annotate aacadtsdec.c @ 12264:aff96d44f992 libavcodec

10l: Remove some commented out code that slipped in.
author alexc
date Sat, 24 Jul 2010 17:01:50 +0000
parents e7634f1b6100
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12149
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
1 /*
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
2 * Audio and Video frame extraction
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
3 * Copyright (c) 2003 Fabrice Bellard
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
4 * Copyright (c) 2003 Michael Niedermayer
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
5 * Copyright (c) 2009 Alex Converse
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
6 *
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
7 * This file is part of FFmpeg.
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
8 *
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
9 * FFmpeg is free software; you can redistribute it and/or
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
10 * modify it under the terms of the GNU Lesser General Public
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
11 * License as published by the Free Software Foundation; either
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
12 * version 2.1 of the License, or (at your option) any later version.
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
13 *
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
14 * FFmpeg is distributed in the hope that it will be useful,
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
17 * Lesser General Public License for more details.
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
18 *
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
19 * You should have received a copy of the GNU Lesser General Public
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
20 * License along with FFmpeg; if not, write to the Free Software
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
22 */
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
23
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
24 #include "aac_ac3_parser.h"
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
25 #include "aacadtsdec.h"
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
26 #include "get_bits.h"
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
27 #include "mpeg4audio.h"
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
28
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
29 int ff_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr)
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
30 {
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
31 int size, rdb, ch, sr;
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
32 int aot, crc_abs;
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
33
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
34 if(get_bits(gbc, 12) != 0xfff)
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
35 return AAC_AC3_PARSE_ERROR_SYNC;
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
36
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
37 skip_bits1(gbc); /* id */
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
38 skip_bits(gbc, 2); /* layer */
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
39 crc_abs = get_bits1(gbc); /* protection_absent */
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
40 aot = get_bits(gbc, 2); /* profile_objecttype */
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
41 sr = get_bits(gbc, 4); /* sample_frequency_index */
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
42 if(!ff_mpeg4audio_sample_rates[sr])
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
43 return AAC_AC3_PARSE_ERROR_SAMPLE_RATE;
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
44 skip_bits1(gbc); /* private_bit */
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
45 ch = get_bits(gbc, 3); /* channel_configuration */
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
46
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
47 skip_bits1(gbc); /* original/copy */
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
48 skip_bits1(gbc); /* home */
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
49
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
50 /* adts_variable_header */
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
51 skip_bits1(gbc); /* copyright_identification_bit */
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
52 skip_bits1(gbc); /* copyright_identification_start */
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
53 size = get_bits(gbc, 13); /* aac_frame_length */
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
54 if(size < AAC_ADTS_HEADER_SIZE)
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
55 return AAC_AC3_PARSE_ERROR_FRAME_SIZE;
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
56
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
57 skip_bits(gbc, 11); /* adts_buffer_fullness */
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
58 rdb = get_bits(gbc, 2); /* number_of_raw_data_blocks_in_frame */
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
59
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
60 hdr->object_type = aot + 1;
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
61 hdr->chan_config = ch;
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
62 hdr->crc_absent = crc_abs;
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
63 hdr->num_aac_frames = rdb + 1;
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
64 hdr->sampling_index = sr;
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
65 hdr->sample_rate = ff_mpeg4audio_sample_rates[sr];
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
66 hdr->samples = (rdb + 1) * 1024;
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
67 hdr->bit_rate = size * 8 * hdr->sample_rate / hdr->samples;
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
68
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
69 return size;
e7634f1b6100 Split the ADTS header decoder off of the ADTS parser.
alexc
parents:
diff changeset
70 }