source: 3DVCSoftware/branches/HTM-4.0-Nokia/source/App/TAppDecoder/TAppDecTop.cpp @ 139

Last change on this file since 139 was 139, checked in by nokia, 12 years ago

3DV-HTM v4.0: FCO

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