source: SHVCSoftware/branches/SHM-3.1-dev/source/App/TAppDecoder/TAppDecTop.cpp @ 425

Last change on this file since 425 was 389, checked in by qualcomm, 12 years ago

Signaling representation format in VPS (MACRO: REPN_FORMAT_IN_VPS)

Includes signaling of representation format - including picture resolution, bit depth, chroma format - in the VPS, with the option of updating them in the SPS. The configuration file has "RepFormatIdx%d" added to indicate for each layer which representation format is used. The rep_format() structures are automatically created by the encoder. If the bit depth and the chroma format are also changed across layers, some more configuration support would be needed.

From: Adarsh K. Ramasubramonian <aramasub@…>

  • Property svn:eol-style set to native
File size: 22.8 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#if EARLY_REF_PIC_MARKING
231      m_acTDecTop[curLayerId].earlyPicMarking(m_iMaxTemporalLayer, m_targetDecLayerIdSet);
232#endif
233    }
234
235    if( pcListPic )
236    {
237      if ( m_pchReconFile[curLayerId] && !recon_opened[curLayerId] )
238      {
239        if (!m_outputBitDepthY) { m_outputBitDepthY = g_bitDepthY; }       
240        if (!m_outputBitDepthC) { m_outputBitDepthC = g_bitDepthC; }
241
242        m_acTVideoIOYuvReconFile[curLayerId].open( m_pchReconFile[curLayerId], true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode
243
244        recon_opened[curLayerId] = true;
245      }
246      if ( bNewPicture && bNewPOC && 
247           (   nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL
248            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP
249            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP
250            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL
251            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP ) )
252      {
253        xFlushOutput( pcListPic, curLayerId );
254      }
255      // write reconstruction to file
256      if(bNewPicture)
257      {
258        xWriteOutput( pcListPic, curLayerId, nalu.m_temporalId );
259      }
260    }
261  }
262  for(UInt layer = 0; layer <= m_tgtLayerId; layer++)
263  {
264    xFlushOutput( m_acTDecTop[layer].getListPic(), layer );
265  }
266  // delete buffers
267#if AVC_BASE
268  if( streamYUV.is_open() )
269  {
270    streamYUV.close();
271  }
272#if AVC_SYNTAX
273  if( streamSyntaxFile.is_open() )
274  {
275    streamSyntaxFile.close();
276  }
277#endif
278  pcBLPic.destroy();
279
280  for(UInt layer = 1; layer <= m_tgtLayerId; layer++)
281#else
282  for(UInt layer = 0; layer <= m_tgtLayerId; layer++)
283#endif
284  {
285    m_acTDecTop[layer].deletePicBuffer();
286  }
287 
288  // destroy internal classes
289  xDestroyDecLib();
290}
291#else
292Void TAppDecTop::decode()
293{
294  Int                 poc;
295  TComList<TComPic*>* pcListPic = NULL;
296
297  ifstream bitstreamFile(m_pchBitstreamFile, ifstream::in | ifstream::binary);
298  if (!bitstreamFile)
299  {
300    fprintf(stderr, "\nfailed to open bitstream file `%s' for reading\n", m_pchBitstreamFile);
301    exit(EXIT_FAILURE);
302  }
303
304  InputByteStream bytestream(bitstreamFile);
305
306  // create & initialize internal classes
307  xCreateDecLib();
308  xInitDecLib  ();
309  m_iPOCLastDisplay += m_iSkipFrame;      // set the last displayed POC correctly for skip forward.
310
311  // main decoder loop
312  Bool recon_opened = false; // reconstruction file not yet opened. (must be performed after SPS is seen)
313
314#if SYNTAX_OUTPUT
315  if( !m_pchBLSyntaxFile )
316  {
317    printf( "Wrong base layer syntax file\n" );
318    exit(EXIT_FAILURE);
319  }
320  fstream streamSyntaxFile( m_pchBLSyntaxFile, fstream::out | fstream::binary );
321  if( !streamSyntaxFile.good() )
322  {
323    printf( "Base layer syntax input reading error\n" );
324    exit(EXIT_FAILURE);
325  }
326  m_cTDecTop.setBLSyntaxFile( &streamSyntaxFile );
327
328  for( Int i = m_iBLFrames * m_iBLSourceWidth * m_iBLSourceHeight * SYNTAX_BYTES / 16; i >= 0; i-- )
329  {
330    streamSyntaxFile.put( 0 );
331  }
332  streamSyntaxFile.seekp( 0 );
333#endif
334
335  while (!!bitstreamFile)
336  {
337    /* location serves to work around a design fault in the decoder, whereby
338     * the process of reading a new slice that is the first slice of a new frame
339     * requires the TDecTop::decode() method to be called again with the same
340     * nal unit. */
341    streampos location = bitstreamFile.tellg();
342    AnnexBStats stats = AnnexBStats();
343    Bool bPreviousPictureDecoded = false;
344
345    vector<uint8_t> nalUnit;
346    InputNALUnit nalu;
347    byteStreamNALUnit(bytestream, nalUnit, stats);
348
349    // call actual decoding function
350    Bool bNewPicture = false;
351    if (nalUnit.empty())
352    {
353      /* this can happen if the following occur:
354       *  - empty input file
355       *  - two back-to-back start_code_prefixes
356       *  - start_code_prefix immediately followed by EOF
357       */
358      fprintf(stderr, "Warning: Attempt to decode an empty NAL unit\n");
359    }
360    else
361    {
362      read(nalu, nalUnit);
363      if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu)  )
364      {
365        if(bPreviousPictureDecoded)
366        {
367          bNewPicture = true;
368          bPreviousPictureDecoded = false;
369        }
370        else
371        {
372          bNewPicture = false;
373        }
374      }
375      else
376      {
377        bNewPicture = m_cTDecTop.decode(nalu, m_iSkipFrame, m_iPOCLastDisplay);
378        if (bNewPicture)
379        {
380          bitstreamFile.clear();
381          /* location points to the current nalunit payload[1] due to the
382           * need for the annexB parser to read three extra bytes.
383           * [1] except for the first NAL unit in the file
384           *     (but bNewPicture doesn't happen then) */
385          bitstreamFile.seekg(location-streamoff(3));
386          bytestream.reset();
387        }
388        bPreviousPictureDecoded = true; 
389      }
390    }
391    if (bNewPicture || !bitstreamFile)
392    {
393      m_cTDecTop.executeLoopFilters(poc, pcListPic);
394    }
395
396    if( pcListPic )
397    {
398      if ( m_pchReconFile && !recon_opened )
399      {
400        if (!m_outputBitDepthY) { m_outputBitDepthY = g_bitDepthY; }
401        if (!m_outputBitDepthC) { m_outputBitDepthC = g_bitDepthC; }
402
403        m_cTVideoIOYuvReconFile.open( m_pchReconFile, true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode
404        recon_opened = true;
405      }
406      if ( bNewPicture && 
407           (   nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL
408            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP
409            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP
410            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL
411            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP ) )
412      {
413        xFlushOutput( pcListPic );
414      }
415      // write reconstruction to file
416      if(bNewPicture)
417      {
418        xWriteOutput( pcListPic, nalu.m_temporalId );
419      }
420    }
421  }
422 
423#if SYNTAX_OUTPUT
424  if( streamSyntaxFile.is_open() )
425  {
426    streamSyntaxFile.close();
427  }
428#endif
429 
430  xFlushOutput( pcListPic );
431  // delete buffers
432  m_cTDecTop.deletePicBuffer();
433 
434  // destroy internal classes
435  xDestroyDecLib();
436}
437#endif
438
439// ====================================================================================================================
440// Protected member functions
441// ====================================================================================================================
442
443Void TAppDecTop::xCreateDecLib()
444{
445#if SVC_EXTENSION
446  // initialize global variables
447  initROM(); 
448
449  for(UInt layer = 0; layer <= m_tgtLayerId; layer++)
450  {
451    // set layer ID
452    m_acTDecTop[layer].setLayerId                      ( layer );
453
454    // create decoder class
455    m_acTDecTop[layer].create();
456
457    m_acTDecTop[layer].setLayerDec(m_apcTDecTop);   
458  }
459#else
460  // create decoder class
461  m_cTDecTop.create();
462#endif
463}
464
465Void TAppDecTop::xDestroyDecLib()
466{
467#if SVC_EXTENSION
468  // destroy ROM
469  destroyROM();
470
471  for(UInt layer = 0; layer <= m_tgtLayerId; layer++)
472  {
473    if ( m_pchReconFile[layer] )
474    {
475      m_acTVideoIOYuvReconFile[layer]. close();
476    }
477
478    // destroy decoder class
479    m_acTDecTop[layer].destroy();
480  }
481#else
482  if ( m_pchReconFile )
483  {
484    m_cTVideoIOYuvReconFile. close();
485  }
486 
487  // destroy decoder class
488  m_cTDecTop.destroy();
489#endif
490}
491
492Void TAppDecTop::xInitDecLib()
493{
494  // initialize decoder class
495#if SVC_EXTENSION
496  for(UInt layer = 0; layer <= m_tgtLayerId; layer++)
497  {
498    m_acTDecTop[layer].init();
499    m_acTDecTop[layer].setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
500    m_acTDecTop[layer].setNumLayer( m_tgtLayerId + 1 );
501  }
502
503#else
504  m_cTDecTop.init();
505  m_cTDecTop.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
506#endif
507}
508
509/** \param pcListPic list of pictures to be written to file
510    \todo            DYN_REF_FREE should be revised
511 */
512#if SVC_EXTENSION
513Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic, UInt layerId, UInt tId )
514#else
515Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic, UInt tId )
516#endif
517{
518  TComList<TComPic*>::iterator iterPic   = pcListPic->begin();
519  Int not_displayed = 0;
520
521  while (iterPic != pcListPic->end())
522  {
523    TComPic* pcPic = *(iterPic);
524#if SVC_EXTENSION
525    if(pcPic->getOutputMark() && pcPic->getPOC() > m_aiPOCLastDisplay[layerId])
526#else
527    if(pcPic->getOutputMark() && pcPic->getPOC() > m_iPOCLastDisplay)
528#endif
529    {
530       not_displayed++;
531    }
532    iterPic++;
533  }
534  iterPic   = pcListPic->begin();
535 
536  while (iterPic != pcListPic->end())
537  {
538    TComPic* pcPic = *(iterPic);
539   
540#if SVC_EXTENSION
541    if ( pcPic->getOutputMark() && (not_displayed >  pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_aiPOCLastDisplay[layerId]))
542#else
543    if ( pcPic->getOutputMark() && (not_displayed >  pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_iPOCLastDisplay))
544#endif
545    {
546      // write to file
547       not_displayed--;
548#if SVC_EXTENSION
549      if ( m_pchReconFile[layerId] )
550      {
551        const Window &conf = pcPic->getConformanceWindow();
552        const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
553#if REPN_FORMAT_IN_VPS
554        UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
555        Int xScal =  TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc );
556        m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(),
557                                       conf.getWindowLeftOffset()  * xScal + defDisp.getWindowLeftOffset(),
558                                       conf.getWindowRightOffset() * xScal + defDisp.getWindowRightOffset(),
559                                       conf.getWindowTopOffset()   * yScal + defDisp.getWindowTopOffset(),
560                                       conf.getWindowBottomOffset()* yScal + defDisp.getWindowBottomOffset() );
561
562#else
563        m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(),
564                                       conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
565                                       conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
566                                       conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
567                                       conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
568#endif
569      }
570     
571      // update POC of display order
572      m_aiPOCLastDisplay[layerId] = pcPic->getPOC();
573#else
574      if ( m_pchReconFile )
575      {
576#if SYNTAX_OUTPUT
577        const Window &conf = pcPic->getConformanceWindow();
578        const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
579        m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
580                                       conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
581                                       conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
582                                       conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
583                                       conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
584#endif
585      }
586     
587      // update POC of display order
588      m_iPOCLastDisplay = pcPic->getPOC();
589#endif
590     
591      // erase non-referenced picture in the reference picture list after display
592      if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
593      {
594#if !DYN_REF_FREE
595        pcPic->setReconMark(false);
596       
597        // mark it should be extended later
598        pcPic->getPicYuvRec()->setBorderExtension( false );
599       
600#else
601        pcPic->destroy();
602        pcListPic->erase( iterPic );
603        iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
604        continue;
605#endif
606      }
607      pcPic->setOutputMark(false);
608    }
609   
610    iterPic++;
611  }
612}
613
614/** \param pcListPic list of pictures to be written to file
615    \todo            DYN_REF_FREE should be revised
616 */
617#if SVC_EXTENSION
618Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic, UInt layerId )
619#else
620Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic )
621#endif
622{
623  if(!pcListPic)
624  {
625    return;
626  } 
627  TComList<TComPic*>::iterator iterPic   = pcListPic->begin();
628
629  iterPic   = pcListPic->begin();
630 
631  while (iterPic != pcListPic->end())
632  {
633    TComPic* pcPic = *(iterPic);
634
635    if ( pcPic->getOutputMark() )
636    {
637      // write to file
638#if SVC_EXTENSION
639      if ( m_pchReconFile[layerId] )
640      {
641        const Window &conf = pcPic->getConformanceWindow();
642        const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
643#if REPN_FORMAT_IN_VPS
644        UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
645        Int xScal =  TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc );
646        m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(),
647                                       conf.getWindowLeftOffset()  *xScal + defDisp.getWindowLeftOffset(),
648                                       conf.getWindowRightOffset() *xScal + defDisp.getWindowRightOffset(),
649                                       conf.getWindowTopOffset()   *yScal + defDisp.getWindowTopOffset(),
650                                       conf.getWindowBottomOffset()*yScal + defDisp.getWindowBottomOffset() );
651
652#else
653        m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(),
654                                       conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
655                                       conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
656                                       conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
657                                       conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
658#endif
659      }
660     
661      // update POC of display order
662      m_aiPOCLastDisplay[layerId] = pcPic->getPOC();
663#else
664      if ( m_pchReconFile )
665      {
666        const Window &conf = pcPic->getConformanceWindow();
667        const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
668        m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
669                                       conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
670                                       conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
671                                       conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
672                                       conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
673      }
674     
675      // update POC of display order
676      m_iPOCLastDisplay = pcPic->getPOC();
677#endif
678     
679      // erase non-referenced picture in the reference picture list after display
680      if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
681      {
682#if !DYN_REF_FREE
683        pcPic->setReconMark(false);
684       
685        // mark it should be extended later
686        pcPic->getPicYuvRec()->setBorderExtension( false );
687       
688#else
689        pcPic->destroy();
690        pcListPic->erase( iterPic );
691        iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
692        continue;
693#endif
694      }
695      pcPic->setOutputMark(false);
696    }
697#if !SVC_EXTENSION
698#if !DYN_REF_FREE
699    if(pcPic)
700    {
701      pcPic->destroy();
702      delete pcPic;
703      pcPic = NULL;
704    }
705#endif   
706#endif
707    iterPic++;
708  }
709#if SVC_EXTENSION
710  m_aiPOCLastDisplay[layerId] = -MAX_INT;
711#else
712  pcListPic->clear();
713  m_iPOCLastDisplay = -MAX_INT;
714#endif
715}
716
717/** \param nalu Input nalu to check whether its LayerId is within targetDecLayerIdSet
718 */
719Bool TAppDecTop::isNaluWithinTargetDecLayerIdSet( InputNALUnit* nalu )
720{
721  if ( m_targetDecLayerIdSet.size() == 0 ) // By default, the set is empty, meaning all LayerIds are allowed
722  {
723    return true;
724  }
725  for (std::vector<Int>::iterator it = m_targetDecLayerIdSet.begin(); it != m_targetDecLayerIdSet.end(); it++)
726  {
727    if ( nalu->m_reservedZero6Bits == (*it) )
728    {
729      return true;
730    }
731  }
732  return false;
733}
734
735//! \}
Note: See TracBrowser for help on using the repository browser.