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-2015, ITU/ISO/IEC |
---|
7 | * All rights reserved. |
---|
8 | * |
---|
9 | * Redistribution and use in source and binary forms, with or without |
---|
10 | * modification, are permitted provided that the following conditions are met: |
---|
11 | * |
---|
12 | * * Redistributions of source code must retain the above copyright notice, |
---|
13 | * this list of conditions and the following disclaimer. |
---|
14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
15 | * this list of conditions and the following disclaimer in the documentation |
---|
16 | * and/or other materials provided with the distribution. |
---|
17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
18 | * be used to endorse or promote products derived from this software without |
---|
19 | * specific prior written permission. |
---|
20 | * |
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
32 | */ |
---|
33 | |
---|
34 | /** \file TComPrediction.cpp |
---|
35 | \brief prediction class |
---|
36 | */ |
---|
37 | |
---|
38 | #include <memory.h> |
---|
39 | #include "TComPrediction.h" |
---|
40 | #include "TComPic.h" |
---|
41 | #include "TComTU.h" |
---|
42 | |
---|
43 | //! \ingroup TLibCommon |
---|
44 | //! \{ |
---|
45 | |
---|
46 | // ==================================================================================================================== |
---|
47 | // Tables |
---|
48 | // ==================================================================================================================== |
---|
49 | |
---|
50 | const UChar TComPrediction::m_aucIntraFilter[MAX_NUM_CHANNEL_TYPE][MAX_INTRA_FILTER_DEPTHS] = |
---|
51 | { |
---|
52 | { // Luma |
---|
53 | 10, //4x4 |
---|
54 | 7, //8x8 |
---|
55 | 1, //16x16 |
---|
56 | 0, //32x32 |
---|
57 | 10, //64x64 |
---|
58 | }, |
---|
59 | { // Chroma |
---|
60 | 10, //4xn |
---|
61 | 7, //8xn |
---|
62 | 1, //16xn |
---|
63 | 0, //32xn |
---|
64 | 10, //64xn |
---|
65 | } |
---|
66 | |
---|
67 | }; |
---|
68 | |
---|
69 | // ==================================================================================================================== |
---|
70 | // Constructor / destructor / initialize |
---|
71 | // ==================================================================================================================== |
---|
72 | |
---|
73 | TComPrediction::TComPrediction() |
---|
74 | : m_pLumaRecBuffer(0) |
---|
75 | , m_iLumaRecStride(0) |
---|
76 | { |
---|
77 | for(UInt ch=0; ch<MAX_NUM_COMPONENT; ch++) |
---|
78 | { |
---|
79 | for(UInt buf=0; buf<2; buf++) |
---|
80 | { |
---|
81 | m_piYuvExt[ch][buf] = NULL; |
---|
82 | } |
---|
83 | } |
---|
84 | } |
---|
85 | |
---|
86 | TComPrediction::~TComPrediction() |
---|
87 | { |
---|
88 | destroy(); |
---|
89 | } |
---|
90 | |
---|
91 | Void TComPrediction::destroy() |
---|
92 | { |
---|
93 | for(UInt ch=0; ch<MAX_NUM_COMPONENT; ch++) |
---|
94 | { |
---|
95 | for(UInt buf=0; buf<NUM_PRED_BUF; buf++) |
---|
96 | { |
---|
97 | delete [] m_piYuvExt[ch][buf]; |
---|
98 | m_piYuvExt[ch][buf] = NULL; |
---|
99 | } |
---|
100 | } |
---|
101 | |
---|
102 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
103 | { |
---|
104 | m_acYuvPred[i].destroy(); |
---|
105 | } |
---|
106 | |
---|
107 | m_cYuvPredTemp.destroy(); |
---|
108 | |
---|
109 | if( m_pLumaRecBuffer ) |
---|
110 | { |
---|
111 | delete [] m_pLumaRecBuffer; |
---|
112 | m_pLumaRecBuffer = 0; |
---|
113 | } |
---|
114 | m_iLumaRecStride = 0; |
---|
115 | |
---|
116 | for (UInt i = 0; i < LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS; i++) |
---|
117 | { |
---|
118 | for (UInt j = 0; j < LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS; j++) |
---|
119 | { |
---|
120 | m_filteredBlock[i][j].destroy(); |
---|
121 | } |
---|
122 | m_filteredBlockTmp[i].destroy(); |
---|
123 | } |
---|
124 | } |
---|
125 | |
---|
126 | Void TComPrediction::initTempBuff(ChromaFormat chromaFormatIDC) |
---|
127 | { |
---|
128 | // if it has been initialised before, but the chroma format has changed, release the memory and start again. |
---|
129 | if( m_piYuvExt[COMPONENT_Y][PRED_BUF_UNFILTERED] != NULL && m_cYuvPredTemp.getChromaFormat()!=chromaFormatIDC) |
---|
130 | { |
---|
131 | destroy(); |
---|
132 | } |
---|
133 | |
---|
134 | if( m_piYuvExt[COMPONENT_Y][PRED_BUF_UNFILTERED] == NULL ) // check if first is null (in which case, nothing initialised yet) |
---|
135 | { |
---|
136 | Int extWidth = MAX_CU_SIZE + 16; |
---|
137 | Int extHeight = MAX_CU_SIZE + 1; |
---|
138 | |
---|
139 | for (UInt i = 0; i < LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS; i++) |
---|
140 | { |
---|
141 | m_filteredBlockTmp[i].create(extWidth, extHeight + 7, chromaFormatIDC); |
---|
142 | for (UInt j = 0; j < LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS; j++) |
---|
143 | { |
---|
144 | m_filteredBlock[i][j].create(extWidth, extHeight, chromaFormatIDC); |
---|
145 | } |
---|
146 | } |
---|
147 | |
---|
148 | m_iYuvExtSize = (MAX_CU_SIZE*2+1) * (MAX_CU_SIZE*2+1); |
---|
149 | for(UInt ch=0; ch<MAX_NUM_COMPONENT; ch++) |
---|
150 | { |
---|
151 | for(UInt buf=0; buf<NUM_PRED_BUF; buf++) |
---|
152 | { |
---|
153 | m_piYuvExt[ch][buf] = new Pel[ m_iYuvExtSize ]; |
---|
154 | } |
---|
155 | } |
---|
156 | |
---|
157 | // new structure |
---|
158 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
159 | { |
---|
160 | m_acYuvPred[i] .create( MAX_CU_SIZE, MAX_CU_SIZE, chromaFormatIDC ); |
---|
161 | } |
---|
162 | |
---|
163 | m_cYuvPredTemp.create( MAX_CU_SIZE, MAX_CU_SIZE, chromaFormatIDC ); |
---|
164 | } |
---|
165 | |
---|
166 | |
---|
167 | if (m_iLumaRecStride != (MAX_CU_SIZE>>1) + 1) |
---|
168 | { |
---|
169 | m_iLumaRecStride = (MAX_CU_SIZE>>1) + 1; |
---|
170 | if (!m_pLumaRecBuffer) |
---|
171 | { |
---|
172 | m_pLumaRecBuffer = new Pel[ m_iLumaRecStride * m_iLumaRecStride ]; |
---|
173 | } |
---|
174 | } |
---|
175 | } |
---|
176 | |
---|
177 | // ==================================================================================================================== |
---|
178 | // Public member functions |
---|
179 | // ==================================================================================================================== |
---|
180 | |
---|
181 | // Function for calculating DC value of the reference samples used in Intra prediction |
---|
182 | //NOTE: Bit-Limit - 25-bit source |
---|
183 | Pel TComPrediction::predIntraGetPredValDC( const Pel* pSrc, Int iSrcStride, UInt iWidth, UInt iHeight, Bool bAbove, Bool bLeft ) |
---|
184 | { |
---|
185 | assert(iWidth > 0 && iHeight > 0); |
---|
186 | Int iInd, iSum = 0; |
---|
187 | Pel pDcVal; |
---|
188 | |
---|
189 | if (bAbove) |
---|
190 | { |
---|
191 | for (iInd = 0;iInd < iWidth;iInd++) |
---|
192 | { |
---|
193 | iSum += pSrc[iInd-iSrcStride]; |
---|
194 | } |
---|
195 | } |
---|
196 | if (bLeft) |
---|
197 | { |
---|
198 | for (iInd = 0;iInd < iHeight;iInd++) |
---|
199 | { |
---|
200 | iSum += pSrc[iInd*iSrcStride-1]; |
---|
201 | } |
---|
202 | } |
---|
203 | |
---|
204 | if (bAbove && bLeft) |
---|
205 | { |
---|
206 | pDcVal = (iSum + iWidth) / (iWidth + iHeight); |
---|
207 | } |
---|
208 | else if (bAbove) |
---|
209 | { |
---|
210 | pDcVal = (iSum + iWidth/2) / iWidth; |
---|
211 | } |
---|
212 | else if (bLeft) |
---|
213 | { |
---|
214 | pDcVal = (iSum + iHeight/2) / iHeight; |
---|
215 | } |
---|
216 | else |
---|
217 | { |
---|
218 | pDcVal = pSrc[-1]; // Default DC value already calculated and placed in the prediction array if no neighbors are available |
---|
219 | } |
---|
220 | |
---|
221 | return pDcVal; |
---|
222 | } |
---|
223 | |
---|
224 | // Function for deriving the angular Intra predictions |
---|
225 | |
---|
226 | /** Function for deriving the simplified angular intra predictions. |
---|
227 | * \param bitDepth bit depth |
---|
228 | * \param pSrc pointer to reconstructed sample array |
---|
229 | * \param srcStride the stride of the reconstructed sample array |
---|
230 | * \param pTrueDst reference to pointer for the prediction sample array |
---|
231 | * \param dstStrideTrue the stride of the prediction sample array |
---|
232 | * \param uiWidth the width of the block |
---|
233 | * \param uiHeight the height of the block |
---|
234 | * \param channelType type of pel array (luma/chroma) |
---|
235 | * \param format chroma format |
---|
236 | * \param dirMode the intra prediction mode index |
---|
237 | * \param blkAboveAvailable boolean indication if the block above is available |
---|
238 | * \param blkLeftAvailable boolean indication if the block to the left is available |
---|
239 | * \param bEnableEdgeFilters indication whether to enable edge filters |
---|
240 | * |
---|
241 | * This function derives the prediction samples for the angular mode based on the prediction direction indicated by |
---|
242 | * the prediction mode index. The prediction direction is given by the displacement of the bottom row of the block and |
---|
243 | * the reference row above the block in the case of vertical prediction or displacement of the rightmost column |
---|
244 | * of the block and reference column left from the block in the case of the horizontal prediction. The displacement |
---|
245 | * is signalled at 1/32 pixel accuracy. When projection of the predicted pixel falls inbetween reference samples, |
---|
246 | * the predicted value for the pixel is linearly interpolated from the reference samples. All reference samples are taken |
---|
247 | * from the extended main reference. |
---|
248 | */ |
---|
249 | //NOTE: Bit-Limit - 25-bit source |
---|
250 | Void TComPrediction::xPredIntraAng( Int bitDepth, |
---|
251 | const Pel* pSrc, Int srcStride, |
---|
252 | Pel* pTrueDst, Int dstStrideTrue, |
---|
253 | UInt uiWidth, UInt uiHeight, ChannelType channelType, |
---|
254 | UInt dirMode, Bool blkAboveAvailable, Bool blkLeftAvailable |
---|
255 | , const Bool bEnableEdgeFilters |
---|
256 | ) |
---|
257 | { |
---|
258 | Int width=Int(uiWidth); |
---|
259 | Int height=Int(uiHeight); |
---|
260 | |
---|
261 | // Map the mode index to main prediction direction and angle |
---|
262 | assert( dirMode != PLANAR_IDX ); //no planar |
---|
263 | const Bool modeDC = dirMode==DC_IDX; |
---|
264 | |
---|
265 | // Do the DC prediction |
---|
266 | if (modeDC) |
---|
267 | { |
---|
268 | const Pel dcval = predIntraGetPredValDC(pSrc, srcStride, width, height, blkAboveAvailable, blkLeftAvailable); |
---|
269 | |
---|
270 | for (Int y=height;y>0;y--, pTrueDst+=dstStrideTrue) |
---|
271 | { |
---|
272 | for (Int x=0; x<width;) // width is always a multiple of 4. |
---|
273 | { |
---|
274 | pTrueDst[x++] = dcval; |
---|
275 | } |
---|
276 | } |
---|
277 | } |
---|
278 | else // Do angular predictions |
---|
279 | { |
---|
280 | const Bool bIsModeVer = (dirMode >= 18); |
---|
281 | const Int intraPredAngleMode = (bIsModeVer) ? (Int)dirMode - VER_IDX : -((Int)dirMode - HOR_IDX); |
---|
282 | const Int absAngMode = abs(intraPredAngleMode); |
---|
283 | const Int signAng = intraPredAngleMode < 0 ? -1 : 1; |
---|
284 | const Bool edgeFilter = bEnableEdgeFilters && isLuma(channelType) && (width <= MAXIMUM_INTRA_FILTERED_WIDTH) && (height <= MAXIMUM_INTRA_FILTERED_HEIGHT); |
---|
285 | |
---|
286 | // Set bitshifts and scale the angle parameter to block size |
---|
287 | static const Int angTable[9] = {0, 2, 5, 9, 13, 17, 21, 26, 32}; |
---|
288 | static const Int invAngTable[9] = {0, 4096, 1638, 910, 630, 482, 390, 315, 256}; // (256 * 32) / Angle |
---|
289 | Int invAngle = invAngTable[absAngMode]; |
---|
290 | Int absAng = angTable[absAngMode]; |
---|
291 | Int intraPredAngle = signAng * absAng; |
---|
292 | |
---|
293 | Pel* refMain; |
---|
294 | Pel* refSide; |
---|
295 | |
---|
296 | Pel refAbove[2*MAX_CU_SIZE+1]; |
---|
297 | Pel refLeft[2*MAX_CU_SIZE+1]; |
---|
298 | |
---|
299 | // Initialise the Main and Left reference array. |
---|
300 | if (intraPredAngle < 0) |
---|
301 | { |
---|
302 | const Int refMainOffsetPreScale = (bIsModeVer ? height : width ) - 1; |
---|
303 | const Int refMainOffset = height - 1; |
---|
304 | for (Int x=0;x<width+1;x++) |
---|
305 | { |
---|
306 | refAbove[x+refMainOffset] = pSrc[x-srcStride-1]; |
---|
307 | } |
---|
308 | for (Int y=0;y<height+1;y++) |
---|
309 | { |
---|
310 | refLeft[y+refMainOffset] = pSrc[(y-1)*srcStride-1]; |
---|
311 | } |
---|
312 | refMain = (bIsModeVer ? refAbove : refLeft) + refMainOffset; |
---|
313 | refSide = (bIsModeVer ? refLeft : refAbove) + refMainOffset; |
---|
314 | |
---|
315 | // Extend the Main reference to the left. |
---|
316 | Int invAngleSum = 128; // rounding for (shift by 8) |
---|
317 | for (Int k=-1; k>(refMainOffsetPreScale+1)*intraPredAngle>>5; k--) |
---|
318 | { |
---|
319 | invAngleSum += invAngle; |
---|
320 | refMain[k] = refSide[invAngleSum>>8]; |
---|
321 | } |
---|
322 | } |
---|
323 | else |
---|
324 | { |
---|
325 | for (Int x=0;x<2*width+1;x++) |
---|
326 | { |
---|
327 | refAbove[x] = pSrc[x-srcStride-1]; |
---|
328 | } |
---|
329 | for (Int y=0;y<2*height+1;y++) |
---|
330 | { |
---|
331 | refLeft[y] = pSrc[(y-1)*srcStride-1]; |
---|
332 | } |
---|
333 | refMain = bIsModeVer ? refAbove : refLeft ; |
---|
334 | refSide = bIsModeVer ? refLeft : refAbove; |
---|
335 | } |
---|
336 | |
---|
337 | // swap width/height if we are doing a horizontal mode: |
---|
338 | Pel tempArray[MAX_CU_SIZE*MAX_CU_SIZE]; |
---|
339 | const Int dstStride = bIsModeVer ? dstStrideTrue : MAX_CU_SIZE; |
---|
340 | Pel *pDst = bIsModeVer ? pTrueDst : tempArray; |
---|
341 | if (!bIsModeVer) |
---|
342 | { |
---|
343 | std::swap(width, height); |
---|
344 | } |
---|
345 | |
---|
346 | if (intraPredAngle == 0) // pure vertical or pure horizontal |
---|
347 | { |
---|
348 | for (Int y=0;y<height;y++) |
---|
349 | { |
---|
350 | for (Int x=0;x<width;x++) |
---|
351 | { |
---|
352 | pDst[y*dstStride+x] = refMain[x+1]; |
---|
353 | } |
---|
354 | } |
---|
355 | |
---|
356 | if (edgeFilter) |
---|
357 | { |
---|
358 | for (Int y=0;y<height;y++) |
---|
359 | { |
---|
360 | pDst[y*dstStride] = Clip3 (0, ((1 << bitDepth) - 1), pDst[y*dstStride] + (( refSide[y+1] - refSide[0] ) >> 1) ); |
---|
361 | } |
---|
362 | } |
---|
363 | } |
---|
364 | else |
---|
365 | { |
---|
366 | Pel *pDsty=pDst; |
---|
367 | |
---|
368 | for (Int y=0, deltaPos=intraPredAngle; y<height; y++, deltaPos+=intraPredAngle, pDsty+=dstStride) |
---|
369 | { |
---|
370 | const Int deltaInt = deltaPos >> 5; |
---|
371 | const Int deltaFract = deltaPos & (32 - 1); |
---|
372 | |
---|
373 | if (deltaFract) |
---|
374 | { |
---|
375 | // Do linear filtering |
---|
376 | const Pel *pRM=refMain+deltaInt+1; |
---|
377 | Int lastRefMainPel=*pRM++; |
---|
378 | for (Int x=0;x<width;pRM++,x++) |
---|
379 | { |
---|
380 | Int thisRefMainPel=*pRM; |
---|
381 | pDsty[x+0] = (Pel) ( ((32-deltaFract)*lastRefMainPel + deltaFract*thisRefMainPel +16) >> 5 ); |
---|
382 | lastRefMainPel=thisRefMainPel; |
---|
383 | } |
---|
384 | } |
---|
385 | else |
---|
386 | { |
---|
387 | // Just copy the integer samples |
---|
388 | for (Int x=0;x<width; x++) |
---|
389 | { |
---|
390 | pDsty[x] = refMain[x+deltaInt+1]; |
---|
391 | } |
---|
392 | } |
---|
393 | } |
---|
394 | } |
---|
395 | |
---|
396 | // Flip the block if this is the horizontal mode |
---|
397 | if (!bIsModeVer) |
---|
398 | { |
---|
399 | for (Int y=0; y<height; y++) |
---|
400 | { |
---|
401 | for (Int x=0; x<width; x++) |
---|
402 | { |
---|
403 | pTrueDst[x*dstStrideTrue] = pDst[x]; |
---|
404 | } |
---|
405 | pTrueDst++; |
---|
406 | pDst+=dstStride; |
---|
407 | } |
---|
408 | } |
---|
409 | } |
---|
410 | } |
---|
411 | |
---|
412 | Void TComPrediction::predIntraAng( const ComponentID compID, UInt uiDirMode, Pel* piOrg /* Will be null for decoding */, UInt uiOrgStride, Pel* piPred, UInt uiStride, TComTU &rTu, Bool bAbove, Bool bLeft, const Bool bUseFilteredPredSamples, const Bool bUseLosslessDPCM ) |
---|
413 | { |
---|
414 | const ChannelType channelType = toChannelType(compID); |
---|
415 | const TComRectangle &rect = rTu.getRect(isLuma(compID) ? COMPONENT_Y : COMPONENT_Cb); |
---|
416 | const Int iWidth = rect.width; |
---|
417 | const Int iHeight = rect.height; |
---|
418 | |
---|
419 | assert( g_aucConvertToBit[ iWidth ] >= 0 ); // 4x 4 |
---|
420 | assert( g_aucConvertToBit[ iWidth ] <= 5 ); // 128x128 |
---|
421 | //assert( iWidth == iHeight ); |
---|
422 | |
---|
423 | Pel *pDst = piPred; |
---|
424 | |
---|
425 | // get starting pixel in block |
---|
426 | const Int sw = (2 * iWidth + 1); |
---|
427 | |
---|
428 | if ( bUseLosslessDPCM ) |
---|
429 | { |
---|
430 | const Pel *ptrSrc = getPredictorPtr( compID, false ); |
---|
431 | // Sample Adaptive intra-Prediction (SAP) |
---|
432 | if (uiDirMode==HOR_IDX) |
---|
433 | { |
---|
434 | // left column filled with reference samples |
---|
435 | // remaining columns filled with piOrg data (if available). |
---|
436 | for(Int y=0; y<iHeight; y++) |
---|
437 | { |
---|
438 | piPred[y*uiStride+0] = ptrSrc[(y+1)*sw]; |
---|
439 | } |
---|
440 | if (piOrg!=0) |
---|
441 | { |
---|
442 | piPred+=1; // miss off first column |
---|
443 | for(Int y=0; y<iHeight; y++, piPred+=uiStride, piOrg+=uiOrgStride) |
---|
444 | { |
---|
445 | memcpy(piPred, piOrg, (iWidth-1)*sizeof(Pel)); |
---|
446 | } |
---|
447 | } |
---|
448 | } |
---|
449 | else // VER_IDX |
---|
450 | { |
---|
451 | // top row filled with reference samples |
---|
452 | // remaining rows filled with piOrd data (if available) |
---|
453 | for(Int x=0; x<iWidth; x++) |
---|
454 | { |
---|
455 | piPred[x] = ptrSrc[x+1]; |
---|
456 | } |
---|
457 | if (piOrg!=0) |
---|
458 | { |
---|
459 | piPred+=uiStride; // miss off the first row |
---|
460 | for(Int y=1; y<iHeight; y++, piPred+=uiStride, piOrg+=uiOrgStride) |
---|
461 | { |
---|
462 | memcpy(piPred, piOrg, iWidth*sizeof(Pel)); |
---|
463 | } |
---|
464 | } |
---|
465 | } |
---|
466 | } |
---|
467 | else |
---|
468 | { |
---|
469 | const Pel *ptrSrc = getPredictorPtr( compID, bUseFilteredPredSamples ); |
---|
470 | |
---|
471 | if ( uiDirMode == PLANAR_IDX ) |
---|
472 | { |
---|
473 | xPredIntraPlanar( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight ); |
---|
474 | } |
---|
475 | else |
---|
476 | { |
---|
477 | // Create the prediction |
---|
478 | TComDataCU *const pcCU = rTu.getCU(); |
---|
479 | const UInt uiAbsPartIdx = rTu.GetAbsPartIdxTU(); |
---|
480 | const Bool enableEdgeFilters = !(pcCU->isRDPCMEnabled(uiAbsPartIdx) && pcCU->getCUTransquantBypass(uiAbsPartIdx)); |
---|
481 | #if O0043_BEST_EFFORT_DECODING |
---|
482 | const Int channelsBitDepthForPrediction = rTu.getCU()->getSlice()->getSPS()->getStreamBitDepth(channelType); |
---|
483 | #else |
---|
484 | #if SVC_EXTENSION |
---|
485 | const Int channelsBitDepthForPrediction = rTu.getCU()->getSlice()->getBitDepth(channelType); |
---|
486 | #else |
---|
487 | const Int channelsBitDepthForPrediction = rTu.getCU()->getSlice()->getSPS()->getBitDepth(channelType); |
---|
488 | #endif |
---|
489 | #endif |
---|
490 | xPredIntraAng( channelsBitDepthForPrediction, ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, channelType, uiDirMode, bAbove, bLeft, enableEdgeFilters ); |
---|
491 | |
---|
492 | if(( uiDirMode == DC_IDX ) && bAbove && bLeft ) |
---|
493 | { |
---|
494 | xDCPredFiltering( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, channelType ); |
---|
495 | } |
---|
496 | } |
---|
497 | } |
---|
498 | |
---|
499 | } |
---|
500 | |
---|
501 | /** Check for identical motion in both motion vector direction of a bi-directional predicted CU |
---|
502 | * \returns true, if motion vectors and reference pictures match |
---|
503 | */ |
---|
504 | Bool TComPrediction::xCheckIdenticalMotion ( TComDataCU* pcCU, UInt PartAddr ) |
---|
505 | { |
---|
506 | if( pcCU->getSlice()->isInterB() && !pcCU->getSlice()->getPPS()->getWPBiPred() ) |
---|
507 | { |
---|
508 | if( pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr) >= 0 && pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr) >= 0) |
---|
509 | { |
---|
510 | Int RefPOCL0 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_0, pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr))->getPOC(); |
---|
511 | Int RefPOCL1 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_1, pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr))->getPOC(); |
---|
512 | if(RefPOCL0 == RefPOCL1 && pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr) == pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr)) |
---|
513 | { |
---|
514 | return true; |
---|
515 | } |
---|
516 | } |
---|
517 | } |
---|
518 | return false; |
---|
519 | } |
---|
520 | |
---|
521 | Void TComPrediction::motionCompensation ( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx ) |
---|
522 | { |
---|
523 | Int iWidth; |
---|
524 | Int iHeight; |
---|
525 | UInt uiPartAddr; |
---|
526 | |
---|
527 | if ( iPartIdx >= 0 ) |
---|
528 | { |
---|
529 | pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight ); |
---|
530 | if ( eRefPicList != REF_PIC_LIST_X ) |
---|
531 | { |
---|
532 | if( pcCU->getSlice()->getPPS()->getUseWP()) |
---|
533 | { |
---|
534 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true ); |
---|
535 | } |
---|
536 | else |
---|
537 | { |
---|
538 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); |
---|
539 | } |
---|
540 | if ( pcCU->getSlice()->getPPS()->getUseWP() ) |
---|
541 | { |
---|
542 | xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); |
---|
543 | } |
---|
544 | } |
---|
545 | else |
---|
546 | { |
---|
547 | if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) ) |
---|
548 | { |
---|
549 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred ); |
---|
550 | } |
---|
551 | else |
---|
552 | { |
---|
553 | xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred ); |
---|
554 | } |
---|
555 | } |
---|
556 | return; |
---|
557 | } |
---|
558 | |
---|
559 | for ( iPartIdx = 0; iPartIdx < pcCU->getNumPartitions(); iPartIdx++ ) |
---|
560 | { |
---|
561 | pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight ); |
---|
562 | |
---|
563 | if ( eRefPicList != REF_PIC_LIST_X ) |
---|
564 | { |
---|
565 | if( pcCU->getSlice()->getPPS()->getUseWP()) |
---|
566 | { |
---|
567 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true ); |
---|
568 | } |
---|
569 | else |
---|
570 | { |
---|
571 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); |
---|
572 | } |
---|
573 | if ( pcCU->getSlice()->getPPS()->getUseWP() ) |
---|
574 | { |
---|
575 | xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); |
---|
576 | } |
---|
577 | } |
---|
578 | else |
---|
579 | { |
---|
580 | if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) ) |
---|
581 | { |
---|
582 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred ); |
---|
583 | } |
---|
584 | else |
---|
585 | { |
---|
586 | xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred ); |
---|
587 | } |
---|
588 | } |
---|
589 | } |
---|
590 | return; |
---|
591 | } |
---|
592 | |
---|
593 | Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv* pcYuvPred, Bool bi ) |
---|
594 | { |
---|
595 | Int iRefIdx = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); assert (iRefIdx >= 0); |
---|
596 | TComMv cMv = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr ); |
---|
597 | pcCU->clipMv(cMv); |
---|
598 | |
---|
599 | #if SVC_EXTENSION |
---|
600 | if( pcCU->getLayerId() > 0 ) |
---|
601 | { |
---|
602 | TComPic* refPic = pcCU->getSlice()->getRefPic(eRefPicList, iRefIdx); |
---|
603 | |
---|
604 | if( refPic->isILR(pcCU->getLayerId()) ) |
---|
605 | { |
---|
606 | // It is a requirement of bitstream conformance that when the reference picture represented by the variable refIdxLX is an inter-layer reference picture, |
---|
607 | // VpsInterLayerSamplePredictionEnabled[ LayerIdxInVps[ currLayerId ] ][ LayerIdxInVps[ rLId ] ] shall be equal to 1, where rLId is set equal to nuh_layer_id of the inter-layer picture |
---|
608 | assert( pcCU->getSlice()->getVPS()->isSamplePredictionType( pcCU->getLayerIdx(), refPic->getLayerIdx() ) ); |
---|
609 | |
---|
610 | #if REF_IDX_ME_ZEROMV |
---|
611 | // It is a requirement of bitstream conformance that the variables mvLX[ 0 ] and mvLX[ 1 ] shall be equal to 0 if the value of refIdxLX corresponds to an inter-layer reference picture. |
---|
612 | assert( cMv.getHor() == 0 && cMv.getVer() == 0 ); |
---|
613 | #endif |
---|
614 | } |
---|
615 | |
---|
616 | } |
---|
617 | #endif |
---|
618 | |
---|
619 | for (UInt comp=COMPONENT_Y; comp<pcYuvPred->getNumberValidComponents(); comp++) |
---|
620 | { |
---|
621 | const ComponentID compID=ComponentID(comp); |
---|
622 | #if SVC_EXTENSION |
---|
623 | xPredInterBlk (compID, pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, pcYuvPred, bi, pcCU->getSlice()->getBitDepth(toChannelType(compID)) ); |
---|
624 | #else |
---|
625 | xPredInterBlk (compID, pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, pcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)) ); |
---|
626 | #endif |
---|
627 | } |
---|
628 | } |
---|
629 | |
---|
630 | Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv* pcYuvPred ) |
---|
631 | { |
---|
632 | TComYuv* pcMbYuv; |
---|
633 | Int iRefIdx[NUM_REF_PIC_LIST_01] = {-1, -1}; |
---|
634 | |
---|
635 | for ( UInt refList = 0; refList < NUM_REF_PIC_LIST_01; refList++ ) |
---|
636 | { |
---|
637 | RefPicList eRefPicList = (refList ? REF_PIC_LIST_1 : REF_PIC_LIST_0); |
---|
638 | iRefIdx[refList] = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
639 | |
---|
640 | if ( iRefIdx[refList] < 0 ) |
---|
641 | { |
---|
642 | continue; |
---|
643 | } |
---|
644 | |
---|
645 | assert( iRefIdx[refList] < pcCU->getSlice()->getNumRefIdx(eRefPicList) ); |
---|
646 | |
---|
647 | pcMbYuv = &m_acYuvPred[refList]; |
---|
648 | if( pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr ) >= 0 && pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr ) >= 0 ) |
---|
649 | { |
---|
650 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, true ); |
---|
651 | } |
---|
652 | else |
---|
653 | { |
---|
654 | if ( ( pcCU->getSlice()->getPPS()->getUseWP() && pcCU->getSlice()->getSliceType() == P_SLICE ) || |
---|
655 | ( pcCU->getSlice()->getPPS()->getWPBiPred() && pcCU->getSlice()->getSliceType() == B_SLICE ) ) |
---|
656 | { |
---|
657 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, true ); |
---|
658 | } |
---|
659 | else |
---|
660 | { |
---|
661 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv ); |
---|
662 | } |
---|
663 | } |
---|
664 | } |
---|
665 | |
---|
666 | if ( pcCU->getSlice()->getPPS()->getWPBiPred() && pcCU->getSlice()->getSliceType() == B_SLICE ) |
---|
667 | { |
---|
668 | xWeightedPredictionBi( pcCU, &m_acYuvPred[REF_PIC_LIST_0], &m_acYuvPred[REF_PIC_LIST_1], iRefIdx[REF_PIC_LIST_0], iRefIdx[REF_PIC_LIST_1], uiPartAddr, iWidth, iHeight, pcYuvPred ); |
---|
669 | } |
---|
670 | else if ( pcCU->getSlice()->getPPS()->getUseWP() && pcCU->getSlice()->getSliceType() == P_SLICE ) |
---|
671 | { |
---|
672 | xWeightedPredictionUni( pcCU, &m_acYuvPred[REF_PIC_LIST_0], uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred ); |
---|
673 | } |
---|
674 | else |
---|
675 | { |
---|
676 | #if SVC_EXTENSION |
---|
677 | xWeightedAverage( &m_acYuvPred[REF_PIC_LIST_0], &m_acYuvPred[REF_PIC_LIST_1], iRefIdx[REF_PIC_LIST_0], iRefIdx[REF_PIC_LIST_1], uiPartAddr, iWidth, iHeight, pcYuvPred, pcCU->getSlice()->getBitDepths() ); |
---|
678 | #else |
---|
679 | xWeightedAverage( &m_acYuvPred[REF_PIC_LIST_0], &m_acYuvPred[REF_PIC_LIST_1], iRefIdx[REF_PIC_LIST_0], iRefIdx[REF_PIC_LIST_1], uiPartAddr, iWidth, iHeight, pcYuvPred, pcCU->getSlice()->getSPS()->getBitDepths() ); |
---|
680 | #endif |
---|
681 | } |
---|
682 | } |
---|
683 | |
---|
684 | /** |
---|
685 | * \brief Generate motion-compensated block |
---|
686 | * |
---|
687 | * \param compID Colour component ID |
---|
688 | * \param cu Pointer to current CU |
---|
689 | * \param refPic Pointer to reference picture |
---|
690 | * \param partAddr Address of block within CU |
---|
691 | * \param mv Motion vector |
---|
692 | * \param width Width of block |
---|
693 | * \param height Height of block |
---|
694 | * \param dstPic Pointer to destination picture |
---|
695 | * \param bi Flag indicating whether bipred is used |
---|
696 | * \param bitDepth Bit depth |
---|
697 | */ |
---|
698 | |
---|
699 | |
---|
700 | Void TComPrediction::xPredInterBlk(const ComponentID compID, TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *dstPic, Bool bi, const Int bitDepth ) |
---|
701 | { |
---|
702 | Int refStride = refPic->getStride(compID); |
---|
703 | Int dstStride = dstPic->getStride(compID); |
---|
704 | Int shiftHor=(2+refPic->getComponentScaleX(compID)); |
---|
705 | Int shiftVer=(2+refPic->getComponentScaleY(compID)); |
---|
706 | |
---|
707 | Int refOffset = (mv->getHor() >> shiftHor) + (mv->getVer() >> shiftVer) * refStride; |
---|
708 | |
---|
709 | Pel* ref = refPic->getAddr(compID, cu->getCtuRsAddr(), cu->getZorderIdxInCtu() + partAddr ) + refOffset; |
---|
710 | |
---|
711 | Pel* dst = dstPic->getAddr( compID, partAddr ); |
---|
712 | |
---|
713 | Int xFrac = mv->getHor() & ((1<<shiftHor)-1); |
---|
714 | Int yFrac = mv->getVer() & ((1<<shiftVer)-1); |
---|
715 | UInt cxWidth = width >> refPic->getComponentScaleX(compID); |
---|
716 | UInt cxHeight = height >> refPic->getComponentScaleY(compID); |
---|
717 | |
---|
718 | const ChromaFormat chFmt = cu->getPic()->getChromaFormat(); |
---|
719 | |
---|
720 | if ( yFrac == 0 ) |
---|
721 | { |
---|
722 | m_if.filterHor(compID, ref, refStride, dst, dstStride, cxWidth, cxHeight, xFrac, !bi, chFmt, bitDepth); |
---|
723 | } |
---|
724 | else if ( xFrac == 0 ) |
---|
725 | { |
---|
726 | m_if.filterVer(compID, ref, refStride, dst, dstStride, cxWidth, cxHeight, yFrac, true, !bi, chFmt, bitDepth); |
---|
727 | } |
---|
728 | else |
---|
729 | { |
---|
730 | Int tmpStride = m_filteredBlockTmp[0].getStride(compID); |
---|
731 | Pel* tmp = m_filteredBlockTmp[0].getAddr(compID); |
---|
732 | |
---|
733 | const Int vFilterSize = isLuma(compID) ? NTAPS_LUMA : NTAPS_CHROMA; |
---|
734 | |
---|
735 | m_if.filterHor(compID, ref - ((vFilterSize>>1) -1)*refStride, refStride, tmp, tmpStride, cxWidth, cxHeight+vFilterSize-1, xFrac, false, chFmt, bitDepth); |
---|
736 | m_if.filterVer(compID, tmp + ((vFilterSize>>1) -1)*tmpStride, tmpStride, dst, dstStride, cxWidth, cxHeight, yFrac, false, !bi, chFmt, bitDepth); |
---|
737 | } |
---|
738 | } |
---|
739 | |
---|
740 | Void TComPrediction::xWeightedAverage( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv* pcYuvDst, const BitDepths &clipBitDepths ) |
---|
741 | { |
---|
742 | if( iRefIdx0 >= 0 && iRefIdx1 >= 0 ) |
---|
743 | { |
---|
744 | pcYuvDst->addAvg( pcYuvSrc0, pcYuvSrc1, uiPartIdx, iWidth, iHeight, clipBitDepths ); |
---|
745 | } |
---|
746 | else if ( iRefIdx0 >= 0 && iRefIdx1 < 0 ) |
---|
747 | { |
---|
748 | pcYuvSrc0->copyPartToPartYuv( pcYuvDst, uiPartIdx, iWidth, iHeight ); |
---|
749 | } |
---|
750 | else if ( iRefIdx0 < 0 && iRefIdx1 >= 0 ) |
---|
751 | { |
---|
752 | pcYuvSrc1->copyPartToPartYuv( pcYuvDst, uiPartIdx, iWidth, iHeight ); |
---|
753 | } |
---|
754 | } |
---|
755 | |
---|
756 | // AMVP |
---|
757 | Void TComPrediction::getMvPredAMVP( TComDataCU* pcCU, UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, TComMv& rcMvPred ) |
---|
758 | { |
---|
759 | AMVPInfo* pcAMVPInfo = pcCU->getCUMvField(eRefPicList)->getAMVPInfo(); |
---|
760 | |
---|
761 | if( pcAMVPInfo->iN <= 1 ) |
---|
762 | { |
---|
763 | rcMvPred = pcAMVPInfo->m_acMvCand[0]; |
---|
764 | |
---|
765 | pcCU->setMVPIdxSubParts( 0, eRefPicList, uiPartAddr, uiPartIdx, pcCU->getDepth(uiPartAddr)); |
---|
766 | pcCU->setMVPNumSubParts( pcAMVPInfo->iN, eRefPicList, uiPartAddr, uiPartIdx, pcCU->getDepth(uiPartAddr)); |
---|
767 | return; |
---|
768 | } |
---|
769 | |
---|
770 | assert(pcCU->getMVPIdx(eRefPicList,uiPartAddr) >= 0); |
---|
771 | rcMvPred = pcAMVPInfo->m_acMvCand[pcCU->getMVPIdx(eRefPicList,uiPartAddr)]; |
---|
772 | return; |
---|
773 | } |
---|
774 | |
---|
775 | /** Function for deriving planar intra prediction. |
---|
776 | * \param pSrc pointer to reconstructed sample array |
---|
777 | * \param srcStride the stride of the reconstructed sample array |
---|
778 | * \param rpDst reference to pointer for the prediction sample array |
---|
779 | * \param dstStride the stride of the prediction sample array |
---|
780 | * \param width the width of the block |
---|
781 | * \param height the height of the block |
---|
782 | * \param channelType type of pel array (luma, chroma) |
---|
783 | * \param format chroma format |
---|
784 | * |
---|
785 | * This function derives the prediction samples for planar mode (intra coding). |
---|
786 | */ |
---|
787 | //NOTE: Bit-Limit - 24-bit source |
---|
788 | Void TComPrediction::xPredIntraPlanar( const Pel* pSrc, Int srcStride, Pel* rpDst, Int dstStride, UInt width, UInt height ) |
---|
789 | { |
---|
790 | assert(width <= height); |
---|
791 | |
---|
792 | Int leftColumn[MAX_CU_SIZE+1], topRow[MAX_CU_SIZE+1], bottomRow[MAX_CU_SIZE], rightColumn[MAX_CU_SIZE]; |
---|
793 | UInt shift1Dhor = g_aucConvertToBit[ width ] + 2; |
---|
794 | UInt shift1Dver = g_aucConvertToBit[ height ] + 2; |
---|
795 | |
---|
796 | // Get left and above reference column and row |
---|
797 | for(Int k=0;k<width+1;k++) |
---|
798 | { |
---|
799 | topRow[k] = pSrc[k-srcStride]; |
---|
800 | } |
---|
801 | |
---|
802 | for (Int k=0; k < height+1; k++) |
---|
803 | { |
---|
804 | leftColumn[k] = pSrc[k*srcStride-1]; |
---|
805 | } |
---|
806 | |
---|
807 | // Prepare intermediate variables used in interpolation |
---|
808 | Int bottomLeft = leftColumn[height]; |
---|
809 | Int topRight = topRow[width]; |
---|
810 | |
---|
811 | for(Int k=0;k<width;k++) |
---|
812 | { |
---|
813 | bottomRow[k] = bottomLeft - topRow[k]; |
---|
814 | topRow[k] <<= shift1Dver; |
---|
815 | } |
---|
816 | |
---|
817 | for(Int k=0;k<height;k++) |
---|
818 | { |
---|
819 | rightColumn[k] = topRight - leftColumn[k]; |
---|
820 | leftColumn[k] <<= shift1Dhor; |
---|
821 | } |
---|
822 | |
---|
823 | const UInt topRowShift = 0; |
---|
824 | |
---|
825 | // Generate prediction signal |
---|
826 | for (Int y=0;y<height;y++) |
---|
827 | { |
---|
828 | Int horPred = leftColumn[y] + width; |
---|
829 | for (Int x=0;x<width;x++) |
---|
830 | { |
---|
831 | horPred += rightColumn[y]; |
---|
832 | topRow[x] += bottomRow[x]; |
---|
833 | |
---|
834 | Int vertPred = ((topRow[x] + topRowShift)>>topRowShift); |
---|
835 | rpDst[y*dstStride+x] = ( horPred + vertPred ) >> (shift1Dhor+1); |
---|
836 | } |
---|
837 | } |
---|
838 | } |
---|
839 | |
---|
840 | /** Function for filtering intra DC predictor. |
---|
841 | * \param pSrc pointer to reconstructed sample array |
---|
842 | * \param iSrcStride the stride of the reconstructed sample array |
---|
843 | * \param pDst reference to pointer for the prediction sample array |
---|
844 | * \param iDstStride the stride of the prediction sample array |
---|
845 | * \param iWidth the width of the block |
---|
846 | * \param iHeight the height of the block |
---|
847 | * \param channelType type of pel array (luma, chroma) |
---|
848 | * |
---|
849 | * This function performs filtering left and top edges of the prediction samples for DC mode (intra coding). |
---|
850 | */ |
---|
851 | Void TComPrediction::xDCPredFiltering( const Pel* pSrc, Int iSrcStride, Pel* pDst, Int iDstStride, Int iWidth, Int iHeight, ChannelType channelType ) |
---|
852 | { |
---|
853 | Int x, y, iDstStride2, iSrcStride2; |
---|
854 | |
---|
855 | if (isLuma(channelType) && (iWidth <= MAXIMUM_INTRA_FILTERED_WIDTH) && (iHeight <= MAXIMUM_INTRA_FILTERED_HEIGHT)) |
---|
856 | { |
---|
857 | //top-left |
---|
858 | pDst[0] = (Pel)((pSrc[-iSrcStride] + pSrc[-1] + 2 * pDst[0] + 2) >> 2); |
---|
859 | |
---|
860 | //top row (vertical filter) |
---|
861 | for ( x = 1; x < iWidth; x++ ) |
---|
862 | { |
---|
863 | pDst[x] = (Pel)((pSrc[x - iSrcStride] + 3 * pDst[x] + 2) >> 2); |
---|
864 | } |
---|
865 | |
---|
866 | //left column (horizontal filter) |
---|
867 | for ( y = 1, iDstStride2 = iDstStride, iSrcStride2 = iSrcStride-1; y < iHeight; y++, iDstStride2+=iDstStride, iSrcStride2+=iSrcStride ) |
---|
868 | { |
---|
869 | pDst[iDstStride2] = (Pel)((pSrc[iSrcStride2] + 3 * pDst[iDstStride2] + 2) >> 2); |
---|
870 | } |
---|
871 | } |
---|
872 | |
---|
873 | return; |
---|
874 | } |
---|
875 | |
---|
876 | /* Static member function */ |
---|
877 | Bool TComPrediction::UseDPCMForFirstPassIntraEstimation(TComTU &rTu, const UInt uiDirMode) |
---|
878 | { |
---|
879 | return (rTu.getCU()->isRDPCMEnabled(rTu.GetAbsPartIdxTU()) ) && |
---|
880 | rTu.getCU()->getCUTransquantBypass(rTu.GetAbsPartIdxTU()) && |
---|
881 | (uiDirMode==HOR_IDX || uiDirMode==VER_IDX); |
---|
882 | } |
---|
883 | |
---|
884 | #if SVC_EXTENSION |
---|
885 | Void TComPrediction::upsampleBasePic( TComSlice* currSlice, UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Int refBitDepthLuma, const Int refBitDepthChroma ) |
---|
886 | { |
---|
887 | m_cUsf.upsampleBasePic( currSlice, refLayerIdc, pcUsPic, pcBasePic, pcTempPic, refBitDepthLuma, refBitDepthChroma ); |
---|
888 | } |
---|
889 | #endif //SVC_EXTENSION |
---|
890 | //! \} |
---|