source: 3DVCSoftware/branches/0.3-poznan-univ/source/App/TAppDecoder/TAppDecTop.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: 26.5 KB
Line 
1/* The copyright in this software is being made available under the BSD
2 * License, included below. This software may be subject to other third party
3 * and contributor rights, including patent rights, and no such rights are
4 * granted under this license.
5 *
6 * Copyright (c) 2010-2011, ISO/IEC
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright notice,
13 *    this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above copyright notice,
15 *    this list of conditions and the following disclaimer in the documentation
16 *    and/or other materials provided with the distribution.
17 *  * Neither the name of the ISO/IEC nor the names of its contributors may
18 *    be used to endorse or promote products derived from this software without
19 *    specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34
35
36/** \file     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_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#if SONY_COLPIC_AVAILABILITY
371  m_acTDecTopList[0]->setViewOrderIdx(0);
372#endif
373}
374
375/** \param pcListPic list of pictures to be written to file
376    \param bFirst    first picture?
377    \todo            DYN_REF_FREE should be revised
378 */
379Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic )
380{
381  TComList<TComPic*>::iterator iterPic   = pcListPic->begin();
382
383  while (iterPic != pcListPic->end())
384  {
385    TComPic* pcPic = *(iterPic);
386    Int iViewIdx = pcPic->getViewIdx();
387    Int bIsDepth = pcPic->getSlice(0)->getSPS()->isDepth() ;
388
389    if (!bIsDepth)
390    {
391      if( m_acTVideoIOYuvReconFileList.size() < iViewIdx+1 )
392            increaseNumberOfViews( iViewIdx+1 ) ;
393
394      if ( pcPic->getReconMark() && pcPic->getPOC() == (m_aiPOCLastDisplayList[iViewIdx] + 1) )
395      {
396        // write to file
397        if ( m_pchReconFile )
398        {
399          m_acTVideoIOYuvReconFileList[iViewIdx]->write( pcPic->getPicYuvRec(), pcPic->getSlice(0)->getSPS()->getPad() );
400        }
401
402        // update POC of display order
403        m_aiPOCLastDisplayList[iViewIdx] = pcPic->getPOC();
404
405        // erase non-referenced picture in the reference picture list after display
406        if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
407        {
408  #if !DYN_REF_FREE
409          pcPic->setReconMark(false);
410
411          // mark it should be extended later
412          pcPic->getPicYuvRec()->setBorderExtension( false );
413
414  #else
415          pcPic->destroy();
416          pcListPic->erase( iterPic );
417          iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
418          continue;
419  #endif
420        }
421      }
422    } /// end !bIsDepth
423    else
424    {
425      if( m_acTVideoIOYuvDepthReconFileList.size() < iViewIdx+1 )
426             increaseNumberOfViews( iViewIdx+1 ) ;
427
428      if ( pcPic->getReconMark() && pcPic->getPOC() == (m_aiDepthPOCLastDisplayList[iViewIdx] + 1) )
429      {
430        // write to file
431        if ( m_pchReconFile )
432        {
433
434#if POZNAN_NONLINEAR_DEPTH
435          TComSPS* pcSPS = pcPic->getSlice(0)->getSPS();
436          TComPicYuv cPicPower;
437
438          //pcPic->getPicYuvRec()
439          cPicPower.create(pcSPS->getWidth(), pcSPS->getHeight(), pcSPS->getMaxCUWidth(), pcSPS->getMaxCUHeight(), pcSPS->getMaxCUDepth() ); 
440
441          pcPic->getPicYuvRec()->nonlinearDepthBackward(&cPicPower, pcSPS->getDepthPower());
442
443          m_acTVideoIOYuvDepthReconFileList[iViewIdx]->write(&cPicPower, pcSPS->getPad());
444          cPicPower.destroy();           
445#else
446          m_acTVideoIOYuvDepthReconFileList[iViewIdx]->write( pcPic->getPicYuvRec(), pcPic->getSlice(0)->getSPS()->getPad() );
447#endif
448        }
449
450        // update POC of display order
451        m_aiDepthPOCLastDisplayList[iViewIdx] = pcPic->getPOC();
452
453        // erase non-referenced picture in the reference picture list after display
454        if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
455        {
456  #if !DYN_REF_FREE
457          pcPic->setReconMark(false);
458
459          // mark it should be extended later
460          pcPic->getPicYuvRec()->setBorderExtension( false );
461
462  #else
463          pcPic->destroy();
464          pcListPic->erase( iterPic );
465          iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
466          continue;
467  #endif
468        }
469      }
470    } // end bIsDepth
471
472    iterPic++;
473  }
474}
475
476Void TAppDecTop::startUsingDepth()
477{
478  m_bUsingDepth = true ;
479  increaseNumberOfViews( (Int)m_acTVideoIOYuvReconFileList.size() );
480}
481
482Void  TAppDecTop::increaseNumberOfViews  (Int iNewNumberOfViews)
483{
484  while( m_acTVideoIOYuvReconFileList.size() < iNewNumberOfViews)
485  {
486    m_acTVideoIOYuvReconFileList.push_back(new TVideoIOYuv);
487
488// GT FIX
489    Char cBuffer[4]  ;
490    sprintf(cBuffer,"_%i",(Int)m_acTVideoIOYuvReconFileList.size()-1 );
491    Char* pchNextFilename;
492    xAppendToFileNameEnd( m_pchReconFile, cBuffer, pchNextFilename);
493// GT FIX END
494    if ( m_outputBitDepth == 0 )
495      m_outputBitDepth = g_uiBitDepth + g_uiBitIncrement;
496    m_acTVideoIOYuvReconFileList.back()->open( pchNextFilename, true, m_outputBitDepth, g_uiBitDepth + g_uiBitIncrement );
497    free (pchNextFilename);
498  }
499
500  while( m_aiPOCLastDisplayList.size() < iNewNumberOfViews )
501    m_aiPOCLastDisplayList.push_back(-1+m_iSkipFrame) ;
502
503  while( m_acTDecTopList.size() < iNewNumberOfViews)
504  {
505    m_acTDecTopList.push_back(new TDecTop) ;// at least one decoder
506    m_acTDecTopList.back()->create() ;
507    m_acTDecTopList.back()->init( this, false );
508    m_acTDecTopList.back()->setViewIdx((Int)m_acTDecTopList.size()-1);
509    m_acTDecTopList.back()->setPictureDigestEnabled(m_pictureDigestEnabled);
510    m_acTDecTopList.back()->setCamParsCollector( &m_cCamParsCollector );
511  }
512  if( m_bUsingDepth )
513  {
514    while( m_acTVideoIOYuvDepthReconFileList.size() < iNewNumberOfViews  )
515    {
516      m_acTVideoIOYuvDepthReconFileList.push_back(new TVideoIOYuv);
517// GT FIX
518      Char* pchTempFilename = NULL;
519      xAppendToFileNameEnd( m_pchReconFile, "_depth", pchTempFilename);
520      Char cBuffer[4]  ;
521      sprintf(cBuffer,"_%i",(Int)m_acTVideoIOYuvDepthReconFileList.size()-1 );
522      Char* pchDepthFilename = NULL;
523      xAppendToFileNameEnd( pchTempFilename, cBuffer, pchDepthFilename);
524// GT FIX END
525      if ( m_outputBitDepth == 0 )
526        m_outputBitDepth = g_uiBitDepth + g_uiBitIncrement;
527      m_acTVideoIOYuvDepthReconFileList.back()->open( pchDepthFilename, true, m_outputBitDepth, g_uiBitDepth + g_uiBitIncrement );
528      free (pchTempFilename);
529      free( pchDepthFilename );
530    }
531    while( m_aiDepthPOCLastDisplayList.size() < iNewNumberOfViews )
532      m_aiDepthPOCLastDisplayList.push_back(-1+m_iSkipFrame) ;
533    while( m_acTDecDepthTopList.size() < iNewNumberOfViews)
534    {
535      m_acTDecDepthTopList.push_back(new TDecTop) ;// at least one decoder
536      m_acTDecDepthTopList.back()->create() ;
537      m_acTDecDepthTopList.back()->init( this, false );
538      m_acTDecDepthTopList.back()->setViewIdx((Int)m_acTDecTopList.size()-1);
539      m_acTDecDepthTopList.back()->setPictureDigestEnabled(m_pictureDigestEnabled);
540      m_acTDecDepthTopList.back()->setToDepth( true );
541      m_acTDecDepthTopList.back()->setCamParsCollector( &m_cCamParsCollector );
542    }
543  }
544}
545
546
547// GT FIX
548std::vector<TComPic*> TAppDecTop::getSpatialRefPics( Int iViewIdx, Int iPoc, Bool bIsDepth ) // only for mvc functionality yet
549{
550  std::vector<TComPic*> apcRefPics( iViewIdx, (TComPic*)NULL );
551  for( int iRefViewIdx = 0; iRefViewIdx < iViewIdx; iRefViewIdx++ )
552  {
553    TComPic* pcRefPic = getPicFromView( iRefViewIdx, iPoc, bIsDepth );
554    assert( pcRefPic != NULL );
555    apcRefPics[iRefViewIdx] = pcRefPic;
556  }
557  return apcRefPics;
558}
559
560TComPic* TAppDecTop::getPicFromView( Int iViewIdx, Int iPoc, bool bIsDepth )
561{
562  TComList<TComPic*>* apcListPic = (bIsDepth ? m_acTDecDepthTopList[iViewIdx] : m_acTDecTopList[iViewIdx])->getListPic();
563  TComPic* pcRefPic = NULL;
564  for( TComList<TComPic*>::iterator it=apcListPic->begin(); it!=apcListPic->end(); it++ )
565  {
566    if( (*it)->getPOC() == iPoc )
567    {
568      pcRefPic = *it;
569      break;
570    }
571  }
572  return pcRefPic;
573}
574
575#if POZNAN_SYNTH
576Void TAppDecTop::initRenderer(TComSPS &cComSPS)
577{
578  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
579}
580//*
581Void TAppDecTop::storeSynthPicsInBuffer(Int iCoddedViewIdx,Int iCoddedViewOrderIdx, Int iCurPoc, Bool bDepth)
582{
583  Int  iLeftViewIdx  = -1;
584  Int  iRightViewIdx = -1;
585  Int  iNearestViewIdx = -1;
586  Bool bRenderFromLeft;
587
588  Int iRelDistToLeft = 128;
589  if(iCoddedViewIdx==0) //First on View Coded List
590  {
591    //TComPic* pcPic = getPicFromView( iCoddedViewIdx, iCurPoc, false );
592    return;
593  }
594  iNearestViewIdx = 0;
595  //bRenderFromLeft = iCoddedViewOrderIdx>0?true:false;
596  //bRenderFromLeft = iCoddedViewOrderIdx<0?true:false;
597  //m_cCamParsCollector.getNearestBaseView(iCoddedViewIdx, iNearestViewIdx, iRelDistToLeft, bRenderFromLeft);
598  bRenderFromLeft = iCoddedViewIdx>1?true:false;
599
600  m_cAvailabilityRenderer.setShiftLUTs(
601    m_cCamParsCollector.getBaseViewShiftLUTD()[iNearestViewIdx][iCoddedViewIdx],
602    m_cCamParsCollector.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
603    m_cCamParsCollector.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
604    m_cCamParsCollector.getBaseViewShiftLUTD()[iNearestViewIdx][iCoddedViewIdx],//right
605    m_cCamParsCollector.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
606    m_cCamParsCollector.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
607    iRelDistToLeft
608  );
609
610  TComPic* pcPic = getPicFromView( iCoddedViewIdx, iCurPoc, bDepth );
611
612  TComPicYuv* pcPicYuvSynthView = pcPic->getPicYuvSynth();
613  TComPicYuv* pcPicYuvAvailView = pcPic->getPicYuvAvail();
614  if(!pcPicYuvSynthView)
615  {
616    pcPic->addSynthesisBuffer();
617    pcPicYuvSynthView = pcPic->getPicYuvSynth();
618  }
619  if(!pcPicYuvAvailView)
620  {
621    pcPic->addAvailabilityBuffer();
622    pcPicYuvAvailView = pcPic->getPicYuvAvail();
623  }
624// usun i uzyj syntezy Krzysztofa tylko przesun ja przed dekodowanie tekstury to do
625  /*
626#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
627  if(!bDepth)
628  {
629  TComPicYuv* pcPicYuvSynthDepthView = pcPic->getPicYuvSynthDepth();
630  if(!pcPicYuvSynthDepthView)
631  {
632    pcPic->addSynthesisDepthBuffer();
633    pcPicYuvSynthDepthView = pcPic->getPicYuvSynthDepth();
634  }
635  m_cAvailabilityRenderer.extrapolateAvailabilityView( getPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), getPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), pcPicYuvSynthDepthView, pcPicYuvAvailView, bRenderFromLeft );
636 
637#if POZNAN_OUTPUT_SYNTH
638      Char acFilenameBaseD[1024];
639      //printf("\niNearestViewIdx: %d, iCurPoc: %d, bRenderFromLeft: %s\n", iNearestViewIdx, iCurPoc, (bRenderFromLeft)?"true":"false");
640      ::sprintf( acFilenameBaseD,  "SynthInputDepth_%s_V%d.yuv", ( true ? "Dec" : "Enc" ),iCoddedViewIdx );
641      getPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec()->dump(acFilenameBaseD, iCurPoc!=0);
642      ::sprintf( acFilenameBaseD,  "SynthDepth_%s_V%d.yuv", ( true ? "Dec" : "Enc" ),iCoddedViewIdx );
643      pcPicYuvSynthDepthView->dump(acFilenameBaseD, iCurPoc!=0);
644#endif
645   }
646#endif//*/
647
648  //m_cAvailabilityRenderer.extrapolateAvailabilityView( xGetPicFromView( iNearestViewIdx, iCurPoc, false )->getPicYuvRec(), xGetPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), pcPicYuvERView, pcPicYuvAvailView, bRenderFromLeft );
649  m_cAvailabilityRenderer.extrapolateAvailabilityView( getPicFromView( iNearestViewIdx, iCurPoc, bDepth )->getPicYuvRec(), getPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), pcPicYuvSynthView, pcPicYuvAvailView, bRenderFromLeft );
650
651  pcPicYuvAvailView->setBorderExtension( false );//Needed??
652  pcPicYuvAvailView->extendPicBorder();//Needed??
653
654#if POZNAN_OUTPUT_AVAILABLE_MAP
655  {
656  Char acFilenameBase[1024];
657  ::sprintf( acFilenameBase,  "Available_%s_%s_V%d.yuv", (bDepth ? "Depth":"Tex"),( true ? "Dec" : "Enc" ), iCoddedViewIdx);
658  pcPicYuvAvailView->dump(acFilenameBase, iCurPoc!=0);
659  }
660#endif
661#if POZNAN_OUTPUT_SYNTH
662  {
663  Char acFilenameBase[1024];
664  ::sprintf( acFilenameBase,  "Synth_%s_%s_V%d.yuv", (bDepth ? "Depth":"Tex"),( true ? "Dec" : "Enc" ), iCoddedViewIdx );
665  pcPicYuvSynthView->dump(acFilenameBase, iCurPoc!=0);
666  }
667#endif
668}
669#endif
670
671//*
672#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
673Void TAppDecTop::storeDepthSynthPicsInBuffer(Int iCoddedViewIdx,Int iCoddedViewOrderIdx, Int iCurPoc)
674{
675  Int  iLeftViewIdx  = -1;
676  Int  iRightViewIdx = -1;
677  Int  iNearestViewIdx = -1;
678  Bool bRenderFromLeft;
679
680  Int iRelDistToLeft = 128;
681  if(iCoddedViewIdx==0) //First on View Coded List
682  {
683    //TComPic* pcPic = getPicFromView( iCoddedViewIdx, iCurPoc, false );
684    return;
685  }
686  iNearestViewIdx = 0;
687  //bRenderFromLeft = iCoddedViewOrderIdx>0?true:false;
688  //bRenderFromLeft = iCoddedViewOrderIdx<0?true:false;
689  //m_cCamParsCollector.getNearestBaseView(iCoddedViewIdx, iNearestViewIdx, iRelDistToLeft, bRenderFromLeft);
690  bRenderFromLeft = iCoddedViewIdx>1?true:false;
691
692  m_cAvailabilityRenderer.setShiftLUTs(
693    m_cCamParsCollector.getBaseViewShiftLUTD()[iNearestViewIdx][iCoddedViewIdx],
694    m_cCamParsCollector.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
695    m_cCamParsCollector.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
696    m_cCamParsCollector.getBaseViewShiftLUTD()[iNearestViewIdx][iCoddedViewIdx],//right
697    m_cCamParsCollector.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
698    m_cCamParsCollector.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
699    iRelDistToLeft
700  );
701
702  TComPic* pcPic = getPicFromView( iCoddedViewIdx, iCurPoc, false );
703
704  TComPicYuv* pcPicYuvSynthDepthView = pcPic->getPicYuvSynthDepth();
705  if(!pcPicYuvSynthDepthView)
706  {
707    pcPic->addSynthesisDepthBuffer();
708    pcPicYuvSynthDepthView = pcPic->getPicYuvSynthDepth();
709  }
710 
711  Int   iWidth        = pcPicYuvSynthDepthView->getWidth      ();
712  Int   iHeight       = pcPicYuvSynthDepthView->getHeight     ();
713  UInt  uiMaxCuWidth  = pcPicYuvSynthDepthView->getMaxCuWidth ();
714  UInt  uiMaxCuHeight = pcPicYuvSynthDepthView->getMaxCuHeight();
715  UInt  uiMaxCuDepth  = pcPicYuvSynthDepthView->getMaxCuDepth ();
716
717  TComPicYuv* pcPicYuvAvailView = new TComPicYuv;
718  pcPicYuvAvailView->create( iWidth, iHeight, uiMaxCuWidth, uiMaxCuHeight, uiMaxCuDepth );
719
720  m_cAvailabilityRenderer.extrapolateAvailabilityView( getPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), getPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), pcPicYuvSynthDepthView, pcPicYuvAvailView, bRenderFromLeft );
721 
722  pcPicYuvAvailView->destroy();
723  delete pcPicYuvAvailView;
724
725#if POZNAN_OUTPUT_SYNTH
726      Char acFilenameBaseD[1024];
727      //printf("\niNearestViewIdx: %d, iCurPoc: %d, bRenderFromLeft: %s\n", iNearestViewIdx, iCurPoc, (bRenderFromLeft)?"true":"false");
728      ::sprintf( acFilenameBaseD,  "SynthInputDepth_%s_V%d.yuv", ( true ? "Dec" : "Enc" ),iCoddedViewIdx );
729      getPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec()->dump(acFilenameBaseD, iCurPoc!=0);
730      ::sprintf( acFilenameBaseD,  "SynthDepth_%s_V%d.yuv", ( true ? "Dec" : "Enc" ),iCoddedViewIdx );
731      pcPicYuvSynthDepthView->dump(acFilenameBaseD, iCurPoc!=0);
732#endif
733 
734}
735#endif//*/
Note: See TracBrowser for help on using the repository browser.