Changeset 296 in 3DVCSoftware for trunk/source/Lib/TLibCommon/TComTrQuant.cpp


Ignore:
Timestamp:
20 Feb 2013, 22:07:43 (11 years ago)
Author:
tech
Message:

Reintegrated branch 5.1-dev0 rev. 295.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/Lib/TLibCommon/TComTrQuant.cpp

    r56 r296  
    180180
    181181
    182 #if H0736_AVC_STYLE_QP_RANGE
    183182/** Set qP for Quantization.
    184183 * \param qpy QPy
     
    214213  m_cQP.setQpParam( qpScaled, bLowpass, eSliceType );
    215214}
    216 #else
    217 /// Including Chroma QP Parameter setting
    218 Void TComTrQuant::setQPforQuant( Int iQP, Bool bLowpass, SliceType eSliceType, TextType eTxtType, Int Shift)
    219 {
    220   iQP = Clip3( MIN_QP, MAX_QP, iQP + Shift );
    221  
    222   if(eTxtType != TEXT_LUMA) //Chroma
    223   {
    224     iQP  = g_aucChromaScale[ iQP ];
    225   }
    226  
    227   m_cQP.setQpParam( iQP, bLowpass, eSliceType );
    228 }
    229 #endif
    230215
    231216#if MATRIX_MULT
     
    421406 *  \param shift specifies right shift after 1D transform
    422407 */
    423 #if !UNIFIED_TRANSFORM
    424 void partialButterfly4(short src[4][4],short dst[4][4],int shift)
    425 {
    426   int j; 
    427   int E[2],O[2];
    428   int add = 1<<(shift-1);
    429 
    430   for (j=0; j<4; j++)
    431   {   
    432     /* E and O */
    433     E[0] = src[j][0] + src[j][3];
    434     O[0] = src[j][0] - src[j][3];
    435     E[1] = src[j][1] + src[j][2];
    436     O[1] = src[j][1] - src[j][2];
    437 
    438     dst[0][j] = (g_aiT4[0][0]*E[0] + g_aiT4[0][1]*E[1] + add)>>shift;
    439     dst[2][j] = (g_aiT4[2][0]*E[0] + g_aiT4[2][1]*E[1] + add)>>shift;
    440     dst[1][j] = (g_aiT4[1][0]*O[0] + g_aiT4[1][1]*O[1] + add)>>shift;
    441     dst[3][j] = (g_aiT4[3][0]*O[0] + g_aiT4[3][1]*O[1] + add)>>shift;
    442   }
    443 }
    444 #endif
    445408
    446409void partialButterfly4(short *src,short *dst,int shift, int line)
     
    470433// Fast DST Algorithm. Full matrix multiplication for DST and Fast DST algorithm
    471434// give identical results
    472 #if UNIFIED_TRANSFORM
    473435void fastForwardDst(short *block,short *coeff,int shift)  // input block, output coeff
    474 #else
    475 void fastForwardDst(short block[4][4],short coeff[4][4],int shift)  // input block, output coeff
    476 #endif
    477436{
    478437  int i, c[4];
     
    481440  {
    482441    // Intermediate Variables
    483 #if UNIFIED_TRANSFORM
    484442    c[0] = block[4*i+0] + block[4*i+3];
    485443    c[1] = block[4*i+1] + block[4*i+3];
     
    491449    coeff[ 8+i] =  ( 29 * c[2] + 55 * c[0]         - c[3]               + rnd_factor ) >> shift;
    492450    coeff[12+i] =  ( 55 * c[2] - 29 * c[1]         + c[3]               + rnd_factor ) >> shift;
    493 #else
    494     c[0] = block[i][0] + block[i][3];
    495     c[1] = block[i][1] + block[i][3];
    496     c[2] = block[i][0] - block[i][1];
    497     c[3] = 74* block[i][2];
    498    
    499     coeff[0][i] =  ( 29 * c[0] + 55 * c[1]         + c[3]               + rnd_factor ) >> shift;
    500     coeff[1][i] =  ( 74 * (block[i][0]+ block[i][1] - block[i][3])      + rnd_factor ) >> shift;
    501     coeff[2][i] =  ( 29 * c[2] + 55 * c[0]         - c[3]               + rnd_factor ) >> shift;
    502     coeff[3][i] =  ( 55 * c[2] - 29 * c[1]         + c[3]               + rnd_factor ) >> shift;
    503 #endif
    504   }
    505 }
    506 
    507 #if UNIFIED_TRANSFORM
     451  }
     452}
     453
    508454void fastInverseDst(short *tmp,short *block,int shift)  // input tmp, output block
    509 #else
    510 void fastInverseDst(short tmp[4][4],short block[4][4],int shift)  // input tmp, output block
    511 #endif
    512455{
    513456  int i, c[4];
     
    516459  { 
    517460    // Intermediate Variables
    518 #if UNIFIED_TRANSFORM
    519461    c[0] = tmp[  i] + tmp[ 8+i];
    520462    c[1] = tmp[8+i] + tmp[12+i];
     
    526468    block[4*i+2] = Clip3( -32768, 32767, ( 74 * (tmp[i] - tmp[8+i]  + tmp[12+i])      + rnd_factor ) >> shift );
    527469    block[4*i+3] = Clip3( -32768, 32767, ( 55 * c[0] + 29 * c[2]     - c[3]               + rnd_factor ) >> shift );
    528 #else
    529     c[0] = tmp[0][i] + tmp[2][i];
    530     c[1] = tmp[2][i] + tmp[3][i];
    531     c[2] = tmp[0][i] - tmp[3][i];
    532     c[3] = 74* tmp[1][i];
    533 
    534     block[i][0] = Clip3( -32768, 32767, ( 29 * c[0] + 55 * c[1]     + c[3]               + rnd_factor ) >> shift );
    535     block[i][1] = Clip3( -32768, 32767, ( 55 * c[2] - 29 * c[1]     + c[3]               + rnd_factor ) >> shift );
    536     block[i][2] = Clip3( -32768, 32767, ( 74 * (tmp[0][i] - tmp[2][i]  + tmp[3][i])      + rnd_factor ) >> shift );
    537     block[i][3] = Clip3( -32768, 32767, ( 55 * c[0] + 29 * c[2]     - c[3]               + rnd_factor ) >> shift );
    538 #endif
    539   }
    540 }
    541 #if !UNIFIED_TRANSFORM
    542 /** 4x4 forward transform (2D)
    543  *  \param block input data (residual)
    544  *  \param coeff output data (transform coefficients)
    545  *  \param uiMode is Intra Prediction mode used in Mode-Dependent DCT/DST only
    546  */
    547 void xTr4(short block[4][4],short coeff[4][4],UInt uiMode)
    548 {
    549 #if FULL_NBIT
    550   int shift_1st = 1 + g_uiBitDepth - 8; // log2(4) - 1 + g_uiBitDepth - 8
    551 #else
    552   int shift_1st = 1 + g_uiBitIncrement; // log2(4) - 1 + g_uiBitIncrement
    553 #endif
    554   int shift_2nd = 8;                    // log2(4) + 6
    555   short tmp[4][4];
    556 #if LOGI_INTRA_NAME_3MPM
    557   if (uiMode != REG_DCT && (!uiMode || (uiMode>=2 && uiMode <= 25)))    // Check for DCT or DST
    558 #else
    559   if (uiMode != REG_DCT && g_aucDCTDSTMode_Hor[uiMode])// Check for DCT or DST
    560 #endif
    561   {
    562     fastForwardDst(block,tmp,shift_1st); // Forward DST BY FAST ALGORITHM, block input, tmp output
    563   }
    564   else 
    565   {
    566     partialButterfly4(block,tmp,shift_1st);
    567   }
    568 
    569 #if LOGI_INTRA_NAME_3MPM
    570   if (uiMode != REG_DCT && (!uiMode || (uiMode>=11 && uiMode <= 34)))    // Check for DCT or DST
    571 #else
    572   if (uiMode != REG_DCT && g_aucDCTDSTMode_Vert[uiMode] )   // Check for DCT or DST
    573 #endif
    574   {
    575     fastForwardDst(tmp,coeff,shift_2nd); // Forward DST BY FAST ALGORITHM, tmp input, coeff output
    576   }
    577   else 
    578   {
    579     partialButterfly4(tmp,coeff,shift_2nd);
    580   }   
    581 }
    582 
    583 /** 4x4 inverse transform implemented using partial butterfly structure (1D)
    584  *  \param src   input data (transform coefficients)
    585  *  \param dst   output data (residual)
    586  *  \param shift specifies right shift after 1D transform
    587  */
    588 void partialButterflyInverse4(short src[4][4],short dst[4][4],int shift)
    589 {
    590   int j;   
    591   int E[2],O[2];
    592   int add = 1<<(shift-1);
    593 
    594   for (j=0; j<4; j++)
    595   {   
    596     /* Utilizing symmetry properties to the maximum to minimize the number of multiplications */   
    597     O[0] = g_aiT4[1][0]*src[1][j] + g_aiT4[3][0]*src[3][j];
    598     O[1] = g_aiT4[1][1]*src[1][j] + g_aiT4[3][1]*src[3][j];
    599     E[0] = g_aiT4[0][0]*src[0][j] + g_aiT4[2][0]*src[2][j];
    600     E[1] = g_aiT4[0][1]*src[0][j] + g_aiT4[2][1]*src[2][j];
    601    
    602     /* Combining even and odd terms at each hierarchy levels to calculate the final spatial domain vector */
    603     dst[j][0] = Clip3( -32768, 32767, (E[0] + O[0] + add)>>shift );
    604     dst[j][1] = Clip3( -32768, 32767, (E[1] + O[1] + add)>>shift );
    605     dst[j][2] = Clip3( -32768, 32767, (E[1] - O[1] + add)>>shift );
    606     dst[j][3] = Clip3( -32768, 32767, (E[0] - O[0] + add)>>shift );
    607   }
    608 }
    609 #endif
     470  }
     471}
    610472
    611473void partialButterflyInverse4(short *src,short *dst,int shift, int line)
     
    634496}
    635497
    636 #if !UNIFIED_TRANSFORM
    637 /** 4x4 inverse transform (2D)
    638  *  \param coeff input data (transform coefficients)
    639  *  \param block output data (residual)
    640  *  \param uiMode is Intra Prediction mode used in Mode-Dependent DCT/DST only
    641  */
    642 void xITr4(short coeff[4][4],short block[4][4], UInt uiMode)
    643 {
    644   int shift_1st = SHIFT_INV_1ST;
    645 #if FULL_NBIT
    646   int shift_2nd = SHIFT_INV_2ND - ((short)g_uiBitDepth - 8);
    647 #else
    648   int shift_2nd = SHIFT_INV_2ND - g_uiBitIncrement;
    649 #endif
    650   short tmp[4][4];
    651  
    652 #if LOGI_INTRA_NAME_3MPM
    653   if (uiMode != REG_DCT && (!uiMode || (uiMode>=11 && uiMode <= 34)))    // Check for DCT or DST
    654 #else
    655   if (uiMode != REG_DCT && g_aucDCTDSTMode_Vert[uiMode] )    // Check for DCT or DST
    656 #endif
    657   {
    658     fastInverseDst(coeff,tmp,shift_1st);    // Inverse DST by FAST Algorithm, coeff input, tmp output
    659   }
    660   else
    661   {
    662     partialButterflyInverse4(coeff,tmp,shift_1st);   
    663   }
    664 #if LOGI_INTRA_NAME_3MPM
    665   if (uiMode != REG_DCT && (!uiMode || (uiMode>=2 && uiMode <= 25)))    // Check for DCT or DST
    666 #else
    667   if (uiMode != REG_DCT && g_aucDCTDSTMode_Hor[uiMode] )    // Check for DCT or DST
    668 #endif
    669   {
    670     fastInverseDst(tmp,block,shift_2nd); // Inverse DST by FAST Algorithm, tmp input, coeff output
    671   }
    672   else
    673   {
    674     partialButterflyInverse4(tmp,block,shift_2nd);
    675   }   
    676 }
    677 
    678 /** 8x8 forward transform implemented using partial butterfly structure (1D)
    679  *  \param src   input data (residual)
    680  *  \param dst   output data (transform coefficients)
    681  *  \param shift specifies right shift after 1D transform
    682  */
    683 void partialButterfly8(short src[8][8],short dst[8][8],int shift)
    684 {
    685   int j,k; 
    686   int E[4],O[4];
    687   int EE[2],EO[2];
    688   int add = 1<<(shift-1);
    689 
    690   for (j=0; j<8; j++)
    691   {   
    692     /* E and O*/
    693     for (k=0;k<4;k++)
    694     {
    695       E[k] = src[j][k] + src[j][7-k];
    696       O[k] = src[j][k] - src[j][7-k];
    697     }   
    698     /* EE and EO */
    699     EE[0] = E[0] + E[3];   
    700     EO[0] = E[0] - E[3];
    701     EE[1] = E[1] + E[2];
    702     EO[1] = E[1] - E[2];
    703 
    704     dst[0][j] = (g_aiT8[0][0]*EE[0] + g_aiT8[0][1]*EE[1] + add)>>shift;
    705     dst[4][j] = (g_aiT8[4][0]*EE[0] + g_aiT8[4][1]*EE[1] + add)>>shift;
    706     dst[2][j] = (g_aiT8[2][0]*EO[0] + g_aiT8[2][1]*EO[1] + add)>>shift;
    707     dst[6][j] = (g_aiT8[6][0]*EO[0] + g_aiT8[6][1]*EO[1] + add)>>shift;
    708 
    709     dst[1][j] = (g_aiT8[1][0]*O[0] + g_aiT8[1][1]*O[1] + g_aiT8[1][2]*O[2] + g_aiT8[1][3]*O[3] + add)>>shift;
    710     dst[3][j] = (g_aiT8[3][0]*O[0] + g_aiT8[3][1]*O[1] + g_aiT8[3][2]*O[2] + g_aiT8[3][3]*O[3] + add)>>shift;
    711     dst[5][j] = (g_aiT8[5][0]*O[0] + g_aiT8[5][1]*O[1] + g_aiT8[5][2]*O[2] + g_aiT8[5][3]*O[3] + add)>>shift;
    712     dst[7][j] = (g_aiT8[7][0]*O[0] + g_aiT8[7][1]*O[1] + g_aiT8[7][2]*O[2] + g_aiT8[7][3]*O[3] + add)>>shift;
    713   }
    714 }
    715 #endif
    716498
    717499void partialButterfly8(short *src,short *dst,int shift, int line)
     
    751533}
    752534
    753 #if !UNIFIED_TRANSFORM
    754 /** 8x8 forward transform (2D)
    755  *  \param block input data (residual)
    756  *  \param coeff  output data (transform coefficients)
    757  */
    758 void xTr8(short block[8][8],short coeff[8][8])
    759 {
    760 #if FULL_NBIT
    761   int shift_1st = 2 + g_uiBitDepth - 8; // log2(8) - 1 + g_uiBitDepth - 8
    762 #else
    763   int shift_1st = 2 + g_uiBitIncrement; // log2(8) - 1 + g_uiBitIncrement
    764 #endif
    765   int shift_2nd = 9;                    // log2(8) + 6
    766   short tmp[8][8];
    767 
    768   partialButterfly8(block,tmp,shift_1st);
    769   partialButterfly8(tmp,coeff,shift_2nd);
    770 }
    771 
    772 /** 8x8 inverse transform implemented using partial butterfly structure (1D)
    773  *  \param src   input data (transform coefficients)
    774  *  \param dst   output data (residual)
    775  *  \param shift specifies right shift after 1D transform
    776  */
    777 void partialButterflyInverse8(short src[8][8],short dst[8][8],int shift)
     535
     536void partialButterflyInverse8(short *src,short *dst,int shift, int line)
    778537{
    779538  int j,k;   
     
    782541  int add = 1<<(shift-1);
    783542
    784   for (j=0; j<8; j++)
     543  for (j=0; j<line; j++)
    785544  {   
    786545    /* Utilizing symmetry properties to the maximum to minimize the number of multiplications */
    787546    for (k=0;k<4;k++)
    788547    {
    789       O[k] = g_aiT8[ 1][k]*src[ 1][j] + g_aiT8[ 3][k]*src[ 3][j] + g_aiT8[ 5][k]*src[ 5][j] + g_aiT8[ 7][k]*src[ 7][j];
    790     }
    791    
    792     EO[0] = g_aiT8[2][0]*src[2][j] + g_aiT8[6][0]*src[6][j];
    793     EO[1] = g_aiT8[2][1]*src[2][j] + g_aiT8[6][1]*src[6][j];
    794     EE[0] = g_aiT8[0][0]*src[0][j] + g_aiT8[4][0]*src[4][j];
    795     EE[1] = g_aiT8[0][1]*src[0][j] + g_aiT8[4][1]*src[4][j];
     548      O[k] = g_aiT8[ 1][k]*src[line] + g_aiT8[ 3][k]*src[3*line] + g_aiT8[ 5][k]*src[5*line] + g_aiT8[ 7][k]*src[7*line];
     549    }
     550
     551    EO[0] = g_aiT8[2][0]*src[ 2*line ] + g_aiT8[6][0]*src[ 6*line ];
     552    EO[1] = g_aiT8[2][1]*src[ 2*line ] + g_aiT8[6][1]*src[ 6*line ];
     553    EE[0] = g_aiT8[0][0]*src[ 0      ] + g_aiT8[4][0]*src[ 4*line ];
     554    EE[1] = g_aiT8[0][1]*src[ 0      ] + g_aiT8[4][1]*src[ 4*line ];
    796555
    797556    /* Combining even and odd terms at each hierarchy levels to calculate the final spatial domain vector */
     
    802561    for (k=0;k<4;k++)
    803562    {
    804       dst[j][k]   = Clip3( -32768, 32767, (E[k] + O[k] + add)>>shift );
    805       dst[j][k+4] = Clip3( -32768, 32767, (E[3-k] - O[3-k] + add)>>shift );
    806     }       
    807   }
    808 }
    809 #endif
    810 
    811 void partialButterflyInverse8(short *src,short *dst,int shift, int line)
    812 {
    813   int j,k;   
    814   int E[4],O[4];
    815   int EE[2],EO[2];
    816   int add = 1<<(shift-1);
    817 
    818   for (j=0; j<line; j++)
    819   {   
    820     /* Utilizing symmetry properties to the maximum to minimize the number of multiplications */
    821     for (k=0;k<4;k++)
    822     {
    823       O[k] = g_aiT8[ 1][k]*src[line] + g_aiT8[ 3][k]*src[3*line] + g_aiT8[ 5][k]*src[5*line] + g_aiT8[ 7][k]*src[7*line];
    824     }
    825 
    826     EO[0] = g_aiT8[2][0]*src[ 2*line ] + g_aiT8[6][0]*src[ 6*line ];
    827     EO[1] = g_aiT8[2][1]*src[ 2*line ] + g_aiT8[6][1]*src[ 6*line ];
    828     EE[0] = g_aiT8[0][0]*src[ 0      ] + g_aiT8[4][0]*src[ 4*line ];
    829     EE[1] = g_aiT8[0][1]*src[ 0      ] + g_aiT8[4][1]*src[ 4*line ];
    830 
    831     /* Combining even and odd terms at each hierarchy levels to calculate the final spatial domain vector */
    832     E[0] = EE[0] + EO[0];
    833     E[3] = EE[0] - EO[0];
    834     E[1] = EE[1] + EO[1];
    835     E[2] = EE[1] - EO[1];
    836     for (k=0;k<4;k++)
    837     {
    838563      dst[ k   ] = Clip3( -32768, 32767, (E[k] + O[k] + add)>>shift );
    839564      dst[ k+4 ] = Clip3( -32768, 32767, (E[3-k] - O[3-k] + add)>>shift );
     
    844569}
    845570
    846 #if !UNIFIED_TRANSFORM
    847 /** 8x8 inverse transform (2D)
    848  *  \param coeff input data (transform coefficients)
    849  *  \param block output data (residual)
    850  */
    851 void xITr8(short coeff[8][8],short block[8][8])
     571
     572void partialButterfly16(short *src,short *dst,int shift, int line)
     573{
     574  int j,k;
     575  int E[8],O[8];
     576  int EE[4],EO[4];
     577  int EEE[2],EEO[2];
     578  int add = 1<<(shift-1);
     579
     580  for (j=0; j<line; j++)
     581  {   
     582    /* E and O*/
     583    for (k=0;k<8;k++)
     584    {
     585      E[k] = src[k] + src[15-k];
     586      O[k] = src[k] - src[15-k];
     587    }
     588    /* EE and EO */
     589    for (k=0;k<4;k++)
     590    {
     591      EE[k] = E[k] + E[7-k];
     592      EO[k] = E[k] - E[7-k];
     593    }
     594    /* EEE and EEO */
     595    EEE[0] = EE[0] + EE[3];   
     596    EEO[0] = EE[0] - EE[3];
     597    EEE[1] = EE[1] + EE[2];
     598    EEO[1] = EE[1] - EE[2];
     599
     600    dst[ 0      ] = (g_aiT16[ 0][0]*EEE[0] + g_aiT16[ 0][1]*EEE[1] + add)>>shift;       
     601    dst[ 8*line ] = (g_aiT16[ 8][0]*EEE[0] + g_aiT16[ 8][1]*EEE[1] + add)>>shift;   
     602    dst[ 4*line ] = (g_aiT16[ 4][0]*EEO[0] + g_aiT16[ 4][1]*EEO[1] + add)>>shift;       
     603    dst[ 12*line] = (g_aiT16[12][0]*EEO[0] + g_aiT16[12][1]*EEO[1] + add)>>shift;
     604
     605    for (k=2;k<16;k+=4)
     606    {
     607      dst[ k*line ] = (g_aiT16[k][0]*EO[0] + g_aiT16[k][1]*EO[1] + g_aiT16[k][2]*EO[2] + g_aiT16[k][3]*EO[3] + add)>>shift;     
     608    }
     609
     610    for (k=1;k<16;k+=2)
     611    {
     612      dst[ k*line ] = (g_aiT16[k][0]*O[0] + g_aiT16[k][1]*O[1] + g_aiT16[k][2]*O[2] + g_aiT16[k][3]*O[3] +
     613        g_aiT16[k][4]*O[4] + g_aiT16[k][5]*O[5] + g_aiT16[k][6]*O[6] + g_aiT16[k][7]*O[7] + add)>>shift;
     614    }
     615
     616    src += 16;
     617    dst ++;
     618
     619  }
     620}
     621
     622
     623void partialButterflyInverse16(short *src,short *dst,int shift, int line)
     624{
     625  int j,k; 
     626  int E[8],O[8];
     627  int EE[4],EO[4];
     628  int EEE[2],EEO[2];
     629  int add = 1<<(shift-1);
     630
     631  for (j=0; j<line; j++)
     632  {   
     633    /* Utilizing symmetry properties to the maximum to minimize the number of multiplications */
     634    for (k=0;k<8;k++)
     635    {
     636      O[k] = g_aiT16[ 1][k]*src[ line] + g_aiT16[ 3][k]*src[ 3*line] + g_aiT16[ 5][k]*src[ 5*line] + g_aiT16[ 7][k]*src[ 7*line] +
     637        g_aiT16[ 9][k]*src[ 9*line] + g_aiT16[11][k]*src[11*line] + g_aiT16[13][k]*src[13*line] + g_aiT16[15][k]*src[15*line];
     638    }
     639    for (k=0;k<4;k++)
     640    {
     641      EO[k] = g_aiT16[ 2][k]*src[ 2*line] + g_aiT16[ 6][k]*src[ 6*line] + g_aiT16[10][k]*src[10*line] + g_aiT16[14][k]*src[14*line];
     642    }
     643    EEO[0] = g_aiT16[4][0]*src[ 4*line ] + g_aiT16[12][0]*src[ 12*line ];
     644    EEE[0] = g_aiT16[0][0]*src[ 0      ] + g_aiT16[ 8][0]*src[ 8*line  ];
     645    EEO[1] = g_aiT16[4][1]*src[ 4*line ] + g_aiT16[12][1]*src[ 12*line ];
     646    EEE[1] = g_aiT16[0][1]*src[ 0      ] + g_aiT16[ 8][1]*src[ 8*line  ];
     647
     648    /* Combining even and odd terms at each hierarchy levels to calculate the final spatial domain vector */
     649    for (k=0;k<2;k++)
     650    {
     651      EE[k] = EEE[k] + EEO[k];
     652      EE[k+2] = EEE[1-k] - EEO[1-k];
     653    }   
     654    for (k=0;k<4;k++)
     655    {
     656      E[k] = EE[k] + EO[k];
     657      E[k+4] = EE[3-k] - EO[3-k];
     658    }   
     659    for (k=0;k<8;k++)
     660    {
     661      dst[k]   = Clip3( -32768, 32767, (E[k] + O[k] + add)>>shift );
     662      dst[k+8] = Clip3( -32768, 32767, (E[7-k] - O[7-k] + add)>>shift );
     663    }   
     664    src ++;
     665    dst += 16;
     666  }
     667}
     668
     669
     670void partialButterfly32(short *src,short *dst,int shift, int line)
     671{
     672  int j,k;
     673  int E[16],O[16];
     674  int EE[8],EO[8];
     675  int EEE[4],EEO[4];
     676  int EEEE[2],EEEO[2];
     677  int add = 1<<(shift-1);
     678
     679  for (j=0; j<line; j++)
     680  {   
     681    /* E and O*/
     682    for (k=0;k<16;k++)
     683    {
     684      E[k] = src[k] + src[31-k];
     685      O[k] = src[k] - src[31-k];
     686    }
     687    /* EE and EO */
     688    for (k=0;k<8;k++)
     689    {
     690      EE[k] = E[k] + E[15-k];
     691      EO[k] = E[k] - E[15-k];
     692    }
     693    /* EEE and EEO */
     694    for (k=0;k<4;k++)
     695    {
     696      EEE[k] = EE[k] + EE[7-k];
     697      EEO[k] = EE[k] - EE[7-k];
     698    }
     699    /* EEEE and EEEO */
     700    EEEE[0] = EEE[0] + EEE[3];   
     701    EEEO[0] = EEE[0] - EEE[3];
     702    EEEE[1] = EEE[1] + EEE[2];
     703    EEEO[1] = EEE[1] - EEE[2];
     704
     705    dst[ 0       ] = (g_aiT32[ 0][0]*EEEE[0] + g_aiT32[ 0][1]*EEEE[1] + add)>>shift;
     706    dst[ 16*line ] = (g_aiT32[16][0]*EEEE[0] + g_aiT32[16][1]*EEEE[1] + add)>>shift;
     707    dst[ 8*line  ] = (g_aiT32[ 8][0]*EEEO[0] + g_aiT32[ 8][1]*EEEO[1] + add)>>shift;
     708    dst[ 24*line ] = (g_aiT32[24][0]*EEEO[0] + g_aiT32[24][1]*EEEO[1] + add)>>shift;
     709    for (k=4;k<32;k+=8)
     710    {
     711      dst[ k*line ] = (g_aiT32[k][0]*EEO[0] + g_aiT32[k][1]*EEO[1] + g_aiT32[k][2]*EEO[2] + g_aiT32[k][3]*EEO[3] + add)>>shift;
     712    }       
     713    for (k=2;k<32;k+=4)
     714    {
     715      dst[ k*line ] = (g_aiT32[k][0]*EO[0] + g_aiT32[k][1]*EO[1] + g_aiT32[k][2]*EO[2] + g_aiT32[k][3]*EO[3] +
     716        g_aiT32[k][4]*EO[4] + g_aiT32[k][5]*EO[5] + g_aiT32[k][6]*EO[6] + g_aiT32[k][7]*EO[7] + add)>>shift;
     717    }       
     718    for (k=1;k<32;k+=2)
     719    {
     720      dst[ k*line ] = (g_aiT32[k][ 0]*O[ 0] + g_aiT32[k][ 1]*O[ 1] + g_aiT32[k][ 2]*O[ 2] + g_aiT32[k][ 3]*O[ 3] +
     721        g_aiT32[k][ 4]*O[ 4] + g_aiT32[k][ 5]*O[ 5] + g_aiT32[k][ 6]*O[ 6] + g_aiT32[k][ 7]*O[ 7] +
     722        g_aiT32[k][ 8]*O[ 8] + g_aiT32[k][ 9]*O[ 9] + g_aiT32[k][10]*O[10] + g_aiT32[k][11]*O[11] +
     723        g_aiT32[k][12]*O[12] + g_aiT32[k][13]*O[13] + g_aiT32[k][14]*O[14] + g_aiT32[k][15]*O[15] + add)>>shift;
     724    }
     725    src += 32;
     726    dst ++;
     727  }
     728}
     729
     730
     731void partialButterflyInverse32(short *src,short *dst,int shift, int line)
     732{
     733  int j,k; 
     734  int E[16],O[16];
     735  int EE[8],EO[8];
     736  int EEE[4],EEO[4];
     737  int EEEE[2],EEEO[2];
     738  int add = 1<<(shift-1);
     739
     740  for (j=0; j<line; j++)
     741  {   
     742    /* Utilizing symmetry properties to the maximum to minimize the number of multiplications */
     743    for (k=0;k<16;k++)
     744    {
     745      O[k] = g_aiT32[ 1][k]*src[ line  ] + g_aiT32[ 3][k]*src[ 3*line  ] + g_aiT32[ 5][k]*src[ 5*line  ] + g_aiT32[ 7][k]*src[ 7*line  ] +
     746        g_aiT32[ 9][k]*src[ 9*line  ] + g_aiT32[11][k]*src[ 11*line ] + g_aiT32[13][k]*src[ 13*line ] + g_aiT32[15][k]*src[ 15*line ] +
     747        g_aiT32[17][k]*src[ 17*line ] + g_aiT32[19][k]*src[ 19*line ] + g_aiT32[21][k]*src[ 21*line ] + g_aiT32[23][k]*src[ 23*line ] +
     748        g_aiT32[25][k]*src[ 25*line ] + g_aiT32[27][k]*src[ 27*line ] + g_aiT32[29][k]*src[ 29*line ] + g_aiT32[31][k]*src[ 31*line ];
     749    }
     750    for (k=0;k<8;k++)
     751    {
     752      EO[k] = g_aiT32[ 2][k]*src[ 2*line  ] + g_aiT32[ 6][k]*src[ 6*line  ] + g_aiT32[10][k]*src[ 10*line ] + g_aiT32[14][k]*src[ 14*line ] +
     753        g_aiT32[18][k]*src[ 18*line ] + g_aiT32[22][k]*src[ 22*line ] + g_aiT32[26][k]*src[ 26*line ] + g_aiT32[30][k]*src[ 30*line ];
     754    }
     755    for (k=0;k<4;k++)
     756    {
     757      EEO[k] = g_aiT32[4][k]*src[ 4*line ] + g_aiT32[12][k]*src[ 12*line ] + g_aiT32[20][k]*src[ 20*line ] + g_aiT32[28][k]*src[ 28*line ];
     758    }
     759    EEEO[0] = g_aiT32[8][0]*src[ 8*line ] + g_aiT32[24][0]*src[ 24*line ];
     760    EEEO[1] = g_aiT32[8][1]*src[ 8*line ] + g_aiT32[24][1]*src[ 24*line ];
     761    EEEE[0] = g_aiT32[0][0]*src[ 0      ] + g_aiT32[16][0]*src[ 16*line ];   
     762    EEEE[1] = g_aiT32[0][1]*src[ 0      ] + g_aiT32[16][1]*src[ 16*line ];
     763
     764    /* Combining even and odd terms at each hierarchy levels to calculate the final spatial domain vector */
     765    EEE[0] = EEEE[0] + EEEO[0];
     766    EEE[3] = EEEE[0] - EEEO[0];
     767    EEE[1] = EEEE[1] + EEEO[1];
     768    EEE[2] = EEEE[1] - EEEO[1];   
     769    for (k=0;k<4;k++)
     770    {
     771      EE[k] = EEE[k] + EEO[k];
     772      EE[k+4] = EEE[3-k] - EEO[3-k];
     773    }   
     774    for (k=0;k<8;k++)
     775    {
     776      E[k] = EE[k] + EO[k];
     777      E[k+8] = EE[7-k] - EO[7-k];
     778    }   
     779    for (k=0;k<16;k++)
     780    {
     781      dst[k]    = Clip3( -32768, 32767, (E[k] + O[k] + add)>>shift );
     782      dst[k+16] = Clip3( -32768, 32767, (E[15-k] - O[15-k] + add)>>shift );
     783    }
     784    src ++;
     785    dst += 32;
     786  }
     787}
     788
     789
     790/** MxN forward transform (2D)
     791*  \param block input data (residual)
     792*  \param coeff output data (transform coefficients)
     793*  \param iWidth input data (width of transform)
     794*  \param iHeight input data (height of transform)
     795*/
     796void xTrMxN(short *block,short *coeff, int iWidth, int iHeight, UInt uiMode)
     797{
     798#if FULL_NBIT
     799  int shift_1st = g_aucConvertToBit[iWidth]  + 1 + g_uiBitDepth - 8; // log2(iWidth) - 1 + g_uiBitDepth - 8
     800#else
     801  int shift_1st = g_aucConvertToBit[iWidth]  + 1 + g_uiBitIncrement; // log2(iWidth) - 1 + g_uiBitIncrement
     802#endif
     803  int shift_2nd = g_aucConvertToBit[iHeight]  + 8;                   // log2(iHeight) + 6
     804
     805  short tmp[ 64 * 64 ];
     806
     807  if( iWidth == 16 && iHeight == 4)
     808  {
     809    partialButterfly16( block, tmp, shift_1st, iHeight );
     810    partialButterfly4( tmp, coeff, shift_2nd, iWidth );
     811  }
     812  else if( iWidth == 32 && iHeight == 8 )
     813  {
     814    partialButterfly32( block, tmp, shift_1st, iHeight );
     815    partialButterfly8( tmp, coeff, shift_2nd, iWidth );
     816  }
     817  else if( iWidth == 4 && iHeight == 16)
     818  {
     819    partialButterfly4( block, tmp, shift_1st, iHeight );
     820    partialButterfly16( tmp, coeff, shift_2nd, iWidth );
     821  }
     822  else if( iWidth == 8 && iHeight == 32 )
     823  {
     824    partialButterfly8( block, tmp, shift_1st, iHeight );
     825    partialButterfly32( tmp, coeff, shift_2nd, iWidth );
     826  }
     827  else if( iWidth == 4 && iHeight == 4)
     828  {
     829    if (uiMode != REG_DCT && (!uiMode || (uiMode>=2 && uiMode <= 25)))    // Check for DCT or DST
     830    {
     831      fastForwardDst(block,tmp,shift_1st); // Forward DST BY FAST ALGORITHM, block input, tmp output
     832    }
     833    else 
     834    {
     835      partialButterfly4(block, tmp, shift_1st, iHeight);
     836    }
     837    if (uiMode != REG_DCT && (!uiMode || (uiMode>=11 && uiMode <= 34)))    // Check for DCT or DST
     838    {
     839      fastForwardDst(tmp,coeff,shift_2nd); // Forward DST BY FAST ALGORITHM, tmp input, coeff output
     840    }
     841    else 
     842    {
     843      partialButterfly4(tmp, coeff, shift_2nd, iWidth);
     844    }   
     845  }
     846  else if( iWidth == 8 && iHeight == 8)
     847  {
     848    partialButterfly8( block, tmp, shift_1st, iHeight );
     849    partialButterfly8( tmp, coeff, shift_2nd, iWidth );
     850  }
     851  else if( iWidth == 16 && iHeight == 16)
     852  {
     853    partialButterfly16( block, tmp, shift_1st, iHeight );
     854    partialButterfly16( tmp, coeff, shift_2nd, iWidth );
     855  }
     856  else if( iWidth == 32 && iHeight == 32)
     857  {
     858    partialButterfly32( block, tmp, shift_1st, iHeight );
     859    partialButterfly32( tmp, coeff, shift_2nd, iWidth );
     860  }
     861}
     862/** MxN inverse transform (2D)
     863*  \param coeff input data (transform coefficients)
     864*  \param block output data (residual)
     865*  \param iWidth input data (width of transform)
     866*  \param iHeight input data (height of transform)
     867*/
     868void xITrMxN(short *coeff,short *block, int iWidth, int iHeight, UInt uiMode)
    852869{
    853870  int shift_1st = SHIFT_INV_1ST;
     
    857874  int shift_2nd = SHIFT_INV_2ND - g_uiBitIncrement;
    858875#endif
    859   short tmp[8][8];
    860  
    861   partialButterflyInverse8(coeff,tmp,shift_1st);
    862   partialButterflyInverse8(tmp,block,shift_2nd);
    863 }
    864 
    865 /** 16x16 forward transform implemented using partial butterfly structure (1D)
    866  *  \param src   input data (residual)
    867  *  \param dst   output data (transform coefficients)
    868  *  \param shift specifies right shift after 1D transform
    869  */
    870 void partialButterfly16(short src[16][16],short dst[16][16],int shift)
    871 {
    872   int j,k;
    873   int E[8],O[8];
    874   int EE[4],EO[4];
    875   int EEE[2],EEO[2];
    876   int add = 1<<(shift-1);
    877 
    878   for (j=0; j<16; j++)
    879   {   
    880     /* E and O*/
    881     for (k=0;k<8;k++)
    882     {
    883       E[k] = src[j][k] + src[j][15-k];
    884       O[k] = src[j][k] - src[j][15-k];
    885     }
    886     /* EE and EO */
    887     for (k=0;k<4;k++)
    888     {
    889       EE[k] = E[k] + E[7-k];
    890       EO[k] = E[k] - E[7-k];
    891     }
    892     /* EEE and EEO */
    893     EEE[0] = EE[0] + EE[3];   
    894     EEO[0] = EE[0] - EE[3];
    895     EEE[1] = EE[1] + EE[2];
    896     EEO[1] = EE[1] - EE[2];
    897 
    898     dst[ 0][j] = (g_aiT16[ 0][0]*EEE[0] + g_aiT16[ 0][1]*EEE[1] + add)>>shift;       
    899     dst[ 8][j] = (g_aiT16[ 8][0]*EEE[0] + g_aiT16[ 8][1]*EEE[1] + add)>>shift;   
    900     dst[ 4][j] = (g_aiT16[ 4][0]*EEO[0] + g_aiT16[ 4][1]*EEO[1] + add)>>shift;       
    901     dst[12][j] = (g_aiT16[12][0]*EEO[0] + g_aiT16[12][1]*EEO[1] + add)>>shift;
    902 
    903     for (k=2;k<16;k+=4)
    904     {
    905       dst[k][j] = (g_aiT16[k][0]*EO[0] + g_aiT16[k][1]*EO[1] + g_aiT16[k][2]*EO[2] + g_aiT16[k][3]*EO[3] + add)>>shift;     
    906     }
    907    
    908     for (k=1;k<16;k+=2)
    909     {
    910       dst[k][j] = (g_aiT16[k][0]*O[0] + g_aiT16[k][1]*O[1] + g_aiT16[k][2]*O[2] + g_aiT16[k][3]*O[3] +
    911                      g_aiT16[k][4]*O[4] + g_aiT16[k][5]*O[5] + g_aiT16[k][6]*O[6] + g_aiT16[k][7]*O[7] + add)>>shift;
    912     }
    913 
    914   }
    915 }
    916 #endif
    917 
    918 void partialButterfly16(short *src,short *dst,int shift, int line)
    919 {
    920   int j,k;
    921   int E[8],O[8];
    922   int EE[4],EO[4];
    923   int EEE[2],EEO[2];
    924   int add = 1<<(shift-1);
    925 
    926   for (j=0; j<line; j++)
    927   {   
    928     /* E and O*/
    929     for (k=0;k<8;k++)
    930     {
    931       E[k] = src[k] + src[15-k];
    932       O[k] = src[k] - src[15-k];
    933     }
    934     /* EE and EO */
    935     for (k=0;k<4;k++)
    936     {
    937       EE[k] = E[k] + E[7-k];
    938       EO[k] = E[k] - E[7-k];
    939     }
    940     /* EEE and EEO */
    941     EEE[0] = EE[0] + EE[3];   
    942     EEO[0] = EE[0] - EE[3];
    943     EEE[1] = EE[1] + EE[2];
    944     EEO[1] = EE[1] - EE[2];
    945 
    946     dst[ 0      ] = (g_aiT16[ 0][0]*EEE[0] + g_aiT16[ 0][1]*EEE[1] + add)>>shift;       
    947     dst[ 8*line ] = (g_aiT16[ 8][0]*EEE[0] + g_aiT16[ 8][1]*EEE[1] + add)>>shift;   
    948     dst[ 4*line ] = (g_aiT16[ 4][0]*EEO[0] + g_aiT16[ 4][1]*EEO[1] + add)>>shift;       
    949     dst[ 12*line] = (g_aiT16[12][0]*EEO[0] + g_aiT16[12][1]*EEO[1] + add)>>shift;
    950 
    951     for (k=2;k<16;k+=4)
    952     {
    953       dst[ k*line ] = (g_aiT16[k][0]*EO[0] + g_aiT16[k][1]*EO[1] + g_aiT16[k][2]*EO[2] + g_aiT16[k][3]*EO[3] + add)>>shift;     
    954     }
    955 
    956     for (k=1;k<16;k+=2)
    957     {
    958       dst[ k*line ] = (g_aiT16[k][0]*O[0] + g_aiT16[k][1]*O[1] + g_aiT16[k][2]*O[2] + g_aiT16[k][3]*O[3] +
    959         g_aiT16[k][4]*O[4] + g_aiT16[k][5]*O[5] + g_aiT16[k][6]*O[6] + g_aiT16[k][7]*O[7] + add)>>shift;
    960     }
    961 
    962     src += 16;
    963     dst ++;
    964 
    965   }
    966 }
    967 
    968 #if !UNIFIED_TRANSFORM
    969 /** 16x16 forward transform (2D)
    970  *  \param block input data (residual)
    971  *  \param coeff output data (transform coefficients)
    972  */
    973 void xTr16(short block[16][16],short coeff[16][16])
    974 {
    975  #if FULL_NBIT
    976   int shift_1st = 3 + g_uiBitDepth - 8; // log2(16) - 1 + g_uiBitDepth - 8
    977 #else
    978   int shift_1st = 3 + g_uiBitIncrement; // log2(16) - 1 + g_uiBitIncrement
    979 #endif
    980   int shift_2nd = 10;                   // log2(16) + 6
    981   short tmp[16][16];
    982 
    983   partialButterfly16(block,tmp,shift_1st);
    984   partialButterfly16(tmp,coeff,shift_2nd);
    985 }
    986 
    987 /** 16x16 inverse transform implemented using partial butterfly structure (1D)
    988  *  \param src   input data (transform coefficients)
    989  *  \param dst   output data (residual)
    990  *  \param shift specifies right shift after 1D transform
    991  */
    992 void partialButterflyInverse16(short src[16][16],short dst[16][16],int shift)
    993 {
    994   int j,k; 
    995   int E[8],O[8];
    996   int EE[4],EO[4];
    997   int EEE[2],EEO[2];
    998   int add = 1<<(shift-1);
    999 
    1000   for (j=0; j<16; j++)
    1001   {   
    1002     /* Utilizing symmetry properties to the maximum to minimize the number of multiplications */
    1003     for (k=0;k<8;k++)
    1004     {
    1005       O[k] = g_aiT16[ 1][k]*src[ 1][j] + g_aiT16[ 3][k]*src[ 3][j] + g_aiT16[ 5][k]*src[ 5][j] + g_aiT16[ 7][k]*src[ 7][j] +
    1006              g_aiT16[ 9][k]*src[ 9][j] + g_aiT16[11][k]*src[11][j] + g_aiT16[13][k]*src[13][j] + g_aiT16[15][k]*src[15][j];
    1007     }
    1008     for (k=0;k<4;k++)
    1009     {
    1010       EO[k] = g_aiT16[ 2][k]*src[ 2][j] + g_aiT16[ 6][k]*src[ 6][j] + g_aiT16[10][k]*src[10][j] + g_aiT16[14][k]*src[14][j];
    1011     }
    1012     EEO[0] = g_aiT16[4][0]*src[4][j] + g_aiT16[12][0]*src[12][j];
    1013     EEE[0] = g_aiT16[0][0]*src[0][j] + g_aiT16[ 8][0]*src[ 8][j];
    1014     EEO[1] = g_aiT16[4][1]*src[4][j] + g_aiT16[12][1]*src[12][j];
    1015     EEE[1] = g_aiT16[0][1]*src[0][j] + g_aiT16[ 8][1]*src[ 8][j];
    1016 
    1017     /* Combining even and odd terms at each hierarchy levels to calculate the final spatial domain vector */
    1018     for (k=0;k<2;k++)
    1019     {
    1020       EE[k] = EEE[k] + EEO[k];
    1021       EE[k+2] = EEE[1-k] - EEO[1-k];
    1022     }   
    1023     for (k=0;k<4;k++)
    1024     {
    1025       E[k] = EE[k] + EO[k];
    1026       E[k+4] = EE[3-k] - EO[3-k];
    1027     }   
    1028     for (k=0;k<8;k++)
    1029     {
    1030       dst[j][k]   = Clip3( -32768, 32767, (E[k] + O[k] + add)>>shift );
    1031       dst[j][k+8] = Clip3( -32768, 32767, (E[7-k] - O[7-k] + add)>>shift );
    1032     }       
    1033   }
    1034 }
    1035 #endif
    1036 
    1037 void partialButterflyInverse16(short *src,short *dst,int shift, int line)
    1038 {
    1039   int j,k; 
    1040   int E[8],O[8];
    1041   int EE[4],EO[4];
    1042   int EEE[2],EEO[2];
    1043   int add = 1<<(shift-1);
    1044 
    1045   for (j=0; j<line; j++)
    1046   {   
    1047     /* Utilizing symmetry properties to the maximum to minimize the number of multiplications */
    1048     for (k=0;k<8;k++)
    1049     {
    1050       O[k] = g_aiT16[ 1][k]*src[ line] + g_aiT16[ 3][k]*src[ 3*line] + g_aiT16[ 5][k]*src[ 5*line] + g_aiT16[ 7][k]*src[ 7*line] +
    1051         g_aiT16[ 9][k]*src[ 9*line] + g_aiT16[11][k]*src[11*line] + g_aiT16[13][k]*src[13*line] + g_aiT16[15][k]*src[15*line];
    1052     }
    1053     for (k=0;k<4;k++)
    1054     {
    1055       EO[k] = g_aiT16[ 2][k]*src[ 2*line] + g_aiT16[ 6][k]*src[ 6*line] + g_aiT16[10][k]*src[10*line] + g_aiT16[14][k]*src[14*line];
    1056     }
    1057     EEO[0] = g_aiT16[4][0]*src[ 4*line ] + g_aiT16[12][0]*src[ 12*line ];
    1058     EEE[0] = g_aiT16[0][0]*src[ 0      ] + g_aiT16[ 8][0]*src[ 8*line  ];
    1059     EEO[1] = g_aiT16[4][1]*src[ 4*line ] + g_aiT16[12][1]*src[ 12*line ];
    1060     EEE[1] = g_aiT16[0][1]*src[ 0      ] + g_aiT16[ 8][1]*src[ 8*line  ];
    1061 
    1062     /* Combining even and odd terms at each hierarchy levels to calculate the final spatial domain vector */
    1063     for (k=0;k<2;k++)
    1064     {
    1065       EE[k] = EEE[k] + EEO[k];
    1066       EE[k+2] = EEE[1-k] - EEO[1-k];
    1067     }   
    1068     for (k=0;k<4;k++)
    1069     {
    1070       E[k] = EE[k] + EO[k];
    1071       E[k+4] = EE[3-k] - EO[3-k];
    1072     }   
    1073     for (k=0;k<8;k++)
    1074     {
    1075       dst[k]   = Clip3( -32768, 32767, (E[k] + O[k] + add)>>shift );
    1076       dst[k+8] = Clip3( -32768, 32767, (E[7-k] - O[7-k] + add)>>shift );
    1077     }   
    1078     src ++;
    1079     dst += 16;
    1080   }
    1081 }
    1082 
    1083 #if !UNIFIED_TRANSFORM
    1084 /** 16x16 inverse transform (2D)
    1085  *  \param coeff input data (transform coefficients)
    1086  *  \param block output data (residual)
    1087  */
    1088 void xITr16(short coeff[16][16],short block[16][16])
    1089 {
    1090   int shift_1st = SHIFT_INV_1ST;
    1091 #if FULL_NBIT
    1092   int shift_2nd = SHIFT_INV_2ND - ((short)g_uiBitDepth - 8);
    1093 #else
    1094   int shift_2nd = SHIFT_INV_2ND - g_uiBitIncrement;
    1095 #endif
    1096   short tmp[16][16];
    1097  
    1098   partialButterflyInverse16(coeff,tmp,shift_1st);
    1099   partialButterflyInverse16(tmp,block,shift_2nd);
    1100 }
    1101 
    1102 /** 32x32 forward transform implemented using partial butterfly structure (1D)
    1103  *  \param src   input data (residual)
    1104  *  \param dst   output data (transform coefficients)
    1105  *  \param shift specifies right shift after 1D transform
    1106  */
    1107 void partialButterfly32(short src[32][32],short dst[32][32],int shift)
    1108 {
    1109   int j,k;
    1110   int E[16],O[16];
    1111   int EE[8],EO[8];
    1112   int EEE[4],EEO[4];
    1113   int EEEE[2],EEEO[2];
    1114   int add = 1<<(shift-1);
    1115 
    1116   for (j=0; j<32; j++)
    1117   {   
    1118     /* E and O*/
    1119     for (k=0;k<16;k++)
    1120     {
    1121       E[k] = src[j][k] + src[j][31-k];
    1122       O[k] = src[j][k] - src[j][31-k];
    1123     }
    1124     /* EE and EO */
    1125     for (k=0;k<8;k++)
    1126     {
    1127       EE[k] = E[k] + E[15-k];
    1128       EO[k] = E[k] - E[15-k];
    1129     }
    1130     /* EEE and EEO */
    1131     for (k=0;k<4;k++)
    1132     {
    1133       EEE[k] = EE[k] + EE[7-k];
    1134       EEO[k] = EE[k] - EE[7-k];
    1135     }
    1136     /* EEEE and EEEO */
    1137     EEEE[0] = EEE[0] + EEE[3];   
    1138     EEEO[0] = EEE[0] - EEE[3];
    1139     EEEE[1] = EEE[1] + EEE[2];
    1140     EEEO[1] = EEE[1] - EEE[2];
    1141 
    1142     dst[ 0][j] = (g_aiT32[ 0][0]*EEEE[0] + g_aiT32[ 0][1]*EEEE[1] + add)>>shift;
    1143     dst[16][j] = (g_aiT32[16][0]*EEEE[0] + g_aiT32[16][1]*EEEE[1] + add)>>shift;
    1144     dst[ 8][j] = (g_aiT32[ 8][0]*EEEO[0] + g_aiT32[ 8][1]*EEEO[1] + add)>>shift;
    1145     dst[24][j] = (g_aiT32[24][0]*EEEO[0] + g_aiT32[24][1]*EEEO[1] + add)>>shift;
    1146     for (k=4;k<32;k+=8)
    1147     {
    1148       dst[k][j] = (g_aiT32[k][0]*EEO[0] + g_aiT32[k][1]*EEO[1] + g_aiT32[k][2]*EEO[2] + g_aiT32[k][3]*EEO[3] + add)>>shift;
    1149     }       
    1150     for (k=2;k<32;k+=4)
    1151     {
    1152       dst[k][j] = (g_aiT32[k][0]*EO[0] + g_aiT32[k][1]*EO[1] + g_aiT32[k][2]*EO[2] + g_aiT32[k][3]*EO[3] +
    1153                      g_aiT32[k][4]*EO[4] + g_aiT32[k][5]*EO[5] + g_aiT32[k][6]*EO[6] + g_aiT32[k][7]*EO[7] + add)>>shift;
    1154     }       
    1155     for (k=1;k<32;k+=2)
    1156     {
    1157       dst[k][j] = (g_aiT32[k][ 0]*O[ 0] + g_aiT32[k][ 1]*O[ 1] + g_aiT32[k][ 2]*O[ 2] + g_aiT32[k][ 3]*O[ 3] +
    1158                      g_aiT32[k][ 4]*O[ 4] + g_aiT32[k][ 5]*O[ 5] + g_aiT32[k][ 6]*O[ 6] + g_aiT32[k][ 7]*O[ 7] +
    1159                      g_aiT32[k][ 8]*O[ 8] + g_aiT32[k][ 9]*O[ 9] + g_aiT32[k][10]*O[10] + g_aiT32[k][11]*O[11] +
    1160                      g_aiT32[k][12]*O[12] + g_aiT32[k][13]*O[13] + g_aiT32[k][14]*O[14] + g_aiT32[k][15]*O[15] + add)>>shift;
    1161     }
    1162   }
    1163 }
    1164 #endif
    1165 
    1166 void partialButterfly32(short *src,short *dst,int shift, int line)
    1167 {
    1168   int j,k;
    1169   int E[16],O[16];
    1170   int EE[8],EO[8];
    1171   int EEE[4],EEO[4];
    1172   int EEEE[2],EEEO[2];
    1173   int add = 1<<(shift-1);
    1174 
    1175   for (j=0; j<line; j++)
    1176   {   
    1177     /* E and O*/
    1178     for (k=0;k<16;k++)
    1179     {
    1180       E[k] = src[k] + src[31-k];
    1181       O[k] = src[k] - src[31-k];
    1182     }
    1183     /* EE and EO */
    1184     for (k=0;k<8;k++)
    1185     {
    1186       EE[k] = E[k] + E[15-k];
    1187       EO[k] = E[k] - E[15-k];
    1188     }
    1189     /* EEE and EEO */
    1190     for (k=0;k<4;k++)
    1191     {
    1192       EEE[k] = EE[k] + EE[7-k];
    1193       EEO[k] = EE[k] - EE[7-k];
    1194     }
    1195     /* EEEE and EEEO */
    1196     EEEE[0] = EEE[0] + EEE[3];   
    1197     EEEO[0] = EEE[0] - EEE[3];
    1198     EEEE[1] = EEE[1] + EEE[2];
    1199     EEEO[1] = EEE[1] - EEE[2];
    1200 
    1201     dst[ 0       ] = (g_aiT32[ 0][0]*EEEE[0] + g_aiT32[ 0][1]*EEEE[1] + add)>>shift;
    1202     dst[ 16*line ] = (g_aiT32[16][0]*EEEE[0] + g_aiT32[16][1]*EEEE[1] + add)>>shift;
    1203     dst[ 8*line  ] = (g_aiT32[ 8][0]*EEEO[0] + g_aiT32[ 8][1]*EEEO[1] + add)>>shift;
    1204     dst[ 24*line ] = (g_aiT32[24][0]*EEEO[0] + g_aiT32[24][1]*EEEO[1] + add)>>shift;
    1205     for (k=4;k<32;k+=8)
    1206     {
    1207       dst[ k*line ] = (g_aiT32[k][0]*EEO[0] + g_aiT32[k][1]*EEO[1] + g_aiT32[k][2]*EEO[2] + g_aiT32[k][3]*EEO[3] + add)>>shift;
    1208     }       
    1209     for (k=2;k<32;k+=4)
    1210     {
    1211       dst[ k*line ] = (g_aiT32[k][0]*EO[0] + g_aiT32[k][1]*EO[1] + g_aiT32[k][2]*EO[2] + g_aiT32[k][3]*EO[3] +
    1212         g_aiT32[k][4]*EO[4] + g_aiT32[k][5]*EO[5] + g_aiT32[k][6]*EO[6] + g_aiT32[k][7]*EO[7] + add)>>shift;
    1213     }       
    1214     for (k=1;k<32;k+=2)
    1215     {
    1216       dst[ k*line ] = (g_aiT32[k][ 0]*O[ 0] + g_aiT32[k][ 1]*O[ 1] + g_aiT32[k][ 2]*O[ 2] + g_aiT32[k][ 3]*O[ 3] +
    1217         g_aiT32[k][ 4]*O[ 4] + g_aiT32[k][ 5]*O[ 5] + g_aiT32[k][ 6]*O[ 6] + g_aiT32[k][ 7]*O[ 7] +
    1218         g_aiT32[k][ 8]*O[ 8] + g_aiT32[k][ 9]*O[ 9] + g_aiT32[k][10]*O[10] + g_aiT32[k][11]*O[11] +
    1219         g_aiT32[k][12]*O[12] + g_aiT32[k][13]*O[13] + g_aiT32[k][14]*O[14] + g_aiT32[k][15]*O[15] + add)>>shift;
    1220     }
    1221     src += 32;
    1222     dst ++;
    1223   }
    1224 }
    1225 
    1226 #if !UNIFIED_TRANSFORM
    1227 /** 32x32 forward transform (2D)
    1228  *  \param block input data (residual)
    1229  *  \param coeff output data (transform coefficients)
    1230  */
    1231 void xTr32(short block[32][32],short coeff[32][32])
    1232 {
    1233  #if FULL_NBIT
    1234   int shift_1st = 4 + g_uiBitDepth - 8; // log2(32) - 1 + g_uiBitDepth - 8
    1235 #else
    1236   int shift_1st = 4 + g_uiBitIncrement; // log2(32) - 1 + g_uiBitIncrement
    1237 #endif
    1238   int shift_2nd = 11;                   // log2(32) + 6
    1239   short tmp[32][32];
    1240 
    1241   partialButterfly32(block,tmp,shift_1st);
    1242   partialButterfly32(tmp,coeff,shift_2nd);
    1243 }
    1244 
    1245 /** 32x32 inverse transform implemented using partial butterfly structure (1D)
    1246  *  \param src   input data (transform coefficients)
    1247  *  \param dst   output data (residual)
    1248  *  \param shift specifies right shift after 1D transform
    1249  */
    1250 void partialButterflyInverse32(short src[32][32],short dst[32][32],int shift)
    1251 {
    1252   int j,k; 
    1253   int E[16],O[16];
    1254   int EE[8],EO[8];
    1255   int EEE[4],EEO[4];
    1256   int EEEE[2],EEEO[2];
    1257   int add = 1<<(shift-1);
    1258 
    1259   for (j=0; j<32; j++)
    1260   {   
    1261     /* Utilizing symmetry properties to the maximum to minimize the number of multiplications */
    1262     for (k=0;k<16;k++)
    1263     {
    1264       O[k] = g_aiT32[ 1][k]*src[ 1][j] + g_aiT32[ 3][k]*src[ 3][j] + g_aiT32[ 5][k]*src[ 5][j] + g_aiT32[ 7][k]*src[ 7][j] +
    1265              g_aiT32[ 9][k]*src[ 9][j] + g_aiT32[11][k]*src[11][j] + g_aiT32[13][k]*src[13][j] + g_aiT32[15][k]*src[15][j] +
    1266              g_aiT32[17][k]*src[17][j] + g_aiT32[19][k]*src[19][j] + g_aiT32[21][k]*src[21][j] + g_aiT32[23][k]*src[23][j] +
    1267              g_aiT32[25][k]*src[25][j] + g_aiT32[27][k]*src[27][j] + g_aiT32[29][k]*src[29][j] + g_aiT32[31][k]*src[31][j];
    1268     }
    1269     for (k=0;k<8;k++)
    1270     {
    1271       EO[k] = g_aiT32[ 2][k]*src[ 2][j] + g_aiT32[ 6][k]*src[ 6][j] + g_aiT32[10][k]*src[10][j] + g_aiT32[14][k]*src[14][j] +
    1272               g_aiT32[18][k]*src[18][j] + g_aiT32[22][k]*src[22][j] + g_aiT32[26][k]*src[26][j] + g_aiT32[30][k]*src[30][j];
    1273     }
    1274     for (k=0;k<4;k++)
    1275     {
    1276       EEO[k] = g_aiT32[4][k]*src[4][j] + g_aiT32[12][k]*src[12][j] + g_aiT32[20][k]*src[20][j] + g_aiT32[28][k]*src[28][j];
    1277     }
    1278     EEEO[0] = g_aiT32[8][0]*src[8][j] + g_aiT32[24][0]*src[24][j];
    1279     EEEO[1] = g_aiT32[8][1]*src[8][j] + g_aiT32[24][1]*src[24][j];
    1280     EEEE[0] = g_aiT32[0][0]*src[0][j] + g_aiT32[16][0]*src[16][j];   
    1281     EEEE[1] = g_aiT32[0][1]*src[0][j] + g_aiT32[16][1]*src[16][j];
    1282 
    1283     /* Combining even and odd terms at each hierarchy levels to calculate the final spatial domain vector */
    1284     EEE[0] = EEEE[0] + EEEO[0];
    1285     EEE[3] = EEEE[0] - EEEO[0];
    1286     EEE[1] = EEEE[1] + EEEO[1];
    1287     EEE[2] = EEEE[1] - EEEO[1];   
    1288     for (k=0;k<4;k++)
    1289     {
    1290       EE[k] = EEE[k] + EEO[k];
    1291       EE[k+4] = EEE[3-k] - EEO[3-k];
    1292     }   
    1293     for (k=0;k<8;k++)
    1294     {
    1295       E[k] = EE[k] + EO[k];
    1296       E[k+8] = EE[7-k] - EO[7-k];
    1297     }   
    1298     for (k=0;k<16;k++)
    1299     {
    1300       dst[j][k]    = Clip3( -32768, 32767, (E[k] + O[k] + add)>>shift );
    1301       dst[j][k+16] = Clip3( -32768, 32767, (E[15-k] - O[15-k] + add)>>shift );
    1302     }       
    1303   }
    1304 }
    1305 #endif
    1306 
    1307 void partialButterflyInverse32(short *src,short *dst,int shift, int line)
    1308 {
    1309   int j,k; 
    1310   int E[16],O[16];
    1311   int EE[8],EO[8];
    1312   int EEE[4],EEO[4];
    1313   int EEEE[2],EEEO[2];
    1314   int add = 1<<(shift-1);
    1315 
    1316   for (j=0; j<line; j++)
    1317   {   
    1318     /* Utilizing symmetry properties to the maximum to minimize the number of multiplications */
    1319     for (k=0;k<16;k++)
    1320     {
    1321       O[k] = g_aiT32[ 1][k]*src[ line  ] + g_aiT32[ 3][k]*src[ 3*line  ] + g_aiT32[ 5][k]*src[ 5*line  ] + g_aiT32[ 7][k]*src[ 7*line  ] +
    1322         g_aiT32[ 9][k]*src[ 9*line  ] + g_aiT32[11][k]*src[ 11*line ] + g_aiT32[13][k]*src[ 13*line ] + g_aiT32[15][k]*src[ 15*line ] +
    1323         g_aiT32[17][k]*src[ 17*line ] + g_aiT32[19][k]*src[ 19*line ] + g_aiT32[21][k]*src[ 21*line ] + g_aiT32[23][k]*src[ 23*line ] +
    1324         g_aiT32[25][k]*src[ 25*line ] + g_aiT32[27][k]*src[ 27*line ] + g_aiT32[29][k]*src[ 29*line ] + g_aiT32[31][k]*src[ 31*line ];
    1325     }
    1326     for (k=0;k<8;k++)
    1327     {
    1328       EO[k] = g_aiT32[ 2][k]*src[ 2*line  ] + g_aiT32[ 6][k]*src[ 6*line  ] + g_aiT32[10][k]*src[ 10*line ] + g_aiT32[14][k]*src[ 14*line ] +
    1329         g_aiT32[18][k]*src[ 18*line ] + g_aiT32[22][k]*src[ 22*line ] + g_aiT32[26][k]*src[ 26*line ] + g_aiT32[30][k]*src[ 30*line ];
    1330     }
    1331     for (k=0;k<4;k++)
    1332     {
    1333       EEO[k] = g_aiT32[4][k]*src[ 4*line ] + g_aiT32[12][k]*src[ 12*line ] + g_aiT32[20][k]*src[ 20*line ] + g_aiT32[28][k]*src[ 28*line ];
    1334     }
    1335     EEEO[0] = g_aiT32[8][0]*src[ 8*line ] + g_aiT32[24][0]*src[ 24*line ];
    1336     EEEO[1] = g_aiT32[8][1]*src[ 8*line ] + g_aiT32[24][1]*src[ 24*line ];
    1337     EEEE[0] = g_aiT32[0][0]*src[ 0      ] + g_aiT32[16][0]*src[ 16*line ];   
    1338     EEEE[1] = g_aiT32[0][1]*src[ 0      ] + g_aiT32[16][1]*src[ 16*line ];
    1339 
    1340     /* Combining even and odd terms at each hierarchy levels to calculate the final spatial domain vector */
    1341     EEE[0] = EEEE[0] + EEEO[0];
    1342     EEE[3] = EEEE[0] - EEEO[0];
    1343     EEE[1] = EEEE[1] + EEEO[1];
    1344     EEE[2] = EEEE[1] - EEEO[1];   
    1345     for (k=0;k<4;k++)
    1346     {
    1347       EE[k] = EEE[k] + EEO[k];
    1348       EE[k+4] = EEE[3-k] - EEO[3-k];
    1349     }   
    1350     for (k=0;k<8;k++)
    1351     {
    1352       E[k] = EE[k] + EO[k];
    1353       E[k+8] = EE[7-k] - EO[7-k];
    1354     }   
    1355     for (k=0;k<16;k++)
    1356     {
    1357       dst[k]    = Clip3( -32768, 32767, (E[k] + O[k] + add)>>shift );
    1358       dst[k+16] = Clip3( -32768, 32767, (E[15-k] - O[15-k] + add)>>shift );
    1359     }
    1360     src ++;
    1361     dst += 32;
    1362   }
    1363 }
    1364 
    1365 #if !UNIFIED_TRANSFORM
    1366 /** 32x32 inverse transform (2D)
    1367  *  \param coeff input data (transform coefficients)
    1368  *  \param block output data (residual)
    1369  */
    1370 void xITr32(short coeff[32][32],short block[32][32])
    1371 {
    1372   int shift_1st = SHIFT_INV_1ST;
    1373 #if FULL_NBIT
    1374   int shift_2nd = SHIFT_INV_2ND - ((short)g_uiBitDepth - 8);
    1375 #else
    1376   int shift_2nd = SHIFT_INV_2ND - g_uiBitIncrement;
    1377 #endif
    1378   short tmp[32][32];
    1379  
    1380   partialButterflyInverse32(coeff,tmp,shift_1st);
    1381   partialButterflyInverse32(tmp,block,shift_2nd);
    1382 }
    1383 #endif
    1384 
    1385 /** MxN forward transform (2D)
    1386 *  \param block input data (residual)
    1387 *  \param coeff output data (transform coefficients)
    1388 *  \param iWidth input data (width of transform)
    1389 *  \param iHeight input data (height of transform)
    1390 */
    1391 #if UNIFIED_TRANSFORM
    1392 void xTrMxN(short *block,short *coeff, int iWidth, int iHeight, UInt uiMode)
    1393 #else
    1394 void xTrMxN(short *block,short *coeff, int iWidth, int iHeight)
    1395 #endif
    1396 {
    1397 #if FULL_NBIT
    1398   int shift_1st = g_aucConvertToBit[iWidth]  + 1 + g_uiBitDepth - 8; // log2(iWidth) - 1 + g_uiBitDepth - 8
    1399 #else
    1400   int shift_1st = g_aucConvertToBit[iWidth]  + 1 + g_uiBitIncrement; // log2(iWidth) - 1 + g_uiBitIncrement
    1401 #endif
    1402   int shift_2nd = g_aucConvertToBit[iHeight]  + 8;                   // log2(iHeight) + 6
    1403 
    1404   short tmp[ 64 * 64 ];
    1405 
    1406   if( iWidth == 16 && iHeight == 4)
    1407   {
    1408     partialButterfly16( block, tmp, shift_1st, iHeight );
    1409     partialButterfly4( tmp, coeff, shift_2nd, iWidth );
    1410   }
    1411   else if( iWidth == 32 && iHeight == 8 )
    1412   {
    1413     partialButterfly32( block, tmp, shift_1st, iHeight );
    1414     partialButterfly8( tmp, coeff, shift_2nd, iWidth );
    1415   }
    1416   else if( iWidth == 4 && iHeight == 16)
    1417   {
    1418     partialButterfly4( block, tmp, shift_1st, iHeight );
    1419     partialButterfly16( tmp, coeff, shift_2nd, iWidth );
    1420   }
    1421   else if( iWidth == 8 && iHeight == 32 )
    1422   {
    1423     partialButterfly8( block, tmp, shift_1st, iHeight );
    1424     partialButterfly32( tmp, coeff, shift_2nd, iWidth );
    1425   }
    1426 #if UNIFIED_TRANSFORM
    1427   else if( iWidth == 4 && iHeight == 4)
    1428   {
    1429 #if LOGI_INTRA_NAME_3MPM
    1430     if (uiMode != REG_DCT && (!uiMode || (uiMode>=2 && uiMode <= 25)))    // Check for DCT or DST
    1431 #else
    1432     if (uiMode != REG_DCT && g_aucDCTDSTMode_Hor[uiMode])// Check for DCT or DST
    1433 #endif
    1434     {
    1435       fastForwardDst(block,tmp,shift_1st); // Forward DST BY FAST ALGORITHM, block input, tmp output
    1436     }
    1437     else 
    1438     {
    1439       partialButterfly4(block, tmp, shift_1st, iHeight);
    1440     }
    1441 #if LOGI_INTRA_NAME_3MPM
    1442     if (uiMode != REG_DCT && (!uiMode || (uiMode>=11 && uiMode <= 34)))    // Check for DCT or DST
    1443 #else
    1444     if (uiMode != REG_DCT && g_aucDCTDSTMode_Vert[uiMode] )   // Check for DCT or DST
    1445 #endif
    1446     {
    1447       fastForwardDst(tmp,coeff,shift_2nd); // Forward DST BY FAST ALGORITHM, tmp input, coeff output
    1448     }
    1449     else 
    1450     {
    1451       partialButterfly4(tmp, coeff, shift_2nd, iWidth);
    1452     }   
    1453   }
    1454   else if( iWidth == 8 && iHeight == 8)
    1455   {
    1456     partialButterfly8( block, tmp, shift_1st, iHeight );
    1457     partialButterfly8( tmp, coeff, shift_2nd, iWidth );
    1458   }
    1459   else if( iWidth == 16 && iHeight == 16)
    1460   {
    1461     partialButterfly16( block, tmp, shift_1st, iHeight );
    1462     partialButterfly16( tmp, coeff, shift_2nd, iWidth );
    1463   }
    1464   else if( iWidth == 32 && iHeight == 32)
    1465   {
    1466     partialButterfly32( block, tmp, shift_1st, iHeight );
    1467     partialButterfly32( tmp, coeff, shift_2nd, iWidth );
    1468   }
    1469 #endif
    1470 }
    1471 /** MxN inverse transform (2D)
    1472 *  \param coeff input data (transform coefficients)
    1473 *  \param block output data (residual)
    1474 *  \param iWidth input data (width of transform)
    1475 *  \param iHeight input data (height of transform)
    1476 */
    1477 #if UNIFIED_TRANSFORM
    1478 void xITrMxN(short *coeff,short *block, int iWidth, int iHeight, UInt uiMode)
    1479 #else
    1480 void xITrMxN(short *coeff,short *block, int iWidth, int iHeight)
    1481 #endif
    1482 {
    1483   int shift_1st = SHIFT_INV_1ST;
    1484 #if FULL_NBIT
    1485   int shift_2nd = SHIFT_INV_2ND - ((short)g_uiBitDepth - 8);
    1486 #else
    1487   int shift_2nd = SHIFT_INV_2ND - g_uiBitIncrement;
    1488 #endif
    1489876
    1490877  short tmp[ 64*64];
     
    1509896    partialButterflyInverse8(tmp,block,shift_2nd,iHeight);
    1510897  }
    1511 #if UNIFIED_TRANSFORM
    1512898  else if( iWidth == 4 && iHeight == 4)
    1513899  {
    1514 #if LOGI_INTRA_NAME_3MPM
    1515900    if (uiMode != REG_DCT && (!uiMode || (uiMode>=11 && uiMode <= 34)))    // Check for DCT or DST
    1516 #else
    1517     if (uiMode != REG_DCT && g_aucDCTDSTMode_Vert[uiMode] )    // Check for DCT or DST
    1518 #endif
    1519901    {
    1520902      fastInverseDst(coeff,tmp,shift_1st);    // Inverse DST by FAST Algorithm, coeff input, tmp output
     
    1524906      partialButterflyInverse4(coeff,tmp,shift_1st,iWidth);   
    1525907    }
    1526 #if LOGI_INTRA_NAME_3MPM
    1527908    if (uiMode != REG_DCT && (!uiMode || (uiMode>=2 && uiMode <= 25)))    // Check for DCT or DST
    1528 #else
    1529     if (uiMode != REG_DCT && g_aucDCTDSTMode_Hor[uiMode] )    // Check for DCT or DST
    1530 #endif
    1531909    {
    1532910      fastInverseDst(tmp,block,shift_2nd); // Inverse DST by FAST Algorithm, tmp input, coeff output
     
    1552930    partialButterflyInverse32(tmp,block,shift_2nd,iHeight);
    1553931  }
    1554 #endif
    1555932}
    1556933
    1557934#endif //MATRIX_MULT
    1558935
    1559 #if MULTIBITS_DATA_HIDING
    1560936// To minimize the distortion only. No rate is considered.
    1561937Void TComTrQuant::signBitHidingHDQ( TComDataCU* pcCU, TCoeff* pQCoef, TCoeff* pCoef, UInt const *scan, Int* deltaU, Int width, Int height )
     
    16841060  return;
    16851061}
    1686 #endif
    16871062
    16881063Void TComTrQuant::xQuant( TComDataCU* pcCU,
     
    17151090  else
    17161091  {
    1717 #if MULTIBITS_DATA_HIDING
    17181092    const UInt   log2BlockSize   = g_aucConvertToBit[ iWidth ] + 2;
    17191093
     
    17401114
    17411115    Int deltaU[32*32] ;
    1742 #endif
    17431116
    17441117#if ADAPTIVE_QP_SELECTION
     
    17461119    Int iQpBase = pcCU->getSlice()->getSliceQpBase();
    17471120
    1748 #if H0736_AVC_STYLE_QP_RANGE
    17491121    Int qpScaled;
    17501122    Int qpBDOffset = (eTType == TEXT_LUMA)? pcCU->getSlice()->getSPS()->getQpBDOffsetY() : pcCU->getSlice()->getSPS()->getQpBDOffsetC();
     
    17681140    }
    17691141    cQpBase.setQpParam(qpScaled, false, pcCU->getSlice()->getSliceType());
    1770 #else
    1771     if(eTType != TEXT_LUMA)
    1772     {
    1773       iQpBase = g_aucChromaScale[iQpBase];
    1774     }
    1775     cQpBase.setQpParam(iQpBase, false, pcCU->getSlice()->getSliceType());
    1776 #endif
    17771142#endif
    17781143
     
    18111176#endif
    18121177
    1813 #if MULTIBITS_DATA_HIDING
    18141178    Int qBits8 = iQBits-8;
    1815 #endif
    18161179    for( Int n = 0; n < iWidth*iHeight; n++ )
    18171180    {
     
    18291192      }
    18301193      iLevel = (Int)((tmpLevel + iAdd ) >> iQBits);
    1831 #if MULTIBITS_DATA_HIDING
    18321194      deltaU[uiBlockPos] = (Int)((tmpLevel - (iLevel<<iQBits) )>> qBits8);
    1833 #endif
    18341195#else
    18351196      iLevel = ((Int64)abs(iLevel) * piQuantCoeff[uiBlockPos] + iAdd ) >> iQBits;
    1836 #if MULTIBITS_DATA_HIDING
    18371197      deltaU[uiBlockPos] = (Int)( ((Int64)abs(iLevel) * piQuantCoeff[uiBlockPos] - (iLevel<<iQBits) )>> qBits8 );
    1838 #endif
    18391198#endif
    18401199      uiAcSum += iLevel;
     
    18421201      piQCoef[uiBlockPos] = Clip3( -32768, 32767, iLevel );
    18431202    } // for n
    1844 #if MULTIBITS_DATA_HIDING
    18451203    if( pcCU->getSlice()->getPPS()->getSignHideFlag() )
    18461204    {
     
    18501208      }
    18511209    }
    1852 #endif
    18531210  } //if RDOQ
    18541211  //return;
     
    18881245  iShift = QUANT_IQUANT_SHIFT - QUANT_SHIFT - iTransformShift;
    18891246
    1890 #if DEQUANT_CLIPPING
    18911247  TCoeff clipQCoef;
    18921248  const Int bitRange = min( 15, ( Int )( 12 + uiLog2TrSize + uiBitDepth - m_cQP.m_iPer) );
    18931249  const Int levelLimit = 1 << bitRange;
    1894 #endif
    18951250
    18961251  if(getUseScalingList())
     
    19111266      for( Int n = 0; n < iWidth*iHeight; n++ )
    19121267      {
    1913 #if DEQUANT_CLIPPING
    19141268        clipQCoef = Clip3( -32768, 32767, piQCoef[n] );
    19151269        iCoeffQ = ((clipQCoef * piDequantCoef[n]) + iAdd ) >> (iShift -  m_cQP.m_iPer);
    1916 #else
    1917         iCoeffQ = ((piQCoef[n] * piDequantCoef[n]) + iAdd ) >> (iShift -  m_cQP.m_iPer);
    1918 #endif
    19191270        piCoef[n] = Clip3(-32768,32767,iCoeffQ);
    19201271      }
     
    19241275      for( Int n = 0; n < iWidth*iHeight; n++ )
    19251276      {
    1926 #if DEQUANT_CLIPPING
    19271277        clipQCoef = Clip3( -levelLimit, levelLimit - 1, piQCoef[n] );
    19281278        iCoeffQ = (clipQCoef * piDequantCoef[n]) << (m_cQP.m_iPer - iShift);
    1929 #else
    1930         iCoeffQ = (piQCoef[n] * piDequantCoef[n]) << (m_cQP.m_iPer - iShift);
    1931 #endif
    19321279        piCoef[n] = Clip3(-32768,32767,iCoeffQ);
    19331280      }
     
    19411288    for( Int n = 0; n < iWidth*iHeight; n++ )
    19421289    {
    1943 #if DEQUANT_CLIPPING
    19441290      clipQCoef = Clip3( -32768, 32767, piQCoef[n] );
    19451291      iCoeffQ = ( clipQCoef * scale + iAdd ) >> iShift;
    1946 #else
    1947       iCoeffQ = ( piQCoef[n] * scale + iAdd ) >> iShift;
    1948 #endif
    19491292      piCoef[n] = Clip3(-32768,32767,iCoeffQ);
    19501293    }
     
    21341477  xTr(piBlkResi,psCoeff,uiStride,(UInt)iSize,uiMode);
    21351478#else
    2136 #if UNIFIED_TRANSFORM
    21371479  Int j;
    2138 #else
    2139   Int iSize = iWidth;
    2140   if( iWidth != iHeight)
    2141 #endif
    21421480  {
    21431481    short block[ 64 * 64 ];
     
    21491487      }
    21501488    }
    2151 #if UNIFIED_TRANSFORM
    21521489    xTrMxN( block, coeff, iWidth, iHeight, uiMode );
    2153 #else
    2154     xTrMxN( block, coeff, iWidth, iHeight );
    2155 #endif
    21561490    for ( j = 0; j < iHeight * iWidth; j++ )
    21571491    {   
     
    21601494    return ;
    21611495  }
    2162 #if !UNIFIED_TRANSFORM
    2163   if (iSize==4)
    2164   {   
    2165     short block[4][4];   
    2166     short coeff[4][4];
    2167     for (j=0; j<4; j++)
    2168     {   
    2169       memcpy(block[j],piBlkResi+j*uiStride,4*sizeof(short));     
    2170     }
    2171     xTr4(block,coeff,uiMode);
    2172     for (j=0; j<4; j++)
    2173     {   
    2174       for (k=0; k<4; k++)
    2175       {       
    2176         psCoeff[j*4+k] = coeff[j][k];
    2177       }   
    2178     }   
    2179   }
    2180   else if (iSize==8)
    2181   {
    2182     short block[8][8];
    2183     short coeff[8][8];
    2184 
    2185     for (j=0; j<8; j++)
    2186     {   
    2187       memcpy(block[j],piBlkResi+j*uiStride,8*sizeof(short));
    2188     }
    2189 
    2190     xTr8(block,coeff);       
    2191     for (j=0; j<8; j++)
    2192     {   
    2193       for (k=0; k<8; k++)
    2194       {       
    2195         psCoeff[j*8+k] = coeff[j][k];
    2196       }   
    2197     }
    2198   }
    2199   else if (iSize==16)
    2200   {   
    2201     short block[16][16];
    2202     short coeff[16][16];
    2203 
    2204     for (j=0; j<16; j++)
    2205     {   
    2206       memcpy(block[j],piBlkResi+j*uiStride,16*sizeof(short));
    2207     }
    2208     xTr16(block,coeff);       
    2209     for (j=0; j<16; j++)
    2210     {   
    2211       for (k=0; k<16; k++)
    2212       {       
    2213         psCoeff[j*16+k] = coeff[j][k];
    2214       }   
    2215     }
    2216   }
    2217   else if (iSize==32)
    2218   {   
    2219     short block[32][32];
    2220     short coeff[32][32];
    2221 
    2222     for (j=0; j<32; j++)
    2223     {   
    2224       memcpy(block[j],piBlkResi+j*uiStride,32*sizeof(short));
    2225     }
    2226     xTr32(block,coeff);       
    2227     for (j=0; j<32; j++)
    2228     {   
    2229       for (k=0; k<32; k++)
    2230       {       
    2231         psCoeff[j*32+k] = coeff[j][k];
    2232       }   
    2233     }
    2234   }
    2235 #endif
    22361496#endif 
    22371497}
     
    22551515  xITr(plCoef,pResidual,uiStride,(UInt)iSize,uiMode);
    22561516#else
    2257 #if UNIFIED_TRANSFORM
    22581517  Int j;
    2259 #else
    2260   Int j,k;
    2261   Int iSize = iWidth;
    2262   if( iWidth != iHeight )
    2263 #endif
    22641518  {
    22651519    short block[ 64 * 64 ];
     
    22691523      coeff[j] = (short)plCoef[j];
    22701524    }
    2271 #if UNIFIED_TRANSFORM
    22721525    xITrMxN( coeff, block, iWidth, iHeight, uiMode );
    2273 #else
    2274     xITrMxN( coeff, block, iWidth, iHeight );
    2275 #endif
    22761526    {
    22771527      for ( j = 0; j < iHeight; j++ )
     
    22821532    return ;
    22831533  }
    2284 #if !UNIFIED_TRANSFORM
    2285   if (iSize==4)
    2286   {   
    2287     short block[4][4];
    2288     short coeff[4][4];
    2289 
    2290     for (j=0; j<4; j++)
    2291     {   
    2292       for (k=0; k<4; k++)
    2293       {       
    2294         coeff[j][k] = (short)plCoef[j*4+k];
    2295       }   
    2296     }
    2297     xITr4(coeff,block,uiMode);
    2298     for (j=0; j<4; j++)
    2299     {   
    2300       memcpy(pResidual+j*uiStride,block[j],4*sizeof(short));
    2301     }   
    2302   }
    2303   else if (iSize==8)
    2304   {
    2305     short block[8][8];
    2306     short coeff[8][8];
    2307 
    2308     for (j=0; j<8; j++)
    2309     {   
    2310       for (k=0; k<8; k++)
    2311       {       
    2312         coeff[j][k] = (short)plCoef[j*8+k];
    2313       }   
    2314     }
    2315     xITr8(coeff,block);       
    2316     for (j=0; j<8; j++)
    2317     {   
    2318       memcpy(pResidual+j*uiStride,block[j],8*sizeof(short));
    2319     }
    2320   }
    2321   else if (iSize==16)
    2322   {
    2323     short block[16][16];
    2324     short coeff[16][16];
    2325 
    2326     for (j=0; j<16; j++)
    2327     {   
    2328       for (k=0; k<16; k++)
    2329       {       
    2330         coeff[j][k] = (short)plCoef[j*16+k];
    2331       }   
    2332     }
    2333     xITr16(coeff,block);       
    2334     for (j=0; j<16; j++)
    2335     {   
    2336       memcpy(pResidual+j*uiStride,block[j],16*sizeof(short));
    2337     }
    2338   }
    2339 
    2340   else if (iSize==32)
    2341   {
    2342     short block[32][32];
    2343     short coeff[32][32];
    2344 
    2345     for (j=0; j<32; j++)
    2346     {   
    2347       for (k=0; k<32; k++)
    2348       {       
    2349         coeff[j][k] = (short)plCoef[j*32+k];
    2350       }   
    2351     }
    2352     xITr32(coeff,block);       
    2353     for (j=0; j<32; j++)
    2354     {   
    2355       memcpy(pResidual+j*uiStride,block[j],32*sizeof(short));
    2356     }   
    2357   }
    2358 #endif
    23591534#endif 
    23601535}
     
    24421617  ::memset( pdCostCoeff, 0, sizeof(Double) *  uiMaxNumCoeff );
    24431618  ::memset( pdCostSig,   0, sizeof(Double) *  uiMaxNumCoeff );
    2444 #if MULTIBITS_DATA_HIDING
    24451619  Int rateIncUp   [ 32 * 32 ];
    24461620  Int rateIncDown [ 32 * 32 ];
     
    24511625  ::memset( sigRateDelta, 0, sizeof(Int) *  uiMaxNumCoeff );
    24521626  ::memset( deltaU,       0, sizeof(Int) *  uiMaxNumCoeff );
    2453 #endif
    24541627
    24551628  const UInt * scanCG;
     
    24571630  {
    24581631    scanCG = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlkSize > 3 ? uiLog2BlkSize-2-1 : 0  ];
    2459 #if MULTILEVEL_SIGMAP_EXT
    24601632    if( uiLog2BlkSize == 3 )
    24611633    {
     
    24661638      scanCG = g_sigLastScanCG32x32;
    24671639    }
    2468 #endif
    24691640  }
    24701641  else
     
    24861657  dTemp                       = dErrScale;
    24871658
    2488 #if RESTRICT_GR1GR2FLAG_NUMBER
    24891659  UInt    c1Idx     = 0;
    24901660  UInt    c2Idx     = 0;
    24911661  Int     baseLevel;
    2492 #endif
    24931662
    24941663  const UInt * scan;
     
    25021671  }
    25031672
    2504 #if !MULTILEVEL_SIGMAP_EXT
    2505   if (blockType < 4)
    2506   {
    2507   for( Int iScanPos = (Int) uiMaxNumCoeff-1; iScanPos >= 0; iScanPos-- )
    2508   {
    2509     //===== quantization =====
    2510     UInt    uiBlkPos          = scan[iScanPos];
    2511     // set coeff
    2512     uiQ  = piQCoef[uiBlkPos];
    2513     dTemp = pdErrScale[uiBlkPos];
    2514     Int lLevelDouble          = plSrcCoeff[ uiBlkPos ];
    2515     lLevelDouble              = (Int)min<Int64>(((Int64)abs(lLevelDouble) * uiQ), MAX_INT-(1 << (iQBits - 1)));
    2516 #if ADAPTIVE_QP_SELECTION
    2517     if( m_bUseAdaptQpSelect )
    2518     {
    2519       piArlDstCoeff[uiBlkPos]   = (Int)(( lLevelDouble + iAddC) >> iQBitsC );
    2520     }
    2521 #endif
    2522     UInt uiMaxAbsLevel        = (lLevelDouble + (1 << (iQBits - 1))) >> iQBits;
    2523     uiMaxAbsLevel=plSrcCoeff[ uiBlkPos ]>=0 ? min<UInt>(uiMaxAbsLevel,32767): min<UInt>(uiMaxAbsLevel,32768);
    2524     Double dErr               = Double( lLevelDouble );
    2525     pdCostCoeff0[ iScanPos ]  = dErr * dErr * dTemp;
    2526     d64BlockUncodedCost      += pdCostCoeff0[ iScanPos ];
    2527     piDstCoeff[ uiBlkPos ]    = uiMaxAbsLevel;
    2528 
    2529     if ( uiMaxAbsLevel > 0 && iLastScanPos < 0 )
    2530     {
    2531       iLastScanPos            = iScanPos;
    2532 #if LEVEL_CTX_LUMA_RED
    2533       uiCtxSet                = (iScanPos < SCAN_SET_SIZE || eTType!=TEXT_LUMA) ? 0 : 2;
    2534 #else
    2535       uiCtxSet                = iScanPos < SCAN_SET_SIZE ? 0 : 3;
    2536       uiCtxSet                = (iScanPos < SCAN_SET_SIZE || eTType!=TEXT_LUMA) ? 0 : 3;
    2537 #endif
    2538     }   
    2539 
    2540     if ( iLastScanPos >= 0 )
    2541     {
    2542       //===== coefficient level estimation =====
    2543       UInt  uiLevel;
    2544       UInt  uiOneCtx         = 4 * uiCtxSet + c1;
    2545 #if RESTRICT_GR1GR2FLAG_NUMBER
    2546       UInt  uiAbsCtx         = uiCtxSet + c2;
    2547 #else
    2548       UInt  uiAbsCtx         = 3 * uiCtxSet + c2;
    2549 #endif
    2550 
    2551       if( iScanPos == iLastScanPos )
    2552       {
    2553 #if RESTRICT_GR1GR2FLAG_NUMBER
    2554         uiLevel              = xGetCodedLevel( pdCostCoeff[ iScanPos ], pdCostCoeff0[ iScanPos ], pdCostSig[ iScanPos ], lLevelDouble, uiMaxAbsLevel, 0, uiOneCtx, uiAbsCtx, uiGoRiceParam, c1Idx, c2Idx, iQBits, dTemp, 1 );
    2555 #else
    2556         uiLevel              = xGetCodedLevel( pdCostCoeff[ iScanPos ], pdCostCoeff0[ iScanPos ], pdCostSig[ iScanPos ], lLevelDouble, uiMaxAbsLevel, 0, uiOneCtx, uiAbsCtx, uiGoRiceParam, iQBits, dTemp, 1 );
    2557 #endif
    2558       }
    2559       else
    2560       {
    2561         UInt   uiPosY        = uiBlkPos >> uiLog2BlkSize;
    2562         UInt   uiPosX        = uiBlkPos - ( uiPosY << uiLog2BlkSize );
    2563         UShort uiCtxSig      = getSigCtxInc( piDstCoeff, uiPosX, uiPosY, blockType, uiWidth, uiHeight, eTType );
    2564 #if RESTRICT_GR1GR2FLAG_NUMBER
    2565         uiLevel              = xGetCodedLevel( pdCostCoeff[ iScanPos ], pdCostCoeff0[ iScanPos ], pdCostSig[ iScanPos ], lLevelDouble, uiMaxAbsLevel, uiCtxSig, uiOneCtx, uiAbsCtx, uiGoRiceParam, c1Idx, c2Idx, iQBits, dTemp, 0 );
    2566 #else
    2567         uiLevel              = xGetCodedLevel( pdCostCoeff[ iScanPos ], pdCostCoeff0[ iScanPos ], pdCostSig[ iScanPos ], lLevelDouble, uiMaxAbsLevel, uiCtxSig, uiOneCtx, uiAbsCtx, uiGoRiceParam, iQBits, dTemp, 0 );
    2568 #endif
    2569 #if MULTIBITS_DATA_HIDING
    2570         sigRateDelta[ uiBlkPos ] = m_pcEstBitsSbac->significantBits[ uiCtxSig ][ 1 ] - m_pcEstBitsSbac->significantBits[ uiCtxSig ][ 0 ];
    2571 #endif
    2572       }
    2573 #if MULTIBITS_DATA_HIDING
    2574       deltaU[ uiBlkPos ]        = (lLevelDouble - ((Int)uiLevel << iQBits)) >> (iQBits-8);
    2575       if( uiLevel > 0 )
    2576       {
    2577 #if RESTRICT_GR1GR2FLAG_NUMBER   
    2578         Int rateNow = xGetICRate( uiLevel, uiOneCtx, uiAbsCtx, uiGoRiceParam, c1Idx, c2Idx );
    2579         rateIncUp   [ uiBlkPos ] = xGetICRate( uiLevel+1, uiOneCtx, uiAbsCtx, uiGoRiceParam, c1Idx, c2Idx ) - rateNow;
    2580         rateIncDown [ uiBlkPos ] = xGetICRate( uiLevel-1, uiOneCtx, uiAbsCtx, uiGoRiceParam, c1Idx, c2Idx ) - rateNow;
    2581 #else 
    2582         Int rateNow = xGetICRate( uiLevel, uiOneCtx, uiAbsCtx, uiGoRiceParam );
    2583         rateIncUp   [ uiBlkPos ] = xGetICRate( uiLevel+1, uiOneCtx, uiAbsCtx, uiGoRiceParam ) - rateNow;
    2584         rateIncDown [ uiBlkPos ] = xGetICRate( uiLevel-1, uiOneCtx, uiAbsCtx, uiGoRiceParam ) - rateNow;
    2585 #endif
    2586       }
    2587       else // uiLevel == 0
    2588       {
    2589         rateIncUp   [ uiBlkPos ] = m_pcEstBitsSbac->m_greaterOneBits[ uiOneCtx ][ 0 ];
    2590       }
    2591 #endif
    2592       piDstCoeff[ uiBlkPos ] = uiLevel;
    2593       d64BaseCost           += pdCostCoeff [ iScanPos ];
    2594 
    2595 #if RESTRICT_GR1GR2FLAG_NUMBER
    2596       baseLevel = (c1Idx < C1FLAG_NUMBER) ? (2 + (c2Idx < C2FLAG_NUMBER)) : 1;
    2597       if( uiLevel >= baseLevel )
    2598       {
    2599 #if EIGHT_BITS_RICE_CODE
    2600         uiGoRiceParam = g_aauiGoRiceUpdate[ uiGoRiceParam ][ min<UInt>( uiLevel - baseLevel, 23 ) ];
    2601 #else
    2602         uiGoRiceParam = g_aauiGoRiceUpdate[ uiGoRiceParam ][ min<UInt>( uiLevel - baseLevel, 15 ) ];
    2603 #endif
    2604       }
    2605       if ( uiLevel >= 1)
    2606       {
    2607         c1Idx ++;
    2608       }
    2609 #endif
    2610 
    2611       //===== update bin model =====
    2612       if( uiLevel > 1 )
    2613       {
    2614         c1 = 0;
    2615         c2 += (c2 < 2);
    2616         uiNumOne++;
    2617 #if RESTRICT_GR1GR2FLAG_NUMBER
    2618         c2Idx ++;
    2619 #else
    2620         if( uiLevel > 2 )
    2621         {
    2622 #if EIGHT_BITS_RICE_CODE
    2623           uiGoRiceParam = g_aauiGoRiceUpdate[ uiGoRiceParam ][ min<UInt>( uiLevel - 3, 23 ) ];
    2624 #else
    2625           uiGoRiceParam = g_aauiGoRiceUpdate[ uiGoRiceParam ][ min<UInt>( uiLevel - 3, 15 ) ];
    2626 #endif
    2627         }
    2628 #endif
    2629       }
    2630       else if( (c1 < 3) && (c1 > 0) && uiLevel)
    2631       {
    2632         c1++;
    2633       }
    2634 
    2635       //===== context set update =====
    2636       if( ( iScanPos % SCAN_SET_SIZE == 0 ) && ( iScanPos > 0 ) )
    2637       {
    2638         c1                = 1;
    2639         c2                = 0;
    2640         uiGoRiceParam     = 0;
    2641 
    2642 #if RESTRICT_GR1GR2FLAG_NUMBER
    2643         c1Idx   = 0;
    2644         c2Idx   = 0;
    2645 #endif
    2646 #if LEVEL_CTX_LUMA_RED
    2647         uiCtxSet          = (iScanPos == SCAN_SET_SIZE || eTType!=TEXT_LUMA) ? 0 : 2;
    2648 #else
    2649         uiCtxSet          = (iScanPos == SCAN_SET_SIZE || eTType!=TEXT_LUMA) ? 0 : 3;
    2650 #endif
    2651         if( uiNumOne > 0 )
    2652         {
    2653           uiCtxSet++;
    2654 #if !LEVEL_CTX_LUMA_RED
    2655           if(uiNumOne > 3 && eTType==TEXT_LUMA)
    2656           {
    2657             uiCtxSet++;
    2658           }
    2659 #endif
    2660         }
    2661         uiNumOne    >>= 1;
    2662       }
    2663     }
    2664     else
    2665     {
    2666       d64BaseCost    += pdCostCoeff0[ iScanPos ];
    2667     }
    2668   }
    2669   }
    2670   else //(uiLog2BlkSize > 3), for 16x16 and 32x32 TU
    2671   {     
    2672 #endif
    26731673    ::memset( pdCostCoeffGroupSig,   0, sizeof(Double) * MLS_GRP_NUM );
    26741674    ::memset( uiSigCoeffGroupFlag,   0, sizeof(UInt) * MLS_GRP_NUM );
     
    26831683      UInt uiCGPosY   = uiCGBlkPos / uiNumBlkSide;
    26841684      UInt uiCGPosX   = uiCGBlkPos - (uiCGPosY * uiNumBlkSide);
    2685 #if MULTILEVEL_SIGMAP_EXT
    26861685      if( uiWidth == 8 && uiHeight == 8 && (uiScanIdx == SCAN_HOR || uiScanIdx == SCAN_VER) )
    26871686      {
     
    26891688        uiCGPosX = (uiScanIdx == SCAN_VER ? uiCGBlkPos : 0);
    26901689      }
    2691 #endif
    26921690      ::memset( &rdStats, 0, sizeof (coeffGroupRDStats));
    26931691       
     
    27181716        {
    27191717          iLastScanPos            = iScanPos;
    2720 #if LEVEL_CTX_LUMA_RED
    27211718          uiCtxSet                = (iScanPos < SCAN_SET_SIZE || eTType!=TEXT_LUMA) ? 0 : 2;
    2722 #else
    2723           uiCtxSet                = (iScanPos < SCAN_SET_SIZE || eTType!=TEXT_LUMA) ? 0 : 3;
    2724 #endif
    27251719          iCGLastScanPos          = iCGScanPos;
    27261720        }
     
    27311725          UInt  uiLevel;
    27321726          UInt  uiOneCtx         = 4 * uiCtxSet + c1;
    2733 #if RESTRICT_GR1GR2FLAG_NUMBER
    27341727          UInt  uiAbsCtx         = uiCtxSet + c2;
    2735 #else
    2736           UInt  uiAbsCtx         = 3 * uiCtxSet + c2;
    2737 #endif
    27381728
    27391729          if( iScanPos == iLastScanPos )
    27401730          {
    2741 #if RESTRICT_GR1GR2FLAG_NUMBER 
    27421731            uiLevel              = xGetCodedLevel( pdCostCoeff[ iScanPos ], pdCostCoeff0[ iScanPos ], pdCostSig[ iScanPos ],
    27431732                                                   lLevelDouble, uiMaxAbsLevel, 0, uiOneCtx, uiAbsCtx, uiGoRiceParam,
    27441733                                                   c1Idx, c2Idx, iQBits, dTemp, 1 );
    2745 #else
    2746             uiLevel              = xGetCodedLevel( pdCostCoeff[ iScanPos ], pdCostCoeff0[ iScanPos ], pdCostSig[ iScanPos ],
    2747                                                    lLevelDouble, uiMaxAbsLevel, 0, uiOneCtx, uiAbsCtx, uiGoRiceParam,
    2748                                                    iQBits, dTemp, 1 );
    2749 #endif
    27501734          }
    27511735          else
     
    27541738            UInt   uiPosX        = uiBlkPos - ( uiPosY << uiLog2BlkSize );
    27551739            UShort uiCtxSig      = getSigCtxInc( piDstCoeff, uiPosX, uiPosY, blockType, uiWidth, uiHeight, eTType );
    2756 #if RESTRICT_GR1GR2FLAG_NUMBER
    27571740            uiLevel              = xGetCodedLevel( pdCostCoeff[ iScanPos ], pdCostCoeff0[ iScanPos ], pdCostSig[ iScanPos ],
    27581741                                                   lLevelDouble, uiMaxAbsLevel, uiCtxSig, uiOneCtx, uiAbsCtx, uiGoRiceParam,
    27591742                                                   c1Idx, c2Idx, iQBits, dTemp, 0 );
    2760 #else
    2761             uiLevel              = xGetCodedLevel( pdCostCoeff[ iScanPos ], pdCostCoeff0[ iScanPos ], pdCostSig[ iScanPos ],
    2762                                                    lLevelDouble, uiMaxAbsLevel, uiCtxSig, uiOneCtx, uiAbsCtx, uiGoRiceParam,
    2763                                                    iQBits, dTemp, 0 );
    2764 #endif
    2765 #if MULTIBITS_DATA_HIDING
    27661743            sigRateDelta[ uiBlkPos ] = m_pcEstBitsSbac->significantBits[ uiCtxSig ][ 1 ] - m_pcEstBitsSbac->significantBits[ uiCtxSig ][ 0 ];
    2767 #endif
    27681744          }
    2769 #if MULTIBITS_DATA_HIDING
    27701745          deltaU[ uiBlkPos ]        = (lLevelDouble - ((Int)uiLevel << iQBits)) >> (iQBits-8);
    27711746          if( uiLevel > 0 )
    27721747          {
    2773 #if RESTRICT_GR1GR2FLAG_NUMBER   
    27741748            Int rateNow = xGetICRate( uiLevel, uiOneCtx, uiAbsCtx, uiGoRiceParam, c1Idx, c2Idx );
    27751749            rateIncUp   [ uiBlkPos ] = xGetICRate( uiLevel+1, uiOneCtx, uiAbsCtx, uiGoRiceParam, c1Idx, c2Idx ) - rateNow;
    27761750            rateIncDown [ uiBlkPos ] = xGetICRate( uiLevel-1, uiOneCtx, uiAbsCtx, uiGoRiceParam, c1Idx, c2Idx ) - rateNow;
    2777 #else
    2778             Int rateNow = xGetICRate( uiLevel, uiOneCtx, uiAbsCtx, uiGoRiceParam );
    2779             rateIncUp   [ uiBlkPos ] = xGetICRate( uiLevel+1, uiOneCtx, uiAbsCtx, uiGoRiceParam ) - rateNow;
    2780             rateIncDown [ uiBlkPos ] = xGetICRate( uiLevel-1, uiOneCtx, uiAbsCtx, uiGoRiceParam ) - rateNow;
    2781 #endif
    27821751          }
    27831752          else // uiLevel == 0
     
    27851754            rateIncUp   [ uiBlkPos ] = m_pcEstBitsSbac->m_greaterOneBits[ uiOneCtx ][ 0 ];
    27861755          }
    2787 #endif
    27881756          piDstCoeff[ uiBlkPos ] = uiLevel;
    27891757          d64BaseCost           += pdCostCoeff [ iScanPos ];
    27901758
    27911759
    2792 #if RESTRICT_GR1GR2FLAG_NUMBER
    27931760          baseLevel = (c1Idx < C1FLAG_NUMBER) ? (2 + (c2Idx < C2FLAG_NUMBER)) : 1;
    27941761          if( uiLevel >= baseLevel )
    27951762          {
    2796 #if EIGHT_BITS_RICE_CODE
    27971763            uiGoRiceParam = g_aauiGoRiceUpdate[ uiGoRiceParam ][ min<UInt>( uiLevel - baseLevel , 23 ) ];
    2798 #else
    2799             uiGoRiceParam = g_aauiGoRiceUpdate[ uiGoRiceParam ][ min<UInt>( uiLevel - baseLevel, 15 ) ];
    2800 #endif
    28011764          }
    28021765          if ( uiLevel >= 1)
     
    28041767            c1Idx ++;
    28051768          }
    2806 #endif
    28071769
    28081770          //===== update bin model =====
     
    28121774            c2 += (c2 < 2);
    28131775            uiNumOne++;
    2814 #if RESTRICT_GR1GR2FLAG_NUMBER
    28151776            c2Idx ++;
    2816 #else
    2817             if( uiLevel > 2 )
    2818             {
    2819 #if EIGHT_BITS_RICE_CODE
    2820               uiGoRiceParam = g_aauiGoRiceUpdate[ uiGoRiceParam ][ min<UInt>( uiLevel - 3, 23 ) ];
    2821 #else
    2822               uiGoRiceParam = g_aauiGoRiceUpdate[ uiGoRiceParam ][ min<UInt>( uiLevel - 3, 15 ) ];
    2823 #endif
    2824             }
    2825 #endif
    28261777          }
    28271778          else if( (c1 < 3) && (c1 > 0) && uiLevel)
     
    28371788            uiGoRiceParam     = 0;
    28381789
    2839 #if RESTRICT_GR1GR2FLAG_NUMBER
    28401790            c1Idx   = 0;
    28411791            c2Idx   = 0;
    2842 #endif
    2843 #if LEVEL_CTX_LUMA_RED
    28441792            uiCtxSet          = (iScanPos == SCAN_SET_SIZE || eTType!=TEXT_LUMA) ? 0 : 2;
    2845 #else
    2846             uiCtxSet          = (iScanPos == SCAN_SET_SIZE || eTType!=TEXT_LUMA) ? 0 : 3;
    2847 #endif
    28481793            if( uiNumOne > 0 )
    28491794            {
    28501795              uiCtxSet++;
    2851 #if !LEVEL_CTX_LUMA_RED
    2852               if( uiNumOne > 3 && eTType==TEXT_LUMA)
    2853               {
    2854                 uiCtxSet++;
    2855               }
    2856 #endif
    28571796            }
    28581797            uiNumOne    >>= 1;
     
    28821821      if (iCGLastScanPos >= 0)
    28831822      {
    2884 #if REMOVE_INFER_SIGGRP
    28851823        if( iCGScanPos )
    2886 #else
    2887 #if MULTILEVEL_SIGMAP_EXT
    2888         if ( !bothCGNeighboursOne( uiSigCoeffGroupFlag, uiCGPosX, uiCGPosY, uiScanIdx, uiWidth, uiHeight ) && (iCGScanPos != 0) )
    2889 #else
    2890         if ( !bothCGNeighboursOne( uiSigCoeffGroupFlag, uiCGPosX, uiCGPosY, uiWidth, uiHeight ) && (iCGScanPos != 0) )
    2891 #endif
    2892 #endif
    28931824        {
    28941825          if (uiSigCoeffGroupFlag[ uiCGBlkPos ] == 0)
    28951826          {
    2896 #if MULTILEVEL_SIGMAP_EXT
    28971827            UInt  uiCtxSig = getSigCoeffGroupCtxInc( uiSigCoeffGroupFlag, uiCGPosX, uiCGPosY, uiScanIdx, uiWidth, uiHeight);
    2898 #else
    2899             UInt  uiCtxSig = getSigCoeffGroupCtxInc( uiSigCoeffGroupFlag, uiCGPosX, uiCGPosY, uiWidth, uiHeight);
    2900 #endif
    29011828            d64BaseCost += xGetRateSigCoeffGroup(0, uiCtxSig) - rdStats.d64SigCost;; 
    29021829            pdCostCoeffGroupSig[ iCGScanPos ] = xGetRateSigCoeffGroup(0, uiCtxSig); 
     
    29151842
    29161843              // add SigCoeffGroupFlag cost to total cost
    2917 #if MULTILEVEL_SIGMAP_EXT
    29181844              UInt  uiCtxSig = getSigCoeffGroupCtxInc( uiSigCoeffGroupFlag, uiCGPosX, uiCGPosY, uiScanIdx, uiWidth, uiHeight);
    2919 #else
    2920               UInt  uiCtxSig = getSigCoeffGroupCtxInc( uiSigCoeffGroupFlag, uiCGPosX, uiCGPosY, uiWidth, uiHeight);
    2921 #endif
    29221845              if (iCGScanPos < iCGLastScanPos)
    29231846              {
     
    29581881          } // end if if (uiSigCoeffGroupFlag[ uiCGBlkPos ] == 0)
    29591882        }
    2960 #if REMOVE_INFER_SIGGRP
    29611883        else
    29621884        {
    29631885          uiSigCoeffGroupFlag[ uiCGBlkPos ] = 1;
    29641886        }
    2965 #else
    2966         else // if ( !bothCGNeighboursOne( uiSigCoeffGroupFlag, uiCGPosX, uiCGPosY ) && (uiCGScanPos != 0) && (uiSigCoeffGroupFlag[ uiCGBlkPos ] != 0) )
    2967         {
    2968           uiSigCoeffGroupFlag[ uiCGBlkPos ] = 1;
    2969         } // end if ( !bothCGNeighboursOne( uiSigCoeffGroupFlag, uiCGPosX, uiCGPosY ) && (uiCGScanPos != 0) && (uiSigCoeffGroupFlag[ uiCGBlkPos ] != 0) )
    2970 #endif
    29711887      }
    29721888    } //end for (iCGScanPos)
    2973 #if !MULTILEVEL_SIGMAP_EXT
    2974   }
    2975 #endif
    29761889
    29771890  //===== estimate last position =====
     
    29981911  }
    29991912
    3000 #if !MULTILEVEL_SIGMAP_EXT
    3001   if (blockType < 4)
    3002   {
    3003   for( Int iScanPos = iLastScanPos; iScanPos >= 0; iScanPos-- )
    3004   {
    3005     UInt   uiBlkPos     = scan[iScanPos];
    3006     if( piDstCoeff[ uiBlkPos ] )
    3007     {
    3008       UInt   uiPosY       = uiBlkPos >> uiLog2BlkSize;
    3009       UInt   uiPosX       = uiBlkPos - ( uiPosY << uiLog2BlkSize );
    3010       Double d64CostLast= uiScanIdx == SCAN_VER ? xGetRateLast( uiPosY, uiPosX, uiWidth ) : xGetRateLast( uiPosX, uiPosY, uiWidth );
    3011       Double totalCost = d64BaseCost + d64CostLast - pdCostSig[ iScanPos ];
    3012       if( totalCost < d64BestCost )
    3013       {
    3014         iBestLastIdxP1  = iScanPos + 1;
    3015         d64BestCost     = totalCost;
    3016       }
    3017       if( piDstCoeff[ uiBlkPos ] > 1 )
    3018       {
    3019         break;
    3020       }
    3021       d64BaseCost      -= pdCostCoeff[ iScanPos ];
    3022       d64BaseCost      += pdCostCoeff0[ iScanPos ];
    3023     }
    3024     else
    3025     {
    3026       d64BaseCost      -= pdCostSig[ iScanPos ];
    3027     }
    3028   }
    3029   }
    3030   else //if (uiLog2BlkSize < 4)
    3031   {
    3032 #endif
    30331913    Bool bFoundLast = false;
    30341914    for (Int iCGScanPos = iCGLastScanPos; iCGScanPos >= 0; iCGScanPos--)
     
    30411921        for (Int iScanPosinCG = uiCGSize-1; iScanPosinCG >= 0; iScanPosinCG--)
    30421922        {
    3043 #if MULTILEVEL_SIGMAP_EXT
    30441923          iScanPos = iCGScanPos*uiCGSize + iScanPosinCG;
    3045 #else
    3046           Int iScanPos = iCGScanPos*uiCGSize + iScanPosinCG;
    3047 #endif
    30481924          if (iScanPos > iLastScanPos) continue;
    30491925          UInt   uiBlkPos     = scan[iScanPos];
     
    30811957      } // end if (uiSigCoeffGroupFlag[ uiCGBlkPos ])
    30821958    } // end for
    3083 #if !MULTILEVEL_SIGMAP_EXT
    3084   } //if (uiLog2BlkSize < 4)
    3085 #endif
    30861959
    30871960  for ( Int scanPos = 0; scanPos < iBestLastIdxP1; scanPos++ )
     
    30991972  }
    31001973
    3101 #if MULTIBITS_DATA_HIDING
    31021974  if( pcCU->getSlice()->getPPS()->getSignHideFlag() && uiAbsSum>=2)
    31031975  {
     
    32262098    }
    32272099  }
    3228 #endif
    32292100}
    32302101
     
    33112182  const TCoeff *pData = pcCoeff + posX + posY * width;
    33122183 
    3313 #if !SIGMAP_CTX_SUBBLOCK
    3314   Int thred = std::max(height, width) >> 2;
    3315 #endif
    33162184 
    33172185  Int cnt = 0;
     
    33412209
    33422210  cnt = ( cnt + 1 ) >> 1;
    3343 #if SIGMAP_CTX_SUBBLOCK
    33442211  return (( textureType == TEXT_LUMA && ((posX>>2) + (posY>>2)) > 0 ) ? 4 : 1) + offset + cnt;
    3345 #else
    3346   return (( textureType == TEXT_LUMA && posX + posY >= thred ) ? 4 : 1) + offset + cnt;
    3347 #endif
    33482212}
    33492213
     
    33732237                                            UShort                          ui16CtxNumAbs,
    33742238                                            UShort                          ui16AbsGoRice,
    3375 #if RESTRICT_GR1GR2FLAG_NUMBER
    33762239                                            UInt                            c1Idx,
    33772240                                            UInt                            c2Idx,
    3378 #endif
    33792241                                            Int                             iQBits,
    33802242                                            Double                          dTemp,
     
    34072269  {
    34082270    Double dErr         = Double( lLevelDouble  - ( uiAbsLevel << iQBits ) );
    3409 #if RESTRICT_GR1GR2FLAG_NUMBER
    34102271    Double dCurrCost    = dErr * dErr * dTemp + xGetICRateCost( uiAbsLevel, ui16CtxNumOne, ui16CtxNumAbs, ui16AbsGoRice, c1Idx, c2Idx );
    3411 #else
    3412     Double dCurrCost    = dErr * dErr * dTemp + xGetICRateCost( uiAbsLevel, ui16CtxNumOne, ui16CtxNumAbs, ui16AbsGoRice );
    3413 #endif
    34142272    dCurrCost          += dCurrCostSig;
    34152273
     
    34362294                                               UShort                          ui16CtxNumAbs,
    34372295                                               UShort                          ui16AbsGoRice
    3438 #if RESTRICT_GR1GR2FLAG_NUMBER
    34392296                                            ,  UInt                            c1Idx,
    34402297                                               UInt                            c2Idx
    3441 #endif
    34422298                                               ) const
    34432299{
    34442300  Double iRate = xGetIEPRate();
    3445 #if RESTRICT_GR1GR2FLAG_NUMBER
    34462301  UInt baseLevel  =  (c1Idx < C1FLAG_NUMBER)? (2 + (c2Idx < C2FLAG_NUMBER)) : 1;
    34472302
     
    34762331  }
    34772332  else
    3478 #endif
    34792333  if( uiAbsLevel == 1 )
    34802334  {
     
    34882342  else
    34892343  {
    3490 #if RESTRICT_GR1GR2FLAG_NUMBER
    34912344    assert (0);
    3492 #else
    3493     UInt uiSymbol     = uiAbsLevel - 3;
     2345  }
     2346  return xGetICost( iRate );
     2347}
     2348
     2349__inline Int TComTrQuant::xGetICRate  ( UInt                            uiAbsLevel,
     2350                                       UShort                          ui16CtxNumOne,
     2351                                       UShort                          ui16CtxNumAbs,
     2352                                       UShort                          ui16AbsGoRice
     2353                                     , UInt                            c1Idx,
     2354                                       UInt                            c2Idx
     2355                                       ) const
     2356{
     2357  Int iRate = 0;
     2358  UInt baseLevel  =  (c1Idx < C1FLAG_NUMBER)? (2 + (c2Idx < C2FLAG_NUMBER)) : 1;
     2359
     2360  if ( uiAbsLevel >= baseLevel )
     2361  {
     2362    UInt uiSymbol     = uiAbsLevel - baseLevel;
    34942363    UInt uiMaxVlc     = g_auiGoRiceRange[ ui16AbsGoRice ];
    34952364    Bool bExpGolomb   = ( uiSymbol > uiMaxVlc );
     
    35072376
    35082377    iRate += ui16NumBins << 15;
    3509     iRate += m_pcEstBitsSbac->m_greaterOneBits[ ui16CtxNumOne ][ 1 ];
    3510     iRate += m_pcEstBitsSbac->m_levelAbsBits[ ui16CtxNumAbs ][ 1 ];
    3511 #endif
    3512   }
    3513   return xGetICost( iRate );
    3514 }
    3515 
    3516 #if MULTIBITS_DATA_HIDING
    3517 __inline Int TComTrQuant::xGetICRate  ( UInt                            uiAbsLevel,
    3518                                        UShort                          ui16CtxNumOne,
    3519                                        UShort                          ui16CtxNumAbs,
    3520                                        UShort                          ui16AbsGoRice
    3521 #if RESTRICT_GR1GR2FLAG_NUMBER
    3522                                      , UInt                            c1Idx,
    3523                                        UInt                            c2Idx
    3524 #endif
    3525                                        ) const
    3526 {
    3527   Int iRate = 0;
    3528 #if RESTRICT_GR1GR2FLAG_NUMBER
    3529   UInt baseLevel  =  (c1Idx < C1FLAG_NUMBER)? (2 + (c2Idx < C2FLAG_NUMBER)) : 1;
    3530 
    3531   if ( uiAbsLevel >= baseLevel )
    3532   {
    3533     UInt uiSymbol     = uiAbsLevel - baseLevel;
    3534     UInt uiMaxVlc     = g_auiGoRiceRange[ ui16AbsGoRice ];
    3535     Bool bExpGolomb   = ( uiSymbol > uiMaxVlc );
    3536 
    3537     if( bExpGolomb )
    3538     {
    3539       uiAbsLevel  = uiSymbol - uiMaxVlc;
    3540       int iEGS    = 1;  for( UInt uiMax = 2; uiAbsLevel >= uiMax; uiMax <<= 1, iEGS += 2 );
    3541       iRate      += iEGS << 15;
    3542       uiSymbol    = min<UInt>( uiSymbol, ( uiMaxVlc + 1 ) );
    3543     }
    3544 
    3545     UShort ui16PrefLen = UShort( uiSymbol >> ui16AbsGoRice ) + 1;
    3546     UShort ui16NumBins = min<UInt>( ui16PrefLen, g_auiGoRicePrefixLen[ ui16AbsGoRice ] ) + ui16AbsGoRice;
    3547 
    3548     iRate += ui16NumBins << 15;
    35492378
    35502379    if (c1Idx < C1FLAG_NUMBER)
     
    35592388  }
    35602389  else
    3561 #endif
    35622390  if( uiAbsLevel == 0 )
    35632391  {
     
    35752403  else
    35762404  {
    3577 #if RESTRICT_GR1GR2FLAG_NUMBER
    35782405    assert(0);
    3579 #else
    3580     UInt uiSymbol     = uiAbsLevel - 3;
    3581     UInt uiMaxVlc     = g_auiGoRiceRange[ ui16AbsGoRice ];
    3582     Bool bExpGolomb   = ( uiSymbol > uiMaxVlc );
    3583 
    3584     if( bExpGolomb )
    3585     {
    3586       uiAbsLevel  = uiSymbol - uiMaxVlc;
    3587       int iEGS    = 1;  for( UInt uiMax = 2; uiAbsLevel >= uiMax; uiMax <<= 1, iEGS += 2 );
    3588       iRate      += iEGS << 15;
    3589       uiSymbol    = min<UInt>( uiSymbol, ( uiMaxVlc + 1 ) );
    3590     }
    3591 
    3592     UShort ui16PrefLen = UShort( uiSymbol >> ui16AbsGoRice ) + 1;
    3593     UShort ui16NumBins = min<UInt>( ui16PrefLen, g_auiGoRicePrefixLen[ ui16AbsGoRice ] ) + ui16AbsGoRice;
    3594 
    3595     iRate += ui16NumBins << 15;
    3596     iRate += m_pcEstBitsSbac->m_greaterOneBits[ ui16CtxNumOne ][ 1 ];
    3597     iRate += m_pcEstBitsSbac->m_levelAbsBits[ ui16CtxNumAbs ][ 1 ];
    3598 #endif
    35992406  }
    36002407  return iRate;
    36012408}
    3602 #endif
    36032409
    36042410__inline Double TComTrQuant::xGetRateSigCoeffGroup  ( UShort                    uiSignificanceCoeffGroup,
     
    36742480                                           const UInt                      uiCGPosX,
    36752481                                           const UInt                      uiCGPosY,
    3676 #if MULTILEVEL_SIGMAP_EXT
    36772482                                           const UInt                      scanIdx,
    3678 #endif
    36792483                                           Int width, Int height)
    36802484{
     
    36842488  width >>= 2;
    36852489  height >>= 2;
    3686 #if MULTILEVEL_SIGMAP_EXT
    36872490  if( width == 2 && height == 2 ) // 8x8
    36882491  {
     
    36982501    }
    36992502  }
    3700 #endif
    37012503  if( uiCGPosX < width - 1 )
    37022504  {
     
    37072509    uiLower = (uiSigCoeffGroupFlag[ (uiCGPosY  + 1 ) * width + uiCGPosX ] != 0);
    37082510  }
    3709 #if REMOVE_INFER_SIGGRP
    37102511  return (uiRight || uiLower);
    3711 #else
    3712   return uiRight + uiLower;
    3713 #endif
    3714 
    3715 }
    3716 #if !REMOVE_INFER_SIGGRP
    3717 // return 1 if both right neighbour and lower neighour are 1's
    3718 Bool TComTrQuant::bothCGNeighboursOne ( const UInt*                   uiSigCoeffGroupFlag,
    3719                                        const UInt                      uiCGPosX,
    3720                                        const UInt                      uiCGPosY,
    3721 #if MULTILEVEL_SIGMAP_EXT
    3722                                        const UInt                      scanIdx,
    3723 #endif
    3724                                        Int width, Int height)
    3725 {
    3726   UInt uiRight = 0;
    3727   UInt uiLower = 0;
    3728 
    3729   width >>= 2;
    3730   height >>= 2;
    3731 #if MULTILEVEL_SIGMAP_EXT
    3732   if( width == 2 && height == 2 ) // 8x8
    3733   {
    3734     if( scanIdx == SCAN_HOR ) 
    3735     {
    3736       width = 1;
    3737       height = 4;
    3738     }
    3739     else if( scanIdx == SCAN_VER )
    3740     {
    3741       width = 4;
    3742       height = 1;
    3743     }
    3744   }
    3745 #endif
    3746   if( uiCGPosX < width - 1 )
    3747   {
    3748     uiRight = (uiSigCoeffGroupFlag[ uiCGPosY * width + uiCGPosX + 1 ] != 0);
    3749   }
    3750   if (uiCGPosY < height - 1 )
    3751   {
    3752     uiLower = (uiSigCoeffGroupFlag[ (uiCGPosY  + 1 ) * width + uiCGPosX ] != 0);
    3753   }
    3754  
    3755   return (uiRight & uiLower);
    3756 }
    3757 #endif
     2512
     2513}
    37582514/** set quantized matrix coefficient for encode
    37592515 * \param scalingList quantaized matrix address
     
    38422598  UInt width = g_scalingListSizeX[sizeId];
    38432599  UInt height = g_scalingListSizeX[sizeId];
    3844 #if SCALING_LIST
    38452600  UInt ratio = g_scalingListSizeX[sizeId]/min(MAX_MATRIX_SIZE_NUM,(Int)g_scalingListSizeX[sizeId]);
    3846 #endif
    38472601  Int *quantcoeff;
    38482602  Int *coeff = scalingList->getScalingListAddress(sizeId,listId);
    38492603  quantcoeff   = getQuantCoeff(listId, qp, sizeId, SCALING_LIST_SQT);
    38502604
    3851 #if SCALING_LIST
    38522605  processScalingListEnc(coeff,quantcoeff,g_quantScales[qp]<<4,height,width,ratio,min(MAX_MATRIX_SIZE_NUM,(Int)g_scalingListSizeX[sizeId]),scalingList->getScalingListDC(sizeId,listId));
    3853 #else
    3854   processScalingListEnc(coeff,quantcoeff,g_quantScales[qp]<<4,height,width,1,(Int)g_scalingListSizeX[sizeId],0);
    3855 #endif
    38562606
    38572607  if(sizeId == SCALING_LIST_32x32 || sizeId == SCALING_LIST_16x16) //for NSQT
    38582608  {
    38592609    quantcoeff   = getQuantCoeff(listId, qp, sizeId-1,SCALING_LIST_VER);
    3860 #if SCALING_LIST
    38612610    processScalingListEnc(coeff,quantcoeff,g_quantScales[qp]<<4,height,width>>2,ratio,min(MAX_MATRIX_SIZE_NUM,(Int)g_scalingListSizeX[sizeId]),scalingList->getScalingListDC(sizeId,listId));
    3862 #else
    3863     processScalingListEnc(coeff,quantcoeff,g_quantScales[qp]<<4,height,width>>2,1,(Int)g_scalingListSizeX[sizeId],0);
    3864 #endif
    38652611
    38662612    quantcoeff   = getQuantCoeff(listId, qp, sizeId-1,SCALING_LIST_HOR);
    3867 #if SCALING_LIST
    38682613    processScalingListEnc(coeff,quantcoeff,g_quantScales[qp]<<4,height>>2,width,ratio,min(MAX_MATRIX_SIZE_NUM,(Int)g_scalingListSizeX[sizeId]),scalingList->getScalingListDC(sizeId,listId));
    3869 #else
    3870     processScalingListEnc(coeff,quantcoeff,g_quantScales[qp]<<4,height>>2,width,1,(Int)g_scalingListSizeX[sizeId],0);
    3871 #endif
    38722614  }
    38732615}
     
    38822624  UInt width = g_scalingListSizeX[sizeId];
    38832625  UInt height = g_scalingListSizeX[sizeId];
    3884 #if SCALING_LIST
    38852626  UInt ratio = g_scalingListSizeX[sizeId]/min(MAX_MATRIX_SIZE_NUM,(Int)g_scalingListSizeX[sizeId]);
    3886 #endif
    38872627  Int *dequantcoeff;
    38882628  Int *coeff = scalingList->getScalingListAddress(sizeId,listId);
    38892629
    38902630  dequantcoeff = getDequantCoeff(listId, qp, sizeId,SCALING_LIST_SQT);
    3891 #if SCALING_LIST
    38922631  processScalingListDec(coeff,dequantcoeff,g_invQuantScales[qp],height,width,ratio,min(MAX_MATRIX_SIZE_NUM,(Int)g_scalingListSizeX[sizeId]),scalingList->getScalingListDC(sizeId,listId));
    3893 #else
    3894   processScalingListDec(coeff,dequantcoeff,g_invQuantScales[qp],height,width,1,(Int)g_scalingListSizeX[sizeId],0);
    3895 #endif
    38962632
    38972633  if(sizeId == SCALING_LIST_32x32 || sizeId == SCALING_LIST_16x16)
    38982634  {
    38992635    dequantcoeff   = getDequantCoeff(listId, qp, sizeId-1,SCALING_LIST_VER);
    3900 #if SCALING_LIST
    39012636    processScalingListDec(coeff,dequantcoeff,g_invQuantScales[qp],height,width>>2,ratio,min(MAX_MATRIX_SIZE_NUM,(Int)g_scalingListSizeX[sizeId]),scalingList->getScalingListDC(sizeId,listId));
    3902 #else
    3903     processScalingListDec(coeff,dequantcoeff,g_invQuantScales[qp],height,width>>2,1,(Int)g_scalingListSizeX[sizeId],0);
    3904 #endif
    39052637
    39062638    dequantcoeff   = getDequantCoeff(listId, qp, sizeId-1,SCALING_LIST_HOR);
    39072639
    3908 #if SCALING_LIST
    39092640    processScalingListDec(coeff,dequantcoeff,g_invQuantScales[qp],height>>2,width,ratio,min(MAX_MATRIX_SIZE_NUM,(Int)g_scalingListSizeX[sizeId]),scalingList->getScalingListDC(sizeId,listId));
    3910 #else
    3911     processScalingListDec(coeff,dequantcoeff,g_invQuantScales[qp],height>>2,width,1,min(MAX_MATRIX_SIZE_NUM,(Int)g_scalingListSizeX[sizeId]),0);
    3912 #endif
    39132641  }
    39142642}
     
    40042732    }
    40052733  }
    4006 #if SCALING_LIST
    40072734  if(ratio > 1)
    40082735  {
    40092736    quantcoeff[0] = quantScales / dc;
    40102737  }
    4011 #endif
    40122738}
    40132739/** set quantized matrix coefficient for decode
     
    40322758    }
    40332759  }
    4034 #if SCALING_LIST
    40352760  if(ratio > 1)
    40362761  {
    40372762    dequantcoeff[0] = invQuantScales * dc;
    40382763  }
    4039 #endif
    40402764}
    40412765
Note: See TracChangeset for help on using the changeset viewer.