Changeset 608 in 3DVCSoftware for trunk/source/App/TAppDecoder


Ignore:
Timestamp:
1 Sep 2013, 22:47:26 (11 years ago)
Author:
tech
Message:

Merged DEV-2.0-dev0@604.

Location:
trunk/source/App/TAppDecoder
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/App/TAppDecoder/TAppDecCfg.cpp

    r121 r608  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    4242#include "TAppCommon/program_options_lite.h"
    4343
     44#if H_MV
     45#include <cassert>
     46#endif
    4447#ifdef WIN32
    4548#define strdup _strdup
     
    6164Bool TAppDecCfg::parseCfg( Int argc, Char* argv[] )
    6265{
    63   bool do_help = false;
     66  Bool do_help = false;
    6467  string cfg_BitstreamFile;
    6568  string cfg_ReconFile;
     69  string cfg_TargetDecLayerIdSetFile;
     70#if H_3D
    6671  string cfg_ScaleOffsetFile;
     72#endif
    6773
    6874  po::Options opts;
     
    7278  ("ReconFile,o",     cfg_ReconFile,     string(""), "reconstructed YUV output file name\n"
    7379                                                     "YUV writing is skipped if omitted")
     80#if H_3D
    7481  ("ScaleOffsetFile,p", cfg_ScaleOffsetFile, string(""), "file with coded scales and offsets")
     82#endif
    7583  ("SkipFrames,s", m_iSkipFrame, 0, "number of frames to skip before random access")
    76   ("OutputBitDepth,d", m_outputBitDepth, 0u, "bit depth of YUV output file (use 0 for native depth)")
     84  ("OutputBitDepth,d", m_outputBitDepthY, 0, "bit depth of YUV output luma component (default: use 0 for native depth)")
     85  ("OutputBitDepthC,d", m_outputBitDepthC, 0, "bit depth of YUV output chroma component (default: use 0 for native depth)")
     86#if H_MV
     87  ("MaxLayerId,-ls", m_maxLayerId, MAX_NUM_LAYER_IDS-1, "Maximum LayerId to be decoded.")
     88#endif
    7789  ("MaxTemporalLayer,t", m_iMaxTemporalLayer, -1, "Maximum Temporal Layer to be decoded. -1 to decode all layers")
    78   ("SEIpictureDigest", m_pictureDigestEnabled, true, "Control handling of picture_digest SEI messages\n"
    79                                               "\t1: check\n"
    80                                               "\t0: ignore")
     90  ("SEIDecodedPictureHash", m_decodedPictureHashSEIEnabled, 1, "Control handling of decoded picture hash SEI messages\n"
     91                                              "\t1: check hash in SEI messages if available in the bitstream\n"
     92                                              "\t0: ignore SEI message")
     93  ("SEIpictureDigest", m_decodedPictureHashSEIEnabled, 1, "deprecated alias for SEIDecodedPictureHash")
     94  ("TarDecLayerIdSetFile,l", cfg_TargetDecLayerIdSetFile, string(""), "targetDecLayerIdSet file name. The file should include white space separated LayerId values to be decoded. Omitting the option or a value of -1 in the file decodes all layers.")
     95  ("RespectDefDispWindow,w", m_respectDefDispWindow, 0, "Only output content inside the default display window\n")
    8196  ;
     97  po::setDefaults(opts);
     98  const list<const Char*>& argv_unhandled = po::scanArgv(opts, argc, (const Char**) argv);
    8299
    83   po::setDefaults(opts);
    84   const list<const char*>& argv_unhandled = po::scanArgv(opts, argc, (const char**) argv);
    85 
    86   for (list<const char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
     100  for (list<const Char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
    87101  {
    88102    fprintf(stderr, "Unhandled argument ignored: `%s'\n", *it);
     
    98112  m_pchBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str());
    99113  m_pchReconFile = cfg_ReconFile.empty() ? NULL : strdup(cfg_ReconFile.c_str());
     114
     115#if H_3D
    100116  m_pchScaleOffsetFile = cfg_ScaleOffsetFile.empty() ? NULL : strdup(cfg_ScaleOffsetFile.c_str());
    101 
    102 
     117#endif
    103118  if (!m_pchBitstreamFile)
    104119  {
    105     fprintf(stderr, "No input file specified, aborting\n");
     120    fprintf(stderr, "No input file specifed, aborting\n");
    106121    return false;
    107122  }
     123
     124  if ( !cfg_TargetDecLayerIdSetFile.empty() )
     125  {
     126    FILE* targetDecLayerIdSetFile = fopen ( cfg_TargetDecLayerIdSetFile.c_str(), "r" );
     127    if ( targetDecLayerIdSetFile )
     128    {
     129      Bool isLayerIdZeroIncluded = false;
     130      while ( !feof(targetDecLayerIdSetFile) )
     131      {
     132        Int layerIdParsed = 0;
     133        if ( fscanf( targetDecLayerIdSetFile, "%d ", &layerIdParsed ) != 1 )
     134        {
     135          if ( m_targetDecLayerIdSet.size() == 0 )
     136          {
     137            fprintf(stderr, "No LayerId could be parsed in file %s. Decoding all LayerIds as default.\n", cfg_TargetDecLayerIdSetFile.c_str() );
     138          }
     139          break;
     140        }
     141        if ( layerIdParsed  == -1 ) // The file includes a -1, which means all LayerIds are to be decoded.
     142        {
     143          m_targetDecLayerIdSet.clear(); // Empty set means decoding all layers.
     144          break;
     145        }
     146        if ( layerIdParsed < 0 || layerIdParsed >= MAX_NUM_LAYER_IDS )
     147        {
     148          fprintf(stderr, "Warning! Parsed LayerId %d is not withing allowed range [0,%d]. Ignoring this value.\n", layerIdParsed, MAX_NUM_LAYER_IDS-1 );
     149        }
     150        else
     151        {
     152          isLayerIdZeroIncluded = layerIdParsed == 0 ? true : isLayerIdZeroIncluded;
     153          m_targetDecLayerIdSet.push_back ( layerIdParsed );
     154        }
     155      }
     156      fclose (targetDecLayerIdSetFile);
     157      if ( m_targetDecLayerIdSet.size() > 0 && !isLayerIdZeroIncluded )
     158      {
     159        fprintf(stderr, "TargetDecLayerIdSet must contain LayerId=0, aborting" );
     160        return false;
     161      }
     162    }
     163    else
     164    {
     165      fprintf(stderr, "File %s could not be opened. Using all LayerIds as default.\n", cfg_TargetDecLayerIdSetFile.c_str() );
     166    }
     167  }
     168#if H_MV
     169  else
     170  {
     171    for ( Int curLayerId = 0; curLayerId <= m_maxLayerId; curLayerId++ )
     172    {
     173      m_targetDecLayerIdSet.push_back( curLayerId );
     174    }
     175  }
     176#endif
    108177
    109178  return true;
    110179}
    111180
     181#if H_MV
    112182Void TAppDecCfg::xAppendToFileNameEnd( Char* pchInputFileName, const Char* pchStringToAppend, Char*& rpchOutputFileName)
    113183{
     
    125195  rpchOutputFileName[iInLength+iAppendLength] = '\0';         
    126196}
    127 
     197#endif
    128198//! \}
  • trunk/source/App/TAppDecoder/TAppDecCfg.h

    r56 r608  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    4444
    4545#include "TLibCommon/CommonDef.h"
     46#include <vector>
    4647
    4748//! \ingroup TAppDecoder
     
    5657{
    5758protected:
    58   char*         m_pchBitstreamFile;                   ///< input bitstream file name
    59   char*         m_pchReconFile;                       ///< output reconstruction file name
    60   char*         m_pchScaleOffsetFile;                 ///< output coded scale and offset parameters
     59  Char*         m_pchBitstreamFile;                   ///< input bitstream file name
     60#if H_MV
     61  Int           m_maxLayerId;                         ///< maximum nuh_layer_id decoded
     62  std::vector<Char*> m_pchReconFiles;                 ///< array of output reconstruction file name create from output reconstruction file name
     63#endif
     64  Char*         m_pchReconFile;                       ///< output reconstruction file name
     65#if H_3D
     66  Char*         m_pchScaleOffsetFile;                 ///< output coded scale and offset parameters
     67#endif
    6168  Int           m_iSkipFrame;                         ///< counter for frames prior to the random access point to skip
    62   UInt          m_outputBitDepth;                     ///< bit depth used for writing output
     69  Int           m_outputBitDepthY;                    ///< bit depth used for writing output (luma)
     70  Int           m_outputBitDepthC;                    ///< bit depth used for writing output (chroma)t
    6371
    6472  Int           m_iMaxTemporalLayer;                  ///< maximum temporal layer to be decoded
    65   bool m_pictureDigestEnabled; ///< enable(1)/disable(0) acting on SEI picture_digest message
     73  Int           m_decodedPictureHashSEIEnabled;       ///< Checksum(3)/CRC(2)/MD5(1)/disable(0) acting on decoded picture hash SEI message
     74
     75  std::vector<Int> m_targetDecLayerIdSet;             ///< set of LayerIds to be included in the sub-bitstream extraction process.
     76  Int           m_respectDefDispWindow;               ///< Only output content inside the default display window
     77
     78#if H_MV
    6679  Void xAppendToFileNameEnd( Char* pchInputFileName, const Char* pchStringToAppend, Char*& rpchOutputFileName); ///< create filenames
    67 
     80#endif
    6881public:
    69   TAppDecCfg()          {}
     82  TAppDecCfg()
     83  : m_pchBitstreamFile(NULL)
     84#if H_MV
     85  , m_maxLayerId(0)
     86#endif
     87  , m_pchReconFile(NULL)
     88  , m_iSkipFrame(0)
     89  , m_outputBitDepthY(0)
     90  , m_outputBitDepthC(0)
     91  , m_iMaxTemporalLayer(-1)
     92  , m_decodedPictureHashSEIEnabled(0)
     93  , m_respectDefDispWindow(0)
     94  {}
    7095  virtual ~TAppDecCfg() {}
    7196 
  • trunk/source/App/TAppDecoder/TAppDecTop.cpp

    r443 r608  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    5454
    5555TAppDecTop::TAppDecTop()
     56#if !H_MV
     57: m_iPOCLastDisplay(-MAX_INT)
     58#else
     59: m_numDecoders( 0 )
     60#endif
    5661{
    5762  ::memset (m_abDecFlag, 0, sizeof (m_abDecFlag));
    58   m_useDepth = false;
    59   m_pScaleOffsetFile  = 0;
     63#if H_MV
     64  for (Int i = 0; i < MAX_NUM_LAYER_IDS; i++) m_layerIdToDecIdx[i] = -1;
     65#endif
     66#if H_3D
     67    m_pScaleOffsetFile  = 0;
     68#endif
    6069}
    6170
     
    6675Void TAppDecTop::destroy()
    6776{
     77  if (m_pchBitstreamFile)
     78  {
     79    free (m_pchBitstreamFile);
     80    m_pchBitstreamFile = NULL;
     81  }
     82#if H_MV
     83  for (Int decIdx = 0; decIdx < m_numDecoders; decIdx++)
     84  {
     85    if (m_pchReconFiles[decIdx])
     86    {
     87      free (m_pchReconFiles[decIdx]);
     88      m_pchReconFiles[decIdx] = NULL;
     89    }
     90  }
     91#endif
     92  if (m_pchReconFile)
     93  {
     94    free (m_pchReconFile);
     95    m_pchReconFile = NULL;
     96  }
     97#if H_3D
     98  if (m_pchScaleOffsetFile)
     99  {
     100    free (m_pchScaleOffsetFile);
     101    m_pchScaleOffsetFile = NULL;
     102  }
     103#endif
    68104}
    69105
     
    82118Void TAppDecTop::decode()
    83119{
    84 #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
    85   increaseNumberOfViews( 0, 0, 0 );
    86 #else
    87   increaseNumberOfViews( 1 );
    88 #endif
    89  
    90 #if FLEX_CODING_ORDER_M23723
    91   Int iDepthViewIdx = 0;
    92   Int iTextureViewIdx=0;
    93   Bool firstFrame=1;
    94   Bool viewIdZero=true;
    95   Int fcoIndex=0;  //when the current frame is not first frame,use FCO_index stand for viewDepth.
    96 #endif
    97 
    98   Int                 viewDepthId = 0;
    99   Int                 previousViewDepthId  = 0;
    100   UInt                uiPOC[MAX_VIEW_NUM*2];
    101   TComList<TComPic*>* pcListPic[MAX_VIEW_NUM*2];
    102   Bool                newPicture[MAX_VIEW_NUM*2];
    103   Bool                previousPictureDecoded = false;
    104   for( Int i = 0; i < MAX_VIEW_NUM*2; i++ )
    105   {
    106     uiPOC[i] = 0;
    107     pcListPic[i] = NULL;
    108     newPicture[i] = false;
    109 #if FLEX_CODING_ORDER_M23723
    110     m_fcoOrder[i] = ' ';
    111 #endif
    112 
    113   }
     120  Int                 poc;
     121#if H_MV
     122  poc = -1;
     123#endif
     124  TComList<TComPic*>* pcListPic = NULL;
    114125
    115126  ifstream bitstreamFile(m_pchBitstreamFile, ifstream::in | ifstream::binary);
     
    120131  }
    121132
     133#if H_3D
    122134  if( m_pchScaleOffsetFile )
    123135  {
     
    126138  }
    127139  m_cCamParsCollector.init( m_pScaleOffsetFile );
    128 
     140#endif
    129141  InputByteStream bytestream(bitstreamFile);
    130142
     143  // create & initialize internal classes
     144  xCreateDecLib();
     145  xInitDecLib  ();
     146#if !H_MV
     147  m_iPOCLastDisplay += m_iSkipFrame;      // set the last displayed POC correctly for skip forward.
     148
     149  // main decoder loop
     150  Bool recon_opened = false; // reconstruction file not yet opened. (must be performed after SPS is seen)
     151#else
     152#if H_3D
     153  Int  pocCurrPic        = -MAX_INT;     
     154  Int  pocLastPic        = -MAX_INT;   
     155#endif
     156
     157  Int  layerIdCurrPic    = 0;
     158
     159  Int  decIdxLastPic     = 0;
     160  Int  decIdxCurrPic     = 0;
     161
     162  Bool firstSlice        = true;
     163#endif
     164 
    131165  while (!!bitstreamFile)
    132166  {
     
    136170     * nal unit. */
    137171    streampos location = bitstreamFile.tellg();
     172#if H_MV
     173#if ENC_DEC_TRACE
     174    Int64 symCount = g_nSymbolCounter;
     175#endif
     176#endif
    138177    AnnexBStats stats = AnnexBStats();
     178#if !H_MV
     179    Bool bPreviousPictureDecoded = false;
     180#endif
     181
    139182    vector<uint8_t> nalUnit;
    140183    InputNALUnit nalu;
     
    142185
    143186    // call actual decoding function
     187    Bool bNewPicture = false;
     188#if H_MV
     189    Bool newSliceDiffPoc   = false;
     190    Bool newSliceDiffLayer = false;
     191#if H_3D
     192    Bool allLayersDecoded  = false;     
     193#endif
     194#endif
    144195    if (nalUnit.empty())
    145196    {
     
    154205    {
    155206      read(nalu, nalUnit);
    156 #if QC_MVHEVC_B0046
    157     viewDepthId = nalu.m_layerId;
    158     Int depth = 0;
    159     Int viewId = viewDepthId;
    160 #else
    161 #if VIDYO_VPS_INTEGRATION
    162       Int viewId = 0;
    163       Int depth = 0;
     207#if H_MV     
     208      Int decIdx     = xGetDecoderIdx( nalu.m_layerId , true );
    164209     
    165       if(nalu.m_nalUnitType != NAL_UNIT_VPS || nalu.m_layerId)
    166       {
    167         // code assumes that the first nal unit is VPS
    168         // currently, this is a hack that requires non-first VPSs have non-zero layer_id
    169         viewId = getVPSAccess()->getActiveVPS()->getViewId(nalu.m_layerId);
    170         depth = getVPSAccess()->getActiveVPS()->getDepthFlag(nalu.m_layerId);
    171       }
    172 #if FLEX_CODING_ORDER_M23723
    173       if (viewId>0)
    174       {
    175         viewIdZero=false;
    176       }
    177       if (viewIdZero==false&&viewId==0)
    178       {
    179         firstFrame=0; //if viewId has been more than zero and now it set to zero again, we can see that it is not the first view
    180       }
    181       if (firstFrame)
    182       { // if the current view is first frame, we set the viewDepthId as texture plus depth and get the FCO order
    183         viewDepthId = iDepthViewIdx+iTextureViewIdx;
    184         m_fcoViewDepthId=viewDepthId;
     210      if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu) )
     211      {
     212        bNewPicture = false;
    185213      }
    186214      else
    187       {//if current view is not first frame, we set the viewDepthId depended on the FCO order
    188         viewDepthId=0;
    189         if (depth)
     215      {
     216        newSliceDiffLayer = nalu.isSlice() && ( nalu.m_layerId != layerIdCurrPic ) && !firstSlice;
     217        newSliceDiffPoc   = m_tDecTop[decIdx]->decode(nalu, m_iSkipFrame, m_pocLastDisplay[decIdx], newSliceDiffLayer );
     218        // decode function only returns true when all of the following conditions are true
     219        // - poc in particular layer changes
     220        // - nalu does not belong to first slice in layer
     221        // - nalu.isSlice() == true     
     222
     223        bNewPicture       = newSliceDiffLayer || newSliceDiffPoc;
     224
     225        if ( nalu.isSlice() && firstSlice )
    190226        {
    191           for (fcoIndex=0;fcoIndex<2*MAX_VIEW_NUM;fcoIndex++ )
    192           {
    193             if (m_fcoOrder[fcoIndex]=='D')
    194             {
    195               if (viewId==viewDepthId)
    196                 break;
    197               else
    198                 viewDepthId++;
    199             }
    200           }
     227          layerIdCurrPic = nalu.m_layerId;
     228#if H_3D
     229          pocCurrPic     = m_tDecTop[decIdx]->getCurrPoc();
     230#endif
     231          decIdxCurrPic  = decIdx;
     232          firstSlice     = false;
     233        }
     234
     235        if ( bNewPicture || !bitstreamFile )
     236        {
     237          layerIdCurrPic    = nalu.m_layerId;
     238#if H_3D         
     239          pocLastPic        = pocCurrPic;
     240          pocCurrPic        = m_tDecTop[decIdx]->getCurrPoc();
     241#endif         
     242          decIdxLastPic     = decIdxCurrPic;
     243          decIdxCurrPic     = decIdx;
     244#if H_3D
     245          allLayersDecoded = ( pocCurrPic != pocLastPic );
     246#endif
     247        }
     248
     249       
     250#else
     251      if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu)  )
     252      {
     253        if(bPreviousPictureDecoded)
     254        {
     255          bNewPicture = true;
     256          bPreviousPictureDecoded = false;
    201257        }
    202258        else
    203259        {
    204           for (fcoIndex=0;fcoIndex<2*MAX_VIEW_NUM;fcoIndex++ )
    205           {
    206             if (m_fcoOrder[fcoIndex]=='T')
    207             {
    208               if (viewId==viewDepthId)
    209                 break;
    210               else
    211                 viewDepthId++;
    212             }
    213           }
     260          bNewPicture = false;
    214261        }
    215 
    216         viewDepthId=fcoIndex;
    217 
    218       }
    219 
    220 
    221 #else
    222       viewDepthId = nalu.m_layerId;   // coding order T0D0T1D1T2D2
    223 #endif
    224    
    225 #else
    226       Int viewId = nalu.m_viewId;
    227       Int depth = nalu.m_isDepth ? 1 : 0;
    228 #if FLEX_CODING_ORDER_M23723
    229       if (viewId>0)
    230       {
    231         viewIdZero=false;
    232       }
    233       if (viewIdZero==false&&viewId==0)
    234       {
    235         firstFrame=0;
    236       }
    237       if (firstFrame)
    238       {
    239         viewDepthId = iDepthViewIdx+iTextureViewIdx;
    240         m_fcoViewDepthId=viewDepthId;
    241262      }
    242263      else
    243264      {
    244         viewDepthId=0;
    245         if (depth)
    246         {
    247           for (fcoIndex=0;fcoIndex<2*MAX_VIEW_NUM;fcoIndex++ )
    248           {
    249             if (m_fcoOrder[fcoIndex]=='D')
    250             {
    251               if (viewId==viewDepthId)
    252                 break;
    253               else
    254                 viewDepthId++;
    255             }
    256           }
    257         }
    258         else
    259         {
    260           for (fcoIndex=0;fcoIndex<2*MAX_VIEW_NUM;fcoIndex++ )
    261           {
    262             if (m_fcoOrder[fcoIndex]=='T')
    263             {
    264               if (viewId==viewDepthId)
    265                 break;
    266               else
    267                 viewDepthId++;
    268             }
    269           }
    270         }
    271         viewDepthId=fcoIndex;
    272       }
    273 #else
    274       viewDepthId = viewId * 2 + depth;   // coding order T0D0T1D1T2D2
    275 #endif
    276 #endif
    277 #endif     
    278       newPicture[viewDepthId] = false;
    279       if( viewDepthId >= m_tDecTop.size() )     
    280       {
    281 #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
    282         increaseNumberOfViews( viewDepthId, viewId, depth );
    283 #else
    284         increaseNumberOfViews( viewDepthId +1 );
    285 #endif   
    286       }
    287       if(m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer)
    288       {
    289         previousPictureDecoded = false;
    290       }
    291       if(m_tDecTop.size() > 1 && (viewDepthId != previousViewDepthId) && previousPictureDecoded )
    292       {
    293         m_tDecTop[previousViewDepthId]->executeDeblockAndAlf(uiPOC[previousViewDepthId], pcListPic[previousViewDepthId], m_iSkipFrame, m_pocLastDisplay[previousViewDepthId]);
    294       }
    295       if( ( viewDepthId == 0 && (viewDepthId != previousViewDepthId) ) || m_tDecTop.size() == 1 )
    296       {
    297 #if H3D_IVRP
    298         for( Int i = 0; i < m_tDecTop.size(); i++ )
    299         {
    300           m_tDecTop[i]->deleteExtraPicBuffers( uiPOC[i] );
    301         }
    302 #endif
    303         for( Int i = 0; i < m_tDecTop.size(); i++ )
    304         {
    305           m_tDecTop[i]->compressMotion( uiPOC[i] );
    306         }
    307       }   
    308       if( !(m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) )
    309       {
    310 #if QC_MVHEVC_B0046
    311         if(viewDepthId && m_tDecTop[viewDepthId]->m_bFirstNal== false)
    312         {
    313           m_tDecTop[viewDepthId]->m_bFirstNal = true;
    314           ParameterSetManagerDecoder* pDecV0 = m_tDecTop[0]->xGetParaSetDec();
    315           m_tDecTop[viewDepthId]->xCopyVPS(pDecV0->getPrefetchedVPS(0));
    316           m_tDecTop[viewDepthId]->xCopySPS(pDecV0->getPrefetchedSPS(0));
    317           m_tDecTop[viewDepthId]->xCopyPPS(pDecV0->getPrefetchedPPS(0));
    318         }
    319 #endif
    320         newPicture[viewDepthId] = m_tDecTop[viewDepthId]->decode(nalu, m_iSkipFrame, m_pocLastDisplay[viewDepthId]);
    321         if (newPicture[viewDepthId])
     265        bNewPicture = m_cTDecTop.decode(nalu, m_iSkipFrame, m_iPOCLastDisplay);
     266#endif
     267        if (bNewPicture)
    322268        {
    323269          bitstreamFile.clear();
     
    328274          bitstreamFile.seekg(location-streamoff(3));
    329275          bytestream.reset();
     276#if ENC_DEC_TRACE
     277#if H_MV_ENC_DEC_TRAC
     278          const Bool resetCounter = false;
     279          if ( resetCounter )
     280          {
     281            g_nSymbolCounter  = symCount; // Only reset counter SH becomes traced twice
     282          }
     283          else
     284          {
     285            g_disableHLSTrace = true;     // Trancing of second parsing of SH is not carried out
     286          }         
     287#else
     288          g_nSymbolCounter = symCount;
     289#endif
     290#endif
    330291        }
    331         if( nalu.isSlice() )
    332         {
    333           previousPictureDecoded = true;
    334 #if FLEX_CODING_ORDER_M23723
    335         if (firstFrame)
    336         {
    337             if (depth)
    338             {
    339                 iDepthViewIdx++;
    340                 m_fcoOrder[viewDepthId]='D';
    341             }
    342             else
    343            {
    344                 iTextureViewIdx++;
    345                 m_fcoOrder[viewDepthId]='T';
    346            }
    347           }
    348 
    349 #endif
    350         }
    351       }
    352     }
    353     if( ( (newPicture[viewDepthId] || !bitstreamFile) && m_tDecTop.size() == 1) || (!bitstreamFile && previousPictureDecoded == true) ) 
    354     {
    355       m_tDecTop[viewDepthId]->executeDeblockAndAlf(uiPOC[viewDepthId], pcListPic[viewDepthId], m_iSkipFrame, m_pocLastDisplay[viewDepthId]);
    356     }
    357     if( pcListPic[viewDepthId] )
    358     {
    359 #if QC_REM_IDV_B0046
    360       Int iviewId = m_tDecTop[viewDepthId]->getViewId();
    361       if( newPicture[viewDepthId] && (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR || ((nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR && iviewId) && m_tDecTop[viewDepthId]->getNalUnitTypeBaseView() == NAL_UNIT_CODED_SLICE_IDR)) )
    362 #else
    363       if( newPicture[viewDepthId] && (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR || (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDV && m_tDecTop[viewDepthId]->getNalUnitTypeBaseView() == NAL_UNIT_CODED_SLICE_IDR)) )
    364 #endif
    365       {
    366         xFlushOutput( pcListPic[viewDepthId], viewDepthId );
     292#if !H_MV
     293        bPreviousPictureDecoded = true;
     294#endif
     295      }
     296    }
     297    if (bNewPicture || !bitstreamFile)
     298    {
     299#if H_MV
     300      assert( decIdxLastPic != -1 );
     301      m_tDecTop[decIdxLastPic]->endPicDecoding(poc, pcListPic, m_targetDecLayerIdSet );
     302#else
     303      m_cTDecTop.executeLoopFilters(poc, pcListPic);
     304#endif
     305    }
     306#if H_3D
     307    if ( allLayersDecoded || !bitstreamFile )
     308    {
     309      for( Int dI = 0; dI < m_numDecoders; dI++ )
     310      {
     311        TComPic* picLastCoded = m_ivPicLists.getPic( m_tDecTop[dI]->getLayerId(), pocLastPic );
     312        assert( picLastCoded != NULL );       
     313#if MTK_SONY_PROGRESSIVE_MV_COMPRESSION_E0170
     314        picLastCoded->compressMotion(1);
     315#else
     316        picLastCoded->compressMotion();         
     317#endif
     318      }
     319    }
     320#endif
     321
     322    if( pcListPic )
     323    {
     324#if H_MV
     325      if ( m_pchReconFiles[decIdxLastPic] && !m_reconOpen[decIdxLastPic] )
     326#else
     327      if ( m_pchReconFile && !recon_opened )
     328#endif
     329      {
     330        if (!m_outputBitDepthY) { m_outputBitDepthY = g_bitDepthY; }
     331        if (!m_outputBitDepthC) { m_outputBitDepthC = g_bitDepthC; }
     332
     333#if H_MV
     334        m_tVideoIOYuvReconFile[decIdxLastPic]->open( m_pchReconFiles[decIdxLastPic], true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode
     335        m_reconOpen[decIdxLastPic] = true;
     336      }
     337      if ( bNewPicture && newSliceDiffPoc &&
     338#else
     339        m_cTVideoIOYuvReconFile.open( m_pchReconFile, true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode
     340        recon_opened = true;
     341      }
     342      if ( bNewPicture &&
     343#endif
     344           (   nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL
     345            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP
     346            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP
     347            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL
     348            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP ) )
     349      {
     350#if H_MV
     351        xFlushOutput( pcListPic, decIdxLastPic );
     352#else
     353        xFlushOutput( pcListPic );
     354#endif
    367355      }
    368356      // write reconstruction to file
    369       if(newPicture[viewDepthId])
    370       {
    371         xWriteOutput( pcListPic[viewDepthId], viewDepthId, nalu.m_temporalId );
    372       }
    373     }
    374     previousViewDepthId = viewDepthId;
    375   }
     357      if(bNewPicture)
     358      {
     359#if H_MV
     360        xWriteOutput( pcListPic, decIdxLastPic, nalu.m_temporalId );
     361      }
     362    }
     363  }
     364
     365#if H_3D
    376366  if( m_cCamParsCollector.isInitialized() )
    377367  {
    378368    m_cCamParsCollector.setSlice( 0 );
    379369  }
    380   // last frame
    381   for( Int viewDepthIdx = 0; viewDepthIdx < m_tDecTop.size(); viewDepthIdx++ )
    382   {
    383     xFlushOutput( pcListPic[viewDepthIdx], viewDepthIdx );
    384   } 
     370#endif
     371  for(UInt decIdx = 0; decIdx < m_numDecoders; decIdx++)
     372  {
     373    xFlushOutput( m_tDecTop[decIdx]->getListPic(), decIdx );
     374  }
     375#else
     376        xWriteOutput( pcListPic, nalu.m_temporalId );
     377      }
     378    }
     379  }
     380 
     381  xFlushOutput( pcListPic );
     382  // delete buffers
     383  m_cTDecTop.deletePicBuffer();
     384#endif
     385     
     386  // destroy internal classes
    385387  xDestroyDecLib();
    386388}
     
    390392// ====================================================================================================================
    391393
     394Void TAppDecTop::xCreateDecLib()
     395{
     396#if H_MV
     397  // initialize global variables
     398  initROM(); 
     399#if H_3D_DIM_DMM
     400  initWedgeLists();
     401#endif
     402#else
     403  // create decoder class
     404  m_cTDecTop.create();
     405#endif
     406}
     407
    392408Void TAppDecTop::xDestroyDecLib()
    393409{
    394 
    395   for(Int viewDepthIdx=0; viewDepthIdx<m_tVideoIOYuvReconFile.size() ; viewDepthIdx++)
    396   {
    397     if( m_tVideoIOYuvReconFile[viewDepthIdx] )
    398     {
    399       m_tVideoIOYuvReconFile[viewDepthIdx]->close();
    400       delete m_tVideoIOYuvReconFile[viewDepthIdx];
    401       m_tVideoIOYuvReconFile[viewDepthIdx] = NULL ;
    402     }
    403   }
    404 
    405   for(Int viewDepthIdx=0; viewDepthIdx<m_tDecTop.size() ; viewDepthIdx++)
    406   {
    407     if( m_tDecTop[viewDepthIdx] )
    408     {
    409       if( !m_useDepth && (viewDepthIdx % 2 == 1) )
    410       {
    411       }
    412       else
    413       {
    414         m_tDecTop[viewDepthIdx]->deletePicBuffer();
    415         m_tDecTop[viewDepthIdx]->destroy() ;
    416       }
    417 #if QC_MVHEVC_B0046
    418       if(viewDepthIdx)
    419       {
    420          //Call clear function to remove the record, which has been freed during viewDepthIdx = 0 case.
    421         m_tDecTop[viewDepthIdx]->xGetParaSetDec()->clearSPS();
    422         m_tDecTop[viewDepthIdx]->xGetParaSetDec()->clearVPS();
    423         m_tDecTop[viewDepthIdx]->xGetParaSetDec()->clearPPS();
    424       }
    425 #endif
    426       delete m_tDecTop[viewDepthIdx] ;
    427       m_tDecTop[viewDepthIdx] = NULL ;
    428     }
    429   }
    430 
     410#if H_MV
     411  // destroy ROM
     412  destroyROM();
     413
     414  for(Int decIdx = 0; decIdx < m_numDecoders ; decIdx++)
     415  {
     416    if( m_tVideoIOYuvReconFile[decIdx] )
     417    {
     418      m_tVideoIOYuvReconFile[decIdx]->close();
     419      delete m_tVideoIOYuvReconFile[decIdx];
     420      m_tVideoIOYuvReconFile[decIdx] = NULL ;
     421    }
     422
     423    if( m_tDecTop[decIdx] )
     424    {
     425      m_tDecTop[decIdx]->deletePicBuffer();
     426      m_tDecTop[decIdx]->destroy() ;
     427    }
     428    delete m_tDecTop[decIdx] ;
     429    m_tDecTop[decIdx] = NULL ;
     430  }
     431#else
     432  if ( m_pchReconFile )
     433  {
     434    m_cTVideoIOYuvReconFile. close();
     435  }
     436 
     437  // destroy decoder class
     438  m_cTDecTop.destroy();
     439#endif
     440#if H_3D
    431441  m_cCamParsCollector.uninit();
    432442  if( m_pScaleOffsetFile )
     
    434444    ::fclose( m_pScaleOffsetFile );
    435445  }
    436 }
    437 
    438 Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic, Int viewDepthId, UInt tId )
     446#endif
     447}
     448
     449Void TAppDecTop::xInitDecLib()
     450{
     451#if !H_MV
     452  // initialize decoder class
     453  m_cTDecTop.init();
     454  m_cTDecTop.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
     455#endif
     456}
     457
     458/** \param pcListPic list of pictures to be written to file
     459    \todo            DYN_REF_FREE should be revised
     460 */
     461#if H_MV
     462Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic, Int decIdx, Int tId )
     463#else
     464Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic, UInt tId )
     465#endif
    439466{
    440467  TComList<TComPic*>::iterator iterPic   = pcListPic->begin();
     
    444471  {
    445472    TComPic* pcPic = *(iterPic);
    446     if(pcPic->getOutputMark() && pcPic->getPOC() > m_pocLastDisplay[viewDepthId])
     473#if H_MV
     474    if(pcPic->getOutputMark() && pcPic->getPOC() > m_pocLastDisplay[decIdx])
     475#else
     476    if(pcPic->getOutputMark() && pcPic->getPOC() > m_iPOCLastDisplay)
     477#endif
    447478    {
    448479       not_displayed++;
     
    455486  {
    456487    TComPic* pcPic = *(iterPic);
    457     TComSPS *sps = pcPic->getSlice(0)->getSPS();
    458488   
    459     if ( pcPic->getOutputMark() && (not_displayed >  pcPic->getSlice(0)->getSPS()->getNumReorderPics(tId) && pcPic->getPOC() > m_pocLastDisplay[viewDepthId]))
     489#if H_MV
     490    if ( pcPic->getOutputMark() && (not_displayed >  pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_pocLastDisplay[decIdx]))
     491#else
     492    if ( pcPic->getOutputMark() && (not_displayed >  pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_iPOCLastDisplay))
     493#endif
    460494    {
    461495      // write to file
    462496       not_displayed--;
     497#if H_MV
     498      if ( m_pchReconFiles[decIdx] )
     499#else
    463500      if ( m_pchReconFile )
    464       {
    465         m_tVideoIOYuvReconFile[viewDepthId]->write( pcPic->getPicYuvRec(), sps->getPicCropLeftOffset(), sps->getPicCropRightOffset(), sps->getPicCropTopOffset(), sps->getPicCropBottomOffset() );
     501#endif
     502      {
     503        const Window &conf = pcPic->getConformanceWindow();
     504        const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
     505#if H_MV
     506        m_tVideoIOYuvReconFile[decIdx]->write( pcPic->getPicYuvRec(),
     507#else
     508        m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
     509#endif
     510                                       conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     511                                       conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
     512                                       conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
     513                                       conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
    466514      }
    467515     
    468516      // update POC of display order
    469       m_pocLastDisplay[viewDepthId] = pcPic->getPOC();
     517#if H_MV
     518      m_pocLastDisplay[decIdx] = pcPic->getPOC();
     519#else
     520      m_iPOCLastDisplay = pcPic->getPOC();
     521#endif
    470522     
    471523      // erase non-referenced picture in the reference picture list after display
     
    495547    \todo            DYN_REF_FREE should be revised
    496548 */
    497 Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic, Int viewDepthId )
     549#if H_MV
     550Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic, Int decIdx )
     551#else
     552Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic )
     553#endif
    498554{
    499555  if(!pcListPic)
     
    508564  {
    509565    TComPic* pcPic = *(iterPic);
    510     TComSPS *sps = pcPic->getSlice(0)->getSPS();
    511566
    512567    if ( pcPic->getOutputMark() )
    513568    {
    514569      // write to file
     570#if H_MV
     571      if ( m_pchReconFiles[decIdx] )
     572#else
    515573      if ( m_pchReconFile )
    516       {
    517         m_tVideoIOYuvReconFile[viewDepthId]->write( pcPic->getPicYuvRec(), sps->getPicCropLeftOffset(), sps->getPicCropRightOffset(), sps->getPicCropTopOffset(), sps->getPicCropBottomOffset() );
     574#endif
     575      {
     576        const Window &conf = pcPic->getConformanceWindow();
     577        const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
     578#if H_MV
     579        m_tVideoIOYuvReconFile[decIdx]->write( pcPic->getPicYuvRec(),
     580#else
     581        m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
     582#endif
     583                                       conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     584                                       conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
     585                                       conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
     586                                       conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
    518587      }
    519588     
    520589      // update POC of display order
    521       m_pocLastDisplay[viewDepthId] = pcPic->getPOC();
     590#if H_MV
     591      m_pocLastDisplay[decIdx] = pcPic->getPOC();
     592#else
     593      m_iPOCLastDisplay = pcPic->getPOC();
     594#endif
    522595     
    523596      // erase non-referenced picture in the reference picture list after display
     
    539612      pcPic->setOutputMark(false);
    540613    }
    541    
     614#if !H_MV
     615#if !DYN_REF_FREE
     616    if(pcPic)
     617    {
     618      pcPic->destroy();
     619      delete pcPic;
     620      pcPic = NULL;
     621    }
     622#endif
     623#endif
    542624    iterPic++;
    543625  }
     626#if H_MV
     627  m_pocLastDisplay[decIdx] = -MAX_INT;
     628#else
    544629  pcListPic->clear();
    545   m_pocLastDisplay[viewDepthId] = -MAX_INT;
    546 }
    547 #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
    548 Void  TAppDecTop::increaseNumberOfViews  ( UInt layerId, UInt viewId, UInt isDepth )
    549 #else
    550 Void  TAppDecTop::increaseNumberOfViews  ( Int newNumberOfViewDepth )
    551 #endif
    552 {
    553 #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
    554   Int newNumberOfViewDepth = layerId + 1;
    555 #endif
    556   if ( m_outputBitDepth == 0 )
    557   {
    558     m_outputBitDepth = g_uiBitDepth + g_uiBitIncrement;
    559   }
    560 #if !VIDYO_VPS_INTEGRATION&!QC_MVHEVC_B0046
    561   Int viewId = (newNumberOfViewDepth-1)>>1;   // coding order T0D0T1D1T2D2
    562   Bool isDepth = ((newNumberOfViewDepth % 2) == 0);  // coding order T0D0T1D1T2D2
    563 #endif
    564   if( isDepth )
    565     m_useDepth = true;
    566 
    567   if ( m_pchReconFile )
    568   {
    569     while( m_tVideoIOYuvReconFile.size() < newNumberOfViewDepth)
    570     {
    571       m_tVideoIOYuvReconFile.push_back(new TVideoIOYuv);
    572       Char buffer[4];
    573 #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
    574       sprintf(buffer,"_%i", viewId );
    575 #else
    576       sprintf(buffer,"_%i", (Int)(m_tVideoIOYuvReconFile.size()-1) / 2 );
    577 #endif
    578       Char* nextFilename = NULL;
    579 #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
    580       if( isDepth)
    581 #else
    582       if( (m_tVideoIOYuvReconFile.size() % 2) == 0 )
    583 #endif
    584       {
    585         Char* pchTempFilename = NULL;
    586         xAppendToFileNameEnd( m_pchReconFile, "_depth", pchTempFilename);
    587         xAppendToFileNameEnd( pchTempFilename, buffer, nextFilename);
    588         free ( pchTempFilename );
    589       }
    590       else
    591       {
    592         xAppendToFileNameEnd( m_pchReconFile, buffer, nextFilename);
    593       }
    594 #if !VIDYO_VPS_INTEGRATION&!QC_MVHEVC_B0046
    595       if( isDepth || ( !isDepth && (m_tVideoIOYuvReconFile.size() % 2) == 1 ) )
    596 #endif
    597       {
    598         m_tVideoIOYuvReconFile.back()->open( nextFilename, true, m_outputBitDepth, g_uiBitDepth + g_uiBitIncrement );
    599       }
    600       free ( nextFilename );
    601     }
    602   }
    603 
    604   while( m_pocLastDisplay.size() < newNumberOfViewDepth )
    605   {
    606     m_pocLastDisplay.push_back(-MAX_INT+m_iSkipFrame);
    607   }
    608   while( m_tDecTop.size() < newNumberOfViewDepth)
    609   {
    610     m_tDecTop.push_back(new TDecTop);
    611 #if !VIDYO_VPS_INTEGRATION&!QC_MVHEVC_B0046
    612     if( isDepth || ( !isDepth && (m_tVideoIOYuvReconFile.size() % 2) == 1 ) )
    613     {
    614 #endif
    615       m_tDecTop.back()->create();
    616       m_tDecTop.back()->init( this, newNumberOfViewDepth == 1);
    617       m_tDecTop.back()->setViewId( viewId );
    618       m_tDecTop.back()->setIsDepth( isDepth );
    619       m_tDecTop.back()->setPictureDigestEnabled(m_pictureDigestEnabled);
    620       m_tDecTop.back()->setCamParsCollector( &m_cCamParsCollector );
    621 #if !VIDYO_VPS_INTEGRATION&!QC_MVHEVC_B0046
    622     }
    623 #endif
    624   }
    625 }
    626 
    627 TDecTop* TAppDecTop::getTDecTop( Int viewId, Bool isDepth )
    628 {
    629 #if FLEX_CODING_ORDER_M23723
    630   Int viewnumber=0;
    631   Int i=0;
    632   Bool fcoFlag=0;
    633   if (viewId>m_fcoViewDepthId)
    634   {
    635     return NULL;
     630  m_iPOCLastDisplay = -MAX_INT;
     631#endif
     632}
     633
     634/** \param nalu Input nalu to check whether its LayerId is within targetDecLayerIdSet
     635 */
     636Bool TAppDecTop::isNaluWithinTargetDecLayerIdSet( InputNALUnit* nalu )
     637{
     638  if ( m_targetDecLayerIdSet.size() == 0 ) // By default, the set is empty, meaning all LayerIds are allowed
     639  {
     640    return true;
     641  }
     642  for (std::vector<Int>::iterator it = m_targetDecLayerIdSet.begin(); it != m_targetDecLayerIdSet.end(); it++)
     643  {
     644#if H_MV
     645    if ( nalu->m_layerId == (*it) )
     646#else
     647    if ( nalu->m_reservedZero6Bits == (*it) )
     648#endif
     649    {
     650      return true;
     651    }
     652  }
     653  return false;
     654}
     655
     656#if H_MV
     657Int TAppDecTop::xGetDecoderIdx( Int layerId, Bool createFlag /*= false */ )
     658{
     659  Int decIdx = -1;
     660  if ( m_layerIdToDecIdx[ layerId ] != -1 )
     661  {     
     662    decIdx = m_layerIdToDecIdx[ layerId ];
    636663  }
    637664  else
    638   {
    639     if (isDepth)
    640    {
    641       for ( i=0; i<=m_fcoViewDepthId;i++)
    642       {
    643          if (m_fcoOrder[i]=='D')
    644          {
    645            if (viewnumber==viewId)
    646            {
    647              fcoFlag=1;
    648              break;
    649            }
    650            else
    651              viewnumber++;
    652          }
    653       }
    654     }
    655     else
    656     {
    657       for ( i=0; i<=m_fcoViewDepthId;i++)
    658       {
    659         if (m_fcoOrder[i]=='T')
    660         {
    661           if (viewnumber==viewId)
    662           {
    663             fcoFlag=1;
    664             break;
    665           }
    666           else
    667             viewnumber++;
    668         }
    669       }
    670     }
    671     if (fcoFlag)
    672     {
    673       return m_tDecTop[i];
    674     }
    675     else
    676       return NULL;
    677    
    678   }
    679 
    680     // coding order T0D0T1D1T2D2
    681 #else
    682   return m_tDecTop[(isDepth ? 1 : 0) + viewId * 2];  // coding order T0D0T1D1T2D2
    683 #endif
    684  
    685 }
    686 
    687 std::vector<TComPic*> TAppDecTop::getInterViewRefPics( Int viewId, Int poc, Bool isDepth, TComSPS* sps )
    688 {
    689   std::vector<TComPic*> apcRefPics( sps->getNumberOfUsableInterViewRefs(), (TComPic*)NULL );
    690   for( Int k = 0; k < sps->getNumberOfUsableInterViewRefs(); k++ )
    691   {
    692     TComPic* pcRefPic = xGetPicFromView( sps->getUsableInterViewRef( k ) + viewId, poc, isDepth );
    693     assert( pcRefPic != NULL );
    694     apcRefPics[k] = pcRefPic;
    695   }
    696   return apcRefPics;
    697 }
    698 
    699 TComPic* TAppDecTop::xGetPicFromView( Int viewId, Int poc, Bool isDepth )
    700 {
    701   assert( ( viewId >= 0 ) );
    702 
    703 #if FLEX_CODING_ORDER_M23723
    704 if (getTDecTop(viewId,isDepth))
    705 {
    706   TComList<TComPic*>* apcListPic = getTDecTop( viewId, isDepth )->getListPic();
    707   TComPic* pcPic = NULL;
    708   for( TComList<TComPic*>::iterator it=apcListPic->begin(); it!=apcListPic->end(); it++ )
    709   {
    710     if( (*it)->getPOC() == poc )
    711     {
    712       pcPic = *it;
    713       break;
    714     }
    715   }
    716   return pcPic;
    717 }
    718 else
    719   return NULL;
    720 #else
    721 
    722   TComList<TComPic*>* apcListPic = getTDecTop( viewId, isDepth )->getListPic();
    723   TComPic* pcPic = NULL;
    724   for( TComList<TComPic*>::iterator it=apcListPic->begin(); it!=apcListPic->end(); it++ )
    725   {
    726     if( (*it)->getPOC() == poc )
    727     {
    728       pcPic = *it;
    729       break;
    730     }
    731   }
    732   return pcPic;
    733 #endif
    734 }
    735 
    736 #if MERL_VSP_C0152
    737 Void TAppDecTop::setBWVSPLUT(
    738 #if MERL_VSP_NBDV_RefVId_Fix_D0166
    739     Int iNeighborViewId,
    740 #endif
    741     TComSlice* pcSlice,  Int iCodedViewIdx,  Int iCurPoc)
    742 
    743 {
    744   //first view does not have VSP
    745   if((iCodedViewIdx == 0)) return;
    746 
    747   AOT( iCodedViewIdx <= 0);
    748   //AOT( iCodedViewIdx >= m_iNumberOfViews );
    749 #if !MERL_VSP_NBDV_RefVId_Fix_D0166
    750   Int iNeighborViewId = 0;
    751 #endif
    752   //  Int* piShiftLUT = bRenderFromLeft ? m_cCamParsCollector.getBaseViewShiftLUTI()[iCodedViewIdx][iNeighborViewId][0] : m_cCamParsCollector.getBaseViewShiftLUTI()[iNeighborViewId][iCodedViewIdx][0];
    753   Int* piShiftLUT = m_cCamParsCollector.getBaseViewShiftLUTI()[iNeighborViewId][iCodedViewIdx][0];
    754 #if MERL_VSP_NBDV_RefVId_Fix_D0166
    755   pcSlice->setBWVSPLUTParam(piShiftLUT, 2-LOG2_DISP_PREC_LUT, iNeighborViewId );
    756 #else
    757   pcSlice->setBWVSPLUTParam(piShiftLUT, 2-LOG2_DISP_PREC_LUT );
    758 #endif
    759 }
    760 #endif
    761 
     665  {     
     666    assert ( createFlag );
     667    assert( m_numDecoders < MAX_NUM_LAYERS );
     668
     669    decIdx = m_numDecoders;
     670
     671    // Init decoder
     672    m_tDecTop[ decIdx ] =  new TDecTop;
     673    m_tDecTop[ decIdx ]->create();
     674    m_tDecTop[ decIdx ]->init( );
     675    m_tDecTop[ decIdx ]->setLayerId( layerId );
     676    m_tDecTop[ decIdx ]->setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
     677    m_tDecTop[ decIdx ]->setIvPicLists( &m_ivPicLists );
     678#if H_3D
     679   m_tDecTop[ decIdx ]->setCamParsCollector( &m_cCamParsCollector );
     680#endif
     681
     682    // append pic list of new decoder to PicLists
     683    assert( m_ivPicLists.size() == m_numDecoders );
     684    m_ivPicLists.push_back( m_tDecTop[ decIdx ]->getListPic() );
     685
     686    // create recon file related stuff     
     687    Char* pchTempFilename = NULL;
     688    if ( m_pchReconFile )
     689    {     
     690      Char buffer[4];     
     691      sprintf(buffer,"_%i", layerId );
     692      assert ( m_pchReconFile );
     693      xAppendToFileNameEnd( m_pchReconFile , buffer, pchTempFilename );
     694      assert( m_pchReconFiles.size() == m_numDecoders );
     695    }
     696
     697    m_pchReconFiles.push_back( pchTempFilename );   
     698
     699    m_tVideoIOYuvReconFile[ decIdx ] = new TVideoIOYuv;
     700    m_reconOpen           [ decIdx ] = false;
     701
     702    // set others
     703    m_pocLastDisplay      [ decIdx ] = -MAX_INT;
     704    m_layerIdToDecIdx     [ layerId ] = decIdx;
     705
     706    m_numDecoders++;
     707  };
     708  return decIdx;
     709}
     710#endif
    762711//! \}
  • trunk/source/App/TAppDecoder/TAppDecTop.h

    r443 r608  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    4646#include "TLibCommon/TComList.h"
    4747#include "TLibCommon/TComPicYuv.h"
    48 #include "TLibCommon/TComDepthMapGenerator.h"
    4948#include "TLibDecoder/TDecTop.h"
    5049#include "TAppDecCfg.h"
     
    6261private:
    6362  // class interface
    64   std::vector<TDecTop*>           m_tDecTop;                      ///< decoder classes
    65 
    66   std::vector<TVideoIOYuv*>       m_tVideoIOYuvReconFile;         ///< reconstruction YUV class
    67 
    68   // for output control
     63#if H_MV
     64  TDecTop*                        m_tDecTop             [ MAX_NUM_LAYERS ];    ///< decoder classes
     65  TVideoIOYuv*                    m_tVideoIOYuvReconFile[ MAX_NUM_LAYERS ];    ///< reconstruction YUV class
     66  Int                             m_layerIdToDecIdx     [ MAX_NUM_LAYER_IDS ]; ///< maping from layer id to decoder index
     67  Int                             m_numDecoders;                               ///< number of decoder instances
     68  TComPicLists                    m_ivPicLists;                                ///< picture buffers of decoder instances
     69#else
     70  TDecTop                         m_cTDecTop;                     ///< decoder class
     71  TVideoIOYuv                     m_cTVideoIOYuvReconFile;        ///< reconstruction YUV class
     72#endif
     73    // for output control
    6974  Bool                            m_abDecFlag[ MAX_GOP ];         ///< decoded flag in one GOP
    70   std::vector<Int>                m_pocLastDisplay;               ///< last POC in display order
    71   Bool                            m_useDepth;
    72 
    73 #if FLEX_CODING_ORDER_M23723
    74   Int  m_fcoViewDepthId;
    75   Char m_fcoOrder[MAX_VIEW_NUM*2];
     75#if H_MV
     76  Int                             m_pocLastDisplay      [ MAX_NUM_LAYERS ]; ///< last POC in display order
     77  Bool                            m_reconOpen           [ MAX_NUM_LAYERS ]; ///< reconstruction file opened
     78#else
     79  Int                             m_iPOCLastDisplay;              ///< last POC in display order
    7680#endif
    77 
     81#if H_3D
    7882  FILE*                           m_pScaleOffsetFile;
    7983  CamParsCollector                m_cCamParsCollector;
    80 #if DEPTH_MAP_GENERATION
    81 #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
    82   TComVPSAccess                   m_cVPSAccess;
    8384#endif
    84   TComSPSAccess                   m_cSPSAccess;
    85   TComAUPicAccess                 m_cAUPicAccess;
    86 #endif
    87 
    8885public:
    8986  TAppDecTop();
     
    9390  Void  destroy           (); ///< destroy internal members
    9491  Void  decode            (); ///< main decoding function
    95 #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
    96   Void  increaseNumberOfViews  (UInt layerId, UInt viewId, UInt isDepth);
    97 #else
    98   Void  increaseNumberOfViews  (Int newNumberOfViewDepth);
    99 #endif
    100   TDecTop* getTDecTop     ( Int viewId, Bool isDepth );
    101 
    102   std::vector<TComPic*> getInterViewRefPics( Int viewId, Int poc, Bool isDepth, TComSPS* sps );
    103   TComPic*              getPicFromView     ( Int viewId, Int poc, bool isDepth ) { return xGetPicFromView( viewId, poc, isDepth ); }
    104 
    105 #if DEPTH_MAP_GENERATION
    106 #if VIDYO_VPS_INTEGRATION
    107   TComVPSAccess*    getVPSAccess  () { return &m_cVPSAccess;   }
    108 #endif
    109   TComSPSAccess*    getSPSAccess  () { return &m_cSPSAccess;   }
    110   TComAUPicAccess*  getAUPicAccess() { return &m_cAUPicAccess; }
    111   TDecTop*          getDecTop0    () { return m_tDecTop[0]; }
    112 #endif
    113 
    114 #if MERL_VSP_C0152
    115 #if MERL_VSP_NBDV_RefVId_Fix_D0166
    116   Void  setBWVSPLUT( Int iNeighborViewId, TComSlice* pcSlice, Int iCodedViewIdx, Int iCurPoc );
    117 #else
    118   Void  setBWVSPLUT( TComSlice* pcSlice, Int iCodedViewIdx, Int iCurPoc   );
    119 #endif
    120 #endif
    12192
    12293protected:
    123 //  Void  xCreateDecLib     (); ///< create internal classes
     94  Void  xCreateDecLib     (); ///< create internal classes
    12495  Void  xDestroyDecLib    (); ///< destroy internal classes
    125 //  Void  xInitDecLib       (); ///< initialize decoder class
    126  
    127   Void  xWriteOutput      ( TComList<TComPic*>* pcListPic, Int viewDepthId, UInt tId); ///< write YUV to file
    128   Void  xFlushOutput      ( TComList<TComPic*>* pcListPic, Int viewDepthId ); ///< flush all remaining decoded pictures to file
     96  Void  xInitDecLib       (); ///< initialize decoder class
    12997
    130   TComPic* xGetPicFromView( Int viewId, Int poc, Bool isDepth );
     98#if H_MV
     99  Void  xWriteOutput      ( TComList<TComPic*>* pcListPic, Int layerId, Int tId ); ///< write YUV to file
     100  Void  xFlushOutput      ( TComList<TComPic*>* pcListPic, Int layerId ); ///< flush all remaining decoded pictures to file
     101  Int   xGetDecoderIdx    ( Int layerId, Bool createFlag = false );
     102#else
     103  Void  xWriteOutput      ( TComList<TComPic*>* pcListPic , UInt tId); ///< write YUV to file
     104  Void  xFlushOutput      ( TComList<TComPic*>* pcListPic ); ///< flush all remaining decoded pictures to file
     105#endif
     106  Bool  isNaluWithinTargetDecLayerIdSet ( InputNALUnit* nalu ); ///< check whether given Nalu is within targetDecLayerIdSet
    131107};
    132108
    133109//! \}
     110
    134111#endif
    135112
  • trunk/source/App/TAppDecoder/decmain.cpp

    r56 r608  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    5656  // print information
    5757  fprintf( stdout, "\n" );
    58   fprintf( stdout, "3D-HTM Software: Decoder Version [%s] based on HM Version [%s]", NV_VERSION, HM_VERSION );
     58#if H_MV
     59  fprintf( stdout, "3D-HTM Software: Decoder Version [%s] based on HM Version [%s]", NV_VERSION, HM_VERSION ); 
     60#else
     61  fprintf( stdout, "HM software: Decoder Version [%s]", NV_VERSION );
     62#endif
    5963  fprintf( stdout, NVM_ONOS );
    6064  fprintf( stdout, NVM_COMPILEDBY );
Note: See TracChangeset for help on using the changeset viewer.