Mercurial > libavcodec.hg
comparison ac3_parser.c @ 8545:a5402e89a80c libavcodec
Factorise enum of AC3 error types to be usable by AAC in the ADTS patch that
will follow
Patch by Alex Converse ( alex converse gmail com )
author | superdump |
---|---|
date | Wed, 07 Jan 2009 18:10:10 +0000 |
parents | c34d5e164b22 |
children | 04423b2f6e0b |
comparison
equal
deleted
inserted
replaced
8544:0ae8629baf6f | 8545:a5402e89a80c |
---|---|
40 | 40 |
41 memset(hdr, 0, sizeof(*hdr)); | 41 memset(hdr, 0, sizeof(*hdr)); |
42 | 42 |
43 hdr->sync_word = get_bits(gbc, 16); | 43 hdr->sync_word = get_bits(gbc, 16); |
44 if(hdr->sync_word != 0x0B77) | 44 if(hdr->sync_word != 0x0B77) |
45 return AC3_PARSE_ERROR_SYNC; | 45 return AAC_AC3_PARSE_ERROR_SYNC; |
46 | 46 |
47 /* read ahead to bsid to distinguish between AC-3 and E-AC-3 */ | 47 /* read ahead to bsid to distinguish between AC-3 and E-AC-3 */ |
48 hdr->bitstream_id = show_bits_long(gbc, 29) & 0x1F; | 48 hdr->bitstream_id = show_bits_long(gbc, 29) & 0x1F; |
49 if(hdr->bitstream_id > 16) | 49 if(hdr->bitstream_id > 16) |
50 return AC3_PARSE_ERROR_BSID; | 50 return AAC_AC3_PARSE_ERROR_BSID; |
51 | 51 |
52 hdr->num_blocks = 6; | 52 hdr->num_blocks = 6; |
53 | 53 |
54 /* set default mix levels */ | 54 /* set default mix levels */ |
55 hdr->center_mix_level = 1; // -4.5dB | 55 hdr->center_mix_level = 1; // -4.5dB |
58 if(hdr->bitstream_id <= 10) { | 58 if(hdr->bitstream_id <= 10) { |
59 /* Normal AC-3 */ | 59 /* Normal AC-3 */ |
60 hdr->crc1 = get_bits(gbc, 16); | 60 hdr->crc1 = get_bits(gbc, 16); |
61 hdr->sr_code = get_bits(gbc, 2); | 61 hdr->sr_code = get_bits(gbc, 2); |
62 if(hdr->sr_code == 3) | 62 if(hdr->sr_code == 3) |
63 return AC3_PARSE_ERROR_SAMPLE_RATE; | 63 return AAC_AC3_PARSE_ERROR_SAMPLE_RATE; |
64 | 64 |
65 frame_size_code = get_bits(gbc, 6); | 65 frame_size_code = get_bits(gbc, 6); |
66 if(frame_size_code > 37) | 66 if(frame_size_code > 37) |
67 return AC3_PARSE_ERROR_FRAME_SIZE; | 67 return AAC_AC3_PARSE_ERROR_FRAME_SIZE; |
68 | 68 |
69 skip_bits(gbc, 5); // skip bsid, already got it | 69 skip_bits(gbc, 5); // skip bsid, already got it |
70 | 70 |
71 skip_bits(gbc, 3); // skip bitstream mode | 71 skip_bits(gbc, 3); // skip bitstream mode |
72 hdr->channel_mode = get_bits(gbc, 3); | 72 hdr->channel_mode = get_bits(gbc, 3); |
91 } else { | 91 } else { |
92 /* Enhanced AC-3 */ | 92 /* Enhanced AC-3 */ |
93 hdr->crc1 = 0; | 93 hdr->crc1 = 0; |
94 hdr->frame_type = get_bits(gbc, 2); | 94 hdr->frame_type = get_bits(gbc, 2); |
95 if(hdr->frame_type == EAC3_FRAME_TYPE_RESERVED) | 95 if(hdr->frame_type == EAC3_FRAME_TYPE_RESERVED) |
96 return AC3_PARSE_ERROR_FRAME_TYPE; | 96 return AAC_AC3_PARSE_ERROR_FRAME_TYPE; |
97 | 97 |
98 hdr->substreamid = get_bits(gbc, 3); | 98 hdr->substreamid = get_bits(gbc, 3); |
99 | 99 |
100 hdr->frame_size = (get_bits(gbc, 11) + 1) << 1; | 100 hdr->frame_size = (get_bits(gbc, 11) + 1) << 1; |
101 if(hdr->frame_size < AC3_HEADER_SIZE) | 101 if(hdr->frame_size < AC3_HEADER_SIZE) |
102 return AC3_PARSE_ERROR_FRAME_SIZE; | 102 return AAC_AC3_PARSE_ERROR_FRAME_SIZE; |
103 | 103 |
104 hdr->sr_code = get_bits(gbc, 2); | 104 hdr->sr_code = get_bits(gbc, 2); |
105 if (hdr->sr_code == 3) { | 105 if (hdr->sr_code == 3) { |
106 int sr_code2 = get_bits(gbc, 2); | 106 int sr_code2 = get_bits(gbc, 2); |
107 if(sr_code2 == 3) | 107 if(sr_code2 == 3) |
108 return AC3_PARSE_ERROR_SAMPLE_RATE; | 108 return AAC_AC3_PARSE_ERROR_SAMPLE_RATE; |
109 hdr->sample_rate = ff_ac3_sample_rate_tab[sr_code2] / 2; | 109 hdr->sample_rate = ff_ac3_sample_rate_tab[sr_code2] / 2; |
110 hdr->sr_shift = 1; | 110 hdr->sr_shift = 1; |
111 } else { | 111 } else { |
112 hdr->num_blocks = eac3_blocks[get_bits(gbc, 2)]; | 112 hdr->num_blocks = eac3_blocks[get_bits(gbc, 2)]; |
113 hdr->sample_rate = ff_ac3_sample_rate_tab[hdr->sr_code]; | 113 hdr->sample_rate = ff_ac3_sample_rate_tab[hdr->sr_code]; |