source: 3DVCSoftware/branches/HTM-5.1-dev2-Sony/source/App/TAppDecoder/TAppDecTop.cpp @ 262

Last change on this file since 262 was 262, checked in by sony, 11 years ago

JCT2-C0115 Inter-view vector scaling for TMVP & flag
The macro is INTER_VIEW_VECTOR_SCALING_C0115.

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