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