Revision 01f35453 libavcodec/ac3dec.c

View differences:

libavcodec/ac3dec.c
72 72
/** dynamic range table. converts codes to scale factors. */
73 73
static float dynrng_tbl[256];
74 74

  
75
/** dialogue normalization table */
76
static float dialnorm_tbl[32];
77

  
75 78
/* Adjustmens in dB gain */
76 79
#define LEVEL_MINUS_3DB         0.7071067811865476
77 80
#define LEVEL_MINUS_4POINT5DB   0.5946035575013605
......
159 162
    int      out_channels;      ///< number of output channels
160 163

  
161 164
    float    downmix_coeffs[AC3_MAX_CHANNELS][2];   ///< stereo downmix coefficients
165
    float    dialnorm[2];                       ///< dialogue normalization
162 166
    float    dynrng;            //dynamic range gain
163 167
    float    dynrng2;           //dynamic range gain for 1+1 mode
164 168
    float    cplco[AC3_MAX_CHANNELS][18];   //coupling coordinates
......
269 273
        dynrng_tbl[i] = powf(2.0f, v) * ((i & 0x1F) | 0x20);
270 274
    }
271 275

  
276
    /* generate dialogue normalization table
277
       references: Section 5.4.2.8 dialnorm
278
                   Section 7.6 Dialogue Normalization */
279
    for(i=1; i<32; i++) {
280
        dialnorm_tbl[i] = expf((i-31) * M_LN10 / 20.0f);
281
    }
282
    dialnorm_tbl[0] = dialnorm_tbl[31];
283

  
272 284
    //generate scale factors
273 285
    for (i = 0; i < 25; i++)
274 286
        scale_factors[i] = pow(2.0, -i);
......
362 374
    /* read the rest of the bsi. read twice for dual mono mode. */
363 375
    i = !(ctx->acmod);
364 376
    do {
365
        skip_bits(gb, 5); //skip dialog normalization
377
        ctx->dialnorm[i] = dialnorm_tbl[get_bits(gb, 5)]; // dialogue normalization
366 378
        if (get_bits1(gb))
367 379
            skip_bits(gb, 8); //skip compression
368 380
        if (get_bits1(gb))
......
1007 1019
    if(ctx->acmod == AC3_ACMOD_STEREO)
1008 1020
        do_rematrixing(ctx);
1009 1021

  
1010
    /* apply scaling to coefficients (headroom, dynrng) */
1022
    /* apply scaling to coefficients (headroom, dialnorm, dynrng) */
1011 1023
    for(ch=1; ch<=ctx->nchans; ch++) {
1012 1024
        float gain = 2.0f * ctx->mul_bias;
1013 1025
        if(ctx->acmod == AC3_ACMOD_DUALMONO && ch == 2) {
1014
            gain *= ctx->dynrng2;
1026
            gain *= ctx->dialnorm[ch-1] * ctx->dynrng2;
1015 1027
        } else {
1016
            gain *= ctx->dynrng;
1028
            gain *= ctx->dialnorm[0] * ctx->dynrng;
1017 1029
        }
1018 1030
        for(i=0; i<ctx->endmant[ch]; i++) {
1019 1031
            ctx->transform_coeffs[ch][i] *= gain;

Also available in: Unified diff