mirror of https://github.com/FFmpeg/FFmpeg.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
2.6 KiB
72 lines
2.6 KiB
15 years ago
|
/*
|
||
|
* Audio and Video frame extraction
|
||
|
* Copyright (c) 2003 Fabrice Bellard
|
||
|
* Copyright (c) 2003 Michael Niedermayer
|
||
|
* Copyright (c) 2009 Alex Converse
|
||
|
*
|
||
|
* This file is part of FFmpeg.
|
||
|
*
|
||
|
* FFmpeg is free software; you can redistribute it and/or
|
||
|
* modify it under the terms of the GNU Lesser General Public
|
||
|
* License as published by the Free Software Foundation; either
|
||
|
* version 2.1 of the License, or (at your option) any later version.
|
||
|
*
|
||
|
* FFmpeg is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
* Lesser General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Lesser General Public
|
||
|
* License along with FFmpeg; if not, write to the Free Software
|
||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||
|
*/
|
||
|
|
||
|
#include "aac_ac3_parser.h"
|
||
8 years ago
|
#include "adts_header.h"
|
||
|
#include "adts_parser.h"
|
||
15 years ago
|
#include "get_bits.h"
|
||
|
#include "mpeg4audio.h"
|
||
|
|
||
8 years ago
|
int ff_adts_header_parse(GetBitContext *gbc, AACADTSHeaderInfo *hdr)
|
||
15 years ago
|
{
|
||
|
int size, rdb, ch, sr;
|
||
|
int aot, crc_abs;
|
||
|
|
||
11 years ago
|
if (get_bits(gbc, 12) != 0xfff)
|
||
15 years ago
|
return AAC_AC3_PARSE_ERROR_SYNC;
|
||
|
|
||
|
skip_bits1(gbc); /* id */
|
||
|
skip_bits(gbc, 2); /* layer */
|
||
|
crc_abs = get_bits1(gbc); /* protection_absent */
|
||
|
aot = get_bits(gbc, 2); /* profile_objecttype */
|
||
|
sr = get_bits(gbc, 4); /* sample_frequency_index */
|
||
11 years ago
|
if (!avpriv_mpeg4audio_sample_rates[sr])
|
||
15 years ago
|
return AAC_AC3_PARSE_ERROR_SAMPLE_RATE;
|
||
|
skip_bits1(gbc); /* private_bit */
|
||
11 years ago
|
ch = get_bits(gbc, 3); /* channel_configuration */
|
||
15 years ago
|
|
||
|
skip_bits1(gbc); /* original/copy */
|
||
|
skip_bits1(gbc); /* home */
|
||
|
|
||
|
/* adts_variable_header */
|
||
|
skip_bits1(gbc); /* copyright_identification_bit */
|
||
|
skip_bits1(gbc); /* copyright_identification_start */
|
||
11 years ago
|
size = get_bits(gbc, 13); /* aac_frame_length */
|
||
8 years ago
|
if (size < AV_AAC_ADTS_HEADER_SIZE)
|
||
15 years ago
|
return AAC_AC3_PARSE_ERROR_FRAME_SIZE;
|
||
|
|
||
|
skip_bits(gbc, 11); /* adts_buffer_fullness */
|
||
|
rdb = get_bits(gbc, 2); /* number_of_raw_data_blocks_in_frame */
|
||
|
|
||
|
hdr->object_type = aot + 1;
|
||
|
hdr->chan_config = ch;
|
||
|
hdr->crc_absent = crc_abs;
|
||
|
hdr->num_aac_frames = rdb + 1;
|
||
|
hdr->sampling_index = sr;
|
||
13 years ago
|
hdr->sample_rate = avpriv_mpeg4audio_sample_rates[sr];
|
||
15 years ago
|
hdr->samples = (rdb + 1) * 1024;
|
||
|
hdr->bit_rate = size * 8 * hdr->sample_rate / hdr->samples;
|
||
|
|
||
|
return size;
|
||
|
}
|