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