source: 3DVCSoftware/tags/HTM-DEV-0.1/source/Lib/TLibEncoder/TEncTop.cpp @ 324

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

Initial development version for update to latest HM version.
Includes MV-HEVC and basic extensions for 3D-HEVC.

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