Ignore:
Timestamp:
4 May 2015, 18:38:08 (10 years ago)
Author:
tech
Message:

Update to HM-16.5.
Starting point for further re-activation of 3D-tools.

Includes:

active:

  • MV-HEVC
  • 3D-HLS (apart from DLT)
  • VSO

inactive:

  • remaining 3D-HEVC tools.
Location:
branches/HTM-14.1-update-dev0/source/App/TAppDecoder
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/HTM-14.1-update-dev0/source/App/TAppDecoder/TAppDecCfg.cpp

    r1179 r1200  
    22 * License, included below. This software may be subject to other third party
    33 * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license. 
    5  *
    6 * Copyright (c) 2010-2015, ITU/ISO/IEC
     4 * granted under this license.
     5 *
     6 * Copyright (c) 2010-2015, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    4141#include "TAppDecCfg.h"
    4242#include "TAppCommon/program_options_lite.h"
    43 
    44 #if H_MV
    45 #include <cassert>
    46 #endif
     43#include "TLibCommon/TComChromaFormat.h"
    4744#ifdef WIN32
    4845#define strdup _strdup
     46#endif
     47#if NH_MV
     48#include <cassert>
    4949#endif
    5050
     
    6868  string cfg_ReconFile;
    6969  string cfg_TargetDecLayerIdSetFile;
    70 #if H_3D
     70#if NH_3D
    7171  string cfg_ScaleOffsetFile;
    7272#endif
     73  string outputColourSpaceConvert;
     74  Int warnUnknowParameter = 0;
    7375
    7476  po::Options opts;
    7577  opts.addOptions()
    76   ("help", do_help, false, "this help text")
    77   ("BitstreamFile,b", cfg_BitstreamFile, string(""), "bitstream input file name")
    78   ("ReconFile,o",     cfg_ReconFile,     string(""), "reconstructed YUV output file name\n"
    79                                                      "YUV writing is skipped if omitted")
    80 #if H_3D
    81   ("ScaleOffsetFile,p", cfg_ScaleOffsetFile, string(""), "file with coded scales and offsets")
    82 #endif
    83   ("SkipFrames,s", m_iSkipFrame, 0, "number of frames to skip before random access")
    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   ("TargetOptLayerSetIdx,x", m_targetOptLayerSetIdx, -1, "Target output layer set index. (default: -1, determine automatically to be equal to highest layer set index") // Should actually equal to 0 as default. However, this would cause only the base layer to be decoded. 
    88 #endif
    89   ("MaxTemporalLayer,t", m_iMaxTemporalLayer, -1, "Maximum Temporal Layer to be decoded. -1 to decode all layers")
    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")
    96 #if H_MV
    97   ("OutputVpsInfo,v", m_outputVpsInfo, false, "Output information about the layer dependencies and layer sets")
    98 #endif
     78
     79
     80  ("help",                      do_help,                               false,      "this help text")
     81  ("BitstreamFile,b",           cfg_BitstreamFile,                     string(""), "bitstream input file name")
     82  ("ReconFile,o",               cfg_ReconFile,                         string(""), "reconstructed YUV output file name\n"
     83                                                                                   "YUV writing is skipped if omitted")
     84#if NH_3D
     85  ("ScaleOffsetFile,p",         cfg_ScaleOffsetFile,                   string(""), "file with coded scales and offsets")
     86  ("Depth420OutputFlag",        m_depth420OutputFlag,                  true      , "Output depth layers in 4:2:0 ")
     87#endif
     88  ("WarnUnknowParameter,w",     warnUnknowParameter,                                  0, "warn for unknown configuration parameters instead of failing")
     89  ("SkipFrames,s",              m_iSkipFrame,                          0,          "number of frames to skip before random access")
     90  ("OutputBitDepth,d",          m_outputBitDepth[CHANNEL_TYPE_LUMA],   0,          "bit depth of YUV output luma component (default: use 0 for native depth)")
     91  ("OutputBitDepthC,d",         m_outputBitDepth[CHANNEL_TYPE_CHROMA], 0,          "bit depth of YUV output chroma component (default: use 0 for native depth)")
     92  ("OutputColourSpaceConvert",  outputColourSpaceConvert,              string(""), "Colour space conversion to apply to input 444 video. Permitted values are (empty string=UNCHANGED) " + getListOfColourSpaceConverts(false))
     93#if NH_MV
     94  ("TargetOptLayerSetIdx,x",    m_targetOptLayerSetIdx,                -1,         "Target output layer set index. (default: -1, determine automatically to be equal to highest layer set index") // Should actually equal to 0 as default. However, this would cause only the base layer to be decoded. 
     95#endif
     96  ("MaxTemporalLayer,t",        m_iMaxTemporalLayer,                   -1,         "Maximum Temporal Layer to be decoded. -1 to decode all layers")
     97  ("SEIDecodedPictureHash",     m_decodedPictureHashSEIEnabled,        1,          "Control handling of decoded picture hash SEI messages\n"
     98                                                                                   "\t1: check hash in SEI messages if available in the bitstream\n"
     99                                                                                   "\t0: ignore SEI message")
     100  ("SEINoDisplay",              m_decodedNoDisplaySEIEnabled,          true,       "Control handling of decoded no display SEI messages")
     101  ("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.")
     102  ("RespectDefDispWindow,w",    m_respectDefDispWindow,                0,          "Only output content inside the default display window\n")
     103#if NH_MV
     104  ("OutputVpsInfo,v",           m_outputVpsInfo,                       false,       "Output information about the layer dependencies and layer sets")
     105#endif
     106#if O0043_BEST_EFFORT_DECODING
     107  ("ForceDecodeBitDepth",       m_forceDecodeBitDepth,                 0U,         "Force the decoder to operate at a particular bit-depth (best effort decoding)")
     108#endif
     109  ("OutputDecodedSEIMessagesFilename",  m_outputDecodedSEIMessagesFilename,    string(""), "When non empty, output decoded SEI messages to the indicated file. If file is '-', then output to stdout\n")
     110  ("ClipOutputVideoToRec709Range",      m_bClipOutputVideoToRec709Range,  false, "If true then clip output video to the Rec. 709 Range on saving")
    99111  ;
     112
    100113  po::setDefaults(opts);
    101   const list<const Char*>& argv_unhandled = po::scanArgv(opts, argc, (const Char**) argv);
     114  po::ErrorReporter err;
     115  const list<const Char*>& argv_unhandled = po::scanArgv(opts, argc, (const Char**) argv, err);
    102116
    103117  for (list<const Char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
     
    109123  {
    110124    po::doHelp(cout, opts);
     125    return false;
     126  }
     127
     128  if (err.is_errored)
     129  {
     130    if (!warnUnknowParameter)
     131    {
     132      /* errors have already been reported to stderr */
     133      return false;
     134    }
     135  }
     136
     137  m_outputColourSpaceConvert = stringToInputColourSpaceConvert(outputColourSpaceConvert, false);
     138  if (m_outputColourSpaceConvert>=NUMBER_INPUT_COLOUR_SPACE_CONVERSIONS)
     139  {
     140    fprintf(stderr, "Bad output colour space conversion string\n");
    111141    return false;
    112142  }
     
    116146  m_pchReconFile = cfg_ReconFile.empty() ? NULL : strdup(cfg_ReconFile.c_str());
    117147
    118 #if H_3D
     148#if NH_3D
    119149  m_pchScaleOffsetFile = cfg_ScaleOffsetFile.empty() ? NULL : strdup(cfg_ScaleOffsetFile.c_str());
    120150#endif
     151
    121152  if (!m_pchBitstreamFile)
    122153  {
    123     fprintf(stderr, "No input file specifed, aborting\n");
     154    fprintf(stderr, "No input file specified, aborting\n");
    124155    return false;
    125156  }
     
    127158  if ( !cfg_TargetDecLayerIdSetFile.empty() )
    128159  {
    129 #if H_MV
     160#if NH_MV
    130161    m_targetDecLayerIdSetFileEmpty = false;     
    131162#endif
     
    152183        if ( layerIdParsed < 0 || layerIdParsed >= MAX_NUM_LAYER_IDS )
    153184        {
    154           fprintf(stderr, "Warning! Parsed LayerId %d is not withing allowed range [0,%d]. Ignoring this value.\n", layerIdParsed, MAX_NUM_LAYER_IDS-1 );
     185          fprintf(stderr, "Warning! Parsed LayerId %d is not within allowed range [0,%d]. Ignoring this value.\n", layerIdParsed, MAX_NUM_LAYER_IDS-1 );
    155186        }
    156187        else
     
    172203    }
    173204  }
    174 #if H_MV
    175   m_targetDecLayerIdSet.push_back( 0 );         // Only base layer at startup
    176 #endif
    177 
     205
     206#if NH_MV
     207  //m_targetDecLayerIdSet.push_back( 0 );         // Only base layer at startup
     208#endif
    178209  return true;
    179210}
    180211
    181 #if H_MV
     212#if NH_MV
    182213Void TAppDecCfg::xAppendToFileNameEnd( Char* pchInputFileName, const Char* pchStringToAppend, Char*& rpchOutputFileName)
    183214{
  • branches/HTM-14.1-update-dev0/source/App/TAppDecoder/TAppDecCfg.h

    r1179 r1200  
    22 * License, included below. This software may be subject to other third party
    33 * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license. 
     4 * granted under this license.
    55 *
    6 * Copyright (c) 2010-2015, ITU/ISO/IEC
     6 * Copyright (c) 2010-2015, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    4545#include "TLibCommon/CommonDef.h"
    4646#include <vector>
     47
    4748//! \ingroup TAppDecoder
    4849//! \{
     
    5657{
    5758protected:
    58   Char*         m_pchBitstreamFile;                   ///< input bitstream file name
    59 #if H_MV
    60   Int           m_targetOptLayerSetIdx;               ///< target output layer set index
    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
     59  Char*         m_pchBitstreamFile;                     ///< input bitstream file name
     60#if NH_MV
     61  Int           m_targetOptLayerSetIdx;                 ///< target output layer set index
     62  Int           m_maxLayerId;                           ///< maximum nuh_layer_id decoded
     63  std::vector<Char*> m_pchReconFiles;                   ///< array of output reconstruction file name create from output reconstruction file name
    6364#endif
    64   Char*         m_pchReconFile;                       ///< output reconstruction file name
    65 #if H_3D
    66   Char*         m_pchScaleOffsetFile;                 ///< output coded scale and offset parameters
     65  Char*         m_pchReconFile;                         ///< output reconstruction file name
     66#if NH_3D
     67  Char*         m_pchScaleOffsetFile;                   ///< output coded scale and offset parameters
     68  Bool          m_depth420OutputFlag;                   ///< output depth layers in 4:2:0
    6769#endif
    68   Int           m_iSkipFrame;                         ///< counter for frames prior to the random access point to skip
    69   Int           m_outputBitDepthY;                    ///< bit depth used for writing output (luma)
    70   Int           m_outputBitDepthC;                    ///< bit depth used for writing output (chroma)t
     70  Int           m_iSkipFrame;                           ///< counter for frames prior to the random access point to skip
     71  Int           m_outputBitDepth[MAX_NUM_CHANNEL_TYPE]; ///< bit depth used for writing output
     72  InputColourSpaceConversion m_outputColourSpaceConvert;
    7173
    7274  Int           m_iMaxTemporalLayer;                  ///< maximum temporal layer to be decoded
    7375  Int           m_decodedPictureHashSEIEnabled;       ///< Checksum(3)/CRC(2)/MD5(1)/disable(0) acting on decoded picture hash SEI message
     76  Bool          m_decodedNoDisplaySEIEnabled;         ///< Enable(true)/disable(false) writing only pictures that get displayed based on the no display SEI message
     77  std::vector<Int> m_targetDecLayerIdSet;             ///< set of LayerIds to be included in the sub-bitstream extraction process.
     78#if NH_MV
     79  Bool          m_targetDecLayerIdSetFileEmpty;       ///< indication if target layers are given by file
     80#endif
    7481
    75   std::vector<Int> m_targetDecLayerIdSet;             ///< set of LayerIds to be included in the sub-bitstream extraction process.
    76 #if H_MV
    77   Bool          m_targetDecLayerIdSetFileEmpty;      ///< indication if target layers are given by file
     82  Int           m_respectDefDispWindow;               ///< Only output content inside the default display window
     83#if O0043_BEST_EFFORT_DECODING
     84  UInt          m_forceDecodeBitDepth;                ///< if non-zero, force the bit depth at the decoder (best effort decoding)
    7885#endif
    79   Int           m_respectDefDispWindow;               ///< Only output content inside the default display window
    80 
    81 #if H_MV
     86  std::string   m_outputDecodedSEIMessagesFilename;   ///< filename to output decoded SEI messages to. If '-', then use stdout. If empty, do not output details.
     87  Bool          m_bClipOutputVideoToRec709Range;      ///< If true, clip the output video to the Rec 709 range on saving.
     88#if NH_MV
    8289  Bool          m_outputVpsInfo;                     ///< Output VPS information
    8390  Void xAppendToFileNameEnd( Char* pchInputFileName, const Char* pchStringToAppend, Char*& rpchOutputFileName); ///< create filenames
    8491#endif
     92
    8593public:
    8694  TAppDecCfg()
     
    8896  , m_pchReconFile(NULL)
    8997  , m_iSkipFrame(0)
    90   , m_outputBitDepthY(0)
    91   , m_outputBitDepthC(0)
     98  , m_outputColourSpaceConvert(IPCOLOURSPACE_UNCHANGED)
    9299  , m_iMaxTemporalLayer(-1)
    93100  , m_decodedPictureHashSEIEnabled(0)
    94 #if H_MV
     101  , m_decodedNoDisplaySEIEnabled(false)
     102#if NH_MV
    95103  , m_targetDecLayerIdSetFileEmpty(true)
    96104#endif
    97105  , m_respectDefDispWindow(0)
    98   {}
     106#if O0043_BEST_EFFORT_DECODING
     107  , m_forceDecodeBitDepth(0)
     108#endif
     109  {
     110    for (UInt channelTypeIndex = 0; channelTypeIndex < MAX_NUM_CHANNEL_TYPE; channelTypeIndex++)
     111    {
     112      m_outputBitDepth[channelTypeIndex] = 0;
     113    }
     114  }
     115
    99116  virtual ~TAppDecCfg() {}
    100  
     117
    101118  Bool  parseCfg        ( Int argc, Char* argv[] );   ///< initialize option class from configuration
    102119};
  • branches/HTM-14.1-update-dev0/source/App/TAppDecoder/TAppDecTop.cpp

    r1196 r1200  
    22 * License, included below. This software may be subject to other third party
    33 * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license. 
     4 * granted under this license.
    55 *
    6 * Copyright (c) 2010-2015, ITU/ISO/IEC
     6 * Copyright (c) 2010-2015, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    4545#include "TLibDecoder/AnnexBread.h"
    4646#include "TLibDecoder/NALread.h"
     47#if RExt__DECODER_DEBUG_BIT_STATISTICS
     48#include "TLibCommon/TComCodingStatistics.h"
     49#endif
    4750
    4851//! \ingroup TAppDecoder
     
    5457
    5558TAppDecTop::TAppDecTop()
    56 #if !H_MV
     59#if !NH_MV
    5760: m_iPOCLastDisplay(-MAX_INT)
    5861#else
     
    6063#endif
    6164{
    62 #if H_MV
     65#if NH_MV
    6366  for (Int i = 0; i < MAX_NUM_LAYER_IDS; i++)
    6467  {
     
    6770  }
    6871#endif
    69 #if H_3D
     72#if NH_3D
    7073    m_pScaleOffsetFile  = 0;
    7174#endif
    7275
    73 #if H_MV
     76#if NH_MV
    7477    m_markedForOutput = false;
    7578#endif
     
    8386Void TAppDecTop::destroy()
    8487{
     88#if NH_MV
     89  // destroy internal classes
     90  xDestroyDecLib();
     91#endif
     92
    8593  if (m_pchBitstreamFile)
    8694  {
     
    8896    m_pchBitstreamFile = NULL;
    8997  }
    90 #if H_MV
     98#if NH_MV
    9199  for (Int decIdx = 0; decIdx < m_numDecoders; decIdx++)
    92100  {
     
    103111    m_pchReconFile = NULL;
    104112  }
    105 #if H_3D
     113#if NH_3D
    106114  if (m_pchScaleOffsetFile)
    107115  {
     
    127135{
    128136  Int                 poc;
    129 #if H_MV
     137#if NH_MV
    130138  poc = -1;
    131139#endif
     
    138146    exit(EXIT_FAILURE);
    139147  }
    140 
    141 #if H_3D
     148#if NH_3D
    142149  if( m_pchScaleOffsetFile )
    143150  {
     
    146153  }
    147154#endif
     155
    148156  InputByteStream bytestream(bitstreamFile);
     157
     158  if (!m_outputDecodedSEIMessagesFilename.empty() && m_outputDecodedSEIMessagesFilename!="-")
     159  {
     160    m_seiMessageFileStream.open(m_outputDecodedSEIMessagesFilename.c_str(), std::ios::out);
     161    if (!m_seiMessageFileStream.is_open() || !m_seiMessageFileStream.good())
     162    {
     163      fprintf(stderr, "\nUnable to open file `%s' for writing decoded SEI messages\n", m_outputDecodedSEIMessagesFilename.c_str());
     164      exit(EXIT_FAILURE);
     165    }
     166  }
    149167
    150168  // create & initialize internal classes
    151169  xCreateDecLib();
    152170  xInitDecLib  ();
    153 #if !H_MV
     171#if !NH_MV
    154172  m_iPOCLastDisplay += m_iSkipFrame;      // set the last displayed POC correctly for skip forward.
    155173
     
    169187  Bool firstSlice        = true;
    170188#endif
    171   Bool loopFiltered      = false;
     189  Bool loopFiltered = false;
    172190
    173191  while (!!bitstreamFile)
     
    177195     * requires the TDecTop::decode() method to be called again with the same
    178196     * nal unit. */
     197#if RExt__DECODER_DEBUG_BIT_STATISTICS
     198    TComCodingStatistics::TComCodingStatisticsData backupStats(TComCodingStatistics::GetStatistics());
     199    streampos location = bitstreamFile.tellg() - streampos(bytestream.GetNumBufferedBytes());
     200#else
    179201    streampos location = bitstreamFile.tellg();
    180 #if H_MV
     202#endif
     203#if NH_MV
    181204#if ENC_DEC_TRACE
    182205    Int64 symCount = g_nSymbolCounter;
     
    184207#endif
    185208    AnnexBStats stats = AnnexBStats();
    186     vector<uint8_t> nalUnit;
     209
    187210    InputNALUnit nalu;
    188     byteStreamNALUnit(bytestream, nalUnit, stats);
     211    byteStreamNALUnit(bytestream, nalu.getBitstream().getFifo(), stats);
    189212
    190213    // call actual decoding function
    191214    Bool bNewPicture = false;
    192 #if H_MV
     215#if NH_MV
    193216    Bool newSliceDiffPoc   = false;
    194217    Bool newSliceDiffLayer = false;
     
    196219    Bool allLayersDecoded  = false;     
    197220#endif
    198     if (nalUnit.empty())
     221    if (nalu.getBitstream().getFifo().empty())
    199222    {
    200223      /* this can happen if the following occur:
     
    207230    else
    208231    {
    209       read(nalu, nalUnit);
    210 #if H_MV     
     232      read(nalu);
     233#if NH_MV     
    211234      if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer)
    212235          || !isNaluWithinTargetDecLayerIdSet(&nalu)
    213           || nalu.m_layerId > MAX_NUM_LAYER_IDS-1
    214           || (nalu.m_nalUnitType == NAL_UNIT_VPS && nalu.m_layerId > 0)           
    215           || (nalu.m_nalUnitType == NAL_UNIT_EOB && nalu.m_layerId > 0)   
    216           || (nalu.m_nalUnitType == NAL_UNIT_EOS && nalu.m_layerId > 0)   
     236          || nalu.m_nuhLayerId > MAX_NUM_LAYER_IDS-1
     237          || (nalu.m_nalUnitType == NAL_UNIT_VPS && nalu.m_nuhLayerId > 0)           
     238          || (nalu.m_nalUnitType == NAL_UNIT_EOB && nalu.m_nuhLayerId > 0)             
    217239         )
    218240      {
     
    225247      else
    226248      {
    227         Int decIdx     = xGetDecoderIdx( nalu.m_layerId , true );     
    228         newSliceDiffLayer = nalu.isSlice() && ( nalu.m_layerId != layerIdCurrPic ) && !firstSlice;
     249        Int decIdx     = xGetDecoderIdx( nalu.m_nuhLayerId , true );     
     250        newSliceDiffLayer = nalu.isSlice() && ( nalu.m_nuhLayerId != layerIdCurrPic ) && !firstSlice;
    229251        newSliceDiffPoc   = m_tDecTop[decIdx]->decode(nalu, m_iSkipFrame, m_pocLastDisplay[decIdx], newSliceDiffLayer, sliceSkippedFlag );
    230252        // decode function only returns true when all of the following conditions are true
     
    233255        // - nalu.isSlice() == true     
    234256
    235         if ( nalu.m_nalUnitType == NAL_UNIT_VPS )
    236         {
    237           m_vps = m_tDecTop[decIdx]->getPrefetchedVPS();
     257        bNewPicture       = ( newSliceDiffLayer || newSliceDiffPoc ) && !sliceSkippedFlag;
     258        if ( nalu.isSlice() && firstSlice && !sliceSkippedFlag )       
     259        {
     260          layerIdCurrPic = nalu.m_nuhLayerId;
     261          pocCurrPic     = m_tDecTop[decIdx]->getCurrPoc();
     262          decIdxCurrPic  = decIdx;
     263          firstSlice     = false;
     264
     265          /// Use VPS activated by the first slice to determine OLS
     266          m_vps = m_tDecTop[decIdx]->getActiveVPS( );
    238267          if ( m_targetDecLayerIdSetFileEmpty )
    239           {
    240             TComVPS* vps = m_vps;
     268          {           
    241269            if ( m_targetOptLayerSetIdx == -1 )
    242270            {
    243               // Not normative! Corresponds to specification by "External Means". (Should be set equal to 0, when no external means available. )
    244               m_targetOptLayerSetIdx = vps->getVpsNumLayerSetsMinus1();
     271              m_targetOptLayerSetIdx = m_tDecTop[decIdx]->getTargetOlsIdx();
    245272            }
    246 
    247             for (Int dI = 0; dI < m_numDecoders; dI++ )
     273            else
    248274            {
    249               m_tDecTop[decIdx]->setTargetOptLayerSetIdx( m_targetOptLayerSetIdx );
    250 #if H_3D
    251               m_tDecTop[decIdx]->setProfileIdc( );
    252 #endif
     275              assert( m_tDecTop[decIdx]->getTargetOlsIdx() == m_targetOptLayerSetIdx );
    253276            }
    254277
    255             if ( m_targetOptLayerSetIdx < 0 || m_targetOptLayerSetIdx >= vps->getNumOutputLayerSets() )
     278            if ( m_targetOptLayerSetIdx < 0 || m_targetOptLayerSetIdx >= m_vps->getNumOutputLayerSets() )
    256279            {
    257               fprintf(stderr, "\ntarget output layer set index must be in the range of 0 to %d, inclusive \n", vps->getNumOutputLayerSets() - 1 );           
     280              fprintf(stderr, "\ntarget output layer set index must be in the range of 0 to %d, inclusive \n", m_vps->getNumOutputLayerSets() - 1 );           
    258281              exit(EXIT_FAILURE);
    259282            }
    260             m_targetDecLayerIdSet = vps->getTargetDecLayerIdList( m_targetOptLayerSetIdx );
     283            m_targetDecLayerIdSet = m_vps->getTargetDecLayerIdList( m_targetOptLayerSetIdx );
    261284          }
     285
    262286          if (m_outputVpsInfo )
    263287          {
     
    267291            m_vps->printPTL();
    268292          }
    269         }
    270 #if H_3D
    271         if (nalu.m_nalUnitType == NAL_UNIT_VPS )
    272         {                 
    273           m_cCamParsCollector.init( m_pScaleOffsetFile, m_tDecTop[decIdx]->getPrefetchedVPS() );
    274         }       
    275 #endif
    276         bNewPicture       = ( newSliceDiffLayer || newSliceDiffPoc ) && !sliceSkippedFlag;
    277         if ( nalu.isSlice() && firstSlice && !sliceSkippedFlag )       
    278         {
    279           layerIdCurrPic = nalu.m_layerId;
    280           pocCurrPic     = m_tDecTop[decIdx]->getCurrPoc();
    281           decIdxCurrPic  = decIdx;
    282           firstSlice     = false;
    283         }
    284 
    285         if ( bNewPicture || !bitstreamFile )
     293        }       
     294
     295        if ( bNewPicture || !bitstreamFile || nalu.m_nalUnitType == NAL_UNIT_EOS )
    286296        {
    287297          layerIdLastPic    = layerIdCurrPic;
    288           layerIdCurrPic    = nalu.m_layerId;
     298          layerIdCurrPic    = nalu.m_nuhLayerId;
    289299          pocLastPic        = pocCurrPic;
    290300          pocCurrPic        = m_tDecTop[decIdx]->getCurrPoc();
    291301          decIdxLastPic     = decIdxCurrPic;
    292302          decIdxCurrPic     = decIdx;
    293           allLayersDecoded = ( pocCurrPic != pocLastPic );
     303          allLayersDecoded = ( pocCurrPic != pocLastPic ) && ( nalu.m_nalUnitType != NAL_UNIT_EOS );
    294304        }
    295305#else
     
    309319           * [1] except for the first NAL unit in the file
    310320           *     (but bNewPicture doesn't happen then) */
     321#if RExt__DECODER_DEBUG_BIT_STATISTICS
     322          bitstreamFile.seekg(location);
     323          bytestream.reset();
     324          TComCodingStatistics::SetStatistics(backupStats);
     325#else
    311326          bitstreamFile.seekg(location-streamoff(3));
    312327          bytestream.reset();
     328#endif
    313329#if H_MV_ENC_DEC_TRAC
    314330#if ENC_DEC_TRACE
     
    327343      }
    328344    }
    329     if (bNewPicture || !bitstreamFile || nalu.m_nalUnitType == NAL_UNIT_EOS )
     345
     346    if ( (bNewPicture || !bitstreamFile || nalu.m_nalUnitType == NAL_UNIT_EOS) &&
     347#if NH_MV     
     348      !m_tDecTop[decIdxLastPic]->getFirstSliceInSequence () )
     349#else
     350      !m_cTDecTop.getFirstSliceInSequence () )
     351#endif
     352
    330353    {
    331354      if (!loopFiltered || bitstreamFile)
    332355      {
    333 #if H_MV
     356#if NH_MV
    334357        assert( decIdxLastPic != -1 );
    335358        m_tDecTop[decIdxLastPic]->endPicDecoding(poc, pcListPic, m_targetDecLayerIdSet );
     
    340363      }
    341364      loopFiltered = (nalu.m_nalUnitType == NAL_UNIT_EOS);
    342     }
    343 #if !FIX_WRITING_OUTPUT
    344 #if SETTING_NO_OUT_PIC_PRIOR
    345     if (bNewPicture && m_cTDecTop.getIsNoOutputPriorPics())
    346     {
    347       m_cTDecTop.checkNoOutputPriorPics( pcListPic );
    348     }
    349 #endif
    350 #endif
    351 #if H_3D
     365      if (nalu.m_nalUnitType == NAL_UNIT_EOS)
     366      {
     367#if NH_MV     
     368        m_tDecTop[decIdxLastPic]->setFirstSliceInSequence(true);
     369#else
     370        m_cTDecTop.setFirstSliceInSequence(true);
     371#endif
     372      }
     373    }
     374    else if ( (bNewPicture || !bitstreamFile || nalu.m_nalUnitType == NAL_UNIT_EOS ) &&
     375#if NH_MV     
     376              m_tDecTop[decIdxLastPic]->getFirstSliceInSequence () )
     377#else
     378              m_cTDecTop.getFirstSliceInSequence () )
     379#endif
     380    {
     381#if NH_MV     
     382      m_tDecTop[decIdxLastPic]->setFirstSliceInPicture (true);
     383#else
     384      m_cTDecTop.setFirstSliceInPicture (true);
     385#endif
     386    }
     387
     388#if NH_3D
    352389    if ( allLayersDecoded || !bitstreamFile )
    353390    {
     
    363400    if( pcListPic )
    364401    {
    365 #if H_MV
     402#if NH_MV
    366403      if ( m_pchReconFiles[decIdxLastPic] && !m_reconOpen[decIdxLastPic] )
    367404#else
    368       if ( m_pchReconFile && !openedReconFile  )
    369 #endif
    370       {
    371         if (!m_outputBitDepthY) { m_outputBitDepthY = g_bitDepthY; }
    372         if (!m_outputBitDepthC) { m_outputBitDepthC = g_bitDepthC; }
    373 
    374 #if H_MV
    375         m_tVideoIOYuvReconFile[decIdxLastPic]->open( m_pchReconFiles[decIdxLastPic], true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode
     405      if ( m_pchReconFile && !openedReconFile )
     406#endif
     407      {
     408        const BitDepths &bitDepths=pcListPic->front()->getPicSym()->getSPS().getBitDepths(); // use bit depths of first reconstructed picture.
     409        for (UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++)
     410        {
     411          if (m_outputBitDepth[channelType] == 0)
     412          {
     413            m_outputBitDepth[channelType] = bitDepths.recon[channelType];
     414          }
     415        }
     416#if NH_MV
     417        m_tVideoIOYuvReconFile[decIdxLastPic]->open( m_pchReconFiles[decIdxLastPic], true, m_outputBitDepth, m_outputBitDepth, bitDepths.recon ); // write mode
    376418        m_reconOpen[decIdxLastPic] = true;
    377419      }
    378 #if FIX_WRITING_OUTPUT
    379420      // write reconstruction to file
    380421      if( bNewPicture )
     
    388429        xWriteOutput( pcListPic, decIdxLastPic, nalu.m_temporalId );
    389430      }
    390 #if SETTING_NO_OUT_PIC_PRIOR
    391431      if ( (bNewPicture || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_CRA) && m_tDecTop[decIdxLastPic]->getNoOutputPriorPicsFlag() )
    392432      {
     
    394434        m_tDecTop[decIdxLastPic]->setNoOutputPriorPicsFlag (false);
    395435      }
    396 #endif
    397 #endif
     436
    398437      if ( bNewPicture && newSliceDiffPoc &&
    399438#else
    400         m_cTVideoIOYuvReconFile.open( m_pchReconFile, true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode
    401         openedReconFile  = true;
    402       }
    403 #if FIX_WRITING_OUTPUT
     439        m_cTVideoIOYuvReconFile.open( m_pchReconFile, true, m_outputBitDepth, m_outputBitDepth, bitDepths.recon ); // write mode
     440        openedReconFile = true;
     441      }
    404442      // write reconstruction to file
    405443      if( bNewPicture )
     
    407445        xWriteOutput( pcListPic, nalu.m_temporalId );
    408446      }
    409 #if SETTING_NO_OUT_PIC_PRIOR
    410447      if ( (bNewPicture || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_CRA) && m_cTDecTop.getNoOutputPriorPicsFlag() )
    411448      {
     
    413450        m_cTDecTop.setNoOutputPriorPicsFlag (false);
    414451      }
    415 #endif
    416 #endif
    417       if ( bNewPicture &&
     452
     453      if ( bNewPicture &&
    418454#endif
    419455           (   nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL
     
    423459            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP ) )
    424460      {
    425 #if H_MV
     461#if NH_MV
    426462        xFlushOutput( pcListPic, decIdxLastPic );
    427463#else
     
    431467      if (nalu.m_nalUnitType == NAL_UNIT_EOS)
    432468      {
    433 #if H_MV
    434 #if FIX_OUTPUT_EOS
    435         xWriteOutput( pcListPic, decIdxLastPic, nalu.m_temporalId );
    436 #else
    437         xFlushOutput( pcListPic, decIdxLastPic );
    438 #endif
    439 #else
    440 #if FIX_OUTPUT_EOS
     469#if NH_MV
     470        xWriteOutput( pcListPic, decIdxCurrPic, nalu.m_temporalId );
     471#else
    441472        xWriteOutput( pcListPic, nalu.m_temporalId );
    442 #else
    443         xFlushOutput( pcListPic );
    444 #endif
    445 
    446 #endif
    447       }
    448       // write reconstruction to file -- for additional bumping as defined in C.5.2.3
    449 #if H_MV
     473#endif
     474#if NH_MV
     475        m_tDecTop[decIdxCurrPic]->setFirstSliceInPicture (false);
     476#else
     477        m_cTDecTop.setFirstSliceInPicture (false);
     478#endif
     479      }
     480      // write reconstruction to file -- for additional bumping as defined in C.5.2.3
     481#if NH_MV
    450482      // Above comment seems to be wrong
    451483#endif
    452 #if FIX_WRITING_OUTPUT
    453484      if(!bNewPicture && nalu.m_nalUnitType >= NAL_UNIT_CODED_SLICE_TRAIL_N && nalu.m_nalUnitType <= NAL_UNIT_RESERVED_VCL31)
    454 #else
    455       if(bNewPicture)
    456 #endif
    457       {
    458 #if H_MV       
     485      {
     486#if NH_MV       
    459487        // Bumping after reference picture set has been applied (here after first vcl nalu.
    460488#if ENC_DEC_TRACE
     
    471499    }
    472500  }
    473 #if H_MV
    474 #if H_3D
     501#if NH_MV
     502#if NH_3D
    475503  if( m_cCamParsCollector.isInitialized() )
    476504  {
     
    486514  // delete buffers
    487515  m_cTDecTop.deletePicBuffer();
    488 #endif
    489      
    490516  // destroy internal classes
    491517  xDestroyDecLib();
     518#endif
    492519}
    493520
     
    498525Void TAppDecTop::xCreateDecLib()
    499526{
    500 #if H_MV
     527#if NH_MV
    501528  // initialize global variables
    502529  initROM(); 
     
    512539Void TAppDecTop::xDestroyDecLib()
    513540{
    514 #if H_MV
     541#if NH_MV
    515542  // destroy ROM
    516543  destroyROM();
     
    538565    m_cTVideoIOYuvReconFile. close();
    539566  }
    540  
     567
    541568  // destroy decoder class
    542569  m_cTDecTop.destroy();
    543570#endif
    544 #if H_3D
     571#if NH_3D
    545572  m_cCamParsCollector.uninit();
    546573  if( m_pScaleOffsetFile )
     
    553580Void TAppDecTop::xInitDecLib()
    554581{
    555 #if !H_MV
     582
     583#if NH_3D
     584  m_cCamParsCollector.setCodeScaleOffsetFile( m_pScaleOffsetFile );
     585#endif
     586#if !NH_MV
    556587  // initialize decoder class
    557588  m_cTDecTop.init();
    558589  m_cTDecTop.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
     590#if O0043_BEST_EFFORT_DECODING
     591  m_cTDecTop.setForceDecodeBitDepth(m_forceDecodeBitDepth);
     592#endif
     593  if (!m_outputDecodedSEIMessagesFilename.empty())
     594  {
     595    std::ostream &os=m_seiMessageFileStream.is_open() ? m_seiMessageFileStream : std::cout;
     596    m_cTDecTop.setDecodedSEIMessageOutputStream(&os);
     597  }
    559598#endif
    560599}
    561600
    562601/** \param pcListPic list of pictures to be written to file
    563     \todo            DYN_REF_FREE should be revised
     602    \param tId       temporal sub-layer ID
    564603 */
    565 #if H_MV
     604#if NH_MV
    566605Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic, Int decIdx, Int tId )
    567606#else
     
    569608#endif
    570609{
    571 
    572610  if (pcListPic->empty())
    573611  {
     
    578616  Int numPicsNotYetDisplayed = 0;
    579617  Int dpbFullness = 0;
    580 #if H_MV
    581   TComSPS* activeSPS = m_tDecTop[ decIdx ]->getActiveSPS();
    582 #else
    583   TComSPS* activeSPS = m_cTDecTop.getActiveSPS();
    584 #endif
     618  const TComSPS* activeSPS = &(pcListPic->front()->getPicSym()->getSPS());
     619
    585620  UInt numReorderPicsHighestTid;
    586621  UInt maxDecPicBufferingHighestTid;
     
    597632    maxDecPicBufferingHighestTid = activeSPS->getMaxDecPicBuffering(m_iMaxTemporalLayer);
    598633  }
    599  
     634
    600635  while (iterPic != pcListPic->end())
    601636  {
    602637    TComPic* pcPic = *(iterPic);
    603 #if H_MV
     638#if NH_MV
    604639    if(pcPic->getOutputMark() && pcPic->getPOC() > m_pocLastDisplay[decIdx])
    605640#else
     
    607642#endif
    608643    {
    609       numPicsNotYetDisplayed++;
     644       numPicsNotYetDisplayed++;
    610645      dpbFullness++;
    611646    }
     
    616651    iterPic++;
    617652  }
    618   iterPic   = pcListPic->begin();
     653
     654  iterPic = pcListPic->begin();
     655
    619656  if (numPicsNotYetDisplayed>2)
    620657  {
    621658    iterPic++;
    622659  }
    623  
     660
    624661  TComPic* pcPic = *(iterPic);
    625662  if (numPicsNotYetDisplayed>2 && pcPic->isField()) //Field Decoding
     
    633670      iterPic++;
    634671      TComPic* pcPicBottom = *(iterPic);
    635      
    636 #if H_MV
    637       if ( pcPicTop->getOutputMark() && (numPicsNotYetDisplayed >  pcPicTop->getNumReorderPics(tId) && !(pcPicTop->getPOC()%2) && pcPicBottom->getPOC() == pcPicTop->getPOC()+1)
    638           && pcPicBottom->getOutputMark() && (numPicsNotYetDisplayed >  pcPicBottom->getNumReorderPics(tId) && (pcPicTop->getPOC() == m_pocLastDisplay[decIdx]+1 || m_pocLastDisplay[decIdx]<0)))
     672
     673#if NH_MV
     674      if ( pcPicTop->getOutputMark() && pcPicBottom->getOutputMark() &&
     675        (numPicsNotYetDisplayed >  numReorderPicsHighestTid || dpbFullness > maxDecPicBufferingHighestTid) &&
     676        (!(pcPicTop->getPOC()%2) && pcPicBottom->getPOC() == pcPicTop->getPOC()+1) &&
     677        (pcPicTop->getPOC() == m_pocLastDisplay[decIdx]+1 || m_pocLastDisplay[decIdx] < 0))
    639678#else
    640679      if ( pcPicTop->getOutputMark() && pcPicBottom->getOutputMark() &&
     
    646685        // write to file
    647686        numPicsNotYetDisplayed = numPicsNotYetDisplayed-2;
    648 #if H_MV
     687#if NH_MV
    649688      if ( m_pchReconFiles[decIdx] )
    650689#else
     
    653692        {
    654693          const Window &conf = pcPicTop->getConformanceWindow();
    655           const Window &defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window();
    656 
     694          const Window  defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window();
    657695          const Bool isTff = pcPicTop->isTopField();
    658 #if H_MV
     696
     697          Bool display = true;
     698          if( m_decodedNoDisplaySEIEnabled )
     699          {
     700            SEIMessages noDisplay = getSeisByType(pcPic->getSEIs(), SEI::NO_DISPLAY );
     701            const SEINoDisplay *nd = ( noDisplay.size() > 0 ) ? (SEINoDisplay*) *(noDisplay.begin()) : NULL;
     702            if( (nd != NULL) && nd->m_noDisplay )
     703            {
     704              display = false;
     705            }
     706          }
     707
     708          if (display)
     709          {
     710#if NH_MV
    659711        assert( conf   .getScaledFlag() );
    660712        assert( defDisp.getScaledFlag() );
     
    667719        m_tVideoIOYuvReconFile[decIdx]->write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
    668720#else
    669           m_cTVideoIOYuvReconFile.write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
    670 #endif
    671                                         conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
    672                                         conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
    673                                         conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
    674                                         conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), isTff );
    675         }
    676        
     721        m_cTVideoIOYuvReconFile.write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
     722#endif
     723                                           m_outputColourSpaceConvert,
     724                                           conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     725                                           conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
     726                                           conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
     727#if NH_3D
     728                                           conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), m_depth420OutputFlag && pcPicTop->getIsDepth() ? CHROMA_420 : NUM_CHROMA_FORMAT, isTff );
     729#else
     730                                           conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), NUM_CHROMA_FORMAT, isTff );
     731#endif
     732          }
     733        }
     734
    677735        // update POC of display order
    678 #if H_MV
     736#if NH_MV
    679737        m_pocLastDisplay[decIdx] = pcPic->getPOC();
    680738#else
    681739        m_iPOCLastDisplay = pcPicBottom->getPOC();
    682740#endif
    683        
     741
    684742        // erase non-referenced picture in the reference picture list after display
    685743        if ( !pcPicTop->getSlice(0)->isReferenced() && pcPicTop->getReconMark() == true )
    686744        {
    687 #if !DYN_REF_FREE
    688745          pcPicTop->setReconMark(false);
    689          
     746
    690747          // mark it should be extended later
    691748          pcPicTop->getPicYuvRec()->setBorderExtension( false );
    692          
    693 #else
    694           pcPicTop->destroy();
    695           pcListPic->erase( iterPic );
    696           iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
    697           continue;
    698 #endif
    699749        }
    700750        if ( !pcPicBottom->getSlice(0)->isReferenced() && pcPicBottom->getReconMark() == true )
    701751        {
    702 #if !DYN_REF_FREE
    703752          pcPicBottom->setReconMark(false);
    704          
     753
    705754          // mark it should be extended later
    706755          pcPicBottom->getPicYuvRec()->setBorderExtension( false );
    707          
    708 #else
    709           pcPicBottom->destroy();
    710           pcListPic->erase( iterPic );
    711           iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
    712           continue;
    713 #endif
    714756        }
    715757        pcPicTop->setOutputMark(false);
     
    721763  {
    722764    iterPic = pcListPic->begin();
     765
    723766    while (iterPic != pcListPic->end())
    724767    {
    725768      pcPic = *(iterPic);
    726769
    727 #if H_MV
     770#if NH_MV
    728771      if(pcPic->getOutputMark() && pcPic->getPOC() > m_pocLastDisplay[decIdx] &&
    729772        (numPicsNotYetDisplayed >  numReorderPicsHighestTid || dpbFullness > maxDecPicBufferingHighestTid))
     
    734777      {
    735778        // write to file
    736         numPicsNotYetDisplayed--;
     779         numPicsNotYetDisplayed--;
    737780        if(pcPic->getSlice(0)->isReferenced() == false)
    738781        {
    739782          dpbFullness--;
    740783        }
    741 #if H_MV
     784#if NH_MV
    742785      if ( m_pchReconFiles[decIdx] )
    743786#else
     
    745788#endif
    746789        {
    747           const Window &conf = pcPic->getConformanceWindow();
    748           const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
    749 #if H_MV
     790          const Window &conf    = pcPic->getConformanceWindow();
     791          const Window defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
     792#if NH_MV
    750793        assert( conf   .getScaledFlag() );
    751794        assert( defDisp.getScaledFlag() );
     
    760803          m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
    761804#endif
    762                                         conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
    763                                         conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
    764                                         conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
    765                                         conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
    766         }
    767        
     805                                         m_outputColourSpaceConvert,
     806                                         conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     807                                         conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
     808                                         conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
     809                                         conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(),
     810#if NH_3D
     811                                          m_depth420OutputFlag && pcPic->getIsDepth() ? CHROMA_420 : NUM_CHROMA_FORMAT,
     812#else
     813                                          NUM_CHROMA_FORMAT,
     814#endif
     815           m_bClipOutputVideoToRec709Range   );
     816        }
     817
    768818        // update POC of display order
    769 #if H_MV
     819#if NH_MV
    770820        m_pocLastDisplay[decIdx] = pcPic->getPOC();
    771821#else
    772822        m_iPOCLastDisplay = pcPic->getPOC();
    773823#endif
    774        
     824
    775825        // erase non-referenced picture in the reference picture list after display
    776826        if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
    777827        {
    778 #if !DYN_REF_FREE
    779828          pcPic->setReconMark(false);
    780          
     829
    781830          // mark it should be extended later
    782831          pcPic->getPicYuvRec()->setBorderExtension( false );
    783          
    784 #else
    785           pcPic->destroy();
    786           pcListPic->erase( iterPic );
    787           iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
    788           continue;
    789 #endif
    790832        }
    791833        pcPic->setOutputMark(false);
    792 #if H_MV
     834#if NH_MV
    793835        pcPic->setPicOutputFlag(false);
    794836#endif
    795837      }
    796      
     838
    797839      iterPic++;
    798840    }
    799841  }
    800842}
     843
    801844/** \param pcListPic list of pictures to be written to file
    802     \todo            DYN_REF_FREE should be revised
    803845 */
    804 #if H_MV
     846#if NH_MV
    805847Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic, Int decIdx )
    806848#else
     
    813855  }
    814856  TComList<TComPic*>::iterator iterPic   = pcListPic->begin();
    815  
     857
    816858  iterPic   = pcListPic->begin();
    817859  TComPic* pcPic = *(iterPic);
    818  
     860
    819861  if (pcPic->isField()) //Field Decoding
    820862  {
     
    827869      iterPic++;
    828870      pcPicBottom = *(iterPic);
    829      
     871
    830872      if ( pcPicTop->getOutputMark() && pcPicBottom->getOutputMark() && !(pcPicTop->getPOC()%2) && (pcPicBottom->getPOC() == pcPicTop->getPOC()+1) )
    831873      {
    832874        // write to file
    833 #if H_MV
     875#if NH_MV
    834876      if ( m_pchReconFiles[decIdx] )
    835877#else
     
    838880        {
    839881          const Window &conf = pcPicTop->getConformanceWindow();
    840           const Window &defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window();
     882          const Window  defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window();
    841883          const Bool isTff = pcPicTop->isTopField();
    842 #if H_MV
     884#if NH_MV
    843885        assert( conf   .getScaledFlag() );
    844886        assert( defDisp.getScaledFlag() );
     
    853895          m_cTVideoIOYuvReconFile.write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
    854896#endif
    855                                         conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
    856                                         conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
    857                                         conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
    858                                         conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), isTff );
    859         }
    860        
     897                                         m_outputColourSpaceConvert,
     898                                         conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     899                                         conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
     900                                         conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
     901#if NH_3D
     902                                         conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), m_depth420OutputFlag && pcPicTop->getIsDepth() ? CHROMA_420 : NUM_CHROMA_FORMAT, isTff );
     903#else
     904                                         conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), NUM_CHROMA_FORMAT, isTff );
     905#endif
     906        }
     907
    861908        // update POC of display order
    862 #if H_MV
     909#if NH_MV
    863910      m_pocLastDisplay[decIdx] = pcPic->getPOC();
    864911#else
    865       m_iPOCLastDisplay = pcPicBottom->getPOC();
     912        m_iPOCLastDisplay = pcPicBottom->getPOC();
    866913#endif       
    867914        // erase non-referenced picture in the reference picture list after display
    868915        if ( !pcPicTop->getSlice(0)->isReferenced() && pcPicTop->getReconMark() == true )
    869916        {
    870 #if !DYN_REF_FREE
    871917          pcPicTop->setReconMark(false);
    872          
     918
    873919          // mark it should be extended later
    874920          pcPicTop->getPicYuvRec()->setBorderExtension( false );
    875          
    876 #else
    877           pcPicTop->destroy();
    878           pcListPic->erase( iterPic );
    879           iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
    880           continue;
    881 #endif
    882921        }
    883922        if ( !pcPicBottom->getSlice(0)->isReferenced() && pcPicBottom->getReconMark() == true )
    884923        {
    885 #if !DYN_REF_FREE
    886924          pcPicBottom->setReconMark(false);
    887          
     925
    888926          // mark it should be extended later
    889927          pcPicBottom->getPicYuvRec()->setBorderExtension( false );
    890          
    891 #else
    892           pcPicBottom->destroy();
    893           pcListPic->erase( iterPic );
    894           iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
    895           continue;
    896 #endif
    897928        }
    898929        pcPicTop->setOutputMark(false);
    899930        pcPicBottom->setOutputMark(false);
    900        
    901 #if !DYN_REF_FREE
     931
    902932        if(pcPicTop)
    903933        {
     
    906936          pcPicTop = NULL;
    907937        }
    908 #endif
    909938      }
    910939    }
     
    921950    {
    922951      pcPic = *(iterPic);
    923      
     952
    924953      if ( pcPic->getOutputMark() )
    925954      {
    926955        // write to file
    927 #if H_MV
     956#if NH_MV
    928957      if ( m_pchReconFiles[decIdx] )
    929958#else
     
    931960#endif
    932961        {
    933           const Window &conf = pcPic->getConformanceWindow();
    934           const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
    935 #if H_MV
     962          const Window &conf    = pcPic->getConformanceWindow();
     963          const Window  defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
     964#if NH_MV
    936965        assert( conf   .getScaledFlag() );
    937966        assert( defDisp.getScaledFlag() );
     
    946975          m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
    947976#endif
    948                                         conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
    949                                         conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
    950                                         conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
    951                                         conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
    952         }
    953        
     977                                         m_outputColourSpaceConvert,
     978                                         conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     979                                         conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
     980                                         conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
     981                                         conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(),
     982#if NH_3D
     983                                         m_depth420OutputFlag && pcPic->getIsDepth() ? CHROMA_420 : NUM_CHROMA_FORMAT
     984#else
     985                                         NUM_CHROMA_FORMAT
     986#endif
     987                                         , m_bClipOutputVideoToRec709Range);
     988        }
     989
    954990        // update POC of display order
    955 #if H_MV
     991#if NH_MV
    956992      m_pocLastDisplay[decIdx] = pcPic->getPOC();
    957993#else
    958994        m_iPOCLastDisplay = pcPic->getPOC();
    959995#endif
    960        
     996
    961997        // erase non-referenced picture in the reference picture list after display
    962998        if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
    963999        {
    964 #if !DYN_REF_FREE
    9651000          pcPic->setReconMark(false);
    966          
     1001
    9671002          // mark it should be extended later
    9681003          pcPic->getPicYuvRec()->setBorderExtension( false );
    969          
    970 #else
    971           pcPic->destroy();
    972           pcListPic->erase( iterPic );
    973           iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
    974           continue;
    975 #endif
    9761004        }
    9771005        pcPic->setOutputMark(false);
    978 #if H_MV
     1006#if NH_MV
    9791007        pcPic->setPicOutputFlag(false);
    9801008#endif
    9811009      }
    982 #if !H_MV
    983 #if !DYN_REF_FREE
    984       if(pcPic)
     1010#if !NH_MV
     1011      if(pcPic != NULL)
    9851012      {
    9861013        pcPic->destroy();
     
    9881015        pcPic = NULL;
    9891016      }
    990 #endif   
    9911017#endif
    9921018      iterPic++;
    9931019    }
    9941020  }
    995 #if H_MV
     1021#if NH_MV
    9961022  m_pocLastDisplay[decIdx] = -MAX_INT;
    9971023#else
     
    10111037  for (std::vector<Int>::iterator it = m_targetDecLayerIdSet.begin(); it != m_targetDecLayerIdSet.end(); it++)
    10121038  {
    1013 #if H_MV
    1014     if ( nalu->m_layerId == (*it) )
    1015 #else
    1016     if ( nalu->m_reservedZero6Bits == (*it) )
     1039#if NH_MV
     1040    if ( nalu->m_nuhLayerId == (*it) )
     1041#else
     1042    if ( nalu->m_nuhLayerId == (*it) )
    10171043#endif
    10181044    {
     
    10231049}
    10241050
    1025 #if H_MV
     1051#if NH_MV
    10261052Int TAppDecTop::xGetDecoderIdx( Int layerId, Bool createFlag /*= false */ )
    10271053{
     
    10521078    m_tDecTop[ decIdx ]->setIvPicLists( &m_ivPicLists );
    10531079    m_tDecTop[ decIdx ]->setLayerInitilizedFlags( m_layerInitilizedFlags );
    1054     m_tDecTop[ decIdx ]->setTargetOptLayerSetIdx( m_targetOptLayerSetIdx );   
    1055 #if H_3D
    1056     m_tDecTop[ decIdx ]->setProfileIdc           ( );   
    1057 #endif
    1058 
    1059 #if H_3D
     1080    m_tDecTop[ decIdx ]->setTargetOlsIdx( m_targetOptLayerSetIdx );   
     1081#if O0043_BEST_EFFORT_DECODING
     1082    m_cTDecTop[ decIdx ]->setForceDecodeBitDepth(m_forceDecodeBitDepth);
     1083#endif
     1084    if (!m_outputDecodedSEIMessagesFilename.empty())
     1085    {
     1086      std::ostream &os=m_seiMessageFileStream.is_open() ? m_seiMessageFileStream : std::cout;
     1087      m_tDecTop[ decIdx ]->setDecodedSEIMessageOutputStream(&os);
     1088    }
     1089#if NH_3D
    10601090   m_tDecTop[ decIdx ]->setCamParsCollector( &m_cCamParsCollector );
    10611091#endif
  • branches/HTM-14.1-update-dev0/source/App/TAppDecoder/TAppDecTop.h

    r1179 r1200  
    22 * License, included below. This software may be subject to other third party
    33 * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license. 
     4 * granted under this license.
    55 *
    6 * Copyright (c) 2010-2015, ITU/ISO/IEC
     6 * Copyright (c) 2010-2015, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    6161private:
    6262  // class interface
    63 #if H_MV
     63#if NH_MV
    6464  TDecTop*                        m_tDecTop             [ MAX_NUM_LAYERS ];    ///< decoder classes
    6565  TVideoIOYuv*                    m_tVideoIOYuvReconFile[ MAX_NUM_LAYERS ];    ///< reconstruction YUV class
     
    6868  TComPicLists                    m_ivPicLists;                                ///< picture buffers of decoder instances
    6969  Bool                            m_layerInitilizedFlags[ MAX_NUM_LAYER_IDS ]; ///< for layerwise startup
    70   TComVPS*                        m_vps;                                ///< active VPS
     70  const TComVPS*                  m_vps;                                ///< active VPS
    7171#else
    7272  TDecTop                         m_cTDecTop;                     ///< decoder class
    7373  TVideoIOYuv                     m_cTVideoIOYuvReconFile;        ///< reconstruction YUV class
    7474#endif
    75     // for output control
    76 #if H_MV
     75  // for output control
     76#if NH_MV
    7777  Int                             m_pocLastDisplay      [ MAX_NUM_LAYERS ]; ///< last POC in display order
    7878  Bool                            m_reconOpen           [ MAX_NUM_LAYERS ]; ///< reconstruction file opened
     
    8181  Int                             m_iPOCLastDisplay;              ///< last POC in display order
    8282#endif
     83  std::ofstream                   m_seiMessageFileStream;         ///< Used for outputing SEI messages.
    8384
    84 #if H_3D
     85#if NH_3D
    8586  FILE*                           m_pScaleOffsetFile;
    8687  CamParsCollector                m_cCamParsCollector;
     
    8990  TAppDecTop();
    9091  virtual ~TAppDecTop() {}
    91  
     92
    9293  Void  create            (); ///< create internal members
    9394  Void  destroy           (); ///< destroy internal members
    9495  Void  decode            (); ///< main decoding function
     96#if NH_MV
     97  UInt  getNumberOfChecksumErrorsDetected( ) const
     98  {
     99    UInt numOfChecksumErrors = 0;
     100    for (Int i = 0; i < m_numDecoders; i++ )
     101    {
     102      numOfChecksumErrors += getNumberOfChecksumErrorsDetected( i );
     103    }
     104    return numOfChecksumErrors;
     105  }
     106
     107  UInt  getNumberOfChecksumErrorsDetected( Int decIdx ) const { return m_tDecTop[decIdx]->getNumberOfChecksumErrorsDetected(); }
     108
     109#else
     110  UInt  getNumberOfChecksumErrorsDetected() const { return m_cTDecTop.getNumberOfChecksumErrorsDetected(); }
     111#endif
    95112
    96113protected:
     
    99116  Void  xInitDecLib       (); ///< initialize decoder class
    100117
    101 #if H_MV
     118#if NH_MV
    102119  Void  xWriteOutput      ( TComList<TComPic*>* pcListPic, Int layerId, Int tId ); ///< write YUV to file
    103120
  • branches/HTM-14.1-update-dev0/source/App/TAppDecoder/decmain.cpp

    r1179 r1200  
    22 * License, included below. This software may be subject to other third party
    33 * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license. 
     4 * granted under this license.
    55 *
    6 * Copyright (c) 2010-2015, ITU/ISO/IEC
     6 * Copyright (c) 2010-2015, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    4444//! \{
    4545
    46 bool g_md5_mismatch = false; ///< top level flag that indicates if there has been a decoding mismatch
    47 
    4846// ====================================================================================================================
    4947// Main function
     
    5250int main(int argc, char* argv[])
    5351{
     52  Int returnCode = EXIT_SUCCESS;
    5453  TAppDecTop  cTAppDecTop;
    5554
    5655  // print information
    5756  fprintf( stdout, "\n" );
    58 #if H_MV
     57#if NH_MV
    5958  fprintf( stdout, "3D-HTM Software: Decoder Version [%s] based on HM Version [%s]", NV_VERSION, HM_VERSION ); 
    6059#else
    61   fprintf( stdout, "HM software: Decoder Version [%s]", NV_VERSION );
     60  fprintf( stdout, "HM software: Decoder Version [%s] (including RExt)", NV_VERSION );
    6261#endif
    6362  fprintf( stdout, NVM_ONOS );
     
    7372  {
    7473    cTAppDecTop.destroy();
    75     return 1;
     74    returnCode = EXIT_FAILURE;
     75    return returnCode;
    7676  }
    7777
    7878  // starting time
    79   double dResult;
    80   long lBefore = clock();
     79  Double dResult;
     80  clock_t lBefore = clock();
    8181
    8282  // call decoding function
    8383  cTAppDecTop.decode();
    8484
    85   if (g_md5_mismatch)
     85  if (cTAppDecTop.getNumberOfChecksumErrorsDetected() != 0)
    8686  {
    8787    printf("\n\n***ERROR*** A decoding mismatch occured: signalled md5sum does not match\n");
     88    returnCode = EXIT_FAILURE;
    8889  }
    8990
    9091  // ending time
    91   dResult = (double)(clock()-lBefore) / CLOCKS_PER_SEC;
     92  dResult = (Double)(clock()-lBefore) / CLOCKS_PER_SEC;
    9293  printf("\n Total Time: %12.3f sec.\n", dResult);
    9394
     
    9596  cTAppDecTop.destroy();
    9697
    97   return g_md5_mismatch ? EXIT_FAILURE : EXIT_SUCCESS;
     98  return returnCode;
    9899}
    99100
Note: See TracChangeset for help on using the changeset viewer.