Changeset 1214 in SHVCSoftware for branches/SHM-dev/source/Lib/TLibEncoder
- Timestamp:
- 8 Jul 2015, 23:35:39 (10 years ago)
- Location:
- branches/SHM-dev/source/Lib/TLibEncoder
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SHM-dev/source/Lib/TLibEncoder/TEnc3DAsymLUT.cpp
r1212 r1214 15 15 16 16 m_pBestEncCuboid = NULL; 17 #if R0151_CGS_3D_ASYMLUT_IMPROVE18 17 m_nAccuFrameBit = 0; 19 18 m_nAccuFrameCGSBit = 0; 20 19 m_nPrevFrameCGSPartNumLog2 = 0; 21 #else22 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 #endif27 20 m_dTotalFrameBit = 0; 28 21 m_nTotalCGSBit = 0; … … 67 60 } 68 61 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 74 64 xAllocate3DArray( m_pColorInfo , xGetYSize() , xGetUSize() , xGetVSize() ); 75 65 xAllocate3DArray( m_pColorInfoC , xGetYSize() , xGetUSize() , xGetVSize() ); … … 111 101 } 112 102 113 #if R0151_CGS_3D_ASYMLUT_IMPROVE114 103 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 , 115 104 Pel & rP0 , Pel & rP1 , Pel & rP3 , Pel & rP7 , Int nResQuantBit ) … … 173 162 return( dMinError ); 174 163 } 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 255 165 Double TEnc3DAsymLUT::estimateDistWithCur3DAsymLUT( TComPic * pCurPic , UInt refLayerIdc ) 256 166 { … … 287 197 return( dErrorLuma + dErrorChroma); 288 198 } 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 332 200 #if R0179_ENC_OPT_3DLUT_SIZE 333 201 Double TEnc3DAsymLUT::derive3DAsymLUT( TComSlice * pSlice , TComPic * pCurPic , UInt refLayerIdc , TEncCfg * pCfg , Bool bSignalPPS , Bool bElRapSliceTypeB, Double dFrameLambda ) … … 497 365 } 498 366 #endif 499 500 367 501 368 Double TEnc3DAsymLUT::derive3DAsymLUT( TComSlice * pSlice , TComPic * pCurPic , UInt refLayerIdc , TEncCfg * pCfg , Bool bSignalPPS , Bool bElRapSliceTypeB ) … … 560 427 return( dMinError ); 561 428 } 562 #else563 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 else586 {587 break;588 }589 }590 setResQuantBit( nBestResQuanBit );591 xSaveCuboids( m_pBestEncCuboid );592 return( dCurError );593 }594 #endif595 429 596 430 Double TEnc3DAsymLUT::xxDeriveVertexes( Int nResQuanBit , SCuboid *** pCurCuboid ) … … 599 433 Int nYSize = 1 << ( getCurOctantDepth() + getCurYPartNumLog2() ); 600 434 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 605 436 for( Int yIdx = 0 ; yIdx < nYSize ; yIdx++ ) 606 437 { … … 612 443 SColorInfo & rCuboidColorInfoC = m_pColorInfoC[yIdx][uIdx][vIdx]; 613 444 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 619 446 for( Int idxVertex = 0 ; idxVertex < 4 ; idxVertex++ ) 620 447 { … … 625 452 { 626 453 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_IMPROVE628 y0 , u0 , v0 , nLengthY , nLengthUV ,629 #endif630 454 rCuboid.P[0].Y , rCuboid.P[1].Y , rCuboid.P[2].Y , rCuboid.P[3].Y , nResQuanBit ); 631 455 } 456 632 457 if( rCuboidColorInfoC.N > 0 ) 633 458 { 634 459 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_IMPROVE636 y0 , u0 , v0 , nLengthY , nLengthUV ,637 #endif638 460 rCuboid.P[0].U , rCuboid.P[1].U , rCuboid.P[2].U , rCuboid.P[3].U , nResQuanBit ); 461 639 462 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_IMPROVE641 y0 , u0 , v0 , nLengthY , nLengthUV ,642 #endif643 463 rCuboid.P[0].V , rCuboid.P[1].V , rCuboid.P[2].V , rCuboid.P[3].V , nResQuanBit ); 644 464 } … … 703 523 // since we do data collection only for overlapped region, the border extension is good enough 704 524 705 #if R0151_CGS_3D_ASYMLUT_IMPROVE706 525 m_dSumU = m_dSumV = 0; 707 526 m_nNChroma = 0; 708 #endif 527 709 528 for( Int i = top ; i <= bottom ; i++ ) 710 529 { … … 738 557 } 739 558 740 #if R0151_CGS_3D_ASYMLUT_IMPROVE741 559 m_dSumU += u; 742 560 m_dSumV += v; 743 561 m_nNChroma++; 744 #endif 562 745 563 SColorInfo sColorInfo; 746 #if R0151_CGS_3D_ASYMLUT_IMPROVE747 564 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 751 566 memset(&sColorInfo, 0, sizeof(SColorInfo)); 567 752 568 sColorInfo.Ys = Y; 753 569 sColorInfo.ys = y; … … 775 591 u = pIRLU[posIRLUV]; 776 592 v = pIRLV[posIRLUV]; 777 #if R0151_CGS_3D_ASYMLUT_IMPROVE 593 778 594 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 782 596 sColorInfo.Us = U; 783 597 sColorInfo.Vs = V; … … 810 624 Void TEnc3DAsymLUT::xxDerivePartNumLog2( TComSlice * pSlice , TEncCfg * pcCfg , Int & rOctantDepth , Int & rYPartNumLog2 , Bool bSignalPPS , Bool bElRapSliceTypeB ) 811 625 { 812 #if !R0151_CGS_3D_ASYMLUT_IMPROVE813 Int nSliceType = pSlice->getSliceType();814 // update slice type as what will be done later815 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 #endif831 626 Int nPartNumLog2 = 4; 832 627 if( pSlice->getBaseColPic( pSlice->getInterLayerPredLayerIdc( 0 ) )->getSlice( 0 )->isIntra() ) … … 834 629 nPartNumLog2 = xGetMaxPartNumLog2(); 835 630 } 836 #if R0151_CGS_3D_ASYMLUT_IMPROVE 631 837 632 if( m_nAccuFrameBit && pSlice->getPPS()->getCGSFlag() ) 838 633 { 839 634 Double dBitCost = 1.0 * m_nAccuFrameCGSBit / m_nAccuFrameBit; 840 635 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 847 637 Double dBitCostT = 0.03; 848 638 if( dBitCost < dBitCostT / 6.0 ) … … 855 645 } 856 646 } 857 #if !R0151_CGS_3D_ASYMLUT_IMPROVE 858 else 859 { 860 nPartNumLog2 -= nSliceTempLevel; 861 } 862 #endif 647 863 648 nPartNumLog2 = Clip3( 0 , xGetMaxPartNumLog2() , nPartNumLog2 ); 864 649 xxMapPartNum2DepthYPart( nPartNumLog2 , rOctantDepth , rYPartNumLog2 ); … … 885 670 Void TEnc3DAsymLUT::updatePicCGSBits( TComSlice * pcSlice , Int nPPSBit ) 886 671 { 887 #if !R0151_CGS_3D_ASYMLUT_IMPROVE888 const Int nSliceType = pcSlice->getSliceType();889 const Int nSliceTempLevel = pcSlice->getDepth();890 #endif891 672 for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) 892 673 { 893 674 UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i); 894 #if R0151_CGS_3D_ASYMLUT_IMPROVE895 675 m_nAccuFrameBit += pcSlice->getPic()->getFrameBit() + pcSlice->getBaseColPic(refLayerIdc)->getFrameBit(); 896 #else897 m_nPrevFrameBit[nSliceType][nSliceTempLevel] = pcSlice->getPic()->getFrameBit() + pcSlice->getBaseColPic(refLayerIdc)->getFrameBit();898 #endif899 676 m_dTotalFrameBit += pcSlice->getPic()->getFrameBit() + pcSlice->getBaseColPic(refLayerIdc)->getFrameBit(); 900 677 } 901 #if R0151_CGS_3D_ASYMLUT_IMPROVE 678 902 679 m_nAccuFrameCGSBit += nPPSBit; 903 680 m_nTotalCGSBit += nPPSBit; 904 681 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 911 683 #if R0179_ENC_OPT_3DLUT_SIZE 912 684 Int nCurELFrameBit = pcSlice->getPic()->getFrameBit(); … … 1033 805 { 1034 806 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() ); 1040 808 setResQuantBit( pSrc->getResQuantBit() ); 1041 809 } 1042 1043 810 #endif 1044 811 #endif -
branches/SHM-dev/source/Lib/TLibEncoder/TEnc3DAsymLUT.h
r1212 r1214 100 100 SCuboid *** m_pEncCuboid; 101 101 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; 116 109 #if R0179_ENC_OPT_3DLUT_SIZE 117 110 … … 124 117 SLUTSize m_sLutSizes[MAX_NUM_LUT_SIZES]; 125 118 #endif 126 #if R0151_CGS_3D_ASYMLUT_IMPROVE127 119 Double m_dSumU; 128 120 Double m_dSumV; 129 121 Int m_nNChroma; 130 #endif131 122 #if R0179_ENC_OPT_3DLUT_SIZE 132 123 TComOutputBitstream *m_pBitstreamRedirect; … … 135 126 136 127 private: 137 #if R0151_CGS_3D_ASYMLUT_IMPROVE138 128 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 , 139 129 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 145 131 Void xxDerivePartNumLog2( TComSlice * pSlice , TEncCfg * pcCfg , Int & rOctantDepth , Int & rYPartNumLog2 , Bool bSignalPPS , Bool bElRapSliceTypeB ); 146 132 Void xxMapPartNum2DepthYPart( Int nPartNumLog2 , Int & rOctantDepth , Int & rYPartNumLog2 ); … … 149 135 150 136 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 159 145 #if R0179_ENC_OPT_3DLUT_SIZE 160 146 Void xxConsolidateData( SLUTSize *pCurLUTSize, SLUTSize *pMaxLUTSize ); … … 175 161 } 176 162 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 ) 163 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, Double a, Double b, Double c, Double d ) 179 164 { 180 165 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; … … 182 167 }; 183 168 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 ) 169 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, Pel nP0, Pel nP1, Pel nP3, Pel nP7 ) 187 170 { 188 171 const Int nOne = xGetNormCoeffOne(); … … 194 177 return( dError ); 195 178 }; 196 #endif197 179 198 180 #endif -
branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
r1213 r1214 2495 2495 WRITE_CODE( pc3DAsymLUT->getDeltaBits()-1 , 2 , "cm_delta_bit" ); 2496 2496 #endif 2497 #if R0151_CGS_3D_ASYMLUT_IMPROVE 2497 2498 2498 if( pc3DAsymLUT->getCurOctantDepth() == 1 ) 2499 2499 { … … 2501 2501 WRITE_SVLC( pc3DAsymLUT->getAdaptChromaThresholdV() - ( 1 << ( pc3DAsymLUT->getInputBitDepthC() - 1 ) ) , "cm_adapt_threshold_v_delta" ); 2502 2502 } 2503 #endif2504 2503 2505 2504 #if R0164_CGS_LUT_BUGFIX_CHECK … … 2555 2554 if( uiCodeVertex ) 2556 2555 { 2557 #if R0151_CGS_3D_ASYMLUT_IMPROVE2558 2556 #if R0300_CGS_RES_COEFF_CODING 2559 2557 xWriteParam( sRes.Y, nFLCbits ); … … 2565 2563 xWriteParam( sRes.V ); 2566 2564 #endif 2567 #else2568 WRITE_SVLC( sRes.Y , "resY" );2569 WRITE_SVLC( sRes.U , "resU" );2570 WRITE_SVLC( sRes.V , "resV" );2571 #endif2572 2565 } 2573 2566 } … … 2579 2572 } 2580 2573 2581 #if R0151_CGS_3D_ASYMLUT_IMPROVE2582 2574 #if R0300_CGS_RES_COEFF_CODING 2583 2575 Void TEncCavlc::xWriteParam( Int param, UInt rParam) … … 2595 2587 WRITE_FLAG( param <0, "sign"); 2596 2588 } 2597 #endif2598 2589 2599 2590 #if R0300_CGS_RES_COEFF_CODING -
branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.h
r1212 r1214 174 174 Void xCode3DAsymLUTOctant( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength ); 175 175 #endif 176 #if R0151_CGS_3D_ASYMLUT_IMPROVE177 176 #if R0300_CGS_RES_COEFF_CODING 178 177 Void xWriteParam( Int param, UInt nFLCBits); … … 182 181 #else 183 182 Void xWriteParam( Int param); 184 #endif185 183 #endif 186 184 #endif -
branches/SHM-dev/source/Lib/TLibEncoder/TEncCfg.h
r1212 r1214 409 409 Int m_nCGSMaxYPartNumLog2; 410 410 Int m_nCGSLUTBit; 411 #if R0151_CGS_3D_ASYMLUT_IMPROVE412 411 Int m_nCGSAdaptiveChroma; 413 #endif414 412 #if R0179_ENC_OPT_3DLUT_SIZE 415 413 Int m_nCGSLutSizeRDO; … … 1150 1148 Void setCGSLUTBit(Int n) { m_nCGSLUTBit = n; } 1151 1149 Int getCGSLUTBit() { return m_nCGSLUTBit; } 1152 #if R0151_CGS_3D_ASYMLUT_IMPROVE1153 1150 Void setCGSAdaptChroma(Int n) { m_nCGSAdaptiveChroma = n; } 1154 1151 Int getCGSAdaptChroma() { return m_nCGSAdaptiveChroma; } 1155 #endif1156 1152 #if R0179_ENC_OPT_3DLUT_SIZE 1157 1153 Void setCGSLutSizeRDO(Int n) { m_nCGSLutSizeRDO = n; }
Note: See TracChangeset for help on using the changeset viewer.