annotate ffmpeg/libavcodec/aacadtsdec.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 * Copyright (c) 2009 Alex Converse
yading@10 6 *
yading@10 7 * This file is part of FFmpeg.
yading@10 8 *
yading@10 9 * FFmpeg is free software; you can redistribute it and/or
yading@10 10 * modify it under the terms of the GNU Lesser General Public
yading@10 11 * License as published by the Free Software Foundation; either
yading@10 12 * version 2.1 of the License, or (at your option) any later version.
yading@10 13 *
yading@10 14 * FFmpeg is distributed in the hope that it will be useful,
yading@10 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
yading@10 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
yading@10 17 * Lesser General Public License for more details.
yading@10 18 *
yading@10 19 * You should have received a copy of the GNU Lesser General Public
yading@10 20 * License along with FFmpeg; if not, write to the Free Software
yading@10 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
yading@10 22 */
yading@10 23
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 int avpriv_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr)
yading@10 30 {
yading@10 31 int size, rdb, ch, sr;
yading@10 32 int aot, crc_abs;
yading@10 33
yading@10 34 if(get_bits(gbc, 12) != 0xfff)
yading@10 35 return AAC_AC3_PARSE_ERROR_SYNC;
yading@10 36
yading@10 37 skip_bits1(gbc); /* id */
yading@10 38 skip_bits(gbc, 2); /* layer */
yading@10 39 crc_abs = get_bits1(gbc); /* protection_absent */
yading@10 40 aot = get_bits(gbc, 2); /* profile_objecttype */
yading@10 41 sr = get_bits(gbc, 4); /* sample_frequency_index */
yading@10 42 if(!avpriv_mpeg4audio_sample_rates[sr])
yading@10 43 return AAC_AC3_PARSE_ERROR_SAMPLE_RATE;
yading@10 44 skip_bits1(gbc); /* private_bit */
yading@10 45 ch = get_bits(gbc, 3); /* channel_configuration */
yading@10 46
yading@10 47 skip_bits1(gbc); /* original/copy */
yading@10 48 skip_bits1(gbc); /* home */
yading@10 49
yading@10 50 /* adts_variable_header */
yading@10 51 skip_bits1(gbc); /* copyright_identification_bit */
yading@10 52 skip_bits1(gbc); /* copyright_identification_start */
yading@10 53 size = get_bits(gbc, 13); /* aac_frame_length */
yading@10 54 if(size < AAC_ADTS_HEADER_SIZE)
yading@10 55 return AAC_AC3_PARSE_ERROR_FRAME_SIZE;
yading@10 56
yading@10 57 skip_bits(gbc, 11); /* adts_buffer_fullness */
yading@10 58 rdb = get_bits(gbc, 2); /* number_of_raw_data_blocks_in_frame */
yading@10 59
yading@10 60 hdr->object_type = aot + 1;
yading@10 61 hdr->chan_config = ch;
yading@10 62 hdr->crc_absent = crc_abs;
yading@10 63 hdr->num_aac_frames = rdb + 1;
yading@10 64 hdr->sampling_index = sr;
yading@10 65 hdr->sample_rate = avpriv_mpeg4audio_sample_rates[sr];
yading@10 66 hdr->samples = (rdb + 1) * 1024;
yading@10 67 hdr->bit_rate = size * 8 * hdr->sample_rate / hdr->samples;
yading@10 68
yading@10 69 return size;
yading@10 70 }