1 | /* The copyright in this software is being made available under the BSD |
---|
2 | * License, included below. This software may be subject to other third party |
---|
3 | * and contributor rights, including patent rights, and no such rights are |
---|
4 | * granted under this license. |
---|
5 | * |
---|
6 | * Copyright (c) 2010-2013, ITU/ISO/IEC |
---|
7 | * All rights reserved. |
---|
8 | * |
---|
9 | * Redistribution and use in source and binary forms, with or without |
---|
10 | * modification, are permitted provided that the following conditions are met: |
---|
11 | * |
---|
12 | * * Redistributions of source code must retain the above copyright notice, |
---|
13 | * this list of conditions and the following disclaimer. |
---|
14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
15 | * this list of conditions and the following disclaimer in the documentation |
---|
16 | * and/or other materials provided with the distribution. |
---|
17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
18 | * be used to endorse or promote products derived from this software without |
---|
19 | * specific prior written permission. |
---|
20 | * |
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
32 | */ |
---|
33 | |
---|
34 | /** \file TComPrediction.cpp |
---|
35 | \brief prediction class |
---|
36 | */ |
---|
37 | |
---|
38 | #include <memory.h> |
---|
39 | #include "TComPrediction.h" |
---|
40 | |
---|
41 | //! \ingroup TLibCommon |
---|
42 | //! \{ |
---|
43 | |
---|
44 | // ==================================================================================================================== |
---|
45 | // Constructor / destructor / initialize |
---|
46 | // ==================================================================================================================== |
---|
47 | |
---|
48 | TComPrediction::TComPrediction() |
---|
49 | : m_pLumaRecBuffer(0) |
---|
50 | , m_iLumaRecStride(0) |
---|
51 | { |
---|
52 | m_piYuvExt = NULL; |
---|
53 | #if H_3D_VSP |
---|
54 | m_pDepthBlock = (Int*) malloc(MAX_NUM_SPU_W*MAX_NUM_SPU_W*sizeof(Int)); |
---|
55 | if (m_pDepthBlock == NULL) |
---|
56 | printf("ERROR: UKTGHU, No memory allocated.\n"); |
---|
57 | #endif |
---|
58 | } |
---|
59 | |
---|
60 | TComPrediction::~TComPrediction() |
---|
61 | { |
---|
62 | #if H_3D_VSP |
---|
63 | if (m_pDepthBlock != NULL) |
---|
64 | free(m_pDepthBlock); |
---|
65 | m_cYuvDepthOnVsp.destroy(); |
---|
66 | #endif |
---|
67 | |
---|
68 | delete[] m_piYuvExt; |
---|
69 | |
---|
70 | m_acYuvPred[0].destroy(); |
---|
71 | m_acYuvPred[1].destroy(); |
---|
72 | |
---|
73 | m_cYuvPredTemp.destroy(); |
---|
74 | |
---|
75 | #if H_3D_ARP |
---|
76 | m_acYuvPredBase[0].destroy(); |
---|
77 | m_acYuvPredBase[1].destroy(); |
---|
78 | #endif |
---|
79 | if( m_pLumaRecBuffer ) |
---|
80 | { |
---|
81 | delete [] m_pLumaRecBuffer; |
---|
82 | } |
---|
83 | |
---|
84 | Int i, j; |
---|
85 | for (i = 0; i < 4; i++) |
---|
86 | { |
---|
87 | for (j = 0; j < 4; j++) |
---|
88 | { |
---|
89 | m_filteredBlock[i][j].destroy(); |
---|
90 | } |
---|
91 | m_filteredBlockTmp[i].destroy(); |
---|
92 | } |
---|
93 | } |
---|
94 | |
---|
95 | Void TComPrediction::initTempBuff() |
---|
96 | { |
---|
97 | if( m_piYuvExt == NULL ) |
---|
98 | { |
---|
99 | Int extWidth = MAX_CU_SIZE + 16; |
---|
100 | Int extHeight = MAX_CU_SIZE + 1; |
---|
101 | Int i, j; |
---|
102 | for (i = 0; i < 4; i++) |
---|
103 | { |
---|
104 | m_filteredBlockTmp[i].create(extWidth, extHeight + 7); |
---|
105 | for (j = 0; j < 4; j++) |
---|
106 | { |
---|
107 | m_filteredBlock[i][j].create(extWidth, extHeight); |
---|
108 | } |
---|
109 | } |
---|
110 | m_iYuvExtHeight = ((MAX_CU_SIZE + 2) << 4); |
---|
111 | m_iYuvExtStride = ((MAX_CU_SIZE + 8) << 4); |
---|
112 | m_piYuvExt = new Int[ m_iYuvExtStride * m_iYuvExtHeight ]; |
---|
113 | |
---|
114 | // new structure |
---|
115 | m_acYuvPred[0] .create( MAX_CU_SIZE, MAX_CU_SIZE ); |
---|
116 | m_acYuvPred[1] .create( MAX_CU_SIZE, MAX_CU_SIZE ); |
---|
117 | |
---|
118 | m_cYuvPredTemp.create( MAX_CU_SIZE, MAX_CU_SIZE ); |
---|
119 | #if H_3D_ARP |
---|
120 | m_acYuvPredBase[0] .create( g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
121 | m_acYuvPredBase[1] .create( g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
122 | #endif |
---|
123 | #if H_3D_VSP |
---|
124 | m_cYuvDepthOnVsp.create( g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
125 | #endif |
---|
126 | } |
---|
127 | |
---|
128 | if (m_iLumaRecStride != (MAX_CU_SIZE>>1) + 1) |
---|
129 | { |
---|
130 | m_iLumaRecStride = (MAX_CU_SIZE>>1) + 1; |
---|
131 | if (!m_pLumaRecBuffer) |
---|
132 | { |
---|
133 | m_pLumaRecBuffer = new Pel[ m_iLumaRecStride * m_iLumaRecStride ]; |
---|
134 | } |
---|
135 | } |
---|
136 | #if H_3D_IC |
---|
137 | m_uiaShift[0] = 0; |
---|
138 | for( Int i = 1; i < 64; i++ ) |
---|
139 | { |
---|
140 | m_uiaShift[i] = ( (1 << 15) + i/2 ) / i; |
---|
141 | } |
---|
142 | #endif |
---|
143 | } |
---|
144 | |
---|
145 | // ==================================================================================================================== |
---|
146 | // Public member functions |
---|
147 | // ==================================================================================================================== |
---|
148 | |
---|
149 | // Function for calculating DC value of the reference samples used in Intra prediction |
---|
150 | Pel TComPrediction::predIntraGetPredValDC( Int* pSrc, Int iSrcStride, UInt iWidth, UInt iHeight, Bool bAbove, Bool bLeft ) |
---|
151 | { |
---|
152 | assert(iWidth > 0 && iHeight > 0); |
---|
153 | Int iInd, iSum = 0; |
---|
154 | Pel pDcVal; |
---|
155 | |
---|
156 | if (bAbove) |
---|
157 | { |
---|
158 | for (iInd = 0;iInd < iWidth;iInd++) |
---|
159 | { |
---|
160 | iSum += pSrc[iInd-iSrcStride]; |
---|
161 | } |
---|
162 | } |
---|
163 | if (bLeft) |
---|
164 | { |
---|
165 | for (iInd = 0;iInd < iHeight;iInd++) |
---|
166 | { |
---|
167 | iSum += pSrc[iInd*iSrcStride-1]; |
---|
168 | } |
---|
169 | } |
---|
170 | |
---|
171 | if (bAbove && bLeft) |
---|
172 | { |
---|
173 | pDcVal = (iSum + iWidth) / (iWidth + iHeight); |
---|
174 | } |
---|
175 | else if (bAbove) |
---|
176 | { |
---|
177 | pDcVal = (iSum + iWidth/2) / iWidth; |
---|
178 | } |
---|
179 | else if (bLeft) |
---|
180 | { |
---|
181 | pDcVal = (iSum + iHeight/2) / iHeight; |
---|
182 | } |
---|
183 | else |
---|
184 | { |
---|
185 | pDcVal = pSrc[-1]; // Default DC value already calculated and placed in the prediction array if no neighbors are available |
---|
186 | } |
---|
187 | |
---|
188 | return pDcVal; |
---|
189 | } |
---|
190 | |
---|
191 | // Function for deriving the angular Intra predictions |
---|
192 | |
---|
193 | /** Function for deriving the simplified angular intra predictions. |
---|
194 | * \param pSrc pointer to reconstructed sample array |
---|
195 | * \param srcStride the stride of the reconstructed sample array |
---|
196 | * \param rpDst reference to pointer for the prediction sample array |
---|
197 | * \param dstStride the stride of the prediction sample array |
---|
198 | * \param width the width of the block |
---|
199 | * \param height the height of the block |
---|
200 | * \param dirMode the intra prediction mode index |
---|
201 | * \param blkAboveAvailable boolean indication if the block above is available |
---|
202 | * \param blkLeftAvailable boolean indication if the block to the left is available |
---|
203 | * |
---|
204 | * This function derives the prediction samples for the angular mode based on the prediction direction indicated by |
---|
205 | * the prediction mode index. The prediction direction is given by the displacement of the bottom row of the block and |
---|
206 | * the reference row above the block in the case of vertical prediction or displacement of the rightmost column |
---|
207 | * of the block and reference column left from the block in the case of the horizontal prediction. The displacement |
---|
208 | * is signalled at 1/32 pixel accuracy. When projection of the predicted pixel falls inbetween reference samples, |
---|
209 | * the predicted value for the pixel is linearly interpolated from the reference samples. All reference samples are taken |
---|
210 | * from the extended main reference. |
---|
211 | */ |
---|
212 | Void TComPrediction::xPredIntraAng(Int bitDepth, Int* pSrc, Int srcStride, Pel*& rpDst, Int dstStride, UInt width, UInt height, UInt dirMode, Bool blkAboveAvailable, Bool blkLeftAvailable, Bool bFilter ) |
---|
213 | { |
---|
214 | Int k,l; |
---|
215 | Int blkSize = width; |
---|
216 | Pel* pDst = rpDst; |
---|
217 | |
---|
218 | // Map the mode index to main prediction direction and angle |
---|
219 | assert( dirMode > 0 ); //no planar |
---|
220 | Bool modeDC = dirMode < 2; |
---|
221 | Bool modeHor = !modeDC && (dirMode < 18); |
---|
222 | Bool modeVer = !modeDC && !modeHor; |
---|
223 | Int intraPredAngle = modeVer ? (Int)dirMode - VER_IDX : modeHor ? -((Int)dirMode - HOR_IDX) : 0; |
---|
224 | Int absAng = abs(intraPredAngle); |
---|
225 | Int signAng = intraPredAngle < 0 ? -1 : 1; |
---|
226 | |
---|
227 | // Set bitshifts and scale the angle parameter to block size |
---|
228 | Int angTable[9] = {0, 2, 5, 9, 13, 17, 21, 26, 32}; |
---|
229 | Int invAngTable[9] = {0, 4096, 1638, 910, 630, 482, 390, 315, 256}; // (256 * 32) / Angle |
---|
230 | Int invAngle = invAngTable[absAng]; |
---|
231 | absAng = angTable[absAng]; |
---|
232 | intraPredAngle = signAng * absAng; |
---|
233 | |
---|
234 | // Do the DC prediction |
---|
235 | if (modeDC) |
---|
236 | { |
---|
237 | Pel dcval = predIntraGetPredValDC(pSrc, srcStride, width, height, blkAboveAvailable, blkLeftAvailable); |
---|
238 | |
---|
239 | for (k=0;k<blkSize;k++) |
---|
240 | { |
---|
241 | for (l=0;l<blkSize;l++) |
---|
242 | { |
---|
243 | pDst[k*dstStride+l] = dcval; |
---|
244 | } |
---|
245 | } |
---|
246 | } |
---|
247 | |
---|
248 | // Do angular predictions |
---|
249 | else |
---|
250 | { |
---|
251 | Pel* refMain; |
---|
252 | Pel* refSide; |
---|
253 | Pel refAbove[2*MAX_CU_SIZE+1]; |
---|
254 | Pel refLeft[2*MAX_CU_SIZE+1]; |
---|
255 | |
---|
256 | // Initialise the Main and Left reference array. |
---|
257 | if (intraPredAngle < 0) |
---|
258 | { |
---|
259 | for (k=0;k<blkSize+1;k++) |
---|
260 | { |
---|
261 | refAbove[k+blkSize-1] = pSrc[k-srcStride-1]; |
---|
262 | } |
---|
263 | for (k=0;k<blkSize+1;k++) |
---|
264 | { |
---|
265 | refLeft[k+blkSize-1] = pSrc[(k-1)*srcStride-1]; |
---|
266 | } |
---|
267 | refMain = (modeVer ? refAbove : refLeft) + (blkSize-1); |
---|
268 | refSide = (modeVer ? refLeft : refAbove) + (blkSize-1); |
---|
269 | |
---|
270 | // Extend the Main reference to the left. |
---|
271 | Int invAngleSum = 128; // rounding for (shift by 8) |
---|
272 | for (k=-1; k>blkSize*intraPredAngle>>5; k--) |
---|
273 | { |
---|
274 | invAngleSum += invAngle; |
---|
275 | refMain[k] = refSide[invAngleSum>>8]; |
---|
276 | } |
---|
277 | } |
---|
278 | else |
---|
279 | { |
---|
280 | for (k=0;k<2*blkSize+1;k++) |
---|
281 | { |
---|
282 | refAbove[k] = pSrc[k-srcStride-1]; |
---|
283 | } |
---|
284 | for (k=0;k<2*blkSize+1;k++) |
---|
285 | { |
---|
286 | refLeft[k] = pSrc[(k-1)*srcStride-1]; |
---|
287 | } |
---|
288 | refMain = modeVer ? refAbove : refLeft; |
---|
289 | refSide = modeVer ? refLeft : refAbove; |
---|
290 | } |
---|
291 | |
---|
292 | if (intraPredAngle == 0) |
---|
293 | { |
---|
294 | for (k=0;k<blkSize;k++) |
---|
295 | { |
---|
296 | for (l=0;l<blkSize;l++) |
---|
297 | { |
---|
298 | pDst[k*dstStride+l] = refMain[l+1]; |
---|
299 | } |
---|
300 | } |
---|
301 | |
---|
302 | if ( bFilter ) |
---|
303 | { |
---|
304 | for (k=0;k<blkSize;k++) |
---|
305 | { |
---|
306 | pDst[k*dstStride] = Clip3(0, (1<<bitDepth)-1, pDst[k*dstStride] + (( refSide[k+1] - refSide[0] ) >> 1) ); |
---|
307 | } |
---|
308 | } |
---|
309 | } |
---|
310 | else |
---|
311 | { |
---|
312 | Int deltaPos=0; |
---|
313 | Int deltaInt; |
---|
314 | Int deltaFract; |
---|
315 | Int refMainIndex; |
---|
316 | |
---|
317 | for (k=0;k<blkSize;k++) |
---|
318 | { |
---|
319 | deltaPos += intraPredAngle; |
---|
320 | deltaInt = deltaPos >> 5; |
---|
321 | deltaFract = deltaPos & (32 - 1); |
---|
322 | |
---|
323 | if (deltaFract) |
---|
324 | { |
---|
325 | // Do linear filtering |
---|
326 | for (l=0;l<blkSize;l++) |
---|
327 | { |
---|
328 | refMainIndex = l+deltaInt+1; |
---|
329 | pDst[k*dstStride+l] = (Pel) ( ((32-deltaFract)*refMain[refMainIndex]+deltaFract*refMain[refMainIndex+1]+16) >> 5 ); |
---|
330 | } |
---|
331 | } |
---|
332 | else |
---|
333 | { |
---|
334 | // Just copy the integer samples |
---|
335 | for (l=0;l<blkSize;l++) |
---|
336 | { |
---|
337 | pDst[k*dstStride+l] = refMain[l+deltaInt+1]; |
---|
338 | } |
---|
339 | } |
---|
340 | } |
---|
341 | } |
---|
342 | |
---|
343 | // Flip the block if this is the horizontal mode |
---|
344 | if (modeHor) |
---|
345 | { |
---|
346 | Pel tmp; |
---|
347 | for (k=0;k<blkSize-1;k++) |
---|
348 | { |
---|
349 | for (l=k+1;l<blkSize;l++) |
---|
350 | { |
---|
351 | tmp = pDst[k*dstStride+l]; |
---|
352 | pDst[k*dstStride+l] = pDst[l*dstStride+k]; |
---|
353 | pDst[l*dstStride+k] = tmp; |
---|
354 | } |
---|
355 | } |
---|
356 | } |
---|
357 | } |
---|
358 | } |
---|
359 | |
---|
360 | Void TComPrediction::predIntraLumaAng(TComPattern* pcTComPattern, UInt uiDirMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft ) |
---|
361 | { |
---|
362 | Pel *pDst = piPred; |
---|
363 | Int *ptrSrc; |
---|
364 | |
---|
365 | assert( g_aucConvertToBit[ iWidth ] >= 0 ); // 4x 4 |
---|
366 | assert( g_aucConvertToBit[ iWidth ] <= 5 ); // 128x128 |
---|
367 | assert( iWidth == iHeight ); |
---|
368 | |
---|
369 | ptrSrc = pcTComPattern->getPredictorPtr( uiDirMode, g_aucConvertToBit[ iWidth ] + 2, m_piYuvExt ); |
---|
370 | |
---|
371 | // get starting pixel in block |
---|
372 | Int sw = 2 * iWidth + 1; |
---|
373 | |
---|
374 | // Create the prediction |
---|
375 | if ( uiDirMode == PLANAR_IDX ) |
---|
376 | { |
---|
377 | xPredIntraPlanar( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight ); |
---|
378 | } |
---|
379 | else |
---|
380 | { |
---|
381 | if ( (iWidth > 16) || (iHeight > 16) ) |
---|
382 | { |
---|
383 | xPredIntraAng(g_bitDepthY, ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, uiDirMode, bAbove, bLeft, false ); |
---|
384 | } |
---|
385 | else |
---|
386 | { |
---|
387 | xPredIntraAng(g_bitDepthY, ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, uiDirMode, bAbove, bLeft, true ); |
---|
388 | |
---|
389 | if( (uiDirMode == DC_IDX ) && bAbove && bLeft ) |
---|
390 | { |
---|
391 | xDCPredFiltering( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight); |
---|
392 | } |
---|
393 | } |
---|
394 | } |
---|
395 | } |
---|
396 | |
---|
397 | // Angular chroma |
---|
398 | Void TComPrediction::predIntraChromaAng( Int* piSrc, UInt uiDirMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft ) |
---|
399 | { |
---|
400 | Pel *pDst = piPred; |
---|
401 | Int *ptrSrc = piSrc; |
---|
402 | |
---|
403 | // get starting pixel in block |
---|
404 | Int sw = 2 * iWidth + 1; |
---|
405 | |
---|
406 | if ( uiDirMode == PLANAR_IDX ) |
---|
407 | { |
---|
408 | xPredIntraPlanar( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight ); |
---|
409 | } |
---|
410 | else |
---|
411 | { |
---|
412 | // Create the prediction |
---|
413 | xPredIntraAng(g_bitDepthC, ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, uiDirMode, bAbove, bLeft, false ); |
---|
414 | } |
---|
415 | } |
---|
416 | |
---|
417 | #if H_3D_DIM |
---|
418 | Void TComPrediction::predIntraLumaDepth( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiIntraMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bFastEnc ) |
---|
419 | { |
---|
420 | assert( iWidth == iHeight ); |
---|
421 | assert( iWidth >= DIM_MIN_SIZE && iWidth <= DIM_MAX_SIZE ); |
---|
422 | assert( isDimMode( uiIntraMode ) ); |
---|
423 | |
---|
424 | UInt dimType = getDimType ( uiIntraMode ); |
---|
425 | Bool dimDeltaDC = isDimDeltaDC( uiIntraMode ); |
---|
426 | Bool isDmmMode = (dimType < DMM_NUM_TYPE); |
---|
427 | Bool isRbcMode = (dimType == RBC_IDX); |
---|
428 | |
---|
429 | Bool* biSegPattern = NULL; |
---|
430 | UInt patternStride = 0; |
---|
431 | |
---|
432 | // get partiton |
---|
433 | #if H_3D_DIM_DMM |
---|
434 | TComWedgelet* dmmSegmentation = NULL; |
---|
435 | if( isDmmMode ) |
---|
436 | { |
---|
437 | switch( dimType ) |
---|
438 | { |
---|
439 | case( DMM1_IDX ): |
---|
440 | { |
---|
441 | dmmSegmentation = &(g_dmmWedgeLists[ g_aucConvertToBit[iWidth] ][ pcCU->getDmmWedgeTabIdx( dimType, uiAbsPartIdx ) ]); |
---|
442 | } break; |
---|
443 | case( DMM3_IDX ): |
---|
444 | { |
---|
445 | UInt uiTabIdx = 0; |
---|
446 | if( bFastEnc ) { uiTabIdx = pcCU->getDmmWedgeTabIdx( dimType, uiAbsPartIdx ); } |
---|
447 | else |
---|
448 | { |
---|
449 | uiTabIdx = xPredWedgeFromTex( pcCU, uiAbsPartIdx, iWidth, iHeight, pcCU->getDmm3IntraTabIdx( uiAbsPartIdx ) ); |
---|
450 | pcCU->setDmmWedgeTabIdxSubParts( uiTabIdx, dimType, uiAbsPartIdx, (pcCU->getDepth(0) + (pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1)) ); |
---|
451 | } |
---|
452 | dmmSegmentation = &(g_dmmWedgeLists[ g_aucConvertToBit[iWidth] ][ uiTabIdx ]); |
---|
453 | } break; |
---|
454 | case( DMM4_IDX ): |
---|
455 | { |
---|
456 | dmmSegmentation = new TComWedgelet( iWidth, iHeight ); |
---|
457 | xPredContourFromTex( pcCU, uiAbsPartIdx, iWidth, iHeight, dmmSegmentation ); |
---|
458 | } break; |
---|
459 | default: assert(0); |
---|
460 | } |
---|
461 | assert( dmmSegmentation ); |
---|
462 | biSegPattern = dmmSegmentation->getPattern(); |
---|
463 | patternStride = dmmSegmentation->getStride (); |
---|
464 | } |
---|
465 | #endif |
---|
466 | #if H_3D_DIM_RBC |
---|
467 | if( isRbcMode ) |
---|
468 | { |
---|
469 | biSegPattern = pcCU->getEdgePartition( uiAbsPartIdx ); |
---|
470 | patternStride = iWidth; |
---|
471 | } |
---|
472 | #endif |
---|
473 | |
---|
474 | // get predicted partition values |
---|
475 | assert( biSegPattern ); |
---|
476 | Int* piMask = NULL; |
---|
477 | #if QC_DIM_DELTADC_UNIFY_F0132 || HHI_DIM_PREDSAMP_FIX_F0171 |
---|
478 | piMask = pcCU->getPattern()->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); // no filtering |
---|
479 | #else |
---|
480 | if( isDmmMode ) piMask = pcCU->getPattern()->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); // no filtering for DMM |
---|
481 | else piMask = pcCU->getPattern()->getPredictorPtr( 0, g_aucConvertToBit[ iWidth ] + 2, m_piYuvExt ); |
---|
482 | #endif |
---|
483 | assert( piMask ); |
---|
484 | Int maskStride = 2*iWidth + 1; |
---|
485 | Int* ptrSrc = piMask+maskStride+1; |
---|
486 | Pel predDC1 = 0; Pel predDC2 = 0; |
---|
487 | xPredBiSegDCs( ptrSrc, maskStride, biSegPattern, patternStride, predDC1, predDC2 ); |
---|
488 | |
---|
489 | // set segment values with deltaDC offsets |
---|
490 | Pel segDC1 = 0; |
---|
491 | Pel segDC2 = 0; |
---|
492 | if( dimDeltaDC ) |
---|
493 | { |
---|
494 | Pel deltaDC1 = pcCU->getDimDeltaDC( dimType, 0, uiAbsPartIdx ); |
---|
495 | Pel deltaDC2 = pcCU->getDimDeltaDC( dimType, 1, uiAbsPartIdx ); |
---|
496 | #if H_3D_DIM_DMM |
---|
497 | #if QC_DIM_DELTADC_UNIFY_F0132 |
---|
498 | if( isDmmMode || isRbcMode) |
---|
499 | #else |
---|
500 | if( isDmmMode ) |
---|
501 | #endif |
---|
502 | { |
---|
503 | #if H_3D_DIM_DLT |
---|
504 | segDC1 = pcCU->getSlice()->getVPS()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pcCU->getSlice()->getVPS()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), predDC1 ) + deltaDC1 ); |
---|
505 | segDC2 = pcCU->getSlice()->getVPS()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pcCU->getSlice()->getVPS()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), predDC2 ) + deltaDC2 ); |
---|
506 | #else |
---|
507 | segDC1 = ClipY( predDC1 + deltaDC1 ); |
---|
508 | segDC2 = ClipY( predDC2 + deltaDC2 ); |
---|
509 | #endif |
---|
510 | } |
---|
511 | #endif |
---|
512 | #if H_3D_DIM_RBC && !QC_DIM_DELTADC_UNIFY_F0132 |
---|
513 | if( isRbcMode ) |
---|
514 | { |
---|
515 | xDeltaDCQuantScaleUp( pcCU, deltaDC1 ); |
---|
516 | xDeltaDCQuantScaleUp( pcCU, deltaDC2 ); |
---|
517 | segDC1 = ClipY( predDC1 + deltaDC1 ); |
---|
518 | segDC2 = ClipY( predDC2 + deltaDC2 ); |
---|
519 | } |
---|
520 | #endif |
---|
521 | } |
---|
522 | else |
---|
523 | { |
---|
524 | segDC1 = predDC1; |
---|
525 | segDC2 = predDC2; |
---|
526 | } |
---|
527 | |
---|
528 | // set prediction signal |
---|
529 | Pel* pDst = piPred; |
---|
530 | xAssignBiSegDCs( pDst, uiStride, biSegPattern, patternStride, segDC1, segDC2 ); |
---|
531 | |
---|
532 | #if H_3D_DIM_DMM |
---|
533 | if( dimType == DMM4_IDX ) { dmmSegmentation->destroy(); delete dmmSegmentation; } |
---|
534 | #endif |
---|
535 | } |
---|
536 | #endif |
---|
537 | |
---|
538 | /** Function for checking identical motion. |
---|
539 | * \param TComDataCU* pcCU |
---|
540 | * \param UInt PartAddr |
---|
541 | */ |
---|
542 | Bool TComPrediction::xCheckIdenticalMotion ( TComDataCU* pcCU, UInt PartAddr ) |
---|
543 | { |
---|
544 | if( pcCU->getSlice()->isInterB() && !pcCU->getSlice()->getPPS()->getWPBiPred() ) |
---|
545 | { |
---|
546 | if( pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr) >= 0 && pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr) >= 0) |
---|
547 | { |
---|
548 | Int RefPOCL0 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_0, pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr))->getPOC(); |
---|
549 | Int RefPOCL1 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_1, pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr))->getPOC(); |
---|
550 | if(RefPOCL0 == RefPOCL1 && pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr) == pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr)) |
---|
551 | { |
---|
552 | return true; |
---|
553 | } |
---|
554 | } |
---|
555 | } |
---|
556 | return false; |
---|
557 | } |
---|
558 | |
---|
559 | |
---|
560 | Void TComPrediction::motionCompensation ( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx ) |
---|
561 | { |
---|
562 | Int iWidth; |
---|
563 | Int iHeight; |
---|
564 | UInt uiPartAddr; |
---|
565 | |
---|
566 | if ( iPartIdx >= 0 ) |
---|
567 | { |
---|
568 | pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight ); |
---|
569 | #if H_3D_VSP |
---|
570 | if ( pcCU->getVSPFlag(uiPartAddr) == 0) |
---|
571 | { |
---|
572 | #endif |
---|
573 | if ( eRefPicList != REF_PIC_LIST_X ) |
---|
574 | { |
---|
575 | if( pcCU->getSlice()->getPPS()->getUseWP()) |
---|
576 | { |
---|
577 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true ); |
---|
578 | } |
---|
579 | else |
---|
580 | { |
---|
581 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); |
---|
582 | } |
---|
583 | if ( pcCU->getSlice()->getPPS()->getUseWP() ) |
---|
584 | { |
---|
585 | xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); |
---|
586 | } |
---|
587 | } |
---|
588 | else |
---|
589 | { |
---|
590 | if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) ) |
---|
591 | { |
---|
592 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred ); |
---|
593 | } |
---|
594 | else |
---|
595 | { |
---|
596 | xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred ); |
---|
597 | } |
---|
598 | } |
---|
599 | #if H_3D_VSP |
---|
600 | } |
---|
601 | else |
---|
602 | { |
---|
603 | if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) ) |
---|
604 | { |
---|
605 | xPredInterUniVSP( pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred ); |
---|
606 | } |
---|
607 | else |
---|
608 | { |
---|
609 | xPredInterBiVSP ( pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred ); |
---|
610 | } |
---|
611 | } |
---|
612 | #endif |
---|
613 | return; |
---|
614 | } |
---|
615 | |
---|
616 | for ( iPartIdx = 0; iPartIdx < pcCU->getNumPartInter(); iPartIdx++ ) |
---|
617 | { |
---|
618 | pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight ); |
---|
619 | |
---|
620 | #if H_3D_VSP |
---|
621 | if ( pcCU->getVSPFlag(uiPartAddr) == 0 ) |
---|
622 | { |
---|
623 | #endif |
---|
624 | if ( eRefPicList != REF_PIC_LIST_X ) |
---|
625 | { |
---|
626 | if( pcCU->getSlice()->getPPS()->getUseWP()) |
---|
627 | { |
---|
628 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true ); |
---|
629 | } |
---|
630 | else |
---|
631 | { |
---|
632 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); |
---|
633 | } |
---|
634 | if ( pcCU->getSlice()->getPPS()->getUseWP() ) |
---|
635 | { |
---|
636 | xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); |
---|
637 | } |
---|
638 | } |
---|
639 | else |
---|
640 | { |
---|
641 | if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) ) |
---|
642 | { |
---|
643 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred ); |
---|
644 | } |
---|
645 | else |
---|
646 | { |
---|
647 | xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred ); |
---|
648 | } |
---|
649 | } |
---|
650 | #if H_3D_VSP |
---|
651 | } |
---|
652 | else |
---|
653 | { |
---|
654 | if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) ) |
---|
655 | { |
---|
656 | xPredInterUniVSP( pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred ); |
---|
657 | } |
---|
658 | else |
---|
659 | { |
---|
660 | xPredInterBiVSP ( pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred ); |
---|
661 | } |
---|
662 | } |
---|
663 | #endif |
---|
664 | } |
---|
665 | return; |
---|
666 | } |
---|
667 | |
---|
668 | Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi ) |
---|
669 | { |
---|
670 | Int iRefIdx = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); assert (iRefIdx >= 0); |
---|
671 | TComMv cMv = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr ); |
---|
672 | pcCU->clipMv(cMv); |
---|
673 | #if H_3D_ARP |
---|
674 | if( pcCU->getARPW( uiPartAddr ) > 0 |
---|
675 | && pcCU->getPartitionSize(uiPartAddr)==SIZE_2Nx2N |
---|
676 | && pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()!= pcCU->getSlice()->getPOC() |
---|
677 | ) |
---|
678 | { |
---|
679 | xPredInterUniARP( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, rpcYuvPred, bi ); |
---|
680 | } |
---|
681 | else |
---|
682 | { |
---|
683 | #endif |
---|
684 | #if H_3D_IC |
---|
685 | Bool bICFlag = pcCU->getICFlag( uiPartAddr ) && ( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getViewIndex() != pcCU->getSlice()->getViewIndex() ); |
---|
686 | xPredInterLumaBlk ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi |
---|
687 | #if H_3D_ARP |
---|
688 | , false |
---|
689 | #endif |
---|
690 | , bICFlag ); |
---|
691 | bICFlag = bICFlag && (iWidth > 8); |
---|
692 | xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi |
---|
693 | #if H_3D_ARP |
---|
694 | , false |
---|
695 | #endif |
---|
696 | , bICFlag ); |
---|
697 | #else |
---|
698 | xPredInterLumaBlk ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi ); |
---|
699 | xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi ); |
---|
700 | #endif |
---|
701 | #if H_3D_ARP |
---|
702 | } |
---|
703 | #endif |
---|
704 | } |
---|
705 | |
---|
706 | #if H_3D_VSP |
---|
707 | Void TComPrediction::xPredInterUniVSP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi ) |
---|
708 | { |
---|
709 | // Get depth reference |
---|
710 | Int depthRefViewIdx = pcCU->getDvInfo(uiPartAddr).m_aVIdxCan; |
---|
711 | #if H_3D_FCO_VSP_DONBDV_E0163 |
---|
712 | TComPic* pRefPicBaseDepth = 0; |
---|
713 | Bool bIsCurrDepthCoded = false; |
---|
714 | pRefPicBaseDepth = pcCU->getSlice()->getIvPic( true, pcCU->getSlice()->getViewIndex() ); |
---|
715 | if ( pRefPicBaseDepth->getPicYuvRec() != NULL ) |
---|
716 | { |
---|
717 | bIsCurrDepthCoded = true; |
---|
718 | } |
---|
719 | else |
---|
720 | { |
---|
721 | pRefPicBaseDepth = pcCU->getSlice()->getIvPic (true, depthRefViewIdx ); |
---|
722 | } |
---|
723 | #else |
---|
724 | TComPic* pRefPicBaseDepth = pcCU->getSlice()->getIvPic (true, depthRefViewIdx ); |
---|
725 | #endif |
---|
726 | assert(pRefPicBaseDepth != NULL); |
---|
727 | TComPicYuv* pcBaseViewDepthPicYuv = pRefPicBaseDepth->getPicYuvRec(); |
---|
728 | assert(pcBaseViewDepthPicYuv != NULL); |
---|
729 | |
---|
730 | // Get texture reference |
---|
731 | Int iRefIdx = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
732 | assert(iRefIdx >= 0); |
---|
733 | TComPic* pRefPicBaseTxt = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx ); |
---|
734 | TComPicYuv* pcBaseViewTxtPicYuv = pRefPicBaseTxt->getPicYuvRec(); |
---|
735 | assert(pcBaseViewTxtPicYuv != NULL); |
---|
736 | |
---|
737 | // Initialize LUT according to the reference viewIdx |
---|
738 | Int txtRefViewIdx = pRefPicBaseTxt->getViewIndex(); |
---|
739 | Int* pShiftLUT = pcCU->getSlice()->getDepthToDisparityB( txtRefViewIdx ); |
---|
740 | assert( txtRefViewIdx < pcCU->getSlice()->getViewIndex() ); |
---|
741 | |
---|
742 | // Do compensation |
---|
743 | TComMv cDv = pcCU->getDvInfo(uiPartAddr).m_acNBDV; |
---|
744 | pcCU->clipMv(cDv); |
---|
745 | |
---|
746 | #if H_3D_FCO_VSP_DONBDV_E0163 |
---|
747 | if ( bIsCurrDepthCoded ) |
---|
748 | { |
---|
749 | cDv.setZero(); |
---|
750 | } |
---|
751 | #endif |
---|
752 | // fetch virtual depth map |
---|
753 | pcBaseViewDepthPicYuv->extendPicBorder(); |
---|
754 | xGetVirtualDepth( pcCU, pcBaseViewDepthPicYuv, &cDv, uiPartAddr, iWidth, iHeight, &m_cYuvDepthOnVsp ); |
---|
755 | // sub-PU based compensation |
---|
756 | xPredInterLumaBlkFromDM ( pcCU, pcBaseViewTxtPicYuv, &m_cYuvDepthOnVsp, pShiftLUT, &cDv, uiPartAddr, iWidth, iHeight, pcCU->getSlice()->getIsDepth(), rpcYuvPred, bi ); |
---|
757 | xPredInterChromaBlkFromDM ( pcCU, pcBaseViewTxtPicYuv, &m_cYuvDepthOnVsp, pShiftLUT, &cDv, uiPartAddr, iWidth, iHeight, pcCU->getSlice()->getIsDepth(), rpcYuvPred, bi ); |
---|
758 | } |
---|
759 | #endif |
---|
760 | |
---|
761 | #if H_3D_ARP |
---|
762 | Void TComPrediction::xPredInterUniARP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, TComMvField * pNewMvFiled ) |
---|
763 | { |
---|
764 | Int iRefIdx = pNewMvFiled ? pNewMvFiled->getRefIdx() : pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
765 | TComMv cMv = pNewMvFiled ? pNewMvFiled->getMv() : pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr ); |
---|
766 | Bool bTobeScaled = false; |
---|
767 | TComPic* pcPicYuvBaseCol = NULL; |
---|
768 | TComPic* pcPicYuvBaseRef = NULL; |
---|
769 | |
---|
770 | #if H_3D_NBDV |
---|
771 | DisInfo cDistparity; |
---|
772 | cDistparity.bDV = pcCU->getDvInfo(uiPartAddr).bDV; |
---|
773 | if( cDistparity.bDV ) |
---|
774 | { |
---|
775 | cDistparity.m_acNBDV = pcCU->getDvInfo(0).m_acNBDV; |
---|
776 | assert(pcCU->getDvInfo(uiPartAddr).bDV == pcCU->getDvInfo(0).bDV); |
---|
777 | cDistparity.m_aVIdxCan = pcCU->getDvInfo(uiPartAddr).m_aVIdxCan; |
---|
778 | } |
---|
779 | #else |
---|
780 | assert(0); // ARP can be applied only when a DV is available |
---|
781 | #endif |
---|
782 | |
---|
783 | UChar dW = cDistparity.bDV ? pcCU->getARPW ( uiPartAddr ) : 0; |
---|
784 | |
---|
785 | if( cDistparity.bDV ) |
---|
786 | { |
---|
787 | if( dW > 0 && pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC()!= pcCU->getSlice()->getPOC() ) |
---|
788 | { |
---|
789 | bTobeScaled = true; |
---|
790 | } |
---|
791 | |
---|
792 | pcPicYuvBaseCol = pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getPOC(), cDistparity.m_aVIdxCan ); |
---|
793 | pcPicYuvBaseRef = pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC(), cDistparity.m_aVIdxCan ); |
---|
794 | |
---|
795 | if( ( !pcPicYuvBaseCol || pcPicYuvBaseCol->getPOC() != pcCU->getSlice()->getPOC() ) || ( !pcPicYuvBaseRef || pcPicYuvBaseRef->getPOC() != pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC() ) ) |
---|
796 | { |
---|
797 | dW = 0; |
---|
798 | bTobeScaled = false; |
---|
799 | } |
---|
800 | else |
---|
801 | { |
---|
802 | assert( pcPicYuvBaseCol->getPOC() == pcCU->getSlice()->getPOC() && pcPicYuvBaseRef->getPOC() == pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC() ); |
---|
803 | } |
---|
804 | |
---|
805 | if(bTobeScaled) |
---|
806 | { |
---|
807 | Int iCurrPOC = pcCU->getSlice()->getPOC(); |
---|
808 | Int iColRefPOC = pcCU->getSlice()->getRefPOC( eRefPicList, iRefIdx ); |
---|
809 | Int iCurrRefPOC = pcCU->getSlice()->getRefPOC( eRefPicList, 0); |
---|
810 | Int iScale = pcCU-> xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iCurrPOC, iColRefPOC); |
---|
811 | if ( iScale != 4096 ) |
---|
812 | { |
---|
813 | cMv = cMv.scaleMv( iScale ); |
---|
814 | } |
---|
815 | iRefIdx = 0; |
---|
816 | } |
---|
817 | } |
---|
818 | |
---|
819 | pcCU->clipMv(cMv); |
---|
820 | TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(); |
---|
821 | xPredInterLumaBlk ( pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi, true ); |
---|
822 | xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi, true ); |
---|
823 | |
---|
824 | if( dW > 0 ) |
---|
825 | { |
---|
826 | TComYuv * pYuvB0 = &m_acYuvPredBase[0]; |
---|
827 | TComYuv * pYuvB1 = &m_acYuvPredBase[1]; |
---|
828 | |
---|
829 | TComMv cMVwithDisparity = cMv + cDistparity.m_acNBDV; |
---|
830 | pcCU->clipMv(cMVwithDisparity); |
---|
831 | |
---|
832 | assert ( cDistparity.bDV ); |
---|
833 | |
---|
834 | pcPicYuvRef = pcPicYuvBaseCol->getPicYuvRec(); |
---|
835 | xPredInterLumaBlk ( pcCU, pcPicYuvRef, uiPartAddr, &cDistparity.m_acNBDV, iWidth, iHeight, pYuvB0, bi, true ); |
---|
836 | xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cDistparity.m_acNBDV, iWidth, iHeight, pYuvB0, bi, true ); |
---|
837 | |
---|
838 | pcPicYuvRef = pcPicYuvBaseRef->getPicYuvRec(); |
---|
839 | xPredInterLumaBlk ( pcCU, pcPicYuvRef, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvB1, bi, true ); |
---|
840 | xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvB1, bi, true ); |
---|
841 | |
---|
842 | pYuvB0->subtractARP( pYuvB0 , pYuvB1 , uiPartAddr , iWidth , iHeight ); |
---|
843 | |
---|
844 | if( 2 == dW ) |
---|
845 | { |
---|
846 | pYuvB0->multiplyARP( uiPartAddr , iWidth , iHeight , dW ); |
---|
847 | } |
---|
848 | rpcYuvPred->addARP( rpcYuvPred , pYuvB0 , uiPartAddr , iWidth , iHeight , !bi ); |
---|
849 | } |
---|
850 | } |
---|
851 | #endif |
---|
852 | |
---|
853 | Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvPred ) |
---|
854 | { |
---|
855 | TComYuv* pcMbYuv; |
---|
856 | Int iRefIdx[2] = {-1, -1}; |
---|
857 | |
---|
858 | for ( Int iRefList = 0; iRefList < 2; iRefList++ ) |
---|
859 | { |
---|
860 | RefPicList eRefPicList = (iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0); |
---|
861 | iRefIdx[iRefList] = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
862 | |
---|
863 | if ( iRefIdx[iRefList] < 0 ) |
---|
864 | { |
---|
865 | continue; |
---|
866 | } |
---|
867 | |
---|
868 | assert( iRefIdx[iRefList] < pcCU->getSlice()->getNumRefIdx(eRefPicList) ); |
---|
869 | |
---|
870 | pcMbYuv = &m_acYuvPred[iRefList]; |
---|
871 | if( pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr ) >= 0 && pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr ) >= 0 ) |
---|
872 | { |
---|
873 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, true ); |
---|
874 | } |
---|
875 | else |
---|
876 | { |
---|
877 | if ( ( pcCU->getSlice()->getPPS()->getUseWP() && pcCU->getSlice()->getSliceType() == P_SLICE ) || |
---|
878 | ( pcCU->getSlice()->getPPS()->getWPBiPred() && pcCU->getSlice()->getSliceType() == B_SLICE ) ) |
---|
879 | { |
---|
880 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, true ); |
---|
881 | } |
---|
882 | else |
---|
883 | { |
---|
884 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv ); |
---|
885 | } |
---|
886 | } |
---|
887 | } |
---|
888 | |
---|
889 | if ( pcCU->getSlice()->getPPS()->getWPBiPred() && pcCU->getSlice()->getSliceType() == B_SLICE ) |
---|
890 | { |
---|
891 | xWeightedPredictionBi( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); |
---|
892 | } |
---|
893 | else if ( pcCU->getSlice()->getPPS()->getUseWP() && pcCU->getSlice()->getSliceType() == P_SLICE ) |
---|
894 | { |
---|
895 | xWeightedPredictionUni( pcCU, &m_acYuvPred[0], uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, rpcYuvPred ); |
---|
896 | } |
---|
897 | else |
---|
898 | { |
---|
899 | xWeightedAverage( &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); |
---|
900 | } |
---|
901 | } |
---|
902 | |
---|
903 | #if H_3D_VSP |
---|
904 | |
---|
905 | Void TComPrediction::xPredInterBiVSP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvPred ) |
---|
906 | { |
---|
907 | TComYuv* pcMbYuv; |
---|
908 | Int iRefIdx[2] = {-1, -1}; |
---|
909 | Bool bi = (pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr ) >= 0 && pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr ) >= 0); |
---|
910 | |
---|
911 | for ( Int iRefList = 0; iRefList < 2; iRefList++ ) |
---|
912 | { |
---|
913 | RefPicList eRefPicList = RefPicList(iRefList); |
---|
914 | iRefIdx[iRefList] = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
915 | |
---|
916 | if ( iRefIdx[iRefList] < 0 ) |
---|
917 | { |
---|
918 | continue; |
---|
919 | } |
---|
920 | assert( iRefIdx[iRefList] < pcCU->getSlice()->getNumRefIdx(eRefPicList) ); |
---|
921 | |
---|
922 | pcMbYuv = &m_acYuvPred[iRefList]; |
---|
923 | xPredInterUniVSP ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, bi ); |
---|
924 | } |
---|
925 | |
---|
926 | xWeightedAverage( &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); |
---|
927 | } |
---|
928 | |
---|
929 | #endif |
---|
930 | |
---|
931 | /** |
---|
932 | * \brief Generate motion-compensated luma block |
---|
933 | * |
---|
934 | * \param cu Pointer to current CU |
---|
935 | * \param refPic Pointer to reference picture |
---|
936 | * \param partAddr Address of block within CU |
---|
937 | * \param mv Motion vector |
---|
938 | * \param width Width of block |
---|
939 | * \param height Height of block |
---|
940 | * \param dstPic Pointer to destination picture |
---|
941 | * \param bi Flag indicating whether bipred is used |
---|
942 | */ |
---|
943 | Void TComPrediction::xPredInterLumaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi |
---|
944 | #if H_3D_ARP |
---|
945 | , Bool filterType |
---|
946 | #endif |
---|
947 | #if H_3D_IC |
---|
948 | , Bool bICFlag |
---|
949 | #endif |
---|
950 | ) |
---|
951 | { |
---|
952 | Int refStride = refPic->getStride(); |
---|
953 | Int refOffset = ( mv->getHor() >> 2 ) + ( mv->getVer() >> 2 ) * refStride; |
---|
954 | Pel *ref = refPic->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset; |
---|
955 | |
---|
956 | Int dstStride = dstPic->getStride(); |
---|
957 | Pel *dst = dstPic->getLumaAddr( partAddr ); |
---|
958 | |
---|
959 | Int xFrac = mv->getHor() & 0x3; |
---|
960 | Int yFrac = mv->getVer() & 0x3; |
---|
961 | |
---|
962 | #if H_3D_IC |
---|
963 | if( cu->getSlice()->getIsDepth() ) |
---|
964 | { |
---|
965 | refOffset = mv->getHor() + mv->getVer() * refStride; |
---|
966 | ref = refPic->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset; |
---|
967 | xFrac = 0; |
---|
968 | yFrac = 0; |
---|
969 | } |
---|
970 | #endif |
---|
971 | if ( yFrac == 0 ) |
---|
972 | { |
---|
973 | #if H_3D_IC |
---|
974 | m_if.filterHorLuma( ref, refStride, dst, dstStride, width, height, xFrac, !bi || bICFlag |
---|
975 | #else |
---|
976 | m_if.filterHorLuma( ref, refStride, dst, dstStride, width, height, xFrac, !bi |
---|
977 | #endif |
---|
978 | #if H_3D_ARP |
---|
979 | , filterType |
---|
980 | #endif |
---|
981 | ); |
---|
982 | } |
---|
983 | else if ( xFrac == 0 ) |
---|
984 | { |
---|
985 | #if H_3D_IC |
---|
986 | m_if.filterVerLuma( ref, refStride, dst, dstStride, width, height, yFrac, true, !bi || bICFlag |
---|
987 | #else |
---|
988 | m_if.filterVerLuma( ref, refStride, dst, dstStride, width, height, yFrac, true, !bi |
---|
989 | #endif |
---|
990 | #if H_3D_ARP |
---|
991 | , filterType |
---|
992 | #endif |
---|
993 | ); |
---|
994 | } |
---|
995 | else |
---|
996 | { |
---|
997 | Int tmpStride = m_filteredBlockTmp[0].getStride(); |
---|
998 | Short *tmp = m_filteredBlockTmp[0].getLumaAddr(); |
---|
999 | |
---|
1000 | Int filterSize = NTAPS_LUMA; |
---|
1001 | Int halfFilterSize = ( filterSize >> 1 ); |
---|
1002 | |
---|
1003 | m_if.filterHorLuma(ref - (halfFilterSize-1)*refStride, refStride, tmp, tmpStride, width, height+filterSize-1, xFrac, false |
---|
1004 | #if H_3D_ARP |
---|
1005 | , filterType |
---|
1006 | #endif |
---|
1007 | ); |
---|
1008 | #if H_3D_IC |
---|
1009 | m_if.filterVerLuma(tmp + (halfFilterSize-1)*tmpStride, tmpStride, dst, dstStride, width, height, yFrac, false, !bi || bICFlag |
---|
1010 | #else |
---|
1011 | m_if.filterVerLuma(tmp + (halfFilterSize-1)*tmpStride, tmpStride, dst, dstStride, width, height, yFrac, false, !bi |
---|
1012 | #endif |
---|
1013 | #if H_3D_ARP |
---|
1014 | , filterType |
---|
1015 | #endif |
---|
1016 | ); |
---|
1017 | } |
---|
1018 | |
---|
1019 | #if H_3D_IC |
---|
1020 | if( bICFlag ) |
---|
1021 | { |
---|
1022 | Int a, b, i, j; |
---|
1023 | const Int iShift = IC_CONST_SHIFT; |
---|
1024 | |
---|
1025 | xGetLLSICPrediction( cu, mv, refPic, a, b, TEXT_LUMA ); |
---|
1026 | |
---|
1027 | |
---|
1028 | for ( i = 0; i < height; i++ ) |
---|
1029 | { |
---|
1030 | for ( j = 0; j < width; j++ ) |
---|
1031 | { |
---|
1032 | dst[j] = Clip3( 0, ( 1 << g_bitDepthY ) - 1, ( ( a*dst[j] ) >> iShift ) + b ); |
---|
1033 | } |
---|
1034 | dst += dstStride; |
---|
1035 | } |
---|
1036 | |
---|
1037 | if(bi) |
---|
1038 | { |
---|
1039 | Pel *dst2 = dstPic->getLumaAddr( partAddr ); |
---|
1040 | Int shift = IF_INTERNAL_PREC - g_bitDepthY; |
---|
1041 | for (i = 0; i < height; i++) |
---|
1042 | { |
---|
1043 | for (j = 0; j < width; j++) |
---|
1044 | { |
---|
1045 | Short val = dst2[j] << shift; |
---|
1046 | dst2[j] = val - (Short)IF_INTERNAL_OFFS; |
---|
1047 | } |
---|
1048 | dst2 += dstStride; |
---|
1049 | } |
---|
1050 | } |
---|
1051 | } |
---|
1052 | #endif |
---|
1053 | } |
---|
1054 | |
---|
1055 | /** |
---|
1056 | * \brief Generate motion-compensated chroma block |
---|
1057 | * |
---|
1058 | * \param cu Pointer to current CU |
---|
1059 | * \param refPic Pointer to reference picture |
---|
1060 | * \param partAddr Address of block within CU |
---|
1061 | * \param mv Motion vector |
---|
1062 | * \param width Width of block |
---|
1063 | * \param height Height of block |
---|
1064 | * \param dstPic Pointer to destination picture |
---|
1065 | * \param bi Flag indicating whether bipred is used |
---|
1066 | */ |
---|
1067 | Void TComPrediction::xPredInterChromaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi |
---|
1068 | #if H_3D_ARP |
---|
1069 | , Bool filterType |
---|
1070 | #endif |
---|
1071 | #if H_3D_IC |
---|
1072 | , Bool bICFlag |
---|
1073 | #endif |
---|
1074 | ) |
---|
1075 | { |
---|
1076 | Int refStride = refPic->getCStride(); |
---|
1077 | Int dstStride = dstPic->getCStride(); |
---|
1078 | |
---|
1079 | Int refOffset = (mv->getHor() >> 3) + (mv->getVer() >> 3) * refStride; |
---|
1080 | |
---|
1081 | Pel* refCb = refPic->getCbAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset; |
---|
1082 | Pel* refCr = refPic->getCrAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset; |
---|
1083 | |
---|
1084 | Pel* dstCb = dstPic->getCbAddr( partAddr ); |
---|
1085 | Pel* dstCr = dstPic->getCrAddr( partAddr ); |
---|
1086 | |
---|
1087 | Int xFrac = mv->getHor() & 0x7; |
---|
1088 | Int yFrac = mv->getVer() & 0x7; |
---|
1089 | UInt cxWidth = width >> 1; |
---|
1090 | UInt cxHeight = height >> 1; |
---|
1091 | |
---|
1092 | Int extStride = m_filteredBlockTmp[0].getStride(); |
---|
1093 | Short* extY = m_filteredBlockTmp[0].getLumaAddr(); |
---|
1094 | |
---|
1095 | Int filterSize = NTAPS_CHROMA; |
---|
1096 | |
---|
1097 | Int halfFilterSize = (filterSize>>1); |
---|
1098 | |
---|
1099 | if ( yFrac == 0 ) |
---|
1100 | { |
---|
1101 | #if H_3D_IC |
---|
1102 | m_if.filterHorChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, xFrac, !bi || bICFlag |
---|
1103 | #else |
---|
1104 | m_if.filterHorChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, xFrac, !bi |
---|
1105 | #endif |
---|
1106 | #if H_3D_ARP |
---|
1107 | , filterType |
---|
1108 | #endif |
---|
1109 | ); |
---|
1110 | #if H_3D_IC |
---|
1111 | m_if.filterHorChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, xFrac, !bi || bICFlag |
---|
1112 | #else |
---|
1113 | m_if.filterHorChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, xFrac, !bi |
---|
1114 | #endif |
---|
1115 | #if H_3D_ARP |
---|
1116 | , filterType |
---|
1117 | #endif |
---|
1118 | ); |
---|
1119 | } |
---|
1120 | else if ( xFrac == 0 ) |
---|
1121 | { |
---|
1122 | #if H_3D_IC |
---|
1123 | m_if.filterVerChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, true, !bi || bICFlag |
---|
1124 | #else |
---|
1125 | m_if.filterVerChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, true, !bi |
---|
1126 | #endif |
---|
1127 | #if H_3D_ARP |
---|
1128 | , filterType |
---|
1129 | #endif |
---|
1130 | ); |
---|
1131 | #if H_3D_IC |
---|
1132 | m_if.filterVerChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, true, !bi || bICFlag |
---|
1133 | #else |
---|
1134 | m_if.filterVerChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, true, !bi |
---|
1135 | #endif |
---|
1136 | #if H_3D_ARP |
---|
1137 | , filterType |
---|
1138 | #endif |
---|
1139 | ); |
---|
1140 | } |
---|
1141 | else |
---|
1142 | { |
---|
1143 | m_if.filterHorChroma(refCb - (halfFilterSize-1)*refStride, refStride, extY, extStride, cxWidth, cxHeight+filterSize-1, xFrac, false |
---|
1144 | #if H_3D_ARP |
---|
1145 | , filterType |
---|
1146 | #endif |
---|
1147 | ); |
---|
1148 | #if H_3D_IC |
---|
1149 | m_if.filterVerChroma(extY + (halfFilterSize-1)*extStride, extStride, dstCb, dstStride, cxWidth, cxHeight , yFrac, false, !bi || bICFlag |
---|
1150 | #else |
---|
1151 | m_if.filterVerChroma(extY + (halfFilterSize-1)*extStride, extStride, dstCb, dstStride, cxWidth, cxHeight , yFrac, false, !bi |
---|
1152 | #endif |
---|
1153 | #if H_3D_ARP |
---|
1154 | , filterType |
---|
1155 | #endif |
---|
1156 | ); |
---|
1157 | |
---|
1158 | m_if.filterHorChroma(refCr - (halfFilterSize-1)*refStride, refStride, extY, extStride, cxWidth, cxHeight+filterSize-1, xFrac, false |
---|
1159 | #if H_3D_ARP |
---|
1160 | , filterType |
---|
1161 | #endif |
---|
1162 | ); |
---|
1163 | #if H_3D_IC |
---|
1164 | m_if.filterVerChroma(extY + (halfFilterSize-1)*extStride, extStride, dstCr, dstStride, cxWidth, cxHeight , yFrac, false, !bi || bICFlag |
---|
1165 | #else |
---|
1166 | m_if.filterVerChroma(extY + (halfFilterSize-1)*extStride, extStride, dstCr, dstStride, cxWidth, cxHeight , yFrac, false, !bi |
---|
1167 | #endif |
---|
1168 | #if H_3D_ARP |
---|
1169 | , filterType |
---|
1170 | #endif |
---|
1171 | ); |
---|
1172 | } |
---|
1173 | |
---|
1174 | #if H_3D_IC |
---|
1175 | if( bICFlag ) |
---|
1176 | { |
---|
1177 | Int a, b, i, j; |
---|
1178 | const Int iShift = IC_CONST_SHIFT; |
---|
1179 | xGetLLSICPrediction( cu, mv, refPic, a, b, TEXT_CHROMA_U ); // Cb |
---|
1180 | for ( i = 0; i < cxHeight; i++ ) |
---|
1181 | { |
---|
1182 | for ( j = 0; j < cxWidth; j++ ) |
---|
1183 | { |
---|
1184 | dstCb[j] = Clip3( 0, ( 1 << g_bitDepthC ) - 1, ( ( a*dstCb[j] ) >> iShift ) + b ); |
---|
1185 | } |
---|
1186 | dstCb += dstStride; |
---|
1187 | } |
---|
1188 | xGetLLSICPrediction( cu, mv, refPic, a, b, TEXT_CHROMA_V ); // Cr |
---|
1189 | for ( i = 0; i < cxHeight; i++ ) |
---|
1190 | { |
---|
1191 | for ( j = 0; j < cxWidth; j++ ) |
---|
1192 | { |
---|
1193 | dstCr[j] = Clip3( 0, ( 1 << g_bitDepthC ) - 1, ( ( a*dstCr[j] ) >> iShift ) + b ); |
---|
1194 | } |
---|
1195 | dstCr += dstStride; |
---|
1196 | } |
---|
1197 | |
---|
1198 | if(bi) |
---|
1199 | { |
---|
1200 | Pel* dstCb2 = dstPic->getCbAddr( partAddr ); |
---|
1201 | Pel* dstCr2 = dstPic->getCrAddr( partAddr ); |
---|
1202 | Int shift = IF_INTERNAL_PREC - g_bitDepthC; |
---|
1203 | for (i = 0; i < cxHeight; i++) |
---|
1204 | { |
---|
1205 | for (j = 0; j < cxWidth; j++) |
---|
1206 | { |
---|
1207 | Short val = dstCb2[j] << shift; |
---|
1208 | dstCb2[j] = val - (Short)IF_INTERNAL_OFFS; |
---|
1209 | |
---|
1210 | val = dstCr2[j] << shift; |
---|
1211 | dstCr2[j] = val - (Short)IF_INTERNAL_OFFS; |
---|
1212 | } |
---|
1213 | dstCb2 += dstStride; |
---|
1214 | dstCr2 += dstStride; |
---|
1215 | } |
---|
1216 | } |
---|
1217 | } |
---|
1218 | #endif |
---|
1219 | } |
---|
1220 | |
---|
1221 | Void TComPrediction::xWeightedAverage( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv*& rpcYuvDst ) |
---|
1222 | { |
---|
1223 | if( iRefIdx0 >= 0 && iRefIdx1 >= 0 ) |
---|
1224 | { |
---|
1225 | rpcYuvDst->addAvg( pcYuvSrc0, pcYuvSrc1, uiPartIdx, iWidth, iHeight ); |
---|
1226 | } |
---|
1227 | else if ( iRefIdx0 >= 0 && iRefIdx1 < 0 ) |
---|
1228 | { |
---|
1229 | pcYuvSrc0->copyPartToPartYuv( rpcYuvDst, uiPartIdx, iWidth, iHeight ); |
---|
1230 | } |
---|
1231 | else if ( iRefIdx0 < 0 && iRefIdx1 >= 0 ) |
---|
1232 | { |
---|
1233 | pcYuvSrc1->copyPartToPartYuv( rpcYuvDst, uiPartIdx, iWidth, iHeight ); |
---|
1234 | } |
---|
1235 | } |
---|
1236 | |
---|
1237 | // AMVP |
---|
1238 | Void TComPrediction::getMvPredAMVP( TComDataCU* pcCU, UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, TComMv& rcMvPred ) |
---|
1239 | { |
---|
1240 | AMVPInfo* pcAMVPInfo = pcCU->getCUMvField(eRefPicList)->getAMVPInfo(); |
---|
1241 | if( pcAMVPInfo->iN <= 1 ) |
---|
1242 | { |
---|
1243 | rcMvPred = pcAMVPInfo->m_acMvCand[0]; |
---|
1244 | |
---|
1245 | pcCU->setMVPIdxSubParts( 0, eRefPicList, uiPartAddr, uiPartIdx, pcCU->getDepth(uiPartAddr)); |
---|
1246 | pcCU->setMVPNumSubParts( pcAMVPInfo->iN, eRefPicList, uiPartAddr, uiPartIdx, pcCU->getDepth(uiPartAddr)); |
---|
1247 | return; |
---|
1248 | } |
---|
1249 | |
---|
1250 | assert(pcCU->getMVPIdx(eRefPicList,uiPartAddr) >= 0); |
---|
1251 | rcMvPred = pcAMVPInfo->m_acMvCand[pcCU->getMVPIdx(eRefPicList,uiPartAddr)]; |
---|
1252 | return; |
---|
1253 | } |
---|
1254 | |
---|
1255 | /** Function for deriving planar intra prediction. |
---|
1256 | * \param pSrc pointer to reconstructed sample array |
---|
1257 | * \param srcStride the stride of the reconstructed sample array |
---|
1258 | * \param rpDst reference to pointer for the prediction sample array |
---|
1259 | * \param dstStride the stride of the prediction sample array |
---|
1260 | * \param width the width of the block |
---|
1261 | * \param height the height of the block |
---|
1262 | * |
---|
1263 | * This function derives the prediction samples for planar mode (intra coding). |
---|
1264 | */ |
---|
1265 | Void TComPrediction::xPredIntraPlanar( Int* pSrc, Int srcStride, Pel* rpDst, Int dstStride, UInt width, UInt height ) |
---|
1266 | { |
---|
1267 | assert(width == height); |
---|
1268 | |
---|
1269 | Int k, l, bottomLeft, topRight; |
---|
1270 | Int horPred; |
---|
1271 | Int leftColumn[MAX_CU_SIZE+1], topRow[MAX_CU_SIZE+1], bottomRow[MAX_CU_SIZE], rightColumn[MAX_CU_SIZE]; |
---|
1272 | UInt blkSize = width; |
---|
1273 | UInt offset2D = width; |
---|
1274 | UInt shift1D = g_aucConvertToBit[ width ] + 2; |
---|
1275 | UInt shift2D = shift1D + 1; |
---|
1276 | |
---|
1277 | // Get left and above reference column and row |
---|
1278 | for(k=0;k<blkSize+1;k++) |
---|
1279 | { |
---|
1280 | topRow[k] = pSrc[k-srcStride]; |
---|
1281 | leftColumn[k] = pSrc[k*srcStride-1]; |
---|
1282 | } |
---|
1283 | |
---|
1284 | // Prepare intermediate variables used in interpolation |
---|
1285 | bottomLeft = leftColumn[blkSize]; |
---|
1286 | topRight = topRow[blkSize]; |
---|
1287 | for (k=0;k<blkSize;k++) |
---|
1288 | { |
---|
1289 | bottomRow[k] = bottomLeft - topRow[k]; |
---|
1290 | rightColumn[k] = topRight - leftColumn[k]; |
---|
1291 | topRow[k] <<= shift1D; |
---|
1292 | leftColumn[k] <<= shift1D; |
---|
1293 | } |
---|
1294 | |
---|
1295 | // Generate prediction signal |
---|
1296 | for (k=0;k<blkSize;k++) |
---|
1297 | { |
---|
1298 | horPred = leftColumn[k] + offset2D; |
---|
1299 | for (l=0;l<blkSize;l++) |
---|
1300 | { |
---|
1301 | horPred += rightColumn[k]; |
---|
1302 | topRow[l] += bottomRow[l]; |
---|
1303 | rpDst[k*dstStride+l] = ( (horPred + topRow[l]) >> shift2D ); |
---|
1304 | } |
---|
1305 | } |
---|
1306 | } |
---|
1307 | |
---|
1308 | /** Function for filtering intra DC predictor. |
---|
1309 | * \param pSrc pointer to reconstructed sample array |
---|
1310 | * \param iSrcStride the stride of the reconstructed sample array |
---|
1311 | * \param rpDst reference to pointer for the prediction sample array |
---|
1312 | * \param iDstStride the stride of the prediction sample array |
---|
1313 | * \param iWidth the width of the block |
---|
1314 | * \param iHeight the height of the block |
---|
1315 | * |
---|
1316 | * This function performs filtering left and top edges of the prediction samples for DC mode (intra coding). |
---|
1317 | */ |
---|
1318 | Void TComPrediction::xDCPredFiltering( Int* pSrc, Int iSrcStride, Pel*& rpDst, Int iDstStride, Int iWidth, Int iHeight ) |
---|
1319 | { |
---|
1320 | Pel* pDst = rpDst; |
---|
1321 | Int x, y, iDstStride2, iSrcStride2; |
---|
1322 | |
---|
1323 | // boundary pixels processing |
---|
1324 | pDst[0] = (Pel)((pSrc[-iSrcStride] + pSrc[-1] + 2 * pDst[0] + 2) >> 2); |
---|
1325 | |
---|
1326 | for ( x = 1; x < iWidth; x++ ) |
---|
1327 | { |
---|
1328 | pDst[x] = (Pel)((pSrc[x - iSrcStride] + 3 * pDst[x] + 2) >> 2); |
---|
1329 | } |
---|
1330 | |
---|
1331 | for ( y = 1, iDstStride2 = iDstStride, iSrcStride2 = iSrcStride-1; y < iHeight; y++, iDstStride2+=iDstStride, iSrcStride2+=iSrcStride ) |
---|
1332 | { |
---|
1333 | pDst[iDstStride2] = (Pel)((pSrc[iSrcStride2] + 3 * pDst[iDstStride2] + 2) >> 2); |
---|
1334 | } |
---|
1335 | |
---|
1336 | return; |
---|
1337 | } |
---|
1338 | #if H_3D_IC |
---|
1339 | /** Function for deriving the position of first non-zero binary bit of a value |
---|
1340 | * \param x input value |
---|
1341 | * |
---|
1342 | * This function derives the position of first non-zero binary bit of a value |
---|
1343 | */ |
---|
1344 | Int GetMSB( UInt x ) |
---|
1345 | { |
---|
1346 | Int iMSB = 0, bits = ( sizeof( Int ) << 3 ), y = 1; |
---|
1347 | |
---|
1348 | while( x > 1 ) |
---|
1349 | { |
---|
1350 | bits >>= 1; |
---|
1351 | y = x >> bits; |
---|
1352 | |
---|
1353 | if( y ) |
---|
1354 | { |
---|
1355 | x = y; |
---|
1356 | iMSB += bits; |
---|
1357 | } |
---|
1358 | } |
---|
1359 | |
---|
1360 | iMSB+=y; |
---|
1361 | |
---|
1362 | return iMSB; |
---|
1363 | } |
---|
1364 | |
---|
1365 | |
---|
1366 | /** Function for deriving LM illumination compensation. |
---|
1367 | */ |
---|
1368 | Void TComPrediction::xGetLLSICPrediction( TComDataCU* pcCU, TComMv *pMv, TComPicYuv *pRefPic, Int &a, Int &b, TextType eType ) |
---|
1369 | { |
---|
1370 | TComPicYuv *pRecPic = pcCU->getPic()->getPicYuvRec(); |
---|
1371 | Pel *pRec = NULL, *pRef = NULL; |
---|
1372 | UInt uiWidth, uiHeight, uiTmpPartIdx; |
---|
1373 | Int iRecStride = ( eType == TEXT_LUMA ) ? pRecPic->getStride() : pRecPic->getCStride(); |
---|
1374 | Int iRefStride = ( eType == TEXT_LUMA ) ? pRefPic->getStride() : pRefPic->getCStride(); |
---|
1375 | Int iCUPelX, iCUPelY, iRefX, iRefY, iRefOffset, iHor, iVer; |
---|
1376 | |
---|
1377 | iCUPelX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]]; |
---|
1378 | iCUPelY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]]; |
---|
1379 | iHor = pcCU->getSlice()->getIsDepth() ? pMv->getHor() : ( ( pMv->getHor() + 2 ) >> 2 ); |
---|
1380 | iVer = pcCU->getSlice()->getIsDepth() ? pMv->getVer() : ( ( pMv->getVer() + 2 ) >> 2 ); |
---|
1381 | iRefX = iCUPelX + iHor; |
---|
1382 | iRefY = iCUPelY + iVer; |
---|
1383 | if( eType != TEXT_LUMA ) |
---|
1384 | { |
---|
1385 | iHor = pcCU->getSlice()->getIsDepth() ? ( ( pMv->getHor() + 1 ) >> 1 ) : ( ( pMv->getHor() + 4 ) >> 3 ); |
---|
1386 | iVer = pcCU->getSlice()->getIsDepth() ? ( ( pMv->getVer() + 1 ) >> 1 ) : ( ( pMv->getVer() + 4 ) >> 3 ); |
---|
1387 | } |
---|
1388 | uiWidth = ( eType == TEXT_LUMA ) ? pcCU->getWidth( 0 ) : ( pcCU->getWidth( 0 ) >> 1 ); |
---|
1389 | uiHeight = ( eType == TEXT_LUMA ) ? pcCU->getHeight( 0 ) : ( pcCU->getHeight( 0 ) >> 1 ); |
---|
1390 | |
---|
1391 | Int i, j, iCountShift = 0; |
---|
1392 | |
---|
1393 | // LLS parameters estimation --> |
---|
1394 | |
---|
1395 | Int x = 0, y = 0, xx = 0, xy = 0; |
---|
1396 | Int precShift = std::max(0, (( eType == TEXT_LUMA ) ? g_bitDepthY : g_bitDepthC) - 12); |
---|
1397 | |
---|
1398 | if( pcCU->getPUAbove( uiTmpPartIdx, pcCU->getZorderIdxInCU() ) && iCUPelY > 0 && iRefY > 0 ) |
---|
1399 | { |
---|
1400 | iRefOffset = iHor + iVer * iRefStride - iRefStride; |
---|
1401 | if( eType == TEXT_LUMA ) |
---|
1402 | { |
---|
1403 | pRef = pRefPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
1404 | pRec = pRecPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; |
---|
1405 | } |
---|
1406 | else if( eType == TEXT_CHROMA_U ) |
---|
1407 | { |
---|
1408 | pRef = pRefPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
1409 | pRec = pRecPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; |
---|
1410 | } |
---|
1411 | else |
---|
1412 | { |
---|
1413 | assert( eType == TEXT_CHROMA_V ); |
---|
1414 | pRef = pRefPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
1415 | pRec = pRecPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; |
---|
1416 | } |
---|
1417 | |
---|
1418 | for( j = 0; j < uiWidth; j+=2 ) |
---|
1419 | { |
---|
1420 | x += pRef[j]; |
---|
1421 | y += pRec[j]; |
---|
1422 | xx += (pRef[j] * pRef[j])>>precShift; |
---|
1423 | xy += (pRef[j] * pRec[j])>>precShift; |
---|
1424 | } |
---|
1425 | iCountShift += g_aucConvertToBit[ uiWidth ] + 1; |
---|
1426 | } |
---|
1427 | |
---|
1428 | |
---|
1429 | if( pcCU->getPULeft( uiTmpPartIdx, pcCU->getZorderIdxInCU() ) && iCUPelX > 0 && iRefX > 0 ) |
---|
1430 | { |
---|
1431 | iRefOffset = iHor + iVer * iRefStride - 1; |
---|
1432 | if( eType == TEXT_LUMA ) |
---|
1433 | { |
---|
1434 | pRef = pRefPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
1435 | pRec = pRecPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; |
---|
1436 | } |
---|
1437 | else if( eType == TEXT_CHROMA_U ) |
---|
1438 | { |
---|
1439 | pRef = pRefPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
1440 | pRec = pRecPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; |
---|
1441 | } |
---|
1442 | else |
---|
1443 | { |
---|
1444 | assert( eType == TEXT_CHROMA_V ); |
---|
1445 | pRef = pRefPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
1446 | pRec = pRecPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; |
---|
1447 | } |
---|
1448 | |
---|
1449 | for( i = 0; i < uiHeight; i+=2 ) |
---|
1450 | { |
---|
1451 | x += pRef[0]; |
---|
1452 | y += pRec[0]; |
---|
1453 | |
---|
1454 | xx += (pRef[0] * pRef[0])>>precShift; |
---|
1455 | xy += (pRef[0] * pRec[0])>>precShift; |
---|
1456 | |
---|
1457 | pRef += iRefStride*2; |
---|
1458 | pRec += iRecStride*2; |
---|
1459 | } |
---|
1460 | iCountShift += iCountShift > 0 ? 1 : ( g_aucConvertToBit[ uiWidth ] + 1 ); |
---|
1461 | } |
---|
1462 | |
---|
1463 | xy += xx >> IC_REG_COST_SHIFT; |
---|
1464 | xx += xx >> IC_REG_COST_SHIFT; |
---|
1465 | Int a1 = ( xy << iCountShift ) - ((y * x) >> precShift); |
---|
1466 | Int a2 = ( xx << iCountShift ) - ((x * x) >> precShift); |
---|
1467 | const Int iShift = IC_CONST_SHIFT; |
---|
1468 | { |
---|
1469 | { |
---|
1470 | const Int iShiftA2 = 6; |
---|
1471 | const Int iAccuracyShift = 15; |
---|
1472 | |
---|
1473 | Int iScaleShiftA2 = 0; |
---|
1474 | Int iScaleShiftA1 = 0; |
---|
1475 | Int a1s = a1; |
---|
1476 | Int a2s = a2; |
---|
1477 | |
---|
1478 | a1 = Clip3(0, 2*a2, a1); |
---|
1479 | iScaleShiftA2 = GetMSB( abs( a2 ) ) - iShiftA2; |
---|
1480 | iScaleShiftA1 = iScaleShiftA2 - IC_SHIFT_DIFF; |
---|
1481 | |
---|
1482 | if( iScaleShiftA1 < 0 ) |
---|
1483 | { |
---|
1484 | iScaleShiftA1 = 0; |
---|
1485 | } |
---|
1486 | |
---|
1487 | if( iScaleShiftA2 < 0 ) |
---|
1488 | { |
---|
1489 | iScaleShiftA2 = 0; |
---|
1490 | } |
---|
1491 | |
---|
1492 | Int iScaleShiftA = iScaleShiftA2 + iAccuracyShift - iShift - iScaleShiftA1; |
---|
1493 | |
---|
1494 | |
---|
1495 | a2s = a2 >> iScaleShiftA2; |
---|
1496 | |
---|
1497 | a1s = a1 >> iScaleShiftA1; |
---|
1498 | |
---|
1499 | a = a1s * m_uiaShift[ a2s ]; |
---|
1500 | a = a >> iScaleShiftA; |
---|
1501 | b = ( y - ( ( a * x ) >> iShift ) + ( 1 << ( iCountShift - 1 ) ) ) >> iCountShift; |
---|
1502 | } |
---|
1503 | } |
---|
1504 | } |
---|
1505 | #endif |
---|
1506 | |
---|
1507 | #if H_3D_VSP |
---|
1508 | // not fully support iRatioTxtPerDepth* != 1 |
---|
1509 | Void TComPrediction::xGetVirtualDepth( TComDataCU *cu, TComPicYuv *picRefDepth, TComMv *mv, UInt partAddr, Int width, Int height, TComYuv *yuvDepth, Int ratioTxtPerDepthX, Int ratioTxtPerDepthY ) |
---|
1510 | { |
---|
1511 | Int nTxtPerDepthX = H_3D_VSP_BLOCKSIZE; |
---|
1512 | Int nTxtPerDepthY = H_3D_VSP_BLOCKSIZE; |
---|
1513 | |
---|
1514 | Int refDepStride = picRefDepth->getStride(); |
---|
1515 | |
---|
1516 | Int refDepOffset = ( (mv->getHor()+2) >> 2 ) + ( (mv->getVer()+2) >> 2 ) * refDepStride; |
---|
1517 | Pel *refDepth = picRefDepth->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ); |
---|
1518 | |
---|
1519 | if( ratioTxtPerDepthX!=1 || ratioTxtPerDepthY!=1 ) |
---|
1520 | { |
---|
1521 | Int posX, posY; |
---|
1522 | refDepth = picRefDepth->getLumaAddr( ); |
---|
1523 | cu->getPic()->getPicYuvRec()->getTopLeftSamplePos( cu->getAddr(), cu->getZorderIdxInCU() + partAddr, posX, posY ); // top-left position in texture |
---|
1524 | posX /= ratioTxtPerDepthX; // texture position -> depth postion |
---|
1525 | posY /= ratioTxtPerDepthY; |
---|
1526 | refDepOffset += posX + posY * refDepStride; |
---|
1527 | |
---|
1528 | width /= ratioTxtPerDepthX; // texture size -> depth size |
---|
1529 | height /= ratioTxtPerDepthY; |
---|
1530 | } |
---|
1531 | |
---|
1532 | refDepth += refDepOffset; |
---|
1533 | |
---|
1534 | Int depStride = yuvDepth->getStride(); |
---|
1535 | Pel *depth = yuvDepth->getLumaAddr(); |
---|
1536 | |
---|
1537 | if( width<8 || height<8 ) |
---|
1538 | { // no split |
---|
1539 | Int rightOffset = width - 1; |
---|
1540 | Int depStrideBlock = depStride * nTxtPerDepthY; |
---|
1541 | Pel *refDepthTop = refDepth; |
---|
1542 | Pel *refDepthBot = refDepthTop + (height-1)*refDepStride; |
---|
1543 | |
---|
1544 | Pel maxDepth = refDepthTop[0] > refDepthBot[0] ? refDepthTop[0] : refDepthBot[0]; |
---|
1545 | if( maxDepth < refDepthTop[rightOffset] ) { maxDepth = refDepthTop[rightOffset]; } |
---|
1546 | if( maxDepth < refDepthBot[rightOffset] ) { maxDepth = refDepthBot[rightOffset]; } |
---|
1547 | |
---|
1548 | for( Int sY=0; sY<height; sY+=nTxtPerDepthY ) |
---|
1549 | { |
---|
1550 | for( Int sX=0; sX<width; sX+=nTxtPerDepthX ) |
---|
1551 | { |
---|
1552 | depth[sX] = maxDepth; |
---|
1553 | } |
---|
1554 | depth += depStrideBlock; |
---|
1555 | } |
---|
1556 | } |
---|
1557 | else |
---|
1558 | { // split to 4x8, or 8x4 |
---|
1559 | Int blocksize = 8; |
---|
1560 | Int subblocksize = 4; |
---|
1561 | Int depStrideBlock = depStride * blocksize; |
---|
1562 | Pel *depthTmp = NULL; |
---|
1563 | Int depStrideTmp = depStride * nTxtPerDepthY; |
---|
1564 | Int offset[4] = { 0, subblocksize-1, subblocksize, blocksize-1 }; |
---|
1565 | Pel *refDepthTmp[4] = { NULL, NULL, NULL, NULL }; |
---|
1566 | Pel repDepth4x8[2] = {0, 0}; |
---|
1567 | Pel repDepth8x4[2] = {0, 0}; |
---|
1568 | |
---|
1569 | Int refDepStrideBlock = refDepStride * blocksize; |
---|
1570 | Int refDepStrideSubBlock = refDepStride * subblocksize; |
---|
1571 | |
---|
1572 | refDepthTmp[0] = refDepth; |
---|
1573 | refDepthTmp[2] = refDepthTmp[0] + refDepStrideSubBlock; |
---|
1574 | refDepthTmp[1] = refDepthTmp[2] - refDepStride; |
---|
1575 | refDepthTmp[3] = refDepthTmp[1] + refDepStrideSubBlock; |
---|
1576 | |
---|
1577 | for( Int y=0; y<height; y+=blocksize ) |
---|
1578 | { |
---|
1579 | for( Int x=0; x<width; x+=blocksize ) |
---|
1580 | { |
---|
1581 | Bool ULvsBR = false, URvsBL = false; |
---|
1582 | |
---|
1583 | ULvsBR = refDepthTmp[0][x+offset[0]] < refDepthTmp[3][x+offset[3]]; |
---|
1584 | URvsBL = refDepthTmp[0][x+offset[3]] < refDepthTmp[3][x+offset[0]]; |
---|
1585 | |
---|
1586 | if( ULvsBR ^ URvsBL ) |
---|
1587 | { // 4x8 |
---|
1588 | repDepth4x8[0] = refDepthTmp[0][x+offset[0]] > refDepthTmp[0][x+offset[1]] ? refDepthTmp[0][x+offset[0]] : refDepthTmp[0][x+offset[1]]; |
---|
1589 | if( repDepth4x8[0] < refDepthTmp[3][x+offset[0]] ) |
---|
1590 | { |
---|
1591 | repDepth4x8[0] = refDepthTmp[3][x+offset[0]]; |
---|
1592 | } |
---|
1593 | if( repDepth4x8[0] < refDepthTmp[3][x+offset[1]] ) |
---|
1594 | { |
---|
1595 | repDepth4x8[0] = refDepthTmp[3][x+offset[1]]; |
---|
1596 | } |
---|
1597 | repDepth4x8[1] = refDepthTmp[0][x+offset[2]] > refDepthTmp[0][x+offset[3]] ? refDepthTmp[0][x+offset[2]] : refDepthTmp[0][x+offset[3]]; |
---|
1598 | if( repDepth4x8[1] < refDepthTmp[3][x+offset[2]] ) |
---|
1599 | { |
---|
1600 | repDepth4x8[1] = refDepthTmp[3][x+offset[2]]; |
---|
1601 | } |
---|
1602 | if( repDepth4x8[1] < refDepthTmp[3][x+offset[3]] ) |
---|
1603 | { |
---|
1604 | repDepth4x8[1] = refDepthTmp[3][x+offset[3]]; |
---|
1605 | } |
---|
1606 | |
---|
1607 | depthTmp = &depth[x]; |
---|
1608 | for( Int sY=0; sY<blocksize; sY+=nTxtPerDepthY ) |
---|
1609 | { |
---|
1610 | for( Int sX=0; sX<subblocksize; sX+=nTxtPerDepthX ) |
---|
1611 | { |
---|
1612 | depthTmp[sX] = repDepth4x8[0]; |
---|
1613 | } |
---|
1614 | depthTmp += depStrideTmp; |
---|
1615 | } |
---|
1616 | depthTmp = &depth[x+subblocksize]; |
---|
1617 | for( Int sY=0; sY<blocksize; sY+=nTxtPerDepthY ) |
---|
1618 | { |
---|
1619 | for( Int sX=0; sX<subblocksize; sX+=nTxtPerDepthX ) |
---|
1620 | { |
---|
1621 | depthTmp[sX] = repDepth4x8[1]; |
---|
1622 | } |
---|
1623 | depthTmp += depStrideTmp; |
---|
1624 | } |
---|
1625 | } |
---|
1626 | else |
---|
1627 | { // 8x4 |
---|
1628 | repDepth8x4[0] = refDepthTmp[0][x+offset[0]] > refDepthTmp[0][x+offset[3]] ? refDepthTmp[0][x+offset[0]] : refDepthTmp[0][x+offset[3]]; |
---|
1629 | if( repDepth8x4[0] < refDepthTmp[1][x+offset[0]] ) |
---|
1630 | { |
---|
1631 | repDepth8x4[0] = refDepthTmp[1][x+offset[0]]; |
---|
1632 | } |
---|
1633 | if( repDepth8x4[0] < refDepthTmp[1][x+offset[3]] ) |
---|
1634 | { |
---|
1635 | repDepth8x4[0] = refDepthTmp[1][x+offset[3]]; |
---|
1636 | } |
---|
1637 | repDepth8x4[1] = refDepthTmp[2][x+offset[0]] > refDepthTmp[2][x+offset[3]] ? refDepthTmp[2][x+offset[0]] : refDepthTmp[2][x+offset[3]]; |
---|
1638 | if( repDepth8x4[1] < refDepthTmp[3][x+offset[0]] ) |
---|
1639 | { |
---|
1640 | repDepth8x4[1] = refDepthTmp[3][x+offset[0]]; |
---|
1641 | } |
---|
1642 | if( repDepth8x4[1] < refDepthTmp[3][x+offset[3]] ) |
---|
1643 | { |
---|
1644 | repDepth8x4[1] = refDepthTmp[3][x+offset[3]]; |
---|
1645 | } |
---|
1646 | |
---|
1647 | depthTmp = &depth[x]; |
---|
1648 | for( Int sY=0; sY<subblocksize; sY+=nTxtPerDepthY ) |
---|
1649 | { |
---|
1650 | for( Int sX=0; sX<blocksize; sX+=nTxtPerDepthX ) |
---|
1651 | { |
---|
1652 | depthTmp[sX] = repDepth8x4[0]; |
---|
1653 | } |
---|
1654 | depthTmp += depStrideTmp; |
---|
1655 | } |
---|
1656 | for( Int sY=0; sY<subblocksize; sY+=nTxtPerDepthY ) |
---|
1657 | { |
---|
1658 | for( Int sX=0; sX<blocksize; sX+=nTxtPerDepthX ) |
---|
1659 | { |
---|
1660 | depthTmp[sX] = repDepth8x4[1]; |
---|
1661 | } |
---|
1662 | depthTmp += depStrideTmp; |
---|
1663 | } |
---|
1664 | } |
---|
1665 | } |
---|
1666 | refDepthTmp[0] += refDepStrideBlock; |
---|
1667 | refDepthTmp[1] += refDepStrideBlock; |
---|
1668 | refDepthTmp[2] += refDepStrideBlock; |
---|
1669 | refDepthTmp[3] += refDepStrideBlock; |
---|
1670 | depth += depStrideBlock; |
---|
1671 | } |
---|
1672 | } |
---|
1673 | |
---|
1674 | |
---|
1675 | } |
---|
1676 | |
---|
1677 | Void TComPrediction::xPredInterLumaBlkFromDM( TComDataCU *cu, TComPicYuv *picRef, TComYuv *yuvDepth, Int* shiftLUT, TComMv *mv, UInt partAddr, Int width, Int height, Bool isDepth, TComYuv *&yuvDst, Bool isBi ) |
---|
1678 | { |
---|
1679 | Int nTxtPerDepthX = H_3D_VSP_BLOCKSIZE; |
---|
1680 | Int nTxtPerDepthY = H_3D_VSP_BLOCKSIZE; |
---|
1681 | |
---|
1682 | Int refStride = picRef->getStride(); |
---|
1683 | Int dstStride = yuvDst->getStride(); |
---|
1684 | Int depStride = yuvDepth->getStride(); |
---|
1685 | Int refStrideBlock = refStride * nTxtPerDepthY; |
---|
1686 | Int dstStrideBlock = dstStride * nTxtPerDepthY; |
---|
1687 | Int depStrideBlock = depStride * nTxtPerDepthY; |
---|
1688 | |
---|
1689 | Pel *ref = picRef->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ); |
---|
1690 | Pel *dst = yuvDst->getLumaAddr(partAddr); |
---|
1691 | Pel *depth = yuvDepth->getLumaAddr(); |
---|
1692 | |
---|
1693 | #if H_3D_VSP_BLOCKSIZE == 1 |
---|
1694 | #if H_3D_VSP_CONSTRAINED |
---|
1695 | //get LUT based horizontal reference range |
---|
1696 | Int range = xGetConstrainedSize(width, height); |
---|
1697 | |
---|
1698 | // The minimum depth value |
---|
1699 | Int minRelativePos = MAX_INT; |
---|
1700 | Int maxRelativePos = MIN_INT; |
---|
1701 | |
---|
1702 | Pel* depthTemp, *depthInitial=depth; |
---|
1703 | for (Int yTxt = 0; yTxt < height; yTxt++) |
---|
1704 | { |
---|
1705 | for (Int xTxt = 0; xTxt < width; xTxt++) |
---|
1706 | { |
---|
1707 | if (depthPosX+xTxt < widthDepth) |
---|
1708 | { |
---|
1709 | depthTemp = depthInitial + xTxt; |
---|
1710 | } |
---|
1711 | else |
---|
1712 | { |
---|
1713 | depthTemp = depthInitial + (widthDepth - depthPosX - 1); |
---|
1714 | } |
---|
1715 | |
---|
1716 | Int disparity = shiftLUT[ *depthTemp ]; // << iShiftPrec; |
---|
1717 | Int disparityInt = disparity >> 2; |
---|
1718 | |
---|
1719 | if( disparity <= 0) |
---|
1720 | { |
---|
1721 | if (minRelativePos > disparityInt+xTxt) |
---|
1722 | { |
---|
1723 | minRelativePos = disparityInt+xTxt; |
---|
1724 | } |
---|
1725 | } |
---|
1726 | else |
---|
1727 | { |
---|
1728 | if (maxRelativePos < disparityInt+xTxt) |
---|
1729 | { |
---|
1730 | maxRelativePos = disparityInt+xTxt; |
---|
1731 | } |
---|
1732 | } |
---|
1733 | } |
---|
1734 | if (depthPosY+yTxt < heightDepth) |
---|
1735 | { |
---|
1736 | depthInitial = depthInitial + depStride; |
---|
1737 | } |
---|
1738 | } |
---|
1739 | |
---|
1740 | Int disparity_tmp = shiftLUT[ *depth ]; // << iShiftPrec; |
---|
1741 | if (disparity_tmp <= 0) |
---|
1742 | { |
---|
1743 | maxRelativePos = minRelativePos + range -1 ; |
---|
1744 | } |
---|
1745 | else |
---|
1746 | { |
---|
1747 | minRelativePos = maxRelativePos - range +1 ; |
---|
1748 | } |
---|
1749 | #endif |
---|
1750 | #endif // H_3D_VSP_BLOCKSIZE == 1 |
---|
1751 | |
---|
1752 | TComMv dv(0, 0); |
---|
1753 | |
---|
1754 | for ( Int yTxt = 0; yTxt < height; yTxt += nTxtPerDepthY ) |
---|
1755 | { |
---|
1756 | for ( Int xTxt = 0; xTxt < width; xTxt += nTxtPerDepthX ) |
---|
1757 | { |
---|
1758 | Pel repDepth = depth[ xTxt ]; |
---|
1759 | assert( repDepth >= 0 && repDepth <= 255 ); |
---|
1760 | |
---|
1761 | Int disparity = shiftLUT[ repDepth ]; // remove << iShiftPrec ?? |
---|
1762 | Int xFrac = disparity & 0x3; |
---|
1763 | |
---|
1764 | dv.setHor( disparity ); |
---|
1765 | cu->clipMv( dv ); |
---|
1766 | |
---|
1767 | Int refOffset = xTxt + (dv.getHor() >> 2); |
---|
1768 | |
---|
1769 | #if H_3D_VSP_CONSTRAINED |
---|
1770 | if(refOffset<minRelativePos || refOffset>maxRelativePos) |
---|
1771 | { |
---|
1772 | xFrac = 0; |
---|
1773 | } |
---|
1774 | refOffset = Clip3(minRelativePos, maxRelativePos, refOffset); |
---|
1775 | #endif |
---|
1776 | |
---|
1777 | assert( ref[refOffset] >= 0 && ref[refOffset]<= 255 ); |
---|
1778 | m_if.filterHorLuma( &ref[refOffset], refStride, &dst[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !isBi ); |
---|
1779 | } |
---|
1780 | ref += refStrideBlock; |
---|
1781 | dst += dstStrideBlock; |
---|
1782 | depth += depStrideBlock; |
---|
1783 | } |
---|
1784 | |
---|
1785 | } |
---|
1786 | |
---|
1787 | Void TComPrediction::xPredInterChromaBlkFromDM ( TComDataCU *cu, TComPicYuv *picRef, TComYuv *yuvDepth, Int* shiftLUT, TComMv *mv, UInt partAddr, Int width, Int height, Bool isDepth, TComYuv *&yuvDst, Bool isBi ) |
---|
1788 | { |
---|
1789 | #if (H_3D_VSP_BLOCKSIZE==1) |
---|
1790 | Int nTxtPerDepthX = 1; |
---|
1791 | Int nTxtPerDepthY = 1; |
---|
1792 | #else |
---|
1793 | Int nTxtPerDepthX = H_3D_VSP_BLOCKSIZE >> 1; |
---|
1794 | Int nTxtPerDepthY = H_3D_VSP_BLOCKSIZE >> 1; |
---|
1795 | #endif |
---|
1796 | |
---|
1797 | Int refStride = picRef->getCStride(); |
---|
1798 | Int dstStride = yuvDst->getCStride(); |
---|
1799 | Int depStride = yuvDepth->getStride(); |
---|
1800 | Int refStrideBlock = refStride * nTxtPerDepthY; |
---|
1801 | Int dstStrideBlock = dstStride * nTxtPerDepthY; |
---|
1802 | Int depStrideBlock = depStride * (nTxtPerDepthY<<1); |
---|
1803 | |
---|
1804 | Pel *refCb = picRef->getCbAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ); |
---|
1805 | Pel *refCr = picRef->getCrAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ); |
---|
1806 | Pel *dstCb = yuvDst->getCbAddr(partAddr); |
---|
1807 | Pel *dstCr = yuvDst->getCrAddr(partAddr); |
---|
1808 | Pel *depth = yuvDepth->getLumaAddr(); |
---|
1809 | |
---|
1810 | #if H_3D_VSP_BLOCKSIZE == 1 |
---|
1811 | #if H_3D_VSP_CONSTRAINED |
---|
1812 | //get LUT based horizontal reference range |
---|
1813 | Int range = xGetConstrainedSize(width, height, false); |
---|
1814 | |
---|
1815 | // The minimum depth value |
---|
1816 | Int minRelativePos = MAX_INT; |
---|
1817 | Int maxRelativePos = MIN_INT; |
---|
1818 | |
---|
1819 | Int depthTmp; |
---|
1820 | for (Int yTxt=0; yTxt<height; yTxt++) |
---|
1821 | { |
---|
1822 | for (Int xTxt=0; xTxt<width; xTxt++) |
---|
1823 | { |
---|
1824 | depthTmp = m_pDepthBlock[xTxt+yTxt*width]; |
---|
1825 | Int disparity = shiftLUT[ depthTmp ]; // << iShiftPrec; |
---|
1826 | Int disparityInt = disparity >> 3;//in chroma resolution |
---|
1827 | |
---|
1828 | if (disparityInt < 0) |
---|
1829 | { |
---|
1830 | if (minRelativePos > disparityInt+xTxt) |
---|
1831 | { |
---|
1832 | minRelativePos = disparityInt+xTxt; |
---|
1833 | } |
---|
1834 | } |
---|
1835 | else |
---|
1836 | { |
---|
1837 | if (maxRelativePos < disparityInt+xTxt) |
---|
1838 | { |
---|
1839 | maxRelativePos = disparityInt+xTxt; |
---|
1840 | } |
---|
1841 | } |
---|
1842 | } |
---|
1843 | } |
---|
1844 | |
---|
1845 | depthTmp = m_pDepthBlock[0]; |
---|
1846 | Int disparity_tmp = shiftLUT[ depthTmp ]; // << iShiftPrec; |
---|
1847 | if ( disparity_tmp < 0 ) |
---|
1848 | { |
---|
1849 | maxRelativePos = minRelativePos + range - 1; |
---|
1850 | } |
---|
1851 | else |
---|
1852 | { |
---|
1853 | minRelativePos = maxRelativePos - range + 1; |
---|
1854 | } |
---|
1855 | |
---|
1856 | #endif // H_3D_VSP_CONSTRAINED |
---|
1857 | #endif // H_3D_VSP_BLOCKSIZE == 1 |
---|
1858 | |
---|
1859 | TComMv dv(0, 0); |
---|
1860 | // luma size -> chroma size |
---|
1861 | height >>= 1; |
---|
1862 | width >>= 1; |
---|
1863 | |
---|
1864 | for ( Int yTxt = 0; yTxt < height; yTxt += nTxtPerDepthY ) |
---|
1865 | { |
---|
1866 | for ( Int xTxt = 0; xTxt < width; xTxt += nTxtPerDepthX ) |
---|
1867 | { |
---|
1868 | Pel repDepth = depth[ xTxt<<1 ]; |
---|
1869 | assert( repDepth >= 0 && repDepth <= 255 ); |
---|
1870 | |
---|
1871 | Int disparity = shiftLUT[ repDepth ]; // remove << iShiftPrec; |
---|
1872 | Int xFrac = disparity & 0x7; |
---|
1873 | |
---|
1874 | dv.setHor( disparity ); |
---|
1875 | cu->clipMv( dv ); |
---|
1876 | |
---|
1877 | Int refOffset = xTxt + (dv.getHor() >> 3); |
---|
1878 | |
---|
1879 | #if H_3D_VSP_CONSTRAINED |
---|
1880 | if(refOffset<minRelativePos || refOffset>maxRelativePos) |
---|
1881 | { |
---|
1882 | xFrac = 0; |
---|
1883 | } |
---|
1884 | refOffset = Clip3(minRelativePos, maxRelativePos, refOffset); |
---|
1885 | #endif |
---|
1886 | |
---|
1887 | assert( refCb[refOffset] >= 0 && refCb[refOffset]<= 255 ); |
---|
1888 | assert( refCr[refOffset] >= 0 && refCr[refOffset]<= 255 ); |
---|
1889 | |
---|
1890 | m_if.filterHorChroma( &refCb[refOffset], refStride, &dstCb[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !isBi ); |
---|
1891 | m_if.filterHorChroma( &refCr[refOffset], refStride, &dstCr[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !isBi ); |
---|
1892 | } |
---|
1893 | refCb += refStrideBlock; |
---|
1894 | refCr += refStrideBlock; |
---|
1895 | dstCb += dstStrideBlock; |
---|
1896 | dstCr += dstStrideBlock; |
---|
1897 | depth += depStrideBlock; |
---|
1898 | } |
---|
1899 | } |
---|
1900 | |
---|
1901 | |
---|
1902 | #if H_3D_VSP_CONSTRAINED |
---|
1903 | Int TComPrediction::xGetConstrainedSize(Int nPbW, Int nPbH, Bool bLuma) |
---|
1904 | { |
---|
1905 | Int iSize = 0; |
---|
1906 | if (bLuma) |
---|
1907 | { |
---|
1908 | Int iArea = (nPbW+7) * (nPbH+7); |
---|
1909 | Int iAlpha = iArea / nPbH - nPbW - 7; |
---|
1910 | iSize = iAlpha + nPbW; |
---|
1911 | } |
---|
1912 | else // chroma |
---|
1913 | { |
---|
1914 | Int iArea = (nPbW+2) * (nPbH+2); |
---|
1915 | Int iAlpha = iArea / nPbH - nPbW - 4; |
---|
1916 | iSize = iAlpha + nPbW; |
---|
1917 | } |
---|
1918 | return iSize; |
---|
1919 | } |
---|
1920 | #endif // H_3D_VSP_CONSTRAINED |
---|
1921 | |
---|
1922 | #endif // H_3D_VSP |
---|
1923 | |
---|
1924 | #if H_3D_DIM |
---|
1925 | Void TComPrediction::xPredBiSegDCs( Int* ptrSrc, UInt srcStride, Bool* biSegPattern, Int patternStride, Pel& predDC1, Pel& predDC2 ) |
---|
1926 | { |
---|
1927 | Int refDC1, refDC2; |
---|
1928 | const Int iTR = ( patternStride - 1 ) - srcStride; |
---|
1929 | const Int iTM = ( ( patternStride - 1 ) >> 1 ) - srcStride; |
---|
1930 | const Int iLB = ( patternStride - 1 ) * srcStride - 1; |
---|
1931 | const Int iLM = ( ( patternStride - 1 ) >> 1 ) * srcStride - 1; |
---|
1932 | |
---|
1933 | Bool bL = ( biSegPattern[0] != biSegPattern[(patternStride-1)*patternStride] ); |
---|
1934 | Bool bT = ( biSegPattern[0] != biSegPattern[(patternStride-1)] ); |
---|
1935 | |
---|
1936 | if( bL == bT ) |
---|
1937 | { |
---|
1938 | refDC1 = bL ? ( ptrSrc[iTR] + ptrSrc[iLB] )>>1 : 1<<( g_bitDepthY - 1 ); |
---|
1939 | refDC2 = ( ptrSrc[ -1] + ptrSrc[-(Int)srcStride] )>>1; |
---|
1940 | } |
---|
1941 | else |
---|
1942 | { |
---|
1943 | refDC1 = bL ? ptrSrc[iLB] : ptrSrc[iTR]; |
---|
1944 | refDC2 = bL ? ptrSrc[iTM] : ptrSrc[iLM]; |
---|
1945 | } |
---|
1946 | |
---|
1947 | predDC1 = biSegPattern[0] ? refDC1 : refDC2; |
---|
1948 | predDC2 = biSegPattern[0] ? refDC2 : refDC1; |
---|
1949 | } |
---|
1950 | |
---|
1951 | Void TComPrediction::xAssignBiSegDCs( Pel* ptrDst, UInt dstStride, Bool* biSegPattern, Int patternStride, Pel valDC1, Pel valDC2 ) |
---|
1952 | { |
---|
1953 | if( dstStride == patternStride ) |
---|
1954 | { |
---|
1955 | for( UInt k = 0; k < (patternStride * patternStride); k++ ) |
---|
1956 | { |
---|
1957 | if( true == biSegPattern[k] ) { ptrDst[k] = valDC2; } |
---|
1958 | else { ptrDst[k] = valDC1; } |
---|
1959 | } |
---|
1960 | } |
---|
1961 | else |
---|
1962 | { |
---|
1963 | Pel* piTemp = ptrDst; |
---|
1964 | for( UInt uiY = 0; uiY < patternStride; uiY++ ) |
---|
1965 | { |
---|
1966 | for( UInt uiX = 0; uiX < patternStride; uiX++ ) |
---|
1967 | { |
---|
1968 | if( true == biSegPattern[uiX] ) { piTemp[uiX] = valDC2; } |
---|
1969 | else { piTemp[uiX] = valDC1; } |
---|
1970 | } |
---|
1971 | piTemp += dstStride; |
---|
1972 | biSegPattern += patternStride; |
---|
1973 | } |
---|
1974 | } |
---|
1975 | } |
---|
1976 | |
---|
1977 | #if H_3D_DIM_DMM |
---|
1978 | UInt TComPrediction::xPredWedgeFromTex( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt intraTabIdx ) |
---|
1979 | { |
---|
1980 | TComPic* pcPicTex = pcCU->getSlice()->getTexturePic(); |
---|
1981 | assert( pcPicTex != NULL ); |
---|
1982 | TComDataCU* pcColTexCU = pcPicTex->getCU(pcCU->getAddr()); |
---|
1983 | UInt uiTexPartIdx = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
1984 | Int uiColTexIntraDir = pcColTexCU->isIntra( uiTexPartIdx ) ? pcColTexCU->getLumaIntraDir( uiTexPartIdx ) : 255; |
---|
1985 | |
---|
1986 | assert( uiColTexIntraDir > DC_IDX && uiColTexIntraDir < 35 ); |
---|
1987 | return g_aauiWdgLstM3[g_aucConvertToBit[uiWidth]][uiColTexIntraDir-2].at(intraTabIdx); |
---|
1988 | } |
---|
1989 | |
---|
1990 | Void TComPrediction::xPredContourFromTex( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, TComWedgelet* pcContourWedge ) |
---|
1991 | { |
---|
1992 | pcContourWedge->clear(); |
---|
1993 | |
---|
1994 | // get copy of co-located texture luma block |
---|
1995 | TComYuv cTempYuv; |
---|
1996 | cTempYuv.create( uiWidth, uiHeight ); |
---|
1997 | cTempYuv.clear(); |
---|
1998 | Pel* piRefBlkY = cTempYuv.getLumaAddr(); |
---|
1999 | xCopyTextureLumaBlock( pcCU, uiAbsPartIdx, piRefBlkY, uiWidth, uiHeight ); |
---|
2000 | piRefBlkY = cTempYuv.getLumaAddr(); |
---|
2001 | |
---|
2002 | // find contour for texture luma block |
---|
2003 | UInt iDC = 0; |
---|
2004 | for( UInt k = 0; k < (uiWidth*uiHeight); k++ ) |
---|
2005 | { |
---|
2006 | iDC += piRefBlkY[k]; |
---|
2007 | } |
---|
2008 | |
---|
2009 | Int cuMaxLog2Size = g_aucConvertToBit[g_uiMaxCUWidth]+2; // |
---|
2010 | iDC = iDC >> (cuMaxLog2Size - pcCU->getDepth(0))*2; // iDC /= (uiWidth*uiHeight); |
---|
2011 | |
---|
2012 | piRefBlkY = cTempYuv.getLumaAddr(); |
---|
2013 | |
---|
2014 | Bool* pabContourPattern = pcContourWedge->getPattern(); |
---|
2015 | for( UInt k = 0; k < (uiWidth*uiHeight); k++ ) |
---|
2016 | { |
---|
2017 | pabContourPattern[k] = (piRefBlkY[k] > iDC) ? true : false; |
---|
2018 | } |
---|
2019 | |
---|
2020 | cTempYuv.destroy(); |
---|
2021 | } |
---|
2022 | |
---|
2023 | |
---|
2024 | Void TComPrediction::xCopyTextureLumaBlock( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piDestBlockY, UInt uiWidth, UInt uiHeight ) |
---|
2025 | { |
---|
2026 | TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getTexturePic()->getPicYuvRec(); |
---|
2027 | assert( pcPicYuvRef != NULL ); |
---|
2028 | Int iRefStride = pcPicYuvRef->getStride(); |
---|
2029 | Pel* piRefY = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiAbsPartIdx ); |
---|
2030 | |
---|
2031 | for ( Int y = 0; y < uiHeight; y++ ) |
---|
2032 | { |
---|
2033 | ::memcpy(piDestBlockY, piRefY, sizeof(Pel)*uiWidth); |
---|
2034 | piDestBlockY += uiWidth; |
---|
2035 | piRefY += iRefStride; |
---|
2036 | } |
---|
2037 | } |
---|
2038 | #endif |
---|
2039 | |
---|
2040 | #if H_3D_DIM_RBC |
---|
2041 | Void TComPrediction::xDeltaDCQuantScaleUp( TComDataCU* pcCU, Pel& rDeltaDC ) |
---|
2042 | { |
---|
2043 | Int iSign = rDeltaDC < 0 ? -1 : 1; |
---|
2044 | UInt uiAbs = abs( rDeltaDC ); |
---|
2045 | |
---|
2046 | Int iQp = pcCU->getQP(0); |
---|
2047 | Double dMax = (Double)( 1<<( g_bitDepthY - 1 ) ); |
---|
2048 | Double dStepSize = Clip3( 1.0, dMax, pow( 2.0, iQp/10.0 - 2.0 ) ); |
---|
2049 | |
---|
2050 | rDeltaDC = iSign * roftoi( uiAbs * dStepSize ); |
---|
2051 | return; |
---|
2052 | } |
---|
2053 | |
---|
2054 | Void TComPrediction::xDeltaDCQuantScaleDown( TComDataCU* pcCU, Pel& rDeltaDC ) |
---|
2055 | { |
---|
2056 | Int iSign = rDeltaDC < 0 ? -1 : 1; |
---|
2057 | UInt uiAbs = abs( rDeltaDC ); |
---|
2058 | |
---|
2059 | Int iQp = pcCU->getQP(0); |
---|
2060 | Double dMax = (Double)( 1<<( g_bitDepthY - 1 ) ); |
---|
2061 | Double dStepSize = Clip3( 1.0, dMax, pow( 2.0, iQp/10.0 - 2.0 ) ); |
---|
2062 | |
---|
2063 | rDeltaDC = iSign * roftoi( uiAbs / dStepSize ); |
---|
2064 | return; |
---|
2065 | } |
---|
2066 | #endif |
---|
2067 | #if H_3D_DIM_SDC |
---|
2068 | Void TComPrediction::analyzeSegmentsSDC( Pel* pOrig, UInt uiStride, UInt uiSize, Pel* rpSegMeans, UInt uiNumSegments, Bool* pMask, UInt uiMaskStride |
---|
2069 | ,UInt uiIntraMode |
---|
2070 | ,Bool orgDC |
---|
2071 | ) |
---|
2072 | { |
---|
2073 | Int iSumDepth[2]; |
---|
2074 | memset(iSumDepth, 0, sizeof(Int)*2); |
---|
2075 | Int iSumPix[2]; |
---|
2076 | memset(iSumPix, 0, sizeof(Int)*2); |
---|
2077 | |
---|
2078 | if (orgDC == false) |
---|
2079 | { |
---|
2080 | if ( getDimType(uiIntraMode) == DMM1_IDX ) |
---|
2081 | { |
---|
2082 | UChar ucSegmentLT = pMask[0]; |
---|
2083 | UChar ucSegmentRT = pMask[uiSize-1]; |
---|
2084 | UChar ucSegmentLB = pMask[uiMaskStride * (uiSize-1)]; |
---|
2085 | UChar ucSegmentRB = pMask[uiMaskStride * (uiSize-1) + (uiSize-1)]; |
---|
2086 | |
---|
2087 | rpSegMeans[ucSegmentLT] = pOrig[0]; |
---|
2088 | rpSegMeans[ucSegmentRT] = pOrig[uiSize-1]; |
---|
2089 | rpSegMeans[ucSegmentLB] = pOrig[uiStride * (uiSize-1) ]; |
---|
2090 | rpSegMeans[ucSegmentRB] = pOrig[uiStride * (uiSize-1) + (uiSize-1) ]; |
---|
2091 | } |
---|
2092 | else if (uiIntraMode == PLANAR_IDX) |
---|
2093 | { |
---|
2094 | Pel* pLeftTop = pOrig; |
---|
2095 | Pel* pRightTop = pOrig + (uiSize-1); |
---|
2096 | Pel* pLeftBottom = (pOrig+ (uiStride*(uiSize-1))); |
---|
2097 | Pel* pRightBottom = (pOrig+ (uiStride*(uiSize-1)) + (uiSize-1)); |
---|
2098 | |
---|
2099 | rpSegMeans[0] = (*pLeftTop + *pRightTop + *pLeftBottom + *pRightBottom + 2)>>2; |
---|
2100 | } |
---|
2101 | return; |
---|
2102 | } |
---|
2103 | |
---|
2104 | Int subSamplePix; |
---|
2105 | if ( uiSize == 64 || uiSize == 32 ) |
---|
2106 | { |
---|
2107 | subSamplePix = 2; |
---|
2108 | } |
---|
2109 | else |
---|
2110 | { |
---|
2111 | subSamplePix = 1; |
---|
2112 | } |
---|
2113 | for (Int y=0; y<uiSize; y+=subSamplePix) |
---|
2114 | { |
---|
2115 | for (Int x=0; x<uiSize; x+=subSamplePix) |
---|
2116 | { |
---|
2117 | UChar ucSegment = pMask?(UChar)pMask[x]:0; |
---|
2118 | assert( ucSegment < uiNumSegments ); |
---|
2119 | |
---|
2120 | iSumDepth[ucSegment] += pOrig[x]; |
---|
2121 | iSumPix[ucSegment] += 1; |
---|
2122 | } |
---|
2123 | |
---|
2124 | pOrig += uiStride*subSamplePix; |
---|
2125 | pMask += uiMaskStride*subSamplePix; |
---|
2126 | } |
---|
2127 | |
---|
2128 | // compute mean for each segment |
---|
2129 | for( UChar ucSeg = 0; ucSeg < uiNumSegments; ucSeg++ ) |
---|
2130 | { |
---|
2131 | if( iSumPix[ucSeg] > 0 ) |
---|
2132 | rpSegMeans[ucSeg] = iSumDepth[ucSeg] / iSumPix[ucSeg]; |
---|
2133 | else |
---|
2134 | rpSegMeans[ucSeg] = 0; // this happens for zero-segments |
---|
2135 | } |
---|
2136 | } |
---|
2137 | #endif // H_3D_DIM_SDC |
---|
2138 | #endif |
---|
2139 | //! \} |
---|