source: 3DVCSoftware/branches/0.2-poznan-univ/source/App/TAppDecoder/TAppDecTop.cpp @ 28

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

Poznan Tools

  • Depth base motion vector prediction
  • Property svn:eol-style set to native
File size: 22.9 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     TAppDecTop.cpp
37    \brief    Decoder application class
38*/
39
40#include <list>
41#include <stdio.h>
42#include <fcntl.h>
43#include <assert.h>
44
45#include "TAppDecTop.h"
46
47// ====================================================================================================================
48// Local constants
49// ====================================================================================================================
50
51/// initial bitstream buffer size
52/// should be large enough for parsing SPS
53/// resized as a function of picture size after parsing SPS
54#define BITS_BUF_SIZE 65536
55
56// ====================================================================================================================
57// Constructor / destructor / initialization / destroy
58// ====================================================================================================================
59
60TAppDecTop::TAppDecTop()
61{
62  ::memset (m_abDecFlag, 0, sizeof (m_abDecFlag));
63  m_bUsingDepth = false;
64//  m_iPOCLastDisplay  = -1;
65  m_pScaleOffsetFile  = 0;
66
67#if POZNAN_MP
68  m_pcMP = NULL;
69#endif
70}
71
72Void TAppDecTop::create()
73{
74  m_apcBitstream  = new TComBitstream;
75 
76  m_apcBitstream->create( BITS_BUF_SIZE );
77
78#if POZNAN_MP
79  m_pcMP = new TComMP();
80#endif
81}
82
83Void TAppDecTop::destroy()
84{
85  if ( m_apcBitstream )
86  {
87    m_apcBitstream->destroy();
88    delete m_apcBitstream;
89    m_apcBitstream = NULL;
90  }
91  if( m_pchBitstreamFile )
92  {
93    free(m_pchBitstreamFile);
94  }
95  if( m_pchReconFile )
96  {
97    free(m_pchReconFile);
98  }
99
100#if POZNAN_MP
101  if(m_pcMP) { delete m_pcMP; m_pcMP = NULL; };
102#endif
103}
104
105// ====================================================================================================================
106// Public member functions
107// ====================================================================================================================
108
109/**
110 - create internal class
111 - initialize internal class
112 - until the end of the bitstream, call decoding function in TDecTop class
113 - delete allocated buffers
114 - destroy internal class
115 .
116 */
117Void TAppDecTop::decode()
118{
119  TComBitstream*      pcBitstream = m_apcBitstream;
120  UInt                uiPOC;
121  TComList<TComPic*>* pcListPic;
122  Bool bFirstSliceDecoded = true;
123
124  // create & initialize internal classes
125  xCreateDecLib();
126  xInitDecLib  ();
127#if DCM_SKIP_DECODING_FRAMES
128//  m_iPOCLastDisplay += m_iSkipFrame;      // set the last displayed POC correctly for skip forward.
129#endif
130
131  // main decoder loop
132  Bool  bEos        = false;
133  Bool resizedBitstreamBuffer = false;
134 
135  Bool bIsDepth = false;
136  Int iViewIdx = 0;
137  TComSPS cComSPS ;
138  NalUnitType eNalUnitType;
139
140 
141  while ( !bEos )
142  {
143    streampos  lLocation = m_cTVideoIOBitstreamFile.getFileLocation();
144    bEos                 = m_cTVideoIOBitstreamFile.readBits( pcBitstream );
145    if (bEos)
146    {
147      //if (!bFirstSliceDecoded) m_cTDecTop.decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_iPOCLastDisplay);
148      if( bIsDepth )
149      {
150        if (!bFirstSliceDecoded) m_acTDecDepthTopList[iViewIdx]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiDepthPOCLastDisplayList[iViewIdx] );
151        m_acTDecDepthTopList[iViewIdx]->executeDeblockAndAlf( bEos, pcBitstream, uiPOC, pcListPic, m_iSkipFrame, m_aiDepthPOCLastDisplayList[iViewIdx]);
152      }
153      else
154      {
155        if (!bFirstSliceDecoded) m_acTDecTopList[iViewIdx]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiPOCLastDisplayList[iViewIdx] );
156        m_acTDecTopList[iViewIdx]->executeDeblockAndAlf( bEos, pcBitstream, uiPOC, pcListPic, m_iSkipFrame, m_aiPOCLastDisplayList[iViewIdx]);
157      }
158      if( pcListPic )
159      {
160        // write reconstuction to file
161        xWriteOutput( pcListPic );
162      }
163      break;
164    }
165   
166    // call actual decoding function
167#if DCM_SKIP_DECODING_FRAMES
168    Bool bNewPicture;
169    if( bIsDepth )
170      bNewPicture = m_acTDecDepthTopList[iViewIdx]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiDepthPOCLastDisplayList[iViewIdx] );
171    else
172      bNewPicture = m_acTDecTopList[iViewIdx]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiPOCLastDisplayList[iViewIdx] );
173    bFirstSliceDecoded   = true;
174
175    if( eNalUnitType == NAL_UNIT_SPS )
176    {
177#if POZNAN_CU_SKIP||POZNAN_CU_SYNTH
178      if(cComSPS.getViewId()==0 && !cComSPS.isDepth()) // it should be called at first view at the begining of the stream
179        initRenderer(cComSPS);
180#endif
181      if( cComSPS.isDepth() && (m_bUsingDepth==false) )  // expected not using depth, but bitstream are using depth
182      {                                                     // know from sps
183        assert( cComSPS.getViewId() == 0 && iViewIdx == 0 && !bIsDepth );
184        startUsingDepth() ;
185      }
186      if( cComSPS.isDepth() && !bIsDepth )
187      {
188        assert( cComSPS.getViewId() == iViewIdx );
189        m_acTDecDepthTopList[iViewIdx]->setSPS(cComSPS);
190      }
191      else if( cComSPS.getViewId() >= m_acTVideoIOYuvReconFileList.size() ) // expecting iViewIdx, but got cComSPS.getViewIdx()
192      {
193        assert( cComSPS.getViewId() == m_acTVideoIOYuvReconFileList.size() );
194        assert( !cComSPS.isDepth() );
195        increaseNumberOfViews(cComSPS.getViewId()+1);
196        m_acTDecTopList[cComSPS.getViewId()]->setSPS(cComSPS);
197      }
198      bEos = m_cTVideoIOBitstreamFile.readBits( pcBitstream );
199      assert( !bEos);
200      if( cComSPS.isDepth() )
201        m_acTDecDepthTopList[cComSPS.getViewId()]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiDepthPOCLastDisplayList[cComSPS.getViewId()]); // decode PPS
202      else
203        m_acTDecTopList[cComSPS.getViewId()]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiPOCLastDisplayList[cComSPS.getViewId()]); // decode PPS
204      assert( eNalUnitType == NAL_UNIT_PPS );
205    }
206    assert( eNalUnitType != NAL_UNIT_SEI ); // not yet supported for MVC
207    if (bNewPicture)
208    {
209      if( bIsDepth )
210        m_acTDecDepthTopList[iViewIdx]->executeDeblockAndAlf( bEos, pcBitstream, uiPOC, pcListPic, m_iSkipFrame, m_aiDepthPOCLastDisplayList[iViewIdx]);
211      else
212        m_acTDecTopList[iViewIdx]->executeDeblockAndAlf( bEos, pcBitstream, uiPOC, pcListPic, m_iSkipFrame, m_aiPOCLastDisplayList[iViewIdx]);
213      if (!m_cTVideoIOBitstreamFile.good()) m_cTVideoIOBitstreamFile.clear();
214      m_cTVideoIOBitstreamFile.setFileLocation( lLocation );
215      bFirstSliceDecoded = false;
216
217      if( m_bUsingDepth && !bIsDepth )
218      {
219        bIsDepth = true;
220      }
221      else
222      {
223        bIsDepth = false;
224        if( iViewIdx<m_acTDecTopList.size()-1)
225        {
226          iViewIdx++ ;
227        }
228        else
229        {
230          iViewIdx = 0;
231
232          // end of access unit: delete extra pic buffers
233          Int iNumViews = (Int)m_acTVideoIOYuvReconFileList.size();
234          for( Int iVId = 0; iVId < iNumViews; iVId++ )
235          {
236            if( iVId < (Int)m_acTDecTopList.size() &&  m_acTDecTopList[iVId] )
237            {
238              m_acTDecTopList[iVId]->deleteExtraPicBuffers( (Int)uiPOC );
239            }
240            if( iVId < (Int)m_acTDecDepthTopList.size() && m_acTDecDepthTopList[iVId] )
241            {
242              m_acTDecDepthTopList[iVId]->deleteExtraPicBuffers( (Int)uiPOC );
243            }
244          }
245
246#if AMVP_BUFFERCOMPRESS
247          // compress motion for entire access unit
248          for( Int iVId = 0; iVId < iNumViews; iVId++ )
249          {
250            if( iVId < (Int)m_acTDecTopList.size() &&  m_acTDecTopList[iVId] )
251            {
252              m_acTDecTopList[iVId]->compressMotion( (Int)uiPOC );
253            }
254            if( iVId < (Int)m_acTDecDepthTopList.size() && m_acTDecDepthTopList[iVId] )
255            {
256              m_acTDecDepthTopList[iVId]->compressMotion( (Int)uiPOC );
257            }
258          }
259#endif
260        }
261      }
262    }
263#else
264#error
265    m_cTDecTop.decode( bEos, pcBitstream, uiPOC, pcListPic );
266#endif
267
268   
269    if (!resizedBitstreamBuffer)
270    {
271      TComSPS *sps = m_acTDecTopList[0]->getSPS();
272      if (sps)
273      {
274        pcBitstream->destroy();
275        pcBitstream->create(sps->getWidth() * sps->getHeight() * 2);
276        resizedBitstreamBuffer = true;
277      }
278    }
279   
280    if( pcListPic )
281    {
282      // write reconstuction to file
283      xWriteOutput( pcListPic );
284    }
285  }
286 
287  // delete buffers
288  for(Int i=0; i<m_acTDecTopList.size(); i++)
289    m_acTDecTopList[i]->deletePicBuffer();
290
291  if (m_bUsingDepth)
292  {
293    for(Int i=0; i<m_acTDecDepthTopList.size(); i++)
294      m_acTDecDepthTopList[i]->deletePicBuffer();
295  }
296 
297  // destroy internal classes
298  xDestroyDecLib();
299}
300
301// ====================================================================================================================
302// Protected member functions
303// ====================================================================================================================
304
305Void TAppDecTop::xCreateDecLib()
306{
307  // open bitstream file
308  m_cTVideoIOBitstreamFile.openBits( m_pchBitstreamFile, false);  // read mode
309
310  // create decoder class
311//  m_cTDecTop.create();
312  m_acTDecTopList.push_back(new TDecTop) ;// at least one decoder
313  m_acTDecTopList[0]->create() ;
314
315  m_aiPOCLastDisplayList.push_back(-1+m_iSkipFrame) ;
316
317  if( m_pchScaleOffsetFile ) 
318  { 
319    m_pScaleOffsetFile = ::fopen( m_pchScaleOffsetFile, "wt" ); 
320    AOF( m_pScaleOffsetFile ); 
321  }
322  m_cCamParsCollector.init( m_pScaleOffsetFile );
323}
324
325Void TAppDecTop::xDestroyDecLib()
326{
327  // close bitstream file
328  m_cTVideoIOBitstreamFile.closeBits();
329
330  for(Int iViewIdx=0; iViewIdx<m_acTVideoIOYuvReconFileList.size() ; iViewIdx++)
331  {
332    m_acTVideoIOYuvReconFileList[iViewIdx]->close();
333    delete m_acTVideoIOYuvReconFileList[iViewIdx]; m_acTVideoIOYuvReconFileList[iViewIdx] = NULL ;
334  }
335
336  // destroy decoder class
337//  m_cTDecTop.destroy();
338  for(Int iViewIdx=0; iViewIdx<m_acTDecTopList.size() ; iViewIdx++)
339  {
340    m_acTDecTopList[iViewIdx]->destroy() ;
341    delete m_acTDecTopList[iViewIdx] ; m_acTDecTopList[iViewIdx] = NULL ;
342  }
343
344  for(Int iViewIdx=0; iViewIdx<m_acTVideoIOYuvDepthReconFileList.size() ; iViewIdx++)
345  {
346    m_acTVideoIOYuvDepthReconFileList[iViewIdx]->close();
347    delete m_acTVideoIOYuvDepthReconFileList[iViewIdx]; m_acTVideoIOYuvDepthReconFileList[iViewIdx] = NULL ;
348  }
349
350  for(Int iViewIdx=0; iViewIdx<m_acTDecDepthTopList.size() ; iViewIdx++)
351  {
352    m_acTDecDepthTopList[iViewIdx]->destroy() ;
353    delete m_acTDecDepthTopList[iViewIdx] ; m_acTDecDepthTopList[iViewIdx] = NULL ;
354  }
355
356  m_cCamParsCollector.uninit();
357  if( m_pScaleOffsetFile ) 
358  { 
359    ::fclose( m_pScaleOffsetFile ); 
360  }
361}
362
363Void TAppDecTop::xInitDecLib()
364{
365  // initialize decoder class
366  m_acTDecTopList[0]->init( this );
367  m_acTDecTopList[0]->setViewIdx(0);
368  m_acTDecTopList[0]->setPictureDigestEnabled(m_pictureDigestEnabled);
369  m_acTDecTopList[0]->setCamParsCollector( &m_cCamParsCollector );
370}
371
372/** \param pcListPic list of pictures to be written to file
373    \param bFirst    first picture?
374    \todo            DYN_REF_FREE should be revised
375 */
376Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic )
377{
378  TComList<TComPic*>::iterator iterPic   = pcListPic->begin();
379
380  while (iterPic != pcListPic->end())
381  {
382    TComPic* pcPic = *(iterPic);
383    Int iViewIdx = pcPic->getViewIdx();
384    Int bIsDepth = pcPic->getSlice(0)->getSPS()->isDepth() ;
385
386    if (!bIsDepth)
387    {
388      if( m_acTVideoIOYuvReconFileList.size() < iViewIdx+1 )
389            increaseNumberOfViews( iViewIdx+1 ) ;
390
391      if ( pcPic->getReconMark() && pcPic->getPOC() == (m_aiPOCLastDisplayList[iViewIdx] + 1) )
392      {
393        // write to file
394        if ( m_pchReconFile )
395        {
396          m_acTVideoIOYuvReconFileList[iViewIdx]->write( pcPic->getPicYuvRec(), pcPic->getSlice(0)->getSPS()->getPad() );
397        }
398
399        // update POC of display order
400        m_aiPOCLastDisplayList[iViewIdx] = pcPic->getPOC();
401
402        // erase non-referenced picture in the reference picture list after display
403        if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
404        {
405  #if !DYN_REF_FREE
406          pcPic->setReconMark(false);
407
408          // mark it should be extended later
409          pcPic->getPicYuvRec()->setBorderExtension( false );
410
411  #else
412          pcPic->destroy();
413          pcListPic->erase( iterPic );
414          iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
415          continue;
416  #endif
417        }
418      }
419    } /// end !bIsDepth
420    else
421    {
422      if( m_acTVideoIOYuvDepthReconFileList.size() < iViewIdx+1 )
423             increaseNumberOfViews( iViewIdx+1 ) ;
424
425      if ( pcPic->getReconMark() && pcPic->getPOC() == (m_aiDepthPOCLastDisplayList[iViewIdx] + 1) )
426      {
427        // write to file
428        if ( m_pchReconFile )
429        {
430
431#if POZNAN_NONLINEAR_DEPTH
432          TComSPS* pcSPS = pcPic->getSlice(0)->getSPS();
433          TComPicYuv cPicPower;
434
435          //pcPic->getPicYuvRec()
436          cPicPower.create(pcSPS->getWidth(), pcSPS->getHeight(), pcSPS->getMaxCUWidth(), pcSPS->getMaxCUHeight(), pcSPS->getMaxCUDepth() ); 
437
438          pcPic->getPicYuvRec()->power(&cPicPower, 1.0f/pcSPS->getDepthPower());
439
440          m_acTVideoIOYuvDepthReconFileList[iViewIdx]->write(&cPicPower, pcSPS->getPad());
441          cPicPower.destroy();           
442#else
443          m_acTVideoIOYuvDepthReconFileList[iViewIdx]->write( pcPic->getPicYuvRec(), pcPic->getSlice(0)->getSPS()->getPad() );
444#endif
445        }
446
447        // update POC of display order
448        m_aiDepthPOCLastDisplayList[iViewIdx] = pcPic->getPOC();
449
450        // erase non-referenced picture in the reference picture list after display
451        if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
452        {
453  #if !DYN_REF_FREE
454          pcPic->setReconMark(false);
455
456          // mark it should be extended later
457          pcPic->getPicYuvRec()->setBorderExtension( false );
458
459  #else
460          pcPic->destroy();
461          pcListPic->erase( iterPic );
462          iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
463          continue;
464  #endif
465        }
466      }
467    } // end bIsDepth
468
469    iterPic++;
470  }
471}
472
473Void TAppDecTop::startUsingDepth()
474{
475  m_bUsingDepth = true ;
476  increaseNumberOfViews( (Int)m_acTVideoIOYuvReconFileList.size() );
477}
478
479Void  TAppDecTop::increaseNumberOfViews  (Int iNewNumberOfViews)
480{
481  while( m_acTVideoIOYuvReconFileList.size() < iNewNumberOfViews)
482  {
483    m_acTVideoIOYuvReconFileList.push_back(new TVideoIOYuv);
484
485// GT FIX
486    Char cBuffer[4]  ;
487    sprintf(cBuffer,"_%i",(Int)m_acTVideoIOYuvReconFileList.size()-1 );
488    Char* pchNextFilename;
489    xAppendToFileNameEnd( m_pchReconFile, cBuffer, pchNextFilename);
490// GT FIX END
491    if ( m_outputBitDepth == 0 )
492      m_outputBitDepth = g_uiBitDepth + g_uiBitIncrement;
493    m_acTVideoIOYuvReconFileList.back()->open( pchNextFilename, true, m_outputBitDepth, g_uiBitDepth + g_uiBitIncrement );
494    free (pchNextFilename);
495  }
496
497  while( m_aiPOCLastDisplayList.size() < iNewNumberOfViews )
498    m_aiPOCLastDisplayList.push_back(-1+m_iSkipFrame) ;
499
500  while( m_acTDecTopList.size() < iNewNumberOfViews)
501  {
502    m_acTDecTopList.push_back(new TDecTop) ;// at least one decoder
503    m_acTDecTopList.back()->create() ;
504    m_acTDecTopList.back()->init( this, false );
505    m_acTDecTopList.back()->setViewIdx((Int)m_acTDecTopList.size()-1);
506    m_acTDecTopList.back()->setPictureDigestEnabled(m_pictureDigestEnabled);
507    m_acTDecTopList.back()->setCamParsCollector( &m_cCamParsCollector );
508  }
509  if( m_bUsingDepth )
510  {
511    while( m_acTVideoIOYuvDepthReconFileList.size() < iNewNumberOfViews  )
512    {
513      m_acTVideoIOYuvDepthReconFileList.push_back(new TVideoIOYuv);
514// GT FIX
515      Char* pchTempFilename = NULL;
516      xAppendToFileNameEnd( m_pchReconFile, "_depth", pchTempFilename);
517      Char cBuffer[4]  ;
518      sprintf(cBuffer,"_%i",(Int)m_acTVideoIOYuvDepthReconFileList.size()-1 );
519      Char* pchDepthFilename = NULL;
520      xAppendToFileNameEnd( pchTempFilename, cBuffer, pchDepthFilename);
521// GT FIX END
522      if ( m_outputBitDepth == 0 )
523        m_outputBitDepth = g_uiBitDepth + g_uiBitIncrement;
524      m_acTVideoIOYuvDepthReconFileList.back()->open( pchDepthFilename, true, m_outputBitDepth, g_uiBitDepth + g_uiBitIncrement );
525      free (pchTempFilename);
526      free( pchDepthFilename );
527    }
528    while( m_aiDepthPOCLastDisplayList.size() < iNewNumberOfViews )
529      m_aiDepthPOCLastDisplayList.push_back(-1+m_iSkipFrame) ;
530    while( m_acTDecDepthTopList.size() < iNewNumberOfViews)
531    {
532      m_acTDecDepthTopList.push_back(new TDecTop) ;// at least one decoder
533      m_acTDecDepthTopList.back()->create() ;
534      m_acTDecDepthTopList.back()->init( this, false );
535      m_acTDecDepthTopList.back()->setViewIdx((Int)m_acTDecTopList.size()-1);
536      m_acTDecDepthTopList.back()->setPictureDigestEnabled(m_pictureDigestEnabled);
537      m_acTDecDepthTopList.back()->setToDepth( true );
538      m_acTDecDepthTopList.back()->setCamParsCollector( &m_cCamParsCollector );
539    }
540  }
541}
542
543
544// GT FIX
545std::vector<TComPic*> TAppDecTop::getSpatialRefPics( Int iViewIdx, Int iPoc, Bool bIsDepth ) // only for mvc functionality yet
546{
547  std::vector<TComPic*> apcRefPics( iViewIdx, (TComPic*)NULL );
548  for( int iRefViewIdx = 0; iRefViewIdx < iViewIdx; iRefViewIdx++ )
549  {
550    TComPic* pcRefPic = getPicFromView( iRefViewIdx, iPoc, bIsDepth );
551    assert( pcRefPic != NULL );
552    apcRefPics[iRefViewIdx] = pcRefPic;
553  }
554  return apcRefPics;
555}
556
557TComPic* TAppDecTop::getPicFromView( Int iViewIdx, Int iPoc, bool bIsDepth )
558{
559  TComList<TComPic*>* apcListPic = (bIsDepth ? m_acTDecDepthTopList[iViewIdx] : m_acTDecTopList[iViewIdx])->getListPic();
560  TComPic* pcRefPic = NULL;
561  for( TComList<TComPic*>::iterator it=apcListPic->begin(); it!=apcListPic->end(); it++ )
562  {
563    if( (*it)->getPOC() == iPoc )
564    {
565      pcRefPic = *it;
566      break;
567    }
568  }
569  return pcRefPic;
570}
571
572#if POZNAN_CU_SYNTH || POZNAN_CU_SKIP
573Void TAppDecTop::initRenderer(TComSPS &cComSPS)
574{
575  m_cAvailabilityRenderer.init(cComSPS.getWidth(), cComSPS.getHeight(),true,0,LOG2_DISP_PREC_LUT,true, 0,0,0,0,0,6,4,1,0,6 );  //GT: simplest configuration
576}
577//*
578Void TAppDecTop::storeSynthPicsInBuffer(Int iCoddedViewIdx,Int iCoddedViewOrderIdx, Int iCurPoc, Bool bDepth)
579{
580  Int  iLeftViewIdx  = -1;
581  Int  iRightViewIdx = -1;
582  Int  iNearestViewIdx = -1;
583  Bool bIsBaseView;
584  Bool bRenderFromLeft;
585
586  Int iRelDistToLeft = 128;
587  if(iCoddedViewIdx==0) //First on View Coded List
588  {
589    TComPic* pcPic = getPicFromView( iCoddedViewIdx, iCurPoc, false );
590    return;
591  }
592  iNearestViewIdx = 0;
593  bRenderFromLeft = iCoddedViewOrderIdx>0?true:false;
594
595  m_cAvailabilityRenderer.setShiftLUTs(
596    m_cCamParsCollector.getBaseViewShiftLUTD()[iNearestViewIdx][iCoddedViewIdx],
597    m_cCamParsCollector.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
598    m_cCamParsCollector.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
599    m_cCamParsCollector.getBaseViewShiftLUTD()[iNearestViewIdx][iCoddedViewIdx],//right
600    m_cCamParsCollector.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
601    m_cCamParsCollector.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
602    iRelDistToLeft
603  );
604
605  TComPic* pcPic = getPicFromView( iCoddedViewIdx, iCurPoc, bDepth );
606
607  TComPicYuv* pcPicYuvSynthView = pcPic->getPicYuvSynth();
608  TComPicYuv* pcPicYuvAvailView = pcPic->getPicYuvAvail();
609  if(!pcPicYuvSynthView)
610  {
611    pcPic->addSynthesisBuffer();
612    pcPicYuvSynthView = pcPic->getPicYuvSynth();
613  }
614  if(!pcPicYuvAvailView)
615  {
616    pcPic->addAvailabilityBuffer();
617    pcPicYuvAvailView = pcPic->getPicYuvAvail();
618  }
619#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
620  TComPicYuv* pcPicYuvSynthDepthView = pcPic->getPicYuvSynthDepth();
621  if(!pcPicYuvSynthDepthView)
622  {
623    pcPic->addSynthesisDepthBuffer();
624    pcPicYuvSynthDepthView = pcPic->getPicYuvSynthDepth();
625  }
626  m_cAvailabilityRenderer.extrapolateAvailabilityView( getPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), getPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), pcPicYuvSynthDepthView, pcPicYuvAvailView, bRenderFromLeft );
627 
628#if POZNAN_OUTPUT_SYNTH
629      Char acFilenameBaseD[1024];
630      ::sprintf( acFilenameBaseD,  "SynthDepth_%s_V%d.yuv", ( true ? "Dec" : "Enc" ),iCoddedViewIdx );
631      pcPicYuvSynthDepthView->dump(acFilenameBaseD, iCurPoc!=0);
632#endif
633#endif
634
635  //m_cAvailabilityRenderer.extrapolateAvailabilityView( xGetPicFromView( iNearestViewIdx, iCurPoc, false )->getPicYuvRec(), xGetPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), pcPicYuvERView, pcPicYuvAvailView, bRenderFromLeft );
636  m_cAvailabilityRenderer.extrapolateAvailabilityView( getPicFromView( iNearestViewIdx, iCurPoc, false )->getPicYuvRec(), getPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), pcPicYuvSynthView, pcPicYuvAvailView, bRenderFromLeft );
637     
638  pcPicYuvAvailView->setBorderExtension( false );//Needed??
639  pcPicYuvAvailView->extendPicBorder();//Needed??
640
641#if POZNAN_OUTPUT_AVAILABLE_MAP
642  {
643  Char acFilenameBase[1024];
644  ::sprintf( acFilenameBase,  "Available_%s_%s_V%d.yuv", (bDepth ? "Depth":"Tex"),( true ? "Dec" : "Enc" ), iCoddedViewIdx);
645  pcPicYuvAvailView->dump(acFilenameBase, iCurPoc!=0);
646  }
647#endif
648#if POZNAN_OUTPUT_SYNTH
649  {
650  Char acFilenameBase[1024];
651  ::sprintf( acFilenameBase,  "Synth_%s_%s_V%d.yuv", (bDepth ? "Depth":"Tex"),( true ? "Dec" : "Enc" ), iCoddedViewIdx );
652  pcPicYuvSynthView->dump(acFilenameBase, iCurPoc!=0);
653  }
654#endif
655
656}//*/
657#endif
Note: See TracBrowser for help on using the repository browser.