source: SHVCSoftware/branches/SHM-1.1-dev/source/App/TAppDecoder/TAppDecTop.cpp @ 503

Last change on this file since 503 was 38, checked in by seregin, 12 years ago

AVC_SYNTAX: initial porting of the AVC metadata file reading

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