Changeset 815 in SHVCSoftware


Ignore:
Timestamp:
30 Jun 2014, 06:13:06 (11 years ago)
Author:
seregin
Message:

merge with SHM-6-dev branch

Location:
trunk
Files:
50 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/SHM.xcodeproj/project.pbxproj

    r125 r815  
    131131                71AD603A11EBC28D00F5F1FE /* libTLibEncoder.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6767961911AD626F00421804 /* libTLibEncoder.a */; };
    132132                71AD603B11EBC29600F5F1FE /* libTLibVideoIO.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6767964B11AD629200421804 /* libTLibVideoIO.a */; };
     133                C3D5A69A190AD6DA005E0EBE /* TCom3DAsymLUT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C3D5A698190AD6DA005E0EBE /* TCom3DAsymLUT.cpp */; };
     134                C3D5A69B190AD6DA005E0EBE /* TCom3DAsymLUT.h in Headers */ = {isa = PBXBuildFile; fileRef = C3D5A699190AD6DA005E0EBE /* TCom3DAsymLUT.h */; };
     135                C3D5A69E190AD6F8005E0EBE /* TEnc3DAsymLUT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C3D5A69C190AD6F8005E0EBE /* TEnc3DAsymLUT.cpp */; };
     136                C3D5A69F190AD6F8005E0EBE /* TEnc3DAsymLUT.h in Headers */ = {isa = PBXBuildFile; fileRef = C3D5A69D190AD6F8005E0EBE /* TEnc3DAsymLUT.h */; };
    133137                DB7795C213F1226500C92469 /* TEncPic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DB7795BE13F1226500C92469 /* TEncPic.cpp */; };
    134138                DB7795C313F1226500C92469 /* TEncPic.h in Headers */ = {isa = PBXBuildFile; fileRef = DB7795BF13F1226500C92469 /* TEncPic.h */; };
     
    340344                7184647513FAE75800747BF9 /* program_options_lite.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = program_options_lite.cpp; path = source/Lib/TAppCommon/program_options_lite.cpp; sourceTree = "<group>"; };
    341345                7184647613FAE75800747BF9 /* program_options_lite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = program_options_lite.h; path = source/Lib/TAppCommon/program_options_lite.h; sourceTree = "<group>"; };
     346                C3D5A698190AD6DA005E0EBE /* TCom3DAsymLUT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TCom3DAsymLUT.cpp; path = source/Lib/TLibCommon/TCom3DAsymLUT.cpp; sourceTree = "<group>"; };
     347                C3D5A699190AD6DA005E0EBE /* TCom3DAsymLUT.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TCom3DAsymLUT.h; path = source/Lib/TLibCommon/TCom3DAsymLUT.h; sourceTree = "<group>"; };
     348                C3D5A69C190AD6F8005E0EBE /* TEnc3DAsymLUT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TEnc3DAsymLUT.cpp; path = source/Lib/TLibEncoder/TEnc3DAsymLUT.cpp; sourceTree = "<group>"; };
     349                C3D5A69D190AD6F8005E0EBE /* TEnc3DAsymLUT.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TEnc3DAsymLUT.h; path = source/Lib/TLibEncoder/TEnc3DAsymLUT.h; sourceTree = "<group>"; };
    342350                DB7795BE13F1226500C92469 /* TEncPic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TEncPic.cpp; path = source/Lib/TLibEncoder/TEncPic.cpp; sourceTree = "<group>"; };
    343351                DB7795BF13F1226500C92469 /* TEncPic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TEncPic.h; path = source/Lib/TLibEncoder/TEncPic.h; sourceTree = "<group>"; };
     
    464472                        isa = PBXGroup;
    465473                        children = (
     474                                C3D5A698190AD6DA005E0EBE /* TCom3DAsymLUT.cpp */,
     475                                C3D5A699190AD6DA005E0EBE /* TCom3DAsymLUT.h */,
    466476                                6B635E7516E5EAB60057B313 /* TComUpsampleFilter.h */,
    467477                                6B635E7616E5EAB60057B313 /* TComUpsampleFilter.cpp */,
     
    563573                        isa = PBXGroup;
    564574                        children = (
     575                                C3D5A69C190AD6F8005E0EBE /* TEnc3DAsymLUT.cpp */,
     576                                C3D5A69D190AD6F8005E0EBE /* TEnc3DAsymLUT.h */,
    565577                                71206CD916066EDD00A354E7 /* SyntaxElementWriter.cpp */,
    566578                                71206CDA16066EDD00A354E7 /* SyntaxElementWriter.h */,
     
    670682                                676795D211AD61FC00421804 /* TComList.h in Headers */,
    671683                                676795D411AD61FC00421804 /* TComLoopFilter.h in Headers */,
     684                                C3D5A69B190AD6DA005E0EBE /* TCom3DAsymLUT.h in Headers */,
    672685                                676795D611AD61FC00421804 /* TComMotionInfo.h in Headers */,
    673686                                676795D911AD61FC00421804 /* TComPattern.h in Headers */,
     
    685698                                671E0D4C11B6AD8C00F3747B /* ContextModel3DBuffer.h in Headers */,
    686699                                671E0D4F11B6AD8C00F3747B /* TComBitCounter.h in Headers */,
     700                                C3D5A69F190AD6F8005E0EBE /* TEnc3DAsymLUT.h in Headers */,
    687701                                671E0D5111B6AD8C00F3747B /* TComCABACTables.h in Headers */,
    688702                                671E0D5211B6AD8C00F3747B /* TComMv.h in Headers */,
     
    932946                        buildActionMask = 2147483647;
    933947                        files = (
     948                                C3D5A69E190AD6F8005E0EBE /* TEnc3DAsymLUT.cpp in Sources */,
    934949                                676795CE11AD61FC00421804 /* TComBitStream.cpp in Sources */,
    935950                                676795D011AD61FC00421804 /* TComDataCU.cpp in Sources */,
     
    939954                                676795DA11AD61FC00421804 /* TComPic.cpp in Sources */,
    940955                                676795DC11AD61FC00421804 /* TComPicSym.cpp in Sources */,
     956                                C3D5A69A190AD6DA005E0EBE /* TCom3DAsymLUT.cpp in Sources */,
    941957                                676795DE11AD61FC00421804 /* TComPicYuv.cpp in Sources */,
    942958                                676795E211AD61FC00421804 /* TComPrediction.cpp in Sources */,
     
    10981114                                HEADER_SEARCH_PATHS = source/Lib;
    10991115                                ONLY_ACTIVE_ARCH = YES;
    1100                                 SDKROOT = macosx;
     1116                                SDKROOT = macosx10.8;
    11011117                        };
    11021118                        name = Debug;
     
    11121128                                GCC_WARN_UNUSED_VARIABLE = YES;
    11131129                                HEADER_SEARCH_PATHS = source/Lib;
    1114                                 SDKROOT = macosx;
     1130                                SDKROOT = macosx10.8;
    11151131                        };
    11161132                        name = Release;
  • trunk/cfg

  • trunk/cfg/layers.cfg

    r713 r815  
    4141InitialQP1                    : 0           # Rate control: initial QP for layer 1
    4242RCForceIntraQP1               : 0           # Rate control: force intra QP to be equal to initial QP for layer 1
     43
     44
     45NumLayerSets                  : 1
     46NumLayerInIdList0             : 2
     47LayerSetLayerIdList0          : 0 1
     48
     49NumAddLayerSets               : 0
  • trunk/source

  • trunk/source/App/TAppDecoder/TAppDecCfg.cpp

    r713 r815  
    146146  m_tgtLayerId = nLayerNum - 1;
    147147  assert( m_tgtLayerId >= 0 );
     148  assert( m_tgtLayerId < MAX_LAYERS );
    148149#if O0137_MAX_LAYERID
    149150  assert( m_tgtLayerId < MAX_NUM_LAYER_IDS );
  • trunk/source/App/TAppDecoder/TAppDecTop.cpp

    r713 r815  
    191191    InputNALUnit nalu;
    192192    byteStreamNALUnit(bytestream, nalUnit, stats);
    193 
    194193    // call actual decoding function
    195194    Bool bNewPicture = false;
     
    215214      {
    216215        bNewPicture = m_acTDecTop[nalu.m_layerId].decode(nalu, m_iSkipFrame, m_aiPOCLastDisplay[nalu.m_layerId], curLayerId, bNewPOC);
     216#if POC_RESET_IDC_DECODER
     217        if ( (bNewPicture && m_acTDecTop[nalu.m_layerId].getParseIdc() == 3) || (m_acTDecTop[nalu.m_layerId].getParseIdc() == 0) )
     218#else
    217219        if (bNewPicture)
     220#endif
    218221        {
    219222          bitstreamFile.clear();
     
    225228          bytestream.reset();
    226229        }
    227       }
    228     }
    229 
     230#if POC_RESET_IDC_DECODER
     231        else if(m_acTDecTop[nalu.m_layerId].getParseIdc() == 1)
     232        {
     233          bitstreamFile.clear();
     234          // This is before third parse of the NAL unit, and
     235          // location points to correct beginning of the NALU
     236          bitstreamFile.seekg(location);
     237          bytestream.reset();
     238        }
     239#endif
     240      }
     241    }
     242
     243#if POC_RESET_IDC_DECODER
     244    if ((bNewPicture && m_acTDecTop[nalu.m_layerId].getParseIdc() == 3) || (m_acTDecTop[nalu.m_layerId].getParseIdc() == 0) || !bitstreamFile || nalu.m_nalUnitType == NAL_UNIT_EOS)
     245#else
    230246    if (bNewPicture || !bitstreamFile || nalu.m_nalUnitType == NAL_UNIT_EOS)
     247#endif
    231248    {
    232249#if O0194_DIFFERENT_BITDEPTH_EL_BL
     
    245262    }
    246263
     264#if POC_RESET_IDC_DECODER
     265    if( bNewPicture && m_acTDecTop[nalu.m_layerId].getParseIdc() == 0 )
     266    {
     267      outputAllPictures( nalu.m_layerId, true );
     268    }
     269#endif
     270
    247271    if( pcListPic )
    248272    {
     
    269293        flushAllPictures( nalu.m_layerId, outputPicturesFlag );       
    270294      }
     295
     296#if POC_RESET_IDC_DECODER
     297      if( bNewPicture && m_acTDecTop[nalu.m_layerId].getParseIdc() != 0 )
     298      // New picture, slice header parsed but picture not decoded
     299#else
    271300      if( bNewPicture ) // New picture, slice header parsed but picture not decoded
     301#endif
    272302      {
    273303#if NO_OUTPUT_OF_PRIOR_PICS
     
    12351265
    12361266    // Find the status of the DPB
     1267#if POC_RESET_IDC_DECODER
     1268    xFindDPBStatus(listOfPocs, listOfPocsInEachLayer, listOfPocsPositionInEachLayer, dpbStatus, false);
     1269#else
    12371270    xFindDPBStatus(listOfPocs, listOfPocsInEachLayer, listOfPocsPositionInEachLayer, dpbStatus);
     1271#endif
    12381272
    12391273    while( dpbStatus.m_numAUsNotDisplayed )
     
    12821316  // Find DPB-information from the VPS
    12831317  DpbStatus maxDpbLimit;
     1318#if RESOLUTION_BASED_DPB
    12841319  Int targetLsIdx, subDpbIdx;
    12851320  TComVPS *vps = findDpbParametersFromVps(listOfPocs, listOfPocsInEachLayer, listOfPocsPositionInEachLayer, maxDpbLimit);
     1321
    12861322  if( getCommonDecoderParams()->getTargetOutputLayerSetIdx() == 0 )
    12871323  {
     
    12941330    subDpbIdx   = vps->getSubDpbAssigned( targetLsIdx, layerIdx );
    12951331  }
     1332#else
     1333  Int subDpbIdx = getCommonDecoderParams()->getTargetOutputLayerSetIdx() == 0 ? 0 : layerIdx;
     1334  findDpbParametersFromVps(listOfPocs, listOfPocsInEachLayer, listOfPocsPositionInEachLayer, maxDpbLimit);
     1335#endif
    12961336  // Assume that listOfPocs is sorted in increasing order - if not have to sort it.
    12971337  while( ifInvokeBumpingBeforeDecoding(dpbStatus, maxDpbLimit, layerIdx, subDpbIdx) )
     
    14371477    for(Int i = 0; i < vps->getNumLayersInIdList( targetLsIdx ); i++)
    14381478    {
     1479#if RESOUTION_BASED_DPB
    14391480      maxDpbLimit.m_numPicsInLayer[i] = vps->getMaxVpsLayerDecPicBuffMinus1( targetOutputLsIdx, i, highestTId ) + 1;
    14401481      maxDpbLimit.m_numPicsInSubDpb[vps->getSubDpbAssigned( targetLsIdx, i )] = vps->getMaxVpsDecPicBufferingMinus1( targetOutputLsIdx, vps->getSubDpbAssigned( targetLsIdx, i ), highestTId) + 1;
     1482#else
     1483      maxDpbLimit.m_numPicsInSubDpb[i] = vps->getMaxVpsDecPicBufferingMinus1( targetOutputLsIdx, i, highestTId) + 1;
     1484#endif
    14411485    }
    14421486    // -------------------------------------
     
    14721516  retVal |= ( dpbStatus.m_numPicsInSubDpb[subDpbIdx] >= dpbLimit.m_numPicsInSubDpb[subDpbIdx] );
    14731517 
     1518#if RESOLUTION_BASED_DPB
    14741519  // Number of pictures in each layer
    14751520  retVal |= ( dpbStatus.m_numPicsInLayer[layerIdx] >= dpbLimit.m_numPicsInLayer[layerIdx]);
     1521#endif
    14761522
    14771523  return retVal;
     
    14921538                            , std::vector<Int> *listOfPocsPositionInEachLayer
    14931539                            , DpbStatus &dpbStatus
     1540#if POC_RESET_IDC_DECODER
     1541                            , Bool notOutputCurrAu
     1542#endif
    14941543                            )
    14951544{
     
    15161565          vps = pic->getSlice(0)->getVPS();
    15171566        }
    1518 
    1519         std::vector<Int>::iterator it;
    1520         if( pic->getOutputMark() ) // && pic->getPOC() > m_aiPOCLastDisplay[i])
    1521         {
    1522           it = find( listOfPocs.begin(), listOfPocs.end(), pic->getPOC() ); // Check if already included
    1523           if( it == listOfPocs.end() )  // New POC value - i.e. new AU - add to the list
     1567#if POC_RESET_IDC_DECODER
     1568        if( !(pic->isCurrAu() && notOutputCurrAu ) )
     1569        {
     1570#endif
     1571          std::vector<Int>::iterator it;
     1572          if( pic->getOutputMark() ) // && pic->getPOC() > m_aiPOCLastDisplay[i])
    15241573          {
    1525             listOfPocs.push_back( pic->getPOC() );
     1574            it = find( listOfPocs.begin(), listOfPocs.end(), pic->getPOC() ); // Check if already included
     1575            if( it == listOfPocs.end() )  // New POC value - i.e. new AU - add to the list
     1576            {
     1577              listOfPocs.push_back( pic->getPOC() );
     1578            }
     1579            listOfPocsInEachLayer         [i].push_back( pic->getPOC()    );    // POC to be output in each layer
     1580            listOfPocsPositionInEachLayer [i].push_back( picPositionInList  );  // For ease of access
    15261581          }
    1527           listOfPocsInEachLayer         [i].push_back( pic->getPOC()    );    // POC to be output in each layer
    1528           listOfPocsPositionInEachLayer [i].push_back( picPositionInList  );  // For ease of access
    1529         }
    1530         if( pic->getSlice(0)->isReferenced() || pic->getOutputMark() )
    1531         {
    1532           dpbStatus.m_numPicsInLayer[i]++;  // Count pictures that are "used for reference" or "needed for output"
    1533         }
     1582          if( pic->getSlice(0)->isReferenced() || pic->getOutputMark() )
     1583          {
     1584            dpbStatus.m_numPicsInLayer[i]++;  // Count pictures that are "used for reference" or "needed for output"
     1585          }
     1586#if POC_RESET_IDC_DECODER
     1587        }
     1588#endif
    15341589      }
    15351590      iterPic++;
     
    15501605  {
    15511606    dpbStatus.m_numPicsNotDisplayedInLayer[i] = listOfPocsInEachLayer[i].size();
     1607#if RESOLUTION_BASED_DPB
    15521608    dpbStatus.m_numPicsInSubDpb[vps->getSubDpbAssigned(targetLsIdx,i)] += dpbStatus.m_numPicsInLayer[i];
     1609#else
     1610    dpbStatus.m_numPicsInSubDpb[i] += dpbStatus.m_numPicsInLayer[i];
     1611#endif
    15531612  }
    15541613  assert( dpbStatus.m_numAUsNotDisplayed != -1 );
    1555 
    1556 
    15571614
     1615
     1616#if POC_RESET_IDC_DECODER
     1617Void TAppDecTop::outputAllPictures(Int layerId, Bool notOutputCurrPic)
     1618{
     1619  { // All pictures in the DPB in that layer are to be output; this means other pictures would also be output
     1620    std::vector<Int>  listOfPocs;
     1621    std::vector<Int>  listOfPocsInEachLayer[MAX_LAYERS];
     1622    std::vector<Int>  listOfPocsPositionInEachLayer[MAX_LAYERS];
     1623    DpbStatus dpbStatus;
     1624
     1625    // Find the status of the DPB
     1626    xFindDPBStatus(listOfPocs, listOfPocsInEachLayer, listOfPocsPositionInEachLayer, dpbStatus, notOutputCurrPic);
     1627
     1628    if( listOfPocs.size() )
     1629    {
     1630      while( listOfPocsInEachLayer[layerId].size() )    // As long as there picture in the layer to be output
     1631      {
     1632        bumpingProcess( listOfPocs, listOfPocsInEachLayer, listOfPocsPositionInEachLayer, dpbStatus );
     1633      }
     1634    }
     1635  }
     1636}
     1637#endif
    15581638#endif
    15591639//! \}
  • trunk/source/App/TAppDecoder/TAppDecTop.h

    r644 r815  
    107107
    108108  Void xOutputAndMarkPic( TComPic *pic, const Char *reconFile, const Int layerID, Int &pocLastDisplay, DpbStatus &dpbStatus);
     109#if POC_RESET_IDC_DECODER
     110  Void outputAllPictures(Int layerId, Bool notOutputCurrAu);
     111#endif
    109112  Void xFindDPBStatus( std::vector<Int> &listOfPocs
    110113                            , std::vector<Int> *listOfPocsInEachLayer
    111114                            , std::vector<Int> *listOfPocsPositionInEachLayer
    112115                            , DpbStatus &dpbStatus
     116#if POC_RESET_IDC_DECODER
     117                            , Bool notOutputCurrAu = true
     118#endif
    113119                            );
    114120
  • trunk/source/App/TAppEncoder/TAppEncCfg.cpp

    r713 r815  
    6969, m_avcBaseLayerFlag(0)
    7070#endif
    71 #if N0120_MAX_TID_REF_CFG
    7271, m_maxTidRefPresentFlag(1)
    73 #endif
    7472, m_pColumnWidth()
    7573, m_pRowHeight()
     
    420418  Int*    cfg_OutputBitDepthC   [MAX_LAYERS];
    421419#endif
    422 #if N0120_MAX_TID_REF_CFG
    423420  Int*    cfg_maxTidIlRefPicsPlus1[MAX_LAYERS];
    424 #endif
    425421  for(UInt layer = 0; layer < MAX_LAYERS; layer++)
    426422  {
     
    491487  cfg_OutputBitDepthC  [layer] = &m_acLayerCfg[layer].m_outputBitDepthC;
    492488#endif
    493 #if N0120_MAX_TID_REF_CFG
    494     cfg_maxTidIlRefPicsPlus1[layer] = &m_acLayerCfg[layer].m_maxTidIlRefPicsPlus1;
    495 #endif
     489  cfg_maxTidIlRefPicsPlus1[layer] = &m_acLayerCfg[layer].m_maxTidIlRefPicsPlus1;
    496490#if AUXILIARY_PICTURES
    497491    cfg_auxId[layer]                = &m_acLayerCfg[layer].m_auxId;
    498492#endif
    499493  }
     494#if Q0078_ADD_LAYER_SETS
     495  Int* cfg_numLayerInIdList[MAX_VPS_LAYER_SETS_PLUS1];
     496  string cfg_layerSetLayerIdList[MAX_VPS_LAYER_SETS_PLUS1];
     497  string* cfg_layerSetLayerIdListPtr[MAX_VPS_LAYER_SETS_PLUS1];
     498  Int* cfg_numHighestLayerIdx[MAX_VPS_LAYER_SETS_PLUS1];
     499  string cfg_highestLayerIdx[MAX_VPS_LAYER_SETS_PLUS1];
     500  string* cfg_highestLayerIdxPtr[MAX_VPS_LAYER_SETS_PLUS1];
     501  for (UInt i = 0; i < MAX_VPS_LAYER_SETS_PLUS1; i++)
     502  {
     503    cfg_numLayerInIdList[i] = &m_numLayerInIdList[i];
     504    cfg_layerSetLayerIdListPtr[i] = &cfg_layerSetLayerIdList[i];
     505    cfg_highestLayerIdxPtr[i] = &cfg_highestLayerIdx[i];
     506    cfg_numHighestLayerIdx[i] = &m_numHighestLayerIdx[i];
     507  }
     508#endif
    500509#if AVC_BASE
    501510  string  cfg_BLInputFile;
     
    519528  string cfg_codedPivotValue;
    520529  string cfg_targetPivotValue;
     530#if P0050_KNEE_FUNCTION_SEI
     531  string cfg_kneeSEIInputKneePointValue;
     532  string cfg_kneeSEIOutputKneePointValue;
     533#endif
    521534  po::Options opts;
    522535  opts.addOptions()
     
    548561#endif
    549562  ("NumLayers",               m_numLayers, 1, "Number of layers to code")
     563#if Q0078_ADD_LAYER_SETS
     564  ("NumLayerSets",            m_numLayerSets, 0, "Number of layer sets")
     565  ("NumLayerInIdList%d",      cfg_numLayerInIdList, 0, MAX_VPS_LAYER_ID_PLUS1, "Number of layers in the set")
     566  ("LayerSetLayerIdList%d",   cfg_layerSetLayerIdListPtr, string(""), MAX_VPS_LAYER_ID_PLUS1, "Layer IDs for the set")
     567  ("NumAddLayerSets",         m_numAddLayerSets, 0, "Number of additional layer sets")
     568  ("NumHighestLayerIdx%d",    cfg_numHighestLayerIdx, 0, MAX_VPS_LAYER_ID_PLUS1, "Number of highest layer idx")
     569  ("HighestLayerIdx%d",       cfg_highestLayerIdxPtr, string(""), MAX_VPS_LAYER_ID_PLUS1, "Highest layer idx for an additional layer set")
     570#endif
    550571#if AUXILIARY_PICTURES
    551572  ("InputChromaFormat%d",     cfg_tmpInputChromaFormat,  420, MAX_LAYERS, "InputChromaFormatIDC for layer %d")
     
    554575#endif
    555576  ("ConformanceMode%d",       cfg_conformanceMode,0, MAX_LAYERS, "Window conformance mode (0: no cropping, 1:automatic padding, 2: padding, 3:cropping")
    556 #if SCALABILITY_MASK_E0104
    557577  ("ScalabilityMask1",        m_scalabilityMask[1], 0, "scalability_mask[1] (multiview)")
    558578  ("ScalabilityMask2",        m_scalabilityMask[2], 1, "scalability_mask[2] (scalable)" )
    559579#if AUXILIARY_PICTURES
    560580  ("ScalabilityMask3",        m_scalabilityMask[3], 0, "scalability_mask[3] (auxiliary pictures)" )
    561 #endif
    562 #else
    563   ("ScalabilityMask0",        m_scalabilityMask[0], 0, "scalability_mask[0] (multiview)")
    564   ("ScalabilityMask1",        m_scalabilityMask[1], 1, "scalability_mask[1] (scalable)" )
    565581#endif
    566582  ("BitstreamFile,b",         cfg_BitstreamFile, string(""), "Bitstream output file name")
     
    598614  ("OutputBitDepthC%d",     cfg_OutputBitDepthC,   0, MAX_LAYERS, "As per OutputBitDepth but for chroma component. (default:InternalBitDepthC)")
    599615#endif
    600 #if N0120_MAX_TID_REF_CFG
    601616  ("MaxTidRefPresentFlag", m_maxTidRefPresentFlag, true, "max_tid_ref_present_flag (0: not present, 1: present(default)) " )
    602617  ("MaxTidIlRefPicsPlus1%d", cfg_maxTidIlRefPicsPlus1, 1, MAX_LAYERS, "allowed maximum temporal_id for inter-layer prediction")
    603 #endif
    604618#if O0223_PICTURE_TYPES_ALIGN_FLAG
    605619  ("CrossLayerPictureTypeAlignFlag", m_crossLayerPictureTypeAlignFlag, true, "align picture type across layers" ) 
    606620#endif
    607 #if N0147_IRAP_ALIGN_FLAG
    608621  ("CrossLayerIrapAlignFlag", m_crossLayerIrapAlignFlag, true, "align IRAP across layers" ) 
    609 #endif
    610622#if P0068_CROSS_LAYER_ALIGNED_IDR_ONLY_FOR_IRAP_FLAG
    611623  ("CrossLayerAlignedIdrOnlyFlag", m_crossLayerAlignedIdrOnlyFlag, true, "only idr for IRAP across layers" ) 
     
    953965  ("SEISOPDescription",              m_SOPDescriptionSEIEnabled,              0, "Control generation of SOP description SEI messages")
    954966  ("SEIScalableNesting",             m_scalableNestingSEIEnabled,              0, "Control generation of scalable nesting SEI messages")
     967#if P0050_KNEE_FUNCTION_SEI
     968  ("SEIKneeFunctionInfo",                 m_kneeSEIEnabled,               false, "Control generation of Knee function SEI messages")
     969  ("SEIKneeFunctionId",                   m_kneeSEIId,                        0, "Specifies Id of Knee function SEI message for a given session")
     970  ("SEIKneeFunctionCancelFlag",           m_kneeSEICancelFlag,            false, "Indicates that Knee function SEI message cancels the persistance or follows")
     971  ("SEIKneeFunctionPersistenceFlag",      m_kneeSEIPersistenceFlag,        true, "Specifies the persistence of the Knee function SEI message")
     972  ("SEIKneeFunctionMappingFlag",          m_kneeSEIMappingFlag,           false, "Specifies the mapping mode of the Knee function SEI message")
     973  ("SEIKneeFunctionInputDrange",          m_kneeSEIInputDrange,            1000, "Specifies the peak luminance level for the input picture of Knee function SEI messages")
     974  ("SEIKneeFunctionInputDispLuminance",   m_kneeSEIInputDispLuminance,      100, "Specifies the expected display brightness for the input picture of Knee function SEI messages")
     975  ("SEIKneeFunctionOutputDrange",         m_kneeSEIOutputDrange,           4000, "Specifies the peak luminance level for the output picture of Knee function SEI messages")
     976  ("SEIKneeFunctionOutputDispLuminance",  m_kneeSEIOutputDispLuminance,     800, "Specifies the expected display brightness for the output picture of Knee function SEI messages")
     977  ("SEIKneeFunctionNumKneePointsMinus1",  m_kneeSEINumKneePointsMinus1,       2, "Specifies the number of knee points - 1")
     978  ("SEIKneeFunctionInputKneePointValue",  cfg_kneeSEIInputKneePointValue,     string("600 800 900"), "Array of input knee point")
     979  ("SEIKneeFunctionOutputKneePointValue", cfg_kneeSEIOutputKneePointValue,    string("100 250 450"), "Array of output knee point")
     980#endif
     981#if Q0189_TMVP_CONSTRAINTS
     982  ("SEITemporalMotionVectorPredictionConstraints",             m_TMVPConstraintsSEIEnabled,              0, "Control generation of TMVP constrants SEI message")
     983#endif
    955984#if M0040_ADAPTIVE_RESOLUTION_CHANGE
    956985  ("AdaptiveResolutionChange",     m_adaptiveResolutionChange, 0, "Adaptive resolution change frame number. Should coincide with EL RAP picture. (0: disable)")
     
    9761005  ("CGSLUTBit",     m_nCGSLUTBit , 12, "bit depth of CGS LUT")
    9771006#endif
     1007#if Q0108_TSA_STSA
     1008  ("InheritCodingStruct%d",m_inheritCodingStruct, 0, MAX_LAYERS, "Predicts the GOP structure of one layer for another layer")
     1009#endif
    9781010  ;
    9791011 
     
    9831015    opts.addOptions()(cOSS.str(), m_GOPList[i-1], GOPEntry());
    9841016  }
     1017
     1018#if Q0108_TSA_STSA
     1019  for (Int i=1; i<MAX_LAYERS; i++)
     1020  {
     1021    for(Int j=1; j<MAX_GOP+1; j++)
     1022    {
     1023      std::ostringstream cOSS;
     1024      cOSS<<"Layer"<<i<<"Frame"<<j;
     1025      opts.addOptions()(cOSS.str(), m_EhGOPList[i][j-1], GOPEntry());
     1026    }
     1027  }
     1028#endif
     1029
    9851030  po::setDefaults(opts);
    9861031  const list<const Char*>& argv_unhandled = po::scanArgv(opts, argc, (const Char**) argv);
     1032
     1033#if Q0108_TSA_STSA
     1034  for (Int i=1; i<MAX_LAYERS; i++)
     1035  {
     1036    if(m_inheritCodingStruct[i] == 0)
     1037    {
     1038      for(Int j=1; j<MAX_GOP+1; j++)
     1039      {
     1040        m_EhGOPList[i][j-1] = m_GOPList[j-1];
     1041      }
     1042    }
     1043    else if( m_inheritCodingStruct[i] > 0)
     1044    {
     1045      for(Int j=1; j<MAX_GOP+1; j++)
     1046      {
     1047        m_EhGOPList[i][j-1] = m_EhGOPList[m_inheritCodingStruct[i]][j-1];
     1048      }
     1049    }
     1050  }
     1051#endif
    9871052
    9881053  if(m_isField)
     
    13091374    {
    13101375      m_acLayerCfg[layer].m_predLayerIds = NULL;
     1376    }
     1377  }
     1378#endif
     1379#if Q0078_ADD_LAYER_SETS
     1380  for (Int layerSet = 0; layerSet < m_numLayerSets; layerSet++)
     1381  {
     1382    if (m_numLayerInIdList[layerSet] > 0)
     1383    {
     1384      Char* layerSetLayerIdListDup = cfg_layerSetLayerIdList[layerSet].empty() ? NULL : strdup(cfg_layerSetLayerIdList[layerSet].c_str());
     1385      Int  i = 0;
     1386      char *layerId = strtok(layerSetLayerIdListDup, " ,-");
     1387      while (layerId != NULL)
     1388      {
     1389        if (i >= m_numLayerInIdList[layerSet])
     1390        {
     1391          printf("NumLayerInIdList%d: The number of layers in the set is larger than the allowed number of layers.\n", layerSet);
     1392          exit(EXIT_FAILURE);
     1393        }
     1394        m_layerSetLayerIdList[layerSet][i] = atoi(layerId);
     1395        layerId = strtok(NULL, " ,-");
     1396        i++;
     1397      }
     1398    }
     1399  }
     1400  for (Int addLayerSet = 0; addLayerSet < m_numAddLayerSets; addLayerSet++)
     1401  {
     1402    if (m_numHighestLayerIdx[addLayerSet] > 0)
     1403    {
     1404      Char* highestLayrIdxListDup = cfg_highestLayerIdx[addLayerSet].empty() ? NULL : strdup(cfg_highestLayerIdx[addLayerSet].c_str());
     1405      Int  i = 0;
     1406      char *layerIdx = strtok(highestLayrIdxListDup, " ,-");
     1407      while (layerIdx != NULL)
     1408      {
     1409        if (i >= m_numLayerInIdList[addLayerSet])
     1410        {
     1411          printf("NumLayerInIdList%d: The number of layer idx's in the highest layer idx list is larger than the allowed number of idx's.\n", addLayerSet);
     1412          exit(EXIT_FAILURE);
     1413        }
     1414        m_highestLayerIdx[addLayerSet][i] = atoi(layerIdx);
     1415        layerIdx = strtok(NULL, " ,-");
     1416        i++;
     1417      }
    13111418    }
    13121419  }
     
    14951602    }
    14961603  }
     1604#if P0050_KNEE_FUNCTION_SEI
     1605  if( m_kneeSEIEnabled && !m_kneeSEICancelFlag )
     1606  {
     1607    Char* pcInputKneePointValue  = cfg_kneeSEIInputKneePointValue.empty()  ? NULL : strdup(cfg_kneeSEIInputKneePointValue.c_str());
     1608    Char* pcOutputKneePointValue = cfg_kneeSEIOutputKneePointValue.empty() ? NULL : strdup(cfg_kneeSEIOutputKneePointValue.c_str());
     1609    assert ( m_kneeSEINumKneePointsMinus1 >= 0 && m_kneeSEINumKneePointsMinus1 < 999 );
     1610    m_kneeSEIInputKneePoint = new Int[m_kneeSEINumKneePointsMinus1+1];
     1611    m_kneeSEIOutputKneePoint = new Int[m_kneeSEINumKneePointsMinus1+1];
     1612    char *InputVal = strtok(pcInputKneePointValue, " .,");
     1613    Int i=0;
     1614    while( InputVal && i<(m_kneeSEINumKneePointsMinus1+1) )
     1615    {
     1616      m_kneeSEIInputKneePoint[i] = (UInt) atoi( InputVal );
     1617      InputVal = strtok(NULL, " .,");
     1618      i++;
     1619    }
     1620    char *OutputVal = strtok(pcOutputKneePointValue, " .,");
     1621    i=0;
     1622    while( OutputVal && i<(m_kneeSEINumKneePointsMinus1+1) )
     1623    {
     1624      m_kneeSEIOutputKneePoint[i] = (UInt) atoi( OutputVal );
     1625      OutputVal = strtok(NULL, " .,");
     1626      i++;
     1627    }
     1628  }
     1629#endif
    14971630
    14981631#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
     
    17421875   * This permits the ability to omit a GOP structure specification */
    17431876#if SVC_EXTENSION
     1877#if Q0108_TSA_STSA
     1878  if( m_acLayerCfg[0].m_iIntraPeriod == 1 && m_GOPList[0].m_POC == -1 )
     1879  {
     1880    m_GOPList[0] = GOPEntry();
     1881    m_GOPList[0].m_QPFactor = 1;
     1882    m_GOPList[0].m_betaOffsetDiv2 = 0;
     1883    m_GOPList[0].m_tcOffsetDiv2 = 0;
     1884    m_GOPList[0].m_POC = 1;
     1885    m_GOPList[0].m_numRefPicsActive = 4;
     1886  }
     1887
    17441888  for(UInt layer = 0; layer < MAX_LAYERS; layer++)
    17451889  {
     1890    if (m_acLayerCfg[layer].m_iIntraPeriod == 1 && m_EhGOPList[layer][0].m_POC == -1) {
     1891      m_EhGOPList[layer][0] = GOPEntry();
     1892      m_EhGOPList[layer][0].m_QPFactor = 1;
     1893      m_EhGOPList[layer][0].m_betaOffsetDiv2 = 0;
     1894      m_EhGOPList[layer][0].m_tcOffsetDiv2 = 0;
     1895      m_EhGOPList[layer][0].m_POC = 1;
     1896      m_EhGOPList[layer][0].m_numRefPicsActive = 4;
     1897    }
     1898  }
     1899#else
     1900  for(UInt layer = 0; layer < MAX_LAYERS; layer++)
     1901  {
    17461902    Int m_iIntraPeriod = m_acLayerCfg[layer].m_iIntraPeriod;
    1747 #endif
     1903    if (m_iIntraPeriod == 1 && m_GOPList[0].m_POC == -1) {
     1904      m_GOPList[0] = GOPEntry();
     1905      m_GOPList[0].m_QPFactor = 1;
     1906      m_GOPList[0].m_betaOffsetDiv2 = 0;
     1907      m_GOPList[0].m_tcOffsetDiv2 = 0;
     1908      m_GOPList[0].m_POC = 1;
     1909      m_GOPList[0].m_numRefPicsActive = 4;
     1910    }
     1911  }
     1912#endif
     1913#else
    17481914  if (m_iIntraPeriod == 1 && m_GOPList[0].m_POC == -1) {
    17491915    m_GOPList[0] = GOPEntry();
     
    17541920    m_GOPList[0].m_numRefPicsActive = 4;
    17551921  }
    1756 #if SVC_EXTENSION
    1757   }
    1758 #endif
    1759  
     1922#endif
    17601923
    17611924  Bool verifiedGOP=false;
     
    17901953  xConfirmPara( m_numLayers > MAX_LAYERS , "Number of layers in config file is greater than MAX_LAYERS" );
    17911954  m_numLayers = m_numLayers > MAX_LAYERS ? MAX_LAYERS : m_numLayers;
    1792 
    17931955 
    17941956  // it can be updated after AVC BL support will be added to the WD
     
    18271989#endif
    18281990
    1829   m_extraRPSs=0;
     1991#if !Q0108_TSA_STSA
     1992   m_extraRPSs = 0;                                     
     1993#else
     1994  memset( m_extraRPSs, 0, sizeof( m_extraRPSs ) );
     1995#endif
    18301996  //start looping through frames in coding order until we can verify that the GOP structure is correct.
    18311997  while(!verifiedGOP&&!errorGOP)
     
    18932059      {
    18942060        //create a new GOPEntry for this frame containing all the reference pictures that were available (POC > 0)
     2061#if !Q0108_TSA_STSA
    18952062        m_GOPList[m_iGOPSize+m_extraRPSs]=m_GOPList[curGOP];
     2063#else
     2064        m_GOPList[m_iGOPSize+m_extraRPSs[0]]=m_GOPList[curGOP];
     2065#endif
    18962066        Int newRefs=0;
    18972067        for(Int i = 0; i< m_GOPList[curGOP].m_numRefPics; i++)
     
    19002070          if(absPOC>=0)
    19012071          {
     2072#if !Q0108_TSA_STSA
    19022073            m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[newRefs]=m_GOPList[curGOP].m_referencePics[i];
    19032074            m_GOPList[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[newRefs]=m_GOPList[curGOP].m_usedByCurrPic[i];
     2075#else
     2076            m_GOPList[m_iGOPSize+m_extraRPSs[0]].m_referencePics[newRefs]=m_GOPList[curGOP].m_referencePics[i];
     2077            m_GOPList[m_iGOPSize+m_extraRPSs[0]].m_usedByCurrPic[newRefs]=m_GOPList[curGOP].m_usedByCurrPic[i];
     2078#endif
    19042079            newRefs++;
    19052080          }
     
    19242099            for(Int i=0; i<newRefs; i++)
    19252100            {
     2101#if !Q0108_TSA_STSA
    19262102              if(m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[i]==offPOC-curPOC)
     2103#else
     2104              if(m_GOPList[m_iGOPSize+m_extraRPSs[0]].m_referencePics[i]==offPOC-curPOC)
     2105#endif
    19272106              {
    19282107                newRef=false;
     
    19392118              for(Int j=0; j<newRefs; j++)
    19402119              {
     2120#if !Q0108_TSA_STSA
    19412121                if(m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j]<offPOC-curPOC||m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j]>0)
     2122#else
     2123                if(m_GOPList[m_iGOPSize+m_extraRPSs[0]].m_referencePics[j]<offPOC-curPOC||m_GOPList[m_iGOPSize+m_extraRPSs[0]].m_referencePics[j]>0)
     2124#endif
    19422125                {
    19432126                  insertPoint = j;
     
    19492132              for(Int j=insertPoint; j<newRefs+1; j++)
    19502133              {
     2134#if !Q0108_TSA_STSA
    19512135                Int newPrev = m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j];
    19522136                Int newUsed = m_GOPList[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[j];
    19532137                m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j]=prev;
    19542138                m_GOPList[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[j]=prevUsed;
     2139#else
     2140                Int newPrev = m_GOPList[m_iGOPSize+m_extraRPSs[0]].m_referencePics[j];
     2141                Int newUsed = m_GOPList[m_iGOPSize+m_extraRPSs[0]].m_usedByCurrPic[j];
     2142                m_GOPList[m_iGOPSize+m_extraRPSs[0]].m_referencePics[j]=prev;
     2143                m_GOPList[m_iGOPSize+m_extraRPSs[0]].m_usedByCurrPic[j]=prevUsed;
     2144#endif
     2145
    19552146                prevUsed=newUsed;
    19562147                prev=newPrev;
     
    19642155          }
    19652156        }
     2157#if !Q0108_TSA_STSA
    19662158        m_GOPList[m_iGOPSize+m_extraRPSs].m_numRefPics=newRefs;
    19672159        m_GOPList[m_iGOPSize+m_extraRPSs].m_POC = curPOC;
     2160#else
     2161        m_GOPList[m_iGOPSize+m_extraRPSs[0]].m_numRefPics=newRefs;
     2162        m_GOPList[m_iGOPSize+m_extraRPSs[0]].m_POC = curPOC;
     2163#endif
     2164#if !Q0108_TSA_STSA
    19682165        if (m_extraRPSs == 0)
    1969         {
     2166#else
     2167        if (m_extraRPSs[0] == 0)
     2168#endif
     2169        {
     2170#if !Q0108_TSA_STSA
    19702171          m_GOPList[m_iGOPSize+m_extraRPSs].m_interRPSPrediction = 0;
    19712172          m_GOPList[m_iGOPSize+m_extraRPSs].m_numRefIdc = 0;
     2173#else
     2174          m_GOPList[m_iGOPSize+m_extraRPSs[0]].m_interRPSPrediction = 0;
     2175          m_GOPList[m_iGOPSize+m_extraRPSs[0]].m_numRefIdc = 0;
     2176#endif
    19722177        }
    19732178        else
    19742179        {
     2180#if !Q0108_TSA_STSA
    19752181          Int rIdx =  m_iGOPSize + m_extraRPSs - 1;
     2182#else
     2183          Int rIdx =  m_iGOPSize + m_extraRPSs[0] - 1;
     2184#endif
    19762185          Int refPOC = m_GOPList[rIdx].m_POC;
    19772186          Int refPics = m_GOPList[rIdx].m_numRefPics;
     
    19822191            Int absPOCref = refPOC+deltaPOC;
    19832192            Int refIdc = 0;
     2193#if !Q0108_TSA_STSA
    19842194            for (Int j = 0; j < m_GOPList[m_iGOPSize+m_extraRPSs].m_numRefPics; j++)
    19852195            {
     
    20062216        m_extraRPSs++;
    20072217      }
     2218#else
     2219            for (Int j = 0; j < m_GOPList[m_iGOPSize+m_extraRPSs[0]].m_numRefPics; j++)
     2220            {
     2221              if ( (absPOCref - curPOC) == m_GOPList[m_iGOPSize+m_extraRPSs[0]].m_referencePics[j])
     2222              {
     2223                if (m_GOPList[m_iGOPSize+m_extraRPSs[0]].m_usedByCurrPic[j])
     2224                {
     2225                  refIdc = 1;
     2226                }
     2227                else
     2228                {
     2229                  refIdc = 2;
     2230                }
     2231              }
     2232            }
     2233            m_GOPList[m_iGOPSize+m_extraRPSs[0]].m_refIdc[newIdc]=refIdc;
     2234            newIdc++;
     2235          }
     2236          m_GOPList[m_iGOPSize+m_extraRPSs[0]].m_interRPSPrediction = 1; 
     2237          m_GOPList[m_iGOPSize+m_extraRPSs[0]].m_numRefIdc = newIdc;
     2238          m_GOPList[m_iGOPSize+m_extraRPSs[0]].m_deltaRPS = refPOC - m_GOPList[m_iGOPSize+m_extraRPSs[0]].m_POC;
     2239        }
     2240        curGOP=m_iGOPSize+m_extraRPSs[0];
     2241        m_extraRPSs[0]++;
     2242      }
     2243#endif
     2244
    20082245      numRefs=0;
    20092246      for(Int i = 0; i< m_GOPList[curGOP].m_numRefPics; i++)
     
    20222259  }
    20232260  xConfirmPara(errorGOP,"Invalid GOP structure given");
     2261
     2262#if SVC_EXTENSION && Q0108_TSA_STSA
     2263  for ( Int layerId = 1; layerId < m_numLayers; layerId++ )
     2264  {
     2265    verifiedGOP=false;
     2266    errorGOP=false;
     2267    checkGOP=1;
     2268    numRefs = m_isField ? 2 : 1;
     2269    refList[0]=0;
     2270
     2271    if(m_isField)
     2272    {
     2273      refList[1] = 1;
     2274    }
     2275
     2276    memset( isOK, 0, sizeof( isOK ) );
     2277    numOK=0;
     2278
     2279    for(Int i=0; i<m_iGOPSize; i++)
     2280    {
     2281      if(m_EhGOPList[layerId][i].m_POC==m_iGOPSize)
     2282      {
     2283        xConfirmPara( m_EhGOPList[layerId][i].m_temporalId!=0 , "The last frame in each GOP must have temporal ID = 0 " );
     2284      }
     2285    }
     2286
     2287    xConfirmPara( m_numLayers > MAX_LAYERS , "Number of layers in config file is greater than MAX_LAYERS" );
     2288    m_numLayers = m_numLayers > MAX_LAYERS ? MAX_LAYERS : m_numLayers;
     2289
     2290    // verify layer configuration parameters
     2291    for(UInt layer=0; layer<m_numLayers; layer++)
     2292    {
     2293      Int m_iIntraPeriod = m_acLayerCfg[layer].m_iIntraPeriod;
     2294      if ( (m_iIntraPeriod != 1) && !m_loopFilterOffsetInPPS && m_DeblockingFilterControlPresent && (!m_bLoopFilterDisable) )
     2295      {
     2296        for(Int i=0; i<m_iGOPSize; i++)
     2297        {
     2298          xConfirmPara( (m_EhGOPList[layerId][i].m_betaOffsetDiv2 + m_loopFilterBetaOffsetDiv2) < -6 || (m_EhGOPList[layerId][i].m_betaOffsetDiv2 + m_loopFilterBetaOffsetDiv2) > 6, "Loop Filter Beta Offset div. 2 for one of the GOP entries exceeds supported range (-6 to 6)" );
     2299          xConfirmPara( (m_EhGOPList[layerId][i].m_tcOffsetDiv2 + m_loopFilterTcOffsetDiv2) < -6 || (m_EhGOPList[layerId][i].m_tcOffsetDiv2 + m_loopFilterTcOffsetDiv2) > 6, "Loop Filter Tc Offset div. 2 for one of the GOP entries exceeds supported range (-6 to 6)" );
     2300        }
     2301      }
     2302    }
     2303
     2304    //start looping through frames in coding order until we can verify that the GOP structure is correct.
     2305    while(!verifiedGOP&&!errorGOP)
     2306    {
     2307      Int curGOP = (checkGOP-1)%m_iGOPSize;
     2308      Int curPOC = ((checkGOP-1)/m_iGOPSize)*m_iGOPSize + m_EhGOPList[layerId][curGOP].m_POC;   
     2309      if(m_EhGOPList[layerId][curGOP].m_POC<0)
     2310      {
     2311        printf("\nError: found fewer Reference Picture Sets than GOPSize\n");
     2312        errorGOP=true;
     2313      }
     2314      else
     2315      {
     2316        //check that all reference pictures are available, or have a POC < 0 meaning they might be available in the next GOP.
     2317        Bool beforeI = false;
     2318        for(Int i = 0; i< m_EhGOPList[layerId][curGOP].m_numRefPics; i++)
     2319        {
     2320          Int absPOC = curPOC+m_EhGOPList[layerId][curGOP].m_referencePics[i];
     2321          if(absPOC < 0)
     2322          {
     2323            beforeI=true;
     2324          }
     2325          else
     2326          {
     2327            Bool found=false;
     2328            for(Int j=0; j<numRefs; j++)
     2329            {
     2330              if(refList[j]==absPOC)
     2331              {
     2332                found=true;
     2333                for(Int k=0; k<m_iGOPSize; k++)
     2334                {
     2335                  if(absPOC%m_iGOPSize == m_EhGOPList[layerId][k].m_POC%m_iGOPSize)
     2336                  {
     2337                    if(m_EhGOPList[layerId][k].m_temporalId==m_EhGOPList[layerId][curGOP].m_temporalId)
     2338                    {
     2339                      m_EhGOPList[layerId][k].m_refPic = true;
     2340                    }
     2341                    m_EhGOPList[layerId][curGOP].m_usedByCurrPic[i]=m_EhGOPList[layerId][k].m_temporalId<=m_EhGOPList[layerId][curGOP].m_temporalId;
     2342                  }
     2343                }
     2344              }
     2345            }
     2346            if(!found)
     2347            {
     2348              printf("\nError: ref pic %d is not available for GOP frame %d\n",m_EhGOPList[layerId][curGOP].m_referencePics[i],curGOP+1);
     2349              errorGOP=true;
     2350            }
     2351          }
     2352        }
     2353        if(!beforeI&&!errorGOP)
     2354        {
     2355          //all ref frames were present
     2356          if(!isOK[curGOP])
     2357          {
     2358            numOK++;
     2359            isOK[curGOP]=true;
     2360            if(numOK==m_iGOPSize)
     2361            {
     2362              verifiedGOP=true;
     2363            }
     2364          }
     2365        }
     2366        else
     2367        {
     2368          //create a new GOPEntry for this frame containing all the reference pictures that were available (POC > 0)
     2369
     2370          m_EhGOPList[layerId][m_iGOPSize+m_extraRPSs[layerId]]=m_EhGOPList[layerId][curGOP];
     2371          Int newRefs=0;
     2372          for(Int i = 0; i< m_EhGOPList[layerId][curGOP].m_numRefPics; i++)
     2373          {
     2374            Int absPOC = curPOC+m_EhGOPList[layerId][curGOP].m_referencePics[i];
     2375            if(absPOC>=0)
     2376            {
     2377              m_EhGOPList[layerId][m_iGOPSize+m_extraRPSs[layerId]].m_referencePics[newRefs]=m_EhGOPList[layerId][curGOP].m_referencePics[i];
     2378              m_EhGOPList[layerId][m_iGOPSize+m_extraRPSs[layerId]].m_usedByCurrPic[newRefs]=m_EhGOPList[layerId][curGOP].m_usedByCurrPic[i];
     2379              newRefs++;
     2380            }
     2381          }
     2382          Int numPrefRefs = m_EhGOPList[layerId][curGOP].m_numRefPicsActive;
     2383
     2384          for(Int offset = -1; offset>-checkGOP; offset--)
     2385          {
     2386            //step backwards in coding order and include any extra available pictures we might find useful to replace the ones with POC < 0.
     2387            Int offGOP = (checkGOP-1+offset)%m_iGOPSize;
     2388            Int offPOC = ((checkGOP-1+offset)/m_iGOPSize)*m_iGOPSize + m_EhGOPList[layerId][offGOP].m_POC;
     2389            if(offPOC>=0&&m_EhGOPList[layerId][offGOP].m_temporalId<=m_EhGOPList[layerId][curGOP].m_temporalId)
     2390            {
     2391              Bool newRef=false;
     2392              for(Int i=0; i<numRefs; i++)
     2393              {
     2394                if(refList[i]==offPOC)
     2395                {
     2396                  newRef=true;
     2397                }
     2398              }
     2399              for(Int i=0; i<newRefs; i++)
     2400              {
     2401                if(m_EhGOPList[layerId][m_iGOPSize+m_extraRPSs[layerId]].m_referencePics[i]==offPOC-curPOC)
     2402                {
     2403                  newRef=false;
     2404                }
     2405              }
     2406              if(newRef)
     2407              {
     2408                Int insertPoint=newRefs;
     2409                //this picture can be added, find appropriate place in list and insert it.
     2410                if(m_EhGOPList[layerId][offGOP].m_temporalId==m_EhGOPList[layerId][curGOP].m_temporalId)
     2411                {
     2412                  m_EhGOPList[layerId][offGOP].m_refPic = true;
     2413                }
     2414                for(Int j=0; j<newRefs; j++)
     2415                {
     2416                  if(m_EhGOPList[layerId][m_iGOPSize+m_extraRPSs[layerId]].m_referencePics[j]<offPOC-curPOC||m_EhGOPList[layerId][m_iGOPSize+m_extraRPSs[layerId]].m_referencePics[j]>0)
     2417                  {
     2418                    insertPoint = j;
     2419                    break;
     2420                  }
     2421                }
     2422                Int prev = offPOC-curPOC;
     2423                Int prevUsed = m_EhGOPList[layerId][offGOP].m_temporalId<=m_EhGOPList[layerId][curGOP].m_temporalId;
     2424                for(Int j=insertPoint; j<newRefs+1; j++)
     2425                {
     2426                  Int newPrev = m_EhGOPList[layerId][m_iGOPSize+m_extraRPSs[layerId]].m_referencePics[j];
     2427                  Int newUsed = m_EhGOPList[layerId][m_iGOPSize+m_extraRPSs[layerId]].m_usedByCurrPic[j];
     2428                  m_EhGOPList[layerId][m_iGOPSize+m_extraRPSs[layerId]].m_referencePics[j]=prev;
     2429                  m_EhGOPList[layerId][m_iGOPSize+m_extraRPSs[layerId]].m_usedByCurrPic[j]=prevUsed;
     2430                  prevUsed=newUsed;
     2431                  prev=newPrev;
     2432                }
     2433                newRefs++;
     2434              }
     2435            }
     2436            if(newRefs>=numPrefRefs)
     2437            {
     2438              break;
     2439            }
     2440          }
     2441          m_EhGOPList[layerId][m_iGOPSize+m_extraRPSs[layerId]].m_numRefPics=newRefs;
     2442          m_EhGOPList[layerId][m_iGOPSize+m_extraRPSs[layerId]].m_POC = curPOC;
     2443          if (m_extraRPSs[layerId] == 0)
     2444          {
     2445            m_EhGOPList[layerId][m_iGOPSize+m_extraRPSs[layerId]].m_interRPSPrediction = 0;
     2446            m_EhGOPList[layerId][m_iGOPSize+m_extraRPSs[layerId]].m_numRefIdc = 0;
     2447          }
     2448          else
     2449          {
     2450            Int rIdx =  m_iGOPSize + m_extraRPSs[layerId] - 1;
     2451            Int refPOC = m_EhGOPList[layerId][rIdx].m_POC;
     2452            Int refPics = m_EhGOPList[layerId][rIdx].m_numRefPics;
     2453            Int newIdc=0;
     2454            for(Int i = 0; i<= refPics; i++)
     2455            {
     2456              Int deltaPOC = ((i != refPics)? m_EhGOPList[layerId][rIdx].m_referencePics[i] : 0);  // check if the reference abs POC is >= 0
     2457              Int absPOCref = refPOC+deltaPOC;
     2458              Int refIdc = 0;
     2459              for (Int j = 0; j < m_EhGOPList[layerId][m_iGOPSize+m_extraRPSs[layerId]].m_numRefPics; j++)
     2460              {
     2461                if ( (absPOCref - curPOC) == m_EhGOPList[layerId][m_iGOPSize+m_extraRPSs[layerId]].m_referencePics[j])
     2462                {
     2463                  if (m_EhGOPList[layerId][m_iGOPSize+m_extraRPSs[layerId]].m_usedByCurrPic[j])
     2464                  {
     2465                    refIdc = 1;
     2466                  }
     2467                  else
     2468                  {
     2469                    refIdc = 2;
     2470                  }
     2471                }
     2472              }
     2473              m_EhGOPList[layerId][m_iGOPSize+m_extraRPSs[layerId]].m_refIdc[newIdc]=refIdc;
     2474              newIdc++;
     2475            }
     2476            m_EhGOPList[layerId][m_iGOPSize+m_extraRPSs[layerId]].m_interRPSPrediction = 1; 
     2477            m_EhGOPList[layerId][m_iGOPSize+m_extraRPSs[layerId]].m_numRefIdc = newIdc;
     2478            m_EhGOPList[layerId][m_iGOPSize+m_extraRPSs[layerId]].m_deltaRPS = refPOC - m_EhGOPList[layerId][m_iGOPSize+m_extraRPSs[layerId]].m_POC;
     2479          }
     2480          curGOP=m_iGOPSize+m_extraRPSs[layerId];
     2481          m_extraRPSs[layerId]++;
     2482        }
     2483        numRefs=0;
     2484        for(Int i = 0; i< m_EhGOPList[layerId][curGOP].m_numRefPics; i++)
     2485        {
     2486          Int absPOC = curPOC+m_EhGOPList[layerId][curGOP].m_referencePics[i];
     2487          if(absPOC >= 0)
     2488          {
     2489            refList[numRefs]=absPOC;
     2490            numRefs++;
     2491          }
     2492        }
     2493        refList[numRefs]=curPOC;
     2494        numRefs++;
     2495      }
     2496      checkGOP++;
     2497    }
     2498    xConfirmPara(errorGOP,"Invalid GOP structure given");
     2499  }
     2500#endif
     2501
    20242502  m_maxTempLayer = 1;
    20252503  for(Int i=0; i<m_iGOPSize; i++)
     
    20312509    xConfirmPara(m_GOPList[i].m_sliceType!='B'&&m_GOPList[i].m_sliceType!='P'&&m_GOPList[i].m_sliceType!='I', "Slice type must be equal to B or P or I");
    20322510  }
     2511
     2512#if Q0108_TSA_STSA
     2513  for ( Int layerId = 1; layerId < m_numLayers; layerId++)
     2514  {
     2515    m_EhMaxTempLayer[layerId] = 1;
     2516    for(Int i=0; i<m_iGOPSize; i++)
     2517    {
     2518      if(m_EhGOPList[layerId][i].m_temporalId >= m_EhMaxTempLayer[layerId] )
     2519      {
     2520        m_EhMaxTempLayer[layerId] = m_EhGOPList[layerId][i].m_temporalId;
     2521      }
     2522      xConfirmPara(m_GOPList[i].m_sliceType!='B'&&m_GOPList[i].m_sliceType!='P'&&m_GOPList[i].m_sliceType!='I', "Slice type must be equal to B or P or I");
     2523    }
     2524  }
     2525#endif
     2526
    20332527  for(Int i=0; i<MAX_TLAYER; i++)
    20342528  {
     
    21952689    xConfirmPara( m_extendedWhiteLevelLumaCodeValue < m_nominalWhiteLevelLumaCodeValue, "SEIToneMapExtendedWhiteLevelLumaCodeValue shall be greater than or equal to SEIToneMapNominalWhiteLevelLumaCodeValue");
    21962690  }
     2691#if P0050_KNEE_FUNCTION_SEI
     2692  if (m_kneeSEIEnabled && !m_kneeSEICancelFlag)
     2693  {
     2694    xConfirmPara( m_kneeSEINumKneePointsMinus1 < 0 || m_kneeSEINumKneePointsMinus1 > 998, "SEIKneeFunctionNumKneePointsMinus1 must be in the range of 0 to 998");
     2695    for ( UInt i=0; i<=m_kneeSEINumKneePointsMinus1; i++ ){
     2696      xConfirmPara( m_kneeSEIInputKneePoint[i] < 1 || m_kneeSEIInputKneePoint[i] > 999, "SEIKneeFunctionInputKneePointValue must be in the range of 1 to 999");
     2697      xConfirmPara( m_kneeSEIOutputKneePoint[i] < 0 || m_kneeSEIOutputKneePoint[i] > 1000, "SEIKneeFunctionInputKneePointValue must be in the range of 0 to 1000");
     2698      if ( i > 0 )
     2699      {
     2700        xConfirmPara( m_kneeSEIInputKneePoint[i-1] >= m_kneeSEIInputKneePoint[i],  "The i-th SEIKneeFunctionInputKneePointValue must be greather than the (i-1)-th value");
     2701      }
     2702    }
     2703  }
     2704#endif
    21972705
    21982706#if RC_SHVC_HARMONIZATION
     
    22342742    xConfirmPara(m_framePackingSEIType < 3 || m_framePackingSEIType > 5 , "SEIFramePackingType must be in rage 3 to 5");
    22352743  }
     2744
     2745#if SVC_EXTENSION
    22362746#if VPS_EXTN_DIRECT_REF_LAYERS
    22372747  xConfirmPara( (m_acLayerCfg[0].m_numSamplePredRefLayers != 0) && (m_acLayerCfg[0].m_numSamplePredRefLayers != -1), "Layer 0 cannot have any reference layers" );
     
    23042814  }
    23052815#endif
    2306 #if N0120_MAX_TID_REF_CFG
    23072816  for (UInt layer=0; layer < MAX_LAYERS-1; layer++)
    23082817  {
    23092818    xConfirmPara(m_acLayerCfg[layer].m_maxTidIlRefPicsPlus1 < 0 || m_acLayerCfg[layer].m_maxTidIlRefPicsPlus1 > 7, "MaxTidIlRefPicsPlus1 must be in range 0 to 7");
    23102819  }
    2311 #endif
    23122820#if AUXILIARY_PICTURES
    23132821  for (UInt layer=0; layer < MAX_LAYERS-1; layer++)
     
    23202828  xConfirmPara( m_nCGSFlag < 0 || m_nCGSFlag > 1 , "0<=CGS<=1" );
    23212829#endif
     2830#endif //SVC_EXTENSION
    23222831#undef xConfirmPara
    23232832  if (check_failed)
     
    23972906#if SVC_EXTENSION 
    23982907  printf("Total number of layers        : %d\n", m_numLayers       );
    2399 #if SCALABILITY_MASK_E0104
    2400   printf("Multiview                     : %d\n", m_scalabilityMask[1] );
    2401   printf("Scalable                      : %d\n", m_scalabilityMask[2] );
     2908  printf("Multiview                     : %d\n", m_scalabilityMask[VIEW_ORDER_INDEX] );
     2909  printf("Scalable                      : %d\n", m_scalabilityMask[SCALABILITY_ID] );
    24022910#if AVC_BASE
    24032911  printf("Base layer                    : %s\n", m_avcBaseLayerFlag ? "AVC" : "HEVC");
    24042912#endif
    24052913#if AUXILIARY_PICTURES
    2406   printf("Auxiliary pictures            : %d\n", m_scalabilityMask[3] );
    2407 #endif
    2408 #else
    2409   printf("Multiview                     : %d\n", m_scalabilityMask[0] );
    2410   printf("Scalable                      : %d\n", m_scalabilityMask[1] );
     2914  printf("Auxiliary pictures            : %d\n", m_scalabilityMask[AUX_ID] );
    24112915#endif
    24122916#if M0040_ADAPTIVE_RESOLUTION_CHANGE
     
    24192923  printf("Align picture type            : %d\n", m_crossLayerPictureTypeAlignFlag );
    24202924#endif
    2421 #if N0147_IRAP_ALIGN_FLAG
    24222925  printf("Cross layer IRAP alignment    : %d\n", m_crossLayerIrapAlignFlag );
    2423 #endif
    24242926#if P0068_CROSS_LAYER_ALIGNED_IDR_ONLY_FOR_IRAP_FLAG
    24252927  printf("IDR only for IRAP             : %d\n", m_crossLayerAlignedIdrOnlyFlag );
  • trunk/source/App/TAppEncoder/TAppEncCfg.h

    r713 r815  
    7373  Char*     m_BLSyntaxFile;                                   ///< input syntax file
    7474#endif
    75 #if N0120_MAX_TID_REF_CFG
    7675  Bool      m_maxTidRefPresentFlag;
    77 #endif
     76#if Q0078_ADD_LAYER_SETS
     77  Int       m_numLayerSets;
     78  Int       m_numLayerInIdList[MAX_VPS_LAYER_SETS_PLUS1];
     79  Int       m_layerSetLayerIdList[MAX_VPS_LAYER_SETS_PLUS1][MAX_VPS_LAYER_ID_PLUS1];
     80  Int       m_numAddLayerSets;
     81  Int       m_numHighestLayerIdx[MAX_VPS_LAYER_SETS_PLUS1];
     82  Int       m_highestLayerIdx[MAX_VPS_LAYER_SETS_PLUS1][MAX_VPS_LAYER_ID_PLUS1];
     83#endif
    7884#else
    7985  Char*     m_pchInputFile;                                   ///< source file name
     
    119125  Int       m_iDecodingRefreshType;                           ///< random access type
    120126  Int       m_iGOPSize;                                       ///< GOP size of hierarchical structure
     127
     128#if !Q0108_TSA_STSA
    121129  Int       m_extraRPSs;                                      ///< extra RPSs added to handle CRA
     130#else
     131  Int       m_extraRPSs[MAX_LAYERS];                          ///< extra RPSs added to handle CRA
     132#endif
     133
    122134  GOPEntry  m_GOPList[MAX_GOP];                               ///< the coding structure entries from the config file
     135#if Q0108_TSA_STSA
     136  GOPEntry  m_EhGOPList[MAX_LAYERS][MAX_GOP];                 ///< the enhancement layer coding structure entries from the config file
     137  Int       m_inheritCodingStruct[MAX_LAYERS];
     138#endif
     139
    123140  Int       m_numReorderPics[MAX_TLAYER];                     ///< total number of reorder pictures
    124141  Int       m_maxDecPicBuffering[MAX_TLAYER];                 ///< total number of pictures in the decoded picture buffer
     
    148165 
    149166  Int       m_maxTempLayer;                                  ///< Max temporal layer
     167#if Q0108_TSA_STSA
     168  Int       m_EhMaxTempLayer[MAX_LAYERS];                    ///< Max temporal layer
     169#endif
    150170
    151171#if !LAYER_CTB
     
    285305  Int       m_SOPDescriptionSEIEnabled;
    286306  Int       m_scalableNestingSEIEnabled;
     307#if Q0189_TMVP_CONSTRAINTS
     308  Int       m_TMVPConstraintsSEIEnabled;
     309#endif
    287310  // weighted prediction
    288311  Bool      m_useWeightedPred;                    ///< Use of weighted prediction in P slices
     
    363386  Void  xPrintParameter ();                                   ///< print configuration values
    364387  Void  xPrintUsage     ();                                   ///< print usage
     388#if SVC_EXTENSION
    365389#if M0040_ADAPTIVE_RESOLUTION_CHANGE
    366390  Int       m_adaptiveResolutionChange;                       ///< Indicate adaptive resolution change frame
     
    386410  Bool      m_crossLayerPictureTypeAlignFlag;
    387411#endif
    388 #if N0147_IRAP_ALIGN_FLAG
    389412  Bool      m_crossLayerIrapAlignFlag;
     413#if P0050_KNEE_FUNCTION_SEI
     414  Bool      m_kneeSEIEnabled;
     415  Int       m_kneeSEIId;
     416  Bool      m_kneeSEICancelFlag;
     417  Bool      m_kneeSEIPersistenceFlag;
     418  Bool      m_kneeSEIMappingFlag;
     419  Int       m_kneeSEIInputDrange;
     420  Int       m_kneeSEIInputDispLuminance;
     421  Int       m_kneeSEIOutputDrange;
     422  Int       m_kneeSEIOutputDispLuminance;
     423  Int       m_kneeSEINumKneePointsMinus1;
     424  Int*      m_kneeSEIInputKneePoint;
     425  Int*      m_kneeSEIOutputKneePoint;
    390426#endif
    391427#if P0068_CROSS_LAYER_ALIGNED_IDR_ONLY_FOR_IRAP_FLAG
     
    404440  Int  m_nCGSLUTBit;
    405441#endif
     442#endif //SVC_EXTENSION
    406443public:
    407444  TAppEncCfg();
  • trunk/source/App/TAppEncoder/TAppEncLayerCfg.h

    r713 r815  
    8383#endif
    8484
    85 #if N0120_MAX_TID_REF_CFG
    8685  Int       m_maxTidIlRefPicsPlus1;
    87 #endif
    8886  Int       m_iWaveFrontSubstreams; //< If iWaveFrontSynchro, this is the number of substreams per frame (dependent tiles) or per tile (independent tiles).
    8987
     
    181179  Void    setSourceHeight(Int x)      { m_iSourceHeight = x;    }
    182180#endif
    183 #if N0120_MAX_TID_REF_CFG
    184181  Int     getMaxTidIlRefPicsPlus1()   { return m_maxTidIlRefPicsPlus1; }
    185 #endif
    186182#if LAYER_CTB
    187183  UInt    getMaxCUWidth()             {return m_uiMaxCUWidth;      }
  • trunk/source/App/TAppEncoder/TAppEncTop.cpp

    r713 r815  
    8282    vps->setTemporalNestingFlag(true);
    8383  }
    84 #if !VPS_RENAME
    85   vps.setMaxLayers                        ( 1 );
    86 #endif
    8784  for(Int i = 0; i < MAX_TLAYER; i++)
    8885  {
     
    190187  delete [] mapIdxToLayer;
    191188#endif
     189
     190  assert( m_numLayers <= MAX_LAYERS );
    192191
    193192  for(UInt layer=0; layer<m_numLayers; layer++)
     
    241240    m_acTEncTop[layer].setDecodingRefreshType          ( m_iDecodingRefreshType );
    242241    m_acTEncTop[layer].setGOPSize                      ( m_iGOPSize );
     242#if Q0108_TSA_STSA
     243    m_acTEncTop[layer].setGopList                      ( layer ? m_EhGOPList[layer] : m_GOPList );
     244#else
    243245    m_acTEncTop[layer].setGopList                      ( m_GOPList );
    244 
     246#endif
     247
     248#if !Q0108_TSA_STSA
    245249    m_acTEncTop[layer].setExtraRPSs                    ( m_extraRPSs );
     250#else
     251    m_acTEncTop[layer].setExtraRPSs                    ( m_extraRPSs[layer] );
     252#endif
    246253    for(Int i = 0; i < MAX_TLAYER; i++)
    247254    {
     
    256263
    257264    m_acTEncTop[layer].setPad                          ( m_acLayerCfg[layer].getPad() );
    258 
     265#if !Q0108_TSA_STSA
    259266    m_acTEncTop[layer].setMaxTempLayer                 ( m_maxTempLayer );
     267#else
     268    if (layer== 0)
     269    {
     270      m_acTEncTop[layer].setMaxTempLayer                 ( m_maxTempLayer );
     271    }
     272    else
     273    {
     274      m_acTEncTop[layer].setMaxTempLayer                 ( m_EhMaxTempLayer[layer] );
     275    }
     276#endif
    260277    m_acTEncTop[layer].setUseAMP( m_enableAMP );
    261 #if N0120_MAX_TID_REF_CFG
    262     if (layer<m_numLayers-1)
     278
     279    if( layer < m_numLayers - 1 )
    263280    {
    264281       m_acTEncTop[layer].setMaxTidIlRefPicsPlus1 ( m_acLayerCfg[layer].getMaxTidIlRefPicsPlus1());
    265282    }
    266 #endif
     283
    267284#if VPS_EXTN_DIRECT_REF_LAYERS
    268285    if(layer)
     
    306323      }
    307324      Int numDirectRefLayers = 0;
     325
     326      assert( layer < MAX_LAYERS );
     327
    308328      for (Int i = 0; i < layer; i++)
    309329      {
     
    480500    m_acTEncTop[layer].setTMISEINominalWhiteLevelLumaCodeValue      ( m_nominalWhiteLevelLumaCodeValue );
    481501    m_acTEncTop[layer].setTMISEIExtendedWhiteLevelLumaCodeValue     ( m_extendedWhiteLevelLumaCodeValue );
     502#if P0050_KNEE_FUNCTION_SEI
     503    m_acTEncTop[layer].setKneeSEIEnabled                            ( m_kneeSEIEnabled );
     504    m_acTEncTop[layer].setKneeSEIId                                 ( m_kneeSEIId );
     505    m_acTEncTop[layer].setKneeSEICancelFlag                         ( m_kneeSEICancelFlag );
     506    m_acTEncTop[layer].setKneeSEIPersistenceFlag                    ( m_kneeSEIPersistenceFlag );
     507    m_acTEncTop[layer].setKneeSEIMappingFlag                        ( m_kneeSEIMappingFlag );
     508    m_acTEncTop[layer].setKneeSEIInputDrange                        ( m_kneeSEIInputDrange );
     509    m_acTEncTop[layer].setKneeSEIInputDispLuminance                 ( m_kneeSEIInputDispLuminance );
     510    m_acTEncTop[layer].setKneeSEIOutputDrange                       ( m_kneeSEIOutputDrange );
     511    m_acTEncTop[layer].setKneeSEIOutputDispLuminance                ( m_kneeSEIOutputDispLuminance );
     512    m_acTEncTop[layer].setKneeSEINumKneePointsMinus1                ( m_kneeSEINumKneePointsMinus1 );
     513    m_acTEncTop[layer].setKneeSEIInputKneePoint                     ( m_kneeSEIInputKneePoint );
     514    m_acTEncTop[layer].setKneeSEIOutputKneePoint                    ( m_kneeSEIOutputKneePoint );
     515#endif
    482516#if Q0074_SEI_COLOR_MAPPING
    483517    m_acTEncTop[layer].setColorMappingInfoSEIFile                   ( m_acLayerCfg[layer].m_cSeiColorMappingFile.empty() ? NULL : const_cast<Char *>(m_acLayerCfg[layer].m_cSeiColorMappingFile.c_str()) );
     
    497531    m_acTEncTop[layer].setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled );
    498532    m_acTEncTop[layer].setScalableNestingSEIEnabled( m_scalableNestingSEIEnabled );
     533#if Q0189_TMVP_CONSTRAINTS
     534    m_acTEncTop[layer].setTMVPConstraintsSEIEnabled( m_TMVPConstraintsSEIEnabled);           
     535#endif
    499536#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    500537    m_acTEncTop[layer].setInterLayerConstrainedTileSetsSEIEnabled( m_interLayerConstrainedTileSetsSEIEnabled );
     
    614651    m_acTEncTop[layer].setCGSLUTBit( m_nCGSLUTBit );
    615652#endif
     653#if Q0078_ADD_LAYER_SETS
     654    m_acTEncTop[layer].setNumAddLayerSets( m_numAddLayerSets );
     655#endif
    616656  }
    617657}
     
    799839  m_cTEncTop.setTMISEINominalWhiteLevelLumaCodeValue      ( m_nominalWhiteLevelLumaCodeValue );
    800840  m_cTEncTop.setTMISEIExtendedWhiteLevelLumaCodeValue     ( m_extendedWhiteLevelLumaCodeValue );
     841#if P0050_KNEE_FUNCTION_SEI
     842  m_cTEncTop.setKneeSEIEnabled              ( m_kneeSEIEnabled );
     843  m_cTEncTop.setKneeSEIId                   ( m_kneeSEIId );
     844  m_cTEncTop.setKneeSEICancelFlag           ( m_kneeSEICancelFlag );
     845  m_cTEncTop.setKneeSEIPersistenceFlag      ( m_kneeSEIPersistenceFlag );
     846  m_cTEncTop.setKneeSEIMappingFlag          ( m_kneeSEIMappingFlag );
     847  m_cTEncTop.setKneeSEIInputDrange          ( m_kneeSEIInputDrange );
     848  m_cTEncTop.setKneeSEIInputDispLuminance   ( m_kneeSEIInputDispLuminance );
     849  m_cTEncTop.setKneeSEIOutputDrange         ( m_kneeSEIOutputDrange );
     850  m_cTEncTop.setKneeSEIOutputDispLuminance  ( m_kneeSEIOutputDispLuminance );
     851  m_cTEncTop.setKneeSEINumKneePointsMinus1  ( m_kneeSEINumKneePointsMinus1 );
     852  m_cTEncTop.setKneeSEIInputKneePoint       ( m_kneeSEIInputKneePoint );
     853  m_cTEncTop.setKneeSEIOutputKneePoint      ( m_kneeSEIOutputKneePoint );
     854#endif
    801855#if Q0074_SEI_COLOR_MAPPING
    802856  m_cTEncTop.setColorMappingInfoSEIFile                   ( m_pchSEIColorMappingFile );
     
    9941048#endif
    9951049  }
    996 #if VPS_RENAME
    9971050  m_acTEncTop[0].getVPS()->setMaxLayers( m_numLayers );
    998 #endif
    9991051#if VPS_EXTN_OP_LAYER_SETS
    10001052  TComVPS* vps = m_acTEncTop[0].getVPS();
     
    10031055  vps->setVpsExtensionFlag( m_numLayers > 1 ? true : false );
    10041056
    1005   vps->setNumLayerSets(m_numLayers);
    1006   for(Int setId = 1; setId < vps->getNumLayerSets(); setId++)
    1007   {
    1008     for(Int layerId = 0; layerId <= vps->getMaxLayerId(); layerId++)
    1009     {
     1057#if Q0078_ADD_LAYER_SETS
     1058  if (m_numLayerSets > 0)
     1059  {
     1060    vps->setNumLayerSets(m_numLayerSets+1);
     1061    for (Int setId = 1; setId < vps->getNumLayerSets(); setId++)
     1062    {
     1063      for (Int layerId = 0; layerId <= vps->getMaxLayerId(); layerId++)
     1064      {
     1065        vps->setLayerIdIncludedFlag(false, setId, layerId);
     1066      }
     1067    }
     1068    for (Int setId = 1; setId < vps->getNumLayerSets(); setId++)
     1069    {
     1070      for (Int i = 0; i < m_numLayerInIdList[setId-1]; i++)
     1071      {
     1072        Int layerId = m_layerSetLayerIdList[setId-1][i];
     1073
    10101074#if O0194_DIFFERENT_BITDEPTH_EL_BL
    1011       //4
    1012       g_bitDepthY = m_acLayerCfg[layerId].m_internalBitDepthY;
    1013       g_bitDepthC = m_acLayerCfg[layerId].m_internalBitDepthC;
    1014 
    1015       g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layerId].m_inputBitDepthY : m_acLayerCfg[layerId].m_internalBitDepthY;
    1016       g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layerId].m_inputBitDepthC : m_acLayerCfg[layerId].m_internalBitDepthC;
    1017 #endif
    1018       if( layerId <= setId )
    1019       {
     1075        //4
     1076        g_bitDepthY = m_acLayerCfg[layerId].m_internalBitDepthY;
     1077        g_bitDepthC = m_acLayerCfg[layerId].m_internalBitDepthC;
     1078
     1079        g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layerId].m_inputBitDepthY : m_acLayerCfg[layerId].m_internalBitDepthY;
     1080        g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layerId].m_inputBitDepthC : m_acLayerCfg[layerId].m_internalBitDepthC;
     1081#endif
     1082
    10201083        vps->setLayerIdIncludedFlag(true, setId, layerId);
    10211084      }
    1022       else
    1023       {
    1024         vps->setLayerIdIncludedFlag(false, setId, layerId);
    1025       }
    1026     }
    1027   }
     1085    }
     1086  }
     1087  else
     1088  {
     1089    // Default layer sets
     1090#endif
     1091    vps->setNumLayerSets(m_numLayers);
     1092    for (Int setId = 1; setId < vps->getNumLayerSets(); setId++)
     1093    {
     1094      for (Int layerId = 0; layerId <= vps->getMaxLayerId(); layerId++)
     1095      {
     1096#if O0194_DIFFERENT_BITDEPTH_EL_BL
     1097        //4
     1098        g_bitDepthY = m_acLayerCfg[layerId].m_internalBitDepthY;
     1099        g_bitDepthC = m_acLayerCfg[layerId].m_internalBitDepthC;
     1100
     1101        g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layerId].m_inputBitDepthY : m_acLayerCfg[layerId].m_internalBitDepthY;
     1102        g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layerId].m_inputBitDepthC : m_acLayerCfg[layerId].m_internalBitDepthC;
     1103#endif
     1104        if (layerId <= setId)
     1105        {
     1106          vps->setLayerIdIncludedFlag(true, setId, layerId);
     1107        }
     1108        else
     1109        {
     1110          vps->setLayerIdIncludedFlag(false, setId, layerId);
     1111        }
     1112      }
     1113    }
     1114#if Q0078_ADD_LAYER_SETS
     1115  }
     1116#endif
     1117#if Q0078_ADD_LAYER_SETS
     1118  vps->setVpsNumLayerSetsMinus1(vps->getNumLayerSets() - 1);
     1119  vps->setNumAddLayerSets(m_numAddLayerSets);
     1120  vps->setNumLayerSets(vps->getNumLayerSets() + vps->getNumAddLayerSets());
     1121  if (m_numAddLayerSets > 0)
     1122  {
     1123    for (Int setId = 0; setId < m_numAddLayerSets; setId++)
     1124    {
     1125      for (Int j = 0; j < m_numHighestLayerIdx[setId]; j++)
     1126      {
     1127        vps->setHighestLayerIdxPlus1(setId, j + 1, m_highestLayerIdx[setId][j] + 1);
     1128      }
     1129    }
     1130  }
     1131#endif
    10281132#if VPS_EXTN_MASK_AND_DIM_INFO
    10291133  UInt i = 0, dimIdLen = 0;
     
    10971201#if VPS_TSLAYERS
    10981202    vps->setMaxTSLayersPresentFlag(true);
     1203
    10991204    for( i = 0; i < vps->getMaxLayers(); i++ )
    11001205    {
     
    11021207    }
    11031208#endif
    1104 #if N0120_MAX_TID_REF_PRESENT_FLAG
    1105 #if N0120_MAX_TID_REF_CFG
    11061209  vps->setMaxTidRefPresentFlag(m_maxTidRefPresentFlag);
    1107 #else
    1108   vps->setMaxTidRefPresentFlag(true);
    1109 #endif
    11101210  if (vps->getMaxTidRefPresentFlag())
    11111211  {
    11121212    for( i = 0; i < vps->getMaxLayers() - 1; i++ )
    11131213    {
    1114 #if N0120_MAX_TID_REF_CFG
    11151214#if O0225_MAX_TID_FOR_REF_LAYERS
    11161215      for( Int j = i+1; j < vps->getMaxLayers(); j++)
     
    11211220      vps->setMaxTidIlRefPicsPlus1(i, m_acTEncTop[i].getMaxTidIlRefPicsPlus1());
    11221221#endif
    1123 #else
     1222    }
     1223  }
     1224  else
     1225  {
     1226    for( i = 0; i < vps->getMaxLayers() - 1; i++ )
     1227    {
    11241228#if O0225_MAX_TID_FOR_REF_LAYERS
    11251229      for( Int j = i+1; j < vps->getMaxLayers(); j++)
    11261230      {
    1127         vps->setMaxTidIlRefPicsPlus1(i, j, vps->getMaxTLayers()+1);
    1128       }
    1129 #else
    1130       vps->setMaxTidIlRefPicsPlus1(i, vps->getMaxTLayers()+1);
    1131 #endif
    1132 #endif
    1133     }
    1134   }
    1135   else
    1136   {
    1137     for( i = 0; i < vps->getMaxLayers() - 1; i++ )
    1138     {
    1139 #if O0225_MAX_TID_FOR_REF_LAYERS
    1140       for( Int j = i+1; j < vps->getMaxLayers(); j++)
    1141       {
    11421231        vps->setMaxTidIlRefPicsPlus1(i, j, 7);
    11431232      }
     
    11471236    }
    11481237  }
    1149 #endif
    1150 #if ILP_SSH_SIG
    1151 #if ILP_SSH_SIG_FIX
    11521238    vps->setIlpSshSignalingEnabledFlag(false);
    1153 #else
    1154     vps->setIlpSshSignalingEnabledFlag(true);
    1155 #endif
    1156 #endif
    11571239#if VPS_EXTN_PROFILE_INFO
    11581240  vps->getPTLForExtnPtr()->resize(vps->getNumLayerSets());
     
    11621244    // Note - may need to be changed for other layer structures.
    11631245    *(vps->getPTLForExtn(setId)) = *(m_acTEncTop[setId].getSPS()->getPTL());
    1164   }
    1165 #endif
    1166   // Target output layer
    1167   vps->setNumOutputLayerSets(vps->getNumLayerSets());
    1168   vps->setNumProfileTierLevel(vps->getNumLayerSets());
    1169 #if P0295_DEFAULT_OUT_LAYER_IDC
    1170   vps->setDefaultTargetOutputLayerIdc(1);
    1171 #else
    1172 #if O0109_DEFAULT_ONE_OUT_LAYER_IDC
    1173   vps->setDefaultOneTargetOutputLayerIdc(1);
    1174 #else
    1175   vps->setDefaultOneTargetOutputLayerFlag(true);
    1176 #endif
    1177 #endif
    1178   for(i = 1; i < vps->getNumLayerSets(); i++)
    1179   {
    1180     vps->setProfileLevelTierIdx(i, i);
    1181     vps->setOutputLayerSetIdx(i, i);
    1182   } 
    1183 #endif
    1184  #if VPS_DPB_SIZE_TABLE
    1185   // The Layer ID List variables can be derived here. 
    1186 #if DERIVE_LAYER_ID_LIST_VARIABLES
    1187   vps->deriveLayerIdListVariables();
    1188 #endif
    1189 #if RESOLUTION_BASED_DPB
    1190   vps->assignSubDpbIndices();
    1191 #else
    1192   vps->deriveNumberOfSubDpbs();
    1193 #endif
    1194 
    1195   // derive OutputLayerFlag[i][j]
    1196   if( vps->getDefaultTargetOutputLayerIdc() == 1 )
    1197   {
    1198     // default_target_output_layer_idc equal to 1 specifies that only the layer with the highest value of nuh_layer_id such that nuh_layer_id equal to nuhLayerIdA and
    1199     // AuxId[ nuhLayerIdA ] equal to 0 in each of the output layer sets with index in the range of 1 to vps_num_layer_sets_minus1, inclusive, is an output layer of its output layer set.
    1200 
    1201     // Include the highest layer as output layer for each layer set
    1202     for(Int lsIdx = 1; lsIdx < vps->getNumLayerSets(); lsIdx++)
    1203     {
    1204       for( UInt layer = 0; layer < vps->getNumLayersInIdList(lsIdx); layer++ )
    1205       {
    1206         if( vps->getLayerIdIncludedFlag(lsIdx, layer) )     
    1207         {       
    1208           vps->setOutputLayerFlag( lsIdx, layer, layer == vps->getNumLayersInIdList(lsIdx) - 1 );
    1209         }
    1210       }
    1211     }
    1212   }
    1213   else
    1214   {
    1215     // cases when default_target_output_layer_idc is not equal to 1
    1216     assert(!"default_target_output_layer_idc not equal to 1 is not yet supported");
    1217   }
    1218 
    1219   // Initialize dpb_size_table() for all ouput layer sets in the VPS extension
    1220   for(i = 1; i < vps->getNumOutputLayerSets(); i++)
    1221   {
    1222 #if CHANGE_NUMSUBDPB_IDX
    1223     Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx( i );
    1224 #endif
    1225     Int layerSetId = vps->getOutputLayerSetIdx(i);
    1226 
    1227     for(Int j = 0; j < vps->getMaxTLayers(); j++)
    1228     {
    1229 
    1230       Int maxNumReorderPics = -1;
    1231 #if CHANGE_NUMSUBDPB_IDX
    1232 #if RESOLUTION_BASED_DPB
    1233       for(Int k = 0; k < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); k++)
    1234 #else
    1235       for(Int k = 0; k < vps->getNumSubDpbs(layerSetIdxForOutputLayerSet); k++)
    1236 #endif
    1237 #else
    1238       for(Int k = 0; k < vps->getNumSubDpbs(i); k++)
    1239 #endif
    1240       {
    1241         Int layerId = vps->getLayerSetLayerIdList(layerSetId, k); // k-th layer in the output layer set
    1242 #if RESOLUTION_BASED_DPB
    1243         vps->setMaxVpsLayerDecPicBuffMinus1( i, k, j, m_acTEncTop[layerId].getMaxDecPicBuffering(j) - 1 );
    1244         // Add sub-DPB sizes of layers belonging to a sub-DPB. If a different sub-DPB size is calculated
    1245         // at the encoder, modify below
    1246         Int oldValue = vps->getMaxVpsDecPicBufferingMinus1( i, vps->getSubDpbAssigned( layerSetIdxForOutputLayerSet, k ), j );
    1247         oldValue += vps->getMaxVpsLayerDecPicBuffMinus1( i, k, j ) + 1;
    1248         vps->setMaxVpsDecPicBufferingMinus1( i, vps->getSubDpbAssigned( layerSetIdxForOutputLayerSet, k ), j, oldValue );
    1249 #else
    1250         vps->setMaxVpsDecPicBufferingMinus1( i, k, j,  m_acTEncTop[layerId].getMaxDecPicBuffering(j) - 1 );
    1251 #endif
    1252         maxNumReorderPics       = std::max( maxNumReorderPics, m_acTEncTop[layerId].getNumReorderPics(j));
    1253       }
    1254 #if RESOLUTION_BASED_DPB
    1255       for(Int k = 0; k < vps->getNumSubDpbs(i); k++)
    1256       {
    1257         // Decrement m_maxVpsDecPicBufferingMinus1
    1258         Int oldValue = vps->getMaxVpsDecPicBufferingMinus1( i, vps->getSubDpbAssigned( layerSetIdxForOutputLayerSet, k ), j );
    1259         vps->setMaxVpsDecPicBufferingMinus1( i, vps->getSubDpbAssigned( layerSetIdxForOutputLayerSet, k ), j, oldValue - 1 );
    1260       }
    1261 #endif
    1262       vps->setMaxVpsNumReorderPics(i, j, maxNumReorderPics);
    1263       vps->determineSubDpbInfoFlags();
    1264     }
    12651246  }
    12661247#endif
     
    12711252  Bool isDefaultDirectDependencyTypeSet = false;
    12721253#endif
    1273   for(UInt layerCtr = 1;layerCtr <= vps->getMaxLayers() - 1; layerCtr++)
    1274   {
    1275     vps->setNumDirectRefLayers( layerCtr, m_acTEncTop[layerCtr].getNumDirectRefLayers() );
    1276     maxDirectRefLayers = max<UInt>( maxDirectRefLayers, vps->getNumDirectRefLayers( layerCtr ) );
    1277 
    1278     for(i = 0; i < vps->getNumDirectRefLayers(layerCtr); i++)
    1279     {
    1280       vps->setRefLayerId( layerCtr, i, m_acTEncTop[layerCtr].getRefLayerId(i) );
     1254  for (UInt layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++)
     1255  {
     1256    vps->setNumDirectRefLayers(layerCtr, m_acTEncTop[layerCtr].getNumDirectRefLayers());
     1257    maxDirectRefLayers = max<UInt>(maxDirectRefLayers, vps->getNumDirectRefLayers(layerCtr));
     1258
     1259    for (i = 0; i < vps->getNumDirectRefLayers(layerCtr); i++)
     1260    {
     1261      vps->setRefLayerId(layerCtr, i, m_acTEncTop[layerCtr].getRefLayerId(i));
    12811262    }
    12821263    // Set direct dependency flag
    12831264    // Initialize flag to 0
    1284     for(Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++)
    1285     {
    1286       vps->setDirectDependencyFlag( layerCtr, refLayerCtr, false );
    1287     }
    1288     for(i = 0; i < vps->getNumDirectRefLayers(layerCtr); i++)
    1289     {
    1290       vps->setDirectDependencyFlag( layerCtr, vps->getLayerIdInVps(m_acTEncTop[layerCtr].getRefLayerId(i)), true);
     1265    for (Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++)
     1266    {
     1267      vps->setDirectDependencyFlag(layerCtr, refLayerCtr, false);
     1268    }
     1269    for (i = 0; i < vps->getNumDirectRefLayers(layerCtr); i++)
     1270    {
     1271      vps->setDirectDependencyFlag(layerCtr, vps->getLayerIdInVps(m_acTEncTop[layerCtr].getRefLayerId(i)), true);
    12911272    }
    12921273    // prediction indications
    12931274    vps->setDirectDepTypeLen(2); // sample and motion types are encoded
    1294     for(Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++)
    1295     {
    1296       if (vps->getDirectDependencyFlag( layerCtr, refLayerCtr))
     1275    for (Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++)
     1276    {
     1277      if (vps->getDirectDependencyFlag(layerCtr, refLayerCtr))
    12971278      {
    12981279        assert(m_acTEncTop[layerCtr].getSamplePredEnabledFlag(refLayerCtr) || m_acTEncTop[layerCtr].getMotionPredEnabledFlag(refLayerCtr));
    1299         vps->setDirectDependencyType( layerCtr, refLayerCtr, ((m_acTEncTop[layerCtr].getSamplePredEnabledFlag(refLayerCtr) ? 1 : 0) |
    1300                                                               (m_acTEncTop[layerCtr].getMotionPredEnabledFlag(refLayerCtr) ? 2 : 0)) - 1);
     1280        vps->setDirectDependencyType(layerCtr, refLayerCtr, ((m_acTEncTop[layerCtr].getSamplePredEnabledFlag(refLayerCtr) ? 1 : 0) |
     1281          (m_acTEncTop[layerCtr].getMotionPredEnabledFlag(refLayerCtr) ? 2 : 0)) - 1);
    13011282#if O0096_DEFAULT_DEPENDENCY_TYPE
    13021283        if (!isDefaultDirectDependencyTypeSet)
     
    13141295      else
    13151296      {
    1316         vps->setDirectDependencyType( layerCtr, refLayerCtr, 0 );
     1297        vps->setDirectDependencyType(layerCtr, refLayerCtr, 0);
    13171298      }
    13181299    }
     
    13201301
    13211302#if O0092_0094_DEPENDENCY_CONSTRAINT
    1322   for(UInt layerCtr = 1;layerCtr <= vps->getMaxLayers() - 1; layerCtr++)
    1323   {
    1324     vps->setNumRefLayers(vps->getLayerIdInNuh(layerCtr));   // identify the number of direct and indirect reference layers of current layer and set recursiveRefLayersFlags
    1325   }
    1326   if(vps->getMaxLayers() > MAX_REF_LAYERS)
    1327   {
    1328     for(UInt layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++)
    1329     {
    1330       assert( vps->getNumRefLayers(vps->getLayerIdInNuh(layerCtr)) <= MAX_REF_LAYERS);
    1331     }
    1332   }
    1333 #endif
     1303  vps->setNumRefLayers();
     1304
     1305  if (vps->getMaxLayers() > MAX_REF_LAYERS)
     1306  {
     1307    for (UInt layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++)
     1308    {
     1309      assert(vps->getNumRefLayers(vps->getLayerIdInNuh(layerCtr)) <= MAX_REF_LAYERS);
     1310    }
     1311  }
     1312#endif
     1313#if Q0078_ADD_LAYER_SETS
     1314  vps->setPredictedLayerIds();
     1315  vps->setTreePartitionLayerIdList();
     1316  vps->setLayerIdIncludedFlagsForAddLayerSets();
     1317#endif
     1318#endif
     1319  // Target output layer
     1320  vps->setNumOutputLayerSets(vps->getNumLayerSets());
     1321  vps->setNumProfileTierLevel(vps->getNumLayerSets());
     1322#if P0295_DEFAULT_OUT_LAYER_IDC
     1323  vps->setDefaultTargetOutputLayerIdc(1);
     1324#else
     1325#if O0109_DEFAULT_ONE_OUT_LAYER_IDC
     1326  vps->setDefaultOneTargetOutputLayerIdc(1);
     1327#else
     1328  vps->setDefaultOneTargetOutputLayerFlag(true);
     1329#endif
     1330#endif
     1331  for(i = 1; i < vps->getNumLayerSets(); i++)
     1332  {
     1333    vps->setProfileLevelTierIdx(i, i);
     1334    vps->setOutputLayerSetIdx(i, i);
     1335  } 
     1336#endif
     1337 #if VPS_DPB_SIZE_TABLE
     1338  // The Layer ID List variables can be derived here. 
     1339#if DERIVE_LAYER_ID_LIST_VARIABLES
     1340  vps->deriveLayerIdListVariables();
     1341#endif
     1342#if RESOLUTION_BASED_DPB
     1343  vps->assignSubDpbIndices();
     1344#else
     1345  vps->deriveNumberOfSubDpbs();
     1346#endif
     1347
     1348  // derive OutputLayerFlag[i][j]
     1349  if( vps->getDefaultTargetOutputLayerIdc() == 1 )
     1350  {
     1351    // default_output_layer_idc equal to 1 specifies that only the layer with the highest value of nuh_layer_id such that nuh_layer_id equal to nuhLayerIdA and
     1352    // AuxId[ nuhLayerIdA ] equal to 0 in each of the output layer sets with index in the range of 1 to vps_num_layer_sets_minus1, inclusive, is an output layer of its output layer set.
     1353
     1354    // Include the highest layer as output layer for each layer set
     1355    for(Int lsIdx = 1; lsIdx < vps->getNumLayerSets(); lsIdx++)
     1356    {
     1357      for( UInt layer = 0; layer < vps->getNumLayersInIdList(lsIdx); layer++ )
     1358      {
     1359#if !Q0078_ADD_LAYER_SETS  // the following condition is incorrect and is not needed anyway
     1360        if( vps->getLayerIdIncludedFlag(lsIdx, layer) )     
     1361#endif
     1362        {       
     1363          vps->setOutputLayerFlag( lsIdx, layer, layer == vps->getNumLayersInIdList(lsIdx) - 1 );
     1364        }
     1365      }
     1366    }
     1367  }
     1368  else
     1369  {
     1370    // cases when default_output_layer_idc is not equal to 1
     1371    assert(!"default_output_layer_idc not equal to 1 is not yet supported");
     1372  }
     1373
     1374  // Initialize dpb_size_table() for all ouput layer sets in the VPS extension
     1375  for(i = 1; i < vps->getNumOutputLayerSets(); i++)
     1376  {
     1377#if CHANGE_NUMSUBDPB_IDX
     1378    Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx( i );
     1379#endif
     1380    Int layerSetId = vps->getOutputLayerSetIdx(i);
     1381
     1382    for(Int j = 0; j < vps->getMaxTLayers(); j++)
     1383    {
     1384
     1385      Int maxNumReorderPics = -1;
     1386#if CHANGE_NUMSUBDPB_IDX
     1387#if RESOLUTION_BASED_DPB
     1388      for(Int k = 0; k < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); k++)
     1389#else
     1390      for(Int k = 0; k < vps->getNumSubDpbs(layerSetIdxForOutputLayerSet); k++)
     1391#endif
     1392#else
     1393      for(Int k = 0; k < vps->getNumSubDpbs(i); k++)
     1394#endif
     1395      {
     1396        Int layerId = vps->getLayerSetLayerIdList(layerSetId, k); // k-th layer in the output layer set
     1397#if RESOLUTION_BASED_DPB
     1398        vps->setMaxVpsLayerDecPicBuffMinus1( i, k, j, m_acTEncTop[layerId].getMaxDecPicBuffering(j) - 1 );
     1399        // Add sub-DPB sizes of layers belonging to a sub-DPB. If a different sub-DPB size is calculated
     1400        // at the encoder, modify below
     1401        Int oldValue = vps->getMaxVpsDecPicBufferingMinus1( i, vps->getSubDpbAssigned( layerSetIdxForOutputLayerSet, k ), j );
     1402        oldValue += vps->getMaxVpsLayerDecPicBuffMinus1( i, k, j ) + 1;
     1403        vps->setMaxVpsDecPicBufferingMinus1( i, vps->getSubDpbAssigned( layerSetIdxForOutputLayerSet, k ), j, oldValue );
     1404#else
     1405        vps->setMaxVpsDecPicBufferingMinus1( i, k, j,  m_acTEncTop[layerId].getMaxDecPicBuffering(j) - 1 );
     1406#endif
     1407        maxNumReorderPics       = std::max( maxNumReorderPics, m_acTEncTop[layerId].getNumReorderPics(j));
     1408      }
     1409#if RESOLUTION_BASED_DPB
     1410      for(Int k = 0; k < vps->getNumSubDpbs(i); k++)
     1411      {
     1412        // Decrement m_maxVpsDecPicBufferingMinus1
     1413        Int oldValue = vps->getMaxVpsDecPicBufferingMinus1( i, vps->getSubDpbAssigned( layerSetIdxForOutputLayerSet, k ), j );
     1414        vps->setMaxVpsDecPicBufferingMinus1( i, vps->getSubDpbAssigned( layerSetIdxForOutputLayerSet, k ), j, oldValue - 1 );
     1415      }
     1416#endif
     1417      vps->setMaxVpsNumReorderPics(i, j, maxNumReorderPics);
     1418      vps->determineSubDpbInfoFlags();
     1419    }
     1420  }
    13341421#endif
    13351422    vps->setMaxOneActiveRefLayerFlag(maxDirectRefLayers > 1 ? false : true);
     
    13391426      if( vps->getNumDirectRefLayers( vps->getLayerIdInNuh(i) ) == 0  )
    13401427      {
     1428#if Q0078_ADD_LAYER_SETS
     1429        vps->setPocLsbNotPresentFlag(i, true); // make independedent layers base-layer compliant
     1430#else
    13411431        vps->setPocLsbNotPresentFlag(i, false);
     1432#endif
    13421433      }
    13431434    }
     
    13491440    vps->setCrossLayerAlignedIdrOnlyFlag( m_crossLayerAlignedIdrOnlyFlag );
    13501441#endif
    1351 #if N0147_IRAP_ALIGN_FLAG
    13521442    vps->setCrossLayerIrapAlignFlag( m_crossLayerIrapAlignFlag );
    13531443    for(UInt layerCtr = 1;layerCtr <= vps->getMaxLayers() - 1; layerCtr++)
     
    13651455      }
    13661456    }
    1367 #endif
    13681457#if M0040_ADAPTIVE_RESOLUTION_CHANGE
    13691458  vps->setSingleLayerForNonIrapFlag(m_adaptiveResolutionChange > 0 ? true : false);
     
    14181507  {
    14191508    vps->setVpsVuiBspHrdPresentFlag(true);
     1509#if Q0078_ADD_LAYER_SETS
     1510    vps->setVpsNumBspHrdParametersMinus1(vps->getVpsNumLayerSetsMinus1() - 1);
     1511#else
    14201512    vps->setVpsNumBspHrdParametersMinus1(vps->getNumLayerSets() - 2);
     1513#endif
    14211514    vps->createBspHrdParamBuffer(vps->getVpsNumBspHrdParametersMinus1() + 1);
    14221515    for ( i = 0; i <= vps->getVpsNumBspHrdParametersMinus1(); i++ )
     
    14511544      vps->setBspHrdParameters( i, pcCfgLayer->getFrameRate(), numDU, pcCfgLayer->getTargetBitrate(), ( pcCfgLayer->getIntraPeriod() > 0 ) );
    14521545    }
     1546#if Q0078_ADD_LAYER_SETS
     1547    for (UInt h = 1; h <= vps->getVpsNumLayerSetsMinus1(); h++)
     1548#else
    14531549    for(UInt h = 1; h <= (vps->getNumLayerSets()-1); h++)
     1550#endif
    14541551    {
    14551552      vps->setNumBitstreamPartitions(h, 1);
     
    15321629    if( m_isField )
    15331630    {
    1534 #if SVC_UPSAMPLING
     1631#if SVC_EXTENSION
    15351632#if LAYER_CTB
    15361633#if AUXILIARY_PICTURES
     
    15521649    else
    15531650    {
    1554 #if SVC_UPSAMPLING
     1651#if SVC_EXTENSION
    15551652#if LAYER_CTB
    15561653#if AUXILIARY_PICTURES
     
    19912088    rpcPicYuvRec = new TComPicYuv;
    19922089
    1993 #if SVC_UPSAMPLING
    19942090#if LAYER_CTB
    19952091#if AUXILIARY_PICTURES
     
    20052101#endif
    20062102#endif
    2007 #else
    2008     rpcPicYuvRec->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
    2009 #endif
    20102103
    20112104  }
     
    20322125Void TAppEncTop::xWriteRecon(UInt layer, Int iNumEncoded)
    20332126{
     2127#if REPN_FORMAT_IN_VPS
     2128  ChromaFormat chromaFormatIdc = m_acLayerCfg[layer].getChromaFormatIDC();
     2129  Int xScal = TComSPS::getWinUnitX( chromaFormatIdc );
     2130  Int yScal = TComSPS::getWinUnitY( chromaFormatIdc );
     2131#endif
     2132
    20342133  if (m_isField)
    20352134  {
     
    20542153#endif
    20552154      {
     2155#if REPN_FORMAT_IN_VPS
     2156        m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRecTop, pcPicYuvRecBottom, m_acLayerCfg[layer].getConfLeft() * xScal, m_acLayerCfg[layer].getConfRight() * xScal,
     2157          m_acLayerCfg[layer].getConfTop() * yScal, m_acLayerCfg[layer].getConfBottom() * yScal, m_isTopFieldFirst );
     2158#else
    20562159        m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRecTop, pcPicYuvRecBottom, m_acLayerCfg[layer].getConfLeft(), m_acLayerCfg[layer].getConfRight(), m_acLayerCfg[layer].getConfTop(), m_acLayerCfg[layer].getConfBottom(), m_isTopFieldFirst );
     2160#endif
    20572161      }
    20582162    }
     
    20782182#endif
    20792183      {
     2184#if REPN_FORMAT_IN_VPS
     2185        m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getConfLeft() * xScal, m_acLayerCfg[layer].getConfRight() * xScal,
     2186          m_acLayerCfg[layer].getConfTop() * yScal, m_acLayerCfg[layer].getConfBottom() * yScal );
     2187#else
    20802188        m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getConfLeft(), m_acLayerCfg[layer].getConfRight(),
    20812189          m_acLayerCfg[layer].getConfTop(), m_acLayerCfg[layer].getConfBottom() );
     2190#endif
    20822191      }
    20832192    }
  • trunk/source/Lib/TLibCommon/CommonDef.h

    r713 r815  
    5858#if SVC_EXTENSION
    5959#include <vector>
    60 #define NV_VERSION        "6.0 (HM-14.0)"                 ///< Current software version
     60#define NV_VERSION        "6.1 (HM-14.0)"                 ///< Current software version
    6161#else
    6262#define NV_VERSION        "14.0"                ///< Current software version
  • trunk/source/Lib/TLibCommon/SEI.h

    r713 r815  
    3737#include <cstring>
    3838
     39#if Q0078_ADD_LAYER_SETS
     40#include "TLibCommon/NAL.h"
     41#endif
     42
    3943//! \ingroup TLibCommon
    4044//! \{
     
    6670    POST_FILTER_HINT                     = 22,
    6771    TONE_MAPPING_INFO                    = 23,
     72#if P0050_KNEE_FUNCTION_SEI
     73    KNEE_FUNCTION_INFO                   = 24,
     74#endif
    6875    FRAME_PACKING                        = 45,
    6976    DISPLAY_ORIENTATION                  = 47,
     
    9198#if Q0074_SEI_COLOR_MAPPING
    9299    COLOR_MAPPING_INFO                   = 143,
     100#endif
     101#if Q0078_ADD_LAYER_SETS
     102    OUTPUT_LAYER_SET_NESTING             = 144,
     103    VPS_REWRITING                        = 145,
     104#endif
     105#if Q0189_TMVP_CONSTRAINTS
     106    TMVP_CONSTRAINTS                     = 146,
     107#endif
     108#if Q0247_FRAME_FIELD_INFO
     109    FRAME_FIELD_INFO                     = 147,
    93110#endif
    94111  };
     
    407424  Int    m_extendedWhiteLevelLumaCodeValue;
    408425};
    409 
     426#if P0050_KNEE_FUNCTION_SEI
     427class SEIKneeFunctionInfo : public SEI
     428{
     429public:
     430  PayloadType payloadType() const { return KNEE_FUNCTION_INFO; }
     431  SEIKneeFunctionInfo() {}
     432  virtual ~SEIKneeFunctionInfo() {}
     433
     434  Int   m_kneeId;
     435  Bool  m_kneeCancelFlag;
     436  Bool  m_kneePersistenceFlag;
     437  Bool  m_kneeMappingFlag;
     438  Int   m_kneeInputDrange;
     439  Int   m_kneeInputDispLuminance;
     440  Int   m_kneeOutputDrange;
     441  Int   m_kneeOutputDispLuminance;
     442  Int   m_kneeNumKneePointsMinus1;
     443  std::vector<Int> m_kneeInputKneePoint;
     444  std::vector<Int> m_kneeOutputKneePoint;
     445};
     446#endif
    410447#if Q0074_SEI_COLOR_MAPPING
    411448class SEIColorMappingInfo : public SEI
     
    486523#endif
    487524
     525#if Q0189_TMVP_CONSTRAINTS
     526class SEITMVPConstrains : public SEI
     527{
     528public:
     529  PayloadType payloadType() const { return TMVP_CONSTRAINTS; }
     530
     531  SEITMVPConstrains()
     532    : prev_pics_not_used_flag(0),no_intra_layer_col_pic_flag(0)
     533    {}
     534
     535  virtual ~SEITMVPConstrains()
     536  {
     537  }
     538
     539  UInt prev_pics_not_used_flag;
     540  UInt no_intra_layer_col_pic_flag;
     541};
     542#endif
     543
     544#if Q0247_FRAME_FIELD_INFO
     545class SEIFrameFieldInfo: public SEI
     546{
     547public:
     548  PayloadType payloadType() const { return FRAME_FIELD_INFO; }
     549
     550  SEIFrameFieldInfo()
     551    : m_ffinfo_picStruct(0),m_ffinfo_sourceScanType(0), m_ffinfo_duplicateFlag(false)
     552    {}
     553
     554  virtual ~SEIFrameFieldInfo()
     555  {
     556  }
     557
     558  UInt  m_ffinfo_picStruct;
     559  UInt  m_ffinfo_sourceScanType;
     560  Bool  m_ffinfo_duplicateFlag;
     561};
     562
     563#endif
     564
    488565typedef std::list<SEI*> SEIMessages;
    489566
     
    583660};
    584661
     662#if Q0078_ADD_LAYER_SETS
     663class SEIOutputLayerSetNesting : public SEI
     664{
     665public:
     666  PayloadType payloadType() const { return OUTPUT_LAYER_SET_NESTING; }
     667
     668  SEIOutputLayerSetNesting() {}
     669  virtual ~SEIOutputLayerSetNesting()
     670  {
     671    if (!m_callerOwnsSEIs)
     672    {
     673      deleteSEIs(m_nestedSEIs);
     674    }
     675  }
     676
     677  Bool m_olsFlag;
     678  UInt m_numOlsIndicesMinus1;
     679  UInt m_olsIdx[1024];
     680  Bool  m_callerOwnsSEIs;
     681  SEIMessages m_nestedSEIs;
     682};
     683
     684class SEIVPSRewriting : public SEI
     685{
     686public:
     687  PayloadType payloadType() const { return VPS_REWRITING; }
     688
     689  SEIVPSRewriting() {}
     690  virtual ~SEIVPSRewriting() {}
     691
     692  NALUnit* nalu;
     693};
     694#endif
     695
    585696//! \}
  • trunk/source/Lib/TLibCommon/TCom3DAsymLUT.cpp

    r713 r815  
    4444
    4545  if( m_pCuboid != NULL )
     46  {
    4647    destroy();
     48  }
    4749  xAllocate3DArray( m_pCuboid , m_nYSize , m_nUSize , m_nVSize );
    4850}
     
    8890
    8991  // alignment padding
    90   pU += (nWidth>>1);
    91   pV += (nWidth>>1);
    92   for( Int y = 0 ; y < (nHeight>>1) ; y ++ )
    93   {
    94     *pU = pU[-1];
    95     *pV = pV[-1];
    96     pU += nStrideC;
    97     pV += nStrideC;
    98   }
    99   memcpy(pU-(nWidth>>1), pU-(nWidth>>1)-nStrideC, ((nWidth>>1)+1)*sizeof(Pel));
    100   memcpy(pV-(nWidth>>1), pV-(nWidth>>1)-nStrideC, ((nWidth>>1)+1)*sizeof(Pel));
    101   pU = pcPic->getCbAddr();
    102   pV = pcPic->getCrAddr();
     92  pcPic->setBorderExtension( false );
     93  pcPic->extendPicBorder();
    10394
    10495  Pel iMaxValY = (1<<getOutputBitDepthY())-1;
  • trunk/source/Lib/TLibCommon/TCom3DAsymLUT.h

    r713 r815  
    100100  p[0] = new T*[xSize*ySize];
    101101  for( Int x = 1 ; x < xSize ; x++ )
     102  {
    102103    p[x] = p[x-1] + ySize;
     104  }
    103105  p[0][0] = new T[xSize*ySize*zSize];
    104106  for( Int x = 0 ; x < xSize ; x++ )
    105107  {
    106108    for( Int y = 0 ; y < ySize ; y++ )
     109    {
    107110      p[x][y] = p[0][0] + x * ySize * zSize + y * zSize;
     111    }
    108112  }
    109113}
     
    117121    {
    118122      if( p[0][0] != NULL )
     123      {
    119124        delete [] p[0][0];
     125      }
    120126      delete [] p[0];
    121127    }
  • trunk/source/Lib/TLibCommon/TComDataCU.cpp

    r713 r815  
    35173517#endif
    35183518
    3519 #if N0139_POSITION_ROUNDING_OFFSET
     3519#if REF_IDX_MFM
     3520  // offset for collocated block in the motion mapping
    35203521  if( iMotionMapping == 1 )
    35213522  {
     3523    Bool unequalPictureSizeFlag = g_posScalingFactor[refLayerIdc][0] != 65536 || g_posScalingFactor[refLayerIdc][1] != 65536; //the condition should be updated according to the WD.
     3524
    35223525    // actually, motion field compression is performed in the Void TComPic::compressMotion() function, but with (+4) the rounding may have effect on the picture boundary check.
    3523     iBX = ( ( iBX + 4 ) >> 4 ) << 4;
    3524     iBY = ( ( iBY + 4 ) >> 4 ) << 4;
     3526    if( unequalPictureSizeFlag )
     3527    {
     3528      iBX = ( ( iBX + 4 ) >> 4 ) << 4;
     3529      iBY = ( ( iBY + 4 ) >> 4 ) << 4;
     3530    }
     3531    else
     3532    {
     3533      iBX += 4;
     3534      iBY += 4;
     3535    }
    35253536  }
    35263537#endif
     
    36373648  {
    36383649    Int refIdxL0 = cMvFieldL0.getRefIdx();
    3639     if(getSlice()->getRefPic(REF_PIC_LIST_0, refIdxL0)->isILR(m_layerId))
     3650    TComPic* refPic = m_pcSlice->getRefPic(REF_PIC_LIST_0, refIdxL0);
     3651
     3652    if(refPic->isILR(m_layerId))
    36403653    {
    36413654      checkZeroMVILR &= (cMvFieldL0.getHor() == 0 && cMvFieldL0.getVer() == 0);
     3655
     3656      // It is a requirement of bitstream conformance that when the reference picture represented by the variable refIdxLX is an inter-layer reference picture,
     3657      // VpsInterLayerSamplePredictionEnabled[ LayerIdxInVps[ currLayerId ] ][ LayerIdxInVps[ rLId ] ] shall be equal to 1, where rLId is set equal to nuh_layer_id of the inter-layer picture
     3658      checkZeroMVILR &= m_pcSlice->getVPS()->isSamplePredictionType( m_layerId, refPic->getLayerId() );
    36423659    }
    36433660  }
     
    36453662  {
    36463663    Int refIdxL1  = cMvFieldL1.getRefIdx();
    3647     if(getSlice()->getRefPic(REF_PIC_LIST_1, refIdxL1)->isILR(m_layerId))
     3664    TComPic* refPic = m_pcSlice->getRefPic(REF_PIC_LIST_1, refIdxL1);
     3665
     3666    if(refPic->isILR(m_layerId))
    36483667    {
    36493668      checkZeroMVILR &= (cMvFieldL1.getHor() == 0 && cMvFieldL1.getVer() == 0);
     3669
     3670      // It is a requirement of bitstream conformance that when the reference picture represented by the variable refIdxLX is an inter-layer reference picture,
     3671      // VpsInterLayerSamplePredictionEnabled[ LayerIdxInVps[ currLayerId ] ][ LayerIdxInVps[ rLId ] ] shall be equal to 1, where rLId is set equal to nuh_layer_id of the inter-layer picture
     3672      checkZeroMVILR &= m_pcSlice->getVPS()->isSamplePredictionType( m_layerId, refPic->getLayerId() );
    36503673    }
    36513674  }
  • trunk/source/Lib/TLibCommon/TComPic.cpp

    r595 r815  
    7272{
    7373}
    74 #if SVC_UPSAMPLING
     74#if SVC_EXTENSION
    7575#if AUXILIARY_PICTURES
    7676Void TComPic::create( Int iWidth, Int iHeight, ChromaFormat chromaFormatIDC, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, Window &conformanceWindow, Window &defaultDisplayWindow,
     
    184184 
    185185  deleteSEIs(m_SEIs);
    186 #if SVC_EXTENSION && SVC_UPSAMPLING
     186#if SVC_EXTENSION
    187187  for( Int i = 0; i < MAX_LAYERS; i++ )
    188188  {
  • trunk/source/Lib/TLibCommon/TComPic.h

    r713 r815  
    9292  Int                   m_nFrameBit;
    9393#endif
    94 
     94#if POC_RESET_IDC_DECODER
     95  Bool                  m_currAuFlag;
     96#endif
    9597public:
    9698  TComPic();
    9799  virtual ~TComPic();
    98100 
     101#if SVC_EXTENSION
    99102#if AUXILIARY_PICTURES
    100 #if SVC_UPSAMPLING
    101103  Void          create( Int iWidth, Int iHeight, ChromaFormat chromaFormatIDC, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, Window &conformanceWindow, Window &defaultDisplayWindow,
    102104                        Int *numReorderPics, TComSPS* pcSps = NULL, Bool bIsVirtual = false );
    103105#else
    104   Void          create( Int iWidth, Int iHeight, ChromaFormat chromaFormatIDC, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, Window &conformanceWindow, Window &defaultDisplayWindow,
    105                         Int *numReorderPics, Bool bIsVirtual = false );                       
    106 #endif
    107 #else
    108 #if SVC_UPSAMPLING
    109106  Void          create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, Window &conformanceWindow, Window &defaultDisplayWindow,
    110107                        Int *numReorderPics, TComSPS* pcSps = NULL, Bool bIsVirtual = false );
     108#endif
    111109#else
    112110  Void          create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, Window &conformanceWindow, Window &defaultDisplayWindow,
    113                         Int *numReorderPics, Bool bIsVirtual = false );                        
    114 #endif
    115 #endif
     111                        Int *numReorderPics, Bool bIsVirtual = false );
     112#endif //SVC_EXTENSION
     113
    116114  virtual Void  destroy();
    117115 
     
    202200  TComPicYuv*   getFullPelBaseRec   (UInt refLayerIdc)  { return  m_pcFullPelBaseRec[refLayerIdc];  }
    203201#if REF_IDX_ME_ZEROMV || ENCODER_FAST_MODE || REF_IDX_MFM
    204   Bool          isILR( UInt currLayerId )   { return ( getIsLongTerm() && m_layerId < currLayerId ); }
     202  Bool          isILR( UInt currLayerId )   { return ( m_bIsLongTerm && m_layerId < currLayerId ); }
    205203#endif
    206204#if REF_IDX_MFM
     
    227225  Int   getFrameBit()         { return m_nFrameBit; }
    228226#endif
     227#if POC_RESET_IDC_DECODER
     228  Bool isCurrAu() { return m_currAuFlag; }
     229  Void setCurrAuFlag(Bool x) {m_currAuFlag = x; }
     230#endif
    229231};// END CLASS DEFINITION TComPic
    230232
  • trunk/source/Lib/TLibCommon/TComPicYuv.cpp

    r713 r815  
    6767{
    6868}
     69
     70#if SVC_EXTENSION
    6971#if AUXILIARY_PICTURES
    70 #if SVC_UPSAMPLING
    7172Void TComPicYuv::create( Int iPicWidth, Int iPicHeight, ChromaFormat chromaFormatIDC, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth, TComSPS* pcSps )
    7273#else
    73 Void TComPicYuv::create( Int iPicWidth, Int iPicHeight, ChromaFormat chromaFormatIDC, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth )
    74 #endif
    75 #else
    76 #if SVC_UPSAMPLING
    7774Void TComPicYuv::create( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth, TComSPS* pcSps )
     75#endif
    7876#else
    7977Void TComPicYuv::create( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth )
    8078#endif
    81 #endif
    8279{
    8380  m_iPicWidth       = iPicWidth;
    8481  m_iPicHeight      = iPicHeight;
    8582 
    86 #if SVC_UPSAMPLING
     83#if SVC_EXTENSION
    8784  if(pcSps != NULL)
    8885  {
     
    369366}
    370367
     368#if SVC_EXTENSION
     369Void TComPicYuv::dump( Char* pFileName, Bool bAdd, Int bitDepth )
     370{
     371  FILE* pFile;
     372  if (!bAdd)
     373  {
     374    pFile = fopen (pFileName, "wb");
     375  }
     376  else
     377  {
     378    pFile = fopen (pFileName, "ab");
     379  }
     380
     381  if( bitDepth == 8 )
     382  {
     383    dump( pFileName, bAdd );
     384    return;
     385  }
     386 
     387  Int   x, y;
     388  UChar uc;
     389 
     390  Pel*  piY   = getLumaAddr();
     391  Pel*  piCb  = getCbAddr();
     392  Pel*  piCr  = getCrAddr();
     393 
     394  for ( y = 0; y < m_iPicHeight; y++ )
     395  {
     396    for ( x = 0; x < m_iPicWidth; x++ )
     397    {
     398      uc = piY[x] & 0xff;     
     399      fwrite( &uc, sizeof(UChar), 1, pFile );
     400      uc = (piY[x] >> 8) & 0xff;     
     401      fwrite( &uc, sizeof(UChar), 1, pFile );
     402    }
     403    piY += getStride();
     404  }
     405 
     406  for ( y = 0; y < m_iPicHeight >> 1; y++ )
     407  {
     408    for ( x = 0; x < m_iPicWidth >> 1; x++ )
     409    {
     410      uc = piCb[x] & 0xff;
     411      fwrite( &uc, sizeof(UChar), 1, pFile );
     412      uc = (piCb[x] >> 8) & 0xff;
     413      fwrite( &uc, sizeof(UChar), 1, pFile );
     414    }
     415    piCb += getCStride();
     416  }
     417 
     418  for ( y = 0; y < m_iPicHeight >> 1; y++ )
     419  {
     420    for ( x = 0; x < m_iPicWidth >> 1; x++ )
     421    {
     422      uc = piCr[x] & 0xff;
     423      fwrite( &uc, sizeof(UChar), 1, pFile );
     424      uc = (piCr[x] >> 8) & 0xff;
     425      fwrite( &uc, sizeof(UChar), 1, pFile );
     426    }
     427    piCr += getCStride();
     428  }
     429 
     430  fclose(pFile);
     431}
     432
     433#endif
    371434
    372435//! \}
  • trunk/source/Lib/TLibCommon/TComPicYuv.h

    r595 r815  
    4242#include "CommonDef.h"
    4343#include "TComRom.h"
    44 #if SVC_UPSAMPLING
     44#if SVC_EXTENSION
    4545#include "TComSlice.h"
    4646#endif
     
    9494  ChromaFormat m_chromaFormatIDC; ////< Chroma Format
    9595#endif
    96 #if SVC_UPSAMPLING
    9796  Window  m_conformanceWindow;
    98 #endif
    9997#if M0040_ADAPTIVE_RESOLUTION_CHANGE
    10098  Bool    m_isReconstructed;
     
    112110  //  Memory management
    113111  // ------------------------------------------------------------------------------------------------
     112#if SVC_EXTENSION
    114113#if AUXILIARY_PICTURES
    115 #if SVC_UPSAMPLING
    116114  Void  create      ( Int iPicWidth, Int iPicHeight, ChromaFormat chromaFormatIDC, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth, TComSPS* pcSps = NULL);
    117115#else
    118   Void  create      ( Int iPicWidth, Int iPicHeight, ChromaFormat chromaFormatIDC, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth );
    119 #endif 
    120 #else
    121 #if SVC_UPSAMPLING
    122116  Void  create      ( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth, TComSPS* pcSps = NULL);
     117#endif
    123118#else
    124119  Void  create      ( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth );
    125 #endif 
    126 #endif
     120#endif //SVC_EXTENSION
    127121 
    128122  Void  destroy     ();
     
    187181#if SVC_EXTENSION
    188182  Void   setHeight   ( Int iPicHeight )     { m_iPicHeight = iPicHeight; }
    189 #if SVC_UPSAMPLING
    190183  Window& getConformanceWindow()                           { return  m_conformanceWindow;             }
    191184  Void    setConformanceWindow(Window& conformanceWindow ) { m_conformanceWindow = conformanceWindow; }
    192 #endif
    193185#if M0040_ADAPTIVE_RESOLUTION_CHANGE
    194186  Void  setReconstructed(Bool x) { m_isReconstructed = x;    }
     
    199191  Void convertToMonochrome();
    200192#endif
     193  Void dump( Char* pFileName, Bool bAdd, Int bitDepth );
    201194#endif //SVC_EXTENSION
    202195
  • trunk/source/Lib/TLibCommon/TComPrediction.cpp

    r713 r815  
    487487  pcCU->clipMv(cMv);
    488488
     489#if SVC_EXTENSION
     490  if( pcCU->getLayerId() > 0 )
     491  {
     492    TComPic* refPic = pcCU->getSlice()->getRefPic(eRefPicList, iRefIdx);
     493
     494    if( refPic->isILR(pcCU->getLayerId()) )
     495    {
     496      // It is a requirement of bitstream conformance that when the reference picture represented by the variable refIdxLX is an inter-layer reference picture,
     497      // VpsInterLayerSamplePredictionEnabled[ LayerIdxInVps[ currLayerId ] ][ LayerIdxInVps[ rLId ] ] shall be equal to 1, where rLId is set equal to nuh_layer_id of the inter-layer picture
     498      assert( pcCU->getSlice()->getVPS()->isSamplePredictionType( pcCU->getLayerId(), refPic->getLayerId() ) );
     499
    489500#if REF_IDX_ME_ZEROMV
    490   assert( ( pcCU->getSlice()->getRefPic(eRefPicList, iRefIdx)->isILR(pcCU->getLayerId()) && cMv.getHor() == 0 && cMv.getVer() == 0 ) || pcCU->getSlice()->getRefPic(eRefPicList, iRefIdx)->isILR(pcCU->getLayerId()) == false );
     501      // It is a requirement of bitstream conformance that the variables mvLX[ 0 ] and mvLX[ 1 ] shall be equal to 0 if the value of refIdxLX corresponds to an inter-layer reference picture.
     502      assert( cMv.getHor() == 0 && cMv.getVer() == 0 );
     503#endif
     504    }
     505
     506  }
    491507#endif
    492508
     
    765781}
    766782
    767 #if SVC_UPSAMPLING
     783#if SVC_EXTENSION
    768784#if O0215_PHASE_ALIGNMENT
    769785#if O0194_JOINT_US_BITSHIFT
     
    791807#endif
    792808#endif
    793 #endif
     809#endif //SVC_EXTENSION
    794810//! \}
  • trunk/source/Lib/TLibCommon/TComPrediction.h

    r713 r815  
    4848#include "TComWeightPrediction.h"
    4949
    50 #if SVC_UPSAMPLING
     50#if SVC_EXTENSION
    5151#include "TComUpsampleFilter.h"
    5252#endif
     
    7272 
    7373  TComInterpolationFilter m_if;
    74  
    75 #if SVC_UPSAMPLING
    76   TComUpsampleFilter      m_cUsf;
    77 #endif
    7874
    7975  Pel*   m_pLumaRecBuffer;       ///< array for downsampled reconstructed luma sample
     
    9490  Void xDCPredFiltering( Int* pSrc, Int iSrcStride, Pel*& rpDst, Int iDstStride, Int iWidth, Int iHeight );
    9591  Bool xCheckIdenticalMotion    ( TComDataCU* pcCU, UInt PartAddr);
     92 
     93#if SVC_EXTENSION
     94  TComUpsampleFilter      m_cUsf;
     95#endif
    9696
    9797public:
     
    118118
    119119#if SVC_EXTENSION
    120 #if SVC_UPSAMPLING
    121120#if O0215_PHASE_ALIGNMENT
    122121#if O0194_JOINT_US_BITSHIFT
     
    132131#endif
    133132#endif
    134 #endif
    135133#endif //SVC_EXTENSION
    136134};
  • trunk/source/Lib/TLibCommon/TComRom.cpp

    r595 r815  
    527527  {
    528528  case NAL_UNIT_CODED_SLICE_TRAIL_N:
     529    return "TRAIL_N";
    529530  case NAL_UNIT_CODED_SLICE_TRAIL_R:
    530     return "TRAIL";
     531    return "TRAIL_R";
    531532 
    532533  case NAL_UNIT_CODED_SLICE_TSA_N:
     534    return "  TSA_N";
    533535  case NAL_UNIT_CODED_SLICE_TSA_R:
    534     return "  TSA";
     536    return "  TSA_R";
    535537 
    536538  case NAL_UNIT_CODED_SLICE_STSA_N:
     539    return " STSA_N";
    537540  case NAL_UNIT_CODED_SLICE_STSA_R:
    538     return " STSA";
     541    return " STSA_R";
    539542
    540543  case NAL_UNIT_CODED_SLICE_RADL_N:
     544    return " RADL_N";
    541545  case NAL_UNIT_CODED_SLICE_RADL_R:
    542     return " RADL";
     546    return " RADL_R";
    543547 
    544548  case NAL_UNIT_CODED_SLICE_RASL_N:
     549    return " RASL_N";
    545550  case NAL_UNIT_CODED_SLICE_RASL_R:
    546     return " RASL";
     551    return " RASL_R";
    547552
    548553  case NAL_UNIT_CODED_SLICE_BLA_W_LP:
    549554  case NAL_UNIT_CODED_SLICE_BLA_W_RADL:
    550555  case NAL_UNIT_CODED_SLICE_BLA_N_LP:
    551     return "  BLA";
     556    return "    BLA";
    552557
    553558  case NAL_UNIT_CODED_SLICE_IDR_W_RADL:
    554559  case NAL_UNIT_CODED_SLICE_IDR_N_LP:
    555     return "  IDR";
     560    return "    IDR";
    556561 
    557562  case NAL_UNIT_CODED_SLICE_CRA:
    558     return "  CRA";
     563    return "    CRA";
    559564
    560565  default:
    561     return "     ";
     566    return "       ";
    562567  };
    563568}
  • trunk/source/Lib/TLibCommon/TComSlice.cpp

    r713 r815  
    125125, m_pocMsbValPresentFlag          ( false )
    126126#endif
     127#if POC_RESET_IDC_DECODER || POC_RESET_IDC_ENCODER
     128, m_picOrderCntLsb (0)
     129#endif
    127130#endif //SVC_EXTENSION
    128131{
     
    200203  m_numEntryPointOffsets = 0;
    201204  m_enableTMVPFlag = true;
     205#if POC_RESET_IDC_SIGNALLING
     206  m_pocResetIdc                   = 0;
     207  m_pocResetPeriodId              = 0;
     208  m_fullPocResetFlag              = false;
     209  m_pocLsbVal                     = 0;
     210  m_pocMsbVal                     = 0;
     211  m_pocMsbValRequiredFlag         = false;
     212  m_pocMsbValPresentFlag          = false;
     213#endif
     214#if POC_RESET_IDC_DECODER || POC_RESET_IDC_ENCODER
     215  m_picOrderCntLsb = 0;
     216#endif
    202217}
    203218
     
    223238}
    224239#endif
    225 
     240#if POC_RESET_IDC_DECODER
     241Bool TComSlice::getRaslPicFlag      ()
     242{
     243  return  getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R
     244  || getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N;
     245}
     246Bool TComSlice::getRadlPicFlag      ()
     247{
     248  return  getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_R
     249  || getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N;
     250}
     251#endif
     252#if POC_RESET_IDC_ENCODER
     253Void TComSlice::decrementRefPocValues(Int const decrementValue)
     254{
     255  for(Int listNum = 0; listNum < 2; listNum++)
     256  {
     257    RefPicList dpbPicSliceList = (listNum == 1) ? REF_PIC_LIST_1 : REF_PIC_LIST_0;
     258    for(Int listIdx = 0; listIdx < getNumRefIdx( dpbPicSliceList ); listIdx++)
     259    {
     260      setRefPOC( getRefPOC(dpbPicSliceList, listIdx) - decrementValue,
     261                  dpbPicSliceList,
     262                  listIdx
     263                  );
     264    }
     265  }
     266}
     267Int TComSlice::getCurrMsb( Int currLsb, Int prevLsb, Int prevMsb, Int maxLsbVal )
     268{
     269  if( prevLsb - currLsb >= (maxLsbVal >> 1) )
     270  {
     271    return prevMsb + maxLsbVal;
     272  }
     273  else if( currLsb - prevLsb > (maxLsbVal >> 1) )
     274  {
     275    return prevMsb - maxLsbVal;
     276  }
     277  else
     278  {
     279    return prevMsb;
     280  }
     281}
     282#endif
    226283/**
    227284 - allocate table to contain substream sizes to be written to the slice header.
     
    279336  while ( iterPic != rcListPic.end() )
    280337  {
     338#if POC_RESET_IDC_ENCODER
     339    if( (pcPic->getPOC() == poc) && (pcPic->getSlice(0)->isReferenced()) )
     340#else
    281341    if(pcPic->getPOC() == poc)
     342#endif
    282343    {
    283344      break;
     
    293354    pcPic = *(iterPic);
    294355  }
    295 #if POC_RESET_FLAG
     356#if POC_RESET_FLAG || POC_RESET_IDC_DECODER
    296357  assert( pcPic->getSlice(0)->isReferenced() );
    297358#endif
     
    512573    }
    513574#if MAX_ONE_RESAMPLING_DIRECT_LAYERS
    514 #if SCALABILITY_MASK_E0104
    515     if( m_pcVPS->getScalabilityMask(2) )
    516 #else
    517     if( m_pcVPS->getScalabilityMask(1) )
    518 #endif
     575    if( m_pcVPS->getScalabilityMask( SCALABILITY_ID ) )
    519576    {
    520577      Int numResampler = 0;
     
    550607#endif
    551608#if O0194_DIFFERENT_BITDEPTH_EL_BL
    552         Int sameBitDepth = g_bitDepthYLayer[m_layerId] - g_bitDepthYLayer[refLayerId] + g_bitDepthCLayer[m_layerId] - g_bitDepthCLayer[refLayerId];
    553 
    554         if( !( g_posScalingFactor[refLayerIdc][0] == 65536 && g_posScalingFactor[refLayerIdc][1] == 65536 ) || !scalingOffset || !sameBitDepth
     609        Bool sameBitDepths = ( g_bitDepthYLayer[m_layerId] == g_bitDepthYLayer[refLayerId] ) && ( g_bitDepthCLayer[m_layerId] == g_bitDepthCLayer[refLayerId] );
     610
     611        if( !( g_posScalingFactor[refLayerIdc][0] == 65536 && g_posScalingFactor[refLayerIdc][1] == 65536 ) || !scalingOffset || !sameBitDepths
    555612#if Q0048_CGS_3D_ASYMLUT
    556613          || getPPS()->getCGSFlag()
     
    775832#endif
    776833
    777 #if N0147_IRAP_ALIGN_FLAG
    778834  assert(m_aiNumRefIdx[REF_PIC_LIST_0] > 0);
    779835  assert(m_aiNumRefIdx[REF_PIC_LIST_1] > 0);
    780 #else
    781   assert(m_aiNumRefIdx[REF_PIC_LIST_0] > 1);
    782   assert(m_aiNumRefIdx[REF_PIC_LIST_1] > 1);
    783 #endif
    784836
    785837  //set L0 inter-layer reference picture modification
    786838#if RPL_INIT_N0316_N0082
    787839  Bool hasModification = (m_aiNumRefIdx[REF_PIC_LIST_0] == (numberOfPocBeforeCurr + m_activeNumILRRefIdx)) ? false : true;
     840
     841  if( m_activeNumILRRefIdx > 1 )
     842  {
     843    hasModification = (m_aiNumRefIdx[REF_PIC_LIST_0] >= (numberOfPocBeforeCurr + m_activeNumILRRefIdx)) ? false : true;
     844  }
    788845#else
    789846  Bool hasModification = (m_aiNumRefIdx[REF_PIC_LIST_0] == numberOfRpsCurrTempList) ? false : true;
    790847#endif
    791 #if N0147_IRAP_ALIGN_FLAG
    792848  hasModification = hasModification && ( m_aiNumRefIdx[REF_PIC_LIST_0] > 1 );
    793 #endif
    794849  refPicListModification->setRefPicListModificationFlagL0(hasModification);
    795850  if(hasModification)
     
    799854      refPicListModification->setRefPicSetIdxL0(i, i);
    800855    }
     856
    801857    if(m_aiNumRefIdx[REF_PIC_LIST_0] > numberOfRpsCurrTempList)
    802858    {
    803         // repeat last ref pic when the number of active ref idx are more than RPS entries
     859      // repeat last ref pic when the number of active ref idx are more than RPS entries
    804860      for (Int i = numberOfRpsCurrTempList; i < m_aiNumRefIdx[REF_PIC_LIST_0]; i ++)
    805861      {
     
    809865    else
    810866    {
    811       for(Int i = m_activeNumILRRefIdx; i > 0; i-- )
     867      // number of ILRPs included into the reference picture list with the list modification
     868      Int includeNumILRP = min( max(1, m_aiNumRefIdx[REF_PIC_LIST_0]-numberOfPocBeforeCurr), m_activeNumILRRefIdx);
     869
     870      for(Int i = includeNumILRP; i > 0; i-- )
    812871      {
    813872#if RPL_INIT_N0316_N0082
    814873        if((numberOfPocBeforeCurr) >= m_aiNumRefIdx[REF_PIC_LIST_0])
    815874        {
    816           refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfPocBeforeCurr);
     875          refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfPocBeforeCurr + includeNumILRP - i);
    817876        }
    818877        else
    819878        {
    820           refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfPocBeforeCurr);
     879          refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfPocBeforeCurr + includeNumILRP - i);
    821880          for (Int j = numberOfPocBeforeCurr; j < (m_aiNumRefIdx[REF_PIC_LIST_0] - i); j++)
    822881          {
    823             refPicListModification->setRefPicSetIdxL0(j, j + m_activeNumILRRefIdx);
     882            assert( j + includeNumILRP < numberOfRpsCurrTempList );
     883            refPicListModification->setRefPicSetIdxL0(j, j + includeNumILRP);
    824884          }
    825885        }
     
    832892
    833893  //set L1 inter-layer reference picture modification
    834   hasModification = (m_aiNumRefIdx[REF_PIC_LIST_1] == numberOfRpsCurrTempList) ? false : true;
    835 #if N0147_IRAP_ALIGN_FLAG
     894  hasModification = (m_aiNumRefIdx[REF_PIC_LIST_1] >= numberOfRpsCurrTempList) ? false : true;
    836895  hasModification = hasModification && ( m_aiNumRefIdx[REF_PIC_LIST_1] > 1 );
    837 #endif
    838896
    839897  refPicListModification->setRefPicListModificationFlagL1(hasModification);
     
    854912    else
    855913    {
    856       for(Int i = m_activeNumILRRefIdx; i > 0; i-- )
     914      Int includeNumILRP = min(m_aiNumRefIdx[REF_PIC_LIST_1], m_activeNumILRRefIdx);
     915
     916      for(Int i = includeNumILRP; i > 0; i-- )
    857917      {
    858918        refPicListModification->setRefPicSetIdxL1(m_aiNumRefIdx[REF_PIC_LIST_1] - i, numberOfRpsCurrTempList - i);
     
    10881148      rpcPic->setCurrSliceIdx(0);
    10891149#if NO_CLRAS_OUTPUT_FLAG
     1150#if POC_RESET_IDC_ENCODER
    10901151      if (noClrasOutputFlag)
    10911152      {
     1153        rpcPic->getSlice(0)->setReferenced(false);  // all layers // TODO. This does not mark all layers
     1154      }
     1155      else
     1156      {
     1157        if (rpcPic->getLayerId() == m_layerId) rpcPic->getSlice(0)->setReferenced(false);  // only current layer
     1158      }
     1159#else
     1160      if (noClrasOutputFlag)
     1161      {
    10921162        if (rpcPic->getPOC() != pocCurr) rpcPic->getSlice(0)->setReferenced(false);  // all layers
    10931163      }
     
    10961166        if (rpcPic->getPOC() != pocCurr && rpcPic->getLayerId() == m_layerId) rpcPic->getSlice(0)->setReferenced(false);  // only current layer
    10971167      }
     1168#endif
    10981169#else
    10991170      if (rpcPic->getPOC() != pocCurr) rpcPic->getSlice(0)->setReferenced(false);
     
    11011172      iterPic++;
    11021173    }
     1174#if POC_RESET_IDC_ENCODER
     1175    this->getPic()->getSlice(0)->setReferenced(true);   // Mark the current picture back as refererced.
     1176#endif
    11031177    if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
    11041178      || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
     
    13291403}
    13301404
    1331 
     1405#if POC_RESET_IDC_ENCODER
     1406Void TComSlice::checkLeadingPictureRestrictions(TComList<TComPic*>& rcListPic, Bool usePocBeforeReset)
     1407#else
    13321408Void TComSlice::checkLeadingPictureRestrictions(TComList<TComPic*>& rcListPic)
     1409#endif
    13331410{
    13341411  TComPic* rpcPic;
     
    14191496         nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL)
    14201497      {
     1498#if POC_RESET_IDC_ENCODER
     1499        if( usePocBeforeReset )
     1500        {
     1501          assert(rpcPic->getSlice(0)->getPocValueBeforeReset() < this->getPocValueBeforeReset());
     1502        }
     1503        else
     1504        {
     1505          assert(rpcPic->getPOC() < this->getPOC());
     1506        }
     1507#else
    14211508        assert(rpcPic->getPOC() < this->getPOC());
     1509#endif
    14221510      }
    14231511    }
     
    14371525          if(this->getAssociatedIRAPPOC() != rpcPic->getPOC())
    14381526          {
     1527#if POC_RESET_IDC_ENCODER
     1528            if( usePocBeforeReset )
     1529            {
     1530              assert(rpcPic->getSlice(0)->getPocValueBeforeReset() < this->getPocValueBeforeReset());
     1531            }
     1532            else
     1533            {
     1534              assert(rpcPic->getPOC() < this->getPOC());
     1535            }
     1536#else
    14391537            assert(rpcPic->getPOC() < this->getPOC());
     1538#endif
    14401539          }
    14411540        }
     
    14541553        // rpcPic is a picture that preceded the leading in decoding order since it exist in the DPB
    14551554        // rpcPic would violate the constraint if it was a trailing picture
     1555#if POC_RESET_IDC_ENCODER
     1556        if( usePocBeforeReset )
     1557        {
     1558          assert(rpcPic->getPOC() <= this->getAssociatedIrapPocBeforeReset());
     1559        }
     1560        else
     1561        {
     1562          assert(rpcPic->getPOC() <= this->getAssociatedIRAPPOC());
     1563        }
     1564#else
    14561565        assert(rpcPic->getPOC() <= this->getAssociatedIRAPPOC());
     1566#endif
    14571567      }
    14581568    }
     
    17601870    if(isAvailable == 0)   
    17611871    {           
     1872#if !UNAVAILABLE_PIC_BUGFIX
    17621873      if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess)
     1874#endif
    17631875      {
    17641876        if(!pReferencePictureSet->getUsed(i) )
     
    17811893      }
    17821894#if ALLOW_RECOVERY_POINT_AS_RAP
     1895#if UNAVAILABLE_PIC_BUGFIX
     1896      if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess)
     1897#else
    17831898      else if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess)
     1899#endif
    17841900      {
    17851901        atLeastOneUnabledByRecoveryPoint = 1;
     
    20252141  if ( layerId == 0 )
    20262142  {
    2027     retVal = sps->getPicWidthInLumaSamples();
     2143    if( vps->getAvcBaseLayerFlag() )
     2144    {
     2145      retVal = vps->getVpsRepFormat(layerId)->getPicWidthVpsInLumaSamples();
     2146    }
     2147    else
     2148    {
     2149      retVal = sps->getPicWidthInLumaSamples();
     2150    }
    20282151  }
    20292152  else
     
    20512174  if( layerId == 0 )
    20522175  {
    2053     retVal = sps->getPicHeightInLumaSamples();
     2176    if( vps->getAvcBaseLayerFlag() )
     2177    {
     2178      retVal = vps->getVpsRepFormat(layerId)->getPicHeightVpsInLumaSamples();
     2179    }
     2180    else
     2181    {
     2182      retVal = sps->getPicHeightInLumaSamples();
     2183    }
    20542184  }
    20552185  else
     
    22072337, m_bTemporalIdNestingFlag    (false)
    22082338, m_numHrdParameters          (  0)
    2209 #if !VPS_RENAME
    2210 , m_maxNuhReservedZeroLayerId (  0)
    2211 #endif
    22122339, m_hrdParameters             (NULL)
    22132340, m_hrdOpSetIdx               (NULL)
    22142341, m_cprmsPresentFlag          (NULL)
    2215 #if VPS_RENAME
    22162342, m_maxLayerId                (0)
    22172343, m_numLayerSets              (0)
    2218 #endif
    22192344#if VPS_EXTN_OP_LAYER_SETS
    22202345, m_numOutputLayerSets        (0) 
     
    22342359#endif
    22352360#endif
    2236 #if VPS_VUI_BITRATE_PICRATE
    22372361, m_bitRatePresentVpsFlag     (false)
    22382362, m_picRatePresentVpsFlag     (false)
    2239 #endif
    22402363#if REPN_FORMAT_IN_VPS
    22412364#if Q0195_REP_FORMAT_CLEANUP
     
    23112434  m_crossLayerPictureTypeAlignFlag = true;
    23122435#endif
    2313 #if N0147_IRAP_ALIGN_FLAG
    23142436  m_crossLayerIrapAlignFlag = true;
    2315 #endif
    23162437#if P0068_CROSS_LAYER_ALIGNED_IDR_ONLY_FOR_IRAP_FLAG
    23172438  m_crossLayerAlignedIdrOnlyFlag = false;
    23182439#endif
    2319 #if N0120_MAX_TID_REF_PRESENT_FLAG
    23202440  m_maxTidRefPresentFlag = true;
    2321 #endif
    23222441  for( Int i = 0; i < MAX_VPS_LAYER_ID_PLUS1 - 1; i++)
    23232442  {
     
    23362455  ::memset(m_loopFilterNotAcrossTilesFlag,  0, sizeof(m_loopFilterNotAcrossTilesFlag));
    23372456#endif
    2338 #if TILE_BOUNDARY_ALIGNED_FLAG
    23392457  ::memset(m_tileBoundariesAlignedFlag,  0, sizeof(m_tileBoundariesAlignedFlag));
    2340 #endif
    23412458#if VPS_VUI_WPP_NOT_IN_USE__FLAG
    23422459  m_wppNotInUseFlag = true;
     
    23632480  }
    23642481#endif
    2365 #if VPS_VUI_BITRATE_PICRATE 
    23662482  ::memset(m_bitRatePresentFlag, 0, sizeof(m_bitRatePresentFlag));
    23672483  ::memset(m_picRatePresentFlag, 0, sizeof(m_picRatePresentFlag));
     
    23702486  ::memset(m_constPicRateIdc   , 0, sizeof(m_constPicRateIdc)   );
    23712487  ::memset(m_avgPicRate        , 0, sizeof(m_avgPicRate)        );
    2372 #endif
    23732488#if REPN_FORMAT_IN_VPS
    23742489  ::memset( m_vpsRepFormatIdx, 0, sizeof(m_vpsRepFormatIdx) );
     
    24852600    }
    24862601  }
    2487 #if TILE_BOUNDARY_ALIGNED_FLAG 
     2602
    24882603  if (m_tilesNotInUseFlag)
    24892604  {
     
    24962611    }
    24972612  }
    2498 #endif
    2499 }
    2500 #endif
     2613}
     2614#endif
     2615
    25012616#if VPS_VUI_WPP_NOT_IN_USE__FLAG
    25022617Void TComVPS::setWppNotInUseFlag(Bool x)
     
    25262641}
    25272642
    2528 Void TComVPS::setNumRefLayers(Int currLayerId)
    2529 {
     2643Void TComVPS::setNumRefLayers()
     2644{
     2645  memset( m_numberRefLayers, 0, sizeof( m_numberRefLayers ) );
     2646
    25302647  for (Int i = 0; i < m_uiMaxLayers; i++)
    25312648  {
     
    25382655  }
    25392656}
     2657#endif
     2658
     2659#if Q0078_ADD_LAYER_SETS
     2660Void TComVPS::setPredictedLayerIds()
     2661{
     2662  for (UInt i = 0; i < getMaxLayers() - 1; i++)
     2663  {
     2664    UInt iNuhLId = getLayerIdInNuh(i);
     2665    UInt predIdx = 0;
     2666    for (UInt j = iNuhLId + 1; j < MAX_NUM_LAYER_IDS; j++)
     2667    {
     2668      if (getRecursiveRefLayerFlag(j, iNuhLId))
     2669      {
     2670        setPredictedLayerId(i, predIdx, j);
     2671        predIdx++;
     2672      }
     2673    }
     2674    setNumPredictedLayers(iNuhLId, predIdx);
     2675  }
     2676}
     2677
     2678Void TComVPS::setTreePartitionLayerIdList()
     2679{
     2680  Bool countedLayerIdxFlag[MAX_NUM_LAYER_IDS];
     2681
     2682  for (UInt i = 0; i <= getMaxLayers() - 1; i++)
     2683  {
     2684    countedLayerIdxFlag[i] = false;
     2685  }
     2686
     2687  Int numIndependentLayers = 0;
     2688
     2689  for (UInt i = 0; i <= getMaxLayers() - 1; i++)
     2690  {
     2691    UInt iNuhLId = getLayerIdInNuh(i);
     2692    if (getNumDirectRefLayers(iNuhLId) == 0)
     2693    {
     2694      setTreePartitionLayerId(numIndependentLayers, 0, iNuhLId);
     2695      setNumLayersInTreePartition(numIndependentLayers, 1);
     2696      for (UInt j = 0; j < getNumPredictedLayers(iNuhLId); j++)
     2697      {
     2698        if (!countedLayerIdxFlag[getLayerIdInVps(iNuhLId)])
     2699        {
     2700          setTreePartitionLayerId(numIndependentLayers, getNumLayersInTreePartition(numIndependentLayers), getPredictedLayerId(iNuhLId, j));
     2701          setNumLayersInTreePartition(numIndependentLayers, getNumLayersInTreePartition(numIndependentLayers) + 1);
     2702          countedLayerIdxFlag[getLayerIdInVps(getPredictedLayerId(iNuhLId, j))] = true;
     2703        }
     2704      }
     2705      numIndependentLayers++;
     2706    }
     2707  }
     2708
     2709  setNumIndependentLayers(numIndependentLayers);
     2710}
     2711
     2712void TComVPS::setLayerIdIncludedFlagsForAddLayerSets()
     2713{
     2714  for (UInt i = 0; i < getNumAddLayerSets(); i++)
     2715  {
     2716    for (UInt j = 1; j < getNumIndependentLayers(); j++)
     2717    {
     2718      Int layerNum = 0;
     2719      Int lsIdx = getVpsNumLayerSetsMinus1() + 1 + i;
     2720      for (Int layerId = 0; layerId < MAX_VPS_LAYER_ID_PLUS1; layerId++)
     2721      {
     2722        setLayerIdIncludedFlag(false, lsIdx, layerId);
     2723      }
     2724      for (Int treeIdx = 1; treeIdx < getNumIndependentLayers(); treeIdx++)
     2725      {
     2726        for (Int layerCnt = 0; layerCnt < getHighestLayerIdxPlus1(i, j); layerCnt++)
     2727        {
     2728          setLayerSetLayerIdList(lsIdx, layerNum, getTreePartitionLayerId(treeIdx, layerCnt));
     2729          setLayerIdIncludedFlag(true, lsIdx, getTreePartitionLayerId(treeIdx, layerCnt));
     2730          layerNum++;
     2731        }
     2732      }
     2733      setNumLayersInIdList(lsIdx, layerNum);
     2734    }
     2735  }
     2736}
     2737
    25402738#endif
    25412739
     
    27012899  return -1;  // Layer not found
    27022900}
     2901#endif
    27032902#if O0164_MULTI_LAYER_HRD
    27042903Void TComVPS::setBspHrdParameters( UInt hrdIdx, UInt frameRate, UInt numDU, UInt bitRate, Bool randomAccess )
     
    27802979}
    27812980#endif
     2981#if RESOLUTION_BASED_DPB
    27822982// RepFormat Assignment operator
    27832983RepFormat& RepFormat::operator= (const RepFormat &other)
     
    28513051#if SVC_EXTENSION
    28523052, m_layerId                   ( 0 )
     3053, m_extensionFlag             ( false )
    28533054, m_numScaledRefLayerOffsets  ( 0 )
    28543055#if REPN_FORMAT_IN_VPS
     
    29053106
    29063107  TimingInfo *timingInfo = vui->getTimingInfo();
    2907 #if TIMING_INFO_NONZERO_LAYERID_SPS
    2908   if( getLayerId() > 0 )
     3108#if SVC_EXTENSION
     3109  if( m_layerId > 0 )
    29093110  {
    29103111    timingInfo->setTimingInfoPresentFlag( false );
     3112    return;
     3113  }
     3114#endif
     3115
     3116  timingInfo->setTimingInfoPresentFlag( true );
     3117  switch( frameRate )
     3118  {
     3119  case 24:
     3120    timingInfo->setNumUnitsInTick( 1125000 );    timingInfo->setTimeScale    ( 27000000 );
     3121    break;
     3122  case 25:
     3123    timingInfo->setNumUnitsInTick( 1080000 );    timingInfo->setTimeScale    ( 27000000 );
     3124    break;
     3125  case 30:
     3126    timingInfo->setNumUnitsInTick( 900900 );     timingInfo->setTimeScale    ( 27000000 );
     3127    break;
     3128  case 50:
     3129    timingInfo->setNumUnitsInTick( 540000 );     timingInfo->setTimeScale    ( 27000000 );
     3130    break;
     3131  case 60:
     3132    timingInfo->setNumUnitsInTick( 450450 );     timingInfo->setTimeScale    ( 27000000 );
     3133    break;
     3134  default:
     3135    timingInfo->setNumUnitsInTick( 1001 );       timingInfo->setTimeScale    ( 60000 );
     3136    break;
     3137  }
     3138
     3139  Bool rateCnt = ( bitRate > 0 );
     3140  hrd->setNalHrdParametersPresentFlag( rateCnt );
     3141  hrd->setVclHrdParametersPresentFlag( rateCnt );
     3142
     3143  hrd->setSubPicCpbParamsPresentFlag( ( numDU > 1 ) );
     3144
     3145  if( hrd->getSubPicCpbParamsPresentFlag() )
     3146  {
     3147    hrd->setTickDivisorMinus2( 100 - 2 );                          //
     3148    hrd->setDuCpbRemovalDelayLengthMinus1( 7 );                    // 8-bit precision ( plus 1 for last DU in AU )
     3149    hrd->setSubPicCpbParamsInPicTimingSEIFlag( true );
     3150    hrd->setDpbOutputDelayDuLengthMinus1( 5 + 7 );                 // With sub-clock tick factor of 100, at least 7 bits to have the same value as AU dpb delay
    29113151  }
    29123152  else
    29133153  {
    2914 #endif
    2915     timingInfo->setTimingInfoPresentFlag( true );
    2916     switch( frameRate )
    2917     {
    2918     case 24:
    2919       timingInfo->setNumUnitsInTick( 1125000 );    timingInfo->setTimeScale    ( 27000000 );
    2920       break;
    2921     case 25:
    2922       timingInfo->setNumUnitsInTick( 1080000 );    timingInfo->setTimeScale    ( 27000000 );
    2923       break;
    2924     case 30:
    2925       timingInfo->setNumUnitsInTick( 900900 );     timingInfo->setTimeScale    ( 27000000 );
    2926       break;
    2927     case 50:
    2928       timingInfo->setNumUnitsInTick( 540000 );     timingInfo->setTimeScale    ( 27000000 );
    2929       break;
    2930     case 60:
    2931       timingInfo->setNumUnitsInTick( 450450 );     timingInfo->setTimeScale    ( 27000000 );
    2932       break;
    2933     default:
    2934       timingInfo->setNumUnitsInTick( 1001 );       timingInfo->setTimeScale    ( 60000 );
    2935       break;
    2936     }
    2937 
    2938     Bool rateCnt = ( bitRate > 0 );
    2939     hrd->setNalHrdParametersPresentFlag( rateCnt );
    2940     hrd->setVclHrdParametersPresentFlag( rateCnt );
    2941 
    2942     hrd->setSubPicCpbParamsPresentFlag( ( numDU > 1 ) );
    2943 
    2944     if( hrd->getSubPicCpbParamsPresentFlag() )
    2945     {
    2946       hrd->setTickDivisorMinus2( 100 - 2 );                          //
    2947       hrd->setDuCpbRemovalDelayLengthMinus1( 7 );                    // 8-bit precision ( plus 1 for last DU in AU )
    2948       hrd->setSubPicCpbParamsInPicTimingSEIFlag( true );
    2949       hrd->setDpbOutputDelayDuLengthMinus1( 5 + 7 );                 // With sub-clock tick factor of 100, at least 7 bits to have the same value as AU dpb delay
    2950     }
    2951     else
    2952     {
    2953       hrd->setSubPicCpbParamsInPicTimingSEIFlag( false ); 
    2954     }
    2955 
    2956     hrd->setBitRateScale( 4 );                                       // in units of 2~( 6 + 4 ) = 1,024 bps
    2957     hrd->setCpbSizeScale( 6 );                                       // in units of 2~( 4 + 4 ) = 1,024 bit
    2958     hrd->setDuCpbSizeScale( 6 );                                       // in units of 2~( 4 + 4 ) = 1,024 bit
    2959  
    2960     hrd->setInitialCpbRemovalDelayLengthMinus1(15);                  // assuming 0.5 sec, log2( 90,000 * 0.5 ) = 16-bit
    2961     if( randomAccess )
    2962     {
    2963       hrd->setCpbRemovalDelayLengthMinus1(5);                        // 32 = 2^5 (plus 1)
    2964       hrd->setDpbOutputDelayLengthMinus1 (5);                        // 32 + 3 = 2^6
    2965     }
    2966     else
    2967     {
    2968       hrd->setCpbRemovalDelayLengthMinus1(9);                        // max. 2^10
    2969       hrd->setDpbOutputDelayLengthMinus1 (9);                        // max. 2^10
    2970     }
    2971 
    2972 /*
    2973      Note: only the case of "vps_max_temporal_layers_minus1 = 0" is supported.
    2974 */
    2975     Int i, j;
    2976     UInt birateValue, cpbSizeValue;
    2977     UInt ducpbSizeValue;
    2978     UInt duBitRateValue = 0;
    2979 
    2980     for( i = 0; i < MAX_TLAYER; i ++ )
    2981     {
    2982       hrd->setFixedPicRateFlag( i, 1 );
    2983       hrd->setPicDurationInTcMinus1( i, 0 );
    2984       hrd->setLowDelayHrdFlag( i, 0 );
    2985       hrd->setCpbCntMinus1( i, 0 );
    2986 
    2987       birateValue  = bitRate;
    2988       cpbSizeValue = bitRate;                                     // 1 second
    2989       ducpbSizeValue = bitRate/numDU;
    2990       duBitRateValue = bitRate;
    2991       for( j = 0; j < ( hrd->getCpbCntMinus1( i ) + 1 ); j ++ )
    2992       {
    2993         hrd->setBitRateValueMinus1( i, j, 0, ( birateValue  - 1 ) );
    2994         hrd->setCpbSizeValueMinus1( i, j, 0, ( cpbSizeValue - 1 ) );
    2995         hrd->setDuCpbSizeValueMinus1( i, j, 0, ( ducpbSizeValue - 1 ) );
    2996         hrd->setCbrFlag( i, j, 0, ( j == 0 ) );
    2997 
    2998         hrd->setBitRateValueMinus1( i, j, 1, ( birateValue  - 1) );
    2999         hrd->setCpbSizeValueMinus1( i, j, 1, ( cpbSizeValue - 1 ) );
    3000         hrd->setDuCpbSizeValueMinus1( i, j, 1, ( ducpbSizeValue - 1 ) );
    3001         hrd->setDuBitRateValueMinus1( i, j, 1, ( duBitRateValue - 1 ) );
    3002         hrd->setCbrFlag( i, j, 1, ( j == 0 ) );
    3003       }
    3004     }
    3005 #if TIMING_INFO_NONZERO_LAYERID_SPS
    3006   }
    3007 #endif
     3154    hrd->setSubPicCpbParamsInPicTimingSEIFlag( false ); 
     3155  }
     3156
     3157  hrd->setBitRateScale( 4 );                                       // in units of 2~( 6 + 4 ) = 1,024 bps
     3158  hrd->setCpbSizeScale( 6 );                                       // in units of 2~( 4 + 4 ) = 1,024 bit
     3159  hrd->setDuCpbSizeScale( 6 );                                       // in units of 2~( 4 + 4 ) = 1,024 bit
     3160
     3161  hrd->setInitialCpbRemovalDelayLengthMinus1(15);                  // assuming 0.5 sec, log2( 90,000 * 0.5 ) = 16-bit
     3162  if( randomAccess )
     3163  {
     3164    hrd->setCpbRemovalDelayLengthMinus1(5);                        // 32 = 2^5 (plus 1)
     3165    hrd->setDpbOutputDelayLengthMinus1 (5);                        // 32 + 3 = 2^6
     3166  }
     3167  else
     3168  {
     3169    hrd->setCpbRemovalDelayLengthMinus1(9);                        // max. 2^10
     3170    hrd->setDpbOutputDelayLengthMinus1 (9);                        // max. 2^10
     3171  }
     3172
     3173  /*
     3174  Note: only the case of "vps_max_temporal_layers_minus1 = 0" is supported.
     3175  */
     3176  Int i, j;
     3177  UInt birateValue, cpbSizeValue;
     3178  UInt ducpbSizeValue;
     3179  UInt duBitRateValue = 0;
     3180
     3181  for( i = 0; i < MAX_TLAYER; i ++ )
     3182  {
     3183    hrd->setFixedPicRateFlag( i, 1 );
     3184    hrd->setPicDurationInTcMinus1( i, 0 );
     3185    hrd->setLowDelayHrdFlag( i, 0 );
     3186    hrd->setCpbCntMinus1( i, 0 );
     3187
     3188    birateValue  = bitRate;
     3189    cpbSizeValue = bitRate;                                     // 1 second
     3190    ducpbSizeValue = bitRate/numDU;
     3191    duBitRateValue = bitRate;
     3192    for( j = 0; j < ( hrd->getCpbCntMinus1( i ) + 1 ); j ++ )
     3193    {
     3194      hrd->setBitRateValueMinus1( i, j, 0, ( birateValue  - 1 ) );
     3195      hrd->setCpbSizeValueMinus1( i, j, 0, ( cpbSizeValue - 1 ) );
     3196      hrd->setDuCpbSizeValueMinus1( i, j, 0, ( ducpbSizeValue - 1 ) );
     3197      hrd->setCbrFlag( i, j, 0, ( j == 0 ) );
     3198
     3199      hrd->setBitRateValueMinus1( i, j, 1, ( birateValue  - 1) );
     3200      hrd->setCpbSizeValueMinus1( i, j, 1, ( cpbSizeValue - 1 ) );
     3201      hrd->setDuCpbSizeValueMinus1( i, j, 1, ( ducpbSizeValue - 1 ) );
     3202      hrd->setDuBitRateValueMinus1( i, j, 1, ( duBitRateValue - 1 ) );
     3203      hrd->setCbrFlag( i, j, 1, ( j == 0 ) );
     3204    }
     3205  }
    30083206}
    30093207const Int TComSPS::m_winUnitX[]={1,2,2,1};
     
    30613259, m_listsModificationPresentFlag(  0)
    30623260, m_numExtraSliceHeaderBits(0)
     3261#if SVC_EXTENSION
     3262, m_extensionFlag(false)
    30633263#if SCALINGLIST_INFERRING
     3264, m_layerId(0)
    30643265, m_inferScalingListFlag ( false )
    30653266, m_scalingListRefLayerId ( 0 )
     
    30683269, m_pocResetInfoPresentFlag   (false)
    30693270#endif
     3271#if Q0048_CGS_3D_ASYMLUT
     3272, m_nCGSFlag(0)
     3273, m_nCGSOutputBitDepthY(0)
     3274, m_nCGSOutputBitDepthC(0)
     3275#endif
     3276#endif //SVC_EXTENSION
    30703277{
    30713278  m_scalingList = new TComScalingList;
     
    36983905    return false;
    36993906  }       
    3700 #if POC_RESET_FLAG
     3907#if POC_RESET_FLAG || POC_RESET_IDC_DECODER
     3908#if POC_RESET_IDC_DECODER
     3909  TComPic* pic = xGetRefPic( rcListPic, getPOC() );
     3910#else
    37013911  TComPic* pic = xGetRefPic( rcListPic, m_bPocResetFlag ? 0 : m_iPOC );
     3912#endif
    37023913
    37033914  if( pic )
     
    37123923  return true;
    37133924#else
    3714   setBaseColPic(refLayerIdc, xGetRefPic(rcListPic, getPOC()));
     3925  setBaseColPic(refLayerIdc, xGetRefPic(rcListPic, getPOC()));
     3926  return true;
    37153927#endif
    37163928}
  • trunk/source/Lib/TLibCommon/TComSlice.h

    r713 r815  
    140140 
    141141  Void  create  (Int numberOfEntries);
    142   Void  destroy ();
     142  Void  destroy();
    143143
    144144
     
    469469
    470470  UInt        m_numHrdParameters;
    471 #if !VPS_RENAME
     471#if !SVC_EXTENSION
    472472  UInt        m_maxNuhReservedZeroLayerId;
    473473#endif
     
    484484#if SVC_EXTENSION
    485485#if DERIVE_LAYER_ID_LIST_VARIABLES
     486#if Q0078_ADD_LAYER_SETS
     487  Int         m_layerSetLayerIdList[MAX_VPS_LAYER_SETS_PLUS1 + MAX_NUM_ADD_LAYER_SETS][MAX_VPS_LAYER_ID_PLUS1];
     488  Int         m_numLayerInIdList[MAX_VPS_LAYER_SETS_PLUS1 + MAX_NUM_ADD_LAYER_SETS];
     489#else
    486490  Int         m_layerSetLayerIdList[MAX_VPS_LAYER_SETS_PLUS1][MAX_VPS_LAYER_ID_PLUS1];
    487491  Int         m_numLayerInIdList[MAX_VPS_LAYER_SETS_PLUS1];
     492#endif
    488493#endif
    489494#if !P0125_REVERT_VPS_EXTN_OFFSET_TO_RESERVED
     
    492497#endif
    493498#endif
    494 #if VPS_RENAME
    495499  UInt        m_maxLayerId;
    496500  UInt        m_numLayerSets;
     501#if Q0078_ADD_LAYER_SETS
     502  UInt        m_vpsNumLayerSetsMinus1;
     503  Bool        m_layerIdIncludedFlag[MAX_VPS_LAYER_SETS_PLUS1 + MAX_NUM_ADD_LAYER_SETS][MAX_VPS_LAYER_ID_PLUS1];
     504#else
    497505  Bool        m_layerIdIncludedFlag[MAX_VPS_LAYER_SETS_PLUS1][MAX_VPS_LAYER_ID_PLUS1];
    498506#endif
     
    514522  UInt       m_layerIdInVps[MAX_VPS_LAYER_ID_PLUS1];            // Maps layer_id_in_nuh with the layer ID in the VPS
    515523#endif
    516 #if ILP_SSH_SIG
     524#if BITRATE_PICRATE_SIGNALLING
     525#if Q0078_ADD_LAYER_SETS
     526  UInt       m_maxSLInLayerSetMinus1[MAX_VPS_LAYER_SETS_PLUS1 + MAX_NUM_ADD_LAYER_SETS];
     527#else
     528  UInt       m_maxSLInLayerSetMinus1[MAX_VPS_LAYER_SETS_PLUS1];
     529#endif
     530#endif
     531   
    517532  Bool       m_ilpSshSignalingEnabledFlag;
    518 #endif
    519533#if VPS_EXTN_PROFILE_INFO
    520534  // Profile-tier-level signalling related
     
    529543  // Target output layer signalling related
    530544  UInt       m_numOutputLayerSets;
     545#if Q0078_ADD_LAYER_SETS
     546  UInt       m_outputLayerSetIdx[MAX_VPS_LAYER_SETS_PLUS1 + 2*MAX_NUM_ADD_LAYER_SETS];
     547  Bool       m_outputLayerFlag[MAX_VPS_LAYER_SETS_PLUS1 + 2*MAX_NUM_ADD_LAYER_SETS][MAX_VPS_LAYER_ID_PLUS1];
     548#else
    531549  UInt       m_outputLayerSetIdx[MAX_VPS_LAYER_SETS_PLUS1];
    532550  Bool       m_outputLayerFlag[MAX_VPS_LAYER_SETS_PLUS1][MAX_VPS_LAYER_ID_PLUS1];
     551#endif
    533552#endif
    534553#if VPS_EXTN_DIRECT_REF_LAYERS
     
    565584  Bool       m_crossLayerPictureTypeAlignFlag;
    566585#endif
    567 #if N0147_IRAP_ALIGN_FLAG
    568586  Bool       m_crossLayerIrapAlignFlag;
    569 #endif
    570587#if P0068_CROSS_LAYER_ALIGNED_IDR_ONLY_FOR_IRAP_FLAG
    571588  Bool       m_crossLayerAlignedIdrOnlyFlag;
     
    576593  UInt       m_maxTidIlRefPicsPlus1[MAX_VPS_LAYER_ID_PLUS1 - 1];
    577594#endif
    578 #if N0120_MAX_TID_REF_PRESENT_FLAG
    579595  Bool       m_maxTidRefPresentFlag;
    580 #endif
    581596#if VPS_TSLAYERS
    582597  Bool       m_maxTSLayersPresentFlag;
     
    594609  Bool       m_loopFilterNotAcrossTilesFlag[MAX_VPS_LAYER_ID_PLUS1];
    595610#endif
    596 #if TILE_BOUNDARY_ALIGNED_FLAG
    597611  Bool       m_tileBoundariesAlignedFlag[MAX_VPS_LAYER_ID_PLUS1][MAX_VPS_LAYER_ID_PLUS1];
    598 #endif
    599612#if VPS_VUI_WPP_NOT_IN_USE__FLAG
    600613  Bool       m_wppNotInUseFlag;
     
    616629  Int        m_vpsTransChar[16];
    617630  Int        m_vpsMatCoeff[16];
    618 #endif 
    619 #if VPS_VUI_BITRATE_PICRATE
     631#endif
     632
    620633  Bool       m_bitRatePresentVpsFlag;
    621634  Bool       m_picRatePresentVpsFlag;
     
    626639  Int        m_constPicRateIdc     [MAX_VPS_LAYER_SETS_PLUS1][MAX_TLAYER];
    627640  Int        m_avgPicRate          [MAX_VPS_LAYER_SETS_PLUS1][MAX_TLAYER];
    628 #endif
    629641 
    630642#if P0312_VERT_PHASE_ADJ
     
    633645
    634646#if P0300_ALT_OUTPUT_LAYER_FLAG
     647#if Q0078_ADD_LAYER_SETS
     648  Bool       m_altOutputLayerFlag[MAX_VPS_LAYER_SETS_PLUS1 + 2*MAX_NUM_ADD_LAYER_SETS];
     649#else
    635650  Bool       m_altOutputLayerFlag[MAX_VPS_LAYER_SETS_PLUS1];
     651#endif
    636652#else
    637653#if O0153_ALT_OUTPUT_LAYER_FLAG
     
    661677  Int        m_numberRefLayers[MAX_NUM_LAYER_IDS];  // number of direct and indirect reference layers of a coding layer
    662678  Bool       m_recursiveRefLayerFlag[MAX_NUM_LAYER_IDS][MAX_NUM_LAYER_IDS];  // flag to indicate if j-th layer is a direct or indirect reference layer of i-th layer
     679#endif
     680#if Q0078_ADD_LAYER_SETS
     681  Int        m_numAddLayerSets;
     682  UInt       m_highestLayerIdxPlus1[MAX_NUM_ADD_LAYER_SETS][MAX_NUM_LAYER_IDS];
     683  UInt       m_predictedLayerId[MAX_NUM_LAYER_IDS][MAX_NUM_LAYER_IDS];
     684  UInt       m_numPredictedLayers[MAX_NUM_LAYER_IDS];
     685  Int        m_numIndependentLayers;
     686  Int        m_numLayersInTreePartition[MAX_NUM_LAYER_IDS];
     687  UInt       m_treePartitionLayerIdList[MAX_NUM_LAYER_IDS][MAX_NUM_LAYER_IDS];
    663688#endif
    664689#if SPS_DPB_PARAMS
     
    675700  Int        m_maxVpsLatencyIncreasePlus1  [MAX_VPS_OP_LAYER_SETS_PLUS1][MAX_LAYERS];
    676701#if CHANGE_NUMSUBDPB_IDX
     702#if Q0078_ADD_LAYER_SETS
     703  Int        m_numSubDpbs                  [MAX_VPS_LAYER_SETS_PLUS1 + 2*MAX_NUM_ADD_LAYER_SETS];
     704#else
    677705  Int        m_numSubDpbs                  [MAX_VPS_LAYER_SETS_PLUS1];
     706#endif
    678707#else
    679708  Int        m_numSubDpbs                  [MAX_VPS_OP_LAYER_SETS_PLUS1];
     
    735764  }
    736765#endif
     766#if HRD_BPB
     767  Int getBspHrdParamBufferCpbCntMinus1(UInt i, UInt sl)
     768  {
     769    return m_bspHrd->getCpbCntMinus1(sl);
     770  }
     771#endif
    737772
    738773  TComHRD* getHrdParameters   ( UInt i )             { return &m_hrdParameters[ i ]; }
     
    798833  Void    setRecursiveRefLayerFlag(Int currLayerId, Int refLayerId, Bool x)      { m_recursiveRefLayerFlag[currLayerId][refLayerId] = x;   }
    799834  Int     getNumRefLayers(Int currLayerId)                                       { return m_numberRefLayers[currLayerId];                  }
    800   Void    setNumRefLayers(Int currLayerId);
    801 #endif
    802 #if VPS_RENAME
    803   UInt    getMaxLayerId()                                       { return m_maxLayerId; }
    804   Void    setMaxLayerId(UInt v)                                 { m_maxLayerId = v;    }
    805 
     835  Void    setNumRefLayers();
     836#endif
     837#if Q0078_ADD_LAYER_SETS
     838  void    setLayerIdIncludedFlagsForAddLayerSets();
     839  UInt    getVpsNumLayerSetsMinus1()                                             { return m_vpsNumLayerSetsMinus1; }
     840  Void    setVpsNumLayerSetsMinus1(UInt x)                                       { m_vpsNumLayerSetsMinus1 = x; }
     841  UInt    getNumAddLayerSets()                                                   { return m_numAddLayerSets; }
     842  Void    setNumAddLayerSets(UInt x)                                             { m_numAddLayerSets = x; }
     843  UInt    getHighestLayerIdxPlus1(UInt set, UInt idx)                            { return m_highestLayerIdxPlus1[set][idx]; }
     844  Void    setHighestLayerIdxPlus1(UInt set, UInt idx, UInt layerIdx)             { m_highestLayerIdxPlus1[set][idx] = layerIdx; }
     845  Void    setPredictedLayerIds();
     846  UInt    getPredictedLayerId(UInt layerIdx, UInt predIdx)                       { return m_predictedLayerId[layerIdx][predIdx]; }
     847  Void    setPredictedLayerId(UInt layerIdx, UInt predIdx, UInt x)               { m_predictedLayerId[layerIdx][predIdx] = x; }
     848  UInt    getNumPredictedLayers(UInt layerId)                                    { return m_numPredictedLayers[layerId]; }
     849  Void    setNumPredictedLayers(UInt layerId, UInt x)                            { m_numPredictedLayers[layerId] = x; }
     850  Void    setTreePartitionLayerIdList();
     851  Int     getNumIndependentLayers()                                              { return m_numIndependentLayers; }
     852  Void    setNumIndependentLayers(Int x)                                         { m_numIndependentLayers = x; }
     853  Int     getNumLayersInTreePartition(Int idx)                                   { return m_numLayersInTreePartition[idx]; }
     854  Void    setNumLayersInTreePartition(Int idx, Int x)                            { m_numLayersInTreePartition[idx] = x; }
     855  UInt    getTreePartitionLayerId(Int idx, Int layerIdx)                         { return m_treePartitionLayerIdList[idx][layerIdx]; }
     856  Void    setTreePartitionLayerId(Int idx, Int layerIdx, UInt layerId)           { m_treePartitionLayerIdList[idx][layerIdx] = layerId; }
     857#endif
     858  UInt    getMaxLayerId()                                       { return m_maxLayerId;   }
     859  Void    setMaxLayerId(UInt v)                                 { m_maxLayerId = v;      }
    806860  UInt    getNumLayerSets()                                     { return m_numLayerSets; }
    807861  Void    setNumLayerSets(UInt v)                               { m_numLayerSets = v;    }
    808 #endif
    809862#if VPS_EXTN_MASK_AND_DIM_INFO
    810863  Bool   getAvcBaseLayerFlag()                                  { return m_avcBaseLayerFlag;       }
     
    835888  Void   setLayerIdInVps(Int id, UInt x)                        { m_layerIdInVps[id] = x;          }
    836889#endif
    837 #if ILP_SSH_SIG
    838     Bool   getIlpSshSignalingEnabledFlag()                      { return m_ilpSshSignalingEnabledFlag;}
    839     Void   setIlpSshSignalingEnabledFlag(Bool x)                { m_ilpSshSignalingEnabledFlag = x;}
    840 #endif
     890#if BITRATE_PICRATE_SIGNALLING
     891  UInt   getMaxSLayersInLayerSetMinus1(Int ls)                  { return m_maxSLInLayerSetMinus1[ls]; }
     892  Void   setMaxSLayersInLayerSetMinus1(Int ls, Int x)           { m_maxSLInLayerSetMinus1[ls] = x;    }
     893#endif
     894  Bool   getIlpSshSignalingEnabledFlag()                        { return m_ilpSshSignalingEnabledFlag;}
     895  Void   setIlpSshSignalingEnabledFlag(Bool x)                  { m_ilpSshSignalingEnabledFlag = x;}
    841896#if VPS_EXTN_PROFILE_INFO
    842897  Bool   getProfilePresentFlag(Int id)                          { return m_profilePresentFlag[id]; }
     
    883938  UInt   getDirectDependencyType(Int currLayerId, Int refLayerId)               { return m_directDependencyType[currLayerId][refLayerId]; }
    884939  Void   setDirectDependencyType(Int currLayerId, Int refLayerId, UInt x)       { m_directDependencyType[currLayerId][refLayerId] = x;    }
     940  Bool   isSamplePredictionType(Int currLayerId, Int refLayerId)                { assert(currLayerId != refLayerId); return ( ( m_directDependencyType[currLayerId][refLayerId] + 1 ) & 1 ) ? true : false; }
     941  Bool   isMotionPredictionType(Int currLayerId, Int refLayerId)                { assert(currLayerId != refLayerId); return ( ( ( m_directDependencyType[currLayerId][refLayerId] + 1 ) & 2 ) >> 1 ) ? true : false; }
    885942#endif
    886943  UInt   getNumProfileTierLevel()                                { return m_numProfileTierLevel; }
     
    923980  Void   setCrossLayerAlignedIdrOnlyFlag(Bool x)                              { m_crossLayerAlignedIdrOnlyFlag = x;                         }
    924981#endif
    925 #if N0147_IRAP_ALIGN_FLAG
    926982  Bool   getCrossLayerIrapAlignFlag()                                           { return m_crossLayerIrapAlignFlag;                      }
    927983  Void   setCrossLayerIrapAlignFlag(Bool x)                                     { m_crossLayerIrapAlignFlag = x;                         }
    928 #endif
    929984#if O0225_MAX_TID_FOR_REF_LAYERS
    930985  UInt   getMaxTidIlRefPicsPlus1(Int layerId, Int refLayerId)                     { return m_maxTidIlRefPicsPlus1[layerId][refLayerId];           }
     
    934989  Void   setMaxTidIlRefPicsPlus1(Int layerId, UInt maxSublayer)   { m_maxTidIlRefPicsPlus1[layerId] = maxSublayer;            }
    935990#endif
    936 #if N0120_MAX_TID_REF_PRESENT_FLAG
    937991  Bool   getMaxTidRefPresentFlag()                                  { return m_maxTidRefPresentFlag ;}
    938992  Void   setMaxTidRefPresentFlag(Bool x)                            { m_maxTidRefPresentFlag = x;}
    939 #endif
    940993#if VPS_TSLAYERS
    941994  Bool   getMaxTSLayersPresentFlag()                                  { return m_maxTSLayersPresentFlag ;}
     
    9601013  Void   setLoopFilterNotAcrossTilesFlag(Int currLayerId, Bool x)    { m_loopFilterNotAcrossTilesFlag[currLayerId] = x; }
    9611014#endif
    962 #if TILE_BOUNDARY_ALIGNED_FLAG 
    9631015  Bool   getTileBoundariesAlignedFlag(Int currLayerId, Int refLayerId)           { return m_tileBoundariesAlignedFlag[currLayerId][refLayerId]; }
    9641016  Void   setTileBoundariesAlignedFlag(Int currLayerId, Int refLayerId, Bool x)   { m_tileBoundariesAlignedFlag[currLayerId][refLayerId] = x; }
    965 #endif
    9661017#if VPS_VUI_WPP_NOT_IN_USE__FLAG 
    9671018  Bool   getWppNotInUseFlag()         { return m_wppNotInUseFlag; }
     
    10011052  Void   setMaxtrixCoeff(Int idx, Int x)       { m_vpsMatCoeff[idx] = x;        }
    10021053#endif
    1003 #if VPS_VUI_BITRATE_PICRATE
    10041054  Bool   getBitRatePresentVpsFlag()       { return m_bitRatePresentVpsFlag; }
    10051055  Void   setBitRatePresentVpsFlag(Bool x) { m_bitRatePresentVpsFlag = x;    }
     
    10211071  Int    getAvgPicRate(Int i, Int j)          { return m_avgPicRate[i][j]; }
    10221072  Void   setAvgPicRate(Int i, Int j, Int x)   { m_avgPicRate[i][j] = x;    }
    1023 #endif
    10241073#if O0164_MULTI_LAYER_HRD
    10251074  Bool     getVpsVuiBspHrdPresentFlag()                         { return m_vpsVuiBspHrdPresentFlag;      }
     
    14631512#if SVC_EXTENSION
    14641513  UInt        m_layerId;
     1514  Bool        m_extensionFlag;
    14651515  UInt        m_numScaledRefLayerOffsets;
    14661516#if P0312_VERT_PHASE_ADJ
     
    16211671  Void     setLayerId(UInt layerId)            { m_layerId = layerId; }
    16221672  UInt     getLayerId()                        { return m_layerId;    }
     1673  Int      getExtensionFlag()                  { return m_extensionFlag;  }
     1674  Void     setExtensionFlag(Int n)             { m_extensionFlag = n;     }
    16231675  UInt     getNumScaledRefLayerOffsets()       { return m_numScaledRefLayerOffsets; }
    16241676  Void     setNumScaledRefLayerOffsets(Int x)  { m_numScaledRefLayerOffsets = x;    }
     
    17361788
    17371789#if SVC_EXTENSION
     1790  Bool     m_extensionFlag;
    17381791#if SCALINGLIST_INFERRING
    17391792  UInt     m_layerId;
     
    18621915
    18631916#if SCALINGLIST_INFERRING
    1864   UInt     getLayerId() { return m_layerId; }
    1865   Void     setLayerId( UInt layerId ) { m_layerId = layerId;            }
    1866   Bool     getInferScalingListFlag()  { return m_inferScalingListFlag;  }
    1867   UInt     getScalingListRefLayerId() { return m_scalingListRefLayerId; }
    1868   Void     setInferScalingListFlag( Bool flag )     { m_inferScalingListFlag = flag;     }
    1869   Void     setScalingListRefLayerId( UInt layerId ) { m_scalingListRefLayerId = layerId; }
    1870 #endif
    1871 
    1872 #if SCALINGLIST_INFERRING
    18731917  Void     setScalingList( TComScalingList *scalingList ) { m_scalingList = scalingList; }
    18741918#else
     
    18861930  Bool getSliceHeaderExtensionPresentFlag   ()                    { return m_sliceHeaderExtensionPresentFlag; }
    18871931  Void setSliceHeaderExtensionPresentFlag   (Bool val)            { m_sliceHeaderExtensionPresentFlag = val; }
     1932#if SVC_EXTENSION
     1933  Int     getExtensionFlag()                { return m_extensionFlag;  }
     1934  Void    setExtensionFlag(Int n)           { m_extensionFlag = n;     }
     1935#if SCALINGLIST_INFERRING
     1936  UInt     getLayerId() { return m_layerId; }
     1937  Void     setLayerId( UInt layerId ) { m_layerId = layerId;            }
     1938  Bool     getInferScalingListFlag()  { return m_inferScalingListFlag;  }
     1939  UInt     getScalingListRefLayerId() { return m_scalingListRefLayerId; }
     1940  Void     setInferScalingListFlag( Bool flag )     { m_inferScalingListFlag = flag;     }
     1941  Void     setScalingListRefLayerId( UInt layerId ) { m_scalingListRefLayerId = layerId; }
     1942#endif
    18881943#if POC_RESET_IDC
    18891944  Bool getPocResetInfoPresentFlag   ()                    { return m_pocResetInfoPresentFlag; }
     
    18981953  Void    setCGSOutputBitDepthC(Int n){ m_nCGSOutputBitDepthC = n;     }
    18991954#endif
     1955#endif //SVC_EXTENSION
    19001956};
    19011957
     
    19351991  Int         m_iLastIDR;
    19361992  Int         m_iAssociatedIRAP;
     1993#if POC_RESET_IDC_ENCODER
     1994  Int         m_associatedIrapPocBeforeReset;
     1995#endif
     1996
    19371997  NalUnitType m_iAssociatedIRAPType;
    19381998  static Int  m_prevTid0POC;
     
    20612121  Bool        m_pocMsbValPresentFlag;
    20622122#endif
     2123#if POC_RESET_IDC_ENCODER
     2124  Int         m_pocValueBeforeReset;
     2125#endif
     2126#if POC_RESET_IDC_DECODER || POC_RESET_IDC_ENCODER
     2127  Int         m_picOrderCntLsb;
     2128#endif
    20632129#if Q0048_CGS_3D_ASYMLUT
    20642130  Int        m_nCGSOverWritePPS;  // for optimization, not output to bitstream
     
    21062172    Void     adjustPrevTid0POC      (Int adj)             { m_prevTid0POC=m_prevTid0POC-adj; }
    21072173#endif
     2174#if POC_RESET_IDC_DECODER
     2175  Void      setPrevTid0POC( Int x ) { m_prevTid0POC = x; }
     2176#endif
     2177
    21082178  TComRefPicListModification* getRefPicListModification() { return &m_RefPicListModification; }
    21092179  Void      setLastIDR(Int iIDRPOC)                       { m_iLastIDR = iIDRPOC; }
     
    21112181  Void      setAssociatedIRAPPOC(Int iAssociatedIRAPPOC)             { m_iAssociatedIRAP = iAssociatedIRAPPOC; }
    21122182  Int       getAssociatedIRAPPOC()                        { return m_iAssociatedIRAP; }
     2183#if POC_RESET_IDC_ENCODER
     2184  Void setAssociatedIrapPocBeforeReset(Int x) { m_associatedIrapPocBeforeReset = x; }
     2185  Int  getAssociatedIrapPocBeforeReset(     ) { return m_associatedIrapPocBeforeReset; }
     2186#endif
     2187
    21132188  Void      setAssociatedIRAPType(NalUnitType associatedIRAPType)    { m_iAssociatedIRAPType = associatedIRAPType; }
    21142189  NalUnitType getAssociatedIRAPType()                        { return m_iAssociatedIRAPType; }
     
    22202295  Void setTLayerInfo( UInt uiTLayer );
    22212296  Void decodingMarking( TComList<TComPic*>& rcListPic, Int iGOPSIze, Int& iMaxRefPicNum );
     2297#if POC_RESET_IDC_ENCODER
     2298  Void checkLeadingPictureRestrictions(TComList<TComPic*>& rcListPic, Bool usePocBeforeReset = false);
     2299#else
    22222300  Void checkLeadingPictureRestrictions( TComList<TComPic*>& rcListPic );
     2301#endif
    22232302  Void applyReferencePictureSet( TComList<TComPic*>& rcListPic, TComReferencePictureSet *RPSList);
    22242303  Bool isTemporalLayerSwitchingPoint( TComList<TComPic*>& rcListPic );
     
    24182497  Bool      getCraPicFlag       ();
    24192498#endif
     2499#if POC_RESET_IDC_DECODER
     2500  Bool      getRaslPicFlag      ();
     2501  Bool      getRadlPicFlag      ();
     2502#endif
     2503#if POC_RESET_IDC_DECODER || POC_RESET_IDC_ENCODER
     2504  Int       getPicOrderCntLsb() { return m_picOrderCntLsb; }
     2505  Void      setPicOrderCntLsb(Int x) { m_picOrderCntLsb = x; }
     2506#endif
     2507
     2508#if POC_RESET_IDC_ENCODER
     2509  Int       getPocValueBeforeReset ()                        { return m_pocValueBeforeReset; }
     2510  Void      setPocValueBeforeReset (Int x)                   { m_pocValueBeforeReset = x ;   }
     2511  Void      decrementRefPocValues(Int const decrementValue);
     2512  Int       getCurrMsb( Int currLsb, Int prevLsb, Int prevMsb, Int maxLsbVal );
     2513#endif
     2514
    24202515
    24212516#endif //SVC_EXTENSION
     
    24722567  }
    24732568
     2569#if Q0078_ADD_LAYER_SETS
     2570  Void removePS(Int psId)
     2571  {
     2572    assert(psId < m_maxId);
     2573    if (m_paramsetMap.find(psId) != m_paramsetMap.end())
     2574    {
     2575      m_paramsetMap.erase(psId);
     2576    }
     2577  }
     2578#endif
     2579
     2580
    24742581private:
    24752582  std::map<Int,T *> m_paramsetMap;
     
    24942601  TComSPS* getSPS(Int spsId)  { return m_spsMap.getPS(spsId); };
    24952602  TComSPS* getFirstSPS()      { return m_spsMap.getFirstPS(); };
     2603#if Q0078_ADD_LAYER_SETS
     2604  Void     removeSPS(Int spsId) { m_spsMap.removePS(spsId); };
     2605#endif
    24962606
    24972607  //! store picture parameter set and take ownership of it
     
    25002610  TComPPS* getPPS(Int ppsId)  { return m_ppsMap.getPS(ppsId); };
    25012611  TComPPS* getFirstPPS()      { return m_ppsMap.getFirstPS(); };
     2612#if Q0078_ADD_LAYER_SETS
     2613  Void     removePPS(Int ppsId) { m_ppsMap.removePS(ppsId); };
     2614#endif
    25022615
    25032616  //! activate a SPS from a active parameter sets SEI message
  • trunk/source/Lib/TLibCommon/TComUpsampleFilter.cpp

    r713 r815  
    1 
     1#include "TypeDef.h"
     2#if SVC_EXTENSION
    23#include "TComUpsampleFilter.h"
    3 #include "TypeDef.h"
    4 
    5 #if SVC_UPSAMPLING
    6 #define CNU -1 ///< Coefficients Not Used
    74
    85const Int TComUpsampleFilter::m_lumaFixedFilter[16][NTAPS_US_LUMA] =
    96{
    10   {  0,  0,  0, 64,  0,  0,  0,  0}, //
    11 #if ARBITRARY_SPATIAL_RATIO
    12   {  0,  1, -3, 63,  4, -2,  1,  0},
    13   { -1,  2, -5, 62,  8, -3,  1,  0},
    14   { -1,  3, -8, 60, 13, -4,  1,  0},
    15   { -1,  4,-10, 58, 17, -5,  1,  0},
    16 #else
    17   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
    18   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
    19   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
    20   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
    21 #endif
    22   { -1, 4, -11, 52, 26,  -8,  3, -1}, // <-> actual phase shift 1/3, used for spatial scalability x1.5
    23 #if ARBITRARY_SPATIAL_RATIO
    24   { -1, 3,  -9, 47, 31, -10,  4, -1},
    25   { -1, 4, -11, 45, 34, -10,  4, -1},
    26 #else
    27   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
    28   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
    29 #endif
    30   { -1, 4, -11, 40, 40, -11,  4, -1}, // <-> actual phase shift 1/2, equal to HEVC MC, used for spatial scalability x2
    31 #if ARBITRARY_SPATIAL_RATIO
    32   { -1,  4, -10, 34, 45, -11,  4, -1},
    33   { -1,  4, -10, 31, 47,  -9,  3, -1},
    34 #else
    35   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
    36   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
    37 #endif
    38   { -1, 3,  -8, 26, 52, -11, 4, -1}, // <-> actual phase shift 2/3, used for spatial scalability x1.5
    39 #if ARBITRARY_SPATIAL_RATIO
    40   { 0,  1,  -5, 17, 58, -10,  4, -1},
    41   { 0,  1,  -4, 13, 60,  -8,  3, -1},
    42   { 0,  1,  -3,  8, 62,  -5,  2, -1},
    43   { 0,  1,  -2,  4, 63,  -3,  1,  0}
    44 #else
    45   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
    46   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
    47   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
    48   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}  //
    49 #endif
     7  {  0, 0,   0, 64,  0,   0,  0,  0 },
     8  {  0, 1,  -3, 63,  4,  -2,  1,  0 },
     9  { -1, 2,  -5, 62,  8,  -3,  1,  0 },
     10  { -1, 3,  -8, 60, 13,  -4,  1,  0 },
     11  { -1, 4, -10, 58, 17,  -5,  1,  0 },
     12  { -1, 4, -11, 52, 26,  -8,  3, -1 }, // <-> actual phase shift 1/3, used for spatial scalability x1.5
     13  { -1, 3,  -9, 47, 31, -10,  4, -1 },
     14  { -1, 4, -11, 45, 34, -10,  4, -1 },
     15  { -1, 4, -11, 40, 40, -11,  4, -1 }, // <-> actual phase shift 1/2, equal to HEVC MC, used for spatial scalability x2
     16  { -1, 4, -10, 34, 45, -11,  4, -1 },
     17  { -1, 4, -10, 31, 47,  -9,  3, -1 },
     18  { -1, 3,  -8, 26, 52, -11,  4, -1 }, // <-> actual phase shift 2/3, used for spatial scalability x1.5
     19  {  0, 1,  -5, 17, 58, -10,  4, -1 },
     20  {  0, 1,  -4, 13, 60,  -8,  3, -1 },
     21  {  0, 1,  -3,  8, 62,  -5,  2, -1 },
     22  {  0, 1,  -2,  4, 63,  -3,  1,  0 }
    5023};
    5124
    5225const Int TComUpsampleFilter::m_chromaFixedFilter[16][NTAPS_US_CHROMA] =
    5326{
    54   {  0, 64,  0,  0},//
    55 #if ARBITRARY_SPATIAL_RATIO
    56   { -2, 62,  4,  0},
    57   { -2, 58, 10, -2},
    58   { -4, 56, 14, -2},
    59 #else
    60   {CNU,CNU,CNU,CNU},//
    61   {CNU,CNU,CNU,CNU},//
    62   {CNU,CNU,CNU,CNU},//
    63 #endif
    64   { -4, 54, 16, -2},// <-> actual phase shift 1/4,equal to HEVC MC, used for spatial scalability x1.5 (only for accurate Chroma alignement)
    65   { -6, 52, 20, -2},// <-> actual phase shift 1/3, used for spatial scalability x1.5
    66   { -6, 46, 28, -4},// <-> actual phase shift 3/8,equal to HEVC MC, used for spatial scalability x2 (only for accurate Chroma alignement)
    67 #if ARBITRARY_SPATIAL_RATIO
    68   { -4, 42, 30, -4},
    69 #else
    70   {CNU,CNU,CNU,CNU},//
    71 #endif
    72   { -4, 36, 36, -4},// <-> actual phase shift 1/2,equal to HEVC MC, used for spatial scalability x2
    73   { -4, 30, 42, -4},// <-> actual phase shift 7/12, used for spatial scalability x1.5 (only for accurate Chroma alignement)
    74 #if ARBITRARY_SPATIAL_RATIO
    75   { -4, 28, 46, -6},
    76 #else
    77   {CNU,CNU,CNU,CNU},//
    78 #endif
    79   { -2, 20, 52, -6},// <-> actual phase shift 2/3, used for spatial scalability x1.5
    80 #if ARBITRARY_SPATIAL_RATIO
    81   {-2, 16, 54, -4},
    82   {-2, 14, 56, -4},
    83 #else
    84   {CNU,CNU,CNU,CNU},//
    85   {CNU,CNU,CNU,CNU},//
    86 #endif
    87   { -2, 10, 58, -2},// <-> actual phase shift 7/8,equal to HEVC MC, used for spatial scalability x2 (only for accurate Chroma alignement)
    88   {  0,  4, 62, -2} // <-> actual phase shift 11/12, used for spatial scalability x1.5 (only for accurate Chroma alignement)
     27  {  0, 64,  0,  0 },
     28  { -2, 62,  4,  0 },
     29  { -2, 58, 10, -2 },
     30  { -4, 56, 14, -2 },
     31  { -4, 54, 16, -2 }, // <-> actual phase shift 1/4,equal to HEVC MC, used for spatial scalability x1.5 (only for accurate Chroma alignement)
     32  { -6, 52, 20, -2 }, // <-> actual phase shift 1/3, used for spatial scalability x1.5
     33  { -6, 46, 28, -4 }, // <-> actual phase shift 3/8,equal to HEVC MC, used for spatial scalability x2 (only for accurate Chroma alignement)
     34  { -4, 42, 30, -4 },
     35  { -4, 36, 36, -4 }, // <-> actual phase shift 1/2,equal to HEVC MC, used for spatial scalability x2
     36  { -4, 30, 42, -4 }, // <-> actual phase shift 7/12, used for spatial scalability x1.5 (only for accurate Chroma alignement)
     37  { -4, 28, 46, -6 },
     38  { -2, 20, 52, -6 }, // <-> actual phase shift 2/3, used for spatial scalability x1.5
     39  { -2, 16, 54, -4 },
     40  { -2, 14, 56, -4 },
     41  { -2, 10, 58, -2 }, // <-> actual phase shift 7/8,equal to HEVC MC, used for spatial scalability x2 (only for accurate Chroma alignement)
     42  {  0,  4, 62, -2 }  // <-> actual phase shift 11/12, used for spatial scalability x1.5 (only for accurate Chroma alignement)
    8943};
    9044
     
    260214    }
    261215
    262 #if ARBITRARY_SPATIAL_RATIO
    263216    assert ( widthEL >= widthBL );
    264217    assert ( heightEL >= heightBL );
    265 #else
    266     assert ( widthEL == widthBL || widthEL == 2*widthBL || 2*widthEL == 3*widthBL );
    267     assert ( heightEL == heightBL || heightEL == 2*heightBL || 2*heightEL == 3*heightBL );
    268 #endif
    269218
    270219    pcBasePic->setBorderExtension(false);
     
    298247#endif
    299248 
    300 #if ROUNDING_OFFSET
    301249    Int   addX = ( ( phaseX * scaleX + 2 ) >> 2 ) + ( 1 << ( shiftX - 5 ) );
    302250    Int   addY = ( ( phaseY * scaleY + 2 ) >> 2 ) + ( 1 << ( shiftY - 5 ) );
    303 #else
    304     Int   addX = ( ( ( widthBL * phaseX ) << ( shiftX - 2 ) ) + ( widthEL >> 1 ) ) / widthEL + ( 1 << ( shiftX - 5 ) );
    305     Int   addY = ( ( ( heightBL * phaseY ) << ( shiftY - 2 ) ) + ( heightEL >> 1 ) ) / heightEL+ ( 1 << ( shiftY - 5 ) );
    306 #endif
    307251
    308252#if Q0120_PHASE_CALCULATION
     
    333277    Int bottomEndL = pcUsPic->getHeight() - scalEL.getWindowBottomOffset();
    334278    Int leftOffset = leftStartL > 0 ? leftStartL : 0;
    335 #if N0214_INTERMEDIATE_BUFFER_16BITS
    336279#if O0194_JOINT_US_BITSHIFT
    337280    // g_bitDepthY was set to EL bit-depth, but shift1 should be calculated using BL bit-depth
     
    345288#else
    346289    Int shift1 = g_bitDepthY - 8;
    347 #endif
    348290#endif
    349291
     
    362304      for( j = 0; j < heightBL ; j++ )
    363305      {
    364 #if N0214_INTERMEDIATE_BUFFER_16BITS
    365306        *piDstY = sumLumaHor(piSrcY, coeff) >> shift1;
    366 #else
    367         *piDstY = sumLumaHor(piSrcY, coeff);
    368 #endif
    369307        piSrcY += strideBL;
    370308        piDstY += strideEL;
     
    378316    pcTempPic->setHeight(heightEL);
    379317
    380 #if N0214_INTERMEDIATE_BUFFER_16BITS
    381318#if O0194_JOINT_US_BITSHIFT
    382319    Int nShift = 20 - g_bitDepthYLayer[currLayerId];
    383320#else
    384321    Int nShift = US_FILTER_PREC*2 - shift1;
    385 #endif
    386 #else
    387     const Int nShift = US_FILTER_PREC*2;
    388322#endif
    389323    Int iOffset = 1 << (nShift - 1);
     
    472406#endif
    473407   
    474 #if ROUNDING_OFFSET
    475408    addX       = ( ( phaseXC * scaleX + 2 ) >> 2 ) + ( 1 << ( shiftX - 5 ) );
    476409    addY       = ( ( phaseYC * scaleY + 2 ) >> 2 ) + ( 1 << ( shiftY - 5 ) );
    477 #else
    478     addX       = ( ( ( widthBL * (phaseXC) ) << ( shiftX - 2 ) ) + ( widthEL >> 1 ) ) / widthEL + ( 1 << ( shiftX - 5 ) );
    479     addY       = ( ( ( heightBL * (phaseYC) ) << ( shiftY - 2 ) ) + ( heightEL >> 1 ) ) / heightEL+ ( 1 << ( shiftY - 5 ) );
    480 #endif
    481410
    482411#if Q0120_PHASE_CALCULATION
     
    502431    heightBL  = min<Int>( pcBasePic->getHeight() >> 1, heightEL );
    503432
    504 #if N0214_INTERMEDIATE_BUFFER_16BITS
    505433#if O0194_JOINT_US_BITSHIFT
    506434    // g_bitDepthC was set to EL bit-depth, but shift1 should be calculated using BL bit-depth
     
    514442#else
    515443    shift1 = g_bitDepthC - 8;
    516 #endif
    517444#endif
    518445
     
    533460      for( j = 0; j < heightBL ; j++ )
    534461      {
    535 #if N0214_INTERMEDIATE_BUFFER_16BITS
    536462        *piDstU = sumChromaHor(piSrcU, coeff) >> shift1;
    537463        *piDstV = sumChromaHor(piSrcV, coeff) >> shift1;
    538 #else
    539         *piDstU = sumChromaHor(piSrcU, coeff);
    540         *piDstV = sumChromaHor(piSrcV, coeff);
    541 #endif
    542464
    543465        piSrcU += strideBL;
     
    554476    pcTempPic->setHeight(heightEL << 1);
    555477
    556 #if N0214_INTERMEDIATE_BUFFER_16BITS
    557478#if O0194_JOINT_US_BITSHIFT
    558479    nShift = 20 - g_bitDepthCLayer[currLayerId];
     
    561482#endif
    562483    iOffset = 1 << (nShift - 1);
    563 #endif
    564484
    565485    for( j = 0; j < pcTempPic->getHeight() >> 1; j++ )
  • trunk/source/Lib/TLibCommon/TypeDef.h

    r713 r815  
    4141#define SVC_EXTENSION                    1
    4242
    43 #define SYNTAX_BYTES                     10      ///< number of bytes taken by syntaxes per 4x4 block [RefIdxL0(1byte), RefIdxL1(1byte), MVxL0(2bytes), MVyL0(2bytes), MVxL1(2bytes), MVyL1(2bytes)]
     43#define SYNTAX_BYTES                     10     ///< number of bytes taken by syntaxes per 4x4 block [RefIdxL0(1byte), RefIdxL1(1byte), MVxL0(2bytes), MVyL0(2bytes), MVxL1(2bytes), MVyL1(2bytes)]
    4444#if SVC_EXTENSION
    4545#define MAX_LAYERS                       8      ///< max number of layers the codec is supposed to handle
    4646
    4747#define VPS_VUI_OFFSET                   1      ///< N0085: Signal VPS VUI offset in the VPS extension
    48 #define RANDOM_ACCESS_SEI_FIX            1
    4948#define O0137_MAX_LAYERID                1      ///< JCTVC-O0137, JCTVC-O0200, JCTVC-O0223: restrict nuh_layer_id and vps_max_layers_minus1
    5049
    51 #define Q0200_CONFORMANCE_BL_SIZE        1       ///< JCTVC-Q0200; use conformance picture size in re-sampling processs
     50#define Q0108_TSA_STSA                   0      ///< JCTVC-Q0108, Remove cross-layer alignment constraints of TSA and STSA pictures, enable to have different prediction structures in different layers
     51#define Q0177_SPS_TEMP_NESTING_FIX       1      ///< JCTVC-Q0177; Fix the inference value of sps_temporal_id_nesting_flag when it is not present
     52#define Q0177_EOS_CHECKS                 1      ///< JCTVC-Q0177; Put checks on handling EOS
     53#define Q0142_POC_LSB_NOT_PRESENT        1      ///< JCTVC-Q0142; Add constraint checking on the value of poc_reset_idc and poc_lsb_val
     54#define Q0146_SSH_EXT_DATA_BIT           1      ///< JCTVC-Q0146; Bug-fix -- the SSH_EXT_DATA_BIT can have any value -- not required to be 1
     55
     56#define Q0200_CONFORMANCE_BL_SIZE        1      ///< JCTVC-Q0200; use conformance picture size in re-sampling processs
    5257#define P0312_VERT_PHASE_ADJ             1      ///< JCTVC-P0312: vertical phase adjustment in re-sampling process (BoG report)
    5358#if P0312_VERT_PHASE_ADJ
     
    6267#define VPS_EXTN_UEV_CODING              1      ///< JCTVC-P0306: Code some syntax elements as ue(v), and remove some syntax elements that duplicate behaviour
    6368#define CHANGE_NUMSUBDPB_IDX             1      ///< Change index of NumSubDpb from output layer set to layer set, to be more aligned with the Spec
    64 #define RESOLUTION_BASED_DPB             1      ///< JCTVC-P0192: Assign layers to sub-DPBs based on the rep_format() signaled in the VPS
     69#define RESOLUTION_BASED_DPB             0      ///< JCTVC-Q0154 - remove sharing of sub-DPB across layers
     70                                                ///< JCTVC-P0192: Assign layers to sub-DPBs based on the rep_format() signaled in the VPS
    6571#define ALIGNED_BUMPING                  1      ///< JCTVC-P0192: Align bumping of pictures in an AU
    66 #define MAX_SUBDPBS                      MAX_LAYERS
    67 #define SUB_BITSTREAM_PROPERTY_SEI       1      ///< JCTVC-P0204: Sub-bitstream property SEI message
    68 #if SUB_BITSTREAM_PROPERTY_SEI
    69 #define MAX_SUB_STREAMS                  1024
    70 #endif
    7172#define O0109_O0199_FLAGS_TO_VUI         1      ///< JCTVC-O0109, O0199: move single_layer_for_non_irap_flag and higher_layer_flag to vps_vui
    7273#define O0109_VIEW_ID_LEN                1      ///< JCTVC-O0109: view_id_len_minus1 to view_id_len, and add constraint (1<<view_id_len) is greater than or equal to NumViews
     
    7778#endif
    7879
    79 #define P0295_DEFAULT_OUT_LAYER_IDC      1      ///< JCTVC-P0295: modifify default_one_target_output_layer_idc to default_target_output_layer_idc
     80#define P0295_DEFAULT_OUT_LAYER_IDC      1      ///< JCTVC-P0295: modifify default_one_target_output_layer_idc to default_output_layer_idc
    8081#define O0109_DEFAULT_ONE_OUT_LAYER_IDC  1      ///< JCTVC-O0109: default_one_target_output_layer_flag to default_one_target_output_layer_idc
    8182#define O0109_MOVE_VPS_VUI_FLAG          1      ///< JCTVC-O0109: move vps_vui_present_flag before vps_vui_offset
     
    8485
    8586#define O0164_MULTI_LAYER_HRD            1      ///< JCTVC-O0164: Multi-layer HRD operation
    86 #define Q0074_SEI_COLOR_MAPPING          1      ///< JCTVC-Q0074, SEI Color Mapping
     87#define Q0182_MULTI_LAYER_HRD_UPDATE     1      ///< JCTVC-Q0182: On bitstream partition buffering
    8788
    8889#define O0194_DIFFERENT_BITDEPTH_EL_BL   1      ///< JCTVC-O0194: Support for different bitdepth values for BL and EL, add required configuration parameters (and Some bugfixes when REPN_FORMAT_IN_VPS (JCTVC-N0092) is enabled)
     
    9293#define Q0048_CGS_3D_ASYMLUT             1      ///< JCTVC-Q0048: Colour gamut scalability with look-up table
    9394#if Q0048_CGS_3D_ASYMLUT
     95#define CGS_GCC_NO_VECTORIZATION         1
    9496#define O0194_WEIGHTED_PREDICTION_CGS    0
    9597#else
    9698#define O0194_WEIGHTED_PREDICTION_CGS    1      ///< JCTVC-O0194: Weighted prediciton for color gamut scalability
    9799#endif
    98 #define MFM_ENCCONSTRAINT                1      ///< JCTVC-O0216: Encoder constraint for motion field mapping
    99 #define VPS_NUH_LAYER_ID                 1      ///< JCTVC-N0085: Assert that the nuh_layer_id of VPS NAL unit should be 0
    100 #define POC_RESET_FLAG                   1      ///< JCTVC-N0244: POC reset flag for  layer pictures.
     100#define POC_RESET_FLAG                   0      ///< JCTVC-N0244: POC reset flag for  layer pictures.
    101101#define POC_RESET_IDC                    1      ///< JCTVC-P0041: Include poc_reset_idc and related derivation - eventually will replace POC_RESET_FLAG
    102102#if POC_RESET_IDC
    103103#define POC_RESET_IDC_SIGNALLING         1      ///< JCTVC-P0041: Include signalling for poc_reset related syntax elements
    104 #endif
     104#define POC_RESET_IDC_ENCODER            1      ///< JCTVC-P0041: Include support of enabling POC reset at the encoder
     105#define POC_RESET_IDC_DECODER            1      ///< JCTVC-P0041: Include support of enabling POC reset at the decoder
     106#define ALIGN_IRAP_BUGFIX                1
     107#define UNAVAILABLE_PIC_BUGFIX           1
     108#endif
     109#define POC_MSB_VAL_PRESENT_FLAG_SEM     1      ///< JCTVC-Q0146: Inference of poc_msb_val_present_flag
     110#define POC_RESET_INFO_INFERENCE         1      ///< JCTVC-Q0146: Infer the value of poc_reset_info_present_flag when not present
    105111#define NO_OUTPUT_OF_PRIOR_PICS          1      ///< Use no_output_of_prior_pics_flag
    106 #define ALIGN_TSA_STSA_PICS              1      ///< JCTVC-N0084: Alignment of TSA and STSA pictures across AU.
    107112#define REPN_FORMAT_IN_VPS               1      ///< JCTVC-N0092: Signal represenation format (spatial resolution, bit depth, colour format) in the VPS
    108113#if REPN_FORMAT_IN_VPS
    109114#define REPN_FORMAT_CONTROL_FLAG         1      ///< JCTVC-O0179: Add control flag in representation format to control sending of chroma and bitdepth parameters
    110115#endif
    111 #define TIMING_INFO_NONZERO_LAYERID_SPS  1      ///< JCTVC-N0085: Semantics of vui_timing_info_present_flag to always set that flag to zero for non-zero layer ID SPS
    112116#define RPL_INIT_N0316_N0082             1      ///< JCTVC-N0316, JCTVC-N0082: initial reference picture list construction
    113117
    114118#define SCALINGLIST_INFERRING            1      ///< JCTVC-N0371: inter-layer scaling list
    115 #define SPS_EXTENSION                    1      ///< Define sps_extension() syntax structure
    116 #if SPS_EXTENSION
    117119#define O0142_CONDITIONAL_SPS_EXTENSION  1      ///< JCTVC-O0142: Conditional SPS extension
    118 #endif
    119 #define SCALABILITY_MASK_E0104           1      ///< JCT3V-E0104: scalability mask for depth
    120 #define LAYER_CTB                        0      ///< enable layer-specific CTB structure
    121120#if POC_RESET_FLAG
    122121#define PREVTID0_POC_RESET               1      ///< JCTVC-O0117 Modification of the PicOrderCntVal of prevTid0Pic
     
    124123#endif
    125124
    126 #define ILP_SSH_SIG                      1      ///< JCTVC-N0195 proposal 2, JCTVC-N0118: add presence flag in VPS ext to condition inter-layer prediction signaling in slice segment header
    127 #if ILP_SSH_SIG
    128 #define ILP_SSH_SIG_FIX                  1      ///< fix for SHM ticket #5
    129 #endif
    130 #define SPL_FLG_CHK                      1      ///< JCTVC-N0195 proposal 5, JCTVC-N0085: constrain sum of lengths to be less than or equal to 6
    131 #define ILP_NUM_REF_CHK                  1      ///< JCTVC-N0195 proposal 1, JCTVC-N0081, JCTVC-N0154, JCTVC-N0217: a condition on signaling inter_layer_pred_layer_idc[ i ], to avoid sending when NumDirectRefLayers equals NumActiveRefLayerPics, and instead infer values
    132 
    133 #define VPS_RENAME                       1      ///< Rename variables max_layer_id and num_layer_sets_minus1 in VPS
    134 #define VPS_EXTNS                        1      ///< Include function structure for VPS extensions
    135 #if VPS_EXTNS
    136125#define VPS_EXTN_MASK_AND_DIM_INFO       1      ///< Include avc_base_layer_flag, splitting_flag, scalability mask and dimension related info
    137126#if VPS_EXTN_MASK_AND_DIM_INFO
     
    142131#define VPS_EXTN_DIRECT_REF_LAYERS       1      ///< Include indication of direct dependency of layers in VPS extension
    143132#define M0040_ADAPTIVE_RESOLUTION_CHANGE 1
    144 #define VPS_VUI                          1      ///< Include function structure for VPS VUI
    145 
    146 #if VPS_VUI
     133
    147134#define VPS_VUI_TILES_NOT_IN_USE__FLAG   1      ///< JCTVC-O0226: VPS VUI flag to indicate tile not in use
    148135#define VPS_VUI_WPP_NOT_IN_USE__FLAG     1      ///< JCTVC-O0226: VPS VUI flag to indicate tile not in use
    149 #define TILE_BOUNDARY_ALIGNED_FLAG       1      ///< JCTVC-N0160/JCTVC-N0199 proposal 2 variant 2: VPS VUI flag to indicate tile boundary alignment
    150136#define N0160_VUI_EXT_ILP_REF            1      ///< VUI extension inter-layer dependency offset signalling
    151 #define VPS_VUI_BITRATE_PICRATE          1      ///< JCTVC-N0085: Signal bit rate and picture in VPS VUI
    152137#if M0040_ADAPTIVE_RESOLUTION_CHANGE
    153138#define HIGHER_LAYER_IRAP_SKIP_FLAG      1      ///< JCTVC-O0199: Indication that higher layer IRAP picture uses skip blocks only
     
    158143#endif
    159144#define P0182_VPS_VUI_PS_FLAG            1      ///< JCTVC-P0182, add base_layer_parameter_set_compatibility_flag
    160 #endif //VPS_VUI
    161 
    162 #endif
    163145
    164146#define P0125_REVERT_VPS_EXTN_OFFSET_TO_RESERVED        1   ///< JCTVC-P0125 -- Keep it as a reserved FFFF value --- The following two macros (VPS_EXTN_OFFSET & VPS_EXTN_OFFSET_CALC) will have no effect when this macro is set to 1.
     
    169151#define DERIVE_LAYER_ID_LIST_VARIABLES   1      ///< Derived variables based on the variables in VPS - for use in syntax table parsing
    170152
    171 #define SVC_UPSAMPLING                   1      ///< upsampling filters
    172 #define ROUNDING_OFFSET                  1      ///< JCTVC-N0111: upsampling rounding offset using scalling factors
    173 #define N0214_INTERMEDIATE_BUFFER_16BITS 1      ///< JCTVC-N0214: support base layer input more than 8 bits
    174 #define ARBITRARY_SPATIAL_RATIO          1      ///< JCTVC-N0219, JCTVC-N0273: Support arbitrary spatial ratio
    175 
    176 #define JCTVC_M0259_LAMBDAREFINEMENT     1      ///< JCTVC-M0259: lambda refinement (encoder only optimization)
    177 
    178153#define AVC_BASE                         1      ///< YUV BL reading for AVC base SVC
    179154#if AVC_BASE
     
    181156#endif
    182157
    183 #define REF_IDX_ME_ZEROMV                1      ///< JCTVC-L0051: use zero motion for inter-layer reference picture (without fractional ME)
    184 #define ENCODER_FAST_MODE                1      ///< JCTVC-L0174: enable encoder fast mode. TestMethod 1 is enabled by setting to 1 and TestMethod 2 is enable by setting to 2. By default it is set to 1.
    185158#define REF_IDX_MFM                      1      ///< JCTVC-L0336: motion vector mapping of inter-layer reference picture
    186159#define MAX_ONE_RESAMPLING_DIRECT_LAYERS 1      ///< Allow maximum of one resampling process for direct reference layers
    187160#define MOTION_RESAMPLING_CONSTRAINT     1      ///< JCTVC-N0108: Allow maximum of one motion resampling process for direct reference layers, and use motion inter-layer prediction from the same layer as texture inter-layer prediction.
    188 #define EARLY_REF_PIC_MARKING            1      ///< Decoded picture marking of sub-layer non-reference pictures
    189 #define N0120_MAX_TID_REF_PRESENT_FLAG   1      ///< JCTVC-N0120: max_tid_ref_pics_plus1_present_flag
    190 #define N0120_MAX_TID_REF_CFG            1      ///< set max_tid_il_ref_pics_plus1 and max_tid_ref_present_flag in the config. file (configuration setting)
     161#define EARLY_REF_PIC_MARKING            0      ///< Valencia meeting - remove early marking of inter-layer reference pictures
     162                                                ///< Decoded picture marking of sub-layer non-reference pictures
    191163#define O0225_MAX_TID_FOR_REF_LAYERS     1
    192164#define O0225_TID_BASED_IL_RPS_DERIV     1
     
    195167#define P0079_DERIVE_NUMACTIVE_REF_PICS  1      ///< JCTVC-P0079 Modification of derivation of variable NumActiveRefLayerPics
    196168#define Q0060_MAX_TID_REF_EQUAL_TO_ZERO  1      ///< JCTVC-Q0060 handling the case max_tid_il_ref_pics_plus1 is equal to 0.
    197 #if REF_IDX_MFM
    198 #define N0139_POSITION_ROUNDING_OFFSET   1      ///< JCTVC-N0139: offset for collocated block in motion mapping
    199 #endif
    200 
    201 #define O0223_PICTURE_TYPES_ALIGN_FLAG   1  ///< a flag to indicatate whether picture types are aligned across layers.
     169
     170#define O0223_PICTURE_TYPES_ALIGN_FLAG   1      ///< a flag to indicatate whether picture types are aligned across layers.
    202171
    203172#define P0068_CROSS_LAYER_ALIGNED_IDR_ONLY_FOR_IRAP_FLAG   1  ///< a flag to indicatate whether picture types for IRAP are IDR across layers.
    204173
    205 #define N0147_IRAP_ALIGN_FLAG            1      ///< a flag to indicatate whether IRAPs are aligned across layers
    206 #if N0147_IRAP_ALIGN_FLAG
    207 #define O0223_O0139_IRAP_ALIGN_NO_CONTRAINTS  1  ///< Remove IRAP align depedency constraints on poc_Reset_flag.
    208 #define IRAP_ALIGN_FLAG_IN_VPS_VUI       1       ///< Move IRAP align flag to VPS VUI
    209 #endif
    210 #if !N0147_IRAP_ALIGN_FLAG
    211 #define IDR_ALIGNMENT                    1      ///< align IDR picures across layers : As per JCTVC-N0373, IDR are not required to be aligned.
    212 #endif
    213 #define FAST_INTRA_SHVC                  1      ///< JCTVC-M0115: reduction number of intra modes in the EL (encoder only)
    214 #if FAST_INTRA_SHVC
    215 #define NB_REMAIN_MODES                  2      ///< JCTVC-M0115: nb of remaining modes
    216 #endif
    217 
    218 #define RC_SHVC_HARMONIZATION            1      ///< JCTVC-M0037: rate control for SHVC
     174#define IRAP_ALIGN_FLAG_IN_VPS_VUI       1      ///< Move IRAP align flag to VPS VUI
    219175
    220176#define VIEW_ID_RELATED_SIGNALING        1      ///< Introduce syntax elements view_id and view_id_val
    221 #define LAYERS_NOT_PRESENT_SEI           1      ///< JCTVC-M0043: add layers not present SEI.
    222 #define N0383_IL_CONSTRAINED_TILE_SETS_SEI  1
    223177#define N0065_LAYER_POC_ALIGNMENT        1
    224178
     
    246200
    247201#define Q0165_OUTPUT_LAYER_SET           1      ///< JCTVC-Q0165: add a constraint to disallow an empty output layer set
    248 #define Q0165_NUM_ADD_OUTPUT_LAYER_SETS  1      ///< JCTVC-Q0165: signal num_add_output_layer_set and default_target_output_layer_idc when vps_num_layer_sets_minus1 is greater than 0
     202#define Q0165_NUM_ADD_OUTPUT_LAYER_SETS  1      ///< JCTVC-Q0165: signal num_add_olss and default_target_output_layer_idc when vps_num_layer_sets_minus1 is greater than 0
     203
     204#define Q0078_ADD_LAYER_SETS             1      ///< JCTVC-Q0078: additional layer sets and layer set config
     205#if Q0078_ADD_LAYER_SETS
     206#define MAX_NUM_ADD_LAYER_SETS           1023
     207#endif
    249208
    250209#define VPS_DPB_SIZE_TABLE               1      ///< JCTVC-O0217: DPB operations: signaling DPB-related parameters
     
    263222#define P0138_USE_ALT_CPB_PARAMS_FLAG    1      ///< JCTVC-P0138: use_alt_cpb_params_flag syntax in buffering period SEI message extension
    264223#define P0166_MODIFIED_PPS_EXTENSION     1      ///< JCTVC-P0166: add pps_extension_type_flag
    265 
    266 #if VIEW_ID_RELATED_SIGNALING
     224#define BITRATE_PICRATE_SIGNALLING       1      ///< JCTVC-Q0102 Proposal 3 signal bitrate, picrate only up to the maximum temporal sub-layers in the corresponding layer set
     225#define LAYER_DECPICBUFF_PARAM           1      ///< JCTVC-Q0102 Proposal 2 infer value from layer DPB param
     226#define HRD_BPB                          1      ///< JCTVC-Q0101 Bitstream Partition Buffering Proposals
     227#define DPB_CONSTRAINTS                  1      ///< JCTVC-Q0100 RPS DPB constraints
     228
    267229/// scalability types
    268230enum ScalabilityType
    269231{
    270232  VIEW_ORDER_INDEX  = 1,
    271   SCALABILITY_ID = 2,
    272 };
    273 #endif
     233  SCALABILITY_ID    = 2,
     234  AUX_ID            = 3,
     235};
     236
     237/// normative encoder constraints --------
     238#define MFM_ENCCONSTRAINT                1      ///< JCTVC-O0216: Encoder constraint for motion field mapping
     239#define REF_IDX_ME_ZEROMV                1      ///< JCTVC-L0051: use zero motion for inter-layer reference picture (without fractional ME)
     240
     241/// encoder settings ---------------------
     242#define FAST_INTRA_SHVC                  1      ///< JCTVC-M0115: reduction number of intra modes in the EL (encoder only)
     243#if FAST_INTRA_SHVC
     244#define NB_REMAIN_MODES                  2      ///< JCTVC-M0115: nb of remaining modes
     245#endif
     246#define RC_SHVC_HARMONIZATION            1      ///< JCTVC-M0037: rate control for SHVC
     247#define JCTVC_M0259_LAMBDAREFINEMENT     1      ///< JCTVC-M0259: lambda refinement (encoder only optimization)
     248#define ENCODER_FAST_MODE                1      ///< JCTVC-L0174: enable encoder fast mode. TestMethod 1 is enabled by setting to 1 and TestMethod 2 is enable by setting to 2. By default it is set to 1.
     249#define LAYER_CTB                        0      ///< enable layer-specific CTB structure
     250
     251/// SEI messages -------------------------
     252#define P0050_KNEE_FUNCTION_SEI          1      ///< JCTVC-P0050: Knee function SEI
     253#define SUB_BITSTREAM_PROPERTY_SEI       1      ///< JCTVC-P0204: Sub-bitstream property SEI message
     254#if SUB_BITSTREAM_PROPERTY_SEI
     255#define MAX_SUB_STREAMS                  1024
     256#endif
     257#define Q0074_SEI_COLOR_MAPPING          1      ///< JCTVC-Q0074, SEI Color Mapping
     258#define LAYERS_NOT_PRESENT_SEI           1      ///< JCTVC-M0043: add layers not present SEI.
     259#define N0383_IL_CONSTRAINED_TILE_SETS_SEI  1
     260#define Q0189_TMVP_CONSTRAINTS           1      ///< JCTVC-Q0189: indicate constraints on TMVP
     261#define Q0247_FRAME_FIELD_INFO           1      ///< JCTVC-Q0247: field_frame_info SEI message
     262
    274263
    275264#else
     
    304293#define MAX_NESTING_NUM_LAYER       64
    305294
    306 #if VPS_RENAME
    307 #define MAX_VPS_OP_LAYER_SETS_PLUS1               3
     295#if SVC_EXTENSION
     296#define MAX_VPS_OP_LAYER_SETS_PLUS1               (MAX_LAYERS+1)
    308297#define MAX_VPS_LAYER_SETS_PLUS1                  1024
    309298#define MAX_VPS_LAYER_ID_PLUS1                    MAX_LAYERS
  • trunk/source/Lib/TLibDecoder/NALread.cpp

    r595 r815  
    114114  if ( nalu.m_temporalId )
    115115  {
     116#if !Q0108_TSA_STSA
    116117    assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA_W_LP
    117118         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA_W_RADL
     
    124125         && nalu.m_nalUnitType != NAL_UNIT_EOS
    125126         && nalu.m_nalUnitType != NAL_UNIT_EOB );
     127#else
     128    assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA_W_LP
     129         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA_W_RADL
     130         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA_N_LP
     131         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_IDR_W_RADL
     132         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_IDR_N_LP
     133         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_CRA
     134         && nalu.m_nalUnitType != NAL_UNIT_VPS
     135         && nalu.m_nalUnitType != NAL_UNIT_SPS
     136         && nalu.m_nalUnitType != NAL_UNIT_EOS);
     137#endif
    126138  }
    127139  else
    128140  {
     141#if !Q0108_TSA_STSA
    129142    assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TSA_R
    130143         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TSA_N
    131144         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_STSA_R
    132          && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_STSA_N );
     145         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_STSA_N
     146         );
     147#else
     148    assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TSA_R
     149         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TSA_N
     150         );
     151#endif
    133152  }
    134153}
  • trunk/source/Lib/TLibDecoder/SEIread.cpp

    r713 r815  
    9393    fprintf( g_hTrace, "===========Tone Mapping Info SEI message ===========\n");
    9494    break;
     95#if P0050_KNEE_FUNCTION_SEI
     96  case SEI::KNEE_FUNCTION_INFO:
     97    fprintf( g_hTrace, "=========== Knee Function Information SEI message ===========\n");
     98    break;
     99#endif
    95100#if Q0074_SEI_COLOR_MAPPING
    96101  case SEI::COLOR_MAPPING_INFO:
     
    129134  case SEI::BSP_HRD:
    130135    fprintf( g_hTrace, "=========== Bitstream parition HRD parameters SEI message ===========\n");
     136    break;
     137#endif
     138#if Q0078_ADD_LAYER_SETS
     139  case SEI::OUTPUT_LAYER_SET_NESTING:
     140    fprintf(g_hTrace, "=========== Output layer set nesting SEI message ===========\n");
     141    break;
     142  case SEI::VPS_REWRITING:
     143    fprintf(g_hTrace, "=========== VPS rewriting SEI message ===========\n");
    131144    break;
    132145#endif
     
    285298      xParseSEIToneMappingInfo((SEIToneMappingInfo&) *sei, payloadSize);
    286299      break;
     300#if P0050_KNEE_FUNCTION_SEI
     301    case SEI::KNEE_FUNCTION_INFO:
     302      sei = new SEIKneeFunctionInfo;
     303      xParseSEIKneeFunctionInfo((SEIKneeFunctionInfo&) *sei, payloadSize);
     304      break;
     305#endif
    287306#if Q0074_SEI_COLOR_MAPPING
    288307    case SEI::COLOR_MAPPING_INFO:
     
    345364     sei = new SEIBspHrd;
    346365     xParseSEIBspHrd((SEIBspHrd&) *sei, sps, *nestingSei);
     366     break;
     367#endif
     368#if Q0078_ADD_LAYER_SETS
     369   case SEI::OUTPUT_LAYER_SET_NESTING:
     370     sei = new SEIOutputLayerSetNesting;
     371#if LAYERS_NOT_PRESENT_SEI
     372     xParseSEIOutputLayerSetNesting((SEIOutputLayerSetNesting&)*sei, nalUnitType, vps, sps);
     373#else
     374     xParseSEIOutputLayerSetNesting((SEIOutputLayerSetNesting&)*sei, nalUnitType, sps);
     375#endif
     376     break;
     377   case SEI::VPS_REWRITING:
     378     sei = new SEIVPSRewriting;
     379     xParseSEIVPSRewriting((SEIVPSRewriting&)*sei);
     380     break;
     381#endif
     382#if Q0189_TMVP_CONSTRAINTS
     383   case SEI::TMVP_CONSTRAINTS:
     384     sei =  new SEITMVPConstrains;
     385     xParseSEITMVPConstraints((SEITMVPConstrains&) *sei, payloadSize);
     386     break;
     387#endif
     388#if Q0247_FRAME_FIELD_INFO
     389   case SEI::FRAME_FIELD_INFO:
     390     sei =  new SEIFrameFieldInfo;
     391     xParseSEIFrameFieldInfo    ((SEIFrameFieldInfo&) *sei, payloadSize);
    347392     break;
    348393#endif
     
    849894}
    850895
     896#if P0050_KNEE_FUNCTION_SEI
     897Void SEIReader::xParseSEIKneeFunctionInfo(SEIKneeFunctionInfo& sei, UInt /*payloadSize*/){
     898  Int i;
     899  UInt val;
     900  READ_UVLC( val, "knee_function_id" );                   sei.m_kneeId = val;
     901  READ_FLAG( val, "knee_function_cancel_flag" );          sei.m_kneeCancelFlag = val;
     902  if ( !sei.m_kneeCancelFlag )
     903  {
     904    READ_FLAG( val, "knee_function_persistence_flag" );   sei.m_kneePersistenceFlag = val;
     905    READ_FLAG( val, "mapping_flag" );                     sei.m_kneeMappingFlag = val;
     906    READ_CODE( 32, val, "input_d_range" );                sei.m_kneeInputDrange = val;
     907    READ_CODE( 32, val, "input_disp_luminance" );         sei.m_kneeInputDispLuminance = val;
     908    READ_CODE( 32, val, "output_d_range" );               sei.m_kneeOutputDrange = val;
     909    READ_CODE( 32, val, "output_disp_luminance" );        sei.m_kneeOutputDispLuminance = val;
     910    READ_UVLC( val, "num_knee_points_minus1" );           sei.m_kneeNumKneePointsMinus1 = val;
     911    assert( sei.m_kneeNumKneePointsMinus1 > 0 );
     912    sei.m_kneeInputKneePoint.resize(sei.m_kneeNumKneePointsMinus1+1);
     913    sei.m_kneeOutputKneePoint.resize(sei.m_kneeNumKneePointsMinus1+1);
     914    for(i = 0; i <= sei.m_kneeNumKneePointsMinus1; i++ )
     915    {
     916      READ_CODE( 10, val, "input_knee_point" );           sei.m_kneeInputKneePoint[i] = val;
     917      READ_CODE( 10, val, "output_knee_point" );          sei.m_kneeOutputKneePoint[i] = val;
     918    }
     919  }
     920}
     921#endif
     922
    851923#if Q0074_SEI_COLOR_MAPPING
    852924Void SEIReader::xParseSEIColorMappingInfo(SEIColorMappingInfo& sei, UInt /*payloadSize*/)
     
    9601032}
    9611033
     1034#if Q0189_TMVP_CONSTRAINTS
     1035Void SEIReader::xParseSEITMVPConstraints   (SEITMVPConstrains& sei, UInt payloadSize)
     1036{
     1037  UInt uiCode;
     1038  READ_UVLC( uiCode,           "prev_pics_not_used_flag"              ); sei.prev_pics_not_used_flag = uiCode;
     1039  READ_UVLC( uiCode,           "no_intra_layer_col_pic_flag"            ); sei.no_intra_layer_col_pic_flag = uiCode;
     1040  xParseByteAlign();
     1041}
     1042#endif
     1043
     1044#if Q0247_FRAME_FIELD_INFO
     1045Void SEIReader::xParseSEIFrameFieldInfo    (SEIFrameFieldInfo& sei, UInt payloadSize)
     1046{
     1047  UInt code;
     1048  READ_CODE( 4, code, "ffinfo_pic_struct" );             sei.m_ffinfo_picStruct            = code;
     1049  READ_CODE( 2, code, "ffinfo_source_scan_type" );       sei.m_ffinfo_sourceScanType = code;
     1050  READ_FLAG(    code, "ffinfo_duplicate_flag" );         sei.m_ffinfo_duplicateFlag    = ( code == 1 ? true : false );
     1051  xParseByteAlign();
     1052}
     1053#endif
     1054
    9621055#if LAYERS_NOT_PRESENT_SEI
    9631056Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComVPS *vps, TComSPS *sps)
     
    12091302    UInt lsIdx = nestingSei.m_nestingOpIdx[h];
    12101303    READ_UVLC( uiCode, "num_sei_bitstream_partitions_minus1[i]"); sei.m_seiNumBitstreamPartitionsMinus1[lsIdx] = uiCode;
    1211     for (UInt i = 0; i <= sei.m_seiNumBitstreamPartitionsMinus1[lsIdx]; i++)
    1212     {
    1213       for (UInt j = 0; j < sei.m_vpsMaxLayers; j++)
     1304#if HRD_BPB
     1305    Int chkPart=0;
     1306#endif
     1307    UInt i;
     1308    for(i = 0; i <= sei.m_seiNumBitstreamPartitionsMinus1[lsIdx]; i++)
     1309    {
     1310#if HRD_BPB
     1311      UInt nl=0; UInt j;
     1312      for(j = 0; j < sei.m_vpsMaxLayers; j++)
    12141313      {
    12151314        if (sei.m_layerIdIncludedFlag[lsIdx][j])
    12161315        {
     1316          nl++;
     1317        }
     1318      }
     1319      for (j = 0; j < nl; j++)
     1320      {
     1321#else
     1322      for (UInt j = 0; j < sei.m_vpsMaxLayers; j++)
     1323      {
     1324        if (sei.m_layerIdIncludedFlag[lsIdx][j])
     1325        {
     1326#endif
    12171327          READ_FLAG( uiCode, "sei_layer_in_bsp_flag[lsIdx][i][j]" ); sei.m_seiLayerInBspFlag[lsIdx][i][j] = uiCode;
    12181328        }
    1219       }
    1220     }
     1329#if !HRD_BPB
     1330      }
     1331#endif
     1332#if HRD_BPB
     1333      chkPart+=sei.m_seiLayerInBspFlag[lsIdx][i][j];
     1334#endif
     1335    }
     1336#if HRD_BPB
     1337    assert(chkPart<=1);
     1338#endif
     1339#if HRD_BPB
     1340    if(sei.m_seiNumBitstreamPartitionsMinus1[lsIdx]==0)
     1341    {
     1342      Int chkPartition1=0; Int chkPartition2=0;
     1343      for (UInt j = 0; j < sei.m_vpsMaxLayers; j++)
     1344      {
     1345        if( sei.m_layerIdIncludedFlag[lsIdx][j] )
     1346        {
     1347          chkPartition1+=sei.m_seiLayerInBspFlag[lsIdx][0][j];
     1348          chkPartition2++;
     1349        }
     1350      }
     1351      assert(chkPartition1!=chkPartition2);
     1352    }
     1353#endif
     1354     
    12211355    READ_UVLC( uiCode, "sei_num_bsp_sched_combinations_minus1[i]"); sei.m_seiNumBspSchedCombinationsMinus1[lsIdx] = uiCode;
    1222     for (UInt i = 0; i <= sei.m_seiNumBspSchedCombinationsMinus1[lsIdx]; i++)
     1356    for (i = 0; i <= sei.m_seiNumBspSchedCombinationsMinus1[lsIdx]; i++)
    12231357    {
    12241358      for (UInt j = 0; j <= sei.m_seiNumBitstreamPartitionsMinus1[lsIdx]; j++)
    12251359      {
    12261360        READ_UVLC( uiCode, "sei_bsp_comb_hrd_idx[lsIdx][i][j]"); sei.m_seiBspCombHrdIdx[lsIdx][i][j] = uiCode;
     1361#if HRD_BPB
     1362        assert(uiCode <= sei.m_seiNumBspHrdParametersMinus1);
     1363#endif
    12271364        READ_UVLC( uiCode, "sei_bsp_comb_sched_idx[lsIdx][i][j]"); sei.m_seiBspCombScheddx[lsIdx][i][j] = uiCode;
     1365#if HRD_BPB
     1366        assert(uiCode <= sei.hrd->getCpbCntMinus1( sps->getMaxTLayers()-1 ));
     1367#endif
     1368
    12281369      }
    12291370    }
     
    13071448#endif
    13081449
     1450#if Q0078_ADD_LAYER_SETS
     1451
     1452#if LAYERS_NOT_PRESENT_SEI
     1453Void SEIReader::xParseSEIOutputLayerSetNesting(SEIOutputLayerSetNesting& sei, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps)
     1454#else
     1455Void SEIReader::xParseSEIOutputLayerSetNesting(SEIOutputLayerSetNesting& sei, const NalUnitType nalUnitType, TComSPS *sps)
     1456#endif
     1457{
     1458  UInt uiCode;
     1459  SEIMessages seis;
     1460
     1461  READ_FLAG(uiCode, "ols_flag"); sei.m_olsFlag = uiCode;
     1462  READ_UVLC(uiCode, "num_ols_indices_minus1"); sei.m_numOlsIndicesMinus1 = uiCode;
     1463
     1464  for (Int i = 0; i <= sei.m_numOlsIndicesMinus1; i++)
     1465  {
     1466    READ_UVLC(uiCode, "ols_idx[i]"); sei.m_olsIdx[i] = uiCode;
     1467  }
     1468
     1469  // byte alignment
     1470  while (m_pcBitstream->getNumBitsRead() % 8 != 0)
     1471  {
     1472    UInt code;
     1473    READ_FLAG(code, "ols_nesting_zero_bit");
     1474  }
     1475
     1476  sei.m_callerOwnsSEIs = false;
     1477
     1478  // read nested SEI messages
     1479  do {
     1480#if O0164_MULTI_LAYER_HRD
     1481#if LAYERS_NOT_PRESENT_SEI
     1482    xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps);
     1483#else
     1484    xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps);
     1485#endif
     1486#else
     1487#if LAYERS_NOT_PRESENT_SEI
     1488    xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps);
     1489#else
     1490    xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps);
     1491#endif
     1492#endif
     1493  } while (m_pcBitstream->getNumBitsLeft() > 8);
     1494
     1495}
     1496
     1497Void SEIReader::xParseSEIVPSRewriting(SEIVPSRewriting &sei)
     1498{
     1499}
     1500
     1501#endif
     1502
    13091503#endif //SVC_EXTENSION
    13101504
  • trunk/source/Lib/TLibDecoder/SEIread.h

    r713 r815  
    9090  Void xParseSEIGradualDecodingRefreshInfo (SEIGradualDecodingRefreshInfo &sei, UInt payloadSize);
    9191  Void xParseSEIToneMappingInfo       (SEIToneMappingInfo& sei, UInt payloadSize);
     92#if P0050_KNEE_FUNCTION_SEI
     93  Void xParseSEIKneeFunctionInfo      (SEIKneeFunctionInfo& sei, UInt payloadSize);
     94#endif
    9295#if Q0074_SEI_COLOR_MAPPING
    9396  Void xParseSEIColorMappingInfo      (SEIColorMappingInfo& sei, UInt payloadSize);
     
    116119  Void xParseHrdParameters(TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1);
    117120#endif
     121#if Q0078_ADD_LAYER_SETS
     122#if LAYERS_NOT_PRESENT_SEI
     123  Void xParseSEIOutputLayerSetNesting(SEIOutputLayerSetNesting& sei, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps);
     124#else
     125  Void xParseSEIOutputLayerSetNesting(SEIOutputLayerSetNesting& sei, const NalUnitType nalUnitType, TComSPS *sps);
     126#endif
     127  Void xParseSEIVPSRewriting(SEIVPSRewriting &sei);
     128#endif
     129
     130#if Q0189_TMVP_CONSTRAINTS
     131  Void xParseSEITMVPConstraints    (SEITMVPConstrains& sei, UInt payloadSize);
     132#endif
     133#if Q0247_FRAME_FIELD_INFO
     134  Void xParseSEIFrameFieldInfo    (SEIFrameFieldInfo& sei, UInt payloadSize);
     135#endif
    118136  Void xParseByteAlign();
    119137};
  • trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp

    r713 r815  
    339339
    340340  READ_FLAG( uiCode, "pps_extension_flag");
     341#if POC_RESET_INFO_INFERENCE
     342  pcPPS->setExtensionFlag( uiCode ? true : false );
     343
     344  if( pcPPS->getExtensionFlag() )
     345#else
    341346  if (uiCode)
     347#endif 
    342348  {
    343349#if P0166_MODIFIED_PPS_EXTENSION
     
    367373#endif
    368374    }
     375#if POC_RESET_INFO_INFERENCE
     376    else  // Extension type 0 absent
     377    {
     378      pcPPS->setPocResetInfoPresentFlag( false );
     379    }
     380#endif
    369381    if (ppsExtensionTypeFlag[7])
    370382    {
     
    379391#endif
    380392  }
     393#if POC_RESET_INFO_INFERENCE
     394  if( !pcPPS->getExtensionFlag() )
     395  {
     396    pcPPS->setPocResetInfoPresentFlag( false );
     397  }
     398#endif
    381399}
    382400
     
    443461  TimingInfo *timingInfo = pcVUI->getTimingInfo();
    444462  READ_FLAG(       uiCode, "vui_timing_info_present_flag");         timingInfo->setTimingInfoPresentFlag      (uiCode ? true : false);
    445 #if TIMING_INFO_NONZERO_LAYERID_SPS
     463#if SVC_EXTENSION
    446464  if( pcSPS->getLayerId() > 0 )
    447465  {
     
    585603#endif
    586604
     605#if !Q0177_SPS_TEMP_NESTING_FIX   //This part is not needed anymore as it is already covered by implementation in TDecTop::xActivateParameterSets()
    587606  if ( pcSPS->getMaxTLayers() == 1 )
    588607  {
     
    596615#endif
    597616  }
     617#endif
     618
    598619#ifdef SPS_PTL_FIX
    599620  if ( pcSPS->getLayerId() == 0)
     
    827848
    828849  READ_FLAG( uiCode, "sps_extension_flag");
    829   if (uiCode)
    830   {
    831 #if SPS_EXTENSION
    832 
     850
     851#if SVC_EXTENSION
     852  pcSPS->setExtensionFlag( uiCode ? true : false );
     853
     854  if( pcSPS->getExtensionFlag() )
     855  {
    833856#if O0142_CONDITIONAL_SPS_EXTENSION
    834857    UInt spsExtensionTypeFlag[8];
     
    849872    {
    850873#endif
    851 
    852 #endif
    853874      while ( xMoreRbspData() )
    854875      {
    855876        READ_FLAG( uiCode, "sps_extension_data_flag");
    856877      }
    857 #if SPS_EXTENSION
    858     }
    859 #endif
    860   }
    861 }
    862 
    863 #if SPS_EXTENSION
     878    }
     879  }
     880#else
     881  if (uiCode)
     882  {
     883    while ( xMoreRbspData() )
     884    {
     885      READ_FLAG( uiCode, "sps_extension_data_flag");
     886    }
     887  }
     888#endif
     889}
     890
     891#if SVC_EXTENSION
    864892Void TDecCavlc::parseSPSExtension( TComSPS* pcSPS )
    865893{
     
    899927  READ_CODE( 4,  uiCode,  "vps_video_parameter_set_id" );         pcVPS->setVPSId( uiCode );
    900928  READ_CODE( 2,  uiCode,  "vps_reserved_three_2bits" );           assert(uiCode == 3);
    901 #if VPS_RENAME
     929#if SVC_EXTENSION
    902930#if O0137_MAX_LAYERID
    903931  READ_CODE( 6,  uiCode,  "vps_max_layers_minus1" );              pcVPS->setMaxLayers( min( 62u, uiCode) + 1 );
     
    941969  }
    942970
    943 #if VPS_RENAME
     971#if SVC_EXTENSION
    944972  assert( pcVPS->getNumHrdParameters() < MAX_VPS_LAYER_SETS_PLUS1 );
    945973  assert( pcVPS->getMaxLayerId()       < MAX_VPS_LAYER_ID_PLUS1 );
    946974  READ_CODE( 6, uiCode, "vps_max_layer_id" );           pcVPS->setMaxLayerId( uiCode );
     975#if Q0078_ADD_LAYER_SETS
     976  READ_UVLC(uiCode, "vps_num_layer_sets_minus1");  pcVPS->setVpsNumLayerSetsMinus1(uiCode);
     977  pcVPS->setNumLayerSets(pcVPS->getVpsNumLayerSetsMinus1() + 1);
     978  for (UInt opsIdx = 1; opsIdx <= pcVPS->getVpsNumLayerSetsMinus1(); opsIdx++)
     979#else
    947980  READ_UVLC(    uiCode, "vps_num_layer_sets_minus1" );  pcVPS->setNumLayerSets( uiCode + 1 );
    948981  for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getNumLayerSets() - 1 ); opsIdx ++ )
     982#endif
    949983  {
    950984    // Operation point set
     
    9951029  }
    9961030
    997 #if VPS_EXTNS
     1031#if SVC_EXTENSION
    9981032  READ_FLAG( uiCode,  "vps_extension_flag" );      pcVPS->setVpsExtensionFlag( uiCode ? true : false );
    9991033
     
    10401074
    10411075#if SVC_EXTENSION
    1042 #if VPS_EXTNS
    10431076Void TDecCavlc::parseVPSExtension(TComVPS *vps)
    10441077{
     
    10811114  }
    10821115
     1116  // The value of dimBitOffset[ NumScalabilityTypes ] is set equal to 6.
    10831117  if(vps->getSplittingFlag())
    10841118  {
     
    11661200  }
    11671201#endif
     1202#if Q0078_ADD_LAYER_SETS
     1203#if O0092_0094_DEPENDENCY_CONSTRAINT // Moved here
     1204  vps->setNumRefLayers();
     1205
     1206  if (vps->getMaxLayers() > MAX_REF_LAYERS)
     1207  {
     1208    for (i = 1; i < vps->getMaxLayers(); i++)
     1209    {
     1210      assert(vps->getNumRefLayers(vps->getLayerIdInNuh(i)) <= MAX_REF_LAYERS);
     1211    }
     1212  }
     1213#endif
     1214  vps->setPredictedLayerIds();
     1215  vps->setTreePartitionLayerIdList();
     1216#endif
    11681217#if VPS_TSLAYERS
    11691218  READ_FLAG( uiCode, "vps_sub_layers_max_minus1_present_flag"); vps->setMaxTSLayersPresentFlag(uiCode ? true : false);
     
    11841233  }
    11851234#endif
    1186 #if N0120_MAX_TID_REF_PRESENT_FLAG
    11871235  READ_FLAG( uiCode, "max_tid_ref_present_flag"); vps->setMaxTidRefPresentFlag(uiCode ? true : false);
    11881236  if (vps->getMaxTidRefPresentFlag())
     
    12011249#else
    12021250      READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i]" ); vps->setMaxTidIlRefPicsPlus1(i, uiCode);
    1203 #if N0120_MAX_TID_REF_CFG
    12041251      assert( uiCode <= vps->getMaxTLayers());
    1205 #else
    1206       assert( uiCode <= vps->getMaxTLayers()+ 1 );
    1207 #endif
    12081252#endif
    12091253    }
     
    12231267    }
    12241268  }
    1225 #else
    1226   for(i = 0; i < vps->getMaxLayers() - 1; i++)
    1227   {
    1228 #if O0225_MAX_TID_FOR_REF_LAYERS
    1229        for( j = i+1; j <= vps->getMaxLayers() - 1; j++)
    1230        {
    1231          if(vps->getDirectDependencyFlag(j, i))
    1232          {
    1233            READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i][j]" ); vps->setMaxTidIlRefPicsPlus1(i, j, uiCode);
    1234            assert( uiCode <= vps->getMaxTLayers() );
    1235          }
    1236        }
    1237 #else
    1238     READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i]" ); vps->setMaxTidIlRefPicsPlus1(i, uiCode);
    1239     assert( uiCode <= vps->getMaxTLayers() );
    1240 #endif   
    1241   }
    1242 #endif
    1243 #if ILP_SSH_SIG
    1244     READ_FLAG( uiCode, "all_ref_layers_active_flag" ); vps->setIlpSshSignalingEnabledFlag(uiCode ? true : false);
    1245 #endif
     1269  READ_FLAG( uiCode, "all_ref_layers_active_flag" ); vps->setIlpSshSignalingEnabledFlag(uiCode ? true : false);
    12461270#if VPS_EXTN_PROFILE_INFO
    12471271  // Profile-tier-level signalling
     
    12761300#endif
    12771301
     1302#if Q0078_ADD_LAYER_SETS
     1303  if (vps->getNumIndependentLayers() > 1)
     1304  {
     1305    READ_UVLC(uiCode, "num_add_layer_sets"); vps->setNumAddLayerSets(uiCode);
     1306    for (i = 0; i < vps->getNumAddLayerSets(); i++)
     1307    {
     1308      for (j = 1; j < vps->getNumIndependentLayers(); j++)
     1309      {
     1310        int len = 1;
     1311        while ((1 << len) < (vps->getNumLayersInTreePartition(j) + 1))
     1312        {
     1313          len++;
     1314        }
     1315        READ_CODE(len, uiCode, "highest_layer_idx_plus1[i][j]"); vps->setHighestLayerIdxPlus1(i, j, uiCode);
     1316      }
     1317    }
     1318    vps->setNumLayerSets(vps->getNumLayerSets() + vps->getNumAddLayerSets());
     1319    vps->setLayerIdIncludedFlagsForAddLayerSets();
     1320  }
     1321#endif
     1322
    12781323#if !VPS_EXTN_UEV_CODING
    12791324  READ_FLAG( uiCode, "more_output_layer_sets_than_default_flag" ); vps->setMoreOutputLayerSetsThanDefaultFlag( uiCode ? true : false );
     
    12931338  if( vps->getNumLayerSets() > 1 )
    12941339  {
    1295     READ_UVLC( uiCode, "num_add_output_layer_sets" );            vps->setNumAddOutputLayerSets( uiCode );
    1296     READ_CODE( 2, uiCode, "default_target_output_layer_idc" );   vps->setDefaultTargetOutputLayerIdc( uiCode );
     1340    READ_UVLC( uiCode, "num_add_olss" );            vps->setNumAddOutputLayerSets( uiCode );
     1341    READ_CODE( 2, uiCode, "default_output_layer_idc" );   vps->setDefaultTargetOutputLayerIdc( uiCode );
    12971342  }
    12981343  else
     
    13041349#endif
    13051350
    1306   // The value of num_add_output_layer_sets shall be in the range of 0 to 1023, inclusive.
     1351  // The value of num_add_olss shall be in the range of 0 to 1023, inclusive.
    13071352  assert( vps->getNumAddOutputLayerSets() >= 0 && vps->getNumAddOutputLayerSets() < 1024 );
    13081353
     
    13281373        numBits++;
    13291374      }
    1330       READ_CODE( numBits, uiCode, "output_layer_set_idx_minus1");   vps->setOutputLayerSetIdx( i, uiCode + 1);
     1375      READ_CODE( numBits, uiCode, "layer_set_idx_for_ols_minus1");   vps->setOutputLayerSetIdx( i, uiCode + 1);
    13311376    }
    13321377    else
     
    13341379      vps->setOutputLayerSetIdx( i, i );
    13351380    }
     1381#if Q0078_ADD_LAYER_SETS
     1382    if ( i > vps->getVpsNumLayerSetsMinus1() || vps->getDefaultTargetOutputLayerIdc() >= 2 )
     1383#else
    13361384    if ( i > (vps->getNumLayerSets() - 1) || vps->getDefaultTargetOutputLayerIdc() >= 2 )
     1385#endif
    13371386    {
    13381387      Int lsIdx = vps->getOutputLayerSetIdx(i);
     
    16341683#endif
    16351684
    1636 #if N0147_IRAP_ALIGN_FLAG && !IRAP_ALIGN_FLAG_IN_VPS_VUI
     1685#if !IRAP_ALIGN_FLAG_IN_VPS_VUI
    16371686  READ_FLAG(uiCode, "cross_layer_irap_aligned_flag" );
    16381687  vps->setCrossLayerIrapAlignFlag(uiCode);
     
    16781727  }
    16791728#endif
    1680 #if O0092_0094_DEPENDENCY_CONSTRAINT
    1681   for(i = 1; i < vps->getMaxLayers(); i++)
    1682   {
    1683     vps->setNumRefLayers(vps->getLayerIdInNuh(i));   // identify the number of direct and indirect reference layers of current layer and set recursiveRefLayersFlags
    1684   }
     1729#if !Q0078_ADD_LAYER_SETS
     1730#if O0092_0094_DEPENDENCY_CONSTRAINT // Moved up
     1731  vps->setNumRefLayers();
     1732
    16851733  if(vps->getMaxLayers() > MAX_REF_LAYERS)
    16861734  {
     
    16901738    }
    16911739  }
     1740#endif
    16921741#endif
    16931742
     
    17321781#endif
    17331782  {
    1734 #if VPS_VUI
    17351783    while ( m_pcBitstream->getNumBitsRead() % 8 != 0 )
    17361784    {
     
    17381786    }
    17391787    parseVPSVUI(vps);
    1740 #endif
    17411788  }
    17421789  else
     
    17781825  }
    17791826 
    1780   // When not present, the value of num_add_output_layer_sets is inferred to be equal to 0.
    1781   // NumOutputLayerSets = num_add_output_layer_sets + vps_num_layer_sets_minus1 + 1
     1827  // When not present, the value of num_add_olss is inferred to be equal to 0.
     1828  // NumOutputLayerSets = num_add_olss + NumLayerSets
    17821829  vps->setNumOutputLayerSets( vps->getNumLayerSets() );
    17831830
    17841831  // For i in the range of 0 to NumOutputLayerSets-1, inclusive, the variable LayerSetIdxForOutputLayerSet[ i ] is derived as specified in the following:
    1785   // LayerSetIdxForOutputLayerSet[ i ] = ( i <= vps_number_layer_sets_minus1 ) ? i : output_layer_set_idx_minus1[ i ] + 1
     1832  // LayerSetIdxForOutputLayerSet[ i ] = ( i <= vps_number_layer_sets_minus1 ) ? i : layer_set_idx_for_ols_minus1[ i ] + 1
    17861833  for( i = 1; i < vps->getNumOutputLayerSets(); i++ )
    17871834  {
     
    18341881Void TDecCavlc::defaultVPSVUI( TComVPS* vps )
    18351882{
    1836 #if N0147_IRAP_ALIGN_FLAG
    18371883  // When not present, the value of all_layers_idr_aligned_flag is inferred to be equal to 0.
    18381884  vps->setCrossLayerIrapAlignFlag( false );
    1839 #endif
    18401885
    18411886#if M0040_ADAPTIVE_RESOLUTION_CHANGE
     
    18491894#endif
    18501895}
    1851 #endif
    18521896
    18531897#if REPN_FORMAT_IN_VPS
     
    19181962  UInt uiCode;
    19191963#if DPB_PARAMS_MAXTLAYERS
     1964#if BITRATE_PICRATE_SIGNALLING
     1965    Int * MaxSubLayersInLayerSetMinus1 = new Int[vps->getNumLayerSets()];
     1966    for(Int i = 0; i < vps->getNumLayerSets(); i++)
     1967#else
    19201968    Int * MaxSubLayersInLayerSetMinus1 = new Int[vps->getNumOutputLayerSets()];
    19211969    for(Int i = 1; i < vps->getNumOutputLayerSets(); i++)
     1970#endif
    19221971    {
    19231972        UInt maxSLMinus1 = 0;
     
    19271976        Int optLsIdx = i;
    19281977#endif
     1978#if BITRATE_PICRATE_SIGNALLING
     1979        optLsIdx = i;
     1980#endif
    19291981        for(Int k = 0; k < vps->getNumLayersInIdList(optLsIdx); k++ ) {
    19301982            Int  lId = vps->getLayerSetLayerIdList(optLsIdx, k);
     
    19321984        }
    19331985        MaxSubLayersInLayerSetMinus1[ i ] = maxSLMinus1;
     1986#if BITRATE_PICRATE_SIGNALLING
     1987        vps->setMaxSLayersInLayerSetMinus1(i,MaxSubLayersInLayerSetMinus1[ i ]);
     1988#endif
    19341989    }
    19351990#endif
     
    19452000    READ_FLAG( uiCode, "sub_layer_flag_info_present_flag[i]");  vps->setSubLayerFlagInfoPresentFlag( i, uiCode ? true : false );
    19462001#if DPB_PARAMS_MAXTLAYERS
     2002#if BITRATE_PICRATE_SIGNALLING
     2003    for(Int j = 0; j <= MaxSubLayersInLayerSetMinus1[ vps->getOutputLayerSetIdx( i ) ]; j++)
     2004#else
    19472005    for(Int j = 0; j <= MaxSubLayersInLayerSetMinus1[ i ]; j++)
     2006#endif
    19482007#else
    19492008    for(Int j = 0; j <= vps->getMaxTLayers(); j++)
     
    20092068      if( !vps->getSubLayerDpbInfoPresentFlag(i, j) )  // If sub-layer DPB information is NOT present
    20102069      {
     2070#if RESOLUTION_BASED_DPB
    20112071        for(Int k = 0; k < vps->getNumSubDpbs(layerSetIdxForOutputLayerSet); k++)
     2072#else
     2073        for(Int k = 0; k < vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ); k++)
     2074#endif
    20122075        {
    20132076          vps->setMaxVpsDecPicBufferingMinus1( i, k, j, vps->getMaxVpsDecPicBufferingMinus1( i, k, j - 1 ) );
    20142077        }
    20152078        vps->setMaxVpsNumReorderPics( i, j, vps->getMaxVpsNumReorderPics( i, j - 1) );
     2079#if RESOLUTION_BASED_DPB
    20162080        for(Int k = 0; k < vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ); k++)
    20172081        {
    20182082          vps->setMaxVpsLayerDecPicBuffMinus1( i, k, j, vps->getMaxVpsLayerDecPicBuffMinus1( i, k, j - 1));
    20192083        }
     2084#endif
    20202085        vps->setMaxVpsLatencyIncreasePlus1( i, j, vps->getMaxVpsLatencyIncreasePlus1( i, j - 1 ) );
    20212086      }
     
    20242089}
    20252090#endif
    2026 #if VPS_VUI
     2091
    20272092Void TDecCavlc::parseVPSVUI(TComVPS *vps)
    20282093{
     
    20392104    vps->setCrossLayerIrapAlignFlag(uiCode);
    20402105#if P0068_CROSS_LAYER_ALIGNED_IDR_ONLY_FOR_IRAP_FLAG
    2041     if (uiCode)
    2042     {
    2043       READ_FLAG(uiCode, "all_layers_idr_aligned_flag" );
    2044       vps->setCrossLayerIrapAlignFlag(uiCode);
     2106    if( uiCode )
     2107    {
     2108      READ_FLAG( uiCode, "all_layers_idr_aligned_flag" );
     2109      vps->setCrossLayerAlignedIdrOnlyFlag(uiCode);
    20452110    }
    20462111#endif
     
    20532118  }
    20542119#endif
    2055 #if VPS_VUI_BITRATE_PICRATE
     2120
    20562121  READ_FLAG( uiCode,        "bit_rate_present_vps_flag" );  vps->setBitRatePresentVpsFlag( uiCode ? true : false );
    20572122  READ_FLAG( uiCode,        "pic_rate_present_vps_flag" );  vps->setPicRatePresentVpsFlag( uiCode ? true : false );
    20582123
    20592124  Bool parseFlag = vps->getBitRatePresentVpsFlag() || vps->getPicRatePresentVpsFlag();
    2060   {
    2061     for( i = 0; i < vps->getNumLayerSets(); i++ )
    2062     {
    2063       for( j = 0; j < vps->getMaxTLayers(); j++ )
    2064       {
    2065         if( parseFlag && vps->getBitRatePresentVpsFlag() )
    2066         {
    2067           READ_FLAG( uiCode,        "bit_rate_present_flag[i][j]" );  vps->setBitRatePresentFlag( i, j, uiCode ? true : false );
    2068         }
    2069         else
    2070         {
    2071           vps->setBitRatePresentFlag( i, j, false );
    2072         }
    2073         if( parseFlag && vps->getPicRatePresentVpsFlag() )
    2074         {
    2075           READ_FLAG( uiCode,        "pic_rate_present_flag[i][j]" );  vps->setPicRatePresentFlag( i, j, uiCode ? true : false );
    2076         }
    2077         else
    2078         {
    2079           vps->setPicRatePresentFlag( i, j, false );
    2080         }
    2081         if( parseFlag && vps->getBitRatePresentFlag(i, j) )
    2082         {
    2083           READ_CODE( 16, uiCode,    "avg_bit_rate[i][j]" ); vps->setAvgBitRate( i, j, uiCode );
    2084           READ_CODE( 16, uiCode,    "max_bit_rate[i][j]" ); vps->setMaxBitRate( i, j, uiCode );
    2085         }
    2086         else
    2087         {
    2088           vps->setAvgBitRate( i, j, 0 );
    2089           vps->setMaxBitRate( i, j, 0 );
    2090         }
    2091         if( parseFlag && vps->getPicRatePresentFlag(i, j) )
    2092         {
    2093           READ_CODE( 2 , uiCode,    "constant_pic_rate_idc[i][j]" ); vps->setConstPicRateIdc( i, j, uiCode );
    2094           READ_CODE( 16, uiCode,    "avg_pic_rate[i][j]"          ); vps->setAvgPicRate( i, j, uiCode );
    2095         }
    2096         else
    2097         {
    2098           vps->setConstPicRateIdc( i, j, 0 );
    2099           vps->setAvgPicRate     ( i, j, 0 );
    2100         }
    2101       }
    2102     }
    2103   }
    2104 #endif
     2125
     2126#if Q0078_ADD_LAYER_SETS
     2127  for( i = 0; i <= vps->getVpsNumLayerSetsMinus1(); i++ )
     2128#else
     2129  for( i = 0; i < vps->getNumLayerSets(); i++ )
     2130#endif
     2131  {
     2132#if BITRATE_PICRATE_SIGNALLING
     2133    for( j = 0; j <= vps->getMaxSLayersInLayerSetMinus1(i); j++ )
     2134#else
     2135    for( j = 0; j < vps->getMaxTLayers(); j++ )
     2136#endif
     2137    {
     2138      if( parseFlag && vps->getBitRatePresentVpsFlag() )
     2139      {
     2140        READ_FLAG( uiCode,        "bit_rate_present_flag[i][j]" );  vps->setBitRatePresentFlag( i, j, uiCode ? true : false );
     2141      }
     2142      else
     2143      {
     2144        vps->setBitRatePresentFlag( i, j, false );
     2145      }
     2146      if( parseFlag && vps->getPicRatePresentVpsFlag() )
     2147      {
     2148        READ_FLAG( uiCode,        "pic_rate_present_flag[i][j]" );  vps->setPicRatePresentFlag( i, j, uiCode ? true : false );
     2149      }
     2150      else
     2151      {
     2152        vps->setPicRatePresentFlag( i, j, false );
     2153      }
     2154      if( parseFlag && vps->getBitRatePresentFlag(i, j) )
     2155      {
     2156        READ_CODE( 16, uiCode,    "avg_bit_rate[i][j]" ); vps->setAvgBitRate( i, j, uiCode );
     2157        READ_CODE( 16, uiCode,    "max_bit_rate[i][j]" ); vps->setMaxBitRate( i, j, uiCode );
     2158      }
     2159      else
     2160      {
     2161        vps->setAvgBitRate( i, j, 0 );
     2162        vps->setMaxBitRate( i, j, 0 );
     2163      }
     2164      if( parseFlag && vps->getPicRatePresentFlag(i, j) )
     2165      {
     2166        READ_CODE( 2 , uiCode,    "constant_pic_rate_idc[i][j]" ); vps->setConstPicRateIdc( i, j, uiCode );
     2167        READ_CODE( 16, uiCode,    "avg_pic_rate[i][j]"          ); vps->setAvgPicRate( i, j, uiCode );
     2168      }
     2169      else
     2170      {
     2171        vps->setConstPicRateIdc( i, j, 0 );
     2172        vps->setAvgPicRate     ( i, j, 0 );
     2173      }
     2174    }
     2175  }
    21052176#if VPS_VUI_VIDEO_SIGNAL_MOVE
    21062177  READ_FLAG( uiCode, "video_signal_info_idx_present_flag" ); vps->setVideoSigPresentVpsFlag( uiCode == 1 );
     
    21622233    }
    21632234#endif
    2164 #if TILE_BOUNDARY_ALIGNED_FLAG
     2235
    21652236    for(i = 1; i < vps->getMaxLayers(); i++)
    21662237    {
     
    21772248      }
    21782249    }
    2179 #endif
    21802250#if VPS_VUI_TILES_NOT_IN_USE__FLAG
    21812251  }
     
    22902360        parseHrdParameters(vps->getBspHrd(i), i==0 ? 1 : vps->getBspCprmsPresentFlag(i), vps->getMaxTLayers()-1);
    22912361      }
     2362#if Q0078_ADD_LAYER_SETS
     2363      for (UInt h = 1; h <= vps->getVpsNumLayerSetsMinus1(); h++)
     2364#else
    22922365      for( UInt h = 1; h <= (vps->getNumLayerSets()-1); h++ )
     2366#endif
    22932367      {
    22942368        READ_UVLC( uiCode, "num_bitstream_partitions[i]"); vps->setNumBitstreamPartitions(h, uiCode);
     2369#if HRD_BPB
     2370        Int chkPart=0;
     2371#endif
    22952372        for( i = 0; i < vps->getNumBitstreamPartitions(h); i++ )
    22962373        {
     
    23022379            }
    23032380          }
    2304         }
     2381#if HRD_BPB
     2382          chkPart+=vps->getLayerInBspFlag(h, i, j);
     2383#endif
     2384        }
     2385#if HRD_BPB
     2386        assert(chkPart<=1);
     2387#endif
     2388#if HRD_BPB
     2389        if(vps->getNumBitstreamPartitions(h)==1)
     2390        {
     2391          Int chkPartition1=0; Int chkPartition2=0;
     2392          for( j = 0; j <= (vps->getMaxLayers()-1); j++ )
     2393          {
     2394            if( vps->getLayerIdIncludedFlag(h, j) )
     2395            {
     2396              chkPartition1+=vps->getLayerInBspFlag(h, 0, j);
     2397              chkPartition2++;
     2398            }
     2399          }
     2400          assert(chkPartition1!=chkPartition2);
     2401        }
     2402#endif
    23052403        if (vps->getNumBitstreamPartitions(h))
    23062404        {
     2405#if Q0182_MULTI_LAYER_HRD_UPDATE
     2406          READ_UVLC( uiCode, "num_bsp_sched_combinations_minus1[h]"); vps->setNumBspSchedCombinations(h, uiCode + 1);
     2407#else
    23072408          READ_UVLC( uiCode, "num_bsp_sched_combinations[h]"); vps->setNumBspSchedCombinations(h, uiCode);
     2409#endif
    23082410          for( i = 0; i < vps->getNumBspSchedCombinations(h); i++ )
    23092411          {
     
    23112413            {
    23122414              READ_UVLC( uiCode, "bsp_comb_hrd_idx[h][i][j]"); vps->setBspCombHrdIdx(h, i, j, uiCode);
     2415#if HRD_BPB
     2416              assert(uiCode <= vps->getVpsNumBspHrdParametersMinus1());
     2417#endif
     2418               
    23132419              READ_UVLC( uiCode, "bsp_comb_sched_idx[h][i][j]"); vps->setBspCombSchedIdx(h, i, j, uiCode);
     2420#if HRD_BPB
     2421              assert(uiCode <= vps->getBspHrdParamBufferCpbCntMinus1(uiCode,vps->getMaxTLayers()-1));
     2422#endif
    23142423            }
    23152424          }
     
    23342443#endif
    23352444}
    2336 #endif
    23372445#endif //SVC_EXTENSION
    23382446
     
    24122520  }
    24132521
     2522#if Q0142_POC_LSB_NOT_PRESENT
     2523#if SHM_FIX7
     2524    Int iPOClsb = 0;
     2525#endif
     2526#endif
     2527
    24142528  if(!rpcSlice->getDependentSliceSegmentFlag())
    24152529  {
     
    24842598    }
    24852599#if N0065_LAYER_POC_ALIGNMENT
     2600#if !Q0142_POC_LSB_NOT_PRESENT
    24862601#if SHM_FIX7
    24872602    Int iPOClsb = 0;
    24882603#endif
     2604#endif
    24892605#if O0062_POC_LSB_NOT_PRESENT_FLAG
    24902606    if( ( rpcSlice->getLayerId() > 0 && !rpcSlice->getVPS()->getPocLsbNotPresentFlag( rpcSlice->getVPS()->getLayerIdInVps(rpcSlice->getLayerId())) ) || !rpcSlice->getIdrPicFlag())
     
    24972613    {
    24982614      READ_CODE(sps->getBitsForPOC(), uiCode, "pic_order_cnt_lsb");
     2615#if POC_RESET_IDC_DECODER
     2616      rpcSlice->setPicOrderCntLsb( uiCode );
     2617#endif
    24992618#if SHM_FIX7
    25002619      iPOClsb = uiCode;
     
    25312650#if SHM_FIX7
    25322651      }
     2652#endif
     2653#if POC_RESET_IDC_DECODER
     2654    else
     2655    {
     2656      rpcSlice->setPicOrderCntLsb( 0 );
     2657    }
    25332658#endif
    25342659      if( !rpcSlice->getIdrPicFlag() )
     
    26452770        rps->setNumberOfPictures(offset);
    26462771      }
     2772#if DPB_CONSTRAINTS
     2773          if(rpcSlice->getVPS()->getVpsExtensionFlag()==1)
     2774          {
     2775#if Q0078_ADD_LAYER_SETS
     2776              for (Int ii = 1; ii < (rpcSlice->getVPS()->getVpsNumLayerSetsMinus1() + 1); ii++)  // prevent assert error when num_add_layer_sets > 0
     2777#else
     2778              for (Int ii=1; ii< rpcSlice->getVPS()->getNumOutputLayerSets(); ii++ )
     2779#endif
     2780              {
     2781                  Int layerSetIdxForOutputLayerSet = rpcSlice->getVPS()->getOutputLayerSetIdx( ii );
     2782                  Int chkAssert=0;
     2783                  for(Int kk = 0; kk < rpcSlice->getVPS()->getNumLayersInIdList(layerSetIdxForOutputLayerSet); kk++)
     2784                  {
     2785                      if(rpcSlice->getLayerId()==rpcSlice->getVPS()->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, kk))
     2786                      {
     2787                          chkAssert=1;
     2788                      }
     2789                  }
     2790                  if(chkAssert)
     2791                  {
     2792                      // There may be something wrong here (layer id assumed to be layer idx?)
     2793                      assert(rps->getNumberOfNegativePictures() <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii)));
     2794                      assert(rps->getNumberOfPositivePictures() <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii)) - rps->getNumberOfNegativePictures());
     2795                      assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii)));
     2796                  }
     2797              }
     2798             
     2799             
     2800          }
     2801          if(rpcSlice->getLayerId() == 0)
     2802          {
     2803              assert(rps->getNumberOfNegativePictures() <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1) );
     2804              assert(rps->getNumberOfPositivePictures() <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1) -rps->getNumberOfNegativePictures());
     2805              assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1));
     2806          }
     2807#endif
    26472808      if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
    26482809        || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
     
    26732834#if SVC_EXTENSION
    26742835    rpcSlice->setActiveNumILRRefIdx(0);
    2675 #if ILP_SSH_SIG
    2676 #if ILP_SSH_SIG_FIX
    26772836    if((rpcSlice->getLayerId() > 0) && !(rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag()) && (rpcSlice->getNumILRRefIdx() > 0) )
    2678 #else
    2679     if((rpcSlice->getLayerId() > 0) && rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag() && (rpcSlice->getNumILRRefIdx() > 0) )
    2680 #endif
    2681 #else
    2682     if((rpcSlice->getLayerId() > 0)  &&  (rpcSlice->getNumILRRefIdx() > 0) )
    2683 #endif
    26842837    {
    26852838      READ_FLAG(uiCode,"inter_layer_pred_enabled_flag");
     
    27202873#endif
    27212874          }
    2722 #if ILP_NUM_REF_CHK
     2875
    27232876          if( rpcSlice->getActiveNumILRRefIdx() == rpcSlice->getNumILRRefIdx() )
    27242877          {
     
    27302883          else
    27312884          {
    2732 #endif
    2733           for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ )
    2734           {
    2735             READ_CODE( numBits,uiCode,"inter_layer_pred_layer_idc[i]" );
    2736             rpcSlice->setInterLayerPredLayerIdc(uiCode,i);
     2885            for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ )
     2886            {
     2887              READ_CODE( numBits,uiCode,"inter_layer_pred_layer_idc[i]" );
     2888              rpcSlice->setInterLayerPredLayerIdc(uiCode,i);
     2889            }
    27372890          }
    2738 #if ILP_NUM_REF_CHK
    2739           }
    2740 #endif
    27412891        }
    27422892        else
     
    27602910      }
    27612911    }
    2762 #if ILP_SSH_SIG
    2763 #if ILP_SSH_SIG_FIX
    27642912    else if( rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag() == true &&  (rpcSlice->getLayerId() > 0 ))
    2765 #else
    2766     else if( rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag() == false )
    2767 #endif
    27682913    {
    27692914      rpcSlice->setInterLayerPredEnabledFlag(true);
     
    27992944#endif
    28002945    }
    2801 #endif
    2802 #endif
    28032946#if P0312_VERT_PHASE_ADJ
    28042947    for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ )
     
    28112954    }
    28122955#endif
     2956#endif //SVC_EXTENSION
    28132957
    28142958    if(sps->getUseSAO())
     
    29923136#if SVC_EXTENSION && REF_IDX_MFM
    29933137      // set motion mapping flag
    2994       rpcSlice->setMFMEnabledFlag( ( rpcSlice->getNumMotionPredRefLayers() > 0 && rpcSlice->getActiveNumILRRefIdx() ) ? true : false );
     3138      rpcSlice->setMFMEnabledFlag( ( rpcSlice->getNumMotionPredRefLayers() > 0 && rpcSlice->getActiveNumILRRefIdx() && !rpcSlice->isIntra() ) ? true : false );
    29953139#endif
    29963140      if ( rpcSlice->getSliceType() == B_SLICE )
     
    31323276
    31333277#if POC_RESET_IDC_SIGNALLING
    3134   Int sliceHederExtensionLength = 0;
     3278  Int sliceHeaderExtensionLength = 0;
    31353279  if(pps->getSliceHeaderExtensionPresentFlag())
    31363280  {
    3137     READ_UVLC( uiCode, "slice_header_extension_length"); sliceHederExtensionLength = uiCode;
     3281    READ_UVLC( uiCode, "slice_header_extension_length"); sliceHeaderExtensionLength = uiCode;
    31383282  }
    31393283  else
    31403284  {
    3141     sliceHederExtensionLength = 0;
     3285    sliceHeaderExtensionLength = 0;
    31423286  }
    31433287  UInt startBits = m_pcBitstream->getNumBitsRead();     // Start counter of # SH Extn bits
    3144   if( sliceHederExtensionLength > 0 )
     3288  if( sliceHeaderExtensionLength > 0 )
    31453289  {
    31463290    if( rpcSlice->getPPS()->getPocResetInfoPresentFlag() )
     
    31523296      rpcSlice->setPocResetIdc( 0 );
    31533297    }
     3298#if Q0142_POC_LSB_NOT_PRESENT
     3299    if ( rpcSlice->getVPS()->getPocLsbNotPresentFlag(rpcSlice->getLayerId()) && iPOClsb > 0 )
     3300    {
     3301      assert( rpcSlice->getPocResetIdc() != 2 );
     3302    }
     3303#endif
    31543304    if( rpcSlice->getPocResetIdc() > 0 )
    31553305    {
     
    31663316      READ_FLAG( uiCode,        "full_poc_reset_flag"); rpcSlice->setFullPocResetFlag((uiCode == 1) ? true : false);
    31673317      READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode,"poc_lsb_val"); rpcSlice->setPocLsbVal(uiCode);
     3318#if Q0142_POC_LSB_NOT_PRESENT
     3319      if ( rpcSlice->getVPS()->getPocLsbNotPresentFlag(rpcSlice->getLayerId()) && rpcSlice->getFullPocResetFlag() )
     3320      {
     3321        assert( rpcSlice->getPocLsbVal() == 0 );
     3322      }
     3323#endif
    31683324    }
    31693325
     
    31793335    else
    31803336    {
     3337#if POC_MSB_VAL_PRESENT_FLAG_SEM
     3338      if( sliceHeaderExtensionLength == 0 )
     3339      {
     3340        rpcSlice->setPocMsbValPresentFlag( false );
     3341      }
     3342      else if( rpcSlice->getPocMsbValRequiredFlag() )
     3343#else
    31813344      if( rpcSlice->getPocMsbValRequiredFlag() )
     3345#endif
    31823346      {
    31833347        rpcSlice->setPocMsbValPresentFlag( true );
     
    31893353    }
    31903354
     3355#if !POC_RESET_IDC_DECODER
    31913356    Int maxPocLsb  = 1 << rpcSlice->getSPS()->getBitsForPOC();
     3357#endif
    31923358    if( rpcSlice->getPocMsbValPresentFlag() )
    31933359    {
    31943360      READ_UVLC( uiCode,    "poc_msb_val");             rpcSlice->setPocMsbVal( uiCode );
     3361
     3362#if !POC_RESET_IDC_DECODER
    31953363      // Update POC of the slice based on this MSB val
    31963364      Int pocLsb     = rpcSlice->getPOC() % maxPocLsb;
     
    32003368    {
    32013369      rpcSlice->setPocMsbVal( rpcSlice->getPOC() / maxPocLsb );
     3370#endif
    32023371    }
    32033372
     
    32123381    while( counter )
    32133382    {
     3383#if Q0146_SSH_EXT_DATA_BIT
     3384      READ_FLAG( uiCode, "slice_segment_header_extension_data_bit" );
     3385#else
    32143386      READ_FLAG( uiCode, "slice_segment_header_extension_reserved_bit" ); assert( uiCode == 1 );
     3387#endif
    32153388      counter--;
    32163389    }
  • trunk/source/Lib/TLibDecoder/TDecCAVLC.h

    r713 r815  
    7575  Void  parseQtRootCbf      ( UInt uiAbsPartIdx, UInt& uiQtRootCbf );
    7676  Void  parseVPS            ( TComVPS* pcVPS );
    77 #if SPS_EXTENSION
    78 #if VPS_EXTNS
     77#if SVC_EXTENSION
    7978  Void  parseVPSExtension   ( TComVPS* pcVPS );
    8079  Void  defaultVPSExtension ( TComVPS* pcVPS );
    81 #endif
    82 
    83 #if VPS_VUI
    84   Void  parseVPSVUI   ( TComVPS* pcVPS );
    85   Void  defaultVPSVUI ( TComVPS* pcVPS );
    86 #endif
     80  Void  parseVPSVUI         ( TComVPS* pcVPS );
     81  Void  defaultVPSVUI       ( TComVPS* pcVPS );
    8782#if REPN_FORMAT_IN_VPS
    8883  Void  parseRepFormat      ( RepFormat *repFormat, RepFormat *repFormatPrev );
  • trunk/source/Lib/TLibDecoder/TDecTop.cpp

    r713 r815  
    8585  m_isNoOutputPriorPics = false;
    8686#endif
     87#if Q0177_EOS_CHECKS
     88  m_isLastNALWasEos = false;
     89#endif
    8790#if NO_CLRAS_OUTPUT_FLAG
    8891  m_noClrasOutputFlag          = false;
     
    9396  m_subDpbIdx = -1;
    9497#endif
     98#if POC_RESET_IDC_DECODER
     99  m_parseIdc = -1;
     100  m_lastPocPeriodId = -1;
     101  m_prevPicOrderCnt = 0;
     102#endif
    95103#if Q0048_CGS_3D_ASYMLUT
    96104  m_pColorMappedPic = NULL;
     
    104112TDecTop::~TDecTop()
    105113{
     114#if Q0078_ADD_LAYER_SETS
     115  for (Int psId = 0; psId < MAX_NUM_SPS; psId++)
     116  {
     117    TComSPS* sps = m_parameterSetManagerDecoder.getSPS(psId);
     118    if (sps != NULL)
     119    {
     120      // Remove parameter set from other layers to prevent multiple deletes of the same object
     121      for (Int lId = 0; lId < m_numLayer; lId++)
     122      {
     123        if (m_ppcTDecTop[lId] != this)
     124        {
     125          m_parameterSetManagerDecoder.removeSPS(psId);
     126        }
     127      }
     128    }
     129  }
     130  for (Int psId = 0; psId < MAX_NUM_PPS; psId++)
     131  {
     132    TComPPS* pps = m_parameterSetManagerDecoder.getPPS(psId);
     133    if (pps != NULL)
     134    {
     135      // Remove parameter set from other layers to prevent multiple deletes of the same object
     136      for (Int lId = 0; lId < m_numLayer; lId++)
     137      {
     138        if (m_ppcTDecTop[lId] != this)
     139        {
     140          m_parameterSetManagerDecoder.removePPS(psId);
     141        }
     142      }
     143    }
     144  }
     145#endif
    106146#if ENC_DEC_TRACE
    107147  fclose( g_hTrace );
     
    225265
    226266        m_cIlpPic[j] = new  TComPic;
     267
    227268#if AUXILIARY_PICTURES
    228269#if REPN_FORMAT_IN_VPS
    229 #if SVC_UPSAMPLING
    230270        m_cIlpPic[j]->create(picWidth, picHeight, slice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true);
    231271#else
    232         m_cIlpPic[j]->create(picWidth, picHeight, slice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, true);
    233 #endif
    234 #else
    235 #if SVC_UPSAMPLING
    236272        m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), pcSPS->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true);
    237 #else
    238         m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), pcSPS->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, true);
    239 #endif
    240273#endif
    241274#else
    242275#if REPN_FORMAT_IN_VPS
    243 #if SVC_UPSAMPLING
    244276        m_cIlpPic[j]->create(picWidth, picHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true);
    245277#else
    246         m_cIlpPic[j]->create(picWidth, picHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, true);
    247 #endif
    248 #else
    249 #if SVC_UPSAMPLING
    250278        m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true);
    251 #else
    252         m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, true);
    253 #endif
    254279#endif
    255280#endif
     
    393418
    394419          //only for scalable extension
    395 #if SCALABILITY_MASK_E0104
    396           assert( pcSlice->getVPS()->getScalabilityMask(2) == true );
    397 #else
    398           assert( pcSlice->getVPS()->getScalabilityMask(1) == true );
    399 #endif
    400         }
    401       }
    402     }
    403 #endif
    404    
     420          assert( pcSlice->getVPS()->getScalabilityMask( SCALABILITY_ID ) == true );
     421        }
     422      }
     423    }
     424
    405425#if AUXILIARY_PICTURES
    406426#if REPN_FORMAT_IN_VPS
    407 #if SVC_UPSAMPLING
    408427    rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), pcSlice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    409428                     conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true);
    410429#else
    411     rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), pcSlice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    412                      conformanceWindow, defaultDisplayWindow, numReorderPics, true);
    413 #endif
    414 #else
    415 #if SVC_UPSAMPLING
    416430    rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), pcSlice->getSPS()->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    417431                     conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true);
    418 #else
    419     rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), pcSlice->getSPS()->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    420                      conformanceWindow, defaultDisplayWindow, numReorderPics, true);
    421 #endif
    422432#endif
    423433#else
    424434#if REPN_FORMAT_IN_VPS
    425 #if SVC_UPSAMPLING
    426435    rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    427436                     conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true);
    428437#else
    429     rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    430                      conformanceWindow, defaultDisplayWindow, numReorderPics, true);
    431 #endif
    432 #else
    433 #if SVC_UPSAMPLING
    434438    rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    435439                     conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true);
    436 #else
     440#endif
     441#endif
     442
     443#else //SVC_EXTENSION
    437444    rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    438445                     conformanceWindow, defaultDisplayWindow, numReorderPics, true);
    439 #endif
    440 #endif
    441 #endif
     446#endif //SVC_EXTENSION
     447   
    442448    m_cListPic.pushBack( rpcPic );
    443449   
     
    478484  rpcPic->destroy();
    479485
     486#if SVC_EXTENSION
    480487#if AUXILIARY_PICTURES
    481488#if REPN_FORMAT_IN_VPS
    482 #if SVC_UPSAMPLING
    483489  rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), pcSlice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    484490                   conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true);
    485 
    486 #else
    487   rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), pcSlice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    488                    conformanceWindow, defaultDisplayWindow, numReorderPics, true);
    489 #endif
    490 #else
    491 #if SVC_UPSAMPLING
     491#else
    492492  rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), pcSlice->getSPS()->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    493493                   conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true);
    494 
    495 #else
    496   rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), pcSlice->getSPS()->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    497                    conformanceWindow, defaultDisplayWindow, numReorderPics, true);
    498 #endif
    499494#endif
    500495#else
    501496#if REPN_FORMAT_IN_VPS
    502 #if SVC_UPSAMPLING
    503497  rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    504498                   conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true);
    505499
    506500#else
    507   rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    508                    conformanceWindow, defaultDisplayWindow, numReorderPics, true);
    509 #endif
    510 #else
    511 #if SVC_UPSAMPLING
    512501  rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    513502                   conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true);
    514 
    515 #else
     503#endif
     504#endif
     505#else  //SVC_EXTENSION
    516506  rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    517507                   conformanceWindow, defaultDisplayWindow, numReorderPics, true);
    518 #endif
    519 #endif
    520 #endif
     508#endif //SVC_EXTENSION
    521509}
    522510
     
    793781
    794782#if AUXILIARY_PICTURES
    795 #if SVC_UPSAMPLING
    796783#if AVC_SYNTAX
    797784      pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), repFormat->getChromaFormatVpsIdc(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, activeSPS, true);
     
    800787#endif
    801788#else
    802       pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), repFormat->getChromaFormatVpsIdc(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, true);
    803 #endif
    804 #else
    805 #if SVC_UPSAMPLING
    806789#if AVC_SYNTAX
    807790      pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, activeSPS, true);
    808791#else
    809792      pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, NULL, true);
    810 #endif
    811 #else
    812       pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), onformanceWindow, defaultDisplayWindow, numReorderPics, true);
    813793#endif
    814794#endif
     
    846826
    847827    // When not present sps_temporal_id_nesting_flag is inferred to be equal to vps_temporal_id_nesting_flag
     828#if Q0177_SPS_TEMP_NESTING_FIX
     829    sps->setTemporalIdNestingFlag( (sps->getMaxTLayers() > 1) ? activeVPS->getTemporalNestingFlag() : true );
     830#else
    848831    sps->setTemporalIdNestingFlag( activeVPS->getTemporalNestingFlag() );
     832#endif
    849833
    850834    // When sps_max_dec_pic_buffering_minus1[ i ] is not present for i in the range of 0 to sps_max_sub_layers_minus1, inclusive, due to nuh_layer_id being greater than 0,
     
    854838      // to avoid compiler warning "array subscript is above array bounds"
    855839      assert( i < MAX_TLAYER );
    856 
     840#if LAYER_DECPICBUFF_PARAM && RESOLUTION_BASED_DPB
     841      sps->setMaxDecPicBuffering( activeVPS->getMaxVpsLayerDecPicBuffMinus1( getCommonDecoderParams()->getTargetOutputLayerSetIdx(), sps->getLayerId(), i) + 1, i);
     842#else
    857843      sps->setMaxDecPicBuffering( activeVPS->getMaxVpsDecPicBufferingMinus1( getCommonDecoderParams()->getTargetOutputLayerSetIdx(), sps->getLayerId(), i) + 1, i);
     844#endif
    858845    }
    859846  }
     
    11221109  }
    11231110#endif
     1111#if POC_RESET_IDC_DECODER
     1112  if( m_parseIdc != -1 ) // Second pass for a POC resetting picture
     1113  {
     1114    m_parseIdc++; // Proceed to POC decoding and RPS derivation
     1115  }
     1116 
     1117  if( m_parseIdc == 2 )
     1118  {
     1119    bNewPOC = false;
     1120  }
     1121
     1122  if( (bNewPOC || m_layerId!=m_uiPrevLayerId) && (m_parseIdc == -1) ) // Will be true at the first pass
     1123  {
     1124  //if (bNewPOC || m_layerId!=m_uiPrevLayerId)
     1125  // Check if new reset period has started - this is needed just so that the SHM decoder which calls slice header decoding twice
     1126  // does not invoke the output twice
     1127  //if( m_lastPocPeriodId[m_apcSlicePilot->getLayerId()] == m_apcSlicePilot->getPocResetPeriodId() )
     1128    // Update CurrAU marking
     1129    if(( m_layerId < m_uiPrevLayerId) ||( ( m_layerId == m_uiPrevLayerId) && bNewPOC)) // Decoding a lower layer than or same layer as previous - mark all earlier pictures as not in current AU
     1130    {
     1131      markAllPicsAsNoCurrAu();
     1132    }
     1133
     1134    if( m_apcSlicePilot->getPocResetIdc() && m_apcSlicePilot->getSliceIdx() == 0 )
     1135    {
     1136      Int pocResetPeriodId = m_apcSlicePilot->getPocResetPeriodId();
     1137      if ( m_apcSlicePilot->getPocResetIdc() == 1 || m_apcSlicePilot->getPocResetIdc() == 2 ||
     1138        ( m_apcSlicePilot->getPocResetIdc() == 3 && pocResetPeriodId != getLastPocPeriodId() ) )
     1139      {
     1140        setLastPocPeriodId(pocResetPeriodId);
     1141        m_parseIdc = 0;
     1142      }
     1143    }
     1144    else
     1145    {
     1146      m_parseIdc = 3; // Proceed to decoding POC and RPS
     1147    } 
     1148  }
     1149#endif
    11241150
    11251151#if ALIGNED_BUMPING
     1152#if POC_RESET_IDC_DECODER
     1153  //if(  (bNewPOC || m_layerId != m_uiPrevLayerId) && ( m_parseIdc != 1) )
     1154  if( m_parseIdc == 1 )
     1155  {
     1156    // Invoke output of pictures if the current picture is a POC reset picture
     1157    bNewPOC = true;
     1158    /* Include reset of all POCs in the layer */
     1159
     1160  // This operation would do the following:
     1161  // 1. Update the other picture in the DPB. This should be done only for the first slice of the picture.
     1162  // 2. Update the value of m_pocCRA.
     1163  // 3. Reset the POC values at the decoder for the current picture to be zero - will be done later
     1164  // 4. update value of POCLastDisplay
     1165     
     1166  //Do the reset stuff here
     1167    Int maxPocLsb = 1 << m_apcSlicePilot->getSPS()->getBitsForPOC();
     1168    Int pocLsbVal;
     1169    if( m_apcSlicePilot->getPocResetIdc() == 3 )
     1170    {
     1171      pocLsbVal = m_apcSlicePilot->getPocLsbVal() ;
     1172    }
     1173    else
     1174    {
     1175      pocLsbVal = (m_apcSlicePilot->getPOC() % maxPocLsb);
     1176    }
     1177
     1178    Int pocMsbDelta = 0;
     1179    if ( m_apcSlicePilot->getPocMsbValPresentFlag() )
     1180    {
     1181      pocMsbDelta = m_apcSlicePilot->getPocMsbVal() * maxPocLsb;
     1182    }
     1183    else
     1184    {
     1185      //This MSB derivation can be made into one function. Item to do next.
     1186      Int prevPoc     = this->getPrevPicOrderCnt();
     1187      Int prevPocLsb  = prevPoc & (maxPocLsb - 1);
     1188      Int prevPocMsb  = prevPoc - prevPocLsb;
     1189
     1190      pocMsbDelta = m_apcSlicePilot->getCurrMsb( pocLsbVal, prevPocLsb, prevPocMsb, maxPocLsb );
     1191    }
     1192
     1193    Int pocLsbDelta;
     1194    if( m_apcSlicePilot->getPocResetIdc() == 2 ||  ( m_apcSlicePilot->getPocResetIdc() == 3 && m_apcSlicePilot->getFullPocResetFlag() ))
     1195    {
     1196      pocLsbDelta = pocLsbVal;
     1197    }
     1198    else
     1199    {
     1200      pocLsbDelta = 0;
     1201    }
     1202
     1203    Int deltaPocVal  =  pocMsbDelta + pocLsbDelta;
     1204
     1205    //Reset all POC for DPB -> basically do it for each slice in the picutre
     1206    TComList<TComPic*>::iterator  iterPic = m_cListPic.begin(); 
     1207
     1208    // Iterate through all picture in DPB
     1209    while( iterPic != m_cListPic.end() )
     1210    {
     1211      TComPic *dpbPic = *iterPic;
     1212      // Check if the picture pointed to by iterPic is either used for reference or
     1213      // needed for output, are in the same layer, and not the current picture.
     1214      if( /*  ( ( dpbPic->getSlice(0)->isReferenced() ) || ( dpbPic->getOutputMark() ) )
     1215          &&*/ ( dpbPic->getLayerId() == m_apcSlicePilot->getLayerId() )
     1216            && ( dpbPic->getReconMark() ) && ( dpbPic->getPicSym()->getSlice(0)->getPicOutputFlag() ))
     1217      {
     1218        for(Int i = dpbPic->getNumAllocatedSlice()-1; i >= 0; i--)
     1219        {
     1220
     1221          TComSlice *slice = dpbPic->getSlice(i);
     1222          TComReferencePictureSet *rps = slice->getRPS();
     1223          slice->setPOC( slice->getPOC() - deltaPocVal );
     1224
     1225          // Also adjust the POC value stored in the RPS of each such slice
     1226          for(Int j = rps->getNumberOfPictures(); j >= 0; j--)
     1227          {
     1228            rps->setPOC( j, rps->getPOC(j) - deltaPocVal );
     1229          }
     1230          // Also adjust the value of refPOC
     1231          for(Int k = 0; k < 2; k++)  // For List 0 and List 1
     1232          {
     1233            RefPicList list = (k == 1) ? REF_PIC_LIST_1 : REF_PIC_LIST_0;
     1234            for(Int j = 0; j < slice->getNumRefIdx(list); j++)
     1235            {
     1236              slice->setRefPOC( slice->getRefPOC(list, j) - deltaPocVal, list, j);
     1237            }
     1238          }
     1239        }
     1240      }
     1241      iterPic++;
     1242    }
     1243    // Update the value of pocCRA
     1244    m_pocCRA -= deltaPocVal;
     1245
     1246    // Update value of POCLastDisplay
     1247    iPOCLastDisplay -= deltaPocVal;
     1248  }
     1249  Int maxPocLsb = 1 << m_apcSlicePilot->getSPS()->getBitsForPOC();
     1250  Int slicePicOrderCntLsb = m_apcSlicePilot->getPicOrderCntLsb();
     1251
     1252  if( m_parseIdc == 1 || m_parseIdc == 2 ) // TODO This should be replaced by pocResettingFlag.
     1253  {
     1254    // Set poc for current slice
     1255    if( m_apcSlicePilot->getPocResetIdc() == 1 )
     1256    {       
     1257      m_apcSlicePilot->setPOC( slicePicOrderCntLsb );
     1258    }
     1259    else if( m_apcSlicePilot->getPocResetIdc() == 2 )
     1260    {
     1261      m_apcSlicePilot->setPOC( 0 );
     1262    }
     1263    else
     1264    {
     1265      Int picOrderCntMsb = m_apcSlicePilot->getCurrMsb( slicePicOrderCntLsb, m_apcSlicePilot->getFullPocResetFlag() ? 0 : m_apcSlicePilot->getPocLsbVal(), 0 , maxPocLsb );
     1266      m_apcSlicePilot->setPOC( picOrderCntMsb + slicePicOrderCntLsb );
     1267    }
     1268  }
     1269  else if (m_parseIdc == 3)
     1270  {
     1271    Int picOrderCntMsb = 0;
     1272    if( m_apcSlicePilot->getPocMsbValPresentFlag() )
     1273    {
     1274      picOrderCntMsb = m_apcSlicePilot->getPocMsbVal() * maxPocLsb;
     1275    }
     1276    else if( m_apcSlicePilot->getIdrPicFlag() )
     1277    {
     1278      picOrderCntMsb = 0;
     1279    }
     1280    else
     1281    {
     1282      Int prevPicOrderCntLsb = this->getPrevPicOrderCnt() & ( maxPocLsb - 1);
     1283      Int prevPicOrderCntMsb  = this->getPrevPicOrderCnt() - prevPicOrderCntLsb;
     1284      picOrderCntMsb = m_apcSlicePilot->getCurrMsb(slicePicOrderCntLsb, prevPicOrderCntLsb, prevPicOrderCntMsb, maxPocLsb );
     1285    }
     1286    m_apcSlicePilot->setPOC( picOrderCntMsb + slicePicOrderCntLsb );
     1287  }
     1288
     1289  if( m_parseIdc == 1 || m_parseIdc == 3)
     1290  {
     1291    // Adjust prevPicOrderCnt
     1292    if(    !m_apcSlicePilot->getRaslPicFlag()
     1293        && !m_apcSlicePilot->getRadlPicFlag()
     1294        && (m_apcSlicePilot->getNalUnitType() % 2 == 1)
     1295        && ( nalu.m_temporalId == 0 )
     1296        && !m_apcSlicePilot->getDiscardableFlag() )
     1297    {
     1298      this->setPrevPicOrderCnt( m_apcSlicePilot->getPOC() );
     1299    }
     1300    else if ( m_apcSlicePilot->getPocResetIdc() == 3 )
     1301    {
     1302      this->setPrevPicOrderCnt( m_apcSlicePilot->getFullPocResetFlag()
     1303                                            ? 0 : m_apcSlicePilot->getPocLsbVal() );
     1304    }
     1305#else
    11261306  if (bNewPOC || m_layerId!=m_uiPrevLayerId)
    11271307  {
     1308#endif
    11281309    m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS());
    11291310  }
    11301311#endif
     1312#if POC_RESET_IDC_DECODER
     1313  if (m_apcSlicePilot->isNextSlice() && (bNewPOC || m_layerId!=m_uiPrevLayerId || m_parseIdc == 1) && !m_bFirstSliceInSequence )
     1314#else
    11311315  if (m_apcSlicePilot->isNextSlice() && (bNewPOC || m_layerId!=m_uiPrevLayerId) && !m_bFirstSliceInSequence )
     1316#endif
    11321317  {
    11331318    m_prevPOC = m_apcSlicePilot->getPOC();
     
    11361321    return true;
    11371322  }
    1138 #else
    1139   //we should only get a different poc for a new picture (with CTU address==0)
    1140   if (m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence && (m_apcSlicePilot->getSliceCurStartCUAddr()!=0))
    1141   {
    1142     printf ("Warning, the first slice of a picture might have been lost!\n");
    1143   }
    1144   // exit when a new picture is found
    1145   if (m_apcSlicePilot->isNextSlice() && (m_apcSlicePilot->getSliceCurStartCUAddr() == 0 && !m_bFirstSliceInPicture) && !m_bFirstSliceInSequence )
    1146   {
    1147     if (m_prevPOC >= m_pocRandomAccess)
    1148     {
    1149       m_prevPOC = m_apcSlicePilot->getPOC();
    1150       return true;
    1151     }
    1152     m_prevPOC = m_apcSlicePilot->getPOC();
    1153   }
    1154 #endif
     1323
     1324#if POC_RESET_IDC_DECODER
     1325  m_parseIdc = -1;
     1326#endif
     1327
    11551328  // actual decoding starts here
    1156   xActivateParameterSets();
    1157 #if !O0223_O0139_IRAP_ALIGN_NO_CONTRAINTS && N0147_IRAP_ALIGN_FLAG
    1158   //Note setting O0223_O0139_IRAP_ALIGN_NO_CONTRAINTS to 0 may cause decoder to crash.
    1159   //When cross_layer_irap_aligned_flag is equal to 0, num_extra_slice_header_bits >=1
    1160   if(!m_apcSlicePilot->getVPS()->getCrossLayerIrapAlignFlag() )
    1161   {
    1162     assert( m_apcSlicePilot->getPPS()->getNumExtraSliceHeaderBits() > 0);
    1163   }
    1164   //When cross_layer_irap_aligned_flag is equal to 1, the value of poc_reset_flag shall be equal to 0 
    1165   if( m_apcSlicePilot->getVPS()->getCrossLayerIrapAlignFlag() )
    1166   {
    1167     assert( m_apcSlicePilot->getPocResetFlag() == 0);
    1168   }
    1169 #endif
     1329    xActivateParameterSets();
     1330
    11701331#if REPN_FORMAT_IN_VPS
    11711332  // Initialize ILRP if needed, only for the current layer 
     
    11771338  {
    11781339    m_prevPOC = m_apcSlicePilot->getPOC();
    1179 #if SVC_EXTENSION
    11801340    curLayerId = m_layerId;
    11811341    m_uiPrevLayerId = m_layerId;
    1182 #endif
    11831342  }
    11841343  m_bFirstSliceInSequence = false;
     
    12491408  }
    12501409#endif
    1251 #if ALIGN_TSA_STSA_PICS
     1410  // Alignment of TSA and STSA pictures across AU
     1411#if !Q0108_TSA_STSA
    12521412  if( m_apcSlicePilot->getLayerId() > 0 )
    12531413  {
     
    12871447  }
    12881448#endif
     1449
     1450#else //SVC_EXTENSION
     1451  //we should only get a different poc for a new picture (with CTU address==0)
     1452  if (m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence && (m_apcSlicePilot->getSliceCurStartCUAddr()!=0))
     1453  {
     1454    printf ("Warning, the first slice of a picture might have been lost!\n");
     1455  }
     1456  // exit when a new picture is found
     1457  if (m_apcSlicePilot->isNextSlice() && (m_apcSlicePilot->getSliceCurStartCUAddr() == 0 && !m_bFirstSliceInPicture) && !m_bFirstSliceInSequence )
     1458  {
     1459    if (m_prevPOC >= m_pocRandomAccess)
     1460    {
     1461      m_prevPOC = m_apcSlicePilot->getPOC();
     1462      return true;
     1463    }
     1464    m_prevPOC = m_apcSlicePilot->getPOC();
     1465  }
     1466
     1467  // actual decoding starts here
     1468  xActivateParameterSets();
     1469
     1470  if (m_apcSlicePilot->isNextSlice())
     1471  {
     1472    m_prevPOC = m_apcSlicePilot->getPOC();
     1473  }
     1474  m_bFirstSliceInSequence = false;
     1475#endif //SVC_EXTENSION
    12891476  //detect lost reference picture and insert copy of earlier frame.
    12901477  Int lostPoc;
     
    13011488      pBLPic->getSlice(0)->setReferenced(true);
    13021489      fstream* pFile  = m_ppcTDecTop[0]->getBLReconFile();
    1303       UInt uiWidth    = pBLPic->getPicYuvRec()->getWidth();
    1304       UInt uiHeight   = pBLPic->getPicYuvRec()->getHeight();
    13051490
    13061491      if( pFile->good() )
    13071492      {
     1493        Bool is16bit  = g_bitDepthYLayer[0] > 8 || g_bitDepthCLayer[0] > 8;
     1494        UInt uiWidth  = pBLPic->getPicYuvRec()->getWidth();
     1495        UInt uiHeight = pBLPic->getPicYuvRec()->getHeight();
     1496
     1497        Int len = uiWidth * (is16bit ? 2 : 1);
     1498        UChar *buf = new UChar[len];
     1499
    13081500        UInt64 uiPos = (UInt64) m_apcSlicePilot->getPOC() * uiWidth * uiHeight * 3 / 2;
     1501        if( is16bit )
     1502        {
     1503            uiPos <<= 1;
     1504        }
    13091505
    13101506        pFile->seekg((UInt)uiPos, ios::beg );
    13111507
     1508        // read Y component
    13121509        Pel* pPel = pBLPic->getPicYuvRec()->getLumaAddr();
    13131510        UInt uiStride = pBLPic->getPicYuvRec()->getStride();
    13141511        for( Int i = 0; i < uiHeight; i++ )
    13151512        {
    1316           for( Int j = 0; j < uiWidth; j++ )
     1513          pFile->read(reinterpret_cast<Char*>(buf), len);
     1514
     1515          if( !is16bit )
    13171516          {
    1318             pPel[j] = pFile->get();
     1517            for (Int x = 0; x < uiWidth; x++)
     1518            {
     1519              pPel[x] = buf[x];
     1520            }
    13191521          }
     1522          else
     1523          {
     1524            for (Int x = 0; x < uiWidth; x++)
     1525            {
     1526              pPel[x] = (buf[2*x+1] << 8) | buf[2*x];
     1527            }
     1528          }
     1529     
    13201530          pPel += uiStride;
    13211531        }
    13221532
     1533        len >>= 1;
     1534        uiWidth >>= 1;
     1535        uiHeight >>= 1;
     1536
     1537        // read Cb component
    13231538        pPel = pBLPic->getPicYuvRec()->getCbAddr();
    13241539        uiStride = pBLPic->getPicYuvRec()->getCStride();
    1325         for( Int i = 0; i < uiHeight/2; i++ )
    1326         {
    1327           for( Int j = 0; j < uiWidth/2; j++ )
     1540        for( Int i = 0; i < uiHeight; i++ )
     1541        {
     1542          pFile->read(reinterpret_cast<Char*>(buf), len);
     1543
     1544          if( !is16bit )
    13281545          {
    1329             pPel[j] = pFile->get();
     1546            for( Int x = 0; x < uiWidth; x++ )
     1547            {
     1548              pPel[x] = buf[x];
     1549            }
    13301550          }
     1551          else
     1552          {
     1553            for( Int x = 0; x < uiWidth; x++ )
     1554            {
     1555              pPel[x] = (buf[2*x+1] << 8) | buf[2*x];
     1556            }
     1557          }
     1558     
    13311559          pPel += uiStride;
    13321560        }
    13331561
     1562        // read Cr component
    13341563        pPel = pBLPic->getPicYuvRec()->getCrAddr();
    13351564        uiStride = pBLPic->getPicYuvRec()->getCStride();
    1336         for( Int i = 0; i < uiHeight/2; i++ )
    1337         {
    1338           for( Int j = 0; j < uiWidth/2; j++ )
     1565        for( Int i = 0; i < uiHeight; i++ )
     1566        {
     1567          pFile->read(reinterpret_cast<Char*>(buf), len);
     1568
     1569          if( !is16bit )
    13391570          {
    1340             pPel[j] = pFile->get();
     1571            for( Int x = 0; x < uiWidth; x++ )
     1572            {
     1573              pPel[x] = buf[x];
     1574            }
    13411575          }
     1576          else
     1577          {
     1578            for( Int x = 0; x < uiWidth; x++ )
     1579            {
     1580              pPel[x] = (buf[2*x+1] << 8) | buf[2*x];
     1581            }
     1582          }
     1583     
    13421584          pPel += uiStride;
    13431585        }
     1586
     1587        delete[] buf;
    13441588      }
    13451589    }
     
    13651609    //  Get a new picture buffer
    13661610    xGetNewPicBuffer (m_apcSlicePilot, pcPic);
     1611
     1612#if POC_RESET_IDC_DECODER
     1613  pcPic->setCurrAuFlag( true );
     1614#endif
    13671615
    13681616    Bool isField = false;
     
    15431791      {
    15441792        UInt refLayerIdc = i;
     1793        UInt refLayerId = pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc);
    15451794#if AVC_BASE
    1546         if( pcSlice->getVPS()->getRefLayerId( m_layerId, refLayerIdc ) == 0 && m_parameterSetManagerDecoder.getActiveVPS()->getAvcBaseLayerFlag() )
     1795        if( refLayerId == 0 && m_parameterSetManagerDecoder.getActiveVPS()->getAvcBaseLayerFlag() )
    15471796        {         
    15481797          TComPic* pic = *m_ppcTDecTop[0]->getListPic()->begin();
     
    15931842
    15941843#if O0098_SCALED_REF_LAYER_ID
    1595         const Window &scalEL = pcSlice->getSPS()->getScaledRefLayerWindowForLayer(pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc));
     1844        const Window &scalEL = pcSlice->getSPS()->getScaledRefLayerWindowForLayer(refLayerId);
    15961845#else
    15971846        const Window &scalEL = pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc);
     
    16271876        }
    16281877#endif
    1629 #if SVC_UPSAMPLING
     1878#if SVC_EXTENSION
    16301879        if( pcPic->isSpatialEnhLayer(refLayerIdc) )
    1631         {   
     1880        {
     1881          // check for the sample prediction picture type
     1882          if( m_ppcTDecTop[m_layerId]->getSamplePredEnabledFlag(refLayerId) )
     1883          {
    16321884#if O0215_PHASE_ALIGNMENT
    16331885#if O0194_JOINT_US_BITSHIFT
    16341886#if Q0048_CGS_3D_ASYMLUT
    1635           m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() );
    1636 #else
    1637           m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() );
     1887            m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() );
     1888#else
     1889            m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() );
    16381890#endif
    16391891#else
    16401892#if Q0048_CGS_3D_ASYMLUT
    1641           m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc), pcSlice->getVPS()->getPhaseAlignFlag() );
    1642 #else
    1643           m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() );
     1893            m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc), pcSlice->getVPS()->getPhaseAlignFlag() );
     1894#else
     1895            m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() );
    16441896#endif
    16451897#endif
     
    16471899#if O0194_JOINT_US_BITSHIFT
    16481900#if Q0048_CGS_3D_ASYMLUT
    1649           m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL );
    1650 #else
    1651           m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL );
     1901            m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL );
     1902#else
     1903            m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL );
    16521904#endif
    16531905#else
    16541906#if Q0048_CGS_3D_ASYMLUT
    1655           m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL );
    1656 #else
    1657           m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL );
    1658 #endif
    1659 #endif
    1660 #endif
     1907            m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL );
     1908#else
     1909            m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL );
     1910#endif
     1911#endif
     1912#endif
     1913          }
    16611914        }
    16621915        else
     
    16651918        }
    16661919        pcSlice->setFullPelBaseRec ( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc) );
    1667 #endif
     1920#endif //SVC_EXTENSION
    16681921      }
    16691922    }
     
    17321985    if( pcSlice->getMFMEnabledFlag() )
    17331986    {
    1734       Int refLayerId = pcSlice->getRefPic( pcSlice->getSliceType() == B_SLICE ? ( RefPicList )( 1 - pcSlice->getColFromL0Flag() ) : REF_PIC_LIST_0 , pcSlice->getColRefIdx() )->getLayerId();
     1987      TComPic* refPic = pcSlice->getRefPic( pcSlice->getSliceType() == B_SLICE ? ( RefPicList )( 1 - pcSlice->getColFromL0Flag() ) : REF_PIC_LIST_0 , pcSlice->getColRefIdx() );
     1988
     1989      assert( refPic );
     1990
     1991      Int refLayerId = refPic->getLayerId();
     1992
    17351993      if( refLayerId != pcSlice->getLayerId() )
    17361994      {
     
    17422000#endif
    17432001   
    1744 #if N0147_IRAP_ALIGN_FLAG
    17452002    if( m_layerId > 0 && pcSlice->getVPS()->getCrossLayerIrapAlignFlag() )
    17462003    {
     
    17582015      }
    17592016    }
    1760 #endif
     2017
     2018    if( m_layerId > 0 && !pcSlice->isIntra() && pcSlice->getEnableTMVPFlag() )
     2019    {
     2020      TComPic* refPic = pcSlice->getRefPic(RefPicList(1 - pcSlice->getColFromL0Flag()), pcSlice->getColRefIdx());
     2021
     2022      assert( refPic );
     2023
     2024      // It is a requirement of bitstream conformance when the collocated picture, used for temporal motion vector prediction, is an inter-layer reference picture,
     2025      // VpsInterLayerMotionPredictionEnabled[ LayerIdxInVps[ currLayerId ] ][ LayerIdxInVps[ rLId ] ] shall be equal to 1, where rLId is set equal to nuh_layer_id of the inter-layer picture.
     2026      if( refPic->isILR(pcSlice->getLayerId()) )
     2027      {
     2028        assert( m_ppcTDecTop[m_layerId]->getMotionPredEnabledFlag(refPic->getLayerId()) );
     2029      }
     2030    }
    17612031#endif //SVC_EXTENSION
    17622032   
     
    18562126#endif
    18572127  m_parameterSetManagerDecoder.storePrefetchedSPS(sps);
     2128#if Q0078_ADD_LAYER_SETS
     2129  // Store SPS for all layers
     2130  for (Int lId = 0; lId < m_numLayer; lId++)
     2131  {
     2132    if (m_ppcTDecTop[lId] != this)
     2133    {
     2134      m_ppcTDecTop[lId]->getParameterSetManager()->storePrefetchedSPS(sps);
     2135    }
     2136  }
     2137#endif
    18582138#if !REPN_FORMAT_IN_VPS   // ILRP can only be initialized at activation 
    18592139  if(m_numLayer>0)
     
    18862166    );
    18872167  m_parameterSetManagerDecoder.storePrefetchedPPS( pps );
     2168#if Q0078_ADD_LAYER_SETS
     2169  // Store PPS for all layers
     2170  for (Int lId = 0; lId < m_numLayer; lId++)
     2171  {
     2172    if (m_ppcTDecTop[lId] != this)
     2173    {
     2174      m_ppcTDecTop[lId]->getParameterSetManager()->storePrefetchedPPS(pps);
     2175    }
     2176  }
     2177#endif
    18882178
    18892179  if( pps->getDependentSliceSegmentsEnabledFlag() )
     
    19062196  if(nalUnitType == NAL_UNIT_SUFFIX_SEI)
    19072197  {
    1908 #if RANDOM_ACCESS_SEI_FIX
    19092198    if (m_prevSliceSkipped) // No need to decode SEI messages of a skipped access unit
    19102199    {
    19112200      return;
    19122201    }
    1913 #endif
    19142202#if LAYERS_NOT_PRESENT_SEI
    19152203    m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS() );
     
    19912279  {
    19922280    case NAL_UNIT_VPS:
    1993 #if VPS_NUH_LAYER_ID
     2281#if SVC_EXTENSION
    19942282      assert( nalu.m_layerId == 0 ); // Non-conforming bitstream. The value of nuh_layer_id of VPS NAL unit shall be equal to 0.
    19952283#endif
    19962284      xDecodeVPS();
     2285#if Q0177_EOS_CHECKS
     2286      m_isLastNALWasEos = false;
     2287#endif
    19972288#if AVC_BASE
    19982289      if( m_parameterSetManagerDecoder.getPrefetchedVPS(0)->getAvcBaseLayerFlag() )
     
    20332324    case NAL_UNIT_PREFIX_SEI:
    20342325    case NAL_UNIT_SUFFIX_SEI:
     2326#if Q0177_EOS_CHECKS
     2327      if ( nalu.m_nalUnitType == NAL_UNIT_SUFFIX_SEI )
     2328      {
     2329        assert( m_isLastNALWasEos == false );
     2330      }
     2331#endif
    20352332      xDecodeSEI( nalu.m_Bitstream, nalu.m_nalUnitType );
    20362333      return false;
     
    20522349    case NAL_UNIT_CODED_SLICE_RASL_N:
    20532350    case NAL_UNIT_CODED_SLICE_RASL_R:
     2351#if Q0177_EOS_CHECKS
     2352      if (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_N ||
     2353          nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TSA_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TSA_N ||
     2354          nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_STSA_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_STSA_N ||
     2355          nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N ||
     2356          nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N )
     2357      {
     2358        assert( m_isLastNALWasEos == false );
     2359      }
     2360      else
     2361      {
     2362        m_isLastNALWasEos = false;
     2363      }
     2364#endif
    20542365#if SVC_EXTENSION
    20552366      return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay, curLayerId, bNewPOC);
     
    20602371     
    20612372    case NAL_UNIT_EOS:
     2373#if Q0177_EOS_CHECKS
     2374      assert( m_isLastNALWasEos == false );
     2375      //Check layer id of the nalu. if it is not 0, give a warning message and just return without doing anything.
     2376      if (nalu.m_layerId > 0)
     2377      {
     2378        printf( "\nThis bitstream has EOS with non-zero layer id.\n" );
     2379        return false;
     2380      }
     2381      m_isLastNALWasEos = true;
     2382#endif
    20622383      m_associatedIRAPType = NAL_UNIT_INVALID;
    20632384      m_pocCRA = 0;
     
    20852406     
    20862407    case NAL_UNIT_FILLER_DATA:
     2408#if Q0177_EOS_CHECKS
     2409      assert( m_isLastNALWasEos == false );
     2410#endif
    20872411      return false;
    20882412     
     
    22562580    }
    22572581  }
    2258   for ( Int i = 1, mIdx = 0, sIdx = 0; i < m_numLayer; i++ )
    2259   {
     2582  for( Int i = 1; i < m_numLayer; i++ )
     2583  {
     2584    Int mIdx = 0, sIdx = 0;
    22602585    Int iNuhLId = vps->getLayerIdInNuh(i);
    22612586    TDecTop *decTop = (TDecTop *)getLayerDec(iNuhLId);
     
    23922717}
    23932718#endif
    2394 
     2719#if POC_RESET_IDC_DECODER
     2720Void TDecTop::markAllPicsAsNoCurrAu()
     2721{
     2722  for(Int i = 0; i < MAX_LAYERS; i++)
     2723  {
     2724    TComList<TComPic*>* listPic = this->getLayerDec(i)->getListPic();
     2725    TComList<TComPic*>::iterator  iterPic = listPic->begin();
     2726    while ( iterPic != listPic->end() )
     2727    {
     2728      TComPic *pcPic = *(iterPic);
     2729      pcPic->setCurrAuFlag( false );
     2730      iterPic++;
     2731    }
     2732  }
     2733}
     2734#endif
    23952735#if Q0048_CGS_3D_ASYMLUT
    23962736Void TDecTop::initAsymLut(TComSlice *pcSlice)
  • trunk/source/Lib/TLibDecoder/TDecTop.h

    r713 r815  
    162162  Bool                    m_craNoRaslOutputFlag;    //value of variable NoRaslOutputFlag of the last CRA pic
    163163#endif
     164#if Q0177_EOS_CHECKS
     165  Bool                    m_isLastNALWasEos;
     166#endif
    164167
    165168#if SVC_EXTENSION
     
    201204  Bool                    m_firstPicInLayerDecodedFlag;
    202205#endif
     206#if POC_RESET_IDC_DECODER
     207  Int                     m_parseIdc;
     208  Int                     m_lastPocPeriodId;
     209  Int                     m_prevPicOrderCnt;
     210#endif
    203211#if RESOLUTION_BASED_DPB
    204212  Int                     m_subDpbIdx;     // Index to the sub-DPB that the layer belongs to.
     
    241249#if EARLY_REF_PIC_MARKING
    242250  Void earlyPicMarking(Int maxTemporalLayer, std::vector<Int>& targetDecLayerIdList);
     251#endif
     252#if POC_RESET_IDC_DECODER
     253  Int getParseIdc() { return m_parseIdc;}
     254  Void        setParseIdc(Int x) { m_parseIdc = x;}
     255  Void        markAllPicsAsNoCurrAu();
     256
     257  Int   getLastPocPeriodId() { return m_lastPocPeriodId; }
     258  Void  setLastPocPeriodId(Int x)    { m_lastPocPeriodId = x; }
     259
     260  Int   getPrevPicOrderCnt() { return m_prevPicOrderCnt; }
     261  Void  setPrevPicOrderCnt(Int const x) { m_prevPicOrderCnt = x; }
    243262#endif
    244263  UInt      getLayerId            () { return m_layerId;              }
  • trunk/source/Lib/TLibEncoder/SEIwrite.cpp

    r713 r815  
    8787    fprintf( g_hTrace, "=========== Tone Mapping Info SEI message ===========\n");
    8888    break;
     89#if P0050_KNEE_FUNCTION_SEI
     90  case SEI::KNEE_FUNCTION_INFO:
     91    fprintf( g_hTrace, "=========== Knee Function Information SEI message ===========\n");
     92    break;
     93#endif
    8994#if Q0074_SEI_COLOR_MAPPING
    9095  case SEI::COLOR_MAPPING_INFO:
     
    123128  case SEI::BSP_HRD:
    124129    fprintf( g_hTrace, "=========== Bitstream parition HRD parameters SEI message ===========\n");
     130    break;
     131#endif
     132#if Q0078_ADD_LAYER_SETS
     133  case SEI::OUTPUT_LAYER_SET_NESTING:
     134    fprintf(g_hTrace, "=========== Output layer set nesting SEI message ===========\n");
     135    break;
     136  case SEI::VPS_REWRITING:
     137    fprintf(g_hTrace, "=========== VPS rewriting SEI message ===========\n");
    125138    break;
    126139#endif
     
    177190    xWriteSEIToneMappingInfo(*static_cast<const SEIToneMappingInfo*>(&sei));
    178191    break;
     192#if P0050_KNEE_FUNCTION_SEI
     193  case SEI::KNEE_FUNCTION_INFO:
     194    xWriteSEIKneeFunctionInfo(*static_cast<const SEIKneeFunctionInfo*>(&sei));
     195    break;
     196#endif
    179197#if Q0074_SEI_COLOR_MAPPING
    180198  case SEI::COLOR_MAPPING_INFO:
     
    217235   case SEI::BSP_HRD:
    218236     xWriteSEIBspHrd(*static_cast<const SEIBspHrd*>(&sei), sps, nestingSei);
     237     break;
     238#endif
     239#if Q0078_ADD_LAYER_SETS
     240   case SEI::OUTPUT_LAYER_SET_NESTING:
     241     xWriteSEIOutputLayerSetNesting(bs, *static_cast<const SEIOutputLayerSetNesting*>(&sei), vps, sps);
     242     break;
     243   case SEI::VPS_REWRITING:
     244     xWriteSEIVPSRewriting(*static_cast<const SEIVPSRewriting*>(&sei));
     245     break;
     246#endif
     247#if Q0189_TMVP_CONSTRAINTS
     248   case SEI::TMVP_CONSTRAINTS:
     249     xWriteSEITMVPConstraints(*static_cast<const SEITMVPConstrains*>(&sei));
     250     break;
     251#endif
     252#if Q0247_FRAME_FIELD_INFO
     253   case SEI::FRAME_FIELD_INFO:
     254     xWriteSEIFrameFieldInfo(*static_cast<const SEIFrameFieldInfo*>(&sei));
    219255     break;
    220256#endif
     
    575611  xWriteByteAlign();
    576612}
    577 
     613#if P0050_KNEE_FUNCTION_SEI
     614Void SEIWriter::xWriteSEIKneeFunctionInfo(const SEIKneeFunctionInfo &sei)
     615{
     616  WRITE_UVLC( sei.m_kneeId, "knee_function_id" );
     617  WRITE_FLAG( sei.m_kneeCancelFlag, "knee_function_cancel_flag" );
     618  if ( !sei.m_kneeCancelFlag )
     619  {
     620    WRITE_FLAG( sei.m_kneePersistenceFlag, "knee_function_persistence_flag" );
     621    WRITE_FLAG( sei.m_kneeMappingFlag, "mapping_flag" );
     622    WRITE_CODE( (UInt)sei.m_kneeInputDrange , 32,  "input_d_range" );
     623    WRITE_CODE( (UInt)sei.m_kneeInputDispLuminance, 32,  "input_disp_luminance" );
     624    WRITE_CODE( (UInt)sei.m_kneeOutputDrange, 32,  "output_d_range" );
     625    WRITE_CODE( (UInt)sei.m_kneeOutputDispLuminance, 32,  "output_disp_luminance" );
     626    WRITE_UVLC( sei.m_kneeNumKneePointsMinus1, "num_knee_points_minus1" );
     627    for(Int i = 0; i <= sei.m_kneeNumKneePointsMinus1; i++ )
     628    {
     629      WRITE_CODE( (UInt)sei.m_kneeInputKneePoint[i], 10,"input_knee_point" );
     630      WRITE_CODE( (UInt)sei.m_kneeOutputKneePoint[i], 10, "output_knee_point" );
     631    }
     632  }
     633  xWriteByteAlign();
     634}
     635#endif
    578636#if Q0074_SEI_COLOR_MAPPING
    579637Void SEIWriter::xWriteSEIColorMappingInfo(const SEIColorMappingInfo& sei)
     
    815873#endif
    816874
     875#if Q0189_TMVP_CONSTRAINTS
     876Void SEIWriter::xWriteSEITMVPConstraints (const SEITMVPConstrains &sei)
     877{
     878  WRITE_UVLC( sei.prev_pics_not_used_flag ,    "prev_pics_not_used_flag"  );
     879  WRITE_UVLC( sei.no_intra_layer_col_pic_flag ,    "no_intra_layer_col_pic_flag"  );
     880  xWriteByteAlign();
     881}
     882#endif
     883
     884#if Q0247_FRAME_FIELD_INFO
     885Void SEIWriter::xWriteSEIFrameFieldInfo  (const SEIFrameFieldInfo &sei)
     886{
     887  WRITE_CODE( sei.m_ffinfo_picStruct , 4,             "ffinfo_pic_struct" );
     888  WRITE_CODE( sei.m_ffinfo_sourceScanType, 2,         "ffinfo_source_scan_type" );
     889  WRITE_FLAG( sei.m_ffinfo_duplicateFlag ? 1 : 0,     "ffinfo_duplicate_flag" );
     890  xWriteByteAlign();
     891}
     892#endif
     893
    817894#if O0164_MULTI_LAYER_HRD
    818895Void SEIWriter::xWriteSEIBspNesting(TComBitIf& bs, const SEIBspNesting &sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei)
     
    893970    for (UInt i = 0; i <= sei.m_seiNumBitstreamPartitionsMinus1[lsIdx]; i++)
    894971    {
     972#if HRD_BPB
     973      UInt nl=0;
    895974      for (UInt j = 0; j < sei.m_vpsMaxLayers; j++)
    896975      {
    897976        if (sei.m_layerIdIncludedFlag[lsIdx][j])
    898977        {
     978          nl++;
     979        }
     980      }
     981      for (UInt j = 0; j < nl; j++)
     982      {
     983#else
     984      for (UInt j = 0; j < sei.m_vpsMaxLayers; j++)
     985      {
     986        if (sei.m_layerIdIncludedFlag[lsIdx][j])
     987        {
     988#endif
    899989          WRITE_FLAG( sei.m_seiLayerInBspFlag[lsIdx][i][j], "sei_layer_in_bsp_flag[lsIdx][i][j]" );
    900990        }
    901       }
     991#if !HRD_BPB
     992      }
     993#endif
    902994    }
    903995    WRITE_UVLC( sei.m_seiNumBspSchedCombinationsMinus1[lsIdx], "sei_num_bsp_sched_combinations_minus1[i]");
     
    9881080#endif
    9891081
     1082#if Q0078_ADD_LAYER_SETS
     1083
     1084Void SEIWriter::xWriteSEIOutputLayerSetNesting(TComBitIf& bs, const SEIOutputLayerSetNesting &sei, TComVPS *vps, TComSPS *sps)
     1085{
     1086  WRITE_FLAG(sei.m_olsFlag, "ols_flag");
     1087  WRITE_UVLC(sei.m_numOlsIndicesMinus1, "num_ols_indices_minus1");
     1088
     1089  for (Int i = 0; i <= sei.m_numOlsIndicesMinus1; i++)
     1090  {
     1091    WRITE_UVLC(sei.m_olsIdx[i], "ols_idx[i]");
     1092  }
     1093
     1094  while (m_pcBitIf->getNumberOfWrittenBits() % 8 != 0)
     1095  {
     1096    WRITE_FLAG(0, "ols_nesting_zero_bit");
     1097  }
     1098
     1099  // write nested SEI messages
     1100  for (SEIMessages::const_iterator it = sei.m_nestedSEIs.begin(); it != sei.m_nestedSEIs.end(); it++)
     1101  {
     1102    writeSEImessage(bs, *(*it), vps, sps);
     1103  }
     1104}
     1105
     1106Void SEIWriter::xWriteSEIVPSRewriting(const SEIVPSRewriting &sei)
     1107{
     1108  //sei.nalu->
     1109}
     1110
     1111#endif
     1112
    9901113#endif //SVC_EXTENSION
    9911114
  • trunk/source/Lib/TLibEncoder/SEIwrite.h

    r713 r815  
    7272  Void xWriteSEIGradualDecodingRefreshInfo(const SEIGradualDecodingRefreshInfo &sei);
    7373  Void xWriteSEIToneMappingInfo(const SEIToneMappingInfo& sei);
     74#if P0050_KNEE_FUNCTION_SEI
     75  Void xWriteSEIKneeFunctionInfo(const SEIKneeFunctionInfo &sei);
     76#endif
    7477#if Q0074_SEI_COLOR_MAPPING
    7578  Void xWriteSEIColorMappingInfo(const SEIColorMappingInfo& sei);
     
    9295  Void xWriteSEISubBitstreamProperty(const SEISubBitstreamProperty &sei);
    9396#endif
     97#if Q0189_TMVP_CONSTRAINTS
     98Void xWriteSEITMVPConstraints (const SEITMVPConstrains &sei);
     99#endif
     100#if Q0247_FRAME_FIELD_INFO
     101  Void xWriteSEIFrameFieldInfo  (const SEIFrameFieldInfo &sei);
     102#endif
    94103#if O0164_MULTI_LAYER_HRD
    95104  Void xWriteSEIBspNesting(TComBitIf& bs, const SEIBspNesting &sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei);
     
    98107  Void xCodeHrdParameters( TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1 );
    99108#endif
     109#if Q0078_ADD_LAYER_SETS
     110  Void xWriteSEIOutputLayerSetNesting(TComBitIf& bs, const SEIOutputLayerSetNesting &sei, TComVPS *vps, TComSPS *sps);
     111  Void xWriteSEIVPSRewriting(const SEIVPSRewriting &sei);
     112#endif
    100113#endif //SVC_EXTENSION
    101114};
  • trunk/source/Lib/TLibEncoder/TEnc3DAsymLUT.cpp

    r713 r815  
    276276  Int nStrideILRY = pRecPic->getStride();
    277277  Int nStrideILRC = pRecPic->getCStride();
    278   Int nWidth = m_pDsOrigPic->getWidth();   //should exclude the padding;
    279   Int nHeight= m_pDsOrigPic->getHeight();
    280278  xReset3DArray( m_pColorInfo , xGetYSize() , xGetUSize() , xGetVSize() );
    281279  xReset3DArray( m_pColorInfoC , xGetYSize() , xGetUSize() , xGetVSize() );
    282280
    283281  //alignment padding
    284   Pel *pU = pRecPic->getCbAddr();
    285   Pel *pV = pRecPic->getCrAddr();
    286   pU[(nWidth>>1)] = pU[(nWidth>>1)-1];
    287   pV[(nWidth>>1)] = pV[(nWidth>>1)-1];
    288   memcpy(pU-nStrideILRC, pU, ((nWidth>>1)+1)*sizeof(Pel));
    289   memcpy(pV-nStrideILRC, pV, ((nWidth>>1)+1)*sizeof(Pel));
    290   pU += nStrideILRC+ (nWidth>>1);
    291   pV += nStrideILRC+ (nWidth>>1);
    292 
    293   for( Int y = 1 ; y < (nHeight>>1) ; y ++ )
    294   {
    295     *pU = pU[-1];
    296     *pV = pV[-1];
    297     pU += nStrideILRC;
    298     pV += nStrideILRC;
    299   }
    300   memcpy(pU-(nWidth>>1), pU-(nWidth>>1)-nStrideILRC, ((nWidth>>1)+1)*sizeof(Pel));
    301   memcpy(pV-(nWidth>>1), pV-(nWidth>>1)-nStrideILRC, ((nWidth>>1)+1)*sizeof(Pel));
    302 
    303   for( Int i = 0 ; i < nHeight ; i++ )
    304   {
    305     Int posSrcY = i * nStrideSrcY;
    306     Int posIRLY = i * nStrideILRY;
    307     Int posSrcUV = ( i >> 1 ) * nStrideSrcC;
    308     Int posIRLUV = ( i >> 1 ) * nStrideILRC;
    309     for( Int j = 0 ; j < nWidth ; j++ , posSrcY++ , posIRLY++ , posSrcUV += !( j & 0x01 ) , posIRLUV += !( j & 0x01 ) )
     282  pRecPic->setBorderExtension( false );
     283  pRecPic->extendPicBorder();
     284
     285  TComSlice * pSlice = pCurPic->getSlice(pCurPic->getCurrSliceIdx());
     286  UInt refLayerId = pSlice->getVPS()->getRefLayerId(pSlice->getLayerId(), refLayerIdc);
     287  const Window &scalEL = pSlice->getSPS()->getScaledRefLayerWindowForLayer(refLayerId);
     288  TComPicYuv *pcRecPicBL = pSlice->getBaseColPic(refLayerIdc)->getPicYuvRec();
     289  // borders of down-sampled picture
     290  Int leftDS =  (scalEL.getWindowLeftOffset()*g_posScalingFactor[refLayerIdc][0]+(1<<15))>>16;
     291  Int rightDS = pcRecPicBL->getWidth() - 1 + (((scalEL.getWindowRightOffset())*g_posScalingFactor[refLayerIdc][0]+(1<<15))>>16);
     292  Int topDS = (((scalEL.getWindowTopOffset())*g_posScalingFactor[refLayerIdc][1]+(1<<15))>>16);
     293  Int bottomDS = pcRecPicBL->getHeight() - 1 + (((scalEL.getWindowBottomOffset())*g_posScalingFactor[refLayerIdc][1]+(1<<15))>>16);
     294  // overlapped region
     295  Int left = max( 0 , leftDS );
     296  Int right = min( pcRecPicBL->getWidth() - 1 , rightDS );
     297  Int top = max( 0 , topDS );
     298  Int bottom = min( pcRecPicBL->getHeight() - 1 , bottomDS );
     299  // since we do data collection only for overlapped region, the border extension is good enough
     300
     301  for( Int i = top ; i <= bottom ; i++ )
     302  {
     303    Int iDS = i-topDS;
     304    Int jDS = left-leftDS;
     305    Int posSrcY = iDS * nStrideSrcY + jDS;
     306    Int posIRLY = i * nStrideILRY + left;
     307    Int posSrcUV = ( iDS >> 1 ) * nStrideSrcC + (jDS>>1);
     308    Int posIRLUV = ( i >> 1 ) * nStrideILRC + (left>>1);
     309    for( Int j = left ; j <= right ; j++ , posSrcY++ , posIRLY++ , posSrcUV += !( j & 0x01 ) , posIRLUV += !( j & 0x01 ) )
    310310    {
    311311      Int Y = pSrcY[posSrcY];
  • trunk/source/Lib/TLibEncoder/TEncCavlc.cpp

    r713 r815  
    256256  WRITE_FLAG( pcPPS->getSliceHeaderExtensionPresentFlag() ? 1 : 0, "slice_segment_header_extension_present_flag");
    257257#if P0166_MODIFIED_PPS_EXTENSION
    258   WRITE_FLAG( 1, "pps_extension_flag" );
    259   if( 1 ) //pps_extension_flag
     258  WRITE_FLAG( pcPPS->getExtensionFlag() ? 1 : 0, "pps_extension_flag" );
     259
     260  if( pcPPS->getExtensionFlag() )
    260261  {
    261262#if !POC_RESET_IDC
     
    638639  }
    639640
    640 #if SPS_EXTENSION
    641   WRITE_FLAG( 1, "sps_extension_flag" );
    642   if( 1 )   // if( sps_extension_flag )
     641#if SVC_EXTENSION
     642  WRITE_FLAG( pcSPS->getExtensionFlag() ? 1 : 0, "sps_extension_flag" );
     643
     644  if( pcSPS->getExtensionFlag() )
    643645  {
    644646#if O0142_CONDITIONAL_SPS_EXTENSION
     
    661663#endif
    662664}
    663 #if SPS_EXTENSION
     665
     666#if SVC_EXTENSION
    664667Void TEncCavlc::codeSPSExtension( TComSPS* pcSPS )
    665668{
     
    688691  }
    689692}
    690 #endif
     693#endif //SVC_EXTENSION
     694
    691695Void TEncCavlc::codeVPS( TComVPS* pcVPS )
    692696{
     
    703707  WRITE_CODE( pcVPS->getVPSId(),                    4,        "vps_video_parameter_set_id" );
    704708  WRITE_CODE( 3,                                    2,        "vps_reserved_three_2bits" );
    705 #if VPS_RENAME
     709#if SVC_EXTENSION
    706710  WRITE_CODE( pcVPS->getMaxLayers() - 1,            6,        "vps_max_layers_minus1" );           
    707711#else
     
    734738  }
    735739
    736 #if VPS_RENAME
     740#if SVC_EXTENSION
    737741  assert( pcVPS->getNumHrdParameters() <= MAX_VPS_LAYER_SETS_PLUS1 );
    738742  assert( pcVPS->getMaxLayerId() < MAX_VPS_LAYER_ID_PLUS1 );
     
    741745#endif
    742746  WRITE_CODE( pcVPS->getMaxLayerId(), 6,                       "vps_max_layer_id" );
     747#if Q0078_ADD_LAYER_SETS
     748  WRITE_UVLC(pcVPS->getVpsNumLayerSetsMinus1(),                "vps_num_layer_sets_minus1");
     749  for (UInt opsIdx = 1; opsIdx <= pcVPS->getVpsNumLayerSetsMinus1(); opsIdx++)
     750#else
    743751  WRITE_UVLC( pcVPS->getNumLayerSets() - 1,                 "vps_num_layer_sets_minus1" );
    744   for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getNumLayerSets() - 1 ); opsIdx ++ )
     752  for (UInt opsIdx = 1; opsIdx <= (pcVPS->getNumLayerSets() - 1); opsIdx++)
     753#endif
    745754  {
    746755    // Operation point set
     
    798807    }
    799808  }
    800 #if VPS_EXTNS
     809#if SVC_EXTENSION
    801810  // When MaxLayersMinus1 is greater than 0, vps_extension_flag shall be equal to 1.
    802811  if( pcVPS->getMaxLayers() > 1 )
     
    832841
    833842#if SVC_EXTENSION
    834 #if VPS_EXTNS
    835843Void TEncCavlc::codeVPSExtension (TComVPS *vps)
    836844{
     
    846854#if !P0307_REMOVE_VPS_VUI_OFFSET
    847855#if O0109_MOVE_VPS_VUI_FLAG
    848 #if !VPS_VUI
    849   WRITE_FLAG( 0,                     "vps_vui_present_flag" );
    850   vps->setVpsVuiPresentFlag(false);
    851 #else
    852856  WRITE_FLAG( 1,                     "vps_vui_present_flag" );
    853857  vps->setVpsVuiPresentFlag(true);
    854 #endif
    855858  if ( vps->getVpsVuiPresentFlag() )
    856859  {
     
    879882  }
    880883
    881 #if SPL_FLG_CHK
     884  // The value of dimBitOffset[ NumScalabilityTypes ] is set equal to 6.
    882885  if(vps->getSplittingFlag())
    883886  {
     
    889892    assert(splDimSum<=6);
    890893  }
    891 #endif
    892894
    893895  WRITE_FLAG( vps->getNuhLayerIdPresentFlag(),         "vps_nuh_layer_id_present_flag" );
     
    957959    }
    958960#endif
    959 #if N0120_MAX_TID_REF_PRESENT_FLAG
    960961   WRITE_FLAG( vps->getMaxTidRefPresentFlag(), "max_tid_ref_present_flag");
    961962   if (vps->getMaxTidRefPresentFlag())
     
    976977     }
    977978   }
    978 #else
    979   for( i = 0; i < vps->getMaxLayers() - 1; i++)
    980   {
    981 #if O0225_MAX_TID_FOR_REF_LAYERS
    982        for( j = i+1; j <= vps->getMaxLayers() - 1; j++)
    983        {
    984          if(vps->getDirectDependencyFlag(j, i))
    985          {
    986            WRITE_CODE(vps->getMaxTidIlRefPicsPlus1(i,j), 3, "max_tid_il_ref_pics_plus1[i][j]" );
    987          }
    988        }
    989 #else
    990     WRITE_CODE(vps->getMaxTidIlRefPicsPlus1(i), 3, "max_tid_il_ref_pics_plus1[i]" );
    991 #endif
    992   }
    993 #endif
    994 #if ILP_SSH_SIG
    995     WRITE_FLAG( vps->getIlpSshSignalingEnabledFlag(), "all_ref_layers_active_flag" );
    996 #endif
     979   WRITE_FLAG( vps->getIlpSshSignalingEnabledFlag(), "all_ref_layers_active_flag" );
    997980#if VPS_EXTN_PROFILE_INFO
    998981  // Profile-tier-level signalling
     
    1016999#endif
    10171000
     1001#if Q0078_ADD_LAYER_SETS
     1002  if (vps->getNumIndependentLayers() > 1)
     1003  {
     1004    WRITE_UVLC( vps->getNumAddLayerSets(), "num_add_layer_sets" );
     1005    for (i = 0; i < vps->getNumAddLayerSets(); i++)
     1006    {
     1007      for (j = 1; j < vps->getNumIndependentLayers(); j++)
     1008      {
     1009        int len = 1;
     1010        while ((1 << len) < (vps->getNumLayersInTreePartition(j) + 1))
     1011        {
     1012          len++;
     1013        }
     1014        WRITE_CODE(vps->getHighestLayerIdxPlus1(i, j), len, "highest_layer_idx_plus1[i][j]");
     1015      }
     1016    }
     1017  }
     1018#endif
     1019
    10181020#if !VPS_EXTN_UEV_CODING
    10191021  Int numOutputLayerSets = vps->getNumOutputLayerSets() ;
     
    10271029  Int numAddOutputLayerSets = numOutputLayerSets - (Int)vps->getNumLayerSets();
    10281030
    1029   // The value of num_add_output_layer_sets shall be in the range of 0 to 1023, inclusive.
     1031  // The value of num_add_olss shall be in the range of 0 to 1023, inclusive.
    10301032  assert( numAddOutputLayerSets >= 0 && numAddOutputLayerSets < 1024 );
    10311033
     
    10331035  if( vps->getNumLayerSets() > 1 )
    10341036  {
    1035     WRITE_UVLC( numAddOutputLayerSets, "num_add_output_layer_sets" );
    1036     WRITE_CODE( vps->getDefaultTargetOutputLayerIdc(), 2, "default_target_output_layer_idc" );
     1037    WRITE_UVLC( numAddOutputLayerSets, "num_add_olss" );
     1038    WRITE_CODE( vps->getDefaultTargetOutputLayerIdc(), 2, "default_output_layer_idc" );
    10371039  }
    10381040#else
     
    10651067        numBits++;
    10661068      }
    1067       WRITE_CODE( vps->getOutputLayerSetIdx(i) - 1, numBits, "output_layer_set_idx_minus1");
     1069      WRITE_CODE( vps->getOutputLayerSetIdx(i) - 1, numBits, "layer_set_idx_for_ols_minus1");
    10681070#if P0295_DEFAULT_OUT_LAYER_IDC
    10691071    }
     1072#if Q0078_ADD_LAYER_SETS
     1073    if ( i > vps->getVpsNumLayerSetsMinus1() || vps->getDefaultTargetOutputLayerIdc() >= 2 ) //Instead of == 2, >= 2 is used to follow the agreement that value 3 should be interpreted as 2
     1074#else
    10701075    if ( i > (vps->getNumLayerSets() - 1) || vps->getDefaultTargetOutputLayerIdc() >= 2 ) //Instead of == 2, >= 2 is used to follow the agreement that value 3 should be interpreted as 2
     1076#endif
    10711077    {
    10721078#endif
     
    12171223  WRITE_FLAG(vps->getPhaseAlignFlag(), "cross_layer_phase_alignment_flag" );
    12181224#endif
    1219 #if N0147_IRAP_ALIGN_FLAG && !IRAP_ALIGN_FLAG_IN_VPS_VUI
     1225#if !IRAP_ALIGN_FLAG_IN_VPS_VUI
    12201226  WRITE_FLAG(vps->getCrossLayerIrapAlignFlag(), "cross_layer_irap_aligned_flag");
    12211227#endif
     
    12861292
    12871293#if !O0109_MOVE_VPS_VUI_FLAG
    1288 #if !VPS_VUI
    1289   WRITE_FLAG( 0,                     "vps_vui_present_flag" );
    1290 #else
    12911294  WRITE_FLAG( 1,                     "vps_vui_present_flag" );
    12921295  if(1)   // Should be conditioned on the value of vps_vui_present_flag
     
    13031306    codeVPSVUI(vps); 
    13041307  }
    1305 #endif
    13061308#else
    13071309#if P0307_REMOVE_VPS_VUI_OFFSET
     
    13261328#endif // 0109_MOVE_VPS_FLAG
    13271329}
    1328 #endif
     1330
    13291331#if REPN_FORMAT_IN_VPS
    13301332Void  TEncCavlc::codeRepFormat( RepFormat *repFormat )
     
    13711373{
    13721374#if DPB_PARAMS_MAXTLAYERS
     1375#if BITRATE_PICRATE_SIGNALLING
     1376    Int * MaxSubLayersInLayerSetMinus1 = new Int[vps->getNumLayerSets()];
     1377    for(Int i = 0; i < vps->getNumLayerSets(); i++)
     1378#else
    13731379    Int * MaxSubLayersInLayerSetMinus1 = new Int[vps->getNumOutputLayerSets()];
    13741380    for(Int i = 1; i < vps->getNumOutputLayerSets(); i++)
     1381#endif
    13751382    {
    13761383        UInt maxSLMinus1 = 0;
     
    13801387        Int optLsIdx = i;
    13811388#endif
     1389#if BITRATE_PICRATE_SIGNALLING
     1390        optLsIdx = i;
     1391#endif
    13821392        for(Int k = 0; k < vps->getNumLayersInIdList(optLsIdx); k++ ) {
    13831393            Int  lId = vps->getLayerSetLayerIdList(optLsIdx, k);
     
    13851395        }
    13861396        MaxSubLayersInLayerSetMinus1[ i ] = maxSLMinus1;
    1387     }
    1388 #endif
     1397#if BITRATE_PICRATE_SIGNALLING
     1398        vps->setMaxSLayersInLayerSetMinus1(i,MaxSubLayersInLayerSetMinus1[ i ]);
     1399#endif
     1400    }
     1401#endif
     1402   
    13891403   
    13901404  for(Int i = 1; i < vps->getNumOutputLayerSets(); i++)
     
    13951409    WRITE_FLAG( vps->getSubLayerFlagInfoPresentFlag( i ), "sub_layer_flag_info_present_flag[i]");
    13961410#if DPB_PARAMS_MAXTLAYERS
     1411#if BITRATE_PICRATE_SIGNALLING
     1412    for(Int j = 0; j <= MaxSubLayersInLayerSetMinus1[ vps->getOutputLayerSetIdx( i ) ]; j++)
     1413#else
    13971414    for(Int j = 0; j <= MaxSubLayersInLayerSetMinus1[ i ]; j++)
     1415#endif
    13981416#else
    13991417    for(Int j = 0; j < vps->getMaxTLayers(); j++)
     
    14071425      {
    14081426#if CHANGE_NUMSUBDPB_IDX
     1427#if RESOLUTION_BASED_DPB
    14091428        for(Int k = 0; k < vps->getNumSubDpbs(layerSetIdxForOutputLayerSet); k++)
     1429#else
     1430        for(Int k = 0; k < vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ); k++)
     1431#endif
    14101432#else
    14111433        for(Int k = 0; k < vps->getNumSubDpbs(i); k++)
     
    14301452}
    14311453#endif
    1432 #if VPS_VUI
     1454
    14331455Void TEncCavlc::codeVPSVUI (TComVPS *vps)
    14341456{
     
    14511473  }
    14521474#endif
    1453 #if VPS_VUI_BITRATE_PICRATE
    14541475  WRITE_FLAG( vps->getBitRatePresentVpsFlag(),        "bit_rate_present_vps_flag" );
    14551476  WRITE_FLAG( vps->getPicRatePresentVpsFlag(),        "pic_rate_present_vps_flag" );
     
    14571478  if( vps->getBitRatePresentVpsFlag() || vps->getPicRatePresentVpsFlag() )
    14581479  {
     1480#if Q0078_ADD_LAYER_SETS
     1481    for( i = 0; i <= vps->getVpsNumLayerSetsMinus1(); i++ )
     1482#else
    14591483    for( i = 0; i < vps->getNumLayerSets(); i++ )
    1460     {
     1484#endif
     1485    {
     1486#if BITRATE_PICRATE_SIGNALLING
     1487      for( j = 0; j <= vps->getMaxSLayersInLayerSetMinus1(i); j++ )
     1488#else
    14611489      for( j = 0; j < vps->getMaxTLayers(); j++ )
     1490#endif
    14621491      {
    14631492        if( vps->getBitRatePresentVpsFlag() )
     
    14821511    }
    14831512  }
    1484 #endif
    14851513#if VPS_VUI_VIDEO_SIGNAL_MOVE
    14861514  WRITE_FLAG( vps->getVideoSigPresentVpsFlag(), "video_signal_info_idx_present_flag" );
     
    15191547    }
    15201548#endif
    1521 #if TILE_BOUNDARY_ALIGNED_FLAG
     1549
    15221550    for(i = 1; i < vps->getMaxLayers(); i++)
    15231551    {
     
    15341562      }
    15351563    } 
    1536 #endif
    15371564#if VPS_VUI_TILES_NOT_IN_USE__FLAG
    15381565  }
     
    16271654        codeHrdParameters(vps->getBspHrd(i), i==0 ? 1 : vps->getBspCprmsPresentFlag(i), vps->getMaxTLayers()-1);
    16281655      }
     1656#if Q0078_ADD_LAYER_SETS
     1657      for( UInt h = 1; h <= vps->getVpsNumLayerSetsMinus1(); h++ )
     1658#else
    16291659      for( UInt h = 1; h <= (vps->getNumLayerSets()-1); h++ )
     1660#endif
    16301661      {
    16311662        WRITE_UVLC( vps->getNumBitstreamPartitions(h), "num_bitstream_partitions[i]");
     
    16421673        if (vps->getNumBitstreamPartitions(h))
    16431674        {
     1675#if Q0182_MULTI_LAYER_HRD_UPDATE
     1676          WRITE_UVLC(vps->getNumBspSchedCombinations(h) - 1, "num_bsp_sched_combinations_minus1[h]");
     1677#else
    16441678          WRITE_UVLC( vps->getNumBspSchedCombinations(h), "num_bsp_sched_combinations[h]");
     1679#endif
    16451680          for( i = 0; i < vps->getNumBspSchedCombinations(h); i++ )
    16461681          {
     
    16731708#endif
    16741709}
    1675 #endif
    16761710#endif //SVC_EXTENSION
    16771711
     
    18111845      }
    18121846#else
     1847#if POC_RESET_IDC_ENCODER
     1848      Int picOrderCntLSB;
     1849      if( pcSlice->getPocResetIdc() == 2 )  // i.e. the LSB is reset
     1850      {
     1851        picOrderCntLSB = pcSlice->getPicOrderCntLsb();  // This will be the LSB value w.r.t to the previous POC reset period.
     1852      }
     1853      else
     1854      {
     1855        picOrderCntLSB = (pcSlice->getPOC() + (1<<pcSlice->getSPS()->getBitsForPOC())) & ((1<<pcSlice->getSPS()->getBitsForPOC())-1);
     1856      }
     1857#else
    18131858      Int picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) & ((1<<pcSlice->getSPS()->getBitsForPOC())-1);
     1859#endif
    18141860#endif
    18151861      WRITE_CODE( picOrderCntLSB, pcSlice->getSPS()->getBitsForPOC(), "pic_order_cnt_lsb");
     
    19401986
    19411987#if SVC_EXTENSION
    1942 #if ILP_SSH_SIG
    1943 #if ILP_SSH_SIG_FIX
    19441988    if((pcSlice->getLayerId() > 0) && !(pcSlice->getVPS()->getIlpSshSignalingEnabledFlag()) && (pcSlice->getNumILRRefIdx() > 0) )
    1945 #else
    1946     if((pcSlice->getLayerId() > 0) && pcSlice->getVPS()->getIlpSshSignalingEnabledFlag() && (pcSlice->getNumILRRefIdx() > 0) )
    1947 #endif
    1948 #else
    1949     if((pcSlice->getLayerId() > 0)  &&  (pcSlice->getNumILRRefIdx() > 0) )
    1950 #endif
    19511989    {
    19521990      WRITE_FLAG(pcSlice->getInterLayerPredEnabledFlag(),"inter_layer_pred_enabled_flag");
     
    19642002            WRITE_CODE(pcSlice->getActiveNumILRRefIdx() - 1, numBits,"num_inter_layer_ref_pics_minus1");
    19652003          }       
    1966 #if ILP_NUM_REF_CHK
     2004
    19672005          if( pcSlice->getNumILRRefIdx() != pcSlice->getActiveNumILRRefIdx() )
    19682006          {
    1969 #endif
    1970           for(Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ )
    1971           {
    1972             WRITE_CODE(pcSlice->getInterLayerPredLayerIdc(i),numBits,"inter_layer_pred_layer_idc[i]");   
     2007            for(Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ )
     2008            {
     2009              WRITE_CODE(pcSlice->getInterLayerPredLayerIdc(i),numBits,"inter_layer_pred_layer_idc[i]");   
     2010            }
    19732011          }
    1974 #if ILP_NUM_REF_CHK
    1975           }
    1976 #endif
    19772012        }
    19782013      }
     
    22942329{
    22952330  Int tmpBitsBeforeWriting = getNumberOfWrittenBits();
     2331  Int maxPocLsb = 1 << slice->getSPS()->getBitsForPOC();
    22962332  if(slice->getPPS()->getSliceHeaderExtensionPresentFlag())
    22972333  {
     
    23362372    {
    23372373      UInt lengthVal = 1;
    2338       UInt tempVal = slice->getPocMsbVal() + 1;
     2374      UInt tempVal = (slice->getPocMsbVal() / maxPocLsb) + 1;
    23392375      assert ( tempVal );
    23402376      while( 1 != tempVal )
     
    23732409    if( slice->getPocMsbValPresentFlag() )
    23742410    {
    2375       WRITE_UVLC( slice->getPocMsbVal(),                                      "poc_msb_val" );
     2411      assert( slice->getPocMsbVal() % maxPocLsb == 0 );
     2412      WRITE_UVLC( slice->getPocMsbVal() / maxPocLsb,                                      "poc_msb_val" );
    23762413    }
    23772414    for (Int i = 0; i < shExtnAdditionalBits; i++)
    23782415    {
     2416#if Q0146_SSH_EXT_DATA_BIT
     2417      WRITE_FLAG( 1, "slice_segment_header_extension_data_bit");
     2418#else
    23792419      WRITE_FLAG( 1, "slice_segment_header_extension_reserved_bit");
     2420#endif
    23802421    }
    23812422  }
  • trunk/source/Lib/TLibEncoder/TEncCavlc.h

    r713 r815  
    159159  Void codeDFSvlc       ( Int   iCode, const Char *pSymbolName );
    160160
    161 #if SPS_EXTENSION
    162   Void codeSPSExtension         ( TComSPS* pcSPS );
    163 #if VPS_EXTNS
    164   Void  codeVPSExtension        ( TComVPS* pcVPS );
    165 #endif
    166 #if VPS_VUI
    167   Void codeVPSVUI               (TComVPS *vps);
    168 #endif
     161#if SVC_EXTENSION
     162  Void codeSPSExtension        ( TComSPS* pcSPS );
     163  Void codeVPSExtension        ( TComVPS* pcVPS );
     164  Void codeVPSVUI              ( TComVPS *vps   );
    169165#if REPN_FORMAT_IN_VPS
    170   Void  codeRepFormat           ( RepFormat *repFormat );
     166  Void  codeRepFormat          ( RepFormat *repFormat );
    171167#endif
    172168#if VPS_DPB_SIZE_TABLE
    173   Void  codeVpsDpbSizeTable      (TComVPS *vps);
     169  Void  codeVpsDpbSizeTable    (TComVPS *vps);
    174170#endif
    175171#if Q0048_CGS_3D_ASYMLUT
  • trunk/source/Lib/TLibEncoder/TEncCfg.h

    r713 r815  
    248248  Int*      m_codedPivotValue;
    249249  Int*      m_targetPivotValue;
     250#if P0050_KNEE_FUNCTION_SEI
     251  Bool      m_kneeSEIEnabled;
     252  Int       m_kneeSEIId;
     253  Bool      m_kneeSEICancelFlag;
     254  Bool      m_kneeSEIPersistenceFlag;
     255  Bool      m_kneeSEIMappingFlag;
     256  Int       m_kneeSEIInputDrange;
     257  Int       m_kneeSEIInputDispLuminance;
     258  Int       m_kneeSEIOutputDrange;
     259  Int       m_kneeSEIOutputDispLuminance;
     260  Int       m_kneeSEINumKneePointsMinus1;
     261  Int*      m_kneeSEIInputKneePoint;
     262  Int*      m_kneeSEIOutputKneePoint;
     263#endif
    250264#if Q0074_SEI_COLOR_MAPPING
    251265  Char*     m_seiColorMappingFile;
     
    262276  Int       m_SOPDescriptionSEIEnabled;
    263277  Int       m_scalableNestingSEIEnabled;
     278#if Q0189_TMVP_CONSTRAINTS
     279  Int       m_TMVPConstraintsSEIEnabled;
     280#endif
    264281  //====== Weighted Prediction ========
    265282  Bool      m_useWeightedPred;       //< Use of Weighting Prediction (P_SLICE)
     
    348365  Bool      m_motionPredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1];
    349366#endif
    350 #if N0120_MAX_TID_REF_CFG
    351367  Int       m_maxTidIlRefPicsPlus1;
    352 #endif
    353368#if AUXILIARY_PICTURES
    354369  ChromaFormat m_chromaFormatIDC;
     
    670685  Void  setTMISEIExtendedWhiteLevelLumaCodeValue(Int b)      {  m_extendedWhiteLevelLumaCodeValue =b;  }
    671686  Int   getTMISEIExtendedWhiteLevelLumaCodeValue()           {  return m_extendedWhiteLevelLumaCodeValue;  }
     687#if P0050_KNEE_FUNCTION_SEI
     688  Void  setKneeSEIEnabled(Int b)                             { m_kneeSEIEnabled = b; }
     689  Bool  getKneeSEIEnabled()                                  { return m_kneeSEIEnabled; }
     690  Void  setKneeSEIId(Int b)                                  { m_kneeSEIId = b; }
     691  Int   getKneeSEIId()                                       { return m_kneeSEIId; }
     692  Void  setKneeSEICancelFlag(Bool b)                         { m_kneeSEICancelFlag=b; }
     693  Bool  getKneeSEICancelFlag()                               { return m_kneeSEICancelFlag; }
     694  Void  setKneeSEIPersistenceFlag(Bool b)                    { m_kneeSEIPersistenceFlag = b; }
     695  Bool  getKneeSEIPersistenceFlag()                          { return m_kneeSEIPersistenceFlag; }
     696  Void  setKneeSEIMappingFlag(Bool b)                        { m_kneeSEIMappingFlag = b; }
     697  Bool  getKneeSEIMappingFlag()                              { return m_kneeSEIMappingFlag; }
     698  Void  setKneeSEIInputDrange(Int b)                         { m_kneeSEIInputDrange = b; }
     699  Int   getKneeSEIInputDrange()                              { return m_kneeSEIInputDrange; }
     700  Void  setKneeSEIInputDispLuminance(Int b)                  { m_kneeSEIInputDispLuminance = b; }
     701  Int   getKneeSEIInputDispLuminance()                       { return m_kneeSEIInputDispLuminance; }
     702  Void  setKneeSEIOutputDrange(Int b)                        { m_kneeSEIOutputDrange = b; }
     703  Int   getKneeSEIOutputDrange()                             { return m_kneeSEIOutputDrange; }
     704  Void  setKneeSEIOutputDispLuminance(Int b)                 { m_kneeSEIOutputDispLuminance = b; }
     705  Int   getKneeSEIOutputDispLuminance()                      { return m_kneeSEIOutputDispLuminance; }
     706  Void  setKneeSEINumKneePointsMinus1(Int b)                 { m_kneeSEINumKneePointsMinus1 = b; }
     707  Int   getKneeSEINumKneePointsMinus1()                      { return m_kneeSEINumKneePointsMinus1; }
     708  Void  setKneeSEIInputKneePoint(Int *p)                     { m_kneeSEIInputKneePoint = p; }
     709  Int*  getKneeSEIInputKneePoint()                           { return m_kneeSEIInputKneePoint; }
     710  Void  setKneeSEIOutputKneePoint(Int *p)                    { m_kneeSEIOutputKneePoint = p; }
     711  Int*  getKneeSEIOutputKneePoint()                          { return m_kneeSEIOutputKneePoint; }
     712#endif
    672713#if Q0074_SEI_COLOR_MAPPING
    673714  Void  setColorMappingInfoSEIFile( Char* nameFile )         {  m_seiColorMappingFile = nameFile; }
     
    695736  Int   getSOPDescriptionSEIEnabled()                     { return m_SOPDescriptionSEIEnabled; }
    696737  Void  setScalableNestingSEIEnabled(Int b)                { m_scalableNestingSEIEnabled = b; }
     738#if Q0189_TMVP_CONSTRAINTS
     739  void setTMVPConstraintsSEIEnabled(Int b)                { m_TMVPConstraintsSEIEnabled = b; }
     740#endif
    697741  Int   getScalableNestingSEIEnabled()                     { return m_scalableNestingSEIEnabled; }
     742#if Q0189_TMVP_CONSTRAINTS
     743  Int   getTMVPConstraintsSEIEnabled()                {  return m_TMVPConstraintsSEIEnabled; }
     744#endif
    698745  Void      setUseWP               ( Bool b )    { m_useWeightedPred   = b;    }
    699746  Void      setWPBiPred            ( Bool b )    { m_useWeightedBiPred = b;    }
     
    877924  Void      setMotionPredEnabledFlag        (Int i,Bool flag)               { m_motionPredEnabledFlag[i] = flag;  }
    878925#endif
    879 #if N0120_MAX_TID_REF_CFG
    880926  Int       getMaxTidIlRefPicsPlus1         ()                              { return m_maxTidIlRefPicsPlus1; }
    881927  Void      setMaxTidIlRefPicsPlus1         (Int num)                       { m_maxTidIlRefPicsPlus1 = num;  }
    882 #endif
    883928#if LAYERS_NOT_PRESENT_SEI
    884929  Void  setLayersNotPresentSEIEnabled(Int b)             { m_layersNotPresentSEIEnabled = b; }
  • trunk/source/Lib/TLibEncoder/TEncCu.cpp

    r595 r815  
    696696#if (ENCODER_FAST_MODE)
    697697        if( rpcBestCU->getSlice()->getSliceType() == I_SLICE ||
     698          rpcBestCU->getPredictionMode(0) == MODE_NONE ||  // if there is no valid inter prediction
    698699          !testInter ||
    699700          rpcBestCU->getCbf( 0, TEXT_LUMA     ) != 0   ||
     
    701702          rpcBestCU->getCbf( 0, TEXT_CHROMA_V ) != 0     ) // avoid very complex intra if it is unlikely
    702703#else
    703           if( rpcBestCU->getSlice()->getSliceType() == I_SLICE ||
    704             rpcBestCU->getCbf( 0, TEXT_LUMA     ) != 0   ||
    705             rpcBestCU->getCbf( 0, TEXT_CHROMA_U ) != 0   ||
    706             rpcBestCU->getCbf( 0, TEXT_CHROMA_V ) != 0     ) // avoid very complex intra if it is unlikely
    707 #endif
     704        if( rpcBestCU->getSlice()->getSliceType() == I_SLICE ||
     705          rpcBestCU->getCbf( 0, TEXT_LUMA     ) != 0   ||
     706          rpcBestCU->getCbf( 0, TEXT_CHROMA_U ) != 0   ||
     707          rpcBestCU->getCbf( 0, TEXT_CHROMA_V ) != 0     ) // avoid very complex intra if it is unlikely
     708#endif
     709        {
     710          xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_2Nx2N );
     711          rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
     712          if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth )
    708713          {
    709             xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_2Nx2N );
    710           rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    711             if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth )
     714            if( rpcTempCU->getWidth(0) > ( 1 << rpcTempCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) )
    712715            {
    713               if( rpcTempCU->getWidth(0) > ( 1 << rpcTempCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) )
    714               {
    715                 xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_NxN   );
     716              xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_NxN   );
    716717              rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    717               }
    718718            }
    719719          }
     720        }
    720721
    721722        // test PCM
     
    734735#if (ENCODER_FAST_MODE)
    735736#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    736       if(pcPic->getLayerId() > 0 && !m_disableILP)
    737 #else
    738       if(pcPic->getLayerId() > 0)
    739 #endif
    740       {
    741         for(Int refLayer = 0; refLayer < pcSlice->getActiveNumILRRefIdx(); refLayer++)
    742         { 
    743            xCheckRDCostILRUni( rpcBestCU, rpcTempCU, pcSlice->getInterLayerPredLayerIdc(refLayer));
    744            rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
     737        if(pcPic->getLayerId() > 0 && !m_disableILP)
     738#else
     739        if(pcPic->getLayerId() > 0)
     740#endif
     741        {
     742          for(Int refLayer = 0; refLayer < pcSlice->getActiveNumILRRefIdx(); refLayer++)
     743          { 
     744            xCheckRDCostILRUni( rpcBestCU, rpcTempCU, pcSlice->getVPS()->getRefLayerId( pcSlice->getLayerId(), pcSlice->getInterLayerPredLayerIdc(refLayer) ) );
     745            rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
     746          }
    745747        }
    746       }
    747748#endif
    748749
     
    821822
    822823  if ( m_pcEncCfg->getCUTransquantBypassFlagForceValue() )
    823     {
     824  {
    824825    iMaxQP = iMinQP; // If all blocks are forced into using transquant bypass, do not loop here.
    825     }
     826  }
    826827
    827828  for (Int iQP=iMinQP; iQP<=iMaxQP; iQP++)
     
    14761477  rpcTempCU->setPredModeSubParts  ( MODE_INTER, 0, uhDepth );
    14771478 
     1479#if SVC_EXTENSION
     1480#if AMP_MRG
     1481  rpcTempCU->setMergeAMP (true);
     1482  Bool ret = m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], false, bUseMRG );
     1483#else 
     1484  Bool ret = m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth] );
     1485#endif
     1486
     1487  if( !ret )
     1488  {
     1489    return;
     1490  }
     1491#else
    14781492#if AMP_MRG
    14791493  rpcTempCU->setMergeAMP (true);
     
    14811495#else 
    14821496  m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth] );
     1497#endif
    14831498#endif
    14841499
  • trunk/source/Lib/TLibEncoder/TEncGOP.cpp

    r713 r815  
    9292  m_bRefreshPending     = 0;
    9393  m_pocCRA            = 0;
     94#if POC_RESET_IDC_ENCODER
     95  m_pocCraWithoutReset = 0;
     96  m_associatedIrapPocBeforeReset = 0;
     97#endif
    9498  m_numLongTermRefPicSPS = 0;
    9599  ::memset(m_ltRefPicPocLsbSps, 0, sizeof(m_ltRefPicPocLsbSps));
     
    103107  m_associatedIRAPPOC  = 0;
    104108#endif
    105 #if SVC_UPSAMPLING
     109#if SVC_EXTENSION
    106110  m_pcPredSearch        = NULL;
    107 #endif
    108111#if Q0048_CGS_3D_ASYMLUT
    109112  m_temp = NULL;
    110113  m_pColorMappedPic = NULL;
    111114#endif
     115#if POC_RESET_IDC_ENCODER
     116  m_lastPocPeriodId = -1;
     117#endif
     118#endif //SVC_EXTENSION
    112119  return;
    113120}
     
    173180#if SVC_EXTENSION
    174181  m_ppcTEncTop           = pcTEncTop->getLayerEnc();
    175 #endif
    176 #if SVC_UPSAMPLING
    177182  m_pcPredSearch         = pcTEncTop->getPredSearch();                       ///< encoder search class
    178 #endif
    179183#if Q0048_CGS_3D_ASYMLUT
    180184  if( pcTEncTop->getLayerId() )
     
    185189    {
    186190      m_pColorMappedPic = new TComPicYuv;
    187       m_pColorMappedPic->create( m_ppcTEncTop[0]->getSourceWidth(), m_ppcTEncTop[0]->getSourceHeight(), CHROMA_420, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL );
    188     }
    189   }
    190 #endif
     191      m_pColorMappedPic->create( m_ppcTEncTop[0]->getSourceWidth(), m_ppcTEncTop[0]->getSourceHeight(), m_ppcTEncTop[0]->getChromaFormatIDC(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL );
     192    }
     193  }
     194#endif
     195#endif //SVC_EXTENSION
    191196}
    192197
     
    327332}
    328333
     334#if P0050_KNEE_FUNCTION_SEI
     335SEIKneeFunctionInfo* TEncGOP::xCreateSEIKneeFunctionInfo()
     336{
     337  SEIKneeFunctionInfo *seiKneeFunctionInfo = new SEIKneeFunctionInfo();
     338  seiKneeFunctionInfo->m_kneeId = m_pcCfg->getKneeSEIId();
     339  seiKneeFunctionInfo->m_kneeCancelFlag = m_pcCfg->getKneeSEICancelFlag();
     340  if ( !seiKneeFunctionInfo->m_kneeCancelFlag )
     341  {
     342    seiKneeFunctionInfo->m_kneePersistenceFlag = m_pcCfg->getKneeSEIPersistenceFlag();
     343    seiKneeFunctionInfo->m_kneeMappingFlag = m_pcCfg->getKneeSEIMappingFlag();
     344    seiKneeFunctionInfo->m_kneeInputDrange = m_pcCfg->getKneeSEIInputDrange();
     345    seiKneeFunctionInfo->m_kneeInputDispLuminance = m_pcCfg->getKneeSEIInputDispLuminance();
     346    seiKneeFunctionInfo->m_kneeOutputDrange = m_pcCfg->getKneeSEIOutputDrange();
     347    seiKneeFunctionInfo->m_kneeOutputDispLuminance = m_pcCfg->getKneeSEIOutputDispLuminance();
     348
     349    seiKneeFunctionInfo->m_kneeNumKneePointsMinus1 = m_pcCfg->getKneeSEINumKneePointsMinus1();
     350    Int* piInputKneePoint  = m_pcCfg->getKneeSEIInputKneePoint();
     351    Int* piOutputKneePoint = m_pcCfg->getKneeSEIOutputKneePoint();
     352    if(piInputKneePoint&&piOutputKneePoint)
     353    {
     354      seiKneeFunctionInfo->m_kneeInputKneePoint.resize(seiKneeFunctionInfo->m_kneeNumKneePointsMinus1+1);
     355      seiKneeFunctionInfo->m_kneeOutputKneePoint.resize(seiKneeFunctionInfo->m_kneeNumKneePointsMinus1+1);
     356      for(Int i=0; i<=seiKneeFunctionInfo->m_kneeNumKneePointsMinus1; i++)
     357      {
     358        seiKneeFunctionInfo->m_kneeInputKneePoint[i] = piInputKneePoint[i];
     359        seiKneeFunctionInfo->m_kneeOutputKneePoint[i] = piOutputKneePoint[i];
     360       }
     361    }
     362  }
     363  return seiKneeFunctionInfo;
     364}
     365#endif
     366
    329367#if Q0074_SEI_COLOR_MAPPING
    330368SEIColorMappingInfo*  TEncGOP::xCreateSEIColorMappingInfo( Char* file )
     
    477515    delete sei;
    478516  }
     517#if P0050_KNEE_FUNCTION_SEI
     518  if(m_pcCfg->getKneeSEIEnabled())
     519  {
     520    SEIKneeFunctionInfo *sei = xCreateSEIKneeFunctionInfo();
     521
     522    nalu = NALUnit(NAL_UNIT_PREFIX_SEI);
     523    m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     524#if O0164_MULTI_LAYER_HRD
     525    m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, m_pcEncTop->getVPS(), sps);
     526#else
     527    m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);
     528#endif
     529    writeRBSPTrailingBits(nalu.m_Bitstream);
     530    accessUnit.push_back(new NALUnitEBSP(nalu));
     531    delete sei;
     532  }
     533#endif
    479534#if Q0074_SEI_COLOR_MAPPING
    480535  if(m_pcCfg->getColorMappingInfoSEIFile())
     
    554609  TEncSbac* pcSbacCoders = NULL;
    555610  TComOutputBitstream* pcSubstreamsOut = NULL;
     611#if Q0108_TSA_STSA
     612  Int flagTSTA = 0;
     613#endif
    556614
    557615  xInitGOP( iPOCLast, iNumPicRcvd, rcListPic, rcListPicYuvRecOut, isField );
     
    855913    }
    856914#endif
     915#if POC_RESET_IDC_ENCODER
     916    pcSlice->setPocValueBeforeReset( pocCurr );
     917    // Check if the current picture is to be assigned as a reset picture
     918    determinePocResetIdc(pocCurr, pcSlice);
     919
     920    // If reset, do the following steps:
     921    if( pcSlice->getPocResetIdc() )
     922    {
     923      updatePocValuesOfPics(pocCurr, pcSlice);
     924    }
     925    else
     926    {
     927      // Check the base layer picture is IDR. If so, just set current POC equal to 0 (alignment of POC)
     928      if( ( m_ppcTEncTop[0]->getGOPEncoder()->getIntraRefreshType() == 2) && ( pocCurr % m_ppcTEncTop[0]->getGOPEncoder()->getIntraRefreshInterval() == 0 ) )       
     929      {
     930        m_pcEncTop->setPocAdjustmentValue( pocCurr );
     931      }
     932      // else
     933      {
     934        // Just subtract POC by the current cumulative POC delta
     935        pcSlice->setPOC( pocCurr - m_pcEncTop->getPocAdjustmentValue() );
     936      }
     937
     938      Int maxPocLsb = 1 << pcSlice->getSPS()->getBitsForPOC();
     939      pcSlice->setPocMsbVal( pcSlice->getPOC() - ( pcSlice->getPOC() & (maxPocLsb-1) ) );
     940    }
     941    // Update the POC of current picture, pictures in the DPB, including references inside the reference pictures
     942
     943#endif
     944
    857945#if O0149_CROSS_LAYER_BLA_FLAG
    858946    if( m_layerId == 0 && (getNalUnitType(pocCurr, m_iLastIDR, isField) == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType(pocCurr, m_iLastIDR, isField) == NAL_UNIT_CODED_SLICE_IDR_N_LP) )
     
    10121100    if (m_layerId > 0)
    10131101    {
    1014     Int interLayerPredLayerIdcTmp[MAX_VPS_LAYER_ID_PLUS1];
    1015     Int activeNumILRRefIdxTmp = 0;
     1102      Int interLayerPredLayerIdcTmp[MAX_VPS_LAYER_ID_PLUS1];
     1103      Int activeNumILRRefIdxTmp = 0;
    10161104
    10171105      for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ )
    10181106      {
    10191107        UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i);
     1108        UInt refLayerId = pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc);
    10201109#if VPS_EXTN_DIRECT_REF_LAYERS
    10211110        TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId]->getRefLayerEnc(refLayerIdc)->getListPic();
     
    10411130
    10421131#if O0098_SCALED_REF_LAYER_ID
    1043         const Window &scalEL = m_pcEncTop->getScaledRefLayerWindowForLayer(pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc));
     1132        const Window &scalEL = m_pcEncTop->getScaledRefLayerWindowForLayer(refLayerId);
    10441133#else
    10451134        const Window &scalEL = m_pcEncTop->getScaledRefLayerWindow(refLayerIdc);
     
    10881177        }
    10891178#endif
    1090 #if SVC_UPSAMPLING
    1091         if( pcPic->isSpatialEnhLayer(refLayerIdc))
    1092         {
     1179#if SVC_EXTENSION
     1180        if( pcPic->isSpatialEnhLayer(refLayerIdc) )
     1181        {
     1182          // check for the sample prediction picture type
     1183          if( m_ppcTEncTop[m_layerId]->getSamplePredEnabledFlag(refLayerId) )
     1184          {
    10931185#if P0312_VERT_PHASE_ADJ
    1094           //when PhasePositionEnableFlag is equal to 1, set vertPhasePositionFlag to 0 if BL is top field and 1 if bottom
    1095           if( scalEL.getVertPhasePositionEnableFlag() )
    1096           {
    1097             pcSlice->setVertPhasePositionFlag( pcSlice->getPOC()%2, refLayerIdc );
    1098           }
     1186            //when PhasePositionEnableFlag is equal to 1, set vertPhasePositionFlag to 0 if BL is top field and 1 if bottom
     1187            if( scalEL.getVertPhasePositionEnableFlag() )
     1188            {
     1189              pcSlice->setVertPhasePositionFlag( pcSlice->getPOC()%2, refLayerIdc );
     1190            }
    10991191#endif
    11001192#if O0215_PHASE_ALIGNMENT
    11011193#if O0194_JOINT_US_BITSHIFT
    11021194#if Q0048_CGS_3D_ASYMLUT
    1103           m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() );
    1104 #else
    1105           m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() );
     1195            m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() );
     1196#else
     1197            m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() );
    11061198#endif
    11071199#else
    11081200#if Q0048_CGS_3D_ASYMLUT
    1109           m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() );
    1110 #else
    1111           m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() );
     1201            m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() );
     1202#else
     1203            m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() );
    11121204#endif
    11131205#endif
     
    11151207#if O0194_JOINT_US_BITSHIFT
    11161208#if Q0048_CGS_3D_ASYMLUT
    1117           m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL );
    1118 #else
    1119           m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL );
     1209            m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL );
     1210#else
     1211            m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL );
    11201212#endif
    11211213#else
    11221214#if Q0048_CGS_3D_ASYMLUT
    1123           m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL );
    1124 #else
    1125           m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL );
    1126 #endif
    1127 #endif
    1128 #endif
     1215            m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL );
     1216#else
     1217            m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL );
     1218#endif
     1219#endif
     1220#endif
     1221          }
    11291222        }
    11301223        else
     
    11371230        }
    11381231        pcSlice->setFullPelBaseRec ( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc) );
    1139 #endif
     1232#endif //SVC_EXTENSION
    11401233      }
    11411234
     
    11541247        pcSlice->setInterLayerPredEnabledFlag(false);
    11551248      }
    1156      
     1249
    11571250      if( pocCurr % m_pcCfg->getIntraPeriod() == 0 )
    11581251      {
    1159 #if N0147_IRAP_ALIGN_FLAG
    11601252        if(pcSlice->getVPS()->getCrossLayerIrapAlignFlag())
    11611253        {
     
    11721264        }
    11731265        else
    1174 #endif
    1175         pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_CRA);
    1176 
    1177 #if IDR_ALIGNMENT
    1178         TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId]->getRefLayerEnc(0)->getListPic();
    1179         TComPic* picLayer0 = pcSlice->getRefPic(*cListPic, pcSlice->getPOC() );
    1180         if( picLayer0->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || picLayer0->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP )
    1181         {
    1182           pcSlice->setNalUnitType(picLayer0->getSlice(0)->getNalUnitType());
    1183         }
    1184         else
    1185         {
     1266        {
     1267#if !ALIGN_IRAP_BUGFIX
    11861268          pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_CRA);
    1187         }
    1188 #endif
    1189       }
    1190      
     1269#endif
     1270        }
     1271      }
     1272
    11911273      if( pcSlice->getActiveNumILRRefIdx() == 0 && pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA )
    11921274      {
     
    11961278      {
    11971279        if( (pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP) &&
    1198            (pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) &&
    1199            pcSlice->getSliceType() == B_SLICE )
     1280          (pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) &&
     1281          pcSlice->getSliceType() == B_SLICE )
    12001282        {
    12011283          pcSlice->setSliceType(P_SLICE);
    12021284        }
    1203       }
     1285      }     
    12041286    }
    12051287#endif //#if SVC_EXTENSION
     
    12071289    {
    12081290      if (pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_R &&
     1291#if SVC_EXTENSION
     1292        ( m_iGopSize != 1 || m_ppcTEncTop[m_layerId]->getIntraPeriod() > 1 ) )
     1293#else
    12091294          !(m_iGopSize == 1 && pcSlice->getSliceType() == I_SLICE))
     1295#endif
    12101296        // Add this condition to avoid POC issues with encoder_intra_main.cfg configuration (see #1127 in bug tracker)
    12111297      {
     
    12321318    {
    12331319      m_associatedIRAPType = pcSlice->getNalUnitType();
     1320#if POC_RESET_IDC_ENCODER
     1321      m_associatedIRAPPOC = pcSlice->getPOC();
     1322      m_associatedIrapPocBeforeReset = pocCurr;
     1323#else
    12341324      m_associatedIRAPPOC = pocCurr;
     1325#endif
    12351326    }
    12361327    pcSlice->setAssociatedIRAPType(m_associatedIRAPType);
    12371328    pcSlice->setAssociatedIRAPPOC(m_associatedIRAPPOC);
     1329#if POC_RESET_IDC_ENCODER
     1330    pcSlice->setAssociatedIrapPocBeforeReset(m_associatedIrapPocBeforeReset);
     1331#endif
    12381332#endif
    12391333#endif
     
    12431337#else
    12441338    pcSlice->decodingRefreshMarking(m_pocCRA, m_bRefreshPending, rcListPic);
     1339#endif
     1340#if POC_RESET_IDC_ENCODER
     1341    // m_pocCRA may have been update here; update m_pocCraWithoutReset
     1342    m_pocCraWithoutReset = m_pocCRA + m_pcEncTop->getPocAdjustmentValue();
    12451343#endif
    12461344    m_pcEncTop->selectReferencePictureSet(pcSlice, pocCurr, iGOPid);
     
    12801378#endif
    12811379#if ALIGNED_BUMPING
     1380#if POC_RESET_IDC_ENCODER
     1381    pcSlice->checkLeadingPictureRestrictions(rcListPic, true);
     1382#else
    12821383    pcSlice->checkLeadingPictureRestrictions(rcListPic);
     1384#endif
    12831385#endif
    12841386    pcSlice->applyReferencePictureSet(rcListPic, pcSlice->getRPS());
     
    12931395      if(pcSlice->isTemporalLayerSwitchingPoint(rcListPic) || pcSlice->getSPS()->getTemporalIdNestingFlag())
    12941396      {
    1295 #if ALIGN_TSA_STSA_PICS
     1397#if !Q0108_TSA_STSA
    12961398        if( pcSlice->getLayerId() > 0 )
    12971399        {
     
    13921494        if(isSTSA==true)
    13931495        {   
    1394 #if ALIGN_TSA_STSA_PICS
     1496#if !Q0108_TSA_STSA
    13951497          if( pcSlice->getLayerId() > 0 )
    13961498          {
     
    14611563      }
    14621564    }
     1565#if Q0108_TSA_STSA
     1566    else if( ( pcSlice->getTLayer() == 0 && pcSlice->getLayerId() > 0)    // only for enhancement layer and with temporal layer 0
     1567       && !( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N     
     1568          || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_R
     1569          || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N
     1570          || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R
     1571          || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL
     1572          || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP
     1573          || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA
     1574          )
     1575        )
     1576    {
     1577        Bool isSTSA=true;
     1578        for(Int ii=iGOPid+1; ii < m_pcCfg->getGOPSize() && isSTSA; ii++)
     1579        {
     1580          Int lTid= m_pcCfg->getGOPEntry(ii).m_temporalId;
     1581          if(lTid==pcSlice->getTLayer())
     1582          {
     1583            TComReferencePictureSet* nRPS = pcSlice->getSPS()->getRPSList()->getReferencePictureSet(ii);
     1584            for(Int jj=0; jj<nRPS->getNumberOfPictures(); jj++)
     1585            {
     1586              if(nRPS->getUsed(jj))
     1587              {
     1588                Int tPoc=m_pcCfg->getGOPEntry(ii).m_POC+nRPS->getDeltaPOC(jj);
     1589                Int kk=0;
     1590                for(kk=0; kk<m_pcCfg->getGOPSize(); kk++)
     1591                {
     1592                  if(m_pcCfg->getGOPEntry(kk).m_POC==tPoc)
     1593                  {
     1594                    break;
     1595                  }
     1596                }
     1597                Int tTid=m_pcCfg->getGOPEntry(kk).m_temporalId;
     1598                if(tTid >= pcSlice->getTLayer())
     1599                {
     1600                  isSTSA = false;
     1601                  break;
     1602                }
     1603              }
     1604            }
     1605          }
     1606        }
     1607        if(isSTSA==true)
     1608        {   
     1609#if !Q0108_TSA_STSA
     1610          if( pcSlice->getLayerId() > 0 )
     1611          {
     1612            Bool oneRefLayerSTSA = false, oneRefLayerNotSTSA = false;
     1613            for( Int i = 0; i < pcSlice->getLayerId(); i++)
     1614            {
     1615              TComList<TComPic *> *cListPic = m_ppcTEncTop[i]->getListPic();
     1616              TComPic *lowerLayerPic = pcSlice->getRefPic(*cListPic, pcSlice->getPOC());
     1617              if( lowerLayerPic && pcSlice->getVPS()->getDirectDependencyFlag(pcSlice->getLayerId(), i) )
     1618              {
     1619                if( ( lowerLayerPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N ) ||
     1620                    ( lowerLayerPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_R )
     1621                  )
     1622                {
     1623                  if(pcSlice->getTemporalLayerNonReferenceFlag() )
     1624                  {
     1625                    pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_STSA_N);
     1626                  }
     1627                  else
     1628                  {
     1629                    pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_STSA_R );
     1630                  }
     1631                  oneRefLayerSTSA = true;
     1632                }
     1633                else
     1634                {
     1635                  oneRefLayerNotSTSA = true;
     1636                }
     1637              }
     1638            }
     1639            assert( !( oneRefLayerNotSTSA && oneRefLayerSTSA ) ); // Only one variable should be true - failure of this assert means
     1640                                                                  // that two independent reference layers that are not dependent on
     1641                                                                  // each other, but are reference for current layer have inconsistency
     1642            if( oneRefLayerNotSTSA /*&& !oneRefLayerSTSA*/ )          // No reference layer is STSA - set current as TRAIL
     1643            {
     1644              if(pcSlice->getTemporalLayerNonReferenceFlag() )
     1645              {
     1646                pcSlice->setNalUnitType( NAL_UNIT_CODED_SLICE_TRAIL_N );
     1647              }
     1648              else
     1649              {
     1650                pcSlice->setNalUnitType( NAL_UNIT_CODED_SLICE_TRAIL_R );
     1651              }
     1652            }
     1653            else  // This means there is no reference layer picture for current picture in this AU
     1654            {
     1655              if(pcSlice->getTemporalLayerNonReferenceFlag() )
     1656              {
     1657                pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_STSA_N);
     1658              }
     1659              else
     1660              {
     1661                pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_STSA_R );
     1662              }
     1663            }
     1664          }
     1665#else
     1666          if(pcSlice->getTemporalLayerNonReferenceFlag())
     1667          {
     1668            pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_STSA_N);
     1669            flagTSTA = 1;
     1670          }
     1671          else
     1672          {
     1673            pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_STSA_R);
     1674            flagTSTA = 1;
     1675          }
     1676#endif
     1677        }
     1678    }
     1679#endif
     1680
    14631681    arrangeLongtermPicturesInRPS(pcSlice, rcListPic);
    14641682    TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification();
     
    14711689    if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() )
    14721690    {
    1473 #if POC_RESET_FLAG
    1474       if ( pocCurr > 0          && pcSlice->isRADL() && pcPic->getSlice(0)->getBaseColPic(pcPic->getSlice(0)->getInterLayerPredLayerIdc(0))->getSlice(0)->isRASL())
     1691#if POC_RESET_FLAG || POC_RESET_IDC_ENCODER
     1692      if ( pocCurr > 0 && pcSlice->isRADL() && pcPic->getSlice(0)->getBaseColPic(pcPic->getSlice(0)->getInterLayerPredLayerIdc(0))->getSlice(0)->isRASL())
    14751693#else
    14761694      if (pcSlice->getPOC()>0  && pcSlice->isRADL() && pcPic->getSlice(0)->getBaseColPic(pcPic->getSlice(0)->getInterLayerPredLayerIdc(0))->getSlice(0)->isRASL())
     
    14801698        pcSlice->setInterLayerPredEnabledFlag(0);
    14811699      }
    1482       if( pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA )
     1700#if Q0108_TSA_STSA
     1701     if( ( pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA ) || flagTSTA == 1 )
     1702#else
     1703     if( pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA )
     1704#endif
    14831705      {
    14841706        pcSlice->setNumRefIdx(REF_PIC_LIST_0, pcSlice->getActiveNumILRRefIdx());
     
    14891711        pcSlice->setNumRefIdx(REF_PIC_LIST_0, pcSlice->getNumRefIdx(REF_PIC_LIST_0)+pcSlice->getActiveNumILRRefIdx());
    14901712        pcSlice->setNumRefIdx(REF_PIC_LIST_1, pcSlice->getNumRefIdx(REF_PIC_LIST_1)+pcSlice->getActiveNumILRRefIdx());
     1713      }
     1714
     1715      // check for the reference pictures whether there is at least one either temporal picture or ILRP with sample prediction type
     1716      if( pcSlice->getNumRefIdx( REF_PIC_LIST_0 ) - pcSlice->getActiveNumILRRefIdx() == 0 && pcSlice->getNumRefIdx( REF_PIC_LIST_1 ) - pcSlice->getActiveNumILRRefIdx() == 0 )
     1717      {
     1718        Bool foundSamplePredPicture = false;               
     1719
     1720        for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ )
     1721        {
     1722          if( m_ppcTEncTop[m_layerId]->getSamplePredEnabledFlag( pcSlice->getVPS()->getRefLayerId( m_layerId, pcSlice->getInterLayerPredLayerIdc(i) ) ) )
     1723          {
     1724            foundSamplePredPicture = true;
     1725            break;
     1726          }
     1727        }
     1728
     1729        if( !foundSamplePredPicture )
     1730        {
     1731          pcSlice->setSliceType(I_SLICE);
     1732          pcSlice->setInterLayerPredEnabledFlag(0);
     1733          pcSlice->setActiveNumILRRefIdx(0);
     1734        }
    14911735      }
    14921736    }
     
    15201764      //  Set reference list
    15211765      pcSlice->setRefPicList ( rcListPic );
    1522 #endif //SVC_EXTENSION
     1766#endif
    15231767      pcSlice->setRefPicListModificationSvc();
    15241768      pcSlice->setRefPicList( rcListPic, false, m_pcEncTop->getIlpList());
     
    15321776
    15331777        for(Int colIdx = 0; colIdx < pcSlice->getNumRefIdx( RefPicList(1 - ColFromL0Flag) ); colIdx++)
    1534         {
    1535           if( pcSlice->getRefPic( RefPicList(1 - ColFromL0Flag), colIdx)->isILR(m_layerId)
     1778        {
     1779          RefPicList refList = RefPicList(1 - ColFromL0Flag);
     1780          TComPic* refPic = pcSlice->getRefPic(refList, colIdx);
     1781
     1782          // It is a requirement of bitstream conformance when the collocated picture, used for temporal motion vector prediction, is an inter-layer reference picture,
     1783          // VpsInterLayerMotionPredictionEnabled[ LayerIdxInVps[ currLayerId ] ][ LayerIdxInVps[ rLId ] ] shall be equal to 1, where rLId is set equal to nuh_layer_id of the inter-layer picture.
     1784          if( refPic->isILR(m_layerId) && m_ppcTEncTop[m_layerId]->getMotionPredEnabledFlag( refPic->getLayerId() )
    15361785#if MFM_ENCCONSTRAINT
    1537             && pcSlice->getBaseColPic( *m_ppcTEncTop[pcSlice->getRefPic( RefPicList(1 - ColFromL0Flag), colIdx)->getLayerId()]->getListPic() )->checkSameRefInfo() == true
     1786            && pcSlice->getBaseColPic( *m_ppcTEncTop[refPic->getLayerId()]->getListPic() )->checkSameRefInfo() == true
    15381787#endif
    15391788            )
     
    15491798          ColFromL0Flag = 1 - ColFromL0Flag;
    15501799          for(Int colIdx = 0; colIdx < pcSlice->getNumRefIdx( RefPicList(1 - ColFromL0Flag) ); colIdx++)
    1551           {
    1552             if( pcSlice->getRefPic( RefPicList(1 - ColFromL0Flag), colIdx)->isILR(m_layerId)
     1800          {
     1801            RefPicList refList = RefPicList(1 - ColFromL0Flag);
     1802            TComPic* refPic = pcSlice->getRefPic(refList, colIdx);
     1803
     1804            // It is a requirement of bitstream conformance when the collocated picture, used for temporal motion vector prediction, is an inter-layer reference picture,
     1805            // VpsInterLayerMotionPredictionEnabled[ LayerIdxInVps[ currLayerId ] ][ LayerIdxInVps[ rLId ] ] shall be equal to 1, where rLId is set equal to nuh_layer_id of the inter-layer picture.
     1806            if( refPic->isILR(m_layerId) && m_ppcTEncTop[m_layerId]->getMotionPredEnabledFlag( refPic->getLayerId() )
    15531807#if MFM_ENCCONSTRAINT
    1554               && pcSlice->getBaseColPic( *m_ppcTEncTop[pcSlice->getRefPic( RefPicList(1 - ColFromL0Flag), colIdx)->getLayerId()]->getListPic() )->checkSameRefInfo() == true
     1808              && pcSlice->getBaseColPic( *m_ppcTEncTop[refPic->getLayerId()]->getListPic() )->checkSameRefInfo() == true
    15551809#endif
    15561810              )
     
    16501904      pcSlice->setEnableTMVPFlag(0);
    16511905    }
     1906
     1907#if SVC_EXTENSION
     1908    if( m_layerId > 0 && !pcSlice->isIntra() )
     1909    {
     1910      Int colFromL0Flag = 1;
     1911      Int colRefIdx = 0;
     1912
     1913      // check whether collocated picture is valid
     1914      if( pcSlice->getEnableTMVPFlag() )
     1915      {
     1916        colFromL0Flag = pcSlice->getColFromL0Flag();
     1917        colRefIdx = pcSlice->getColRefIdx();
     1918
     1919        TComPic* refPic = pcSlice->getRefPic(RefPicList(1-colFromL0Flag), colRefIdx);
     1920
     1921        assert( refPic );
     1922
     1923        // It is a requirement of bitstream conformance when the collocated picture, used for temporal motion vector prediction, is an inter-layer reference picture,
     1924        // VpsInterLayerMotionPredictionEnabled[ LayerIdxInVps[ currLayerId ] ][ LayerIdxInVps[ rLId ] ] shall be equal to 1, where rLId is set equal to nuh_layer_id of the inter-layer picture.
     1925        if( refPic->isILR(m_layerId) && !m_ppcTEncTop[m_layerId]->getMotionPredEnabledFlag(refPic->getLayerId()) )
     1926        {
     1927          pcSlice->setEnableTMVPFlag(false);
     1928          pcSlice->setMFMEnabledFlag(false);
     1929          colRefIdx = 0;
     1930        }
     1931      }
     1932
     1933      // remove motion only ILRP from the end of the colFromL0Flag reference picture list
     1934      RefPicList refList = RefPicList(colFromL0Flag);
     1935      Int numRefIdx = pcSlice->getNumRefIdx(refList);
     1936
     1937      if( numRefIdx > 0 )
     1938      {
     1939        for( Int refIdx = pcSlice->getNumRefIdx(refList) - 1; refIdx > 0; refIdx-- )
     1940        {
     1941          TComPic* refPic = pcSlice->getRefPic(refList, refIdx);
     1942
     1943          if( !refPic->isILR(m_layerId) || ( refPic->isILR(m_layerId) && m_ppcTEncTop[m_layerId]->getSamplePredEnabledFlag( refPic->getLayerId() ) ) )
     1944          {
     1945            break;
     1946          }
     1947          else
     1948          {
     1949            assert( numRefIdx > 1 );
     1950            numRefIdx--;             
     1951          }
     1952        }
     1953
     1954        pcSlice->setNumRefIdx( refList, numRefIdx );
     1955      }
     1956
     1957      // remove motion only ILRP from the end of the (1-colFromL0Flag) reference picture list up to colRefIdx
     1958      refList = RefPicList(1 - colFromL0Flag);
     1959      numRefIdx = pcSlice->getNumRefIdx(refList);
     1960
     1961      if( numRefIdx > 0 )
     1962      {
     1963        for( Int refIdx = pcSlice->getNumRefIdx(refList) - 1; refIdx > colRefIdx; refIdx-- )
     1964        {
     1965          TComPic* refPic = pcSlice->getRefPic(refList, refIdx);
     1966
     1967          if( !refPic->isILR(m_layerId) || ( refPic->isILR(m_layerId) && m_ppcTEncTop[m_layerId]->getSamplePredEnabledFlag( refPic->getLayerId() ) ) )
     1968          {
     1969            break;
     1970          }
     1971          else
     1972          {
     1973            assert( numRefIdx > 1 );
     1974            numRefIdx--;             
     1975          }
     1976        }
     1977
     1978        pcSlice->setNumRefIdx( refList, numRefIdx );
     1979      }
     1980
     1981      assert( pcSlice->getNumRefIdx(REF_PIC_LIST_0) > 0 && ( pcSlice->isInterP() || (pcSlice->isInterB() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) > 0) ) );
     1982    }
     1983#endif
     1984
    16521985    /////////////////////////////////////////////////////////////////////////////////////////////////// Compress a slice
    16531986    //  Slice compression
     
    17002033
    17012034      Int sliceQP = m_pcCfg->getInitialQP();
    1702 #if POC_RESET_FLAG
     2035#if POC_RESET_FLAG || POC_RESET_IDC_ENCODER
    17032036      if ( ( pocCurr == 0 && m_pcCfg->getInitialQP() > 0 ) || ( frameLevel == 0 && m_pcCfg->getForceIntraQP() ) ) // QP is specified
    17042037#else
     
    19832316    {
    19842317#if SVC_EXTENSION
    1985 #if VPS_NUH_LAYER_ID
    1986       OutputNALUnit nalu(NAL_UNIT_VPS, 0, 0        ); // The value of nuh_layer_id of VPS NAL unit shall be equal to 0.
    1987 #else
    1988       OutputNALUnit nalu(NAL_UNIT_VPS, 0, m_layerId);
    1989 #endif
     2318      OutputNALUnit nalu( NAL_UNIT_VPS, 0, 0 ); // The value of nuh_layer_id of VPS NAL unit shall be equal to 0.
    19902319#if AVC_BASE
    19912320      if( ( m_layerId == 1 && m_pcEncTop->getVPS()->getAvcBaseLayerFlag() ) || ( m_layerId == 0 && !m_pcEncTop->getVPS()->getAvcBaseLayerFlag() ) )
     
    20212350      nalu = NALUnit(NAL_UNIT_SPS);
    20222351#endif
     2352#if Q0078_ADD_LAYER_SETS
     2353      if (m_pcEncTop->getVPS()->getNumDirectRefLayers(m_layerId) == 0 && m_pcEncTop->getVPS()->getNumAddLayerSets() > 0)
     2354      {
     2355        nalu.m_layerId = 0; // For independent base layer rewriting
     2356      }
     2357#endif
    20232358      m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    20242359      if (m_bSeqFirst)
     
    20582393#else
    20592394      nalu = NALUnit(NAL_UNIT_PPS);
     2395#endif
     2396#if Q0078_ADD_LAYER_SETS
     2397      if (m_pcEncTop->getVPS()->getNumDirectRefLayers(m_layerId) == 0 && m_pcEncTop->getVPS()->getNumAddLayerSets() > 0)
     2398      {
     2399        nalu.m_layerId = 0; // For independent base layer rewriting
     2400      }
    20602401#endif
    20612402      m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     
    21552496      writeSOP = false;
    21562497    }
     2498#if Q0189_TMVP_CONSTRAINTS
     2499   if( m_pcEncTop->getTMVPConstraintsSEIEnabled() == 1 &&
     2500      (m_pcEncTop->getTMVPModeId() == 1 || m_pcEncTop->getTMVPModeId() == 2) &&
     2501      pcSlice->getLayerId() >0 &&
     2502      (pcSlice->getNalUnitType() ==  NAL_UNIT_CODED_SLICE_IDR_W_RADL || pcSlice->getNalUnitType() ==  NAL_UNIT_CODED_SLICE_IDR_N_LP))
     2503   {
     2504      OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
     2505      SEITMVPConstrains seiTMVPConstrains;
     2506      m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
     2507      m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     2508      seiTMVPConstrains.no_intra_layer_col_pic_flag = 1;
     2509      seiTMVPConstrains.prev_pics_not_used_flag = 1;
     2510#if   O0164_MULTI_LAYER_HRD
     2511      m_seiWriter.writeSEImessage( nalu.m_Bitstream, seiTMVPConstrains, m_pcEncTop->getVPS(), pcSlice->getSPS() );
     2512#else
     2513      m_seiWriter.writeSEImessage( nalu.m_Bitstream, seiTMVPConstrains, pcSlice->getSPS() );
     2514#endif
     2515      writeRBSPTrailingBits(nalu.m_Bitstream);
     2516      accessUnit.push_back(new NALUnitEBSP(nalu));
     2517   }
     2518#endif
     2519#if Q0247_FRAME_FIELD_INFO
     2520    if(  pcSlice->getLayerId()> 0 &&
     2521     ( (m_pcCfg->getProgressiveSourceFlag() && m_pcCfg->getInterlacedSourceFlag()) || m_pcCfg->getFrameFieldInfoPresentFlag()))
     2522    {
     2523      OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
     2524      SEIFrameFieldInfo seiFFInfo;
     2525      m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
     2526      m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     2527      seiFFInfo.m_ffinfo_picStruct = (isField && pcSlice->getPic()->isTopField())? 1 : isField? 2 : 0;
     2528#if   O0164_MULTI_LAYER_HRD
     2529      m_seiWriter.writeSEImessage( nalu.m_Bitstream, seiFFInfo, m_pcEncTop->getVPS(), pcSlice->getSPS() );
     2530#else
     2531      m_seiWriter.writeSEImessage( nalu.m_Bitstream, seiFFInfo, pcSlice->getSPS() );
     2532#endif
     2533      writeRBSPTrailingBits(nalu.m_Bitstream);
     2534      accessUnit.push_back(new NALUnitEBSP(nalu));
     2535    }
     2536#endif
    21572537
    21582538    if( ( m_pcCfg->getPictureTimingSEIEnabled() || m_pcCfg->getDecodingUnitInfoSEIEnabled() ) &&
     
    21852565      }
    21862566      pictureTimingSEI.m_auCpbRemovalDelay = std::min<Int>(std::max<Int>(1, m_totalCoded - m_lastBPSEI), static_cast<Int>(pow(2, static_cast<double>(pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getCpbRemovalDelayLengthMinus1()+1)))); // Syntax element signalled as minus, hence the .
    2187 #if POC_RESET_FLAG
     2567#if POC_RESET_FLAG || POC_RESET_IDC_ENCODER
    21882568      pictureTimingSEI.m_picDpbOutputDelay = pcSlice->getSPS()->getNumReorderPics(pcSlice->getSPS()->getMaxTLayers()-1) + pocCurr - m_totalCoded;
    21892569#else
     
    23132693      SEIRecoveryPoint sei_recovery_point;
    23142694      sei_recovery_point.m_recoveryPocCnt    = 0;
    2315 #if POC_RESET_FLAG
     2695#if POC_RESET_FLAG || POC_RESET_IDC_ENCODER
    23162696      sei_recovery_point.m_exactMatchingFlag = ( pocCurr == 0 ) ? (true) : (false);
    23172697#else
     
    30683448#endif
    30693449}
     3450
     3451#if POC_RESET_IDC_ENCODER
     3452Void TEncGOP::determinePocResetIdc(Int const pocCurr, TComSlice *const slice)
     3453{
     3454  // If one picture in the AU is IDR, and another picture is not IDR, set the poc_reset_idc to 1 or 2
     3455  // If BL picture in the AU is IDR, and another picture is not IDR, set the poc_reset_idc to 2
     3456  // If BL picture is IRAP, and another picture is non-IRAP, then the poc_reset_idc is equal to 1 or 2.
     3457  if( slice->getSliceIdx() == 0 ) // First slice - compute, copy for other slices
     3458  {
     3459    Int needReset = false;
     3460    Int resetDueToBL = false;
     3461    if( slice->getVPS()->getMaxLayers() > 1 )
     3462    {
     3463      // If IRAP is refreshed in this access unit for base layer
     3464      if( (m_ppcTEncTop[0]->getGOPEncoder()->getIntraRefreshType() == 1 || m_ppcTEncTop[0]->getGOPEncoder()->getIntraRefreshType() == 2)
     3465        && ( pocCurr % m_ppcTEncTop[0]->getGOPEncoder()->getIntraRefreshInterval() == 0 )
     3466        )
     3467      {
     3468        // Check if the IRAP refresh interval of any layer does not match that of the base layer
     3469        for(Int i = 1; i < slice->getVPS()->getMaxLayers(); i++)
     3470        {
     3471          Bool refreshIntervalFlag = ( pocCurr % m_ppcTEncTop[i]->getGOPEncoder()->getIntraRefreshInterval() == 0 );
     3472          Bool refreshTypeFlag     = ( m_ppcTEncTop[0]->getGOPEncoder()->getIntraRefreshType() == m_ppcTEncTop[i]->getGOPEncoder()->getIntraRefreshType() );
     3473          if( !(refreshIntervalFlag && refreshTypeFlag) )
     3474          {
     3475            needReset = true;
     3476            resetDueToBL = true;
     3477            break;
     3478          }
     3479        }
     3480      }
     3481    }
     3482   
     3483    if( !needReset )// No need reset due to base layer IRAP
     3484    {
     3485      // Check if EL IDRs results in POC Reset
     3486      for(Int i = 1; i < slice->getVPS()->getMaxLayers() && !needReset; i++)
     3487      {
     3488        Bool idrFlag = ( (m_ppcTEncTop[i]->getGOPEncoder()->getIntraRefreshType() == 2)
     3489                        && ( pocCurr % m_ppcTEncTop[i]->getGOPEncoder()->getIntraRefreshInterval() == 0 )
     3490                        );
     3491        for(Int j = 0; j < slice->getVPS()->getMaxLayers(); j++)
     3492        {
     3493          if( j == i )
     3494          {
     3495            continue;
     3496          }
     3497          Bool idrOtherPicFlag = ( (m_ppcTEncTop[j]->getGOPEncoder()->getIntraRefreshType() == 2)
     3498                                  && ( pocCurr % m_ppcTEncTop[j]->getGOPEncoder()->getIntraRefreshInterval() == 0 )
     3499                                  );
     3500
     3501          if( idrFlag != idrOtherPicFlag )
     3502          {
     3503            needReset = true;
     3504            break;
     3505          }
     3506        }
     3507      }
     3508    }
     3509    if( needReset )
     3510    {
     3511      if( m_ppcTEncTop[0]->getGOPEncoder()->getIntraRefreshType() == 2 )  // BL IDR refresh, assuming BL picture present
     3512      {
     3513        if( resetDueToBL )
     3514        {
     3515          slice->setPocResetIdc( 2 ); // Full reset needed
     3516        }
     3517        else
     3518        {
     3519          slice->setPocResetIdc( 1 ); // Due to IDR in EL
     3520        }
     3521      }
     3522      else
     3523      {
     3524        slice->setPocResetIdc( 1 ); // Only MSB reset
     3525      }
     3526
     3527      // Start a new POC reset period
     3528      if (m_layerId == 0)   // Assuming BL picture is always present at encoder; for other AU structures, need to change this
     3529      {
     3530        Int periodId = rand() % 64;
     3531        m_lastPocPeriodId = (periodId == m_lastPocPeriodId) ? (periodId + 1) % 64 : periodId ;
     3532      }
     3533      else
     3534      {
     3535        m_lastPocPeriodId = m_ppcTEncTop[0]->getGOPEncoder()->getLastPocPeriodId();
     3536      }
     3537      slice->setPocResetPeriodId(m_lastPocPeriodId);
     3538    }
     3539    else
     3540    {
     3541      slice->setPocResetIdc( 0 );
     3542    }
     3543  }
     3544}
     3545
     3546Void TEncGOP::updatePocValuesOfPics(Int const pocCurr, TComSlice *const slice)
     3547{
     3548
     3549  Int pocAdjustValue = pocCurr - m_pcEncTop->getPocAdjustmentValue();
     3550
     3551  // New POC reset period
     3552  Int maxPocLsb, pocLsbVal, pocMsbDelta, pocLsbDelta, deltaPocVal;
     3553
     3554  maxPocLsb   = 1 << slice->getSPS()->getBitsForPOC();
     3555  pocLsbVal   = (slice->getPocResetIdc() == 3)
     3556                ? slice->getPocLsbVal()
     3557                : pocAdjustValue % maxPocLsb;
     3558  pocMsbDelta = pocAdjustValue - pocLsbVal;
     3559  pocLsbDelta = (slice->getPocResetIdc() == 2 || ( slice->getPocResetIdc() == 3 && slice->getFullPocResetFlag() ))
     3560                ? pocLsbVal
     3561                : 0;
     3562  deltaPocVal = pocMsbDelta  + pocLsbDelta;
     3563 
     3564  // Decrement value of associatedIrapPoc of the TEncGop object
     3565  this->m_associatedIRAPPOC -= deltaPocVal;
     3566
     3567  // Decrememnt the value of m_pocCRA
     3568  this->m_pocCRA -= deltaPocVal;
     3569
     3570  // Iterate through all pictures in the DPB
     3571  TComList<TComPic*>::iterator  iterPic = getListPic()->begin(); 
     3572  while( iterPic != getListPic()->end() )
     3573  {
     3574    TComPic *dpbPic = *iterPic;
     3575   
     3576    if( dpbPic->getReconMark() )
     3577    {
     3578      for(Int i = dpbPic->getNumAllocatedSlice() - 1; i >= 0; i--)
     3579      {
     3580        TComSlice *dpbPicSlice = dpbPic->getSlice( i );
     3581        TComReferencePictureSet *dpbPicRps = dpbPicSlice->getRPS();
     3582
     3583        // Decrement POC of slice
     3584        dpbPicSlice->setPOC( dpbPicSlice->getPOC() - deltaPocVal );
     3585
     3586        // Decrement POC value stored in the RPS of each such slice
     3587        for( Int j = dpbPicRps->getNumberOfPictures() - 1; j >= 0; j-- )
     3588        {
     3589          dpbPicRps->setPOC( j, dpbPicRps->getPOC(j) - deltaPocVal );
     3590        }
     3591
     3592        // Decrement value of refPOC
     3593        dpbPicSlice->decrementRefPocValues( deltaPocVal );
     3594
     3595        // Update value of associatedIrapPoc of each slice
     3596        dpbPicSlice->setAssociatedIRAPPOC( dpbPicSlice->getAssociatedIRAPPOC() - deltaPocVal );
     3597      }
     3598    }
     3599    iterPic++;
     3600  }
     3601 
     3602  // Actual POC value before reset
     3603  Int adjustedPocValue = pocCurr - m_pcEncTop->getPocAdjustmentValue();
     3604
     3605  // Set MSB value before reset
     3606  Int tempLsbVal = adjustedPocValue & (maxPocLsb - 1);
     3607  slice->setPocMsbVal( adjustedPocValue - tempLsbVal);
     3608
     3609  // Set LSB value before reset - this is needed in the case of resetIdc = 2
     3610  slice->setPicOrderCntLsb( tempLsbVal );
     3611
     3612  // Cumulative delta
     3613  m_pcEncTop->setPocAdjustmentValue( m_pcEncTop->getPocAdjustmentValue() + deltaPocVal );
     3614
     3615  // New LSB value, after reset
     3616  adjustedPocValue = pocCurr - m_pcEncTop->getPocAdjustmentValue();
     3617  Int newLsbVal = adjustedPocValue & (maxPocLsb - 1);
     3618
     3619  // Set value of POC current picture after RESET
     3620  if( slice->getPocResetIdc() == 1 )
     3621  {
     3622    slice->setPOC( newLsbVal );
     3623  }
     3624  else if( slice->getPocResetIdc() == 2 )
     3625  {
     3626    slice->setPOC( 0 );
     3627  }
     3628  else if( slice->getPocResetIdc() == 3 )
     3629  {
     3630    Int picOrderCntMsb = slice->getCurrMsb( newLsbVal,
     3631                                        slice->getFullPocResetFlag() ? 0 : slice->getPocLsbVal(),
     3632                                        0,
     3633                                        maxPocLsb );
     3634    slice->setPOC( picOrderCntMsb + newLsbVal );
     3635  }
     3636  else
     3637  {
     3638    assert(0);
     3639  }
     3640}
     3641#endif
     3642
    30703643
    30713644#if !SVC_EXTENSION
     
    35164089      if( pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->isILR(m_layerId) )
    35174090      {
     4091#if POC_RESET_IDC_ENCODER
     4092        printf( "%d(%d)", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex), pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->getLayerId() );
     4093#else
    35184094        printf( "%d(%d)", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex)-pcSlice->getLastIDR(), pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->getLayerId() );
     4095#endif
    35194096      }
    35204097      else
    35214098      {
     4099#if POC_RESET_IDC_ENCODER
     4100        printf ("%d", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex));
     4101#else
    35224102        printf ("%d", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex)-pcSlice->getLastIDR());
     4103#endif
    35234104      }
    35244105#endif
     
    37474328    }
    37484329  }
     4330
     4331#if POC_RESET_IDC_ENCODER
     4332  if(m_pocCraWithoutReset > 0 && this->m_associatedIRAPType == NAL_UNIT_CODED_SLICE_CRA)
     4333  {
     4334    if(pocCurr < m_pocCraWithoutReset)
     4335#else
    37494336  if(m_pocCRA>0)
    37504337  {
    37514338    if(pocCurr<m_pocCRA)
     4339#endif
    37524340    {
    37534341      // All leading pictures are being marked as TFD pictures here since current encoder uses all
     
    42874875
    42884876    if(!m_temp)
     4877    {
    42894878      initDs(iWidth, iHeight, m_pcCfg->getIntraPeriod()>1);
     4879    }
    42904880
    42914881    filterImg(pcYuvSrc->getLumaAddr(), pcYuvSrc->getStride(), pcYuvDest->getLumaAddr(), pcYuvDest->getStride(), iHeight, iWidth,  inputBitDepth-outputBitDepth, 0);
     
    42944884  }
    42954885}
    4296 const int TEncGOP::m_phase_filter_0_t0[4][13]={
     4886const Int TEncGOP::m_phase_filter_0_t0[4][13]={
    42974887  {0,  2,  -3,  -9,   6,  39,  58,  39,   6,  -9,  -3,  2,  0}, 
    42984888  {0, 0,  0,  -2,  8,-20, 116, 34, -10,  2,  0, 0,  0},                      //{0,  1,  -1,  -8,  -1,  31,  57,  47,  13,  -7,  -5,  1,  0},  //
     
    43014891};
    43024892
    4303 const int TEncGOP::m_phase_filter_0_t1[4][13]={
     4893const Int TEncGOP::m_phase_filter_0_t1[4][13]={
    43044894  {0,  4,  0,  -12, 0,  40,  64,  40, 0, -12,  0,  4,  0},
    43054895  {0, 0,  0,  -2,  8,-20, 116,34,-10,  2,  0, 0,  0},                      //{0,  1,  -1,  -8,  -1,  31,  57,  47,  13,  -7,  -5,  1,  0},  //
     
    43074897  {0,  0,   1,  -5,  -7,  13,  47,  57,  31,  -1,  -8,-1,  1} 
    43084898};
    4309 const int TEncGOP::m_phase_filter_0_t1_chroma[4][13]={
     4899const Int TEncGOP::m_phase_filter_0_t1_chroma[4][13]={
    43104900  {0,  0,  0,   0,  0,   0,  128, 0,  0,  0,  0,  0,  0},
    43114901  {0, 0,  0,  -2,  8,-20, 116,34,-10,  2,  0, 0,  0},                      //{0,  1,  -1,  -8,  -1,  31,  57,  47,  13,  -7,  -5,  1,  0},  //
     
    43144904};
    43154905
    4316 const int TEncGOP::m_phase_filter_1[8][13]={
     4906const Int TEncGOP::m_phase_filter_1[8][13]={
    43174907  {0,   0,  5,  -6,  -10,37,  76,  37,-10,   -6, 5,  0,   0},   
    43184908  {0,  -1,  5,  -3,  -12,29,  75,  45,  -7,   -8, 5,  0,   0},   
     
    43254915};
    43264916
     4917#if CGS_GCC_NO_VECTORIZATION 
     4918#ifdef __GNUC__
     4919#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
     4920#if GCC_VERSION > 40600
     4921__attribute__((optimize("no-tree-vectorize")))
     4922#endif
     4923#endif
     4924#endif
    43274925Void TEncGOP::filterImg(
    43284926    Pel           *src,
     
    43774975  // pad temp (vertical)
    43784976  for (k=-(length>>1); k<0; k++)
    4379     memcpy(m_temp[k], m_temp[0], width2*sizeof(int));
     4977  {
     4978    memcpy(m_temp[k], m_temp[0], width2*sizeof(Int));
     4979  }
    43804980  for (k=height1; k<(height1+(length>>1)); k++)
    4381     memcpy(m_temp[k], m_temp[k-1], (width2)* sizeof(int));
     4981  {
     4982    memcpy(m_temp[k], m_temp[k-1], (width2)* sizeof(Int));
     4983  }
    43824984
    43834985  // vertical filtering
     
    44005002      }
    44015003      iSum=((iSum + shift_round) >> shift2);
    4402       *p_dst++ = (short)(iSum > iMax ? iMax : (iSum < 0 ? 0 : iSum));
     5004      *p_dst++ = (Short)(iSum > iMax ? iMax : (iSum < 0 ? 0 : iSum));
    44035005    }
    44045006    p_dst_line += iDstStride;
     
    44555057  {
    44565058    if (*array2D)
     5059    {
    44575060      xFree(array2D[-iPadY]-iPadX);
     5061    }
    44585062    else
     5063    {
    44595064      printf("free_mem2DintWithPad: trying to free unused memory\r\nPress Any Key\r\n");
     5065    }
    44605066
    44615067    free (&array2D[-iPadY]);
  • trunk/source/Lib/TLibEncoder/TEncGOP.h

    r713 r815  
    113113  Bool                    m_bRefreshPending;
    114114  Int                     m_pocCRA;
     115#if POC_RESET_IDC_ENCODER
     116  Int                     m_pocCraWithoutReset;
     117  Int                     m_associatedIrapPocBeforeReset;
     118#endif
    115119  std::vector<Int>        m_storedStartCUAddrForEncodingSlice;
    116120  std::vector<Int>        m_storedStartCUAddrForEncodingSliceSegment;
     
    135139  UInt                    m_layerId;     
    136140  TEncTop**               m_ppcTEncTop;
    137 #if SVC_UPSAMPLING
    138141  TEncSearch*             m_pcPredSearch;                       ///< encoder search class
    139 #endif 
    140142#if Q0048_CGS_3D_ASYMLUT
    141143  TEnc3DAsymLUT           m_Enc3DAsymLUTPicUpdate;
     
    154156  Int   **m_temp;
    155157#endif
     158#if POC_RESET_IDC_ENCODER
     159  Int   m_lastPocPeriodId;
     160#endif
    156161#endif
    157162 
     
    172177#else
    173178  Void  compressGOP ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP, Bool isField, Bool isTff );
     179#endif
     180#if POC_RESET_IDC_ENCODER
     181  Void  determinePocResetIdc( Int const pocCurr, TComSlice *const slice);
     182  Int   getIntraRefreshInterval()  { return m_pcCfg->getIntraPeriod(); }
     183  Int   getIntraRefreshType()      { return m_pcCfg->getDecodingRefreshType(); }
     184  // Int   getIntraRefreshInterval ()  { return (m_pcCfg) ? m_pcCfg->getIntraPeriod() : 0;  }
     185  Int   getLastPocPeriodId()      { return m_lastPocPeriodId; }
     186  Void  setLastPocPeriodId(Int x) { m_lastPocPeriodId = x;    }
     187  Void  updatePocValuesOfPics( Int const pocCurr, TComSlice *const slice);
    174188#endif
    175189  Void  xAttachSliceDataToNalUnit (OutputNALUnit& rNalu, TComOutputBitstream*& rpcBitstreamRedirect);
     
    209223
    210224  SEIToneMappingInfo*     xCreateSEIToneMappingInfo();
     225#if P0050_KNEE_FUNCTION_SEI
     226  SEIKneeFunctionInfo*    xCreateSEIKneeFunctionInfo();
     227#endif
    211228#if Q0074_SEI_COLOR_MAPPING
    212229  SEIColorMappingInfo*    xCreateSEIColorMappingInfo( Char* file );
  • trunk/source/Lib/TLibEncoder/TEncPic.cpp

    r595 r815  
    126126 * \return Void
    127127 */
     128#if SVC_EXTENSION
    128129#if AUXILIARY_PICTURES
    129 #if SVC_UPSAMPLING
    130130Void TEncPic::create( Int iWidth, Int iHeight, ChromaFormat chromaFormat, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, UInt uiMaxAQDepth, 
    131131                      Window &conformanceWindow, Window &defaultDisplayWindow, Int *numReorderPics, TComSPS* pcSps, Bool bIsVirtual )
    132 
    133 #else
    134 
    135 Void TEncPic::create( Int iWidth, Int iHeight, ChromaFormat chromaFormat, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, UInt uiMaxAQDepth,
    136                       Window &conformanceWindow, Window &defaultDisplayWindow, Int *numReorderPics, Bool bIsVirtual )
    137 #endif
    138132{
    139 #if SVC_UPSAMPLING
    140133  TComPic::create( iWidth, iHeight, chromaFormat, uiMaxWidth, uiMaxHeight, uiMaxDepth, 
    141134                   conformanceWindow, defaultDisplayWindow, numReorderPics, pcSps, bIsVirtual );
    142135#else
    143   TComPic::create( iWidth, iHeight, chromaFormat, uiMaxWidth, uiMaxHeight, uiMaxDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, bIsVirtual );
     136Void TEncPic::create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, UInt uiMaxAQDepth, 
     137                      Window &conformanceWindow, Window &defaultDisplayWindow, Int *numReorderPics, TComSPS* pcSps, Bool bIsVirtual )
     138{
     139  TComPic::create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, 
     140                   conformanceWindow, defaultDisplayWindow, numReorderPics, pcSps, bIsVirtual );
    144141#endif
    145142  m_uiMaxAQDepth = uiMaxAQDepth;
     
    153150  }
    154151}
    155 #else
    156 #if SVC_UPSAMPLING
    157 Void TEncPic::create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, UInt uiMaxAQDepth, 
    158                       Window &conformanceWindow, Window &defaultDisplayWindow, Int *numReorderPics, TComSPS* pcSps, Bool bIsVirtual )
    159 
    160 #else
     152#else  //SVC_EXTENSION
    161153Void TEncPic::create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, UInt uiMaxAQDepth, 
    162154                      Window &conformanceWindow, Window &defaultDisplayWindow, Int *numReorderPics, Bool bIsVirtual )
    163 #endif
    164155{
    165 #if SVC_UPSAMPLING
    166   TComPic::create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, 
    167                    conformanceWindow, defaultDisplayWindow, numReorderPics, pcSps, bIsVirtual );
    168 #else
    169156  TComPic::create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, 
    170157                   conformanceWindow, defaultDisplayWindow, numReorderPics, bIsVirtual );
    171 #endif
    172158  m_uiMaxAQDepth = uiMaxAQDepth;
    173159  if ( uiMaxAQDepth > 0 )
     
    180166  }
    181167}
    182 #endif
     168#endif //SVC_EXTENSION
    183169
    184170/** Clean up
  • trunk/source/Lib/TLibEncoder/TEncPic.h

    r595 r815  
    4141#include "TLibCommon/CommonDef.h"
    4242#include "TLibCommon/TComPic.h"
    43 #if SVC_UPSAMPLING
     43#if SVC_EXTENSION
    4444#include "TLibCommon/TComSlice.h"
    4545#endif
     
    105105  virtual ~TEncPic();
    106106
     107#if SVC_EXTENSION
    107108#if AUXILIARY_PICTURES
    108 #if SVC_UPSAMPLING
    109109  Void          create( Int iWidth, Int iHeight, ChromaFormat chromaFormat, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, UInt uiMaxAQDepth, 
    110110                      Window &conformanceWindow, Window &defaultDisplayWindow, Int *numReorderPics, TComSPS* pcSps, Bool bIsVirtual=false );
    111111#else
    112   Void          create( Int iWidth, Int iHeight, ChromaFormat chromaFormat, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, UInt uiMaxAQDepth,
    113                           Window &conformanceWindow, Window &defaultDisplayWindow, Int *numReorderPics, Bool bIsVirtual = false );
    114 
    115 #endif
    116 #else
    117 #if SVC_UPSAMPLING
    118112  Void          create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, UInt uiMaxAQDepth,   
    119113                        Window &conformanceWindow, Window &defaultDisplayWindow, Int *numReorderPics, TComSPS* pcSps, Bool bIsVirtual = false );
    120 #else
     114#endif
     115#else  //SVC_EXTENSION
    121116  Void          create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, UInt uiMaxAQDepth,   
    122117                        Window &conformanceWindow, Window &defaultDisplayWindow, Int *numReorderPics, Bool bIsVirtual = false );
    123 #endif
    124 #endif
     118#endif //SVC_EXTENSION
     119
    125120  virtual Void  destroy();
    126121
  • trunk/source/Lib/TLibEncoder/TEncSearch.cpp

    r713 r815  
    31023102 * \returns Void
    31033103 */
     3104#if SVC_EXTENSION
     3105#if AMP_MRG
     3106Bool TEncSearch::predInterSearch( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, Bool bUseRes, Bool bUseMRG )
     3107#else
     3108Bool TEncSearch::predInterSearch( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, Bool bUseRes )
     3109#endif
     3110#else
    31043111#if AMP_MRG
    31053112Void TEncSearch::predInterSearch( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, Bool bUseRes, Bool bUseMRG )
    31063113#else
    31073114Void TEncSearch::predInterSearch( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, Bool bUseRes )
     3115#endif
    31083116#endif
    31093117{
     
    32153223#endif
    32163224
     3225#if SVC_EXTENSION
     3226      Bool doneUniPred = false;
     3227#endif
     3228
    32173229    //  Uni-directional prediction
    32183230    for ( Int iRefList = 0; iRefList < iNumPredDir; iRefList++ )
     
    32223234      for ( Int iRefIdxTemp = 0; iRefIdxTemp < pcCU->getSlice()->getNumRefIdx(eRefPicList); iRefIdxTemp++ )
    32233235      {
     3236#if SVC_EXTENSION
     3237        TComPic* pcPic = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxTemp );
     3238       
     3239        // motion search only for the ILRP with sample prediction type
     3240        if( pcPic->isILR( pcCU->getLayerId() ) && !pcCU->getSlice()->getVPS()->isSamplePredictionType( pcCU->getLayerId(), pcPic->getLayerId() ) )
     3241        {
     3242          continue;
     3243        }
     3244
    32243245#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    3225         if (pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxTemp )->isILR(pcCU->getLayerId()) && m_disableILP)
     3246        if( pcPic->isILR(pcCU->getLayerId()) && m_disableILP )
    32263247        {
    32273248          continue;
    32283249        }
    32293250#endif
    3230 #if (ENCODER_FAST_MODE)
    3231         TComPic* pcPic    = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxTemp );
     3251#if (ENCODER_FAST_MODE)       
    32323252        if( pcPic->isILR(pcCU->getLayerId()) && (ePartSize == SIZE_2Nx2N) )
    32333253        {
    32343254          continue;
    32353255        }
     3256#endif
     3257        doneUniPred = true;
    32363258#endif
    32373259
     
    33423364      }
    33433365    }
     3366
     3367#if SVC_EXTENSION
     3368    if( pcCU->getLayerId() && !doneUniPred )
     3369    {
     3370      // there is no valid reference pictures for inter prediction
     3371      return false;
     3372    }
     3373#endif
     3374
    33443375    //  Bi-directional prediction
    33453376#if REF_IDX_ME_ZEROMV
     
    34623493#if (ENCODER_FAST_MODE)
    34633494          Bool testRefIdx = true;
    3464           pcPic           = pcCU->getSlice()->getRefPic( RefPicList(iRefList) , iRefIdxTemp );
     3495          pcPic = pcCU->getSlice()->getRefPic( RefPicList(iRefList) , iRefIdxTemp );
     3496
     3497          // motion search only for the ILRP with sample prediction type
     3498          if( pcPic->isILR( pcCU->getLayerId() ) && !pcCU->getSlice()->getVPS()->isSamplePredictionType( pcCU->getLayerId(), pcPic->getLayerId() ) )
     3499          {
     3500            continue;
     3501          }
     3502
    34653503          if(pcPic->isILR(pcCU->getLayerId()) && (ePartSize == SIZE_2Nx2N))
    34663504          {
     
    37813819  setWpScalingDistParam( pcCU, -1, REF_PIC_LIST_X );
    37823820
     3821#if SVC_EXTENSION
     3822  return true;
     3823#else
    37833824  return;
     3825#endif
    37843826}
    37853827
     
    59676009Bool TEncSearch::predInterSearchILRUni( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, UInt refLayerId )
    59686010{
    5969     rpcPredYuv->clear();
    5970     rpcRecoYuv->clear();
    5971 
    5972     Int           iNumPredDir = pcCU->getSlice()->isInterP() ? 1 : 2;
    5973 
    5974     TComMv        cMv[2];
    5975     TComMv        cMvPred[2][33];
    5976     TComMv        cMvTemp[2][33];
    5977     TComMv        TempMv;
    5978 
    5979     Int           iRefIdx[2]={0,0};
    5980 
    5981     Int           aaiMvpIdx[2][33];
    5982     Int           aaiMvpNum[2][33];
    5983 
    5984     UInt          uiMbBits[3] = {1, 1, 0};
    5985     UInt          uiLastMode = 0;
    5986 
    5987     UInt          uiCost[2]   = { MAX_UINT, MAX_UINT };     //uni, rdCost
    5988     UInt          uiCostTemp;
    5989     UInt          biPDistTemp = MAX_INT;
    5990     UInt          uiBitsTemp;
    5991 
    5992     PartSize      ePartSize = pcCU->getPartitionSize( 0 );  //2Nx2N
    5993     Int           iPartIdx  = 0;                            //one PU in CU
    5994     UInt          uiPartAddr;
    5995     Int           iRoiWidth, iRoiHeight;
    5996     Bool          bILRSearched = false;
    5997 
    5998     xGetBlkBits( ePartSize, pcCU->getSlice()->isInterP(), iPartIdx, uiLastMode, uiMbBits);
    5999     pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iRoiWidth, iRoiHeight );
    6000 
    6001     for( Int iRefList = 0; iRefList < iNumPredDir; iRefList++)  //list
    6002     {
    6003         if(bILRSearched)
    6004            continue;
    6005 
    6006         RefPicList  eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 );
    6007 
    6008         Int  iRefIdxTemp = -1;
    6009         Bool foundILR    = false;
    6010 
    6011         for( Int refIdx = 0; refIdx < pcCU->getSlice()->getNumRefIdx(eRefPicList); refIdx++ )
    6012         {
    6013             if( pcCU->getSlice()->getRefPic(eRefPicList, refIdx)->isILR(pcCU->getLayerId()) && pcCU->getSlice()->getRefPic(eRefPicList, refIdx)->getLayerId() == refLayerId )
    6014             {
    6015                 iRefIdxTemp = refIdx;
    6016                 foundILR    = true;
    6017                 bILRSearched = true;
    6018                 break;
    6019             }
    6020         }
    6021 
    6022         if(!foundILR)  //no ILR in eRefPiclist
    6023         {
    6024             continue; 
    6025         }
    6026 
    6027         uiBitsTemp = uiMbBits[iRefList];
    6028         if ( pcCU->getSlice()->getNumRefIdx(eRefPicList) > 1 )
    6029         {
    6030             uiBitsTemp += iRefIdxTemp+1;
    6031             if ( iRefIdxTemp == pcCU->getSlice()->getNumRefIdx(eRefPicList)-1 ) uiBitsTemp--;
    6032         }
    6033 
    6034         xEstimateMvPredAMVP( pcCU, pcOrgYuv, iPartIdx, eRefPicList, iRefIdxTemp, cMvPred[iRefList][iRefIdxTemp], false, &biPDistTemp);
    6035         aaiMvpIdx[iRefList][iRefIdxTemp] = pcCU->getMVPIdx(eRefPicList, uiPartAddr);
    6036         aaiMvpNum[iRefList][iRefIdxTemp] = pcCU->getMVPNum(eRefPicList, uiPartAddr);
    6037 
    6038         uiBitsTemp += m_auiMVPIdxCost[aaiMvpIdx[iRefList][iRefIdxTemp]][AMVP_MAX_NUM_CANDS];
    6039 
    6040         xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp );
    6041         xCheckBestMVP(pcCU, eRefPicList, cMvTemp[iRefList][iRefIdxTemp], cMvPred[iRefList][iRefIdxTemp], aaiMvpIdx[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp);
    6042 
    6043         if( uiCostTemp < uiCost[iRefList] )
    6044         {
    6045             uiCost[iRefList] = uiCostTemp;
    6046 
    6047             cMv[iRefList]     = cMvTemp[iRefList][iRefIdxTemp];
    6048             iRefIdx[iRefList] = iRefIdxTemp;
    6049 
    6050             pcCU->getCUMvField(eRefPicList)->setAllMv( cMv[iRefList], ePartSize, uiPartAddr, 0, iPartIdx );
    6051             pcCU->getCUMvField(eRefPicList)->setAllRefIdx( iRefIdx[iRefList], ePartSize, uiPartAddr, 0, iPartIdx );
    6052         }
    6053     }
    6054 
    6055     if( uiCost[0] == MAX_UINT && uiCost[1] == MAX_UINT )  //no ILR in both list0 and list1
    6056     {
    6057         return false;
    6058     }
    6059 
    6060     //  Clear Motion Field
    6061     pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( TComMvField(), ePartSize, uiPartAddr, 0, iPartIdx );
    6062     pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( TComMvField(), ePartSize, uiPartAddr, 0, iPartIdx );
    6063     pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd    ( TComMv(),      ePartSize, uiPartAddr, 0, iPartIdx );
    6064     pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd    ( TComMv(),      ePartSize, uiPartAddr, 0, iPartIdx );
    6065 
    6066     pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
    6067     pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
    6068     pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
    6069     pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
    6070 
    6071     if( uiCost[0] <= uiCost[1] )  //list0 ILR
    6072     {
    6073         pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMv    ( cMv[0], ePartSize, uiPartAddr, 0, iPartIdx );
    6074         pcCU->getCUMvField(REF_PIC_LIST_0)->setAllRefIdx( iRefIdx[0], ePartSize, uiPartAddr, 0, iPartIdx );
    6075 
    6076         TempMv = cMv[0] - cMvPred[0][iRefIdx[0]];
    6077         pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd( TempMv, ePartSize, uiPartAddr, 0, iPartIdx );
    6078 
    6079         pcCU->setInterDirSubParts( 1, uiPartAddr, iPartIdx, pcCU->getDepth(0) );
    6080 
    6081         pcCU->setMVPIdxSubParts( aaiMvpIdx[0][iRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
    6082         pcCU->setMVPNumSubParts( aaiMvpNum[0][iRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
    6083     }
    6084     else if( uiCost[1] < uiCost[0] )  //list1 ILR
    6085     {
    6086         pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMv    ( cMv[1], ePartSize, uiPartAddr, 0, iPartIdx );
    6087         pcCU->getCUMvField(REF_PIC_LIST_1)->setAllRefIdx( iRefIdx[1], ePartSize, uiPartAddr, 0, iPartIdx );
    6088 
    6089         TempMv = cMv[1] - cMvPred[1][iRefIdx[1]];
    6090         pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd( TempMv, ePartSize, uiPartAddr, 0, iPartIdx );
    6091 
    6092         pcCU->setInterDirSubParts( 2, uiPartAddr, iPartIdx, pcCU->getDepth(0) );
    6093 
    6094         pcCU->setMVPIdxSubParts( aaiMvpIdx[1][iRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
    6095         pcCU->setMVPNumSubParts( aaiMvpNum[1][iRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
    6096     }
    6097     else
    6098     {
    6099         assert(0);
    6100     }
    6101 
    6102     pcCU->setMergeFlagSubParts( false, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    6103 
    6104     motionCompensation ( pcCU, rpcPredYuv, REF_PIC_LIST_X, iPartIdx );
    6105     setWpScalingDistParam( pcCU, -1, REF_PIC_LIST_X );
    6106 
    6107     return true;
     6011  rpcPredYuv->clear();
     6012  rpcRecoYuv->clear();
     6013
     6014  Int           iNumPredDir = pcCU->getSlice()->isInterP() ? 1 : 2;
     6015
     6016  TComMv        cMv[2];
     6017  TComMv        cMvPred[2][33];
     6018  TComMv        cMvTemp[2][33];
     6019  TComMv        TempMv;
     6020
     6021  Int           iRefIdx[2]={0,0};
     6022
     6023  Int           aaiMvpIdx[2][33];
     6024  Int           aaiMvpNum[2][33];
     6025
     6026  UInt          uiMbBits[3] = {1, 1, 0};
     6027  UInt          uiLastMode = 0;
     6028
     6029  UInt          uiCost[2]   = { MAX_UINT, MAX_UINT };     //uni, rdCost
     6030  UInt          uiCostTemp;
     6031  UInt          biPDistTemp = MAX_INT;
     6032  UInt          uiBitsTemp;
     6033
     6034  PartSize      ePartSize = pcCU->getPartitionSize( 0 );  //2Nx2N
     6035  Int           iPartIdx  = 0;                            //one PU in CU
     6036  UInt          uiPartAddr;
     6037  Int           iRoiWidth, iRoiHeight;
     6038  Bool          bILRSearched = false;
     6039
     6040  xGetBlkBits( ePartSize, pcCU->getSlice()->isInterP(), iPartIdx, uiLastMode, uiMbBits);
     6041  pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iRoiWidth, iRoiHeight );
     6042
     6043  for( Int iRefList = 0; iRefList < iNumPredDir; iRefList++)  //list
     6044  {
     6045    if(bILRSearched)
     6046    {
     6047      continue;
     6048    }
     6049
     6050    RefPicList  eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 );
     6051
     6052    Int  iRefIdxTemp = -1;
     6053    Bool foundILR    = false;
     6054
     6055    for( Int refIdx = 0; refIdx < pcCU->getSlice()->getNumRefIdx(eRefPicList); refIdx++ )
     6056    {
     6057      TComPic* refPic = pcCU->getSlice()->getRefPic(eRefPicList, refIdx);
     6058
     6059      // ILRP has to be for the sample prediction type
     6060      if( refPic->isILR(pcCU->getLayerId()) && refPic->getLayerId() == refLayerId && pcCU->getSlice()->getVPS()->isSamplePredictionType( pcCU->getLayerId(), refLayerId ) )
     6061      {
     6062        iRefIdxTemp = refIdx;
     6063        foundILR    = true;
     6064        bILRSearched = true;
     6065        break;
     6066      }
     6067    }
     6068
     6069    if(!foundILR)  //no ILR in eRefPiclist
     6070    {
     6071      continue; 
     6072    }   
     6073
     6074    uiBitsTemp = uiMbBits[iRefList];
     6075    if ( pcCU->getSlice()->getNumRefIdx(eRefPicList) > 1 )
     6076    {
     6077      uiBitsTemp += iRefIdxTemp+1;
     6078      if ( iRefIdxTemp == pcCU->getSlice()->getNumRefIdx(eRefPicList)-1 ) uiBitsTemp--;
     6079    }
     6080
     6081    xEstimateMvPredAMVP( pcCU, pcOrgYuv, iPartIdx, eRefPicList, iRefIdxTemp, cMvPred[iRefList][iRefIdxTemp], false, &biPDistTemp);
     6082    aaiMvpIdx[iRefList][iRefIdxTemp] = pcCU->getMVPIdx(eRefPicList, uiPartAddr);
     6083    aaiMvpNum[iRefList][iRefIdxTemp] = pcCU->getMVPNum(eRefPicList, uiPartAddr);
     6084
     6085    uiBitsTemp += m_auiMVPIdxCost[aaiMvpIdx[iRefList][iRefIdxTemp]][AMVP_MAX_NUM_CANDS];
     6086
     6087    xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp );
     6088    xCheckBestMVP(pcCU, eRefPicList, cMvTemp[iRefList][iRefIdxTemp], cMvPred[iRefList][iRefIdxTemp], aaiMvpIdx[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp);
     6089
     6090    if( uiCostTemp < uiCost[iRefList] )
     6091    {
     6092      uiCost[iRefList] = uiCostTemp;
     6093
     6094      cMv[iRefList]     = cMvTemp[iRefList][iRefIdxTemp];
     6095      iRefIdx[iRefList] = iRefIdxTemp;
     6096
     6097      pcCU->getCUMvField(eRefPicList)->setAllMv( cMv[iRefList], ePartSize, uiPartAddr, 0, iPartIdx );
     6098      pcCU->getCUMvField(eRefPicList)->setAllRefIdx( iRefIdx[iRefList], ePartSize, uiPartAddr, 0, iPartIdx );
     6099    }
     6100  }
     6101
     6102  if( uiCost[0] == MAX_UINT && uiCost[1] == MAX_UINT )  //no ILR in both list0 and list1
     6103  {
     6104    return false;
     6105  }
     6106
     6107  //  Clear Motion Field
     6108  pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( TComMvField(), ePartSize, uiPartAddr, 0, iPartIdx );
     6109  pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( TComMvField(), ePartSize, uiPartAddr, 0, iPartIdx );
     6110  pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd    ( TComMv(),      ePartSize, uiPartAddr, 0, iPartIdx );
     6111  pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd    ( TComMv(),      ePartSize, uiPartAddr, 0, iPartIdx );
     6112
     6113  pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     6114  pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     6115  pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     6116  pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     6117
     6118  if( uiCost[0] <= uiCost[1] )  //list0 ILR
     6119  {
     6120    pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMv    ( cMv[0], ePartSize, uiPartAddr, 0, iPartIdx );
     6121    pcCU->getCUMvField(REF_PIC_LIST_0)->setAllRefIdx( iRefIdx[0], ePartSize, uiPartAddr, 0, iPartIdx );
     6122
     6123    TempMv = cMv[0] - cMvPred[0][iRefIdx[0]];
     6124    pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd( TempMv, ePartSize, uiPartAddr, 0, iPartIdx );
     6125
     6126    pcCU->setInterDirSubParts( 1, uiPartAddr, iPartIdx, pcCU->getDepth(0) );
     6127
     6128    pcCU->setMVPIdxSubParts( aaiMvpIdx[0][iRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     6129    pcCU->setMVPNumSubParts( aaiMvpNum[0][iRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     6130  }
     6131  else if( uiCost[1] < uiCost[0] )  //list1 ILR
     6132  {
     6133    pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMv    ( cMv[1], ePartSize, uiPartAddr, 0, iPartIdx );
     6134    pcCU->getCUMvField(REF_PIC_LIST_1)->setAllRefIdx( iRefIdx[1], ePartSize, uiPartAddr, 0, iPartIdx );
     6135
     6136    TempMv = cMv[1] - cMvPred[1][iRefIdx[1]];
     6137    pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd( TempMv, ePartSize, uiPartAddr, 0, iPartIdx );
     6138
     6139    pcCU->setInterDirSubParts( 2, uiPartAddr, iPartIdx, pcCU->getDepth(0) );
     6140
     6141    pcCU->setMVPIdxSubParts( aaiMvpIdx[1][iRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     6142    pcCU->setMVPNumSubParts( aaiMvpNum[1][iRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     6143  }
     6144  else
     6145  {
     6146    assert(0);
     6147  }
     6148
     6149  pcCU->setMergeFlagSubParts( false, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
     6150
     6151  motionCompensation ( pcCU, rpcPredYuv, REF_PIC_LIST_X, iPartIdx );
     6152  setWpScalingDistParam( pcCU, -1, REF_PIC_LIST_X );
     6153
     6154  return true;
    61086155}
    61096156#endif
  • trunk/source/Lib/TLibEncoder/TEncSearch.h

    r595 r815  
    126126
    127127#if SVC_EXTENSION
    128   TEncTop**       m_ppcTEncTop;
    129128#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    130129  Bool            m_disableILP;
    131130#endif
    132 #endif //SVC_EXTENAION
     131#endif //SVC_EXTENSION
    133132
    134133public:
     
    194193 
    195194  /// encoder estimation - inter prediction (non-skip)
     195#if SVC_EXTENSION
     196  Bool predInterSearch          ( TComDataCU* pcCU,
     197#else
    196198  Void predInterSearch          ( TComDataCU* pcCU,
     199#endif
    197200                                  TComYuv*    pcOrgYuv,
    198201                                  TComYuv*&   rpcPredYuv,
  • trunk/source/Lib/TLibEncoder/TEncTop.cpp

    r713 r815  
    8989#endif
    9090  m_numScaledRefLayerOffsets = 0;
    91 #if POC_RESET_FLAG
     91#if POC_RESET_FLAG || POC_RESET_IDC_ENCODER
    9292  m_pocAdjustmentValue     = 0;
    9393#endif
     
    810810
    811811            //only for scalable extension
    812 #if SCALABILITY_MASK_E0104
    813             assert( m_cVPS.getScalabilityMask(2) == true );
    814 #else
    815             assert( m_cVPS.getScalabilityMask(1) == true );
    816 #endif
     812            assert( m_cVPS.getScalabilityMask( SCALABILITY_ID ) == true );
    817813          }
    818814        }
     
    820816#endif
    821817
     818#if SVC_EXTENSION
    822819#if AUXILIARY_PICTURES
    823 #if SVC_UPSAMPLING
    824820      pcEPic->create( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, m_cPPS.getMaxCuDQPDepth()+1 ,
    825821                      m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics, &m_cSPS);
    826822#else
    827       pcEPic->create( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, m_cPPS.getMaxCuDQPDepth()+1 ,
    828                       m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics);
    829 #endif
    830 #else
    831 #if SVC_UPSAMPLING
    832823      pcEPic->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, m_cPPS.getMaxCuDQPDepth()+1 ,
    833824                      m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics, &m_cSPS);
    834 #else
     825#endif
     826#else  //SVC_EXTENSION
    835827      pcEPic->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, m_cPPS.getMaxCuDQPDepth()+1 ,
    836828                      m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics);
    837 #endif
    838 #endif
     829#endif //SVC_EXTENSION
    839830      rpcPic = pcEPic;
    840831    }
     
    879870
    880871            //only for scalable extension
    881 #if SCALABILITY_MASK_E0104
    882             assert( m_cVPS.getScalabilityMask(2) == true );
    883 #else
    884             assert( m_cVPS.getScalabilityMask(1) == true );
    885 #endif
     872            assert( m_cVPS.getScalabilityMask( SCALABILITY_ID ) == true );
    886873          }
    887874        }
     
    889876#endif
    890877
     878#if SVC_EXTENSION
    891879#if AUXILIARY_PICTURES
    892 #if SVC_UPSAMPLING
    893880      rpcPic->create( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    894881                      m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics, &m_cSPS);
    895882#else
    896       rpcPic->create( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    897                       m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics);
    898 #endif
    899 #else
    900 #if SVC_UPSAMPLING
    901883      rpcPic->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    902884                      m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics, &m_cSPS);
    903 #else
     885#endif
     886#else  //SVC_EXTENSION
    904887      rpcPic->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    905888                      m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics);
    906 #endif
    907 #endif
     889#endif //SVC_EXTENSION
    908890    }
    909891    m_cListPic.pushBack( rpcPic );
     
    922904{
    923905#if SVC_EXTENSION
     906  m_cSPS.setExtensionFlag( m_layerId > 0 ? true : false );
     907
     908#if Q0078_ADD_LAYER_SETS
     909  if (getNumDirectRefLayers() == 0 && getNumAddLayerSets() > 0)
     910  {
     911    m_cSPS.setLayerId(0); // layer ID 0 for independent layers
     912  }
     913  else
     914  {
     915    m_cSPS.setLayerId(m_layerId);
     916  }
     917#else
    924918  m_cSPS.setLayerId(m_layerId);
     919#endif
    925920  m_cSPS.setNumScaledRefLayerOffsets(m_numScaledRefLayerOffsets);
    926921  for(Int i = 0; i < m_cSPS.getNumScaledRefLayerOffsets(); i++)
     
    10821077Void TEncTop::xInitPPS()
    10831078{
    1084 #if SCALINGLIST_INFERRING
    1085   m_cPPS.setLayerId( m_layerId );
    1086 #endif
    1087 
    10881079  m_cPPS.setConstrainedIntraPred( m_bUseConstrainedIntraPred );
    10891080  Bool bUseDQP = (getMaxCuDQPDepth() > 0)? true : false;
     
    11811172  }
    11821173#if SVC_EXTENSION
    1183   if (!m_layerId)
     1174#if SCALINGLIST_INFERRING
     1175  m_cPPS.setLayerId( m_layerId );
     1176#endif
     1177
     1178#if Q0078_ADD_LAYER_SETS
     1179  if (getNumDirectRefLayers() == 0 && getNumAddLayerSets() > 0)
     1180  {
     1181    m_cPPS.setLayerId(0); // layer ID 0 for independent layers
     1182  }
     1183#endif
     1184
     1185  if( m_layerId > 0 )
     1186  {
     1187    m_cPPS.setListsModificationPresentFlag(true);
     1188    m_cPPS.setExtensionFlag(true);
     1189  }
     1190  else
    11841191  {
    11851192    m_cPPS.setListsModificationPresentFlag(false);
    1186   }
    1187   else
    1188   {
    1189     m_cPPS.setListsModificationPresentFlag(true);
    1190   }
    1191 
    1192   m_cPPS.setPPSId         ( m_iPPSIdCnt         );
    1193   m_cPPS.setSPSId         ( m_iSPSIdCnt         );
    1194 #endif
     1193    m_cPPS.setExtensionFlag(false);
     1194  }
     1195
     1196  m_cPPS.setPPSId( m_iPPSIdCnt );
     1197  m_cPPS.setSPSId( m_iSPSIdCnt );
    11951198#if POC_RESET_FLAG
    11961199  m_cPPS.setNumExtraSliceHeaderBits( 2 );
     
    12051208  m_cPPS.setCGSFlag( m_nCGSFlag );
    12061209#endif
     1210#if POC_RESET_IDC_ENCODER
     1211  m_cPPS.setPocResetInfoPresentFlag( true );
     1212  m_cPPS.setExtensionFlag( true );
     1213  m_cPPS.setSliceHeaderExtensionPresentFlag( true );
     1214#endif
     1215#endif //SVC_EXTENSION
    12071216}
    12081217
     
    15821591      {
    15831592        m_cIlpPic[j] = new  TComPic;
    1584 #if SVC_UPSAMPLING
    15851593#if AUXILIARY_PICTURES
    15861594        m_cIlpPic[j]->create(m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, &m_cSPS, true);
    15871595#else
    15881596        m_cIlpPic[j]->create(m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, &m_cSPS, true);
    1589 #endif
    1590 #else
    1591         m_cIlpPic[j]->create(m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, true);
    15921597#endif
    15931598        for (Int i=0; i<m_cIlpPic[j]->getPicSym()->getNumberOfCUsInFrame(); i++)
     
    16491654      {
    16501655        m_cIlpPic[j] = new  TComPic;
    1651 #if SVC_UPSAMPLING
    16521656#if AUXILIARY_PICTURES
    16531657        m_cIlpPic[j]->create(picWidth, picHeight, m_chromaFormatIDC, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, &m_cSPS, true);
    16541658#else
    16551659        m_cIlpPic[j]->create(picWidth, picHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, &m_cSPS, true);
    1656 #endif
    1657 #else
    1658         m_cIlpPic[j]->create(m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, true);
    16591660#endif
    16601661        for (Int i=0; i<m_cIlpPic[j]->getPicSym()->getNumberOfCUsInFrame(); i++)
  • trunk/source/Lib/TLibEncoder/TEncTop.h

    r713 r815  
    142142  Bool                    m_vertPhasePositionEnableFlag[MAX_LAYERS];
    143143#endif
    144 #if POC_RESET_FLAG
     144#if POC_RESET_FLAG || POC_RESET_IDC_ENCODER
    145145  Int                     m_pocAdjustmentValue;
    146146#endif
     
    153153#if O0194_WEIGHTED_PREDICTION_CGS
    154154  Bool                    m_interLayerWeightedPredFlag;
     155#endif
     156#if Q0078_ADD_LAYER_SETS
     157  int                     m_numAddLayerSets;
    155158#endif
    156159#endif //SVC_EXTENSION
     
    254257  TEncTop*  getRefLayerEnc(UInt refLayerIdc);
    255258#endif
    256 #if POC_RESET_FLAG
     259#if POC_RESET_FLAG || POC_RESET_IDC_ENCODER
    257260  Int       getPocAdjustmentValue()      { return m_pocAdjustmentValue;}
    258261  Void      setPocAdjustmentValue(Int x) { m_pocAdjustmentValue = x;   }
     
    268271  Void setNoOutputOfPriorPicsFlags(Bool x)   { m_noOutputOfPriorPicsFlags = x;   }
    269272#endif
     273#if Q0078_ADD_LAYER_SETS
     274  Void setNumAddLayerSets(Int x)             { m_numAddLayerSets = x; }
     275  Int  getNumAddLayerSets()                  { return m_numAddLayerSets; }
     276#endif
    270277#else //SVC_EXTENSION
    271278  Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut,
Note: See TracChangeset for help on using the changeset viewer.