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

Last change on this file since 193 was 189, checked in by tech, 12 years ago

Reintegrated branch 4.1-dev0 Rev. 188.

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