source: 3DVCSoftware/branches/HTM-14.1-update-dev1/source/Lib/TLibEncoder/TEncTop.cpp @ 1314

Last change on this file since 1314 was 1310, checked in by tech, 9 years ago

Fixes:

NH_MV_FIX_TICKET_105 layer_set_idx_for_ols_minus1 length
NH_3D_FIX_TICKET_98 Writing of depth intra skip flag
NH_MV_FIX_TICKET_100 Extra slice header bits

  • Property svn:eol-style set to native
File size: 53.2 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-2015, 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 "TLibCommon/TComChromaFormat.h"
42#if FAST_BIT_EST
43#include "TLibCommon/ContextModel.h"
44#endif
45#if NH_MV
46#include "../../App/TAppEncoder/TAppEncTop.h"
47#endif
48
49//! \ingroup TLibEncoder
50//! \{
51
52// ====================================================================================================================
53// Constructor / destructor / create / destroy
54// ====================================================================================================================
55
56TEncTop::TEncTop()
57{
58  m_iPOCLast          = -1;
59  m_iNumPicRcvd       =  0;
60  m_uiNumAllPicCoded  =  0;
61  m_pppcRDSbacCoder   =  NULL;
62  m_pppcBinCoderCABAC =  NULL;
63  m_cRDGoOnSbacCoder.init( &m_cRDGoOnBinCoderCABAC );
64#if ENC_DEC_TRACE
65  if (g_hTrace == NULL)
66  {
67    g_hTrace = fopen( "TraceEnc.txt", "wb" );
68  }
69  g_bJustDoIt = g_bEncDecTraceDisable;
70  g_nSymbolCounter = 0;
71#endif
72
73  m_iMaxRefPicNum     = 0;
74
75#if FAST_BIT_EST
76  ContextModel::buildNextStateTable();
77#endif
78#if NH_MV
79  m_ivPicLists = NULL;
80#endif
81#if NH_3D_IC
82  m_aICEnableCandidate = NULL;
83  m_aICEnableNum = NULL;
84#endif
85#if NH_3D
86  m_cCavlcCoder.setEncTop(this); 
87#endif
88
89}
90
91TEncTop::~TEncTop()
92{
93#if ENC_DEC_TRACE
94  if (g_hTrace != stdout)
95  {
96    fclose( g_hTrace );
97  }
98#endif
99}
100
101Void TEncTop::create ()
102{
103#if !NH_MV
104  // initialize global variables
105  initROM();
106#endif
107
108  // create processing unit classes
109  m_cGOPEncoder.        create( );
110  m_cSliceEncoder.      create( getSourceWidth(), getSourceHeight(), m_chromaFormatIDC, m_maxCUWidth, m_maxCUHeight, m_maxTotalCUDepth );
111  m_cCuEncoder.         create( m_maxTotalCUDepth, m_maxCUWidth, m_maxCUHeight, m_chromaFormatIDC );
112  if (m_bUseSAO)
113  {
114    m_cEncSAO.create( getSourceWidth(), getSourceHeight(), m_chromaFormatIDC, m_maxCUWidth, m_maxCUHeight, m_maxTotalCUDepth, m_log2SaoOffsetScale[CHANNEL_TYPE_LUMA], m_log2SaoOffsetScale[CHANNEL_TYPE_CHROMA] );
115    m_cEncSAO.createEncData(getSaoCtuBoundary());
116  }
117#if ADAPTIVE_QP_SELECTION
118  if (m_bUseAdaptQpSelect)
119  {
120    m_cTrQuant.initSliceQpDelta();
121  }
122#endif
123
124  m_cLoopFilter.create( m_maxTotalCUDepth );
125
126  if ( m_RCEnableRateControl )
127  {
128#if KWU_RC_MADPRED_E0227
129    m_cRateCtrl.init( m_framesToBeEncoded, m_RCTargetBitrate, m_iFrameRate, m_iGOPSize, m_iSourceWidth, m_iSourceHeight,
130      g_uiMaxCUWidth, g_uiMaxCUHeight, m_RCKeepHierarchicalBit, m_RCUseLCUSeparateModel, m_GOPList, getLayerId() );
131#else
132    m_cRateCtrl.init( m_framesToBeEncoded, m_RCTargetBitrate, m_iFrameRate, m_iGOPSize, m_iSourceWidth, m_iSourceHeight,
133        m_maxCUWidth, m_maxCUHeight, m_RCKeepHierarchicalBit, m_RCUseLCUSeparateModel, m_GOPList );
134#endif
135  }
136
137  m_pppcRDSbacCoder = new TEncSbac** [m_maxTotalCUDepth+1];
138#if FAST_BIT_EST
139  m_pppcBinCoderCABAC = new TEncBinCABACCounter** [m_maxTotalCUDepth+1];
140#else
141  m_pppcBinCoderCABAC = new TEncBinCABAC** [m_maxTotalCUDepth+1];
142#endif
143
144  for ( Int iDepth = 0; iDepth < m_maxTotalCUDepth+1; iDepth++ )
145  {
146    m_pppcRDSbacCoder[iDepth] = new TEncSbac* [CI_NUM];
147#if FAST_BIT_EST
148    m_pppcBinCoderCABAC[iDepth] = new TEncBinCABACCounter* [CI_NUM];
149#else
150    m_pppcBinCoderCABAC[iDepth] = new TEncBinCABAC* [CI_NUM];
151#endif
152
153    for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ )
154    {
155      m_pppcRDSbacCoder[iDepth][iCIIdx] = new TEncSbac;
156#if FAST_BIT_EST
157      m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABACCounter;
158#else
159      m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABAC;
160#endif
161      m_pppcRDSbacCoder   [iDepth][iCIIdx]->init( m_pppcBinCoderCABAC [iDepth][iCIIdx] );
162    }
163  }
164}
165
166Void TEncTop::destroy ()
167{
168  // destroy processing unit classes
169  m_cGOPEncoder.        destroy();
170  m_cSliceEncoder.      destroy();
171  m_cCuEncoder.         destroy();
172  m_cEncSAO.            destroyEncData();
173  m_cEncSAO.            destroy();
174  m_cLoopFilter.        destroy();
175  m_cRateCtrl.          destroy();
176  m_cSearch.            destroy();
177  Int iDepth;
178  for ( iDepth = 0; iDepth < m_maxTotalCUDepth+1; iDepth++ )
179  {
180    for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ )
181    {
182      delete m_pppcRDSbacCoder[iDepth][iCIIdx];
183      delete m_pppcBinCoderCABAC[iDepth][iCIIdx];
184    }
185  }
186
187  for ( iDepth = 0; iDepth < m_maxTotalCUDepth+1; iDepth++ )
188  {
189    delete [] m_pppcRDSbacCoder[iDepth];
190    delete [] m_pppcBinCoderCABAC[iDepth];
191  }
192
193  delete [] m_pppcRDSbacCoder;
194  delete [] m_pppcBinCoderCABAC;
195
196#if !NH_MV
197  // destroy ROM
198  destroyROM();
199#endif
200
201  return;
202}
203
204#if KWU_RC_MADPRED_E0227
205Void TEncTop::init(TAppEncTop* pcTAppEncTop, Bool isFieldCoding)
206#else
207Void TEncTop::init(Bool isFieldCoding)
208#endif
209{
210  // initialize SPS
211#if H_3D
212  // Assuming that all PPS indirectly refer to the same VPS via different SPS
213  m_cSPS.setVPS(m_cVPS);
214#endif
215  xInitSPS();
216  xInitVPS();
217
218  m_cRdCost.setCostMode(m_costMode);
219
220#if NH_MV
221  // This seems to be incorrect, but irrelevant for the MV-HEVC
222  *(m_cVPS->getPTL()) = *m_cSPS.getPTL();
223  m_cVPS->getTimingInfo()->setTimingInfoPresentFlag       ( false );
224#endif
225  // initialize PPS
226  xInitPPS();
227  xInitRPS(isFieldCoding);
228
229  xInitPPSforTiles();
230#if NH_3D_IC
231  m_aICEnableCandidate = new Int[ 10 ];
232  m_aICEnableNum = new Int[ 10 ];
233
234  for(int i=0;i<10;i++)
235  {
236    m_aICEnableCandidate[i]=0;
237    m_aICEnableNum[i]=0;
238  }
239#endif
240
241  // initialize processing unit classes
242  m_cGOPEncoder.  init( this );
243  m_cSliceEncoder.init( this );
244  m_cCuEncoder.   init( this );
245
246#if KWU_RC_MADPRED_E0227
247  m_pcTAppEncTop = pcTAppEncTop;
248#endif
249  // initialize transform & quantization class
250  m_pcCavlcCoder = getCavlcCoder();
251
252  m_cTrQuant.init( 1 << m_uiQuadtreeTULog2MaxSize,
253                   m_useRDOQ,
254                   m_useRDOQTS,
255#if T0196_SELECTIVE_RDOQ
256                   m_useSelectiveRDOQ,
257#endif
258                   true
259                  ,m_useTransformSkipFast
260#if ADAPTIVE_QP_SELECTION
261                  ,m_bUseAdaptQpSelect
262#endif
263                  );
264
265  // initialize encoder search class
266  m_cSearch.init( this, &m_cTrQuant, m_iSearchRange, m_bipredSearchRange, m_iFastSearch, m_maxCUWidth, m_maxCUHeight, m_maxTotalCUDepth, &m_cEntropyCoder, &m_cRdCost, getRDSbacCoder(), getRDGoOnSbacCoder() );
267
268  m_iMaxRefPicNum = 0;
269
270  xInitScalingLists();
271}
272
273Void TEncTop::xInitScalingLists()
274{
275  // Initialise scaling lists
276  // The encoder will only use the SPS scaling lists. The PPS will never be marked present.
277  const Int maxLog2TrDynamicRange[MAX_NUM_CHANNEL_TYPE] =
278  {
279      m_cSPS.getMaxLog2TrDynamicRange(CHANNEL_TYPE_LUMA),
280      m_cSPS.getMaxLog2TrDynamicRange(CHANNEL_TYPE_CHROMA)
281  };
282  if(getUseScalingListId() == SCALING_LIST_OFF)
283  {
284    getTrQuant()->setFlatScalingList(maxLog2TrDynamicRange, m_cSPS.getBitDepths());
285    getTrQuant()->setUseScalingList(false);
286    m_cSPS.setScalingListPresentFlag(false);
287    m_cPPS.setScalingListPresentFlag(false);
288  }
289  else if(getUseScalingListId() == SCALING_LIST_DEFAULT)
290  {
291    m_cSPS.getScalingList().setDefaultScalingList ();
292    m_cSPS.setScalingListPresentFlag(false);
293    m_cPPS.setScalingListPresentFlag(false);
294
295    getTrQuant()->setScalingList(&(m_cSPS.getScalingList()), maxLog2TrDynamicRange, m_cSPS.getBitDepths());
296    getTrQuant()->setUseScalingList(true);
297  }
298  else if(getUseScalingListId() == SCALING_LIST_FILE_READ)
299  {
300    m_cSPS.getScalingList().setDefaultScalingList ();
301    if(m_cSPS.getScalingList().xParseScalingList(getScalingListFile()))
302    {
303      Bool bParsedScalingList=false; // Use of boolean so that assertion outputs useful string
304      assert(bParsedScalingList);
305      exit(1);
306    }
307    m_cSPS.getScalingList().checkDcOfMatrix();
308    m_cSPS.setScalingListPresentFlag(m_cSPS.getScalingList().checkDefaultScalingList());
309    m_cPPS.setScalingListPresentFlag(false);
310    getTrQuant()->setScalingList(&(m_cSPS.getScalingList()), maxLog2TrDynamicRange, m_cSPS.getBitDepths());
311    getTrQuant()->setUseScalingList(true);
312  }
313  else
314  {
315    printf("error : ScalingList == %d not supported\n",getUseScalingListId());
316    assert(0);
317  }
318
319  if (getUseScalingListId() != SCALING_LIST_OFF)
320  { 
321    // Prepare delta's:
322  for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++)
323  {
324    const Int predListStep = (sizeId == SCALING_LIST_32x32? (SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) : 1); // if 32x32, skip over chroma entries.
325
326    for(UInt listId = 0; listId < SCALING_LIST_NUM; listId+=predListStep)
327    {
328      m_cSPS.getScalingList().checkPredMode( sizeId, listId );
329    }
330  }
331  }
332}
333
334// ====================================================================================================================
335// Public member functions
336// ====================================================================================================================
337
338#if NH_MV
339Void TEncTop::initNewPic( TComPicYuv* pcPicYuvOrg )
340{
341  TComPic* pcPicCurr = NULL;
342
343  // get original YUV
344  xGetNewPicBuffer( pcPicCurr );
345  pcPicYuvOrg->copyToPic( pcPicCurr->getPicYuvOrg() );
346
347  // compute image characteristics
348  if ( getUseAdaptiveQP() )
349  {
350    m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcPicCurr ) );
351  }
352#if NH_MV
353  pcPicCurr->setLayerId( getLayerId()); 
354#endif
355#if NH_3D
356  pcPicCurr->setScaleOffset( m_cameraParameters->getCodedScale(), m_cameraParameters->getCodedOffset() );
357#endif
358}
359#endif
360
361Void TEncTop::deletePicBuffer()
362{
363  TComList<TComPic*>::iterator iterPic = m_cListPic.begin();
364  Int iSize = Int( m_cListPic.size() );
365
366  for ( Int i = 0; i < iSize; i++ )
367  {
368    TComPic* pcPic = *(iterPic++);
369
370    pcPic->destroy();
371    delete pcPic;
372    pcPic = NULL;
373  }
374}
375
376/**
377 - Application has picture buffer list with size of GOP + 1
378 - Picture buffer list acts like as ring buffer
379 - End of the list has the latest picture
380 .
381 \param   flush               cause encoder to encode a partial GOP
382 \param   pcPicYuvOrg         original YUV picture
383 \param   pcPicYuvTrueOrg     
384 \param   snrCSC
385 \retval  rcListPicYuvRecOut  list of reconstruction YUV pictures
386 \retval  accessUnitsOut      list of output access units
387 \retval  iNumEncoded         number of encoded pictures
388 */
389#if NH_MV
390Void TEncTop::encode( Bool flush, TComPicYuv* pcPicYuvOrg, TComPicYuv* pcPicYuvTrueOrg, const InputColourSpaceConversion snrCSC, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Int gopId )
391{
392#else
393Void TEncTop::encode( Bool flush, TComPicYuv* pcPicYuvOrg, TComPicYuv* pcPicYuvTrueOrg, const InputColourSpaceConversion snrCSC, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded )
394{
395#endif
396#if NH_3D
397  TComPic* picLastCoded = getPic( getGOPEncoder()->getPocLastCoded() );
398  if( picLastCoded )
399  {
400    picLastCoded->compressMotion(1); 
401  }
402#endif
403#if NH_MV
404  if( gopId == 0)
405  {
406    m_cGOPEncoder.initGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut); 
407#else
408  if (pcPicYuvOrg != NULL)
409  {
410    // get original YUV
411    TComPic* pcPicCurr = NULL;
412
413    xGetNewPicBuffer( pcPicCurr );
414    pcPicYuvOrg->copyToPic( pcPicCurr->getPicYuvOrg() );
415    pcPicYuvTrueOrg->copyToPic( pcPicCurr->getPicYuvTrueOrg() );
416
417    // compute image characteristics
418    if ( getUseAdaptiveQP() )
419    {
420      m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcPicCurr ) );
421    }
422  }
423
424  if ((m_iNumPicRcvd == 0) || (!flush && (m_iPOCLast != 0) && (m_iNumPicRcvd != m_iGOPSize) && (m_iGOPSize != 0)))
425  {
426    iNumEncoded = 0;
427    return;
428  }
429#endif
430  if ( m_RCEnableRateControl )
431  {
432    m_cRateCtrl.initRCGOP( m_iNumPicRcvd );
433  }
434#if NH_MV
435  }
436  m_cGOPEncoder.compressPicInGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, false, false, snrCSC, m_printFrameMSE, gopId);
437
438  if( gopId + 1 == m_cGOPEncoder.getGOPSize() )
439  {
440#else
441  // compress GOP
442  m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, false, false, snrCSC, m_printFrameMSE);
443#endif
444  if ( m_RCEnableRateControl )
445  {
446    m_cRateCtrl.destroyRCGOP();
447  }
448
449  iNumEncoded         = m_iNumPicRcvd;
450  m_iNumPicRcvd       = 0;
451  m_uiNumAllPicCoded += iNumEncoded;
452#if NH_MV
453}
454#endif
455}
456
457/**------------------------------------------------
458 Separate interlaced frame into two fields
459 -------------------------------------------------**/
460Void separateFields(Pel* org, Pel* dstField, UInt stride, UInt width, UInt height, Bool isTop)
461{
462  if (!isTop)
463  {
464    org += stride;
465  }
466  for (Int y = 0; y < height>>1; y++)
467  {
468    for (Int x = 0; x < width; x++)
469    {
470      dstField[x] = org[x];
471    }
472
473    dstField += stride;
474    org += stride*2;
475  }
476
477}
478#if NH_MV
479Void TEncTop::encode(Bool flush, TComPicYuv* pcPicYuvOrg, TComPicYuv* pcPicYuvTrueOrg, const InputColourSpaceConversion snrCSC, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Bool isTff, Int gopId )
480{
481  assert( 0 ); // Field coding and multiview need to be further harmonized.
482}
483#else
484Void TEncTop::encode(Bool flush, TComPicYuv* pcPicYuvOrg, TComPicYuv* pcPicYuvTrueOrg, const InputColourSpaceConversion snrCSC, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Bool isTff)
485{
486  iNumEncoded = 0;
487
488  for (Int fieldNum=0; fieldNum<2; fieldNum++)
489  {
490    if (pcPicYuvOrg)
491    {
492
493      /* -- field initialization -- */
494      const Bool isTopField=isTff==(fieldNum==0);
495
496      TComPic *pcField;
497      xGetNewPicBuffer( pcField );
498      pcField->setReconMark (false);                     // where is this normally?
499
500      if (fieldNum==1)                                   // where is this normally?
501      {
502        TComPicYuv* rpcPicYuvRec;
503
504        // org. buffer
505        if ( rcListPicYuvRecOut.size() >= (UInt)m_iGOPSize+1 ) // need to maintain field 0 in list of RecOuts while processing field 1. Hence +1 on m_iGOPSize.
506        {
507          rpcPicYuvRec = rcListPicYuvRecOut.popFront();
508        }
509        else
510        {
511          rpcPicYuvRec = new TComPicYuv;
512          rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, m_maxCUWidth, m_maxCUHeight, m_maxTotalCUDepth, true);
513        }
514        rcListPicYuvRecOut.pushBack( rpcPicYuvRec );
515      }
516
517      pcField->getSlice(0)->setPOC( m_iPOCLast );        // superfluous?
518      pcField->getPicYuvRec()->setBorderExtension(false);// where is this normally?
519
520      pcField->setTopField(isTopField);                  // interlaced requirement
521
522      for (UInt componentIndex = 0; componentIndex < pcPicYuvOrg->getNumberValidComponents(); componentIndex++)
523      {
524        const ComponentID component = ComponentID(componentIndex);
525        const UInt stride = pcPicYuvOrg->getStride(component);
526
527        separateFields((pcPicYuvOrg->getBuf(component) + pcPicYuvOrg->getMarginX(component) + (pcPicYuvOrg->getMarginY(component) * stride)),
528                       pcField->getPicYuvOrg()->getAddr(component),
529                       pcPicYuvOrg->getStride(component),
530                       pcPicYuvOrg->getWidth(component),
531                       pcPicYuvOrg->getHeight(component),
532                       isTopField);
533
534        separateFields((pcPicYuvTrueOrg->getBuf(component) + pcPicYuvTrueOrg->getMarginX(component) + (pcPicYuvTrueOrg->getMarginY(component) * stride)),
535                       pcField->getPicYuvTrueOrg()->getAddr(component),
536                       pcPicYuvTrueOrg->getStride(component),
537                       pcPicYuvTrueOrg->getWidth(component),
538                       pcPicYuvTrueOrg->getHeight(component),
539                       isTopField);
540      }
541
542      // compute image characteristics
543      if ( getUseAdaptiveQP() )
544      {
545        m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcField ) );
546      }
547    }
548
549    if ( m_iNumPicRcvd && ((flush&&fieldNum==1) || (m_iPOCLast/2)==0 || m_iNumPicRcvd==m_iGOPSize ) )
550    {
551      // compress GOP
552      m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff, snrCSC, m_printFrameMSE);
553
554      iNumEncoded += m_iNumPicRcvd;
555      m_uiNumAllPicCoded += m_iNumPicRcvd;
556      m_iNumPicRcvd = 0;
557    }
558  }
559}
560#endif
561// ====================================================================================================================
562// Protected member functions
563// ====================================================================================================================
564
565/**
566 - Application has picture buffer list with size of GOP + 1
567 - Picture buffer list acts like as ring buffer
568 - End of the list has the latest picture
569 .
570 \retval rpcPic obtained picture buffer
571 */
572Void TEncTop::xGetNewPicBuffer ( TComPic*& rpcPic )
573{
574  // At this point, the SPS and PPS can be considered activated - they are copied to the new TComPic.
575
576  TComSlice::sortPicList(m_cListPic);
577
578
579  if (m_cListPic.size() >= (UInt)(m_iGOPSize + getMaxDecPicBuffering(MAX_TLAYER-1) + 2) )
580  {
581    TComList<TComPic*>::iterator iterPic  = m_cListPic.begin();
582    Int iSize = Int( m_cListPic.size() );
583    for ( Int i = 0; i < iSize; i++ )
584    {
585      rpcPic = *(iterPic++);
586      if(rpcPic->getSlice(0)->isReferenced() == false)
587      {
588        break;
589      }
590    }
591  }
592  else
593  {
594    if ( getUseAdaptiveQP() )
595    {
596      TEncPic* pcEPic = new TEncPic;
597      pcEPic->create( m_cSPS, m_cPPS, m_cPPS.getMaxCuDQPDepth()+1, false);
598      rpcPic = pcEPic;
599    }
600    else
601    {
602      rpcPic = new TComPic;
603      rpcPic->create( m_cSPS, m_cPPS, false );
604    }
605
606    m_cListPic.pushBack( rpcPic );
607  }
608  rpcPic->setReconMark (false);
609
610  m_iPOCLast++;
611  m_iNumPicRcvd++;
612
613  rpcPic->getSlice(0)->setPOC( m_iPOCLast );
614  // mark it should be extended
615  rpcPic->getPicYuvRec()->setBorderExtension(false);
616#if NH_MV
617  rpcPic->getPicYuvOrg()->setBorderExtension(false);
618#endif
619
620}
621
622Void TEncTop::xInitVPS()
623{
624  // The SPS must have already been set up.
625  // set the VPS profile information.
626#if NH_MV
627  // Do initialization in TAppEncTop
628#else
629  *m_cVPS.getPTL() = *m_cSPS.getPTL();
630  m_cVPS.setMaxOpSets(1);
631  m_cVPS.getTimingInfo()->setTimingInfoPresentFlag       ( false );
632  m_cVPS.setNumHrdParameters( 0 );
633
634  m_cVPS.createHrdParamBuffer();
635  for( UInt i = 0; i < m_cVPS.getNumHrdParameters(); i ++ )
636  {
637    m_cVPS.setHrdOpSetIdx( 0, i );
638    m_cVPS.setCprmsPresentFlag( false, i );
639    // Set up HrdParameters here.
640  }
641#endif
642}
643
644Void TEncTop::xInitSPS()
645{
646#if NH_MV
647  m_cSPS.setSPSId( getLayerIdInVps() );
648  m_cSPS.setLayerId( getLayerId() );
649 // Code below needs to be moved to VPS
650#endif
651  ProfileTierLevel& profileTierLevel = *m_cSPS.getPTL()->getGeneralPTL();
652  profileTierLevel.setLevelIdc(m_level);
653  profileTierLevel.setTierFlag(m_levelTier);
654  profileTierLevel.setProfileIdc(m_profile);
655  profileTierLevel.setProfileCompatibilityFlag(m_profile, 1);
656  profileTierLevel.setProgressiveSourceFlag(m_progressiveSourceFlag);
657  profileTierLevel.setInterlacedSourceFlag(m_interlacedSourceFlag);
658  profileTierLevel.setNonPackedConstraintFlag(m_nonPackedConstraintFlag);
659  profileTierLevel.setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag);
660  profileTierLevel.setBitDepthConstraint(m_bitDepthConstraintValue);
661  profileTierLevel.setChromaFormatConstraint(m_chromaFormatConstraintValue);
662  profileTierLevel.setIntraConstraintFlag(m_intraConstraintFlag);
663  profileTierLevel.setOnePictureOnlyConstraintFlag(m_onePictureOnlyConstraintFlag);
664  profileTierLevel.setLowerBitRateConstraintFlag(m_lowerBitRateConstraintFlag);
665
666  if ((m_profile == Profile::MAIN10) && (m_bitDepth[CHANNEL_TYPE_LUMA] == 8) && (m_bitDepth[CHANNEL_TYPE_CHROMA] == 8))
667  {
668    /* The above constraint is equal to Profile::MAIN */
669    profileTierLevel.setProfileCompatibilityFlag(Profile::MAIN, 1);
670  }
671  if (m_profile == Profile::MAIN)
672  {
673    /* A Profile::MAIN10 decoder can always decode Profile::MAIN */
674    profileTierLevel.setProfileCompatibilityFlag(Profile::MAIN10, 1);
675  }
676  /* XXX: should Main be marked as compatible with still picture? */
677  /* XXX: may be a good idea to refactor the above into a function
678   * that chooses the actual compatibility based upon options */
679#if NH_MV 
680  m_cSPS.setUpdateRepFormatFlag           ( false );   
681  Bool multiLayerExtensionFlag  = ( getLayerId() > 0 ) && ( m_cVPS->getNumRefLayers( getLayerId() ) > 0 ); 
682 
683  m_cSPS.setSpsExtOrMaxSubLayersMinus1( multiLayerExtensionFlag ? 7 : m_maxTempLayer - 1 );
684  if ( multiLayerExtensionFlag )
685  {
686    m_cSPS.setSpsInferScalingListFlag   ( true ); 
687    m_cSPS.setSpsScalingListRefLayerId( m_cVPS->getIdRefLayer( getLayerId(), 0 ) ); 
688#if NH_MV
689    if ( m_bUseDisparitySearchRangeRestriction )
690    {
691      m_cSPS.setInterViewMvVertConstraintFlag ( true ) ;
692    }
693#endif
694  } 
695  m_cSPS.setSpsExtensionPresentFlag       ( true ); 
696  m_cSPS.setSpsMultilayerExtensionFlag    ( true ); 
697#if NH_3D
698  m_cSPS.setSps3dExtensionFlag            ( true ); 
699#endif
700#endif
701
702  m_cSPS.setPicWidthInLumaSamples  ( m_iSourceWidth      );
703  m_cSPS.setPicHeightInLumaSamples ( m_iSourceHeight     );
704  m_cSPS.setConformanceWindow      ( m_conformanceWindow );
705  m_cSPS.setMaxCUWidth             ( m_maxCUWidth        );
706  m_cSPS.setMaxCUHeight            ( m_maxCUHeight       );
707  m_cSPS.setMaxTotalCUDepth        ( m_maxTotalCUDepth   );
708#if NH_3D
709  assert( !getIsDepth()  || m_chromaFormatIDC == CHROMA_400 ); 
710#endif
711  m_cSPS.setChromaFormatIdc( m_chromaFormatIDC);
712  m_cSPS.setLog2DiffMaxMinCodingBlockSize(m_log2DiffMaxMinCodingBlockSize);
713
714  Int minCUSize = m_cSPS.getMaxCUWidth() >> ( m_cSPS.getLog2DiffMaxMinCodingBlockSize() );
715  Int log2MinCUSize = 0;
716  while(minCUSize > 1)
717  {
718    minCUSize >>= 1;
719    log2MinCUSize++;
720  }
721
722  m_cSPS.setLog2MinCodingBlockSize(log2MinCUSize);
723
724  m_cSPS.setPCMLog2MinSize (m_uiPCMLog2MinSize);
725  m_cSPS.setUsePCM        ( m_usePCM           );
726  m_cSPS.setPCMLog2MaxSize( m_pcmLog2MaxSize  );
727
728  m_cSPS.setQuadtreeTULog2MaxSize( m_uiQuadtreeTULog2MaxSize );
729  m_cSPS.setQuadtreeTULog2MinSize( m_uiQuadtreeTULog2MinSize );
730  m_cSPS.setQuadtreeTUMaxDepthInter( m_uiQuadtreeTUMaxDepthInter    );
731  m_cSPS.setQuadtreeTUMaxDepthIntra( m_uiQuadtreeTUMaxDepthIntra    );
732
733  m_cSPS.setTMVPFlagsPresent((getTMVPModeId() == 2 || getTMVPModeId() == 1));
734
735  m_cSPS.setMaxTrSize   ( 1 << m_uiQuadtreeTULog2MaxSize );
736
737  m_cSPS.setUseAMP ( m_useAMP );
738
739  for (UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++)
740  {
741    m_cSPS.setBitDepth      (ChannelType(channelType), m_bitDepth[channelType] );
742#if O0043_BEST_EFFORT_DECODING
743    m_cSPS.setStreamBitDepth(ChannelType(channelType), m_bitDepth[channelType] );
744#endif
745    m_cSPS.setQpBDOffset  (ChannelType(channelType), (6 * (m_bitDepth[channelType] - 8)));
746    m_cSPS.setPCMBitDepth (ChannelType(channelType), m_PCMBitDepth[channelType]         );
747  }
748#if NH_MV
749  m_cSPS.inferRepFormat( m_cVPS, getLayerId(), true ); 
750#endif
751m_cSPS.setUseSAO( m_bUseSAO );
752
753  m_cSPS.setMaxTLayers( m_maxTempLayer );
754  m_cSPS.setTemporalIdNestingFlag( ( m_maxTempLayer == 1 ) ? true : false );
755
756  for (Int i = 0; i < min(m_cSPS.getMaxTLayers(),(UInt) MAX_TLAYER); i++ )
757  {
758    m_cSPS.setMaxDecPicBuffering(m_maxDecPicBuffering[i], i);
759    m_cSPS.setNumReorderPics(m_numReorderPics[i], i);
760  }
761#if NH_MV
762  for ( Int ols = 0; ols < m_cVPS->getNumOutputLayerSets(); ols++)
763  {
764    // Check MaxDecPicBuffering
765    const std::vector<Int>& targetDecLayerIdList = m_cVPS->getTargetDecLayerIdList( m_cVPS->olsIdxToLsIdx( ols )); 
766    for( Int is = 0; is < targetDecLayerIdList.size(); is++  )
767    {
768      if ( m_cVPS->getNecessaryLayerFlag( ols, is ) )
769      {     
770        m_cSPS.inferSpsMaxDecPicBufferingMinus1( m_cVPS, ols, targetDecLayerIdList[is], true );       
771      }
772    }
773  }
774#endif
775
776
777  m_cSPS.setPCMFilterDisableFlag  ( m_bPCMFilterDisableFlag );
778  m_cSPS.setScalingListFlag ( (m_useScalingListId == SCALING_LIST_OFF) ? 0 : 1 );
779  m_cSPS.setUseStrongIntraSmoothing( m_useStrongIntraSmoothing );
780  m_cSPS.setVuiParametersPresentFlag(getVuiParametersPresentFlag());
781
782  if (m_cSPS.getVuiParametersPresentFlag())
783  {
784    TComVUI* pcVUI = m_cSPS.getVuiParameters();
785    pcVUI->setAspectRatioInfoPresentFlag(getAspectRatioInfoPresentFlag());
786    pcVUI->setAspectRatioIdc(getAspectRatioIdc());
787    pcVUI->setSarWidth(getSarWidth());
788    pcVUI->setSarHeight(getSarHeight());
789    pcVUI->setOverscanInfoPresentFlag(getOverscanInfoPresentFlag());
790    pcVUI->setOverscanAppropriateFlag(getOverscanAppropriateFlag());
791#if NH_MV
792    pcVUI->setVideoSignalTypePresentFlag(getVideoSignalTypePresentFlag() && getLayerId() == 0 );
793#else
794    pcVUI->setVideoSignalTypePresentFlag(getVideoSignalTypePresentFlag());
795#endif
796    pcVUI->setVideoFormat(getVideoFormat());
797    pcVUI->setVideoFullRangeFlag(getVideoFullRangeFlag());
798    pcVUI->setColourDescriptionPresentFlag(getColourDescriptionPresentFlag());
799    pcVUI->setColourPrimaries(getColourPrimaries());
800    pcVUI->setTransferCharacteristics(getTransferCharacteristics());
801    pcVUI->setMatrixCoefficients(getMatrixCoefficients());
802    pcVUI->setChromaLocInfoPresentFlag(getChromaLocInfoPresentFlag());
803    pcVUI->setChromaSampleLocTypeTopField(getChromaSampleLocTypeTopField());
804    pcVUI->setChromaSampleLocTypeBottomField(getChromaSampleLocTypeBottomField());
805    pcVUI->setNeutralChromaIndicationFlag(getNeutralChromaIndicationFlag());
806    pcVUI->setDefaultDisplayWindow(getDefaultDisplayWindow());
807    pcVUI->setFrameFieldInfoPresentFlag(getFrameFieldInfoPresentFlag());
808    pcVUI->setFieldSeqFlag(false);
809    pcVUI->setHrdParametersPresentFlag(false);
810    pcVUI->getTimingInfo()->setPocProportionalToTimingFlag(getPocProportionalToTimingFlag());
811    pcVUI->getTimingInfo()->setNumTicksPocDiffOneMinus1   (getNumTicksPocDiffOneMinus1()   );
812    pcVUI->setBitstreamRestrictionFlag(getBitstreamRestrictionFlag());
813    pcVUI->setTilesFixedStructureFlag(getTilesFixedStructureFlag());
814    pcVUI->setMotionVectorsOverPicBoundariesFlag(getMotionVectorsOverPicBoundariesFlag());
815    pcVUI->setMinSpatialSegmentationIdc(getMinSpatialSegmentationIdc());
816    pcVUI->setMaxBytesPerPicDenom(getMaxBytesPerPicDenom());
817    pcVUI->setMaxBitsPerMinCuDenom(getMaxBitsPerMinCuDenom());
818    pcVUI->setLog2MaxMvLengthHorizontal(getLog2MaxMvLengthHorizontal());
819    pcVUI->setLog2MaxMvLengthVertical(getLog2MaxMvLengthVertical());
820  }
821  m_cSPS.setNumLongTermRefPicSPS(NUM_LONG_TERM_REF_PIC_SPS);
822  assert (NUM_LONG_TERM_REF_PIC_SPS <= MAX_NUM_LONG_TERM_REF_PICS);
823  for (Int k = 0; k < NUM_LONG_TERM_REF_PIC_SPS; k++)
824  {
825    m_cSPS.setLtRefPicPocLsbSps(k, 0);
826    m_cSPS.setUsedByCurrPicLtSPSFlag(k, 0);
827  }
828  if( getPictureTimingSEIEnabled() || getDecodingUnitInfoSEIEnabled() )
829  {
830    xInitHrdParameters();
831  }
832  if( getBufferingPeriodSEIEnabled() || getPictureTimingSEIEnabled() || getDecodingUnitInfoSEIEnabled() )
833  {
834    m_cSPS.getVuiParameters()->setHrdParametersPresentFlag( true );
835  }
836
837  // Set up SPS range extension settings
838  m_cSPS.getSpsRangeExtension().setTransformSkipRotationEnabledFlag(m_transformSkipRotationEnabledFlag);
839  m_cSPS.getSpsRangeExtension().setTransformSkipContextEnabledFlag(m_transformSkipContextEnabledFlag);
840  for (UInt signallingModeIndex = 0; signallingModeIndex < NUMBER_OF_RDPCM_SIGNALLING_MODES; signallingModeIndex++)
841  {
842    m_cSPS.getSpsRangeExtension().setRdpcmEnabledFlag(RDPCMSignallingMode(signallingModeIndex), m_rdpcmEnabledFlag[signallingModeIndex]);
843  }
844  m_cSPS.getSpsRangeExtension().setExtendedPrecisionProcessingFlag(m_extendedPrecisionProcessingFlag);
845  m_cSPS.getSpsRangeExtension().setIntraSmoothingDisabledFlag( m_intraSmoothingDisabledFlag );
846  m_cSPS.getSpsRangeExtension().setHighPrecisionOffsetsEnabledFlag(m_highPrecisionOffsetsEnabledFlag);
847  m_cSPS.getSpsRangeExtension().setPersistentRiceAdaptationEnabledFlag(m_persistentRiceAdaptationEnabledFlag);
848  m_cSPS.getSpsRangeExtension().setCabacBypassAlignmentEnabledFlag(m_cabacBypassAlignmentEnabledFlag);
849#if NH_MV
850  m_cSPS.setSpsRangeExtensionsFlag( m_cSPS.getSpsRangeExtension().settingsDifferFromDefaults() );
851#endif
852
853}
854
855Void TEncTop::xInitHrdParameters()
856{
857  Bool useSubCpbParams = (getSliceMode() > 0) || (getSliceSegmentMode() > 0);
858  Int  bitRate         = getTargetBitrate();
859  Bool isRandomAccess  = getIntraPeriod() > 0;
860
861  if( !getVuiParametersPresentFlag() )
862  {
863    return;
864  }
865
866  TComVUI *vui = m_cSPS.getVuiParameters();
867  TComHRD *hrd = vui->getHrdParameters();
868
869  TimingInfo *timingInfo = vui->getTimingInfo();
870  timingInfo->setTimingInfoPresentFlag( true );
871  switch( getFrameRate() )
872  {
873  case 24:
874    timingInfo->setNumUnitsInTick( 1125000 );    timingInfo->setTimeScale    ( 27000000 );
875    break;
876  case 25:
877    timingInfo->setNumUnitsInTick( 1080000 );    timingInfo->setTimeScale    ( 27000000 );
878    break;
879  case 30:
880    timingInfo->setNumUnitsInTick( 900900 );     timingInfo->setTimeScale    ( 27000000 );
881    break;
882  case 50:
883    timingInfo->setNumUnitsInTick( 540000 );     timingInfo->setTimeScale    ( 27000000 );
884    break;
885  case 60:
886    timingInfo->setNumUnitsInTick( 450450 );     timingInfo->setTimeScale    ( 27000000 );
887    break;
888  default:
889    timingInfo->setNumUnitsInTick( 1001 );       timingInfo->setTimeScale    ( 60000 );
890    break;
891  }
892
893  Bool rateCnt = ( bitRate > 0 );
894  hrd->setNalHrdParametersPresentFlag( rateCnt );
895  hrd->setVclHrdParametersPresentFlag( rateCnt );
896
897  hrd->setSubPicCpbParamsPresentFlag( useSubCpbParams );
898
899  if( hrd->getSubPicCpbParamsPresentFlag() )
900  {
901    hrd->setTickDivisorMinus2( 100 - 2 );                          //
902    hrd->setDuCpbRemovalDelayLengthMinus1( 7 );                    // 8-bit precision ( plus 1 for last DU in AU )
903    hrd->setSubPicCpbParamsInPicTimingSEIFlag( true );
904    hrd->setDpbOutputDelayDuLengthMinus1( 5 + 7 );                 // With sub-clock tick factor of 100, at least 7 bits to have the same value as AU dpb delay
905  }
906  else
907  {
908    hrd->setSubPicCpbParamsInPicTimingSEIFlag( false );
909  }
910
911  hrd->setBitRateScale( 4 );                                       // in units of 2^( 6 + 4 ) = 1,024 bps
912  hrd->setCpbSizeScale( 6 );                                       // in units of 2^( 4 + 6 ) = 1,024 bit
913  hrd->setDuCpbSizeScale( 6 );                                     // in units of 2^( 4 + 6 ) = 1,024 bit
914
915  hrd->setInitialCpbRemovalDelayLengthMinus1(15);                  // assuming 0.5 sec, log2( 90,000 * 0.5 ) = 16-bit
916  if( isRandomAccess )
917  {
918    hrd->setCpbRemovalDelayLengthMinus1(5);                        // 32 = 2^5 (plus 1)
919    hrd->setDpbOutputDelayLengthMinus1 (5);                        // 32 + 3 = 2^6
920  }
921  else
922  {
923    hrd->setCpbRemovalDelayLengthMinus1(9);                        // max. 2^10
924    hrd->setDpbOutputDelayLengthMinus1 (9);                        // max. 2^10
925  }
926
927  // Note: parameters for all temporal layers are initialized with the same values
928  Int i, j;
929  UInt bitrateValue, cpbSizeValue;
930  UInt duCpbSizeValue;
931  UInt duBitRateValue = 0;
932
933  for( i = 0; i < MAX_TLAYER; i ++ )
934  {
935    hrd->setFixedPicRateFlag( i, 1 );
936    hrd->setPicDurationInTcMinus1( i, 0 );
937    hrd->setLowDelayHrdFlag( i, 0 );
938    hrd->setCpbCntMinus1( i, 0 );
939
940    //! \todo check for possible PTL violations
941    // BitRate[ i ] = ( bit_rate_value_minus1[ i ] + 1 ) * 2^( 6 + bit_rate_scale )
942    bitrateValue = bitRate / (1 << (6 + hrd->getBitRateScale()) );      // bitRate is in bits, so it needs to be scaled down
943    // CpbSize[ i ] = ( cpb_size_value_minus1[ i ] + 1 ) * 2^( 4 + cpb_size_scale )
944    cpbSizeValue = bitRate / (1 << (4 + hrd->getCpbSizeScale()) );      // using bitRate results in 1 second CPB size
945
946    // DU CPB size could be smaller (i.e. bitrateValue / number of DUs), but we don't know
947    // in how many DUs the slice segment settings will result
948    duCpbSizeValue = bitrateValue;
949    duBitRateValue = cpbSizeValue;
950
951    for( j = 0; j < ( hrd->getCpbCntMinus1( i ) + 1 ); j ++ )
952    {
953      hrd->setBitRateValueMinus1( i, j, 0, ( bitrateValue - 1 ) );
954      hrd->setCpbSizeValueMinus1( i, j, 0, ( cpbSizeValue - 1 ) );
955      hrd->setDuCpbSizeValueMinus1( i, j, 0, ( duCpbSizeValue - 1 ) );
956      hrd->setDuBitRateValueMinus1( i, j, 0, ( duBitRateValue - 1 ) );
957      hrd->setCbrFlag( i, j, 0, false );
958
959      hrd->setBitRateValueMinus1( i, j, 1, ( bitrateValue - 1) );
960      hrd->setCpbSizeValueMinus1( i, j, 1, ( cpbSizeValue - 1 ) );
961      hrd->setDuCpbSizeValueMinus1( i, j, 1, ( duCpbSizeValue - 1 ) );
962      hrd->setDuBitRateValueMinus1( i, j, 1, ( duBitRateValue - 1 ) );
963      hrd->setCbrFlag( i, j, 1, false );
964    }
965  }
966}
967
968
969Void TEncTop::xInitPPS()
970{
971#if NH_MV
972  m_cPPS.setLayerId( getLayerId() );
973#if NH_3D
974  // Check if this condition is still correct
975  if( getVPS()->getNumRefListLayers( getLayerId() ) > 0 )
976#else
977  if( getVPS()->getNumDirectRefLayers( getLayerId() ) > 0 )
978#endif
979  {
980    m_cPPS.setListsModificationPresentFlag( true );
981  }
982  m_cPPS.setPPSId( getLayerIdInVps() );
983  m_cPPS.setSPSId( getLayerIdInVps() );
984  m_cPPS.setPpsMultilayerExtensionFlag    ( true ); 
985#if NH_3D
986  // Might be used for DLT
987  m_cPPS.setPps3dExtensionFlag            ( getIsDepth() ); 
988#endif
989#endif
990
991#if NH_3D_DLT
992  // create mapping from depth layer indexes to layer ids
993  Int j=0;
994  for( Int i=0; i<=getVPS()->getMaxLayersMinus1(); i++ )
995  {
996    Int layerId = getVPS()->getLayerIdInNuh(i);
997    if( getVPS()->getDepthId(layerId) )
998      m_cDLT.setDepthIdxToLayerId(j++, layerId);
999  }
1000  m_cPPS.setDLT( m_cDLT );
1001#endif
1002
1003  m_cPPS.setConstrainedIntraPred( m_bUseConstrainedIntraPred );
1004  Bool bUseDQP = (getMaxCuDQPDepth() > 0)? true : false;
1005
1006  if((getMaxDeltaQP() != 0 )|| getUseAdaptiveQP())
1007  {
1008    bUseDQP = true;
1009  }
1010
1011  if (m_costMode==COST_SEQUENCE_LEVEL_LOSSLESS || m_costMode==COST_LOSSLESS_CODING)
1012  {
1013    bUseDQP=false;
1014  }
1015
1016
1017  if ( m_RCEnableRateControl )
1018  {
1019    m_cPPS.setUseDQP(true);
1020    m_cPPS.setMaxCuDQPDepth( 0 );
1021  }
1022  else if(bUseDQP)
1023  {
1024    m_cPPS.setUseDQP(true);
1025    m_cPPS.setMaxCuDQPDepth( m_iMaxCuDQPDepth );
1026  }
1027  else
1028  {
1029    m_cPPS.setUseDQP(false);
1030    m_cPPS.setMaxCuDQPDepth( 0 );
1031  }
1032
1033  if ( m_diffCuChromaQpOffsetDepth >= 0 )
1034  {
1035    m_cPPS.getPpsRangeExtension().setDiffCuChromaQpOffsetDepth(m_diffCuChromaQpOffsetDepth);
1036    m_cPPS.getPpsRangeExtension().clearChromaQpOffsetList();
1037    m_cPPS.getPpsRangeExtension().setChromaQpOffsetListEntry(1, 6, 6);
1038    /* todo, insert table entries from command line (NB, 0 should not be touched) */
1039  }
1040  else
1041  {
1042    m_cPPS.getPpsRangeExtension().setDiffCuChromaQpOffsetDepth(0);
1043    m_cPPS.getPpsRangeExtension().clearChromaQpOffsetList();
1044  }
1045  m_cPPS.getPpsRangeExtension().setCrossComponentPredictionEnabledFlag(m_crossComponentPredictionEnabledFlag);
1046  m_cPPS.getPpsRangeExtension().setLog2SaoOffsetScale(CHANNEL_TYPE_LUMA,   m_log2SaoOffsetScale[CHANNEL_TYPE_LUMA  ]);
1047  m_cPPS.getPpsRangeExtension().setLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA, m_log2SaoOffsetScale[CHANNEL_TYPE_CHROMA]);
1048
1049  m_cPPS.setQpOffset(COMPONENT_Cb, m_chromaCbQpOffset );
1050  m_cPPS.setQpOffset(COMPONENT_Cr, m_chromaCrQpOffset );
1051
1052  m_cPPS.setEntropyCodingSyncEnabledFlag( m_iWaveFrontSynchro > 0 );
1053  m_cPPS.setTilesEnabledFlag( (m_iNumColumnsMinus1 > 0 || m_iNumRowsMinus1 > 0) );
1054  m_cPPS.setUseWP( m_useWeightedPred );
1055  m_cPPS.setWPBiPred( m_useWeightedBiPred );
1056  m_cPPS.setOutputFlagPresentFlag( false );
1057#if NH_MV
1058#if NH_MV_FIX_TICKET_100
1059  m_cPPS.setNumExtraSliceHeaderBits( 2 ); 
1060#else
1061  m_cPPS.setNumExtraSliceHeaderBits( 3 ); 
1062#endif
1063#endif
1064  m_cPPS.setSignHideFlag(getSignHideFlag());
1065  if ( getDeblockingFilterMetric() )
1066  {
1067    m_cPPS.setDeblockingFilterOverrideEnabledFlag(true);
1068    m_cPPS.setPicDisableDeblockingFilterFlag(false);
1069  }
1070  else
1071  {
1072      m_cPPS.setDeblockingFilterOverrideEnabledFlag( !getLoopFilterOffsetInPPS() );
1073      m_cPPS.setPicDisableDeblockingFilterFlag( getLoopFilterDisable() );
1074    }
1075
1076  if (! m_cPPS.getPicDisableDeblockingFilterFlag())
1077  {
1078    m_cPPS.setDeblockingFilterBetaOffsetDiv2( getLoopFilterBetaOffset() );
1079    m_cPPS.setDeblockingFilterTcOffsetDiv2( getLoopFilterTcOffset() );
1080  }
1081  else
1082  {
1083    m_cPPS.setDeblockingFilterBetaOffsetDiv2(0);
1084    m_cPPS.setDeblockingFilterTcOffsetDiv2(0);
1085  }
1086
1087  // deblockingFilterControlPresentFlag is true if any of the settings differ from the inferred values:
1088  const Bool deblockingFilterControlPresentFlag = m_cPPS.getDeblockingFilterOverrideEnabledFlag() ||
1089                                                  m_cPPS.getPicDisableDeblockingFilterFlag()      ||
1090                                                  m_cPPS.getDeblockingFilterBetaOffsetDiv2() != 0 ||
1091                                                  m_cPPS.getDeblockingFilterTcOffsetDiv2() != 0;
1092
1093  m_cPPS.setDeblockingFilterControlPresentFlag(deblockingFilterControlPresentFlag);
1094
1095  m_cPPS.setLog2ParallelMergeLevelMinus2   (m_log2ParallelMergeLevelMinus2 );
1096  m_cPPS.setCabacInitPresentFlag(CABAC_INIT_PRESENT_FLAG);
1097  m_cPPS.setLoopFilterAcrossSlicesEnabledFlag( m_bLFCrossSliceBoundaryFlag );
1098
1099
1100  Int histogram[MAX_NUM_REF + 1];
1101  for( Int i = 0; i <= MAX_NUM_REF; i++ )
1102  {
1103    histogram[i]=0;
1104  }
1105  for( Int i = 0; i < getGOPSize(); i++)
1106  {
1107    assert(getGOPEntry(i).m_numRefPicsActive >= 0 && getGOPEntry(i).m_numRefPicsActive <= MAX_NUM_REF);
1108    histogram[getGOPEntry(i).m_numRefPicsActive]++;
1109  }
1110
1111  Int maxHist=-1;
1112  Int bestPos=0;
1113  for( Int i = 0; i <= MAX_NUM_REF; i++ )
1114  {
1115    if(histogram[i]>maxHist)
1116    {
1117      maxHist=histogram[i];
1118      bestPos=i;
1119    }
1120  }
1121  assert(bestPos <= 15);
1122  m_cPPS.setNumRefIdxL0DefaultActive(bestPos);
1123  m_cPPS.setNumRefIdxL1DefaultActive(bestPos);
1124  m_cPPS.setTransquantBypassEnableFlag(getTransquantBypassEnableFlag());
1125  m_cPPS.setUseTransformSkip( m_useTransformSkip );
1126  m_cPPS.getPpsRangeExtension().setLog2MaxTransformSkipBlockSize( m_log2MaxTransformSkipBlockSize  );
1127
1128  if (m_sliceSegmentMode != NO_SLICES)
1129  {
1130    m_cPPS.setDependentSliceSegmentsEnabledFlag( true );
1131  }
1132}
1133
1134//Function for initializing m_RPSList, a list of TComReferencePictureSet, based on the GOPEntry objects read from the config file.
1135Void TEncTop::xInitRPS(Bool isFieldCoding)
1136{
1137  TComReferencePictureSet*      rps;
1138
1139  m_cSPS.createRPSList(getGOPSize() + m_extraRPSs + 1);
1140  TComRPSList* rpsList = m_cSPS.getRPSList();
1141
1142  for( Int i = 0; i < getGOPSize()+m_extraRPSs; i++)
1143  {
1144    GOPEntry ge = getGOPEntry(i);
1145    rps = rpsList->getReferencePictureSet(i);
1146    rps->setNumberOfPictures(ge.m_numRefPics);
1147    rps->setNumRefIdc(ge.m_numRefIdc);
1148    Int numNeg = 0;
1149    Int numPos = 0;
1150    for( Int j = 0; j < ge.m_numRefPics; j++)
1151    {
1152      rps->setDeltaPOC(j,ge.m_referencePics[j]);
1153      rps->setUsed(j,ge.m_usedByCurrPic[j]);
1154      if(ge.m_referencePics[j]>0)
1155      {
1156        numPos++;
1157      }
1158      else
1159      {
1160        numNeg++;
1161      }
1162    }
1163    rps->setNumberOfNegativePictures(numNeg);
1164    rps->setNumberOfPositivePictures(numPos);
1165
1166    // handle inter RPS intialization from the config file.
1167    rps->setInterRPSPrediction(ge.m_interRPSPrediction > 0);  // not very clean, converting anything > 0 to true.
1168    rps->setDeltaRIdxMinus1(0);                               // index to the Reference RPS is always the previous one.
1169    TComReferencePictureSet*     RPSRef = i>0 ? rpsList->getReferencePictureSet(i-1): NULL;  // get the reference RPS
1170
1171    if (ge.m_interRPSPrediction == 2)  // Automatic generation of the inter RPS idc based on the RIdx provided.
1172    {
1173      assert (RPSRef!=NULL);
1174      Int deltaRPS = getGOPEntry(i-1).m_POC - ge.m_POC;  // the ref POC - current POC
1175      Int numRefDeltaPOC = RPSRef->getNumberOfPictures();
1176
1177      rps->setDeltaRPS(deltaRPS);           // set delta RPS
1178      rps->setNumRefIdc(numRefDeltaPOC+1);  // set the numRefIdc to the number of pictures in the reference RPS + 1.
1179      Int count=0;
1180      for (Int j = 0; j <= numRefDeltaPOC; j++ ) // cycle through pics in reference RPS.
1181      {
1182        Int RefDeltaPOC = (j<numRefDeltaPOC)? RPSRef->getDeltaPOC(j): 0;  // if it is the last decoded picture, set RefDeltaPOC = 0
1183        rps->setRefIdc(j, 0);
1184        for (Int k = 0; k < rps->getNumberOfPictures(); k++ )  // cycle through pics in current RPS.
1185        {
1186          if (rps->getDeltaPOC(k) == ( RefDeltaPOC + deltaRPS))  // if the current RPS has a same picture as the reference RPS.
1187          {
1188              rps->setRefIdc(j, (rps->getUsed(k)?1:2));
1189              count++;
1190              break;
1191          }
1192        }
1193      }
1194      if (count != rps->getNumberOfPictures())
1195      {
1196        printf("Warning: Unable fully predict all delta POCs using the reference RPS index given in the config file.  Setting Inter RPS to false for this RPS.\n");
1197        rps->setInterRPSPrediction(0);
1198      }
1199    }
1200    else if (ge.m_interRPSPrediction == 1)  // inter RPS idc based on the RefIdc values provided in config file.
1201    {
1202      assert (RPSRef!=NULL);
1203      rps->setDeltaRPS(ge.m_deltaRPS);
1204      rps->setNumRefIdc(ge.m_numRefIdc);
1205      for (Int j = 0; j < ge.m_numRefIdc; j++ )
1206      {
1207        rps->setRefIdc(j, ge.m_refIdc[j]);
1208      }
1209      // the following code overwrite the deltaPOC and Used by current values read from the config file with the ones
1210      // computed from the RefIdc.  A warning is printed if they are not identical.
1211      numNeg = 0;
1212      numPos = 0;
1213      TComReferencePictureSet      RPSTemp;  // temporary variable
1214
1215      for (Int j = 0; j < ge.m_numRefIdc; j++ )
1216      {
1217        if (ge.m_refIdc[j])
1218        {
1219          Int deltaPOC = ge.m_deltaRPS + ((j < RPSRef->getNumberOfPictures())? RPSRef->getDeltaPOC(j) : 0);
1220          RPSTemp.setDeltaPOC((numNeg+numPos),deltaPOC);
1221          RPSTemp.setUsed((numNeg+numPos),ge.m_refIdc[j]==1?1:0);
1222          if (deltaPOC<0)
1223          {
1224            numNeg++;
1225          }
1226          else
1227          {
1228            numPos++;
1229          }
1230        }
1231      }
1232      if (numNeg != rps->getNumberOfNegativePictures())
1233      {
1234        printf("Warning: number of negative pictures in RPS is different between intra and inter RPS specified in the config file.\n");
1235        rps->setNumberOfNegativePictures(numNeg);
1236        rps->setNumberOfPictures(numNeg+numPos);
1237      }
1238      if (numPos != rps->getNumberOfPositivePictures())
1239      {
1240        printf("Warning: number of positive pictures in RPS is different between intra and inter RPS specified in the config file.\n");
1241        rps->setNumberOfPositivePictures(numPos);
1242        rps->setNumberOfPictures(numNeg+numPos);
1243      }
1244      RPSTemp.setNumberOfPictures(numNeg+numPos);
1245      RPSTemp.setNumberOfNegativePictures(numNeg);
1246      RPSTemp.sortDeltaPOC();     // sort the created delta POC before comparing
1247      // check if Delta POC and Used are the same
1248      // print warning if they are not.
1249      for (Int j = 0; j < ge.m_numRefIdc; j++ )
1250      {
1251        if (RPSTemp.getDeltaPOC(j) != rps->getDeltaPOC(j))
1252        {
1253          printf("Warning: delta POC is different between intra RPS and inter RPS specified in the config file.\n");
1254          rps->setDeltaPOC(j,RPSTemp.getDeltaPOC(j));
1255        }
1256        if (RPSTemp.getUsed(j) != rps->getUsed(j))
1257        {
1258          printf("Warning: Used by Current in RPS is different between intra and inter RPS specified in the config file.\n");
1259          rps->setUsed(j,RPSTemp.getUsed(j));
1260        }
1261      }
1262    }
1263  }
1264  //In case of field coding, we need to set special parameters for the first bottom field of the sequence, since it is not specified in the cfg file.
1265  //The position = GOPSize + extraRPSs which is (a priori) unused is reserved for this field in the RPS.
1266  if (isFieldCoding)
1267  {
1268    rps = rpsList->getReferencePictureSet(getGOPSize()+m_extraRPSs);
1269    rps->setNumberOfPictures(1);
1270    rps->setNumberOfNegativePictures(1);
1271    rps->setNumberOfPositivePictures(0);
1272    rps->setNumberOfLongtermPictures(0);
1273    rps->setDeltaPOC(0,-1);
1274    rps->setPOC(0,0);
1275    rps->setUsed(0,true);
1276    rps->setInterRPSPrediction(false);
1277    rps->setDeltaRIdxMinus1(0);
1278    rps->setDeltaRPS(0);
1279    rps->setNumRefIdc(0);
1280  }
1281}
1282
1283   // This is a function that
1284   // determines what Reference Picture Set to use
1285   // for a specific slice (with POC = POCCurr)
1286Void TEncTop::selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid )
1287{
1288#if NH_MV
1289  if( slice->getRapPicFlag() == true && getLayerId() > 0 && POCCurr == 0 )
1290  {
1291    TComReferencePictureSet* rps = slice->getLocalRPS();
1292    rps->setNumberOfNegativePictures(0);
1293    rps->setNumberOfPositivePictures(0);
1294    rps->setNumberOfLongtermPictures(0);
1295    rps->setNumberOfPictures(0);
1296    slice->setRPS(rps);
1297  }
1298  else
1299  {
1300#endif
1301  slice->setRPSidx(GOPid);
1302
1303  for(Int extraNum=m_iGOPSize; extraNum<m_extraRPSs+m_iGOPSize; extraNum++)
1304  {
1305    if(m_uiIntraPeriod > 0 && getDecodingRefreshType() > 0)
1306    {
1307      Int POCIndex = POCCurr%m_uiIntraPeriod;
1308      if(POCIndex == 0)
1309      {
1310        POCIndex = m_uiIntraPeriod;
1311      }
1312      if(POCIndex == m_GOPList[extraNum].m_POC)
1313      {
1314        slice->setRPSidx(extraNum);
1315      }
1316    }
1317    else
1318    {
1319      if(POCCurr==m_GOPList[extraNum].m_POC)
1320      {
1321        slice->setRPSidx(extraNum);
1322      }
1323    }
1324  }
1325
1326  if(POCCurr == 1 && slice->getPic()->isField())
1327  {
1328    slice->setRPSidx(m_iGOPSize+m_extraRPSs);
1329  }
1330
1331  const TComReferencePictureSet *rps = (slice->getSPS()->getRPSList()->getReferencePictureSet(slice->getRPSidx()));
1332  slice->setRPS(rps);
1333#if NH_MV
1334  }
1335#endif
1336
1337}
1338
1339Int TEncTop::getReferencePictureSetIdxForSOP(Int POCCurr, Int GOPid )
1340{
1341  Int rpsIdx = GOPid;
1342
1343  for(Int extraNum=m_iGOPSize; extraNum<m_extraRPSs+m_iGOPSize; extraNum++)
1344  {
1345    if(m_uiIntraPeriod > 0 && getDecodingRefreshType() > 0)
1346    {
1347      Int POCIndex = POCCurr%m_uiIntraPeriod;
1348      if(POCIndex == 0)
1349      {
1350        POCIndex = m_uiIntraPeriod;
1351      }
1352      if(POCIndex == m_GOPList[extraNum].m_POC)
1353      {
1354        rpsIdx = extraNum;
1355      }
1356    }
1357    else
1358    {
1359      if(POCCurr==m_GOPList[extraNum].m_POC)
1360      {
1361        rpsIdx = extraNum;
1362      }
1363    }
1364  }
1365
1366  return rpsIdx;
1367}
1368
1369Void  TEncTop::xInitPPSforTiles()
1370{
1371  m_cPPS.setTileUniformSpacingFlag( m_tileUniformSpacingFlag );
1372  m_cPPS.setNumTileColumnsMinus1( m_iNumColumnsMinus1 );
1373  m_cPPS.setNumTileRowsMinus1( m_iNumRowsMinus1 );
1374  if( !m_tileUniformSpacingFlag )
1375  {
1376    m_cPPS.setTileColumnWidth( m_tileColumnWidth );
1377    m_cPPS.setTileRowHeight( m_tileRowHeight );
1378  }
1379  m_cPPS.setLoopFilterAcrossTilesEnabledFlag( m_loopFilterAcrossTilesEnabledFlag );
1380
1381  // # substreams is "per tile" when tiles are independent.
1382}
1383
1384Void  TEncCfg::xCheckGSParameters()
1385{
1386  Int   iWidthInCU = ( m_iSourceWidth%m_maxCUWidth ) ? m_iSourceWidth/m_maxCUWidth + 1 : m_iSourceWidth/m_maxCUWidth;
1387  Int   iHeightInCU = ( m_iSourceHeight%m_maxCUHeight ) ? m_iSourceHeight/m_maxCUHeight + 1 : m_iSourceHeight/m_maxCUHeight;
1388  UInt  uiCummulativeColumnWidth = 0;
1389  UInt  uiCummulativeRowHeight = 0;
1390
1391  //check the column relative parameters
1392  if( m_iNumColumnsMinus1 >= (1<<(LOG2_MAX_NUM_COLUMNS_MINUS1+1)) )
1393  {
1394    printf( "The number of columns is larger than the maximum allowed number of columns.\n" );
1395    exit( EXIT_FAILURE );
1396  }
1397
1398  if( m_iNumColumnsMinus1 >= iWidthInCU )
1399  {
1400    printf( "The current picture can not have so many columns.\n" );
1401    exit( EXIT_FAILURE );
1402  }
1403
1404  if( m_iNumColumnsMinus1 && !m_tileUniformSpacingFlag )
1405  {
1406    for(Int i=0; i<m_iNumColumnsMinus1; i++)
1407    {
1408      uiCummulativeColumnWidth += m_tileColumnWidth[i];
1409    }
1410
1411    if( uiCummulativeColumnWidth >= iWidthInCU )
1412    {
1413      printf( "The width of the column is too large.\n" );
1414      exit( EXIT_FAILURE );
1415    }
1416  }
1417
1418  //check the row relative parameters
1419  if( m_iNumRowsMinus1 >= (1<<(LOG2_MAX_NUM_ROWS_MINUS1+1)) )
1420  {
1421    printf( "The number of rows is larger than the maximum allowed number of rows.\n" );
1422    exit( EXIT_FAILURE );
1423  }
1424
1425  if( m_iNumRowsMinus1 >= iHeightInCU )
1426  {
1427    printf( "The current picture can not have so many rows.\n" );
1428    exit( EXIT_FAILURE );
1429  }
1430
1431  if( m_iNumRowsMinus1 && !m_tileUniformSpacingFlag )
1432  {
1433    for(Int i=0; i<m_iNumRowsMinus1; i++)
1434    {
1435      uiCummulativeRowHeight += m_tileRowHeight[i];
1436    }
1437
1438    if( uiCummulativeRowHeight >= iHeightInCU )
1439    {
1440      printf( "The height of the row is too large.\n" );
1441      exit( EXIT_FAILURE );
1442    }
1443  }
1444}
1445
1446#if NH_MV
1447Int TEncTop::getFrameId(Int iGOPid) 
1448{
1449  if(m_iPOCLast == 0)
1450  {
1451    return(0 );
1452  }
1453  else
1454  {
1455    return m_iPOCLast -m_iNumPicRcvd+ getGOPEntry(iGOPid).m_POC ;
1456  }
1457}
1458
1459TComPic* TEncTop::getPic( Int poc )
1460{
1461  TComList<TComPic*>* listPic = getListPic();
1462  TComPic* pcPic = NULL;
1463  for(TComList<TComPic*>::iterator it=listPic->begin(); it!=listPic->end(); it++)
1464  {
1465    if( (*it)->getPOC() == poc )
1466    {
1467      pcPic = *it ;
1468      break ;
1469    }
1470  }
1471  return pcPic;
1472}
1473
1474#endif
1475
1476#if NH_3D_VSO
1477Void TEncTop::setupRenModel( Int iPoc, Int iEncViewIdx, Int iEncContent, Int iHorOffset, Int maxCuHeight )
1478{
1479  TRenModel* rendererModel = m_cRdCost.getRenModel(); 
1480  rendererModel->setupPart( iHorOffset, std::min( maxCuHeight, (Int) ( m_iSourceHeight - iHorOffset ) )) ; 
1481 
1482  Int iEncViewSIdx = m_cameraParameters->getBaseId2SortedId()[ iEncViewIdx ];
1483
1484  // setup base views
1485  Int iNumOfBV = m_renderModelParameters->getNumOfBaseViewsForView( iEncViewSIdx, iEncContent );
1486
1487  for (Int iCurView = 0; iCurView < iNumOfBV; iCurView++ )
1488  {
1489    Int iBaseViewSIdx;
1490    Int iVideoDistMode;
1491    Int iDepthDistMode;
1492
1493    m_renderModelParameters->getBaseViewData( iEncViewSIdx, iEncContent, iCurView, iBaseViewSIdx, iVideoDistMode, iDepthDistMode );
1494
1495    AOT( iVideoDistMode < 0 || iVideoDistMode > 2 );
1496
1497    Int iBaseViewIdx = m_cameraParameters->getBaseSortedId2Id()[ iBaseViewSIdx ];
1498
1499    TComPicYuv* pcPicYuvVideoRec  = m_ivPicLists->getPicYuv( iBaseViewIdx, false, iPoc, true  );
1500    TComPicYuv* pcPicYuvDepthRec  = m_ivPicLists->getPicYuv( iBaseViewIdx, true , iPoc, true  );
1501    TComPicYuv* pcPicYuvVideoOrg  = m_ivPicLists->getPicYuv( iBaseViewIdx, false, iPoc, false );
1502    TComPicYuv* pcPicYuvDepthOrg  = m_ivPicLists->getPicYuv( iBaseViewIdx, true , iPoc, false );   
1503
1504    TComPicYuv* pcPicYuvVideoRef  = ( iVideoDistMode == 2 ) ? pcPicYuvVideoOrg  : NULL;
1505    TComPicYuv* pcPicYuvDepthRef  = ( iDepthDistMode == 2 ) ? pcPicYuvDepthOrg  : NULL;
1506
1507    TComPicYuv* pcPicYuvVideoTest = ( iVideoDistMode == 0 ) ? pcPicYuvVideoOrg  : pcPicYuvVideoRec;
1508    TComPicYuv* pcPicYuvDepthTest = ( iDepthDistMode == 0 ) ? pcPicYuvDepthOrg  : pcPicYuvDepthRec;
1509
1510    AOT( (iVideoDistMode == 2) != (pcPicYuvVideoRef != NULL) );
1511    AOT( (iDepthDistMode == 2) != (pcPicYuvDepthRef != NULL) );
1512    AOT( pcPicYuvDepthTest == NULL );
1513    AOT( pcPicYuvVideoTest == NULL );
1514
1515    rendererModel->setBaseView( iBaseViewSIdx, pcPicYuvVideoTest, pcPicYuvDepthTest, pcPicYuvVideoRef, pcPicYuvDepthRef );
1516  }
1517
1518  rendererModel->setErrorMode( iEncViewSIdx, iEncContent, 0 );
1519  // setup virtual views
1520  Int iNumOfSV  = m_renderModelParameters->getNumOfModelsForView( iEncViewSIdx, iEncContent );
1521  for (Int iCurView = 0; iCurView < iNumOfSV; iCurView++ )
1522  {
1523    Int iOrgRefBaseViewSIdx;
1524    Int iLeftBaseViewSIdx;
1525    Int iRightBaseViewSIdx;
1526    Int iSynthViewRelNum;
1527    Int iModelNum;
1528    Int iBlendMode;
1529    m_renderModelParameters->getSingleModelData(iEncViewSIdx, iEncContent, iCurView, iModelNum, iBlendMode,iLeftBaseViewSIdx, iRightBaseViewSIdx, iOrgRefBaseViewSIdx, iSynthViewRelNum );
1530
1531    Int iLeftBaseViewIdx    = -1;
1532    Int iRightBaseViewIdx   = -1;
1533
1534    TComPicYuv* pcPicYuvOrgRef  = NULL;
1535    Int**      ppiShiftLUTLeft  = NULL;
1536    Int**      ppiShiftLUTRight = NULL;
1537    Int**      ppiBaseShiftLUTLeft  = NULL;
1538    Int**      ppiBaseShiftLUTRight = NULL;
1539
1540
1541    Int        iDistToLeft      = -1;
1542
1543    Int iSynthViewIdx = m_cameraParameters->synthRelNum2Idx( iSynthViewRelNum );
1544
1545    if ( iLeftBaseViewSIdx != -1 )
1546    {
1547      iLeftBaseViewIdx   = m_cameraParameters->getBaseSortedId2Id()   [ iLeftBaseViewSIdx ];
1548      ppiShiftLUTLeft    = m_cameraParameters->getSynthViewShiftLUTI()[ iLeftBaseViewIdx  ][ iSynthViewIdx  ];
1549    }
1550
1551    if ( iRightBaseViewSIdx != -1 )
1552    {
1553      iRightBaseViewIdx  = m_cameraParameters->getBaseSortedId2Id()   [iRightBaseViewSIdx ];
1554      ppiShiftLUTRight   = m_cameraParameters->getSynthViewShiftLUTI()[ iRightBaseViewIdx ][ iSynthViewIdx ];
1555    }
1556
1557    if ( iRightBaseViewSIdx != -1 && iLeftBaseViewSIdx != -1 )
1558    {
1559      iDistToLeft          = m_cameraParameters->getRelDistLeft(  iSynthViewIdx , iLeftBaseViewIdx, iRightBaseViewIdx);
1560      ppiBaseShiftLUTLeft  = m_cameraParameters->getBaseViewShiftLUTI() [ iLeftBaseViewIdx  ][ iRightBaseViewIdx ];
1561      ppiBaseShiftLUTRight = m_cameraParameters->getBaseViewShiftLUTI() [ iRightBaseViewIdx ][ iLeftBaseViewIdx  ];
1562
1563    }
1564
1565    if ( iOrgRefBaseViewSIdx != -1 )
1566    {
1567      pcPicYuvOrgRef = m_ivPicLists->getPicYuv(  m_cameraParameters->getBaseSortedId2Id()[ iOrgRefBaseViewSIdx ] , false, iPoc, false );
1568      AOF ( pcPicYuvOrgRef );
1569    }
1570
1571    rendererModel->setSingleModel( iModelNum, ppiShiftLUTLeft, ppiBaseShiftLUTLeft, ppiShiftLUTRight, ppiBaseShiftLUTRight, iDistToLeft, pcPicYuvOrgRef );
1572  }
1573}
1574#endif
1575
1576//! \}
Note: See TracBrowser for help on using the repository browser.