source: 3DVCSoftware/branches/HTM-5.0-Sony/source/Lib/TLibEncoder/TEncTop.cpp @ 197

Last change on this file since 197 was 197, checked in by sony, 12 years ago

Add DV_V_RESTRICTION_B0037 macro and two config parameters (DisparitySearchRangeRestriction, VerticalDisparitySearchRange).

It enables to restrict disparity vector range at encoder on motion search.
When users want to try the option, please set DisparitySearchRangeRestriction to 1 and set VerticalDisparitySearchRange to any positive integer value to be tested. The restriction is disabled by default.

  • 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-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#if OL_QTLIMIT_PREDCODING_B0068
772  m_cSPS.setUseQTLPC( m_bUseQTLPC );
773#endif
774#if HHI_MPI
775  m_cSPS.setUseMVI( m_bUseMVI );
776#endif
777
778  if( m_isDepth )
779  {
780    m_cSPS.initMultiviewSPSDepth    ( m_viewId, m_iViewOrderIdx );
781#if DEPTH_MAP_GENERATION
782    m_cSPS.setPredDepthMapGeneration( m_viewId, true );
783#endif
784#if HHI_INTER_VIEW_RESIDUAL_PRED
785    m_cSPS.setMultiviewResPredMode  ( 0 );
786#endif
787  }
788  else
789  {
790#if QC_MVHEVC_B0046
791    m_cSPS.initMultiviewSPS   ( m_viewId);
792#else
793    m_cSPS.initMultiviewSPS           ( m_viewId, m_iViewOrderIdx, m_uiCamParPrecision, m_bCamParInSliceHeader, m_aaiCodedScale, m_aaiCodedOffset );
794#endif
795    if( m_viewId )
796    {
797#if DEPTH_MAP_GENERATION
798#if HHI_INTER_VIEW_MOTION_PRED
799      m_cSPS.setPredDepthMapGeneration( m_viewId, false, m_uiPredDepthMapGeneration, m_uiMultiviewMvPredMode, m_uiPdmPrecision, m_aaiPdmScaleNomDelta, m_aaiPdmOffset );
800#else
801      m_cSPS.setPredDepthMapGeneration( m_viewId, false, m_uiPredDepthMapGeneration, 0, m_uiPdmPrecision, m_aaiPdmScaleNomDelta, m_aaiPdmOffset );
802#endif
803#endif
804#if HHI_INTER_VIEW_RESIDUAL_PRED
805      m_cSPS.setMultiviewResPredMode  ( m_uiMultiviewResPredMode );
806#endif
807    }
808    else
809    {
810#if DEPTH_MAP_GENERATION
811      m_cSPS.setPredDepthMapGeneration( m_viewId, false );
812#endif
813#if HHI_INTER_VIEW_RESIDUAL_PRED
814      m_cSPS.setMultiviewResPredMode  ( 0 );
815#endif
816    }
817  }
818}
819
820Void TEncTop::xInitPPS()
821{
822  m_cPPS.setConstrainedIntraPred( m_bUseConstrainedIntraPred );
823  m_cPPS.setSliceGranularity(m_iSliceGranularity);
824#if !H0566_TLA
825  if ( m_cSPS.getTemporalIdNestingFlag() ) 
826  {
827    m_cPPS.setNumTLayerSwitchingFlags( 0 );
828    for ( UInt i = 0; i < m_cSPS.getMaxTLayers() - 1; i++ )
829    {
830      m_cPPS.setTLayerSwitchingFlag( i, true );
831    }
832  }
833  else
834  {
835    m_cPPS.setNumTLayerSwitchingFlags( m_cSPS.getMaxTLayers() - 1 );
836    for ( UInt i = 0; i < m_cPPS.getNumTLayerSwitchingFlags(); i++ )
837    {
838      m_cPPS.setTLayerSwitchingFlag( i, m_abTLayerSwitchingFlag[i] );
839    }
840  }   
841#endif
842  Bool bUseDQP = (getMaxCuDQPDepth() > 0)? true : false;
843
844#if LOSSLESS_CODING
845#if H0736_AVC_STYLE_QP_RANGE
846  Int lowestQP = - m_cSPS.getQpBDOffsetY();
847#else
848  Int lowestQP = 0;
849#endif
850
851  if(getUseLossless())
852  {
853    if ((getMaxCuDQPDepth() == 0) && (getMaxDeltaQP() == 0 ) && (getQP() == lowestQP) )
854    {
855      bUseDQP = false;
856    }
857    else
858    {
859      bUseDQP = true;
860    }
861  }
862  else
863  {
864    if(bUseDQP == false)
865    {
866      if((getMaxDeltaQP() != 0 )|| getUseAdaptiveQP())
867      {
868        bUseDQP = true;
869      }
870    }
871  }
872
873#else
874  if(bUseDQP == false)
875  {
876    if((getMaxDeltaQP() != 0 )|| getUseAdaptiveQP())
877    {
878      bUseDQP = true;
879    }
880  }
881#endif
882
883  if(bUseDQP)
884  {
885    m_cPPS.setUseDQP(true);
886    m_cPPS.setMaxCuDQPDepth( m_iMaxCuDQPDepth );
887    m_cPPS.setMinCuDQPSize( m_cPPS.getSPS()->getMaxCUWidth() >> ( m_cPPS.getMaxCuDQPDepth()) );
888  }
889  else
890  {
891    m_cPPS.setUseDQP(false);
892    m_cPPS.setMaxCuDQPDepth( 0 );
893    m_cPPS.setMinCuDQPSize( m_cPPS.getSPS()->getMaxCUWidth() >> ( m_cPPS.getMaxCuDQPDepth()) );
894  }
895
896  m_cPPS.setChromaQpOffset   ( m_iChromaQpOffset    );
897  m_cPPS.setChromaQpOffset2nd( m_iChromaQpOffset2nd );
898
899  m_cPPS.setEntropyCodingMode( 1 ); // In the PPS now, but also remains in slice header!
900#if !WPP_SIMPLIFICATION
901  m_cPPS.setEntropyCodingSynchro(m_iWaveFrontSynchro);
902  m_cPPS.setCabacIstateReset(m_iWaveFrontFlush != 0);
903#endif
904  m_cPPS.setNumSubstreams(m_iWaveFrontSubstreams);
905  m_cPPS.setUseWP( m_bUseWeightPred );
906  m_cPPS.setWPBiPredIdc( m_uiBiPredIdc );
907  m_cPPS.setEnableTMVPFlag( m_bEnableTMVP );
908#if H0388
909  m_cPPS.setOutputFlagPresentFlag( false );
910#endif
911#if MULTIBITS_DATA_HIDING
912  m_cPPS.setSignHideFlag(getSignHideFlag());
913  m_cPPS.setTSIG(getTSIG());
914#endif
915#if DBL_CONTROL
916  m_cPPS.setDeblockingFilterControlPresent (m_DeblockingFilterControlPresent );
917#endif
918#if PARALLEL_MERGE
919  m_cPPS.setLog2ParallelMergeLevelMinus2      (LOG2_PARALLEL_MERGE_LEVEL_MINUS2);
920#endif
921#if CABAC_INIT_FLAG
922  m_cPPS.setCabacInitPresentFlag(CABAC_INIT_PRESENT_FLAG);
923#endif
924}
925
926//Function for initializing m_RPSList, a list of TComReferencePictureSet, based on the GOPEntry objects read from the config file.
927Void TEncTop::xInitRPS()
928{
929  TComReferencePictureSet*      rps;
930 
931  m_RPSList.create(getGOPSize()+m_extraRPSs);
932  for( Int i = 0; i < getGOPSize()+m_extraRPSs; i++) 
933  {
934    GOPEntryMvc ge = getGOPEntry(i);
935    rps = m_RPSList.getReferencePictureSet(i);
936    rps->setNumberOfPictures(ge.m_numRefPics);
937    rps->setNumRefIdc(ge.m_numRefIdc);
938    Int numNeg = 0;
939    Int numPos = 0;
940    for( Int j = 0; j < ge.m_numRefPics; j++)
941    {
942      rps->setDeltaPOC(j,ge.m_referencePics[j]);
943      rps->setUsed(j,ge.m_usedByCurrPic[j]);
944      if(ge.m_referencePics[j]>0)
945      {
946        numPos++;
947      }
948      else
949      {
950        numNeg++;
951      }
952    }
953    rps->setNumberOfNegativePictures(numNeg);
954    rps->setNumberOfPositivePictures(numPos);
955    rps->setInterRPSPrediction(ge.m_interRPSPrediction);
956    if (ge.m_interRPSPrediction)
957    {
958      rps->setDeltaRIdxMinus1(ge.m_deltaRIdxMinus1);
959      rps->setDeltaRPS(ge.m_deltaRPS);
960      rps->setNumRefIdc(ge.m_numRefIdc);
961      for (Int j = 0; j < ge.m_numRefIdc; j++ )
962      {
963        rps->setRefIdc(j, ge.m_refIdc[j]);
964      }
965#if WRITE_BACK
966      // the folowing code overwrite the deltaPOC and Used by current values read from the config file with the ones
967      // computed from the RefIdc.  This is not necessary if both are identical. Currently there is no check to see if they are identical.
968      numNeg = 0;
969      numPos = 0;
970      TComReferencePictureSet*     RPSRef = m_RPSList.getReferencePictureSet(i-(ge.m_deltaRIdxMinus1+1));
971      for (Int j = 0; j < ge.m_numRefIdc; j++ )
972      {
973        if (ge.m_refIdc[j])
974        {
975          Int deltaPOC = ge.m_deltaRPS + ((j < RPSRef->getNumberOfPictures())? RPSRef->getDeltaPOC(j) : 0);
976          rps->setDeltaPOC((numNeg+numPos),deltaPOC);
977          rps->setUsed((numNeg+numPos),ge.m_refIdc[j]==1?1:0);
978          if (deltaPOC<0)
979          {
980            numNeg++;
981          }
982          else
983          {
984            numPos++;
985          }
986        }
987      }
988      rps->setNumberOfNegativePictures(numNeg);
989      rps->setNumberOfPositivePictures(numPos);
990      rps->sortDeltaPOC();
991#endif
992    }
993  }
994 
995}
996
997   // This is a function that
998   // determines what Reference Picture Set to use
999   // for a specific slice (with POC = POCCurr)
1000Void TEncTop::selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid,TComList<TComPic*>& listPic )
1001{
1002#if QC_REM_IDV_B0046
1003  if( (slice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR ||slice->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA) && slice->getSPS()->getViewId() && POCCurr == 0 )
1004#else
1005  if( slice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDV && POCCurr == 0 )
1006#endif
1007  {
1008    TComReferencePictureSet* rps = slice->getLocalRPS();
1009    rps->setNumberOfNegativePictures(0);
1010    rps->setNumberOfPositivePictures(0);
1011    rps->setNumberOfLongtermPictures(0);
1012    rps->setNumberOfPictures(0);
1013    slice->setRPS(rps);
1014  }
1015  else
1016  {
1017    slice->setRPSidx(GOPid);
1018
1019    for(Int extraNum=m_iGOPSize; extraNum<m_extraRPSs+m_iGOPSize; extraNum++)
1020    {   
1021      if(m_uiIntraPeriod > 0)
1022      {
1023        if(POCCurr%m_uiIntraPeriod==m_GOPList[extraNum].m_POC)
1024        {
1025          slice->setRPSidx(extraNum);
1026        }
1027      }
1028      else
1029      {
1030        if(POCCurr==m_GOPList[extraNum].m_POC)
1031        {
1032          slice->setRPSidx(extraNum);
1033        }
1034      }
1035    }
1036
1037    slice->setRPS(getRPSList()->getReferencePictureSet(slice->getRPSidx()));
1038    slice->getRPS()->setNumberOfPictures(slice->getRPS()->getNumberOfNegativePictures()+slice->getRPS()->getNumberOfPositivePictures());
1039  }
1040}
1041
1042Void TEncTop::xInitSPSforInterViewRefs()
1043{
1044  // base view
1045  if( getGOPEntry( MAX_GOP ).m_POC == -1 )
1046  { 
1047    m_cSPS.setNumberOfUsableInterViewRefs( 0 );
1048    m_cSPS.setListsModificationPresentFlag( false );
1049    return;
1050  }
1051
1052  Int numberUsableInterViewRefs = 0;
1053  for( Int i = 0; i < getGOPSize()+1 && numberUsableInterViewRefs < MAX_VIEW_NUM; i++ ) 
1054  {
1055    GOPEntryMvc ge = ( i < getGOPSize() ) ? getGOPEntry( i ) : getGOPEntry( MAX_GOP );
1056    for( Int j = 0; j < ge.m_numInterViewRefPics; j++ )
1057    {
1058      // add ref view to list
1059      Bool onList = false;
1060      for( Int k = 0; k < numberUsableInterViewRefs; k++ )
1061      {
1062        if( ge.m_interViewRefs[j] == m_cSPS.getUsableInterViewRef( k ) )
1063        {
1064          onList = true;
1065          break;
1066        }
1067      }
1068      if( !onList )
1069      {
1070        m_cSPS.setUsableInterViewRef( (UInt)numberUsableInterViewRefs, ge.m_interViewRefs[j] );
1071        numberUsableInterViewRefs++;
1072      }
1073    }
1074  }
1075  m_cSPS.setNumberOfUsableInterViewRefs( numberUsableInterViewRefs );
1076
1077  // sort inter view refs
1078  for( Int j = 1; j < m_cSPS.getNumberOfUsableInterViewRefs(); j++ )
1079  { 
1080    Int deltaViewId = m_cSPS.getUsableInterViewRef( j );
1081    for( Int k = j-1; k >= 0; k-- )
1082    {
1083      Int temp = m_cSPS.getUsableInterViewRef( k );
1084      if( deltaViewId > temp )
1085      {
1086        m_cSPS.setUsableInterViewRef( k+1, temp );
1087        m_cSPS.setUsableInterViewRef( k, deltaViewId );
1088      }
1089    }
1090  }
1091
1092  m_cSPS.setListsModificationPresentFlag( true );
1093}
1094
1095Void  TEncTop::xInitPPSforTiles()
1096{
1097    m_cPPS.setColumnRowInfoPresent( m_iColumnRowInfoPresent );
1098    m_cPPS.setUniformSpacingIdr( m_iUniformSpacingIdr );
1099#if !REMOVE_TILE_DEPENDENCE
1100    m_cPPS.setTileBoundaryIndependenceIdr( m_iTileBoundaryIndependenceIdr );
1101#endif
1102    m_cPPS.setNumColumnsMinus1( m_iNumColumnsMinus1 );
1103    m_cPPS.setNumRowsMinus1( m_iNumRowsMinus1 );
1104    if( m_iUniformSpacingIdr == 0 )
1105    {
1106      m_cPPS.setColumnWidth( m_puiColumnWidth );
1107      m_cPPS.setRowHeight( m_puiRowHeight );
1108    }
1109    m_cPPS.setTileBehaviorControlPresentFlag( m_iTileBehaviorControlPresentFlag );
1110    m_cPPS.setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag );
1111
1112    // # substreams is "per tile" when tiles are independent.
1113    if ( m_iWaveFrontSynchro )
1114    {
1115      m_cPPS.setNumSubstreams(m_iWaveFrontSubstreams * (m_iNumColumnsMinus1+1)*(m_iNumRowsMinus1+1));
1116    }
1117}
1118
1119Void  TEncCfg::xCheckGSParameters()
1120{
1121  Int   iWidthInCU = ( m_iSourceWidth%g_uiMaxCUWidth ) ? m_iSourceWidth/g_uiMaxCUWidth + 1 : m_iSourceWidth/g_uiMaxCUWidth;
1122  Int   iHeightInCU = ( m_iSourceHeight%g_uiMaxCUHeight ) ? m_iSourceHeight/g_uiMaxCUHeight + 1 : m_iSourceHeight/g_uiMaxCUHeight;
1123  UInt  uiCummulativeColumnWidth = 0;
1124  UInt  uiCummulativeRowHeight = 0;
1125
1126  //check the column relative parameters
1127  if( m_iNumColumnsMinus1 >= (1<<(LOG2_MAX_NUM_COLUMNS_MINUS1+1)) )
1128  {
1129    printf( "The number of columns is larger than the maximum allowed number of columns.\n" );
1130    exit( EXIT_FAILURE );
1131  }
1132
1133  if( m_iNumColumnsMinus1 >= iWidthInCU )
1134  {
1135    printf( "The current picture can not have so many columns.\n" );
1136    exit( EXIT_FAILURE );
1137  }
1138
1139  if( m_iNumColumnsMinus1 && m_iUniformSpacingIdr==0 )
1140  {
1141    for(Int i=0; i<m_iNumColumnsMinus1; i++)
1142      uiCummulativeColumnWidth += m_puiColumnWidth[i];
1143
1144    if( uiCummulativeColumnWidth >= iWidthInCU )
1145    {
1146      printf( "The width of the column is too large.\n" );
1147      exit( EXIT_FAILURE );
1148    }
1149  }
1150
1151  //check the row relative parameters
1152  if( m_iNumRowsMinus1 >= (1<<(LOG2_MAX_NUM_ROWS_MINUS1+1)) )
1153  {
1154    printf( "The number of rows is larger than the maximum allowed number of rows.\n" );
1155    exit( EXIT_FAILURE );
1156  }
1157
1158  if( m_iNumRowsMinus1 >= iHeightInCU )
1159  {
1160    printf( "The current picture can not have so many rows.\n" );
1161    exit( EXIT_FAILURE );
1162  }
1163
1164  if( m_iNumRowsMinus1 && m_iUniformSpacingIdr==0 )
1165  {
1166    for(Int i=0; i<m_iNumRowsMinus1; i++)
1167      uiCummulativeRowHeight += m_puiRowHeight[i];
1168
1169    if( uiCummulativeRowHeight >= iHeightInCU )
1170    {
1171      printf( "The height of the row is too large.\n" );
1172      exit( EXIT_FAILURE );
1173    }
1174  }
1175}
1176
1177Void TEncTop::setTEncTopList(std::vector<TEncTop*>* pacTEncTopList )
1178{
1179  assert(m_viewId!=-1); // not to be set for single view coding
1180
1181  m_pacTEncTopList=pacTEncTopList;
1182
1183}
1184
1185Void TEncTop::printOutSummary(UInt uiNumAllPicCoded)
1186{
1187  assert (uiNumAllPicCoded == m_cAnalyzeAll.getNumPic());
1188
1189  //--CFG_KDY
1190  m_cAnalyzeAll.setFrmRate( getFrameRate() );
1191  m_cAnalyzeI.setFrmRate( getFrameRate() );
1192  m_cAnalyzeP.setFrmRate( getFrameRate() );
1193  m_cAnalyzeB.setFrmRate( getFrameRate() );
1194
1195  //-- all
1196  if(m_viewId==-1)
1197    printf( "\n\nSUMMARY --------------------------------------------------------\n" );
1198  else {
1199    if ( m_isDepth )
1200    {
1201      printf( "\n\nSUMMARY ---------------------------------------------- DEPTH %2d\n", m_viewId );
1202    }
1203    else
1204    {
1205      printf( "\n\nSUMMARY ---------------------------------------------- VIDEO %2d\n", m_viewId );
1206    }
1207  };
1208  m_cAnalyzeAll.printOut('a');
1209
1210  printf( "\n\nI Slices--------------------------------------------------------\n" );
1211  m_cAnalyzeI.printOut('i');
1212
1213  printf( "\n\nP Slices--------------------------------------------------------\n" );
1214  m_cAnalyzeP.printOut('p');
1215
1216  printf( "\n\nB Slices--------------------------------------------------------\n" );
1217  m_cAnalyzeB.printOut('b');
1218
1219//  m_cAnalyzeAll.printSummaryOut();
1220//  m_cAnalyzeI.printSummary('I');
1221//  m_cAnalyzeP.printSummary('P');
1222//  m_cAnalyzeB.printSummary('B');
1223}
1224
1225//! \}
Note: See TracBrowser for help on using the repository browser.