source: 3DVCSoftware/branches/HTM-4.0.1-VSP-dev0/source/App/TAppEncoder/TAppEncTop.cpp @ 193

Last change on this file since 193 was 193, checked in by mitsubishi-htm, 12 years ago

A second release, as planned

  • Migrate to HTM 4.1
  • Move VSP related switches to cfg file instead of #define in the source code
  • A few bug fixes
  • For VC project files, only VC9 file is updated

TODO

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