www.pudn.com > AVS_M_ver10.rar > re8_dic.c
/*
***********************************************************************
* COPYRIGHT AND WARRANTY INFORMATION
*
* Copyright 2007 Audio Video Coding Standard, Part ¢ú
*
* This software module was developed by AVS Audio sub-group
*
* DISCLAIMER OF WARRANTY
*
* These software programs are available to the users without any
* license fee or royalty on an "as is" basis. The AVS disclaims
* any and all warranties, whether express, implied, or statutory,
* including any implied warranties of merchantability or of fitness
* for a particular purpose. In no event shall the contributors or
* the AVS be liable for any incidental, punitive, or consequential
* damages of any kind whatsoever arising from the use of this program.
*
* This disclaimer of warranty extends to the user of this program
* and user's customers, employees, agents, transferees, successors,
* and assigns.
*
* The AVS does not represent or warrant that the program furnished
* hereunder are free of infringement of any third-party patents.
* Commercial implementations of AVS, including shareware, may be
* subject to royalty fees to patent holders. Information regarding
* the AVS patent policy is available from the AVS Web site at
* http://www.avs.org.cn
*
* THIS IS NOT A GRANT OF PATENT RIGHTS - SEE THE AVS PATENT POLICY.
************************************************************************
*/
#include "../include/amr_plus.h"
#ifdef NEW_TVC
#define NB_SPHERE 22
#define NB_LEADER 23
#define NB_LDSIGN 184
#define NB_LDQ3 9
#define NB_LDQ4 14
/* NOTE the tables here consume 1034 (16-bit) Words,
* assuming ALL values are stored as Words (even if they'd fit in bytes)
*/
/* table of successive powers of 2 (for the computation of the sign code of
a signed leader */
const int tab_pow2[8]={128, 64, 32, 16, 8, 4, 2, 1};
/* table of factorial */
const int tab_factorial[8]={5040, 720, 120, 24, 6, 2, 1, 1};
/* Da_pos - Position of the first absolute leader on a spherical shell (or sphere) */
const int Da_pos[NB_SPHERE] = {
0, 3, 6, 8, 11, 14, 15, 17, 19, 20, 20, 21, 21, 21, 21, 21,
22, 22, 22, 22, 22, 22};
/* Da_nb - Number of absolute leaders on a spherical shell */
const int Da_nb[NB_SPHERE] = {
3, 3, 2, 3, 3, 1, 2, 2, 1, 0, 1, 0, 0, 0, 0, 1,
0, 0, 0, 0, 0, 1};
/* Da_id - identification code of an absolute leader */
const int Da_id[NB_LEADER+2] = {
0x0001, 0x0002, 0x0008, 0x0010, 0x0016, 0x0040, 0x002A, 0X0048,
0x003E, 0x0080, 0x009E, 0x0052, 0x00B2, 0x0148, 0x00C6, 0x013A,
0x025A, 0x026E, 0x008E, 0x00A2, 0x066A, 0x0E4E, 0x1BE6,
/* special leader (3,3,3,3,3,1,1,1) and (3,3,3,3,3,3,3,1,1)*/
0x066, 0x07A};
/* Da_nq - Codebook number for each absolute leader */
const int Da_nq[NB_LEADER+2] = {
2, 2, 2, 3, 3, 3, 4, 3, 4, 3, 4, 4, 4, 3, 4, 4,
4, 4, 4, 4, 4, 4, 4, 0, 100};
/* Da - Absolute leaders */
const int Da[NB_LEADER][8]={
{ 2, 0, 0, 0, 0, 0, 0, 0},
{ 1, 1, 1, 1, 1, 1, 1, 1},
{ 2, 2, 0, 0, 0, 0, 0, 0},
{ 2, 2, 2, 2, 0, 0, 0, 0},
{ 3, 1, 1, 1, 1, 1, 1, 1},
{ 4, 0, 0, 0, 0, 0, 0, 0},
{ 3, 3, 1, 1, 1, 1, 1, 1},
{ 4, 2, 2, 0, 0, 0, 0, 0},
{ 3, 3, 3, 1, 1, 1, 1, 1},
{ 4, 4, 0, 0, 0, 0, 0, 0},
{ 5, 1, 1, 1, 1, 1, 1, 1},
{ 3, 3, 3, 3, 1, 1, 1, 1},
{ 5, 3, 1, 1, 1, 1, 1, 1},
{ 6, 2, 0, 0, 0, 0, 0, 0},
{ 5, 3, 3, 1, 1, 1, 1, 1},
{ 5, 5, 1, 1, 1, 1, 1, 1},
{ 7, 1, 1, 1, 1, 1, 1, 1},
{ 7, 3, 1, 1, 1, 1, 1, 1},
{ 3, 3, 3, 3, 3, 3, 3, 1},
{ 3, 3, 3, 3, 3, 3, 3, 3},
{ 9, 1, 1, 1, 1, 1, 1, 1},
{ 11, 1, 1, 1, 1, 1, 1, 1},
{ 13, 1, 1, 1, 1, 1, 1, 1}
};
/* Ds - Sign codes of all signed leaders */
const int Ds[NB_LDSIGN]={
0,128,
0,3,15,63,255,
0,64,192,
0,16,48,112,240,
1,7,31,127,128,131,143,191,
0,128,
0,3,15,63,65,71,95,192,195,207,255,
0,32,96,128,160,224,
1,7,31,32,35,47,97,103,127,224,227,239,
0,64,192,
0,3,15,63,129,135,159,255,
0,3,15,17,23,48,51,63,113,119,240,243,255,
1,7,31,64,67,79,127,128,131,143,191,193,199,223,
0,64,128,192,
0,3,15,33,39,63,96,99,111,129,135,159,160,163,175,225,231,255,
0,3,15,63,65,71,95,192,195,207,255,
1,7,31,127,128,131,143,191,
0,3,15,63,65,71,95,129,135,159,192,195,207,255,
1,2,7,14,31,62,127,254,
0,3,15,63,255,
0,3,15,63,129,135,159,255,
1,7,31,127,128,131,143,191,
0,3,15,63,129,135,159,255
};
/* Ns - Number of signed leader associated to a given absolute leader */
const int Ns[NB_LEADER]= {
2, 5, 3, 5, 8, 2, 11, 6, 12, 3, 8, 13,
14, 4, 18, 11, 8, 14, 8, 5, 8, 8, 8};
/* Ia - Position of the first signed leader associated to an absolute leader */
const int Ia[NB_LEADER]= {
0, 2, 7, 10, 15, 23, 25, 36, 42, 54, 57, 65,
78, 92, 96, 114, 125, 133, 147, 155, 160, 168, 176};
/* Is - Cardinalite offset of signed leaders */
const unsigned int Is[NB_LDSIGN]={
0, 8, 16, 17, 45, 115, 143, 144,
172, 228, 256, 326, 606, 1026, 1306, 1376,
1432, 1712, 1880, 1888, 1896, 2064, 2344, 2400,
2408, 0, 28, 448, 868, 896, 1232, 2352,
2688, 2716, 3136, 3556, 2416, 2584, 2920, 3088,
3256, 3592, 3584, 3864, 4424, 4480, 4648, 6328,
7168, 8008, 9688, 9856, 9912, 10472, 3760, 3788,
3844, 10752, 10760, 10928, 11208, 11264, 11320, 11600,
11768, 11776, 11846, 12266, 12336, 13456, 14576, 14996,
17516, 17936, 19056, 20176, 20246, 20666, 20736, 21072,
22192, 22528, 22584, 23424, 24264, 24320, 24376, 25216,
26056, 26112, 26448, 27568, 3872, 3928, 3984, 4040,
27904, 28072, 29752, 30592, 32272, 35632, 35968, 36136,
37816, 38656, 39496, 41176, 41344, 41680, 45040, 46720,
47560, 49240, 49408, 49436, 49856, 50276, 50304, 50640,
51760, 52096, 52124, 52544, 52964, 52992, 53048, 53328,
53496, 53504, 53512, 53680, 53960, 54016, 54072, 54912,
55752, 55808, 56144, 57264, 57600, 57936, 59056, 59392,
59448, 60288, 61128, 61184, 61192, 61248, 61416, 61696,
61976, 62144, 62200, 62208, 62209, 62237, 62307, 62335,
62336, 62344, 62512, 62792, 62848, 62904, 63184, 63352,
63360, 63416, 63696, 63864, 63872, 63880, 64048, 64328,
64384, 64392, 64560, 64840, 64896, 64952, 65232, 65400};
/* A3 - Number of the absolute leaders in codebooks Q2 and Q3 */
const int A3[NB_LDQ3]={
0, 1, 2, 3, 4, 5, 7, 9, 13};
/* A4 - Number of the absolute leaders in codebook Q4 */
const int A4[NB_LDQ4]={
6, 8, 10, 11, 12, 14, 15, 16, 17,
18, 19, 20, 21, 22};
/* I3 - Cardinality offsets for absolute leaders in Q3 */
const unsigned int I3[NB_LDQ3]={
0, 16, 144, 256, 1376, 2400, 2416, 3760, 3872};
/* I4 - Cardinality offset for absolute leaders in Q4 */
const unsigned int I4[NB_LDQ4]={
0, 3584, 10752, 11776, 20736, 27904, 49408, 52992, 54016,
61184, 62208, 62336, 63360, 64384};
#else
#define NB_SPHERE 32
#define NB_LEADER 36
#define NB_LDSIGN 224
#define NB_LDQ3 9
#define NB_LDQ4 27
/* NOTE the tables here consume 1034 (16-bit) Words,
* assuming ALL values are stored as Words (even if they'd fit in bytes)
*/
/* table of successive powers of 2 (for the computation of the sign code of
a signed leader */
const int tab_pow2[8]={128, 64, 32, 16, 8, 4, 2, 1};
/* table of factorial */
const int tab_factorial[8]={5040, 720, 120, 24, 6, 2, 1, 1};
/* Da_pos - Position of the first absolute leader on a spherical shell (or sphere) */
const int Da_pos[NB_SPHERE] = {
0, 2, 5, 8, 13, 18, 20, 22, 23, 25, 26, 27, 27, 28, 28, 28,
29, 30, 31, 31, 32, 32, 32, 32, 32, 34, 35, 35, 35, 35, 35, 35};
/* Da_nb - Number of absolute leaders on a spherical shell */
const int Da_nb[NB_SPHERE] = {
2, 3, 3, 5, 5, 2, 2, 1, 2, 1, 1, 0, 1, 0, 0, 1,
1, 1, 0, 1, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 1};
/* Da_id - identification code of an absolute leader */
const int Da_id[NB_LEADER] = {
0x0001, 0x0004, 0x0008, 0x000B, 0x0020, 0x000C, 0x0015, 0x0024,
0x0010, 0x001F, 0x0028, 0x0040, 0x004F, 0x0029, 0x002C, 0x0044,
0x0059, 0x00A4, 0x0060, 0x00A8, 0x00C4, 0x012D, 0x0200, 0x0144,
0x0204, 0x0220, 0x0335, 0x04E4, 0x0400, 0x0584, 0x0A20, 0x0A40,
0x09C4, 0x12C4, 0x0C20, 0x2000};
/* Da_nq - Codebook number for each absolute leader */
const int Da_nq[NB_LEADER+2] = {
2, 2, 3, 3, 2, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, 4,
4, 3, 4, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 0, 100};
/* Da - Absolute leaders */
const int Da[NB_LEADER][8]={
{ 1, 1, 1, 1, 1, 1, 1, 1},
{ 2, 2, 0, 0, 0, 0, 0, 0},
{ 2, 2, 2, 2, 0, 0, 0, 0},
{ 3, 1, 1, 1, 1, 1, 1, 1},
{ 4, 0, 0, 0, 0, 0, 0, 0},
{ 2, 2, 2, 2, 2, 2, 0, 0},
{ 3, 3, 1, 1, 1, 1, 1, 1},
{ 4, 2, 2, 0, 0, 0, 0, 0},
{ 2, 2, 2, 2, 2, 2, 2, 2},
{ 3, 3, 3, 1, 1, 1, 1, 1},
{ 4, 2, 2, 2, 2, 0, 0, 0},
{ 4, 4, 0, 0, 0, 0, 0, 0},
{ 5, 1, 1, 1, 1, 1, 1, 1},
{ 3, 3, 3, 3, 1, 1, 1, 1},
{ 4, 2, 2, 2, 2, 2, 2, 0},
{ 4, 4, 2, 2, 0, 0, 0, 0},
{ 5, 3, 1, 1, 1, 1, 1, 1},
{ 6, 2, 0, 0, 0, 0, 0, 0},
{ 4, 4, 4, 0, 0, 0, 0, 0},
{ 6, 2, 2, 2, 0, 0, 0, 0},
{ 6, 4, 2, 0, 0, 0, 0, 0},
{ 7, 1, 1, 1, 1, 1, 1, 1},
{ 8, 0, 0, 0, 0, 0, 0, 0},
{ 6, 6, 0, 0, 0, 0, 0, 0},
{ 8, 2, 2, 0, 0, 0, 0, 0},
{ 8, 4, 0, 0, 0, 0, 0, 0},
{ 9, 1, 1, 1, 1, 1, 1, 1},
{10, 2, 0, 0, 0, 0, 0, 0},
{ 8, 8, 0, 0, 0, 0, 0, 0},
{10, 6, 0, 0, 0, 0, 0, 0},
{12, 0, 0, 0, 0, 0, 0, 0},
{12, 4, 0, 0, 0, 0, 0, 0},
{10, 10, 0, 0, 0, 0, 0, 0},
{14, 2, 0, 0, 0, 0, 0, 0},
{12, 8, 0, 0, 0, 0, 0, 0},
{16, 0, 0, 0, 0, 0, 0, 0}};
/* Ds - Sign codes of all signed leaders */
const int Ds[NB_LDSIGN]={
0,3,15,63,255,
0,64,192,
0,16,48,112,240,
1,7,31,127,128,131,143,191,
0,128,
0,4,12,28,60,124,252,
0,3,15,63,65,71,95,192,195,207,255,
0,32,96,128,160,224,
0,1,3,7,15,31,63,127,255,
1,7,31,32,35,47,97,103,127,224,227,239,
0,8,24,56,120,128,136,152,184,248,
0,64,192,
0,3,15,63,129,135,159,255,
0,3,15,17,23,48,51,63,113,119,240,243,255,
0,2,6,14,30,62,126,128,130,134,142,158,190,254,
0,16,48,64,80,112,192,208,240,
1,7,31,64,67,79,127,128,131,143,191,193,199,223,
0,64,128,192,
0,32,96,224,
0,16,48,112,128,144,176,240,
0,32,64,96,128,160,192,224,
1,7,31,127,128,131,143,191,
0,128,
0,64,192,
0,32,96,128,160,224,
0,64,128,192,
0,3,15,63,129,135,159,255,
0,64,128,192,
0,64,192,
0,64,128,192,
0,128,
0,64,128,192,
0,64,192,
0,64,128,192,
0,64,128,192,
0,128
};
/* Ns - Number of signed leader associated to a given absolute leader */
const int Ns[NB_LEADER]= {
5, 3, 5, 8, 2, 7, 11, 6, 9, 12, 10, 3,
8, 13, 14, 9, 14, 4, 4, 8, 8, 8, 2, 3,
6, 4, 8, 4, 3, 4, 2, 4, 3, 4, 4, 2};
/* Ia - Position of the first signed leader associated to an absolute leader */
const int Ia[NB_LEADER]= {
0, 5, 8, 13, 21, 23, 30, 41, 47, 56, 68, 78,
81, 89, 102, 116, 125, 139, 143, 147, 155, 163, 171, 173,
176, 182, 186, 194, 198, 201, 205, 207, 211, 214, 218, 222};
/* Is - Cardinalite offset of signed leaders */
const unsigned int Is[NB_LDSIGN]={
0, 1, 29, 99, 127, 128, 156, 212,
256, 326, 606, 1026, 1306, 1376, 1432, 1712,
1880, 1888, 1896, 2064, 2344, 240, 248, 0,
28, 196, 616, 1176, 1596, 1764, 1792, 1820,
2240, 2660, 2688, 3024, 4144, 4480, 4508, 4928,
5348, 2400, 2568, 2904, 3072, 3240, 3576, 5376,
5377, 5385, 5413, 5469, 5539, 5595, 5623, 5631,
5632, 5912, 6472, 6528, 6696, 8376, 9216, 10056,
11736, 11904, 11960, 12520, 12800, 13080, 14200, 15880,
17000, 17280, 17560, 18680, 20360, 21480, 3744, 3772,
3828, 21760, 21768, 21936, 22216, 22272, 22328, 22608,
22776, 22784, 22854, 23274, 23344, 24464, 25584, 26004,
28524, 28944, 30064, 31184, 31254, 31674, 31744, 31800,
32136, 32976, 34096, 34936, 35272, 35328, 35384, 35720,
36560, 37680, 38520, 38856, 38912, 39332, 40172, 40592,
41432, 43112, 43952, 44372, 45212, 45632, 45968, 47088,
47424, 47480, 48320, 49160, 49216, 49272, 50112, 50952,
51008, 51344, 52464, 3856, 3912, 3968, 4024, 52800,
52856, 53024, 53192, 53248, 53528, 54368, 55208, 55488,
55768, 56608, 57448, 57728, 58064, 58400, 58736, 59072,
59408, 59744, 60080, 60416, 60472, 60752, 60920, 60928,
60936, 61104, 61384, 4080, 4088, 61440, 61468, 61524,
61552, 61720, 62056, 62224, 62392, 62728, 62896, 62952,
63008, 63064, 63120, 63128, 63296, 63576, 63632, 63688,
63968, 64136, 64144, 64200, 64256, 64312, 64368, 64396,
64452, 64480, 64536, 64592, 64648, 64704, 64712, 64720,
64776, 64832, 64888, 64944, 64972, 65028, 65056, 65112,
65168, 65224, 65280, 65336, 65392, 65448, 65504, 65512};
/* A3 - Number of the absolute leaders in codebooks Q2 and Q3 */
const int A3[NB_LDQ3]={
0, 1, 4, 2, 3, 7, 11, 17, 22};
/* A4 - Number of the absolute leaders in codebook Q4 */
const int A4[NB_LDQ4]={
5, 6, 8, 9, 10, 12, 13, 14, 15,
16, 18, 19, 20, 21, 23, 24, 25, 26,
27, 28, 29, 30, 31, 32, 33, 34, 35};
/* I3 - Cardinality offsets for absolute leaders in Q3 */
const unsigned int I3[NB_LDQ3]={
0, 128, 240, 256, 1376, 2400, 3744, 3856, 4080};
/* I4 - Cardinality offset for absolute leaders in Q4 */
const unsigned int I4[NB_LDQ4]={
0, 1792, 5376, 5632, 12800, 21760, 22784, 31744, 38912,
45632, 52800, 53248, 57728, 60416, 61440, 61552, 62896, 63120,
64144, 64368, 64480, 64704, 64720, 64944, 65056, 65280, 65504};
#endif