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