Revision 55736cfb libavcodec/ac3dec.c

View differences:

libavcodec/ac3dec.c
89 89
};
90 90

  
91 91
/**
92
 * Table for center mix levels
93
 * reference: Section 5.4.2.4 cmixlev
94
 */
95
static const uint8_t center_levels[4] = { 2, 3, 4, 3 };
96

  
97
/**
98
 * Table for surround mix levels
99
 * reference: Section 5.4.2.5 surmixlev
100
 */
101
static const uint8_t surround_levels[4] = { 2, 4, 0, 4 };
102

  
103
/**
104 92
 * Table for default stereo downmixing coefficients
105 93
 * reference: Section 7.8.2 Downmixing Into Two Channels
106 94
 */
......
315 303
    GetBitContext *gbc = &s->gbc;
316 304
    int err, i;
317 305

  
318
    err = ff_ac3_parse_header(gbc->buffer, &hdr);
306
    err = ff_ac3_parse_header(gbc, &hdr);
319 307
    if(err)
320 308
        return err;
321 309

  
......
333 321
    s->fbw_channels                 = s->channels - s->lfe_on;
334 322
    s->lfe_ch                       = s->fbw_channels + 1;
335 323
    s->frame_size                   = hdr.frame_size;
324
    s->center_mix_level             = hdr.center_mix_level;
325
    s->surround_mix_level           = hdr.surround_mix_level;
336 326

  
337 327
    /* set default output to all source channels */
338 328
    s->out_channels = s->channels;
......
340 330
    if(s->lfe_on)
341 331
        s->output_mode |= AC3_OUTPUT_LFEON;
342 332

  
343
    /* set default mix levels */
344
    s->center_mix_level   = 3;  // -4.5dB
345
    s->surround_mix_level = 4;  // -6.0dB
346

  
347
    /* skip over portion of header which has already been read */
348
    skip_bits(gbc, 16); // skip the sync_word
349
    skip_bits(gbc, 16); // skip crc1
350
    skip_bits(gbc, 8);  // skip fscod and frmsizecod
351
    skip_bits(gbc, 11); // skip bsid, bsmod, and acmod
352
    if(s->channel_mode == AC3_CHMODE_STEREO) {
353
        skip_bits(gbc, 2); // skip dsurmod
354
    } else {
355
        if((s->channel_mode & 1) && s->channel_mode != AC3_CHMODE_MONO)
356
            s->center_mix_level = center_levels[get_bits(gbc, 2)];
357
        if(s->channel_mode & 4)
358
            s->surround_mix_level = surround_levels[get_bits(gbc, 2)];
359
    }
360
    skip_bits1(gbc); // skip lfeon
361

  
362 333
    /* read the rest of the bsi. read twice for dual mono mode. */
363 334
    i = !(s->channel_mode);
364 335
    do {

Also available in: Unified diff