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

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

SVN merge bug Fix

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