www.pudn.com > jm50g.zip > abt_const.c
/* *********************************************************************** * COPYRIGHT AND WARRANTY INFORMATION * * Copyright 2001, International Telecommunications Union, Geneva * * DISCLAIMER OF WARRANTY * * These software programs are available to the user without any * license fee or royalty on an "as is" basis. The ITU 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 * contributor or the ITU be liable for any incidental, punitive, or * consequential damages of any kind whatsoever arising from the * use of these programs. * * This disclaimer of warranty extends to the user of these programs * and user's customers, employees, agents, transferees, successors, * and assigns. * * The ITU does not represent or warrant that the programs furnished * hereunder are free of infringement of any third-party patents. * Commercial implementations of ITU-T Recommendations, including * shareware, may be subject to royalty fees to patent holders. * Information regarding the ITU-T patent policy is available from * the ITU Web site at http://www.itu.int. * * THIS IS NOT A GRANT OF PATENT RIGHTS - SEE THE ITU-T PATENT POLICY. ************************************************************************ */ /* ************************************************************************************* * \file * abt_const.c * * \brief * Constant Arrays, Transforms etc to be used with Adaptive Block Transforms * * \author * Main contributors (see contributors.h for copyright, address and affiliation details) * - Mathias Wien* - Achim Dahlhoff * * \date * Fri Mar 8 2002 * * copyright : (C) 2002 by Mathias Wien * Institut und Lehrstuhl für Nachrichtentechnik * RWTH Aachen University * 52072 Aachen * Germany ************************************************************************************* */ #include "defines.h" #include "abt.h" const int ABT_matrix[2][8][8]= { { { 1, 1, 1, 1}, { 2, 1,-1,-2}, { 1,-1,-1, 1}, { 1,-2, 2,-1}, }, { {13, 13, 13, 13, 13, 13, 13, 13}, {19, 15, 9, 3, -3, -9,-15,-19}, {17, 7, -7,-17,-17, -7, 7, 17}, { 9, 3,-19,-15, 15, 19, -3, -9}, {13,-13,-13, 13, 13,-13,-13, 13}, {15,-19, -3, 9, -9, 3, 19,-15}, { 7,-17, 17, -7, -7, 17,-17, 7}, { 3, -9, 15,-19, 19,-15, 9, -3}, } }; const int ABT_TRSIZE[4][2] = { // block mode {8,8}, // 8x8 {8,4}, // 8x4 {4,8}, // 4x8 {4,4}, // 4x4 }; const int ABT_NUMTR[4][2] = { // block mode {1,1}, // 8x8 {1,2}, // 8x4 {2,1}, // 4x8 {2,2}, // 4x4 }; const int ABT_TRIDX[4][2] = { // block mode {1,1}, // 8x8 {1,0}, // 8x4 {0,1}, // 4x8 {0,0}, // 4x4 }; const int ABT_Q[4][QUANT_PERIOD][3] = // Quantization { { // 8x8 {2506}, {2211}, {1979}, {1709}, {1566}, {1392} },{//ac bc // 4x8,8x4 {11030,7220}, {9927 ,6618}, {9025 ,5673}, {8273 ,4964}, {7091 ,4672}, {6618 ,3971} },{//ac bc // 4x8,8x4 {11030,7220}, {9927 ,6618}, {9025 ,5673}, {8273 ,4964}, {7091 ,4672}, {6618 ,3971} },{ // aa bb ab // 4x4 #ifdef _CD_4x4VALUES_ {13107,5243,8066}, {11916,4660,7490}, {10082,4194,6554}, {9362, 3647,5825}, {8192, 3355,5243}, {7282, 2893,4559} #else {13107, 5243,8224}, {11651, 4660,7358}, {10486, 4143,6554}, { 9198, 3687,5825}, { 8322, 3290,5243}, { 7384, 2943,4660} #endif } }; const int ABT_R[4][QUANT_PERIOD][3] = // De-Quantization { { {15}, {17}, {19}, {22}, {24}, {27} },{ {9 ,11}, {10,12}, {11,14}, {12,16}, {14,17}, {15,20} },{ {9 ,11}, {10,12}, {11,14}, {12,16}, {14,17}, {15,20} },{//aa bb ab // 4x4 #ifdef _CD_4x4VALUES_ {40, 64, 52}, // 4* {10,16,13} {44, 72, 56}, // 4* {11,18,14} {52, 80, 64}, // 4* {13,20,16} {56, 92, 72}, // 4* {14,23,18} {64,100, 80}, // 4* {16,25,20} {72,116, 92} // 4* {18,29,23} #else {40, 64,51}, {45, 72,57}, {50, 81,64}, {57, 91,72}, {63,102,80}, {71,114,90} #endif } }; const int ABT_QMAP[4][2][2] = { { {0,0},{0,0} }, // 8x8 { {0,0},{1,1} }, // 8x4 { {0,1},{0,1} }, // 4x8 { {0,2},{2,1} }, // 4x4 }; const int ABT_N[4][2] = { {23, 13}, {21, 8}, {21, 8}, {17, 6} }; const int ABT_SHIFT0[4][2][2] = { {{7,7},{7,7}}, {{2,2},{4,4}}, {{2,4},{2,4}}, {{0,0},{0,0}} }; const int ABT_SHIFT1[4] = { 7,2,2,0 }; const int ABT_SCAN[2][4][64][2] = // [abt_mode][scan_pos][x/y] ATTENTION: the ScanPositions are (pix,lin)! { { { // 8x8 { 0, 0}, { 1, 0}, { 0, 1}, { 0, 2}, { 1, 1}, { 2, 0}, { 3, 0}, { 2, 1}, { 1, 2}, { 0, 3}, { 0, 4}, { 1, 3}, { 2, 2}, { 3, 1}, { 4, 0}, { 5, 0}, { 4, 1}, { 3, 2}, { 2, 3}, { 1, 4}, { 0, 5}, { 0, 6}, { 1, 5}, { 2, 4}, { 3, 3}, { 4, 2}, { 5, 1}, { 6, 0}, { 7, 0}, { 6, 1}, { 5, 2}, { 4, 3}, { 3, 4}, { 2, 5}, { 1, 6}, { 0, 7}, { 1, 7}, { 2, 6}, { 3, 5}, { 4, 4}, { 5, 3}, { 6, 2}, { 7, 1}, { 7, 2}, { 6, 3}, { 5, 4}, { 4, 5}, { 3, 6}, { 2, 7}, { 3, 7}, { 4, 6}, { 5, 5}, { 6, 4}, { 7, 3}, { 7, 4}, { 6, 5}, { 5, 6}, { 4, 7}, { 5, 7}, { 6, 6}, { 7, 5}, { 7, 6}, { 6, 7}, { 7, 7} },{ // 8x4 { 0, 0}, { 1, 0}, { 0, 1}, { 0, 2}, { 1, 1}, { 2, 0}, { 3, 0}, { 2, 1}, { 1, 2}, { 0, 3}, { 1, 3}, { 2, 2}, { 3, 1}, { 4, 0}, { 5, 0}, { 4, 1}, { 3, 2}, { 2, 3}, { 3, 3}, { 4, 2}, { 5, 1}, { 6, 0}, { 7, 0}, { 6, 1}, { 5, 2}, { 4, 3}, { 5, 3}, { 6, 2}, { 7, 1}, { 7, 2}, { 6, 3}, { 7, 3} },{ // 4x8 { 0, 0}, { 0, 1}, { 1, 0}, { 2, 0}, { 1, 1}, { 0, 2}, { 0, 3}, { 1, 2}, { 2, 1}, { 3, 0}, { 3, 1}, { 2, 2}, { 1, 3}, { 0, 4}, { 0, 5}, { 1, 4}, { 2, 3}, { 3, 2}, { 3, 3}, { 2, 4}, { 1, 5}, { 0, 6}, { 0, 7}, { 1, 6}, { 2, 5}, { 3, 4}, { 3, 5}, { 2, 6}, { 1, 7}, { 2, 7}, { 3, 6}, { 3, 7} },{ // 4x4 { 0, 0}, { 1, 0}, { 0, 1}, { 0, 2}, { 1, 1}, { 2, 0}, { 3, 0}, { 2, 1}, { 1, 2}, { 0, 3}, { 1, 3}, { 2, 2}, { 3, 1}, { 3, 2}, { 2, 3}, { 3, 3} } }, { // alt. scan von Limin Wang, JVT-C140. { // 8x8 { 0, 0}, { 0, 1}, { 0, 2}, { 1, 0}, { 1, 1}, { 0, 3}, { 0, 4}, { 1, 2}, { 2, 0}, { 1, 3}, { 0, 5}, { 0, 6}, { 0, 7}, { 1, 4}, { 2, 1}, { 3, 0}, { 2, 2}, { 1, 5}, { 1, 6}, { 1, 7}, { 2, 3}, { 3, 1}, { 4, 0}, { 3, 2}, { 2, 4}, { 2, 5}, { 2, 6}, { 2, 7}, { 3, 3}, { 4, 1}, { 5, 0}, { 4, 2}, { 3, 4}, { 3, 5}, { 3, 6}, { 3, 7}, { 4, 3}, { 5, 1}, { 6, 0}, { 5, 2}, { 4, 4}, { 4, 5}, { 4, 6}, { 4, 7}, { 5, 3}, { 6, 1}, { 6, 2}, { 5, 4}, { 5, 5}, { 5, 6}, { 5, 7}, { 6, 3}, { 7, 0}, { 7, 1}, { 6, 4}, { 6, 5}, { 6, 6}, { 6, 7}, { 7, 2}, { 7, 3}, { 7, 4}, { 7, 5}, { 7, 6}, { 7, 7} },{ // 8x4 { 0, 0}, { 0, 1}, { 1, 0}, { 0, 2}, { 0, 3}, { 1, 1}, { 2, 0}, { 1, 2}, { 1, 3}, { 2, 1}, { 3, 0}, { 2, 2}, { 2, 3}, { 3, 1}, { 4, 0}, { 3, 2}, { 3, 3}, { 4, 1}, { 5, 0}, { 4, 2}, { 4, 3}, { 5, 1}, { 6, 0}, { 5, 2}, { 5, 3}, { 6, 1}, { 7, 0}, { 6, 2}, { 6, 3}, { 7, 1}, { 7, 2}, { 7, 3} },{ // 4x8 { 0, 0}, { 0, 1}, { 0, 2}, { 0, 3}, { 1, 0}, { 1, 1}, { 1, 2}, { 0, 4}, { 0, 5}, { 0, 6}, { 0, 7}, { 1, 3}, { 2, 0}, { 2, 1}, { 2, 2}, { 1, 4}, { 1, 5}, { 1, 6}, { 1, 7}, { 2, 3}, { 3, 0}, { 3, 1}, { 3, 2}, { 2, 4}, { 2, 5}, { 2, 6}, { 2, 7}, { 3, 3}, { 3, 4}, { 3, 5}, { 3, 6}, { 3, 7} },{ // 4x4 { 0, 0}, { 0, 1}, { 1, 0}, { 0, 2}, { 0, 3}, { 1, 1}, { 1, 2}, { 1, 3}, { 2, 0}, { 2, 1}, { 2, 2}, { 2, 3}, { 3, 0}, { 3, 1}, { 3, 2}, { 3, 3} } } }; const int ABT_COEFF_COST[4][64] = // TML COEFF_COST 'stretched' for ABT { { // 8 x 8 3,3,3,3,2,2,2,2,2,2,2,2,1,1,1,1, 1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },{ // 8 x 4 3,3,2,2,2,2,1,1,1,1,1,1,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },{ // 4 x 8 3,3,2,2,2,2,1,1,1,1,1,1,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },{ // 4 x 4 3,2,2,1,1,1,0,0,0,0,0,0,0,0,0,0 } }; //identical to table in encoder. See comments there. const char ABT_2D_VLC[NUM_2D_TABLES][16][8]= { { { 0, 1, 5, 13, 21, 31, 39, 47}, {-1, 3, 15, 33, 51, -1, -1, -1}, {-1, 7, 25, 53, -1, -1, -1, -1}, {-1, 9, 35, -1, -1, -1, -1, -1}, {-1, 11, 45, -1, -1, -1, -1, -1}, {-1, 17, 55, -1, -1, -1, -1, -1}, {-1, 19, -1, -1, -1, -1, -1, -1}, {-1, 23, -1, -1, -1, -1, -1, -1}, {-1, 27, -1, -1, -1, -1, -1, -1}, {-1, 29, -1, -1, -1, -1, -1, -1}, {-1, 37, -1, -1, -1, -1, -1, -1}, {-1, 41, -1, -1, -1, -1, -1, -1}, {-1, 43, -1, -1, -1, -1, -1, -1}, {-1, 49, -1, -1, -1, -1, -1, -1}, {-1, 57, -1, -1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1, -1, -1, -1}, },{ { 0, 1, 3, 7, 9, 13, 19, 21}, {-1, 5, 15, 25, 31, 39, 45, 49}, {-1, 11, 29, 41, 51, -1, -1, -1}, {-1, 17, 35, 55, -1, -1, -1, -1}, {-1, 23, 43, -1, -1, -1, -1, -1}, {-1, 27, 57, -1, -1, -1, -1, -1}, {-1, 33, -1, -1, -1, -1, -1, -1}, {-1, 37, -1, -1, -1, -1, -1, -1}, {-1, 47, -1, -1, -1, -1, -1, -1}, {-1, 53, -1, -1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1, -1, -1, -1}, },{ { 0, 1, 3, 9, 13, 19, 23, 31}, {-1, 5, 15, 27, 37, 49, 57, -1}, {-1, 7, 25, 43, -1, -1, -1, -1}, {-1, 11, 35, -1, -1, -1, -1, -1}, {-1, 17, 45, -1, -1, -1, -1, -1}, {-1, 21, 51, -1, -1, -1, -1, -1}, {-1, 29, -1, -1, -1, -1, -1, -1}, {-1, 33, -1, -1, -1, -1, -1, -1}, {-1, 39, -1, -1, -1, -1, -1, -1}, {-1, 41, -1, -1, -1, -1, -1, -1}, {-1, 47, -1, -1, -1, -1, -1, -1}, {-1, 53, -1, -1, -1, -1, -1, -1}, {-1, 55, -1, -1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1, -1, -1, -1}, },{ { 0, 1, 5, 13, 21, 33, 43, 57}, {-1, 3, 17, 31, 49, -1, -1, -1}, {-1, 7, 25, 47, -1, -1, -1, -1}, {-1, 9, 35, -1, -1, -1, -1, -1}, {-1, 11, 41, -1, -1, -1, -1, -1}, {-1, 15, 51, -1, -1, -1, -1, -1}, {-1, 19, -1, -1, -1, -1, -1, -1}, {-1, 23, -1, -1, -1, -1, -1, -1}, {-1, 27, -1, -1, -1, -1, -1, -1}, {-1, 29, -1, -1, -1, -1, -1, -1}, {-1, 37, -1, -1, -1, -1, -1, -1}, {-1, 39, -1, -1, -1, -1, -1, -1}, {-1, 45, -1, -1, -1, -1, -1, -1}, {-1, 53, -1, -1, -1, -1, -1, -1}, {-1, 55, -1, -1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1, -1, -1, -1}, } }; /* const char ABT_2D_VLC[3][16][8]= { { { 0, 1, 7, 21, 39, 47, -1, -1}, {-1, 3, 27, 43, -1, -1, -1, -1}, {-1, 5, 37, -1, -1, -1, -1, -1}, {-1, 9, 45, -1, -1, -1, -1, -1}, {-1, 11, 49, -1, -1, -1, -1, -1}, {-1, 13, 51, -1, -1, -1, -1, -1}, {-1, 15, 53, -1, -1, -1, -1, -1}, {-1, 17, -1, -1, -1, -1, -1, -1}, {-1, 19, -1, -1, -1, -1, -1, -1}, {-1, 23, -1, -1, -1, -1, -1, -1}, {-1, 25, -1, -1, -1, -1, -1, -1}, {-1, 29, -1, -1, -1, -1, -1, -1}, {-1, 31, -1, -1, -1, -1, -1, -1}, {-1, 33, -1, -1, -1, -1, -1, -1}, {-1, 35, -1, -1, -1, -1, -1, -1}, {-1, 41, -1, -1, -1, -1, -1, 55} }, { { 0, 1, 7, 21, 37, 53, -1, -1}, {-1, 3, 19, 41, 57, -1, -1, -1}, {-1, 5, 27, 55, -1, -1, -1, -1}, {-1, 9, 39, -1, -1, -1, -1, -1}, {-1, 11, 43, -1, -1, -1, -1, -1}, {-1, 13, 45, -1, -1, -1, -1, -1}, {-1, 15, 51, -1, -1, -1, -1, -1}, {-1, 17, -1, -1, -1, -1, -1, -1}, {-1, 23, -1, -1, -1, -1, -1, -1}, {-1, 25, -1, -1, -1, -1, -1, -1}, {-1, 29, -1, -1, -1, -1, -1, -1}, {-1, 31, -1, -1, -1, -1, -1, -1}, {-1, 33, -1, -1, -1, -1, -1, -1}, {-1, 35, -1, -1, -1, -1, -1, -1}, {-1, 47, -1, -1, -1, -1, -1, -1}, {-1, 49, -1, -1, -1, -1, -1, 59} }, { { 0, 1, 9, 21, 33, 45, -1, -1}, {-1, 3, 15, 35, 53, -1, -1, -1}, {-1, 5, 25, 43, -1, -1, -1, -1}, {-1, 7, 27, 57, -1, -1, -1, -1}, {-1, 11, 37, -1, -1, -1, -1, -1}, {-1, 13, 39, -1, -1, -1, -1, -1}, {-1, 17, 47, -1, -1, -1, -1, -1}, {-1, 19, 49, -1, -1, -1, -1, -1}, {-1, 23, 51, -1, -1, -1, -1, -1}, {-1, 29, -1, -1, -1, -1, -1, -1}, {-1, 31, -1, -1, -1, -1, -1, -1}, {-1, 41, -1, -1, -1, -1, -1, -1}, {-1, 55, -1, -1, -1, -1, -1, -1}, {-1, 59, -1, -1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1, -1, -1, 61} }, }; */ char ABT_2D_VLC_dec[4][64][2]={{{-1,-1}}}; //The -1 values indicate the table is not valid. It is generated the first time it's needed. It could also be placed here, but that is a potential source of bugs. //masks to be used for the bits in Macroblock->cbp_blk (2.Jan.2001 dahlhoff) // cbp_blk_masks[MB_mode 1..7][subblock 0..15] const unsigned short int cbp_blk_masks[4][4]= { {0x0033U,0xFFFFU,0xFFFFU,0xFFFFU}, {0x0003U,0xFFFFU,0x0030U,0xFFFFU}, {0x0011U,0x0022U,0xFFFFU,0xFFFFU}, {0x0001U,0x0002U,0x0010U,0x0020U} };