Mercurial > libavcodec.hg
annotate mpeg4audio.c @ 9603:875cd15dfd74 libavcodec
mpegaudio: enclose SUM8() macro args in parens when used
| author | mru |
|---|---|
| date | Tue, 05 May 2009 18:44:13 +0000 |
| parents | b687da895962 |
| children | 8e95c7402d1a |
| rev | line source |
|---|---|
| 6558 | 1 /* |
| 2 * MPEG-4 Audio common code | |
| 3 * Copyright (c) 2008 Baptiste Coudurier <baptiste.coudurier@free.fr> | |
| 4 * | |
| 5 * This file is part of FFmpeg. | |
| 6 * | |
| 7 * FFmpeg is free software; you can redistribute it and/or | |
| 8 * modify it under the terms of the GNU Lesser General Public | |
| 9 * License as published by the Free Software Foundation; either | |
| 10 * version 2.1 of the License, or (at your option) any later version. | |
| 11 * | |
| 12 * FFmpeg is distributed in the hope that it will be useful, | |
| 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 15 * Lesser General Public License for more details. | |
| 16 * | |
| 17 * You should have received a copy of the GNU Lesser General Public | |
| 18 * License along with FFmpeg; if not, write to the Free Software | |
| 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
| 20 */ | |
| 21 | |
| 9428 | 22 #include "get_bits.h" |
| 6558 | 23 #include "mpeg4audio.h" |
| 24 | |
| 25 const int ff_mpeg4audio_sample_rates[16] = { | |
| 26 96000, 88200, 64000, 48000, 44100, 32000, | |
| 27 24000, 22050, 16000, 12000, 11025, 8000, 7350 | |
| 28 }; | |
| 29 | |
| 30 const uint8_t ff_mpeg4audio_channels[8] = { | |
| 31 0, 1, 2, 3, 4, 5, 6, 8 | |
| 32 }; | |
| 33 | |
| 34 static inline int get_object_type(GetBitContext *gb) | |
| 35 { | |
| 36 int object_type = get_bits(gb, 5); | |
| 37 if (object_type == 31) | |
| 38 object_type = 32 + get_bits(gb, 6); | |
| 39 return object_type; | |
| 40 } | |
| 41 | |
| 42 static inline int get_sample_rate(GetBitContext *gb, int *index) | |
| 43 { | |
| 44 *index = get_bits(gb, 4); | |
| 45 return *index == 0x0f ? get_bits(gb, 24) : | |
| 46 ff_mpeg4audio_sample_rates[*index]; | |
| 47 } | |
| 48 | |
| 49 int ff_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int buf_size) | |
| 50 { | |
| 51 GetBitContext gb; | |
| 52 int specific_config_bitindex; | |
| 53 | |
| 54 init_get_bits(&gb, buf, buf_size*8); | |
| 55 c->object_type = get_object_type(&gb); | |
| 56 c->sample_rate = get_sample_rate(&gb, &c->sampling_index); | |
| 57 c->chan_config = get_bits(&gb, 4); | |
| 58 c->sbr = -1; | |
| 59 if (c->object_type == 5) { | |
| 60 c->ext_object_type = c->object_type; | |
| 61 c->sbr = 1; | |
| 62 c->ext_sample_rate = get_sample_rate(&gb, &c->ext_sampling_index); | |
| 63 c->object_type = get_object_type(&gb); | |
|
9527
b687da895962
Read extended channel configuration when extended AOT is BSAC.
jai_menon
parents:
9428
diff
changeset
|
64 if (c->object_type == AOT_ER_BSAC) |
|
b687da895962
Read extended channel configuration when extended AOT is BSAC.
jai_menon
parents:
9428
diff
changeset
|
65 c->ext_chan_config = get_bits(&gb, 4); |
| 9226 | 66 } else { |
| 6558 | 67 c->ext_object_type = 0; |
| 9226 | 68 c->ext_sample_rate = 0; |
| 69 } | |
| 6558 | 70 specific_config_bitindex = get_bits_count(&gb); |
| 71 | |
| 72 if (c->ext_object_type != 5) { | |
| 73 int bits_left = buf_size*8 - specific_config_bitindex; | |
| 74 for (; bits_left > 15; bits_left--) { | |
| 75 if (show_bits(&gb, 11) == 0x2b7) { // sync extension | |
| 76 get_bits(&gb, 11); | |
| 77 c->ext_object_type = get_object_type(&gb); | |
| 78 if (c->ext_object_type == 5 && (c->sbr = get_bits1(&gb)) == 1) | |
| 79 c->ext_sample_rate = get_sample_rate(&gb, &c->ext_sampling_index); | |
| 80 break; | |
| 81 } else | |
| 82 get_bits1(&gb); // skip 1 bit | |
| 83 } | |
| 84 } | |
| 85 return specific_config_bitindex; | |
| 86 } |
