Ticket #1450: reduceHMMemory.patch

File reduceHMMemory.patch, 27.6 KB (added by karlsharman, 8 years ago)
  • source/Lib/TLibCommon/TComDataCU.cpp

     
    9595
    9696  for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)
    9797  {
    98     m_apcCUColocated[i]  = NULL;
     98    //m_apcCUColocated[i]  = NULL;
    9999    m_apiMVPIdx[i]       = NULL;
    100100    m_apiMVPNum[i]       = NULL;
    101101  }
     
    205205  m_pCtuAbove          = NULL;
    206206  m_pCtuLeft           = NULL;
    207207
    208   for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)
    209   {
    210     m_apcCUColocated[i]  = NULL;
    211   }
     208  //for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)
     209  //{
     210  //  m_apcCUColocated[i]  = NULL;
     211  //}
    212212}
    213213
    214214Void TComDataCU::destroy()
     
    373373  m_pCtuLeft           = NULL;
    374374
    375375
    376   for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)
    377   {
    378     m_apcCUColocated[i]  = NULL;
    379   }
     376  //for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)
     377  //{
     378  //  m_apcCUColocated[i]  = NULL;
     379  //}
    380380
    381381}
    382382
     
    503503  m_pCtuAboveRight  = NULL;
    504504
    505505
    506   for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)
    507   {
    508     m_apcCUColocated[i]  = NULL;
    509   }
     506  //for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)
     507  //{
     508  //  m_apcCUColocated[i]  = NULL;
     509  //}
    510510
    511511  UInt frameWidthInCtus = pcPic->getFrameWidthInCtus();
    512512  if ( m_ctuRsAddr % frameWidthInCtus )
     
    529529    m_pCtuAboveRight = pcPic->getCtu( m_ctuRsAddr - frameWidthInCtus + 1 );
    530530  }
    531531
    532   for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)
    533   {
    534     const RefPicList rpl=RefPicList(i);
    535     if ( getSlice()->getNumRefIdx( rpl ) > 0 )
    536     {
    537       m_apcCUColocated[rpl] = getSlice()->getRefPic( rpl, 0)->getCtu( m_ctuRsAddr );
    538     }
    539   }
     532  //for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)
     533  //{
     534  //  const RefPicList rpl=RefPicList(i);
     535  //  if ( getSlice()->getNumRefIdx( rpl ) > 0 )
     536  //  {
     537  //    m_apcCUColocated[rpl] = getSlice()->getRefPic( rpl, 0)->getCtu( m_ctuRsAddr );
     538  //  }
     539  //}
    540540}
    541541
    542542
     
    707707  m_pCtuAboveLeft   = pcCU->getCtuAboveLeft();
    708708  m_pCtuAboveRight  = pcCU->getCtuAboveRight();
    709709
    710   for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)
    711   {
    712     m_apcCUColocated[i] = pcCU->getCUColocated(RefPicList(i));
    713   }
     710  //for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)
     711  //{
     712  //  m_apcCUColocated[i] = pcCU->getCUColocated(RefPicList(i));
     713  //}
    714714}
    715715
    716716Void TComDataCU::setOutsideCUPart( UInt uiAbsPartIdx, UInt uiDepth )
     
    782782  for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)
    783783  {
    784784    const RefPicList rpl=RefPicList(i);
    785     m_apcCUColocated[rpl] = pcCU->getCUColocated(rpl);
     785    // m_apcCUColocated[rpl] = pcCU->getCUColocated(rpl);
    786786    m_apiMVPIdx[rpl]=pcCU->getMVPIdx(rpl)  + uiPart;
    787787    m_apiMVPNum[rpl]=pcCU->getMVPNum(rpl)  + uiPart;
    788788  }
     
    828828  m_pCtuAbove          = pcCU->getCtuAbove();
    829829  m_pCtuLeft           = pcCU->getCtuLeft();
    830830
    831   for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)
    832   {
    833     m_apcCUColocated[i]  = pcCU->getCUColocated(RefPicList(i));
    834   }
     831  //for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)
     832  //{
     833  //  m_apcCUColocated[i]  = pcCU->getCUColocated(RefPicList(i));
     834  //}
    835835
    836836  m_skipFlag           = pcCU->getSkipFlag ()             + uiAbsPartIdx;
    837837
     
    914914    const RefPicList rpl=RefPicList(i);
    915915    memcpy( m_apiMVPIdx[rpl] + uiOffset, pcCU->getMVPIdx(rpl), iSizeInUchar );
    916916    memcpy( m_apiMVPNum[rpl] + uiOffset, pcCU->getMVPNum(rpl), iSizeInUchar );
    917     m_apcCUColocated[rpl] = pcCU->getCUColocated(rpl);
     917    // m_apcCUColocated[rpl] = pcCU->getCUColocated(rpl);
    918918  }
    919919
    920920  for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)
     
    29932993
    29942994  // use coldir.
    29952995  const TComPic    * const pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0), getSlice()->getColRefIdx());
    2996   const TComDataCU * const pColCtu = pColPic->getCtu( ctuRsAddr );
    2997   if(pColCtu->getPic()==0 || pColCtu->getPartitionSize(partUnitIdx)==NUMBER_OF_PART_SIZES)
     2996  const TComPicSym::DPBPerCtuData * const pColDpbCtu = &(pColPic->getPicSym()->getDPBPerCtuData(ctuRsAddr));
     2997  const TComSlice * const pColSlice = pColDpbCtu->getSlice();
     2998  if(/*pColCtu->getPic()==0 || */pColDpbCtu->getPartitionSize(partUnitIdx)==NUMBER_OF_PART_SIZES)
    29982999  {
    29993000    return false;
    30003001  }
    30013002
    3002   if (!pColCtu->isInter(absPartAddr))
     3003  if (!pColDpbCtu->isInter(absPartAddr))
    30033004  {
    30043005    return false;
    30053006  }
    30063007
    30073008  RefPicList eColRefPicList = getSlice()->getCheckLDC() ? eRefPicList : RefPicList(getSlice()->getColFromL0Flag());
    3008   Int iColRefIdx            = pColCtu->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(absPartAddr);
     3009  Int iColRefIdx            = pColDpbCtu->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(absPartAddr);
    30093010
    30103011  if (iColRefIdx < 0 )
    30113012  {
    30123013    eColRefPicList = RefPicList(1 - eColRefPicList);
    3013     iColRefIdx = pColCtu->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(absPartAddr);
     3014    iColRefIdx = pColDpbCtu->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(absPartAddr);
    30143015
    30153016    if (iColRefIdx < 0 )
    30163017    {
     
    30193020  }
    30203021
    30213022  const Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, refIdx)->getIsLongTerm();
    3022   const Bool bIsColRefLongTerm  = pColCtu->getSlice()->getIsUsedAsLongTerm(eColRefPicList, iColRefIdx);
     3023  const Bool bIsColRefLongTerm  = pColSlice->getIsUsedAsLongTerm(eColRefPicList, iColRefIdx);
    30233024
    30243025  if ( bIsCurrRefLongTerm != bIsColRefLongTerm )
    30253026  {
     
    30273028  }
    30283029
    30293030  // Scale the vector.
    3030   const TComMv &cColMv = pColCtu->getCUMvField(eColRefPicList)->getMv(absPartAddr);
     3031  const TComMv &cColMv = pColDpbCtu->getCUMvField(eColRefPicList)->getMv(absPartAddr);
    30313032  if ( bIsCurrRefLongTerm /*|| bIsColRefLongTerm*/ )
    30323033  {
    30333034    rcMv = cColMv;
     
    30353036  else
    30363037  {
    30373038    const Int currPOC    = m_pcSlice->getPOC();
    3038     const Int colPOC     = pColCtu->getSlice()->getPOC();
    3039     const Int colRefPOC  = pColCtu->getSlice()->getRefPOC(eColRefPicList, iColRefIdx);
     3039    const Int colPOC     = pColSlice->getPOC();
     3040    const Int colRefPOC  = pColSlice->getRefPOC(eColRefPicList, iColRefIdx);
    30403041    const Int currRefPOC = m_pcSlice->getRefPic(eRefPicList, refIdx)->getPOC();
    30413042    const Int scale      = xGetDistScaleFactor(currPOC, currRefPOC, colPOC, colRefPOC);
    30423043    if ( scale == 4096 )
     
    30873088
    30883089Void TComDataCU::compressMV()
    30893090{
    3090   Int scaleFactor = 4 * AMVP_DECIMATION_FACTOR / m_unitSize;
    3091   if (scaleFactor > 0)
     3091  const Int scaleFactor = std::max<Int>(1,4 * AMVP_DECIMATION_FACTOR / m_unitSize);
     3092  TComPicSym &picSym=*(getPic()->getPicSym());
     3093  TComPicSym::DPBPerCtuData &dpbForCtu=picSym.getDPBPerCtuData(getCtuRsAddr());
     3094
     3095  for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)
    30923096  {
    3093     for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)
    3094     {
    3095       m_acCUMvField[i].compress(m_pePredMode, scaleFactor);
    3096     }
     3097    dpbForCtu.m_CUMvField[i].compress(dpbForCtu.m_pePredMode, m_pePredMode, scaleFactor,m_acCUMvField[i]);
     3098    memcpy(dpbForCtu.m_pePartSize, m_pePartSize, sizeof(*m_pePartSize)*m_uiNumPartition);
     3099    dpbForCtu.m_pSlice = getSlice();
    30973100  }
    30983101}
    30993102
  • source/Lib/TLibCommon/TComDataCU.h

     
    118118  TComDataCU*   m_pCtuAboveRight;                       ///< pointer of above-right CTU.
    119119  TComDataCU*   m_pCtuAbove;                            ///< pointer of above CTU.
    120120  TComDataCU*   m_pCtuLeft;                             ///< pointer of left CTU
    121   TComDataCU*   m_apcCUColocated[NUM_REF_PIC_LIST_01];  ///< pointer of temporally colocated CU's for both directions
     121  //TComDataCU*   m_apcCUColocated[NUM_REF_PIC_LIST_01];  ///< pointer of temporally colocated CU's for both directions
    122122  TComMvField   m_cMvFieldA;                            ///< motion vector of position A
    123123  TComMvField   m_cMvFieldB;                            ///< motion vector of position B
    124124  TComMvField   m_cMvFieldC;                            ///< motion vector of position C
     
    392392  TComDataCU*   getCtuAbove                   ( )                                                          { return m_pCtuAbove;                        }
    393393  TComDataCU*   getCtuAboveLeft               ( )                                                          { return m_pCtuAboveLeft;                    }
    394394  TComDataCU*   getCtuAboveRight              ( )                                                          { return m_pCtuAboveRight;                   }
    395   TComDataCU*   getCUColocated                ( RefPicList eRefPicList )                                   { return m_apcCUColocated[eRefPicList];      }
     395  //TComDataCU*   getCUColocated                ( RefPicList eRefPicList )                                   { return m_apcCUColocated[eRefPicList];      }
    396396  Bool          CUIsFromSameSlice             ( const TComDataCU *pCU /* Can be NULL */ ) const            { return ( pCU!=NULL && pCU->getSlice()->getSliceCurStartCtuTsAddr() == getSlice()->getSliceCurStartCtuTsAddr() ); }
    397397  Bool          CUIsFromSameTile              ( const TComDataCU *pCU /* Can be NULL */ ) const;
    398398  Bool          CUIsFromSameSliceAndTile      ( const TComDataCU *pCU /* Can be NULL */ ) const;
  • source/Lib/TLibCommon/TComMotionInfo.cpp

     
    327327 * \param pePredMode Pointer to prediction modes
    328328 * \param scale      Factor by which to subsample motion information
    329329 */
    330 Void TComCUMvField::compress(SChar* pePredMode, Int scale)
     330Void TComCUMvField::compress(SChar *pePredMode, const SChar* pePredModeSource, const Int scale, const TComCUMvField &source)
    331331{
    332   Int N = scale * scale;
    333   assert( N > 0 && N <= m_uiNumPartition);
     332  const Int numSubpartsWithIdenticalMotion = scale * scale;
     333  assert( numSubpartsWithIdenticalMotion > 0 && numSubpartsWithIdenticalMotion <= m_uiNumPartition);
     334  assert(source.m_uiNumPartition == m_uiNumPartition);
    334335
    335   for ( Int uiPartIdx = 0; uiPartIdx < m_uiNumPartition; uiPartIdx += N )
     336  for ( Int partIdx = 0; partIdx < m_uiNumPartition; partIdx += numSubpartsWithIdenticalMotion )
    336337  {
    337338    TComMv cMv(0,0);
    338339    Int iRefIdx = 0;
    339340
    340     cMv = m_pcMv[ uiPartIdx ];
    341     PredMode predMode = static_cast<PredMode>( pePredMode[ uiPartIdx ] );
    342     iRefIdx = m_piRefIdx[ uiPartIdx ];
    343     for ( Int i = 0; i < N; i++ )
     341    cMv = source.m_pcMv[ partIdx ];
     342    PredMode predMode = static_cast<PredMode>( pePredModeSource[ partIdx ] );
     343    iRefIdx = source.m_piRefIdx[ partIdx ];
     344    for ( Int i = 0; i < numSubpartsWithIdenticalMotion; i++ )
    344345    {
    345       m_pcMv[ uiPartIdx + i ] = cMv;
    346       pePredMode[ uiPartIdx + i ] = predMode;
    347       m_piRefIdx[ uiPartIdx + i ] = iRefIdx;
     346      m_pcMv[ partIdx + i ] = cMv;
     347      pePredMode[ partIdx + i ] = predMode;
     348      m_piRefIdx[ partIdx + i ] = iRefIdx;
    348349    }
    349350  }
    350351}
  • source/Lib/TLibCommon/TComMotionInfo.h

     
    152152    m_piRefIdx = src->m_piRefIdx + offset;
    153153  }
    154154
    155   Void compress(SChar* pePredMode, Int scale);
     155  Void compress(SChar *pePredMode, const SChar* pePredModeSource, const Int scale, const TComCUMvField &source);
    156156};
    157157
    158158//! \}
  • source/Lib/TLibCommon/TComPic.cpp

     
    6767  destroy();
    6868}
    6969
    70 Void TComPic::create( const TComSPS &sps, const TComPPS &pps, const Bool bIsVirtual)
     70Void TComPic::create( const TComSPS &sps, const TComPPS &pps, const Bool bCreateEncoderSourcePicYuv, const Bool bCreateForImmediateReconstruction )
    7171{
    7272  destroy();
    7373
     
    7878  const UInt         uiMaxCuHeight   = sps.getMaxCUHeight();
    7979  const UInt         uiMaxDepth      = sps.getMaxTotalCUDepth();
    8080
    81   m_picSym.create( sps, pps, uiMaxDepth );
    82   if (!bIsVirtual)
     81  m_picSym.create( sps, pps, uiMaxDepth, bCreateForImmediateReconstruction );
     82  if (bCreateEncoderSourcePicYuv)
    8383  {
    8484    m_apcPicYuv[PIC_YUV_ORG    ]   = new TComPicYuv;  m_apcPicYuv[PIC_YUV_ORG     ]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true );
    8585    m_apcPicYuv[PIC_YUV_TRUE_ORG]  = new TComPicYuv;  m_apcPicYuv[PIC_YUV_TRUE_ORG]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true );
    8686  }
    87   m_apcPicYuv[PIC_YUV_REC]  = new TComPicYuv;  m_apcPicYuv[PIC_YUV_REC]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true );
     87  if (bCreateForImmediateReconstruction)
     88  {
     89    m_apcPicYuv[PIC_YUV_REC]  = new TComPicYuv;  m_apcPicYuv[PIC_YUV_REC]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true );
     90  }
    8891
    8992  // there are no SEI messages associated with this picture initially
    9093  if (m_SEIs.size() > 0)
     
    9497  m_bUsedByCurr = false;
    9598}
    9699
     100Void TComPic::prepareForEncoderSourcePicYuv()
     101{
     102  const TComSPS &sps=m_picSym.getSPS();
     103
     104  const ChromaFormat chromaFormatIDC = sps.getChromaFormatIdc();
     105  const Int          iWidth          = sps.getPicWidthInLumaSamples();
     106  const Int          iHeight         = sps.getPicHeightInLumaSamples();
     107  const UInt         uiMaxCuWidth    = sps.getMaxCUWidth();
     108  const UInt         uiMaxCuHeight   = sps.getMaxCUHeight();
     109  const UInt         uiMaxDepth      = sps.getMaxTotalCUDepth();
     110
     111  if (m_apcPicYuv[PIC_YUV_ORG    ]==NULL)
     112  {
     113    m_apcPicYuv[PIC_YUV_ORG    ]   = new TComPicYuv;  m_apcPicYuv[PIC_YUV_ORG     ]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true );
     114  }
     115  if (m_apcPicYuv[PIC_YUV_TRUE_ORG    ]==NULL)
     116  {
     117    m_apcPicYuv[PIC_YUV_TRUE_ORG]  = new TComPicYuv;  m_apcPicYuv[PIC_YUV_TRUE_ORG]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true );
     118  }
     119}
     120
     121Void TComPic::prepareForReconstruction()
     122{
     123  if (m_apcPicYuv[PIC_YUV_REC] == NULL)
     124  {
     125    const TComSPS &sps=m_picSym.getSPS();
     126    const ChromaFormat chromaFormatIDC = sps.getChromaFormatIdc();
     127    const Int          iWidth          = sps.getPicWidthInLumaSamples();
     128    const Int          iHeight         = sps.getPicHeightInLumaSamples();
     129    const UInt         uiMaxCuWidth    = sps.getMaxCUWidth();
     130    const UInt         uiMaxCuHeight   = sps.getMaxCUHeight();
     131    const UInt         uiMaxDepth      = sps.getMaxTotalCUDepth();
     132
     133    m_apcPicYuv[PIC_YUV_REC]  = new TComPicYuv;  m_apcPicYuv[PIC_YUV_REC]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true );
     134  }
     135
     136  // mark it should be extended
     137  m_apcPicYuv[PIC_YUV_REC]->setBorderExtension(false);
     138
     139  m_picSym.prepareForReconstruction();
     140}
     141
     142Void TComPic::releaseReconstructionIntermediateData()
     143{
     144#if KJS_DEBUG
     145  double mem_before=get_mem_usage();
     146#endif
     147  m_picSym.releaseReconstructionIntermediateData();
     148#if KJS_DEBUG
     149  printf("%-60s: %6.1f MBytes total, %6.1f MBytes\n", "At releaseReconstructionIntermediateData", get_mem_usage()/1024, (get_mem_usage()-mem_before)/1024);
     150#endif
     151}
     152
     153Void TComPic::releaseEncoderSourceImageData()
     154{
     155#if KJS_DEBUG
     156  double mem_before=get_mem_usage();
     157#endif
     158  if (m_apcPicYuv[PIC_YUV_ORG    ])
     159  {
     160    m_apcPicYuv[PIC_YUV_ORG]->destroy();
     161    delete m_apcPicYuv[PIC_YUV_ORG];
     162    m_apcPicYuv[PIC_YUV_ORG] = NULL;
     163  }
     164  if (m_apcPicYuv[PIC_YUV_TRUE_ORG    ])
     165  {
     166    m_apcPicYuv[PIC_YUV_TRUE_ORG]->destroy();
     167    delete m_apcPicYuv[PIC_YUV_TRUE_ORG];
     168    m_apcPicYuv[PIC_YUV_TRUE_ORG] = NULL;
     169  }
     170#if KJS_DEBUG
     171  printf("%-60s: %6.1f MBytes total, %6.1f MBytes\n", "At releaseEncoderSourceImageData", get_mem_usage()/1024, (get_mem_usage()-mem_before)/1024);
     172#endif
     173}
     174
     175Void TComPic::releaseAllReconstructionData()
     176{
     177
     178#if KJS_DEBUG
     179  double mem_before=get_mem_usage();
     180#endif
     181
     182  if (m_apcPicYuv[PIC_YUV_REC    ])
     183  {
     184    m_apcPicYuv[PIC_YUV_REC]->destroy();
     185    delete m_apcPicYuv[PIC_YUV_REC];
     186    m_apcPicYuv[PIC_YUV_REC] = NULL;
     187  }
     188  m_picSym.releaseAllReconstructionData();
     189#if KJS_DEBUG
     190  printf("%-60s: %6.1f MBytes total, %6.1f MBytes\n", "At releaseAllReconstructionData", get_mem_usage()/1024, (get_mem_usage()-mem_before)/1024);
     191#endif
     192}
     193
     194
    97195Void TComPic::destroy()
    98196{
    99197  m_picSym.destroy();
  • source/Lib/TLibCommon/TComPic.h

     
    8585  TComPic();
    8686  virtual ~TComPic();
    8787
    88   Void          create( const TComSPS &sps, const TComPPS &pps, const Bool bIsVirtual /*= false*/ );
     88  Void          create( const TComSPS &sps, const TComPPS &pps, const Bool bCreateEncoderSourcePicYuv, const Bool bCreateForImmediateReconstruction );
     89  Void          prepareForEncoderSourcePicYuv();
     90  Void          prepareForReconstruction();
     91  Void          releaseReconstructionIntermediateData();
     92  Void          releaseAllReconstructionData();
     93  Void          releaseEncoderSourceImageData();
    8994
    9095  virtual Void  destroy();
    9196
  • source/Lib/TLibCommon/TComPicSym.cpp

     
    6363,m_ctuTsToRsAddrMap(NULL)
    6464,m_puiTileIdxMap(NULL)
    6565,m_ctuRsToTsAddrMap(NULL)
     66,m_dpbPerCtuData(NULL)
    6667,m_saoBlkParams(NULL)
    6768#if ADAPTIVE_QP_SELECTION
    6869,m_pParentARLBuffer(NULL)
     
    7677}
    7778
    7879
    79 Void TComPicSym::create  ( const TComSPS &sps, const TComPPS &pps, UInt uiMaxDepth )
     80Void TComPicSym::create  ( const TComSPS &sps, const TComPPS &pps, UInt uiMaxDepth, const Bool bAllocateCtuArray )
    8081{
    8182  destroy();
    8283
    8384  m_sps = sps;
    8485  m_pps = pps;
    8586
    86   const ChromaFormat chromaFormatIDC = sps.getChromaFormatIdc();
     87  //const ChromaFormat chromaFormatIDC = sps.getChromaFormatIdc();
    8788  const Int iPicWidth      = sps.getPicWidthInLumaSamples();
    8889  const Int iPicHeight     = sps.getPicHeightInLumaSamples();
    8990  const UInt uiMaxCuWidth  = sps.getMaxCUWidth();
     
    102103  m_frameHeightInCtus  = ( iPicHeight%uiMaxCuHeight ) ? iPicHeight/uiMaxCuHeight + 1 : iPicHeight/uiMaxCuHeight;
    103104
    104105  m_numCtusInFrame     = m_frameWidthInCtus * m_frameHeightInCtus;
    105   m_pictureCtuArray    = new TComDataCU*[m_numCtusInFrame];
     106  m_pictureCtuArray    = NULL;
    106107
    107108  clearSliceBuffer();
    108109  allocateNewSlice();
     
    110111#if ADAPTIVE_QP_SELECTION
    111112  if (m_pParentARLBuffer == NULL)
    112113  {
    113      m_pParentARLBuffer = new TCoeff[uiMaxCuWidth*uiMaxCuHeight*MAX_NUM_COMPONENT];
     114    m_pParentARLBuffer = new TCoeff[uiMaxCuWidth*uiMaxCuHeight*MAX_NUM_COMPONENT];
    114115  }
    115116#endif
    116117
    117   for (UInt i=0; i<m_numCtusInFrame ; i++ )
     118  if (bAllocateCtuArray)
    118119  {
    119     m_pictureCtuArray[i] = new TComDataCU;
    120     m_pictureCtuArray[i]->create( chromaFormatIDC, m_numPartitionsInCtu, uiMaxCuWidth, uiMaxCuHeight, false, uiMaxCuWidth >> m_uhTotalDepth
    121 #if ADAPTIVE_QP_SELECTION
    122       , m_pParentARLBuffer
    123 #endif
    124       );
     120    prepareForReconstruction();
    125121  }
    126122
    127123  m_ctuTsToRsAddrMap = new UInt[m_numCtusInFrame+1];
     
    142138
    143139}
    144140
    145 Void TComPicSym::destroy()
     141Void TComPicSym::prepareForReconstruction()
    146142{
    147   clearSliceBuffer();
     143  const ChromaFormat chromaFormatIDC = m_sps.getChromaFormatIdc();
     144  const UInt uiMaxCuWidth  = m_sps.getMaxCUWidth();
     145  const UInt uiMaxCuHeight = m_sps.getMaxCUHeight();
     146  if (m_pictureCtuArray == NULL)
     147  {
     148    m_pictureCtuArray = new TComDataCU*[m_numCtusInFrame];
     149
     150    for (UInt i=0; i<m_numCtusInFrame ; i++ )
     151    {
     152      m_pictureCtuArray[i] = new TComDataCU;
     153      m_pictureCtuArray[i]->create( chromaFormatIDC, m_numPartitionsInCtu, uiMaxCuWidth, uiMaxCuHeight, false, uiMaxCuWidth >> m_uhTotalDepth
     154#if ADAPTIVE_QP_SELECTION
     155        , m_pParentARLBuffer
     156#endif
     157        );
     158    }
     159  }
     160  if (m_dpbPerCtuData == NULL)
     161  {
     162    m_dpbPerCtuData = new DPBPerCtuData[m_numCtusInFrame];
     163    for(UInt i=0; i<m_numCtusInFrame; i++)
     164    {
     165      for(Int j=0; j<NUM_REF_PIC_LIST_01; j++)
     166      {
     167        m_dpbPerCtuData[i].m_CUMvField[j].create( m_numPartitionsInCtu );
     168      }
     169      m_dpbPerCtuData[i].m_pePredMode = new SChar[m_numPartitionsInCtu];
     170      m_dpbPerCtuData[i].m_pePartSize = new SChar[m_numPartitionsInCtu];
     171      m_dpbPerCtuData[i].m_pSlice=NULL;
     172    }
     173  }
     174}
    148175
     176Void TComPicSym::releaseReconstructionIntermediateData()
     177{
    149178  if (m_pictureCtuArray)
    150179  {
    151180    for (Int i = 0; i < m_numCtusInFrame; i++)
     
    160189    delete [] m_pictureCtuArray;
    161190    m_pictureCtuArray = NULL;
    162191  }
     192}
     193
     194Void TComPicSym::releaseAllReconstructionData()
     195{
     196  releaseReconstructionIntermediateData();
     197
     198  if (m_dpbPerCtuData != NULL)
     199  {
     200    for(UInt i=0; i<m_numCtusInFrame; i++)
     201    {
     202      for(Int j=0; j<NUM_REF_PIC_LIST_01; j++)
     203      {
     204        m_dpbPerCtuData[i].m_CUMvField[j].destroy();
     205      }
     206      delete [] m_dpbPerCtuData[i].m_pePredMode;
     207      delete [] m_dpbPerCtuData[i].m_pePartSize;
     208    }
     209    delete [] m_dpbPerCtuData;
     210    m_dpbPerCtuData=NULL;
     211  }
     212}
     213
     214Void TComPicSym::destroy()
     215{
     216  clearSliceBuffer();
     217  releaseAllReconstructionData();
    163218
    164219  delete [] m_ctuTsToRsAddrMap;
    165220  m_ctuTsToRsAddrMap = NULL;
  • source/Lib/TLibCommon/TComPicSym.h

     
    105105  UInt*         m_puiTileIdxMap;       ///< the map of the tile index relative to CTU raster scan address
    106106  UInt*         m_ctuRsToTsAddrMap;    ///< for a given RS (Raster-Scan) address, returns the TS (Tile-Scan; coding order) address. cf CtbAddrRsToTs in specification.
    107107
     108public:
     109  struct DPBPerCtuData
     110  {
     111    Bool isInter(const UInt absPartAddr)                const { return m_pePredMode[absPartAddr] == MODE_INTER; }
     112    PartSize getPartitionSize( const UInt absPartAddr ) const { return static_cast<PartSize>( m_pePartSize[absPartAddr] ); }
     113    const TComCUMvField* getCUMvField ( RefPicList e )  const { return &m_CUMvField[e];                  }
     114    const TComSlice* getSlice()                         const { return m_pSlice; }
     115
     116    SChar        * m_pePredMode;
     117    SChar        * m_pePartSize;
     118    TComCUMvField  m_CUMvField[NUM_REF_PIC_LIST_01];
     119    TComSlice    * m_pSlice;
     120  };
     121private:
     122  DPBPerCtuData *m_dpbPerCtuData;
    108123  SAOBlkParam  *m_saoBlkParams;
    109124#if ADAPTIVE_QP_SELECTION
    110125  TCoeff*       m_pParentARLBuffer;
     
    120135  Void               setCtuRsToTsAddrMap( Int ctuRsAddr, Int ctuTsOrder )  { *(m_ctuRsToTsAddrMap + ctuRsAddr) = ctuTsOrder; }
    121136
    122137public:
    123   Void               create  ( const TComSPS &sps, const TComPPS &pps, UInt uiMaxDepth );
     138  Void               create  ( const TComSPS &sps, const TComPPS &pps, UInt uiMaxDepth, const Bool bAllocateCtuArray );
     139  Void               prepareForReconstruction();
     140  Void               releaseReconstructionIntermediateData();
     141  Void               releaseAllReconstructionData();
    124142  Void               destroy ();
    125143
    126144  TComPicSym  ();
     
    137155  const TComDataCU*  getCtu( UInt ctuRsAddr ) const                        { return m_pictureCtuArray[ctuRsAddr];  }
    138156  const TComSPS&     getSPS()                 const                        { return m_sps; }
    139157  const TComPPS&     getPPS()                 const                        { return m_pps; }
     158  DPBPerCtuData&       getDPBPerCtuData(UInt ctuRsAddr)                    { return m_dpbPerCtuData[ctuRsAddr]; }
     159  const DPBPerCtuData& getDPBPerCtuData(UInt ctuRsAddr) const              { return m_dpbPerCtuData[ctuRsAddr]; }
    140160
    141161  TComSlice *        swapSliceObject(TComSlice* p, UInt i)                 { p->setSPS(&m_sps); p->setPPS(&m_pps); TComSlice *pTmp=m_apSlices[i];m_apSlices[i] = p; pTmp->setSPS(0); pTmp->setPPS(0); return pTmp; }
    142162  UInt               getNumAllocatedSlice() const                          { return UInt(m_apSlices.size());       }
  • source/Lib/TLibDecoder/TDecTop.cpp

     
    160160  {
    161161    rpcPic = new TComPic();
    162162
    163     rpcPic->create ( sps, pps, true);
     163    rpcPic->create ( sps, pps, false, true);
    164164
    165165    m_cListPic.pushBack( rpcPic );
    166166
     
    197197    m_cListPic.pushBack( rpcPic );
    198198  }
    199199  rpcPic->destroy();
    200   rpcPic->create ( sps, pps, true);
     200  rpcPic->create ( sps, pps, false, true);
    201201}
    202202
    203203Void TDecTop::executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic)
  • source/Lib/TLibEncoder/TEncGOP.cpp

     
    11591159    AccessUnit& accessUnit = accessUnitsInGOP.back();
    11601160    xGetBuffer( rcListPic, rcListPicYuvRecOut, iNumPicRcvd, iTimeOffset, pcPic, pcPicYuvRecOut, pocCurr, isField );
    11611161
     1162    pcPic->prepareForReconstruction();
     1163
    11621164    //  Slice data initialization
    11631165    pcPic->clearSliceBuffer();
    11641166    pcPic->allocateNewSlice();
     
    18611863    {
    18621864      iGOPid=effFieldIRAPMap.restoreGOPid(iGOPid);
    18631865    }
     1866
     1867    pcPic->releaseReconstructionIntermediateData();
     1868    pcPic->releaseEncoderSourceImageData();
     1869
    18641870  } // iGOPid-loop
    18651871
    18661872  delete pcBitstreamRedirect;
  • source/Lib/TLibEncoder/TEncPic.cpp

     
    121121 * \param uiMaxAdaptiveQPDepth Maximum depth of unit block for assigning QP adaptive to local image characteristics
    122122 * \param bIsVirtual
    123123 */
    124 Void TEncPic::create( const TComSPS &sps, const TComPPS &pps, UInt uiMaxAdaptiveQPDepth, Bool bIsVirtual )
     124Void TEncPic::create( const TComSPS &sps, const TComPPS &pps, UInt uiMaxAdaptiveQPDepth )
    125125{
    126   TComPic::create( sps, pps, bIsVirtual );
     126  TComPic::create( sps, pps, true, false );
    127127  const Int  iWidth      = sps.getPicWidthInLumaSamples();
    128128  const Int  iHeight     = sps.getPicHeightInLumaSamples();
    129129  const UInt uiMaxWidth  = sps.getMaxCUWidth();
  • source/Lib/TLibEncoder/TEncPic.h

     
    102102  TEncPic();
    103103  virtual ~TEncPic();
    104104
    105   Void          create( const TComSPS &sps, const TComPPS &pps, UInt uiMaxAdaptiveQPDepth, Bool bIsVirtual /* = false*/ );
     105  Void          create( const TComSPS &sps, const TComPPS &pps, UInt uiMaxAdaptiveQPDepth );
    106106  virtual Void  destroy();
    107107
    108108  TEncPicQPAdaptationLayer* getAQLayer( UInt uiDepth )  { return &m_acAQLayer[uiDepth]; }
  • source/Lib/TLibEncoder/TEncTop.cpp

     
    491491        break;
    492492      }
    493493    }
     494    rpcPic->releaseAllReconstructionData();
     495    rpcPic->prepareForEncoderSourcePicYuv();
    494496  }
    495497  else
    496498  {
    497499    if ( getUseAdaptiveQP() )
    498500    {
    499501      TEncPic* pcEPic = new TEncPic;
    500       pcEPic->create( m_cSPS, m_cPPS, m_cPPS.getMaxCuDQPDepth()+1, false);
     502      pcEPic->create( m_cSPS, m_cPPS, m_cPPS.getMaxCuDQPDepth()+1);
    501503      rpcPic = pcEPic;
    502504    }
    503505    else
    504506    {
    505507      rpcPic = new TComPic;
    506       rpcPic->create( m_cSPS, m_cPPS, false );
     508      rpcPic->create( m_cSPS, m_cPPS, true, false );
    507509    }
    508510
    509511    m_cListPic.pushBack( rpcPic );
     
    514516  m_iNumPicRcvd++;
    515517
    516518  rpcPic->getSlice(0)->setPOC( m_iPOCLast );
    517   // mark it should be extended
    518   rpcPic->getPicYuvRec()->setBorderExtension(false);
    519519}
    520520
    521521Void TEncTop::xInitVPS()