source: 3DVCSoftware/branches/HTM-6.2-dev1-Sharp/source/App/TAppDecoder/TAppDecTop.cpp @ 471

Last change on this file since 471 was 296, checked in by tech, 12 years ago

Reintegrated branch 5.1-dev0 rev. 295.

  • Property svn:eol-style set to native
File size: 22.1 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-2012, ITU/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 ITU/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/** \file     TAppDecTop.cpp
35    \brief    Decoder application class
36*/
37
38#include <list>
39#include <vector>
40#include <stdio.h>
41#include <fcntl.h>
42#include <assert.h>
43
44#include "TAppDecTop.h"
45#include "TLibDecoder/AnnexBread.h"
46#include "TLibDecoder/NALread.h"
47
48//! \ingroup TAppDecoder
49//! \{
50
51// ====================================================================================================================
52// Constructor / destructor / initialization / destroy
53// ====================================================================================================================
54
55TAppDecTop::TAppDecTop()
56{
57  ::memset (m_abDecFlag, 0, sizeof (m_abDecFlag));
58  m_useDepth = false;
59  m_pScaleOffsetFile  = 0;
60}
61
62Void TAppDecTop::create()
63{
64}
65
66Void TAppDecTop::destroy()
67{
68}
69
70// ====================================================================================================================
71// Public member functions
72// ====================================================================================================================
73
74/**
75 - create internal class
76 - initialize internal class
77 - until the end of the bitstream, call decoding function in TDecTop class
78 - delete allocated buffers
79 - destroy internal class
80 .
81 */
82Void TAppDecTop::decode()
83{
84#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
85  increaseNumberOfViews( 0, 0, 0 );
86#else
87  increaseNumberOfViews( 1 );
88#endif
89 
90#if FLEX_CODING_ORDER_M23723
91  Int iDepthViewIdx = 0;
92  Int iTextureViewIdx=0;
93  Bool firstFrame=1;
94  Bool viewIdZero=true;
95  Int fcoIndex=0;  //when the current frame is not first frame,use FCO_index stand for viewDepth.
96#endif
97
98  Int                 viewDepthId = 0;
99  Int                 previousViewDepthId  = 0;
100  UInt                uiPOC[MAX_VIEW_NUM*2];
101  TComList<TComPic*>* pcListPic[MAX_VIEW_NUM*2];
102  Bool                newPicture[MAX_VIEW_NUM*2];
103  Bool                previousPictureDecoded = false;
104  for( Int i = 0; i < MAX_VIEW_NUM*2; i++ )
105  {
106    uiPOC[i] = 0;
107    pcListPic[i] = NULL;
108    newPicture[i] = false;
109#if FLEX_CODING_ORDER_M23723
110    m_fcoOrder[i] = ' ';
111#endif
112
113  }
114
115  ifstream bitstreamFile(m_pchBitstreamFile, ifstream::in | ifstream::binary);
116  if (!bitstreamFile)
117  {
118    fprintf(stderr, "\nfailed to open bitstream file `%s' for reading\n", m_pchBitstreamFile);
119    exit(EXIT_FAILURE);
120  }
121
122  if( m_pchScaleOffsetFile ) 
123  { 
124    m_pScaleOffsetFile = ::fopen( m_pchScaleOffsetFile, "wt" ); 
125    AOF( m_pScaleOffsetFile ); 
126  }
127  m_cCamParsCollector.init( m_pScaleOffsetFile );
128
129  InputByteStream bytestream(bitstreamFile);
130
131  while (!!bitstreamFile)
132  {
133    /* location serves to work around a design fault in the decoder, whereby
134     * the process of reading a new slice that is the first slice of a new frame
135     * requires the TDecTop::decode() method to be called again with the same
136     * nal unit. */
137    streampos location = bitstreamFile.tellg();
138    AnnexBStats stats = AnnexBStats();
139    vector<uint8_t> nalUnit;
140    InputNALUnit nalu;
141    byteStreamNALUnit(bytestream, nalUnit, stats);
142
143    // call actual decoding function
144    if (nalUnit.empty())
145    {
146      /* this can happen if the following occur:
147       *  - empty input file
148       *  - two back-to-back start_code_prefixes
149       *  - start_code_prefix immediately followed by EOF
150       */
151      fprintf(stderr, "Warning: Attempt to decode an empty NAL unit\n");
152    }
153    else
154    {
155      read(nalu, nalUnit);
156#if QC_MVHEVC_B0046
157    viewDepthId = nalu.m_layerId;
158    Int depth = 0;
159    Int viewId = viewDepthId;
160#else
161#if VIDYO_VPS_INTEGRATION
162      Int viewId = 0;
163      Int depth = 0;
164     
165      if(nalu.m_nalUnitType != NAL_UNIT_VPS || nalu.m_layerId)
166      {
167        // code assumes that the first nal unit is VPS
168        // currently, this is a hack that requires non-first VPSs have non-zero layer_id
169        viewId = getVPSAccess()->getActiveVPS()->getViewId(nalu.m_layerId);
170        depth = getVPSAccess()->getActiveVPS()->getDepthFlag(nalu.m_layerId);
171      }
172#if FLEX_CODING_ORDER_M23723
173      if (viewId>0)
174      {
175        viewIdZero=false;
176      }
177      if (viewIdZero==false&&viewId==0)
178      {
179        firstFrame=0; //if viewId has been more than zero and now it set to zero again, we can see that it is not the first view
180      }
181      if (firstFrame)
182      { // if the current view is first frame, we set the viewDepthId as texture plus depth and get the FCO order
183        viewDepthId = iDepthViewIdx+iTextureViewIdx;
184        m_fcoViewDepthId=viewDepthId;
185      }
186      else
187      {//if current view is not first frame, we set the viewDepthId depended on the FCO order
188        viewDepthId=0;
189        if (depth)
190        {
191          for (fcoIndex=0;fcoIndex<2*MAX_VIEW_NUM;fcoIndex++ )
192          {
193            if (m_fcoOrder[fcoIndex]=='D')
194            {
195              if (viewId==viewDepthId)
196                break;
197              else
198                viewDepthId++;
199            }
200          }
201        }
202        else
203        {
204          for (fcoIndex=0;fcoIndex<2*MAX_VIEW_NUM;fcoIndex++ )
205          {
206            if (m_fcoOrder[fcoIndex]=='T')
207            {
208              if (viewId==viewDepthId)
209                break;
210              else
211                viewDepthId++;
212            }
213          }
214        }
215
216        viewDepthId=fcoIndex;
217
218      }
219
220
221#else
222      viewDepthId = nalu.m_layerId;   // coding order T0D0T1D1T2D2
223#endif
224   
225#else
226      Int viewId = nalu.m_viewId;
227      Int depth = nalu.m_isDepth ? 1 : 0;
228#if FLEX_CODING_ORDER_M23723
229      if (viewId>0)
230      {
231        viewIdZero=false;
232      }
233      if (viewIdZero==false&&viewId==0)
234      {
235        firstFrame=0;
236      }
237      if (firstFrame)
238      {
239        viewDepthId = iDepthViewIdx+iTextureViewIdx;
240        m_fcoViewDepthId=viewDepthId;
241      }
242      else
243      {
244        viewDepthId=0;
245        if (depth)
246        {
247          for (fcoIndex=0;fcoIndex<2*MAX_VIEW_NUM;fcoIndex++ )
248          {
249            if (m_fcoOrder[fcoIndex]=='D')
250            {
251              if (viewId==viewDepthId)
252                break;
253              else
254                viewDepthId++;
255            }
256          }
257        }
258        else
259        {
260          for (fcoIndex=0;fcoIndex<2*MAX_VIEW_NUM;fcoIndex++ )
261          {
262            if (m_fcoOrder[fcoIndex]=='T')
263            {
264              if (viewId==viewDepthId)
265                break;
266              else
267                viewDepthId++;
268            }
269          }
270        }
271        viewDepthId=fcoIndex;
272      }
273#else
274      viewDepthId = viewId * 2 + depth;   // coding order T0D0T1D1T2D2
275#endif
276#endif
277#endif     
278      newPicture[viewDepthId] = false;
279      if( viewDepthId >= m_tDecTop.size() )     
280      {
281#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
282        increaseNumberOfViews( viewDepthId, viewId, depth );
283#else
284        increaseNumberOfViews( viewDepthId +1 );
285#endif   
286      }
287      if(m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer)
288      {
289        previousPictureDecoded = false; 
290      }
291      if(m_tDecTop.size() > 1 && (viewDepthId != previousViewDepthId) && previousPictureDecoded )
292      {
293        m_tDecTop[previousViewDepthId]->executeDeblockAndAlf(uiPOC[previousViewDepthId], pcListPic[previousViewDepthId], m_iSkipFrame, m_pocLastDisplay[previousViewDepthId]);
294      } 
295      if( ( viewDepthId == 0 && (viewDepthId != previousViewDepthId) ) || m_tDecTop.size() == 1 )
296      {
297#if H3D_IVRP
298        for( Int i = 0; i < m_tDecTop.size(); i++ )
299        {
300          m_tDecTop[i]->deleteExtraPicBuffers( uiPOC[i] );
301        }
302#endif
303        for( Int i = 0; i < m_tDecTop.size(); i++ )
304        {
305          m_tDecTop[i]->compressMotion( uiPOC[i] );
306        }
307      }   
308      if( !(m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) )
309      {
310#if QC_MVHEVC_B0046
311        if(viewDepthId && m_tDecTop[viewDepthId]->m_bFirstNal== false)
312        {
313          m_tDecTop[viewDepthId]->m_bFirstNal = true;
314          ParameterSetManagerDecoder* pDecV0 = m_tDecTop[0]->xGetParaSetDec();
315          m_tDecTop[viewDepthId]->xCopyVPS(pDecV0->getPrefetchedVPS(0));
316          m_tDecTop[viewDepthId]->xCopySPS(pDecV0->getPrefetchedSPS(0));
317          m_tDecTop[viewDepthId]->xCopyPPS(pDecV0->getPrefetchedPPS(0));
318        }
319#endif
320        newPicture[viewDepthId] = m_tDecTop[viewDepthId]->decode(nalu, m_iSkipFrame, m_pocLastDisplay[viewDepthId]);
321        if (newPicture[viewDepthId])
322        {
323          bitstreamFile.clear();
324          /* location points to the current nalunit payload[1] due to the
325           * need for the annexB parser to read three extra bytes.
326           * [1] except for the first NAL unit in the file
327           *     (but bNewPicture doesn't happen then) */
328          bitstreamFile.seekg(location-streamoff(3));
329          bytestream.reset();
330        }
331        if( nalu.isSlice() )
332        {
333          previousPictureDecoded = true;
334#if FLEX_CODING_ORDER_M23723
335        if (firstFrame)
336        {
337            if (depth)
338            {
339                iDepthViewIdx++;
340                m_fcoOrder[viewDepthId]='D';
341            }
342            else
343           {
344                iTextureViewIdx++;
345                m_fcoOrder[viewDepthId]='T';
346           }
347          }
348
349#endif
350        }
351      }
352    }
353    if( ( (newPicture[viewDepthId] || !bitstreamFile) && m_tDecTop.size() == 1) || (!bitstreamFile && previousPictureDecoded == true) ) 
354    {
355      m_tDecTop[viewDepthId]->executeDeblockAndAlf(uiPOC[viewDepthId], pcListPic[viewDepthId], m_iSkipFrame, m_pocLastDisplay[viewDepthId]);
356    }
357    if( pcListPic[viewDepthId] )
358    {
359#if QC_REM_IDV_B0046
360      Int iviewId = m_tDecTop[viewDepthId]->getViewId();
361      if( newPicture[viewDepthId] && (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR || ((nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR && iviewId) && m_tDecTop[viewDepthId]->getNalUnitTypeBaseView() == NAL_UNIT_CODED_SLICE_IDR)) )
362#else
363      if( newPicture[viewDepthId] && (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR || (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDV && m_tDecTop[viewDepthId]->getNalUnitTypeBaseView() == NAL_UNIT_CODED_SLICE_IDR)) )
364#endif
365      {
366        xFlushOutput( pcListPic[viewDepthId], viewDepthId );
367      }
368      // write reconstruction to file
369      if(newPicture[viewDepthId])
370      {
371        xWriteOutput( pcListPic[viewDepthId], viewDepthId, nalu.m_temporalId );
372      }
373    }
374    previousViewDepthId = viewDepthId;
375  } 
376  if( m_cCamParsCollector.isInitialized() )
377  {
378    m_cCamParsCollector.setSlice( 0 );
379  }
380  // last frame
381  for( Int viewDepthIdx = 0; viewDepthIdx < m_tDecTop.size(); viewDepthIdx++ )
382  {
383    xFlushOutput( pcListPic[viewDepthIdx], viewDepthIdx );
384  } 
385  xDestroyDecLib();
386}
387
388// ====================================================================================================================
389// Protected member functions
390// ====================================================================================================================
391
392Void TAppDecTop::xDestroyDecLib()
393{
394
395  for(Int viewDepthIdx=0; viewDepthIdx<m_tVideoIOYuvReconFile.size() ; viewDepthIdx++)
396  {
397    if( m_tVideoIOYuvReconFile[viewDepthIdx] )
398    {
399      m_tVideoIOYuvReconFile[viewDepthIdx]->close();
400      delete m_tVideoIOYuvReconFile[viewDepthIdx]; 
401      m_tVideoIOYuvReconFile[viewDepthIdx] = NULL ;
402    }
403  }
404
405  for(Int viewDepthIdx=0; viewDepthIdx<m_tDecTop.size() ; viewDepthIdx++)
406  {
407    if( m_tDecTop[viewDepthIdx] )
408    {
409      if( !m_useDepth && (viewDepthIdx % 2 == 1) )
410      {
411      }
412      else
413      {
414        m_tDecTop[viewDepthIdx]->deletePicBuffer();
415        m_tDecTop[viewDepthIdx]->destroy() ;
416      }
417#if QC_MVHEVC_B0046
418      if(viewDepthIdx)
419      {
420         //Call clear function to remove the record, which has been freed during viewDepthIdx = 0 case.
421        m_tDecTop[viewDepthIdx]->xGetParaSetDec()->clearSPS();
422        m_tDecTop[viewDepthIdx]->xGetParaSetDec()->clearVPS();
423        m_tDecTop[viewDepthIdx]->xGetParaSetDec()->clearPPS();
424      }
425#endif
426      delete m_tDecTop[viewDepthIdx] ; 
427      m_tDecTop[viewDepthIdx] = NULL ;
428    }
429  }
430
431  m_cCamParsCollector.uninit();
432  if( m_pScaleOffsetFile ) 
433  { 
434    ::fclose( m_pScaleOffsetFile ); 
435  }
436}
437
438Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic, Int viewDepthId, UInt tId )
439{
440  TComList<TComPic*>::iterator iterPic   = pcListPic->begin();
441  Int not_displayed = 0;
442
443  while (iterPic != pcListPic->end())
444  {
445    TComPic* pcPic = *(iterPic);
446    if(pcPic->getOutputMark() && pcPic->getPOC() > m_pocLastDisplay[viewDepthId])
447    {
448       not_displayed++;
449    }
450    iterPic++;
451  }
452  iterPic   = pcListPic->begin();
453 
454  while (iterPic != pcListPic->end())
455  {
456    TComPic* pcPic = *(iterPic);
457    TComSPS *sps = pcPic->getSlice(0)->getSPS();
458   
459    if ( pcPic->getOutputMark() && (not_displayed >  pcPic->getSlice(0)->getSPS()->getNumReorderPics(tId) && pcPic->getPOC() > m_pocLastDisplay[viewDepthId]))
460    {
461      // write to file
462       not_displayed--;
463      if ( m_pchReconFile )
464      {
465        m_tVideoIOYuvReconFile[viewDepthId]->write( pcPic->getPicYuvRec(), sps->getPicCropLeftOffset(), sps->getPicCropRightOffset(), sps->getPicCropTopOffset(), sps->getPicCropBottomOffset() );
466      }
467     
468      // update POC of display order
469      m_pocLastDisplay[viewDepthId] = pcPic->getPOC();
470     
471      // erase non-referenced picture in the reference picture list after display
472      if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
473      {
474#if !DYN_REF_FREE
475        pcPic->setReconMark(false);
476       
477        // mark it should be extended later
478        pcPic->getPicYuvRec()->setBorderExtension( false );
479       
480#else
481        pcPic->destroy();
482        pcListPic->erase( iterPic );
483        iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
484        continue;
485#endif
486      }
487      pcPic->setOutputMark(false);
488    }
489   
490    iterPic++;
491  }
492}
493
494/** \param pcListPic list of pictures to be written to file
495    \todo            DYN_REF_FREE should be revised
496 */
497Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic, Int viewDepthId )
498{
499  if(!pcListPic)
500  {
501    return;
502  } 
503  TComList<TComPic*>::iterator iterPic   = pcListPic->begin();
504
505  iterPic   = pcListPic->begin();
506 
507  while (iterPic != pcListPic->end())
508  {
509    TComPic* pcPic = *(iterPic);
510    TComSPS *sps = pcPic->getSlice(0)->getSPS();
511
512    if ( pcPic->getOutputMark() )
513    {
514      // write to file
515      if ( m_pchReconFile )
516      {
517        m_tVideoIOYuvReconFile[viewDepthId]->write( pcPic->getPicYuvRec(), sps->getPicCropLeftOffset(), sps->getPicCropRightOffset(), sps->getPicCropTopOffset(), sps->getPicCropBottomOffset() );
518      }
519     
520      // update POC of display order
521      m_pocLastDisplay[viewDepthId] = pcPic->getPOC();
522     
523      // erase non-referenced picture in the reference picture list after display
524      if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
525      {
526#if !DYN_REF_FREE
527        pcPic->setReconMark(false);
528       
529        // mark it should be extended later
530        pcPic->getPicYuvRec()->setBorderExtension( false );
531       
532#else
533        pcPic->destroy();
534        pcListPic->erase( iterPic );
535        iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
536        continue;
537#endif
538      }
539      pcPic->setOutputMark(false);
540    }
541   
542    iterPic++;
543  }
544  pcListPic->clear();
545  m_pocLastDisplay[viewDepthId] = -MAX_INT;
546}
547#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
548Void  TAppDecTop::increaseNumberOfViews  ( UInt layerId, UInt viewId, UInt isDepth )
549#else
550Void  TAppDecTop::increaseNumberOfViews  ( Int newNumberOfViewDepth )
551#endif
552{
553#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
554  Int newNumberOfViewDepth = layerId + 1;
555#endif
556  if ( m_outputBitDepth == 0 )
557  {
558    m_outputBitDepth = g_uiBitDepth + g_uiBitIncrement;
559  }
560#if !VIDYO_VPS_INTEGRATION&!QC_MVHEVC_B0046
561  Int viewId = (newNumberOfViewDepth-1)>>1;   // coding order T0D0T1D1T2D2
562  Bool isDepth = ((newNumberOfViewDepth % 2) == 0);  // coding order T0D0T1D1T2D2
563#endif
564  if( isDepth )
565    m_useDepth = true;
566
567  if ( m_pchReconFile )
568  { 
569    while( m_tVideoIOYuvReconFile.size() < newNumberOfViewDepth)
570    {
571      m_tVideoIOYuvReconFile.push_back(new TVideoIOYuv);
572      Char buffer[4];
573#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
574      sprintf(buffer,"_%i", viewId );
575#else
576      sprintf(buffer,"_%i", (Int)(m_tVideoIOYuvReconFile.size()-1) / 2 );
577#endif
578      Char* nextFilename = NULL;
579#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
580      if( isDepth)
581#else
582      if( (m_tVideoIOYuvReconFile.size() % 2) == 0 )
583#endif
584      {
585        Char* pchTempFilename = NULL;
586        xAppendToFileNameEnd( m_pchReconFile, "_depth", pchTempFilename);
587        xAppendToFileNameEnd( pchTempFilename, buffer, nextFilename);
588        free ( pchTempFilename );
589      }
590      else
591      {
592        xAppendToFileNameEnd( m_pchReconFile, buffer, nextFilename);
593      }
594#if !VIDYO_VPS_INTEGRATION&!QC_MVHEVC_B0046
595      if( isDepth || ( !isDepth && (m_tVideoIOYuvReconFile.size() % 2) == 1 ) )
596#endif
597      {
598        m_tVideoIOYuvReconFile.back()->open( nextFilename, true, m_outputBitDepth, g_uiBitDepth + g_uiBitIncrement );
599      }
600      free ( nextFilename );
601    }
602  }
603
604  while( m_pocLastDisplay.size() < newNumberOfViewDepth )
605  {
606    m_pocLastDisplay.push_back(-MAX_INT+m_iSkipFrame);
607  }
608  while( m_tDecTop.size() < newNumberOfViewDepth)
609  {
610    m_tDecTop.push_back(new TDecTop);
611#if !VIDYO_VPS_INTEGRATION&!QC_MVHEVC_B0046
612    if( isDepth || ( !isDepth && (m_tVideoIOYuvReconFile.size() % 2) == 1 ) )
613    {
614#endif
615      m_tDecTop.back()->create();
616      m_tDecTop.back()->init( this, newNumberOfViewDepth == 1);
617      m_tDecTop.back()->setViewId( viewId );
618      m_tDecTop.back()->setIsDepth( isDepth );
619      m_tDecTop.back()->setPictureDigestEnabled(m_pictureDigestEnabled);
620      m_tDecTop.back()->setCamParsCollector( &m_cCamParsCollector );
621#if !VIDYO_VPS_INTEGRATION&!QC_MVHEVC_B0046
622    }
623#endif
624  }
625}
626
627TDecTop* TAppDecTop::getTDecTop( Int viewId, Bool isDepth )
628{ 
629#if FLEX_CODING_ORDER_M23723
630  Int viewnumber=0;
631  Int i=0;
632  Bool fcoFlag=0;
633  if (viewId>m_fcoViewDepthId)
634  {
635    return NULL;
636  }
637  else
638  {
639    if (isDepth)
640   {
641      for ( i=0; i<=m_fcoViewDepthId;i++)
642      {
643         if (m_fcoOrder[i]=='D')
644         {
645           if (viewnumber==viewId)
646           {
647             fcoFlag=1;
648             break;
649           }
650           else
651             viewnumber++;
652         }
653      }
654    }
655    else
656    {
657      for ( i=0; i<=m_fcoViewDepthId;i++)
658      {
659        if (m_fcoOrder[i]=='T')
660        {
661          if (viewnumber==viewId)
662          {
663            fcoFlag=1;
664            break;
665          }
666          else
667            viewnumber++;
668        }
669      }
670    }
671    if (fcoFlag)
672    {
673      return m_tDecTop[i];
674    }
675    else
676      return NULL;
677   
678  }
679
680    // coding order T0D0T1D1T2D2
681#else
682  return m_tDecTop[(isDepth ? 1 : 0) + viewId * 2];  // coding order T0D0T1D1T2D2
683#endif
684 
685} 
686
687std::vector<TComPic*> TAppDecTop::getInterViewRefPics( Int viewId, Int poc, Bool isDepth, TComSPS* sps )
688{
689  std::vector<TComPic*> apcRefPics( sps->getNumberOfUsableInterViewRefs(), (TComPic*)NULL );
690  for( Int k = 0; k < sps->getNumberOfUsableInterViewRefs(); k++ )
691  {
692    TComPic* pcRefPic = xGetPicFromView( sps->getUsableInterViewRef( k ) + viewId, poc, isDepth );
693    assert( pcRefPic != NULL );
694    apcRefPics[k] = pcRefPic;
695  }
696  return apcRefPics;
697}
698
699TComPic* TAppDecTop::xGetPicFromView( Int viewId, Int poc, Bool isDepth )
700{
701  assert( ( viewId >= 0 ) );
702
703#if FLEX_CODING_ORDER_M23723
704if (getTDecTop(viewId,isDepth))
705{
706  TComList<TComPic*>* apcListPic = getTDecTop( viewId, isDepth )->getListPic();
707  TComPic* pcPic = NULL;
708  for( TComList<TComPic*>::iterator it=apcListPic->begin(); it!=apcListPic->end(); it++ )
709  {
710    if( (*it)->getPOC() == poc )
711    {
712      pcPic = *it;
713      break;
714    }
715  }
716  return pcPic;
717}
718else
719  return NULL;
720#else
721
722  TComList<TComPic*>* apcListPic = getTDecTop( viewId, isDepth )->getListPic();
723  TComPic* pcPic = NULL;
724  for( TComList<TComPic*>::iterator it=apcListPic->begin(); it!=apcListPic->end(); it++ )
725  {
726    if( (*it)->getPOC() == poc )
727    {
728      pcPic = *it;
729      break;
730    }
731  }
732  return pcPic;
733#endif
734}
735
736#if MERL_VSP_C0152
737Void TAppDecTop::setBWVSPLUT(TComSlice* pcSlice,  Int iCodedViewIdx,  Int iCurPoc)
738{
739  //first view does not have VSP
740  if((iCodedViewIdx == 0)) return;
741
742  AOT( iCodedViewIdx <= 0);
743  //AOT( iCodedViewIdx >= m_iNumberOfViews );
744  Int iNeighborViewId = 0;
745  //  Int* piShiftLUT = bRenderFromLeft ? m_cCamParsCollector.getBaseViewShiftLUTI()[iCodedViewIdx][iNeighborViewId][0] : m_cCamParsCollector.getBaseViewShiftLUTI()[iNeighborViewId][iCodedViewIdx][0];
746  Int* piShiftLUT = m_cCamParsCollector.getBaseViewShiftLUTI()[iNeighborViewId][iCodedViewIdx][0];
747  pcSlice->setBWVSPLUTParam(piShiftLUT, 2-LOG2_DISP_PREC_LUT );
748}
749#endif
750
751//! \}
Note: See TracBrowser for help on using the repository browser.