source: 3DVCSoftware/branches/HTM-9.1-dev0-MediaTek/source/Lib/TLibEncoder/TEncTop.cpp @ 1258

Last change on this file since 1258 was 755, checked in by chang, 12 years ago

Integrate

  • JCT3V-F0136/F0045: view order index based camera parameter signaling
  • JCT3V-F0082: the cp_in_slice_segment_layer_flag to be view specific and used as a condition of the presence of slice header level camera parameters
  • JCT3V-F0044: move camera parameter from slice header extension to slice header
  • Property svn:eol-style set to native
File size: 49.2 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 *
[608]6 * Copyright (c) 2010-2013, 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"
41#if FAST_BIT_EST
42#include "TLibCommon/ContextModel.h"
43#endif
[608]44#if H_MV
45#include "../../App/TAppEncoder/TAppEncTop.h"
46#endif
[2]47
[56]48//! \ingroup TLibEncoder
49//! \{
50
[2]51// ====================================================================================================================
52// Constructor / destructor / create / destroy
53// ====================================================================================================================
54
55TEncTop::TEncTop()
56{
57  m_iPOCLast          = -1;
58  m_iNumPicRcvd       =  0;
59  m_uiNumAllPicCoded  =  0;
60  m_pppcRDSbacCoder   =  NULL;
61  m_pppcBinCoderCABAC =  NULL;
62  m_cRDGoOnSbacCoder.init( &m_cRDGoOnBinCoderCABAC );
63#if ENC_DEC_TRACE
64  g_hTrace = fopen( "TraceEnc.txt", "wb" );
65  g_bJustDoIt = g_bEncDecTraceDisable;
66  g_nSymbolCounter = 0;
67#endif
[56]68
69  m_iMaxRefPicNum     = 0;
70
71#if FAST_BIT_EST
72  ContextModel::buildNextStateTable();
73#endif
74
75  m_pcSbacCoders           = NULL;
76  m_pcBinCoderCABACs       = NULL;
77  m_ppppcRDSbacCoders      = NULL;
78  m_ppppcBinCodersCABAC    = NULL;
79  m_pcRDGoOnSbacCoders     = NULL;
80  m_pcRDGoOnBinCodersCABAC = NULL;
81  m_pcBitCounters          = NULL;
82  m_pcRdCosts              = NULL;
[608]83#if H_MV
84  m_ivPicLists = NULL;
85#endif
[2]86}
87
88TEncTop::~TEncTop()
89{
90#if ENC_DEC_TRACE
91  fclose( g_hTrace );
92#endif
93}
94
95Void TEncTop::create ()
96{
[608]97#if !H_MV
[2]98  // initialize global variables
[608]99  initROM();
100#endif
101 
[2]102  // create processing unit classes
[608]103  m_cGOPEncoder.        create();
[2]104  m_cSliceEncoder.      create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
105  m_cCuEncoder.         create( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight );
106  if (m_bUseSAO)
107  {
[443]108    m_cEncSAO.setSaoLcuBoundary(getSaoLcuBoundary());
109    m_cEncSAO.setSaoLcuBasedOptimization(getSaoLcuBasedOptimization());
[56]110    m_cEncSAO.setMaxNumOffsetsPerPic(getMaxNumOffsetsPerPic());
[608]111    m_cEncSAO.create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight );
[2]112    m_cEncSAO.createEncBuffer();
113  }
[56]114#if ADAPTIVE_QP_SELECTION
115  if (m_bUseAdaptQpSelect)
116  {
117    m_cTrQuant.initSliceQpDelta();
118  }
[2]119#endif
120  m_cLoopFilter.        create( g_uiMaxCUDepth );
121
[608]122#if RATE_CONTROL_LAMBDA_DOMAIN
123  if ( m_RCEnableRateControl )
[2]124  {
[655]125#if KWU_RC_MADPRED_E0227
[608]126    m_cRateCtrl.init( m_framesToBeEncoded, m_RCTargetBitrate, m_iFrameRate, m_iGOPSize, m_iSourceWidth, m_iSourceHeight,
[655]127      g_uiMaxCUWidth, g_uiMaxCUHeight, m_RCKeepHierarchicalBit, m_RCUseLCUSeparateModel, m_GOPList, getLayerId() );
128#else
129    m_cRateCtrl.init( m_framesToBeEncoded, m_RCTargetBitrate, m_iFrameRate, m_iGOPSize, m_iSourceWidth, m_iSourceHeight,
[608]130                      g_uiMaxCUWidth, g_uiMaxCUHeight, m_RCKeepHierarchicalBit, m_RCUseLCUSeparateModel, m_GOPList );
[655]131#endif
[2]132  }
[608]133#else
[655]134#if KWU_FIX_URQ
135  if(m_enableRateCtrl)
[608]136#endif
[655]137    m_cRateCtrl.create(getIntraPeriod(), getGOPSize(), getFrameRate(), getTargetBitrate(), getQP(), getNumLCUInUnit(), getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight);
138#endif
[2]139  // if SBAC-based RD optimization is used
140  if( m_bUseSBACRD )
141  {
[56]142    m_pppcRDSbacCoder = new TEncSbac** [g_uiMaxCUDepth+1];
143#if FAST_BIT_EST
144    m_pppcBinCoderCABAC = new TEncBinCABACCounter** [g_uiMaxCUDepth+1];
145#else
146    m_pppcBinCoderCABAC = new TEncBinCABAC** [g_uiMaxCUDepth+1];
147#endif
148   
149    for ( Int iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ )
[2]150    {
151      m_pppcRDSbacCoder[iDepth] = new TEncSbac* [CI_NUM];
[56]152#if FAST_BIT_EST
153      m_pppcBinCoderCABAC[iDepth] = new TEncBinCABACCounter* [CI_NUM];
154#else
[2]155      m_pppcBinCoderCABAC[iDepth] = new TEncBinCABAC* [CI_NUM];
[56]156#endif
157     
[2]158      for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ )
159      {
160        m_pppcRDSbacCoder[iDepth][iCIIdx] = new TEncSbac;
[56]161#if FAST_BIT_EST
162        m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABACCounter;
163#else
[2]164        m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABAC;
[56]165#endif
[2]166        m_pppcRDSbacCoder   [iDepth][iCIIdx]->init( m_pppcBinCoderCABAC [iDepth][iCIIdx] );
167      }
168    }
169  }
170}
171
[56]172/**
173 - Allocate coders required for wavefront for the nominated number of substreams.
174 .
175 \param iNumSubstreams Determines how much information to allocate.
176 */
177Void TEncTop::createWPPCoders(Int iNumSubstreams)
178{
179  if (m_pcSbacCoders != NULL)
[608]180  {
[56]181    return; // already generated.
[608]182  }
[56]183
184  m_iNumSubstreams         = iNumSubstreams;
185  m_pcSbacCoders           = new TEncSbac       [iNumSubstreams];
186  m_pcBinCoderCABACs       = new TEncBinCABAC   [iNumSubstreams];
187  m_pcRDGoOnSbacCoders     = new TEncSbac       [iNumSubstreams];
188  m_pcRDGoOnBinCodersCABAC = new TEncBinCABAC   [iNumSubstreams];
189  m_pcBitCounters          = new TComBitCounter [iNumSubstreams];
190  m_pcRdCosts              = new TComRdCost     [iNumSubstreams];
191
192  for ( UInt ui = 0 ; ui < iNumSubstreams; ui++ )
193  {
194    m_pcRDGoOnSbacCoders[ui].init( &m_pcRDGoOnBinCodersCABAC[ui] );
195    m_pcSbacCoders[ui].init( &m_pcBinCoderCABACs[ui] );
196  }
197  if( m_bUseSBACRD )
198  {
199    m_ppppcRDSbacCoders      = new TEncSbac***    [iNumSubstreams];
200    m_ppppcBinCodersCABAC    = new TEncBinCABAC***[iNumSubstreams];
201    for ( UInt ui = 0 ; ui < iNumSubstreams ; ui++ )
202    {
203      m_ppppcRDSbacCoders[ui]  = new TEncSbac** [g_uiMaxCUDepth+1];
204      m_ppppcBinCodersCABAC[ui]= new TEncBinCABAC** [g_uiMaxCUDepth+1];
205     
206      for ( Int iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ )
207      {
208        m_ppppcRDSbacCoders[ui][iDepth]  = new TEncSbac*     [CI_NUM];
209        m_ppppcBinCodersCABAC[ui][iDepth]= new TEncBinCABAC* [CI_NUM];
210
211        for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ )
212        {
213          m_ppppcRDSbacCoders  [ui][iDepth][iCIIdx] = new TEncSbac;
214          m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx] = new TEncBinCABAC;
215          m_ppppcRDSbacCoders  [ui][iDepth][iCIIdx]->init( m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx] );
216        }
217      }
218    }
219  }
220}
221
[2]222Void TEncTop::destroy ()
223{
224  // destroy processing unit classes
[56]225  m_cGOPEncoder.        destroy();
[2]226  m_cSliceEncoder.      destroy();
227  m_cCuEncoder.         destroy();
228  if (m_cSPS.getUseSAO())
229  {
230    m_cEncSAO.destroy();
[56]231    m_cEncSAO.destroyEncBuffer();
[2]232  }
233  m_cLoopFilter.        destroy();
[608]234  m_cRateCtrl.          destroy();
[2]235  // SBAC RD
236  if( m_bUseSBACRD )
237  {
238    Int iDepth;
239    for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ )
240    {
241      for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ )
242      {
243        delete m_pppcRDSbacCoder[iDepth][iCIIdx];
244        delete m_pppcBinCoderCABAC[iDepth][iCIIdx];
245      }
246    }
[56]247   
[2]248    for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ )
249    {
250      delete [] m_pppcRDSbacCoder[iDepth];
251      delete [] m_pppcBinCoderCABAC[iDepth];
252    }
[56]253   
[2]254    delete [] m_pppcRDSbacCoder;
255    delete [] m_pppcBinCoderCABAC;
[56]256
257    for ( UInt ui = 0; ui < m_iNumSubstreams; ui++ )
258    {
259      for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ )
260      {
261        for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ )
262        {
263          delete m_ppppcRDSbacCoders  [ui][iDepth][iCIIdx];
264          delete m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx];
265        }
266      }
267
268      for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ )
269      {
270        delete [] m_ppppcRDSbacCoders  [ui][iDepth];
271        delete [] m_ppppcBinCodersCABAC[ui][iDepth];
272      }
273      delete[] m_ppppcRDSbacCoders  [ui];
274      delete[] m_ppppcBinCodersCABAC[ui];
275    }
276    delete[] m_ppppcRDSbacCoders;
277    delete[] m_ppppcBinCodersCABAC;
[2]278  }
[56]279  delete[] m_pcSbacCoders;
280  delete[] m_pcBinCoderCABACs;
281  delete[] m_pcRDGoOnSbacCoders; 
282  delete[] m_pcRDGoOnBinCodersCABAC;
283  delete[] m_pcBitCounters;
284  delete[] m_pcRdCosts;
285 
[608]286#if !H_MV
287    // destroy ROM
[56]288  destroyROM();
[608]289#endif
290
[2]291  return;
292}
293
[655]294#if KWU_RC_MADPRED_E0227
295Void TEncTop::init(TAppEncTop* pcTAppEncTop, Bool isFieldCoding)
296#else
297Void TEncTop::init(Bool isFieldCoding)
298#endif
[2]299{
300  // initialize SPS
[748]301#if DLT_DIFF_CODING_IN_PPS
302  // Assuming that all PPS indirectly refer to the same VPS via different SPS
303  m_cSPS.setVPS(m_cVPS);
304#endif
[2]305  xInitSPS();
[56]306 
[608]307  /* set the VPS profile information */
308#if H_MV
309  // This seems to be incorrect, but irrelevant for the MV-HEVC
310  *(m_cVPS->getPTL()) = *m_cSPS.getPTL();
311  m_cVPS->getTimingInfo()->setTimingInfoPresentFlag       ( false );
312#else
313  *m_cVPS.getPTL() = *m_cSPS.getPTL();
314  m_cVPS.getTimingInfo()->setTimingInfoPresentFlag       ( false );
315#endif
[2]316  // initialize PPS
[56]317  m_cPPS.setSPS(&m_cSPS);
[2]318  xInitPPS();
[655]319  xInitRPS(isFieldCoding);
[2]320
[56]321  xInitPPSforTiles();
322
[2]323  // initialize processing unit classes
[56]324  m_cGOPEncoder.  init( this );
[2]325  m_cSliceEncoder.init( this );
326  m_cCuEncoder.   init( this );
[56]327 
[655]328#if KWU_RC_MADPRED_E0227
329  m_pcTAppEncTop = pcTAppEncTop;
330#endif
[2]331  // initialize transform & quantization class
332  m_pcCavlcCoder = getCavlcCoder();
[56]333 
[608]334  m_cTrQuant.init( 1 << m_uiQuadtreeTULog2MaxSize,
335                  m_useRDOQ, 
336                  m_useRDOQTS,
337                  true 
338                  ,m_useTransformSkipFast
[56]339#if ADAPTIVE_QP_SELECTION                 
340                  , m_bUseAdaptQpSelect
[2]341#endif
[56]342                  );
343 
[2]344  // initialize encoder search class
345  m_cSearch.init( this, &m_cTrQuant, m_iSearchRange, m_bipredSearchRange, m_iFastSearch, 0, &m_cEntropyCoder, &m_cRdCost, getRDSbacCoder(), getRDGoOnSbacCoder() );
[56]346
347  m_iMaxRefPicNum = 0;
[2]348}
349
350// ====================================================================================================================
351// Public member functions
352// ====================================================================================================================
353
[608]354#if H_MV
355Void TEncTop::initNewPic( TComPicYuv* pcPicYuvOrg )
[56]356{
357  TComPic* pcPicCurr = NULL;
358
359  // get original YUV
360  xGetNewPicBuffer( pcPicCurr );
361  pcPicYuvOrg->copyToPic( pcPicCurr->getPicYuvOrg() );
362
363  // compute image characteristics
364  if ( getUseAdaptiveQP() )
365  {
366    m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcPicCurr ) );
367  }
[608]368#if H_MV
369  pcPicCurr->setLayerId( getLayerId()); 
370#endif
371#if H_3D
372  pcPicCurr->setScaleOffset( m_aaiCodedScale, m_aaiCodedOffset );
373#endif
[56]374}
[608]375#endif
[2]376Void TEncTop::deletePicBuffer()
377{
378  TComList<TComPic*>::iterator iterPic = m_cListPic.begin();
379  Int iSize = Int( m_cListPic.size() );
[56]380 
[2]381  for ( Int i = 0; i < iSize; i++ )
382  {
383    TComPic* pcPic = *(iterPic++);
[56]384   
[2]385    pcPic->destroy();
386    delete pcPic;
387    pcPic = NULL;
388  }
389}
390
391/**
392 - Application has picture buffer list with size of GOP + 1
393 - Picture buffer list acts like as ring buffer
394 - End of the list has the latest picture
395 .
[608]396 \param   flush               cause encoder to encode a partial GOP
[2]397 \param   pcPicYuvOrg         original YUV picture
398 \retval  rcListPicYuvRecOut  list of reconstruction YUV pictures
399 \retval  rcListBitstreamOut  list of output bitstreams
400 \retval  iNumEncoded         number of encoded pictures
401 */
[608]402#if H_MV
403Void TEncTop::encode(Bool flush, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded , Int gopId )
404{
405#else
406Void TEncTop::encode(Bool flush, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded )
407{
408#endif
409#if H_3D
410  TComPic* picLastCoded = getPic( getGOPEncoder()->getPocLastCoded() );
411  if( picLastCoded )
412  {
413    picLastCoded->compressMotion(1); 
414  }
415#endif
416#if H_MV
[56]417  if( gopId == 0)
[2]418  {
[56]419    m_cGOPEncoder.initGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut); 
[608]420#else
421  if (pcPicYuvOrg) {
422    // get original YUV
423    TComPic* pcPicCurr = NULL;
424    xGetNewPicBuffer( pcPicCurr );
425    pcPicYuvOrg->copyToPic( pcPicCurr->getPicYuvOrg() );
426
427    // compute image characteristics
428    if ( getUseAdaptiveQP() )
429    {
430      m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcPicCurr ) );
431    }
[2]432  }
[608]433 
434  if (!m_iNumPicRcvd || (!flush && m_iPOCLast != 0 && m_iNumPicRcvd != m_iGOPSize && m_iGOPSize))
[2]435  {
[608]436    iNumEncoded = 0;
437    return;
[2]438  }
[608]439#endif
[56]440 
[608]441#if RATE_CONTROL_LAMBDA_DOMAIN
442  if ( m_RCEnableRateControl )
[2]443  {
[608]444    m_cRateCtrl.initRCGOP( m_iNumPicRcvd );
[2]445  }
[608]446#endif
[2]447
[608]448#if H_MV
449  }
[655]450  m_cGOPEncoder.compressPicInGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, gopId, false, false );
[2]451
[608]452  if( gopId + 1 == m_cGOPEncoder.getGOPSize() )
[2]453  {
[608]454#else
455  // compress GOP
[655]456  m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, false, false);
[5]457#endif
[2]458
[608]459#if RATE_CONTROL_LAMBDA_DOMAIN
460  if ( m_RCEnableRateControl )
[2]461  {
[608]462    m_cRateCtrl.destroyRCGOP();
[2]463  }
[608]464#endif
465 
466  iNumEncoded         = m_iNumPicRcvd;
467  m_iNumPicRcvd       = 0;
468  m_uiNumAllPicCoded += iNumEncoded;
469#if H_MV
[2]470}
[608]471#endif
472}
[655]473/**------------------------------------------------
474 Separate interlaced frame into two fields
475 -------------------------------------------------**/
476void separateFields(Pel* org, Pel* dstField, UInt stride, UInt width, UInt height, bool isTop)
477{
478  if (!isTop)
479  {
480    org += stride;
481  }
482  for (Int y = 0; y < height>>1; y++)
483  {
484    for (Int x = 0; x < width; x++)
485    {
486      dstField[x] = org[x];
487    }
488   
489    dstField += stride;
490    org += stride*2;
491  }
492 
493}
[2]494
[655]495#if H_MV
496Void TEncTop::encode(Bool flush, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, bool isTff, Int gopId )
497{
498  assert( 0 ); // Field coding and multiview need to be furhter harmonized.
499}
500#else
501Void TEncTop::encode(Bool flush, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, bool isTff)
502{
503  /* -- TOP FIELD -- */
504 
505  if (pcPicYuvOrg)
506  {
507   
508    /* -- Top field initialization -- */
509   
510    TComPic *pcTopField;
511    xGetNewPicBuffer( pcTopField );
512    pcTopField->getPicSym()->allocSaoParam(&m_cEncSAO);
513    pcTopField->setReconMark (false);
514   
515    pcTopField->getSlice(0)->setPOC( m_iPOCLast );
516    pcTopField->getPicYuvRec()->setBorderExtension(false);
517    pcTopField->setTopField(isTff);
518   
519    int nHeight = pcPicYuvOrg->getHeight();
520    int nWidth = pcPicYuvOrg->getWidth();
521    int nStride = pcPicYuvOrg->getStride();
522    int nPadLuma = pcPicYuvOrg->getLumaMargin();
523    int nPadChroma = pcPicYuvOrg->getChromaMargin();
524   
525    // Get pointers
526    Pel * PicBufY = pcPicYuvOrg->getBufY();
527    Pel * PicBufU = pcPicYuvOrg->getBufU();
528    Pel * PicBufV = pcPicYuvOrg->getBufV();
529   
530    Pel * pcTopFieldY =  pcTopField->getPicYuvOrg()->getLumaAddr();
531    Pel * pcTopFieldU =  pcTopField->getPicYuvOrg()->getCbAddr();
532    Pel * pcTopFieldV =  pcTopField->getPicYuvOrg()->getCrAddr();
533   
534    // compute image characteristics
535    if ( getUseAdaptiveQP() )
536    {
537      m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcTopField ) );
538    }
539   
540    /* -- Defield -- */
541   
542    bool isTop = isTff;
543   
544    separateFields(PicBufY + nPadLuma + nStride*nPadLuma, pcTopFieldY, nStride, nWidth, nHeight, isTop);
545    separateFields(PicBufU + nPadChroma + (nStride >> 1)*nPadChroma, pcTopFieldU, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop);
546    separateFields(PicBufV + nPadChroma + (nStride >> 1)*nPadChroma, pcTopFieldV, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop);
547   
548  }
549 
550  if (m_iPOCLast == 0) // compress field 0
551  {
552    m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff);
553  }
554 
555  /* -- BOTTOM FIELD -- */
556 
557  if (pcPicYuvOrg)
558  {
559   
560    /* -- Bottom field initialization -- */
561   
562    TComPic* pcBottomField;
563    xGetNewPicBuffer( pcBottomField );
564    pcBottomField->getPicSym()->allocSaoParam(&m_cEncSAO);
565    pcBottomField->setReconMark (false);
566   
567    TComPicYuv* rpcPicYuvRec = new TComPicYuv;
568    if ( rcListPicYuvRecOut.size() == (UInt)m_iGOPSize )
569    {
570      rpcPicYuvRec = rcListPicYuvRecOut.popFront();
571    }
572    else
573    {
574      rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
575    }
576    rcListPicYuvRecOut.pushBack( rpcPicYuvRec );
577   
578    pcBottomField->getSlice(0)->setPOC( m_iPOCLast);
579    pcBottomField->getPicYuvRec()->setBorderExtension(false);
580    pcBottomField->setTopField(!isTff);
581   
582    int nHeight = pcPicYuvOrg->getHeight();
583    int nWidth = pcPicYuvOrg->getWidth();
584    int nStride = pcPicYuvOrg->getStride();
585    int nPadLuma = pcPicYuvOrg->getLumaMargin();
586    int nPadChroma = pcPicYuvOrg->getChromaMargin();
587   
588    // Get pointers
589    Pel * PicBufY = pcPicYuvOrg->getBufY();
590    Pel * PicBufU = pcPicYuvOrg->getBufU();
591    Pel * PicBufV = pcPicYuvOrg->getBufV();
592   
593    Pel * pcBottomFieldY =  pcBottomField->getPicYuvOrg()->getLumaAddr();
594    Pel * pcBottomFieldU =  pcBottomField->getPicYuvOrg()->getCbAddr();
595    Pel * pcBottomFieldV =  pcBottomField->getPicYuvOrg()->getCrAddr();
596   
597    // Compute image characteristics
598    if ( getUseAdaptiveQP() )
599    {
600      m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcBottomField ) );
601    }
602   
603    /* -- Defield -- */
604   
605    bool isTop = !isTff;
606   
607    separateFields(PicBufY + nPadLuma + nStride*nPadLuma, pcBottomFieldY, nStride, nWidth, nHeight, isTop);
608    separateFields(PicBufU + nPadChroma + (nStride >> 1)*nPadChroma, pcBottomFieldU, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop);
609    separateFields(PicBufV + nPadChroma + (nStride >> 1)*nPadChroma, pcBottomFieldV, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop);
610   
611  }
612 
613  if ( ( !(m_iNumPicRcvd) || (!flush && m_iPOCLast != 1 && m_iNumPicRcvd != m_iGOPSize && m_iGOPSize)) )
614  {
615    iNumEncoded = 0;
616    return;
617  }
618 
619  // compress GOP
620  m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff);
621 
622  iNumEncoded = m_iNumPicRcvd;
623  m_iNumPicRcvd = 0;
624  m_uiNumAllPicCoded += iNumEncoded;
625}
626#endif
627
628
629
[2]630// ====================================================================================================================
631// Protected member functions
632// ====================================================================================================================
633
634/**
635 - Application has picture buffer list with size of GOP + 1
636 - Picture buffer list acts like as ring buffer
637 - End of the list has the latest picture
638 .
639 \retval rpcPic obtained picture buffer
640 */
641Void TEncTop::xGetNewPicBuffer ( TComPic*& rpcPic )
642{
643  TComSlice::sortPicList(m_cListPic);
[56]644 
645  if (m_cListPic.size() >= (UInt)(m_iGOPSize + getMaxDecPicBuffering(MAX_TLAYER-1) + 2) )
[2]646  {
[56]647    TComList<TComPic*>::iterator iterPic  = m_cListPic.begin();
648    Int iSize = Int( m_cListPic.size() );
649    for ( Int i = 0; i < iSize; i++ )
650    {
[608]651      rpcPic = *(iterPic++);
[56]652      if(rpcPic->getSlice(0)->isReferenced() == false)
[608]653      {
654        break;
655      }
[56]656    }
[2]657  }
658  else
659  {
[608]660    if ( getUseAdaptiveQP() )
661    {
662      TEncPic* pcEPic = new TEncPic;
663      pcEPic->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, m_cPPS.getMaxCuDQPDepth()+1 ,
664                      m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics);
665      rpcPic = pcEPic;
666    }
667    else
668    {
669      rpcPic = new TComPic;
670
671      rpcPic->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, 
672                      m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics);
673    }
674    if (getUseSAO())
675    {
676      rpcPic->getPicSym()->allocSaoParam(&m_cEncSAO);
677    }
[56]678    m_cListPic.pushBack( rpcPic );
[2]679  }
680  rpcPic->setReconMark (false);
[56]681 
[2]682  m_iPOCLast++;
683  m_iNumPicRcvd++;
[56]684 
[2]685  rpcPic->getSlice(0)->setPOC( m_iPOCLast );
686  // mark it should be extended
687  rpcPic->getPicYuvRec()->setBorderExtension(false);
[622]688
689#if H_MV
[608]690  rpcPic->getPicYuvOrg()->setBorderExtension(false);
[622]691#endif
[2]692}
693
694Void TEncTop::xInitSPS()
695{
[608]696#if H_MV
697  m_cSPS.setSPSId( getLayerIdInVps() );
698  m_cSPS.setLayerId( getLayerId() );
699#endif
700  ProfileTierLevel& profileTierLevel = *m_cSPS.getPTL()->getGeneralPTL();
701  profileTierLevel.setLevelIdc(m_level);
702  profileTierLevel.setTierFlag(m_levelTier);
703  profileTierLevel.setProfileIdc(m_profile);
704  profileTierLevel.setProfileCompatibilityFlag(m_profile, 1);
705  profileTierLevel.setProgressiveSourceFlag(m_progressiveSourceFlag);
706  profileTierLevel.setInterlacedSourceFlag(m_interlacedSourceFlag);
707  profileTierLevel.setNonPackedConstraintFlag(m_nonPackedConstraintFlag);
708  profileTierLevel.setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag);
709 
710  if (m_profile == Profile::MAIN10 && g_bitDepthY == 8 && g_bitDepthC == 8)
711  {
712    /* The above constraint is equal to Profile::MAIN */
713    profileTierLevel.setProfileCompatibilityFlag(Profile::MAIN, 1);
714  }
715  if (m_profile == Profile::MAIN)
716  {
717    /* A Profile::MAIN10 decoder can always decode Profile::MAIN */
718    profileTierLevel.setProfileCompatibilityFlag(Profile::MAIN10, 1);
719  }
720  /* XXX: should Main be marked as compatible with still picture? */
721  /* XXX: may be a good idea to refactor the above into a function
722   * that chooses the actual compatibility based upon options */
723
[622]724#if H_MV 
[738]725#if H_MV_6_PS_REP_FORM_18_19_20
726  m_cSPS.setUpdateRepFormatFlag           ( false );   
727#else
[622]728  m_cSPS.setUpdateRepFormatFlag           ( m_layerId == 0 );   
[738]729#endif
[622]730  m_cSPS.setSpsInferScalingListFlag       ( m_layerId > 0 && m_cVPS->getInDirectDependencyFlag( getLayerIdInVps(), 0 ) ); 
731  m_cSPS.setSpsScalingListRefLayerId      ( 0              ); 
[738]732#if H_MV_6_PSEM_O0142_3
733  m_cSPS.setSpsExtensionFlag              ( true ); 
734  m_cSPS.setSpsExtensionTypeFlag          ( PS_EX_T_MV ,true ); 
735#if H_3D
736  m_cSPS.setSpsExtensionTypeFlag          ( PS_EX_T_3D ,true ); 
[622]737#endif
[738]738#endif
739#endif
[56]740  m_cSPS.setPicWidthInLumaSamples         ( m_iSourceWidth      );
741  m_cSPS.setPicHeightInLumaSamples        ( m_iSourceHeight     );
[608]742  m_cSPS.setConformanceWindow             ( m_conformanceWindow );
[2]743  m_cSPS.setMaxCUWidth    ( g_uiMaxCUWidth      );
744  m_cSPS.setMaxCUHeight   ( g_uiMaxCUHeight     );
745  m_cSPS.setMaxCUDepth    ( g_uiMaxCUDepth      );
[608]746
747  Int minCUSize = m_cSPS.getMaxCUWidth() >> ( m_cSPS.getMaxCUDepth()-g_uiAddCUDepth );
748  Int log2MinCUSize = 0;
749  while(minCUSize > 1)
750  {
751    minCUSize >>= 1;
752    log2MinCUSize++;
753  }
754
755  m_cSPS.setLog2MinCodingBlockSize(log2MinCUSize);
756  m_cSPS.setLog2DiffMaxMinCodingBlockSize(m_cSPS.getMaxCUDepth()-g_uiAddCUDepth);
[56]757 
758  m_cSPS.setPCMLog2MinSize (m_uiPCMLog2MinSize);
759  m_cSPS.setUsePCM        ( m_usePCM           );
760  m_cSPS.setPCMLog2MaxSize( m_pcmLog2MaxSize  );
[2]761
762  m_cSPS.setQuadtreeTULog2MaxSize( m_uiQuadtreeTULog2MaxSize );
763  m_cSPS.setQuadtreeTULog2MinSize( m_uiQuadtreeTULog2MinSize );
764  m_cSPS.setQuadtreeTUMaxDepthInter( m_uiQuadtreeTUMaxDepthInter    );
765  m_cSPS.setQuadtreeTUMaxDepthIntra( m_uiQuadtreeTUMaxDepthIntra    );
[56]766 
[608]767  m_cSPS.setTMVPFlagsPresent(false);
[56]768  m_cSPS.setUseLossless   ( m_useLossless  );
[608]769
[56]770  m_cSPS.setMaxTrSize   ( 1 << m_uiQuadtreeTULog2MaxSize );
771 
772  Int i;
773 
[608]774  for (i = 0; i < g_uiMaxCUDepth-g_uiAddCUDepth; i++ )
[56]775  {
776    m_cSPS.setAMPAcc( i, m_useAMP );
777    //m_cSPS.setAMPAcc( i, 1 );
778  }
[2]779
[56]780  m_cSPS.setUseAMP ( m_useAMP );
[2]781
[608]782#if H_3D_QTLPC
783  m_cSPS.setUseQTL( m_bUseQTL );
784  m_cSPS.setUsePC ( m_bUsePC  );
785#endif
786
787  for (i = g_uiMaxCUDepth-g_uiAddCUDepth; i < g_uiMaxCUDepth; i++ )
[56]788  {
789    m_cSPS.setAMPAcc(i, 0);
790  }
791
[608]792  m_cSPS.setBitDepthY( g_bitDepthY );
793  m_cSPS.setBitDepthC( g_bitDepthC );
[2]794
[608]795  m_cSPS.setQpBDOffsetY ( 6*(g_bitDepthY - 8) );
796  m_cSPS.setQpBDOffsetC ( 6*(g_bitDepthC - 8) );
797
[56]798  m_cSPS.setUseSAO( m_bUseSAO );
[2]799
[56]800  m_cSPS.setMaxTLayers( m_maxTempLayer );
[608]801  m_cSPS.setTemporalIdNestingFlag( ( m_maxTempLayer == 1 ) ? true : false );
[56]802  for ( i = 0; i < m_cSPS.getMaxTLayers(); i++ )
803  {
804    m_cSPS.setMaxDecPicBuffering(m_maxDecPicBuffering[i], i);
805    m_cSPS.setNumReorderPics(m_numReorderPics[i], i);
806  }
807  m_cSPS.setPCMBitDepthLuma (g_uiPCMBitDepthLuma);
808  m_cSPS.setPCMBitDepthChroma (g_uiPCMBitDepthChroma);
809  m_cSPS.setPCMFilterDisableFlag  ( m_bPCMFilterDisableFlag );
[42]810
[56]811  m_cSPS.setScalingListFlag ( (m_useScalingListId == 0) ? 0 : 1 );
812
[608]813  m_cSPS.setUseStrongIntraSmoothing( m_useStrongIntraSmoothing );
[210]814
[608]815  m_cSPS.setVuiParametersPresentFlag(getVuiParametersPresentFlag());
816  if (m_cSPS.getVuiParametersPresentFlag())
[56]817  {
[608]818    TComVUI* pcVUI = m_cSPS.getVuiParameters();
819    pcVUI->setAspectRatioInfoPresentFlag(getAspectRatioIdc() != -1);
820    pcVUI->setAspectRatioIdc(getAspectRatioIdc());
821    pcVUI->setSarWidth(getSarWidth());
822    pcVUI->setSarHeight(getSarHeight());
823    pcVUI->setOverscanInfoPresentFlag(getOverscanInfoPresentFlag());
824    pcVUI->setOverscanAppropriateFlag(getOverscanAppropriateFlag());
[738]825#if H_MV_6_PS_O0118_33
826    pcVUI->setVideoSignalTypePresentFlag(getVideoSignalTypePresentFlag() && getLayerId() == 0 );
827#else
[608]828    pcVUI->setVideoSignalTypePresentFlag(getVideoSignalTypePresentFlag());
[738]829#endif
[608]830    pcVUI->setVideoFormat(getVideoFormat());
831    pcVUI->setVideoFullRangeFlag(getVideoFullRangeFlag());
832    pcVUI->setColourDescriptionPresentFlag(getColourDescriptionPresentFlag());
833    pcVUI->setColourPrimaries(getColourPrimaries());
834    pcVUI->setTransferCharacteristics(getTransferCharacteristics());
835    pcVUI->setMatrixCoefficients(getMatrixCoefficients());
836    pcVUI->setChromaLocInfoPresentFlag(getChromaLocInfoPresentFlag());
837    pcVUI->setChromaSampleLocTypeTopField(getChromaSampleLocTypeTopField());
838    pcVUI->setChromaSampleLocTypeBottomField(getChromaSampleLocTypeBottomField());
839    pcVUI->setNeutralChromaIndicationFlag(getNeutralChromaIndicationFlag());
840    pcVUI->setDefaultDisplayWindow(getDefaultDisplayWindow());
841    pcVUI->setFrameFieldInfoPresentFlag(getFrameFieldInfoPresentFlag());
842    pcVUI->setFieldSeqFlag(false);
843    pcVUI->setHrdParametersPresentFlag(false);
844    pcVUI->getTimingInfo()->setPocProportionalToTimingFlag(getPocProportionalToTimingFlag());
845    pcVUI->getTimingInfo()->setNumTicksPocDiffOneMinus1   (getNumTicksPocDiffOneMinus1()   );
846    pcVUI->setBitstreamRestrictionFlag(getBitstreamRestrictionFlag());
847    pcVUI->setTilesFixedStructureFlag(getTilesFixedStructureFlag());
848    pcVUI->setMotionVectorsOverPicBoundariesFlag(getMotionVectorsOverPicBoundariesFlag());
849    pcVUI->setMinSpatialSegmentationIdc(getMinSpatialSegmentationIdc());
850    pcVUI->setMaxBytesPerPicDenom(getMaxBytesPerPicDenom());
851    pcVUI->setMaxBitsPerMinCuDenom(getMaxBitsPerMinCuDenom());
852    pcVUI->setLog2MaxMvLengthHorizontal(getLog2MaxMvLengthHorizontal());
853    pcVUI->setLog2MaxMvLengthVertical(getLog2MaxMvLengthVertical());
[2]854  }
[608]855#if H_3D
[755]856#if !CAM_HLS_F0136_F0045_F0082
[724]857#if !QC_DEPTH_IV_MRG_F0125
[608]858  if ( !m_isDepth )
[724]859#endif
[2]860  {
[608]861    m_cSPS.initCamParaSPS           ( m_viewIndex, m_uiCamParPrecision, m_bCamParInSliceHeader, m_aaiCodedScale, m_aaiCodedOffset );
862  }
[210]863#endif
[755]864#endif
[56]865}
[2]866
[56]867Void TEncTop::xInitPPS()
868{
[608]869#if H_MV
[622]870  m_cPPS.setLayerId( getLayerId() );
871  if( getVPS()->getNumDirectRefLayers( getLayerId() ) > 0 )
[608]872  {
873    m_cPPS.setListsModificationPresentFlag( true );
874  }
875  m_cPPS.setPPSId( getLayerIdInVps() );
876  m_cPPS.setSPSId( getLayerIdInVps() );
877#endif
[748]878
879#if DLT_DIFF_CODING_IN_PPS
880  m_cPPS.setDLT( getDLT() );
881#endif
882
[56]883  m_cPPS.setConstrainedIntraPred( m_bUseConstrainedIntraPred );
884  Bool bUseDQP = (getMaxCuDQPDepth() > 0)? true : false;
[2]885
[56]886  Int lowestQP = - m_cSPS.getQpBDOffsetY();
887
888  if(getUseLossless())
[2]889  {
[56]890    if ((getMaxCuDQPDepth() == 0) && (getMaxDeltaQP() == 0 ) && (getQP() == lowestQP) )
891    {
892      bUseDQP = false;
893    }
894    else
895    {
896      bUseDQP = true;
897    }
[2]898  }
[56]899  else
900  {
901    if(bUseDQP == false)
902    {
903      if((getMaxDeltaQP() != 0 )|| getUseAdaptiveQP())
904      {
905        bUseDQP = true;
906      }
907    }
908  }
909
910  if(bUseDQP)
911  {
912    m_cPPS.setUseDQP(true);
913    m_cPPS.setMaxCuDQPDepth( m_iMaxCuDQPDepth );
914    m_cPPS.setMinCuDQPSize( m_cPPS.getSPS()->getMaxCUWidth() >> ( m_cPPS.getMaxCuDQPDepth()) );
915  }
916  else
917  {
918    m_cPPS.setUseDQP(false);
919    m_cPPS.setMaxCuDQPDepth( 0 );
920    m_cPPS.setMinCuDQPSize( m_cPPS.getSPS()->getMaxCUWidth() >> ( m_cPPS.getMaxCuDQPDepth()) );
921  }
[2]922
[608]923#if RATE_CONTROL_LAMBDA_DOMAIN
924  if ( m_RCEnableRateControl )
925  {
926    m_cPPS.setUseDQP(true);
927    m_cPPS.setMaxCuDQPDepth( 0 );
928    m_cPPS.setMinCuDQPSize( m_cPPS.getSPS()->getMaxCUWidth() >> ( m_cPPS.getMaxCuDQPDepth()) );
[655]929  }
930#endif
931#if !RATE_CONTROL_LAMBDA_DOMAIN && KWU_FIX_URQ
932  if ( m_enableRateCtrl )
933  {
934    m_cPPS.setUseDQP(true);
935    m_cPPS.setMaxCuDQPDepth( 0 );
936    m_cPPS.setMinCuDQPSize( m_cPPS.getSPS()->getMaxCUWidth() >> ( m_cPPS.getMaxCuDQPDepth()) );
[608]937  } 
938#endif
[2]939
[608]940  m_cPPS.setChromaCbQpOffset( m_chromaCbQpOffset );
941  m_cPPS.setChromaCrQpOffset( m_chromaCrQpOffset );
942
[56]943  m_cPPS.setNumSubstreams(m_iWaveFrontSubstreams);
[608]944  m_cPPS.setEntropyCodingSyncEnabledFlag( m_iWaveFrontSynchro > 0 );
945  m_cPPS.setTilesEnabledFlag( (m_iNumColumnsMinus1 > 0 || m_iNumRowsMinus1 > 0) );
946  m_cPPS.setUseWP( m_useWeightedPred );
947  m_cPPS.setWPBiPred( m_useWeightedBiPred );
[56]948  m_cPPS.setOutputFlagPresentFlag( false );
[608]949#if H_MV
[738]950#if H_MV_6_RALS_O0149_11
951  m_cPPS.setNumExtraSliceHeaderBits( 3 ); 
952#else
[622]953  m_cPPS.setNumExtraSliceHeaderBits( 2 ); 
[608]954#endif
[738]955#endif
[56]956  m_cPPS.setSignHideFlag(getSignHideFlag());
[655]957  if ( getDeblockingFilterMetric() )
958  {
959    m_cPPS.setDeblockingFilterControlPresentFlag (true);
960    m_cPPS.setDeblockingFilterOverrideEnabledFlag(true);
961    m_cPPS.setPicDisableDeblockingFilterFlag(false);
962    m_cPPS.setDeblockingFilterBetaOffsetDiv2(0);
963    m_cPPS.setDeblockingFilterTcOffsetDiv2(0);
964  } 
965  else
966  {
967    m_cPPS.setDeblockingFilterControlPresentFlag (m_DeblockingFilterControlPresent );
968  }
[608]969  m_cPPS.setLog2ParallelMergeLevelMinus2   (m_log2ParallelMergeLevelMinus2 );
[56]970  m_cPPS.setCabacInitPresentFlag(CABAC_INIT_PRESENT_FLAG);
[608]971  m_cPPS.setLoopFilterAcrossSlicesEnabledFlag( m_bLFCrossSliceBoundaryFlag );
972  Int histogram[MAX_NUM_REF + 1];
973  for( Int i = 0; i <= MAX_NUM_REF; i++ )
974  {
975    histogram[i]=0;
976  }
977  for( Int i = 0; i < getGOPSize(); i++ )
978  {
979    assert(getGOPEntry(i).m_numRefPicsActive >= 0 && getGOPEntry(i).m_numRefPicsActive <= MAX_NUM_REF);
980    histogram[getGOPEntry(i).m_numRefPicsActive]++;
981  }
982  Int maxHist=-1;
983  Int bestPos=0;
984  for( Int i = 0; i <= MAX_NUM_REF; i++ )
985  {
986    if(histogram[i]>maxHist)
987    {
988      maxHist=histogram[i];
989      bestPos=i;
990    }
991  }
992  assert(bestPos <= 15);
993  m_cPPS.setNumRefIdxL0DefaultActive(bestPos);
994  m_cPPS.setNumRefIdxL1DefaultActive(bestPos);
995  m_cPPS.setTransquantBypassEnableFlag(getTransquantBypassEnableFlag());
996  m_cPPS.setUseTransformSkip( m_useTransformSkip );
997  if (m_sliceSegmentMode)
998  {
999    m_cPPS.setDependentSliceSegmentsEnabledFlag( true );
1000  }
1001  if( m_cPPS.getDependentSliceSegmentsEnabledFlag() )
1002  {
1003    Int NumCtx = m_cPPS.getEntropyCodingSyncEnabledFlag()?2:1;
1004    m_cSliceEncoder.initCtxMem( NumCtx );
1005    for ( UInt st = 0; st < NumCtx; st++ )
1006    {
1007      TEncSbac* ctx = NULL;
1008      ctx = new TEncSbac;
1009      ctx->init( &m_cBinCoderCABAC );
1010      m_cSliceEncoder.setCtxMem( ctx, st );
1011    }
1012  }
1013#if H_3D
[755]1014#if CAM_HLS_F0136_F0045_F0082
1015  if( m_cVPS->hasCamParInSliceHeader( getViewIndex() ) )
1016#else
[608]1017  if( m_cSPS.hasCamParInSliceHeader() )
[755]1018#endif
[608]1019  {
1020    m_cPPS.setSliceHeaderExtensionPresentFlag( true ); 
1021  }
[42]1022#endif
[2]1023}
1024
[56]1025//Function for initializing m_RPSList, a list of TComReferencePictureSet, based on the GOPEntry objects read from the config file.
[655]1026Void TEncTop::xInitRPS(Bool isFieldCoding)
[2]1027{
[56]1028  TComReferencePictureSet*      rps;
1029 
[655]1030  m_cSPS.createRPSList(getGOPSize()+m_extraRPSs+1);
[608]1031  TComRPSList* rpsList = m_cSPS.getRPSList();
1032
[56]1033  for( Int i = 0; i < getGOPSize()+m_extraRPSs; i++) 
1034  {
[608]1035    GOPEntry ge = getGOPEntry(i);
1036    rps = rpsList->getReferencePictureSet(i);
[56]1037    rps->setNumberOfPictures(ge.m_numRefPics);
1038    rps->setNumRefIdc(ge.m_numRefIdc);
1039    Int numNeg = 0;
1040    Int numPos = 0;
1041    for( Int j = 0; j < ge.m_numRefPics; j++)
[2]1042    {
[56]1043      rps->setDeltaPOC(j,ge.m_referencePics[j]);
1044      rps->setUsed(j,ge.m_usedByCurrPic[j]);
1045      if(ge.m_referencePics[j]>0)
1046      {
1047        numPos++;
1048      }
1049      else
1050      {
1051        numNeg++;
1052      }
[2]1053    }
[56]1054    rps->setNumberOfNegativePictures(numNeg);
1055    rps->setNumberOfPositivePictures(numPos);
[608]1056
1057    // handle inter RPS intialization from the config file.
1058#if AUTO_INTER_RPS
1059    rps->setInterRPSPrediction(ge.m_interRPSPrediction > 0);  // not very clean, converting anything > 0 to true.
1060    rps->setDeltaRIdxMinus1(0);                               // index to the Reference RPS is always the previous one.
1061    TComReferencePictureSet*     RPSRef = rpsList->getReferencePictureSet(i-1);  // get the reference RPS
1062
1063    if (ge.m_interRPSPrediction == 2)  // Automatic generation of the inter RPS idc based on the RIdx provided.
1064    {
1065      Int deltaRPS = getGOPEntry(i-1).m_POC - ge.m_POC;  // the ref POC - current POC
1066      Int numRefDeltaPOC = RPSRef->getNumberOfPictures();
1067
1068      rps->setDeltaRPS(deltaRPS);           // set delta RPS
1069      rps->setNumRefIdc(numRefDeltaPOC+1);  // set the numRefIdc to the number of pictures in the reference RPS + 1.
1070      Int count=0;
1071      for (Int j = 0; j <= numRefDeltaPOC; j++ ) // cycle through pics in reference RPS.
1072      {
1073        Int RefDeltaPOC = (j<numRefDeltaPOC)? RPSRef->getDeltaPOC(j): 0;  // if it is the last decoded picture, set RefDeltaPOC = 0
1074        rps->setRefIdc(j, 0);
1075        for (Int k = 0; k < rps->getNumberOfPictures(); k++ )  // cycle through pics in current RPS.
1076        {
1077          if (rps->getDeltaPOC(k) == ( RefDeltaPOC + deltaRPS))  // if the current RPS has a same picture as the reference RPS.
1078          {
1079              rps->setRefIdc(j, (rps->getUsed(k)?1:2));
1080              count++;
1081              break;
1082          }
1083        }
1084      }
1085      if (count != rps->getNumberOfPictures())
1086      {
1087        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");
1088        rps->setInterRPSPrediction(0);
1089      }
1090    }
1091    else if (ge.m_interRPSPrediction == 1)  // inter RPS idc based on the RefIdc values provided in config file.
1092    {
1093      rps->setDeltaRPS(ge.m_deltaRPS);
1094      rps->setNumRefIdc(ge.m_numRefIdc);
1095      for (Int j = 0; j < ge.m_numRefIdc; j++ )
1096      {
1097        rps->setRefIdc(j, ge.m_refIdc[j]);
1098      }
1099#if WRITE_BACK
1100      // the folowing code overwrite the deltaPOC and Used by current values read from the config file with the ones
1101      // computed from the RefIdc.  A warning is printed if they are not identical.
1102      numNeg = 0;
1103      numPos = 0;
1104      TComReferencePictureSet      RPSTemp;  // temporary variable
1105
1106      for (Int j = 0; j < ge.m_numRefIdc; j++ )
1107      {
1108        if (ge.m_refIdc[j])
1109        {
1110          Int deltaPOC = ge.m_deltaRPS + ((j < RPSRef->getNumberOfPictures())? RPSRef->getDeltaPOC(j) : 0);
1111          RPSTemp.setDeltaPOC((numNeg+numPos),deltaPOC);
1112          RPSTemp.setUsed((numNeg+numPos),ge.m_refIdc[j]==1?1:0);
1113          if (deltaPOC<0)
1114          {
1115            numNeg++;
1116          }
1117          else
1118          {
1119            numPos++;
1120          }
1121        }
1122      }
1123      if (numNeg != rps->getNumberOfNegativePictures())
1124      {
1125        printf("Warning: number of negative pictures in RPS is different between intra and inter RPS specified in the config file.\n");
1126        rps->setNumberOfNegativePictures(numNeg);
[655]1127        rps->setNumberOfPictures(numNeg+numPos);
[608]1128      }
1129      if (numPos != rps->getNumberOfPositivePictures())
1130      {
1131        printf("Warning: number of positive pictures in RPS is different between intra and inter RPS specified in the config file.\n");
1132        rps->setNumberOfPositivePictures(numPos);
[655]1133        rps->setNumberOfPictures(numNeg+numPos);
[608]1134      }
1135      RPSTemp.setNumberOfPictures(numNeg+numPos);
1136      RPSTemp.setNumberOfNegativePictures(numNeg);
1137      RPSTemp.sortDeltaPOC();     // sort the created delta POC before comparing
1138      // check if Delta POC and Used are the same
1139      // print warning if they are not.
1140      for (Int j = 0; j < ge.m_numRefIdc; j++ )
1141      {
1142        if (RPSTemp.getDeltaPOC(j) != rps->getDeltaPOC(j))
1143        {
1144          printf("Warning: delta POC is different between intra RPS and inter RPS specified in the config file.\n");
1145          rps->setDeltaPOC(j,RPSTemp.getDeltaPOC(j));
1146        }
1147        if (RPSTemp.getUsed(j) != rps->getUsed(j))
1148        {
1149          printf("Warning: Used by Current in RPS is different between intra and inter RPS specified in the config file.\n");
1150          rps->setUsed(j,RPSTemp.getUsed(j));
1151        }
1152      }
1153#endif
1154    }
1155#else
[56]1156    rps->setInterRPSPrediction(ge.m_interRPSPrediction);
1157    if (ge.m_interRPSPrediction)
[2]1158    {
[608]1159      rps->setDeltaRIdxMinus1(0);
[56]1160      rps->setDeltaRPS(ge.m_deltaRPS);
1161      rps->setNumRefIdc(ge.m_numRefIdc);
1162      for (Int j = 0; j < ge.m_numRefIdc; j++ )
1163      {
1164        rps->setRefIdc(j, ge.m_refIdc[j]);
1165      }
1166#if WRITE_BACK
1167      // the folowing code overwrite the deltaPOC and Used by current values read from the config file with the ones
1168      // computed from the RefIdc.  This is not necessary if both are identical. Currently there is no check to see if they are identical.
1169      numNeg = 0;
1170      numPos = 0;
[608]1171      TComReferencePictureSet*     RPSRef = m_RPSList.getReferencePictureSet(i-1);
1172
[56]1173      for (Int j = 0; j < ge.m_numRefIdc; j++ )
1174      {
1175        if (ge.m_refIdc[j])
1176        {
1177          Int deltaPOC = ge.m_deltaRPS + ((j < RPSRef->getNumberOfPictures())? RPSRef->getDeltaPOC(j) : 0);
1178          rps->setDeltaPOC((numNeg+numPos),deltaPOC);
1179          rps->setUsed((numNeg+numPos),ge.m_refIdc[j]==1?1:0);
1180          if (deltaPOC<0)
1181          {
1182            numNeg++;
1183          }
1184          else
1185          {
1186            numPos++;
1187          }
1188        }
1189      }
1190      rps->setNumberOfNegativePictures(numNeg);
1191      rps->setNumberOfPositivePictures(numPos);
1192      rps->sortDeltaPOC();
1193#endif
[2]1194    }
[608]1195#endif //INTER_RPS_AUTO
[56]1196  }
[655]1197  //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.
1198  //The position = GOPSize + extraRPSs which is (a priori) unused is reserved for this field in the RPS.
1199  if (isFieldCoding) 
1200  {
1201    rps = rpsList->getReferencePictureSet(getGOPSize()+m_extraRPSs);
1202    rps->setNumberOfPictures(1);
1203    rps->setNumberOfNegativePictures(1);
1204    rps->setNumberOfPositivePictures(0);
1205    rps->setNumberOfLongtermPictures(0);
1206    rps->setDeltaPOC(0,-1);
1207    rps->setPOC(0,0);
1208    rps->setUsed(0,true);
1209    rps->setInterRPSPrediction(false);
1210    rps->setDeltaRIdxMinus1(0);
1211    rps->setDeltaRPS(0);
1212    rps->setNumRefIdc(0);
[56]1213}
[655]1214}
[2]1215
[56]1216   // This is a function that
1217   // determines what Reference Picture Set to use
1218   // for a specific slice (with POC = POCCurr)
[608]1219Void TEncTop::selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid )
[56]1220{
[608]1221#if H_MV
1222  if( slice->getRapPicFlag() == true && getLayerId() > 0 && POCCurr == 0 )
[56]1223  {
1224    TComReferencePictureSet* rps = slice->getLocalRPS();
1225    rps->setNumberOfNegativePictures(0);
1226    rps->setNumberOfPositivePictures(0);
1227    rps->setNumberOfLongtermPictures(0);
1228    rps->setNumberOfPictures(0);
1229    slice->setRPS(rps);
1230  }
1231  else
1232  {
[608]1233#endif
1234  slice->setRPSidx(GOPid);
[2]1235
[608]1236  for(Int extraNum=m_iGOPSize; extraNum<m_extraRPSs+m_iGOPSize; extraNum++)
1237  {   
1238    if(m_uiIntraPeriod > 0 && getDecodingRefreshType() > 0)
1239    {
1240      Int POCIndex = POCCurr%m_uiIntraPeriod;
1241      if(POCIndex == 0)
[56]1242      {
[608]1243        POCIndex = m_uiIntraPeriod;
[56]1244      }
[608]1245      if(POCIndex == m_GOPList[extraNum].m_POC)
[56]1246      {
[608]1247        slice->setRPSidx(extraNum);
[56]1248      }
1249    }
[608]1250    else
1251    {
1252      if(POCCurr==m_GOPList[extraNum].m_POC)
1253      {
1254        slice->setRPSidx(extraNum);
1255      }
1256    }
1257  }
[655]1258  if(POCCurr == 1 && slice->getPic()->isField())
1259  {
1260    slice->setRPSidx(m_iGOPSize+m_extraRPSs);
1261  }
[2]1262
[608]1263  slice->setRPS(getSPS()->getRPSList()->getReferencePictureSet(slice->getRPSidx()));
1264  slice->getRPS()->setNumberOfPictures(slice->getRPS()->getNumberOfNegativePictures()+slice->getRPS()->getNumberOfPositivePictures());
1265#if H_MV
[56]1266  }
[608]1267#endif
1268
[2]1269}
1270
[608]1271Int TEncTop::getReferencePictureSetIdxForSOP(TComSlice* slice, Int POCCurr, Int GOPid )
[2]1272{
[608]1273  int rpsIdx = GOPid;
[2]1274
[608]1275  for(Int extraNum=m_iGOPSize; extraNum<m_extraRPSs+m_iGOPSize; extraNum++)
1276  {   
1277    if(m_uiIntraPeriod > 0 && getDecodingRefreshType() > 0)
[2]1278    {
[608]1279      Int POCIndex = POCCurr%m_uiIntraPeriod;
1280      if(POCIndex == 0)
[2]1281      {
[608]1282        POCIndex = m_uiIntraPeriod;
[2]1283      }
[608]1284      if(POCIndex == m_GOPList[extraNum].m_POC)
[2]1285      {
[608]1286        rpsIdx = extraNum;
[2]1287      }
1288    }
[608]1289    else
[56]1290    {
[608]1291      if(POCCurr==m_GOPList[extraNum].m_POC)
[56]1292      {
[608]1293        rpsIdx = extraNum;
[56]1294      }
1295    }
[2]1296  }
[56]1297
[608]1298  return rpsIdx;
[56]1299}
1300
1301Void  TEncTop::xInitPPSforTiles()
1302{
[608]1303  m_cPPS.setUniformSpacingFlag( m_iUniformSpacingIdr );
1304  m_cPPS.setNumColumnsMinus1( m_iNumColumnsMinus1 );
1305  m_cPPS.setNumRowsMinus1( m_iNumRowsMinus1 );
1306  if( m_iUniformSpacingIdr == 0 )
1307  {
1308    m_cPPS.setColumnWidth( m_puiColumnWidth );
1309    m_cPPS.setRowHeight( m_puiRowHeight );
1310  }
1311  m_cPPS.setLoopFilterAcrossTilesEnabledFlag( m_loopFilterAcrossTilesEnabledFlag );
[56]1312
[608]1313  // # substreams is "per tile" when tiles are independent.
1314  if (m_iWaveFrontSynchro
1315    )
1316  {
1317    m_cPPS.setNumSubstreams(m_iWaveFrontSubstreams * (m_iNumColumnsMinus1+1));
1318  }
[2]1319}
1320
[56]1321Void  TEncCfg::xCheckGSParameters()
[2]1322{
[56]1323  Int   iWidthInCU = ( m_iSourceWidth%g_uiMaxCUWidth ) ? m_iSourceWidth/g_uiMaxCUWidth + 1 : m_iSourceWidth/g_uiMaxCUWidth;
1324  Int   iHeightInCU = ( m_iSourceHeight%g_uiMaxCUHeight ) ? m_iSourceHeight/g_uiMaxCUHeight + 1 : m_iSourceHeight/g_uiMaxCUHeight;
1325  UInt  uiCummulativeColumnWidth = 0;
1326  UInt  uiCummulativeRowHeight = 0;
1327
1328  //check the column relative parameters
1329  if( m_iNumColumnsMinus1 >= (1<<(LOG2_MAX_NUM_COLUMNS_MINUS1+1)) )
[2]1330  {
[56]1331    printf( "The number of columns is larger than the maximum allowed number of columns.\n" );
1332    exit( EXIT_FAILURE );
[2]1333  }
[56]1334
1335  if( m_iNumColumnsMinus1 >= iWidthInCU )
[2]1336  {
[56]1337    printf( "The current picture can not have so many columns.\n" );
1338    exit( EXIT_FAILURE );
[2]1339  }
[56]1340
1341  if( m_iNumColumnsMinus1 && m_iUniformSpacingIdr==0 )
[2]1342  {
[56]1343    for(Int i=0; i<m_iNumColumnsMinus1; i++)
[608]1344    {
[56]1345      uiCummulativeColumnWidth += m_puiColumnWidth[i];
[608]1346    }
[56]1347
1348    if( uiCummulativeColumnWidth >= iWidthInCU )
1349    {
1350      printf( "The width of the column is too large.\n" );
1351      exit( EXIT_FAILURE );
1352    }
[2]1353  }
[56]1354
1355  //check the row relative parameters
1356  if( m_iNumRowsMinus1 >= (1<<(LOG2_MAX_NUM_ROWS_MINUS1+1)) )
[2]1357  {
[56]1358    printf( "The number of rows is larger than the maximum allowed number of rows.\n" );
1359    exit( EXIT_FAILURE );
[2]1360  }
[56]1361
1362  if( m_iNumRowsMinus1 >= iHeightInCU )
[2]1363  {
[56]1364    printf( "The current picture can not have so many rows.\n" );
1365    exit( EXIT_FAILURE );
[2]1366  }
1367
[56]1368  if( m_iNumRowsMinus1 && m_iUniformSpacingIdr==0 )
1369  {
1370    for(Int i=0; i<m_iNumRowsMinus1; i++)
1371      uiCummulativeRowHeight += m_puiRowHeight[i];
1372
1373    if( uiCummulativeRowHeight >= iHeightInCU )
1374    {
1375      printf( "The height of the row is too large.\n" );
1376      exit( EXIT_FAILURE );
1377    }
1378  }
[2]1379}
[608]1380#if H_MV
[655]1381Void TEncTop::printSummary( Int numAllPicCoded, Bool isField )
[56]1382{
[655]1383  assert ( !isField ); // Multiview and field coding need to be further unified
[608]1384  assert (numAllPicCoded == m_cAnalyzeAll.getNumPic());
[2]1385
[56]1386  //--CFG_KDY
1387  m_cAnalyzeAll.setFrmRate( getFrameRate() );
1388  m_cAnalyzeI.setFrmRate( getFrameRate() );
1389  m_cAnalyzeP.setFrmRate( getFrameRate() );
1390  m_cAnalyzeB.setFrmRate( getFrameRate() );
[2]1391
[56]1392  //-- all
[608]1393  printf( "\n\nSUMMARY ------------------------------------------- LayerId %2d\n", m_layerId );
1394
[56]1395  m_cAnalyzeAll.printOut('a');
[2]1396
[56]1397  printf( "\n\nI Slices--------------------------------------------------------\n" );
1398  m_cAnalyzeI.printOut('i');
1399
1400  printf( "\n\nP Slices--------------------------------------------------------\n" );
1401  m_cAnalyzeP.printOut('p');
1402
1403  printf( "\n\nB Slices--------------------------------------------------------\n" );
1404  m_cAnalyzeB.printOut('b');
1405
[608]1406#if _SUMMARY_OUT_
1407  m_cAnalyzeAll.printSummaryOut();
1408#endif
1409#if _SUMMARY_PIC_
1410  m_cAnalyzeI.printSummary('I');
1411  m_cAnalyzeP.printSummary('P');
1412  m_cAnalyzeB.printSummary('B');
1413#endif
[2]1414}
[56]1415
[608]1416Int TEncTop::getFrameId(Int iGOPid) 
1417{
1418  if(m_iPOCLast == 0)
1419  {
1420    return(0 );
1421  }
1422  else
1423  {
1424    return m_iPOCLast -m_iNumPicRcvd+ getGOPEntry(iGOPid).m_POC ;
1425  }
1426}
1427
1428TComPic* TEncTop::getPic( Int poc )
1429{
1430  TComList<TComPic*>* listPic = getListPic();
1431  TComPic* pcPic = NULL;
1432  for(TComList<TComPic*>::iterator it=listPic->begin(); it!=listPic->end(); it++)
1433  {
1434    if( (*it)->getPOC() == poc )
1435    {
1436      pcPic = *it ;
1437      break ;
1438    }
1439  }
1440  return pcPic;
1441}
1442#endif
1443
1444#if H_3D_VSO
1445Void TEncTop::setupRenModel( Int iPoc, Int iEncViewIdx, Int iEncContent, Int iHorOffset )
1446{
1447  TRenModel* rendererModel = m_cRdCost.getRenModel(); 
1448  rendererModel->setupPart( iHorOffset, std::min( (Int) g_uiMaxCUHeight, (Int) ( m_iSourceHeight - iHorOffset ) )) ; 
1449 
1450  Int iEncViewSIdx = m_cameraParameters->getBaseId2SortedId()[ iEncViewIdx ];
1451
1452  // setup base views
1453  Int iNumOfBV = m_renderModelParameters->getNumOfBaseViewsForView( iEncViewSIdx, iEncContent );
1454
1455  for (Int iCurView = 0; iCurView < iNumOfBV; iCurView++ )
1456  {
1457    Int iBaseViewSIdx;
1458    Int iVideoDistMode;
1459    Int iDepthDistMode;
1460
1461    m_renderModelParameters->getBaseViewData( iEncViewSIdx, iEncContent, iCurView, iBaseViewSIdx, iVideoDistMode, iDepthDistMode );
1462
1463    AOT( iVideoDistMode < 0 || iVideoDistMode > 2 );
1464
1465    Int iBaseViewIdx = m_cameraParameters->getBaseSortedId2Id()[ iBaseViewSIdx ];
1466
1467    TComPicYuv* pcPicYuvVideoRec  = m_ivPicLists->getPicYuv( iBaseViewIdx, false, iPoc, true  );
1468    TComPicYuv* pcPicYuvDepthRec  = m_ivPicLists->getPicYuv( iBaseViewIdx, true , iPoc, true  );
1469    TComPicYuv* pcPicYuvVideoOrg  = m_ivPicLists->getPicYuv( iBaseViewIdx, false, iPoc, false );
1470    TComPicYuv* pcPicYuvDepthOrg  = m_ivPicLists->getPicYuv( iBaseViewIdx, true , iPoc, false );   
1471
1472    TComPicYuv* pcPicYuvVideoRef  = ( iVideoDistMode == 2 ) ? pcPicYuvVideoOrg  : NULL;
1473    TComPicYuv* pcPicYuvDepthRef  = ( iDepthDistMode == 2 ) ? pcPicYuvDepthOrg  : NULL;
1474
1475    TComPicYuv* pcPicYuvVideoTest = ( iVideoDistMode == 0 ) ? pcPicYuvVideoOrg  : pcPicYuvVideoRec;
1476    TComPicYuv* pcPicYuvDepthTest = ( iDepthDistMode == 0 ) ? pcPicYuvDepthOrg  : pcPicYuvDepthRec;
1477
1478    AOT( (iVideoDistMode == 2) != (pcPicYuvVideoRef != NULL) );
1479    AOT( (iDepthDistMode == 2) != (pcPicYuvDepthRef != NULL) );
1480    AOT( pcPicYuvDepthTest == NULL );
1481    AOT( pcPicYuvVideoTest == NULL );
1482
1483    rendererModel->setBaseView( iBaseViewSIdx, pcPicYuvVideoTest, pcPicYuvDepthTest, pcPicYuvVideoRef, pcPicYuvDepthRef );
1484  }
1485
1486  rendererModel->setErrorMode( iEncViewSIdx, iEncContent, 0 );
1487  // setup virtual views
1488  Int iNumOfSV  = m_renderModelParameters->getNumOfModelsForView( iEncViewSIdx, iEncContent );
1489  for (Int iCurView = 0; iCurView < iNumOfSV; iCurView++ )
1490  {
1491    Int iOrgRefBaseViewSIdx;
1492    Int iLeftBaseViewSIdx;
1493    Int iRightBaseViewSIdx;
1494    Int iSynthViewRelNum;
1495    Int iModelNum;
1496    Int iBlendMode;
1497    m_renderModelParameters->getSingleModelData(iEncViewSIdx, iEncContent, iCurView, iModelNum, iBlendMode,iLeftBaseViewSIdx, iRightBaseViewSIdx, iOrgRefBaseViewSIdx, iSynthViewRelNum );
1498
1499    Int iLeftBaseViewIdx    = -1;
1500    Int iRightBaseViewIdx   = -1;
1501
1502    TComPicYuv* pcPicYuvOrgRef  = NULL;
1503    Int**      ppiShiftLUTLeft  = NULL;
1504    Int**      ppiShiftLUTRight = NULL;
1505    Int**      ppiBaseShiftLUTLeft  = NULL;
1506    Int**      ppiBaseShiftLUTRight = NULL;
1507
1508
1509    Int        iDistToLeft      = -1;
1510
1511    Int iSynthViewIdx = m_cameraParameters->synthRelNum2Idx( iSynthViewRelNum );
1512
1513    if ( iLeftBaseViewSIdx != -1 )
1514    {
1515      iLeftBaseViewIdx   = m_cameraParameters->getBaseSortedId2Id()   [ iLeftBaseViewSIdx ];
1516      ppiShiftLUTLeft    = m_cameraParameters->getSynthViewShiftLUTI()[ iLeftBaseViewIdx  ][ iSynthViewIdx  ];
1517    }
1518
1519    if ( iRightBaseViewSIdx != -1 )
1520    {
1521      iRightBaseViewIdx  = m_cameraParameters->getBaseSortedId2Id()   [iRightBaseViewSIdx ];
1522      ppiShiftLUTRight   = m_cameraParameters->getSynthViewShiftLUTI()[ iRightBaseViewIdx ][ iSynthViewIdx ];
1523    }
1524
1525    if ( iRightBaseViewSIdx != -1 && iLeftBaseViewSIdx != -1 )
1526    {
1527      iDistToLeft          = m_cameraParameters->getRelDistLeft(  iSynthViewIdx , iLeftBaseViewIdx, iRightBaseViewIdx);
1528      ppiBaseShiftLUTLeft  = m_cameraParameters->getBaseViewShiftLUTI() [ iLeftBaseViewIdx  ][ iRightBaseViewIdx ];
1529      ppiBaseShiftLUTRight = m_cameraParameters->getBaseViewShiftLUTI() [ iRightBaseViewIdx ][ iLeftBaseViewIdx  ];
1530
1531    }
1532
1533    if ( iOrgRefBaseViewSIdx != -1 )
1534    {
1535      pcPicYuvOrgRef = m_ivPicLists->getPicYuv(  m_cameraParameters->getBaseSortedId2Id()[ iOrgRefBaseViewSIdx ] , false, iPoc, false );
1536      AOF ( pcPicYuvOrgRef );
1537    }
1538
1539    rendererModel->setSingleModel( iModelNum, ppiShiftLUTLeft, ppiBaseShiftLUTLeft, ppiShiftLUTRight, ppiBaseShiftLUTRight, iDistToLeft, pcPicYuvOrgRef );
1540  }
1541}
1542#endif
[56]1543//! \}
Note: See TracBrowser for help on using the repository browser.