source: 3DVCSoftware/branches/HTM-5.0-Qualcomm/source/App/TAppEncoder/TAppEncTop.cpp @ 799

Last change on this file since 799 was 195, checked in by tech, 12 years ago

Changed macro switch names to match conventions.

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