comparison aac_parser.c @ 6559:23430438e4e8 libavcodec

use mpeg4audio common code in aac parser
author bcoudurier
date Tue, 01 Apr 2008 12:50:32 +0000
parents 04763b6fd4f0
children 013def14c931
comparison
equal deleted inserted replaced
6558:06b1e0371e90 6559:23430438e4e8
21 */ 21 */
22 22
23 #include "parser.h" 23 #include "parser.h"
24 #include "aac_ac3_parser.h" 24 #include "aac_ac3_parser.h"
25 #include "bitstream.h" 25 #include "bitstream.h"
26 26 #include "mpeg4audio.h"
27 27
28 #define AAC_HEADER_SIZE 7 28 #define AAC_HEADER_SIZE 7
29
30
31 static const int aac_sample_rates[16] = {
32 96000, 88200, 64000, 48000, 44100, 32000,
33 24000, 22050, 16000, 12000, 11025, 8000, 7350
34 };
35
36 static const int aac_channels[8] = {
37 0, 1, 2, 3, 4, 5, 6, 8
38 };
39
40 29
41 static int aac_sync(AACAC3ParseContext *hdr_info, AACAC3FrameFlag *flag) 30 static int aac_sync(AACAC3ParseContext *hdr_info, AACAC3FrameFlag *flag)
42 { 31 {
43 GetBitContext bits; 32 GetBitContext bits;
44 int size, rdb, ch, sr; 33 int size, rdb, ch, sr;
51 skip_bits1(&bits); /* id */ 40 skip_bits1(&bits); /* id */
52 skip_bits(&bits, 2); /* layer */ 41 skip_bits(&bits, 2); /* layer */
53 skip_bits1(&bits); /* protection_absent */ 42 skip_bits1(&bits); /* protection_absent */
54 skip_bits(&bits, 2); /* profile_objecttype */ 43 skip_bits(&bits, 2); /* profile_objecttype */
55 sr = get_bits(&bits, 4); /* sample_frequency_index */ 44 sr = get_bits(&bits, 4); /* sample_frequency_index */
56 if(!aac_sample_rates[sr]) 45 if(!ff_mpeg4audio_sample_rates[sr])
57 return 0; 46 return 0;
58 skip_bits1(&bits); /* private_bit */ 47 skip_bits1(&bits); /* private_bit */
59 ch = get_bits(&bits, 3); /* channel_configuration */ 48 ch = get_bits(&bits, 3); /* channel_configuration */
60 if(!aac_channels[ch]) 49 if(!ff_mpeg4audio_channels[ch])
61 return 0; 50 return 0;
62 skip_bits1(&bits); /* original/copy */ 51 skip_bits1(&bits); /* original/copy */
63 skip_bits1(&bits); /* home */ 52 skip_bits1(&bits); /* home */
64 53
65 /* adts_variable_header */ 54 /* adts_variable_header */
70 return 0; 59 return 0;
71 60
72 skip_bits(&bits, 11); /* adts_buffer_fullness */ 61 skip_bits(&bits, 11); /* adts_buffer_fullness */
73 rdb = get_bits(&bits, 2); /* number_of_raw_data_blocks_in_frame */ 62 rdb = get_bits(&bits, 2); /* number_of_raw_data_blocks_in_frame */
74 63
75 hdr_info->channels = aac_channels[ch]; 64 hdr_info->channels = ff_mpeg4audio_channels[ch];
76 hdr_info->sample_rate = aac_sample_rates[sr]; 65 hdr_info->sample_rate = ff_mpeg4audio_sample_rates[sr];
77 hdr_info->samples = (rdb + 1) * 1024; 66 hdr_info->samples = (rdb + 1) * 1024;
78 hdr_info->bit_rate = size * 8 * hdr_info->sample_rate / hdr_info->samples; 67 hdr_info->bit_rate = size * 8 * hdr_info->sample_rate / hdr_info->samples;
79 *flag = FRAME_COMPLETE; 68 *flag = FRAME_COMPLETE;
80 69
81 return size; 70 return size;