Mercurial > libavcodec.hg
comparison ac3_parser.c @ 7011:77f607fb4e8b libavcodec
get the number of blocks from the ac3 parser and use in the ac3 decoder.
author | jbr |
---|---|
date | Sat, 07 Jun 2008 22:29:03 +0000 |
parents | 2d0b86dfe5bb |
children | 4156c54aedba |
comparison
equal
deleted
inserted
replaced
7010:942e0bd99179 | 7011:77f607fb4e8b |
---|---|
47 | 47 |
48 | 48 |
49 int ff_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr) | 49 int ff_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr) |
50 { | 50 { |
51 int frame_size_code; | 51 int frame_size_code; |
52 int num_blocks; | |
53 | 52 |
54 memset(hdr, 0, sizeof(*hdr)); | 53 memset(hdr, 0, sizeof(*hdr)); |
55 | 54 |
56 hdr->sync_word = get_bits(gbc, 16); | 55 hdr->sync_word = get_bits(gbc, 16); |
57 if(hdr->sync_word != 0x0B77) | 56 if(hdr->sync_word != 0x0B77) |
59 | 58 |
60 /* read ahead to bsid to distinguish between AC-3 and E-AC-3 */ | 59 /* read ahead to bsid to distinguish between AC-3 and E-AC-3 */ |
61 hdr->bitstream_id = show_bits_long(gbc, 29) & 0x1F; | 60 hdr->bitstream_id = show_bits_long(gbc, 29) & 0x1F; |
62 if(hdr->bitstream_id > 16) | 61 if(hdr->bitstream_id > 16) |
63 return AC3_PARSE_ERROR_BSID; | 62 return AC3_PARSE_ERROR_BSID; |
63 | |
64 hdr->num_blocks = 6; | |
64 | 65 |
65 if(hdr->bitstream_id <= 10) { | 66 if(hdr->bitstream_id <= 10) { |
66 /* Normal AC-3 */ | 67 /* Normal AC-3 */ |
67 hdr->crc1 = get_bits(gbc, 16); | 68 hdr->crc1 = get_bits(gbc, 16); |
68 hdr->sr_code = get_bits(gbc, 2); | 69 hdr->sr_code = get_bits(gbc, 2); |
116 int sr_code2 = get_bits(gbc, 2); | 117 int sr_code2 = get_bits(gbc, 2); |
117 if(sr_code2 == 3) | 118 if(sr_code2 == 3) |
118 return AC3_PARSE_ERROR_SAMPLE_RATE; | 119 return AC3_PARSE_ERROR_SAMPLE_RATE; |
119 hdr->sample_rate = ff_ac3_sample_rate_tab[sr_code2] / 2; | 120 hdr->sample_rate = ff_ac3_sample_rate_tab[sr_code2] / 2; |
120 hdr->sr_shift = 1; | 121 hdr->sr_shift = 1; |
121 num_blocks = 6; | |
122 } else { | 122 } else { |
123 num_blocks = eac3_blocks[get_bits(gbc, 2)]; | 123 hdr->num_blocks = eac3_blocks[get_bits(gbc, 2)]; |
124 hdr->sample_rate = ff_ac3_sample_rate_tab[hdr->sr_code]; | 124 hdr->sample_rate = ff_ac3_sample_rate_tab[hdr->sr_code]; |
125 hdr->sr_shift = 0; | 125 hdr->sr_shift = 0; |
126 } | 126 } |
127 | 127 |
128 hdr->channel_mode = get_bits(gbc, 3); | 128 hdr->channel_mode = get_bits(gbc, 3); |
129 hdr->lfe_on = get_bits1(gbc); | 129 hdr->lfe_on = get_bits1(gbc); |
130 | 130 |
131 hdr->bit_rate = (uint32_t)(8.0 * hdr->frame_size * hdr->sample_rate / | 131 hdr->bit_rate = (uint32_t)(8.0 * hdr->frame_size * hdr->sample_rate / |
132 (num_blocks * 256.0)); | 132 (hdr->num_blocks * 256.0)); |
133 hdr->channels = ff_ac3_channels_tab[hdr->channel_mode] + hdr->lfe_on; | 133 hdr->channels = ff_ac3_channels_tab[hdr->channel_mode] + hdr->lfe_on; |
134 } | 134 } |
135 | 135 |
136 return 0; | 136 return 0; |
137 } | 137 } |