1 | |
---|
2 | |
---|
3 | /** \file TComPrediction.cpp |
---|
4 | \brief prediction class |
---|
5 | */ |
---|
6 | |
---|
7 | #include <memory.h> |
---|
8 | #include "TComPrediction.h" |
---|
9 | |
---|
10 | // ==================================================================================================================== |
---|
11 | // Constructor / destructor / initialize |
---|
12 | // ==================================================================================================================== |
---|
13 | |
---|
14 | TComPrediction::TComPrediction() |
---|
15 | : m_pLumaRecBuffer(0) |
---|
16 | { |
---|
17 | m_piYuvExt = NULL; |
---|
18 | } |
---|
19 | |
---|
20 | TComPrediction::~TComPrediction() |
---|
21 | { |
---|
22 | m_cYuvExt.destroy(); |
---|
23 | |
---|
24 | delete[] m_piYuvExt; |
---|
25 | |
---|
26 | m_acYuvPred[0].destroy(); |
---|
27 | m_acYuvPred[1].destroy(); |
---|
28 | |
---|
29 | m_cYuvPredTemp.destroy(); |
---|
30 | |
---|
31 | #if LM_CHROMA |
---|
32 | if( m_pLumaRecBuffer ) |
---|
33 | delete [] m_pLumaRecBuffer; |
---|
34 | #endif |
---|
35 | } |
---|
36 | |
---|
37 | Void TComPrediction::initTempBuff() |
---|
38 | { |
---|
39 | if( m_piYuvExt == NULL ) |
---|
40 | { |
---|
41 | m_iYuvExtHeight = ((g_uiMaxCUHeight + 2) << 4); |
---|
42 | m_iYuvExtStride = ((g_uiMaxCUWidth + 8) << 4); |
---|
43 | m_cYuvExt.create( m_iYuvExtStride, m_iYuvExtHeight ); |
---|
44 | m_piYuvExt = new Int[ m_iYuvExtStride * m_iYuvExtHeight ]; |
---|
45 | |
---|
46 | // new structure |
---|
47 | m_acYuvPred[0] .create( g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
48 | m_acYuvPred[1] .create( g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
49 | |
---|
50 | m_cYuvPredTemp.create( g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
51 | } |
---|
52 | |
---|
53 | #if LM_CHROMA |
---|
54 | m_iLumaRecStride = (g_uiMaxCUWidth>>1) + 1; |
---|
55 | m_pLumaRecBuffer = new Pel[ m_iLumaRecStride * m_iLumaRecStride ]; |
---|
56 | |
---|
57 | for( Int i = 1; i < 66; i++ ) |
---|
58 | m_uiaShift[i-1] = ( (1 << 15) + i/2 ) / i; |
---|
59 | #endif |
---|
60 | } |
---|
61 | |
---|
62 | // ==================================================================================================================== |
---|
63 | // Public member functions |
---|
64 | // ==================================================================================================================== |
---|
65 | |
---|
66 | // Function for calculating DC value of the reference samples used in Intra prediction |
---|
67 | Pel TComPrediction::predIntraGetPredValDC( Int* pSrc, Int iSrcStride, UInt iWidth, UInt iHeight, Bool bAbove, Bool bLeft ) |
---|
68 | { |
---|
69 | Int iInd, iSum = 0; |
---|
70 | Pel pDcVal; |
---|
71 | |
---|
72 | if (bAbove) |
---|
73 | { |
---|
74 | for (iInd = 0;iInd < iWidth;iInd++) |
---|
75 | iSum += pSrc[iInd-iSrcStride]; |
---|
76 | } |
---|
77 | if (bLeft) |
---|
78 | { |
---|
79 | for (iInd = 0;iInd < iHeight;iInd++) |
---|
80 | iSum += pSrc[iInd*iSrcStride-1]; |
---|
81 | } |
---|
82 | |
---|
83 | if (bAbove && bLeft) |
---|
84 | pDcVal = (iSum + iWidth) / (iWidth + iHeight); |
---|
85 | else if (bAbove) |
---|
86 | pDcVal = (iSum + iWidth/2) / iWidth; |
---|
87 | else if (bLeft) |
---|
88 | pDcVal = (iSum + iHeight/2) / iHeight; |
---|
89 | else |
---|
90 | pDcVal = pSrc[-1]; // Default DC value already calculated and placed in the prediction array if no neighbors are available |
---|
91 | |
---|
92 | return pDcVal; |
---|
93 | } |
---|
94 | |
---|
95 | // Function for deriving the angular Intra predictions |
---|
96 | |
---|
97 | /** Function for deriving the simplified angular intra predictions. |
---|
98 | * \param pSrc pointer to reconstructed sample array |
---|
99 | * \param srcStride the stride of the reconstructed sample array |
---|
100 | * \param rpDst reference to pointer for the prediction sample array |
---|
101 | * \param dstStride the stride of the prediction sample array |
---|
102 | * \param width the width of the block |
---|
103 | * \param height the height of the block |
---|
104 | * \param dirMode the intra prediction mode index |
---|
105 | * \param blkAboveAvailable boolean indication if the block above is available |
---|
106 | * \param blkLeftAvailable boolean indication if the block to the left is available |
---|
107 | * |
---|
108 | * This function derives the prediction samples for the angular mode based on the prediction direction indicated by |
---|
109 | * the prediction mode index. The prediction direction is given by the displacement of the bottom row of the block and |
---|
110 | * the reference row above the block in the case of vertical prediction or displacement of the rightmost column |
---|
111 | * of the block and reference column left from the block in the case of the horizontal prediction. The displacement |
---|
112 | * is signalled at 1/32 pixel accuracy. When projection of the predicted pixel falls inbetween reference samples, |
---|
113 | * the predicted value for the pixel is linearly interpolated from the reference samples. All reference samples are taken |
---|
114 | * from the extended main reference. |
---|
115 | */ |
---|
116 | Void TComPrediction::xPredIntraAng( Int* pSrc, Int srcStride, Pel*& rpDst, Int dstStride, UInt width, UInt height, UInt dirMode, Bool blkAboveAvailable, Bool blkLeftAvailable ) |
---|
117 | { |
---|
118 | Int k,l; |
---|
119 | Int blkSize = width; |
---|
120 | Pel* pDst = rpDst; |
---|
121 | |
---|
122 | // Map the mode index to main prediction direction and angle |
---|
123 | Bool modeDC = dirMode == 0; |
---|
124 | Bool modeVer = !modeDC && (dirMode < 18); |
---|
125 | Bool modeHor = !modeDC && !modeVer; |
---|
126 | Int intraPredAngle = modeVer ? dirMode - 9 : modeHor ? dirMode - 25 : 0; |
---|
127 | Int absAng = abs(intraPredAngle); |
---|
128 | Int signAng = intraPredAngle < 0 ? -1 : 1; |
---|
129 | |
---|
130 | // Set bitshifts and scale the angle parameter to block size |
---|
131 | Int angTable[9] = {0, 2, 5, 9, 13, 17, 21, 26, 32}; |
---|
132 | Int invAngTable[9] = {0, 4096, 1638, 910, 630, 482, 390, 315, 256}; // (256 * 32) / Angle |
---|
133 | Int invAngle = invAngTable[absAng]; |
---|
134 | absAng = angTable[absAng]; |
---|
135 | intraPredAngle = signAng * absAng; |
---|
136 | |
---|
137 | // Do the DC prediction |
---|
138 | if (modeDC) |
---|
139 | { |
---|
140 | Pel dcval = predIntraGetPredValDC(pSrc, srcStride, width, height, blkAboveAvailable, blkLeftAvailable); |
---|
141 | |
---|
142 | for (k=0;k<blkSize;k++) |
---|
143 | { |
---|
144 | for (l=0;l<blkSize;l++) |
---|
145 | { |
---|
146 | pDst[k*dstStride+l] = dcval; |
---|
147 | } |
---|
148 | } |
---|
149 | } |
---|
150 | |
---|
151 | // Do angular predictions |
---|
152 | else |
---|
153 | { |
---|
154 | Pel* refMain; |
---|
155 | Pel* refSide; |
---|
156 | Pel refAbove[2*MAX_CU_SIZE+1]; |
---|
157 | Pel refLeft[2*MAX_CU_SIZE+1]; |
---|
158 | |
---|
159 | // Initialise the Main and Left reference array. |
---|
160 | if (intraPredAngle < 0) |
---|
161 | { |
---|
162 | for (k=0;k<blkSize+1;k++) |
---|
163 | { |
---|
164 | refAbove[k+blkSize-1] = pSrc[k-srcStride-1]; |
---|
165 | } |
---|
166 | for (k=0;k<blkSize+1;k++) |
---|
167 | { |
---|
168 | refLeft[k+blkSize-1] = pSrc[(k-1)*srcStride-1]; |
---|
169 | } |
---|
170 | refMain = (modeVer ? refAbove : refLeft) + (blkSize-1); |
---|
171 | refSide = (modeVer ? refLeft : refAbove) + (blkSize-1); |
---|
172 | |
---|
173 | // Extend the Main reference to the left. |
---|
174 | Int invAngleSum = 128; // rounding for (shift by 8) |
---|
175 | for (k=-1; k>blkSize*intraPredAngle>>5; k--) |
---|
176 | { |
---|
177 | invAngleSum += invAngle; |
---|
178 | refMain[k] = refSide[invAngleSum>>8]; |
---|
179 | } |
---|
180 | } |
---|
181 | else |
---|
182 | { |
---|
183 | for (k=0;k<2*blkSize+1;k++) |
---|
184 | { |
---|
185 | refAbove[k] = pSrc[k-srcStride-1]; |
---|
186 | } |
---|
187 | for (k=0;k<2*blkSize+1;k++) |
---|
188 | { |
---|
189 | refLeft[k] = pSrc[(k-1)*srcStride-1]; |
---|
190 | } |
---|
191 | refMain = modeVer ? refAbove : refLeft; |
---|
192 | } |
---|
193 | |
---|
194 | if (intraPredAngle == 0) |
---|
195 | { |
---|
196 | for (k=0;k<blkSize;k++) |
---|
197 | { |
---|
198 | for (l=0;l<blkSize;l++) |
---|
199 | { |
---|
200 | pDst[k*dstStride+l] = refMain[l+1]; |
---|
201 | } |
---|
202 | } |
---|
203 | } |
---|
204 | else |
---|
205 | { |
---|
206 | Int deltaPos=0; |
---|
207 | Int deltaInt; |
---|
208 | Int deltaFract; |
---|
209 | Int refMainIndex; |
---|
210 | |
---|
211 | for (k=0;k<blkSize;k++) |
---|
212 | { |
---|
213 | deltaPos += intraPredAngle; |
---|
214 | deltaInt = deltaPos >> 5; |
---|
215 | deltaFract = deltaPos & (32 - 1); |
---|
216 | |
---|
217 | if (deltaFract) |
---|
218 | { |
---|
219 | // Do linear filtering |
---|
220 | for (l=0;l<blkSize;l++) |
---|
221 | { |
---|
222 | refMainIndex = l+deltaInt+1; |
---|
223 | pDst[k*dstStride+l] = (Pel) ( ((32-deltaFract)*refMain[refMainIndex]+deltaFract*refMain[refMainIndex+1]+16) >> 5 ); |
---|
224 | } |
---|
225 | } |
---|
226 | else |
---|
227 | { |
---|
228 | // Just copy the integer samples |
---|
229 | for (l=0;l<blkSize;l++) |
---|
230 | { |
---|
231 | pDst[k*dstStride+l] = refMain[l+deltaInt+1]; |
---|
232 | } |
---|
233 | } |
---|
234 | } |
---|
235 | } |
---|
236 | |
---|
237 | // Flip the block if this is the horizontal mode |
---|
238 | if (modeHor) |
---|
239 | { |
---|
240 | Pel tmp; |
---|
241 | for (k=0;k<blkSize-1;k++) |
---|
242 | { |
---|
243 | for (l=k+1;l<blkSize;l++) |
---|
244 | { |
---|
245 | tmp = pDst[k*dstStride+l]; |
---|
246 | pDst[k*dstStride+l] = pDst[l*dstStride+k]; |
---|
247 | pDst[l*dstStride+k] = tmp; |
---|
248 | } |
---|
249 | } |
---|
250 | } |
---|
251 | } |
---|
252 | } |
---|
253 | |
---|
254 | Void TComPrediction::predIntraLumaAng(TComPattern* pcTComPattern, UInt uiDirMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, TComDataCU* pcCU, Bool bAbove, Bool bLeft ) |
---|
255 | { |
---|
256 | Pel *pDst = piPred; |
---|
257 | Int *ptrSrc; |
---|
258 | |
---|
259 | // only assign variable in debug mode |
---|
260 | #ifndef NDEBUG |
---|
261 | // get intra direction |
---|
262 | Int iIntraSizeIdx = g_aucConvertToBit[ iWidth ] + 1; |
---|
263 | |
---|
264 | assert( iIntraSizeIdx >= 1 ); // 4x 4 |
---|
265 | assert( iIntraSizeIdx <= 6 ); // 128x128 |
---|
266 | assert( iWidth == iHeight ); |
---|
267 | #endif //NDEBUG |
---|
268 | |
---|
269 | #if QC_MDIS |
---|
270 | #if HHI_DISABLE_INTRA_SMOOTHING_DEPTH |
---|
271 | ptrSrc = pcTComPattern->getPredictorPtr( uiDirMode, g_aucConvertToBit[ iWidth ] + 1, iWidth, iHeight, m_piYuvExt, pcCU->getSlice()->getSPS()->isDepth() ); |
---|
272 | #else |
---|
273 | ptrSrc = pcTComPattern->getPredictorPtr( uiDirMode, g_aucConvertToBit[ iWidth ] + 1, iWidth, iHeight, m_piYuvExt ); |
---|
274 | #endif |
---|
275 | #else |
---|
276 | ptrSrc = pcTComPattern->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); |
---|
277 | #endif //QC_MDIS |
---|
278 | |
---|
279 | // get starting pixel in block |
---|
280 | Int sw = ( iWidth<<1 ) + 1; |
---|
281 | |
---|
282 | #if ADD_PLANAR_MODE |
---|
283 | if ( uiDirMode == PLANAR_IDX ) |
---|
284 | { |
---|
285 | #if REFERENCE_SAMPLE_PADDING |
---|
286 | xPredIntraPlanar( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight ); |
---|
287 | #else |
---|
288 | xPredIntraPlanar( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, bAbove, bLeft ); |
---|
289 | #endif |
---|
290 | return; |
---|
291 | } |
---|
292 | #endif |
---|
293 | |
---|
294 | // get converted direction |
---|
295 | uiDirMode = g_aucAngIntraModeOrder[ uiDirMode ]; |
---|
296 | |
---|
297 | // Create the prediction |
---|
298 | xPredIntraAng( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, uiDirMode, bAbove, bLeft ); |
---|
299 | |
---|
300 | #if MN_DC_PRED_FILTER |
---|
301 | if ((uiDirMode == 0) && pcTComPattern->getDCPredFilterFlag()) |
---|
302 | xDCPredFiltering( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight); |
---|
303 | #endif |
---|
304 | } |
---|
305 | |
---|
306 | |
---|
307 | Void |
---|
308 | TComPrediction::predIntraDepthAng(TComPattern* pcTComPattern, UInt uiDirMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight ) |
---|
309 | { |
---|
310 | Pel* pDst = piPred; |
---|
311 | Int* ptrSrc = pcTComPattern->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); |
---|
312 | Int sw = ( iWidth<<1 ) + 1; |
---|
313 | uiDirMode = g_aucAngIntraModeOrder[ uiDirMode ]; |
---|
314 | xPredIntraAngDepth( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, uiDirMode ); |
---|
315 | } |
---|
316 | |
---|
317 | Int |
---|
318 | TComPrediction::xGetDCDepth( Int* pSrc, Int iDelta, Int iBlkSize ) |
---|
319 | { |
---|
320 | Int iDC = PDM_UNDEFINED_DEPTH; |
---|
321 | Int iSum = 0; |
---|
322 | Int iNum = 0; |
---|
323 | for( Int k = 0; k < iBlkSize; k++, pSrc += iDelta ) |
---|
324 | { |
---|
325 | if( *pSrc != PDM_UNDEFINED_DEPTH ) |
---|
326 | { |
---|
327 | iSum += *pSrc; |
---|
328 | iNum ++; |
---|
329 | } |
---|
330 | } |
---|
331 | if( iNum ) |
---|
332 | { |
---|
333 | iDC = ( iSum + ( iNum >> 1 ) ) / iNum; |
---|
334 | } |
---|
335 | return iDC; |
---|
336 | } |
---|
337 | |
---|
338 | Int |
---|
339 | TComPrediction::xGetDCValDepth( Int iVal1, Int iVal2, Int iVal3, Int iVal4 ) |
---|
340 | { |
---|
341 | if ( iVal1 != PDM_UNDEFINED_DEPTH ) return iVal1; |
---|
342 | else if( iVal2 != PDM_UNDEFINED_DEPTH ) return iVal2; |
---|
343 | else if( iVal3 != PDM_UNDEFINED_DEPTH ) return iVal3; |
---|
344 | return iVal4; |
---|
345 | } |
---|
346 | |
---|
347 | Void |
---|
348 | TComPrediction::xPredIntraAngDepth( Int* pSrc, Int srcStride, Pel* pDst, Int dstStride, UInt width, UInt height, UInt dirMode ) |
---|
349 | { |
---|
350 | AOF( width == height ); |
---|
351 | Int blkSize = width; |
---|
352 | Int iDCAbove = xGetDCDepth( pSrc - srcStride, 1, blkSize ); |
---|
353 | Int iDCAboveRight = xGetDCDepth( pSrc - srcStride + blkSize, 1, blkSize ); |
---|
354 | Int iDCLeft = xGetDCDepth( pSrc - 1, srcStride, blkSize ); |
---|
355 | Int iDCBelowLeft = xGetDCDepth( pSrc - 1 + blkSize * srcStride, srcStride, blkSize ); |
---|
356 | Int iWgt, iDC1, iDC2; |
---|
357 | if( dirMode == 0 ) // 0 |
---|
358 | { |
---|
359 | iDC1 = xGetDCValDepth( iDCAbove, iDCAboveRight, iDCLeft, iDCBelowLeft ); |
---|
360 | iDC2 = xGetDCValDepth( iDCLeft, iDCBelowLeft, iDCAbove, iDCAboveRight ); |
---|
361 | iWgt = 8; |
---|
362 | } |
---|
363 | else if( dirMode < 10 ) // 1..9 |
---|
364 | { |
---|
365 | iDC1 = xGetDCValDepth( iDCAbove, iDCAboveRight, iDCLeft, iDCBelowLeft ); |
---|
366 | iDC2 = xGetDCValDepth( iDCLeft, iDCBelowLeft, iDCAbove, iDCAboveRight ); |
---|
367 | iWgt = 7 + dirMode; |
---|
368 | } |
---|
369 | else if( dirMode < 18 ) // 10..17 |
---|
370 | { |
---|
371 | iDC1 = xGetDCValDepth( iDCAbove, iDCAboveRight, iDCLeft, iDCBelowLeft ); |
---|
372 | iDC2 = xGetDCValDepth( iDCAboveRight, iDCAbove, iDCLeft, iDCBelowLeft ); |
---|
373 | iWgt = 25 - dirMode; |
---|
374 | } |
---|
375 | else if( dirMode < 26 ) // 18..25 |
---|
376 | { |
---|
377 | iDC1 = xGetDCValDepth( iDCAbove, iDCAboveRight, iDCLeft, iDCBelowLeft ); |
---|
378 | iDC2 = xGetDCValDepth( iDCLeft, iDCBelowLeft, iDCAbove, iDCAboveRight ); |
---|
379 | iWgt = 25 - dirMode; |
---|
380 | } |
---|
381 | else if( dirMode < 34 ) // 26..33 |
---|
382 | { |
---|
383 | iDC1 = xGetDCValDepth( iDCLeft, iDCBelowLeft, iDCAbove, iDCAboveRight ); |
---|
384 | iDC2 = xGetDCValDepth( iDCBelowLeft, iDCLeft, iDCAbove, iDCAboveRight ); |
---|
385 | iWgt = 41 - dirMode; |
---|
386 | } |
---|
387 | else // 34 (wedgelet -> use simple DC prediction |
---|
388 | { |
---|
389 | iDC1 = xGetDCValDepth( iDCAbove, iDCAboveRight, iDCLeft, iDCBelowLeft ); |
---|
390 | iDC2 = xGetDCValDepth( iDCLeft, iDCBelowLeft, iDCAbove, iDCAboveRight ); |
---|
391 | iWgt = 8; |
---|
392 | } |
---|
393 | Int iWgt2 = 16 - iWgt; |
---|
394 | Int iDCVal = ( iWgt * iDC1 + iWgt2 * iDC2 + 8 ) >> 4; |
---|
395 | |
---|
396 | // set depth |
---|
397 | for( Int iY = 0; iY < blkSize; iY++, pDst += dstStride ) |
---|
398 | { |
---|
399 | for( Int iX = 0; iX < blkSize; iX++ ) |
---|
400 | { |
---|
401 | pDst[ iX ] = iDCVal; |
---|
402 | } |
---|
403 | } |
---|
404 | } |
---|
405 | |
---|
406 | |
---|
407 | // Angular chroma |
---|
408 | Void TComPrediction::predIntraChromaAng( TComPattern* pcTComPattern, Int* piSrc, UInt uiDirMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, TComDataCU* pcCU, Bool bAbove, Bool bLeft ) |
---|
409 | { |
---|
410 | Pel *pDst = piPred; |
---|
411 | Int *ptrSrc = piSrc; |
---|
412 | |
---|
413 | // get starting pixel in block |
---|
414 | Int sw = ( iWidth<<1 ) + 1; |
---|
415 | |
---|
416 | #if ADD_PLANAR_MODE |
---|
417 | if ( uiDirMode == PLANAR_IDX ) |
---|
418 | { |
---|
419 | #if REFERENCE_SAMPLE_PADDING |
---|
420 | xPredIntraPlanar( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight ); |
---|
421 | #else |
---|
422 | xPredIntraPlanar( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, bAbove, bLeft ); |
---|
423 | #endif |
---|
424 | return; |
---|
425 | } |
---|
426 | #endif |
---|
427 | |
---|
428 | // get converted direction |
---|
429 | uiDirMode = g_aucAngIntraModeOrder[ uiDirMode ]; |
---|
430 | |
---|
431 | // Create the prediction |
---|
432 | xPredIntraAng( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, uiDirMode, bAbove, bLeft ); |
---|
433 | } |
---|
434 | |
---|
435 | #if HHI_DMM_INTRA |
---|
436 | Void TComPrediction::predIntraLumaDMM( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder ) |
---|
437 | { |
---|
438 | if( uiMode == DMM_WEDGE_FULL_IDX ) { xPredIntraWedgeFull ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, false, pcCU->getWedgeFullTabIdx ( uiAbsPartIdx ) ); } |
---|
439 | 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 ) ); } |
---|
440 | if( uiMode == DMM_WEDGE_PREDDIR_IDX ) { xPredIntraWedgeDir ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, false, pcCU->getWedgePredDirDeltaEnd( uiAbsPartIdx ) ); } |
---|
441 | 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 ) ); } |
---|
442 | if( uiMode == DMM_WEDGE_PREDTEX_IDX ) { xPredIntraWedgeTex ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, false ); } |
---|
443 | if( uiMode == DMM_WEDGE_PREDTEX_D_IDX ) { xPredIntraWedgeTex ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, true, pcCU->getWedgePredTexDeltaDC1( uiAbsPartIdx ), pcCU->getWedgePredTexDeltaDC2( uiAbsPartIdx ) ); } |
---|
444 | if( uiMode == DMM_CONTOUR_PREDTEX_IDX ) { xPredIntraContourTex ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, false ); } |
---|
445 | if( uiMode == DMM_CONTOUR_PREDTEX_D_IDX ) { xPredIntraContourTex ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, true, pcCU->getContourPredTexDeltaDC1( uiAbsPartIdx ), pcCU->getContourPredTexDeltaDC2( uiAbsPartIdx ) ); } |
---|
446 | } |
---|
447 | |
---|
448 | Void TComPrediction::xDeltaDCQuantScaleUp( TComDataCU* pcCU, Int& riDeltaDC ) |
---|
449 | { |
---|
450 | Int iSign = riDeltaDC < 0 ? -1 : 1; |
---|
451 | UInt uiAbs = abs( riDeltaDC ); |
---|
452 | |
---|
453 | Int iQp = pcCU->getQP(0); |
---|
454 | Int iMax = ( 1<<( g_uiBitDepth + g_uiBitIncrement - 1) ); |
---|
455 | Double dStepSize = Clip3( 1, iMax, pow( 2.0, iQp/10.0 + g_dDeltaDCsQuantOffset ) ); |
---|
456 | |
---|
457 | riDeltaDC = iSign * roftoi( uiAbs * dStepSize ); |
---|
458 | return; |
---|
459 | } |
---|
460 | |
---|
461 | 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 ) |
---|
462 | { |
---|
463 | assert( iWidth >= DMM_WEDGEMODEL_MIN_SIZE && iWidth <= DMM_WEDGEMODEL_MAX_SIZE ); |
---|
464 | WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[iWidth])]; |
---|
465 | TComWedgelet* pcWedgelet = &(pacWedgeList->at(uiTabIdx)); |
---|
466 | |
---|
467 | // get wedge pred DCs |
---|
468 | Int iPredDC1 = 0; |
---|
469 | Int iPredDC2 = 0; |
---|
470 | |
---|
471 | Int* piMask = pcCU->getPattern()->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); |
---|
472 | Int iMaskStride = ( iWidth<<1 ) + 1; |
---|
473 | piMask += iMaskStride+1; |
---|
474 | getWedgePredDCs( pcWedgelet, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft ); |
---|
475 | |
---|
476 | if( bDelta ) |
---|
477 | { |
---|
478 | xDeltaDCQuantScaleUp( pcCU, iDeltaDC1 ); |
---|
479 | xDeltaDCQuantScaleUp( pcCU, iDeltaDC2 ); |
---|
480 | } |
---|
481 | |
---|
482 | // assign wedge pred DCs to prediction |
---|
483 | if( bDelta ) { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, Clip( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); } |
---|
484 | else { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, iPredDC1, iPredDC2 ); } |
---|
485 | } |
---|
486 | |
---|
487 | Void TComPrediction::getWedgePredDCs( TComWedgelet* pcWedgelet, Int* piMask, Int iMaskStride, Int& riPredDC1, Int& riPredDC2, Bool bAbove, Bool bLeft ) |
---|
488 | { |
---|
489 | riPredDC1 = ( 1<<( g_uiBitDepth + g_uiBitIncrement - 1) ); //pred val, if no neighbors are available |
---|
490 | riPredDC2 = ( 1<<( g_uiBitDepth + g_uiBitIncrement - 1) ); |
---|
491 | |
---|
492 | if( !bAbove && !bLeft ) { return; } |
---|
493 | |
---|
494 | UInt uiNumSmpDC1 = 0, uiNumSmpDC2 = 0; |
---|
495 | Int iPredDC1 = 0, iPredDC2 = 0; |
---|
496 | |
---|
497 | Bool* pabWedgePattern = pcWedgelet->getPattern(); |
---|
498 | UInt uiWedgeStride = pcWedgelet->getStride(); |
---|
499 | |
---|
500 | if( bAbove ) |
---|
501 | { |
---|
502 | for( Int k = 0; k < pcWedgelet->getWidth(); k++ ) |
---|
503 | { |
---|
504 | if( true == pabWedgePattern[k] ) |
---|
505 | { |
---|
506 | iPredDC2 += piMask[k-iMaskStride]; |
---|
507 | uiNumSmpDC2++; |
---|
508 | } |
---|
509 | else |
---|
510 | { |
---|
511 | iPredDC1 += piMask[k-iMaskStride]; |
---|
512 | uiNumSmpDC1++; |
---|
513 | } |
---|
514 | } |
---|
515 | } |
---|
516 | if( bLeft ) |
---|
517 | { |
---|
518 | for( Int k = 0; k < pcWedgelet->getHeight(); k++ ) |
---|
519 | { |
---|
520 | if( true == pabWedgePattern[k*uiWedgeStride] ) |
---|
521 | { |
---|
522 | iPredDC2 += piMask[k*iMaskStride-1]; |
---|
523 | uiNumSmpDC2++; |
---|
524 | } |
---|
525 | else |
---|
526 | { |
---|
527 | iPredDC1 += piMask[k*iMaskStride-1]; |
---|
528 | uiNumSmpDC1++; |
---|
529 | } |
---|
530 | } |
---|
531 | } |
---|
532 | |
---|
533 | if( uiNumSmpDC1 > 0 ) |
---|
534 | { |
---|
535 | iPredDC1 /= uiNumSmpDC1; |
---|
536 | riPredDC1 = iPredDC1; |
---|
537 | } |
---|
538 | if( uiNumSmpDC2 > 0 ) |
---|
539 | { |
---|
540 | iPredDC2 /= uiNumSmpDC2; |
---|
541 | riPredDC2 = iPredDC2; |
---|
542 | } |
---|
543 | } |
---|
544 | |
---|
545 | Void TComPrediction::getBestContourFromText( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, TComWedgelet* pcContourWedge ) |
---|
546 | { |
---|
547 | pcContourWedge->clear(); |
---|
548 | Bool* pabContourPattern = pcContourWedge->getPattern(); |
---|
549 | |
---|
550 | // get copy of according texture luma block |
---|
551 | UInt uiPartAddr = 0; |
---|
552 | Int iBlockWidth, iBlockHeight; |
---|
553 | |
---|
554 | pcCU->getPartIndexAndSize( uiAbsPartIdx, uiPartAddr, iBlockWidth, iBlockHeight ); |
---|
555 | |
---|
556 | TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getTexturePic()->getPicYuvRec(); |
---|
557 | Int iRefStride = pcPicYuvRef->getStride(); |
---|
558 | Pel* piRefY = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ); |
---|
559 | |
---|
560 | TComYuv cTempYuv; cTempYuv.create( pcCU->getWidth(0), pcCU->getHeight(0) ); cTempYuv.clear(); |
---|
561 | UInt uiTempStride = cTempYuv.getStride(); |
---|
562 | Pel* piTempY = cTempYuv.getLumaAddr( uiAbsPartIdx, uiWidth ); |
---|
563 | |
---|
564 | for ( Int y = 0; y < iBlockHeight; y++ ) |
---|
565 | { |
---|
566 | ::memcpy(piTempY, piRefY, sizeof(Pel)*iBlockWidth); |
---|
567 | piTempY += uiTempStride; |
---|
568 | piRefY += iRefStride; |
---|
569 | } |
---|
570 | piTempY = cTempYuv.getLumaAddr( uiAbsPartIdx, uiWidth ); |
---|
571 | |
---|
572 | // find contour for texture luma block |
---|
573 | UInt iDC = 0; |
---|
574 | for( UInt k = 0; k < (iBlockWidth*iBlockHeight); k++ ) { iDC += piTempY[k]; } |
---|
575 | iDC /= (iBlockWidth*iBlockHeight); |
---|
576 | |
---|
577 | for( UInt k = 0; k < (iBlockWidth*iBlockHeight); k++ ) |
---|
578 | { |
---|
579 | pabContourPattern[k] = (piTempY[k] > iDC) ? true : false; |
---|
580 | } |
---|
581 | |
---|
582 | cTempYuv.destroy(); |
---|
583 | } |
---|
584 | |
---|
585 | UInt TComPrediction::getBestContinueWedge( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Int iDeltaEnd ) |
---|
586 | { |
---|
587 | UInt uiThisBlockSize = uiWidth; |
---|
588 | assert( uiThisBlockSize >= DMM_WEDGEMODEL_MIN_SIZE && uiThisBlockSize <= DMM_WEDGEMODEL_MAX_SIZE ); |
---|
589 | WedgeList* pacContDWedgeList = &g_aacWedgeLists [(g_aucConvertToBit[uiThisBlockSize])]; |
---|
590 | WedgeRefList* pacContDWedgeRefList = &g_aacWedgeRefLists[(g_aucConvertToBit[uiThisBlockSize])]; |
---|
591 | |
---|
592 | UInt uiPredDirWedgeTabIdx = 0; |
---|
593 | TComDataCU* pcTempCU; |
---|
594 | UInt uiTempPartIdx; |
---|
595 | // 1st: try continue above wedgelet |
---|
596 | pcTempCU = pcCU->getPUAbove( uiTempPartIdx, pcCU->getZorderIdxInCU() + uiAbsPartIdx ); |
---|
597 | if( pcTempCU ) |
---|
598 | { |
---|
599 | UChar uhLumaIntraDir = pcTempCU->getLumaIntraDir( uiTempPartIdx ); |
---|
600 | if( DMM_WEDGE_FULL_IDX == uhLumaIntraDir || |
---|
601 | DMM_WEDGE_FULL_D_IDX == uhLumaIntraDir || |
---|
602 | DMM_WEDGE_PREDDIR_IDX == uhLumaIntraDir || |
---|
603 | DMM_WEDGE_PREDDIR_D_IDX == uhLumaIntraDir || |
---|
604 | DMM_WEDGE_PREDTEX_IDX == uhLumaIntraDir || |
---|
605 | DMM_WEDGE_PREDTEX_D_IDX == uhLumaIntraDir ) |
---|
606 | { |
---|
607 | UInt uiRefWedgeSize = (UInt)g_aucIntraSizeIdxToWedgeSize[pcTempCU->getIntraSizeIdx( uiTempPartIdx )]; |
---|
608 | WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiRefWedgeSize])]; |
---|
609 | |
---|
610 | // get offset between current and reference block |
---|
611 | UInt uiOffsetX = 0; |
---|
612 | UInt uiOffsetY = 0; |
---|
613 | xGetBlockOffset( pcCU, uiAbsPartIdx, pcTempCU, uiTempPartIdx, uiOffsetX, uiOffsetY ); |
---|
614 | |
---|
615 | // get reference wedgelet |
---|
616 | UInt uiRefWedgeTabIdx = 0; |
---|
617 | switch( uhLumaIntraDir ) |
---|
618 | { |
---|
619 | case( DMM_WEDGE_FULL_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgeFullTabIdx ( uiTempPartIdx ); } break; |
---|
620 | case( DMM_WEDGE_FULL_D_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgeFullTabIdx ( uiTempPartIdx ); } break; |
---|
621 | case( DMM_WEDGE_PREDDIR_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredDirTabIdx( uiTempPartIdx ); } break; |
---|
622 | case( DMM_WEDGE_PREDDIR_D_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredDirTabIdx( uiTempPartIdx ); } break; |
---|
623 | case( DMM_WEDGE_PREDTEX_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredTexTabIdx( uiTempPartIdx ); } break; |
---|
624 | case( DMM_WEDGE_PREDTEX_D_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredTexTabIdx( uiTempPartIdx ); } break; |
---|
625 | default: { assert( 0 ); return uiPredDirWedgeTabIdx; } |
---|
626 | } |
---|
627 | TComWedgelet* pcRefWedgelet; |
---|
628 | pcRefWedgelet = &(pacWedgeList->at( uiRefWedgeTabIdx )); |
---|
629 | |
---|
630 | // find reference wedgelet, if direction is suitable for continue wedge |
---|
631 | if( pcRefWedgelet->checkPredDirAbovePossible( uiThisBlockSize, uiOffsetX ) ) |
---|
632 | { |
---|
633 | UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye; |
---|
634 | pcRefWedgelet->getPredDirStartEndAbove( uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, uiThisBlockSize, uiOffsetX, iDeltaEnd ); |
---|
635 | getWedgeListIdx( pacContDWedgeList, pacContDWedgeRefList, uiPredDirWedgeTabIdx, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye ); |
---|
636 | return uiPredDirWedgeTabIdx; |
---|
637 | } |
---|
638 | } |
---|
639 | } |
---|
640 | |
---|
641 | // 2nd: try continue left wedglelet |
---|
642 | pcTempCU = pcCU->getPULeft( uiTempPartIdx, pcCU->getZorderIdxInCU() + uiAbsPartIdx ); |
---|
643 | if( pcTempCU ) |
---|
644 | { |
---|
645 | UChar uhLumaIntraDir = pcTempCU->getLumaIntraDir( uiTempPartIdx ); |
---|
646 | if( DMM_WEDGE_FULL_IDX == uhLumaIntraDir || |
---|
647 | DMM_WEDGE_FULL_D_IDX == uhLumaIntraDir || |
---|
648 | DMM_WEDGE_PREDDIR_IDX == uhLumaIntraDir || |
---|
649 | DMM_WEDGE_PREDDIR_D_IDX == uhLumaIntraDir || |
---|
650 | DMM_WEDGE_PREDTEX_IDX == uhLumaIntraDir || |
---|
651 | DMM_WEDGE_PREDTEX_D_IDX == uhLumaIntraDir ) |
---|
652 | { |
---|
653 | UInt uiRefWedgeSize = (UInt)g_aucIntraSizeIdxToWedgeSize[pcTempCU->getIntraSizeIdx( uiTempPartIdx )]; |
---|
654 | WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiRefWedgeSize])]; |
---|
655 | |
---|
656 | // get offset between current and reference block |
---|
657 | UInt uiOffsetX = 0; |
---|
658 | UInt uiOffsetY = 0; |
---|
659 | xGetBlockOffset( pcCU, uiAbsPartIdx, pcTempCU, uiTempPartIdx, uiOffsetX, uiOffsetY ); |
---|
660 | |
---|
661 | // get reference wedgelet |
---|
662 | UInt uiRefWedgeTabIdx = 0; |
---|
663 | switch( uhLumaIntraDir ) |
---|
664 | { |
---|
665 | case( DMM_WEDGE_FULL_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgeFullTabIdx ( uiTempPartIdx ); } break; |
---|
666 | case( DMM_WEDGE_FULL_D_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgeFullTabIdx ( uiTempPartIdx ); } break; |
---|
667 | case( DMM_WEDGE_PREDDIR_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredDirTabIdx( uiTempPartIdx ); } break; |
---|
668 | case( DMM_WEDGE_PREDDIR_D_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredDirTabIdx( uiTempPartIdx ); } break; |
---|
669 | case( DMM_WEDGE_PREDTEX_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredTexTabIdx( uiTempPartIdx ); } break; |
---|
670 | case( DMM_WEDGE_PREDTEX_D_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredTexTabIdx( uiTempPartIdx ); } break; |
---|
671 | default: { assert( 0 ); return uiPredDirWedgeTabIdx; } |
---|
672 | } |
---|
673 | TComWedgelet* pcRefWedgelet; |
---|
674 | pcRefWedgelet = &(pacWedgeList->at( uiRefWedgeTabIdx )); |
---|
675 | |
---|
676 | // find reference wedgelet, if direction is suitable for continue wedge |
---|
677 | if( pcRefWedgelet->checkPredDirLeftPossible( uiThisBlockSize, uiOffsetY ) ) |
---|
678 | { |
---|
679 | UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye; |
---|
680 | pcRefWedgelet->getPredDirStartEndLeft( uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, uiThisBlockSize, uiOffsetY, iDeltaEnd ); |
---|
681 | getWedgeListIdx( pacContDWedgeList, pacContDWedgeRefList, uiPredDirWedgeTabIdx, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye ); |
---|
682 | return uiPredDirWedgeTabIdx; |
---|
683 | } |
---|
684 | } |
---|
685 | } |
---|
686 | |
---|
687 | // 3rd: (default) make wedglet from intra dir and max slope point |
---|
688 | Int iSlopeX = 0; |
---|
689 | Int iSlopeY = 0; |
---|
690 | UInt uiStartPosX = 0; |
---|
691 | UInt uiStartPosY = 0; |
---|
692 | if( xGetWedgeIntraDirPredData( pcCU, uiAbsPartIdx, uiThisBlockSize, iSlopeX, iSlopeY, uiStartPosX, uiStartPosY ) ) |
---|
693 | { |
---|
694 | UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye; |
---|
695 | xGetWedgeIntraDirStartEnd( pcCU, uiAbsPartIdx, uiThisBlockSize, iSlopeX, iSlopeY, uiStartPosX, uiStartPosY, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, iDeltaEnd ); |
---|
696 | getWedgeListIdx( pacContDWedgeList, pacContDWedgeRefList, uiPredDirWedgeTabIdx, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye ); |
---|
697 | return uiPredDirWedgeTabIdx; |
---|
698 | } |
---|
699 | |
---|
700 | return uiPredDirWedgeTabIdx; |
---|
701 | } |
---|
702 | |
---|
703 | Void TComPrediction::xGetBlockOffset( TComDataCU* pcCU, UInt uiAbsPartIdx, TComDataCU* pcRefCU, UInt uiRefAbsPartIdx, UInt& ruiOffsetX, UInt& ruiOffsetY ) |
---|
704 | { |
---|
705 | ruiOffsetX = 0; |
---|
706 | ruiOffsetY = 0; |
---|
707 | |
---|
708 | // get offset between current and above/left block |
---|
709 | UInt uiThisOriginX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
710 | UInt uiThisOriginY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
711 | |
---|
712 | UInt uiNumPartInRefCU = pcRefCU->getTotalNumPart(); |
---|
713 | UInt uiMaxDepthRefCU = 0; |
---|
714 | while( uiNumPartInRefCU > 1 ) |
---|
715 | { |
---|
716 | uiNumPartInRefCU >>= 2; |
---|
717 | uiMaxDepthRefCU++; |
---|
718 | } |
---|
719 | |
---|
720 | UInt uiDepthRefPU = (pcRefCU->getDepth(uiRefAbsPartIdx)) + (pcRefCU->getPartitionSize(uiRefAbsPartIdx) == SIZE_2Nx2N ? 0 : 1); |
---|
721 | UInt uiShifts = (uiMaxDepthRefCU - uiDepthRefPU)*2; |
---|
722 | UInt uiRefBlockOriginPartIdx = (uiRefAbsPartIdx>>uiShifts)<<uiShifts; |
---|
723 | |
---|
724 | UInt uiRefOriginX = pcRefCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiRefBlockOriginPartIdx] ]; |
---|
725 | UInt uiRefOriginY = pcRefCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiRefBlockOriginPartIdx] ]; |
---|
726 | |
---|
727 | if( (uiThisOriginX - uiRefOriginX) > 0 ) { ruiOffsetX = (UInt)(uiThisOriginX - uiRefOriginX); } |
---|
728 | if( (uiThisOriginY - uiRefOriginY) > 0 ) { ruiOffsetY = (UInt)(uiThisOriginY - uiRefOriginY); } |
---|
729 | } |
---|
730 | |
---|
731 | Bool TComPrediction::xGetWedgeIntraDirPredData( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiBlockSize, Int& riSlopeX, Int& riSlopeY, UInt& ruiStartPosX, UInt& ruiStartPosY ) |
---|
732 | { |
---|
733 | riSlopeX = 0; |
---|
734 | riSlopeY = 0; |
---|
735 | ruiStartPosX = 0; |
---|
736 | ruiStartPosY = 0; |
---|
737 | |
---|
738 | // 1st step: get wedge start point (max. slope) |
---|
739 | Int* piSource = pcCU->getPattern()->getAdiOrgBuf( uiBlockSize, uiBlockSize, m_piYuvExt ); |
---|
740 | Int iSourceStride = ( uiBlockSize<<1 ) + 1; |
---|
741 | |
---|
742 | UInt uiSlopeMaxAbove = 0; |
---|
743 | UInt uiPosSlopeMaxAbove = 0; |
---|
744 | for( UInt uiPosHor = 0; uiPosHor < (uiBlockSize-1); uiPosHor++ ) |
---|
745 | { |
---|
746 | if( abs( piSource[uiPosHor+1] - piSource[uiPosHor] ) > uiSlopeMaxAbove ) |
---|
747 | { |
---|
748 | uiSlopeMaxAbove = abs( piSource[uiPosHor+1] - piSource[uiPosHor] ); |
---|
749 | uiPosSlopeMaxAbove = uiPosHor; |
---|
750 | } |
---|
751 | } |
---|
752 | |
---|
753 | UInt uiSlopeMaxLeft = 0; |
---|
754 | UInt uiPosSlopeMaxLeft = 0; |
---|
755 | for( UInt uiPosVer = 0; uiPosVer < (uiBlockSize-1); uiPosVer++ ) |
---|
756 | { |
---|
757 | if( abs( piSource[(uiPosVer+1)*iSourceStride] - piSource[uiPosVer*iSourceStride] ) > uiSlopeMaxLeft ) |
---|
758 | { |
---|
759 | uiSlopeMaxLeft = abs( piSource[(uiPosVer+1)*iSourceStride] - piSource[uiPosVer*iSourceStride] ); |
---|
760 | uiPosSlopeMaxLeft = uiPosVer; |
---|
761 | } |
---|
762 | } |
---|
763 | |
---|
764 | if( uiSlopeMaxAbove == 0 && uiSlopeMaxLeft == 0 ) |
---|
765 | { |
---|
766 | return false; |
---|
767 | } |
---|
768 | |
---|
769 | if( uiSlopeMaxAbove > uiSlopeMaxLeft ) |
---|
770 | { |
---|
771 | ruiStartPosX = uiPosSlopeMaxAbove; |
---|
772 | ruiStartPosY = 0; |
---|
773 | } |
---|
774 | else |
---|
775 | { |
---|
776 | ruiStartPosX = 0; |
---|
777 | ruiStartPosY = uiPosSlopeMaxLeft; |
---|
778 | } |
---|
779 | |
---|
780 | // 2nd step: derive wedge direction |
---|
781 | Int angTable[9] = {0,2,5,9,13,17,21,26,32}; |
---|
782 | |
---|
783 | Int uiPreds[2] = {-1, -1}; |
---|
784 | Int uiPredNum = pcCU->getIntraDirLumaPredictor( uiAbsPartIdx, uiPreds ); |
---|
785 | |
---|
786 | UInt uiDirMode = 0; |
---|
787 | if( uiPredNum == 1 ) |
---|
788 | { |
---|
789 | uiDirMode = g_aucAngIntraModeOrder[uiPreds[0]]; |
---|
790 | } |
---|
791 | else if( uiPredNum == 2 ) |
---|
792 | { |
---|
793 | uiDirMode = g_aucAngIntraModeOrder[uiPreds[1]]; |
---|
794 | } |
---|
795 | |
---|
796 | if( uiDirMode == 0 ) |
---|
797 | { |
---|
798 | return false; |
---|
799 | } |
---|
800 | |
---|
801 | Bool modeVer = (uiDirMode < 18); |
---|
802 | Bool modeHor = !modeVer; |
---|
803 | Int intraPredAngle = modeVer ? uiDirMode - 9 : modeHor ? uiDirMode - 25 : 0; |
---|
804 | Int absAng = abs(intraPredAngle); |
---|
805 | Int signAng = intraPredAngle < 0 ? -1 : 1; |
---|
806 | absAng = angTable[absAng]; |
---|
807 | intraPredAngle = signAng * absAng; |
---|
808 | |
---|
809 | // 3rd step: set slope for direction |
---|
810 | if( modeHor ) |
---|
811 | { |
---|
812 | if( intraPredAngle > 0 ) |
---|
813 | { |
---|
814 | riSlopeX = -32; |
---|
815 | riSlopeY = intraPredAngle; |
---|
816 | } |
---|
817 | else |
---|
818 | { |
---|
819 | riSlopeX = 32; |
---|
820 | riSlopeY = -intraPredAngle; |
---|
821 | } |
---|
822 | } |
---|
823 | else if( modeVer ) |
---|
824 | { |
---|
825 | if( intraPredAngle > 0 ) |
---|
826 | { |
---|
827 | riSlopeX = intraPredAngle; |
---|
828 | riSlopeY = -32; |
---|
829 | } |
---|
830 | else |
---|
831 | { |
---|
832 | riSlopeX = -intraPredAngle; |
---|
833 | riSlopeY = 32; |
---|
834 | } |
---|
835 | } |
---|
836 | |
---|
837 | return true; |
---|
838 | } |
---|
839 | |
---|
840 | 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 ) |
---|
841 | { |
---|
842 | ruhXs = 0; |
---|
843 | ruhYs = 0; |
---|
844 | ruhXe = 0; |
---|
845 | ruhYe = 0; |
---|
846 | UInt uiOri; |
---|
847 | |
---|
848 | // scaling of start pos and block size to wedge resolution |
---|
849 | UInt uiScaledStartPosX = 0; |
---|
850 | UInt uiScaledStartPosY = 0; |
---|
851 | UInt uiScaledBlockSize = 0; |
---|
852 | WedgeResolution eWedgeRes = g_aeWedgeResolutionList[(UInt)g_aucConvertToBit[uiBlockSize]]; |
---|
853 | switch( eWedgeRes ) |
---|
854 | { |
---|
855 | case( DOUBLE_PEL ): { uiScaledStartPosX = (uiPMSPosX>>1); uiScaledStartPosY = (uiPMSPosY>>1); uiScaledBlockSize = (uiBlockSize>>1); break; } |
---|
856 | case( FULL_PEL ): { uiScaledStartPosX = uiPMSPosX; uiScaledStartPosY = uiPMSPosY; uiScaledBlockSize = uiBlockSize; break; } |
---|
857 | case( HALF_PEL ): { uiScaledStartPosX = (uiPMSPosX<<1); uiScaledStartPosY = (uiPMSPosY<<1); uiScaledBlockSize = (uiBlockSize<<1); break; } |
---|
858 | } |
---|
859 | |
---|
860 | // case above |
---|
861 | if( uiScaledStartPosX > 0 && uiScaledStartPosY == 0 ) |
---|
862 | { |
---|
863 | ruhXs = (UChar)uiScaledStartPosX; |
---|
864 | ruhYs = 0; |
---|
865 | |
---|
866 | if( iDeltaY == 0 ) |
---|
867 | { |
---|
868 | if( iDeltaX < 0 ) |
---|
869 | { |
---|
870 | uiOri = 0; |
---|
871 | ruhXe = 0; |
---|
872 | ruhYe = (UChar)Min( Max( iDeltaEnd, 0 ), (uiScaledBlockSize-1) ); |
---|
873 | return; |
---|
874 | } |
---|
875 | else |
---|
876 | { |
---|
877 | uiOri = 1; |
---|
878 | ruhXe = (UChar)(uiScaledBlockSize-1); ; |
---|
879 | ruhYe = (UChar)Min( Max( -iDeltaEnd, 0 ), (uiScaledBlockSize-1) ); |
---|
880 | std::swap( ruhXs, ruhXe ); |
---|
881 | std::swap( ruhYs, ruhYe ); |
---|
882 | return; |
---|
883 | } |
---|
884 | } |
---|
885 | |
---|
886 | // regular case |
---|
887 | Int iVirtualEndX = (Int)ruhXs + roftoi( (Double)(uiScaledBlockSize-1) * ((Double)iDeltaX / (Double)iDeltaY) ); |
---|
888 | |
---|
889 | if( iVirtualEndX < 0 ) |
---|
890 | { |
---|
891 | Int iYe = roftoi( (Double)(0 - (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) ) + iDeltaEnd; |
---|
892 | if( iYe < (Int)uiScaledBlockSize ) |
---|
893 | { |
---|
894 | uiOri = 0; |
---|
895 | ruhXe = 0; |
---|
896 | ruhYe = (UChar)Max( iYe, 0 ); |
---|
897 | return; |
---|
898 | } |
---|
899 | else |
---|
900 | { |
---|
901 | uiOri = 4; |
---|
902 | ruhXe = (UChar)Min( (iYe - (uiScaledBlockSize-1)), (uiScaledBlockSize-1) ); |
---|
903 | ruhYe = (UChar)(uiScaledBlockSize-1); |
---|
904 | return; |
---|
905 | } |
---|
906 | } |
---|
907 | else if( iVirtualEndX > (uiScaledBlockSize-1) ) |
---|
908 | { |
---|
909 | Int iYe = roftoi( (Double)((Int)(uiScaledBlockSize-1) - (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) ) - iDeltaEnd; |
---|
910 | if( iYe < (Int)uiScaledBlockSize ) |
---|
911 | { |
---|
912 | uiOri = 1; |
---|
913 | ruhXe = (UChar)(uiScaledBlockSize-1); |
---|
914 | ruhYe = (UChar)Max( iYe, 0 ); |
---|
915 | std::swap( ruhXs, ruhXe ); |
---|
916 | std::swap( ruhYs, ruhYe ); |
---|
917 | return; |
---|
918 | } |
---|
919 | else |
---|
920 | { |
---|
921 | uiOri = 4; |
---|
922 | ruhXe = (UChar)Max( ((uiScaledBlockSize-1) - (iYe - (uiScaledBlockSize-1))), 0 ); |
---|
923 | ruhYe = (UChar)(uiScaledBlockSize-1); |
---|
924 | return; |
---|
925 | } |
---|
926 | } |
---|
927 | else |
---|
928 | { |
---|
929 | Int iXe = iVirtualEndX + iDeltaEnd; |
---|
930 | if( iXe < 0 ) |
---|
931 | { |
---|
932 | uiOri = 0; |
---|
933 | ruhXe = 0; |
---|
934 | ruhYe = (UChar)Max( ((uiScaledBlockSize-1) + iXe), 0 ); |
---|
935 | return; |
---|
936 | } |
---|
937 | else if( iXe > (uiScaledBlockSize-1) ) |
---|
938 | { |
---|
939 | uiOri = 1; |
---|
940 | ruhXe = (UChar)(uiScaledBlockSize-1); |
---|
941 | ruhYe = (UChar)Max( ((uiScaledBlockSize-1) - (iXe - (uiScaledBlockSize-1))), 0 ); |
---|
942 | std::swap( ruhXs, ruhXe ); |
---|
943 | std::swap( ruhYs, ruhYe ); |
---|
944 | return; |
---|
945 | } |
---|
946 | else |
---|
947 | { |
---|
948 | uiOri = 4; |
---|
949 | ruhXe = (UChar)iXe; |
---|
950 | ruhYe = (UChar)(uiScaledBlockSize-1); |
---|
951 | return; |
---|
952 | } |
---|
953 | } |
---|
954 | } |
---|
955 | |
---|
956 | // case left |
---|
957 | if( uiScaledStartPosY > 0 && uiScaledStartPosX == 0 ) |
---|
958 | { |
---|
959 | ruhXs = 0; |
---|
960 | ruhYs = (UChar)uiScaledStartPosY; |
---|
961 | |
---|
962 | if( iDeltaX == 0 ) |
---|
963 | { |
---|
964 | if( iDeltaY < 0 ) |
---|
965 | { |
---|
966 | uiOri = 0; |
---|
967 | ruhXe = (UChar)Min( Max( -iDeltaEnd, 0 ), (uiScaledBlockSize-1) ); |
---|
968 | ruhYe = 0; |
---|
969 | std::swap( ruhXs, ruhXe ); |
---|
970 | std::swap( ruhYs, ruhYe ); |
---|
971 | return; |
---|
972 | } |
---|
973 | else |
---|
974 | { |
---|
975 | uiOri = 3; |
---|
976 | ruhXe = (UChar)Min( Max( iDeltaEnd, 0 ), (uiScaledBlockSize-1) ); |
---|
977 | ruhYe = (UChar)(uiScaledBlockSize-1); |
---|
978 | return; |
---|
979 | } |
---|
980 | } |
---|
981 | |
---|
982 | // regular case |
---|
983 | Int iVirtualEndY = (Int)ruhYs + roftoi( (Double)(uiScaledBlockSize-1) * ((Double)iDeltaY / (Double)iDeltaX) ); |
---|
984 | |
---|
985 | if( iVirtualEndY < 0 ) |
---|
986 | { |
---|
987 | Int iXe = roftoi( (Double)(0 - (Int)ruhYs ) * ((Double)iDeltaX / (Double)iDeltaY) ) - iDeltaEnd; |
---|
988 | if( iXe < (Int)uiScaledBlockSize ) |
---|
989 | { |
---|
990 | uiOri = 0; |
---|
991 | ruhXe = (UChar)Max( iXe, 0 ); |
---|
992 | ruhYe = 0; |
---|
993 | std::swap( ruhXs, ruhXe ); |
---|
994 | std::swap( ruhYs, ruhYe ); |
---|
995 | return; |
---|
996 | } |
---|
997 | else |
---|
998 | { |
---|
999 | uiOri = 5; |
---|
1000 | ruhXe = (UChar)(uiScaledBlockSize-1); |
---|
1001 | ruhYe = (UChar)Min( (iXe - (uiScaledBlockSize-1)), (uiScaledBlockSize-1) ); |
---|
1002 | std::swap( ruhXs, ruhXe ); |
---|
1003 | std::swap( ruhYs, ruhYe ); |
---|
1004 | return; |
---|
1005 | } |
---|
1006 | } |
---|
1007 | else if( iVirtualEndY > (uiScaledBlockSize-1) ) |
---|
1008 | { |
---|
1009 | Int iXe = roftoi( (Double)((Int)(uiScaledBlockSize-1) - (Int)ruhYs ) * ((Double)iDeltaX / (Double)iDeltaY) ) + iDeltaEnd; |
---|
1010 | if( iXe < (Int)uiScaledBlockSize ) |
---|
1011 | { |
---|
1012 | uiOri = 3; |
---|
1013 | ruhXe = (UChar)Max( iXe, 0 ); |
---|
1014 | ruhYe = (UChar)(uiScaledBlockSize-1); |
---|
1015 | return; |
---|
1016 | } |
---|
1017 | else |
---|
1018 | { |
---|
1019 | uiOri = 5; |
---|
1020 | ruhXe = (UChar)(uiScaledBlockSize-1); |
---|
1021 | ruhYe = (UChar)Max( ((uiScaledBlockSize-1) - (iXe - (uiScaledBlockSize-1))), 0 ); |
---|
1022 | std::swap( ruhXs, ruhXe ); |
---|
1023 | std::swap( ruhYs, ruhYe ); |
---|
1024 | return; |
---|
1025 | } |
---|
1026 | } |
---|
1027 | else |
---|
1028 | { |
---|
1029 | Int iYe = iVirtualEndY - iDeltaEnd; |
---|
1030 | if( iYe < 0 ) |
---|
1031 | { |
---|
1032 | uiOri = 0; |
---|
1033 | ruhXe = (UChar)Max( ((uiScaledBlockSize-1) + iYe), 0 ); |
---|
1034 | ruhYe = 0; |
---|
1035 | std::swap( ruhXs, ruhXe ); |
---|
1036 | std::swap( ruhYs, ruhYe ); |
---|
1037 | return; |
---|
1038 | } |
---|
1039 | else if( iYe > (uiScaledBlockSize-1) ) |
---|
1040 | { |
---|
1041 | uiOri = 3; |
---|
1042 | ruhXe = (UChar)Max( ((uiScaledBlockSize-1) - (iYe - (uiScaledBlockSize-1))), 0 ); |
---|
1043 | ruhYe = (UChar)(uiScaledBlockSize-1); |
---|
1044 | return; |
---|
1045 | } |
---|
1046 | else |
---|
1047 | { |
---|
1048 | uiOri = 5; |
---|
1049 | ruhXe = (UChar)(uiScaledBlockSize-1); |
---|
1050 | ruhYe = (UChar)iYe; |
---|
1051 | std::swap( ruhXs, ruhXe ); |
---|
1052 | std::swap( ruhYs, ruhYe ); |
---|
1053 | return; |
---|
1054 | } |
---|
1055 | } |
---|
1056 | } |
---|
1057 | |
---|
1058 | // case origin |
---|
1059 | if( uiScaledStartPosX == 0 && uiScaledStartPosY == 0 ) |
---|
1060 | { |
---|
1061 | if( iDeltaX*iDeltaY < 0 ) |
---|
1062 | { |
---|
1063 | return; |
---|
1064 | } |
---|
1065 | |
---|
1066 | ruhXs = 0; |
---|
1067 | ruhYs = 0; |
---|
1068 | |
---|
1069 | if( iDeltaY == 0 ) |
---|
1070 | { |
---|
1071 | uiOri = 1; |
---|
1072 | ruhXe = (UChar)(uiScaledBlockSize-1); |
---|
1073 | ruhYe = 0; |
---|
1074 | std::swap( ruhXs, ruhXe ); |
---|
1075 | std::swap( ruhYs, ruhYe ); |
---|
1076 | return; |
---|
1077 | } |
---|
1078 | |
---|
1079 | if( iDeltaX == 0 ) |
---|
1080 | { |
---|
1081 | uiOri = 0; |
---|
1082 | ruhXe = 0; |
---|
1083 | ruhYe = (UChar)(uiScaledBlockSize-1); |
---|
1084 | return; |
---|
1085 | } |
---|
1086 | |
---|
1087 | Int iVirtualEndX = (Int)ruhXs + roftoi( (Double)(uiScaledBlockSize-1) * ((Double)iDeltaX / (Double)iDeltaY) ); |
---|
1088 | |
---|
1089 | if( iVirtualEndX > (uiScaledBlockSize-1) ) |
---|
1090 | { |
---|
1091 | Int iYe = roftoi( (Double)((Int)(uiScaledBlockSize-1) - (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) ) - iDeltaEnd; |
---|
1092 | if( iYe < (Int)uiScaledBlockSize ) |
---|
1093 | { |
---|
1094 | uiOri = 1; |
---|
1095 | ruhXe = (UChar)(uiScaledBlockSize-1); |
---|
1096 | ruhYe = (UChar)Max( iYe, 0 ); |
---|
1097 | std::swap( ruhXs, ruhXe ); |
---|
1098 | std::swap( ruhYs, ruhYe ); |
---|
1099 | return; |
---|
1100 | } |
---|
1101 | else |
---|
1102 | { |
---|
1103 | uiOri = 3; |
---|
1104 | ruhXe = (UChar)Max( ((uiScaledBlockSize-1) - (iYe - (uiScaledBlockSize-1))), 0 ); |
---|
1105 | ruhYe = (UChar)(uiScaledBlockSize-1); |
---|
1106 | return; |
---|
1107 | } |
---|
1108 | } |
---|
1109 | else |
---|
1110 | { |
---|
1111 | Int iXe = iVirtualEndX + iDeltaEnd; |
---|
1112 | if( iXe < 0 ) |
---|
1113 | { |
---|
1114 | uiOri = 0; |
---|
1115 | ruhXe = 0; |
---|
1116 | ruhYe = (UChar)Max( ((uiScaledBlockSize-1) + iXe), 0 ); |
---|
1117 | return; |
---|
1118 | } |
---|
1119 | else if( iXe > (uiScaledBlockSize-1) ) |
---|
1120 | { |
---|
1121 | uiOri = 1; |
---|
1122 | ruhXe = (UChar)(uiScaledBlockSize-1); |
---|
1123 | ruhYe = (UChar)Max( ((uiScaledBlockSize-1) - (iXe - (uiScaledBlockSize-1))), 0 ); |
---|
1124 | std::swap( ruhXs, ruhXe ); |
---|
1125 | std::swap( ruhYs, ruhYe ); |
---|
1126 | return; |
---|
1127 | } |
---|
1128 | else |
---|
1129 | { |
---|
1130 | uiOri = 3; |
---|
1131 | ruhXe = (UChar)iXe; |
---|
1132 | ruhYe = (UChar)(uiScaledBlockSize-1); |
---|
1133 | return; |
---|
1134 | } |
---|
1135 | } |
---|
1136 | } |
---|
1137 | } |
---|
1138 | |
---|
1139 | Bool TComPrediction::getWedgeListIdx( WedgeList* pcWedgeList, WedgeRefList* pcWedgeRefList, UInt& ruiTabIdx, UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe ) |
---|
1140 | { |
---|
1141 | ruiTabIdx = 0; |
---|
1142 | |
---|
1143 | for( UInt uiIdx = 0; uiIdx < pcWedgeList->size(); uiIdx++ ) |
---|
1144 | { |
---|
1145 | TComWedgelet* pcTestWedge = &(pcWedgeList->at(uiIdx)); |
---|
1146 | |
---|
1147 | if( pcTestWedge->getStartX() == uhXs && |
---|
1148 | pcTestWedge->getStartY() == uhYs && |
---|
1149 | pcTestWedge->getEndX() == uhXe && |
---|
1150 | pcTestWedge->getEndY() == uhYe ) |
---|
1151 | { |
---|
1152 | ruiTabIdx = uiIdx; |
---|
1153 | return true; |
---|
1154 | } |
---|
1155 | } |
---|
1156 | |
---|
1157 | // additionally search in WedgeRef lists of duplicated patterns |
---|
1158 | for( UInt uiIdx = 0; uiIdx < pcWedgeRefList->size(); uiIdx++ ) |
---|
1159 | { |
---|
1160 | TComWedgeRef* pcTestWedgeRef = &(pcWedgeRefList->at(uiIdx)); |
---|
1161 | |
---|
1162 | if( pcTestWedgeRef->getStartX() == uhXs && |
---|
1163 | pcTestWedgeRef->getStartY() == uhYs && |
---|
1164 | pcTestWedgeRef->getEndX() == uhXe && |
---|
1165 | pcTestWedgeRef->getEndY() == uhYe ) |
---|
1166 | { |
---|
1167 | ruiTabIdx = pcTestWedgeRef->getRefIdx(); |
---|
1168 | return true; |
---|
1169 | } |
---|
1170 | } |
---|
1171 | |
---|
1172 | return false; |
---|
1173 | } |
---|
1174 | |
---|
1175 | 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 ) |
---|
1176 | { |
---|
1177 | assert( iWidth >= DMM_WEDGEMODEL_MIN_SIZE && iWidth <= DMM_WEDGEMODEL_MAX_SIZE ); |
---|
1178 | WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[iWidth])]; |
---|
1179 | |
---|
1180 | // get wedge pattern |
---|
1181 | UInt uiDirWedgeTabIdx = 0; |
---|
1182 | if( bEncoder ) |
---|
1183 | { |
---|
1184 | // encoder: load stored wedge pattern from CU |
---|
1185 | uiDirWedgeTabIdx = pcCU->getWedgePredDirTabIdx( uiAbsPartIdx ); |
---|
1186 | } |
---|
1187 | else |
---|
1188 | { |
---|
1189 | uiDirWedgeTabIdx = getBestContinueWedge( pcCU, uiAbsPartIdx, iWidth, iHeight, iWedgeDeltaEnd ); |
---|
1190 | |
---|
1191 | UInt uiDepth = (pcCU->getDepth(0)) + (pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1); |
---|
1192 | pcCU->setWedgePredDirTabIdxSubParts( uiDirWedgeTabIdx, uiAbsPartIdx, uiDepth ); |
---|
1193 | } |
---|
1194 | TComWedgelet* pcWedgelet = &(pacWedgeList->at(uiDirWedgeTabIdx)); |
---|
1195 | |
---|
1196 | // get wedge pred DCs |
---|
1197 | Int iPredDC1 = 0; |
---|
1198 | Int iPredDC2 = 0; |
---|
1199 | |
---|
1200 | Int* piMask = pcCU->getPattern()->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); |
---|
1201 | Int iMaskStride = ( iWidth<<1 ) + 1; |
---|
1202 | piMask += iMaskStride+1; |
---|
1203 | getWedgePredDCs( pcWedgelet, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft ); |
---|
1204 | |
---|
1205 | if( bDelta ) |
---|
1206 | { |
---|
1207 | xDeltaDCQuantScaleUp( pcCU, iDeltaDC1 ); |
---|
1208 | xDeltaDCQuantScaleUp( pcCU, iDeltaDC2 ); |
---|
1209 | } |
---|
1210 | |
---|
1211 | // assign wedge pred DCs to prediction |
---|
1212 | if( bDelta ) { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, Clip ( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); } |
---|
1213 | else { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, iPredDC1, iPredDC2 ); } |
---|
1214 | } |
---|
1215 | |
---|
1216 | 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 ) |
---|
1217 | { |
---|
1218 | assert( iWidth >= DMM_WEDGEMODEL_MIN_SIZE && iWidth <= DMM_WEDGEMODEL_MAX_SIZE ); |
---|
1219 | WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[iWidth])]; |
---|
1220 | |
---|
1221 | // get wedge pattern |
---|
1222 | UInt uiTextureWedgeTabIdx = 0; |
---|
1223 | if( bEncoder ) |
---|
1224 | { |
---|
1225 | // encoder: load stored wedge pattern from CU |
---|
1226 | uiTextureWedgeTabIdx = pcCU->getWedgePredTexTabIdx( uiAbsPartIdx ); |
---|
1227 | } |
---|
1228 | else |
---|
1229 | { |
---|
1230 | // decoder: get and store wedge pattern in CU |
---|
1231 | uiTextureWedgeTabIdx = getBestWedgeFromText( pcCU, uiAbsPartIdx, (UInt)iWidth, (UInt)iHeight ); |
---|
1232 | UInt uiDepth = (pcCU->getDepth(0)) + (pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1); |
---|
1233 | pcCU->setWedgePredTexTabIdxSubParts( uiTextureWedgeTabIdx, uiAbsPartIdx, uiDepth ); |
---|
1234 | } |
---|
1235 | TComWedgelet* pcWedgelet = &(pacWedgeList->at(uiTextureWedgeTabIdx)); |
---|
1236 | |
---|
1237 | // get wedge pred DCs |
---|
1238 | Int iPredDC1 = 0; |
---|
1239 | Int iPredDC2 = 0; |
---|
1240 | Int* piMask = pcCU->getPattern()->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); |
---|
1241 | Int iMaskStride = ( iWidth<<1 ) + 1; |
---|
1242 | piMask += iMaskStride+1; |
---|
1243 | getWedgePredDCs( pcWedgelet, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft ); |
---|
1244 | |
---|
1245 | if( bDelta ) |
---|
1246 | { |
---|
1247 | xDeltaDCQuantScaleUp( pcCU, iDeltaDC1 ); |
---|
1248 | xDeltaDCQuantScaleUp( pcCU, iDeltaDC2 ); |
---|
1249 | } |
---|
1250 | |
---|
1251 | // assign wedge pred DCs to prediction |
---|
1252 | if( bDelta ) { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, Clip ( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); } |
---|
1253 | else { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, iPredDC1, iPredDC2 ); } |
---|
1254 | } |
---|
1255 | |
---|
1256 | 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 ) |
---|
1257 | { |
---|
1258 | // get contour pattern |
---|
1259 | TComWedgelet* pcContourWedge = new TComWedgelet( iWidth, iHeight ); |
---|
1260 | getBestContourFromText( pcCU, uiAbsPartIdx, (UInt)iWidth, (UInt)iHeight, pcContourWedge ); |
---|
1261 | |
---|
1262 | // get wedge pred DCs |
---|
1263 | Int iPredDC1 = 0; |
---|
1264 | Int iPredDC2 = 0; |
---|
1265 | Int* piMask = pcCU->getPattern()->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); |
---|
1266 | Int iMaskStride = ( iWidth<<1 ) + 1; |
---|
1267 | piMask += iMaskStride+1; |
---|
1268 | getWedgePredDCs( pcContourWedge, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft ); |
---|
1269 | |
---|
1270 | if( bDelta ) |
---|
1271 | { |
---|
1272 | xDeltaDCQuantScaleUp( pcCU, iDeltaDC1 ); |
---|
1273 | xDeltaDCQuantScaleUp( pcCU, iDeltaDC2 ); |
---|
1274 | } |
---|
1275 | |
---|
1276 | // assign wedge pred DCs to prediction |
---|
1277 | if( bDelta ) { assignWedgeDCs2Pred( pcContourWedge, piPred, uiStride, Clip ( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); } |
---|
1278 | else { assignWedgeDCs2Pred( pcContourWedge, piPred, uiStride, iPredDC1, iPredDC2 ); } |
---|
1279 | |
---|
1280 | pcContourWedge->destroy(); |
---|
1281 | delete pcContourWedge; |
---|
1282 | } |
---|
1283 | #endif |
---|
1284 | #if HHI_DMM_INTRA |
---|
1285 | Void TComPrediction::calcWedgeDCs( TComWedgelet* pcWedgelet, Pel* piOrig, UInt uiStride, Int& riDC1, Int& riDC2 ) |
---|
1286 | { |
---|
1287 | UInt uiDC1 = 0; |
---|
1288 | UInt uiDC2 = 0; |
---|
1289 | UInt uiNumPixDC1 = 0, uiNumPixDC2 = 0; |
---|
1290 | Bool* pabWedgePattern = pcWedgelet->getPattern(); |
---|
1291 | if( uiStride == pcWedgelet->getStride() ) |
---|
1292 | { |
---|
1293 | for( UInt k = 0; k < (pcWedgelet->getWidth() * pcWedgelet->getHeight()); k++ ) |
---|
1294 | { |
---|
1295 | if( true == pabWedgePattern[k] ) |
---|
1296 | { |
---|
1297 | uiDC2 += piOrig[k]; |
---|
1298 | uiNumPixDC2++; |
---|
1299 | } |
---|
1300 | else |
---|
1301 | { |
---|
1302 | uiDC1 += piOrig[k]; |
---|
1303 | uiNumPixDC1++; |
---|
1304 | } |
---|
1305 | } |
---|
1306 | } |
---|
1307 | else |
---|
1308 | { |
---|
1309 | Pel* piTemp = piOrig; |
---|
1310 | UInt uiWedgeStride = pcWedgelet->getStride(); |
---|
1311 | for( UInt uiY = 0; uiY < pcWedgelet->getHeight(); uiY++ ) |
---|
1312 | { |
---|
1313 | for( UInt uiX = 0; uiX < pcWedgelet->getWidth(); uiX++ ) |
---|
1314 | { |
---|
1315 | if( true == pabWedgePattern[uiX] ) |
---|
1316 | { |
---|
1317 | uiDC2 += piTemp[uiX]; |
---|
1318 | uiNumPixDC2++; |
---|
1319 | } |
---|
1320 | else |
---|
1321 | { |
---|
1322 | uiDC1 += piTemp[uiX]; |
---|
1323 | uiNumPixDC1++; |
---|
1324 | } |
---|
1325 | } |
---|
1326 | piTemp += uiStride; |
---|
1327 | pabWedgePattern += uiWedgeStride; |
---|
1328 | } |
---|
1329 | } |
---|
1330 | |
---|
1331 | if( uiNumPixDC1 > 0 ) { riDC1 = uiDC1 / uiNumPixDC1; } |
---|
1332 | else { riDC1 = ( 1<<( g_uiBitDepth + g_uiBitIncrement - 1) ); } |
---|
1333 | |
---|
1334 | if( uiNumPixDC2 > 0 ) { riDC2 = uiDC2 / uiNumPixDC2; } |
---|
1335 | else { riDC2 = ( 1<<( g_uiBitDepth + g_uiBitIncrement - 1) ); } |
---|
1336 | } |
---|
1337 | |
---|
1338 | Void TComPrediction::assignWedgeDCs2Pred( TComWedgelet* pcWedgelet, Pel* piPred, UInt uiStride, Int iDC1, Int iDC2 ) |
---|
1339 | { |
---|
1340 | Bool* pabWedgePattern = pcWedgelet->getPattern(); |
---|
1341 | |
---|
1342 | if( uiStride == pcWedgelet->getStride() ) |
---|
1343 | { |
---|
1344 | for( UInt k = 0; k < (pcWedgelet->getWidth() * pcWedgelet->getHeight()); k++ ) |
---|
1345 | { |
---|
1346 | if( true == pabWedgePattern[k] ) |
---|
1347 | { |
---|
1348 | piPred[k] = iDC2; |
---|
1349 | } |
---|
1350 | else |
---|
1351 | { |
---|
1352 | piPred[k] = iDC1; |
---|
1353 | } |
---|
1354 | } |
---|
1355 | } |
---|
1356 | else |
---|
1357 | { |
---|
1358 | Pel* piTemp = piPred; |
---|
1359 | UInt uiWedgeStride = pcWedgelet->getStride(); |
---|
1360 | for( UInt uiY = 0; uiY < pcWedgelet->getHeight(); uiY++ ) |
---|
1361 | { |
---|
1362 | for( UInt uiX = 0; uiX < pcWedgelet->getWidth(); uiX++ ) |
---|
1363 | { |
---|
1364 | if( true == pabWedgePattern[uiX] ) |
---|
1365 | { |
---|
1366 | piTemp[uiX] = iDC2; |
---|
1367 | } |
---|
1368 | else |
---|
1369 | { |
---|
1370 | piTemp[uiX] = iDC1; |
---|
1371 | } |
---|
1372 | } |
---|
1373 | piTemp += uiStride; |
---|
1374 | pabWedgePattern += uiWedgeStride; |
---|
1375 | } |
---|
1376 | } |
---|
1377 | } |
---|
1378 | |
---|
1379 | UInt TComPrediction::getBestWedgeFromText( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, WedgeDist eWedgeDist ) |
---|
1380 | { |
---|
1381 | assert( uiWidth >= DMM_WEDGEMODEL_MIN_SIZE && uiWidth <= DMM_WEDGEMODEL_MAX_SIZE ); |
---|
1382 | WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiWidth])]; |
---|
1383 | |
---|
1384 | // get copy of according texture luma block |
---|
1385 | UInt uiPartAddr = 0; |
---|
1386 | Int iBlockWidth, iBlockHeight; |
---|
1387 | TComYuv cTempYuv; |
---|
1388 | UInt uiTempStride; |
---|
1389 | Pel* piTempY; |
---|
1390 | |
---|
1391 | TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getTexturePic()->getPicYuvRec(); |
---|
1392 | Int iRefStride = pcPicYuvRef->getStride(); |
---|
1393 | Pel* piRefY; |
---|
1394 | |
---|
1395 | pcCU->getPartIndexAndSize( uiAbsPartIdx, uiPartAddr, iBlockWidth, iBlockHeight ); |
---|
1396 | |
---|
1397 | piRefY = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ); |
---|
1398 | |
---|
1399 | cTempYuv.create( pcCU->getWidth(0), pcCU->getHeight(0) ); cTempYuv.clear(); |
---|
1400 | uiTempStride = cTempYuv.getStride(); |
---|
1401 | piTempY = cTempYuv.getLumaAddr( uiAbsPartIdx, uiWidth ); |
---|
1402 | |
---|
1403 | for ( Int y = 0; y < iBlockHeight; y++ ) |
---|
1404 | { |
---|
1405 | ::memcpy(piTempY, piRefY, sizeof(Pel)*iBlockWidth); |
---|
1406 | piTempY += uiTempStride; |
---|
1407 | piRefY += iRefStride; |
---|
1408 | } |
---|
1409 | |
---|
1410 | piTempY = cTempYuv.getLumaAddr( uiAbsPartIdx, uiWidth ); |
---|
1411 | |
---|
1412 | TComWedgeDist cWedgeDist; |
---|
1413 | UInt uiTextureWedgeTabIdx = 0; |
---|
1414 | |
---|
1415 | // local pred buffer |
---|
1416 | TComYuv cPredYuv; |
---|
1417 | cPredYuv.create( uiWidth, uiHeight ); |
---|
1418 | cPredYuv.clear(); |
---|
1419 | |
---|
1420 | UInt uiPredStride = cPredYuv.getStride(); |
---|
1421 | Pel* piPred = cPredYuv.getLumaAddr(); |
---|
1422 | |
---|
1423 | Int iDC1 = 0; |
---|
1424 | Int iDC2 = 0; |
---|
1425 | // regular wedge search |
---|
1426 | UInt uiBestDist = MAX_UINT; |
---|
1427 | UInt uiBestTabIdx = 0; |
---|
1428 | |
---|
1429 | for( UInt uiIdx = 0; uiIdx < pacWedgeList->size(); uiIdx++ ) |
---|
1430 | { |
---|
1431 | calcWedgeDCs ( &(pacWedgeList->at(uiIdx)), piTempY, uiTempStride, iDC1, iDC2 ); |
---|
1432 | assignWedgeDCs2Pred( &(pacWedgeList->at(uiIdx)), piPred, uiPredStride, iDC1, iDC2 ); |
---|
1433 | |
---|
1434 | UInt uiActDist = cWedgeDist.getDistPart( piPred, uiPredStride, piTempY, uiTempStride, uiWidth, uiHeight, eWedgeDist ); |
---|
1435 | |
---|
1436 | if( uiActDist < uiBestDist || uiBestDist == MAX_UINT ) |
---|
1437 | { |
---|
1438 | uiBestDist = uiActDist; |
---|
1439 | uiBestTabIdx = uiIdx; |
---|
1440 | } |
---|
1441 | } |
---|
1442 | uiTextureWedgeTabIdx = uiBestTabIdx; |
---|
1443 | |
---|
1444 | cPredYuv.destroy(); |
---|
1445 | cTempYuv.destroy(); |
---|
1446 | return uiTextureWedgeTabIdx; |
---|
1447 | } |
---|
1448 | #endif |
---|
1449 | |
---|
1450 | Void TComPrediction::motionCompensation ( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx, Bool bPrdDepthMap ) |
---|
1451 | { |
---|
1452 | Int iWidth; |
---|
1453 | Int iHeight; |
---|
1454 | UInt uiPartAddr; |
---|
1455 | |
---|
1456 | if ( iPartIdx >= 0 ) |
---|
1457 | { |
---|
1458 | pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight ); |
---|
1459 | if ( eRefPicList != REF_PIC_LIST_X ) |
---|
1460 | { |
---|
1461 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap ); |
---|
1462 | #ifdef WEIGHT_PRED |
---|
1463 | if ( pcCU->getSlice()->getPPS()->getUseWP() ) |
---|
1464 | { |
---|
1465 | xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx ); |
---|
1466 | } |
---|
1467 | #endif |
---|
1468 | } |
---|
1469 | else |
---|
1470 | { |
---|
1471 | xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred, iPartIdx, bPrdDepthMap ); |
---|
1472 | |
---|
1473 | } |
---|
1474 | return; |
---|
1475 | } |
---|
1476 | |
---|
1477 | for ( iPartIdx = 0; iPartIdx < pcCU->getNumPartInter(); iPartIdx++ ) |
---|
1478 | { |
---|
1479 | pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight ); |
---|
1480 | |
---|
1481 | if ( eRefPicList != REF_PIC_LIST_X ) |
---|
1482 | { |
---|
1483 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap ); |
---|
1484 | #ifdef WEIGHT_PRED |
---|
1485 | if ( pcCU->getSlice()->getPPS()->getUseWP() ) |
---|
1486 | { |
---|
1487 | xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx ); |
---|
1488 | } |
---|
1489 | #endif |
---|
1490 | } |
---|
1491 | else |
---|
1492 | { |
---|
1493 | xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred, iPartIdx, bPrdDepthMap ); |
---|
1494 | } |
---|
1495 | } |
---|
1496 | return; |
---|
1497 | } |
---|
1498 | |
---|
1499 | #if HIGH_ACCURACY_BI |
---|
1500 | Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap, Bool bi ) |
---|
1501 | #else |
---|
1502 | Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap ) |
---|
1503 | #endif |
---|
1504 | { |
---|
1505 | Int iRefIdx = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); assert (iRefIdx >= 0); |
---|
1506 | TComMv cMv = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr ); |
---|
1507 | pcCU->clipMv(cMv); |
---|
1508 | |
---|
1509 | if( bPrdDepthMap ) |
---|
1510 | { |
---|
1511 | #if HIGH_ACCURACY_BI |
---|
1512 | UInt uiRShift = ( bi ? 14-g_uiBitDepth-g_uiBitIncrement : 0 ); |
---|
1513 | #else |
---|
1514 | UInt uiRShift = 0; |
---|
1515 | #endif |
---|
1516 | xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPredDepthMap(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, uiRShift, PDM_DEPTH_MAP_MCP_FILTER ); |
---|
1517 | return; |
---|
1518 | } |
---|
1519 | |
---|
1520 | #if MW_DEPTH_MAP_INTERP_FILTER |
---|
1521 | if( pcCU->getSlice()->getSPS()->isDepth() ) |
---|
1522 | { |
---|
1523 | #if HIGH_ACCURACY_BI |
---|
1524 | UInt uiRShift = ( bi ? 14-g_uiBitDepth-g_uiBitIncrement : 0 ); |
---|
1525 | #else |
---|
1526 | UInt uiRShift = 0; |
---|
1527 | #endif |
---|
1528 | xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, uiRShift, MW_DEPTH_MAP_INTERP_FILTER ); |
---|
1529 | } |
---|
1530 | else |
---|
1531 | { |
---|
1532 | #endif |
---|
1533 | #if HIGH_ACCURACY_BI |
---|
1534 | if(!bi) |
---|
1535 | { |
---|
1536 | xPredInterLumaBlk ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec() , uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred ); |
---|
1537 | } |
---|
1538 | else |
---|
1539 | { |
---|
1540 | xPredInterLumaBlk_ha ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec() , uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred ); |
---|
1541 | } |
---|
1542 | #else |
---|
1543 | xPredInterLumaBlk ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred ); |
---|
1544 | #endif |
---|
1545 | #if MW_DEPTH_MAP_INTERP_FILTER |
---|
1546 | } |
---|
1547 | #endif |
---|
1548 | |
---|
1549 | #if HIGH_ACCURACY_BI |
---|
1550 | if (!bi) |
---|
1551 | { |
---|
1552 | xPredInterChromaBlk ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred ); |
---|
1553 | } |
---|
1554 | else |
---|
1555 | { |
---|
1556 | xPredInterChromaBlk_ha ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec() , uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred ); |
---|
1557 | } |
---|
1558 | #else |
---|
1559 | xPredInterChromaBlk ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred ); |
---|
1560 | #endif |
---|
1561 | } |
---|
1562 | |
---|
1563 | Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap ) |
---|
1564 | { |
---|
1565 | TComYuv* pcMbYuv; |
---|
1566 | Int iRefIdx[2] = {-1, -1}; |
---|
1567 | |
---|
1568 | for ( Int iRefList = 0; iRefList < 2; iRefList++ ) |
---|
1569 | { |
---|
1570 | RefPicList eRefPicList = (iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0); |
---|
1571 | iRefIdx[iRefList] = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
1572 | |
---|
1573 | if ( iRefIdx[iRefList] < 0 ) |
---|
1574 | { |
---|
1575 | continue; |
---|
1576 | } |
---|
1577 | |
---|
1578 | assert( iRefIdx[iRefList] < pcCU->getSlice()->getNumRefIdx(eRefPicList) ); |
---|
1579 | |
---|
1580 | pcMbYuv = &m_acYuvPred[iRefList]; |
---|
1581 | #if HIGH_ACCURACY_BI |
---|
1582 | if( pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr ) >= 0 && pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr ) >= 0 ) |
---|
1583 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, true ); |
---|
1584 | else |
---|
1585 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap ); |
---|
1586 | #else |
---|
1587 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap ); |
---|
1588 | #endif |
---|
1589 | } |
---|
1590 | |
---|
1591 | #ifdef WEIGHT_PRED |
---|
1592 | if ( pcCU->getSlice()->getPPS()->getWPBiPredIdc() ) |
---|
1593 | { |
---|
1594 | xWeightedPredictionBi( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); |
---|
1595 | } |
---|
1596 | else |
---|
1597 | #endif |
---|
1598 | xWeightedAverage( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); |
---|
1599 | } |
---|
1600 | |
---|
1601 | |
---|
1602 | Void |
---|
1603 | TComPrediction::xPredInterPrdDepthMap( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, TComYuv*& rpcYuv, UInt uiRShift, UInt uiFilterMode ) // 0:std, 1:bilin, 2:nearest neighbour |
---|
1604 | { |
---|
1605 | AOF( uiFilterMode <= 2 ); |
---|
1606 | |
---|
1607 | Int iFPelMask = ~3; |
---|
1608 | Int iRefStride = pcPicYuvRef->getStride(); |
---|
1609 | Int iDstStride = rpcYuv->getStride(); |
---|
1610 | Int iHor = ( uiFilterMode == 2 ? ( pcMv->getHor() + 2 ) & iFPelMask : pcMv->getHor() ); |
---|
1611 | Int iVer = ( uiFilterMode == 2 ? ( pcMv->getVer() + 2 ) & iFPelMask : pcMv->getVer() ); |
---|
1612 | #if MW_DEPTH_MAP_INTERP_FILTER == 2 && MW_FULL_PEL_DEPTH_MAP_MV_SIGNALLING |
---|
1613 | if( pcCU->getSlice()->getSPS()->isDepth() ) |
---|
1614 | { |
---|
1615 | assert( uiFilterMode == 2 ); |
---|
1616 | iHor = pcMv->getHor() * 4; |
---|
1617 | iVer = pcMv->getVer() * 4; |
---|
1618 | } |
---|
1619 | #endif |
---|
1620 | Int iRefOffset = ( iHor >> 2 ) + ( iVer >> 2 ) * iRefStride; |
---|
1621 | Int ixFrac = iHor & 0x3; |
---|
1622 | Int iyFrac = iVer & 0x3; |
---|
1623 | Pel* piRefY = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset; |
---|
1624 | Pel* piDstY = rpcYuv->getLumaAddr( uiPartAddr ); |
---|
1625 | |
---|
1626 | // Integer position |
---|
1627 | if( ixFrac == 0 && iyFrac == 0 ) |
---|
1628 | { |
---|
1629 | for( Int y = 0; y < iHeight; y++, piDstY += iDstStride, piRefY += iRefStride ) |
---|
1630 | { |
---|
1631 | for( Int x = 0; x < iWidth; x++ ) |
---|
1632 | { |
---|
1633 | piDstY[ x ] = piRefY[ x ] << uiRShift; |
---|
1634 | } |
---|
1635 | } |
---|
1636 | return; |
---|
1637 | } |
---|
1638 | |
---|
1639 | // bi-linear interpolation |
---|
1640 | if( uiFilterMode == 1 ) |
---|
1641 | { |
---|
1642 | Int iW00 = ( 4 - ixFrac ) * ( 4 - iyFrac ); |
---|
1643 | Int iW01 = ( ixFrac ) * ( 4 - iyFrac ); |
---|
1644 | Int iW10 = ( 4 - ixFrac ) * ( iyFrac ); |
---|
1645 | Int iW11 = ( ixFrac ) * ( iyFrac ); |
---|
1646 | Pel* piRefY1 = piRefY + iRefStride; |
---|
1647 | for( Int y = 0; y < iHeight; y++, piDstY += iDstStride, piRefY += iRefStride, piRefY1 += iRefStride ) |
---|
1648 | { |
---|
1649 | for( Int x = 0; x < iWidth; x++ ) |
---|
1650 | { |
---|
1651 | Int iSV = iW00 * piRefY [ x ] + iW01 * piRefY [ x + 1 ] |
---|
1652 | + iW10 * piRefY1[ x ] + iW11 * piRefY1[ x + 1 ]; |
---|
1653 | iSV <<= uiRShift; |
---|
1654 | piDstY[ x ] = ( iSV + 8 ) >> 4; |
---|
1655 | } |
---|
1656 | } |
---|
1657 | return; |
---|
1658 | } |
---|
1659 | |
---|
1660 | xPredInterLumaBlk( pcCU, pcPicYuvRef, uiPartAddr, pcMv, iWidth, iHeight, rpcYuv ); |
---|
1661 | return; |
---|
1662 | } |
---|
1663 | |
---|
1664 | |
---|
1665 | |
---|
1666 | #if HIGH_ACCURACY_BI |
---|
1667 | |
---|
1668 | Void TComPrediction::xPredInterLumaBlk_ha( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, TComYuv*& rpcYuv ) |
---|
1669 | { |
---|
1670 | Int iRefStride = pcPicYuvRef->getStride(); |
---|
1671 | Int iDstStride = rpcYuv->getStride(); |
---|
1672 | |
---|
1673 | Int iRefOffset = ( pcMv->getHor() >> 2 ) + ( pcMv->getVer() >> 2 ) * iRefStride; |
---|
1674 | Pel* piRefY = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset; |
---|
1675 | |
---|
1676 | Int ixFrac = pcMv->getHor() & 0x3; |
---|
1677 | Int iyFrac = pcMv->getVer() & 0x3; |
---|
1678 | |
---|
1679 | Pel* piDstY = rpcYuv->getLumaAddr( uiPartAddr ); |
---|
1680 | UInt shiftNum = 14-g_uiBitDepth-g_uiBitIncrement; |
---|
1681 | // Integer point |
---|
1682 | if ( ixFrac == 0 && iyFrac == 0 ) |
---|
1683 | { |
---|
1684 | for ( Int y = 0; y < iHeight; y++ ) |
---|
1685 | { |
---|
1686 | for(Int x=0; x<iWidth; x++) |
---|
1687 | piDstY[x] = piRefY[x]<<shiftNum; |
---|
1688 | piDstY += iDstStride; |
---|
1689 | piRefY += iRefStride; |
---|
1690 | } |
---|
1691 | return; |
---|
1692 | } |
---|
1693 | |
---|
1694 | // Half-pel horizontal |
---|
1695 | if ( ixFrac == 2 && iyFrac == 0 ) |
---|
1696 | { |
---|
1697 | xCTI_FilterHalfHor_ha ( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); |
---|
1698 | return; |
---|
1699 | } |
---|
1700 | |
---|
1701 | // Half-pel vertical |
---|
1702 | if ( ixFrac == 0 && iyFrac == 2 ) |
---|
1703 | { |
---|
1704 | xCTI_FilterHalfVer_ha ( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); |
---|
1705 | return; |
---|
1706 | } |
---|
1707 | |
---|
1708 | Int iExtStride = m_iYuvExtStride;//m_cYuvExt.getStride(); |
---|
1709 | Int* piExtY = m_piYuvExt;//m_cYuvExt.getLumaAddr(); |
---|
1710 | |
---|
1711 | // Half-pel center |
---|
1712 | if ( ixFrac == 2 && iyFrac == 2 ) |
---|
1713 | { |
---|
1714 | xCTI_FilterHalfVer (piRefY - 3, iRefStride, 1, iWidth +7, iHeight, iExtStride, 1, piExtY ); |
---|
1715 | xCTI_FilterHalfHor_ha (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); |
---|
1716 | return; |
---|
1717 | } |
---|
1718 | |
---|
1719 | // Quater-pel horizontal |
---|
1720 | if ( iyFrac == 0) |
---|
1721 | { |
---|
1722 | if ( ixFrac == 1) |
---|
1723 | { |
---|
1724 | xCTI_FilterQuarter0Hor_ha( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); |
---|
1725 | return; |
---|
1726 | } |
---|
1727 | if ( ixFrac == 3) |
---|
1728 | { |
---|
1729 | xCTI_FilterQuarter1Hor_ha( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); |
---|
1730 | return; |
---|
1731 | } |
---|
1732 | } |
---|
1733 | if ( iyFrac == 2 ) |
---|
1734 | { |
---|
1735 | if ( ixFrac == 1) |
---|
1736 | { |
---|
1737 | xCTI_FilterHalfVer (piRefY -3, iRefStride, 1, iWidth +7, iHeight, iExtStride, 1, piExtY ); |
---|
1738 | xCTI_FilterQuarter0Hor_ha (piExtY + 3, iExtStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); |
---|
1739 | return; |
---|
1740 | } |
---|
1741 | if ( ixFrac == 3) |
---|
1742 | { |
---|
1743 | xCTI_FilterHalfVer (piRefY - 3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); |
---|
1744 | xCTI_FilterQuarter1Hor_ha (piExtY + 3, iExtStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); |
---|
1745 | return; |
---|
1746 | } |
---|
1747 | } |
---|
1748 | |
---|
1749 | // Quater-pel vertical |
---|
1750 | if( ixFrac == 0 ) |
---|
1751 | { |
---|
1752 | if( iyFrac == 1 ) |
---|
1753 | { |
---|
1754 | xCTI_FilterQuarter0Ver_ha( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); |
---|
1755 | return; |
---|
1756 | } |
---|
1757 | if( iyFrac == 3 ) |
---|
1758 | { |
---|
1759 | xCTI_FilterQuarter1Ver_ha( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); |
---|
1760 | return; |
---|
1761 | } |
---|
1762 | } |
---|
1763 | |
---|
1764 | if( ixFrac == 2 ) |
---|
1765 | { |
---|
1766 | if( iyFrac == 1 ) |
---|
1767 | { |
---|
1768 | xCTI_FilterQuarter0Ver (piRefY - 3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); |
---|
1769 | xCTI_FilterHalfHor_ha (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); |
---|
1770 | |
---|
1771 | return; |
---|
1772 | } |
---|
1773 | if( iyFrac == 3 ) |
---|
1774 | { |
---|
1775 | xCTI_FilterQuarter1Ver (piRefY -3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); |
---|
1776 | xCTI_FilterHalfHor_ha (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); |
---|
1777 | return; |
---|
1778 | } |
---|
1779 | } |
---|
1780 | |
---|
1781 | /// Quarter-pel center |
---|
1782 | if ( iyFrac == 1) |
---|
1783 | { |
---|
1784 | if ( ixFrac == 1) |
---|
1785 | { |
---|
1786 | xCTI_FilterQuarter0Ver (piRefY - 3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); |
---|
1787 | xCTI_FilterQuarter0Hor_ha (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); |
---|
1788 | return; |
---|
1789 | } |
---|
1790 | if ( ixFrac == 3) |
---|
1791 | { |
---|
1792 | xCTI_FilterQuarter0Ver (piRefY - 3, iRefStride, 1, iWidth +7, iHeight, iExtStride, 1, piExtY ); |
---|
1793 | xCTI_FilterQuarter1Hor_ha (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); |
---|
1794 | |
---|
1795 | return; |
---|
1796 | } |
---|
1797 | } |
---|
1798 | if ( iyFrac == 3 ) |
---|
1799 | { |
---|
1800 | if ( ixFrac == 1) |
---|
1801 | { |
---|
1802 | xCTI_FilterQuarter1Ver (piRefY - 3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); |
---|
1803 | xCTI_FilterQuarter0Hor_ha (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); |
---|
1804 | return; |
---|
1805 | } |
---|
1806 | if ( ixFrac == 3) |
---|
1807 | { |
---|
1808 | xCTI_FilterQuarter1Ver (piRefY - 3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); |
---|
1809 | xCTI_FilterQuarter1Hor_ha (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); |
---|
1810 | return; |
---|
1811 | } |
---|
1812 | } |
---|
1813 | } |
---|
1814 | |
---|
1815 | #endif |
---|
1816 | |
---|
1817 | Void TComPrediction::xPredInterLumaBlk( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, TComYuv*& rpcYuv ) |
---|
1818 | { |
---|
1819 | Int iRefStride = pcPicYuvRef->getStride(); |
---|
1820 | Int iDstStride = rpcYuv->getStride(); |
---|
1821 | |
---|
1822 | Int iRefOffset = ( pcMv->getHor() >> 2 ) + ( pcMv->getVer() >> 2 ) * iRefStride; |
---|
1823 | Pel* piRefY = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset; |
---|
1824 | |
---|
1825 | Int ixFrac = pcMv->getHor() & 0x3; |
---|
1826 | Int iyFrac = pcMv->getVer() & 0x3; |
---|
1827 | |
---|
1828 | Pel* piDstY = rpcYuv->getLumaAddr( uiPartAddr ); |
---|
1829 | |
---|
1830 | // Integer point |
---|
1831 | if ( ixFrac == 0 && iyFrac == 0 ) |
---|
1832 | { |
---|
1833 | for ( Int y = 0; y < iHeight; y++ ) |
---|
1834 | { |
---|
1835 | ::memcpy(piDstY, piRefY, sizeof(Pel)*iWidth); |
---|
1836 | piDstY += iDstStride; |
---|
1837 | piRefY += iRefStride; |
---|
1838 | } |
---|
1839 | return; |
---|
1840 | } |
---|
1841 | |
---|
1842 | // Half-pel horizontal |
---|
1843 | if ( ixFrac == 2 && iyFrac == 0 ) |
---|
1844 | { |
---|
1845 | xCTI_FilterHalfHor ( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); |
---|
1846 | return; |
---|
1847 | } |
---|
1848 | |
---|
1849 | // Half-pel vertical |
---|
1850 | if ( ixFrac == 0 && iyFrac == 2 ) |
---|
1851 | { |
---|
1852 | xCTI_FilterHalfVer ( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); |
---|
1853 | return; |
---|
1854 | } |
---|
1855 | |
---|
1856 | Int iExtStride = m_iYuvExtStride;//m_cYuvExt.getStride(); |
---|
1857 | Int* piExtY = m_piYuvExt;//m_cYuvExt.getLumaAddr(); |
---|
1858 | |
---|
1859 | // Half-pel center |
---|
1860 | if ( ixFrac == 2 && iyFrac == 2 ) |
---|
1861 | { |
---|
1862 | |
---|
1863 | xCTI_FilterHalfVer (piRefY - 3, iRefStride, 1, iWidth +7, iHeight, iExtStride, 1, piExtY ); |
---|
1864 | xCTI_FilterHalfHor (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); |
---|
1865 | return; |
---|
1866 | } |
---|
1867 | |
---|
1868 | // Quater-pel horizontal |
---|
1869 | if ( iyFrac == 0) |
---|
1870 | { |
---|
1871 | if ( ixFrac == 1) |
---|
1872 | { |
---|
1873 | xCTI_FilterQuarter0Hor( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); |
---|
1874 | return; |
---|
1875 | } |
---|
1876 | if ( ixFrac == 3) |
---|
1877 | { |
---|
1878 | xCTI_FilterQuarter1Hor( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); |
---|
1879 | return; |
---|
1880 | } |
---|
1881 | } |
---|
1882 | if ( iyFrac == 2 ) |
---|
1883 | { |
---|
1884 | if ( ixFrac == 1) |
---|
1885 | { |
---|
1886 | xCTI_FilterHalfVer (piRefY -3, iRefStride, 1, iWidth +7, iHeight, iExtStride, 1, piExtY ); |
---|
1887 | xCTI_FilterQuarter0Hor (piExtY + 3, iExtStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); |
---|
1888 | return; |
---|
1889 | } |
---|
1890 | if ( ixFrac == 3) |
---|
1891 | { |
---|
1892 | xCTI_FilterHalfVer (piRefY - 3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); |
---|
1893 | xCTI_FilterQuarter1Hor (piExtY + 3, iExtStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); |
---|
1894 | return; |
---|
1895 | } |
---|
1896 | } |
---|
1897 | |
---|
1898 | // Quater-pel vertical |
---|
1899 | if( ixFrac == 0 ) |
---|
1900 | { |
---|
1901 | if( iyFrac == 1 ) |
---|
1902 | { |
---|
1903 | xCTI_FilterQuarter0Ver( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); |
---|
1904 | return; |
---|
1905 | } |
---|
1906 | if( iyFrac == 3 ) |
---|
1907 | { |
---|
1908 | xCTI_FilterQuarter1Ver( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); |
---|
1909 | return; |
---|
1910 | } |
---|
1911 | } |
---|
1912 | |
---|
1913 | if( ixFrac == 2 ) |
---|
1914 | { |
---|
1915 | if( iyFrac == 1 ) |
---|
1916 | { |
---|
1917 | xCTI_FilterQuarter0Ver (piRefY - 3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); |
---|
1918 | xCTI_FilterHalfHor (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); |
---|
1919 | return; |
---|
1920 | } |
---|
1921 | if( iyFrac == 3 ) |
---|
1922 | { |
---|
1923 | xCTI_FilterQuarter1Ver (piRefY -3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); |
---|
1924 | xCTI_FilterHalfHor (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); |
---|
1925 | return; |
---|
1926 | } |
---|
1927 | } |
---|
1928 | |
---|
1929 | /// Quarter-pel center |
---|
1930 | if ( iyFrac == 1) |
---|
1931 | { |
---|
1932 | if ( ixFrac == 1) |
---|
1933 | { |
---|
1934 | xCTI_FilterQuarter0Ver (piRefY - 3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); |
---|
1935 | xCTI_FilterQuarter0Hor (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); |
---|
1936 | return; |
---|
1937 | } |
---|
1938 | if ( ixFrac == 3) |
---|
1939 | { |
---|
1940 | xCTI_FilterQuarter0Ver (piRefY - 3, iRefStride, 1, iWidth +7, iHeight, iExtStride, 1, piExtY ); |
---|
1941 | xCTI_FilterQuarter1Hor (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); |
---|
1942 | return; |
---|
1943 | } |
---|
1944 | } |
---|
1945 | if ( iyFrac == 3 ) |
---|
1946 | { |
---|
1947 | if ( ixFrac == 1) |
---|
1948 | { |
---|
1949 | xCTI_FilterQuarter1Ver (piRefY - 3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); |
---|
1950 | xCTI_FilterQuarter0Hor (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); |
---|
1951 | return; |
---|
1952 | } |
---|
1953 | if ( ixFrac == 3) |
---|
1954 | { |
---|
1955 | xCTI_FilterQuarter1Ver (piRefY - 3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); |
---|
1956 | xCTI_FilterQuarter1Hor (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); |
---|
1957 | return; |
---|
1958 | } |
---|
1959 | } |
---|
1960 | } |
---|
1961 | |
---|
1962 | #if HIGH_ACCURACY_BI |
---|
1963 | Void TComPrediction::xPredInterChromaBlk_ha( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, TComYuv*& rpcYuv ) |
---|
1964 | { |
---|
1965 | Int iRefStride = pcPicYuvRef->getCStride(); |
---|
1966 | Int iDstStride = rpcYuv->getCStride(); |
---|
1967 | |
---|
1968 | Int iRefOffset = (pcMv->getHor() >> 3) + (pcMv->getVer() >> 3) * iRefStride; |
---|
1969 | |
---|
1970 | Pel* piRefCb = pcPicYuvRef->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset; |
---|
1971 | Pel* piRefCr = pcPicYuvRef->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset; |
---|
1972 | |
---|
1973 | Pel* piDstCb = rpcYuv->getCbAddr( uiPartAddr ); |
---|
1974 | Pel* piDstCr = rpcYuv->getCrAddr( uiPartAddr ); |
---|
1975 | |
---|
1976 | Int ixFrac = pcMv->getHor() & 0x7; |
---|
1977 | Int iyFrac = pcMv->getVer() & 0x7; |
---|
1978 | UInt uiCWidth = iWidth >> 1; |
---|
1979 | UInt uiCHeight = iHeight >> 1; |
---|
1980 | |
---|
1981 | xDCTIF_FilterC_ha(piRefCb, iRefStride,piDstCb,iDstStride,uiCWidth,uiCHeight, iyFrac, ixFrac); |
---|
1982 | xDCTIF_FilterC_ha(piRefCr, iRefStride,piDstCr,iDstStride,uiCWidth,uiCHeight, iyFrac, ixFrac); |
---|
1983 | return; |
---|
1984 | } |
---|
1985 | #endif |
---|
1986 | |
---|
1987 | //-- |
---|
1988 | Void TComPrediction::xPredInterChromaBlk( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, TComYuv*& rpcYuv ) |
---|
1989 | { |
---|
1990 | Int iRefStride = pcPicYuvRef->getCStride(); |
---|
1991 | Int iDstStride = rpcYuv->getCStride(); |
---|
1992 | |
---|
1993 | Int iRefOffset = (pcMv->getHor() >> 3) + (pcMv->getVer() >> 3) * iRefStride; |
---|
1994 | |
---|
1995 | Pel* piRefCb = pcPicYuvRef->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset; |
---|
1996 | Pel* piRefCr = pcPicYuvRef->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset; |
---|
1997 | |
---|
1998 | Pel* piDstCb = rpcYuv->getCbAddr( uiPartAddr ); |
---|
1999 | Pel* piDstCr = rpcYuv->getCrAddr( uiPartAddr ); |
---|
2000 | |
---|
2001 | Int ixFrac = pcMv->getHor() & 0x7; |
---|
2002 | Int iyFrac = pcMv->getVer() & 0x7; |
---|
2003 | UInt uiCWidth = iWidth >> 1; |
---|
2004 | UInt uiCHeight = iHeight >> 1; |
---|
2005 | |
---|
2006 | xDCTIF_FilterC(piRefCb, iRefStride,piDstCb,iDstStride,uiCWidth,uiCHeight, iyFrac, ixFrac); |
---|
2007 | xDCTIF_FilterC(piRefCr, iRefStride,piDstCr,iDstStride,uiCWidth,uiCHeight, iyFrac, ixFrac); |
---|
2008 | return; |
---|
2009 | } |
---|
2010 | |
---|
2011 | Void TComPrediction::xDCTIF_FilterC ( Pel* piRefC, Int iRefStride,Pel* piDstC,Int iDstStride, |
---|
2012 | Int iWidth, Int iHeight,Int iMVyFrac,Int iMVxFrac) |
---|
2013 | { |
---|
2014 | // Integer point |
---|
2015 | if ( iMVxFrac == 0 && iMVyFrac == 0 ) |
---|
2016 | { |
---|
2017 | for ( Int y = 0; y < iHeight; y++ ) |
---|
2018 | { |
---|
2019 | ::memcpy(piDstC, piRefC, sizeof(Pel)*iWidth); |
---|
2020 | piDstC += iDstStride; |
---|
2021 | piRefC += iRefStride; |
---|
2022 | } |
---|
2023 | return; |
---|
2024 | } |
---|
2025 | |
---|
2026 | if ( iMVyFrac == 0 ) |
---|
2027 | { |
---|
2028 | xCTI_Filter1DHorC (piRefC, iRefStride, iWidth, iHeight, iDstStride, piDstC, iMVxFrac ); |
---|
2029 | return; |
---|
2030 | } |
---|
2031 | |
---|
2032 | if ( iMVxFrac == 0 ) |
---|
2033 | { |
---|
2034 | xCTI_Filter1DVerC (piRefC, iRefStride, iWidth, iHeight, iDstStride, piDstC, iMVyFrac ); |
---|
2035 | return; |
---|
2036 | } |
---|
2037 | |
---|
2038 | Int iExtStride = m_iYuvExtStride; |
---|
2039 | Int* piExtC = m_piYuvExt; |
---|
2040 | |
---|
2041 | xCTI_Filter2DVerC (piRefC - 1, iRefStride, iWidth + 3, iHeight, iExtStride, piExtC, iMVyFrac ); |
---|
2042 | xCTI_Filter2DHorC (piExtC + 1, iExtStride, iWidth , iHeight, iDstStride, piDstC, iMVxFrac ); |
---|
2043 | } |
---|
2044 | |
---|
2045 | #if HIGH_ACCURACY_BI |
---|
2046 | |
---|
2047 | Void TComPrediction::xDCTIF_FilterC_ha ( Pel* piRefC, Int iRefStride,Pel* piDstC,Int iDstStride, |
---|
2048 | Int iWidth, Int iHeight,Int iMVyFrac,Int iMVxFrac) |
---|
2049 | { |
---|
2050 | UInt shiftNumOrg = 6 - g_uiBitIncrement + 8 - g_uiBitDepth; |
---|
2051 | // Integer point |
---|
2052 | if ( iMVxFrac == 0 && iMVyFrac == 0 ) |
---|
2053 | { |
---|
2054 | for (Int y = 0; y < iHeight; y++ ) |
---|
2055 | { |
---|
2056 | for(Int x=0; x<iWidth; x++) |
---|
2057 | { |
---|
2058 | piDstC[x] = (piRefC[x]<<shiftNumOrg); |
---|
2059 | } |
---|
2060 | piDstC += iDstStride; |
---|
2061 | piRefC += iRefStride; |
---|
2062 | } |
---|
2063 | return; |
---|
2064 | } |
---|
2065 | |
---|
2066 | if ( iMVyFrac == 0 ) |
---|
2067 | { |
---|
2068 | xCTI_Filter1DHorC_ha (piRefC, iRefStride, iWidth, iHeight, iDstStride, piDstC, iMVxFrac ); |
---|
2069 | return; |
---|
2070 | |
---|
2071 | } |
---|
2072 | |
---|
2073 | if ( iMVxFrac == 0 ) |
---|
2074 | { |
---|
2075 | xCTI_Filter1DVerC_ha (piRefC, iRefStride, iWidth, iHeight, iDstStride, piDstC, iMVyFrac ); |
---|
2076 | return; |
---|
2077 | } |
---|
2078 | |
---|
2079 | Int iExtStride = m_iYuvExtStride; |
---|
2080 | Int* piExtC = m_piYuvExt; |
---|
2081 | |
---|
2082 | xCTI_Filter2DVerC (piRefC - 1, iRefStride, iWidth + 3, iHeight, iExtStride, piExtC, iMVyFrac ); |
---|
2083 | xCTI_Filter2DHorC_ha (piExtC + 1, iExtStride, iWidth , iHeight, iDstStride, piDstC, iMVxFrac ); |
---|
2084 | return; |
---|
2085 | |
---|
2086 | } |
---|
2087 | |
---|
2088 | #endif |
---|
2089 | |
---|
2090 | |
---|
2091 | Void TComPrediction::xWeightedAverage( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv*& rpcYuvDst ) |
---|
2092 | { |
---|
2093 | if( iRefIdx0 >= 0 && iRefIdx1 >= 0 ) |
---|
2094 | { |
---|
2095 | #ifdef ROUNDING_CONTROL_BIPRED |
---|
2096 | rpcYuvDst->addAvg( pcYuvSrc0, pcYuvSrc1, uiPartIdx, iWidth, iHeight, pcCU->getSlice()->isRounding()); |
---|
2097 | #else |
---|
2098 | rpcYuvDst->addAvg( pcYuvSrc0, pcYuvSrc1, uiPartIdx, iWidth, iHeight ); |
---|
2099 | #endif |
---|
2100 | } |
---|
2101 | else if ( iRefIdx0 >= 0 && iRefIdx1 < 0 ) |
---|
2102 | { |
---|
2103 | pcYuvSrc0->copyPartToPartYuv( rpcYuvDst, uiPartIdx, iWidth, iHeight ); |
---|
2104 | } |
---|
2105 | else if ( iRefIdx0 < 0 && iRefIdx1 >= 0 ) |
---|
2106 | { |
---|
2107 | pcYuvSrc1->copyPartToPartYuv( rpcYuvDst, uiPartIdx, iWidth, iHeight ); |
---|
2108 | } |
---|
2109 | else |
---|
2110 | { |
---|
2111 | assert (0); |
---|
2112 | } |
---|
2113 | } |
---|
2114 | |
---|
2115 | // AMVP |
---|
2116 | Void TComPrediction::getMvPredAMVP( TComDataCU* pcCU, UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMvPred ) |
---|
2117 | { |
---|
2118 | AMVPInfo* pcAMVPInfo = pcCU->getCUMvField(eRefPicList)->getAMVPInfo(); |
---|
2119 | |
---|
2120 | if( pcCU->getAMVPMode(uiPartAddr) == AM_NONE || (pcAMVPInfo->iN <= 1 && pcCU->getAMVPMode(uiPartAddr) == AM_EXPL) ) |
---|
2121 | { |
---|
2122 | rcMvPred = pcAMVPInfo->m_acMvCand[0]; |
---|
2123 | |
---|
2124 | pcCU->setMVPIdxSubParts( 0, eRefPicList, uiPartAddr, uiPartIdx, pcCU->getDepth(uiPartAddr)); |
---|
2125 | pcCU->setMVPNumSubParts( pcAMVPInfo->iN, eRefPicList, uiPartAddr, uiPartIdx, pcCU->getDepth(uiPartAddr)); |
---|
2126 | return; |
---|
2127 | } |
---|
2128 | |
---|
2129 | assert(pcCU->getMVPIdx(eRefPicList,uiPartAddr) >= 0); |
---|
2130 | rcMvPred = pcAMVPInfo->m_acMvCand[pcCU->getMVPIdx(eRefPicList,uiPartAddr)]; |
---|
2131 | return; |
---|
2132 | } |
---|
2133 | |
---|
2134 | #if ADD_PLANAR_MODE |
---|
2135 | /** Function for deriving planar intra prediction. |
---|
2136 | * \param pSrc pointer to reconstructed sample array |
---|
2137 | * \param srcStride the stride of the reconstructed sample array |
---|
2138 | * \param rpDst reference to pointer for the prediction sample array |
---|
2139 | * \param dstStride the stride of the prediction sample array |
---|
2140 | * \param width the width of the block |
---|
2141 | * \param height the height of the block |
---|
2142 | * \param blkAboveAvailable boolean indication if the block above is available |
---|
2143 | * \param blkLeftAvailable boolean indication if the block to the left is available |
---|
2144 | * |
---|
2145 | * This function derives the prediction samples for planar mode (intra coding). |
---|
2146 | */ |
---|
2147 | #if REFERENCE_SAMPLE_PADDING |
---|
2148 | Void TComPrediction::xPredIntraPlanar( Int* pSrc, Int srcStride, Pel*& rpDst, Int dstStride, UInt width, UInt height ) |
---|
2149 | #else |
---|
2150 | Void TComPrediction::xPredIntraPlanar( Int* pSrc, Int srcStride, Pel*& rpDst, Int dstStride, UInt width, UInt height, Bool blkAboveAvailable, Bool blkLeftAvailable ) |
---|
2151 | #endif |
---|
2152 | { |
---|
2153 | assert(width == height); |
---|
2154 | |
---|
2155 | Int k, l, bottomLeft, topRight; |
---|
2156 | Int horPred; |
---|
2157 | Int leftColumn[MAX_CU_SIZE], topRow[MAX_CU_SIZE], bottomRow[MAX_CU_SIZE], rightColumn[MAX_CU_SIZE]; |
---|
2158 | UInt blkSize = width; |
---|
2159 | UInt offset2D = width; |
---|
2160 | UInt shift1D = g_aucConvertToBit[ width ] + 2; |
---|
2161 | UInt shift2D = shift1D + 1; |
---|
2162 | |
---|
2163 | // Get left and above reference column and row |
---|
2164 | #if REFERENCE_SAMPLE_PADDING |
---|
2165 | for(k=0;k<blkSize;k++) |
---|
2166 | { |
---|
2167 | topRow[k] = pSrc[k-srcStride]; |
---|
2168 | leftColumn[k] = pSrc[k*srcStride-1]; |
---|
2169 | } |
---|
2170 | #else |
---|
2171 | if (!blkAboveAvailable && !blkLeftAvailable) |
---|
2172 | { |
---|
2173 | for(k=0;k<blkSize;k++) |
---|
2174 | { |
---|
2175 | leftColumn[k] = topRow[k] = ( 1 << ( g_uiBitDepth + g_uiBitIncrement - 1 ) ); |
---|
2176 | } |
---|
2177 | } |
---|
2178 | else |
---|
2179 | { |
---|
2180 | if(blkAboveAvailable) |
---|
2181 | { |
---|
2182 | for(k=0;k<blkSize;k++) |
---|
2183 | { |
---|
2184 | topRow[k] = pSrc[k-srcStride]; |
---|
2185 | } |
---|
2186 | } |
---|
2187 | else |
---|
2188 | { |
---|
2189 | Int leftSample = pSrc[-1]; |
---|
2190 | for(k=0;k<blkSize;k++) |
---|
2191 | { |
---|
2192 | topRow[k] = leftSample; |
---|
2193 | } |
---|
2194 | } |
---|
2195 | if(blkLeftAvailable) |
---|
2196 | { |
---|
2197 | for(k=0;k<blkSize;k++) |
---|
2198 | { |
---|
2199 | leftColumn[k] = pSrc[k*srcStride-1]; |
---|
2200 | } |
---|
2201 | } |
---|
2202 | else |
---|
2203 | { |
---|
2204 | Int aboveSample = pSrc[-srcStride]; |
---|
2205 | for(k=0;k<blkSize;k++) |
---|
2206 | { |
---|
2207 | leftColumn[k] = aboveSample; |
---|
2208 | } |
---|
2209 | } |
---|
2210 | } |
---|
2211 | #endif |
---|
2212 | |
---|
2213 | // Prepare intermediate variables used in interpolation |
---|
2214 | bottomLeft = leftColumn[blkSize-1]; |
---|
2215 | topRight = topRow[blkSize-1]; |
---|
2216 | for (k=0;k<blkSize;k++) |
---|
2217 | { |
---|
2218 | bottomRow[k] = bottomLeft - topRow[k]; |
---|
2219 | rightColumn[k] = topRight - leftColumn[k]; |
---|
2220 | topRow[k] <<= shift1D; |
---|
2221 | leftColumn[k] <<= shift1D; |
---|
2222 | } |
---|
2223 | |
---|
2224 | // Generate prediction signal |
---|
2225 | for (k=0;k<blkSize;k++) |
---|
2226 | { |
---|
2227 | horPred = leftColumn[k] + offset2D; |
---|
2228 | for (l=0;l<blkSize;l++) |
---|
2229 | { |
---|
2230 | horPred += rightColumn[k]; |
---|
2231 | topRow[l] += bottomRow[l]; |
---|
2232 | rpDst[k*dstStride+l] = ( (horPred + topRow[l]) >> shift2D ); |
---|
2233 | } |
---|
2234 | } |
---|
2235 | } |
---|
2236 | #endif |
---|
2237 | |
---|
2238 | #if LM_CHROMA |
---|
2239 | /** Function for deriving chroma LM intra prediction. |
---|
2240 | * \param pcPattern pointer to neighbouring pixel access pattern |
---|
2241 | * \param pSrc pointer to reconstructed chroma sample array |
---|
2242 | * \param pPred pointer for the prediction sample array |
---|
2243 | * \param uiPredStride the stride of the prediction sample array |
---|
2244 | * \param uiCWidth the width of the chroma block |
---|
2245 | * \param uiCHeight the height of the chroma block |
---|
2246 | * \param uiChromaId boolean indication of chroma component |
---|
2247 | |
---|
2248 | \ This function derives the prediction samples for chroma LM mode (chroma intra coding) |
---|
2249 | */ |
---|
2250 | Void TComPrediction::predLMIntraChroma( TComPattern* pcPattern, Int* piSrc, Pel* pPred, UInt uiPredStride, UInt uiCWidth, UInt uiCHeight, UInt uiChromaId ) |
---|
2251 | { |
---|
2252 | UInt uiWidth = uiCWidth << 1; |
---|
2253 | UInt uiHeight = uiCHeight << 1; |
---|
2254 | |
---|
2255 | if (uiChromaId == 0) |
---|
2256 | xGetRecPixels( pcPattern, pcPattern->getROIY(), pcPattern->getPatternLStride(), m_pLumaRecBuffer + m_iLumaRecStride + 1, m_iLumaRecStride, uiWidth, uiHeight ); |
---|
2257 | |
---|
2258 | xGetLLSPrediction( pcPattern, piSrc+uiWidth+2, uiWidth+1, pPred, uiPredStride, uiCWidth, uiCHeight, 1 ); |
---|
2259 | } |
---|
2260 | |
---|
2261 | /** Function for deriving downsampled luma sample of current chroma block and its above, left causal pixel |
---|
2262 | * \param pcPattern pointer to neighbouring pixel access pattern |
---|
2263 | * \param pRecSrc pointer to reconstructed luma sample array |
---|
2264 | * \param iRecSrcStride the stride of reconstructed luma sample array |
---|
2265 | * \param pDst0 pointer to downsampled luma sample array |
---|
2266 | * \param iDstStride the stride of downsampled luma sample array |
---|
2267 | * \param uiWidth0 the width of the luma block |
---|
2268 | * \param uiHeight0 the height of the luma block |
---|
2269 | |
---|
2270 | \ This function derives downsampled luma sample of current chroma block and its above, left causal pixel |
---|
2271 | */ |
---|
2272 | |
---|
2273 | Void TComPrediction::xGetRecPixels( TComPattern* pcPattern, Pel* pRecSrc, Int iRecSrcStride, Pel* pDst0, Int iDstStride, UInt uiWidth0, UInt uiHeight0 ) |
---|
2274 | { |
---|
2275 | Pel* pSrc = pRecSrc; |
---|
2276 | Pel* pDst = pDst0; |
---|
2277 | |
---|
2278 | Int uiCWidth = uiWidth0/2; |
---|
2279 | Int uiCHeight = uiHeight0/2; |
---|
2280 | |
---|
2281 | if( pcPattern->isLeftAvailable() ) |
---|
2282 | { |
---|
2283 | pSrc = pSrc - 2; |
---|
2284 | pDst = pDst - 1; |
---|
2285 | |
---|
2286 | uiCWidth += 1; |
---|
2287 | } |
---|
2288 | |
---|
2289 | if( pcPattern->isAboveAvailable() ) |
---|
2290 | { |
---|
2291 | pSrc = pSrc - 2*iRecSrcStride; |
---|
2292 | pDst = pDst - iDstStride; |
---|
2293 | |
---|
2294 | uiCHeight += 1; |
---|
2295 | } |
---|
2296 | |
---|
2297 | for( Int j = 0; j < uiCHeight; j++ ) |
---|
2298 | { |
---|
2299 | for( Int i = 0, ii = i << 1; i < uiCWidth; i++, ii = i << 1 ) |
---|
2300 | pDst[i] = (pSrc[ii] + pSrc[ii + iRecSrcStride]) >> 1; |
---|
2301 | |
---|
2302 | pDst += iDstStride; |
---|
2303 | pSrc += iRecSrcStride*2; |
---|
2304 | } |
---|
2305 | } |
---|
2306 | |
---|
2307 | /** Function for deriving the positon of first non-zero binary bit of a value |
---|
2308 | * \param x input value |
---|
2309 | \ This function derives the positon of first non-zero binary bit of a value |
---|
2310 | */ |
---|
2311 | Int GetMSB( UInt x ) |
---|
2312 | { |
---|
2313 | #if 1 |
---|
2314 | Int iMSB = 0, bits = ( sizeof( Int ) << 3 ), y = 1; |
---|
2315 | |
---|
2316 | while( x > 1 ) |
---|
2317 | { |
---|
2318 | bits >>= 1; |
---|
2319 | y = x >> bits; |
---|
2320 | |
---|
2321 | if( y ) |
---|
2322 | { |
---|
2323 | x = y; |
---|
2324 | iMSB += bits; |
---|
2325 | } |
---|
2326 | } |
---|
2327 | |
---|
2328 | iMSB+=y; |
---|
2329 | |
---|
2330 | #else |
---|
2331 | |
---|
2332 | Int iMSB = 0; |
---|
2333 | while( x > 0 ) |
---|
2334 | { |
---|
2335 | x >>= 1; |
---|
2336 | iMSB++; |
---|
2337 | } |
---|
2338 | #endif |
---|
2339 | |
---|
2340 | return iMSB; |
---|
2341 | } |
---|
2342 | |
---|
2343 | /** Function for deriving LM intra prediction. |
---|
2344 | * \param pcPattern pointer to neighbouring pixel access pattern |
---|
2345 | * \param pSrc0 pointer to reconstructed chroma sample array |
---|
2346 | * \param iSrcStride the stride of reconstructed chroma sample array |
---|
2347 | * \param pDst0 reference to pointer for the prediction sample array |
---|
2348 | * \param iDstStride the stride of the prediction sample array |
---|
2349 | * \param uiWidth the width of the chroma block |
---|
2350 | * \param uiHeight the height of the chroma block |
---|
2351 | * \param uiExt0 line number of neiggboirng pixels for calculating LM model parameter, default value is 1 |
---|
2352 | |
---|
2353 | \ This function derives the prediction samples for chroma LM mode (chroma intra coding) |
---|
2354 | */ |
---|
2355 | Void TComPrediction::xGetLLSPrediction( TComPattern* pcPattern, Int* pSrc0, Int iSrcStride, Pel* pDst0, Int iDstStride, UInt uiWidth, UInt uiHeight, UInt uiExt0 ) |
---|
2356 | { |
---|
2357 | |
---|
2358 | Pel *pDst, *pLuma; |
---|
2359 | Int *pSrc; |
---|
2360 | |
---|
2361 | Int iLumaStride = m_iLumaRecStride; |
---|
2362 | Pel* pLuma0 = m_pLumaRecBuffer + uiExt0 * iLumaStride + uiExt0; |
---|
2363 | |
---|
2364 | Int i, j, iCountShift = 0; |
---|
2365 | |
---|
2366 | UInt uiExt = uiExt0; |
---|
2367 | |
---|
2368 | // LLS parameters estimation --> |
---|
2369 | |
---|
2370 | Int x = 0, y = 0, xx = 0, xy = 0; |
---|
2371 | |
---|
2372 | if( pcPattern->isAboveAvailable() ) |
---|
2373 | { |
---|
2374 | pSrc = pSrc0 - iSrcStride; |
---|
2375 | pLuma = pLuma0 - iLumaStride; |
---|
2376 | |
---|
2377 | for( j = 0; j < uiWidth; j++ ) |
---|
2378 | { |
---|
2379 | x += pLuma[j]; |
---|
2380 | y += pSrc[j]; |
---|
2381 | xx += pLuma[j] * pLuma[j]; |
---|
2382 | xy += pLuma[j] * pSrc[j]; |
---|
2383 | } |
---|
2384 | iCountShift += g_aucConvertToBit[ uiWidth ] + 2; |
---|
2385 | } |
---|
2386 | |
---|
2387 | if( pcPattern->isLeftAvailable() ) |
---|
2388 | { |
---|
2389 | pSrc = pSrc0 - uiExt; |
---|
2390 | pLuma = pLuma0 - uiExt; |
---|
2391 | |
---|
2392 | for( i = 0; i < uiHeight; i++ ) |
---|
2393 | { |
---|
2394 | x += pLuma[0]; |
---|
2395 | y += pSrc[0]; |
---|
2396 | xx += pLuma[0] * pLuma[0]; |
---|
2397 | xy += pLuma[0] * pSrc[0]; |
---|
2398 | |
---|
2399 | pSrc += iSrcStride; |
---|
2400 | pLuma += iLumaStride; |
---|
2401 | } |
---|
2402 | iCountShift += iCountShift > 0 ? 1 : ( g_aucConvertToBit[ uiWidth ] + 2 ); |
---|
2403 | } |
---|
2404 | |
---|
2405 | Int iBitdepth = ( ( g_uiBitDepth + g_uiBitIncrement ) + g_aucConvertToBit[ uiWidth ] + 3 ) * 2; |
---|
2406 | Int iTempShift = Max( ( iBitdepth - 31 + 1) / 2, 0); |
---|
2407 | |
---|
2408 | if(iTempShift > 0) |
---|
2409 | { |
---|
2410 | x = ( x + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
2411 | y = ( y + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
2412 | xx = ( xx + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
2413 | xy = ( xy + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
2414 | iCountShift -= iTempShift; |
---|
2415 | } |
---|
2416 | |
---|
2417 | Int a, b, iShift = 13; |
---|
2418 | |
---|
2419 | if( iCountShift == 0 ) |
---|
2420 | { |
---|
2421 | a = 0; |
---|
2422 | b = 128 << g_uiBitIncrement; |
---|
2423 | iShift = 0; |
---|
2424 | } |
---|
2425 | else |
---|
2426 | { |
---|
2427 | Int a1 = ( xy << iCountShift ) - y * x; |
---|
2428 | Int a2 = ( xx << iCountShift ) - x * x; |
---|
2429 | |
---|
2430 | if( a2 == 0 || a1 == 0 ) |
---|
2431 | { |
---|
2432 | a = 0; |
---|
2433 | b = ( y + ( 1 << ( iCountShift - 1 ) ) )>> iCountShift; |
---|
2434 | iShift = 0; |
---|
2435 | } |
---|
2436 | else |
---|
2437 | { |
---|
2438 | const Int iShiftA2 = 6; |
---|
2439 | const Int iShiftA1 = 15; |
---|
2440 | const Int iAccuracyShift = 15; |
---|
2441 | |
---|
2442 | Int iScaleShiftA2 = 0; |
---|
2443 | Int iScaleShiftA1 = 0; |
---|
2444 | Int a1s = a1; |
---|
2445 | Int a2s = a2; |
---|
2446 | |
---|
2447 | iScaleShiftA1 = GetMSB( abs( a1 ) ) - iShiftA1; |
---|
2448 | iScaleShiftA2 = GetMSB( abs( a2 ) ) - iShiftA2; |
---|
2449 | |
---|
2450 | if( iScaleShiftA1 < 0 ) |
---|
2451 | iScaleShiftA1 = 0; |
---|
2452 | |
---|
2453 | if( iScaleShiftA2 < 0 ) |
---|
2454 | iScaleShiftA2 = 0; |
---|
2455 | |
---|
2456 | Int iScaleShiftA = iScaleShiftA2 + iAccuracyShift - iShift - iScaleShiftA1; |
---|
2457 | |
---|
2458 | a2s = a2 >> iScaleShiftA2; |
---|
2459 | |
---|
2460 | a1s = a1 >> iScaleShiftA1; |
---|
2461 | |
---|
2462 | a = a1s * m_uiaShift[ abs( a2s ) ]; |
---|
2463 | |
---|
2464 | if( iScaleShiftA < 0 ) |
---|
2465 | a = a << -iScaleShiftA; |
---|
2466 | else |
---|
2467 | a = a >> iScaleShiftA; |
---|
2468 | |
---|
2469 | if( a > ( 1 << 15 ) - 1 ) |
---|
2470 | a = ( 1 << 15 ) - 1; |
---|
2471 | else if( a < -( 1 << 15 ) ) |
---|
2472 | a = -( 1 << 15 ); |
---|
2473 | |
---|
2474 | b = ( y - ( ( a * x ) >> iShift ) + ( 1 << ( iCountShift - 1 ) ) ) >> iCountShift; |
---|
2475 | } |
---|
2476 | } |
---|
2477 | |
---|
2478 | // <-- end of LLS parameters estimation |
---|
2479 | |
---|
2480 | // get prediction --> |
---|
2481 | uiExt = uiExt0; |
---|
2482 | pLuma = pLuma0; |
---|
2483 | pDst = pDst0; |
---|
2484 | |
---|
2485 | for( i = 0; i < uiHeight; i++ ) |
---|
2486 | { |
---|
2487 | for( j = 0; j < uiWidth; j++ ) |
---|
2488 | pDst[j] = Clip( ( ( a * pLuma[j] ) >> iShift ) + b ); |
---|
2489 | |
---|
2490 | pDst += iDstStride; |
---|
2491 | pLuma += iLumaStride; |
---|
2492 | } |
---|
2493 | // <-- end of get prediction |
---|
2494 | |
---|
2495 | } |
---|
2496 | #endif |
---|
2497 | |
---|
2498 | #if MN_DC_PRED_FILTER |
---|
2499 | /** Function for filtering intra DC predictor. |
---|
2500 | * \param pSrc pointer to reconstructed sample array |
---|
2501 | * \param iSrcStride the stride of the reconstructed sample array |
---|
2502 | * \param rpDst reference to pointer for the prediction sample array |
---|
2503 | * \param iDstStride the stride of the prediction sample array |
---|
2504 | * \param iWidth the width of the block |
---|
2505 | * \param iHeight the height of the block |
---|
2506 | * |
---|
2507 | * This function performs filtering left and top edges of the prediction samples for DC mode (intra coding). |
---|
2508 | */ |
---|
2509 | Void TComPrediction::xDCPredFiltering( Int* pSrc, Int iSrcStride, Pel*& rpDst, Int iDstStride, Int iWidth, Int iHeight ) |
---|
2510 | { |
---|
2511 | Pel* pDst = rpDst; |
---|
2512 | Int x, y, iDstStride2, iSrcStride2; |
---|
2513 | Int iIntraSizeIdx = g_aucConvertToBit[ iWidth ] + 1; |
---|
2514 | static const UChar g_aucDCPredFilter[7] = { 0, 3, 2, 1, 0, 0, 0}; |
---|
2515 | |
---|
2516 | switch (g_aucDCPredFilter[iIntraSizeIdx]) |
---|
2517 | { |
---|
2518 | case 0: |
---|
2519 | {} |
---|
2520 | break; |
---|
2521 | case 1: |
---|
2522 | { |
---|
2523 | // boundary pixels processing |
---|
2524 | pDst[0] = (Pel)((pSrc[-iSrcStride] + pSrc[-1] + 6 * pDst[0] + 4) >> 3); |
---|
2525 | |
---|
2526 | for ( x = 1; x < iWidth; x++ ) |
---|
2527 | pDst[x] = (Pel)((pSrc[x - iSrcStride] + 7 * pDst[x] + 4) >> 3); |
---|
2528 | |
---|
2529 | for ( y = 1, iDstStride2 = iDstStride, iSrcStride2 = iSrcStride-1; y < iHeight; y++, iDstStride2+=iDstStride, iSrcStride2+=iSrcStride ) |
---|
2530 | pDst[iDstStride2] = (Pel)((pSrc[iSrcStride2] + 7 * pDst[iDstStride2] + 4) >> 3); |
---|
2531 | } |
---|
2532 | break; |
---|
2533 | case 2: |
---|
2534 | { |
---|
2535 | // boundary pixels processing |
---|
2536 | pDst[0] = (Pel)((pSrc[-iSrcStride] + pSrc[-1] + 2 * pDst[0] + 2) >> 2); |
---|
2537 | |
---|
2538 | for ( x = 1; x < iWidth; x++ ) |
---|
2539 | pDst[x] = (Pel)((pSrc[x - iSrcStride] + 3 * pDst[x] + 2) >> 2); |
---|
2540 | |
---|
2541 | for ( y = 1, iDstStride2 = iDstStride, iSrcStride2 = iSrcStride-1; y < iHeight; y++, iDstStride2+=iDstStride, iSrcStride2+=iSrcStride ) |
---|
2542 | pDst[iDstStride2] = (Pel)((pSrc[iSrcStride2] + 3 * pDst[iDstStride2] + 2) >> 2); |
---|
2543 | } |
---|
2544 | break; |
---|
2545 | case 3: |
---|
2546 | { |
---|
2547 | // boundary pixels processing |
---|
2548 | pDst[0] = (Pel)((3 * (pSrc[-iSrcStride] + pSrc[-1]) + 2 * pDst[0] + 4) >> 3); |
---|
2549 | |
---|
2550 | for ( x = 1; x < iWidth; x++ ) |
---|
2551 | pDst[x] = (Pel)((3 * pSrc[x - iSrcStride] + 5 * pDst[x] + 4) >> 3); |
---|
2552 | |
---|
2553 | for ( y = 1, iDstStride2 = iDstStride, iSrcStride2 = iSrcStride-1; y < iHeight; y++, iDstStride2+=iDstStride, iSrcStride2+=iSrcStride ) |
---|
2554 | pDst[iDstStride2] = (Pel)((3 * pSrc[iSrcStride2] + 5 * pDst[iDstStride2] + 4) >> 3); |
---|
2555 | } |
---|
2556 | break; |
---|
2557 | } |
---|
2558 | |
---|
2559 | return; |
---|
2560 | } |
---|
2561 | #endif |
---|
2562 | |
---|
2563 | #if HHI_DMM_INTRA |
---|
2564 | TComWedgeDist::TComWedgeDist() |
---|
2565 | { |
---|
2566 | init(); |
---|
2567 | } |
---|
2568 | |
---|
2569 | TComWedgeDist::~TComWedgeDist() |
---|
2570 | { |
---|
2571 | } |
---|
2572 | |
---|
2573 | Void TComWedgeDist::init() |
---|
2574 | { |
---|
2575 | // m_afpDistortFunc[0] = NULL; // for DF_DEFAULT |
---|
2576 | |
---|
2577 | // m_afpDistortFunc[8] = TComRdCost::xGetSAD; |
---|
2578 | m_afpDistortFunc[0] = TComWedgeDist::xGetSAD4; |
---|
2579 | m_afpDistortFunc[1] = TComWedgeDist::xGetSAD8; |
---|
2580 | m_afpDistortFunc[2] = TComWedgeDist::xGetSAD16; |
---|
2581 | m_afpDistortFunc[3] = TComWedgeDist::xGetSAD32; |
---|
2582 | |
---|
2583 | m_afpDistortFunc[4] = TComWedgeDist::xGetSSE4; |
---|
2584 | m_afpDistortFunc[5] = TComWedgeDist::xGetSSE8; |
---|
2585 | m_afpDistortFunc[6] = TComWedgeDist::xGetSSE16; |
---|
2586 | m_afpDistortFunc[7] = TComWedgeDist::xGetSSE32; |
---|
2587 | |
---|
2588 | // m_afpDistortFunc[13] = TComRdCost::xGetSAD64; |
---|
2589 | #ifdef ROUNDING_CONTROL_BIPRED |
---|
2590 | // m_afpDistortFuncRnd[0] = NULL; |
---|
2591 | // m_afpDistortFuncRnd[8] = TComRdCost::xGetSAD; |
---|
2592 | m_afpDistortFuncRnd[9] = TComRdCost::xGetSAD4; |
---|
2593 | m_afpDistortFuncRnd[10] = TComRdCost::xGetSAD8; |
---|
2594 | m_afpDistortFuncRnd[11] = TComRdCost::xGetSAD16; |
---|
2595 | m_afpDistortFuncRnd[12] = TComRdCost::xGetSAD32; |
---|
2596 | // m_afpDistortFuncRnd[13] = TComRdCost::xGetSAD64; |
---|
2597 | #endif |
---|
2598 | } |
---|
2599 | |
---|
2600 | UInt TComWedgeDist::xGetSAD4( DistParam* pcDtParam ) |
---|
2601 | { |
---|
2602 | Pel* piOrg = pcDtParam->pOrg; |
---|
2603 | Pel* piCur = pcDtParam->pCur; |
---|
2604 | Int iRows = pcDtParam->iRows; |
---|
2605 | Int iSubShift = pcDtParam->iSubShift; |
---|
2606 | Int iSubStep = ( 1 << iSubShift ); |
---|
2607 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
2608 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
2609 | |
---|
2610 | UInt uiSum = 0; |
---|
2611 | |
---|
2612 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
2613 | { |
---|
2614 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
2615 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
2616 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
2617 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
2618 | |
---|
2619 | piOrg += iStrideOrg; |
---|
2620 | piCur += iStrideCur; |
---|
2621 | } |
---|
2622 | |
---|
2623 | uiSum <<= iSubShift; |
---|
2624 | return ( uiSum >> g_uiBitIncrement ); |
---|
2625 | } |
---|
2626 | |
---|
2627 | UInt TComWedgeDist::xGetSAD8( DistParam* pcDtParam ) |
---|
2628 | { |
---|
2629 | Pel* piOrg = pcDtParam->pOrg; |
---|
2630 | Pel* piCur = pcDtParam->pCur; |
---|
2631 | Int iRows = pcDtParam->iRows; |
---|
2632 | Int iSubShift = pcDtParam->iSubShift; |
---|
2633 | Int iSubStep = ( 1 << iSubShift ); |
---|
2634 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
2635 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
2636 | |
---|
2637 | UInt uiSum = 0; |
---|
2638 | |
---|
2639 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
2640 | { |
---|
2641 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
2642 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
2643 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
2644 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
2645 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
2646 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
2647 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
2648 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
2649 | |
---|
2650 | piOrg += iStrideOrg; |
---|
2651 | piCur += iStrideCur; |
---|
2652 | } |
---|
2653 | |
---|
2654 | uiSum <<= iSubShift; |
---|
2655 | return ( uiSum >> g_uiBitIncrement ); |
---|
2656 | } |
---|
2657 | |
---|
2658 | UInt TComWedgeDist::xGetSAD16( DistParam* pcDtParam ) |
---|
2659 | { |
---|
2660 | Pel* piOrg = pcDtParam->pOrg; |
---|
2661 | Pel* piCur = pcDtParam->pCur; |
---|
2662 | Int iRows = pcDtParam->iRows; |
---|
2663 | Int iSubShift = pcDtParam->iSubShift; |
---|
2664 | Int iSubStep = ( 1 << iSubShift ); |
---|
2665 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
2666 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
2667 | |
---|
2668 | UInt uiSum = 0; |
---|
2669 | |
---|
2670 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
2671 | { |
---|
2672 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
2673 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
2674 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
2675 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
2676 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
2677 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
2678 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
2679 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
2680 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
2681 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
2682 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
2683 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
2684 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
2685 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
2686 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
2687 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
2688 | |
---|
2689 | piOrg += iStrideOrg; |
---|
2690 | piCur += iStrideCur; |
---|
2691 | } |
---|
2692 | |
---|
2693 | uiSum <<= iSubShift; |
---|
2694 | return ( uiSum >> g_uiBitIncrement ); |
---|
2695 | } |
---|
2696 | |
---|
2697 | UInt TComWedgeDist::xGetSAD32( DistParam* pcDtParam ) |
---|
2698 | { |
---|
2699 | Pel* piOrg = pcDtParam->pOrg; |
---|
2700 | Pel* piCur = pcDtParam->pCur; |
---|
2701 | Int iRows = pcDtParam->iRows; |
---|
2702 | Int iSubShift = pcDtParam->iSubShift; |
---|
2703 | Int iSubStep = ( 1 << iSubShift ); |
---|
2704 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
2705 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
2706 | |
---|
2707 | UInt uiSum = 0; |
---|
2708 | |
---|
2709 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
2710 | { |
---|
2711 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
2712 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
2713 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
2714 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
2715 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
2716 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
2717 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
2718 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
2719 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
2720 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
2721 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
2722 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
2723 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
2724 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
2725 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
2726 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
2727 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
2728 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
2729 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
2730 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
2731 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
2732 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
2733 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
2734 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
2735 | uiSum += abs( piOrg[24] - piCur[24] ); |
---|
2736 | uiSum += abs( piOrg[25] - piCur[25] ); |
---|
2737 | uiSum += abs( piOrg[26] - piCur[26] ); |
---|
2738 | uiSum += abs( piOrg[27] - piCur[27] ); |
---|
2739 | uiSum += abs( piOrg[28] - piCur[28] ); |
---|
2740 | uiSum += abs( piOrg[29] - piCur[29] ); |
---|
2741 | uiSum += abs( piOrg[30] - piCur[30] ); |
---|
2742 | uiSum += abs( piOrg[31] - piCur[31] ); |
---|
2743 | |
---|
2744 | piOrg += iStrideOrg; |
---|
2745 | piCur += iStrideCur; |
---|
2746 | } |
---|
2747 | |
---|
2748 | uiSum <<= iSubShift; |
---|
2749 | return ( uiSum >> g_uiBitIncrement ); |
---|
2750 | } |
---|
2751 | |
---|
2752 | UInt TComWedgeDist::xGetSSE4( DistParam* pcDtParam ) |
---|
2753 | { |
---|
2754 | Pel* piOrg = pcDtParam->pOrg; |
---|
2755 | Pel* piCur = pcDtParam->pCur; |
---|
2756 | Int iRows = pcDtParam->iRows; |
---|
2757 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
2758 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
2759 | |
---|
2760 | UInt uiSum = 0; |
---|
2761 | UInt uiShift = g_uiBitIncrement<<1; |
---|
2762 | |
---|
2763 | Int iTemp; |
---|
2764 | |
---|
2765 | for( ; iRows != 0; iRows-- ) |
---|
2766 | { |
---|
2767 | |
---|
2768 | iTemp = piOrg[0] - piCur[0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2769 | iTemp = piOrg[1] - piCur[1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2770 | iTemp = piOrg[2] - piCur[2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2771 | iTemp = piOrg[3] - piCur[3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2772 | |
---|
2773 | piOrg += iStrideOrg; |
---|
2774 | piCur += iStrideCur; |
---|
2775 | } |
---|
2776 | |
---|
2777 | return ( uiSum ); |
---|
2778 | } |
---|
2779 | |
---|
2780 | UInt TComWedgeDist::xGetSSE8( DistParam* pcDtParam ) |
---|
2781 | { |
---|
2782 | Pel* piOrg = pcDtParam->pOrg; |
---|
2783 | Pel* piCur = pcDtParam->pCur; |
---|
2784 | Int iRows = pcDtParam->iRows; |
---|
2785 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
2786 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
2787 | |
---|
2788 | UInt uiSum = 0; |
---|
2789 | UInt uiShift = g_uiBitIncrement<<1; |
---|
2790 | |
---|
2791 | Int iTemp; |
---|
2792 | |
---|
2793 | for( ; iRows != 0; iRows-- ) |
---|
2794 | { |
---|
2795 | iTemp = piOrg[0] - piCur[0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2796 | iTemp = piOrg[1] - piCur[1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2797 | iTemp = piOrg[2] - piCur[2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2798 | iTemp = piOrg[3] - piCur[3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2799 | iTemp = piOrg[4] - piCur[4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2800 | iTemp = piOrg[5] - piCur[5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2801 | iTemp = piOrg[6] - piCur[6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2802 | iTemp = piOrg[7] - piCur[7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2803 | |
---|
2804 | piOrg += iStrideOrg; |
---|
2805 | piCur += iStrideCur; |
---|
2806 | } |
---|
2807 | |
---|
2808 | return ( uiSum ); |
---|
2809 | } |
---|
2810 | |
---|
2811 | UInt TComWedgeDist::xGetSSE16( DistParam* pcDtParam ) |
---|
2812 | { |
---|
2813 | Pel* piOrg = pcDtParam->pOrg; |
---|
2814 | Pel* piCur = pcDtParam->pCur; |
---|
2815 | Int iRows = pcDtParam->iRows; |
---|
2816 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
2817 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
2818 | |
---|
2819 | UInt uiSum = 0; |
---|
2820 | UInt uiShift = g_uiBitIncrement<<1; |
---|
2821 | |
---|
2822 | Int iTemp; |
---|
2823 | |
---|
2824 | for( ; iRows != 0; iRows-- ) |
---|
2825 | { |
---|
2826 | |
---|
2827 | iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2828 | iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2829 | iTemp = piOrg[ 2] - piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2830 | iTemp = piOrg[ 3] - piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2831 | iTemp = piOrg[ 4] - piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2832 | iTemp = piOrg[ 5] - piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2833 | iTemp = piOrg[ 6] - piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2834 | iTemp = piOrg[ 7] - piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2835 | iTemp = piOrg[ 8] - piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2836 | iTemp = piOrg[ 9] - piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2837 | iTemp = piOrg[10] - piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2838 | iTemp = piOrg[11] - piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2839 | iTemp = piOrg[12] - piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2840 | iTemp = piOrg[13] - piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2841 | iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2842 | iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2843 | |
---|
2844 | piOrg += iStrideOrg; |
---|
2845 | piCur += iStrideCur; |
---|
2846 | } |
---|
2847 | |
---|
2848 | return ( uiSum ); |
---|
2849 | } |
---|
2850 | |
---|
2851 | UInt TComWedgeDist::xGetSSE32( DistParam* pcDtParam ) |
---|
2852 | { |
---|
2853 | Pel* piOrg = pcDtParam->pOrg; |
---|
2854 | Pel* piCur = pcDtParam->pCur; |
---|
2855 | Int iRows = pcDtParam->iRows; |
---|
2856 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
2857 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
2858 | |
---|
2859 | UInt uiSum = 0; |
---|
2860 | UInt uiShift = g_uiBitIncrement<<1; |
---|
2861 | Int iTemp; |
---|
2862 | |
---|
2863 | for( ; iRows != 0; iRows-- ) |
---|
2864 | { |
---|
2865 | |
---|
2866 | iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2867 | iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2868 | iTemp = piOrg[ 2] - piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2869 | iTemp = piOrg[ 3] - piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2870 | iTemp = piOrg[ 4] - piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2871 | iTemp = piOrg[ 5] - piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2872 | iTemp = piOrg[ 6] - piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2873 | iTemp = piOrg[ 7] - piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2874 | iTemp = piOrg[ 8] - piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2875 | iTemp = piOrg[ 9] - piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2876 | iTemp = piOrg[10] - piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2877 | iTemp = piOrg[11] - piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2878 | iTemp = piOrg[12] - piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2879 | iTemp = piOrg[13] - piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2880 | iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2881 | iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2882 | iTemp = piOrg[16] - piCur[16]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2883 | iTemp = piOrg[17] - piCur[17]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2884 | iTemp = piOrg[18] - piCur[18]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2885 | iTemp = piOrg[19] - piCur[19]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2886 | iTemp = piOrg[20] - piCur[20]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2887 | iTemp = piOrg[21] - piCur[21]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2888 | iTemp = piOrg[22] - piCur[22]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2889 | iTemp = piOrg[23] - piCur[23]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2890 | iTemp = piOrg[24] - piCur[24]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2891 | iTemp = piOrg[25] - piCur[25]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2892 | iTemp = piOrg[26] - piCur[26]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2893 | iTemp = piOrg[27] - piCur[27]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2894 | iTemp = piOrg[28] - piCur[28]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2895 | iTemp = piOrg[29] - piCur[29]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2896 | iTemp = piOrg[30] - piCur[30]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2897 | iTemp = piOrg[31] - piCur[31]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2898 | |
---|
2899 | piOrg += iStrideOrg; |
---|
2900 | piCur += iStrideCur; |
---|
2901 | } |
---|
2902 | |
---|
2903 | return ( uiSum ); |
---|
2904 | } |
---|
2905 | |
---|
2906 | Void TComWedgeDist::setDistParam( UInt uiBlkWidth, UInt uiBlkHeight, WedgeDist eWDist, DistParam& rcDistParam ) |
---|
2907 | { |
---|
2908 | // set Block Width / Height |
---|
2909 | rcDistParam.iCols = uiBlkWidth; |
---|
2910 | rcDistParam.iRows = uiBlkHeight; |
---|
2911 | rcDistParam.DistFunc = m_afpDistortFunc[eWDist + g_aucConvertToBit[ rcDistParam.iCols ] ]; |
---|
2912 | |
---|
2913 | // initialize |
---|
2914 | rcDistParam.iSubShift = 0; |
---|
2915 | } |
---|
2916 | |
---|
2917 | UInt TComWedgeDist::getDistPart( Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, WedgeDist eWDist ) |
---|
2918 | { |
---|
2919 | DistParam cDtParam; |
---|
2920 | setDistParam( uiBlkWidth, uiBlkHeight, eWDist, cDtParam ); |
---|
2921 | cDtParam.pOrg = piOrg; |
---|
2922 | cDtParam.pCur = piCur; |
---|
2923 | cDtParam.iStrideOrg = iOrgStride; |
---|
2924 | cDtParam.iStrideCur = iCurStride; |
---|
2925 | #ifdef DCM_RDCOST_TEMP_FIX //Temporary fix since DistParam is lacking a constructor and the variable iStep is not initialized |
---|
2926 | cDtParam.iStep = 1; |
---|
2927 | #endif |
---|
2928 | return cDtParam.DistFunc( &cDtParam ); |
---|
2929 | } |
---|
2930 | #endif |
---|