[FFmpeg-devel] [PATCH] One more shared func for SIPR and AMR

Vitor Sessak vitor1001
Sat Nov 14 22:43:59 CET 2009


Michael Niedermayer wrote:
> On Wed, Nov 11, 2009 at 06:03:40PM +0100, Vitor Sessak wrote:
>> $subj.
>>
>> -Vitor
> 
>>  acelp_pitch_delay.c |   48 ++++++++++++++++++++++++++++++++++++++++++++++++
>>  acelp_pitch_delay.h |   18 ++++++++++++++++++
>>  2 files changed, 66 insertions(+)
>> e0460b2f9e7167632ea6c730a18eb19f8b71e2f9  pitch_lag.diff
>> Index: libavcodec/acelp_pitch_delay.c
>> ===================================================================
>> --- libavcodec/acelp_pitch_delay.c	(revision 20431)
>> +++ libavcodec/acelp_pitch_delay.c	(working copy)
>> @@ -140,3 +140,51 @@
>>  
>>      return val;
>>  }
>> +
>> +void ff_decode_pitch_lag(int *lag_int, int *lag_frac, int pitch_index,
>> +                         const int prev_lag_int, const int subframe,
>> +                         int third_as_first, int resolution)
>> +{
>> +    /* Note n * 10923 >> 15 is floor(x/3) for 0 <= n <= 32767 */
>> +    if (subframe == 0 ||
>> +        (subframe == 2 && third_as_first)) {
>> +        if (pitch_index < 197) {
>> +            *lag_int  = (pitch_index + 59) * 10923 >> 15;
>> +            *lag_frac = pitch_index - *lag_int * 3 + 58;
>> +        } else {
>> +            *lag_int  = pitch_index - 112;
>> +            *lag_frac = 0;
>> +        }
> 
> maybe this function could be clearer if the int/frac split was factored out
> and done at the end?
> above could be something like:
> 
> if(pitch_index < 197) pitch_index += 59
> else                  pitch_index = 3*pitch_index - 335
> 
> *lag_int  = pitch_index * 10923 >> 15;
> *lag_frac = pitch_index - *lag_int * 3 - 1;
> 
> but this of course makes only sense if its not meassureable slower in
> reality and actually clearer

The function is not speed critical and this indeed makes the function 
less obfuscated. New patch attached.

-Vitor
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pitch_lag2.diff
Type: text/x-patch
Size: 3442 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20091114/cdc71c6b/attachment.bin>



More information about the ffmpeg-devel mailing list