Changeset 825 in SHVCSoftware for branches/SHM-dev/source/Lib/TLibEncoder
- Timestamp:
- 11 Jul 2014, 20:42:00 (11 years ago)
- Location:
- branches/SHM-dev/source/Lib/TLibEncoder
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SHM-dev/source/Lib/TLibEncoder/TEnc3DAsymLUT.cpp
r815 r825 15 15 m_pEncCuboid = NULL; 16 16 m_pBestEncCuboid = NULL; 17 memset( m_nPrevFrameBit , 0 , sizeof( m_nPrevFrameBit ) ); 18 memset( m_nPrevFrameCGSBit , 0 , sizeof( m_nPrevFrameCGSBit ) ); 19 memset( m_nPrevFrameCGSPartNumLog2 , 0 , sizeof( m_nPrevFrameCGSPartNumLog2 ) ); 20 memset( m_nPrevFrameOverWritePPS , 0 , sizeof( m_nPrevFrameOverWritePPS ) ); 17 m_nAccuFrameBit = 0; 18 m_nAccuFrameCGSBit = 0; 19 m_nPrevFrameCGSPartNumLog2 = 0; 21 20 m_dTotalFrameBit = 0; 22 21 m_nTotalCGSBit = 0; … … 32 31 } 33 32 34 TCom3DAsymLUT::create( nMaxOctantDepth , nInputBitDepth , nInputBitDepthC, nOutputBitDepth , nOutputBitDepthC, nMaxYPartNumLog2 ); 33 TCom3DAsymLUT::create( nMaxOctantDepth , nInputBitDepth , nInputBitDepthC, nOutputBitDepth , nOutputBitDepthC, nMaxYPartNumLog2 34 #if R0151_CGS_3D_ASYMLUT_IMPROVE 35 , 1 << ( nInputBitDepthC - 1 ) , 1 << ( nInputBitDepthC - 1 ) 36 #endif 37 ); 35 38 xAllocate3DArray( m_pColorInfo , xGetYSize() , xGetUSize() , xGetVSize() ); 36 39 xAllocate3DArray( m_pColorInfoC , xGetYSize() , xGetUSize() , xGetVSize() ); … … 58 61 } 59 62 63 #if R0151_CGS_3D_ASYMLUT_IMPROVE 64 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 , 65 Pel & rP0 , Pel & rP1 , Pel & rP3 , Pel & rP7 , Int nResQuantBit ) 66 { 67 Int nInitP0 = rP0; 68 Int nInitP1 = rP1; 69 Int nInitP3 = rP3; 70 Int nInitP7 = rP7; 71 72 const Int nOne = xGetNormCoeffOne(); 73 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); 74 if( N > 16 && dNorm != 0 ) 75 { 76 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; 77 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; 78 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; 79 nInitP0 = ( Int )( dInitA * nOne + 0.5 ) >> nResQuantBit << nResQuantBit; 80 nInitP1 = ( Int )( dInitB * nOne + 0.5 ) >> nResQuantBit << nResQuantBit; 81 nInitP3 = ( Int )( dInitC * nOne + 0.5 ) >> nResQuantBit << nResQuantBit; 82 } 83 84 Int nMin = - ( 1 << ( m_nLUTBitDepth - 1 ) ); 85 Int nMax = - nMin - ( 1 << nResQuantBit ); 86 Int nMask = ( 1 << nResQuantBit ) - 1; 87 88 Double dMinError = MAX_DOUBLE; 89 Int nTestRange = 2; 90 Int nStepSize = 1 << nResQuantBit; 91 for( Int i = - nTestRange ; i <= nTestRange ; i++ ) 92 { 93 for( Int j = - nTestRange ; j <= nTestRange ; j++ ) 94 { 95 for( Int k = - nTestRange ; k <= nTestRange ; k++ ) 96 { 97 Int nTestP0 = Clip3( nMin , nMax , nInitP0 + i * nStepSize ); 98 Int nTestP1 = Clip3( nMin , nMax , nInitP1 + j * nStepSize ); 99 Int nTestP3 = Clip3( nMin , nMax , nInitP3 + k * nStepSize ); 100 Double a = 1.0 * nTestP0 / nOne; 101 Double b = 1.0 * nTestP1 / nOne; 102 Double c = 1.0 * nTestP3 / nOne; 103 Double d = ( Ys - a * ys - b * us - c * vs ) / N; 104 nInitP7 = ( ( Int )d ) >> nResQuantBit << nResQuantBit; 105 for( Int m = 0 ; m < 2 ; m++ ) 106 { 107 Int nTestP7 = Clip3( nMin , nMax , nInitP7 + m * nStepSize ); 108 Double dError = xxCalEstDist( N , Ys , Yy , Yu , Yv , ys , us , vs , yy , yu , yv , uu , uv , vv , YY , a , b , c , nTestP7 ); 109 if( dError < dMinError ) 110 { 111 dMinError = dError; 112 rP0 = ( Pel )nTestP0; 113 rP1 = ( Pel )nTestP1; 114 rP3 = ( Pel )nTestP3; 115 rP7 = ( Pel )nTestP7; 116 } 117 } 118 } 119 } 120 } 121 assert( !( rP0 & nMask ) && !( rP1 & nMask ) && !( rP3 & nMask ) && !( rP7 & nMask ) ); 122 123 return( dMinError ); 124 } 125 #else 60 126 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 , 61 127 Int y0 , Int u0 , Int v0 , Int nLengthY , Int nLengthUV , … … 134 200 return( dMinError ); 135 201 } 136 202 #endif 203 204 #if R0151_CGS_3D_ASYMLUT_IMPROVE 205 Double TEnc3DAsymLUT::estimateDistWithCur3DAsymLUT( TComPic * pCurPic , UInt refLayerIdc ) 206 { 207 xxCollectData( pCurPic , refLayerIdc ); 208 209 Double dErrorLuma = 0 , dErrorChroma = 0; 210 Int nYSize = 1 << ( getCurOctantDepth() + getCurYPartNumLog2() ); 211 Int nUVSize = 1 << getCurOctantDepth(); 212 for( Int yIdx = 0 ; yIdx < nYSize ; yIdx++ ) 213 { 214 for( Int uIdx = 0 ; uIdx < nUVSize ; uIdx++ ) 215 { 216 for( Int vIdx = 0 ; vIdx < nUVSize ; vIdx++ ) 217 { 218 SColorInfo & rCuboidColorInfo = m_pColorInfo[yIdx][uIdx][vIdx]; 219 SColorInfo & rCuboidColorInfoC = m_pColorInfoC[yIdx][uIdx][vIdx]; 220 SCuboid & rCuboid = xGetCuboid( yIdx , uIdx , vIdx ); 221 if( rCuboidColorInfo.N > 0 ) 222 { 223 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 , 224 rCuboid.P[0].Y , rCuboid.P[1].Y , rCuboid.P[2].Y , rCuboid.P[3].Y ); 225 } 226 if( rCuboidColorInfoC.N > 0 ) 227 { 228 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 , 229 rCuboid.P[0].U , rCuboid.P[1].U , rCuboid.P[2].U , rCuboid.P[3].U ); 230 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 , 231 rCuboid.P[0].V , rCuboid.P[1].V , rCuboid.P[2].V , rCuboid.P[3].V ); 232 } 233 } 234 } 235 } 236 237 return( dErrorLuma + dErrorChroma); 238 } 239 #else 137 240 Double TEnc3DAsymLUT::estimateDistWithCur3DAsymLUT( TComPic * pCurPic , UInt refLayerIdc ) 138 241 { … … 174 277 return( dErrorLuma + dErrorChroma); 175 278 } 176 279 #endif 280 281 #if R0151_CGS_3D_ASYMLUT_IMPROVE 282 Double TEnc3DAsymLUT::derive3DAsymLUT( TComSlice * pSlice , TComPic * pCurPic , UInt refLayerIdc , TEncCfg * pCfg , Bool bSignalPPS , Bool bElRapSliceTypeB ) 283 { 284 m_nLUTBitDepth = pCfg->getCGSLUTBit(); 285 Int nCurYPartNumLog2 = 0 , nCurOctantDepth = 0; 286 xxDerivePartNumLog2( pSlice , pCfg , nCurOctantDepth , nCurYPartNumLog2 , bSignalPPS , bElRapSliceTypeB ); 287 288 Int nBestResQuanBit = 0; 289 Int nBestAdaptCThresholdU = 1 << ( getInputBitDepthC() - 1 ); 290 Int nBestAdaptCThresholdV = 1 << ( getInputBitDepthC() - 1 ); 291 Int nBestOctantDepth = nCurOctantDepth; 292 Int nBestYPartNumLog2 = nCurYPartNumLog2; 293 Int nTargetLoop = 1 + ( pCfg->getCGSAdaptChroma() && ( nCurOctantDepth == 1 || ( nCurOctantDepth * 3 + nCurYPartNumLog2 ) >= 5 ) ); 294 Double dMinError = MAX_DOUBLE; 295 for( Int nLoop = 0 ; nLoop < nTargetLoop ; nLoop++ ) 296 { 297 Int nAdaptCThresholdU = 1 << ( getInputBitDepthC() - 1 ); 298 Int nAdaptCThresholdV = 1 << ( getInputBitDepthC() - 1 ); 299 if( nLoop > 0 ) 300 { 301 nAdaptCThresholdU = ( Int )( m_dSumU / m_nNChroma + 0.5 ); 302 nAdaptCThresholdV = ( Int )( m_dSumV / m_nNChroma + 0.5 ); 303 if( nCurOctantDepth > 1 ) 304 { 305 nCurOctantDepth = 1; 306 nCurYPartNumLog2 = 2; 307 } 308 if( nAdaptCThresholdU == nBestAdaptCThresholdU && nAdaptCThresholdV == nBestAdaptCThresholdV 309 && nCurOctantDepth == nBestOctantDepth && nCurYPartNumLog2 == nBestYPartNumLog2 ) 310 break; 311 } 312 xUpdatePartitioning( nCurOctantDepth , nCurYPartNumLog2 , nAdaptCThresholdU , nAdaptCThresholdV ); 313 xxCollectData( pCurPic , refLayerIdc ); 314 for( Int nResQuanBit = 0 ; nResQuanBit < 4 ; nResQuanBit++ ) 315 { 316 Double dError = xxDeriveVertexes( nResQuanBit , m_pEncCuboid ) / ( 1 + ( nResQuanBit > 0 ) * 0.001 * ( pSlice->getDepth() + 1 ) ); 317 if( dError <= dMinError ) 318 { 319 nBestResQuanBit = nResQuanBit; 320 nBestAdaptCThresholdU = nAdaptCThresholdU; 321 nBestAdaptCThresholdV = nAdaptCThresholdV; 322 nBestOctantDepth = nCurOctantDepth; 323 nBestYPartNumLog2 = nCurYPartNumLog2; 324 SCuboid *** tmp = m_pBestEncCuboid; 325 m_pBestEncCuboid = m_pEncCuboid; 326 m_pEncCuboid = tmp; 327 dMinError = dError; 328 } 329 else 330 { 331 break; 332 } 333 } 334 } 335 setResQuantBit( nBestResQuanBit ); 336 xUpdatePartitioning( nBestOctantDepth , nBestYPartNumLog2 , nBestAdaptCThresholdU , nBestAdaptCThresholdV ); 337 xSaveCuboids( m_pBestEncCuboid ); 338 return( dMinError ); 339 } 340 #else 177 341 Double TEnc3DAsymLUT::derive3DAsymLUT( TComSlice * pSlice , TComPic * pCurPic , UInt refLayerIdc , TEncCfg * pCfg , Bool bSignalPPS , Bool bElRapSliceTypeB ) 178 342 { … … 204 368 setResQuantBit( nBestResQuanBit ); 205 369 xSaveCuboids( m_pBestEncCuboid ); 206 207 370 return( dCurError ); 208 371 } 372 #endif 209 373 210 374 Double TEnc3DAsymLUT::xxDeriveVertexes( Int nResQuanBit , SCuboid *** pCurCuboid ) … … 213 377 Int nYSize = 1 << ( getCurOctantDepth() + getCurYPartNumLog2() ); 214 378 Int nUVSize = 1 << getCurOctantDepth(); 379 #if !R0151_CGS_3D_ASYMLUT_IMPROVE 215 380 Int nLengthY = 1 << ( getInputBitDepthY() - getCurOctantDepth() - getCurYPartNumLog2() ); 216 381 Int nLengthUV = 1 << ( getInputBitDepthC() - getCurOctantDepth() ); 382 #endif 217 383 for( Int yIdx = 0 ; yIdx < nYSize ; yIdx++ ) 218 384 { … … 224 390 SColorInfo & rCuboidColorInfoC = m_pColorInfoC[yIdx][uIdx][vIdx]; 225 391 SCuboid & rCuboid = pCurCuboid[yIdx][uIdx][vIdx]; 392 #if !R0151_CGS_3D_ASYMLUT_IMPROVE 226 393 Int y0 = yIdx << xGetYShift2Idx(); 227 394 Int u0 = uIdx << xGetUShift2Idx(); 228 395 Int v0 = vIdx << xGetVShift2Idx(); 396 #endif 229 397 for( Int idxVertex = 0 ; idxVertex < 4 ; idxVertex++ ) 230 398 { … … 235 403 { 236 404 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 , 237 y0 , u0 , v0 , nLengthY , nLengthUV , rCuboid.P[0].Y , rCuboid.P[1].Y , rCuboid.P[2].Y , rCuboid.P[3].Y , nResQuanBit ); 405 #if !R0151_CGS_3D_ASYMLUT_IMPROVE 406 y0 , u0 , v0 , nLengthY , nLengthUV , 407 #endif 408 rCuboid.P[0].Y , rCuboid.P[1].Y , rCuboid.P[2].Y , rCuboid.P[3].Y , nResQuanBit ); 238 409 } 239 410 if( rCuboidColorInfoC.N > 0 ) 240 411 { 241 412 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 , 242 y0 , u0 , v0 , nLengthY , nLengthUV , rCuboid.P[0].U , rCuboid.P[1].U , rCuboid.P[2].U , rCuboid.P[3].U , nResQuanBit ); 413 #if !R0151_CGS_3D_ASYMLUT_IMPROVE 414 y0 , u0 , v0 , nLengthY , nLengthUV , 415 #endif 416 rCuboid.P[0].U , rCuboid.P[1].U , rCuboid.P[2].U , rCuboid.P[3].U , nResQuanBit ); 243 417 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 , 244 y0 , u0 , v0 , nLengthY , nLengthUV , rCuboid.P[0].V , rCuboid.P[1].V , rCuboid.P[2].V , rCuboid.P[3].V , nResQuanBit ); 418 #if !R0151_CGS_3D_ASYMLUT_IMPROVE 419 y0 , u0 , v0 , nLengthY , nLengthUV , 420 #endif 421 rCuboid.P[0].V , rCuboid.P[1].V , rCuboid.P[2].V , rCuboid.P[3].V , nResQuanBit ); 245 422 } 246 423 … … 299 476 // since we do data collection only for overlapped region, the border extension is good enough 300 477 478 #if R0151_CGS_3D_ASYMLUT_IMPROVE 479 m_dSumU = m_dSumV = 0; 480 m_nNChroma = 0; 481 #endif 301 482 for( Int i = top ; i <= bottom ; i++ ) 302 483 { … … 330 511 } 331 512 513 #if R0151_CGS_3D_ASYMLUT_IMPROVE 514 m_dSumU += u; 515 m_dSumV += v; 516 m_nNChroma++; 517 #endif 332 518 SColorInfo sColorInfo; 519 #if R0151_CGS_3D_ASYMLUT_IMPROVE 520 SColorInfo & rCuboidColorInfo = m_pColorInfo[xGetYIdx(y)][xGetUIdx(u)][xGetVIdx(v)]; 521 #else 333 522 SColorInfo & rCuboidColorInfo = m_pColorInfo[y>>xGetYShift2Idx()][u>>xGetUShift2Idx()][v>>xGetVShift2Idx()]; 523 #endif 334 524 memset(&sColorInfo, 0, sizeof(SColorInfo)); 335 525 sColorInfo.Ys = Y; … … 358 548 u = pIRLU[posIRLUV]; 359 549 v = pIRLV[posIRLUV]; 550 #if R0151_CGS_3D_ASYMLUT_IMPROVE 551 SColorInfo & rCuboidColorInfoC = m_pColorInfoC[xGetYIdx(y)][xGetUIdx(u)][xGetVIdx(v)]; 552 #else 360 553 SColorInfo & rCuboidColorInfoC = m_pColorInfoC[y>>xGetYShift2Idx()][u>>xGetUShift2Idx()][v>>xGetVShift2Idx()]; 554 #endif 361 555 sColorInfo.Us = U; 362 556 sColorInfo.Vs = V; … … 389 583 Void TEnc3DAsymLUT::xxDerivePartNumLog2( TComSlice * pSlice , TEncCfg * pcCfg , Int & rOctantDepth , Int & rYPartNumLog2 , Bool bSignalPPS , Bool bElRapSliceTypeB ) 390 584 { 391 Int nSliceType = pSlice->getSliceType();392 // update slice type as what will be done later393 if( pSlice->getActiveNumILRRefIdx() == 0 && pSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA )394 {395 nSliceType = I_SLICE;396 }397 else if( !bElRapSliceTypeB )398 {399 if( (pSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP) &&400 (pSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) &&401 pSlice->getSliceType() == B_SLICE )402 {403 nSliceType = P_SLICE;404 }405 }406 407 const Int nSliceTempLevel = pSlice->getDepth();408 585 Int nPartNumLog2 = 4; 409 586 if( pSlice->getBaseColPic( pSlice->getInterLayerPredLayerIdc( 0 ) )->getSlice( 0 )->isIntra() ) … … 411 588 nPartNumLog2 = xGetMaxPartNumLog2(); 412 589 } 413 if( m_n PrevFrameBit[nSliceType][nSliceTempLevel]&& pSlice->getPPS()->getCGSFlag() )414 { 415 Double dBitCost = 1.0 * m_n PrevFrameCGSBit[nSliceType][nSliceTempLevel] / m_nPrevFrameBit[nSliceType][nSliceTempLevel];416 nPartNumLog2 = m_nPrevFrameCGSPartNumLog2 [nSliceType][nSliceTempLevel];590 if( m_nAccuFrameBit && pSlice->getPPS()->getCGSFlag() ) 591 { 592 Double dBitCost = 1.0 * m_nAccuFrameCGSBit / m_nAccuFrameBit; 593 nPartNumLog2 = m_nPrevFrameCGSPartNumLog2; 417 594 Double dBitCostT = 0.03; 418 595 if( dBitCost < dBitCostT / 6.0 ) … … 425 602 } 426 603 } 427 else 428 { 429 nPartNumLog2 -= nSliceTempLevel; 430 } 431 nPartNumLog2 = Clip3( 0 , xGetMaxPartNumLog2() , nPartNumLog2 ); 604 nPartNumLog2 = Clip3( 0 , xGetMaxPartNumLog2() , nPartNumLog2 ); 432 605 xxMapPartNum2DepthYPart( nPartNumLog2 , rOctantDepth , rYPartNumLog2 ); 433 606 } … … 453 626 Void TEnc3DAsymLUT::updatePicCGSBits( TComSlice * pcSlice , Int nPPSBit ) 454 627 { 455 const Int nSliceType = pcSlice->getSliceType();456 const Int nSliceTempLevel = pcSlice->getDepth();457 458 628 for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) 459 629 { 460 630 UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i); 461 m_n PrevFrameBit[nSliceType][nSliceTempLevel]= pcSlice->getPic()->getFrameBit() + pcSlice->getBaseColPic(refLayerIdc)->getFrameBit();631 m_nAccuFrameBit += pcSlice->getPic()->getFrameBit() + pcSlice->getBaseColPic(refLayerIdc)->getFrameBit(); 462 632 m_dTotalFrameBit += pcSlice->getPic()->getFrameBit() + pcSlice->getBaseColPic(refLayerIdc)->getFrameBit(); 463 633 } 464 m_nPrevFrameOverWritePPS[nSliceType][nSliceTempLevel] = pcSlice->getCGSOverWritePPS(); 465 m_nPrevFrameCGSBit[nSliceType][nSliceTempLevel] = nPPSBit; 634 m_nAccuFrameCGSBit += nPPSBit; 466 635 m_nTotalCGSBit += nPPSBit; 467 m_nPrevFrameCGSPartNumLog2 [nSliceType][nSliceTempLevel]= getCurOctantDepth() * 3 + getCurYPartNumLog2();468 } 469 470 #endif 636 m_nPrevFrameCGSPartNumLog2 = getCurOctantDepth() * 3 + getCurYPartNumLog2(); 637 } 638 639 #endif -
branches/SHM-dev/source/Lib/TLibEncoder/TEnc3DAsymLUT.h
r713 r825 78 78 SCuboid *** m_pEncCuboid; 79 79 SCuboid *** m_pBestEncCuboid; 80 Int m_nPrevFrameBit[3][MAX_TLAYER]; // base + enhancement layer 81 Int m_nPrevFrameCGSBit[3][MAX_TLAYER]; 82 Int m_nPrevFrameCGSPartNumLog2[3][MAX_TLAYER]; 83 Int m_nPrevFrameOverWritePPS[3][MAX_TLAYER]; 80 Int m_nAccuFrameBit; // base + enhancement layer 81 Int m_nAccuFrameCGSBit; 82 Int m_nPrevFrameCGSPartNumLog2; 84 83 Double m_dTotalFrameBit; 85 84 Int m_nTotalCGSBit; 86 85 Int m_nPPSBit; 87 86 Int m_nLUTBitDepth; 87 #if R0151_CGS_3D_ASYMLUT_IMPROVE 88 Double m_dSumU; 89 Double m_dSumV; 90 Int m_nNChroma; 91 #endif 88 92 89 93 private: 94 #if R0151_CGS_3D_ASYMLUT_IMPROVE 95 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 , 96 Pel & rP0 , Pel & rP1 , Pel & rP3 , Pel & rP7 , Int nResQuantBit ); 97 #else 90 98 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 , 91 99 Int y0 , Int u0 , Int v0 , Int nLengthY , Int nLengthUV , 92 100 Pel & rP0 , Pel & rP1 , Pel & rP3 , Pel & rP7 , Int nResQuantBit ); 101 #endif 93 102 Void xxDerivePartNumLog2( TComSlice * pSlice , TEncCfg * pcCfg , Int & rOctantDepth , Int & rYPartNumLog2 , Bool bSignalPPS , Bool bElRapSliceTypeB ); 94 103 Void xxMapPartNum2DepthYPart( Int nPartNumLog2 , Int & rOctantDepth , Int & rYPartNumLog2 ); … … 100 109 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 , 101 110 Double a , Double b , Double c , Double d ); 111 #if R0151_CGS_3D_ASYMLUT_IMPROVE 112 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 , 113 Pel nP0 , Pel nP1 , Pel nP3 , Pel nP7 ); 114 #endif 102 115 }; 103 116 … … 118 131 return( dError ); 119 132 }; 133 134 #if R0151_CGS_3D_ASYMLUT_IMPROVE 135 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 , 136 Pel nP0 , Pel nP1 , Pel nP3 , Pel nP7 ) 137 { 138 const Int nOne = xGetNormCoeffOne(); 139 Double a = 1.0 * nP0 / nOne; 140 Double b = 1.0 * nP1 / nOne; 141 Double c = 1.0 * nP3 / nOne; 142 Double d = nP7; 143 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; 144 return( dError ); 145 }; 120 146 #endif 121 147 122 148 #endif 149 150 #endif -
branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
r824 r825 2762 2762 Void TEncCavlc::xCode3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT ) 2763 2763 { 2764 #if R0150_CGS_SIGNAL_CONSTRAINTS 2765 UInt uiNumRefLayers = ( UInt )pc3DAsymLUT->getRefLayerNum(); 2766 WRITE_UVLC( uiNumRefLayers - 1 , "num_cm_ref_layers_minus1" ); 2767 for( UInt i = 0 ; i < uiNumRefLayers ; i++ ) 2768 { 2769 WRITE_CODE( pc3DAsymLUT->getRefLayerId( i ) , 6 , "cm_ref_layer_id" ); 2770 } 2771 #endif 2764 2772 assert( pc3DAsymLUT->getCurOctantDepth() < 4 ); 2765 2773 WRITE_CODE( pc3DAsymLUT->getCurOctantDepth() , 2 , "cm_octant_depth" ); … … 2767 2775 WRITE_CODE( pc3DAsymLUT->getCurYPartNumLog2() , 2 , "cm_y_part_num_log2" ); 2768 2776 assert( pc3DAsymLUT->getInputBitDepthY() < 16 ); 2777 #if R0150_CGS_SIGNAL_CONSTRAINTS 2778 WRITE_CODE( pc3DAsymLUT->getInputBitDepthY() - 8 , 3 , "cm_input_luma_bit_depth_minus8" ); 2779 WRITE_CODE( pc3DAsymLUT->getInputBitDepthC() - 8 , 3 , "cm_input_chroma_bit_depth_minus8" ); 2780 WRITE_CODE( pc3DAsymLUT->getOutputBitDepthY() - 8 , 3 , "cm_output_luma_bit_depth_minus8" ); 2781 WRITE_CODE( pc3DAsymLUT->getOutputBitDepthC() - 8 , 3 , "cm_output_chroma_bit_depth_minus8" ); 2782 #else 2769 2783 WRITE_CODE( pc3DAsymLUT->getInputBitDepthY() - 8 , 3 , "cm_input_bit_depth_minus8" ); 2770 2784 WRITE_SVLC(pc3DAsymLUT->getInputBitDepthC()-pc3DAsymLUT->getInputBitDepthY(), "cm_input_bit_depth_chroma delta"); … … 2772 2786 WRITE_CODE( pc3DAsymLUT->getOutputBitDepthY() - 8 , 3 , "cm_output_bit_depth_minus8" ); 2773 2787 WRITE_SVLC(pc3DAsymLUT->getOutputBitDepthC()-pc3DAsymLUT->getOutputBitDepthY(), "cm_output_bit_depth_chroma_delta"); 2788 #endif 2774 2789 assert( pc3DAsymLUT->getResQuantBit() < 4 ); 2775 2790 WRITE_CODE( pc3DAsymLUT->getResQuantBit() , 2 , "cm_res_quant_bit" ); 2776 2791 #if R0151_CGS_3D_ASYMLUT_IMPROVE 2792 if( pc3DAsymLUT->getCurOctantDepth() == 1 ) 2793 { 2794 WRITE_SVLC( pc3DAsymLUT->getAdaptChromaThresholdU() - ( 1 << ( pc3DAsymLUT->getInputBitDepthC() - 1 ) ) , "cm_adapt_threshold_u_delta" ); 2795 WRITE_SVLC( pc3DAsymLUT->getAdaptChromaThresholdV() - ( 1 << ( pc3DAsymLUT->getInputBitDepthC() - 1 ) ) , "cm_adapt_threshold_v_delta" ); 2796 } 2797 #endif 2798 2799 #if R0164_CGS_LUT_BUGFIX 2800 pc3DAsymLUT->xInitCuboids(); 2801 #endif 2777 2802 xCode3DAsymLUTOctant( pc3DAsymLUT , 0 , 0 , 0 , 0 , 1 << pc3DAsymLUT->getCurOctantDepth() ); 2803 #if R0164_CGS_LUT_BUGFIX 2804 pc3DAsymLUT->xCuboidsExplicitCheck( false ); 2805 #endif 2778 2806 } 2779 2807 … … 2802 2830 for( Int l = 0 ; l < nYPartNum ; l++ ) 2803 2831 { 2832 #if R0164_CGS_LUT_BUGFIX 2833 Int shift = pc3DAsymLUT->getMaxOctantDepth() - nDepth ; 2834 #endif 2804 2835 for( Int nVertexIdx = 0 ; nVertexIdx < 4 ; nVertexIdx++ ) 2805 2836 { 2837 #if R0164_CGS_LUT_BUGFIX 2838 SYUVP sRes = pc3DAsymLUT->getCuboidVertexResTree( yIdx + (l<<shift) , uIdx , vIdx , nVertexIdx ); 2839 #else 2806 2840 SYUVP sRes = pc3DAsymLUT->getCuboidVertexResTree( yIdx + l , uIdx , vIdx , nVertexIdx ); 2841 #endif 2807 2842 UInt uiCodeVertex = sRes.Y != 0 || sRes.U != 0 || sRes.V != 0; 2808 2843 WRITE_FLAG( uiCodeVertex , "coded_vertex_flag" ); 2809 2844 if( uiCodeVertex ) 2810 2845 { 2846 #if R0151_CGS_3D_ASYMLUT_IMPROVE 2847 xWriteParam( sRes.Y ); 2848 xWriteParam( sRes.U ); 2849 xWriteParam( sRes.V ); 2850 #else 2811 2851 WRITE_SVLC( sRes.Y , "resY" ); 2812 2852 WRITE_SVLC( sRes.U , "resU" ); 2813 2853 WRITE_SVLC( sRes.V , "resV" ); 2814 } 2815 } 2816 } 2817 } 2818 } 2854 #endif 2855 } 2856 } 2857 #if R0164_CGS_LUT_BUGFIX 2858 pc3DAsymLUT->xSetExplicit( yIdx + (l<<shift) , uIdx , vIdx ); 2859 #endif 2860 } 2861 } 2862 } 2863 2864 #if R0151_CGS_3D_ASYMLUT_IMPROVE 2865 Void TEncCavlc::xWriteParam( Int param) 2866 { 2867 const UInt rParam = 7; 2868 Int codeNumber = abs(param); 2869 WRITE_UVLC(codeNumber / (1 << rParam), "quotient"); 2870 WRITE_CODE((codeNumber % (1 << rParam)), rParam, "remainder"); 2871 if (abs(param)) 2872 WRITE_FLAG( param <0, "sign"); 2873 } 2874 #endif 2875 2819 2876 #endif 2820 2877 //! \} -
branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.h
r815 r825 173 173 Void xCode3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT ); 174 174 Void xCode3DAsymLUTOctant( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength ); 175 #if R0151_CGS_3D_ASYMLUT_IMPROVE 176 Void xWriteParam( Int param); 177 #endif 175 178 #endif 176 179 #endif //SVC_EXTENSION -
branches/SHM-dev/source/Lib/TLibEncoder/TEncCfg.h
r823 r825 367 367 Int m_nCGSMaxYPartNumLog2; 368 368 Int m_nCGSLUTBit; 369 #if R0151_CGS_3D_ASYMLUT_IMPROVE 370 Int m_nCGSAdaptiveChroma; 371 #endif 369 372 #endif 370 373 #if P0050_KNEE_FUNCTION_SEI … … 940 943 Void setCGSLUTBit(Int n) { m_nCGSLUTBit = n; } 941 944 Int getCGSLUTBit() { return m_nCGSLUTBit; } 945 #if R0151_CGS_3D_ASYMLUT_IMPROVE 946 Void setCGSAdaptChroma(Int n) { m_nCGSAdaptiveChroma = n; } 947 Int getCGSAdaptChroma() { return m_nCGSAdaptiveChroma; } 948 #endif 942 949 #endif 943 950 #endif -
branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp
r823 r825 1153 1153 if( pcSlice->getPPS()->getCGSFlag() ) 1154 1154 { 1155 #if R0150_CGS_SIGNAL_CONSTRAINTS 1156 // all reference layers are currently taken as CGS reference layers 1157 m_Enc3DAsymLUTPPS.addRefLayerId( pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc) ); 1158 m_Enc3DAsymLUTPicUpdate.addRefLayerId( pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc) ); 1159 #endif 1155 1160 if(g_posScalingFactor[refLayerIdc][0] < (1<<16) || g_posScalingFactor[refLayerIdc][1] < (1<<16)) //if(pcPic->isSpatialEnhLayer(refLayerIdc)) 1156 1161 { … … 3987 3992 if( m_layerId && pcSlice->getPPS()->getCGSFlag() ) 3988 3993 { 3994 if( m_Enc3DAsymLUTPPS.getPPSBit() > 0 ) 3995 m_Enc3DAsymLUTPicUpdate.copy3DAsymLUT( &m_Enc3DAsymLUTPPS ); 3989 3996 m_Enc3DAsymLUTPicUpdate.updatePicCGSBits( pcSlice , m_Enc3DAsymLUTPPS.getPPSBit() ); 3990 3997 }
Note: See TracChangeset for help on using the changeset viewer.