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 | #if SHARP_ILLUCOMP_REFINE_E0046 |
---|
42 | #define IC_REG_COST_SHIFT 7 |
---|
43 | #define IC_CONST_SHIFT 5 |
---|
44 | #define IC_SHIFT_DIFF 12 |
---|
45 | #endif |
---|
46 | |
---|
47 | //! \ingroup TLibCommon |
---|
48 | //! \{ |
---|
49 | |
---|
50 | // ==================================================================================================================== |
---|
51 | // Constructor / destructor / initialize |
---|
52 | // ==================================================================================================================== |
---|
53 | |
---|
54 | TComPrediction::TComPrediction() |
---|
55 | : m_pLumaRecBuffer(0) |
---|
56 | , m_iLumaRecStride(0) |
---|
57 | { |
---|
58 | m_piYuvExt = NULL; |
---|
59 | #if H_3D_VSP |
---|
60 | m_pDepthBlock = (Int*) malloc(MAX_NUM_SPU_W*MAX_NUM_SPU_W*sizeof(Int)); |
---|
61 | if (m_pDepthBlock == NULL) |
---|
62 | printf("ERROR: UKTGHU, No memory allocated.\n"); |
---|
63 | #endif |
---|
64 | } |
---|
65 | |
---|
66 | TComPrediction::~TComPrediction() |
---|
67 | { |
---|
68 | #if H_3D_VSP |
---|
69 | if (m_pDepthBlock != NULL) |
---|
70 | free(m_pDepthBlock); |
---|
71 | #if NTT_VSP_COMMON_E0207_E0208 |
---|
72 | m_cYuvDepthOnVsp.destroy(); |
---|
73 | #endif |
---|
74 | #endif |
---|
75 | |
---|
76 | delete[] m_piYuvExt; |
---|
77 | |
---|
78 | m_acYuvPred[0].destroy(); |
---|
79 | m_acYuvPred[1].destroy(); |
---|
80 | |
---|
81 | m_cYuvPredTemp.destroy(); |
---|
82 | |
---|
83 | #if H_3D_ARP |
---|
84 | m_acYuvPredBase[0].destroy(); |
---|
85 | m_acYuvPredBase[1].destroy(); |
---|
86 | #endif |
---|
87 | if( m_pLumaRecBuffer ) |
---|
88 | { |
---|
89 | delete [] m_pLumaRecBuffer; |
---|
90 | } |
---|
91 | |
---|
92 | Int i, j; |
---|
93 | for (i = 0; i < 4; i++) |
---|
94 | { |
---|
95 | for (j = 0; j < 4; j++) |
---|
96 | { |
---|
97 | m_filteredBlock[i][j].destroy(); |
---|
98 | } |
---|
99 | m_filteredBlockTmp[i].destroy(); |
---|
100 | } |
---|
101 | } |
---|
102 | |
---|
103 | Void TComPrediction::initTempBuff() |
---|
104 | { |
---|
105 | if( m_piYuvExt == NULL ) |
---|
106 | { |
---|
107 | Int extWidth = MAX_CU_SIZE + 16; |
---|
108 | Int extHeight = MAX_CU_SIZE + 1; |
---|
109 | Int i, j; |
---|
110 | for (i = 0; i < 4; i++) |
---|
111 | { |
---|
112 | m_filteredBlockTmp[i].create(extWidth, extHeight + 7); |
---|
113 | for (j = 0; j < 4; j++) |
---|
114 | { |
---|
115 | m_filteredBlock[i][j].create(extWidth, extHeight); |
---|
116 | } |
---|
117 | } |
---|
118 | m_iYuvExtHeight = ((MAX_CU_SIZE + 2) << 4); |
---|
119 | m_iYuvExtStride = ((MAX_CU_SIZE + 8) << 4); |
---|
120 | m_piYuvExt = new Int[ m_iYuvExtStride * m_iYuvExtHeight ]; |
---|
121 | |
---|
122 | // new structure |
---|
123 | m_acYuvPred[0] .create( MAX_CU_SIZE, MAX_CU_SIZE ); |
---|
124 | m_acYuvPred[1] .create( MAX_CU_SIZE, MAX_CU_SIZE ); |
---|
125 | |
---|
126 | m_cYuvPredTemp.create( MAX_CU_SIZE, MAX_CU_SIZE ); |
---|
127 | #if H_3D_ARP |
---|
128 | m_acYuvPredBase[0] .create( g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
129 | m_acYuvPredBase[1] .create( g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
130 | #endif |
---|
131 | #if NTT_VSP_COMMON_E0207_E0208 |
---|
132 | m_cYuvDepthOnVsp.create( g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
133 | #endif |
---|
134 | } |
---|
135 | |
---|
136 | if (m_iLumaRecStride != (MAX_CU_SIZE>>1) + 1) |
---|
137 | { |
---|
138 | m_iLumaRecStride = (MAX_CU_SIZE>>1) + 1; |
---|
139 | if (!m_pLumaRecBuffer) |
---|
140 | { |
---|
141 | m_pLumaRecBuffer = new Pel[ m_iLumaRecStride * m_iLumaRecStride ]; |
---|
142 | } |
---|
143 | } |
---|
144 | #if H_3D_IC |
---|
145 | #if SHARP_ILLUCOMP_REFINE_E0046 |
---|
146 | m_uiaShift[0] = 0; |
---|
147 | for( Int i = 1; i < 64; i++ ) |
---|
148 | { |
---|
149 | m_uiaShift[i] = ( (1 << 15) + i/2 ) / i; |
---|
150 | } |
---|
151 | #else |
---|
152 | for( Int i = 1; i < 64; i++ ) |
---|
153 | { |
---|
154 | m_uiaShift[i-1] = ( (1 << 15) + i/2 ) / i; |
---|
155 | } |
---|
156 | #endif |
---|
157 | #endif |
---|
158 | } |
---|
159 | |
---|
160 | // ==================================================================================================================== |
---|
161 | // Public member functions |
---|
162 | // ==================================================================================================================== |
---|
163 | |
---|
164 | // Function for calculating DC value of the reference samples used in Intra prediction |
---|
165 | Pel TComPrediction::predIntraGetPredValDC( Int* pSrc, Int iSrcStride, UInt iWidth, UInt iHeight, Bool bAbove, Bool bLeft ) |
---|
166 | { |
---|
167 | assert(iWidth > 0 && iHeight > 0); |
---|
168 | Int iInd, iSum = 0; |
---|
169 | Pel pDcVal; |
---|
170 | |
---|
171 | if (bAbove) |
---|
172 | { |
---|
173 | for (iInd = 0;iInd < iWidth;iInd++) |
---|
174 | { |
---|
175 | iSum += pSrc[iInd-iSrcStride]; |
---|
176 | } |
---|
177 | } |
---|
178 | if (bLeft) |
---|
179 | { |
---|
180 | for (iInd = 0;iInd < iHeight;iInd++) |
---|
181 | { |
---|
182 | iSum += pSrc[iInd*iSrcStride-1]; |
---|
183 | } |
---|
184 | } |
---|
185 | |
---|
186 | if (bAbove && bLeft) |
---|
187 | { |
---|
188 | pDcVal = (iSum + iWidth) / (iWidth + iHeight); |
---|
189 | } |
---|
190 | else if (bAbove) |
---|
191 | { |
---|
192 | pDcVal = (iSum + iWidth/2) / iWidth; |
---|
193 | } |
---|
194 | else if (bLeft) |
---|
195 | { |
---|
196 | pDcVal = (iSum + iHeight/2) / iHeight; |
---|
197 | } |
---|
198 | else |
---|
199 | { |
---|
200 | pDcVal = pSrc[-1]; // Default DC value already calculated and placed in the prediction array if no neighbors are available |
---|
201 | } |
---|
202 | |
---|
203 | return pDcVal; |
---|
204 | } |
---|
205 | |
---|
206 | // Function for deriving the angular Intra predictions |
---|
207 | |
---|
208 | /** Function for deriving the simplified angular intra predictions. |
---|
209 | * \param pSrc pointer to reconstructed sample array |
---|
210 | * \param srcStride the stride of the reconstructed sample array |
---|
211 | * \param rpDst reference to pointer for the prediction sample array |
---|
212 | * \param dstStride the stride of the prediction sample array |
---|
213 | * \param width the width of the block |
---|
214 | * \param height the height of the block |
---|
215 | * \param dirMode the intra prediction mode index |
---|
216 | * \param blkAboveAvailable boolean indication if the block above is available |
---|
217 | * \param blkLeftAvailable boolean indication if the block to the left is available |
---|
218 | * |
---|
219 | * This function derives the prediction samples for the angular mode based on the prediction direction indicated by |
---|
220 | * the prediction mode index. The prediction direction is given by the displacement of the bottom row of the block and |
---|
221 | * the reference row above the block in the case of vertical prediction or displacement of the rightmost column |
---|
222 | * of the block and reference column left from the block in the case of the horizontal prediction. The displacement |
---|
223 | * is signalled at 1/32 pixel accuracy. When projection of the predicted pixel falls inbetween reference samples, |
---|
224 | * the predicted value for the pixel is linearly interpolated from the reference samples. All reference samples are taken |
---|
225 | * from the extended main reference. |
---|
226 | */ |
---|
227 | 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 ) |
---|
228 | { |
---|
229 | Int k,l; |
---|
230 | Int blkSize = width; |
---|
231 | Pel* pDst = rpDst; |
---|
232 | |
---|
233 | // Map the mode index to main prediction direction and angle |
---|
234 | assert( dirMode > 0 ); //no planar |
---|
235 | Bool modeDC = dirMode < 2; |
---|
236 | Bool modeHor = !modeDC && (dirMode < 18); |
---|
237 | Bool modeVer = !modeDC && !modeHor; |
---|
238 | Int intraPredAngle = modeVer ? (Int)dirMode - VER_IDX : modeHor ? -((Int)dirMode - HOR_IDX) : 0; |
---|
239 | Int absAng = abs(intraPredAngle); |
---|
240 | Int signAng = intraPredAngle < 0 ? -1 : 1; |
---|
241 | |
---|
242 | // Set bitshifts and scale the angle parameter to block size |
---|
243 | Int angTable[9] = {0, 2, 5, 9, 13, 17, 21, 26, 32}; |
---|
244 | Int invAngTable[9] = {0, 4096, 1638, 910, 630, 482, 390, 315, 256}; // (256 * 32) / Angle |
---|
245 | Int invAngle = invAngTable[absAng]; |
---|
246 | absAng = angTable[absAng]; |
---|
247 | intraPredAngle = signAng * absAng; |
---|
248 | |
---|
249 | // Do the DC prediction |
---|
250 | if (modeDC) |
---|
251 | { |
---|
252 | Pel dcval = predIntraGetPredValDC(pSrc, srcStride, width, height, blkAboveAvailable, blkLeftAvailable); |
---|
253 | |
---|
254 | for (k=0;k<blkSize;k++) |
---|
255 | { |
---|
256 | for (l=0;l<blkSize;l++) |
---|
257 | { |
---|
258 | pDst[k*dstStride+l] = dcval; |
---|
259 | } |
---|
260 | } |
---|
261 | } |
---|
262 | |
---|
263 | // Do angular predictions |
---|
264 | else |
---|
265 | { |
---|
266 | Pel* refMain; |
---|
267 | Pel* refSide; |
---|
268 | Pel refAbove[2*MAX_CU_SIZE+1]; |
---|
269 | Pel refLeft[2*MAX_CU_SIZE+1]; |
---|
270 | |
---|
271 | // Initialise the Main and Left reference array. |
---|
272 | if (intraPredAngle < 0) |
---|
273 | { |
---|
274 | for (k=0;k<blkSize+1;k++) |
---|
275 | { |
---|
276 | refAbove[k+blkSize-1] = pSrc[k-srcStride-1]; |
---|
277 | } |
---|
278 | for (k=0;k<blkSize+1;k++) |
---|
279 | { |
---|
280 | refLeft[k+blkSize-1] = pSrc[(k-1)*srcStride-1]; |
---|
281 | } |
---|
282 | refMain = (modeVer ? refAbove : refLeft) + (blkSize-1); |
---|
283 | refSide = (modeVer ? refLeft : refAbove) + (blkSize-1); |
---|
284 | |
---|
285 | // Extend the Main reference to the left. |
---|
286 | Int invAngleSum = 128; // rounding for (shift by 8) |
---|
287 | for (k=-1; k>blkSize*intraPredAngle>>5; k--) |
---|
288 | { |
---|
289 | invAngleSum += invAngle; |
---|
290 | refMain[k] = refSide[invAngleSum>>8]; |
---|
291 | } |
---|
292 | } |
---|
293 | else |
---|
294 | { |
---|
295 | for (k=0;k<2*blkSize+1;k++) |
---|
296 | { |
---|
297 | refAbove[k] = pSrc[k-srcStride-1]; |
---|
298 | } |
---|
299 | for (k=0;k<2*blkSize+1;k++) |
---|
300 | { |
---|
301 | refLeft[k] = pSrc[(k-1)*srcStride-1]; |
---|
302 | } |
---|
303 | refMain = modeVer ? refAbove : refLeft; |
---|
304 | refSide = modeVer ? refLeft : refAbove; |
---|
305 | } |
---|
306 | |
---|
307 | if (intraPredAngle == 0) |
---|
308 | { |
---|
309 | for (k=0;k<blkSize;k++) |
---|
310 | { |
---|
311 | for (l=0;l<blkSize;l++) |
---|
312 | { |
---|
313 | pDst[k*dstStride+l] = refMain[l+1]; |
---|
314 | } |
---|
315 | } |
---|
316 | |
---|
317 | if ( bFilter ) |
---|
318 | { |
---|
319 | for (k=0;k<blkSize;k++) |
---|
320 | { |
---|
321 | pDst[k*dstStride] = Clip3(0, (1<<bitDepth)-1, pDst[k*dstStride] + (( refSide[k+1] - refSide[0] ) >> 1) ); |
---|
322 | } |
---|
323 | } |
---|
324 | } |
---|
325 | else |
---|
326 | { |
---|
327 | Int deltaPos=0; |
---|
328 | Int deltaInt; |
---|
329 | Int deltaFract; |
---|
330 | Int refMainIndex; |
---|
331 | |
---|
332 | for (k=0;k<blkSize;k++) |
---|
333 | { |
---|
334 | deltaPos += intraPredAngle; |
---|
335 | deltaInt = deltaPos >> 5; |
---|
336 | deltaFract = deltaPos & (32 - 1); |
---|
337 | |
---|
338 | if (deltaFract) |
---|
339 | { |
---|
340 | // Do linear filtering |
---|
341 | for (l=0;l<blkSize;l++) |
---|
342 | { |
---|
343 | refMainIndex = l+deltaInt+1; |
---|
344 | pDst[k*dstStride+l] = (Pel) ( ((32-deltaFract)*refMain[refMainIndex]+deltaFract*refMain[refMainIndex+1]+16) >> 5 ); |
---|
345 | } |
---|
346 | } |
---|
347 | else |
---|
348 | { |
---|
349 | // Just copy the integer samples |
---|
350 | for (l=0;l<blkSize;l++) |
---|
351 | { |
---|
352 | pDst[k*dstStride+l] = refMain[l+deltaInt+1]; |
---|
353 | } |
---|
354 | } |
---|
355 | } |
---|
356 | } |
---|
357 | |
---|
358 | // Flip the block if this is the horizontal mode |
---|
359 | if (modeHor) |
---|
360 | { |
---|
361 | Pel tmp; |
---|
362 | for (k=0;k<blkSize-1;k++) |
---|
363 | { |
---|
364 | for (l=k+1;l<blkSize;l++) |
---|
365 | { |
---|
366 | tmp = pDst[k*dstStride+l]; |
---|
367 | pDst[k*dstStride+l] = pDst[l*dstStride+k]; |
---|
368 | pDst[l*dstStride+k] = tmp; |
---|
369 | } |
---|
370 | } |
---|
371 | } |
---|
372 | } |
---|
373 | } |
---|
374 | |
---|
375 | Void TComPrediction::predIntraLumaAng(TComPattern* pcTComPattern, UInt uiDirMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft ) |
---|
376 | { |
---|
377 | Pel *pDst = piPred; |
---|
378 | Int *ptrSrc; |
---|
379 | |
---|
380 | assert( g_aucConvertToBit[ iWidth ] >= 0 ); // 4x 4 |
---|
381 | assert( g_aucConvertToBit[ iWidth ] <= 5 ); // 128x128 |
---|
382 | assert( iWidth == iHeight ); |
---|
383 | |
---|
384 | ptrSrc = pcTComPattern->getPredictorPtr( uiDirMode, g_aucConvertToBit[ iWidth ] + 2, m_piYuvExt ); |
---|
385 | |
---|
386 | // get starting pixel in block |
---|
387 | Int sw = 2 * iWidth + 1; |
---|
388 | |
---|
389 | // Create the prediction |
---|
390 | if ( uiDirMode == PLANAR_IDX ) |
---|
391 | { |
---|
392 | xPredIntraPlanar( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight ); |
---|
393 | } |
---|
394 | else |
---|
395 | { |
---|
396 | if ( (iWidth > 16) || (iHeight > 16) ) |
---|
397 | { |
---|
398 | xPredIntraAng(g_bitDepthY, ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, uiDirMode, bAbove, bLeft, false ); |
---|
399 | } |
---|
400 | else |
---|
401 | { |
---|
402 | xPredIntraAng(g_bitDepthY, ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, uiDirMode, bAbove, bLeft, true ); |
---|
403 | |
---|
404 | if( (uiDirMode == DC_IDX ) && bAbove && bLeft ) |
---|
405 | { |
---|
406 | xDCPredFiltering( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight); |
---|
407 | } |
---|
408 | } |
---|
409 | } |
---|
410 | } |
---|
411 | |
---|
412 | // Angular chroma |
---|
413 | Void TComPrediction::predIntraChromaAng( Int* piSrc, UInt uiDirMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft ) |
---|
414 | { |
---|
415 | Pel *pDst = piPred; |
---|
416 | Int *ptrSrc = piSrc; |
---|
417 | |
---|
418 | // get starting pixel in block |
---|
419 | Int sw = 2 * iWidth + 1; |
---|
420 | |
---|
421 | if ( uiDirMode == PLANAR_IDX ) |
---|
422 | { |
---|
423 | xPredIntraPlanar( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight ); |
---|
424 | } |
---|
425 | else |
---|
426 | { |
---|
427 | // Create the prediction |
---|
428 | xPredIntraAng(g_bitDepthC, ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, uiDirMode, bAbove, bLeft, false ); |
---|
429 | } |
---|
430 | } |
---|
431 | |
---|
432 | #if H_3D_DIM |
---|
433 | Void TComPrediction::predIntraLumaDepth( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiIntraMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bFastEnc ) |
---|
434 | { |
---|
435 | assert( iWidth == iHeight ); |
---|
436 | assert( iWidth >= DIM_MIN_SIZE && iWidth <= DIM_MAX_SIZE ); |
---|
437 | assert( isDimMode( uiIntraMode ) ); |
---|
438 | |
---|
439 | UInt dimType = getDimType ( uiIntraMode ); |
---|
440 | Bool dimDeltaDC = isDimDeltaDC( uiIntraMode ); |
---|
441 | Bool isDmmMode = (dimType < DMM_NUM_TYPE); |
---|
442 | Bool isRbcMode = (dimType == RBC_IDX); |
---|
443 | |
---|
444 | Bool* biSegPattern = NULL; |
---|
445 | UInt patternStride = 0; |
---|
446 | |
---|
447 | // get partiton |
---|
448 | #if H_3D_DIM_DMM |
---|
449 | TComWedgelet* dmmSegmentation = NULL; |
---|
450 | if( isDmmMode ) |
---|
451 | { |
---|
452 | switch( dimType ) |
---|
453 | { |
---|
454 | case( DMM1_IDX ): |
---|
455 | { |
---|
456 | dmmSegmentation = &(g_dmmWedgeLists[ g_aucConvertToBit[iWidth] ][ pcCU->getDmmWedgeTabIdx( dimType, uiAbsPartIdx ) ]); |
---|
457 | } break; |
---|
458 | #if !SEC_DMM2_E0146_HHIFIX |
---|
459 | case( DMM2_IDX ): |
---|
460 | { |
---|
461 | UInt uiTabIdx = 0; |
---|
462 | if( bFastEnc ) { uiTabIdx = pcCU->getDmmWedgeTabIdx( dimType, uiAbsPartIdx ); } |
---|
463 | else |
---|
464 | { |
---|
465 | uiTabIdx = xPredWedgeFromIntra( pcCU, uiAbsPartIdx, iWidth, iHeight, pcCU->getDmm2DeltaEnd( uiAbsPartIdx ) ); |
---|
466 | pcCU->setDmmWedgeTabIdxSubParts( uiTabIdx, dimType, uiAbsPartIdx, (pcCU->getDepth(0) + (pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1)) ); |
---|
467 | } |
---|
468 | dmmSegmentation = &(g_dmmWedgeLists[ g_aucConvertToBit[iWidth] ][ uiTabIdx ]); |
---|
469 | } break; |
---|
470 | #endif |
---|
471 | case( DMM3_IDX ): |
---|
472 | { |
---|
473 | UInt uiTabIdx = 0; |
---|
474 | if( bFastEnc ) { uiTabIdx = pcCU->getDmmWedgeTabIdx( dimType, uiAbsPartIdx ); } |
---|
475 | else |
---|
476 | { |
---|
477 | uiTabIdx = xPredWedgeFromTex( pcCU, uiAbsPartIdx, iWidth, iHeight, pcCU->getDmm3IntraTabIdx( uiAbsPartIdx ) ); |
---|
478 | pcCU->setDmmWedgeTabIdxSubParts( uiTabIdx, dimType, uiAbsPartIdx, (pcCU->getDepth(0) + (pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1)) ); |
---|
479 | } |
---|
480 | dmmSegmentation = &(g_dmmWedgeLists[ g_aucConvertToBit[iWidth] ][ uiTabIdx ]); |
---|
481 | } break; |
---|
482 | case( DMM4_IDX ): |
---|
483 | { |
---|
484 | dmmSegmentation = new TComWedgelet( iWidth, iHeight ); |
---|
485 | xPredContourFromTex( pcCU, uiAbsPartIdx, iWidth, iHeight, dmmSegmentation ); |
---|
486 | } break; |
---|
487 | default: assert(0); |
---|
488 | } |
---|
489 | assert( dmmSegmentation ); |
---|
490 | biSegPattern = dmmSegmentation->getPattern(); |
---|
491 | patternStride = dmmSegmentation->getStride (); |
---|
492 | } |
---|
493 | #endif |
---|
494 | #if H_3D_DIM_RBC |
---|
495 | if( isRbcMode ) |
---|
496 | { |
---|
497 | biSegPattern = pcCU->getEdgePartition( uiAbsPartIdx ); |
---|
498 | patternStride = iWidth; |
---|
499 | } |
---|
500 | #endif |
---|
501 | |
---|
502 | // get predicted partition values |
---|
503 | assert( biSegPattern ); |
---|
504 | Int* piMask = NULL; |
---|
505 | if( isDmmMode ) piMask = pcCU->getPattern()->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); // no filtering for DMM |
---|
506 | else piMask = pcCU->getPattern()->getPredictorPtr( 0, g_aucConvertToBit[ iWidth ] + 2, m_piYuvExt ); |
---|
507 | assert( piMask ); |
---|
508 | Int maskStride = 2*iWidth + 1; |
---|
509 | Int* ptrSrc = piMask+maskStride+1; |
---|
510 | Pel predDC1 = 0; Pel predDC2 = 0; |
---|
511 | xPredBiSegDCs( ptrSrc, maskStride, biSegPattern, patternStride, predDC1, predDC2 ); |
---|
512 | |
---|
513 | // set segment values with deltaDC offsets |
---|
514 | Pel segDC1 = 0; |
---|
515 | Pel segDC2 = 0; |
---|
516 | if( dimDeltaDC ) |
---|
517 | { |
---|
518 | Pel deltaDC1 = pcCU->getDimDeltaDC( dimType, 0, uiAbsPartIdx ); |
---|
519 | Pel deltaDC2 = pcCU->getDimDeltaDC( dimType, 1, uiAbsPartIdx ); |
---|
520 | #if H_3D_DIM_DMM |
---|
521 | if( isDmmMode ) |
---|
522 | { |
---|
523 | #if H_3D_DIM_DLT |
---|
524 | segDC1 = pcCU->getSlice()->getVPS()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pcCU->getSlice()->getVPS()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), predDC1 ) + deltaDC1 ); |
---|
525 | segDC2 = pcCU->getSlice()->getVPS()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pcCU->getSlice()->getVPS()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), predDC2 ) + deltaDC2 ); |
---|
526 | #else |
---|
527 | segDC1 = ClipY( predDC1 + deltaDC1 ); |
---|
528 | segDC2 = ClipY( predDC2 + deltaDC2 ); |
---|
529 | #endif |
---|
530 | } |
---|
531 | #endif |
---|
532 | #if H_3D_DIM_RBC |
---|
533 | if( isRbcMode ) |
---|
534 | { |
---|
535 | xDeltaDCQuantScaleUp( pcCU, deltaDC1 ); |
---|
536 | xDeltaDCQuantScaleUp( pcCU, deltaDC2 ); |
---|
537 | segDC1 = ClipY( predDC1 + deltaDC1 ); |
---|
538 | segDC2 = ClipY( predDC2 + deltaDC2 ); |
---|
539 | } |
---|
540 | #endif |
---|
541 | } |
---|
542 | else |
---|
543 | { |
---|
544 | segDC1 = predDC1; |
---|
545 | segDC2 = predDC2; |
---|
546 | } |
---|
547 | |
---|
548 | // set prediction signal |
---|
549 | Pel* pDst = piPred; |
---|
550 | xAssignBiSegDCs( pDst, uiStride, biSegPattern, patternStride, segDC1, segDC2 ); |
---|
551 | |
---|
552 | #if H_3D_DIM_DMM |
---|
553 | if( dimType == DMM4_IDX ) { dmmSegmentation->destroy(); delete dmmSegmentation; } |
---|
554 | #endif |
---|
555 | } |
---|
556 | #endif |
---|
557 | |
---|
558 | /** Function for checking identical motion. |
---|
559 | * \param TComDataCU* pcCU |
---|
560 | * \param UInt PartAddr |
---|
561 | */ |
---|
562 | Bool TComPrediction::xCheckIdenticalMotion ( TComDataCU* pcCU, UInt PartAddr ) |
---|
563 | { |
---|
564 | if( pcCU->getSlice()->isInterB() && !pcCU->getSlice()->getPPS()->getWPBiPred() ) |
---|
565 | { |
---|
566 | if( pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr) >= 0 && pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr) >= 0) |
---|
567 | { |
---|
568 | Int RefPOCL0 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_0, pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr))->getPOC(); |
---|
569 | Int RefPOCL1 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_1, pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr))->getPOC(); |
---|
570 | if(RefPOCL0 == RefPOCL1 && pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr) == pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr)) |
---|
571 | { |
---|
572 | return true; |
---|
573 | } |
---|
574 | } |
---|
575 | } |
---|
576 | return false; |
---|
577 | } |
---|
578 | |
---|
579 | |
---|
580 | Void TComPrediction::motionCompensation ( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx ) |
---|
581 | { |
---|
582 | Int iWidth; |
---|
583 | Int iHeight; |
---|
584 | UInt uiPartAddr; |
---|
585 | |
---|
586 | if ( iPartIdx >= 0 ) |
---|
587 | { |
---|
588 | pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight ); |
---|
589 | #if H_3D_VSP |
---|
590 | if ( pcCU->getVSPFlag(uiPartAddr) == 0) |
---|
591 | { |
---|
592 | #endif |
---|
593 | if ( eRefPicList != REF_PIC_LIST_X ) |
---|
594 | { |
---|
595 | if( pcCU->getSlice()->getPPS()->getUseWP()) |
---|
596 | { |
---|
597 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true ); |
---|
598 | } |
---|
599 | else |
---|
600 | { |
---|
601 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); |
---|
602 | } |
---|
603 | if ( pcCU->getSlice()->getPPS()->getUseWP() ) |
---|
604 | { |
---|
605 | xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); |
---|
606 | } |
---|
607 | } |
---|
608 | else |
---|
609 | { |
---|
610 | if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) ) |
---|
611 | { |
---|
612 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred ); |
---|
613 | } |
---|
614 | else |
---|
615 | { |
---|
616 | xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred ); |
---|
617 | } |
---|
618 | } |
---|
619 | #if H_3D_VSP |
---|
620 | } |
---|
621 | else |
---|
622 | { |
---|
623 | if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) ) |
---|
624 | { |
---|
625 | xPredInterUniVSP( pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred ); |
---|
626 | } |
---|
627 | else |
---|
628 | { |
---|
629 | xPredInterBiVSP ( pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred ); |
---|
630 | } |
---|
631 | } |
---|
632 | #endif |
---|
633 | return; |
---|
634 | } |
---|
635 | |
---|
636 | for ( iPartIdx = 0; iPartIdx < pcCU->getNumPartInter(); iPartIdx++ ) |
---|
637 | { |
---|
638 | pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight ); |
---|
639 | |
---|
640 | #if H_3D_VSP |
---|
641 | if ( pcCU->getVSPFlag(uiPartAddr) == 0 ) |
---|
642 | { |
---|
643 | #endif |
---|
644 | if ( eRefPicList != REF_PIC_LIST_X ) |
---|
645 | { |
---|
646 | if( pcCU->getSlice()->getPPS()->getUseWP()) |
---|
647 | { |
---|
648 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true ); |
---|
649 | } |
---|
650 | else |
---|
651 | { |
---|
652 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); |
---|
653 | } |
---|
654 | if ( pcCU->getSlice()->getPPS()->getUseWP() ) |
---|
655 | { |
---|
656 | xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); |
---|
657 | } |
---|
658 | } |
---|
659 | else |
---|
660 | { |
---|
661 | if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) ) |
---|
662 | { |
---|
663 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred ); |
---|
664 | } |
---|
665 | else |
---|
666 | { |
---|
667 | xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred ); |
---|
668 | } |
---|
669 | } |
---|
670 | #if H_3D_VSP |
---|
671 | } |
---|
672 | else |
---|
673 | { |
---|
674 | if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) ) |
---|
675 | { |
---|
676 | xPredInterUniVSP( pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred ); |
---|
677 | } |
---|
678 | else |
---|
679 | { |
---|
680 | xPredInterBiVSP ( pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred ); |
---|
681 | } |
---|
682 | } |
---|
683 | #endif |
---|
684 | } |
---|
685 | return; |
---|
686 | } |
---|
687 | |
---|
688 | Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi ) |
---|
689 | { |
---|
690 | Int iRefIdx = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); assert (iRefIdx >= 0); |
---|
691 | TComMv cMv = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr ); |
---|
692 | pcCU->clipMv(cMv); |
---|
693 | #if H_3D_ARP |
---|
694 | if( pcCU->getARPW( uiPartAddr ) > 0 |
---|
695 | && pcCU->getPartitionSize(uiPartAddr)==SIZE_2Nx2N |
---|
696 | && pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()!= pcCU->getSlice()->getPOC() |
---|
697 | ) |
---|
698 | { |
---|
699 | xPredInterUniARP( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, rpcYuvPred, bi ); |
---|
700 | } |
---|
701 | else |
---|
702 | { |
---|
703 | #endif |
---|
704 | #if H_3D_IC |
---|
705 | Bool bICFlag = pcCU->getICFlag( uiPartAddr ) && ( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getViewIndex() != pcCU->getSlice()->getViewIndex() ); |
---|
706 | xPredInterLumaBlk ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi |
---|
707 | #if H_3D_ARP |
---|
708 | , false |
---|
709 | #endif |
---|
710 | , bICFlag ); |
---|
711 | #if SHARP_ILLUCOMP_REFINE_E0046 |
---|
712 | bICFlag = bICFlag && (iWidth > 8); |
---|
713 | #endif |
---|
714 | xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi |
---|
715 | #if H_3D_ARP |
---|
716 | , false |
---|
717 | #endif |
---|
718 | , bICFlag ); |
---|
719 | #else |
---|
720 | xPredInterLumaBlk ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi ); |
---|
721 | xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi ); |
---|
722 | #endif |
---|
723 | #if H_3D_ARP |
---|
724 | } |
---|
725 | #endif |
---|
726 | } |
---|
727 | |
---|
728 | #if H_3D_VSP |
---|
729 | Void TComPrediction::xPredInterUniVSP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi ) |
---|
730 | { |
---|
731 | // Get depth reference |
---|
732 | Int depthRefViewIdx = pcCU->getDvInfo(uiPartAddr).m_aVIdxCan; |
---|
733 | #if H_3D_FCO_VSP_DONBDV |
---|
734 | TComPic* pRefPicBaseDepth = 0; |
---|
735 | Bool bIsCurrDepthCoded = false; |
---|
736 | pRefPicBaseDepth = pcCU->getSlice()->getIvPic( true, pcCU->getSlice()->getViewIndex() ); |
---|
737 | if ( pRefPicBaseDepth->getPicYuvRec() != NULL ) |
---|
738 | { |
---|
739 | bIsCurrDepthCoded = true; |
---|
740 | } |
---|
741 | else |
---|
742 | { |
---|
743 | pRefPicBaseDepth = pcCU->getSlice()->getIvPic (true, depthRefViewIdx ); |
---|
744 | } |
---|
745 | #else |
---|
746 | TComPic* pRefPicBaseDepth = pcCU->getSlice()->getIvPic (true, depthRefViewIdx ); |
---|
747 | #endif |
---|
748 | assert(pRefPicBaseDepth != NULL); |
---|
749 | TComPicYuv* pcBaseViewDepthPicYuv = pRefPicBaseDepth->getPicYuvRec(); |
---|
750 | assert(pcBaseViewDepthPicYuv != NULL); |
---|
751 | |
---|
752 | // Get texture reference |
---|
753 | Int iRefIdx = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
754 | assert(iRefIdx >= 0); |
---|
755 | TComPic* pRefPicBaseTxt = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx ); |
---|
756 | TComPicYuv* pcBaseViewTxtPicYuv = pRefPicBaseTxt->getPicYuvRec(); |
---|
757 | assert(pcBaseViewTxtPicYuv != NULL); |
---|
758 | |
---|
759 | // Initialize LUT according to the reference viewIdx |
---|
760 | Int txtRefViewIdx = pRefPicBaseTxt->getViewIndex(); |
---|
761 | Int* pShiftLUT = pcCU->getSlice()->getDepthToDisparityB( txtRefViewIdx ); |
---|
762 | assert( txtRefViewIdx < pcCU->getSlice()->getViewIndex() ); |
---|
763 | |
---|
764 | // Do compensation |
---|
765 | TComMv cDv = pcCU->getDvInfo(uiPartAddr).m_acNBDV; |
---|
766 | pcCU->clipMv(cDv); |
---|
767 | |
---|
768 | #if H_3D_FCO_VSP_DONBDV |
---|
769 | if ( bIsCurrDepthCoded ) |
---|
770 | { |
---|
771 | cDv.setZero(); |
---|
772 | } |
---|
773 | #endif |
---|
774 | |
---|
775 | #if NTT_VSP_COMMON_E0207_E0208 |
---|
776 | // fetch virtual depth map |
---|
777 | #if NTT_VSP_VECTOR_CLIP_E0208 |
---|
778 | pcBaseViewDepthPicYuv->extendPicBorder(); |
---|
779 | #endif |
---|
780 | xGetVirtualDepth( pcCU, pcBaseViewDepthPicYuv, &cDv, uiPartAddr, iWidth, iHeight, &m_cYuvDepthOnVsp ); |
---|
781 | // sub-PU based compensation |
---|
782 | xPredInterLumaBlkFromDM ( pcCU, pcBaseViewTxtPicYuv, &m_cYuvDepthOnVsp, pShiftLUT, &cDv, uiPartAddr, iWidth, iHeight, pcCU->getSlice()->getIsDepth(), rpcYuvPred, bi ); |
---|
783 | xPredInterChromaBlkFromDM ( pcCU, pcBaseViewTxtPicYuv, &m_cYuvDepthOnVsp, pShiftLUT, &cDv, uiPartAddr, iWidth, iHeight, pcCU->getSlice()->getIsDepth(), rpcYuvPred, bi ); |
---|
784 | #else |
---|
785 | UInt uiAbsPartIdx = pcCU->getZorderIdxInCU(); |
---|
786 | Int iBlkX = ( pcCU->getAddr() % pRefPicBaseDepth->getFrameWidthInCU() ) * g_uiMaxCUWidth + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartIdx ] ]; |
---|
787 | Int iBlkY = ( pcCU->getAddr() / pRefPicBaseDepth->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartIdx ] ]; |
---|
788 | xPredInterLumaBlkFromDM ( pcBaseViewTxtPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, &cDv, uiPartAddr, iBlkX, iBlkY, iWidth, iHeight, pcCU->getSlice()->getIsDepth(), rpcYuvPred, bi ); |
---|
789 | xPredInterChromaBlkFromDM( pcBaseViewTxtPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, &cDv, uiPartAddr, iBlkX>>1, iBlkY>>1, iWidth>>1, iHeight>>1, pcCU->getSlice()->getIsDepth(), rpcYuvPred, bi ); |
---|
790 | #endif |
---|
791 | |
---|
792 | } |
---|
793 | #endif |
---|
794 | |
---|
795 | #if H_3D_ARP |
---|
796 | Void TComPrediction::xPredInterUniARP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, TComMvField * pNewMvFiled ) |
---|
797 | { |
---|
798 | Int iRefIdx = pNewMvFiled ? pNewMvFiled->getRefIdx() : pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
799 | TComMv cMv = pNewMvFiled ? pNewMvFiled->getMv() : pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr ); |
---|
800 | Bool bTobeScaled = false; |
---|
801 | TComPic* pcPicYuvBaseCol = NULL; |
---|
802 | TComPic* pcPicYuvBaseRef = NULL; |
---|
803 | |
---|
804 | #if H_3D_NBDV |
---|
805 | DisInfo cDistparity; |
---|
806 | cDistparity.bDV = pcCU->getDvInfo(uiPartAddr).bDV; |
---|
807 | if( cDistparity.bDV ) |
---|
808 | { |
---|
809 | cDistparity.m_acNBDV = pcCU->getDvInfo(0).m_acNBDV; |
---|
810 | assert(pcCU->getDvInfo(uiPartAddr).bDV == pcCU->getDvInfo(0).bDV); |
---|
811 | cDistparity.m_aVIdxCan = pcCU->getDvInfo(uiPartAddr).m_aVIdxCan; |
---|
812 | } |
---|
813 | #else |
---|
814 | assert(0); // ARP can be applied only when a DV is available |
---|
815 | #endif |
---|
816 | |
---|
817 | UChar dW = cDistparity.bDV ? pcCU->getARPW ( uiPartAddr ) : 0; |
---|
818 | |
---|
819 | if( cDistparity.bDV ) |
---|
820 | { |
---|
821 | if( dW > 0 && pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC()!= pcCU->getSlice()->getPOC() ) |
---|
822 | { |
---|
823 | bTobeScaled = true; |
---|
824 | } |
---|
825 | |
---|
826 | pcPicYuvBaseCol = pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getPOC(), cDistparity.m_aVIdxCan ); |
---|
827 | pcPicYuvBaseRef = pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC(), cDistparity.m_aVIdxCan ); |
---|
828 | |
---|
829 | if( ( !pcPicYuvBaseCol || pcPicYuvBaseCol->getPOC() != pcCU->getSlice()->getPOC() ) || ( !pcPicYuvBaseRef || pcPicYuvBaseRef->getPOC() != pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC() ) ) |
---|
830 | { |
---|
831 | dW = 0; |
---|
832 | bTobeScaled = false; |
---|
833 | } |
---|
834 | else |
---|
835 | { |
---|
836 | assert( pcPicYuvBaseCol->getPOC() == pcCU->getSlice()->getPOC() && pcPicYuvBaseRef->getPOC() == pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC() ); |
---|
837 | } |
---|
838 | |
---|
839 | if(bTobeScaled) |
---|
840 | { |
---|
841 | Int iCurrPOC = pcCU->getSlice()->getPOC(); |
---|
842 | Int iColRefPOC = pcCU->getSlice()->getRefPOC( eRefPicList, iRefIdx ); |
---|
843 | Int iCurrRefPOC = pcCU->getSlice()->getRefPOC( eRefPicList, 0); |
---|
844 | Int iScale = pcCU-> xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iCurrPOC, iColRefPOC); |
---|
845 | if ( iScale != 4096 ) |
---|
846 | { |
---|
847 | cMv = cMv.scaleMv( iScale ); |
---|
848 | } |
---|
849 | iRefIdx = 0; |
---|
850 | } |
---|
851 | } |
---|
852 | |
---|
853 | pcCU->clipMv(cMv); |
---|
854 | TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(); |
---|
855 | xPredInterLumaBlk ( pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi, true ); |
---|
856 | xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi, true ); |
---|
857 | |
---|
858 | if( dW > 0 ) |
---|
859 | { |
---|
860 | TComYuv * pYuvB0 = &m_acYuvPredBase[0]; |
---|
861 | TComYuv * pYuvB1 = &m_acYuvPredBase[1]; |
---|
862 | |
---|
863 | TComMv cMVwithDisparity = cMv + cDistparity.m_acNBDV; |
---|
864 | pcCU->clipMv(cMVwithDisparity); |
---|
865 | |
---|
866 | assert ( cDistparity.bDV ); |
---|
867 | |
---|
868 | pcPicYuvRef = pcPicYuvBaseCol->getPicYuvRec(); |
---|
869 | xPredInterLumaBlk ( pcCU, pcPicYuvRef, uiPartAddr, &cDistparity.m_acNBDV, iWidth, iHeight, pYuvB0, bi, true ); |
---|
870 | xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cDistparity.m_acNBDV, iWidth, iHeight, pYuvB0, bi, true ); |
---|
871 | |
---|
872 | pcPicYuvRef = pcPicYuvBaseRef->getPicYuvRec(); |
---|
873 | xPredInterLumaBlk ( pcCU, pcPicYuvRef, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvB1, bi, true ); |
---|
874 | xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvB1, bi, true ); |
---|
875 | |
---|
876 | pYuvB0->subtractARP( pYuvB0 , pYuvB1 , uiPartAddr , iWidth , iHeight ); |
---|
877 | |
---|
878 | if( 2 == dW ) |
---|
879 | { |
---|
880 | pYuvB0->multiplyARP( uiPartAddr , iWidth , iHeight , dW ); |
---|
881 | } |
---|
882 | rpcYuvPred->addARP( rpcYuvPred , pYuvB0 , uiPartAddr , iWidth , iHeight , !bi ); |
---|
883 | } |
---|
884 | } |
---|
885 | #endif |
---|
886 | |
---|
887 | Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvPred ) |
---|
888 | { |
---|
889 | TComYuv* pcMbYuv; |
---|
890 | Int iRefIdx[2] = {-1, -1}; |
---|
891 | |
---|
892 | for ( Int iRefList = 0; iRefList < 2; iRefList++ ) |
---|
893 | { |
---|
894 | RefPicList eRefPicList = (iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0); |
---|
895 | iRefIdx[iRefList] = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
896 | |
---|
897 | if ( iRefIdx[iRefList] < 0 ) |
---|
898 | { |
---|
899 | continue; |
---|
900 | } |
---|
901 | |
---|
902 | assert( iRefIdx[iRefList] < pcCU->getSlice()->getNumRefIdx(eRefPicList) ); |
---|
903 | |
---|
904 | pcMbYuv = &m_acYuvPred[iRefList]; |
---|
905 | if( pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr ) >= 0 && pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr ) >= 0 ) |
---|
906 | { |
---|
907 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, true ); |
---|
908 | } |
---|
909 | else |
---|
910 | { |
---|
911 | if ( ( pcCU->getSlice()->getPPS()->getUseWP() && pcCU->getSlice()->getSliceType() == P_SLICE ) || |
---|
912 | ( pcCU->getSlice()->getPPS()->getWPBiPred() && pcCU->getSlice()->getSliceType() == B_SLICE ) ) |
---|
913 | { |
---|
914 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, true ); |
---|
915 | } |
---|
916 | else |
---|
917 | { |
---|
918 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv ); |
---|
919 | } |
---|
920 | } |
---|
921 | } |
---|
922 | |
---|
923 | if ( pcCU->getSlice()->getPPS()->getWPBiPred() && pcCU->getSlice()->getSliceType() == B_SLICE ) |
---|
924 | { |
---|
925 | xWeightedPredictionBi( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); |
---|
926 | } |
---|
927 | else if ( pcCU->getSlice()->getPPS()->getUseWP() && pcCU->getSlice()->getSliceType() == P_SLICE ) |
---|
928 | { |
---|
929 | xWeightedPredictionUni( pcCU, &m_acYuvPred[0], uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, rpcYuvPred ); |
---|
930 | } |
---|
931 | else |
---|
932 | { |
---|
933 | xWeightedAverage( &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); |
---|
934 | } |
---|
935 | } |
---|
936 | |
---|
937 | #if H_3D_VSP |
---|
938 | |
---|
939 | Void TComPrediction::xPredInterBiVSP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvPred ) |
---|
940 | { |
---|
941 | TComYuv* pcMbYuv; |
---|
942 | Int iRefIdx[2] = {-1, -1}; |
---|
943 | Bool bi = (pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr ) >= 0 && pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr ) >= 0); |
---|
944 | |
---|
945 | for ( Int iRefList = 0; iRefList < 2; iRefList++ ) |
---|
946 | { |
---|
947 | RefPicList eRefPicList = RefPicList(iRefList); |
---|
948 | iRefIdx[iRefList] = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
949 | |
---|
950 | if ( iRefIdx[iRefList] < 0 ) |
---|
951 | { |
---|
952 | continue; |
---|
953 | } |
---|
954 | assert( iRefIdx[iRefList] < pcCU->getSlice()->getNumRefIdx(eRefPicList) ); |
---|
955 | |
---|
956 | pcMbYuv = &m_acYuvPred[iRefList]; |
---|
957 | xPredInterUniVSP ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, bi ); |
---|
958 | } |
---|
959 | |
---|
960 | xWeightedAverage( &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); |
---|
961 | } |
---|
962 | |
---|
963 | #endif |
---|
964 | |
---|
965 | /** |
---|
966 | * \brief Generate motion-compensated luma block |
---|
967 | * |
---|
968 | * \param cu Pointer to current CU |
---|
969 | * \param refPic Pointer to reference picture |
---|
970 | * \param partAddr Address of block within CU |
---|
971 | * \param mv Motion vector |
---|
972 | * \param width Width of block |
---|
973 | * \param height Height of block |
---|
974 | * \param dstPic Pointer to destination picture |
---|
975 | * \param bi Flag indicating whether bipred is used |
---|
976 | */ |
---|
977 | Void TComPrediction::xPredInterLumaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi |
---|
978 | #if H_3D_ARP |
---|
979 | , Bool filterType |
---|
980 | #endif |
---|
981 | #if H_3D_IC |
---|
982 | , Bool bICFlag |
---|
983 | #endif |
---|
984 | ) |
---|
985 | { |
---|
986 | Int refStride = refPic->getStride(); |
---|
987 | Int refOffset = ( mv->getHor() >> 2 ) + ( mv->getVer() >> 2 ) * refStride; |
---|
988 | Pel *ref = refPic->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset; |
---|
989 | |
---|
990 | Int dstStride = dstPic->getStride(); |
---|
991 | Pel *dst = dstPic->getLumaAddr( partAddr ); |
---|
992 | |
---|
993 | Int xFrac = mv->getHor() & 0x3; |
---|
994 | Int yFrac = mv->getVer() & 0x3; |
---|
995 | |
---|
996 | #if H_3D_IC |
---|
997 | if( cu->getSlice()->getIsDepth() ) |
---|
998 | { |
---|
999 | refOffset = mv->getHor() + mv->getVer() * refStride; |
---|
1000 | ref = refPic->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset; |
---|
1001 | xFrac = 0; |
---|
1002 | yFrac = 0; |
---|
1003 | } |
---|
1004 | #endif |
---|
1005 | if ( yFrac == 0 ) |
---|
1006 | { |
---|
1007 | #if MTK_CLIPPING_ALIGN_IC_E0168 |
---|
1008 | m_if.filterHorLuma( ref, refStride, dst, dstStride, width, height, xFrac, !bi || bICFlag |
---|
1009 | #else |
---|
1010 | m_if.filterHorLuma( ref, refStride, dst, dstStride, width, height, xFrac, !bi |
---|
1011 | #endif |
---|
1012 | #if H_3D_ARP |
---|
1013 | , filterType |
---|
1014 | #endif |
---|
1015 | ); |
---|
1016 | } |
---|
1017 | else if ( xFrac == 0 ) |
---|
1018 | { |
---|
1019 | #if MTK_CLIPPING_ALIGN_IC_E0168 |
---|
1020 | m_if.filterVerLuma( ref, refStride, dst, dstStride, width, height, yFrac, true, !bi || bICFlag |
---|
1021 | #else |
---|
1022 | m_if.filterVerLuma( ref, refStride, dst, dstStride, width, height, yFrac, true, !bi |
---|
1023 | #endif |
---|
1024 | #if H_3D_ARP |
---|
1025 | , filterType |
---|
1026 | #endif |
---|
1027 | ); |
---|
1028 | } |
---|
1029 | else |
---|
1030 | { |
---|
1031 | Int tmpStride = m_filteredBlockTmp[0].getStride(); |
---|
1032 | Short *tmp = m_filteredBlockTmp[0].getLumaAddr(); |
---|
1033 | |
---|
1034 | Int filterSize = NTAPS_LUMA; |
---|
1035 | Int halfFilterSize = ( filterSize >> 1 ); |
---|
1036 | |
---|
1037 | m_if.filterHorLuma(ref - (halfFilterSize-1)*refStride, refStride, tmp, tmpStride, width, height+filterSize-1, xFrac, false |
---|
1038 | #if H_3D_ARP |
---|
1039 | , filterType |
---|
1040 | #endif |
---|
1041 | ); |
---|
1042 | #if MTK_CLIPPING_ALIGN_IC_E0168 |
---|
1043 | m_if.filterVerLuma(tmp + (halfFilterSize-1)*tmpStride, tmpStride, dst, dstStride, width, height, yFrac, false, !bi || bICFlag |
---|
1044 | #else |
---|
1045 | m_if.filterVerLuma(tmp + (halfFilterSize-1)*tmpStride, tmpStride, dst, dstStride, width, height, yFrac, false, !bi |
---|
1046 | #endif |
---|
1047 | #if H_3D_ARP |
---|
1048 | , filterType |
---|
1049 | #endif |
---|
1050 | ); |
---|
1051 | } |
---|
1052 | |
---|
1053 | #if H_3D_IC |
---|
1054 | if( bICFlag ) |
---|
1055 | { |
---|
1056 | #if SHARP_ILLUCOMP_REFINE_E0046 |
---|
1057 | Int a, b, i, j; |
---|
1058 | const Int iShift = IC_CONST_SHIFT; |
---|
1059 | |
---|
1060 | xGetLLSICPrediction( cu, mv, refPic, a, b, TEXT_LUMA ); |
---|
1061 | #else |
---|
1062 | Int a, b, iShift, i, j; |
---|
1063 | |
---|
1064 | xGetLLSICPrediction( cu, mv, refPic, a, b, iShift, TEXT_LUMA ); |
---|
1065 | #endif |
---|
1066 | |
---|
1067 | |
---|
1068 | for ( i = 0; i < height; i++ ) |
---|
1069 | { |
---|
1070 | for ( j = 0; j < width; j++ ) |
---|
1071 | { |
---|
1072 | #if !MTK_CLIPPING_ALIGN_IC_E0168 |
---|
1073 | if( bi ) |
---|
1074 | { |
---|
1075 | Int iIFshift = IF_INTERNAL_PREC - g_bitDepthY; |
---|
1076 | dst[j] = ( ( a*dst[j] + a*IF_INTERNAL_OFFS ) >> iShift ) + b*( 1 << iIFshift ) - IF_INTERNAL_OFFS; |
---|
1077 | } |
---|
1078 | else |
---|
1079 | #endif |
---|
1080 | dst[j] = Clip3( 0, ( 1 << g_bitDepthY ) - 1, ( ( a*dst[j] ) >> iShift ) + b ); |
---|
1081 | } |
---|
1082 | dst += dstStride; |
---|
1083 | } |
---|
1084 | #if MTK_CLIPPING_ALIGN_IC_E0168 |
---|
1085 | if(bi) |
---|
1086 | { |
---|
1087 | Pel *dst2 = dstPic->getLumaAddr( partAddr ); |
---|
1088 | Int shift = IF_INTERNAL_PREC - g_bitDepthY; |
---|
1089 | for (i = 0; i < height; i++) |
---|
1090 | { |
---|
1091 | for (j = 0; j < width; j++) |
---|
1092 | { |
---|
1093 | Short val = dst2[j] << shift; |
---|
1094 | dst2[j] = val - (Short)IF_INTERNAL_OFFS; |
---|
1095 | } |
---|
1096 | dst2 += dstStride; |
---|
1097 | } |
---|
1098 | } |
---|
1099 | #endif |
---|
1100 | } |
---|
1101 | #endif |
---|
1102 | } |
---|
1103 | |
---|
1104 | /** |
---|
1105 | * \brief Generate motion-compensated chroma block |
---|
1106 | * |
---|
1107 | * \param cu Pointer to current CU |
---|
1108 | * \param refPic Pointer to reference picture |
---|
1109 | * \param partAddr Address of block within CU |
---|
1110 | * \param mv Motion vector |
---|
1111 | * \param width Width of block |
---|
1112 | * \param height Height of block |
---|
1113 | * \param dstPic Pointer to destination picture |
---|
1114 | * \param bi Flag indicating whether bipred is used |
---|
1115 | */ |
---|
1116 | Void TComPrediction::xPredInterChromaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi |
---|
1117 | #if H_3D_ARP |
---|
1118 | , Bool filterType |
---|
1119 | #endif |
---|
1120 | #if H_3D_IC |
---|
1121 | , Bool bICFlag |
---|
1122 | #endif |
---|
1123 | ) |
---|
1124 | { |
---|
1125 | Int refStride = refPic->getCStride(); |
---|
1126 | Int dstStride = dstPic->getCStride(); |
---|
1127 | |
---|
1128 | Int refOffset = (mv->getHor() >> 3) + (mv->getVer() >> 3) * refStride; |
---|
1129 | |
---|
1130 | Pel* refCb = refPic->getCbAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset; |
---|
1131 | Pel* refCr = refPic->getCrAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset; |
---|
1132 | |
---|
1133 | Pel* dstCb = dstPic->getCbAddr( partAddr ); |
---|
1134 | Pel* dstCr = dstPic->getCrAddr( partAddr ); |
---|
1135 | |
---|
1136 | Int xFrac = mv->getHor() & 0x7; |
---|
1137 | Int yFrac = mv->getVer() & 0x7; |
---|
1138 | UInt cxWidth = width >> 1; |
---|
1139 | UInt cxHeight = height >> 1; |
---|
1140 | |
---|
1141 | Int extStride = m_filteredBlockTmp[0].getStride(); |
---|
1142 | Short* extY = m_filteredBlockTmp[0].getLumaAddr(); |
---|
1143 | |
---|
1144 | Int filterSize = NTAPS_CHROMA; |
---|
1145 | |
---|
1146 | Int halfFilterSize = (filterSize>>1); |
---|
1147 | |
---|
1148 | if ( yFrac == 0 ) |
---|
1149 | { |
---|
1150 | #if MTK_CLIPPING_ALIGN_IC_E0168 |
---|
1151 | m_if.filterHorChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, xFrac, !bi || bICFlag |
---|
1152 | #else |
---|
1153 | m_if.filterHorChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, xFrac, !bi |
---|
1154 | #endif |
---|
1155 | #if H_3D_ARP |
---|
1156 | , filterType |
---|
1157 | #endif |
---|
1158 | ); |
---|
1159 | #if MTK_CLIPPING_ALIGN_IC_E0168 |
---|
1160 | m_if.filterHorChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, xFrac, !bi || bICFlag |
---|
1161 | #else |
---|
1162 | m_if.filterHorChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, xFrac, !bi |
---|
1163 | #endif |
---|
1164 | #if H_3D_ARP |
---|
1165 | , filterType |
---|
1166 | #endif |
---|
1167 | ); |
---|
1168 | } |
---|
1169 | else if ( xFrac == 0 ) |
---|
1170 | { |
---|
1171 | #if MTK_CLIPPING_ALIGN_IC_E0168 |
---|
1172 | m_if.filterVerChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, true, !bi || bICFlag |
---|
1173 | #else |
---|
1174 | m_if.filterVerChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, true, !bi |
---|
1175 | #endif |
---|
1176 | #if H_3D_ARP |
---|
1177 | , filterType |
---|
1178 | #endif |
---|
1179 | ); |
---|
1180 | #if MTK_CLIPPING_ALIGN_IC_E0168 |
---|
1181 | m_if.filterVerChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, true, !bi || bICFlag |
---|
1182 | #else |
---|
1183 | m_if.filterVerChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, true, !bi |
---|
1184 | #endif |
---|
1185 | #if H_3D_ARP |
---|
1186 | , filterType |
---|
1187 | #endif |
---|
1188 | ); |
---|
1189 | } |
---|
1190 | else |
---|
1191 | { |
---|
1192 | m_if.filterHorChroma(refCb - (halfFilterSize-1)*refStride, refStride, extY, extStride, cxWidth, cxHeight+filterSize-1, xFrac, false |
---|
1193 | #if H_3D_ARP |
---|
1194 | , filterType |
---|
1195 | #endif |
---|
1196 | ); |
---|
1197 | #if MTK_CLIPPING_ALIGN_IC_E0168 |
---|
1198 | m_if.filterVerChroma(extY + (halfFilterSize-1)*extStride, extStride, dstCb, dstStride, cxWidth, cxHeight , yFrac, false, !bi || bICFlag |
---|
1199 | #else |
---|
1200 | m_if.filterVerChroma(extY + (halfFilterSize-1)*extStride, extStride, dstCb, dstStride, cxWidth, cxHeight , yFrac, false, !bi |
---|
1201 | #endif |
---|
1202 | #if H_3D_ARP |
---|
1203 | , filterType |
---|
1204 | #endif |
---|
1205 | ); |
---|
1206 | |
---|
1207 | m_if.filterHorChroma(refCr - (halfFilterSize-1)*refStride, refStride, extY, extStride, cxWidth, cxHeight+filterSize-1, xFrac, false |
---|
1208 | #if H_3D_ARP |
---|
1209 | , filterType |
---|
1210 | #endif |
---|
1211 | ); |
---|
1212 | #if MTK_CLIPPING_ALIGN_IC_E0168 |
---|
1213 | m_if.filterVerChroma(extY + (halfFilterSize-1)*extStride, extStride, dstCr, dstStride, cxWidth, cxHeight , yFrac, false, !bi || bICFlag |
---|
1214 | #else |
---|
1215 | m_if.filterVerChroma(extY + (halfFilterSize-1)*extStride, extStride, dstCr, dstStride, cxWidth, cxHeight , yFrac, false, !bi |
---|
1216 | #endif |
---|
1217 | #if H_3D_ARP |
---|
1218 | , filterType |
---|
1219 | #endif |
---|
1220 | ); |
---|
1221 | } |
---|
1222 | |
---|
1223 | #if H_3D_IC |
---|
1224 | if( bICFlag ) |
---|
1225 | { |
---|
1226 | #if SHARP_ILLUCOMP_REFINE_E0046 |
---|
1227 | Int a, b, i, j; |
---|
1228 | const Int iShift = IC_CONST_SHIFT; |
---|
1229 | xGetLLSICPrediction( cu, mv, refPic, a, b, TEXT_CHROMA_U ); // Cb |
---|
1230 | #else |
---|
1231 | Int a, b, iShift, i, j; |
---|
1232 | xGetLLSICPrediction( cu, mv, refPic, a, b, iShift, TEXT_CHROMA_U ); // Cb |
---|
1233 | #endif |
---|
1234 | for ( i = 0; i < cxHeight; i++ ) |
---|
1235 | { |
---|
1236 | for ( j = 0; j < cxWidth; j++ ) |
---|
1237 | { |
---|
1238 | #if !MTK_CLIPPING_ALIGN_IC_E0168 |
---|
1239 | if( bi ) |
---|
1240 | { |
---|
1241 | Int iIFshift = IF_INTERNAL_PREC - g_bitDepthC; |
---|
1242 | dstCb[j] = ( ( a*dstCb[j] + a*IF_INTERNAL_OFFS ) >> iShift ) + b*( 1<<iIFshift ) - IF_INTERNAL_OFFS; |
---|
1243 | } |
---|
1244 | else |
---|
1245 | #endif |
---|
1246 | dstCb[j] = Clip3( 0, ( 1 << g_bitDepthC ) - 1, ( ( a*dstCb[j] ) >> iShift ) + b ); |
---|
1247 | } |
---|
1248 | dstCb += dstStride; |
---|
1249 | } |
---|
1250 | #if SHARP_ILLUCOMP_REFINE_E0046 |
---|
1251 | xGetLLSICPrediction( cu, mv, refPic, a, b, TEXT_CHROMA_V ); // Cr |
---|
1252 | #else |
---|
1253 | xGetLLSICPrediction( cu, mv, refPic, a, b, iShift, TEXT_CHROMA_V ); // Cr |
---|
1254 | #endif |
---|
1255 | for ( i = 0; i < cxHeight; i++ ) |
---|
1256 | { |
---|
1257 | for ( j = 0; j < cxWidth; j++ ) |
---|
1258 | { |
---|
1259 | #if !MTK_CLIPPING_ALIGN_IC_E0168 |
---|
1260 | if( bi ) |
---|
1261 | { |
---|
1262 | Int iIFshift = IF_INTERNAL_PREC - g_bitDepthC; |
---|
1263 | dstCr[j] = ( ( a*dstCr[j] + a*IF_INTERNAL_OFFS ) >> iShift ) + b*( 1<<iIFshift ) - IF_INTERNAL_OFFS; |
---|
1264 | } |
---|
1265 | else |
---|
1266 | #endif |
---|
1267 | dstCr[j] = Clip3( 0, ( 1 << g_bitDepthC ) - 1, ( ( a*dstCr[j] ) >> iShift ) + b ); |
---|
1268 | } |
---|
1269 | dstCr += dstStride; |
---|
1270 | } |
---|
1271 | #if MTK_CLIPPING_ALIGN_IC_E0168 |
---|
1272 | if(bi) |
---|
1273 | { |
---|
1274 | Pel* dstCb2 = dstPic->getCbAddr( partAddr ); |
---|
1275 | Pel* dstCr2 = dstPic->getCrAddr( partAddr ); |
---|
1276 | Int shift = IF_INTERNAL_PREC - g_bitDepthC; |
---|
1277 | for (i = 0; i < cxHeight; i++) |
---|
1278 | { |
---|
1279 | for (j = 0; j < cxWidth; j++) |
---|
1280 | { |
---|
1281 | Short val = dstCb2[j] << shift; |
---|
1282 | dstCb2[j] = val - (Short)IF_INTERNAL_OFFS; |
---|
1283 | |
---|
1284 | val = dstCr2[j] << shift; |
---|
1285 | dstCr2[j] = val - (Short)IF_INTERNAL_OFFS; |
---|
1286 | } |
---|
1287 | dstCb2 += dstStride; |
---|
1288 | dstCr2 += dstStride; |
---|
1289 | } |
---|
1290 | } |
---|
1291 | #endif |
---|
1292 | } |
---|
1293 | #endif |
---|
1294 | } |
---|
1295 | |
---|
1296 | Void TComPrediction::xWeightedAverage( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv*& rpcYuvDst ) |
---|
1297 | { |
---|
1298 | if( iRefIdx0 >= 0 && iRefIdx1 >= 0 ) |
---|
1299 | { |
---|
1300 | rpcYuvDst->addAvg( pcYuvSrc0, pcYuvSrc1, uiPartIdx, iWidth, iHeight ); |
---|
1301 | } |
---|
1302 | else if ( iRefIdx0 >= 0 && iRefIdx1 < 0 ) |
---|
1303 | { |
---|
1304 | pcYuvSrc0->copyPartToPartYuv( rpcYuvDst, uiPartIdx, iWidth, iHeight ); |
---|
1305 | } |
---|
1306 | else if ( iRefIdx0 < 0 && iRefIdx1 >= 0 ) |
---|
1307 | { |
---|
1308 | pcYuvSrc1->copyPartToPartYuv( rpcYuvDst, uiPartIdx, iWidth, iHeight ); |
---|
1309 | } |
---|
1310 | } |
---|
1311 | |
---|
1312 | // AMVP |
---|
1313 | Void TComPrediction::getMvPredAMVP( TComDataCU* pcCU, UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, TComMv& rcMvPred ) |
---|
1314 | { |
---|
1315 | AMVPInfo* pcAMVPInfo = pcCU->getCUMvField(eRefPicList)->getAMVPInfo(); |
---|
1316 | if( pcAMVPInfo->iN <= 1 ) |
---|
1317 | { |
---|
1318 | rcMvPred = pcAMVPInfo->m_acMvCand[0]; |
---|
1319 | |
---|
1320 | pcCU->setMVPIdxSubParts( 0, eRefPicList, uiPartAddr, uiPartIdx, pcCU->getDepth(uiPartAddr)); |
---|
1321 | pcCU->setMVPNumSubParts( pcAMVPInfo->iN, eRefPicList, uiPartAddr, uiPartIdx, pcCU->getDepth(uiPartAddr)); |
---|
1322 | return; |
---|
1323 | } |
---|
1324 | |
---|
1325 | assert(pcCU->getMVPIdx(eRefPicList,uiPartAddr) >= 0); |
---|
1326 | rcMvPred = pcAMVPInfo->m_acMvCand[pcCU->getMVPIdx(eRefPicList,uiPartAddr)]; |
---|
1327 | return; |
---|
1328 | } |
---|
1329 | |
---|
1330 | /** Function for deriving planar intra prediction. |
---|
1331 | * \param pSrc pointer to reconstructed sample array |
---|
1332 | * \param srcStride the stride of the reconstructed sample array |
---|
1333 | * \param rpDst reference to pointer for the prediction sample array |
---|
1334 | * \param dstStride the stride of the prediction sample array |
---|
1335 | * \param width the width of the block |
---|
1336 | * \param height the height of the block |
---|
1337 | * |
---|
1338 | * This function derives the prediction samples for planar mode (intra coding). |
---|
1339 | */ |
---|
1340 | Void TComPrediction::xPredIntraPlanar( Int* pSrc, Int srcStride, Pel* rpDst, Int dstStride, UInt width, UInt height ) |
---|
1341 | { |
---|
1342 | assert(width == height); |
---|
1343 | |
---|
1344 | Int k, l, bottomLeft, topRight; |
---|
1345 | Int horPred; |
---|
1346 | Int leftColumn[MAX_CU_SIZE], topRow[MAX_CU_SIZE], bottomRow[MAX_CU_SIZE], rightColumn[MAX_CU_SIZE]; |
---|
1347 | UInt blkSize = width; |
---|
1348 | UInt offset2D = width; |
---|
1349 | UInt shift1D = g_aucConvertToBit[ width ] + 2; |
---|
1350 | UInt shift2D = shift1D + 1; |
---|
1351 | |
---|
1352 | // Get left and above reference column and row |
---|
1353 | for(k=0;k<blkSize+1;k++) |
---|
1354 | { |
---|
1355 | topRow[k] = pSrc[k-srcStride]; |
---|
1356 | leftColumn[k] = pSrc[k*srcStride-1]; |
---|
1357 | } |
---|
1358 | |
---|
1359 | // Prepare intermediate variables used in interpolation |
---|
1360 | bottomLeft = leftColumn[blkSize]; |
---|
1361 | topRight = topRow[blkSize]; |
---|
1362 | for (k=0;k<blkSize;k++) |
---|
1363 | { |
---|
1364 | bottomRow[k] = bottomLeft - topRow[k]; |
---|
1365 | rightColumn[k] = topRight - leftColumn[k]; |
---|
1366 | topRow[k] <<= shift1D; |
---|
1367 | leftColumn[k] <<= shift1D; |
---|
1368 | } |
---|
1369 | |
---|
1370 | // Generate prediction signal |
---|
1371 | for (k=0;k<blkSize;k++) |
---|
1372 | { |
---|
1373 | horPred = leftColumn[k] + offset2D; |
---|
1374 | for (l=0;l<blkSize;l++) |
---|
1375 | { |
---|
1376 | horPred += rightColumn[k]; |
---|
1377 | topRow[l] += bottomRow[l]; |
---|
1378 | rpDst[k*dstStride+l] = ( (horPred + topRow[l]) >> shift2D ); |
---|
1379 | } |
---|
1380 | } |
---|
1381 | } |
---|
1382 | |
---|
1383 | /** Function for filtering intra DC predictor. |
---|
1384 | * \param pSrc pointer to reconstructed sample array |
---|
1385 | * \param iSrcStride the stride of the reconstructed sample array |
---|
1386 | * \param rpDst reference to pointer for the prediction sample array |
---|
1387 | * \param iDstStride the stride of the prediction sample array |
---|
1388 | * \param iWidth the width of the block |
---|
1389 | * \param iHeight the height of the block |
---|
1390 | * |
---|
1391 | * This function performs filtering left and top edges of the prediction samples for DC mode (intra coding). |
---|
1392 | */ |
---|
1393 | Void TComPrediction::xDCPredFiltering( Int* pSrc, Int iSrcStride, Pel*& rpDst, Int iDstStride, Int iWidth, Int iHeight ) |
---|
1394 | { |
---|
1395 | Pel* pDst = rpDst; |
---|
1396 | Int x, y, iDstStride2, iSrcStride2; |
---|
1397 | |
---|
1398 | // boundary pixels processing |
---|
1399 | pDst[0] = (Pel)((pSrc[-iSrcStride] + pSrc[-1] + 2 * pDst[0] + 2) >> 2); |
---|
1400 | |
---|
1401 | for ( x = 1; x < iWidth; x++ ) |
---|
1402 | { |
---|
1403 | pDst[x] = (Pel)((pSrc[x - iSrcStride] + 3 * pDst[x] + 2) >> 2); |
---|
1404 | } |
---|
1405 | |
---|
1406 | for ( y = 1, iDstStride2 = iDstStride, iSrcStride2 = iSrcStride-1; y < iHeight; y++, iDstStride2+=iDstStride, iSrcStride2+=iSrcStride ) |
---|
1407 | { |
---|
1408 | pDst[iDstStride2] = (Pel)((pSrc[iSrcStride2] + 3 * pDst[iDstStride2] + 2) >> 2); |
---|
1409 | } |
---|
1410 | |
---|
1411 | return; |
---|
1412 | } |
---|
1413 | #if H_3D_IC |
---|
1414 | /** Function for deriving the position of first non-zero binary bit of a value |
---|
1415 | * \param x input value |
---|
1416 | * |
---|
1417 | * This function derives the position of first non-zero binary bit of a value |
---|
1418 | */ |
---|
1419 | Int GetMSB( UInt x ) |
---|
1420 | { |
---|
1421 | Int iMSB = 0, bits = ( sizeof( Int ) << 3 ), y = 1; |
---|
1422 | |
---|
1423 | while( x > 1 ) |
---|
1424 | { |
---|
1425 | bits >>= 1; |
---|
1426 | y = x >> bits; |
---|
1427 | |
---|
1428 | if( y ) |
---|
1429 | { |
---|
1430 | x = y; |
---|
1431 | iMSB += bits; |
---|
1432 | } |
---|
1433 | } |
---|
1434 | |
---|
1435 | iMSB+=y; |
---|
1436 | |
---|
1437 | return iMSB; |
---|
1438 | } |
---|
1439 | |
---|
1440 | #if !SHARP_ILLUCOMP_REFINE_E0046 |
---|
1441 | /** Function for counting leading number of zeros/ones |
---|
1442 | * \param x input value |
---|
1443 | \ This function counts leading number of zeros for positive numbers and |
---|
1444 | \ leading number of ones for negative numbers. This can be implemented in |
---|
1445 | \ single instructure cycle on many processors. |
---|
1446 | */ |
---|
1447 | |
---|
1448 | Short CountLeadingZerosOnes (Short x) |
---|
1449 | { |
---|
1450 | Short clz; |
---|
1451 | Short i; |
---|
1452 | |
---|
1453 | if(x == 0) |
---|
1454 | { |
---|
1455 | clz = 0; |
---|
1456 | } |
---|
1457 | else |
---|
1458 | { |
---|
1459 | if (x == -1) |
---|
1460 | { |
---|
1461 | clz = 15; |
---|
1462 | } |
---|
1463 | else |
---|
1464 | { |
---|
1465 | if(x < 0) |
---|
1466 | { |
---|
1467 | x = ~x; |
---|
1468 | } |
---|
1469 | clz = 15; |
---|
1470 | for(i = 0;i < 15;++i) |
---|
1471 | { |
---|
1472 | if(x) |
---|
1473 | { |
---|
1474 | clz --; |
---|
1475 | } |
---|
1476 | x = x >> 1; |
---|
1477 | } |
---|
1478 | } |
---|
1479 | } |
---|
1480 | return clz; |
---|
1481 | } |
---|
1482 | #endif |
---|
1483 | |
---|
1484 | /** Function for deriving LM illumination compensation. |
---|
1485 | */ |
---|
1486 | #if SHARP_ILLUCOMP_REFINE_E0046 |
---|
1487 | Void TComPrediction::xGetLLSICPrediction( TComDataCU* pcCU, TComMv *pMv, TComPicYuv *pRefPic, Int &a, Int &b, TextType eType ) |
---|
1488 | #else |
---|
1489 | Void TComPrediction::xGetLLSICPrediction( TComDataCU* pcCU, TComMv *pMv, TComPicYuv *pRefPic, Int &a, Int &b, Int &iShift, TextType eType ) |
---|
1490 | #endif |
---|
1491 | { |
---|
1492 | TComPicYuv *pRecPic = pcCU->getPic()->getPicYuvRec(); |
---|
1493 | Pel *pRec = NULL, *pRef = NULL; |
---|
1494 | UInt uiWidth, uiHeight, uiTmpPartIdx; |
---|
1495 | Int iRecStride = ( eType == TEXT_LUMA ) ? pRecPic->getStride() : pRecPic->getCStride(); |
---|
1496 | Int iRefStride = ( eType == TEXT_LUMA ) ? pRefPic->getStride() : pRefPic->getCStride(); |
---|
1497 | Int iCUPelX, iCUPelY, iRefX, iRefY, iRefOffset, iHor, iVer; |
---|
1498 | |
---|
1499 | iCUPelX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]]; |
---|
1500 | iCUPelY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]]; |
---|
1501 | iHor = pcCU->getSlice()->getIsDepth() ? pMv->getHor() : ( ( pMv->getHor() + 2 ) >> 2 ); |
---|
1502 | iVer = pcCU->getSlice()->getIsDepth() ? pMv->getVer() : ( ( pMv->getVer() + 2 ) >> 2 ); |
---|
1503 | iRefX = iCUPelX + iHor; |
---|
1504 | iRefY = iCUPelY + iVer; |
---|
1505 | if( eType != TEXT_LUMA ) |
---|
1506 | { |
---|
1507 | iHor = pcCU->getSlice()->getIsDepth() ? ( ( pMv->getHor() + 1 ) >> 1 ) : ( ( pMv->getHor() + 4 ) >> 3 ); |
---|
1508 | iVer = pcCU->getSlice()->getIsDepth() ? ( ( pMv->getVer() + 1 ) >> 1 ) : ( ( pMv->getVer() + 4 ) >> 3 ); |
---|
1509 | } |
---|
1510 | uiWidth = ( eType == TEXT_LUMA ) ? pcCU->getWidth( 0 ) : ( pcCU->getWidth( 0 ) >> 1 ); |
---|
1511 | uiHeight = ( eType == TEXT_LUMA ) ? pcCU->getHeight( 0 ) : ( pcCU->getHeight( 0 ) >> 1 ); |
---|
1512 | |
---|
1513 | Int i, j, iCountShift = 0; |
---|
1514 | |
---|
1515 | // LLS parameters estimation --> |
---|
1516 | |
---|
1517 | Int x = 0, y = 0, xx = 0, xy = 0; |
---|
1518 | #if SHARP_ILLUCOMP_REFINE_E0046 |
---|
1519 | Int precShift = std::max(0, (( eType == TEXT_LUMA ) ? g_bitDepthY : g_bitDepthC) - 12); |
---|
1520 | #endif |
---|
1521 | |
---|
1522 | if( pcCU->getPUAbove( uiTmpPartIdx, pcCU->getZorderIdxInCU() ) && iCUPelY > 0 && iRefY > 0 ) |
---|
1523 | { |
---|
1524 | iRefOffset = iHor + iVer * iRefStride - iRefStride; |
---|
1525 | if( eType == TEXT_LUMA ) |
---|
1526 | { |
---|
1527 | pRef = pRefPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
1528 | pRec = pRecPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; |
---|
1529 | } |
---|
1530 | else if( eType == TEXT_CHROMA_U ) |
---|
1531 | { |
---|
1532 | pRef = pRefPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
1533 | pRec = pRecPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; |
---|
1534 | } |
---|
1535 | else |
---|
1536 | { |
---|
1537 | assert( eType == TEXT_CHROMA_V ); |
---|
1538 | pRef = pRefPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
1539 | pRec = pRecPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; |
---|
1540 | } |
---|
1541 | |
---|
1542 | #if SHARP_ILLUCOMP_REFINE_E0046 |
---|
1543 | for( j = 0; j < uiWidth; j+=2 ) |
---|
1544 | #else |
---|
1545 | for( j = 0; j < uiWidth; j++ ) |
---|
1546 | #endif |
---|
1547 | { |
---|
1548 | x += pRef[j]; |
---|
1549 | y += pRec[j]; |
---|
1550 | #if SHARP_ILLUCOMP_REFINE_E0046 |
---|
1551 | xx += (pRef[j] * pRef[j])>>precShift; |
---|
1552 | xy += (pRef[j] * pRec[j])>>precShift; |
---|
1553 | #else |
---|
1554 | xx += pRef[j] * pRef[j]; |
---|
1555 | xy += pRef[j] * pRec[j]; |
---|
1556 | #endif |
---|
1557 | } |
---|
1558 | #if SHARP_ILLUCOMP_REFINE_E0046 |
---|
1559 | iCountShift += g_aucConvertToBit[ uiWidth ] + 1; |
---|
1560 | #else |
---|
1561 | iCountShift += g_aucConvertToBit[ uiWidth ] + 2; |
---|
1562 | #endif |
---|
1563 | } |
---|
1564 | |
---|
1565 | |
---|
1566 | if( pcCU->getPULeft( uiTmpPartIdx, pcCU->getZorderIdxInCU() ) && iCUPelX > 0 && iRefX > 0 ) |
---|
1567 | { |
---|
1568 | iRefOffset = iHor + iVer * iRefStride - 1; |
---|
1569 | if( eType == TEXT_LUMA ) |
---|
1570 | { |
---|
1571 | pRef = pRefPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
1572 | pRec = pRecPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; |
---|
1573 | } |
---|
1574 | else if( eType == TEXT_CHROMA_U ) |
---|
1575 | { |
---|
1576 | pRef = pRefPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
1577 | pRec = pRecPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; |
---|
1578 | } |
---|
1579 | else |
---|
1580 | { |
---|
1581 | assert( eType == TEXT_CHROMA_V ); |
---|
1582 | pRef = pRefPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
1583 | pRec = pRecPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; |
---|
1584 | } |
---|
1585 | |
---|
1586 | #if SHARP_ILLUCOMP_REFINE_E0046 |
---|
1587 | for( i = 0; i < uiHeight; i+=2 ) |
---|
1588 | #else |
---|
1589 | for( i = 0; i < uiHeight; i++ ) |
---|
1590 | #endif |
---|
1591 | { |
---|
1592 | x += pRef[0]; |
---|
1593 | y += pRec[0]; |
---|
1594 | #if SHARP_ILLUCOMP_REFINE_E0046 |
---|
1595 | xx += (pRef[0] * pRef[0])>>precShift; |
---|
1596 | xy += (pRef[0] * pRec[0])>>precShift; |
---|
1597 | |
---|
1598 | pRef += iRefStride*2; |
---|
1599 | pRec += iRecStride*2; |
---|
1600 | #else |
---|
1601 | xx += pRef[0] * pRef[0]; |
---|
1602 | xy += pRef[0] * pRec[0]; |
---|
1603 | |
---|
1604 | pRef += iRefStride; |
---|
1605 | pRec += iRecStride; |
---|
1606 | #endif |
---|
1607 | } |
---|
1608 | #if SHARP_ILLUCOMP_REFINE_E0046 |
---|
1609 | iCountShift += iCountShift > 0 ? 1 : ( g_aucConvertToBit[ uiWidth ] + 1 ); |
---|
1610 | #else |
---|
1611 | iCountShift += iCountShift > 0 ? 1 : ( g_aucConvertToBit[ uiWidth ] + 2 ); |
---|
1612 | #endif |
---|
1613 | } |
---|
1614 | |
---|
1615 | #if SHARP_ILLUCOMP_REFINE_E0046 |
---|
1616 | xy += xx >> IC_REG_COST_SHIFT; |
---|
1617 | xx += xx >> IC_REG_COST_SHIFT; |
---|
1618 | Int a1 = ( xy << iCountShift ) - ((y * x) >> precShift); |
---|
1619 | Int a2 = ( xx << iCountShift ) - ((x * x) >> precShift); |
---|
1620 | const Int iShift = IC_CONST_SHIFT; |
---|
1621 | { |
---|
1622 | #else |
---|
1623 | Int iTempShift = ( ( eType == TEXT_LUMA ) ? g_bitDepthY : g_bitDepthC ) + g_aucConvertToBit[ uiWidth ] + 3 - 15; |
---|
1624 | |
---|
1625 | if( iTempShift > 0 ) |
---|
1626 | { |
---|
1627 | x = ( x + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
1628 | y = ( y + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
1629 | xx = ( xx + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
1630 | xy = ( xy + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
1631 | iCountShift -= iTempShift; |
---|
1632 | } |
---|
1633 | |
---|
1634 | iShift = 13; |
---|
1635 | |
---|
1636 | if( iCountShift == 0 ) |
---|
1637 | { |
---|
1638 | a = 1; |
---|
1639 | b = 0; |
---|
1640 | iShift = 0; |
---|
1641 | } |
---|
1642 | else |
---|
1643 | { |
---|
1644 | Int a1 = ( xy << iCountShift ) - y * x; |
---|
1645 | Int a2 = ( xx << iCountShift ) - x * x; |
---|
1646 | #endif |
---|
1647 | { |
---|
1648 | const Int iShiftA2 = 6; |
---|
1649 | #if !SHARP_ILLUCOMP_REFINE_E0046 |
---|
1650 | const Int iShiftA1 = 15; |
---|
1651 | #endif |
---|
1652 | const Int iAccuracyShift = 15; |
---|
1653 | |
---|
1654 | Int iScaleShiftA2 = 0; |
---|
1655 | Int iScaleShiftA1 = 0; |
---|
1656 | Int a1s = a1; |
---|
1657 | Int a2s = a2; |
---|
1658 | |
---|
1659 | #if SHARP_ILLUCOMP_REFINE_E0046 |
---|
1660 | a1 = Clip3(0, 2*a2, a1); |
---|
1661 | iScaleShiftA2 = GetMSB( abs( a2 ) ) - iShiftA2; |
---|
1662 | iScaleShiftA1 = iScaleShiftA2 - IC_SHIFT_DIFF; |
---|
1663 | #else |
---|
1664 | iScaleShiftA1 = GetMSB( abs( a1 ) ) - iShiftA1; |
---|
1665 | iScaleShiftA2 = GetMSB( abs( a2 ) ) - iShiftA2; |
---|
1666 | #endif |
---|
1667 | |
---|
1668 | if( iScaleShiftA1 < 0 ) |
---|
1669 | { |
---|
1670 | iScaleShiftA1 = 0; |
---|
1671 | } |
---|
1672 | |
---|
1673 | if( iScaleShiftA2 < 0 ) |
---|
1674 | { |
---|
1675 | iScaleShiftA2 = 0; |
---|
1676 | } |
---|
1677 | |
---|
1678 | Int iScaleShiftA = iScaleShiftA2 + iAccuracyShift - iShift - iScaleShiftA1; |
---|
1679 | |
---|
1680 | |
---|
1681 | a2s = a2 >> iScaleShiftA2; |
---|
1682 | |
---|
1683 | a1s = a1 >> iScaleShiftA1; |
---|
1684 | |
---|
1685 | #if SHARP_ILLUCOMP_REFINE_E0046 |
---|
1686 | a = a1s * m_uiaShift[ a2s ]; |
---|
1687 | a = a >> iScaleShiftA; |
---|
1688 | #else |
---|
1689 | if (a2s >= 1) |
---|
1690 | { |
---|
1691 | a = a1s * m_uiaShift[ a2s - 1]; |
---|
1692 | } |
---|
1693 | else |
---|
1694 | { |
---|
1695 | a = 0; |
---|
1696 | } |
---|
1697 | |
---|
1698 | if( iScaleShiftA < 0 ) |
---|
1699 | { |
---|
1700 | a = a << -iScaleShiftA; |
---|
1701 | } |
---|
1702 | else |
---|
1703 | { |
---|
1704 | a = a >> iScaleShiftA; |
---|
1705 | } |
---|
1706 | |
---|
1707 | a = Clip3( -( 1 << 15 ), ( 1 << 15 ) - 1, a ); |
---|
1708 | |
---|
1709 | Int minA = -(1 << (6)); |
---|
1710 | Int maxA = (1 << 6) - 1; |
---|
1711 | if( a <= maxA && a >= minA ) |
---|
1712 | { |
---|
1713 | // do nothing |
---|
1714 | } |
---|
1715 | else |
---|
1716 | { |
---|
1717 | Short n = CountLeadingZerosOnes( a ); |
---|
1718 | a = a >> (9-n); |
---|
1719 | iShift -= (9-n); |
---|
1720 | } |
---|
1721 | #endif |
---|
1722 | b = ( y - ( ( a * x ) >> iShift ) + ( 1 << ( iCountShift - 1 ) ) ) >> iCountShift; |
---|
1723 | } |
---|
1724 | } |
---|
1725 | } |
---|
1726 | #endif |
---|
1727 | |
---|
1728 | #if H_3D_VSP |
---|
1729 | |
---|
1730 | #if NTT_VSP_COMMON_E0207_E0208 |
---|
1731 | // not fully support iRatioTxtPerDepth* != 1 |
---|
1732 | Void TComPrediction::xGetVirtualDepth( TComDataCU *cu, TComPicYuv *picRefDepth, TComMv *mv, UInt partAddr, Int width, Int height, TComYuv *yuvDepth, Int ratioTxtPerDepthX, Int ratioTxtPerDepthY ) |
---|
1733 | { |
---|
1734 | Int nTxtPerDepthX = H_3D_VSP_BLOCKSIZE; |
---|
1735 | Int nTxtPerDepthY = H_3D_VSP_BLOCKSIZE; |
---|
1736 | |
---|
1737 | Int refDepStride = picRefDepth->getStride(); |
---|
1738 | |
---|
1739 | #if NTT_VSP_VECTOR_CLIP_E0208 |
---|
1740 | |
---|
1741 | Int refDepOffset = ( (mv->getHor()+2) >> 2 ) + ( (mv->getVer()+2) >> 2 ) * refDepStride; |
---|
1742 | Pel *refDepth = picRefDepth->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ); |
---|
1743 | |
---|
1744 | if( ratioTxtPerDepthX!=1 || ratioTxtPerDepthY!=1 ) |
---|
1745 | { |
---|
1746 | Int posX, posY; |
---|
1747 | refDepth = picRefDepth->getLumaAddr( ); |
---|
1748 | cu->getPic()->getPicYuvRec()->getTopLeftSamplePos( cu->getAddr(), cu->getZorderIdxInCU() + partAddr, posX, posY ); // top-left position in texture |
---|
1749 | posX /= ratioTxtPerDepthX; // texture position -> depth postion |
---|
1750 | posY /= ratioTxtPerDepthY; |
---|
1751 | refDepOffset += posX + posY * refDepStride; |
---|
1752 | |
---|
1753 | width /= ratioTxtPerDepthX; // texture size -> depth size |
---|
1754 | height /= ratioTxtPerDepthY; |
---|
1755 | } |
---|
1756 | |
---|
1757 | refDepth += refDepOffset; |
---|
1758 | |
---|
1759 | #else // NTT_VSP_VECTOR_CLIP_E0208 |
---|
1760 | |
---|
1761 | Int widthDepth = picRefDepth->getWidth(); |
---|
1762 | Int heightDepth = picRefDepth->getHeight(); |
---|
1763 | Int posX, posY; |
---|
1764 | cu->getPic()->getPicYuvRec()->getTopLeftSamplePos( cu->getAddr(), cu->getZorderIdxInCU() + partAddr, posX, posY ); // top-left position in texture |
---|
1765 | posX /= ratioTxtPerDepthX; // texture position -> depth postion |
---|
1766 | posY /= ratioTxtPerDepthY; |
---|
1767 | |
---|
1768 | posX = Clip3(0, widthDepth-width, posX + ((mv->getHor()+2)>>2)); |
---|
1769 | posY = Clip3(0, heightDepth-height, posY + ((mv->getVer()+2)>>2)); |
---|
1770 | |
---|
1771 | Pel *refDepth = picRefDepth->getLumaAddr() + posX + posY * refDepStride; |
---|
1772 | |
---|
1773 | #endif // NTT_VSP_VECTOR_CLIP_E0208 |
---|
1774 | |
---|
1775 | Int depStride = yuvDepth->getStride(); |
---|
1776 | Pel *depth = yuvDepth->getLumaAddr(); |
---|
1777 | |
---|
1778 | #if NTT_VSP_ADAPTIVE_SPLIT_E0207 |
---|
1779 | |
---|
1780 | if( width<8 || height<8 ) |
---|
1781 | { // no split |
---|
1782 | Int rightOffset = width - 1; |
---|
1783 | Int depStrideBlock = depStride * nTxtPerDepthY; |
---|
1784 | Pel *refDepthTop = refDepth; |
---|
1785 | Pel *refDepthBot = refDepthTop + (height-1)*refDepStride; |
---|
1786 | |
---|
1787 | Pel maxDepth = refDepthTop[0] > refDepthBot[0] ? refDepthTop[0] : refDepthBot[0]; |
---|
1788 | if( maxDepth < refDepthTop[rightOffset] ) { maxDepth = refDepthTop[rightOffset]; } |
---|
1789 | if( maxDepth < refDepthBot[rightOffset] ) { maxDepth = refDepthBot[rightOffset]; } |
---|
1790 | |
---|
1791 | for( Int sY=0; sY<height; sY+=nTxtPerDepthY ) |
---|
1792 | { |
---|
1793 | for( Int sX=0; sX<width; sX+=nTxtPerDepthX ) |
---|
1794 | { |
---|
1795 | depth[sX] = maxDepth; |
---|
1796 | } |
---|
1797 | depth += depStrideBlock; |
---|
1798 | } |
---|
1799 | } |
---|
1800 | else |
---|
1801 | { // split to 4x8, or 8x4 |
---|
1802 | Int blocksize = 8; |
---|
1803 | Int subblocksize = 4; |
---|
1804 | Int depStrideBlock = depStride * blocksize; |
---|
1805 | Pel *depthTmp = NULL; |
---|
1806 | Int depStrideTmp = depStride * nTxtPerDepthY; |
---|
1807 | Int offset[4] = { 0, subblocksize-1, subblocksize, blocksize-1 }; |
---|
1808 | Pel *refDepthTmp[4] = { NULL, NULL, NULL, NULL }; |
---|
1809 | Pel repDepth4x8[2] = {0, 0}; |
---|
1810 | Pel repDepth8x4[2] = {0, 0}; |
---|
1811 | |
---|
1812 | Int refDepStrideBlock = refDepStride * blocksize; |
---|
1813 | Int refDepStrideSubBlock = refDepStride * subblocksize; |
---|
1814 | |
---|
1815 | refDepthTmp[0] = refDepth; |
---|
1816 | refDepthTmp[2] = refDepthTmp[0] + refDepStrideSubBlock; |
---|
1817 | refDepthTmp[1] = refDepthTmp[2] - refDepStride; |
---|
1818 | refDepthTmp[3] = refDepthTmp[1] + refDepStrideSubBlock; |
---|
1819 | |
---|
1820 | for( Int y=0; y<height; y+=blocksize ) |
---|
1821 | { |
---|
1822 | for( Int x=0; x<width; x+=blocksize ) |
---|
1823 | { |
---|
1824 | Bool ULvsBR = false, URvsBL = false; |
---|
1825 | |
---|
1826 | ULvsBR = refDepthTmp[0][x+offset[0]] < refDepthTmp[3][x+offset[3]]; |
---|
1827 | URvsBL = refDepthTmp[0][x+offset[3]] < refDepthTmp[3][x+offset[0]]; |
---|
1828 | |
---|
1829 | if( ULvsBR ^ URvsBL ) |
---|
1830 | { // 4x8 |
---|
1831 | repDepth4x8[0] = refDepthTmp[0][x+offset[0]] > refDepthTmp[0][x+offset[1]] ? refDepthTmp[0][x+offset[0]] : refDepthTmp[0][x+offset[1]]; |
---|
1832 | if( repDepth4x8[0] < refDepthTmp[3][x+offset[0]] ) |
---|
1833 | { |
---|
1834 | repDepth4x8[0] = refDepthTmp[3][x+offset[0]]; |
---|
1835 | } |
---|
1836 | if( repDepth4x8[0] < refDepthTmp[3][x+offset[1]] ) |
---|
1837 | { |
---|
1838 | repDepth4x8[0] = refDepthTmp[3][x+offset[1]]; |
---|
1839 | } |
---|
1840 | repDepth4x8[1] = refDepthTmp[0][x+offset[2]] > refDepthTmp[0][x+offset[3]] ? refDepthTmp[0][x+offset[2]] : refDepthTmp[0][x+offset[3]]; |
---|
1841 | if( repDepth4x8[1] < refDepthTmp[3][x+offset[2]] ) |
---|
1842 | { |
---|
1843 | repDepth4x8[1] = refDepthTmp[3][x+offset[2]]; |
---|
1844 | } |
---|
1845 | if( repDepth4x8[1] < refDepthTmp[3][x+offset[3]] ) |
---|
1846 | { |
---|
1847 | repDepth4x8[1] = refDepthTmp[3][x+offset[3]]; |
---|
1848 | } |
---|
1849 | |
---|
1850 | depthTmp = &depth[x]; |
---|
1851 | for( Int sY=0; sY<blocksize; sY+=nTxtPerDepthY ) |
---|
1852 | { |
---|
1853 | for( Int sX=0; sX<subblocksize; sX+=nTxtPerDepthX ) |
---|
1854 | { |
---|
1855 | depthTmp[sX] = repDepth4x8[0]; |
---|
1856 | } |
---|
1857 | depthTmp += depStrideTmp; |
---|
1858 | } |
---|
1859 | depthTmp = &depth[x+subblocksize]; |
---|
1860 | for( Int sY=0; sY<blocksize; sY+=nTxtPerDepthY ) |
---|
1861 | { |
---|
1862 | for( Int sX=0; sX<subblocksize; sX+=nTxtPerDepthX ) |
---|
1863 | { |
---|
1864 | depthTmp[sX] = repDepth4x8[1]; |
---|
1865 | } |
---|
1866 | depthTmp += depStrideTmp; |
---|
1867 | } |
---|
1868 | } |
---|
1869 | else |
---|
1870 | { // 8x4 |
---|
1871 | repDepth8x4[0] = refDepthTmp[0][x+offset[0]] > refDepthTmp[0][x+offset[3]] ? refDepthTmp[0][x+offset[0]] : refDepthTmp[0][x+offset[3]]; |
---|
1872 | if( repDepth8x4[0] < refDepthTmp[1][x+offset[0]] ) |
---|
1873 | { |
---|
1874 | repDepth8x4[0] = refDepthTmp[1][x+offset[0]]; |
---|
1875 | } |
---|
1876 | if( repDepth8x4[0] < refDepthTmp[1][x+offset[3]] ) |
---|
1877 | { |
---|
1878 | repDepth8x4[0] = refDepthTmp[1][x+offset[3]]; |
---|
1879 | } |
---|
1880 | repDepth8x4[1] = refDepthTmp[2][x+offset[0]] > refDepthTmp[2][x+offset[3]] ? refDepthTmp[2][x+offset[0]] : refDepthTmp[2][x+offset[3]]; |
---|
1881 | if( repDepth8x4[1] < refDepthTmp[3][x+offset[0]] ) |
---|
1882 | { |
---|
1883 | repDepth8x4[1] = refDepthTmp[3][x+offset[0]]; |
---|
1884 | } |
---|
1885 | if( repDepth8x4[1] < refDepthTmp[3][x+offset[3]] ) |
---|
1886 | { |
---|
1887 | repDepth8x4[1] = refDepthTmp[3][x+offset[3]]; |
---|
1888 | } |
---|
1889 | |
---|
1890 | depthTmp = &depth[x]; |
---|
1891 | for( Int sY=0; sY<subblocksize; sY+=nTxtPerDepthY ) |
---|
1892 | { |
---|
1893 | for( Int sX=0; sX<blocksize; sX+=nTxtPerDepthX ) |
---|
1894 | { |
---|
1895 | depthTmp[sX] = repDepth8x4[0]; |
---|
1896 | } |
---|
1897 | depthTmp += depStrideTmp; |
---|
1898 | } |
---|
1899 | for( Int sY=0; sY<subblocksize; sY+=nTxtPerDepthY ) |
---|
1900 | { |
---|
1901 | for( Int sX=0; sX<blocksize; sX+=nTxtPerDepthX ) |
---|
1902 | { |
---|
1903 | depthTmp[sX] = repDepth8x4[1]; |
---|
1904 | } |
---|
1905 | depthTmp += depStrideTmp; |
---|
1906 | } |
---|
1907 | } |
---|
1908 | } |
---|
1909 | refDepthTmp[0] += refDepStrideBlock; |
---|
1910 | refDepthTmp[1] += refDepStrideBlock; |
---|
1911 | refDepthTmp[2] += refDepStrideBlock; |
---|
1912 | refDepthTmp[3] += refDepStrideBlock; |
---|
1913 | depth += depStrideBlock; |
---|
1914 | } |
---|
1915 | } |
---|
1916 | |
---|
1917 | #else // NTT_VSP_ADAPTIVE_SPLIT_E0207 |
---|
1918 | |
---|
1919 | Int rightOffset = nTxtPerDepthX - 1; |
---|
1920 | Int depStrideBlock = depStride * nTxtPerDepthY; |
---|
1921 | Int refDepStrideBlock = refDepStride * nTxtPerDepthY; |
---|
1922 | Pel *refDepthTop = refDepth; |
---|
1923 | Pel *refDepthBot = refDepthTop + (nTxtPerDepthY-1)*refDepStride; |
---|
1924 | |
---|
1925 | for( Int y=0; y<height; y+= nTxtPerDepthY ) |
---|
1926 | { |
---|
1927 | for( Int x=0; x<width; x+=nTxtPerDepthX ) |
---|
1928 | { |
---|
1929 | Pel maxDepth = refDepthTop[x] > refDepthBot[x] ? refDepthTop[x] : refDepthBot[x]; |
---|
1930 | |
---|
1931 | if( maxDepth < refDepthTop[x+rightOffset] ) |
---|
1932 | { |
---|
1933 | maxDepth = refDepthTop[x+rightOffset]; |
---|
1934 | } |
---|
1935 | if( maxDepth < refDepthBot[x+rightOffset] ) |
---|
1936 | { |
---|
1937 | maxDepth = refDepthBot[x+rightOffset]; |
---|
1938 | } |
---|
1939 | |
---|
1940 | depth[x] = maxDepth; |
---|
1941 | |
---|
1942 | } |
---|
1943 | refDepthTop += refDepStrideBlock; |
---|
1944 | refDepthBot += refDepStrideBlock; |
---|
1945 | depth += depStrideBlock; |
---|
1946 | } |
---|
1947 | |
---|
1948 | #endif // NTT_VSP_ADAPTIVE_SPLIT_E0207 |
---|
1949 | } |
---|
1950 | |
---|
1951 | 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 ) |
---|
1952 | { |
---|
1953 | Int nTxtPerDepthX = H_3D_VSP_BLOCKSIZE; |
---|
1954 | Int nTxtPerDepthY = H_3D_VSP_BLOCKSIZE; |
---|
1955 | |
---|
1956 | Int refStride = picRef->getStride(); |
---|
1957 | Int dstStride = yuvDst->getStride(); |
---|
1958 | Int depStride = yuvDepth->getStride(); |
---|
1959 | Int refStrideBlock = refStride * nTxtPerDepthY; |
---|
1960 | Int dstStrideBlock = dstStride * nTxtPerDepthY; |
---|
1961 | Int depStrideBlock = depStride * nTxtPerDepthY; |
---|
1962 | |
---|
1963 | Pel *ref = picRef->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ); |
---|
1964 | Pel *dst = yuvDst->getLumaAddr(partAddr); |
---|
1965 | Pel *depth = yuvDepth->getLumaAddr(); |
---|
1966 | |
---|
1967 | #if !(NTT_VSP_DC_BUGFIX_E0208) |
---|
1968 | Int widthLuma = picRef->getWidth(); |
---|
1969 | Int posX, posY; |
---|
1970 | cu->getPic()->getPicYuvRec()->getTopLeftSamplePos( cu->getAddr(), cu->getZorderIdxInCU() + partAddr, posX, posY ); // top-left position in texture |
---|
1971 | #endif |
---|
1972 | |
---|
1973 | #if H_3D_VSP_BLOCKSIZE == 1 |
---|
1974 | #if H_3D_VSP_CONSTRAINED |
---|
1975 | //get LUT based horizontal reference range |
---|
1976 | Int range = xGetConstrainedSize(width, height); |
---|
1977 | |
---|
1978 | // The minimum depth value |
---|
1979 | Int minRelativePos = MAX_INT; |
---|
1980 | Int maxRelativePos = MIN_INT; |
---|
1981 | |
---|
1982 | Pel* depthTemp, *depthInitial=depth; |
---|
1983 | for (Int yTxt = 0; yTxt < height; yTxt++) |
---|
1984 | { |
---|
1985 | for (Int xTxt = 0; xTxt < width; xTxt++) |
---|
1986 | { |
---|
1987 | if (depthPosX+xTxt < widthDepth) |
---|
1988 | { |
---|
1989 | depthTemp = depthInitial + xTxt; |
---|
1990 | } |
---|
1991 | else |
---|
1992 | { |
---|
1993 | depthTemp = depthInitial + (widthDepth - depthPosX - 1); |
---|
1994 | } |
---|
1995 | |
---|
1996 | Int disparity = shiftLUT[ *depthTemp ]; // << iShiftPrec; |
---|
1997 | Int disparityInt = disparity >> 2; |
---|
1998 | |
---|
1999 | if( disparity <= 0) |
---|
2000 | { |
---|
2001 | if (minRelativePos > disparityInt+xTxt) |
---|
2002 | { |
---|
2003 | minRelativePos = disparityInt+xTxt; |
---|
2004 | } |
---|
2005 | } |
---|
2006 | else |
---|
2007 | { |
---|
2008 | if (maxRelativePos < disparityInt+xTxt) |
---|
2009 | { |
---|
2010 | maxRelativePos = disparityInt+xTxt; |
---|
2011 | } |
---|
2012 | } |
---|
2013 | } |
---|
2014 | if (depthPosY+yTxt < heightDepth) |
---|
2015 | { |
---|
2016 | depthInitial = depthInitial + depStride; |
---|
2017 | } |
---|
2018 | } |
---|
2019 | |
---|
2020 | Int disparity_tmp = shiftLUT[ *depth ]; // << iShiftPrec; |
---|
2021 | if (disparity_tmp <= 0) |
---|
2022 | { |
---|
2023 | maxRelativePos = minRelativePos + range -1 ; |
---|
2024 | } |
---|
2025 | else |
---|
2026 | { |
---|
2027 | minRelativePos = maxRelativePos - range +1 ; |
---|
2028 | } |
---|
2029 | #endif |
---|
2030 | #endif // H_3D_VSP_BLOCKSIZE == 1 |
---|
2031 | |
---|
2032 | TComMv dv(0, 0); |
---|
2033 | |
---|
2034 | for ( Int yTxt = 0; yTxt < height; yTxt += nTxtPerDepthY ) |
---|
2035 | { |
---|
2036 | for ( Int xTxt = 0; xTxt < width; xTxt += nTxtPerDepthX ) |
---|
2037 | { |
---|
2038 | Pel repDepth = depth[ xTxt ]; |
---|
2039 | assert( repDepth >= 0 && repDepth <= 255 ); |
---|
2040 | |
---|
2041 | Int disparity = shiftLUT[ repDepth ]; // remove << iShiftPrec ?? |
---|
2042 | Int xFrac = disparity & 0x3; |
---|
2043 | |
---|
2044 | #if NTT_VSP_DC_BUGFIX_E0208 |
---|
2045 | |
---|
2046 | dv.setHor( disparity ); |
---|
2047 | cu->clipMv( dv ); |
---|
2048 | |
---|
2049 | Int refOffset = xTxt + (dv.getHor() >> 2); |
---|
2050 | |
---|
2051 | #if H_3D_VSP_CONSTRAINED |
---|
2052 | if(refOffset<minRelativePos || refOffset>maxRelativePos) |
---|
2053 | { |
---|
2054 | xFrac = 0; |
---|
2055 | } |
---|
2056 | refOffset = Clip3(minRelativePos, maxRelativePos, refOffset); |
---|
2057 | #endif |
---|
2058 | |
---|
2059 | assert( ref[refOffset] >= 0 && ref[refOffset]<= 255 ); |
---|
2060 | m_if.filterHorLuma( &ref[refOffset], refStride, &dst[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !isBi ); |
---|
2061 | |
---|
2062 | #else // NTT_VSP_DC_BUGFIX_E0208 |
---|
2063 | |
---|
2064 | for( Int j=0; j < nTxtPerDepthX; j++ ) |
---|
2065 | { |
---|
2066 | Int refOffset = xTxt+j + (disparity >> 2); |
---|
2067 | #if H_3D_VSP_CONSTRAINED |
---|
2068 | if(refOffset<minRelativePos || refOffset>maxRelativePos) |
---|
2069 | { |
---|
2070 | xFrac = 0; |
---|
2071 | } |
---|
2072 | refOffset = Clip3(minRelativePos, maxRelativePos, refOffset); |
---|
2073 | #endif |
---|
2074 | Int absX = posX + refOffset; |
---|
2075 | |
---|
2076 | if (xFrac == 0) |
---|
2077 | { |
---|
2078 | absX = Clip3(0, widthLuma-1, absX); |
---|
2079 | } |
---|
2080 | else |
---|
2081 | { |
---|
2082 | absX = Clip3(4, widthLuma-5, absX); |
---|
2083 | } |
---|
2084 | |
---|
2085 | refOffset = absX - posX; |
---|
2086 | assert( ref[refOffset] >= 0 && ref[refOffset] <= 255 ); |
---|
2087 | |
---|
2088 | m_if.filterHorLuma( &ref[refOffset], refStride, &dst[xTxt+j], dstStride, 1, nTxtPerDepthY, xFrac, !isBi ); |
---|
2089 | } |
---|
2090 | |
---|
2091 | #endif // NTT_VSP_DC_BUGFIX_E0208 |
---|
2092 | |
---|
2093 | } |
---|
2094 | ref += refStrideBlock; |
---|
2095 | dst += dstStrideBlock; |
---|
2096 | depth += depStrideBlock; |
---|
2097 | } |
---|
2098 | |
---|
2099 | } |
---|
2100 | |
---|
2101 | 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 ) |
---|
2102 | { |
---|
2103 | #if (H_3D_VSP_BLOCKSIZE==1) |
---|
2104 | Int nTxtPerDepthX = 1; |
---|
2105 | Int nTxtPerDepthY = 1; |
---|
2106 | #else |
---|
2107 | Int nTxtPerDepthX = H_3D_VSP_BLOCKSIZE >> 1; |
---|
2108 | Int nTxtPerDepthY = H_3D_VSP_BLOCKSIZE >> 1; |
---|
2109 | #endif |
---|
2110 | |
---|
2111 | Int refStride = picRef->getCStride(); |
---|
2112 | Int dstStride = yuvDst->getCStride(); |
---|
2113 | Int depStride = yuvDepth->getStride(); |
---|
2114 | Int refStrideBlock = refStride * nTxtPerDepthY; |
---|
2115 | Int dstStrideBlock = dstStride * nTxtPerDepthY; |
---|
2116 | Int depStrideBlock = depStride * (nTxtPerDepthY<<1); |
---|
2117 | |
---|
2118 | Pel *refCb = picRef->getCbAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ); |
---|
2119 | Pel *refCr = picRef->getCrAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ); |
---|
2120 | Pel *dstCb = yuvDst->getCbAddr(partAddr); |
---|
2121 | Pel *dstCr = yuvDst->getCrAddr(partAddr); |
---|
2122 | Pel *depth = yuvDepth->getLumaAddr(); |
---|
2123 | |
---|
2124 | #if !(NTT_VSP_DC_BUGFIX_E0208) |
---|
2125 | Int widthChroma = picRef->getWidth() >> 1; |
---|
2126 | Int posX, posY; |
---|
2127 | cu->getPic()->getPicYuvRec()->getTopLeftSamplePos( cu->getAddr(), cu->getZorderIdxInCU() + partAddr, posX, posY ); // top-left position in texture |
---|
2128 | posX >>= 1; |
---|
2129 | posY >>= 1; |
---|
2130 | #endif |
---|
2131 | |
---|
2132 | #if H_3D_VSP_BLOCKSIZE == 1 |
---|
2133 | #if H_3D_VSP_CONSTRAINED |
---|
2134 | //get LUT based horizontal reference range |
---|
2135 | Int range = xGetConstrainedSize(width, height, false); |
---|
2136 | |
---|
2137 | // The minimum depth value |
---|
2138 | Int minRelativePos = MAX_INT; |
---|
2139 | Int maxRelativePos = MIN_INT; |
---|
2140 | |
---|
2141 | Int depthTmp; |
---|
2142 | for (Int yTxt=0; yTxt<height; yTxt++) |
---|
2143 | { |
---|
2144 | for (Int xTxt=0; xTxt<width; xTxt++) |
---|
2145 | { |
---|
2146 | depthTmp = m_pDepthBlock[xTxt+yTxt*width]; |
---|
2147 | Int disparity = shiftLUT[ depthTmp ]; // << iShiftPrec; |
---|
2148 | Int disparityInt = disparity >> 3;//in chroma resolution |
---|
2149 | |
---|
2150 | if (disparityInt < 0) |
---|
2151 | { |
---|
2152 | if (minRelativePos > disparityInt+xTxt) |
---|
2153 | { |
---|
2154 | minRelativePos = disparityInt+xTxt; |
---|
2155 | } |
---|
2156 | } |
---|
2157 | else |
---|
2158 | { |
---|
2159 | if (maxRelativePos < disparityInt+xTxt) |
---|
2160 | { |
---|
2161 | maxRelativePos = disparityInt+xTxt; |
---|
2162 | } |
---|
2163 | } |
---|
2164 | } |
---|
2165 | } |
---|
2166 | |
---|
2167 | depthTmp = m_pDepthBlock[0]; |
---|
2168 | Int disparity_tmp = shiftLUT[ depthTmp ]; // << iShiftPrec; |
---|
2169 | if ( disparity_tmp < 0 ) |
---|
2170 | { |
---|
2171 | maxRelativePos = minRelativePos + range - 1; |
---|
2172 | } |
---|
2173 | else |
---|
2174 | { |
---|
2175 | minRelativePos = maxRelativePos - range + 1; |
---|
2176 | } |
---|
2177 | |
---|
2178 | #endif // H_3D_VSP_CONSTRAINED |
---|
2179 | #endif // H_3D_VSP_BLOCKSIZE == 1 |
---|
2180 | |
---|
2181 | TComMv dv(0, 0); |
---|
2182 | // luma size -> chroma size |
---|
2183 | height >>= 1; |
---|
2184 | width >>= 1; |
---|
2185 | |
---|
2186 | for ( Int yTxt = 0; yTxt < height; yTxt += nTxtPerDepthY ) |
---|
2187 | { |
---|
2188 | for ( Int xTxt = 0; xTxt < width; xTxt += nTxtPerDepthX ) |
---|
2189 | { |
---|
2190 | Pel repDepth = depth[ xTxt<<1 ]; |
---|
2191 | assert( repDepth >= 0 && repDepth <= 255 ); |
---|
2192 | |
---|
2193 | Int disparity = shiftLUT[ repDepth ]; // remove << iShiftPrec; |
---|
2194 | Int xFrac = disparity & 0x7; |
---|
2195 | |
---|
2196 | #if NTT_VSP_DC_BUGFIX_E0208 |
---|
2197 | |
---|
2198 | dv.setHor( disparity ); |
---|
2199 | cu->clipMv( dv ); |
---|
2200 | |
---|
2201 | Int refOffset = xTxt + (dv.getHor() >> 3); |
---|
2202 | |
---|
2203 | #if H_3D_VSP_CONSTRAINED |
---|
2204 | if(refOffset<minRelativePos || refOffset>maxRelativePos) |
---|
2205 | { |
---|
2206 | xFrac = 0; |
---|
2207 | } |
---|
2208 | refOffset = Clip3(minRelativePos, maxRelativePos, refOffset); |
---|
2209 | #endif |
---|
2210 | |
---|
2211 | assert( refCb[refOffset] >= 0 && refCb[refOffset]<= 255 ); |
---|
2212 | assert( refCr[refOffset] >= 0 && refCr[refOffset]<= 255 ); |
---|
2213 | |
---|
2214 | m_if.filterHorChroma( &refCb[refOffset], refStride, &dstCb[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !isBi ); |
---|
2215 | m_if.filterHorChroma( &refCr[refOffset], refStride, &dstCr[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !isBi ); |
---|
2216 | |
---|
2217 | #else // NTT_VSP_DC_BUGFIX_E0208 |
---|
2218 | |
---|
2219 | for( Int j=0; j < nTxtPerDepthX; j++ ) |
---|
2220 | { |
---|
2221 | Int refOffset = xTxt+j + (disparity >> 3); |
---|
2222 | #if H_3D_VSP_CONSTRAINED |
---|
2223 | if(refOffset<minRelativePos || refOffset>maxRelativePos) |
---|
2224 | { |
---|
2225 | xFrac = 0; |
---|
2226 | } |
---|
2227 | refOffset = Clip3(minRelativePos, maxRelativePos, refOffset); |
---|
2228 | #endif |
---|
2229 | Int absX = posX + refOffset; |
---|
2230 | |
---|
2231 | if (xFrac == 0) |
---|
2232 | { |
---|
2233 | absX = Clip3(0, widthChroma-1, absX); |
---|
2234 | } |
---|
2235 | else |
---|
2236 | { |
---|
2237 | absX = Clip3(4, widthChroma-5, absX); |
---|
2238 | } |
---|
2239 | |
---|
2240 | refOffset = absX - posX; |
---|
2241 | assert( refCb[refOffset] >= 0 && refCb[refOffset] <= 255 ); |
---|
2242 | assert( refCr[refOffset] >= 0 && refCr[refOffset] <= 255 ); |
---|
2243 | |
---|
2244 | m_if.filterHorChroma( &refCb[refOffset], refStride, &dstCb[xTxt+j], dstStride, 1, nTxtPerDepthY, xFrac, !isBi ); |
---|
2245 | m_if.filterHorChroma( &refCr[refOffset], refStride, &dstCr[xTxt+j], dstStride, 1, nTxtPerDepthY, xFrac, !isBi ); |
---|
2246 | } |
---|
2247 | |
---|
2248 | #endif // NTT_VSP_DC_BUGFIX_E0208 |
---|
2249 | } |
---|
2250 | refCb += refStrideBlock; |
---|
2251 | refCr += refStrideBlock; |
---|
2252 | dstCb += dstStrideBlock; |
---|
2253 | dstCr += dstStrideBlock; |
---|
2254 | depth += depStrideBlock; |
---|
2255 | } |
---|
2256 | |
---|
2257 | } |
---|
2258 | #else // NTT_VSP_COMMON_E0207_E0208 |
---|
2259 | |
---|
2260 | // Input: |
---|
2261 | // refPic: Ref picture. Full picture, with padding |
---|
2262 | // posX, posY: PU position, texture |
---|
2263 | // sizeX, sizeY: PU size |
---|
2264 | // partAddr: z-order index |
---|
2265 | // dv: disparity vector. derived from neighboring blocks |
---|
2266 | // |
---|
2267 | // Output: dstPic, PU predictor 64x64 |
---|
2268 | Void TComPrediction::xPredInterLumaBlkFromDM( TComPicYuv *refPic, TComPicYuv *pPicBaseDepth, Int* pShiftLUT, TComMv* dv, UInt partAddr,Int posX, Int posY |
---|
2269 | , Int sizeX, Int sizeY, Bool isDepth, TComYuv *&dstPic, Bool bi ) |
---|
2270 | { |
---|
2271 | Int widthLuma; |
---|
2272 | Int heightLuma; |
---|
2273 | |
---|
2274 | if (isDepth) |
---|
2275 | { |
---|
2276 | widthLuma = pPicBaseDepth->getWidth(); |
---|
2277 | heightLuma = pPicBaseDepth->getHeight(); |
---|
2278 | } |
---|
2279 | else |
---|
2280 | { |
---|
2281 | widthLuma = refPic->getWidth(); |
---|
2282 | heightLuma = refPic->getHeight(); |
---|
2283 | } |
---|
2284 | |
---|
2285 | #if H_3D_VSP_BLOCKSIZE != 1 |
---|
2286 | Int widthDepth = pPicBaseDepth->getWidth(); |
---|
2287 | Int heightDepth = pPicBaseDepth->getHeight(); |
---|
2288 | #endif |
---|
2289 | |
---|
2290 | #if H_3D_VSP_CONSTRAINED |
---|
2291 | Int widthDepth = pPicBaseDepth->getWidth(); |
---|
2292 | Int heightDepth = pPicBaseDepth->getHeight(); |
---|
2293 | #endif |
---|
2294 | |
---|
2295 | Int nTxtPerDepthX = widthLuma / ( pPicBaseDepth->getWidth() ); // texture pixel # per depth pixel |
---|
2296 | Int nTxtPerDepthY = heightLuma / ( pPicBaseDepth->getHeight() ); |
---|
2297 | |
---|
2298 | Int refStride = refPic->getStride(); |
---|
2299 | Int dstStride = dstPic->getStride(); |
---|
2300 | Int depStride = pPicBaseDepth->getStride(); |
---|
2301 | Int depthPosX = Clip3(0, widthLuma - sizeX, (posX/nTxtPerDepthX) + ((dv->getHor()+2)>>2)); |
---|
2302 | Int depthPosY = Clip3(0, heightLuma- sizeY, (posY/nTxtPerDepthY) + ((dv->getVer()+2)>>2)); |
---|
2303 | Pel *ref = refPic->getLumaAddr() + posX + posY * refStride; |
---|
2304 | Pel *dst = dstPic->getLumaAddr(partAddr); |
---|
2305 | Pel *depth = pPicBaseDepth->getLumaAddr() + depthPosX + depthPosY * depStride; |
---|
2306 | |
---|
2307 | #if H_3D_VSP_BLOCKSIZE != 1 |
---|
2308 | #if H_3D_VSP_BLOCKSIZE == 2 |
---|
2309 | Int dW = sizeX>>1; |
---|
2310 | Int dH = sizeY>>1; |
---|
2311 | #endif |
---|
2312 | #if H_3D_VSP_BLOCKSIZE == 4 |
---|
2313 | Int dW = sizeX>>2; |
---|
2314 | Int dH = sizeY>>2; |
---|
2315 | #endif |
---|
2316 | { |
---|
2317 | Pel* depthi = depth; |
---|
2318 | for (Int j = 0; j < dH; j++) |
---|
2319 | { |
---|
2320 | for (Int i = 0; i < dW; i++) |
---|
2321 | { |
---|
2322 | Pel* depthTmp; |
---|
2323 | #if H_3D_VSP_BLOCKSIZE == 2 |
---|
2324 | if (depthPosX + (i<<1) < widthDepth) |
---|
2325 | depthTmp = depthi + (i << 1); |
---|
2326 | else |
---|
2327 | depthTmp = depthi + (widthDepth - depthPosX - 1); |
---|
2328 | #endif |
---|
2329 | #if H_3D_VSP_BLOCKSIZE == 4 |
---|
2330 | if (depthPosX + (i<<2) < widthDepth) |
---|
2331 | depthTmp = depthi + (i << 2); |
---|
2332 | else |
---|
2333 | depthTmp = depthi + (widthDepth - depthPosX - 1); |
---|
2334 | #endif |
---|
2335 | Int maxV = 0; |
---|
2336 | for (Int blockj = 0; blockj < H_3D_VSP_BLOCKSIZE; blockj+=(H_3D_VSP_BLOCKSIZE-1)) |
---|
2337 | { |
---|
2338 | Int iX = 0; |
---|
2339 | for (Int blocki = 0; blocki < H_3D_VSP_BLOCKSIZE; blocki+=(H_3D_VSP_BLOCKSIZE-1)) |
---|
2340 | { |
---|
2341 | if (maxV < depthTmp[iX]) |
---|
2342 | maxV = depthTmp[iX]; |
---|
2343 | #if H_3D_VSP_BLOCKSIZE == 2 |
---|
2344 | if (depthPosX + (i<<1) + blocki < widthDepth - 1) |
---|
2345 | #else // H_3D_VSP_BLOCKSIZE == 4 |
---|
2346 | if (depthPosX + (i<<2) + blocki < widthDepth - 1) |
---|
2347 | #endif |
---|
2348 | iX = (H_3D_VSP_BLOCKSIZE-1); |
---|
2349 | } |
---|
2350 | #if H_3D_VSP_BLOCKSIZE == 2 |
---|
2351 | if (depthPosY + (j<<1) + blockj < heightDepth - 1) |
---|
2352 | #else // H_3D_VSP_BLOCKSIZE == 4 |
---|
2353 | if (depthPosY + (j<<2) + blockj < heightDepth - 1) |
---|
2354 | #endif |
---|
2355 | depthTmp += depStride * (H_3D_VSP_BLOCKSIZE-1); |
---|
2356 | } |
---|
2357 | m_pDepthBlock[i+j*dW] = maxV; |
---|
2358 | } // end of i < dW |
---|
2359 | #if H_3D_VSP_BLOCKSIZE == 2 |
---|
2360 | if (depthPosY + ((j+1)<<1) < heightDepth) |
---|
2361 | depthi += (depStride << 1); |
---|
2362 | else |
---|
2363 | depthi = depth + (heightDepth-depthPosY-1)*depStride; |
---|
2364 | #endif |
---|
2365 | #if H_3D_VSP_BLOCKSIZE == 4 |
---|
2366 | if (depthPosY + ((j+1)<<2) < heightDepth) // heightDepth-1 |
---|
2367 | depthi += (depStride << 2); |
---|
2368 | else |
---|
2369 | depthi = depth + (heightDepth-depthPosY-1)*depStride; // the last line |
---|
2370 | #endif |
---|
2371 | } |
---|
2372 | } |
---|
2373 | #endif // H_3D_VSP_BLOCKSIZE != 1 |
---|
2374 | |
---|
2375 | #if H_3D_VSP_BLOCKSIZE == 1 |
---|
2376 | #if H_3D_VSP_CONSTRAINED |
---|
2377 | //get LUT based horizontal reference range |
---|
2378 | Int range = xGetConstrainedSize(sizeX, sizeY); |
---|
2379 | |
---|
2380 | // The minimum depth value |
---|
2381 | Int minRelativePos = MAX_INT; |
---|
2382 | Int maxRelativePos = MIN_INT; |
---|
2383 | |
---|
2384 | Pel* depthTemp, *depthInitial=depth; |
---|
2385 | for (Int yTxt = 0; yTxt < sizeY; yTxt++) |
---|
2386 | { |
---|
2387 | for (Int xTxt = 0; xTxt < sizeX; xTxt++) |
---|
2388 | { |
---|
2389 | if (depthPosX+xTxt < widthDepth) |
---|
2390 | depthTemp = depthInitial + xTxt; |
---|
2391 | else |
---|
2392 | depthTemp = depthInitial + (widthDepth - depthPosX - 1); |
---|
2393 | |
---|
2394 | Int disparity = pShiftLUT[ *depthTemp ]; // << iShiftPrec; |
---|
2395 | Int disparityInt = disparity >> 2; |
---|
2396 | |
---|
2397 | if( disparity <= 0) |
---|
2398 | { |
---|
2399 | if (minRelativePos > disparityInt+xTxt) |
---|
2400 | minRelativePos = disparityInt+xTxt; |
---|
2401 | } |
---|
2402 | else |
---|
2403 | { |
---|
2404 | if (maxRelativePos < disparityInt+xTxt) |
---|
2405 | maxRelativePos = disparityInt+xTxt; |
---|
2406 | } |
---|
2407 | } |
---|
2408 | if (depthPosY+yTxt < heightDepth) |
---|
2409 | depthInitial = depthInitial + depStride; |
---|
2410 | } |
---|
2411 | |
---|
2412 | Int disparity_tmp = pShiftLUT[ *depth ]; // << iShiftPrec; |
---|
2413 | if (disparity_tmp <= 0) |
---|
2414 | maxRelativePos = minRelativePos + range -1 ; |
---|
2415 | else |
---|
2416 | minRelativePos = maxRelativePos - range +1 ; |
---|
2417 | #endif |
---|
2418 | #endif // H_3D_VSP_BLOCKSIZE == 1 |
---|
2419 | |
---|
2420 | #if H_3D_VSP_BLOCKSIZE != 1 |
---|
2421 | Int yDepth = 0; |
---|
2422 | #endif |
---|
2423 | for ( Int yTxt = 0; yTxt < sizeY; yTxt += nTxtPerDepthY ) |
---|
2424 | { |
---|
2425 | for ( Int xTxt = 0, xDepth = 0; xTxt < sizeX; xTxt += nTxtPerDepthX, xDepth++ ) |
---|
2426 | { |
---|
2427 | Pel repDepth = 0; // to store the depth value used for warping |
---|
2428 | #if H_3D_VSP_BLOCKSIZE == 1 |
---|
2429 | repDepth = depth[xDepth]; |
---|
2430 | #endif |
---|
2431 | #if H_3D_VSP_BLOCKSIZE == 2 |
---|
2432 | repDepth = m_pDepthBlock[(xTxt>>1) + (yTxt>>1)*dW]; |
---|
2433 | #endif |
---|
2434 | #if H_3D_VSP_BLOCKSIZE == 4 |
---|
2435 | repDepth = m_pDepthBlock[(xTxt>>2) + (yTxt>>2)*dW]; |
---|
2436 | #endif |
---|
2437 | |
---|
2438 | assert( repDepth >= 0 && repDepth <= 255 ); |
---|
2439 | Int disparity = pShiftLUT[ repDepth ]; // remove << iShiftPrec ?? |
---|
2440 | Int refOffset = xTxt + (disparity >> 2); |
---|
2441 | Int xFrac = disparity & 0x3; |
---|
2442 | #if H_3D_VSP_CONSTRAINED |
---|
2443 | if(refOffset<minRelativePos || refOffset>maxRelativePos) |
---|
2444 | xFrac = 0; |
---|
2445 | refOffset = Clip3(minRelativePos, maxRelativePos, refOffset); |
---|
2446 | #endif |
---|
2447 | Int absX = posX + refOffset; |
---|
2448 | |
---|
2449 | if (xFrac == 0) |
---|
2450 | absX = Clip3(0, widthLuma-1, absX); |
---|
2451 | else |
---|
2452 | absX = Clip3(4, widthLuma-5, absX); |
---|
2453 | |
---|
2454 | refOffset = absX - posX; |
---|
2455 | |
---|
2456 | assert( ref[refOffset] >= 0 && ref[refOffset]<= 255 ); |
---|
2457 | m_if.filterHorLuma( &ref[refOffset], refStride, &dst[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !bi ); |
---|
2458 | } |
---|
2459 | ref += refStride*nTxtPerDepthY; |
---|
2460 | dst += dstStride*nTxtPerDepthY; |
---|
2461 | depth += depStride; |
---|
2462 | #if H_3D_VSP_BLOCKSIZE != 1 |
---|
2463 | yDepth++; |
---|
2464 | #endif |
---|
2465 | |
---|
2466 | } |
---|
2467 | } |
---|
2468 | |
---|
2469 | Void TComPrediction::xPredInterChromaBlkFromDM ( TComPicYuv *refPic, TComPicYuv *pPicBaseDepth, Int* pShiftLUT, TComMv*dv, UInt partAddr, Int posX, Int posY |
---|
2470 | , Int sizeX, Int sizeY, Bool isDepth, TComYuv *&dstPic, Bool bi) |
---|
2471 | { |
---|
2472 | Int refStride = refPic->getCStride(); |
---|
2473 | Int dstStride = dstPic->getCStride(); |
---|
2474 | Int depStride = pPicBaseDepth->getStride(); |
---|
2475 | |
---|
2476 | Int widthChroma, heightChroma; |
---|
2477 | if( isDepth) |
---|
2478 | { |
---|
2479 | widthChroma = pPicBaseDepth->getWidth()>>1; |
---|
2480 | heightChroma = pPicBaseDepth->getHeight()>>1; |
---|
2481 | } |
---|
2482 | else |
---|
2483 | { |
---|
2484 | widthChroma = refPic->getWidth()>>1; |
---|
2485 | heightChroma = refPic->getHeight()>>1; |
---|
2486 | } |
---|
2487 | |
---|
2488 | // Below is only for Texture chroma component |
---|
2489 | |
---|
2490 | Int widthDepth = pPicBaseDepth->getWidth(); |
---|
2491 | Int heightDepth = pPicBaseDepth->getHeight(); |
---|
2492 | |
---|
2493 | Int nTxtPerDepthX, nTxtPerDepthY; // Number of texture samples per one depth sample |
---|
2494 | Int nDepthPerTxtX, nDepthPerTxtY; // Number of depth samples per one texture sample |
---|
2495 | |
---|
2496 | Int depthPosX; // Starting position in depth image |
---|
2497 | Int depthPosY; |
---|
2498 | |
---|
2499 | if ( widthChroma > widthDepth ) |
---|
2500 | { |
---|
2501 | nTxtPerDepthX = widthChroma / widthDepth; |
---|
2502 | nDepthPerTxtX = 1; |
---|
2503 | depthPosX = posX / nTxtPerDepthX + ((dv->getHor()+2)>>2); |
---|
2504 | } |
---|
2505 | else |
---|
2506 | { |
---|
2507 | nTxtPerDepthX = 1; |
---|
2508 | nDepthPerTxtX = widthDepth / widthChroma; |
---|
2509 | depthPosX = posX * nDepthPerTxtX + ((dv->getHor()+2)>>2); |
---|
2510 | } |
---|
2511 | depthPosX = Clip3(0, widthDepth - (sizeX<<1), depthPosX); |
---|
2512 | if ( heightChroma > heightDepth ) |
---|
2513 | { |
---|
2514 | nTxtPerDepthY = heightChroma / heightDepth; |
---|
2515 | nDepthPerTxtY = 1; |
---|
2516 | depthPosY = posY / nTxtPerDepthY + ((dv->getVer()+2)>>2); |
---|
2517 | } |
---|
2518 | else |
---|
2519 | { |
---|
2520 | nTxtPerDepthY = 1; |
---|
2521 | nDepthPerTxtY = heightDepth / heightChroma; |
---|
2522 | depthPosY = posY * nDepthPerTxtY + ((dv->getVer()+2)>>2); |
---|
2523 | } |
---|
2524 | depthPosY = Clip3(0, heightDepth - (sizeY<<1), depthPosY); |
---|
2525 | |
---|
2526 | Pel *refCb = refPic->getCbAddr() + posX + posY * refStride; |
---|
2527 | Pel *refCr = refPic->getCrAddr() + posX + posY * refStride; |
---|
2528 | Pel *dstCb = dstPic->getCbAddr(partAddr); |
---|
2529 | Pel *dstCr = dstPic->getCrAddr(partAddr); |
---|
2530 | Pel *depth = pPicBaseDepth->getLumaAddr() + depthPosX + depthPosY * depStride; // move the pointer to the current depth pixel position |
---|
2531 | |
---|
2532 | Int refStrideBlock = refStride * nTxtPerDepthY; |
---|
2533 | Int dstStrideBlock = dstStride * nTxtPerDepthY; |
---|
2534 | Int depStrideBlock = depStride * nDepthPerTxtY; |
---|
2535 | |
---|
2536 | if ( widthChroma > widthDepth ) // We assume |
---|
2537 | { |
---|
2538 | assert( heightChroma > heightDepth ); |
---|
2539 | printf("This branch should never been reached.\n"); |
---|
2540 | exit(0); |
---|
2541 | } |
---|
2542 | else |
---|
2543 | { |
---|
2544 | #if H_3D_VSP_BLOCKSIZE == 1 |
---|
2545 | Int dW = sizeX; |
---|
2546 | Int dH = sizeY; |
---|
2547 | Int sW = 2; // search window size |
---|
2548 | Int sH = 2; |
---|
2549 | #endif |
---|
2550 | #if H_3D_VSP_BLOCKSIZE == 2 |
---|
2551 | Int dW = sizeX; |
---|
2552 | Int dH = sizeY; |
---|
2553 | Int sW = 2; // search window size |
---|
2554 | Int sH = 2; |
---|
2555 | #endif |
---|
2556 | #if H_3D_VSP_BLOCKSIZE == 4 |
---|
2557 | Int dW = sizeX>>1; |
---|
2558 | Int dH = sizeY>>1; |
---|
2559 | Int sW = 4; // search window size |
---|
2560 | Int sH = 4; |
---|
2561 | #endif |
---|
2562 | |
---|
2563 | { |
---|
2564 | Pel* depthi = depth; |
---|
2565 | for (Int j = 0; j < dH; j++) |
---|
2566 | { |
---|
2567 | for (Int i = 0; i < dW; i++) |
---|
2568 | { |
---|
2569 | Pel* depthTmp; |
---|
2570 | #if H_3D_VSP_BLOCKSIZE == 1 |
---|
2571 | depthTmp = depthi + (i << 1); |
---|
2572 | #endif |
---|
2573 | #if H_3D_VSP_BLOCKSIZE == 2 |
---|
2574 | if (depthPosX + (i<<1) < widthDepth) |
---|
2575 | depthTmp = depthi + (i << 1); |
---|
2576 | else |
---|
2577 | depthTmp = depthi + (widthDepth - depthPosX - 1); |
---|
2578 | #endif |
---|
2579 | #if H_3D_VSP_BLOCKSIZE == 4 |
---|
2580 | if (depthPosX + (i<<2) < widthDepth) |
---|
2581 | depthTmp = depthi + (i << 2); |
---|
2582 | else |
---|
2583 | depthTmp = depthi + (widthDepth - depthPosX - 1); |
---|
2584 | #endif |
---|
2585 | Int maxV = 0; |
---|
2586 | for (Int blockj = 0; blockj < sH; blockj+=(sH-1)) |
---|
2587 | { |
---|
2588 | Int iX = 0; |
---|
2589 | for (Int blocki = 0; blocki < sW; blocki+=(sW-1)) |
---|
2590 | { |
---|
2591 | if (maxV < depthTmp[iX]) |
---|
2592 | maxV = depthTmp[iX]; |
---|
2593 | if (depthPosX + i*sW + blocki < widthDepth - 1) |
---|
2594 | iX = (sW-1); |
---|
2595 | } |
---|
2596 | if (depthPosY + j*sH + blockj < heightDepth - 1) |
---|
2597 | depthTmp += depStride * (sH-1); |
---|
2598 | } |
---|
2599 | m_pDepthBlock[i+j*dW] = maxV; |
---|
2600 | } // end of i < dW |
---|
2601 | #if H_3D_VSP_BLOCKSIZE == 1 |
---|
2602 | if (depthPosY + ((j+1)<<1) < heightDepth) |
---|
2603 | depthi += (depStride << 1); |
---|
2604 | else |
---|
2605 | depthi = depth + (heightDepth-1)*depStride; |
---|
2606 | #endif |
---|
2607 | #if H_3D_VSP_BLOCKSIZE == 2 |
---|
2608 | if (depthPosY + ((j+1)<<1) < heightDepth) |
---|
2609 | depthi += (depStride << 1); |
---|
2610 | else |
---|
2611 | depthi = depth + (heightDepth-depthPosY-1)*depStride; |
---|
2612 | #endif |
---|
2613 | #if H_3D_VSP_BLOCKSIZE == 4 |
---|
2614 | if (depthPosY + ((j+1)<<2) < heightDepth) // heightDepth-1 |
---|
2615 | depthi += (depStride << 2); |
---|
2616 | else |
---|
2617 | depthi = depth + (heightDepth-depthPosY-1)*depStride; // the last line |
---|
2618 | #endif |
---|
2619 | } |
---|
2620 | } |
---|
2621 | |
---|
2622 | |
---|
2623 | #if H_3D_VSP_BLOCKSIZE == 1 |
---|
2624 | #if H_3D_VSP_CONSTRAINED |
---|
2625 | //get LUT based horizontal reference range |
---|
2626 | Int range = xGetConstrainedSize(sizeX, sizeY, false); |
---|
2627 | |
---|
2628 | // The minimum depth value |
---|
2629 | Int minRelativePos = MAX_INT; |
---|
2630 | Int maxRelativePos = MIN_INT; |
---|
2631 | |
---|
2632 | Int depthTmp; |
---|
2633 | for (Int yTxt=0; yTxt<sizeY; yTxt++) |
---|
2634 | { |
---|
2635 | for (Int xTxt=0; xTxt<sizeX; xTxt++) |
---|
2636 | { |
---|
2637 | depthTmp = m_pDepthBlock[xTxt+yTxt*dW]; |
---|
2638 | Int disparity = pShiftLUT[ depthTmp ]; // << iShiftPrec; |
---|
2639 | Int disparityInt = disparity >> 3;//in chroma resolution |
---|
2640 | |
---|
2641 | if (disparityInt < 0) |
---|
2642 | { |
---|
2643 | if (minRelativePos > disparityInt+xTxt) |
---|
2644 | minRelativePos = disparityInt+xTxt; |
---|
2645 | } |
---|
2646 | else |
---|
2647 | { |
---|
2648 | if (maxRelativePos < disparityInt+xTxt) |
---|
2649 | maxRelativePos = disparityInt+xTxt; |
---|
2650 | } |
---|
2651 | } |
---|
2652 | } |
---|
2653 | |
---|
2654 | depthTmp = m_pDepthBlock[0]; |
---|
2655 | Int disparity_tmp = pShiftLUT[ depthTmp ]; // << iShiftPrec; |
---|
2656 | if ( disparity_tmp < 0 ) |
---|
2657 | maxRelativePos = minRelativePos + range - 1; |
---|
2658 | else |
---|
2659 | minRelativePos = maxRelativePos - range + 1; |
---|
2660 | |
---|
2661 | #endif // H_3D_VSP_CONSTRAINED |
---|
2662 | #endif // H_3D_VSP_BLOCKSIZE == 1 |
---|
2663 | |
---|
2664 | // (sizeX, sizeY) is Chroma block size |
---|
2665 | for ( Int yTxt = 0, yDepth = 0; yTxt < sizeY; yTxt += nTxtPerDepthY, yDepth += nDepthPerTxtY ) |
---|
2666 | { |
---|
2667 | for ( Int xTxt = 0, xDepth = 0; xTxt < sizeX; xTxt += nTxtPerDepthX, xDepth += nDepthPerTxtX ) |
---|
2668 | { |
---|
2669 | Pel repDepth = 0; // to store the depth value used for warping |
---|
2670 | #if H_3D_VSP_BLOCKSIZE == 1 |
---|
2671 | repDepth = m_pDepthBlock[(xTxt) + (yTxt)*dW]; |
---|
2672 | #endif |
---|
2673 | #if H_3D_VSP_BLOCKSIZE == 2 |
---|
2674 | repDepth = m_pDepthBlock[(xTxt) + (yTxt)*dW]; |
---|
2675 | #endif |
---|
2676 | #if H_3D_VSP_BLOCKSIZE == 4 |
---|
2677 | repDepth = m_pDepthBlock[(xTxt>>1) + (yTxt>>1)*dW]; |
---|
2678 | #endif |
---|
2679 | |
---|
2680 | // calculate the offset in the reference picture |
---|
2681 | Int disparity = pShiftLUT[ repDepth ]; // Remove << iShiftPrec; |
---|
2682 | Int refOffset = xTxt + (disparity >> 3); // in integer pixel in chroma image |
---|
2683 | Int xFrac = disparity & 0x7; |
---|
2684 | #if H_3D_VSP_CONSTRAINED |
---|
2685 | if(refOffset < minRelativePos || refOffset > maxRelativePos) |
---|
2686 | xFrac = 0; |
---|
2687 | refOffset = Clip3(minRelativePos, maxRelativePos, refOffset); |
---|
2688 | #endif |
---|
2689 | Int absX = posX + refOffset; |
---|
2690 | |
---|
2691 | if (xFrac == 0) |
---|
2692 | absX = Clip3(0, widthChroma-1, absX); |
---|
2693 | else |
---|
2694 | absX = Clip3(4, widthChroma-5, absX); |
---|
2695 | |
---|
2696 | refOffset = absX - posX; |
---|
2697 | |
---|
2698 | assert( refCb[refOffset] >= 0 && refCb[refOffset]<= 255 ); |
---|
2699 | assert( refCr[refOffset] >= 0 && refCr[refOffset]<= 255 ); |
---|
2700 | m_if.filterHorChroma(&refCb[refOffset], refStride, &dstCb[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !bi); |
---|
2701 | m_if.filterHorChroma(&refCr[refOffset], refStride, &dstCr[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !bi); |
---|
2702 | } |
---|
2703 | refCb += refStrideBlock; |
---|
2704 | refCr += refStrideBlock; |
---|
2705 | dstCb += dstStrideBlock; |
---|
2706 | dstCr += dstStrideBlock; |
---|
2707 | depth += depStrideBlock; |
---|
2708 | } |
---|
2709 | } |
---|
2710 | |
---|
2711 | } |
---|
2712 | |
---|
2713 | #endif // NTT_VSP_COMMON_E0207_E0208 |
---|
2714 | |
---|
2715 | #if H_3D_VSP_CONSTRAINED |
---|
2716 | Int TComPrediction::xGetConstrainedSize(Int nPbW, Int nPbH, Bool bLuma) |
---|
2717 | { |
---|
2718 | Int iSize = 0; |
---|
2719 | if (bLuma) |
---|
2720 | { |
---|
2721 | Int iArea = (nPbW+7) * (nPbH+7); |
---|
2722 | Int iAlpha = iArea / nPbH - nPbW - 7; |
---|
2723 | iSize = iAlpha + nPbW; |
---|
2724 | } |
---|
2725 | else // chroma |
---|
2726 | { |
---|
2727 | Int iArea = (nPbW+2) * (nPbH+2); |
---|
2728 | Int iAlpha = iArea / nPbH - nPbW - 4; |
---|
2729 | iSize = iAlpha + nPbW; |
---|
2730 | } |
---|
2731 | return iSize; |
---|
2732 | } |
---|
2733 | #endif // H_3D_VSP_CONSTRAINED |
---|
2734 | |
---|
2735 | #endif // H_3D_VSP |
---|
2736 | |
---|
2737 | #if H_3D_DIM |
---|
2738 | Void TComPrediction::xPredBiSegDCs( Int* ptrSrc, UInt srcStride, Bool* biSegPattern, Int patternStride, Pel& predDC1, Pel& predDC2 ) |
---|
2739 | { |
---|
2740 | Int refDC1, refDC2; |
---|
2741 | const Int iTR = ( patternStride - 1 ) - srcStride; |
---|
2742 | const Int iTM = ( ( patternStride - 1 ) >> 1 ) - srcStride; |
---|
2743 | const Int iLB = ( patternStride - 1 ) * srcStride - 1; |
---|
2744 | const Int iLM = ( ( patternStride - 1 ) >> 1 ) * srcStride - 1; |
---|
2745 | |
---|
2746 | Bool bL = ( biSegPattern[0] != biSegPattern[(patternStride-1)*patternStride] ); |
---|
2747 | Bool bT = ( biSegPattern[0] != biSegPattern[(patternStride-1)] ); |
---|
2748 | |
---|
2749 | if( bL == bT ) |
---|
2750 | { |
---|
2751 | refDC1 = bL ? ( ptrSrc[iTR] + ptrSrc[iLB] )>>1 : 1<<( g_bitDepthY - 1 ); |
---|
2752 | refDC2 = ( ptrSrc[ -1] + ptrSrc[-(Int)srcStride] )>>1; |
---|
2753 | } |
---|
2754 | else |
---|
2755 | { |
---|
2756 | refDC1 = bL ? ptrSrc[iLB] : ptrSrc[iTR]; |
---|
2757 | refDC2 = bL ? ptrSrc[iTM] : ptrSrc[iLM]; |
---|
2758 | } |
---|
2759 | |
---|
2760 | predDC1 = biSegPattern[0] ? refDC1 : refDC2; |
---|
2761 | predDC2 = biSegPattern[0] ? refDC2 : refDC1; |
---|
2762 | } |
---|
2763 | |
---|
2764 | Void TComPrediction::xAssignBiSegDCs( Pel* ptrDst, UInt dstStride, Bool* biSegPattern, Int patternStride, Pel valDC1, Pel valDC2 ) |
---|
2765 | { |
---|
2766 | if( dstStride == patternStride ) |
---|
2767 | { |
---|
2768 | for( UInt k = 0; k < (patternStride * patternStride); k++ ) |
---|
2769 | { |
---|
2770 | if( true == biSegPattern[k] ) { ptrDst[k] = valDC2; } |
---|
2771 | else { ptrDst[k] = valDC1; } |
---|
2772 | } |
---|
2773 | } |
---|
2774 | else |
---|
2775 | { |
---|
2776 | Pel* piTemp = ptrDst; |
---|
2777 | for( UInt uiY = 0; uiY < patternStride; uiY++ ) |
---|
2778 | { |
---|
2779 | for( UInt uiX = 0; uiX < patternStride; uiX++ ) |
---|
2780 | { |
---|
2781 | if( true == biSegPattern[uiX] ) { piTemp[uiX] = valDC2; } |
---|
2782 | else { piTemp[uiX] = valDC1; } |
---|
2783 | } |
---|
2784 | piTemp += dstStride; |
---|
2785 | biSegPattern += patternStride; |
---|
2786 | } |
---|
2787 | } |
---|
2788 | } |
---|
2789 | |
---|
2790 | #if H_3D_DIM_DMM |
---|
2791 | #if !SEC_DMM2_E0146_HHIFIX |
---|
2792 | UInt TComPrediction::xPredWedgeFromIntra( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Int iDeltaEnd ) |
---|
2793 | { |
---|
2794 | UInt uiThisBlockSize = uiWidth; |
---|
2795 | |
---|
2796 | TComDataCU* pcTempCU; |
---|
2797 | UInt uiTempPartIdx; |
---|
2798 | // 1st: try continue above wedgelet |
---|
2799 | pcTempCU = pcCU->getPUAbove( uiTempPartIdx, pcCU->getZorderIdxInCU() + uiAbsPartIdx ); |
---|
2800 | if( pcTempCU && isDimMode( pcTempCU->getLumaIntraDir( uiTempPartIdx ) ) ) |
---|
2801 | { |
---|
2802 | UInt dimType = getDimType( pcTempCU->getLumaIntraDir( uiTempPartIdx ) ); |
---|
2803 | if( DMM1_IDX == dimType || DMM2_IDX == dimType || DMM3_IDX == dimType ) |
---|
2804 | { |
---|
2805 | // get offset between current and reference block |
---|
2806 | UInt uiOffsetX = 0, uiOffsetY = 0; |
---|
2807 | xGetBlockOffset( pcCU, uiAbsPartIdx, pcTempCU, uiTempPartIdx, uiOffsetX, uiOffsetY ); |
---|
2808 | |
---|
2809 | // get reference wedgelet |
---|
2810 | WedgeList* pacWedgeList = &g_dmmWedgeLists[(g_aucConvertToBit[(pcTempCU->getWidth( uiTempPartIdx )>>((pcTempCU->getPartitionSize( uiTempPartIdx ) == SIZE_NxN) ? 1 : 0))])]; |
---|
2811 | TComWedgelet* pcRefWedgelet = &(pacWedgeList->at( pcTempCU->getDmmWedgeTabIdx( dimType, uiTempPartIdx ) ) ); |
---|
2812 | |
---|
2813 | // find wedgelet, if direction is suitable for continue wedge |
---|
2814 | if( pcRefWedgelet->checkPredDirAbovePossible( uiThisBlockSize, uiOffsetX ) ) |
---|
2815 | { |
---|
2816 | UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye; |
---|
2817 | pcRefWedgelet->getPredDirStartEndAbove( uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, uiThisBlockSize, uiOffsetX, iDeltaEnd ); |
---|
2818 | return xGetWedgePatternIdx( uiThisBlockSize, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye ); |
---|
2819 | } |
---|
2820 | } |
---|
2821 | } |
---|
2822 | |
---|
2823 | // 2nd: try continue left wedglelet |
---|
2824 | pcTempCU = pcCU->getPULeft( uiTempPartIdx, pcCU->getZorderIdxInCU() + uiAbsPartIdx ); |
---|
2825 | if( pcTempCU && isDimMode( pcTempCU->getLumaIntraDir( uiTempPartIdx ) ) ) |
---|
2826 | { |
---|
2827 | UInt dimType = getDimType( pcTempCU->getLumaIntraDir( uiTempPartIdx ) ); |
---|
2828 | if( DMM1_IDX == dimType || DMM2_IDX == dimType || DMM3_IDX == dimType ) |
---|
2829 | { |
---|
2830 | // get offset between current and reference block |
---|
2831 | UInt uiOffsetX = 0, uiOffsetY = 0; |
---|
2832 | xGetBlockOffset( pcCU, uiAbsPartIdx, pcTempCU, uiTempPartIdx, uiOffsetX, uiOffsetY ); |
---|
2833 | |
---|
2834 | // get reference wedgelet |
---|
2835 | WedgeList* pacWedgeList = &g_dmmWedgeLists[(g_aucConvertToBit[(pcTempCU->getWidth( uiTempPartIdx )>>((pcTempCU->getPartitionSize( uiTempPartIdx ) == SIZE_NxN) ? 1 : 0))])]; |
---|
2836 | TComWedgelet* pcRefWedgelet = &(pacWedgeList->at( pcTempCU->getDmmWedgeTabIdx( dimType, uiTempPartIdx ) ) ); |
---|
2837 | |
---|
2838 | // find wedgelet, if direction is suitable for continue wedge |
---|
2839 | if( pcRefWedgelet->checkPredDirLeftPossible( uiThisBlockSize, uiOffsetY ) ) |
---|
2840 | { |
---|
2841 | UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye; |
---|
2842 | pcRefWedgelet->getPredDirStartEndLeft( uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, uiThisBlockSize, uiOffsetY, iDeltaEnd ); |
---|
2843 | return xGetWedgePatternIdx( uiThisBlockSize, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye ); |
---|
2844 | } |
---|
2845 | } |
---|
2846 | } |
---|
2847 | |
---|
2848 | // 3rd: (default) make wedglet from intra dir and max slope point |
---|
2849 | Int iSlopeX = 0, iSlopeY = 0; |
---|
2850 | UInt uiStartPosX = 0, uiStartPosY = 0; |
---|
2851 | if( xGetWedgeIntraDirPredData( pcCU, uiAbsPartIdx, uiThisBlockSize, iSlopeX, iSlopeY, uiStartPosX, uiStartPosY ) ) |
---|
2852 | { |
---|
2853 | UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye; |
---|
2854 | xGetWedgeIntraDirStartEnd( pcCU, uiAbsPartIdx, uiThisBlockSize, iSlopeX, iSlopeY, uiStartPosX, uiStartPosY, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, iDeltaEnd ); |
---|
2855 | return xGetWedgePatternIdx( uiThisBlockSize, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye ); |
---|
2856 | } |
---|
2857 | |
---|
2858 | return 0; |
---|
2859 | } |
---|
2860 | #endif |
---|
2861 | |
---|
2862 | UInt TComPrediction::xPredWedgeFromTex( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt intraTabIdx ) |
---|
2863 | { |
---|
2864 | TComPic* pcPicTex = pcCU->getSlice()->getTexturePic(); |
---|
2865 | assert( pcPicTex != NULL ); |
---|
2866 | TComDataCU* pcColTexCU = pcPicTex->getCU(pcCU->getAddr()); |
---|
2867 | UInt uiTexPartIdx = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
2868 | Int uiColTexIntraDir = pcColTexCU->isIntra( uiTexPartIdx ) ? pcColTexCU->getLumaIntraDir( uiTexPartIdx ) : 255; |
---|
2869 | |
---|
2870 | #if LGE_PKU_DMM3_OVERLAP_E0159_HHIFIX |
---|
2871 | assert( uiColTexIntraDir > DC_IDX && uiColTexIntraDir < 35 ); |
---|
2872 | return g_aauiWdgLstM3[g_aucConvertToBit[uiWidth]][uiColTexIntraDir-2].at(intraTabIdx); |
---|
2873 | #else |
---|
2874 | if( uiColTexIntraDir > DC_IDX && uiColTexIntraDir < 35 ) { return g_aauiWdgLstM3[g_aucConvertToBit[uiWidth]][uiColTexIntraDir-2].at(intraTabIdx); } |
---|
2875 | else { return g_dmmWedgeNodeLists[(g_aucConvertToBit[uiWidth])].at(intraTabIdx).getPatternIdx(); } |
---|
2876 | #endif |
---|
2877 | } |
---|
2878 | |
---|
2879 | Void TComPrediction::xPredContourFromTex( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, TComWedgelet* pcContourWedge ) |
---|
2880 | { |
---|
2881 | pcContourWedge->clear(); |
---|
2882 | |
---|
2883 | // get copy of co-located texture luma block |
---|
2884 | TComYuv cTempYuv; |
---|
2885 | cTempYuv.create( uiWidth, uiHeight ); |
---|
2886 | cTempYuv.clear(); |
---|
2887 | Pel* piRefBlkY = cTempYuv.getLumaAddr(); |
---|
2888 | xCopyTextureLumaBlock( pcCU, uiAbsPartIdx, piRefBlkY, uiWidth, uiHeight ); |
---|
2889 | piRefBlkY = cTempYuv.getLumaAddr(); |
---|
2890 | |
---|
2891 | // find contour for texture luma block |
---|
2892 | UInt iDC = 0; |
---|
2893 | for( UInt k = 0; k < (uiWidth*uiHeight); k++ ) |
---|
2894 | { |
---|
2895 | iDC += piRefBlkY[k]; |
---|
2896 | } |
---|
2897 | |
---|
2898 | #if SCU_HS_DMM4_REMOVE_DIV_E0242 |
---|
2899 | Int cuMaxLog2Size = g_aucConvertToBit[g_uiMaxCUWidth]+2; |
---|
2900 | iDC = iDC >> (cuMaxLog2Size - pcCU->getDepth(0))*2; |
---|
2901 | #else |
---|
2902 | iDC /= (uiWidth*uiHeight); |
---|
2903 | #endif |
---|
2904 | piRefBlkY = cTempYuv.getLumaAddr(); |
---|
2905 | |
---|
2906 | Bool* pabContourPattern = pcContourWedge->getPattern(); |
---|
2907 | for( UInt k = 0; k < (uiWidth*uiHeight); k++ ) |
---|
2908 | { |
---|
2909 | pabContourPattern[k] = (piRefBlkY[k] > iDC) ? true : false; |
---|
2910 | } |
---|
2911 | |
---|
2912 | cTempYuv.destroy(); |
---|
2913 | } |
---|
2914 | |
---|
2915 | |
---|
2916 | Void TComPrediction::xCopyTextureLumaBlock( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piDestBlockY, UInt uiWidth, UInt uiHeight ) |
---|
2917 | { |
---|
2918 | TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getTexturePic()->getPicYuvRec(); |
---|
2919 | assert( pcPicYuvRef != NULL ); |
---|
2920 | Int iRefStride = pcPicYuvRef->getStride(); |
---|
2921 | Pel* piRefY = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiAbsPartIdx ); |
---|
2922 | |
---|
2923 | for ( Int y = 0; y < uiHeight; y++ ) |
---|
2924 | { |
---|
2925 | ::memcpy(piDestBlockY, piRefY, sizeof(Pel)*uiWidth); |
---|
2926 | piDestBlockY += uiWidth; |
---|
2927 | piRefY += iRefStride; |
---|
2928 | } |
---|
2929 | } |
---|
2930 | |
---|
2931 | #if !SEC_DMM2_E0146_HHIFIX |
---|
2932 | Void TComPrediction::xGetBlockOffset( TComDataCU* pcCU, UInt uiAbsPartIdx, TComDataCU* pcRefCU, UInt uiRefAbsPartIdx, UInt& ruiOffsetX, UInt& ruiOffsetY ) |
---|
2933 | { |
---|
2934 | ruiOffsetX = 0; |
---|
2935 | ruiOffsetY = 0; |
---|
2936 | |
---|
2937 | // get offset between current and above/left block |
---|
2938 | UInt uiThisOriginX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
2939 | UInt uiThisOriginY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
2940 | |
---|
2941 | UInt uiNumPartInRefCU = pcRefCU->getTotalNumPart(); |
---|
2942 | UInt uiMaxDepthRefCU = 0; |
---|
2943 | while( uiNumPartInRefCU > 1 ) |
---|
2944 | { |
---|
2945 | uiNumPartInRefCU >>= 2; |
---|
2946 | uiMaxDepthRefCU++; |
---|
2947 | } |
---|
2948 | |
---|
2949 | UInt uiDepthRefPU = (pcRefCU->getDepth(uiRefAbsPartIdx)) + (pcRefCU->getPartitionSize(uiRefAbsPartIdx) == SIZE_2Nx2N ? 0 : 1); |
---|
2950 | UInt uiShifts = (uiMaxDepthRefCU - uiDepthRefPU)*2; |
---|
2951 | UInt uiRefBlockOriginPartIdx = (uiRefAbsPartIdx>>uiShifts)<<uiShifts; |
---|
2952 | |
---|
2953 | UInt uiRefOriginX = pcRefCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiRefBlockOriginPartIdx] ]; |
---|
2954 | UInt uiRefOriginY = pcRefCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiRefBlockOriginPartIdx] ]; |
---|
2955 | |
---|
2956 | if( (uiThisOriginX - uiRefOriginX) > 0 ) { ruiOffsetX = (UInt)(uiThisOriginX - uiRefOriginX); } |
---|
2957 | if( (uiThisOriginY - uiRefOriginY) > 0 ) { ruiOffsetY = (UInt)(uiThisOriginY - uiRefOriginY); } |
---|
2958 | } |
---|
2959 | |
---|
2960 | Bool TComPrediction::xGetWedgeIntraDirPredData( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiBlockSize, Int& riSlopeX, Int& riSlopeY, UInt& ruiStartPosX, UInt& ruiStartPosY ) |
---|
2961 | { |
---|
2962 | riSlopeX = 0, riSlopeY = 0, ruiStartPosX = 0, ruiStartPosY = 0; |
---|
2963 | |
---|
2964 | // 1st step: get wedge start point (max. slope) |
---|
2965 | Int* piSource = pcCU->getPattern()->getAdiOrgBuf( uiBlockSize, uiBlockSize, m_piYuvExt ); |
---|
2966 | Int iSourceStride = ( uiBlockSize<<1 ) + 1; |
---|
2967 | |
---|
2968 | UInt uiSlopeMaxAbove = 0, uiPosSlopeMaxAbove = 0; |
---|
2969 | for( UInt uiPosHor = 0; uiPosHor < (uiBlockSize-1); uiPosHor++ ) |
---|
2970 | { |
---|
2971 | if( abs( piSource[uiPosHor+1] - piSource[uiPosHor] ) > uiSlopeMaxAbove ) |
---|
2972 | { |
---|
2973 | uiSlopeMaxAbove = abs( piSource[uiPosHor+1] - piSource[uiPosHor] ); |
---|
2974 | uiPosSlopeMaxAbove = uiPosHor; |
---|
2975 | } |
---|
2976 | } |
---|
2977 | |
---|
2978 | UInt uiSlopeMaxLeft = 0, uiPosSlopeMaxLeft = 0; |
---|
2979 | for( UInt uiPosVer = 0; uiPosVer < (uiBlockSize-1); uiPosVer++ ) |
---|
2980 | { |
---|
2981 | if( abs( piSource[(uiPosVer+1)*iSourceStride] - piSource[uiPosVer*iSourceStride] ) > uiSlopeMaxLeft ) |
---|
2982 | { |
---|
2983 | uiSlopeMaxLeft = abs( piSource[(uiPosVer+1)*iSourceStride] - piSource[uiPosVer*iSourceStride] ); |
---|
2984 | uiPosSlopeMaxLeft = uiPosVer; |
---|
2985 | } |
---|
2986 | } |
---|
2987 | |
---|
2988 | if( uiSlopeMaxAbove == 0 && uiSlopeMaxLeft == 0 ) |
---|
2989 | { |
---|
2990 | return false; |
---|
2991 | } |
---|
2992 | |
---|
2993 | ruiStartPosX = ( uiSlopeMaxAbove > uiSlopeMaxLeft ) ? uiPosSlopeMaxAbove : 0; |
---|
2994 | ruiStartPosY = ( uiSlopeMaxLeft >= uiSlopeMaxAbove ) ? uiPosSlopeMaxLeft : 0; |
---|
2995 | |
---|
2996 | // 2nd step: derive wedge direction |
---|
2997 | Int uiPreds[3] = {-1, -1, -1}; |
---|
2998 | Int iMode = -1; |
---|
2999 | Int iPredNum = pcCU->getIntraDirLumaPredictor( uiAbsPartIdx, uiPreds, &iMode ); |
---|
3000 | |
---|
3001 | UInt uiDirMode = 0; |
---|
3002 | if( iMode >= 0 ) { iPredNum = iMode; } |
---|
3003 | if( iPredNum == 1 ) { uiDirMode = uiPreds[0]; } |
---|
3004 | if( iPredNum == 2 ) { uiDirMode = uiPreds[1]; } |
---|
3005 | |
---|
3006 | if( uiDirMode < 2 ) { return false; } // no planar & DC |
---|
3007 | |
---|
3008 | Bool modeHor = (uiDirMode < 18); |
---|
3009 | Bool modeVer = !modeHor; |
---|
3010 | Int intraPredAngle = modeVer ? (Int)uiDirMode - VER_IDX : modeHor ? -((Int)uiDirMode - HOR_IDX) : 0; |
---|
3011 | Int absAng = abs(intraPredAngle); |
---|
3012 | Int signAng = intraPredAngle < 0 ? -1 : 1; |
---|
3013 | Int angTable[9] = {0,2,5,9,13,17,21,26,32}; |
---|
3014 | absAng = angTable[absAng]; |
---|
3015 | intraPredAngle = signAng * absAng; |
---|
3016 | |
---|
3017 | // 3rd step: set slope for direction |
---|
3018 | if( modeHor ) |
---|
3019 | { |
---|
3020 | riSlopeX = ( intraPredAngle > 0 ) ? -32 : 32; |
---|
3021 | riSlopeY = ( intraPredAngle > 0 ) ? intraPredAngle : -intraPredAngle; |
---|
3022 | } |
---|
3023 | else if( modeVer ) |
---|
3024 | { |
---|
3025 | riSlopeX = ( intraPredAngle > 0 ) ? intraPredAngle : -intraPredAngle; |
---|
3026 | riSlopeY = ( intraPredAngle > 0 ) ? -32 : 32; |
---|
3027 | } |
---|
3028 | |
---|
3029 | return true; |
---|
3030 | } |
---|
3031 | |
---|
3032 | Void TComPrediction::xGetWedgeIntraDirStartEnd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiBlockSize, Int iDeltaX, Int iDeltaY, UInt uiPMSPosX, UInt uiPMSPosY, UChar& ruhXs, UChar& ruhYs, UChar& ruhXe, UChar& ruhYe, Int iDeltaEnd ) |
---|
3033 | { |
---|
3034 | ruhXs = 0; |
---|
3035 | ruhYs = 0; |
---|
3036 | ruhXe = 0; |
---|
3037 | ruhYe = 0; |
---|
3038 | |
---|
3039 | // scaling of start pos and block size to wedge resolution |
---|
3040 | UInt uiScaledStartPosX = 0; |
---|
3041 | UInt uiScaledStartPosY = 0; |
---|
3042 | UInt uiScaledBlockSize = 0; |
---|
3043 | WedgeResolution eWedgeRes = g_dmmWedgeResolution[(UInt)g_aucConvertToBit[uiBlockSize]]; |
---|
3044 | switch( eWedgeRes ) |
---|
3045 | { |
---|
3046 | case( DOUBLE_PEL ): { uiScaledStartPosX = (uiPMSPosX>>1); uiScaledStartPosY = (uiPMSPosY>>1); uiScaledBlockSize = (uiBlockSize>>1); break; } |
---|
3047 | case( FULL_PEL ): { uiScaledStartPosX = uiPMSPosX; uiScaledStartPosY = uiPMSPosY; uiScaledBlockSize = uiBlockSize; break; } |
---|
3048 | case( HALF_PEL ): { uiScaledStartPosX = (uiPMSPosX<<1); uiScaledStartPosY = (uiPMSPosY<<1); uiScaledBlockSize = (uiBlockSize<<1); break; } |
---|
3049 | } |
---|
3050 | Int iMaxPos = (Int)uiScaledBlockSize - 1; |
---|
3051 | |
---|
3052 | // case above |
---|
3053 | if( uiScaledStartPosX > 0 && uiScaledStartPosY == 0 ) |
---|
3054 | { |
---|
3055 | ruhXs = (UChar)uiScaledStartPosX; |
---|
3056 | ruhYs = 0; |
---|
3057 | |
---|
3058 | if( iDeltaY == 0 ) |
---|
3059 | { |
---|
3060 | if( iDeltaX < 0 ) |
---|
3061 | { |
---|
3062 | ruhXe = 0; |
---|
3063 | ruhYe = (UChar)std::min( std::max( iDeltaEnd, 0 ), iMaxPos ); |
---|
3064 | return; |
---|
3065 | } |
---|
3066 | else |
---|
3067 | { |
---|
3068 | ruhXe = (UChar)iMaxPos; |
---|
3069 | ruhYe = (UChar)std::min( std::max( -iDeltaEnd, 0 ), iMaxPos ); |
---|
3070 | std::swap( ruhXs, ruhXe ); |
---|
3071 | std::swap( ruhYs, ruhYe ); |
---|
3072 | return; |
---|
3073 | } |
---|
3074 | } |
---|
3075 | |
---|
3076 | // regular case |
---|
3077 | Int iVirtualEndX = (Int)ruhXs + roftoi( (Double)iMaxPos * ((Double)iDeltaX / (Double)iDeltaY) ); |
---|
3078 | |
---|
3079 | if( iVirtualEndX < 0 ) |
---|
3080 | { |
---|
3081 | Int iYe = roftoi( (Double)(0 - (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) ) + iDeltaEnd; |
---|
3082 | if( iYe < (Int)uiScaledBlockSize ) |
---|
3083 | { |
---|
3084 | ruhXe = 0; |
---|
3085 | ruhYe = (UChar)std::max( iYe, 0 ); |
---|
3086 | return; |
---|
3087 | } |
---|
3088 | else |
---|
3089 | { |
---|
3090 | ruhXe = (UChar)std::min( (iYe - iMaxPos), iMaxPos ); |
---|
3091 | ruhYe = (UChar)iMaxPos; |
---|
3092 | return; |
---|
3093 | } |
---|
3094 | } |
---|
3095 | else if( iVirtualEndX > iMaxPos ) |
---|
3096 | { |
---|
3097 | Int iYe = roftoi( (Double)(iMaxPos - (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) ) - iDeltaEnd; |
---|
3098 | if( iYe < (Int)uiScaledBlockSize ) |
---|
3099 | { |
---|
3100 | ruhXe = (UChar)iMaxPos; |
---|
3101 | ruhYe = (UChar)std::max( iYe, 0 ); |
---|
3102 | std::swap( ruhXs, ruhXe ); |
---|
3103 | std::swap( ruhYs, ruhYe ); |
---|
3104 | return; |
---|
3105 | } |
---|
3106 | else |
---|
3107 | { |
---|
3108 | ruhXe = (UChar)std::max( (iMaxPos - (iYe - iMaxPos)), 0 ); |
---|
3109 | ruhYe = (UChar)iMaxPos; |
---|
3110 | return; |
---|
3111 | } |
---|
3112 | } |
---|
3113 | else |
---|
3114 | { |
---|
3115 | Int iXe = iVirtualEndX + iDeltaEnd; |
---|
3116 | if( iXe < 0 ) |
---|
3117 | { |
---|
3118 | ruhXe = 0; |
---|
3119 | ruhYe = (UChar)std::max( (iMaxPos + iXe), 0 ); |
---|
3120 | return; |
---|
3121 | } |
---|
3122 | else if( iXe > iMaxPos ) |
---|
3123 | { |
---|
3124 | ruhXe = (UChar)iMaxPos; |
---|
3125 | ruhYe = (UChar)std::max( (iMaxPos - (iXe - iMaxPos)), 0 ); |
---|
3126 | std::swap( ruhXs, ruhXe ); |
---|
3127 | std::swap( ruhYs, ruhYe ); |
---|
3128 | return; |
---|
3129 | } |
---|
3130 | else |
---|
3131 | { |
---|
3132 | ruhXe = (UChar)iXe; |
---|
3133 | ruhYe = (UChar)iMaxPos; |
---|
3134 | return; |
---|
3135 | } |
---|
3136 | } |
---|
3137 | } |
---|
3138 | |
---|
3139 | // case left |
---|
3140 | if( uiScaledStartPosY > 0 && uiScaledStartPosX == 0 ) |
---|
3141 | { |
---|
3142 | ruhXs = 0; |
---|
3143 | ruhYs = (UChar)uiScaledStartPosY; |
---|
3144 | |
---|
3145 | if( iDeltaX == 0 ) |
---|
3146 | { |
---|
3147 | if( iDeltaY < 0 ) |
---|
3148 | { |
---|
3149 | ruhXe = (UChar)std::min( std::max( -iDeltaEnd, 0 ), iMaxPos ); |
---|
3150 | ruhYe = 0; |
---|
3151 | std::swap( ruhXs, ruhXe ); |
---|
3152 | std::swap( ruhYs, ruhYe ); |
---|
3153 | return; |
---|
3154 | } |
---|
3155 | else |
---|
3156 | { |
---|
3157 | ruhXe = (UChar)std::min( std::max( iDeltaEnd, 0 ), iMaxPos ); |
---|
3158 | ruhYe = (UChar)iMaxPos; |
---|
3159 | return; |
---|
3160 | } |
---|
3161 | } |
---|
3162 | |
---|
3163 | // regular case |
---|
3164 | Int iVirtualEndY = (Int)ruhYs + roftoi( (Double)iMaxPos * ((Double)iDeltaY / (Double)iDeltaX) ); |
---|
3165 | |
---|
3166 | if( iVirtualEndY < 0 ) |
---|
3167 | { |
---|
3168 | Int iXe = roftoi( (Double)(0 - (Int)ruhYs ) * ((Double)iDeltaX / (Double)iDeltaY) ) - iDeltaEnd; |
---|
3169 | if( iXe < (Int)uiScaledBlockSize ) |
---|
3170 | { |
---|
3171 | ruhXe = (UChar)std::max( iXe, 0 ); |
---|
3172 | ruhYe = 0; |
---|
3173 | std::swap( ruhXs, ruhXe ); |
---|
3174 | std::swap( ruhYs, ruhYe ); |
---|
3175 | return; |
---|
3176 | } |
---|
3177 | else |
---|
3178 | { |
---|
3179 | ruhXe = (UChar)iMaxPos; |
---|
3180 | ruhYe = (UChar)std::min( (iXe - iMaxPos), iMaxPos ); |
---|
3181 | std::swap( ruhXs, ruhXe ); |
---|
3182 | std::swap( ruhYs, ruhYe ); |
---|
3183 | return; |
---|
3184 | } |
---|
3185 | } |
---|
3186 | else if( iVirtualEndY > (uiScaledBlockSize-1) ) |
---|
3187 | { |
---|
3188 | Int iXe = roftoi( (Double)((Int)(uiScaledBlockSize-1) - (Int)ruhYs ) * ((Double)iDeltaX / (Double)iDeltaY) ) + iDeltaEnd; |
---|
3189 | if( iXe < (Int)uiScaledBlockSize ) |
---|
3190 | { |
---|
3191 | ruhXe = (UChar)std::max( iXe, 0 ); |
---|
3192 | ruhYe = (UChar)(uiScaledBlockSize-1); |
---|
3193 | return; |
---|
3194 | } |
---|
3195 | else |
---|
3196 | { |
---|
3197 | ruhXe = (UChar)iMaxPos; |
---|
3198 | ruhYe = (UChar)std::max( (iMaxPos - (iXe - iMaxPos)), 0 ); |
---|
3199 | std::swap( ruhXs, ruhXe ); |
---|
3200 | std::swap( ruhYs, ruhYe ); |
---|
3201 | return; |
---|
3202 | } |
---|
3203 | } |
---|
3204 | else |
---|
3205 | { |
---|
3206 | Int iYe = iVirtualEndY - iDeltaEnd; |
---|
3207 | if( iYe < 0 ) |
---|
3208 | { |
---|
3209 | ruhXe = (UChar)std::max( (iMaxPos + iYe), 0 ); |
---|
3210 | ruhYe = 0; |
---|
3211 | std::swap( ruhXs, ruhXe ); |
---|
3212 | std::swap( ruhYs, ruhYe ); |
---|
3213 | return; |
---|
3214 | } |
---|
3215 | else if( iYe > iMaxPos ) |
---|
3216 | { |
---|
3217 | ruhXe = (UChar)std::max( (iMaxPos - (iYe - iMaxPos)), 0 ); |
---|
3218 | ruhYe = (UChar)iMaxPos; |
---|
3219 | return; |
---|
3220 | } |
---|
3221 | else |
---|
3222 | { |
---|
3223 | ruhXe = (UChar)iMaxPos; |
---|
3224 | ruhYe = (UChar)iYe; |
---|
3225 | std::swap( ruhXs, ruhXe ); |
---|
3226 | std::swap( ruhYs, ruhYe ); |
---|
3227 | return; |
---|
3228 | } |
---|
3229 | } |
---|
3230 | } |
---|
3231 | |
---|
3232 | // case origin |
---|
3233 | if( uiScaledStartPosX == 0 && uiScaledStartPosY == 0 ) |
---|
3234 | { |
---|
3235 | if( iDeltaX*iDeltaY < 0 ) |
---|
3236 | { |
---|
3237 | return; |
---|
3238 | } |
---|
3239 | |
---|
3240 | ruhXs = 0; |
---|
3241 | ruhYs = 0; |
---|
3242 | |
---|
3243 | if( iDeltaY == 0 ) |
---|
3244 | { |
---|
3245 | ruhXe = (UChar)iMaxPos; |
---|
3246 | ruhYe = 0; |
---|
3247 | std::swap( ruhXs, ruhXe ); |
---|
3248 | std::swap( ruhYs, ruhYe ); |
---|
3249 | return; |
---|
3250 | } |
---|
3251 | |
---|
3252 | if( iDeltaX == 0 ) |
---|
3253 | { |
---|
3254 | ruhXe = 0; |
---|
3255 | ruhYe = (UChar)iMaxPos; |
---|
3256 | return; |
---|
3257 | } |
---|
3258 | |
---|
3259 | Int iVirtualEndX = (Int)ruhXs + roftoi( (Double)iMaxPos * ((Double)iDeltaX / (Double)iDeltaY) ); |
---|
3260 | |
---|
3261 | if( iVirtualEndX > iMaxPos ) |
---|
3262 | { |
---|
3263 | Int iYe = roftoi( (Double)((Int)iMaxPos - (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) ) - iDeltaEnd; |
---|
3264 | if( iYe < (Int)uiScaledBlockSize ) |
---|
3265 | { |
---|
3266 | ruhXe = (UChar)(uiScaledBlockSize-1); |
---|
3267 | ruhYe = (UChar)std::max( iYe, 0 ); |
---|
3268 | std::swap( ruhXs, ruhXe ); |
---|
3269 | std::swap( ruhYs, ruhYe ); |
---|
3270 | return; |
---|
3271 | } |
---|
3272 | else |
---|
3273 | { |
---|
3274 | ruhXe = (UChar)std::max( (iMaxPos - (iYe - iMaxPos)), 0 ); |
---|
3275 | ruhYe = (UChar)(uiScaledBlockSize-1); |
---|
3276 | return; |
---|
3277 | } |
---|
3278 | } |
---|
3279 | else |
---|
3280 | { |
---|
3281 | Int iXe = iVirtualEndX + iDeltaEnd; |
---|
3282 | if( iXe < 0 ) |
---|
3283 | { |
---|
3284 | ruhXe = 0; |
---|
3285 | ruhYe = (UChar)std::max( (iMaxPos + iXe), 0 ); |
---|
3286 | return; |
---|
3287 | } |
---|
3288 | else if( iXe > iMaxPos ) |
---|
3289 | { |
---|
3290 | ruhXe = (UChar)(uiScaledBlockSize-1); |
---|
3291 | ruhYe = (UChar)std::max( (iMaxPos - (iXe - iMaxPos)), 0 ); |
---|
3292 | std::swap( ruhXs, ruhXe ); |
---|
3293 | std::swap( ruhYs, ruhYe ); |
---|
3294 | return; |
---|
3295 | } |
---|
3296 | else |
---|
3297 | { |
---|
3298 | ruhXe = (UChar)iXe; |
---|
3299 | ruhYe = (UChar)(uiScaledBlockSize-1); |
---|
3300 | return; |
---|
3301 | } |
---|
3302 | } |
---|
3303 | } |
---|
3304 | } |
---|
3305 | |
---|
3306 | UInt TComPrediction::xGetWedgePatternIdx( UInt uiBlockSize, UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe ) |
---|
3307 | { |
---|
3308 | WedgeRefList* pcWedgeRefList = &g_dmmWedgeRefLists[(g_aucConvertToBit[uiBlockSize])]; |
---|
3309 | for( UInt uiIdx = 0; uiIdx < pcWedgeRefList->size(); uiIdx++ ) |
---|
3310 | { |
---|
3311 | TComWedgeRef* pcTestWedgeRef = &(pcWedgeRefList->at(uiIdx)); |
---|
3312 | if( pcTestWedgeRef->getStartX() == uhXs && pcTestWedgeRef->getStartY() == uhYs && pcTestWedgeRef->getEndX() == uhXe && pcTestWedgeRef->getEndY() == uhYe ) |
---|
3313 | { |
---|
3314 | return pcTestWedgeRef->getRefIdx(); |
---|
3315 | } |
---|
3316 | } |
---|
3317 | return 0; |
---|
3318 | } |
---|
3319 | #endif |
---|
3320 | #endif |
---|
3321 | #if H_3D_DIM_RBC |
---|
3322 | Void TComPrediction::xDeltaDCQuantScaleUp( TComDataCU* pcCU, Pel& rDeltaDC ) |
---|
3323 | { |
---|
3324 | Int iSign = rDeltaDC < 0 ? -1 : 1; |
---|
3325 | UInt uiAbs = abs( rDeltaDC ); |
---|
3326 | |
---|
3327 | Int iQp = pcCU->getQP(0); |
---|
3328 | Double dMax = (Double)( 1<<( g_bitDepthY - 1 ) ); |
---|
3329 | Double dStepSize = Clip3( 1.0, dMax, pow( 2.0, iQp/10.0 - 2.0 ) ); |
---|
3330 | |
---|
3331 | rDeltaDC = iSign * roftoi( uiAbs * dStepSize ); |
---|
3332 | return; |
---|
3333 | } |
---|
3334 | |
---|
3335 | Void TComPrediction::xDeltaDCQuantScaleDown( TComDataCU* pcCU, Pel& rDeltaDC ) |
---|
3336 | { |
---|
3337 | Int iSign = rDeltaDC < 0 ? -1 : 1; |
---|
3338 | UInt uiAbs = abs( rDeltaDC ); |
---|
3339 | |
---|
3340 | Int iQp = pcCU->getQP(0); |
---|
3341 | Double dMax = (Double)( 1<<( g_bitDepthY - 1 ) ); |
---|
3342 | Double dStepSize = Clip3( 1.0, dMax, pow( 2.0, iQp/10.0 - 2.0 ) ); |
---|
3343 | |
---|
3344 | rDeltaDC = iSign * roftoi( uiAbs / dStepSize ); |
---|
3345 | return; |
---|
3346 | } |
---|
3347 | #endif |
---|
3348 | #if H_3D_DIM_SDC |
---|
3349 | Void TComPrediction::analyzeSegmentsSDC( Pel* pOrig, UInt uiStride, UInt uiSize, Pel* rpSegMeans, UInt uiNumSegments, Bool* pMask, UInt uiMaskStride |
---|
3350 | #if KWU_SDC_SIMPLE_DC_E0117 |
---|
3351 | ,UInt uiIntraMode |
---|
3352 | ,Bool orgDC |
---|
3353 | #endif |
---|
3354 | ) |
---|
3355 | { |
---|
3356 | Int iSumDepth[2]; |
---|
3357 | memset(iSumDepth, 0, sizeof(Int)*2); |
---|
3358 | Int iSumPix[2]; |
---|
3359 | memset(iSumPix, 0, sizeof(Int)*2); |
---|
3360 | |
---|
3361 | #if KWU_SDC_SIMPLE_DC_E0117 |
---|
3362 | if (orgDC == false) |
---|
3363 | { |
---|
3364 | if ( getDimType(uiIntraMode) == DMM1_IDX ) |
---|
3365 | { |
---|
3366 | UChar ucSegmentLT = pMask[0]; |
---|
3367 | UChar ucSegmentRT = pMask[uiSize-1]; |
---|
3368 | UChar ucSegmentLB = pMask[uiMaskStride * (uiSize-1)]; |
---|
3369 | UChar ucSegmentRB = pMask[uiMaskStride * (uiSize-1) + (uiSize-1)]; |
---|
3370 | |
---|
3371 | rpSegMeans[ucSegmentLT] = pOrig[0]; |
---|
3372 | rpSegMeans[ucSegmentRT] = pOrig[uiSize-1]; |
---|
3373 | rpSegMeans[ucSegmentLB] = pOrig[uiStride * (uiSize-1) ]; |
---|
3374 | rpSegMeans[ucSegmentRB] = pOrig[uiStride * (uiSize-1) + (uiSize-1) ]; |
---|
3375 | } |
---|
3376 | else if (uiIntraMode == PLANAR_IDX) |
---|
3377 | { |
---|
3378 | Pel* pLeftTop = pOrig; |
---|
3379 | Pel* pRightTop = pOrig + (uiSize-1); |
---|
3380 | Pel* pLeftBottom = (pOrig+ (uiStride*(uiSize-1))); |
---|
3381 | Pel* pRightBottom = (pOrig+ (uiStride*(uiSize-1)) + (uiSize-1)); |
---|
3382 | |
---|
3383 | rpSegMeans[0] = (*pLeftTop + *pRightTop + *pLeftBottom + *pRightBottom + 2)>>2; |
---|
3384 | } |
---|
3385 | return; |
---|
3386 | } |
---|
3387 | #endif |
---|
3388 | |
---|
3389 | Int subSamplePix; |
---|
3390 | if ( uiSize == 64 || uiSize == 32 ) |
---|
3391 | { |
---|
3392 | subSamplePix = 2; |
---|
3393 | } |
---|
3394 | else |
---|
3395 | { |
---|
3396 | subSamplePix = 1; |
---|
3397 | } |
---|
3398 | for (Int y=0; y<uiSize; y+=subSamplePix) |
---|
3399 | { |
---|
3400 | for (Int x=0; x<uiSize; x+=subSamplePix) |
---|
3401 | { |
---|
3402 | UChar ucSegment = pMask?(UChar)pMask[x]:0; |
---|
3403 | assert( ucSegment < uiNumSegments ); |
---|
3404 | |
---|
3405 | iSumDepth[ucSegment] += pOrig[x]; |
---|
3406 | iSumPix[ucSegment] += 1; |
---|
3407 | } |
---|
3408 | |
---|
3409 | pOrig += uiStride*subSamplePix; |
---|
3410 | pMask += uiMaskStride*subSamplePix; |
---|
3411 | } |
---|
3412 | |
---|
3413 | // compute mean for each segment |
---|
3414 | for( UChar ucSeg = 0; ucSeg < uiNumSegments; ucSeg++ ) |
---|
3415 | { |
---|
3416 | if( iSumPix[ucSeg] > 0 ) |
---|
3417 | rpSegMeans[ucSeg] = iSumDepth[ucSeg] / iSumPix[ucSeg]; |
---|
3418 | else |
---|
3419 | rpSegMeans[ucSeg] = 0; // this happens for zero-segments |
---|
3420 | } |
---|
3421 | } |
---|
3422 | #endif // H_3D_DIM_SDC |
---|
3423 | #endif |
---|
3424 | //! \} |
---|