source: 3DVCSoftware/branches/0.2-poznan-univ/source/App/TAppEncoder/TAppEncTop.cpp @ 11

Last change on this file since 11 was 11, checked in by poznan-univ, 12 years ago

Poznan disocclusion coding - CU Skip

  • Property svn:eol-style set to native
File size: 54.5 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-2011, 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 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
35
36/** \file     TAppEncTop.cpp
37    \brief    Encoder application class
38*/
39
40#include <list>
41#include <stdio.h>
42#include <fcntl.h>
43#include <assert.h>
44
45#include "TAppEncTop.h"
46
47// ====================================================================================================================
48// Constructor / destructor / initialization / destroy
49// ====================================================================================================================
50
51TAppEncTop::TAppEncTop()
52{
53#if HHI_VSO
54  m_iLastFramePutInERViewBuffer = -1;
55#endif
56}
57
58TAppEncTop::~TAppEncTop()
59{
60}
61
62
63Void TAppEncTop::xInitLibCfg()
64{
65  for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
66  {
67    m_iFrameRcvdVector.push_back(0) ;
68    m_acTEncTopList.push_back(new TEncTop);
69
70    m_acTVideoIOYuvInputFileList.push_back(new TVideoIOYuv);
71
72    m_acTVideoIOYuvReconFileList.push_back(new TVideoIOYuv);
73    m_cListPicYuvRecList.push_back(new TComList<TComPicYuv*>) ;
74    m_aiNextPocToDump.push_back( 0 );
75    m_cListPicYuvRecMap.push_back( std::map<PicOrderCnt,TComPicYuv*>() );
76    m_acTEncTopList[iViewIdx]->setFrameRate                    ( m_iFrameRate );
77    m_acTEncTopList[iViewIdx]->setFrameSkip                    ( m_FrameSkip );
78    m_acTEncTopList[iViewIdx]->setSourceWidth                  ( m_iSourceWidth );
79    m_acTEncTopList[iViewIdx]->setSourceHeight                 ( m_iSourceHeight );
80    m_acTEncTopList[iViewIdx]->setFrameToBeEncoded             ( m_iFrameToBeEncoded );
81
82  //====== Coding Structure ========
83#if DCM_DECODING_REFRESH
84    m_acTEncTopList[iViewIdx]->setDecodingRefreshType          ( m_iDecodingRefreshType );
85#endif
86    m_acTEncTopList[iViewIdx]->setCPSSize                      ( m_uiCodedPictureStoreSize );
87    m_acTEncTopList[iViewIdx]->setGOPSize                      ( m_iGOPSize );
88    m_acTEncTopList[iViewIdx]->setRateGOPSize                  ( m_iRateGOPSize );
89
90    m_acTEncTopList[iViewIdx]->setSeqStructure                              ( m_cInputFormatString );
91
92    m_acTEncTopList[iViewIdx]->setQP                           ( m_aiQP[0] );
93
94    m_acTEncTopList[iViewIdx]->setTemporalLayerQPOffset        ( m_aiTLayerQPOffset );
95    m_acTEncTopList[iViewIdx]->setPad                          ( m_aiPad );
96
97    //===== Slice ========
98
99    //====== Entropy Coding ========
100    m_acTEncTopList[iViewIdx]->setSymbolMode                   ( m_iSymbolMode );
101
102    //====== Loop/Deblock Filter ========
103    m_acTEncTopList[iViewIdx]->setLoopFilterDisable            ( m_abLoopFilterDisable[0]   );
104    m_acTEncTopList[iViewIdx]->setLoopFilterAlphaC0Offset      ( m_iLoopFilterAlphaC0Offset );
105    m_acTEncTopList[iViewIdx]->setLoopFilterBetaOffset         ( m_iLoopFilterBetaOffset    );
106
107    //====== Motion search ========
108    m_acTEncTopList[iViewIdx]->setFastSearch                   ( m_iFastSearch  );
109    m_acTEncTopList[iViewIdx]->setSearchRange                  ( m_iSearchRange );
110    m_acTEncTopList[iViewIdx]->setBipredSearchRange            ( m_bipredSearchRange );
111    m_acTEncTopList[iViewIdx]->setMaxDeltaQP                   ( m_iMaxDeltaQP  );
112
113#if HHI_VSO
114    //====== VSO =========
115    m_acTEncTopList[iViewIdx]->setForceLambdaScaleVSO          ( false );
116    m_acTEncTopList[iViewIdx]->setLambdaScaleVSO               ( 1     );
117    m_acTEncTopList[iViewIdx]->setVSOMode                      ( 0     );
118#endif
119
120    //====== Tool list ========
121    m_acTEncTopList[iViewIdx]->setUseSBACRD                    ( m_bUseSBACRD   );
122    m_acTEncTopList[iViewIdx]->setDeltaQpRD                    ( m_uiDeltaQpRD  );
123    m_acTEncTopList[iViewIdx]->setUseASR                       ( m_bUseASR      );
124    m_acTEncTopList[iViewIdx]->setUseHADME                     ( m_bUseHADME    );
125    m_acTEncTopList[iViewIdx]->setUseALF                       ( m_abUseALF[0]  );
126#if MQT_ALF_NPASS
127    m_acTEncTopList[iViewIdx]->setALFEncodePassReduction       ( m_iALFEncodePassReduction );
128#endif
129#if DCM_COMB_LIST
130    m_acTEncTopList[iViewIdx]->setUseLComb                     ( m_bUseLComb    );
131    m_acTEncTopList[iViewIdx]->setLCMod                        ( m_bLCMod         );
132#endif
133    m_acTEncTopList[iViewIdx]->setdQPs                         ( m_aidQP        );
134    m_acTEncTopList[iViewIdx]->setUseRDOQ                      ( m_abUseRDOQ[0] );
135    m_acTEncTopList[iViewIdx]->setUseLDC                       ( m_bUseLDC      );
136    m_acTEncTopList[iViewIdx]->setUsePAD                       ( m_bUsePAD      );
137    m_acTEncTopList[iViewIdx]->setQuadtreeTULog2MaxSize        ( m_uiQuadtreeTULog2MaxSize );
138    m_acTEncTopList[iViewIdx]->setQuadtreeTULog2MinSize        ( m_uiQuadtreeTULog2MinSize );
139    m_acTEncTopList[iViewIdx]->setQuadtreeTUMaxDepthInter      ( m_uiQuadtreeTUMaxDepthInter );
140    m_acTEncTopList[iViewIdx]->setQuadtreeTUMaxDepthIntra      ( m_uiQuadtreeTUMaxDepthIntra );
141    m_acTEncTopList[iViewIdx]->setUseFastEnc                   ( m_bUseFastEnc  );
142
143#if HHI_VSO
144    m_acTEncTopList[iViewIdx]->setUseVSO                       ( false ); //GT: might be enabled later for VSO Mode 4
145#endif
146
147    m_acTEncTopList[iViewIdx]->setViewId                       ( (UInt)iViewIdx );
148    m_acTEncTopList[iViewIdx]->setViewOrderIdx                 ( m_cCameraData.getViewOrderIndex()[ iViewIdx ] );
149    m_acTEncTopList[iViewIdx]->setIsDepth                      ( false );
150    m_acTEncTopList[iViewIdx]->setCamParPrecision              ( m_cCameraData.getCamParsCodedPrecision  () );
151    m_acTEncTopList[iViewIdx]->setCamParInSliceHeader          ( m_cCameraData.getVaryingCameraParameters() );
152    m_acTEncTopList[iViewIdx]->setCodedScale                   ( m_cCameraData.getCodedScale             () );
153    m_acTEncTopList[iViewIdx]->setCodedOffset                  ( m_cCameraData.getCodedOffset            () );
154#if DEPTH_MAP_GENERATION
155    m_acTEncTopList[iViewIdx]->setPredDepthMapGeneration       ( m_uiPredDepthMapGeneration );
156    m_acTEncTopList[iViewIdx]->setPdmPrecision                 ( (UInt)m_cCameraData.getPdmPrecision     () );
157    m_acTEncTopList[iViewIdx]->setPdmScaleNomDelta             (       m_cCameraData.getPdmScaleNomDelta () );
158    m_acTEncTopList[iViewIdx]->setPdmOffset                    (       m_cCameraData.getPdmOffset        () );
159#endif
160#if HHI_INTER_VIEW_MOTION_PRED
161    m_acTEncTopList[iViewIdx]->setMultiviewMvPredMode          ( m_uiMultiviewMvPredMode );
162    m_acTEncTopList[iViewIdx]->setMultiviewMvRegMode           ( iViewIdx ? m_uiMultiviewMvRegMode       : 0   );
163    m_acTEncTopList[iViewIdx]->setMultiviewMvRegLambdaScale    ( iViewIdx ? m_dMultiviewMvRegLambdaScale : 0.0 );
164#endif
165#if HHI_INTER_VIEW_RESIDUAL_PRED
166    m_acTEncTopList[iViewIdx]->setMultiviewResPredMode         ( m_uiMultiviewResPredMode );
167#endif
168
169
170#if HHI_INTERVIEW_SKIP
171    m_acTEncTopList[iViewIdx]->setInterViewSkip            ( iViewIdx ? m_uiInterViewSkip : 0 );
172#if HHI_INTERVIEW_SKIP_LAMBDA_SCALE
173    m_acTEncTopList[iViewIdx]->setInterViewSkipLambdaScale ( iViewIdx ? (Int)m_dInterViewSkipLambdaScale : 1 );
174#endif
175#endif
176    m_acTEncTopList[iViewIdx]->setUseMRG                       ( m_bUseMRG      ); // SOPH:
177
178#if LM_CHROMA
179    m_acTEncTopList[iViewIdx]->setUseLMChroma                  ( m_bUseLMChroma );
180#endif
181
182#if HHI_RMP_SWITCH
183    m_acTEncTopList[iViewIdx]->setUseRMP                     ( m_bUseRMP );
184#endif
185#ifdef ROUNDING_CONTROL_BIPRED
186    m_acTEncTopList[iViewIdx]->setUseRoundingControlBipred(m_useRoundingControlBipred);
187#endif
188#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
189    m_acTEncTopList[iViewIdx]->setUseDMM( false );
190#endif
191#if CONSTRAINED_INTRA_PRED
192    m_acTEncTopList[iViewIdx]->setUseConstrainedIntraPred      ( m_bUseConstrainedIntraPred );
193#endif
194#ifdef WEIGHT_PRED
195    //====== Weighted Prediction ========
196    m_acTEncTopList[iViewIdx]->setUseWP                         ( m_bUseWeightPred      );
197    m_acTEncTopList[iViewIdx]->setWPBiPredIdc                   ( m_uiBiPredIdc         );
198#endif
199    //====== Slice ========
200    m_acTEncTopList[iViewIdx]->setSliceMode               ( m_iSliceMode                );
201    m_acTEncTopList[iViewIdx]->setSliceArgument           ( m_iSliceArgument            );
202
203    //====== Entropy Slice ========
204    m_acTEncTopList[iViewIdx]->setEntropySliceMode        ( m_iEntropySliceMode         );
205    m_acTEncTopList[iViewIdx]->setEntropySliceArgument    ( m_iEntropySliceArgument     );
206#if MTK_NONCROSS_INLOOP_FILTER
207    if(m_iSliceMode == 0 )
208    {
209      m_bLFCrossSliceBoundaryFlag = true;
210    }
211    m_acTEncTopList[iViewIdx]->setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag );
212#endif
213#if MTK_SAO
214    m_acTEncTopList[iViewIdx]->setUseSAO               ( m_abUseSAO[0]     );
215#endif
216#if HHI_MPI
217    m_acTEncTopList[iViewIdx]->setUseMVI( false );
218#endif
219
220    m_acTEncTopList[iViewIdx]->setPictureDigestEnabled(m_pictureDigestEnabled);
221    m_acTEncTopList[iViewIdx]->setQpChangeFrame( m_iQpChangeFrame );
222    m_acTEncTopList[iViewIdx]->setQpChangeOffsetVideo( m_iQpChangeOffsetVideo );
223    m_acTEncTopList[iViewIdx]->setQpChangeOffsetDepth( m_iQpChangeOffsetDepth );
224  }
225  if( m_bUsingDepthMaps )
226  {
227
228#if HHI_VSO
229    for (Int iViewIdx=0; iViewIdx<m_iNumberOfExternalRefs; iViewIdx++)
230    {
231        m_acTVideoIOYuvERFileList.push_back(new TVideoIOYuv);
232    }
233#endif
234
235    for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
236    {
237      m_iDepthFrameRcvdVector.push_back(0) ;
238      m_acTEncDepthTopList.push_back(new TEncTop);
239
240      m_acTVideoIOYuvDepthInputFileList.push_back(new TVideoIOYuv);
241
242      m_acTVideoIOYuvDepthReconFileList.push_back(new TVideoIOYuv);
243      m_cListPicYuvDepthRecList.push_back(new TComList<TComPicYuv*>) ;
244      m_aiNextDepthPocToDump.push_back( 0 );
245      m_cListPicYuvDepthRecMap.push_back( std::map<PicOrderCnt,TComPicYuv*>() );
246      m_acTEncDepthTopList[iViewIdx]->setFrameRate                    ( m_iFrameRate );
247      m_acTEncDepthTopList[iViewIdx]->setFrameSkip                    ( m_FrameSkip );
248      m_acTEncDepthTopList[iViewIdx]->setSourceWidth                  ( m_iSourceWidth );
249      m_acTEncDepthTopList[iViewIdx]->setSourceHeight                 ( m_iSourceHeight );
250      m_acTEncDepthTopList[iViewIdx]->setFrameToBeEncoded             ( m_iFrameToBeEncoded );
251
252      //====== Coding Structure ========
253#if DCM_DECODING_REFRESH
254      m_acTEncDepthTopList[iViewIdx]->setDecodingRefreshType          ( m_iDecodingRefreshType );
255#endif
256      m_acTEncDepthTopList[iViewIdx]->setCPSSize                      ( m_uiCodedPictureStoreSize );
257      m_acTEncDepthTopList[iViewIdx]->setGOPSize                      ( m_iGOPSize );
258      m_acTEncDepthTopList[iViewIdx]->setRateGOPSize                  ( m_iRateGOPSize );
259
260      m_acTEncDepthTopList[iViewIdx]->setSeqStructure                              ( m_cInputFormatString );
261
262      m_acTEncDepthTopList[iViewIdx]->setQP                           ( m_aiQP[1] );
263
264      m_acTEncDepthTopList[iViewIdx]->setTemporalLayerQPOffset        ( m_aiTLayerQPOffset );
265      m_acTEncDepthTopList[iViewIdx]->setPad                          ( m_aiPad );
266
267      //===== Slice ========
268
269      //====== Entropy Coding ========
270      m_acTEncDepthTopList[iViewIdx]->setSymbolMode                   ( m_iSymbolMode );
271
272      //====== Loop/Deblock Filter ========
273      m_acTEncDepthTopList[iViewIdx]->setLoopFilterDisable            ( m_abLoopFilterDisable[1]   );
274      m_acTEncDepthTopList[iViewIdx]->setLoopFilterAlphaC0Offset      ( m_iLoopFilterAlphaC0Offset );
275      m_acTEncDepthTopList[iViewIdx]->setLoopFilterBetaOffset         ( m_iLoopFilterBetaOffset    );
276
277      //====== Motion search ========
278      m_acTEncDepthTopList[iViewIdx]->setFastSearch                   ( m_iFastSearch  );
279      m_acTEncDepthTopList[iViewIdx]->setSearchRange                  ( m_iSearchRange );
280      m_acTEncDepthTopList[iViewIdx]->setBipredSearchRange            ( m_bipredSearchRange );
281      m_acTEncDepthTopList[iViewIdx]->setMaxDeltaQP                   ( m_iMaxDeltaQP  );
282
283      //====== Tool list ========
284      m_acTEncDepthTopList[iViewIdx]->setUseSBACRD                    ( m_bUseSBACRD   );
285      m_acTEncDepthTopList[iViewIdx]->setDeltaQpRD                    ( m_uiDeltaQpRD  );
286      m_acTEncDepthTopList[iViewIdx]->setUseASR                       ( m_bUseASR      );
287      m_acTEncDepthTopList[iViewIdx]->setUseHADME                     ( m_bUseHADME    );
288      m_acTEncDepthTopList[iViewIdx]->setUseALF                       ( m_abUseALF[1]  );
289#if MQT_ALF_NPASS
290      m_acTEncDepthTopList[iViewIdx]->setALFEncodePassReduction       ( m_iALFEncodePassReduction );
291#endif
292#if DCM_COMB_LIST
293      m_acTEncDepthTopList[iViewIdx]->setUseLComb                     ( m_bUseLComb    );
294      m_acTEncDepthTopList[iViewIdx]->setLCMod                        ( m_bLCMod         );
295#endif
296      m_acTEncDepthTopList[iViewIdx]->setdQPs                         ( m_aidQP        );
297      m_acTEncDepthTopList[iViewIdx]->setUseRDOQ                      ( m_abUseRDOQ[1] );
298      m_acTEncDepthTopList[iViewIdx]->setUseLDC                       ( m_bUseLDC      );
299      m_acTEncDepthTopList[iViewIdx]->setUsePAD                       ( m_bUsePAD      );
300      m_acTEncDepthTopList[iViewIdx]->setQuadtreeTULog2MaxSize        ( m_uiQuadtreeTULog2MaxSize );
301      m_acTEncDepthTopList[iViewIdx]->setQuadtreeTULog2MinSize        ( m_uiQuadtreeTULog2MinSize );
302      m_acTEncDepthTopList[iViewIdx]->setQuadtreeTUMaxDepthInter      ( m_uiQuadtreeTUMaxDepthInter );
303      m_acTEncDepthTopList[iViewIdx]->setQuadtreeTUMaxDepthIntra      ( m_uiQuadtreeTUMaxDepthIntra );
304      m_acTEncDepthTopList[iViewIdx]->setUseFastEnc                   ( m_bUseFastEnc  );
305
306#if HHI_VSO
307      m_acTEncDepthTopList[iViewIdx]->setUseVSO                       ( m_bUseVSO      ); //GT: might be enabled/disabled later for VSO Mode 4
308      m_acTEncDepthTopList[iViewIdx]->setForceLambdaScaleVSO          ( m_bForceLambdaScaleVSO );
309      m_acTEncDepthTopList[iViewIdx]->setLambdaScaleVSO               ( m_dLambdaScaleVSO );
310#if HHI_VSO_DIST_INT
311      m_acTEncDepthTopList[iViewIdx]->setAllowNegDist                 ( m_bAllowNegDist );
312#endif
313      m_acTEncDepthTopList[iViewIdx]->setVSOMode                      ( m_uiVSOMode );
314#endif
315
316      m_acTEncDepthTopList[iViewIdx]->setViewId                       ( (UInt)iViewIdx );
317      m_acTEncDepthTopList[iViewIdx]->setViewOrderIdx                 ( m_cCameraData.getViewOrderIndex()[ iViewIdx ] );
318      m_acTEncDepthTopList[iViewIdx]->setIsDepth                      ( true );
319      m_acTEncDepthTopList[iViewIdx]->setCamParPrecision              ( 0 );
320      m_acTEncDepthTopList[iViewIdx]->setCamParInSliceHeader          ( false );
321      m_acTEncDepthTopList[iViewIdx]->setCodedScale                   ( 0 );
322      m_acTEncDepthTopList[iViewIdx]->setCodedOffset                  ( 0 );
323#if DEPTH_MAP_GENERATION
324      m_acTEncDepthTopList[iViewIdx]->setPredDepthMapGeneration       ( 0 );
325#endif
326#if HHI_INTER_VIEW_MOTION_PRED
327      m_acTEncDepthTopList[iViewIdx]->setMultiviewMvPredMode          ( 0 );
328      m_acTEncDepthTopList[iViewIdx]->setMultiviewMvRegMode           ( 0 );
329      m_acTEncDepthTopList[iViewIdx]->setMultiviewMvRegLambdaScale    ( 0.0 );
330#endif
331#if HHI_INTER_VIEW_RESIDUAL_PRED
332      m_acTEncDepthTopList[iViewIdx]->setMultiviewResPredMode         ( 0 );
333#endif
334
335#if HHI_INTERVIEW_SKIP
336      m_acTEncDepthTopList[iViewIdx]->setInterViewSkip            ( 0 );
337#if HHI_INTERVIEW_SKIP_LAMBDA_SCALE
338      m_acTEncDepthTopList[iViewIdx]->setInterViewSkipLambdaScale ( 1 );
339#endif
340#endif
341      m_acTEncDepthTopList[iViewIdx]->setUseMRG                       ( m_bUseMRG      ); // SOPH:
342
343#if LM_CHROMA
344      m_acTEncDepthTopList[iViewIdx]->setUseLMChroma                  ( m_bUseLMChroma );
345#endif
346
347#if HHI_RMP_SWITCH
348      m_acTEncDepthTopList[iViewIdx]->setUseRMP                     ( m_bUseRMP );
349#endif
350#ifdef ROUNDING_CONTROL_BIPRED
351      m_acTEncDepthTopList[iViewIdx]->setUseRoundingControlBipred(m_useRoundingControlBipred);
352#endif
353#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
354      m_acTEncDepthTopList[iViewIdx]->setUseDMM( m_bUseDMM );
355#endif
356#if CONSTRAINED_INTRA_PRED
357      m_acTEncDepthTopList[iViewIdx]->setUseConstrainedIntraPred      ( m_bUseConstrainedIntraPred );
358#endif
359#ifdef WEIGHT_PRED
360    //====== Weighted Prediction ========
361      m_acTEncDepthTopList[iViewIdx]->setUseWP                         ( m_bUseWeightPred      );
362      m_acTEncDepthTopList[iViewIdx]->setWPBiPredIdc                   ( m_uiBiPredIdc         );
363#endif
364      //====== Slice ========
365      m_acTEncDepthTopList[iViewIdx]->setSliceMode               ( m_iSliceMode                );
366      m_acTEncDepthTopList[iViewIdx]->setSliceArgument           ( m_iSliceArgument            );
367
368      //====== Entropy Slice ========
369      m_acTEncDepthTopList[iViewIdx]->setEntropySliceMode        ( m_iEntropySliceMode         );
370      m_acTEncDepthTopList[iViewIdx]->setEntropySliceArgument    ( m_iEntropySliceArgument     );
371#if MTK_NONCROSS_INLOOP_FILTER
372      if(m_iSliceMode == 0 )
373      {
374        m_bLFCrossSliceBoundaryFlag = true;
375      }
376      m_acTEncDepthTopList[iViewIdx]->setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag );
377#endif
378#if MTK_SAO
379      m_acTEncDepthTopList[iViewIdx]->setUseSAO               ( m_abUseSAO[1]     );
380#endif
381#if HHI_MPI
382      m_acTEncDepthTopList[iViewIdx]->setUseMVI( m_bUseMVI );
383#endif
384
385      m_acTEncDepthTopList[iViewIdx]->setPictureDigestEnabled(m_pictureDigestEnabled);
386
387      m_acTEncDepthTopList[iViewIdx]->setQpChangeFrame( m_iQpChangeFrame );
388      m_acTEncDepthTopList[iViewIdx]->setQpChangeOffsetVideo( m_iQpChangeOffsetVideo );
389      m_acTEncDepthTopList[iViewIdx]->setQpChangeOffsetDepth( m_iQpChangeOffsetDepth );
390    }
391  }
392#if HHI_INTER_VIEW_MOTION_PRED
393  else if( m_uiMultiviewMvRegMode )
394  {
395    for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
396    {
397      m_acTVideoIOYuvDepthInputFileList.push_back( new TVideoIOYuv );
398    }
399  }
400#endif
401
402#if HHI_VSO
403  if ( m_bUseVSO )
404  {
405    if ( m_uiVSOMode == 4 )
406    {
407      m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, m_iSourceHeight, LOG2_DISP_PREC_LUT, 0 );
408
409      for ( Int iViewNum = 0; iViewNum < m_iNumberOfViews; iViewNum++ )
410      {
411        for (Int iContent = 0; iContent < 2; iContent++ )
412        {
413          Int iNumOfModels   = m_cRenModStrParser.getNumOfModelsForView(iViewNum, iContent);
414          Bool bUseVSO = (iNumOfModels != 0);
415
416          TEncTop* pcEncTop = ( iContent == 0 ) ? m_acTEncTopList[iViewNum] : m_acTEncDepthTopList[iViewNum];
417          pcEncTop->setUseVSO( bUseVSO );
418          pcEncTop->getRdCost()->setRenModel( bUseVSO ? &m_cRendererModel : NULL );
419
420          for (Int iCurModel = 0; iCurModel < iNumOfModels; iCurModel++ )
421          {
422            Int iModelNum; Int iLeftViewNum; Int iRightViewNum; Int iDump; Int iOrgRefNum; Int iBlendMode;
423
424            m_cRenModStrParser.getSingleModelData  ( iViewNum, iContent, iCurModel, iModelNum, iBlendMode, iLeftViewNum, iRightViewNum, iOrgRefNum, iDump ) ;
425            m_cRendererModel  .createSingleModel   ( iViewNum, iContent, iModelNum, iLeftViewNum, iRightViewNum, (iOrgRefNum != -1), iBlendMode );
426          }
427        }
428      }
429    }
430    else
431    {
432      m_cRendererTop.init(m_iSourceWidth, m_iSourceHeight,true,0,0,true, 0,0,0,0,0,0,0,1,0,0 );  //GT: simplest configuration
433    }
434  }
435#endif
436
437#if POZNAN_SYNTH
438  //m_cAvailabilityRenderer.init(m_iSourceWidth, m_iSourceHeight,true,0,0,true, 0,0,0,0,0,0,0,1,0,0 );  //GT: simplest configuration
439  m_cAvailabilityRenderer.init(m_iSourceWidth, m_iSourceHeight,true,0,LOG2_DISP_PREC_LUT,true, 0,0,0,0,0,6,4,1,0,6 );  //GT: simplest configuration
440#endif
441
442#if HHI_INTERVIEW_SKIP
443  m_cUsedPelsRenderer.init(m_iSourceWidth, m_iSourceHeight, true, 0, LOG2_DISP_PREC_LUT, true, 0, 0, 0, 0, 0, 6, 4, 1, 0, 6 );
444#endif
445}
446
447Void TAppEncTop::xCreateLib()
448{
449  // Video I/O
450  m_cTVideoIOBitsFile.openBits( m_pchBitstreamFile, true  );  // write mode
451
452  for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
453  {
454    m_acTVideoIOYuvInputFileList[iViewIdx]->open( m_pchInputFileList[iViewIdx],     false, m_uiInputBitDepth, m_uiInternalBitDepth );  // read  mode
455    m_acTVideoIOYuvInputFileList[iViewIdx]->skipFrames(m_FrameSkip, m_iSourceWidth, m_iSourceHeight);
456    m_acTVideoIOYuvReconFileList[iViewIdx]->open( m_pchReconFileList[iViewIdx],     true, m_uiOutputBitDepth, m_uiInternalBitDepth);  // write mode
457
458    // Neo Decoder
459    m_acTEncTopList[iViewIdx]->create();
460
461    if( m_bUsingDepthMaps )
462    {
463      m_acTVideoIOYuvDepthInputFileList[iViewIdx]->open( m_pchDepthInputFileList[iViewIdx],     false, m_uiInputBitDepth, m_uiInternalBitDepth );  // read  mode
464      m_acTVideoIOYuvDepthInputFileList[iViewIdx]->skipFrames(m_FrameSkip, m_iSourceWidth, m_iSourceHeight);
465
466      m_acTVideoIOYuvDepthReconFileList[iViewIdx]->open( m_pchDepthReconFileList[iViewIdx],     true, m_uiOutputBitDepth, m_uiInternalBitDepth);  // write mode
467
468      // Neo Decoder
469      m_acTEncDepthTopList[iViewIdx]->create();
470    }
471#if HHI_INTER_VIEW_MOTION_PRED
472    else if( m_uiMultiviewMvRegMode )
473    {
474      m_acTVideoIOYuvDepthInputFileList[iViewIdx]->open( m_pchDepthInputFileList[iViewIdx],     false, m_uiInputBitDepth, m_uiInternalBitDepth );  // read  mode
475      m_acTVideoIOYuvDepthInputFileList[iViewIdx]->skipFrames(m_FrameSkip, m_iSourceWidth, m_iSourceHeight);
476    }
477#endif
478  }
479
480#if HHI_VSO
481  for(Int iViewIdx=0; iViewIdx < m_iNumberOfExternalRefs; iViewIdx++)
482  {
483    m_acTVideoIOYuvERFileList[iViewIdx]->open( m_pchERRefFileList[iViewIdx], false, m_uiInputBitDepth, m_uiInternalBitDepth ); // read mode
484  }
485#endif
486}
487
488Void TAppEncTop::xDestroyLib()
489{
490
491  m_cTVideoIOBitsFile.closeBits();
492
493#if HHI_VSO
494  for ( Int iViewIdx = 0; iViewIdx < m_iNumberOfExternalRefs; iViewIdx++ )
495  {
496    m_acTVideoIOYuvERFileList[iViewIdx]->close();
497    delete m_acTVideoIOYuvERFileList[iViewIdx];
498    m_acTVideoIOYuvERFileList[iViewIdx] = 0;
499  };
500#endif
501
502  for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
503  {
504    m_acTVideoIOYuvInputFileList[iViewIdx]->close();
505    m_acTVideoIOYuvReconFileList[iViewIdx]->close();
506
507    delete m_acTVideoIOYuvInputFileList[iViewIdx] ; m_acTVideoIOYuvInputFileList[iViewIdx] = NULL;
508    delete m_acTVideoIOYuvReconFileList[iViewIdx] ; m_acTVideoIOYuvReconFileList[iViewIdx] = NULL;
509
510    delete m_cListPicYuvRecList[iViewIdx] ; m_cListPicYuvRecList[iViewIdx] = NULL;
511
512    m_acTEncTopList[iViewIdx]->destroy();
513    delete m_acTEncTopList[iViewIdx] ; m_acTEncTopList[iViewIdx] = NULL;
514
515    if( iViewIdx < Int( m_acTVideoIOYuvDepthInputFileList.size() ) && m_acTVideoIOYuvDepthInputFileList[iViewIdx] )
516    {
517      m_acTVideoIOYuvDepthInputFileList[iViewIdx]->close( );
518      delete m_acTVideoIOYuvDepthInputFileList[iViewIdx] ;
519    }
520    if( iViewIdx < Int( m_acTVideoIOYuvDepthReconFileList.size() ) && m_acTVideoIOYuvDepthReconFileList[iViewIdx] )
521    {
522      m_acTVideoIOYuvDepthReconFileList[iViewIdx]->close () ;
523      delete m_acTVideoIOYuvDepthReconFileList[iViewIdx];
524    }
525    if( iViewIdx < Int( m_acTEncDepthTopList.size() ) && m_acTEncDepthTopList[iViewIdx] )
526    {
527      m_acTEncDepthTopList[iViewIdx]->destroy();
528      delete m_acTEncDepthTopList[iViewIdx];
529    }
530    if( iViewIdx < Int( m_cListPicYuvDepthRecList.size() ) && m_cListPicYuvDepthRecList[iViewIdx] )
531    {
532      delete m_cListPicYuvDepthRecList[iViewIdx ];
533    }
534  }
535}
536
537Void TAppEncTop::xInitLib()
538{
539  for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
540  {
541    m_acTEncTopList[iViewIdx]->init( this );
542  }
543  for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
544  {
545    m_acTEncTopList[iViewIdx]->setTEncTopList( &m_acTEncTopList  );
546  }
547  if ( m_bUsingDepthMaps )
548  {
549    for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
550    {
551      m_acTEncDepthTopList[iViewIdx]->init( this );
552    }
553    for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
554    {
555      m_acTEncDepthTopList[iViewIdx]->setTEncTopList( &m_acTEncDepthTopList  );
556    }
557  }
558}
559
560// ====================================================================================================================
561// Public member functions
562// ====================================================================================================================
563
564/**
565 - create internal class
566 - initialize internal variable
567 - until the end of input YUV file, call encoding function in TEncTop class
568 - delete allocated buffers
569 - destroy internal class
570 .
571 */
572//GT PRE LOAD ENC BUFFER
573Void TAppEncTop::encode()
574{
575  TComPicYuv*       pcPicYuvOrg      = new TComPicYuv;
576  TComPicYuv*       pcDepthPicYuvOrg = new TComPicYuv;
577  TComPicYuv*       pcPdmDepthOrg    = new TComPicYuv;
578  TComPicYuv*       pcPicYuvRec      = NULL;
579  //TComPicYuv*       pcDepthPicYuvRec = NULL;
580
581  // initialize internal class & member variables
582  xInitLibCfg();
583  xCreateLib();
584  xInitLib();
585
586  // main encoder loop
587
588  //GT: setup and init Bools for Eos and Continue Reading
589  Bool  bAllEos = false;
590  Bool  bAllContinueReadingPics;
591  std::vector<Bool>  bEos ;
592  std::vector<Bool>  bContinueReadingPics ;
593
594  Bool  bAllDepthEos = false;
595  Bool  bAllContinueReadingDepthPics;
596  std::vector<Bool>  bDepthEos ;
597  std::vector<Bool>  bContinueReadingDepthPics ;
598
599  for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
600  {
601    bEos.push_back( false ) ;
602    bContinueReadingPics.push_back( true );
603    if( m_bUsingDepthMaps)
604    {
605      bDepthEos.push_back( false ) ;
606      bContinueReadingDepthPics.push_back( true ) ;
607    }
608  }
609  // allocate original YUV buffer
610  pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
611  if( m_bUsingDepthMaps)
612  {
613    pcDepthPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
614  }
615#if HHI_INTER_VIEW_MOTION_PRED
616  if( m_uiMultiviewMvRegMode )
617  {
618    pcPdmDepthOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
619  }
620#endif
621
622  TComBitstream*    pcBitstream = new TComBitstream;
623  pcBitstream->create( (m_iSourceWidth * m_iSourceHeight * 3) >> 1 ) ; //GT: is size reasonable ??
624
625  while ( !(bAllEos&& bAllContinueReadingPics) )
626  {
627    bAllContinueReadingPics = false;
628    bAllContinueReadingDepthPics = false;
629
630    //GT: Read all Buffers
631    for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ ) //GT; store frames first
632    {
633      if (!bEos[iViewIdx] && bContinueReadingPics[iViewIdx] ) //GT: read frames to buffer
634      {
635        // get buffers
636        xGetBuffer( pcPicYuvRec, iViewIdx, m_cListPicYuvRecList ); // ringbuffer of size gopsize -> m_cListPicYuvRec, m_cListBitstream
637        // read input YUV file
638        m_acTVideoIOYuvInputFileList[iViewIdx]->read( pcPicYuvOrg, m_aiPad  ) ;
639        bEos[iViewIdx] = ( m_acTVideoIOYuvInputFileList[iViewIdx]->isEof() == 1 ?   true : false  );             //GT: End of File
640        bEos[iViewIdx] = ( m_iFrameRcvdVector[iViewIdx] == (m_iFrameToBeEncoded - 1) ?    true : bEos[iViewIdx]   );   //GT: FramesToBeEncoded Reached
641        bAllEos = bAllEos|bEos[iViewIdx] ;
642
643#if HHI_INTER_VIEW_MOTION_PRED
644        if( m_uiMultiviewMvRegMode && iViewIdx )
645        {
646          m_acTVideoIOYuvDepthInputFileList[iViewIdx]->read( pcPdmDepthOrg, m_aiPad, m_bUsingDepthMaps );
647        }
648#endif
649
650        // increase number of received frames
651        m_iFrameRcvdVector[iViewIdx]++ ;
652      }
653
654#if HHI_INTER_VIEW_MOTION_PRED
655      m_acTEncTopList[iViewIdx]->receivePic( bEos[iViewIdx],  pcPicYuvOrg, m_cListPicYuvRecList[iViewIdx]->back(), ( m_uiMultiviewMvRegMode && iViewIdx ? pcPdmDepthOrg : 0 ) );
656#else
657      m_acTEncTopList[iViewIdx]->receivePic( bEos[iViewIdx],  pcPicYuvOrg, m_cListPicYuvRecList[iViewIdx]->back(), 0 );
658#endif
659
660      if( m_bUsingDepthMaps )
661      {
662        if (!bDepthEos[iViewIdx] && bContinueReadingDepthPics[iViewIdx] )
663        {
664          // get buffers
665          xGetBuffer( pcPicYuvRec, iViewIdx, m_cListPicYuvDepthRecList ); // ringbuffer of size gopsize -> m_cListPicYuvRec, m_cListBitstream
666          // read input YUV file
667          m_acTVideoIOYuvDepthInputFileList[iViewIdx]->read( pcDepthPicYuvOrg, m_aiPad  ) ;
668          bDepthEos[iViewIdx] = ( m_acTVideoIOYuvDepthInputFileList[iViewIdx]->isEof() == 1 ?   true : false  );
669          bDepthEos[iViewIdx] = ( m_iDepthFrameRcvdVector[iViewIdx] == (m_iFrameToBeEncoded - 1) ?    true : bDepthEos[iViewIdx]   );
670          bAllDepthEos = bAllDepthEos|bDepthEos[iViewIdx] ;
671          // increase number of received frames
672          m_iDepthFrameRcvdVector[iViewIdx]++ ;
673        }
674        m_acTEncDepthTopList[iViewIdx]->receivePic( bDepthEos[iViewIdx],  pcDepthPicYuvOrg, m_cListPicYuvDepthRecList[iViewIdx]->back() );
675      }
676    }
677
678    //===== store current POC =====
679    Bool  bCurrPocCoded = m_acTEncTopList[ 0 ]->currentPocWillBeCoded();
680    Int   iCurrPoc      = m_acTEncTopList[ 0 ]->getNextFrameId();
681
682    //===== update camera parameters =====
683    if( bCurrPocCoded )
684    {
685      m_cCameraData.update( (UInt)iCurrPoc );
686    }
687
688#if HHI_VSO   
689    if ( m_bUseVSO && ( m_uiVSOMode != 4) )
690    {
691      //GT: Read external reference pics or render references
692      xStoreVSORefPicsInBuffer();       //GT;
693    }
694#endif
695
696    //GT: Encode
697    for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ )     // Start encoding
698    {
699#if POZNAN_SYNTH
700      xStoreSynthPicsInBuffer(iViewIdx,false);
701#endif
702      bool bThisViewContinueReadingPics = bContinueReadingPics[iViewIdx];
703      m_acTEncTopList[iViewIdx]->encode( bEos[iViewIdx], m_cListPicYuvRecMap[iViewIdx], pcBitstream, bThisViewContinueReadingPics );
704      bContinueReadingPics[iViewIdx]=bThisViewContinueReadingPics;
705      bAllContinueReadingPics = bAllContinueReadingPics||bContinueReadingPics[iViewIdx];
706
707      if(pcBitstream->getNumberOfWrittenBits()!=0)
708      {
709        m_cTVideoIOBitsFile.writeBits( pcBitstream );
710      }
711      pcBitstream->resetBits(); //GT: also done later in ....
712      pcBitstream->rewindStreamPacket( );
713      // write bistream to file if necessary
714      xWriteOutput( iViewIdx ); //GT: Write Reconfiles (when gop is complete?)
715
716      if( m_bUsingDepthMaps )
717      {
718#if POZNAN_SYNTH
719        xStoreSynthPicsInBuffer(iViewIdx,true);
720#endif
721        bool bThisViewContinueReadingDepthPics = bContinueReadingDepthPics[iViewIdx];
722        m_acTEncDepthTopList[iViewIdx]->encode( bDepthEos[iViewIdx], m_cListPicYuvDepthRecMap[iViewIdx], pcBitstream, bThisViewContinueReadingDepthPics );
723        bContinueReadingDepthPics[iViewIdx]=bThisViewContinueReadingDepthPics;
724
725        bAllContinueReadingDepthPics = bAllContinueReadingDepthPics||bContinueReadingDepthPics[iViewIdx];
726        if(pcBitstream->getNumberOfWrittenBits()!=0)
727        {
728          m_cTVideoIOBitsFile.writeBits( pcBitstream );
729        }
730        pcBitstream->resetBits();
731        pcBitstream->rewindStreamPacket( );
732        // write bistream to file if necessary
733        xWriteOutput( iViewIdx, true );
734      }
735    }
736
737    // delete extra picture buffers
738    if( bCurrPocCoded )
739    {
740      for( Int iViewIdx = 0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
741      {
742        if( iViewIdx < (Int)m_acTEncTopList.size() && m_acTEncTopList[iViewIdx] )
743        {
744          m_acTEncTopList[iViewIdx]->deleteExtraPicBuffers( iCurrPoc );
745        }
746        if( iViewIdx < (Int)m_acTEncDepthTopList.size() && m_acTEncDepthTopList[iViewIdx] )
747        {
748          m_acTEncDepthTopList[iViewIdx]->deleteExtraPicBuffers( iCurrPoc );
749        }
750      }
751    }
752
753#if AMVP_BUFFERCOMPRESS
754    // compress motion for entire access
755    if( bCurrPocCoded )
756    {
757      for( Int iViewIdx = 0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
758      {
759        if( iViewIdx < (Int)m_acTEncTopList.size() && m_acTEncTopList[iViewIdx] )
760        {
761          m_acTEncTopList[iViewIdx]->compressMotion( iCurrPoc );
762        }
763        if( iViewIdx < (Int)m_acTEncDepthTopList.size() && m_acTEncDepthTopList[iViewIdx] )
764        {
765          m_acTEncDepthTopList[iViewIdx]->compressMotion( iCurrPoc );
766        }
767      }
768    }
769#endif
770  }
771
772  // write output
773  for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
774  {
775    m_acTEncTopList[iViewIdx]->printOutSummary(m_acTEncTopList[iViewIdx]->getNumAllPicCoded());
776    if ( m_bUsingDepthMaps )
777    {
778      m_acTEncDepthTopList[iViewIdx]->printOutSummary(m_acTEncDepthTopList[iViewIdx]->getNumAllPicCoded());
779    }
780  }
781
782  // delete original YUV buffer
783  pcPicYuvOrg->destroy();
784  delete pcPicYuvOrg;
785  pcPicYuvOrg = NULL;
786
787  // valgrind
788  if( m_bUsingDepthMaps)
789  {
790    pcDepthPicYuvOrg->destroy();
791  }
792  delete pcDepthPicYuvOrg ;
793  pcDepthPicYuvOrg = NULL ;
794
795  pcBitstream->destroy();
796  delete pcBitstream;
797  pcBitstream = NULL ;
798
799
800  // delete used buffers in encoder class
801  for(Int iViewIdx =0; iViewIdx < m_iNumberOfViews; iViewIdx++)
802  {
803    m_acTEncTopList[iViewIdx]->deletePicBuffer() ;
804  }
805
806  if( m_bUsingDepthMaps)
807  {
808    for(Int iViewIdx =0; iViewIdx < m_iNumberOfViews; iViewIdx++)
809    {
810      m_acTEncDepthTopList[iViewIdx]->deletePicBuffer() ;
811    }
812  }
813
814  if ( pcPdmDepthOrg )
815  {
816    pcPdmDepthOrg->destroy();
817    delete pcPdmDepthOrg;
818    pcPdmDepthOrg = NULL;
819  }
820
821  // delete buffers & classes
822  xDeleteBuffer();
823  xDestroyLib();
824}
825
826// ====================================================================================================================
827// Protected member functions
828// ====================================================================================================================
829
830/**
831 - application has picture buffer list with size of GOP
832 - picture buffer list acts as ring buffer
833 - end of the list has the latest picture
834 .
835 */
836Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, Int iViewIdx, std::vector< TComList<TComPicYuv*>*>& racBuffer )
837{
838  if ( m_uiCodedPictureStoreSize   == 0 )
839    {
840      if (racBuffer[iViewIdx]->size() == 0)
841      {
842        rpcPicYuvRec = new TComPicYuv;
843        rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
844
845        racBuffer[iViewIdx]->pushBack( rpcPicYuvRec );
846      }
847      rpcPicYuvRec = racBuffer[iViewIdx]->popFront(); //GT why? only one in list ?? A: only to get rpcPicYuvRec
848      racBuffer[iViewIdx]->pushBack( rpcPicYuvRec );
849      return;
850    }
851
852    // org. buffer
853  if ( racBuffer[iViewIdx]->size() == (UInt)m_uiCodedPictureStoreSize )
854    {
855      rpcPicYuvRec = racBuffer[iViewIdx]->popFront();
856    }
857    else
858    {
859      rpcPicYuvRec = new TComPicYuv;
860      rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
861    }
862    racBuffer[iViewIdx]->pushBack( rpcPicYuvRec );
863}
864
865Void TAppEncTop::xDeleteBuffer( )
866{
867  TComList<TComBitstream*>::iterator iterBitstream = m_cListBitstream.begin();
868
869  Int iSize = Int( m_cListBitstream.size() );
870
871  for ( Int i = 0; i < iSize; i++ )
872  {
873    TComBitstream* pcBitstream = *(iterBitstream++);
874
875    pcBitstream->destroy();
876
877    delete pcBitstream; pcBitstream = NULL;
878  }
879
880  for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
881  {
882    TComList<TComPicYuv*>::iterator iterPicYuvRec  = m_cListPicYuvRecList[iViewIdx]->begin();
883
884    iSize = Int( m_cListPicYuvRecList[iViewIdx]->size() );
885
886    for ( Int i = 0; i < iSize; i++ )
887    {
888        TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
889        pcPicYuvRec->destroy();
890        delete pcPicYuvRec; pcPicYuvRec = NULL;
891    }
892  }
893  if( m_bUsingDepthMaps)
894  {
895    for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
896    {
897      TComList<TComPicYuv*>::iterator iterPicYuvRec  = m_cListPicYuvDepthRecList[iViewIdx]->begin();
898
899      iSize = Int( m_cListPicYuvDepthRecList[iViewIdx]->size() );
900
901      for ( Int i = 0; i < iSize; i++ )
902      {
903          TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
904          pcPicYuvRec->destroy();
905          delete pcPicYuvRec; pcPicYuvRec = NULL;
906      }
907    }
908  }
909
910  // Delete ERFiles
911
912#if HHI_VSO
913  std::map< Int,vector<TComPicYuv*> >::iterator iterMapPicExtRefView = m_cMapPicExtRefView.begin();
914  while ( iterMapPicExtRefView != m_cMapPicExtRefView.end() )
915  {
916    for ( UInt uiViewNumber = 0; uiViewNumber < iterMapPicExtRefView->second.size(); uiViewNumber++ )
917    {
918      if ( iterMapPicExtRefView->second[uiViewNumber] )
919      {
920        iterMapPicExtRefView->second[uiViewNumber]->destroy();
921        delete iterMapPicExtRefView->second[uiViewNumber];
922      }
923    }
924    iterMapPicExtRefView++;
925  }
926#endif
927}
928
929/** \param iNumEncoded  number of encoded frames
930 */
931Void TAppEncTop::xWriteOutput( Int iViewIdx, Bool isDepth )
932{
933  std::map<PicOrderCnt, TComPicYuv*> &rcMap = ( isDepth ? m_cListPicYuvDepthRecMap          : m_cListPicYuvRecMap          )[iViewIdx];
934  PicOrderCnt  &riNextPocToDump             = ( isDepth ? m_aiNextDepthPocToDump            : m_aiNextPocToDump            )[iViewIdx];
935  TVideoIOYuv* &rpcTVideoIOYuvReconFile     = ( isDepth ? m_acTVideoIOYuvDepthReconFileList : m_acTVideoIOYuvReconFileList )[iViewIdx];
936  std::map<PicOrderCnt, TComPicYuv*>::iterator i;
937
938  while( ! rcMap.empty() && ( i = rcMap.begin() )->first == riNextPocToDump )
939  {
940    riNextPocToDump++;
941    rpcTVideoIOYuvReconFile->write( i->second, m_aiPad );
942    rcMap.erase( i );
943  }
944}
945
946// GT FIX
947std::vector<TComPic*> TAppEncTop::getSpatialRefPics( Int iViewIdx, Int iPoc, Bool bIsDepthCoder )
948{
949  std::vector<TComPic*> apcRefPics( iViewIdx, (TComPic*)NULL );
950  for( int iRefViewIdx = 0; iRefViewIdx < iViewIdx; iRefViewIdx++ )
951  {
952// GT FIX
953    TComPic* pcRefPic = xGetPicFromView(iRefViewIdx, iPoc, bIsDepthCoder);
954
955    assert( pcRefPic != NULL );
956    apcRefPics[iRefViewIdx] = pcRefPic;
957  }
958  return apcRefPics;
959}
960
961
962TComPic* TAppEncTop::xGetPicFromView( Int iViewIdx, Int iPoc, bool bDepth )
963{
964  assert( ( iViewIdx >= 0) && ( iViewIdx < m_iNumberOfViews ) );
965
966  TComPic* pcPic = 0;
967  TComList<TComPic*>* apcListPic;
968
969  apcListPic = (bDepth ?  m_acTEncDepthTopList[iViewIdx] : m_acTEncTopList[iViewIdx])->getListPic() ;
970
971  for(TComList<TComPic*>::iterator it=apcListPic->begin(); it!=apcListPic->end(); it++)
972  {
973    if( (*it)->getPOC() == iPoc )
974    {
975      pcPic = *it ;
976      break ;
977    }
978  }
979
980  return pcPic;
981};
982
983TComPicYuv* TAppEncTop::xGetPicYuvFromView( Int iViewIdx, Int iPoc, Bool bDepth, Bool bRecon )
984{
985  TComPic*    pcPic = xGetPicFromView( iViewIdx, iPoc, bDepth);
986  TComPicYuv* pcPicYuv = NULL;
987
988  if (pcPic != NULL)
989  {
990    if( bRecon )
991    {
992      if ( pcPic->getReconMark() )
993      {
994        pcPicYuv = pcPic->getPicYuvRec();
995      }
996    }
997    else
998    {
999      pcPicYuv = pcPic->getPicYuvOrg();
1000    }
1001  };
1002
1003  return pcPicYuv;
1004};
1005
1006#if HHI_VSO
1007Void TAppEncTop::xSetBasePicYuv( Int iViewIdx, Int iPoc, TComMVDRefData* pcRefInfo, InterViewReference eView, bool bDepth )
1008{
1009
1010  if ( ( iViewIdx < 0) || ( iViewIdx >= m_iNumberOfViews ) )
1011    return;
1012
1013  if ( !m_bUsingDepthMaps && bDepth )
1014    return;
1015
1016  TComPic* pcPic = xGetPicFromView( iViewIdx, iPoc, bDepth);
1017
1018  if (pcPic == 0)
1019    return;
1020
1021  pcRefInfo->setPicYuvBaseView(eView, bDepth, pcPic->getPicYuvOrg(),  pcPic->getReconMark() ? pcPic->getPicYuvRec() : NULL );
1022
1023};
1024
1025Void TAppEncTop::setMVDPic( Int iViewIdx, Int iPoc, TComMVDRefData* pcMVDRefData )
1026{
1027  AOF( iViewIdx >= 0);
1028  AOF( iViewIdx <  m_iNumberOfViews  );
1029
1030  xSetBasePicYuv(iViewIdx - 1, iPoc, pcMVDRefData, PREVVIEW, false);
1031  xSetBasePicYuv(iViewIdx    , iPoc, pcMVDRefData, CURRVIEW, false );
1032  xSetBasePicYuv(iViewIdx + 1, iPoc, pcMVDRefData, NEXTVIEW, false );
1033
1034  if ( m_bUsingDepthMaps )
1035  {
1036    xSetBasePicYuv(iViewIdx - 1, iPoc, pcMVDRefData, PREVVIEW, true );
1037    xSetBasePicYuv(iViewIdx    , iPoc, pcMVDRefData, CURRVIEW, true );
1038    xSetBasePicYuv(iViewIdx + 1, iPoc, pcMVDRefData, NEXTVIEW, true );
1039  }
1040
1041
1042  xSetBaseLUT       (iViewIdx, iViewIdx-1  , pcMVDRefData, PREVVIEW );
1043  xSetBaseLUT       (iViewIdx, iViewIdx+1  , pcMVDRefData, NEXTVIEW );
1044
1045
1046  if ( m_bUseVSO && m_uiVSOMode != 4)
1047  {
1048    xSetERPicYuvs               (iViewIdx, iPoc, pcMVDRefData);
1049    pcMVDRefData->setShiftLUTsERView(m_cCameraData.getSynthViewShiftLUTD()[iViewIdx],  m_cCameraData.getSynthViewShiftLUTI()[iViewIdx] );
1050    pcMVDRefData->setRefViewInd     (m_aaiBaseViewRefInd[iViewIdx], m_aaiERViewRefInd[iViewIdx], m_aaiERViewRefLutInd[iViewIdx]);
1051  }
1052};
1053
1054
1055Void TAppEncTop::xSetBaseLUT( Int iViewIdxSource, Int iViewIdxTarget, TComMVDRefData* pcRefInfo, InterViewReference eView )
1056{
1057  if ( ( iViewIdxSource < 0) || ( iViewIdxSource >= m_iNumberOfViews )||( iViewIdxTarget < 0) || ( iViewIdxTarget >= m_iNumberOfViews ) )
1058    return;
1059  assert( abs( iViewIdxTarget - iViewIdxSource ) <= 1 );  //GT; Not supported yet
1060  pcRefInfo->setShiftLUTsBaseView(eView, m_cCameraData.getBaseViewShiftLUTD()[iViewIdxSource][iViewIdxTarget],m_cCameraData.getBaseViewShiftLUTI()[iViewIdxSource][iViewIdxTarget] );
1061};
1062
1063Void TAppEncTop::xSetERPicYuvs( Int iViewIdx, Int iPoc, TComMVDRefData* pcReferenceInfo )
1064{
1065  std::vector<TComPicYuv*> apcExtRefViews;
1066
1067  std::map< Int, vector<TComPicYuv*> >::iterator cMapIt;
1068  cMapIt = m_cMapPicExtRefView.find(iPoc);
1069
1070  assert(  cMapIt != m_cMapPicExtRefView.end() );
1071
1072  pcReferenceInfo->setPicYuvERViews( cMapIt->second );
1073}
1074
1075Void TAppEncTop::xStoreVSORefPicsInBuffer()
1076{
1077  // X-Check if all Encoders have received the same number of pics
1078  Int iNumRcvd = m_iFrameRcvdVector[0];
1079  for ( UInt uiViewNumber = 0; uiViewNumber < m_iNumberOfViews; uiViewNumber ++ )
1080  {
1081    assert( ( m_iFrameRcvdVector[uiViewNumber] == iNumRcvd ) && ( m_iDepthFrameRcvdVector[uiViewNumber] == iNumRcvd ) ); //GT; if assert here, the encoder instances are not synchronized any more, re-think this function and the ERView Buffer!!
1082  };
1083
1084  Int iCurPoc = iNumRcvd - 1;
1085
1086  if ( iCurPoc <= m_iLastFramePutInERViewBuffer )
1087  {
1088    return;
1089  }
1090
1091  std::vector<TComPicYuv*> apcExtRefViewVec;
1092
1093  Int iNumberOfReferenceViews = 0;
1094  if (m_iNumberOfExternalRefs != 0)
1095  {
1096    m_aaiERViewRefLutInd = m_aaiERViewRefInd;
1097    // Insert Rendered Views form File
1098
1099    iNumberOfReferenceViews = m_iNumberOfExternalRefs;
1100
1101    for ( UInt uiViewNumber = 0; uiViewNumber < iNumberOfReferenceViews; uiViewNumber++ )
1102    {
1103      TComPicYuv* pcPicYuvERView = new TComPicYuv;
1104      pcPicYuvERView->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
1105
1106      m_acTVideoIOYuvERFileList[uiViewNumber]->read( pcPicYuvERView, m_aiPad  ) ;
1107
1108      apcExtRefViewVec.push_back( pcPicYuvERView );
1109    }
1110  }
1111  else
1112  { //Render Views
1113
1114    for ( UInt uiViewNumber = 0; uiViewNumber < m_iNumberOfViews; uiViewNumber++ )
1115    {
1116      m_aaiERViewRefInd   [uiViewNumber].clear();
1117      m_aaiERViewRefLutInd[uiViewNumber].clear();
1118    }
1119
1120    iNumberOfReferenceViews = 0;
1121    for ( UInt iSynthViewIdx = 0; iSynthViewIdx < m_cCameraData.getSynthViewNumbers().size(); iSynthViewIdx++ )
1122    {
1123      // Get Left and right view
1124      Int  iLeftViewIdx  = -1;
1125      Int  iRightViewIdx = -1;
1126      Bool bIsBaseView;
1127
1128      Int iRelDistToLeft;
1129      m_cCameraData.getLeftRightBaseView( iSynthViewIdx, iLeftViewIdx, iRightViewIdx, iRelDistToLeft, bIsBaseView );
1130
1131      if  ((iLeftViewIdx == -1) || (iRightViewIdx == -1))
1132      {
1133        std::cerr << "Left or right View not given." << endl;
1134        exit(EXIT_FAILURE);
1135      }
1136
1137      m_cRendererTop.setShiftLUTs(
1138        m_cCameraData.getSynthViewShiftLUTD()[iLeftViewIdx] [iSynthViewIdx],
1139        m_cCameraData.getSynthViewShiftLUTI()[iLeftViewIdx] [iSynthViewIdx],
1140        m_cCameraData.getBaseViewShiftLUTI ()[iLeftViewIdx] [iRightViewIdx],
1141        m_cCameraData.getSynthViewShiftLUTD()[iRightViewIdx][iSynthViewIdx],
1142        m_cCameraData.getSynthViewShiftLUTI()[iRightViewIdx][iSynthViewIdx],
1143        m_cCameraData.getBaseViewShiftLUTI ()[iRightViewIdx][iLeftViewIdx],
1144        iRelDistToLeft
1145      );
1146      if ( bIsBaseView ) continue;
1147
1148      // Render from left
1149      TComPicYuv* pcPicYuvERView = new TComPicYuv;
1150      pcPicYuvERView->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
1151      m_cRendererTop.extrapolateView( xGetPicFromView( iLeftViewIdx, iCurPoc, false )->getPicYuvOrg(), xGetPicFromView( iLeftViewIdx, iCurPoc, true )->getPicYuvOrg(), pcPicYuvERView, true );
1152
1153      apcExtRefViewVec.push_back( pcPicYuvERView );
1154
1155      m_aaiERViewRefInd   [ iLeftViewIdx].push_back( iNumberOfReferenceViews );
1156      m_aaiERViewRefLutInd[ iLeftViewIdx].push_back( iSynthViewIdx );
1157      iNumberOfReferenceViews++;
1158
1159      //Render from right
1160      pcPicYuvERView = new TComPicYuv;
1161      pcPicYuvERView->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
1162
1163      m_cRendererTop.extrapolateView( xGetPicFromView( iRightViewIdx, iCurPoc, false )->getPicYuvOrg(), xGetPicFromView( iRightViewIdx, iCurPoc, true )->getPicYuvOrg(), pcPicYuvERView, false );
1164      apcExtRefViewVec.push_back( pcPicYuvERView );
1165
1166      m_aaiERViewRefInd   [ iRightViewIdx].push_back( iNumberOfReferenceViews );
1167      m_aaiERViewRefLutInd[ iRightViewIdx].push_back( iSynthViewIdx );
1168      iNumberOfReferenceViews++;
1169    }
1170  }
1171
1172  m_iLastFramePutInERViewBuffer++;
1173  m_cMapPicExtRefView.insert( std::make_pair( m_iLastFramePutInERViewBuffer, apcExtRefViewVec ) );
1174
1175  if ( m_cMapPicExtRefView.size() >  (UInt)m_iGOPSize + 1 )
1176  {
1177    for ( UInt uiViewNumber = 0; uiViewNumber < (UInt) m_cMapPicExtRefView.begin()->second.size(); uiViewNumber++ )
1178    {
1179      if ( m_cMapPicExtRefView.begin()->second[uiViewNumber] )
1180      {
1181        m_cMapPicExtRefView.begin()->second[uiViewNumber]->destroy();
1182        delete m_cMapPicExtRefView.begin()->second[uiViewNumber];
1183      }
1184    }
1185    m_cMapPicExtRefView.erase ( m_cMapPicExtRefView.begin() );
1186  }
1187}
1188#endif
1189
1190#if POZNAN_SYNTH
1191Void TAppEncTop::xStoreSynthPicsInBuffer(Int iCoddedViewIdx,Bool bDepth)
1192{
1193  Int iCurPoc;
1194  if(bDepth)
1195  {
1196    iCurPoc = m_acTEncDepthTopList[ iCoddedViewIdx ]->getNextFrameId();
1197    if (!(m_acTEncDepthTopList[ iCoddedViewIdx ]->currentPocWillBeCoded())) return;
1198  }
1199  else
1200  {
1201    iCurPoc = m_acTEncTopList[ iCoddedViewIdx ]->getNextFrameId();
1202    if (!(m_acTEncTopList[ iCoddedViewIdx ]->currentPocWillBeCoded())) return;
1203  }
1204 
1205  Int iNumberOfReferenceViews = 0;
1206  UInt iSynthViewIdx;
1207  // Get Left and right view
1208  Int  iLeftViewIdx  = -1;
1209  Int  iRightViewIdx = -1;
1210  Int  iNearestViewIdx = -1;
1211  Bool bIsBaseView;
1212  Bool bRenderFromLeft;
1213
1214  Int iRelDistToLeft;
1215  if(iCoddedViewIdx==0) //First on View Coded List
1216  {
1217    //TComPic* pcPic = xGetPicFromView( iCoddedViewIdx, iCurPoc, false );
1218    return;
1219  }
1220  m_cCameraData.getNearestBaseView(iCoddedViewIdx, iNearestViewIdx, iRelDistToLeft, bRenderFromLeft);
1221
1222  m_cAvailabilityRenderer.setShiftLUTs(
1223    m_cCameraData.getBaseViewShiftLUTD()[iNearestViewIdx][iCoddedViewIdx],
1224    m_cCameraData.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
1225    m_cCameraData.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
1226    m_cCameraData.getBaseViewShiftLUTD()[iNearestViewIdx][iCoddedViewIdx],//right
1227    m_cCameraData.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
1228    m_cCameraData.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
1229    iRelDistToLeft
1230  );
1231   
1232
1233  TComPicYuv* pcPicYuvERView = new TComPicYuv;
1234  pcPicYuvERView->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
1235
1236  TComPic* pcPic = xGetPicFromView( iCoddedViewIdx, iCurPoc, bDepth );
1237  pcPic->addSynthesisBuffer();
1238  pcPic->addAvailabilityBuffer();
1239  TComPicYuv* pcPicYuvSynthView = pcPic->getPicYuvSynth();
1240  TComPicYuv* pcPicYuvAvailView = pcPic->getPicYuvAvail();
1241 
1242  //m_cAvailabilityRenderer.extrapolateAvailabilityView( xGetPicFromView( iNearestViewIdx, iCurPoc, false )->getPicYuvRec(), xGetPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), pcPicYuvERView, pcPicYuvAvailView, bRenderFromLeft );
1243  m_cAvailabilityRenderer.extrapolateAvailabilityView( xGetPicFromView( iNearestViewIdx, iCurPoc, bDepth )->getPicYuvRec(), xGetPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), pcPicYuvSynthView, pcPicYuvAvailView, bRenderFromLeft );
1244     
1245  pcPicYuvAvailView->setBorderExtension( false );//Needed??
1246  pcPicYuvAvailView->extendPicBorder();//Needed??
1247
1248  pcPicYuvSynthView->setBorderExtension( false );//Needed??
1249  pcPicYuvSynthView->extendPicBorder();//Needed??
1250
1251  //TComPic* pcPicDepth = xGetPicFromView( iCoddedViewIdx, iCurPoc, true );
1252  //pcPicDepth->addAvailabilityBuffer();
1253  //pcPicDepth->addSynthesisBuffer();
1254  //pcPicYuvAvailView->copyToPic(pcPicDepth->getPicYuvAvail());
1255     
1256#if POZNAN_OUTPUT_AVAILABLE_MAP
1257  {
1258  Char acFilenameBase[1024];
1259  ::sprintf( acFilenameBase,  "Available_%s_%s_V%d.yuv", (bDepth?"Depth":"Tex"),( false ? "Dec" : "Enc" ),iCoddedViewIdx );
1260  pcPicYuvAvailView->dump(acFilenameBase, iCurPoc!=0);
1261  }
1262#endif
1263#if POZNAN_OUTPUT_SYNTH
1264  {
1265  Char acFilenameBase[1024];
1266  ::sprintf( acFilenameBase,  "Synth_%s_%s_V%d.yuv", (bDepth?"Depth":"Tex"),( false ? "Dec" : "Enc" ),iCoddedViewIdx );
1267  pcPicYuvERView->dump(acFilenameBase, iCurPoc!=0);
1268  }
1269#endif
1270
1271      //Usun pcPicYuvERView i inne bufforki
1272}
1273#endif
1274
1275#if HHI_INTERVIEW_SKIP
1276Void TAppEncTop::getUsedPelsMap( Int iViewIdx, Int iPoc, TComPicYuv* pcPicYuvUsedSplsMap )
1277{
1278  AOT( iViewIdx <= 0);
1279  AOT( iViewIdx >= m_iNumberOfViews );
1280  AOF( m_uiInterViewSkip != 0 );
1281  AOF( m_cCameraData.getCurFrameId() == iPoc );
1282
1283  Int iViewSIdx      = m_cCameraData.getBaseId2SortedId()[iViewIdx];
1284  Int iFirstViewSIdx = m_cCameraData.getBaseId2SortedId()[0];
1285
1286  AOT( iViewSIdx == iFirstViewSIdx );
1287
1288  Bool bFirstIsLeft = (iFirstViewSIdx < iViewSIdx);
1289
1290    m_cUsedPelsRenderer.setShiftLUTs(
1291      m_cCameraData.getBaseViewShiftLUTD()[0][iViewIdx],
1292      m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx],
1293      m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx],
1294      m_cCameraData.getBaseViewShiftLUTD()[0][iViewIdx],
1295      m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx],
1296      m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx],
1297      -1
1298      );
1299
1300
1301  TComPicYuv* pcPicYuvDepth = xGetPicYuvFromView(0, iPoc, true, true );
1302  AOF( pcPicYuvDepth);
1303
1304  m_cUsedPelsRenderer.getUsedSamplesMap( pcPicYuvDepth, pcPicYuvUsedSplsMap, bFirstIsLeft );
1305
1306}
1307#endif
1308
1309#if HHI_VSO
1310Void TAppEncTop::setupRenModel( Int iPoc, Int iEncViewIdx, Int iEncContent )
1311{
1312  Int iEncViewSIdx = m_cCameraData.getBaseId2SortedId()[ iEncViewIdx ];
1313
1314  // setup base views
1315  Int iNumOfBV = m_cRenModStrParser.getNumOfBaseViewsForView( iEncViewSIdx, iEncContent );
1316
1317  for (Int iCurView = 0; iCurView < iNumOfBV; iCurView++ )
1318  {
1319    Int iBaseViewSIdx;
1320    Int iVideoDistMode;
1321    Int iDepthDistMode;
1322
1323    m_cRenModStrParser.getBaseViewData( iEncViewSIdx, iEncContent, iCurView, iBaseViewSIdx, iVideoDistMode, iDepthDistMode );
1324
1325    AOT( iVideoDistMode < 0 || iVideoDistMode > 2 );
1326
1327    Int iBaseViewIdx = m_cCameraData.getBaseSortedId2Id()[ iBaseViewSIdx ];
1328
1329    TComPicYuv* pcPicYuvVideoRec  = xGetPicYuvFromView( iBaseViewIdx, iPoc, false, true  );
1330    TComPicYuv* pcPicYuvDepthRec  = xGetPicYuvFromView( iBaseViewIdx, iPoc, true , true  );
1331    TComPicYuv* pcPicYuvVideoOrg  = xGetPicYuvFromView( iBaseViewIdx, iPoc, false, false );
1332    TComPicYuv* pcPicYuvDepthOrg  = xGetPicYuvFromView( iBaseViewIdx, iPoc, true , false );
1333
1334    TComPicYuv* pcPicYuvVideoRef  = ( iVideoDistMode == 2 ) ? pcPicYuvVideoOrg  : NULL;
1335    TComPicYuv* pcPicYuvDepthRef  = ( iDepthDistMode == 2 ) ? pcPicYuvDepthOrg  : NULL;
1336
1337    TComPicYuv* pcPicYuvVideoTest = ( iVideoDistMode == 0 ) ? pcPicYuvVideoOrg  : pcPicYuvVideoRec;
1338    TComPicYuv* pcPicYuvDepthTest = ( iDepthDistMode == 0 ) ? pcPicYuvDepthOrg  : pcPicYuvDepthRec;
1339
1340    AOT( (iVideoDistMode == 2) != (pcPicYuvVideoRef != NULL) );
1341    AOT( (iDepthDistMode == 2) != (pcPicYuvDepthRef != NULL) );
1342    AOT( pcPicYuvDepthTest == NULL );
1343    AOT( pcPicYuvVideoTest == NULL );
1344
1345    m_cRendererModel.setBaseView( iBaseViewSIdx, pcPicYuvVideoTest, pcPicYuvDepthTest, pcPicYuvVideoRef, pcPicYuvDepthRef );
1346  }
1347
1348  m_cRendererModel.setErrorMode( iEncViewSIdx, iEncContent, 0 );
1349  // setup virtual views
1350  Int iNumOfSV  = m_cRenModStrParser.getNumOfModelsForView( iEncViewSIdx, iEncContent );
1351  for (Int iCurView = 0; iCurView < iNumOfSV; iCurView++ )
1352  {
1353    Int iOrgRefBaseViewSIdx;
1354    Int iLeftBaseViewSIdx;
1355    Int iRightBaseViewSIdx;
1356    Int iSynthViewRelNum;
1357    Int iModelNum;
1358    Int iBlendMode;
1359    m_cRenModStrParser.getSingleModelData(iEncViewSIdx, iEncContent, iCurView, iModelNum, iBlendMode,iLeftBaseViewSIdx, iRightBaseViewSIdx, iOrgRefBaseViewSIdx, iSynthViewRelNum );
1360
1361    Int iLeftBaseViewIdx    = -1;
1362    Int iRightBaseViewIdx   = -1;
1363
1364    TComPicYuv* pcPicYuvOrgRef  = NULL;
1365    Int**      ppiShiftLUTLeft  = NULL;
1366    Int**      ppiShiftLUTRight = NULL;
1367    Int**      ppiBaseShiftLUTLeft  = NULL;
1368    Int**      ppiBaseShiftLUTRight = NULL;
1369
1370
1371    Int        iDistToLeft      = -1;
1372
1373    Int iSynthViewIdx = m_cCameraData.synthRelNum2Idx( iSynthViewRelNum );
1374
1375    if ( iLeftBaseViewSIdx != -1 )
1376    {
1377      iLeftBaseViewIdx   = m_cCameraData.getBaseSortedId2Id()   [ iLeftBaseViewSIdx ];
1378      ppiShiftLUTLeft    = m_cCameraData.getSynthViewShiftLUTI()[ iLeftBaseViewIdx  ][ iSynthViewIdx  ];
1379    }
1380
1381    if ( iRightBaseViewSIdx != -1 )
1382    {
1383      iRightBaseViewIdx  = m_cCameraData.getBaseSortedId2Id()   [iRightBaseViewSIdx ];
1384      ppiShiftLUTRight   = m_cCameraData.getSynthViewShiftLUTI()[ iRightBaseViewIdx ][ iSynthViewIdx ];
1385    }
1386
1387    if ( iRightBaseViewSIdx != -1 && iLeftBaseViewSIdx != -1 )
1388    {
1389      iDistToLeft    = m_cCameraData.getRelDistLeft(  iSynthViewIdx , iLeftBaseViewIdx, iRightBaseViewIdx);
1390      ppiBaseShiftLUTLeft  = m_cCameraData.getBaseViewShiftLUTI() [ iLeftBaseViewIdx  ][ iRightBaseViewIdx ];
1391      ppiBaseShiftLUTRight = m_cCameraData.getBaseViewShiftLUTI() [ iRightBaseViewIdx ][ iLeftBaseViewIdx  ];
1392
1393    }
1394
1395    if ( iOrgRefBaseViewSIdx != -1 )
1396    {
1397      pcPicYuvOrgRef = xGetPicYuvFromView( m_cCameraData.getBaseSortedId2Id()[ iOrgRefBaseViewSIdx ] , iPoc, false, false );
1398      AOF ( pcPicYuvOrgRef );
1399    }
1400
1401    m_cRendererModel.setSingleModel( iModelNum, ppiShiftLUTLeft, ppiBaseShiftLUTLeft, ppiShiftLUTRight, ppiBaseShiftLUTRight, iDistToLeft, pcPicYuvOrgRef );
1402  }
1403}
1404#endif
1405
Note: See TracBrowser for help on using the repository browser.