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