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