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

Last change on this file since 233 was 210, checked in by tech, 12 years ago

Reintegrated /branches/HTM-5.0-dev0 rev. 207.

  • Property svn:eol-style set to native
File size: 35.5 KB
RevLine 
[5]1/* The copyright in this software is being made available under the BSD
2 * License, included below. This software may be subject to other third party
3 * and contributor rights, including patent rights, and no such rights are
[56]4 * granted under this license. 
[5]5 *
[56]6 * Copyright (c) 2010-2012, ITU/ISO/IEC
[5]7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright notice,
13 *    this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above copyright notice,
15 *    this list of conditions and the following disclaimer in the documentation
16 *    and/or other materials provided with the distribution.
[56]17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
[5]18 *    be used to endorse or promote products derived from this software without
19 *    specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
[2]33
34/** \file     TEncTop.cpp
35    \brief    encoder class
36*/
37
[56]38#include "TLibCommon/CommonDef.h"
[2]39#include "TEncTop.h"
[56]40#include "TEncPic.h"
[2]41#include "../../App/TAppEncoder/TAppEncTop.h"
[56]42#if FAST_BIT_EST
43#include "TLibCommon/ContextModel.h"
44#endif
[2]45
[56]46//! \ingroup TLibEncoder
47//! \{
48
[2]49// ====================================================================================================================
50// Constructor / destructor / create / destroy
51// ====================================================================================================================
52
53TEncTop::TEncTop()
54{
55  m_iPOCLast          = -1;
56  m_iNumPicRcvd       =  0;
57  m_uiNumAllPicCoded  =  0;
58  m_pppcRDSbacCoder   =  NULL;
59  m_pppcBinCoderCABAC =  NULL;
60  m_cRDGoOnSbacCoder.init( &m_cRDGoOnBinCoderCABAC );
61#if ENC_DEC_TRACE
62  g_hTrace = fopen( "TraceEnc.txt", "wb" );
63  g_bJustDoIt = g_bEncDecTraceDisable;
64  g_nSymbolCounter = 0;
65#endif
[56]66
67  m_iMaxRefPicNum     = 0;
68
69#if FAST_BIT_EST
70  ContextModel::buildNextStateTable();
71#endif
72
73  m_pcSbacCoders           = NULL;
74  m_pcBinCoderCABACs       = NULL;
75  m_ppppcRDSbacCoders      = NULL;
76  m_ppppcBinCodersCABAC    = NULL;
77  m_pcRDGoOnSbacCoders     = NULL;
78  m_pcRDGoOnBinCodersCABAC = NULL;
79  m_pcBitCounters          = NULL;
80  m_pcRdCosts              = NULL;
[2]81}
82
83TEncTop::~TEncTop()
84{
85#if ENC_DEC_TRACE
86  fclose( g_hTrace );
87#endif
88}
89
90Void TEncTop::create ()
91{
92  // initialize global variables
[105]93  if( m_viewId == 0 && m_isDepth == false )
94  {
95    initROM();
96  }
97
98
[2]99  // create processing unit classes
[56]100  m_cGOPEncoder.        create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight );
[2]101  m_cSliceEncoder.      create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
102  m_cCuEncoder.         create( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight );
103  if (m_bUseSAO)
104  {
[56]105#if SAO_UNIT_INTERLEAVING
106    m_cEncSAO.setSaoInterleavingFlag(getSaoInterleavingFlag());
107    m_cEncSAO.setMaxNumOffsetsPerPic(getMaxNumOffsetsPerPic());
108#endif
[2]109    m_cEncSAO.create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
110    m_cEncSAO.createEncBuffer();
111  }
[56]112#if ADAPTIVE_QP_SELECTION
113  if (m_bUseAdaptQpSelect)
114  {
115    m_cTrQuant.initSliceQpDelta();
116  }
[2]117#endif
118  m_cAdaptiveLoopFilter.create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
119  m_cLoopFilter.        create( g_uiMaxCUDepth );
[56]120 
[5]121#if DEPTH_MAP_GENERATION
[21]122  m_cDepthMapGenerator. create( false, getSourceWidth(), getSourceHeight(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiBitDepth + g_uiBitIncrement, PDM_SUB_SAMP_EXP_X(m_uiPredDepthMapGeneration), PDM_SUB_SAMP_EXP_Y(m_uiPredDepthMapGeneration) );
[5]123#endif
124#if HHI_INTER_VIEW_RESIDUAL_PRED
[2]125  m_cResidualGenerator. create( false, getSourceWidth(), getSourceHeight(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiBitDepth + g_uiBitIncrement );
[5]126#endif
[2]127
128  if(m_bUseALF)
129  {
[56]130#if LCU_SYNTAX_ALF
131    m_cAdaptiveLoopFilter.setAlfCoefInSlice(m_bALFParamInSlice);
132    m_cAdaptiveLoopFilter.createAlfGlobalBuffers();
133#else
134    m_cAdaptiveLoopFilter.setGOPSize( getGOPSize() );
[2]135    m_cAdaptiveLoopFilter.createAlfGlobalBuffers(m_iALFEncodePassReduction);
[56]136#endif
[2]137  }
138
[56]139  if(m_bUseSAO || m_bUseALF)
140  {
141    m_vAPS.reserve(MAX_NUM_SUPPORTED_APS);
142  }
143
[2]144  // if SBAC-based RD optimization is used
145  if( m_bUseSBACRD )
146  {
[56]147    m_pppcRDSbacCoder = new TEncSbac** [g_uiMaxCUDepth+1];
148#if FAST_BIT_EST
149    m_pppcBinCoderCABAC = new TEncBinCABACCounter** [g_uiMaxCUDepth+1];
150#else
151    m_pppcBinCoderCABAC = new TEncBinCABAC** [g_uiMaxCUDepth+1];
152#endif
153   
154    for ( Int iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ )
[2]155    {
156      m_pppcRDSbacCoder[iDepth] = new TEncSbac* [CI_NUM];
[56]157#if FAST_BIT_EST
158      m_pppcBinCoderCABAC[iDepth] = new TEncBinCABACCounter* [CI_NUM];
159#else
[2]160      m_pppcBinCoderCABAC[iDepth] = new TEncBinCABAC* [CI_NUM];
[56]161#endif
162     
[2]163      for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ )
164      {
165        m_pppcRDSbacCoder[iDepth][iCIIdx] = new TEncSbac;
[56]166#if FAST_BIT_EST
167        m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABACCounter;
168#else
[2]169        m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABAC;
[56]170#endif
[2]171        m_pppcRDSbacCoder   [iDepth][iCIIdx]->init( m_pppcBinCoderCABAC [iDepth][iCIIdx] );
172      }
173    }
174  }
[56]175  m_pcTAppEncTop = NULL;
[5]176#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
[56]177  if( g_aacWedgeLists.empty() && m_bUseDMM )
[2]178  {
179    initWedgeLists();
180  }
181#endif
182}
183
[56]184/**
185 - Allocate coders required for wavefront for the nominated number of substreams.
186 .
187 \param iNumSubstreams Determines how much information to allocate.
188 */
189Void TEncTop::createWPPCoders(Int iNumSubstreams)
190{
191  if (m_pcSbacCoders != NULL)
192    return; // already generated.
193
194  m_iNumSubstreams         = iNumSubstreams;
195  m_pcSbacCoders           = new TEncSbac       [iNumSubstreams];
196  m_pcBinCoderCABACs       = new TEncBinCABAC   [iNumSubstreams];
197  m_pcRDGoOnSbacCoders     = new TEncSbac       [iNumSubstreams];
198  m_pcRDGoOnBinCodersCABAC = new TEncBinCABAC   [iNumSubstreams];
199  m_pcBitCounters          = new TComBitCounter [iNumSubstreams];
200  m_pcRdCosts              = new TComRdCost     [iNumSubstreams];
201
202  for ( UInt ui = 0 ; ui < iNumSubstreams; ui++ )
203  {
204    m_pcRDGoOnSbacCoders[ui].init( &m_pcRDGoOnBinCodersCABAC[ui] );
205    m_pcSbacCoders[ui].init( &m_pcBinCoderCABACs[ui] );
206  }
207  if( m_bUseSBACRD )
208  {
209    m_ppppcRDSbacCoders      = new TEncSbac***    [iNumSubstreams];
210    m_ppppcBinCodersCABAC    = new TEncBinCABAC***[iNumSubstreams];
211    for ( UInt ui = 0 ; ui < iNumSubstreams ; ui++ )
212    {
213      m_ppppcRDSbacCoders[ui]  = new TEncSbac** [g_uiMaxCUDepth+1];
214      m_ppppcBinCodersCABAC[ui]= new TEncBinCABAC** [g_uiMaxCUDepth+1];
215     
216      for ( Int iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ )
217      {
218        m_ppppcRDSbacCoders[ui][iDepth]  = new TEncSbac*     [CI_NUM];
219        m_ppppcBinCodersCABAC[ui][iDepth]= new TEncBinCABAC* [CI_NUM];
220
221        for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ )
222        {
223          m_ppppcRDSbacCoders  [ui][iDepth][iCIIdx] = new TEncSbac;
224          m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx] = new TEncBinCABAC;
225          m_ppppcRDSbacCoders  [ui][iDepth][iCIIdx]->init( m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx] );
226        }
227      }
228    }
229  }
230}
231
[2]232Void TEncTop::destroy ()
233{
234  if(m_bUseALF)
235  {
236    m_cAdaptiveLoopFilter.destroyAlfGlobalBuffers();
237  }
238
[56]239  for(Int i=0; i< m_vAPS.size(); i++)
240  {
241    TComAPS& cAPS = m_vAPS[i];
242    m_cGOPEncoder.freeAPS(&cAPS, &m_cSPS);
243  }
244
[2]245  // destroy processing unit classes
[56]246  m_cGOPEncoder.        destroy();
[2]247  m_cSliceEncoder.      destroy();
248  m_cCuEncoder.         destroy();
249  if (m_cSPS.getUseSAO())
250  {
251    m_cEncSAO.destroy();
[56]252    m_cEncSAO.destroyEncBuffer();
[2]253  }
254  m_cAdaptiveLoopFilter.destroy();
255  m_cLoopFilter.        destroy();
[56]256
[5]257#if DEPTH_MAP_GENERATION
[2]258  m_cDepthMapGenerator. destroy();
[5]259#endif
260#if HHI_INTER_VIEW_RESIDUAL_PRED
[2]261  m_cResidualGenerator. destroy();
[5]262#endif
[2]263
[56]264  m_RPSList.            destroy();
265 
[2]266  // SBAC RD
267  if( m_bUseSBACRD )
268  {
269    Int iDepth;
270    for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ )
271    {
272      for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ )
273      {
274        delete m_pppcRDSbacCoder[iDepth][iCIIdx];
275        delete m_pppcBinCoderCABAC[iDepth][iCIIdx];
276      }
277    }
[56]278   
[2]279    for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ )
280    {
281      delete [] m_pppcRDSbacCoder[iDepth];
282      delete [] m_pppcBinCoderCABAC[iDepth];
283    }
[56]284   
[2]285    delete [] m_pppcRDSbacCoder;
286    delete [] m_pppcBinCoderCABAC;
[56]287
288    for ( UInt ui = 0; ui < m_iNumSubstreams; ui++ )
289    {
290      for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ )
291      {
292        for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ )
293        {
294          delete m_ppppcRDSbacCoders  [ui][iDepth][iCIIdx];
295          delete m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx];
296        }
297      }
298
299      for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ )
300      {
301        delete [] m_ppppcRDSbacCoders  [ui][iDepth];
302        delete [] m_ppppcBinCodersCABAC[ui][iDepth];
303      }
304      delete[] m_ppppcRDSbacCoders  [ui];
305      delete[] m_ppppcBinCodersCABAC[ui];
306    }
307    delete[] m_ppppcRDSbacCoders;
308    delete[] m_ppppcBinCodersCABAC;
[2]309  }
[56]310  delete[] m_pcSbacCoders;
311  delete[] m_pcBinCoderCABACs;
312  delete[] m_pcRDGoOnSbacCoders; 
313  delete[] m_pcRDGoOnBinCodersCABAC;
314  delete[] m_pcBitCounters;
315  delete[] m_pcRdCosts;
316 
[2]317  // destroy ROM
[56]318  if(m_viewId == 0 && m_isDepth == false)
319  {
320  destroyROM();
321  }
322 
[2]323  return;
324}
325
326Void TEncTop::init( TAppEncTop* pcTAppEncTop )
327{
328  UInt *aTable4=NULL, *aTable8=NULL;
[56]329  UInt* aTableLastPosVlcIndex=NULL; 
[2]330  // initialize SPS
331  xInitSPS();
[56]332 
[2]333  // initialize PPS
[56]334  m_cPPS.setSPS(&m_cSPS);
335#if RPS_IN_SPS
336  m_cSPS.setRPSList(&m_RPSList);
337#else
338  m_cPPS.setRPSList(&m_RPSList);
339#endif
[2]340  xInitPPS();
[56]341  xInitRPS();
[2]342
[56]343  xInitSPSforInterViewRefs();
344  xInitPPSforTiles();
345
[2]346  // initialize processing unit classes
[56]347  m_cGOPEncoder.  init( this );
[2]348  m_cSliceEncoder.init( this );
349  m_cCuEncoder.   init( this );
[56]350 
351  m_pcTAppEncTop = pcTAppEncTop;
[2]352
[5]353#if DEPTH_MAP_GENERATION
[77]354#if VIDYO_VPS_INTEGRATION
355  m_cDepthMapGenerator.init( (TComPrediction*)this->getPredSearch(), m_pcTAppEncTop->getVPSAccess(), m_pcTAppEncTop->getSPSAccess(), m_pcTAppEncTop->getAUPicAccess() );
356#else
[2]357  m_cDepthMapGenerator.init( (TComPrediction*)this->getPredSearch(), m_pcTAppEncTop->getSPSAccess(), m_pcTAppEncTop->getAUPicAccess() );
[5]358#endif
[77]359#endif
[5]360#if HHI_INTER_VIEW_RESIDUAL_PRED
[2]361  m_cResidualGenerator.init( &m_cTrQuant, &m_cDepthMapGenerator );
[5]362#endif
[2]363
364  // initialize transform & quantization class
365  m_pcCavlcCoder = getCavlcCoder();
[56]366 
367  m_cTrQuant.init( g_uiMaxCUWidth, g_uiMaxCUHeight, 1 << m_uiQuadtreeTULog2MaxSize,
368                  0,
369                  aTable4, aTable8, 
370                  aTableLastPosVlcIndex, m_bUseRDOQ, true 
371#if ADAPTIVE_QP_SELECTION                 
372                  , m_bUseAdaptQpSelect
[2]373#endif
[56]374                  );
375 
[2]376  // initialize encoder search class
[210]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
[2]380  m_cSearch.init( this, &m_cTrQuant, m_iSearchRange, m_bipredSearchRange, m_iFastSearch, 0, &m_cEntropyCoder, &m_cRdCost, getRDSbacCoder(), getRDGoOnSbacCoder() );
[210]381#endif
[2]382  if(m_bUseALF)
383  {
384    m_cAdaptiveLoopFilter.setALFEncodePassReduction( m_iALFEncodePassReduction );
[56]385    m_cAdaptiveLoopFilter.setALFMaxNumberFilters( m_iALFMaxNumberFilters );
386#if LCU_SYNTAX_ALF
387    m_cAdaptiveLoopFilter.initPicQuadTreePartition(m_bALFPicBasedEncode );   
388#endif
[2]389  }
[56]390
391  m_iMaxRefPicNum = 0;
[2]392}
393
394// ====================================================================================================================
395// Public member functions
396// ====================================================================================================================
397
[56]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
[2]441Void TEncTop::deletePicBuffer()
442{
443  TComList<TComPic*>::iterator iterPic = m_cListPic.begin();
444  Int iSize = Int( m_cListPic.size() );
[56]445 
[2]446  for ( Int i = 0; i < iSize; i++ )
447  {
448    TComPic* pcPic = *(iterPic++);
[56]449   
[2]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 */
[56]467Void TEncTop::encode( bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Int gopId )
468{ 
[2]469
[56]470  if( gopId == 0)
[2]471  {
[56]472    m_cGOPEncoder.initGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut); 
[2]473  }
474
475  {
[56]476    m_cGOPEncoder.compressPicInGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, gopId );
[2]477  }
[56]478 
479  if( gopId + 1 == m_cGOPEncoder.getGOPSize() )
[2]480  {
[56]481    iNumEncoded         = m_iNumPicRcvd;
482    m_iNumPicRcvd       = 0;
483    m_uiNumAllPicCoded += iNumEncoded;
[2]484  }
485}
486
487
[56]488#if HHI_INTERVIEW_SKIP || HHI_INTER_VIEW_MOTION_PRED || HHI_INTER_VIEW_RESIDUAL_PRED
[2]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  {
[5]506#if HHI_INTER_VIEW_MOTION_PRED
[2]507    pcPic->removeOrgDepthMapBuffer();
[5]508#endif
509#if HHI_INTER_VIEW_RESIDUAL_PRED
[2]510    pcPic->removeResidualBuffer   ();
[5]511#endif
512#if HHI_INTERVIEW_SKIP
[2]513    pcPic->removeUsedPelsMapBuffer();
[5]514#endif
[2]515  }
516}
[56]517#endif
[2]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);
[56]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
[2]560  {
[56]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    }
[2]569  }
570  else
571  {
[56]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 );
[2]584  }
[56]585#if HHI_INTERVIEW_SKIP
586  if( m_bInterViewSkip )
587  {
588    rpcPic->addUsedPelsMapBuffer();
589  }
590#endif
[2]591  rpcPic->setReconMark (false);
[56]592 
[2]593  m_iPOCLast++;
594  m_iNumPicRcvd++;
[56]595 
[5]596#if HHI_INTER_VIEW_MOTION_PRED
[2]597  if( m_uiMultiviewMvRegMode )
598  {
599    rpcPic->addOrgDepthMapBuffer();
600  }
[5]601#endif
[56]602 
[2]603  rpcPic->getSlice(0)->setPOC( m_iPOCLast );
604  // mark it should be extended
605  rpcPic->getPicYuvRec()->setBorderExtension(false);
[100]606  rpcPic->getPicYuvOrg()->setBorderExtension(false); 
[2]607}
608
609Void TEncTop::xInitSPS()
610{
[56]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
[2]623  m_cSPS.setPad           ( m_aiPad             );
[56]624#endif
[2]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                   );
[56]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  );
[2]638
639  m_cSPS.setUseALF        ( m_bUseALF           );
[56]640#if LCU_SYNTAX_ALF
641  if(m_bUseALF)
642  {
643    m_cSPS.setUseALFCoefInSlice(m_bALFParamInSlice);
644  }
645#endif
646 
[189]647#if RWTH_SDC_DLT_B0036
648  m_cSPS.setUseDLT        ( m_bUseDLT );
649#endif
650 
[2]651  m_cSPS.setQuadtreeTULog2MaxSize( m_uiQuadtreeTULog2MaxSize );
652  m_cSPS.setQuadtreeTULog2MinSize( m_uiQuadtreeTULog2MinSize );
653  m_cSPS.setQuadtreeTUMaxDepthInter( m_uiQuadtreeTUMaxDepthInter    );
654  m_cSPS.setQuadtreeTUMaxDepthIntra( m_uiQuadtreeTUMaxDepthIntra    );
[56]655 
656#if LOSSLESS_CODING
657  m_cSPS.setUseLossless   ( m_useLossless  );
[2]658#endif
[56]659#if !PIC_CROPPING
[2]660  m_cSPS.setUsePAD        ( m_bUsePAD           );
[56]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  }
[2]688
[56]689  m_cSPS.setUseAMP ( m_useAMP );
[2]690
[56]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)) );
[2]701#endif
702
[56]703  m_cSPS.setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag );
704  m_cSPS.setUseSAO( m_bUseSAO );
[2]705
[56]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 );
[42]741#endif
[56]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 );
[42]752
[56]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 )
[2]761  {
[56]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
[210]771
772#if HHI_DMM_PRED_TEX && FLEX_CODING_ORDER_M23723
773  m_cSPS.setUseDMM34( m_bUseDMM34 );
774#endif
775
[189]776#if OL_QTLIMIT_PREDCODING_B0068
777  m_cSPS.setUseQTLPC( m_bUseQTLPC );
[115]778#endif
[56]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 );
[5]786#if DEPTH_MAP_GENERATION
[56]787    m_cSPS.setPredDepthMapGeneration( m_viewId, true );
[5]788#endif
789#if HHI_INTER_VIEW_RESIDUAL_PRED
[2]790    m_cSPS.setMultiviewResPredMode  ( 0 );
[5]791#endif
[2]792  }
793  else
794  {
[210]795#if QC_MVHEVC_B0046
796    m_cSPS.initMultiviewSPS   ( m_viewId);
797#else
[56]798    m_cSPS.initMultiviewSPS           ( m_viewId, m_iViewOrderIdx, m_uiCamParPrecision, m_bCamParInSliceHeader, m_aaiCodedScale, m_aaiCodedOffset );
[210]799#endif
[56]800    if( m_viewId )
[2]801    {
[5]802#if DEPTH_MAP_GENERATION
803#if HHI_INTER_VIEW_MOTION_PRED
[56]804      m_cSPS.setPredDepthMapGeneration( m_viewId, false, m_uiPredDepthMapGeneration, m_uiMultiviewMvPredMode, m_uiPdmPrecision, m_aaiPdmScaleNomDelta, m_aaiPdmOffset );
[5]805#else
[56]806      m_cSPS.setPredDepthMapGeneration( m_viewId, false, m_uiPredDepthMapGeneration, 0, m_uiPdmPrecision, m_aaiPdmScaleNomDelta, m_aaiPdmOffset );
[5]807#endif
808#endif
809#if HHI_INTER_VIEW_RESIDUAL_PRED
[2]810      m_cSPS.setMultiviewResPredMode  ( m_uiMultiviewResPredMode );
[5]811#endif
[2]812    }
813    else
814    {
[5]815#if DEPTH_MAP_GENERATION
[56]816      m_cSPS.setPredDepthMapGeneration( m_viewId, false );
[5]817#endif
818#if HHI_INTER_VIEW_RESIDUAL_PRED
[2]819      m_cSPS.setMultiviewResPredMode  ( 0 );
[5]820#endif
[2]821    }
822  }
[56]823}
[2]824
[56]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  }   
[2]846#endif
[56]847  Bool bUseDQP = (getMaxCuDQPDepth() > 0)? true : false;
[2]848
[56]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())
[2]857  {
[56]858    if ((getMaxCuDQPDepth() == 0) && (getMaxDeltaQP() == 0 ) && (getQP() == lowestQP) )
859    {
860      bUseDQP = false;
861    }
862    else
863    {
864      bUseDQP = true;
865    }
[2]866  }
[56]867  else
868  {
869    if(bUseDQP == false)
870    {
871      if((getMaxDeltaQP() != 0 )|| getUseAdaptiveQP())
872      {
873        bUseDQP = true;
874      }
875    }
876  }
877
[2]878#else
[56]879  if(bUseDQP == false)
[2]880  {
[56]881    if((getMaxDeltaQP() != 0 )|| getUseAdaptiveQP())
882    {
883      bUseDQP = true;
884    }
[2]885  }
886#endif
887
[56]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  }
[2]900
[56]901  m_cPPS.setChromaQpOffset   ( m_iChromaQpOffset    );
902  m_cPPS.setChromaQpOffset2nd( m_iChromaQpOffset2nd );
[2]903
[56]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);
[2]908#endif
[56]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 );
[2]915#endif
[56]916#if MULTIBITS_DATA_HIDING
917  m_cPPS.setSignHideFlag(getSignHideFlag());
918  m_cPPS.setTSIG(getTSIG());
[2]919#endif
[56]920#if DBL_CONTROL
921  m_cPPS.setDeblockingFilterControlPresent (m_DeblockingFilterControlPresent );
[42]922#endif
[56]923#if PARALLEL_MERGE
924  m_cPPS.setLog2ParallelMergeLevelMinus2      (LOG2_PARALLEL_MERGE_LEVEL_MINUS2);
[5]925#endif
[56]926#if CABAC_INIT_FLAG
927  m_cPPS.setCabacInitPresentFlag(CABAC_INIT_PRESENT_FLAG);
[42]928#endif
[2]929}
930
[56]931//Function for initializing m_RPSList, a list of TComReferencePictureSet, based on the GOPEntry objects read from the config file.
932Void TEncTop::xInitRPS()
[2]933{
[56]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++)
[2]946    {
[56]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      }
[2]957    }
[56]958    rps->setNumberOfNegativePictures(numNeg);
959    rps->setNumberOfPositivePictures(numPos);
960    rps->setInterRPSPrediction(ge.m_interRPSPrediction);
961    if (ge.m_interRPSPrediction)
[2]962    {
[56]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
[2]997    }
[56]998  }
999 
1000}
[2]1001
[56]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{
[210]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
[77]1010  if( slice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDV && POCCurr == 0 )
[210]1011#endif
[56]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);
[2]1023
[56]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    }
[2]1041
[56]1042    slice->setRPS(getRPSList()->getReferencePictureSet(slice->getRPSidx()));
1043    slice->getRPS()->setNumberOfPictures(slice->getRPS()->getNumberOfNegativePictures()+slice->getRPS()->getNumberOfPositivePictures());
1044  }
[2]1045}
1046
[56]1047Void TEncTop::xInitSPSforInterViewRefs()
[2]1048{
[56]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  }
[2]1056
[56]1057  Int numberUsableInterViewRefs = 0;
1058  for( Int i = 0; i < getGOPSize()+1 && numberUsableInterViewRefs < MAX_VIEW_NUM; i++ ) 
[2]1059  {
[56]1060    GOPEntryMvc ge = ( i < getGOPSize() ) ? getGOPEntry( i ) : getGOPEntry( MAX_GOP );
1061    for( Int j = 0; j < ge.m_numInterViewRefPics; j++ )
[2]1062    {
[56]1063      // add ref view to list
1064      Bool onList = false;
1065      for( Int k = 0; k < numberUsableInterViewRefs; k++ )
[2]1066      {
[56]1067        if( ge.m_interViewRefs[j] == m_cSPS.getUsableInterViewRef( k ) )
[2]1068        {
[56]1069          onList = true;
[2]1070          break;
1071        }
1072      }
[56]1073      if( !onList )
[2]1074      {
[56]1075        m_cSPS.setUsableInterViewRef( (UInt)numberUsableInterViewRefs, ge.m_interViewRefs[j] );
1076        numberUsableInterViewRefs++;
[2]1077      }
1078    }
1079  }
[56]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    }
[2]1095  }
[56]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 )
[2]1110    {
[56]1111      m_cPPS.setColumnWidth( m_puiColumnWidth );
1112      m_cPPS.setRowHeight( m_puiRowHeight );
[2]1113    }
[56]1114    m_cPPS.setTileBehaviorControlPresentFlag( m_iTileBehaviorControlPresentFlag );
1115    m_cPPS.setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag );
1116
1117    // # substreams is "per tile" when tiles are independent.
[121]1118    if ( m_iWaveFrontSynchro )
[2]1119    {
[56]1120      m_cPPS.setNumSubstreams(m_iWaveFrontSubstreams * (m_iNumColumnsMinus1+1)*(m_iNumRowsMinus1+1));
[2]1121    }
1122}
1123
[56]1124Void  TEncCfg::xCheckGSParameters()
[2]1125{
[56]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)) )
[2]1133  {
[56]1134    printf( "The number of columns is larger than the maximum allowed number of columns.\n" );
1135    exit( EXIT_FAILURE );
[2]1136  }
[56]1137
1138  if( m_iNumColumnsMinus1 >= iWidthInCU )
[2]1139  {
[56]1140    printf( "The current picture can not have so many columns.\n" );
1141    exit( EXIT_FAILURE );
[2]1142  }
[56]1143
1144  if( m_iNumColumnsMinus1 && m_iUniformSpacingIdr==0 )
[2]1145  {
[56]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    }
[2]1154  }
[56]1155
1156  //check the row relative parameters
1157  if( m_iNumRowsMinus1 >= (1<<(LOG2_MAX_NUM_ROWS_MINUS1+1)) )
[2]1158  {
[56]1159    printf( "The number of rows is larger than the maximum allowed number of rows.\n" );
1160    exit( EXIT_FAILURE );
[2]1161  }
[56]1162
1163  if( m_iNumRowsMinus1 >= iHeightInCU )
[2]1164  {
[56]1165    printf( "The current picture can not have so many rows.\n" );
1166    exit( EXIT_FAILURE );
[2]1167  }
1168
[56]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  }
[2]1180}
1181
[56]1182Void TEncTop::setTEncTopList(std::vector<TEncTop*>* pacTEncTopList )
1183{
1184  assert(m_viewId!=-1); // not to be set for single view coding
[2]1185
[56]1186  m_pacTEncTopList=pacTEncTopList;
1187
1188}
1189
1190Void TEncTop::printOutSummary(UInt uiNumAllPicCoded)
[2]1191{
[56]1192  assert (uiNumAllPicCoded == m_cAnalyzeAll.getNumPic());
[2]1193
[56]1194  //--CFG_KDY
1195  m_cAnalyzeAll.setFrmRate( getFrameRate() );
1196  m_cAnalyzeI.setFrmRate( getFrameRate() );
1197  m_cAnalyzeP.setFrmRate( getFrameRate() );
1198  m_cAnalyzeB.setFrmRate( getFrameRate() );
[2]1199
[56]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');
[2]1214
[56]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');
[2]1228}
[56]1229
1230//! \}
Note: See TracBrowser for help on using the repository browser.