HEVC Test Model (HM)  HM-16.18
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TComPrediction.cpp
Go to the documentation of this file.
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-2017, 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 
38 #include <memory.h>
39 #include "TComPrediction.h"
40 #include "TComPic.h"
41 #include "TComTU.h"
42 
45 
46 // ====================================================================================================================
47 // Tables
48 // ====================================================================================================================
49 
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 
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 
87 {
88  destroy();
89 }
90 
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 
108 
109  if( m_pLumaRecBuffer )
110  {
111  delete [] m_pLumaRecBuffer;
112  m_pLumaRecBuffer = 0;
113  }
114  m_iLumaRecStride = 0;
115 
117  {
119  {
120  m_filteredBlock[i][j].destroy();
121  }
123  }
124 }
125 
127 {
128  // if it has been initialised before, but the chroma format has changed, release the memory and start again.
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 
140  {
141  m_filteredBlockTmp[i].create(extWidth, extHeight + 7, chromaFormatIDC);
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  {
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 
228 //NOTE: Bit-Limit - 25-bit source
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  const Int channelsBitDepthForPrediction = rTu.getCU()->getSlice()->getSPS()->getBitDepth(channelType);
463 #endif
464  xPredIntraAng( channelsBitDepthForPrediction, ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, channelType, uiDirMode, enableEdgeFilters );
465 
466  if( uiDirMode == DC_IDX )
467  {
468  xDCPredFiltering( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, channelType );
469  }
470  }
471  }
472 
473 }
474 
479 {
480  if( pcCU->getSlice()->isInterB() && !pcCU->getSlice()->getPPS()->getWPBiPred() )
481  {
482  if( pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr) >= 0 && pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr) >= 0)
483  {
484  Int RefPOCL0 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_0, pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr))->getPOC();
485  Int RefPOCL1 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_1, pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr))->getPOC();
486  if(RefPOCL0 == RefPOCL1 && pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr) == pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr))
487  {
488  return true;
489  }
490  }
491  }
492  return false;
493 }
494 
495 Void TComPrediction::motionCompensation ( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx )
496 {
497  Int iWidth;
498  Int iHeight;
499  UInt uiPartAddr;
500  const TComSlice *pSlice = pcCU->getSlice();
501  const SliceType sliceType = pSlice->getSliceType();
502  const TComPPS &pps = *(pSlice->getPPS());
503 
504  if ( iPartIdx >= 0 )
505  {
506  pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight );
507  if ( eRefPicList != REF_PIC_LIST_X )
508  {
509  if( (sliceType == P_SLICE && pps.getUseWP()) || (sliceType == B_SLICE && pps.getWPBiPred()))
510  {
511  xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true );
512  xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
513  }
514  else
515  {
516  xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
517  }
518  }
519  else
520  {
521  if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) )
522  {
523  xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred );
524  }
525  else
526  {
527  xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred );
528  }
529  }
530  return;
531  }
532 
533  for ( iPartIdx = 0; iPartIdx < pcCU->getNumPartitions(); iPartIdx++ )
534  {
535  pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight );
536 
537  if ( eRefPicList != REF_PIC_LIST_X )
538  {
539  if( (sliceType == P_SLICE && pps.getUseWP()) || (sliceType == B_SLICE && pps.getWPBiPred()))
540  {
541  xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true );
542  xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
543  }
544  else
545  {
546  xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
547  }
548  }
549  else
550  {
551  if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) )
552  {
553  xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred );
554  }
555  else
556  {
557  xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred );
558  }
559  }
560  }
561  return;
562 }
563 
564 Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv* pcYuvPred, Bool bi )
565 {
566  Int iRefIdx = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); assert (iRefIdx >= 0);
567  TComMv cMv = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr );
568  pcCU->clipMv(cMv);
569 
570  for (UInt comp=COMPONENT_Y; comp<pcYuvPred->getNumberValidComponents(); comp++)
571  {
572  const ComponentID compID=ComponentID(comp);
573  xPredInterBlk (compID, pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, pcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)) );
574  }
575 }
576 
577 Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv* pcYuvPred )
578 {
579  TComYuv* pcMbYuv;
580  Int iRefIdx[NUM_REF_PIC_LIST_01] = {-1, -1};
581 
582  for ( UInt refList = 0; refList < NUM_REF_PIC_LIST_01; refList++ )
583  {
584  RefPicList eRefPicList = (refList ? REF_PIC_LIST_1 : REF_PIC_LIST_0);
585  iRefIdx[refList] = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );
586 
587  if ( iRefIdx[refList] < 0 )
588  {
589  continue;
590  }
591 
592  assert( iRefIdx[refList] < pcCU->getSlice()->getNumRefIdx(eRefPicList) );
593 
594  pcMbYuv = &m_acYuvPred[refList];
595  if( pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr ) >= 0 && pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr ) >= 0 )
596  {
597  xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, true );
598  }
599  else
600  {
601  if ( ( pcCU->getSlice()->getPPS()->getUseWP() && pcCU->getSlice()->getSliceType() == P_SLICE ) ||
602  ( pcCU->getSlice()->getPPS()->getWPBiPred() && pcCU->getSlice()->getSliceType() == B_SLICE ) )
603  {
604  xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, true );
605  }
606  else
607  {
608  xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv );
609  }
610  }
611  }
612 
613  if ( pcCU->getSlice()->getPPS()->getWPBiPred() && pcCU->getSlice()->getSliceType() == B_SLICE )
614  {
615  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 );
616  }
617  else if ( pcCU->getSlice()->getPPS()->getUseWP() && pcCU->getSlice()->getSliceType() == P_SLICE )
618  {
619  xWeightedPredictionUni( pcCU, &m_acYuvPred[REF_PIC_LIST_0], uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred );
620  }
621  else
622  {
623  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() );
624  }
625 }
626 
643 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 )
644 {
645  Int refStride = refPic->getStride(compID);
646  Int dstStride = dstPic->getStride(compID);
647  Int shiftHor=(2+refPic->getComponentScaleX(compID));
648  Int shiftVer=(2+refPic->getComponentScaleY(compID));
649 
650  Int refOffset = (mv->getHor() >> shiftHor) + (mv->getVer() >> shiftVer) * refStride;
651 
652  Pel* ref = refPic->getAddr(compID, cu->getCtuRsAddr(), cu->getZorderIdxInCtu() + partAddr ) + refOffset;
653 
654  Pel* dst = dstPic->getAddr( compID, partAddr );
655 
656  Int xFrac = mv->getHor() & ((1<<shiftHor)-1);
657  Int yFrac = mv->getVer() & ((1<<shiftVer)-1);
658  UInt cxWidth = width >> refPic->getComponentScaleX(compID);
659  UInt cxHeight = height >> refPic->getComponentScaleY(compID);
660 
661  const ChromaFormat chFmt = cu->getPic()->getChromaFormat();
662 
663  if ( yFrac == 0 )
664  {
665  m_if.filterHor(compID, ref, refStride, dst, dstStride, cxWidth, cxHeight, xFrac, !bi, chFmt, bitDepth);
666  }
667  else if ( xFrac == 0 )
668  {
669  m_if.filterVer(compID, ref, refStride, dst, dstStride, cxWidth, cxHeight, yFrac, true, !bi, chFmt, bitDepth);
670  }
671  else
672  {
673  Int tmpStride = m_filteredBlockTmp[0].getStride(compID);
674  Pel* tmp = m_filteredBlockTmp[0].getAddr(compID);
675 
676  const Int vFilterSize = isLuma(compID) ? NTAPS_LUMA : NTAPS_CHROMA;
677 
678  m_if.filterHor(compID, ref - ((vFilterSize>>1) -1)*refStride, refStride, tmp, tmpStride, cxWidth, cxHeight+vFilterSize-1, xFrac, false, chFmt, bitDepth);
679  m_if.filterVer(compID, tmp + ((vFilterSize>>1) -1)*tmpStride, tmpStride, dst, dstStride, cxWidth, cxHeight, yFrac, false, !bi, chFmt, bitDepth);
680  }
681 }
682 
683 Void TComPrediction::xWeightedAverage( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv* pcYuvDst, const BitDepths &clipBitDepths )
684 {
685  if( iRefIdx0 >= 0 && iRefIdx1 >= 0 )
686  {
687  pcYuvDst->addAvg( pcYuvSrc0, pcYuvSrc1, uiPartIdx, iWidth, iHeight, clipBitDepths );
688  }
689  else if ( iRefIdx0 >= 0 && iRefIdx1 < 0 )
690  {
691  pcYuvSrc0->copyPartToPartYuv( pcYuvDst, uiPartIdx, iWidth, iHeight );
692  }
693  else if ( iRefIdx0 < 0 && iRefIdx1 >= 0 )
694  {
695  pcYuvSrc1->copyPartToPartYuv( pcYuvDst, uiPartIdx, iWidth, iHeight );
696  }
697 }
698 
699 // AMVP
700 Void TComPrediction::getMvPredAMVP( TComDataCU* pcCU, UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, TComMv& rcMvPred )
701 {
702  AMVPInfo* pcAMVPInfo = pcCU->getCUMvField(eRefPicList)->getAMVPInfo();
703 
704  if( pcAMVPInfo->iN <= 1 )
705  {
706  rcMvPred = pcAMVPInfo->m_acMvCand[0];
707 
708  pcCU->setMVPIdxSubParts( 0, eRefPicList, uiPartAddr, uiPartIdx, pcCU->getDepth(uiPartAddr));
709  pcCU->setMVPNumSubParts( pcAMVPInfo->iN, eRefPicList, uiPartAddr, uiPartIdx, pcCU->getDepth(uiPartAddr));
710  return;
711  }
712 
713  assert(pcCU->getMVPIdx(eRefPicList,uiPartAddr) >= 0);
714  rcMvPred = pcAMVPInfo->m_acMvCand[pcCU->getMVPIdx(eRefPicList,uiPartAddr)];
715  return;
716 }
717 
730 //NOTE: Bit-Limit - 24-bit source
731 Void TComPrediction::xPredIntraPlanar( const Pel* pSrc, Int srcStride, Pel* rpDst, Int dstStride, UInt width, UInt height )
732 {
733  assert(width <= height);
734 
735  Int leftColumn[MAX_CU_SIZE+1], topRow[MAX_CU_SIZE+1], bottomRow[MAX_CU_SIZE], rightColumn[MAX_CU_SIZE];
736  UInt shift1Dhor = g_aucConvertToBit[ width ] + 2;
737  UInt shift1Dver = g_aucConvertToBit[ height ] + 2;
738 
739  // Get left and above reference column and row
740  for(Int k=0;k<width+1;k++)
741  {
742  topRow[k] = pSrc[k-srcStride];
743  }
744 
745  for (Int k=0; k < height+1; k++)
746  {
747  leftColumn[k] = pSrc[k*srcStride-1];
748  }
749 
750  // Prepare intermediate variables used in interpolation
751  Int bottomLeft = leftColumn[height];
752  Int topRight = topRow[width];
753 
754  for(Int k=0;k<width;k++)
755  {
756  bottomRow[k] = bottomLeft - topRow[k];
757  topRow[k] <<= shift1Dver;
758  }
759 
760  for(Int k=0;k<height;k++)
761  {
762  rightColumn[k] = topRight - leftColumn[k];
763  leftColumn[k] <<= shift1Dhor;
764  }
765 
766  const UInt topRowShift = 0;
767 
768  // Generate prediction signal
769  for (Int y=0;y<height;y++)
770  {
771  Int horPred = leftColumn[y] + width;
772  for (Int x=0;x<width;x++)
773  {
774  horPred += rightColumn[y];
775  topRow[x] += bottomRow[x];
776 
777  Int vertPred = ((topRow[x] + topRowShift)>>topRowShift);
778  rpDst[y*dstStride+x] = ( horPred + vertPred ) >> (shift1Dhor+1);
779  }
780  }
781 }
782 
794 Void TComPrediction::xDCPredFiltering( const Pel* pSrc, Int iSrcStride, Pel* pDst, Int iDstStride, Int iWidth, Int iHeight, ChannelType channelType )
795 {
796  Int x, y, iDstStride2, iSrcStride2;
797 
798  if (isLuma(channelType) && (iWidth <= MAXIMUM_INTRA_FILTERED_WIDTH) && (iHeight <= MAXIMUM_INTRA_FILTERED_HEIGHT))
799  {
800  //top-left
801  pDst[0] = (Pel)((pSrc[-iSrcStride] + pSrc[-1] + 2 * pDst[0] + 2) >> 2);
802 
803  //top row (vertical filter)
804  for ( x = 1; x < iWidth; x++ )
805  {
806  pDst[x] = (Pel)((pSrc[x - iSrcStride] + 3 * pDst[x] + 2) >> 2);
807  }
808 
809  //left column (horizontal filter)
810  for ( y = 1, iDstStride2 = iDstStride, iSrcStride2 = iSrcStride-1; y < iHeight; y++, iDstStride2+=iDstStride, iSrcStride2+=iSrcStride )
811  {
812  pDst[iDstStride2] = (Pel)((pSrc[iSrcStride2] + 3 * pDst[iDstStride2] + 2) >> 2);
813  }
814  }
815 
816  return;
817 }
818 
819 /* Static member function */
821 {
822  return (rTu.getCU()->isRDPCMEnabled(rTu.GetAbsPartIdxTU()) ) &&
824  (uiDirMode==HOR_IDX || uiDirMode==VER_IDX);
825 }
826 
827 #if MCTS_ENC_CHECK
828 
829 Void getRefPUPartPos(TComDataCU* pcCU, TComMv& cMv, Int uiPartIdx, Int& ruiPredXLeft, Int& ruiPredYTop, Int& ruiPredXRight, Int& ruiPredYBottom, Int iWidth, Int iHeight)
830 {
831  ruiPredXLeft = pcCU->getCUPelX();
832  ruiPredYTop = pcCU->getCUPelY();
833 
834  switch (pcCU->getPartitionSize(0))
835  {
836  case SIZE_2NxN:
837  if (uiPartIdx == 0)
838  {
839  ruiPredXRight = ruiPredXLeft + iWidth;
840  ruiPredYBottom = ruiPredYTop + iHeight;
841  }
842  else
843  {
844  ruiPredXRight = ruiPredXLeft + iWidth;
845  ruiPredYBottom = ruiPredYTop + (iHeight << 1);
846  ruiPredYTop += iHeight;
847  }
848  break;
849  case SIZE_Nx2N:
850  if (uiPartIdx == 0)
851  {
852  ruiPredXRight = ruiPredXLeft + iWidth;
853  ruiPredYBottom = ruiPredYTop + iHeight;
854  }
855  else
856  {
857  ruiPredXRight = ruiPredXLeft + (iWidth << 1);
858  ruiPredYBottom = ruiPredYTop + iHeight;
859  ruiPredXLeft += iWidth;
860  }
861  break;
862  case SIZE_NxN:
863  if (uiPartIdx == 0)
864  {
865  ruiPredXRight = ruiPredXLeft + iWidth;
866  ruiPredYBottom = ruiPredYTop + iHeight;
867  }
868  else if (uiPartIdx == 1)
869  {
870  ruiPredXRight = ruiPredXLeft + (iWidth << 1);
871  ruiPredYBottom = ruiPredYTop + iHeight;
872  ruiPredXLeft += iWidth;
873  }
874  else if (uiPartIdx == 2)
875  {
876  ruiPredXRight = ruiPredXLeft + iWidth;
877  ruiPredYBottom = ruiPredYTop + (iHeight << 1);
878  ruiPredYTop += iHeight;
879  }
880  else if (uiPartIdx == 3)
881  {
882  ruiPredXRight = ruiPredXLeft + (iWidth << 1);
883  ruiPredYBottom = ruiPredYTop + (iHeight << 1);
884  ruiPredXLeft += iWidth;
885  ruiPredYTop += iHeight;
886  }
887  break;
888  case SIZE_2NxnU:
889  if (uiPartIdx == 0)
890  {
891  ruiPredXRight = ruiPredXLeft + iWidth;
892  ruiPredYBottom = ruiPredYTop + iHeight;
893  }
894  else
895  {
896  ruiPredXRight = ruiPredXLeft + iWidth;
897  ruiPredYBottom = ruiPredYTop + pcCU->getHeight(0);
898  ruiPredYTop += (iHeight / 3);
899  }
900  break;
901  case SIZE_2NxnD:
902  if (uiPartIdx == 0)
903  {
904  ruiPredXRight = ruiPredXLeft + iWidth;
905  ruiPredYBottom = ruiPredYTop + iHeight;
906  }
907  else
908  {
909  Int oriHeight = iHeight << 2;
910  ruiPredXRight = ruiPredXLeft + iWidth;
911  ruiPredYBottom = ruiPredYTop + oriHeight;
912  ruiPredYTop += (oriHeight >> 2) + (oriHeight >> 1);
913  }
914  break;
915  case SIZE_nLx2N:
916  if (uiPartIdx == 0)
917  {
918  ruiPredXRight = ruiPredXLeft + iWidth;
919  ruiPredYBottom = ruiPredYTop + iHeight;
920  }
921  else
922  {
923  ruiPredXRight = ruiPredXLeft + pcCU->getWidth(0);
924  ruiPredYBottom = ruiPredYTop + iHeight;
925  ruiPredXLeft += (iWidth / 3);
926  }
927  break;
928  case SIZE_nRx2N:
929  if (uiPartIdx == 0)
930  {
931  ruiPredXRight = ruiPredXLeft + iWidth;
932  ruiPredYBottom = ruiPredYTop + iHeight;
933  }
934  else
935  {
936  Int oriWidth = (iWidth << 2);
937  ruiPredXRight = ruiPredXLeft + oriWidth;
938  ruiPredYBottom = ruiPredYTop + iHeight;
939  ruiPredXLeft += (oriWidth >> 2) + (oriWidth >> 1);
940  }
941  break;
942  default:
943  ruiPredXRight = ruiPredXLeft + iWidth;
944  ruiPredYBottom = ruiPredYTop + iHeight;
945  break;
946  }
947 
948  ruiPredXLeft += (cMv.getHor() >> 2);
949  ruiPredYTop += (cMv.getVer() >> 2);
950  ruiPredXRight += (cMv.getHor() >> 2) - 1;
951  ruiPredYBottom += (cMv.getVer() >> 2) - 1;
952 }
953 
954 Bool checkMVPRange(TComMv& cMv, UInt ctuLength, UInt tileXPosInCtus, UInt tileYPosInCtus, UInt tileWidthtInCtus, UInt tileHeightInCtus, Int PredXLeft, Int PredXRight, Int PredYTop, Int PredYBottom, ChromaFormat chromaFormat)
955 {
956  // filter length of sub-sample generation filter to be considered
957  const UInt LumaLTSampleOffset = 3;
958  const UInt LumaRBSampleOffset = 4;
959  const UInt CromaLTSampleoffset = 1;
960  const UInt CromaRBSampleoffset = 2;
961 
962  // tile position in full pels
963  const Int leftTopPelPosX = ctuLength * tileXPosInCtus;
964  const Int leftTopPelPosY = ctuLength * tileYPosInCtus;
965  const Int rightBottomPelPosX = ((tileWidthtInCtus + tileXPosInCtus) * ctuLength) - 1;
966  const Int rightBottomPelPosY = ((tileHeightInCtus + tileYPosInCtus) * ctuLength) - 1;
967 
968  // Luma MV range check
969  const Bool isFullPelHorLuma = (cMv.getHor() % 4 == 0);
970  const Bool isFullPelVerLuma = (cMv.getVer() % 4 == 0);
971 
972  const Int lRangeXLeft = leftTopPelPosX + (isFullPelHorLuma ? 0 : LumaLTSampleOffset);
973  const Int lRangeYTop = leftTopPelPosY + (isFullPelVerLuma ? 0 : LumaLTSampleOffset);
974  const Int lRangeXRight = rightBottomPelPosX - (isFullPelHorLuma ? 0 : LumaRBSampleOffset);
975  const Int lRangeYBottom = rightBottomPelPosY - (isFullPelVerLuma ? 0 : LumaRBSampleOffset);
976 
977  if (!(PredXLeft >= lRangeXLeft && PredXLeft <= lRangeXRight) || !(PredXRight >= lRangeXLeft && PredXRight <= lRangeXRight))
978  {
979  return false;
980  }
981  else if (!(PredYTop >= lRangeYTop && PredYTop <= lRangeYBottom) || !(PredYBottom >= lRangeYTop && PredYBottom <= lRangeYBottom))
982  {
983  return false;
984  }
985 
986  if ((chromaFormat != CHROMA_444) && (chromaFormat != CHROMA_400))
987  {
988  // Chroma MV range check
989  const Bool isFullPelHorChroma = (cMv.getHor() % 8 == 0);
990  const Bool isFullPelVerChroma = (cMv.getVer() % 8 == 0);
991 
992  const Int cRangeXLeft = leftTopPelPosX + (isFullPelHorChroma ? 0 : CromaLTSampleoffset);
993  const Int cRangeYTop = leftTopPelPosY + (isFullPelVerChroma ? 0 : CromaLTSampleoffset);
994  const Int cRangeXRight = rightBottomPelPosX - (isFullPelHorChroma ? 0 : CromaRBSampleoffset);
995  const Int cRangeYBottom = rightBottomPelPosY - (isFullPelVerChroma ? 0 : CromaRBSampleoffset);
996 
997  if (!(PredXLeft >= cRangeXLeft && PredXLeft <= cRangeXRight) || !(PredXRight >= cRangeXLeft && PredXRight <= cRangeXRight))
998  {
999  return false;
1000  }
1001  else if ((!(PredYTop >= cRangeYTop && PredYTop <= cRangeYBottom) || !(PredYBottom >= cRangeYTop && PredYBottom <= cRangeYBottom)) && (chromaFormat != CHROMA_422))
1002  {
1003  return false;
1004  }
1005  }
1006 
1007  return true;
1008 }
1009 
1011 {
1012  Int partWidth = 0;
1013  Int partHeight = 0;
1014  UInt partAddr = 0;
1015 
1016  UInt tileXPosInCtus = 0;
1017  UInt tileYPosInCtus = 0;
1018  UInt tileWidthtInCtus = 0;
1019  UInt tileHeightInCtus = 0;
1020 
1021  getTilePosition(pcCU, tileXPosInCtus, tileYPosInCtus, tileWidthtInCtus, tileHeightInCtus);
1022 
1023  const UInt ctuLength = pcCU->getPic()->getPicSym()->getSPS().getMaxCUWidth();
1024  const ChromaFormat chromaFormat = pcCU->getPic()->getPicSym()->getSPS().getChromaFormatIdc();
1025 
1026  Int predXLeft;
1027  Int predYTop;
1028  Int predXRight;
1029  Int predYBottom;
1030 
1031  if (partIdx >= 0)
1032  {
1033  pcCU->getPartIndexAndSize(partIdx, partAddr, partWidth, partHeight);
1034 
1035  if (xCheckIdenticalMotion(pcCU, partAddr))
1036  {
1037  RefPicList eRefPicList = REF_PIC_LIST_0;
1038  TComMv cMv = pcCU->getCUMvField(eRefPicList)->getMv(partAddr);
1039  getRefPUPartPos(pcCU, cMv, partIdx, predXLeft, predYTop, predXRight, predYBottom, partWidth, partHeight);
1040  if (!checkMVPRange(cMv, ctuLength, tileXPosInCtus, tileYPosInCtus, tileWidthtInCtus, tileHeightInCtus, predXLeft, predXRight, predYTop, predYBottom, chromaFormat))
1041  {
1042  return false;
1043  }
1044  }
1045  else
1046  {
1047  for (UInt refList = 0; refList < NUM_REF_PIC_LIST_01; refList++)
1048  {
1049  RefPicList eRefPicList = (refList ? REF_PIC_LIST_1 : REF_PIC_LIST_0);
1050 
1051  TComMv cMv = pcCU->getCUMvField(eRefPicList)->getMv(partAddr);
1052  getRefPUPartPos(pcCU, cMv, partIdx, predXLeft, predYTop, predXRight, predYBottom, partWidth, partHeight);
1053  if (!checkMVPRange(cMv, ctuLength, tileXPosInCtus, tileYPosInCtus, tileWidthtInCtus, tileHeightInCtus, predXLeft, predXRight, predYTop, predYBottom, chromaFormat))
1054  {
1055  return false;
1056  }
1057  }
1058  }
1059  return true;
1060  }
1061 
1062  for (partIdx = 0; partIdx < pcCU->getNumPartitions(); partIdx++)
1063  {
1064  pcCU->getPartIndexAndSize(partIdx, partAddr, partWidth, partHeight);
1065 
1066  if (xCheckIdenticalMotion(pcCU, partAddr))
1067  {
1068  RefPicList eRefPicList = REF_PIC_LIST_0;
1069  TComMv cMv = pcCU->getCUMvField(eRefPicList)->getMv(partAddr);
1070  getRefPUPartPos(pcCU, cMv, partIdx, predXLeft, predYTop, predXRight, predYBottom, partWidth, partHeight);
1071  if (!checkMVPRange(cMv, ctuLength, tileXPosInCtus, tileYPosInCtus, tileWidthtInCtus, tileHeightInCtus, predXLeft, predXRight, predYTop, predYBottom, chromaFormat))
1072  {
1073  return false;
1074  }
1075  }
1076  else
1077  {
1078  for (UInt refList = 0; refList < NUM_REF_PIC_LIST_01; refList++)
1079  {
1080  RefPicList eRefPicList = (refList ? REF_PIC_LIST_1 : REF_PIC_LIST_0);
1081 
1082  TComMv cMv = pcCU->getCUMvField(eRefPicList)->getMv(partAddr);
1083  getRefPUPartPos(pcCU, cMv, partIdx, predXLeft, predYTop, predXRight, predYBottom, partWidth, partHeight);
1084  if (!checkMVPRange(cMv, ctuLength, tileXPosInCtus, tileYPosInCtus, tileWidthtInCtus, tileHeightInCtus, predXLeft, predXRight, predYTop, predYBottom, chromaFormat))
1085  {
1086  return false;
1087  }
1088  }
1089  }
1090  }
1091  return true;
1092 }
1093 
1094 
1095 #endif
1096 
SChar g_aucConvertToBit[MAX_CU_SIZE+1]
Definition: TComRom.cpp:572
UChar getNumPartitions(const UInt uiAbsPartIdx=0) const
static const Int MAXIMUM_INTRA_FILTERED_HEIGHT
Definition: CommonDef.h:148
Void setMVPNumSubParts(Int iMVPNum, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth)
Void destroy()
Destroy YUV buffer.
Definition: TComYuv.cpp:79
SliceType
supported slice type
Definition: TypeDef.h:283
Int getMVPIdx(RefPicList eRefPicList, UInt uiIdx) const
Definition: TComDataCU.h:378
Int getRefIdx(Int iIdx) const
SChar * getPartitionSize()
Definition: TComDataCU.h:226
picture YUV buffer class
Definition: TComPicYuv.h:55
SliceType getSliceType() const
Definition: TComSlice.h:1353
CU data structure class.
Definition: TComDataCU.h:64
ChannelType
Definition: TypeDef.h:301
static const Int LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS
Definition: CommonDef.h:200
static const Int HOR_IDX
index for intra HORIZONTAL mode
Definition: CommonDef.h:185
Int getHor() const
Definition: TComMv.h:88
prediction class (header)
void Void
Definition: TypeDef.h:203
Int getStride(const ComponentID id) const
Definition: TComPicYuv.h:121
Void getMvPredAMVP(TComDataCU *pcCU, UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, TComMv &rcMvPred)
static const UInt MAX_INTRA_FILTER_DEPTHS
Pel predIntraGetPredValDC(const Pel *pSrc, Int iSrcStride, UInt iWidth, UInt iHeight)
#define NULL
Definition: CommonDef.h:107
Void motionCompensation(TComDataCU *pcCU, TComYuv *pcYuvPred, RefPicList eRefPicList=REF_PIC_LIST_X, Int iPartIdx=-1)
unsigned int UInt
Definition: TypeDef.h:212
Void xPredInterBlk(const ComponentID compID, TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *dstPic, Bool bi, const Int bitDepth)
Generate motion-compensated block.
TComYuv m_acYuvPred[NUM_REF_PIC_LIST_01]
Short Pel
pixel type
Definition: TypeDef.h:249
Void initTempBuff(ChromaFormat chromaFormatIDC)
symmetric motion partition, 2Nx N
Definition: TypeDef.h:351
static const UChar m_aucIntraFilter[MAX_NUM_CHANNEL_TYPE][MAX_INTRA_FILTER_DEPTHS]
UInt getStride(const ComponentID id) const
Definition: TComYuv.h:199
picture class (header)
ChromaFormat getChromaFormatIdc() const
Definition: TComSlice.h:826
Int getNumRefIdx(RefPicList e) const
Definition: TComSlice.h:1370
TComMv m_acMvCand[AMVP_MAX_NUM_CANDS]
array of motion vector predictor candidates
Bool isInterB() const
Definition: TComSlice.h:1424
UInt getZorderIdxInCtu() const
Definition: TComDataCU.h:206
TComPicYuv * getPicYuvRec()
Definition: TComPic.h:120
TComYuv m_cYuvPredTemp
UInt GetAbsPartIdxTU() const
Definition: TComTU.h:119
Bool checkTMctsMvp(TComDataCU *pcCU, Int partIdx=-1)
Int iN
number of motion vector predictor candidates
general YUV buffer class
Definition: TComYuv.h:54
Void predIntraAng(const ComponentID compID, UInt uiDirMode, Pel *piOrg, UInt uiOrgStride, Pel *piPred, UInt uiStride, TComTU &rTu, const Bool bUseFilteredPredSamples, const Bool bUseLosslessDPCM=false)
UInt getComponentScaleY(const ComponentID id) const
Definition: TComPicYuv.h:151
UInt getComponentScaleX(const ComponentID id) const
Definition: TComPicYuv.h:150
Void xWeightedAverage(TComYuv *pcYuvSrc0, TComYuv *pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv *pcYuvDst, const BitDepths &clipBitDepths)
bool Bool
Definition: TypeDef.h:204
Void clipMv(TComMv &rcMv) const
static const Int VER_IDX
index for intra VERTICAL mode
Definition: CommonDef.h:184
Bool isRDPCMEnabled(UInt uiAbsPartIdx) const
Definition: TComDataCU.h:290
PPS class.
Definition: TComSlice.h:1034
asymmetric motion partition, 2Nx( N/2) + 2Nx(3N/2)
Definition: TypeDef.h:354
asymmetric motion partition, (3N/2)x2N + ( N/2)x2N
Definition: TypeDef.h:357
parameters for AMVP
UInt & getCtuRsAddr()
Definition: TComDataCU.h:204
Void create(const UInt iWidth, const UInt iHeight, const ChromaFormat chromaFormatIDC)
Create YUV buffer.
Definition: TComYuv.cpp:64
Int m_iLumaRecStride
stride of m_pLumaRecBuffer array
UInt getCUPelY() const
Definition: TComDataCU.h:208
static ChannelType toChannelType(const ComponentID id)
T Clip3(const T minVal, const T maxVal, const T a)
general min/max clip
Definition: CommonDef.h:252
TComMv const & getMv(Int iIdx) const
static const Int DC_IDX
index for intra DC mode
Definition: CommonDef.h:186
reference list 0
Definition: TypeDef.h:372
Int getBitDepth(ChannelType type) const
Definition: TComSlice.h:894
Pel * getAddr(const ComponentID id)
Definition: TComYuv.h:150
RefPicList
reference list index
Definition: TypeDef.h:370
TComPicSym * getPicSym()
Definition: TComPic.h:111
ChromaFormat
chroma formats (according to semantics of chroma_format_idc)
Definition: TypeDef.h:292
unsigned char UChar
Definition: TypeDef.h:208
const TComRectangle & getRect(const ComponentID compID) const
Definition: TComTU.h:96
const BitDepths & getBitDepths() const
Definition: TComSlice.h:900
UChar * getDepth()
Definition: TComDataCU.h:210
const TComPPS * getPPS() const
Definition: TComSlice.h:1332
UInt getCUPelX() const
Definition: TComDataCU.h:207
Int getVer() const
Definition: TComMv.h:89
Bool getUseWP() const
Definition: TComSlice.h:1134
ChromaFormat getChromaFormat() const
Definition: TComPic.h:139
Void xPredIntraPlanar(const Pel *pSrc, Int srcStride, Pel *rpDst, Int dstStride, UInt width, UInt height)
Void getPartIndexAndSize(UInt uiPartIdx, UInt &ruiPartAddr, Int &riWidth, Int &riHeight) const
Void xDCPredFiltering(const Pel *pSrc, Int iSrcStride, Pel *pDst, Int iDstStride, Int iWidth, Int iHeight, ChannelType channelType)
TComDataCU * getCU()
Definition: TComTU.h:126
reference list 1
Definition: TypeDef.h:373
UChar * getHeight()
Definition: TComDataCU.h:252
const TComSPS & getSPS() const
Definition: TComPicSym.h:163
Bool * getCUTransquantBypass()
Definition: TComDataCU.h:245
asymmetric motion partition, ( N/2)x2N + (3N/2)x2N
Definition: TypeDef.h:356
TComPic * getPic()
Definition: TComDataCU.h:200
AMVPInfo * getAMVPInfo()
Definition: TComTU.h:48
Void getRefPUPartPos(TComDataCU *pcCU, TComMv &cMv, Int uiPartIdx, Int &ruiPredXLeft, Int &ruiPredYTop, Int &ruiPredXRight, Int &ruiPredYBottom, Int iWidth, Int iHeight)
ChromaFormat getChromaFormat() const
Definition: TComYuv.h:202
Pel * m_pLumaRecBuffer
array for downsampled reconstructed luma sample
static const Int MAX_CU_SIZE
= 1&lt;&lt;(MAX_CU_DEPTH)
Definition: CommonDef.h:221
TComInterpolationFilter m_if
static Void filterVer(Int bitDepth, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Bool isFirst, Bool isLast, TFilterCoeff const *coeff)
Filter a block of samples (vertical)
Pel * getAddr(const ComponentID ch)
Definition: TComPicYuv.h:139
static const Int PLANAR_IDX
Definition: CommonDef.h:183
TComCUMvField * getCUMvField(RefPicList e)
Definition: TComDataCU.h:297
UChar * getWidth()
Definition: TComDataCU.h:248
Pel * getPredictorPtr(const ComponentID compID, const Bool bUseFilteredPredictions)
Void addAvg(const TComYuv *pcYuvSrc0, const TComYuv *pcYuvSrc1, const UInt iPartUnitIdx, const UInt iWidth, const UInt iHeight, const BitDepths &clipBitDepths)
Definition: TComYuv.cpp:354
int Int
Definition: TypeDef.h:211
basic motion vector class
Definition: TComMv.h:51
Bool xCheckIdenticalMotion(TComDataCU *pcCU, UInt PartAddr)
virtual ~TComPrediction()
ComponentID
Definition: TypeDef.h:308
Void xPredInterBi(TComDataCU *pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv *pcYuvPred)
TComYuv m_filteredBlockTmp[LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS]
Bool checkMVPRange(TComMv &cMv, UInt ctuLength, UInt tileXPosInCtus, UInt tileYPosInCtus, UInt tileWidthtInCtus, UInt tileHeightInCtus, Int PredXLeft, Int PredXRight, Int PredYTop, Int PredYBottom, ChromaFormat chromaFormat)
asymmetric motion partition, 2Nx(3N/2) + 2Nx( N/2)
Definition: TypeDef.h:355
symmetric motion partition, Nx N
Definition: TypeDef.h:353
special mark
Definition: TypeDef.h:375
TComYuv m_filteredBlock[LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS]
Void setMVPIdxSubParts(Int iMVPIdx, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth)
Void xWeightedPredictionBi(TComDataCU *const pcCU, const TComYuv *const pcYuvSrc0, const TComYuv *const pcYuvSrc1, const Int iRefIdx0, const Int iRefIdx1, const UInt uiPartIdx, const Int iWidth, const Int iHeight, TComYuv *pcYuvDst)
weighted prediction for bi-pred
slice header class
Definition: TComSlice.h:1225
Bool getWPBiPred() const
Definition: TComSlice.h:1135
static const Int MAXIMUM_INTRA_FILTERED_WIDTH
Definition: CommonDef.h:147
UInt getNumberValidComponents() const
Definition: TComYuv.h:203
Void getTilePosition(const TComDataCU *const pcCU, UInt &tileXPosInCtus, UInt &tileYPosInCtus, UInt &tileWidthtInCtus, UInt &tileHeightInCtus)
Definition: TComPicSym.cpp:605
Void copyPartToPartYuv(TComYuv *pcYuvDst, const UInt uiPartIdx, const UInt uiWidth, const UInt uiHeight) const
Definition: TComYuv.cpp:224
#define NTAPS_LUMA
Number of taps for luma.
Void xPredInterUni(TComDataCU *pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv *pcYuvPred, Bool bi=false)
TComPic * getRefPic(RefPicList e, Int iRefIdx)
Definition: TComSlice.h:1373
Pel * m_piYuvExt[MAX_NUM_COMPONENT][NUM_PRED_BUF]
symmetric motion partition, Nx2N
Definition: TypeDef.h:352
static Bool isLuma(const ComponentID id)
#define NTAPS_CHROMA
Number of taps for chroma.
static Void filterHor(Int bitDepth, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Bool isLast, TFilterCoeff const *coeff)
Filter a block of samples (horizontal)
Void xPredIntraAng(Int bitDepth, const Pel *pSrc, Int srcStride, Pel *pDst, Int dstStride, UInt width, UInt height, ChannelType channelType, UInt dirMode, const Bool bEnableEdgeFilters)
UInt getMaxCUWidth() const
Definition: TComSlice.h:857
TComSlice * getSlice()
Definition: TComDataCU.h:202
const TComSPS * getSPS() const
Definition: TComSlice.h:1329
Void xWeightedPredictionUni(TComDataCU *const pcCU, const TComYuv *const pcYuvSrc, const UInt uiPartAddr, const Int iWidth, const Int iHeight, const RefPicList eRefPicList, TComYuv *pcYuvPred, const Int iRefIdx=-1)
weighted prediction for uni-pred
static Bool UseDPCMForFirstPassIntraEstimation(TComTU &rTu, const UInt uiDirMode)