Changeset 1214 in SHVCSoftware for branches/SHM-dev/source/Lib/TLibEncoder


Ignore:
Timestamp:
8 Jul 2015, 23:35:39 (10 years ago)
Author:
seregin
Message:

macro cleanup: R0151_CGS_3D_ASYMLUT_IMPROVE

Location:
branches/SHM-dev/source/Lib/TLibEncoder
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-dev/source/Lib/TLibEncoder/TEnc3DAsymLUT.cpp

    r1212 r1214  
    1515
    1616  m_pBestEncCuboid = NULL;
    17 #if R0151_CGS_3D_ASYMLUT_IMPROVE
    1817  m_nAccuFrameBit = 0;
    1918  m_nAccuFrameCGSBit = 0;
    2019  m_nPrevFrameCGSPartNumLog2 = 0;
    21 #else
    22   memset( m_nPrevFrameBit , 0 , sizeof( m_nPrevFrameBit ) );
    23   memset( m_nPrevFrameCGSBit , 0 , sizeof( m_nPrevFrameCGSBit ) );
    24   memset( m_nPrevFrameCGSPartNumLog2 , 0 , sizeof( m_nPrevFrameCGSPartNumLog2 ) );
    25   memset( m_nPrevFrameOverWritePPS , 0 , sizeof( m_nPrevFrameOverWritePPS ) );
    26 #endif
    2720  m_dTotalFrameBit = 0;
    2821  m_nTotalCGSBit = 0;
     
    6760  }
    6861
    69   TCom3DAsymLUT::create( nMaxOctantDepth , nInputBitDepth , nInputBitDepthC, nOutputBitDepth , nOutputBitDepthC, nMaxYPartNumLog2
    70 #if R0151_CGS_3D_ASYMLUT_IMPROVE
    71     , 1 << ( nInputBitDepthC - 1 ) , 1 << ( nInputBitDepthC - 1 )
    72 #endif
    73     );
     62  TCom3DAsymLUT::create( nMaxOctantDepth , nInputBitDepth , nInputBitDepthC, nOutputBitDepth , nOutputBitDepthC, nMaxYPartNumLog2, 1 << ( nInputBitDepthC - 1 ) , 1 << ( nInputBitDepthC - 1 ) );
     63
    7464  xAllocate3DArray( m_pColorInfo , xGetYSize() , xGetUSize() , xGetVSize() );
    7565  xAllocate3DArray( m_pColorInfoC , xGetYSize() , xGetUSize() , xGetVSize() );
     
    111101}
    112102
    113 #if R0151_CGS_3D_ASYMLUT_IMPROVE
    114103Double TEnc3DAsymLUT::xxDeriveVertexPerColor( Double N , Double Ys , Double Yy , Double Yu , Double Yv , Double ys , Double us , Double vs , Double yy , Double yu , Double yv , Double uu , Double uv , Double vv , Double YY ,
    115104  Pel & rP0 , Pel & rP1 , Pel & rP3 , Pel & rP7 , Int nResQuantBit )
     
    173162  return( dMinError );
    174163}
    175 #else
    176 Double TEnc3DAsymLUT::xxDeriveVertexPerColor( Double N , Double Ys , Double Yy , Double Yu , Double Yv , Double ys , Double us , Double vs , Double yy , Double yu , Double yv , Double uu , Double uv , Double vv , Double YY ,
    177   Int y0 , Int u0 , Int v0 , Int nLengthY , Int nLengthUV ,
    178   Pel & rP0 , Pel & rP1 , Pel & rP3 , Pel & rP7 , Int nResQuantBit )
    179 {
    180   Int nInitP0 = rP0;
    181   Int nInitP1 = rP1;
    182   Int nInitP3 = rP3;
    183   Int nInitP7 = rP7;
    184 
    185   Double dNorm = (N * yy * vv * uu - N * yy * uv * uv - N * yv * yv * uu - N * vv * yu * yu + 2 * N * yv * uv * yu - yy * vs * vs * uu + 2 * yy * vs * uv * us - yy * vv * us * us - 2 * vs * uv * yu * ys + uv * uv * ys * ys + vs * vs * yu * yu - 2 * yv * vs * us * yu + 2 * yv * vs * ys * uu - 2 * yv * uv * us * ys + 2 * vv * yu * ys * us - vv * uu * ys * ys + yv * yv * us * us);
    186   if( N > 16 && dNorm != 0 )
    187   {
    188     Double dInitA = (-N * uu * yv * Yv + N * uu * Yy * vv - N * Yy * uv * uv + N * yv * uv * Yu - N * yu * Yu * vv + N * yu * uv * Yv + yu * us * Ys * vv - vs * ys * uv * Yu - yu * vs * us * Yv - yv * uv * us * Ys - yv * vs * us * Yu - yu * uv * vs * Ys - ys * us * uv * Yv + ys * us * Yu * vv + 2 * Yy * vs * uv * us + uu * yv * vs * Ys - uu * ys * Ys * vv + uu * vs * ys * Yv + ys * Ys * uv * uv - Yy * vv * us * us + yu * Yu * vs * vs + yv * Yv * us * us - uu * Yy * vs * vs) / dNorm;
    189     Double dInitB = (N * yy * Yu * vv - N * yy * uv * Yv - N * Yu * yv * yv - N * yu * Yy * vv + N * uv * yv * Yy + N * yv * yu * Yv - yy * us * Ys * vv + yy * uv * vs * Ys - yy * Yu * vs * vs + yy * vs * us * Yv - uv * vs * ys * Yy - yv * yu * vs * Ys + yu * Yy * vs * vs + yu * ys * Ys * vv - uv * yv * ys * Ys + 2 * Yu * yv * vs * ys + us * ys * Yy * vv - vs * ys * yu * Yv + uv * ys * ys * Yv + us * Ys * yv * yv - Yu * ys * ys * vv - yv * ys * us * Yv - vs * us * yv * Yy) / dNorm;
    190     Double dInitC = -(-N * yy * Yv * uu + N * yy * uv * Yu - N * yv * yu * Yu - N * uv * yu * Yy + N * Yv * yu * yu + N * yv * Yy * uu - yy * uv * us * Ys + yy * Yv * us * us + yy * vs * Ys * uu - yy * vs * us * Yu + yv * ys * us * Yu - vs * Ys * yu * yu - yv * ys * Ys * uu + vs * us * yu * Yy + vs * ys * yu * Yu - uv * Yu * ys * ys + Yv * uu * ys * ys - yv * Yy * us * us - 2 * Yv * yu * ys * us - vs * ys * Yy * uu + uv * us * ys * Yy + uv * yu * ys * Ys + yv * yu * us * Ys) / dNorm;
    191     Double dInitD = (-uu * yy * vs * Yv + uu * yy * Ys * vv + uu * vs * yv * Yy - uu * ys * Yy * vv + uu * ys * yv * Yv - uu * Ys * yv * yv + yy * vs * uv * Yu + yy * us * uv * Yv - yy * Ys * uv * uv - yy * us * Yu * vv + ys * yu * Yu * vv + vs * Yv * yu * yu + ys * Yy * uv * uv - us * yu * yv * Yv + us * yu * Yy * vv + 2 * Ys * yv * uv * yu - vs * uv * yu * Yy - vs * yv * yu * Yu - Ys * vv * yu * yu - us * uv * yv * Yy - ys * yv * uv * Yu - ys * yu * uv * Yv + us * Yu * yv * yv) / dNorm;
    192     nInitP0 = xxCoeff2Vertex( dInitA , dInitB , dInitC , dInitD , y0 , u0 , v0 ) >> nResQuantBit  << nResQuantBit ;
    193     nInitP1 = xxCoeff2Vertex( dInitA , dInitB , dInitC , dInitD , y0 , u0 + nLengthUV , v0 ) >> nResQuantBit  << nResQuantBit ;
    194     nInitP3 = xxCoeff2Vertex( dInitA , dInitB , dInitC , dInitD , y0 , u0 + nLengthUV , v0 + nLengthUV ) >> nResQuantBit  << nResQuantBit ;
    195     nInitP7 = xxCoeff2Vertex( dInitA , dInitB , dInitC , dInitD , y0 + nLengthY , u0 + nLengthUV , v0 + nLengthUV ) >> nResQuantBit  << nResQuantBit ;
    196   }
    197 
    198   Int nMin = - ( 1 << ( m_nLUTBitDepth - 1 ) );
    199   Int nMax = - nMin - ( 1 << nResQuantBit  );
    200   Int nMask = ( 1 << nResQuantBit ) - 1;
    201 
    202   Double dMinError = MAX_DOUBLE;
    203   Int testRange = 2;
    204   for( Int i = - testRange , nDeltaP01 = nInitP1 - nInitP0 - testRange * ( 1 << nResQuantBit  ) ; i <= testRange ; i++ , nDeltaP01 += ( 1 << nResQuantBit  ) )
    205   {
    206     for( Int j = - testRange , nDeltaP13 = nInitP3 - nInitP1 - testRange * ( 1 << nResQuantBit  ) ; j <= testRange ; j++ , nDeltaP13 += ( 1 << nResQuantBit  ) )
    207     {
    208       for( Int k = - testRange , nDeltaP37 = nInitP7 - nInitP3 - testRange * ( 1 << nResQuantBit  ) ; k <= testRange ; k++ , nDeltaP37 += ( 1 << nResQuantBit  ) )
    209       {
    210         Double a = 1.0 * nDeltaP37 / nLengthY;
    211         Double b = 1.0 * nDeltaP01 / nLengthUV;
    212         Double c = 1.0 * nDeltaP13 / nLengthUV;
    213         Double d = ( Ys - a * ys - b * us - c * vs ) / N;
    214         Int nP0 = xxCoeff2Vertex( a , b , c , d , y0 , u0 , v0 ) >> nResQuantBit  << nResQuantBit ;
    215         nP0 = Clip3( nMin , nMax , nP0 );
    216         Int nP1 = Clip3( nMin , nMax , nP0 + nDeltaP01 );
    217         Int nP3 = Clip3( nMin , nMax , nP1 + nDeltaP13 );
    218         Int nP7 = Clip3( nMin , nMax , nP3 + nDeltaP37 );
    219         if ( nP0 & nMask )
    220         {
    221           nP0 -= ( nP0 & nMask );
    222         }
    223         if ( nP1 & nMask )
    224         {
    225           nP1 -= ( nP1 & nMask );
    226         }
    227         if ( nP3 & nMask )
    228         {
    229           nP3 -= ( nP3 & nMask );
    230         }
    231         if ( nP7 & nMask )
    232         {
    233           nP7 -= ( nP7 & nMask );
    234         }
    235         assert( !( nP0 & nMask ) && !( nP1 & nMask ) && !( nP3 & nMask ) && !( nP7 & nMask ) );
    236         Double dError = xxCalEstDist( N , Ys , Yy , Yu , Yv , ys , us , vs , yy , yu , yv , uu , uv , vv , YY , y0 , u0 , v0 , nLengthY , nLengthUV , nP0 , nP1 , nP3 , nP7 );
    237         if( dError < dMinError )
    238         {
    239           dMinError = dError;
    240           rP0 = ( Pel )nP0;
    241           rP1 = ( Pel )nP1;
    242           rP3 = ( Pel )nP3;
    243           rP7 = ( Pel )nP7;
    244           assert( nMin <= rP0 && rP0 <= nMax && nMin <= rP1 && rP1 <= nMax  && nMin <= rP3 && rP3 <= nMax && nMin <= rP7 && rP7 <= nMax );
    245         }
    246       }
    247     }
    248   }
    249 
    250   return( dMinError );
    251 }
    252 #endif
    253 
    254 #if R0151_CGS_3D_ASYMLUT_IMPROVE
     164
    255165Double TEnc3DAsymLUT::estimateDistWithCur3DAsymLUT( TComPic * pCurPic , UInt refLayerIdc )
    256166{
     
    287197  return( dErrorLuma + dErrorChroma);
    288198}
    289 #else
    290 Double TEnc3DAsymLUT::estimateDistWithCur3DAsymLUT( TComPic * pCurPic , UInt refLayerIdc )
    291 {
    292   xxCollectData( pCurPic , refLayerIdc );
    293 
    294   Double dErrorLuma = 0 , dErrorChroma = 0;
    295   Int nYSize = 1 << ( getCurOctantDepth() + getCurYPartNumLog2() );
    296   Int nUVSize = 1 << getCurOctantDepth();
    297   Int nLengthY = 1 << ( getInputBitDepthY() - getCurOctantDepth() - getCurYPartNumLog2() );
    298   Int nLengthUV = 1 << ( getInputBitDepthC() - getCurOctantDepth() );
    299   for( Int yIdx = 0 ; yIdx < nYSize ; yIdx++ )
    300   {
    301     for( Int uIdx = 0 ; uIdx < nUVSize ; uIdx++ )
    302     {
    303       for( Int vIdx = 0 ; vIdx < nUVSize ; vIdx++ )
    304       {
    305         SColorInfo & rCuboidColorInfo = m_pColorInfo[yIdx][uIdx][vIdx];
    306         SColorInfo & rCuboidColorInfoC = m_pColorInfoC[yIdx][uIdx][vIdx];
    307         SCuboid & rCuboid = xGetCuboid( yIdx , uIdx , vIdx );
    308         Int y0 = yIdx << xGetYShift2Idx();
    309         Int u0 = uIdx << xGetUShift2Idx();
    310         Int v0 = vIdx << xGetVShift2Idx();
    311         if( rCuboidColorInfo.N > 0 )
    312         {
    313           dErrorLuma += xxCalEstDist( rCuboidColorInfo.N , rCuboidColorInfo.Ys , rCuboidColorInfo.Yy , rCuboidColorInfo.Yu , rCuboidColorInfo.Yv , rCuboidColorInfo.ys , rCuboidColorInfo.us , rCuboidColorInfo.vs , rCuboidColorInfo.yy , rCuboidColorInfo.yu , rCuboidColorInfo.yv , rCuboidColorInfo.uu , rCuboidColorInfo.uv , rCuboidColorInfo.vv , rCuboidColorInfo.YY ,
    314             y0 , u0 , v0 , nLengthY , nLengthUV , rCuboid.P[0].Y , rCuboid.P[1].Y , rCuboid.P[2].Y , rCuboid.P[3].Y );
    315         }
    316         if( rCuboidColorInfoC.N > 0 )
    317         {
    318           dErrorChroma += xxCalEstDist( rCuboidColorInfoC.N , rCuboidColorInfoC.Us , rCuboidColorInfoC.Uy , rCuboidColorInfoC.Uu , rCuboidColorInfoC.Uv , rCuboidColorInfoC.ys , rCuboidColorInfoC.us , rCuboidColorInfoC.vs , rCuboidColorInfoC.yy , rCuboidColorInfoC.yu , rCuboidColorInfoC.yv , rCuboidColorInfoC.uu , rCuboidColorInfoC.uv , rCuboidColorInfoC.vv , rCuboidColorInfoC.UU ,
    319             y0 , u0 , v0 , nLengthY , nLengthUV , rCuboid.P[0].U , rCuboid.P[1].U , rCuboid.P[2].U , rCuboid.P[3].U );
    320           dErrorChroma += xxCalEstDist( rCuboidColorInfoC.N , rCuboidColorInfoC.Vs , rCuboidColorInfoC.Vy , rCuboidColorInfoC.Vu , rCuboidColorInfoC.Vv , rCuboidColorInfoC.ys , rCuboidColorInfoC.us , rCuboidColorInfoC.vs , rCuboidColorInfoC.yy , rCuboidColorInfoC.yu , rCuboidColorInfoC.yv , rCuboidColorInfoC.uu , rCuboidColorInfoC.uv , rCuboidColorInfoC.vv , rCuboidColorInfoC.VV ,
    321             y0 , u0 , v0 , nLengthY , nLengthUV , rCuboid.P[0].V , rCuboid.P[1].V , rCuboid.P[2].V , rCuboid.P[3].V );
    322         }
    323       }
    324     }
    325   }
    326 
    327   return( dErrorLuma + dErrorChroma);
    328 }
    329 #endif
    330 
    331 #if R0151_CGS_3D_ASYMLUT_IMPROVE
     199
    332200#if R0179_ENC_OPT_3DLUT_SIZE
    333201Double TEnc3DAsymLUT::derive3DAsymLUT( TComSlice * pSlice , TComPic * pCurPic , UInt refLayerIdc , TEncCfg * pCfg , Bool bSignalPPS , Bool bElRapSliceTypeB, Double dFrameLambda )
     
    497365}
    498366#endif
    499 
    500367
    501368Double TEnc3DAsymLUT::derive3DAsymLUT( TComSlice * pSlice , TComPic * pCurPic , UInt refLayerIdc , TEncCfg * pCfg , Bool bSignalPPS , Bool bElRapSliceTypeB )
     
    560427  return( dMinError );
    561428}
    562 #else
    563 Double TEnc3DAsymLUT::derive3DAsymLUT( TComSlice * pSlice , TComPic * pCurPic , UInt refLayerIdc , TEncCfg * pCfg , Bool bSignalPPS , Bool bElRapSliceTypeB )
    564 {
    565   m_nLUTBitDepth = pCfg->getCGSLUTBit();
    566   Int nCurYPartNumLog2 = 0 , nCurOctantDepth = 0;
    567   xxDerivePartNumLog2( pSlice , pCfg , nCurOctantDepth , nCurYPartNumLog2 , bSignalPPS , bElRapSliceTypeB );
    568   xUpdatePartitioning( nCurOctantDepth , nCurYPartNumLog2 );
    569   xxCollectData( pCurPic , refLayerIdc );
    570   Int nBestResQuanBit = 0;
    571   Double dError0 = xxDeriveVertexes( nBestResQuanBit , m_pBestEncCuboid );
    572   Double dCurError = dError0;
    573   Double dFactor = 1 + 0.001 * ( pSlice->getDepth() + 1 );
    574   for( Int nResQuanBit = 1 ; nResQuanBit < 4 ; nResQuanBit++ )
    575   {
    576     Double dError = xxDeriveVertexes( nResQuanBit , m_pEncCuboid );
    577     if( dError < dError0 * dFactor )
    578     {
    579       nBestResQuanBit = nResQuanBit;
    580       SCuboid *** tmp = m_pBestEncCuboid;
    581       m_pBestEncCuboid = m_pEncCuboid;
    582       m_pEncCuboid = tmp;
    583       dCurError = dError;
    584     }
    585     else
    586     {
    587       break;
    588     }
    589   }
    590   setResQuantBit( nBestResQuanBit );
    591   xSaveCuboids( m_pBestEncCuboid );
    592   return( dCurError );
    593 }
    594 #endif
    595429
    596430Double TEnc3DAsymLUT::xxDeriveVertexes( Int nResQuanBit , SCuboid *** pCurCuboid )
     
    599433  Int nYSize = 1 << ( getCurOctantDepth() + getCurYPartNumLog2() );
    600434  Int nUVSize = 1 << getCurOctantDepth();
    601 #if !R0151_CGS_3D_ASYMLUT_IMPROVE
    602   Int nLengthY = 1 << ( getInputBitDepthY() - getCurOctantDepth() - getCurYPartNumLog2() );
    603   Int nLengthUV = 1 << ( getInputBitDepthC() - getCurOctantDepth() );
    604 #endif
     435
    605436  for( Int yIdx = 0 ; yIdx < nYSize ; yIdx++ )
    606437  {
     
    612443        SColorInfo & rCuboidColorInfoC = m_pColorInfoC[yIdx][uIdx][vIdx];
    613444        SCuboid & rCuboid = pCurCuboid[yIdx][uIdx][vIdx];
    614 #if !R0151_CGS_3D_ASYMLUT_IMPROVE
    615         Int y0 = yIdx << xGetYShift2Idx();
    616         Int u0 = uIdx << xGetUShift2Idx();
    617         Int v0 = vIdx << xGetVShift2Idx();
    618 #endif
     445
    619446        for( Int idxVertex = 0 ; idxVertex < 4 ; idxVertex++ )
    620447        {
     
    625452        {
    626453          dErrorLuma += xxDeriveVertexPerColor( rCuboidColorInfo.N , rCuboidColorInfo.Ys , rCuboidColorInfo.Yy , rCuboidColorInfo.Yu , rCuboidColorInfo.Yv , rCuboidColorInfo.ys , rCuboidColorInfo.us , rCuboidColorInfo.vs , rCuboidColorInfo.yy , rCuboidColorInfo.yu , rCuboidColorInfo.yv , rCuboidColorInfo.uu , rCuboidColorInfo.uv , rCuboidColorInfo.vv , rCuboidColorInfo.YY ,
    627 #if !R0151_CGS_3D_ASYMLUT_IMPROVE
    628             y0 , u0 , v0 , nLengthY , nLengthUV ,
    629 #endif
    630454            rCuboid.P[0].Y , rCuboid.P[1].Y , rCuboid.P[2].Y , rCuboid.P[3].Y , nResQuanBit );
    631455        }
     456
    632457        if( rCuboidColorInfoC.N > 0 )
    633458        {
    634459          dErrorChroma += xxDeriveVertexPerColor( rCuboidColorInfoC.N , rCuboidColorInfoC.Us , rCuboidColorInfoC.Uy , rCuboidColorInfoC.Uu , rCuboidColorInfoC.Uv , rCuboidColorInfoC.ys , rCuboidColorInfoC.us , rCuboidColorInfoC.vs , rCuboidColorInfoC.yy , rCuboidColorInfoC.yu , rCuboidColorInfoC.yv , rCuboidColorInfoC.uu , rCuboidColorInfoC.uv , rCuboidColorInfoC.vv , rCuboidColorInfoC.UU ,
    635 #if !R0151_CGS_3D_ASYMLUT_IMPROVE
    636             y0 , u0 , v0 , nLengthY , nLengthUV ,
    637 #endif
    638460            rCuboid.P[0].U , rCuboid.P[1].U , rCuboid.P[2].U , rCuboid.P[3].U , nResQuanBit );
     461
    639462          dErrorChroma += xxDeriveVertexPerColor( rCuboidColorInfoC.N , rCuboidColorInfoC.Vs , rCuboidColorInfoC.Vy , rCuboidColorInfoC.Vu , rCuboidColorInfoC.Vv , rCuboidColorInfoC.ys , rCuboidColorInfoC.us , rCuboidColorInfoC.vs , rCuboidColorInfoC.yy , rCuboidColorInfoC.yu , rCuboidColorInfoC.yv , rCuboidColorInfoC.uu , rCuboidColorInfoC.uv , rCuboidColorInfoC.vv , rCuboidColorInfoC.VV ,
    640 #if !R0151_CGS_3D_ASYMLUT_IMPROVE
    641             y0 , u0 , v0 , nLengthY , nLengthUV ,
    642 #endif
    643463            rCuboid.P[0].V , rCuboid.P[1].V , rCuboid.P[2].V , rCuboid.P[3].V , nResQuanBit );
    644464        }
     
    703523  // since we do data collection only for overlapped region, the border extension is good enough
    704524
    705 #if R0151_CGS_3D_ASYMLUT_IMPROVE
    706525  m_dSumU = m_dSumV = 0;
    707526  m_nNChroma = 0;
    708 #endif
     527
    709528  for( Int i = top ; i <= bottom ; i++ )
    710529  {
     
    738557      }
    739558
    740 #if R0151_CGS_3D_ASYMLUT_IMPROVE
    741559      m_dSumU += u;
    742560      m_dSumV += v;
    743561      m_nNChroma++;
    744 #endif
     562
    745563      SColorInfo sColorInfo;
    746 #if R0151_CGS_3D_ASYMLUT_IMPROVE
    747564      SColorInfo & rCuboidColorInfo = m_pColorInfo[xGetYIdx(y)][xGetUIdx(u)][xGetVIdx(v)];
    748 #else
    749       SColorInfo & rCuboidColorInfo = m_pColorInfo[y>>xGetYShift2Idx()][u>>xGetUShift2Idx()][v>>xGetVShift2Idx()];
    750 #endif
     565
    751566      memset(&sColorInfo, 0, sizeof(SColorInfo));
     567
    752568      sColorInfo.Ys = Y;
    753569      sColorInfo.ys = y;
     
    775591        u = pIRLU[posIRLUV];
    776592        v = pIRLV[posIRLUV];
    777 #if R0151_CGS_3D_ASYMLUT_IMPROVE
     593
    778594        SColorInfo & rCuboidColorInfoC = m_pColorInfoC[xGetYIdx(y)][xGetUIdx(u)][xGetVIdx(v)];
    779 #else
    780         SColorInfo & rCuboidColorInfoC = m_pColorInfoC[y>>xGetYShift2Idx()][u>>xGetUShift2Idx()][v>>xGetVShift2Idx()];
    781 #endif
     595
    782596        sColorInfo.Us = U;
    783597        sColorInfo.Vs = V;
     
    810624Void TEnc3DAsymLUT::xxDerivePartNumLog2( TComSlice * pSlice , TEncCfg * pcCfg , Int & rOctantDepth , Int & rYPartNumLog2 , Bool bSignalPPS , Bool bElRapSliceTypeB )
    811625{
    812 #if !R0151_CGS_3D_ASYMLUT_IMPROVE
    813   Int nSliceType = pSlice->getSliceType();
    814   // update slice type as what will be done later
    815   if( pSlice->getActiveNumILRRefIdx() == 0 && pSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA )
    816   {
    817     nSliceType = I_SLICE;
    818   }
    819   else if( !bElRapSliceTypeB )
    820   {
    821     if( (pSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP) &&
    822       (pSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) &&
    823       pSlice->getSliceType() == B_SLICE )
    824     {
    825       nSliceType = P_SLICE;
    826     }
    827   }
    828 
    829   const Int nSliceTempLevel = pSlice->getDepth();
    830 #endif
    831626  Int nPartNumLog2 = 4;
    832627  if( pSlice->getBaseColPic( pSlice->getInterLayerPredLayerIdc( 0 ) )->getSlice( 0 )->isIntra() )
     
    834629    nPartNumLog2 = xGetMaxPartNumLog2();
    835630  }
    836 #if R0151_CGS_3D_ASYMLUT_IMPROVE
     631
    837632  if( m_nAccuFrameBit && pSlice->getPPS()->getCGSFlag() )
    838633  {
    839634    Double dBitCost = 1.0 * m_nAccuFrameCGSBit / m_nAccuFrameBit;
    840635    nPartNumLog2 = m_nPrevFrameCGSPartNumLog2;
    841 #else
    842   if( m_nPrevFrameBit[nSliceType][nSliceTempLevel] && pSlice->getPPS()->getCGSFlag() )
    843   {
    844     Double dBitCost = 1.0 * m_nPrevFrameCGSBit[nSliceType][nSliceTempLevel] / m_nPrevFrameBit[nSliceType][nSliceTempLevel];
    845     nPartNumLog2 = m_nPrevFrameCGSPartNumLog2[nSliceType][nSliceTempLevel];
    846 #endif
     636
    847637    Double dBitCostT = 0.03;
    848638    if( dBitCost < dBitCostT / 6.0 )
     
    855645    }
    856646  }
    857 #if !R0151_CGS_3D_ASYMLUT_IMPROVE
    858   else
    859   {
    860     nPartNumLog2 -= nSliceTempLevel;
    861   }
    862 #endif
     647
    863648  nPartNumLog2 = Clip3( 0 , xGetMaxPartNumLog2()  , nPartNumLog2 );
    864649  xxMapPartNum2DepthYPart( nPartNumLog2 , rOctantDepth , rYPartNumLog2 );
     
    885670Void TEnc3DAsymLUT::updatePicCGSBits( TComSlice * pcSlice , Int nPPSBit )
    886671{
    887 #if !R0151_CGS_3D_ASYMLUT_IMPROVE
    888   const Int nSliceType = pcSlice->getSliceType();
    889   const Int nSliceTempLevel = pcSlice->getDepth();
    890 #endif
    891672  for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ )
    892673  {
    893674    UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i);
    894 #if R0151_CGS_3D_ASYMLUT_IMPROVE
    895675    m_nAccuFrameBit += pcSlice->getPic()->getFrameBit() + pcSlice->getBaseColPic(refLayerIdc)->getFrameBit();
    896 #else
    897     m_nPrevFrameBit[nSliceType][nSliceTempLevel] = pcSlice->getPic()->getFrameBit() + pcSlice->getBaseColPic(refLayerIdc)->getFrameBit();
    898 #endif
    899676    m_dTotalFrameBit += pcSlice->getPic()->getFrameBit() + pcSlice->getBaseColPic(refLayerIdc)->getFrameBit();
    900677  }
    901 #if R0151_CGS_3D_ASYMLUT_IMPROVE
     678
    902679  m_nAccuFrameCGSBit += nPPSBit;
    903680  m_nTotalCGSBit += nPPSBit;
    904681  m_nPrevFrameCGSPartNumLog2 = getCurOctantDepth() * 3 + getCurYPartNumLog2();
    905 #else
    906   m_nPrevFrameOverWritePPS[nSliceType][nSliceTempLevel] = pcSlice->getCGSOverWritePPS();
    907   m_nPrevFrameCGSBit[nSliceType][nSliceTempLevel] = nPPSBit;
    908   m_nTotalCGSBit += nPPSBit;
    909   m_nPrevFrameCGSPartNumLog2[nSliceType][nSliceTempLevel] = getCurOctantDepth() * 3 + getCurYPartNumLog2();
    910 #endif
     682
    911683#if R0179_ENC_OPT_3DLUT_SIZE
    912684  Int nCurELFrameBit = pcSlice->getPic()->getFrameBit();
     
    1033805{
    1034806  assert( pSrc->getMaxOctantDepth() == getMaxOctantDepth() && pSrc->getMaxYPartNumLog2() == getMaxYPartNumLog2() );
    1035   xUpdatePartitioning( pSrc->getCurOctantDepth() , pSrc->getCurYPartNumLog2()
    1036 #if R0151_CGS_3D_ASYMLUT_IMPROVE
    1037     , pSrc->getAdaptChromaThresholdU() , pSrc->getAdaptChromaThresholdV()
    1038 #endif
    1039     );
     807  xUpdatePartitioning( pSrc->getCurOctantDepth(), pSrc->getCurYPartNumLog2(), pSrc->getAdaptChromaThresholdU(), pSrc->getAdaptChromaThresholdV() );
    1040808  setResQuantBit( pSrc->getResQuantBit() );
    1041809}
    1042 
    1043810#endif
    1044811#endif
  • branches/SHM-dev/source/Lib/TLibEncoder/TEnc3DAsymLUT.h

    r1212 r1214  
    100100  SCuboid *** m_pEncCuboid;
    101101  SCuboid *** m_pBestEncCuboid;
    102 #if R0151_CGS_3D_ASYMLUT_IMPROVE
    103   Int   m_nAccuFrameBit;                  // base + enhancement layer
    104   Int   m_nAccuFrameCGSBit;
    105   Int   m_nPrevFrameCGSPartNumLog2;
    106 #else
    107   Int   m_nPrevFrameBit[3][MAX_TLAYER];                  // base + enhancement layer
    108   Int   m_nPrevFrameCGSBit[3][MAX_TLAYER];
    109   Int   m_nPrevFrameCGSPartNumLog2[3][MAX_TLAYER];
    110   Int   m_nPrevFrameOverWritePPS[3][MAX_TLAYER];
    111 #endif
    112   Double m_dTotalFrameBit;
    113   Int   m_nTotalCGSBit;
    114   Int   m_nPPSBit;
    115   Int   m_nLUTBitDepth;
     102  Int         m_nAccuFrameBit;                  // base + enhancement layer
     103  Int         m_nAccuFrameCGSBit;
     104  Int         m_nPrevFrameCGSPartNumLog2;
     105  Double      m_dTotalFrameBit;
     106  Int         m_nTotalCGSBit;
     107  Int         m_nPPSBit;
     108  Int         m_nLUTBitDepth;
    116109#if R0179_ENC_OPT_3DLUT_SIZE
    117110
     
    124117  SLUTSize m_sLutSizes[MAX_NUM_LUT_SIZES];
    125118#endif
    126 #if R0151_CGS_3D_ASYMLUT_IMPROVE
    127119  Double m_dSumU;
    128120  Double m_dSumV;
    129121  Int    m_nNChroma;
    130 #endif
    131122#if R0179_ENC_OPT_3DLUT_SIZE
    132123  TComOutputBitstream  *m_pBitstreamRedirect;
     
    135126
    136127private:
    137 #if R0151_CGS_3D_ASYMLUT_IMPROVE
    138128  Double  xxDeriveVertexPerColor( Double N , Double Ys , Double Yy , Double Yu , Double Yv , Double ys , Double us , Double vs , Double yy , Double yu , Double yv , Double uu , Double uv , Double vv , Double YY ,
    139129    Pel & rP0 , Pel & rP1 , Pel & rP3 , Pel & rP7 , Int nResQuantBit );
    140 #else
    141   Double  xxDeriveVertexPerColor( Double N , Double Ys , Double Yy , Double Yu , Double Yv , Double ys , Double us , Double vs , Double yy , Double yu , Double yv , Double uu , Double uv , Double vv , Double YY ,
    142     Int y0 , Int u0 , Int v0 , Int nLengthY , Int nLengthUV ,
    143     Pel & rP0 , Pel & rP1 , Pel & rP3 , Pel & rP7 , Int nResQuantBit );
    144 #endif
     130
    145131  Void    xxDerivePartNumLog2( TComSlice * pSlice , TEncCfg * pcCfg , Int & rOctantDepth , Int & rYPartNumLog2 , Bool bSignalPPS , Bool bElRapSliceTypeB );
    146132  Void    xxMapPartNum2DepthYPart( Int nPartNumLog2 , Int & rOctantDepth , Int & rYPartNumLog2 );
     
    149135
    150136  Double  xxDeriveVertexes( Int nResQuantBit , SCuboid *** pCurCuboid );
    151   inline Double  xxCalEstDist( Double N , Double Ys , Double Yy , Double Yu , Double Yv , Double ys , Double us , Double vs , Double yy , Double yu , Double yv , Double uu , Double uv , Double vv , Double YY ,
    152     Int y0 , Int u0 , Int v0 , Int nLengthY , Int nLengthUV , Pel nP0 , Pel nP1 , Pel nP3 , Pel nP7 );
    153   inline Double  xxCalEstDist( Double N , Double Ys , Double Yy , Double Yu , Double Yv , Double ys , Double us , Double vs , Double yy , Double yu , Double yv , Double uu , Double uv , Double vv , Double YY ,
    154     Double a , Double b , Double c , Double d );
    155 #if R0151_CGS_3D_ASYMLUT_IMPROVE
    156   inline Double  xxCalEstDist( Double N , Double Ys , Double Yy , Double Yu , Double Yv , Double ys , Double us , Double vs , Double yy , Double yu , Double yv , Double uu , Double uv , Double vv , Double YY ,
    157     Pel nP0 , Pel nP1 , Pel nP3 , Pel nP7 );
    158 #endif
     137
     138  inline Double xxCalEstDist( Double N, Double Ys, Double Yy, Double Yu, Double Yv, Double ys, Double us, Double vs, Double yy, Double yu, Double yv, Double uu, Double uv, Double vv, Double YY,
     139    Int y0, Int u0, Int v0, Int nLengthY, Int nLengthUV, Pel nP0, Pel nP1, Pel nP3, Pel nP7 );
     140
     141  inline Double xxCalEstDist( Double N, Double Ys, Double Yy, Double Yu, Double Yv, Double ys, Double us, Double vs, Double yy, Double yu, Double yv, Double uu, Double uv, Double vv, Double YY, Double a, Double b, Double c, Double d );
     142
     143  inline Double xxCalEstDist( Double N, Double Ys, Double Yy, Double Yu, Double Yv, Double ys, Double us, Double vs, Double yy, Double yu, Double yv, Double uu, Double uv, Double vv, Double YY, Pel nP0, Pel nP1, Pel nP3, Pel nP7 );
     144
    159145#if R0179_ENC_OPT_3DLUT_SIZE
    160146  Void    xxConsolidateData( SLUTSize *pCurLUTSize, SLUTSize *pMaxLUTSize );
     
    175161}
    176162
    177 Double TEnc3DAsymLUT::xxCalEstDist( Double N , Double Ys , Double Yy , Double Yu , Double Yv , Double ys , Double us , Double vs , Double yy , Double yu , Double yv , Double uu , Double uv , Double vv , Double YY ,
    178   Double a , Double b , Double c , Double d )
     163Double TEnc3DAsymLUT::xxCalEstDist( Double N, Double Ys, Double Yy, Double Yu, Double Yv, Double ys, Double us, Double vs, Double yy, Double yu, Double yv, Double uu, Double uv, Double vv, Double YY, Double a, Double b, Double c, Double d ) 
    179164{
    180165  Double dError = N * d * d + 2 * b * c * uv + 2 * a * c * yv + 2 * a * b * yu - 2 * c * Yv - 2 * b * Yu - 2 * a * Yy + 2 * c * d * vs + 2 * b * d * us + 2 * a * d * ys + a * a * yy + c * c * vv + b * b * uu - 2 * d * Ys + YY;
     
    182167};
    183168
    184 #if R0151_CGS_3D_ASYMLUT_IMPROVE
    185 Double TEnc3DAsymLUT::xxCalEstDist( Double N , Double Ys , Double Yy , Double Yu , Double Yv , Double ys , Double us , Double vs , Double yy , Double yu , Double yv , Double uu , Double uv , Double vv , Double YY ,
    186   Pel nP0 , Pel nP1 , Pel nP3 , Pel nP7 )
     169Double TEnc3DAsymLUT::xxCalEstDist( Double N, Double Ys, Double Yy, Double Yu, Double Yv, Double ys, Double us, Double vs, Double yy, Double yu, Double yv, Double uu, Double uv, Double vv, Double YY, Pel nP0, Pel nP1, Pel nP3, Pel nP7 ) 
    187170{
    188171  const Int nOne = xGetNormCoeffOne();
     
    194177  return( dError );
    195178};
    196 #endif
    197179
    198180#endif
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp

    r1213 r1214  
    24952495  WRITE_CODE( pc3DAsymLUT->getDeltaBits()-1 , 2 , "cm_delta_bit" );
    24962496#endif
    2497 #if R0151_CGS_3D_ASYMLUT_IMPROVE
     2497
    24982498  if( pc3DAsymLUT->getCurOctantDepth() == 1 )
    24992499  {
     
    25012501    WRITE_SVLC( pc3DAsymLUT->getAdaptChromaThresholdV() - ( 1 << ( pc3DAsymLUT->getInputBitDepthC() - 1 ) ) , "cm_adapt_threshold_v_delta" );
    25022502  }
    2503 #endif
    25042503
    25052504#if R0164_CGS_LUT_BUGFIX_CHECK
     
    25552554        if( uiCodeVertex )
    25562555        {
    2557 #if R0151_CGS_3D_ASYMLUT_IMPROVE
    25582556#if R0300_CGS_RES_COEFF_CODING
    25592557          xWriteParam( sRes.Y, nFLCbits );
     
    25652563          xWriteParam( sRes.V );
    25662564#endif
    2567 #else
    2568           WRITE_SVLC( sRes.Y , "resY" );
    2569           WRITE_SVLC( sRes.U , "resU" );
    2570           WRITE_SVLC( sRes.V , "resV" );
    2571 #endif
    25722565        }
    25732566      }
     
    25792572}
    25802573
    2581 #if R0151_CGS_3D_ASYMLUT_IMPROVE
    25822574#if R0300_CGS_RES_COEFF_CODING
    25832575Void TEncCavlc::xWriteParam( Int param, UInt rParam)
     
    25952587    WRITE_FLAG( param <0, "sign");
    25962588}
    2597 #endif
    25982589
    25992590#if R0300_CGS_RES_COEFF_CODING
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.h

    r1212 r1214  
    174174  Void xCode3DAsymLUTOctant( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength );
    175175#endif
    176 #if R0151_CGS_3D_ASYMLUT_IMPROVE
    177176#if R0300_CGS_RES_COEFF_CODING
    178177  Void xWriteParam( Int param, UInt nFLCBits);
     
    182181#else
    183182  Void xWriteParam( Int param);
    184 #endif
    185183#endif
    186184#endif
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncCfg.h

    r1212 r1214  
    409409  Int       m_nCGSMaxYPartNumLog2;
    410410  Int       m_nCGSLUTBit;
    411 #if R0151_CGS_3D_ASYMLUT_IMPROVE
    412411  Int       m_nCGSAdaptiveChroma;
    413 #endif
    414412#if R0179_ENC_OPT_3DLUT_SIZE
    415413  Int       m_nCGSLutSizeRDO;
     
    11501148  Void      setCGSLUTBit(Int n)           { m_nCGSLUTBit = n;    }
    11511149  Int       getCGSLUTBit()                { return m_nCGSLUTBit; }
    1152 #if R0151_CGS_3D_ASYMLUT_IMPROVE
    11531150  Void      setCGSAdaptChroma(Int n)      { m_nCGSAdaptiveChroma = n;  }
    11541151  Int       getCGSAdaptChroma()           { return m_nCGSAdaptiveChroma; }
    1155 #endif
    11561152#if R0179_ENC_OPT_3DLUT_SIZE
    11571153  Void      setCGSLutSizeRDO(Int n)      { m_nCGSLutSizeRDO = n;  }
Note: See TracChangeset for help on using the changeset viewer.