[677] | 1 | #include <cstdio> |
---|
| 2 | #include <cstdlib> |
---|
| 3 | #include <cstring> |
---|
| 4 | #include <cmath> |
---|
| 5 | #include <algorithm> |
---|
| 6 | |
---|
| 7 | #include "TypeDef.h" |
---|
| 8 | #include "TCom3DAsymLUT.h" |
---|
| 9 | #include "TComPicYuv.h" |
---|
| 10 | |
---|
| 11 | #if Q0048_CGS_3D_ASYMLUT |
---|
| 12 | |
---|
| 13 | const Int TCom3DAsymLUT::m_nVertexIdxOffset[4][3] = { { 0 , 0 , 0 } , { 0 , 1 , 0 } , { 0 , 1 , 1 } , { 1 , 1 , 1 } }; |
---|
| 14 | |
---|
| 15 | TCom3DAsymLUT::TCom3DAsymLUT() |
---|
| 16 | { |
---|
| 17 | m_pCuboid = NULL; |
---|
| 18 | m_nResQuanBit = 0; |
---|
[825] | 19 | #if R0164_CGS_LUT_BUGFIX |
---|
| 20 | m_pCuboidExplicit = NULL; |
---|
| 21 | #endif |
---|
[677] | 22 | } |
---|
| 23 | |
---|
| 24 | TCom3DAsymLUT::~TCom3DAsymLUT() |
---|
| 25 | { |
---|
| 26 | destroy(); |
---|
| 27 | } |
---|
| 28 | |
---|
[825] | 29 | Void TCom3DAsymLUT::create( Int nMaxOctantDepth , Int nInputBitDepth , Int nInputBitDepthC , Int nOutputBitDepth , Int nOutputBitDepthC , Int nMaxYPartNumLog2 |
---|
| 30 | #if R0151_CGS_3D_ASYMLUT_IMPROVE |
---|
| 31 | , Int nAdaptCThresholdU , Int nAdaptCThresholdV |
---|
| 32 | #endif |
---|
| 33 | ) |
---|
[677] | 34 | { |
---|
| 35 | m_nMaxOctantDepth = nMaxOctantDepth; |
---|
| 36 | m_nInputBitDepthY = nInputBitDepth; |
---|
| 37 | m_nOutputBitDepthY = nOutputBitDepth; |
---|
| 38 | m_nInputBitDepthC = nInputBitDepthC; |
---|
| 39 | m_nOutputBitDepthC = nOutputBitDepthC; |
---|
| 40 | m_nDeltaBitDepthC = m_nOutputBitDepthC - m_nInputBitDepthC; |
---|
| 41 | m_nDeltaBitDepth = m_nOutputBitDepthY - m_nInputBitDepthY; |
---|
| 42 | m_nMaxYPartNumLog2 = nMaxYPartNumLog2; |
---|
| 43 | m_nMaxPartNumLog2 = 3 * m_nMaxOctantDepth + m_nMaxYPartNumLog2; |
---|
| 44 | |
---|
[825] | 45 | xUpdatePartitioning( nMaxOctantDepth , nMaxYPartNumLog2 |
---|
| 46 | #if R0151_CGS_3D_ASYMLUT_IMPROVE |
---|
| 47 | , nAdaptCThresholdU , nAdaptCThresholdV |
---|
| 48 | #endif |
---|
| 49 | ); |
---|
[677] | 50 | |
---|
| 51 | m_nYSize = 1 << ( m_nMaxOctantDepth + m_nMaxYPartNumLog2 ); |
---|
| 52 | m_nUSize = 1 << m_nMaxOctantDepth; |
---|
| 53 | m_nVSize = 1 << m_nMaxOctantDepth; |
---|
| 54 | assert( m_nYSize > 0 && m_nUSize > 0 && m_nVSize > 0 ); |
---|
| 55 | |
---|
| 56 | if( m_pCuboid != NULL ) |
---|
[815] | 57 | { |
---|
[677] | 58 | destroy(); |
---|
[815] | 59 | } |
---|
[677] | 60 | xAllocate3DArray( m_pCuboid , m_nYSize , m_nUSize , m_nVSize ); |
---|
[825] | 61 | |
---|
| 62 | #if R0164_CGS_LUT_BUGFIX |
---|
| 63 | xAllocate3DArray( m_pCuboidExplicit , m_nYSize , m_nUSize , m_nVSize ); |
---|
| 64 | #endif |
---|
[677] | 65 | } |
---|
| 66 | |
---|
| 67 | Void TCom3DAsymLUT::destroy() |
---|
| 68 | { |
---|
| 69 | xFree3DArray( m_pCuboid ); |
---|
[825] | 70 | #if R0164_CGS_LUT_BUGFIX |
---|
| 71 | xFree3DArray( m_pCuboidExplicit ); |
---|
| 72 | #endif |
---|
[677] | 73 | } |
---|
| 74 | |
---|
[825] | 75 | Void TCom3DAsymLUT::xUpdatePartitioning( Int nCurOctantDepth , Int nCurYPartNumLog2 |
---|
| 76 | #if R0151_CGS_3D_ASYMLUT_IMPROVE |
---|
| 77 | , Int nAdaptCThresholdU , Int nAdaptCThresholdV |
---|
| 78 | #endif |
---|
| 79 | ) |
---|
[677] | 80 | { |
---|
| 81 | assert( nCurOctantDepth <= m_nMaxOctantDepth ); |
---|
[826] | 82 | #if R0179_CGS_SIZE_8x1x1 |
---|
| 83 | assert( nCurYPartNumLog2 + nCurOctantDepth <= m_nMaxYPartNumLog2 + m_nMaxOctantDepth ); |
---|
| 84 | #else |
---|
[677] | 85 | assert( nCurYPartNumLog2 <= m_nMaxYPartNumLog2 ); |
---|
[826] | 86 | #endif |
---|
[677] | 87 | |
---|
| 88 | m_nCurOctantDepth = nCurOctantDepth; |
---|
| 89 | m_nCurYPartNumLog2 = nCurYPartNumLog2; |
---|
| 90 | m_nYShift2Idx = m_nInputBitDepthY - m_nCurOctantDepth - m_nCurYPartNumLog2; |
---|
| 91 | m_nUShift2Idx = m_nVShift2Idx = m_nInputBitDepthC - m_nCurOctantDepth; |
---|
[825] | 92 | #if R0151_CGS_3D_ASYMLUT_IMPROVE |
---|
| 93 | m_nMappingShift = 10 + m_nInputBitDepthY - m_nOutputBitDepthY; |
---|
| 94 | m_nAdaptCThresholdU = nAdaptCThresholdU; |
---|
| 95 | m_nAdaptCThresholdV = nAdaptCThresholdV; |
---|
| 96 | #else |
---|
[677] | 97 | m_nMappingShift = m_nYShift2Idx + m_nUShift2Idx; |
---|
[825] | 98 | #endif |
---|
[677] | 99 | m_nMappingOffset = 1 << ( m_nMappingShift - 1 ); |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | Void TCom3DAsymLUT::colorMapping( TComPicYuv * pcPic, TComPicYuv * pcPicDst ) |
---|
| 103 | { |
---|
| 104 | Int nWidth = pcPic->getWidth(); |
---|
| 105 | Int nHeight = pcPic->getHeight(); |
---|
| 106 | Int nStrideY = pcPic->getStride(); |
---|
| 107 | Int nStrideC = pcPic->getCStride(); |
---|
| 108 | Pel * pY = pcPic->getLumaAddr(); |
---|
| 109 | Pel * pU = pcPic->getCbAddr(); |
---|
| 110 | Pel * pV = pcPic->getCrAddr(); |
---|
| 111 | |
---|
| 112 | Int nDstStrideY = pcPicDst->getStride(); |
---|
| 113 | Int nDstStrideC = pcPicDst->getCStride(); |
---|
| 114 | Pel * pYDst = pcPicDst->getLumaAddr(); |
---|
| 115 | Pel * pUDst = pcPicDst->getCbAddr(); |
---|
| 116 | Pel * pVDst = pcPicDst->getCrAddr(); |
---|
| 117 | |
---|
| 118 | Pel *pUPrev = pU; |
---|
| 119 | Pel *pVPrev = pV; |
---|
| 120 | Pel *pUNext = pU+nStrideC; |
---|
| 121 | Pel *pVNext = pV+nStrideC; |
---|
| 122 | |
---|
| 123 | // alignment padding |
---|
[815] | 124 | pcPic->setBorderExtension( false ); |
---|
| 125 | pcPic->extendPicBorder(); |
---|
[677] | 126 | |
---|
| 127 | Pel iMaxValY = (1<<getOutputBitDepthY())-1; |
---|
| 128 | Pel iMaxValC = (1<<getOutputBitDepthC())-1; |
---|
| 129 | for( Int y = 0 ; y < nHeight ; y += 2 ) |
---|
| 130 | { |
---|
| 131 | for( Int xY = 0 , xC = 0 ; xY < nWidth ; xY += 2 , xC++ ) |
---|
| 132 | { |
---|
| 133 | Pel srcY00 = pY[xY]; |
---|
| 134 | Pel srcY01 = pY[xY+1]; |
---|
| 135 | Pel srcY10 = pY[xY+nStrideY]; |
---|
| 136 | Pel srcY11 = pY[xY+nStrideY+1]; |
---|
| 137 | Pel srcYaver; |
---|
| 138 | Pel srcU = pU[xC]; |
---|
| 139 | Pel srcV = pV[xC]; |
---|
| 140 | Pel dstY00, dstY01, dstY10, dstY11; |
---|
| 141 | |
---|
| 142 | // alignment |
---|
| 143 | srcYaver = (srcY00 + srcY10 + 1 ) >> 1; |
---|
| 144 | Pel srcUP0 = pUPrev[xC]; |
---|
| 145 | Pel srcVP0 = pVPrev[xC]; |
---|
| 146 | Pel tmpU = (srcUP0 + srcU + (srcU<<1) + 2 ) >> 2; |
---|
| 147 | Pel tmpV = (srcVP0 + srcV + (srcV<<1) + 2 ) >> 2; |
---|
| 148 | dstY00 = xMapY( srcY00 , tmpU , tmpV ); |
---|
| 149 | Pel a = pU[xC+1] + srcU; |
---|
| 150 | tmpU = ((a<<1) + a + srcUP0 + pUPrev[xC+1] + 4 ) >> 3; |
---|
| 151 | Pel b = pV[xC+1] + srcV; |
---|
| 152 | tmpV = ((b<<1) + b + srcVP0 + pVPrev[xC+1] + 4 ) >> 3; |
---|
| 153 | dstY01 = xMapY( srcY01 , tmpU , tmpV ); |
---|
| 154 | |
---|
| 155 | srcUP0 = pUNext[xC]; |
---|
| 156 | srcVP0 = pVNext[xC]; |
---|
| 157 | tmpU = (srcUP0 + srcU + (srcU<<1) + 2 ) >> 2; |
---|
| 158 | tmpV = (srcVP0 + srcV + (srcV<<1) + 2 ) >> 2; |
---|
| 159 | dstY10 = xMapY( srcY10 , tmpU , tmpV ); |
---|
| 160 | tmpU = ((a<<1) + a + srcUP0 + pUNext[xC+1] + 4 ) >> 3; |
---|
| 161 | tmpV = ((b<<1) + b + srcVP0 + pVNext[xC+1] + 4 ) >> 3; |
---|
| 162 | dstY11 = xMapY( srcY11 , tmpU , tmpV ); |
---|
| 163 | |
---|
| 164 | SYUVP dstUV = xMapUV( srcYaver , srcU , srcV ); |
---|
| 165 | pYDst[xY] = Clip3((Pel)0, iMaxValY, dstY00 ); |
---|
| 166 | pYDst[xY+1] = Clip3((Pel)0, iMaxValY, dstY01 ); |
---|
| 167 | pYDst[xY+nDstStrideY] = Clip3((Pel)0, iMaxValY, dstY10 ); |
---|
| 168 | pYDst[xY+nDstStrideY+1] = Clip3((Pel)0, iMaxValY, dstY11 ); |
---|
| 169 | pUDst[xC] = Clip3((Pel)0, iMaxValC, dstUV.U ); |
---|
| 170 | pVDst[xC] = Clip3((Pel)0, iMaxValC, dstUV.V ); |
---|
| 171 | } |
---|
| 172 | pY += nStrideY + nStrideY; |
---|
| 173 | |
---|
| 174 | // alignment |
---|
| 175 | pUPrev = pU; |
---|
| 176 | pVPrev = pV; |
---|
| 177 | pU = pUNext; |
---|
| 178 | pV = pVNext; |
---|
| 179 | pUNext += nStrideC; |
---|
| 180 | pVNext += nStrideC; |
---|
| 181 | |
---|
| 182 | pYDst += nDstStrideY + nDstStrideY; |
---|
| 183 | pUDst += nDstStrideC; |
---|
| 184 | pVDst += nDstStrideC; |
---|
| 185 | } |
---|
| 186 | } |
---|
| 187 | |
---|
| 188 | SYUVP TCom3DAsymLUT::xGetCuboidVertexPredA( Int yIdx , Int uIdx , Int vIdx , Int nVertexIdx ) |
---|
| 189 | { |
---|
| 190 | assert( nVertexIdx < 4 ); |
---|
| 191 | |
---|
| 192 | SYUVP sPred; |
---|
[825] | 193 | #if R0151_CGS_3D_ASYMLUT_IMPROVE |
---|
| 194 | sPred.Y = sPred.U = sPred.V = 0; |
---|
| 195 | if( nVertexIdx == 0 ) |
---|
| 196 | sPred.Y = xGetNormCoeffOne() << ( m_nOutputBitDepthY - m_nInputBitDepthY ); |
---|
| 197 | else if( nVertexIdx == 1 ) |
---|
| 198 | sPred.U = xGetNormCoeffOne() << ( m_nOutputBitDepthY - m_nInputBitDepthY ); |
---|
| 199 | else if( nVertexIdx == 2 ) |
---|
| 200 | sPred.V = xGetNormCoeffOne() << ( m_nOutputBitDepthY - m_nInputBitDepthY ); |
---|
| 201 | #else |
---|
[677] | 202 | sPred.Y = ( yIdx + m_nVertexIdxOffset[nVertexIdx][0] ) << ( m_nYShift2Idx + m_nDeltaBitDepth ); |
---|
| 203 | sPred.U = ( uIdx + m_nVertexIdxOffset[nVertexIdx][1] ) << ( m_nUShift2Idx + m_nDeltaBitDepthC ); |
---|
| 204 | sPred.V = ( vIdx + m_nVertexIdxOffset[nVertexIdx][2] ) << ( m_nVShift2Idx + m_nDeltaBitDepthC ); |
---|
[825] | 205 | #endif |
---|
[677] | 206 | return( sPred ); |
---|
| 207 | } |
---|
| 208 | |
---|
| 209 | SYUVP TCom3DAsymLUT::xGetCuboidVertexPredAll( Int yIdx , Int uIdx , Int vIdx , Int nVertexIdx , SCuboid *** pCurCuboid ) |
---|
| 210 | { |
---|
| 211 | SCuboid*** pCuboid = pCurCuboid ? pCurCuboid : m_pCuboid ; |
---|
| 212 | |
---|
[825] | 213 | #if R0151_CGS_3D_ASYMLUT_IMPROVE |
---|
| 214 | SYUVP sPred; |
---|
| 215 | if( yIdx == 0 ) |
---|
| 216 | { |
---|
| 217 | sPred.Y = nVertexIdx == 0 ? 1024 : 0; |
---|
| 218 | sPred.U = nVertexIdx == 1 ? 1024 : 0; |
---|
| 219 | sPred.V = nVertexIdx == 2 ? 1024 : 0; |
---|
| 220 | } |
---|
| 221 | else |
---|
| 222 | { |
---|
| 223 | sPred = pCuboid[yIdx-1][uIdx][vIdx].P[nVertexIdx]; |
---|
| 224 | } |
---|
| 225 | #else |
---|
[677] | 226 | // PredA |
---|
| 227 | SYUVP sPredA = xGetCuboidVertexPredA( yIdx , uIdx , vIdx , nVertexIdx ); |
---|
| 228 | |
---|
| 229 | // PredB |
---|
| 230 | SYUVP sPredB; |
---|
| 231 | memset( &sPredB , 0 , sizeof( sPredB ) ); |
---|
| 232 | if( yIdx > 0 ) |
---|
| 233 | { |
---|
| 234 | SYUVP & recNeighborP = pCuboid[yIdx-1][uIdx][vIdx].P[nVertexIdx]; |
---|
| 235 | SYUVP sPredNeighbor = xGetCuboidVertexPredA( yIdx - 1 , uIdx , vIdx , nVertexIdx ); |
---|
| 236 | sPredB.Y += recNeighborP.Y - sPredNeighbor.Y ; |
---|
| 237 | sPredB.U += recNeighborP.U - sPredNeighbor.U ; |
---|
| 238 | sPredB.V += recNeighborP.V - sPredNeighbor.V ; |
---|
| 239 | |
---|
| 240 | Pel min = - ( 1 << ( getOutputBitDepthY() - 2 ) ); |
---|
[678] | 241 | Pel max = - min; |
---|
[677] | 242 | sPredB.Y = Clip3( min , max , sPredB.Y ); |
---|
| 243 | min = - ( 1 << ( getOutputBitDepthC() - 2 ) ); |
---|
[678] | 244 | max = - min; |
---|
[677] | 245 | sPredB.U = Clip3( min , max , sPredB.U ); |
---|
| 246 | sPredB.V = Clip3( min , max , sPredB.V ); |
---|
| 247 | } |
---|
| 248 | |
---|
| 249 | SYUVP sPred; |
---|
| 250 | sPred.Y = sPredA.Y + sPredB.Y; |
---|
| 251 | sPred.U = sPredA.U + sPredB.U; |
---|
| 252 | sPred.V = sPredA.V + sPredB.V; |
---|
[825] | 253 | #endif |
---|
[677] | 254 | return sPred ; |
---|
| 255 | } |
---|
| 256 | |
---|
| 257 | SYUVP TCom3DAsymLUT::getCuboidVertexResTree( Int yIdx , Int uIdx , Int vIdx , Int nVertexIdx ) |
---|
| 258 | { |
---|
| 259 | const SYUVP & rYUVP = m_pCuboid[yIdx][uIdx][vIdx].P[nVertexIdx]; |
---|
| 260 | SYUVP sPred = xGetCuboidVertexPredAll( yIdx , uIdx , vIdx , nVertexIdx ); |
---|
| 261 | |
---|
| 262 | SYUVP sResidue; |
---|
| 263 | sResidue.Y = ( rYUVP.Y - sPred.Y ) >> m_nResQuanBit; |
---|
| 264 | sResidue.U = ( rYUVP.U - sPred.U ) >> m_nResQuanBit; |
---|
| 265 | sResidue.V = ( rYUVP.V - sPred.V ) >> m_nResQuanBit; |
---|
| 266 | return( sResidue ); |
---|
| 267 | } |
---|
| 268 | |
---|
| 269 | Void TCom3DAsymLUT::setCuboidVertexResTree( Int yIdx , Int uIdx , Int vIdx , Int nVertexIdx , Int deltaY , Int deltaU , Int deltaV ) |
---|
| 270 | { |
---|
| 271 | SYUVP & rYUVP = m_pCuboid[yIdx][uIdx][vIdx].P[nVertexIdx]; |
---|
| 272 | SYUVP sPred = xGetCuboidVertexPredAll( yIdx , uIdx , vIdx , nVertexIdx ); |
---|
| 273 | |
---|
| 274 | rYUVP.Y = sPred.Y + ( deltaY << m_nResQuanBit ); |
---|
| 275 | rYUVP.U = sPred.U + ( deltaU << m_nResQuanBit ); |
---|
| 276 | rYUVP.V = sPred.V + ( deltaV << m_nResQuanBit ); |
---|
[825] | 277 | #if R0150_CGS_SIGNAL_CONSTRAINTS |
---|
| 278 | // LUT coefficients are less than 12-bit |
---|
| 279 | assert( -2048 <= rYUVP.Y && rYUVP.Y <= 2047 ); |
---|
| 280 | assert( -2048 <= rYUVP.U && rYUVP.U <= 2047 ); |
---|
| 281 | assert( -2048 <= rYUVP.V && rYUVP.V <= 2047 ); |
---|
| 282 | #endif |
---|
[677] | 283 | } |
---|
| 284 | |
---|
| 285 | Pel TCom3DAsymLUT::xMapY( Pel y , Pel u , Pel v ) |
---|
| 286 | { |
---|
[825] | 287 | #if R0151_CGS_3D_ASYMLUT_IMPROVE |
---|
| 288 | const SCuboid & rCuboid = m_pCuboid[xGetYIdx(y)][xGetUIdx(u)][xGetVIdx(v)]; |
---|
| 289 | Pel dstY = ( ( rCuboid.P[0].Y * y + rCuboid.P[1].Y * u + rCuboid.P[2].Y * v + m_nMappingOffset ) >> m_nMappingShift ) + rCuboid.P[3].Y; |
---|
| 290 | #else |
---|
[677] | 291 | const SCuboid & rCuboid = m_pCuboid[y>>m_nYShift2Idx][u>>m_nUShift2Idx][v>>m_nVShift2Idx]; |
---|
| 292 | Pel dstY = rCuboid.P[0].Y; |
---|
| 293 | Int deltaY = y - ( y >> m_nYShift2Idx << m_nYShift2Idx ); |
---|
| 294 | Int deltaU = u - ( u >> m_nUShift2Idx << m_nUShift2Idx ); |
---|
| 295 | Int deltaV = v - ( v >> m_nVShift2Idx << m_nVShift2Idx ); |
---|
| 296 | dstY += ( Pel )( ( ( ( deltaY * ( rCuboid.P[3].Y - rCuboid.P[2].Y ) ) << m_nUShift2Idx ) |
---|
| 297 | + ( ( deltaU * ( rCuboid.P[1].Y - rCuboid.P[0].Y ) ) << m_nYShift2Idx ) |
---|
| 298 | + ( ( deltaV * ( rCuboid.P[2].Y - rCuboid.P[1].Y ) ) << m_nYShift2Idx ) |
---|
| 299 | + m_nMappingOffset ) >> m_nMappingShift ); |
---|
[825] | 300 | #endif |
---|
[677] | 301 | return( dstY ); |
---|
| 302 | } |
---|
| 303 | |
---|
| 304 | SYUVP TCom3DAsymLUT::xMapUV( Pel y , Pel u , Pel v ) |
---|
| 305 | { |
---|
[825] | 306 | #if R0151_CGS_3D_ASYMLUT_IMPROVE |
---|
| 307 | const SCuboid & rCuboid = m_pCuboid[xGetYIdx(y)][xGetUIdx(u)][xGetVIdx(v)]; |
---|
| 308 | SYUVP dst; |
---|
| 309 | dst.Y = 0; |
---|
| 310 | dst.U = ( ( rCuboid.P[0].U * y + rCuboid.P[1].U * u + rCuboid.P[2].U * v + m_nMappingOffset ) >> m_nMappingShift ) + rCuboid.P[3].U; |
---|
| 311 | dst.V = ( ( rCuboid.P[0].V * y + rCuboid.P[1].V * u + rCuboid.P[2].V * v + m_nMappingOffset ) >> m_nMappingShift ) + rCuboid.P[3].V; |
---|
| 312 | #else |
---|
[677] | 313 | const SCuboid & rCuboid = m_pCuboid[y>>m_nYShift2Idx][u>>m_nUShift2Idx][v>>m_nVShift2Idx]; |
---|
| 314 | SYUVP dst = rCuboid.P[0]; |
---|
| 315 | Int deltaY = y - ( y >> m_nYShift2Idx << m_nYShift2Idx ); |
---|
| 316 | Int deltaU = u - ( u >> m_nUShift2Idx << m_nUShift2Idx ); |
---|
| 317 | Int deltaV = v - ( v >> m_nVShift2Idx << m_nVShift2Idx ); |
---|
| 318 | dst.U += ( Pel )( ( ( ( deltaY * ( rCuboid.P[3].U - rCuboid.P[2].U ) ) << m_nUShift2Idx ) |
---|
| 319 | + ( ( deltaU * ( rCuboid.P[1].U - rCuboid.P[0].U ) ) << m_nYShift2Idx ) |
---|
| 320 | + ( ( deltaV * ( rCuboid.P[2].U - rCuboid.P[1].U ) ) << m_nYShift2Idx ) |
---|
| 321 | + m_nMappingOffset ) >> m_nMappingShift ); |
---|
| 322 | dst.V += ( Pel )( ( ( ( deltaY * ( rCuboid.P[3].V - rCuboid.P[2].V ) ) << m_nUShift2Idx ) |
---|
| 323 | + ( ( deltaU * ( rCuboid.P[1].V - rCuboid.P[0].V ) ) << m_nYShift2Idx ) |
---|
| 324 | + ( ( deltaV * ( rCuboid.P[2].V - rCuboid.P[1].V ) ) << m_nYShift2Idx ) |
---|
| 325 | + m_nMappingOffset ) >> m_nMappingShift ); |
---|
[825] | 326 | #endif |
---|
[677] | 327 | return( dst ); |
---|
| 328 | } |
---|
| 329 | |
---|
| 330 | Void TCom3DAsymLUT::xSaveCuboids( SCuboid *** pSrcCuboid ) |
---|
| 331 | { |
---|
| 332 | memcpy( m_pCuboid[0][0] , pSrcCuboid[0][0] , sizeof( SCuboid ) * m_nYSize * m_nUSize * m_nVSize ); |
---|
| 333 | } |
---|
| 334 | |
---|
| 335 | Void TCom3DAsymLUT::copy3DAsymLUT( TCom3DAsymLUT * pSrc ) |
---|
| 336 | { |
---|
| 337 | assert( pSrc->getMaxOctantDepth() == getMaxOctantDepth() && pSrc->getMaxYPartNumLog2() == getMaxYPartNumLog2() ); |
---|
[825] | 338 | xUpdatePartitioning( pSrc->getCurOctantDepth() , pSrc->getCurYPartNumLog2() |
---|
| 339 | #if R0151_CGS_3D_ASYMLUT_IMPROVE |
---|
| 340 | , pSrc->getAdaptChromaThresholdU() , pSrc->getAdaptChromaThresholdV() |
---|
| 341 | #endif |
---|
| 342 | ); |
---|
[677] | 343 | setResQuantBit( pSrc->getResQuantBit() ); |
---|
| 344 | xSaveCuboids( pSrc->m_pCuboid ); |
---|
| 345 | } |
---|
| 346 | |
---|
[825] | 347 | #if R0164_CGS_LUT_BUGFIX |
---|
| 348 | Void TCom3DAsymLUT::xInitCuboids( ) |
---|
| 349 | { |
---|
| 350 | // All vertices are initialized as non-exlicitly-encoded |
---|
| 351 | for( Int yIdx = 0 ; yIdx < m_nYSize ; yIdx++ ) |
---|
| 352 | { |
---|
| 353 | for( Int uIdx = 0 ; uIdx < m_nUSize ; uIdx++ ) |
---|
| 354 | { |
---|
| 355 | for( Int vIdx = 0 ; vIdx < m_nVSize ; vIdx++ ) |
---|
| 356 | { |
---|
| 357 | m_pCuboidExplicit[yIdx][uIdx][vIdx] = false; |
---|
| 358 | } |
---|
| 359 | } |
---|
| 360 | } |
---|
| 361 | } |
---|
| 362 | |
---|
| 363 | Void TCom3DAsymLUT::xCuboidsExplicitCheck( Int yIdx , Int uIdx , Int vIdx ) |
---|
| 364 | { |
---|
| 365 | if ( m_pCuboidExplicit[yIdx][uIdx][vIdx] == false ) |
---|
| 366 | { |
---|
| 367 | if( yIdx > 0) |
---|
| 368 | assert ( m_pCuboidExplicit[yIdx-1][uIdx][vIdx] ); |
---|
| 369 | |
---|
| 370 | for ( Int nVertexIdx=0 ; nVertexIdx<4 ; nVertexIdx++ ) |
---|
| 371 | m_pCuboid[yIdx][uIdx][vIdx].P[nVertexIdx] = yIdx == 0 ? xGetCuboidVertexPredA( yIdx , uIdx , vIdx , nVertexIdx ): xGetCuboidVertexPredAll( yIdx , uIdx , vIdx , nVertexIdx ); |
---|
| 372 | |
---|
| 373 | m_pCuboidExplicit[yIdx][uIdx][vIdx] = true ; |
---|
| 374 | } |
---|
| 375 | } |
---|
| 376 | |
---|
| 377 | |
---|
| 378 | Void TCom3DAsymLUT::xCuboidsExplicitCheck( Bool bDecode ) |
---|
| 379 | { |
---|
| 380 | Int ySize = 1 << ( getCurOctantDepth() + getCurYPartNumLog2() ); |
---|
| 381 | Int uSize = 1 << getCurOctantDepth(); |
---|
| 382 | Int vSize = 1 << getCurOctantDepth(); |
---|
| 383 | for( Int yIdx = 0 ; yIdx < ySize ; yIdx++ ) |
---|
| 384 | { |
---|
| 385 | for( Int uIdx = 0 ; uIdx < uSize ; uIdx++ ) |
---|
| 386 | { |
---|
| 387 | for( Int vIdx = 0 ; vIdx < vSize ; vIdx++ ) |
---|
| 388 | { |
---|
| 389 | if ( bDecode ) |
---|
| 390 | xCuboidsExplicitCheck( yIdx , uIdx , vIdx ); |
---|
| 391 | |
---|
| 392 | assert( m_pCuboidExplicit[yIdx][uIdx][vIdx] ); |
---|
| 393 | } |
---|
| 394 | } |
---|
| 395 | } |
---|
| 396 | |
---|
| 397 | } |
---|
[677] | 398 | #endif |
---|
| 399 | |
---|
[825] | 400 | #if R0150_CGS_SIGNAL_CONSTRAINTS |
---|
| 401 | Bool TCom3DAsymLUT::isRefLayer( UInt uiRefLayerId ) |
---|
| 402 | { |
---|
| 403 | Bool bIsRefLayer = false; |
---|
| 404 | for( UInt i = 0 ; i < m_vRefLayerId.size() ; i++ ) |
---|
| 405 | { |
---|
| 406 | if( m_vRefLayerId[i] == uiRefLayerId ) |
---|
| 407 | { |
---|
| 408 | bIsRefLayer = true; |
---|
| 409 | break; |
---|
| 410 | } |
---|
| 411 | } |
---|
| 412 | |
---|
| 413 | return( bIsRefLayer ); |
---|
| 414 | } |
---|
| 415 | #endif |
---|
| 416 | |
---|
| 417 | #endif |
---|
| 418 | |
---|