Mercurial > libavcodec.hg
comparison ac3_parser.c @ 7019:81d5c68233e5 libavcodec
move mix level tables from parser to decoder. have parser read bitstream value instead of using an index to a table in the decoder.
author | jbr |
---|---|
date | Sat, 07 Jun 2008 22:30:09 +0000 |
parents | 885cad616170 |
children | 1f85910c9ab2 |
comparison
equal
deleted
inserted
replaced
7018:885cad616170 | 7019:81d5c68233e5 |
---|---|
31 | 31 |
32 static const uint8_t eac3_blocks[4] = { | 32 static const uint8_t eac3_blocks[4] = { |
33 1, 2, 3, 6 | 33 1, 2, 3, 6 |
34 }; | 34 }; |
35 | 35 |
36 /** | |
37 * Table for center mix levels | |
38 * reference: Section 5.4.2.4 cmixlev | |
39 */ | |
40 static const uint8_t center_levels[4] = { 4, 5, 6, 5 }; | |
41 | |
42 /** | |
43 * Table for surround mix levels | |
44 * reference: Section 5.4.2.5 surmixlev | |
45 */ | |
46 static const uint8_t surround_levels[4] = { 4, 6, 7, 6 }; | |
47 | |
48 | 36 |
49 int ff_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr) | 37 int ff_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr) |
50 { | 38 { |
51 int frame_size_code; | 39 int frame_size_code; |
52 | 40 |
62 return AC3_PARSE_ERROR_BSID; | 50 return AC3_PARSE_ERROR_BSID; |
63 | 51 |
64 hdr->num_blocks = 6; | 52 hdr->num_blocks = 6; |
65 | 53 |
66 /* set default mix levels */ | 54 /* set default mix levels */ |
67 hdr->center_mix_level = 3; // -4.5dB | 55 hdr->center_mix_level = 1; // -4.5dB |
68 hdr->surround_mix_level = 4; // -6.0dB | 56 hdr->surround_mix_level = 1; // -6.0dB |
69 | 57 |
70 if(hdr->bitstream_id <= 10) { | 58 if(hdr->bitstream_id <= 10) { |
71 /* Normal AC-3 */ | 59 /* Normal AC-3 */ |
72 hdr->crc1 = get_bits(gbc, 16); | 60 hdr->crc1 = get_bits(gbc, 16); |
73 hdr->sr_code = get_bits(gbc, 2); | 61 hdr->sr_code = get_bits(gbc, 2); |
85 | 73 |
86 if(hdr->channel_mode == AC3_CHMODE_STEREO) { | 74 if(hdr->channel_mode == AC3_CHMODE_STEREO) { |
87 skip_bits(gbc, 2); // skip dsurmod | 75 skip_bits(gbc, 2); // skip dsurmod |
88 } else { | 76 } else { |
89 if((hdr->channel_mode & 1) && hdr->channel_mode != AC3_CHMODE_MONO) | 77 if((hdr->channel_mode & 1) && hdr->channel_mode != AC3_CHMODE_MONO) |
90 hdr->center_mix_level = center_levels[get_bits(gbc, 2)]; | 78 hdr->center_mix_level = get_bits(gbc, 2); |
91 if(hdr->channel_mode & 4) | 79 if(hdr->channel_mode & 4) |
92 hdr->surround_mix_level = surround_levels[get_bits(gbc, 2)]; | 80 hdr->surround_mix_level = get_bits(gbc, 2); |
93 } | 81 } |
94 hdr->lfe_on = get_bits1(gbc); | 82 hdr->lfe_on = get_bits1(gbc); |
95 | 83 |
96 hdr->sr_shift = FFMAX(hdr->bitstream_id, 8) - 8; | 84 hdr->sr_shift = FFMAX(hdr->bitstream_id, 8) - 8; |
97 hdr->sample_rate = ff_ac3_sample_rate_tab[hdr->sr_code] >> hdr->sr_shift; | 85 hdr->sample_rate = ff_ac3_sample_rate_tab[hdr->sr_code] >> hdr->sr_shift; |