Changeset 1540 in SHVCSoftware for branches


Ignore:
Timestamp:
22 Mar 2016, 23:10:27 (9 years ago)
Author:
seregin
Message:

port rev 4692

Location:
branches/SHM-dev/source/Lib
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-dev/source/Lib/TLibCommon/TComPic.cpp

    r1512 r1540  
    7575TComPic::~TComPic()
    7676{
     77  destroy();
    7778}
    7879#if SVC_EXTENSION
    7980Void TComPic::create( const TComSPS &sps, const TComPPS &pps, const Bool bIsVirtual, const UInt layerId )
    8081{
     82  destroy();
     83
    8184  const ChromaFormat chromaFormatIDC = sps.getChromaFormatIdc();
    8285  const Int          iWidth          = sps.getPicWidthInLumaSamples();
     
    116119Void TComPic::create( const TComSPS &sps, const TComPPS &pps, const Bool bIsVirtual)
    117120{
     121  destroy();
     122
    118123  const ChromaFormat chromaFormatIDC = sps.getChromaFormatIdc();
    119124  const Int          iWidth          = sps.getPicWidthInLumaSamples();
  • branches/SHM-dev/source/Lib/TLibCommon/TComPicSym.cpp

    r1503 r1540  
    7777{}
    7878
     79
     80TComPicSym::~TComPicSym()
     81{
     82  destroy();
     83}
     84
    7985#if SVC_EXTENSION
    8086Void TComPicSym::create  ( const TComSPS &sps, const TComPPS &pps, UInt uiMaxDepth, const UInt layerId )
     
    8490{
    8591#endif
    86   UInt i;
     92  destroy();
     93
    8794  m_sps = sps;
    8895  m_pps = pps;
     
    9198  const Int iPicWidth      = sps.getPicWidthInLumaSamples();
    9299  const Int iPicHeight     = sps.getPicHeightInLumaSamples();
    93 
    94100  const UInt uiMaxCuWidth  = sps.getMaxCUWidth();
    95101  const UInt uiMaxCuHeight = sps.getMaxCUHeight();
     
    124130#endif
    125131
    126   for ( i=0; i<m_numCtusInFrame ; i++ )
     132  for (UInt i=0; i<m_numCtusInFrame ; i++ )
    127133  {
    128134    m_pictureCtuArray[i] = new TComDataCU;
     
    144150#endif 
    145151
    146   for( i=0; i<m_numCtusInFrame; i++ )
     152  for(UInt i=0; i<m_numCtusInFrame; i++ )
    147153  {
    148154    m_ctuTsToRsAddrMap[i] = i;
  • branches/SHM-dev/source/Lib/TLibCommon/TComPicSym.h

    r1520 r1540  
    140140
    141141  TComPicSym  ();
     142  ~TComPicSym();
     143
    142144  TComSlice*         getSlice(UInt i)                                      { return m_apSlices[i];             }
    143145  const TComSlice*   getSlice(UInt i) const                                { return m_apSlices[i];             }
  • branches/SHM-dev/source/Lib/TLibCommon/TComPicYuv.cpp

    r1460 r1540  
    7474TComPicYuv::~TComPicYuv()
    7575{
     76  destroy();
    7677}
    7778
     
    9091
    9192{
     93  destroy();
    9294
    9395#if SVC_EXTENSION
  • branches/SHM-dev/source/Lib/TLibCommon/TComYuv.cpp

    r1324 r1540  
    5959TComYuv::~TComYuv()
    6060{
     61  destroy();
    6162}
    6263
    6364Void TComYuv::create( UInt iWidth, UInt iHeight, ChromaFormat chromaFormatIDC )
    6465{
     66  destroy();
    6567  // set width and height
    6668  m_iWidth   = iWidth;
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp

    r1538 r1540  
    35873587  assert(noCol > 1);
    35883588  assert(noRows > 1);
    3589   UInt64 *colSAD = (UInt64*)malloc(noCol*sizeof(UInt64));
    3590   UInt64 *rowSAD = (UInt64*)malloc(noRows*sizeof(UInt64));
     3589  std::vector<UInt64> colSAD(noCol, UInt64(0));
     3590  std::vector<UInt64> rowSAD(noCol, UInt64(0));
    35913591  UInt colIdx = 0;
    35923592  UInt rowIdx = 0;
     
    36003600  const Int thr1 = 2*bitdepthScale;
    36013601  UInt a = 0;
    3602 
    3603   memset(colSAD, 0, noCol*sizeof(UInt64));
    3604   memset(rowSAD, 0, noRows*sizeof(UInt64));
    36053602
    36063603  if (maxTBsize > minBlockArtSize)
     
    36923689    }
    36933690  }
    3694 
    3695   free(colSAD);
    3696   free(rowSAD);
    36973691}
    36983692
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncSlice.cpp

    r1527 r1540  
    5050 : m_encCABACTableIdx(I_SLICE)
    5151{
    52   m_apcPicYuvPred = NULL;
    53   m_apcPicYuvResi = NULL;
    54 
    55   m_pdRdPicLambda = NULL;
    56   m_pdRdPicQp     = NULL;
    57   m_piRdPicQp     = NULL;
    5852}
    5953
    6054TEncSlice::~TEncSlice()
    6155{
     56  destroy();
    6257}
    6358
     
    6560{
    6661  // create prediction picture
    67   if ( m_apcPicYuvPred == NULL )
    68   {
    69     m_apcPicYuvPred  = new TComPicYuv;
    70     m_apcPicYuvPred->create( iWidth, iHeight, chromaFormat, iMaxCUWidth, iMaxCUHeight, uhTotalDepth, true );
    71   }
     62  m_picYuvPred.create( iWidth, iHeight, chromaFormat, iMaxCUWidth, iMaxCUHeight, uhTotalDepth, true );
    7263
    7364  // create residual picture
    74   if( m_apcPicYuvResi == NULL )
    75   {
    76     m_apcPicYuvResi  = new TComPicYuv;
    77     m_apcPicYuvResi->create( iWidth, iHeight, chromaFormat, iMaxCUWidth, iMaxCUHeight, uhTotalDepth, true );
    78   }
     65  m_picYuvResi.create( iWidth, iHeight, chromaFormat, iMaxCUWidth, iMaxCUHeight, uhTotalDepth, true );
    7966}
    8067
    8168Void TEncSlice::destroy()
    8269{
    83   // destroy prediction picture
    84   if ( m_apcPicYuvPred )
    85   {
    86     m_apcPicYuvPred->destroy();
    87     delete m_apcPicYuvPred;
    88     m_apcPicYuvPred  = NULL;
    89   }
    90 
    91   // destroy residual picture
    92   if ( m_apcPicYuvResi )
    93   {
    94     m_apcPicYuvResi->destroy();
    95     delete m_apcPicYuvResi;
    96     m_apcPicYuvResi  = NULL;
    97   }
     70  m_picYuvPred.destroy();
     71  m_picYuvResi.destroy();
    9872
    9973  // free lambda and QP arrays
    100   if ( m_pdRdPicLambda )
    101   {
    102     xFree( m_pdRdPicLambda );
    103     m_pdRdPicLambda = NULL;
    104   }
    105   if ( m_pdRdPicQp )
    106   {
    107     xFree( m_pdRdPicQp );
    108     m_pdRdPicQp = NULL;
    109   }
    110   if ( m_piRdPicQp )
    111   {
    112     xFree( m_piRdPicQp );
    113     m_piRdPicQp = NULL;
    114   }
     74  m_vdRdPicLambda.clear();
     75  m_vdRdPicQp.clear();
     76  m_viRdPicQp.clear();
    11577}
    11678
     
    13496
    13597  // create lambda and QP arrays
    136   m_pdRdPicLambda     = (Double*)xMalloc( Double, m_pcCfg->getDeltaQpRD() * 2 + 1 );
    137   m_pdRdPicQp         = (Double*)xMalloc( Double, m_pcCfg->getDeltaQpRD() * 2 + 1 );
    138   m_piRdPicQp         = (Int*   )xMalloc( Int,    m_pcCfg->getDeltaQpRD() * 2 + 1 );
     98  m_vdRdPicLambda.resize(m_pcCfg->getDeltaQpRD() * 2 + 1 );
     99  m_vdRdPicQp.resize(    m_pcCfg->getDeltaQpRD() * 2 + 1 );
     100  m_viRdPicQp.resize(    m_pcCfg->getDeltaQpRD() * 2 + 1 );
    139101  m_pcRateCtrl        = pcEncTop->getRateCtrl();
    140102
     
    416378    iQP = max( -rpcSlice->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA), min( MAX_QP, (Int) floor( dQP + 0.5 ) ) );
    417379
    418     m_pdRdPicLambda[iDQpIdx] = dLambda;
    419     m_pdRdPicQp    [iDQpIdx] = dQP;
    420     m_piRdPicQp    [iDQpIdx] = iQP;
     380    m_vdRdPicLambda[iDQpIdx] = dLambda;
     381    m_vdRdPicQp    [iDQpIdx] = dQP;
     382    m_viRdPicQp    [iDQpIdx] = iQP;
    421383  }
    422384
    423385  // obtain dQP = 0 case
    424   dLambda = m_pdRdPicLambda[0];
    425   dQP     = m_pdRdPicQp    [0];
    426   iQP     = m_piRdPicQp    [0];
     386  dLambda = m_vdRdPicLambda[0];
     387  dQP     = m_vdRdPicQp    [0];
     388  iQP     = m_viRdPicQp    [0];
    427389
    428390  const Int temporalId=m_pcCfg->getGOPEntry(iGOPid).m_temporalId;
     
    536498  rpcSlice->setTLayer( pcPic->getTLayer() );
    537499
    538   assert( m_apcPicYuvPred );
    539   assert( m_apcPicYuvResi );
    540 
    541   pcPic->setPicYuvPred( m_apcPicYuvPred );
    542   pcPic->setPicYuvResi( m_apcPicYuvResi );
     500  pcPic->setPicYuvPred( &m_picYuvPred );
     501  pcPic->setPicYuvResi( &m_picYuvResi );
    543502  rpcSlice->setSliceMode            ( m_pcCfg->getSliceMode()            );
    544503  rpcSlice->setSliceArgument        ( m_pcCfg->getSliceArgument()        );
     
    660619  if (m_pcCfg->getGOPSize() > 1)
    661620  {
    662     dFrameLambda = 0.68 * pow (2, (m_piRdPicQp[0]  - SHIFT_QP) / 3.0) * (pcSlice->isInterB()? 2 : 1);
     621    dFrameLambda = 0.68 * pow (2, (m_viRdPicQp[0]  - SHIFT_QP) / 3.0) * (pcSlice->isInterB()? 2 : 1);
    663622  }
    664623  else
    665624  {
    666     dFrameLambda = 0.68 * pow (2, (m_piRdPicQp[0] - SHIFT_QP) / 3.0);
     625    dFrameLambda = 0.68 * pow (2, (m_viRdPicQp[0] - SHIFT_QP) / 3.0);
    667626  }
    668627  m_pcRdCost      ->setFrameLambda(dFrameLambda);
     
    671630  for ( UInt uiQpIdx = 0; uiQpIdx < 2 * m_pcCfg->getDeltaQpRD() + 1; uiQpIdx++ )
    672631  {
    673     pcSlice       ->setSliceQp             ( m_piRdPicQp    [uiQpIdx] );
     632    pcSlice       ->setSliceQp             ( m_viRdPicQp    [uiQpIdx] );
    674633#if ADAPTIVE_QP_SELECTION
    675     pcSlice       ->setSliceQpBase         ( m_piRdPicQp    [uiQpIdx] );
    676 #endif
    677     setUpLambda(pcSlice, m_pdRdPicLambda[uiQpIdx], m_piRdPicQp    [uiQpIdx]);
     634    pcSlice       ->setSliceQpBase         ( m_viRdPicQp    [uiQpIdx] );
     635#endif
     636    setUpLambda(pcSlice, m_vdRdPicLambda[uiQpIdx], m_viRdPicQp    [uiQpIdx]);
    678637
    679638    // try compress
     
    699658
    700659  // set best values
    701   pcSlice       ->setSliceQp             ( m_piRdPicQp    [uiQpIdxBest] );
     660  pcSlice       ->setSliceQp             ( m_viRdPicQp    [uiQpIdxBest] );
    702661#if ADAPTIVE_QP_SELECTION
    703   pcSlice       ->setSliceQpBase         ( m_piRdPicQp    [uiQpIdxBest] );
    704 #endif
    705   setUpLambda(pcSlice, m_pdRdPicLambda[uiQpIdxBest], m_piRdPicQp    [uiQpIdxBest]);
     662  pcSlice       ->setSliceQpBase         ( m_viRdPicQp    [uiQpIdxBest] );
     663#endif
     664  setUpLambda(pcSlice, m_vdRdPicLambda[uiQpIdxBest], m_viRdPicQp    [uiQpIdxBest]);
    706665}
    707666
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncSlice.h

    r1391 r1540  
    6868  // pictures
    6969  TComList<TComPic*>*     m_pcListPic;                          ///< list of pictures
    70   TComPicYuv*             m_apcPicYuvPred;                      ///< prediction picture buffer
    71   TComPicYuv*             m_apcPicYuvResi;                      ///< residual picture buffer
     70  TComPicYuv              m_picYuvPred;                         ///< prediction picture buffer
     71  TComPicYuv              m_picYuvResi;                         ///< residual picture buffer
    7272
    7373  // processing units
     
    9191  UInt64                  m_uiPicDist;                          ///< total distortion for the picture
    9292  Double                  m_dPicRdCost;                         ///< picture-level RD cost
    93   Double*                 m_pdRdPicLambda;                      ///< array of lambda candidates
    94   Double*                 m_pdRdPicQp;                          ///< array of picture QP candidates (double-type for lambda)
    95   Int*                    m_piRdPicQp;                          ///< array of picture QP candidates (Int-type)
     93  std::vector<Double>     m_vdRdPicLambda;                      ///< array of lambda candidates
     94  std::vector<Double>     m_vdRdPicQp;                          ///< array of picture QP candidates (double-type for lambda)
     95  std::vector<Int>        m_viRdPicQp;                          ///< array of picture QP candidates (Int-type)
    9696  TEncRateCtrl*           m_pcRateCtrl;                         ///< Rate control manager
    9797  UInt                    m_uiSliceIdx;
Note: See TracChangeset for help on using the changeset viewer.