Changeset 1317 in 3DVCSoftware for branches


Ignore:
Timestamp:
4 Sep 2015, 21:28:58 (9 years ago)
Author:
tech
Message:

Clean-ups. HLS.

Location:
branches/HTM-15.0-dev0/source
Files:
47 edited

Legend:

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

    r1313 r1317  
    102102  ("RespectDefDispWindow,w",    m_respectDefDispWindow,                0,          "Only output content inside the default display window\n")
    103103#if NH_MV
    104   ("OutputVpsInfo,v",           m_outputVpsInfo,                       false,       "Output information about the layer dependencies and layer sets")
     104  ("OutputVpsInfo,v",           m_printVpsInfo,                       false,       "Output information about the layer dependencies and layer sets")
     105  ("PrintPicOutput,c" ,         m_printPicOutput,                     false,         "Print information on picture output")
     106  ("PrintNalus,n",              m_printReceivedNalus,                 false,        "Print information on received NAL units")
    105107#endif
    106108#if O0043_BEST_EFFORT_DECODING
  • branches/HTM-15.0-dev0/source/App/TAppDecoder/TAppDecCfg.h

    r1313 r1317  
    4545#include "TLibCommon/CommonDef.h"
    4646#include <vector>
     47#if NH_MV
     48#include <fstream>
     49#endif
    4750
    4851//! \ingroup TAppDecoder
     
    5861protected:
    5962  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
    64 #endif
    6563  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
    69 #endif
    7064  Int           m_iSkipFrame;                           ///< counter for frames prior to the random access point to skip
    7165  Int           m_outputBitDepth[MAX_NUM_CHANNEL_TYPE]; ///< bit depth used for writing output
     
    7670  Bool          m_decodedNoDisplaySEIEnabled;         ///< Enable(true)/disable(false) writing only pictures that get displayed based on the no display SEI message
    7771  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
    8172
    8273  Int           m_respectDefDispWindow;               ///< Only output content inside the default display window
     
    8778  Bool          m_bClipOutputVideoToRec709Range;      ///< If true, clip the output video to the Rec 709 range on saving.
    8879#if NH_MV
    89   Bool          m_outputVpsInfo;                     ///< Output VPS information
     80  std::vector<Char*> m_pchReconFiles;                   ///< array of output reconstruction file name create from output reconstruction file name
     81
     82  Int           m_targetOptLayerSetIdx;                 ///< target output layer set index
     83  Int           m_targetDecLayerSetIdx;
     84  Int           m_baseLayerOutputFlag;
     85  Int           m_baseLayerPicOutputFlag;
     86  Int           m_auOutputFlag;
     87  Int           m_maxLayerId;                           ///< maximum nuh_layer_id decoded
     88  std::ifstream m_bitstreamFile;
     89  Bool          m_targetDecLayerIdSetFileEmpty;       ///< indication if target layers are given by file
     90  Int           m_highestTid;
     91
     92  Bool          m_printVpsInfo;                      ///< Output VPS information
     93  Bool          m_printPicOutput;                     ///< Print information on picture output
     94  Bool          m_printReceivedNalus;                 ///< Print information on received NAL units
     95#if NH_3D
     96  Char*         m_pchScaleOffsetFile;                   ///< output coded scale and offset parameters
     97  Bool          m_depth420OutputFlag;                   ///< output depth layers in 4:2:0
     98#endif
     99
    90100  Void xAppendToFileNameEnd( Char* pchInputFileName, const Char* pchStringToAppend, Char*& rpchOutputFileName); ///< create filenames
    91101#endif
     
    100110  , m_decodedPictureHashSEIEnabled(0)
    101111  , m_decodedNoDisplaySEIEnabled(false)
    102 #if NH_MV
    103   , m_targetDecLayerIdSetFileEmpty(true)
    104 #endif
    105112  , m_respectDefDispWindow(0)
    106113#if O0043_BEST_EFFORT_DECODING
    107114  , m_forceDecodeBitDepth(0)
    108115#endif
     116#if NH_MV
     117  , m_highestTid(-1)
     118  , m_targetDecLayerIdSetFileEmpty(true)
     119#endif
     120
    109121  {
    110122    for (UInt channelTypeIndex = 0; channelTypeIndex < MAX_NUM_CHANNEL_TYPE; channelTypeIndex++)
  • branches/HTM-15.0-dev0/source/App/TAppDecoder/TAppDecTop.cpp

    r1313 r1317  
    6464{
    6565#if NH_MV
    66   for (Int i = 0; i < MAX_NUM_LAYER_IDS; i++)
    67   {
    68     m_layerIdToDecIdx[i] = -1;
    69     m_layerInitilizedFlags[i] = false;
    70   }
     66  for (Int i = 0; i < MAX_NUM_LAYER_IDS; i++)
     67  {
     68    m_layerIdToDecIdx                     [i] = -1;
     69    m_layerInitilizedFlag                 [i] = false;
     70    m_eosInLayer                          [i] = false;
     71    m_firstPicInLayerDecodedFlag          [i] = false;
     72    m_pocDecrementedInDpbFlag             [i] = false;
     73    m_decodingOrder                       [i] = 0;
     74    m_lastPresentPocResetIdc              [i] = MIN_INT;
     75    m_firstPicInPocResettingPeriodReceived[i] = true;
     76    m_noRaslOutputFlagAssocIrap           [i] = false;
     77  }
     78
     79  m_curPic                          = NULL;
     80  m_vps                             = NULL;
     81  m_sps                             = NULL;
     82  m_pps                             = NULL;
     83  m_initilizedFromVPS               = false;
     84  m_firstSliceInBitstream           = true;
     85  m_newVpsActivatedbyCurAu          = false;
     86  m_newVpsActivatedbyCurPic         = false;
     87  m_handleCraAsBlaFlag              = false;
     88  m_handleCraAsBlaFlagSetByExtMeans = false;
     89  m_noClrasOutputFlag               = false;
     90  m_noClrasOutputFlagSetByExtMeans  = false;
     91  m_layerResetFlag                  = false;
     92  m_totalNumofPicsReceived          = 0;
     93  m_cvsStartFound                   = false;
    7194#endif
    7295#if NH_3D
    73     m_pScaleOffsetFile  = 0;
     96    m_pScaleOffsetFile              = 0;
    7497#endif
    75 
     98}
     99
     100Void TAppDecTop::create()
     101{
    76102#if NH_MV
    77     m_markedForOutput = false;
     103#if ENC_DEC_TRACE
     104  if ( g_hTrace == NULL )
     105  {
     106    g_hTrace = fopen( "TraceDec.txt", "wb" );
     107    g_bJustDoIt = g_bEncDecTraceDisable;
     108    g_nSymbolCounter = 0;
     109  }
    78110#endif
    79 
    80 }
    81 
    82 Void TAppDecTop::create()
    83 {
     111#endif
    84112}
    85113
     
    115143  {
    116144    free (m_pchScaleOffsetFile);
    117     m_pchScaleOffsetFile = NULL; 
     145    m_pchScaleOffsetFile = NULL;
    118146  }
    119147#endif
     
    132160 .
    133161 */
     162
     163#if NH_MV
    134164Void TAppDecTop::decode()
    135165{
     166  // create & initialize internal classes
     167  xInitFileIO  ();
     168  xCreateDecLib();
     169  xInitDecLib  ();
     170
     171  InputByteStream bytestream(m_bitstreamFile);
     172
     173  while ( m_bitstreamFile )
     174  {
     175    AnnexBStats stats = AnnexBStats();
     176    InputNALUnit nalu;
     177
     178    byteStreamNALUnit(bytestream, nalu.getBitstream().getFifo(), stats);
     179
     180    if (nalu.getBitstream().getFifo().empty())
     181    {
     182      /* this can happen if the following occur:
     183       *  - empty input file
     184       *  - two back-to-back start_code_prefixes
     185       *  - start_code_prefix immediately followed by EOF
     186       */
     187      fprintf(stderr, "Warning: Attempt to decode an empty NAL unit\n");
     188    }
     189    else
     190    {
     191      read(nalu);
     192
     193      if ( m_printReceivedNalus )
     194      {
     195        std::cout << "Received NAL unit: ";
     196        nalu.print();
     197        std::cout << std::endl;
     198      }
     199
     200      if ( xExtractAndRewrite( &nalu )
     201          && nalu.m_nuhLayerId <= MAX_NUM_LAYER_IDS-1
     202          && !(nalu.m_nalUnitType == NAL_UNIT_VPS && nalu.m_nuhLayerId > 0)
     203          && !(nalu.m_nalUnitType == NAL_UNIT_EOB && nalu.m_nuhLayerId > 0)
     204         )
     205      {
     206        xGetDecoderIdx( nalu.m_nuhLayerId , true );
     207        if( nalu.isSlice() )
     208        {
     209          xProcessVclNalu   ( nalu );
     210        }
     211        else
     212        {
     213          xProcessNonVclNalu( nalu );
     214        }
     215      }
     216    }
     217  }
     218 xTerminateDecoding();
     219}
     220#endif
     221
     222#if !NH_MV
     223Void TAppDecTop::decode()
     224{
    136225  Int                 poc;
    137 #if NH_MV
    138   poc = -1;
    139 #endif
    140226  TComList<TComPic*>* pcListPic = NULL;
    141227
     
    146232    exit(EXIT_FAILURE);
    147233  }
    148 #if NH_3D
    149   if( m_pchScaleOffsetFile )
    150   {
    151     m_pScaleOffsetFile = ::fopen( m_pchScaleOffsetFile, "wt" );
    152     AOF( m_pScaleOffsetFile );
    153   }
    154 #endif
    155234
    156235  InputByteStream bytestream(bitstreamFile);
     
    169248  xCreateDecLib();
    170249  xInitDecLib  ();
    171 #if !NH_MV
     250
    172251  m_iPOCLastDisplay += m_iSkipFrame;      // set the last displayed POC correctly for skip forward.
    173252
    174253  // main decoder loop
    175254  Bool openedReconFile = false; // reconstruction file not yet opened. (must be performed after SPS is seen)
    176 #else
    177 
    178   Int  pocCurrPic        = -MAX_INT;     
    179   Int  pocLastPic        = -MAX_INT;   
    180 
    181   Int  layerIdLastPic    = -MAX_INT;
    182   Int  layerIdCurrPic    = 0;
    183 
    184   Int  decIdxLastPic     = 0;
    185   Int  decIdxCurrPic     = 0;
    186 
    187   Bool firstSlice        = true;
    188 #endif
    189255  Bool loopFiltered = false;
    190256
     
    201267    streampos location = bitstreamFile.tellg();
    202268#endif
    203 #if NH_MV
    204 #if ENC_DEC_TRACE
    205     Int64 symCount = g_nSymbolCounter;
    206 #endif
    207 #endif
    208269    AnnexBStats stats = AnnexBStats();
    209270
     
    213274    // call actual decoding function
    214275    Bool bNewPicture = false;
    215 #if NH_MV
    216     Bool newSliceDiffPoc   = false;
    217     Bool newSliceDiffLayer = false;
    218     Bool sliceSkippedFlag  = false;
    219     Bool allLayersDecoded  = false;     
    220 #endif
    221276    if (nalu.getBitstream().getFifo().empty())
    222277    {
     
    231286    {
    232287      read(nalu);
    233 #if NH_MV     
    234       if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer)
    235           || !isNaluWithinTargetDecLayerIdSet(&nalu)
    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)             
    239          )
     288
     289      if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu)  )
    240290      {
    241291        bNewPicture = false;
    242         if ( !bitstreamFile )
    243         {
    244           decIdxLastPic     = decIdxCurrPic;
    245         }
    246292      }
    247293      else
    248       {
    249         Int decIdx     = xGetDecoderIdx( nalu.m_nuhLayerId , true );     
    250         newSliceDiffLayer = nalu.isSlice() && ( nalu.m_nuhLayerId != layerIdCurrPic ) && !firstSlice;
    251         newSliceDiffPoc   = m_tDecTop[decIdx]->decode(nalu, m_iSkipFrame, m_pocLastDisplay[decIdx], newSliceDiffLayer, sliceSkippedFlag );
    252         // decode function only returns true when all of the following conditions are true
    253         // - poc in particular layer changes
    254         // - nalu does not belong to first slice in layer
    255         // - nalu.isSlice() == true     
    256 
    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( );
    267           if ( m_targetDecLayerIdSetFileEmpty )
    268           {           
    269             if ( m_targetOptLayerSetIdx == -1 )
    270             {
    271               m_targetOptLayerSetIdx = m_tDecTop[decIdx]->getTargetOlsIdx();
    272             }
    273             else
    274             {
    275               assert( m_tDecTop[decIdx]->getTargetOlsIdx() == m_targetOptLayerSetIdx );
    276             }
    277 
    278             if ( m_targetOptLayerSetIdx < 0 || m_targetOptLayerSetIdx >= m_vps->getNumOutputLayerSets() )
    279             {
    280               fprintf(stderr, "\ntarget output layer set index must be in the range of 0 to %d, inclusive \n", m_vps->getNumOutputLayerSets() - 1 );           
    281               exit(EXIT_FAILURE);
    282             }
    283             m_targetDecLayerIdSet = m_vps->getTargetDecLayerIdList( m_targetOptLayerSetIdx );
    284           }
    285 
    286           if (m_outputVpsInfo )
    287           {
    288             m_vps->printScalabilityId();
    289             m_vps->printLayerDependencies();
    290             m_vps->printLayerSets();
    291             m_vps->printPTL();
    292           }
    293         }       
    294 
    295         if ( bNewPicture || !bitstreamFile || nalu.m_nalUnitType == NAL_UNIT_EOS )
    296         {
    297           layerIdLastPic    = layerIdCurrPic;
    298           layerIdCurrPic    = nalu.m_nuhLayerId;
    299           pocLastPic        = pocCurrPic;
    300           pocCurrPic        = m_tDecTop[decIdx]->getCurrPoc();
    301           decIdxLastPic     = decIdxCurrPic;
    302           decIdxCurrPic     = decIdx;
    303           allLayersDecoded = ( pocCurrPic != pocLastPic ) && ( nalu.m_nalUnitType != NAL_UNIT_EOS );
    304         }
    305 #else
    306       if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu)  )
    307       {
    308         bNewPicture = false;
    309       }
    310       else
    311294      {
    312295        bNewPicture = m_cTDecTop.decode(nalu, m_iSkipFrame, m_iPOCLastDisplay);
    313 #endif
    314296        if (bNewPicture)
    315297        {
     
    327309          bytestream.reset();
    328310#endif
    329 #if H_MV_ENC_DEC_TRAC
    330 #if ENC_DEC_TRACE
    331           const Bool resetCounter = false;
    332           if ( resetCounter )
    333           {
    334             g_nSymbolCounter  = symCount; // Only reset counter SH becomes traced twice
    335           }
    336           else
    337           {
    338             g_disableHLSTrace = true;     // Tracing of second parsing of SH is not carried out
    339           }     
    340 #endif
    341 #endif
    342311        }
    343312      }
     
    345314
    346315    if ( (bNewPicture || !bitstreamFile || nalu.m_nalUnitType == NAL_UNIT_EOS) &&
    347 #if NH_MV     
    348       !m_tDecTop[decIdxLastPic]->getFirstSliceInSequence () )
    349 #else
     316
    350317      !m_cTDecTop.getFirstSliceInSequence () )
    351 #endif
    352318
    353319    {
    354320      if (!loopFiltered || bitstreamFile)
    355321      {
    356 #if NH_MV
    357         assert( decIdxLastPic != -1 );
    358         m_tDecTop[decIdxLastPic]->endPicDecoding(poc, pcListPic, m_targetDecLayerIdSet );
    359         xMarkForOutput( allLayersDecoded, poc, layerIdLastPic );
    360 #else
    361322        m_cTDecTop.executeLoopFilters(poc, pcListPic);
    362 #endif
    363323      }
    364324      loopFiltered = (nalu.m_nalUnitType == NAL_UNIT_EOS);
    365325      if (nalu.m_nalUnitType == NAL_UNIT_EOS)
    366326      {
    367 #if NH_MV     
    368         m_tDecTop[decIdxLastPic]->setFirstSliceInSequence(true);
    369 #else
    370327        m_cTDecTop.setFirstSliceInSequence(true);
    371 #endif
    372328      }
    373329    }
    374330    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
     331              m_cTDecTop.getFirstSliceInSequence () )
     332    {
    384333      m_cTDecTop.setFirstSliceInPicture (true);
    385 #endif
    386     }
    387 
    388 #if NH_3D
    389     if ( allLayersDecoded || !bitstreamFile )
    390     {
    391       for( Int dI = 0; dI < m_numDecoders; dI++ )
    392       {
    393         TComPic* picLastCoded = m_ivPicLists.getPic( m_tDecTop[dI]->getLayerId(), pocLastPic );
    394         assert( picLastCoded != NULL );       
    395         picLastCoded->compressMotion(1);
    396       }
    397     }
    398 #endif
     334   }
    399335
    400336    if( pcListPic )
    401337    {
    402 #if NH_MV
    403       if ( m_pchReconFiles[decIdxLastPic] && !m_reconOpen[decIdxLastPic] )
    404 #else
    405338      if ( m_pchReconFile && !openedReconFile )
    406 #endif
    407339      {
    408340        const BitDepths &bitDepths=pcListPic->front()->getPicSym()->getSPS().getBitDepths(); // use bit depths of first reconstructed picture.
     
    414346          }
    415347        }
    416 #if NH_MV
    417         m_tVideoIOYuvReconFile[decIdxLastPic]->open( m_pchReconFiles[decIdxLastPic], true, m_outputBitDepth, m_outputBitDepth, bitDepths.recon ); // write mode
    418         m_reconOpen[decIdxLastPic] = true;
     348        m_cTVideoIOYuvReconFile.open( m_pchReconFile, true, m_outputBitDepth, m_outputBitDepth, bitDepths.recon ); // write mode
     349        openedReconFile = true;
    419350      }
    420351      // write reconstruction to file
    421352      if( bNewPicture )
    422353      {
    423         // Bumping after picture has been decoded
    424 #if ENC_DEC_TRACE
    425         g_bJustDoIt = true; 
    426         writeToTraceFile( "Bumping after decoding \n", g_decTracePicOutput  );         
    427         g_bJustDoIt = false; 
    428 #endif
    429         xWriteOutput( pcListPic, decIdxLastPic, nalu.m_temporalId );
    430       }
    431       if ( (bNewPicture || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_CRA) && m_tDecTop[decIdxLastPic]->getNoOutputPriorPicsFlag() )
    432       {
    433         m_tDecTop[decIdxLastPic]->checkNoOutputPriorPics( pcListPic );
    434         m_tDecTop[decIdxLastPic]->setNoOutputPriorPicsFlag (false);
    435       }
    436 
    437       if ( bNewPicture && newSliceDiffPoc &&
    438 #else
    439         m_cTVideoIOYuvReconFile.open( m_pchReconFile, true, m_outputBitDepth, m_outputBitDepth, bitDepths.recon ); // write mode
    440         openedReconFile = true;
    441       }
    442       // write reconstruction to file
    443       if( bNewPicture )
    444       {
    445354        xWriteOutput( pcListPic, nalu.m_temporalId );
    446355      }
     
    452361
    453362      if ( bNewPicture &&
    454 #endif
    455363           (   nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL
    456364            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP
     
    459367            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP ) )
    460368      {
    461 #if NH_MV
    462         xFlushOutput( pcListPic, decIdxLastPic );
    463 #else
     369
    464370        xFlushOutput( pcListPic );
    465 #endif
    466371      }
    467372      if (nalu.m_nalUnitType == NAL_UNIT_EOS)
    468373      {
    469 #if NH_MV
    470         xWriteOutput( pcListPic, decIdxCurrPic, nalu.m_temporalId );
    471 #else
     374
    472375        xWriteOutput( pcListPic, nalu.m_temporalId );
    473 #endif
    474 #if NH_MV
    475         m_tDecTop[decIdxCurrPic]->setFirstSliceInPicture (false);
    476 #else
    477376        m_cTDecTop.setFirstSliceInPicture (false);
    478 #endif
    479377      }
    480378      // write reconstruction to file -- for additional bumping as defined in C.5.2.3
    481 #if NH_MV
    482       // Above comment seems to be wrong
    483 #endif
    484379      if(!bNewPicture && nalu.m_nalUnitType >= NAL_UNIT_CODED_SLICE_TRAIL_N && nalu.m_nalUnitType <= NAL_UNIT_RESERVED_VCL31)
    485380      {
    486 #if NH_MV       
    487         // Bumping after reference picture set has been applied (here after first vcl nalu.
    488 #if ENC_DEC_TRACE
    489         g_bJustDoIt = true; 
    490         writeToTraceFile( "Bumping after reference picture set has been applied \n", g_decTracePicOutput  );         
    491         g_bJustDoIt = false; 
    492 #endif
    493 
    494         xWriteOutput( m_tDecTop[decIdxCurrPic]->getListPic(), decIdxCurrPic, nalu.m_temporalId );
    495 #else
    496381        xWriteOutput( pcListPic, nalu.m_temporalId );
    497 #endif
    498       }
    499     }
    500   }
    501 #if NH_MV
    502 #if NH_3D
    503   if( m_cCamParsCollector.isInitialized() )
    504   {
    505     m_cCamParsCollector.setSlice( 0 );
    506   }
    507 #endif
    508   for(UInt decIdx = 0; decIdx < m_numDecoders; decIdx++)
    509   {
    510     xFlushOutput( m_tDecTop[decIdx]->getListPic(), decIdx );
    511   }
    512 #else 
     382      }
     383    }
     384  }
     385
    513386  xFlushOutput( pcListPic );
    514387  // delete buffers
     
    516389  // destroy internal classes
    517390  xDestroyDecLib();
     391}
    518392#endif
    519 }
    520393
    521394// ====================================================================================================================
     
    527400#if NH_MV
    528401  // initialize global variables
    529   initROM(); 
     402  initROM();
    530403#if NH_3D_DMM
    531404  initWedgeLists();
     
    548421    {
    549422      m_tVideoIOYuvReconFile[decIdx]->close();
    550       delete m_tVideoIOYuvReconFile[decIdx]; 
     423      delete m_tVideoIOYuvReconFile[decIdx];
    551424      m_tVideoIOYuvReconFile[decIdx] = NULL ;
    552425    }
     
    554427    if( m_tDecTop[decIdx] )
    555428    {
     429#if !NH_MV
    556430      m_tDecTop[decIdx]->deletePicBuffer();
     431#endif
    557432      m_tDecTop[decIdx]->destroy() ;
    558433    }
    559     delete m_tDecTop[decIdx] ; 
     434    delete m_tDecTop[decIdx] ;
    560435    m_tDecTop[decIdx] = NULL ;
    561436  }
     
    571446#if NH_3D
    572447  m_cCamParsCollector.uninit();
    573   if( m_pScaleOffsetFile ) 
    574   { 
    575     ::fclose( m_pScaleOffsetFile ); 
     448  if( m_pScaleOffsetFile )
     449  {
     450    ::fclose( m_pScaleOffsetFile );
    576451  }
    577452#endif
     
    584459  m_cCamParsCollector.setCodeScaleOffsetFile( m_pScaleOffsetFile );
    585460#endif
    586 #if !NH_MV
     461#if NH_MV
     462  m_dpb.setPrintPicOutput(m_printPicOutput);
     463#else
    587464  // initialize decoder class
    588465  m_cTDecTop.init();
     
    599476}
    600477
     478
     479#if !NH_MV
    601480/** \param pcListPic list of pictures to be written to file
    602481    \param tId       temporal sub-layer ID
    603482 */
    604 #if NH_MV
    605 Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic, Int decIdx, Int tId )
    606 #else
    607483Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic, UInt tId )
    608 #endif
    609484{
    610485  if (pcListPic->empty())
     
    625500  {
    626501    numReorderPicsHighestTid = activeSPS->getNumReorderPics(maxNrSublayers-1);
    627     maxDecPicBufferingHighestTid =  activeSPS->getMaxDecPicBuffering(maxNrSublayers-1); 
     502    maxDecPicBufferingHighestTid =  activeSPS->getMaxDecPicBuffering(maxNrSublayers-1);
    628503  }
    629504  else
    630505  {
    631506    numReorderPicsHighestTid = activeSPS->getNumReorderPics(m_iMaxTemporalLayer);
    632     maxDecPicBufferingHighestTid = activeSPS->getMaxDecPicBuffering(m_iMaxTemporalLayer); 
     507    maxDecPicBufferingHighestTid = activeSPS->getMaxDecPicBuffering(m_iMaxTemporalLayer);
    633508  }
    634509
     
    636511  {
    637512    TComPic* pcPic = *(iterPic);
    638 #if NH_MV
    639     if(pcPic->getOutputMark() && pcPic->getPOC() > m_pocLastDisplay[decIdx])
    640 #else
    641513    if(pcPic->getOutputMark() && pcPic->getPOC() > m_iPOCLastDisplay)
    642 #endif
    643514    {
    644515       numPicsNotYetDisplayed++;
     
    671542      TComPic* pcPicBottom = *(iterPic);
    672543
    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))
    678 #else
    679544      if ( pcPicTop->getOutputMark() && pcPicBottom->getOutputMark() &&
    680545          (numPicsNotYetDisplayed >  numReorderPicsHighestTid || dpbFullness > maxDecPicBufferingHighestTid) &&
    681546          (!(pcPicTop->getPOC()%2) && pcPicBottom->getPOC() == pcPicTop->getPOC()+1) &&
    682547          (pcPicTop->getPOC() == m_iPOCLastDisplay+1 || m_iPOCLastDisplay < 0))
    683 #endif
    684548      {
    685549        // write to file
    686550        numPicsNotYetDisplayed = numPicsNotYetDisplayed-2;
    687 #if NH_MV
    688       if ( m_pchReconFiles[decIdx] )
    689 #else
    690551        if ( m_pchReconFile )
    691 #endif
    692552        {
    693553          const Window &conf = pcPicTop->getConformanceWindow();
     
    708568          if (display)
    709569          {
    710 #if NH_MV
    711         assert( conf   .getScaledFlag() );
    712         assert( defDisp.getScaledFlag() );
    713 #if ENC_DEC_TRACE
    714         g_bJustDoIt = true; 
    715         writeToTraceFile( "OutputPic Poc"   , pcPic->getPOC    (), g_decTracePicOutput  );
    716         writeToTraceFile( "OutputPic LayerId", pcPic->getLayerId(), g_decTracePicOutput );         
    717         g_bJustDoIt = false; 
    718 #endif
    719         m_tVideoIOYuvReconFile[decIdx]->write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
    720 #else
    721570        m_cTVideoIOYuvReconFile.write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
    722 #endif
    723571                                           m_outputColourSpaceConvert,
    724572                                           conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
    725573                                           conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
    726574                                           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
    730575                                           conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), NUM_CHROMA_FORMAT, isTff );
    731 #endif
    732576          }
    733577        }
    734578
    735579        // update POC of display order
    736 #if NH_MV
    737         m_pocLastDisplay[decIdx] = pcPic->getPOC();
    738 #else
    739580        m_iPOCLastDisplay = pcPicBottom->getPOC();
    740 #endif
    741581
    742582        // erase non-referenced picture in the reference picture list after display
     
    768608      pcPic = *(iterPic);
    769609
    770 #if NH_MV
    771       if(pcPic->getOutputMark() && pcPic->getPOC() > m_pocLastDisplay[decIdx] &&
    772         (numPicsNotYetDisplayed >  numReorderPicsHighestTid || dpbFullness > maxDecPicBufferingHighestTid))
    773 #else     
    774610      if(pcPic->getOutputMark() && pcPic->getPOC() > m_iPOCLastDisplay &&
    775611        (numPicsNotYetDisplayed >  numReorderPicsHighestTid || dpbFullness > maxDecPicBufferingHighestTid))
    776 #endif
    777612      {
    778613        // write to file
     
    782617          dpbFullness--;
    783618        }
    784 #if NH_MV
    785       if ( m_pchReconFiles[decIdx] )
    786 #else
    787619        if ( m_pchReconFile )
    788 #endif
    789620        {
    790621          const Window &conf    = pcPic->getConformanceWindow();
    791622          const Window defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
    792 #if NH_MV
    793         assert( conf   .getScaledFlag() );
    794         assert( defDisp.getScaledFlag() );
    795 #if ENC_DEC_TRACE
    796         g_bJustDoIt = true; 
    797         writeToTraceFile( "OutputPic Poc"   , pcPic->getPOC    (), g_decTracePicOutput  );
    798         writeToTraceFile( "OutputPic LayerId", pcPic->getLayerId(), g_decTracePicOutput );         
    799         g_bJustDoIt = false;
    800 #endif
    801         m_tVideoIOYuvReconFile[decIdx]->write( pcPic->getPicYuvRec(),
    802 #else
     623
    803624          m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
    804 #endif
    805625                                         m_outputColourSpaceConvert,
    806626                                         conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
    807627                                         conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
    808628                                         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   );
     629                                         conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(),
     630                                         NUM_CHROMA_FORMAT, m_bClipOutputVideoToRec709Range  );
    816631        }
    817632
    818633        // update POC of display order
    819 #if NH_MV
    820         m_pocLastDisplay[decIdx] = pcPic->getPOC();
    821 #else
    822634        m_iPOCLastDisplay = pcPic->getPOC();
    823 #endif
    824635
    825636        // erase non-referenced picture in the reference picture list after display
     
    832643        }
    833644        pcPic->setOutputMark(false);
    834 #if NH_MV
    835         pcPic->setPicOutputFlag(false);
    836 #endif
    837645      }
    838646
     
    844652/** \param pcListPic list of pictures to be written to file
    845653 */
    846 #if NH_MV
    847 Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic, Int decIdx )
    848 #else
    849654Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic )
    850 #endif
    851655{
    852656  if(!pcListPic || pcListPic->empty())
     
    873677      {
    874678        // write to file
    875 #if NH_MV
    876       if ( m_pchReconFiles[decIdx] )
    877 #else
     679
    878680        if ( m_pchReconFile )
    879 #endif
    880681        {
    881682          const Window &conf = pcPicTop->getConformanceWindow();
    882683          const Window  defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window();
    883684          const Bool isTff = pcPicTop->isTopField();
    884 #if NH_MV
    885         assert( conf   .getScaledFlag() );
    886         assert( defDisp.getScaledFlag() );
    887 #if ENC_DEC_TRACE
    888         g_bJustDoIt = true; 
    889         writeToTraceFile( "OutputPic Poc"   , pcPic->getPOC    (), g_decTracePicOutput  );
    890         writeToTraceFile( "OutputPic LayerId", pcPic->getLayerId(), g_decTracePicOutput );         
    891         g_bJustDoIt = false; 
    892 #endif
    893         m_tVideoIOYuvReconFile[decIdx]->write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
    894 #else
    895685          m_cTVideoIOYuvReconFile.write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
    896 #endif
    897686                                         m_outputColourSpaceConvert,
    898687                                         conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
    899688                                         conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
    900689                                         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
    904690                                         conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), NUM_CHROMA_FORMAT, isTff );
    905 #endif
    906691        }
    907692
    908693        // update POC of display order
    909 #if NH_MV
    910       m_pocLastDisplay[decIdx] = pcPic->getPOC();
    911 #else
    912694        m_iPOCLastDisplay = pcPicBottom->getPOC();
    913 #endif       
     695
    914696        // erase non-referenced picture in the reference picture list after display
    915697        if ( !pcPicTop->getSlice(0)->isReferenced() && pcPicTop->getReconMark() == true )
     
    954736      {
    955737        // write to file
    956 #if NH_MV
    957       if ( m_pchReconFiles[decIdx] )
    958 #else
    959738        if ( m_pchReconFile )
    960 #endif
    961739        {
    962740          const Window &conf    = pcPic->getConformanceWindow();
    963741          const Window  defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
    964 #if NH_MV
    965         assert( conf   .getScaledFlag() );
    966         assert( defDisp.getScaledFlag() );
    967 #if ENC_DEC_TRACE
    968         g_bJustDoIt = true; 
    969         writeToTraceFile( "OutputPic Poc"   , pcPic->getPOC    (), g_decTracePicOutput  );
    970         writeToTraceFile( "OutputPic LayerId", pcPic->getLayerId(), g_decTracePicOutput );         
    971         g_bJustDoIt = false; 
    972 #endif
    973         m_tVideoIOYuvReconFile[decIdx]->write( pcPic->getPicYuvRec(),
    974 #else
    975742          m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
    976 #endif
    977743                                         m_outputColourSpaceConvert,
    978744                                         conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
    979745                                         conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
    980746                                         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);
     747                                         conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(),
     748                                         NUM_CHROMA_FORMAT, m_bClipOutputVideoToRec709Range );
    988749        }
    989750
    990751        // update POC of display order
    991 #if NH_MV
    992       m_pocLastDisplay[decIdx] = pcPic->getPOC();
    993 #else
    994752        m_iPOCLastDisplay = pcPic->getPOC();
    995 #endif
    996 
    997753        // erase non-referenced picture in the reference picture list after display
    998754        if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
     
    1004760        }
    1005761        pcPic->setOutputMark(false);
    1006 #if NH_MV
    1007         pcPic->setPicOutputFlag(false);
    1008 #endif
    1009       }
    1010 #if !NH_MV
     762      }
    1011763      if(pcPic != NULL)
    1012764      {
     
    1015767        pcPic = NULL;
    1016768      }
    1017 #endif
    1018769      iterPic++;
    1019770    }
    1020771  }
    1021 #if NH_MV
    1022   m_pocLastDisplay[decIdx] = -MAX_INT;
    1023 #else
    1024772  pcListPic->clear();
    1025773  m_iPOCLastDisplay = -MAX_INT;
     774}
    1026775#endif
    1027 }
    1028 
    1029776/** \param nalu Input nalu to check whether its LayerId is within targetDecLayerIdSet
    1030777 */
     778#if NH_MV
     779Bool TAppDecTop::xIsNaluInTargetDecLayerIdSet( InputNALUnit* nalu )
     780#else
    1031781Bool TAppDecTop::isNaluWithinTargetDecLayerIdSet( InputNALUnit* nalu )
     782#endif
    1032783{
    1033784  if ( m_targetDecLayerIdSet.size() == 0 ) // By default, the set is empty, meaning all LayerIds are allowed
     
    1037788  for (std::vector<Int>::iterator it = m_targetDecLayerIdSet.begin(); it != m_targetDecLayerIdSet.end(); it++)
    1038789  {
     790    if ( nalu->m_nuhLayerId == (*it) )
     791    {
     792      return true;
     793    }
     794  }
     795  return false;
     796}
     797
    1039798#if NH_MV
    1040     if ( nalu->m_nuhLayerId == (*it) )
    1041 #else
    1042     if ( nalu->m_nuhLayerId == (*it) )
     799
     800Bool TAppDecTop::xExtractAndRewrite( InputNALUnit* nalu )
     801{
     802  Bool naluInSubStream;
     803  if ( !m_initilizedFromVPS )
     804  {
     805    naluInSubStream = true; // No active VPS yet. Wait for slice activating one.
     806  }
     807  else
     808  {
     809    if ( m_decProcCvsg == CLAUSE_8 )
     810    {
     811      // 8.1.2->clause 10
     812
     813      // sub-bitstream extraction process as specified in clause 10
     814      naluInSubStream = true;
     815      if ( nalu->m_temporalId > m_highestTid || !xIsNaluInTargetDecLayerIdSet(nalu) )
     816      {
     817        naluInSubStream = false;
     818      }
     819    }
     820    else
     821    {
     822      // F.8.1.2
     823      Int targetDecLayerSetIdx = m_vps->olsIdxToLsIdx( m_targetOptLayerSetIdx );
     824      if ( targetDecLayerSetIdx <= m_vps->getVpsNumLayerSetsMinus1() && m_vps->getVpsBaseLayerInternalFlag() )
     825      {
     826        // - If TargetDecLayerSetIdx is less than or equal to vps_num_layer_sets_minus1 and
     827        //   vps_base_layer_internal_flag is equal to 1, the following applies:
     828        //   - The sub-bitstream extraction process as specified in clause 10 is applied with the CVSG, HighestTid and
     829        //     TargetDecLayerIdList as inputs, and the output is assigned to a bitstream referred to as BitstreamToDecode.
     830
     831        naluInSubStream = true;
     832        if ( nalu->m_temporalId > m_highestTid || !xIsNaluInTargetDecLayerIdSet(nalu) )
     833        {
     834          naluInSubStream = false;
     835        }
     836
     837      }
     838      else if ( targetDecLayerSetIdx <= m_vps->getVpsNumLayerSetsMinus1() && !m_vps->getVpsBaseLayerInternalFlag() )
     839      {
     840        // - Otherwise, if TargetDecLayerSetIdx is less than or equal to vps_num_layer_sets_minus1 and vps_base_layer_internal_flag
     841        //   is equal to 0, the following applies:
     842        //   - The sub-bitstream extraction process as specified in clause F.10.1 is applied with the CVSG, HighestTid and
     843        //     TargetDecLayerIdList as inputs, and the output is assigned to a bitstream referred to as BitstreamToDecode.
     844
     845        naluInSubStream = true;
     846        if ( nalu->m_temporalId > m_highestTid || !xIsNaluInTargetDecLayerIdSet(nalu) )
     847        {
     848          naluInSubStream = false;
     849        }
     850      }
     851      else if ( targetDecLayerSetIdx > m_vps->getVpsNumLayerSetsMinus1() && m_vps->getNumLayersInIdList( targetDecLayerSetIdx ) == 1 )
     852      {
     853        // - Otherwise, if TargetDecLayerSetIdx is greater than vps_num_layer_sets_minus1 and
     854        //   NumLayersInIdList[ TargetDecLayerSetIdx ] is equal to 1, the following applies:
     855        //   - The independent non-base layer rewriting process of clause F.10.2 is applied with the CVSG, HighestTid and
     856        //     TargetDecLayerIdList[ 0 ] as inputs, and the output is assigned to a bitstream referred to as BitstreamToDecode.
     857
     858        Int assingedBaseLayerId = m_targetDecLayerIdSet[0];
     859        naluInSubStream = true;
     860
     861        if ( nalu->m_nalUnitType != NAL_UNIT_SPS &&
     862          nalu->m_nalUnitType != NAL_UNIT_PPS &&
     863          nalu->m_nalUnitType != NAL_UNIT_EOB &&
     864          nalu->m_nuhLayerId != assingedBaseLayerId )
     865        {
     866          naluInSubStream = false;
     867        }
     868
     869        if ( ( nalu->m_nalUnitType == NAL_UNIT_SPS || nalu->m_nalUnitType != NAL_UNIT_PPS ) &&
     870          !( nalu->m_nuhLayerId == 0 || nalu->m_nuhLayerId == assingedBaseLayerId ) )
     871        {
     872          naluInSubStream = false;
     873        }
     874
     875        if ( nalu->m_nalUnitType == NAL_UNIT_VPS )
     876        {
     877          naluInSubStream = false;
     878        }
     879
     880        if ( nalu->m_temporalId > m_highestTid )
     881        {
     882          naluInSubStream = false;
     883        }
     884               
     885        // For now, don't do the layer id change here, but change smallest layer id.
     886        // To be verified.         
     887        //if ( naluInSubStream )
     888        //{
     889        //  nalu->m_nuhLayerId = 0;
     890        //}
     891      }
     892      else
     893      {
     894        // - Otherwise, the following applies:
     895        //   - The sub-bitstream extraction process as specified in clause F.10.3 is applied with the CVSG, HighestTid and
     896        //     TargetDecLayerIdList as inputs, and the output is assigned to a bitstream referred to as BitstreamToDecode.
     897
     898        naluInSubStream = true;
     899
     900        if ( nalu->m_nalUnitType != NAL_UNIT_VPS &&
     901          nalu->m_nalUnitType != NAL_UNIT_SPS &&
     902          nalu->m_nalUnitType != NAL_UNIT_PPS &&
     903          nalu->m_nalUnitType != NAL_UNIT_EOS &&
     904          nalu->m_nalUnitType != NAL_UNIT_EOB &&
     905          !xIsNaluInTargetDecLayerIdSet(nalu) )
     906        {
     907          naluInSubStream = false;
     908        }
     909
     910        if ( ( nalu->m_nalUnitType == NAL_UNIT_VPS ||
     911          nalu->m_nalUnitType == NAL_UNIT_SPS ||
     912          nalu->m_nalUnitType == NAL_UNIT_PPS ||
     913          nalu->m_nalUnitType == NAL_UNIT_EOS    ) &&
     914          !( nalu->m_nuhLayerId == 0 || xIsNaluInTargetDecLayerIdSet(nalu) )
     915          )
     916        {
     917          naluInSubStream = false;
     918        }
     919
     920        if ( nalu->m_temporalId > m_highestTid )
     921        {
     922          naluInSubStream = false;
     923        }
     924        // TBD: vps_base_layer_available_flag in each VPS is set equal to 0.
     925      }
     926    }
     927  }
     928
     929  return naluInSubStream;
     930}
     931
     932Void TAppDecTop::xProcessVclNalu( InputNALUnit nalu )
     933{
     934  TDecTop* dec  = xGetDecoder( nalu );
     935
     936  // Decode slice header of slice of current or new picture.
     937  dec->decodeSliceHeader( nalu );
     938
     939  // Check if slice belongs to current or new picture
     940  Bool sliceIsFirstOfNewPicture = dec->getFirstSliceSegementInPicFlag();
     941
     942  if ( !xIsSkipVclNalu( nalu, sliceIsFirstOfNewPicture ) )
     943  {
     944    if ( sliceIsFirstOfNewPicture )
     945    {
     946      xDetectNewPocResettingPeriod( nalu );
     947      Bool sliceIsFirstOfNewAU = xDetectNewAu( nalu );
     948      xFinalizePreviousPictures ( sliceIsFirstOfNewAU );
     949      xDecodeFirstSliceOfPicture( nalu, sliceIsFirstOfNewAU );
     950    }
     951    else
     952    {
     953      xDecodeFollowSliceOfPicture( nalu );
     954    }
     955  }
     956}
     957
     958Bool TAppDecTop::xIsSkipVclNalu( InputNALUnit& nalu, Bool isFirstSliceOfPic )
     959{
     960
     961  TDecTop* dec = xGetDecoder( nalu );
     962
     963  m_handleCraAsBlaFlagSetByExtMeans = false;
     964  Bool skipNalu = false;
     965
     966  if ( isFirstSliceOfPic )
     967  {
     968    m_totalNumofPicsReceived++;
     969  }
     970
     971  if (!m_cvsStartFound )
     972  {
     973    // Skip as specified by decoder option. (Not normative!)
     974    if ( m_totalNumofPicsReceived <= m_iSkipFrame )
     975    {
     976      skipNalu = true;
     977      if ( isFirstSliceOfPic )
     978      {
     979        std::cout << "Layer " << std::setfill(' ') << std::setw(2) << nalu.m_nuhLayerId
     980          << "   POC    ? Skipping picture." << std::setw(5) << m_totalNumofPicsReceived - 1 << std::endl;
     981      }
     982    }
     983    else
     984    {     
     985      if ( dec->getIsInOwnTargetDecLayerIdList() )
     986      {
     987        // Search for initial IRAP access unit
     988        Bool canBeSliceOfInitialIrapAu = nalu.isIrap() && ( dec->decProcClause8() || nalu.m_nuhLayerId == dec->getSmallestLayerId() );
     989
     990        if ( !canBeSliceOfInitialIrapAu )
     991        {
     992          skipNalu = true;
     993          if ( isFirstSliceOfPic )
     994          {
     995            std::cout << "Layer " << std::setfill(' ') << std::setw(2) << nalu.m_nuhLayerId
     996              << "   POC    ? Not an initial IRAP AU. Skipping picture." << std::setw(5) << m_totalNumofPicsReceived - 1 << std::endl;
     997          }
     998        }
     999        else
     1000        {
     1001          m_cvsStartFound = true;
     1002          if( nalu.isCra() )
     1003          {
     1004            // Ensure that NoRaslOutputFlag of picture is equal to 1.
     1005            m_handleCraAsBlaFlagSetByExtMeans = true;
     1006            m_handleCraAsBlaFlag = true;
     1007          }
     1008        }
     1009      }
     1010      else
     1011      {
     1012        skipNalu = true;
     1013      }
     1014    }
     1015  }
     1016  else
     1017  {
     1018    assert( dec->getIsInOwnTargetDecLayerIdList() );
     1019  }
     1020  return skipNalu;
     1021}
     1022
     1023Void TAppDecTop::xProcessNonVclNalu( InputNALUnit nalu )
     1024{
     1025  xGetDecoder(nalu)->decodeNonVclNalu( nalu );
     1026
     1027  if (  nalu.m_nalUnitType == NAL_UNIT_EOS )
     1028  {
     1029    m_eosInLayer[ nalu.m_nuhLayerId ] = true;
     1030  }
     1031}
     1032Void TAppDecTop::xTerminateDecoding()
     1033{
     1034    xFinalizePic( true );
     1035    xFinalizeAU ( );
     1036
     1037#if NH_3D
     1038  if( m_cCamParsCollector.isInitialized() )
     1039  {
     1040    m_cCamParsCollector.setSlice( 0 );
     1041  }
    10431042#endif
    1044     {
    1045       return true;
    1046     }
    1047   }
    1048   return false;
    1049 }
    1050 
    1051 #if NH_MV
     1043   xFlushOutput();
     1044   m_dpb.emptyAllSubDpbs();
     1045}
     1046
     1047
     1048//////////////////////////////
     1049/// Process slices
     1050//////////////////////////////
     1051
     1052Void TAppDecTop::xDecodeFirstSliceOfPicture( InputNALUnit nalu, Bool sliceIsFirstOfNewAu )
     1053{
     1054  TDecTop* dec = xGetDecoder(nalu);
     1055  // Initialize from VPS of first slice
     1056
     1057  // Get current SPS and PPS
     1058  TComSlice* slicePilot = dec->getSlicePilot();
     1059  m_vps = slicePilot->getVPS();
     1060  m_sps = slicePilot->getSPS();
     1061  m_pps = slicePilot->getPPS();
     1062
     1063  /// Use VPS activated by the first slice to initialized decoding
     1064  if( !m_initilizedFromVPS )
     1065  {
     1066    xF811GeneralDecProc( nalu );
     1067    m_initilizedFromVPS = true;
     1068    m_newVpsActivatedbyCurAu  = true; //TBD
     1069    m_newVpsActivatedbyCurPic = true;
     1070#if NH_3D
     1071    m_dpb.setVPS( m_vps );
     1072#endif
     1073  }
     1074
     1075  // Create new sub-DBP if not existing
     1076  m_dpb.getSubDpb( nalu.m_nuhLayerId, true );
     1077
     1078  // Create a new picture initialize and make it the current picture
     1079  assert( m_curPic == NULL );
     1080  m_curPic = new TComPic;
     1081
     1082  m_curPic->create(*m_sps, *m_pps, true);
     1083
     1084  m_curPic->setLayerId                      ( nalu.m_nuhLayerId );
     1085  m_curPic->setDecodingOrder                ( m_decodingOrder[ nalu.m_nuhLayerId ]);
     1086  m_curPic->setIsFstPicOfAllLayOfPocResetPer( m_newPicIsFstPicOfAllLayOfPocResetPer );
     1087  m_curPic->setIsPocResettingPic            ( m_newPicIsPocResettingPic );
     1088  m_curPic->setActivatesNewVps              ( m_newVpsActivatedbyCurPic );
     1089
     1090  dec     ->activatePSsAndInitPicOrSlice( m_curPic );
     1091
     1092  m_decodingOrder[ nalu.m_nuhLayerId ]++;
     1093
     1094  // Insert pic to current AU
     1095  // ( There is also a "current AU in the DBP", however the DBP AU will include the current
     1096  //   picture only after it is inserted to the DBP )
     1097  m_curAu.addPic(  m_curPic, true );
     1098
     1099  // Invoke Claus 8 and Annex F decoding process for a picture (only parts before POC derivation ).
     1100  xPicDecoding( START_PIC, sliceIsFirstOfNewAu );
     1101
     1102  if (m_decProcCvsg == ANNEX_F )
     1103  {
     1104    // Do output before POC derivation
     1105    xF13522OutputAndRemOfPicsFromDpb( true );
     1106  }
     1107
     1108  // Decode POC and apply reference picture set
     1109  dec->setDecProcPocAndRps( m_decProcPocAndRps );
     1110  dec->decodePocAndRps( );
     1111
     1112  // Do output after POC and RPS derivation
     1113  if (m_decProcCvsg == CLAUSE_8 )
     1114  {
     1115    xC522OutputAndRemOfPicsFromDpb( );
     1116  }
     1117  else if (m_decProcCvsg == ANNEX_F )
     1118  {
     1119    xF13522OutputAndRemOfPicsFromDpb( false );
     1120  }
     1121  else
     1122  {
     1123    assert(false);
     1124  }
     1125
     1126  // Generate unavailable reference pictures
     1127  dec->genUnavailableRefPics( );
     1128
     1129  // decode first slice segment
     1130  dec->decodeSliceSegment( nalu );
     1131
     1132  m_firstSliceInBitstream = false;
     1133}
     1134
     1135Void TAppDecTop::xDecodeFollowSliceOfPicture( InputNALUnit nalu )
     1136{
     1137  // decode following segment
     1138    TDecTop* dec = xGetDecoder( nalu );
     1139    dec->activatePSsAndInitPicOrSlice( NULL );
     1140    dec->decodeSliceSegment          ( nalu );
     1141}
     1142
     1143Void TAppDecTop::xFinalizePreviousPictures( Bool sliceIsFirstOfNewAU )
     1144{
     1145  Bool curPicIsLastInAu = sliceIsFirstOfNewAU && (m_curPic != NULL);
     1146  // When slice belongs to new picture, finalize current picture.
     1147  if( m_curPic != NULL )
     1148  {
     1149    xFinalizePic( curPicIsLastInAu );
     1150
     1151    if (m_curPic->isIrap() )
     1152    {
     1153      m_noRaslOutputFlagAssocIrap[ m_curPic->getLayerId() ] = m_curPic->getNoRaslOutputFlag();
     1154    }
     1155
     1156    m_tDecTop[ xGetDecoderIdx( m_curPic->getLayerId() )]->finalizePic();
     1157    m_curPic->getPicYuvRec()->extendPicBorder();
     1158    m_newVpsActivatedbyCurPic = false;
     1159  }
     1160
     1161  // When slice belongs to new AU, finalize current AU.
     1162  if ( curPicIsLastInAu && !m_curAu.empty() )
     1163  {
     1164    xFinalizeAU( );
     1165    m_newVpsActivatedbyCurAu = false;
     1166    m_curAu.clear();
     1167  }
     1168  m_curPic = NULL;
     1169}
     1170
     1171
     1172Void TAppDecTop::xFinalizePic(Bool curPicIsLastInAu )
     1173{
     1174  if ( m_curPic != NULL )
     1175  {
     1176    m_tDecTop[ xGetDecoderIdx(m_curPic->getLayerId() ) ]->executeLoopFilters( ); // 8.7
     1177
     1178    // Invoke Claus 8 and F.8 decoding process for a picture (only parts after POC derivation )
     1179    xPicDecoding(FINALIZE_PIC, curPicIsLastInAu );
     1180
     1181    if( m_decProcCvsg == CLAUSE_8 )
     1182    {
     1183      xC523PicDecMarkAddBumpAndStor    ( );
     1184    }
     1185    else if ( m_decProcCvsg == ANNEX_F )
     1186    {
     1187      xF13523PicDecMarkAddBumpAndStor  ( curPicIsLastInAu );
     1188    }
     1189  }
     1190}
     1191
     1192Void TAppDecTop::xFinalizeAU()
     1193{
     1194#if NH_3D
     1195  if ( !m_curAu.empty())
     1196  {
     1197    for (TComList<TComPic*>::iterator it = m_curAu.begin(); it != m_curAu.end(); it++)
     1198    {
     1199      TComPic* pic = (*it);
     1200      if ( !pic->getHasGeneratedRefPics() )
     1201      {
     1202        pic->compressMotion(1);
     1203      }
     1204    }
     1205  }
     1206#endif
     1207}
     1208
     1209
     1210Void TAppDecTop::xF811GeneralDecProc( InputNALUnit nalu )
     1211{
     1212  ////////////////////////////////////////////////////////////////////////////////
     1213  // F.8.1 General decoding process
     1214  ////////////////////////////////////////////////////////////////////////////////
     1215
     1216  // The following applies at the beginning of decoding a CVSG, after activating the VPS RBSP that is active for
     1217  // the entire CVSG and before decoding any VCL NAL units of the CVSG:
     1218
     1219  if ( !m_vps->getVpsExtensionFlag() )
     1220  {
     1221    //-   If vps_extension( ) is not present in the active VPS or a decoding process specified in this annex is not in use,
     1222    //   clause 8.1.2 is invoked with the CVSG as input.
     1223    x812CvsgDecodingProcess( xGetDecoderIdx( nalu.m_nuhLayerId ) );
     1224    m_decProcCvsg = CLAUSE_8;
     1225  }
     1226  else
     1227  {
     1228    // - Otherwise (vps_extension( ) is present in the active VPS and a decoding process specified in this annex is in use),
     1229    xF812CvsgDecodingProcess( xGetDecoderIdx( nalu.m_nuhLayerId ) );
     1230    xF13521InitDpb();
     1231    m_decProcCvsg = ANNEX_F;
     1232  }
     1233
     1234  if ( m_printVpsInfo  && ( m_decProcCvsg == ANNEX_F ) )
     1235  {
     1236    m_vps->printScalabilityId();
     1237    m_vps->printLayerDependencies();
     1238    m_vps->printLayerSets();
     1239    m_vps->printPTL();
     1240  }
     1241}
     1242
     1243Void   TAppDecTop::xPicDecoding( DecProcPart curPart, Bool picPosInAuIndication )
     1244{
     1245  if ( m_decProcCvsg == CLAUSE_8 )
     1246  {
     1247    // F.8.1.1 -> 8.1.2 -> 8.1.3
     1248    x813decProcForCodPicWithLIdZero  ( curPart );
     1249  }
     1250  else if ( m_decProcCvsg == ANNEX_F )
     1251  {
     1252    if ( m_targetOptLayerSetIdx == 0  )
     1253    {
     1254      // F.8.1.1 -> F.8.1.2 -> 8.1.3
     1255      x813decProcForCodPicWithLIdZero  ( curPart );
     1256    }
     1257    else
     1258    {
     1259      // F.8.1.1 -> F.8.1.2 -> F.8.1.3
     1260      xF813ComDecProcForACodedPic( curPart, picPosInAuIndication );
     1261    }
     1262  }
     1263  else
     1264  {
     1265    assert( false );
     1266  }
     1267}
     1268
     1269Void TAppDecTop::x812CvsgDecodingProcess( Int decIdx )
     1270{
     1271  ///////////////////////////////////////////////////////////////////////////////////////
     1272  //  8.1.2 CVSG decoding process
     1273  ///////////////////////////////////////////////////////////////////////////////////////
     1274
     1275  // The layer identifier list TargetDecLayerIdList, which specifies the list of nuh_layer_id values,
     1276  // in increasing order of nuh_layer_id values, of the NAL units to be decoded, is specified as follows:
     1277
     1278  Bool externalMeansToSetTargetDecLayerIdList = !m_targetDecLayerIdSetFileEmpty;
     1279
     1280  if ( externalMeansToSetTargetDecLayerIdList )
     1281  {
     1282    // - If some external means, not specified in this Specification, is available to set TargetDecLayerIdList,
     1283    //   TargetDecLayerIdList is set by the external means.
     1284    assert( !m_targetDecLayerIdSet.empty() ); // Already done when parsing cfg ile
     1285  }
     1286  else
     1287  {
     1288    //-  Otherwise, TargetDecLayerIdList contains only one nuh_layer_id value that is equal to 0.
     1289    m_targetDecLayerIdSet.clear();
     1290    m_targetDecLayerIdSet.push_back( 0 );
     1291  }
     1292
     1293  // The variable HighestTid, which identifies the highest temporal sub-layer to be decoded, is specified as follows:
     1294  Bool externalMeansSetHighestTid = ( m_iMaxTemporalLayer != -1 );
     1295  if ( externalMeansSetHighestTid )
     1296  {
     1297    //- If some external means, not specified in this Specification, is available to set HighestTid,
     1298    //  HighestTid is set by the external means.
     1299    m_highestTid = m_iMaxTemporalLayer;
     1300  }
     1301  else
     1302  {
     1303    //-  Otherwise, HighestTid is set equal to sps_max_sub_layers_minus1.
     1304    m_highestTid = m_sps->getSpsMaxSubLayersMinus1();
     1305  }
     1306
     1307  //The variable SubPicHrdFlag is specified as follows:
     1308  //- If the decoding process is invoked in a bitstream conformance test as specified in clause C.1, SubPicHrdFlag is set as specified in clause C.1.
     1309  //- Otherwise, SubPicHrdFlag is set equal to ( SubPicHrdPreferredFlag  &&  sub_pic_hrd_params_present_flag ).
     1310
     1311  // The sub-bitstream extraction process as specified in clause 10 is applied with the CVSG, HighestTid and TargetDecLayerIdList as inputs, and the output is assigned to a bitstream referred to as BitstreamToDecode.
     1312}
     1313
     1314Void TAppDecTop::x813decProcForCodPicWithLIdZero( DecProcPart curPart )
     1315{
     1316  ////////////////////////////////////////////////////////////////////////////////
     1317  // 8.1.3 Decoding process for a coded picture with nuh_layer_id equal to 0.
     1318  ////////////////////////////////////////////////////////////////////////////////
     1319
     1320  if ( curPart == START_PIC )
     1321  {
     1322    Int nuhLayerId = m_curPic->getLayerId();
     1323
     1324    if ( ( m_curPic->isBla() && m_curPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP ) || m_curPic->isCra() )
     1325    {
     1326      // Not needed.
     1327      // When the current picture is a BLA picture that has nal_unit_type equal to BLA_W_LP or is a CRA picture, the following applies:
     1328      // -  If some external means not specified in this Specification is available to set the variable UseAltCpbParamsFlag to a value, UseAltCpbParamsFlag is set equal to the value provided by the external means.
     1329      // -  Otherwise, the value of UseAltCpbParamsFlag is set equal to 0.
     1330    }
     1331
     1332    if ( m_curPic->isIrap() )
     1333    {
     1334      // When the current picture is an IRAP picture, the following applies:
     1335      if ( m_curPic->isIdr() || m_curPic->isBla() || m_curPic->getDecodingOrder() == 0 || m_eosInLayer[ nuhLayerId ] )
     1336      {
     1337        // -  If the current picture is an IDR picture, a BLA picture, the first picture in the bitstream in decoding order,
     1338        //    or the first picture that follows an end of sequence NAL unit in decoding order, the variable NoRaslOutputFlag
     1339        //    is set equal to 1.
     1340
     1341        m_curPic->setNoRaslOutputFlag( true );
     1342      }
     1343      else if ( m_handleCraAsBlaFlagSetByExtMeans )
     1344      {
     1345        // -  Otherwise, if some external means not specified in this Specification is available to set the variable HandleCraAsBlaFlag
     1346        //    to a value for the current picture, the variable HandleCraAsBlaFlag is set equal to the value provided by
     1347        //    the external means and the variable NoRaslOutputFlag is set equal to HandleCraAsBlaFlag.
     1348
     1349        m_curPic->setNoRaslOutputFlag( m_handleCraAsBlaFlag );
     1350      }
     1351      else
     1352      {
     1353        // -  Otherwise, the variable HandleCraAsBlaFlag is set equal to 0 and the variable NoRaslOutputFlag is set equal to 0.
     1354        m_handleCraAsBlaFlag = false;
     1355        m_curPic->setNoRaslOutputFlag( false );
     1356      }
     1357    }
     1358
     1359    m_decProcPocAndRps = CLAUSE_8;
     1360  }
     1361  else if ( curPart == FINALIZE_PIC )
     1362  {
     1363    // -  PicOutputFlag is set as follows:
     1364    if (m_curPic->isRasl() && m_noRaslOutputFlagAssocIrap[ m_curPic->getLayerId() ] )
     1365    {
     1366      // -  If the current picture is a RASL picture and NoRaslOutputFlag of the associated IRAP picture is equal to 1,
     1367      //    PicOutputFlag is set equal to 0.
     1368      m_curPic->setPicOutputFlag( false );
     1369    }
     1370    else
     1371    {
     1372      // -  Otherwise, PicOutputFlag is set equal to pic_output_flag.
     1373      m_curPic->setPicOutputFlag( m_curPic->getSlice(0)->getPicOutputFlag() );
     1374    }
     1375
     1376    // 4.  After all slices of the current picture have been decoded, the decoded picture is marked as "used for short-term reference".
     1377    m_curPic->markAsUsedForShortTermReference();
     1378  }
     1379}
     1380
     1381// F.8.1.2
     1382Void TAppDecTop::xF812CvsgDecodingProcess( Int decIdx )
     1383{
     1384  ///////////////////////////////////////////////////////////////////////////////////////
     1385  //  F.8.1.2 CVSG decoding process
     1386 ///////////////////////////////////////////////////////////////////////////////////////
     1387
     1388  // The variable TargetOlsIdx, which specifies the index to the list of the OLSs
     1389  // specified by the VPS, of the target OLS, is specified as follows:
     1390
     1391
     1392  // If some external means, not specified in this Specification, is available to set
     1393  // TargetOlsIdx, TargetOlsIdx is set by the external means.
     1394
     1395  // For this decoder the TargetOlsIdx is always set by external means:
     1396  // When m_targetOptLayerSetIdx is equal to -1,  TargetOlsIdx is set to getVpsNumLayerSetsMinus1 (which has already been done in TDecTop, since needed there for parsing)
     1397  // Otherwise m_targetOptLayerSetIdx is used directly.
     1398
     1399  if ( m_targetOptLayerSetIdx == -1 )
     1400  {
     1401    m_targetOptLayerSetIdx = m_tDecTop[decIdx]->getTargetOlsIdx();
     1402  }
     1403  else
     1404  {
     1405    assert( m_tDecTop[decIdx]->getTargetOlsIdx() == m_targetOptLayerSetIdx );
     1406  }
     1407
     1408  m_targetDecLayerSetIdx = m_vps->olsIdxToLsIdx( m_targetOptLayerSetIdx );
     1409  m_targetDecLayerIdSet  = m_vps->getTargetDecLayerIdList( m_targetOptLayerSetIdx );
     1410
     1411
     1412  if ( m_targetOptLayerSetIdx < 0 || m_targetOptLayerSetIdx >= m_vps->getNumOutputLayerSets() )
     1413  {
     1414    fprintf(stderr, "\ntarget output layer set index must be in the range of 0 to %d, inclusive \n", m_vps->getNumOutputLayerSets() - 1 );
     1415    exit(EXIT_FAILURE);
     1416  }
     1417
     1418  if ( !m_vps->getVpsBaseLayerAvailableFlag() )
     1419  {
     1420    if(  m_targetDecLayerSetIdx < m_vps->getFirstAddLayerSetIdx() || m_targetDecLayerSetIdx > m_vps->getLastAddLayerSetIdx() )
     1421    {
     1422      // When vps_base_layer_available_flag is equal to 0, OlsIdxToLsIdx[ TargetOlsIdx ] shall be in the range of FirstAddLayerSetIdx to LastAddLayerSetIdx, inclusive.
     1423      fprintf(stderr, "\nvps_base_layer_available_flag is equal to 0, OlsIdxToLsIdx[ TargetOlsIdx ] shall be in the range of %d to %d, inclusive \n", m_vps->getFirstAddLayerSetIdx(), m_vps->getLastAddLayerSetIdx() );
     1424      exit(EXIT_FAILURE);
     1425    }
     1426  }
     1427
     1428  if ( !m_vps->getVpsBaseLayerInternalFlag() && m_targetOptLayerSetIdx <= 0 )
     1429  {
     1430    // When vps_base_layer_internal_flag is equal to 0, TargetOlsIdx shall be greater than 0.
     1431    fprintf(stderr, "\nvps_base_layer_internal_flag is equal to 0, TargetOlsIdx shall be greater than 0.\n" );
     1432    exit(EXIT_FAILURE);
     1433  }
     1434
     1435  // The variable HighestTid, which identifies the highest temporal sub-layer to be decoded,
     1436  // is specified as follows:
     1437
     1438  Bool externalMeansSetHighestTid = ( m_iMaxTemporalLayer != -1 );
     1439  if ( externalMeansSetHighestTid )
     1440  {
     1441    m_highestTid = m_iMaxTemporalLayer;
     1442  }
     1443  else
     1444  {
     1445    m_highestTid = m_sps->getSpsMaxSubLayersMinus1();
     1446  }
     1447
     1448  // The variable SubPicHrdPreferredFlag is either specified by external means, or when not specified by external means, set equal to 0.
     1449  // The variable SubPicHrdFlag is specified as follows:
     1450  // -  If the decoding process is invoked in a bitstream conformance test as specified in clause F.13.1, SubPicHrdFlag is set as specified in clause F.13.1.
     1451  // -  Otherwise, SubPicHrdFlag is set equal to ( SubPicHrdPreferredFlag  &&  sub_pic_hrd_params_present_flag ), where sub_pic_hrd_params_present_flag is found in any hrd_parameters( ) syntax structure that applies to at least one bitstream partition of the output layer set idenified by TargetOlsIdx.
     1452  // -  TBD in case that needed some when.
     1453
     1454  // A bitstream to be decoded, BitstreamToDecode, is specified as follows:
     1455  //   - Extraction is done in xExtractAndRewrite();
     1456
     1457  //   - SmallestLayerId is already derived in  TDecTop:: initFromActiveVps, since required for SH parsing.
     1458  m_smallestLayerId = m_tDecTop[decIdx]->getSmallestLayerId();
     1459
     1460  // When vps_base_layer_internal_flag is equal to 0, vps_base_layer_available_flag is equal to 1,
     1461  // and TargetDecLayerSetIdx is in the range of 0 to vps_num_layer_sets_minus1, inclusive,
     1462  // the following applies:
     1463  if ( !m_vps->getVpsBaseLayerInternalFlag() && m_vps->getVpsBaseLayerAvailableFlag() &&
     1464       ( m_targetDecLayerSetIdx >= 0 && m_targetDecLayerSetIdx <= m_vps->getVpsNumLayerSetsMinus1() ) )
     1465  {
     1466
     1467    // TBD: The size of the sub-DPB for the layer with nuh_layer_id equal to 0 is set equal to 1.
     1468
     1469    // TBD: The values of pic_width_in_luma_samples, pic_height_in_luma_samples, chroma_format_idc,
     1470    // separate_colour_plane_flag, bit_depth_luma_minus8, bit_depth_chroma_minus8, conf_win_left_offset,
     1471    // conf_win_right_offset, conf_win_top_offset, and conf_win_bottom_offset for decoded pictures
     1472    // with nuh_layer_id equal to 0 are set equal to the values of pic_width_vps_in_luma_samples,
     1473    // pic_height_vps_in_luma_samples, chroma_format_vps_idc, separate_colour_plane_vps_flag,
     1474    // bit_depth_vps_luma_minus8, bit_depth_vps_chroma_minus8, conf_win_vps_left_offset,
     1475    // conf_win_vps_right_offset, conf_win_vps_top_offset, and conf_win_vps_bottom_offset respectively,
     1476    // of the vps_rep_format_idx[ 0 ]-th rep_format( ) syntax structure in the active VPS.
     1477
     1478    // The variable BaseLayerOutputFlag is set equal to ( TargetOptLayerIdList[ 0 ]  = =  0 ).
     1479
     1480    m_baseLayerOutputFlag = ( m_vps->getTargetOptLayerIdList( m_targetOptLayerSetIdx )[ 0 ] == 0 );
     1481
     1482    // NOTE - The BaseLayerOutputFlag for each access unit is to be sent by an external means to
     1483    // the base layer decoder for controlling the output of base layer decoded pictures.
     1484    // BaseLayerOutputFlag equal to 1 indicates that the base layer is an output layer.
     1485    // BaseLayerOutputFlag equal to 0 indicates that the base layer is not an output layer.
     1486
     1487    // The variable LayerInitializedFlag[ i ] is set equal to 0 for all values of i from 0
     1488    // to vps_max_layer_id, inclusive, and the variable FirstPicInLayerDecodedFlag[ i ] is set
     1489    // equal to 0 for all values of i from 0 to vps_max_layer_id, inclusive.
     1490
     1491    for (Int i = 0; i <= m_vps->getVpsMaxLayerId(); i++ )
     1492    {
     1493      m_layerInitilizedFlag       [ i ] = false;
     1494      m_firstPicInLayerDecodedFlag[ i ] = false;
     1495    }
     1496  }
     1497}
     1498
     1499Void TAppDecTop::xC522OutputAndRemOfPicsFromDpb( )
     1500{
     1501  ////////////////////////////////////////////////////////////////////////////////
     1502  // C.5.2.2 Output and removal of pictures from the DPB
     1503  ////////////////////////////////////////////////////////////////////////////////
     1504
     1505//  The output and removal of pictures from the DPB before the decoding of the current picture
     1506//  (but after parsing the slice header of the first slice of the current picture) happens instantaneously
     1507//  when the first decoding unit of the access unit containing the current picture is removed from the CPB and proceeds as follows:
     1508//  - The decoding process for RPS as specified in clause 8.3.2 is invoked.
     1509
     1510  Int nuhLayerId = m_curPic->getLayerId();
     1511  const TComSPS* sps = m_curPic->getSlice(0)->getSPS();
     1512  assert( nuhLayerId == 0 );
     1513
     1514  if( ( m_curPic->isIrap() && m_curPic->getNoRaslOutputFlag() == 1) && m_curPic->getDecodingOrder() != 0 )
     1515  {
     1516    // - If the current picture is an IRAP picture with NoRaslOutputFlag equal to 1 that is not picture 0,
     1517    //   the following ordered steps are applied:
     1518
     1519    // 1.  The variable NoOutputOfPriorPicsFlag is derived for the decoder under test as follows:
     1520    Int noOutputOfPriorPicsFlag;
     1521    if( m_curPic->isCra() )
     1522    {
     1523      //-  If the current picture is a CRA picture, NoOutputOfPriorPicsFlag is set equal to 1
     1524      // (regardless of the value of no_output_of_prior_pics_flag).
     1525      noOutputOfPriorPicsFlag = true;
     1526    }
     1527    else if ( 0  )
     1528    {
     1529      // TBD
     1530      //- Otherwise, if the value of pic_width_in_luma_samples, pic_height_in_luma_samples, chroma_format_idc,
     1531      //  separate_colour_plane_flag, bit_depth_luma_minus8, bit_depth_chroma_minus8 or sps_max_dec_pic_buffering_minus1[ HighestTid ]
     1532      //  derived from the active SPS is different from the value of pic_width_in_luma_samples, pic_height_in_luma_samples,
     1533      //  chroma_format_idc, separate_colour_plane_flag, bit_depth_luma_minus8, bit_depth_chroma_minus8 or
     1534      //  sps_max_dec_pic_buffering_minus1[ HighestTid ], respectively, derived from the SPS active for the preceding picture,
     1535      //  NoOutputOfPriorPicsFlag may (but should not) be set to 1 by the decoder under test,
     1536      //  regardless of the value of no_output_of_prior_pics_flag.
     1537      //     NOTE - Although setting NoOutputOfPriorPicsFlag equal to no_output_of_prior_pics_flag is preferred under these conditions,
     1538      //            the decoder under test is allowed to set NoOutputOfPriorPicsFlag to 1 in this case.
     1539    }
     1540    else
     1541    {
     1542      noOutputOfPriorPicsFlag = m_curPic->getSlice(0)->getNoOutputPriorPicsFlag();
     1543    }
     1544    //  2.  The value of NoOutputOfPriorPicsFlag derived for the decoder under test is applied for the HRD as follows:
     1545    if (noOutputOfPriorPicsFlag)
     1546    {
     1547      //-  If NoOutputOfPriorPicsFlag is equal to 1, all picture storage buffers in the DPB are emptied
     1548      //   without output of the pictures they contain and the DPB fullness is set equal to 0.
     1549      m_dpb.emptySubDpb( nuhLayerId );
     1550    }
     1551    else if (!noOutputOfPriorPicsFlag)
     1552    {
     1553      //  -  Otherwise (NoOutputOfPriorPicsFlag is equal to 0), all picture storage buffers containing a picture that
     1554      //     is marked as "not needed for output" and "unused for reference" are emptied (without output) and all non-empty
     1555      //     picture storage buffers in the DPB are emptied by repeatedly invoking the "bumping" process specified in clause C.5.2.4
     1556      //     and the DPB fullness is set equal to 0.
     1557
     1558      m_dpb.emptySubDpbNotNeedForOutputAndUnusedForRef( nuhLayerId );
     1559      while( m_dpb.getSubDpb( nuhLayerId, false  )->size() != 0 )
     1560      {
     1561        xC524Bumping();
     1562      }
     1563    }
     1564  }
     1565  else if ( !( m_curPic->isIrap() && m_curPic->getNoRaslOutputFlag() == 0 ) )
     1566  {
     1567    //  -  Otherwise (the current picture is not an IRAP picture with NoRaslOutputFlag equal to 1),
     1568    //     all picture storage buffers containing a picture which are marked as "not needed for output" and "unused for reference"
     1569    //     are emptied (without output). For each picture storage buffer that is emptied, the DPB fullness is decremented by one.
     1570
     1571    m_dpb.emptySubDpbNotNeedForOutputAndUnusedForRef( nuhLayerId );
     1572
     1573    Bool repeat = true;
     1574
     1575    while( repeat )
     1576    {
     1577      TComSubDpb* dpb = m_dpb.getSubDpb( nuhLayerId, false );
     1578      TComList<TComPic*> picsMarkedForOutput = dpb->getPicsMarkedNeedForOutput();
     1579      // When one or more of the following conditions are true, the "bumping" process specified in clause C.5.2.4
     1580      // is invoked repeatedly while further decrementing the DPB fullness by one for each additional picture storage buffer that
     1581      // is emptied, until none of the following conditions are true:
     1582
     1583      // -  The number of pictures in the DPB that are marked as "needed for output" is greater
     1584      //    than sps_max_num_reorder_pics[ HighestTid ].
     1585      Bool cond1 = ( picsMarkedForOutput.size() > sps->getSpsMaxNumReorderPics( m_highestTid ) );
     1586
     1587      //  -  sps_max_latency_increase_plus1[ HighestTid ] is not equal to 0 and there is at least one picture in the DPB
     1588      //     that is marked as "needed for output" for which the associated variable PicLatencyCount is greater than or equal
     1589      //     to SpsMaxLatencyPictures[ HighestTid ].
     1590      Bool anyPicWithGtOrEqLatencyCnt = false;
     1591      for (TComList<TComPic*>::iterator itP = picsMarkedForOutput.begin(); itP != picsMarkedForOutput.end() && !anyPicWithGtOrEqLatencyCnt; itP++ )
     1592      {
     1593        anyPicWithGtOrEqLatencyCnt = anyPicWithGtOrEqLatencyCnt || ( (*itP)->getPicLatencyCount() >= sps->getSpsMaxLatencyPictures( m_highestTid ));
     1594      }
     1595      Bool cond2 = ( sps->getSpsMaxLatencyIncreasePlus1( m_highestTid ) != 0 ) && anyPicWithGtOrEqLatencyCnt;
     1596
     1597      //  -  The number of pictures in the DPB is greater than or equal to sps_max_dec_pic_buffering_minus1[ HighestTid ] + 1.
     1598      Bool cond3 = ( dpb->size() >= ( sps->getSpsMaxDecPicBufferingMinus1( m_highestTid ) + 1 ));
     1599
     1600      if ( cond1 || cond2 || cond3 )
     1601      {
     1602        xC524Bumping();
     1603      }
     1604      else
     1605      {
     1606        repeat = false;
     1607      }
     1608    }
     1609  }
     1610}
     1611
     1612Void TAppDecTop::xC523PicDecMarkAddBumpAndStor()
     1613{
     1614  ///////////////////////////////////////////////////////////////////////////////////////
     1615  // C.5.2.3 Picture decoding, marking, additional bumping and storage 
     1616  ///////////////////////////////////////////////////////////////////////////////////////
     1617 
     1618  Int nuhLayerId = m_curPic->getLayerId();
     1619  const TComSPS* sps = m_curPic->getSlice(0)->getSPS();
     1620  // The processes specified in this clause happen instantaneously when the last decoding unit of access unit n containing the
     1621  // current picture is removed from the CPB.
     1622  if (m_curPic->getPicOutputFlag() )
     1623  {
     1624    // When the current picture has PicOutputFlag equal to 1, for each picture in the DPB that is marked as "needed for output"
     1625    // and follows the current picture in output order, the associated variable PicLatencyCount is set equal to PicLatencyCount + 1.
     1626    TComSubDpb* dpb = m_dpb.getSubDpb( nuhLayerId, false);
     1627
     1628    for (TComSubDpb::iterator itP = dpb->begin(); itP != dpb->end(); itP++)
     1629    {
     1630      TComPic* pic = (*itP);
     1631      if ( pic->getOutputMark() && pic->getPOC() > m_curPic->getPOC() )
     1632      {
     1633        pic->setPicLatencyCount( pic->getPicLatencyCount() + 1 );
     1634      }
     1635    }
     1636  }
     1637
     1638  // The current picture is considered as decoded after the last decoding unit of the picture is decoded.
     1639  // The current decoded picture is stored in an empty picture storage buffer in the DPB and the following applies:
     1640  m_dpb.addNewPic( m_curPic );
     1641
     1642
     1643  if (m_curPic->getPicOutputFlag())
     1644  {
     1645    // - If the current decoded picture has PicOutputFlag equal to 1, it is marked as "needed for output" and its associated
     1646    //   variable PicLatencyCount is set equal to 0.
     1647    m_curPic->setOutputMark( true );
     1648    m_curPic->setPicLatencyCount( 0 );
     1649  }
     1650  else if (!m_curPic->getPicOutputFlag() )
     1651  {
     1652    // - Otherwise (the current decoded picture has PicOutputFlag equal to 0), it is marked as "not needed for output".
     1653    m_curPic->setOutputMark( false );
     1654  }
     1655
     1656  // The current decoded picture is marked as "used for short-term reference".
     1657  m_curPic->markAsUsedForShortTermReference();
     1658
     1659  Bool repeat = true;
     1660
     1661  while( repeat )
     1662  {
     1663    TComSubDpb* dpb = m_dpb.getSubDpb( nuhLayerId, false );
     1664    TComList<TComPic*> picsMarkedForOutput = dpb->getPicsMarkedNeedForOutput();
     1665
     1666    // When one or more of the following conditions are true, the "bumping" process specified in clause C.5.2.4
     1667    // is invoked repeatedly until none of the following conditions are true:
     1668
     1669    // - The number of pictures in the DPB that are marked as "needed for output" is greater than sps_max_num_reorder_pics[ HighestTid ].
     1670    Bool cond1 = ( picsMarkedForOutput.size() > sps->getSpsMaxNumReorderPics( m_highestTid ) );
     1671
     1672    // - sps_max_latency_increase_plus1[ HighestTid ] is not equal to 0 and there is at least one picture in the DPB that is marked
     1673    //   as "needed for output" for which the associated variable PicLatencyCount that is greater than or equal to
     1674    //   SpsMaxLatencyPictures[ HighestTid ].
     1675    Bool anyPicWithGtOrEqLatencyCnt = false;
     1676    for (TComList<TComPic*>::iterator itP = picsMarkedForOutput.begin(); itP != picsMarkedForOutput.end() && !anyPicWithGtOrEqLatencyCnt; itP++ )
     1677    {
     1678      anyPicWithGtOrEqLatencyCnt = anyPicWithGtOrEqLatencyCnt || ( (*itP)->getPicLatencyCount() >= sps->getSpsMaxLatencyPictures( m_highestTid ));
     1679    }
     1680    Bool cond2 = ( sps->getSpsMaxLatencyIncreasePlus1( m_highestTid ) != 0 ) && anyPicWithGtOrEqLatencyCnt;
     1681
     1682    if ( cond1 || cond2 )
     1683    {
     1684      xC524Bumping();
     1685    }
     1686    else
     1687    {
     1688      repeat = false;
     1689    }
     1690  }
     1691}
     1692
     1693Void TAppDecTop::xC524Bumping( )
     1694{
     1695  ////////////////////////////////////////////////////////////////////////////////
     1696  // C.5.2.4 "Bumping" process
     1697  ////////////////////////////////////////////////////////////////////////////////
     1698
     1699  // The "bumping" process consists of the following ordered steps:
     1700
     1701  // 1.  The picture that is first for output is selected as the one having the smallest value of PicOrderCntVal of all pictures
     1702  //     in the DPB marked as "needed for output".
     1703  TComPic* pic = *(m_dpb.getSubDpb( 0, false)->getPicsMarkedNeedForOutput().begin()); // pics are sorted, so take first
     1704
     1705  // 2.  The picture is cropped, using the conformance cropping window specified in the active SPS for the picture,
     1706  //     the cropped picture is output, and the picture is marked as "not needed for output".
     1707  xCropAndOutput( pic );
     1708  pic->setOutputMark( false );
     1709
     1710  //3.  When the picture storage buffer that included the picture that was cropped and output contains a picture marked
     1711  //    as "unused for reference", the picture storage buffer is emptied.
     1712  if (pic->getMarkedUnUsedForReference() )
     1713  {
     1714    m_dpb.removePic( pic );
     1715  }
     1716
     1717  // NOTE - For any two pictures picA and picB that belong to the same CVS and are output by the "bumping process", when picA
     1718  //        is output earlier than picB, the value of PicOrderCntVal of picA is less than the value of PicOrderCntVal of picB.
     1719}
     1720
     1721
     1722Void TAppDecTop::xF813ComDecProcForACodedPic( DecProcPart curPart, Bool picPosInAuIndication )
     1723{
     1724  ////////////////////////////////////////////////////////////////////////////////
     1725  // F.8.1.3  Common decoding process for a coded picture
     1726  ////////////////////////////////////////////////////////////////////////////////
     1727
     1728  // PicPosInAuIndication is interpreted based on curPart.
     1729  // - If curPart is equal to START_PIC               , it indicates whether the current pic is the first in the current AU.
     1730  // - Otherwise (if curPart is equal to FINALIZE_PIC), it indicates whether the current pic is the last  in the current AU.
     1731
     1732  if (curPart == START_PIC )
     1733  {
     1734    Bool curPicIsFirstInAu = picPosInAuIndication;
     1735
     1736    Int nuhLayerId = m_curPic->getLayerId();
     1737
     1738    if ( !m_vps->getVpsBaseLayerInternalFlag() && m_vps->getVpsBaseLayerAvailableFlag() &&
     1739      ( m_targetDecLayerSetIdx >= 0 && m_targetDecLayerSetIdx <= m_vps->getVpsNumLayerSetsMinus1() ) &&
     1740      m_curPic->getSlice(0)->getTemporalId() <= m_vps->getSubLayersVpsMaxMinus1( 0 ) && curPicIsFirstInAu )
     1741    {
     1742      // When vps_base_layer_internal_flag is equal to 0, vps_base_layer_available_flag is equal to 1,
     1743      // TargetDecLayerSetIdx is in the range of 0 to vps_num_layer_sets_minus1, inclusive,
     1744      // TemporalId is less than or equal to sub_layers_vps_max_minus1[ 0 ], and the current picture
     1745      // is the first coded picture of an access unit, clause F.8.1.8 is invoked prior to decoding the current picture.
     1746
     1747      assert( false ); //TBD
     1748    }
     1749
     1750    //  When the current picture is an IRAP picture, the variable HandleCraAsBlaFlag is derived as specified in the following:
     1751    if ( m_curPic->isIrap() )
     1752    {
     1753      if ( m_handleCraAsBlaFlagSetByExtMeans )
     1754      {
     1755        // If some external means not specified in this Specification is available to set the variable HandleCraAsBlaFlag to
     1756        // a value for the current picture, the variable HandleCraAsBlaFlag is set equal to the value provided by the external means.
     1757      }
     1758      else
     1759      {
     1760        // - Otherwise, the variable HandleCraAsBlaFlag is set equal to 0.
     1761        m_handleCraAsBlaFlag = false;
     1762      }
     1763    }
     1764
     1765    if ( m_curPic->isIrap() && nuhLayerId == m_smallestLayerId )
     1766    {
     1767      // When the current picture is an IRAP picture and has nuh_layer_id equal to SmallestLayerId, the following applies:
     1768      // The variable NoClrasOutputFlag is specified as follows:
     1769
     1770      if( m_firstSliceInBitstream )
     1771      {
     1772        //  - If the current picture is the first picture in the bitstream, NoClrasOutputFlag is set equal to 1.
     1773        m_curPic->setNoClrasOutputFlag(true );
     1774      }
     1775      else if( m_eosInLayer[ 0 ] || m_eosInLayer[ nuhLayerId ] )
     1776      {
     1777        //  - Otherwise, if the current picture is included in the first access unit that follows an access unit
     1778        //    including an end of sequence NAL unit with nuh_layer_id equal to SmallestLayerId or 0 in decoding order,
     1779        //    NoClrasOutputFlag is set equal to 1.
     1780
     1781        m_curPic->setNoClrasOutputFlag(true );
     1782      }
     1783      else if ( m_curPic->isBla() || (m_curPic->isCra() && m_handleCraAsBlaFlag ))
     1784      {
     1785        //  - Otherwise, if the current picture is a BLA picture or a CRA picture with HandleCraAsBlaFlag equal to 1,
     1786        //    NoClrasOutputFlag is set equal to 1.
     1787        m_curPic->setNoClrasOutputFlag(true );
     1788      }
     1789      else if ( m_curPic->isIdr() && m_curPic->getSlice(0)->getCrossLayerBlaFlag() )
     1790      {
     1791        //  - Otherwise, if the current picture is an IDR picture with cross_layer_bla_flag is equal to 1,
     1792        //    NoClrasOutputFlag is set equal to 1.
     1793        m_curPic->setNoClrasOutputFlag(true );
     1794      }
     1795      else if ( m_noClrasOutputFlagSetByExtMeans )
     1796      {
     1797        m_curPic->setNoClrasOutputFlag( m_noClrasOutputFlag );
     1798        //  - Otherwise, if some external means, not specified in this Specification, is available to set NoClrasOutputFlag,
     1799        //    NoClrasOutputFlag is set by the external means.
     1800      }
     1801      else
     1802      {
     1803        //  - Otherwise, NoClrasOutputFlag is set equal to 0.
     1804        m_curPic->setNoClrasOutputFlag(false );
     1805      }
     1806
     1807      //-  When NoClrasOutputFlag is equal to 1, the variable LayerInitializedFlag[ i ] is set equal to 0 for all values
     1808      //  of i from 0 to vps_max_layer_id, inclusive, and the variable FirstPicInLayerDecodedFlag[ i ] is set equal to 0
     1809      //  for all values of i from 0 to vps_max_layer_id, inclusive.
     1810      if ( m_curPic->getNoClrasOutputFlag( ) )
     1811      {
     1812        for (Int i = 0; i <= m_vps->getVpsMaxLayerId(); i++)
     1813        {
     1814          m_layerInitilizedFlag       [i] = false;
     1815          m_firstPicInLayerDecodedFlag[i] = false;
     1816        }
     1817      }
     1818    }
     1819
     1820    // The variables LayerResetFlag and dolLayerId are derived as follows:
     1821    Int dolLayerId = -1;
     1822    if ( m_curPic->isIrap() && nuhLayerId > m_smallestLayerId )
     1823    {
     1824      // - If the current picture is an IRAP picture and has nuh_layer_id nuhLayerId greater than SmallestLayerId,
     1825      //   the following applies:
     1826
     1827      if( m_eosInLayer[ nuhLayerId ] )
     1828      {
     1829        // -  If the current picture is the first picture, in decoding order, that follows an end of sequence NAL unit with
     1830        //    nuh_layer_id equal to nuhLayerId, LayerResetFlag is set equal to 1 and dolLayerId is set equal to the nuh_layer_id
     1831        //    value of the current NAL unit.
     1832
     1833        m_layerResetFlag = true;
     1834        dolLayerId = nuhLayerId;
     1835      }
     1836      else  if( ( m_curPic->isCra() && m_handleCraAsBlaFlag ) ||
     1837        (m_curPic->isIdr() && m_curPic->getSlice(0)->getCrossLayerBlaFlag() ) || m_curPic->isBla() )
     1838      {
     1839        // - Otherwise, if the current picture is a CRA picture with HandleCraAsBlaFlag equal to 1, an IDR picture with
     1840        //   cross_layer_bla_flag is equal to 1 or a BLA picture, LayerResetFlag is set equal to 1 and dolLayerId is set
     1841        //   equal to the nuh_layer_id value of the current NAL unit.
     1842        m_layerResetFlag = true;
     1843        dolLayerId = nuhLayerId;
     1844      }
     1845      else
     1846      {
     1847        // -   Otherwise, LayerResetFlag is set equal to 0.
     1848        m_layerResetFlag = false;
     1849      }
     1850
     1851      // NOTE 1 - An end of sequence NAL unit, a CRA picture with HandleCraAsBlaFlag equal to 1, an IDR picture with
     1852      // cross_layer_bla_flag equal to 1, or a BLA picture, each with nuh_layer_id nuhLayerId greater than SmallestLayerId,
     1853      // may be present to indicate a discontinuity of the layer with nuh_layer_id equal to nuhLayerId and its predicted layers.
     1854
     1855      if (m_layerResetFlag )
     1856      {
     1857        //When LayerResetFlag is equal to 1, the following applies:
     1858        //  - The values of LayerInitializedFlag and FirstPicInLayerDecodedFlag are updated as follows:
     1859
     1860        for( Int i = 0; i < m_vps->getNumPredictedLayers( dolLayerId ); i++ )
     1861        {
     1862          Int iLayerId = m_vps->getIdPredictedLayer(  dolLayerId , i );
     1863          m_layerInitilizedFlag       [ iLayerId ] = false;
     1864          m_firstPicInLayerDecodedFlag[ iLayerId ] = false;
     1865        }
     1866
     1867        //  - Each picture that is in the DPB and has nuh_layer_id equal to dolLayerId is marked as "unused for reference".
     1868        m_dpb.markSubDpbAsUnusedForReference( dolLayerId );
     1869
     1870        //  - When NumPredictedLayers[ dolLayerId ] is greater than 0, each picture that is in the DPB and has nuh_layer_id
     1871        //    equal to any value of IdPredictedLayer[ dolLayerId ][ i ] for the values of i in the range of 0 to
     1872        //    NumPredictedLayers[ dolLayerId ] - 1, inclusive, is marked as "unused for reference".
     1873
     1874        for( Int i = 0; i <= m_vps->getNumPredictedLayers( dolLayerId )- 1; i++  )
     1875        {
     1876          m_dpb.markSubDpbAsUnusedForReference( m_vps->getIdPredictedLayer( dolLayerId, i ) );
     1877        }
     1878      }
     1879    }
     1880    else
     1881    {
     1882      // - Otherwise, LayerResetFlag is set equal to 0.
     1883      m_layerResetFlag = false;
     1884    }
     1885
     1886    if ( m_curPic->isIrap() )
     1887    {
     1888      // When the current picture is an IRAP picture, the following applies:
     1889
     1890      if ( m_curPic->isIdr() || m_curPic->isBla() || m_curPic->getDecodingOrder() == 0 || m_eosInLayer[nuhLayerId] )
     1891      {
     1892        // - If the current picture with a particular value of nuh_layer_id is an IDR picture, a BLA picture, the first picture
     1893        //   with that particular value of nuh_layer_id in the bitstream in decoding order or the first picture with that
     1894        //   particular value of nuh_layer_id that follows an end of sequence NAL unit with that particular value of nuh_layer_id
     1895        //   in decoding order, the variable NoRaslOutputFlag is set equal to 1.
     1896
     1897        m_curPic->setNoRaslOutputFlag(  true );
     1898      }
     1899      else if ( m_layerInitilizedFlag[ nuhLayerId ] == 0 && xAllRefLayersInitilized( nuhLayerId ) )
     1900      {
     1901        // Otherwise, if LayerInitializedFlag[ nuh_layer_id ] is equal to 0 and LayerInitializedFlag[ refLayerId ] is equal to 1
     1902        // for all values of refLayerId equal to IdDirectRefLayer[ nuh_layer_id ][ j ], where j is in the range of 0 to
     1903        // NumDirectRefLayers[ nuh_layer_id ] - 1, inclusive, the variable NoRaslOutputFlag is set equal to 1.
     1904
     1905        m_curPic->setNoRaslOutputFlag(  true );
     1906      }
     1907      else
     1908      {
     1909        // - Otherwise, the variable NoRaslOutputFlag is set equal to HandleCraAsBlaFlag.
     1910        m_curPic->setNoRaslOutputFlag(  m_handleCraAsBlaFlag );
     1911      }
     1912    }
     1913
     1914    // The following applies for the decoding of the current picture:
     1915    if ( m_curPic->isIrap() && m_curPic->getNoRaslOutputFlag() && (
     1916      ( nuhLayerId == 0 ) ||
     1917      ( m_layerInitilizedFlag[ nuhLayerId ] == 0   && m_vps->getNumDirectRefLayers( nuhLayerId ) == 0  ) ||
     1918      ( m_layerInitilizedFlag[ nuhLayerId ] == 0 && xAllRefLayersInitilized( nuhLayerId ) )
     1919      ) )
     1920    {
     1921      // When the current picture is an IRAP picture with NoRaslOutputFlag equal to 1 and one of the following conditions is true,
     1922      // LayerInitializedFlag[ nuh_layer_id ] is set equal to 1:
     1923      // - nuh_layer_id is equal to 0.
     1924      // - LayerInitializedFlag[ nuh_layer_id ] is equal to 0 and NumDirectRefLayers[ nuh_layer_id ] is equal to 0.
     1925      // - LayerInitializedFlag[ nuh_layer_id ] is equal to 0 and LayerInitializedFlag[ refLayerId ] is equal to 1 for all values of
     1926      //   refLayerId equal to IdDirectRefLayer[ nuh_layer_id ][ j ], where j is in the range of 0 to NumDirectRefLayers[ nuh_layer_id ] - 1, inclusive.
     1927
     1928      m_layerInitilizedFlag[ nuhLayerId ] = true;
     1929    }
     1930
     1931    // The following applies for the decoding of the current picture:
     1932
     1933    if ( nuhLayerId == 0 )
     1934    {
     1935      //  If the current picture has nuh_layer_id equal to 0, the decoding process for the current picture takes as inputs the syntax elements
     1936      //  and upper-case variables from clause F.7 and the decoding process for a coded picture with nuh_layer_id equal to 0 as specified in clause F.8.1.4
     1937      //  is invoked.
     1938
     1939      xF814decProcForCodPicWithLIdZero( curPart );
     1940    }
     1941    else
     1942    {
     1943      Bool decodedPicWithLayerIdZeroProvided = false;
     1944      if ( !m_vps->getVpsBaseLayerInternalFlag() && m_vps->getVpsBaseLayerAvailableFlag() &&
     1945        ( m_targetDecLayerSetIdx >= 0 && m_targetDecLayerSetIdx <= m_vps->getVpsNumLayerSetsMinus1() ) &&
     1946        m_curPic->getSlice(0)->getTemporalId() <= m_vps->getSubLayersVpsMaxMinus1( 0 ) && curPicIsFirstInAu
     1947        && decodedPicWithLayerIdZeroProvided )
     1948      {
     1949        assert( false ); //TBD
     1950        //TBD: Hybrid scalability
     1951        //  When vps_base_layer_internal_flag is equal to 0, vps_base_layer_available_flag is equal to 1,
     1952        //  TargetDecLayerSetIdx is in the range of 0 to vps_num_layer_sets_minus1, inclusive,
     1953        //  TemporalId is less than or equal to sub_layers_vps_max_minus1[ 0 ], the current picture
     1954        //  is the first coded picture of an access unit, and a decoded picture with nuh_layer_id equal
     1955        //  to 0 is provided by external means for the current access unit, clause F.8.1.9 is invoked
     1956        //  after the decoding of the slice segment header of the first slice segment, in decoding order,
     1957        //  of the current picture, but prior to decoding any slice segment of the first
     1958        //  coded picture of the access unit.
     1959      }
     1960
     1961      m_decProcPocAndRps = ANNEX_F;
     1962      // For the decoding of the slice segment header of the first slice segment, in decoding order, of the current picture,
     1963      // the decoding process for starting the decoding of a coded picture with nuh_layer_id greater than 0 specified in
     1964      // clause F.8.1.5 is invoked.  --> This is done in the loop when receiving slices.
     1965
     1966      // The decoding process is already selected before.
     1967    }
     1968  }
     1969  else if( curPart == FINALIZE_PIC )
     1970  {
     1971    Bool curPicIsLastInAu = picPosInAuIndication;
     1972
     1973    if (m_curPic->getLayerId() == 0 )
     1974    {
     1975      xF814decProcForCodPicWithLIdZero( curPart );
     1976    }
     1977    else
     1978    {
     1979      // - After all slices of the current picture have been decoded, the decoding process for ending the decoding of a
     1980      //   coded picture with nuh_layer_id greater than 0 specified in clause F.8.1.6 is invoked.
     1981      xF816decProcEndDecOfCodPicLIdGrtZero( );
     1982    }
     1983
     1984    TComSlice* slice = m_curPic->getSlice(0);
     1985    const TComVPS* vps = slice->getVPS();
     1986
     1987    if ( curPicIsLastInAu )
     1988    {
     1989      //When the current picture is the last coded picture in an access unit in BitstreamToDecode, the following steps apply after
     1990      // the decoding of the current picture, prior to the decoding of the next picture:
     1991
     1992      //-  PicOutputFlag is updated as follows:
     1993      TComPic* picAtOutputLayer = NULL;
     1994      Int outputLayerId = -1;
     1995
     1996      // Try to find pic at output layer.
     1997      if( vps->getAltOutputLayerFlag( m_targetOptLayerSetIdx ) )
     1998      {
     1999        // When alt_output_layer_flag is equal to 1, the target output layer set can only contain one output layer.
     2000        assert( vps->getNumOutputLayersInOutputLayerSet( m_targetOptLayerSetIdx ) == 1 );
     2001        outputLayerId = vps->getTargetOptLayerIdList(m_targetOptLayerSetIdx)[0];
     2002        picAtOutputLayer = m_curAu.getPic( outputLayerId );
     2003      }
     2004
     2005      if ( vps->getAltOutputLayerFlag( m_targetOptLayerSetIdx ) &&
     2006        ( picAtOutputLayer == NULL || (picAtOutputLayer != NULL && !picAtOutputLayer->getPicOutputFlag() ) ) )
     2007      {
     2008        // If alt_output_layer_flag[ TargetOlsIdx ] is equal to 1 and the current access unit either does
     2009        // not contain a picture at the output layer or contains a picture at the output layer that has PicOutputFlag equal to 0:
     2010
     2011        // - The list nonOutputLayerPictures is set to be the list of the pictures of the access unit with PicOutputFlag equal to 1 and
     2012        //   with nuh_layer_id values among the nuh_layer_id values of the reference layers of the output layer.
     2013        TComList<TComPic*> nonOutputLayerPictures;
     2014        for( TComList<TComPic*>::iterator itP= m_curAu.begin();  itP != m_curAu.end() ; itP++ )
     2015        {
     2016          TComPic* pic = (*itP);
     2017          Bool isRefernceLayerOfOutputLayer = false;
     2018          for ( Int i = 0; i < vps->getNumRefLayers( outputLayerId ) && !isRefernceLayerOfOutputLayer; i++ )
     2019          {
     2020            if ( pic->getLayerId() == vps->getIdRefLayer(outputLayerId, i) )
     2021            {
     2022              isRefernceLayerOfOutputLayer = true;
     2023            }
     2024          }
     2025
     2026          if ( pic->getPicOutputFlag() && isRefernceLayerOfOutputLayer )
     2027          {
     2028            nonOutputLayerPictures.pushBack( pic );
     2029          }
     2030        }
     2031
     2032
     2033        if (nonOutputLayerPictures.size() != 0 )
     2034        {
     2035          // -  When the list nonOutputLayerPictures is not empty,
     2036          //    The picture with the highest nuh_layer_id value among the list nonOutputLayerPictures is removed from the list nonOutputLayerPictures.
     2037          //    As in AU the picture with the highest layer id is the last
     2038          nonOutputLayerPictures.pop_back();
     2039        }
     2040
     2041        //  -  PicOutputFlag for each picture that is included in the list nonOutputLayerPictures is set equal to 0.
     2042        for( TComList<TComPic*>::iterator itP= nonOutputLayerPictures.begin();  itP != nonOutputLayerPictures.end() ; itP++ )
     2043        {
     2044          (*itP)->setPicOutputFlag( false );
     2045        }
     2046      }
     2047      else
     2048      {
     2049        //Otherwise, PicOutputFlag for pictures that are not included in an output layer is set equal to 0.
     2050        for( TComList<TComPic*>::iterator itP= m_curAu.begin();  itP != m_curAu.end() ; itP++ )
     2051        {
     2052          TComPic* pic = (*itP);
     2053
     2054          Bool includedInOutputLayer = false;
     2055          for (Int i = 0 ; i < vps->getNumOutputLayersInOutputLayerSet( m_targetOptLayerSetIdx ) && !includedInOutputLayer; i++)
     2056          {
     2057            includedInOutputLayer = ( pic->getLayerId() ==  vps->getTargetOptLayerIdList(m_targetOptLayerSetIdx)[i]);
     2058          }
     2059
     2060          if ( !includedInOutputLayer )
     2061          {
     2062            pic->setPicOutputFlag( false );
     2063          }
     2064        }
     2065      }
     2066
     2067      // When vps_base_layer_internal_flag is equal to 0, vps_base_layer_available_flag is equal to 1 and
     2068      // TargetDecLayerSetIdx is in the range of 0 to vps_num_layer_sets_minus1, inclusive
     2069
     2070      if( !vps->getVpsBaseLayerInternalFlag() && vps->getVpsBaseLayerAvailableFlag() && ( m_targetDecLayerSetIdx >= 0 && m_targetDecLayerSetIdx <= vps->getVpsNumLayerSetsMinus1()   ) )
     2071      {
     2072        if( !m_baseLayerOutputFlag )
     2073        {
     2074          // Check if base layer is a reference layer of the output layer
     2075          // and if the access unit does not contain a picture at any other reference layer of the output layer
     2076          Bool baseLayerIsRefOfOutputLayer = false;
     2077          Bool auDoesNotContainPicAtAnyOtherRefLayerOfOptLayer = true;
     2078          if ( vps->getAltOutputLayerFlag( m_targetOptLayerSetIdx ))
     2079          {
     2080            assert( outputLayerId >= 0 );
     2081
     2082            for (Int i = 0; i < vps->getNumRefLayers( outputLayerId ); i++ )
     2083            {
     2084              Int refLayerId = vps->getIdRefLayer(outputLayerId, i);
     2085              if( refLayerId == 0 )
     2086              {
     2087                baseLayerIsRefOfOutputLayer = true;
     2088              }
     2089              else
     2090              {
     2091                if ( m_curAu.getPic( refLayerId ) != NULL )
     2092                {
     2093                  auDoesNotContainPicAtAnyOtherRefLayerOfOptLayer = false;
     2094                }
     2095              }
     2096            }
     2097          }
     2098
     2099          // If alt_output_layer_flag[ TargetOlsIdx ] is equal to 1, the base layer is a reference layer of the output layer,
     2100          // the access unit does not contain a picture at the output layer or contains a picture at the output layer that has
     2101          // PicOutputFlag equal to 0, and the access unit does not contain a picture at any other reference layer of the output layer,
     2102          // BaseLayerPicOutputFlag is set equal to 1
     2103
     2104          if ( vps->getAltOutputLayerFlag( m_targetOptLayerSetIdx ) && baseLayerIsRefOfOutputLayer
     2105            && ( ( picAtOutputLayer == NULL ) || ( picAtOutputLayer != NULL && !picAtOutputLayer->getPicOutputFlag()  ) )
     2106            &&  auDoesNotContainPicAtAnyOtherRefLayerOfOptLayer )
     2107          {
     2108            m_baseLayerPicOutputFlag = true;
     2109          }
     2110          else
     2111          {
     2112            m_baseLayerPicOutputFlag = false;
     2113          }
     2114        }
     2115        else
     2116        {
     2117          m_baseLayerPicOutputFlag = true;
     2118        }
     2119
     2120        // NOTE 3 - The BaseLayerPicOutputFlag for each access unit is to be sent by an external means
     2121        // to the base layer decoder for controlling the output of base layer decoded pictures.
     2122        // BaseLayerPicOutputFlag equal to 1 for an access unit specifies that the base layer picture of the access unit is to be output.
     2123        // BaseLayerPicOutputFlag equal to 0 for an access unit specifies that the base layer picture of the access unit is not to be output.
     2124
     2125        //  The sub-DPB for the layer with nuh_layer_id equal to 0 is set to be empty.
     2126        m_dpb.emptySubDpb( 0 );
     2127      }
     2128
     2129      // The variable AuOutputFlag that is associated with the current access unit is derived as follows:
     2130
     2131      // Derive if at least one picture in the current access unit has PicOutputFlag equal to 1
     2132      Bool atLeastOnePicInAuWithPicOptFlagOne = false;
     2133      for( TComList<TComPic*>::iterator itP= m_curAu.begin();  itP != m_curAu.end() ; itP++ )
     2134      {
     2135        if ( (*itP)->getPicOutputFlag() )
     2136        {
     2137          atLeastOnePicInAuWithPicOptFlagOne = true;
     2138        }
     2139      }
     2140
     2141      //If at least one picture in the current access unit has PicOutputFlag equal to 1
     2142      if ( atLeastOnePicInAuWithPicOptFlagOne )
     2143      {
     2144        m_auOutputFlag = true;
     2145      }
     2146      else
     2147      {
     2148        m_auOutputFlag = false;
     2149      }
     2150
     2151      // The variable PicLatencyCount that is associated with the current access unit is set equal to 0.
     2152      m_curAu.setPicLatencyCount( 0 );
     2153
     2154
     2155      if ( m_auOutputFlag )
     2156      {
     2157        // for each access unit in the DPB
     2158        // that has at least one picture marked as "needed for output" and
     2159        // follows the current access unit in output order, the associated
     2160        // variable PicLatencyCount is set equal to PicLatencyCount + 1.
     2161
     2162        TComList<TComAu*> aus = m_dpb.getAusHavingPicsMarkedForOutput(); // <-- current AU is actually not yet in DPB, but this does not matter here.
     2163
     2164        for(TComList<TComAu*>::iterator itA= aus.begin(); ( itA!=aus.end()); itA++)
     2165        {
     2166          if( m_curAu.getPoc() < (*itA)->getPoc())
     2167          {
     2168            (*itA)->setPicLatencyCount( (*itA)->getPicLatencyCount() + 1 );
     2169          }
     2170        }
     2171      }
     2172    }
     2173  }
     2174}
     2175
     2176Void TAppDecTop::xF814decProcForCodPicWithLIdZero( DecProcPart curPart )
     2177{
     2178  ////////////////////////////////////////////////////////////////////////////////
     2179  // F.8.1.4 Decoding process for a coded picture with nuh_layer_id equal to 0
     2180  ////////////////////////////////////////////////////////////////////////////////
     2181
     2182  x813decProcForCodPicWithLIdZero( curPart );
     2183
     2184  if (curPart == START_PIC )
     2185  {
     2186    m_decProcPocAndRps = ANNEX_F;
     2187  }
     2188  else if (curPart == FINALIZE_PIC )
     2189  {
     2190    if ( !m_firstPicInLayerDecodedFlag[0] )
     2191    {
     2192      m_firstPicInLayerDecodedFlag[0] = true;
     2193    }
     2194  }
     2195}
     2196
     2197Void TAppDecTop::xF13521InitDpb()
     2198{
     2199  ////////////////////////////////////////////////////////////////////////////////
     2200  // F.13.5.2.1 General
     2201  ////////////////////////////////////////////////////////////////////////////////
     2202
     2203  const TComDpbSize* dpbSize = m_vps->getDpbSize();
     2204  m_maxNumReorderPics       = dpbSize->getMaxVpsNumReorderPics      ( m_targetOptLayerSetIdx, m_highestTid );
     2205  m_maxLatencyIncreasePlus1 = dpbSize->getMaxVpsLatencyIncreasePlus1( m_targetOptLayerSetIdx, m_highestTid );
     2206  m_maxLatencyValue         = dpbSize->getVpsMaxLatencyPictures     ( m_targetOptLayerSetIdx, m_highestTid );
     2207
     2208  for(Int i = 0; i < MAX_NUM_LAYER_IDS; i++)
     2209  {
     2210    m_maxDecPicBufferingMinus1[ i ] = MIN_INT;
     2211  }
     2212  for( Int i = 0; i <= m_vps->getMaxLayersMinus1(); i++ )
     2213  {
     2214    Int currLayerId = m_vps->getLayerIdInNuh( i );
     2215    for(Int layerIdx = 0 ; layerIdx < m_vps->getNumLayersInIdList( m_targetDecLayerSetIdx); layerIdx++ )
     2216    {
     2217      if( m_vps->getLayerSetLayerIdList( m_targetDecLayerSetIdx, layerIdx ) == currLayerId )
     2218      {
     2219        m_maxDecPicBufferingMinus1[currLayerId] = dpbSize->getMaxVpsDecPicBufferingMinus1( m_targetDecLayerSetIdx, layerIdx, m_highestTid );
     2220      }
     2221    }
     2222  }
     2223}
     2224
     2225Void TAppDecTop::xF13522OutputAndRemOfPicsFromDpb( Bool beforePocDerivation )
     2226{
     2227  ////////////////////////////////////////////////////////////////////////////////
     2228  // F.13.5.2.2 Output and removal of pictures from the DPB
     2229  ////////////////////////////////////////////////////////////////////////////////
     2230
     2231  if( beforePocDerivation )
     2232  {
     2233    // F.13.5.2.2
     2234    // Part before POC and RPS derivation.
     2235
     2236    if( m_curPic->getDecodingOrder() != 0 )
     2237    {
     2238      // When the current picture is not picture 0 in the current layer,
     2239      // the output and removal of pictures in the current layer, with nuh_layer_id equal to currLayerId,
     2240      // from the DPB before the decoding of the current picture, i.e., picture n, but after parsing the
     2241      // slice header of the first slice of the current picture and before the invocation of the decoding
     2242      // process for picture order count, happens instantaneously when the first decoding unit of the current
     2243      // picture is removed from the CPB and proceeds as follows:
     2244
     2245      if( m_curPic->getIsPocResettingPic() )
     2246      {
     2247        // When the current picture is a POC resetting picture, all pictures in the DPB that do
     2248        // not belong to the current access unit and that are marked as "needed for output" are
     2249        // output, starting with pictures with the smallest value of PicOrderCntVal of all pictures
     2250        // excluding those in the current access unit in the DPB, in ascending order of the PicOrderCntVal
     2251        // values, and pictures with the same value of PicOrderCntVal are output in ascending order
     2252        // of the nuh_layer_id values. When a picture is output, it is cropped using the conformance cropping
     2253        // window specified in the active SPS for the picture, the cropped picture is output, and
     2254        // the picture is marked as "not needed for output"
     2255
     2256        TComList<TComAu*>* aus = m_dpb.getAus(); // Theses are sorted by POC.
     2257        for (TComList<TComAu*>::iterator itA = aus->begin(); itA != aus->end(); itA++ )
     2258        {
     2259          //Pictures in AUs are sorted by nuh_layer_id;
     2260          for (TComAu::iterator itP = (*itA)->begin(); itP != (*itA)->end(); itP++ )
     2261          {
     2262            TComPic* pic = (*itP);
     2263            if ( !m_curAu.containsPic( pic ) )
     2264            {
     2265              xCropAndOutput( pic );
     2266              pic->setOutputMark( false );
     2267            }
     2268          }
     2269        }
     2270      }
     2271    }
     2272  }
     2273  else if ( !beforePocDerivation )
     2274  {
     2275    //  The variable listOfSubDpbsToEmpty is derived as follows:
     2276
     2277    Int nuhLayerId = m_curPic->getLayerId();
     2278    TComList<TComSubDpb*> listOfSubDpbsToEmpty;
     2279
     2280    if ( m_newVpsActivatedbyCurAu && ( m_curPic->isIrap()&& nuhLayerId == m_smallestLayerId
     2281      && m_curPic->getNoRaslOutputFlag() && m_curPic->getNoClrasOutputFlag() ) )
     2282    {
     2283      // If a new VPS is activated by the current access unit or the current picture is IRAP picture
     2284      // with nuh_layer_id equal to SmallestLayerId,   NoRaslOutputFlag equal to 1, and NoClrasOutputFlag equal to 1,
     2285      // listOfSubDpbsToEmpty is set equal to all the sub-DPBs.
     2286      listOfSubDpbsToEmpty = (*m_dpb.getSubDpbs());
     2287    }
     2288    else if (m_curPic->isIrap() && m_vps->getNumDirectRefLayers( nuhLayerId ) == 0 &&
     2289      nuhLayerId > m_smallestLayerId && m_curPic->getNoRaslOutputFlag() && m_layerResetFlag  )
     2290    {
     2291      // Otherwise, if the current picture is an IRAP picture with any nuh_layer_id value indepLayerId
     2292      // such that NumDirectRefLayers[ indepLayerId ] is equal to 0 and indepLayerId is greater than
     2293      // SmallestLayerId, and with NoRaslOutputFlag equal to 1, and LayerResetFlag is equal to 1,
     2294
     2295      // listOfSubDpbsToEmpty is set equal to the sub-DPBs containing the current layer and the sub-DPBs
     2296      // containing the predicted layers of the current layer.
     2297
     2298      listOfSubDpbsToEmpty.pushBack( m_dpb.getSubDpb( nuhLayerId, false  ) );
     2299      for( Int i = 0; i < m_vps->getNumPredictedLayers( nuhLayerId ); i++  )
     2300      {
     2301        listOfSubDpbsToEmpty.pushBack( m_dpb.getSubDpb( m_vps->getIdPredictedLayer( nuhLayerId, i), false  ) );
     2302      }
     2303    }
     2304    else
     2305    {
     2306      // Otherwise, crossLayerBufferEmptyFlag is set equal to 0.
     2307
     2308      // The SPEC seems to have an issue here. Use current subDpb as in form F.13.3.2
     2309      listOfSubDpbsToEmpty.pushBack( m_dpb.getSubDpb( nuhLayerId, false  ) );
     2310    }
     2311
     2312    // If the current picture is an IRAP picture with NoRaslOutputFlag equal to 1 and any of
     2313    // the following conditions is true:
     2314    //   - nuh_layer_id equal to SmallestLayerId,
     2315    //   - nuh_layer_id of the current layer is greater than SmallestLayerId, and NumDirectRefLayers[ nuh_layer_id ]
     2316    //     is equal to 0,
     2317
     2318    if ( m_curPic->isIrap() && m_curPic->getNoRaslOutputFlag() && (
     2319      ( nuhLayerId == m_smallestLayerId ) ||
     2320      ( ( nuhLayerId > m_smallestLayerId ) && m_vps->getNumDirectRefLayers( nuhLayerId ) == 0 ) )
     2321      )
     2322    {
     2323      // 1. The variable NoOutputOfPriorPicsFlag is derived for the decoder under test as follows:
     2324      Bool noOutputOfPriorPicsFlag;
     2325      if( m_curPic->isCra() )
     2326      {
     2327        noOutputOfPriorPicsFlag = true;
     2328        // - If the current picture is a CRA picture, NoOutputOfPriorPicsFlag is set equal to 1
     2329        // (regardless of the value of no_output_of_prior_pics_flag).
     2330      }
     2331      else if ( false )
     2332      {
     2333        // TBD
     2334        // - Otherwise, if the value of pic_width_in_luma_samples, pic_height_in_luma_samples,
     2335        //   chroma_format_idc, bit_depth_luma_minus8, bit_depth_chroma_minus8, separate_colour_plane_flag,
     2336        //   or sps_max_dec_pic_buffering_minus1[ HighestTid ] derived from the active SPS for the current
     2337        //   layer is different from the value of pic_width_in_luma_samples, pic_height_in_luma_samples,
     2338        //   chroma_format_idc, bit_depth_luma_minus8, bit_depth_chroma_minus8, separate_colour_plane_flag,
     2339        //   or sps_max_dec_pic_buffering_minus1[ HighestTid ], respectively, derived from the SPS that
     2340        //   was active for the current layer when decoding the preceding picture in the current layer,
     2341        //   NoOutputOfPriorPicsFlag may (but should not) be set equal to 1 by the decoder under test,
     2342        //   regardless of the value of no_output_of_prior_pics_flag.
     2343        //    NOTE - Although setting NoOutputOfPriorPicsFlag equal to no_output_of_prior_pics_flag is preferred
     2344        //    under these conditions, the decoder under test is allowed to set NoOutputOfPriorPicsFlag to 1 in this case.
     2345        // - Otherwise, NoOutputOfPriorPicsFlag is set equal to no_output_of_prior_pics_flag.
     2346
     2347        // assert( 1 );
     2348      }
     2349      else
     2350      {
     2351        // - Otherwise, NoOutputOfPriorPicsFlag is set equal to no_output_of_prior_pics_flag.
     2352        noOutputOfPriorPicsFlag = m_curPic->getSlice(0)->getNoOutputPriorPicsFlag();
     2353      }
     2354
     2355      // 2. The value of NoOutputOfPriorPicsFlag derived for the decoder under test is applied for the HRD as follows:
     2356      if ( !noOutputOfPriorPicsFlag )
     2357      {
     2358        // - If NoOutputOfPriorPicsFlag is equal to 0, all non-empty picture storage buffers in all the sub-DPBs included
     2359        //   in listOfSubDpbsToEmpty are output by repeatedly invoking the "bumping" process specified in clause
     2360        //   F.13.5.2.4 until all these pictures are marked as "not needed for output".
     2361
     2362        Bool repeat = true;
     2363        while (repeat )
     2364        {
     2365          Bool allPicsMarkedNotNeedForOutput = true;
     2366          for (TComList<TComSubDpb*>::iterator itS = listOfSubDpbsToEmpty.begin(); itS != listOfSubDpbsToEmpty.end() && allPicsMarkedNotNeedForOutput; itS++ )
     2367          {
     2368            allPicsMarkedNotNeedForOutput = allPicsMarkedNotNeedForOutput && ( (*itS)->areAllPicsMarkedNotNeedForOutput() );
     2369          }
     2370
     2371          if ( !allPicsMarkedNotNeedForOutput )
     2372          {
     2373            xF13524Bumping( m_dpb.getAusHavingPicsMarkedForOutput() );
     2374          }
     2375          else
     2376          {
     2377            repeat = false;
     2378          }
     2379        }
     2380      }
     2381      else
     2382      {
     2383        // - Otherwise (NoOutputOfPriorPicsFlag is equal to 1), all picture storage buffers containing a picture
     2384        //   that is marked as "not needed for output" and "unused for reference" are emptied (without output),
     2385        //   all pictures that are contained in a sub-DPB included in listOfSubDpbsToEmpty are emptied, and the sub-DPB
     2386        //   fullness of each sub-DPB is decremented by the number of picture storage buffers emptied in that sub-DPB.
     2387        m_dpb.emptyNotNeedForOutputAndUnusedForRef();
     2388
     2389        for( TComList<TComSubDpb*>::iterator iS = listOfSubDpbsToEmpty.begin(); iS != listOfSubDpbsToEmpty.end(); iS++)
     2390        {
     2391          m_dpb.emptySubDpbs( &listOfSubDpbsToEmpty );
     2392        }
     2393      }
     2394    }
     2395    else
     2396    {
     2397      // -  Otherwise, all picture storage buffers that contain a picture in the current layer and that are marked as
     2398      //   "not needed for output" and "unused for reference" are emptied (without output). For each picture storage buffer that is emptied,
     2399      //   the sub-DPB fullness is decremented by one.
     2400
     2401      m_dpb.emptySubDpbNotNeedForOutputAndUnusedForRef( nuhLayerId );
     2402
     2403      //    When one or more of the following conditions are true, the "bumping" process specified in clause F.13.5.2.4
     2404      //    is invoked repeatedly until none of the following conditions are true:
     2405
     2406      Bool repeat = true;
     2407      while ( repeat )
     2408      {
     2409        TComList<TComAu*> aus = m_dpb.getAusHavingPicsMarkedForOutput();
     2410
     2411        // The number of access units that contain at least one decoded picture in the DPB marked
     2412        // as "needed for output" is greater than MaxNumReorderPics.
     2413        Bool cond1 = ( aus.size() > m_maxNumReorderPics );
     2414
     2415        // MaxLatencyIncreasePlus1 is not equal to 0 and there is at least one access unit
     2416        // that contains at least one decoded picture in the DPB marked as "needed for output"
     2417        // for which the associated variable PicLatencyCount is greater than or equal to MaxLatencyValue.
     2418        Bool auWithGreaterLatencyCount = false;
     2419        for(TComList<TComAu*>::iterator itA= aus.begin(); ( itA!=aus.end()) && !auWithGreaterLatencyCount ; itA++)
     2420        {
     2421          if ( (*itA)->getPicLatencyCount() > m_maxLatencyValue )
     2422          {
     2423            auWithGreaterLatencyCount = true;
     2424          }
     2425        }
     2426
     2427        Bool cond2 = (m_maxLatencyIncreasePlus1 != 0 ) && auWithGreaterLatencyCount;
     2428
     2429        // The number of pictures in the sub-DPB is greater than or equal to MaxDecPicBufferingMinus1 + 1.
     2430        Bool cond3 = ( m_dpb.getSubDpb( nuhLayerId, false )->size() >= m_maxDecPicBufferingMinus1[ nuhLayerId ] + 1 );
     2431
     2432        if ( cond1  || cond2 || cond3 )
     2433        {
     2434          xF13524Bumping( aus );
     2435        }
     2436        else
     2437        {
     2438          repeat = false;
     2439        }
     2440      }
     2441    }
     2442  }
     2443}
     2444
     2445Void TAppDecTop::xF13523PicDecMarkAddBumpAndStor( Bool curPicIsLastInAu )
     2446{
     2447  ////////////////////////////////////////////////////////////////////////////////
     2448  // F.13.5.2.3 Picture decoding, marking, additional bumping and storage
     2449  ////////////////////////////////////////////////////////////////////////////////
     2450
     2451  const TComVPS* vps = m_curPic->getSlice(0)->getVPS();
     2452
     2453  // The current picture is considered as decoded after the last decoding unit of
     2454  // the picture is decoded. The current decoded picture is stored in an empty picture
     2455  // storage buffer in the sub-DPB.
     2456
     2457  m_dpb.addNewPic( m_curPic );
     2458
     2459  if ( curPicIsLastInAu )
     2460  {
     2461    // When the current picture is the last picture in an access unit, the following applies
     2462    // for each decoded picture with nuh_layer_id greater than or
     2463    // equal to ( vps_base_layer_internal_flag ? 0 : 1 ) of the access unit:
     2464
     2465    for( TComList<TComPic*>::iterator itP = m_curAu.begin(); itP != m_curAu.end(); itP++ )
     2466    {
     2467      TComPic* pic = (*itP);
     2468      if( pic->getLayerId() >= ( vps->getVpsBaseLayerInternalFlag() ? 0 : 1 ) )
     2469      {
     2470        if ( pic->getPicOutputFlag() )
     2471        {
     2472          //If the decoded picture has PicOutputFlag equal to 1, it is marked as "needed for output".
     2473          pic->setOutputMark( true );
     2474        }
     2475        else
     2476        {
     2477          // Otherwise it is marked as "not needed for output".
     2478          pic->setOutputMark( false );
     2479        }
     2480        // NOTE - Prior to investigating the conditions above, PicOutputFlag
     2481        // of each picture of the access unit is updated as specified in clause F.8.1.2.
     2482      }
     2483    }
     2484  }
     2485
     2486  // The current decoded picture is marked as "used for short-term reference".
     2487  m_curPic->markAsUsedForShortTermReference();
     2488
     2489
     2490  Bool repeat = true;
     2491  while ( repeat )
     2492  {
     2493    TComList<TComAu*> aus = m_dpb.getAusHavingPicsMarkedForOutput();
     2494
     2495    // When one or more of the following conditions are true,
     2496    // the "bumping" process specified in clause F.13.5.2.4 is invoked
     2497    // repeatedly until none of the following conditions are true:
     2498
     2499    // - The number of access units that contain at least one decoded picture in the DPB marked
     2500    //   as "needed for output" is greater than MaxNumReorderPics.
     2501    Bool cond1 = ( aus.size() > m_maxNumReorderPics );
     2502
     2503    // - MaxLatencyIncreasePlus1 is not equal to 0 and there is at least one access unit
     2504    //   that contains at least one decoded picture in the DPB marked as "needed for output"
     2505    //   for which the associated variable PicLatencyCount is greater than or equal to MaxLatencyValue.
     2506    Bool auWithGreaterLatencyCount = false;
     2507    for(TComList<TComAu*>::iterator itA= aus.begin(); ( itA!=aus.end()) && !auWithGreaterLatencyCount ; itA++)
     2508    {
     2509      if ( (*itA)->getPicLatencyCount() > m_maxLatencyValue )
     2510      {
     2511        auWithGreaterLatencyCount = true;
     2512      }
     2513    }
     2514
     2515    Bool cond2 = (m_maxLatencyIncreasePlus1 != 0 ) && auWithGreaterLatencyCount;
     2516
     2517    if ( cond1  || cond2 )
     2518    {
     2519      xF13524Bumping( aus );
     2520    }
     2521    else
     2522    {
     2523      repeat = false;
     2524    }
     2525  }
     2526}
     2527
     2528Void TAppDecTop::xF13524Bumping( TComList<TComAu*> aus )
     2529{
     2530  ////////////////////////////////////////////////////////////////////////////////
     2531  // F.13.5.2.4 "Bumping" process
     2532  ////////////////////////////////////////////////////////////////////////////////
     2533
     2534  // The picture or pictures that are first for output are selected as the ones having the
     2535  // smallest value of PicOrderCntVal of all pictures in the DPB marked as "needed for output".
     2536
     2537  assert( !aus.empty() );
     2538
     2539  // Create copy, since original AU from DBP is modified when removing pic.
     2540  TComAu auWithSmallestPoc = *((*aus.begin())); // List is sorted, hence the AU with smallest POC is the first.
     2541
     2542  for(TComAu::iterator itP= auWithSmallestPoc.begin(); ( itP!=auWithSmallestPoc.end() ); itP++)
     2543  {
     2544    TComPic* pic = (*itP);
     2545
     2546    if (pic->getOutputMark() )
     2547    {
     2548      // Each of these pictures is, in ascending nuh_layer_id order, cropped,
     2549      // using the conformance cropping window specified in the active SPS for the picture,
     2550      // the cropped picture is output, and the picture is marked as "not needed for output".
     2551
     2552      // pictures are sorted in the AU in ascending nuh_layer_id order.
     2553
     2554
     2555      xCropAndOutput( pic );
     2556      pic->setOutputMark( false );
     2557
     2558      // Each picture storage buffer that contains a picture marked as "unused for reference"
     2559      // and that was one of the pictures cropped and output is emptied and the fullness of
     2560      // the associated sub-DPB is decremented by one.
     2561
     2562      if (pic->getMarkedUnUsedForReference() )
     2563      {
     2564        m_dpb.removePic( pic );
     2565      }
     2566    }
     2567  }
     2568}
     2569
     2570Void TAppDecTop::xF816decProcEndDecOfCodPicLIdGrtZero()
     2571{
     2572  ////////////////////////////////////////////////////////////////////////////////
     2573  // F.8.1.6  Decoding process for ending the decoding of a coded picture with nuh_layer_id greater than 0
     2574  ////////////////////////////////////////////////////////////////////////////////
     2575
     2576  const TComSlice* slice = m_curPic->getSlice( 0 );
     2577  const Int nuhLayerId   = m_curPic->getLayerId();
     2578
     2579  assert(  nuhLayerId != 0 );
     2580
     2581  //The marking of decoded pictures is modified as specified in the following:
     2582  for (Int i = 0; i < m_curPic->getDecodedRps()->m_numActiveRefLayerPics0;i++ )
     2583  {
     2584    m_curPic->getDecodedRps()->m_refPicSetInterLayer0[i]->markAsUsedForShortTermReference();
     2585  }
     2586
     2587  for (Int i = 0; i < m_curPic->getDecodedRps()->m_numActiveRefLayerPics1;i++ )
     2588  {
     2589    m_curPic->getDecodedRps()->m_refPicSetInterLayer1[i]->markAsUsedForShortTermReference();
     2590  }
     2591
     2592  // PicOutputFlag is set as follows:
     2593  if ( !m_layerInitilizedFlag[ nuhLayerId ] )
     2594  {
     2595    // - If LayerInitializedFlag[ nuh_layer_id ] is equal to 0, PicOutputFlag is set equal to 0.
     2596    m_curPic->setPicOutputFlag( false );
     2597  }
     2598  else if (m_curPic->isRasl( ) && m_noRaslOutputFlagAssocIrap[ nuhLayerId] )
     2599  {
     2600    // - Otherwise, if the current picture is a RASL picture and NoRaslOutputFlag of the associated IRAP picture is equal to 1,
     2601    //   PicOutputFlag is set equal to 0.
     2602
     2603    m_curPic->setPicOutputFlag( false );
     2604  }
     2605  else
     2606  {
     2607    // - Otherwise, PicOutputFlag is set equal to pic_output_flag.
     2608    m_curPic->setPicOutputFlag( slice->getPicOutputFlag() );
     2609  }
     2610
     2611  // The decoded picture is marked as "used for short-term reference".
     2612  m_curPic->markAsUsedForShortTermReference();
     2613
     2614  if ( !m_firstPicInLayerDecodedFlag[ nuhLayerId ] )
     2615  {
     2616    // When FirstPicInLayerDecodedFlag[ nuh_layer_id ] is equal to 0, FirstPicInLayerDecodedFlag[ nuh_layer_id ] is set equal to 1.
     2617    m_firstPicInLayerDecodedFlag[ nuhLayerId ] = true;
     2618  }
     2619}
     2620
     2621TDecTop* TAppDecTop::xGetDecoder( InputNALUnit& nalu )
     2622{
     2623  return m_tDecTop[ xGetDecoderIdx( nalu.m_nuhLayerId )];
     2624}
     2625
     2626
    10522627Int TAppDecTop::xGetDecoderIdx( Int layerId, Bool createFlag /*= false */ )
    10532628{
    1054   Int decIdx = -1; 
    1055 
    1056   if ( layerId > MAX_NUM_LAYER_IDS-1 ) 
    1057   {
    1058     return decIdx; 
    1059   }
    1060 
    1061   if ( m_layerIdToDecIdx[ layerId ] != -1 ) 
    1062   {     
    1063     decIdx = m_layerIdToDecIdx[ layerId ]; 
     2629  Int decIdx = -1;
     2630
     2631  if ( layerId > MAX_NUM_LAYER_IDS-1 )
     2632  {
     2633    return decIdx;
     2634  }
     2635
     2636  if ( m_layerIdToDecIdx[ layerId ] != -1 )
     2637  {
     2638    decIdx = m_layerIdToDecIdx[ layerId ];
    10642639  }
    10652640  else
    1066   {     
    1067     assert ( createFlag ); 
    1068     assert( m_numDecoders < MAX_NUM_LAYERS ); 
    1069 
    1070     decIdx = m_numDecoders; 
     2641  {
     2642    assert ( createFlag );
     2643    assert( m_numDecoders < MAX_NUM_LAYERS );
     2644
     2645    decIdx = m_numDecoders;
    10712646
    10722647    // Init decoder
     
    10762651    m_tDecTop[ decIdx ]->setLayerId( layerId );
    10772652    m_tDecTop[ decIdx ]->setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
    1078     m_tDecTop[ decIdx ]->setIvPicLists( &m_ivPicLists );
    1079     m_tDecTop[ decIdx ]->setLayerInitilizedFlags( m_layerInitilizedFlags );
    1080     m_tDecTop[ decIdx ]->setTargetOlsIdx( m_targetOptLayerSetIdx );   
     2653    m_tDecTop[ decIdx ]->setDpb( &m_dpb );
     2654    m_tDecTop[ decIdx ]->setTargetOlsIdx( m_targetOptLayerSetIdx );
     2655    m_tDecTop[ decIdx ]->setFirstPicInLayerDecodedFlag( m_firstPicInLayerDecodedFlag );
     2656    m_tDecTop[ decIdx ]->setPocDecrementedInDPBFlag   ( m_pocDecrementedInDpbFlag    );
     2657    m_tDecTop[ decIdx ]->setLastPresentPocResetIdc    ( m_lastPresentPocResetIdc );
     2658
     2659
    10812660#if O0043_BEST_EFFORT_DECODING
    10822661    m_cTDecTop[ decIdx ]->setForceDecodeBitDepth(m_forceDecodeBitDepth);
     
    10912670#endif
    10922671
    1093     // append pic list of new decoder to PicLists
    1094     assert( m_ivPicLists.size() == m_numDecoders );
    1095     m_ivPicLists.push_back( m_tDecTop[ decIdx ]->getListPic() );
    1096 
    1097     // create recon file related stuff     
     2672    // append pic list of new decoder to PicLists
     2673
     2674    // create recon file related stuff
    10982675    Char* pchTempFilename = NULL;
    10992676    if ( m_pchReconFile )
    1100     {     
    1101       Char buffer[4];     
     2677    {
     2678      Char buffer[4];
    11022679      sprintf(buffer,"_%i", layerId );
    1103       assert ( m_pchReconFile ); 
     2680      assert ( m_pchReconFile );
    11042681      xAppendToFileNameEnd( m_pchReconFile , buffer, pchTempFilename );
    11052682      assert( m_pchReconFiles.size() == m_numDecoders );
    11062683    }
    11072684
    1108     m_pchReconFiles.push_back( pchTempFilename );   
     2685    m_pchReconFiles.push_back( pchTempFilename );
    11092686
    11102687    m_tVideoIOYuvReconFile[ decIdx ] = new TVideoIOYuv;
    11112688    m_reconOpen           [ decIdx ] = false;
    11122689
    1113     // set others
    1114     m_pocLastDisplay      [ decIdx ] = -MAX_INT;
    1115     m_layerIdToDecIdx     [ layerId ] = decIdx;
    1116 
    1117     m_numDecoders++;
     2690    // set others
     2691    m_layerIdToDecIdx     [ layerId ] = decIdx;
     2692
     2693    m_numDecoders++;
    11182694  };
    11192695  return decIdx;
     
    11212697}
    11222698
    1123 Void TAppDecTop::xMarkForOutput( Bool allLayersDecoded, Int pocLastPic, Int layerIdLastPic )
     2699Int TAppDecTop::xPreDecodePoc( InputNALUnit& nalu )
    11242700
    1125   vector<Int> targetOptLayerIdList = m_vps->getTargetOptLayerIdList( m_targetOptLayerSetIdx );
    1126 
    1127   if (m_vps->getAltOutputLayerFlagVar( m_targetOptLayerSetIdx ) )
    1128   {
    1129     assert( targetOptLayerIdList.size() == 1 );
    1130     Int targetLayerId = targetOptLayerIdList[0];     
    1131 
    1132     TComPic* curPic = m_ivPicLists.getPic( layerIdLastPic, pocLastPic );
    1133     assert( curPic != NULL );
    1134 
    1135     if ( layerIdLastPic == targetLayerId )
    1136     {
    1137       if ( curPic->getPicOutputFlag() )
    1138       {
    1139         curPic->setOutputMark( true );
     2701  // - According to F.7.4.2.4.4, the POC of the current picture is required to detect whether it is the first in a new AU
     2702  // - F.8.1.3 needs to know if the current picture is the first of an AU
     2703  //   actually before its POC has been decoded.
     2704
     2705  // Thus, in the software implementation the processes can not be invoked in the same order as in the Spec.
     2706  // For this, this function decodes the POC before invoking F.8.1.3. However, this is done without
     2707  // altering member variables
     2708
     2709  // Do some stuff from F.8.1.3 required for POC derivation, which is not depending on AU detection.
     2710  TDecTop* dec          = xGetDecoder( nalu );
     2711  TComSlice* slicePilot = dec->getSlicePilot();
     2712  Int nuhLayerId        = nalu.m_nuhLayerId;
     2713  Int smallestLayerId   = dec->getSmallestLayerId();
     2714
     2715  Int handleCraAsBlaFlag;
     2716  if ( nalu.isIrap() )
     2717  {
     2718    if ( !m_handleCraAsBlaFlagSetByExtMeans )
     2719    {
     2720      handleCraAsBlaFlag = false;
     2721    }
     2722  }
     2723
     2724  Bool firstPicInLayerDecodedFlag = m_firstPicInLayerDecodedFlag[ nalu.m_nuhLayerId ];
     2725 
     2726  if ( nalu.isIrap() && nuhLayerId == smallestLayerId )
     2727  {
     2728    Int noClrasOutputFlag;
     2729    if( m_firstSliceInBitstream )
     2730    {
     2731      noClrasOutputFlag = true;
     2732    }
     2733    else if( m_eosInLayer[ 0 ] || m_eosInLayer[ nuhLayerId ] )
     2734    {
     2735      noClrasOutputFlag = true;
     2736    }
     2737    else if ( nalu.isBla() || (nalu.isCra() && handleCraAsBlaFlag ))
     2738    {
     2739      noClrasOutputFlag = true;
     2740    }
     2741    else if ( nalu.isIdr() && slicePilot->getCrossLayerBlaFlag() )
     2742    {
     2743      noClrasOutputFlag = true;
     2744    }
     2745    else if ( m_noClrasOutputFlagSetByExtMeans )
     2746    {
     2747      noClrasOutputFlag = m_noClrasOutputFlag;
     2748    }
     2749    else
     2750    {     
     2751      noClrasOutputFlag  = false;
     2752    }
     2753
     2754    if( noClrasOutputFlag )
     2755    {
     2756      firstPicInLayerDecodedFlag = false;
     2757    }   
     2758  }
     2759
     2760  // Derive POC
     2761  return dec->preDecodePoc(firstPicInLayerDecodedFlag, m_newPicIsFstPicOfAllLayOfPocResetPer, m_newPicIsPocResettingPic );
     2762}
     2763
     2764Bool TAppDecTop::xDetectNewAu( InputNALUnit& nalu )
     2765{
     2766  TDecTop*        dec        = xGetDecoder( nalu );
     2767  TComSlice*      slicePilot = dec->getSlicePilot();
     2768  const TComVPS*  vps        = slicePilot->getVPS();
     2769
     2770  Bool firstVclNaluOfAu;
     2771
     2772  if (m_curPic == NULL )
     2773  {
     2774    // No picture decoded yet, so we have a new AU.
     2775    firstVclNaluOfAu = true;
     2776  }
     2777  else
     2778  {
     2779    if ( !vps->getVpsExtensionFlag() )
     2780    {
     2781      // Decoding according to clause 8, hence one pic per AU.
     2782      firstVclNaluOfAu = slicePilot->getFirstSliceSegementInPicFlag();
     2783    }
     2784    else
     2785    {
     2786      if ( dec->getTargetOlsIdx() == 0 )
     2787      {
     2788        // Only the base layer is decoded, hence one pic per AU.
     2789        firstVclNaluOfAu = slicePilot->getFirstSliceSegementInPicFlag();
    11402790      }
    11412791      else
    1142       {       
    1143         xMarkAltOutPic( targetLayerId, pocLastPic );
    1144       }
    1145       m_markedForOutput = true;
    1146     }
    1147     else if ( ( layerIdLastPic > targetLayerId || allLayersDecoded ) && !m_markedForOutput )
    1148     {
    1149       xMarkAltOutPic( targetLayerId, pocLastPic );
    1150     }
    1151 
    1152     if ( allLayersDecoded )
    1153     {
    1154       m_markedForOutput = false;
    1155     }
     2792      {
     2793        // F.7.4.2.4.4  Order of NAL units and coded pictures and association to access units   
     2794        //  An access unit consists of one or more coded pictures, each with a distinct value of
     2795        //  nuh_layer_id, and zero or more non-VCL NAL units.
     2796
     2797        //  A VCL NAL unit is the first VCL NAL unit of an access unit, when all of the following conditions are true:
     2798        //  -  first_slice_segment_in_pic_flag is equal to 1.
     2799        //  -  At least one of the following conditions is true:
     2800        //     - The previous picture in decoding order belongs to a different POC resetting period
     2801        //       than the picture containing the VCL NAL unit.
     2802        Bool prevPicDiffPocResetPeriod = m_newPicIsFstPicOfAllLayOfPocResetPer;
     2803
     2804        //     - PicOrderCntVal derived for the VCL NAL unit differs from the PicOrderCntVal of the
     2805        //       previous picture in decoding order.
     2806        Bool prevPicDiffPoc = ( xPreDecodePoc( nalu ) != m_curPic->getPOC() );
     2807
     2808        if( slicePilot->getFirstSliceSegementInPicFlag() && ( prevPicDiffPocResetPeriod || prevPicDiffPoc ) )
     2809        {
     2810          firstVclNaluOfAu = true;
     2811        }
     2812        else
     2813        {
     2814          firstVclNaluOfAu = false;
     2815        }
     2816      }
     2817    }
     2818  }
     2819  return firstVclNaluOfAu;
     2820}
     2821
     2822Void TAppDecTop::xDetectNewPocResettingPeriod( InputNALUnit& nalu )
     2823{
     2824  TDecTop* dec  = xGetDecoder( nalu );
     2825  dec->inferPocResetPeriodId();
     2826
     2827
     2828  Int pocResetIdc         = dec->getSlicePilot()->getPocResetIdc();
     2829  Int newPocResetPeriodId = dec->getSlicePilot()->getPocResetPeriodId();
     2830
     2831  Int curPocResetPeriodId = ( m_curPic != NULL)  ? m_curPic->getPocResetPeriodId() : MIN_INT;
     2832
     2833  // Check if new picture starts a new poc resetting period.
     2834  if(  ( pocResetIdc == 1 || pocResetIdc == 2 ) &&  ( curPocResetPeriodId != newPocResetPeriodId ) )
     2835  {
     2836    for (Int i = 0; i < MAX_NUM_LAYER_IDS; i++ )
     2837    {
     2838      m_firstPicInPocResettingPeriodReceived[ i ] = false;
     2839    }
     2840    m_newPicIsFstPicOfAllLayOfPocResetPer = true;
    11562841  }
    11572842  else
    1158   {
    1159     for( Int dI = 0; dI < m_numDecoders; dI++ )
    1160     {     
    1161       Int layerId = m_tDecTop[dI]->getLayerId();
    1162       TComPic* curPic = m_ivPicLists.getPic( layerId, pocLastPic );
    1163       if ( curPic != NULL )
    1164       {
    1165         if ( curPic->getReconMark() )
    1166         {
    1167           Bool isTargetOptLayer = std::find(targetOptLayerIdList.begin(), targetOptLayerIdList.end(), layerId) != targetOptLayerIdList.end();
    1168           curPic->setOutputMark( isTargetOptLayer ? curPic->getPicOutputFlag() : false );
    1169         }
    1170       }
    1171     }
    1172   }
    1173 }
    1174 
    1175 Void TAppDecTop::xMarkAltOutPic( Int targetOutputLayer, Int pocLastPic )
    1176 {
    1177   Int optLayerIdxInVps = m_vps->getLayerIdInNuh( targetOutputLayer );
    1178   Int highestNuhLayerId = -1;
    1179   TComPic* picWithHighestNuhLayerId = NULL;
    1180   for (Int dIdx = 0; dIdx < m_numDecoders; dIdx++)
    1181   {
    1182     Int curLayerId = m_tDecTop[dIdx]->getLayerId();
    1183     Int curLayerIdxInVps = m_vps->getLayerIdInNuh( curLayerId  );
    1184     if ( m_vps->getDependencyFlag(optLayerIdxInVps, curLayerIdxInVps ) )
    1185     {
    1186       TComPic* curPic = m_ivPicLists.getPic( curLayerId, pocLastPic );
    1187       if (curPic != NULL)
    1188       {
    1189         if (curPic->getReconMark() && curPic->getPicOutputFlag() )
    1190         {
    1191           curPic->setOutputMark   ( false );
    1192           curPic->setPicOutputFlag( false );
    1193           if ( curLayerId > highestNuhLayerId)
    1194           {
    1195             highestNuhLayerId = curLayerId ;
    1196             picWithHighestNuhLayerId = curPic;
    1197           }           
    1198         }
    1199       }
    1200     }
    1201   }
    1202   if ( picWithHighestNuhLayerId != NULL )
    1203   {
    1204     picWithHighestNuhLayerId->setPicOutputFlag(true);
    1205     picWithHighestNuhLayerId->setOutputMark   (true);
    1206   }
     2843  {
     2844    m_newPicIsFstPicOfAllLayOfPocResetPer = false;
     2845  }
     2846
     2847  // Check if current picture is a poc resetting picture (thus the first picture of this layer within the POC resetting period.
     2848  if ( !m_firstPicInPocResettingPeriodReceived[ nalu.m_nuhLayerId ] )
     2849  {
     2850    m_newPicIsPocResettingPic = true;
     2851    m_firstPicInPocResettingPeriodReceived[ nalu.m_nuhLayerId ] = true;
     2852  }
     2853  else
     2854  {
     2855    m_newPicIsPocResettingPic = false;
     2856  }
     2857
     2858}
     2859
     2860Bool TAppDecTop::xAllRefLayersInitilized( Int curLayerId )
     2861{
     2862  Bool allRefLayersInitilizedFlag = true;
     2863  for (Int i = 0; i < m_vps->getNumDirectRefLayers( curLayerId  ); i++ )
     2864  {
     2865    Int refLayerId = m_vps->getIdDirectRefLayer( curLayerId, i );
     2866    allRefLayersInitilizedFlag = allRefLayersInitilizedFlag && m_layerInitilizedFlag[ refLayerId ];
     2867  }
     2868
     2869  return allRefLayersInitilizedFlag;
     2870}
     2871
     2872Void TAppDecTop::xInitFileIO()
     2873{
     2874  m_bitstreamFile.open(m_pchBitstreamFile, ifstream::in | ifstream::binary);
     2875
     2876  if ( !m_bitstreamFile)
     2877  {
     2878    fprintf(stderr, "\nUnable to open bitstream file `%s' for reading\n", m_pchBitstreamFile);
     2879    exit(EXIT_FAILURE);
     2880  }
     2881
     2882  if (!m_outputDecodedSEIMessagesFilename.empty() && m_outputDecodedSEIMessagesFilename!="-")
     2883  {
     2884    m_seiMessageFileStream.open(m_outputDecodedSEIMessagesFilename.c_str(), std::ios::out);
     2885    if (!m_seiMessageFileStream.is_open() || !m_seiMessageFileStream.good())
     2886    {
     2887      fprintf(stderr, "\nUnable to open file `%s' for writing decoded SEI messages\n", m_outputDecodedSEIMessagesFilename.c_str());
     2888      exit(EXIT_FAILURE);
     2889    }
     2890  }
     2891
     2892#if NH_3D
     2893  if( m_pchScaleOffsetFile )
     2894  {
     2895    m_pScaleOffsetFile = ::fopen( m_pchScaleOffsetFile, "wt" );
     2896    if (!m_pScaleOffsetFile)
     2897    {
     2898      fprintf(stderr, "\nUnable to open file `%s' for writing decoded Camera Parameters messages\n", m_pchScaleOffsetFile);
     2899      exit(EXIT_FAILURE);
     2900    }
     2901  }
     2902#endif
     2903}
     2904
     2905Void TAppDecTop::xOpenReconFile( TComPic* curPic )
     2906{
     2907  Int decIdx = xGetDecoderIdx( curPic->getLayerId() );
     2908
     2909  if ( m_pchReconFile && !m_reconOpen[decIdx] )
     2910  {
     2911    const BitDepths &bitDepths= curPic->getPicSym()->getSPS().getBitDepths(); // use bit depths of first reconstructed picture.
     2912    for (UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++)
     2913    {
     2914      if (m_outputBitDepth[channelType] == 0)
     2915      {
     2916        m_outputBitDepth[channelType] = bitDepths.recon[channelType];
     2917      }
     2918    }
     2919
     2920    m_tVideoIOYuvReconFile[decIdx]->open( m_pchReconFiles[decIdx], true, m_outputBitDepth, m_outputBitDepth, bitDepths.recon ); // write mode
     2921    m_reconOpen[decIdx] = true;
     2922  }
     2923}
     2924
     2925Void TAppDecTop::xFlushOutput()
     2926{
     2927  Bool repeat = true;
     2928  while ( repeat )
     2929  {
     2930    if( m_decProcCvsg == ANNEX_F )
     2931    {
     2932      TComList<TComAu*> aus = m_dpb.getAusHavingPicsMarkedForOutput();
     2933      if ( !aus.empty() )
     2934      {
     2935        xF13524Bumping( aus );
     2936      }     
     2937      else
     2938      {
     2939        repeat = false;
     2940      }
     2941    }     
     2942    else if( m_decProcCvsg == CLAUSE_8 )
     2943    {
     2944      TComList<TComPic*> picsMarkedForOutput = m_dpb.getSubDpb( 0, false )->getPicsMarkedNeedForOutput();
     2945      if (!picsMarkedForOutput.empty())
     2946      {
     2947        xC524Bumping();
     2948      }
     2949      else
     2950      {
     2951        repeat = false;
     2952      }
     2953    }
     2954  }
     2955}
     2956
     2957Void TAppDecTop::xCropAndOutput( TComPic* curPic )
     2958{
     2959
     2960  if ( m_printPicOutput )
     2961  {
     2962    std::cout << "  Output picture: ";
     2963    curPic->print( 2 );
     2964    std::cout << std::endl;
     2965  }
     2966
     2967  assert( !curPic->getHasGeneratedRefPics() );
     2968  assert( !curPic->getIsGenerated()         );
     2969
     2970  Int decIdx = xGetDecoderIdx( curPic->getLayerId() );
     2971
     2972  if (!m_reconOpen[ decIdx ])
     2973  {
     2974    xOpenReconFile( curPic );
     2975  }
     2976
     2977  if ( m_pchReconFiles[ decIdx ] )
     2978  {
     2979    const Window &conf    = curPic->getConformanceWindow();
     2980    const Window  defDisp = m_respectDefDispWindow ? curPic->getDefDisplayWindow() : Window();
     2981
     2982    assert( conf   .getScaledFlag() );
     2983    assert( defDisp.getScaledFlag() );
     2984
     2985    m_tVideoIOYuvReconFile[decIdx]->write( curPic->getPicYuvRec(),
     2986      m_outputColourSpaceConvert,
     2987      conf.getWindowLeftOffset()   + defDisp.getWindowLeftOffset(),
     2988      conf.getWindowRightOffset()  + defDisp.getWindowRightOffset(),
     2989      conf.getWindowTopOffset()    + defDisp.getWindowTopOffset(),
     2990      conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(),
     2991#if NH_3D
     2992      m_depth420OutputFlag && curPic->getIsDepth() ? CHROMA_420 : NUM_CHROMA_FORMAT
     2993#else
     2994      NUM_CHROMA_FORMAT
     2995#endif
     2996      , m_bClipOutputVideoToRec709Range);
     2997  }
     2998}
     2999
     3000UInt TAppDecTop::getNumberOfChecksumErrorsDetected() const
     3001{
     3002  UInt numOfChecksumErrors = 0;
     3003  for (Int i = 0; i < m_numDecoders; i++ )
     3004  {
     3005    numOfChecksumErrors += getNumberOfChecksumErrorsDetected( i );
     3006  }
     3007  return numOfChecksumErrors;
    12073008}
    12083009
  • branches/HTM-15.0-dev0/source/App/TAppDecoder/TAppDecTop.h

    r1313 r1317  
    6060{
    6161private:
    62   // class interface
     62  // class interface 
    6363#if NH_MV
    6464  TDecTop*                        m_tDecTop             [ MAX_NUM_LAYERS ];    ///< decoder classes
    6565  TVideoIOYuv*                    m_tVideoIOYuvReconFile[ MAX_NUM_LAYERS ];    ///< reconstruction YUV class
    66   Int                             m_layerIdToDecIdx     [ MAX_NUM_LAYER_IDS ]; ///< maping from layer id to decoder index
     66  Int                             m_layerIdToDecIdx     [ MAX_NUM_LAYER_IDS ]; ///< mapping from layer id to decoder index
    6767  Int                             m_numDecoders;                               ///< number of decoder instances
    68   TComPicLists                    m_ivPicLists;                                ///< picture buffers of decoder instances
    69   Bool                            m_layerInitilizedFlags[ MAX_NUM_LAYER_IDS ]; ///< for layerwise startup
     68  TComPicLists                    m_dpb;                                       ///< picture buffers of decoder instances
     69
     70  TComPic*                        m_curPic;                                    ///< currently decoded picture
     71  TComAu                          m_curAu;                                     ///< currently decoded Au
     72 
     73  // Random access related
     74  Bool                            m_handleCraAsBlaFlag;
     75  Bool                            m_handleCraAsBlaFlagSetByExtMeans;
     76  Bool                            m_noClrasOutputFlag;
     77  Bool                            m_noClrasOutputFlagSetByExtMeans;
     78  Bool                            m_noRaslOutputFlagAssocIrap           [ MAX_NUM_LAYER_IDS ];
     79
     80  // Layer wise startup
     81  Bool                            m_firstPicInLayerDecodedFlag          [ MAX_NUM_LAYER_IDS ];
     82  Bool                            m_layerInitilizedFlag                 [ MAX_NUM_LAYER_IDS ];
     83  Bool                            m_layerResetFlag;
     84
     85  // DPB related variables
     86  Int                             m_maxNumReorderPics;
     87  Int                             m_maxLatencyIncreasePlus1;
     88  Int                             m_maxLatencyValue;
     89  Int                             m_maxDecPicBufferingMinus1            [ MAX_NUM_LAYER_IDS ];
     90
     91  // Poc resetting
     92  Int                             m_lastPresentPocResetIdc              [ MAX_NUM_LAYER_IDS ];
     93  Bool                            m_firstPicInPocResettingPeriodReceived[ MAX_NUM_LAYER_IDS ];
     94  Bool                            m_pocDecrementedInDpbFlag             [ MAX_NUM_LAYER_IDS ];
     95  Bool                            m_newPicIsFstPicOfAllLayOfPocResetPer;
     96  Bool                            m_newPicIsPocResettingPic;
     97
     98  // General decoding state
     99  Bool                            m_newVpsActivatedbyCurAu;
     100  Bool                            m_newVpsActivatedbyCurPic;
     101  Bool                            m_eosInLayer                          [ MAX_NUM_LAYER_IDS ];
     102  Bool                            m_initilizedFromVPS;
     103  Bool                            m_firstSliceInBitstream;
     104  UInt64                          m_decodingOrder                       [ MAX_NUM_LAYER_IDS ];
     105  UInt64                          m_totalNumofPicsReceived;
     106  Bool                            m_cvsStartFound;
     107  Int                             m_smallestLayerId;
     108
     109  // Decoding processes for current  picture
     110  DecodingProcess                 m_decProcPocAndRps;
     111  DecodingProcess                 m_decProcCvsg;
     112 
     113  // Active parameter sets
     114  const TComPPS*                  m_pps;                                ///< active PPS
     115  const TComSPS*                  m_sps;                                ///< active SPS
    70116  const TComVPS*                  m_vps;                                ///< active VPS
     117
     118  Bool                            m_reconOpen           [ MAX_NUM_LAYERS ]; ///< reconstruction file opened
     119#if NH_3D
     120  FILE*                           m_pScaleOffsetFile;
     121  CamParsCollector                m_cCamParsCollector;
     122#endif
    71123#else
    72124  TDecTop                         m_cTDecTop;                     ///< decoder class
    73125  TVideoIOYuv                     m_cTVideoIOYuvReconFile;        ///< reconstruction YUV class
    74 #endif
    75126  // for output control
    76 #if NH_MV
    77   Int                             m_pocLastDisplay      [ MAX_NUM_LAYERS ]; ///< last POC in display order
    78   Bool                            m_reconOpen           [ MAX_NUM_LAYERS ]; ///< reconstruction file opened
    79   Bool                            m_markedForOutput;
    80 #else
    81127  Int                             m_iPOCLastDisplay;              ///< last POC in display order
    82128#endif
    83   std::ofstream                   m_seiMessageFileStream;         ///< Used for outputing SEI messages.
    84 
    85 #if NH_3D
    86   FILE*                           m_pScaleOffsetFile;
    87   CamParsCollector                m_cCamParsCollector;
    88 #endif
     129  std::ofstream                   m_seiMessageFileStream;         ///< Used for outputing SEI messages. 
    89130public:
    90131  TAppDecTop();
     
    95136  Void  decode            (); ///< main decoding function
    96137#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 
     138  UInt  getNumberOfChecksumErrorsDetected( ) const;
    107139  UInt  getNumberOfChecksumErrorsDetected( Int decIdx ) const { return m_tDecTop[decIdx]->getNumberOfChecksumErrorsDetected(); }
    108 
    109140#else
    110141  UInt  getNumberOfChecksumErrorsDetected() const { return m_cTDecTop.getNumberOfChecksumErrorsDetected(); }
     
    112143
    113144protected:
     145
    114146  Void  xCreateDecLib     (); ///< create internal classes
    115147  Void  xDestroyDecLib    (); ///< destroy internal classes
    116148  Void  xInitDecLib       (); ///< initialize decoder class
    117149
    118 #if NH_MV
    119   Void  xWriteOutput      ( TComList<TComPic*>* pcListPic, Int layerId, Int tId ); ///< write YUV to file
    120 
    121   Void  xMarkForOutput   ( Bool allLayersDecoded, Int pocLastPic, Int layerIdLastPic );         
    122   Void  xMarkAltOutPic    ( Int targetOutputLayer, Int pocLastPic );
    123 
    124   Void  xFlushOutput      ( TComList<TComPic*>* pcListPic, Int layerId ); ///< flush all remaining decoded pictures to file
    125   Int   xGetDecoderIdx    ( Int layerId, Bool createFlag = false );
    126 #else
     150#if !NH_MV
    127151  Void  xWriteOutput      ( TComList<TComPic*>* pcListPic , UInt tId); ///< write YUV to file
    128152  Void  xFlushOutput      ( TComList<TComPic*>* pcListPic ); ///< flush all remaining decoded pictures to file
    129 #endif
    130   Bool  isNaluWithinTargetDecLayerIdSet ( InputNALUnit* nalu ); ///< check whether given Nalu is within targetDecLayerIdSet
     153  Bool  isNaluWithinTargetDecLayerIdSet    ( InputNALUnit* nalu ); ///< check whether given Nalu is within targetDecLayerIdSet
     154
     155#else
     156  // Process NAL units
     157  Bool xExtractAndRewrite                  ( InputNALUnit* nalu );
     158  Void xProcessVclNalu                     ( InputNALUnit nalu );
     159  Bool xIsSkipVclNalu                      ( InputNALUnit& nalu, Bool isFirstSliceOfPic );
     160  Void xProcessNonVclNalu                  ( InputNALUnit nalu );
     161  Void xTerminateDecoding                  ( );
     162
     163  // Process slice
     164  Void xDecodeFirstSliceOfPicture          ( InputNALUnit nalu, Bool sliceIsFirstOfNewAu ); 
     165  Void xDecodeFollowSliceOfPicture         ( InputNALUnit nalu );
     166
     167  // Process picture 
     168  Void xFinalizePreviousPictures           ( Bool sliceIsFirstOfNewAU );
     169  Void xFinalizePic                        ( Bool curPicIsLastInAu );
     170  Void xFinalizeAU                         ( );
     171  Void xPicDecoding                        ( DecProcPart curPart, Bool picPosInAuIndication );
     172
     173  // Clause 8
     174  Void x812CvsgDecodingProcess             ( Int decIdx );
     175  Void x813decProcForCodPicWithLIdZero     ( DecProcPart curPart );
     176
     177  // Annex C (DPB)
     178  Void xC522OutputAndRemOfPicsFromDpb      ( );
     179  Void xC523PicDecMarkAddBumpAndStor       ( );
     180  Void xC524Bumping                        ( );
     181
     182  // Annex F.8
     183  Void xF811GeneralDecProc                 ( InputNALUnit nalu );
     184  Void xF812CvsgDecodingProcess            ( Int decIdx );
     185  Void xF813ComDecProcForACodedPic         ( DecProcPart curPart, Bool picPosInAuIndication );
     186  Void xF814decProcForCodPicWithLIdZero    ( DecProcPart curPart );
     187  Void xF816decProcEndDecOfCodPicLIdGrtZero( );
     188
     189  // Annex F.13 (DPB)
     190  Void xF13521InitDpb                      ( );
     191  Void xF13522OutputAndRemOfPicsFromDpb    ( Bool beforePocDerivation );
     192  Void xF13523PicDecMarkAddBumpAndStor     ( Bool curPicIsLastInAu   );
     193  Void xF13524Bumping                      ( TComList<TComAu*> aus );
     194
     195  // Helpers
     196  TDecTop* xGetDecoder                     ( InputNALUnit& nalu ); 
     197  Int   xGetDecoderIdx                     ( Int layerId, Bool createFlag = false );
     198  Int   xPreDecodePoc                      ( InputNALUnit& nalu );
     199  Bool  xDetectNewAu                       ( InputNALUnit& nalu );
     200  Void  xDetectNewPocResettingPeriod       ( InputNALUnit& nalu );
     201  Bool  xIsNaluInTargetDecLayerIdSet       ( InputNALUnit* nalu ); ///< check whether given Nalu is within targetDecLayerIdSet
     202  Bool  xAllRefLayersInitilized            ( Int curLayerId );
     203  Void  xInitFileIO                        ( ); 
     204  Void  xOpenReconFile                     ( TComPic* curPic );
     205  Void  xFlushOutput                       ( );
     206  Void  xCropAndOutput                     ( TComPic* curPic ); 
     207#endif
    131208};
    132209
     
    134211
    135212#endif
    136 
  • branches/HTM-15.0-dev0/source/App/TAppEncoder/TAppEncTop.cpp

    r1313 r1317  
    260260  {
    261261    m_cListPicYuvRec            .push_back(new TComList<TComPicYuv*>) ;
     262
     263#if !NH_MV
    262264    m_ivPicLists.push_back( m_acTEncTopList[ layerIdInVps ]->getListPic()  );
     265#endif
     266
    263267    TEncTop& m_cTEncTop = *m_acTEncTopList[ layerIdInVps ];  // It is not a member, but this name helps avoiding code duplication !!!
    264268
    265     Int layerId = vps.getLayerIdInNuh( layerIdInVps );
     269    Int layerId = vps.getLayerIdInNuh          ( layerIdInVps );
     270#if NH_MV
     271    m_ivPicLists.getSubDpb( layerId, true );
     272#endif
     273
    266274    m_cTEncTop.setLayerIdInVps                 ( layerIdInVps );
    267275    m_cTEncTop.setLayerId                      ( layerId );   
     
    12161224  }
    12171225#if NH_MV
    1218     }
     1226}
    12191227  }
    12201228#endif 
     
    17661774      // check if all inter layer reference pictures specified in the gop entry are valid reference layer pictures when allRefLayerActiveFlag is equal to 1
    17671775      // (Should actually always be true)
    1768       Bool maxTidIlRefAndSubLayerMaxVaildFlag = true;
     1776      Bool maxTidIlRefAndSubLayerMaxValidFlag = true;
    17691777      for( Int l = 0; l < ge.m_numActiveRefLayerPics; l++ )
    17701778      {   
     
    17841792          }         
    17851793        }
    1786        maxTidIlRefAndSubLayerMaxVaildFlag = maxTidIlRefAndSubLayerMaxVaildFlag && referenceLayerFoundFlag; 
    1787       }
    1788       assert ( maxTidIlRefAndSubLayerMaxVaildFlag ); // Something wrong with MaxTidIlRefPicsPlus1 or SubLayersVpsMaxMinus1
     1794       maxTidIlRefAndSubLayerMaxValidFlag = maxTidIlRefAndSubLayerMaxValidFlag && referenceLayerFoundFlag; 
     1795      }
     1796      assert ( maxTidIlRefAndSubLayerMaxValidFlag ); // Something wrong with MaxTidIlRefPicsPlus1 or SubLayersVpsMaxMinus1
    17891797    }           
    17901798  }
  • branches/HTM-15.0-dev0/source/Lib/TLibCommon/CommonDef.h

    r1314 r1317  
    278278static const Int  MAX_NUM_VIDEO_SIGNAL_INFO =                     16 ;
    279279static const Int  MAX_NUM_SCALED_REF_LAYERS =     MAX_NUM_LAYERS - 1 ;
     280static const Int  MAX_NUM_PICS_RPS          =                     16 ;
     281static const Int  MAX_NUM_REF_LAYERS        =                     63 ; 
    280282#endif
    281283
     
    367369#endif
    368370
     371#if NH_MV
     372static const std::string NALU_TYPE_STR[] = { 
     373    "CODED_SLICE_TRAIL_N   ",  // 0
     374    "CODED_SLICE_TRAIL_R   ",  // 1
     375    "CODED_SLICE_TSA_N     ",  // 2
     376    "CODED_SLICE_TSA_R     ",  // 3
     377    "CODED_SLICE_STSA_N    ",  // 4
     378    "CODED_SLICE_STSA_R    ",  // 5
     379    "CODED_SLICE_RADL_N    ",  // 6
     380    "CODED_SLICE_RADL_R    ",  // 7
     381    "CODED_SLICE_RASL_N    ",  // 8
     382    "CODED_SLICE_RASL_R    ",  // 9
     383    "RESERVED_VCL_N10      ",
     384    "RESERVED_VCL_R11      ",
     385    "RESERVED_VCL_N12      ",
     386    "RESERVED_VCL_R13      ",
     387    "RESERVED_VCL_N14      ",
     388    "RESERVED_VCL_R15      ",
     389    "CODED_SLICE_BLA_W_LP  ",  // 16
     390    "CODED_SLICE_BLA_W_RADL",  // 17
     391    "CODED_SLICE_BLA_N_LP  ",  // 18
     392    "CODED_SLICE_IDR_W_RADL",  // 19
     393    "CODED_SLICE_IDR_N_LP  ",  // 20
     394    "CODED_SLICE_CRA       ",  // 21
     395    "RESERVED_IRAP_VCL22   ",
     396    "RESERVED_IRAP_VCL23   ",
     397    "RESERVED_VCL24        ",
     398    "RESERVED_VCL25        ",
     399    "RESERVED_VCL26        ",
     400    "RESERVED_VCL27        ",
     401    "RESERVED_VCL28        ",
     402    "RESERVED_VCL29        ",
     403    "RESERVED_VCL30        ",
     404    "RESERVED_VCL31        ",
     405    "VPS                   ",   // 32
     406    "SPS                   ",   // 33
     407    "PPS                   ",   // 34
     408    "ACCESS_UNIT_DELIMITER ",   // 35
     409    "EOS                   ",   // 36
     410    "EOB                   ",   // 37
     411    "FILLER_DATA           ",   // 38
     412    "PREFIX_SEI            ",   // 39
     413    "SUFFIX_SEI            ",   // 40
     414    "RESERVED_NVCL41       ",
     415    "RESERVED_NVCL42       ",
     416    "RESERVED_NVCL43       ",
     417    "RESERVED_NVCL44       ",
     418    "RESERVED_NVCL45       ",
     419    "RESERVED_NVCL46       ",
     420    "RESERVED_NVCL47       ",
     421    "UNSPECIFIED_48        ",
     422    "UNSPECIFIED_49        ",
     423    "UNSPECIFIED_50        ",
     424    "UNSPECIFIED_51        ",
     425    "UNSPECIFIED_52        ",
     426    "UNSPECIFIED_53        ",
     427    "UNSPECIFIED_54        ",
     428    "UNSPECIFIED_55        ",
     429    "UNSPECIFIED_56        ",
     430    "UNSPECIFIED_57        ",
     431    "UNSPECIFIED_58        ",
     432    "UNSPECIFIED_59        ",
     433    "UNSPECIFIED_60        ",
     434    "UNSPECIFIED_61        ",
     435    "UNSPECIFIED_62        ",
     436    "UNSPECIFIED_63        ",
     437    "INVALID               "               
     438  };
     439#endif
    369440
    370441#if NH_3D
  • branches/HTM-15.0-dev0/source/Lib/TLibCommon/Debug.cpp

    r1313 r1317  
    152152EnvVar DebugOptionList::ForceLumaMode         ("FORCE_LUMA_MODE",   "0", "Force a particular intra direction for Luma (0-34)"                                             );
    153153EnvVar DebugOptionList::ForceChromaMode       ("FORCE_CHROMA_MODE", "0", "Force a particular intra direction for chroma (0-5)"                                            );
    154 
    155 #if DEBUG_STRING
    156 EnvVar DebugOptionList::DebugString_Structure ("DEBUG_STRUCTURE",   "3", "Produce output on chosen structure                        bit0=intra, bit1=inter");
    157 EnvVar DebugOptionList::DebugString_Pred      ("DEBUG_PRED",        "3", "Produce output on prediction data.                        bit0=intra, bit1=inter");
    158 EnvVar DebugOptionList::DebugString_Resi      ("DEBUG_RESI",        "3", "Produce output on residual data.                          bit0=intra, bit1=inter");
    159 EnvVar DebugOptionList::DebugString_Reco      ("DEBUG_RECO",        "3", "Produce output on reconstructed data.                     bit0=intra, bit1=inter");
     154                                                                     
     155#if DEBUG_STRING                                                     
     156EnvVar DebugOptionList::DebugString_Structure ("DEBUG_STRUCTURE",   "0", "Produce output on chosen structure                        bit0=intra, bit1=inter");
     157EnvVar DebugOptionList::DebugString_Pred      ("DEBUG_PRED",        "0", "Produce output on prediction data.                        bit0=intra, bit1=inter");
     158EnvVar DebugOptionList::DebugString_Resi      ("DEBUG_RESI",        "0", "Produce output on residual data.                          bit0=intra, bit1=inter");
     159EnvVar DebugOptionList::DebugString_Reco      ("DEBUG_RECO",        "0", "Produce output on reconstructed data.                     bit0=intra, bit1=inter");
    160160EnvVar DebugOptionList::DebugString_InvTran   ("DEBUG_INV_QT",      "0", "Produce output on inverse-quantiser and transform stages. bit0=intra, bit1=inter");
    161161#endif
  • branches/HTM-15.0-dev0/source/Lib/TLibCommon/NAL.h

    r1313 r1317  
    9898        || m_nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R;
    9999  }
     100#if NH_MV
     101  Bool isIrap()
     102  {
     103   return  m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP
     104        || m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL
     105        || m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP
     106        || m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL
     107        || m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP
     108        || m_nalUnitType == NAL_UNIT_CODED_SLICE_CRA;
     109  }
     110
     111  Bool isIdr()
     112  {
     113    return  m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL
     114         || m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP;
     115  }
     116
     117  Bool isBla()
     118  {
     119    return  m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP
     120         || m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL
     121         || m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP;
     122  }
     123
     124  Bool isCra()
     125  {
     126   return  m_nalUnitType == NAL_UNIT_CODED_SLICE_CRA;
     127  }
     128
     129
     130#endif
    100131  Bool isSei()
    101132  {
     
    108139    return ( (UInt)m_nalUnitType < 32 );
    109140  }
     141#if NH_MV
     142  Void print( )
     143  {
     144    std::cout << "Type: " << NALU_TYPE_STR[m_nalUnitType] << " LayerId: " << m_nuhLayerId << " TemporalId: " << m_temporalId;
     145  }
     146#endif
    110147};
    111148
  • branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComBitStream.cpp

    r1313 r1317  
    4141#include <string.h>
    4242#include <memory.h>
    43 
     43#if NH_MV
     44#include "TComRom.h" // This is only here, since ENC_DEC_TRACE is currently there. Consider removing when this has changed.
     45#endif
    4446using namespace std;
    4547
     
    258260  m_numBitsRead += uiNumberOfBits;
    259261
     262#if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC
     263  if ( g_traceBitsRead )
     264  {
     265      Bool oldJustDoIt = g_bJustDoIt;
     266      g_bJustDoIt = true;
     267      writeToTraceFile( "Bits: ", m_numBitsRead, true );
     268      g_bJustDoIt = oldJustDoIt;
     269  }
     270#endif
     271
    260272  /* NB, bits are extracted from the MSB of each byte. */
    261273  UInt retval = 0;
  • branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComCodingStatistics.h

    r1313 r1317  
    102102  STATS__CABAC_BITS__3D_IC,
    103103#endif
    104 #if NH_3D_DMM || NH_3D_SDC_INTRA || H_3D_INTER_SDC
     104#if NH_3D_DMM || NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    105105  STATS__CABAC_BITS__DELTADC_SIGN_EP,
    106106  STATS__CABAC_BITS__DELTADC_PREFIX,
     
    174174    "CABAC_BITS__3D_IC"
    175175#endif
    176 #if NH_3D_DMM || NH_3D_SDC_INTRA || H_3D_INTER_SDC
     176#if NH_3D_DMM || NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    177177   ,"STATS__CABAC_BITS__DELTADC_SIGN_EP"
    178178   ,"STATS__CABAC_BITS__DELTADC_PREFIX"
  • branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComDataCU.cpp

    r1313 r1317  
    29342934}
    29352935
    2936 #if NH_3D_FIX_PRUNING
     2936#if NH_3D
    29372937Bool TComDataCU::hasEqualMotion( Int dirA, const TComMvField* mvFieldA, Int dirB, const TComMvField* mvFieldB )
    29382938{
     
    30463046      if( !iLoop && ivCandDir[0] > 0)
    30473047      {
    3048 #if NH_3D_FIX_PRUNING
    30493048        if( hasEqualMotion(tmpDir, tmpMV, m_mergCands[MRG_IVMC].m_uDir, m_mergCands[MRG_IVMC].m_cMvField ))
    3050 #else
    3051         if(tmpDir == m_mergCands[MRG_IVMC].m_uDir && m_mergCands[MRG_IVMC].m_cMvField[0]==tmpMV[0] && m_mergCands[MRG_IVMC].m_cMvField[1]==tmpMV[1])
    3052 #endif
    30533049        {
    30543050            bRemove                         = true;
     
    31013097  }
    31023098
     3099
     3100#if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC
     3101  if ( g_traceMergeCandListConst )
     3102  {
     3103    for (Int i = 0; i<MRG_IVSHIFT+1; i++)
     3104    {
     3105      m_mergCands[i].print( i );
     3106    }
     3107  }
     3108#endif
     3109
     3110
    31033111  Int iCount = 0;
    31043112  TComMv cZeroMv;
     
    31563164    pcMvFieldNeighbours[(ui<<1)+1].setMvField(cZeroMv, NOT_VALID);
    31573165  }
     3166
    31583167  // copy extMergeCandList to output
    31593168  for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ui++ )
     
    31613170    puhInterDirNeighbours[ui] = uhInterDirNeighboursExt[ui];
    31623171    pcMvFieldNeighbours[ui<<1].setMvField(extMergeCandList[ui<<1].getMv(), extMergeCandList[ui<<1].getRefIdx());
     3172
    31633173    if ( getSlice()->isInterB() )
     3174    {
    31643175      pcMvFieldNeighbours[(ui<<1)+1].setMvField(extMergeCandList[(ui<<1)+1].getMv(), extMergeCandList[(ui<<1)+1].getRefIdx());
    3165   }
     3176    }
     3177  }
     3178
     3179#if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC
     3180  if ( g_traceMergeCandListConst )
     3181  {
     3182    std::cout << std::setfill(' ')                          << std::setw( 15 )
     3183      <<  "Num"                                             << std::setw( 15 )
     3184      <<  "Dir "                                            << std::setw( 15 )
     3185      <<  "L0 RefIdx"                                       << std::setw( 15 )
     3186      <<  "L0 Hor"                                          << std::setw( 15 )
     3187      <<  "L0 Ver"                                          << std::setw( 15 )
     3188      <<  "L1 RefIdx"                                       << std::setw( 15 )
     3189      <<  "L1 Hor"                                          << std::setw( 15 )
     3190      <<  "L1 Ver"                                          << std::setw( 15 )
     3191      << std::endl;
     3192
     3193    // copy extMergeCandList to output
     3194    for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ui++ )
     3195    {
     3196      UChar curDir        = puhInterDirNeighbours[ui];
     3197      TComMvField& curf   = pcMvFieldNeighbours[ui<<1];
     3198      TComMvField& curf2  = pcMvFieldNeighbours[(ui<<1)+1];
     3199
     3200      std::cout << std::setfill(' ')                         << std::setw( 15 )
     3201        << ui                                                << std::setw( 15 )       
     3202        << (UInt) curDir                                     << std::setw( 15 )   
     3203        << ((curDir & 1) ? curf.getRefIdx()       : MIN_INT) << std::setw( 15 )
     3204        << ((curDir & 1) ? curf.getMv().getHor()  : MIN_INT) << std::setw( 15 )
     3205        << ((curDir & 1) ? curf.getMv().getVer()  : MIN_INT) << std::setw( 15 );
     3206
     3207      if ( getSlice()->isInterB() )
     3208      {     
     3209        std::cout << ((curDir & 2) ? curf2.getRefIdx() : MIN_INT) << std::setw( 15 )
     3210          << ((curDir & 1) ? curf2.getMv().getHor()    : MIN_INT) << std::setw( 15 )
     3211          << ((curDir & 1) ? curf2.getMv().getVer()    : MIN_INT) << std::setw( 15 );
     3212      }
     3213      std::cout << std::endl;
     3214    }
     3215  }
     3216#endif
    31663217  numValidMergeCand = iCount;
    31673218  assert(iCount == getSlice()->getMaxNumMergeCand());
     
    35033554          continue;
    35043555        }
    3505 #if NH_3D_FIX_PRUNING
    35063556        if (hasEqualMotion( tmpDir, tmpMV, m_mergCands[MRG_A1+iCnloop].m_uDir, m_mergCands[MRG_A1+iCnloop].m_cMvField ) )
    3507 #else
    3508         if (tmpDir == m_mergCands[MRG_A1+iCnloop].m_uDir && tmpMV[0]==m_mergCands[MRG_A1+iCnloop].m_cMvField[0] && tmpMV[1]==m_mergCands[MRG_A1+iCnloop].m_cMvField[1])
    3509 #endif
    35103557        {
    35113558          m_mergCands[MRG_A1+iCnloop].m_bAvailable = false;
     
    35813628          continue;
    35823629        }
    3583 #if NH_3D_FIX_PRUNING
    35843630        if (hasEqualMotion(ivCandDir[0], tmpMV, m_mergCands[MRG_A1+i].m_uDir,  m_mergCands[MRG_A1+i].m_cMvField) )
    3585 #else
    3586         if (ivCandDir[0] == m_mergCands[MRG_A1+i].m_uDir && tmpMV[0]==m_mergCands[MRG_A1+i].m_cMvField[0] && tmpMV[1]==m_mergCands[MRG_A1+i].m_cMvField[1])
    3587 #endif
    35883631        {
    35893632          m_mergCands[MRG_A1+i].m_bAvailable = false;
     
    35943637    else
    35953638    {
    3596 #if NH_3D_FIX_PRUNING
    35973639      if( hasEqualMotion( ivCandDir[0], tmpMV, m_mergCands[MRG_T].m_uDir, m_mergCands[MRG_T].m_cMvField ) )
    3598 #else
    3599       if (m_mergCands[MRG_T].m_bAvailable && ivCandDir[0] == m_mergCands[MRG_T].m_uDir && tmpMV[0]==m_mergCands[MRG_T].m_cMvField[0] && tmpMV[1]==m_mergCands[MRG_T].m_cMvField[1])
    3600 #endif
    36013640      {
    36023641        bRemoveSpa                      = true;
     
    36473686      !bARPFlag &&
    36483687#endif
    3649 #if H_3D || NH_3D_FIX_VSP
     3688#if NH_3D
    36503689      (nPSW + nPSH > 12) &&
    36513690#endif
     
    36943733        continue;
    36953734      }
    3696 #if NH_3D_FIX_PRUNING
    36973735      if ( hasEqualMotion(ivCandDir[1], tmpMV, m_mergCands[MRG_A1+i].m_uDir, m_mergCands[MRG_A1+i].m_cMvField) )
    3698 #else
    3699       if (ivCandDir[1] == m_mergCands[MRG_A1+i].m_uDir && tmpMV[0]==m_mergCands[MRG_A1+i].m_cMvField[0] && tmpMV[1]==m_mergCands[MRG_A1+i].m_cMvField[1])
    3700 #endif
    37013736      {
    37023737        bRemoveSpa                      = true;
     
    48524887  }
    48534888}
     4889#if NH_3D
     4890Void TComDataCU::printMV( )
     4891
     4892
     4893  for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)
     4894  {
     4895    std::cout << "L" << i;
     4896    m_acCUMvField[i].print(m_pePredMode);
     4897  }
     4898
     4899}
     4900#endif
    48544901
    48554902UInt TComDataCU::getCoefScanIdx(const UInt uiAbsPartIdx, const UInt uiWidth, const UInt uiHeight, const ComponentID compID) const
     
    52845331#if NH_3D_NBDV_REF
    52855332          TComPic* picDepth = NULL;
    5286           assert(getSlice()->getRefPic(eRefPicList, refId)->getPOC() == getSlice()->getPOC());         
     5333          assert(getSlice()->getRefPic(eRefPicList, refId)->getPOC() == getSlice()->getPOC());           
    52875334#if H_3D_FCO_VSP_DONBDV_E0163
    52885335          picDepth  = getSlice()->getIvPic(true, getSlice()->getViewIndex() );
     
    56275674    if(!m_pcSlice->getIsDepth())
    56285675    {
    5629 #if H_3D_DBBP || NH_3D_ALIGN_SPIVMP_DBBP
     5676#if NH_3D_DBBP
    56305677      if (!getDBBPFlag(0))
    56315678#else
     
    58035850      iCurrPosY  += ( iHeight >> 1 );
    58045851    }
    5805 #if H_3D_DBBP || NH_3D_ALIGN_SPIVMP_DBBP
     5852#if NH_3D_DBBP
    58065853    for(Int iLoopCan = ( (m_pcSlice->getIsDepth() || getDBBPFlag(0)) ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++)
    58075854#else
     
    58785925    }
    58795926#if NH_3D_SPIVMP
    5880 #if H_3D_DBBP || NH_3D_ALIGN_SPIVMP_DBBP
     5927#if NH_3D_DBBP
    58815928    for(Int iLoopCan = ( (m_pcSlice->getIsDepth() || getDBBPFlag(0)) ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++)
    58825929#else
  • branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComDataCU.h

    r1313 r1317  
    601601#if NH_3D
    602602  Void          compressMV            ( Int scale );
     603  Void          printMV               ( );
    603604#else           
    604605  Void          compressMV            ();
     
    644645
    645646  Bool          hasEqualMotion              ( UInt uiAbsPartIdx, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx );
    646 #if NH_3D_FIX_PRUNING
     647#if NH_3D
    647648  Bool          hasEqualMotion              ( Int dirA, const TComMvField* mvFieldA,  Int dirB, const TComMvField* mvFieldB  );
    648649#endif
  • branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComMotionInfo.cpp

    r1313 r1317  
    4444#include "TComPic.h"
    4545#endif
    46 
     46#if NH_MV
     47#include <iomanip>
     48#endif
    4749//! \ingroup TLibCommon
    4850//! \{
     
    377379  }
    378380}
     381
     382#if NH_MV
     383Void TComCUMvField::print(Char* pePredMode)
     384{
     385  for ( Int uiPartIdx = 0; uiPartIdx < m_uiNumPartition; uiPartIdx += 1 )
     386  {
     387    PredMode predMode = static_cast<PredMode>( pePredMode[ uiPartIdx ] );
     388
     389    if ( predMode == MODE_INTRA)
     390    {
     391      std::cout << std::setfill(' ') << "("
     392        << std::setw(3) <<  "   "    << ","
     393        << std::setw(3) <<  "   "    << ","
     394        << std::setw(3) <<  "   "    << ")";
     395    }
     396    else
     397    {
     398      ;
     399      std::cout << std::setfill(' ') << "("
     400        << std::setw(3) <<  (Int) m_piRefIdx[ uiPartIdx ]        << ","
     401        << std::setw(3) <<  m_pcMv[ uiPartIdx ].getHor()   << ","
     402        << std::setw(3) <<  m_pcMv[ uiPartIdx ].getVer()   << ")";
     403    }   
     404  }
     405}
     406
     407#if NH_3D_MLC
     408Void TComMotionCand::print( Int i )
     409{
     410  if (i == 0  )
     411  {
     412
     413    std::cout << std::setfill(' ')                          << std::setw( 15 )
     414      << "Num"                                              << std::setw( 15 )
     415      << "Avai"                                             << std::setw( 15 )
     416      << "Dir "                                             << std::setw( 15 )
     417      <<  "L0 RefIdx"                                       << std::setw( 15 )
     418      <<  "L0 Hor"                                          << std::setw( 15 )
     419      <<  "L0 Ver"                                          << std::setw( 15 )
     420      <<  "L1 RefIdx"                                       << std::setw( 15 )
     421      <<  "L1 Hor"                                          << std::setw( 15 )
     422      <<  "L1 Ver"                                          << std::setw( 15 )
     423      << "VspFlag"                                          << std::setw( 15 )
     424      << "SPIVMPFlag"                                       
     425      << std::endl;
     426  }
     427
     428  std::cout << std::setfill(' ')                                  << std::setw( 15 )
     429    << i                                                          << std::setw( 15 )
     430    << m_bAvailable                                               << std::setw( 15 )
     431    << (UInt) m_uDir                                              << std::setw( 15 )
     432    << ((m_uDir & 1) ? m_cMvField[0].getRefIdx()       : MIN_INT) << std::setw( 15 )
     433    << ((m_uDir & 1) ? m_cMvField[0].getMv().getHor()  : MIN_INT) << std::setw( 15 )
     434    << ((m_uDir & 1) ? m_cMvField[0].getMv().getVer()  : MIN_INT) << std::setw( 15 )
     435    << ((m_uDir & 2) ? m_cMvField[1].getRefIdx()       : MIN_INT) << std::setw( 15 )
     436    << ((m_uDir & 2) ? m_cMvField[1].getMv().getHor()  : MIN_INT) << std::setw( 15 )
     437    << ((m_uDir & 2) ? m_cMvField[1].getMv().getVer()  : MIN_INT) << std::setw( 15 )
     438    << m_iVspFlag                                                 << std::setw( 15 )
     439    << m_bSPIVMPFlag                                              << std::setw( 15 )
     440    << std::endl;
     441}
     442#endif
     443#endif
    379444//! \}
  • branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComMotionInfo.h

    r1313 r1317  
    4343#include "CommonDef.h"
    4444#include "TComMv.h"
     45
    4546//! \ingroup TLibCommon
    4647//! \{
     
    188189 
    189190  Void compress(Char* pePredMode, Int scale);
     191#if NH_MV
     192  Void print   (Char* pePredMode);
     193#endif
    190194};
    191195
     
    281285#endif
    282286  }
     287
     288
     289  Void print( Int i );
     290
    283291};
     292
     293
    284294#endif
    285295
  • branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComPic.cpp

    r1313 r1317  
    5454, m_bReconstructed                        (false)
    5555, m_bNeededForOutput                      (false)
    56 #if NH_MV
    57 , m_bPicOutputFlag                        (false)
    58 #endif
    5956, m_uiCurrSliceIdx                        (0)
    6057, m_bCheckLTMSB                           (false)
     
    6259, m_layerId                               (0)
    6360, m_viewId                                (0)
     61, m_bPicOutputFlag                        (false)
    6462#if NH_3D
    6563, m_viewIndex                             (0)
     
    8280  m_eRapRefList       = REF_PIC_LIST_0;
    8381  m_uiRapRefIdx       = 0;
     82#endif
     83#if NH_MV
     84  m_isPocResettingPic = false;   
     85  m_hasGeneratedRefPics = false;
     86  m_isFstPicOfAllLayOfPocResetPer = false;
     87  m_decodingOrder     = 0;
     88  m_noRaslOutputFlag  = false; 
     89  m_noClrasOutputFlag = false;
     90  m_picLatencyCount   = 0;
     91  m_isGenerated       = false;
     92  m_isGeneratedCl833  = false;
     93  m_activatesNewVps   = false;
    8494#endif
    8595}
     
    185195  }
    186196}
     197
    187198
    188199Bool  TComPic::getSAOMergeAvailability(Int currAddr, Int mergeAddr)
     
    231242
    232243#if NH_MV
    233 Void TComPic::print( Bool legend )
    234 {
    235   if ( legend )
    236     std::cout  << std::endl << "LId"        << "\t" << "POC"   << "\t" << "Rec"          << "\t" << "Ref"                       << "\t" << "LT"            <<  "\t" << "OutMark" <<  "\t" << "OutFlag" << std::endl;
    237   else
    238     std::cout  << getLayerId() << "\t" << getPOC()<< "\t" << getReconMark() << "\t" << getSlice(0)->isReferenced() << "\t" << getIsLongTerm() << "\t" << getOutputMark() << "\t" << getSlice(0)->getPicOutputFlag() <<std::endl;
    239 }
    240 
    241 TComPic* TComPicLists::getPic( Int layerIdInNuh, Int poc )
    242 {
    243   TComPic* pcPic = NULL;
    244   for(TComList<TComList<TComPic*>*>::iterator itL = m_lists.begin(); ( itL != m_lists.end() && pcPic == NULL ); itL++)
    245   {   
    246     for(TComList<TComPic*>::iterator itP=(*itL)->begin(); ( itP!=(*itL)->end() && pcPic == NULL ); itP++)
    247     {
    248       TComPic* currPic = (*itP);
    249       if ( ( currPic->getPOC() == poc ) && ( currPic->getLayerId() == layerIdInNuh ) )
    250       {
    251         pcPic = currPic ;     
    252       }
    253     }
    254   }
    255   return pcPic;
     244Bool TComPic::getPocResetPeriodId()
     245{
     246  return getSlice(0)->getPocResetIdc();
     247}
     248
     249Void TComPic::markAsUsedForShortTermReference()
     250{
     251  getSlice(0)->setReferenced( true );
     252  setIsLongTerm( false );
     253}
     254
     255Void TComPic::markAsUsedForLongTermReference()
     256{
     257  getSlice(0)->setReferenced( true );
     258  setIsLongTerm( true );
     259}
     260
     261
     262Void TComPic::markAsUnusedForReference()
     263{
     264  getSlice(0)->setReferenced( false );
     265  setIsLongTerm( false );
     266}
     267
     268
     269Bool TComPic::getMarkedUnUsedForReference()
     270{
     271  return !getSlice(0)->isReferenced( );
     272}
     273
     274
     275Bool TComPic::getMarkedAsShortTerm()
     276{
     277  return ( getSlice(0)->isReferenced( ) && !getIsLongTerm() );
     278}
     279
     280Void TComPic::print( Int outputLevel )
     281{
     282  if ( outputLevel== 0  )
     283  {
     284    std::cout  << std::endl
     285      << "LId"
     286      << "\t" << "POC"
     287      << "\t" << "Rec"
     288      << "\t" << "Ref"
     289      << "\t" << "LT"
     290      << "\t" << "OutMark"
     291      << "\t" << "OutFlag"
     292      << "\t" << "Type"
     293      << "\t" << "PReFlag"
     294      << std::endl;
     295  }
     296  else if( outputLevel == 1  )
     297  {
     298    std::cout  << getLayerId()
     299      << "\t" << getPOC()
     300      << "\t" << getReconMark()
     301      << "\t" << getSlice(0)->isReferenced()
     302      << "\t" << getIsLongTerm()
     303      << "\t" << getOutputMark()
     304      << "\t" << getSlice(0)->getPicOutputFlag()
     305      << "\t" << getSlice(0)->getNalUnitTypeString()
     306      << "\t" << getSlice(0)->getPocResetFlag()
     307      << std::endl;
     308  }
     309  else if ( outputLevel == 2  )
     310  {
     311    std::cout  << std:: setfill(' ')
     312      << " LayerId: "         << std::setw(2) << getLayerId()
     313      << "\t"  << " POC: "             << std::setw(5) << getPOC()
     314      << "\t"  << " Dec. Order: "      << std::setw(5) << getDecodingOrder()
     315      << "\t"  << " Referenced: "      << std::setw(1) << getSlice(0)->isReferenced()
     316      << "\t"  << " Pic type: "        <<                 getSlice(0)->getNalUnitTypeString()
     317      << "\t"  << " Generated: "       << std::setw(1) << getIsGenerated()
     318      << "\t"  << " Gen. Ref. Pics: "  << std::setw(1) << getHasGeneratedRefPics();
     319  }
     320  else if ( outputLevel == 4  )
     321  {
     322    std::cout  << std:: setfill(' ')
     323      << " LayerId: "         << std::setw(2) << getLayerId()
     324      << "\t"  << " POC: "             << std::setw(5) << getPOC()     
     325      << "\t"  << " Referenced: "      << std::setw(1) << getSlice(0)->isReferenced() << std::endl;
     326  }
    256327}
    257328
    258329#if NH_3D
    259 TComPic* TComPicLists::getPic( Int viewIndex, Bool depthFlag, Int poc )
    260 {
    261   return getPic   ( m_vps->getLayerIdInNuh( viewIndex, depthFlag ), poc );
    262 }
    263 #endif
    264 Void TComPicLists::print()
    265 {
    266   Bool first = true;     
    267   for(TComList<TComList<TComPic*>*>::iterator itL = m_lists.begin(); ( itL != m_lists.end() ); itL++)
    268   {   
    269     for(TComList<TComPic*>::iterator itP=(*itL)->begin(); ( itP!=(*itL)->end() ); itP++)
    270     {
    271       if ( first )
    272       {
    273         (*itP)->print( true );       
    274         first = false;
    275       }
    276       (*itP)->print( false );       
    277     }
    278   }
    279 }
    280 
    281 TComPicYuv* TComPicLists::getPicYuv( Int layerIdInNuh, Int poc, Bool reconFlag )
    282 {
    283   TComPic*    pcPic = getPic( layerIdInNuh, poc );
    284   TComPicYuv* pcPicYuv = NULL;
    285 
    286   if (pcPic != NULL)
    287   {
    288     if( reconFlag )
    289     {
    290       if ( pcPic->getReconMark() )
    291       {
    292         pcPicYuv = pcPic->getPicYuvRec();
    293       }
    294     }
    295     else
    296     {
    297       pcPicYuv = pcPic->getPicYuvOrg();
    298     }
    299   };
    300 
    301   return pcPicYuv;
    302 }
    303 
    304 #if NH_3D
    305 TComPicYuv* TComPicLists::getPicYuv( Int viewIndex, Bool depthFlag, Int poc, Bool recon )
    306 
    307   Int layerIdInNuh = m_vps->getLayerIdInNuh( viewIndex, depthFlag );
    308   return getPicYuv( layerIdInNuh, poc, recon );
    309 }
    310 #if NH_3D_ARP
    311 TComList<TComPic*>* TComPicLists::getPicList( Int layerIdInNuh )
    312 {
    313   TComList<TComList<TComPic*>*>::iterator itL = m_lists.begin();
    314   Int iLayer = 0;
    315 
    316   assert( layerIdInNuh < m_lists.size() );
    317 
    318   while( iLayer != layerIdInNuh )
    319   {
    320     itL++;
    321     iLayer++;
    322   }
    323 
    324   return *itL;
    325 }
    326 #endif
    327 #endif
    328 #endif // NH_MV
     330Void TComPic::printMotion()
     331{
     332  TComPicSym* pPicSym = getPicSym();
     333  for ( UInt uiCUAddr = 0; uiCUAddr < pPicSym->getNumberOfCtusInFrame(); uiCUAddr++ )
     334  {
     335    TComDataCU* pCtu = pPicSym->getCtu(uiCUAddr);
     336    std::cout << "CUAddr " << uiCUAddr << std::endl;
     337    pCtu->printMV();
     338    std::cout << std::endl;
     339  }
     340}
    329341
    330342#if NH_3D_NBDV
     
    437449          m_abTIVRINCurrRL[curCandPic][iColRefDir][iColRefIdx] = false;
    438450          Int iColViewIdx    = pcCandColSlice->getViewIndex();
     451#if H_3D_FIX_ARP_CHECK_NOT_IN_DPB
     452          // The picture pcCandColSlice->getRefPic((RefPicList)iColRefDir, iColRefIdx) might not be in DPB anymore
     453          // So don't access it directly.
     454          Int iColRefViewIdx = pcCandColSlice->getVPS()->getViewOrderIdx( pcCandColSlice->getRefLayerId( (RefPicList)iColRefDir, iColRefIdx ) );       
     455#else
    439456          Int iColRefViewIdx = pcCandColSlice->getRefPic((RefPicList)iColRefDir, iColRefIdx)->getViewIndex();
     457#endif
    440458          if(iColViewIdx == iColRefViewIdx)
    441459          {
     
    487505        {
    488506          if(pcCurrSlice->getRefPOC((RefPicList)iCurrRefDir, iCurrRefIdx ) == iTextRefPOC &&
    489              pcCurrSlice->getRefPic((RefPicList)iCurrRefDir, iCurrRefIdx)->getViewIndex() == iTextRefViewId)
     507            pcCurrSlice->getRefPic((RefPicList)iCurrRefDir, iCurrRefIdx)->getViewIndex() == iTextRefViewId)
    490508          { 
    491             m_aiTexToDepRef[iTextRefDir][iTextRefIdx] = iCurrRefIdx;
     509            m_aiTexToDepRef[iTextRefDir][iTextRefIdx] = iCurrRefIdx;           
    492510          }
    493511        }
     
    504522}
    505523#endif
     524#endif
     525
     526Void TComAu::setPicLatencyCount( Int picLatenyCount )
     527{
     528  for(TComList<TComPic*>::iterator itP= begin();  itP!= end(); itP++)
     529  {     
     530    (*itP)->setPicLatencyCount( picLatenyCount );
     531  }
     532}
     533
     534TComPic* TComAu::getPic( Int nuhLayerId )
     535{
     536  TComPic* pic = NULL;
     537  for(TComList<TComPic*>::iterator itP= begin(); ( itP!= end() && (pic == NULL) ); itP++)
     538  {     
     539    if ( (*itP)->getLayerId() == nuhLayerId )
     540    {
     541      pic = (*itP);
     542    }
     543  }
     544  return pic;
     545}
     546
     547Void TComAu::addPic( TComPic* pic, Bool pocUnkown )
     548{
     549  if ( !empty() )
     550  {
     551    if (!pocUnkown)
     552    {
     553      assert( pic->getPOC()   == ( getPoc() ));
     554    }     
     555    pic->setPicLatencyCount( getPicLatencyCount() );
     556
     557    assert( getPic( pic->getLayerId() ) == NULL );
     558
     559    // Add sorted
     560    TComAu::iterator itP = begin();
     561    Bool inserted = false;
     562    while( !inserted )
     563    {
     564      if ( ( itP == end()) || pic->getLayerId() < (*itP)->getLayerId() )
     565      {
     566        insert(itP, pic );
     567        inserted = true;
     568      }
     569      else
     570      {
     571        ++itP;
     572      }       
     573    }     
     574  }
     575  else
     576  {
     577    pushBack( pic );     
     578  }
     579}
     580
     581Bool TComAu::containsPic( TComPic* pic )
     582{
     583  Bool isInList = false;
     584  for(TComList<TComPic*>::iterator itP= begin(); ( itP!= end() && (!isInList) ); itP++)
     585  {
     586    isInList = isInList || ( pic == (*itP));
     587  }
     588  return isInList;
     589}
     590
     591TComSubDpb::TComSubDpb( Int nuhLayerid )
     592{
     593  m_nuhLayerId = nuhLayerid;
     594}
     595
     596TComPic* TComSubDpb::getPic( Int poc )
     597{
     598  TComPic* pic = NULL;
     599  for(TComList<TComPic*>::iterator itP= begin(); ( itP!= end() && (pic == NULL) ); itP++)
     600  {     
     601    if ( (*itP)->getPOC() == poc )
     602    {
     603      pic = (*itP);
     604    }
     605  }
     606  return pic;
     607}
     608
     609TComPic* TComSubDpb::getPicFromLsb( Int pocLsb, Int maxPicOrderCntLsb )
     610{
     611  TComPic* pic = NULL;
     612  for(TComList<TComPic*>::iterator itP= begin(); ( itP!= end() && (pic == NULL) ); itP++)
     613  {     
     614    if ( ( (*itP)->getPOC() & ( maxPicOrderCntLsb - 1 ) ) == pocLsb )
     615    {
     616      pic = (*itP);
     617    }
     618  }
     619  return pic;
     620}
     621
     622TComPic* TComSubDpb::getShortTermRefPic( Int poc )
     623{
     624  TComPic* pic = NULL;
     625  for(TComList<TComPic*>::iterator itP= begin(); ( itP!= end() && (pic == NULL) ); itP++)
     626  {     
     627    if ( (*itP)->getPOC() == poc && (*itP)->getMarkedAsShortTerm() )
     628    {
     629      pic = (*itP);
     630    }
     631  }
     632  return pic;
     633}
     634
     635TComList<TComPic*> TComSubDpb::getPicsMarkedNeedForOutput()
     636{
     637  TComList<TComPic*> picsMarkedNeedForOutput;
     638
     639  for(TComList<TComPic*>::iterator itP= begin();  itP!= end() ; itP++ )
     640  {     
     641    if ( (*itP)->getOutputMark() )
     642    {
     643      picsMarkedNeedForOutput.push_back( (*itP) );
     644    }
     645  }
     646  return picsMarkedNeedForOutput;
     647}
     648
     649Void TComSubDpb::markAllAsUnusedForReference()
     650{
     651  for(TComList<TComPic*>::iterator itP= begin();  itP!= end() ; itP++ )
     652  {     
     653    (*itP)->markAsUnusedForReference();
     654  }
     655}
     656
     657Void TComSubDpb::addPic( TComPic* pic )
     658{
     659  assert( pic != NULL );
     660  assert( m_nuhLayerId == pic->getLayerId() || m_nuhLayerId == -1);     
     661  if ( !empty() )
     662  {
     663    assert( getPic( pic->getPOC() ) == NULL ); // Don't add twice; assert( pic->getLayerId() == m_nuhLayerId );           
     664
     665    // Add sorted
     666    TComSubDpb::iterator itP = begin();
     667    Bool inserted = false;
     668    while( !inserted )
     669    {
     670      if ( ( itP == end()) || pic->getPOC() < (*itP)->getPOC() )
     671      {
     672        insert(itP, pic );
     673        inserted = true;
     674      }
     675      else
     676      {
     677        ++itP;
     678      }       
     679    }     
     680  }
     681  else
     682  {
     683    pushBack( pic );
     684  }
     685}
     686
     687Void TComSubDpb::removePics( std::vector<TComPic*> picToRemove )
     688{
     689  for (Int i = 0; i < picToRemove.size(); i++ )
     690  {
     691    if( picToRemove[i] != NULL)
     692    {
     693      remove( picToRemove[i] );
     694    }
     695  }
     696}
     697
     698Bool TComSubDpb::areAllPicsMarkedNotNeedForOutput()
     699{
     700  return ( getPicsMarkedNeedForOutput().size() == 0 );
     701}
     702
     703
     704TComPicLists::~TComPicLists()
     705{
     706  emptyAllSubDpbs();
     707  for(TComList<TComSubDpb*>::iterator itL = m_subDpbs.begin(); ( itL != m_subDpbs.end()); itL++)
     708  {     
     709    if ( (*itL) != NULL )
     710    {
     711      delete (*itL);
     712      (*itL) = NULL;
     713    }
     714  }
     715}
     716
     717Void TComPicLists::addNewPic( TComPic* pic )
     718{
     719  getSubDpb ( pic->getLayerId() , true )->addPic( pic );
     720  getAu     ( pic->getPOC()     , true )->addPic( pic , false );
     721  if ( m_printPicOutput )
     722  {
     723    std::cout << "  Add    picture: ";
     724    pic->print( 2 );
     725    std::cout << std::endl;
     726  }
     727}
     728
     729Void TComPicLists::removePic( TComPic* pic )
     730{
     731  if (pic != NULL)
     732  {
     733
     734    TComSubDpb* curSubDpb = getSubDpb( pic->getLayerId(), false );
     735    curSubDpb->remove( pic );
     736
     737    TComAu* curAu = getAu     ( pic->getPOC(), false );       
     738
     739    if (curAu != NULL)
     740    {   
     741      curAu->remove( pic );
     742      // Remove AU when empty.
     743      if (curAu->empty() )
     744      {
     745        m_aus.remove( curAu );
     746        delete curAu;
     747      }
     748    }
     749
     750    if ( m_printPicOutput )
     751    {
     752      std::cout << "  Remove picture: ";
     753      pic->print( 2 );
     754      std::cout << std::endl;
     755    }
     756
     757    pic->destroy();
     758    delete pic;
     759  }
     760}
     761
     762TComPic* TComPicLists::getPic( Int layerIdInNuh, Int poc )
     763{
     764  TComPic* pcPic = NULL;
     765  TComSubDpb* subDpb = getSubDpb( layerIdInNuh, false );
     766  if ( subDpb != NULL )
     767  {
     768    pcPic = subDpb->getPic( poc );
     769  }
     770  return pcPic;
     771}
     772
     773TComPicYuv* TComPicLists::getPicYuv( Int layerIdInNuh, Int poc, Bool reconFlag )
     774{
     775  TComPic*    pcPic = getPic( layerIdInNuh, poc );
     776  TComPicYuv* pcPicYuv = NULL;
     777
     778  if (pcPic != NULL)
     779  {
     780    if( reconFlag )
     781    {
     782      if ( pcPic->getReconMark() )
     783      {
     784        pcPicYuv = pcPic->getPicYuvRec();
     785      }
     786    }
     787    else
     788    {
     789      pcPicYuv = pcPic->getPicYuvOrg();
     790    }
     791  };
     792
     793  return pcPicYuv;
     794}
     795
     796TComSubDpb* TComPicLists::getSubDpb( Int nuhLayerId, Bool create )
     797{
     798  TComSubDpb* subDpb = NULL;
     799  for(TComList<TComSubDpb*>::iterator itL = m_subDpbs.begin(); ( itL != m_subDpbs.end() && subDpb == NULL ); itL++)
     800  {     
     801    if ( (*itL)->getLayerId() == nuhLayerId )
     802    {       
     803      subDpb = (*itL);
     804    }
     805  } 
     806  if ( subDpb == NULL && create )
     807  {
     808    m_subDpbs.push_back( new TComSubDpb(nuhLayerId) );
     809  }
     810  return subDpb;
     811}
     812
     813TComList<TComSubDpb*>* TComPicLists::getSubDpbs()
     814{
     815  return (&m_subDpbs);
     816}
     817
     818TComAu* TComPicLists::addAu( Int poc )
     819{
     820  TComList<TComAu*>::iterator itA = m_aus.begin();
     821
     822  assert( getAu(poc, false) == NULL );
     823  Bool inserted = false;
     824  while( !inserted)
     825  {     
     826    if ( ( itA == m_aus.end()) || poc < (*itA)->getPoc() )
     827    {       
     828      m_aus.insert(itA, new TComAu );       
     829      inserted = true;
     830      --itA;
     831    }
     832    else
     833    {
     834      ++itA;
     835    }
     836  }
     837  return (*itA);
     838}
     839
     840TComAu* TComPicLists::getAu( Int poc, Bool create )
     841{
     842  TComAu* au = NULL;
     843
     844  for( TComList<TComAu*>::iterator itA = m_aus.begin(); ( itA != m_aus.end() && au == NULL ); itA++)
     845  {
     846    if ( (*itA)->getPoc() == poc )
     847    {       
     848      au = (*itA);
     849    }
     850  } 
     851
     852  if ( au == NULL && create )
     853  {
     854    au = addAu( poc );
     855  }
     856  return au;
     857}
     858
     859TComList<TComAu*>* TComPicLists::getAus()
     860{
     861  return (&m_aus);
     862}
     863
     864TComList<TComAu*> TComPicLists::getAusHavingPicsMarkedForOutput()
     865{
     866  TComList<TComAu*> ausHavingPicsForOutput;
     867  for(TComList<TComAu*>::iterator itA= m_aus.begin(); ( itA!=m_aus.end()); itA++)
     868  {
     869    Bool hasPicMarkedAsNeedForOutput = false;
     870    for( TComAu::iterator itP= (*itA)->begin(); (itP!=(*itA)->end() && !hasPicMarkedAsNeedForOutput); itP++  )
     871    {
     872      if( (*itP)->getOutputMark() )
     873      {
     874        hasPicMarkedAsNeedForOutput = true;
     875      }
     876    }
     877    if (hasPicMarkedAsNeedForOutput)
     878    {
     879      ausHavingPicsForOutput.pushBack( (*itA) );
     880    }
     881  }
     882  return ausHavingPicsForOutput;
     883}
     884
     885Void TComPicLists::markSubDpbAsUnusedForReference( Int layerIdInNuh )
     886{
     887  TComSubDpb* subDpb = getSubDpb( layerIdInNuh, false );
     888  markSubDpbAsUnusedForReference( *subDpb );
     889}
     890
     891Void TComPicLists::markSubDpbAsUnusedForReference( TComSubDpb& subDpb )
     892{
     893  for(TComList<TComPic*>::iterator itP=subDpb.begin(); ( itP!=subDpb.end()); itP++)
     894  {
     895    (*itP)->markAsUnusedForReference();
     896  }
     897}
     898
     899Void TComPicLists::markAllSubDpbAsUnusedForReference()
     900{
     901  for(TComList<TComSubDpb*>::iterator itS= m_subDpbs.begin(); ( itS!=m_subDpbs.end()); itS++)
     902  {
     903    markSubDpbAsUnusedForReference( *(*itS) );
     904  }
     905}
     906
     907Void TComPicLists::decrementPocsInSubDpb( Int nuhLayerId, Int deltaPocVal )
     908{
     909  TComSubDpb* subDpb = getSubDpb( nuhLayerId, false );
     910
     911  for(TComSubDpb::iterator itP = subDpb->begin(); itP!=subDpb->end(); itP++)
     912  {
     913    TComPic* pic = (*itP);
     914    for (Int i = 0; i < pic->getNumAllocatedSlice(); i++)
     915    {
     916      TComSlice* slice = pic->getSlice(i);
     917      slice->setPOC( slice->getPOC() - deltaPocVal );
     918    }   
     919  }
     920}
     921Void TComPicLists::emptyAllSubDpbs()
     922{
     923  emptySubDpbs( &m_subDpbs );
     924}
     925
     926Void TComPicLists::emptySubDpbs( TComList<TComSubDpb*>* subDpbs )
     927{
     928  assert( subDpbs != NULL );
     929  for( TComList<TComSubDpb*>::iterator itS = subDpbs->begin(); itS != subDpbs->end(); itS++ )
     930  {
     931    emptySubDpb( (*itS) );
     932  }
     933}
     934
     935Void TComPicLists::emptySubDpb( TComSubDpb* subDpb )
     936{
     937  if(subDpb != NULL)
     938  {
     939    while( !subDpb->empty() )
     940    {
     941      TComPic* curPic = *(subDpb->begin());
     942      removePic( curPic );
     943    }
     944  }
     945}
     946
     947Void TComPicLists::emptySubDpb( Int nuhLayerId )
     948{
     949  emptySubDpb( getSubDpb( nuhLayerId , false) );
     950}
     951
     952Void TComPicLists::emptyNotNeedForOutputAndUnusedForRef()
     953{
     954  for(TComList<TComSubDpb*>::iterator itS= m_subDpbs.begin(); ( itS!=m_subDpbs.end()); itS++)
     955  {
     956    emptySubDpbNotNeedForOutputAndUnusedForRef( *(*itS) );
     957  }
     958}
     959
     960Void TComPicLists::emptySubDpbNotNeedForOutputAndUnusedForRef( Int layerId )
     961{
     962  TComSubDpb* subDpb = getSubDpb( layerId, false );
     963  emptySubDpbNotNeedForOutputAndUnusedForRef( *subDpb );
     964}
     965
     966Void TComPicLists::emptySubDpbNotNeedForOutputAndUnusedForRef( TComSubDpb subDpb )
     967{
     968  for(TComSubDpb::iterator itP= subDpb.begin(); ( itP!=subDpb.end()); itP++)
     969  {
     970    TComPic* pic = (*itP);
     971    if ( !pic->getOutputMark() && pic->getMarkedUnUsedForReference() )
     972    {
     973      removePic( pic );
     974    }
     975  }
     976}
     977
     978Void TComPicLists::print()
     979{
     980  Bool first = true;     
     981  for(TComList<TComSubDpb*>::iterator itL = m_subDpbs.begin(); ( itL != m_subDpbs.end() ); itL++)
     982  {   
     983    for(TComList<TComPic*>::iterator itP=(*itL)->begin(); ( itP!=(*itL)->end() ); itP++)
     984    {
     985      if ( first )
     986      {
     987        (*itP)->print( true );       
     988        first = false;
     989      }
     990      (*itP)->print( false );       
     991    }
     992  }
     993}
     994
     995#if NH_3D
     996TComPicYuv* TComPicLists::getPicYuv( Int viewIndex, Bool depthFlag, Int poc, Bool recon )
     997
     998  Int layerIdInNuh = m_vps->getLayerIdInNuh( viewIndex, depthFlag );
     999  return getPicYuv( layerIdInNuh, poc, recon );
     1000}
     1001
     1002TComPic* TComPicLists::getPic( Int viewIndex, Bool depthFlag, Int poc )
     1003{
     1004  return getPic   ( m_vps->getLayerIdInNuh( viewIndex, depthFlag ), poc );
     1005}
     1006
     1007#endif
     1008
     1009#endif
     1010
     1011
    5061012
    5071013
    5081014//! \}
     1015
  • branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComPic.h

    r1313 r1317  
    5454/// picture class (symbol + YUV buffers)
    5555
     56
     57
     58#if NH_MV
     59class TComPic;
     60
     61class TComDecodedRps
     62{
     63public:
     64
     65  TComDecodedRps()
     66  {
     67    m_refPicSetsCurr[0] = &m_refPicSetStCurrBefore;
     68    m_refPicSetsCurr[1] = &m_refPicSetStCurrAfter ;
     69    m_refPicSetsCurr[2] = &m_refPicSetLtCurr      ;
     70
     71    m_refPicSetsLt  [0] = &m_refPicSetLtCurr      ;
     72    m_refPicSetsLt  [1] = &m_refPicSetLtFoll      ;
     73
     74    m_refPicSetsAll [0] = &m_refPicSetStCurrBefore;
     75    m_refPicSetsAll [1] = &m_refPicSetStCurrAfter ;
     76    m_refPicSetsAll [2] = &m_refPicSetStFoll      ;
     77    m_refPicSetsAll [3] = &m_refPicSetLtCurr      ;
     78    m_refPicSetsAll [4] = &m_refPicSetLtFoll      ;
     79  };   
     80
     81  std::vector<Int>       m_pocStCurrBefore;
     82  std::vector<Int>       m_pocStCurrAfter;
     83  std::vector<Int>       m_pocStFoll;   
     84  std::vector<Int>       m_pocLtCurr;
     85  std::vector<Int>       m_pocLtFoll;
     86
     87  Int                    m_numPocStCurrBefore;
     88  Int                    m_numPocStCurrAfter;
     89  Int                    m_numPocStFoll;
     90  Int                    m_numPocLtCurr;
     91  Int                    m_numPocLtFoll;
     92
     93  std::vector<TComPic*>  m_refPicSetStCurrBefore;
     94  std::vector<TComPic*>  m_refPicSetStCurrAfter;
     95  std::vector<TComPic*>  m_refPicSetStFoll;
     96  std::vector<TComPic*>  m_refPicSetLtCurr;
     97  std::vector<TComPic*>  m_refPicSetLtFoll;   
     98
     99  std::vector<TComPic*>* m_refPicSetsCurr[3];
     100  std::vector<TComPic*>* m_refPicSetsLt  [2];
     101  std::vector<TComPic*>* m_refPicSetsAll [5];
     102
     103  // Annex F
     104  Int                    m_numActiveRefLayerPics0;
     105  Int                    m_numActiveRefLayerPics1;     
     106
     107  std::vector<TComPic*>  m_refPicSetInterLayer0;
     108  std::vector<TComPic*>  m_refPicSetInterLayer1;
     109};
     110#endif
     111
    56112class TComPic
    57113{
     
    72128  Bool                  m_bReconstructed;
    73129  Bool                  m_bNeededForOutput;
    74 #if NH_MV
    75   Bool                  m_bPicOutputFlag;         // Semantics variable
    76 #endif
     130
    77131  UInt                  m_uiCurrSliceIdx;         // Index of current slice
    78132  Bool                  m_bCheckLTMSB;
     
    87141  Int                   m_layerId;
    88142  Int                   m_viewId;
     143  Bool                  m_bPicOutputFlag;                // Semantics variable
     144  Bool                  m_hasGeneratedRefPics;
     145  Bool                  m_isPocResettingPic;
     146  Bool                  m_isFstPicOfAllLayOfPocResetPer;
     147  Int64                 m_decodingOrder;
     148  Bool                  m_noRaslOutputFlag;
     149  Bool                  m_noClrasOutputFlag;
     150  Int                   m_picLatencyCount;
     151  Bool                  m_isGenerated;
     152  Bool                  m_isGeneratedCl833;
     153  Bool                  m_activatesNewVps;
     154  TComDecodedRps        m_decodedRps;
     155#endif
    89156#if NH_3D
    90157  Int                   m_viewIndex;
     
    92159  Int**                 m_aaiCodedScale;
    93160  Int**                 m_aaiCodedOffset;
    94 #endif
    95 #endif
    96161#if NH_3D_QTLPC
    97162  Bool                  m_bReduceBitsQTL;
    98163#endif
    99164#if NH_3D_NBDV
    100   UInt        m_uiRapRefIdx;
    101   RefPicList  m_eRapRefList;
    102   Int         m_iNumDdvCandPics;
    103   Bool        m_abTIVRINCurrRL [2][2][MAX_NUM_REF]; //whether an inter-view reference picture with the same view index of the inter-view reference picture of temporal reference picture of current picture exists in current reference picture lists
    104   Int         m_aiTexToDepRef  [2][MAX_NUM_REF];
    105 #endif
    106 
     165  UInt                   m_uiRapRefIdx;
     166  RefPicList             m_eRapRefList;
     167  Int                    m_iNumDdvCandPics;
     168  Bool                   m_abTIVRINCurrRL [2][2][MAX_NUM_REF]; //whether an inter-view reference picture with the same view index of the inter-view reference picture of temporal reference picture of current picture exists in current reference picture lists
     169  Int                    m_aiTexToDepRef  [2][MAX_NUM_REF];
     170#endif
     171#endif
    107172public:
    108173  TComPic();
     
    115180  UInt          getTLayer() const               { return m_uiTLayer;   }
    116181  Void          setTLayer( UInt uiTLayer ) { m_uiTLayer = uiTLayer; }
    117 #if NH_MV
    118   Void          setLayerId            ( Int layerId )    { m_layerId      = layerId; }
    119   Int           getLayerId            ()                 { return m_layerId;    }
    120   Void          setViewId             ( Int viewId )     { m_viewId = viewId;   }
    121   Int           getViewId             ()                 { return m_viewId;     }
    122 #if NH_3D
    123   Void          setViewIndex          ( Int viewIndex )  { m_viewIndex = viewIndex;   }
    124   Int           getViewIndex          ()                 { return m_viewIndex;     }
    125 
    126   Void          setIsDepth            ( Bool isDepth )   { m_isDepth = isDepth; }
    127   Bool          getIsDepth            ()                 { return m_isDepth; }
    128 
    129   Void          setScaleOffset( Int** pS, Int** pO )  { m_aaiCodedScale = pS; m_aaiCodedOffset = pO; }
    130   Int**         getCodedScale ()                      { return m_aaiCodedScale;  }
    131   Int**         getCodedOffset()                      { return m_aaiCodedOffset; }
    132 #endif
    133 #endif
    134 #if NH_3D_QTLPC
    135   Bool          getReduceBitsFlag ()             { return m_bReduceBitsQTL;     }
    136   Void          setReduceBitsFlag ( Bool bFlag ) { m_bReduceBitsQTL = bFlag;    }
    137 #endif
    138182
    139183  Bool          getUsedByCurr() const            { return m_bUsedByCurr; }
     
    177221  Void          setOutputMark (Bool b) { m_bNeededForOutput = b;     }
    178222  Bool          getOutputMark () const      { return m_bNeededForOutput;  }
    179  #if NH_MV
    180   Void          setPicOutputFlag(Bool b) { m_bPicOutputFlag = b;      }
    181   Bool          getPicOutputFlag()       { return m_bPicOutputFlag ;  }
    182 #endif
    183 #if NH_3D
    184 #if NH_3D_ARP
    185   Void          getCUAddrAndPartIdx( Int iX, Int iY, Int& riCuAddr, Int& riAbsZorderIdx );
    186 #endif
    187   Void          compressMotion(Int scale);
    188 #else   
     223
     224#if !NH_3D
    189225  Void          compressMotion();
    190226#endif
     
    210246
    211247#if NH_MV
    212   Void          print( Bool legend );
     248   Void          setLayerId            ( Int layerId )    { m_layerId      = layerId; }
     249   Int           getLayerId            ()                 { return m_layerId;    }
     250   
     251   Void          setViewId             ( Int viewId )     { m_viewId = viewId;   }
     252   Int           getViewId             ()                 { return m_viewId;     }
     253
     254   Void          setPicOutputFlag(Bool b)                 { m_bPicOutputFlag = b;      }
     255   Bool          getPicOutputFlag()                       { return m_bPicOutputFlag ;  }
     256
     257   Bool          getPocResetPeriodId();
     258
     259   Void          markAsUsedForShortTermReference();
     260   Void          markAsUsedForLongTermReference();
     261   Void          markAsUnusedForReference();
     262
     263   Bool          getMarkedUnUsedForReference();
     264   Bool          getMarkedAsShortTerm();
     265
     266   Void          setHasGeneratedRefPics(Bool val)       { m_hasGeneratedRefPics  = val;    }
     267   Bool          getHasGeneratedRefPics( )              { return m_hasGeneratedRefPics;   }
     268
     269   Void          setIsPocResettingPic(Bool val)         { m_isPocResettingPic = val;    }
     270   Bool          getIsPocResettingPic( )                { return m_isPocResettingPic;   }
     271
     272   Void          setIsFstPicOfAllLayOfPocResetPer(Bool val) { m_isFstPicOfAllLayOfPocResetPer = val;  }
     273   Bool          getIsFstPicOfAllLayOfPocResetPer( )        { return m_isFstPicOfAllLayOfPocResetPer; }
     274
     275   Int64         getDecodingOrder( )                    { return m_decodingOrder;       }
     276   Void          setDecodingOrder( UInt64 val  )        { m_decodingOrder = val;        }
     277
     278   Bool          getNoRaslOutputFlag()                  { return m_noRaslOutputFlag;     }
     279   Void          setNoRaslOutputFlag( Bool b )          { m_noRaslOutputFlag = b;        }
     280
     281   Bool          getNoClrasOutputFlag()                 { return m_noClrasOutputFlag;    }
     282   Void          setNoClrasOutputFlag( Bool b )         { m_noClrasOutputFlag = b;       }
     283
     284   Int           getPicLatencyCount()                   { return m_picLatencyCount;      }
     285   Void          setPicLatencyCount( Int val )          { m_picLatencyCount = val;       }
     286
     287   Bool          getIsGenerated() const                 { return m_isGenerated;          }
     288   Void          setIsGenerated( Bool b )               { m_isGenerated = b;             }
     289
     290   Bool          getIsGeneratedCl833() const            { return m_isGeneratedCl833;     }
     291   Void          setIsGeneratedCl833( Bool b )          { m_isGeneratedCl833 = b;        }
     292
     293   Int           getTemporalId( )                       { return getSlice(0)->getTemporalId(); }
     294
     295   Bool          getActivatesNewVps()                   { return m_activatesNewVps;      }
     296   Void          setActivatesNewVps( Bool b )           { m_activatesNewVps = b;         }
     297
     298   TComDecodedRps* getDecodedRps()                      { return &m_decodedRps;          }
     299
     300   Bool          isIrap()                               { return getSlice(0)->isIRAP(); }
     301   Bool          isBla ()                               { return getSlice(0)->isBla (); }
     302   Bool          isIdr ()                               { return getSlice(0)->isIdr (); }
     303   Bool          isCra ()                               { return getSlice(0)->isCra (); }
     304   Bool          isSlnr ()                              { return getSlice(0)->isSlnr (); }
     305   Bool          isRasl ()                              { return getSlice(0)->isRasl (); }
     306   Bool          isRadl ()                              { return getSlice(0)->isRadl (); }
     307   Bool          isStsa ()                              { return getSlice(0)->isStsa (); }
     308   Bool          isTsa ()                               { return getSlice(0)->isTsa  (); }
     309
     310   Void          print( Int outputLevel );
     311
     312#if NH_3D
     313   Void          setViewIndex          ( Int viewIndex )  { m_viewIndex = viewIndex;   }
     314   Int           getViewIndex          ()                 { return m_viewIndex;     }
     315
     316   Void          setIsDepth            ( Bool isDepth )   { m_isDepth = isDepth; }
     317   Bool          getIsDepth            ()                 { return m_isDepth; }
     318
     319   Void          setScaleOffset( Int** pS, Int** pO )     { m_aaiCodedScale = pS; m_aaiCodedOffset = pO; }
     320   Int**         getCodedScale ()                         { return m_aaiCodedScale;  }
     321   Int**         getCodedOffset()                         { return m_aaiCodedOffset; }
     322
     323   Void          compressMotion(Int scale);
     324   Void          printMotion( );
     325#if NH_3D_ARP
     326   Void          getCUAddrAndPartIdx( Int iX, Int iY, Int& riCuAddr, Int& riAbsZorderIdx );
     327#endif
     328#if NH_3D_QTLPC
     329   Bool          getReduceBitsFlag ()                     { return m_bReduceBitsQTL;     }
     330   Void          setReduceBitsFlag ( Bool bFlag )         { m_bReduceBitsQTL = bFlag;    }
    213331#endif
    214332#if NH_3D_NBDV
    215   Int           getNumDdvCandPics()                    {return m_iNumDdvCandPics;   }
    216   Int           getDisCandRefPictures(Int iColPOC);
    217   Void          setRapRefIdx(UInt uiRapRefIdx)         {m_uiRapRefIdx = uiRapRefIdx;}
    218   Void          setRapRefList(RefPicList eRefPicList)  {m_eRapRefList = eRefPicList;}
    219   Void          setNumDdvCandPics (Int i)              {m_iNumDdvCandPics = i;       }
    220   UInt          getRapRefIdx()                         {return m_uiRapRefIdx;       }
    221   RefPicList    getRapRefList()                        {return m_eRapRefList;       }
    222   Void          checkTemporalIVRef();
    223   Bool          isTempIVRefValid(Int currCandPic, Int iTempRefDir, Int iTempRefIdx);
    224   Void          checkTextureRef(  );
    225   Int           isTextRefValid(Int iTextRefDir, Int iTextRefIdx);
     333  Int            getNumDdvCandPics()                      { return m_iNumDdvCandPics;    }
     334  Int            getDisCandRefPictures(Int iColPOC);       
     335  Void           setRapRefIdx(UInt uiRapRefIdx)           { m_uiRapRefIdx = uiRapRefIdx; }
     336  Void           setRapRefList(RefPicList eRefPicList)    { m_eRapRefList = eRefPicList; }
     337  Void           setNumDdvCandPics (Int i)                { m_iNumDdvCandPics = i;       }
     338  UInt           getRapRefIdx()                           { return m_uiRapRefIdx;        }
     339  RefPicList     getRapRefList()                          { return m_eRapRefList;        }
     340  Void           checkTemporalIVRef();                     
     341  Bool           isTempIVRefValid(Int currCandPic, Int iTempRefDir, Int iTempRefIdx);
     342  Void           checkTextureRef(  );
     343  Int            isTextRefValid(Int iTextRefDir, Int iTextRefIdx);
     344#endif
     345#endif
    226346#endif
    227347
     
    241361
    242362#if NH_MV
     363
     364class TComAu : public TComList<TComPic*>
     365{
     366 
     367public:
     368
     369  Int                 getPoc            ( )                     {  assert(!empty()); return back()->getPOC            ();  }
     370  Void                setPicLatencyCount( Int picLatenyCount );
     371  Int                 getPicLatencyCount( )                     {  assert(!empty()); return back()->getPicLatencyCount();  } 
     372  TComPic*            getPic            ( Int nuhLayerId  );
     373  Void                addPic            ( TComPic* pic, Bool pocUnkown );
     374  Bool                containsPic       ( TComPic* pic ); 
     375};
     376
     377
     378class TComSubDpb : public TComList<TComPic*>
     379{
     380private:
     381  Int m_nuhLayerId;
     382public: 
     383  TComSubDpb( Int nuhLayerid );
     384
     385  Int                 getLayerId                      ( ) { return m_nuhLayerId; }
     386
     387  TComPic*            getPic                          ( Int poc  );
     388  TComPic*            getPicFromLsb                   ( Int pocLsb, Int maxPicOrderCntLsb );
     389  TComPic*            getShortTermRefPic              ( Int poc  );
     390  TComList<TComPic*>  getPicsMarkedNeedForOutput      ( );
     391
     392  Void                markAllAsUnusedForReference     ( );
     393
     394  Void                addPic                          ( TComPic* pic );
     395  Void                removePics                      ( std::vector<TComPic*> picToRemove );
     396  Bool                areAllPicsMarkedNotNeedForOutput( );
     397};
     398
    243399class TComPicLists
    244400{
    245401private:
    246   TComList<TComList<TComPic*>*> m_lists;
    247 #if NH_3D
    248   const TComVPS*                     m_vps;
     402  TComList<TComAu*    >       m_aus; 
     403  TComList<TComSubDpb*>       m_subDpbs;
     404  Bool                        m_printPicOutput;
     405#if NH_3D                     
     406  const TComVPS*              m_vps;
    249407#endif
    250408public:
    251   Void        push_back( TComList<TComPic*>* list ) { m_lists.push_back( list );   }
    252   Int         size     ()                           { return (Int) m_lists.size(); }
    253 #if NH_3D_ARP
    254   TComList<TComPic*>*  getPicList   ( Int layerIdInNuh );
    255 #endif
    256   TComPic*    getPic   ( Int layerIdInNuh,              Int poc );   
    257   TComPicYuv* getPicYuv( Int layerIdInNuh,              Int poc, Bool recon );
    258 #if NH_3D
    259   Void        setVPS   ( const TComVPS* vps ) { m_vps = vps;  };
    260   TComPic*    getPic   ( Int viewIndex, Bool depthFlag, Int poc );
    261   TComPicYuv* getPicYuv( Int viewIndex, Bool depthFlag, Int poc, Bool recon );
     409  ~TComPicLists();
     410
     411  // Add and remove single pictures
     412  Void                   addNewPic( TComPic* pic );
     413  Void                   removePic( TComPic* pic );
     414
     415  // Get Pics
     416  TComPic*               getPic                         ( Int layerIdInNuh, Int poc );
     417  TComPicYuv*            getPicYuv                      ( Int layerIdInNuh, Int poc, Bool recon );
     418
     419  // Get and AUs and SubDPBs
     420  TComSubDpb*            getSubDpb                      ( Int nuhLayerId, Bool create );
     421  TComList<TComSubDpb*>* getSubDpbs                     ( );
     422                                                       
     423  TComAu*                addAu                          ( Int poc  );
     424  TComAu*                getAu                          ( Int poc, Bool create );
     425  TComList<TComAu*>*     getAus                         ( );
     426  TComList<TComAu*>      getAusHavingPicsMarkedForOutput( );
     427
     428  // Mark pictures and set POCs
     429  Void                   markSubDpbAsUnusedForReference ( Int layerIdInNuh );
     430  Void                   markSubDpbAsUnusedForReference ( TComSubDpb& subDpb );
     431  Void                   markAllSubDpbAsUnusedForReference(  );
     432  Void                   decrementPocsInSubDpb          ( Int nuhLayerId, Int deltaPocVal );
     433 
     434  // Empty Sub DPBs
     435  Void                   emptyAllSubDpbs                ( );
     436  Void                   emptySubDpbs                   ( TComList<TComSubDpb*>* subDpbs);
     437  Void                   emptySubDpb                    ( TComSubDpb* subDpb);
     438  Void                   emptySubDpb                    ( Int nuhLayerId );
     439
     440  Void                   emptyNotNeedForOutputAndUnusedForRef      ( );
     441  Void                   emptySubDpbNotNeedForOutputAndUnusedForRef( Int layerId  );
     442  Void                   emptySubDpbNotNeedForOutputAndUnusedForRef( TComSubDpb subDpb ); 
     443
     444  // For printing to std::out
     445  Void                   setPrintPicOutput ( Bool printPicOutput ) { m_printPicOutput = printPicOutput; };
     446  Void                   print();
     447
     448#if NH_3D                                   
     449  Void                   setVPS                        ( const TComVPS* vps ) { m_vps = vps;  };
     450  TComPic*               getPic                        ( Int viewIndex, Bool depthFlag, Int poc );
     451  TComPicYuv*            getPicYuv                     ( Int viewIndex, Bool depthFlag, Int poc, Bool recon );
    262452#endif 
    263453
    264   Void print( ); 
    265 
    266 }; // END CLASS DEFINITION TComPicLists
    267 
    268 #endif
     454};
     455
     456// END CLASS DEFINITION TComPicLists
     457
     458#endif
     459
    269460
    270461//! \}
  • branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComPicYuv.h

    r1313 r1317  
    166166  // Set border extension flag
    167167  Void          setBorderExtension(Bool b) { m_bIsBorderExtended = b; }
     168#if NH_MV
     169  Bool          getBorderExtension( )     { return m_bIsBorderExtended; }
     170#endif
    168171#if NH_3D
    169172  // Set Function
  • branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComPrediction.cpp

    r1313 r1317  
    584584    pcCU->getSPAbsPartIdx(uiPartAddr, iSPWidth, iSPHeight, i, iNumSPInOneLine, uiSPAddr[i]);
    585585  }
    586 #if H_3D_ARP || NH_3D_ALIGN_SPIVMP_RP // check this!
     586#if NH_3D_ARP
    587587  if( pcCU->getARPW( uiPartAddr ) != 0 )
    588588  {
     
    13021302  TComMv      cMv         = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr );
    13031303  pcCU->clipMv(cMv);
     1304
     1305#if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC
     1306  if ( g_traceMotionInfoBeforUniPred  )
     1307  {
     1308    std::cout << "RefPic POC     : " << pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()     << std::endl;
     1309    std::cout << "RefPic Layer Id: " << pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getLayerId() << std::endl;
     1310    std::cout << "RefIdx         : " << iRefIdx                                                           << std::endl;
     1311    std::cout << "RefPIcList     : " << eRefPicList                                                        << std::endl;
     1312  }
     1313#endif
     1314
    13041315#if NH_MV
    13051316  pcCU->checkMvVertRest(cMv, eRefPicList, iRefIdx );
     
    13091320  {
    13101321    if( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()== pcCU->getSlice()->getPOC() )
    1311   {
     1322    {
    13121323      xPredInterUniARPviewRef( pcCU , uiPartAddr , iWidth , iHeight , eRefPicList , pcYuvPred , bi );
    1313   }
    1314   else
    1315   {
     1324    }
     1325    else
     1326    {
    13161327      xPredInterUniARP( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, bi );
    13171328    }     
    1318     }
    1319     else
    1320     {
    1321 #endif
    1322   for (UInt comp=COMPONENT_Y; comp<pcYuvPred->getNumberValidComponents(); comp++)
    1323   {
    1324     const ComponentID compID=ComponentID(comp);
     1329  }
     1330  else
     1331  {
     1332#endif
     1333
     1334    for (UInt comp=COMPONENT_Y; comp<pcYuvPred->getNumberValidComponents(); comp++)
     1335    {
     1336      const ComponentID compID=ComponentID(comp);
    13251337#if NH_3D_IC
    1326     Bool bICFlag = pcCU->getICFlag( uiPartAddr ) && ( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getViewIndex() != pcCU->getSlice()->getViewIndex() ) && ( isLuma(compID) || (iWidth > 8) );
     1338      Bool bICFlag = pcCU->getICFlag( uiPartAddr ) && ( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getViewIndex() != pcCU->getSlice()->getViewIndex() ) && ( isLuma(compID) || (iWidth > 8) );
    13271339      xPredInterBlk(compID,  pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, pcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID))
    13281340#if NH_3D_ARP
     
    13311343        , bICFlag );
    13321344#else
    1333     xPredInterBlk  (compID,  pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, pcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)) );
    1334 #endif
    1335   }
     1345      xPredInterBlk  (compID,  pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, pcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)) );
     1346#endif
     1347    }
    13361348#if NH_3D_ARP
    13371349  }
     
    18131825)
    18141826{
     1827#if NH_MV
     1828  assert( refPic->getBorderExtension() );
     1829#endif
    18151830  Int     refStride  = refPic->getStride(compID);
    18161831  Int     dstStride  = dstPic->getStride(compID);
  • branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComPrediction.h

    r1313 r1317  
    176176  Void          combineSegmentsWithMask( TComYuv* pInYuv[2], TComYuv* pOutYuv, Bool* pMask, UInt uiWidth, UInt uiHeight, UInt uiPartAddr, UInt partSize, Int bitDepthY );
    177177#endif
    178 
     178#if NH_3D
    179179  Pel  predIntraGetPredValDC      ( const Pel* pSrc, Int iSrcStride, UInt iWidth, UInt iHeight, Bool bAbove, Bool bLeft );
    180 
     180#endif
    181181  Pel*  getPredictorPtr           ( const ComponentID compID, const Bool bUseFilteredPredictions )
    182182  {
  • branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComRdCost.cpp

    r1313 r1317  
    133133  }
    134134
     135#if NH_MV
    135136  D_PRINT_INDENT( g_traceRDCost,  "Dist: " + n2s(uiDistortion) + " Bits: " + n2s(uiBits) + " RD Cost: " + n2s(dRdCost));
     137#endif
    136138  return dRdCost;
    137139}
     
    603605  cDtParam.bitDepth   = bitDepth;
    604606
    605 #if NH_3D_IC_FIX
    606607  cDtParam.bUseIC       = false;
    607 #endif
    608608#if NH_3D_SDC_INTER
    609609  cDtParam.bUseSDCMRSAD = false;
     
    36853685  }
    36863686
     3687#if NH_MV
    36873688  D_PRINT_INDENT( g_traceRDCost, "VSO Dist: " + n2s(uiDistortion) + " Bits: " + n2s(uiBits) + " RD Cost: " + n2s(dRdCost));
     3689#endif
    36883690
    36893691  return dRdCost;
  • branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComRom.cpp

    r1313 r1317  
    222222#if NH_MV
    223223#if H_MV_HLS_PTL_LIMITS
    224  g_generalTierAndLevelLimits[ Level::LEVEL1   ] = TComGeneralTierAndLevelLimits(    36864,     350,  INT_MIN,   16,   1,   1 );
    225  g_generalTierAndLevelLimits[ Level::LEVEL2   ] = TComGeneralTierAndLevelLimits(   122880,    1500,  INT_MIN,   16,   1,   1 );
    226  g_generalTierAndLevelLimits[ Level::LEVEL2_1 ] = TComGeneralTierAndLevelLimits(   245760,    3000,  INT_MIN,   20,   1,   1 );
    227  g_generalTierAndLevelLimits[ Level::LEVEL3   ] = TComGeneralTierAndLevelLimits(   552960,    6000,  INT_MIN,   30,   2,   2 );
    228  g_generalTierAndLevelLimits[ Level::LEVEL3_1 ] = TComGeneralTierAndLevelLimits(   983040,   10000,  INT_MIN,   40,   3,   3 );
     224 g_generalTierAndLevelLimits[ Level::LEVEL1   ] = TComGeneralTierAndLevelLimits(    36864,     350,  MIN_INT,   16,   1,   1 );
     225 g_generalTierAndLevelLimits[ Level::LEVEL2   ] = TComGeneralTierAndLevelLimits(   122880,    1500,  MIN_INT,   16,   1,   1 );
     226 g_generalTierAndLevelLimits[ Level::LEVEL2_1 ] = TComGeneralTierAndLevelLimits(   245760,    3000,  MIN_INT,   20,   1,   1 );
     227 g_generalTierAndLevelLimits[ Level::LEVEL3   ] = TComGeneralTierAndLevelLimits(   552960,    6000,  MIN_INT,   30,   2,   2 );
     228 g_generalTierAndLevelLimits[ Level::LEVEL3_1 ] = TComGeneralTierAndLevelLimits(   983040,   10000,  MIN_INT,   40,   3,   3 );
    229229 g_generalTierAndLevelLimits[ Level::LEVEL4   ] = TComGeneralTierAndLevelLimits(  2228224,   12000,    30000,   75,   5,   5 );
    230230 g_generalTierAndLevelLimits[ Level::LEVEL4_1 ] = TComGeneralTierAndLevelLimits(  2228224,   20000,    50000,   75,   5,   5 );
     
    546546Bool g_disableNumbering = false;
    547547Bool g_disableHLSTrace = false;
    548 UInt64 g_stopAtCounter         = 4660;
    549 Bool g_traceCopyBack           = false;
    550 Bool g_decTraceDispDer         = false;
    551 Bool g_decTraceMvFromMerge     = false;
    552 Bool g_decTracePicOutput       = false;
     548UInt64 g_stopAtCounter       = 4660;
     549Bool g_traceCopyBack         = false;
     550Bool g_decTraceDispDer       = false;
     551Bool g_decTraceMvFromMerge   = false;
     552Bool g_decTracePicOutput     = false;
    553553Bool g_startStopTrace          = false;
    554 Bool g_outputPos               = false;
    555 Bool g_traceCameraParameters   = false;
    556 Bool g_encNumberOfWrittenBits  = false;
     554Bool g_outputPos             = false;   
     555Bool g_traceCameraParameters = false;
     556Bool g_encNumberOfWrittenBits     = false;
    557557Bool g_traceEncFracBits        = false;
    558558Bool g_traceIntraSearchCost    = false;
     
    561561Bool g_traceModeCheck          = false;
    562562UInt g_indent                  = false;
     563Bool g_decNumBitsRead          = false;
     564Bool g_traceMotionInfoBeforUniPred = false;
     565Bool g_traceMergeCandListConst = false;
     566Bool g_traceSubPBMotion       = false;
    563567#endif
    564568#endif
     
    693697  Bool startTrace = false;
    694698  if ( g_startStopTrace && poc == 0 && layerId == 0 )
    695   {   
     699  {
    696700    startTrace = ( cuPelX  == 0 ) && ( cuPelY  == 0 ) && ( cuWidth == 64 ) && ( cuHeight == 64 );
    697   }
     701    }
    698702  if ( startTrace )
    699703  {
     
    705709    g_traceModeCheck         = true;
    706710    g_traceCopyBack          = false;
    707  
     711    }
    708712  Bool stopTrace = false;
    709713  if ( g_startStopTrace && poc == 0 && layerId == 0 )
     
    752756    fflush ( g_hTrace );   
    753757  }
    754 }
    755 Void printStr( std::string str )
    756 {
    757   std::cout << str << std::endl;
    758 }
    759 Void printStrIndent( Bool b, std::string strStr )
    760 {
    761   if ( b )
    762   { 
    763     std::cout << std::string(g_indent, ' ');
    764     printStr( strStr );
    765   }
    766 }
    767 Void prinStrIncIndent( Bool b,  std::string strStr )
    768 {
    769   if ( b )
    770   {
    771     printStrIndent( true,  strStr );
    772     if (g_indent < 50)
    773     {
    774       g_indent++;
    775     }
    776   } 
    777 }
    778 Void decIndent( Bool b )
    779 {
    780   if (b && g_indent > 0)
    781   {
    782     g_indent--; 
    783   } 
    784758}
    785759#endif
  • branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComRom.h

    r1313 r1317  
    9191extern const UChar  g_aucIntraModeNumFast_NotUseMPM[MAX_CU_DEPTH];
    9292extern const UChar  g_chroma422IntraAngleMappingTable[NUM_INTRA_MODE];
     93#if NH_3D_DMM
    9394// ====================================================================================================================
    9495// Depth coding modes
    9596// ====================================================================================================================
    96 #if NH_3D_DMM
     97
    9798extern const WedgeResolution                                 g_dmmWedgeResolution [6];
    9899extern const UChar                                           g_dmm1TabIdxBits     [6];
     
    193194 extern Bool   g_traceSAOCost;
    194195 extern UInt   g_indent;
     196extern Bool   g_traceMotionInfoBeforUniPred;
     197 extern Bool   g_traceMergeCandListConst;
     198 extern Bool   g_traceSubPBMotion;
    195199#define DTRACE_CU(x,y)             writeToTraceFile( x,y, g_traceCU );
    196200#define DTRACE_PU(x,y)             writeToTraceFile( x,y, g_tracePU );
     
    232236#define DTRACE_CABAC_R( x,y )
    233237#define DTRACE_CABAC_N
     238#if NH_MV
    234239#define DTRACE_CU(x,y) ;             
    235240#define DTRACE_PU(x,y) ;           
     
    242247#define D_PRINT_INC_INDENT( b, str );
    243248#define D_PRINT_INDENT( b, str );
    244 
     249#endif
    245250#endif
    246251const Char* nalUnitTypeToString(NalUnitType type);
  • branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComSlice.cpp

    r1313 r1317  
    66 * Copyright (c) 2010-2015, ITU/ISO/IEC
    77 * All rights reserved.
     8
    89 *
    910 * Redistribution and use in source and binary forms, with or without
     
    112113, m_encCABACTableIdx              (I_SLICE)
    113114#if NH_MV
    114 , m_availableForTMVPRefFlag       ( true )
    115115, m_refPicSetInterLayer0          ( NULL )
    116116, m_refPicSetInterLayer1          ( NULL )
     
    121121, m_isDepth                       (false)
    122122#endif
    123 #if !H_MV_HLS7_GEN
     123#if NH_MV
    124124, m_pocResetFlag                  (false)
    125 #endif
    126 #if NH_MV
    127125, m_crossLayerBlaFlag             (false)
    128126#endif
     
    134132, m_pocResetIdc                   (0)
    135133, m_pocResetPeriodId              (0)
     134, m_hasPocResetPeriodIdPresent    (false)
    136135, m_fullPocResetFlag              (false)
    137136, m_pocLsbVal                     (0)
    138 , m_pocMsbValPresentFlag          (false)
    139 , m_pocMsbVal                     (0)
     137, m_pocMsbCycleValPresentFlag     (false)
     138, m_pocMsbCycleVal                (0)
    140139, m_pocMsbValRequiredFlag         (false)
    141140#endif
     
    155154#endif
    156155{
     156
     157#if NH_MV
     158  m_shortTermRefPicSetIdx = 0;
     159  m_numLongTermSps        = 0;
     160  m_numLongTermPics       = 0;
     161  for (Int i = 0; i < MAX_NUM_PICS_RPS; i++)
     162  {
     163    m_ltIdxSps          [i] = 0;
     164    m_deltaPocMsbCycleLt[i] = 0;
     165  }
     166  setSliceTemporalMvpEnabledFlag( false );
     167#endif
    157168  for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)
    158169  {
     
    790801#endif
    791802
     803
    792804Int TComSlice::getNumRpsCurrTempList() const
    793805{
     
    806818  }
    807819#if NH_MV
    808   numRpsCurrTempList = numRpsCurrTempList + getNumActiveRefLayerPics();
     820    numRpsCurrTempList = numRpsCurrTempList + getNumActiveRefLayerPics();
    809821#endif
    810822  return numRpsCurrTempList;
     
    10971109  m_pcVPS                = pSrc->m_pcVPS;
    10981110#endif
    1099   m_pRPS                = pSrc->m_pRPS;  m_iLastIDR             = pSrc->m_iLastIDR;
     1111  m_pRPS                = pSrc->m_pRPS;
     1112  m_iLastIDR             = pSrc->m_iLastIDR;
    11001113
    11011114  m_pcPic                = pSrc->m_pcPic;
     
    11551168#if NH_MV
    11561169  // Additional slice header syntax elements
    1157 #if !H_MV_HLS7_GEN
    11581170  m_pocResetFlag               = pSrc->m_pocResetFlag;
    1159 #endif
    11601171  m_discardableFlag            = pSrc->m_discardableFlag;
    11611172  m_interLayerPredEnabledFlag  = pSrc->m_interLayerPredEnabledFlag;
     
    26702681  }
    26712682}
    2672 #endif
    2673 
     2683
     2684#endif
    26742685#endif // NH_MV
    26752686
     
    27192730, m_uiBitsForPOC              (  8)
    27202731, m_numLongTermRefPicSPS      (  0)
     2732#if NH_MV
     2733, m_numShortTermRefPicSets    (   0)
     2734#endif
    27212735, m_uiMaxTrSize               ( 32)
    27222736, m_bUseSAO                   (false)
     
    27502764  for ( Int i = 0; i < MAX_TLAYER; i++ )
    27512765  {
     2766#if NH_MV
     2767    m_uiSpsMaxLatencyIncreasePlus1[i] = 0;
     2768#else
    27522769    m_uiMaxLatencyIncrease[i] = 0;
     2770#endif
    27532771    m_uiMaxDecPicBuffering[i] = 1;
    27542772    m_numReorderPics[i]       = 0;
     
    30813099Void TComSPS::inferSpsMaxDecPicBufferingMinus1( TComVPS* vps, Int targetOptLayerSetIdx, Int currLayerId, Bool encoder )
    30823100{
    3083   const std::vector<Int>& targetDecLayerIdList = vps->getTargetDecLayerIdList( vps->olsIdxToLsIdx( targetOptLayerSetIdx ));
    3084 
    30853101  if ( getMultiLayerExtSpsFlag() )
    30863102  {
     3103    const std::vector<Int>& targetDecLayerIdList = vps->getTargetDecLayerIdList( vps->olsIdxToLsIdx( targetOptLayerSetIdx ));
    30873104    Int layerIdx = 0;         
    30883105    while (layerIdx < (Int) targetDecLayerIdList.size() )
     
    31093126        // This preliminary fix needs to be checked.
    31103127        assert( getNumReorderPics( i )     == maxNumReorderPics       );
    3111         assert( getMaxLatencyIncrease( i ) == maxLatencyIncreasePlus1 );
     3128        assert( getSpsMaxLatencyIncreasePlus1( i ) == maxLatencyIncreasePlus1 );
    31123129
    31133130      }
     
    31173134        setMaxDecPicBuffering( maxDecPicBufferingMinus1 + 1 , i);
    31183135        setNumReorderPics    ( maxNumReorderPics, i );
    3119         setMaxLatencyIncrease( maxLatencyIncreasePlus1 - 1 , i);
     3136        setSpsMaxLatencyIncreasePlus1( maxLatencyIncreasePlus1 , i);
    31203137      }
    31213138    }   
     
    34123429  }
    34133430}
    3414 
    34153431Void TComSlice::markIvRefPicsAsShortTerm( std::vector<TComPic*> refPicSetInterLayer0, std::vector<TComPic*> refPicSetInterLayer1 )
    34163432{
     
    34353451    for (Int rIdx = 0; rIdx <= (m_aiNumRefIdx[li]-1); rIdx ++)
    34363452    {     
    3437       if (rIdx == 0 && li == 0) m_apcRefPicList[li][rIdx]->print( true );
     3453      if (rIdx == 0 && li == 0) m_apcRefPicList[li][rIdx]->print( 1 );
     3454      m_apcRefPicList[li][rIdx]->print( 0 );     
    34383455       
    3439       m_apcRefPicList[li][rIdx]->print( false );
    34403456    }
    34413457  }
     
    34563472  m_refPicSetInterLayer1 = refPicSetInterLayer1;
    34573473}
     3474
     3475TComPic* TComSlice::getRefPicSetInterLayer( Int setIdc, Int i ) const
     3476{
     3477  TComPic* pic = NULL;
     3478  if (setIdc == 0 )
     3479  {
     3480    pic = (*m_refPicSetInterLayer0)[ i ];
     3481  }
     3482  else if (setIdc == 1 )
     3483  {
     3484    pic = (*m_refPicSetInterLayer1)[ i ];
     3485  }
     3486
     3487  assert( pic != NULL );   
     3488
     3489  return pic;
     3490}
     3491
    34583492
    34593493TComPic* TComSlice::getPicFromRefPicSetInterLayer(Int setIdc, Int layerId ) const
     
    35723606#endif
    35733607}
     3608#endif
    35743609#if NH_3D_NBDV
    35753610Void TComSlice::setDefaultRefView()
     
    36873722      if( iViewIdx<getViewIndex() && !bIsDepth )
    36883723      {
    3689         setBaseViewRefPicList( ivPicLists->getPicList( iLayerId ), iViewIdx );
     3724        setBaseViewRefPicList( ivPicLists->getSubDpb( iLayerId, false ), iViewIdx );
    36903725      }
    36913726    }
     
    37103745        if ( pcCurrPic->getViewIndex() != pcRefPic->getViewIndex() )
    37113746        {
    3712           existInterViewRef = true;       
     3747          existInterViewRef = true;
    37133748        }
    37143749      }
     
    38333868#if NH_3D
    38343869Void TComSlice::setIvPicLists( TComPicLists* m_ivPicLists )
    3835 {
     3870{ 
    38363871  for (Int i = 0; i < MAX_NUM_LAYERS; i++ )
    3837   {    
     3872  {
    38383873    for ( Int depthId = 0; depthId < 2; depthId++ )
    38393874    {
     
    39203955}
    39213956#endif
    3922 #endif
     3957
    39233958
    39243959
     
    39333968}
    39343969
    3935 Bool TComSlice::inferPocMsbValPresentFlag()
     3970Bool TComSlice::inferPocMsbCycleValPresentFlag()
    39363971{
    39373972  Bool pocMsbValPresentFlag;
     
    39523987}
    39533988
     3989
     3990Void TComSlice::f834decProcForRefPicListConst()
     3991{
     3992  // This process is invoked at the beginning of the decoding process for each P or B slice.
     3993  assert( getSliceType() == B_SLICE || getSliceType() == P_SLICE );
     3994
     3995  // Reference pictures are addressed through reference indices as specified in clause 8.5.3.3.2. A reference index is an index into
     3996  // a reference picture list. When decoding a P slice, there is a single reference picture list RefPicList0. When decoding a B
     3997  // slice, there is a second independent reference picture list RefPicList1 in addition to RefPicList0.
     3998
     3999  // At the beginning of the decoding process for each slice, the reference picture lists RefPicList0 and, for B slices, RefPicList1
     4000  // are derived as follows:
     4001
     4002  // The variable NumRpsCurrTempList0 is set equal to Max( num_ref_idx_l0_active_minus1 + 1, NumPicTotalCurr )
     4003  Int numRpsCurrTempList0 = std::max( getNumRefIdxL0ActiveMinus1() + 1, getNumPicTotalCurr() );
     4004
     4005  // and the list RefPicListTemp0 is constructed as follows:
     4006  std::vector<TComPic*> refPicListTemp0;
     4007  refPicListTemp0.resize((MAX_NUM_REF+1),NULL);
     4008
     4009  const TComDecodedRps* decRps = getPic()->getDecodedRps();
     4010
     4011  const std::vector<TComPic*>& refPicSetStCurrBefore  = decRps->m_refPicSetStCurrBefore;
     4012  const std::vector<TComPic*>& refPicSetStCurrAfter   = decRps->m_refPicSetStCurrAfter;
     4013  const std::vector<TComPic*>& refPicSetLtCurr        = decRps->m_refPicSetLtCurr;
     4014
     4015  const Int                    numPocStCurrBefore     = decRps->m_numPocStCurrBefore;
     4016  const Int                    numPocStCurrAfter      = decRps->m_numPocStCurrAfter;
     4017  const Int                    numPocLtCurr           = decRps->m_numPocLtCurr;
     4018
     4019  const Int                    numActiveRefLayerPics0 = decRps->m_numActiveRefLayerPics0;
     4020  const Int                    numActiveRefLayerPics1 = decRps->m_numActiveRefLayerPics1;
     4021
     4022  const std::vector<TComPic*>& refPicSetInterLayer0   = decRps->m_refPicSetInterLayer0;
     4023  const std::vector<TComPic*>& refPicSetInterLayer1   = decRps->m_refPicSetInterLayer1;
     4024
     4025  Int rIdx = 0;
     4026  while( rIdx < numRpsCurrTempList0 )
     4027  {
     4028    for(Int  i = 0; i < numPocStCurrBefore  &&  rIdx < numRpsCurrTempList0; rIdx++, i++ )
     4029    {
     4030      refPicListTemp0[ rIdx ] = refPicSetStCurrBefore[ i ];
     4031    }   
     4032
     4033    for(Int  i = 0; i < numActiveRefLayerPics0; rIdx++, i++ )
     4034    {
     4035      refPicListTemp0[ rIdx ] = refPicSetInterLayer0[ i ];
     4036    }
     4037
     4038    for(Int  i = 0;  i < numPocStCurrAfter  &&  rIdx < numRpsCurrTempList0; rIdx++, i++ )  // (F 65)
     4039    {
     4040      refPicListTemp0[ rIdx ] = refPicSetStCurrAfter[ i ];
     4041    }
     4042
     4043    for(Int  i = 0; i < numPocLtCurr  &&  rIdx < numRpsCurrTempList0; rIdx++, i++ )
     4044    {
     4045      refPicListTemp0[ rIdx ] = refPicSetLtCurr[ i ];
     4046    }
     4047
     4048    for(Int  i = 0; i < numActiveRefLayerPics1; rIdx++, i++ )
     4049    {
     4050      refPicListTemp0[ rIdx ] = refPicSetInterLayer1[ i ];
     4051    }
     4052  }
     4053
     4054  // The list RefPicList0 is constructed as follows:
     4055  TComRefPicListModification* rplm  = getRefPicListModification();
     4056  for( rIdx = 0; rIdx  <=  getNumRefIdxL0ActiveMinus1(); rIdx++ )      //  (F 66)
     4057  {
     4058    m_apcRefPicList[ 0 ][ rIdx ] = rplm->getRefPicListModificationFlagL0( ) ? refPicListTemp0[ rplm->getListEntryL0( rIdx )] : refPicListTemp0[ rIdx ];
     4059    // The decoding process below slice level requires the status
     4060    // of the reference pictures, when decoding the RPS. So store it here.
     4061    m_bIsUsedAsLongTerm[ 0 ][ rIdx ] = m_apcRefPicList[ 0 ][ rIdx ]->getIsLongTerm();
     4062    m_aiRefPOCList     [ 0 ][ rIdx ] = m_apcRefPicList[ 0 ][ rIdx ]->getPOC();
     4063    m_aiRefLayerIdList [ 0 ][ rIdx ] = m_apcRefPicList[ 0 ][ rIdx ]->getLayerId();
     4064  } 
     4065
     4066  std::vector<TComPic*> refPicListTemp1;
     4067  refPicListTemp1.resize((MAX_NUM_REF+1),NULL);
     4068
     4069  if (getSliceType() == B_SLICE )
     4070  {
     4071    // When the slice is a B slice, the variable NumRpsCurrTempList1 is set equal to
     4072    // Max( num_ref_idx_l1_active_minus1 + 1, NumPicTotalCurr ) and the list RefPicListTemp1 is constructed as follows:       
     4073    Int numRpsCurrTempList1 = std::max( getNumRefIdxL1ActiveMinus1() + 1, getNumPicTotalCurr() );
     4074
     4075    rIdx = 0;
     4076    while( rIdx < numRpsCurrTempList1 )
     4077    {
     4078      for( Int i = 0; i < numPocStCurrAfter  &&  rIdx < numRpsCurrTempList1; rIdx++, i++ )
     4079      {
     4080        refPicListTemp1[ rIdx ] = refPicSetStCurrAfter[ i ];
     4081      }
     4082      for( Int i = 0; i< numActiveRefLayerPics1; rIdx++, i++ )
     4083      {
     4084        refPicListTemp1[ rIdx ] = refPicSetInterLayer1[ i ];
     4085      }
     4086      for( Int i = 0;  i < numPocStCurrBefore  &&  rIdx < numRpsCurrTempList1; rIdx++, i++ )  // (F 67)
     4087      {
     4088        refPicListTemp1[ rIdx ] = refPicSetStCurrBefore[ i ];
     4089      }         
     4090      for( Int i = 0; i < numPocLtCurr  &&  rIdx < numRpsCurrTempList1; rIdx++, i++ )
     4091      {
     4092        refPicListTemp1[ rIdx ] = refPicSetLtCurr[ i ];
     4093      }
     4094      for( Int i = 0; i< numActiveRefLayerPics0; rIdx++, i++ )
     4095      {
     4096        refPicListTemp1[ rIdx ] = refPicSetInterLayer0[ i ];
     4097      }
     4098    }
     4099  }
     4100
     4101  if (getSliceType() == B_SLICE )
     4102  {
     4103    //   When the slice is a B slice, the list RefPicList1 is constructed as follows:
     4104    for( rIdx = 0; rIdx  <=  getNumRefIdxL1ActiveMinus1(); rIdx++ )      // (F 68)
     4105    {
     4106      m_apcRefPicList[ 1 ][ rIdx ] = rplm->getRefPicListModificationFlagL1() ? refPicListTemp1[ rplm->getListEntryL1( rIdx ) ] : refPicListTemp1[ rIdx ];
     4107
     4108      // The decoding process below slice level requires the marking status
     4109      // of the reference pictures, when decoding the RPS. So store it here.
     4110      m_bIsUsedAsLongTerm[ 1 ][ rIdx ] = m_apcRefPicList[ 1 ][ rIdx ]->getIsLongTerm();
     4111      m_aiRefPOCList     [ 1 ][ rIdx ] = m_apcRefPicList[ 1 ][ rIdx ]->getPOC();
     4112      m_aiRefLayerIdList [ 1 ][ rIdx ] = m_apcRefPicList[ 1 ][ rIdx ]->getLayerId();
     4113    }   
     4114  }
     4115}
     4116
     4117
     4118Void TComSlice::cl834DecProcForRefPicListConst()
     4119{
     4120  // This process is invoked at the beginning of the decoding process for each P or B slice.
     4121  assert( getSliceType() == B_SLICE || getSliceType() == P_SLICE );
     4122
     4123  // Reference pictures are addressed through reference indices as specified in clause 8.5.3.3.2. A reference index is an index into
     4124  // a reference picture list. When decoding a P slice, there is a single reference picture list RefPicList0. When decoding a B
     4125  // slice, there is a second independent reference picture list RefPicList1 in addition to RefPicList0.
     4126
     4127  // At the beginning of the decoding process for each slice, the reference picture lists RefPicList0 and, for B slices, RefPicList1
     4128  // are derived as follows:
     4129
     4130  // The variable NumRpsCurrTempList0 is set equal to Max( num_ref_idx_l0_active_minus1 + 1, NumPicTotalCurr )
     4131  Int numRpsCurrTempList0 = std::max( getNumRefIdxL0ActiveMinus1() + 1, getNumPicTotalCurr() );
     4132
     4133  // and the list RefPicListTemp0 is constructed as follows:
     4134  std::vector<TComPic*> refPicListTemp0;
     4135  refPicListTemp0.resize((MAX_NUM_REF+1),NULL);
     4136
     4137  const TComDecodedRps* decRps = getPic()->getDecodedRps();
     4138
     4139  const std::vector<TComPic*>& refPicSetStCurrBefore = decRps->m_refPicSetStCurrBefore;
     4140  const std::vector<TComPic*>& refPicSetStCurrAfter  = decRps->m_refPicSetStCurrAfter;
     4141  const std::vector<TComPic*>& refPicSetLtCurr       = decRps->m_refPicSetLtCurr;
     4142   
     4143  const Int                    numPocStCurrBefore    = decRps->m_numPocStCurrBefore;
     4144  const Int                    numPocStCurrAfter     = decRps->m_numPocStCurrAfter;
     4145  const Int                    numPocLtCurr          = decRps->m_numPocLtCurr;
     4146
     4147  Int rIdx = 0;
     4148  while( rIdx < numRpsCurrTempList0 )
     4149  {
     4150    for(Int  i = 0; i < numPocStCurrBefore  &&  rIdx < numRpsCurrTempList0; rIdx++, i++ )
     4151    {
     4152      refPicListTemp0[ rIdx ] = refPicSetStCurrBefore[ i ];
     4153    }   
     4154
     4155    for(Int  i = 0;  i < numPocStCurrAfter  &&  rIdx < numRpsCurrTempList0; rIdx++, i++ )  // (8 8)
     4156    {
     4157      refPicListTemp0[ rIdx ] = refPicSetStCurrAfter[ i ];
     4158    }
     4159
     4160    for(Int  i = 0; i < numPocLtCurr  &&  rIdx < numRpsCurrTempList0; rIdx++, i++ )
     4161    {
     4162      refPicListTemp0[ rIdx ] = refPicSetLtCurr[ i ];
     4163    }
     4164  }
     4165
     4166  // The list RefPicList0 is constructed as follows:
     4167
     4168  TComRefPicListModification* rplm = getRefPicListModification();
     4169  for( rIdx = 0; rIdx  <=  getNumRefIdxL0ActiveMinus1(); rIdx++ )      //   (8-9)
     4170  {
     4171    m_apcRefPicList[0][ rIdx ] = rplm->getRefPicListModificationFlagL0( ) ? refPicListTemp0[ rplm->getListEntryL0( rIdx )] : refPicListTemp0[ rIdx ];
     4172
     4173    // The decoding process below slice level requires the marking status
     4174    // of the reference pictures, when decoding the RPS. So store it here.
     4175    m_bIsUsedAsLongTerm[ 0 ][ rIdx ] = m_apcRefPicList[ 0 ][ rIdx ]->getIsLongTerm();
     4176    m_aiRefPOCList     [ 0 ][ rIdx ] = m_apcRefPicList[ 0 ][ rIdx ]->getPOC();
     4177    m_aiRefLayerIdList [ 0 ][ rIdx ] = m_apcRefPicList[ 0 ][ rIdx ]->getLayerId();
     4178  }
     4179
     4180  std::vector<TComPic*> refPicListTemp1;
     4181  refPicListTemp1.resize((MAX_NUM_REF+1),NULL);
     4182
     4183  if (getSliceType() == B_SLICE )
     4184  {
     4185    // When the slice is a B slice, the variable NumRpsCurrTempList1 is set equal to
     4186    // Max( num_ref_idx_l1_active_minus1 + 1, NumPicTotalCurr ) and the list RefPicListTemp1 is constructed as follows:
     4187    Int numRpsCurrTempList1 = std::max( getNumRefIdxL1ActiveMinus1() + 1, getNumPicTotalCurr() );
     4188
     4189    rIdx = 0;
     4190    while( rIdx < numRpsCurrTempList1 )
     4191    {
     4192      for( Int i = 0; i < numPocStCurrAfter  &&  rIdx < numRpsCurrTempList1; rIdx++, i++ )
     4193      {
     4194        refPicListTemp1[ rIdx ] = refPicSetStCurrAfter[ i ];
     4195      }
     4196      for( Int i = 0;  i < numPocStCurrBefore  &&  rIdx < numRpsCurrTempList1; rIdx++, i++ )  // (8-10)
     4197      {
     4198        refPicListTemp1[ rIdx ] = refPicSetStCurrBefore[ i ];
     4199      }         
     4200      for( Int i = 0; i < numPocLtCurr  &&  rIdx < numRpsCurrTempList1; rIdx++, i++ )
     4201      {
     4202        refPicListTemp1[ rIdx ] = refPicSetLtCurr[ i ];
     4203      }
     4204    }
     4205  }
     4206
     4207  if (getSliceType() == B_SLICE )
     4208  {
     4209    //   When the slice is a B slice, the list RefPicList1 is constructed as follows:
     4210    for( rIdx = 0; rIdx  <=  getNumRefIdxL1ActiveMinus1(); rIdx++ )      // (F 68)
     4211    {
     4212      m_apcRefPicList[ 1 ][ rIdx ] = rplm->getRefPicListModificationFlagL1() ? refPicListTemp1[ rplm->getListEntryL1( rIdx ) ] : refPicListTemp1[ rIdx ];
     4213
     4214      // The decoding process below slice level requires the marking status
     4215      // of the reference pictures, when decoding the RPS. So store it here.
     4216      m_bIsUsedAsLongTerm[ 1 ][ rIdx ] = m_apcRefPicList[ 1 ][ rIdx ]->getIsLongTerm();
     4217      m_aiRefPOCList     [ 1 ][ rIdx ] = m_apcRefPicList[ 1 ][ rIdx ]->getPOC();
     4218      m_aiRefLayerIdList [ 1 ][ rIdx ] = m_apcRefPicList[ 1 ][ rIdx ]->getLayerId();
     4219    }
     4220  }
     4221}
     4222
     4223Int TComSlice::getNumPicTotalCurr() const
     4224{
     4225  Int numPicTotalCurr = 0;
     4226#if NH_MV_FIX_NUM_POC_TOTAL_CUR
     4227  if ( !isIdr()  )
     4228  {
     4229    const TComStRefPicSet* stRps = getStRps( getCurrRpsIdx() );
     4230#endif
     4231    for( Int i = 0; i < stRps->getNumNegativePicsVar(); i++ )
     4232    {
     4233      if( stRps->getUsedByCurrPicS0Var( i ) )
     4234      {
     4235        numPicTotalCurr++;
     4236      }
     4237    }
     4238    for( Int i = 0; i < stRps->getNumPositivePicsVar(); i++)  //(7 55)
     4239    {
     4240      if( stRps->getUsedByCurrPicS1Var(i) )
     4241      {
     4242        numPicTotalCurr++;
     4243      }
     4244    }
     4245    for( Int i = 0; i < getNumLongTermSps() + getNumLongTermPics(); i++ )
     4246    {
     4247      if( getUsedByCurrPicLtVar( i ) )
     4248      {
     4249        numPicTotalCurr++;
     4250      }
     4251    }
     4252#if NH_MV_FIX_NUM_POC_TOTAL_CUR
     4253  }
     4254#endif
     4255
     4256  if ( decProcAnnexF() )
     4257  {
     4258    numPicTotalCurr += getNumActiveRefLayerPics();
     4259  }
     4260  return numPicTotalCurr;
     4261}
     4262
     4263
     4264
     4265Int TComSlice::getPocLsbLtVar( Int i )
     4266{
     4267  Int pocLsbLtVar;
     4268  if (i < getNumLongTermSps() )
     4269  {
     4270
     4271    pocLsbLtVar = getSPS()->getLtRefPicPocLsbSps( getLtIdxSps( i ) );
     4272  }
     4273  else
     4274  {
     4275    pocLsbLtVar = getPocLsbLt( i );
     4276  }
     4277  return pocLsbLtVar;
     4278}
     4279
     4280
     4281Bool TComSlice::getUsedByCurrPicLtVar( Int i ) const
     4282{
     4283  Bool usedByCurrPicLtVar;
     4284  if (i < getNumLongTermSps() )
     4285  {
     4286    usedByCurrPicLtVar = getSPS()->getUsedByCurrPicLtSPSFlag( getLtIdxSps( i ) );
     4287  }
     4288  else
     4289  {
     4290    usedByCurrPicLtVar = getUsedByCurrPicLtFlag( i );
     4291  }
     4292  return usedByCurrPicLtVar;
     4293}
     4294
     4295
     4296Int TComSlice::getDeltaPocMsbCycleLtVar( Int i ) const
     4297{
     4298  Int deltaPocMsbCycleVar;
     4299  if (i == 0 || i == getNumLongTermSps() )
     4300  {
     4301    deltaPocMsbCycleVar = getDeltaPocMsbCycleLt( i );
     4302  }
     4303  else
     4304  {
     4305    deltaPocMsbCycleVar = getDeltaPocMsbCycleLt( i ) + getDeltaPocMsbCycleLtVar( i - 1 );
     4306  }
     4307  return deltaPocMsbCycleVar;
     4308}
    39544309
    39554310#endif
     
    40744429
    40754430Void TComSlice::checkInCompPredRefLayers()
    4076 {
     4431{ 
    40774432  if ( getInCompPredFlag() )
    40784433  {
    40794434    for (Int i = 0; i < getNumCurCmpLIds(); i++ )
    4080     {
     4435    {     
    40814436      assert( getIvPic(!getIsDepth(), getInCmpRefViewIdcs( i ) ) != NULL );       
    40824437      //  It is a requirement of bitstream conformance that there
    40834438      //  is a picture in the DPB with PicOrderCntVal equal to the PicOrderCntVal of the current picture,
    40844439      //  and a nuh_layer_id value equal to ViewCompLayerId[ inCmpRefViewIdcs[ i ] ][ !DepthFlag ].
     4440    }
     4441  }
     4442}
     4443
     4444Void TComSlice::setPocsInCurrRPSs()
     4445{
     4446  // Currently only needed at decoder side;
     4447  m_pocsInCurrRPSs.clear();   
     4448  std::vector<TComPic*>** rpsCurr = getPic()->getDecodedRps()->m_refPicSetsCurr;
     4449  for (Int i = 0 ; i < 3; i++ )
     4450  {
     4451    for( Int j = 0; j < rpsCurr[i]->size(); j++ )
     4452    {
     4453      m_pocsInCurrRPSs.push_back( (*rpsCurr[i])[j]->getPOC() );
    40854454    }
    40864455  }
     
    46134982
    46144983  ProfileTierLevel* curProfileTierLevel = getGeneralPTL( );
     4984  assert( curProfileTierLevel != NULL );
    46154985
    46164986  if( !profilePresentFlag )
     
    46445014Void TComPTL::inferSubLayerValues(Int maxNumSubLayersMinus1, Int k, TComPTL* refPTL)
    46455015{
    4646   assert( k == 0 || refPTL != NULL );
    4647 
     5016  assert( k == 0 || refPTL != NULL );   
    46485017  for (Int i = maxNumSubLayersMinus1; i >= 0; i--)
    46495018  {
     
    46655034    }   
    46665035
     5036    assert( refProfileTierLevel != NULL );
    46675037    ProfileTierLevel* curProfileTierLevel = getSubLayerPTL( i );
     5038    assert( curProfileTierLevel != NULL );
    46685039    if( !getSubLayerLevelPresentFlag( i ) )
    46695040    {
     
    48835254}
    48845255
     5256
     5257Int TComDpbSize::getVpsMaxLatencyPictures( Int i, Int j ) const
     5258{
     5259  return getMaxVpsNumReorderPics( i, j ) + getMaxVpsLatencyIncreasePlus1(i, j) - 1;
     5260}
     5261
    48855262Void Window::scaleOffsets( Int scal )
    48865263{
     
    48945271  }
    48955272}
    4896 #endif
     5273
     5274Void TComStRefPicSet::inferRps( Int stRpsIdx, TComSPS* sps, Bool encoder )
     5275{
     5276  if ( getInterRefPicSetPredictionFlag() )
     5277  {
     5278    // When inter_ref_pic_set_prediction_flag is equal to 1, the variables DeltaPocS0[ stRpsIdx ][ i ], UsedByCurrPicS0[ stRpsIdx ][ i ],
     5279    // NumNegativePics[ stRpsIdx ], DeltaPocS1[ stRpsIdx ][ i ], UsedByCurrPicS1[ stRpsIdx ][ i ] and NumPositivePics[ stRpsIdx ] are
     5280    // derived as follows:
     5281
     5282    Int i = 0;
     5283    Int refRpsIdx = getRefRpsIdx( stRpsIdx );
     5284    TComStRefPicSet* refRps = sps->getStRefPicSet( refRpsIdx );
     5285
     5286    for( Int j = refRps->getNumPositivePicsVar( ) - 1; j >= 0; j-- )
     5287    {
     5288      Int dPoc = refRps->getDeltaPocS1Var( j ) + getDeltaRps();
     5289      if( dPoc < 0  &&  getUseDeltaFlag( refRps->getNumNegativePicsVar( ) + j ) )
     5290      {
     5291        setDeltaPocS0Var     ( i, dPoc );
     5292        setUsedByCurrPicS0Var( i++ , getUsedByCurrPicFlag( refRps->getNumNegativePicsVar( ) + j ) );
     5293      }
     5294    }
     5295    if( getDeltaRps() < 0  && getUseDeltaFlag( refRps->getNumDeltaPocs() ) )   //   (7 59)
     5296    {
     5297      setDeltaPocS0Var( i,  getDeltaRps() );
     5298      setUsedByCurrPicS0Var( i++ , getUsedByCurrPicFlag( refRps->getNumDeltaPocs() ) );
     5299    }
     5300    for( Int j = 0; j < refRps->getNumNegativePicsVar(); j++ )
     5301    {
     5302      Int dPoc = refRps->getDeltaPocS0Var( j ) + getDeltaRps();
     5303      if( dPoc < 0  &&  getUseDeltaFlag( j ) )
     5304      {
     5305        setDeltaPocS0Var( i , dPoc);
     5306        setUsedByCurrPicS0Var( i++ , getUsedByCurrPicFlag( j )) ;
     5307      }
     5308    }
     5309
     5310    setNumNegativePicsVar( i );
     5311
     5312    i = 0;
     5313    for( Int j = refRps->getNumNegativePicsVar() - 1; j  >=  0; j-- )
     5314    {
     5315      Int dPoc = refRps->getDeltaPocS0Var( j ) + getDeltaRps();
     5316      if( dPoc > 0  &&  getUseDeltaFlag( j ) )
     5317      {
     5318        setDeltaPocS1Var( i, dPoc );
     5319        setUsedByCurrPicS1Var(  i++, getUsedByCurrPicFlag( j ) ) ;
     5320      }
     5321    }
     5322
     5323    if( getDeltaRps() > 0  &&  getUseDeltaFlag( refRps->getNumDeltaPocs() ) ) //  (7 60)
     5324    {
     5325      setDeltaPocS1Var( i , getDeltaRps() );
     5326      setUsedByCurrPicS1Var( i++ , getUsedByCurrPicFlag( refRps->getNumDeltaPocs() ));
     5327    }
     5328
     5329    for( Int j = 0; j < refRps->getNumPositivePicsVar( ); j++)
     5330    {
     5331      Int dPoc = refRps->getDeltaPocS1Var( j ) + getDeltaRps();
     5332      if( dPoc > 0  &&  getUseDeltaFlag( refRps->getNumNegativePicsVar() + j ) )
     5333      {
     5334        setDeltaPocS1Var( i, dPoc);
     5335        setUsedByCurrPicS1Var( i++, getUsedByCurrPicFlag( refRps->getNumNegativePicsVar() + j ));
     5336      }
     5337    }
     5338    setNumPositivePicsVar(  i );
     5339  }
     5340  else
     5341  {
     5342    // When inter_ref_pic_set_prediction_flag is equal to 0, the variables NumNegativePics[ stRpsIdx ], NumPositivePics[ stRpsIdx ],
     5343    // UsedByCurrPicS0[ stRpsIdx ][ i ], UsedByCurrPicS1[ stRpsIdx ][ i ], DeltaPocS0[ stRpsIdx ][ i ] and DeltaPocS1[ stRpsIdx ][ i ]
     5344    // are derived as follows:
     5345
     5346    setNumNegativePicsVar( getNumNegativePics( ) );        //  (7 61)
     5347    setNumPositivePicsVar( getNumPositivePics( ) );         //  (7 62)
     5348
     5349    for (Int i = 0 ; i < getNumNegativePics(); i++ )
     5350    {     
     5351      setUsedByCurrPicS0Var( i,  getUsedByCurrPicS0Flag( i ) ); //  (7 63)
     5352      if (i == 0 )
     5353      {
     5354        setDeltaPocS0Var( i , -( getDeltaPocS0Minus1( i ) + 1 )); // (7 65)
     5355      }
     5356      else
     5357      {
     5358        setDeltaPocS0Var( i , getDeltaPocS0Var( i - 1 ) - ( getDeltaPocS0Minus1( i ) + 1 )); //  (7 67)
     5359      }
     5360    }
     5361
     5362    for (Int i = 0 ; i < getNumPositivePics(); i++ )
     5363    {     
     5364      setUsedByCurrPicS1Var( i,  getUsedByCurrPicS1Flag( i ) ); //  (7 64)
     5365
     5366      if (i == 0 )
     5367      {
     5368        setDeltaPocS1Var( i , getDeltaPocS1Minus1( i ) + 1    );      // (7 66)
     5369      }
     5370      else
     5371      {
     5372        setDeltaPocS1Var( i , getDeltaPocS1Var( i - 1 ) + ( getDeltaPocS1Minus1( i ) + 1 )); //  (7 68)
     5373      }
     5374    }
     5375  }
     5376}
     5377
     5378#endif
  • branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComSlice.h

    r1313 r1317  
    5353class TComTrQuant;
    5454#if NH_MV
     55class TComDecodedRps;
    5556class TComPicLists;
    5657class TComVPS;
     
    6869
    6970/// Reference Picture Set class
     71
     72#if NH_MV
     73class TComStRefPicSet
     74{
     75  // This class is currently only used by the decoder.
     76  // TBD: Modify encoder to use also it.
     77
     78private:
     79
     80  // Syntax elements:
     81
     82  Bool m_interRefPicSetPredictionFlag;
     83  Int  m_deltaIdxMinus1;
     84  Bool m_deltaRpsSign;
     85  Int  m_absDeltaRpsMinus1;
     86  Bool m_usedByCurrPicFlag  [ MAX_NUM_PICS_RPS ];
     87  Bool m_useDeltaFlag       [ MAX_NUM_PICS_RPS ];
     88  Int  m_numNegativePics;   
     89  Int  m_numPositivePics;   
     90  Int  m_deltaPocS0Minus1   [ MAX_NUM_PICS_RPS ];
     91  Bool m_usedByCurrPicS0Flag[ MAX_NUM_PICS_RPS ];
     92  Int  m_deltaPocS1Minus1   [ MAX_NUM_PICS_RPS ];
     93  Bool m_usedByCurrPicS1Flag[ MAX_NUM_PICS_RPS ];
     94
     95  // Semantic variables:
     96  Int m_deltaPocS0Var       [ MAX_NUM_PICS_RPS ];
     97  Int m_deltaPocS1Var       [ MAX_NUM_PICS_RPS ];
     98  Int m_usedByCurrPicS0Var  [ MAX_NUM_PICS_RPS ];
     99  Int m_usedByCurrPicS1Var  [ MAX_NUM_PICS_RPS ];
     100  Int m_numNegativePicsVar  ;
     101  Int m_numPositivePicsVar  ;
     102
     103public:
     104
     105  TComStRefPicSet( )
     106  {
     107    // Set default inheritance values:
     108    setInterRefPicSetPredictionFlag( false );
     109    setDeltaIdxMinus1( 0 );
     110    for (Int j = 0; j < MAX_NUM_PICS_RPS; j++)
     111    {
     112      setUseDeltaFlag( j, true  );
     113    }   
     114  }
     115
     116  // Syntax elements:
     117  Void  setInterRefPicSetPredictionFlag( Bool flag )           { m_interRefPicSetPredictionFlag = flag; }
     118  Bool  getInterRefPicSetPredictionFlag(  ) const              { return m_interRefPicSetPredictionFlag; }
     119
     120  Void  setDeltaIdxMinus1( Int  val )                          { m_deltaIdxMinus1 = val;                }
     121  Int   getDeltaIdxMinus1(  ) const                            { return m_deltaIdxMinus1;               }
     122
     123  Void  setDeltaRpsSign( Bool flag )                           { m_deltaRpsSign = flag;                 }
     124  Bool  getDeltaRpsSign(  ) const                              { return m_deltaRpsSign;                 }
     125
     126  Void  setAbsDeltaRpsMinus1( Int  val )                       { m_absDeltaRpsMinus1 = val;             }
     127  Int   getAbsDeltaRpsMinus1(  ) const                         { return m_absDeltaRpsMinus1;            }
     128
     129  Void  setUsedByCurrPicFlag( Int j, Bool flag )               { m_usedByCurrPicFlag[j] = flag;         }
     130  Bool  getUsedByCurrPicFlag( Int j ) const                    { return m_usedByCurrPicFlag[j];         }
     131
     132  Void  setUseDeltaFlag( Int j, Bool flag )                    { m_useDeltaFlag[j] = flag;              }
     133  Bool  getUseDeltaFlag( Int j ) const                         { return m_useDeltaFlag[j];              }
     134
     135  Void  setNumNegativePics( Int  val )                         { m_numNegativePics = val;               }
     136  Int   getNumNegativePics(  ) const                           { return m_numNegativePics;              }
     137
     138  Void  setNumPositivePics( Int  val )                         { m_numPositivePics = val;               }
     139  Int   getNumPositivePics(  ) const                           { return m_numPositivePics;              }
     140
     141  Void  setDeltaPocS0Minus1( Int i, Int  val )                 { m_deltaPocS0Minus1[i] = val;           }
     142  Int   getDeltaPocS0Minus1( Int i ) const                     { return m_deltaPocS0Minus1[i];          }
     143
     144  Void  setUsedByCurrPicS0Flag( Int i, Bool flag )             { m_usedByCurrPicS0Flag[i] = flag;       }
     145  Bool  getUsedByCurrPicS0Flag( Int i ) const                  { return m_usedByCurrPicS0Flag[i];       }
     146
     147  Void  setDeltaPocS1Minus1( Int i, Int  val )                 { m_deltaPocS1Minus1[i] = val;           }
     148  Int   getDeltaPocS1Minus1( Int i ) const                     { return m_deltaPocS1Minus1[i];          }
     149
     150  Void  setUsedByCurrPicS1Flag( Int i, Bool flag )             { m_usedByCurrPicS1Flag[i] = flag;       }
     151  Bool  getUsedByCurrPicS1Flag( Int i ) const                  { return m_usedByCurrPicS1Flag[i];       }
     152
     153  // Semantics variables:
     154  Int   getRefRpsIdx(Int stRpsIdx ) const                      { return ( stRpsIdx - (getDeltaIdxMinus1() +  1) ); }
     155  Int   getDeltaRps()  const                                   { return (  ( 1 - 2 * getDeltaRpsSign() ) * ( getAbsDeltaRpsMinus1() + 1 ) ); }
     156  Int   getNumDeltaPocs() const                                { return ( getNumNegativePicsVar() + getNumPositivePicsVar());    }
     157
     158  Void  setNumNegativePicsVar( Int  val )                      { m_numNegativePicsVar = val;            }
     159  Int   getNumNegativePicsVar(  ) const                        { return m_numNegativePicsVar;           }
     160
     161  Void  setNumPositivePicsVar( Int  val )                      { m_numPositivePicsVar = val;            }
     162  Int   getNumPositivePicsVar(  ) const                        { return m_numPositivePicsVar;           }
     163
     164  Void  setDeltaPocS0Var( Int i, Int  val )                    { m_deltaPocS0Var[i] = val;              }
     165  Int   getDeltaPocS0Var( Int i ) const                        { return m_deltaPocS0Var[i];             }
     166
     167  Void  setUsedByCurrPicS0Var( Int i, Bool flag )              { m_usedByCurrPicS0Var[i] = flag;       }
     168  Bool  getUsedByCurrPicS0Var( Int i ) const                   { return m_usedByCurrPicS0Var[i];       }
     169
     170  Void  setDeltaPocS1Var( Int i, Int  val )                    { m_deltaPocS1Var[i] = val;             }
     171  Int   getDeltaPocS1Var( Int i ) const                        { return m_deltaPocS1Var[i];            }
     172
     173  Void  setUsedByCurrPicS1Var( Int i, Bool flag )              { m_usedByCurrPicS1Var[i] = flag;       }
     174  Bool  getUsedByCurrPicS1Var( Int i ) const                   { return m_usedByCurrPicS1Var[i];       }
     175
     176  Void  inferRps( Int stRpsIdx, TComSPS* sps, Bool encoder );
     177};
     178
     179#endif
     180
    70181class TComReferencePictureSet
    71182{
     
    302413{
    303414  ProfileTierLevel m_generalPTL;
     415#if !NH_MV
    304416  ProfileTierLevel m_subLayerPTL    [MAX_TLAYER-1];      // max. value of max_sub_layers_minus1 is MAX_TLAYER-1 (= 6)
    305417  Bool m_subLayerProfilePresentFlag [MAX_TLAYER-1];
    306418  Bool m_subLayerLevelPresentFlag   [MAX_TLAYER-1];
     419#else
     420  ProfileTierLevel m_subLayerPTL    [MAX_TLAYER];        // However, highest index is 6, so we need one more.
     421  Bool m_subLayerProfilePresentFlag [MAX_TLAYER];
     422  Bool m_subLayerLevelPresentFlag   [MAX_TLAYER];
     423#endif
    307424
    308425public:
     
    804921
    805922  Void          setMaxVpsLatencyIncreasePlus1( Int i, Int j, Int  val )              { m_maxVpsLatencyIncreasePlus1[i][j] = val;                  }
    806   Int           getMaxVpsLatencyIncreasePlus1( Int i, Int j ) const                  { return m_maxVpsLatencyIncreasePlus1[i][j];                 }
     923  Int           getMaxVpsLatencyIncreasePlus1( Int i, Int j ) const                  { return m_maxVpsLatencyIncreasePlus1[i][j];                 }
     924  Int           getVpsMaxLatencyPictures     ( Int i, Int j ) const;
    807925};
    808926#endif
     
    9011019  Int         m_defaultDirectDependencyType;
    9021020 
    903 #if H_MV_HLS7_GEN
    904   Int         m_directDependencyType     [MAX_NUM_LAYERS] [MAX_NUM_LAYERS];
    905 #endif
    9061021  Bool        m_vpsVuiPresentFlag;
    9071022  TComVPSVUI  m_vpsVUI;
    908 #if !H_MV_HLS7_GEN
    9091023  Int         m_directDependencyType     [MAX_NUM_LAYERS] [MAX_NUM_LAYERS];
    910 #endif
    9111024
    9121025  // VPS EXTENSION SEMANTICS VARIABLES
     
    11191232  Void    setLayerSetIdxForOlsMinus1( Int outLayerSetIdx, Int val )             { m_layerSetIdxForOlsMinus1[ outLayerSetIdx ]  = val; }
    11201233  Int     getLayerSetIdxForOlsMinus1( Int outLayerSetIdx )           const      { return m_layerSetIdxForOlsMinus1[ outLayerSetIdx ]; }
    1121 #if NH_MV_FIX_TICKET_105
    11221234  Int     getLayerSetIdxForOlsMinus1Len( Int outLayerSetIdx )        const      { return gCeilLog2( getNumLayerSets() - 1 ); }
    1123 #else
    1124   Int     getLayerSetIdxForOlsMinus1Len( Int outLayerSetIdx )        const      { return gCeilLog2( getNumLayerSets() ); }
    1125 #endif
    11261235
    11271236  Void    setOutputLayerFlag( Int outLayerSetIdx, Int i, Bool flag )            { m_outputLayerFlag[ outLayerSetIdx ][ i ] = flag; }
     
    18031912
    18041913  TComRPSList      m_RPSList;
     1914#if NH_MV
     1915  std::vector<TComStRefPicSet> m_stRefPicSets;
     1916#endif
    18051917  Bool             m_bLongTermRefsPresent;
    18061918  Bool             m_TMVPFlagsPresent;
     
    18251937  UInt             m_uiBitsForPOC;
    18261938  UInt             m_numLongTermRefPicSPS;
     1939#if NH_MV
     1940  Int              m_numShortTermRefPicSets;
     1941#endif
    18271942  UInt             m_ltRefPicPocLsbSps[MAX_NUM_LONG_TERM_REF_PICS];
    18281943  Bool             m_usedByCurrPicLtSPSFlag[MAX_NUM_LONG_TERM_REF_PICS];
     
    18381953  TComScalingList  m_scalingList;
    18391954  UInt             m_uiMaxDecPicBuffering[MAX_TLAYER];
     1955#if NH_MV
     1956  UInt             m_uiSpsMaxLatencyIncreasePlus1[MAX_TLAYER]; 
     1957  // Calling a member m_uiMaxLatencyIncrease although it is m_uiMaxLatencyIncreasePlus1 is really bad style. 
     1958#else
    18401959  UInt             m_uiMaxLatencyIncrease[MAX_TLAYER];  // Really max latency increase plus 1 (value 0 expresses no limit)
     1960#endif
    18411961
    18421962  Bool             m_useStrongIntraSmoothing;
     
    19112031  Void                   setConformanceWindow(Window& conformanceWindow )                                { m_conformanceWindow = conformanceWindow;                             }
    19122032
     2033#if NH_MV
     2034  UInt                   getNumLongTermRefPicsSps() const                                                 { return m_numLongTermRefPicSPS;                                       }
     2035#endif
     2036 
    19132037  UInt                   getNumLongTermRefPicSPS() const                                                 { return m_numLongTermRefPicSPS;                                       }
    19142038  Void                   setNumLongTermRefPicSPS(UInt val)                                               { m_numLongTermRefPicSPS = val;                                        }
     
    19392063  Void                   setBitsForPOC( UInt u )                                                         { m_uiBitsForPOC = u;                                                  }
    19402064  UInt                   getBitsForPOC() const                                                           { return m_uiBitsForPOC;                                               }
     2065#if NH_MV
     2066  UInt                   getMaxPicOrderCntLsb() const                                                    { return (1 << ( getLog2MaxPicOrderCntLsbMinus4() + 4) );  }
     2067  Int                    getLog2MaxPicOrderCntLsbMinus4() const                                          { return (getBitsForPOC() - 4);  }
     2068#endif
    19412069  Bool                   getUseAMP() const                                                               { return m_useAMP;                                                     }
    19422070  Void                   setUseAMP( Bool b )                                                             { m_useAMP = b;                                                        }
     
    19542082  const TComRPSList*     getRPSList() const                                                              { return &m_RPSList;                                                   }
    19552083  TComRPSList*           getRPSList()                                                                    { return &m_RPSList;                                                   }
     2084#if NH_MV
     2085  Void                   initStRefPicSets( )                                                             { m_stRefPicSets.resize( getNumShortTermRefPicSets() );                }
     2086  TComStRefPicSet*       getStRefPicSet( Int i )                                                         { return &(m_stRefPicSets[i]);                                         }
     2087  const TComStRefPicSet* getStRefPicSet( Int i ) const                                                   { return &(m_stRefPicSets[i]);                                         }
     2088  Bool                   getLongTermRefPicsPresentFlag() const                                           { return m_bLongTermRefsPresent;                                       }
     2089  Void                   setLongTermRefPicsPresentFlag(Bool b)                                           { m_bLongTermRefsPresent=b;                                            }
     2090#else
    19562091  Bool                   getLongTermRefsPresent() const                                                  { return m_bLongTermRefsPresent;                                       }
    19572092  Void                   setLongTermRefsPresent(Bool b)                                                  { m_bLongTermRefsPresent=b;                                            }
     2093#endif
    19582094  Bool                   getTMVPFlagsPresent() const                                                     { return m_TMVPFlagsPresent;                                           }
    19592095  Void                   setTMVPFlagsPresent(Bool b)                                                     { m_TMVPFlagsPresent=b;                                                }
     2096#if NH_MV
     2097  Bool                   getSpsTemporalMvpEnabledFlag() const                                            { return m_TMVPFlagsPresent;                                           }
     2098#endif
    19602099  // physical transform
    19612100  Void                   setMaxTrSize( UInt u )                                                          { m_uiMaxTrSize = u;                                                   }
     
    19882127  Void                   setPCMFilterDisableFlag( Bool bValue )                                          { m_bPCMFilterDisableFlag = bValue;                                    }
    19892128  Bool                   getPCMFilterDisableFlag() const                                                 { return m_bPCMFilterDisableFlag;                                      }
    1990 
     2129#if NH_MV
     2130  Void                  setNumShortTermRefPicSets( Int  val )                                            { m_numShortTermRefPicSets = val; }
     2131  Int                   getNumShortTermRefPicSets(  )const                                               { return m_numShortTermRefPicSets; }
     2132#endif
    19912133  Bool                   getScalingListFlag() const                                                      { return m_scalingListEnabledFlag;                                     }
    19922134  Void                   setScalingListFlag( Bool b )                                                    { m_scalingListEnabledFlag  = b;                                       }
     
    19982140  UInt                   getMaxDecPicBuffering(UInt tlayer) const                                        { return m_uiMaxDecPicBuffering[tlayer];                               }
    19992141  Void                   setMaxDecPicBuffering( UInt ui, UInt tlayer )                                   { assert(tlayer < MAX_TLAYER); m_uiMaxDecPicBuffering[tlayer] = ui;    }
     2142#if NH_MV
     2143  UInt                   getSpsMaxDecPicBufferingMinus1(UInt tlayer) const                               { return m_uiMaxDecPicBuffering[tlayer] -1 ;                           }
     2144  UInt                   getSpsMaxLatencyIncreasePlus1(UInt tlayer) const                                { return m_uiSpsMaxLatencyIncreasePlus1[tlayer];                       }
     2145  Void                   setSpsMaxLatencyIncreasePlus1( UInt ui , UInt tlayer)                           { m_uiSpsMaxLatencyIncreasePlus1[tlayer] = ui;                         }
     2146  Int                    getSpsMaxLatencyPictures( Int i )  const                                       { return ( getSpsMaxNumReorderPics(i) + getSpsMaxLatencyIncreasePlus1(i)-1); }
     2147#else
    20002148  UInt                   getMaxLatencyIncrease(UInt tlayer) const                                        { return m_uiMaxLatencyIncrease[tlayer];                               }
    20012149  Void                   setMaxLatencyIncrease( UInt ui , UInt tlayer)                                   { m_uiMaxLatencyIncrease[tlayer] = ui;                                 }
     2150#endif
     2151
     2152#if NH_MV
     2153  Int                    getSpsMaxNumReorderPics(Int i ) const                                           { return getNumReorderPics( i );                                       }
     2154#endif
    20022155
    20032156  Void                   setUseStrongIntraSmoothing(Bool bVal)                                           { m_useStrongIntraSmoothing = bVal;                                    }
     
    21332286  Void    setRefPicSetIdxL1(UInt idx, UInt refPicSetIdx) { assert(idx<REF_PIC_LIST_NUM_IDX); m_RefPicSetIdxL1[idx] = refPicSetIdx; }
    21342287#if NH_MV
    2135   // Why not a listIdx for all members, would avoid code duplication??
     2288 
    21362289  Void    setRefPicSetIdxL(UInt li, UInt idx, UInt refPicSetIdx) {( li==0 ? m_RefPicSetIdxL0[idx] : m_RefPicSetIdxL1[idx] ) = refPicSetIdx;              }
    21372290  UInt    getRefPicSetIdxL(UInt li, UInt idx )                   { return ( li == 0 ) ? m_RefPicSetIdxL0[idx] : m_RefPicSetIdxL1[idx] ;                  }
    21382291  Void    setRefPicListModificationFlagL(UInt li, Bool flag)     { ( li==0  ? m_refPicListModificationFlagL0 : m_refPicListModificationFlagL1 ) = flag;  }
    21392292  Bool    getRefPicListModificationFlagL(UInt li )               { return ( li== 0) ? m_refPicListModificationFlagL0 : m_refPicListModificationFlagL1;   }
     2293
     2294  Int     getListEntryL0( Int i) const                           { assert(i<REF_PIC_LIST_NUM_IDX); return m_RefPicSetIdxL0[i];         }
     2295  Int     getListEntryL1( Int i) const                           { assert(i<REF_PIC_LIST_NUM_IDX); return m_RefPicSetIdxL1[i];         }
     2296
     2297  Int     getListEntryLXLen( Int numPicTotalCur ) const          { return gCeilLog2( numPicTotalCur );                                 } 
     2298
     2299  Void    setListEntryL0( Int i, Int  val )                      { m_RefPicSetIdxL0[i] = val;                                          }
     2300  Void    setListEntryL1( Int i, Int  val )                      { m_RefPicSetIdxL1[i] = val;                                          }
     2301
     2302
    21402303#endif
    21412304};
     
    24702633private:
    24712634  //  Bitstream writing
     2635#if NH_MV
     2636  Bool                       m_firstSliceSegmentInPicFlag;
     2637#endif
    24722638  Bool                       m_saoEnabledFlag[MAX_NUM_CHANNEL_TYPE];
    24732639  Int                        m_iPPSId;               ///< picture parameter set ID
     
    24752641#if NH_MV
    24762642  Int                        m_slicePicOrderCntLsb;   
     2643  Bool                       m_shortTermRefPicSetSpsFlag;
     2644  Int                        m_shortTermRefPicSetIdx;
     2645  Int                        m_numLongTermSps;
     2646  Int                        m_numLongTermPics;
     2647  Int                        m_ltIdxSps                     [MAX_NUM_PICS_RPS];
     2648  Int                        m_pocLsbLt                     [MAX_NUM_PICS_RPS];
     2649  Bool                       m_usedByCurrPicLtFlag          [MAX_NUM_PICS_RPS];
     2650  Bool                       m_deltaPocMsbPresentFlag       [MAX_NUM_PICS_RPS];
     2651  Int                        m_deltaPocMsbCycleLt           [MAX_NUM_PICS_RPS];
     2652  Bool                       m_sliceTemporalMvpEnabledFlag;
     2653  TComStRefPicSet            m_stRefPicSet;
    24772654#endif 
    24782655  Int                        m_iPOC;
     
    25102687  Int                        m_aiRefPOCList  [NUM_REF_PIC_LIST_01][MAX_NUM_REF+1];
    25112688#if NH_MV
    2512   Int         m_aiRefLayerIdList[2][MAX_NUM_REF+1];
     2689  Int                        m_aiRefLayerIdList[2][MAX_NUM_REF+1];
    25132690#endif
    25142691  Bool                       m_bIsUsedAsLongTerm[NUM_REF_PIC_LIST_01][MAX_NUM_REF+1];
     
    25702747  SliceType                  m_encCABACTableIdx;           // Used to transmit table selection across slices.
    25712748#if NH_MV
    2572   Bool       m_availableForTMVPRefFlag;
    2573 #endif
    2574 
    2575 #if NH_MV
     2749
    25762750  std::vector<TComPic*>* m_refPicSetInterLayer0;
    25772751  std::vector<TComPic*>* m_refPicSetInterLayer1;
     
    25842758
    25852759// Additional slice header syntax elements
    2586 #if !H_MV_HLS7_GEN
    25872760  Bool       m_pocResetFlag;
    2588 #endif
     2761
    25892762  Bool       m_crossLayerBlaFlag;
    25902763  Bool       m_discardableFlag;
     
    25962769  Int        m_pocResetIdc;
    25972770  Int        m_pocResetPeriodId;
     2771
     2772  Bool       m_hasPocResetPeriodIdPresent;
     2773  DecodingProcess m_decodingProcess;
     2774  DecodingProcess m_decProcPocAndRps;
    25982775  Bool       m_fullPocResetFlag;
    25992776  Int        m_pocLsbVal;
    2600   Bool       m_pocMsbValPresentFlag;
    2601   Int        m_pocMsbVal;
     2777  Bool       m_pocMsbCycleValPresentFlag;
     2778  Int        m_pocMsbCycleVal;
    26022779  Bool       m_pocMsbValRequiredFlag;
    26032780
     
    26762853  Void                        setSlicePicOrderCntLsb( Int i )                        { m_slicePicOrderCntLsb = i;                                    }
    26772854  Int                         getSlicePicOrderCntLsb(  )  const                      { return m_slicePicOrderCntLsb;                                 }
     2855
     2856  Bool                        getFirstSliceSegementInPicFlag() const                 {  return m_firstSliceSegmentInPicFlag;                         }
     2857  Void                        setFirstSliceSegementInPicFlag(Bool val)               { m_firstSliceSegmentInPicFlag = val;                           }
    26782858#endif
    26792859  Bool                        getPicOutputFlag() const                               { return m_PicOutputFlag;                                       }
     
    27342914  Void                        setBaseViewRefPicList( TComList<TComPic*> *pListPic, Int iViewIdx )      { m_pBaseViewRefPicList[iViewIdx] = pListPic; }                 
    27352915  Void                        setARPStepNum( TComPicLists*ivPicLists );                                                                             
     2916  Void                        setPocsInCurrRPSs( );
     2917
    27362918  TComPic*                    getBaseViewRefPic    ( UInt uiPOC , Int iViewIdx )     { return xGetRefPic( *m_pBaseViewRefPicList[iViewIdx], uiPOC ); }
    27372919  UInt                        getARPStepNum( )                                       { return m_nARPStepNum;                                         } 
     
    27462928  Bool                        getMvdL1ZeroFlag() const                               { return m_bLMvdL1Zero;                                         }
    27472929  Int                         getNumRpsCurrTempList() const;
     2930#if NH_MV
     2931  Int                         getNumPicTotalCurr() const;
     2932#endif
    27482933  Int                         getList1IdxToList0Idx( Int list1Idx ) const            { return m_list1IdxToList0Idx[list1Idx];                        }
    27492934  Void                        setReferenced(Bool b)                                  { m_bRefenced = b;                                              }
     
    27532938  Void                        setNalUnitType( NalUnitType e )                        { m_eNalUnitType      = e;                                      }
    27542939  NalUnitType                 getNalUnitType() const                                 { return m_eNalUnitType;                                        }
     2940#if NH_MV
     2941  std::string                 getNalUnitTypeString(    )                             { return NALU_TYPE_STR[ getNalUnitType() ]; };
     2942#endif
    27552943  Bool                        getRapPicFlag() const;
    27562944  Bool                        getIdrPicFlag() const                                  { return getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP; }
    27572945  Bool                        isIRAP() const                                         { return (getNalUnitType() >= 16) && (getNalUnitType() <= 23);  }
     2946#if NH_MV 
     2947  Bool                        isBla() const                                          { return ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP   )  || ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) || ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL ); }
     2948  Bool                        isIdr() const                                          { return ( getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL )  || ( getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ); }
     2949  Bool                        isCra() const                                          { return ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ); }
     2950
     2951  Bool                        isSlnr() const                                         { return ( getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N  ||   
     2952                                                                                                getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N    ||   
     2953                                                                                                getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N   ||   
     2954                                                                                                getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N   ||   
     2955                                                                                                getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N   ||   
     2956                                                                                                getNalUnitType() == NAL_UNIT_RESERVED_VCL_N10     ||
     2957                                                                                                getNalUnitType() == NAL_UNIT_RESERVED_VCL_N12     ||           
     2958                                                                                                getNalUnitType() == NAL_UNIT_RESERVED_VCL_N14     );  }
     2959 
     2960  Bool                        isRasl() const                                          { return ( getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R )  || ( getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N ); }
     2961  Bool                        isRadl() const                                          { return ( getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_R )  || ( getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N ); }
     2962  Bool                        isStsa() const                                          { return ( getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_R )  || ( getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N ); }
     2963  Bool                        isTsa()  const                                          { return ( getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_R )   || ( getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N ); }
     2964
     2965  Bool                        decProcClause8() const                                  { return ( m_decodingProcess == CLAUSE_8  ); }   
     2966  Bool                        decProcAnnexF()  const                                  { return ( decProcAnnexG()  || decProcAnnexH() || decProcAnnexI() ) ; }
     2967  Bool                        decProcAnnexG()  const                                  { return ( m_decodingProcess == ANNEX_G || decProcAnnexI()  ); }   
     2968  Bool                        decProcAnnexH()  const                                  { return ( m_decodingProcess == ANNEX_H  ); }   
     2969  Bool                        decProcAnnexI()  const                                  { return ( m_decodingProcess == ANNEX_I  ); }   
     2970  Int                         getCurrRpsIdx() const                                   { return ( getShortTermRefPicSetSpsFlag() ? getShortTermRefPicSetIdx() : getSPS()->getNumShortTermRefPicSets() ) ;}
     2971
     2972#endif
     2973
     2974
    27582975  Void                        checkCRA(const TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, NalUnitType& associatedIRAPType, TComList<TComPic *>& rcListPic);
    27592976  Void                        decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic, const bool bEfficientFieldIRAPEnabled);
     
    27742991  Void                        setRefPOC( Int i, RefPicList e, Int iRefIdx )          { m_aiRefPOCList[e][iRefIdx] = i;                               }
    27752992  Void                        setNumRefIdx( RefPicList e, Int i )                    { m_aiNumRefIdx[e]    = i;                                      }
     2993#if NH_MV
     2994  Int                         getNumRefIdxL0ActiveMinus1() const                     { return ( getNumRefIdx(REF_PIC_LIST_0) -1);                    }
     2995  Int                         getNumRefIdxL1ActiveMinus1() const                     { return ( getNumRefIdx(REF_PIC_LIST_1) -1);                    }
     2996#endif
    27762997  Void                        setPic( TComPic* p )                                   { m_pcPic             = p;                                      }
    27772998  Void                        setDepth( Int iDepth )                                 { m_iDepth            = iDepth;                                 }
     
    28273048  Void                        setTLayer( UInt uiTLayer )                             { m_uiTLayer = uiTLayer;                                        }
    28283049#if NH_MV
    2829   Int                         getTemporalId          ( )                             { return (Int) m_uiTLayer;                                      }
     3050  Int                         getTemporalId( ) const                                 { return (Int) m_uiTLayer;                                      }
    28303051#endif
    28313052
     
    28363057#if NH_MV
    28373058  Void                        createInterLayerReferencePictureSet( TComPicLists* ivPicLists, std::vector<TComPic*>& refPicSetInterLayer0, std::vector<TComPic*>& refPicSetInterLayer1 );
     3059  Void                        f834decProcForRefPicListConst();
     3060  Void                        cl834DecProcForRefPicListConst();
     3061
    28383062  static Void                 markIvRefPicsAsShortTerm    ( std::vector<TComPic*> refPicSetInterLayer0, std::vector<TComPic*> refPicSetInterLayer1 );
    28393063  static Void                 markCurrPic                 ( TComPic* currPic );
     
    28523076  Void                        setNoRaslOutputFlag( Bool val )                        { m_noRaslOutputFlag = val;                                     }
    28533077  Bool                        getNoRaslOutputFlag() const                            { return m_noRaslOutputFlag;                                    }
     3078
    28543079
    28553080  Void                        setHandleCraAsBlaFlag( Bool val )                      { m_handleCraAsBlaFlag = val;                                   }
     
    29153140  Bool                        getLFCrossSliceBoundaryFlag()                          { return m_LFCrossSliceBoundaryFlag;                            }
    29163141
     3142#if NH_MV
     3143  Void                        setShortTermRefPicSetSpsFlag( Bool flag )              { m_shortTermRefPicSetSpsFlag = flag;                           }
     3144  Bool                        getShortTermRefPicSetSpsFlag(  ) const                 { return m_shortTermRefPicSetSpsFlag;                           }
     3145
     3146  Int                         getShortTermRefPicSetIdxLen() const                    { return gCeilLog2( getSPS()->getNumShortTermRefPicSets() );    }
     3147  Void                        setShortTermRefPicSetIdx( Int  val )                   { m_shortTermRefPicSetIdx = val;                                }
     3148  Int                         getShortTermRefPicSetIdx(  ) const                     { return m_shortTermRefPicSetIdx;                               }
     3149 
     3150  Void                        setNumLongTermSps( Int  val )                          { m_numLongTermSps = val;                                       }
     3151  Int                         getNumLongTermSps(  ) const                            { return m_numLongTermSps;                                      }
     3152
     3153  Void                        setNumLongTermPics( Int  val )                         { m_numLongTermPics = val;                                      }
     3154  Int                         getNumLongTermPics(  ) const                           { return m_numLongTermPics;                                     }
     3155 
     3156  Int                         getLtIdxSpsLen() const                                 { return gCeilLog2( getSPS()->getNumLongTermRefPicsSps() );     }
     3157  Void                        setLtIdxSps( Int i, Int  val )                         { m_ltIdxSps[i] = val;                                          }
     3158  Int                         getLtIdxSps( Int i ) const                             { return m_ltIdxSps[i];                                         }
     3159
     3160  Int                         getPocLsbLtLen() const                                 { return (getSPS()->getLog2MaxPicOrderCntLsbMinus4()+ 4);       }
     3161  Void                        setPocLsbLt( Int i, Int  val )                         { m_pocLsbLt[i] = val;                                          }
     3162  Int                         getPocLsbLt( Int i ) const                             { return m_pocLsbLt[i];                                         }
     3163
     3164  Void                        setUsedByCurrPicLtFlag( Int i, Bool flag )             { m_usedByCurrPicLtFlag[i] = flag;                              }
     3165  Bool                        getUsedByCurrPicLtFlag( Int i ) const                  { return m_usedByCurrPicLtFlag[i];                              }
     3166
     3167  Void                        setDeltaPocMsbPresentFlag( Int i, Bool flag )          { m_deltaPocMsbPresentFlag[i] = flag;                           }
     3168  Bool                        getDeltaPocMsbPresentFlag( Int i ) const               { return m_deltaPocMsbPresentFlag[i];                           }
     3169
     3170  Void                        setDeltaPocMsbCycleLt( Int i, Int  val )               { m_deltaPocMsbCycleLt[i] = val;                                }
     3171  Int                         getDeltaPocMsbCycleLt( Int i ) const                   { return m_deltaPocMsbCycleLt[i];                               }
     3172
     3173  Void                        setSliceTemporalMvpEnabledFlag( Bool flag )            { m_enableTMVPFlag = flag;                         }
     3174  Bool                        getSliceTemporalMvpEnabledFlag(  ) const               { return m_enableTMVPFlag;                         }
     3175
     3176  TComStRefPicSet*            getLocalStRps( )                                       { return &m_stRefPicSet; };
     3177  const TComStRefPicSet*      getStRps( Int stRpsIdx ) const                         { return ( (stRpsIdx == getSPS()->getNumShortTermRefPicSets()) ? &m_stRefPicSet : getSPS()->getStRefPicSet( stRpsIdx ) ); };
     3178
     3179#endif
     3180
    29173181  Void                        setEnableTMVPFlag( Bool   b )                          { m_enableTMVPFlag = b;                                         }
    29183182  Bool                        getEnableTMVPFlag()                                    { return m_enableTMVPFlag;                                      }
     
    29223186
    29233187#if NH_MV
    2924   Void                        setAvailableForTMVPRefFlag( Bool   b )                 { m_availableForTMVPRefFlag = b;                                }
    2925   Bool                        getAvailableForTMVPRefFlag()                           { return m_availableForTMVPRefFlag;                             }
    2926 
    29273188  Void                        setLayerId     ( Int layerId )                         { m_layerId      = layerId;                                     }
    29283189  Int                         getLayerId     ()                 const                { return m_layerId;                                             }
     
    29323193  Void                        setViewIndex   ( Int viewIndex )                       { m_viewIndex = viewIndex;                                      }
    29333194  Int                         getViewIndex   ()                 const                { return m_viewIndex;                                           }
     3195
     3196  Void                        setDecodingProcess ( DecodingProcess decProc )         { m_decodingProcess = decProc;                                  }
     3197
     3198
    29343199#if NH_3D
    29353200#if NH_3D_TMVP
     
    29863251  Void                        checkCrossLayerBlaFlag ( ) const ;
    29873252
    2988 #if !H_MV_HLS7_GEN
     3253#if NH_MV
    29893254  Void                        setPocResetFlag( Bool flag )                           { m_pocResetFlag = flag;                                        }
    29903255  Bool                        getPocResetFlag(  ) const                              { return m_pocResetFlag;                                        }
     
    30103275  Void                        checkPocResetIdc( ) const                              { assert( !(getVPS()->getPocLsbNotPresentFlag( getLayerIdInVps() ) )  || !(getSlicePicOrderCntLsb() > 0 ) || !( getPocResetIdc() == 2) ); }
    30113276
     3277 
    30123278  Void                        setPocResetPeriodId( Int  val )                        { m_pocResetPeriodId = val;                                     }
    30133279  Int                         getPocResetPeriodId(  ) const                          { return m_pocResetPeriodId;                                    }
     
    30203286  Void                        checkPocLsbVal( ) const                                { assert( !(getVPS()->getPocLsbNotPresentFlag( getLayerIdInVps() ) )  || !getFullPocResetFlag() || ( getPocLsbVal() == 0 ) ); }
    30213287
     3288#if NH_MV
     3289  Void                        setHasPocResetPeriodIdPresent( Bool  val )              { m_hasPocResetPeriodIdPresent = val;                                }
     3290  Bool                        getHasPocResetPeriodIdPresent(  ) const                { return m_hasPocResetPeriodIdPresent;                               }
     3291
     3292  Void                        setPocMsbCycleValPresentFlag( Bool flag )              { m_pocMsbCycleValPresentFlag = flag;                                }
     3293  Bool                        getPocMsbCycleValPresentFlag(  )          const        { return m_pocMsbCycleValPresentFlag;                                }
     3294
     3295  Void                        setPocMsbCycleVal( Int  val )                          { m_pocMsbCycleVal = val;                                            }
     3296  Int                         getPocMsbCycleVal(  )         const                    { return m_pocMsbCycleVal;                                           }
     3297 
     3298  Int                         getPocLsbLtVar(Int i);
     3299  Bool                        getUsedByCurrPicLtVar(Int i) const;
     3300  Int                         getDeltaPocMsbCycleLtVar( Int i ) const;
     3301
     3302#else
    30223303  Void                        setPocMsbValPresentFlag( Bool flag )                   { m_pocMsbValPresentFlag = flag;                                }
    30233304  Bool                        getPocMsbValPresentFlag(  )          const             { return m_pocMsbValPresentFlag;                                }
     
    30253306  Void                        setPocMsbVal( Int  val )                               { m_pocMsbVal = val;                                            }
    30263307  Int                         getPocMsbVal(  )         const                         { return m_pocMsbVal;                                           }
     3308#endif
     3309
    30273310
    30283311  Bool                        getCraOrBlaPicFlag()       const                       { return ( getCraPicFlag() || getBlaPicFlag() );                }
    30293312  Bool                        getPocMsbValRequiredFlag() const                       { return ( getCraOrBlaPicFlag() && ( getVPS()->getVpsPocLsbAlignedFlag() || getVPS()->getNumDirectRefLayers( getLayerIdInVps() ) == 0 ) );  }
    30303313
    3031   UInt                        getPocLsbValLen() const                                { return getSPS()->getBitsForPOC();                             }; //log2_max_pic_order_cnt_lsb_minus4 + 4
     3314  UInt                        getPocLsbValLen() const                                { return getSPS()->getBitsForPOC();                             }; //log2_max_pic_order_cnt_lsb_minus4 + 4 
    30323315
    30333316  Bool getBlaPicFlag() const
     
    30693352  Void                        deriveInCmpPredAndCpAvailFlag( );
    30703353  Void                        init3dToolParameters();
    3071   Void                        checkInCompPredRefLayers();;
     3354  Void                        checkInCompPredRefLayers();
    30723355
    30733356  Bool                        getIvMvPredFlag           ( )                          { return m_ivMvPredFlag           ;                             };
     
    30953378#endif
    30963379#endif
     3380#if NH_MV
     3381 TComPic*                     getRefPicSetInterLayer( Int setIdc, Int i ) const;
     3382#endif
     3383
    30973384  // Inference
     3385#if NH_MV
     3386  Bool                        inferPocMsbCycleValPresentFlag();
     3387#else
    30983388  Bool                        inferPocMsbValPresentFlag();
     3389#endif
    30993390#endif
    31003391protected:
  • branches/HTM-15.0-dev0/source/Lib/TLibCommon/TypeDef.h

    r1313 r1317  
    6161#define NH_3D          ( HEVC_EXT == 2)
    6262/////////////////////////////////////////////////////////////////////////////////////////
     63///////////////////////////////////   FIXES           /////////////////////////////////// 
     64/////////////////////////////////////////////////////////////////////////////////////////
     65#if NH_MV
     66#define NH_MV_FIX_NO_REF_PICS_CHECK               1 // !!SPEC!!
     67#define NH_MV_FIX_INIT_NUM_ACTIVE_REF_LAYER_PICS  1 // Derivation of NumActiveRefLayerPIcs. !!SPEC!!
     68#define NH_MV_FIX_NUM_POC_TOTAL_CUR               1 // Derivation of NumPocTotalCur for IDR pictures. !!SPEC!!
     69#endif
     70#if NH_3D
     71#define H_3D_FIX_ARP_CHECK_NOT_IN_DPB     1
     72#endif
     73/////////////////////////////////////////////////////////////////////////////////////////
    6374///////////////////////////////////   MAJOR DEFINES   /////////////////////////////////// 
    6475/////////////////////////////////////////////////////////////////////////////////////////
    6576#if NH_MV
    66 #define NH_MV_FIX_TICKET_105              1 // layer_set_idx_for_ols_minus1 length
    67 #define NH_MV_FIX_TICKET_100              1 // Extra slice header bits
    6877#define H_MV_ENC_DEC_TRAC                 1  //< CU/PU level tracking
    69 #define H_MV_ENC_DEC_TRAC_FIX             1  // by SHARP
    7078#if NH_3D
    71 // FIXES
    72 #define NH_3D_FIX_TICKET_98               1 // Writing of depth intra skip flag
    73 #define NH_3D_FIX_TICKET_101              ( 1 && NH_3D_VER141_DEC_COMP_FLAG )  // Camera parameters for depth
    74 #define NH_3D_DIS_FIX                     1
    75 #define NH_3D_ENC_DEPTH_FIX               1 // Fix Intra TU coding.
    76 #define NH_3D_INTRA_SDC_RD_FIX            1 // Fix in RD- decision of intra SDC.
    77 #define NH_3D_DLT_FIX                     1 // Fixes numbers of parsed DLTs
    78 #define NH_3D_VER141_DEC_COMP_FLAG        0 // Makes decoding of this version compatible to HTM-14.1 by re-introducing HTM-14.1 bugs.
    79 #define NH_3D_ALIGN_SPIVMP_DBBP           1 // Further alignment of DBBP and SBP motion
    80 #define NH_3D_ALIGN_SPIVMP_RP             1 // Alignment of DBBP and RP
    81 #define NH_3D_FIX_VSP                     1
    82 #define NH_3D_VSO                         1
    83 #define NH_3D_NBDV                        1
    84 #define NH_3D_TMVP                        1   // QC_TMVP_C0047
    85                                               // Sony_M23639
    86                                               // H_3D_TMVP_SCALING_FIX_K0053       1   // QC/CY for K0053
    87 #define NH_3D_IC                          1   // Illumination Compensation, JCT3V-B0045, JCT3V-C0046, JCT3V-D0060
    88                                               // Unifying rounding offset, for IC part, JCT3V-D0135
    89                                               // SHARP_ILLUCOMP_REFINE_E0046
    90                                               // MTK_CLIPPING_ALIGN_IC_E0168       // To support simplify bi-prediction PU with identical motion checking, JCT3V-E0168
    91                                               // LGE_IC_CTX_F0160 //JCT3V-F0160
    92                                               // SEC_ONLY_TEXTURE_IC_F0151
    93                                               // MTK_IC_FLAG_CABAC_SIMP_G0061
    94                                               // SEC_IC_ARP_SIG_G0072, Disabling IC when ARP is enabled, option 1 in JCT3V-G0072, part 2 in JCT3V-G0121
    95                                               // MTK_LOW_LATENCY_IC_ENCODING_H0086  Low-latency IC encoding in JCT3V-H0086
    96                                               // MTK_LOW_LATENCY_IC_ENCODING_H0086_FIX  1  // Remove the global variables used in JCT3V-H0086
    97                                               // SEC_IC_NEIGHBOR_CLIP_I0080    // Clipping of neighboring sample position, JCT3V-I0080
    98                                               // LGE_CHROMA_IC_J0050_J0034
    99 #define NH_3D_IC_FIX                      1   // Fix uninitialized value in cDtParam.bUseIC (it happened on intra block)
    100 #define NH_3D_FULL_PEL_DEPTH_MAP_MV_ACC   1   // Full Pel Interpolation for Depth, HHI_FULL_PEL_DEPTH_MAP_MV_ACC
    101 #define NH_3D_QTLPC                       1   // OL_QTLIMIT_PREDCODING_B0068 //JCT3V-B0068
    102                                               // HHI_QTLPC_RAU_OFF_C0160 JCT3V-C0160 change 2: quadtree limitation and predictive coding switched off in random access units
    103                                               // MTK_TEX_DEP_PAR_G0055 Texture-partition-dependent depth partition. JCT3V-G0055
    104 #define NH_3D_NBDV_REF                    1
    105 #define NH_3D_MLC                         1
    106 #define NH_3D_FIX_PRUNING                 1
    107 #define NH_3D_VSP                         1
    108 #define NH_3D_IV_MERGE                    1
    109 #define NH_3D_SPIVMP                      1
    11079#define NH_3D_INTEGER_MV_DEPTH            1
    111 #define NH_3D_TEXT_MERGE                  1
    112 #define NH_3D_DBBP                         1
    113 #define BUF_FIX 1
    114 #define NH_3D_ARP                         1  // Advanced residual prediction (ARP), JCT3V-D0177
    115                                               // QC_MTK_INTERVIEW_ARP_F0123_F0108 JCT3V-F0123; JCT3V-F0108
    116                                               // SHARP_ARP_REF_CHECK_F0105        ARP reference picture selection and DPB check
    117                                               // LGE_ARP_CTX_F0161                JCT3V-F0161
    118                                               // MTK_ARP_FLAG_CABAC_SIMP_G0061 Use 2 context for ARP flag referring to only left neighbor block in JCT3V-G0061
    119                                               // MTK_ARP_REF_SELECTION_G0053 ARP Reference picture selection in JCT3V-G0053
    120                                               // MTK_ALIGN_SW_WD_BI_PRED_ARP_H0085  Align the SW and WD for the bi-prediction ARP PUs by disallowing non-normative fast bi-prediction for ARP PUs, JCT3V-H0085
    121                                               // QC_I0051_ARP_SIMP         
    122                                               // SHARP_ARP_CHROMA_I0104     
    123                                               // MTK_I0072_IVARP_SCALING_FIX
    124                                               // SEC_ARP_VIEW_REF_CHECK_J0037    Signaling iv_res_pred_weight_idx when the current slice has both view and temporal reference picture(s), JCT3V-J0037 item1
    125                                               // SEC_ARP_REM_ENC_RESTRICT_K0035    Removal of encoder restriction of ARP, JCT3V-K0035
    126 #define NH_3D_DMM                         1   // Depth modeling modes
    127 #define NH_3D_DLT                         1   // Depth Lookup Table
    128 #define NH_3D_SDC_INTRA                   1   // Segment-wise DC Coding method for INTRA
    129 #define NH_3D_SDC_INTER                   1   // Segment-wise DC Coding method for INTER 
    13080#define NH_3D_ENC_DEPTH                   1   // Encoder optimizations for depth, incl.
    13181                                              // HHI_DEPTH_INTRA_SEARCH_RAU_C0160
     
    13383                                              // HHI_DMM4_ENC_I0066
    13484                                              // H_3D_FAST_DEPTH_INTRA
    135 #define NH_3D_DIS                         1
    13685#define NH_3D_FAST_TEXTURE_ENCODING       1   // Fast merge mode decision and early CU determination for texture component of dependent view, JCT3V-E0173
    137 #endif
    138 #if H_3D
    139 #define H_3D_QTLPC                        1   // OL_QTLIMIT_PREDCODING_B0068 //JCT3V-B0068
     86#define NH_3D_ARP                         1  // Advanced residual prediction (ARP), JCT3V-D0177
     87                                             // QC_MTK_INTERVIEW_ARP_F0123_F0108 JCT3V-F0123; JCT3V-F0108
     88                                             // SHARP_ARP_REF_CHECK_F0105        ARP reference picture selection and DPB check
     89                                             // LGE_ARP_CTX_F0161                JCT3V-F0161
     90                                             // MTK_ARP_FLAG_CABAC_SIMP_G0061 Use 2 context for ARP flag referring to only left neighbor block in JCT3V-G0061
     91                                             // MTK_ARP_REF_SELECTION_G0053 ARP Reference picture selection in JCT3V-G0053
     92                                             // MTK_ALIGN_SW_WD_BI_PRED_ARP_H0085  Align the SW and WD for the bi-prediction ARP PUs by disallowing non-normative fast bi-prediction for ARP PUs, JCT3V-H0085
     93                                             // QC_I0051_ARP_SIMP         
     94                                             // SHARP_ARP_CHROMA_I0104     
     95                                             // MTK_I0072_IVARP_SCALING_FIX
     96                                             // SEC_ARP_VIEW_REF_CHECK_J0037    Signaling iv_res_pred_weight_idx when the current slice has both view and temporal reference picture(s), JCT3V-J0037 item1
     97                                             // SEC_ARP_REM_ENC_RESTRICT_K0035    Removal of encoder restriction of ARP, JCT3V-K0035
     98#define NH_3D_QTLPC                        1   // OL_QTLIMIT_PREDCODING_B0068 //JCT3V-B0068
    14099                                              // HHI_QTLPC_RAU_OFF_C0160 JCT3V-C0160 change 2: quadtree limitation and predictive coding switched off in random access units
    141100                                              // MTK_TEX_DEP_PAR_G0055 Texture-partition-dependent depth partition. JCT3V-G0055
    142 #define H_3D_VSO                          1   // VSO, View synthesis optimization, includes:
     101#define NH_3D_VSO                          1   // VSO, View synthesis optimization, includes:
    143102                                              // HHI_VSO
    144103                                              // HHI_VSO_LS_TABLE_M23714 enable table base Lagrange multiplier optimization
     
    146105                                              // LGE_WVSO_A0119
    147106                                              // SCU_HS_VSD_BUGFIX_IMPROV_G0163
    148 #define H_3D_NBDV                         1   // Neighboring block disparity derivation
     107#define NH_3D_NBDV                         1   // Neighboring block disparity derivation
    149108                                              // QC_JCT3V-A0097
    150109                                              // LGE_DVMCP_A0126
     
    162121                                              // MTK_TEXTURE_MRGCAND_BUGFIX_E0182  Bug fix for TEXTURE MERGING CANDIDATE     , JCT3V-E0182
    163122                                              // LGE_SIMP_DISP_AVAIL_J0041    // Use 2 status for disparity availability - DISP_AVAILABLE and DISP_NONE
    164 #define H_3D_IC                           1   // Illumination Compensation, JCT3V-B0045, JCT3V-C0046, JCT3V-D0060
     123#define NH_3D_IC                          1   // Illumination Compensation, JCT3V-B0045, JCT3V-C0046, JCT3V-D0060
    165124                                              // Unifying rounding offset, for IC part, JCT3V-D0135
    166125                                              // Full Pel Interpolation for Depth, HHI_FULL_PEL_DEPTH_MAP_MV_ACC
     
    176135                                              // LGE_CHROMA_IC_J0050_J0034
    177136#if NH_3D_NBDV
    178 #define H_3D_NBDV_REF                     1   // Depth oriented neighboring block disparity derivation
     137#define NH_3D_NBDV_REF                     1   // Depth oriented neighboring block disparity derivation
    179138                                              // MTK_D0156
    180139                                              // MERL_D0166: Reference view selection in NBDV & Bi-VSP
     
    184143                                              // SEC_VER_DONBDV_H0103          Vertical DV Restriction for DoNBDV
    185144#endif
    186 #define H_3D_VSP                          1   // View synthesis prediction
     145#define NH_3D_VSP                          1   // View synthesis prediction
    187146                                              // MERL_C0152: Basic VSP
    188147                                              // MERL_D0166: Reference view selection in NBDV & Bi-VSP
     
    202161                                              // MTK_MRG_LIST_SIZE_CLEANUP_J0059   1   // Include VSP for deriving merge candidate list size, JCT3V-J0059
    203162                                              // SEC_A1_BASED_VSP_J0039            1   // Removal of redundant VSP in Merge list
    204 #define H_3D_IV_MERGE                     1   // Inter-view motion merge candidate
     163#define NH_3D_MLC                          1
     164#define NH_3D_IV_MERGE                     1  // Inter-view motion merge candidate
    205165                                              // HHI_INTER_VIEW_MOTION_PRED
    206166                                              // SAIT_IMPROV_MOTION_PRED_M24829, improved inter-view motion vector prediction
     
    209169                                              // MTK_INTERVIEW_MERGE_A0049     , second part
    210170                                              // QC_AMVP_MRG_UNIFY_IVCAN_C0051     
    211                                               // TEXTURE MERGING CANDIDATE     , JCT3V-C0137
    212171                                              // QC_INRIA_MTK_MRG_E0126
    213172                                              // ETRIKHU_MERGE_REUSE_F0093 QC_DEPTH_IV_MRG_F0125, JCT3V-F0125: Depth oriented Inter-view MV candidate
    214                                               // EC_MPI_ENABLING_MERGE_F0150, MPI flag in VPS and enabling in Merge mode
    215173                                              // MTK_NBDV_IVREF_FIX_G0067      , Disable IvMC, VSP when IVREF is not available, JCT3V-G0067
    216174                                              // SEC_DEPTH_DV_DERIVAITON_G0074, Simplification of DV derivation for depth, JCT3V-G0074
     
    225183                                              // SEC_SIMP_SHIFTED_DV_I0086     Simplification of Shifted DV candidate, JCT3V-I0086
    226184                                              // SEC_SHIFTED_IVMC_POS_K0036    Position Derivation for Shifted-IVMC, JCT3V-K0036
    227 #define H_3D_TMVP                         1   // QC_TMVP_C0047
     185#define NH_3D_TEXT_MERGE                  1
     186                                              // TEXTURE MERGING CANDIDATE     , JCT3V-C0137
     187                                              // EC_MPI_ENABLING_MERGE_F0150, MPI flag in VPS and enabling in Merge mode
     188#define NH_3D_TMVP                        1   // QC_TMVP_C0047
    228189                                              // Sony_M23639
    229190                                              // H_3D_TMVP_SCALING_FIX_K0053       1   // QC/CY for K0053
    230 #define H_3D_DIM                          1   // DIM, Depth intra modes, includes:
     191#define NH_3D_DMM                         1   // Depth modeling modes
     192                                              // HHI_DMM_PRED_TEX
    231193                                              // HHI_DMM_WEDGE_INTRA
    232                                               // HHI_DMM_PRED_TEX
    233194                                              // FIX_WEDGE_NOFLOAT_D0036
    234195                                              // LGE_EDGE_INTRA_A0070
    235196                                              // LGE_DMM3_SIMP_C0044
    236197                                              // QC_DC_PREDICTOR_D0183
     198                                              // LGE_CONCATENATE_D0141
     199                                              // PKU_QC_DEPTH_INTRA_UNI_D0195
     200                                              // SEC_DMM2_E0146_HHIFIX Removal of DMM2 from DMMs
     201                                              // ZJU_DEPTH_INTRA_MODE_E0204 Simplified Binarization for depth_intra_mode
     202                                              // SCU_HS_DMM4_REMOVE_DIV_E0242 DMM4 Division Removal
     203                                              // LGE_PKU_DMM3_OVERLAP_E0159_HHIFIX 1   Removal of overlap between DMM3 and DMM1
     204                                              // SEC_DMM3_RBC_F0147 Removal of DMM3 and RBC from DMMs
     205                                              // HHI_DIM_PREDSAMP_FIX_F0171
     206                                              // QC_DIM_DELTADC_UNIFY_F0132 Unify delta DC coding in depth intra modes
     207                                              // LGE_SIMP_DIM_NOT_PRESENT_FLAG_CODING_H0119_H0135  Use only one context for CABAC of dim_not_present_flag
     208                                              // QC_SIMP_DELTADC_CODING_H0131   Simplify detaDC entropy coding
     209                                              // MTK_DMM_SIMP_CODE_H0092        Remove CABAC context for DMM1 mode coding
     210                                              // MTK_DELTA_DC_FLAG_ONE_CONTEXT_H0084_H0100_H0113 Use only one context for CABAC of delta_dc_flag as in JCTVC-H0084, JCTVC-H0100 and JCTVC-H0113
     211                                              // HS_DMM_SIGNALLING_I0120
     212                                              // SHARP_DMM1_I0110 LUT size reduction for DMM1 proposed in JCT3V-I0110
     213                                              // MTK_DMM_SIM_J0035
     214                                              // SHARP_DMM_CLEAN_K0042             1   // Generate DMM pattern with rotation
     215#define NH_3D_DLT                         1   // Depth Lookup Table
    237216                                              // HHI_DELTADC_DLT_D0035
    238                                               // PKU_QC_DEPTH_INTRA_UNI_D0195
     217                                              // LGE_PRED_RES_CODING_DLT_DOMAIN_F0159 JCT3V-F0159
     218                                              // SEC_NO_RESI_DLT_H0105   
     219                                              // MTK_DLT_CODING_FIX_H0091
     220                                              // H_3D_DELTA_DLT
     221                                              // RWTH_DLT_CLIP_I0057
     222                                              // SHARP_DLT_SIMP_J0029 DLT(DepthValue2Idx[]) table derivation cleanup 
     223#define NH_3D_SDC_INTRA                   1   // Segment-wise DC Coding method for INTRA
     224#define NH_3D_SDC_INTER                   1   // Segment-wise DC Coding method for INTER 
    239225                                              // RWTH_SDC_DLT_B0036
    240226                                              // INTEL_SDC64_D0193
    241227                                              // RWTH_SDC_CTX_SIMPL_D0032
    242                                               // LGE_CONCATENATE_D0141
    243228                                              // FIX_SDC_ENC_RD_WVSO_D0163
    244229                                              // MTK_SAMPLE_BASED_SDC_D0110
    245                                               // SEC_DMM2_E0146_HHIFIX Removal of DMM2 from DMMs
    246                                               // ZJU_DEPTH_INTRA_MODE_E0204 Simplified Binarization for depth_intra_mode
    247230                                              // KWU_SDC_SIMPLE_DC_E0117 Simplified DC calculation for SDC
    248                                               // SCU_HS_DMM4_REMOVE_DIV_E0242 DMM4 Division Removal
    249231                                              // LGE_SDC_REMOVE_DC_E0158 Removal of DC mode from SDC
    250                                               // LGE_PKU_DMM3_OVERLAP_E0159_HHIFIX 1   Removal of overlap between DMM3 and DMM1
    251                                               // LGE_PRED_RES_CODING_DLT_DOMAIN_F0159 JCT3V-F0159
    252                                               // HHI_DIM_PREDSAMP_FIX_F0171
    253                                               // SEC_DMM3_RBC_F0147 Removal of DMM3 and RBC from DMMs
    254                                               // QC_DIM_DELTADC_UNIFY_F0132 Unify delta DC coding in depth intra modes
    255232                                              // Unify intra SDC and inter SDC
    256233                                              // QC_GENERIC_SDC_G0122 Generalize SDC to all depth intra modes
     
    259236                                              // QC_PKU_SDC_SPLIT_G0123 Intra SDC Split
    260237                                              // HS_DMM_SDC_PREDICTOR_UNIFY_H0108  Unification of DMM and SDC predictor derivation
    261                                               // LGE_SIMP_DIM_NOT_PRESENT_FLAG_CODING_H0119_H0135  Use only one context for CABAC of dim_not_present_flag
    262                                               // QC_SIMP_DELTADC_CODING_H0131   Simplify detaDC entropy coding
    263                                               // MTK_DMM_SIMP_CODE_H0092        Remove CABAC context for DMM1 mode coding
    264                                               // MTK_DELTA_DC_FLAG_ONE_CONTEXT_H0084_H0100_H0113 Use only one context for CABAC of delta_dc_flag as in JCTVC-H0084, JCTVC-H0100 and JCTVC-H0113
    265238                                              // MTK_SDC_FLAG_FIX_H0095                          Remove conditional check of PCM flag based on SDC flag, JCTVC-H0095
    266                                               // SEC_NO_RESI_DLT_H0105   
    267                                               // MTK_DLT_CODING_FIX_H0091
    268                                               // HS_DMM_SIGNALLING_I0120
    269                                               // SHARP_DMM1_I0110 LUT size reduction for DMM1 proposed in JCT3V-I0110
    270239                                              // FAST_SDC_OFFSET_DECISION_I0084
    271240                                              // SEPARATE_FLAG_I0085
    272                                               // H_3D_DELTA_DLT
    273                                               // RWTH_DLT_CLIP_I0057
    274                                               // MTK_DMM_SIM_J0035
    275241                                              // MTK_J0033
    276                                               // SHARP_DLT_SIMP_J0029 DLT(DepthValue2Idx[]) table derivation cleanup
    277                                               // SHARP_DMM_CLEAN_K0042             1   // Generate DMM pattern with rotation
    278 #define H_3D_INTER_SDC                    1   // INTER SDC, Inter simplified depth coding
    279242                                              // LGE_INTER_SDC_E0156 Enable inter SDC for depth coding
    280243                                              // SEC_INTER_SDC_G0101 Improved inter SDC with multiple DC candidates
    281 #define H_3D_INTER_SDC_FIX                1
    282 #define H_3D_SPIVMP                       1   // H_3D_SPIVMP JCT3V-F0110: Sub-PU level inter-view motion prediction
     244#define NH_3D_SPIVMP                       1   // H_3D_SPIVMP JCT3V-F0110: Sub-PU level inter-view motion prediction
    283245                                              // SEC_SPIVMP_MCP_SIZE_G0077, Apply SPIVMP only to 2Nx2N partition, JCT3V-G0077
    284246                                              // QC_SPIVMP_MPI_G0119 Sub-PU level MPI merge candidate
    285247                                              // Simplification on Sub-PU level temporal interview motion prediction
    286248                                              // MPI_SUBPU_DEFAULT_MV_H0077_H0099_H0111_H0133
    287 #define H_3D_DBBP                         1   // DBBP: Depth-based Block Partitioning and Merging
     249#define NH_3D_DBBP                         1   // DBBP: Depth-based Block Partitioning and Merging
    288250                                              // MTK_DBBP_AMP_REM_H0072   
    289251                                              // RWTH_DBBP_NO_SPU_H0057   
     
    298260                                              // RWTH_DBBP_NO_SATD_K0028
    299261                                              // HS_DBBP_CLEAN_K0048
    300 #define H_3D_DDD                          1   // Disparity derived depth coding
    301                                               // LGE_DDD_REMOVAL_J0042_J0030 DDD removal
    302 #define H_3D_DIS                          1   // Depth intra skip
     262#define NH_3D_DIS                         1   // Depth intra skip
    303263                                              // SEC_DEPTH_INTRA_SKIP_MODE_K0033  Depth intra skip mode
    304264#define H_3D_FCO                          0   // Flexible coding order for 3D
    305 #define H_3D_FAST_INTRA_SDC               1   // I0123
    306265// OTHERS
    307266                                              // MTK_SONY_PROGRESSIVE_MV_COMPRESSION_E0170 // Progressive MV Compression, JCT3V-E0170
    308 #define H_3D_FAST_TEXTURE_ENCODING        1   // Fast merge mode decision and early CU determination for texture component of dependent view, JCT3V-E0173
    309267                                              // MTK_FAST_TEXTURE_ENCODING_E0173
    310 #if H_3D_DIM
    311 #define H_3D_FAST_DEPTH_INTRA             1   // Fast DMM Selection
    312                                               // SCU_HS_FAST_DEPTH_INTRA_E0238_HHIFIX
    313 #endif
    314268//HLS
    315269                                             // HHI_DEPENDENCY_SIGNALLING_I1_J0107
     
    321275                                             // H_3D_DIRECT_DEP_TYPE     
    322276// Rate Control
    323 #define KWU_FIX_URQ                       1
     277#define KWU_FIX_URQ                       0
    324278#define KWU_RC_VIEWRC_E0227               0  ///< JCT3V-E0227, view-wise target bitrate allocation
    325279#define KWU_RC_MADPRED_E0227              0  ///< JCT3V-E0227, inter-view MAD prediction
    326 #endif // H_3D
     280#endif // NH_3D
    327281/////////////////////////////////////////////////////////////////////////////////////////
    328282///////////////////////////////////   DERIVED DEFINES /////////////////////////////////// 
     
    349303#if NH_3D_ARP
    350304#define H_3D_ARP_WFNR                     3
    351 #endif
    352 ///// ***** DEPTH INTRA MODES *********
    353 #if H_3D_DIM
    354                                               // HHI_DMM4_ENC_I0066
    355 #define H_3D_DIM_DMM                      1   // Depth Modeling Modes
    356 #define H_3D_DIM_SDC                      1   // Simplified Depth Coding method
    357 #define H_3D_DIM_DLT                      1   // Depth Lookup Table
    358 #define H_3D_DIM_ENC                      1   // Depth Intra encoder optimizations, includes:
    359                                               // HHI_DEPTH_INTRA_SEARCH_RAU_C0160
    360                                               // LG_ZEROINTRADEPTHRESI_A0087
    361305#endif
    362306/////////////////////////////////////////////////////////////////////////////////////
     
    389333// TBD: Check if integration is necessary.
    390334#define H_MV_HLS_PTL_LIMITS                  0
    391 #define H_MV_HLS7_GEN                        0  // General changes (not tested)
    392 // POC
    393 // #define H_MV_HLS_7_POC_P0041_3            0 // (POC/P0041/POC reset) #3 It was remarked that we should require each non-IRAP picture that has discardable_flag equal to 1 to have NUT value indicating that it is a sub-layer non-reference picture. This was agreed. Decision: Adopt (with constraint for discardable_flag as described above)
    394 // #define H_MV_HLS_7_POC_P0041_FIXES        0 // (POC/P0041/Fixes) For each non-IRAP picture that has discardable_flag equal to 1 to have NUT value indicating that it is a sub-layer non-reference picture.
    395 // #define H_MV_HLS_7_POC_P0056_4            0 // (POC/P0056/layer tree poc) #4 Proposal 1: If the POC reset approach is adopted as the basis for multi-layer POC derivation, it is proposed to derive the POC anchor picture from the previous TID0 picture (that is not a RASL picture, a RADL picture or a sub-layer non-reference picture and not with discardable_flag equal to 1) of  the current layer or any of its reference layer. This is asserted to improve loss resilience and reduce bit rate overhead. Decision: Adopt Proposal 1 (with the suggested modifications Ewith text provided as P0297).
    396 // SEI related
    397 //#define H_MV_HLS_8_SEI_NODOC_53  0 // #53 (SEI    /NODOC/Added Multiview view position SEI message) Plain copy from AVC.
    398 //#define H_MV_HLS_8_SEI_NODOC_52  0 // #52 (SEI    /NODOC/Added Multiview acquisition information SEI) Plain copy from AVC.
    399 //#define H_MV_HLS_8_SEI_NODOC_51  0 // #51 (SEI    /NODOC/Added Multiview scene information SEI message)
    400 //#define H_MV_HLS_8_SEI_Q0189_35  0 // #35 (SEI    /Q0189/SEI message for indicating constraints on TMVP) Proposal 2.3,  SEI message for indicating constraints on TMVP
    401 //#define H_MV_HLS_8_EDF_Q0116_29  0 // #29 (ED.FIX /Q0116/Recovery point SEI) , consider adding a note regarding how random accessibility is affected by the recovery point SEI message
    402 //#define H_MV_HLS_8_GEN_Q0183_23  0 // #23 (GEN    /Q0183/SEI clean-ups) numerous small clean-ups on SEI messages.
    403 //#define H_MV_HLS_8_MIS_Q0247_49  0 // #49 (MISC   /Q0247/frame-field information SEI message)
    404 //#define H_MV_HLS_8_MIS_Q0189_34  0 // #34 (MISC   /Q0189/slice temporal mvp enabled flag) Proposal 2.2, clarification of semantics of slice temporal mvp enabled flag
    405 //#define H_MV_HLS_8_EDF_Q0081_01  0 // #1  (ED.FIX /Q0081/alpha channel persist) On reuse of alpha planes in auxiliary pictures. It was asked why there would not be a presumption that the alpha channel content would simply persist, without needing the flag to indicate it. Decision (Ed.): Delegated to editors to clarify, as necessary, that the alpha channel content persists until cancelled or updated in output order.
    406 //#define H_MV_HLS_8_SEI_Q0253_37  0 // #37 (SEI    /Q0253/layer not present), modified semantics of layers not present SEI message to correct bug introduced during editing
    407 //#define H_MV_HLS_8_SEI_Q0045_11  0 // #11 (SEI    /Q0045/Overlay) Proposal for an SEI message on selectable overlays. Decision: Adopt (modified for variable-length strings).
    408 //#define H_MV_HLS_7_SEI_P0133_28  0 // (SEI/P0133/Recovery point SEI) #28 Decision: Adopt change to recover point semantics only (-v3)
    409 //#define H_MV_HLS_7_SEI_P0123_25  0 // (SEI/P0123/Alpha channel info) #25 Add alpha channel information SEI message Decision: Adopt. Constrain the bit depth indicated to be equal to the coded bit depth of the aux picture.
    410 // DPB
    411 //#define H_MV_HLS_8_HRD_Q0102_09  0 // #9  (HRD    /Q0102/NoOutputOfPriorPicsFlag) It was suggested that also the separate_colour_plane_flag should affect inference of NoOutputOfPriorPicsFlag. Decision (Ed.): Agreed (affects RExt text).
    412 //#define H_MV_HLS_8_DBP_Q0154_38  0 // #38 (DBP    /Q0154/VPS DPB) Proposal in C.5.2.1: Add in the decoding process that when a new VPS is activated, all pictures in the DPB are marked as unused for reference
    413 //#define H_MV_HLS_8_HRD_Q0154_10  0 // #10 (HRD    /Q0154/DPB Flushing and parameters) On picture flushing and DPB parameters Decision: Adopted (some details to be discussed further in BoG).
    414 //#define H_MV_HLS_7_OTHER_P0187_1 0 // (OTHER/P0187/NoOutputOfPriorPicsFlag) #1 Inference of NoOutputOfPriorPicsFlag and proposes to take into account colour format and bit depth for the inference in addition to spatial resolution
    415 // OTHERS
    416 //#define H_MV_HLS_8_HSB_Q0041_03  0 // #3  (HS     /Q0041/hybrid scalability) The proposed text was endorsed, with non-editorial open issues considered as follows ?// #define H_MV_HLS_7_OTHER_P0187_1          0 // (OTHER/P0187/NoOutputOfPriorPicsFlag) #1 Inference of NoOutputOfPriorPicsFlag and proposes to take into account colour format and bit depth for the inference in addition to spatial resolution
    417 //#define H_MV_HLS_8_MIS_Q0078_24  0 // #24 (MISC   /Q0078/scan and pic type) , Items 3 b,c and 4, clarifying which pictures in an output layer sets are applied the values of general_progressive_source_flag, general_interlaced_source_flag, general_non_packed_constraint_flag and general_frame_only_constraint_flag.
    418 //#define H_MV_HLS_7_HRD_P0138_6   0 //     (HRD/P0138/HRD parameters for bitstreams excluding) #6 Decision: Adopt (as revised in updated contribution, with the specification of a flag in the BP SEI (HRD/P0192/sub-DPB) #12 Establish sub-DPBs based on the representation format indicated at the VPS level. It was suggested that the expressed shared capacity limit would need to be less than or equal to the sum of the individual capacity limits. Decision: Adopt as modified. Further study is encouraged on profile/level constraint selections.
    419335/////////////////////////////////////////////////////////////////////////////////////////
    420336///////////////////////////////////   HM RELATED DEFINES ////////////////////////////////
     
    871787#define NUM_SAO_BO_CLASSES_LOG2  5
    872788#define NUM_SAO_BO_CLASSES       (1<<NUM_SAO_BO_CLASSES_LOG2)
     789#if NH_MV
     790enum DecodingProcess
     791{
     792  INVALID,
     793  CLAUSE_8,
     794  ANNEX_C,
     795  ANNEX_F,
     796  ANNEX_G,
     797  ANNEX_H,
     798  ANNEX_I 
     799};
     800#endif
    873801namespace Profile
    874802{
     
    1017945  AUX_ID = 3,
    1018946};
     947enum DecProcPart
     948{
     949  START_PIC,
     950  FINALIZE_PIC
     951};
    1019952#endif
    1020953#if NH_3D
  • branches/HTM-15.0-dev0/source/Lib/TLibDecoder/TDecCAVLC.cpp

    r1313 r1317  
    6666  fprintf( g_hTrace, "=========== Picture Parameter Set  ===========\n");
    6767}
     68
     69Void  xTraceSliceHeader ()
     70{
     71  fprintf( g_hTrace, "=========== Slice ===========\n");
     72}
     73
    6874#endif
    6975#endif
     
    8591// ====================================================================================================================
    8692
     93#if NH_MV
     94Void TDecCavlc::parseShortTermRefPicSet( TComSPS* sps, TComStRefPicSet* stRps, Int stRpsIdx )
     95{
     96  UInt uiCode; 
     97  if( stRpsIdx  !=  0 )
     98  {
     99    READ_FLAG( uiCode, "inter_ref_pic_set_prediction_flag" ); stRps->setInterRefPicSetPredictionFlag( uiCode == 1 );
     100  }
     101  if( stRps->getInterRefPicSetPredictionFlag() )
     102  {
     103    if( stRpsIdx  ==  sps->getNumShortTermRefPicSets() )
     104    {
     105      READ_UVLC( uiCode, "delta_idx_minus1" ); stRps->setDeltaIdxMinus1( uiCode );
     106    }
     107    READ_FLAG( uiCode, "delta_rps_sign" ); stRps->setDeltaRpsSign( uiCode == 1 );
     108    READ_UVLC( uiCode, "abs_delta_rps_minus1" ); stRps->setAbsDeltaRpsMinus1( uiCode );
     109    for( Int j = 0; j  <=  sps->getStRefPicSet( stRps->getRefRpsIdx( stRpsIdx ) )->getNumDeltaPocs() ; j++ )
     110    {
     111      READ_FLAG( uiCode, "used_by_curr_pic_flag" ); stRps->setUsedByCurrPicFlag( j, uiCode == 1 );
     112      if( !stRps->getUsedByCurrPicFlag( j ) )
     113      {
     114        READ_FLAG( uiCode, "use_delta_flag" ); stRps->setUseDeltaFlag( j, uiCode == 1 );
     115      }
     116    }
     117  }
     118  else
     119  {
     120    READ_UVLC( uiCode, "num_negative_pics" ); stRps->setNumNegativePics( uiCode );
     121    READ_UVLC( uiCode, "num_positive_pics" ); stRps->setNumPositivePics( uiCode );
     122    for( Int i = 0; i < stRps->getNumNegativePics( ); i++ )
     123    {
     124      READ_UVLC( uiCode, "delta_poc_s0_minus1" ); stRps->setDeltaPocS0Minus1( i, uiCode );
     125      READ_FLAG( uiCode, "used_by_curr_pic_s0_flag" ); stRps->setUsedByCurrPicS0Flag( i, uiCode == 1 );
     126    }
     127    for( Int i = 0; i < stRps->getNumPositivePics( ); i++ )
     128    {
     129      READ_UVLC( uiCode, "delta_poc_s1_minus1" ); stRps->setDeltaPocS1Minus1( i, uiCode );
     130      READ_FLAG( uiCode, "used_by_curr_pic_s1_flag" ); stRps->setUsedByCurrPicS1Flag( i, uiCode == 1 );
     131    }
     132  }
     133  stRps->inferRps( stRpsIdx, sps, false );
     134}
     135#else
    87136Void TDecCavlc::parseShortTermRefPicSet( TComSPS* sps, TComReferencePictureSet* rps, Int idx )
    88137{
     
    180229#endif
    181230}
     231#endif
    182232
    183233Void TDecCavlc::parsePPS(TComPPS* pcPPS)
     
    507557  {
    508558    READ_CODE(6, uiCode, "pps_depth_layers_minus1");
    509 #if NH_3D_VER141_DEC_COMP_FLAG
    510     pcDLT->setNumDepthViews( uiCode );
    511 #else
    512559    pcDLT->setNumDepthViews( uiCode+1 );
    513 #endif
    514560   
    515561    READ_CODE(4, uiCode, "pps_bit_depth_for_depth_layers_minus8");
    516562    pcDLT->setDepthViewBitDepth( (uiCode+8) );
    517563   
    518 #if NH_3D_DLT_FIX
    519564    for( Int i = 0; i <= pcDLT->getNumDepthViews()-1; i++ )
    520 #else
    521     for( Int i = 0; i <= pcDLT->getNumDepthViews(); i++ )
    522 #endif
    523565    {
    524566      Int layerId = pcDLT->getDepthIdxToLayerId(i);
     
    866908#if NH_MV
    867909    pcSPS->getPTL()->inferGeneralValues ( true, 0, NULL );
    868     pcSPS->getPTL()->inferSubLayerValues( pcSPS->getMaxTLayers() - 1, 0, NULL );
     910    pcSPS->getPTL()->inferSubLayerValues( pcSPS->getSpsMaxSubLayersMinus1(), 0, NULL );
    869911  }
    870912#endif
     
    9721014    pcSPS->setNumReorderPics(uiCode, i);
    9731015    READ_UVLC ( uiCode, "sps_max_latency_increase_plus1[i]");
     1016#if NH_MV
     1017    pcSPS->setSpsMaxLatencyIncreasePlus1( uiCode, i );
     1018#else
    9741019    pcSPS->setMaxLatencyIncrease( uiCode, i );
     1020#endif
    9751021
    9761022    if (!subLayerOrderingInfoPresentFlag)
     
    9801026        pcSPS->setMaxDecPicBuffering(pcSPS->getMaxDecPicBuffering(0), i);
    9811027        pcSPS->setNumReorderPics(pcSPS->getNumReorderPics(0), i);
     1028#if NH_MV
     1029        pcSPS->setSpsMaxLatencyIncreasePlus1(pcSPS->getSpsMaxLatencyIncreasePlus1(0), i);
     1030#else
    9821031        pcSPS->setMaxLatencyIncrease(pcSPS->getMaxLatencyIncrease(0), i);
     1032#endif
    9831033      }
    9841034      break;
     
    10531103
    10541104  READ_UVLC( uiCode, "num_short_term_ref_pic_sets" );
     1105
    10551106  assert(uiCode <= 64);
     1107#if NH_MV
     1108  pcSPS->setNumShortTermRefPicSets( uiCode ); 
     1109  pcSPS->initStRefPicSets();
     1110
     1111  for(Int i=0; i< pcSPS->getNumShortTermRefPicSets(); i++ )
     1112  {
     1113    parseShortTermRefPicSet(pcSPS,pcSPS->getStRefPicSet(i),i);
     1114  }
     1115
     1116  READ_FLAG( uiCode, "long_term_ref_pics_present_flag" );          pcSPS->setLongTermRefPicsPresentFlag(uiCode);
     1117  if (pcSPS->getLongTermRefPicsPresentFlag() )
     1118#else
    10561119  pcSPS->createRPSList(uiCode);
    10571120
     
    10641127    parseShortTermRefPicSet(pcSPS,rps,i);
    10651128  }
     1129
    10661130  READ_FLAG( uiCode, "long_term_ref_pics_present_flag" );          pcSPS->setLongTermRefsPresent(uiCode);
    10671131  if (pcSPS->getLongTermRefsPresent())
     1132#endif
    10681133  {
    10691134    READ_UVLC( uiCode, "num_long_term_ref_pics_sps" );
     
    21492214#endif
    21502215
     2216#if NH_MV
     2217Void TDecCavlc::parseFirstSliceSegmentInPicFlag(TComSlice* pcSlice )
     2218{
     2219#if ENC_DEC_TRACE
     2220#if NH_MV
     2221  tracePSHeader( "Slice", pcSlice->getLayerId() );
     2222#else
     2223  xTraceSliceHeader();
     2224#endif
     2225#endif
     2226
     2227  UInt uiCode;
     2228  READ_FLAG( uiCode, "first_slice_segment_in_pic_flag" );
     2229  pcSlice->setFirstSliceSegementInPicFlag( uiCode );
     2230}
     2231
     2232Void TDecCavlc::parseSliceHeader (TComSlice* pcSlice, ParameterSetManager *parameterSetManager )
     2233#else
    21512234Void TDecCavlc::parseSliceHeader (TComSlice* pcSlice, ParameterSetManager *parameterSetManager, const Int prevTid0POC)
     2235#endif
    21522236{
    21532237  UInt  uiCode;
    21542238  Int   iCode;
    21552239
     2240#if !NH_MV
    21562241#if ENC_DEC_TRACE
    2157 #if NH_MV
    2158   tracePSHeader( "Slice", pcSlice->getLayerId() );
    2159 #else
    21602242  xTraceSliceHeader();
    21612243#endif
     
    21672249#endif
    21682250
     2251#if NH_MV
     2252  // This has been parsed before in parseFirstSliceSegmentFlag(TComSlice* pcSlice )
     2253  UInt firstSliceSegmentInPic = pcSlice->getFirstSliceSegementInPicFlag();   
     2254#else
    21692255  UInt firstSliceSegmentInPic;
    21702256  READ_FLAG( firstSliceSegmentInPic, "first_slice_segment_in_pic_flag" );
     2257#endif
    21712258  if( pcSlice->getRapPicFlag())
    21722259  {
     
    21842271  vps = parameterSetManager->getVPS(sps->getVPSId());
    21852272  assert( vps != NULL ); 
     2273 
    21862274  m_decTop->initFromActiveVps( vps );
     2275 
     2276  if ( !m_decTop->getIsInOwnTargetDecLayerIdList() )
     2277  {
     2278    return;
     2279  }
     2280
     2281  pcSlice->setDecodingProcess( m_decTop->getDecodingProcess() );
    21872282  Int targetOlsIdx = m_decTop->getTargetOlsIdx();
    21882283
     
    22412336  pcSlice->setSliceSegmentCurStartCtuTsAddr( sliceSegmentAddress );// this is actually a Raster-Scan (RS) address, but we do not have the RS->TS conversion table defined yet.
    22422337  pcSlice->setSliceSegmentCurEndCtuTsAddr(numCTUs);                // Set end as the last CTU of the picture.
    2243 
    2244 #if NH_MV
    2245     UInt slicePicOrderCntLsb = 0;
    2246 #endif
    22472338
    22482339
     
    23032394
    23042395#if NH_MV
    2305     Int iPOClsb = slicePicOrderCntLsb;  // Needed later
    23062396    if ( (pcSlice->getLayerId() > 0 && !vps->getPocLsbNotPresentFlag( pcSlice->getLayerIdInVps())) || !pcSlice->getIdrPicFlag() )
    23072397    {
    2308       READ_CODE(sps->getBitsForPOC(), slicePicOrderCntLsb, "slice_pic_order_cnt_lsb");       
    2309     }   
    2310     pcSlice->setSlicePicOrderCntLsb( slicePicOrderCntLsb );
    2311 
    2312     Bool picOrderCntMSBZeroFlag = false;     
    2313 
    2314     // as in HM code. However are all cases for IRAP picture with NoRaslOutputFlag equal to 1 covered??
    2315     picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP   );
    2316     picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL );
    2317     picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP   );
    2318     picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag ||   pcSlice->getIdrPicFlag();
    2319 
    2320     // TBD picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || ( rpcSlice->getLayerId() > 0 &&   !rpcSlice->getFirstPicInLayerDecodedFlag() );
    2321 
    2322     Int picOrderCntMSB = 0;
    2323 
    2324     if ( !picOrderCntMSBZeroFlag )
    2325     {
    2326       Int prevPicOrderCnt    = prevTid0POC;
    2327       Int maxPicOrderCntLsb  = 1 << sps->getBitsForPOC();
    2328       Int prevPicOrderCntLsb = prevPicOrderCnt & (maxPicOrderCntLsb - 1);
    2329       Int prevPicOrderCntMsb = prevPicOrderCnt - prevPicOrderCntLsb;
    2330            
    2331       if( ( slicePicOrderCntLsb  <  prevPicOrderCntLsb ) && ( ( prevPicOrderCntLsb - slicePicOrderCntLsb )  >=  ( maxPicOrderCntLsb / 2 ) ) )
    2332       {
    2333         picOrderCntMSB = prevPicOrderCntMsb + maxPicOrderCntLsb;
    2334       }
    2335       else if( (slicePicOrderCntLsb  >  prevPicOrderCntLsb )  && ( (slicePicOrderCntLsb - prevPicOrderCntLsb )  >  ( maxPicOrderCntLsb / 2 ) ) )
    2336       {
    2337         picOrderCntMSB = prevPicOrderCntMsb - maxPicOrderCntLsb;
    2338       }
    2339       else
    2340       {
    2341         picOrderCntMSB = prevPicOrderCntMsb;
    2342       }   
    2343     }
    2344      
    2345     pcSlice->setPOC( picOrderCntMSB + slicePicOrderCntLsb );
    2346     if ( pcSlice->getPocResetFlag() ) 
    2347     {
    2348       pcSlice->setPocBeforeReset   ( pcSlice->getPOC() );
    2349       pcSlice->setPOC              ( 0 );
    2350     }     
    2351 #endif
    2352 
    2353     if( pcSlice->getIdrPicFlag() )
    2354     {
    2355 #if !NH_MV
    2356       pcSlice->setPOC(0);
    2357 #endif
    2358       TComReferencePictureSet* rps = pcSlice->getLocalRPS();
    2359       (*rps)=TComReferencePictureSet();
    2360       pcSlice->setRPS(rps);
    2361 #if NH_MV
    2362       pcSlice->setEnableTMVPFlag(false);
    2363 #endif
    2364     }
     2398      READ_CODE(sps->getBitsForPOC(), uiCode, "slice_pic_order_cnt_lsb"); pcSlice->setSlicePicOrderCntLsb( uiCode );
     2399    }
    23652400    else
    23662401    {
    2367 #if !NH_MV
    2368       READ_CODE(sps->getBitsForPOC(), uiCode, "slice_pic_order_cnt_lsb");
    2369       Int iPOClsb = uiCode;
    2370       Int iPrevPOC = prevTid0POC;
    2371       Int iMaxPOClsb = 1<< sps->getBitsForPOC();
    2372       Int iPrevPOClsb = iPrevPOC & (iMaxPOClsb - 1);
    2373       Int iPrevPOCmsb = iPrevPOC-iPrevPOClsb;
    2374       Int iPOCmsb;
    2375       if( ( iPOClsb  <  iPrevPOClsb ) && ( ( iPrevPOClsb - iPOClsb )  >=  ( iMaxPOClsb / 2 ) ) )
    2376       {
    2377         iPOCmsb = iPrevPOCmsb + iMaxPOClsb;
    2378       }
    2379       else if( (iPOClsb  >  iPrevPOClsb )  && ( (iPOClsb - iPrevPOClsb )  >  ( iMaxPOClsb / 2 ) ) )
    2380       {
    2381         iPOCmsb = iPrevPOCmsb - iMaxPOClsb;
    2382       }
    2383       else
    2384       {
    2385         iPOCmsb = iPrevPOCmsb;
    2386       }
    2387       if ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
    2388         || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
    2389         || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP )
    2390       {
    2391         // For BLA picture types, POCmsb is set to 0.
    2392         iPOCmsb = 0;
    2393       }
    2394       pcSlice->setPOC              (iPOCmsb+iPOClsb);
    2395 #endif
    2396       TComReferencePictureSet* rps;
    2397       rps = pcSlice->getLocalRPS();
    2398       (*rps)=TComReferencePictureSet();
    2399 
    2400       pcSlice->setRPS(rps);
    2401       READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" );
    2402       if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header
    2403       {
    2404         parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets());
    2405 #if NH_MV
    2406         if ( !rps->getInterRPSPrediction( ) )
    2407         { // check sum of num_positive_pics and num_negative_pics
    2408           rps->checkMaxNumPics(
    2409             vps->getVpsExtensionFlag(),
    2410             MAX_INT,  // To be replaced by MaxDbpSize
    2411             pcSlice->getLayerId(),
    2412             sps->getMaxDecPicBuffering( sps->getSpsMaxSubLayersMinus1() ) - 1 );
    2413         }
    2414 #endif
    2415 
    2416       }
    2417       else // use reference to short-term reference picture set in PPS
    2418       {
    2419         Int numBits = 0;
    2420         while ((1 << numBits) < sps->getRPSList()->getNumberOfReferencePictureSets())
    2421         {
    2422           numBits++;
    2423         }
    2424         if (numBits > 0)
    2425         {
    2426           READ_CODE( numBits, uiCode, "short_term_ref_pic_set_idx");
    2427         }
    2428         else
    2429         {
    2430           uiCode = 0;
    2431        
    2432         }
    2433         *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode));
    2434       }
    2435       if(sps->getLongTermRefsPresent())
    2436       {
    2437         Int offset = rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures();
    2438         UInt numOfLtrp = 0;
    2439         UInt numLtrpInSPS = 0;
    2440         if (sps->getNumLongTermRefPicSPS() > 0)
    2441         {
    2442           READ_UVLC( uiCode, "num_long_term_sps");
    2443           numLtrpInSPS = uiCode;
    2444           numOfLtrp += numLtrpInSPS;
    2445           rps->setNumberOfLongtermPictures(numOfLtrp);
    2446         }
    2447         Int bitsForLtrpInSPS = 0;
    2448         while (sps->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS))
    2449         {
    2450           bitsForLtrpInSPS++;
    2451         }
    2452         READ_UVLC( uiCode, "num_long_term_pics");             rps->setNumberOfLongtermPictures(uiCode);
    2453         numOfLtrp += uiCode;
    2454         rps->setNumberOfLongtermPictures(numOfLtrp);
    2455         Int maxPicOrderCntLSB = 1 << sps->getBitsForPOC();
    2456         Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;
    2457         for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++)
    2458         {
    2459           Int pocLsbLt;
    2460           if (k < numLtrpInSPS)
     2402      pcSlice->setSlicePicOrderCntLsb( 0 );
     2403    }
     2404
     2405    if( pcSlice->getNalUnitType()  != NAL_UNIT_CODED_SLICE_IDR_W_RADL  &&  pcSlice->getNalUnitType() !=  NAL_UNIT_CODED_SLICE_IDR_N_LP )
     2406    {     
     2407      READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" ); pcSlice->setShortTermRefPicSetSpsFlag( uiCode == 1 );
     2408      if( !pcSlice->getShortTermRefPicSetSpsFlag() )
     2409      {
     2410        parseShortTermRefPicSet( sps, pcSlice->getLocalStRps( ), sps->getNumShortTermRefPicSets() );
     2411      }
     2412      else if( sps->getNumShortTermRefPicSets() > 1 )
     2413      {
     2414        READ_CODE( pcSlice->getShortTermRefPicSetIdxLen() , uiCode, "short_term_ref_pic_set_idx" ); pcSlice->setShortTermRefPicSetIdx( uiCode );
     2415      }
     2416      if( sps->getLongTermRefPicsPresentFlag() )
     2417      {
     2418        if( sps->getNumLongTermRefPicsSps() > 0 )
     2419        {
     2420          READ_UVLC( uiCode, "num_long_term_sps" ); pcSlice->setNumLongTermSps( uiCode );
     2421        }
     2422        READ_UVLC( uiCode, "num_long_term_pics" ); pcSlice->setNumLongTermPics( uiCode );
     2423        for( Int i = 0; i < pcSlice->getNumLongTermSps() + pcSlice->getNumLongTermPics( ); i++ )
     2424        {
     2425          if( i < pcSlice->getNumLongTermSps() )
    24612426          {
    2462             uiCode = 0;
    2463             if (bitsForLtrpInSPS > 0)
     2427            if( sps->getNumLongTermRefPicsSps() > 1 )
    24642428            {
    2465               READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]");
     2429              READ_CODE( pcSlice->getLtIdxSpsLen() , uiCode, "lt_idx_sps" ); pcSlice->setLtIdxSps( i, uiCode );
    24662430            }
    2467             Bool usedByCurrFromSPS=sps->getUsedByCurrPicLtSPSFlag(uiCode);
    2468 
    2469             pocLsbLt = sps->getLtRefPicPocLsbSps(uiCode);
    2470             rps->setUsed(j,usedByCurrFromSPS);
    24712431          }
    24722432          else
    24732433          {
    2474             READ_CODE(sps->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode;
    2475             READ_FLAG( uiCode, "used_by_curr_pic_lt_flag");     rps->setUsed(j,uiCode);
     2434            READ_CODE( pcSlice->getPocLsbLtLen() , uiCode, "poc_lsb_lt" ); pcSlice->setPocLsbLt( i, uiCode );
     2435            READ_FLAG( uiCode, "used_by_curr_pic_lt_flag" ); pcSlice->setUsedByCurrPicLtFlag( i, uiCode == 1 );
    24762436          }
    2477           READ_FLAG(uiCode,"delta_poc_msb_present_flag");
    2478           Bool mSBPresentFlag = uiCode ? true : false;
    2479           if(mSBPresentFlag)
     2437          READ_FLAG( uiCode, "delta_poc_msb_present_flag" ); pcSlice->setDeltaPocMsbPresentFlag( i, uiCode == 1 );
     2438          if( pcSlice->getDeltaPocMsbPresentFlag( i ) )
    24802439          {
    2481             READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" );
    2482             Bool deltaFlag = false;
    2483             //            First LTRP                               || First LTRP from SH
    2484             if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) )
    2485             {
    2486               deltaFlag = true;
    2487             }
    2488             if(deltaFlag)
    2489             {
    2490               deltaPocMSBCycleLT = uiCode;
    2491             }
    2492             else
    2493             {
    2494               deltaPocMSBCycleLT = uiCode + prevDeltaMSB;
    2495             }
    2496 
    2497             Int pocLTCurr = pcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB
    2498                                         - iPOClsb + pocLsbLt;
    2499             rps->setPOC     (j, pocLTCurr);
    2500             rps->setDeltaPOC(j, - pcSlice->getPOC() + pocLTCurr);
    2501             rps->setCheckLTMSBPresent(j,true);
     2440            READ_UVLC( uiCode, "delta_poc_msb_cycle_lt" ); pcSlice->setDeltaPocMsbCycleLt( i, uiCode );
    25022441          }
    2503           else
    2504           {
     2442        }
     2443      }
     2444      if( sps->getSpsTemporalMvpEnabledFlag() )
     2445      {
     2446        READ_FLAG( uiCode, "slice_temporal_mvp_enabled_flag" ); pcSlice->setSliceTemporalMvpEnabledFlag( uiCode == 1 );
     2447      }
     2448    }
     2449#else
     2450if( pcSlice->getIdrPicFlag() )
     2451{
     2452  pcSlice->setPOC(0);
     2453  TComReferencePictureSet* rps = pcSlice->getLocalRPS();
     2454  (*rps)=TComReferencePictureSet();
     2455  pcSlice->setRPS(rps);
     2456}
     2457else
     2458{
     2459  READ_CODE(sps->getBitsForPOC(), uiCode, "slice_pic_order_cnt_lsb");
     2460  Int iPOClsb = uiCode;
     2461  Int iPrevPOC = prevTid0POC;
     2462  Int iMaxPOClsb = 1<< sps->getBitsForPOC();
     2463  Int iPrevPOClsb = iPrevPOC & (iMaxPOClsb - 1);
     2464  Int iPrevPOCmsb = iPrevPOC-iPrevPOClsb;
     2465  Int iPOCmsb;
     2466  if( ( iPOClsb  <  iPrevPOClsb ) && ( ( iPrevPOClsb - iPOClsb )  >=  ( iMaxPOClsb / 2 ) ) )
     2467  {
     2468    iPOCmsb = iPrevPOCmsb + iMaxPOClsb;
     2469  }
     2470  else if( (iPOClsb  >  iPrevPOClsb )  && ( (iPOClsb - iPrevPOClsb )  >  ( iMaxPOClsb / 2 ) ) )
     2471  {
     2472    iPOCmsb = iPrevPOCmsb - iMaxPOClsb;
     2473  }
     2474  else
     2475  {
     2476    iPOCmsb = iPrevPOCmsb;
     2477  }
     2478  if ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
     2479    || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
     2480    || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP )
     2481  {
     2482    // For BLA picture types, POCmsb is set to 0.
     2483    iPOCmsb = 0;
     2484  }
     2485  pcSlice->setPOC              (iPOCmsb+iPOClsb);
     2486
     2487  TComReferencePictureSet* rps;
     2488  rps = pcSlice->getLocalRPS();
     2489  (*rps)=TComReferencePictureSet();
     2490
     2491  pcSlice->setRPS(rps);
     2492  READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" );
     2493  if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header
     2494  {
     2495    parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets());
     2496  }
     2497  else // use reference to short-term reference picture set in PPS
     2498  {
     2499    Int numBits = 0;
     2500    while ((1 << numBits) < sps->getRPSList()->getNumberOfReferencePictureSets())
     2501    {
     2502      numBits++;
     2503    }
     2504    if (numBits > 0)
     2505    {
     2506      READ_CODE( numBits, uiCode, "short_term_ref_pic_set_idx");
     2507    }
     2508    else
     2509    {
     2510      uiCode = 0;       
     2511    }
     2512    *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode));
     2513  }
     2514  if(sps->getLongTermRefsPresent())
     2515  {
     2516    Int offset = rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures();
     2517    UInt numOfLtrp = 0;
     2518    UInt numLtrpInSPS = 0;
     2519    if (sps->getNumLongTermRefPicSPS() > 0)
     2520    {
     2521      READ_UVLC( uiCode, "num_long_term_sps");
     2522      numLtrpInSPS = uiCode;
     2523      numOfLtrp += numLtrpInSPS;
     2524      rps->setNumberOfLongtermPictures(numOfLtrp);
     2525    }
     2526    Int bitsForLtrpInSPS = 0;
     2527    while (sps->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS))
     2528    {
     2529      bitsForLtrpInSPS++;
     2530    }
     2531    READ_UVLC( uiCode, "num_long_term_pics");             rps->setNumberOfLongtermPictures(uiCode);
     2532    numOfLtrp += uiCode;
     2533    rps->setNumberOfLongtermPictures(numOfLtrp);
     2534    Int maxPicOrderCntLSB = 1 << sps->getBitsForPOC();
     2535    Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;
     2536    for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++)
     2537    {
     2538      Int pocLsbLt;
     2539      if (k < numLtrpInSPS)
     2540      {
     2541        uiCode = 0;
     2542        if (bitsForLtrpInSPS > 0)
     2543        {
     2544          READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]");
     2545        }
     2546        Bool usedByCurrFromSPS=sps->getUsedByCurrPicLtSPSFlag(uiCode);
     2547
     2548        pocLsbLt = sps->getLtRefPicPocLsbSps(uiCode);
     2549        rps->setUsed(j,usedByCurrFromSPS);
     2550      }
     2551      else
     2552      {
     2553        READ_CODE(sps->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode;
     2554        READ_FLAG( uiCode, "used_by_curr_pic_lt_flag");     rps->setUsed(j,uiCode);
     2555      }
     2556      READ_FLAG(uiCode,"delta_poc_msb_present_flag");
     2557      Bool mSBPresentFlag = uiCode ? true : false;
     2558      if(mSBPresentFlag)
     2559      {
     2560        READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" );
     2561        Bool deltaFlag = false;
     2562        //            First LTRP                               || First LTRP from SH
     2563        if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) )
     2564        {
     2565          deltaFlag = true;
     2566        }
     2567        if(deltaFlag)
     2568        {
     2569          deltaPocMSBCycleLT = uiCode;
     2570        }
     2571        else
     2572        {
     2573          deltaPocMSBCycleLT = uiCode + prevDeltaMSB;
     2574        }
     2575
     2576        Int pocLTCurr = pcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB
     2577          - iPOClsb + pocLsbLt;
     2578        rps->setPOC     (j, pocLTCurr);
     2579        rps->setDeltaPOC(j, - pcSlice->getPOC() + pocLTCurr);
     2580        rps->setCheckLTMSBPresent(j,true);
     2581      }
     2582      else
     2583      {
    25052584            rps->setPOC     (j, pocLsbLt);
    25062585            rps->setDeltaPOC(j, - pcSlice->getPOC() + pocLsbLt);
    2507             rps->setCheckLTMSBPresent(j,false);
    2508 
    2509             // reset deltaPocMSBCycleLT for first LTRP from slice header if MSB not present
    2510             if( j == offset+(numOfLtrp-numLtrpInSPS)-1 )
    2511             {
    2512               deltaPocMSBCycleLT = 0;
    2513             }
    2514           }
    2515           prevDeltaMSB = deltaPocMSBCycleLT;
    2516         }
    2517         offset += rps->getNumberOfLongtermPictures();
    2518         rps->setNumberOfPictures(offset);
    2519       }
    2520 #if NH_MV
    2521       if ( !rps->getInterRPSPrediction( ) )
    2522       { // check sum of NumPositivePics, NumNegativePics, num_long_term_sps and num_long_term_pics
    2523         rps->checkMaxNumPics(
    2524           vps->getVpsExtensionFlag(),
    2525             MAX_INT,  // To be replaced by MaxDbpsize
    2526           pcSlice->getLayerId(),
    2527           sps->getMaxDecPicBuffering( sps->getSpsMaxSubLayersMinus1() ) - 1 );
    2528       }
    2529 #endif
    2530 
    2531       if ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
    2532         || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
    2533         || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP )
    2534       {
    2535         // In the case of BLA picture types, rps data is read from slice header but ignored
    2536         rps = pcSlice->getLocalRPS();
    2537         (*rps)=TComReferencePictureSet();
    2538         pcSlice->setRPS(rps);
    2539       }
    2540       if (sps->getTMVPFlagsPresent())
    2541       {
    2542 #if NH_MV
    2543         READ_FLAG( uiCode, "slice_temporal_mvp_enabled_flag" );
    2544 #else
    2545         READ_FLAG( uiCode, "slice_temporal_mvp_enabled_flag" );
    2546 #endif
    2547         pcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false );
    2548       }
    2549       else
    2550       {
    2551         pcSlice->setEnableTMVPFlag(false);
    2552       }
    2553     }
     2586        rps->setCheckLTMSBPresent(j,false);
     2587
     2588        // reset deltaPocMSBCycleLT for first LTRP from slice header if MSB not present
     2589        if( j == offset+(numOfLtrp-numLtrpInSPS)-1 )
     2590        {
     2591          deltaPocMSBCycleLT = 0;
     2592        }
     2593      }
     2594      prevDeltaMSB = deltaPocMSBCycleLT;
     2595    }
     2596    offset += rps->getNumberOfLongtermPictures();
     2597    rps->setNumberOfPictures(offset);
     2598  }
     2599
     2600  if ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
     2601    || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
     2602    || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP )
     2603  {
     2604    // In the case of BLA picture types, rps data is read from slice header but ignored
     2605    rps = pcSlice->getLocalRPS();
     2606    (*rps)=TComReferencePictureSet();
     2607    pcSlice->setRPS(rps);
     2608  }
     2609  if (sps->getTMVPFlagsPresent())
     2610  {
     2611    READ_FLAG( uiCode, "slice_temporal_mvp_enabled_flag" );
     2612    pcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false );
     2613  }
     2614  else
     2615  {
     2616    pcSlice->setEnableTMVPFlag(false);
     2617  }
     2618}
     2619#endif
     2620
    25542621#if NH_MV
    25552622    Bool interLayerPredLayerIdcPresentFlag = false;
     
    26492716    }
    26502717    // }
     2718#if NH_MV
     2719   
     2720    const Int numPicTotalCurr = pcSlice->getNumPicTotalCurr();
     2721    if( pcSlice->getSliceType() == P_SLICE || pcSlice->getSliceType() == B_SLICE )
     2722    {
     2723      if( pps->getListsModificationPresentFlag() && numPicTotalCurr > 1 )
     2724      {
     2725        TComRefPicListModification* rplMod = pcSlice->getRefPicListModification();
     2726        READ_FLAG( uiCode, "ref_pic_list_modification_flag_l0" ); rplMod->setRefPicListModificationFlagL0( uiCode == 1 );
     2727        if( rplMod->getRefPicListModificationFlagL0() )
     2728        {
     2729          for( Int i = 0; i  <=  pcSlice->getNumRefIdxL0ActiveMinus1( ); i++ )
     2730          {
     2731            READ_CODE( rplMod->getListEntryLXLen( numPicTotalCurr ) , uiCode, "list_entry_l0" ); rplMod->setListEntryL0( i, uiCode );
     2732          }
     2733        }
     2734
     2735        if( pcSlice->getSliceType() == B_SLICE )
     2736        {
     2737          READ_FLAG( uiCode, "ref_pic_list_modification_flag_l1" ); rplMod->setRefPicListModificationFlagL1( uiCode == 1 );
     2738          if( rplMod->getRefPicListModificationFlagL1() )
     2739          {
     2740            for( Int i = 0; i  <=  pcSlice->getNumRefIdxL1ActiveMinus1( ); i++ )
     2741            {
     2742              READ_CODE( rplMod->getListEntryLXLen( numPicTotalCurr ), uiCode, "list_entry_l1" ); rplMod->setListEntryL1( i, uiCode );
     2743            }
     2744          }
     2745        }
     2746      }
     2747    }
     2748#else
    26512749    TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification();
    26522750    if(!pcSlice->isIntra())
     
    27352833      refPicListModification->setRefPicListModificationFlagL1(0);
    27362834    }
     2835#endif
     2836
    27372837    if (pcSlice->isInterB())
    27382838    {
     
    28982998    {
    28992999      Int voiInVps = vps->getVoiInVps( pcSlice->getViewIndex() );
    2900 #if NH_3D_FIX_TICKET_101
    29013000      if( vps->getCpInSliceSegmentHeaderFlag( voiInVps ) )
    2902 #else
    2903       if( vps->getCpInSliceSegmentHeaderFlag( voiInVps ) && !pcSlice->getIsDepth() )
    2904 #endif
    29053001      {
    29063002        for( Int m = 0; m < vps->getNumCp( voiInVps ); m++ )
     
    29523048    pcSlice->checkPocResetIdc();
    29533049
     3050#if NH_MV
     3051    if ( pcSlice->getVPS()->getPocLsbNotPresentFlag(pcSlice->getLayerId()) && pcSlice->getSlicePicOrderCntLsb() > 0 )
     3052#else
    29543053    if ( pcSlice->getVPS()->getPocLsbNotPresentFlag(pcSlice->getLayerId()) && slicePicOrderCntLsb > 0 )
     3054#endif
    29553055    {
    29563056      assert( pcSlice->getPocResetIdc() != 2 );
     
    29593059    if( pcSlice->getPocResetIdc() !=  0 )
    29603060    {
    2961       READ_CODE( 6, uiCode, "poc_reset_period_id" ); pcSlice->setPocResetPeriodId( uiCode );
     3061      READ_CODE( 6, uiCode, "poc_reset_period_id" ); pcSlice->setPocResetPeriodId( uiCode );     
     3062      pcSlice->setHasPocResetPeriodIdPresent( true );
    29623063    }
    29633064    else
    29643065    {
    29653066      // TODO Copy poc_reset_period from earlier picture
     3067#if NH_MV
     3068      pcSlice->setHasPocResetPeriodIdPresent( false);
     3069#else
    29663070      pcSlice->setPocResetPeriodId( 0 );
     3071#endif
    29673072    }
    29683073   
     
    29723077      READ_CODE( pcSlice->getPocLsbValLen() , uiCode, "poc_lsb_val" ); pcSlice->setPocLsbVal( uiCode );
    29733078    }         
    2974     pcSlice->checkPocLsbVal();
    2975 
    2976     // Derive the value of PocMs8bValRequiredFlag
     3079    pcSlice->checkPocLsbVal();       
    29773080
    29783081    if( !pcSlice->getPocMsbValRequiredFlag() && pcSlice->getVPS()->getVpsPocLsbAlignedFlag() )
    29793082    {
     3083#if NH_MV
     3084      READ_FLAG( uiCode, "poc_msb_cycle_val_present_flag" ); pcSlice->setPocMsbCycleValPresentFlag( uiCode == 1 );
     3085#else
    29803086      READ_FLAG( uiCode, "poc_msb_val_present_flag" ); pcSlice->setPocMsbValPresentFlag( uiCode == 1 );
     3087#endif
    29813088    }
    29823089    else
    29833090    {
     3091#if NH_MV
     3092      pcSlice->setPocMsbCycleValPresentFlag( pcSlice->inferPocMsbCycleValPresentFlag( ) );
     3093#else
    29843094      pcSlice->setPocMsbValPresentFlag( pcSlice->inferPocMsbValPresentFlag( ) );
     3095#endif
    29853096    }
    29863097
    29873098   
     3099#if NH_MV
     3100    if( pcSlice->getPocMsbCycleValPresentFlag() )
     3101#else
    29883102    if( pcSlice->getPocMsbValPresentFlag() )
    2989     {
     3103#endif
     3104    {
     3105#if NH_MV
     3106      READ_UVLC( uiCode, "poc_msb_val" ); pcSlice->setPocMsbCycleVal( uiCode );
     3107#else
    29903108      READ_UVLC( uiCode, "poc_msb_val" ); pcSlice->setPocMsbVal( uiCode );
     3109#endif
    29913110    }
    29923111
  • branches/HTM-15.0-dev0/source/Lib/TLibDecoder/TDecCAVLC.h

    r1313 r1317  
    6464protected:
    6565
     66#if NH_MV
     67  Void  parseShortTermRefPicSet            (TComSPS* pcSPS, TComStRefPicSet* pcRPS, Int stRpsIdx );
     68#else
    6669  Void  parseShortTermRefPicSet            (TComSPS* pcSPS, TComReferencePictureSet* pcRPS, Int idx);
     70#endif
    6771
    6872#if NH_MV
     
    104108  Void  parseProfileTier    (ProfileTierLevel *ptl, const Bool bIsSubLayer);
    105109  Void  parseHrdParameters  (TComHRD *hrd, Bool cprms_present_flag, UInt tempLevelHigh);
     110#if NH_MV
     111  Void  parseFirstSliceSegmentInPicFlag( TComSlice* pcSlice );
     112  Void  parseSliceHeader    ( TComSlice* pcSlice, ParameterSetManager *parameterSetManager );
     113#else
    106114  Void  parseSliceHeader    ( TComSlice* pcSlice, ParameterSetManager *parameterSetManager, const Int prevTid0POC);
     115#endif
     116
    107117  Void  parseTerminatingBit ( UInt& ruiBit );
    108118  Void  parseRemainingBytes ( Bool noTrailingBytesExpected );
  • branches/HTM-15.0-dev0/source/Lib/TLibDecoder/TDecCu.cpp

    r1313 r1317  
    531531        pcCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight);
    532532      }
     533#if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC
     534      if ( g_traceSubPBMotion )
     535      {
     536        std::cout << std::setfill(' ')                          << std::setw( 15 )
     537          << "Num"                                              << std::setw( 15 )
     538          << "Dir "                                             << std::setw( 15 )
     539          <<  "L0 RefIdx"                                       << std::setw( 15 )
     540          <<  "L0 Hor"                                          << std::setw( 15 )
     541          <<  "L0 Ver"                                          << std::setw( 15 )
     542          <<  "L1 RefIdx"                                       << std::setw( 15 )
     543          <<  "L1 Hor"                                          << std::setw( 15 )
     544          <<  "L1 Ver"                                          << std::setw( 15 )
     545          << std::endl;
     546
     547        for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++)
     548        {
     549          UChar        dir = puhInterDirSP[iPartitionIdx];
     550          TComMvField& mv0 = pcMvFieldSP  [2*iPartitionIdx];
     551          TComMvField& mv1 = pcMvFieldSP  [2*iPartitionIdx+1];
     552
     553          std::cout << std::setfill(' ')                                  << std::setw( 15 )
     554            << iPartitionIdx                                              << std::setw( 15 )
     555            << (UInt) dir                                                 << std::setw( 15 )
     556            << ((dir & 1) ? mv0.getRefIdx()       : MIN_INT)              << std::setw( 15 )
     557            << ((dir & 1) ? mv0.getMv().getHor()  : MIN_INT)              << std::setw( 15 )
     558            << ((dir & 1) ? mv0.getMv().getVer()  : MIN_INT)              << std::setw( 15 )
     559            << ((dir & 2) ? mv1.getRefIdx()       : MIN_INT)              << std::setw( 15 )
     560            << ((dir & 2) ? mv1.getMv().getHor()  : MIN_INT)              << std::setw( 15 )
     561            << ((dir & 2) ? mv1.getMv().getVer()  : MIN_INT)              << std::setw( 15 )
     562            << std::endl;
     563        }
     564      }
     565#endif
    533566    }
    534567    delete[] pcMvFieldSP;
     
    779812  const ChromaFormat chFmt     = rTu.GetChromaFormat();
    780813
     814  DEBUG_STRING_NEW(sTemp)
    781815  if ( pcCU->getDISType(uiAbsPartIdx) == 0 )
    782816  {
     
    12711305    TComTURecurse tuRecurseWithPU(tuRecurseCU, false, TComTU::DONT_SPLIT);
    12721306
     1307    DEBUG_STRING_NEW(sTemp)
    12731308    m_pcPrediction->initIntraPatternChType( tuRecurseWithPU, COMPONENT_Y, false DEBUG_STRING_PASS_INTO(sTemp) );
    12741309
     
    13211356     
    13221357      //===== init pattern for luma prediction =====
    1323      
     1358      DEBUG_STRING_NEW(sTemp)
    13241359      m_pcPrediction->initIntraPatternChType( tuRecurseWithPU, COMPONENT_Y, bUseFilter  DEBUG_STRING_PASS_INTO(sTemp) );
    13251360     
  • branches/HTM-15.0-dev0/source/Lib/TLibDecoder/TDecEntropy.cpp

    r1313 r1317  
    238238  UInt uiNumPU = ( ePartSize == SIZE_2Nx2N ? 1 : ( ePartSize == SIZE_NxN ? 4 : 2 ) );
    239239  UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxTotalCUDepth() - uiDepth ) << 1 ) ) >> 4;
     240
     241#if NH_3D_MLC
    240242//#if H_3D_IV_MERGE
    241 #if NH_3D_MLC
    242243  TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
    243244  UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
     
    651652#endif
    652653        }
    653       }
     654      } 
    654655#if NH_3D_IC
    655656      decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
  • branches/HTM-15.0-dev0/source/Lib/TLibDecoder/TDecEntropy.h

    r1313 r1317  
    6767  virtual Void  parseSPS                  ( TComSPS* pcSPS )     = 0;
    6868  virtual Void  parsePPS                  ( TComPPS* pcPPS )     = 0;
    69   virtual Void parseSliceHeader          ( TComSlice* pcSlice, ParameterSetManager *parameterSetManager, const Int prevTid0POC)       = 0;
     69#if NH_MV
     70  virtual Void  parseFirstSliceSegmentInPicFlag( TComSlice* pcSlice ) = 0;
     71  virtual Void  parseSliceHeader          ( TComSlice* pcSlice, ParameterSetManager *parameterSetManager )       = 0;
     72#else
     73  virtual Void  parseSliceHeader          ( TComSlice* pcSlice, ParameterSetManager *parameterSetManager, const Int prevTid0POC)       = 0;
     74#endif
    7075
    7176  virtual Void parseTerminatingBit       ( UInt& ruilsLast )                                     = 0;
     
    156161  Void    decodeSPS                   ( TComSPS* pcSPS ) { m_pcEntropyDecoderIf->parseSPS(pcSPS); }
    157162  Void    decodePPS                   ( TComPPS* pcPPS ) { m_pcEntropyDecoderIf->parsePPS(pcPPS); }
     163#if NH_MV
     164  Void    decodeFirstSliceSegmentInPicFlag ( TComSlice* pcSlice )  { m_pcEntropyDecoderIf->parseFirstSliceSegmentInPicFlag( pcSlice );         }
     165#endif
     166#if NH_MV
     167  Void    decodeSliceHeader           ( TComSlice* pcSlice, ParameterSetManager *parameterSetManager )  { m_pcEntropyDecoderIf->parseSliceHeader(pcSlice, parameterSetManager);         }
     168#else
    158169  Void    decodeSliceHeader           ( TComSlice* pcSlice, ParameterSetManager *parameterSetManager, const Int prevTid0POC)  { m_pcEntropyDecoderIf->parseSliceHeader(pcSlice, parameterSetManager, prevTid0POC);         }
     170#endif
    159171  Void    decodeTerminatingBit        ( UInt& ruiIsLast )       { m_pcEntropyDecoderIf->parseTerminatingBit(ruiIsLast);     }
    160172  Void    decodeRemainingBytes( Bool noTrailingBytesExpected ) { m_pcEntropyDecoderIf->parseRemainingBytes(noTrailingBytesExpected); }
  • branches/HTM-15.0-dev0/source/Lib/TLibDecoder/TDecSbac.h

    r1313 r1317  
    8080  Void  parseSPS                  ( TComSPS* /*pcSPS*/ ) {}
    8181  Void  parsePPS                  ( TComPPS* /*pcPPS*/ ) {}
     82#if NH_MV
     83  Void  parseFirstSliceSegmentInPicFlag( TComSlice* /*pcSlice*/ ) {}
     84  Void  parseSliceHeader          ( TComSlice* /*pcSlice*/, ParameterSetManager* /*parameterSetManager*/ ) {}
     85#else
    8286  Void  parseSliceHeader          ( TComSlice* /*pcSlice*/, ParameterSetManager* /*parameterSetManager*/, const Int /*prevTid0POC*/) {}
     87#endif
    8388  Void  parseTerminatingBit       ( UInt& ruiBit );
    8489  Void  parseRemainingBytes       ( Bool noTrailingBytesExpected);
  • branches/HTM-15.0-dev0/source/Lib/TLibDecoder/TDecTop.cpp

    r1313 r1317  
    3535    \brief    decoder class
    3636*/
    37 
    3837#include "NALread.h"
    3938#include "TDecTop.h"
     
    127126  }
    128127}
    129 
    130 
    131 
    132128
    133129Void
     
    290286}
    291287
    292 
    293 #if !NH_3D_FIX_TICKET_101
    294 #if NH_3D_IV_MERGE
    295 Void
    296 CamParsCollector::copyCamParamForSlice( TComSlice* pcSlice )
    297 {
    298   if( m_bCamParsVaryOverTime )
    299   {
    300     pcSlice->setCamparaSlice( m_aaiCodedScale, m_aaiCodedOffset );
    301   }
    302 }
    303 #endif
    304 #endif
    305 
    306 
    307288Void
    308289CamParsCollector::xOutput( Int iPOC )
     
    351332TDecTop::TDecTop()
    352333  : m_iMaxRefPicNum(0)
     334#if !NH_MV
    353335  , m_associatedIRAPType(NAL_UNIT_INVALID)
    354   , m_pocCRA(0)
     336  , m_pocCRA(0) 
    355337  , m_pocRandomAccess(MAX_INT)
    356338  , m_cListPic()
    357 #if !NH_MV
    358339  , m_parameterSetManager()
    359340#endif
     
    373354  , m_cSAO()
    374355  , m_pcPic(NULL)
     356#if !NH_MV
    375357  , m_prevPOC(MAX_INT)
    376358  , m_prevTid0POC(0)
     
    383365  , m_isNoOutputPriorPics(false)
    384366  , m_craNoRaslOutputFlag(false)
     367#endif
    385368#if O0043_BEST_EFFORT_DECODING
    386369  , m_forceDecodeBitDepth(8)
    387370#endif
    388371  , m_pDecodedSEIOutputStream(NULL)
     372#if !NH_MV
    389373  , m_warningMessageSkipPicture(false)
     374#endif
    390375  , m_prefixSEINALUs()
     376{
     377#if !NH_MV
     378#if ENC_DEC_TRACE
     379  if (g_hTrace == NULL)
     380  {
     381    g_hTrace = fopen( "TraceDec.txt", "wb" );
     382  }
     383  g_bJustDoIt = g_bEncDecTraceDisable;
     384  g_nSymbolCounter = 0;
     385#endif
     386#endif
     387
     388#if NH_MV
     389  m_layerId                       = 0;
     390  m_viewId                        = 0;
     391
     392#if NH_3D
     393  m_viewIndex                     = 0;
     394  m_isDepth                       = false;
     395  m_pcCamParsCollector            = 0;
     396#endif
     397
     398  m_decodingProcess               = CLAUSE_8;
     399  m_targetOlsIdx                  = -1;
     400  m_smallestLayerId               = -1;
     401  m_isInOwnTargetDecLayerIdList   = 0;
     402  m_prevPicOrderCnt               = 0;
     403  m_pocDecrementedInDpbFlag       = NULL;
     404  m_firstPicInLayerDecodedFlag    = NULL;
     405  m_lastPresentPocResetIdc        = NULL;
     406
     407  m_prevIrapPoc                   = MIN_INT;
     408  m_prevIrapDecodingOrder         = MIN_INT;
     409  m_prevStsaDecOrder              = MIN_INT;
     410  m_prevStsaTemporalId            = MIN_INT;
     411#endif
     412}
     413
     414TDecTop::~TDecTop()
    391415{
    392416#if ENC_DEC_TRACE
    393417#if NH_MV
    394   if ( g_hTrace == NULL )
    395   {
    396 #endif
    397   if (g_hTrace == NULL)
    398   {
    399     g_hTrace = fopen( "TraceDec.txt", "wb" );
    400   }
    401   g_bJustDoIt = g_bEncDecTraceDisable;
    402   g_nSymbolCounter = 0;
    403 #if NH_MV
    404   }
    405 #endif
    406 #endif
    407 #if NH_MV
    408   m_isLastNALWasEos = false;
    409   m_layerId = 0;
    410   m_viewId = 0;
    411 #if NH_3D
    412   m_viewIndex = 0;
    413   m_isDepth = false;
    414   m_pcCamParsCollector = 0;
    415 #endif
    416 #if NH_MV
    417   m_targetOlsIdx = -1;
    418 #endif
    419 #endif
    420 
    421 }
    422 
    423 TDecTop::~TDecTop()
    424 {
    425 #if ENC_DEC_TRACE
    426 #if H_MV_ENC_DEC_TRAC_FIX
    427418  if (g_hTrace != stdout && g_hTrace != NULL)
     419  {
     420    fclose( g_hTrace );
     421    g_hTrace = NULL;
     422  }
    428423#else
    429424  if (g_hTrace != stdout)
    430 #endif
    431425  {
    432426    fclose( g_hTrace );
    433 #if H_MV_ENC_DEC_TRAC_FIX
    434     g_hTrace = NULL;
    435 #endif
    436   }
     427  }
     428#endif 
    437429#endif
    438430  while (!m_prefixSEINALUs.empty())
     
    452444Void TDecTop::destroy()
    453445{
     446
     447#if NH_MV
     448  m_cSAO.destroy();
     449  m_cLoopFilter.        destroy();
     450#endif
     451
    454452  m_cGopDecoder.destroy();
    455453
     
    474472}
    475473
     474#if !NH_MV
    476475Void TDecTop::deletePicBuffer ( )
    477476{
     477
    478478  TComList<TComPic*>::iterator  iterPic   = m_cListPic.begin();
    479479  Int iSize = Int( m_cListPic.size() );
     
    482482  {
    483483    TComPic* pcPic = *(iterPic++);
    484 #if NH_MV
    485     if( pcPic )
    486     {
    487 #endif
    488484    pcPic->destroy();
    489485
    490486    delete pcPic;
    491487    pcPic = NULL;
    492 #if NH_MV
    493     }
    494 #endif
    495488  }
    496489
     
    499492  m_cLoopFilter.        destroy();
    500493
    501 #if !NH_MV
    502494  // destroy ROM
    503495  destroyROM();
    504 #endif
    505496}
    506497
    507498Void TDecTop::xGetNewPicBuffer ( const TComSPS &sps, const TComPPS &pps, TComPic*& rpcPic, const UInt temporalLayer )
    508499{
    509 #if NH_MV
    510   if ( getLayerId() == 0 )
    511   { 
    512     m_iMaxRefPicNum = sps.getMaxDecPicBuffering(temporalLayer);     // m_uiMaxDecPicBuffering has the space for the picture currently being decoded
    513   }
    514   else
    515   {
    516     //GTCIC
    517     //m_iMaxRefPicNum = pcSlice->getVPS()->getMaxDecPicBuffering(pcSlice->getTLayer());   
    518 #if H_MV_HLS7_GEN
    519     TComVPS* vps         = pcSlice->getVPS();
    520     TComDpbSize* dpbSize = vps->getDpbSize();
    521     Int lsIdx            = vps->olsIdxToLsIdx( getTargetOutputLayerSetIdx()); // Is this correct, seems to be missing in spec?
    522     Int layerIdx         = vps->getIdxInLayerSet     ( lsIdx, getLayerId() );
    523     Int subDpbIdx        = dpbSize->getSubDpbAssigned( lsIdx, layerIdx );
    524     m_iMaxRefPicNum      = dpbSize->getMaxVpsDecPicBufferingMinus1(getTargetOutputLayerSetIdx(), subDpbIdx , vps->getSubLayersVpsMaxMinus1( vps->getLayerIdInVps( getLayerId() ) ) + 1 ) + 1 ; 
    525 #endif   
    526   }
    527 #else
    528500  m_iMaxRefPicNum = sps.getMaxDecPicBuffering(temporalLayer);     // m_uiMaxDecPicBuffering has the space for the picture currently being decoded
    529 #endif
    530501  if (m_cListPic.size() < (UInt)m_iMaxRefPicNum)
    531502  {
     
    547518    {
    548519      rpcPic->setOutputMark(false);
    549 #if NH_MV
    550       rpcPic->setPicOutputFlag(false);
    551 #endif
    552520      bBufferIsAvailable = true;
    553521      break;
     
    557525    {
    558526      rpcPic->setOutputMark(false);
    559 #if NH_MV
    560       rpcPic->setPicOutputFlag(false);
    561 #endif
    562527      rpcPic->setReconMark( false );
    563528      rpcPic->getPicYuvRec()->setBorderExtension( false );
     
    577542  rpcPic->create ( sps, pps, true);
    578543}
    579 #if NH_MV
    580 Void TDecTop::endPicDecoding(Int& poc, TComList<TComPic*>*& rpcListPic, std::vector<Int>& targetDecLayerIdSet )
    581 #else
     544
    582545Void TDecTop::executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic)
    583 #endif
    584546{
    585547  if (!m_pcPic)
     
    599561  rpcListPic          = &m_cListPic;
    600562  m_cCuDecoder.destroy();
    601 #if NH_MV
    602   TComSlice::markIvRefPicsAsShortTerm( m_refPicSetInterLayer0, m_refPicSetInterLayer1 ); 
    603   TComSlice::markCurrPic( pcPic );
    604 #endif
    605563  m_bFirstSliceInPicture  = true;
    606 
    607564  return;
    608565}
     
    623580    {
    624581      pcPicTmp->setOutputMark(false);
    625 #if NH_MV
    626       pcPicTmp->setPicOutputFlag(false);
    627 #endif
    628582    }
    629583  }
     
    673627  }
    674628}
    675 
    676 
     629#endif
     630
     631
     632#if NH_MV
     633Void TDecTop::activatePSsAndInitPicOrSlice( TComPic* newPic )
     634{
     635  if ( m_apcSlicePilot->getFirstSliceSegementInPicFlag() )
     636  {
     637    assert( newPic != NULL );
     638
     639#else
    677640Void TDecTop::xActivateParameterSets()
    678641{
    679642  if (m_bFirstSliceInPicture)
    680643  {
     644#endif
    681645    const TComPPS *pps = m_parameterSetManager.getPPS(m_apcSlicePilot->getPPSId()); // this is a temporary PPS object. Do not store this value
    682646    assert (pps != 0);
     
    690654    const TComVPS* vps = m_parameterSetManager.getVPS(sps->getVPSId());
    691655    assert (vps != 0);
    692     if (!m_parameterSetManager.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP(), m_layerId ) )
     656    // TBD: check the condition on m_firstPicInLayerDecodedFlag
     657    if (!m_parameterSetManager.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP() || !m_firstPicInLayerDecodedFlag[m_layerId] , m_layerId ) )
    693658#else
    694659    if (false == m_parameterSetManager.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP()))
     
    700665
    701666#if NH_MV
    702   // When the value of vps_num_rep_formats_minus1 in the active VPS is equal to 0
    703   if ( vps->getVpsNumRepFormatsMinus1() == 0 )
    704   {
    705     //, it is a requirement of bitstream conformance that the value of update_rep_format_flag shall be equal to 0.
    706     assert( sps->getUpdateRepFormatFlag() == false );
    707   }
    708   sps->checkRpsMaxNumPics( vps, getLayerId() );
    709 
    710   // It is a requirement of bitstream conformance that, when the SPS is referred to by
    711   // any current picture that belongs to an independent non-base layer, the value of
    712   // MultiLayerExtSpsFlag derived from the SPS shall be equal to 0.
    713 
    714   if ( m_layerId > 0 && vps->getNumRefLayers( m_layerId ) == 0 )
    715   { 
    716     assert( sps->getMultiLayerExtSpsFlag() == 0 );
    717   }
     667    if ( decProcAnnexG() )
     668    {
     669      // When the value of vps_num_rep_formats_minus1 in the active VPS is equal to 0
     670      if ( vps->getVpsNumRepFormatsMinus1() == 0 )
     671      {
     672        //, it is a requirement of bitstream conformance that the value of update_rep_format_flag shall be equal to 0.
     673        assert( sps->getUpdateRepFormatFlag() == false );
     674      }
     675      sps->checkRpsMaxNumPics( vps, getLayerId() );
     676
     677      // It is a requirement of bitstream conformance that, when the SPS is referred to by
     678      // any current picture that belongs to an independent non-base layer, the value of
     679      // MultiLayerExtSpsFlag derived from the SPS shall be equal to 0.
     680
     681      if ( m_layerId > 0 && vps->getNumRefLayers( m_layerId ) == 0 )
     682      { 
     683        assert( sps->getMultiLayerExtSpsFlag() == 0 );
     684      }
     685    }
    718686#endif
    719687
     
    734702
    735703    //  Get a new picture buffer. This will also set up m_pcPic, and therefore give us a SPS and PPS pointer that we can use.
     704#if !NH_MV
    736705    xGetNewPicBuffer (*(sps), *(pps), m_pcPic, m_apcSlicePilot->getTLayer());
     706
    737707    m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS());
    738 #if NH_MV
    739     m_apcSlicePilot->createInterLayerReferencePictureSet( m_ivPicLists, m_refPicSetInterLayer0, m_refPicSetInterLayer1 );
     708#else
     709    m_pcPic = newPic;
    740710#endif
    741711
     
    752722
    753723#if NH_MV
     724    pSlice->setPic( m_pcPic );
    754725    vps=pSlice->getVPS(); 
    755726    // The nuh_layer_id value of the NAL unit containing the PPS that is activated for a layer layerA with nuh_layer_id equal to nuhLayerIdA shall be equal to 0, or nuhLayerIdA, or the nuh_layer_id of a direct or indirect reference layer of layerA.
     
    803774  else
    804775  {
     776#if NH_MV
     777    assert( m_pcPic != NULL );
     778    assert( newPic  == NULL );
     779#endif
    805780    // make the slice-pilot a real slice, and set up the slice-pilot for the next slice
    806781    m_pcPic->allocateNewSlice();
     
    828803
    829804    // Check if any new SEI has arrived
    830      if(!m_SEIs.empty())
    831      {
    832        // Currently only decoding Unit SEI message occurring between VCL NALUs copied
    833        SEIMessages &picSEI = m_pcPic->getSEIs();
    834        SEIMessages decodingUnitInfos = extractSeisByType (m_SEIs, SEI::DECODING_UNIT_INFO);
    835        picSEI.insert(picSEI.end(), decodingUnitInfos.begin(), decodingUnitInfos.end());
    836        deleteSEIs(m_SEIs);
    837      }
    838   }
    839 }
     805    if(!m_SEIs.empty())
     806    {
     807      // Currently only decoding Unit SEI message occurring between VCL NALUs copied
     808      SEIMessages &picSEI = m_pcPic->getSEIs();
     809      SEIMessages decodingUnitInfos = extractSeisByType (m_SEIs, SEI::DECODING_UNIT_INFO);
     810      picSEI.insert(picSEI.end(), decodingUnitInfos.begin(), decodingUnitInfos.end());
     811      deleteSEIs(m_SEIs);
     812    }
     813  }
     814}
     815
    840816Void TDecTop::xParsePrefixSEIsForUnknownVCLNal()
    841817{
     
    865841}
    866842
    867 
    868 #if NH_MV
    869 Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, Bool newLayerFlag, Bool& sliceSkippedFlag  )
    870 {
    871   assert( nalu.m_nuhLayerId == m_layerId );
     843#if !NH_MV
     844Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay )
     845{
     846  m_apcSlicePilot->initSlice(); // the slice pilot is an object to prepare for a new slice
     847  // it is not associated with picture, sps or pps structures.
     848  if (m_bFirstSliceInPicture)
     849  {
    872850#else
    873 Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay )
    874 {
    875 #endif
     851Void TDecTop::decodeSliceHeader(InputNALUnit &nalu )
     852{
     853  // Initialize entropy decoder
     854  m_cEntropyDecoder.setEntropyDecoder (&m_cCavlcDecoder);
     855  m_cEntropyDecoder.setBitstream      (&(nalu.getBitstream()));
     856
     857  assert( nalu.m_nuhLayerId == m_layerId );   
    876858  m_apcSlicePilot->initSlice(); // the slice pilot is an object to prepare for a new slice
    877                                 // it is not associated with picture, sps or pps structures.
    878 
    879   if (m_bFirstSliceInPicture)
    880   {
     859  // it is not associated with picture, sps or pps structures.
     860  m_apcSlicePilot->setLayerId( nalu.m_nuhLayerId );
     861  m_cEntropyDecoder.decodeFirstSliceSegmentInPicFlag( m_apcSlicePilot );   
     862  if ( m_apcSlicePilot->getFirstSliceSegementInPicFlag() )
     863  {
     864#endif 
    881865    m_uiSliceIdx = 0;
    882866  }
     
    889873  m_apcSlicePilot->setNalUnitType(nalu.m_nalUnitType);
    890874  Bool nonReferenceFlag = (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N ||
    891                            m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N   ||
    892                            m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N  ||
    893                            m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N  ||
    894                            m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N);
     875    m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N   ||
     876    m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N  ||
     877    m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N  ||
     878    m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N);
    895879  m_apcSlicePilot->setTemporalLayerNonReferenceFlag(nonReferenceFlag);
     880#if !NH_MV
    896881  m_apcSlicePilot->setReferenced(true); // Putting this as true ensures that picture is referenced the first time it is in an RPS
     882#endif
    897883  m_apcSlicePilot->setTLayerInfo(nalu.m_temporalId);
    898 
     884#if NH_MV
     885  m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManager );
     886#else
    899887#if ENC_DEC_TRACE
    900888  const UInt64 originalSymbolCount = g_nSymbolCounter;
    901889#endif
     890    m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManager, m_prevTid0POC);
     891#endif
    902892
    903893#if NH_MV
    904   m_apcSlicePilot->setRefPicSetInterLayer( & m_refPicSetInterLayer0, &m_refPicSetInterLayer1 );
    905   m_apcSlicePilot->setLayerId( nalu.m_nuhLayerId );
    906 #endif
    907 
    908   m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManager, m_prevTid0POC);
    909 
     894}
     895#else
    910896  // set POC for dependent slices in skipped pictures
    911897  if(m_apcSlicePilot->getDependentSliceSegmentFlag() && m_prevSliceSkipped)
     
    915901
    916902  xUpdatePreviousTid0POC(m_apcSlicePilot);
    917 
    918903  m_apcSlicePilot->setAssociatedIRAPPOC(m_pocCRA);
    919904  m_apcSlicePilot->setAssociatedIRAPType(m_associatedIRAPType);
    920 #if NH_MV 
    921   const TComVPS* vps     = m_apcSlicePilot->getVPS();
    922   Int layerId            = nalu.m_nuhLayerId;   
    923   setViewId   ( vps->getViewId   ( layerId )      ); 
    924 #if NH_3D
    925   setViewIndex( vps->getViewIndex( layerId )      ); 
    926   setIsDepth  ( vps->getDepthId  ( layerId ) == 1 ); 
    927   m_ivPicLists->setVPS( vps );
    928 #endif
    929 #endif
     905
    930906
    931907  //For inference of NoOutputOfPriorPicsFlag
    932908  if (m_apcSlicePilot->getRapPicFlag())
    933909  {
    934     if ((m_apcSlicePilot->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_apcSlicePilot->getNalUnitType() <= NAL_UNIT_CODED_SLICE_IDR_N_LP) ||
     910      if ((m_apcSlicePilot->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_apcSlicePilot->getNalUnitType() <= NAL_UNIT_CODED_SLICE_IDR_N_LP) ||
    935911        (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_bFirstSliceInSequence) ||
    936912        (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_apcSlicePilot->getHandleCraAsBlaFlag()))
    937     {
    938       m_apcSlicePilot->setNoRaslOutputFlag(true);
    939     }
     913      {
     914        m_apcSlicePilot->setNoRaslOutputFlag(true);
     915      }
    940916    //the inference for NoOutputPriorPicsFlag
    941917    if (!m_bFirstSliceInBitstream && m_apcSlicePilot->getRapPicFlag() && m_apcSlicePilot->getNoRaslOutputFlag())
     
    948924    else
    949925    {
    950       m_apcSlicePilot->setNoOutputPriorPicsFlag(false);
     926      m_apcSlicePilot->setNoOutputPriorPicsFlag(false); 
    951927    }
    952928
     
    974950    }
    975951  }
    976 
     952 
    977953  if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_craNoRaslOutputFlag) //Reset POC MSB when CRA has NoRaslOutputFlag equal to 1
    978954  {
     
    985961    xUpdatePreviousTid0POC(m_apcSlicePilot);
    986962  }
    987 #if NH_MV
    988     xCeckNoClrasOutput();
    989 #endif
    990963
    991964  // Skip pictures due to random access
    992 
    993 #if NH_MV
    994   if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay, vps))
    995 #else
    996965  if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay))
    997 #endif
    998966  {
    999967    m_prevSliceSkipped = true;
    1000968    m_skippedPOC = m_apcSlicePilot->getPOC();
    1001 #if NH_MV
    1002     sliceSkippedFlag = true;
    1003 #endif
    1004969    return false;
    1005970  }
     
    1009974    m_prevSliceSkipped = true;
    1010975    m_skippedPOC = m_apcSlicePilot->getPOC();
    1011 #if NH_MV
    1012     sliceSkippedFlag = true;
    1013 #endif
    1014976    return false;
    1015977  }
     
    1030992    {
    1031993      m_prevPOC = m_apcSlicePilot->getPOC();
     994
    1032995#if ENC_DEC_TRACE
    1033996      //rewind the trace counter since we didn't actually decode the slice
     
    10381001    m_prevPOC = m_apcSlicePilot->getPOC();
    10391002  }
    1040 #if NH_MV
    1041   if ( newLayerFlag )
    1042   {
    1043     return false;
    1044   }
    1045 #if ENC_DEC_TRACE
    1046 #if H_MV_ENC_DEC_TRAC
    1047   // parse remainder of SH
    1048    g_disableHLSTrace = false;
    1049 #endif
    1050 #endif
    1051 #endif
    1052 
    1053 #if NH_MV
    1054    // This part needs further testing !
    1055    if ( m_apcSlicePilot->getPocResetFlag() )
    1056    {   
    1057      xResetPocInPicBuffer();
    1058    }
    1059 
    1060    if ( m_apcSlicePilot->getTLayer() == 0 && m_apcSlicePilot->getEnableTMVPFlag() == 0 )
    1061   {
    1062     //update all pics in the DPB such that they cannot be used for TMPV ref
    1063     TComList<TComPic*>::iterator  iterRefPic = m_cListPic.begin(); 
    1064     while( iterRefPic != m_cListPic.end() )
    1065     {
    1066       TComPic *refPic = *iterRefPic;
    1067       if( ( refPic->getLayerId() == m_apcSlicePilot->getLayerId() ) && refPic->getReconMark() )
    1068       {
    1069         for(Int i = refPic->getNumAllocatedSlice()-1; i >= 0; i--)
    1070         {
    1071 
    1072           TComSlice *refSlice = refPic->getSlice(i);
    1073           refSlice->setAvailableForTMVPRefFlag( false );
    1074         }
    1075       }
    1076       iterRefPic++;
    1077     }
    1078   }
    1079   m_apcSlicePilot->setAvailableForTMVPRefFlag( true );
    1080 #endif
    10811003
    10821004  //detect lost reference picture and insert copy of earlier frame.
     
    10931015    m_prevPOC = m_apcSlicePilot->getPOC();
    10941016  }
    1095 
    10961017  // actual decoding starts here
    10971018  xActivateParameterSets();
     
    11031024  TComSlice* pcSlice = m_pcPic->getPicSym()->getSlice(m_uiSliceIdx);
    11041025
    1105   // When decoding the slice header, the stored start and end addresses were actually RS addresses, not TS addresses.
    1106   // Now, having set up the maps, convert them to the correct form.
    1107   pcSlice->setSliceSegmentCurStartCtuTsAddr( m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceSegmentCurStartCtuTsAddr()) );
    1108   pcSlice->setSliceSegmentCurEndCtuTsAddr( m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceSegmentCurEndCtuTsAddr()) );
    1109   if(!pcSlice->getDependentSliceSegmentFlag())
    1110   {
    1111     pcSlice->setSliceCurStartCtuTsAddr(m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceCurStartCtuTsAddr()));
    1112     pcSlice->setSliceCurEndCtuTsAddr(m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceCurEndCtuTsAddr()));
    1113   }
    1114 
    1115   m_pcPic->setTLayer(nalu.m_temporalId);
     1026#endif
    11161027
    11171028#if NH_MV
    1118   //Check Multiview Main profile constraint in G.11.1.1
    1119   //  When ViewOrderIdx[ i ] derived according to any active VPS is equal to 1
    1120   //  for the layer with nuh_layer_id equal to i in subBitstream,
    1121   //  inter_view_mv_vert_constraint_flag shall be equal to 1
    1122   //  in the sps_multilayer_extension( ) syntax structure in each active SPS for that layer.
    1123   if( pcSlice->getSPS()->getPTL()->getGeneralPTL()->getProfileIdc()==Profile::MULTIVIEWMAIN
     1029Void TDecTop::decodeSliceSegment(InputNALUnit &nalu )
     1030{
     1031  TComSlice* pcSlice = m_pcPic->getPicSym()->getSlice(m_uiSliceIdx);
     1032
     1033  if ( m_pcPic->getHasGeneratedRefPics() )
     1034  {
     1035    if ( pcSlice->getFirstSliceSegementInPicFlag() )
     1036    {
     1037      std::cout << std:: setfill(' ')
     1038        << "Layer "  << std::setw(2) << m_pcPic->getLayerId()
     1039        << "   POC " << std::setw(4) << m_pcPic->getPOC()
     1040        << " Reference pictures missing. Skipping picture." << std::endl;
     1041    }
     1042  }
     1043  else
     1044  {
     1045    //Check Multiview Main profile constraint in G.11.1.1
     1046    //  When ViewOrderIdx[ i ] derived according to any active VPS is equal to 1
     1047    //  for the layer with nuh_layer_id equal to i in subBitstream,
     1048    //  inter_view_mv_vert_constraint_flag shall be equal to 1
     1049    //  in the sps_multilayer_extension( ) syntax structure in each active SPS for that layer.
     1050    if( pcSlice->getSPS()->getPTL()->getGeneralPTL()->getProfileIdc()==Profile::MULTIVIEWMAIN
    11241051      &&
    11251052      pcSlice->getVPS()->getViewOrderIdx(pcSlice->getVPS()->getLayerIdInNuh(getLayerId()))==1
    1126      )
    1127   {
    1128     assert( pcSlice->getSPS()->getInterViewMvVertConstraintFlag()==1 );
    1129   }
    1130 #endif
    1131 #if NH_MV
    1132   m_pcPic->setLayerId( nalu.m_nuhLayerId );
    1133   m_pcPic->setViewId ( getViewId() );
     1053      )
     1054    {
     1055      assert( pcSlice->getSPS()->getInterViewMvVertConstraintFlag()==1 );
     1056    }
     1057
     1058    m_pcPic->setLayerId( nalu.m_nuhLayerId );
     1059    m_pcPic->setViewId ( getViewId() );
    11341060#if NH_3D
    1135   m_pcPic->setViewIndex( getViewIndex() );
    1136   m_pcPic->setIsDepth  ( getIsDepth  () );
    1137   pcSlice->setIvPicLists( m_ivPicLists );         
    1138 #endif
    1139 #endif
    1140 
    1141   if (!pcSlice->getDependentSliceSegmentFlag())
    1142   {
    1143     pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_associatedIRAPType, m_cListPic );
    1144     // Set reference list
    1145 #if NH_MV   
    1146     std::vector< TComPic* > tempRefPicLists[2];
    1147     std::vector< Bool     > usedAsLongTerm [2];
    1148     Int       numPocTotalCurr;
    1149 
    1150     pcSlice->getTempRefPicLists( m_cListPic, m_refPicSetInterLayer0, m_refPicSetInterLayer1, tempRefPicLists, usedAsLongTerm, numPocTotalCurr);
    1151     pcSlice->setRefPicList     ( tempRefPicLists, usedAsLongTerm, numPocTotalCurr, true );
     1061    m_pcPic->setViewIndex( getViewIndex() );
     1062    m_pcPic->setIsDepth  ( getIsDepth  () );
     1063    pcSlice->setIvPicLists( m_dpb );         
     1064#endif
     1065#endif
     1066   
     1067    // When decoding the slice header, the stored start and end addresses were actually RS addresses, not TS addresses.
     1068    // Now, having set up the maps, convert them to the correct form.
     1069    pcSlice->setSliceSegmentCurStartCtuTsAddr( m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceSegmentCurStartCtuTsAddr()) );
     1070    pcSlice->setSliceSegmentCurEndCtuTsAddr( m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceSegmentCurEndCtuTsAddr()) );
     1071    if(!pcSlice->getDependentSliceSegmentFlag())
     1072    {
     1073      pcSlice->setSliceCurStartCtuTsAddr(m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceCurStartCtuTsAddr()));
     1074      pcSlice->setSliceCurEndCtuTsAddr(m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceCurEndCtuTsAddr()));
     1075    }
     1076
     1077    m_pcPic->setTLayer(nalu.m_temporalId);
     1078
     1079
     1080    if (!pcSlice->getDependentSliceSegmentFlag())
     1081    {
     1082#if !NH_MV
     1083      pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_associatedIRAPType, m_cListPic );
     1084      // Set reference list
     1085      pcSlice->setRefPicList( m_cListPic, true );
     1086#else
     1087      if (pcSlice->getSliceType() != I_SLICE )
     1088      {
     1089        if( m_decProcPocAndRps == ANNEX_F )
     1090        {
     1091          pcSlice->f834decProcForRefPicListConst();
     1092        }
     1093        else if ( m_decProcPocAndRps == CLAUSE_8 )
     1094        {
     1095          pcSlice->cl834DecProcForRefPicListConst();
     1096        }
     1097        else
     1098        {
     1099          assert( false );
     1100        }
     1101      }
    11521102#if NH_3D_NBDV
    1153     pcSlice->setDefaultRefView();
     1103      pcSlice->setDefaultRefView();
    11541104#endif
    11551105#if NH_3D_ARP
    1156     pcSlice->setARPStepNum(m_ivPicLists);
    1157 #endif
    1158 #else
    1159     pcSlice->setRefPicList( m_cListPic, true );
    1160 #endif
    1161 
    1162 #if NH_3D
    1163     pcSlice->checkInCompPredRefLayers();
    1164 #if NH_3D_IV_MERGE
    1165 #if H_3D_FCO
    1166     //assert( !getIsDepth() );
    1167 #else
    1168     assert( !getIsDepth() || ( pcSlice->getTexturePic() != 0 ) );
    1169 #endif
    1170 #endif   
    1171 #endif
    1172 #if NH_MV
    1173     if( m_layerId > 0 && !pcSlice->isIntra() && pcSlice->getEnableTMVPFlag() )
    1174     {
    1175       TComPic* refPic = pcSlice->getRefPic(RefPicList(1 - pcSlice->getColFromL0Flag()), pcSlice->getColRefIdx());
    1176 
    1177       assert ( refPic );
    1178       assert ( refPic->getPicSym()->getSlice(0)->getAvailableForTMVPRefFlag() == true );
    1179     }
    1180 #endif
    1181 
    1182     // For generalized B
    1183     // note: maybe not existed case (always L0 is copied to L1 if L1 is empty)
    1184     if (pcSlice->isInterB() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == 0)
    1185     {
    1186       Int iNumRefIdx = pcSlice->getNumRefIdx(REF_PIC_LIST_0);
    1187       pcSlice->setNumRefIdx        ( REF_PIC_LIST_1, iNumRefIdx );
    1188 
    1189       for (Int iRefIdx = 0; iRefIdx < iNumRefIdx; iRefIdx++)
    1190       {
    1191         pcSlice->setRefPic(pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx), REF_PIC_LIST_1, iRefIdx);
    1192       }
    1193     }
    1194     if (!pcSlice->isIntra())
    1195     {
    1196       Bool bLowDelay = true;
    1197       Int  iCurrPOC  = pcSlice->getPOC();
    1198       Int iRefIdx = 0;
    1199 
    1200       for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_0) && bLowDelay; iRefIdx++)
    1201       {
    1202         if ( pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx)->getPOC() > iCurrPOC )
     1106      pcSlice->setPocsInCurrRPSs();
     1107      pcSlice->setARPStepNum(m_dpb);
     1108#endif     
     1109#endif
     1110
     1111      // For generalized B
     1112      // note: maybe not existed case (always L0 is copied to L1 if L1 is empty)
     1113      if (pcSlice->isInterB() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == 0)
     1114      {
     1115        Int iNumRefIdx = pcSlice->getNumRefIdx(REF_PIC_LIST_0);
     1116        pcSlice->setNumRefIdx        ( REF_PIC_LIST_1, iNumRefIdx );
     1117
     1118        for (Int iRefIdx = 0; iRefIdx < iNumRefIdx; iRefIdx++)
    12031119        {
    1204           bLowDelay = false;
     1120          pcSlice->setRefPic(pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx), REF_PIC_LIST_1, iRefIdx);
    12051121        }
    12061122      }
    1207       if (pcSlice->isInterB())
    1208       {
    1209         for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_1) && bLowDelay; iRefIdx++)
     1123      if (!pcSlice->isIntra())
     1124      {
     1125        Bool bLowDelay = true;
     1126        Int  iCurrPOC  = pcSlice->getPOC();
     1127        Int iRefIdx = 0;
     1128
     1129        for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_0) && bLowDelay; iRefIdx++)
    12101130        {
    1211           if ( pcSlice->getRefPic(REF_PIC_LIST_1, iRefIdx)->getPOC() > iCurrPOC )
     1131          if ( pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx)->getPOC() > iCurrPOC )
    12121132          {
    12131133            bLowDelay = false;
    12141134          }
    12151135        }
    1216       }
    1217 
    1218       pcSlice->setCheckLDC(bLowDelay);
    1219     }
    1220 
    1221     //---------------
    1222     pcSlice->setRefPOCList();
     1136        if (pcSlice->isInterB())
     1137        {
     1138          for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_1) && bLowDelay; iRefIdx++)
     1139          {
     1140            if ( pcSlice->getRefPic(REF_PIC_LIST_1, iRefIdx)->getPOC() > iCurrPOC )
     1141            {
     1142              bLowDelay = false;
     1143            }
     1144          }
     1145        }
     1146
     1147        pcSlice->setCheckLDC(bLowDelay);
     1148      }
     1149
     1150      //---------------
     1151      pcSlice->setRefPOCList();
    12231152#if  NH_3D_TMVP
    1224     if(pcSlice->getLayerId())
    1225     {
    1226       pcSlice->generateAlterRefforTMVP();
    1227     }
    1228 #endif
    1229   }
    1230 
    1231   m_pcPic->setCurrSliceIdx(m_uiSliceIdx);
    1232   if(pcSlice->getSPS()->getScalingListFlag())
    1233   {
    1234     TComScalingList scalingList;
    1235     if(pcSlice->getPPS()->getScalingListPresentFlag())
    1236     {
    1237       scalingList = pcSlice->getPPS()->getScalingList();
    1238     }
    1239     else if (pcSlice->getSPS()->getScalingListPresentFlag())
    1240     {
    1241       scalingList = pcSlice->getSPS()->getScalingList();
     1153      if(pcSlice->getLayerId())
     1154      {
     1155        pcSlice->generateAlterRefforTMVP();
     1156      }
     1157#endif
     1158    }
     1159
     1160    m_pcPic->setCurrSliceIdx(m_uiSliceIdx);
     1161    if(pcSlice->getSPS()->getScalingListFlag())
     1162    {
     1163      TComScalingList scalingList;
     1164      if(pcSlice->getPPS()->getScalingListPresentFlag())
     1165      {
     1166        scalingList = pcSlice->getPPS()->getScalingList();
     1167      }
     1168      else if (pcSlice->getSPS()->getScalingListPresentFlag())
     1169      {
     1170        scalingList = pcSlice->getSPS()->getScalingList();
     1171      }
     1172      else
     1173      {
     1174        scalingList.setDefaultScalingList();
     1175      }
     1176      m_cTrQuant.setScalingListDec(scalingList);
     1177      m_cTrQuant.setUseScalingList(true);
    12421178    }
    12431179    else
    12441180    {
    1245       scalingList.setDefaultScalingList();
    1246     }
    1247     m_cTrQuant.setScalingListDec(scalingList);
    1248     m_cTrQuant.setUseScalingList(true);
    1249   }
    1250   else
    1251   {
    1252     const Int maxLog2TrDynamicRange[MAX_NUM_CHANNEL_TYPE] =
    1253     {
     1181      const Int maxLog2TrDynamicRange[MAX_NUM_CHANNEL_TYPE] =
     1182      {
    12541183        pcSlice->getSPS()->getMaxLog2TrDynamicRange(CHANNEL_TYPE_LUMA),
    12551184        pcSlice->getSPS()->getMaxLog2TrDynamicRange(CHANNEL_TYPE_CHROMA)
    1256     };
    1257     m_cTrQuant.setFlatScalingList(maxLog2TrDynamicRange, pcSlice->getSPS()->getBitDepths());
    1258     m_cTrQuant.setUseScalingList(false);
    1259   }
    1260 
    1261 #if !NH_3D_FIX_TICKET_101
    1262 #if NH_3D_IV_MERGE
    1263 #if H_3D_FCO
    1264   if( !pcSlice->getIsDepth() && m_pcCamParsCollector )
     1185      };
     1186      m_cTrQuant.setFlatScalingList(maxLog2TrDynamicRange, pcSlice->getSPS()->getBitDepths());
     1187      m_cTrQuant.setUseScalingList(false);
     1188    }
     1189
     1190#if NH_3D
     1191    if ( decProcAnnexI() )
     1192    {
     1193      pcSlice->checkInCompPredRefLayers();
     1194    }
     1195#endif
     1196
     1197    //  Decode a picture
     1198    m_cGopDecoder.decompressSlice(&(nalu.getBitstream()), m_pcPic);
     1199
     1200#if NH_3D
     1201    if( m_pcCamParsCollector )
     1202    {
     1203      m_pcCamParsCollector->setSlice( pcSlice );
     1204    }
     1205#endif
     1206
     1207#if !NH_MV
     1208    m_bFirstSliceInPicture = false;
    12651209#else
    1266   if( pcSlice->getIsDepth() && m_pcCamParsCollector )
    1267 #endif
    1268   {
    1269     m_pcCamParsCollector->copyCamParamForSlice( pcSlice );
    1270   }
    1271 #endif
    1272 #endif
    1273   //  Decode a picture
    1274   m_cGopDecoder.decompressSlice(&(nalu.getBitstream()), m_pcPic);
    1275 
    1276 #if NH_3D
    1277   if( m_pcCamParsCollector )
    1278   {
    1279     m_pcCamParsCollector->setSlice( pcSlice );
    1280   }
    1281 #endif
    1282 
    1283   m_bFirstSliceInPicture = false;
     1210  }
     1211#endif
    12841212  m_uiSliceIdx++;
    12851213
     1214#if !NH_MV
    12861215  return false;
    1287 }
     1216#endif
     1217}
     1218
    12881219
    12891220Void TDecTop::xDecodeVPS(const std::vector<UChar> &naluData)
     
    13331264
    13341265#if NH_MV
    1335 Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayerFlag, Bool& sliceSkippedFlag )
     1266Bool TDecTop::decodeNonVclNalu(InputNALUnit& nalu )
    13361267#else
    13371268Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay)
     
    13541285    case NAL_UNIT_VPS:
    13551286      xDecodeVPS(nalu.getBitstream().getFifo());
    1356 #if NH_MV
    1357       m_isLastNALWasEos = false;
    1358 #endif
    13591287      return false;
    13601288
     
    13731301
    13741302    case NAL_UNIT_SUFFIX_SEI:
    1375 #if NH_MV
    1376       if ( nalu.m_nalUnitType == NAL_UNIT_SUFFIX_SEI )
    1377       {
    1378         assert( m_isLastNALWasEos == false );
    1379       }
    1380 #endif
    13811303      if (m_pcPic)
    13821304      {
     
    14101332    case NAL_UNIT_CODED_SLICE_RASL_R:
    14111333#if NH_MV
    1412       if (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_N ||
    1413           nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TSA_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TSA_N ||
    1414           nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_STSA_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_STSA_N ||
    1415           nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N ||
    1416           nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N )
    1417       {
    1418         assert( m_isLastNALWasEos == false );
    1419       }
    1420       else
    1421       {
    1422         m_isLastNALWasEos = false;
    1423       }
    1424       return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay, newLayerFlag, sliceSkippedFlag );
     1334      assert( false );
     1335      return 1;
    14251336#else
    14261337      return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay);
     
    14291340
    14301341    case NAL_UNIT_EOS:
    1431 #if NH_MV
    1432       assert( m_isLastNALWasEos == false );
    1433       //Check layer id of the nalu. if it is not 0, give a warning message and just return without doing anything.
    1434       if (nalu.m_nuhLayerId > 0)
    1435       {
    1436         printf( "\nThis bitstream has EOS with non-zero layer id.\n" );
    1437         return false;
    1438       }
    1439       m_isLastNALWasEos = true;
    1440 #endif
     1342#if !NH_MV
    14411343      m_associatedIRAPType = NAL_UNIT_INVALID;
    14421344      m_pocCRA = 0;
     
    14451347      m_prevSliceSkipped = false;
    14461348      m_skippedPOC = 0;
     1349#endif
    14471350      return false;
    14481351
     
    14651368        fdReader.parseFillerData(&(nalu.getBitstream()),size);
    14661369        printf ("Note: found NAL_UNIT_FILLER_DATA with %u bytes payload.\n", size);
    1467 #if NH_MV
    1468       assert( m_isLastNALWasEos == false );
    1469 #endif
    14701370      return false;
    14711371      }
     
    15281428}
    15291429
     1430#if !NH_MV
    15301431/** Function for checking if picture should be skipped because of association with a previous BLA picture
    15311432 * \param iPOCLastDisplay POC of last picture displayed
     
    15581459 * access point there is no guarantee that the decoder will not crash.
    15591460 */
    1560 #if NH_MV
    1561 Bool TDecTop::isRandomAccessSkipPicture(Int& iSkipFrame,  Int& iPOCLastDisplay, const TComVPS* vps)
    1562 #else
    15631461Bool TDecTop::isRandomAccessSkipPicture(Int& iSkipFrame,  Int& iPOCLastDisplay )
    1564 #endif
    15651462{
    15661463  if (iSkipFrame)
     
    15691466    return true;
    15701467  }
    1571 #if NH_MV
    1572   else if ( !m_layerInitilizedFlag[ m_layerId ] ) // start of random access point, m_pocRandomAccess has not been set yet.
    1573 #else
    15741468  else if (m_pocRandomAccess == MAX_INT) // start of random access point, m_pocRandomAccess has not been set yet.
    1575 #endif
    15761469  {
    15771470    if (   m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA
     
    15811474    {
    15821475
    1583 #if NH_MV
    1584       if ( xAllRefLayersInitilized( vps ) )
    1585       {
    1586         m_layerInitilizedFlag[ m_layerId ] = true;
    1587         m_pocRandomAccess = m_apcSlicePilot->getPOC();
    1588       }
    1589       else
    1590       {
    1591         return true;
    1592       }
    1593 #else
    15941476      // set the POC random access since we need to skip the reordered pictures in the case of CRA/CRANT/BLA/BLANT.
    15951477      m_pocRandomAccess = m_apcSlicePilot->getPOC();
    1596 #endif
    15971478    }
    15981479    else if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP )
    15991480    {
    1600 #if NH_MV
    1601       if ( xAllRefLayersInitilized( vps) )
    1602       {
    1603         m_layerInitilizedFlag[ m_layerId ] = true;
    1604         m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable.
    1605       }
    1606       else
    1607       {
    1608         return true;
    1609       }
    1610 #else
    16111481      m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable.
    1612 #endif
    16131482    }
    16141483    else
    16151484    {
    1616 #if NH_MV
    1617       static Bool warningMessage[MAX_NUM_LAYERS];
    1618       static Bool warningInitFlag = false;
    1619      
    1620       if (!warningInitFlag)
    1621       {
    1622         for ( Int i = 0; i < MAX_NUM_LAYERS; i++)
    1623         {
    1624           warningMessage[i] = true;
    1625         }
    1626         warningInitFlag = true;
    1627       }
    1628 
    1629       if ( warningMessage[getLayerId()] )
    1630       {
    1631         printf("\nLayer%3d   No valid random access point. VCL NAL units of this layer are discarded until next layer initialization picture. ", getLayerId() );
    1632         warningMessage[m_layerId] = false;
    1633       }
    1634 #else
    16351485      if(!m_warningMessageSkipPicture)
    16361486      {
     
    16381488        m_warningMessageSkipPicture = true;
    16391489      }
    1640 #endif
    16411490      return true;
    16421491    }
     
    16491498  }
    16501499  // if we reach here, then the picture is not skipped.
    1651 #if NH_MV
    1652   return !m_layerInitilizedFlag[ getLayerId() ];
     1500  return false;
     1501}
     1502
    16531503#else
    1654   return false;
    1655 #endif
    1656 }
    1657 #if NH_MV
    1658 TComPic* TDecTop::getPic( Int poc )
    1659 {
    1660   xGetPic( m_layerId, poc );
    1661   TComList<TComPic*>* listPic = getListPic();
    1662   TComPic* pcPic = NULL;
    1663   for(TComList<TComPic*>::iterator it=listPic->begin(); it!=listPic->end(); it++)
    1664   {
    1665     if( (*it)->getPOC() == poc )
    1666     {
    1667       pcPic = *it ;
    1668       break ;
    1669     }
    1670   }
    1671   return pcPic;
    1672 }
    1673 
    1674 TComPic* TDecTop::xGetPic( Int layerId, Int poc )
     1504
     1505Int TDecTop::preDecodePoc( Bool firstPicInLayerDecodedFlag, Bool isFstPicOfAllLayOfPocResetPer, Bool isPocResettingPicture )
     1506{
     1507  //Output of this process is PicOrderCntVal, the picture order count of the current picture.
     1508  //  Picture order counts are used to identify pictures, for deriving motion parameters in merge mode and
     1509  //  motion vector prediction and for decoder conformance checking (see clause F.13.5).
     1510
     1511  //  Each coded picture is associated with a picture order count variable, denoted as PicOrderCntVal.
     1512
     1513  TComSlice* slice = m_apcSlicePilot;
     1514  const Int nuhLayerId   = slice->getLayerId();
     1515  const TComVPS*   vps   = slice->getVPS();
     1516  const TComSPS*   sps   = slice->getSPS();
     1517
     1518  Int pocDecrementedInDpbFlag = m_pocDecrementedInDpbFlag[ nuhLayerId ];
     1519
     1520  if ( isFstPicOfAllLayOfPocResetPer )
     1521  {
     1522    //  When the current picture is the first picture among all layers of a POC resetting period,
     1523    //  the variable PocDecrementedInDPBFlag[ i ] is set equal to 0 for each value of i in the range of 0 to 62, inclusive.
     1524    pocDecrementedInDpbFlag = false;
     1525  }
     1526
     1527  //  The variable pocResettingFlag is derived as follows:
     1528  Bool pocResettingFlag;
     1529  if ( isPocResettingPicture )
     1530  {
     1531    //-  If the current picture is a POC resetting picture, the following applies:   
     1532    if( vps->getVpsPocLsbAlignedFlag()  )
     1533    {
     1534      //  -  If vps_poc_lsb_aligned_flag is equal to 0, pocResettingFlag is set equal to 1.
     1535      pocResettingFlag = true;
     1536    }
     1537    else if ( pocDecrementedInDpbFlag )
     1538    {
     1539      //  -  Otherwise, if PocDecrementedInDPBFlag[ nuh_layer_id ] is equal to 1, pocResettingFlag is set equal to 0.
     1540      pocResettingFlag = false;
     1541    }
     1542    else
     1543    {
     1544      //  -  Otherwise, pocResettingFlag is set equal to 1.
     1545      pocResettingFlag = true;
     1546    }
     1547  }
     1548  else
     1549  {
     1550    //  -  Otherwise, pocResettingFlag is set equal to 0.
     1551    pocResettingFlag = false;
     1552  }
     1553
     1554  Int picOrderCntMsb;
     1555  Int picOrderCntVal;
     1556
     1557  //  Depending on pocResettingFlag, the following applies:
     1558  if ( pocResettingFlag )
     1559  {
     1560    //-  The PicOrderCntVal of the current picture is derived as follows:
     1561    if( slice->getPocResetIdc()  ==  1 )
     1562    {
     1563      picOrderCntVal = slice->getSlicePicOrderCntLsb();
     1564    }
     1565    else if (slice->getPocResetIdc()  ==  2 )
     1566    {
     1567      picOrderCntVal = 0;
     1568    }
     1569    else
     1570    {
     1571      picOrderCntMsb = xGetCurrMsb( slice->getSlicePicOrderCntLsb(), slice->getFullPocResetFlag() ? 0 : slice->getPocLsbVal(), 0, sps->getMaxPicOrderCntLsb() );
     1572      picOrderCntVal = picOrderCntMsb + slice->getSlicePicOrderCntLsb();
     1573    }
     1574  }
     1575  else
     1576  {
     1577    //-  Otherwise (pocResettingFlag is equal to 0), the following applies:
     1578    //-  The PicOrderCntVal of the current picture is derived as follows:
     1579
     1580    if( slice->getPocMsbCycleValPresentFlag() )
     1581    {
     1582      picOrderCntMsb = slice->getPocMsbCycleVal() * sps->getMaxPicOrderCntLsb();
     1583    }
     1584    else if( !firstPicInLayerDecodedFlag  ||
     1585      slice->getNalUnitType()  ==  NAL_UNIT_CODED_SLICE_IDR_N_LP || slice->getNalUnitType() ==  NAL_UNIT_CODED_SLICE_IDR_W_RADL )
     1586    {
     1587      picOrderCntMsb = 0; //     (F 62)
     1588    }   
     1589    else
     1590    {
     1591      Int prevPicOrderCntLsb = m_prevPicOrderCnt & ( sps->getMaxPicOrderCntLsb() - 1 );
     1592      Int prevPicOrderCntMsb = m_prevPicOrderCnt - prevPicOrderCntLsb;
     1593      picOrderCntMsb = xGetCurrMsb( slice->getSlicePicOrderCntLsb(), prevPicOrderCntLsb, prevPicOrderCntMsb, sps->getMaxPicOrderCntLsb() );
     1594    }
     1595    picOrderCntVal = picOrderCntMsb + slice->getSlicePicOrderCntLsb();
     1596  } 
     1597  return picOrderCntVal;
     1598}
     1599
     1600Void TDecTop::inferPocResetPeriodId()
     1601{
     1602  // Infer PocResetPeriodId
     1603  // When not present, the value of poc_reset_period_id is inferred as follows:
     1604
     1605  if ( !m_apcSlicePilot->getHasPocResetPeriodIdPresent() )
     1606  {
     1607    if ( m_lastPresentPocResetIdc[ m_apcSlicePilot->getLayerId() ] != MIN_INT )
     1608    {
     1609      // - If the previous picture picA that has poc_reset_period_id present in the slice segment header is present in the same layer
     1610      //   of the bitstream as the current picture, the value of poc_reset_period_id is inferred to be equal to the value of the
     1611      //   poc_reset_period_id of picA.
     1612
     1613      m_apcSlicePilot->setPocResetPeriodId( m_lastPresentPocResetIdc[ m_apcSlicePilot->getLayerId() ] );
     1614    }
     1615    else
     1616    {
     1617      //- Otherwise, the value of poc_reset_period_id is inferred to be equal to 0.
     1618      m_apcSlicePilot->setPocResetPeriodId( 0 );
     1619    }
     1620  }
     1621  else
     1622  {
     1623    m_lastPresentPocResetIdc[ m_apcSlicePilot->getLayerId() ] = m_apcSlicePilot->getPocResetPeriodId(); 
     1624  }
     1625}
     1626
     1627
     1628Void TDecTop::decodePocAndRps( )
    16751629{
    1676   return m_ivPicLists->getPic( layerId, poc ) ;
    1677 }
    1678 
    1679 Void TDecTop::xResetPocInPicBuffer()
    1680 {
    1681   TComList<TComPic*>::iterator  iterPic   = m_cListPic.begin();
    1682   while (iterPic != m_cListPic.end())
    1683   {
    1684     TComPic* pic = *(iterPic++);
    1685     if ( pic->getReconMark() )
    1686     {
    1687       for( Int i = 0; i < pic->getNumAllocatedSlice(); i++)
    1688       {
    1689         TComSlice* slice = pic->getSlice( i );
    1690         slice->setPOC ( slice->getPOC() - m_apcSlicePilot->getPocBeforeReset() );           
    1691       }         
    1692     }     
    1693   }
    1694 }
    1695 
    1696 Void TDecTop::xCeckNoClrasOutput()
    1697 {
    1698   // This part needs further testing!
    1699   if ( getLayerId() == 0 )
     1630  assert( m_uiSliceIdx == 0 );
     1631  Int nuhLayerId = m_pcPic->getLayerId();
     1632  if ( m_decProcPocAndRps == CLAUSE_8 )
     1633  {
     1634    // 8.1.3 Decoding process for a coded picture with nuh_layer_id equal to 0
     1635
     1636    // Variables and functions relating to picture order count are derived as
     1637    // specified in clause 8.3.1. This needs to be invoked only for the first slice
     1638    // segment of a picture.
     1639    x831DecProcForPicOrderCount( );
     1640
     1641    // The decoding process for RPS in clause 8.3.2 is invoked, wherein reference
     1642    // pictures may be marked as "unused for reference" or "used for long-term
     1643    // reference". This needs to be invoked only for the first slice segment of a
     1644    // picture.
     1645    x832DecProcForRefPicSet    (  false );
     1646  }
     1647  else if( m_decProcPocAndRps == ANNEX_F )
     1648  {
     1649    // F.8.1.3 Common decoding process for a coded picture
     1650
     1651    if (nuhLayerId == 0 )
     1652    {
     1653      // F.8.1.4 Decoding process for a coded picture with nuh_layer_id equal to
     1654      // --> Clause 8.1.3 is invoked with replacments of 8.3.1, 8.3.2, and 8.3.3 by F.8.3.1, 8.3.2, and 8.3.3
     1655
     1656      // Variables and functions relating to picture order count are derived as
     1657      // specified in clause 8.3.1. This needs to be invoked only for the first slice
     1658      // segment of a picture.
     1659      xF831DecProcForPicOrderCount( );
     1660
     1661      // The decoding process for RPS in clause 8.3.2 is invoked, wherein reference
     1662      // pictures may be marked as "unused for reference" or "used for long-term
     1663      // reference". This needs to be invoked only for the first slice segment of a
     1664      // picture.
     1665      xF832DecProcForRefPicSet( );
     1666    }
     1667    else
     1668    {
     1669      // F.8.1.5 Decoding process for starting the decoding of a coded picture with
     1670      // nuh_layer_id greater than 0
     1671
     1672      // Variables and functions relating to picture order count are derived in clause F.8.3.1.
     1673      // This needs to be invoked only for the first slice segment of a picture. It is a requirement
     1674      // of bitstream conformance that PicOrderCntVal of each picture in an access unit shall have the
     1675      // same value during and at the end of decoding of the access unit
     1676      xF831DecProcForPicOrderCount( );
     1677
     1678      // The decoding process for RPS in clause F.8.3.2 is invoked, wherein only reference pictures with
     1679      // nuh_layer_id equal to that of CurrPic may be marked as "unused for reference" or "used for
     1680      // long-term reference" and any picture with a different value of nuh_layer_id is not marked.
     1681      // This needs to be invoked only for the first slice segment of a picture.
     1682      xF832DecProcForRefPicSet( );
     1683    }
     1684  }
     1685  else
     1686  {
     1687    assert( false );
     1688  }
     1689}
     1690
     1691Void TDecTop::genUnavailableRefPics( )
     1692{
     1693  assert( m_uiSliceIdx == 0 );
     1694  Int nuhLayerId = m_pcPic->getLayerId();
     1695  if ( m_decProcPocAndRps == CLAUSE_8 )
     1696  {
     1697    // 8.1.3 Decoding process for a coded picture with nuh_layer_id equal to 0
     1698
     1699    if ( m_pcPic->isBla() || ( m_pcPic->isCra() && m_pcPic->getNoRaslOutputFlag() ) )
     1700    {
     1701      // When the current picture is a BLA picture or is a CRA picture
     1702      // with NoRaslOutputFlag equal to 1, the decoding process for generating
     1703      // unavailable reference pictures specified in clause 8.3.3 is invoked,
     1704      // which needs to be invoked only for the first slice segment of a picture.
     1705      x8331GenDecProcForGenUnavilRefPics();       
     1706    }
     1707  }
     1708  else if( m_decProcPocAndRps == ANNEX_F )
     1709  {
     1710    // F.8.1.3 Common decoding process for a coded picture
     1711
     1712    if (nuhLayerId == 0 )
     1713    {
     1714      // F.8.1.4 Decoding process for a coded picture with nuh_layer_id equal to
     1715      // --> Clause 8.1.3 is invoked with replacments of 8.3.1, 8.3.2, and 8.3.3 by F.8.3.1, 8.3.2, and 8.3.3
     1716
     1717      if ( m_pcPic->isBla() || ( m_pcPic->isCra() && m_pcPic->getNoRaslOutputFlag() ) )
     1718      {
     1719        // When the current picture is a BLA picture or is a CRA picture
     1720        // with NoRaslOutputFlag equal to 1, the decoding process for generating
     1721        // unavailable reference pictures specified in clause 8.3.3 is invoked,
     1722        // which needs to be invoked only for the first slice segment of a picture.
     1723        xF833DecProcForGenUnavRefPics();
     1724      }
     1725#if NH_MV_FIX_INIT_NUM_ACTIVE_REF_LAYER_PICS
     1726      TComDecodedRps* decRps = m_pcPic->getDecodedRps();
     1727      decRps->m_numActiveRefLayerPics0 = 0;
     1728      decRps->m_numActiveRefLayerPics1 = 0;     
     1729#endif
     1730    }
     1731    else
     1732    {
     1733      // F.8.1.5 Decoding process for starting the decoding of a coded picture with
     1734      // nuh_layer_id greater than 0
     1735
     1736      if ( !m_firstPicInLayerDecodedFlag[ nuhLayerId ] )
     1737      {
     1738        // When FirstPicInLayerDecodedFlag[ nuh_layer_id ] is equal to 0, the decoding process for generating
     1739        // unavailable reference pictures for pictures first in decoding order within a layer specified in
     1740        // clause F.8.1.7 is invoked, which needs to be invoked only for the first slice segment of a picture.
     1741        xF817DecProcForGenUnavRefPicForPicsFrstInDecOrderInLay();
     1742      }
     1743
     1744      if ( m_firstPicInLayerDecodedFlag[ nuhLayerId ] && ( m_pcPic->isIrap() && m_pcPic->getNoRaslOutputFlag() ) )
     1745      {
     1746        // When FirstPicInLayerDecodedFlag[ nuh_layer_id ] is equal to 1 and the current picture is an IRAP
     1747        // picture with NoRaslOutputFlag equal to 1, the decoding process for generating unavailable reference
     1748        // pictures specified in clause F.8.3.3 is invoked, which needs to be invoked only for the first slice
     1749        // segment of a picture.
     1750        xF833DecProcForGenUnavRefPics();
     1751      }
     1752
     1753      if ( decProcAnnexG() )
     1754      {
     1755        // G.1.2 --> G.1.3
     1756        xG813DecProcForInterLayerRefPicSet();
     1757      }
     1758    }
     1759  }
     1760  else
     1761  {
     1762    assert( false );
     1763  }
     1764
     1765  xCheckUnavailableRefPics();     
     1766}
     1767Void TDecTop::executeLoopFilters( )
     1768{
     1769  assert( m_pcPic != NULL );
     1770  if ( !m_pcPic->getHasGeneratedRefPics() && !m_pcPic->getIsGenerated() )
     1771  {
     1772    m_cGopDecoder.filterPicture( m_pcPic );
     1773  }
     1774  m_cCuDecoder.destroy();
     1775}
     1776
     1777Void TDecTop::finalizePic()
     1778{
     1779  if( m_pcPic->isIrap() )
     1780  {
     1781    m_prevIrapPoc           = m_pcPic->getPOC();
     1782    m_prevIrapDecodingOrder = m_pcPic->getDecodingOrder();
     1783  }
     1784  if( m_pcPic->isStsa() )
     1785  {
     1786    m_prevStsaDecOrder      = m_pcPic->getDecodingOrder();
     1787    m_prevStsaTemporalId    = m_pcPic->getTemporalId()   ;
     1788  }
     1789}
     1790
     1791
     1792Void TDecTop::initFromActiveVps( const TComVPS* vps )
     1793{   
     1794  setViewId   ( vps->getViewId   ( getLayerId() )      ); 
     1795#if NH_3D
     1796  setViewIndex( vps->getViewIndex( getLayerId() )      ); 
     1797  setIsDepth  ( vps->getDepthId  ( getLayerId() ) == 1 ); 
     1798#endif
     1799
     1800  if ( !vps->getVpsExtensionFlag() )
     1801  {
     1802    m_decodingProcess = CLAUSE_8;
     1803    m_isInOwnTargetDecLayerIdList = ( getLayerId() ==  0 );
     1804  }
     1805  else
     1806  { 
     1807    if ( m_targetOlsIdx == -1 )
     1808    {
     1809      // Corresponds to specification by "External Means". (Should be set equal to 0, when no external means available. )
     1810      m_targetOlsIdx = vps->getVpsNumLayerSetsMinus1();
     1811    }
     1812
     1813    Int targetDecLayerSetIdx = vps->olsIdxToLsIdx( m_targetOlsIdx );
     1814
     1815    if ( targetDecLayerSetIdx <= vps->getVpsNumLayerSetsMinus1() && vps->getVpsBaseLayerInternalFlag() )
     1816    {
     1817      m_smallestLayerId = 0;
     1818    }
     1819    else if ( targetDecLayerSetIdx <= vps->getVpsNumLayerSetsMinus1() && !vps->getVpsBaseLayerInternalFlag() )
     1820    {
     1821      m_smallestLayerId = 0;
     1822    }
     1823    else if ( targetDecLayerSetIdx > vps->getVpsNumLayerSetsMinus1() && vps->getNumLayersInIdList( targetDecLayerSetIdx) == 1 )
     1824    {
     1825     
     1826      // m_smallestLayerId = 0;       
     1827      // For now don't do change of layer id here.
     1828      m_smallestLayerId = vps->getTargetDecLayerIdList( targetDecLayerSetIdx )[ 0 ];   
     1829    }
     1830    else
     1831    {
     1832      m_smallestLayerId = vps->getTargetDecLayerIdList( targetDecLayerSetIdx )[ 0 ];   
     1833    }
     1834
     1835
     1836    // Set profile
     1837    Int lsIdx = vps->olsIdxToLsIdx( m_targetOlsIdx );
     1838    Int lIdx = -1;
     1839    for (Int j = 0; j < vps->getNumLayersInIdList( lsIdx ) ; j++ )
     1840    {
     1841      if ( vps->getLayerSetLayerIdList( lsIdx, j ) == getLayerId() )
     1842      {       
     1843        lIdx = j;         
     1844        break;
     1845      }       
     1846    }
     1847    m_isInOwnTargetDecLayerIdList = (lIdx != -1);
     1848
     1849    if ( m_isInOwnTargetDecLayerIdList )
     1850    {
     1851      Int profileIdc = vps->getPTL( vps->getProfileTierLevelIdx( m_targetOlsIdx, lIdx ) )->getGeneralPTL()->getProfileIdc();
     1852      assert( profileIdc == 1 || profileIdc == 6 || profileIdc == 8 );
     1853
     1854      if (  profileIdc == 6 )
     1855      {
     1856        m_decodingProcess = ANNEX_G;
     1857      }
     1858      else if (profileIdc == 7 )
     1859      {
     1860        m_decodingProcess = ANNEX_H;
     1861      }
     1862      else if (profileIdc == 8 )
     1863      {
     1864        m_decodingProcess = ANNEX_I;
     1865      }
     1866    }
     1867  }
     1868}
     1869
     1870
     1871Bool TDecTop::getFirstSliceSegementInPicFlag()
     1872{
     1873  return m_apcSlicePilot->getFirstSliceSegementInPicFlag();
     1874}
     1875
     1876Void TDecTop::x831DecProcForPicOrderCount()
     1877{
     1878  /////////////////////////////////////////////////////
     1879  // 8.3.1 Decoding process for picture order count //
     1880  /////////////////////////////////////////////////////
     1881
     1882  //  Output of this process is PicOrderCntVal, the picture order count of the current picture.
     1883  //  Picture order counts are used to identify pictures, for deriving motion parameters in merge mode and
     1884  //  motion vector prediction, and for decoder conformance checking (see clause C.5).
     1885  //  Each coded picture is associated with a picture order count variable, denoted as PicOrderCntVal.
     1886
     1887  const TComSlice* curSlice = m_pcPic->getSlice(0);
     1888
     1889  Int prevPicOrderCntLsb = MIN_INT;
     1890  Int prevPicOrderCntMsb = MIN_INT; 
     1891  if (!(m_pcPic->isIrap() && m_pcPic->getNoRaslOutputFlag() )  ) 
     1892  {
     1893    //  When the current picture is not an IRAP picture with NoRaslOutputFlag equal to 1,
     1894    //  the variables prevPicOrderCntLsb and prevPicOrderCntMsb are derived as follows:
     1895
     1896    //  -  Let prevTid0Pic be the previous picture in decoding order that has TemporalId equal to 0 and that is not a RASL picture,
     1897    //     a RADL picture or an SLNR picture.
     1898
     1899    //  -  The variable prevPicOrderCntLsb is set equal to slice_pic_order_cnt_lsb of prevTid0Pic.
     1900    prevPicOrderCntLsb = m_prevTid0PicSlicePicOrderCntLsb;
     1901
     1902    //  -  The variable prevPicOrderCntMsb is set equal to PicOrderCntMsb of prevTid0Pic.
     1903    prevPicOrderCntMsb = m_prevTid0PicPicOrderCntMsb;
     1904  }
     1905
     1906  //  The variable PicOrderCntMsb of the current picture is derived as follows: 
     1907 
     1908  Int slicePicOrderCntLsb = curSlice->getSlicePicOrderCntLsb();
     1909
     1910  Int picOrderCntMsb;
     1911
     1912  if (m_pcPic->isIrap() && m_pcPic->getNoRaslOutputFlag()  )
     1913  {
     1914    //-  If the current picture is an IRAP picture with NoRaslOutputFlag equal to 1, PicOrderCntMsb is set equal to 0.
     1915    picOrderCntMsb = 0;
     1916  }
     1917  else
     1918  {
     1919    Int maxPicOrderCntLsb   = curSlice->getSPS()->getMaxPicOrderCntLsb();
     1920
     1921  //  -  Otherwise, PicOrderCntMsb is derived as follows:
     1922
     1923    if( ( slicePicOrderCntLsb < prevPicOrderCntLsb )  &&
     1924      ( ( prevPicOrderCntLsb - slicePicOrderCntLsb )  >=  ( maxPicOrderCntLsb / 2 ) ) )
     1925    {
     1926      picOrderCntMsb = prevPicOrderCntMsb + maxPicOrderCntLsb;   // (8 1)
     1927    }
     1928    else if( (slicePicOrderCntLsb > prevPicOrderCntLsb )  &&
     1929    ( ( slicePicOrderCntLsb - prevPicOrderCntLsb ) > ( maxPicOrderCntLsb / 2 ) ) )
     1930    {
     1931      picOrderCntMsb = prevPicOrderCntMsb - maxPicOrderCntLsb;
     1932    }
     1933    else
     1934    {
     1935      picOrderCntMsb = prevPicOrderCntMsb;
     1936    }
     1937  }
     1938 
     1939  //PicOrderCntVal is derived as follows:
     1940  Int picOrderCntVal = picOrderCntMsb + slicePicOrderCntLsb; //   (8 2)
     1941
     1942  //  NOTE 1 - All IDR pictures will have PicOrderCntVal equal to 0 since slice_pic_order_cnt_lsb is inferred to be 0 for IDR
     1943  //  pictures and prevPicOrderCntLsb and prevPicOrderCntMsb are both set equal to 0.
     1944
     1945  m_pcPic->getSlice(0)->setPOC( picOrderCntVal );
     1946
     1947  // Update prevTid0Pic
     1948  //   Let prevTid0Pic be the previous picture in decoding order that has TemporalId equal to 0 and that is not a RASL picture, a RADL picture or an SLNR picture.
     1949  if( curSlice->getTemporalId() == 0  && !m_pcPic->isRasl() && !m_pcPic->isRadl() && !m_pcPic->isSlnr() )
     1950  {
     1951    m_prevTid0PicSlicePicOrderCntLsb = slicePicOrderCntLsb;     
     1952    m_prevTid0PicPicOrderCntMsb      = picOrderCntMsb; 
     1953  }
     1954}
     1955
     1956Void TDecTop::xF831DecProcForPicOrderCount()
     1957{
     1958  //Output of this process is PicOrderCntVal, the picture order count of the current picture.
     1959  //  Picture order counts are used to identify pictures, for deriving motion parameters in merge mode and
     1960  //  motion vector prediction and for decoder conformance checking (see clause F.13.5).
     1961
     1962  //  Each coded picture is associated with a picture order count variable, denoted as PicOrderCntVal.
     1963
     1964  const TComSlice* slice = m_pcPic->getSlice(0);
     1965  const Int nuhLayerId   = m_pcPic->getLayerId();
     1966  const TComVPS*   vps   = slice->getVPS();
     1967  const TComSPS*   sps   = slice->getSPS();
     1968  if ( m_pcPic->getIsFstPicOfAllLayOfPocResetPer() )
     1969  {
     1970    //  When the current picture is the first picture among all layers of a POC resetting period,
     1971    //  the variable PocDecrementedInDPBFlag[ i ] is set equal to 0 for each value of i in the range of 0 to 62, inclusive.
     1972    for (Int i = 0; i <= 62; i++)
     1973    {
     1974      m_pocDecrementedInDpbFlag[ i ] = 0;
     1975    }
     1976  }
     1977
     1978  //  The variable pocResettingFlag is derived as follows:
     1979  Bool pocResettingFlag;
     1980  if (m_pcPic->getIsPocResettingPic() )
     1981  {
     1982    //-  If the current picture is a POC resetting picture, the following applies:   
     1983    if( vps->getVpsPocLsbAlignedFlag()  )
     1984    {
     1985      //  -  If vps_poc_lsb_aligned_flag is equal to 0, pocResettingFlag is set equal to 1.
     1986      pocResettingFlag = true;
     1987    }
     1988    else if ( m_pocDecrementedInDpbFlag[ nuhLayerId ] )
     1989    {
     1990      //  -  Otherwise, if PocDecrementedInDPBFlag[ nuh_layer_id ] is equal to 1, pocResettingFlag is set equal to 0.
     1991      pocResettingFlag = false;
     1992    }
     1993    else
     1994    {
     1995      //  -  Otherwise, pocResettingFlag is set equal to 1.
     1996      pocResettingFlag = true;
     1997    }
     1998  }
     1999  else
     2000  {
     2001    //  -  Otherwise, pocResettingFlag is set equal to 0.
     2002    pocResettingFlag = false;
     2003  }
     2004
     2005  //  The list affectedLayerList is derived as follows:
     2006  std::vector<Int> affectedLayerList;
     2007  if (! vps->getVpsPocLsbAlignedFlag() )
     2008  {
     2009    //-  If vps_poc_lsb_aligned_flag is equal to 0, affectedLayerList consists of the nuh_layer_id of the current picture.
     2010    affectedLayerList.push_back( nuhLayerId );
     2011  }
     2012  else
     2013  {
     2014    //  -  Otherwise, affectedLayerList consists of the nuh_layer_id of the current picture and the nuh_layer_id values
     2015    //     equal to IdPredictedLayer[ currNuhLayerId ][ j ] for all values of j in the range of 0 to NumPredictedLayers[ currNuhLayerId ] - 1,
     2016    //     inclusive, where currNuhLayerId is the nuh_layer_id value of the current picture.
     2017    affectedLayerList.push_back( nuhLayerId );
     2018    Int currNuhLayerId = nuhLayerId;
     2019    for (Int j = 0; j <= vps->getNumPredictedLayers( currNuhLayerId )-1; j++ )
     2020    {
     2021      affectedLayerList.push_back( vps->getIdPredictedLayer(currNuhLayerId, j ) );
     2022    }
     2023  }
     2024 
     2025  Int picOrderCntMsb;
     2026  Int picOrderCntVal;
     2027
     2028  //  Depending on pocResettingFlag, the following applies:
     2029  if ( pocResettingFlag )
     2030  {
     2031    //-  If pocResettingFlag is equal to 1, the following applies:
     2032    if ( m_firstPicInLayerDecodedFlag[ nuhLayerId ] )
     2033    {
     2034      //-  The variables pocMsbDelta, pocLsbDelta and DeltaPocVal are derived as follows:
     2035      Int pocMsbDelta;
     2036      Int pocLsbDelta;
     2037      Int deltaPocVal;       
     2038
     2039      {
     2040        Int pocLsbVal;
     2041        Int prevPicOrderCntLsb;
     2042        Int prevPicOrderCntMsb;
     2043
     2044        if( slice->getPocResetIdc() ==  3 )
     2045        {
     2046          pocLsbVal = slice->getPocLsbVal();
     2047        }     
     2048        else
     2049        {
     2050          pocLsbVal = slice->getSlicePicOrderCntLsb();
     2051        }
     2052
     2053        if( slice->getPocMsbCycleValPresentFlag() )
     2054        {
     2055          pocMsbDelta = slice->getPocMsbCycleVal() * sps->getMaxPicOrderCntLsb();   // (F 60)
     2056        }     
     2057        else
     2058        {
     2059          prevPicOrderCntLsb = m_prevPicOrderCnt & ( sps->getMaxPicOrderCntLsb() - 1 );
     2060          prevPicOrderCntMsb = m_prevPicOrderCnt - prevPicOrderCntLsb;
     2061
     2062          pocMsbDelta = xGetCurrMsb( pocLsbVal, prevPicOrderCntLsb, prevPicOrderCntMsb, sps->getMaxPicOrderCntLsb() );
     2063        }
     2064
     2065        if( slice->getPocResetIdc() == 2 ||  ( slice->getPocResetIdc() == 3  &&  slice->getFullPocResetFlag() ) )
     2066        {
     2067          pocLsbDelta = pocLsbVal;
     2068        }
     2069        else
     2070        {
     2071          pocLsbDelta = 0;
     2072        }
     2073        deltaPocVal = pocMsbDelta + pocLsbDelta;
     2074      }
     2075
     2076      //-  The PicOrderCntVal of each picture that has nuh_layer_id value nuhLayerId for which PocDecrementedInDPBFlag[ nuhLayerId ] is equal to 0
     2077      //   and that is equal to any value in affectedLayerList is decremented by DeltaPocVal.
     2078      for (Int i = 0; i < (Int) affectedLayerList.size(); i++ )
     2079      {
     2080        if ( !m_pocDecrementedInDpbFlag[ affectedLayerList[i] ] )
     2081        {
     2082          m_dpb->decrementPocsInSubDpb( affectedLayerList[i], deltaPocVal );
     2083        }
     2084      }
     2085
     2086      //-  PocDecrementedInDPBFlag[ nuhLayerId ] is set equal to 1 for each value of nuhLayerId included in affectedLayerList.
     2087      for (Int i = 0; i < (Int) affectedLayerList.size(); i++ )
     2088      {
     2089        m_pocDecrementedInDpbFlag[ affectedLayerList[i] ] = true;
     2090      }
     2091    }
     2092
     2093    //-  The PicOrderCntVal of the current picture is derived as follows:
     2094    if( slice->getPocResetIdc()  ==  1 )
     2095    {
     2096      picOrderCntVal = slice->getSlicePicOrderCntLsb();
     2097    }
     2098    else if (slice->getPocResetIdc()  ==  2 )
     2099    {
     2100      picOrderCntVal = 0;
     2101    }
     2102    else
     2103    {
     2104       picOrderCntMsb = xGetCurrMsb( slice->getSlicePicOrderCntLsb(), slice->getFullPocResetFlag() ? 0 : slice->getPocLsbVal(), 0, sps->getMaxPicOrderCntLsb() );
     2105       picOrderCntVal = picOrderCntMsb + slice->getSlicePicOrderCntLsb();
     2106    }
     2107  }
     2108  else
     2109  {
     2110    //-  Otherwise (pocResettingFlag is equal to 0), the following applies:
     2111    //-  The PicOrderCntVal of the current picture is derived as follows:
     2112   
     2113    if( slice->getPocMsbCycleValPresentFlag() )
     2114    {
     2115      picOrderCntMsb = slice->getPocMsbCycleVal() * sps->getMaxPicOrderCntLsb();
     2116    }
     2117    else if( !m_firstPicInLayerDecodedFlag[ nuhLayerId ]  ||
     2118    slice->getNalUnitType()  ==  NAL_UNIT_CODED_SLICE_IDR_N_LP || slice->getNalUnitType() ==  NAL_UNIT_CODED_SLICE_IDR_W_RADL )
     2119    {
     2120      picOrderCntMsb = 0; //     (F 62)
     2121    }   
     2122    else
     2123    {
     2124        Int prevPicOrderCntLsb = m_prevPicOrderCnt & ( sps->getMaxPicOrderCntLsb() - 1 );
     2125        Int prevPicOrderCntMsb = m_prevPicOrderCnt - prevPicOrderCntLsb;
     2126        picOrderCntMsb = xGetCurrMsb( slice->getSlicePicOrderCntLsb(), prevPicOrderCntLsb, prevPicOrderCntMsb, sps->getMaxPicOrderCntLsb() );
     2127    }
     2128    picOrderCntVal = picOrderCntMsb + slice->getSlicePicOrderCntLsb();
     2129  }
     2130 
     2131  m_pcPic->getSlice(0)->setPOC( picOrderCntVal );
     2132 
     2133  for (Int lId = 0; lId < (Int) affectedLayerList.size(); lId++ )
     2134  { 
     2135    //  The value of PrevPicOrderCnt[ lId ] for each of the lId values included in affectedLayerList is derived as follows:
     2136
     2137    if (!m_pcPic->isRasl() && !m_pcPic->isRadl() && !m_pcPic->isSlnr() && slice->getTemporalId() == 0 && !slice->getDiscardableFlag() )
     2138    {
     2139      //-  If the current picture is not a RASL picture, a RADL picture or a sub-layer non-reference picture, and the current picture
     2140      //   has TemporalId equal to 0 and discardable_flag equal to 0, PrevPicOrderCnt[ lId ] is set equal to PicOrderCntVal.
     2141      m_prevPicOrderCnt = picOrderCntVal;
     2142    }
     2143    else if ( slice->getPocResetIdc() == 3 &&  (
     2144      ( !m_firstPicInLayerDecodedFlag[ nuhLayerId ]) ||
     2145      ( m_firstPicInLayerDecodedFlag[ nuhLayerId ] && m_pcPic->getIsPocResettingPic() )
     2146      ) )
     2147    {
     2148      //  -  Otherwise, when poc_reset_idc is equal to 3 and one of the following conditions is true, PrevPicOrderCnt[ lId ] is set equal to ( full_poc_reset_flag ? 0 : poc_lsb_val ):
     2149      //     -  FirstPicInLayerDecodedFlag[ nuh_layer_id ] is equal to 0.
     2150      //     -  FirstPicInLayerDecodedFlag[ nuh_layer_id ] is equal to 1 and the current picture is a POC resetting picture.
     2151      m_prevPicOrderCnt = ( slice->getFullPocResetFlag() ? 0 : slice->getPocLsbVal() );
     2152    }
     2153  }
     2154}
     2155
     2156Int TDecTop::xGetCurrMsb( Int cl, Int pl, Int pm, Int ml )
     2157{
     2158  Int currMsb;
     2159  if ((pl - cl) >= (ml/ 2))
     2160  {
     2161    currMsb = pm + ml;
     2162  }
     2163  else if ( (cl - pl) > (ml / 2))
     2164  {
     2165    currMsb = pm - ml;
     2166  }
     2167  else
     2168  {
     2169    currMsb = pm;
     2170  }
     2171
     2172  return currMsb; 
     2173}   
     2174
     2175
     2176
     2177Void TDecTop::x832DecProcForRefPicSet(  Bool annexFModifications )
     2178{
     2179  ///////////////////////////////////////////////////////////////////////////////////////
     2180  // 8.3.2 8.3.2 Decoding process for reference picture set
     2181  ///////////////////////////////////////////////////////////////////////////////////////
     2182
     2183  TComSlice* slice = m_pcPic->getSlice( 0 );
     2184  const TComSPS* sps = slice->getSPS();
     2185  //  This process is invoked once per picture, after decoding of a slice header but prior to the decoding of any coding unit and prior
     2186  //  to the decoding process for reference picture list construction for the slice as specified in clause 8.3.3.
     2187  //  This process may result in one or more reference pictures in the DPB being marked as "unused for reference" or
     2188  //  "used for long-term reference".
     2189
     2190  // The variable currPicLayerId is set equal to nuh_layer_id of the current picture.
     2191  Int currPicLayerId = m_pcPic->getLayerId();
     2192  Int picOrderCntVal = m_pcPic->getPOC();
     2193
     2194  if (m_pcPic->isIrap() && m_pcPic->getNoRaslOutputFlag()  )
     2195  {     
     2196    // When the current picture is an IRAP picture with NoRaslOutputFlag equal to 1,
     2197    // all reference pictures with nuh_layer_id equal to currPicLayerId currently in the
     2198    // DPB (if any) are marked as "unused for reference".
     2199    m_dpb->markSubDpbAsUnusedForReference( currPicLayerId );
     2200  }
     2201  // Short-term reference pictures are identified by their PicOrderCntVal values. Long-term reference pictures are identified either by
     2202  // their PicOrderCntVal values or their slice_pic_order_cnt_lsb values.
     2203
     2204  // Five lists of picture order count values are constructed to derive the RPS. These five lists are PocStCurrBefore,
     2205  // PocStCurrAfter, PocStFoll, PocLtCurr and PocLtFoll, with NumPocStCurrBefore, NumPocStCurrAfter, NumPocStFoll,
     2206  // NumPocLtCurr and NumPocLtFoll number of elements, respectively. The five lists and the five variables are derived as follows:
     2207 
     2208  TComDecodedRps* decRps = m_pcPic->getDecodedRps();
     2209
     2210  std::vector<Int>& pocStCurrBefore = decRps->m_pocStCurrBefore;
     2211  std::vector<Int>& pocStCurrAfter  = decRps->m_pocStCurrAfter;
     2212  std::vector<Int>& pocStFoll       = decRps->m_pocStFoll;
     2213  std::vector<Int>& pocLtCurr       = decRps->m_pocLtCurr;
     2214  std::vector<Int>& pocLtFoll       = decRps->m_pocLtFoll;
     2215
     2216  Int& numPocStCurrBefore = decRps->m_numPocStCurrBefore;
     2217  Int& numPocStCurrAfter  = decRps->m_numPocStCurrAfter;
     2218  Int& numPocStFoll       = decRps->m_numPocStFoll;
     2219  Int& numPocLtCurr       = decRps->m_numPocLtCurr;
     2220  Int& numPocLtFoll       = decRps->m_numPocLtFoll;   
     2221
     2222  std::vector<Int> currDeltaPocMsbPresentFlag, follDeltaPocMsbPresentFlag;
     2223
     2224  if (m_pcPic->isIdr() )
     2225  {
     2226    // - If the current picture is an IDR picture, PocStCurrBefore, PocStCurrAfter, PocStFoll,
     2227    //   PocLtCurr and PocLtFoll are all set to be empty, and NumPocStCurrBefore,
     2228    //   NumPocStCurrAfter, NumPocStFoll, NumPocLtCurr and NumPocLtFoll are all set equal to 0.
     2229
     2230    pocStCurrBefore.clear();
     2231    pocStCurrAfter .clear();
     2232    pocStFoll      .clear();
     2233    pocLtCurr      .clear();
     2234    pocLtFoll      .clear();
     2235    numPocStCurrBefore = 0;
     2236    numPocStCurrAfter  = 0;
     2237    numPocStFoll       = 0;
     2238    numPocLtCurr       = 0;
     2239    numPocLtFoll       = 0;
     2240  }
     2241  else
     2242  {
     2243    const TComStRefPicSet* stRps  = slice->getStRps( slice->getCurrRpsIdx() );
     2244    // -  Otherwise, the following applies:
     2245
     2246    Int j = 0;
     2247    Int k = 0;
     2248    for( Int i = 0; i < stRps->getNumNegativePicsVar() ; i++ )
     2249    {
     2250      if( stRps->getUsedByCurrPicS0Var( i  ) )
     2251      {
     2252        pocStCurrBefore.push_back( picOrderCntVal + stRps->getDeltaPocS0Var( i ) ); j++;
     2253      }
     2254      else
     2255      {
     2256        pocStFoll      .push_back( picOrderCntVal + stRps->getDeltaPocS0Var( i ) ); k++;
     2257      }
     2258    }
     2259    numPocStCurrBefore = j;   
     2260
     2261    j = 0;
     2262    for (Int i = 0; i < stRps->getNumPositivePicsVar(); i++ )
     2263    {
     2264      if (stRps->getUsedByCurrPicS1Var( i ) )
     2265      {
     2266        pocStCurrAfter.push_back( picOrderCntVal + stRps->getDeltaPocS1Var( i ) ); j++;
     2267      }
     2268      else
     2269      {
     2270        pocStFoll     .push_back( picOrderCntVal + stRps->getDeltaPocS1Var( i ) ); k++;
     2271      }
     2272    }
     2273    numPocStCurrAfter = j;
     2274    numPocStFoll = k; //    (8 5)
     2275
     2276
     2277    j = 0;
     2278    k = 0;
     2279    for( Int i = 0; i < slice->getNumLongTermSps( ) + slice->getNumLongTermPics(); i++ )
     2280    {
     2281      Int pocLt = slice->getPocLsbLtVar( i );
     2282      if( slice->getDeltaPocMsbPresentFlag( i ) )
     2283      {
     2284        pocLt  +=  picOrderCntVal - slice->getDeltaPocMsbCycleLtVar( i ) * sps->getMaxPicOrderCntLsb() -
     2285          ( picOrderCntVal & ( sps->getMaxPicOrderCntLsb() - 1 ) );
     2286      }
     2287
     2288      if( slice->getUsedByCurrPicLtVar(i))
     2289      {
     2290        pocLtCurr.push_back( pocLt );
     2291        currDeltaPocMsbPresentFlag.push_back( slice->getDeltaPocMsbPresentFlag( i ) ); j++;
     2292      }
     2293      else
     2294      {
     2295        pocLtFoll.push_back( pocLt );
     2296        follDeltaPocMsbPresentFlag.push_back( slice->getDeltaPocMsbPresentFlag( i ) ); k++;
     2297      }
     2298    }
     2299    numPocLtCurr = j;
     2300    numPocLtFoll = k;
     2301  }
     2302
     2303  assert(numPocStCurrAfter  == pocStCurrAfter   .size() );
     2304  assert(numPocStCurrBefore == pocStCurrBefore  .size() );
     2305  assert(numPocStFoll       == pocStFoll        .size() ); 
     2306  assert(numPocLtCurr       == pocLtCurr        .size() ); 
     2307  assert(numPocLtFoll       == pocLtFoll        .size() );
     2308
     2309  // where PicOrderCntVal is the picture order count of the current picture as specified in clause 8.3.1.
     2310
     2311  //   NOTE 2 - A value of CurrRpsIdx in the range of 0 to num_short_term_ref_pic_sets - 1, inclusive,
     2312  //   indicates that a candidate short-term RPS from the active SPS for the current layer is being used,
     2313  //   where CurrRpsIdx is the index of the candidate short-term RPS into the list of candidate short-term RPSs signalled
     2314  //   in the active SPS for the current layer. CurrRpsIdx equal to num_short_term_ref_pic_sets indicates that
     2315  //   the short-term RPS of the current picture is directly signalled in the slice header.
     2316
     2317  for (Int i = 0; i <= numPocLtCurr - 1; i++  )
     2318  {
     2319      // For each i in the range of 0 to NumPocLtCurr - 1, inclusive, when CurrDeltaPocMsbPresentFlag[ i ] is equal to 1,
     2320      // it is a requirement of bitstream conformance that the following conditions apply:
     2321    if ( currDeltaPocMsbPresentFlag[i] )
     2322    {
     2323      // -  There shall be no j in the range of 0 to NumPocStCurrBefore - 1, inclusive,
     2324      //    for which PocLtCurr[ i ] is equal to PocStCurrBefore[ j ].
     2325      for (Int j = 0; j <= numPocStCurrBefore - 1; j++ )
     2326      {
     2327        assert(!( pocLtCurr[ i ] == pocStCurrBefore[ j ] ) );
     2328      }
     2329
     2330      // -  There shall be no j in the range of 0 to NumPocStCurrAfter - 1, inclusive,
     2331      //    for which PocLtCurr[ i ] is equal to PocStCurrAfter[ j ].
     2332      for (Int j = 0; j <= numPocStCurrAfter - 1; j++ )
     2333      {
     2334        assert(!( pocLtCurr[ i ] == pocStCurrAfter[ j ] ) );
     2335      }
     2336
     2337      // -  There shall be no j in the range of 0 to NumPocStFoll - 1, inclusive,
     2338      //    for which PocLtCurr[ i ] is equal to PocStFoll[ j ].
     2339      for (Int j = 0; j <= numPocStFoll - 1; j++ )
     2340      {
     2341        assert(!( pocLtCurr[ i ] == pocStFoll[ j ] ) );
     2342      }
     2343
     2344      // -  There shall be no j in the range of 0 to NumPocLtCurr - 1, inclusive,
     2345      //    where j is not equal to i, for which PocLtCurr[ i ] is equal to PocLtCurr[ j ].
     2346      for (Int j = 0; j <= numPocLtCurr - 1; j++ )
     2347      {
     2348        if ( i != j )
     2349        {       
     2350          assert(!( pocLtCurr[ i ] == pocLtCurr[ j ] ) );
     2351        }
     2352      }
     2353    }
     2354  }
     2355
     2356  for (Int i = 0; i <= numPocLtFoll - 1; i++  )
     2357  {
     2358    // For each i in the range of 0 to NumPocLtFoll - 1, inclusive, when FollDeltaPocMsbPresentFlag[ i ] is equal to 1,
     2359    // it is a requirement of bitstream conformance that the following conditions apply:
     2360    if ( follDeltaPocMsbPresentFlag[i] )
     2361    {
     2362      // -  There shall be no j in the range of 0 to NumPocStCurrBefore - 1, inclusive,
     2363      //    for which PocLtFoll[ i ] is equal to PocStCurrBefore[ j ].
     2364      for (Int j = 0; j <= numPocStCurrBefore - 1; j++ )
     2365      {
     2366        assert(!( pocLtFoll[ i ] == pocStCurrBefore[ j ] ) );
     2367      }
     2368
     2369      // -  There shall be no j in the range of 0 to NumPocStCurrAfter - 1, inclusive,
     2370      //    for which PocLtFoll[ i ] is equal to PocStCurrAfter[ j ].
     2371      for (Int j = 0; j <= numPocStCurrAfter - 1; j++ )
     2372      {
     2373        assert(!( pocLtFoll[ i ] == pocStCurrAfter[ j ] ) );
     2374      }
     2375
     2376      // -  There shall be no j in the range of 0 to NumPocStFoll - 1, inclusive,
     2377      //    for which PocLtFoll[ i ] is equal to PocStFoll[ j ].
     2378      for (Int j = 0; j <= numPocStFoll - 1; j++ )
     2379      {
     2380        assert(!( pocLtFoll[ i ] == pocStFoll[ j ] ) );
     2381      }
     2382
     2383      // -  There shall be no j in the range of 0 to NumPocLtFoll - 1, inclusive,
     2384      //    where j is not equal to i, for which PocLtFoll[ i ] is equal to PocLtFoll[ j ].
     2385      for (Int j = 0; j <= numPocLtFoll - 1; j++ )
     2386      {
     2387        if (j != i)
     2388        {
     2389          assert(!( pocLtFoll[ i ] == pocLtFoll[ j ] ) );
     2390        }
     2391      }
     2392
     2393      // -  There shall be no j in the range of 0 to NumPocLtCurr - 1, inclusive,
     2394      //    for which PocLtFoll[ i ] is equal to PocLtCurr[ j ].
     2395      for (Int j = 0; j <= numPocLtCurr - 1; j++ )
     2396      {
     2397        assert(!( pocLtFoll[ i ] == pocLtCurr[ j ] ) );
     2398      }
     2399    }
     2400  }
     2401
     2402  Int maxPicOrderCntLsb = sps->getMaxPicOrderCntLsb();
     2403  for (Int i = 0; i <= numPocLtCurr - 1; i++  )
     2404  {
     2405    // For each i in the range of 0 to NumPocLtCurr - 1, inclusive, when CurrDeltaPocMsbPresentFlag[ i ] is equal to 0,
     2406    // it is a requirement of bitstream conformance that the following conditions apply:
     2407    if ( currDeltaPocMsbPresentFlag[ i ] == 0  )
     2408    {
     2409      // -  There shall be no j in the range of 0 to NumPocStCurrBefore - 1, inclusive,
     2410      //    for which PocLtCurr[ i ] is equal to ( PocStCurrBefore[ j ] & ( MaxPicOrderCntLsb - 1 ) ).
     2411      for (Int j = 0; j <= numPocStCurrBefore - 1; j++ )
     2412      {
     2413        assert(!( pocLtCurr[ i ] == ( pocStCurrBefore[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) );
     2414      }
     2415
     2416      // -  There shall be no j in the range of 0 to NumPocStCurrAfter - 1, inclusive,
     2417      //    for which PocLtCurr[ i ] is equal to ( PocStCurrAfter[ j ] & ( MaxPicOrderCntLsb - 1 ) ).
     2418      for (Int j = 0; j <= numPocStCurrAfter - 1; j++ )
     2419      {
     2420        assert(!( pocLtCurr[ i ] == ( pocStCurrAfter[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) );
     2421      }
     2422
     2423      // -  There shall be no j in the range of 0 to NumPocStFoll - 1, inclusive,
     2424      //    for which PocLtCurr[ i ] is equal to ( PocStFoll[ j ] & ( MaxPicOrderCntLsb - 1 ) ).
     2425      for (Int j = 0; j <= numPocStFoll - 1; j++ )
     2426      {
     2427        assert(!( pocLtCurr[ i ] == ( pocStFoll[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) );
     2428      }
     2429
     2430      // -  There shall be no j in the range of 0 to NumPocLtCurr - 1, inclusive,
     2431      //    where j is not equal to i, for which PocLtCurr[ i ] is equal to ( PocLtCurr[ j ] & ( MaxPicOrderCntLsb - 1 ) ).
     2432      for (Int j = 0; j <= numPocLtCurr - 1; j++ )
     2433      {
     2434        if (j != i)
     2435        {
     2436          assert(!( pocLtCurr[ i ] == ( pocLtCurr[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) );
     2437        }
     2438      }
     2439    }
     2440  }
     2441
     2442  for (Int i = 0; i <= numPocLtFoll - 1; i++  )
     2443  {
     2444    // For each i in the range of 0 to NumPocLtFoll - 1, inclusive, when FollDeltaPocMsbPresentFlag[ i ] is equal to 0,
     2445    // it is a requirement of bitstream conformance that the following conditions apply:
     2446    if ( follDeltaPocMsbPresentFlag[ i ] == 0  )
     2447    {
     2448      // -  There shall be no j in the range of 0 to NumPocStCurrBefore - 1, inclusive,
     2449      //    for which PocLtFoll[ i ] is equal to ( PocStCurrBefore[ j ] & ( MaxPicOrderCntLsb - 1 ) ).
     2450      for (Int j = 0; j <= numPocStCurrBefore - 1; j++ )
     2451      {
     2452        assert(!( pocLtFoll[ i ] == ( pocStCurrBefore[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) );
     2453      }
     2454
     2455      // -  There shall be no j in the range of 0 to NumPocStCurrAfter - 1, inclusive,
     2456      //    for which PocLtFoll[ i ] is equal to ( PocStCurrAfter[ j ] & ( MaxPicOrderCntLsb - 1 ) ).
     2457      for (Int j = 0; j <= numPocStCurrAfter - 1; j++ )
     2458      {
     2459        assert(!( pocLtFoll[ i ] == ( pocStCurrAfter[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) );
     2460      }
     2461
     2462      // -  There shall be no j in the range of 0 to NumPocStFoll - 1, inclusive,
     2463      //    for which PocLtFoll[ i ] is equal to ( PocStFoll[ j ] & ( MaxPicOrderCntLsb - 1 ) ).
     2464      for (Int j = 0; j <= numPocStFoll - 1; j++ )
     2465      {
     2466        assert(!( pocLtFoll[ i ] == ( pocStFoll[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) );
     2467      }
     2468
     2469      // -  There shall be no j in the range of 0 to NumPocLtFoll - 1, inclusive,
     2470      //    where j is not equal to i, for which PocLtFoll[ i ] is equal to ( PocLtFoll[ j ] & ( MaxPicOrderCntLsb - 1 ) ).
     2471      for (Int j = 0; j <= numPocLtFoll - 1; j++ )
     2472      {
     2473        if (j != i)
     2474        {
     2475          assert(!( pocLtFoll[ i ] == ( pocLtFoll[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) );
     2476        }         
     2477      }
     2478
     2479      // -  There shall be no j in the range of 0 to NumPocLtCurr - 1, inclusive,
     2480      //    for which PocLtFoll[ i ] is equal to ( PocLtCurr[ j ] & ( MaxPicOrderCntLsb - 1 ) ).
     2481      for (Int j = 0; j <= numPocLtCurr - 1; j++ )
     2482      {
     2483        assert(!( pocLtFoll[ i ] == ( pocLtCurr[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) );
     2484      }
     2485    }
     2486  }
     2487
     2488  if ( !annexFModifications )
     2489  { 
     2490    // The variable NumPicTotalCurr is derived as specified in clause 7.4.7.2.
     2491
     2492    // It is a requirement of bitstream conformance that the following applies to the value of NumPicTotalCurr:
     2493    if ( m_pcPic->isBla() || m_pcPic->isCra() )
     2494    {
     2495      // -  If the current picture is a BLA or CRA picture, the value of NumPicTotalCurr shall be equal to 0.
     2496      assert( slice->getNumPicTotalCurr() == 0 );
     2497    }
     2498    else
     2499    {
     2500      // -  Otherwise,
     2501      if ( slice->isInterP() || slice->isInterB() )
     2502      {
     2503        // when the current picture contains a P or B slice, the value of NumPicTotalCurr shall not be equal to 0.
     2504        assert( slice->getNumPicTotalCurr() != 0 );
     2505      }
     2506    }
     2507  }
     2508   
     2509  // The RPS of the current picture consists of five RPS lists; RefPicSetStCurrBefore, RefPicSetStCurrAfter, RefPicSetStFoll,
     2510  // RefPicSetLtCurr and RefPicSetLtFoll. RefPicSetStCurrBefore, RefPicSetStCurrAfter and RefPicSetStFoll are collectively
     2511  // referred to as the short-term RPS. RefPicSetLtCurr and RefPicSetLtFoll are collectively referred to as the long-term RPS.
     2512
     2513  std::vector<TComPic*>& refPicSetStCurrBefore = decRps->m_refPicSetStCurrBefore;
     2514  std::vector<TComPic*>& refPicSetStCurrAfter  = decRps->m_refPicSetStCurrAfter ;
     2515  std::vector<TComPic*>& refPicSetStFoll       = decRps->m_refPicSetStFoll      ;
     2516  std::vector<TComPic*>& refPicSetLtCurr       = decRps->m_refPicSetLtCurr      ;
     2517  std::vector<TComPic*>& refPicSetLtFoll       = decRps->m_refPicSetLtFoll      ;
     2518 
     2519  std::vector<TComPic*>** refPicSetsCurr       = decRps->m_refPicSetsCurr       ;
     2520  std::vector<TComPic*>** refPicSetsLt         = decRps->m_refPicSetsLt         ;
     2521  std::vector<TComPic*>** refPicSetsAll        = decRps->m_refPicSetsAll        ;
     2522  //   NOTE 3 - RefPicSetStCurrBefore, RefPicSetStCurrAfter and RefPicSetLtCurr contain all reference pictures that may be
     2523  //   used for inter prediction of the current picture and one or more pictures that follow the current picture in decoding order.
     2524  //   RefPicSetStFoll and RefPicSetLtFoll consist of all reference pictures that are not used for inter prediction of the current
     2525  //   picture but may be used in inter prediction for one or more pictures that follow the current picture in decoding order.
     2526
     2527  // The derivation process for the RPS and picture marking are performed according to the following ordered steps:
     2528  // 1.  The following applies:
     2529
     2530  TComSubDpb* dpb = m_dpb->getSubDpb( getLayerId(), false );   
     2531  assert( refPicSetLtCurr.empty() );
     2532  for( Int i = 0; i < numPocLtCurr; i++ )
     2533  {
     2534    if( !currDeltaPocMsbPresentFlag[ i ] )
     2535    {   
     2536      refPicSetLtCurr.push_back( dpb->getPicFromLsb( pocLtCurr[ i ], maxPicOrderCntLsb ) );       
     2537    }
     2538    else
     2539    {
     2540      refPicSetLtCurr.push_back(dpb->getPic( pocLtCurr[ i ] ));       
     2541    }   
     2542  }
     2543
     2544  assert( refPicSetLtFoll.empty() );
     2545  for( Int i = 0; i < numPocLtFoll; i++ )
     2546  {
     2547   if( !follDeltaPocMsbPresentFlag[ i ] )
     2548   {
     2549     refPicSetLtFoll.push_back(dpb->getPicFromLsb(pocLtFoll[ i ], maxPicOrderCntLsb ));
     2550   }
     2551   else
     2552   {
     2553     refPicSetLtFoll.push_back(dpb->getPic( pocLtFoll[ i ] ));       
     2554   }
     2555  }
     2556 
     2557  // 2.  All reference pictures that are included in RefPicSetLtCurr or RefPicSetLtFoll and have nuh_layer_id equal
     2558  //     to currPicLayerId are marked as "used for long-term reference".
     2559  for (Int i = 0; i < numPocLtCurr; i++)
     2560  {
     2561    if ( refPicSetLtCurr[i] != NULL )
     2562    {
     2563      refPicSetLtCurr[i]->markAsUsedForLongTermReference();
     2564    }   
     2565  }
     2566
     2567  for (Int i = 0; i < numPocLtFoll; i++)
     2568  {
     2569    if ( refPicSetLtFoll[i] != NULL )
     2570    {
     2571      refPicSetLtFoll[i]->markAsUsedForLongTermReference();
     2572    }   
     2573  }
     2574
     2575  // 3.  The following applies:
     2576  assert( refPicSetStCurrBefore.empty() );
     2577  for( Int i = 0; i < numPocStCurrBefore; i++ )
     2578  {
     2579    refPicSetStCurrBefore.push_back(dpb->getShortTermRefPic( pocStCurrBefore[ i ] ));
     2580  }
     2581
     2582  assert( refPicSetStCurrAfter.empty() );
     2583  for( Int i = 0; i < numPocStCurrAfter; i++ )
     2584  {
     2585    refPicSetStCurrAfter.push_back(dpb->getShortTermRefPic( pocStCurrAfter[ i ] ));
     2586  }
     2587
     2588  assert( refPicSetStFoll.empty() );
     2589  for( Int i = 0; i < numPocStFoll; i++ )
     2590  {
     2591    refPicSetStFoll.push_back(dpb->getShortTermRefPic( pocStFoll[ i ] ));
     2592  }
     2593 
     2594  // 4.  All reference pictures in the DPB that are not included in RefPicSetLtCurr, RefPicSetLtFoll, RefPicSetStCurrBefore,
     2595  //     RefPicSetStCurrAfter, or RefPicSetStFoll and have nuh_layer_id equal to currPicLayerId are marked as "unused for reference".
     2596  TComSubDpb picsToMark = (*dpb);
     2597  for (Int j = 0; j < 5; j++ )
     2598  {
     2599    picsToMark.removePics( *refPicSetsAll[j] );
     2600  } 
     2601  picsToMark.markAllAsUnusedForReference();
     2602 
     2603  //     NOTE 4 - There may be one or more entries in the RPS lists that are equal to "no reference picture" because
     2604  //     the corresponding pictures are not present in the DPB. Entries in RefPicSetStFoll or RefPicSetLtFoll that are equal
     2605  //     to "no reference picture" should be ignored. An unintentional picture loss should be inferred for each entry in
     2606  //     RefPicSetStCurrBefore, RefPicSetStCurrAfter, or RefPicSetLtCurr that is equal to "no reference picture".
     2607
     2608  //     NOTE 5 - A picture cannot be included in more than one of the five RPS lists.
     2609
     2610 
     2611  // It is a requirement of bitstream conformance that the RPS is restricted as follows:
     2612
     2613
     2614#if NH_MV_FIX_NO_REF_PICS_CHECK
     2615  if ( !annexFModifications || m_firstPicInLayerDecodedFlag[ m_pcPic->getLayerId() ] )
     2616  {
     2617#endif
     2618    for (Int j = 0; j < 3; j++ )
     2619    {
     2620      // -  There shall be no entry in RefPicSetStCurrBefore, RefPicSetStCurrAfter or RefPicSetLtCurr
     2621      //    for which one or more of the following are true:
     2622
     2623      std::vector<TComPic*>* currSet = refPicSetsCurr[j];
     2624      for (Int i = 0; i < currSet->size(); i++)
     2625      {
     2626        TComPic* pic = (*currSet)[i];
     2627
     2628        // -  The entry is equal to "no reference picture".
     2629        assert( ! (pic == NULL ) );
     2630
     2631        // -  The entry is an SLNR picture and has TemporalId equal to that of the current picture.
     2632        assert( !( pic->isSlnr() && pic->getTemporalId() == m_pcPic->getTemporalId() ) );
     2633
     2634        // -  The entry is a picture that has TemporalId greater than that of the current picture.
     2635        assert( !(  pic->getTemporalId() > m_pcPic->getTemporalId() ) );
     2636      }     
     2637    }
     2638#if NH_MV_FIX_NO_REF_PICS_CHECK
     2639  }
     2640#endif
     2641 
     2642  //  -  There shall be no entry in RefPicSetLtCurr or RefPicSetLtFoll for which the
     2643  //     difference between the picture order count value of the current picture and the picture order count
     2644  //     value of the entry is greater than or equal to 2^24.
     2645  for (Int j = 0; j < 2; j++ )
    17002646  {   
    1701     NalUnitType nut = m_apcSlicePilot->getNalUnitType();
    1702 
    1703     Bool isBLA =  ( nut == NAL_UNIT_CODED_SLICE_BLA_W_LP  )  || ( nut == NAL_UNIT_CODED_SLICE_BLA_N_LP ) || ( nut == NAL_UNIT_CODED_SLICE_BLA_W_RADL );
    1704     Bool isIDR  = ( nut == NAL_UNIT_CODED_SLICE_IDR_W_RADL ) || ( nut == NAL_UNIT_CODED_SLICE_IDR_N_LP );
    1705     Bool noClrasOutputFlag  = isBLA || ( isIDR  &&  m_apcSlicePilot->getCrossLayerBlaFlag() );
    1706 
    1707     if ( noClrasOutputFlag )
    1708     {
    1709       for (Int i = 0; i < MAX_NUM_LAYER_IDS; i++)
    1710       {
    1711         m_layerInitilizedFlag[i] = false;
    1712       }
    1713     }
    1714   }
    1715 }
    1716 
    1717 Bool TDecTop::xAllRefLayersInitilized( const TComVPS* vps )
    1718 {
    1719   Bool allRefLayersInitilizedFlag = true;   
    1720   for (Int i = 0; i < vps->getNumDirectRefLayers( getLayerId()  ); i++ )
    1721   {
    1722     Int refLayerId = vps->getIdDirectRefLayer( m_layerId, i );
    1723     allRefLayersInitilizedFlag = allRefLayersInitilizedFlag && m_layerInitilizedFlag[ refLayerId ];
    1724   }
    1725 
    1726   return allRefLayersInitilizedFlag;
    1727 }
    1728 
    1729 
    1730 Void TDecTop::initFromActiveVps( const TComVPS* vps )
    1731 {
    1732   if ( m_targetOlsIdx == -1 )
    1733   {
    1734     // Not normative! Corresponds to specification by "External Means". (Should be set equal to 0, when no external means available. )
    1735     m_targetOlsIdx = vps->getVpsNumLayerSetsMinus1();
    1736   }
    1737 #if NH_3D
    1738   // Set profile
    1739   Int lsIdx = vps->olsIdxToLsIdx( m_targetOlsIdx );
    1740   Int lIdx = -1;
    1741   for (Int j = 0; j < vps->getNumLayersInIdList( lsIdx ); j++ )
    1742   {
    1743     if ( vps->getLayerSetLayerIdList( lsIdx, j ) == getLayerId() )
    1744     {
    1745       lIdx = j;
    1746       break;
    1747     }       
    1748   }
    1749   assert( lIdx != -1 );
    1750 
    1751   Int profileIdc = vps->getPTL( vps->getProfileTierLevelIdx( m_targetOlsIdx, lIdx ) )->getGeneralPTL()->getProfileIdc();
    1752   assert( profileIdc == 1 || profileIdc == 6 || profileIdc == 8 );
    1753   m_profileIdc = profileIdc;   
    1754 #endif
    1755 }
     2647    std::vector<TComPic*>* ltSet = refPicSetsLt[j];
     2648    for (Int i = 0; i < ltSet->size(); i++)
     2649    {
     2650      TComPic* pic = (*ltSet)[i];
     2651      if( pic != NULL )
     2652      {
     2653        assert(!( abs( m_pcPic->getPOC() - pic->getPOC() ) >= (1 << 24) ));
     2654      }
     2655    }
     2656  }
     2657
     2658  //   -  When the current picture is a temporal sub-layer access (TSA) picture, there shall be no picture
     2659  //      included in the RPS with TemporalId greater than or equal to the TemporalId of the current picture.
     2660  if (m_pcPic->isTsa() )
     2661  {
     2662    for (Int j = 0; j < 5; j++ )
     2663    {   
     2664      std::vector<TComPic*>* aSet = refPicSetsAll[j];
     2665      for (Int i = 0; i < aSet->size(); i++)
     2666      {
     2667        TComPic* pic = (*aSet)[i];
     2668        if( pic != NULL )
     2669        {
     2670          assert( ! (pic->getTemporalId() >= m_pcPic->getTemporalId() ) );
     2671        }
     2672      }
     2673    }
     2674  }
     2675
     2676  //   -  When the current picture is a step-wise temporal sub-layer access (STSA) picture,
     2677  //      there shall be no picture included in RefPicSetStCurrBefore, RefPicSetStCurrAfter or RefPicSetLtCurr that has
     2678  //      TemporalId equal to that of the current picture.
     2679  if (m_pcPic->isStsa() )
     2680  {
     2681    for (Int j = 0; j < 3; j++ )
     2682    {   
     2683      std::vector<TComPic*>* cSet = refPicSetsCurr[j];
     2684      for (Int i = 0; i < cSet->size(); i++)
     2685      {
     2686        TComPic* pic = (*cSet)[i];
     2687        if( pic != NULL )
     2688        {
     2689          assert( ! (pic->getTemporalId() == m_pcPic->getTemporalId() ) );
     2690        }
     2691      }
     2692    }
     2693  }
     2694
     2695  //   -  When the current picture is a picture that follows, in decoding order, an STSA picture
     2696  //      that has TemporalId equal to that of the current picture, there shall be no picture that has
     2697  //      TemporalId equal to that of the current picture included in RefPicSetStCurrBefore, RefPicSetStCurrAfter
     2698  //      or RefPicSetLtCurr that precedes the STSA picture in decoding order.
     2699  if ( m_pcPic->getDecodingOrder() > m_prevStsaDecOrder && m_pcPic->getTemporalId() == m_prevStsaTemporalId  )
     2700  {
     2701    for (Int j = 0; j < 3; j++ )
     2702    {   
     2703      std::vector<TComPic*>* cSet = refPicSetsCurr[j];
     2704      for (Int i = 0; i < cSet->size(); i++)
     2705      {
     2706        TComPic* pic = (*cSet)[i];
     2707        if( pic != NULL )
     2708        {
     2709          assert( ! (pic->getTemporalId() == m_pcPic->getTemporalId() && pic->getDecodingOrder() < m_prevStsaDecOrder  ) );
     2710        }
     2711      }
     2712    }
     2713  }
     2714 
     2715  //   -  When the current picture is a CRA picture, there shall be no picture included in the RPS that
     2716  //      precedes, in output order or decoding order, any preceding IRAP picture in decoding order (when present).
     2717  if ( m_pcPic->isCra() )
     2718  {
     2719    for (Int j = 0; j < 5; j++ )
     2720    {   
     2721      std::vector<TComPic*>* aSet = refPicSetsAll[j];
     2722      for (Int i = 0; i < aSet->size(); i++)
     2723      {
     2724        // TBD check whether it sufficient to test only the last IRAP
     2725        TComPic* pic = (*aSet)[i];
     2726        if( pic != NULL )
     2727        {       
     2728          assert( ! (pic->getPOC()           < m_prevIrapPoc           ) );           
     2729          assert( ! (pic->getDecodingOrder() < m_prevIrapDecodingOrder ) );
     2730        }
     2731      }
     2732    }
     2733  }
     2734 
     2735  Bool isTrailingPicture = ( !m_pcPic->isIrap() ) && ( m_pcPic->getPOC() > m_prevIrapPoc );
     2736  //   -  When the current picture is a trailing picture, there shall be no picture in RefPicSetStCurrBefore,
     2737  //      RefPicSetStCurrAfter or RefPicSetLtCurr that was generated by the decoding process for generating unavailable
     2738  //      reference pictures as specified in clause 8.3.3.
     2739  if ( isTrailingPicture )
     2740  {
     2741    for (Int j = 0; j < 3; j++ )
     2742    {   
     2743      std::vector<TComPic*>* cSet = refPicSetsCurr[j];
     2744      for (Int i = 0; i < cSet->size(); i++)
     2745      {
     2746        TComPic* pic = (*cSet)[i];
     2747        if( pic != NULL )
     2748        {
     2749          assert( ! (pic->getIsGeneratedCl833() ) );
     2750        }
     2751      }
     2752    }
     2753  }
     2754
     2755  //   -  When the current picture is a trailing picture, there shall be no picture in the RPS that precedes the
     2756  //      associated IRAP picture in output order or decoding order.
     2757  if ( isTrailingPicture )
     2758  {
     2759    for (Int j = 0; j < 5; j++ )
     2760    {   
     2761      std::vector<TComPic*>* aSet = refPicSetsAll[j];
     2762      for (Int i = 0; i < aSet->size(); i++)
     2763      {
     2764        // TBD check whether it sufficient to test only the last IRAP
     2765         TComPic* pic = (*aSet)[i];
     2766        if( pic != NULL )
     2767        {         
     2768          assert( ! (pic->getPOC()           < m_prevIrapPoc           ) );
     2769          assert( ! (pic->getDecodingOrder() < m_prevIrapDecodingOrder ) );
     2770        }
     2771      }
     2772    }
     2773  }
     2774
     2775  //   -  When the current picture is a RADL picture, there shall be no picture included in RefPicSetStCurrBefore,
     2776  //      RefPicSetStCurrAfter or RefPicSetLtCurr that is any of the following:
     2777  if ( m_pcPic->isRadl() )
     2778  {
     2779    for (Int j = 0; j < 3; j++ )
     2780    {   
     2781      std::vector<TComPic*>* cSet = refPicSetsCurr[j];
     2782      for (Int i = 0; i < cSet->size(); i++)
     2783      {       
     2784        TComPic* pic = (*cSet)[i];
     2785        if( pic != NULL )
     2786        {       
     2787          // -  A RASL picture
     2788          assert( ! (pic->isRasl() ) );
     2789          // -  A picture that was generated by the decoding process for generating unavailable reference pictures
     2790          //    as specified in clause 8.3.3
     2791          assert( ! (pic->getIsGeneratedCl833() ) );
     2792          // -  A picture that precedes the associated IRAP picture in decoding order
     2793          assert( ! (pic->getDecodingOrder() < m_prevIrapDecodingOrder ) );
     2794        }
     2795      }
     2796    }
     2797  }
     2798 
     2799 
     2800  if ( sps->getTemporalIdNestingFlag() )
     2801  {
     2802    // -  When sps_temporal_id_nesting_flag is equal to 1, the following applies:
     2803    //    -  Let tIdA be the value of TemporalId of the current picture picA.
     2804    TComPic* picA = m_pcPic;
     2805    Int      tIdA = picA->getTemporalId();
     2806    //   -  Any picture picB with TemporalId equal to tIdB that is less than or equal to tIdA shall not be included in
     2807    //      RefPicSetStCurrBefore, RefPicSetStCurrAfter or RefPicSetLtCurr of picA when there exists a picture picC that
     2808    //      has TemporalId less than tIdB, follows picB in decoding order, and precedes picA in decoding order.
     2809    for (Int j = 0; j < 3; j++ )
     2810    {   
     2811      std::vector<TComPic*>* cSet = refPicSetsCurr[j];
     2812      for (Int i = 0; i < cSet->size(); i++)
     2813      {
     2814        TComPic* picB = (*cSet)[i];
     2815        if( picB != NULL )
     2816        {
     2817          Int tIdB = picB->getTemporalId();
     2818
     2819          if (tIdB <= tIdA)
     2820          {
     2821            for ( TComSubDpb::iterator itP = dpb->begin(); itP != dpb->end(); itP++ )
     2822            {
     2823              TComPic* picC = (*itP);
     2824              assert(! ( picC->getTemporalId() < tIdB && picC->getDecodingOrder() > picB->getDecodingOrder() && picC->getDecodingOrder() < picA->getDecodingOrder()  )  );
     2825            }
     2826          }
     2827        }
     2828      }
     2829    }
     2830  }   
     2831}
     2832
     2833
     2834Void TDecTop::xF832DecProcForRefPicSet()
     2835{
     2836  ///////////////////////////////////////////////////////////////////////////////////////
     2837  // F.8.3.2 Decoding process for reference picture set
     2838  ///////////////////////////////////////////////////////////////////////////////////////
     2839
     2840  // The specifications in clause 8.3.2 apply with the following changes:
     2841  // -  The references to clauses 7.4.7.2, 8.3.1, 8.3.3 and 8.3.4 are replaced with references to
     2842  //    clauses F.7.4.7.2, F.8.3.1, F.8.3.3 and F.8.3.4, respectively.
     2843
     2844  x832DecProcForRefPicSet( true );
     2845
     2846  // -  The following specifications are added:
     2847  if (m_pcPic->isIrap() && m_pcPic->getLayerId() == m_smallestLayerId )
     2848  {
     2849    // -  When the current picture is an IRAP picture with nuh_layer_id equal to SmallestLayerId,
     2850    //    all reference pictures with any value of nuh_layer_id currently in the DPB (if any) are marked
     2851    //    as "unused for reference" when at least one of the following conditions is true:
     2852
     2853    if ( m_pcPic->getNoClrasOutputFlag() || m_pcPic->getActivatesNewVps() )
     2854    {
     2855      // -  The current picture has NoClrasOutputFlag is equal to 1.
     2856      // -  The current picture activates a new VPS.
     2857      m_dpb->markAllSubDpbAsUnusedForReference( );
     2858    }
     2859  }
     2860
     2861  // -  It is a requirement of bitstream conformance that the RPS is restricted as follows:
     2862  // -  When the current picture is a CRA picture, there shall be no picture in RefPicSetStCurrBefore, RefPicSetStCurrAfter
     2863  //    or RefPicSetLtCurr.
     2864
     2865  std::vector<TComPic*>** refPicSetsCurr       = m_pcPic->getDecodedRps()->m_refPicSetsCurr;
     2866
     2867  if ( m_pcPic->isCra() )
     2868  {
     2869    for (Int j = 0; j < 3; j++ )   
     2870    {   
     2871      std::vector<TComPic*>* cSet = refPicSetsCurr[j];
     2872      assert ( cSet->size() == 0 );
     2873    }
     2874  }
     2875
     2876  // -  The constraints specified in clause 8.3.2 on the value of NumPicTotalCurr are replaced with the following:
     2877  //    -  It is a requirement of bitstream conformance that the following applies to the value of NumPicTotalCurr:
     2878  Int numPicTotalCurr = m_pcPic->getSlice(0)->getNumPicTotalCurr();
     2879  Int currPicLayerId  = m_pcPic->getLayerId();
     2880  const TComVPS* vps  = m_pcPic->getSlice(0)->getVPS();
     2881
     2882  if ( ( m_pcPic->isBla() || m_pcPic->isCra() ) && (  (currPicLayerId == 0 ) || ( vps->getNumDirectRefLayers( currPicLayerId ) == 0 ) ) )
     2883  {   
     2884    assert( numPicTotalCurr == 0 );
     2885    // -  If the current picture is a BLA or CRA picture and either currPicLayerId is equal to 0 or
     2886    //     NumDirectRefLayers[ currPicLayerId ] is equal to 0, the value of NumPicTotalCurr shall be equal to 0.
     2887  }
     2888  else
     2889  {
     2890    // TBD: check all slices
     2891    if ( m_pcPic->getSlice(0)->getSliceType() == P_SLICE  ||  m_pcPic->getSlice(0)->getSliceType() == B_SLICE )
     2892    {
     2893      // -  Otherwise, when the current picture contains a P or B slice, the value of NumPicTotalCurr shall not be equal to 0.
     2894      assert( numPicTotalCurr != 0 );
     2895    }
     2896  }
     2897}
     2898
     2899
     2900Void TDecTop::xG813DecProcForInterLayerRefPicSet()
     2901{
     2902  ////////////////////////////////////////////////////////////////////
     2903  // G.8.1.3 Decoding process for inter-layer reference picture set //
     2904  ////////////////////////////////////////////////////////////////////
     2905
     2906  // Outputs of this process are updated lists of inter-layer reference pictures RefPicSetInterLayer0 and RefPicSetInterLayer1
     2907  // and the variables NumActiveRefLayerPics0 and NumActiveRefLayerPics1.
     2908
     2909  TComDecodedRps* decRps = m_pcPic->getDecodedRps();
     2910  TComSlice* slice       = m_pcPic->getSlice( 0 );
     2911  const TComVPS* vps     =  slice->getVPS();
     2912
     2913  Int&                   numActiveRefLayerPics0 = decRps->m_numActiveRefLayerPics0;
     2914  Int&                   numActiveRefLayerPics1 = decRps->m_numActiveRefLayerPics1;
     2915
     2916  std::vector<TComPic*>& refPicSetInterLayer0   = decRps->m_refPicSetInterLayer0;
     2917  std::vector<TComPic*>& refPicSetInterLayer1   = decRps->m_refPicSetInterLayer1;
     2918
     2919  // The variable currLayerId is set equal to nuh_layer_id of the current picture.
     2920  Int currLayerId = getLayerId();
     2921
     2922  // The lists RefPicSetInterLayer0 and RefPicSetInterLayer1 are first emptied, NumActiveRefLayerPics0 and NumActiveRefLayerPics1
     2923  // are set equal to 0 and the following applies:
     2924
     2925  refPicSetInterLayer0.clear();
     2926  refPicSetInterLayer1.clear();
     2927
     2928  numActiveRefLayerPics0 = 0;
     2929  numActiveRefLayerPics1 = 0;
     2930
     2931  Int viewIdCurrLayerId  = vps->getViewId( currLayerId );
     2932  Int viewId0            = vps->getViewId( 0   );
     2933
     2934  for( Int i = 0; i < slice->getNumActiveRefLayerPics(); i++ )   
     2935  {
     2936    Int viewIdRefPicLayerIdi = vps->getViewId( slice->getRefPicLayerId( i ) );
     2937
     2938    Bool refPicSet0Flag =
     2939      ( ( viewIdCurrLayerId <=  viewId0  &&  viewIdCurrLayerId <=  viewIdRefPicLayerIdi )  ||
     2940      ( viewIdCurrLayerId >=  viewId0  &&  viewIdCurrLayerId >=  viewIdRefPicLayerIdi ) );
     2941
     2942    TComPic* picX = m_dpb->getAu(slice->getPOC(), false )->getPic( slice->getRefPicLayerId( i ) );
     2943    if ( picX != NULL )
     2944    {
     2945      // there is a picture picX in the DPB that is in the same access unit as the current picture and has
     2946      // nuh_layer_id equal to RefPicLayerId[ i ]
     2947
     2948      if ( refPicSet0Flag )
     2949      {
     2950        refPicSetInterLayer0.push_back( picX );
     2951        refPicSetInterLayer0[ numActiveRefLayerPics0++ ]->markAsUsedForLongTermReference();
     2952      }
     2953      else
     2954      {
     2955        refPicSetInterLayer1.push_back( picX );
     2956        refPicSetInterLayer1[ numActiveRefLayerPics1++ ]->markAsUsedForLongTermReference();
     2957      }
     2958
     2959      // There shall be no picture that has discardable_flag equal to 1 in RefPicSetInterLayer0 or RefPicSetInterLayer1.
     2960      assert( ! picX->getSlice(0)->getDiscardableFlag() );
     2961
     2962      // If the current picture is a RADL picture, there shall be no entry in RefPicSetInterLayer0 or RefPicSetInterLayer1
     2963      // that is a RASL picture.
     2964      if ( m_pcPic->isRadl() )
     2965      {
     2966        assert( ! picX->isRasl() );
     2967      }
     2968    }
     2969    else
     2970    {
     2971      if( refPicSet0Flag )
     2972      {
     2973        refPicSetInterLayer0.push_back( NULL ); // "no reference picture" (G 1)
     2974        numActiveRefLayerPics0++;
     2975      }
     2976      else
     2977      {
     2978        refPicSetInterLayer1.push_back( NULL ); // "no reference picture";
     2979        numActiveRefLayerPics1++;
     2980      }
     2981      // There shall be no entry equal to "no reference picture" in RefPicSetInterLayer0 or RefPicSetInterLayer1.
     2982      assert( false );
     2983    }
     2984  }
     2985}
     2986
     2987
     2988Void TDecTop::x8331GenDecProcForGenUnavilRefPics()
     2989{
     2990  ///////////////////////////////////////////////////////////////////////////////////////
     2991  // 8.3.3.1  General decoding process for generating unavailable reference pictures ////
     2992  ///////////////////////////////////////////////////////////////////////////////////////
     2993
     2994  // This process is invoked once per coded picture when the current picture is a
     2995  // BLA picture or is a CRA picture with NoRaslOutputFlag equal to 1.
     2996
     2997  assert( m_pcPic->isBla() || (m_pcPic->isCra() && m_pcPic->getNoRaslOutputFlag() ) );
     2998  TComDecodedRps* decRps = m_pcPic->getDecodedRps();
     2999
     3000  std::vector<TComPic*>& refPicSetStFoll      = decRps->m_refPicSetStFoll;
     3001  std::vector<TComPic*>& refPicSetLtFoll      = decRps->m_refPicSetLtFoll;
     3002
     3003  const std::vector<Int>& pocStFoll             = decRps->m_pocStFoll;
     3004  const std::vector<Int>& pocLtFoll             = decRps->m_pocLtFoll;
     3005
     3006  const Int               numPocStFoll          = decRps->m_numPocStFoll;
     3007  const Int               numPocLtFoll          = decRps->m_numPocLtFoll;   
     3008
     3009  // When this process is invoked, the following applies:
     3010  for ( Int i = 0 ; i <= numPocStFoll - 1; i++ )
     3011  {
     3012    if ( refPicSetStFoll[ i ] == NULL )
     3013    {
     3014      //-  For each RefPicSetStFoll[ i ], with i in the range of 0 to NumPocStFoll - 1, inclusive, that is equal
     3015      //   to "no reference picture", a picture is generated as specified in clause 8.3.3.2, and the following applies:
     3016      TComPic* genPic = x8332GenOfOneUnavailPic( true ); 
     3017
     3018      // -  The value of PicOrderCntVal for the generated picture is set equal to PocStFoll[ i ].
     3019      genPic->getSlice(0)->setPOC( pocStFoll[ i ] );
     3020
     3021      //-  The value of PicOutputFlag for the generated picture is set equal to 0. 
     3022      genPic->setPicOutputFlag( false );
     3023
     3024      // -  The generated picture is marked as "used for short-term reference".
     3025      genPic->markAsUsedForShortTermReference();
     3026
     3027      // -  RefPicSetStFoll[ i ] is set to be the generated reference picture.
     3028      refPicSetStFoll[ i ] = genPic;
     3029
     3030      // -  The value of nuh_layer_id for the generated picture is set equal to nuh_layer_id of the current picture.
     3031      genPic->setLayerId( m_pcPic-> getLayerId() );
     3032
     3033      // Insert to DPB
     3034      m_dpb->addNewPic( genPic );
     3035    }
     3036  }
     3037
     3038  for ( Int i = 0 ; i <= numPocLtFoll - 1; i++ )
     3039  {
     3040    if ( refPicSetLtFoll[ i ] == NULL )
     3041    {
     3042      //-  For each RefPicSetLtFoll[ i ], with i in the range of 0 to NumPocLtFoll - 1, inclusive, that is equal to
     3043      //   "no reference picture", a picture is generated as specified in clause 8.3.3.2, and the following applies:
     3044      TComPic* genPic = x8332GenOfOneUnavailPic( true ); 
     3045
     3046      //-  The value of PicOrderCntVal for the generated picture is set equal to PocLtFoll[ i ].
     3047      genPic->getSlice(0)->setPOC( pocStFoll[ i ] );
     3048
     3049      //  -  The value of slice_pic_order_cnt_lsb for the generated picture is inferred to be equal to ( PocLtFoll[ i ] & ( MaxPicOrderCntLsb - 1 ) ).
     3050      genPic->getSlice(0)->setSlicePicOrderCntLsb( ( pocLtFoll[ i ] & ( m_pcPic->getSlice(0)->getSPS()->getMaxPicOrderCntLsb() - 1 ) ) );
     3051
     3052      //  -  The value of PicOutputFlag for the generated picture is set equal to 0.   
     3053      genPic->setPicOutputFlag( false );
     3054
     3055      //  -  The generated picture is marked as "used for long-term reference".
     3056      genPic->markAsUsedForLongTermReference();
     3057
     3058      //  -  RefPicSetLtFoll[ i ] is set to be the generated reference picture.
     3059      refPicSetLtFoll[ i ] = genPic;
     3060
     3061      //  -  The value of nuh_layer_id for the generated picture is set equal to nuh_layer_id of the current picture.
     3062      genPic->setLayerId( m_pcPic-> getLayerId() );
     3063
     3064      // Insert to DPB
     3065      m_dpb->addNewPic( genPic );
     3066    }
     3067  }
     3068}
     3069
     3070
     3071TComPic* TDecTop::x8332GenOfOneUnavailPic( Bool calledFromCl8331 )
     3072{
     3073  ///////////////////////////////////////////////////////////////////////////////////////
     3074  // 8.3.3.2 Generation of one unavailable picture
     3075  ///////////////////////////////////////////////////////////////////////////////////////
     3076
     3077  TComPic* genPic = new TComPic;
     3078  genPic->create( *m_pcPic->getSlice(0)->getSPS(), *m_pcPic->getSlice(0)->getPPS(), true );
     3079  genPic->setIsGenerated( true );     
     3080  genPic->setIsGeneratedCl833( calledFromCl8331 );
     3081  return genPic;
     3082}
     3083
     3084
     3085Void TDecTop::xF817DecProcForGenUnavRefPicForPicsFrstInDecOrderInLay()
     3086{
     3087  ///////////////////////////////////////////////////////////////////////////////////////
     3088  // F.8.1.7 Decoding process for generating unavailable reference pictures for pictures
     3089  //         first in decoding order within a layer
     3090  ///////////////////////////////////////////////////////////////////////////////////////
     3091
     3092  //  This process is invoked for a picture with nuh_layer_id equal to layerId, when FirstPicInLayerDecodedFlag[layerId ] is equal to 0.   
     3093  assert( !m_firstPicInLayerDecodedFlag[ getLayerId() ] );
     3094
     3095
     3096  TComDecodedRps* decRps = m_pcPic->getDecodedRps();
     3097
     3098  std::vector<TComPic*>& refPicSetStCurrBefore = decRps->m_refPicSetStCurrBefore;
     3099  std::vector<TComPic*>& refPicSetStCurrAfter  = decRps->m_refPicSetStCurrAfter;
     3100  std::vector<TComPic*>& refPicSetStFoll       = decRps->m_refPicSetStFoll;
     3101  std::vector<TComPic*>& refPicSetLtCurr       = decRps->m_refPicSetLtCurr;
     3102  std::vector<TComPic*>& refPicSetLtFoll       = decRps->m_refPicSetLtFoll;
     3103
     3104
     3105  const std::vector<Int>& pocStCurrBefore      = decRps->m_pocStCurrBefore;
     3106  const std::vector<Int>& pocStCurrAfter       = decRps->m_pocStCurrAfter;
     3107  const std::vector<Int>& pocStFoll            = decRps->m_pocStFoll;
     3108  const std::vector<Int>& pocLtCurr            = decRps->m_pocLtCurr;
     3109  const std::vector<Int>& pocLtFoll            = decRps->m_pocLtFoll;
     3110
     3111  const Int numPocStCurrBefore                 = decRps->m_numPocStCurrBefore;
     3112  const Int numPocStCurrAfter                  = decRps->m_numPocStCurrAfter;
     3113  const Int numPocStFoll                       = decRps->m_numPocStFoll;
     3114  const Int numPocLtCurr                       = decRps->m_numPocLtCurr;
     3115  const Int numPocLtFoll                       = decRps->m_numPocLtFoll;   
     3116
     3117  Int nuhLayerId = m_pcPic-> getLayerId();
     3118  for ( Int i = 0 ; i <= numPocStCurrBefore - 1; i++ )
     3119  {
     3120    if ( refPicSetStCurrBefore[ i ] == NULL )
     3121    {
     3122      //-  For each RefPicSetStCurrBefore[ i ], with i in the range of 0 to NumPocStCurrBefore - 1, inclusive, that is
     3123      //  equal to "no reference picture", a picture is generated as specified in clause 8.3.3.2 and the following applies:
     3124      TComPic* genPic = x8332GenOfOneUnavailPic( false ); 
     3125
     3126      //-  The value of PicOrderCntVal for the generated picture is set equal to PocStCurrBefore[ i ].
     3127      genPic->getSlice(0)->setPOC( pocStCurrBefore[ i ] );
     3128
     3129      //  -  The value of PicOutputFlag for the generated picture is set equal to 0.
     3130      genPic->setPicOutputFlag( false );
     3131
     3132      //  -  The generated picture is marked as "used for short-term reference".
     3133      genPic->markAsUsedForShortTermReference();
     3134
     3135      //  -  RefPicSetStCurrBefore[ i ] is set to be the generated reference picture.
     3136      refPicSetStCurrBefore[ i ] = genPic;
     3137
     3138      //  -  The value of nuh_layer_id for the generated picture is set equal to nuh_layer_id.
     3139      genPic->setLayerId( nuhLayerId );
     3140
     3141      // Insert to DPB
     3142      m_dpb->addNewPic( genPic );
     3143    }
     3144  }
     3145
     3146  for ( Int i = 0 ; i <= numPocStCurrAfter - 1; i++ )
     3147  {
     3148    if ( refPicSetStCurrAfter[ i ] == NULL )
     3149    {
     3150      //  -  For each RefPicSetStCurrAfter[ i ], with i in the range of 0 to NumPocStCurrAfter - 1, inclusive, that is equal
     3151      //     to "no reference picture", a picture is generated as specified in clause 8.3.3.2 and the following applies:
     3152      TComPic* genPic = x8332GenOfOneUnavailPic( false ); 
     3153
     3154      //  -  The value of PicOrderCntVal for the generated picture is set equal to PocStCurrAfter[ i ].
     3155      genPic->getSlice(0)->setPOC( pocStCurrAfter[ i ] );
     3156
     3157      //  -  The value of PicOutputFlag for the generated picture is set equal to 0.
     3158      genPic->setPicOutputFlag( false );
     3159
     3160      //  -  The generated picture is marked as "used for short-term reference".
     3161      genPic->markAsUsedForShortTermReference();
     3162
     3163      //  -  RefPicSetStCurrAfter[ i ] is set to be the generated reference picture.
     3164      refPicSetStCurrAfter[ i ] = genPic;
     3165
     3166      //  -  The value of nuh_layer_id for the generated picture is set equal to nuh_layer_id.
     3167      genPic->setLayerId( nuhLayerId );
     3168
     3169      // Insert to DPB
     3170      m_dpb->addNewPic( genPic );
     3171
     3172    }
     3173  }
     3174
     3175  for ( Int i = 0 ; i <= numPocStFoll - 1; i++ )
     3176  {
     3177    if ( refPicSetStFoll[ i ] == NULL )
     3178    {
     3179      //  -  For each RefPicSetStFoll[ i ], with i in the range of 0 to NumPocStFoll - 1, inclusive, that is equal to "no
     3180      //     reference picture", a picture is generated as specified in clause 8.3.3.2 and the following applies:
     3181      TComPic* genPic = x8332GenOfOneUnavailPic( false ); 
     3182
     3183      //  -  The value of PicOrderCntVal for the generated picture is set equal to PocStFoll[ i ].
     3184      genPic->getSlice(0)->setPOC( pocStFoll[ i ] );
     3185
     3186      //  -  The value of PicOutputFlag for the generated picture is set equal to 0.
     3187      genPic->setPicOutputFlag( false );
     3188
     3189      //  -  The generated picture is marked as "used for short-term reference".
     3190      genPic->markAsUsedForShortTermReference();
     3191
     3192      //  -  RefPicSetStFoll[ i ] is set to be the generated reference picture.
     3193      refPicSetStFoll[ i ] = genPic;
     3194
     3195      //  -  The value of nuh_layer_id for the generated picture is set equal to nuh_layer_id.
     3196      genPic->setLayerId( nuhLayerId );
     3197
     3198      // Insert to DPB
     3199      m_dpb->addNewPic( genPic );
     3200    }
     3201  }
     3202
     3203  Int maxPicOrderCntLsb = m_pcPic->getSlice(0)->getSPS()->getMaxPicOrderCntLsb(); 
     3204  for ( Int i = 0 ; i <= numPocLtCurr - 1; i++ )
     3205  {
     3206    if ( refPicSetLtCurr[ i ] == NULL )
     3207    {
     3208      //  -  For each RefPicSetLtCurr[ i ], with i in the range of 0 to NumPocLtCurr - 1, inclusive, that is equal to "no
     3209      //     reference picture", a picture is generated as specified in clause 8.3.3.2 and the following applies:
     3210      TComPic* genPic = x8332GenOfOneUnavailPic( false ); 
     3211
     3212      //  -  The value of PicOrderCntVal for the generated picture is set equal to PocLtCurr[ i ].
     3213      genPic->getSlice(0)->setPOC( pocLtCurr[ i ] );
     3214
     3215      //  -  The value of slice_pic_order_cnt_lsb for the generated picture is inferred to be equal to ( PocLtCurr[ i ] & (
     3216      //     MaxPicOrderCntLsb - 1 ) ).
     3217      genPic->getSlice(0)->setSlicePicOrderCntLsb( ( pocLtCurr[ i ] & ( maxPicOrderCntLsb - 1 ) ) );
     3218
     3219      //  -  The value of PicOutputFlag for the generated picture is set equal to 0.
     3220      genPic->setPicOutputFlag( false );
     3221
     3222      //  -  The generated picture is marked as "used for long-term reference".
     3223      genPic->markAsUsedForLongTermReference();
     3224
     3225      //  -  RefPicSetLtCurr[ i ] is set to be the generated reference picture.
     3226      refPicSetLtCurr[ i ] = genPic;
     3227
     3228      //  -  The value of nuh_layer_id for the generated picture is set equal to nuh_layer_id.
     3229      genPic->setLayerId( nuhLayerId );
     3230
     3231      // Insert to DPB
     3232      m_dpb->addNewPic( genPic );
     3233    }
     3234  }
     3235
     3236  for ( Int i = 0 ; i <= numPocLtFoll - 1; i++ )
     3237  {
     3238    if ( refPicSetLtFoll[ i ] == NULL )
     3239    {
     3240      //  -  For each RefPicSetLtFoll[ i ], with i in the range of 0 to NumPocLtFoll - 1, inclusive, that is equal to "no
     3241      //     reference picture", a picture is generated as specified in clause 8.3.3.2 and the following applies:
     3242      TComPic* genPic = x8332GenOfOneUnavailPic( false ); 
     3243
     3244      //  -  The value of PicOrderCntVal for the generated picture is set equal to PocLtFoll[ i ].
     3245      genPic->getSlice(0)->setPOC( pocLtFoll[ i ] );
     3246
     3247      //  -  The value of slice_pic_order_cnt_lsb for the generated picture is inferred to be equal to ( PocLtCurr[ i ] & (
     3248      //     MaxPicOrderCntLsb - 1 ) ).
     3249      genPic->getSlice(0)->setSlicePicOrderCntLsb( ( pocLtCurr[ i ] & ( maxPicOrderCntLsb - 1 ) ) );
     3250
     3251      //  -  The value of PicOutputFlag for the generated picture is set equal to 0.
     3252      genPic->setPicOutputFlag( false );
     3253
     3254      //  -  The generated picture is marked as "used for long-term reference".
     3255      genPic->markAsUsedForLongTermReference();
     3256
     3257      //  -  RefPicSetLtFoll[ i ] is set to be the generated reference picture.
     3258      refPicSetLtFoll[ i ] = genPic;
     3259
     3260      //  -  The value of nuh_layer_id for the generated picture is set equal to nuh_layer_id.
     3261      genPic->setLayerId( nuhLayerId );
     3262
     3263      // Insert to DPB
     3264      m_dpb->addNewPic( genPic );
     3265    }
     3266  }
     3267}
     3268
     3269Void TDecTop::xF833DecProcForGenUnavRefPics()
     3270{
     3271  ///////////////////////////////////////////////////////////////////////////////////////
     3272  // F.8.3.3 Decoding process for generating unavailable reference picture
     3273  ///////////////////////////////////////////////////////////////////////////////////////
     3274
     3275  x8331GenDecProcForGenUnavilRefPics();
     3276}
     3277
     3278Void TDecTop::xCheckUnavailableRefPics()
     3279{
     3280  std::vector<TComPic*>** refPicSetsCurr       = m_pcPic->getDecodedRps()->m_refPicSetsCurr;
     3281
     3282  Bool hasGeneratedRefPic = false;
     3283  for (Int j = 0; j < 3; j++ )   
     3284  {   
     3285    std::vector<TComPic*>* cSet = refPicSetsCurr[j];
     3286    for (Int i = 0 ; i < cSet->size();  i++ )
     3287    {
     3288      assert( (*cSet)[i] != NULL );
     3289      if ((*cSet)[i]->getIsGenerated() )
     3290      {
     3291        hasGeneratedRefPic = true;
     3292      }
     3293    }
     3294  }
     3295  m_pcPic->setHasGeneratedRefPics( hasGeneratedRefPic );
     3296}
     3297
    17563298#endif
    17573299
  • branches/HTM-15.0-dev0/source/Lib/TLibDecoder/TDecTop.h

    r1313 r1317  
    8181  Int**** getBaseViewShiftLUTI()  { return m_aiBaseViewShiftLUT;   }
    8282
    83 #if !NH_3D_FIX_TICKET_101
    84 #if NH_3D_IV_MERGE
    85   Void  copyCamParamForSlice( TComSlice* pcSlice );
    86 #endif
    87 #endif
    88 
    8983private:
    9084  Void xResetReceivedIdc( Bool overWriteFlag );
     
    182176{
    183177private:
    184   Int                     m_iMaxRefPicNum;
    185 
    186   NalUnitType             m_associatedIRAPType; ///< NAL unit type of the associated IRAP picture
    187   Int                     m_pocCRA;            ///< POC number of the latest CRA picture
    188   Int                     m_pocRandomAccess;   ///< POC number of the random access point (the first IDR or CRA picture)
    189 
    190   TComList<TComPic*>      m_cListPic;         //  Dynamic buffer
    191 #if NH_MV
    192   Bool*                    m_layerInitilizedFlag; // initialization Layers
    193   static ParameterSetManager m_parameterSetManager;  // storage for parameter sets
    194   Int                      m_targetOlsIdx;
    195 #else
    196   ParameterSetManager     m_parameterSetManager;  // storage for parameter sets
    197 #endif
     178  Int                         m_iMaxRefPicNum;
     179                             
     180  NalUnitType                 m_associatedIRAPType; ///< NAL unit type of the associated IRAP picture
     181#if !NH_MV
     182  Int                         m_pocCRA;            ///< POC number of the latest CRA picture
     183  Int                         m_pocRandomAccess;   ///< POC number of the random access point (the first IDR or CRA picture)
     184 
     185  TComList<TComPic*>           m_cListPic;         //  Dynamic buffer
     186  ParameterSetManager          m_parameterSetManager;  // storage for parameter sets
     187#endif
     188
    198189  TComSlice*              m_apcSlicePilot;
    199190
     
    215206
    216207  Bool isSkipPictureForBLA(Int& iPOCLastDisplay);
    217 #if NH_MV
    218   Bool isRandomAccessSkipPicture(Int& iSkipFrame,  Int& iPOCLastDisplay, const TComVPS* vps);
    219 #else
     208#if !NH_MV
    220209  Bool isRandomAccessSkipPicture(Int& iSkipFrame,  Int& iPOCLastDisplay);
    221210#endif
     211
    222212  TComPic*                m_pcPic;
    223213  UInt                    m_uiSliceIdx;
     214#if !NH_MV
    224215  Int                     m_prevPOC;
    225216  Int                     m_prevTid0POC;
    226   Bool                    m_bFirstSliceInPicture;
     217  Bool                    m_bFirstSliceInPicture; 
    227218  Bool                    m_bFirstSliceInSequence;
    228219  Bool                    m_prevSliceSkipped;
     
    232223  Bool                    m_isNoOutputPriorPics;
    233224  Bool                    m_craNoRaslOutputFlag;    //value of variable NoRaslOutputFlag of the last CRA pic
     225#endif
     226 
    234227#if O0043_BEST_EFFORT_DECODING
    235228  UInt                    m_forceDecodeBitDepth;
    236229#endif
     230
     231
    237232  std::ostream           *m_pDecodedSEIOutputStream;
    238233
     234#if !NH_MV
    239235  Bool                    m_warningMessageSkipPicture;
     236#endif
     237
    240238#if NH_MV
    241   Bool                    m_isLastNALWasEos;
    242 #endif
    243 
    244 #if NH_MV
    245   // For NH_MV m_bFirstSliceInSequence indicates first slice in sequence of the particular layer 
     239  // Class interface
     240  static ParameterSetManager  m_parameterSetManager;  // storage for parameter sets
     241  TComPicLists*           m_dpb;
     242#if NH_3D
     243  CamParsCollector*       m_pcCamParsCollector;
     244#endif
     245
     246  // Layer identification
    246247  Int                     m_layerId;
    247248  Int                     m_viewId;
    248   TComPicLists*           m_ivPicLists;
    249   std::vector<TComPic*>   m_refPicSetInterLayer0;
    250   std::vector<TComPic*>   m_refPicSetInterLayer1;
    251 #if NH_3D
     249#if NH_3D                 
    252250  Int                     m_viewIndex;
    253251  Bool                    m_isDepth;
    254   CamParsCollector*       m_pcCamParsCollector;
    255   Int                     m_profileIdc;
    256 #endif
     252#endif
     253
     254  // Layer set
     255  Int                     m_targetOlsIdx;
     256  Int                     m_smallestLayerId;
     257  Bool                    m_isInOwnTargetDecLayerIdList;   
     258
     259  // Decoding processes
     260  DecodingProcess         m_decodingProcess;
     261  DecodingProcess         m_decProcPocAndRps;
     262
     263  // Decoding state
     264  Bool*                   m_firstPicInLayerDecodedFlag;   
     265   
     266  Int                     m_prevPicOrderCnt;
     267  Int                     m_prevTid0PicPicOrderCntMsb;
     268  Int                     m_prevTid0PicSlicePicOrderCntLsb;
     269 
     270  Int*                    m_lastPresentPocResetIdc;
     271  Bool*                   m_pocDecrementedInDpbFlag;
     272
     273  Int                     m_prevIrapPoc;
     274  Int64                   m_prevIrapDecodingOrder;
     275  Int64                   m_prevStsaDecOrder;
     276  Int                     m_prevStsaTemporalId;
    257277#endif
    258278
     
    268288
    269289  Void  init();
    270 #if NH_MV 
    271   Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayer, Bool& sliceSkippedFlag );
    272   Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayer );
    273 #else 
     290#if !NH_MV
    274291  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay);
    275 #endif
    276292  Void  deletePicBuffer();
    277293
    278 #if NH_MV
    279   const TComVPS* getActiveVPS() { return m_parameterSetManager.getActiveVPS( ); }
    280   const TComSPS* getActiveSPS() { return m_parameterSetManager.getActiveSPS( m_layerId ); }
    281 #endif
    282 
    283 #if NH_MV
    284   Void endPicDecoding(Int& poc, TComList<TComPic*>*& rpcListPic,  std::vector<Int>& targetDecLayerIdSet); 
    285 #else 
    286294  Void  executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic);
    287 #endif
    288295  Void  checkNoOutputPriorPics (TComList<TComPic*>* rpcListPic);
    289296
    290297  Bool  getNoOutputPriorPicsFlag () { return m_isNoOutputPriorPics; }
    291298  Void  setNoOutputPriorPicsFlag (Bool val) { m_isNoOutputPriorPics = val; }
     299 
    292300  Void  setFirstSliceInPicture (bool val)  { m_bFirstSliceInPicture = val; }
     301
    293302  Bool  getFirstSliceInSequence ()         { return m_bFirstSliceInSequence; }
    294303  Void  setFirstSliceInSequence (bool val) { m_bFirstSliceInSequence = val; }
     304#endif
     305
    295306#if O0043_BEST_EFFORT_DECODING
    296307  Void  setForceDecodeBitDepth(UInt bitDepth) { m_forceDecodeBitDepth = bitDepth; }
    297308#endif
     309
    298310  Void  setDecodedSEIMessageOutputStream(std::ostream *pOpStream) { m_pDecodedSEIOutputStream = pOpStream; }
    299311  UInt  getNumberOfChecksumErrorsDetected() const { return m_cGopDecoder.getNumberOfChecksumErrorsDetected(); }
     312
    300313#if NH_MV   
    301   TComPic*                getPic                ( Int poc );
    302   TComList<TComPic*>*     getListPic            ()               { return &m_cListPic;  } 
    303   Void                    setIvPicLists         ( TComPicLists* picLists) { m_ivPicLists = picLists; }
    304   Void                    setLayerInitilizedFlags( Bool* val )    { m_layerInitilizedFlag = val; }
    305   Void                    setTargetOlsIdx       ( Int targetOlsIdx ) { m_targetOlsIdx = targetOlsIdx; }   
    306   Int                     getTargetOlsIdx       ( )                  { return m_targetOlsIdx; }   
    307   Int                     getCurrPoc            ()               { return m_apcSlicePilot->getPOC(); }
    308   Void                    setLayerId            ( Int layer)     { m_layerId = layer;   }
    309   Int                     getLayerId            ()               { return m_layerId;    }
    310   Void                    setViewId             ( Int viewId  )  { m_viewId  = viewId;  }
    311   Int                     getViewId             ()               { return m_viewId;     } 
    312   Void                    initFromActiveVps     ( const TComVPS* vps );
     314
     315  /////////////////////////
     316  // For access from TAppDecTop
     317  /////////////////////////
     318
     319  // Non VCL decoding
     320  Bool       decodeNonVclNalu            ( InputNALUnit& nalu );                                   
     321                                   
     322  // Start picture decoding         
     323  Int        preDecodePoc                ( Bool firstPicInLayerDecodedFlag, Bool isFstPicOfAllLayOfPocResetPer, Bool isPocResettingPicture );
     324  Void       inferPocResetPeriodId       ( );
     325  Void       decodeSliceHeader           ( InputNALUnit &nalu );   
     326
     327  // Picture decoding
     328  Void       activatePSsAndInitPicOrSlice( TComPic* newPic );
     329  Void       decodePocAndRps             ( );
     330  Void       genUnavailableRefPics       ( );                               
     331  Void       decodeSliceSegment          ( InputNALUnit &nalu );
     332                                   
     333  // End Picture decoding           
     334  Void       executeLoopFilters          ( );
     335  Void       finalizePic( );
     336 
     337  //////////////////////////
     338  // For access from slice
     339  /////////////////////////
     340  Void       initFromActiveVps           ( const TComVPS* vps );
     341
     342  //////////////////////////
     343  // General access
     344  /////////////////////////
     345 
     346  // Picture identification
     347  Void       setLayerId            ( Int layer )       { m_layerId = layer;   }
     348  Int        getLayerId            ( )                 { return m_layerId;    }
     349  Void       setViewId             ( Int viewId )      { m_viewId  = viewId;  }
     350  Int        getViewId             ( )                 { return m_viewId;     } 
    313351#if NH_3D   
    314   Void                    setViewIndex          ( Int viewIndex  )  { m_viewIndex  = viewIndex;  }
    315   Int                     getViewIndex          ()               { return m_viewIndex;     } 
    316   Void                    setIsDepth            ( Bool isDepth ) { m_isDepth = isDepth; }
    317   Bool                    getIsDepth            ()               { return m_isDepth;    }
    318   Void                    setCamParsCollector( CamParsCollector* pcCamParsCollector ) { m_pcCamParsCollector = pcCamParsCollector; }
    319 
    320 
    321   Bool                    decProcAnnexI()           { assert( m_profileIdc != -1 ); return ( m_profileIdc == 8); }   
    322 #endif
     352  Void       setViewIndex          ( Int viewIndex )   { m_viewIndex  = viewIndex;  }
     353  Int        getViewIndex          ( )                 { return m_viewIndex;     } 
     354  Void       setIsDepth            ( Bool isDepth )    { m_isDepth = isDepth; }
     355  Bool       getIsDepth            ( )                 { return m_isDepth;    }
     356#endif
     357
     358  // Classes
     359  Void       setDpb                ( TComPicLists* picLists) { m_dpb = picLists; }
     360#if NH_3D                                       
     361  Void       setCamParsCollector   ( CamParsCollector* pcCamParsCollector ) { m_pcCamParsCollector = pcCamParsCollector; }
     362#endif
     363
     364  // Slice pilot access
     365  TComSlice* getSlicePilot                ( )               { return m_apcSlicePilot; }
     366                                                                         
     367  // Decoding state                                                     
     368  Bool      getFirstSliceSegementInPicFlag( );             
     369  Void      setFirstPicInLayerDecodedFlag(Bool* val )      { m_firstPicInLayerDecodedFlag = val;  }
     370  Void      setPocDecrementedInDPBFlag   (Bool* val )      { m_pocDecrementedInDpbFlag = val;  } 
     371  Void      setLastPresentPocResetIdc    (Int*  val )      { m_lastPresentPocResetIdc  = val;  }
     372                                                           
     373  // Layer sets                                                         
     374  Void      setTargetOlsIdx        ( Int targetOlsIdx )    { m_targetOlsIdx = targetOlsIdx; }   
     375  Int       getTargetOlsIdx        ( )                     { return m_targetOlsIdx; }   
     376  Int       getSmallestLayerId     ( )                     { return m_smallestLayerId; }   
     377  Bool      getIsInOwnTargetDecLayerIdList()               { return m_isInOwnTargetDecLayerIdList; }
     378                                                                         
     379  // Decoding processes identification                                   
     380  Bool      decProcClause8( )                              { return ( m_decodingProcess == CLAUSE_8 ); }
     381  Bool      decProcAnnexF ( )                              { return ( decProcAnnexG() || decProcAnnexH() || decProcAnnexI() ); }
     382  Bool      decProcAnnexG ( )                              { return ( m_decodingProcess == ANNEX_G || decProcAnnexI() ); }
     383  Bool      decProcAnnexH ( )                              { return ( m_decodingProcess == ANNEX_H  ); }
     384  Bool      decProcAnnexI ( )                              { return ( m_decodingProcess == ANNEX_I  ); }
     385                                                                         
     386  DecodingProcess getDecodingProcess ( ) const                   { return m_decodingProcess;                }
     387  Void      setDecProcPocAndRps( DecodingProcess decProc ) { m_decProcPocAndRps = decProc; }   
    323388#endif
    324389
    325390protected:
    326   Void  xGetNewPicBuffer  (const TComSPS &sps, const TComPPS &pps, TComPic*& rpcPic, const UInt temporalLayer);
    327   Void  xCreateLostPicture (Int iLostPOC);
    328 
     391
     392#if !NH_MV
     393  Void      xGetNewPicBuffer  (const TComSPS &sps, const TComPPS &pps, TComPic*& rpcPic, const UInt temporalLayer);
     394  Void      xCreateLostPicture (Int iLostPOC);
    329395  Void      xActivateParameterSets();
    330 #if NH_MV 
    331   TComPic*  xGetPic( Int layerId, Int poc );
    332   Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, Bool newLayerFlag, Bool& sliceSkippedFlag ); 
    333   Void      xResetPocInPicBuffer();
    334   Void      xCeckNoClrasOutput();
    335 
    336   Bool      xAllRefLayersInitilized( const TComVPS* vps );
    337 #else
    338   Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay);
    339 #endif
     396  Bool      xDecodeSlice                   (InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay);
     397#endif
     398
    340399  Void      xDecodeVPS(const std::vector<UChar> &naluData);
    341400  Void      xDecodeSPS(const std::vector<UChar> &naluData);
    342   Void      xDecodePPS(const std::vector<UChar> &naluData);
     401  Void      xDecodePPS(const std::vector<UChar> &naluData); 
     402#if !NH_MV
    343403  Void      xUpdatePreviousTid0POC( TComSlice *pSlice ) { if ((pSlice->getTLayer()==0) && (pSlice->isReferenceNalu() && (pSlice->getNalUnitType()!=NAL_UNIT_CODED_SLICE_RASL_R)&& (pSlice->getNalUnitType()!=NAL_UNIT_CODED_SLICE_RADL_R))) { m_prevTid0POC=pSlice->getPOC(); } }
     404#endif
    344405
    345406  Void      xParsePrefixSEImessages();
    346407  Void      xParsePrefixSEIsForUnknownVCLNal();
    347408
     409#if NH_MV
     410  // POC
     411  Void      x831DecProcForPicOrderCount         ( );
     412  Void      xF831DecProcForPicOrderCount        ( );
     413  Int       xGetCurrMsb                         ( Int cl, Int pl, Int pm, Int ml );
     414
     415  //RPS                                         
     416  Void      x832DecProcForRefPicSet             ( Bool annexFModifications );
     417  Void      xF832DecProcForRefPicSet            ( );
     418  Void      xG813DecProcForInterLayerRefPicSet  ( );
     419
     420  // Unavailable Pics
     421  Void      x8331GenDecProcForGenUnavilRefPics  ( );
     422  TComPic*  x8332GenOfOneUnavailPic             ( Bool calledFromCl8331 );
     423  Void      xF817DecProcForGenUnavRefPicForPicsFrstInDecOrderInLay();
     424  Void      xF833DecProcForGenUnavRefPics       ( ); 
     425  Void      xCheckUnavailableRefPics            ( );
     426#endif
     427
    348428};// END CLASS DEFINITION TDecTop
    349429
    350430
    351431//! \}
    352 
    353432#endif // __TDECTOP__
    354433
  • branches/HTM-15.0-dev0/source/Lib/TLibEncoder/TEncBinCoderCABAC.cpp

    r1313 r1317  
    156156#if FAST_BIT_EST
    157157  m_fracBits = pcTEncBinCABAC->m_fracBits;
     158#if NH_MV
    158159  D_PRINT_INDENT(g_traceEncFracBits,  "CopyState " + n2s(m_fracBits) );   
     160#endif
    159161#endif
    160162}
     
    171173  }
    172174#if FAST_BIT_EST
     175#if NH_MV
    173176  D_PRINT_INDENT( g_traceEncFracBits, "Reset Bits Before" + n2s(m_fracBits) );
     177#endif
    174178  m_fracBits &= 32767;
     179#if NH_MV
    175180  D_PRINT_INDENT( g_traceEncFracBits, "Reset Bits " + n2s(m_fracBits) ); 
     181#endif
    176182#endif
    177183}
  • branches/HTM-15.0-dev0/source/Lib/TLibEncoder/TEncBinCoderCABACCounter.cpp

    r1313 r1317  
    5959  m_pcTComBitIf->write(0, UInt(m_fracBits >> 15) );
    6060  m_fracBits &= 32767;
     61#if NH_MV
    6162  D_PRINT_INDENT( g_traceEncFracBits, "Finish " + n2s(m_fracBits) );   
     63#endif
    6264}
    6365
     
    8183  m_uiBinsCoded += m_binCountIncrement;
    8284  m_fracBits += rcCtxModel.getEntropyBits( binValue );
     85#if NH_MV
    8386  D_PRINT_INDENT( g_traceEncFracBits, "EncodeBin " + n2s(m_fracBits) );   
     87#endif
    8488
    8589  rcCtxModel.update( binValue );
     
    113117  m_uiBinsCoded += m_binCountIncrement;
    114118  m_fracBits += 32768;
    115     D_PRINT_INDENT( g_traceEncFracBits , "EncodeBinEP " + n2s(m_fracBits) );   
     119#if NH_MV
     120  D_PRINT_INDENT( g_traceEncFracBits , "EncodeBinEP " + n2s(m_fracBits) );
     121#endif
    116122}
    117123
     
    126132  m_uiBinsCoded += numBins & -m_binCountIncrement;
    127133  m_fracBits += 32768 * numBins;
     134#if NH_MV
    128135  D_PRINT_INDENT( g_traceEncFracBits , "EncodeBinsEP " + n2s(m_fracBits) );   
     136#endif
    129137}
    130138
     
    138146  m_uiBinsCoded += m_binCountIncrement;
    139147  m_fracBits += ContextModel::getEntropyBitsTrm( binValue );
     148#if NH_MV
    140149  D_PRINT_INDENT( g_traceEncFracBits , "EncodeBinTrm " + n2s(m_fracBits) );   
     150#endif
    141151}
    142152
     
    144154{
    145155  m_fracBits = (m_fracBits + 32767) & (~32767);
     156#if NH_MV
    146157  D_PRINT_INDENT( g_traceEncFracBits, "Align " + n2s(m_fracBits) );   
     158#endif
    147159}
    148160
  • branches/HTM-15.0-dev0/source/Lib/TLibEncoder/TEncCavlc.cpp

    r1313 r1317  
    4040#include "SEIwrite.h"
    4141
    42 #if NH_3D
     42#if NH_MV
    4343#include "TEncTop.h"
    4444#endif
     
    5353{
    5454  fprintf( g_hTrace, "=========== Video Parameter Set     ===========\n" );
     55}
    5556
    5657Void  xTraceSPSHeader ()
     
    380381    WRITE_CODE((pcPPS->getDLT()->getDepthViewBitDepth() - 8), 4, "pps_bit_depth_for_depth_layers_minus8");
    381382   
    382 #if NH_3D_DLT_FIX
    383383    for( Int i = 0; i <= pcPPS->getDLT()->getNumDepthViews()-1; i++ )
    384 #else
    385     for( Int i = 0; i <= pcPPS->getDLT()->getNumDepthViews(); i++ )
    386 #endif
    387384    {
    388385      Int layerId = pcPPS->getDLT()->getDepthIdxToLayerId(i);
     
    748745    WRITE_UVLC( pcSPS->getMaxDecPicBuffering(i) - 1,       "sps_max_dec_pic_buffering_minus1[i]" );
    749746    WRITE_UVLC( pcSPS->getNumReorderPics(i),               "sps_max_num_reorder_pics[i]" );
     747#if NH_MV
     748    WRITE_UVLC( pcSPS->getSpsMaxLatencyIncreasePlus1(i),   "sps_max_latency_increase_plus1[i]" );
     749#else
    750750    WRITE_UVLC( pcSPS->getMaxLatencyIncrease(i),           "sps_max_latency_increase_plus1[i]" );
     751#endif
    751752    if (!subLayerOrderingInfoPresentFlag)
    752753    {
     
    814815    codeShortTermRefPicSet( rps,false, i);
    815816  }
     817#if NH_MV
     818  WRITE_FLAG( pcSPS->getLongTermRefPicsPresentFlag() ? 1 : 0,         "long_term_ref_pics_present_flag" );
     819  if (pcSPS->getLongTermRefPicsPresentFlag())
     820#else
    816821  WRITE_FLAG( pcSPS->getLongTermRefsPresent() ? 1 : 0,         "long_term_ref_pics_present_flag" );
    817822  if (pcSPS->getLongTermRefsPresent())
     823#endif
    818824  {
    819825    WRITE_UVLC(pcSPS->getNumLongTermRefPicSPS(), "num_long_term_ref_pics_sps" );
     
    17471753  //write slice address
    17481754  const Int sliceSegmentRsAddress = pcSlice->getPic()->getPicSym()->getCtuTsToRsAddrMap(ctuTsAddress);
    1749 
     1755#if NH_MV
     1756  // This should actually be done somewhere else and not in writing process.
     1757  pcSlice->setFirstSliceSegementInPicFlag( sliceSegmentRsAddress==0 );
     1758  WRITE_FLAG( pcSlice->getFirstSliceSegementInPicFlag() , "first_slice_segment_in_pic_flag" );
     1759#else
    17501760  WRITE_FLAG( sliceSegmentRsAddress==0, "first_slice_segment_in_pic_flag" );
     1761#endif
    17511762  if ( pcSlice->getRapPicFlag() )
    17521763  {
     
    17601771  else
    17611772#endif
    1762 
    17631773  WRITE_UVLC( pcSlice->getPPS()->getPPSId(), "slice_pic_parameter_set_id" );
    17641774  if ( pcSlice->getPPS()->getDependentSliceSegmentsEnabledFlag() && (sliceSegmentRsAddress!=0) )
     
    17721782  if ( !pcSlice->getDependentSliceSegmentFlag() )
    17731783  {
    1774 
    17751784#if NH_MV   
    17761785    Int esb = 0;  //Don't use i, otherwise will shadow something below
     
    18611870        }
    18621871      }
     1872#if NH_MV
     1873      if(pcSlice->getSPS()->getLongTermRefPicsPresentFlag())
     1874#else
    18631875      if(pcSlice->getSPS()->getLongTermRefsPresent())
     1876#endif
    18641877      {
    18651878        Int numLtrpInSH = rps->getNumberOfLongtermPictures();
     
    21962209    Bool isDBFEnabled = (!pcSlice->getDeblockingFilterDisable());
    21972210
    2198     if(pcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled ))
     2211      if(pcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled ))
    21992212    {
    22002213      WRITE_FLAG(pcSlice->getLFCrossSliceBoundaryFlag()?1:0, "slice_loop_filter_across_slices_enabled_flag");
     
    22042217    {
    22052218      Int voiInVps = vps->getVoiInVps( pcSlice->getViewIndex() );
    2206 #if NH_3D_FIX_TICKET_101
    22072219      if( vps->getCpInSliceSegmentHeaderFlag( voiInVps ) )
    2208 #else
    2209       if( vps->getCpInSliceSegmentHeaderFlag( voiInVps ) && !pcSlice->getIsDepth() )
    2210 #endif
    22112220      {
    22122221        for( Int m = 0; m < vps->getNumCp( voiInVps ); m++ )
     
    22572266      if( pcSlice->getPocMsbValRequiredFlag() )
    22582267      {
    2259         pcSlice->setPocMsbValPresentFlag( true );
     2268        pcSlice->setPocMsbCycleValPresentFlag( true );
    22602269      }
    22612270      else
    22622271      {
    2263         pcSlice->setPocMsbValPresentFlag( false );
    2264       }
    2265     }
    2266 
    2267     if( pcSlice->getPocMsbValPresentFlag() )
     2272        pcSlice->setPocMsbCycleValPresentFlag( false );
     2273      }
     2274    }
     2275
     2276    if( pcSlice->getPocMsbCycleValPresentFlag() )
    22682277    {
    22692278//      Int iMaxPOClsb = 1<< pcSlice->getSPS()->getBitsForPOC(); currently unused
    22702279
    22712280      UInt lengthVal = 1;
    2272       UInt tempVal = pcSlice->getPocMsbVal() + 1;
     2281      UInt tempVal = pcSlice->getPocMsbCycleVal() + 1;
    22732282      assert ( tempVal );
    22742283      while( 1 != tempVal )
     
    23142323    if( !pcSlice->getPocMsbValRequiredFlag() &&  pcSlice->getVPS()->getVpsPocLsbAlignedFlag()  )
    23152324    {
    2316       WRITE_FLAG( pcSlice->getPocMsbValPresentFlag( ) ? 1 : 0 , "poc_msb_val_present_flag" );
     2325      WRITE_FLAG( pcSlice->getPocMsbCycleValPresentFlag( ) ? 1 : 0 , "poc_msb_cycle_val_present_flag" );
    23172326    }
    23182327    else
    23192328    {
    2320       assert( pcSlice->getPocMsbValPresentFlag() ==  pcSlice->inferPocMsbValPresentFlag( ) );
     2329      assert( pcSlice->getPocMsbCycleValPresentFlag() ==  pcSlice->inferPocMsbCycleValPresentFlag( ) );
    23212330    }
    23222331   
    2323     if( pcSlice->getPocMsbValPresentFlag() )
    2324     {
    2325       WRITE_UVLC( pcSlice->getPocMsbVal( ), "poc_msb_val" );
     2332    if( pcSlice->getPocMsbCycleValPresentFlag() )
     2333    {
     2334      WRITE_UVLC( pcSlice->getPocMsbCycleVal( ), "poc_msb_cycle_val" );
    23262335    }
    23272336   
     
    23472356  for (Int i = 0; i < maxNumSubLayersMinus1; i++)
    23482357  {
    2349 #if !NH_MV
    2350 #endif
    23512358    WRITE_FLAG( pcPTL->getSubLayerProfilePresentFlag(i), "sub_layer_profile_present_flag[i]" );
    2352 #if !NH_MV
    2353 #endif
    23542359    WRITE_FLAG( pcPTL->getSubLayerLevelPresentFlag(i),   "sub_layer_level_present_flag[i]" );
    23552360  }
  • branches/HTM-15.0-dev0/source/Lib/TLibEncoder/TEncCavlc.h

    r1313 r1317  
    6666
    6767protected:
    68 #if NH_3D
     68#if NH_MV
    6969  TEncTop*      m_encTop;
    7070#endif
     
    179179  Void codeExplicitRdpcmMode( TComTU &rTu, const ComponentID compID );
    180180
    181 #if NH_3D
     181#if NH_MV
    182182  TEncTop* getEncTop()               { return m_encTop; };
    183183  Void     setEncTop( TEncTop* et )  {  m_encTop = et; };
  • branches/HTM-15.0-dev0/source/Lib/TLibEncoder/TEncCu.cpp

    r1313 r1317  
    764764    if( rpcBestCU->getSlice()->getDepthIntraSkipFlag() )
    765765    {
    766       xCheckRDCostDIS( rpcBestCU, rpcTempCU, SIZE_2Nx2N );
     766      xCheckRDCostDIS( rpcBestCU, rpcTempCU, SIZE_2Nx2N DEBUG_STRING_PASS_INTO(sDebug) );
    767767      rpcTempCU->initEstData( uiDepth, iMinQP, isAddLowestQP  );
    768768    }
     
    795795            {
    796796#if  NH_3D_FAST_TEXTURE_ENCODING
    797               xCheckRDCostInter( rpcBestCU, rpcTempCU DEBUG_STRING_PASS_INTO(sDebug), SIZE_NxN, bFMD  );
     797              xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_NxN DEBUG_STRING_PASS_INTO(sDebug), bFMD  );
    798798#else
    799799
     
    10961096
    10971097        if((rpcBestCU->getSlice()->getSliceType() == I_SLICE)                                     ||
    1098            ((!m_pcEncCfg->getDisableIntraPUsInInterSlices()) && ( // avoid very complex intra if it is unlikely
     1098           ((!m_pcEncCfg->getDisableIntraPUsInInterSlices()) && (
    10991099           (rpcBestCU->getCbf( 0, COMPONENT_Y  ) != 0)                                            ||
    11001100          ((rpcBestCU->getCbf( 0, COMPONENT_Cb ) != 0) && (numberValidComponents > COMPONENT_Cb)) ||
    1101           ((rpcBestCU->getCbf( 0, COMPONENT_Cr ) != 0) && (numberValidComponents > COMPONENT_Cr))
     1101          ((rpcBestCU->getCbf( 0, COMPONENT_Cr ) != 0) && (numberValidComponents > COMPONENT_Cr))   // avoid very complex intra if it is unlikely
    11021102 #if NH_3D_ENC_DEPTH
    11031103            || rpcBestCU->getSlice()->getIsDepth()
     
    17851785  }
    17861786
     1787#if NH_MV
    17871788  D_PRINT_INC_INDENT( g_traceModeCheck, "xCheckRDCostMerge2Nx2N" );
     1789#endif
    17881790
    17891791#if NH_3D_MLC
     
    19701972  for( UInt uiNoResidual = 0; uiNoResidual < iteration; ++uiNoResidual )
    19711973  {
     1974#if NH_MV
    19721975    D_PRINT_INC_INDENT ( g_traceModeCheck, "uiNoResidual: " + n2s( uiNoResidual) );
     1976#endif
    19731977
    19741978    for( UInt uiMergeCand = 0; uiMergeCand < numValidMergeCand; ++uiMergeCand )
     
    19831987      }
    19841988#endif
     1989#if NH_MV
    19851990      D_PRINT_INC_INDENT ( g_traceModeCheck, "uiMergeCand: "+  n2s(uiMergeCand) );
     1991#endif
    19861992
    19871993      if(!(uiNoResidual==1 && mergeCandBuffer[uiMergeCand]==1))
     
    21732179
    21742180              xCheckDQP( rpcTempCU );
    2175               xCheckBestMode( rpcBestCU, rpcTempCU, uhDepth );
     2181              xCheckBestMode( rpcBestCU, rpcTempCU, uhDepth DEBUG_STRING_PASS_INTO(bestStr) DEBUG_STRING_PASS_INTO(tmpStr) );
    21762182            }
    21772183          }
     
    21972203        }
    21982204      }
     2205#if NH_MV
    21992206      D_DEC_INDENT( g_traceModeCheck );
     2207#endif
    22002208    }
    22012209
     
    22292237      }
    22302238    }
     2239#if NH_MV
    22312240    D_DEC_INDENT( g_traceModeCheck );
     2241#endif
    22322242  }
    22332243  DEBUG_STRING_APPEND(sDebug, bestStr)
     
    22392249 delete[] puhInterDirSP;
    22402250#endif
     2251#if NH_MV
    22412252 D_DEC_INDENT( g_traceModeCheck );
     2253#endif
    22422254}
    22432255
     
    22652277  }
    22662278
     2279#if NH_MV
    22672280  D_PRINT_INC_INDENT(g_traceModeCheck,   "xCheckRDCostInter; ePartSize:" + n2s( ePartSize) );
     2281#endif
    22682282
    22692283
     
    23542368  {
    23552369#if NH_3D_ARP
    2356     if( nARPWMax )
    2357     {
    2358       continue;
    2359     }
    2360     else
    2361 #endif
    2362     {
    2363       D_DEC_INDENT( g_traceModeCheck );
    2364       return;
    2365     }
     2370        if( nARPWMax )
     2371        {
     2372          continue;
     2373        }
     2374        else
     2375#endif
     2376    {
     2377#if NH_MV
     2378        D_DEC_INDENT( g_traceModeCheck );
     2379#endif
     2380    return;
     2381  }
    23662382  }
    23672383#endif
     
    24682484
    24692485          xCheckDQP( rpcTempCU );
    2470           xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth);
     2486          xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth DEBUG_STRING_PASS_INTO(sDebug) DEBUG_STRING_PASS_INTO(sTest));
    24712487        }
    24722488
     
    24792495  }
    24802496#endif
     2497#if NH_MV
    24812498  D_DEC_INDENT( g_traceModeCheck );
     2499#endif
    24822500}
    24832501
     
    26832701#endif
    26842702#if NH_3D_DIS
    2685 Void TEncCu::xCheckRDCostDIS( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize eSize )
     2703Void TEncCu::xCheckRDCostDIS( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize eSize DEBUG_STRING_FN_DECLARE(sDebug) )
    26862704{
     2705  DEBUG_STRING_NEW(sTest)
    26872706  UInt uiDepth = rpcTempCU->getDepth( 0 );
    26882707  if( !rpcBestCU->getSlice()->getIsDepth() || (eSize != SIZE_2Nx2N))
     
    26912710  }
    26922711
     2712#if NH_MV
    26932713  D_PRINT_INC_INDENT(g_traceModeCheck, "xCheckRDCostDIS" );
     2714#endif
    26942715
    26952716#if NH_3D_VSO // M5
     
    27532774  xCheckDQP( rpcTempCU );
    27542775  xCheckBestMode(rpcBestCU, rpcTempCU, uiDepth  DEBUG_STRING_PASS_INTO(sDebug) DEBUG_STRING_PASS_INTO(sTest) );
     2776#if NH_MV
    27552777  D_DEC_INDENT( g_traceModeCheck ); 
     2778#endif
    27562779}
    27572780#endif
     
    27772800    }
    27782801  }
     2802#if NH_MV
    27792803  D_PRINT_INC_INDENT (g_traceModeCheck, "xCheckRDCostIntra; eSize: " + n2s(eSize) );
    2780  
     2804#endif
     2805
    27812806  UInt uiDepth = rpcTempCU->getDepth( 0 );
    27822807#if NH_3D_VSO // M5
     
    28302855    m_pcEntropyCoder->encodeCUTransquantBypassFlag( rpcTempCU, 0,          true );
    28312856  }
    2832 #if NH_3D_DIS && !NH_3D_DIS_FIX
     2857  m_pcEntropyCoder->encodeSkipFlag ( rpcTempCU, 0,          true );
     2858#if NH_3D_DIS
    28332859  m_pcEntropyCoder->encodeDIS( rpcTempCU, 0,          true );
    28342860  if(!rpcTempCU->getDISFlag(0))
    28352861  {
    28362862#endif
    2837   m_pcEntropyCoder->encodeSkipFlag ( rpcTempCU, 0,          true );
    2838 #if NH_3D_DIS_FIX
    2839   m_pcEntropyCoder->encodeDIS( rpcTempCU, 0,          true );
    2840   if(!rpcTempCU->getDISFlag(0))
    2841   {
    2842 #endif
    2843   m_pcEntropyCoder->encodePredMode( rpcTempCU, 0,          true );
    2844   m_pcEntropyCoder->encodePartSize( rpcTempCU, 0, uiDepth, true );
    2845   m_pcEntropyCoder->encodePredInfo( rpcTempCU, 0 );
    2846   m_pcEntropyCoder->encodeIPCMInfo(rpcTempCU, 0, true );
     2863    m_pcEntropyCoder->encodePredMode( rpcTempCU, 0,          true );
     2864    m_pcEntropyCoder->encodePartSize( rpcTempCU, 0, uiDepth, true );
     2865    m_pcEntropyCoder->encodePredInfo( rpcTempCU, 0 );
     2866    m_pcEntropyCoder->encodeIPCMInfo(rpcTempCU, 0, true );
    28472867#if NH_3D_SDC_INTRA
    28482868    m_pcEntropyCoder->encodeSDCFlag( rpcTempCU, 0, true );
    28492869#endif
    28502870
    2851   // Encode Coefficients
    2852   Bool bCodeDQP = getdQPFlag();
    2853   Bool codeChromaQpAdjFlag = getCodeChromaQpAdjFlag();
    2854   m_pcEntropyCoder->encodeCoeff( rpcTempCU, 0, uiDepth, bCodeDQP, codeChromaQpAdjFlag );
    2855   setCodeChromaQpAdjFlag( codeChromaQpAdjFlag );
    2856   setdQPFlag( bCodeDQP );
     2871    // Encode Coefficients
     2872    Bool bCodeDQP = getdQPFlag();
     2873    Bool codeChromaQpAdjFlag = getCodeChromaQpAdjFlag();
     2874    m_pcEntropyCoder->encodeCoeff( rpcTempCU, 0, uiDepth, bCodeDQP, codeChromaQpAdjFlag );
     2875    setCodeChromaQpAdjFlag( codeChromaQpAdjFlag );
     2876    setdQPFlag( bCodeDQP );
    28572877#if NH_3D_DIS
    28582878  }
     
    28772897  xCheckBestMode(rpcBestCU, rpcTempCU, uiDepth DEBUG_STRING_PASS_INTO(sDebug) DEBUG_STRING_PASS_INTO(sTest));
    28782898
     2899#if NH_MV
    28792900  D_DEC_INDENT( g_traceModeCheck );
    2880   }
     2901#endif
     2902}
    28812903
    28822904
     
    29122934  }
    29132935#endif
    2914 
    29152936  rpcTempCU->setSkipFlagSubParts( false, 0, uiDepth );
    29162937#if NH_3D_DIS
  • branches/HTM-15.0-dev0/source/Lib/TLibEncoder/TEncCu.h

    r1313 r1317  
    163163#endif
    164164#if NH_3D_DIS
    165   Void  xCheckRDCostDIS   ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize );
     165  Void  xCheckRDCostDIS   ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize DEBUG_STRING_FN_DECLARE(sDebug) );
    166166#endif
    167167  Void  xCheckRDCostIntra   ( TComDataCU *&rpcBestCU,
  • branches/HTM-15.0-dev0/source/Lib/TLibEncoder/TEncEntropy.cpp

    r1313 r1317  
    119119Void TEncEntropy::encodeDIS( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD )
    120120{
    121 #if NH_3D_FIX_TICKET_98 
    122121  if( !pcCU->getSlice()->getDepthIntraSkipFlag() )
    123 #else
    124   if ( !pcCU->getSlice()->getIsDepth() )
    125 #endif
    126122  {
    127123    return;
  • branches/HTM-15.0-dev0/source/Lib/TLibEncoder/TEncEntropy.h

    r1313 r1317  
    140140  Void    resetBits                 ()                        { m_pcEntropyCoderIf->resetBits();      }
    141141  UInt    getNumberOfWrittenBits    ()                        {
     142#if NH_MV
    142143      D_PRINT_INDENT(g_encNumberOfWrittenBits,  "NumBits: " +  n2s( m_pcEntropyCoderIf->getNumberOfWrittenBits() ))
     144#endif
    143145 return m_pcEntropyCoderIf->getNumberOfWrittenBits(); }
    144146  Void    resetEntropy              (const TComSlice *pSlice) { m_pcEntropyCoderIf->resetEntropy(pSlice);  }
  • branches/HTM-15.0-dev0/source/Lib/TLibEncoder/TEncGOP.cpp

    r1313 r1317  
    14281428          if ( gopNum == MAX_GOP)
    14291429          {
    1430             printf( "\nError: FrameI_l%d cannot enable inter-component prediction.\n", pcSlice->getVPS()->getLayerIdInVps( getLayerId() ) );
     1430            printf( "\nError: FrameI_l%d cannot enable inter-component prediction on slice level. All reference layers need to be available and at least one tool using inter-component prediction must be enabled in the SPS. \n", pcSlice->getVPS()->getLayerIdInVps( getLayerId() ) );
    14311431          }
    14321432          else
    14331433          {
    1434             printf( "\nError: Frame%d_l%d cannot enable inter-component prediction.\n", gopNum, pcSlice->getVPS()->getLayerIdInVps( getLayerId() ) );
     1434            printf( "\nError: Frame%d_l%d cannot enable inter-component prediction on slice level. All reference layers need to be available and at least one tool using inter-component prediction must be enabled in the SPS. \n", gopNum, pcSlice->getVPS()->getLayerIdInVps( getLayerId() ) );
    14351435          }
    14361436         
     
    14411441      pcSlice->checkInCompPredRefLayers();
    14421442    }   
    1443 
    14441443#if NH_3D_IV_MERGE
    14451444    // This needs to be done after initialization of 3D tool parameters.
  • branches/HTM-15.0-dev0/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp

    r1313 r1317  
    826826      }
    827827
     828#if NH_MV
    828829      D_PRINT_INDENT( g_traceSAOCost, "SAO mode " + n2s( mode ) + " Cost:  " + n2s( modeCost) );
    829 
     830#endif
    830831      if(modeCost < minCost)
    831832      {
  • branches/HTM-15.0-dev0/source/Lib/TLibEncoder/TEncSearch.cpp

    r1313 r1317  
    15301530                                  )
    15311531{
     1532#if NH_MV
    15321533  D_PRINT_INC_INDENT( g_traceModeCheck, "xRecurIntraCodingLumaQT; zeroResiFlag " + n2s(zeroResiFlag) )
     1534#endif
    15331535
    15341536  TComDataCU   *pcCU          = rTu.getCU();
     
    17131715      dSingleCost   = 0.0;
    17141716#if NH_3D_ENC_DEPTH
    1715 #if NH_3D_ENC_DEPTH_FIX
    17161717      xIntraCodingTUBlock( pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaSingle, false, uiSingleDistLuma, COMPONENT_Y, rTu DEBUG_STRING_PASS_INTO(sDebug), 0, zeroResiFlag );
    1717 #else
    1718       xIntraCodingTUBlock( pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaSingle, false, uiSingleDistLuma, COMPONENT_Y, rTu DEBUG_STRING_PASS_INTO(sDebug), zeroResiFlag );
    1719 #endif
    17201718#else
    17211719      pcCU ->setTransformSkipSubParts ( 0, COMPONENT_Y, uiAbsPartIdx, totalAdjustedDepthChan );
     
    18411839        }
    18421840      }
     1841#if NH_MV
    18431842      D_DEC_INDENT( g_traceModeCheck );
     1843#endif
    18441844      return;
    18451845    }
     
    18881888  ruiDistY += uiSingleDistLuma;
    18891889  dRDCost  += dSingleCost;
     1890#if NH_MV
    18901891  D_DEC_INDENT( g_traceModeCheck );
     1892#endif
    18911893}
    18921894
     
    19071909  TComTURecurse rTu(pcCU, 0);
    19081910  const ChromaFormat chFmt     = rTu.GetChromaFormat();
    1909 
     1911  DEBUG_STRING_NEW(sTemp)
    19101912  if ( uiPredMode == 0 )
    19111913  {
     
    20312033    TComTURecurse tuRecurseCU(pcCU, 0);
    20322034    TComTURecurse tuRecurseWithPU(tuRecurseCU, false, TComTU::DONT_SPLIT);
    2033 
     2035    DEBUG_STRING_NEW(sTemp)
    20342036    initIntraPatternChType( tuRecurseWithPU, COMPONENT_Y, false DEBUG_STRING_PASS_INTO(sTemp) );
    20352037
     
    20862088     
    20872089      //===== init pattern for luma prediction =====
    2088      
     2090      DEBUG_STRING_NEW(sTemp2)
    20892091      initIntraPatternChType( tuRecurseWithPU, COMPONENT_Y, bUseFilter DEBUG_STRING_PASS_INTO(sTemp2) );
    20902092     
     
    22122214
    22132215  //===== determine distortion ===== 
    2214 #if NH_3D_INTRA_SDC_RD_FIX
    22152216#if NH_3D_VSO 
    22162217  if( m_pcRdCost->getUseVSO() )
     
    22192220  }
    22202221  else
    2221 #endif
    2222 #else
    2223 #if NH_3D_VSO 
    2224   if( m_pcRdCost->getUseVSO() )
    2225   {
    2226     if( m_pcRdCost->getUseEstimatedVSD() )
    2227     {
    2228       ruiDist = m_pcRdCost->getDistPartVSD( pcCU, uiAbsPartIdx, bitDepthY, piPred, uiStride, piOrg, uiStride, uiWidth, uiHeight, false );
    2229     }
    2230     else
    2231     {
    2232       ruiDist = m_pcRdCost->getDistPartVSO( pcCU, uiAbsPartIdx, bitDepthY, piPred, uiStride, piOrg, uiStride, uiWidth, uiHeight, false );
    2233     }
    2234   }
    2235   else
    2236 #endif
    22372222#endif
    22382223  {
     
    27542739                                  Bool        bLumaOnly )
    27552740{
     2741#if NH_MV
    27562742  D_PRINT_INC_INDENT(g_traceModeCheck, "estIntraPredDis");
     2743#endif
    27572744
    27582745  UInt    uiDepth        = pcCU->getDepth(0);
     
    27722759  for( UInt uiPredMode = 0; uiPredMode < 4 ; uiPredMode++ )
    27732760  {
     2761#if NH_MV
    27742762    D_PRINT_INC_INDENT(g_traceModeCheck, "uiPredMode" +  n2s(uiPredMode ) );
     2763#endif
    27752764
    27762765    // set context models
     
    27962785      pcPredYuv->copyPartToPartYuv(pcRecoYuv, 0, uiWidth, uiHeight);
    27972786    }
     2787#if NH_MV
    27982788      D_DEC_INDENT( g_traceModeCheck ); 
     2789#endif
    27992790  }
    28002791
     
    28072798  //===== set distortion (rate and r-d costs are determined later) =====
    28082799  pcCU->getTotalDistortion() = uiBestDist;
     2800#if NH_MV
    28092801  D_DEC_INDENT( g_traceModeCheck );
     2802#endif
    28102803}
    28112804#endif
     
    28262819                              )
    28272820{
     2821#if NH_MV
    28282822  D_PRINT_INC_INDENT( g_traceModeCheck,  "estIntraPredLumaQT");
     2823#endif
    28292824
    28302825  const UInt         uiDepth               = pcCU->getDepth(0);
     
    28822877  {
    28832878    const UInt uiPartOffset=tuRecurseWithPU.GetAbsPartIdxTU();
     2879#if NH_MV
    28842880    D_PRINT_INC_INDENT(g_traceModeCheck, "uiPartOffset: " + n2s(uiPartOffset ) );
     2881#endif
    28852882
    28862883//  for( UInt uiPU = 0, uiPartOffset=0; uiPU < uiNumPU; uiPU++, uiPartOffset += uiQNumParts )
     
    29272924      m_pcRdCost->setDistParam(distParam, sps.getBitDepth(CHANNEL_TYPE_LUMA), piOrg, uiStride, piPred, uiStride, puRect.width, puRect.height, bUseHadamard);
    29282925
    2929 #if NH_3D_IC_FIX
     2926#if NH_3D
    29302927      distParam.bUseIC = false;
    29312928#endif
     
    29402937        Distortion uiSad  = 0;
    29412938#endif
     2939#if NH_MV
    29422940        D_PRINT_INC_INDENT(g_traceModeCheck, "preTest; uiMode " + n2s(uiMode) );
     2941#endif
    29432942
    29442943        const Bool bUseFilter=TComPrediction::filteringIntraReferenceSamples(COMPONENT_Y, uiMode, puRect.width, puRect.height, chFmt, sps.getSpsRangeExtension().getIntraSmoothingDisabledFlag());
     
    29932992
    29942993        CandNum += xUpdateCandList( uiMode, cost, numModesForFullRD, uiRdModeList, CandCostList );
     2994#if NH_MV
    29952995        D_DEC_INDENT( g_traceModeCheck );
     2996#endif
    29962997      }
    29972998
     
    31933194#endif
    31943195
     3196#if NH_MV
    31953197      D_PRINT_INC_INDENT(g_traceModeCheck, "Test; uiOrgMode: " + n2s(uiOrgMode) );
     3198#endif
    31963199
    31973200      pcCU->setIntraDirSubParts ( CHANNEL_TYPE_LUMA, uiOrgMode, uiPartOffset, uiDepth + uiInitTrDepth );
     
    33953398      } // SDC loop
    33963399#endif
     3400#if NH_MV
    33973401      D_DEC_INDENT( g_traceModeCheck );
     3402#endif
    33983403    } // Mode loop
    33993404
     
    35543559    pcCU->setSDCFlagSubParts          ( bBestUseSDC, uiPartOffset, uiDepth + uiInitTrDepth );
    35553560#endif
     3561#if NH_MV
    35563562    D_DEC_INDENT( g_traceModeCheck );
     3563#endif
    35573564  } while (tuRecurseWithPU.nextSection(tuRecurseCU));
    35583565
     
    35833590  //===== set distortion (rate and r-d costs are determined later) =====
    35843591  pcCU->getTotalDistortion() = uiOverallDistY;
     3592#if NH_MV
    35853593  D_DEC_INDENT( g_traceModeCheck );
     3594#endif
    35863595}
    35873596
     
    38923901)
    38933902{
     3903#if NH_MV
    38943904  D_PRINT_INC_INDENT(g_traceModeCheck,  "xMergeEstimation" );
     3905#endif
    38953906
    38963907  UInt uiAbsPartIdx = 0;
     
    40144025  for( UInt uiMergeCand = 0; uiMergeCand < numValidMergeCand; ++uiMergeCand )
    40154026  {
     4027#if NH_MV
    40164028    D_PRINT_INC_INDENT(g_traceModeCheck,  "uiMergeCand: " + n2s(uiMergeCand) );
     4029#endif
    40174030    Distortion uiCostCand = std::numeric_limits<Distortion>::max();
    40184031    UInt       uiBitsCand = 0;
     
    40924105    uiCostCand = uiCostCand + m_pcRdCost->getCost( uiBitsCand );
    40934106
     4107#if NH_MV
    40944108    D_PRINT_INDENT( g_traceRDCost, "IP RD Cost: "  + n2s(uiCostCand));
     4109#endif
    40954110
    40964111    if ( uiCostCand < ruiCost )
     
    41024117      uiMergeIndex = uiMergeCand;
    41034118    }
     4119#if NH_MV
    41044120    D_DEC_INDENT( g_traceModeCheck );
    4105   }
     4121#endif
     4122  }
     4123#if NH_MV
    41064124  D_DEC_INDENT( g_traceModeCheck );
     4125#endif
    41074126}
    41084127
     
    41424161{
    41434162
     4163#if NH_MV
    41444164  D_PRINT_INC_INDENT(g_traceModeCheck,  "predInterSearch");
     4165#endif
    41454166
    41464167  for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)
     
    42104231  for ( Int iPartIdx = 0; iPartIdx < iNumPart; iPartIdx++ )
    42114232  {
     4233#if NH_MV
    42124234    D_PRINT_INC_INDENT(g_traceModeCheck, "iPartIdx: " + n2s(iPartIdx) );
     4235#endif
    42134236
    42144237    Distortion   uiCost[2] = { std::numeric_limits<Distortion>::max(), std::numeric_limits<Distortion>::max() };
     
    42584281    for ( Int iRefList = 0; iRefList < iNumPredDir; iRefList++ )
    42594282    {
     4283#if NH_MV
    42604284      D_PRINT_INC_INDENT(g_traceModeCheck,  "iRefList: " + n2s(iRefList) );
     4285#endif
    42614286
    42624287      RefPicList  eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 );
     
    42644289      for ( Int iRefIdxTemp = 0; iRefIdxTemp < pcCU->getSlice()->getNumRefIdx(eRefPicList); iRefIdxTemp++ )
    42654290      {
     4291#if NH_MV
    42664292        D_PRINT_INC_INDENT(g_traceModeCheck,  "iRefIdxTemp: " + n2s(iRefIdxTemp) );
     4293#endif
    42674294
    42684295        uiBitsTemp = uiMbBits[iRefList];
     
    43384365          refIdxValidList1 = iRefIdxTemp;
    43394366        }
     4367#if NH_MV
    43404368        D_DEC_INDENT( g_traceModeCheck );
    4341       }
     4369#endif
     4370      }
     4371#if NH_MV
    43424372      D_DEC_INDENT( g_traceModeCheck );
     4373#endif
    43434374    }
    43444375
     
    46094640        xGetInterPredictionError( pcCU, pcOrgYuv, iPartIdx, uiMEError, m_pcEncCfg->getUseHADME() );
    46104641        uiMECost = uiMEError + m_pcRdCost->getCost( uiMEBits );
     4642#if NH_MV
    46114643        D_PRINT_INDENT( g_traceRDCost, "IP RD Cost: "  + n2s(uiMECost));
     4644#endif
    46124645      }
    46134646#else
     
    47564789    //  MC
    47574790    motionCompensation ( pcCU, pcPredYuv, REF_PIC_LIST_X, iPartIdx );
     4791#if NH_MV
    47584792    D_DEC_INDENT( g_traceModeCheck );
     4793#endif
    47594794  } //  end of for ( Int iPartIdx = 0; iPartIdx < iNumPart; iPartIdx++ )
    47604795
    47614796  setWpScalingDistParam( pcCU, -1, REF_PIC_LIST_X );
    47624797
     4798#if NH_MV
    47634799  D_DEC_INDENT( g_traceModeCheck );
     4800#endif
    47644801  return;
    47654802}
     
    47694806Void TEncSearch::xEstimateMvPredAMVP( TComDataCU* pcCU, TComYuv* pcOrgYuv, UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMvPred, Bool bFilled, Distortion* puiDistBiP )
    47704807{
     4808#if NH_MV
    47714809  D_PRINT_INC_INDENT(g_traceModeCheck, "xEstimateMvPredAMVP");
     4810#endif
    47724811
    47734812  AMVPInfo*  pcAMVPInfo = pcCU->getCUMvField(eRefPicList)->getAMVPInfo();
     
    48474886    if(pcCU->getSlice()->getMvdL1ZeroFlag() && eRefPicList==REF_PIC_LIST_1)
    48484887    {
     4888#if NH_MV
    48494889      D_PRINT_INC_INDENT(g_traceModeCheck, "Init");
     4890#endif
    48504891
    48514892      (*puiDistBiP) = xGetTemplateCost( pcCU, uiPartAddr, pcOrgYuv, &m_cYuvPredTemp, rcMvPred, 0, AMVP_MAX_NUM_CANDS, eRefPicList, iRefIdx, iRoiWidth, iRoiHeight);
    48524893
     4894#if NH_MV
    48534895      D_DEC_INDENT( g_traceModeCheck );
     4896#endif
    48544897    }
    48554898    return;
     
    48674910  for ( i = 0 ; i < pcAMVPInfo->iN; i++)
    48684911  {
     4912#if NH_MV
    48694913    D_PRINT_INC_INDENT(g_traceModeCheck, "Cand i=" +  n2s(i) + " X: " + n2s( pcAMVPInfo->m_acMvCand[i].getHor() ) + " Y: " + n2s( pcAMVPInfo->m_acMvCand[i].getVer() ));
     4914#endif
    48704915
    48714916    Distortion uiTmpCost;
     
    48794924    }
    48804925
     4926#if NH_MV
    48814927    D_DEC_INDENT( g_traceModeCheck );
     4928#endif
    48824929  }
    48834930
     
    48894936  pcCU->setMVPNumSubParts( pcAMVPInfo->iN, eRefPicList, uiPartAddr, uiPartIdx, pcCU->getDepth(uiPartAddr));
    48904937
     4938#if NH_MV
    48914939  D_DEC_INDENT( g_traceModeCheck );
     4940#endif
    48924941
    48934942  return;
     
    50945143Void TEncSearch::xMotionEstimation( TComDataCU* pcCU, TComYuv* pcYuvOrg, Int iPartIdx, RefPicList eRefPicList, TComMv* pcMvPred, Int iRefIdxPred, TComMv& rcMv, UInt& ruiBits, Distortion& ruiCost, Bool bBi  )
    50955144{
     5145#if NH_MV
    50965146  D_PRINT_INC_INDENT(g_traceModeCheck,  "xMotionEstimation");
     5147#endif
    50975148
    50985149  UInt          uiPartAddr;
     
    52275278  ruiCost       = (Distortion)( floor( fWeight * ( (Double)ruiCost - (Double)m_pcRdCost->getCost( uiMvBits ) ) ) + (Double)m_pcRdCost->getCost( ruiBits ) );
    52285279 
     5280#if NH_MV
    52295281  D_PRINT_INDENT(g_traceRDCost, "ME Cost:" + n2s(ruiCost)  );
    52305282  D_DEC_INDENT  ( g_traceModeCheck );
     5283#endif
    52315284}
    52325285
     
    57885841                                            Bool bSkipResidual DEBUG_STRING_FN_DECLARE(sDebug) )
    57895842{
     5843#if NH_MV
    57905844  D_PRINT_INC_INDENT(g_traceModeCheck, "encodeResAndCalcRdInterCU; Skip residual: " + n2s(bSkipResidual));
     5845#endif
    57915846
    57925847  assert ( !pcCU->isIntra(0) );
     
    58835938    }
    58845939#endif
     5940#if NH_MV
    58855941    D_DEC_INDENT( g_traceModeCheck );
     5942#endif
    58865943
    58875944    return;
     
    60496106  }
    60506107#endif
     6108#if NH_MV
    60516109  D_DEC_INDENT( g_traceModeCheck );
     6110#endif
    60526111}
    60536112
     
    62076266                                           DEBUG_STRING_FN_DECLARE(sDebug) )
    62086267{
     6268#if NH_MV
    62096269  D_PRINT_INC_INDENT(g_traceModeCheck, "xEstimateInterResidualQT");
     6270#endif
    62106271
    62116272  TComDataCU *pcCU        = rTu.getCU();
     
    62606321  if( bCheckFull )
    62616322  {
     6323#if NH_MV
    62626324    D_PRINT_INC_INDENT(g_traceModeCheck,  "bCheckFull" );
     6325#endif
    62636326
    62646327    Double minCost[MAX_NUM_COMPONENT][2/*0 = top (or whole TU for non-4:2:2) sub-TU, 1 = bottom sub-TU*/];
     
    63496412          for (Int transformSkipModeId = 0; transformSkipModeId < transformSkipModesToTest; transformSkipModeId++)
    63506413          {
     6414#if NH_MV
    63516415            D_PRINT_INC_INDENT( g_traceModeCheck && ( transformSkipModeId > 0) , "TransformSkipModeId: " + n2s(transformSkipModeId) );
     6416#endif
    63526417
    63536418            pcCU->setTransformSkipPartRange(transformSkipModeId, compID, subTUAbsPartIdx, partIdxesPerSubTU);
     
    63586423              const Bool bUseCrossCPrediction = crossCPredictionModeId != 0;
    63596424
     6425#if NH_MV
    63606426              D_PRINT_INC_INDENT( g_traceModeCheck, "Zero" );             
     6427#endif
    63616428
    63626429              m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] );
     
    65116578              }
    65126579
     6580
    65136581              DEBUG_STRING_NEW(sSingleStringTest)
    6514 
    6515               D_DEC_INDENT( g_traceModeCheck );
    6516 
     6582#if NH_MV
     6583                D_DEC_INDENT( g_traceModeCheck );
     6584#endif
    65176585              if( currAbsSum > 0 ) //if non-zero coefficients are present, a residual needs to be derived for further prediction
    65186586              {
     6587#if NH_MV
    65196588                D_PRINT_INC_INDENT(g_traceModeCheck, "NonZero");
     6589#endif
    65206590
    65216591                if (isFirstMode)
     
    66116681                currCompCost = nonCoeffCost;
    66126682              }
     6683#if NH_MV
    66136684              D_DEC_INDENT( g_traceModeCheck );
     6685#endif
    66146686
    66156687              // evaluate
     
    66896761              }
    66906762            }
     6763#if NH_MV
    66916764            D_DEC_INDENT( g_traceModeCheck );
     6765#endif
    66926766          }
    66936767
     
    67006774    } // component loop
    67016775
     6776#if NH_MV
    67026777    D_PRINT_INC_INDENT(g_traceModeCheck,  "Final");
     6778#endif
    67036779
    67046780    for(UInt ch = 0; ch < numValidComp; ch++)
     
    67586834      dSingleCost = m_pcRdCost->calcRdCost( uiSingleBits, uiSingleDist );
    67596835
     6836#if NH_MV
    67606837      D_DEC_INDENT( g_traceModeCheck );
    67616838      D_DEC_INDENT( g_traceModeCheck );
     6839#endif
    67626840  } // check full
    67636841
     
    67656843  if( bCheckSplit )
    67666844  {
     6845#if NH_MV
    67676846    D_PRINT_INC_INDENT(g_traceModeCheck,  "bCheckSplit" );
     6847#endif
    67686848    if( bCheckFull )
    67696849    {
     
    69357015      m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_TEST ] );
    69367016    }
     7017#if NH_MV
    69377018    D_DEC_INDENT( g_traceModeCheck );
     7019#endif
    69387020  }
    69397021  else
     
    69557037#endif
    69567038  }
     7039#if NH_MV
    69577040  D_DEC_INDENT( g_traceModeCheck );
     7041#endif
    69587042  DEBUG_STRING_APPEND(sDebug, debug_reorder_data_inter_token[MAX_NUM_COMPONENT])
     7043
    69597044}
    69607045
  • branches/HTM-15.0-dev0/source/Lib/TLibEncoder/TEncSearch.h

    r1313 r1317  
    351351#endif
    352352
     353#if NH_3D_DMM
    353354  // -------------------------------------------------------------------------------------------------------------------
    354355  // Depth intra search
    355356  // -------------------------------------------------------------------------------------------------------------------
    356 #if NH_3D_DMM
     357
    357358  Void xCalcBiSegDCs              ( Pel* ptrSrc, UInt srcStride, Bool* biSegPattern, Int patternStride, Pel& valDC1, Pel& valDC2, Pel defaultVal, Bool subSamp = false );
    358359  Void xSearchDmmDeltaDCs         ( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piOrig, Pel* piPredic, UInt uiStride, Bool* biSegPattern, Int patternStride, UInt uiWidth, UInt uiHeight, Pel& rDeltaDC1, Pel& rDeltaDC2 );
  • branches/HTM-15.0-dev0/source/Lib/TLibEncoder/TEncTop.cpp

    r1313 r1317  
    8383  m_aICEnableNum = NULL;
    8484#endif
    85 #if NH_3D
     85#if NH_MV
    8686  m_cCavlcCoder.setEncTop(this);
    8787#endif
     
    350350    m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcPicCurr ) );
    351351  }
    352 #if NH_MV
    353352  pcPicCurr->setLayerId( getLayerId());
    354 #endif
    355353#if NH_3D
    356354  pcPicCurr->setScaleOffset( m_cameraParameters->getCodedScale(), m_cameraParameters->getCodedOffset() );
     
    361359Void TEncTop::deletePicBuffer()
    362360{
     361
     362#if !NH_MV
    363363  TComList<TComPic*>::iterator iterPic = m_cListPic.begin();
    364364  Int iSize = Int( m_cListPic.size() );
    365 
    366365  for ( Int i = 0; i < iSize; i++ )
    367366  {
     
    372371    pcPic = NULL;
    373372  }
     373#endif
    374374}
    375375
     
    404404  if( gopId == 0)
    405405  {
    406     m_cGOPEncoder.initGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut); 
     406    m_cGOPEncoder.initGOP(m_iPOCLast, m_iNumPicRcvd, *(m_ivPicLists->getSubDpb( getLayerId(), false )), rcListPicYuvRecOut, accessUnitsOut); 
    407407#else
    408408  if (pcPicYuvOrg != NULL)
     
    434434#if NH_MV
    435435  }
    436   m_cGOPEncoder.compressPicInGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, false, false, snrCSC, m_printFrameMSE, gopId);
     436  m_cGOPEncoder.compressPicInGOP(m_iPOCLast, m_iNumPicRcvd, *(m_ivPicLists->getSubDpb(getLayerId(), false) ), rcListPicYuvRecOut, accessUnitsOut, false, false, snrCSC, m_printFrameMSE, gopId);
    437437
    438438  if( gopId + 1 == m_cGOPEncoder.getGOPSize() )
     
    574574  // At this point, the SPS and PPS can be considered activated - they are copied to the new TComPic.
    575575
     576#if NH_MV
     577  TComList<TComPic*>& cListPic = *(m_ivPicLists->getSubDpb(getLayerId(), false) );
     578  TComSlice::sortPicList(cListPic);
     579#else
    576580  TComSlice::sortPicList(m_cListPic);
    577 
    578 
     581#endif
     582
     583
     584#if NH_MV
     585  if (cListPic.size() >= (UInt)(m_iGOPSize + getMaxDecPicBuffering(MAX_TLAYER-1) + 2) )
     586  {
     587    TComList<TComPic*>::iterator iterPic  = cListPic.begin();
     588    Int iSize = Int( cListPic.size() );
     589#else
    579590  if (m_cListPic.size() >= (UInt)(m_iGOPSize + getMaxDecPicBuffering(MAX_TLAYER-1) + 2) )
    580591  {
    581592    TComList<TComPic*>::iterator iterPic  = m_cListPic.begin();
    582593    Int iSize = Int( m_cListPic.size() );
     594#endif
    583595    for ( Int i = 0; i < iSize; i++ )
    584596    {
     
    604616    }
    605617
     618#if NH_MV
     619    cListPic.pushBack( rpcPic );
     620#else
    606621    m_cListPic.pushBack( rpcPic );
     622#endif
    607623  }
    608624  rpcPic->setReconMark (false);
     
    10561072  m_cPPS.setOutputFlagPresentFlag( false );
    10571073#if NH_MV
    1058 #if NH_MV_FIX_TICKET_100
    10591074  m_cPPS.setNumExtraSliceHeaderBits( 2 );
    1060 #else
    1061   m_cPPS.setNumExtraSliceHeaderBits( 3 );
    1062 #endif
    10631075#endif
    10641076  m_cPPS.setSignHideFlag(getSignHideFlag());
  • branches/HTM-15.0-dev0/source/Lib/TLibEncoder/TEncTop.h

    r1313 r1317  
    7676  Int                     m_iNumPicRcvd;                  ///< number of received pictures
    7777  UInt                    m_uiNumAllPicCoded;             ///< number of coded pictures
     78#if !NH_MV
    7879  TComList<TComPic*>      m_cListPic;                     ///< dynamic list of pictures
     80#endif
    7981
    8082#if NH_MV
     
    170172  // -------------------------------------------------------------------------------------------------------------------
    171173
     174#if NH_MV
     175  TComList<TComPic*>*     getListPic            () { return  m_ivPicLists->getSubDpb( getLayerId(), false);             }
     176#else
    172177  TComList<TComPic*>*     getListPic            () { return  &m_cListPic;             }
     178#endif
    173179  TEncSearch*             getPredSearch         () { return  &m_cSearch;              }
    174180
Note: See TracChangeset for help on using the changeset viewer.