annotate ffmpeg/libavcodec/aac_parser.c @ 13:844d341cf643 tip

Back up before ISMIR
author Yading Song <yading.song@eecs.qmul.ac.uk>
date Thu, 31 Oct 2013 13:17:06 +0000
parents 6840f77b83aa
children
rev   line source
yading@10 1 /*
yading@10 2 * Audio and Video frame extraction
yading@10 3 * Copyright (c) 2003 Fabrice Bellard
yading@10 4 * Copyright (c) 2003 Michael Niedermayer
yading@10 5 *
yading@10 6 * This file is part of FFmpeg.
yading@10 7 *
yading@10 8 * FFmpeg is free software; you can redistribute it and/or
yading@10 9 * modify it under the terms of the GNU Lesser General Public
yading@10 10 * License as published by the Free Software Foundation; either
yading@10 11 * version 2.1 of the License, or (at your option) any later version.
yading@10 12 *
yading@10 13 * FFmpeg is distributed in the hope that it will be useful,
yading@10 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
yading@10 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
yading@10 16 * Lesser General Public License for more details.
yading@10 17 *
yading@10 18 * You should have received a copy of the GNU Lesser General Public
yading@10 19 * License along with FFmpeg; if not, write to the Free Software
yading@10 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
yading@10 21 */
yading@10 22
yading@10 23 #include "parser.h"
yading@10 24 #include "aac_ac3_parser.h"
yading@10 25 #include "aacadtsdec.h"
yading@10 26 #include "get_bits.h"
yading@10 27 #include "mpeg4audio.h"
yading@10 28
yading@10 29 static int aac_sync(uint64_t state, AACAC3ParseContext *hdr_info,
yading@10 30 int *need_next_header, int *new_frame_start)
yading@10 31 {
yading@10 32 GetBitContext bits;
yading@10 33 AACADTSHeaderInfo hdr;
yading@10 34 int size;
yading@10 35 union {
yading@10 36 uint64_t u64;
yading@10 37 uint8_t u8[8];
yading@10 38 } tmp;
yading@10 39
yading@10 40 tmp.u64 = av_be2ne64(state);
yading@10 41 init_get_bits(&bits, tmp.u8+8-AAC_ADTS_HEADER_SIZE, AAC_ADTS_HEADER_SIZE * 8);
yading@10 42
yading@10 43 if ((size = avpriv_aac_parse_header(&bits, &hdr)) < 0)
yading@10 44 return 0;
yading@10 45 *need_next_header = 0;
yading@10 46 *new_frame_start = 1;
yading@10 47 hdr_info->sample_rate = hdr.sample_rate;
yading@10 48 hdr_info->channels = ff_mpeg4audio_channels[hdr.chan_config];
yading@10 49 hdr_info->samples = hdr.samples;
yading@10 50 hdr_info->bit_rate = hdr.bit_rate;
yading@10 51 return size;
yading@10 52 }
yading@10 53
yading@10 54 static av_cold int aac_parse_init(AVCodecParserContext *s1)
yading@10 55 {
yading@10 56 AACAC3ParseContext *s = s1->priv_data;
yading@10 57 s->header_size = AAC_ADTS_HEADER_SIZE;
yading@10 58 s->sync = aac_sync;
yading@10 59 return 0;
yading@10 60 }
yading@10 61
yading@10 62
yading@10 63 AVCodecParser ff_aac_parser = {
yading@10 64 .codec_ids = { AV_CODEC_ID_AAC },
yading@10 65 .priv_data_size = sizeof(AACAC3ParseContext),
yading@10 66 .parser_init = aac_parse_init,
yading@10 67 .parser_parse = ff_aac_ac3_parse,
yading@10 68 .parser_close = ff_parse_close,
yading@10 69 };