source: 3DVCSoftware/branches/HTM-4.0-dev0/source/App/TAppEncoder/TAppEncTop.cpp @ 1389

Last change on this file since 1389 was 102, checked in by tech, 13 years ago

SAIT_VSO_EST_A0033 code improvement

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