[FFmpeg-devel] [PATCH] psy_snr:Psychoacoustic SNR for audio files

Claudio Freire klaussfreire at gmail.com
Fri Oct 31 23:09:36 CET 2014


I notice you have tons of c++-isms you should check:

On Thu, Oct 30, 2014 at 3:03 PM, Senjuti Kundu <senjutikundu93 at gmail.com> wrote:
> +    int i = 0;
> +    float* maskingfunc = malloc(tempsize*sizeof(float));
> +    maskingfunc[tempsize/2] = exp(-db_attenuation*log(10));

Split declaration and initialization, as explained on an earlier post.

> +    int i = 0;
> +    int j = 0;
> +    float* mask = malloc(tempsize*sizeof(float));
> +    float self = 0;
> +    float next = 0;
> +    float prev = 0;

Also here

(and several other places)

> +        DECLARE_ALIGNED(32, FFTComplex, fftcomplexa)[SIZE/len];
> +        DECLARE_ALIGNED(32, FFTComplex, fftcomplexb)[SIZE/len];

That len is a compile-time variable, not constant, as required by C
for sizes. Just remove the /len, a buffer of SIZE complex values will
always be bigger.

Alternatively, you can use alloca.

> +        FFTContext* fftcontexta = av_fft_init(floor(log2(SIZE/len)),0);
> +        av_fft_permute (fftcontexta, fftcomplexa);
> +        int temp = 0;
> +        av_fft_calc (fftcontexta, fftcomplexa);
> +        FFTContext* fftcontextb = av_fft_init(floor(log2(SIZE/len)),0);
> +        av_fft_permute (fftcontextb, fftcomplexb);
> +        av_fft_calc (fftcontextb, fftcomplexb);

You don't need to initialize on every iteration. Move the av_fft_init
outside the loops.

Also, don't declare variables in the middle of blocks, that's C++. All
declarations should go at the beginning of the enclosing block.


More information about the ffmpeg-devel mailing list