source: 3DVCSoftware/trunk/source/Lib/TLibEncoder/TEncTop.cpp @ 605

Last change on this file since 605 was 443, checked in by tech, 12 years ago
  • Reintegrated branch 6.2-dev0 rev. 442.
  • Changed version number.
  • Added coding results.
  • Property svn:eol-style set to native
File size: 33.8 KB
RevLine 
[5]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
[56]4 * granted under this license. 
[5]5 *
[56]6 * Copyright (c) 2010-2012, ITU/ISO/IEC
[5]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.
[56]17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
[5]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 */
[2]33
34/** \file     TEncTop.cpp
35    \brief    encoder class
36*/
37
[56]38#include "TLibCommon/CommonDef.h"
[2]39#include "TEncTop.h"
[56]40#include "TEncPic.h"
[2]41#include "../../App/TAppEncoder/TAppEncTop.h"
[56]42#if FAST_BIT_EST
43#include "TLibCommon/ContextModel.h"
44#endif
[2]45
[56]46//! \ingroup TLibEncoder
47//! \{
48
[2]49// ====================================================================================================================
50// Constructor / destructor / create / destroy
51// ====================================================================================================================
52
53TEncTop::TEncTop()
54{
55  m_iPOCLast          = -1;
56  m_iNumPicRcvd       =  0;
57  m_uiNumAllPicCoded  =  0;
58  m_pppcRDSbacCoder   =  NULL;
59  m_pppcBinCoderCABAC =  NULL;
60  m_cRDGoOnSbacCoder.init( &m_cRDGoOnBinCoderCABAC );
61#if ENC_DEC_TRACE
62  g_hTrace = fopen( "TraceEnc.txt", "wb" );
63  g_bJustDoIt = g_bEncDecTraceDisable;
64  g_nSymbolCounter = 0;
65#endif
[56]66
67  m_iMaxRefPicNum     = 0;
68
69#if FAST_BIT_EST
70  ContextModel::buildNextStateTable();
71#endif
72
73  m_pcSbacCoders           = NULL;
74  m_pcBinCoderCABACs       = NULL;
75  m_ppppcRDSbacCoders      = NULL;
76  m_ppppcBinCodersCABAC    = NULL;
77  m_pcRDGoOnSbacCoders     = NULL;
78  m_pcRDGoOnBinCodersCABAC = NULL;
79  m_pcBitCounters          = NULL;
80  m_pcRdCosts              = NULL;
[2]81}
82
83TEncTop::~TEncTop()
84{
85#if ENC_DEC_TRACE
86  fclose( g_hTrace );
87#endif
88}
89
90Void TEncTop::create ()
91{
92  // initialize global variables
[105]93  if( m_viewId == 0 && m_isDepth == false )
94  {
95    initROM();
96  }
97
98
[2]99  // create processing unit classes
[56]100  m_cGOPEncoder.        create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight );
[2]101  m_cSliceEncoder.      create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
102  m_cCuEncoder.         create( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight );
103  if (m_bUseSAO)
104  {
[443]105#if LGE_SAO_MIGRATION_D0091
106    m_cEncSAO.setSaoLcuBoundary(getSaoLcuBoundary());
107    m_cEncSAO.setSaoLcuBasedOptimization(getSaoLcuBasedOptimization());
108#else
[56]109    m_cEncSAO.setSaoInterleavingFlag(getSaoInterleavingFlag());
[443]110#endif
[56]111    m_cEncSAO.setMaxNumOffsetsPerPic(getMaxNumOffsetsPerPic());
[2]112    m_cEncSAO.create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
113    m_cEncSAO.createEncBuffer();
114  }
[56]115#if ADAPTIVE_QP_SELECTION
116  if (m_bUseAdaptQpSelect)
117  {
118    m_cTrQuant.initSliceQpDelta();
119  }
[2]120#endif
121  m_cAdaptiveLoopFilter.create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
122  m_cLoopFilter.        create( g_uiMaxCUDepth );
[56]123 
[5]124#if DEPTH_MAP_GENERATION
[21]125  m_cDepthMapGenerator. create( false, getSourceWidth(), getSourceHeight(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiBitDepth + g_uiBitIncrement, PDM_SUB_SAMP_EXP_X(m_uiPredDepthMapGeneration), PDM_SUB_SAMP_EXP_Y(m_uiPredDepthMapGeneration) );
[5]126#endif
[443]127#if H3D_IVRP & !QC_ARP_D0177
[2]128  m_cResidualGenerator. create( false, getSourceWidth(), getSourceHeight(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiBitDepth + g_uiBitIncrement );
[5]129#endif
[2]130
131  if(m_bUseALF)
132  {
[56]133    m_cAdaptiveLoopFilter.setAlfCoefInSlice(m_bALFParamInSlice);
134    m_cAdaptiveLoopFilter.createAlfGlobalBuffers();
[2]135  }
136
[56]137  if(m_bUseSAO || m_bUseALF)
138  {
139    m_vAPS.reserve(MAX_NUM_SUPPORTED_APS);
140  }
141
[2]142  // if SBAC-based RD optimization is used
143  if( m_bUseSBACRD )
144  {
[56]145    m_pppcRDSbacCoder = new TEncSbac** [g_uiMaxCUDepth+1];
146#if FAST_BIT_EST
147    m_pppcBinCoderCABAC = new TEncBinCABACCounter** [g_uiMaxCUDepth+1];
148#else
149    m_pppcBinCoderCABAC = new TEncBinCABAC** [g_uiMaxCUDepth+1];
150#endif
151   
152    for ( Int iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ )
[2]153    {
154      m_pppcRDSbacCoder[iDepth] = new TEncSbac* [CI_NUM];
[56]155#if FAST_BIT_EST
156      m_pppcBinCoderCABAC[iDepth] = new TEncBinCABACCounter* [CI_NUM];
157#else
[2]158      m_pppcBinCoderCABAC[iDepth] = new TEncBinCABAC* [CI_NUM];
[56]159#endif
160     
[2]161      for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ )
162      {
163        m_pppcRDSbacCoder[iDepth][iCIIdx] = new TEncSbac;
[56]164#if FAST_BIT_EST
165        m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABACCounter;
166#else
[2]167        m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABAC;
[56]168#endif
[2]169        m_pppcRDSbacCoder   [iDepth][iCIIdx]->init( m_pppcBinCoderCABAC [iDepth][iCIIdx] );
170      }
171    }
172  }
[56]173  m_pcTAppEncTop = NULL;
[5]174#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
[56]175  if( g_aacWedgeLists.empty() && m_bUseDMM )
[2]176  {
177    initWedgeLists();
178  }
179#endif
180}
181
[56]182/**
183 - Allocate coders required for wavefront for the nominated number of substreams.
184 .
185 \param iNumSubstreams Determines how much information to allocate.
186 */
187Void TEncTop::createWPPCoders(Int iNumSubstreams)
188{
189  if (m_pcSbacCoders != NULL)
190    return; // already generated.
191
192  m_iNumSubstreams         = iNumSubstreams;
193  m_pcSbacCoders           = new TEncSbac       [iNumSubstreams];
194  m_pcBinCoderCABACs       = new TEncBinCABAC   [iNumSubstreams];
195  m_pcRDGoOnSbacCoders     = new TEncSbac       [iNumSubstreams];
196  m_pcRDGoOnBinCodersCABAC = new TEncBinCABAC   [iNumSubstreams];
197  m_pcBitCounters          = new TComBitCounter [iNumSubstreams];
198  m_pcRdCosts              = new TComRdCost     [iNumSubstreams];
199
200  for ( UInt ui = 0 ; ui < iNumSubstreams; ui++ )
201  {
202    m_pcRDGoOnSbacCoders[ui].init( &m_pcRDGoOnBinCodersCABAC[ui] );
203    m_pcSbacCoders[ui].init( &m_pcBinCoderCABACs[ui] );
204  }
205  if( m_bUseSBACRD )
206  {
207    m_ppppcRDSbacCoders      = new TEncSbac***    [iNumSubstreams];
208    m_ppppcBinCodersCABAC    = new TEncBinCABAC***[iNumSubstreams];
209    for ( UInt ui = 0 ; ui < iNumSubstreams ; ui++ )
210    {
211      m_ppppcRDSbacCoders[ui]  = new TEncSbac** [g_uiMaxCUDepth+1];
212      m_ppppcBinCodersCABAC[ui]= new TEncBinCABAC** [g_uiMaxCUDepth+1];
213     
214      for ( Int iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ )
215      {
216        m_ppppcRDSbacCoders[ui][iDepth]  = new TEncSbac*     [CI_NUM];
217        m_ppppcBinCodersCABAC[ui][iDepth]= new TEncBinCABAC* [CI_NUM];
218
219        for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ )
220        {
221          m_ppppcRDSbacCoders  [ui][iDepth][iCIIdx] = new TEncSbac;
222          m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx] = new TEncBinCABAC;
223          m_ppppcRDSbacCoders  [ui][iDepth][iCIIdx]->init( m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx] );
224        }
225      }
226    }
227  }
228}
229
[2]230Void TEncTop::destroy ()
231{
232  if(m_bUseALF)
233  {
234    m_cAdaptiveLoopFilter.destroyAlfGlobalBuffers();
235  }
236
[56]237  for(Int i=0; i< m_vAPS.size(); i++)
238  {
239    TComAPS& cAPS = m_vAPS[i];
240    m_cGOPEncoder.freeAPS(&cAPS, &m_cSPS);
241  }
242
[2]243  // destroy processing unit classes
[56]244  m_cGOPEncoder.        destroy();
[2]245  m_cSliceEncoder.      destroy();
246  m_cCuEncoder.         destroy();
247  if (m_cSPS.getUseSAO())
248  {
249    m_cEncSAO.destroy();
[56]250    m_cEncSAO.destroyEncBuffer();
[2]251  }
252  m_cAdaptiveLoopFilter.destroy();
253  m_cLoopFilter.        destroy();
[56]254
[5]255#if DEPTH_MAP_GENERATION
[2]256  m_cDepthMapGenerator. destroy();
[5]257#endif
[443]258#if H3D_IVRP & !QC_ARP_D0177
[2]259  m_cResidualGenerator. destroy();
[5]260#endif
[2]261
[56]262  m_RPSList.            destroy();
263 
[2]264  // SBAC RD
265  if( m_bUseSBACRD )
266  {
267    Int iDepth;
268    for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ )
269    {
270      for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ )
271      {
272        delete m_pppcRDSbacCoder[iDepth][iCIIdx];
273        delete m_pppcBinCoderCABAC[iDepth][iCIIdx];
274      }
275    }
[56]276   
[2]277    for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ )
278    {
279      delete [] m_pppcRDSbacCoder[iDepth];
280      delete [] m_pppcBinCoderCABAC[iDepth];
281    }
[56]282   
[2]283    delete [] m_pppcRDSbacCoder;
284    delete [] m_pppcBinCoderCABAC;
[56]285
286    for ( UInt ui = 0; ui < m_iNumSubstreams; ui++ )
287    {
288      for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ )
289      {
290        for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ )
291        {
292          delete m_ppppcRDSbacCoders  [ui][iDepth][iCIIdx];
293          delete m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx];
294        }
295      }
296
297      for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ )
298      {
299        delete [] m_ppppcRDSbacCoders  [ui][iDepth];
300        delete [] m_ppppcBinCodersCABAC[ui][iDepth];
301      }
302      delete[] m_ppppcRDSbacCoders  [ui];
303      delete[] m_ppppcBinCodersCABAC[ui];
304    }
305    delete[] m_ppppcRDSbacCoders;
306    delete[] m_ppppcBinCodersCABAC;
[2]307  }
[56]308  delete[] m_pcSbacCoders;
309  delete[] m_pcBinCoderCABACs;
310  delete[] m_pcRDGoOnSbacCoders; 
311  delete[] m_pcRDGoOnBinCodersCABAC;
312  delete[] m_pcBitCounters;
313  delete[] m_pcRdCosts;
314 
[2]315  // destroy ROM
[56]316  if(m_viewId == 0 && m_isDepth == false)
317  {
318  destroyROM();
319  }
320 
[2]321  return;
322}
323
324Void TEncTop::init( TAppEncTop* pcTAppEncTop )
325{
326  UInt *aTable4=NULL, *aTable8=NULL;
[56]327  UInt* aTableLastPosVlcIndex=NULL; 
[2]328  // initialize SPS
329  xInitSPS();
[56]330 
[2]331  // initialize PPS
[56]332  m_cPPS.setSPS(&m_cSPS);
333  m_cSPS.setRPSList(&m_RPSList);
[2]334  xInitPPS();
[56]335  xInitRPS();
[2]336
[56]337  xInitSPSforInterViewRefs();
338  xInitPPSforTiles();
339
[2]340  // initialize processing unit classes
[56]341  m_cGOPEncoder.  init( this );
[2]342  m_cSliceEncoder.init( this );
343  m_cCuEncoder.   init( this );
[56]344 
345  m_pcTAppEncTop = pcTAppEncTop;
[2]346
[5]347#if DEPTH_MAP_GENERATION
[77]348#if VIDYO_VPS_INTEGRATION
349  m_cDepthMapGenerator.init( (TComPrediction*)this->getPredSearch(), m_pcTAppEncTop->getVPSAccess(), m_pcTAppEncTop->getSPSAccess(), m_pcTAppEncTop->getAUPicAccess() );
350#else
[2]351  m_cDepthMapGenerator.init( (TComPrediction*)this->getPredSearch(), m_pcTAppEncTop->getSPSAccess(), m_pcTAppEncTop->getAUPicAccess() );
[5]352#endif
[77]353#endif
[443]354#if H3D_IVRP & !QC_ARP_D0177
[2]355  m_cResidualGenerator.init( &m_cTrQuant, &m_cDepthMapGenerator );
[5]356#endif
[2]357
358  // initialize transform & quantization class
359  m_pcCavlcCoder = getCavlcCoder();
[56]360 
361  m_cTrQuant.init( g_uiMaxCUWidth, g_uiMaxCUHeight, 1 << m_uiQuadtreeTULog2MaxSize,
362                  0,
363                  aTable4, aTable8, 
364                  aTableLastPosVlcIndex, m_bUseRDOQ, true 
365#if ADAPTIVE_QP_SELECTION                 
366                  , m_bUseAdaptQpSelect
[2]367#endif
[56]368                  );
369 
[2]370  // initialize encoder search class
[210]371#if DV_V_RESTRICTION_B0037
372  m_cSearch.init( this, &m_cTrQuant, m_iSearchRange, m_bipredSearchRange, m_bUseDisparitySearchRangeRestriction, m_iVerticalDisparitySearchRange, m_iFastSearch, 0, &m_cEntropyCoder, &m_cRdCost, getRDSbacCoder(), getRDGoOnSbacCoder() );
373#else
[2]374  m_cSearch.init( this, &m_cTrQuant, m_iSearchRange, m_bipredSearchRange, m_iFastSearch, 0, &m_cEntropyCoder, &m_cRdCost, getRDSbacCoder(), getRDGoOnSbacCoder() );
[210]375#endif
[2]376  if(m_bUseALF)
377  {
378    m_cAdaptiveLoopFilter.setALFEncodePassReduction( m_iALFEncodePassReduction );
[56]379    m_cAdaptiveLoopFilter.setALFMaxNumberFilters( m_iALFMaxNumberFilters );
380    m_cAdaptiveLoopFilter.initPicQuadTreePartition(m_bALFPicBasedEncode );   
[2]381  }
[56]382
383  m_iMaxRefPicNum = 0;
[2]384}
385
386// ====================================================================================================================
387// Public member functions
388// ====================================================================================================================
389
[56]390Void TEncTop::initNewPic( TComPicYuv* pcPicYuvOrg, TComPicYuv* pcOrgPdmDepth )
391{
392  TComPic* pcPicCurr = NULL;
393
394  // get original YUV
395  xGetNewPicBuffer( pcPicCurr );
396  pcPicYuvOrg->copyToPic( pcPicCurr->getPicYuvOrg() );
397
[296]398#if INTER_VIEW_VECTOR_SCALING_C0115
399  pcPicCurr->setViewOrderIdx(m_iViewOrderIdx);    // will be changed to view_id
[56]400#endif
401  pcPicCurr->setScaleOffset( m_aaiCodedScale, m_aaiCodedOffset );
402
[296]403#if H3D_IVMP
[56]404  if( m_uiMultiviewMvRegMode )
405  {
406    AOF( pcOrgPdmDepth );
407    AOF( pcPicCurr->getOrgDepthMap() );
408    pcOrgPdmDepth->copyToPic( pcPicCurr->getOrgDepthMap() );
409  }
410  else
411  {
412    AOT( pcOrgPdmDepth );
413    AOT( pcPicCurr->getOrgDepthMap() );
414  }
415#endif
416
417#if DEPTH_MAP_GENERATION
418  // add extra pic buffers
419  Bool  bNeedPrdDepthMapBuf = ( m_uiPredDepthMapGeneration > 0 );
420  if( bNeedPrdDepthMapBuf && !pcPicCurr->getPredDepthMap() )
421  {
422    pcPicCurr->addPrdDepthMapBuffer( PDM_SUB_SAMP_EXP_X(m_uiPredDepthMapGeneration), PDM_SUB_SAMP_EXP_Y(m_uiPredDepthMapGeneration) );
423  }
424#endif
425
426  // compute image characteristics
427  if ( getUseAdaptiveQP() )
428  {
429    m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcPicCurr ) );
430  }
431}
432
[2]433Void TEncTop::deletePicBuffer()
434{
435  TComList<TComPic*>::iterator iterPic = m_cListPic.begin();
436  Int iSize = Int( m_cListPic.size() );
[56]437 
[2]438  for ( Int i = 0; i < iSize; i++ )
439  {
440    TComPic* pcPic = *(iterPic++);
[56]441   
[2]442    pcPic->destroy();
443    delete pcPic;
444    pcPic = NULL;
445  }
446}
447
448/**
449 - Application has picture buffer list with size of GOP + 1
450 - Picture buffer list acts like as ring buffer
451 - End of the list has the latest picture
452 .
453 \param   bEos                true if end-of-sequence is reached
454 \param   pcPicYuvOrg         original YUV picture
455 \retval  rcListPicYuvRecOut  list of reconstruction YUV pictures
456 \retval  rcListBitstreamOut  list of output bitstreams
457 \retval  iNumEncoded         number of encoded pictures
458 */
[56]459Void TEncTop::encode( bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Int gopId )
460{ 
[2]461
[56]462  if( gopId == 0)
[2]463  {
[56]464    m_cGOPEncoder.initGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut); 
[2]465  }
466
467  {
[56]468    m_cGOPEncoder.compressPicInGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, gopId );
[2]469  }
[56]470 
471  if( gopId + 1 == m_cGOPEncoder.getGOPSize() )
[2]472  {
[56]473    iNumEncoded         = m_iNumPicRcvd;
474    m_iNumPicRcvd       = 0;
475    m_uiNumAllPicCoded += iNumEncoded;
[2]476  }
477}
478
479
[296]480#if HHI_INTERVIEW_SKIP || H3D_IVMP || H3D_IVRP
[2]481Void
482TEncTop::deleteExtraPicBuffers( Int iPoc )
483{
484  TComPic*                      pcPic = 0;
485  TComList<TComPic*>::iterator  cIter = m_cListPic.begin();
486  TComList<TComPic*>::iterator  cEnd  = m_cListPic.end  ();
487  for( ; cIter != cEnd; cIter++ )
488  {
489    if( (*cIter)->getPOC() == iPoc )
490    {
491      pcPic = *cIter;
492      break;
493    }
494  }
495  AOF( pcPic );
496  if ( pcPic )
497  {
[296]498#if H3D_IVMP
[2]499    pcPic->removeOrgDepthMapBuffer();
[5]500#endif
[296]501#if H3D_IVRP
[2]502    pcPic->removeResidualBuffer   ();
[5]503#endif
504#if HHI_INTERVIEW_SKIP
[2]505    pcPic->removeUsedPelsMapBuffer();
[5]506#endif
[2]507  }
508}
[56]509#endif
[2]510
511Void
512TEncTop::compressMotion( Int iPoc )
513{
514  TComPic*                      pcPic = 0;
515  TComList<TComPic*>::iterator  cIter = m_cListPic.begin();
516  TComList<TComPic*>::iterator  cEnd  = m_cListPic.end  ();
517  for( ; cIter != cEnd; cIter++ )
518  {
519    if( (*cIter)->getPOC() == iPoc )
520    {
521      pcPic = *cIter;
522      break;
523    }
524  }
525  AOF( pcPic );
526  if ( pcPic )
527  {
528    pcPic->compressMotion();
529  }
530}
531
532// ====================================================================================================================
533// Protected member functions
534// ====================================================================================================================
535
536/**
537 - Application has picture buffer list with size of GOP + 1
538 - Picture buffer list acts like as ring buffer
539 - End of the list has the latest picture
540 .
541 \retval rpcPic obtained picture buffer
542 */
543Void TEncTop::xGetNewPicBuffer ( TComPic*& rpcPic )
544{
545  TComSlice::sortPicList(m_cListPic);
[56]546 
547  if (m_cListPic.size() >= (UInt)(m_iGOPSize + getMaxDecPicBuffering(MAX_TLAYER-1) + 2) )
[2]548  {
[56]549    TComList<TComPic*>::iterator iterPic  = m_cListPic.begin();
550    Int iSize = Int( m_cListPic.size() );
551    for ( Int i = 0; i < iSize; i++ )
552    {
553      rpcPic = *(++iterPic);
554      if(rpcPic->getSlice(0)->isReferenced() == false)
555         break;
556    }
[2]557  }
558  else
559  {
[56]560        if ( getUseAdaptiveQP() )
561        {
562          TEncPic* pcEPic = new TEncPic;
563          pcEPic->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, m_cPPS.getMaxCuDQPDepth()+1 );
564          rpcPic = pcEPic;
565        }
566        else
567        {
568          rpcPic = new TComPic;
569          rpcPic->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
570        }
571    m_cListPic.pushBack( rpcPic );
[2]572  }
[56]573#if HHI_INTERVIEW_SKIP
574  if( m_bInterViewSkip )
575  {
576    rpcPic->addUsedPelsMapBuffer();
577  }
578#endif
[2]579  rpcPic->setReconMark (false);
[56]580 
[2]581  m_iPOCLast++;
582  m_iNumPicRcvd++;
[56]583 
[296]584#if H3D_IVMP
[2]585  if( m_uiMultiviewMvRegMode )
586  {
587    rpcPic->addOrgDepthMapBuffer();
588  }
[5]589#endif
[56]590 
[2]591  rpcPic->getSlice(0)->setPOC( m_iPOCLast );
592  // mark it should be extended
593  rpcPic->getPicYuvRec()->setBorderExtension(false);
[100]594  rpcPic->getPicYuvOrg()->setBorderExtension(false); 
[2]595}
596
597Void TEncTop::xInitSPS()
598{
[56]599  m_cSPS.setPicWidthInLumaSamples         ( m_iSourceWidth      );
600  m_cSPS.setPicHeightInLumaSamples        ( m_iSourceHeight     );
601  m_cSPS.setPicCroppingFlag( m_croppingMode!= 0 );
602  if (m_croppingMode != 0)
603  {
604    m_cSPS.setPicCropLeftOffset( m_cropLeft );
605    m_cSPS.setPicCropRightOffset( m_cropRight );
606    m_cSPS.setPicCropTopOffset( m_cropTop );
607    m_cSPS.setPicCropBottomOffset( m_cropBottom );
608  }
[2]609  m_cSPS.setMaxCUWidth    ( g_uiMaxCUWidth      );
610  m_cSPS.setMaxCUHeight   ( g_uiMaxCUHeight     );
611  m_cSPS.setMaxCUDepth    ( g_uiMaxCUDepth      );
612  m_cSPS.setMinTrDepth    ( 0                   );
613  m_cSPS.setMaxTrDepth    ( 1                   );
[56]614 
615  m_cSPS.setPCMLog2MinSize (m_uiPCMLog2MinSize);
616  m_cSPS.setUsePCM        ( m_usePCM           );
617  m_cSPS.setPCMLog2MaxSize( m_pcmLog2MaxSize  );
[2]618
619  m_cSPS.setUseALF        ( m_bUseALF           );
[56]620  if(m_bUseALF)
621  {
622    m_cSPS.setUseALFCoefInSlice(m_bALFParamInSlice);
623  }
624 
[189]625#if RWTH_SDC_DLT_B0036
626  m_cSPS.setUseDLT        ( m_bUseDLT );
627#endif
628 
[2]629  m_cSPS.setQuadtreeTULog2MaxSize( m_uiQuadtreeTULog2MaxSize );
630  m_cSPS.setQuadtreeTULog2MinSize( m_uiQuadtreeTULog2MinSize );
631  m_cSPS.setQuadtreeTUMaxDepthInter( m_uiQuadtreeTUMaxDepthInter    );
632  m_cSPS.setQuadtreeTUMaxDepthIntra( m_uiQuadtreeTUMaxDepthIntra    );
[56]633 
634#if LOSSLESS_CODING
635  m_cSPS.setUseLossless   ( m_useLossless  );
[2]636#endif
[56]637  m_cSPS.setUseLMChroma   ( m_bUseLMChroma           ); 
638 
639  m_cSPS.setMaxTrSize   ( 1 << m_uiQuadtreeTULog2MaxSize );
640 
641  m_cSPS.setUseLComb    ( m_bUseLComb           );
642  m_cSPS.setLCMod       ( m_bLCMod   );
643  m_cSPS.setUseNSQT( m_useNSQT );
644 
645  Int i;
646#if HHI_AMVP_OFF
647  for ( i = 0; i < g_uiMaxCUDepth; i++ )
648  {
649    m_cSPS.setAMVPMode( i, AM_NONE );
650  }
651#else
652  for ( i = 0; i < g_uiMaxCUDepth; i++ )
653  {
654    m_cSPS.setAMVPMode( i, AM_EXPL );
655  }
656#endif
657 
658  for (i = 0; i < g_uiMaxCUDepth-1; i++ )
659  {
660    m_cSPS.setAMPAcc( i, m_useAMP );
661    //m_cSPS.setAMPAcc( i, 1 );
662  }
[2]663
[56]664  m_cSPS.setUseAMP ( m_useAMP );
[2]665
[56]666  for (i = g_uiMaxCUDepth-1; i < g_uiMaxCUDepth; i++ )
667  {
668    m_cSPS.setAMPAcc(i, 0);
669  }
670
671  m_cSPS.setBitDepth    ( g_uiBitDepth        );
672  m_cSPS.setBitIncrement( g_uiBitIncrement    );
673  m_cSPS.setQpBDOffsetY ( (Int)(6*(g_uiBitDepth + g_uiBitIncrement - 8)) );
674  m_cSPS.setQpBDOffsetC ( (Int)(6*(g_uiBitDepth + g_uiBitIncrement - 8)) );
[2]675
[56]676  m_cSPS.setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag );
677  m_cSPS.setUseSAO( m_bUseSAO );
[2]678
[56]679  m_cSPS.setMaxTLayers( m_maxTempLayer );
680  m_cSPS.setTemporalIdNestingFlag( false );
681  for ( i = 0; i < m_cSPS.getMaxTLayers(); i++ )
682  {
683    m_cSPS.setMaxDecPicBuffering(m_maxDecPicBuffering[i], i);
684    m_cSPS.setNumReorderPics(m_numReorderPics[i], i);
685  }
686  m_cSPS.setPCMBitDepthLuma (g_uiPCMBitDepthLuma);
687  m_cSPS.setPCMBitDepthChroma (g_uiPCMBitDepthChroma);
688  m_cSPS.setPCMFilterDisableFlag  ( m_bPCMFilterDisableFlag );
[42]689
[56]690  m_cSPS.setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag );
691  m_cSPS.setUniformSpacingIdr( m_iUniformSpacingIdr );
692  m_cSPS.setNumColumnsMinus1( m_iNumColumnsMinus1 );
693  m_cSPS.setNumRowsMinus1( m_iNumRowsMinus1 );
694  if( m_iUniformSpacingIdr == 0 )
[2]695  {
[56]696    m_cSPS.setColumnWidth( m_puiColumnWidth );
697    m_cSPS.setRowHeight( m_puiRowHeight );
698  }
699  m_cSPS.setScalingListFlag ( (m_useScalingListId == 0) ? 0 : 1 );
700  m_cSPS.setUseDF( m_loopFilterOffsetInAPS );
701
702#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
703  m_cSPS.setUseDMM( m_bUseDMM );
704#endif
[210]705
706#if HHI_DMM_PRED_TEX && FLEX_CODING_ORDER_M23723
707  m_cSPS.setUseDMM34( m_bUseDMM34 );
708#endif
709
[332]710#if H3D_QTL
[189]711  m_cSPS.setUseQTLPC( m_bUseQTLPC );
[115]712#endif
[56]713#if HHI_MPI
714  m_cSPS.setUseMVI( m_bUseMVI );
715#endif
716
[443]717
718#if MTK_D0156
719#if MERL_VSP_COMPENSATION_C0152
720  m_cSPS.setUseVSPCompensation           ( m_bUseVSPCompensation );
721#endif
722  m_cSPS.setUseDVPRefine                 ( m_bUseDVPRefine       );
723#endif
724
[56]725  if( m_isDepth )
726  {
[313]727#if FCO_FIX_SPS_CHANGE
728    m_cSPS.initMultiviewSPSDepth    ( m_viewId, m_iViewOrderIdx, m_uiCamParPrecision, m_bCamParInSliceHeader, m_aaiCodedScale, m_aaiCodedOffset );
729#else
[56]730    m_cSPS.initMultiviewSPSDepth    ( m_viewId, m_iViewOrderIdx );
[313]731#endif
732
[5]733#if DEPTH_MAP_GENERATION
[56]734    m_cSPS.setPredDepthMapGeneration( m_viewId, true );
[5]735#endif
[296]736#if H3D_IVRP
[443]737#if QC_ARP_D0177
738    m_cSPS.setUseAdvRP              ( 0 );
739    m_cSPS.setARPStepNum            ( 1 );
740#else
[2]741    m_cSPS.setMultiviewResPredMode  ( 0 );
[5]742#endif
[443]743#endif
744
[2]745  }
746  else
747  {
[210]748#if QC_MVHEVC_B0046
749    m_cSPS.initMultiviewSPS   ( m_viewId);
750#else
[56]751    m_cSPS.initMultiviewSPS           ( m_viewId, m_iViewOrderIdx, m_uiCamParPrecision, m_bCamParInSliceHeader, m_aaiCodedScale, m_aaiCodedOffset );
[210]752#endif
[56]753    if( m_viewId )
[2]754    {
[5]755#if DEPTH_MAP_GENERATION
[296]756#if H3D_IVMP
[56]757      m_cSPS.setPredDepthMapGeneration( m_viewId, false, m_uiPredDepthMapGeneration, m_uiMultiviewMvPredMode, m_uiPdmPrecision, m_aaiPdmScaleNomDelta, m_aaiPdmOffset );
[5]758#else
[56]759      m_cSPS.setPredDepthMapGeneration( m_viewId, false, m_uiPredDepthMapGeneration, 0, m_uiPdmPrecision, m_aaiPdmScaleNomDelta, m_aaiPdmOffset );
[5]760#endif
761#endif
[296]762#if H3D_IVRP
[443]763#if QC_ARP_D0177
764     m_cSPS.setUseAdvRP  ( m_viewId > 0   ? m_nUseAdvResPred : 0 );
765     m_cSPS.setARPStepNum( m_viewId > 0   ? QC_ARP_WFNR      : 1 );
766#else
767     m_cSPS.setMultiviewResPredMode  ( m_uiMultiviewResPredMode );
[5]768#endif
[443]769#endif
[2]770    }
771    else
772    {
[5]773#if DEPTH_MAP_GENERATION
[56]774      m_cSPS.setPredDepthMapGeneration( m_viewId, false );
[5]775#endif
[296]776#if H3D_IVRP
[443]777#if QC_ARP_D0177
778      m_cSPS.setUseAdvRP              ( 0 );
779      m_cSPS.setARPStepNum            ( 1 );
780#else
[2]781      m_cSPS.setMultiviewResPredMode  ( 0 );
[5]782#endif
[443]783#endif
[2]784    }
785  }
[56]786}
[2]787
[56]788Void TEncTop::xInitPPS()
789{
790  m_cPPS.setConstrainedIntraPred( m_bUseConstrainedIntraPred );
791  m_cPPS.setSliceGranularity(m_iSliceGranularity);
792  Bool bUseDQP = (getMaxCuDQPDepth() > 0)? true : false;
[2]793
[56]794#if LOSSLESS_CODING
795  Int lowestQP = - m_cSPS.getQpBDOffsetY();
796
797  if(getUseLossless())
[2]798  {
[56]799    if ((getMaxCuDQPDepth() == 0) && (getMaxDeltaQP() == 0 ) && (getQP() == lowestQP) )
800    {
801      bUseDQP = false;
802    }
803    else
804    {
805      bUseDQP = true;
806    }
[2]807  }
[56]808  else
809  {
810    if(bUseDQP == false)
811    {
812      if((getMaxDeltaQP() != 0 )|| getUseAdaptiveQP())
813      {
814        bUseDQP = true;
815      }
816    }
817  }
818
[2]819#else
[56]820  if(bUseDQP == false)
[2]821  {
[56]822    if((getMaxDeltaQP() != 0 )|| getUseAdaptiveQP())
823    {
824      bUseDQP = true;
825    }
[2]826  }
827#endif
828
[56]829  if(bUseDQP)
830  {
831    m_cPPS.setUseDQP(true);
832    m_cPPS.setMaxCuDQPDepth( m_iMaxCuDQPDepth );
833    m_cPPS.setMinCuDQPSize( m_cPPS.getSPS()->getMaxCUWidth() >> ( m_cPPS.getMaxCuDQPDepth()) );
834  }
835  else
836  {
837    m_cPPS.setUseDQP(false);
838    m_cPPS.setMaxCuDQPDepth( 0 );
839    m_cPPS.setMinCuDQPSize( m_cPPS.getSPS()->getMaxCUWidth() >> ( m_cPPS.getMaxCuDQPDepth()) );
840  }
[2]841
[56]842  m_cPPS.setChromaQpOffset   ( m_iChromaQpOffset    );
843  m_cPPS.setChromaQpOffset2nd( m_iChromaQpOffset2nd );
[2]844
[56]845  m_cPPS.setEntropyCodingMode( 1 ); // In the PPS now, but also remains in slice header!
846  m_cPPS.setNumSubstreams(m_iWaveFrontSubstreams);
847  m_cPPS.setUseWP( m_bUseWeightPred );
848  m_cPPS.setWPBiPredIdc( m_uiBiPredIdc );
849  m_cPPS.setEnableTMVPFlag( m_bEnableTMVP );
850  m_cPPS.setOutputFlagPresentFlag( false );
851  m_cPPS.setSignHideFlag(getSignHideFlag());
852  m_cPPS.setTSIG(getTSIG());
853  m_cPPS.setDeblockingFilterControlPresent (m_DeblockingFilterControlPresent );
854  m_cPPS.setLog2ParallelMergeLevelMinus2      (LOG2_PARALLEL_MERGE_LEVEL_MINUS2);
855#if CABAC_INIT_FLAG
856  m_cPPS.setCabacInitPresentFlag(CABAC_INIT_PRESENT_FLAG);
[42]857#endif
[2]858}
859
[56]860//Function for initializing m_RPSList, a list of TComReferencePictureSet, based on the GOPEntry objects read from the config file.
861Void TEncTop::xInitRPS()
[2]862{
[56]863  TComReferencePictureSet*      rps;
864 
865  m_RPSList.create(getGOPSize()+m_extraRPSs);
866  for( Int i = 0; i < getGOPSize()+m_extraRPSs; i++) 
867  {
868    GOPEntryMvc ge = getGOPEntry(i);
869    rps = m_RPSList.getReferencePictureSet(i);
870    rps->setNumberOfPictures(ge.m_numRefPics);
871    rps->setNumRefIdc(ge.m_numRefIdc);
872    Int numNeg = 0;
873    Int numPos = 0;
874    for( Int j = 0; j < ge.m_numRefPics; j++)
[2]875    {
[56]876      rps->setDeltaPOC(j,ge.m_referencePics[j]);
877      rps->setUsed(j,ge.m_usedByCurrPic[j]);
878      if(ge.m_referencePics[j]>0)
879      {
880        numPos++;
881      }
882      else
883      {
884        numNeg++;
885      }
[2]886    }
[56]887    rps->setNumberOfNegativePictures(numNeg);
888    rps->setNumberOfPositivePictures(numPos);
889    rps->setInterRPSPrediction(ge.m_interRPSPrediction);
890    if (ge.m_interRPSPrediction)
[2]891    {
[56]892      rps->setDeltaRIdxMinus1(ge.m_deltaRIdxMinus1);
893      rps->setDeltaRPS(ge.m_deltaRPS);
894      rps->setNumRefIdc(ge.m_numRefIdc);
895      for (Int j = 0; j < ge.m_numRefIdc; j++ )
896      {
897        rps->setRefIdc(j, ge.m_refIdc[j]);
898      }
899#if WRITE_BACK
900      // the folowing code overwrite the deltaPOC and Used by current values read from the config file with the ones
901      // computed from the RefIdc.  This is not necessary if both are identical. Currently there is no check to see if they are identical.
902      numNeg = 0;
903      numPos = 0;
904      TComReferencePictureSet*     RPSRef = m_RPSList.getReferencePictureSet(i-(ge.m_deltaRIdxMinus1+1));
905      for (Int j = 0; j < ge.m_numRefIdc; j++ )
906      {
907        if (ge.m_refIdc[j])
908        {
909          Int deltaPOC = ge.m_deltaRPS + ((j < RPSRef->getNumberOfPictures())? RPSRef->getDeltaPOC(j) : 0);
910          rps->setDeltaPOC((numNeg+numPos),deltaPOC);
911          rps->setUsed((numNeg+numPos),ge.m_refIdc[j]==1?1:0);
912          if (deltaPOC<0)
913          {
914            numNeg++;
915          }
916          else
917          {
918            numPos++;
919          }
920        }
921      }
922      rps->setNumberOfNegativePictures(numNeg);
923      rps->setNumberOfPositivePictures(numPos);
924      rps->sortDeltaPOC();
925#endif
[2]926    }
[56]927  }
928 
929}
[2]930
[56]931   // This is a function that
932   // determines what Reference Picture Set to use
933   // for a specific slice (with POC = POCCurr)
934Void TEncTop::selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid,TComList<TComPic*>& listPic )
935{
[210]936#if QC_REM_IDV_B0046
937  if( (slice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR ||slice->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA) && slice->getSPS()->getViewId() && POCCurr == 0 )
938#else
[77]939  if( slice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDV && POCCurr == 0 )
[210]940#endif
[56]941  {
942    TComReferencePictureSet* rps = slice->getLocalRPS();
943    rps->setNumberOfNegativePictures(0);
944    rps->setNumberOfPositivePictures(0);
945    rps->setNumberOfLongtermPictures(0);
946    rps->setNumberOfPictures(0);
947    slice->setRPS(rps);
948  }
949  else
950  {
951    slice->setRPSidx(GOPid);
[2]952
[56]953    for(Int extraNum=m_iGOPSize; extraNum<m_extraRPSs+m_iGOPSize; extraNum++)
954    {   
955      if(m_uiIntraPeriod > 0)
956      {
957        if(POCCurr%m_uiIntraPeriod==m_GOPList[extraNum].m_POC)
958        {
959          slice->setRPSidx(extraNum);
960        }
961      }
962      else
963      {
964        if(POCCurr==m_GOPList[extraNum].m_POC)
965        {
966          slice->setRPSidx(extraNum);
967        }
968      }
969    }
[2]970
[56]971    slice->setRPS(getRPSList()->getReferencePictureSet(slice->getRPSidx()));
972    slice->getRPS()->setNumberOfPictures(slice->getRPS()->getNumberOfNegativePictures()+slice->getRPS()->getNumberOfPositivePictures());
973  }
[2]974}
975
[56]976Void TEncTop::xInitSPSforInterViewRefs()
[2]977{
[56]978  // base view
979  if( getGOPEntry( MAX_GOP ).m_POC == -1 )
980  { 
981    m_cSPS.setNumberOfUsableInterViewRefs( 0 );
982    m_cSPS.setListsModificationPresentFlag( false );
983    return;
984  }
[2]985
[56]986  Int numberUsableInterViewRefs = 0;
987  for( Int i = 0; i < getGOPSize()+1 && numberUsableInterViewRefs < MAX_VIEW_NUM; i++ ) 
[2]988  {
[56]989    GOPEntryMvc ge = ( i < getGOPSize() ) ? getGOPEntry( i ) : getGOPEntry( MAX_GOP );
990    for( Int j = 0; j < ge.m_numInterViewRefPics; j++ )
[2]991    {
[56]992      // add ref view to list
993      Bool onList = false;
994      for( Int k = 0; k < numberUsableInterViewRefs; k++ )
[2]995      {
[56]996        if( ge.m_interViewRefs[j] == m_cSPS.getUsableInterViewRef( k ) )
[2]997        {
[56]998          onList = true;
[2]999          break;
1000        }
1001      }
[56]1002      if( !onList )
[2]1003      {
[56]1004        m_cSPS.setUsableInterViewRef( (UInt)numberUsableInterViewRefs, ge.m_interViewRefs[j] );
1005        numberUsableInterViewRefs++;
[2]1006      }
1007    }
1008  }
[56]1009  m_cSPS.setNumberOfUsableInterViewRefs( numberUsableInterViewRefs );
1010
1011  // sort inter view refs
1012  for( Int j = 1; j < m_cSPS.getNumberOfUsableInterViewRefs(); j++ )
1013  { 
1014    Int deltaViewId = m_cSPS.getUsableInterViewRef( j );
1015    for( Int k = j-1; k >= 0; k-- )
1016    {
1017      Int temp = m_cSPS.getUsableInterViewRef( k );
1018      if( deltaViewId > temp )
1019      {
1020        m_cSPS.setUsableInterViewRef( k+1, temp );
1021        m_cSPS.setUsableInterViewRef( k, deltaViewId );
1022      }
1023    }
[2]1024  }
[56]1025
1026  m_cSPS.setListsModificationPresentFlag( true );
1027}
1028
1029Void  TEncTop::xInitPPSforTiles()
1030{
1031    m_cPPS.setColumnRowInfoPresent( m_iColumnRowInfoPresent );
1032    m_cPPS.setUniformSpacingIdr( m_iUniformSpacingIdr );
1033    m_cPPS.setNumColumnsMinus1( m_iNumColumnsMinus1 );
1034    m_cPPS.setNumRowsMinus1( m_iNumRowsMinus1 );
1035    if( m_iUniformSpacingIdr == 0 )
[2]1036    {
[56]1037      m_cPPS.setColumnWidth( m_puiColumnWidth );
1038      m_cPPS.setRowHeight( m_puiRowHeight );
[2]1039    }
[56]1040    m_cPPS.setTileBehaviorControlPresentFlag( m_iTileBehaviorControlPresentFlag );
1041    m_cPPS.setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag );
1042
1043    // # substreams is "per tile" when tiles are independent.
[121]1044    if ( m_iWaveFrontSynchro )
[2]1045    {
[56]1046      m_cPPS.setNumSubstreams(m_iWaveFrontSubstreams * (m_iNumColumnsMinus1+1)*(m_iNumRowsMinus1+1));
[2]1047    }
1048}
1049
[56]1050Void  TEncCfg::xCheckGSParameters()
[2]1051{
[56]1052  Int   iWidthInCU = ( m_iSourceWidth%g_uiMaxCUWidth ) ? m_iSourceWidth/g_uiMaxCUWidth + 1 : m_iSourceWidth/g_uiMaxCUWidth;
1053  Int   iHeightInCU = ( m_iSourceHeight%g_uiMaxCUHeight ) ? m_iSourceHeight/g_uiMaxCUHeight + 1 : m_iSourceHeight/g_uiMaxCUHeight;
1054  UInt  uiCummulativeColumnWidth = 0;
1055  UInt  uiCummulativeRowHeight = 0;
1056
1057  //check the column relative parameters
1058  if( m_iNumColumnsMinus1 >= (1<<(LOG2_MAX_NUM_COLUMNS_MINUS1+1)) )
[2]1059  {
[56]1060    printf( "The number of columns is larger than the maximum allowed number of columns.\n" );
1061    exit( EXIT_FAILURE );
[2]1062  }
[56]1063
1064  if( m_iNumColumnsMinus1 >= iWidthInCU )
[2]1065  {
[56]1066    printf( "The current picture can not have so many columns.\n" );
1067    exit( EXIT_FAILURE );
[2]1068  }
[56]1069
1070  if( m_iNumColumnsMinus1 && m_iUniformSpacingIdr==0 )
[2]1071  {
[56]1072    for(Int i=0; i<m_iNumColumnsMinus1; i++)
1073      uiCummulativeColumnWidth += m_puiColumnWidth[i];
1074
1075    if( uiCummulativeColumnWidth >= iWidthInCU )
1076    {
1077      printf( "The width of the column is too large.\n" );
1078      exit( EXIT_FAILURE );
1079    }
[2]1080  }
[56]1081
1082  //check the row relative parameters
1083  if( m_iNumRowsMinus1 >= (1<<(LOG2_MAX_NUM_ROWS_MINUS1+1)) )
[2]1084  {
[56]1085    printf( "The number of rows is larger than the maximum allowed number of rows.\n" );
1086    exit( EXIT_FAILURE );
[2]1087  }
[56]1088
1089  if( m_iNumRowsMinus1 >= iHeightInCU )
[2]1090  {
[56]1091    printf( "The current picture can not have so many rows.\n" );
1092    exit( EXIT_FAILURE );
[2]1093  }
1094
[56]1095  if( m_iNumRowsMinus1 && m_iUniformSpacingIdr==0 )
1096  {
1097    for(Int i=0; i<m_iNumRowsMinus1; i++)
1098      uiCummulativeRowHeight += m_puiRowHeight[i];
1099
1100    if( uiCummulativeRowHeight >= iHeightInCU )
1101    {
1102      printf( "The height of the row is too large.\n" );
1103      exit( EXIT_FAILURE );
1104    }
1105  }
[2]1106}
1107
[56]1108Void TEncTop::setTEncTopList(std::vector<TEncTop*>* pacTEncTopList )
1109{
1110  assert(m_viewId!=-1); // not to be set for single view coding
[2]1111
[56]1112  m_pacTEncTopList=pacTEncTopList;
1113
1114}
1115
1116Void TEncTop::printOutSummary(UInt uiNumAllPicCoded)
[2]1117{
[56]1118  assert (uiNumAllPicCoded == m_cAnalyzeAll.getNumPic());
[2]1119
[56]1120  //--CFG_KDY
1121  m_cAnalyzeAll.setFrmRate( getFrameRate() );
1122  m_cAnalyzeI.setFrmRate( getFrameRate() );
1123  m_cAnalyzeP.setFrmRate( getFrameRate() );
1124  m_cAnalyzeB.setFrmRate( getFrameRate() );
[2]1125
[56]1126  //-- all
1127  if(m_viewId==-1)
1128    printf( "\n\nSUMMARY --------------------------------------------------------\n" );
1129  else {
1130    if ( m_isDepth )
1131    {
1132      printf( "\n\nSUMMARY ---------------------------------------------- DEPTH %2d\n", m_viewId );
1133    }
1134    else
1135    {
1136      printf( "\n\nSUMMARY ---------------------------------------------- VIDEO %2d\n", m_viewId );
1137    }
1138  };
1139  m_cAnalyzeAll.printOut('a');
[2]1140
[56]1141  printf( "\n\nI Slices--------------------------------------------------------\n" );
1142  m_cAnalyzeI.printOut('i');
1143
1144  printf( "\n\nP Slices--------------------------------------------------------\n" );
1145  m_cAnalyzeP.printOut('p');
1146
1147  printf( "\n\nB Slices--------------------------------------------------------\n" );
1148  m_cAnalyzeB.printOut('b');
1149
1150//  m_cAnalyzeAll.printSummaryOut();
1151//  m_cAnalyzeI.printSummary('I');
1152//  m_cAnalyzeP.printSummary('P');
1153//  m_cAnalyzeB.printSummary('B');
[2]1154}
[56]1155
1156//! \}
Note: See TracBrowser for help on using the repository browser.