source: 3DVCSoftware/branches/HTM-DEV-0.1-dev/source/Lib/TLibEncoder/TEncTop.cpp @ 362

Last change on this file since 362 was 362, checked in by tech, 11 years ago

Update to HM-10.1.

  • Property svn:eol-style set to native
File size: 36.8 KB
Line 
1/* The copyright in this software is being made available under the BSD
2 * License, included below. This software may be subject to other third party
3 * and contributor rights, including patent rights, and no such rights are
4 * granted under this license. 
5 *
6 * Copyright (c) 2010-2013, ITU/ISO/IEC
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright notice,
13 *    this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above copyright notice,
15 *    this list of conditions and the following disclaimer in the documentation
16 *    and/or other materials provided with the distribution.
17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
18 *    be used to endorse or promote products derived from this software without
19 *    specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/** \file     TEncTop.cpp
35    \brief    encoder class
36*/
37
38#include "TLibCommon/CommonDef.h"
39#include "TEncTop.h"
40#include "TEncPic.h"
41#if FAST_BIT_EST
42#include "TLibCommon/ContextModel.h"
43#endif
44#if H_MV
45#include "../../App/TAppEncoder/TAppEncTop.h"
46#endif
47
48//! \ingroup TLibEncoder
49//! \{
50
51// ====================================================================================================================
52// Constructor / destructor / create / destroy
53// ====================================================================================================================
54
55TEncTop::TEncTop()
56{
57  m_iPOCLast          = -1;
58  m_iNumPicRcvd       =  0;
59  m_uiNumAllPicCoded  =  0;
60  m_pppcRDSbacCoder   =  NULL;
61  m_pppcBinCoderCABAC =  NULL;
62  m_cRDGoOnSbacCoder.init( &m_cRDGoOnBinCoderCABAC );
63#if ENC_DEC_TRACE
64  g_hTrace = fopen( "TraceEnc.txt", "wb" );
65  g_bJustDoIt = g_bEncDecTraceDisable;
66  g_nSymbolCounter = 0;
67#endif
68
69  m_iMaxRefPicNum     = 0;
70
71#if FAST_BIT_EST
72  ContextModel::buildNextStateTable();
73#endif
74
75  m_pcSbacCoders           = NULL;
76  m_pcBinCoderCABACs       = NULL;
77  m_ppppcRDSbacCoders      = NULL;
78  m_ppppcBinCodersCABAC    = NULL;
79  m_pcRDGoOnSbacCoders     = NULL;
80  m_pcRDGoOnBinCodersCABAC = NULL;
81  m_pcBitCounters          = NULL;
82  m_pcRdCosts              = NULL;
83#if H_MV
84  m_ivPicLists = NULL;
85#endif
86}
87
88TEncTop::~TEncTop()
89{
90#if ENC_DEC_TRACE
91  fclose( g_hTrace );
92#endif
93}
94
95Void TEncTop::create ()
96{
97#if !H_MV
98  // initialize global variables
99  initROM();
100#endif
101 
102  // create processing unit classes
103  m_cGOPEncoder.        create();
104  m_cSliceEncoder.      create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
105  m_cCuEncoder.         create( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight );
106  if (m_bUseSAO)
107  {
108    m_cEncSAO.setSaoLcuBoundary(getSaoLcuBoundary());
109    m_cEncSAO.setSaoLcuBasedOptimization(getSaoLcuBasedOptimization());
110    m_cEncSAO.setMaxNumOffsetsPerPic(getMaxNumOffsetsPerPic());
111    m_cEncSAO.create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight );
112    m_cEncSAO.createEncBuffer();
113  }
114#if ADAPTIVE_QP_SELECTION
115  if (m_bUseAdaptQpSelect)
116  {
117    m_cTrQuant.initSliceQpDelta();
118  }
119#endif
120  m_cLoopFilter.        create( g_uiMaxCUDepth );
121 
122#if RATE_CONTROL_LAMBDA_DOMAIN
123  if ( m_RCEnableRateControl )
124  {
125    m_cRateCtrl.init( m_framesToBeEncoded, m_RCTargetBitrate, m_iFrameRate, m_iGOPSize, m_iSourceWidth, m_iSourceHeight,
126                      g_uiMaxCUWidth, g_uiMaxCUHeight, m_RCKeepHierarchicalBit, m_RCUseLCUSeparateModel, m_GOPList );
127  }
128#else
129  m_cRateCtrl.create(getIntraPeriod(), getGOPSize(), getFrameRate(), getTargetBitrate(), getQP(), getNumLCUInUnit(), getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight);
130#endif
131  // if SBAC-based RD optimization is used
132  if( m_bUseSBACRD )
133  {
134    m_pppcRDSbacCoder = new TEncSbac** [g_uiMaxCUDepth+1];
135#if FAST_BIT_EST
136    m_pppcBinCoderCABAC = new TEncBinCABACCounter** [g_uiMaxCUDepth+1];
137#else
138    m_pppcBinCoderCABAC = new TEncBinCABAC** [g_uiMaxCUDepth+1];
139#endif
140   
141    for ( Int iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ )
142    {
143      m_pppcRDSbacCoder[iDepth] = new TEncSbac* [CI_NUM];
144#if FAST_BIT_EST
145      m_pppcBinCoderCABAC[iDepth] = new TEncBinCABACCounter* [CI_NUM];
146#else
147      m_pppcBinCoderCABAC[iDepth] = new TEncBinCABAC* [CI_NUM];
148#endif
149     
150      for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ )
151      {
152        m_pppcRDSbacCoder[iDepth][iCIIdx] = new TEncSbac;
153#if FAST_BIT_EST
154        m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABACCounter;
155#else
156        m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABAC;
157#endif
158        m_pppcRDSbacCoder   [iDepth][iCIIdx]->init( m_pppcBinCoderCABAC [iDepth][iCIIdx] );
159      }
160    }
161  }
162}
163
164/**
165 - Allocate coders required for wavefront for the nominated number of substreams.
166 .
167 \param iNumSubstreams Determines how much information to allocate.
168 */
169Void TEncTop::createWPPCoders(Int iNumSubstreams)
170{
171  if (m_pcSbacCoders != NULL)
172  {
173    return; // already generated.
174  }
175
176  m_iNumSubstreams         = iNumSubstreams;
177  m_pcSbacCoders           = new TEncSbac       [iNumSubstreams];
178  m_pcBinCoderCABACs       = new TEncBinCABAC   [iNumSubstreams];
179  m_pcRDGoOnSbacCoders     = new TEncSbac       [iNumSubstreams];
180  m_pcRDGoOnBinCodersCABAC = new TEncBinCABAC   [iNumSubstreams];
181  m_pcBitCounters          = new TComBitCounter [iNumSubstreams];
182  m_pcRdCosts              = new TComRdCost     [iNumSubstreams];
183
184  for ( UInt ui = 0 ; ui < iNumSubstreams; ui++ )
185  {
186    m_pcRDGoOnSbacCoders[ui].init( &m_pcRDGoOnBinCodersCABAC[ui] );
187    m_pcSbacCoders[ui].init( &m_pcBinCoderCABACs[ui] );
188  }
189  if( m_bUseSBACRD )
190  {
191    m_ppppcRDSbacCoders      = new TEncSbac***    [iNumSubstreams];
192    m_ppppcBinCodersCABAC    = new TEncBinCABAC***[iNumSubstreams];
193    for ( UInt ui = 0 ; ui < iNumSubstreams ; ui++ )
194    {
195      m_ppppcRDSbacCoders[ui]  = new TEncSbac** [g_uiMaxCUDepth+1];
196      m_ppppcBinCodersCABAC[ui]= new TEncBinCABAC** [g_uiMaxCUDepth+1];
197     
198      for ( Int iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ )
199      {
200        m_ppppcRDSbacCoders[ui][iDepth]  = new TEncSbac*     [CI_NUM];
201        m_ppppcBinCodersCABAC[ui][iDepth]= new TEncBinCABAC* [CI_NUM];
202
203        for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ )
204        {
205          m_ppppcRDSbacCoders  [ui][iDepth][iCIIdx] = new TEncSbac;
206          m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx] = new TEncBinCABAC;
207          m_ppppcRDSbacCoders  [ui][iDepth][iCIIdx]->init( m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx] );
208        }
209      }
210    }
211  }
212}
213
214Void TEncTop::destroy ()
215{
216  // destroy processing unit classes
217  m_cGOPEncoder.        destroy();
218  m_cSliceEncoder.      destroy();
219  m_cCuEncoder.         destroy();
220  if (m_cSPS.getUseSAO())
221  {
222    m_cEncSAO.destroy();
223    m_cEncSAO.destroyEncBuffer();
224  }
225  m_cLoopFilter.        destroy();
226  m_cRateCtrl.          destroy();
227  // SBAC RD
228  if( m_bUseSBACRD )
229  {
230    Int iDepth;
231    for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ )
232    {
233      for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ )
234      {
235        delete m_pppcRDSbacCoder[iDepth][iCIIdx];
236        delete m_pppcBinCoderCABAC[iDepth][iCIIdx];
237      }
238    }
239   
240    for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ )
241    {
242      delete [] m_pppcRDSbacCoder[iDepth];
243      delete [] m_pppcBinCoderCABAC[iDepth];
244    }
245   
246    delete [] m_pppcRDSbacCoder;
247    delete [] m_pppcBinCoderCABAC;
248
249    for ( UInt ui = 0; ui < m_iNumSubstreams; ui++ )
250    {
251      for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ )
252      {
253        for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ )
254        {
255          delete m_ppppcRDSbacCoders  [ui][iDepth][iCIIdx];
256          delete m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx];
257        }
258      }
259
260      for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ )
261      {
262        delete [] m_ppppcRDSbacCoders  [ui][iDepth];
263        delete [] m_ppppcBinCodersCABAC[ui][iDepth];
264      }
265      delete[] m_ppppcRDSbacCoders  [ui];
266      delete[] m_ppppcBinCodersCABAC[ui];
267    }
268    delete[] m_ppppcRDSbacCoders;
269    delete[] m_ppppcBinCodersCABAC;
270  }
271  delete[] m_pcSbacCoders;
272  delete[] m_pcBinCoderCABACs;
273  delete[] m_pcRDGoOnSbacCoders; 
274  delete[] m_pcRDGoOnBinCodersCABAC;
275  delete[] m_pcBitCounters;
276  delete[] m_pcRdCosts;
277 
278#if !H_MV
279    // destroy ROM
280  destroyROM();
281#endif
282
283  return;
284}
285
286Void TEncTop::init()
287{
288  // initialize SPS
289  xInitSPS();
290 
291  /* set the VPS profile information */
292  *m_cVPS.getPTL() = *m_cSPS.getPTL();
293#if L0043_TIMING_INFO
294  m_cVPS.getTimingInfo()->setTimingInfoPresentFlag       ( false );
295#endif
296  // initialize PPS
297  m_cPPS.setSPS(&m_cSPS);
298  xInitPPS();
299  xInitRPS();
300
301  xInitPPSforTiles();
302
303  // initialize processing unit classes
304  m_cGOPEncoder.  init( this );
305  m_cSliceEncoder.init( this );
306  m_cCuEncoder.   init( this );
307 
308  // initialize transform & quantization class
309  m_pcCavlcCoder = getCavlcCoder();
310 
311  m_cTrQuant.init( 1 << m_uiQuadtreeTULog2MaxSize,
312                  m_useRDOQ, 
313                  m_useRDOQTS,
314                  true 
315                  ,m_useTransformSkipFast
316#if ADAPTIVE_QP_SELECTION                 
317                  , m_bUseAdaptQpSelect
318#endif
319                  );
320 
321  // initialize encoder search class
322  m_cSearch.init( this, &m_cTrQuant, m_iSearchRange, m_bipredSearchRange, m_iFastSearch, 0, &m_cEntropyCoder, &m_cRdCost, getRDSbacCoder(), getRDGoOnSbacCoder() );
323
324  m_iMaxRefPicNum = 0;
325}
326
327// ====================================================================================================================
328// Public member functions
329// ====================================================================================================================
330
331#if H_MV
332Void TEncTop::initNewPic( TComPicYuv* pcPicYuvOrg )
333{
334  TComPic* pcPicCurr = NULL;
335
336  // get original YUV
337  xGetNewPicBuffer( pcPicCurr );
338  pcPicYuvOrg->copyToPic( pcPicCurr->getPicYuvOrg() );
339
340  // compute image characteristics
341  if ( getUseAdaptiveQP() )
342  {
343    m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcPicCurr ) );
344  }
345}
346#endif
347Void TEncTop::deletePicBuffer()
348{
349  TComList<TComPic*>::iterator iterPic = m_cListPic.begin();
350  Int iSize = Int( m_cListPic.size() );
351 
352  for ( Int i = 0; i < iSize; i++ )
353  {
354    TComPic* pcPic = *(iterPic++);
355   
356    pcPic->destroy();
357    delete pcPic;
358    pcPic = NULL;
359  }
360}
361
362/**
363 - Application has picture buffer list with size of GOP + 1
364 - Picture buffer list acts like as ring buffer
365 - End of the list has the latest picture
366 .
367 \param   flush               cause encoder to encode a partial GOP
368 \param   pcPicYuvOrg         original YUV picture
369 \retval  rcListPicYuvRecOut  list of reconstruction YUV pictures
370 \retval  rcListBitstreamOut  list of output bitstreams
371 \retval  iNumEncoded         number of encoded pictures
372 */
373#if H_MV
374Void TEncTop::encode(Bool flush, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded , Int gopId )
375{
376#else
377Void TEncTop::encode(Bool flush, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded )
378{
379#endif
380#if H_3D
381  TComPic* picLastCoded = getPic( getGOPEncoder()->getPocLastCoded() );
382  if( picLastCoded )
383  {
384    picLastCoded->compressMotion(); 
385  }
386#endif
387#if H_MV
388  if( gopId == 0)
389  {
390    m_cGOPEncoder.initGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut); 
391#else
392  if (pcPicYuvOrg) {
393    // get original YUV
394    TComPic* pcPicCurr = NULL;
395    xGetNewPicBuffer( pcPicCurr );
396    pcPicYuvOrg->copyToPic( pcPicCurr->getPicYuvOrg() );
397
398    // compute image characteristics
399    if ( getUseAdaptiveQP() )
400    {
401      m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcPicCurr ) );
402    }
403  }
404 
405  if (!m_iNumPicRcvd || (!flush && m_iPOCLast != 0 && m_iNumPicRcvd != m_iGOPSize && m_iGOPSize))
406  {
407    iNumEncoded = 0;
408    return;
409  }
410#endif
411 
412#if RATE_CONTROL_LAMBDA_DOMAIN
413  if ( m_RCEnableRateControl )
414  {
415    m_cRateCtrl.initRCGOP( m_iNumPicRcvd );
416  }
417#endif
418
419#if H_MV
420  }
421  m_cGOPEncoder.compressPicInGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, gopId );
422
423  if( gopId + 1 == m_cGOPEncoder.getGOPSize() )
424  {
425#else
426  // compress GOP
427  m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut);
428#endif
429
430#if RATE_CONTROL_LAMBDA_DOMAIN
431  if ( m_RCEnableRateControl )
432  {
433    m_cRateCtrl.destroyRCGOP();
434  }
435#endif
436 
437  iNumEncoded         = m_iNumPicRcvd;
438  m_iNumPicRcvd       = 0;
439  m_uiNumAllPicCoded += iNumEncoded;
440
441#if H_MV
442}
443#endif
444
445}
446
447// ====================================================================================================================
448// Protected member functions
449// ====================================================================================================================
450
451/**
452 - Application has picture buffer list with size of GOP + 1
453 - Picture buffer list acts like as ring buffer
454 - End of the list has the latest picture
455 .
456 \retval rpcPic obtained picture buffer
457 */
458Void TEncTop::xGetNewPicBuffer ( TComPic*& rpcPic )
459{
460  TComSlice::sortPicList(m_cListPic);
461 
462  if (m_cListPic.size() >= (UInt)(m_iGOPSize + getMaxDecPicBuffering(MAX_TLAYER-1) + 2) )
463  {
464    TComList<TComPic*>::iterator iterPic  = m_cListPic.begin();
465    Int iSize = Int( m_cListPic.size() );
466    for ( Int i = 0; i < iSize; i++ )
467    {
468      rpcPic = *(iterPic++);
469      if(rpcPic->getSlice(0)->isReferenced() == false)
470      {
471        break;
472      }
473    }
474  }
475  else
476  {
477    if ( getUseAdaptiveQP() )
478    {
479      TEncPic* pcEPic = new TEncPic;
480      pcEPic->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, m_cPPS.getMaxCuDQPDepth()+1 ,
481                      m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics);
482      rpcPic = pcEPic;
483    }
484    else
485    {
486      rpcPic = new TComPic;
487
488      rpcPic->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, 
489                      m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics);
490    }
491    if (getUseSAO())
492    {
493      rpcPic->getPicSym()->allocSaoParam(&m_cEncSAO);
494    }
495    m_cListPic.pushBack( rpcPic );
496  }
497  rpcPic->setReconMark (false);
498 
499  m_iPOCLast++;
500  m_iNumPicRcvd++;
501 
502  rpcPic->getSlice(0)->setPOC( m_iPOCLast );
503  // mark it should be extended
504  rpcPic->getPicYuvRec()->setBorderExtension(false);
505}
506
507Void TEncTop::xInitSPS()
508{
509#if H_MV
510  m_cSPS.setSPSId( getLayerIdInVps() );
511#endif
512  ProfileTierLevel& profileTierLevel = *m_cSPS.getPTL()->getGeneralPTL();
513  profileTierLevel.setLevelIdc(m_level);
514  profileTierLevel.setTierFlag(m_levelTier);
515  profileTierLevel.setProfileIdc(m_profile);
516  profileTierLevel.setProfileCompatibilityFlag(m_profile, 1);
517#if L0046_CONSTRAINT_FLAGS
518  profileTierLevel.setProgressiveSourceFlag(m_progressiveSourceFlag);
519  profileTierLevel.setInterlacedSourceFlag(m_interlacedSourceFlag);
520  profileTierLevel.setNonPackedConstraintFlag(m_nonPackedConstraintFlag);
521  profileTierLevel.setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag);
522#endif
523 
524  if (m_profile == Profile::MAIN10 && g_bitDepthY == 8 && g_bitDepthC == 8)
525  {
526    /* The above constraint is equal to Profile::MAIN */
527    profileTierLevel.setProfileCompatibilityFlag(Profile::MAIN, 1);
528  }
529  if (m_profile == Profile::MAIN)
530  {
531    /* A Profile::MAIN10 decoder can always decode Profile::MAIN */
532    profileTierLevel.setProfileCompatibilityFlag(Profile::MAIN10, 1);
533  }
534  /* XXX: should Main be marked as compatible with still picture? */
535  /* XXX: may be a good idea to refactor the above into a function
536   * that chooses the actual compatibility based upon options */
537
538  m_cSPS.setPicWidthInLumaSamples         ( m_iSourceWidth      );
539  m_cSPS.setPicHeightInLumaSamples        ( m_iSourceHeight     );
540  m_cSPS.setConformanceWindow             ( m_conformanceWindow );
541  m_cSPS.setMaxCUWidth    ( g_uiMaxCUWidth      );
542  m_cSPS.setMaxCUHeight   ( g_uiMaxCUHeight     );
543  m_cSPS.setMaxCUDepth    ( g_uiMaxCUDepth      );
544
545  Int minCUSize = m_cSPS.getMaxCUWidth() >> ( m_cSPS.getMaxCUDepth()-g_uiAddCUDepth );
546  Int log2MinCUSize = 0;
547  while(minCUSize > 1)
548  {
549    minCUSize >>= 1;
550    log2MinCUSize++;
551  }
552
553  m_cSPS.setLog2MinCodingBlockSize(log2MinCUSize);
554  m_cSPS.setLog2DiffMaxMinCodingBlockSize(m_cSPS.getMaxCUDepth()-g_uiAddCUDepth);
555 
556  m_cSPS.setPCMLog2MinSize (m_uiPCMLog2MinSize);
557  m_cSPS.setUsePCM        ( m_usePCM           );
558  m_cSPS.setPCMLog2MaxSize( m_pcmLog2MaxSize  );
559
560  m_cSPS.setQuadtreeTULog2MaxSize( m_uiQuadtreeTULog2MaxSize );
561  m_cSPS.setQuadtreeTULog2MinSize( m_uiQuadtreeTULog2MinSize );
562  m_cSPS.setQuadtreeTUMaxDepthInter( m_uiQuadtreeTUMaxDepthInter    );
563  m_cSPS.setQuadtreeTUMaxDepthIntra( m_uiQuadtreeTUMaxDepthIntra    );
564 
565  m_cSPS.setTMVPFlagsPresent(false);
566  m_cSPS.setUseLossless   ( m_useLossless  );
567
568  m_cSPS.setMaxTrSize   ( 1 << m_uiQuadtreeTULog2MaxSize );
569#if !L0034_COMBINED_LIST_CLEANUP
570  m_cSPS.setUseLComb    ( m_bUseLComb           );
571#endif
572 
573  Int i;
574 
575  for (i = 0; i < g_uiMaxCUDepth-g_uiAddCUDepth; i++ )
576  {
577    m_cSPS.setAMPAcc( i, m_useAMP );
578    //m_cSPS.setAMPAcc( i, 1 );
579  }
580
581  m_cSPS.setUseAMP ( m_useAMP );
582
583  for (i = g_uiMaxCUDepth-g_uiAddCUDepth; i < g_uiMaxCUDepth; i++ )
584  {
585    m_cSPS.setAMPAcc(i, 0);
586  }
587
588  m_cSPS.setBitDepthY( g_bitDepthY );
589  m_cSPS.setBitDepthC( g_bitDepthC );
590
591  m_cSPS.setQpBDOffsetY ( 6*(g_bitDepthY - 8) );
592  m_cSPS.setQpBDOffsetC ( 6*(g_bitDepthC - 8) );
593
594  m_cSPS.setUseSAO( m_bUseSAO );
595
596  m_cSPS.setMaxTLayers( m_maxTempLayer );
597  m_cSPS.setTemporalIdNestingFlag( ( m_maxTempLayer == 1 ) ? true : false );
598  for ( i = 0; i < m_cSPS.getMaxTLayers(); i++ )
599  {
600    m_cSPS.setMaxDecPicBuffering(m_maxDecPicBuffering[i], i);
601    m_cSPS.setNumReorderPics(m_numReorderPics[i], i);
602  }
603  m_cSPS.setPCMBitDepthLuma (g_uiPCMBitDepthLuma);
604  m_cSPS.setPCMBitDepthChroma (g_uiPCMBitDepthChroma);
605  m_cSPS.setPCMFilterDisableFlag  ( m_bPCMFilterDisableFlag );
606
607  m_cSPS.setScalingListFlag ( (m_useScalingListId == 0) ? 0 : 1 );
608
609  m_cSPS.setUseStrongIntraSmoothing( m_useStrongIntraSmoothing );
610
611  m_cSPS.setVuiParametersPresentFlag(getVuiParametersPresentFlag());
612  if (m_cSPS.getVuiParametersPresentFlag())
613  {
614    TComVUI* pcVUI = m_cSPS.getVuiParameters();
615    pcVUI->setAspectRatioInfoPresentFlag(getAspectRatioIdc() != -1);
616    pcVUI->setAspectRatioIdc(getAspectRatioIdc());
617    pcVUI->setSarWidth(getSarWidth());
618    pcVUI->setSarHeight(getSarHeight());
619    pcVUI->setOverscanInfoPresentFlag(getOverscanInfoPresentFlag());
620    pcVUI->setOverscanAppropriateFlag(getOverscanAppropriateFlag());
621    pcVUI->setVideoSignalTypePresentFlag(getVideoSignalTypePresentFlag());
622    pcVUI->setVideoFormat(getVideoFormat());
623    pcVUI->setVideoFullRangeFlag(getVideoFullRangeFlag());
624    pcVUI->setColourDescriptionPresentFlag(getColourDescriptionPresentFlag());
625    pcVUI->setColourPrimaries(getColourPrimaries());
626    pcVUI->setTransferCharacteristics(getTransferCharacteristics());
627    pcVUI->setMatrixCoefficients(getMatrixCoefficients());
628    pcVUI->setChromaLocInfoPresentFlag(getChromaLocInfoPresentFlag());
629    pcVUI->setChromaSampleLocTypeTopField(getChromaSampleLocTypeTopField());
630    pcVUI->setChromaSampleLocTypeBottomField(getChromaSampleLocTypeBottomField());
631    pcVUI->setNeutralChromaIndicationFlag(getNeutralChromaIndicationFlag());
632    pcVUI->setDefaultDisplayWindow(getDefaultDisplayWindow());
633    pcVUI->setFrameFieldInfoPresentFlag(getFrameFieldInfoPresentFlag());
634    pcVUI->setFieldSeqFlag(false);
635    pcVUI->setHrdParametersPresentFlag(false);
636#if L0043_TIMING_INFO
637    pcVUI->getTimingInfo()->setPocProportionalToTimingFlag(getPocProportionalToTimingFlag());
638    pcVUI->getTimingInfo()->setNumTicksPocDiffOneMinus1   (getNumTicksPocDiffOneMinus1()   );
639#else
640    pcVUI->setPocProportionalToTimingFlag(getPocProportionalToTimingFlag());
641    pcVUI->setNumTicksPocDiffOneMinus1   (getNumTicksPocDiffOneMinus1()   );
642#endif
643    pcVUI->setBitstreamRestrictionFlag(getBitstreamRestrictionFlag());
644    pcVUI->setTilesFixedStructureFlag(getTilesFixedStructureFlag());
645    pcVUI->setMotionVectorsOverPicBoundariesFlag(getMotionVectorsOverPicBoundariesFlag());
646    pcVUI->setMinSpatialSegmentationIdc(getMinSpatialSegmentationIdc());
647    pcVUI->setMaxBytesPerPicDenom(getMaxBytesPerPicDenom());
648    pcVUI->setMaxBitsPerMinCuDenom(getMaxBitsPerMinCuDenom());
649    pcVUI->setLog2MaxMvLengthHorizontal(getLog2MaxMvLengthHorizontal());
650    pcVUI->setLog2MaxMvLengthVertical(getLog2MaxMvLengthVertical());
651  }
652}
653
654Void TEncTop::xInitPPS()
655{
656#if H_MV
657  if( m_cVPS.getNumDirectRefLayers( getLayerIdInVps() ) > 0 )
658  {
659    m_cPPS.setListsModificationPresentFlag( true );
660  }
661  m_cPPS.setPPSId( getLayerIdInVps() );
662  m_cPPS.setSPSId( getLayerIdInVps() );
663#endif
664  m_cPPS.setConstrainedIntraPred( m_bUseConstrainedIntraPred );
665  Bool bUseDQP = (getMaxCuDQPDepth() > 0)? true : false;
666
667  Int lowestQP = - m_cSPS.getQpBDOffsetY();
668
669  if(getUseLossless())
670  {
671    if ((getMaxCuDQPDepth() == 0) && (getMaxDeltaQP() == 0 ) && (getQP() == lowestQP) )
672    {
673      bUseDQP = false;
674    }
675    else
676    {
677      bUseDQP = true;
678    }
679  }
680  else
681  {
682    if(bUseDQP == false)
683    {
684      if((getMaxDeltaQP() != 0 )|| getUseAdaptiveQP())
685      {
686        bUseDQP = true;
687      }
688    }
689  }
690
691  if(bUseDQP)
692  {
693    m_cPPS.setUseDQP(true);
694    m_cPPS.setMaxCuDQPDepth( m_iMaxCuDQPDepth );
695    m_cPPS.setMinCuDQPSize( m_cPPS.getSPS()->getMaxCUWidth() >> ( m_cPPS.getMaxCuDQPDepth()) );
696  }
697  else
698  {
699    m_cPPS.setUseDQP(false);
700    m_cPPS.setMaxCuDQPDepth( 0 );
701    m_cPPS.setMinCuDQPSize( m_cPPS.getSPS()->getMaxCUWidth() >> ( m_cPPS.getMaxCuDQPDepth()) );
702  }
703
704#if RATE_CONTROL_LAMBDA_DOMAIN
705  if ( m_RCEnableRateControl )
706  {
707    m_cPPS.setUseDQP(true);
708    m_cPPS.setMaxCuDQPDepth( 0 );
709    m_cPPS.setMinCuDQPSize( m_cPPS.getSPS()->getMaxCUWidth() >> ( m_cPPS.getMaxCuDQPDepth()) );
710  } 
711#endif
712
713  m_cPPS.setChromaCbQpOffset( m_chromaCbQpOffset );
714  m_cPPS.setChromaCrQpOffset( m_chromaCrQpOffset );
715
716  m_cPPS.setNumSubstreams(m_iWaveFrontSubstreams);
717  m_cPPS.setEntropyCodingSyncEnabledFlag( m_iWaveFrontSynchro > 0 );
718  m_cPPS.setTilesEnabledFlag( (m_iNumColumnsMinus1 > 0 || m_iNumRowsMinus1 > 0) );
719  m_cPPS.setUseWP( m_useWeightedPred );
720  m_cPPS.setWPBiPred( m_useWeightedBiPred );
721  m_cPPS.setOutputFlagPresentFlag( false );
722  m_cPPS.setSignHideFlag(getSignHideFlag());
723#if L0386_DB_METRIC
724  if ( getDeblockingFilterMetric() )
725  {
726    m_cPPS.setDeblockingFilterControlPresentFlag (true);
727    m_cPPS.setDeblockingFilterOverrideEnabledFlag(true);
728    m_cPPS.setPicDisableDeblockingFilterFlag(false);
729    m_cPPS.setDeblockingFilterBetaOffsetDiv2(0);
730    m_cPPS.setDeblockingFilterTcOffsetDiv2(0);
731  } 
732  else
733  {
734  m_cPPS.setDeblockingFilterControlPresentFlag (m_DeblockingFilterControlPresent );
735  }
736#else
737  m_cPPS.setDeblockingFilterControlPresentFlag (m_DeblockingFilterControlPresent );
738#endif
739  m_cPPS.setLog2ParallelMergeLevelMinus2   (m_log2ParallelMergeLevelMinus2 );
740  m_cPPS.setCabacInitPresentFlag(CABAC_INIT_PRESENT_FLAG);
741  m_cPPS.setLoopFilterAcrossSlicesEnabledFlag( m_bLFCrossSliceBoundaryFlag );
742  Int histogram[MAX_NUM_REF + 1];
743  for( Int i = 0; i <= MAX_NUM_REF; i++ )
744  {
745    histogram[i]=0;
746  }
747  for( Int i = 0; i < getGOPSize(); i++ )
748  {
749    assert(getGOPEntry(i).m_numRefPicsActive >= 0 && getGOPEntry(i).m_numRefPicsActive <= MAX_NUM_REF);
750    histogram[getGOPEntry(i).m_numRefPicsActive]++;
751  }
752  Int maxHist=-1;
753  Int bestPos=0;
754  for( Int i = 0; i <= MAX_NUM_REF; i++ )
755  {
756    if(histogram[i]>maxHist)
757    {
758      maxHist=histogram[i];
759      bestPos=i;
760    }
761  }
762#if L0323_LIMIT_DEFAULT_LIST_SIZE
763  assert(bestPos <= 15);
764#endif
765  m_cPPS.setNumRefIdxL0DefaultActive(bestPos);
766  m_cPPS.setNumRefIdxL1DefaultActive(bestPos);
767  m_cPPS.setTransquantBypassEnableFlag(getTransquantBypassEnableFlag());
768  m_cPPS.setUseTransformSkip( m_useTransformSkip );
769  if (m_sliceSegmentMode)
770  {
771    m_cPPS.setDependentSliceSegmentsEnabledFlag( true );
772  }
773  if( m_cPPS.getDependentSliceSegmentsEnabledFlag() )
774  {
775    Int NumCtx = m_cPPS.getEntropyCodingSyncEnabledFlag()?2:1;
776    m_cSliceEncoder.initCtxMem( NumCtx );
777    for ( UInt st = 0; st < NumCtx; st++ )
778    {
779      TEncSbac* ctx = NULL;
780      ctx = new TEncSbac;
781      ctx->init( &m_cBinCoderCABAC );
782      m_cSliceEncoder.setCtxMem( ctx, st );
783    }
784  }
785}
786
787//Function for initializing m_RPSList, a list of TComReferencePictureSet, based on the GOPEntry objects read from the config file.
788Void TEncTop::xInitRPS()
789{
790  TComReferencePictureSet*      rps;
791 
792  m_cSPS.createRPSList(getGOPSize()+m_extraRPSs);
793  TComRPSList* rpsList = m_cSPS.getRPSList();
794
795  for( Int i = 0; i < getGOPSize()+m_extraRPSs; i++) 
796  {
797    GOPEntry ge = getGOPEntry(i);
798    rps = rpsList->getReferencePictureSet(i);
799    rps->setNumberOfPictures(ge.m_numRefPics);
800    rps->setNumRefIdc(ge.m_numRefIdc);
801    Int numNeg = 0;
802    Int numPos = 0;
803    for( Int j = 0; j < ge.m_numRefPics; j++)
804    {
805      rps->setDeltaPOC(j,ge.m_referencePics[j]);
806      rps->setUsed(j,ge.m_usedByCurrPic[j]);
807      if(ge.m_referencePics[j]>0)
808      {
809        numPos++;
810      }
811      else
812      {
813        numNeg++;
814      }
815    }
816    rps->setNumberOfNegativePictures(numNeg);
817    rps->setNumberOfPositivePictures(numPos);
818
819    // handle inter RPS intialization from the config file.
820#if AUTO_INTER_RPS
821    rps->setInterRPSPrediction(ge.m_interRPSPrediction > 0);  // not very clean, converting anything > 0 to true.
822    rps->setDeltaRIdxMinus1(0);                               // index to the Reference RPS is always the previous one.
823    TComReferencePictureSet*     RPSRef = rpsList->getReferencePictureSet(i-1);  // get the reference RPS
824
825    if (ge.m_interRPSPrediction == 2)  // Automatic generation of the inter RPS idc based on the RIdx provided.
826    {
827      Int deltaRPS = getGOPEntry(i-1).m_POC - ge.m_POC;  // the ref POC - current POC
828      Int numRefDeltaPOC = RPSRef->getNumberOfPictures();
829
830      rps->setDeltaRPS(deltaRPS);           // set delta RPS
831      rps->setNumRefIdc(numRefDeltaPOC+1);  // set the numRefIdc to the number of pictures in the reference RPS + 1.
832      Int count=0;
833      for (Int j = 0; j <= numRefDeltaPOC; j++ ) // cycle through pics in reference RPS.
834      {
835        Int RefDeltaPOC = (j<numRefDeltaPOC)? RPSRef->getDeltaPOC(j): 0;  // if it is the last decoded picture, set RefDeltaPOC = 0
836        rps->setRefIdc(j, 0);
837        for (Int k = 0; k < rps->getNumberOfPictures(); k++ )  // cycle through pics in current RPS.
838        {
839          if (rps->getDeltaPOC(k) == ( RefDeltaPOC + deltaRPS))  // if the current RPS has a same picture as the reference RPS.
840          {
841              rps->setRefIdc(j, (rps->getUsed(k)?1:2));
842              count++;
843              break;
844          }
845        }
846      }
847      if (count != rps->getNumberOfPictures())
848      {
849        printf("Warning: Unable fully predict all delta POCs using the reference RPS index given in the config file.  Setting Inter RPS to false for this RPS.\n");
850        rps->setInterRPSPrediction(0);
851      }
852    }
853    else if (ge.m_interRPSPrediction == 1)  // inter RPS idc based on the RefIdc values provided in config file.
854    {
855      rps->setDeltaRPS(ge.m_deltaRPS);
856      rps->setNumRefIdc(ge.m_numRefIdc);
857      for (Int j = 0; j < ge.m_numRefIdc; j++ )
858      {
859        rps->setRefIdc(j, ge.m_refIdc[j]);
860      }
861#if WRITE_BACK
862      // the folowing code overwrite the deltaPOC and Used by current values read from the config file with the ones
863      // computed from the RefIdc.  A warning is printed if they are not identical.
864      numNeg = 0;
865      numPos = 0;
866      TComReferencePictureSet      RPSTemp;  // temporary variable
867
868      for (Int j = 0; j < ge.m_numRefIdc; j++ )
869      {
870        if (ge.m_refIdc[j])
871        {
872          Int deltaPOC = ge.m_deltaRPS + ((j < RPSRef->getNumberOfPictures())? RPSRef->getDeltaPOC(j) : 0);
873          RPSTemp.setDeltaPOC((numNeg+numPos),deltaPOC);
874          RPSTemp.setUsed((numNeg+numPos),ge.m_refIdc[j]==1?1:0);
875          if (deltaPOC<0)
876          {
877            numNeg++;
878          }
879          else
880          {
881            numPos++;
882          }
883        }
884      }
885      if (numNeg != rps->getNumberOfNegativePictures())
886      {
887        printf("Warning: number of negative pictures in RPS is different between intra and inter RPS specified in the config file.\n");
888        rps->setNumberOfNegativePictures(numNeg);
889        rps->setNumberOfPositivePictures(numNeg+numPos);
890      }
891      if (numPos != rps->getNumberOfPositivePictures())
892      {
893        printf("Warning: number of positive pictures in RPS is different between intra and inter RPS specified in the config file.\n");
894        rps->setNumberOfPositivePictures(numPos);
895        rps->setNumberOfPositivePictures(numNeg+numPos);
896      }
897      RPSTemp.setNumberOfPictures(numNeg+numPos);
898      RPSTemp.setNumberOfNegativePictures(numNeg);
899      RPSTemp.sortDeltaPOC();     // sort the created delta POC before comparing
900      // check if Delta POC and Used are the same
901      // print warning if they are not.
902      for (Int j = 0; j < ge.m_numRefIdc; j++ )
903      {
904        if (RPSTemp.getDeltaPOC(j) != rps->getDeltaPOC(j))
905        {
906          printf("Warning: delta POC is different between intra RPS and inter RPS specified in the config file.\n");
907          rps->setDeltaPOC(j,RPSTemp.getDeltaPOC(j));
908        }
909        if (RPSTemp.getUsed(j) != rps->getUsed(j))
910        {
911          printf("Warning: Used by Current in RPS is different between intra and inter RPS specified in the config file.\n");
912          rps->setUsed(j,RPSTemp.getUsed(j));
913        }
914      }
915#endif
916    }
917#else
918    rps->setInterRPSPrediction(ge.m_interRPSPrediction);
919    if (ge.m_interRPSPrediction)
920    {
921      rps->setDeltaRIdxMinus1(0);
922      rps->setDeltaRPS(ge.m_deltaRPS);
923      rps->setNumRefIdc(ge.m_numRefIdc);
924      for (Int j = 0; j < ge.m_numRefIdc; j++ )
925      {
926        rps->setRefIdc(j, ge.m_refIdc[j]);
927      }
928#if WRITE_BACK
929      // the folowing code overwrite the deltaPOC and Used by current values read from the config file with the ones
930      // computed from the RefIdc.  This is not necessary if both are identical. Currently there is no check to see if they are identical.
931      numNeg = 0;
932      numPos = 0;
933      TComReferencePictureSet*     RPSRef = m_RPSList.getReferencePictureSet(i-1);
934
935      for (Int j = 0; j < ge.m_numRefIdc; j++ )
936      {
937        if (ge.m_refIdc[j])
938        {
939          Int deltaPOC = ge.m_deltaRPS + ((j < RPSRef->getNumberOfPictures())? RPSRef->getDeltaPOC(j) : 0);
940          rps->setDeltaPOC((numNeg+numPos),deltaPOC);
941          rps->setUsed((numNeg+numPos),ge.m_refIdc[j]==1?1:0);
942          if (deltaPOC<0)
943          {
944            numNeg++;
945          }
946          else
947          {
948            numPos++;
949          }
950        }
951      }
952      rps->setNumberOfNegativePictures(numNeg);
953      rps->setNumberOfPositivePictures(numPos);
954      rps->sortDeltaPOC();
955#endif
956    }
957#endif //INTER_RPS_AUTO
958  }
959 
960}
961
962   // This is a function that
963   // determines what Reference Picture Set to use
964   // for a specific slice (with POC = POCCurr)
965Void TEncTop::selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid )
966{
967#if H_MV
968  if( slice->getRapPicFlag() == true && getLayerId() > 0 && POCCurr == 0 )
969  {
970    TComReferencePictureSet* rps = slice->getLocalRPS();
971    rps->setNumberOfNegativePictures(0);
972    rps->setNumberOfPositivePictures(0);
973    rps->setNumberOfLongtermPictures(0);
974    rps->setNumberOfPictures(0);
975    slice->setRPS(rps);
976  }
977  else
978  {
979#endif
980  slice->setRPSidx(GOPid);
981
982  for(Int extraNum=m_iGOPSize; extraNum<m_extraRPSs+m_iGOPSize; extraNum++)
983  {   
984    if(m_uiIntraPeriod > 0 && getDecodingRefreshType() > 0)
985    {
986      Int POCIndex = POCCurr%m_uiIntraPeriod;
987      if(POCIndex == 0)
988      {
989        POCIndex = m_uiIntraPeriod;
990      }
991      if(POCIndex == m_GOPList[extraNum].m_POC)
992      {
993        slice->setRPSidx(extraNum);
994      }
995    }
996    else
997    {
998      if(POCCurr==m_GOPList[extraNum].m_POC)
999      {
1000        slice->setRPSidx(extraNum);
1001      }
1002    }
1003  }
1004
1005  slice->setRPS(getSPS()->getRPSList()->getReferencePictureSet(slice->getRPSidx()));
1006  slice->getRPS()->setNumberOfPictures(slice->getRPS()->getNumberOfNegativePictures()+slice->getRPS()->getNumberOfPositivePictures());
1007#if H_MV
1008  }
1009#endif
1010}
1011
1012#if L0208_SOP_DESCRIPTION_SEI
1013Int TEncTop::getReferencePictureSetIdxForSOP(TComSlice* slice, Int POCCurr, Int GOPid )
1014{
1015  int rpsIdx = GOPid;
1016
1017  for(Int extraNum=m_iGOPSize; extraNum<m_extraRPSs+m_iGOPSize; extraNum++)
1018  {   
1019    if(m_uiIntraPeriod > 0 && getDecodingRefreshType() > 0)
1020    {
1021      Int POCIndex = POCCurr%m_uiIntraPeriod;
1022      if(POCIndex == 0)
1023      {
1024        POCIndex = m_uiIntraPeriod;
1025      }
1026      if(POCIndex == m_GOPList[extraNum].m_POC)
1027      {
1028        rpsIdx = extraNum;
1029      }
1030    }
1031    else
1032    {
1033      if(POCCurr==m_GOPList[extraNum].m_POC)
1034      {
1035        rpsIdx = extraNum;
1036      }
1037    }
1038  }
1039
1040  return rpsIdx;
1041}
1042#endif
1043
1044Void  TEncTop::xInitPPSforTiles()
1045{
1046  m_cPPS.setUniformSpacingFlag( m_iUniformSpacingIdr );
1047  m_cPPS.setNumColumnsMinus1( m_iNumColumnsMinus1 );
1048  m_cPPS.setNumRowsMinus1( m_iNumRowsMinus1 );
1049  if( m_iUniformSpacingIdr == 0 )
1050  {
1051    m_cPPS.setColumnWidth( m_puiColumnWidth );
1052    m_cPPS.setRowHeight( m_puiRowHeight );
1053  }
1054  m_cPPS.setLoopFilterAcrossTilesEnabledFlag( m_loopFilterAcrossTilesEnabledFlag );
1055
1056  // # substreams is "per tile" when tiles are independent.
1057  if (m_iWaveFrontSynchro
1058    )
1059  {
1060    m_cPPS.setNumSubstreams(m_iWaveFrontSubstreams * (m_iNumColumnsMinus1+1));
1061  }
1062}
1063
1064Void  TEncCfg::xCheckGSParameters()
1065{
1066  Int   iWidthInCU = ( m_iSourceWidth%g_uiMaxCUWidth ) ? m_iSourceWidth/g_uiMaxCUWidth + 1 : m_iSourceWidth/g_uiMaxCUWidth;
1067  Int   iHeightInCU = ( m_iSourceHeight%g_uiMaxCUHeight ) ? m_iSourceHeight/g_uiMaxCUHeight + 1 : m_iSourceHeight/g_uiMaxCUHeight;
1068  UInt  uiCummulativeColumnWidth = 0;
1069  UInt  uiCummulativeRowHeight = 0;
1070
1071  //check the column relative parameters
1072  if( m_iNumColumnsMinus1 >= (1<<(LOG2_MAX_NUM_COLUMNS_MINUS1+1)) )
1073  {
1074    printf( "The number of columns is larger than the maximum allowed number of columns.\n" );
1075    exit( EXIT_FAILURE );
1076  }
1077
1078  if( m_iNumColumnsMinus1 >= iWidthInCU )
1079  {
1080    printf( "The current picture can not have so many columns.\n" );
1081    exit( EXIT_FAILURE );
1082  }
1083
1084  if( m_iNumColumnsMinus1 && m_iUniformSpacingIdr==0 )
1085  {
1086    for(Int i=0; i<m_iNumColumnsMinus1; i++)
1087    {
1088      uiCummulativeColumnWidth += m_puiColumnWidth[i];
1089    }
1090
1091    if( uiCummulativeColumnWidth >= iWidthInCU )
1092    {
1093      printf( "The width of the column is too large.\n" );
1094      exit( EXIT_FAILURE );
1095    }
1096  }
1097
1098  //check the row relative parameters
1099  if( m_iNumRowsMinus1 >= (1<<(LOG2_MAX_NUM_ROWS_MINUS1+1)) )
1100  {
1101    printf( "The number of rows is larger than the maximum allowed number of rows.\n" );
1102    exit( EXIT_FAILURE );
1103  }
1104
1105  if( m_iNumRowsMinus1 >= iHeightInCU )
1106  {
1107    printf( "The current picture can not have so many rows.\n" );
1108    exit( EXIT_FAILURE );
1109  }
1110
1111  if( m_iNumRowsMinus1 && m_iUniformSpacingIdr==0 )
1112  {
1113    for(Int i=0; i<m_iNumRowsMinus1; i++)
1114      uiCummulativeRowHeight += m_puiRowHeight[i];
1115
1116    if( uiCummulativeRowHeight >= iHeightInCU )
1117    {
1118      printf( "The height of the row is too large.\n" );
1119      exit( EXIT_FAILURE );
1120    }
1121  }
1122}
1123
1124#if H_MV
1125Void TEncTop::printSummary( Int numAllPicCoded )
1126{
1127  assert (numAllPicCoded == m_cAnalyzeAll.getNumPic());
1128
1129  //--CFG_KDY
1130  m_cAnalyzeAll.setFrmRate( getFrameRate() );
1131  m_cAnalyzeI.setFrmRate( getFrameRate() );
1132  m_cAnalyzeP.setFrmRate( getFrameRate() );
1133  m_cAnalyzeB.setFrmRate( getFrameRate() );
1134
1135  //-- all
1136  printf( "\n\nSUMMARY ------------------------------------------- LayerId %2d\n", m_layerId );
1137
1138  m_cAnalyzeAll.printOut('a');
1139
1140  printf( "\n\nI Slices--------------------------------------------------------\n" );
1141  m_cAnalyzeI.printOut('i');
1142
1143  printf( "\n\nP Slices--------------------------------------------------------\n" );
1144  m_cAnalyzeP.printOut('p');
1145
1146  printf( "\n\nB Slices--------------------------------------------------------\n" );
1147  m_cAnalyzeB.printOut('b');
1148
1149#if _SUMMARY_OUT_
1150  m_cAnalyzeAll.printSummaryOut();
1151#endif
1152#if _SUMMARY_PIC_
1153  m_cAnalyzeI.printSummary('I');
1154  m_cAnalyzeP.printSummary('P');
1155  m_cAnalyzeB.printSummary('B');
1156#endif
1157}
1158
1159Int TEncTop::getFrameId(Int iGOPid) 
1160{
1161  if(m_iPOCLast == 0)
1162  {
1163    return(0 );
1164  }
1165  else
1166  {
1167    return m_iPOCLast -m_iNumPicRcvd+ getGOPEntry(iGOPid).m_POC ;
1168  }
1169}
1170
1171TComPic* TEncTop::getPic( Int poc )
1172{
1173  TComList<TComPic*>* listPic = getListPic();
1174  TComPic* pcPic = NULL;
1175  for(TComList<TComPic*>::iterator it=listPic->begin(); it!=listPic->end(); it++)
1176  {
1177    if( (*it)->getPOC() == poc )
1178    {
1179      pcPic = *it ;
1180      break ;
1181    }
1182  }
1183  return pcPic;
1184}
1185#endif
1186
1187//! \}
Note: See TracBrowser for help on using the repository browser.