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