source: 3DVCSoftware/branches/HTM-5.1-dev3-MERL/source/App/TAppDecoder/TAppDecTop.cpp @ 231

Last change on this file since 231 was 231, checked in by mitsubishi-htm, 11 years ago

-Integration of JCT3V-C0152 & JCT3V-C0131
-This check-in enable C0131 only

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