[Ffmpeg-devel] ac3 encoder

Justin Ruggles jruggle
Sun Apr 24 21:46:40 CEST 2005


Benjamin Larsson wrote:

> Hi,
>
> Justin Ruggles wrote:
>
>> I've been playing around with the AC3 encoder in ffmpeg hoping to 
>> make some improvements.  Right now I've added stereo matrixing for 
>> 2-channel audio, and I've been experimenting with some different 
>> exponent strategy algorithms.  I've made an attempt at block 
>> switching, but can't figure out how to get the short-block mdct to 
>> work with fft, so right now it's extremely slow doing it the O(n^2) 
>> way.  I have plans to try my luck at channel coupling as well.
>>
> Contact me in private or post some example code to the list and I 
> might be able to help with the mdct code.

Hello,
I'm just 1 step away from getting the short-block mdct working.  I need 
to figure out exactly how to implement a type-iv dct using fft.  It 
seems like anytime I find a reference that would be helpful, I need a 
subscription to ACM or IEEE to read the paper.  I would greatly 
appreciate any help or good references I can get.
-Justin

Right now, this is what I have for the short block mdct's doing it the 
slow way.  mdct256() takes the same parameters as mdct512().  It sounds 
good, but it's at least 30X slower than mdct512().

static void
dct4_128(int32_t *in, int32_t *out)
{
    int k, n;
    for(k=0; k<128; k++) {
        out[k] = 0;
        for(n=0; n<128; n++) {
            out[k] += in[n] * cos(M_PI/128.0*(n+0.5)*(k+0.5));
        }
        out[k] = -out[k] >> 7;
    }
}

static void
mdct256(int32_t *out, int16_t *in)
{
    int i;
    int32_t coef_a[128];
    int32_t coef_b[128];
    int32_t xx[128];
    for(i=0; i<128; i++) {
        xx[i] = (int)in[i]-(int)in[255-i];
    }
    dct4_128(xx, coef_a);

    for(i=256; i<384; i++) {
        xx[i-256] = ((int)-in[i+128]) - ((int)in[640-i]);
    }
    dct4_128(xx, coef_b);

    for(i=0; i<128; i++) {
        out[2*i] = coef_a[i];
        out[2*i+1] = coef_b[i];
    }
}





More information about the ffmpeg-devel mailing list