source: 3DVCSoftware/branches/HTM-5.1-dev0/source/App/TAppDecoder/TAppDecTop.cpp @ 289

Last change on this file since 289 was 289, checked in by tech, 11 years ago

Clean up of macros related to NBDV.

  • Property svn:eol-style set to native
File size: 23.0 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 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          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#if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER
372        xWriteOutput( pcListPic[viewDepthId], viewDepthId, nalu.m_temporalId );
373#else
374        xWriteOutput( pcListPic[viewDepthId], viewDepthId );
375#endif
376      }
377    }
378    previousViewDepthId = viewDepthId;
379  } 
380  if( m_cCamParsCollector.isInitialized() )
381  {
382    m_cCamParsCollector.setSlice( 0 );
383  }
384  // last frame
385  for( Int viewDepthIdx = 0; viewDepthIdx < m_tDecTop.size(); viewDepthIdx++ )
386  {
387    xFlushOutput( pcListPic[viewDepthIdx], viewDepthIdx );
388  } 
389  xDestroyDecLib();
390}
391
392// ====================================================================================================================
393// Protected member functions
394// ====================================================================================================================
395
396Void TAppDecTop::xDestroyDecLib()
397{
398
399  for(Int viewDepthIdx=0; viewDepthIdx<m_tVideoIOYuvReconFile.size() ; viewDepthIdx++)
400  {
401    if( m_tVideoIOYuvReconFile[viewDepthIdx] )
402    {
403      m_tVideoIOYuvReconFile[viewDepthIdx]->close();
404      delete m_tVideoIOYuvReconFile[viewDepthIdx]; 
405      m_tVideoIOYuvReconFile[viewDepthIdx] = NULL ;
406    }
407  }
408
409  for(Int viewDepthIdx=0; viewDepthIdx<m_tDecTop.size() ; viewDepthIdx++)
410  {
411    if( m_tDecTop[viewDepthIdx] )
412    {
413      if( !m_useDepth && (viewDepthIdx % 2 == 1) )
414      {
415      }
416      else
417      {
418        m_tDecTop[viewDepthIdx]->deletePicBuffer();
419        m_tDecTop[viewDepthIdx]->destroy() ;
420      }
421#if QC_MVHEVC_B0046
422      if(viewDepthIdx)
423      {
424         //Call clear function to remove the record, which has been freed during viewDepthIdx = 0 case.
425        m_tDecTop[viewDepthIdx]->xGetParaSetDec()->clearSPS();
426        m_tDecTop[viewDepthIdx]->xGetParaSetDec()->clearVPS();
427        m_tDecTop[viewDepthIdx]->xGetParaSetDec()->clearPPS();
428      }
429#endif
430      delete m_tDecTop[viewDepthIdx] ; 
431      m_tDecTop[viewDepthIdx] = NULL ;
432    }
433  }
434
435  m_cCamParsCollector.uninit();
436  if( m_pScaleOffsetFile ) 
437  { 
438    ::fclose( m_pScaleOffsetFile ); 
439  }
440}
441
442#if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER
443Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic, Int viewDepthId, UInt tId )
444#else
445Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic, Int viewDepthId )
446#endif
447{
448  TComList<TComPic*>::iterator iterPic   = pcListPic->begin();
449  Int not_displayed = 0;
450
451  while (iterPic != pcListPic->end())
452  {
453    TComPic* pcPic = *(iterPic);
454    if(pcPic->getOutputMark() && pcPic->getPOC() > m_pocLastDisplay[viewDepthId])
455    {
456       not_displayed++;
457    }
458    iterPic++;
459  }
460  iterPic   = pcListPic->begin();
461 
462  while (iterPic != pcListPic->end())
463  {
464    TComPic* pcPic = *(iterPic);
465#if PIC_CROPPING
466    TComSPS *sps = pcPic->getSlice(0)->getSPS();
467#endif
468   
469#if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER
470    if ( pcPic->getOutputMark() && (not_displayed >  pcPic->getSlice(0)->getSPS()->getNumReorderPics(tId) && pcPic->getPOC() > m_pocLastDisplay[viewDepthId]))
471#else
472    if ( pcPic->getOutputMark() && (not_displayed >  pcPic->getSlice(0)->getSPS()->getNumReorderFrames() && pcPic->getPOC() > m_pocLastDisplay[viewDepthId]))
473#endif
474    {
475      // write to file
476       not_displayed--;
477      if ( m_pchReconFile )
478      {
479#if PIC_CROPPING
480        m_tVideoIOYuvReconFile[viewDepthId]->write( pcPic->getPicYuvRec(), sps->getPicCropLeftOffset(), sps->getPicCropRightOffset(), sps->getPicCropTopOffset(), sps->getPicCropBottomOffset() );
481#else
482        m_tVideoIOYuvReconFile[viewDepthId]->write( pcPic->getPicYuvRec(), pcPic->getSlice(0)->getSPS()->getPad() );
483#endif
484      }
485     
486      // update POC of display order
487      m_pocLastDisplay[viewDepthId] = pcPic->getPOC();
488     
489      // erase non-referenced picture in the reference picture list after display
490      if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
491      {
492#if !DYN_REF_FREE
493        pcPic->setReconMark(false);
494       
495        // mark it should be extended later
496        pcPic->getPicYuvRec()->setBorderExtension( false );
497       
498#else
499        pcPic->destroy();
500        pcListPic->erase( iterPic );
501        iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
502        continue;
503#endif
504      }
505      pcPic->setOutputMark(false);
506    }
507   
508    iterPic++;
509  }
510}
511
512/** \param pcListPic list of pictures to be written to file
513    \todo            DYN_REF_FREE should be revised
514 */
515Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic, Int viewDepthId )
516{
517  if(!pcListPic)
518  {
519    return;
520  } 
521  TComList<TComPic*>::iterator iterPic   = pcListPic->begin();
522
523  iterPic   = pcListPic->begin();
524 
525  while (iterPic != pcListPic->end())
526  {
527    TComPic* pcPic = *(iterPic);
528#if PIC_CROPPING
529    TComSPS *sps = pcPic->getSlice(0)->getSPS();
530#endif
531
532    if ( pcPic->getOutputMark() )
533    {
534      // write to file
535      if ( m_pchReconFile )
536      {
537#if PIC_CROPPING
538        m_tVideoIOYuvReconFile[viewDepthId]->write( pcPic->getPicYuvRec(), sps->getPicCropLeftOffset(), sps->getPicCropRightOffset(), sps->getPicCropTopOffset(), sps->getPicCropBottomOffset() );
539#else
540        m_tVideoIOYuvReconFile[viewDepthId]->write( pcPic->getPicYuvRec(), pcPic->getSlice(0)->getSPS()->getPad() );
541#endif
542      }
543     
544      // update POC of display order
545      m_pocLastDisplay[viewDepthId] = pcPic->getPOC();
546     
547      // erase non-referenced picture in the reference picture list after display
548      if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
549      {
550#if !DYN_REF_FREE
551        pcPic->setReconMark(false);
552       
553        // mark it should be extended later
554        pcPic->getPicYuvRec()->setBorderExtension( false );
555       
556#else
557        pcPic->destroy();
558        pcListPic->erase( iterPic );
559        iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
560        continue;
561#endif
562      }
563      pcPic->setOutputMark(false);
564    }
565   
566    iterPic++;
567  }
568  pcListPic->clear();
569  m_pocLastDisplay[viewDepthId] = -MAX_INT;
570}
571#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
572Void  TAppDecTop::increaseNumberOfViews  ( UInt layerId, UInt viewId, UInt isDepth )
573#else
574Void  TAppDecTop::increaseNumberOfViews  ( Int newNumberOfViewDepth )
575#endif
576{
577#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
578  Int newNumberOfViewDepth = layerId + 1;
579#endif
580  if ( m_outputBitDepth == 0 )
581  {
582    m_outputBitDepth = g_uiBitDepth + g_uiBitIncrement;
583  }
584#if !VIDYO_VPS_INTEGRATION&!QC_MVHEVC_B0046
585  Int viewId = (newNumberOfViewDepth-1)>>1;   // coding order T0D0T1D1T2D2
586  Bool isDepth = ((newNumberOfViewDepth % 2) == 0);  // coding order T0D0T1D1T2D2
587#endif
588  if( isDepth )
589    m_useDepth = true;
590
591  if ( m_pchReconFile )
592  { 
593    while( m_tVideoIOYuvReconFile.size() < newNumberOfViewDepth)
594    {
595      m_tVideoIOYuvReconFile.push_back(new TVideoIOYuv);
596      Char buffer[4];
597#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
598      sprintf(buffer,"_%i", viewId );
599#else
600      sprintf(buffer,"_%i", (Int)(m_tVideoIOYuvReconFile.size()-1) / 2 );
601#endif
602      Char* nextFilename = NULL;
603#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
604      if( isDepth)
605#else
606      if( (m_tVideoIOYuvReconFile.size() % 2) == 0 )
607#endif
608      {
609        Char* pchTempFilename = NULL;
610        xAppendToFileNameEnd( m_pchReconFile, "_depth", pchTempFilename);
611        xAppendToFileNameEnd( pchTempFilename, buffer, nextFilename);
612        free ( pchTempFilename );
613      }
614      else
615      {
616        xAppendToFileNameEnd( m_pchReconFile, buffer, nextFilename);
617      }
618#if !VIDYO_VPS_INTEGRATION&!QC_MVHEVC_B0046
619      if( isDepth || ( !isDepth && (m_tVideoIOYuvReconFile.size() % 2) == 1 ) )
620#endif
621      {
622        m_tVideoIOYuvReconFile.back()->open( nextFilename, true, m_outputBitDepth, g_uiBitDepth + g_uiBitIncrement );
623      }
624      free ( nextFilename );
625    }
626  }
627
628  while( m_pocLastDisplay.size() < newNumberOfViewDepth )
629  {
630    m_pocLastDisplay.push_back(-MAX_INT+m_iSkipFrame);
631  }
632  while( m_tDecTop.size() < newNumberOfViewDepth)
633  {
634    m_tDecTop.push_back(new TDecTop);
635#if !VIDYO_VPS_INTEGRATION&!QC_MVHEVC_B0046
636    if( isDepth || ( !isDepth && (m_tVideoIOYuvReconFile.size() % 2) == 1 ) )
637    {
638#endif
639      m_tDecTop.back()->create();
640      m_tDecTop.back()->init( this, newNumberOfViewDepth == 1);
641      m_tDecTop.back()->setViewId( viewId );
642      m_tDecTop.back()->setIsDepth( isDepth );
643      m_tDecTop.back()->setPictureDigestEnabled(m_pictureDigestEnabled);
644      m_tDecTop.back()->setCamParsCollector( &m_cCamParsCollector );
645#if !VIDYO_VPS_INTEGRATION&!QC_MVHEVC_B0046
646    }
647#endif
648  }
649}
650
651TDecTop* TAppDecTop::getTDecTop( Int viewId, Bool isDepth )
652{ 
653#if FLEX_CODING_ORDER_M23723
654  Int viewnumber=0;
655  Int i=0;
656  Bool fcoFlag=0;
657  if (viewId>m_fcoViewDepthId)
658  {
659    return NULL;
660  }
661  else
662  {
663    if (isDepth)
664   {
665      for ( i=0; i<=m_fcoViewDepthId;i++)
666      {
667         if (m_fcoOrder[i]=='D')
668         {
669           if (viewnumber==viewId)
670           {
671             fcoFlag=1;
672             break;
673           }
674           else
675             viewnumber++;
676         }
677      }
678    }
679    else
680    {
681      for ( i=0; i<=m_fcoViewDepthId;i++)
682      {
683        if (m_fcoOrder[i]=='T')
684        {
685          if (viewnumber==viewId)
686          {
687            fcoFlag=1;
688            break;
689          }
690          else
691            viewnumber++;
692        }
693      }
694    }
695    if (fcoFlag)
696    {
697      return m_tDecTop[i];
698    }
699    else
700      return NULL;
701   
702  }
703
704    // coding order T0D0T1D1T2D2
705#else
706  return m_tDecTop[(isDepth ? 1 : 0) + viewId * 2];  // coding order T0D0T1D1T2D2
707#endif
708 
709} 
710
711std::vector<TComPic*> TAppDecTop::getInterViewRefPics( Int viewId, Int poc, Bool isDepth, TComSPS* sps )
712{
713  std::vector<TComPic*> apcRefPics( sps->getNumberOfUsableInterViewRefs(), (TComPic*)NULL );
714  for( Int k = 0; k < sps->getNumberOfUsableInterViewRefs(); k++ )
715  {
716    TComPic* pcRefPic = xGetPicFromView( sps->getUsableInterViewRef( k ) + viewId, poc, isDepth );
717    assert( pcRefPic != NULL );
718    apcRefPics[k] = pcRefPic;
719  }
720  return apcRefPics;
721}
722
723TComPic* TAppDecTop::xGetPicFromView( Int viewId, Int poc, Bool isDepth )
724{
725  assert( ( viewId >= 0 ) );
726
727#if FLEX_CODING_ORDER_M23723
728if (getTDecTop(viewId,isDepth))
729{
730  TComList<TComPic*>* apcListPic = getTDecTop( viewId, isDepth )->getListPic();
731  TComPic* pcPic = NULL;
732  for( TComList<TComPic*>::iterator it=apcListPic->begin(); it!=apcListPic->end(); it++ )
733  {
734    if( (*it)->getPOC() == poc )
735    {
736      pcPic = *it;
737      break;
738    }
739  }
740  return pcPic;
741}
742else
743  return NULL;
744#else
745
746  TComList<TComPic*>* apcListPic = getTDecTop( viewId, isDepth )->getListPic();
747  TComPic* pcPic = NULL;
748  for( TComList<TComPic*>::iterator it=apcListPic->begin(); it!=apcListPic->end(); it++ )
749  {
750    if( (*it)->getPOC() == poc )
751    {
752      pcPic = *it;
753      break;
754    }
755  }
756  return pcPic;
757#endif
758}
759
760#if MERL_VSP_C0152
761Void TAppDecTop::setBWVSPLUT(TComSlice* pcSlice,  Int iCodedViewIdx,  Int iCurPoc)
762{
763  //first view does not have VSP
764  if((iCodedViewIdx == 0)) return;
765
766  AOT( iCodedViewIdx <= 0);
767  //AOT( iCodedViewIdx >= m_iNumberOfViews );
768  Int iNeighborViewId = 0;
769  //  Int* piShiftLUT = bRenderFromLeft ? m_cCamParsCollector.getBaseViewShiftLUTI()[iCodedViewIdx][iNeighborViewId][0] : m_cCamParsCollector.getBaseViewShiftLUTI()[iNeighborViewId][iCodedViewIdx][0];
770  Int* piShiftLUT = m_cCamParsCollector.getBaseViewShiftLUTI()[iNeighborViewId][iCodedViewIdx][0];
771  pcSlice->setBWVSPLUTParam(piShiftLUT, 2-LOG2_DISP_PREC_LUT );
772}
773#endif
774
775//! \}
Note: See TracBrowser for help on using the repository browser.