* Copyright (c) 2003 Sascha Sommer
* Copyright (c) 2005 Benjamin Larsson
*
- * This library is free software; you can redistribute it and/or
+ * This file is part of Libav.
+ *
+ * Libav 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 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
*
- * This library is distributed in the hope that it will be useful,
+ * Libav 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 this library; if not, write to the Free Software
+ * License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
*/
/**
- * @file cookdata.h
- * Cook AKA RealAudio G2 compatible decoderdata
+ * @file
+ * Cook AKA RealAudio G2 compatible decoder data
*/
+#ifndef AVCODEC_COOKDATA_H
+#define AVCODEC_COOKDATA_H
+
+#include <stdint.h>
+
/* various data tables */
static const int expbits_tab[8] = {
52,47,43,37,29,22,16,0,
};
-static const float dither_tab[8] = {
- 0.0, 0.0, 0.0, 0.0, 0.0, 0.176777, 0.25, 0.707107,
+static const float dither_tab[9] = {
+ 0.0, 0.0, 0.0, 0.0, 0.0, 0.176777, 0.25, 0.707107, 1.0
};
-static const float randsign[2] = {1.0, -1.0};
-
static const float quant_centroid_tab[7][14] = {
{ 0.000, 0.392, 0.761, 1.120, 1.477, 1.832, 2.183, 2.541, 2.893, 3.245, 3.598, 3.942, 4.288, 4.724 },
{ 0.000, 0.544, 1.060, 1.563, 2.068, 2.571, 3.072, 3.562, 4.070, 4.620, 0.000, 0.000, 0.000, 0.000 },
0x003c,0x01fc,0x00fb,0x03fd,0x00fc,0x03fe,0x01fd,0x07ff,
};
-static const uint16_t* cvh_huffcodes[7] = {
+static const uint16_t* const cvh_huffcodes[7] = {
cvh_huffcodes0, cvh_huffcodes1, cvh_huffcodes2, cvh_huffcodes3,
cvh_huffcodes4, cvh_huffcodes5, cvh_huffcodes6,
};
-static const uint8_t* cvh_huffbits[7] = {
+static const uint8_t* const cvh_huffbits[7] = {
cvh_huffbits0, cvh_huffbits1, cvh_huffbits2, cvh_huffbits3,
cvh_huffbits4, cvh_huffbits5, cvh_huffbits6,
};
14,14,16,
};
-static const uint16_t* ccpl_huffcodes[5] = {
+static const uint16_t* const ccpl_huffcodes[5] = {
ccpl_huffcodes2,ccpl_huffcodes3,
ccpl_huffcodes4,ccpl_huffcodes5,ccpl_huffcodes6
};
-static const uint8_t* ccpl_huffbits[5] = {
+static const uint8_t* const ccpl_huffbits[5] = {
ccpl_huffbits2,ccpl_huffbits3,
ccpl_huffbits4,ccpl_huffbits5,ccpl_huffbits6
};
19,
};
-static const float cplscale2[3] = {
+// The 1 and 0 at the beginning/end are to prevent overflows with
+// bitstream-read indexes. E.g. if n_bits=5, we can access any
+// index from [1, (1<<n_bits)] for the first decoupling coeff,
+// and (1<<n_bits)-coeff1 as index for coeff2, i.e.:
+// coeff1_idx = [1, 32], and coeff2_idx = [0, 31].
+// These values aren't part of the tables in the original binary.
+
+static const float cplscale2[5] = {
+1,
0.953020632266998,0.70710676908493,0.302905440330505,
+0,
};
-static const float cplscale3[7] = {
+static const float cplscale3[9] = {
+1,
0.981279790401459,0.936997592449188,0.875934481620789,0.70710676908493,
0.482430040836334,0.349335819482803,0.192587479948997,
+0,
};
-static const float cplscale4[15] = {
+static const float cplscale4[17] = {
+1,
0.991486728191376,0.973249018192291,0.953020632266998,0.930133521556854,
0.903453230857849,0.870746195316315,0.826180458068848,0.70710676908493,
0.563405573368073,0.491732746362686,0.428686618804932,0.367221474647522,
0.302905440330505,0.229752898216248,0.130207896232605,
+0,
};
-static const float cplscale5[31] = {
+static const float cplscale5[33] = {
+1,
0.995926380157471,0.987517595291138,0.978726446628571,0.969505727291107,
0.95979779958725,0.949531257152557,0.938616216182709,0.926936149597168,
0.914336204528809,0.900602877140045,0.885426938533783,0.868331849575043,
0.464778542518616,0.434642940759659,0.404955863952637,0.375219136476517,
0.344963222742081,0.313672333955765,0.280692428350449,0.245068684220314,
0.205169528722763,0.157508864998817,0.0901700109243393,
+0,
};
-static const float cplscale6[63] = {
+static const float cplscale6[65] = {
+1,
0.998005926609039,0.993956744670868,0.989822506904602,0.985598564147949,
0.981279790401459,0.976860702037811,0.972335040569305,0.967696130275726,
0.962936460971832,0.958047747612000,0.953020632266998,0.947844684123993,
0.302905440330505,0.286608695983887,0.269728302955627,0.252119421958923,
0.233590632677078,0.213876649737358,0.192587479948997,0.169101938605309,
0.142307326197624,0.109772264957428,0.0631198287010193,
+0,
};
-static const float* cplscales[5] = {
+static const float* const cplscales[5] = {
cplscale2, cplscale3, cplscale4, cplscale5, cplscale6,
};
+
+#endif /* AVCODEC_COOKDATA_H */