source: 3DVCSoftware/trunk/source/App/TAppEncoder/TAppEncTop.cpp @ 96

Last change on this file since 96 was 77, checked in by tech, 13 years ago

Merged with branch/HTM-3.0Samsung REV74 including:

  • restricted residual prediction m24766
  • Inter-view residual prediction m24938
  • VPS concept m24714,m24878, m24945,m24896, m2491
  • reference list modification, restriction on IDR m24876, m24874
  • depth based motion parameter prediction m24829

Fixed bugs:

  • interview prediction
  • VSO

Added:

  • xcode project
  • Property svn:eol-style set to native
File size: 56.6 KB
RevLine 
[5]1/* The copyright in this software is being made available under the BSD
2 * License, included below. This software may be subject to other third party
3 * and contributor rights, including patent rights, and no such rights are
[56]4 * granted under this license. 
[5]5 *
[56]6 * Copyright (c) 2010-2012, ITU/ISO/IEC
[5]7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright notice,
13 *    this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above copyright notice,
15 *    this list of conditions and the following disclaimer in the documentation
16 *    and/or other materials provided with the distribution.
[56]17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
[5]18 *    be used to endorse or promote products derived from this software without
19 *    specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
[2]33
34/** \file     TAppEncTop.cpp
35    \brief    Encoder application class
36*/
37
38#include <list>
[56]39#include <fstream>
40#include <stdlib.h>
[2]41#include <stdio.h>
42#include <fcntl.h>
43#include <assert.h>
44
45#include "TAppEncTop.h"
[56]46#include "TLibEncoder/AnnexBwrite.h"
[2]47
[56]48using namespace std;
49
50//! \ingroup TAppEncoder
51//! \{
52
[2]53// ====================================================================================================================
54// Constructor / destructor / initialization / destroy
55// ====================================================================================================================
56
57TAppEncTop::TAppEncTop()
58{
[56]59  m_totalBytes = 0;
60  m_essentialBytes = 0;
[2]61}
62
63TAppEncTop::~TAppEncTop()
64{
65}
66
67Void TAppEncTop::xInitLibCfg()
68{
[77]69#if VIDYO_VPS_INTEGRATION
70  UInt layerId = 0;
71  // TODO: fix the assumption here that the temporal structures are all equal across all layers???
72  m_cVPS.setMaxTLayers( m_maxTempLayer[0] );
73  m_cVPS.setMaxLayers( m_iNumberOfViews * (m_bUsingDepthMaps ? 2:1) );
74  for(Int i = 0; i < MAX_TLAYER; i++)
75  {
76    m_cVPS.setNumReorderPics( m_numReorderPics[0][i], i );
77    m_cVPS.setMaxDecPicBuffering( m_maxDecPicBuffering[0][i], i );
78  }
79#endif
80 
[2]81  for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
82  {
[56]83    m_frameRcvd.push_back(0);
84    m_acTEncTopList.push_back(new TEncTop); 
[2]85    m_acTVideoIOYuvInputFileList.push_back(new TVideoIOYuv);
[56]86    m_acTVideoIOYuvReconFileList.push_back(new TVideoIOYuv);
87    m_picYuvRec.push_back(new TComList<TComPicYuv*>) ;
[2]88
89    m_acTEncTopList[iViewIdx]->setFrameRate                    ( m_iFrameRate );
90    m_acTEncTopList[iViewIdx]->setFrameSkip                    ( m_FrameSkip );
91    m_acTEncTopList[iViewIdx]->setSourceWidth                  ( m_iSourceWidth );
92    m_acTEncTopList[iViewIdx]->setSourceHeight                 ( m_iSourceHeight );
[56]93#if PIC_CROPPING
94    m_acTEncTopList[iViewIdx]->setCroppingMode                 ( m_croppingMode );
95    m_acTEncTopList[iViewIdx]->setCropLeft                     ( m_cropLeft );
96    m_acTEncTopList[iViewIdx]->setCropRight                    ( m_cropRight );
97    m_acTEncTopList[iViewIdx]->setCropTop                      ( m_cropTop );
98    m_acTEncTopList[iViewIdx]->setCropBottom                   ( m_cropBottom );
99#endif
[2]100    m_acTEncTopList[iViewIdx]->setFrameToBeEncoded             ( m_iFrameToBeEncoded );
[56]101    m_acTEncTopList[iViewIdx]->setViewId                       ( iViewIdx );
102    m_acTEncTopList[iViewIdx]->setIsDepth                      ( false );
103    m_acTEncTopList[iViewIdx]->setViewOrderIdx                 ( m_cCameraData.getViewOrderIndex()[ iViewIdx ] );
[77]104#if VIDYO_VPS_INTEGRATION
105    layerId = iViewIdx * (m_bUsingDepthMaps ? 2:1);
106    m_acTEncTopList[iViewIdx]->setLayerId                      ( layerId );
107    m_cVPS.setDepthFlag                                        ( false, layerId );
108    m_cVPS.setViewId                                           ( iViewIdx, layerId );
109    m_cVPS.setViewOrderIdx                                     ( m_cCameraData.getViewOrderIndex()[ iViewIdx ], layerId );
110    // TODO: set correct dependentFlag and dependentLayer
111    m_cVPS.setDependentFlag                                    ( iViewIdx ? true:false, layerId );
112    m_cVPS.setDependentLayer                                   ( layerId - (m_bUsingDepthMaps ? 2:1), layerId );
113#endif
114   
[56]115    m_acTEncTopList[iViewIdx]->setCamParPrecision              ( m_cCameraData.getCamParsCodedPrecision  () );
116    m_acTEncTopList[iViewIdx]->setCamParInSliceHeader          ( m_cCameraData.getVaryingCameraParameters() );
117    m_acTEncTopList[iViewIdx]->setCodedScale                   ( m_cCameraData.getCodedScale             () );
118    m_acTEncTopList[iViewIdx]->setCodedOffset                  ( m_cCameraData.getCodedOffset            () );
[2]119
120  //====== Coding Structure ========
[56]121    m_acTEncTopList[iViewIdx]->setIntraPeriod                  ( m_iIntraPeriod );
[2]122    m_acTEncTopList[iViewIdx]->setDecodingRefreshType          ( m_iDecodingRefreshType );
[56]123    m_acTEncTopList[iViewIdx]->setGOPSize                      ( m_iGOPSize );
124    m_acTEncTopList[iViewIdx]->setGopList                      ( m_GOPListsMvc[iViewIdx] );
125    m_acTEncTopList[iViewIdx]->setExtraRPSs                    ( m_extraRPSs[iViewIdx] );
126#if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER
127    for(Int i = 0; i < MAX_TLAYER; i++)
128    {
129      m_acTEncTopList[iViewIdx]->setNumReorderPics             ( m_numReorderPics[iViewIdx][i], i );
130      m_acTEncTopList[iViewIdx]->setMaxDecPicBuffering         ( m_maxDecPicBuffering[iViewIdx][i], i );
131    }
132#else
133    m_acTEncTopList[iViewIdx]->setNumReorderFrames             ( m_numReorderFrames );
134    m_acTEncTopList[iViewIdx]->setMaxNumberOfReferencePictures ( m_maxNumberOfReferencePictures );
[2]135#endif
[56]136    for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop )
137    {
138      m_acTEncTopList[iViewIdx]->setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] );
139    }
[2]140    m_acTEncTopList[iViewIdx]->setQP                           ( m_aiQP[0] );
[56]141 
[2]142    m_acTEncTopList[iViewIdx]->setTemporalLayerQPOffset        ( m_aiTLayerQPOffset );
143    m_acTEncTopList[iViewIdx]->setPad                          ( m_aiPad );
[56]144   
145#if H0566_TLA
146    m_acTEncTopList[iViewIdx]->setMaxTempLayer                 ( m_maxTempLayer[iViewIdx] );
147#else
148    m_acTEncTopList[iViewIdx]->setTLayering                    ( m_bTLayering );
149    m_acTEncTopList[iViewIdx]->setTLayerSwitchingFlag          ( m_abTLayerSwitchingFlag );
150#endif
[2]151
[56]152    m_acTEncTopList[iViewIdx]->setDisInter4x4                  ( m_bDisInter4x4);
153 
154    m_acTEncTopList[iViewIdx]->setUseNSQT( m_enableNSQT );
155    m_acTEncTopList[iViewIdx]->setUseAMP( m_enableAMP );
156 
157  //===== Slice ========
158 
159  //====== Loop/Deblock Filter ========
160    m_acTEncTopList[iViewIdx]->setLoopFilterDisable            ( m_abLoopFilterDisable[0]       );
161    m_acTEncTopList[iViewIdx]->setLoopFilterOffsetInAPS        ( m_loopFilterOffsetInAPS );
162    m_acTEncTopList[iViewIdx]->setLoopFilterBetaOffset         ( m_loopFilterBetaOffsetDiv2  );
163    m_acTEncTopList[iViewIdx]->setLoopFilterTcOffset           ( m_loopFilterTcOffsetDiv2    );
164#if DBL_CONTROL
165    m_acTEncTopList[iViewIdx]->setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent);
166#endif
[2]167
[56]168  //====== Motion search ========
[2]169    m_acTEncTopList[iViewIdx]->setFastSearch                   ( m_iFastSearch  );
170    m_acTEncTopList[iViewIdx]->setSearchRange                  ( m_iSearchRange );
171    m_acTEncTopList[iViewIdx]->setBipredSearchRange            ( m_bipredSearchRange );
[56]172
173  //====== Quality control ========
[2]174    m_acTEncTopList[iViewIdx]->setMaxDeltaQP                   ( m_iMaxDeltaQP  );
[56]175    m_acTEncTopList[iViewIdx]->setMaxCuDQPDepth                ( m_iMaxCuDQPDepth  );
[2]176
[56]177    m_acTEncTopList[iViewIdx]->setChromaQpOffset               ( m_iChromaQpOffset     );
178    m_acTEncTopList[iViewIdx]->setChromaQpOffset2nd            ( m_iChromaQpOffset2nd  );
179
180#if ADAPTIVE_QP_SELECTION
181    m_acTEncTopList[iViewIdx]->setUseAdaptQpSelect             ( m_bUseAdaptQpSelect   );
182#endif
183
184#if LOSSLESS_CODING
185    Int lowestQP;
186#if H0736_AVC_STYLE_QP_RANGE
187    lowestQP =  - ( (Int)(6*(g_uiBitDepth + g_uiBitIncrement - 8)) );
188#else
189    lowestQP = 0;
190#endif
191    if ((m_iMaxDeltaQP == 0 ) && (m_aiQP[0] == lowestQP) && (m_useLossless == true))
192    {
193      m_bUseAdaptiveQP = false;
194    }
195#endif
196
197    m_acTEncTopList[iViewIdx]->setUseAdaptiveQP                ( m_bUseAdaptiveQP  );
198    m_acTEncTopList[iViewIdx]->setQPAdaptationRange            ( m_iQPAdaptationRange );
199 
[5]200#if HHI_VSO
[2]201    //====== VSO =========
202    m_acTEncTopList[iViewIdx]->setForceLambdaScaleVSO          ( false );
203    m_acTEncTopList[iViewIdx]->setLambdaScaleVSO               ( 1     );
204    m_acTEncTopList[iViewIdx]->setVSOMode                      ( 0     );
[56]205    m_acTEncTopList[iViewIdx]->setUseVSO                       ( false ); //GT: might be enabled later for VSO Mode 4
[5]206#endif
[2]207
[56]208#if DEPTH_MAP_GENERATION
209    m_acTEncTopList[iViewIdx]->setPredDepthMapGeneration       ( m_uiPredDepthMapGeneration );
210    m_acTEncTopList[iViewIdx]->setPdmPrecision                 ( (UInt)m_cCameraData.getPdmPrecision     () );
211    m_acTEncTopList[iViewIdx]->setPdmScaleNomDelta             (       m_cCameraData.getPdmScaleNomDelta () );
212    m_acTEncTopList[iViewIdx]->setPdmOffset                    (       m_cCameraData.getPdmOffset        () );
213#endif
214#if HHI_INTER_VIEW_MOTION_PRED
215    m_acTEncTopList[iViewIdx]->setMultiviewMvPredMode          ( m_uiMultiviewMvPredMode );
216    m_acTEncTopList[iViewIdx]->setMultiviewMvRegMode           ( iViewIdx ? m_uiMultiviewMvRegMode       : 0   );
217    m_acTEncTopList[iViewIdx]->setMultiviewMvRegLambdaScale    ( iViewIdx ? m_dMultiviewMvRegLambdaScale : 0.0 );
218#endif
219#if HHI_INTER_VIEW_RESIDUAL_PRED
220    m_acTEncTopList[iViewIdx]->setMultiviewResPredMode         ( m_uiMultiviewResPredMode );
221#endif
222
223  //====== Tool list ========
[2]224    m_acTEncTopList[iViewIdx]->setUseSBACRD                    ( m_bUseSBACRD   );
225    m_acTEncTopList[iViewIdx]->setDeltaQpRD                    ( m_uiDeltaQpRD  );
226    m_acTEncTopList[iViewIdx]->setUseASR                       ( m_bUseASR      );
227    m_acTEncTopList[iViewIdx]->setUseHADME                     ( m_bUseHADME    );
228    m_acTEncTopList[iViewIdx]->setUseALF                       ( m_abUseALF[0]  );
229    m_acTEncTopList[iViewIdx]->setALFEncodePassReduction       ( m_iALFEncodePassReduction );
[56]230#if LOSSLESS_CODING
231    m_acTEncTopList[iViewIdx]->setUseLossless                  ( m_useLossless );
[2]232#endif
[56]233    m_acTEncTopList[iViewIdx]->setALFMaxNumberFilters          ( m_iALFMaxNumberFilters ) ;
234
[2]235    m_acTEncTopList[iViewIdx]->setUseLComb                     ( m_bUseLComb    );
236    m_acTEncTopList[iViewIdx]->setLCMod                        ( m_bLCMod         );
237    m_acTEncTopList[iViewIdx]->setdQPs                         ( m_aidQP        );
238    m_acTEncTopList[iViewIdx]->setUseRDOQ                      ( m_abUseRDOQ[0] );
[56]239#if !PIC_CROPPING
[2]240    m_acTEncTopList[iViewIdx]->setUsePAD                       ( m_bUsePAD      );
[56]241#endif
[2]242    m_acTEncTopList[iViewIdx]->setQuadtreeTULog2MaxSize        ( m_uiQuadtreeTULog2MaxSize );
243    m_acTEncTopList[iViewIdx]->setQuadtreeTULog2MinSize        ( m_uiQuadtreeTULog2MinSize );
244    m_acTEncTopList[iViewIdx]->setQuadtreeTUMaxDepthInter      ( m_uiQuadtreeTUMaxDepthInter );
245    m_acTEncTopList[iViewIdx]->setQuadtreeTUMaxDepthIntra      ( m_uiQuadtreeTUMaxDepthIntra );
246    m_acTEncTopList[iViewIdx]->setUseFastEnc                   ( m_bUseFastEnc  );
[56]247    m_acTEncTopList[iViewIdx]->setUseEarlyCU                   ( m_bUseEarlyCU  ); 
248#if FAST_DECISION_FOR_MRG_RD_COST
249    m_acTEncTopList[iViewIdx]->setUseFastDecisionForMerge      ( m_useFastDecisionForMerge  );
[5]250#endif
[56]251    m_acTEncTopList[iViewIdx]->setUseCbfFastMode               ( m_bUseCbfFastMode  );
252#if HHI_INTERVIEW_SKIP
253    m_acTEncTopList[iViewIdx]->setInterViewSkip            ( iViewIdx>0 ? m_bInterViewSkip : false );
254#if HHI_INTERVIEW_SKIP_LAMBDA_SCALE
255    m_acTEncTopList[iViewIdx]->setInterViewSkipLambdaScale ( iViewIdx>0 ? (UInt)m_dInterViewSkipLambdaScale : 1 );
[42]256#endif
[5]257#endif
[56]258    m_acTEncTopList[iViewIdx]->setUseLMChroma                  ( m_bUseLMChroma );
259    m_acTEncTopList[iViewIdx]->setUseConstrainedIntraPred      ( m_bUseConstrainedIntraPred );
260    m_acTEncTopList[iViewIdx]->setPCMLog2MinSize               ( m_uiPCMLog2MinSize);
261    m_acTEncTopList[iViewIdx]->setUsePCM                       ( m_usePCM );
262    m_acTEncTopList[iViewIdx]->setPCMLog2MaxSize               ( m_pcmLog2MaxSize);
[2]263
[56]264  //====== Weighted Prediction ========
265    m_acTEncTopList[iViewIdx]->setUseWP                        ( m_bUseWeightPred      );
266    m_acTEncTopList[iViewIdx]->setWPBiPredIdc                  ( m_uiBiPredIdc         );
267  //====== Slice ========
268    m_acTEncTopList[iViewIdx]->setSliceMode                    ( m_iSliceMode                );
269    m_acTEncTopList[iViewIdx]->setSliceArgument                ( m_iSliceArgument            );
[5]270
[56]271  //====== Entropy Slice ========
272    m_acTEncTopList[iViewIdx]->setEntropySliceMode             ( m_iEntropySliceMode         );
273    m_acTEncTopList[iViewIdx]->setEntropySliceArgument         ( m_iEntropySliceArgument     );
274    int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1);
275    if(m_iEntropySliceMode==SHARP_FIXED_NUMBER_OF_LCU_IN_ENTROPY_SLICE)
276    {
277      m_acTEncTopList[iViewIdx]->setEntropySliceArgument ( m_iEntropySliceArgument * ( iNumPartInCU >> ( m_iSliceGranularity << 1 ) ) );
278    }
279    if(m_iSliceMode==AD_HOC_SLICES_FIXED_NUMBER_OF_LCU_IN_SLICE)
280    {
281      m_acTEncTopList[iViewIdx]->setSliceArgument ( m_iSliceArgument * ( iNumPartInCU >> ( m_iSliceGranularity << 1 ) ) );
282    }
283#if FIXED_NUMBER_OF_TILES_SLICE_MODE
284    if(m_iSliceMode==AD_HOC_SLICES_FIXED_NUMBER_OF_TILES_IN_SLICE)
285    {
286      m_acTEncTopList[iViewIdx]->setSliceArgument ( m_iSliceArgument );
287    }
[2]288#endif
[56]289    m_acTEncTopList[iViewIdx]->setSliceGranularity        ( m_iSliceGranularity         );
290    if(m_iSliceMode == 0 )
291    {
292      m_bLFCrossSliceBoundaryFlag = true;
293    }
294    m_acTEncTopList[iViewIdx]->setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag );
295    m_acTEncTopList[iViewIdx]->setUseSAO               ( m_abUseSAO[0]     );
296#if SAO_UNIT_INTERLEAVING
297    m_acTEncTopList[iViewIdx]->setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic);
298    m_acTEncTopList[iViewIdx]->setSaoInterleavingFlag (m_saoInterleavingFlag);
[2]299#endif
[56]300    m_acTEncTopList[iViewIdx]->setPCMInputBitDepthFlag  ( m_bPCMInputBitDepthFlag); 
301    m_acTEncTopList[iViewIdx]->setPCMFilterDisableFlag  ( m_bPCMFilterDisableFlag); 
[2]302
[56]303    m_acTEncTopList[iViewIdx]->setPictureDigestEnabled(m_pictureDigestEnabled);
[2]304
[56]305    m_acTEncTopList[iViewIdx]->setColumnRowInfoPresent       ( m_iColumnRowInfoPresent );
306    m_acTEncTopList[iViewIdx]->setUniformSpacingIdr          ( m_iUniformSpacingIdr );
307#if !REMOVE_TILE_DEPENDENCE
308    m_acTEncTopList[iViewIdx]->setTileBoundaryIndependenceIdr( m_iTileBoundaryIndependenceIdr );
[2]309#endif
[56]310    m_acTEncTopList[iViewIdx]->setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
311    m_acTEncTopList[iViewIdx]->setNumRowsMinus1              ( m_iNumRowsMinus1 );
312    if(m_iUniformSpacingIdr==0)
313    {
314      m_acTEncTopList[iViewIdx]->setColumnWidth              ( m_pchColumnWidth );
315      m_acTEncTopList[iViewIdx]->setRowHeight                ( m_pchRowHeight );
316    }
317    m_acTEncTopList[iViewIdx]->xCheckGSParameters();
318    m_acTEncTopList[iViewIdx]->setTileLocationInSliceHeaderFlag ( m_iTileLocationInSliceHeaderFlag );
319    m_acTEncTopList[iViewIdx]->setTileMarkerFlag              ( m_iTileMarkerFlag );
320    m_acTEncTopList[iViewIdx]->setMaxTileMarkerEntryPoints    ( m_iMaxTileMarkerEntryPoints );
321 
322    Int uiTilesCount          = (m_iNumRowsMinus1+1) * (m_iNumColumnsMinus1+1);
323    m_dMaxTileMarkerOffset    = ((Double)uiTilesCount) / m_iMaxTileMarkerEntryPoints;
324    m_acTEncTopList[iViewIdx]->setMaxTileMarkerOffset         ( m_dMaxTileMarkerOffset );
325    m_acTEncTopList[iViewIdx]->setTileBehaviorControlPresentFlag( m_iTileBehaviorControlPresentFlag );
326#if !REMOVE_TILE_DEPENDENCE
327    if(m_iTileBoundaryIndependenceIdr == 0 || uiTilesCount == 1)
328#else
329    if(uiTilesCount == 1)
[2]330#endif
[56]331    {
332      m_bLFCrossTileBoundaryFlag = true; 
333    }
334    m_acTEncTopList[iViewIdx]->setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag );
335    m_acTEncTopList[iViewIdx]->setWaveFrontSynchro           ( m_iWaveFrontSynchro );
336    m_acTEncTopList[iViewIdx]->setWaveFrontFlush             ( m_iWaveFrontFlush );
337    m_acTEncTopList[iViewIdx]->setWaveFrontSubstreams        ( m_iWaveFrontSubstreams );
338    m_acTEncTopList[iViewIdx]->setEnableTMVP ( m_enableTMVP );
339    m_acTEncTopList[iViewIdx]->setUseScalingListId           ( m_useScalingListId  );
340    m_acTEncTopList[iViewIdx]->setScalingListFile            ( m_scalingListFile   );
341#if MULTIBITS_DATA_HIDING
342    m_acTEncTopList[iViewIdx]->setSignHideFlag(m_signHideFlag);
343    m_acTEncTopList[iViewIdx]->setTSIG(m_signHidingThreshold);
[2]344#endif
345
[56]346#if LCU_SYNTAX_ALF
347    if(uiTilesCount > 1)
[2]348    {
[56]349      m_bALFParamInSlice = false;
350      m_bALFPicBasedEncode = true;
[2]351    }
[56]352    m_acTEncTopList[iViewIdx]->setALFParamInSlice              ( m_bALFParamInSlice);
353    m_acTEncTopList[iViewIdx]->setALFPicBasedEncode            ( m_bALFPicBasedEncode);
[2]354#endif
[56]355
356    //====== Depth tools ========
357#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
358    m_acTEncTopList[iViewIdx]->setUseDMM                     ( false );
[2]359#endif
[5]360#if HHI_MPI
[2]361    m_acTEncTopList[iViewIdx]->setUseMVI( false );
[5]362#endif
[2]363  }
364  if( m_bUsingDepthMaps )
365  {
366    for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
367    {
[56]368      m_depthFrameRcvd.push_back(0);
369      m_acTEncDepthTopList.push_back(new TEncTop); 
[2]370      m_acTVideoIOYuvDepthInputFileList.push_back(new TVideoIOYuv);
[56]371      m_acTVideoIOYuvDepthReconFileList.push_back(new TVideoIOYuv);
372      m_picYuvDepthRec.push_back(new TComList<TComPicYuv*>) ;
[2]373
374      m_acTEncDepthTopList[iViewIdx]->setFrameRate                    ( m_iFrameRate );
375      m_acTEncDepthTopList[iViewIdx]->setFrameSkip                    ( m_FrameSkip );
376      m_acTEncDepthTopList[iViewIdx]->setSourceWidth                  ( m_iSourceWidth );
377      m_acTEncDepthTopList[iViewIdx]->setSourceHeight                 ( m_iSourceHeight );
[56]378#if PIC_CROPPING
379      m_acTEncDepthTopList[iViewIdx]->setCroppingMode                 ( m_croppingMode );
380      m_acTEncDepthTopList[iViewIdx]->setCropLeft                     ( m_cropLeft );
381      m_acTEncDepthTopList[iViewIdx]->setCropRight                    ( m_cropRight );
382      m_acTEncDepthTopList[iViewIdx]->setCropTop                      ( m_cropTop );
383      m_acTEncDepthTopList[iViewIdx]->setCropBottom                   ( m_cropBottom );
384#endif
[2]385      m_acTEncDepthTopList[iViewIdx]->setFrameToBeEncoded             ( m_iFrameToBeEncoded );
[56]386      m_acTEncDepthTopList[iViewIdx]->setViewId                       ( iViewIdx );
387      m_acTEncDepthTopList[iViewIdx]->setIsDepth                      ( true );
388      m_acTEncDepthTopList[iViewIdx]->setViewOrderIdx                 ( m_cCameraData.getViewOrderIndex()[ iViewIdx ] );
[77]389#if VIDYO_VPS_INTEGRATION
390      layerId = iViewIdx * 2 + 1;
391      m_acTEncDepthTopList[iViewIdx]->setLayerId                      ( layerId );
392      m_cVPS.setDepthFlag                                             ( true, layerId );
393      m_cVPS.setViewId                                                ( iViewIdx, layerId );
394      m_cVPS.setViewOrderIdx                                          ( m_cCameraData.getViewOrderIndex()[ iViewIdx ], layerId );
395      m_cVPS.setDependentFlag                                         ( true, layerId );
396      m_cVPS.setDependentLayer                                        ( layerId-1, layerId);
397#endif
[56]398      m_acTEncDepthTopList[iViewIdx]->setCamParPrecision              ( 0 );
399      m_acTEncDepthTopList[iViewIdx]->setCamParInSliceHeader          ( false );
400      m_acTEncDepthTopList[iViewIdx]->setCodedScale                   ( 0 );
401      m_acTEncDepthTopList[iViewIdx]->setCodedOffset                  ( 0 );
[2]402
403      //====== Coding Structure ========
[56]404      m_acTEncDepthTopList[iViewIdx]->setIntraPeriod                  ( m_iIntraPeriod );
[2]405      m_acTEncDepthTopList[iViewIdx]->setDecodingRefreshType          ( m_iDecodingRefreshType );
[56]406      m_acTEncDepthTopList[iViewIdx]->setGOPSize                      ( m_iGOPSize );
407      m_acTEncDepthTopList[iViewIdx]->setGopList                      ( m_GOPListsMvc[iViewIdx] );
408      m_acTEncDepthTopList[iViewIdx]->setExtraRPSs                    ( m_extraRPSs[iViewIdx] );
409#if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER
410      for(Int i = 0; i < MAX_TLAYER; i++)
411      {
412        m_acTEncDepthTopList[iViewIdx]->setNumReorderPics             ( m_numReorderPics[iViewIdx][i], i );
413        m_acTEncDepthTopList[iViewIdx]->setMaxDecPicBuffering         ( m_maxDecPicBuffering[iViewIdx][i], i );
414      }
415#else
416      m_acTEncDepthTopList[iViewIdx]->setNumReorderFrames             ( m_numReorderFrames );
417      m_acTEncDepthTopList[iViewIdx]->setMaxNumberOfReferencePictures ( m_maxNumberOfReferencePictures );
[2]418#endif
[56]419      for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop )
420      {
421        m_acTEncDepthTopList[iViewIdx]->setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] );
422      }
[2]423      m_acTEncDepthTopList[iViewIdx]->setQP                           ( m_aiQP[1] );
424
425      m_acTEncDepthTopList[iViewIdx]->setTemporalLayerQPOffset        ( m_aiTLayerQPOffset );
426      m_acTEncDepthTopList[iViewIdx]->setPad                          ( m_aiPad );
427
[56]428#if H0566_TLA
429      m_acTEncDepthTopList[iViewIdx]->setMaxTempLayer                 ( m_maxTempLayer[iViewIdx] );
430#else
431      m_acTEncDepthTopList[iViewIdx]->setTLayering                    ( m_bTLayering );
432      m_acTEncDepthTopList[iViewIdx]->setTLayerSwitchingFlag          ( m_abTLayerSwitchingFlag );
433#endif
434
435      m_acTEncDepthTopList[iViewIdx]->setDisInter4x4                  ( m_bDisInter4x4);
436
437      m_acTEncDepthTopList[iViewIdx]->setUseNSQT( m_enableNSQT );
438      m_acTEncDepthTopList[iViewIdx]->setUseAMP( m_enableAMP );
439
[2]440      //===== Slice ========
441
442      //====== Loop/Deblock Filter ========
443      m_acTEncDepthTopList[iViewIdx]->setLoopFilterDisable            ( m_abLoopFilterDisable[1]   );
[56]444      m_acTEncDepthTopList[iViewIdx]->setLoopFilterOffsetInAPS        ( m_loopFilterOffsetInAPS );
445      m_acTEncDepthTopList[iViewIdx]->setLoopFilterBetaOffset         ( m_loopFilterBetaOffsetDiv2  );
446      m_acTEncDepthTopList[iViewIdx]->setLoopFilterTcOffset           ( m_loopFilterTcOffsetDiv2    );
447#if DBL_CONTROL
448      m_acTEncDepthTopList[iViewIdx]->setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent);
449#endif
[2]450
451      //====== Motion search ========
452      m_acTEncDepthTopList[iViewIdx]->setFastSearch                   ( m_iFastSearch  );
453      m_acTEncDepthTopList[iViewIdx]->setSearchRange                  ( m_iSearchRange );
454      m_acTEncDepthTopList[iViewIdx]->setBipredSearchRange            ( m_bipredSearchRange );
[56]455
456      //====== Quality control ========
[2]457      m_acTEncDepthTopList[iViewIdx]->setMaxDeltaQP                   ( m_iMaxDeltaQP  );
[56]458      m_acTEncDepthTopList[iViewIdx]->setMaxCuDQPDepth                ( m_iMaxCuDQPDepth  );
[2]459
[56]460      m_acTEncDepthTopList[iViewIdx]->setChromaQpOffset               ( m_iChromaQpOffset     );
461      m_acTEncDepthTopList[iViewIdx]->setChromaQpOffset2nd            ( m_iChromaQpOffset2nd  );
462
463#if ADAPTIVE_QP_SELECTION
464      m_acTEncDepthTopList[iViewIdx]->setUseAdaptQpSelect             ( m_bUseAdaptQpSelect   );
465#endif
466
467      m_acTEncDepthTopList[iViewIdx]->setUseAdaptiveQP                ( m_bUseAdaptiveQP  );
468      m_acTEncDepthTopList[iViewIdx]->setQPAdaptationRange            ( m_iQPAdaptationRange );
469
[2]470      //====== Tool list ========
471      m_acTEncDepthTopList[iViewIdx]->setUseSBACRD                    ( m_bUseSBACRD   );
472      m_acTEncDepthTopList[iViewIdx]->setDeltaQpRD                    ( m_uiDeltaQpRD  );
473      m_acTEncDepthTopList[iViewIdx]->setUseASR                       ( m_bUseASR      );
474      m_acTEncDepthTopList[iViewIdx]->setUseHADME                     ( m_bUseHADME    );
475      m_acTEncDepthTopList[iViewIdx]->setUseALF                       ( m_abUseALF[1]  );
476      m_acTEncDepthTopList[iViewIdx]->setALFEncodePassReduction       ( m_iALFEncodePassReduction );
[56]477#if LOSSLESS_CODING
478      m_acTEncDepthTopList[iViewIdx]->setUseLossless                  ( m_useLossless );
[2]479#endif
[56]480      m_acTEncDepthTopList[iViewIdx]->setALFMaxNumberFilters          ( m_iALFMaxNumberFilters ) ;
481
[2]482      m_acTEncDepthTopList[iViewIdx]->setUseLComb                     ( m_bUseLComb    );
[56]483      m_acTEncDepthTopList[iViewIdx]->setLCMod                        ( m_bLCMod       );
484      m_acTEncDepthTopList[iViewIdx]->setdQPs                         ( m_aidQPdepth   );
[2]485      m_acTEncDepthTopList[iViewIdx]->setUseRDOQ                      ( m_abUseRDOQ[1] );
[56]486#if !PIC_CROPPING
[2]487      m_acTEncDepthTopList[iViewIdx]->setUsePAD                       ( m_bUsePAD      );
[56]488#endif
[2]489      m_acTEncDepthTopList[iViewIdx]->setQuadtreeTULog2MaxSize        ( m_uiQuadtreeTULog2MaxSize );
490      m_acTEncDepthTopList[iViewIdx]->setQuadtreeTULog2MinSize        ( m_uiQuadtreeTULog2MinSize );
491      m_acTEncDepthTopList[iViewIdx]->setQuadtreeTUMaxDepthInter      ( m_uiQuadtreeTUMaxDepthInter );
492      m_acTEncDepthTopList[iViewIdx]->setQuadtreeTUMaxDepthIntra      ( m_uiQuadtreeTUMaxDepthIntra );
493      m_acTEncDepthTopList[iViewIdx]->setUseFastEnc                   ( m_bUseFastEnc  );
[56]494      m_acTEncDepthTopList[iViewIdx]->setUseEarlyCU                   ( m_bUseEarlyCU  ); 
495#if FAST_DECISION_FOR_MRG_RD_COST
496      m_acTEncDepthTopList[iViewIdx]->setUseFastDecisionForMerge      ( m_useFastDecisionForMerge  );
497#endif
498      m_acTEncDepthTopList[iViewIdx]->setUseCbfFastMode               ( m_bUseCbfFastMode  );
499#if HHI_INTERVIEW_SKIP
500      m_acTEncDepthTopList[iViewIdx]->setInterViewSkip            ( 0 );
501#if HHI_INTERVIEW_SKIP_LAMBDA_SCALE
502      m_acTEncDepthTopList[iViewIdx]->setInterViewSkipLambdaScale ( 1 );
503#endif
504#endif
505      m_acTEncDepthTopList[iViewIdx]->setUseLMChroma                  ( m_bUseLMChroma );
506      m_acTEncDepthTopList[iViewIdx]->setUseConstrainedIntraPred      ( m_bUseConstrainedIntraPred );
507      m_acTEncDepthTopList[iViewIdx]->setPCMLog2MinSize               ( m_uiPCMLog2MinSize);
508      m_acTEncDepthTopList[iViewIdx]->setUsePCM                       ( m_usePCM );
509      m_acTEncDepthTopList[iViewIdx]->setPCMLog2MaxSize               ( m_pcmLog2MaxSize);
510      //====== VSO ========
[5]511#if HHI_VSO
[2]512      m_acTEncDepthTopList[iViewIdx]->setUseVSO                       ( m_bUseVSO      ); //GT: might be enabled/disabled later for VSO Mode 4
513      m_acTEncDepthTopList[iViewIdx]->setForceLambdaScaleVSO          ( m_bForceLambdaScaleVSO );
514      m_acTEncDepthTopList[iViewIdx]->setLambdaScaleVSO               ( m_dLambdaScaleVSO );
[5]515#if HHI_VSO_DIST_INT
[2]516      m_acTEncDepthTopList[iViewIdx]->setAllowNegDist                 ( m_bAllowNegDist );
517#endif
518      m_acTEncDepthTopList[iViewIdx]->setVSOMode                      ( m_uiVSOMode );
[5]519#endif
[2]520
[5]521#if DEPTH_MAP_GENERATION
[2]522      m_acTEncDepthTopList[iViewIdx]->setPredDepthMapGeneration       ( 0 );
[5]523#endif
524#if HHI_INTER_VIEW_MOTION_PRED
[2]525      m_acTEncDepthTopList[iViewIdx]->setMultiviewMvPredMode          ( 0 );
526      m_acTEncDepthTopList[iViewIdx]->setMultiviewMvRegMode           ( 0 );
527      m_acTEncDepthTopList[iViewIdx]->setMultiviewMvRegLambdaScale    ( 0.0 );
[5]528#endif
529#if HHI_INTER_VIEW_RESIDUAL_PRED
[2]530      m_acTEncDepthTopList[iViewIdx]->setMultiviewResPredMode         ( 0 );
[5]531#endif
[2]532
[56]533      //====== Weighted Prediction ========
534      m_acTEncDepthTopList[iViewIdx]->setUseWP                        ( m_bUseWeightPred      );
535      m_acTEncDepthTopList[iViewIdx]->setWPBiPredIdc                  ( m_uiBiPredIdc         );
536      //====== Slice ========
537      m_acTEncDepthTopList[iViewIdx]->setSliceMode                    ( m_iSliceMode                );
538      m_acTEncDepthTopList[iViewIdx]->setSliceArgument                ( m_iSliceArgument            );
539
540      //====== Entropy Slice ========
541      m_acTEncDepthTopList[iViewIdx]->setEntropySliceMode             ( m_iEntropySliceMode         );
542      m_acTEncDepthTopList[iViewIdx]->setEntropySliceArgument         ( m_iEntropySliceArgument     );
543      int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1);
544      if(m_iEntropySliceMode==SHARP_FIXED_NUMBER_OF_LCU_IN_ENTROPY_SLICE)
545      {
546        m_acTEncDepthTopList[iViewIdx]->setEntropySliceArgument ( m_iEntropySliceArgument * ( iNumPartInCU >> ( m_iSliceGranularity << 1 ) ) );
547      }
548      if(m_iSliceMode==AD_HOC_SLICES_FIXED_NUMBER_OF_LCU_IN_SLICE)
549      {
550        m_acTEncDepthTopList[iViewIdx]->setSliceArgument ( m_iSliceArgument * ( iNumPartInCU >> ( m_iSliceGranularity << 1 ) ) );
551      }
552#if FIXED_NUMBER_OF_TILES_SLICE_MODE
553      if(m_iSliceMode==AD_HOC_SLICES_FIXED_NUMBER_OF_TILES_IN_SLICE)
554      {
555        m_acTEncDepthTopList[iViewIdx]->setSliceArgument ( m_iSliceArgument );
556      }
[2]557#endif
[56]558      m_acTEncDepthTopList[iViewIdx]->setSliceGranularity        ( m_iSliceGranularity         );
559      if(m_iSliceMode == 0 )
560      {
561        m_bLFCrossSliceBoundaryFlag = true;
562      }
563      m_acTEncDepthTopList[iViewIdx]->setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag );
564      m_acTEncDepthTopList[iViewIdx]->setUseSAO               ( m_abUseSAO[1]     );
565#if SAO_UNIT_INTERLEAVING
566      m_acTEncDepthTopList[iViewIdx]->setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic);
567      m_acTEncDepthTopList[iViewIdx]->setSaoInterleavingFlag (m_saoInterleavingFlag);
[2]568#endif
[56]569      m_acTEncDepthTopList[iViewIdx]->setPCMInputBitDepthFlag  ( m_bPCMInputBitDepthFlag); 
570      m_acTEncDepthTopList[iViewIdx]->setPCMFilterDisableFlag  ( m_bPCMFilterDisableFlag); 
[2]571
[56]572      m_acTEncDepthTopList[iViewIdx]->setPictureDigestEnabled(m_pictureDigestEnabled);
573
574      m_acTEncDepthTopList[iViewIdx]->setColumnRowInfoPresent       ( m_iColumnRowInfoPresent );
575      m_acTEncDepthTopList[iViewIdx]->setUniformSpacingIdr          ( m_iUniformSpacingIdr );
576#if !REMOVE_TILE_DEPENDENCE
577      m_acTEncDepthTopList[iViewIdx]->setTileBoundaryIndependenceIdr( m_iTileBoundaryIndependenceIdr );
[2]578#endif
[56]579      m_acTEncDepthTopList[iViewIdx]->setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
580      m_acTEncDepthTopList[iViewIdx]->setNumRowsMinus1              ( m_iNumRowsMinus1 );
581      if(m_iUniformSpacingIdr==0)
582      {
583        m_acTEncDepthTopList[iViewIdx]->setColumnWidth              ( m_pchColumnWidth );
584        m_acTEncDepthTopList[iViewIdx]->setRowHeight                ( m_pchRowHeight );
585      }
586      m_acTEncDepthTopList[iViewIdx]->xCheckGSParameters();
587      m_acTEncDepthTopList[iViewIdx]->setTileLocationInSliceHeaderFlag ( m_iTileLocationInSliceHeaderFlag );
588      m_acTEncDepthTopList[iViewIdx]->setTileMarkerFlag              ( m_iTileMarkerFlag );
589      m_acTEncDepthTopList[iViewIdx]->setMaxTileMarkerEntryPoints    ( m_iMaxTileMarkerEntryPoints );
[2]590
[56]591      Int uiTilesCount          = (m_iNumRowsMinus1+1) * (m_iNumColumnsMinus1+1);
592      m_dMaxTileMarkerOffset    = ((Double)uiTilesCount) / m_iMaxTileMarkerEntryPoints;
593      m_acTEncDepthTopList[iViewIdx]->setMaxTileMarkerOffset         ( m_dMaxTileMarkerOffset );
594      m_acTEncDepthTopList[iViewIdx]->setTileBehaviorControlPresentFlag( m_iTileBehaviorControlPresentFlag );
595#if !REMOVE_TILE_DEPENDENCE
596      if(m_iTileBoundaryIndependenceIdr == 0 || uiTilesCount == 1)
597#else
598      if(uiTilesCount == 1)
[2]599#endif
[56]600      {
601        m_bLFCrossTileBoundaryFlag = true; 
602      }
603      m_acTEncDepthTopList[iViewIdx]->setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag );
604      m_acTEncDepthTopList[iViewIdx]->setWaveFrontSynchro           ( m_iWaveFrontSynchro );
605      m_acTEncDepthTopList[iViewIdx]->setWaveFrontFlush             ( m_iWaveFrontFlush );
606      m_acTEncDepthTopList[iViewIdx]->setWaveFrontSubstreams        ( m_iWaveFrontSubstreams );
607      m_acTEncDepthTopList[iViewIdx]->setEnableTMVP ( m_enableTMVP );
608      m_acTEncDepthTopList[iViewIdx]->setUseScalingListId           ( m_useScalingListId  );
609      m_acTEncDepthTopList[iViewIdx]->setScalingListFile            ( m_scalingListFile   );
610#if MULTIBITS_DATA_HIDING
611      m_acTEncDepthTopList[iViewIdx]->setSignHideFlag(m_signHideFlag);
612      m_acTEncDepthTopList[iViewIdx]->setTSIG(m_signHidingThreshold);
[2]613#endif
614
[56]615#if LCU_SYNTAX_ALF
616      if(uiTilesCount > 1)
[2]617      {
[56]618        m_bALFParamInSlice = false;
619        m_bALFPicBasedEncode = true;
[2]620      }
[56]621      m_acTEncDepthTopList[iViewIdx]->setALFParamInSlice              ( m_bALFParamInSlice);
622      m_acTEncDepthTopList[iViewIdx]->setALFPicBasedEncode            ( m_bALFPicBasedEncode);
[2]623#endif
[56]624
625  //====== Depth tools ========
626#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
627    m_acTEncDepthTopList[iViewIdx]->setUseDMM                     ( m_bUseDMM );
[2]628#endif
[5]629#if HHI_MPI
[56]630     m_acTEncDepthTopList[iViewIdx]->setUseMVI( m_bUseMVI );
[5]631#endif
[2]632    }
633  }
[56]634
[5]635#if HHI_INTER_VIEW_MOTION_PRED
[2]636  else if( m_uiMultiviewMvRegMode )
637  {
638    for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
639    {
640      m_acTVideoIOYuvDepthInputFileList.push_back( new TVideoIOYuv );
641    }
642  }
[5]643#endif
[2]644
[5]645#if HHI_VSO
[2]646  if ( m_bUseVSO )
647  {
648    if ( m_uiVSOMode == 4 )
[5]649    {
[2]650      m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, m_iSourceHeight, LOG2_DISP_PREC_LUT, 0 );
651
652      for ( Int iViewNum = 0; iViewNum < m_iNumberOfViews; iViewNum++ )
653      {
654        for (Int iContent = 0; iContent < 2; iContent++ )
655        {
[5]656          Int iNumOfModels   = m_cRenModStrParser.getNumOfModelsForView(iViewNum, iContent);
657          Bool bUseVSO = (iNumOfModels != 0);
[2]658
[5]659          TEncTop* pcEncTop = ( iContent == 0 ) ? m_acTEncTopList[iViewNum] : m_acTEncDepthTopList[iViewNum];
660          pcEncTop->setUseVSO( bUseVSO );
661          pcEncTop->getRdCost()->setRenModel( bUseVSO ? &m_cRendererModel : NULL );
662
[2]663          for (Int iCurModel = 0; iCurModel < iNumOfModels; iCurModel++ )
664          {
[5]665            Int iModelNum; Int iLeftViewNum; Int iRightViewNum; Int iDump; Int iOrgRefNum; Int iBlendMode;
[2]666
[5]667            m_cRenModStrParser.getSingleModelData  ( iViewNum, iContent, iCurModel, iModelNum, iBlendMode, iLeftViewNum, iRightViewNum, iOrgRefNum, iDump ) ;
668            m_cRendererModel  .createSingleModel   ( iViewNum, iContent, iModelNum, iLeftViewNum, iRightViewNum, (iOrgRefNum != -1), iBlendMode );
[2]669          }
670        }
671      }
672    }
673    else
674    {
[56]675      AOT(true);
[2]676    }
[5]677  }
678#endif
[2]679
[5]680#if HHI_INTERVIEW_SKIP
681  m_cUsedPelsRenderer.init(m_iSourceWidth, m_iSourceHeight, true, 0, LOG2_DISP_PREC_LUT, true, 0, 0, 0, 0, 0, 6, 4, 1, 0, 6 );
682#endif
[56]683
[2]684}
685
686Void TAppEncTop::xCreateLib()
687{
688  for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
689  {
690    m_acTVideoIOYuvInputFileList[iViewIdx]->open( m_pchInputFileList[iViewIdx],     false, m_uiInputBitDepth, m_uiInternalBitDepth );  // read  mode
[56]691    m_acTVideoIOYuvInputFileList[iViewIdx]->skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]);
[2]692
[56]693    if (m_pchReconFileList[iViewIdx])
694      m_acTVideoIOYuvReconFileList[iViewIdx]->open(m_pchReconFileList[iViewIdx], true, m_uiOutputBitDepth, m_uiInternalBitDepth);  // write mode
[2]695    m_acTEncTopList[iViewIdx]->create();
696    if( m_bUsingDepthMaps )
697    {
698      m_acTVideoIOYuvDepthInputFileList[iViewIdx]->open( m_pchDepthInputFileList[iViewIdx],     false, m_uiInputBitDepth, m_uiInternalBitDepth );  // read  mode
[56]699      m_acTVideoIOYuvDepthInputFileList[iViewIdx]->skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]);
[2]700
[56]701      if (m_pchDepthReconFileList[iViewIdx])
702        m_acTVideoIOYuvDepthReconFileList[iViewIdx]->open(m_pchDepthReconFileList[iViewIdx], true, m_uiOutputBitDepth, m_uiInternalBitDepth);  // write mode
[2]703      m_acTEncDepthTopList[iViewIdx]->create();
704    }
[5]705#if HHI_INTER_VIEW_MOTION_PRED
[2]706    else if( m_uiMultiviewMvRegMode )
707    {
708      m_acTVideoIOYuvDepthInputFileList[iViewIdx]->open( m_pchDepthInputFileList[iViewIdx],     false, m_uiInputBitDepth, m_uiInternalBitDepth );  // read  mode
709      m_acTVideoIOYuvDepthInputFileList[iViewIdx]->skipFrames(m_FrameSkip, m_iSourceWidth, m_iSourceHeight);
710    }
[5]711#endif
[2]712  }
713}
714
715Void TAppEncTop::xDestroyLib()
716{
[56]717  // Video I/O
[2]718  for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
719  {
720    m_acTVideoIOYuvInputFileList[iViewIdx]->close();
721    m_acTVideoIOYuvReconFileList[iViewIdx]->close();
[56]722    delete m_acTVideoIOYuvInputFileList[iViewIdx] ; 
723    m_acTVideoIOYuvInputFileList[iViewIdx] = NULL;
724    delete m_acTVideoIOYuvReconFileList[iViewIdx] ; 
725    m_acTVideoIOYuvReconFileList[iViewIdx] = NULL;
726    m_acTEncTopList[iViewIdx]->deletePicBuffer();
[2]727    m_acTEncTopList[iViewIdx]->destroy();
[56]728    delete m_acTEncTopList[iViewIdx] ; 
729    m_acTEncTopList[iViewIdx] = NULL;
730    delete m_picYuvRec[iViewIdx] ; 
731    m_picYuvRec[iViewIdx] = NULL;
[2]732
733    if( iViewIdx < Int( m_acTVideoIOYuvDepthInputFileList.size() ) && m_acTVideoIOYuvDepthInputFileList[iViewIdx] )
734    {
735      m_acTVideoIOYuvDepthInputFileList[iViewIdx]->close( );
[56]736      delete m_acTVideoIOYuvDepthInputFileList[iViewIdx];
737      m_acTVideoIOYuvDepthInputFileList[iViewIdx] = NULL;
[2]738    }
739    if( iViewIdx < Int( m_acTVideoIOYuvDepthReconFileList.size() ) && m_acTVideoIOYuvDepthReconFileList[iViewIdx] )
740    {
741      m_acTVideoIOYuvDepthReconFileList[iViewIdx]->close () ;
742      delete m_acTVideoIOYuvDepthReconFileList[iViewIdx];
[56]743      m_acTVideoIOYuvDepthReconFileList[iViewIdx] = NULL;
[2]744    }
745    if( iViewIdx < Int( m_acTEncDepthTopList.size() ) && m_acTEncDepthTopList[iViewIdx] )
746    {
[56]747      m_acTEncDepthTopList[iViewIdx]->deletePicBuffer();
[2]748      m_acTEncDepthTopList[iViewIdx]->destroy();
749      delete m_acTEncDepthTopList[iViewIdx];
[56]750      m_acTEncDepthTopList[iViewIdx] = NULL;
[2]751    }
[56]752    if( iViewIdx < Int( m_picYuvDepthRec.size() ) && m_picYuvDepthRec[iViewIdx] )
[2]753    {
[56]754      delete m_picYuvDepthRec[iViewIdx] ; 
755      m_picYuvDepthRec[iViewIdx] = NULL;
[2]756    }
757  }
758}
759
760Void TAppEncTop::xInitLib()
761{
762  for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
763  {
764    m_acTEncTopList[iViewIdx]->init( this );
765  }
766  for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
767  {
768    m_acTEncTopList[iViewIdx]->setTEncTopList( &m_acTEncTopList  );
769  }
770  if ( m_bUsingDepthMaps )
771  {
772    for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
773    {
774      m_acTEncDepthTopList[iViewIdx]->init( this );
775    }
776    for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
777    {
778      m_acTEncDepthTopList[iViewIdx]->setTEncTopList( &m_acTEncDepthTopList  );
779    }
780  }
781}
782
783// ====================================================================================================================
784// Public member functions
785// ====================================================================================================================
786
787/**
788 - create internal class
789 - initialize internal variable
790 - until the end of input YUV file, call encoding function in TEncTop class
791 - delete allocated buffers
792 - destroy internal class
793 .
794 */
795Void TAppEncTop::encode()
796{
[56]797  fstream bitstreamFile(m_pchBitstreamFile, fstream::binary | fstream::out);
798  if (!bitstreamFile)
799  {
800    fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pchBitstreamFile);
801    exit(EXIT_FAILURE);
802  }
803
804  TComPicYuv*       pcPicYuvOrg = new TComPicYuv;
[2]805  TComPicYuv*       pcDepthPicYuvOrg = new TComPicYuv;
806  TComPicYuv*       pcPdmDepthOrg    = new TComPicYuv;
[56]807  TComPicYuv*       pcPicYuvRec = NULL;
808  TComPicYuv*       pcDepthPicYuvRec = NULL;
809 
[2]810  // initialize internal class & member variables
811  xInitLibCfg();
812  xCreateLib();
813  xInitLib();
[56]814 
[2]815  // main encoder loop
[56]816  Bool  allEos = false;
817  std::vector<Bool>  eos ;
818  std::vector<Bool>  depthEos ;
819  Int maxGopSize = 0;
820  Int gopSize = 1;
821 
822  list<AccessUnit> outputAccessUnits; ///< list of access units to write out.  is populated by the encoding process
823  maxGopSize = (std::max)(maxGopSize, m_acTEncTopList[0]->getGOPSize());   
[2]824
825  for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
826  {
[56]827    eos.push_back( false );
828    depthEos.push_back( false );
[2]829  }
[56]830
[2]831  // allocate original YUV buffer
832  pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
[56]833  pcDepthPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
834
[5]835#if HHI_INTER_VIEW_MOTION_PRED
[2]836  if( m_uiMultiviewMvRegMode )
837  {
838    pcPdmDepthOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
839  }
[5]840#endif
[2]841
[56]842  while ( !allEos )
[2]843  {
[56]844    for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
[2]845    {
[56]846      Int frmCnt = 0;
847      while ( !eos[iViewIdx] && !(frmCnt == gopSize))
[2]848      {
849        // get buffers
[56]850        xGetBuffer(pcPicYuvRec, iViewIdx, false);
851
[2]852        // read input YUV file
[56]853        m_acTVideoIOYuvInputFileList[iViewIdx]->read( pcPicYuvOrg, m_aiPad );
854     
[5]855#if HHI_INTER_VIEW_MOTION_PRED
[2]856        if( m_uiMultiviewMvRegMode && iViewIdx )
857        {
858          m_acTVideoIOYuvDepthInputFileList[iViewIdx]->read( pcPdmDepthOrg, m_aiPad, m_bUsingDepthMaps );
859        }
[5]860#endif
[2]861
[5]862#if HHI_INTER_VIEW_MOTION_PRED
[56]863        m_acTEncTopList[iViewIdx]->initNewPic( pcPicYuvOrg, ( m_uiMultiviewMvRegMode && iViewIdx ? pcPdmDepthOrg : 0 ) );
[5]864#else
[56]865        m_acTEncTopList[iViewIdx]->initNewPic( pcPicYuvOrg );
[5]866#endif
[2]867
[56]868        // increase number of received frames
869        m_frameRcvd[iViewIdx]++;
870        frmCnt++;
871        // check end of file
872        eos[iViewIdx] = ( m_acTVideoIOYuvInputFileList[iViewIdx]->isEof() == 1 ?   true : false  );
873        eos[iViewIdx] = ( m_frameRcvd[iViewIdx] == m_iFrameToBeEncoded ?    true : eos[iViewIdx]   );
874        allEos = allEos|eos[iViewIdx] ; 
875      }
[2]876      if( m_bUsingDepthMaps )
877      {
[56]878        Int frmCntDepth = 0;
879        while ( !depthEos[iViewIdx] && !(frmCntDepth == gopSize))
[2]880        {
881          // get buffers
[56]882          xGetBuffer(pcDepthPicYuvRec, iViewIdx, true);
883
[2]884          // read input YUV file
[56]885          m_acTVideoIOYuvDepthInputFileList[iViewIdx]->read( pcDepthPicYuvOrg, m_aiPad );
[2]886
[56]887          m_acTEncDepthTopList[iViewIdx]->initNewPic( pcDepthPicYuvOrg );
[2]888
[56]889          // increase number of received frames
890          m_depthFrameRcvd[iViewIdx]++;
891          frmCntDepth++;
892          // check end of file
893          depthEos[iViewIdx] = ( m_acTVideoIOYuvDepthInputFileList[iViewIdx]->isEof() == 1 ?   true : false  );
894          depthEos[iViewIdx] = ( m_depthFrameRcvd[iViewIdx] == m_iFrameToBeEncoded ?    true : depthEos[iViewIdx]   );
895          allEos = allEos|depthEos[iViewIdx] ; 
[42]896        }
897      }
898    }
[56]899    for ( Int gopId=0; gopId < gopSize; gopId++ )
[42]900    {
[56]901      Int  iNumEncoded = 0;
902      UInt iNextPoc = m_acTEncTopList[0] -> getFrameId( gopId );
903      if ( iNextPoc < m_iFrameToBeEncoded )
[2]904      {
[56]905      m_cCameraData.update( iNextPoc );
[2]906      }
[56]907      for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
[2]908      {
[56]909        iNumEncoded = 0;
910        // call encoding function for one frame
911        m_acTEncTopList[iViewIdx]->encode( eos[iViewIdx], pcPicYuvOrg, *m_picYuvRec[iViewIdx], outputAccessUnits, iNumEncoded, gopId );
912        xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits, iViewIdx, false);
913        outputAccessUnits.clear();
914        if( m_bUsingDepthMaps )
[2]915        {
[56]916          Int  iNumDepthEncoded = 0;
917          // call encoding function for one depth frame
918          m_acTEncDepthTopList[iViewIdx]->encode( depthEos[iViewIdx], pcDepthPicYuvOrg, *m_picYuvDepthRec[iViewIdx], outputAccessUnits, iNumDepthEncoded, gopId );
919          xWriteOutput(bitstreamFile, iNumDepthEncoded, outputAccessUnits, iViewIdx, true);
920          outputAccessUnits.clear();
[2]921        }
922      }
[56]923#if HHI_INTERVIEW_SKIP || HHI_INTER_VIEW_MOTION_PRED || HHI_INTER_VIEW_RESIDUAL_PRED
[2]924      for( Int iViewIdx = 0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
925      {
926        if( iViewIdx < (Int)m_acTEncTopList.size() && m_acTEncTopList[iViewIdx] )
927        {
[56]928          m_acTEncTopList[iViewIdx]->deleteExtraPicBuffers( m_acTEncTopList[iViewIdx]->getGOPEncoder()->getPocLastCoded() );
[2]929        }
930        if( iViewIdx < (Int)m_acTEncDepthTopList.size() && m_acTEncDepthTopList[iViewIdx] )
931        {
[56]932          m_acTEncDepthTopList[iViewIdx]->deleteExtraPicBuffers( m_acTEncTopList[iViewIdx]->getGOPEncoder()->getPocLastCoded() );
[2]933        }
934      }
[56]935#endif
936      for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
[2]937      {
[56]938        m_acTEncTopList[iViewIdx]->compressMotion( m_acTEncTopList[iViewIdx]->getGOPEncoder()->getPocLastCoded() );
939        if( m_bUsingDepthMaps )
[2]940        {
[56]941          m_acTEncDepthTopList[iViewIdx]->compressMotion( m_acTEncDepthTopList[iViewIdx]->getGOPEncoder()->getPocLastCoded() );
[2]942        }
943      }
944    }
[56]945    gopSize = maxGopSize;
[2]946  }
[56]947  // delete original YUV buffer
948  pcPicYuvOrg->destroy();
949  delete pcPicYuvOrg;
950  pcPicYuvOrg = NULL;
951  pcDepthPicYuvOrg->destroy();
952  delete pcDepthPicYuvOrg;
953  pcDepthPicYuvOrg = NULL;
954 
[2]955  for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
956  {
957    m_acTEncTopList[iViewIdx]->printOutSummary(m_acTEncTopList[iViewIdx]->getNumAllPicCoded());
958    if ( m_bUsingDepthMaps )
959    {
960      m_acTEncDepthTopList[iViewIdx]->printOutSummary(m_acTEncDepthTopList[iViewIdx]->getNumAllPicCoded());
961    }
962  }
963
[56]964  // delete buffers & classes
965  xDeleteBuffer();
966  xDestroyLib();
[2]967
[56]968  return;
969}
[2]970
[56]971TEncTop*  TAppEncTop::getTEncTop( Int viewId, Bool isDepth )   
972{ 
973  if ( isDepth ) 
[2]974  {
[56]975    return m_acTEncDepthTopList[viewId]; 
976  } 
977  else
978  { 
979    return m_acTEncTopList[viewId]; 
980  } 
981}
[2]982
983
984// ====================================================================================================================
985// Protected member functions
986// ====================================================================================================================
987
988/**
989 - application has picture buffer list with size of GOP
990 - picture buffer list acts as ring buffer
991 - end of the list has the latest picture
992 .
993 */
[56]994Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, Int iViewIdx, Bool isDepth)
[2]995{
[56]996  assert( m_iGOPSize > 0 );
997 
998  if( !isDepth )
999  {
1000    if ( m_picYuvRec[iViewIdx]->size() == (UInt)m_iGOPSize )
[2]1001    {
[56]1002      rpcPicYuvRec = m_picYuvRec[iViewIdx]->popFront();
[2]1003    }
[56]1004    else
[2]1005    {
[56]1006      rpcPicYuvRec = new TComPicYuv; 
1007      rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
[2]1008    }
[56]1009    m_picYuvRec[iViewIdx]->pushBack( rpcPicYuvRec );
1010  }
1011  else
1012  {
1013    if ( m_picYuvDepthRec[iViewIdx]->size() == (UInt)m_iGOPSize )
1014    {
1015      rpcPicYuvRec = m_picYuvDepthRec[iViewIdx]->popFront();
1016    }
[2]1017    else
1018    {
[56]1019      rpcPicYuvRec = new TComPicYuv; 
[2]1020      rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
1021    }
[56]1022    m_picYuvDepthRec[iViewIdx]->pushBack( rpcPicYuvRec );
1023  }
[2]1024}
1025
1026Void TAppEncTop::xDeleteBuffer( )
1027{
[56]1028  for(Int iViewIdx=0; iViewIdx<m_picYuvRec.size(); iViewIdx++)
[2]1029  {
[56]1030    if(m_picYuvRec[iViewIdx])
[2]1031    {
[56]1032      TComList<TComPicYuv*>::iterator iterPicYuvRec  = m_picYuvRec[iViewIdx]->begin();
1033      Int iSize = Int( m_picYuvRec[iViewIdx]->size() );
[2]1034      for ( Int i = 0; i < iSize; i++ )
1035      {
[56]1036        TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
1037        if(pcPicYuvRec)
1038        {
[2]1039          pcPicYuvRec->destroy();
[56]1040          delete pcPicYuvRec; 
1041          pcPicYuvRec = NULL;
1042        }
[2]1043      }
[56]1044    } 
[2]1045  }
[56]1046  for(Int iViewIdx=0; iViewIdx<m_picYuvDepthRec.size(); iViewIdx++)
[2]1047  {
[56]1048    if(m_picYuvDepthRec[iViewIdx])
[2]1049    {
[56]1050      TComList<TComPicYuv*>::iterator iterPicYuvRec  = m_picYuvDepthRec[iViewIdx]->begin();
1051      Int iSize = Int( m_picYuvDepthRec[iViewIdx]->size() );
1052      for ( Int i = 0; i < iSize; i++ )
[2]1053      {
[56]1054        TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
1055        if(pcPicYuvRec)
1056        {
1057          pcPicYuvRec->destroy();
1058          delete pcPicYuvRec; 
1059          pcPicYuvRec = NULL;
1060        }
1061      } 
[2]1062    }
1063  }
1064}
1065
1066/** \param iNumEncoded  number of encoded frames
1067 */
[56]1068Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, std::list<AccessUnit>& accessUnits, Int iViewIdx, Bool isDepth )
[2]1069{
[56]1070  Int i;
1071 
1072  if( iNumEncoded > 0 )
[2]1073  {
[56]1074    TComList<TComPicYuv*>::iterator iterPicYuvRec = !isDepth ? m_picYuvRec[iViewIdx]->end() : m_picYuvDepthRec[iViewIdx]->end();
1075 
1076    for ( i = 0; i < iNumEncoded; i++ )
1077    {
1078      --iterPicYuvRec;
1079    }
1080 
1081    for ( i = 0; i < iNumEncoded; i++ )
1082    {
1083      TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
1084      if( !isDepth )
1085      {
1086        if (m_pchReconFileList[iViewIdx])
1087        {
1088#if PIC_CROPPING
1089          m_acTVideoIOYuvReconFileList[iViewIdx]->write( pcPicYuvRec, m_cropLeft, m_cropRight, m_cropTop, m_cropBottom );
1090#else
1091          m_acTVideoIOYuvReconFileList[iViewIdx]->write( pcPicYuvRec, m_aiPad );
1092#endif
1093        }
1094      }
1095      else
1096      {
1097        if (m_pchDepthReconFileList[iViewIdx])
1098        {
1099#if PIC_CROPPING
1100          m_acTVideoIOYuvDepthReconFileList[iViewIdx]->write( pcPicYuvRec, m_cropLeft, m_cropRight, m_cropTop, m_cropBottom );
1101#else
1102          m_acTVideoIOYuvDepthReconFileList[iViewIdx]->write( pcPicYuvRec, m_aiPad );
1103#endif
1104        }
1105      }
1106    }
[2]1107  }
[56]1108  if( ! accessUnits.empty() )
[2]1109  {
[56]1110    list<AccessUnit>::iterator aUIter;
1111    for( aUIter = accessUnits.begin(); aUIter != accessUnits.end(); aUIter++ )
[2]1112    {
[56]1113      const vector<unsigned>& stats = writeAnnexB(bitstreamFile, *aUIter);
1114      rateStatsAccum(*aUIter, stats);
[2]1115    }
1116  }
[56]1117}
[2]1118
1119
1120TComPicYuv* TAppEncTop::xGetPicYuvFromView( Int iViewIdx, Int iPoc, Bool bDepth, Bool bRecon )
1121{
[5]1122  TComPic*    pcPic = xGetPicFromView( iViewIdx, iPoc, bDepth);
1123  TComPicYuv* pcPicYuv = NULL;
[2]1124
1125  if (pcPic != NULL)
1126  {
1127    if( bRecon )
1128    {
1129      if ( pcPic->getReconMark() )
1130      {
[5]1131        pcPicYuv = pcPic->getPicYuvRec();
[2]1132      }
1133    }
1134    else
1135    {
[5]1136      pcPicYuv = pcPic->getPicYuvOrg();
1137    }
[2]1138  };
1139
[5]1140  return pcPicYuv;
1141};
[2]1142
[56]1143/**
1144 *
1145 */
1146void TAppEncTop::rateStatsAccum(const AccessUnit& au, const std::vector<unsigned>& annexBsizes)
[2]1147{
[56]1148  AccessUnit::const_iterator it_au = au.begin();
1149  vector<unsigned>::const_iterator it_stats = annexBsizes.begin();
[2]1150
[56]1151  for (; it_au != au.end(); it_au++, it_stats++)
[2]1152  {
[56]1153    switch ((*it_au)->m_nalUnitType)
[2]1154    {
[56]1155    case NAL_UNIT_CODED_SLICE:
1156#if H0566_TLA
1157    case NAL_UNIT_CODED_SLICE_IDV:
1158    case NAL_UNIT_CODED_SLICE_TLA:
1159    case NAL_UNIT_CODED_SLICE_CRA:
1160#else
1161    case NAL_UNIT_CODED_SLICE_DATAPART_A:
1162    case NAL_UNIT_CODED_SLICE_DATAPART_B:
1163    case NAL_UNIT_CODED_SLICE_CDR:
1164#endif
1165    case NAL_UNIT_CODED_SLICE_IDR:
1166    case NAL_UNIT_SPS:
1167    case NAL_UNIT_PPS:
[77]1168#if VIDYO_VPS_INTEGRATION
1169    case NAL_UNIT_VPS:
1170#endif
[56]1171      m_essentialBytes += *it_stats;
1172      break;
1173    default:
1174      break;
[2]1175    }
1176
[56]1177    m_totalBytes += *it_stats;
[2]1178  }
1179}
1180
[5]1181#if HHI_INTERVIEW_SKIP
[2]1182Void TAppEncTop::getUsedPelsMap( Int iViewIdx, Int iPoc, TComPicYuv* pcPicYuvUsedSplsMap )
1183{
[5]1184  AOT( iViewIdx <= 0);
1185  AOT( iViewIdx >= m_iNumberOfViews );
1186  AOF( m_cCameraData.getCurFrameId() == iPoc );
1187  Int iViewSIdx      = m_cCameraData.getBaseId2SortedId()[iViewIdx];
1188  Int iFirstViewSIdx = m_cCameraData.getBaseId2SortedId()[0];
[2]1189
1190  AOT( iViewSIdx == iFirstViewSIdx );
1191
[5]1192  Bool bFirstIsLeft = (iFirstViewSIdx < iViewSIdx);
[2]1193
[56]1194  m_cUsedPelsRenderer.setShiftLUTs(
[2]1195      m_cCameraData.getBaseViewShiftLUTD()[0][iViewIdx],
1196      m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx],
1197      m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx],
1198      m_cCameraData.getBaseViewShiftLUTD()[0][iViewIdx],
1199      m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx],
1200      m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx],
1201      -1
[5]1202      );
[2]1203
1204  TComPicYuv* pcPicYuvDepth = xGetPicYuvFromView(0, iPoc, true, true );
[5]1205  AOF( pcPicYuvDepth);
[2]1206
[5]1207  m_cUsedPelsRenderer.getUsedSamplesMap( pcPicYuvDepth, pcPicYuvUsedSplsMap, bFirstIsLeft );
[2]1208}
[5]1209#endif
1210#if HHI_VSO
[2]1211Void TAppEncTop::setupRenModel( Int iPoc, Int iEncViewIdx, Int iEncContent )
1212{
[5]1213  Int iEncViewSIdx = m_cCameraData.getBaseId2SortedId()[ iEncViewIdx ];
[2]1214
1215  // setup base views
[5]1216  Int iNumOfBV = m_cRenModStrParser.getNumOfBaseViewsForView( iEncViewSIdx, iEncContent );
[2]1217
1218  for (Int iCurView = 0; iCurView < iNumOfBV; iCurView++ )
[5]1219  {
1220    Int iBaseViewSIdx;
1221    Int iVideoDistMode;
1222    Int iDepthDistMode;
[2]1223
[5]1224    m_cRenModStrParser.getBaseViewData( iEncViewSIdx, iEncContent, iCurView, iBaseViewSIdx, iVideoDistMode, iDepthDistMode );
[2]1225
[5]1226    AOT( iVideoDistMode < 0 || iVideoDistMode > 2 );
[2]1227
[5]1228    Int iBaseViewIdx = m_cCameraData.getBaseSortedId2Id()[ iBaseViewSIdx ];
[2]1229
[5]1230    TComPicYuv* pcPicYuvVideoRec  = xGetPicYuvFromView( iBaseViewIdx, iPoc, false, true  );
1231    TComPicYuv* pcPicYuvDepthRec  = xGetPicYuvFromView( iBaseViewIdx, iPoc, true , true  );
1232    TComPicYuv* pcPicYuvVideoOrg  = xGetPicYuvFromView( iBaseViewIdx, iPoc, false, false );
1233    TComPicYuv* pcPicYuvDepthOrg  = xGetPicYuvFromView( iBaseViewIdx, iPoc, true , false );
[2]1234
[5]1235    TComPicYuv* pcPicYuvVideoRef  = ( iVideoDistMode == 2 ) ? pcPicYuvVideoOrg  : NULL;
1236    TComPicYuv* pcPicYuvDepthRef  = ( iDepthDistMode == 2 ) ? pcPicYuvDepthOrg  : NULL;
[2]1237
[5]1238    TComPicYuv* pcPicYuvVideoTest = ( iVideoDistMode == 0 ) ? pcPicYuvVideoOrg  : pcPicYuvVideoRec;
1239    TComPicYuv* pcPicYuvDepthTest = ( iDepthDistMode == 0 ) ? pcPicYuvDepthOrg  : pcPicYuvDepthRec;
1240
1241    AOT( (iVideoDistMode == 2) != (pcPicYuvVideoRef != NULL) );
1242    AOT( (iDepthDistMode == 2) != (pcPicYuvDepthRef != NULL) );
1243    AOT( pcPicYuvDepthTest == NULL );
1244    AOT( pcPicYuvVideoTest == NULL );
1245
1246    m_cRendererModel.setBaseView( iBaseViewSIdx, pcPicYuvVideoTest, pcPicYuvDepthTest, pcPicYuvVideoRef, pcPicYuvDepthRef );
[2]1247  }
1248
[5]1249  m_cRendererModel.setErrorMode( iEncViewSIdx, iEncContent, 0 );
[2]1250  // setup virtual views
[5]1251  Int iNumOfSV  = m_cRenModStrParser.getNumOfModelsForView( iEncViewSIdx, iEncContent );
[2]1252  for (Int iCurView = 0; iCurView < iNumOfSV; iCurView++ )
[5]1253  {
1254    Int iOrgRefBaseViewSIdx;
1255    Int iLeftBaseViewSIdx;
1256    Int iRightBaseViewSIdx;
1257    Int iSynthViewRelNum;
1258    Int iModelNum;
1259    Int iBlendMode;
1260    m_cRenModStrParser.getSingleModelData(iEncViewSIdx, iEncContent, iCurView, iModelNum, iBlendMode,iLeftBaseViewSIdx, iRightBaseViewSIdx, iOrgRefBaseViewSIdx, iSynthViewRelNum );
[2]1261
[5]1262    Int iLeftBaseViewIdx    = -1;
1263    Int iRightBaseViewIdx   = -1;
[2]1264
[5]1265    TComPicYuv* pcPicYuvOrgRef  = NULL;
1266    Int**      ppiShiftLUTLeft  = NULL;
1267    Int**      ppiShiftLUTRight = NULL;
1268    Int**      ppiBaseShiftLUTLeft  = NULL;
1269    Int**      ppiBaseShiftLUTRight = NULL;
[2]1270
1271
[5]1272    Int        iDistToLeft      = -1;
[2]1273
[5]1274    Int iSynthViewIdx = m_cCameraData.synthRelNum2Idx( iSynthViewRelNum );
[2]1275
1276    if ( iLeftBaseViewSIdx != -1 )
1277    {
[5]1278      iLeftBaseViewIdx   = m_cCameraData.getBaseSortedId2Id()   [ iLeftBaseViewSIdx ];
[2]1279      ppiShiftLUTLeft    = m_cCameraData.getSynthViewShiftLUTI()[ iLeftBaseViewIdx  ][ iSynthViewIdx  ];
1280    }
1281
1282    if ( iRightBaseViewSIdx != -1 )
1283    {
[5]1284      iRightBaseViewIdx  = m_cCameraData.getBaseSortedId2Id()   [iRightBaseViewSIdx ];
[2]1285      ppiShiftLUTRight   = m_cCameraData.getSynthViewShiftLUTI()[ iRightBaseViewIdx ][ iSynthViewIdx ];
1286    }
1287
1288    if ( iRightBaseViewSIdx != -1 && iLeftBaseViewSIdx != -1 )
[5]1289    {
1290      iDistToLeft    = m_cCameraData.getRelDistLeft(  iSynthViewIdx , iLeftBaseViewIdx, iRightBaseViewIdx);
[2]1291      ppiBaseShiftLUTLeft  = m_cCameraData.getBaseViewShiftLUTI() [ iLeftBaseViewIdx  ][ iRightBaseViewIdx ];
1292      ppiBaseShiftLUTRight = m_cCameraData.getBaseViewShiftLUTI() [ iRightBaseViewIdx ][ iLeftBaseViewIdx  ];
1293
1294    }
1295
1296    if ( iOrgRefBaseViewSIdx != -1 )
1297    {
[5]1298      pcPicYuvOrgRef = xGetPicYuvFromView( m_cCameraData.getBaseSortedId2Id()[ iOrgRefBaseViewSIdx ] , iPoc, false, false );
1299      AOF ( pcPicYuvOrgRef );
1300    }
[2]1301
[5]1302    m_cRendererModel.setSingleModel( iModelNum, ppiShiftLUTLeft, ppiBaseShiftLUTLeft, ppiShiftLUTRight, ppiBaseShiftLUTRight, iDistToLeft, pcPicYuvOrgRef );
[2]1303  }
1304}
[5]1305#endif
[2]1306
[56]1307
1308
1309/*
1310void TAppEncTop::printRateSummary()
1311{
1312  double time = (double) m_iFrameRcvd / m_iFrameRate;
1313  printf("Bytes written to file: %u (%.3f kbps)\n", m_totalBytes, 0.008 * m_totalBytes / time);
1314#if VERBOSE_RATE
1315  printf("Bytes for SPS/PPS/Slice (Incl. Annex B): %u (%.3f kbps)\n", m_essentialBytes, 0.008 * m_essentialBytes / time);
1316#endif
1317}
1318*/
1319
1320std::vector<TComPic*> TAppEncTop::getInterViewRefPics( Int viewId, Int poc, Bool isDepth, TComSPS* sps )
1321{
1322  std::vector<TComPic*> apcRefPics( sps->getNumberOfUsableInterViewRefs(), (TComPic*)NULL );
1323  for( Int k = 0; k < sps->getNumberOfUsableInterViewRefs(); k++ )
1324  {
1325    TComPic* pcRefPic = xGetPicFromView( sps->getUsableInterViewRef( k ) + viewId, poc, isDepth );
1326    assert( pcRefPic != NULL );
1327    apcRefPics[k] = pcRefPic;
1328  }
1329  return apcRefPics;
1330}
1331
1332TComPic* TAppEncTop::xGetPicFromView( Int viewIdx, Int poc, Bool isDepth )
1333{
1334  assert( ( viewIdx >= 0 ) && ( viewIdx < m_iNumberOfViews ) );
1335
1336  TComList<TComPic*>* apcListPic = (isDepth ?  m_acTEncDepthTopList[viewIdx] : m_acTEncTopList[viewIdx])->getListPic() ;
1337
1338  TComPic* pcPic = NULL;
1339  for(TComList<TComPic*>::iterator it=apcListPic->begin(); it!=apcListPic->end(); it++)
1340  {
1341    if( (*it)->getPOC() == poc )
1342    {
1343      pcPic = *it ;
1344      break ;
1345    }
1346  }
1347
1348  return pcPic;
1349};
1350
1351//! \}
Note: See TracBrowser for help on using the repository browser.