source: 3DVCSoftware/branches/0.3-poznan-univ/source/App/TAppEncoder/TAppEncTop.cpp @ 28

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

Poznan Tools

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