00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "aac_ac3_parser.h"
00025 #include "aacadtsdec.h"
00026 #include "get_bits.h"
00027 #include "mpeg4audio.h"
00028
00029 int ff_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr)
00030 {
00031 int size, rdb, ch, sr;
00032 int aot, crc_abs;
00033
00034 if(get_bits(gbc, 12) != 0xfff)
00035 return AAC_AC3_PARSE_ERROR_SYNC;
00036
00037 skip_bits1(gbc);
00038 skip_bits(gbc, 2);
00039 crc_abs = get_bits1(gbc);
00040 aot = get_bits(gbc, 2);
00041 sr = get_bits(gbc, 4);
00042 if(!ff_mpeg4audio_sample_rates[sr])
00043 return AAC_AC3_PARSE_ERROR_SAMPLE_RATE;
00044 skip_bits1(gbc);
00045 ch = get_bits(gbc, 3);
00046
00047 skip_bits1(gbc);
00048 skip_bits1(gbc);
00049
00050
00051 skip_bits1(gbc);
00052 skip_bits1(gbc);
00053 size = get_bits(gbc, 13);
00054 if(size < AAC_ADTS_HEADER_SIZE)
00055 return AAC_AC3_PARSE_ERROR_FRAME_SIZE;
00056
00057 skip_bits(gbc, 11);
00058 rdb = get_bits(gbc, 2);
00059
00060 hdr->object_type = aot + 1;
00061 hdr->chan_config = ch;
00062 hdr->crc_absent = crc_abs;
00063 hdr->num_aac_frames = rdb + 1;
00064 hdr->sampling_index = sr;
00065 hdr->sample_rate = ff_mpeg4audio_sample_rates[sr];
00066 hdr->samples = (rdb + 1) * 1024;
00067 hdr->bit_rate = size * 8 * hdr->sample_rate / hdr->samples;
00068
00069 return size;
00070 }