Mercurial > libavcodec.hg
comparison amr.h @ 12485:b42e02e9bf2b libavcodec
Move AMR-NB frame unpacking code to a common file so it can be reused in
the AMR-WB decoder.
Patch by Marcelo Galv?o P?voa.
| author | vitor |
|---|---|
| date | Fri, 10 Sep 2010 19:51:08 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 12484:01562fcb773d | 12485:b42e02e9bf2b |
|---|---|
| 1 /* | |
| 2 * Shared functions between AMR codecs | |
| 3 * | |
| 4 * Copyright (c) 2010 Marcelo Galvao Povoa | |
| 5 * | |
| 6 * This file is part of FFmpeg. | |
| 7 * | |
| 8 * FFmpeg is free software; you can redistribute it and/or | |
| 9 * modify it under the terms of the GNU Lesser General Public | |
| 10 * License as published by the Free Software Foundation; either | |
| 11 * version 2.1 of the License, or (at your option) any later version. | |
| 12 * | |
| 13 * FFmpeg is distributed in the hope that it will be useful, | |
| 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 16 * Lesser General Public License for more details. | |
| 17 * | |
| 18 * You should have received a copy of the GNU Lesser General Public | |
| 19 * License along with FFmpeg; if not, write to the Free Software | |
| 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
| 21 */ | |
| 22 | |
| 23 #ifndef AVCODEC_AMR_H | |
| 24 #define AVCODEC_AMR_H | |
| 25 | |
| 26 #ifdef AMR_USE_16BIT_TABLES | |
| 27 #define R_TABLE_TYPE uint16_t | |
| 28 #else | |
| 29 #define R_TABLE_TYPE uint8_t | |
| 30 #endif | |
| 31 | |
| 32 /** | |
| 33 * Fill the frame structure variables from bitstream by parsing the | |
| 34 * given reordering table that uses the following format: | |
| 35 * | |
| 36 * Each field (16 bits) in the AMR Frame is stored as: | |
| 37 * - one byte for the number of bits in the field | |
| 38 * - one byte for the field index | |
| 39 * - then, one byte for each bit of the field (from most-significant to least) | |
| 40 * of the position of that bit in the AMR frame. | |
| 41 * | |
| 42 * @param out pointer to the frame struct | |
| 43 * @param size the size in bytes of the frame struct | |
| 44 * @param data input bitstream after the frame header | |
| 45 * @param ord_table the reordering table as above | |
| 46 */ | |
| 47 static inline void ff_amr_bit_reorder(uint16_t *out, int size, | |
| 48 const uint8_t *data, | |
| 49 const R_TABLE_TYPE *ord_table) | |
| 50 { | |
| 51 int field_size; | |
| 52 | |
| 53 memset(out, 0, size); | |
| 54 while ((field_size = *ord_table++)) { | |
| 55 int field = 0; | |
| 56 int field_offset = *ord_table++; | |
| 57 while (field_size--) { | |
| 58 int bit = *ord_table++; | |
| 59 field <<= 1; | |
| 60 field |= data[bit >> 3] >> (bit & 7) & 1; | |
| 61 } | |
| 62 out[field_offset] = field; | |
| 63 } | |
| 64 } | |
| 65 | |
| 66 #endif /* AVCODEC_AMR_H */ |
