[FFmpeg-devel] [PATCH] 1D DCT for dsputil

Diego Biurrun diego
Tue Dec 22 01:07:14 CET 2009


On Mon, Dec 21, 2009 at 02:02:00PM -0500, Daniel Verkamp wrote:
> 
> --- /dev/null
> +++ b/libavcodec/dct.c
> @@ -0,0 +1,95 @@
> +static void ff_dct_calc_c(DCTContext *s, FFTSample *data)
> +{
> +    int n = 1<<s->nbits;

Spaces around << would make this more readable.

> +#define ROTATE(i,n) (-M_PI*((n)-0.5f)*(i)/(n))

This could also use some spaces.

> +    if (s->inverse) {
> +        for(i=0; i < n; i++) {

K&R places a space after keywords, i.e. "for (".

> +            s->data[i].re = 2 * data[i] * cos(ROTATE(i,n));
> +            s->data[i].im = 2 * data[i] * sin(ROTATE(i,n));
> +        }
> +        s->data[n].re = 0;
> +        s->data[n].im = 0;
> +        for(i=0; i<n-1; i++) {
> +            s->data[n+i+1].re = -2 * data[n - (i+1)] * cos(ROTATE(n+i+1,n));
> +            s->data[n+i+1].im = -2 * data[n - (i+1)] * sin(ROTATE(n+i+1,n));
> +        }
> +    }else{
> +        for(i=0; i < n; i++) {
> +            s->data[i].re = data[n - (i+1)];
> +            s->data[i].im = 0;
> +            s->data[n+i].re = data[i];
> +            s->data[n+i].im = 0;
> +        }
> +    }
> +
> +    ff_fft_permute(&s->fft, s->data);
> +    ff_fft_calc(&s->fft, s->data);
> +
> +    if (s->inverse) {
> +        for(i=0; i < n; i++)
> +            data[i] = s->data[n-(i+1)].re / (2 * n);
> +    }else {
> +        for(i=0; i < n; i++)
> +            data[i] = s->data[i].re / (2 * cos(ROTATE(i,n)));

same in here

This could also use more spaces and some alignment.

Diego



More information about the ffmpeg-devel mailing list