1 /* 2 * gsm 06.10 decoder data 3 * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de> 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 22 #include <stdint.h> 23 #include "gsmdec_data.h" 24 25 const uint16_t ff_gsm_long_term_gain_tab[4] = { 26 3277, 11469, 21299, 32767 27 }; 28 29 const uint8_t ff_gsm_requant_tab[4][8] = { 30 { 0 }, 31 { 0, 7 }, 32 { 0, 2, 5, 7 }, 33 { 0, 1, 2, 3, 4, 5, 6, 7 } 34 }; 35 36 const int16_t ff_gsm_dequant_tab[64][8] = { 37 { -28, -20, -12, -4, 4, 12, 20, 28}, 38 { -56, -40, -24, -8, 8, 24, 40, 56}, 39 { -84, -60, -36, -12, 12, 36, 60, 84}, 40 { -112, -80, -48, -16, 16, 48, 80, 112}, 41 { -140, -100, -60, -20, 20, 60, 100, 140}, 42 { -168, -120, -72, -24, 24, 72, 120, 168}, 43 { -196, -140, -84, -28, 28, 84, 140, 196}, 44 { -224, -160, -96, -32, 32, 96, 160, 224}, 45 { -252, -180, -108, -36, 36, 108, 180, 252}, 46 { -280, -200, -120, -40, 40, 120, 200, 280}, 47 { -308, -220, -132, -44, 44, 132, 220, 308}, 48 { -336, -240, -144, -48, 48, 144, 240, 336}, 49 { -364, -260, -156, -52, 52, 156, 260, 364}, 50 { -392, -280, -168, -56, 56, 168, 280, 392}, 51 { -420, -300, -180, -60, 60, 180, 300, 420}, 52 { -448, -320, -192, -64, 64, 192, 320, 448}, 53 { -504, -360, -216, -72, 72, 216, 360, 504}, 54 { -560, -400, -240, -80, 80, 240, 400, 560}, 55 { -616, -440, -264, -88, 88, 264, 440, 616}, 56 { -672, -480, -288, -96, 96, 288, 480, 672}, 57 { -728, -520, -312, -104, 104, 312, 520, 728}, 58 { -784, -560, -336, -112, 112, 336, 560, 784}, 59 { -840, -600, -360, -120, 120, 360, 600, 840}, 60 { -896, -640, -384, -128, 128, 384, 640, 896}, 61 { -1008, -720, -432, -144, 144, 432, 720, 1008}, 62 { -1120, -800, -480, -160, 160, 480, 800, 1120}, 63 { -1232, -880, -528, -176, 176, 528, 880, 1232}, 64 { -1344, -960, -576, -192, 192, 576, 960, 1344}, 65 { -1456, -1040, -624, -208, 208, 624, 1040, 1456}, 66 { -1568, -1120, -672, -224, 224, 672, 1120, 1568}, 67 { -1680, -1200, -720, -240, 240, 720, 1200, 1680}, 68 { -1792, -1280, -768, -256, 256, 768, 1280, 1792}, 69 { -2016, -1440, -864, -288, 288, 864, 1440, 2016}, 70 { -2240, -1600, -960, -320, 320, 960, 1600, 2240}, 71 { -2464, -1760, -1056, -352, 352, 1056, 1760, 2464}, 72 { -2688, -1920, -1152, -384, 384, 1152, 1920, 2688}, 73 { -2912, -2080, -1248, -416, 416, 1248, 2080, 2912}, 74 { -3136, -2240, -1344, -448, 448, 1344, 2240, 3136}, 75 { -3360, -2400, -1440, -480, 480, 1440, 2400, 3360}, 76 { -3584, -2560, -1536, -512, 512, 1536, 2560, 3584}, 77 { -4032, -2880, -1728, -576, 576, 1728, 2880, 4032}, 78 { -4480, -3200, -1920, -640, 640, 1920, 3200, 4480}, 79 { -4928, -3520, -2112, -704, 704, 2112, 3520, 4928}, 80 { -5376, -3840, -2304, -768, 768, 2304, 3840, 5376}, 81 { -5824, -4160, -2496, -832, 832, 2496, 4160, 5824}, 82 { -6272, -4480, -2688, -896, 896, 2688, 4480, 6272}, 83 { -6720, -4800, -2880, -960, 960, 2880, 4800, 6720}, 84 { -7168, -5120, -3072, -1024, 1024, 3072, 5120, 7168}, 85 { -8063, -5759, -3456, -1152, 1152, 3456, 5760, 8064}, 86 { -8959, -6399, -3840, -1280, 1280, 3840, 6400, 8960}, 87 { -9855, -7039, -4224, -1408, 1408, 4224, 7040, 9856}, 88 {-10751, -7679, -4608, -1536, 1536, 4608, 7680, 10752}, 89 {-11647, -8319, -4992, -1664, 1664, 4992, 8320, 11648}, 90 {-12543, -8959, -5376, -1792, 1792, 5376, 8960, 12544}, 91 {-13439, -9599, -5760, -1920, 1920, 5760, 9600, 13440}, 92 {-14335, -10239, -6144, -2048, 2048, 6144, 10240, 14336}, 93 {-16127, -11519, -6912, -2304, 2304, 6912, 11519, 16127}, 94 {-17919, -12799, -7680, -2560, 2560, 7680, 12799, 17919}, 95 {-19711, -14079, -8448, -2816, 2816, 8448, 14079, 19711}, 96 {-21503, -15359, -9216, -3072, 3072, 9216, 15359, 21503}, 97 {-23295, -16639, -9984, -3328, 3328, 9984, 16639, 23295}, 98 {-25087, -17919, -10752, -3584, 3584, 10752, 17919, 25087}, 99 {-26879, -19199, -11520, -3840, 3840, 11520, 19199, 26879}, 100 {-28671, -20479, -12288, -4096, 4096, 12288, 20479, 28671} 101 }; 102 103 static const int apcm_bits[11][13] = { 104 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, 105 { 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1 }, 106 { 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1 }, 107 { 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1 }, 108 { 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1 }, 109 { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, 110 { 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, 111 { 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, 112 { 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, 113 { 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, 114 { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 } 115 }; 116 117 const int* const ff_gsm_apcm_bits[][4] = { 118 { apcm_bits[10], apcm_bits[10], apcm_bits[10], apcm_bits[10] }, // 13000 119 { apcm_bits[10], apcm_bits[10], apcm_bits[10], apcm_bits[ 6] }, // 12400 120 { apcm_bits[10], apcm_bits[10], apcm_bits[ 7], apcm_bits[ 5] }, // 11800 121 { apcm_bits[10], apcm_bits[ 8], apcm_bits[ 5], apcm_bits[ 5] }, // 11200 122 { apcm_bits[ 9], apcm_bits[ 5], apcm_bits[ 5], apcm_bits[ 5] }, // 10600 123 { apcm_bits[ 5], apcm_bits[ 5], apcm_bits[ 5], apcm_bits[ 1] }, // 10000 124 { apcm_bits[ 5], apcm_bits[ 5], apcm_bits[ 2], apcm_bits[ 0] }, // 9400 125 { apcm_bits[ 5], apcm_bits[ 3], apcm_bits[ 0], apcm_bits[ 0] }, // 8800 126 { apcm_bits[ 4], apcm_bits[ 0], apcm_bits[ 0], apcm_bits[ 0] }, // 8200 127 }; 128