source: 3DVCSoftware/branches/HTM-6.0-Mediatek/source/App/TAppEncoder/TAppEncTop.cpp @ 303

Last change on this file since 303 was 303, checked in by mediatek-htm, 11 years ago

Added FCO_FIX, FCO_FIX_SPS_CHANGE, and FCO_DVP_REFINE_C0132_C0170 macros to support FCO.
The new macros are default disabled in CTC.

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