00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "parser.h"
00024 #include "aac_ac3_parser.h"
00025 #include "aacadtsdec.h"
00026 #include "get_bits.h"
00027 #include "mpeg4audio.h"
00028
00029 static int aac_sync(uint64_t state, AACAC3ParseContext *hdr_info,
00030 int *need_next_header, int *new_frame_start)
00031 {
00032 GetBitContext bits;
00033 AACADTSHeaderInfo hdr;
00034 int size;
00035 union {
00036 uint64_t u64;
00037 uint8_t u8[8];
00038 } tmp;
00039
00040 tmp.u64 = av_be2ne64(state);
00041 init_get_bits(&bits, tmp.u8+8-AAC_ADTS_HEADER_SIZE, AAC_ADTS_HEADER_SIZE * 8);
00042
00043 if ((size = avpriv_aac_parse_header(&bits, &hdr)) < 0)
00044 return 0;
00045 *need_next_header = 0;
00046 *new_frame_start = 1;
00047 hdr_info->sample_rate = hdr.sample_rate;
00048 hdr_info->channels = ff_mpeg4audio_channels[hdr.chan_config];
00049 hdr_info->samples = hdr.samples;
00050 hdr_info->bit_rate = hdr.bit_rate;
00051 return size;
00052 }
00053
00054 static av_cold int aac_parse_init(AVCodecParserContext *s1)
00055 {
00056 AACAC3ParseContext *s = s1->priv_data;
00057 s->header_size = AAC_ADTS_HEADER_SIZE;
00058 s->sync = aac_sync;
00059 return 0;
00060 }
00061
00062
00063 AVCodecParser ff_aac_parser = {
00064 .codec_ids = { AV_CODEC_ID_AAC },
00065 .priv_data_size = sizeof(AACAC3ParseContext),
00066 .parser_init = aac_parse_init,
00067 .parser_parse = ff_aac_ac3_parse,
00068 .parser_close = ff_parse_close,
00069 };