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) |
---|
184 | { |
---|
185 | assert(iWidth > 0 && iHeight > 0); |
---|
186 | Int iInd, iSum = 0; |
---|
187 | Pel pDcVal; |
---|
188 | |
---|
189 | for (iInd = 0;iInd < iWidth;iInd++) |
---|
190 | { |
---|
191 | iSum += pSrc[iInd-iSrcStride]; |
---|
192 | } |
---|
193 | for (iInd = 0;iInd < iHeight;iInd++) |
---|
194 | { |
---|
195 | iSum += pSrc[iInd*iSrcStride-1]; |
---|
196 | } |
---|
197 | |
---|
198 | pDcVal = (iSum + iWidth) / (iWidth + iHeight); |
---|
199 | |
---|
200 | return pDcVal; |
---|
201 | } |
---|
202 | |
---|
203 | // Function for deriving the angular Intra predictions |
---|
204 | |
---|
205 | /** Function for deriving the simplified angular intra predictions. |
---|
206 | * \param bitDepth bit depth |
---|
207 | * \param pSrc pointer to reconstructed sample array |
---|
208 | * \param srcStride the stride of the reconstructed sample array |
---|
209 | * \param pTrueDst reference to pointer for the prediction sample array |
---|
210 | * \param dstStrideTrue the stride of the prediction sample array |
---|
211 | * \param uiWidth the width of the block |
---|
212 | * \param uiHeight the height of the block |
---|
213 | * \param channelType type of pel array (luma/chroma) |
---|
214 | * \param format chroma format |
---|
215 | * \param dirMode the intra prediction mode index |
---|
216 | * \param blkAboveAvailable boolean indication if the block above is available |
---|
217 | * \param blkLeftAvailable boolean indication if the block to the left is available |
---|
218 | * \param bEnableEdgeFilters indication whether to enable edge filters |
---|
219 | * |
---|
220 | * This function derives the prediction samples for the angular mode based on the prediction direction indicated by |
---|
221 | * the prediction mode index. The prediction direction is given by the displacement of the bottom row of the block and |
---|
222 | * the reference row above the block in the case of vertical prediction or displacement of the rightmost column |
---|
223 | * of the block and reference column left from the block in the case of the horizontal prediction. The displacement |
---|
224 | * is signalled at 1/32 pixel accuracy. When projection of the predicted pixel falls inbetween reference samples, |
---|
225 | * the predicted value for the pixel is linearly interpolated from the reference samples. All reference samples are taken |
---|
226 | * from the extended main reference. |
---|
227 | */ |
---|
228 | //NOTE: Bit-Limit - 25-bit source |
---|
229 | Void TComPrediction::xPredIntraAng( Int bitDepth, |
---|
230 | const Pel* pSrc, Int srcStride, |
---|
231 | Pel* pTrueDst, Int dstStrideTrue, |
---|
232 | UInt uiWidth, UInt uiHeight, ChannelType channelType, |
---|
233 | UInt dirMode, const Bool bEnableEdgeFilters |
---|
234 | ) |
---|
235 | { |
---|
236 | Int width=Int(uiWidth); |
---|
237 | Int height=Int(uiHeight); |
---|
238 | |
---|
239 | // Map the mode index to main prediction direction and angle |
---|
240 | assert( dirMode != PLANAR_IDX ); //no planar |
---|
241 | const Bool modeDC = dirMode==DC_IDX; |
---|
242 | |
---|
243 | // Do the DC prediction |
---|
244 | if (modeDC) |
---|
245 | { |
---|
246 | const Pel dcval = predIntraGetPredValDC(pSrc, srcStride, width, height); |
---|
247 | |
---|
248 | for (Int y=height;y>0;y--, pTrueDst+=dstStrideTrue) |
---|
249 | { |
---|
250 | for (Int x=0; x<width;) // width is always a multiple of 4. |
---|
251 | { |
---|
252 | pTrueDst[x++] = dcval; |
---|
253 | } |
---|
254 | } |
---|
255 | } |
---|
256 | else // Do angular predictions |
---|
257 | { |
---|
258 | const Bool bIsModeVer = (dirMode >= 18); |
---|
259 | const Int intraPredAngleMode = (bIsModeVer) ? (Int)dirMode - VER_IDX : -((Int)dirMode - HOR_IDX); |
---|
260 | const Int absAngMode = abs(intraPredAngleMode); |
---|
261 | const Int signAng = intraPredAngleMode < 0 ? -1 : 1; |
---|
262 | const Bool edgeFilter = bEnableEdgeFilters && isLuma(channelType) && (width <= MAXIMUM_INTRA_FILTERED_WIDTH) && (height <= MAXIMUM_INTRA_FILTERED_HEIGHT); |
---|
263 | |
---|
264 | // Set bitshifts and scale the angle parameter to block size |
---|
265 | static const Int angTable[9] = {0, 2, 5, 9, 13, 17, 21, 26, 32}; |
---|
266 | static const Int invAngTable[9] = {0, 4096, 1638, 910, 630, 482, 390, 315, 256}; // (256 * 32) / Angle |
---|
267 | Int invAngle = invAngTable[absAngMode]; |
---|
268 | Int absAng = angTable[absAngMode]; |
---|
269 | Int intraPredAngle = signAng * absAng; |
---|
270 | |
---|
271 | Pel* refMain; |
---|
272 | Pel* refSide; |
---|
273 | |
---|
274 | Pel refAbove[2*MAX_CU_SIZE+1]; |
---|
275 | Pel refLeft[2*MAX_CU_SIZE+1]; |
---|
276 | |
---|
277 | // Initialize the Main and Left reference array. |
---|
278 | if (intraPredAngle < 0) |
---|
279 | { |
---|
280 | const Int refMainOffsetPreScale = (bIsModeVer ? height : width ) - 1; |
---|
281 | const Int refMainOffset = height - 1; |
---|
282 | for (Int x=0;x<width+1;x++) |
---|
283 | { |
---|
284 | refAbove[x+refMainOffset] = pSrc[x-srcStride-1]; |
---|
285 | } |
---|
286 | for (Int y=0;y<height+1;y++) |
---|
287 | { |
---|
288 | refLeft[y+refMainOffset] = pSrc[(y-1)*srcStride-1]; |
---|
289 | } |
---|
290 | refMain = (bIsModeVer ? refAbove : refLeft) + refMainOffset; |
---|
291 | refSide = (bIsModeVer ? refLeft : refAbove) + refMainOffset; |
---|
292 | |
---|
293 | // Extend the Main reference to the left. |
---|
294 | Int invAngleSum = 128; // rounding for (shift by 8) |
---|
295 | for (Int k=-1; k>(refMainOffsetPreScale+1)*intraPredAngle>>5; k--) |
---|
296 | { |
---|
297 | invAngleSum += invAngle; |
---|
298 | refMain[k] = refSide[invAngleSum>>8]; |
---|
299 | } |
---|
300 | } |
---|
301 | else |
---|
302 | { |
---|
303 | for (Int x=0;x<2*width+1;x++) |
---|
304 | { |
---|
305 | refAbove[x] = pSrc[x-srcStride-1]; |
---|
306 | } |
---|
307 | for (Int y=0;y<2*height+1;y++) |
---|
308 | { |
---|
309 | refLeft[y] = pSrc[(y-1)*srcStride-1]; |
---|
310 | } |
---|
311 | refMain = bIsModeVer ? refAbove : refLeft ; |
---|
312 | refSide = bIsModeVer ? refLeft : refAbove; |
---|
313 | } |
---|
314 | |
---|
315 | // swap width/height if we are doing a horizontal mode: |
---|
316 | Pel tempArray[MAX_CU_SIZE*MAX_CU_SIZE]; |
---|
317 | const Int dstStride = bIsModeVer ? dstStrideTrue : MAX_CU_SIZE; |
---|
318 | Pel *pDst = bIsModeVer ? pTrueDst : tempArray; |
---|
319 | if (!bIsModeVer) |
---|
320 | { |
---|
321 | std::swap(width, height); |
---|
322 | } |
---|
323 | |
---|
324 | if (intraPredAngle == 0) // pure vertical or pure horizontal |
---|
325 | { |
---|
326 | for (Int y=0;y<height;y++) |
---|
327 | { |
---|
328 | for (Int x=0;x<width;x++) |
---|
329 | { |
---|
330 | pDst[y*dstStride+x] = refMain[x+1]; |
---|
331 | } |
---|
332 | } |
---|
333 | |
---|
334 | if (edgeFilter) |
---|
335 | { |
---|
336 | for (Int y=0;y<height;y++) |
---|
337 | { |
---|
338 | pDst[y*dstStride] = Clip3 (0, ((1 << bitDepth) - 1), pDst[y*dstStride] + (( refSide[y+1] - refSide[0] ) >> 1) ); |
---|
339 | } |
---|
340 | } |
---|
341 | } |
---|
342 | else |
---|
343 | { |
---|
344 | Pel *pDsty=pDst; |
---|
345 | |
---|
346 | for (Int y=0, deltaPos=intraPredAngle; y<height; y++, deltaPos+=intraPredAngle, pDsty+=dstStride) |
---|
347 | { |
---|
348 | const Int deltaInt = deltaPos >> 5; |
---|
349 | const Int deltaFract = deltaPos & (32 - 1); |
---|
350 | |
---|
351 | if (deltaFract) |
---|
352 | { |
---|
353 | // Do linear filtering |
---|
354 | const Pel *pRM=refMain+deltaInt+1; |
---|
355 | Int lastRefMainPel=*pRM++; |
---|
356 | for (Int x=0;x<width;pRM++,x++) |
---|
357 | { |
---|
358 | Int thisRefMainPel=*pRM; |
---|
359 | pDsty[x+0] = (Pel) ( ((32-deltaFract)*lastRefMainPel + deltaFract*thisRefMainPel +16) >> 5 ); |
---|
360 | lastRefMainPel=thisRefMainPel; |
---|
361 | } |
---|
362 | } |
---|
363 | else |
---|
364 | { |
---|
365 | // Just copy the integer samples |
---|
366 | for (Int x=0;x<width; x++) |
---|
367 | { |
---|
368 | pDsty[x] = refMain[x+deltaInt+1]; |
---|
369 | } |
---|
370 | } |
---|
371 | } |
---|
372 | } |
---|
373 | |
---|
374 | // Flip the block if this is the horizontal mode |
---|
375 | if (!bIsModeVer) |
---|
376 | { |
---|
377 | for (Int y=0; y<height; y++) |
---|
378 | { |
---|
379 | for (Int x=0; x<width; x++) |
---|
380 | { |
---|
381 | pTrueDst[x*dstStrideTrue] = pDst[x]; |
---|
382 | } |
---|
383 | pTrueDst++; |
---|
384 | pDst+=dstStride; |
---|
385 | } |
---|
386 | } |
---|
387 | } |
---|
388 | } |
---|
389 | |
---|
390 | Void TComPrediction::predIntraAng( const ComponentID compID, UInt uiDirMode, Pel* piOrg /* Will be null for decoding */, UInt uiOrgStride, Pel* piPred, UInt uiStride, TComTU &rTu, const Bool bUseFilteredPredSamples, const Bool bUseLosslessDPCM ) |
---|
391 | { |
---|
392 | const ChannelType channelType = toChannelType(compID); |
---|
393 | const TComRectangle &rect = rTu.getRect(isLuma(compID) ? COMPONENT_Y : COMPONENT_Cb); |
---|
394 | const Int iWidth = rect.width; |
---|
395 | const Int iHeight = rect.height; |
---|
396 | |
---|
397 | assert( g_aucConvertToBit[ iWidth ] >= 0 ); // 4x 4 |
---|
398 | assert( g_aucConvertToBit[ iWidth ] <= 5 ); // 128x128 |
---|
399 | //assert( iWidth == iHeight ); |
---|
400 | |
---|
401 | Pel *pDst = piPred; |
---|
402 | |
---|
403 | // get starting pixel in block |
---|
404 | const Int sw = (2 * iWidth + 1); |
---|
405 | |
---|
406 | if ( bUseLosslessDPCM ) |
---|
407 | { |
---|
408 | const Pel *ptrSrc = getPredictorPtr( compID, false ); |
---|
409 | // Sample Adaptive intra-Prediction (SAP) |
---|
410 | if (uiDirMode==HOR_IDX) |
---|
411 | { |
---|
412 | // left column filled with reference samples |
---|
413 | // remaining columns filled with piOrg data (if available). |
---|
414 | for(Int y=0; y<iHeight; y++) |
---|
415 | { |
---|
416 | piPred[y*uiStride+0] = ptrSrc[(y+1)*sw]; |
---|
417 | } |
---|
418 | if (piOrg!=0) |
---|
419 | { |
---|
420 | piPred+=1; // miss off first column |
---|
421 | for(Int y=0; y<iHeight; y++, piPred+=uiStride, piOrg+=uiOrgStride) |
---|
422 | { |
---|
423 | memcpy(piPred, piOrg, (iWidth-1)*sizeof(Pel)); |
---|
424 | } |
---|
425 | } |
---|
426 | } |
---|
427 | else // VER_IDX |
---|
428 | { |
---|
429 | // top row filled with reference samples |
---|
430 | // remaining rows filled with piOrd data (if available) |
---|
431 | for(Int x=0; x<iWidth; x++) |
---|
432 | { |
---|
433 | piPred[x] = ptrSrc[x+1]; |
---|
434 | } |
---|
435 | if (piOrg!=0) |
---|
436 | { |
---|
437 | piPred+=uiStride; // miss off the first row |
---|
438 | for(Int y=1; y<iHeight; y++, piPred+=uiStride, piOrg+=uiOrgStride) |
---|
439 | { |
---|
440 | memcpy(piPred, piOrg, iWidth*sizeof(Pel)); |
---|
441 | } |
---|
442 | } |
---|
443 | } |
---|
444 | } |
---|
445 | else |
---|
446 | { |
---|
447 | const Pel *ptrSrc = getPredictorPtr( compID, bUseFilteredPredSamples ); |
---|
448 | |
---|
449 | if ( uiDirMode == PLANAR_IDX ) |
---|
450 | { |
---|
451 | xPredIntraPlanar( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight ); |
---|
452 | } |
---|
453 | else |
---|
454 | { |
---|
455 | // Create the prediction |
---|
456 | TComDataCU *const pcCU = rTu.getCU(); |
---|
457 | const UInt uiAbsPartIdx = rTu.GetAbsPartIdxTU(); |
---|
458 | const Bool enableEdgeFilters = !(pcCU->isRDPCMEnabled(uiAbsPartIdx) && pcCU->getCUTransquantBypass(uiAbsPartIdx)); |
---|
459 | #if O0043_BEST_EFFORT_DECODING |
---|
460 | const Int channelsBitDepthForPrediction = rTu.getCU()->getSlice()->getSPS()->getStreamBitDepth(channelType); |
---|
461 | #else |
---|
462 | #if SVC_EXTENSION |
---|
463 | const Int channelsBitDepthForPrediction = rTu.getCU()->getSlice()->getBitDepth(channelType); |
---|
464 | #else |
---|
465 | const Int channelsBitDepthForPrediction = rTu.getCU()->getSlice()->getSPS()->getBitDepth(channelType); |
---|
466 | #endif |
---|
467 | #endif |
---|
468 | xPredIntraAng( channelsBitDepthForPrediction, ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, channelType, uiDirMode, enableEdgeFilters ); |
---|
469 | |
---|
470 | if( uiDirMode == DC_IDX ) |
---|
471 | { |
---|
472 | xDCPredFiltering( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, channelType ); |
---|
473 | } |
---|
474 | } |
---|
475 | } |
---|
476 | |
---|
477 | } |
---|
478 | |
---|
479 | /** Check for identical motion in both motion vector direction of a bi-directional predicted CU |
---|
480 | * \returns true, if motion vectors and reference pictures match |
---|
481 | */ |
---|
482 | Bool TComPrediction::xCheckIdenticalMotion ( TComDataCU* pcCU, UInt PartAddr ) |
---|
483 | { |
---|
484 | if( pcCU->getSlice()->isInterB() && !pcCU->getSlice()->getPPS()->getWPBiPred() ) |
---|
485 | { |
---|
486 | if( pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr) >= 0 && pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr) >= 0) |
---|
487 | { |
---|
488 | Int RefPOCL0 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_0, pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr))->getPOC(); |
---|
489 | Int RefPOCL1 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_1, pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr))->getPOC(); |
---|
490 | #if SVC_EXTENSION |
---|
491 | Int layerIdL0 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_0, pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr))->getLayerId(); |
---|
492 | Int layerIdL1 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_1, pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr))->getLayerId(); |
---|
493 | |
---|
494 | if( layerIdL0 == layerIdL1 && RefPOCL0 == RefPOCL1 && pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr) == pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr) ) |
---|
495 | #else |
---|
496 | if(RefPOCL0 == RefPOCL1 && pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr) == pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr)) |
---|
497 | #endif |
---|
498 | { |
---|
499 | return true; |
---|
500 | } |
---|
501 | } |
---|
502 | } |
---|
503 | return false; |
---|
504 | } |
---|
505 | |
---|
506 | Void TComPrediction::motionCompensation ( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx ) |
---|
507 | { |
---|
508 | Int iWidth; |
---|
509 | Int iHeight; |
---|
510 | UInt uiPartAddr; |
---|
511 | const TComSlice *pSlice = pcCU->getSlice(); |
---|
512 | const SliceType sliceType = pSlice->getSliceType(); |
---|
513 | const TComPPS &pps = *(pSlice->getPPS()); |
---|
514 | |
---|
515 | if ( iPartIdx >= 0 ) |
---|
516 | { |
---|
517 | pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight ); |
---|
518 | if ( eRefPicList != REF_PIC_LIST_X ) |
---|
519 | { |
---|
520 | if( (sliceType == P_SLICE && pps.getUseWP()) || (sliceType == B_SLICE && pps.getWPBiPred())) |
---|
521 | { |
---|
522 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true ); |
---|
523 | xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); |
---|
524 | } |
---|
525 | else |
---|
526 | { |
---|
527 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); |
---|
528 | } |
---|
529 | } |
---|
530 | else |
---|
531 | { |
---|
532 | if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) ) |
---|
533 | { |
---|
534 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred ); |
---|
535 | } |
---|
536 | else |
---|
537 | { |
---|
538 | xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred ); |
---|
539 | } |
---|
540 | } |
---|
541 | return; |
---|
542 | } |
---|
543 | |
---|
544 | for ( iPartIdx = 0; iPartIdx < pcCU->getNumPartitions(); iPartIdx++ ) |
---|
545 | { |
---|
546 | pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight ); |
---|
547 | |
---|
548 | if ( eRefPicList != REF_PIC_LIST_X ) |
---|
549 | { |
---|
550 | if( (sliceType == P_SLICE && pps.getUseWP()) || (sliceType == B_SLICE && pps.getWPBiPred())) |
---|
551 | { |
---|
552 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true ); |
---|
553 | xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); |
---|
554 | } |
---|
555 | else |
---|
556 | { |
---|
557 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); |
---|
558 | } |
---|
559 | } |
---|
560 | else |
---|
561 | { |
---|
562 | if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) ) |
---|
563 | { |
---|
564 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred ); |
---|
565 | } |
---|
566 | else |
---|
567 | { |
---|
568 | xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred ); |
---|
569 | } |
---|
570 | } |
---|
571 | } |
---|
572 | return; |
---|
573 | } |
---|
574 | |
---|
575 | Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv* pcYuvPred, Bool bi ) |
---|
576 | { |
---|
577 | Int iRefIdx = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); assert (iRefIdx >= 0); |
---|
578 | TComMv cMv = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr ); |
---|
579 | pcCU->clipMv(cMv); |
---|
580 | |
---|
581 | #if SVC_EXTENSION |
---|
582 | if( pcCU->getPic()->getLayerId() > 0 ) |
---|
583 | { |
---|
584 | TComPic* refPic = pcCU->getSlice()->getRefPic(eRefPicList, iRefIdx); |
---|
585 | |
---|
586 | if( refPic->isILR(pcCU->getPic()->getLayerId()) ) |
---|
587 | { |
---|
588 | // It is a requirement of bitstream conformance that when the reference picture represented by the variable refIdxLX is an inter-layer reference picture, |
---|
589 | // VpsInterLayerSamplePredictionEnabled[ LayerIdxInVps[ currLayerId ] ][ LayerIdxInVps[ rLId ] ] shall be equal to 1, where rLId is set equal to nuh_layer_id of the inter-layer picture |
---|
590 | assert( pcCU->getSlice()->getVPS()->isSamplePredictionType( pcCU->getPic()->getLayerIdx(), refPic->getLayerIdx() ) ); |
---|
591 | |
---|
592 | #if REF_IDX_ME_ZEROMV |
---|
593 | // 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. |
---|
594 | if( pcCU->getSlice()->getVPS()->getScalabilityMask( SCALABILITY_ID ) ) |
---|
595 | { |
---|
596 | assert( cMv.getHor() == 0 && cMv.getVer() == 0 ); |
---|
597 | } |
---|
598 | #endif |
---|
599 | } |
---|
600 | |
---|
601 | } |
---|
602 | #endif |
---|
603 | |
---|
604 | for (UInt comp=COMPONENT_Y; comp<pcYuvPred->getNumberValidComponents(); comp++) |
---|
605 | { |
---|
606 | const ComponentID compID=ComponentID(comp); |
---|
607 | #if SVC_EXTENSION |
---|
608 | xPredInterBlk (compID, pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, pcYuvPred, bi, pcCU->getSlice()->getBitDepth(toChannelType(compID)) ); |
---|
609 | #else |
---|
610 | xPredInterBlk (compID, pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, pcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)) ); |
---|
611 | #endif |
---|
612 | } |
---|
613 | } |
---|
614 | |
---|
615 | Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv* pcYuvPred ) |
---|
616 | { |
---|
617 | TComYuv* pcMbYuv; |
---|
618 | Int iRefIdx[NUM_REF_PIC_LIST_01] = {-1, -1}; |
---|
619 | |
---|
620 | for ( UInt refList = 0; refList < NUM_REF_PIC_LIST_01; refList++ ) |
---|
621 | { |
---|
622 | RefPicList eRefPicList = (refList ? REF_PIC_LIST_1 : REF_PIC_LIST_0); |
---|
623 | iRefIdx[refList] = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
624 | |
---|
625 | if ( iRefIdx[refList] < 0 ) |
---|
626 | { |
---|
627 | continue; |
---|
628 | } |
---|
629 | |
---|
630 | assert( iRefIdx[refList] < pcCU->getSlice()->getNumRefIdx(eRefPicList) ); |
---|
631 | |
---|
632 | pcMbYuv = &m_acYuvPred[refList]; |
---|
633 | if( pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr ) >= 0 && pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr ) >= 0 ) |
---|
634 | { |
---|
635 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, true ); |
---|
636 | } |
---|
637 | else |
---|
638 | { |
---|
639 | if ( ( pcCU->getSlice()->getPPS()->getUseWP() && pcCU->getSlice()->getSliceType() == P_SLICE ) || |
---|
640 | ( pcCU->getSlice()->getPPS()->getWPBiPred() && pcCU->getSlice()->getSliceType() == B_SLICE ) ) |
---|
641 | { |
---|
642 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, true ); |
---|
643 | } |
---|
644 | else |
---|
645 | { |
---|
646 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv ); |
---|
647 | } |
---|
648 | } |
---|
649 | } |
---|
650 | |
---|
651 | if ( pcCU->getSlice()->getPPS()->getWPBiPred() && pcCU->getSlice()->getSliceType() == B_SLICE ) |
---|
652 | { |
---|
653 | 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 ); |
---|
654 | } |
---|
655 | else if ( pcCU->getSlice()->getPPS()->getUseWP() && pcCU->getSlice()->getSliceType() == P_SLICE ) |
---|
656 | { |
---|
657 | xWeightedPredictionUni( pcCU, &m_acYuvPred[REF_PIC_LIST_0], uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred ); |
---|
658 | } |
---|
659 | else |
---|
660 | { |
---|
661 | #if SVC_EXTENSION |
---|
662 | 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() ); |
---|
663 | #else |
---|
664 | 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() ); |
---|
665 | #endif |
---|
666 | } |
---|
667 | } |
---|
668 | |
---|
669 | /** |
---|
670 | * \brief Generate motion-compensated block |
---|
671 | * |
---|
672 | * \param compID Colour component ID |
---|
673 | * \param cu Pointer to current CU |
---|
674 | * \param refPic Pointer to reference picture |
---|
675 | * \param partAddr Address of block within CU |
---|
676 | * \param mv Motion vector |
---|
677 | * \param width Width of block |
---|
678 | * \param height Height of block |
---|
679 | * \param dstPic Pointer to destination picture |
---|
680 | * \param bi Flag indicating whether bipred is used |
---|
681 | * \param bitDepth Bit depth |
---|
682 | */ |
---|
683 | |
---|
684 | |
---|
685 | 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 ) |
---|
686 | { |
---|
687 | Int refStride = refPic->getStride(compID); |
---|
688 | Int dstStride = dstPic->getStride(compID); |
---|
689 | Int shiftHor=(2+refPic->getComponentScaleX(compID)); |
---|
690 | Int shiftVer=(2+refPic->getComponentScaleY(compID)); |
---|
691 | |
---|
692 | Int refOffset = (mv->getHor() >> shiftHor) + (mv->getVer() >> shiftVer) * refStride; |
---|
693 | |
---|
694 | Pel* ref = refPic->getAddr(compID, cu->getCtuRsAddr(), cu->getZorderIdxInCtu() + partAddr ) + refOffset; |
---|
695 | |
---|
696 | Pel* dst = dstPic->getAddr( compID, partAddr ); |
---|
697 | |
---|
698 | Int xFrac = mv->getHor() & ((1<<shiftHor)-1); |
---|
699 | Int yFrac = mv->getVer() & ((1<<shiftVer)-1); |
---|
700 | UInt cxWidth = width >> refPic->getComponentScaleX(compID); |
---|
701 | UInt cxHeight = height >> refPic->getComponentScaleY(compID); |
---|
702 | |
---|
703 | const ChromaFormat chFmt = cu->getPic()->getChromaFormat(); |
---|
704 | |
---|
705 | if ( yFrac == 0 ) |
---|
706 | { |
---|
707 | m_if.filterHor(compID, ref, refStride, dst, dstStride, cxWidth, cxHeight, xFrac, !bi, chFmt, bitDepth); |
---|
708 | } |
---|
709 | else if ( xFrac == 0 ) |
---|
710 | { |
---|
711 | m_if.filterVer(compID, ref, refStride, dst, dstStride, cxWidth, cxHeight, yFrac, true, !bi, chFmt, bitDepth); |
---|
712 | } |
---|
713 | else |
---|
714 | { |
---|
715 | Int tmpStride = m_filteredBlockTmp[0].getStride(compID); |
---|
716 | Pel* tmp = m_filteredBlockTmp[0].getAddr(compID); |
---|
717 | |
---|
718 | const Int vFilterSize = isLuma(compID) ? NTAPS_LUMA : NTAPS_CHROMA; |
---|
719 | |
---|
720 | m_if.filterHor(compID, ref - ((vFilterSize>>1) -1)*refStride, refStride, tmp, tmpStride, cxWidth, cxHeight+vFilterSize-1, xFrac, false, chFmt, bitDepth); |
---|
721 | m_if.filterVer(compID, tmp + ((vFilterSize>>1) -1)*tmpStride, tmpStride, dst, dstStride, cxWidth, cxHeight, yFrac, false, !bi, chFmt, bitDepth); |
---|
722 | } |
---|
723 | } |
---|
724 | |
---|
725 | Void TComPrediction::xWeightedAverage( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv* pcYuvDst, const BitDepths &clipBitDepths ) |
---|
726 | { |
---|
727 | if( iRefIdx0 >= 0 && iRefIdx1 >= 0 ) |
---|
728 | { |
---|
729 | pcYuvDst->addAvg( pcYuvSrc0, pcYuvSrc1, uiPartIdx, iWidth, iHeight, clipBitDepths ); |
---|
730 | } |
---|
731 | else if ( iRefIdx0 >= 0 && iRefIdx1 < 0 ) |
---|
732 | { |
---|
733 | pcYuvSrc0->copyPartToPartYuv( pcYuvDst, uiPartIdx, iWidth, iHeight ); |
---|
734 | } |
---|
735 | else if ( iRefIdx0 < 0 && iRefIdx1 >= 0 ) |
---|
736 | { |
---|
737 | pcYuvSrc1->copyPartToPartYuv( pcYuvDst, uiPartIdx, iWidth, iHeight ); |
---|
738 | } |
---|
739 | } |
---|
740 | |
---|
741 | // AMVP |
---|
742 | Void TComPrediction::getMvPredAMVP( TComDataCU* pcCU, UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, TComMv& rcMvPred ) |
---|
743 | { |
---|
744 | AMVPInfo* pcAMVPInfo = pcCU->getCUMvField(eRefPicList)->getAMVPInfo(); |
---|
745 | |
---|
746 | if( pcAMVPInfo->iN <= 1 ) |
---|
747 | { |
---|
748 | rcMvPred = pcAMVPInfo->m_acMvCand[0]; |
---|
749 | |
---|
750 | pcCU->setMVPIdxSubParts( 0, eRefPicList, uiPartAddr, uiPartIdx, pcCU->getDepth(uiPartAddr)); |
---|
751 | pcCU->setMVPNumSubParts( pcAMVPInfo->iN, eRefPicList, uiPartAddr, uiPartIdx, pcCU->getDepth(uiPartAddr)); |
---|
752 | return; |
---|
753 | } |
---|
754 | |
---|
755 | assert(pcCU->getMVPIdx(eRefPicList,uiPartAddr) >= 0); |
---|
756 | rcMvPred = pcAMVPInfo->m_acMvCand[pcCU->getMVPIdx(eRefPicList,uiPartAddr)]; |
---|
757 | return; |
---|
758 | } |
---|
759 | |
---|
760 | /** Function for deriving planar intra prediction. |
---|
761 | * \param pSrc pointer to reconstructed sample array |
---|
762 | * \param srcStride the stride of the reconstructed sample array |
---|
763 | * \param rpDst reference to pointer for the prediction sample array |
---|
764 | * \param dstStride the stride of the prediction sample array |
---|
765 | * \param width the width of the block |
---|
766 | * \param height the height of the block |
---|
767 | * \param channelType type of pel array (luma, chroma) |
---|
768 | * \param format chroma format |
---|
769 | * |
---|
770 | * This function derives the prediction samples for planar mode (intra coding). |
---|
771 | */ |
---|
772 | //NOTE: Bit-Limit - 24-bit source |
---|
773 | Void TComPrediction::xPredIntraPlanar( const Pel* pSrc, Int srcStride, Pel* rpDst, Int dstStride, UInt width, UInt height ) |
---|
774 | { |
---|
775 | assert(width <= height); |
---|
776 | |
---|
777 | Int leftColumn[MAX_CU_SIZE+1], topRow[MAX_CU_SIZE+1], bottomRow[MAX_CU_SIZE], rightColumn[MAX_CU_SIZE]; |
---|
778 | UInt shift1Dhor = g_aucConvertToBit[ width ] + 2; |
---|
779 | UInt shift1Dver = g_aucConvertToBit[ height ] + 2; |
---|
780 | |
---|
781 | // Get left and above reference column and row |
---|
782 | for(Int k=0;k<width+1;k++) |
---|
783 | { |
---|
784 | topRow[k] = pSrc[k-srcStride]; |
---|
785 | } |
---|
786 | |
---|
787 | for (Int k=0; k < height+1; k++) |
---|
788 | { |
---|
789 | leftColumn[k] = pSrc[k*srcStride-1]; |
---|
790 | } |
---|
791 | |
---|
792 | // Prepare intermediate variables used in interpolation |
---|
793 | Int bottomLeft = leftColumn[height]; |
---|
794 | Int topRight = topRow[width]; |
---|
795 | |
---|
796 | for(Int k=0;k<width;k++) |
---|
797 | { |
---|
798 | bottomRow[k] = bottomLeft - topRow[k]; |
---|
799 | topRow[k] <<= shift1Dver; |
---|
800 | } |
---|
801 | |
---|
802 | for(Int k=0;k<height;k++) |
---|
803 | { |
---|
804 | rightColumn[k] = topRight - leftColumn[k]; |
---|
805 | leftColumn[k] <<= shift1Dhor; |
---|
806 | } |
---|
807 | |
---|
808 | const UInt topRowShift = 0; |
---|
809 | |
---|
810 | // Generate prediction signal |
---|
811 | for (Int y=0;y<height;y++) |
---|
812 | { |
---|
813 | Int horPred = leftColumn[y] + width; |
---|
814 | for (Int x=0;x<width;x++) |
---|
815 | { |
---|
816 | horPred += rightColumn[y]; |
---|
817 | topRow[x] += bottomRow[x]; |
---|
818 | |
---|
819 | Int vertPred = ((topRow[x] + topRowShift)>>topRowShift); |
---|
820 | rpDst[y*dstStride+x] = ( horPred + vertPred ) >> (shift1Dhor+1); |
---|
821 | } |
---|
822 | } |
---|
823 | } |
---|
824 | |
---|
825 | /** Function for filtering intra DC predictor. |
---|
826 | * \param pSrc pointer to reconstructed sample array |
---|
827 | * \param iSrcStride the stride of the reconstructed sample array |
---|
828 | * \param pDst reference to pointer for the prediction sample array |
---|
829 | * \param iDstStride the stride of the prediction sample array |
---|
830 | * \param iWidth the width of the block |
---|
831 | * \param iHeight the height of the block |
---|
832 | * \param channelType type of pel array (luma, chroma) |
---|
833 | * |
---|
834 | * This function performs filtering left and top edges of the prediction samples for DC mode (intra coding). |
---|
835 | */ |
---|
836 | Void TComPrediction::xDCPredFiltering( const Pel* pSrc, Int iSrcStride, Pel* pDst, Int iDstStride, Int iWidth, Int iHeight, ChannelType channelType ) |
---|
837 | { |
---|
838 | Int x, y, iDstStride2, iSrcStride2; |
---|
839 | |
---|
840 | if (isLuma(channelType) && (iWidth <= MAXIMUM_INTRA_FILTERED_WIDTH) && (iHeight <= MAXIMUM_INTRA_FILTERED_HEIGHT)) |
---|
841 | { |
---|
842 | //top-left |
---|
843 | pDst[0] = (Pel)((pSrc[-iSrcStride] + pSrc[-1] + 2 * pDst[0] + 2) >> 2); |
---|
844 | |
---|
845 | //top row (vertical filter) |
---|
846 | for ( x = 1; x < iWidth; x++ ) |
---|
847 | { |
---|
848 | pDst[x] = (Pel)((pSrc[x - iSrcStride] + 3 * pDst[x] + 2) >> 2); |
---|
849 | } |
---|
850 | |
---|
851 | //left column (horizontal filter) |
---|
852 | for ( y = 1, iDstStride2 = iDstStride, iSrcStride2 = iSrcStride-1; y < iHeight; y++, iDstStride2+=iDstStride, iSrcStride2+=iSrcStride ) |
---|
853 | { |
---|
854 | pDst[iDstStride2] = (Pel)((pSrc[iSrcStride2] + 3 * pDst[iDstStride2] + 2) >> 2); |
---|
855 | } |
---|
856 | } |
---|
857 | |
---|
858 | return; |
---|
859 | } |
---|
860 | |
---|
861 | /* Static member function */ |
---|
862 | Bool TComPrediction::UseDPCMForFirstPassIntraEstimation(TComTU &rTu, const UInt uiDirMode) |
---|
863 | { |
---|
864 | return (rTu.getCU()->isRDPCMEnabled(rTu.GetAbsPartIdxTU()) ) && |
---|
865 | rTu.getCU()->getCUTransquantBypass(rTu.GetAbsPartIdxTU()) && |
---|
866 | (uiDirMode==HOR_IDX || uiDirMode==VER_IDX); |
---|
867 | } |
---|
868 | |
---|
869 | #if SVC_EXTENSION |
---|
870 | Void TComPrediction::upsampleBasePic( TComSlice* currSlice, UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Int refBitDepthLuma, const Int refBitDepthChroma ) |
---|
871 | { |
---|
872 | m_cUsf.upsampleBasePic( currSlice, refLayerIdc, pcUsPic, pcBasePic, pcTempPic, refBitDepthLuma, refBitDepthChroma ); |
---|
873 | } |
---|
874 | #endif //SVC_EXTENSION |
---|
875 | //! \} |
---|