source: SHVCSoftware/branches/SHM-2.0-dev/source/App/TAppDecoder/TAppDecTop.cpp @ 579

Last change on this file since 579 was 187, checked in by seregin, 12 years ago

enable zero number of direct references, fix for AVC base YUV input

File size: 21.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-2013, 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
55#if SVC_EXTENSION
56TAppDecTop::TAppDecTop()
57{
58  ::memset (m_abDecFlag, 0, sizeof (m_abDecFlag));
59  for(UInt layer=0; layer < MAX_LAYERS; layer++)
60  {
61    m_aiPOCLastDisplay[layer]  = -MAX_INT;
62    m_apcTDecTop[layer] = &m_acTDecTop[layer];
63  }
64}
65#else
66TAppDecTop::TAppDecTop()
67: m_iPOCLastDisplay(-MAX_INT)
68{
69  ::memset (m_abDecFlag, 0, sizeof (m_abDecFlag));
70}
71#endif
72
73Void TAppDecTop::create()
74{
75}
76
77Void TAppDecTop::destroy()
78{
79  if (m_pchBitstreamFile)
80  {
81    free (m_pchBitstreamFile);
82    m_pchBitstreamFile = NULL;
83  }
84#if SVC_EXTENSION   
85  for( Int i = 0; i < m_tgtLayerId; i++ )
86  {
87    if( m_pchReconFile[i] )
88    {
89      free ( m_pchReconFile[i] );
90      m_pchReconFile[i] = NULL;
91    }
92  } 
93#if AVC_BASE
94  if( m_pchBLReconFile )
95  {
96    free ( m_pchBLReconFile );
97    m_pchBLReconFile = NULL;
98  }
99#endif
100#else
101  if (m_pchReconFile)
102  {
103    free (m_pchReconFile);
104    m_pchReconFile = NULL;
105  }
106#endif
107#if AVC_SYNTAX || SYNTAX_OUTPUT
108  if( m_pchBLSyntaxFile )
109  {
110    free ( m_pchBLSyntaxFile );
111    m_pchBLSyntaxFile = NULL;
112  }
113#endif
114}
115
116// ====================================================================================================================
117// Public member functions
118// ====================================================================================================================
119
120/**
121 - create internal class
122 - initialize internal class
123 - until the end of the bitstream, call decoding function in TDecTop class
124 - delete allocated buffers
125 - destroy internal class
126 .
127 */
128#if SVC_EXTENSION
129Void TAppDecTop::decode()
130{
131  Int                poc;
132  TComList<TComPic*>* pcListPic = NULL;
133
134  ifstream bitstreamFile(m_pchBitstreamFile, ifstream::in | ifstream::binary);
135  if (!bitstreamFile)
136  {
137    fprintf(stderr, "\nfailed to open bitstream file `%s' for reading\n", m_pchBitstreamFile);
138    exit(EXIT_FAILURE);
139  }
140
141  InputByteStream bytestream(bitstreamFile);
142
143  // create & initialize internal classes
144  xCreateDecLib();
145  xInitDecLib  ();
146
147  // main decoder loop
148  Bool recon_opened[MAX_LAYERS]; // reconstruction file not yet opened. (must be performed after SPS is seen)
149  for(UInt layer=0; layer<=m_tgtLayerId; layer++)
150  {
151    recon_opened[layer] = false;
152    m_aiPOCLastDisplay[layer] += m_iSkipFrame;      // set the last displayed POC correctly for skip forward.
153  }
154
155  UInt curLayerId = 0;     // current layer to be reconstructed
156
157#if AVC_BASE
158  TComPic pcBLPic;
159  fstream streamYUV;
160  if( m_pchBLReconFile )
161  {
162    streamYUV.open( m_pchBLReconFile, fstream::in | fstream::binary );
163  }
164  TComList<TComPic*> *cListPic = m_acTDecTop[0].getListPic();
165  m_acTDecTop[0].setBLsize( m_iBLSourceWidth, m_iBLSourceHeight );
166  m_acTDecTop[0].setBLReconFile( &streamYUV );
167  pcBLPic.setLayerId( 0 );
168  cListPic->pushBack( &pcBLPic );
169#if AVC_SYNTAX
170  fstream streamSyntaxFile;
171  if( m_pchBLSyntaxFile )
172  {
173    streamSyntaxFile.open( m_pchBLSyntaxFile, fstream::in | fstream::binary );
174  }
175  m_acTDecTop[0].setBLSyntaxFile( &streamSyntaxFile );
176#endif
177#endif
178
179  while (!!bitstreamFile)
180  {
181    /* location serves to work around a design fault in the decoder, whereby
182     * the process of reading a new slice that is the first slice of a new frame
183     * requires the TDecTop::decode() method to be called again with the same
184     * nal unit. */
185    streampos location = bitstreamFile.tellg();
186    AnnexBStats stats = AnnexBStats();
187
188    vector<uint8_t> nalUnit;
189    InputNALUnit nalu;
190    byteStreamNALUnit(bytestream, nalUnit, stats);
191
192    // call actual decoding function
193    Bool bNewPicture = false;
194    Bool bNewPOC = false;
195    if (nalUnit.empty())
196    {
197      /* this can happen if the following occur:
198       *  - empty input file
199       *  - two back-to-back start_code_prefixes
200       *  - start_code_prefix immediately followed by EOF
201       */
202      fprintf(stderr, "Warning: Attempt to decode an empty NAL unit\n");
203    }
204    else
205    {
206      read(nalu, nalUnit);
207      if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu)  ||
208        (nalu.m_layerId > m_tgtLayerId) )
209      {
210        bNewPicture = false;
211      }
212      else
213      {
214        bNewPicture = m_acTDecTop[nalu.m_layerId].decode(nalu, m_iSkipFrame, m_aiPOCLastDisplay[nalu.m_layerId], curLayerId, bNewPOC);
215        if (bNewPicture)
216        {
217          bitstreamFile.clear();
218          /* location points to the current nalunit payload[1] due to the
219           * need for the annexB parser to read three extra bytes.
220           * [1] except for the first NAL unit in the file
221           *     (but bNewPicture doesn't happen then) */
222          bitstreamFile.seekg(location-streamoff(3));
223          bytestream.reset();
224        }
225      }
226    }
227    if (bNewPicture || !bitstreamFile)
228    {
229      m_acTDecTop[curLayerId].executeLoopFilters(poc, pcListPic);
230    }
231
232    if( pcListPic )
233    {
234      if ( m_pchReconFile[curLayerId] && !recon_opened[curLayerId] )
235      {
236        if (!m_outputBitDepthY) { m_outputBitDepthY = g_bitDepthY; }       
237        if (!m_outputBitDepthC) { m_outputBitDepthC = g_bitDepthC; }
238
239        m_acTVideoIOYuvReconFile[curLayerId].open( m_pchReconFile[curLayerId], true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode
240
241        recon_opened[curLayerId] = true;
242      }
243      if ( bNewPicture && bNewPOC && 
244           (   nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL
245            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP
246            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP
247            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL
248            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP ) )
249      {
250        xFlushOutput( pcListPic, curLayerId );
251      }
252      // write reconstruction to file
253      if(bNewPicture)
254      {
255        xWriteOutput( pcListPic, curLayerId, nalu.m_temporalId );
256      }
257    }
258  }
259  for(UInt layer = 0; layer <= m_tgtLayerId; layer++)
260  {
261    xFlushOutput( m_acTDecTop[layer].getListPic(), layer );
262  }
263  // delete buffers
264#if AVC_BASE
265  if( streamYUV.is_open() )
266  {
267    streamYUV.close();
268  }
269#if AVC_SYNTAX
270  if( streamSyntaxFile.is_open() )
271  {
272    streamSyntaxFile.close();
273  }
274#endif
275  pcBLPic.destroy();
276
277  for(UInt layer = 1; layer <= m_tgtLayerId; layer++)
278#else
279  for(UInt layer = 0; layer <= m_tgtLayerId; layer++)
280#endif
281  {
282    m_acTDecTop[layer].deletePicBuffer();
283  }
284 
285  // destroy internal classes
286  xDestroyDecLib();
287}
288#else
289Void TAppDecTop::decode()
290{
291  Int                 poc;
292  TComList<TComPic*>* pcListPic = NULL;
293
294  ifstream bitstreamFile(m_pchBitstreamFile, ifstream::in | ifstream::binary);
295  if (!bitstreamFile)
296  {
297    fprintf(stderr, "\nfailed to open bitstream file `%s' for reading\n", m_pchBitstreamFile);
298    exit(EXIT_FAILURE);
299  }
300
301  InputByteStream bytestream(bitstreamFile);
302
303  // create & initialize internal classes
304  xCreateDecLib();
305  xInitDecLib  ();
306  m_iPOCLastDisplay += m_iSkipFrame;      // set the last displayed POC correctly for skip forward.
307
308  // main decoder loop
309  Bool recon_opened = false; // reconstruction file not yet opened. (must be performed after SPS is seen)
310
311#if SYNTAX_OUTPUT
312  if( !m_pchBLSyntaxFile )
313  {
314    printf( "Wrong base layer syntax file\n" );
315    exit(EXIT_FAILURE);
316  }
317  fstream streamSyntaxFile( m_pchBLSyntaxFile, fstream::out | fstream::binary );
318  if( !streamSyntaxFile.good() )
319  {
320    printf( "Base layer syntax input reading error\n" );
321    exit(EXIT_FAILURE);
322  }
323  m_cTDecTop.setBLSyntaxFile( &streamSyntaxFile );
324
325  for( Int i = m_iBLFrames * m_iBLSourceWidth * m_iBLSourceHeight * SYNTAX_BYTES / 16; i >= 0; i-- )
326  {
327    streamSyntaxFile.put( 0 );
328  }
329  streamSyntaxFile.seekp( 0 );
330#endif
331
332  while (!!bitstreamFile)
333  {
334    /* location serves to work around a design fault in the decoder, whereby
335     * the process of reading a new slice that is the first slice of a new frame
336     * requires the TDecTop::decode() method to be called again with the same
337     * nal unit. */
338    streampos location = bitstreamFile.tellg();
339    AnnexBStats stats = AnnexBStats();
340    Bool bPreviousPictureDecoded = false;
341
342    vector<uint8_t> nalUnit;
343    InputNALUnit nalu;
344    byteStreamNALUnit(bytestream, nalUnit, stats);
345
346    // call actual decoding function
347    Bool bNewPicture = false;
348    if (nalUnit.empty())
349    {
350      /* this can happen if the following occur:
351       *  - empty input file
352       *  - two back-to-back start_code_prefixes
353       *  - start_code_prefix immediately followed by EOF
354       */
355      fprintf(stderr, "Warning: Attempt to decode an empty NAL unit\n");
356    }
357    else
358    {
359      read(nalu, nalUnit);
360      if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu)  )
361      {
362        if(bPreviousPictureDecoded)
363        {
364          bNewPicture = true;
365          bPreviousPictureDecoded = false;
366        }
367        else
368        {
369          bNewPicture = false;
370        }
371      }
372      else
373      {
374        bNewPicture = m_cTDecTop.decode(nalu, m_iSkipFrame, m_iPOCLastDisplay);
375        if (bNewPicture)
376        {
377          bitstreamFile.clear();
378          /* location points to the current nalunit payload[1] due to the
379           * need for the annexB parser to read three extra bytes.
380           * [1] except for the first NAL unit in the file
381           *     (but bNewPicture doesn't happen then) */
382          bitstreamFile.seekg(location-streamoff(3));
383          bytestream.reset();
384        }
385        bPreviousPictureDecoded = true; 
386      }
387    }
388    if (bNewPicture || !bitstreamFile)
389    {
390      m_cTDecTop.executeLoopFilters(poc, pcListPic);
391    }
392
393    if( pcListPic )
394    {
395      if ( m_pchReconFile && !recon_opened )
396      {
397        if (!m_outputBitDepthY) { m_outputBitDepthY = g_bitDepthY; }
398        if (!m_outputBitDepthC) { m_outputBitDepthC = g_bitDepthC; }
399
400        m_cTVideoIOYuvReconFile.open( m_pchReconFile, true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode
401        recon_opened = true;
402      }
403      if ( bNewPicture && 
404           (   nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL
405            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP
406            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP
407            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL
408            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP ) )
409      {
410        xFlushOutput( pcListPic );
411      }
412      // write reconstruction to file
413      if(bNewPicture)
414      {
415        xWriteOutput( pcListPic, nalu.m_temporalId );
416      }
417    }
418  }
419 
420#if SYNTAX_OUTPUT
421  if( streamSyntaxFile.is_open() )
422  {
423    streamSyntaxFile.close();
424  }
425#endif
426 
427  xFlushOutput( pcListPic );
428  // delete buffers
429  m_cTDecTop.deletePicBuffer();
430 
431  // destroy internal classes
432  xDestroyDecLib();
433}
434#endif
435
436// ====================================================================================================================
437// Protected member functions
438// ====================================================================================================================
439
440Void TAppDecTop::xCreateDecLib()
441{
442#if SVC_EXTENSION
443  // initialize global variables
444  initROM(); 
445
446  for(UInt layer = 0; layer <= m_tgtLayerId; layer++)
447  {
448    // set layer ID
449    m_acTDecTop[layer].setLayerId                      ( layer );
450
451    // create decoder class
452    m_acTDecTop[layer].create();
453
454    m_acTDecTop[layer].setLayerDec(m_apcTDecTop);   
455  }
456#else
457  // create decoder class
458  m_cTDecTop.create();
459#endif
460}
461
462Void TAppDecTop::xDestroyDecLib()
463{
464#if SVC_EXTENSION
465  // destroy ROM
466  destroyROM();
467
468  for(UInt layer = 0; layer <= m_tgtLayerId; layer++)
469  {
470    if ( m_pchReconFile[layer] )
471    {
472      m_acTVideoIOYuvReconFile[layer]. close();
473    }
474
475    // destroy decoder class
476    m_acTDecTop[layer].destroy();
477  }
478#else
479  if ( m_pchReconFile )
480  {
481    m_cTVideoIOYuvReconFile. close();
482  }
483 
484  // destroy decoder class
485  m_cTDecTop.destroy();
486#endif
487}
488
489Void TAppDecTop::xInitDecLib()
490{
491  // initialize decoder class
492#if SVC_EXTENSION
493  for(UInt layer = 0; layer <= m_tgtLayerId; layer++)
494  {
495    m_acTDecTop[layer].init();
496    m_acTDecTop[layer].setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
497    m_acTDecTop[layer].setNumLayer( m_tgtLayerId + 1 );
498  }
499
500#else
501  m_cTDecTop.init();
502  m_cTDecTop.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
503#endif
504}
505
506/** \param pcListPic list of pictures to be written to file
507    \todo            DYN_REF_FREE should be revised
508 */
509#if SVC_EXTENSION
510Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic, UInt layerId, UInt tId )
511#else
512Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic, UInt tId )
513#endif
514{
515  TComList<TComPic*>::iterator iterPic   = pcListPic->begin();
516  Int not_displayed = 0;
517
518  while (iterPic != pcListPic->end())
519  {
520    TComPic* pcPic = *(iterPic);
521#if SVC_EXTENSION
522    if(pcPic->getOutputMark() && pcPic->getPOC() > m_aiPOCLastDisplay[layerId])
523#else
524    if(pcPic->getOutputMark() && pcPic->getPOC() > m_iPOCLastDisplay)
525#endif
526    {
527       not_displayed++;
528    }
529    iterPic++;
530  }
531  iterPic   = pcListPic->begin();
532 
533  while (iterPic != pcListPic->end())
534  {
535    TComPic* pcPic = *(iterPic);
536   
537#if SVC_EXTENSION
538    if ( pcPic->getOutputMark() && (not_displayed >  pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_aiPOCLastDisplay[layerId]))
539#else
540    if ( pcPic->getOutputMark() && (not_displayed >  pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_iPOCLastDisplay))
541#endif
542    {
543      // write to file
544       not_displayed--;
545#if SVC_EXTENSION
546      if ( m_pchReconFile[layerId] )
547      {
548        const Window &conf = pcPic->getConformanceWindow();
549        const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
550        m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(),
551                                       conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
552                                       conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
553                                       conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
554                                       conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
555      }
556     
557      // update POC of display order
558      m_aiPOCLastDisplay[layerId] = pcPic->getPOC();
559#else
560      if ( m_pchReconFile )
561      {
562#if SYNTAX_OUTPUT && ILP_DECODED_PICTURE
563        m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec() );
564#else
565        const Window &conf = pcPic->getConformanceWindow();
566        const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
567        m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
568                                       conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
569                                       conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
570                                       conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
571                                       conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
572#endif
573      }
574     
575      // update POC of display order
576      m_iPOCLastDisplay = pcPic->getPOC();
577#endif
578     
579      // erase non-referenced picture in the reference picture list after display
580      if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
581      {
582#if !DYN_REF_FREE
583        pcPic->setReconMark(false);
584       
585        // mark it should be extended later
586        pcPic->getPicYuvRec()->setBorderExtension( false );
587       
588#else
589        pcPic->destroy();
590        pcListPic->erase( iterPic );
591        iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
592        continue;
593#endif
594      }
595      pcPic->setOutputMark(false);
596    }
597   
598    iterPic++;
599  }
600}
601
602/** \param pcListPic list of pictures to be written to file
603    \todo            DYN_REF_FREE should be revised
604 */
605#if SVC_EXTENSION
606Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic, UInt layerId )
607#else
608Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic )
609#endif
610{
611  if(!pcListPic)
612  {
613    return;
614  } 
615  TComList<TComPic*>::iterator iterPic   = pcListPic->begin();
616
617  iterPic   = pcListPic->begin();
618 
619  while (iterPic != pcListPic->end())
620  {
621    TComPic* pcPic = *(iterPic);
622
623    if ( pcPic->getOutputMark() )
624    {
625      // write to file
626#if SVC_EXTENSION
627      if ( m_pchReconFile[layerId] )
628      {
629        const Window &conf = pcPic->getConformanceWindow();
630        const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
631        m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(),
632                                       conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
633                                       conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
634                                       conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
635                                       conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
636      }
637     
638      // update POC of display order
639      m_aiPOCLastDisplay[layerId] = pcPic->getPOC();
640#else
641      if ( m_pchReconFile )
642      {
643        const Window &conf = pcPic->getConformanceWindow();
644        const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
645        m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
646                                       conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
647                                       conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
648                                       conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
649                                       conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
650      }
651     
652      // update POC of display order
653      m_iPOCLastDisplay = pcPic->getPOC();
654#endif
655     
656      // erase non-referenced picture in the reference picture list after display
657      if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
658      {
659#if !DYN_REF_FREE
660        pcPic->setReconMark(false);
661       
662        // mark it should be extended later
663        pcPic->getPicYuvRec()->setBorderExtension( false );
664       
665#else
666        pcPic->destroy();
667        pcListPic->erase( iterPic );
668        iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
669        continue;
670#endif
671      }
672      pcPic->setOutputMark(false);
673    }
674#if !SVC_EXTENSION
675#if !DYN_REF_FREE
676    if(pcPic)
677    {
678      pcPic->destroy();
679      delete pcPic;
680      pcPic = NULL;
681    }
682#endif   
683#endif
684    iterPic++;
685  }
686#if SVC_EXTENSION
687  m_aiPOCLastDisplay[layerId] = -MAX_INT;
688#else
689  pcListPic->clear();
690  m_iPOCLastDisplay = -MAX_INT;
691#endif
692}
693
694/** \param nalu Input nalu to check whether its LayerId is within targetDecLayerIdSet
695 */
696Bool TAppDecTop::isNaluWithinTargetDecLayerIdSet( InputNALUnit* nalu )
697{
698  if ( m_targetDecLayerIdSet.size() == 0 ) // By default, the set is empty, meaning all LayerIds are allowed
699  {
700    return true;
701  }
702  for (std::vector<Int>::iterator it = m_targetDecLayerIdSet.begin(); it != m_targetDecLayerIdSet.end(); it++)
703  {
704    if ( nalu->m_reservedZero6Bits == (*it) )
705    {
706      return true;
707    }
708  }
709  return false;
710}
711
712//! \}
Note: See TracBrowser for help on using the repository browser.