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 DEPTH_MAP_GENERATION |
---|
1524 | if( bPrdDepthMap ) |
---|
1525 | { |
---|
1526 | iWidth >>= uiSubSampExpX; |
---|
1527 | iHeight >>= uiSubSampExpY; |
---|
1528 | } |
---|
1529 | #endif |
---|
1530 | |
---|
1531 | if ( eRefPicList != REF_PIC_LIST_X ) |
---|
1532 | { |
---|
1533 | #if DEPTH_MAP_GENERATION |
---|
1534 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY ); |
---|
1535 | #else |
---|
1536 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx ); |
---|
1537 | #endif |
---|
1538 | #ifdef WEIGHT_PRED |
---|
1539 | if ( pcCU->getSlice()->getPPS()->getUseWP() ) |
---|
1540 | { |
---|
1541 | xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx ); |
---|
1542 | } |
---|
1543 | #endif |
---|
1544 | } |
---|
1545 | else |
---|
1546 | { |
---|
1547 | #if DEPTH_MAP_GENERATION |
---|
1548 | xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, pcYuvPred, iPartIdx, bPrdDepthMap ); |
---|
1549 | #else |
---|
1550 | xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred, iPartIdx ); |
---|
1551 | #endif |
---|
1552 | } |
---|
1553 | return; |
---|
1554 | } |
---|
1555 | |
---|
1556 | for ( iPartIdx = 0; iPartIdx < pcCU->getNumPartInter(); iPartIdx++ ) |
---|
1557 | { |
---|
1558 | pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight ); |
---|
1559 | |
---|
1560 | #if DEPTH_MAP_GENERATION |
---|
1561 | if( bPrdDepthMap ) |
---|
1562 | { |
---|
1563 | iWidth >>= uiSubSampExpX; |
---|
1564 | iHeight >>= uiSubSampExpY; |
---|
1565 | } |
---|
1566 | #endif |
---|
1567 | |
---|
1568 | if ( eRefPicList != REF_PIC_LIST_X ) |
---|
1569 | { |
---|
1570 | #if DEPTH_MAP_GENERATION |
---|
1571 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY ); |
---|
1572 | #else |
---|
1573 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx ); |
---|
1574 | #endif |
---|
1575 | #ifdef WEIGHT_PRED |
---|
1576 | if ( pcCU->getSlice()->getPPS()->getUseWP() ) |
---|
1577 | { |
---|
1578 | xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx ); |
---|
1579 | } |
---|
1580 | #endif |
---|
1581 | } |
---|
1582 | else |
---|
1583 | { |
---|
1584 | #if DEPTH_MAP_GENERATION |
---|
1585 | xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, pcYuvPred, iPartIdx, bPrdDepthMap ); |
---|
1586 | #else |
---|
1587 | xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred, iPartIdx ); |
---|
1588 | #endif |
---|
1589 | } |
---|
1590 | } |
---|
1591 | return; |
---|
1592 | } |
---|
1593 | |
---|
1594 | #if HIGH_ACCURACY_BI |
---|
1595 | #if DEPTH_MAP_GENERATION |
---|
1596 | 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 ) |
---|
1597 | #else |
---|
1598 | Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bi ) |
---|
1599 | #endif |
---|
1600 | #else |
---|
1601 | #if DEPTH_MAP_GENERATION |
---|
1602 | Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY ) |
---|
1603 | #else |
---|
1604 | Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx ) |
---|
1605 | #endif |
---|
1606 | #endif |
---|
1607 | { |
---|
1608 | Int iRefIdx = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); assert (iRefIdx >= 0); |
---|
1609 | TComMv cMv = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr ); |
---|
1610 | pcCU->clipMv(cMv); |
---|
1611 | |
---|
1612 | #if DEPTH_MAP_GENERATION |
---|
1613 | if( bPrdDepthMap ) |
---|
1614 | { |
---|
1615 | UInt uiRShift = 0; |
---|
1616 | xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPredDepthMap(), uiPartAddr, &cMv, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, rpcYuvPred, uiRShift ); |
---|
1617 | return; |
---|
1618 | } |
---|
1619 | #endif |
---|
1620 | |
---|
1621 | #if HHI_FULL_PEL_DEPTH_MAP_MV_ACC |
---|
1622 | if( pcCU->getSlice()->getSPS()->isDepth() ) |
---|
1623 | { |
---|
1624 | #if HIGH_ACCURACY_BI |
---|
1625 | UInt uiRShift = ( bi ? 14-g_uiBitDepth-g_uiBitIncrement : 0 ); |
---|
1626 | #else |
---|
1627 | UInt uiRShift = 0; |
---|
1628 | #endif |
---|
1629 | #if DEPTH_MAP_GENERATION |
---|
1630 | xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, 0, 0, rpcYuvPred, uiRShift ); |
---|
1631 | #else |
---|
1632 | xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, uiRShift ); |
---|
1633 | #endif |
---|
1634 | } |
---|
1635 | else |
---|
1636 | { |
---|
1637 | #endif |
---|
1638 | #if HIGH_ACCURACY_BI |
---|
1639 | if(!bi) |
---|
1640 | { |
---|
1641 | xPredInterLumaBlk ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec() , uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred ); |
---|
1642 | } |
---|
1643 | else |
---|
1644 | { |
---|
1645 | xPredInterLumaBlk_ha ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec() , uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred ); |
---|
1646 | } |
---|
1647 | #else |
---|
1648 | xPredInterLumaBlk ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred ); |
---|
1649 | #endif |
---|
1650 | #if HHI_FULL_PEL_DEPTH_MAP_MV_ACC |
---|
1651 | } |
---|
1652 | #endif |
---|
1653 | |
---|
1654 | #if HIGH_ACCURACY_BI |
---|
1655 | if (!bi) |
---|
1656 | { |
---|
1657 | xPredInterChromaBlk ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred ); |
---|
1658 | } |
---|
1659 | else |
---|
1660 | { |
---|
1661 | xPredInterChromaBlk_ha ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec() , uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred ); |
---|
1662 | } |
---|
1663 | #else |
---|
1664 | xPredInterChromaBlk ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred ); |
---|
1665 | #endif |
---|
1666 | } |
---|
1667 | |
---|
1668 | #if DEPTH_MAP_GENERATION |
---|
1669 | Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap ) |
---|
1670 | #else |
---|
1671 | Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvPred, Int iPartIdx ) |
---|
1672 | #endif |
---|
1673 | { |
---|
1674 | TComYuv* pcMbYuv; |
---|
1675 | Int iRefIdx[2] = {-1, -1}; |
---|
1676 | |
---|
1677 | for ( Int iRefList = 0; iRefList < 2; iRefList++ ) |
---|
1678 | { |
---|
1679 | RefPicList eRefPicList = (iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0); |
---|
1680 | iRefIdx[iRefList] = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
1681 | |
---|
1682 | if ( iRefIdx[iRefList] < 0 ) |
---|
1683 | { |
---|
1684 | continue; |
---|
1685 | } |
---|
1686 | |
---|
1687 | assert( iRefIdx[iRefList] < pcCU->getSlice()->getNumRefIdx(eRefPicList) ); |
---|
1688 | |
---|
1689 | pcMbYuv = &m_acYuvPred[iRefList]; |
---|
1690 | #if HIGH_ACCURACY_BI |
---|
1691 | if( pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr ) >= 0 && pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr ) >= 0 ) |
---|
1692 | #if DEPTH_MAP_GENERATION |
---|
1693 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, true ); |
---|
1694 | #else |
---|
1695 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, true ); |
---|
1696 | #endif |
---|
1697 | else |
---|
1698 | #if DEPTH_MAP_GENERATION |
---|
1699 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY ); |
---|
1700 | #else |
---|
1701 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx ); |
---|
1702 | #endif |
---|
1703 | #else |
---|
1704 | #if DEPTH_MAP_GENERATION |
---|
1705 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY ); |
---|
1706 | #else |
---|
1707 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx ); |
---|
1708 | #endif |
---|
1709 | #endif |
---|
1710 | } |
---|
1711 | |
---|
1712 | #ifdef WEIGHT_PRED |
---|
1713 | if ( pcCU->getSlice()->getPPS()->getWPBiPredIdc() ) |
---|
1714 | { |
---|
1715 | xWeightedPredictionBi( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); |
---|
1716 | } |
---|
1717 | else |
---|
1718 | #endif |
---|
1719 | |
---|
1720 | #if DEPTH_MAP_GENERATION |
---|
1721 | if ( bPrdDepthMap ) |
---|
1722 | { |
---|
1723 | xWeightedAveragePdm( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred, uiSubSampExpX, uiSubSampExpY ); |
---|
1724 | } |
---|
1725 | else |
---|
1726 | { |
---|
1727 | xWeightedAverage( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); |
---|
1728 | } |
---|
1729 | #else |
---|
1730 | xWeightedAverage( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); |
---|
1731 | #endif |
---|
1732 | |
---|
1733 | } |
---|
1734 | |
---|
1735 | |
---|
1736 | Void |
---|
1737 | #if DEPTH_MAP_GENERATION |
---|
1738 | TComPrediction::xPredInterPrdDepthMap( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY, TComYuv*& rpcYuv, UInt uiRShift ) |
---|
1739 | #else |
---|
1740 | TComPrediction::xPredInterPrdDepthMap( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, TComYuv*& rpcYuv, UInt uiRShift ) |
---|
1741 | #endif |
---|
1742 | { |
---|
1743 | #if DEPTH_MAP_GENERATION |
---|
1744 | Int iShiftX = 2 + uiSubSampExpX; |
---|
1745 | Int iShiftY = 2 + uiSubSampExpY; |
---|
1746 | Int iAddX = ( 1 << iShiftX ) >> 1; |
---|
1747 | Int iAddY = ( 1 << iShiftY ) >> 1; |
---|
1748 | Int iHor = ( pcMv->getHor() + iAddX ) >> iShiftX; |
---|
1749 | Int iVer = ( pcMv->getVer() + iAddY ) >> iShiftY; |
---|
1750 | #if HHI_FULL_PEL_DEPTH_MAP_MV_ACC |
---|
1751 | if( pcCU->getSlice()->getSPS()->isDepth() ) |
---|
1752 | { |
---|
1753 | iHor = pcMv->getHor(); |
---|
1754 | iVer = pcMv->getVer(); |
---|
1755 | } |
---|
1756 | #endif |
---|
1757 | Int iRefStride = pcPicYuvRef->getStride(); |
---|
1758 | Int iDstStride = rpcYuv->getStride(); |
---|
1759 | Int iRefOffset = iHor + iVer * iRefStride; |
---|
1760 | #else |
---|
1761 | Int iFPelMask = ~3; |
---|
1762 | Int iRefStride = pcPicYuvRef->getStride(); |
---|
1763 | Int iDstStride = rpcYuv->getStride(); |
---|
1764 | Int iHor = ( pcMv->getHor() + 2 ) & iFPelMask; |
---|
1765 | Int iVer = ( pcMv->getVer() + 2 ) & iFPelMask; |
---|
1766 | #if HHI_FULL_PEL_DEPTH_MAP_MV_ACC |
---|
1767 | if( pcCU->getSlice()->getSPS()->isDepth() ) |
---|
1768 | { |
---|
1769 | iHor = pcMv->getHor() * 4; |
---|
1770 | iVer = pcMv->getVer() * 4; |
---|
1771 | } |
---|
1772 | #endif |
---|
1773 | Int ixFrac = iHor & 0x3; |
---|
1774 | Int iyFrac = iVer & 0x3; |
---|
1775 | Int iRefOffset = ( iHor >> 2 ) + ( iVer >> 2 ) * iRefStride; |
---|
1776 | #endif |
---|
1777 | |
---|
1778 | Pel* piRefY = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset; |
---|
1779 | Pel* piDstY = rpcYuv->getLumaAddr( uiPartAddr ); |
---|
1780 | |
---|
1781 | for( Int y = 0; y < iHeight; y++, piDstY += iDstStride, piRefY += iRefStride ) |
---|
1782 | { |
---|
1783 | for( Int x = 0; x < iWidth; x++ ) |
---|
1784 | { |
---|
1785 | piDstY[ x ] = piRefY[ x ] << uiRShift; |
---|
1786 | } |
---|
1787 | } |
---|
1788 | } |
---|
1789 | |
---|
1790 | |
---|
1791 | |
---|
1792 | #if HIGH_ACCURACY_BI |
---|
1793 | |
---|
1794 | Void TComPrediction::xPredInterLumaBlk_ha( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, TComYuv*& rpcYuv ) |
---|
1795 | { |
---|
1796 | Int iRefStride = pcPicYuvRef->getStride(); |
---|
1797 | Int iDstStride = rpcYuv->getStride(); |
---|
1798 | |
---|
1799 | Int iRefOffset = ( pcMv->getHor() >> 2 ) + ( pcMv->getVer() >> 2 ) * iRefStride; |
---|
1800 | Pel* piRefY = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset; |
---|
1801 | |
---|
1802 | Int ixFrac = pcMv->getHor() & 0x3; |
---|
1803 | Int iyFrac = pcMv->getVer() & 0x3; |
---|
1804 | |
---|
1805 | Pel* piDstY = rpcYuv->getLumaAddr( uiPartAddr ); |
---|
1806 | UInt shiftNum = 14-g_uiBitDepth-g_uiBitIncrement; |
---|
1807 | // Integer point |
---|
1808 | if ( ixFrac == 0 && iyFrac == 0 ) |
---|
1809 | { |
---|
1810 | for ( Int y = 0; y < iHeight; y++ ) |
---|
1811 | { |
---|
1812 | for(Int x=0; x<iWidth; x++) |
---|
1813 | piDstY[x] = piRefY[x]<<shiftNum; |
---|
1814 | piDstY += iDstStride; |
---|
1815 | piRefY += iRefStride; |
---|
1816 | } |
---|
1817 | return; |
---|
1818 | } |
---|
1819 | |
---|
1820 | // Half-pel horizontal |
---|
1821 | if ( ixFrac == 2 && iyFrac == 0 ) |
---|
1822 | { |
---|
1823 | xCTI_FilterHalfHor_ha ( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); |
---|
1824 | return; |
---|
1825 | } |
---|
1826 | |
---|
1827 | // Half-pel vertical |
---|
1828 | if ( ixFrac == 0 && iyFrac == 2 ) |
---|
1829 | { |
---|
1830 | xCTI_FilterHalfVer_ha ( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); |
---|
1831 | return; |
---|
1832 | } |
---|
1833 | |
---|
1834 | Int iExtStride = m_iYuvExtStride;//m_cYuvExt.getStride(); |
---|
1835 | Int* piExtY = m_piYuvExt;//m_cYuvExt.getLumaAddr(); |
---|
1836 | |
---|
1837 | // Half-pel center |
---|
1838 | if ( ixFrac == 2 && iyFrac == 2 ) |
---|
1839 | { |
---|
1840 | xCTI_FilterHalfVer (piRefY - 3, iRefStride, 1, iWidth +7, iHeight, iExtStride, 1, piExtY ); |
---|
1841 | xCTI_FilterHalfHor_ha (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); |
---|
1842 | return; |
---|
1843 | } |
---|
1844 | |
---|
1845 | // Quater-pel horizontal |
---|
1846 | if ( iyFrac == 0) |
---|
1847 | { |
---|
1848 | if ( ixFrac == 1) |
---|
1849 | { |
---|
1850 | xCTI_FilterQuarter0Hor_ha( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); |
---|
1851 | return; |
---|
1852 | } |
---|
1853 | if ( ixFrac == 3) |
---|
1854 | { |
---|
1855 | xCTI_FilterQuarter1Hor_ha( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); |
---|
1856 | return; |
---|
1857 | } |
---|
1858 | } |
---|
1859 | if ( iyFrac == 2 ) |
---|
1860 | { |
---|
1861 | if ( ixFrac == 1) |
---|
1862 | { |
---|
1863 | xCTI_FilterHalfVer (piRefY -3, iRefStride, 1, iWidth +7, iHeight, iExtStride, 1, piExtY ); |
---|
1864 | xCTI_FilterQuarter0Hor_ha (piExtY + 3, iExtStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); |
---|
1865 | return; |
---|
1866 | } |
---|
1867 | if ( ixFrac == 3) |
---|
1868 | { |
---|
1869 | xCTI_FilterHalfVer (piRefY - 3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); |
---|
1870 | xCTI_FilterQuarter1Hor_ha (piExtY + 3, iExtStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); |
---|
1871 | return; |
---|
1872 | } |
---|
1873 | } |
---|
1874 | |
---|
1875 | // Quater-pel vertical |
---|
1876 | if( ixFrac == 0 ) |
---|
1877 | { |
---|
1878 | if( iyFrac == 1 ) |
---|
1879 | { |
---|
1880 | xCTI_FilterQuarter0Ver_ha( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); |
---|
1881 | return; |
---|
1882 | } |
---|
1883 | if( iyFrac == 3 ) |
---|
1884 | { |
---|
1885 | xCTI_FilterQuarter1Ver_ha( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); |
---|
1886 | return; |
---|
1887 | } |
---|
1888 | } |
---|
1889 | |
---|
1890 | if( ixFrac == 2 ) |
---|
1891 | { |
---|
1892 | if( iyFrac == 1 ) |
---|
1893 | { |
---|
1894 | xCTI_FilterQuarter0Ver (piRefY - 3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); |
---|
1895 | xCTI_FilterHalfHor_ha (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); |
---|
1896 | |
---|
1897 | return; |
---|
1898 | } |
---|
1899 | if( iyFrac == 3 ) |
---|
1900 | { |
---|
1901 | xCTI_FilterQuarter1Ver (piRefY -3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); |
---|
1902 | xCTI_FilterHalfHor_ha (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); |
---|
1903 | return; |
---|
1904 | } |
---|
1905 | } |
---|
1906 | |
---|
1907 | /// Quarter-pel center |
---|
1908 | if ( iyFrac == 1) |
---|
1909 | { |
---|
1910 | if ( ixFrac == 1) |
---|
1911 | { |
---|
1912 | xCTI_FilterQuarter0Ver (piRefY - 3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); |
---|
1913 | xCTI_FilterQuarter0Hor_ha (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); |
---|
1914 | return; |
---|
1915 | } |
---|
1916 | if ( ixFrac == 3) |
---|
1917 | { |
---|
1918 | xCTI_FilterQuarter0Ver (piRefY - 3, iRefStride, 1, iWidth +7, iHeight, iExtStride, 1, piExtY ); |
---|
1919 | xCTI_FilterQuarter1Hor_ha (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); |
---|
1920 | |
---|
1921 | return; |
---|
1922 | } |
---|
1923 | } |
---|
1924 | if ( iyFrac == 3 ) |
---|
1925 | { |
---|
1926 | if ( ixFrac == 1) |
---|
1927 | { |
---|
1928 | xCTI_FilterQuarter1Ver (piRefY - 3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); |
---|
1929 | xCTI_FilterQuarter0Hor_ha (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); |
---|
1930 | return; |
---|
1931 | } |
---|
1932 | if ( ixFrac == 3) |
---|
1933 | { |
---|
1934 | xCTI_FilterQuarter1Ver (piRefY - 3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); |
---|
1935 | xCTI_FilterQuarter1Hor_ha (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); |
---|
1936 | return; |
---|
1937 | } |
---|
1938 | } |
---|
1939 | } |
---|
1940 | |
---|
1941 | #endif |
---|
1942 | |
---|
1943 | Void TComPrediction::xPredInterLumaBlk( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, TComYuv*& rpcYuv ) |
---|
1944 | { |
---|
1945 | Int iRefStride = pcPicYuvRef->getStride(); |
---|
1946 | Int iDstStride = rpcYuv->getStride(); |
---|
1947 | |
---|
1948 | Int iRefOffset = ( pcMv->getHor() >> 2 ) + ( pcMv->getVer() >> 2 ) * iRefStride; |
---|
1949 | Pel* piRefY = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset; |
---|
1950 | |
---|
1951 | Int ixFrac = pcMv->getHor() & 0x3; |
---|
1952 | Int iyFrac = pcMv->getVer() & 0x3; |
---|
1953 | |
---|
1954 | Pel* piDstY = rpcYuv->getLumaAddr( uiPartAddr ); |
---|
1955 | |
---|
1956 | // Integer point |
---|
1957 | if ( ixFrac == 0 && iyFrac == 0 ) |
---|
1958 | { |
---|
1959 | for ( Int y = 0; y < iHeight; y++ ) |
---|
1960 | { |
---|
1961 | ::memcpy(piDstY, piRefY, sizeof(Pel)*iWidth); |
---|
1962 | piDstY += iDstStride; |
---|
1963 | piRefY += iRefStride; |
---|
1964 | } |
---|
1965 | return; |
---|
1966 | } |
---|
1967 | |
---|
1968 | // Half-pel horizontal |
---|
1969 | if ( ixFrac == 2 && iyFrac == 0 ) |
---|
1970 | { |
---|
1971 | xCTI_FilterHalfHor ( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); |
---|
1972 | return; |
---|
1973 | } |
---|
1974 | |
---|
1975 | // Half-pel vertical |
---|
1976 | if ( ixFrac == 0 && iyFrac == 2 ) |
---|
1977 | { |
---|
1978 | xCTI_FilterHalfVer ( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); |
---|
1979 | return; |
---|
1980 | } |
---|
1981 | |
---|
1982 | Int iExtStride = m_iYuvExtStride;//m_cYuvExt.getStride(); |
---|
1983 | Int* piExtY = m_piYuvExt;//m_cYuvExt.getLumaAddr(); |
---|
1984 | |
---|
1985 | // Half-pel center |
---|
1986 | if ( ixFrac == 2 && iyFrac == 2 ) |
---|
1987 | { |
---|
1988 | |
---|
1989 | xCTI_FilterHalfVer (piRefY - 3, iRefStride, 1, iWidth +7, iHeight, iExtStride, 1, piExtY ); |
---|
1990 | xCTI_FilterHalfHor (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); |
---|
1991 | return; |
---|
1992 | } |
---|
1993 | |
---|
1994 | // Quater-pel horizontal |
---|
1995 | if ( iyFrac == 0) |
---|
1996 | { |
---|
1997 | if ( ixFrac == 1) |
---|
1998 | { |
---|
1999 | xCTI_FilterQuarter0Hor( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); |
---|
2000 | return; |
---|
2001 | } |
---|
2002 | if ( ixFrac == 3) |
---|
2003 | { |
---|
2004 | xCTI_FilterQuarter1Hor( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); |
---|
2005 | return; |
---|
2006 | } |
---|
2007 | } |
---|
2008 | if ( iyFrac == 2 ) |
---|
2009 | { |
---|
2010 | if ( ixFrac == 1) |
---|
2011 | { |
---|
2012 | xCTI_FilterHalfVer (piRefY -3, iRefStride, 1, iWidth +7, iHeight, iExtStride, 1, piExtY ); |
---|
2013 | xCTI_FilterQuarter0Hor (piExtY + 3, iExtStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); |
---|
2014 | return; |
---|
2015 | } |
---|
2016 | if ( ixFrac == 3) |
---|
2017 | { |
---|
2018 | xCTI_FilterHalfVer (piRefY - 3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); |
---|
2019 | xCTI_FilterQuarter1Hor (piExtY + 3, iExtStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); |
---|
2020 | return; |
---|
2021 | } |
---|
2022 | } |
---|
2023 | |
---|
2024 | // Quater-pel vertical |
---|
2025 | if( ixFrac == 0 ) |
---|
2026 | { |
---|
2027 | if( iyFrac == 1 ) |
---|
2028 | { |
---|
2029 | xCTI_FilterQuarter0Ver( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); |
---|
2030 | return; |
---|
2031 | } |
---|
2032 | if( iyFrac == 3 ) |
---|
2033 | { |
---|
2034 | xCTI_FilterQuarter1Ver( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); |
---|
2035 | return; |
---|
2036 | } |
---|
2037 | } |
---|
2038 | |
---|
2039 | if( ixFrac == 2 ) |
---|
2040 | { |
---|
2041 | if( iyFrac == 1 ) |
---|
2042 | { |
---|
2043 | xCTI_FilterQuarter0Ver (piRefY - 3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); |
---|
2044 | xCTI_FilterHalfHor (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); |
---|
2045 | return; |
---|
2046 | } |
---|
2047 | if( iyFrac == 3 ) |
---|
2048 | { |
---|
2049 | xCTI_FilterQuarter1Ver (piRefY -3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); |
---|
2050 | xCTI_FilterHalfHor (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); |
---|
2051 | return; |
---|
2052 | } |
---|
2053 | } |
---|
2054 | |
---|
2055 | /// Quarter-pel center |
---|
2056 | if ( iyFrac == 1) |
---|
2057 | { |
---|
2058 | if ( ixFrac == 1) |
---|
2059 | { |
---|
2060 | xCTI_FilterQuarter0Ver (piRefY - 3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); |
---|
2061 | xCTI_FilterQuarter0Hor (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); |
---|
2062 | return; |
---|
2063 | } |
---|
2064 | if ( ixFrac == 3) |
---|
2065 | { |
---|
2066 | xCTI_FilterQuarter0Ver (piRefY - 3, iRefStride, 1, iWidth +7, iHeight, iExtStride, 1, piExtY ); |
---|
2067 | xCTI_FilterQuarter1Hor (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); |
---|
2068 | return; |
---|
2069 | } |
---|
2070 | } |
---|
2071 | if ( iyFrac == 3 ) |
---|
2072 | { |
---|
2073 | if ( ixFrac == 1) |
---|
2074 | { |
---|
2075 | xCTI_FilterQuarter1Ver (piRefY - 3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); |
---|
2076 | xCTI_FilterQuarter0Hor (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); |
---|
2077 | return; |
---|
2078 | } |
---|
2079 | if ( ixFrac == 3) |
---|
2080 | { |
---|
2081 | xCTI_FilterQuarter1Ver (piRefY - 3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); |
---|
2082 | xCTI_FilterQuarter1Hor (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); |
---|
2083 | return; |
---|
2084 | } |
---|
2085 | } |
---|
2086 | } |
---|
2087 | |
---|
2088 | #if HIGH_ACCURACY_BI |
---|
2089 | Void TComPrediction::xPredInterChromaBlk_ha( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, TComYuv*& rpcYuv ) |
---|
2090 | { |
---|
2091 | Int iRefStride = pcPicYuvRef->getCStride(); |
---|
2092 | Int iDstStride = rpcYuv->getCStride(); |
---|
2093 | |
---|
2094 | Int iRefOffset = (pcMv->getHor() >> 3) + (pcMv->getVer() >> 3) * iRefStride; |
---|
2095 | |
---|
2096 | Pel* piRefCb = pcPicYuvRef->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset; |
---|
2097 | Pel* piRefCr = pcPicYuvRef->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset; |
---|
2098 | |
---|
2099 | Pel* piDstCb = rpcYuv->getCbAddr( uiPartAddr ); |
---|
2100 | Pel* piDstCr = rpcYuv->getCrAddr( uiPartAddr ); |
---|
2101 | |
---|
2102 | Int ixFrac = pcMv->getHor() & 0x7; |
---|
2103 | Int iyFrac = pcMv->getVer() & 0x7; |
---|
2104 | UInt uiCWidth = iWidth >> 1; |
---|
2105 | UInt uiCHeight = iHeight >> 1; |
---|
2106 | |
---|
2107 | xDCTIF_FilterC_ha(piRefCb, iRefStride,piDstCb,iDstStride,uiCWidth,uiCHeight, iyFrac, ixFrac); |
---|
2108 | xDCTIF_FilterC_ha(piRefCr, iRefStride,piDstCr,iDstStride,uiCWidth,uiCHeight, iyFrac, ixFrac); |
---|
2109 | return; |
---|
2110 | } |
---|
2111 | #endif |
---|
2112 | |
---|
2113 | //-- |
---|
2114 | Void TComPrediction::xPredInterChromaBlk( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, TComYuv*& rpcYuv ) |
---|
2115 | { |
---|
2116 | Int iRefStride = pcPicYuvRef->getCStride(); |
---|
2117 | Int iDstStride = rpcYuv->getCStride(); |
---|
2118 | |
---|
2119 | Int iRefOffset = (pcMv->getHor() >> 3) + (pcMv->getVer() >> 3) * iRefStride; |
---|
2120 | |
---|
2121 | Pel* piRefCb = pcPicYuvRef->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset; |
---|
2122 | Pel* piRefCr = pcPicYuvRef->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset; |
---|
2123 | |
---|
2124 | Pel* piDstCb = rpcYuv->getCbAddr( uiPartAddr ); |
---|
2125 | Pel* piDstCr = rpcYuv->getCrAddr( uiPartAddr ); |
---|
2126 | |
---|
2127 | Int ixFrac = pcMv->getHor() & 0x7; |
---|
2128 | Int iyFrac = pcMv->getVer() & 0x7; |
---|
2129 | UInt uiCWidth = iWidth >> 1; |
---|
2130 | UInt uiCHeight = iHeight >> 1; |
---|
2131 | |
---|
2132 | xDCTIF_FilterC(piRefCb, iRefStride,piDstCb,iDstStride,uiCWidth,uiCHeight, iyFrac, ixFrac); |
---|
2133 | xDCTIF_FilterC(piRefCr, iRefStride,piDstCr,iDstStride,uiCWidth,uiCHeight, iyFrac, ixFrac); |
---|
2134 | return; |
---|
2135 | } |
---|
2136 | |
---|
2137 | Void TComPrediction::xDCTIF_FilterC ( Pel* piRefC, Int iRefStride,Pel* piDstC,Int iDstStride, |
---|
2138 | Int iWidth, Int iHeight,Int iMVyFrac,Int iMVxFrac) |
---|
2139 | { |
---|
2140 | // Integer point |
---|
2141 | if ( iMVxFrac == 0 && iMVyFrac == 0 ) |
---|
2142 | { |
---|
2143 | for ( Int y = 0; y < iHeight; y++ ) |
---|
2144 | { |
---|
2145 | ::memcpy(piDstC, piRefC, sizeof(Pel)*iWidth); |
---|
2146 | piDstC += iDstStride; |
---|
2147 | piRefC += iRefStride; |
---|
2148 | } |
---|
2149 | return; |
---|
2150 | } |
---|
2151 | |
---|
2152 | if ( iMVyFrac == 0 ) |
---|
2153 | { |
---|
2154 | xCTI_Filter1DHorC (piRefC, iRefStride, iWidth, iHeight, iDstStride, piDstC, iMVxFrac ); |
---|
2155 | return; |
---|
2156 | } |
---|
2157 | |
---|
2158 | if ( iMVxFrac == 0 ) |
---|
2159 | { |
---|
2160 | xCTI_Filter1DVerC (piRefC, iRefStride, iWidth, iHeight, iDstStride, piDstC, iMVyFrac ); |
---|
2161 | return; |
---|
2162 | } |
---|
2163 | |
---|
2164 | Int iExtStride = m_iYuvExtStride; |
---|
2165 | Int* piExtC = m_piYuvExt; |
---|
2166 | |
---|
2167 | xCTI_Filter2DVerC (piRefC - 1, iRefStride, iWidth + 3, iHeight, iExtStride, piExtC, iMVyFrac ); |
---|
2168 | xCTI_Filter2DHorC (piExtC + 1, iExtStride, iWidth , iHeight, iDstStride, piDstC, iMVxFrac ); |
---|
2169 | } |
---|
2170 | |
---|
2171 | #if HIGH_ACCURACY_BI |
---|
2172 | |
---|
2173 | Void TComPrediction::xDCTIF_FilterC_ha ( Pel* piRefC, Int iRefStride,Pel* piDstC,Int iDstStride, |
---|
2174 | Int iWidth, Int iHeight,Int iMVyFrac,Int iMVxFrac) |
---|
2175 | { |
---|
2176 | UInt shiftNumOrg = 6 - g_uiBitIncrement + 8 - g_uiBitDepth; |
---|
2177 | // Integer point |
---|
2178 | if ( iMVxFrac == 0 && iMVyFrac == 0 ) |
---|
2179 | { |
---|
2180 | for (Int y = 0; y < iHeight; y++ ) |
---|
2181 | { |
---|
2182 | for(Int x=0; x<iWidth; x++) |
---|
2183 | { |
---|
2184 | piDstC[x] = (piRefC[x]<<shiftNumOrg); |
---|
2185 | } |
---|
2186 | piDstC += iDstStride; |
---|
2187 | piRefC += iRefStride; |
---|
2188 | } |
---|
2189 | return; |
---|
2190 | } |
---|
2191 | |
---|
2192 | if ( iMVyFrac == 0 ) |
---|
2193 | { |
---|
2194 | xCTI_Filter1DHorC_ha (piRefC, iRefStride, iWidth, iHeight, iDstStride, piDstC, iMVxFrac ); |
---|
2195 | return; |
---|
2196 | |
---|
2197 | } |
---|
2198 | |
---|
2199 | if ( iMVxFrac == 0 ) |
---|
2200 | { |
---|
2201 | xCTI_Filter1DVerC_ha (piRefC, iRefStride, iWidth, iHeight, iDstStride, piDstC, iMVyFrac ); |
---|
2202 | return; |
---|
2203 | } |
---|
2204 | |
---|
2205 | Int iExtStride = m_iYuvExtStride; |
---|
2206 | Int* piExtC = m_piYuvExt; |
---|
2207 | |
---|
2208 | xCTI_Filter2DVerC (piRefC - 1, iRefStride, iWidth + 3, iHeight, iExtStride, piExtC, iMVyFrac ); |
---|
2209 | xCTI_Filter2DHorC_ha (piExtC + 1, iExtStride, iWidth , iHeight, iDstStride, piDstC, iMVxFrac ); |
---|
2210 | return; |
---|
2211 | |
---|
2212 | } |
---|
2213 | |
---|
2214 | #endif |
---|
2215 | |
---|
2216 | #if DEPTH_MAP_GENERATION |
---|
2217 | 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 ) |
---|
2218 | { |
---|
2219 | if( iRefIdx0 >= 0 && iRefIdx1 >= 0 ) |
---|
2220 | { |
---|
2221 | rpcYuvDst->addAvgPdm( pcYuvSrc0, pcYuvSrc1, uiPartIdx, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY ); |
---|
2222 | } |
---|
2223 | else if ( iRefIdx0 >= 0 && iRefIdx1 < 0 ) |
---|
2224 | { |
---|
2225 | pcYuvSrc0->copyPartToPartYuvPdm( rpcYuvDst, uiPartIdx, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY ); |
---|
2226 | } |
---|
2227 | else if ( iRefIdx0 < 0 && iRefIdx1 >= 0 ) |
---|
2228 | { |
---|
2229 | pcYuvSrc1->copyPartToPartYuvPdm( rpcYuvDst, uiPartIdx, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY ); |
---|
2230 | } |
---|
2231 | else |
---|
2232 | { |
---|
2233 | assert (0); |
---|
2234 | } |
---|
2235 | } |
---|
2236 | #endif |
---|
2237 | |
---|
2238 | |
---|
2239 | Void TComPrediction::xWeightedAverage( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv*& rpcYuvDst ) |
---|
2240 | { |
---|
2241 | if( iRefIdx0 >= 0 && iRefIdx1 >= 0 ) |
---|
2242 | { |
---|
2243 | #ifdef ROUNDING_CONTROL_BIPRED |
---|
2244 | rpcYuvDst->addAvg( pcYuvSrc0, pcYuvSrc1, uiPartIdx, iWidth, iHeight, pcCU->getSlice()->isRounding()); |
---|
2245 | #else |
---|
2246 | rpcYuvDst->addAvg( pcYuvSrc0, pcYuvSrc1, uiPartIdx, iWidth, iHeight ); |
---|
2247 | #endif |
---|
2248 | } |
---|
2249 | else if ( iRefIdx0 >= 0 && iRefIdx1 < 0 ) |
---|
2250 | { |
---|
2251 | pcYuvSrc0->copyPartToPartYuv( rpcYuvDst, uiPartIdx, iWidth, iHeight ); |
---|
2252 | } |
---|
2253 | else if ( iRefIdx0 < 0 && iRefIdx1 >= 0 ) |
---|
2254 | { |
---|
2255 | pcYuvSrc1->copyPartToPartYuv( rpcYuvDst, uiPartIdx, iWidth, iHeight ); |
---|
2256 | } |
---|
2257 | else |
---|
2258 | { |
---|
2259 | assert (0); |
---|
2260 | } |
---|
2261 | } |
---|
2262 | |
---|
2263 | // AMVP |
---|
2264 | Void TComPrediction::getMvPredAMVP( TComDataCU* pcCU, UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMvPred ) |
---|
2265 | { |
---|
2266 | AMVPInfo* pcAMVPInfo = pcCU->getCUMvField(eRefPicList)->getAMVPInfo(); |
---|
2267 | |
---|
2268 | if( pcCU->getAMVPMode(uiPartAddr) == AM_NONE || (pcAMVPInfo->iN <= 1 && pcCU->getAMVPMode(uiPartAddr) == AM_EXPL) ) |
---|
2269 | { |
---|
2270 | rcMvPred = pcAMVPInfo->m_acMvCand[0]; |
---|
2271 | |
---|
2272 | pcCU->setMVPIdxSubParts( 0, eRefPicList, uiPartAddr, uiPartIdx, pcCU->getDepth(uiPartAddr)); |
---|
2273 | pcCU->setMVPNumSubParts( pcAMVPInfo->iN, eRefPicList, uiPartAddr, uiPartIdx, pcCU->getDepth(uiPartAddr)); |
---|
2274 | return; |
---|
2275 | } |
---|
2276 | |
---|
2277 | assert(pcCU->getMVPIdx(eRefPicList,uiPartAddr) >= 0); |
---|
2278 | rcMvPred = pcAMVPInfo->m_acMvCand[pcCU->getMVPIdx(eRefPicList,uiPartAddr)]; |
---|
2279 | return; |
---|
2280 | } |
---|
2281 | |
---|
2282 | #if ADD_PLANAR_MODE |
---|
2283 | /** Function for deriving planar intra prediction. |
---|
2284 | * \param pSrc pointer to reconstructed sample array |
---|
2285 | * \param srcStride the stride of the reconstructed sample array |
---|
2286 | * \param rpDst reference to pointer for the prediction sample array |
---|
2287 | * \param dstStride the stride of the prediction sample array |
---|
2288 | * \param width the width of the block |
---|
2289 | * \param height the height of the block |
---|
2290 | * \param blkAboveAvailable boolean indication if the block above is available |
---|
2291 | * \param blkLeftAvailable boolean indication if the block to the left is available |
---|
2292 | * |
---|
2293 | * This function derives the prediction samples for planar mode (intra coding). |
---|
2294 | */ |
---|
2295 | #if REFERENCE_SAMPLE_PADDING |
---|
2296 | Void TComPrediction::xPredIntraPlanar( Int* pSrc, Int srcStride, Pel*& rpDst, Int dstStride, UInt width, UInt height ) |
---|
2297 | #else |
---|
2298 | Void TComPrediction::xPredIntraPlanar( Int* pSrc, Int srcStride, Pel*& rpDst, Int dstStride, UInt width, UInt height, Bool blkAboveAvailable, Bool blkLeftAvailable ) |
---|
2299 | #endif |
---|
2300 | { |
---|
2301 | assert(width == height); |
---|
2302 | |
---|
2303 | Int k, l, bottomLeft, topRight; |
---|
2304 | Int horPred; |
---|
2305 | Int leftColumn[MAX_CU_SIZE], topRow[MAX_CU_SIZE], bottomRow[MAX_CU_SIZE], rightColumn[MAX_CU_SIZE]; |
---|
2306 | UInt blkSize = width; |
---|
2307 | UInt offset2D = width; |
---|
2308 | UInt shift1D = g_aucConvertToBit[ width ] + 2; |
---|
2309 | UInt shift2D = shift1D + 1; |
---|
2310 | |
---|
2311 | // Get left and above reference column and row |
---|
2312 | #if REFERENCE_SAMPLE_PADDING |
---|
2313 | for(k=0;k<blkSize;k++) |
---|
2314 | { |
---|
2315 | topRow[k] = pSrc[k-srcStride]; |
---|
2316 | leftColumn[k] = pSrc[k*srcStride-1]; |
---|
2317 | } |
---|
2318 | #else |
---|
2319 | if (!blkAboveAvailable && !blkLeftAvailable) |
---|
2320 | { |
---|
2321 | for(k=0;k<blkSize;k++) |
---|
2322 | { |
---|
2323 | leftColumn[k] = topRow[k] = ( 1 << ( g_uiBitDepth + g_uiBitIncrement - 1 ) ); |
---|
2324 | } |
---|
2325 | } |
---|
2326 | else |
---|
2327 | { |
---|
2328 | if(blkAboveAvailable) |
---|
2329 | { |
---|
2330 | for(k=0;k<blkSize;k++) |
---|
2331 | { |
---|
2332 | topRow[k] = pSrc[k-srcStride]; |
---|
2333 | } |
---|
2334 | } |
---|
2335 | else |
---|
2336 | { |
---|
2337 | Int leftSample = pSrc[-1]; |
---|
2338 | for(k=0;k<blkSize;k++) |
---|
2339 | { |
---|
2340 | topRow[k] = leftSample; |
---|
2341 | } |
---|
2342 | } |
---|
2343 | if(blkLeftAvailable) |
---|
2344 | { |
---|
2345 | for(k=0;k<blkSize;k++) |
---|
2346 | { |
---|
2347 | leftColumn[k] = pSrc[k*srcStride-1]; |
---|
2348 | } |
---|
2349 | } |
---|
2350 | else |
---|
2351 | { |
---|
2352 | Int aboveSample = pSrc[-srcStride]; |
---|
2353 | for(k=0;k<blkSize;k++) |
---|
2354 | { |
---|
2355 | leftColumn[k] = aboveSample; |
---|
2356 | } |
---|
2357 | } |
---|
2358 | } |
---|
2359 | #endif |
---|
2360 | |
---|
2361 | // Prepare intermediate variables used in interpolation |
---|
2362 | bottomLeft = leftColumn[blkSize-1]; |
---|
2363 | topRight = topRow[blkSize-1]; |
---|
2364 | for (k=0;k<blkSize;k++) |
---|
2365 | { |
---|
2366 | bottomRow[k] = bottomLeft - topRow[k]; |
---|
2367 | rightColumn[k] = topRight - leftColumn[k]; |
---|
2368 | topRow[k] <<= shift1D; |
---|
2369 | leftColumn[k] <<= shift1D; |
---|
2370 | } |
---|
2371 | |
---|
2372 | // Generate prediction signal |
---|
2373 | for (k=0;k<blkSize;k++) |
---|
2374 | { |
---|
2375 | horPred = leftColumn[k] + offset2D; |
---|
2376 | for (l=0;l<blkSize;l++) |
---|
2377 | { |
---|
2378 | horPred += rightColumn[k]; |
---|
2379 | topRow[l] += bottomRow[l]; |
---|
2380 | rpDst[k*dstStride+l] = ( (horPred + topRow[l]) >> shift2D ); |
---|
2381 | } |
---|
2382 | } |
---|
2383 | } |
---|
2384 | #endif |
---|
2385 | |
---|
2386 | #if LM_CHROMA |
---|
2387 | /** Function for deriving chroma LM intra prediction. |
---|
2388 | * \param pcPattern pointer to neighbouring pixel access pattern |
---|
2389 | * \param pSrc pointer to reconstructed chroma sample array |
---|
2390 | * \param pPred pointer for the prediction sample array |
---|
2391 | * \param uiPredStride the stride of the prediction sample array |
---|
2392 | * \param uiCWidth the width of the chroma block |
---|
2393 | * \param uiCHeight the height of the chroma block |
---|
2394 | * \param uiChromaId boolean indication of chroma component |
---|
2395 | |
---|
2396 | \ This function derives the prediction samples for chroma LM mode (chroma intra coding) |
---|
2397 | */ |
---|
2398 | Void TComPrediction::predLMIntraChroma( TComPattern* pcPattern, Int* piSrc, Pel* pPred, UInt uiPredStride, UInt uiCWidth, UInt uiCHeight, UInt uiChromaId ) |
---|
2399 | { |
---|
2400 | UInt uiWidth = uiCWidth << 1; |
---|
2401 | UInt uiHeight = uiCHeight << 1; |
---|
2402 | |
---|
2403 | if (uiChromaId == 0) |
---|
2404 | xGetRecPixels( pcPattern, pcPattern->getROIY(), pcPattern->getPatternLStride(), m_pLumaRecBuffer + m_iLumaRecStride + 1, m_iLumaRecStride, uiWidth, uiHeight ); |
---|
2405 | |
---|
2406 | xGetLLSPrediction( pcPattern, piSrc+uiWidth+2, uiWidth+1, pPred, uiPredStride, uiCWidth, uiCHeight, 1 ); |
---|
2407 | } |
---|
2408 | |
---|
2409 | /** Function for deriving downsampled luma sample of current chroma block and its above, left causal pixel |
---|
2410 | * \param pcPattern pointer to neighbouring pixel access pattern |
---|
2411 | * \param pRecSrc pointer to reconstructed luma sample array |
---|
2412 | * \param iRecSrcStride the stride of reconstructed luma sample array |
---|
2413 | * \param pDst0 pointer to downsampled luma sample array |
---|
2414 | * \param iDstStride the stride of downsampled luma sample array |
---|
2415 | * \param uiWidth0 the width of the luma block |
---|
2416 | * \param uiHeight0 the height of the luma block |
---|
2417 | |
---|
2418 | \ This function derives downsampled luma sample of current chroma block and its above, left causal pixel |
---|
2419 | */ |
---|
2420 | |
---|
2421 | Void TComPrediction::xGetRecPixels( TComPattern* pcPattern, Pel* pRecSrc, Int iRecSrcStride, Pel* pDst0, Int iDstStride, UInt uiWidth0, UInt uiHeight0 ) |
---|
2422 | { |
---|
2423 | Pel* pSrc = pRecSrc; |
---|
2424 | Pel* pDst = pDst0; |
---|
2425 | |
---|
2426 | Int uiCWidth = uiWidth0/2; |
---|
2427 | Int uiCHeight = uiHeight0/2; |
---|
2428 | |
---|
2429 | if( pcPattern->isLeftAvailable() ) |
---|
2430 | { |
---|
2431 | pSrc = pSrc - 2; |
---|
2432 | pDst = pDst - 1; |
---|
2433 | |
---|
2434 | uiCWidth += 1; |
---|
2435 | } |
---|
2436 | |
---|
2437 | if( pcPattern->isAboveAvailable() ) |
---|
2438 | { |
---|
2439 | pSrc = pSrc - 2*iRecSrcStride; |
---|
2440 | pDst = pDst - iDstStride; |
---|
2441 | |
---|
2442 | uiCHeight += 1; |
---|
2443 | } |
---|
2444 | |
---|
2445 | for( Int j = 0; j < uiCHeight; j++ ) |
---|
2446 | { |
---|
2447 | for( Int i = 0, ii = i << 1; i < uiCWidth; i++, ii = i << 1 ) |
---|
2448 | pDst[i] = (pSrc[ii] + pSrc[ii + iRecSrcStride]) >> 1; |
---|
2449 | |
---|
2450 | pDst += iDstStride; |
---|
2451 | pSrc += iRecSrcStride*2; |
---|
2452 | } |
---|
2453 | } |
---|
2454 | |
---|
2455 | /** Function for deriving the positon of first non-zero binary bit of a value |
---|
2456 | * \param x input value |
---|
2457 | \ This function derives the positon of first non-zero binary bit of a value |
---|
2458 | */ |
---|
2459 | Int GetMSB( UInt x ) |
---|
2460 | { |
---|
2461 | #if 1 |
---|
2462 | Int iMSB = 0, bits = ( sizeof( Int ) << 3 ), y = 1; |
---|
2463 | |
---|
2464 | while( x > 1 ) |
---|
2465 | { |
---|
2466 | bits >>= 1; |
---|
2467 | y = x >> bits; |
---|
2468 | |
---|
2469 | if( y ) |
---|
2470 | { |
---|
2471 | x = y; |
---|
2472 | iMSB += bits; |
---|
2473 | } |
---|
2474 | } |
---|
2475 | |
---|
2476 | iMSB+=y; |
---|
2477 | |
---|
2478 | #else |
---|
2479 | |
---|
2480 | Int iMSB = 0; |
---|
2481 | while( x > 0 ) |
---|
2482 | { |
---|
2483 | x >>= 1; |
---|
2484 | iMSB++; |
---|
2485 | } |
---|
2486 | #endif |
---|
2487 | |
---|
2488 | return iMSB; |
---|
2489 | } |
---|
2490 | |
---|
2491 | /** Function for deriving LM intra prediction. |
---|
2492 | * \param pcPattern pointer to neighbouring pixel access pattern |
---|
2493 | * \param pSrc0 pointer to reconstructed chroma sample array |
---|
2494 | * \param iSrcStride the stride of reconstructed chroma sample array |
---|
2495 | * \param pDst0 reference to pointer for the prediction sample array |
---|
2496 | * \param iDstStride the stride of the prediction sample array |
---|
2497 | * \param uiWidth the width of the chroma block |
---|
2498 | * \param uiHeight the height of the chroma block |
---|
2499 | * \param uiExt0 line number of neiggboirng pixels for calculating LM model parameter, default value is 1 |
---|
2500 | |
---|
2501 | \ This function derives the prediction samples for chroma LM mode (chroma intra coding) |
---|
2502 | */ |
---|
2503 | Void TComPrediction::xGetLLSPrediction( TComPattern* pcPattern, Int* pSrc0, Int iSrcStride, Pel* pDst0, Int iDstStride, UInt uiWidth, UInt uiHeight, UInt uiExt0 ) |
---|
2504 | { |
---|
2505 | |
---|
2506 | Pel *pDst, *pLuma; |
---|
2507 | Int *pSrc; |
---|
2508 | |
---|
2509 | Int iLumaStride = m_iLumaRecStride; |
---|
2510 | Pel* pLuma0 = m_pLumaRecBuffer + uiExt0 * iLumaStride + uiExt0; |
---|
2511 | |
---|
2512 | Int i, j, iCountShift = 0; |
---|
2513 | |
---|
2514 | UInt uiExt = uiExt0; |
---|
2515 | |
---|
2516 | // LLS parameters estimation --> |
---|
2517 | |
---|
2518 | Int x = 0, y = 0, xx = 0, xy = 0; |
---|
2519 | |
---|
2520 | if( pcPattern->isAboveAvailable() ) |
---|
2521 | { |
---|
2522 | pSrc = pSrc0 - iSrcStride; |
---|
2523 | pLuma = pLuma0 - iLumaStride; |
---|
2524 | |
---|
2525 | for( j = 0; j < uiWidth; j++ ) |
---|
2526 | { |
---|
2527 | x += pLuma[j]; |
---|
2528 | y += pSrc[j]; |
---|
2529 | xx += pLuma[j] * pLuma[j]; |
---|
2530 | xy += pLuma[j] * pSrc[j]; |
---|
2531 | } |
---|
2532 | iCountShift += g_aucConvertToBit[ uiWidth ] + 2; |
---|
2533 | } |
---|
2534 | |
---|
2535 | if( pcPattern->isLeftAvailable() ) |
---|
2536 | { |
---|
2537 | pSrc = pSrc0 - uiExt; |
---|
2538 | pLuma = pLuma0 - uiExt; |
---|
2539 | |
---|
2540 | for( i = 0; i < uiHeight; i++ ) |
---|
2541 | { |
---|
2542 | x += pLuma[0]; |
---|
2543 | y += pSrc[0]; |
---|
2544 | xx += pLuma[0] * pLuma[0]; |
---|
2545 | xy += pLuma[0] * pSrc[0]; |
---|
2546 | |
---|
2547 | pSrc += iSrcStride; |
---|
2548 | pLuma += iLumaStride; |
---|
2549 | } |
---|
2550 | iCountShift += iCountShift > 0 ? 1 : ( g_aucConvertToBit[ uiWidth ] + 2 ); |
---|
2551 | } |
---|
2552 | |
---|
2553 | Int iBitdepth = ( ( g_uiBitDepth + g_uiBitIncrement ) + g_aucConvertToBit[ uiWidth ] + 3 ) * 2; |
---|
2554 | Int iTempShift = Max( ( iBitdepth - 31 + 1) / 2, 0); |
---|
2555 | |
---|
2556 | if(iTempShift > 0) |
---|
2557 | { |
---|
2558 | x = ( x + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
2559 | y = ( y + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
2560 | xx = ( xx + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
2561 | xy = ( xy + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
2562 | iCountShift -= iTempShift; |
---|
2563 | } |
---|
2564 | |
---|
2565 | Int a, b, iShift = 13; |
---|
2566 | |
---|
2567 | if( iCountShift == 0 ) |
---|
2568 | { |
---|
2569 | a = 0; |
---|
2570 | b = 128 << g_uiBitIncrement; |
---|
2571 | iShift = 0; |
---|
2572 | } |
---|
2573 | else |
---|
2574 | { |
---|
2575 | Int a1 = ( xy << iCountShift ) - y * x; |
---|
2576 | Int a2 = ( xx << iCountShift ) - x * x; |
---|
2577 | |
---|
2578 | if( a2 == 0 || a1 == 0 ) |
---|
2579 | { |
---|
2580 | a = 0; |
---|
2581 | b = ( y + ( 1 << ( iCountShift - 1 ) ) )>> iCountShift; |
---|
2582 | iShift = 0; |
---|
2583 | } |
---|
2584 | else |
---|
2585 | { |
---|
2586 | const Int iShiftA2 = 6; |
---|
2587 | const Int iShiftA1 = 15; |
---|
2588 | const Int iAccuracyShift = 15; |
---|
2589 | |
---|
2590 | Int iScaleShiftA2 = 0; |
---|
2591 | Int iScaleShiftA1 = 0; |
---|
2592 | Int a1s = a1; |
---|
2593 | Int a2s = a2; |
---|
2594 | |
---|
2595 | iScaleShiftA1 = GetMSB( abs( a1 ) ) - iShiftA1; |
---|
2596 | iScaleShiftA2 = GetMSB( abs( a2 ) ) - iShiftA2; |
---|
2597 | |
---|
2598 | if( iScaleShiftA1 < 0 ) |
---|
2599 | iScaleShiftA1 = 0; |
---|
2600 | |
---|
2601 | if( iScaleShiftA2 < 0 ) |
---|
2602 | iScaleShiftA2 = 0; |
---|
2603 | |
---|
2604 | Int iScaleShiftA = iScaleShiftA2 + iAccuracyShift - iShift - iScaleShiftA1; |
---|
2605 | |
---|
2606 | a2s = a2 >> iScaleShiftA2; |
---|
2607 | |
---|
2608 | a1s = a1 >> iScaleShiftA1; |
---|
2609 | |
---|
2610 | a = a1s * m_uiaShift[ abs( a2s ) ]; |
---|
2611 | |
---|
2612 | if( iScaleShiftA < 0 ) |
---|
2613 | a = a << -iScaleShiftA; |
---|
2614 | else |
---|
2615 | a = a >> iScaleShiftA; |
---|
2616 | |
---|
2617 | if( a > ( 1 << 15 ) - 1 ) |
---|
2618 | a = ( 1 << 15 ) - 1; |
---|
2619 | else if( a < -( 1 << 15 ) ) |
---|
2620 | a = -( 1 << 15 ); |
---|
2621 | |
---|
2622 | b = ( y - ( ( a * x ) >> iShift ) + ( 1 << ( iCountShift - 1 ) ) ) >> iCountShift; |
---|
2623 | } |
---|
2624 | } |
---|
2625 | |
---|
2626 | // <-- end of LLS parameters estimation |
---|
2627 | |
---|
2628 | // get prediction --> |
---|
2629 | uiExt = uiExt0; |
---|
2630 | pLuma = pLuma0; |
---|
2631 | pDst = pDst0; |
---|
2632 | |
---|
2633 | for( i = 0; i < uiHeight; i++ ) |
---|
2634 | { |
---|
2635 | for( j = 0; j < uiWidth; j++ ) |
---|
2636 | pDst[j] = Clip( ( ( a * pLuma[j] ) >> iShift ) + b ); |
---|
2637 | |
---|
2638 | pDst += iDstStride; |
---|
2639 | pLuma += iLumaStride; |
---|
2640 | } |
---|
2641 | // <-- end of get prediction |
---|
2642 | |
---|
2643 | } |
---|
2644 | #endif |
---|
2645 | |
---|
2646 | #if MN_DC_PRED_FILTER |
---|
2647 | /** Function for filtering intra DC predictor. |
---|
2648 | * \param pSrc pointer to reconstructed sample array |
---|
2649 | * \param iSrcStride the stride of the reconstructed sample array |
---|
2650 | * \param rpDst reference to pointer for the prediction sample array |
---|
2651 | * \param iDstStride the stride of the prediction sample array |
---|
2652 | * \param iWidth the width of the block |
---|
2653 | * \param iHeight the height of the block |
---|
2654 | * |
---|
2655 | * This function performs filtering left and top edges of the prediction samples for DC mode (intra coding). |
---|
2656 | */ |
---|
2657 | Void TComPrediction::xDCPredFiltering( Int* pSrc, Int iSrcStride, Pel*& rpDst, Int iDstStride, Int iWidth, Int iHeight ) |
---|
2658 | { |
---|
2659 | Pel* pDst = rpDst; |
---|
2660 | Int x, y, iDstStride2, iSrcStride2; |
---|
2661 | Int iIntraSizeIdx = g_aucConvertToBit[ iWidth ] + 1; |
---|
2662 | static const UChar g_aucDCPredFilter[7] = { 0, 3, 2, 1, 0, 0, 0}; |
---|
2663 | |
---|
2664 | switch (g_aucDCPredFilter[iIntraSizeIdx]) |
---|
2665 | { |
---|
2666 | case 0: |
---|
2667 | {} |
---|
2668 | break; |
---|
2669 | case 1: |
---|
2670 | { |
---|
2671 | // boundary pixels processing |
---|
2672 | pDst[0] = (Pel)((pSrc[-iSrcStride] + pSrc[-1] + 6 * pDst[0] + 4) >> 3); |
---|
2673 | |
---|
2674 | for ( x = 1; x < iWidth; x++ ) |
---|
2675 | pDst[x] = (Pel)((pSrc[x - iSrcStride] + 7 * pDst[x] + 4) >> 3); |
---|
2676 | |
---|
2677 | for ( y = 1, iDstStride2 = iDstStride, iSrcStride2 = iSrcStride-1; y < iHeight; y++, iDstStride2+=iDstStride, iSrcStride2+=iSrcStride ) |
---|
2678 | pDst[iDstStride2] = (Pel)((pSrc[iSrcStride2] + 7 * pDst[iDstStride2] + 4) >> 3); |
---|
2679 | } |
---|
2680 | break; |
---|
2681 | case 2: |
---|
2682 | { |
---|
2683 | // boundary pixels processing |
---|
2684 | pDst[0] = (Pel)((pSrc[-iSrcStride] + pSrc[-1] + 2 * pDst[0] + 2) >> 2); |
---|
2685 | |
---|
2686 | for ( x = 1; x < iWidth; x++ ) |
---|
2687 | pDst[x] = (Pel)((pSrc[x - iSrcStride] + 3 * pDst[x] + 2) >> 2); |
---|
2688 | |
---|
2689 | for ( y = 1, iDstStride2 = iDstStride, iSrcStride2 = iSrcStride-1; y < iHeight; y++, iDstStride2+=iDstStride, iSrcStride2+=iSrcStride ) |
---|
2690 | pDst[iDstStride2] = (Pel)((pSrc[iSrcStride2] + 3 * pDst[iDstStride2] + 2) >> 2); |
---|
2691 | } |
---|
2692 | break; |
---|
2693 | case 3: |
---|
2694 | { |
---|
2695 | // boundary pixels processing |
---|
2696 | pDst[0] = (Pel)((3 * (pSrc[-iSrcStride] + pSrc[-1]) + 2 * pDst[0] + 4) >> 3); |
---|
2697 | |
---|
2698 | for ( x = 1; x < iWidth; x++ ) |
---|
2699 | pDst[x] = (Pel)((3 * pSrc[x - iSrcStride] + 5 * pDst[x] + 4) >> 3); |
---|
2700 | |
---|
2701 | for ( y = 1, iDstStride2 = iDstStride, iSrcStride2 = iSrcStride-1; y < iHeight; y++, iDstStride2+=iDstStride, iSrcStride2+=iSrcStride ) |
---|
2702 | pDst[iDstStride2] = (Pel)((3 * pSrc[iSrcStride2] + 5 * pDst[iDstStride2] + 4) >> 3); |
---|
2703 | } |
---|
2704 | break; |
---|
2705 | } |
---|
2706 | |
---|
2707 | return; |
---|
2708 | } |
---|
2709 | #endif |
---|
2710 | |
---|
2711 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
2712 | TComWedgeDist::TComWedgeDist() |
---|
2713 | { |
---|
2714 | init(); |
---|
2715 | } |
---|
2716 | |
---|
2717 | TComWedgeDist::~TComWedgeDist() |
---|
2718 | { |
---|
2719 | } |
---|
2720 | |
---|
2721 | Void TComWedgeDist::init() |
---|
2722 | { |
---|
2723 | // m_afpDistortFunc[0] = NULL; // for DF_DEFAULT |
---|
2724 | |
---|
2725 | // m_afpDistortFunc[8] = TComRdCost::xGetSAD; |
---|
2726 | m_afpDistortFunc[0] = TComWedgeDist::xGetSAD4; |
---|
2727 | m_afpDistortFunc[1] = TComWedgeDist::xGetSAD8; |
---|
2728 | m_afpDistortFunc[2] = TComWedgeDist::xGetSAD16; |
---|
2729 | m_afpDistortFunc[3] = TComWedgeDist::xGetSAD32; |
---|
2730 | |
---|
2731 | m_afpDistortFunc[4] = TComWedgeDist::xGetSSE4; |
---|
2732 | m_afpDistortFunc[5] = TComWedgeDist::xGetSSE8; |
---|
2733 | m_afpDistortFunc[6] = TComWedgeDist::xGetSSE16; |
---|
2734 | m_afpDistortFunc[7] = TComWedgeDist::xGetSSE32; |
---|
2735 | |
---|
2736 | // m_afpDistortFunc[13] = TComRdCost::xGetSAD64; |
---|
2737 | #ifdef ROUNDING_CONTROL_BIPRED |
---|
2738 | // m_afpDistortFuncRnd[0] = NULL; |
---|
2739 | // m_afpDistortFuncRnd[8] = TComRdCost::xGetSAD; |
---|
2740 | m_afpDistortFuncRnd[9] = TComRdCost::xGetSAD4; |
---|
2741 | m_afpDistortFuncRnd[10] = TComRdCost::xGetSAD8; |
---|
2742 | m_afpDistortFuncRnd[11] = TComRdCost::xGetSAD16; |
---|
2743 | m_afpDistortFuncRnd[12] = TComRdCost::xGetSAD32; |
---|
2744 | // m_afpDistortFuncRnd[13] = TComRdCost::xGetSAD64; |
---|
2745 | #endif |
---|
2746 | } |
---|
2747 | |
---|
2748 | UInt TComWedgeDist::xGetSAD4( DistParam* pcDtParam ) |
---|
2749 | { |
---|
2750 | Pel* piOrg = pcDtParam->pOrg; |
---|
2751 | Pel* piCur = pcDtParam->pCur; |
---|
2752 | Int iRows = pcDtParam->iRows; |
---|
2753 | Int iSubShift = pcDtParam->iSubShift; |
---|
2754 | Int iSubStep = ( 1 << iSubShift ); |
---|
2755 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
2756 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
2757 | |
---|
2758 | UInt uiSum = 0; |
---|
2759 | |
---|
2760 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
2761 | { |
---|
2762 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
2763 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
2764 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
2765 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
2766 | |
---|
2767 | piOrg += iStrideOrg; |
---|
2768 | piCur += iStrideCur; |
---|
2769 | } |
---|
2770 | |
---|
2771 | uiSum <<= iSubShift; |
---|
2772 | return ( uiSum >> g_uiBitIncrement ); |
---|
2773 | } |
---|
2774 | |
---|
2775 | UInt TComWedgeDist::xGetSAD8( DistParam* pcDtParam ) |
---|
2776 | { |
---|
2777 | Pel* piOrg = pcDtParam->pOrg; |
---|
2778 | Pel* piCur = pcDtParam->pCur; |
---|
2779 | Int iRows = pcDtParam->iRows; |
---|
2780 | Int iSubShift = pcDtParam->iSubShift; |
---|
2781 | Int iSubStep = ( 1 << iSubShift ); |
---|
2782 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
2783 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
2784 | |
---|
2785 | UInt uiSum = 0; |
---|
2786 | |
---|
2787 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
2788 | { |
---|
2789 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
2790 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
2791 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
2792 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
2793 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
2794 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
2795 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
2796 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
2797 | |
---|
2798 | piOrg += iStrideOrg; |
---|
2799 | piCur += iStrideCur; |
---|
2800 | } |
---|
2801 | |
---|
2802 | uiSum <<= iSubShift; |
---|
2803 | return ( uiSum >> g_uiBitIncrement ); |
---|
2804 | } |
---|
2805 | |
---|
2806 | UInt TComWedgeDist::xGetSAD16( DistParam* pcDtParam ) |
---|
2807 | { |
---|
2808 | Pel* piOrg = pcDtParam->pOrg; |
---|
2809 | Pel* piCur = pcDtParam->pCur; |
---|
2810 | Int iRows = pcDtParam->iRows; |
---|
2811 | Int iSubShift = pcDtParam->iSubShift; |
---|
2812 | Int iSubStep = ( 1 << iSubShift ); |
---|
2813 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
2814 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
2815 | |
---|
2816 | UInt uiSum = 0; |
---|
2817 | |
---|
2818 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
2819 | { |
---|
2820 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
2821 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
2822 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
2823 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
2824 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
2825 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
2826 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
2827 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
2828 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
2829 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
2830 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
2831 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
2832 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
2833 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
2834 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
2835 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
2836 | |
---|
2837 | piOrg += iStrideOrg; |
---|
2838 | piCur += iStrideCur; |
---|
2839 | } |
---|
2840 | |
---|
2841 | uiSum <<= iSubShift; |
---|
2842 | return ( uiSum >> g_uiBitIncrement ); |
---|
2843 | } |
---|
2844 | |
---|
2845 | UInt TComWedgeDist::xGetSAD32( DistParam* pcDtParam ) |
---|
2846 | { |
---|
2847 | Pel* piOrg = pcDtParam->pOrg; |
---|
2848 | Pel* piCur = pcDtParam->pCur; |
---|
2849 | Int iRows = pcDtParam->iRows; |
---|
2850 | Int iSubShift = pcDtParam->iSubShift; |
---|
2851 | Int iSubStep = ( 1 << iSubShift ); |
---|
2852 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
2853 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
2854 | |
---|
2855 | UInt uiSum = 0; |
---|
2856 | |
---|
2857 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
2858 | { |
---|
2859 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
2860 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
2861 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
2862 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
2863 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
2864 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
2865 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
2866 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
2867 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
2868 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
2869 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
2870 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
2871 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
2872 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
2873 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
2874 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
2875 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
2876 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
2877 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
2878 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
2879 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
2880 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
2881 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
2882 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
2883 | uiSum += abs( piOrg[24] - piCur[24] ); |
---|
2884 | uiSum += abs( piOrg[25] - piCur[25] ); |
---|
2885 | uiSum += abs( piOrg[26] - piCur[26] ); |
---|
2886 | uiSum += abs( piOrg[27] - piCur[27] ); |
---|
2887 | uiSum += abs( piOrg[28] - piCur[28] ); |
---|
2888 | uiSum += abs( piOrg[29] - piCur[29] ); |
---|
2889 | uiSum += abs( piOrg[30] - piCur[30] ); |
---|
2890 | uiSum += abs( piOrg[31] - piCur[31] ); |
---|
2891 | |
---|
2892 | piOrg += iStrideOrg; |
---|
2893 | piCur += iStrideCur; |
---|
2894 | } |
---|
2895 | |
---|
2896 | uiSum <<= iSubShift; |
---|
2897 | return ( uiSum >> g_uiBitIncrement ); |
---|
2898 | } |
---|
2899 | |
---|
2900 | UInt TComWedgeDist::xGetSSE4( DistParam* pcDtParam ) |
---|
2901 | { |
---|
2902 | Pel* piOrg = pcDtParam->pOrg; |
---|
2903 | Pel* piCur = pcDtParam->pCur; |
---|
2904 | Int iRows = pcDtParam->iRows; |
---|
2905 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
2906 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
2907 | |
---|
2908 | UInt uiSum = 0; |
---|
2909 | UInt uiShift = g_uiBitIncrement<<1; |
---|
2910 | |
---|
2911 | Int iTemp; |
---|
2912 | |
---|
2913 | for( ; iRows != 0; iRows-- ) |
---|
2914 | { |
---|
2915 | |
---|
2916 | iTemp = piOrg[0] - piCur[0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2917 | iTemp = piOrg[1] - piCur[1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2918 | iTemp = piOrg[2] - piCur[2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2919 | iTemp = piOrg[3] - piCur[3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2920 | |
---|
2921 | piOrg += iStrideOrg; |
---|
2922 | piCur += iStrideCur; |
---|
2923 | } |
---|
2924 | |
---|
2925 | return ( uiSum ); |
---|
2926 | } |
---|
2927 | |
---|
2928 | UInt TComWedgeDist::xGetSSE8( DistParam* pcDtParam ) |
---|
2929 | { |
---|
2930 | Pel* piOrg = pcDtParam->pOrg; |
---|
2931 | Pel* piCur = pcDtParam->pCur; |
---|
2932 | Int iRows = pcDtParam->iRows; |
---|
2933 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
2934 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
2935 | |
---|
2936 | UInt uiSum = 0; |
---|
2937 | UInt uiShift = g_uiBitIncrement<<1; |
---|
2938 | |
---|
2939 | Int iTemp; |
---|
2940 | |
---|
2941 | for( ; iRows != 0; iRows-- ) |
---|
2942 | { |
---|
2943 | iTemp = piOrg[0] - piCur[0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2944 | iTemp = piOrg[1] - piCur[1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2945 | iTemp = piOrg[2] - piCur[2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2946 | iTemp = piOrg[3] - piCur[3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2947 | iTemp = piOrg[4] - piCur[4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2948 | iTemp = piOrg[5] - piCur[5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2949 | iTemp = piOrg[6] - piCur[6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2950 | iTemp = piOrg[7] - piCur[7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2951 | |
---|
2952 | piOrg += iStrideOrg; |
---|
2953 | piCur += iStrideCur; |
---|
2954 | } |
---|
2955 | |
---|
2956 | return ( uiSum ); |
---|
2957 | } |
---|
2958 | |
---|
2959 | UInt TComWedgeDist::xGetSSE16( DistParam* pcDtParam ) |
---|
2960 | { |
---|
2961 | Pel* piOrg = pcDtParam->pOrg; |
---|
2962 | Pel* piCur = pcDtParam->pCur; |
---|
2963 | Int iRows = pcDtParam->iRows; |
---|
2964 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
2965 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
2966 | |
---|
2967 | UInt uiSum = 0; |
---|
2968 | UInt uiShift = g_uiBitIncrement<<1; |
---|
2969 | |
---|
2970 | Int iTemp; |
---|
2971 | |
---|
2972 | for( ; iRows != 0; iRows-- ) |
---|
2973 | { |
---|
2974 | |
---|
2975 | iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2976 | iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2977 | iTemp = piOrg[ 2] - piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2978 | iTemp = piOrg[ 3] - piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2979 | iTemp = piOrg[ 4] - piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2980 | iTemp = piOrg[ 5] - piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2981 | iTemp = piOrg[ 6] - piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2982 | iTemp = piOrg[ 7] - piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2983 | iTemp = piOrg[ 8] - piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2984 | iTemp = piOrg[ 9] - piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2985 | iTemp = piOrg[10] - piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2986 | iTemp = piOrg[11] - piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2987 | iTemp = piOrg[12] - piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2988 | iTemp = piOrg[13] - piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2989 | iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2990 | iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2991 | |
---|
2992 | piOrg += iStrideOrg; |
---|
2993 | piCur += iStrideCur; |
---|
2994 | } |
---|
2995 | |
---|
2996 | return ( uiSum ); |
---|
2997 | } |
---|
2998 | |
---|
2999 | UInt TComWedgeDist::xGetSSE32( DistParam* pcDtParam ) |
---|
3000 | { |
---|
3001 | Pel* piOrg = pcDtParam->pOrg; |
---|
3002 | Pel* piCur = pcDtParam->pCur; |
---|
3003 | Int iRows = pcDtParam->iRows; |
---|
3004 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
3005 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
3006 | |
---|
3007 | UInt uiSum = 0; |
---|
3008 | UInt uiShift = g_uiBitIncrement<<1; |
---|
3009 | Int iTemp; |
---|
3010 | |
---|
3011 | for( ; iRows != 0; iRows-- ) |
---|
3012 | { |
---|
3013 | |
---|
3014 | iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
3015 | iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
3016 | iTemp = piOrg[ 2] - piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
3017 | iTemp = piOrg[ 3] - piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
3018 | iTemp = piOrg[ 4] - piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
3019 | iTemp = piOrg[ 5] - piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
3020 | iTemp = piOrg[ 6] - piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
3021 | iTemp = piOrg[ 7] - piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
3022 | iTemp = piOrg[ 8] - piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
3023 | iTemp = piOrg[ 9] - piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
3024 | iTemp = piOrg[10] - piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
3025 | iTemp = piOrg[11] - piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
3026 | iTemp = piOrg[12] - piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
3027 | iTemp = piOrg[13] - piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
3028 | iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
3029 | iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
3030 | iTemp = piOrg[16] - piCur[16]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
3031 | iTemp = piOrg[17] - piCur[17]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
3032 | iTemp = piOrg[18] - piCur[18]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
3033 | iTemp = piOrg[19] - piCur[19]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
3034 | iTemp = piOrg[20] - piCur[20]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
3035 | iTemp = piOrg[21] - piCur[21]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
3036 | iTemp = piOrg[22] - piCur[22]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
3037 | iTemp = piOrg[23] - piCur[23]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
3038 | iTemp = piOrg[24] - piCur[24]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
3039 | iTemp = piOrg[25] - piCur[25]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
3040 | iTemp = piOrg[26] - piCur[26]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
3041 | iTemp = piOrg[27] - piCur[27]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
3042 | iTemp = piOrg[28] - piCur[28]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
3043 | iTemp = piOrg[29] - piCur[29]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
3044 | iTemp = piOrg[30] - piCur[30]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
3045 | iTemp = piOrg[31] - piCur[31]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
3046 | |
---|
3047 | piOrg += iStrideOrg; |
---|
3048 | piCur += iStrideCur; |
---|
3049 | } |
---|
3050 | |
---|
3051 | return ( uiSum ); |
---|
3052 | } |
---|
3053 | |
---|
3054 | Void TComWedgeDist::setDistParam( UInt uiBlkWidth, UInt uiBlkHeight, WedgeDist eWDist, DistParam& rcDistParam ) |
---|
3055 | { |
---|
3056 | // set Block Width / Height |
---|
3057 | rcDistParam.iCols = uiBlkWidth; |
---|
3058 | rcDistParam.iRows = uiBlkHeight; |
---|
3059 | rcDistParam.DistFunc = m_afpDistortFunc[eWDist + g_aucConvertToBit[ rcDistParam.iCols ] ]; |
---|
3060 | |
---|
3061 | // initialize |
---|
3062 | rcDistParam.iSubShift = 0; |
---|
3063 | } |
---|
3064 | |
---|
3065 | UInt TComWedgeDist::getDistPart( Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, WedgeDist eWDist ) |
---|
3066 | { |
---|
3067 | DistParam cDtParam; |
---|
3068 | setDistParam( uiBlkWidth, uiBlkHeight, eWDist, cDtParam ); |
---|
3069 | cDtParam.pOrg = piOrg; |
---|
3070 | cDtParam.pCur = piCur; |
---|
3071 | cDtParam.iStrideOrg = iOrgStride; |
---|
3072 | cDtParam.iStrideCur = iCurStride; |
---|
3073 | #ifdef DCM_RDCOST_TEMP_FIX //Temporary fix since DistParam is lacking a constructor and the variable iStep is not initialized |
---|
3074 | cDtParam.iStep = 1; |
---|
3075 | #endif |
---|
3076 | return cDtParam.DistFunc( &cDtParam ); |
---|
3077 | } |
---|
3078 | #endif |
---|