source: 3DVCSoftware/branches/HTM-5.0-Nokia/source/App/TAppDecoder/TAppDecTop.cpp @ 201

Last change on this file since 201 was 201, checked in by nokia, 11 years ago
  1. Recommended coding style changes
  2. Disabling Compile flags:

#define QC_IV_AS_LT_B0046 0
#define QC_TMVP_IDX_MOD_B0046 0
#define QC_REM_IDV_B0046 0
#define FIX_DEL_NULLPTR 0

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