[FFmpeg-devel] [PATCH] avfilter/avf_showfreqs: avoid wasteful pow

Ganesh Ajjanagadde gajjanagadde at gmail.com
Thu Dec 10 02:11:30 CET 2015


On Wed, Dec 9, 2015 at 6:11 PM, Paul B Mahol <onemda at gmail.com> wrote:
> On 12/9/15, Ganesh Ajjanagadde <gajjanagadde at gmail.com> wrote:
>> pow is a ridiculous function for computing a simple Gaussian.
>>
>> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
>> ---
>>  libavfilter/avf_showfreqs.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavfilter/avf_showfreqs.c b/libavfilter/avf_showfreqs.c
>> index a3665ef..3ed0155 100644
>> --- a/libavfilter/avf_showfreqs.c
>> +++ b/libavfilter/avf_showfreqs.c
>> @@ -227,8 +227,9 @@ static void generate_window_func(float *lut, int N, int
>> win_func, float *overlap
>>          *overlap = 0.75;
>>          break;
>>      case WFUNC_GAUSS:
>> +#define SQR(x) ((x)*(x))
>>          for (n = 0; n < N; n++)
>> -            lut[n] = pow(M_E,-0.5*pow((n-(N-1)/2)/(0.4*(N-1)/2.f),2));
>> +            lut[n] = exp(-0.5 * SQR((n-(N-1)/2)/(0.4*(N-1)/2.f)));
>>          *overlap = 0.75;
>>          break;
>>      default:
>> --
>> 2.6.3
>
> OK

pushed, thanks


More information about the ffmpeg-devel mailing list