[FFmpeg-devel] [PATCH] avfilter/af_dynaudnorm: remove wasteful pow

Ganesh Ajjanagadde gajjanagadde at gmail.com
Thu Nov 26 15:23:55 CET 2015


On Wed, Nov 25, 2015 at 4:16 AM, Paul B Mahol <onemda at gmail.com> wrote:
> On 11/25/15, Ganesh Ajjanagadde <gajjanagadde at gmail.com> wrote:
>> This removes wasteful pow(x, 2.0) that although not terribly important
>> for speed, is still useless.
>>
>> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
>> ------------------------------------------------------------------------------
>> Observed while auditing the codebase for wasteful pow calls.
>>
>> ---
>>  libavfilter/af_dynaudnorm.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/libavfilter/af_dynaudnorm.c b/libavfilter/af_dynaudnorm.c
>> index 62a2653..5f412f5 100644
>> --- a/libavfilter/af_dynaudnorm.c
>> +++ b/libavfilter/af_dynaudnorm.c
>> @@ -237,13 +237,13 @@ static void
>> init_gaussian_filter(DynamicAudioNormalizerContext *s)
>>      // Pre-compute constants
>>      const int offset = s->filter_size / 2;
>>      const double c1 = 1.0 / (sigma * sqrt(2.0 * M_PI));
>> -    const double c2 = 2.0 * pow(sigma, 2.0);
>> +    const double c2 = 2.0 * sigma * sigma;
>>
>>      // Compute weights
>>      for (i = 0; i < s->filter_size; i++) {
>>          const int x = i - offset;
>>
>> -        s->weights[i] = c1 * exp(-(pow(x, 2.0) / c2));
>> +        s->weights[i] = c1 * exp(-x * x / c2);
>>          total_weight += s->weights[i];
>>      }
>>
>> --
>> 2.6.2
>>
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel at ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>
> probably ok

pushed, thanks


More information about the ffmpeg-devel mailing list