[FFmpeg-devel] [PATCH] avcodec/opus_celt: replace pow by exp2

Ganesh Ajjanagadde gajjanag at mit.edu
Thu Dec 17 23:10:47 CET 2015


On Thu, Dec 17, 2015 at 11:10 AM, Paul B Mahol <onemda at gmail.com> wrote:
> On 12/17/15, Ganesh Ajjanagadde <gajjanagadde at gmail.com> wrote:
>> exp2 is faster.
>>
>> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
>> ---
>>  libavcodec/opus_celt.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/libavcodec/opus_celt.c b/libavcodec/opus_celt.c
>> index 9911de3..474452f 100644
>> --- a/libavcodec/opus_celt.c
>> +++ b/libavcodec/opus_celt.c
>> @@ -1677,7 +1677,7 @@ static void celt_denormalize(CeltContext *s, CeltFrame
>> *frame, float *data)
>>
>>      for (i = s->startband; i < s->endband; i++) {
>>          float *dst = data + (celt_freq_bands[i] << s->duration);
>> -        float norm = pow(2, frame->energy[i] + celt_mean_energy[i]);
>> +        float norm = exp2(frame->energy[i] + celt_mean_energy[i]);
>>
>>          for (j = 0; j < celt_freq_range[i] << s->duration; j++)
>>              dst[j] *= norm;
>> @@ -1857,7 +1857,7 @@ static void process_anticollapse(CeltContext *s,
>> CeltFrame *frame, float *X)
>>
>>          /* r needs to be multiplied by 2 or 2*sqrt(2) depending on LM
>> because
>>          short blocks don't have the same energy as long */
>> -        r = pow(2, 1 - Ediff);
>> +        r = exp2(1 - Ediff);
>>          if (s->duration == 3)
>>              r *= M_SQRT2;
>>          r = FFMIN(thresh, r) * sqrt_1;
>> --
>> 2.6.3
>>
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel at ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>
> should be ok iff fate passes.

FATE does pass on my GNU/Linux setup, so pushed. Thanks.

BTW: there is likely some things that can be done, since the exponent
seems to be a multiple of 0.25. Left as it needs study, but added to
commit message for reference.

> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


More information about the ffmpeg-devel mailing list