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-2012, 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 | #if LGE_EDGE_INTRA_A0070 |
---|
49 | #define MAX_DISTANCE_EDGEINTRA 255 |
---|
50 | #endif |
---|
51 | |
---|
52 | #if MERL_General_Fix |
---|
53 | #if MERL_VSP_C0152 |
---|
54 | #if MERL_CVSP_D0165 |
---|
55 | Int TComPrediction::m_iRangeLuma[12] = {14, 34, 21, 15, 36, 26, 21, 49, 41, 36, 80, 72}; |
---|
56 | Int TComPrediction::m_iRangeChroma[12] = { 2, 8, 5, 4, 11, 9, 8, 19, 17, 15, 34, 32}; |
---|
57 | #endif |
---|
58 | #endif |
---|
59 | #endif |
---|
60 | |
---|
61 | TComPrediction::TComPrediction() |
---|
62 | : m_pLumaRecBuffer(0) |
---|
63 | { |
---|
64 | m_piYuvExt = NULL; |
---|
65 | #if MERL_VSP_C0152 |
---|
66 | m_pDepth = (Int*) malloc(64*64*sizeof(Int)); // TODO: Use a smart way to determine the size of the array |
---|
67 | if (m_pDepth == NULL) |
---|
68 | { |
---|
69 | printf("ERROR: UKTGHU, No memory allocated.\n"); |
---|
70 | } |
---|
71 | #endif |
---|
72 | } |
---|
73 | |
---|
74 | TComPrediction::~TComPrediction() |
---|
75 | { |
---|
76 | |
---|
77 | #if MERL_VSP_C0152 |
---|
78 | if (m_pDepth != NULL) |
---|
79 | { |
---|
80 | free(m_pDepth); |
---|
81 | } |
---|
82 | #endif |
---|
83 | delete[] m_piYuvExt; |
---|
84 | |
---|
85 | m_acYuvPred[0].destroy(); |
---|
86 | m_acYuvPred[1].destroy(); |
---|
87 | |
---|
88 | m_cYuvPredTemp.destroy(); |
---|
89 | #if QC_ARP_D0177 |
---|
90 | m_acYuvPredBase[0].destroy(); |
---|
91 | m_acYuvPredBase[1].destroy(); |
---|
92 | m_acYuvDiff[0].destroy(); |
---|
93 | m_acYuvDiff[1].destroy(); |
---|
94 | #endif |
---|
95 | if( m_pLumaRecBuffer ) |
---|
96 | { |
---|
97 | delete [] m_pLumaRecBuffer; |
---|
98 | } |
---|
99 | |
---|
100 | Int i, j; |
---|
101 | for (i = 0; i < 4; i++) |
---|
102 | { |
---|
103 | for (j = 0; j < 4; j++) |
---|
104 | { |
---|
105 | m_filteredBlock[i][j].destroy(); |
---|
106 | } |
---|
107 | m_filteredBlockTmp[i].destroy(); |
---|
108 | } |
---|
109 | } |
---|
110 | |
---|
111 | Void TComPrediction::initTempBuff() |
---|
112 | { |
---|
113 | if( m_piYuvExt == NULL ) |
---|
114 | { |
---|
115 | Int extWidth = g_uiMaxCUWidth + 16; |
---|
116 | Int extHeight = g_uiMaxCUHeight + 1; |
---|
117 | Int i, j; |
---|
118 | for (i = 0; i < 4; i++) |
---|
119 | { |
---|
120 | m_filteredBlockTmp[i].create(extWidth, extHeight + 7); |
---|
121 | for (j = 0; j < 4; j++) |
---|
122 | { |
---|
123 | m_filteredBlock[i][j].create(extWidth, extHeight); |
---|
124 | } |
---|
125 | } |
---|
126 | m_iYuvExtHeight = ((g_uiMaxCUHeight + 2) << 4); |
---|
127 | m_iYuvExtStride = ((g_uiMaxCUWidth + 8) << 4); |
---|
128 | m_piYuvExt = new Int[ m_iYuvExtStride * m_iYuvExtHeight ]; |
---|
129 | |
---|
130 | // new structure |
---|
131 | m_acYuvPred[0] .create( g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
132 | m_acYuvPred[1] .create( g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
133 | |
---|
134 | m_cYuvPredTemp.create( g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
135 | #if QC_ARP_D0177 |
---|
136 | m_acYuvPredBase[0] .create( g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
137 | m_acYuvPredBase[1] .create( g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
138 | m_acYuvDiff [0] .create( g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
139 | m_acYuvDiff [1] .create( g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
140 | #endif |
---|
141 | } |
---|
142 | |
---|
143 | m_iLumaRecStride = (g_uiMaxCUWidth>>1) + 1; |
---|
144 | m_pLumaRecBuffer = new Pel[ m_iLumaRecStride * m_iLumaRecStride ]; |
---|
145 | |
---|
146 | for( Int i = 1; i < 64; i++ ) |
---|
147 | { |
---|
148 | m_uiaShift[i-1] = ( (1 << 15) + i/2 ) / i; |
---|
149 | } |
---|
150 | } |
---|
151 | |
---|
152 | // ==================================================================================================================== |
---|
153 | // Public member functions |
---|
154 | // ==================================================================================================================== |
---|
155 | |
---|
156 | // Function for calculating DC value of the reference samples used in Intra prediction |
---|
157 | Pel TComPrediction::predIntraGetPredValDC( Int* pSrc, Int iSrcStride, UInt iWidth, UInt iHeight, Bool bAbove, Bool bLeft ) |
---|
158 | { |
---|
159 | Int iInd, iSum = 0; |
---|
160 | Pel pDcVal; |
---|
161 | |
---|
162 | if (bAbove) |
---|
163 | { |
---|
164 | for (iInd = 0;iInd < iWidth;iInd++) |
---|
165 | { |
---|
166 | iSum += pSrc[iInd-iSrcStride]; |
---|
167 | } |
---|
168 | } |
---|
169 | if (bLeft) |
---|
170 | { |
---|
171 | for (iInd = 0;iInd < iHeight;iInd++) |
---|
172 | { |
---|
173 | iSum += pSrc[iInd*iSrcStride-1]; |
---|
174 | } |
---|
175 | } |
---|
176 | |
---|
177 | if (bAbove && bLeft) |
---|
178 | { |
---|
179 | pDcVal = (iSum + iWidth) / (iWidth + iHeight); |
---|
180 | } |
---|
181 | else if (bAbove) |
---|
182 | { |
---|
183 | pDcVal = (iSum + iWidth/2) / iWidth; |
---|
184 | } |
---|
185 | else if (bLeft) |
---|
186 | { |
---|
187 | pDcVal = (iSum + iHeight/2) / iHeight; |
---|
188 | } |
---|
189 | else |
---|
190 | { |
---|
191 | pDcVal = pSrc[-1]; // Default DC value already calculated and placed in the prediction array if no neighbors are available |
---|
192 | } |
---|
193 | |
---|
194 | return pDcVal; |
---|
195 | } |
---|
196 | |
---|
197 | // Function for deriving the angular Intra predictions |
---|
198 | |
---|
199 | /** Function for deriving the simplified angular intra predictions. |
---|
200 | * \param pSrc pointer to reconstructed sample array |
---|
201 | * \param srcStride the stride of the reconstructed sample array |
---|
202 | * \param rpDst reference to pointer for the prediction sample array |
---|
203 | * \param dstStride the stride of the prediction sample array |
---|
204 | * \param width the width of the block |
---|
205 | * \param height the height of the block |
---|
206 | * \param dirMode the intra prediction mode index |
---|
207 | * \param blkAboveAvailable boolean indication if the block above is available |
---|
208 | * \param blkLeftAvailable boolean indication if the block to the left is available |
---|
209 | * |
---|
210 | * This function derives the prediction samples for the angular mode based on the prediction direction indicated by |
---|
211 | * the prediction mode index. The prediction direction is given by the displacement of the bottom row of the block and |
---|
212 | * the reference row above the block in the case of vertical prediction or displacement of the rightmost column |
---|
213 | * of the block and reference column left from the block in the case of the horizontal prediction. The displacement |
---|
214 | * is signalled at 1/32 pixel accuracy. When projection of the predicted pixel falls inbetween reference samples, |
---|
215 | * the predicted value for the pixel is linearly interpolated from the reference samples. All reference samples are taken |
---|
216 | * from the extended main reference. |
---|
217 | */ |
---|
218 | Void TComPrediction::xPredIntraAng( Int* pSrc, Int srcStride, Pel*& rpDst, Int dstStride, UInt width, UInt height, UInt dirMode, Bool blkAboveAvailable, Bool blkLeftAvailable, Bool bFilter ) |
---|
219 | { |
---|
220 | Int k,l; |
---|
221 | Int blkSize = width; |
---|
222 | Pel* pDst = rpDst; |
---|
223 | |
---|
224 | // Map the mode index to main prediction direction and angle |
---|
225 | assert( dirMode > 0 ); //no planar |
---|
226 | Bool modeDC = dirMode < 2; |
---|
227 | Bool modeHor = !modeDC && (dirMode < 18); |
---|
228 | Bool modeVer = !modeDC && !modeHor; |
---|
229 | Int intraPredAngle = modeVer ? (Int)dirMode - VER_IDX : modeHor ? -((Int)dirMode - HOR_IDX) : 0; |
---|
230 | Int absAng = abs(intraPredAngle); |
---|
231 | Int signAng = intraPredAngle < 0 ? -1 : 1; |
---|
232 | |
---|
233 | // Set bitshifts and scale the angle parameter to block size |
---|
234 | Int angTable[9] = {0, 2, 5, 9, 13, 17, 21, 26, 32}; |
---|
235 | Int invAngTable[9] = {0, 4096, 1638, 910, 630, 482, 390, 315, 256}; // (256 * 32) / Angle |
---|
236 | Int invAngle = invAngTable[absAng]; |
---|
237 | absAng = angTable[absAng]; |
---|
238 | intraPredAngle = signAng * absAng; |
---|
239 | |
---|
240 | // Do the DC prediction |
---|
241 | if (modeDC) |
---|
242 | { |
---|
243 | Pel dcval = predIntraGetPredValDC(pSrc, srcStride, width, height, blkAboveAvailable, blkLeftAvailable); |
---|
244 | |
---|
245 | for (k=0;k<blkSize;k++) |
---|
246 | { |
---|
247 | for (l=0;l<blkSize;l++) |
---|
248 | { |
---|
249 | pDst[k*dstStride+l] = dcval; |
---|
250 | } |
---|
251 | } |
---|
252 | } |
---|
253 | |
---|
254 | // Do angular predictions |
---|
255 | else |
---|
256 | { |
---|
257 | Pel* refMain; |
---|
258 | Pel* refSide; |
---|
259 | Pel refAbove[2*MAX_CU_SIZE+1]; |
---|
260 | Pel refLeft[2*MAX_CU_SIZE+1]; |
---|
261 | |
---|
262 | // Initialise the Main and Left reference array. |
---|
263 | if (intraPredAngle < 0) |
---|
264 | { |
---|
265 | for (k=0;k<blkSize+1;k++) |
---|
266 | { |
---|
267 | refAbove[k+blkSize-1] = pSrc[k-srcStride-1]; |
---|
268 | } |
---|
269 | for (k=0;k<blkSize+1;k++) |
---|
270 | { |
---|
271 | refLeft[k+blkSize-1] = pSrc[(k-1)*srcStride-1]; |
---|
272 | } |
---|
273 | refMain = (modeVer ? refAbove : refLeft) + (blkSize-1); |
---|
274 | refSide = (modeVer ? refLeft : refAbove) + (blkSize-1); |
---|
275 | |
---|
276 | // Extend the Main reference to the left. |
---|
277 | Int invAngleSum = 128; // rounding for (shift by 8) |
---|
278 | for (k=-1; k>blkSize*intraPredAngle>>5; k--) |
---|
279 | { |
---|
280 | invAngleSum += invAngle; |
---|
281 | refMain[k] = refSide[invAngleSum>>8]; |
---|
282 | } |
---|
283 | } |
---|
284 | else |
---|
285 | { |
---|
286 | for (k=0;k<2*blkSize+1;k++) |
---|
287 | { |
---|
288 | refAbove[k] = pSrc[k-srcStride-1]; |
---|
289 | } |
---|
290 | for (k=0;k<2*blkSize+1;k++) |
---|
291 | { |
---|
292 | refLeft[k] = pSrc[(k-1)*srcStride-1]; |
---|
293 | } |
---|
294 | refMain = modeVer ? refAbove : refLeft; |
---|
295 | refSide = modeVer ? refLeft : refAbove; |
---|
296 | } |
---|
297 | |
---|
298 | if (intraPredAngle == 0) |
---|
299 | { |
---|
300 | for (k=0;k<blkSize;k++) |
---|
301 | { |
---|
302 | for (l=0;l<blkSize;l++) |
---|
303 | { |
---|
304 | pDst[k*dstStride+l] = refMain[l+1]; |
---|
305 | } |
---|
306 | } |
---|
307 | |
---|
308 | if ( bFilter ) |
---|
309 | { |
---|
310 | for (k=0;k<blkSize;k++) |
---|
311 | { |
---|
312 | pDst[k*dstStride] = Clip ( pDst[k*dstStride] + (( refSide[k+1] - refSide[0] ) >> 1) ); |
---|
313 | } |
---|
314 | } |
---|
315 | } |
---|
316 | else |
---|
317 | { |
---|
318 | Int deltaPos=0; |
---|
319 | Int deltaInt; |
---|
320 | Int deltaFract; |
---|
321 | Int refMainIndex; |
---|
322 | |
---|
323 | for (k=0;k<blkSize;k++) |
---|
324 | { |
---|
325 | deltaPos += intraPredAngle; |
---|
326 | deltaInt = deltaPos >> 5; |
---|
327 | deltaFract = deltaPos & (32 - 1); |
---|
328 | |
---|
329 | if (deltaFract) |
---|
330 | { |
---|
331 | // Do linear filtering |
---|
332 | for (l=0;l<blkSize;l++) |
---|
333 | { |
---|
334 | refMainIndex = l+deltaInt+1; |
---|
335 | pDst[k*dstStride+l] = (Pel) ( ((32-deltaFract)*refMain[refMainIndex]+deltaFract*refMain[refMainIndex+1]+16) >> 5 ); |
---|
336 | } |
---|
337 | } |
---|
338 | else |
---|
339 | { |
---|
340 | // Just copy the integer samples |
---|
341 | for (l=0;l<blkSize;l++) |
---|
342 | { |
---|
343 | pDst[k*dstStride+l] = refMain[l+deltaInt+1]; |
---|
344 | } |
---|
345 | } |
---|
346 | } |
---|
347 | } |
---|
348 | |
---|
349 | // Flip the block if this is the horizontal mode |
---|
350 | if (modeHor) |
---|
351 | { |
---|
352 | Pel tmp; |
---|
353 | for (k=0;k<blkSize-1;k++) |
---|
354 | { |
---|
355 | for (l=k+1;l<blkSize;l++) |
---|
356 | { |
---|
357 | tmp = pDst[k*dstStride+l]; |
---|
358 | pDst[k*dstStride+l] = pDst[l*dstStride+k]; |
---|
359 | pDst[l*dstStride+k] = tmp; |
---|
360 | } |
---|
361 | } |
---|
362 | } |
---|
363 | } |
---|
364 | } |
---|
365 | |
---|
366 | Void TComPrediction::predIntraLumaAng(TComPattern* pcTComPattern, UInt uiDirMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, TComDataCU* pcCU, Bool bAbove, Bool bLeft ) |
---|
367 | { |
---|
368 | Pel *pDst = piPred; |
---|
369 | Int *ptrSrc; |
---|
370 | |
---|
371 | assert( g_aucConvertToBit[ iWidth ] >= 0 ); // 4x 4 |
---|
372 | assert( g_aucConvertToBit[ iWidth ] <= 5 ); // 128x128 |
---|
373 | assert( iWidth == iHeight ); |
---|
374 | |
---|
375 | ptrSrc = pcTComPattern->getPredictorPtr( uiDirMode, g_aucConvertToBit[ iWidth ] + 2, m_piYuvExt ); |
---|
376 | |
---|
377 | // get starting pixel in block |
---|
378 | Int sw = 2 * iWidth + 1; |
---|
379 | |
---|
380 | // Create the prediction |
---|
381 | if ( uiDirMode == PLANAR_IDX ) |
---|
382 | { |
---|
383 | xPredIntraPlanar( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight ); |
---|
384 | } |
---|
385 | else |
---|
386 | { |
---|
387 | xPredIntraAng( 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 | // Angular chroma |
---|
397 | Void TComPrediction::predIntraChromaAng( TComPattern* pcTComPattern, Int* piSrc, UInt uiDirMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, TComDataCU* pcCU, Bool bAbove, Bool bLeft ) |
---|
398 | { |
---|
399 | Pel *pDst = piPred; |
---|
400 | Int *ptrSrc = piSrc; |
---|
401 | |
---|
402 | // get starting pixel in block |
---|
403 | Int sw = 2 * iWidth + 1; |
---|
404 | |
---|
405 | if ( uiDirMode == PLANAR_IDX ) |
---|
406 | { |
---|
407 | xPredIntraPlanar( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight ); |
---|
408 | } |
---|
409 | else |
---|
410 | { |
---|
411 | // Create the prediction |
---|
412 | xPredIntraAng( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, uiDirMode, bAbove, bLeft, false ); |
---|
413 | } |
---|
414 | } |
---|
415 | |
---|
416 | /** Function for checking identical motion. |
---|
417 | * \param TComDataCU* pcCU |
---|
418 | * \param UInt PartAddr |
---|
419 | */ |
---|
420 | Bool TComPrediction::xCheckIdenticalMotion ( TComDataCU* pcCU, UInt PartAddr ) |
---|
421 | { |
---|
422 | if( pcCU->getSlice()->isInterB() && pcCU->getSlice()->getPPS()->getWPBiPredIdc() == 0 ) |
---|
423 | { |
---|
424 | if( pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr) >= 0 && pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr) >= 0) |
---|
425 | { |
---|
426 | Int RefPOCL0 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_0, pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr))->getPOC(); |
---|
427 | Int RefViewIdL0 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_0, pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr))->getViewId(); |
---|
428 | Int RefPOCL1 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_1, pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr))->getPOC(); |
---|
429 | Int RefViewIdL1 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_1, pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr))->getViewId(); |
---|
430 | if(RefPOCL0 == RefPOCL1 && RefViewIdL0 == RefViewIdL1 && pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr) == pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr)) |
---|
431 | { |
---|
432 | return true; |
---|
433 | } |
---|
434 | } |
---|
435 | } |
---|
436 | return false; |
---|
437 | } |
---|
438 | |
---|
439 | #if LGE_EDGE_INTRA_A0070 |
---|
440 | Void TComPrediction::predIntraLumaEdge ( TComDataCU* pcCU, TComPattern* pcTComPattern, UInt uiAbsPartIdx, Int iWidth, Int iHeight, Pel* piPred, UInt uiStride, Bool bDelta ) |
---|
441 | { |
---|
442 | Pel *piDst = piPred; |
---|
443 | Int *piSrc; |
---|
444 | Int iSrcStride = ( iWidth<<1 ) + 1; |
---|
445 | Int iDstStride = uiStride; |
---|
446 | |
---|
447 | piSrc = pcTComPattern->getPredictorPtr( 0, g_aucConvertToBit[ iWidth ] + 2, m_piYuvExt ); |
---|
448 | |
---|
449 | xPredIntraEdge ( pcCU, uiAbsPartIdx, iWidth, iHeight, piSrc, iSrcStride, piDst, iDstStride |
---|
450 | #if LGE_EDGE_INTRA_DELTA_DC |
---|
451 | , bDelta |
---|
452 | #endif |
---|
453 | ); |
---|
454 | } |
---|
455 | |
---|
456 | Pel TComPrediction::xGetNearestNeighbor( Int x, Int y, Int* pSrc, Int srcStride, Int iWidth, Int iHeight, Bool* bpRegion ) |
---|
457 | { |
---|
458 | Bool bLeft = (x < y) ? true : false; |
---|
459 | Bool bFound = false; |
---|
460 | Int iFoundX = -1, iFoundY = -1; |
---|
461 | Int cResult = 0; |
---|
462 | |
---|
463 | UChar* piTopDistance = new UChar[iWidth]; |
---|
464 | UChar* piLeftDistance = new UChar[iHeight]; |
---|
465 | |
---|
466 | for( Int i = 0; i < iWidth; i++ ) |
---|
467 | { |
---|
468 | int Abs = x > i ? x - i : i - x; |
---|
469 | piTopDistance[ i ] = y + Abs; |
---|
470 | |
---|
471 | Abs = y > i ? y - i : i - y; |
---|
472 | piLeftDistance[ i ] = x + Abs; |
---|
473 | } |
---|
474 | |
---|
475 | for( Int dist = 0; dist < MAX_DISTANCE_EDGEINTRA && !bFound; dist++ ) |
---|
476 | { |
---|
477 | if( !bLeft ) |
---|
478 | { |
---|
479 | for( Int i = 0; i < iWidth; i++ ) |
---|
480 | { |
---|
481 | if( piTopDistance[ i ] == dist ) |
---|
482 | { |
---|
483 | if( bpRegion[ i ] == bpRegion[ x + y * iWidth ] ) |
---|
484 | { |
---|
485 | iFoundX = i; |
---|
486 | iFoundY = 0; |
---|
487 | bFound = true; |
---|
488 | } |
---|
489 | } |
---|
490 | } |
---|
491 | for( Int i = 0; i < iHeight; i++ ) |
---|
492 | { |
---|
493 | if( piLeftDistance[ i ] == dist ) |
---|
494 | { |
---|
495 | if( bpRegion[ i * iWidth ] == bpRegion[ x + y * iWidth ] ) |
---|
496 | { |
---|
497 | iFoundX = 0; |
---|
498 | iFoundY = i; |
---|
499 | bFound = true; |
---|
500 | } |
---|
501 | } |
---|
502 | } |
---|
503 | } |
---|
504 | else |
---|
505 | { |
---|
506 | for( Int i = 0; i < iHeight; i++ ) |
---|
507 | { |
---|
508 | if( piLeftDistance[ i ] == dist ) |
---|
509 | { |
---|
510 | if( bpRegion[ i * iWidth ] == bpRegion[ x + y * iWidth ] ) |
---|
511 | { |
---|
512 | iFoundX = 0; |
---|
513 | iFoundY = i; |
---|
514 | bFound = true; |
---|
515 | } |
---|
516 | } |
---|
517 | } |
---|
518 | for( Int i = 0; i < iWidth; i++ ) |
---|
519 | { |
---|
520 | if( piTopDistance[ i ] == dist ) |
---|
521 | { |
---|
522 | if( bpRegion[ i ] == bpRegion[ x + y * iWidth ] ) |
---|
523 | { |
---|
524 | iFoundX = i; |
---|
525 | iFoundY = 0; |
---|
526 | bFound = true; |
---|
527 | } |
---|
528 | } |
---|
529 | } |
---|
530 | } |
---|
531 | } |
---|
532 | |
---|
533 | if( iFoundY == 0 ) |
---|
534 | { |
---|
535 | cResult = pSrc[ iFoundX + 1 ]; |
---|
536 | } |
---|
537 | else // iFoundX == 0 |
---|
538 | { |
---|
539 | cResult = pSrc[ (iFoundY + 1) * srcStride ]; |
---|
540 | } |
---|
541 | |
---|
542 | delete[] piTopDistance; piTopDistance = NULL; |
---|
543 | delete[] piLeftDistance; piLeftDistance = NULL; |
---|
544 | |
---|
545 | assert( bFound ); |
---|
546 | |
---|
547 | return cResult; |
---|
548 | } |
---|
549 | |
---|
550 | Void TComPrediction::xPredIntraEdge( TComDataCU* pcCU, UInt uiAbsPartIdx, Int iWidth, Int iHeight, Int* pSrc, Int srcStride, Pel*& rpDst, Int dstStride, Bool bDelta ) |
---|
551 | { |
---|
552 | Pel* pDst = rpDst; |
---|
553 | Bool* pbRegion = pcCU->getEdgePartition( uiAbsPartIdx ); |
---|
554 | |
---|
555 | // Do prediction |
---|
556 | { |
---|
557 | //UInt uiSum0 = 0, uiSum1 = 0; |
---|
558 | Int iSum0 = 0, iSum1 = 0; |
---|
559 | //UInt uiMean0, uiMean1; |
---|
560 | Int iMean0, iMean1; |
---|
561 | //UInt uiCount0 = 0, uiCount1 = 0; |
---|
562 | Int iCount0 = 0, iCount1 = 0; |
---|
563 | for( UInt ui = 0; ui < iWidth; ui++ ) |
---|
564 | { |
---|
565 | if( pbRegion[ ui ] == false ) |
---|
566 | { |
---|
567 | iSum0 += (pSrc[ ui + 1 ]); |
---|
568 | iCount0++; |
---|
569 | } |
---|
570 | else |
---|
571 | { |
---|
572 | iSum1 += (pSrc[ ui + 1 ]); |
---|
573 | iCount1++; |
---|
574 | } |
---|
575 | } |
---|
576 | for( UInt ui = 0; ui < iHeight; ui++ ) // (0,0) recount (to avoid division) |
---|
577 | { |
---|
578 | if( pbRegion[ ui * iWidth ] == false ) |
---|
579 | { |
---|
580 | iSum0 += (pSrc[ (ui + 1) * srcStride ]); |
---|
581 | iCount0++; |
---|
582 | } |
---|
583 | else |
---|
584 | { |
---|
585 | iSum1 += (pSrc[ (ui + 1) * srcStride ]); |
---|
586 | iCount1++; |
---|
587 | } |
---|
588 | } |
---|
589 | if( iCount0 == 0 ) |
---|
590 | assert(false); |
---|
591 | if( iCount1 == 0 ) |
---|
592 | assert(false); |
---|
593 | iMean0 = iSum0 / iCount0; // TODO : integer op. |
---|
594 | iMean1 = iSum1 / iCount1; |
---|
595 | #if LGE_EDGE_INTRA_DELTA_DC |
---|
596 | if( bDelta ) |
---|
597 | { |
---|
598 | Int iDeltaDC0 = pcCU->getEdgeDeltaDC0( uiAbsPartIdx ); |
---|
599 | Int iDeltaDC1 = pcCU->getEdgeDeltaDC1( uiAbsPartIdx ); |
---|
600 | xDeltaDCQuantScaleUp( pcCU, iDeltaDC0 ); |
---|
601 | xDeltaDCQuantScaleUp( pcCU, iDeltaDC1 ); |
---|
602 | iMean0 = Clip( iMean0 + iDeltaDC0 ); |
---|
603 | iMean1 = Clip( iMean1 + iDeltaDC1 ); |
---|
604 | } |
---|
605 | #endif |
---|
606 | for( UInt ui = 0; ui < iHeight; ui++ ) |
---|
607 | { |
---|
608 | for( UInt uii = 0; uii < iWidth; uii++ ) |
---|
609 | { |
---|
610 | if( pbRegion[ uii + ui * iWidth ] == false ) |
---|
611 | pDst[ uii + ui * dstStride ] = iMean0; |
---|
612 | else |
---|
613 | pDst[ uii + ui * dstStride ] = iMean1; |
---|
614 | } |
---|
615 | } |
---|
616 | } |
---|
617 | } |
---|
618 | #endif |
---|
619 | |
---|
620 | #if DEPTH_MAP_GENERATION |
---|
621 | #if MERL_VSP_C0152 |
---|
622 | Void TComPrediction::motionCompensation( TComDataCU* pcCU, TComYuv* pcYuvPred, UInt uiAbsPartIdx, RefPicList eRefPicList, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY ) |
---|
623 | #else |
---|
624 | Void TComPrediction::motionCompensation( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY ) |
---|
625 | #endif |
---|
626 | #else |
---|
627 | #if MERL_VSP_C0152 |
---|
628 | Void TComPrediction::motionCompensation ( TComDataCU* pcCU, TComYuv* pcYuvPred, UInt uiAbsPartIdx, RefPicList eRefPicList, Int iPartIdx ) |
---|
629 | #else |
---|
630 | Void TComPrediction::motionCompensation ( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx ) |
---|
631 | #endif |
---|
632 | #endif |
---|
633 | { |
---|
634 | Int iWidth; |
---|
635 | Int iHeight; |
---|
636 | UInt uiPartAddr; |
---|
637 | |
---|
638 | if ( iPartIdx >= 0 ) |
---|
639 | { |
---|
640 | pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight ); |
---|
641 | |
---|
642 | #if DEPTH_MAP_GENERATION |
---|
643 | if( bPrdDepthMap ) |
---|
644 | { |
---|
645 | iWidth >>= uiSubSampExpX; |
---|
646 | iHeight >>= uiSubSampExpY; |
---|
647 | } |
---|
648 | #endif |
---|
649 | |
---|
650 | if ( eRefPicList != REF_PIC_LIST_X ) |
---|
651 | { |
---|
652 | #if LGE_ILLUCOMP_B0045 |
---|
653 | if( pcCU->getSlice()->getPPS()->getUseWP() && !pcCU->getICFlag(uiPartAddr)) |
---|
654 | #else |
---|
655 | if( pcCU->getSlice()->getPPS()->getUseWP()) |
---|
656 | #endif |
---|
657 | { |
---|
658 | #if MERL_VSP_C0152 |
---|
659 | xPredInterUni (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, true ); |
---|
660 | #else |
---|
661 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, true ); |
---|
662 | #endif |
---|
663 | } |
---|
664 | else |
---|
665 | { |
---|
666 | #if MERL_VSP_C0152 |
---|
667 | xPredInterUni (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false ); |
---|
668 | #else |
---|
669 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false ); |
---|
670 | #endif |
---|
671 | } |
---|
672 | #if LGE_ILLUCOMP_B0045 |
---|
673 | if( pcCU->getSlice()->getPPS()->getUseWP() && !pcCU->getICFlag(uiPartAddr) ) |
---|
674 | #else |
---|
675 | if ( pcCU->getSlice()->getPPS()->getUseWP() ) |
---|
676 | #endif |
---|
677 | { |
---|
678 | xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx ); |
---|
679 | } |
---|
680 | } |
---|
681 | else |
---|
682 | { |
---|
683 | if( xCheckIdenticalMotion( pcCU, uiPartAddr ) && !bPrdDepthMap ) |
---|
684 | { |
---|
685 | #if MERL_VSP_C0152 |
---|
686 | xPredInterUni (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false ); |
---|
687 | #else |
---|
688 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false ); |
---|
689 | #endif |
---|
690 | } |
---|
691 | else |
---|
692 | { |
---|
693 | #if MERL_VSP_C0152 |
---|
694 | xPredInterBi (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, pcYuvPred, iPartIdx, bPrdDepthMap ); |
---|
695 | #else |
---|
696 | xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, pcYuvPred, iPartIdx, bPrdDepthMap ); |
---|
697 | #endif |
---|
698 | } |
---|
699 | } |
---|
700 | return; |
---|
701 | } |
---|
702 | |
---|
703 | for ( iPartIdx = 0; iPartIdx < pcCU->getNumPartInter(); iPartIdx++ ) |
---|
704 | { |
---|
705 | pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight ); |
---|
706 | |
---|
707 | if( bPrdDepthMap ) |
---|
708 | { |
---|
709 | iWidth >>= uiSubSampExpX; |
---|
710 | iHeight >>= uiSubSampExpY; |
---|
711 | } |
---|
712 | |
---|
713 | if ( eRefPicList != REF_PIC_LIST_X ) |
---|
714 | { |
---|
715 | #if LGE_ILLUCOMP_B0045 |
---|
716 | if( pcCU->getSlice()->getPPS()->getUseWP() && !pcCU->getICFlag(uiPartAddr)) |
---|
717 | #else |
---|
718 | if( pcCU->getSlice()->getPPS()->getUseWP()) |
---|
719 | #endif |
---|
720 | { |
---|
721 | #if MERL_VSP_C0152 |
---|
722 | xPredInterUni (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, true ); |
---|
723 | #else |
---|
724 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, true ); |
---|
725 | #endif |
---|
726 | } |
---|
727 | else |
---|
728 | { |
---|
729 | #if MERL_VSP_C0152 |
---|
730 | xPredInterUni (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false ); |
---|
731 | #else |
---|
732 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false ); |
---|
733 | #endif |
---|
734 | } |
---|
735 | #if MERL_VSP_C0152 |
---|
736 | xPredInterUni (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false ); |
---|
737 | #else |
---|
738 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false ); |
---|
739 | #endif |
---|
740 | |
---|
741 | #if LGE_ILLUCOMP_B0045 |
---|
742 | if( pcCU->getSlice()->getPPS()->getUseWP() && !pcCU->getICFlag(uiPartAddr)) |
---|
743 | #else |
---|
744 | if( pcCU->getSlice()->getPPS()->getUseWP()) |
---|
745 | #endif |
---|
746 | { |
---|
747 | xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx ); |
---|
748 | } |
---|
749 | } |
---|
750 | else |
---|
751 | { |
---|
752 | if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) ) |
---|
753 | { |
---|
754 | #if MERL_VSP_C0152 |
---|
755 | xPredInterUni (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false ); |
---|
756 | #else |
---|
757 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false ); |
---|
758 | #endif |
---|
759 | } |
---|
760 | else |
---|
761 | { |
---|
762 | #if MERL_VSP_C0152 |
---|
763 | xPredInterBi (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, pcYuvPred, iPartIdx, bPrdDepthMap ); |
---|
764 | #else |
---|
765 | xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, pcYuvPred, iPartIdx, bPrdDepthMap ); |
---|
766 | #endif |
---|
767 | } |
---|
768 | } |
---|
769 | } |
---|
770 | return; |
---|
771 | } |
---|
772 | |
---|
773 | #if H3D_IVRP & !QC_ARP_D0177 |
---|
774 | Void TComPrediction::residualPrediction(TComDataCU* pcCU, TComYuv* pcYuvPred, TComYuv* pcYuvResPred) |
---|
775 | { |
---|
776 | Int iWidth; |
---|
777 | Int iHeight; |
---|
778 | UInt uiPartAddr; |
---|
779 | |
---|
780 | pcCU->getPartIndexAndSize( 0, uiPartAddr, iWidth, iHeight ); |
---|
781 | |
---|
782 | Bool bResAvail = false; |
---|
783 | |
---|
784 | bResAvail = pcCU->getResidualSamples( 0, true, pcYuvResPred ); |
---|
785 | |
---|
786 | assert (bResAvail); |
---|
787 | |
---|
788 | pcYuvPred->add(pcYuvResPred, iWidth, iHeight); |
---|
789 | } |
---|
790 | #endif |
---|
791 | |
---|
792 | #if MERL_General_Fix |
---|
793 | #if MERL_VSP_C0152 |
---|
794 | // Function to perform VSP block compensation |
---|
795 | Void TComPrediction::xPredInterVSPBlk(TComDataCU* pcCU, UInt uiPartAddr, UInt uiAbsPartIdx, Int iWidth, Int iHeight, TComMv cMv, RefPicList eRefPicList, TComYuv*& rpcYuvPred |
---|
796 | , Bool bi |
---|
797 | #if !MERL_Bi_VSP_D0166 |
---|
798 | , Int vspIdx |
---|
799 | #endif |
---|
800 | ) |
---|
801 | { |
---|
802 | TComPic* pRefPicBaseTxt = NULL; |
---|
803 | TComPicYuv* pcBaseViewTxtPicYuv = NULL; |
---|
804 | TComPicYuv* pcBaseViewDepthPicYuv = NULL; |
---|
805 | Int iBlkX = 0; |
---|
806 | Int iBlkY = 0; |
---|
807 | Int* pShiftLUT; |
---|
808 | Int iShiftPrec; |
---|
809 | |
---|
810 | #if !MERL_VSP_NBDV_RefVId_Fix_D0166 |
---|
811 | pRefPicBaseTxt = pcCU->getSlice()->getRefPicBaseTxt(); |
---|
812 | pcBaseViewTxtPicYuv = pRefPicBaseTxt->getPicYuvRec(); |
---|
813 | TComPic* pRefPicBaseDepth = pcCU->getSlice()->getRefPicBaseDepth(); |
---|
814 | pcBaseViewDepthPicYuv = pRefPicBaseDepth->getPicYuvRec(); |
---|
815 | |
---|
816 | Int iBlkX = ( pcCU->getAddr() % pRefPicBaseDepth->getFrameWidthInCU() ) * g_uiMaxCUWidth + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartIdx ] ]; |
---|
817 | Int iBlkY = ( pcCU->getAddr() / pRefPicBaseDepth->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartIdx ] ]; |
---|
818 | pcCU->getSlice()->getBWVSPLUTParam(pShiftLUT, iShiftPrec); |
---|
819 | xPredInterLumaBlkFromDM ( pcBaseViewTxtPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, iShiftPrec, &cMv, uiPartAddr, iBlkX, iBlkY, iWidth, iHeight, pcCU->getSlice()->getSPS()->isDepth(), rpcYuvPred ); |
---|
820 | xPredInterChromaBlkFromDM( pcBaseViewTxtPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, iShiftPrec, &cMv, uiPartAddr, iBlkX>>1, iBlkY>>1, iWidth>>1, iHeight>>1, pcCU->getSlice()->getSPS()->isDepth(), rpcYuvPred ); |
---|
821 | |
---|
822 | #else // MERL_VSP_NBDV_RefVId_Fix_D0166 |
---|
823 | |
---|
824 | //recover VSP reference frame according to negative refIdx number |
---|
825 | RefPicList privateRefPicList = (RefPicList) pcCU->getVSPDir( uiPartAddr ); |
---|
826 | assert(privateRefPicList == REF_PIC_LIST_0 || privateRefPicList == REF_PIC_LIST_1); |
---|
827 | |
---|
828 | // Step 1: get depth reference |
---|
829 | Int refIdx = -1-pcCU->getCUMvField( privateRefPicList )->getRefIdx( uiPartAddr ); // texture ref index, a trick when storing refIdx |
---|
830 | Int viewId = pcCU->getSlice()->getRefViewId(privateRefPicList, refIdx); // texture view id |
---|
831 | Int refPoc = pcCU->getSlice()->getRefPOC(privateRefPicList, refIdx); // texture POC |
---|
832 | TComPic* pRefPicBaseDepth = pcCU->getSlice()->getDepthRefPic(viewId, refPoc); |
---|
833 | |
---|
834 | pcBaseViewDepthPicYuv = pRefPicBaseDepth->getPicYuvRec(); |
---|
835 | assert(refPoc == pcCU->getSlice()->getPOC()); |
---|
836 | assert(pRefPicBaseDepth != NULL); |
---|
837 | assert(pcBaseViewDepthPicYuv != NULL); |
---|
838 | |
---|
839 | iBlkX = ( pcCU->getAddr() % pRefPicBaseDepth->getFrameWidthInCU() ) * g_uiMaxCUWidth + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartIdx ] ]; |
---|
840 | iBlkY = ( pcCU->getAddr() / pRefPicBaseDepth->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartIdx ] ]; |
---|
841 | #if MERL_Bi_VSP_D0166 |
---|
842 | // Step 2: get texture reference |
---|
843 | pRefPicBaseTxt = xGetVspRefTxt( pcCU, uiPartAddr, eRefPicList); |
---|
844 | pcBaseViewTxtPicYuv = pRefPicBaseTxt->getPicYuvRec(); |
---|
845 | assert(pcBaseViewTxtPicYuv != NULL); |
---|
846 | |
---|
847 | // initialize the LUT according to the reference view idx |
---|
848 | pcCU->getSlice()->getBWVSPLUTParam(pShiftLUT, iShiftPrec, pRefPicBaseTxt->getViewId()); |
---|
849 | |
---|
850 | // Step 3: Do compensation |
---|
851 | xPredInterLumaBlkFromDM ( pcBaseViewTxtPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, iShiftPrec, &cMv, uiPartAddr, iBlkX, iBlkY, iWidth, iHeight, pcCU->getSlice()->getSPS()->isDepth(), rpcYuvPred, bi ); |
---|
852 | xPredInterChromaBlkFromDM( pcBaseViewTxtPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, iShiftPrec, &cMv, uiPartAddr, iBlkX>>1, iBlkY>>1, iWidth>>1, iHeight>>1, pcCU->getSlice()->getSPS()->isDepth(), rpcYuvPred, bi ); |
---|
853 | #else |
---|
854 | // Step 2: get texture reference |
---|
855 | pRefPicBaseTxt = pcCU->getSlice()->getRefPic(privateRefPicList, refIdx); |
---|
856 | pcBaseViewTxtPicYuv = pRefPicBaseTxt->getPicYuvRec(); |
---|
857 | assert(pcBaseViewTxtPicYuv != NULL); |
---|
858 | |
---|
859 | //initialize the LUT according to the reference view idx |
---|
860 | pcCU->getSlice()->getBWVSPLUTParam(pShiftLUT, iShiftPrec, pRefPicBaseTxt->getViewId()); |
---|
861 | |
---|
862 | // Step 3: Do compensation |
---|
863 | xPredInterLumaBlkFromDM ( pcBaseViewTxtPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, iShiftPrec, &cMv, uiPartAddr, iBlkX, iBlkY, iWidth, iHeight, pcCU->getSlice()->getSPS()->isDepth(), vspIdx, rpcYuvPred ); |
---|
864 | xPredInterChromaBlkFromDM( pcBaseViewTxtPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, iShiftPrec, &cMv, uiPartAddr, iBlkX>>1, iBlkY>>1, iWidth>>1, iHeight>>1, pcCU->getSlice()->getSPS()->isDepth(), vspIdx, rpcYuvPred ); |
---|
865 | #endif |
---|
866 | |
---|
867 | #endif |
---|
868 | } |
---|
869 | |
---|
870 | #endif |
---|
871 | |
---|
872 | #if MERL_Bi_VSP_D0166 |
---|
873 | TComPic* TComPrediction::xGetVspRefTxt(TComDataCU* pcCU, UInt uiPartAddr, RefPicList eRefPicList) |
---|
874 | { |
---|
875 | RefPicList privateRefPicList = (RefPicList) pcCU->getVSPDir( uiPartAddr ); |
---|
876 | Int refIdx = -1-pcCU->getCUMvField( privateRefPicList )->getRefIdx( uiPartAddr ); // texture ref index, a trick when storing refIdx |
---|
877 | Int viewId = pcCU->getSlice()->getRefViewId(privateRefPicList, refIdx); // texture view id |
---|
878 | TComPic* refPic = NULL; |
---|
879 | |
---|
880 | assert(privateRefPicList == REF_PIC_LIST_0 || privateRefPicList == REF_PIC_LIST_1); |
---|
881 | |
---|
882 | if (privateRefPicList == eRefPicList) |
---|
883 | { |
---|
884 | Int refIdxt = -1-pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
885 | assert(refIdxt>= 0); |
---|
886 | refPic = pcCU->getSlice()->getRefPic(eRefPicList, refIdxt); |
---|
887 | } |
---|
888 | else |
---|
889 | { |
---|
890 | // Find the other interview reference in order to do VSP |
---|
891 | RefPicList otherRefPicList = privateRefPicList == REF_PIC_LIST_0 ? REF_PIC_LIST_1 : REF_PIC_LIST_0; |
---|
892 | Bool isFound = false; |
---|
893 | for (Int iRefIdx = 0; iRefIdx <pcCU->getSlice()->getNumRefIdx(otherRefPicList); iRefIdx ++ ) |
---|
894 | { |
---|
895 | Int refViewIdx = pcCU->getSlice()->getRefViewId( otherRefPicList, iRefIdx); |
---|
896 | if ( (refViewIdx != pcCU->getSlice()->getViewId()) && (refViewIdx != viewId ) ) |
---|
897 | { |
---|
898 | refPic = pcCU->getSlice()->getRefPic(otherRefPicList, iRefIdx); |
---|
899 | isFound = true; |
---|
900 | break; |
---|
901 | } |
---|
902 | } |
---|
903 | |
---|
904 | if (isFound == false) |
---|
905 | { |
---|
906 | Int refIdxTxt = -1-pcCU->getCUMvField( privateRefPicList )->getRefIdx( uiPartAddr ); |
---|
907 | assert(refIdxTxt >= 0); |
---|
908 | refPic = pcCU->getSlice()->getRefPic(privateRefPicList, refIdxTxt); |
---|
909 | } |
---|
910 | assert(isFound); |
---|
911 | } |
---|
912 | assert(refPic != NULL); |
---|
913 | return refPic; |
---|
914 | } |
---|
915 | #endif |
---|
916 | #endif |
---|
917 | |
---|
918 | #if MERL_VSP_C0152 |
---|
919 | Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, UInt uiAbsPartIdx, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY, Bool bi ) |
---|
920 | #else |
---|
921 | Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY, Bool bi ) |
---|
922 | #endif |
---|
923 | { |
---|
924 | #if MERL_VSP_C0152 |
---|
925 | Int iRefIdx = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
926 | Int vspIdx = pcCU->getVSPIndex(uiPartAddr); |
---|
927 | if (vspIdx != 0) |
---|
928 | { |
---|
929 | if (iRefIdx >= 0) |
---|
930 | { |
---|
931 | printf("vspIdx = %d, iRefIdx = %d\n", vspIdx, iRefIdx); |
---|
932 | } |
---|
933 | assert (iRefIdx < 0); // assert (iRefIdx == NOT_VALID); |
---|
934 | } |
---|
935 | else |
---|
936 | { |
---|
937 | assert (iRefIdx >= 0); |
---|
938 | } |
---|
939 | #else |
---|
940 | Int iRefIdx = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); assert (iRefIdx >= 0); |
---|
941 | #endif |
---|
942 | |
---|
943 | TComMv cMv = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr ); |
---|
944 | pcCU->clipMv(cMv); |
---|
945 | |
---|
946 | #if DEPTH_MAP_GENERATION |
---|
947 | if( bPrdDepthMap ) |
---|
948 | { |
---|
949 | UInt uiRShift = 0; |
---|
950 | if( pcCU->getPic()->getStoredPDMforV2() == 1 ) |
---|
951 | xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPredDepthMapTemp(), uiPartAddr, &cMv, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, rpcYuvPred, uiRShift, 0 ); |
---|
952 | else |
---|
953 | xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPredDepthMap(), uiPartAddr, &cMv, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, rpcYuvPred, uiRShift, 0 ); |
---|
954 | |
---|
955 | return; |
---|
956 | } |
---|
957 | #endif |
---|
958 | #if QC_ARP_D0177 |
---|
959 | if( |
---|
960 | #if MERL_General_Fix // TODO: Maybe logically redundant, but easier to read. Need verification before being removed |
---|
961 | #if MERL_VSP_C0152 |
---|
962 | vspIdx == 0 && |
---|
963 | #endif |
---|
964 | #endif |
---|
965 | pcCU->getSlice()->getSPS()->isDepth() == false |
---|
966 | && pcCU->getSlice()->getSPS()->getViewId() > 0 |
---|
967 | && pcCU->getSlice()->getSPS()->getUseAdvRP() > 0 |
---|
968 | && pcCU->getARPW( uiPartAddr ) > 0 |
---|
969 | && pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()!= pcCU->getSlice()->getPOC() |
---|
970 | && (pcCU->getPartitionSize(uiPartAddr)==SIZE_2Nx2N || pcCU->isSkipped(uiPartAddr)) |
---|
971 | ) |
---|
972 | { |
---|
973 | xPredInterUniARP( pcCU , uiPartAddr , iWidth , iHeight , eRefPicList , rpcYuvPred , iPartIdx , bi ); |
---|
974 | } |
---|
975 | else |
---|
976 | { |
---|
977 | #endif |
---|
978 | #if HHI_FULL_PEL_DEPTH_MAP_MV_ACC |
---|
979 | if( pcCU->getSlice()->getSPS()->isDepth() ) |
---|
980 | { |
---|
981 | #if MERL_VSP_C0152 |
---|
982 | if (vspIdx != 0) |
---|
983 | { // depth, vsp compensation |
---|
984 | #if !MERL_General_Fix |
---|
985 | // get depth estimator here |
---|
986 | TComPic* pRefPicBaseDepth = pcCU->getSlice()->getRefPicBaseDepth(); |
---|
987 | TComPicYuv* pcBaseViewDepthPicYuv = NULL; |
---|
988 | if (vspIdx < 4) // spatial |
---|
989 | { |
---|
990 | pcBaseViewDepthPicYuv = pRefPicBaseDepth->getPicYuvRec(); |
---|
991 | } |
---|
992 | Int iBlkX = ( pcCU->getAddr() % pRefPicBaseDepth->getFrameWidthInCU() ) * g_uiMaxCUWidth + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartIdx ] ]; |
---|
993 | Int iBlkY = ( pcCU->getAddr() / pRefPicBaseDepth->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartIdx ] ]; |
---|
994 | Int* pShiftLUT; |
---|
995 | Int iShiftPrec; |
---|
996 | pcCU->getSlice()->getBWVSPLUTParam(pShiftLUT, iShiftPrec); |
---|
997 | //using disparity to find the depth block of the base view as the depth block estimator of the current block |
---|
998 | //using depth block estimator and base view texture to get Backward warping |
---|
999 | xPredInterLumaBlkFromDM ( pcBaseViewDepthPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, iShiftPrec, &cMv, uiPartAddr, iBlkX, iBlkY, iWidth, iHeight, pcCU->getSlice()->getSPS()->isDepth(), vspIdx, rpcYuvPred ); |
---|
1000 | xPredInterChromaBlkFromDM( pcBaseViewDepthPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, iShiftPrec, &cMv, uiPartAddr, iBlkX>>1, iBlkY>>1, iWidth>>1, iHeight>>1, pcCU->getSlice()->getSPS()->isDepth(), vspIdx, rpcYuvPred ); |
---|
1001 | #else |
---|
1002 | #if MERL_Bi_VSP_D0166 |
---|
1003 | xPredInterVSPBlk(pcCU, uiPartAddr, uiAbsPartIdx, iWidth, iHeight, cMv, eRefPicList, rpcYuvPred, bi ); |
---|
1004 | #else |
---|
1005 | xPredInterVSPBlk(pcCU, uiPartAddr, uiAbsPartIdx, iWidth, iHeight, cMv, eRefPicList, rpcYuvPred, bi, vspIdx ); |
---|
1006 | #endif |
---|
1007 | #endif |
---|
1008 | } |
---|
1009 | else |
---|
1010 | { |
---|
1011 | #endif |
---|
1012 | UInt uiRShift = ( bi ? 14-g_uiBitDepth-g_uiBitIncrement : 0 ); |
---|
1013 | UInt uiOffset = bi ? IF_INTERNAL_OFFS : 0; |
---|
1014 | #if LGE_ILLUCOMP_DEPTH_C0046 |
---|
1015 | Bool bICFlag = pcCU->getICFlag(uiPartAddr) && (pcCU->getSlice()->getRefViewId( eRefPicList, iRefIdx ) != pcCU->getSlice()->getViewId()); |
---|
1016 | #endif |
---|
1017 | #if DEPTH_MAP_GENERATION |
---|
1018 | xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, 0, 0, rpcYuvPred, uiRShift, uiOffset |
---|
1019 | #if LGE_ILLUCOMP_DEPTH_C0046 |
---|
1020 | , bICFlag |
---|
1021 | #endif |
---|
1022 | ); |
---|
1023 | #else |
---|
1024 | xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, uiRShift, uiOffset ); |
---|
1025 | #endif |
---|
1026 | #if MERL_VSP_C0152 |
---|
1027 | } |
---|
1028 | #endif// MERL_VSP_C0152 //else |
---|
1029 | } |
---|
1030 | else // texture |
---|
1031 | { |
---|
1032 | #endif |
---|
1033 | #if MERL_VSP_C0152 |
---|
1034 | if ( vspIdx != 0 ) |
---|
1035 | { // texture, vsp compensation |
---|
1036 | #if !MERL_General_Fix |
---|
1037 | TComPic* pRefPicBaseTxt = pcCU->getSlice()->getRefPicBaseTxt(); |
---|
1038 | TComPicYuv* pcBaseViewTxtPicYuv = pRefPicBaseTxt->getPicYuvRec(); |
---|
1039 | TComPicYuv* pcBaseViewDepthPicYuv = NULL; |
---|
1040 | if (vspIdx < 4) // spatial |
---|
1041 | { |
---|
1042 | TComPic* pRefPicBaseDepth = pcCU->getSlice()->getRefPicBaseDepth(); |
---|
1043 | pcBaseViewDepthPicYuv = pRefPicBaseDepth->getPicYuvRec(); |
---|
1044 | } |
---|
1045 | Int iBlkX = ( pcCU->getAddr() % pRefPicBaseTxt->getFrameWidthInCU() ) * g_uiMaxCUWidth + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartIdx ] ]; |
---|
1046 | Int iBlkY = ( pcCU->getAddr() / pRefPicBaseTxt->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartIdx ] ]; |
---|
1047 | Int* pShiftLUT; |
---|
1048 | Int iShiftPrec; |
---|
1049 | pcCU->getSlice()->getBWVSPLUTParam(pShiftLUT, iShiftPrec); |
---|
1050 | |
---|
1051 | //using disparity to find the depth block of the base view as the depth block estimator of the current block |
---|
1052 | //using depth block estimator and base view texture to get Backward warping |
---|
1053 | xPredInterLumaBlkFromDM ( pcBaseViewTxtPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, iShiftPrec, &cMv, uiPartAddr, iBlkX, iBlkY, iWidth, iHeight, pcCU->getSlice()->getSPS()->isDepth(), vspIdx, rpcYuvPred ); |
---|
1054 | xPredInterChromaBlkFromDM( pcBaseViewTxtPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, iShiftPrec, &cMv, uiPartAddr, iBlkX>>1, iBlkY>>1, iWidth>>1, iHeight>>1, pcCU->getSlice()->getSPS()->isDepth(), vspIdx, rpcYuvPred ); |
---|
1055 | #else |
---|
1056 | #if MERL_Bi_VSP_D0166 |
---|
1057 | xPredInterVSPBlk(pcCU, uiPartAddr, uiAbsPartIdx, iWidth, iHeight, cMv, eRefPicList, rpcYuvPred, bi ); |
---|
1058 | #else |
---|
1059 | xPredInterVSPBlk(pcCU, uiPartAddr, uiAbsPartIdx, iWidth, iHeight, cMv, eRefPicList, rpcYuvPred, bi, vspIdx ); |
---|
1060 | #endif |
---|
1061 | #endif |
---|
1062 | } |
---|
1063 | else//texture not VSP |
---|
1064 | { |
---|
1065 | #endif //MERL_VSP_C0152 |
---|
1066 | #if LGE_ILLUCOMP_B0045 |
---|
1067 | Bool bICFlag = pcCU->getICFlag(uiPartAddr) && (pcCU->getSlice()->getRefViewId( eRefPicList, iRefIdx ) != pcCU->getSlice()->getViewId()); |
---|
1068 | |
---|
1069 | xPredInterLumaBlk ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi, bICFlag); |
---|
1070 | #else |
---|
1071 | xPredInterLumaBlk ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi ); |
---|
1072 | #endif |
---|
1073 | #if MERL_VSP_C0152 |
---|
1074 | } //texture not VSP |
---|
1075 | #endif |
---|
1076 | #if HHI_FULL_PEL_DEPTH_MAP_MV_ACC |
---|
1077 | } |
---|
1078 | #endif |
---|
1079 | |
---|
1080 | #if MERL_VSP_C0152 |
---|
1081 | if ( vspIdx == 0 )//Not VSP |
---|
1082 | { |
---|
1083 | #endif |
---|
1084 | #if LGE_ILLUCOMP_B0045 |
---|
1085 | Bool bICFlag = pcCU->getICFlag(uiPartAddr) && (pcCU->getSlice()->getRefViewId( eRefPicList, iRefIdx ) != pcCU->getSlice()->getViewId()); |
---|
1086 | |
---|
1087 | xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi, bICFlag ); |
---|
1088 | #else |
---|
1089 | xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi ); |
---|
1090 | #endif |
---|
1091 | #if MERL_VSP_C0152 |
---|
1092 | } |
---|
1093 | #endif |
---|
1094 | #if QC_ARP_D0177 |
---|
1095 | } |
---|
1096 | #endif |
---|
1097 | } |
---|
1098 | |
---|
1099 | #if QC_ARP_D0177 |
---|
1100 | Void TComPrediction::xPredInterUniARP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bi, TComMvField * pNewMvFiled ) |
---|
1101 | { |
---|
1102 | Int iRefIdx = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
1103 | TComMv cMv = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr ); |
---|
1104 | Bool bTobeScaled = false; |
---|
1105 | UChar dW = pcCU->getARPW ( uiPartAddr ); |
---|
1106 | TComPic* pcPicYuvBaseCol = NULL; |
---|
1107 | TComPic* pcPicYuvBaseRef = NULL; |
---|
1108 | DisInfo cDistparity; |
---|
1109 | |
---|
1110 | if( pNewMvFiled ) |
---|
1111 | { |
---|
1112 | iRefIdx = pNewMvFiled->getRefIdx(); |
---|
1113 | cMv = pNewMvFiled->getMv(); |
---|
1114 | } |
---|
1115 | |
---|
1116 | #if QC_CU_NBDV_D0181 |
---|
1117 | cDistparity.bDV = pcCU->getDvInfo(uiPartAddr).bDV; |
---|
1118 | if( cDistparity.bDV ) |
---|
1119 | { |
---|
1120 | #if MERL_VSP_C0152 |
---|
1121 | cDistparity.m_acMvCand[0] = pcCU->getDvInfo(0).m_acMvCandNoRef[0]; |
---|
1122 | #else |
---|
1123 | cDistparity.m_acMvCand[0] = pcCU->getDvInfo(0).m_acMvCand[0]; |
---|
1124 | #endif |
---|
1125 | assert(pcCU->getDvInfo(uiPartAddr).bDV == pcCU->getDvInfo(0).bDV); |
---|
1126 | cDistparity.m_aVIdxCan[0] = pcCU->getDvInfo(uiPartAddr).m_aVIdxCan[0]; |
---|
1127 | cDistparity.iN = pcCU->getDvInfo(uiPartAddr).iN; |
---|
1128 | } |
---|
1129 | else |
---|
1130 | cDistparity.iN = 0; |
---|
1131 | #else |
---|
1132 | pcCU->getDisMvpCandNBDV( iPartIdx, uiPartAddr, &cDistparity, false ); |
---|
1133 | #endif |
---|
1134 | |
---|
1135 | dW = !cDistparity.iN ? 0: dW; |
---|
1136 | if( cDistparity.iN ) |
---|
1137 | { |
---|
1138 | if(dW > 0 && pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC()!= pcCU->getSlice()->getPOC()) |
---|
1139 | bTobeScaled = true; |
---|
1140 | pcPicYuvBaseCol = pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getPOC(), cDistparity.m_aVIdxCan[0] ); |
---|
1141 | pcPicYuvBaseRef = pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC(), cDistparity.m_aVIdxCan[0] ); |
---|
1142 | if( (!pcPicYuvBaseCol || pcPicYuvBaseCol->getPOC() != pcCU->getSlice()->getPOC()) || (!pcPicYuvBaseRef || pcPicYuvBaseRef->getPOC() != pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC() )) |
---|
1143 | { |
---|
1144 | dW = 0; |
---|
1145 | bTobeScaled = false; |
---|
1146 | } |
---|
1147 | else |
---|
1148 | assert( pcPicYuvBaseCol->getPOC() == pcCU->getSlice()->getPOC() && pcPicYuvBaseRef->getPOC() == pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC() ); |
---|
1149 | if(bTobeScaled) |
---|
1150 | { |
---|
1151 | Int iCurrPOC = pcCU->getSlice()->getPOC(); |
---|
1152 | Int iColRefPOC = pcCU->getSlice()->getRefPOC( eRefPicList, iRefIdx ); |
---|
1153 | Int iCurrRefPOC = pcCU->getSlice()->getRefPOC( eRefPicList, 0); |
---|
1154 | Int iScale = pcCU-> xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iCurrPOC, iColRefPOC); |
---|
1155 | if ( iScale != 4096 ) |
---|
1156 | cMv = cMv.scaleMv( iScale ); |
---|
1157 | iRefIdx = 0; |
---|
1158 | } |
---|
1159 | } |
---|
1160 | pcCU->clipMv(cMv); |
---|
1161 | TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(); |
---|
1162 | xPredInterLumaBlk ( pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi |
---|
1163 | #if LGE_ILLUCOMP_B0045 |
---|
1164 | , false |
---|
1165 | #endif |
---|
1166 | , true |
---|
1167 | ); |
---|
1168 | xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi |
---|
1169 | #if LGE_ILLUCOMP_B0045 |
---|
1170 | , false |
---|
1171 | #endif |
---|
1172 | , true |
---|
1173 | ); |
---|
1174 | if( dW > 0 ) |
---|
1175 | { |
---|
1176 | TComYuv * pYuvmB0 = &m_acYuvPredBase[0]; |
---|
1177 | TComYuv * pYuvB1 = &m_acYuvPredBase[1]; |
---|
1178 | assert ( cDistparity.iN == 1 ); |
---|
1179 | pcPicYuvRef = pcPicYuvBaseCol->getPicYuvRec(); |
---|
1180 | xPredInterLumaBlk ( pcCU, pcPicYuvRef, uiPartAddr, &cDistparity.m_acMvCand[0], iWidth, iHeight, pYuvB1, bi |
---|
1181 | #if LGE_ILLUCOMP_B0045 |
---|
1182 | , false |
---|
1183 | #endif |
---|
1184 | , true |
---|
1185 | ); |
---|
1186 | xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cDistparity.m_acMvCand[0], iWidth, iHeight, pYuvB1, bi |
---|
1187 | #if LGE_ILLUCOMP_B0045 |
---|
1188 | , false |
---|
1189 | #endif |
---|
1190 | , true |
---|
1191 | ); |
---|
1192 | pcPicYuvRef = pcPicYuvBaseRef->getPicYuvRec(); |
---|
1193 | TComMv cMVwithDisparity = cMv + cDistparity.m_acMvCand[0]; |
---|
1194 | pcCU->clipMv(cMVwithDisparity); |
---|
1195 | xPredInterLumaBlk ( pcCU, pcPicYuvRef, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvmB0, bi |
---|
1196 | #if LGE_ILLUCOMP_B0045 |
---|
1197 | , false |
---|
1198 | #endif |
---|
1199 | , true |
---|
1200 | ); |
---|
1201 | xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvmB0, bi |
---|
1202 | #if LGE_ILLUCOMP_B0045 |
---|
1203 | , false |
---|
1204 | #endif |
---|
1205 | , true |
---|
1206 | ); |
---|
1207 | pYuvB1->subtractARP( pYuvB1 , pYuvmB0 , uiPartAddr , iWidth , iHeight ); |
---|
1208 | if(dW == 2) |
---|
1209 | pYuvB1->multiplyARP( uiPartAddr , iWidth , iHeight , dW ); |
---|
1210 | rpcYuvPred->addARP( rpcYuvPred , pYuvB1 , uiPartAddr , iWidth , iHeight , !bi ); |
---|
1211 | } |
---|
1212 | } |
---|
1213 | #endif |
---|
1214 | |
---|
1215 | #if MERL_VSP_C0152 |
---|
1216 | Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, UInt uiAbsPartIdx, Int iWidth, Int iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap ) |
---|
1217 | #else |
---|
1218 | Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap ) |
---|
1219 | #endif |
---|
1220 | { |
---|
1221 | TComYuv* pcMbYuv; |
---|
1222 | Int iRefIdx[2] = {-1, -1}; |
---|
1223 | |
---|
1224 | #if MERL_Bi_VSP_D0166 |
---|
1225 | Bool biDecision = 0; |
---|
1226 | Int predDirVSP = 0; |
---|
1227 | if (pcCU->getVSPIndex(uiPartAddr) != 0) // is VSP |
---|
1228 | { |
---|
1229 | Int biVSPAvail = 0; |
---|
1230 | //test whether VSP is Bi or Uni |
---|
1231 | //Step1. Get derived DV view id |
---|
1232 | RefPicList privateRefPicList = (RefPicList) pcCU->getVSPDir( uiPartAddr ); |
---|
1233 | RefPicList otherRefPicList = privateRefPicList == REF_PIC_LIST_0 ? REF_PIC_LIST_1 : REF_PIC_LIST_0; |
---|
1234 | assert(privateRefPicList == REF_PIC_LIST_0 || privateRefPicList == REF_PIC_LIST_1); |
---|
1235 | Int refIdx = -1-pcCU->getCUMvField( privateRefPicList )->getRefIdx( uiPartAddr ); |
---|
1236 | assert(refIdx >= 0); |
---|
1237 | Int viewId = pcCU->getSlice()->getRefViewId(privateRefPicList, refIdx); |
---|
1238 | Int refPoc = pcCU->getSlice()->getRefPOC(privateRefPicList, refIdx); |
---|
1239 | |
---|
1240 | assert(refPoc == pcCU->getSlice()->getPOC()); |
---|
1241 | // if(refPoc != pcCU->getSlice()->getPOC() ) |
---|
1242 | // { |
---|
1243 | // printf("refPOC= %d, and current POC=%d\n", refPoc, pcCU->getSlice()->getPOC() ); |
---|
1244 | // } |
---|
1245 | //Step 2. Get initial prediction direction value according to reference picture list availability |
---|
1246 | Int iInterDir = ((pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_0) > 0 && pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_1) > 0) ? 3 : |
---|
1247 | (pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_0) > 0 ? 1 : 2)); |
---|
1248 | //Step 3. Check the availability of Bi VSP by checking the interview reference availability in the other reference list |
---|
1249 | if(iInterDir == 3) |
---|
1250 | { |
---|
1251 | for (Int jRefIdx = 0; jRefIdx <pcCU->getSlice()->getNumRefIdx(otherRefPicList); jRefIdx++ ) |
---|
1252 | { |
---|
1253 | Int refViewIdx = pcCU->getSlice()->getRefViewId( otherRefPicList, jRefIdx); |
---|
1254 | if ( (refViewIdx != pcCU->getSlice()->getViewId()) && (refViewIdx != viewId ) ) |
---|
1255 | { |
---|
1256 | biVSPAvail = 1; |
---|
1257 | break; |
---|
1258 | } |
---|
1259 | } |
---|
1260 | } |
---|
1261 | //Step 4. Update the Bi VSP prediction direction |
---|
1262 | if ( iInterDir == 3 && biVSPAvail == 1) |
---|
1263 | { |
---|
1264 | biDecision = 1; |
---|
1265 | predDirVSP = 3; |
---|
1266 | } |
---|
1267 | else |
---|
1268 | { |
---|
1269 | biDecision = 0; |
---|
1270 | if ( privateRefPicList == REF_PIC_LIST_0 ) |
---|
1271 | predDirVSP = 1; |
---|
1272 | else |
---|
1273 | predDirVSP = 2; |
---|
1274 | } |
---|
1275 | } |
---|
1276 | else |
---|
1277 | {//not VSP |
---|
1278 | if( ( pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr ) >= 0 && pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr ) >= 0 ) ) |
---|
1279 | biDecision = 1; |
---|
1280 | else |
---|
1281 | biDecision = 0; |
---|
1282 | } |
---|
1283 | #endif |
---|
1284 | |
---|
1285 | for ( Int iRefList = 0; iRefList < 2; iRefList++ ) |
---|
1286 | { |
---|
1287 | RefPicList eRefPicList = (iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0); |
---|
1288 | iRefIdx[iRefList] = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
1289 | |
---|
1290 | #if MERL_VSP_C0152 |
---|
1291 | if(!pcCU->getVSPIndex(uiPartAddr)) |
---|
1292 | { |
---|
1293 | if ( iRefIdx[iRefList] < 0 ) |
---|
1294 | { |
---|
1295 | continue; |
---|
1296 | } |
---|
1297 | } |
---|
1298 | else |
---|
1299 | { |
---|
1300 | |
---|
1301 | #if !MERL_Bi_VSP_D0166 //both lists should go |
---|
1302 | if ( iRefList == REF_PIC_LIST_1 && iRefIdx[iRefList] < 0 ) // iRefIdx[iRefList] ==NOT_VALID |
---|
1303 | { |
---|
1304 | continue; |
---|
1305 | } |
---|
1306 | #else |
---|
1307 | //Reference list loop termination |
---|
1308 | RefPicList privateVSPRefPicList = (RefPicList) pcCU->getVSPDir( uiPartAddr ); |
---|
1309 | if( (pcCU->getVSPIndex(uiPartAddr)!=0) && iRefList != privateVSPRefPicList && !biDecision ) |
---|
1310 | {//when VSP mode, if it is uni prediction, the other reference list should skip |
---|
1311 | continue; |
---|
1312 | } |
---|
1313 | #endif |
---|
1314 | |
---|
1315 | } |
---|
1316 | #else |
---|
1317 | if ( iRefIdx[iRefList] < 0 ) |
---|
1318 | { |
---|
1319 | continue; |
---|
1320 | } |
---|
1321 | #endif |
---|
1322 | |
---|
1323 | assert( iRefIdx[iRefList] < pcCU->getSlice()->getNumRefIdx(eRefPicList) ); |
---|
1324 | |
---|
1325 | pcMbYuv = &m_acYuvPred[iRefList]; |
---|
1326 | |
---|
1327 | #if MERL_Bi_VSP_D0166 |
---|
1328 | if(biDecision == 1) |
---|
1329 | #else |
---|
1330 | if( pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr ) >= 0 && pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr ) >= 0 ) |
---|
1331 | #endif |
---|
1332 | { |
---|
1333 | #if MERL_VSP_C0152 |
---|
1334 | xPredInterUni ( pcCU, uiPartAddr, uiAbsPartIdx, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, true ); |
---|
1335 | #else |
---|
1336 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, true ); |
---|
1337 | #endif |
---|
1338 | } |
---|
1339 | else |
---|
1340 | { |
---|
1341 | #if FIX_LGE_WP_FOR_3D_C0223 |
---|
1342 | if ( ( pcCU->getSlice()->getPPS()->getUseWP() && pcCU->getSlice()->getSliceType() == P_SLICE ) || |
---|
1343 | ( pcCU->getSlice()->getPPS()->getWPBiPredIdc() && pcCU->getSlice()->getSliceType() == B_SLICE ) ) |
---|
1344 | #else |
---|
1345 | if ( pcCU->getSlice()->getPPS()->getWPBiPredIdc() ) |
---|
1346 | #endif |
---|
1347 | { |
---|
1348 | #if MERL_VSP_C0152 |
---|
1349 | xPredInterUni ( pcCU, uiPartAddr, uiAbsPartIdx, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, true ); |
---|
1350 | #else |
---|
1351 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, true ); |
---|
1352 | #endif |
---|
1353 | } |
---|
1354 | else |
---|
1355 | { |
---|
1356 | #if MERL_VSP_C0152 |
---|
1357 | xPredInterUni ( pcCU, uiPartAddr, uiAbsPartIdx, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false ); |
---|
1358 | #else |
---|
1359 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false ); |
---|
1360 | #endif |
---|
1361 | } |
---|
1362 | } |
---|
1363 | } |
---|
1364 | #if FIX_LGE_WP_FOR_3D_C0223 |
---|
1365 | if ( pcCU->getSlice()->getPPS()->getWPBiPredIdc() && pcCU->getSlice()->getSliceType() == B_SLICE ) |
---|
1366 | #else |
---|
1367 | if ( pcCU->getSlice()->getPPS()->getWPBiPredIdc() ) |
---|
1368 | #endif |
---|
1369 | { |
---|
1370 | #if MERL_VSP_C0152 |
---|
1371 | #if !MERL_Bi_VSP_D0166 |
---|
1372 | if(pcCU->getVSPIndex(uiPartAddr)) |
---|
1373 | m_acYuvPred[0].copyPartToPartYuv( rpcYuvPred, uiPartAddr, iWidth, iHeight ); |
---|
1374 | else |
---|
1375 | #endif |
---|
1376 | #endif |
---|
1377 | xWeightedPredictionBi( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); |
---|
1378 | } |
---|
1379 | #if FIX_LGE_WP_FOR_3D_C0223 |
---|
1380 | else if ( pcCU->getSlice()->getPPS()->getUseWP() && pcCU->getSlice()->getSliceType() == P_SLICE ) |
---|
1381 | |
---|
1382 | { |
---|
1383 | #if MERL_VSP_C0152 |
---|
1384 | #if !MERL_Bi_VSP_D0166 |
---|
1385 | if(pcCU->getVSPIndex(uiPartAddr)) |
---|
1386 | m_acYuvPred[0].copyPartToPartYuv( rpcYuvPred, uiPartAddr, iWidth, iHeight ); |
---|
1387 | else |
---|
1388 | #endif |
---|
1389 | #endif |
---|
1390 | xWeightedPredictionUni( pcCU, &m_acYuvPred[0], uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, rpcYuvPred, iPartIdx ); |
---|
1391 | } |
---|
1392 | #endif |
---|
1393 | else |
---|
1394 | { |
---|
1395 | if ( bPrdDepthMap ) |
---|
1396 | { |
---|
1397 | xWeightedAveragePdm( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred, uiSubSampExpX, uiSubSampExpY ); |
---|
1398 | } |
---|
1399 | else |
---|
1400 | { |
---|
1401 | #if MERL_VSP_C0152 |
---|
1402 | #if !MERL_Bi_VSP_D0166 |
---|
1403 | if(pcCU->getVSPIndex(uiPartAddr)) |
---|
1404 | m_acYuvPred[0].copyPartToPartYuv( rpcYuvPred, uiPartAddr, iWidth, iHeight ); |
---|
1405 | else |
---|
1406 | xWeightedAverage( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); |
---|
1407 | #else |
---|
1408 | xWeightedAverage( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred, predDirVSP ); |
---|
1409 | #endif |
---|
1410 | #else |
---|
1411 | xWeightedAverage( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); |
---|
1412 | #endif |
---|
1413 | } |
---|
1414 | } |
---|
1415 | } |
---|
1416 | |
---|
1417 | |
---|
1418 | |
---|
1419 | Void |
---|
1420 | TComPrediction::xPredInterPrdDepthMap( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY, TComYuv*& rpcYuv, UInt uiRShift, UInt uiOffset |
---|
1421 | #if LGE_ILLUCOMP_DEPTH_C0046 |
---|
1422 | , Bool bICFlag |
---|
1423 | #endif |
---|
1424 | ) |
---|
1425 | { |
---|
1426 | Int iShiftX = 2 + uiSubSampExpX; |
---|
1427 | Int iShiftY = 2 + uiSubSampExpY; |
---|
1428 | Int iAddX = ( 1 << iShiftX ) >> 1; |
---|
1429 | Int iAddY = ( 1 << iShiftY ) >> 1; |
---|
1430 | Int iHor = ( pcMv->getHor() + iAddX ) >> iShiftX; |
---|
1431 | Int iVer = ( pcMv->getVer() + iAddY ) >> iShiftY; |
---|
1432 | #if HHI_FULL_PEL_DEPTH_MAP_MV_ACC |
---|
1433 | if( pcCU->getSlice()->getSPS()->isDepth() ) |
---|
1434 | { |
---|
1435 | iHor = pcMv->getHor(); |
---|
1436 | iVer = pcMv->getVer(); |
---|
1437 | } |
---|
1438 | #endif |
---|
1439 | Int iRefStride = pcPicYuvRef->getStride(); |
---|
1440 | Int iDstStride = rpcYuv->getStride(); |
---|
1441 | Int iRefOffset = iHor + iVer * iRefStride; |
---|
1442 | |
---|
1443 | Pel* piRefY = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset; |
---|
1444 | Pel* piDstY = rpcYuv->getLumaAddr( uiPartAddr ); |
---|
1445 | |
---|
1446 | for( Int y = 0; y < iHeight; y++, piDstY += iDstStride, piRefY += iRefStride ) |
---|
1447 | { |
---|
1448 | for( Int x = 0; x < iWidth; x++ ) |
---|
1449 | { |
---|
1450 | piDstY[ x ] = ( piRefY[ x ] << uiRShift ) - uiOffset; |
---|
1451 | } |
---|
1452 | } |
---|
1453 | |
---|
1454 | #if LGE_ILLUCOMP_DEPTH_C0046 |
---|
1455 | if(bICFlag) |
---|
1456 | { |
---|
1457 | Int a, b, iShift; |
---|
1458 | TComMv tTmpMV(pcMv->getHor()<<2, pcMv->getVer()<<2); |
---|
1459 | |
---|
1460 | piRefY = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset; |
---|
1461 | piDstY = rpcYuv->getLumaAddr( uiPartAddr ); |
---|
1462 | |
---|
1463 | xGetLLSICPrediction(pcCU, &tTmpMV, pcPicYuvRef, a, b, iShift); |
---|
1464 | |
---|
1465 | for( Int y = 0; y < iHeight; y++, piDstY += iDstStride, piRefY += iRefStride ) |
---|
1466 | { |
---|
1467 | for( Int x = 0; x < iWidth; x++ ) |
---|
1468 | { |
---|
1469 | if(uiOffset) |
---|
1470 | { |
---|
1471 | Int iIFshift = IF_INTERNAL_PREC - ( g_uiBitDepth + g_uiBitIncrement ); |
---|
1472 | piDstY[ x ] = ( (a*piDstY[ x ]+a*IF_INTERNAL_OFFS) >> iShift ) + b*(1<<iIFshift) - IF_INTERNAL_OFFS; |
---|
1473 | } |
---|
1474 | else |
---|
1475 | piDstY[ x ] = Clip( ( (a*piDstY[ x ]) >> iShift ) + b ); |
---|
1476 | } |
---|
1477 | } |
---|
1478 | } |
---|
1479 | #endif |
---|
1480 | } |
---|
1481 | |
---|
1482 | |
---|
1483 | /** |
---|
1484 | * \brief Generate motion-compensated luma block |
---|
1485 | * |
---|
1486 | * \param cu Pointer to current CU |
---|
1487 | * \param refPic Pointer to reference picture |
---|
1488 | * \param partAddr Address of block within CU |
---|
1489 | * \param mv Motion vector |
---|
1490 | * \param width Width of block |
---|
1491 | * \param height Height of block |
---|
1492 | * \param dstPic Pointer to destination picture |
---|
1493 | * \param bi Flag indicating whether bipred is used |
---|
1494 | */ |
---|
1495 | #if LGE_ILLUCOMP_B0045 |
---|
1496 | Void TComPrediction::xPredInterLumaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi, Bool bICFlag |
---|
1497 | #if QC_ARP_D0177 |
---|
1498 | , |
---|
1499 | Int filterType |
---|
1500 | #endif |
---|
1501 | ) |
---|
1502 | #else |
---|
1503 | Void TComPrediction::xPredInterLumaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi |
---|
1504 | #if QC_ARP_D0177 |
---|
1505 | , |
---|
1506 | Int filterType |
---|
1507 | #endif |
---|
1508 | ) |
---|
1509 | #endif |
---|
1510 | { |
---|
1511 | Int refStride = refPic->getStride(); |
---|
1512 | Int refOffset = ( mv->getHor() >> 2 ) + ( mv->getVer() >> 2 ) * refStride; |
---|
1513 | Pel *ref = refPic->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset; |
---|
1514 | |
---|
1515 | Int dstStride = dstPic->getStride(); |
---|
1516 | Pel *dst = dstPic->getLumaAddr( partAddr ); |
---|
1517 | |
---|
1518 | Int xFrac = mv->getHor() & 0x3; |
---|
1519 | Int yFrac = mv->getVer() & 0x3; |
---|
1520 | |
---|
1521 | #if HHI_FULL_PEL_DEPTH_MAP_MV_ACC |
---|
1522 | assert( ! cu->getSlice()->getIsDepth() || ( xFrac == 0 && yFrac == 0 ) ); |
---|
1523 | #endif |
---|
1524 | |
---|
1525 | if ( yFrac == 0 ) |
---|
1526 | { |
---|
1527 | m_if.filterHorLuma( ref, refStride, dst, dstStride, width, height, xFrac, !bi |
---|
1528 | #if QC_ARP_D0177 |
---|
1529 | , |
---|
1530 | filterType |
---|
1531 | #endif |
---|
1532 | ); |
---|
1533 | } |
---|
1534 | else if ( xFrac == 0 ) |
---|
1535 | { |
---|
1536 | m_if.filterVerLuma( ref, refStride, dst, dstStride, width, height, yFrac, true, !bi |
---|
1537 | #if QC_ARP_D0177 |
---|
1538 | , |
---|
1539 | filterType |
---|
1540 | #endif |
---|
1541 | ); |
---|
1542 | } |
---|
1543 | else |
---|
1544 | { |
---|
1545 | Int tmpStride = m_filteredBlockTmp[0].getStride(); |
---|
1546 | Short *tmp = m_filteredBlockTmp[0].getLumaAddr(); |
---|
1547 | |
---|
1548 | Int filterSize = NTAPS_LUMA; |
---|
1549 | Int halfFilterSize = ( filterSize >> 1 ); |
---|
1550 | |
---|
1551 | m_if.filterHorLuma(ref - (halfFilterSize-1)*refStride, refStride, tmp, tmpStride, width, height+filterSize-1, xFrac, false |
---|
1552 | #if QC_ARP_D0177 |
---|
1553 | , |
---|
1554 | filterType |
---|
1555 | #endif |
---|
1556 | ); |
---|
1557 | m_if.filterVerLuma(tmp + (halfFilterSize-1)*tmpStride, tmpStride, dst, dstStride, width, height, yFrac, false, !bi |
---|
1558 | #if QC_ARP_D0177 |
---|
1559 | , |
---|
1560 | filterType |
---|
1561 | #endif |
---|
1562 | ); |
---|
1563 | } |
---|
1564 | |
---|
1565 | #if LGE_ILLUCOMP_B0045 |
---|
1566 | if(bICFlag) |
---|
1567 | { |
---|
1568 | Int a, b, iShift, i, j; |
---|
1569 | |
---|
1570 | xGetLLSICPrediction(cu, mv, refPic, a, b, iShift); |
---|
1571 | |
---|
1572 | for (i = 0; i < height; i++) |
---|
1573 | { |
---|
1574 | for (j = 0; j < width; j++) |
---|
1575 | { |
---|
1576 | if(bi) |
---|
1577 | { |
---|
1578 | Int iIFshift = IF_INTERNAL_PREC - ( g_uiBitDepth + g_uiBitIncrement ); |
---|
1579 | dst[j] = ( (a*dst[j]+a*IF_INTERNAL_OFFS) >> iShift ) + b*(1<<iIFshift) - IF_INTERNAL_OFFS; |
---|
1580 | } |
---|
1581 | else |
---|
1582 | dst[j] = Clip( ( (a*dst[j]) >> iShift ) + b ); |
---|
1583 | } |
---|
1584 | dst += dstStride; |
---|
1585 | } |
---|
1586 | } |
---|
1587 | #endif |
---|
1588 | } |
---|
1589 | |
---|
1590 | /** |
---|
1591 | * \brief Generate motion-compensated chroma block |
---|
1592 | * |
---|
1593 | * \param cu Pointer to current CU |
---|
1594 | * \param refPic Pointer to reference picture |
---|
1595 | * \param partAddr Address of block within CU |
---|
1596 | * \param mv Motion vector |
---|
1597 | * \param width Width of block |
---|
1598 | * \param height Height of block |
---|
1599 | * \param dstPic Pointer to destination picture |
---|
1600 | * \param bi Flag indicating whether bipred is used |
---|
1601 | */ |
---|
1602 | #if LGE_ILLUCOMP_B0045 |
---|
1603 | Void TComPrediction::xPredInterChromaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi, Bool bICFlag |
---|
1604 | #if QC_ARP_D0177 |
---|
1605 | , |
---|
1606 | Int filterType |
---|
1607 | #endif |
---|
1608 | ) |
---|
1609 | #else |
---|
1610 | Void TComPrediction::xPredInterChromaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi |
---|
1611 | #if QC_ARP_D0177 |
---|
1612 | , Int filterType |
---|
1613 | #endif |
---|
1614 | ) |
---|
1615 | #endif |
---|
1616 | { |
---|
1617 | Int refStride = refPic->getCStride(); |
---|
1618 | Int dstStride = dstPic->getCStride(); |
---|
1619 | |
---|
1620 | Int refOffset = (mv->getHor() >> 3) + (mv->getVer() >> 3) * refStride; |
---|
1621 | |
---|
1622 | Pel* refCb = refPic->getCbAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset; |
---|
1623 | Pel* refCr = refPic->getCrAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset; |
---|
1624 | |
---|
1625 | Pel* dstCb = dstPic->getCbAddr( partAddr ); |
---|
1626 | Pel* dstCr = dstPic->getCrAddr( partAddr ); |
---|
1627 | |
---|
1628 | Int xFrac = mv->getHor() & 0x7; |
---|
1629 | Int yFrac = mv->getVer() & 0x7; |
---|
1630 | UInt cxWidth = width >> 1; |
---|
1631 | UInt cxHeight = height >> 1; |
---|
1632 | |
---|
1633 | Int extStride = m_filteredBlockTmp[0].getStride(); |
---|
1634 | Short* extY = m_filteredBlockTmp[0].getLumaAddr(); |
---|
1635 | |
---|
1636 | Int filterSize = NTAPS_CHROMA; |
---|
1637 | |
---|
1638 | Int halfFilterSize = (filterSize>>1); |
---|
1639 | |
---|
1640 | if ( yFrac == 0 ) |
---|
1641 | { |
---|
1642 | m_if.filterHorChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, xFrac, !bi |
---|
1643 | #if QC_ARP_D0177 |
---|
1644 | , |
---|
1645 | filterType |
---|
1646 | #endif |
---|
1647 | ); |
---|
1648 | m_if.filterHorChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, xFrac, !bi |
---|
1649 | #if QC_ARP_D0177 |
---|
1650 | , |
---|
1651 | filterType |
---|
1652 | #endif |
---|
1653 | ); |
---|
1654 | } |
---|
1655 | else if ( xFrac == 0 ) |
---|
1656 | { |
---|
1657 | m_if.filterVerChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, true, !bi |
---|
1658 | #if QC_ARP_D0177 |
---|
1659 | , |
---|
1660 | filterType |
---|
1661 | #endif |
---|
1662 | ); |
---|
1663 | m_if.filterVerChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, true, !bi |
---|
1664 | #if QC_ARP_D0177 |
---|
1665 | , |
---|
1666 | filterType |
---|
1667 | #endif |
---|
1668 | ); |
---|
1669 | } |
---|
1670 | else |
---|
1671 | { |
---|
1672 | m_if.filterHorChroma(refCb - (halfFilterSize-1)*refStride, refStride, extY, extStride, cxWidth, cxHeight+filterSize-1, xFrac, false |
---|
1673 | #if QC_ARP_D0177 |
---|
1674 | , |
---|
1675 | filterType |
---|
1676 | #endif |
---|
1677 | ); |
---|
1678 | m_if.filterVerChroma(extY + (halfFilterSize-1)*extStride, extStride, dstCb, dstStride, cxWidth, cxHeight , yFrac, false, !bi |
---|
1679 | #if QC_ARP_D0177 |
---|
1680 | , |
---|
1681 | filterType |
---|
1682 | #endif |
---|
1683 | ); |
---|
1684 | |
---|
1685 | m_if.filterHorChroma(refCr - (halfFilterSize-1)*refStride, refStride, extY, extStride, cxWidth, cxHeight+filterSize-1, xFrac, false |
---|
1686 | #if QC_ARP_D0177 |
---|
1687 | , |
---|
1688 | filterType |
---|
1689 | #endif |
---|
1690 | ); |
---|
1691 | m_if.filterVerChroma(extY + (halfFilterSize-1)*extStride, extStride, dstCr, dstStride, cxWidth, cxHeight , yFrac, false, !bi |
---|
1692 | #if QC_ARP_D0177 |
---|
1693 | , |
---|
1694 | filterType |
---|
1695 | #endif |
---|
1696 | ); |
---|
1697 | } |
---|
1698 | #if LGE_ILLUCOMP_B0045 |
---|
1699 | if(bICFlag) |
---|
1700 | { |
---|
1701 | Int a, b, iShift, i, j; |
---|
1702 | xGetLLSICPredictionChroma(cu, mv, refPic, a, b, iShift, 0); // Cb |
---|
1703 | for (i = 0; i < cxHeight; i++) |
---|
1704 | { |
---|
1705 | for (j = 0; j < cxWidth; j++) |
---|
1706 | { |
---|
1707 | if(bi) |
---|
1708 | { |
---|
1709 | Int iIFshift = IF_INTERNAL_PREC - ( g_uiBitDepth + g_uiBitIncrement ); |
---|
1710 | dstCb[j] = ( (a*dstCb[j]+a*IF_INTERNAL_OFFS) >> iShift ) + b*(1<<iIFshift) - IF_INTERNAL_OFFS; |
---|
1711 | } |
---|
1712 | else |
---|
1713 | dstCb[j] = Clip3(0, 255, ((a*dstCb[j])>>iShift)+b); |
---|
1714 | } |
---|
1715 | dstCb += dstStride; |
---|
1716 | } |
---|
1717 | |
---|
1718 | xGetLLSICPredictionChroma(cu, mv, refPic, a, b, iShift, 1); // Cr |
---|
1719 | for (i = 0; i < cxHeight; i++) |
---|
1720 | { |
---|
1721 | for (j = 0; j < cxWidth; j++) |
---|
1722 | { |
---|
1723 | if(bi) |
---|
1724 | { |
---|
1725 | Int iIFshift = IF_INTERNAL_PREC - ( g_uiBitDepth + g_uiBitIncrement ); |
---|
1726 | dstCr[j] = ( (a*dstCr[j]+a*IF_INTERNAL_OFFS) >> iShift ) + b*(1<<iIFshift) - IF_INTERNAL_OFFS; |
---|
1727 | } |
---|
1728 | else |
---|
1729 | dstCr[j] = Clip3(0, 255, ((a*dstCr[j])>>iShift)+b); |
---|
1730 | } |
---|
1731 | dstCr += dstStride; |
---|
1732 | } |
---|
1733 | } |
---|
1734 | #endif |
---|
1735 | } |
---|
1736 | |
---|
1737 | #if MERL_VSP_C0152 |
---|
1738 | // Input: |
---|
1739 | // refPic: Ref picture. Full picture, with padding |
---|
1740 | // posX, posY: PU position, texture |
---|
1741 | // sizeX, sizeY: PU size |
---|
1742 | // partAddr: z-order index |
---|
1743 | // mv: disparity vector. derived from neighboring blocks |
---|
1744 | // |
---|
1745 | // Output: dstPic, PU predictor 64x64 |
---|
1746 | Void TComPrediction::xPredInterLumaBlkFromDM( TComPicYuv *refPic, TComPicYuv *pPicBaseDepth, Int* pShiftLUT, Int iShiftPrec, TComMv* mv, UInt partAddr,Int posX, Int posY, Int sizeX, Int sizeY, Bool isDepth |
---|
1747 | #if !MERL_Bi_VSP_D0166 |
---|
1748 | , Int vspIdx |
---|
1749 | #endif |
---|
1750 | , TComYuv *&dstPic |
---|
1751 | #if MERL_Bi_VSP_D0166 |
---|
1752 | , Bool bi |
---|
1753 | #endif |
---|
1754 | ) |
---|
1755 | { |
---|
1756 | Int widthLuma; |
---|
1757 | Int heightLuma; |
---|
1758 | |
---|
1759 | if (isDepth) |
---|
1760 | { |
---|
1761 | widthLuma = pPicBaseDepth->getWidth(); |
---|
1762 | heightLuma = pPicBaseDepth->getHeight(); |
---|
1763 | } |
---|
1764 | else |
---|
1765 | { |
---|
1766 | widthLuma = refPic->getWidth(); |
---|
1767 | heightLuma = refPic->getHeight(); |
---|
1768 | } |
---|
1769 | |
---|
1770 | #if MERL_VSP_BLOCKSIZE_C0152 != 1 |
---|
1771 | Int widthDepth = pPicBaseDepth->getWidth(); |
---|
1772 | Int heightDepth = pPicBaseDepth->getHeight(); |
---|
1773 | #endif |
---|
1774 | |
---|
1775 | #if MERL_CVSP_D0165 |
---|
1776 | Int widthDepth = pPicBaseDepth->getWidth(); |
---|
1777 | Int heightDepth = pPicBaseDepth->getHeight(); |
---|
1778 | #endif |
---|
1779 | |
---|
1780 | Int nTxtPerDepthX = widthLuma / ( pPicBaseDepth->getWidth() ); // texture pixel # per depth pixel |
---|
1781 | Int nTxtPerDepthY = heightLuma / ( pPicBaseDepth->getHeight() ); |
---|
1782 | |
---|
1783 | Int refStride = refPic->getStride(); |
---|
1784 | Int dstStride = dstPic->getStride(); |
---|
1785 | Int depStride = pPicBaseDepth->getStride(); |
---|
1786 | Int depthPosX = Clip3(0, widthLuma - sizeX, (posX/nTxtPerDepthX) + (mv->getHor()>>2)); |
---|
1787 | Int depthPosY = Clip3(0, heightLuma- sizeY, (posY/nTxtPerDepthY) + (mv->getVer()>>2)); |
---|
1788 | Pel *ref = refPic->getLumaAddr() + posX + posY * refStride; |
---|
1789 | Pel *dst = dstPic->getLumaAddr(partAddr); |
---|
1790 | Pel *depth = pPicBaseDepth->getLumaAddr() + depthPosX + depthPosY * depStride; |
---|
1791 | |
---|
1792 | #if MERL_VSP_BLOCKSIZE_C0152 != 1 |
---|
1793 | #if MERL_VSP_BLOCKSIZE_C0152 == 2 |
---|
1794 | Int dW = sizeX>>1; |
---|
1795 | Int dH = sizeY>>1; |
---|
1796 | #endif |
---|
1797 | #if MERL_VSP_BLOCKSIZE_C0152 == 4 |
---|
1798 | Int dW = sizeX>>2; |
---|
1799 | Int dH = sizeY>>2; |
---|
1800 | #endif |
---|
1801 | { |
---|
1802 | Pel* depthi = depth; |
---|
1803 | for (Int j = 0; j < dH; j++) |
---|
1804 | { |
---|
1805 | for (Int i = 0; i < dW; i++) |
---|
1806 | { |
---|
1807 | Pel* depthTmp; |
---|
1808 | #if MERL_VSP_BLOCKSIZE_C0152 == 2 |
---|
1809 | if (depthPosX + (i<<1) < widthDepth) |
---|
1810 | depthTmp = depthi + (i << 1); |
---|
1811 | else |
---|
1812 | depthTmp = depthi + (widthDepth - depthPosX - 1); |
---|
1813 | #endif |
---|
1814 | #if MERL_VSP_BLOCKSIZE_C0152 == 4 |
---|
1815 | if (depthPosX + (i<<2) < widthDepth) |
---|
1816 | depthTmp = depthi + (i << 2); |
---|
1817 | else |
---|
1818 | depthTmp = depthi + (widthDepth - depthPosX - 1); |
---|
1819 | #endif |
---|
1820 | Int maxV = 0; |
---|
1821 | #if MTK_DEPTH_TO_DISP_D0138 |
---|
1822 | for (Int blockj = 0; blockj < MERL_VSP_BLOCKSIZE_C0152; blockj+=(MERL_VSP_BLOCKSIZE_C0152-1)) |
---|
1823 | #else |
---|
1824 | for (Int blockj = 0; blockj < MERL_VSP_BLOCKSIZE_C0152; blockj++) |
---|
1825 | #endif |
---|
1826 | { |
---|
1827 | Int iX = 0; |
---|
1828 | #if MTK_DEPTH_TO_DISP_D0138 |
---|
1829 | for (Int blocki = 0; blocki < MERL_VSP_BLOCKSIZE_C0152; blocki+=(MERL_VSP_BLOCKSIZE_C0152-1)) |
---|
1830 | #else |
---|
1831 | for (Int blocki = 0; blocki < MERL_VSP_BLOCKSIZE_C0152; blocki++) |
---|
1832 | #endif |
---|
1833 | { |
---|
1834 | if (maxV < depthTmp[iX]) |
---|
1835 | maxV = depthTmp[iX]; |
---|
1836 | #if MERL_VSP_BLOCKSIZE_C0152 == 2 |
---|
1837 | if (depthPosX + (i<<1) + blocki < widthDepth - 1) |
---|
1838 | #else // MERL_VSP_BLOCKSIZE_C0152 == 4 |
---|
1839 | if (depthPosX + (i<<2) + blocki < widthDepth - 1) |
---|
1840 | #endif |
---|
1841 | iX++; |
---|
1842 | } |
---|
1843 | #if MERL_VSP_BLOCKSIZE_C0152 == 2 |
---|
1844 | if (depthPosY + (j<<1) + blockj < heightDepth - 1) |
---|
1845 | #else // MERL_VSP_BLOCKSIZE_C0152 == 4 |
---|
1846 | if (depthPosY + (j<<2) + blockj < heightDepth - 1) |
---|
1847 | #endif |
---|
1848 | depthTmp += depStride; |
---|
1849 | } |
---|
1850 | m_pDepth[i+j*dW] = maxV; |
---|
1851 | } // end of i < dW |
---|
1852 | #if MERL_VSP_BLOCKSIZE_C0152 == 2 |
---|
1853 | if (depthPosY + ((j+1)<<1) < heightDepth) |
---|
1854 | depthi += (depStride << 1); |
---|
1855 | else |
---|
1856 | depthi = depth + (heightDepth-depthPosY-1)*depStride; |
---|
1857 | #endif |
---|
1858 | #if MERL_VSP_BLOCKSIZE_C0152 == 4 |
---|
1859 | if (depthPosY + ((j+1)<<2) < heightDepth) // heightDepth-1 |
---|
1860 | depthi += (depStride << 2); |
---|
1861 | else |
---|
1862 | depthi = depth + (heightDepth-depthPosY-1)*depStride; // the last line |
---|
1863 | #endif |
---|
1864 | } |
---|
1865 | } |
---|
1866 | #endif |
---|
1867 | |
---|
1868 | #if MERL_General_Fix |
---|
1869 | #if MERL_VSP_BLOCKSIZE_C0152 == 1 |
---|
1870 | #if MERL_CVSP_D0165 |
---|
1871 | //get LUT based horizontal reference range |
---|
1872 | Int range = 0; |
---|
1873 | if( sizeX == 4 && sizeY == 8 ) |
---|
1874 | range = m_iRangeLuma[0]; |
---|
1875 | else if( sizeX == 8 && sizeY == 4 ) |
---|
1876 | range = m_iRangeLuma[1]; |
---|
1877 | else if( sizeX == 8 && sizeY == 8 ) |
---|
1878 | range = m_iRangeLuma[2]; |
---|
1879 | else if( sizeX == 8 && sizeY == 16 ) |
---|
1880 | range = m_iRangeLuma[3]; |
---|
1881 | else if( sizeX == 16 && sizeY == 8 ) |
---|
1882 | range = m_iRangeLuma[4]; |
---|
1883 | else if( sizeX == 16 && sizeY == 16 ) |
---|
1884 | range = m_iRangeLuma[5]; |
---|
1885 | else if( sizeX == 16 && sizeY == 32 ) |
---|
1886 | range = m_iRangeLuma[6]; |
---|
1887 | else if( sizeX == 32 && sizeY == 16 ) |
---|
1888 | range = m_iRangeLuma[7]; |
---|
1889 | else if( sizeX == 32 && sizeY == 32 ) |
---|
1890 | range = m_iRangeLuma[8]; |
---|
1891 | else if( sizeX == 32 && sizeY == 64 ) |
---|
1892 | range = m_iRangeLuma[9]; |
---|
1893 | else if( sizeX == 64 && sizeY == 32 ) |
---|
1894 | range = m_iRangeLuma[10]; |
---|
1895 | else if( sizeX == 64 && sizeY == 64 ) |
---|
1896 | range = m_iRangeLuma[11]; |
---|
1897 | else |
---|
1898 | assert(0); |
---|
1899 | |
---|
1900 | // The minimum depth value |
---|
1901 | Int minRelativePos = 5000; |
---|
1902 | Int maxRelativePos = -5000; |
---|
1903 | |
---|
1904 | Pel* depthTemp, *depthInitial=depth; |
---|
1905 | for (Int yTxt =0; yTxt<sizeY; yTxt++) |
---|
1906 | { |
---|
1907 | for (Int xTxt =0; xTxt<sizeX; xTxt++) |
---|
1908 | { |
---|
1909 | if (depthPosX+xTxt < widthDepth) |
---|
1910 | depthTemp = depthInitial + xTxt; |
---|
1911 | else |
---|
1912 | depthTemp = depthInitial + (widthDepth - depthPosX - 1); |
---|
1913 | |
---|
1914 | Int disparity = pShiftLUT[ *depthTemp ] << iShiftPrec; |
---|
1915 | Int disparityInt = disparity >> 2; |
---|
1916 | |
---|
1917 | if( disparity <= 0) |
---|
1918 | { |
---|
1919 | if (minRelativePos > disparityInt+xTxt) |
---|
1920 | minRelativePos = disparityInt+xTxt; |
---|
1921 | } |
---|
1922 | else |
---|
1923 | { |
---|
1924 | if (maxRelativePos < disparityInt+xTxt) |
---|
1925 | maxRelativePos = disparityInt+xTxt; |
---|
1926 | } |
---|
1927 | } |
---|
1928 | if (depthPosY+yTxt < heightDepth) |
---|
1929 | depthInitial = depthInitial + depStride; |
---|
1930 | } |
---|
1931 | |
---|
1932 | Int disparity_tmp = pShiftLUT[ *depth ] << iShiftPrec; |
---|
1933 | if (disparity_tmp <= 0) |
---|
1934 | maxRelativePos = minRelativePos + range -1 ; |
---|
1935 | else |
---|
1936 | minRelativePos = maxRelativePos - range +1 ; |
---|
1937 | #endif |
---|
1938 | #endif |
---|
1939 | #endif |
---|
1940 | |
---|
1941 | #if MERL_VSP_BLOCKSIZE_C0152 != 1 |
---|
1942 | Int yDepth = 0; |
---|
1943 | #endif |
---|
1944 | for ( Int yTxt = 0; yTxt < sizeY; yTxt += nTxtPerDepthY ) |
---|
1945 | { |
---|
1946 | for ( Int xTxt = 0, xDepth = 0; xTxt < sizeX; xTxt += nTxtPerDepthX, xDepth++ ) |
---|
1947 | { |
---|
1948 | Pel repDepth = 0; // to store the depth value used for warping |
---|
1949 | #if MERL_VSP_BLOCKSIZE_C0152 == 1 |
---|
1950 | repDepth = depth[xDepth]; |
---|
1951 | #endif |
---|
1952 | #if MERL_VSP_BLOCKSIZE_C0152 == 2 |
---|
1953 | repDepth = m_pDepth[(xTxt>>1) + (yTxt>>1)*dW]; |
---|
1954 | #endif |
---|
1955 | #if MERL_VSP_BLOCKSIZE_C0152 == 4 |
---|
1956 | repDepth = m_pDepth[(xTxt>>2) + (yTxt>>2)*dW]; |
---|
1957 | #endif |
---|
1958 | |
---|
1959 | assert( repDepth >= 0 && repDepth <= 255 ); |
---|
1960 | Int disparity = pShiftLUT[ repDepth ] << iShiftPrec; |
---|
1961 | Int refOffset = xTxt + (disparity >> 2); |
---|
1962 | Int xFrac = disparity & 0x3; |
---|
1963 | #if MERL_CVSP_D0165 |
---|
1964 | if(refOffset<minRelativePos || refOffset>maxRelativePos) |
---|
1965 | xFrac = 0; |
---|
1966 | refOffset = Clip3(minRelativePos, maxRelativePos, refOffset); |
---|
1967 | #endif |
---|
1968 | Int absX = posX + refOffset; |
---|
1969 | |
---|
1970 | if (xFrac == 0) |
---|
1971 | absX = Clip3(0, widthLuma-1, absX); |
---|
1972 | else |
---|
1973 | absX = Clip3(4, widthLuma-5, absX); |
---|
1974 | |
---|
1975 | refOffset = absX - posX; |
---|
1976 | |
---|
1977 | assert( ref[refOffset] >= 0 && ref[refOffset]<= 255 ); |
---|
1978 | #if MERL_Bi_VSP_D0166 |
---|
1979 | m_if.filterHorLuma( &ref[refOffset], refStride, &dst[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !bi ); |
---|
1980 | #else |
---|
1981 | m_if.filterHorLuma( &ref[refOffset], refStride, &dst[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, true ); |
---|
1982 | #endif |
---|
1983 | |
---|
1984 | } |
---|
1985 | ref += refStride*nTxtPerDepthY; |
---|
1986 | dst += dstStride*nTxtPerDepthY; |
---|
1987 | depth += depStride; |
---|
1988 | #if MERL_VSP_BLOCKSIZE_C0152 != 1 |
---|
1989 | yDepth++; |
---|
1990 | #endif |
---|
1991 | |
---|
1992 | } |
---|
1993 | } |
---|
1994 | |
---|
1995 | Void TComPrediction::xPredInterChromaBlkFromDM ( TComPicYuv *refPic, TComPicYuv *pPicBaseDepth, Int* pShiftLUT, Int iShiftPrec, TComMv*mv, UInt partAddr, Int posX, Int posY, Int sizeX, Int sizeY, Bool isDepth |
---|
1996 | #if !MERL_Bi_VSP_D0166 |
---|
1997 | , Int vspIdx |
---|
1998 | #endif |
---|
1999 | , TComYuv *&dstPic |
---|
2000 | #if MERL_Bi_VSP_D0166 |
---|
2001 | , Bool bi |
---|
2002 | #endif |
---|
2003 | ) |
---|
2004 | { |
---|
2005 | Int refStride = refPic->getCStride(); |
---|
2006 | Int dstStride = dstPic->getCStride(); |
---|
2007 | Int depStride = pPicBaseDepth->getStride(); |
---|
2008 | |
---|
2009 | Int widthChroma, heightChroma; |
---|
2010 | if( isDepth) |
---|
2011 | { |
---|
2012 | widthChroma = pPicBaseDepth->getWidth()>>1; |
---|
2013 | heightChroma = pPicBaseDepth->getHeight()>>1; |
---|
2014 | } |
---|
2015 | else |
---|
2016 | { |
---|
2017 | widthChroma = refPic->getWidth()>>1; |
---|
2018 | heightChroma = refPic->getHeight()>>1; |
---|
2019 | } |
---|
2020 | |
---|
2021 | // Below is only for Texture chroma component |
---|
2022 | |
---|
2023 | Int widthDepth = pPicBaseDepth->getWidth(); |
---|
2024 | Int heightDepth = pPicBaseDepth->getHeight(); |
---|
2025 | |
---|
2026 | Int nTxtPerDepthX, nTxtPerDepthY; // Number of texture samples per one depth sample |
---|
2027 | Int nDepthPerTxtX, nDepthPerTxtY; // Number of depth samples per one texture sample |
---|
2028 | |
---|
2029 | Int depthPosX; // Starting position in depth image |
---|
2030 | Int depthPosY; |
---|
2031 | |
---|
2032 | if ( widthChroma > widthDepth ) |
---|
2033 | { |
---|
2034 | nTxtPerDepthX = widthChroma / widthDepth; |
---|
2035 | nDepthPerTxtX = 1; |
---|
2036 | depthPosX = posX / nTxtPerDepthX + (mv->getHor()>>2); //mv denotes the disparity for VSP |
---|
2037 | } |
---|
2038 | else |
---|
2039 | { |
---|
2040 | nTxtPerDepthX = 1; |
---|
2041 | nDepthPerTxtX = widthDepth / widthChroma; |
---|
2042 | depthPosX = posX * nDepthPerTxtX + (mv->getHor()>>2); //mv denotes the disparity for VSP |
---|
2043 | } |
---|
2044 | depthPosX = Clip3(0, widthDepth - (sizeX<<1), depthPosX); |
---|
2045 | if ( heightChroma > heightDepth ) |
---|
2046 | { |
---|
2047 | nTxtPerDepthY = heightChroma / heightDepth; |
---|
2048 | nDepthPerTxtY = 1; |
---|
2049 | depthPosY = posY / nTxtPerDepthY + (mv->getVer()>>2); //mv denotes the disparity for VSP |
---|
2050 | } |
---|
2051 | else |
---|
2052 | { |
---|
2053 | nTxtPerDepthY = 1; |
---|
2054 | nDepthPerTxtY = heightDepth / heightChroma; |
---|
2055 | depthPosY = posY * nDepthPerTxtY + (mv->getVer()>>2); //mv denotes the disparity for VSP |
---|
2056 | } |
---|
2057 | depthPosY = Clip3(0, heightDepth - (sizeY<<1), depthPosY); |
---|
2058 | |
---|
2059 | Pel *refCb = refPic->getCbAddr() + posX + posY * refStride; |
---|
2060 | Pel *refCr = refPic->getCrAddr() + posX + posY * refStride; |
---|
2061 | Pel *dstCb = dstPic->getCbAddr(partAddr); |
---|
2062 | Pel *dstCr = dstPic->getCrAddr(partAddr); |
---|
2063 | Pel *depth = pPicBaseDepth->getLumaAddr() + depthPosX + depthPosY * depStride; // move the pointer to the current depth pixel position |
---|
2064 | |
---|
2065 | Int refStrideBlock = refStride * nTxtPerDepthY; |
---|
2066 | Int dstStrideBlock = dstStride * nTxtPerDepthY; |
---|
2067 | Int depStrideBlock = depStride * nDepthPerTxtY; |
---|
2068 | |
---|
2069 | #if !MERL_Bi_VSP_D0166 |
---|
2070 | if (isDepth) |
---|
2071 | { |
---|
2072 | // DT: Since the call for this function is redundant, .. |
---|
2073 | for (Int y = 0; y < sizeY; y++) |
---|
2074 | { |
---|
2075 | for (Int x = 0; x < sizeX; x++) |
---|
2076 | { |
---|
2077 | dstCb[x] = 128; |
---|
2078 | dstCr[x] = 128; |
---|
2079 | } |
---|
2080 | dstCb += dstStride; |
---|
2081 | dstCr += dstStride; |
---|
2082 | } |
---|
2083 | return; |
---|
2084 | } |
---|
2085 | #endif |
---|
2086 | |
---|
2087 | if ( widthChroma > widthDepth ) // We assume |
---|
2088 | { |
---|
2089 | assert( heightChroma > heightDepth ); |
---|
2090 | printf("This branch should never been reached.\n"); |
---|
2091 | exit(0); |
---|
2092 | } |
---|
2093 | else |
---|
2094 | { |
---|
2095 | #if MERL_VSP_BLOCKSIZE_C0152 == 1 |
---|
2096 | Int dW = sizeX; |
---|
2097 | Int dH = sizeY; |
---|
2098 | Int sW = 2; // search window size |
---|
2099 | Int sH = 2; |
---|
2100 | #endif |
---|
2101 | #if MERL_VSP_BLOCKSIZE_C0152 == 2 |
---|
2102 | Int dW = sizeX; |
---|
2103 | Int dH = sizeY; |
---|
2104 | Int sW = 2; // search window size |
---|
2105 | Int sH = 2; |
---|
2106 | #endif |
---|
2107 | #if MERL_VSP_BLOCKSIZE_C0152 == 4 |
---|
2108 | Int dW = sizeX>>1; |
---|
2109 | Int dH = sizeY>>1; |
---|
2110 | Int sW = 4; // search window size |
---|
2111 | Int sH = 4; |
---|
2112 | #endif |
---|
2113 | |
---|
2114 | { |
---|
2115 | Pel* depthi = depth; |
---|
2116 | for (Int j = 0; j < dH; j++) |
---|
2117 | { |
---|
2118 | for (Int i = 0; i < dW; i++) |
---|
2119 | { |
---|
2120 | Pel* depthTmp; |
---|
2121 | #if MERL_VSP_BLOCKSIZE_C0152 == 1 |
---|
2122 | depthTmp = depthi + (i << 1); |
---|
2123 | #endif |
---|
2124 | #if MERL_VSP_BLOCKSIZE_C0152 == 2 |
---|
2125 | if (depthPosX + (i<<1) < widthDepth) |
---|
2126 | depthTmp = depthi + (i << 1); |
---|
2127 | else |
---|
2128 | depthTmp = depthi + (widthDepth - depthPosX - 1); |
---|
2129 | #endif |
---|
2130 | #if MERL_VSP_BLOCKSIZE_C0152 == 4 |
---|
2131 | if (depthPosX + (i<<2) < widthDepth) |
---|
2132 | depthTmp = depthi + (i << 2); |
---|
2133 | else |
---|
2134 | depthTmp = depthi + (widthDepth - depthPosX - 1); |
---|
2135 | #endif |
---|
2136 | Int maxV = 0; |
---|
2137 | for (Int blockj = 0; blockj < sH; blockj++) |
---|
2138 | { |
---|
2139 | Int iX = 0; |
---|
2140 | for (Int blocki = 0; blocki < sW; blocki++) |
---|
2141 | { |
---|
2142 | if (maxV < depthTmp[iX]) |
---|
2143 | maxV = depthTmp[iX]; |
---|
2144 | if (depthPosX + i*sW + blocki < widthDepth - 1) |
---|
2145 | iX++; |
---|
2146 | } |
---|
2147 | if (depthPosY + j*sH + blockj < heightDepth - 1) |
---|
2148 | depthTmp += depStride; |
---|
2149 | } |
---|
2150 | m_pDepth[i+j*dW] = maxV; |
---|
2151 | } // end of i < dW |
---|
2152 | #if MERL_VSP_BLOCKSIZE_C0152 == 1 |
---|
2153 | if (depthPosY + ((j+1)<<1) < heightDepth) |
---|
2154 | depthi += (depStride << 1); |
---|
2155 | else |
---|
2156 | depthi = depth + (heightDepth-1)*depStride; |
---|
2157 | #endif |
---|
2158 | #if MERL_VSP_BLOCKSIZE_C0152 == 2 |
---|
2159 | if (depthPosY + ((j+1)<<1) < heightDepth) |
---|
2160 | depthi += (depStride << 1); |
---|
2161 | else |
---|
2162 | depthi = depth + (heightDepth-depthPosY-1)*depStride; |
---|
2163 | #endif |
---|
2164 | #if MERL_VSP_BLOCKSIZE_C0152 == 4 |
---|
2165 | if (depthPosY + ((j+1)<<2) < heightDepth) // heightDepth-1 |
---|
2166 | depthi += (depStride << 2); |
---|
2167 | else |
---|
2168 | depthi = depth + (heightDepth-depthPosY-1)*depStride; // the last line |
---|
2169 | #endif |
---|
2170 | } |
---|
2171 | } |
---|
2172 | |
---|
2173 | |
---|
2174 | #if MERL_General_Fix |
---|
2175 | #if MERL_VSP_BLOCKSIZE_C0152 == 1 |
---|
2176 | #if MERL_CVSP_D0165 |
---|
2177 | //get LUT based horizontal reference range |
---|
2178 | Int range=0; |
---|
2179 | if( sizeX == 2 && sizeY == 4 ) |
---|
2180 | range = m_iRangeChroma[0]; |
---|
2181 | else if( sizeX == 4 && sizeY == 2 ) |
---|
2182 | range = m_iRangeChroma[1]; |
---|
2183 | else if( sizeX == 4 && sizeY == 4 ) |
---|
2184 | range = m_iRangeChroma[2]; |
---|
2185 | else if( sizeX == 4 && sizeY == 8 ) |
---|
2186 | range = m_iRangeChroma[3]; |
---|
2187 | else if( sizeX == 8 && sizeY == 4 ) |
---|
2188 | range = m_iRangeChroma[4]; |
---|
2189 | else if( sizeX == 8 && sizeY == 8 ) |
---|
2190 | range = m_iRangeChroma[5]; |
---|
2191 | else if( sizeX == 8 && sizeY == 16 ) |
---|
2192 | range = m_iRangeChroma[6]; |
---|
2193 | else if( sizeX == 16 && sizeY == 8 ) |
---|
2194 | range = m_iRangeChroma[7]; |
---|
2195 | else if( sizeX == 16 && sizeY == 16 ) |
---|
2196 | range = m_iRangeChroma[8]; |
---|
2197 | else if( sizeX == 16 && sizeY == 32 ) |
---|
2198 | range = m_iRangeChroma[9]; |
---|
2199 | else if( sizeX == 32 && sizeY == 16 ) |
---|
2200 | range = m_iRangeChroma[10]; |
---|
2201 | else if( sizeX == 32 && sizeY == 32 ) |
---|
2202 | range = m_iRangeChroma[11]; |
---|
2203 | else |
---|
2204 | assert(0); |
---|
2205 | |
---|
2206 | // The minimum depth value |
---|
2207 | Int minRelativePos = 5000; |
---|
2208 | Int maxRelativePos = -5000; |
---|
2209 | |
---|
2210 | Int depthTmp; |
---|
2211 | for (Int yTxt=0; yTxt<sizeY; yTxt++) |
---|
2212 | { |
---|
2213 | for (Int xTxt=0; xTxt<sizeX; xTxt++) |
---|
2214 | { |
---|
2215 | depthTmp = m_pDepth[xTxt+yTxt*dW]; |
---|
2216 | Int disparity = pShiftLUT[ depthTmp ] << iShiftPrec; |
---|
2217 | Int disparityInt = disparity >> 3;//in chroma resolution |
---|
2218 | |
---|
2219 | if (disparityInt < 0) |
---|
2220 | { |
---|
2221 | if (minRelativePos > disparityInt+xTxt) |
---|
2222 | minRelativePos = disparityInt+xTxt; |
---|
2223 | } |
---|
2224 | else |
---|
2225 | { |
---|
2226 | if (maxRelativePos < disparityInt+xTxt) |
---|
2227 | maxRelativePos = disparityInt+xTxt; |
---|
2228 | } |
---|
2229 | } |
---|
2230 | } |
---|
2231 | |
---|
2232 | depthTmp = m_pDepth[0]; |
---|
2233 | Int disparity_tmp = pShiftLUT[ depthTmp ] << iShiftPrec; |
---|
2234 | if ( disparity_tmp < 0 ) |
---|
2235 | maxRelativePos = minRelativePos + range - 1; |
---|
2236 | else |
---|
2237 | minRelativePos = maxRelativePos - range + 1; |
---|
2238 | |
---|
2239 | #endif |
---|
2240 | #endif |
---|
2241 | #endif |
---|
2242 | |
---|
2243 | // (sizeX, sizeY) is Chroma block size |
---|
2244 | for ( Int yTxt = 0, yDepth = 0; yTxt < sizeY; yTxt += nTxtPerDepthY, yDepth += nDepthPerTxtY ) |
---|
2245 | { |
---|
2246 | for ( Int xTxt = 0, xDepth = 0; xTxt < sizeX; xTxt += nTxtPerDepthX, xDepth += nDepthPerTxtX ) |
---|
2247 | { |
---|
2248 | Pel repDepth = 0; // to store the depth value used for warping |
---|
2249 | #if MERL_VSP_BLOCKSIZE_C0152 == 1 |
---|
2250 | repDepth = m_pDepth[(xTxt) + (yTxt)*dW]; |
---|
2251 | #endif |
---|
2252 | #if MERL_VSP_BLOCKSIZE_C0152 == 2 |
---|
2253 | repDepth = m_pDepth[(xTxt) + (yTxt)*dW]; |
---|
2254 | #endif |
---|
2255 | #if MERL_VSP_BLOCKSIZE_C0152 == 4 |
---|
2256 | repDepth = m_pDepth[(xTxt>>1) + (yTxt>>1)*dW]; |
---|
2257 | #endif |
---|
2258 | |
---|
2259 | // calculate the offset in the reference picture |
---|
2260 | Int disparity = pShiftLUT[ repDepth ] << iShiftPrec; |
---|
2261 | Int refOffset = xTxt + (disparity >> 3); // in integer pixel in chroma image |
---|
2262 | Int xFrac = disparity & 0x7; |
---|
2263 | #if MERL_CVSP_D0165 |
---|
2264 | if(refOffset < minRelativePos || refOffset > maxRelativePos) |
---|
2265 | xFrac = 0; |
---|
2266 | refOffset = Clip3(minRelativePos, maxRelativePos, refOffset); |
---|
2267 | #endif |
---|
2268 | Int absX = posX + refOffset; |
---|
2269 | |
---|
2270 | if (xFrac == 0) |
---|
2271 | absX = Clip3(0, widthChroma-1, absX); |
---|
2272 | else |
---|
2273 | absX = Clip3(4, widthChroma-5, absX); |
---|
2274 | |
---|
2275 | refOffset = absX - posX; |
---|
2276 | |
---|
2277 | assert( refCb[refOffset] >= 0 && refCb[refOffset]<= 255 ); |
---|
2278 | assert( refCr[refOffset] >= 0 && refCr[refOffset]<= 255 ); |
---|
2279 | #if MERL_Bi_VSP_D0166 |
---|
2280 | m_if.filterHorChroma(&refCb[refOffset], refStride, &dstCb[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !bi); |
---|
2281 | m_if.filterHorChroma(&refCr[refOffset], refStride, &dstCr[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !bi); |
---|
2282 | #else |
---|
2283 | m_if.filterHorChroma(&refCb[refOffset], refStride, &dstCb[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, true); |
---|
2284 | m_if.filterHorChroma(&refCr[refOffset], refStride, &dstCr[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, true); |
---|
2285 | #endif |
---|
2286 | |
---|
2287 | } |
---|
2288 | refCb += refStrideBlock; |
---|
2289 | refCr += refStrideBlock; |
---|
2290 | dstCb += dstStrideBlock; |
---|
2291 | dstCr += dstStrideBlock; |
---|
2292 | depth += depStrideBlock; |
---|
2293 | } |
---|
2294 | } |
---|
2295 | |
---|
2296 | } |
---|
2297 | |
---|
2298 | #endif // MERL_VSP_C0152 |
---|
2299 | |
---|
2300 | #if DEPTH_MAP_GENERATION |
---|
2301 | Void TComPrediction::xWeightedAveragePdm( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv*& rpcYuvDst, UInt uiSubSampExpX, UInt uiSubSampExpY ) |
---|
2302 | { |
---|
2303 | |
---|
2304 | if( iRefIdx0 >= 0 && iRefIdx1 >= 0 ) |
---|
2305 | { |
---|
2306 | rpcYuvDst->addAvgPdm( pcYuvSrc0, pcYuvSrc1, uiPartIdx, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY ); |
---|
2307 | } |
---|
2308 | else if ( iRefIdx0 >= 0 && iRefIdx1 < 0 ) |
---|
2309 | { |
---|
2310 | pcYuvSrc0->copyPartToPartYuvPdm( rpcYuvDst, uiPartIdx, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY ); |
---|
2311 | } |
---|
2312 | else if ( iRefIdx0 < 0 && iRefIdx1 >= 0 ) |
---|
2313 | { |
---|
2314 | pcYuvSrc1->copyPartToPartYuvPdm( rpcYuvDst, uiPartIdx, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY ); |
---|
2315 | } |
---|
2316 | else |
---|
2317 | { |
---|
2318 | assert (0); |
---|
2319 | } |
---|
2320 | } |
---|
2321 | #endif |
---|
2322 | |
---|
2323 | Void TComPrediction::xWeightedAverage( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv*& rpcYuvDst |
---|
2324 | #if MERL_Bi_VSP_D0166 |
---|
2325 | , Int predDirVSP |
---|
2326 | #endif |
---|
2327 | ) |
---|
2328 | { |
---|
2329 | #if MERL_Bi_VSP_D0166 |
---|
2330 | Bool isVSP = 0; |
---|
2331 | if (pcCU->getVSPIndex(uiPartIdx)!=0)//is VSP |
---|
2332 | { |
---|
2333 | isVSP = 1; |
---|
2334 | } |
---|
2335 | |
---|
2336 | if(( !isVSP && iRefIdx0 >= 0 && iRefIdx1 >= 0 ) || ( isVSP && predDirVSP == 3 )) |
---|
2337 | #else |
---|
2338 | if( iRefIdx0 >= 0 && iRefIdx1 >= 0 ) |
---|
2339 | #endif |
---|
2340 | { |
---|
2341 | rpcYuvDst->addAvg( pcYuvSrc0, pcYuvSrc1, uiPartIdx, iWidth, iHeight ); |
---|
2342 | } |
---|
2343 | #if MERL_Bi_VSP_D0166 |
---|
2344 | else if ( ( !isVSP && iRefIdx0 >= 0 && iRefIdx1 < 0 ) || ( isVSP && predDirVSP == 1)) |
---|
2345 | #else |
---|
2346 | else if ( iRefIdx0 >= 0 && iRefIdx1 < 0 ) |
---|
2347 | #endif |
---|
2348 | { |
---|
2349 | pcYuvSrc0->copyPartToPartYuv( rpcYuvDst, uiPartIdx, iWidth, iHeight ); |
---|
2350 | } |
---|
2351 | #if MERL_Bi_VSP_D0166 |
---|
2352 | else if (( !isVSP && iRefIdx0 < 0 && iRefIdx1 >= 0 ) || ( isVSP && predDirVSP == 2)) |
---|
2353 | #else |
---|
2354 | else if ( iRefIdx0 < 0 && iRefIdx1 >= 0 ) |
---|
2355 | #endif |
---|
2356 | { |
---|
2357 | pcYuvSrc1->copyPartToPartYuv( rpcYuvDst, uiPartIdx, iWidth, iHeight ); |
---|
2358 | } |
---|
2359 | #if MERL_Bi_VSP_D0166 |
---|
2360 | else |
---|
2361 | {//for debug test only |
---|
2362 | assert(0); |
---|
2363 | } |
---|
2364 | #endif |
---|
2365 | } |
---|
2366 | |
---|
2367 | // AMVP |
---|
2368 | Void TComPrediction::getMvPredAMVP( TComDataCU* pcCU, UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMvPred ) |
---|
2369 | { |
---|
2370 | AMVPInfo* pcAMVPInfo = pcCU->getCUMvField(eRefPicList)->getAMVPInfo(); |
---|
2371 | |
---|
2372 | if( pcCU->getAMVPMode(uiPartAddr) == AM_NONE || (pcAMVPInfo->iN <= 1 && pcCU->getAMVPMode(uiPartAddr) == AM_EXPL) ) |
---|
2373 | { |
---|
2374 | rcMvPred = pcAMVPInfo->m_acMvCand[0]; |
---|
2375 | |
---|
2376 | pcCU->setMVPIdxSubParts( 0, eRefPicList, uiPartAddr, uiPartIdx, pcCU->getDepth(uiPartAddr)); |
---|
2377 | pcCU->setMVPNumSubParts( pcAMVPInfo->iN, eRefPicList, uiPartAddr, uiPartIdx, pcCU->getDepth(uiPartAddr)); |
---|
2378 | return; |
---|
2379 | } |
---|
2380 | |
---|
2381 | assert(pcCU->getMVPIdx(eRefPicList,uiPartAddr) >= 0); |
---|
2382 | rcMvPred = pcAMVPInfo->m_acMvCand[pcCU->getMVPIdx(eRefPicList,uiPartAddr)]; |
---|
2383 | return; |
---|
2384 | } |
---|
2385 | |
---|
2386 | /** Function for deriving planar intra prediction. |
---|
2387 | * \param pSrc pointer to reconstructed sample array |
---|
2388 | * \param srcStride the stride of the reconstructed sample array |
---|
2389 | * \param rpDst reference to pointer for the prediction sample array |
---|
2390 | * \param dstStride the stride of the prediction sample array |
---|
2391 | * \param width the width of the block |
---|
2392 | * \param height the height of the block |
---|
2393 | * |
---|
2394 | * This function derives the prediction samples for planar mode (intra coding). |
---|
2395 | */ |
---|
2396 | Void TComPrediction::xPredIntraPlanar( Int* pSrc, Int srcStride, Pel* rpDst, Int dstStride, UInt width, UInt height ) |
---|
2397 | { |
---|
2398 | assert(width == height); |
---|
2399 | |
---|
2400 | Int k, l, bottomLeft, topRight; |
---|
2401 | Int horPred; |
---|
2402 | Int leftColumn[MAX_CU_SIZE], topRow[MAX_CU_SIZE], bottomRow[MAX_CU_SIZE], rightColumn[MAX_CU_SIZE]; |
---|
2403 | UInt blkSize = width; |
---|
2404 | UInt offset2D = width; |
---|
2405 | UInt shift1D = g_aucConvertToBit[ width ] + 2; |
---|
2406 | UInt shift2D = shift1D + 1; |
---|
2407 | |
---|
2408 | // Get left and above reference column and row |
---|
2409 | for(k=0;k<blkSize+1;k++) |
---|
2410 | { |
---|
2411 | topRow[k] = pSrc[k-srcStride]; |
---|
2412 | leftColumn[k] = pSrc[k*srcStride-1]; |
---|
2413 | } |
---|
2414 | |
---|
2415 | // Prepare intermediate variables used in interpolation |
---|
2416 | bottomLeft = leftColumn[blkSize]; |
---|
2417 | topRight = topRow[blkSize]; |
---|
2418 | for (k=0;k<blkSize;k++) |
---|
2419 | { |
---|
2420 | bottomRow[k] = bottomLeft - topRow[k]; |
---|
2421 | rightColumn[k] = topRight - leftColumn[k]; |
---|
2422 | topRow[k] <<= shift1D; |
---|
2423 | leftColumn[k] <<= shift1D; |
---|
2424 | } |
---|
2425 | |
---|
2426 | // Generate prediction signal |
---|
2427 | for (k=0;k<blkSize;k++) |
---|
2428 | { |
---|
2429 | horPred = leftColumn[k] + offset2D; |
---|
2430 | for (l=0;l<blkSize;l++) |
---|
2431 | { |
---|
2432 | horPred += rightColumn[k]; |
---|
2433 | topRow[l] += bottomRow[l]; |
---|
2434 | rpDst[k*dstStride+l] = ( (horPred + topRow[l]) >> shift2D ); |
---|
2435 | } |
---|
2436 | } |
---|
2437 | } |
---|
2438 | |
---|
2439 | /** Function for deriving chroma LM intra prediction. |
---|
2440 | * \param pcPattern pointer to neighbouring pixel access pattern |
---|
2441 | * \param piSrc pointer to reconstructed chroma sample array |
---|
2442 | * \param pPred pointer for the prediction sample array |
---|
2443 | * \param uiPredStride the stride of the prediction sample array |
---|
2444 | * \param uiCWidth the width of the chroma block |
---|
2445 | * \param uiCHeight the height of the chroma block |
---|
2446 | * \param uiChromaId boolean indication of chroma component |
---|
2447 | * |
---|
2448 | * This function derives the prediction samples for chroma LM mode (chroma intra coding) |
---|
2449 | */ |
---|
2450 | Void TComPrediction::predLMIntraChroma( TComPattern* pcPattern, Int* piSrc, Pel* pPred, UInt uiPredStride, UInt uiCWidth, UInt uiCHeight, UInt uiChromaId ) |
---|
2451 | { |
---|
2452 | UInt uiWidth = 2 * uiCWidth; |
---|
2453 | |
---|
2454 | xGetLLSPrediction( pcPattern, piSrc+uiWidth+2, uiWidth+1, pPred, uiPredStride, uiCWidth, uiCHeight, 1 ); |
---|
2455 | } |
---|
2456 | |
---|
2457 | /** Function for deriving downsampled luma sample of current chroma block and its above, left causal pixel |
---|
2458 | * \param pcPattern pointer to neighbouring pixel access pattern |
---|
2459 | * \param uiCWidth the width of the chroma block |
---|
2460 | * \param uiCHeight the height of the chroma block |
---|
2461 | * |
---|
2462 | * This function derives downsampled luma sample of current chroma block and its above, left causal pixel |
---|
2463 | */ |
---|
2464 | Void TComPrediction::getLumaRecPixels( TComPattern* pcPattern, UInt uiCWidth, UInt uiCHeight ) |
---|
2465 | { |
---|
2466 | UInt uiWidth = 2 * uiCWidth; |
---|
2467 | UInt uiHeight = 2 * uiCHeight; |
---|
2468 | |
---|
2469 | Pel* pRecSrc = pcPattern->getROIY(); |
---|
2470 | Pel* pDst0 = m_pLumaRecBuffer + m_iLumaRecStride + 1; |
---|
2471 | |
---|
2472 | Int iRecSrcStride = pcPattern->getPatternLStride(); |
---|
2473 | Int iRecSrcStride2 = iRecSrcStride << 1; |
---|
2474 | Int iDstStride = m_iLumaRecStride; |
---|
2475 | Int iSrcStride = ( max( uiWidth, uiHeight ) << 1 ) + 1; |
---|
2476 | |
---|
2477 | Int* ptrSrc = pcPattern->getAdiOrgBuf( uiWidth, uiHeight, m_piYuvExt ); |
---|
2478 | |
---|
2479 | // initial pointers |
---|
2480 | Pel* pDst = pDst0 - 1 - iDstStride; |
---|
2481 | Int* piSrc = ptrSrc; |
---|
2482 | |
---|
2483 | // top left corner downsampled from ADI buffer |
---|
2484 | // don't need this point |
---|
2485 | |
---|
2486 | // top row downsampled from ADI buffer |
---|
2487 | pDst++; |
---|
2488 | piSrc ++; |
---|
2489 | for (Int i = 0; i < uiCWidth; i++) |
---|
2490 | { |
---|
2491 | pDst[i] = ((piSrc[2*i] * 2 ) + piSrc[2*i - 1] + piSrc[2*i + 1] + 2) >> 2; |
---|
2492 | } |
---|
2493 | |
---|
2494 | // left column downsampled from ADI buffer |
---|
2495 | pDst = pDst0 - 1; |
---|
2496 | piSrc = ptrSrc + iSrcStride; |
---|
2497 | for (Int j = 0; j < uiCHeight; j++) |
---|
2498 | { |
---|
2499 | pDst[0] = ( piSrc[0] + piSrc[iSrcStride] ) >> 1; |
---|
2500 | piSrc += iSrcStride << 1; |
---|
2501 | pDst += iDstStride; |
---|
2502 | } |
---|
2503 | |
---|
2504 | // inner part from reconstructed picture buffer |
---|
2505 | for( Int j = 0; j < uiCHeight; j++ ) |
---|
2506 | { |
---|
2507 | for (Int i = 0; i < uiCWidth; i++) |
---|
2508 | { |
---|
2509 | pDst0[i] = (pRecSrc[2*i] + pRecSrc[2*i + iRecSrcStride]) >> 1; |
---|
2510 | } |
---|
2511 | |
---|
2512 | pDst0 += iDstStride; |
---|
2513 | pRecSrc += iRecSrcStride2; |
---|
2514 | } |
---|
2515 | } |
---|
2516 | |
---|
2517 | /** Function for deriving the positon of first non-zero binary bit of a value |
---|
2518 | * \param x input value |
---|
2519 | * |
---|
2520 | * This function derives the positon of first non-zero binary bit of a value |
---|
2521 | */ |
---|
2522 | Int GetMSB( UInt x ) |
---|
2523 | { |
---|
2524 | Int iMSB = 0, bits = ( sizeof( Int ) << 3 ), y = 1; |
---|
2525 | |
---|
2526 | while( x > 1 ) |
---|
2527 | { |
---|
2528 | bits >>= 1; |
---|
2529 | y = x >> bits; |
---|
2530 | |
---|
2531 | if( y ) |
---|
2532 | { |
---|
2533 | x = y; |
---|
2534 | iMSB += bits; |
---|
2535 | } |
---|
2536 | } |
---|
2537 | |
---|
2538 | iMSB+=y; |
---|
2539 | |
---|
2540 | return iMSB; |
---|
2541 | } |
---|
2542 | |
---|
2543 | /** Function for counting leading number of zeros/ones |
---|
2544 | * \param x input value |
---|
2545 | \ This function counts leading number of zeros for positive numbers and |
---|
2546 | \ leading number of ones for negative numbers. This can be implemented in |
---|
2547 | \ single instructure cycle on many processors. |
---|
2548 | */ |
---|
2549 | |
---|
2550 | Short CountLeadingZerosOnes (Short x) |
---|
2551 | { |
---|
2552 | Short clz; |
---|
2553 | Short i; |
---|
2554 | |
---|
2555 | if(x == 0) |
---|
2556 | { |
---|
2557 | clz = 0; |
---|
2558 | } |
---|
2559 | else |
---|
2560 | { |
---|
2561 | if (x == -1) |
---|
2562 | { |
---|
2563 | clz = 15; |
---|
2564 | } |
---|
2565 | else |
---|
2566 | { |
---|
2567 | if(x < 0) |
---|
2568 | { |
---|
2569 | x = ~x; |
---|
2570 | } |
---|
2571 | clz = 15; |
---|
2572 | for(i = 0;i < 15;++i) |
---|
2573 | { |
---|
2574 | if(x) |
---|
2575 | { |
---|
2576 | clz --; |
---|
2577 | } |
---|
2578 | x = x >> 1; |
---|
2579 | } |
---|
2580 | } |
---|
2581 | } |
---|
2582 | return clz; |
---|
2583 | } |
---|
2584 | |
---|
2585 | /** Function for deriving LM intra prediction. |
---|
2586 | * \param pcPattern pointer to neighbouring pixel access pattern |
---|
2587 | * \param pSrc0 pointer to reconstructed chroma sample array |
---|
2588 | * \param iSrcStride the stride of reconstructed chroma sample array |
---|
2589 | * \param pDst0 reference to pointer for the prediction sample array |
---|
2590 | * \param iDstStride the stride of the prediction sample array |
---|
2591 | * \param uiWidth the width of the chroma block |
---|
2592 | * \param uiHeight the height of the chroma block |
---|
2593 | * \param uiExt0 line number of neiggboirng pixels for calculating LM model parameter, default value is 1 |
---|
2594 | * |
---|
2595 | * This function derives the prediction samples for chroma LM mode (chroma intra coding) |
---|
2596 | */ |
---|
2597 | Void TComPrediction::xGetLLSPrediction( TComPattern* pcPattern, Int* pSrc0, Int iSrcStride, Pel* pDst0, Int iDstStride, UInt uiWidth, UInt uiHeight, UInt uiExt0 ) |
---|
2598 | { |
---|
2599 | |
---|
2600 | Pel *pDst, *pLuma; |
---|
2601 | Int *pSrc; |
---|
2602 | |
---|
2603 | Int iLumaStride = m_iLumaRecStride; |
---|
2604 | Pel* pLuma0 = m_pLumaRecBuffer + uiExt0 * iLumaStride + uiExt0; |
---|
2605 | |
---|
2606 | Int i, j, iCountShift = 0; |
---|
2607 | |
---|
2608 | UInt uiExt = uiExt0; |
---|
2609 | |
---|
2610 | // LLS parameters estimation --> |
---|
2611 | |
---|
2612 | Int x = 0, y = 0, xx = 0, xy = 0; |
---|
2613 | |
---|
2614 | pSrc = pSrc0 - iSrcStride; |
---|
2615 | pLuma = pLuma0 - iLumaStride; |
---|
2616 | |
---|
2617 | for( j = 0; j < uiWidth; j++ ) |
---|
2618 | { |
---|
2619 | x += pLuma[j]; |
---|
2620 | y += pSrc[j]; |
---|
2621 | xx += pLuma[j] * pLuma[j]; |
---|
2622 | xy += pLuma[j] * pSrc[j]; |
---|
2623 | } |
---|
2624 | iCountShift += g_aucConvertToBit[ uiWidth ] + 2; |
---|
2625 | |
---|
2626 | pSrc = pSrc0 - uiExt; |
---|
2627 | pLuma = pLuma0 - uiExt; |
---|
2628 | |
---|
2629 | for( i = 0; i < uiHeight; i++ ) |
---|
2630 | { |
---|
2631 | x += pLuma[0]; |
---|
2632 | y += pSrc[0]; |
---|
2633 | xx += pLuma[0] * pLuma[0]; |
---|
2634 | xy += pLuma[0] * pSrc[0]; |
---|
2635 | |
---|
2636 | pSrc += iSrcStride; |
---|
2637 | pLuma += iLumaStride; |
---|
2638 | } |
---|
2639 | iCountShift += iCountShift > 0 ? 1 : ( g_aucConvertToBit[ uiWidth ] + 2 ); |
---|
2640 | |
---|
2641 | Int iTempShift = ( g_uiBitDepth + g_uiBitIncrement ) + g_aucConvertToBit[ uiWidth ] + 3 - 15; |
---|
2642 | |
---|
2643 | if(iTempShift > 0) |
---|
2644 | { |
---|
2645 | x = ( x + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
2646 | y = ( y + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
2647 | xx = ( xx + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
2648 | xy = ( xy + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
2649 | iCountShift -= iTempShift; |
---|
2650 | } |
---|
2651 | |
---|
2652 | Int a, b, iShift = 13; |
---|
2653 | |
---|
2654 | if( iCountShift == 0 ) |
---|
2655 | { |
---|
2656 | a = 0; |
---|
2657 | b = 1 << (g_uiBitDepth + g_uiBitIncrement - 1); |
---|
2658 | iShift = 0; |
---|
2659 | } |
---|
2660 | else |
---|
2661 | { |
---|
2662 | Int a1 = ( xy << iCountShift ) - y * x; |
---|
2663 | Int a2 = ( xx << iCountShift ) - x * x; |
---|
2664 | |
---|
2665 | { |
---|
2666 | const Int iShiftA2 = 6; |
---|
2667 | const Int iShiftA1 = 15; |
---|
2668 | const Int iAccuracyShift = 15; |
---|
2669 | |
---|
2670 | Int iScaleShiftA2 = 0; |
---|
2671 | Int iScaleShiftA1 = 0; |
---|
2672 | Int a1s = a1; |
---|
2673 | Int a2s = a2; |
---|
2674 | |
---|
2675 | iScaleShiftA1 = GetMSB( abs( a1 ) ) - iShiftA1; |
---|
2676 | iScaleShiftA2 = GetMSB( abs( a2 ) ) - iShiftA2; |
---|
2677 | |
---|
2678 | if( iScaleShiftA1 < 0 ) |
---|
2679 | { |
---|
2680 | iScaleShiftA1 = 0; |
---|
2681 | } |
---|
2682 | |
---|
2683 | if( iScaleShiftA2 < 0 ) |
---|
2684 | { |
---|
2685 | iScaleShiftA2 = 0; |
---|
2686 | } |
---|
2687 | |
---|
2688 | Int iScaleShiftA = iScaleShiftA2 + iAccuracyShift - iShift - iScaleShiftA1; |
---|
2689 | |
---|
2690 | a2s = a2 >> iScaleShiftA2; |
---|
2691 | |
---|
2692 | a1s = a1 >> iScaleShiftA1; |
---|
2693 | |
---|
2694 | if (a2s >= 1) |
---|
2695 | { |
---|
2696 | a = a1s * m_uiaShift[ a2s - 1]; |
---|
2697 | } |
---|
2698 | else |
---|
2699 | { |
---|
2700 | a = 0; |
---|
2701 | } |
---|
2702 | |
---|
2703 | if( iScaleShiftA < 0 ) |
---|
2704 | { |
---|
2705 | a = a << -iScaleShiftA; |
---|
2706 | } |
---|
2707 | else |
---|
2708 | { |
---|
2709 | a = a >> iScaleShiftA; |
---|
2710 | } |
---|
2711 | |
---|
2712 | a = Clip3(-( 1 << 15 ), ( 1 << 15 ) - 1, a); |
---|
2713 | |
---|
2714 | Int minA = -(1 << (6)); |
---|
2715 | Int maxA = (1 << 6) - 1; |
---|
2716 | if( a <= maxA && a >= minA ) |
---|
2717 | { |
---|
2718 | // do nothing |
---|
2719 | } |
---|
2720 | else |
---|
2721 | { |
---|
2722 | Short n = CountLeadingZerosOnes(a); |
---|
2723 | a = a >> (9-n); |
---|
2724 | iShift -= (9-n); |
---|
2725 | } |
---|
2726 | |
---|
2727 | b = ( y - ( ( a * x ) >> iShift ) + ( 1 << ( iCountShift - 1 ) ) ) >> iCountShift; |
---|
2728 | } |
---|
2729 | } |
---|
2730 | |
---|
2731 | // <-- end of LLS parameters estimation |
---|
2732 | |
---|
2733 | // get prediction --> |
---|
2734 | uiExt = uiExt0; |
---|
2735 | pLuma = pLuma0; |
---|
2736 | pDst = pDst0; |
---|
2737 | |
---|
2738 | for( i = 0; i < uiHeight; i++ ) |
---|
2739 | { |
---|
2740 | for( j = 0; j < uiWidth; j++ ) |
---|
2741 | { |
---|
2742 | pDst[j] = Clip( ( ( a * pLuma[j] ) >> iShift ) + b ); |
---|
2743 | } |
---|
2744 | |
---|
2745 | pDst += iDstStride; |
---|
2746 | pLuma += iLumaStride; |
---|
2747 | } |
---|
2748 | // <-- end of get prediction |
---|
2749 | |
---|
2750 | } |
---|
2751 | |
---|
2752 | |
---|
2753 | #if LGE_ILLUCOMP_B0045 |
---|
2754 | /** Function for deriving LM illumination compensation. |
---|
2755 | */ |
---|
2756 | Void TComPrediction::xGetLLSICPrediction(TComDataCU* pcCU, TComMv *pMv, TComPicYuv *pRefPic, Int &a, Int &b, Int &iShift) |
---|
2757 | { |
---|
2758 | TComPicYuv *pRecPic = pcCU->getPic()->getPicYuvRec(); |
---|
2759 | Pel *pRec, *pRef; |
---|
2760 | UInt uiWidth, uiHeight, uiTmpPartIdx; |
---|
2761 | Int iRecStride = pRecPic->getStride(), iRefStride = pRefPic->getStride(); |
---|
2762 | Int iCUPelX, iCUPelY, iRefX, iRefY, iRefOffset; |
---|
2763 | |
---|
2764 | iCUPelX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]]; |
---|
2765 | iCUPelY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]]; |
---|
2766 | iRefX = iCUPelX + (pMv->getHor() >> 2); |
---|
2767 | iRefY = iCUPelY + (pMv->getVer() >> 2); |
---|
2768 | uiWidth = pcCU->getWidth(0); |
---|
2769 | uiHeight = pcCU->getHeight(0); |
---|
2770 | |
---|
2771 | Int i, j, iCountShift = 0; |
---|
2772 | |
---|
2773 | // LLS parameters estimation --> |
---|
2774 | |
---|
2775 | Int x = 0, y = 0, xx = 0, xy = 0; |
---|
2776 | |
---|
2777 | if(pcCU->getPUAbove(uiTmpPartIdx, pcCU->getZorderIdxInCU()) && iCUPelY > 0 && iRefY > 0) |
---|
2778 | { |
---|
2779 | iRefOffset = ( pMv->getHor() >> 2 ) + ( pMv->getVer() >> 2 ) * iRefStride - iRefStride; |
---|
2780 | pRef = pRefPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
2781 | pRec = pRecPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; |
---|
2782 | |
---|
2783 | for( j = 0; j < uiWidth; j++ ) |
---|
2784 | { |
---|
2785 | x += pRef[j]; |
---|
2786 | y += pRec[j]; |
---|
2787 | xx += pRef[j] * pRef[j]; |
---|
2788 | xy += pRef[j] * pRec[j]; |
---|
2789 | } |
---|
2790 | iCountShift += g_aucConvertToBit[ uiWidth ] + 2; |
---|
2791 | } |
---|
2792 | |
---|
2793 | |
---|
2794 | if(pcCU->getPULeft(uiTmpPartIdx, pcCU->getZorderIdxInCU()) && iCUPelX > 0 && iRefX > 0) |
---|
2795 | { |
---|
2796 | iRefOffset = ( pMv->getHor() >> 2 ) + ( pMv->getVer() >> 2 ) * iRefStride - 1; |
---|
2797 | pRef = pRefPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
2798 | pRec = pRecPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; |
---|
2799 | |
---|
2800 | for( i = 0; i < uiHeight; i++ ) |
---|
2801 | { |
---|
2802 | x += pRef[0]; |
---|
2803 | y += pRec[0]; |
---|
2804 | xx += pRef[0] * pRef[0]; |
---|
2805 | xy += pRef[0] * pRec[0]; |
---|
2806 | |
---|
2807 | pRef += iRefStride; |
---|
2808 | pRec += iRecStride; |
---|
2809 | } |
---|
2810 | iCountShift += iCountShift > 0 ? 1 : ( g_aucConvertToBit[ uiWidth ] + 2 ); |
---|
2811 | } |
---|
2812 | |
---|
2813 | Int iTempShift = ( g_uiBitDepth + g_uiBitIncrement ) + g_aucConvertToBit[ uiWidth ] + 3 - 15; |
---|
2814 | |
---|
2815 | if(iTempShift > 0) |
---|
2816 | { |
---|
2817 | x = ( x + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
2818 | y = ( y + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
2819 | xx = ( xx + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
2820 | xy = ( xy + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
2821 | iCountShift -= iTempShift; |
---|
2822 | } |
---|
2823 | |
---|
2824 | iShift = 13; |
---|
2825 | |
---|
2826 | if( iCountShift == 0 ) |
---|
2827 | { |
---|
2828 | a = 1; |
---|
2829 | b = 0; |
---|
2830 | iShift = 0; |
---|
2831 | } |
---|
2832 | else |
---|
2833 | { |
---|
2834 | Int a1 = ( xy << iCountShift ) - y * x; |
---|
2835 | Int a2 = ( xx << iCountShift ) - x * x; |
---|
2836 | |
---|
2837 | { |
---|
2838 | const Int iShiftA2 = 6; |
---|
2839 | const Int iShiftA1 = 15; |
---|
2840 | const Int iAccuracyShift = 15; |
---|
2841 | |
---|
2842 | Int iScaleShiftA2 = 0; |
---|
2843 | Int iScaleShiftA1 = 0; |
---|
2844 | Int a1s = a1; |
---|
2845 | Int a2s = a2; |
---|
2846 | |
---|
2847 | iScaleShiftA1 = GetMSB( abs( a1 ) ) - iShiftA1; |
---|
2848 | iScaleShiftA2 = GetMSB( abs( a2 ) ) - iShiftA2; |
---|
2849 | |
---|
2850 | if( iScaleShiftA1 < 0 ) |
---|
2851 | { |
---|
2852 | iScaleShiftA1 = 0; |
---|
2853 | } |
---|
2854 | |
---|
2855 | if( iScaleShiftA2 < 0 ) |
---|
2856 | { |
---|
2857 | iScaleShiftA2 = 0; |
---|
2858 | } |
---|
2859 | |
---|
2860 | Int iScaleShiftA = iScaleShiftA2 + iAccuracyShift - iShift - iScaleShiftA1; |
---|
2861 | |
---|
2862 | a2s = a2 >> iScaleShiftA2; |
---|
2863 | |
---|
2864 | a1s = a1 >> iScaleShiftA1; |
---|
2865 | |
---|
2866 | if (a2s >= 1) |
---|
2867 | { |
---|
2868 | a = a1s * m_uiaShift[ a2s - 1]; |
---|
2869 | } |
---|
2870 | else |
---|
2871 | { |
---|
2872 | a = 0; |
---|
2873 | } |
---|
2874 | |
---|
2875 | if( iScaleShiftA < 0 ) |
---|
2876 | { |
---|
2877 | a = a << -iScaleShiftA; |
---|
2878 | } |
---|
2879 | else |
---|
2880 | { |
---|
2881 | a = a >> iScaleShiftA; |
---|
2882 | } |
---|
2883 | |
---|
2884 | a = Clip3(-( 1 << 15 ), ( 1 << 15 ) - 1, a); |
---|
2885 | |
---|
2886 | Int minA = -(1 << (6)); |
---|
2887 | Int maxA = (1 << 6) - 1; |
---|
2888 | if( a <= maxA && a >= minA ) |
---|
2889 | { |
---|
2890 | // do nothing |
---|
2891 | } |
---|
2892 | else |
---|
2893 | { |
---|
2894 | Short n = CountLeadingZerosOnes(a); |
---|
2895 | a = a >> (9-n); |
---|
2896 | iShift -= (9-n); |
---|
2897 | } |
---|
2898 | |
---|
2899 | b = ( y - ( ( a * x ) >> iShift ) + ( 1 << ( iCountShift - 1 ) ) ) >> iCountShift; |
---|
2900 | } |
---|
2901 | } |
---|
2902 | } |
---|
2903 | |
---|
2904 | Void TComPrediction::xGetLLSICPredictionChroma(TComDataCU* pcCU, TComMv *pMv, TComPicYuv *pRefPic, Int &a, Int &b, Int &iShift, Int iChromaId) |
---|
2905 | { |
---|
2906 | TComPicYuv *pRecPic = pcCU->getPic()->getPicYuvRec(); |
---|
2907 | Pel *pRec = NULL, *pRef = NULL; |
---|
2908 | UInt uiWidth, uiHeight, uiTmpPartIdx; |
---|
2909 | Int iRecStride = pRecPic->getCStride(), iRefStride = pRefPic->getCStride(); |
---|
2910 | Int iCUPelX, iCUPelY, iRefX, iRefY, iRefOffset; |
---|
2911 | |
---|
2912 | iCUPelX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]]; |
---|
2913 | iCUPelY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]]; |
---|
2914 | iRefX = iCUPelX + (pMv->getHor() >> 2); |
---|
2915 | iRefY = iCUPelY + (pMv->getVer() >> 2); |
---|
2916 | uiWidth = pcCU->getWidth(0) >> 1; |
---|
2917 | uiHeight = pcCU->getHeight(0) >> 1; |
---|
2918 | |
---|
2919 | Int i, j, iCountShift = 0; |
---|
2920 | |
---|
2921 | // LLS parameters estimation --> |
---|
2922 | |
---|
2923 | Int x = 0, y = 0, xx = 0, xy = 0; |
---|
2924 | |
---|
2925 | if(pcCU->getPUAbove(uiTmpPartIdx, pcCU->getZorderIdxInCU()) && iCUPelY > 0 && iRefY > 0) |
---|
2926 | { |
---|
2927 | iRefOffset = ( pMv->getHor() >> 3 ) + ( pMv->getVer() >> 3 ) * iRefStride - iRefStride; |
---|
2928 | if (iChromaId == 0) // Cb |
---|
2929 | { |
---|
2930 | pRef = pRefPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
2931 | pRec = pRecPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; |
---|
2932 | } |
---|
2933 | else if (iChromaId == 1) // Cr |
---|
2934 | { |
---|
2935 | pRef = pRefPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
2936 | pRec = pRecPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; |
---|
2937 | } |
---|
2938 | |
---|
2939 | for( j = 0; j < uiWidth; j++ ) |
---|
2940 | { |
---|
2941 | x += pRef[j]; |
---|
2942 | y += pRec[j]; |
---|
2943 | xx += pRef[j] * pRef[j]; |
---|
2944 | xy += pRef[j] * pRec[j]; |
---|
2945 | } |
---|
2946 | iCountShift += g_aucConvertToBit[ uiWidth ] + 2; |
---|
2947 | } |
---|
2948 | |
---|
2949 | |
---|
2950 | if(pcCU->getPULeft(uiTmpPartIdx, pcCU->getZorderIdxInCU()) && iCUPelX > 0 && iRefX > 0) |
---|
2951 | { |
---|
2952 | iRefOffset = ( pMv->getHor() >> 3 ) + ( pMv->getVer() >> 3 ) * iRefStride - 1; |
---|
2953 | if (iChromaId == 0) // Cb |
---|
2954 | { |
---|
2955 | pRef = pRefPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
2956 | pRec = pRecPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; |
---|
2957 | } |
---|
2958 | else if (iChromaId == 1) // Cr |
---|
2959 | { |
---|
2960 | pRef = pRefPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
2961 | pRec = pRecPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; |
---|
2962 | } |
---|
2963 | |
---|
2964 | for( i = 0; i < uiHeight; i++ ) |
---|
2965 | { |
---|
2966 | x += pRef[0]; |
---|
2967 | y += pRec[0]; |
---|
2968 | xx += pRef[0] * pRef[0]; |
---|
2969 | xy += pRef[0] * pRec[0]; |
---|
2970 | |
---|
2971 | pRef += iRefStride; |
---|
2972 | pRec += iRecStride; |
---|
2973 | } |
---|
2974 | iCountShift += iCountShift > 0 ? 1 : ( g_aucConvertToBit[ uiWidth ] + 2 ); |
---|
2975 | } |
---|
2976 | |
---|
2977 | Int iTempShift = ( g_uiBitDepth + g_uiBitIncrement ) + g_aucConvertToBit[ uiWidth ] + 3 - 15; |
---|
2978 | |
---|
2979 | if(iTempShift > 0) |
---|
2980 | { |
---|
2981 | x = ( x + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
2982 | y = ( y + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
2983 | xx = ( xx + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
2984 | xy = ( xy + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
2985 | iCountShift -= iTempShift; |
---|
2986 | } |
---|
2987 | |
---|
2988 | iShift = 13; |
---|
2989 | |
---|
2990 | if( iCountShift == 0 ) |
---|
2991 | { |
---|
2992 | a = 1; |
---|
2993 | b = 0; |
---|
2994 | iShift = 0; |
---|
2995 | } |
---|
2996 | else |
---|
2997 | { |
---|
2998 | Int a1 = ( xy << iCountShift ) - y * x; |
---|
2999 | Int a2 = ( xx << iCountShift ) - x * x; |
---|
3000 | |
---|
3001 | { |
---|
3002 | const Int iShiftA2 = 6; |
---|
3003 | const Int iShiftA1 = 15; |
---|
3004 | const Int iAccuracyShift = 15; |
---|
3005 | |
---|
3006 | Int iScaleShiftA2 = 0; |
---|
3007 | Int iScaleShiftA1 = 0; |
---|
3008 | Int a1s = a1; |
---|
3009 | Int a2s = a2; |
---|
3010 | |
---|
3011 | iScaleShiftA1 = GetMSB( abs( a1 ) ) - iShiftA1; |
---|
3012 | iScaleShiftA2 = GetMSB( abs( a2 ) ) - iShiftA2; |
---|
3013 | |
---|
3014 | if( iScaleShiftA1 < 0 ) |
---|
3015 | { |
---|
3016 | iScaleShiftA1 = 0; |
---|
3017 | } |
---|
3018 | |
---|
3019 | if( iScaleShiftA2 < 0 ) |
---|
3020 | { |
---|
3021 | iScaleShiftA2 = 0; |
---|
3022 | } |
---|
3023 | |
---|
3024 | Int iScaleShiftA = iScaleShiftA2 + iAccuracyShift - iShift - iScaleShiftA1; |
---|
3025 | |
---|
3026 | a2s = a2 >> iScaleShiftA2; |
---|
3027 | |
---|
3028 | a1s = a1 >> iScaleShiftA1; |
---|
3029 | |
---|
3030 | if (a2s >= 1) |
---|
3031 | { |
---|
3032 | a = a1s * m_uiaShift[ a2s - 1]; |
---|
3033 | } |
---|
3034 | else |
---|
3035 | { |
---|
3036 | a = 0; |
---|
3037 | } |
---|
3038 | |
---|
3039 | if( iScaleShiftA < 0 ) |
---|
3040 | { |
---|
3041 | a = a << -iScaleShiftA; |
---|
3042 | } |
---|
3043 | else |
---|
3044 | { |
---|
3045 | a = a >> iScaleShiftA; |
---|
3046 | } |
---|
3047 | |
---|
3048 | a = Clip3(-( 1 << 15 ), ( 1 << 15 ) - 1, a); |
---|
3049 | |
---|
3050 | Int minA = -(1 << (6)); |
---|
3051 | Int maxA = (1 << 6) - 1; |
---|
3052 | if( a <= maxA && a >= minA ) |
---|
3053 | { |
---|
3054 | // do nothing |
---|
3055 | } |
---|
3056 | else |
---|
3057 | { |
---|
3058 | Short n = CountLeadingZerosOnes(a); |
---|
3059 | a = a >> (9-n); |
---|
3060 | iShift -= (9-n); |
---|
3061 | } |
---|
3062 | |
---|
3063 | b = ( y - ( ( a * x ) >> iShift ) + ( 1 << ( iCountShift - 1 ) ) ) >> iCountShift; |
---|
3064 | } |
---|
3065 | } |
---|
3066 | } |
---|
3067 | #endif |
---|
3068 | /** Function for filtering intra DC predictor. |
---|
3069 | * \param pSrc pointer to reconstructed sample array |
---|
3070 | * \param iSrcStride the stride of the reconstructed sample array |
---|
3071 | * \param rpDst reference to pointer for the prediction sample array |
---|
3072 | * \param iDstStride the stride of the prediction sample array |
---|
3073 | * \param iWidth the width of the block |
---|
3074 | * \param iHeight the height of the block |
---|
3075 | * |
---|
3076 | * This function performs filtering left and top edges of the prediction samples for DC mode (intra coding). |
---|
3077 | */ |
---|
3078 | Void TComPrediction::xDCPredFiltering( Int* pSrc, Int iSrcStride, Pel*& rpDst, Int iDstStride, Int iWidth, Int iHeight ) |
---|
3079 | { |
---|
3080 | Pel* pDst = rpDst; |
---|
3081 | Int x, y, iDstStride2, iSrcStride2; |
---|
3082 | |
---|
3083 | // boundary pixels processing |
---|
3084 | pDst[0] = (Pel)((pSrc[-iSrcStride] + pSrc[-1] + 2 * pDst[0] + 2) >> 2); |
---|
3085 | |
---|
3086 | for ( x = 1; x < iWidth; x++ ) |
---|
3087 | { |
---|
3088 | pDst[x] = (Pel)((pSrc[x - iSrcStride] + 3 * pDst[x] + 2) >> 2); |
---|
3089 | } |
---|
3090 | |
---|
3091 | for ( y = 1, iDstStride2 = iDstStride, iSrcStride2 = iSrcStride-1; y < iHeight; y++, iDstStride2+=iDstStride, iSrcStride2+=iSrcStride ) |
---|
3092 | { |
---|
3093 | pDst[iDstStride2] = (Pel)((pSrc[iSrcStride2] + 3 * pDst[iDstStride2] + 2) >> 2); |
---|
3094 | } |
---|
3095 | |
---|
3096 | return; |
---|
3097 | } |
---|
3098 | |
---|
3099 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
3100 | Void TComPrediction::predIntraLumaDMM( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder ) |
---|
3101 | { |
---|
3102 | #if HHI_DMM_WEDGE_INTRA |
---|
3103 | if( uiMode == DMM_WEDGE_FULL_IDX ) { xPredIntraWedgeFull ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, false, pcCU->getWedgeFullTabIdx ( uiAbsPartIdx ) ); } |
---|
3104 | if( uiMode == DMM_WEDGE_FULL_D_IDX ) { xPredIntraWedgeFull ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, true, pcCU->getWedgeFullTabIdx( uiAbsPartIdx ), pcCU->getWedgeFullDeltaDC1( uiAbsPartIdx ), pcCU->getWedgeFullDeltaDC2( uiAbsPartIdx ) ); } |
---|
3105 | if( uiMode == DMM_WEDGE_PREDDIR_IDX ) { xPredIntraWedgeDir ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, false, pcCU->getWedgePredDirDeltaEnd( uiAbsPartIdx ) ); } |
---|
3106 | if( uiMode == DMM_WEDGE_PREDDIR_D_IDX ) { xPredIntraWedgeDir ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, true, pcCU->getWedgePredDirDeltaEnd( uiAbsPartIdx ), pcCU->getWedgePredDirDeltaDC1( uiAbsPartIdx ), pcCU->getWedgePredDirDeltaDC2( uiAbsPartIdx ) ); } |
---|
3107 | #endif |
---|
3108 | #if HHI_DMM_PRED_TEX |
---|
3109 | if( uiMode == DMM_WEDGE_PREDTEX_IDX ) { xPredIntraWedgeTex ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, false ); } |
---|
3110 | if( uiMode == DMM_WEDGE_PREDTEX_D_IDX ) { xPredIntraWedgeTex ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, true, pcCU->getWedgePredTexDeltaDC1( uiAbsPartIdx ), pcCU->getWedgePredTexDeltaDC2( uiAbsPartIdx ) ); } |
---|
3111 | if( uiMode == DMM_CONTOUR_PREDTEX_IDX ) { xPredIntraContourTex( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, false ); } |
---|
3112 | if( uiMode == DMM_CONTOUR_PREDTEX_D_IDX ) { xPredIntraContourTex( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, true, pcCU->getContourPredTexDeltaDC1( uiAbsPartIdx ), pcCU->getContourPredTexDeltaDC2( uiAbsPartIdx ) ); } |
---|
3113 | #endif |
---|
3114 | } |
---|
3115 | |
---|
3116 | Void TComPrediction::getWedgePredDCs( TComWedgelet* pcWedgelet, Int* piMask, Int iMaskStride, Int& riPredDC1, Int& riPredDC2, Bool bAbove, Bool bLeft ) |
---|
3117 | { |
---|
3118 | riPredDC1 = ( 1<<( g_uiBitDepth + g_uiBitIncrement - 1) ); //pred val, if no neighbors are available |
---|
3119 | riPredDC2 = ( 1<<( g_uiBitDepth + g_uiBitIncrement - 1) ); |
---|
3120 | |
---|
3121 | if( !bAbove && !bLeft ) { return; } |
---|
3122 | |
---|
3123 | UInt uiNumSmpDC1 = 0, uiNumSmpDC2 = 0; |
---|
3124 | Int iPredDC1 = 0, iPredDC2 = 0; |
---|
3125 | |
---|
3126 | Bool* pabWedgePattern = pcWedgelet->getPattern(); |
---|
3127 | UInt uiWedgeStride = pcWedgelet->getStride(); |
---|
3128 | |
---|
3129 | #if HS_REFERENCE_SUBSAMPLE_C0154 |
---|
3130 | Int subSamplePix; |
---|
3131 | if ( pcWedgelet->getWidth() == 32 ) |
---|
3132 | { |
---|
3133 | subSamplePix = 2; |
---|
3134 | } |
---|
3135 | else |
---|
3136 | { |
---|
3137 | subSamplePix = 1; |
---|
3138 | } |
---|
3139 | #endif |
---|
3140 | |
---|
3141 | if( bAbove ) |
---|
3142 | { |
---|
3143 | #if HS_REFERENCE_SUBSAMPLE_C0154 |
---|
3144 | for( Int k = 0; k < pcWedgelet->getWidth(); k+=subSamplePix ) |
---|
3145 | #else |
---|
3146 | for( Int k = 0; k < pcWedgelet->getWidth(); k++ ) |
---|
3147 | #endif |
---|
3148 | { |
---|
3149 | if( true == pabWedgePattern[k] ) |
---|
3150 | { |
---|
3151 | iPredDC2 += piMask[k-iMaskStride]; |
---|
3152 | uiNumSmpDC2++; |
---|
3153 | } |
---|
3154 | else |
---|
3155 | { |
---|
3156 | iPredDC1 += piMask[k-iMaskStride]; |
---|
3157 | uiNumSmpDC1++; |
---|
3158 | } |
---|
3159 | } |
---|
3160 | } |
---|
3161 | if( bLeft ) |
---|
3162 | { |
---|
3163 | #if HS_REFERENCE_SUBSAMPLE_C0154 |
---|
3164 | for( Int k = 0; k < pcWedgelet->getHeight(); k+=subSamplePix ) |
---|
3165 | #else |
---|
3166 | for( Int k = 0; k < pcWedgelet->getHeight(); k++ ) |
---|
3167 | #endif |
---|
3168 | { |
---|
3169 | if( true == pabWedgePattern[k*uiWedgeStride] ) |
---|
3170 | { |
---|
3171 | iPredDC2 += piMask[k*iMaskStride-1]; |
---|
3172 | uiNumSmpDC2++; |
---|
3173 | } |
---|
3174 | else |
---|
3175 | { |
---|
3176 | iPredDC1 += piMask[k*iMaskStride-1]; |
---|
3177 | uiNumSmpDC1++; |
---|
3178 | } |
---|
3179 | } |
---|
3180 | } |
---|
3181 | |
---|
3182 | if( uiNumSmpDC1 > 0 ) |
---|
3183 | { |
---|
3184 | iPredDC1 /= uiNumSmpDC1; |
---|
3185 | riPredDC1 = iPredDC1; |
---|
3186 | } |
---|
3187 | if( uiNumSmpDC2 > 0 ) |
---|
3188 | { |
---|
3189 | iPredDC2 /= uiNumSmpDC2; |
---|
3190 | riPredDC2 = iPredDC2; |
---|
3191 | } |
---|
3192 | } |
---|
3193 | |
---|
3194 | Void TComPrediction::calcWedgeDCs( TComWedgelet* pcWedgelet, Pel* piOrig, UInt uiStride, Int& riDC1, Int& riDC2 ) |
---|
3195 | { |
---|
3196 | UInt uiDC1 = 0; |
---|
3197 | UInt uiDC2 = 0; |
---|
3198 | UInt uiNumPixDC1 = 0, uiNumPixDC2 = 0; |
---|
3199 | Bool* pabWedgePattern = pcWedgelet->getPattern(); |
---|
3200 | if( uiStride == pcWedgelet->getStride() ) |
---|
3201 | { |
---|
3202 | for( UInt k = 0; k < (pcWedgelet->getWidth() * pcWedgelet->getHeight()); k++ ) |
---|
3203 | { |
---|
3204 | if( true == pabWedgePattern[k] ) |
---|
3205 | { |
---|
3206 | uiDC2 += piOrig[k]; |
---|
3207 | uiNumPixDC2++; |
---|
3208 | } |
---|
3209 | else |
---|
3210 | { |
---|
3211 | uiDC1 += piOrig[k]; |
---|
3212 | uiNumPixDC1++; |
---|
3213 | } |
---|
3214 | } |
---|
3215 | } |
---|
3216 | else |
---|
3217 | { |
---|
3218 | Pel* piTemp = piOrig; |
---|
3219 | UInt uiWedgeStride = pcWedgelet->getStride(); |
---|
3220 | for( UInt uiY = 0; uiY < pcWedgelet->getHeight(); uiY++ ) |
---|
3221 | { |
---|
3222 | for( UInt uiX = 0; uiX < pcWedgelet->getWidth(); uiX++ ) |
---|
3223 | { |
---|
3224 | if( true == pabWedgePattern[uiX] ) |
---|
3225 | { |
---|
3226 | uiDC2 += piTemp[uiX]; |
---|
3227 | uiNumPixDC2++; |
---|
3228 | } |
---|
3229 | else |
---|
3230 | { |
---|
3231 | uiDC1 += piTemp[uiX]; |
---|
3232 | uiNumPixDC1++; |
---|
3233 | } |
---|
3234 | } |
---|
3235 | piTemp += uiStride; |
---|
3236 | pabWedgePattern += uiWedgeStride; |
---|
3237 | } |
---|
3238 | } |
---|
3239 | |
---|
3240 | if( uiNumPixDC1 > 0 ) { riDC1 = uiDC1 / uiNumPixDC1; } |
---|
3241 | else { riDC1 = ( 1<<( g_uiBitDepth + g_uiBitIncrement - 1) ); } |
---|
3242 | |
---|
3243 | if( uiNumPixDC2 > 0 ) { riDC2 = uiDC2 / uiNumPixDC2; } |
---|
3244 | else { riDC2 = ( 1<<( g_uiBitDepth + g_uiBitIncrement - 1) ); } |
---|
3245 | } |
---|
3246 | |
---|
3247 | Void TComPrediction::assignWedgeDCs2Pred( TComWedgelet* pcWedgelet, Pel* piPred, UInt uiStride, Int iDC1, Int iDC2 ) |
---|
3248 | { |
---|
3249 | Bool* pabWedgePattern = pcWedgelet->getPattern(); |
---|
3250 | |
---|
3251 | if( uiStride == pcWedgelet->getStride() ) |
---|
3252 | { |
---|
3253 | for( UInt k = 0; k < (pcWedgelet->getWidth() * pcWedgelet->getHeight()); k++ ) |
---|
3254 | { |
---|
3255 | if( true == pabWedgePattern[k] ) |
---|
3256 | { |
---|
3257 | piPred[k] = iDC2; |
---|
3258 | } |
---|
3259 | else |
---|
3260 | { |
---|
3261 | piPred[k] = iDC1; |
---|
3262 | } |
---|
3263 | } |
---|
3264 | } |
---|
3265 | else |
---|
3266 | { |
---|
3267 | Pel* piTemp = piPred; |
---|
3268 | UInt uiWedgeStride = pcWedgelet->getStride(); |
---|
3269 | for( UInt uiY = 0; uiY < pcWedgelet->getHeight(); uiY++ ) |
---|
3270 | { |
---|
3271 | for( UInt uiX = 0; uiX < pcWedgelet->getWidth(); uiX++ ) |
---|
3272 | { |
---|
3273 | if( true == pabWedgePattern[uiX] ) |
---|
3274 | { |
---|
3275 | piTemp[uiX] = iDC2; |
---|
3276 | } |
---|
3277 | else |
---|
3278 | { |
---|
3279 | piTemp[uiX] = iDC1; |
---|
3280 | } |
---|
3281 | } |
---|
3282 | piTemp += uiStride; |
---|
3283 | pabWedgePattern += uiWedgeStride; |
---|
3284 | } |
---|
3285 | } |
---|
3286 | } |
---|
3287 | |
---|
3288 | Void TComPrediction::xDeltaDCQuantScaleUp( TComDataCU* pcCU, Int& riDeltaDC ) |
---|
3289 | { |
---|
3290 | Int iSign = riDeltaDC < 0 ? -1 : 1; |
---|
3291 | UInt uiAbs = abs( riDeltaDC ); |
---|
3292 | |
---|
3293 | Int iQp = pcCU->getQP(0); |
---|
3294 | Double dMax = (Double)( 1<<( g_uiBitDepth + g_uiBitIncrement - 1) ); |
---|
3295 | Double dStepSize = Clip3( 1.0, dMax, pow( 2.0, iQp/10.0 + g_iDeltaDCsQuantOffset ) ); |
---|
3296 | |
---|
3297 | riDeltaDC = iSign * roftoi( uiAbs * dStepSize ); |
---|
3298 | return; |
---|
3299 | } |
---|
3300 | |
---|
3301 | Void TComPrediction::xDeltaDCQuantScaleDown( TComDataCU* pcCU, Int& riDeltaDC ) |
---|
3302 | { |
---|
3303 | Int iSign = riDeltaDC < 0 ? -1 : 1; |
---|
3304 | UInt uiAbs = abs( riDeltaDC ); |
---|
3305 | |
---|
3306 | Int iQp = pcCU->getQP(0); |
---|
3307 | Double dMax = (Double)( 1<<( g_uiBitDepth + g_uiBitIncrement - 1) ); |
---|
3308 | Double dStepSize = Clip3( 1.0, dMax, pow( 2.0, iQp/10.0 + g_iDeltaDCsQuantOffset ) ); |
---|
3309 | |
---|
3310 | riDeltaDC = iSign * roftoi( uiAbs / dStepSize ); |
---|
3311 | return; |
---|
3312 | } |
---|
3313 | #endif |
---|
3314 | |
---|
3315 | #if HHI_DMM_PRED_TEX |
---|
3316 | Void TComPrediction::getBestContourFromTex( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, TComWedgelet* pcContourWedge ) |
---|
3317 | { |
---|
3318 | pcContourWedge->clear(); |
---|
3319 | |
---|
3320 | // get copy of co-located texture luma block |
---|
3321 | TComYuv cTempYuv; |
---|
3322 | cTempYuv.create( uiWidth, uiHeight ); |
---|
3323 | cTempYuv.clear(); |
---|
3324 | Pel* piRefBlkY = cTempYuv.getLumaAddr(); |
---|
3325 | copyTextureLumaBlock( pcCU, uiAbsPartIdx, piRefBlkY, uiWidth, uiHeight ); |
---|
3326 | piRefBlkY = cTempYuv.getLumaAddr(); |
---|
3327 | |
---|
3328 | // find contour for texture luma block |
---|
3329 | UInt iDC = 0; |
---|
3330 | for( UInt k = 0; k < (uiWidth*uiHeight); k++ ) |
---|
3331 | { |
---|
3332 | iDC += piRefBlkY[k]; |
---|
3333 | } |
---|
3334 | iDC /= (uiWidth*uiHeight); |
---|
3335 | piRefBlkY = cTempYuv.getLumaAddr(); |
---|
3336 | |
---|
3337 | Bool* pabContourPattern = pcContourWedge->getPattern(); |
---|
3338 | for( UInt k = 0; k < (uiWidth*uiHeight); k++ ) |
---|
3339 | { |
---|
3340 | pabContourPattern[k] = (piRefBlkY[k] > iDC) ? true : false; |
---|
3341 | } |
---|
3342 | |
---|
3343 | cTempYuv.destroy(); |
---|
3344 | } |
---|
3345 | |
---|
3346 | #if LGE_DMM3_SIMP_C0044 |
---|
3347 | /** |
---|
3348 | - fetch best Wedgelet pattern at decoder |
---|
3349 | */ |
---|
3350 | UInt TComPrediction::getBestWedgeFromTex( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt IntraTabIdx) |
---|
3351 | { |
---|
3352 | assert( uiWidth >= DMM_WEDGEMODEL_MIN_SIZE && uiWidth <= DMM_WEDGEMODEL_MAX_SIZE ); |
---|
3353 | |
---|
3354 | UInt uiBestTabIdx = 0; |
---|
3355 | TComPic* pcPicTex = pcCU->getSlice()->getTexturePic(); |
---|
3356 | TComDataCU* pcColTexCU = pcPicTex->getCU(pcCU->getAddr()); |
---|
3357 | UInt uiTexPartIdx = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
3358 | Int uiColTexIntraDir = pcColTexCU->isIntra( uiTexPartIdx ) ? pcColTexCU->getLumaIntraDir( uiTexPartIdx ) : 255; |
---|
3359 | |
---|
3360 | std::vector< std::vector<UInt> > pauiWdgLstSz = g_aauiWdgLstM3[g_aucConvertToBit[uiWidth]]; |
---|
3361 | |
---|
3362 | if( uiColTexIntraDir > DC_IDX && uiColTexIntraDir < 35 ) |
---|
3363 | { |
---|
3364 | std::vector<UInt>* pauiWdgLst = &pauiWdgLstSz[uiColTexIntraDir-2]; |
---|
3365 | uiBestTabIdx = pauiWdgLst->at(IntraTabIdx); |
---|
3366 | } |
---|
3367 | else |
---|
3368 | { |
---|
3369 | WedgeNodeList* pacWedgeNodeList = &g_aacWedgeNodeLists[(g_aucConvertToBit[uiWidth])]; |
---|
3370 | uiBestTabIdx = pacWedgeNodeList->at(IntraTabIdx).getPatternIdx(); |
---|
3371 | } |
---|
3372 | |
---|
3373 | return uiBestTabIdx; |
---|
3374 | } |
---|
3375 | #endif |
---|
3376 | |
---|
3377 | #if LGE_DMM3_SIMP_C0044 |
---|
3378 | /** |
---|
3379 | - calculate best Wedgelet pattern at encoder |
---|
3380 | */ |
---|
3381 | UInt TComPrediction::getBestWedgeFromTex( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Pel* piOrigi, UInt uiStride, UInt & ruiIntraTabIdx) |
---|
3382 | #else |
---|
3383 | UInt TComPrediction::getBestWedgeFromTex( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight ) |
---|
3384 | #endif |
---|
3385 | { |
---|
3386 | assert( uiWidth >= DMM_WEDGEMODEL_MIN_SIZE && uiWidth <= DMM_WEDGEMODEL_MAX_SIZE ); |
---|
3387 | |
---|
3388 | // get copy of co-located texture luma block |
---|
3389 | TComYuv cTempYuv; |
---|
3390 | cTempYuv.create( uiWidth, uiHeight ); |
---|
3391 | cTempYuv.clear(); |
---|
3392 | Pel* piRefBlkY = cTempYuv.getLumaAddr(); |
---|
3393 | |
---|
3394 | copyTextureLumaBlock( pcCU, uiAbsPartIdx, piRefBlkY, uiWidth, uiHeight ); |
---|
3395 | piRefBlkY = cTempYuv.getLumaAddr(); |
---|
3396 | |
---|
3397 | // local pred buffer |
---|
3398 | TComYuv cPredYuv; |
---|
3399 | cPredYuv.create( uiWidth, uiHeight ); |
---|
3400 | cPredYuv.clear(); |
---|
3401 | Pel* piPred = cPredYuv.getLumaAddr(); |
---|
3402 | |
---|
3403 | UInt uiPredStride = cPredYuv.getStride(); |
---|
3404 | |
---|
3405 | // wedge search |
---|
3406 | TComWedgeDist cWedgeDist; |
---|
3407 | UInt uiBestDist = MAX_UINT; |
---|
3408 | UInt uiBestTabIdx = 0; |
---|
3409 | Int iDC1 = 0; |
---|
3410 | Int iDC2 = 0; |
---|
3411 | WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiWidth])]; |
---|
3412 | #if LGE_DMM3_SIMP_C0044 |
---|
3413 | ruiIntraTabIdx = 0; |
---|
3414 | #endif |
---|
3415 | TComPic* pcPicTex = pcCU->getSlice()->getTexturePic(); |
---|
3416 | TComDataCU* pcColTexCU = pcPicTex->getCU(pcCU->getAddr()); |
---|
3417 | UInt uiTexPartIdx = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
3418 | Int uiColTexIntraDir = pcColTexCU->isIntra( uiTexPartIdx ) ? pcColTexCU->getLumaIntraDir( uiTexPartIdx ) : 255; |
---|
3419 | |
---|
3420 | std::vector< std::vector<UInt> > pauiWdgLstSz = g_aauiWdgLstM3[g_aucConvertToBit[uiWidth]]; |
---|
3421 | if( uiColTexIntraDir > DC_IDX && uiColTexIntraDir < 35 ) |
---|
3422 | { |
---|
3423 | std::vector<UInt>* pauiWdgLst = &pauiWdgLstSz[uiColTexIntraDir-2]; |
---|
3424 | for( UInt uiIdxW = 0; uiIdxW < pauiWdgLst->size(); uiIdxW++ ) |
---|
3425 | { |
---|
3426 | UInt uiIdx = pauiWdgLst->at(uiIdxW); |
---|
3427 | #if LGE_DMM3_SIMP_C0044 |
---|
3428 | calcWedgeDCs ( &(pacWedgeList->at(uiIdx)), piOrigi, uiWidth, iDC1, iDC2 ); |
---|
3429 | #else |
---|
3430 | calcWedgeDCs ( &(pacWedgeList->at(uiIdx)), piRefBlkY, uiWidth, iDC1, iDC2 ); |
---|
3431 | #endif |
---|
3432 | assignWedgeDCs2Pred( &(pacWedgeList->at(uiIdx)), piPred, uiPredStride, iDC1, iDC2 ); |
---|
3433 | |
---|
3434 | #if LGE_DMM3_SIMP_C0044 |
---|
3435 | UInt uiActDist = cWedgeDist.getDistPart( piPred, uiPredStride, piOrigi, uiStride, uiWidth, uiHeight, WedgeDist_SAD ); |
---|
3436 | #else |
---|
3437 | UInt uiActDist = cWedgeDist.getDistPart( piPred, uiPredStride, piRefBlkY, uiWidth, uiWidth, uiHeight, WedgeDist_SAD ); |
---|
3438 | #endif |
---|
3439 | |
---|
3440 | if( uiActDist < uiBestDist || uiBestDist == MAX_UINT ) |
---|
3441 | { |
---|
3442 | uiBestDist = uiActDist; |
---|
3443 | uiBestTabIdx = uiIdx; |
---|
3444 | #if LGE_DMM3_SIMP_C0044 |
---|
3445 | ruiIntraTabIdx = uiIdxW; |
---|
3446 | #endif |
---|
3447 | } |
---|
3448 | } |
---|
3449 | } |
---|
3450 | else |
---|
3451 | { |
---|
3452 | WedgeNodeList* pacWedgeNodeList = &g_aacWedgeNodeLists[(g_aucConvertToBit[uiWidth])]; |
---|
3453 | UInt uiBestNodeDist = MAX_UINT; |
---|
3454 | UInt uiBestNodeId = 0; |
---|
3455 | for( UInt uiNodeId = 0; uiNodeId < pacWedgeNodeList->size(); uiNodeId++ ) |
---|
3456 | { |
---|
3457 | #if LGE_DMM3_SIMP_C0044 |
---|
3458 | calcWedgeDCs ( &(pacWedgeList->at(pacWedgeNodeList->at(uiNodeId).getPatternIdx())), piOrigi, uiWidth, iDC1, iDC2 ); |
---|
3459 | #else |
---|
3460 | calcWedgeDCs ( &(pacWedgeList->at(pacWedgeNodeList->at(uiNodeId).getPatternIdx())), piRefBlkY, uiWidth, iDC1, iDC2 ); |
---|
3461 | #endif |
---|
3462 | assignWedgeDCs2Pred( &(pacWedgeList->at(pacWedgeNodeList->at(uiNodeId).getPatternIdx())), piPred, uiPredStride, iDC1, iDC2 ); |
---|
3463 | |
---|
3464 | #if LGE_DMM3_SIMP_C0044 |
---|
3465 | UInt uiActDist = cWedgeDist.getDistPart( piPred, uiPredStride, piOrigi, uiStride, uiWidth, uiHeight, WedgeDist_SAD ); |
---|
3466 | #else |
---|
3467 | UInt uiActDist = cWedgeDist.getDistPart( piPred, uiPredStride, piRefBlkY, uiWidth, uiWidth, uiHeight, WedgeDist_SAD ); |
---|
3468 | #endif |
---|
3469 | |
---|
3470 | if( uiActDist < uiBestNodeDist || uiBestNodeDist == MAX_UINT ) |
---|
3471 | { |
---|
3472 | uiBestNodeDist = uiActDist; |
---|
3473 | uiBestNodeId = uiNodeId; |
---|
3474 | #if LGE_DMM3_SIMP_C0044 |
---|
3475 | ruiIntraTabIdx = uiNodeId; |
---|
3476 | #endif |
---|
3477 | } |
---|
3478 | } |
---|
3479 | #if LGE_DMM3_SIMP_C0044 |
---|
3480 | uiBestTabIdx = pacWedgeNodeList->at(uiBestNodeId).getPatternIdx(); |
---|
3481 | #else |
---|
3482 | // refinement |
---|
3483 | uiBestDist = uiBestNodeDist; |
---|
3484 | uiBestTabIdx = pacWedgeNodeList->at(uiBestNodeId).getPatternIdx(); |
---|
3485 | for( UInt uiRefId = 0; uiRefId < NUM_WEDGE_REFINES; uiRefId++ ) |
---|
3486 | { |
---|
3487 | if( pacWedgeNodeList->at(uiBestNodeId).getRefineIdx( uiRefId ) != NO_IDX ) |
---|
3488 | { |
---|
3489 | calcWedgeDCs ( &(pacWedgeList->at(pacWedgeNodeList->at(uiBestNodeId).getRefineIdx( uiRefId ))), piRefBlkY, uiWidth, iDC1, iDC2 ); |
---|
3490 | assignWedgeDCs2Pred( &(pacWedgeList->at(pacWedgeNodeList->at(uiBestNodeId).getRefineIdx( uiRefId ))), piPred, uiPredStride, iDC1, iDC2 ); |
---|
3491 | |
---|
3492 | UInt uiActDist = cWedgeDist.getDistPart( piPred, uiPredStride, piRefBlkY, uiWidth, uiWidth, uiHeight, WedgeDist_SAD ); |
---|
3493 | |
---|
3494 | if( uiActDist < uiBestDist || uiBestDist == MAX_UINT ) |
---|
3495 | { |
---|
3496 | uiBestDist = uiActDist; |
---|
3497 | uiBestTabIdx = pacWedgeNodeList->at(uiBestNodeId).getRefineIdx( uiRefId ); |
---|
3498 | } |
---|
3499 | } |
---|
3500 | } |
---|
3501 | #endif |
---|
3502 | } |
---|
3503 | |
---|
3504 | cPredYuv.destroy(); |
---|
3505 | cTempYuv.destroy(); |
---|
3506 | return uiBestTabIdx; |
---|
3507 | } |
---|
3508 | |
---|
3509 | Void TComPrediction::copyTextureLumaBlock( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piDestBlockY, UInt uiWidth, UInt uiHeight ) |
---|
3510 | { |
---|
3511 | TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getTexturePic()->getPicYuvRec(); |
---|
3512 | Int iRefStride = pcPicYuvRef->getStride(); |
---|
3513 | Pel* piRefY; |
---|
3514 | |
---|
3515 | piRefY = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiAbsPartIdx ); |
---|
3516 | |
---|
3517 | for ( Int y = 0; y < uiHeight; y++ ) |
---|
3518 | { |
---|
3519 | ::memcpy(piDestBlockY, piRefY, sizeof(Pel)*uiWidth); |
---|
3520 | // ::memset(piDestBlockY, 128, sizeof(Pel)*uiWidth); |
---|
3521 | piDestBlockY += uiWidth; |
---|
3522 | piRefY += iRefStride; |
---|
3523 | } |
---|
3524 | } |
---|
3525 | |
---|
3526 | Void TComPrediction::xPredIntraWedgeTex( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder, Bool bDelta, Int iDeltaDC1, Int iDeltaDC2 ) |
---|
3527 | { |
---|
3528 | assert( iWidth >= DMM_WEDGEMODEL_MIN_SIZE && iWidth <= DMM_WEDGEMODEL_MAX_SIZE ); |
---|
3529 | WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[iWidth])]; |
---|
3530 | |
---|
3531 | // get wedge pattern |
---|
3532 | UInt uiTextureWedgeTabIdx = 0; |
---|
3533 | if( bEncoder ) |
---|
3534 | { |
---|
3535 | // encoder: load stored wedge pattern from CU |
---|
3536 | uiTextureWedgeTabIdx = pcCU->getWedgePredTexTabIdx( uiAbsPartIdx ); |
---|
3537 | } |
---|
3538 | else |
---|
3539 | { |
---|
3540 | // decoder: get and store wedge pattern in CU |
---|
3541 | // decoder: get and store wedge pattern in CU |
---|
3542 | #if LGE_DMM3_SIMP_C0044 |
---|
3543 | UInt uiIntraTabIdx = pcCU->getWedgePredTexIntraTabIdx ( uiAbsPartIdx ); |
---|
3544 | uiTextureWedgeTabIdx = getBestWedgeFromTex( pcCU, uiAbsPartIdx, (UInt)iWidth, (UInt)iHeight, uiIntraTabIdx ); |
---|
3545 | #else |
---|
3546 | uiTextureWedgeTabIdx = getBestWedgeFromTex( pcCU, uiAbsPartIdx, (UInt)iWidth, (UInt)iHeight ); |
---|
3547 | #endif |
---|
3548 | |
---|
3549 | UInt uiDepth = (pcCU->getDepth(0)) + (pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1); |
---|
3550 | pcCU->setWedgePredTexTabIdxSubParts( uiTextureWedgeTabIdx, uiAbsPartIdx, uiDepth ); |
---|
3551 | } |
---|
3552 | TComWedgelet* pcWedgelet = &(pacWedgeList->at(uiTextureWedgeTabIdx)); |
---|
3553 | |
---|
3554 | // get wedge pred DCs |
---|
3555 | Int iPredDC1 = 0; |
---|
3556 | Int iPredDC2 = 0; |
---|
3557 | Int* piMask = pcCU->getPattern()->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); |
---|
3558 | Int iMaskStride = ( iWidth<<1 ) + 1; |
---|
3559 | piMask += iMaskStride+1; |
---|
3560 | getWedgePredDCs( pcWedgelet, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft ); |
---|
3561 | |
---|
3562 | // assign wedge pred DCs to prediction |
---|
3563 | if( bDelta ) { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, Clip ( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); } |
---|
3564 | else { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, iPredDC1, iPredDC2 ); } |
---|
3565 | } |
---|
3566 | |
---|
3567 | Void TComPrediction::xPredIntraContourTex( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder, Bool bDelta, Int iDeltaDC1, Int iDeltaDC2 ) |
---|
3568 | { |
---|
3569 | // get contour pattern |
---|
3570 | TComWedgelet* pcContourWedge = new TComWedgelet( iWidth, iHeight ); |
---|
3571 | getBestContourFromTex( pcCU, uiAbsPartIdx, (UInt)iWidth, (UInt)iHeight, pcContourWedge ); |
---|
3572 | |
---|
3573 | // get wedge pred DCs |
---|
3574 | Int iPredDC1 = 0; |
---|
3575 | Int iPredDC2 = 0; |
---|
3576 | Int* piMask = pcCU->getPattern()->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); |
---|
3577 | Int iMaskStride = ( iWidth<<1 ) + 1; |
---|
3578 | piMask += iMaskStride+1; |
---|
3579 | getWedgePredDCs( pcContourWedge, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft ); |
---|
3580 | |
---|
3581 | // assign wedge pred DCs to prediction |
---|
3582 | if( bDelta ) { assignWedgeDCs2Pred( pcContourWedge, piPred, uiStride, Clip ( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); } |
---|
3583 | else { assignWedgeDCs2Pred( pcContourWedge, piPred, uiStride, iPredDC1, iPredDC2 ); } |
---|
3584 | |
---|
3585 | pcContourWedge->destroy(); |
---|
3586 | delete pcContourWedge; |
---|
3587 | } |
---|
3588 | #endif // HHI_DMM_PRED_TEX |
---|
3589 | |
---|
3590 | #if HHI_DMM_WEDGE_INTRA |
---|
3591 | UInt TComPrediction::getBestContinueWedge( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Int iDeltaEnd ) |
---|
3592 | { |
---|
3593 | UInt uiThisBlockSize = uiWidth; |
---|
3594 | assert( uiThisBlockSize >= DMM_WEDGEMODEL_MIN_SIZE && uiThisBlockSize <= DMM_WEDGEMODEL_MAX_SIZE ); |
---|
3595 | WedgeRefList* pacContDWedgeRefList = &g_aacWedgeRefLists[(g_aucConvertToBit[uiThisBlockSize])]; |
---|
3596 | |
---|
3597 | UInt uiPredDirWedgeTabIdx = 0; |
---|
3598 | TComDataCU* pcTempCU; |
---|
3599 | UInt uiTempPartIdx; |
---|
3600 | // 1st: try continue above wedgelet |
---|
3601 | pcTempCU = pcCU->getPUAbove( uiTempPartIdx, pcCU->getZorderIdxInCU() + uiAbsPartIdx ); |
---|
3602 | if( pcTempCU ) |
---|
3603 | { |
---|
3604 | UChar uhLumaIntraDir = pcTempCU->getLumaIntraDir( uiTempPartIdx ); |
---|
3605 | if( DMM_WEDGE_FULL_IDX == uhLumaIntraDir || |
---|
3606 | DMM_WEDGE_FULL_D_IDX == uhLumaIntraDir || |
---|
3607 | DMM_WEDGE_PREDDIR_IDX == uhLumaIntraDir || |
---|
3608 | DMM_WEDGE_PREDDIR_D_IDX == uhLumaIntraDir |
---|
3609 | #if HHI_DMM_PRED_TEX |
---|
3610 | || |
---|
3611 | DMM_WEDGE_PREDTEX_IDX == uhLumaIntraDir || |
---|
3612 | DMM_WEDGE_PREDTEX_D_IDX == uhLumaIntraDir |
---|
3613 | #endif |
---|
3614 | ) |
---|
3615 | { |
---|
3616 | UInt uiRefWedgeSize = (UInt)g_aucIntraSizeIdxToWedgeSize[pcTempCU->getIntraSizeIdx( uiTempPartIdx )]; |
---|
3617 | WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiRefWedgeSize])]; |
---|
3618 | |
---|
3619 | // get offset between current and reference block |
---|
3620 | UInt uiOffsetX = 0; |
---|
3621 | UInt uiOffsetY = 0; |
---|
3622 | xGetBlockOffset( pcCU, uiAbsPartIdx, pcTempCU, uiTempPartIdx, uiOffsetX, uiOffsetY ); |
---|
3623 | |
---|
3624 | // get reference wedgelet |
---|
3625 | UInt uiRefWedgeTabIdx = 0; |
---|
3626 | switch( uhLumaIntraDir ) |
---|
3627 | { |
---|
3628 | case( DMM_WEDGE_FULL_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgeFullTabIdx ( uiTempPartIdx ); } break; |
---|
3629 | case( DMM_WEDGE_FULL_D_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgeFullTabIdx ( uiTempPartIdx ); } break; |
---|
3630 | case( DMM_WEDGE_PREDDIR_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredDirTabIdx( uiTempPartIdx ); } break; |
---|
3631 | case( DMM_WEDGE_PREDDIR_D_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredDirTabIdx( uiTempPartIdx ); } break; |
---|
3632 | #if HHI_DMM_PRED_TEX |
---|
3633 | case( DMM_WEDGE_PREDTEX_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredTexTabIdx( uiTempPartIdx ); } break; |
---|
3634 | case( DMM_WEDGE_PREDTEX_D_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredTexTabIdx( uiTempPartIdx ); } break; |
---|
3635 | #endif |
---|
3636 | default: { assert( 0 ); return uiPredDirWedgeTabIdx; } |
---|
3637 | } |
---|
3638 | TComWedgelet* pcRefWedgelet; |
---|
3639 | pcRefWedgelet = &(pacWedgeList->at( uiRefWedgeTabIdx )); |
---|
3640 | |
---|
3641 | // find reference wedgelet, if direction is suitable for continue wedge |
---|
3642 | if( pcRefWedgelet->checkPredDirAbovePossible( uiThisBlockSize, uiOffsetX ) ) |
---|
3643 | { |
---|
3644 | UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye; |
---|
3645 | pcRefWedgelet->getPredDirStartEndAbove( uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, uiThisBlockSize, uiOffsetX, iDeltaEnd ); |
---|
3646 | getWedgePatternIdx( pacContDWedgeRefList, uiPredDirWedgeTabIdx, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye ); |
---|
3647 | return uiPredDirWedgeTabIdx; |
---|
3648 | } |
---|
3649 | } |
---|
3650 | } |
---|
3651 | |
---|
3652 | // 2nd: try continue left wedglelet |
---|
3653 | pcTempCU = pcCU->getPULeft( uiTempPartIdx, pcCU->getZorderIdxInCU() + uiAbsPartIdx ); |
---|
3654 | if( pcTempCU ) |
---|
3655 | { |
---|
3656 | UChar uhLumaIntraDir = pcTempCU->getLumaIntraDir( uiTempPartIdx ); |
---|
3657 | if( DMM_WEDGE_FULL_IDX == uhLumaIntraDir || |
---|
3658 | DMM_WEDGE_FULL_D_IDX == uhLumaIntraDir || |
---|
3659 | DMM_WEDGE_PREDDIR_IDX == uhLumaIntraDir || |
---|
3660 | DMM_WEDGE_PREDDIR_D_IDX == uhLumaIntraDir |
---|
3661 | #if HHI_DMM_PRED_TEX |
---|
3662 | || |
---|
3663 | DMM_WEDGE_PREDTEX_IDX == uhLumaIntraDir || |
---|
3664 | DMM_WEDGE_PREDTEX_D_IDX == uhLumaIntraDir |
---|
3665 | #endif |
---|
3666 | ) |
---|
3667 | { |
---|
3668 | UInt uiRefWedgeSize = (UInt)g_aucIntraSizeIdxToWedgeSize[pcTempCU->getIntraSizeIdx( uiTempPartIdx )]; |
---|
3669 | WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiRefWedgeSize])]; |
---|
3670 | |
---|
3671 | // get offset between current and reference block |
---|
3672 | UInt uiOffsetX = 0; |
---|
3673 | UInt uiOffsetY = 0; |
---|
3674 | xGetBlockOffset( pcCU, uiAbsPartIdx, pcTempCU, uiTempPartIdx, uiOffsetX, uiOffsetY ); |
---|
3675 | |
---|
3676 | // get reference wedgelet |
---|
3677 | UInt uiRefWedgeTabIdx = 0; |
---|
3678 | switch( uhLumaIntraDir ) |
---|
3679 | { |
---|
3680 | case( DMM_WEDGE_FULL_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgeFullTabIdx ( uiTempPartIdx ); } break; |
---|
3681 | case( DMM_WEDGE_FULL_D_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgeFullTabIdx ( uiTempPartIdx ); } break; |
---|
3682 | case( DMM_WEDGE_PREDDIR_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredDirTabIdx( uiTempPartIdx ); } break; |
---|
3683 | case( DMM_WEDGE_PREDDIR_D_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredDirTabIdx( uiTempPartIdx ); } break; |
---|
3684 | #if HHI_DMM_PRED_TEX |
---|
3685 | case( DMM_WEDGE_PREDTEX_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredTexTabIdx( uiTempPartIdx ); } break; |
---|
3686 | case( DMM_WEDGE_PREDTEX_D_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredTexTabIdx( uiTempPartIdx ); } break; |
---|
3687 | #endif |
---|
3688 | default: { assert( 0 ); return uiPredDirWedgeTabIdx; } |
---|
3689 | } |
---|
3690 | TComWedgelet* pcRefWedgelet; |
---|
3691 | pcRefWedgelet = &(pacWedgeList->at( uiRefWedgeTabIdx )); |
---|
3692 | |
---|
3693 | // find reference wedgelet, if direction is suitable for continue wedge |
---|
3694 | if( pcRefWedgelet->checkPredDirLeftPossible( uiThisBlockSize, uiOffsetY ) ) |
---|
3695 | { |
---|
3696 | UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye; |
---|
3697 | pcRefWedgelet->getPredDirStartEndLeft( uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, uiThisBlockSize, uiOffsetY, iDeltaEnd ); |
---|
3698 | getWedgePatternIdx( pacContDWedgeRefList, uiPredDirWedgeTabIdx, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye ); |
---|
3699 | return uiPredDirWedgeTabIdx; |
---|
3700 | } |
---|
3701 | } |
---|
3702 | } |
---|
3703 | |
---|
3704 | // 3rd: (default) make wedglet from intra dir and max slope point |
---|
3705 | Int iSlopeX = 0; |
---|
3706 | Int iSlopeY = 0; |
---|
3707 | UInt uiStartPosX = 0; |
---|
3708 | UInt uiStartPosY = 0; |
---|
3709 | if( xGetWedgeIntraDirPredData( pcCU, uiAbsPartIdx, uiThisBlockSize, iSlopeX, iSlopeY, uiStartPosX, uiStartPosY ) ) |
---|
3710 | { |
---|
3711 | UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye; |
---|
3712 | xGetWedgeIntraDirStartEnd( pcCU, uiAbsPartIdx, uiThisBlockSize, iSlopeX, iSlopeY, uiStartPosX, uiStartPosY, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, iDeltaEnd ); |
---|
3713 | getWedgePatternIdx( pacContDWedgeRefList, uiPredDirWedgeTabIdx, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye ); |
---|
3714 | return uiPredDirWedgeTabIdx; |
---|
3715 | } |
---|
3716 | |
---|
3717 | return uiPredDirWedgeTabIdx; |
---|
3718 | } |
---|
3719 | |
---|
3720 | Bool TComPrediction::getWedgePatternIdx( WedgeRefList* pcWedgeRefList, UInt& ruiTabIdx, UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe ) |
---|
3721 | { |
---|
3722 | ruiTabIdx = 0; |
---|
3723 | |
---|
3724 | for( UInt uiIdx = 0; uiIdx < pcWedgeRefList->size(); uiIdx++ ) |
---|
3725 | { |
---|
3726 | TComWedgeRef* pcTestWedgeRef = &(pcWedgeRefList->at(uiIdx)); |
---|
3727 | |
---|
3728 | if( pcTestWedgeRef->getStartX() == uhXs && |
---|
3729 | pcTestWedgeRef->getStartY() == uhYs && |
---|
3730 | pcTestWedgeRef->getEndX() == uhXe && |
---|
3731 | pcTestWedgeRef->getEndY() == uhYe ) |
---|
3732 | { |
---|
3733 | ruiTabIdx = pcTestWedgeRef->getRefIdx(); |
---|
3734 | return true; |
---|
3735 | } |
---|
3736 | } |
---|
3737 | |
---|
3738 | return false; |
---|
3739 | } |
---|
3740 | |
---|
3741 | Void TComPrediction::xPredIntraWedgeFull( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder, Bool bDelta, UInt uiTabIdx, Int iDeltaDC1, Int iDeltaDC2 ) |
---|
3742 | { |
---|
3743 | assert( iWidth >= DMM_WEDGEMODEL_MIN_SIZE && iWidth <= DMM_WEDGEMODEL_MAX_SIZE ); |
---|
3744 | WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[iWidth])]; |
---|
3745 | TComWedgelet* pcWedgelet = &(pacWedgeList->at(uiTabIdx)); |
---|
3746 | |
---|
3747 | // get wedge pred DCs |
---|
3748 | Int iPredDC1 = 0; |
---|
3749 | Int iPredDC2 = 0; |
---|
3750 | |
---|
3751 | Int* piMask = pcCU->getPattern()->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); |
---|
3752 | Int iMaskStride = ( iWidth<<1 ) + 1; |
---|
3753 | piMask += iMaskStride+1; |
---|
3754 | getWedgePredDCs( pcWedgelet, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft ); |
---|
3755 | |
---|
3756 | // assign wedge pred DCs to prediction |
---|
3757 | if( bDelta ) { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, Clip( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); } |
---|
3758 | else { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, iPredDC1, iPredDC2 ); } |
---|
3759 | } |
---|
3760 | |
---|
3761 | Void TComPrediction::xPredIntraWedgeDir( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder, Bool bDelta, Int iWedgeDeltaEnd, Int iDeltaDC1, Int iDeltaDC2 ) |
---|
3762 | { |
---|
3763 | assert( iWidth >= DMM_WEDGEMODEL_MIN_SIZE && iWidth <= DMM_WEDGEMODEL_MAX_SIZE ); |
---|
3764 | WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[iWidth])]; |
---|
3765 | |
---|
3766 | // get wedge pattern |
---|
3767 | UInt uiDirWedgeTabIdx = 0; |
---|
3768 | if( bEncoder ) |
---|
3769 | { |
---|
3770 | // encoder: load stored wedge pattern from CU |
---|
3771 | uiDirWedgeTabIdx = pcCU->getWedgePredDirTabIdx( uiAbsPartIdx ); |
---|
3772 | } |
---|
3773 | else |
---|
3774 | { |
---|
3775 | uiDirWedgeTabIdx = getBestContinueWedge( pcCU, uiAbsPartIdx, iWidth, iHeight, iWedgeDeltaEnd ); |
---|
3776 | |
---|
3777 | UInt uiDepth = (pcCU->getDepth(0)) + (pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1); |
---|
3778 | pcCU->setWedgePredDirTabIdxSubParts( uiDirWedgeTabIdx, uiAbsPartIdx, uiDepth ); |
---|
3779 | } |
---|
3780 | TComWedgelet* pcWedgelet = &(pacWedgeList->at(uiDirWedgeTabIdx)); |
---|
3781 | |
---|
3782 | // get wedge pred DCs |
---|
3783 | Int iPredDC1 = 0; |
---|
3784 | Int iPredDC2 = 0; |
---|
3785 | |
---|
3786 | Int* piMask = pcCU->getPattern()->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); |
---|
3787 | Int iMaskStride = ( iWidth<<1 ) + 1; |
---|
3788 | piMask += iMaskStride+1; |
---|
3789 | getWedgePredDCs( pcWedgelet, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft ); |
---|
3790 | |
---|
3791 | // assign wedge pred DCs to prediction |
---|
3792 | if( bDelta ) { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, Clip( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); } |
---|
3793 | else { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, iPredDC1, iPredDC2 ); } |
---|
3794 | } |
---|
3795 | |
---|
3796 | Void TComPrediction::xGetBlockOffset( TComDataCU* pcCU, UInt uiAbsPartIdx, TComDataCU* pcRefCU, UInt uiRefAbsPartIdx, UInt& ruiOffsetX, UInt& ruiOffsetY ) |
---|
3797 | { |
---|
3798 | ruiOffsetX = 0; |
---|
3799 | ruiOffsetY = 0; |
---|
3800 | |
---|
3801 | // get offset between current and above/left block |
---|
3802 | UInt uiThisOriginX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
3803 | UInt uiThisOriginY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
3804 | |
---|
3805 | UInt uiNumPartInRefCU = pcRefCU->getTotalNumPart(); |
---|
3806 | UInt uiMaxDepthRefCU = 0; |
---|
3807 | while( uiNumPartInRefCU > 1 ) |
---|
3808 | { |
---|
3809 | uiNumPartInRefCU >>= 2; |
---|
3810 | uiMaxDepthRefCU++; |
---|
3811 | } |
---|
3812 | |
---|
3813 | UInt uiDepthRefPU = (pcRefCU->getDepth(uiRefAbsPartIdx)) + (pcRefCU->getPartitionSize(uiRefAbsPartIdx) == SIZE_2Nx2N ? 0 : 1); |
---|
3814 | UInt uiShifts = (uiMaxDepthRefCU - uiDepthRefPU)*2; |
---|
3815 | UInt uiRefBlockOriginPartIdx = (uiRefAbsPartIdx>>uiShifts)<<uiShifts; |
---|
3816 | |
---|
3817 | UInt uiRefOriginX = pcRefCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiRefBlockOriginPartIdx] ]; |
---|
3818 | UInt uiRefOriginY = pcRefCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiRefBlockOriginPartIdx] ]; |
---|
3819 | |
---|
3820 | if( (uiThisOriginX - uiRefOriginX) > 0 ) { ruiOffsetX = (UInt)(uiThisOriginX - uiRefOriginX); } |
---|
3821 | if( (uiThisOriginY - uiRefOriginY) > 0 ) { ruiOffsetY = (UInt)(uiThisOriginY - uiRefOriginY); } |
---|
3822 | } |
---|
3823 | |
---|
3824 | Bool TComPrediction::xGetWedgeIntraDirPredData( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiBlockSize, Int& riSlopeX, Int& riSlopeY, UInt& ruiStartPosX, UInt& ruiStartPosY ) |
---|
3825 | { |
---|
3826 | riSlopeX = 0; |
---|
3827 | riSlopeY = 0; |
---|
3828 | ruiStartPosX = 0; |
---|
3829 | ruiStartPosY = 0; |
---|
3830 | |
---|
3831 | // 1st step: get wedge start point (max. slope) |
---|
3832 | Int* piSource = pcCU->getPattern()->getAdiOrgBuf( uiBlockSize, uiBlockSize, m_piYuvExt ); |
---|
3833 | Int iSourceStride = ( uiBlockSize<<1 ) + 1; |
---|
3834 | |
---|
3835 | UInt uiSlopeMaxAbove = 0; |
---|
3836 | UInt uiPosSlopeMaxAbove = 0; |
---|
3837 | for( UInt uiPosHor = 0; uiPosHor < (uiBlockSize-1); uiPosHor++ ) |
---|
3838 | { |
---|
3839 | if( abs( piSource[uiPosHor+1] - piSource[uiPosHor] ) > uiSlopeMaxAbove ) |
---|
3840 | { |
---|
3841 | uiSlopeMaxAbove = abs( piSource[uiPosHor+1] - piSource[uiPosHor] ); |
---|
3842 | uiPosSlopeMaxAbove = uiPosHor; |
---|
3843 | } |
---|
3844 | } |
---|
3845 | |
---|
3846 | UInt uiSlopeMaxLeft = 0; |
---|
3847 | UInt uiPosSlopeMaxLeft = 0; |
---|
3848 | for( UInt uiPosVer = 0; uiPosVer < (uiBlockSize-1); uiPosVer++ ) |
---|
3849 | { |
---|
3850 | if( abs( piSource[(uiPosVer+1)*iSourceStride] - piSource[uiPosVer*iSourceStride] ) > uiSlopeMaxLeft ) |
---|
3851 | { |
---|
3852 | uiSlopeMaxLeft = abs( piSource[(uiPosVer+1)*iSourceStride] - piSource[uiPosVer*iSourceStride] ); |
---|
3853 | uiPosSlopeMaxLeft = uiPosVer; |
---|
3854 | } |
---|
3855 | } |
---|
3856 | |
---|
3857 | if( uiSlopeMaxAbove == 0 && uiSlopeMaxLeft == 0 ) |
---|
3858 | { |
---|
3859 | return false; |
---|
3860 | } |
---|
3861 | |
---|
3862 | if( uiSlopeMaxAbove > uiSlopeMaxLeft ) |
---|
3863 | { |
---|
3864 | ruiStartPosX = uiPosSlopeMaxAbove; |
---|
3865 | ruiStartPosY = 0; |
---|
3866 | } |
---|
3867 | else |
---|
3868 | { |
---|
3869 | ruiStartPosX = 0; |
---|
3870 | ruiStartPosY = uiPosSlopeMaxLeft; |
---|
3871 | } |
---|
3872 | |
---|
3873 | // 2nd step: derive wedge direction |
---|
3874 | Int uiPreds[3] = {-1, -1, -1}; |
---|
3875 | Int iMode = -1; |
---|
3876 | Int iPredNum = pcCU->getIntraDirLumaPredictor( uiAbsPartIdx, uiPreds, &iMode ); |
---|
3877 | |
---|
3878 | UInt uiDirMode = 0; |
---|
3879 | if( iMode >= 0 ) { iPredNum = iMode; } |
---|
3880 | if( iPredNum == 1 ) { uiDirMode = uiPreds[0]; } |
---|
3881 | if( iPredNum == 2 ) { uiDirMode = uiPreds[1]; } |
---|
3882 | |
---|
3883 | if( uiDirMode < 2 ) { return false; } // no planar & DC |
---|
3884 | |
---|
3885 | Bool modeHor = (uiDirMode < 18); |
---|
3886 | Bool modeVer = !modeHor; |
---|
3887 | Int intraPredAngle = modeVer ? (Int)uiDirMode - VER_IDX : modeHor ? -((Int)uiDirMode - HOR_IDX) : 0; |
---|
3888 | Int absAng = abs(intraPredAngle); |
---|
3889 | Int signAng = intraPredAngle < 0 ? -1 : 1; |
---|
3890 | Int angTable[9] = {0,2,5,9,13,17,21,26,32}; |
---|
3891 | absAng = angTable[absAng]; |
---|
3892 | intraPredAngle = signAng * absAng; |
---|
3893 | |
---|
3894 | // 3rd step: set slope for direction |
---|
3895 | if( modeHor ) |
---|
3896 | { |
---|
3897 | if( intraPredAngle > 0 ) |
---|
3898 | { |
---|
3899 | riSlopeX = -32; |
---|
3900 | riSlopeY = intraPredAngle; |
---|
3901 | } |
---|
3902 | else |
---|
3903 | { |
---|
3904 | riSlopeX = 32; |
---|
3905 | riSlopeY = -intraPredAngle; |
---|
3906 | } |
---|
3907 | } |
---|
3908 | else if( modeVer ) |
---|
3909 | { |
---|
3910 | if( intraPredAngle > 0 ) |
---|
3911 | { |
---|
3912 | riSlopeX = intraPredAngle; |
---|
3913 | riSlopeY = -32; |
---|
3914 | } |
---|
3915 | else |
---|
3916 | { |
---|
3917 | riSlopeX = -intraPredAngle; |
---|
3918 | riSlopeY = 32; |
---|
3919 | } |
---|
3920 | } |
---|
3921 | |
---|
3922 | return true; |
---|
3923 | } |
---|
3924 | |
---|
3925 | Void TComPrediction::xGetWedgeIntraDirStartEnd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiBlockSize, Int iDeltaX, Int iDeltaY, UInt uiPMSPosX, UInt uiPMSPosY, UChar& ruhXs, UChar& ruhYs, UChar& ruhXe, UChar& ruhYe, Int iDeltaEnd ) |
---|
3926 | { |
---|
3927 | ruhXs = 0; |
---|
3928 | ruhYs = 0; |
---|
3929 | ruhXe = 0; |
---|
3930 | ruhYe = 0; |
---|
3931 | |
---|
3932 | // scaling of start pos and block size to wedge resolution |
---|
3933 | UInt uiScaledStartPosX = 0; |
---|
3934 | UInt uiScaledStartPosY = 0; |
---|
3935 | UInt uiScaledBlockSize = 0; |
---|
3936 | WedgeResolution eWedgeRes = g_aeWedgeResolutionList[(UInt)g_aucConvertToBit[uiBlockSize]]; |
---|
3937 | switch( eWedgeRes ) |
---|
3938 | { |
---|
3939 | case( DOUBLE_PEL ): { uiScaledStartPosX = (uiPMSPosX>>1); uiScaledStartPosY = (uiPMSPosY>>1); uiScaledBlockSize = (uiBlockSize>>1); break; } |
---|
3940 | case( FULL_PEL ): { uiScaledStartPosX = uiPMSPosX; uiScaledStartPosY = uiPMSPosY; uiScaledBlockSize = uiBlockSize; break; } |
---|
3941 | case( HALF_PEL ): { uiScaledStartPosX = (uiPMSPosX<<1); uiScaledStartPosY = (uiPMSPosY<<1); uiScaledBlockSize = (uiBlockSize<<1); break; } |
---|
3942 | } |
---|
3943 | Int iMaxPos = (Int)uiScaledBlockSize - 1; |
---|
3944 | |
---|
3945 | // case above |
---|
3946 | if( uiScaledStartPosX > 0 && uiScaledStartPosY == 0 ) |
---|
3947 | { |
---|
3948 | ruhXs = (UChar)uiScaledStartPosX; |
---|
3949 | ruhYs = 0; |
---|
3950 | |
---|
3951 | if( iDeltaY == 0 ) |
---|
3952 | { |
---|
3953 | if( iDeltaX < 0 ) |
---|
3954 | { |
---|
3955 | ruhXe = 0; |
---|
3956 | ruhYe = (UChar)std::min( std::max( iDeltaEnd, 0 ), iMaxPos ); |
---|
3957 | return; |
---|
3958 | } |
---|
3959 | else |
---|
3960 | { |
---|
3961 | ruhXe = (UChar)iMaxPos; |
---|
3962 | ruhYe = (UChar)std::min( std::max( -iDeltaEnd, 0 ), iMaxPos ); |
---|
3963 | std::swap( ruhXs, ruhXe ); |
---|
3964 | std::swap( ruhYs, ruhYe ); |
---|
3965 | return; |
---|
3966 | } |
---|
3967 | } |
---|
3968 | |
---|
3969 | // regular case |
---|
3970 | Int iVirtualEndX = (Int)ruhXs + roftoi( (Double)iMaxPos * ((Double)iDeltaX / (Double)iDeltaY) ); |
---|
3971 | |
---|
3972 | if( iVirtualEndX < 0 ) |
---|
3973 | { |
---|
3974 | Int iYe = roftoi( (Double)(0 - (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) ) + iDeltaEnd; |
---|
3975 | if( iYe < (Int)uiScaledBlockSize ) |
---|
3976 | { |
---|
3977 | ruhXe = 0; |
---|
3978 | ruhYe = (UChar)std::max( iYe, 0 ); |
---|
3979 | return; |
---|
3980 | } |
---|
3981 | else |
---|
3982 | { |
---|
3983 | ruhXe = (UChar)std::min( (iYe - iMaxPos), iMaxPos ); |
---|
3984 | ruhYe = (UChar)iMaxPos; |
---|
3985 | return; |
---|
3986 | } |
---|
3987 | } |
---|
3988 | else if( iVirtualEndX > iMaxPos ) |
---|
3989 | { |
---|
3990 | Int iYe = roftoi( (Double)(iMaxPos - (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) ) - iDeltaEnd; |
---|
3991 | if( iYe < (Int)uiScaledBlockSize ) |
---|
3992 | { |
---|
3993 | ruhXe = (UChar)iMaxPos; |
---|
3994 | ruhYe = (UChar)std::max( iYe, 0 ); |
---|
3995 | std::swap( ruhXs, ruhXe ); |
---|
3996 | std::swap( ruhYs, ruhYe ); |
---|
3997 | return; |
---|
3998 | } |
---|
3999 | else |
---|
4000 | { |
---|
4001 | ruhXe = (UChar)std::max( (iMaxPos - (iYe - iMaxPos)), 0 ); |
---|
4002 | ruhYe = (UChar)iMaxPos; |
---|
4003 | return; |
---|
4004 | } |
---|
4005 | } |
---|
4006 | else |
---|
4007 | { |
---|
4008 | Int iXe = iVirtualEndX + iDeltaEnd; |
---|
4009 | if( iXe < 0 ) |
---|
4010 | { |
---|
4011 | ruhXe = 0; |
---|
4012 | ruhYe = (UChar)std::max( (iMaxPos + iXe), 0 ); |
---|
4013 | return; |
---|
4014 | } |
---|
4015 | else if( iXe > iMaxPos ) |
---|
4016 | { |
---|
4017 | ruhXe = (UChar)iMaxPos; |
---|
4018 | ruhYe = (UChar)std::max( (iMaxPos - (iXe - iMaxPos)), 0 ); |
---|
4019 | std::swap( ruhXs, ruhXe ); |
---|
4020 | std::swap( ruhYs, ruhYe ); |
---|
4021 | return; |
---|
4022 | } |
---|
4023 | else |
---|
4024 | { |
---|
4025 | ruhXe = (UChar)iXe; |
---|
4026 | ruhYe = (UChar)iMaxPos; |
---|
4027 | return; |
---|
4028 | } |
---|
4029 | } |
---|
4030 | } |
---|
4031 | |
---|
4032 | // case left |
---|
4033 | if( uiScaledStartPosY > 0 && uiScaledStartPosX == 0 ) |
---|
4034 | { |
---|
4035 | ruhXs = 0; |
---|
4036 | ruhYs = (UChar)uiScaledStartPosY; |
---|
4037 | |
---|
4038 | if( iDeltaX == 0 ) |
---|
4039 | { |
---|
4040 | if( iDeltaY < 0 ) |
---|
4041 | { |
---|
4042 | ruhXe = (UChar)std::min( std::max( -iDeltaEnd, 0 ), iMaxPos ); |
---|
4043 | ruhYe = 0; |
---|
4044 | std::swap( ruhXs, ruhXe ); |
---|
4045 | std::swap( ruhYs, ruhYe ); |
---|
4046 | return; |
---|
4047 | } |
---|
4048 | else |
---|
4049 | { |
---|
4050 | ruhXe = (UChar)std::min( std::max( iDeltaEnd, 0 ), iMaxPos ); |
---|
4051 | ruhYe = (UChar)iMaxPos; |
---|
4052 | return; |
---|
4053 | } |
---|
4054 | } |
---|
4055 | |
---|
4056 | // regular case |
---|
4057 | Int iVirtualEndY = (Int)ruhYs + roftoi( (Double)iMaxPos * ((Double)iDeltaY / (Double)iDeltaX) ); |
---|
4058 | |
---|
4059 | if( iVirtualEndY < 0 ) |
---|
4060 | { |
---|
4061 | Int iXe = roftoi( (Double)(0 - (Int)ruhYs ) * ((Double)iDeltaX / (Double)iDeltaY) ) - iDeltaEnd; |
---|
4062 | if( iXe < (Int)uiScaledBlockSize ) |
---|
4063 | { |
---|
4064 | ruhXe = (UChar)std::max( iXe, 0 ); |
---|
4065 | ruhYe = 0; |
---|
4066 | std::swap( ruhXs, ruhXe ); |
---|
4067 | std::swap( ruhYs, ruhYe ); |
---|
4068 | return; |
---|
4069 | } |
---|
4070 | else |
---|
4071 | { |
---|
4072 | ruhXe = (UChar)iMaxPos; |
---|
4073 | ruhYe = (UChar)std::min( (iXe - iMaxPos), iMaxPos ); |
---|
4074 | std::swap( ruhXs, ruhXe ); |
---|
4075 | std::swap( ruhYs, ruhYe ); |
---|
4076 | return; |
---|
4077 | } |
---|
4078 | } |
---|
4079 | else if( iVirtualEndY > (uiScaledBlockSize-1) ) |
---|
4080 | { |
---|
4081 | Int iXe = roftoi( (Double)((Int)(uiScaledBlockSize-1) - (Int)ruhYs ) * ((Double)iDeltaX / (Double)iDeltaY) ) + iDeltaEnd; |
---|
4082 | if( iXe < (Int)uiScaledBlockSize ) |
---|
4083 | { |
---|
4084 | ruhXe = (UChar)std::max( iXe, 0 ); |
---|
4085 | ruhYe = (UChar)(uiScaledBlockSize-1); |
---|
4086 | return; |
---|
4087 | } |
---|
4088 | else |
---|
4089 | { |
---|
4090 | ruhXe = (UChar)iMaxPos; |
---|
4091 | ruhYe = (UChar)std::max( (iMaxPos - (iXe - iMaxPos)), 0 ); |
---|
4092 | std::swap( ruhXs, ruhXe ); |
---|
4093 | std::swap( ruhYs, ruhYe ); |
---|
4094 | return; |
---|
4095 | } |
---|
4096 | } |
---|
4097 | else |
---|
4098 | { |
---|
4099 | Int iYe = iVirtualEndY - iDeltaEnd; |
---|
4100 | if( iYe < 0 ) |
---|
4101 | { |
---|
4102 | ruhXe = (UChar)std::max( (iMaxPos + iYe), 0 ); |
---|
4103 | ruhYe = 0; |
---|
4104 | std::swap( ruhXs, ruhXe ); |
---|
4105 | std::swap( ruhYs, ruhYe ); |
---|
4106 | return; |
---|
4107 | } |
---|
4108 | else if( iYe > iMaxPos ) |
---|
4109 | { |
---|
4110 | ruhXe = (UChar)std::max( (iMaxPos - (iYe - iMaxPos)), 0 ); |
---|
4111 | ruhYe = (UChar)iMaxPos; |
---|
4112 | return; |
---|
4113 | } |
---|
4114 | else |
---|
4115 | { |
---|
4116 | ruhXe = (UChar)iMaxPos; |
---|
4117 | ruhYe = (UChar)iYe; |
---|
4118 | std::swap( ruhXs, ruhXe ); |
---|
4119 | std::swap( ruhYs, ruhYe ); |
---|
4120 | return; |
---|
4121 | } |
---|
4122 | } |
---|
4123 | } |
---|
4124 | |
---|
4125 | // case origin |
---|
4126 | if( uiScaledStartPosX == 0 && uiScaledStartPosY == 0 ) |
---|
4127 | { |
---|
4128 | if( iDeltaX*iDeltaY < 0 ) |
---|
4129 | { |
---|
4130 | return; |
---|
4131 | } |
---|
4132 | |
---|
4133 | ruhXs = 0; |
---|
4134 | ruhYs = 0; |
---|
4135 | |
---|
4136 | if( iDeltaY == 0 ) |
---|
4137 | { |
---|
4138 | ruhXe = (UChar)iMaxPos; |
---|
4139 | ruhYe = 0; |
---|
4140 | std::swap( ruhXs, ruhXe ); |
---|
4141 | std::swap( ruhYs, ruhYe ); |
---|
4142 | return; |
---|
4143 | } |
---|
4144 | |
---|
4145 | if( iDeltaX == 0 ) |
---|
4146 | { |
---|
4147 | ruhXe = 0; |
---|
4148 | ruhYe = (UChar)iMaxPos; |
---|
4149 | return; |
---|
4150 | } |
---|
4151 | |
---|
4152 | Int iVirtualEndX = (Int)ruhXs + roftoi( (Double)iMaxPos * ((Double)iDeltaX / (Double)iDeltaY) ); |
---|
4153 | |
---|
4154 | if( iVirtualEndX > iMaxPos ) |
---|
4155 | { |
---|
4156 | Int iYe = roftoi( (Double)((Int)iMaxPos - (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) ) - iDeltaEnd; |
---|
4157 | if( iYe < (Int)uiScaledBlockSize ) |
---|
4158 | { |
---|
4159 | ruhXe = (UChar)(uiScaledBlockSize-1); |
---|
4160 | ruhYe = (UChar)std::max( iYe, 0 ); |
---|
4161 | std::swap( ruhXs, ruhXe ); |
---|
4162 | std::swap( ruhYs, ruhYe ); |
---|
4163 | return; |
---|
4164 | } |
---|
4165 | else |
---|
4166 | { |
---|
4167 | ruhXe = (UChar)std::max( (iMaxPos - (iYe - iMaxPos)), 0 ); |
---|
4168 | ruhYe = (UChar)(uiScaledBlockSize-1); |
---|
4169 | return; |
---|
4170 | } |
---|
4171 | } |
---|
4172 | else |
---|
4173 | { |
---|
4174 | Int iXe = iVirtualEndX + iDeltaEnd; |
---|
4175 | if( iXe < 0 ) |
---|
4176 | { |
---|
4177 | ruhXe = 0; |
---|
4178 | ruhYe = (UChar)std::max( (iMaxPos + iXe), 0 ); |
---|
4179 | return; |
---|
4180 | } |
---|
4181 | else if( iXe > iMaxPos ) |
---|
4182 | { |
---|
4183 | ruhXe = (UChar)(uiScaledBlockSize-1); |
---|
4184 | ruhYe = (UChar)std::max( (iMaxPos - (iXe - iMaxPos)), 0 ); |
---|
4185 | std::swap( ruhXs, ruhXe ); |
---|
4186 | std::swap( ruhYs, ruhYe ); |
---|
4187 | return; |
---|
4188 | } |
---|
4189 | else |
---|
4190 | { |
---|
4191 | ruhXe = (UChar)iXe; |
---|
4192 | ruhYe = (UChar)(uiScaledBlockSize-1); |
---|
4193 | return; |
---|
4194 | } |
---|
4195 | } |
---|
4196 | } |
---|
4197 | } |
---|
4198 | #endif |
---|
4199 | |
---|
4200 | Void |
---|
4201 | TComPrediction::predIntraDepthAng(TComPattern* pcTComPattern, UInt uiDirMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight ) |
---|
4202 | { |
---|
4203 | Pel* pDst = piPred; |
---|
4204 | Int* ptrSrc = pcTComPattern->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); |
---|
4205 | Int sw = ( iWidth<<1 ) + 1; |
---|
4206 | xPredIntraAngDepth( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, uiDirMode ); |
---|
4207 | } |
---|
4208 | |
---|
4209 | Int |
---|
4210 | TComPrediction::xGetDCDepth( Int* pSrc, Int iDelta, Int iBlkSize ) |
---|
4211 | { |
---|
4212 | Int iDC = PDM_UNDEFINED_DEPTH; |
---|
4213 | Int iSum = 0; |
---|
4214 | Int iNum = 0; |
---|
4215 | for( Int k = 0; k < iBlkSize; k++, pSrc += iDelta ) |
---|
4216 | { |
---|
4217 | if( *pSrc != PDM_UNDEFINED_DEPTH ) |
---|
4218 | { |
---|
4219 | iSum += *pSrc; |
---|
4220 | iNum ++; |
---|
4221 | } |
---|
4222 | } |
---|
4223 | if( iNum ) |
---|
4224 | { |
---|
4225 | iDC = ( iSum + ( iNum >> 1 ) ) / iNum; |
---|
4226 | } |
---|
4227 | return iDC; |
---|
4228 | } |
---|
4229 | |
---|
4230 | Int |
---|
4231 | TComPrediction::xGetDCValDepth( Int iVal1, Int iVal2, Int iVal3, Int iVal4 ) |
---|
4232 | { |
---|
4233 | if ( iVal1 != PDM_UNDEFINED_DEPTH ) return iVal1; |
---|
4234 | else if( iVal2 != PDM_UNDEFINED_DEPTH ) return iVal2; |
---|
4235 | else if( iVal3 != PDM_UNDEFINED_DEPTH ) return iVal3; |
---|
4236 | return iVal4; |
---|
4237 | } |
---|
4238 | |
---|
4239 | Void |
---|
4240 | TComPrediction::xPredIntraAngDepth( Int* pSrc, Int srcStride, Pel* pDst, Int dstStride, UInt width, UInt height, UInt dirMode ) |
---|
4241 | { |
---|
4242 | AOF( width == height ); |
---|
4243 | Int blkSize = width; |
---|
4244 | Int iDCAbove = xGetDCDepth( pSrc - srcStride, 1, blkSize ); |
---|
4245 | Int iDCAboveRight = xGetDCDepth( pSrc - srcStride + blkSize, 1, blkSize ); |
---|
4246 | Int iDCLeft = xGetDCDepth( pSrc - 1, srcStride, blkSize ); |
---|
4247 | Int iDCBelowLeft = xGetDCDepth( pSrc - 1 + blkSize * srcStride, srcStride, blkSize ); |
---|
4248 | Int iWgt, iDC1, iDC2; |
---|
4249 | if( dirMode < 2 ) // 1..2 |
---|
4250 | { |
---|
4251 | iDC1 = xGetDCValDepth( iDCAbove, iDCAboveRight, iDCLeft, iDCBelowLeft ); |
---|
4252 | iDC2 = xGetDCValDepth( iDCLeft, iDCBelowLeft, iDCAbove, iDCAboveRight ); |
---|
4253 | iWgt = 8; |
---|
4254 | } |
---|
4255 | else if( dirMode < 11 ) // 3..10 |
---|
4256 | { |
---|
4257 | iDC1 = xGetDCValDepth( iDCLeft, iDCBelowLeft, iDCAbove, iDCAboveRight ); |
---|
4258 | iDC2 = xGetDCValDepth( iDCBelowLeft, iDCLeft, iDCAbove, iDCAboveRight ); |
---|
4259 | iWgt = 6 + dirMode; |
---|
4260 | } |
---|
4261 | else if( dirMode < 27 ) // 11..26 |
---|
4262 | { |
---|
4263 | iDC1 = xGetDCValDepth( iDCAbove, iDCAboveRight, iDCLeft, iDCBelowLeft ); |
---|
4264 | iDC2 = xGetDCValDepth( iDCLeft, iDCBelowLeft, iDCAbove, iDCAboveRight ); |
---|
4265 | iWgt = dirMode - 10; |
---|
4266 | } |
---|
4267 | else if( dirMode < 35 ) // 27..34 |
---|
4268 | { |
---|
4269 | iDC1 = xGetDCValDepth( iDCAbove, iDCAboveRight, iDCLeft, iDCBelowLeft ); |
---|
4270 | iDC2 = xGetDCValDepth( iDCAboveRight, iDCAbove, iDCLeft, iDCBelowLeft ); |
---|
4271 | iWgt = 42 - dirMode; |
---|
4272 | } |
---|
4273 | else // (wedgelet -> use simple DC prediction |
---|
4274 | { |
---|
4275 | iDC1 = xGetDCValDepth( iDCAbove, iDCAboveRight, iDCLeft, iDCBelowLeft ); |
---|
4276 | iDC2 = xGetDCValDepth( iDCLeft, iDCBelowLeft, iDCAbove, iDCAboveRight ); |
---|
4277 | iWgt = 8; |
---|
4278 | } |
---|
4279 | Int iWgt2 = 16 - iWgt; |
---|
4280 | Int iDCVal = ( iWgt * iDC1 + iWgt2 * iDC2 + 8 ) >> 4; |
---|
4281 | |
---|
4282 | // set depth |
---|
4283 | for( Int iY = 0; iY < blkSize; iY++, pDst += dstStride ) |
---|
4284 | { |
---|
4285 | for( Int iX = 0; iX < blkSize; iX++ ) |
---|
4286 | { |
---|
4287 | pDst[ iX ] = iDCVal; |
---|
4288 | } |
---|
4289 | } |
---|
4290 | } |
---|
4291 | |
---|
4292 | //! \} |
---|