Changeset 1155806be963b2229168227b093a763650c604ff

Show
Ignore:
Timestamp:
21/10/07 18:00:27 (1 year ago)
Author:
Laurent Aimar <fenrir@videolan.org>
git-committer:
Laurent Aimar <fenrir@videolan.org> 1192982427 +0000
git-parent:

[9c4f520e6526f194e27b9d293132a492de05dde8]

git-author:
Laurent Aimar <fenrir@videolan.org> 1192982427 +0000
Message:

Increase rate/speed control granularity.
We now have:

1x 1.5x 2x 3x 4x 8x (and the same for slower).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/input/input.c

    r9b62d74 r1155806  
    16751675            int i_rate; 
    16761676 
    1677             if( i_type == INPUT_CONTROL_SET_RATE_SLOWER
    1678                 i_rate = p_input->p->i_rate * 2; 
    1679             else if( i_type == INPUT_CONTROL_SET_RATE_FASTER ) 
    1680                 i_rate = p_input->p->i_rate / 2; 
     1677            if( i_type == INPUT_CONTROL_SET_RATE
     1678            { 
     1679                i_rate = val.i_int; 
     1680            } 
    16811681            else 
    1682                 i_rate = val.i_int; 
     1682            { 
     1683                static const int ppi_factor[][2] = { 
     1684                    {1,64}, {1,32}, {1,16}, {1,8}, {1,4}, {1,3}, {1,2}, {2,3}, 
     1685                    {1,1}, 
     1686                    {3,2}, {2,1}, {3,1}, {4,1}, {8,1}, {16,1}, {32,1}, {64,1}, 
     1687                    {0,0} 
     1688                }; 
     1689                int i_error; 
     1690                int i_idx; 
     1691                int i; 
     1692 
     1693                i_error = INT_MAX; 
     1694                i_idx = -1; 
     1695                for( i = 0; ppi_factor[i][0] != 0; i++ ) 
     1696                { 
     1697                    const int i_test_r = INPUT_RATE_DEFAULT * ppi_factor[i][0] / ppi_factor[i][1]; 
     1698                    const int i_test_e = abs(p_input->p->i_rate - i_test_r); 
     1699                    if( i_test_e < i_error ) 
     1700                    { 
     1701                        i_idx = i; 
     1702                        i_error = i_test_e; 
     1703                    } 
     1704                } 
     1705                assert( i_idx >= 0 && ppi_factor[i_idx][0] != 0 ); 
     1706 
     1707                if( i_type == INPUT_CONTROL_SET_RATE_SLOWER ) 
     1708                { 
     1709                    if( ppi_factor[i_idx+1][0] > 0 ) 
     1710                        i_rate = INPUT_RATE_DEFAULT * ppi_factor[i_idx+1][0] / ppi_factor[i_idx+1][1]; 
     1711                    else 
     1712                        i_rate = INPUT_RATE_MAX+1; 
     1713                } 
     1714                else 
     1715                { 
     1716                    assert( i_type == INPUT_CONTROL_SET_RATE_FASTER ); 
     1717                    if( i_idx > 0 ) 
     1718                        i_rate = INPUT_RATE_DEFAULT * ppi_factor[i_idx-1][0] / ppi_factor[i_idx-1][1]; 
     1719                    else 
     1720                        i_rate = INPUT_RATE_MIN-1; 
     1721                } 
     1722            } 
    16831723 
    16841724            if( i_rate < INPUT_RATE_MIN )