source: 3DVCSoftware/branches/HTM-5.0-Nokia/source/Lib/TLibEncoder/TEncTop.cpp @ 200

Last change on this file since 200 was 200, checked in by nokia, 12 years ago

Reintegration of Flexible Coding Order to 3DV-HTM v5.1
To enable following params are required:
FCO : 1
FCOCodingOrder : T0D0D1D2T1T2
VSOConfig: [ox0 B(cc1) I(s0.25 s0.5 s0.75)][cx1 B(oo0) B(oo2) I(s0.25 s0.5 s0.75 s1.25 s1.5 s1.75)][ox2 B(cc1) I(s1.25 s1.5 s1.75)]

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