[FFmpeg-devel] NellyMoser transform bug

Benjamin Larsson banan
Wed Oct 24 13:07:41 CEST 2007


Fabrice Bellard wrote:
> Hi,
>
> While looking at the NellyMoser audio decoder, I found a very suspect 
> code which makes the transform incorrect in the sense that there is 
> information loss. So I suggest the attached patch.
>
> Can someone confirm that my code corresponds to what the "reference" 
> decoder does ? If it does, then I confirm that it is possible to 
> convert the code to use the ffmpeg IMDCT code...
>
> Fabrice.
>
>   
This code should be from the unpack_coeffs function in nelly.c from 
http://nelly2pcm.googlecode.com/files/nelly2pcm.tar.bz2. And it looks 
like a typo from my cleanup work. Thanks for catching this and feel free 
to rewrite it to use the regular mdct or tell me how to do it.

static void unpack_coeffs(float *buf, float *audio)
{
    int i, end, mid_hi, mid_lo;
    float a, b, c, d, e, f;

    end = NELLY_BUF_LEN-1;
    mid_hi = NELLY_BUF_LEN/2;
    mid_lo = mid_hi-1;

    for (i = 0; i < NELLY_BUF_LEN/4; i++) {
        a = buf[end-(2*i)];
        b = buf[2*i];
        c = buf[(2*i)+1];
        d = buf[end-(2*i)-1];
        e = nelly_pos_unpack_table[i];
        f = nelly_neg_unpack_table[i];

        audio[2*i] = b*e-a*f;
        audio[(2*i)+1] = a*e+b*f;

        a = nelly_neg_unpack_table[mid_lo-i];
        b = nelly_pos_unpack_table[mid_lo-i];

        audio[end-(2*i)-1] = b*d-a*c;
        audio[end-(2*i)] = b*c+a*d;
    }
}

> ------------------------------------------------------------------------
>
> Index: nellymoserdec.c
> ===================================================================
> --- nellymoserdec.c	(revision 10847)
> +++ nellymoserdec.c	(working copy)
> @@ -125,7 +125,7 @@
>          audio[2*i]      =   buf[2*i      ]*tcos[i       ] - buf[end-2*i]*tsin[i];
>          audio[2*i+1]    = -(buf[end-2*i  ]*tcos[i       ] + buf[2*i    ]*tsin[i]);
>          audio[end-2*i-1]=   buf[end-2*i-1]*tcos[mid_lo-i] - buf[2*i+1  ]*tsin[mid_lo-i];
> -        audio[end-2*i  ]= -(buf[2*i+1    ]*tcos[mid_lo-i] + buf[end-2*i]*tsin[mid_lo-i]);
> +        audio[end-2*i  ]= -(buf[2*i+1    ]*tcos[mid_lo-i] + buf[end-2*i-1]*tsin[mid_lo-i]);
>      }
>  }
>   

MvH
Benjamin Larsson






More information about the ffmpeg-devel mailing list