Changeset 189 in SHVCSoftware for trunk/source


Ignore:
Timestamp:
13 May 2013, 16:58:44 (12 years ago)
Author:
seregin
Message:

merge with SHM-2.0-dev branch

Location:
trunk/source
Files:
57 edited

Legend:

Unmodified
Added
Removed
  • trunk/source

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

    r125 r189  
    6060#if SVC_EXTENSION
    6161  Char*         m_pchReconFile [MAX_LAYERS];          ///< output reconstruction file name
    62 #if AVC_BASE
    63   Char*         m_pchBLReconFile;                     ///< input BL reconstruction file name
    64   Int           m_iBLSourceWidth;
    65   Int           m_iBLSourceHeight;
    66 #if AVC_SYNTAX
    67   Char*         m_pchBLSyntaxFile;                     ///< input BL syntax file name 
    68 #endif
    69 #endif
    7062#else
    7163  Char*         m_pchReconFile;                       ///< output reconstruction file name
    72 #endif
    73 #if SYNTAX_OUTPUT
    74   Char*         m_pchBLSyntaxFile;                     ///< input BL syntax file name
    75   Int           m_iBLSourceWidth;
    76   Int           m_iBLSourceHeight;
    77   Int           m_iBLFrames;
    7864#endif
    7965  Int           m_iSkipFrame;                         ///< counter for frames prior to the random access point to skip
     
    8672#if SVC_EXTENSION
    8773  Int           m_tgtLayerId;                        ///< target layer ID
     74#if AVC_BASE
     75  Char*         m_pchBLReconFile;                     ///< input BL reconstruction file name
     76  Int           m_iBLSourceWidth;
     77  Int           m_iBLSourceHeight;
     78#if AVC_SYNTAX
     79  Char*         m_pchBLSyntaxFile;                     ///< input BL syntax file name 
    8880#endif
     81#endif
     82#endif
     83
     84#if SYNTAX_OUTPUT
     85  Char*         m_pchBLSyntaxFile;                     ///< input BL syntax file name
     86  Int           m_iBLSourceWidth;
     87  Int           m_iBLSourceHeight;
     88  Int           m_iBLFrames;
     89#endif
     90
    8991  std::vector<Int> m_targetDecLayerIdSet;             ///< set of LayerIds to be included in the sub-bitstream extraction process.
    9092  Int           m_respectDefDispWindow;               ///< Only output content inside the default display window
     
    103105#if SVC_EXTENSION
    104106  , m_tgtLayerId(0)
    105 #endif
    106   , m_respectDefDispWindow(0)
    107107#if AVC_BASE
    108108  , m_iBLSourceWidth(0)
     
    114114  , m_iBLFrames(0)
    115115#endif
     116#endif
     117  , m_respectDefDispWindow(0)
    116118  {}
    117119  virtual ~TAppDecCfg() {}
  • trunk/source/App/TAppDecoder/TAppDecTop.cpp

    r125 r189  
    157157#if AVC_BASE
    158158  TComPic pcBLPic;
    159   if( !m_pchBLReconFile )
    160   {
    161     printf( "Wrong base layer YUV input file\n" );
    162     exit(EXIT_FAILURE);
    163   }
    164   fstream streamYUV( m_pchBLReconFile, fstream::in | fstream::binary );
    165   if( !streamYUV.good() )
    166   {
    167     printf( "Base layer YUV input reading error\n" );
    168     exit(EXIT_FAILURE);
     159  fstream streamYUV;
     160  if( m_pchBLReconFile )
     161  {
     162    streamYUV.open( m_pchBLReconFile, fstream::in | fstream::binary );
    169163  }
    170164  TComList<TComPic*> *cListPic = m_acTDecTop[0].getListPic();
     
    174168  cListPic->pushBack( &pcBLPic );
    175169#if AVC_SYNTAX
    176   if( !m_pchBLSyntaxFile )
    177   {
    178     printf( "Wrong base layer syntax file\n" );
    179     exit(EXIT_FAILURE);
    180   }
    181   fstream streamSyntaxFile( m_pchBLSyntaxFile, fstream::in | fstream::binary );
    182   if( !streamSyntaxFile.good() )
    183   {
    184     printf( "Base layer syntax input reading error\n" );
    185     exit(EXIT_FAILURE);
     170  fstream streamSyntaxFile;
     171  if( m_pchBLSyntaxFile )
     172  {
     173    streamSyntaxFile.open( m_pchBLSyntaxFile, fstream::in | fstream::binary );
    186174  }
    187175  m_acTDecTop[0].setBLSyntaxFile( &streamSyntaxFile );
     
    254242      }
    255243      if ( bNewPicture && bNewPOC &&
    256            (   nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR
     244           (   nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL
    257245            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP
    258246            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP
    259             || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLANT
    260             || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA ) )
     247            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL
     248            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP ) )
    261249      {
    262250        xFlushOutput( pcListPic, curLayerId );
     
    414402      }
    415403      if ( bNewPicture &&
    416            (   nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR
     404           (   nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL
    417405            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP
    418406            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP
    419             || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLANT
    420             || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA ) )
     407            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL
     408            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP ) )
    421409      {
    422410        xFlushOutput( pcListPic );
     
    572560      if ( m_pchReconFile )
    573561      {
     562#if SYNTAX_OUTPUT && ILP_DECODED_PICTURE
     563        m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec() );
     564#else
    574565        const Window &conf = pcPic->getConformanceWindow();
    575566        const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
     
    579570                                       conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
    580571                                       conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
     572#endif
    581573      }
    582574     
  • trunk/source/App/TAppEncoder/TAppEncCfg.cpp

    r125 r189  
    6666TAppEncCfg::TAppEncCfg()
    6767: m_pBitstreamFile()
     68#if AVC_BASE
     69, m_avcBaseLayerFlag(0)
     70#endif
    6871, m_pColumnWidth()
    6972, m_pRowHeight()
     
    8992{
    9093  m_aidQP = NULL;
     94#if J0149_TONE_MAPPING_SEI
     95  m_startOfCodedInterval = NULL;
     96  m_codedPivotValue = NULL;
     97  m_targetPivotValue = NULL;
     98#endif
    9199}
    92100#endif
     
    102110    delete[] m_aidQP;
    103111  }
     112#if J0149_TONE_MAPPING_SEI
     113  if ( m_startOfCodedInterval )
     114  {
     115    delete[] m_startOfCodedInterval;
     116    m_startOfCodedInterval = NULL;
     117  }
     118   if ( m_codedPivotValue )
     119  {
     120    delete[] m_codedPivotValue;
     121    m_codedPivotValue = NULL;
     122  }
     123  if ( m_targetPivotValue )
     124  {
     125    delete[] m_targetPivotValue;
     126    m_targetPivotValue = NULL;
     127  }
     128#endif
    104129  free(m_pchInputFile);
    105130#endif
     
    119144Void TAppEncCfg::destroy()
    120145{
     146#if VPS_EXTN_DIRECT_REF_LAYERS
     147  for(Int layer = 0; layer < MAX_LAYERS; layer++)
     148  {
     149    if( m_acLayerCfg[layer].m_numDirectRefLayers > 0 )
     150    {
     151      delete [] m_acLayerCfg[layer].m_refLayerIds;
     152    }
     153  }
     154#endif
    121155}
    122156
     
    297331  string* cfg_refLayerIdsPtr   [MAX_LAYERS];
    298332#endif
     333#if SCALED_REF_LAYER_OFFSETS
     334  Int*    cfg_scaledRefLayerLeftOffset [MAX_LAYERS];
     335  Int*    cfg_scaledRefLayerTopOffset [MAX_LAYERS];
     336  Int*    cfg_scaledRefLayerRightOffset [MAX_LAYERS];
     337  Int*    cfg_scaledRefLayerBottomOffset [MAX_LAYERS];
     338#endif
    299339  for(UInt layer = 0; layer < MAX_LAYERS; layer++)
    300340  {
     
    311351    cfg_refLayerIdsPtr      [layer]  = &cfg_refLayerIds[layer];
    312352#endif
    313   }
     353#if SCALED_REF_LAYER_OFFSETS
     354    cfg_scaledRefLayerLeftOffset  [layer] = &m_acLayerCfg[layer].m_scaledRefLayerLeftOffset;
     355    cfg_scaledRefLayerTopOffset   [layer] = &m_acLayerCfg[layer].m_scaledRefLayerTopOffset;
     356    cfg_scaledRefLayerRightOffset [layer] = &m_acLayerCfg[layer].m_scaledRefLayerRightOffset;
     357    cfg_scaledRefLayerBottomOffset[layer] = &m_acLayerCfg[layer].m_scaledRefLayerBottomOffset;
     358#endif
     359  }
     360#if AVC_BASE
     361  string  cfg_BLInputFile;
     362#endif
    314363#if AVC_SYNTAX
    315364  string  cfg_BLSyntaxFile;
     
    324373  string cfg_RowHeight;
    325374  string cfg_ScalingListFile;
     375#if J0149_TONE_MAPPING_SEI
     376  string cfg_startOfCodedInterval;
     377  string cfg_codedPivotValue;
     378  string cfg_targetPivotValue;
     379#endif
    326380#if SIGNAL_BITRATE_PICRATE_IN_VPS
    327381  string cfg_bitRateInfoPresentFlag;
     
    361415  ("OutputBitDepthC",       m_outputBitDepthC,   0, "As per OutputBitDepth but for chroma component. (default:InternalBitDepthC)")
    362416  ("InternalBitDepthC",     m_internalBitDepthC, 0, "As per InternalBitDepth but for chroma component. (default:IntrenalBitDepth)")
    363 
     417#if SCALED_REF_LAYER_OFFSETS
     418  ("ScaledRefLayerLeftOffset%d",   cfg_scaledRefLayerLeftOffset,  0, MAX_LAYERS, "Horizontal offset of top-left luma sample of scaled base layer picture with respect to"
     419                                                                 " top-left luma sample of the EL picture, in units of two luma samples")
     420  ("ScaledRefLayerTopOffset%d",    cfg_scaledRefLayerTopOffset,   0, MAX_LAYERS,   "Vertical offset of top-left luma sample of scaled base layer picture with respect to"
     421                                                                 " top-left luma sample of the EL picture, in units of two luma samples")
     422  ("ScaledRefLayerRightOffset%d",  cfg_scaledRefLayerRightOffset, 0, MAX_LAYERS, "Horizontal offset of bottom-right luma sample of scaled base layer picture with respect to"
     423                                                                 " bottom-right luma sample of the EL picture, in units of two luma samples")
     424  ("ScaledRefLayerBottomOffset%d", cfg_scaledRefLayerBottomOffset,0, MAX_LAYERS, "Vertical offset of bottom-right luma sample of scaled base layer picture with respect to"
     425                                                                 " bottom-right luma sample of the EL picture, in units of two luma samples")
     426#endif
    364427#if AVC_BASE
    365   ("InputBLFile,-ibl",        *cfg_InputFile[0],     string(""), "Base layer rec YUV input file name")
     428  ("AvcBase,-avc",            m_avcBaseLayerFlag,     0, "avc_base_layer_flag")
     429  ("InputBLFile,-ibl",        cfg_BLInputFile,     string(""), "Base layer rec YUV input file name")
    366430#if AVC_SYNTAX
    367431  ("InputBLSyntaxFile,-ibs",  cfg_BLSyntaxFile,     string(""), "Base layer syntax input file name")
     
    369433#endif
    370434#if REF_IDX_FRAMEWORK
    371   ("EnableElRapB,-use-rap-b",  m_elRapSliceBEnabled, 0, "Set ILP over base-layer I picture to B picture (default is P picture_")
     435  ("EnableElRapB,-use-rap-b",  m_elRapSliceBEnabled, 0, "Set ILP over base-layer I picture to B picture (default is P picture)")
    372436#endif 
    373437#else 
     
    430494  ("DecodingRefreshType,-dr", m_iDecodingRefreshType,       0, "Intra refresh type (0:none 1:CRA 2:IDR)")
    431495  ("GOPSize,g",               m_iGOPSize,                   1, "GOP size of temporal structure")
     496#if !L0034_COMBINED_LIST_CLEANUP
    432497  ("ListCombination,-lc",     m_bUseLComb,               true, "Combined reference list for uni-prediction estimation in B-slices")
     498#endif
    433499  // motion options
    434500  ("FastSearch",              m_iFastSearch,                1, "0:Full search  1:Diamond  2:PMVFAST")
     
    488554  ("LoopFilterTcOffset_div2",        m_loopFilterTcOffsetDiv2,             0 )
    489555  ("DeblockingFilterControlPresent", m_DeblockingFilterControlPresent, false )
     556#if L0386_DB_METRIC
     557  ("DeblockingFilterMetric",         m_DeblockingFilterMetric,         false )
     558#endif
    490559
    491560  // Coding tools
     
    602671  ("SEIBufferingPeriod",             m_bufferingPeriodSEIEnabled,              0, "Control generation of buffering period SEI messages")
    603672  ("SEIPictureTiming",               m_pictureTimingSEIEnabled,                0, "Control generation of picture timing SEI messages")
     673#if J0149_TONE_MAPPING_SEI
     674  ("SEIToneMappingInfo",                       m_toneMappingInfoSEIEnabled,    false, "Control generation of Tone Mapping SEI messages")
     675  ("SEIToneMapId",                             m_toneMapId,                        0, "Specifies Id of Tone Mapping SEI message for a given session")
     676  ("SEIToneMapCancelFlag",                     m_toneMapCancelFlag,            false, "Indicates that Tone Mapping SEI message cancels the persistance or follows")
     677  ("SEIToneMapPersistenceFlag",                m_toneMapPersistenceFlag,        true, "Specifies the persistence of the Tone Mapping SEI message")
     678  ("SEIToneMapCodedDataBitDepth",              m_toneMapCodedDataBitDepth,         8, "Specifies Coded Data BitDepth of Tone Mapping SEI messages")
     679  ("SEIToneMapTargetBitDepth",                 m_toneMapTargetBitDepth,            8, "Specifies Output BitDepth of Tome mapping function")
     680  ("SEIToneMapModelId",                        m_toneMapModelId,                   0, "Specifies Model utilized for mapping coded data into target_bit_depth range\n"
     681                                                                                      "\t0:  linear mapping with clipping\n"
     682                                                                                      "\t1:  sigmoidal mapping\n"
     683                                                                                      "\t2:  user-defined table mapping\n"
     684                                                                                      "\t3:  piece-wise linear mapping\n"
     685                                                                                      "\t4:  luminance dynamic range information ")
     686  ("SEIToneMapMinValue",                              m_toneMapMinValue,                          0, "Specifies the minimum value in mode 0")
     687  ("SEIToneMapMaxValue",                              m_toneMapMaxValue,                       1023, "Specifies the maxmum value in mode 0")
     688  ("SEIToneMapSigmoidMidpoint",                       m_sigmoidMidpoint,                        512, "Specifies the centre point in mode 1")
     689  ("SEIToneMapSigmoidWidth",                          m_sigmoidWidth,                           960, "Specifies the distance between 5% and 95% values of the target_bit_depth in mode 1")
     690  ("SEIToneMapStartOfCodedInterval",                  cfg_startOfCodedInterval,          string(""), "Array of user-defined mapping table")
     691  ("SEIToneMapNumPivots",                             m_numPivots,                                0, "Specifies the number of pivot points in mode 3")
     692  ("SEIToneMapCodedPivotValue",                       cfg_codedPivotValue,               string(""), "Array of pivot point")
     693  ("SEIToneMapTargetPivotValue",                      cfg_targetPivotValue,              string(""), "Array of pivot point")
     694  ("SEIToneMapCameraIsoSpeedIdc",                     m_cameraIsoSpeedIdc,                        0, "Indicates the camera ISO speed for daylight illumination")
     695  ("SEIToneMapCameraIsoSpeedValue",                   m_cameraIsoSpeedValue,                    400, "Specifies the camera ISO speed for daylight illumination of Extended_ISO")
     696  ("SEIToneMapExposureCompensationValueSignFlag",     m_exposureCompensationValueSignFlag,        0, "Specifies the sign of ExposureCompensationValue")
     697  ("SEIToneMapExposureCompensationValueNumerator",    m_exposureCompensationValueNumerator,       0, "Specifies the numerator of ExposureCompensationValue")
     698  ("SEIToneMapExposureCompensationValueDenomIdc",     m_exposureCompensationValueDenomIdc,        2, "Specifies the denominator of ExposureCompensationValue")
     699  ("SEIToneMapRefScreenLuminanceWhite",               m_refScreenLuminanceWhite,                350, "Specifies reference screen brightness setting in units of candela per square metre")
     700  ("SEIToneMapExtendedRangeWhiteLevel",               m_extendedRangeWhiteLevel,                800, "Indicates the luminance dynamic range")
     701  ("SEIToneMapNominalBlackLevelLumaCodeValue",        m_nominalBlackLevelLumaCodeValue,          16, "Specifies luma sample value of the nominal black level assigned decoded pictures")
     702  ("SEIToneMapNominalWhiteLevelLumaCodeValue",        m_nominalWhiteLevelLumaCodeValue,         235, "Specifies luma sample value of the nominal white level assigned decoded pictures")
     703  ("SEIToneMapExtendedWhiteLevelLumaCodeValue",       m_extendedWhiteLevelLumaCodeValue,        300, "Specifies luma sample value of the extended dynamic range assigned decoded pictures")
     704#endif
    604705  ("SEIFramePacking",                m_framePackingSEIEnabled,                 0, "Control generation of frame packing SEI messages")
    605706  ("SEIFramePackingType",            m_framePackingSEIType,                    0, "Define frame packing arrangement\n"
     
    622723  ("SEIGradualDecodingRefreshInfo",  m_gradualDecodingRefreshInfoEnabled,      0, "Control generation of gradual decoding refresh information SEI message")
    623724  ("SEIDecodingUnitInfo",             m_decodingUnitInfoSEIEnabled,                       0, "Control generation of decoding unit information SEI message.")
     725#if L0208_SOP_DESCRIPTION_SEI
     726  ("SEISOPDescription",              m_SOPDescriptionSEIEnabled,              0, "Control generation of SOP description SEI messages")
     727#endif
     728#if K0180_SCALABLE_NESTING_SEI
     729  ("SEIScalableNesting",             m_scalableNestingSEIEnabled,              0, "Control generation of scalable nesting SEI messages")
     730#endif
    624731#if SIGNAL_BITRATE_PICRATE_IN_VPS
    625732  ("BitRatePicRateMaxTLayers",   m_bitRatePicRateMaxTLayers,           0, "Maximum number of sub-layers signalled; can be inferred otherwise; here for easy parsing of config. file")
     
    662769  /* convert std::string to c string for compatability */
    663770#if SVC_EXTENSION
     771#if AVC_BASE
     772  if( m_avcBaseLayerFlag )
     773  {
     774    *cfg_InputFile[0] = cfg_BLInputFile;
     775  }
     776#endif
    664777  m_pBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str());
    665778#if AVC_SYNTAX
     
    878991  }
    879992  m_iWaveFrontSubstreams = m_iWaveFrontSynchro ? (m_iSourceHeight + m_uiMaxCUHeight - 1) / m_uiMaxCUHeight : 1;
     993#endif
     994#if J0149_TONE_MAPPING_SEI
     995  if( m_toneMappingInfoSEIEnabled && !m_toneMapCancelFlag )
     996  {
     997    Char* pcStartOfCodedInterval = cfg_startOfCodedInterval.empty() ? NULL: strdup(cfg_startOfCodedInterval.c_str());
     998    Char* pcCodedPivotValue = cfg_codedPivotValue.empty() ? NULL: strdup(cfg_codedPivotValue.c_str());
     999    Char* pcTargetPivotValue = cfg_targetPivotValue.empty() ? NULL: strdup(cfg_targetPivotValue.c_str());
     1000    if( m_toneMapModelId == 2 && pcStartOfCodedInterval )
     1001    {
     1002      char *startOfCodedInterval;
     1003      UInt num = 1u<< m_toneMapTargetBitDepth;
     1004      m_startOfCodedInterval = new Int[num];
     1005      ::memset( m_startOfCodedInterval, 0, sizeof(Int)*num );
     1006      startOfCodedInterval = strtok(pcStartOfCodedInterval, " .");
     1007      int i = 0;
     1008      while( startOfCodedInterval && ( i < num ) )
     1009      {
     1010        m_startOfCodedInterval[i] = atoi( startOfCodedInterval );
     1011        startOfCodedInterval = strtok(NULL, " .");
     1012        i++;
     1013      }
     1014    }
     1015    else
     1016    {
     1017      m_startOfCodedInterval = NULL;
     1018    }
     1019    if( ( m_toneMapModelId == 3 ) && ( m_numPivots > 0 ) )
     1020    {
     1021      if( pcCodedPivotValue && pcTargetPivotValue )
     1022      {
     1023        char *codedPivotValue;
     1024        char *targetPivotValue;
     1025        m_codedPivotValue = new Int[m_numPivots];
     1026        m_targetPivotValue = new Int[m_numPivots];
     1027        ::memset( m_codedPivotValue, 0, sizeof(Int)*( m_numPivots ) );
     1028        ::memset( m_targetPivotValue, 0, sizeof(Int)*( m_numPivots ) );
     1029        codedPivotValue = strtok(pcCodedPivotValue, " .");
     1030        int i=0;
     1031        while(codedPivotValue&&i<m_numPivots)
     1032        {
     1033          m_codedPivotValue[i] = atoi( codedPivotValue );
     1034          codedPivotValue = strtok(NULL, " .");
     1035          i++;
     1036        }
     1037        i=0;
     1038        targetPivotValue = strtok(pcTargetPivotValue, " .");
     1039        while(targetPivotValue&&i<m_numPivots)
     1040        {
     1041          m_targetPivotValue[i]= atoi( targetPivotValue );
     1042          targetPivotValue = strtok(NULL, " .");
     1043          i++;
     1044        }
     1045      }
     1046    }
     1047    else
     1048    {
     1049      m_codedPivotValue = NULL;
     1050      m_targetPivotValue = NULL;
     1051    }
     1052  }
    8801053#endif
    8811054  // check validity of input parameters
     
    11391312
    11401313#if SVC_EXTENSION
     1314  xConfirmPara( m_numLayers > MAX_LAYERS , "Number of layers in config file is greater than MAX_LAYERS" );
     1315  m_numLayers = m_numLayers > MAX_LAYERS ? MAX_LAYERS : m_numLayers;
     1316
    11411317  // verify layer configuration parameters
    11421318  for(UInt layer=0; layer<m_numLayers; layer++)
     
    13751551  {
    13761552    m_numReorderPics[i] = 0;
     1553#if L0323_DPB
     1554    m_maxDecPicBuffering[i] = 1;
     1555#else
    13771556    m_maxDecPicBuffering[i] = 0;
     1557#endif
    13781558  }
    13791559  for(Int i=0; i<m_iGOPSize; i++)
    13801560  {
     1561#if L0323_DPB
     1562    if(m_GOPList[i].m_numRefPics+1 > m_maxDecPicBuffering[m_GOPList[i].m_temporalId])
     1563#else
    13811564    if(m_GOPList[i].m_numRefPics > m_maxDecPicBuffering[m_GOPList[i].m_temporalId])
    1382     {
     1565#endif
     1566    {
     1567#if L0323_DPB
     1568      m_maxDecPicBuffering[m_GOPList[i].m_temporalId] = m_GOPList[i].m_numRefPics + 1;
     1569#else
    13831570      m_maxDecPicBuffering[m_GOPList[i].m_temporalId] = m_GOPList[i].m_numRefPics;
     1571#endif
    13841572    }
    13851573    Int highestDecodingNumberWithLowerPOC = 0;
     
    14121600      m_numReorderPics[i+1] = m_numReorderPics[i];
    14131601    }
     1602#if L0323_DPB
     1603    // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ] - 1, inclusive
     1604    if(m_numReorderPics[i] > m_maxDecPicBuffering[i] - 1)
     1605    {
     1606      m_maxDecPicBuffering[i] = m_numReorderPics[i] + 1;
     1607    }
     1608#else
    14141609    // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ], inclusive
    14151610    if(m_numReorderPics[i] > m_maxDecPicBuffering[i])
     
    14171612      m_maxDecPicBuffering[i] = m_numReorderPics[i];
    14181613    }
     1614#endif
    14191615    // a lower layer can not have higher value of m_uiMaxDecPicBuffering than a higher layer
    14201616    if(m_maxDecPicBuffering[i+1] < m_maxDecPicBuffering[i])
     
    14231619    }
    14241620  }
     1621
     1622
     1623#if L0323_DPB
     1624  // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ] -  1, inclusive
     1625  if(m_numReorderPics[MAX_TLAYER-1] > m_maxDecPicBuffering[MAX_TLAYER-1] - 1)
     1626  {
     1627    m_maxDecPicBuffering[MAX_TLAYER-1] = m_numReorderPics[MAX_TLAYER-1] + 1;
     1628  }
     1629#else
    14251630  // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ], inclusive
    14261631  if(m_numReorderPics[MAX_TLAYER-1] > m_maxDecPicBuffering[MAX_TLAYER-1])
     
    14281633    m_maxDecPicBuffering[MAX_TLAYER-1] = m_numReorderPics[MAX_TLAYER-1];
    14291634  }
     1635#endif
    14301636
    14311637#if SVC_EXTENSION // ToDo: it should be checked for the case when parameters are different for the layers
     
    15111717  }
    15121718#endif
    1513 
     1719#if !L0034_COMBINED_LIST_CLEANUP
    15141720  xConfirmPara( m_bUseLComb==false && m_numReorderPics[MAX_TLAYER-1]!=0, "ListCombination can only be 0 in low delay coding (more precisely when L0 and L1 are identical)" );  // Note however this is not the full necessary condition as ref_pic_list_combination_flag can only be 0 if L0 == L1.
     1721#endif
    15151722  xConfirmPara( m_iWaveFrontSynchro < 0, "WaveFrontSynchro cannot be negative" );
    15161723#if !SVC_EXTENSION
     
    15201727
    15211728  xConfirmPara( m_decodedPictureHashSEIEnabled<0 || m_decodedPictureHashSEIEnabled>3, "this hash type is not correct!\n");
     1729
     1730#if J0149_TONE_MAPPING_SEI
     1731  if (m_toneMappingInfoSEIEnabled)
     1732  {
     1733    xConfirmPara( m_toneMapCodedDataBitDepth < 8 || m_toneMapCodedDataBitDepth > 14 , "SEIToneMapCodedDataBitDepth must be in rage 8 to 14");
     1734    xConfirmPara( m_toneMapTargetBitDepth < 1 || (m_toneMapTargetBitDepth > 16 && m_toneMapTargetBitDepth < 255) , "SEIToneMapTargetBitDepth must be in rage 1 to 16 or equal to 255");
     1735    xConfirmPara( m_toneMapModelId < 0 || m_toneMapModelId > 4 , "SEIToneMapModelId must be in rage 0 to 4");
     1736    xConfirmPara( m_cameraIsoSpeedValue == 0, "SEIToneMapCameraIsoSpeedValue shall not be equal to 0");
     1737    xConfirmPara( m_extendedRangeWhiteLevel < 100, "SEIToneMapExtendedRangeWhiteLevel should be greater than or equal to 100");
     1738    xConfirmPara( m_nominalBlackLevelLumaCodeValue >= m_nominalWhiteLevelLumaCodeValue, "SEIToneMapNominalWhiteLevelLumaCodeValue shall be greater than SEIToneMapNominalBlackLevelLumaCodeValue");
     1739    xConfirmPara( m_extendedWhiteLevelLumaCodeValue < m_nominalWhiteLevelLumaCodeValue, "SEIToneMapExtendedWhiteLevelLumaCodeValue shall be greater than or equal to SEIToneMapNominalWhiteLevelLumaCodeValue");
     1740  }
     1741#endif
    15221742
    15231743#if RATE_CONTROL_LAMBDA_DOMAIN
     
    16091829  {
    16101830    printf("=== Layer %d settings === \n", layer);
     1831#if AVC_SYNTAX
     1832    m_acLayerCfg[layer].xPrintParameter( layer );
     1833#else
    16111834    m_acLayerCfg[layer].xPrintParameter();
     1835#endif
    16121836    printf("\n");
    16131837  }
     
    16771901  printf("SQP:%d ", m_uiDeltaQpRD         );
    16781902  printf("ASR:%d ", m_bUseASR             );
     1903#if !L0034_COMBINED_LIST_CLEANUP
    16791904  printf("LComb:%d ", m_bUseLComb         );
     1905#endif
    16801906  printf("FEN:%d ", m_bUseFastEnc         );
    16811907  printf("ECU:%d ", m_bUseEarlyCU         );
     
    17181944#if SVC_EXTENSION
    17191945  printf("RecalQP:%d ", m_recalculateQPAccordingToLambda ? 1 : 0 );
    1720   printf("AVC_BASE:%d ", AVC_BASE);
     1946#if AVC_BASE
     1947  printf("AvcBase:%d ", m_avcBaseLayerFlag ? 1 : 0);
     1948#else
     1949  printf("AvcBase:%d ", 0);
     1950#endif
    17211951#if REF_IDX_FRAMEWORK
    17221952  printf("REF_IDX_FRAMEWORK:%d ", REF_IDX_FRAMEWORK);
    17231953  printf("EL_RAP_SliceType: %d ", m_elRapSliceBEnabled);
    1724   printf("REF_IDX_ME_ZEROMV: %d", REF_IDX_ME_ZEROMV);
     1954  printf("REF_IDX_ME_ZEROMV: %d ", REF_IDX_ME_ZEROMV);
     1955  printf("ENCODER_FAST_MODE: %d ", ENCODER_FAST_MODE);
     1956  printf("REF_IDX_MFM: %d ", REF_IDX_MFM);
    17251957#elif INTRA_BL
    17261958  printf("INTRA_BL:%d ", INTRA_BL);
  • trunk/source/App/TAppEncoder/TAppEncCfg.h

    r125 r189  
    6767  UInt      m_FrameSkip;                                      ///< number of skipped frames from the beginning
    6868  Int       m_framesToBeEncoded;                              ///< number of encoded frames
     69#if AVC_BASE
     70  Int       m_avcBaseLayerFlag;                               ///< AVC_BASElayer_flag
     71#endif
    6972#if AVC_SYNTAX
    70   char*     m_BLSyntaxFile;                                   ///< input syntax file
     73  Char*     m_BLSyntaxFile;                                   ///< input syntax file
    7174#endif
    7275#else
     
    109112  GOPEntry  m_GOPList[MAX_GOP];                               ///< the coding structure entries from the config file
    110113  Int       m_numReorderPics[MAX_TLAYER];                     ///< total number of reorder pictures
     114#if L0323_DPB
     115  Int       m_maxDecPicBuffering[MAX_TLAYER];                 ///< total number of pictures in the decoded picture buffer
     116#else
    111117  Int       m_maxDecPicBuffering[MAX_TLAYER];                 ///< total number of reference pictures needed for decoding
     118#endif
     119#if !L0034_COMBINED_LIST_CLEANUP
    112120  Bool      m_bUseLComb;                                      ///< flag for using combined reference list for uni-prediction in B-slices (JCTVC-D421)
     121#endif
    113122  Bool      m_useTransformSkip;                               ///< flag for enabling intra transform skipping
    114123  Bool      m_useTransformSkipFast;                           ///< flag for enabling fast intra transform skipping
     
    172181  Int       m_loopFilterTcOffsetDiv2;                       ///< tc offset for deblocking filter
    173182  Bool      m_DeblockingFilterControlPresent;                 ///< deblocking filter control present flag in PPS
     183#if L0386_DB_METRIC
     184  Bool      m_DeblockingFilterMetric;                         ///< blockiness metric in encoder
     185#endif
    174186 
    175187  // coding tools (PCM)
     
    223235  Int       m_bufferingPeriodSEIEnabled;
    224236  Int       m_pictureTimingSEIEnabled;
     237#if J0149_TONE_MAPPING_SEI
     238  Bool      m_toneMappingInfoSEIEnabled;
     239  Int       m_toneMapId;
     240  Bool      m_toneMapCancelFlag;
     241  Bool      m_toneMapPersistenceFlag;
     242  Int       m_toneMapCodedDataBitDepth;
     243  Int       m_toneMapTargetBitDepth;
     244  Int       m_toneMapModelId;
     245  Int       m_toneMapMinValue;
     246  Int       m_toneMapMaxValue;
     247  Int       m_sigmoidMidpoint;
     248  Int       m_sigmoidWidth;
     249  Int       m_numPivots;
     250  Int       m_cameraIsoSpeedIdc;
     251  Int       m_cameraIsoSpeedValue;
     252  Int       m_exposureCompensationValueSignFlag;
     253  Int       m_exposureCompensationValueNumerator;
     254  Int       m_exposureCompensationValueDenomIdc;
     255  Int       m_refScreenLuminanceWhite;
     256  Int       m_extendedRangeWhiteLevel;
     257  Int       m_nominalBlackLevelLumaCodeValue;
     258  Int       m_nominalWhiteLevelLumaCodeValue;
     259  Int       m_extendedWhiteLevelLumaCodeValue;
     260  Int*      m_startOfCodedInterval;
     261  Int*      m_codedPivotValue;
     262  Int*      m_targetPivotValue;
     263#endif
    225264  Int       m_framePackingSEIEnabled;
    226265  Int       m_framePackingSEIType;
     
    232271  Int       m_gradualDecodingRefreshInfoEnabled;
    233272  Int       m_decodingUnitInfoSEIEnabled;
     273#if L0208_SOP_DESCRIPTION_SEI
     274  Int       m_SOPDescriptionSEIEnabled;
     275#endif
     276#if K0180_SCALABLE_NESTING_SEI
     277  Int       m_scalableNestingSEIEnabled;
     278#endif
    234279  // weighted prediction
    235280  Bool      m_useWeightedPred;                    ///< Use of weighted prediction in P slices
     
    316361  Int*      m_constantPicRateIdc;                                ///< Indicates constant picture rate idc for various sub-layers
    317362#endif
    318   #
    319363public:
    320364  TAppEncCfg();
  • trunk/source/App/TAppEncoder/TAppEncLayerCfg.cpp

    r125 r189  
    116116}
    117117
     118#if AVC_SYNTAX
     119Void TAppEncLayerCfg::xPrintParameter( UInt layerId )
     120#else
    118121Void TAppEncLayerCfg::xPrintParameter()
     122#endif
    119123{
    120124  printf("Input File                    : %s\n", m_cInputFile.c_str()  );
    121125  printf("Reconstruction File           : %s\n", m_cReconFile.c_str()  );
    122126#if AVC_SYNTAX
    123   printf("Base layer input file         : %s\n", m_cAppEncCfg->getBLSyntaxFile() );
     127  if( layerId == 0 )
     128  {
     129    printf("Base layer syntax file        : %s\n", m_cAppEncCfg->getBLSyntaxFile() );
     130  }
    124131#endif
    125132  printf("Real     Format               : %dx%d %dHz\n", m_iSourceWidth - m_confLeft - m_confRight, m_iSourceHeight - m_confTop - m_confBottom, m_iFrameRate );
  • trunk/source/App/TAppEncoder/TAppEncLayerCfg.h

    r125 r189  
    5454  Int*      m_aidQP;                                          ///< array of slice QP values
    5555  TAppEncCfg* m_cAppEncCfg;                                   ///< pointer to app encoder config
     56#if SCALED_REF_LAYER_OFFSETS
     57  Int       m_scaledRefLayerLeftOffset;
     58  Int       m_scaledRefLayerTopOffset;
     59  Int       m_scaledRefLayerRightOffset;
     60  Int       m_scaledRefLayerBottomOffset;
     61#endif 
    5662public:
    5763  TAppEncLayerCfg();
     
    6369  bool  parseCfg  ( const string& cfgFileName );              ///< parse layer configuration file to fill member variables
    6470
     71#if AVC_SYNTAX
     72  Void  xPrintParameter( UInt layerId );
     73#else
    6574  Void  xPrintParameter();
     75#endif
    6676  Bool  xCheckParameter();
    6777
  • trunk/source/App/TAppEncoder/TAppEncTop.cpp

    r125 r189  
    11/* The copyright in this software is being made available under the BSD
    2 * License, included below. This software may be subject to other third party
    3 * and contributor rights, including patent rights, and no such rights are
    4 * granted under this license. 
    5 *
    6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    7 * All rights reserved.
    8 *
    9 * Redistribution and use in source and binary forms, with or without
    10 * modification, are permitted provided that the following conditions are met:
    11 *
    12 *  * Redistributions of source code must retain the above copyright notice,
    13 *    this list of conditions and the following disclaimer.
    14 *  * Redistributions in binary form must reproduce the above copyright notice,
    15 *    this list of conditions and the following disclaimer in the documentation
    16 *    and/or other materials provided with the distribution.
    17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
    18 *    be used to endorse or promote products derived from this software without
    19 *    specific prior written permission.
    20 *
    21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
    25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
    31 * THE POSSIBILITY OF SUCH DAMAGE.
    32 */
     2 * License, included below. This software may be subject to other third party
     3 * and contributor rights, including patent rights, and no such rights are
     4 * granted under this license. 
     5 *
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
     7 * All rights reserved.
     8 *
     9 * Redistribution and use in source and binary forms, with or without
     10 * modification, are permitted provided that the following conditions are met:
     11 *
     12 *  * Redistributions of source code must retain the above copyright notice,
     13 *    this list of conditions and the following disclaimer.
     14 *  * Redistributions in binary form must reproduce the above copyright notice,
     15 *    this list of conditions and the following disclaimer in the documentation
     16 *    and/or other materials provided with the distribution.
     17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
     18 *    be used to endorse or promote products derived from this software without
     19 *    specific prior written permission.
     20 *
     21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
     25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     31 * THE POSSIBILITY OF SUCH DAMAGE.
     32 */
    3333
    3434/** \file     TAppEncTop.cpp
    35 \brief    Encoder application class
     35    \brief    Encoder application class
    3636*/
    3737
     
    112112
    113113#if REF_IDX_MFM
     114#if AVC_BASE
     115    m_acTEncTop[layer].setMFMEnabledFlag(layer == 0 ? false : ( m_avcBaseLayerFlag ? AVC_SYNTAX : true ));
     116#else
    114117    m_acTEncTop[layer].setMFMEnabledFlag(layer == 0 ? false : true);
     118#endif
    115119#endif
    116120    // set layer ID
     
    167171    m_acTEncTop[layer].setLoopFilterTcOffset           ( m_loopFilterTcOffsetDiv2    );
    168172    m_acTEncTop[layer].setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent);
     173#if L0386_DB_METRIC
     174    m_acTEncTop[layer].setDeblockingFilterMetric       ( m_DeblockingFilterMetric );
     175#endif
    169176
    170177    //====== Motion search ========
     
    200207    m_acTEncTop[layer].setUseHADME                     ( m_bUseHADME    );
    201208    m_acTEncTop[layer].setUseLossless                  ( m_useLossless );
    202     m_acTEncTop[layer].setUseLComb                     ( m_bUseLComb    );
     209#if !L0034_COMBINED_LIST_CLEANUP
     210    m_cTEncTop.setUseLComb                             ( m_bUseLComb    );
     211#endif
    203212    m_acTEncTop[layer].setdQPs                         ( m_acLayerCfg[layer].getdQPs() );
    204213    m_acTEncTop[layer].setUseRDOQ                      ( m_useRDOQ     );
     
    270279    m_acTEncTop[layer].setBufferingPeriodSEIEnabled( m_bufferingPeriodSEIEnabled );
    271280    m_acTEncTop[layer].setPictureTimingSEIEnabled( m_pictureTimingSEIEnabled );
     281#if J0149_TONE_MAPPING_SEI
     282    m_acTEncTop[layer].setToneMappingInfoSEIEnabled                 ( m_toneMappingInfoSEIEnabled );
     283    m_acTEncTop[layer].setTMISEIToneMapId                           ( m_toneMapId );
     284    m_acTEncTop[layer].setTMISEIToneMapCancelFlag                   ( m_toneMapCancelFlag );
     285    m_acTEncTop[layer].setTMISEIToneMapPersistenceFlag              ( m_toneMapPersistenceFlag );
     286    m_acTEncTop[layer].setTMISEICodedDataBitDepth                   ( m_toneMapCodedDataBitDepth );
     287    m_acTEncTop[layer].setTMISEITargetBitDepth                      ( m_toneMapTargetBitDepth );
     288    m_acTEncTop[layer].setTMISEIModelID                             ( m_toneMapModelId );
     289    m_acTEncTop[layer].setTMISEIMinValue                            ( m_toneMapMinValue );
     290    m_acTEncTop[layer].setTMISEIMaxValue                            ( m_toneMapMaxValue );
     291    m_acTEncTop[layer].setTMISEISigmoidMidpoint                     ( m_sigmoidMidpoint );
     292    m_acTEncTop[layer].setTMISEISigmoidWidth                        ( m_sigmoidWidth );
     293    m_acTEncTop[layer].setTMISEIStartOfCodedInterva                 ( m_startOfCodedInterval );
     294    m_acTEncTop[layer].setTMISEINumPivots                           ( m_numPivots );
     295    m_acTEncTop[layer].setTMISEICodedPivotValue                     ( m_codedPivotValue );
     296    m_acTEncTop[layer].setTMISEITargetPivotValue                    ( m_targetPivotValue );
     297    m_acTEncTop[layer].setTMISEICameraIsoSpeedIdc                   ( m_cameraIsoSpeedIdc );
     298    m_acTEncTop[layer].setTMISEICameraIsoSpeedValue                 ( m_cameraIsoSpeedValue );
     299    m_acTEncTop[layer].setTMISEIExposureCompensationValueSignFlag   ( m_exposureCompensationValueSignFlag );
     300    m_acTEncTop[layer].setTMISEIExposureCompensationValueNumerator  ( m_exposureCompensationValueNumerator );
     301    m_acTEncTop[layer].setTMISEIExposureCompensationValueDenomIdc   ( m_exposureCompensationValueDenomIdc );
     302    m_acTEncTop[layer].setTMISEIRefScreenLuminanceWhite             ( m_refScreenLuminanceWhite );
     303    m_acTEncTop[layer].setTMISEIExtendedRangeWhiteLevel             ( m_extendedRangeWhiteLevel );
     304    m_acTEncTop[layer].setTMISEINominalBlackLevelLumaCodeValue      ( m_nominalBlackLevelLumaCodeValue );
     305    m_acTEncTop[layer].setTMISEINominalWhiteLevelLumaCodeValue      ( m_nominalWhiteLevelLumaCodeValue );
     306    m_acTEncTop[layer].setTMISEIExtendedWhiteLevelLumaCodeValue     ( m_extendedWhiteLevelLumaCodeValue );
     307#endif
    272308    m_acTEncTop[layer].setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled );
    273309    m_acTEncTop[layer].setFramePackingArrangementSEIType( m_framePackingSEIType );
     
    279315    m_acTEncTop[layer].setGradualDecodingRefreshInfoEnabled( m_gradualDecodingRefreshInfoEnabled );
    280316    m_acTEncTop[layer].setDecodingUnitInfoSEIEnabled( m_decodingUnitInfoSEIEnabled );
     317#if L0208_SOP_DESCRIPTION_SEI
     318    m_acTEncTop[layer].setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled );
     319#endif
     320#if K0180_SCALABLE_NESTING_SEI
     321    m_acTEncTop[layer].setScalableNestingSEIEnabled( m_scalableNestingSEIEnabled );
     322#endif
    281323    m_acTEncTop[layer].setUniformSpacingIdr          ( m_iUniformSpacingIdr );
    282324    m_acTEncTop[layer].setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
     
    376418    m_acTEncTop[layer].setElRapSliceTypeB(layer == 0? 0 : m_elRapSliceBEnabled);
    377419#endif
     420#if SCALED_REF_LAYER_OFFSETS
     421    if( layer > 0 )
     422    {
     423      m_acTEncTop[layer].getScaledRefLayerWindow().setWindow( 2*m_acLayerCfg[layer].m_scaledRefLayerLeftOffset, 2*m_acLayerCfg[layer].m_scaledRefLayerRightOffset,
     424                                                  2*m_acLayerCfg[layer].m_scaledRefLayerTopOffset, 2*m_acLayerCfg[layer].m_scaledRefLayerBottomOffset); 
     425    }
     426#endif
    378427  }
    379428}
     
    442491  m_cTEncTop.setLoopFilterTcOffset           ( m_loopFilterTcOffsetDiv2    );
    443492  m_cTEncTop.setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent);
     493#if L0386_DB_METRIC
     494  m_cTEncTop.setDeblockingFilterMetric       ( m_DeblockingFilterMetric );
     495#endif
    444496
    445497  //====== Motion search ========
     
    475527  m_cTEncTop.setUseHADME                     ( m_bUseHADME    );
    476528  m_cTEncTop.setUseLossless                  ( m_useLossless );
     529#if !L0034_COMBINED_LIST_CLEANUP
    477530  m_cTEncTop.setUseLComb                     ( m_bUseLComb    );
     531#endif
    478532  m_cTEncTop.setdQPs                         ( m_aidQP        );
    479533  m_cTEncTop.setUseRDOQ                      ( m_useRDOQ     );
     
    545599  m_cTEncTop.setBufferingPeriodSEIEnabled( m_bufferingPeriodSEIEnabled );
    546600  m_cTEncTop.setPictureTimingSEIEnabled( m_pictureTimingSEIEnabled );
     601#if J0149_TONE_MAPPING_SEI
     602  m_cTEncTop.setToneMappingInfoSEIEnabled                 ( m_toneMappingInfoSEIEnabled );
     603  m_cTEncTop.setTMISEIToneMapId                           ( m_toneMapId );
     604  m_cTEncTop.setTMISEIToneMapCancelFlag                   ( m_toneMapCancelFlag );
     605  m_cTEncTop.setTMISEIToneMapPersistenceFlag              ( m_toneMapPersistenceFlag );
     606  m_cTEncTop.setTMISEICodedDataBitDepth                   ( m_toneMapCodedDataBitDepth );
     607  m_cTEncTop.setTMISEITargetBitDepth                      ( m_toneMapTargetBitDepth );
     608  m_cTEncTop.setTMISEIModelID                             ( m_toneMapModelId );
     609  m_cTEncTop.setTMISEIMinValue                            ( m_toneMapMinValue );
     610  m_cTEncTop.setTMISEIMaxValue                            ( m_toneMapMaxValue );
     611  m_cTEncTop.setTMISEISigmoidMidpoint                     ( m_sigmoidMidpoint );
     612  m_cTEncTop.setTMISEISigmoidWidth                        ( m_sigmoidWidth );
     613  m_cTEncTop.setTMISEIStartOfCodedInterva                 ( m_startOfCodedInterval );
     614  m_cTEncTop.setTMISEINumPivots                           ( m_numPivots );
     615  m_cTEncTop.setTMISEICodedPivotValue                     ( m_codedPivotValue );
     616  m_cTEncTop.setTMISEITargetPivotValue                    ( m_targetPivotValue );
     617  m_cTEncTop.setTMISEICameraIsoSpeedIdc                   ( m_cameraIsoSpeedIdc );
     618  m_cTEncTop.setTMISEICameraIsoSpeedValue                 ( m_cameraIsoSpeedValue );
     619  m_cTEncTop.setTMISEIExposureCompensationValueSignFlag   ( m_exposureCompensationValueSignFlag );
     620  m_cTEncTop.setTMISEIExposureCompensationValueNumerator  ( m_exposureCompensationValueNumerator );
     621  m_cTEncTop.setTMISEIExposureCompensationValueDenomIdc   ( m_exposureCompensationValueDenomIdc );
     622  m_cTEncTop.setTMISEIRefScreenLuminanceWhite             ( m_refScreenLuminanceWhite );
     623  m_cTEncTop.setTMISEIExtendedRangeWhiteLevel             ( m_extendedRangeWhiteLevel );
     624  m_cTEncTop.setTMISEINominalBlackLevelLumaCodeValue      ( m_nominalBlackLevelLumaCodeValue );
     625  m_cTEncTop.setTMISEINominalWhiteLevelLumaCodeValue      ( m_nominalWhiteLevelLumaCodeValue );
     626  m_cTEncTop.setTMISEIExtendedWhiteLevelLumaCodeValue     ( m_extendedWhiteLevelLumaCodeValue );
     627#endif
    547628  m_cTEncTop.setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled );
    548629  m_cTEncTop.setFramePackingArrangementSEIType( m_framePackingSEIType );
     
    554635  m_cTEncTop.setGradualDecodingRefreshInfoEnabled( m_gradualDecodingRefreshInfoEnabled );
    555636  m_cTEncTop.setDecodingUnitInfoSEIEnabled( m_decodingUnitInfoSEIEnabled );
     637#if L0208_SOP_DESCRIPTION_SEI
     638  m_cTEncTop.setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled );
     639#endif
     640#if K0180_SCALABLE_NESTING_SEI
     641  m_cTEncTop.setScalableNestingSEIEnabled( m_scalableNestingSEIEnabled );
     642#endif
    556643  m_cTEncTop.setUniformSpacingIdr          ( m_iUniformSpacingIdr );
    557644  m_cTEncTop.setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
     
    729816#if VPS_EXTN_MASK_AND_DIM_INFO
    730817  UInt i = 0, dimIdLen = 0;
     818#if AVC_BASE
     819  vps->setAvcBaseLayerFlag(m_avcBaseLayerFlag);
     820#else
    731821  vps->setAvcBaseLayerFlag(false);
     822#endif
    732823  vps->setSplittingFlag(false);
    733824  for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++)
     
    769860#endif
    770861  // Target output layer
     862#if VPS_PROFILE_OUTPUT_LAYERS
     863  vps->setNumOutputLayerSets(2);    // 2 including the default base-layer set.
     864  vps->setNumProfileTierLevel(2);   // 1 for the enhancement layer
     865  vps->setProfileLevelTierIdx(1, 1);
     866  vps->setDefaultOneTargetOutputLayerFlag(true);
     867  Int lsIdx = 1;
     868  vps->setOutputLayerSetIdx(1, lsIdx); // Because only one layer set
     869#else
    771870  vps->setNumOutputLayerSets(1);
    772871  Int lsIdx = 1;
    773872  vps->setOutputLayerSetIdx(0, lsIdx); // Because only one layer set
     873#endif
    774874  // Include the highest layer as output layer
    775875  for(UInt layer=0; layer <= vps->getMaxLayerId() ; layer++)
     
    802902  }
    803903#endif
     904#if JCTVC_M0458_INTERLAYER_RPS_SIG       
     905    vps->setMaxOneActiveRefLayerFlag(true);
     906#endif
    804907#else
    805908  m_cTEncTop.init();
     
    812915
    813916/**
    814 - create internal class
    815 - initialize internal variable
    816 - until the end of input YUV file, call encoding function in TEncTop class
    817 - delete allocated buffers
    818 - destroy internal class
    819 .
    820 */
     917 - create internal class
     918 - initialize internal variable
     919 - until the end of input YUV file, call encoding function in TEncTop class
     920 - delete allocated buffers
     921 - destroy internal class
     922 .
     923 */
    821924#if SVC_EXTENSION
    822925Void TAppEncTop::encode()
     
    855958
    856959#if AVC_SYNTAX
    857   if( !m_BLSyntaxFile )
    858   {
    859     printf( "Wrong base layer syntax input file\n" );
    860     exit(EXIT_FAILURE);
    861   }
    862   fstream streamSyntaxFile( m_BLSyntaxFile, fstream::in | fstream::binary );
    863   if( !streamSyntaxFile.good() )
    864   {
    865     printf( "Base layer syntax input reading error\n" );
    866     exit(EXIT_FAILURE);
    867   }
    868   m_acTEncTop[0].setBLSyntaxFile( &streamSyntaxFile );
     960  fstream streamSyntaxFile;
     961  if( m_acTEncTop[0].getVPS()->getAvcBaseLayerFlag() )
     962  {
     963    if( !m_BLSyntaxFile )
     964    {
     965      printf( "Wrong base layer syntax input file\n" );
     966      exit(EXIT_FAILURE);
     967    }
     968    streamSyntaxFile.open( m_BLSyntaxFile, fstream::in | fstream::binary );
     969    if( !streamSyntaxFile.good() )
     970    {
     971      printf( "Base layer syntax input reading error\n" );
     972      exit(EXIT_FAILURE);
     973    }
     974    m_acTEncTop[0].setBLSyntaxFile( &streamSyntaxFile );
     975  }
    869976#endif
    870977
     
    11021209
    11031210/**
    1104 - application has picture buffer list with size of GOP
    1105 - picture buffer list acts as ring buffer
    1106 - end of the list has the latest picture
    1107 .
    1108 */
     1211 - application has picture buffer list with size of GOP
     1212 - picture buffer list acts as ring buffer
     1213 - end of the list has the latest picture
     1214 .
     1215 */
    11091216#if SVC_EXTENSION
    11101217Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, UInt layer)
     
    12221329
    12231330/** \param iNumEncoded  number of encoded frames
    1224 */
     1331 */
    12251332Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits)
    12261333{
     
    12401347    if (m_pchReconFile)
    12411348    {
     1349#if SYNTAX_OUTPUT && ILP_DECODED_PICTURE
     1350      m_cTVideoIOYuvReconFile.write( pcPicYuvRec );
     1351#else
    12421352      m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom );
     1353#endif
    12431354    }
    12441355
     
    12511362
    12521363/**
    1253 *
    1254 */
     1364 *
     1365 */
    12551366void TAppEncTop::rateStatsAccum(const AccessUnit& au, const std::vector<UInt>& annexBsizes)
    12561367{
     
    12641375    case NAL_UNIT_CODED_SLICE_TRAIL_R:
    12651376    case NAL_UNIT_CODED_SLICE_TRAIL_N:
    1266     case NAL_UNIT_CODED_SLICE_TLA:
     1377    case NAL_UNIT_CODED_SLICE_TLA_R:
    12671378    case NAL_UNIT_CODED_SLICE_TSA_N:
    12681379    case NAL_UNIT_CODED_SLICE_STSA_R:
    12691380    case NAL_UNIT_CODED_SLICE_STSA_N:
    1270     case NAL_UNIT_CODED_SLICE_BLA:
    1271     case NAL_UNIT_CODED_SLICE_BLANT:
     1381    case NAL_UNIT_CODED_SLICE_BLA_W_LP:
     1382    case NAL_UNIT_CODED_SLICE_BLA_W_RADL:
    12721383    case NAL_UNIT_CODED_SLICE_BLA_N_LP:
    1273     case NAL_UNIT_CODED_SLICE_IDR:
     1384    case NAL_UNIT_CODED_SLICE_IDR_W_RADL:
    12741385    case NAL_UNIT_CODED_SLICE_IDR_N_LP:
    12751386    case NAL_UNIT_CODED_SLICE_CRA:
    12761387    case NAL_UNIT_CODED_SLICE_RADL_N:
    1277     case NAL_UNIT_CODED_SLICE_DLP:
     1388    case NAL_UNIT_CODED_SLICE_RADL_R:
    12781389    case NAL_UNIT_CODED_SLICE_RASL_N:
    1279     case NAL_UNIT_CODED_SLICE_TFD:
     1390    case NAL_UNIT_CODED_SLICE_RASL_R:
    12801391    case NAL_UNIT_VPS:
    12811392    case NAL_UNIT_SPS:
  • trunk/source/Lib/TLibCommon/CommonDef.h

    r125 r189  
    5656// ====================================================================================================================
    5757
    58 #define NV_VERSION        "1.2"                 ///< Current software version
     58#define NV_VERSION        "2.0rc1"                 ///< Current software version
    5959
    6060// ====================================================================================================================
     
    110110#define MAX_NUM_REF_PICS            16          ///< max. number of pictures used for reference
    111111#define MAX_NUM_REF                 16          ///< max. number of entries in picture reference list
     112#if !L0034_COMBINED_LIST_CLEANUP
    112113#define MAX_NUM_REF_LC              MAX_NUM_REF_PICS  // TODO: remove this macro definition (leftover from combined list concept)
     114#endif
    113115
    114116#define MAX_UINT                    0xFFFFFFFFU ///< max. value of unsigned 32-bit integer
     
    197199 
    198200  NAL_UNIT_CODED_SLICE_TSA_N,     // 2
    199   NAL_UNIT_CODED_SLICE_TLA,       // 3   // Current name in the spec: TSA_R
     201  NAL_UNIT_CODED_SLICE_TLA_R,       // 3
    200202 
    201203  NAL_UNIT_CODED_SLICE_STSA_N,    // 4
     
    203205
    204206  NAL_UNIT_CODED_SLICE_RADL_N,    // 6
    205   NAL_UNIT_CODED_SLICE_DLP,       // 7 // Current name in the spec: RADL_R
     207  NAL_UNIT_CODED_SLICE_RADL_R,      // 7
    206208 
    207209  NAL_UNIT_CODED_SLICE_RASL_N,    // 8
    208   NAL_UNIT_CODED_SLICE_TFD,       // 9 // Current name in the spec: RASL_R
    209 
    210   NAL_UNIT_RESERVED_10,
    211   NAL_UNIT_RESERVED_11,
    212   NAL_UNIT_RESERVED_12,
    213   NAL_UNIT_RESERVED_13,
    214   NAL_UNIT_RESERVED_14,
    215   NAL_UNIT_RESERVED_15,
    216 
    217   NAL_UNIT_CODED_SLICE_BLA,       // 16   // Current name in the spec: BLA_W_LP
    218   NAL_UNIT_CODED_SLICE_BLANT,     // 17   // Current name in the spec: BLA_W_DLP
     210  NAL_UNIT_CODED_SLICE_RASL_R,      // 9
     211
     212  NAL_UNIT_RESERVED_VCL_N10,
     213  NAL_UNIT_RESERVED_VCL_R11,
     214  NAL_UNIT_RESERVED_VCL_N12,
     215  NAL_UNIT_RESERVED_VCL_R13,
     216  NAL_UNIT_RESERVED_VCL_N14,
     217  NAL_UNIT_RESERVED_VCL_R15,
     218
     219  NAL_UNIT_CODED_SLICE_BLA_W_LP,    // 16
     220  NAL_UNIT_CODED_SLICE_BLA_W_RADL,  // 17
    219221  NAL_UNIT_CODED_SLICE_BLA_N_LP,  // 18
    220   NAL_UNIT_CODED_SLICE_IDR,       // 19  // Current name in the spec: IDR_W_DLP
     222  NAL_UNIT_CODED_SLICE_IDR_W_RADL,  // 19
    221223  NAL_UNIT_CODED_SLICE_IDR_N_LP,  // 20
    222224  NAL_UNIT_CODED_SLICE_CRA,       // 21
    223   NAL_UNIT_RESERVED_22,
    224   NAL_UNIT_RESERVED_23,
    225 
    226   NAL_UNIT_RESERVED_24,
    227   NAL_UNIT_RESERVED_25,
    228   NAL_UNIT_RESERVED_26,
    229   NAL_UNIT_RESERVED_27,
    230   NAL_UNIT_RESERVED_28,
    231   NAL_UNIT_RESERVED_29,
    232   NAL_UNIT_RESERVED_30,
    233   NAL_UNIT_RESERVED_31,
     225  NAL_UNIT_RESERVED_IRAP_VCL22,
     226  NAL_UNIT_RESERVED_IRAP_VCL23,
     227
     228  NAL_UNIT_RESERVED_VCL24,
     229  NAL_UNIT_RESERVED_VCL25,
     230  NAL_UNIT_RESERVED_VCL26,
     231  NAL_UNIT_RESERVED_VCL27,
     232  NAL_UNIT_RESERVED_VCL28,
     233  NAL_UNIT_RESERVED_VCL29,
     234  NAL_UNIT_RESERVED_VCL30,
     235  NAL_UNIT_RESERVED_VCL31,
    234236
    235237  NAL_UNIT_VPS,                   // 32
     
    240242  NAL_UNIT_EOB,                   // 37
    241243  NAL_UNIT_FILLER_DATA,           // 38
    242   NAL_UNIT_SEI,                   // 39 Prefix SEI
    243   NAL_UNIT_SEI_SUFFIX,            // 40 Suffix SEI
    244   NAL_UNIT_RESERVED_41,
    245   NAL_UNIT_RESERVED_42,
    246   NAL_UNIT_RESERVED_43,
    247   NAL_UNIT_RESERVED_44,
    248   NAL_UNIT_RESERVED_45,
    249   NAL_UNIT_RESERVED_46,
    250   NAL_UNIT_RESERVED_47,
     244  NAL_UNIT_PREFIX_SEI,              // 39
     245  NAL_UNIT_SUFFIX_SEI,              // 40
     246  NAL_UNIT_RESERVED_NVCL41,
     247  NAL_UNIT_RESERVED_NVCL42,
     248  NAL_UNIT_RESERVED_NVCL43,
     249  NAL_UNIT_RESERVED_NVCL44,
     250  NAL_UNIT_RESERVED_NVCL45,
     251  NAL_UNIT_RESERVED_NVCL46,
     252  NAL_UNIT_RESERVED_NVCL47,
    251253  NAL_UNIT_UNSPECIFIED_48,
    252254  NAL_UNIT_UNSPECIFIED_49,
  • trunk/source/Lib/TLibCommon/NAL.h

    r125 r189  
    7676    return m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_R
    7777        || m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_N
    78         || m_nalUnitType == NAL_UNIT_CODED_SLICE_TLA
     78        || m_nalUnitType == NAL_UNIT_CODED_SLICE_TLA_R
    7979        || m_nalUnitType == NAL_UNIT_CODED_SLICE_TSA_N
    8080        || m_nalUnitType == NAL_UNIT_CODED_SLICE_STSA_R
    8181        || m_nalUnitType == NAL_UNIT_CODED_SLICE_STSA_N
    82         || m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA
    83         || m_nalUnitType == NAL_UNIT_CODED_SLICE_BLANT
     82        || m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP
     83        || m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL
    8484        || m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP
    85         || m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR
     85        || m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL
    8686        || m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP
    8787        || m_nalUnitType == NAL_UNIT_CODED_SLICE_CRA
    8888        || m_nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N
    89         || m_nalUnitType == NAL_UNIT_CODED_SLICE_DLP
     89        || m_nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R
    9090        || m_nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N
    91         || m_nalUnitType == NAL_UNIT_CODED_SLICE_TFD;
     91        || m_nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R;
    9292  }
    9393#if L0045_NON_NESTED_SEI_RESTRICTIONS
    9494  Bool isSei()
    9595  {
    96     return m_nalUnitType == NAL_UNIT_SEI
    97         || m_nalUnitType == NAL_UNIT_SEI_SUFFIX;
     96    return m_nalUnitType == NAL_UNIT_PREFIX_SEI
     97        || m_nalUnitType == NAL_UNIT_SUFFIX_SEI;
    9898  }
    9999
  • trunk/source/Lib/TLibCommon/SEI.cpp

    r127 r189  
    3838#include "CommonDef.h"
    3939#include "SEI.h"
     40
     41#if J0149_TONE_MAPPING_SEI
     42//Table D-7 Meaning of camera iso sensitivity indicator and exposure index rating indicator
     43Int  Table_exp_indicator[32] = {0, 10, 12, 16, 20, 25, 32, 40, 50, 64, 80, 100, 125, 160, 200, 250, 320, 400, 500, 640, 800, 1000, 1250, 1600, 2000, 2500, 3200, 4000, 5000, 6400, 8000, -1};
     44#endif
    4045
    4146SEIMessages getSeisByType(SEIMessages &seiList, SEI::PayloadType seiType)
  • trunk/source/Lib/TLibCommon/SEI.h

    r125 r189  
    355355};
    356356
     357#if L0208_SOP_DESCRIPTION_SEI
     358class SEISOPDescription : public SEI
     359{
     360public:
     361  PayloadType payloadType() const { return SOP_DESCRIPTION; }
     362
     363  SEISOPDescription() {}
     364  virtual ~SEISOPDescription() {}
     365
     366  UInt m_sopSeqParameterSetId;
     367  UInt m_numPicsInSopMinus1;
     368
     369  UInt m_sopDescVclNaluType[MAX_NUM_PICS_IN_SOP];
     370  UInt m_sopDescTemporalId[MAX_NUM_PICS_IN_SOP];
     371  UInt m_sopDescStRpsIdx[MAX_NUM_PICS_IN_SOP];
     372  Int m_sopDescPocDelta[MAX_NUM_PICS_IN_SOP];
     373};
     374#endif
     375
     376#if J0149_TONE_MAPPING_SEI
     377class SEIToneMappingInfo : public SEI
     378{
     379public:
     380  PayloadType payloadType() const { return TONE_MAPPING_INFO; }
     381  SEIToneMappingInfo() {}
     382  virtual ~SEIToneMappingInfo() {}
     383
     384  Int    m_toneMapId;
     385  Bool   m_toneMapCancelFlag;
     386  Bool   m_toneMapPersistenceFlag;
     387  Int    m_codedDataBitDepth;
     388  Int    m_targetBitDepth;
     389  Int    m_modelId;
     390  Int    m_minValue;
     391  Int    m_maxValue;
     392  Int    m_sigmoidMidpoint;
     393  Int    m_sigmoidWidth;
     394  std::vector<Int> m_startOfCodedInterval;
     395  Int    m_numPivots;
     396  std::vector<Int> m_codedPivotValue;
     397  std::vector<Int> m_targetPivotValue;
     398  Int    m_cameraIsoSpeedIdc;
     399  Int    m_cameraIsoSpeedValue;
     400  Int    m_exposureCompensationValueSignFlag;
     401  Int    m_exposureCompensationValueNumerator;
     402  Int    m_exposureCompensationValueDenomIdc;
     403  Int    m_refScreenLuminanceWhite;
     404  Int    m_extendedRangeWhiteLevel;
     405  Int    m_nominalBlackLevelLumaCodeValue;
     406  Int    m_nominalWhiteLevelLumaCodeValue;
     407  Int    m_extendedWhiteLevelLumaCodeValue;
     408};
     409#endif
     410
    357411typedef std::list<SEI*> SEIMessages;
    358412
     
    366420Void deleteSEIs (SEIMessages &seiList);
    367421
     422#if K0180_SCALABLE_NESTING_SEI
     423class SEIScalableNesting : public SEI
     424{
     425public:
     426  PayloadType payloadType() const { return SCALABLE_NESTING; }
     427
     428  SEIScalableNesting() {}
     429  virtual ~SEIScalableNesting()
     430  {
     431    if (!m_callerOwnsSEIs)
     432    {
     433      deleteSEIs(m_nestedSEIs);
     434    }
     435  }
     436
     437  Bool  m_bitStreamSubsetFlag;
     438  Bool  m_nestingOpFlag;
     439  Bool  m_defaultOpFlag;                             //value valid if m_nestingOpFlag != 0
     440  UInt  m_nestingNumOpsMinus1;                       // -"-
     441  UInt  m_nestingMaxTemporalIdPlus1[MAX_TLAYER];     // -"-
     442  UInt  m_nestingOpIdx[MAX_NESTING_NUM_OPS];         // -"-
     443
     444  Bool  m_allLayersFlag;                             //value valid if m_nestingOpFlag == 0
     445  UInt  m_nestingNoOpMaxTemporalIdPlus1;             //value valid if m_nestingOpFlag == 0 and m_allLayersFlag == 0
     446  UInt  m_nestingNumLayersMinus1;                    //value valid if m_nestingOpFlag == 0 and m_allLayersFlag == 0
     447  UChar m_nestingLayerId[MAX_NESTING_NUM_LAYER];     //value valid if m_nestingOpFlag == 0 and m_allLayersFlag == 0. This can e.g. be a static array of 64 unsigned char values
     448
     449  Bool  m_callerOwnsSEIs;
     450  SEIMessages m_nestedSEIs;
     451};
     452#endif
     453
    368454//! \}
  • trunk/source/Lib/TLibCommon/TComBitStream.cpp

    r125 r189  
    177177  }
    178178}
     179
    179180Void TComOutputBitstream::writeByteAlignment()
    180181{
     
    182183  writeAlignZero();
    183184}
     185
     186Int TComOutputBitstream::countStartCodeEmulations()
     187{
     188  UInt cnt = 0;
     189  vector<uint8_t>& rbsp   = getFIFO();
     190  for (vector<uint8_t>::iterator it = rbsp.begin(); it != rbsp.end();)
     191  {
     192    vector<uint8_t>::iterator found = it;
     193    do
     194    {
     195      // find the next emulated 00 00 {00,01,02,03}
     196      // NB, end()-1, prevents finding a trailing two byte sequence
     197      found = search_n(found, rbsp.end()-1, 2, 0);
     198      found++;
     199      // if not found, found == end, otherwise found = second zero byte
     200      if (found == rbsp.end())
     201      {
     202        break;
     203      }
     204      if (*(++found) <= 3)
     205      {
     206        break;
     207      }
     208    } while (true);
     209    it = found;
     210    if (found != rbsp.end())
     211    {
     212      cnt++;
     213    }
     214  }
     215  return cnt;
     216}
     217
    184218/**
    185219 * read #uiNumberOfBits# from bitstream without updating the bitstream
  • trunk/source/Lib/TLibCommon/TComBitStream.h

    r125 r189  
    154154  Void          addSubstream    ( TComOutputBitstream* pcSubstream );
    155155  Void writeByteAlignment();
     156
     157  //! returns the number of start code emulations contained in the current buffer
     158  Int countStartCodeEmulations();
    156159};
    157160
     
    163166{
    164167  std::vector<uint8_t> *m_fifo; /// FIFO for storage of complete bytes
     168  std::vector<UInt> m_emulationPreventionByteLocation;
    165169
    166170protected:
     
    206210  UInt  getNumBitsRead() { return m_numBitsRead; }
    207211  Void readByteAlignment();
     212
     213  Void      pushEmulationPreventionByteLocation ( UInt pos )                  { m_emulationPreventionByteLocation.push_back( pos ); }
     214  UInt      numEmulationPreventionBytesRead     ()                            { return (UInt) m_emulationPreventionByteLocation.size();    }
     215  std::vector<UInt>  getEmulationPreventionByteLocation  ()                   { return m_emulationPreventionByteLocation;           }
     216  UInt      getEmulationPreventionByteLocation  ( UInt idx )                  { return m_emulationPreventionByteLocation[ idx ];    }
     217  Void      clearEmulationPreventionByteLocation()                            { m_emulationPreventionByteLocation.clear();          }
     218  Void      setEmulationPreventionByteLocation  ( std::vector<UInt> vec )     { m_emulationPreventionByteLocation = vec;            }
    208219};
    209220
  • trunk/source/Lib/TLibCommon/TComDataCU.cpp

    r125 r189  
    18021802UInt TComDataCU::getCtxIntraBLFlag( UInt uiAbsPartIdx )
    18031803{
     1804#if INTRA_BL_CTX_CHANGE
     1805  Int cuDepth = getDepth(uiAbsPartIdx);
     1806  Int maxCuDepth = g_uiMaxCUDepth - g_uiAddCUDepth;
     1807  UInt uiCtx = (maxCuDepth==3 && cuDepth > 0) ? (cuDepth - 1) : cuDepth;
     1808  return uiCtx;
     1809#else
    18041810  TComDataCU* pcTempCU;
    18051811  UInt        uiTempPartIdx;
     
    18241830 
    18251831  return uiCtx;
     1832#endif
    18261833}
    18271834#endif
     
    18351842  {
    18361843    Int refIdxL0 = cMvFieldL0.getRefIdx();
    1837     if(getSlice()->getRefPic(REF_PIC_LIST_0, refIdxL0)->isILR())
     1844    if(getSlice()->getRefPic(REF_PIC_LIST_0, refIdxL0)->isILR(m_layerId))
    18381845    {
    18391846      checkZeroMVILR &= (cMvFieldL0.getHor() == 0 && cMvFieldL0.getVer() == 0);
     
    18431850  {
    18441851    Int refIdxL1  = cMvFieldL1.getRefIdx();
    1845     if(getSlice()->getRefPic(REF_PIC_LIST_1, refIdxL1)->isILR())
     1852    if(getSlice()->getRefPic(REF_PIC_LIST_1, refIdxL1)->isILR(m_layerId))
    18461853    {
    18471854      checkZeroMVILR &= (cMvFieldL1.getHor() == 0 && cMvFieldL1.getVer() == 0);
     
    18591866  Bool checkZeroMVILR = true;
    18601867
    1861   if(getSlice()->getRefPic(eRefPicList, iRefIdx)->isILR())
     1868  if(getSlice()->getRefPic(eRefPicList, iRefIdx)->isILR(m_layerId))
    18621869  {
    18631870    AMVPInfo* pcAMVPInfo = getCUMvField(eRefPicList)->getAMVPInfo();
     
    25302537  if(m_layerId) 
    25312538  {
    2532 #if MV_SCALING_POS_FIX
    25332539    pcColCU = getBaseColCU( xP + nPSW/2, yP + nPSH/2, uiCUAddrBase, uiAbsPartAddrBase );
    2534 #else
    2535     UInt uiPartIdxCenter;
    2536     xDeriveCenterIdx( cCurPS, uiPUIdx, uiPartIdxCenter );
    2537     uiPartIdxCenter -= m_uiAbsIdxInLCU;
    2538     pcColCU = getBaseColCU( uiPartIdxCenter, uiCUAddrBase, uiAbsPartAddrBase );
    2539 #endif
    25402540   
    25412541#if INTRA_BL
     
    26712671#endif
    26722672  Bool isAvailableB0 = pcCUAboveRight &&
    2673 #if SVC_MVP
     2673#if SVC_MVP && !IL_MRG_SIMPLIFIED_PRUNING
    26742674  ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCUAboveRight->hasEqualMotion( uiAboveRightPartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0] )) &&
    26752675#endif
     
    27152715  Bool isAvailableA0 = pcCULeftBottom &&
    27162716  pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) &&
    2717 #if SVC_MVP
     2717#if SVC_MVP && !IL_MRG_SIMPLIFIED_PRUNING
    27182718  ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCULeftBottom->hasEqualMotion( uiLeftBottomPartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0])) &&
    27192719#endif
     
    27592759    Bool isAvailableB2 = pcCUAboveLeft &&
    27602760    pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) &&
    2761 #if SVC_MVP
     2761#if SVC_MVP && !IL_MRG_SIMPLIFIED_PRUNING
    27622762    ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCUAboveLeft->hasEqualMotion( uiAboveLeftPartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0] )) &&
    27632763#endif
     
    41754175  TComPic* cBaseColPic = m_pcSlice->getBaseColPic();
    41764176
    4177 #if SVC_UPSAMPLING
     4177#if !SIMPLIFIED_MV_POS_SCALING
     4178#if SVC_UPSAMPLING && !ILP_DECODED_PICTURE
    41784179  const Window &confBL = cBaseColPic->getPicYuvRec()->getConformanceWindow();
    41794180  const Window &confEL = m_pcPic->getPicYuvRec()->getConformanceWindow();
     
    41914192  Int heightEL  = m_pcPic->getPicYuvRec()->getHeight();
    41924193#endif
     4194#endif
    41934195
    41944196  uiPelX = (UInt)Clip3<UInt>(0, m_pcPic->getPicYuvRec()->getWidth() - 1, uiPelX);
     
    41974199  UInt uiMinUnitSize = m_pcPic->getMinCUWidth();
    41984200
     4201#if SIMPLIFIED_MV_POS_SCALING
     4202#if SCALED_REF_LAYER_OFFSETS
     4203  Int leftStartL = this->getSlice()->getSPS()->getScaledRefLayerWindow().getWindowLeftOffset();
     4204  Int topStartL  = this->getSlice()->getSPS()->getScaledRefLayerWindow().getWindowTopOffset();
     4205  Int iBX = ((uiPelX - leftStartL)*g_posScalingFactor[m_layerId][0] + (1<<15)) >> 16;
     4206  Int iBY = ((uiPelY - topStartL )*g_posScalingFactor[m_layerId][1] + (1<<15)) >> 16;
     4207#else
     4208  Int iBX = (uiPelX*g_posScalingFactor[m_layerId][0] + (1<<15)) >> 16;
     4209  Int iBY = (uiPelY*g_posScalingFactor[m_layerId][1] + (1<<15)) >> 16;
     4210#endif
     4211#else
    41994212  Int iBX = (uiPelX*widthBL + widthEL/2)/widthEL;
    42004213  Int iBY = (uiPelY*heightBL+ heightEL/2)/heightEL;
    4201 
     4214#endif
     4215
     4216#if SCALED_REF_LAYER_OFFSETS
     4217  if ( iBX >= cBaseColPic->getPicYuvRec()->getWidth() || iBY >= cBaseColPic->getPicYuvRec()->getHeight() ||
     4218       iBX < 0                                        || iBY < 0                                           )
     4219#else
    42024220  if ( iBX >= cBaseColPic->getPicYuvRec()->getWidth() || iBY >= cBaseColPic->getPicYuvRec()->getHeight())
     4221#endif
    42034222  {
    42044223    return NULL;
    42054224  }
    42064225
    4207 #if AVC_SYNTAX
     4226#if AVC_SYNTAX && !ILP_DECODED_PICTURE
     4227#if !ILP_DECODED_PICTURE
     4228  const Window &confBL = cBaseColPic->getPicYuvRec()->getConformanceWindow();
     4229  const Window &confEL = m_pcPic->getPicYuvRec()->getConformanceWindow();
     4230
     4231  Int widthBL   = m_pcSlice->getBaseColPic()->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset();
     4232  Int heightBL  = m_pcSlice->getBaseColPic()->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset();
     4233#endif
    42084234  if( iBX >= widthBL || iBY >= heightBL ) //outside of the reference layer cropped picture
    42094235  {
     
    42284254  TComMvField cMvFieldBase;
    42294255  TComMv cMv;
    4230 
    4231 #if MV_SCALING_FIX
     4256#if SIMPLIFIED_MV_POS_SCALING
     4257  cMv = rcMvFieldBase.getMv().scaleMv( g_mvScalingFactor[m_layerId][0], g_mvScalingFactor[m_layerId][1] );
     4258#else
    42324259  const Window &confBL = m_pcSlice->getBaseColPic()->getPicYuvRec()->getConformanceWindow();
    42334260  const Window &confEL = m_pcPic->getPicYuvRec()->getConformanceWindow();
     
    42384265  Int widthEL   = m_pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset();
    42394266  Int heightEL  = m_pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
    4240 #else
    4241   Int widthBL   = m_pcSlice->getBaseColPic()->getPicYuvRec()->getWidth();
    4242   Int heightBL  = m_pcSlice->getBaseColPic()->getPicYuvRec()->getHeight();
    4243 
    4244   Int widthEL   = m_pcPic->getPicYuvRec()->getWidth();
    4245   Int heightEL  = m_pcPic->getPicYuvRec()->getHeight();
    4246 #endif
    42474267
    42484268  Int iMvX = (rcMvFieldBase.getHor()*widthEL + (widthBL/2 -1) * (rcMvFieldBase.getHor() > 0 ? 1: -1) )/widthBL;
     
    42504270
    42514271  cMv.set(iMvX, iMvY);
     4272#endif
    42524273
    42534274  rcMvFieldEnhance.setMvField( cMv, rcMvFieldBase.getRefIdx() );
  • trunk/source/Lib/TLibCommon/TComLoopFilter.cpp

    r125 r189  
    5757// ====================================================================================================================
    5858
    59 const UChar tctable_8x8[54] =
     59const UChar TComLoopFilter::sm_tcTable[54] =
    6060{
    6161  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,5,5,6,6,7,8,9,10,11,13,14,16,18,20,22,24
    6262};
    6363
    64 const UChar betatable_8x8[52] =
     64const UChar TComLoopFilter::sm_betaTable[52] =
    6565{
    6666  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,7,8,9,10,11,12,13,14,15,16,17,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64
     
    585585      Int iIndexB = Clip3(0, MAX_QP, iQP + (betaOffsetDiv2 << 1));
    586586     
    587       Int iTc =  tctable_8x8[iIndexTC]*iBitdepthScale;
    588       Int iBeta = betatable_8x8[iIndexB]*iBitdepthScale;
     587      Int iTc =  sm_tcTable[iIndexTC]*iBitdepthScale;
     588      Int iBeta = sm_betaTable[iIndexB]*iBitdepthScale;
    589589      Int iSideThreshold = (iBeta+(iBeta>>1))>>3;
    590590      Int iThrCut = iTc*10;
     
    735735
    736736        Int iIndexTC = Clip3(0, MAX_QP+DEFAULT_INTRA_TC_OFFSET, iQP + DEFAULT_INTRA_TC_OFFSET*(ucBs - 1) + (tcOffsetDiv2 << 1));
    737         Int iTc =  tctable_8x8[iIndexTC]*iBitdepthScale;
     737        Int iTc =  sm_tcTable[iIndexTC]*iBitdepthScale;
    738738
    739739        for ( UInt uiStep = 0; uiStep < uiPelsInPartChroma; uiStep++ )
  • trunk/source/Lib/TLibCommon/TComLoopFilter.h

    r125 r189  
    9999  __inline Int xCalcDQ( Pel* piSrc, Int iOffset);
    100100 
     101  static const UChar sm_tcTable[54];
     102  static const UChar sm_betaTable[52];
     103
    101104public:
    102105  TComLoopFilter();
     
    111114  /// picture-level deblocking filter
    112115  Void loopFilterPic( TComPic* pcPic );
     116
     117  static Int getBeta( Int qp )
     118  {
     119    Int indexB = Clip3( 0, MAX_QP, qp );
     120    return sm_betaTable[ indexB ];
     121  }
    113122};
    114123
  • trunk/source/Lib/TLibCommon/TComMv.h

    r125 r189  
    149149    return TComMv( mvx, mvy );
    150150  }
     151#if SIMPLIFIED_MV_POS_SCALING
     152  const TComMv scaleMv( Int iScaleX, Int iScaleY ) const
     153  {
     154    Int mvx = Clip3( -32768, 32767, (iScaleX * getHor() + 127 + (iScaleX * getHor() < 0)) >> 8 );
     155    Int mvy = Clip3( -32768, 32767, (iScaleY * getVer() + 127 + (iScaleY * getVer() < 0)) >> 8 );
     156    return TComMv( mvx, mvy );
     157  }
     158#endif
    151159};// END CLASS DEFINITION TComMV
    152160
  • trunk/source/Lib/TLibCommon/TComPic.cpp

    r125 r189  
    116116  return;
    117117}
    118 #if REF_IDX_FRAMEWORK
    119 Void TComPic::createWithOutYuv( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, TComSPS* pcSps,  Bool bIsVirtual)
    120 {
    121   m_apcPicSym     = new TComPicSym;  m_apcPicSym   ->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth );
    122   if (!bIsVirtual)
    123   {
    124     m_apcPicYuv[0]  = new TComPicYuv;  m_apcPicYuv[0]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, pcSps );
    125   }
    126   m_apcPicYuv[1]  = NULL;
    127  
    128 #if SVC_UPSAMPLING
    129   if (m_bSpatialEnhLayer)
    130   {
    131     m_pcFullPelBaseRec = new TComPicYuv;  m_pcFullPelBaseRec->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, pcSps );
    132   }
    133 #endif
    134 
    135   /* there are no SEI messages associated with this picture initially */
    136   m_SEIs.clear();
    137   m_bUsedByCurr = false;
    138   return;
    139 }
    140 #endif
    141118#else
    142119Void TComPic::create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, Window &conformanceWindow, Window &defaultDisplayWindow,
     
    559536}
    560537
    561 Void TComPic:: copyUpsampledPictureYuv(TComPicYuv*   pcPicYuvIn, TComPicYuv*   pcPicYuvOut)
     538Void TComPic::copyUpsampledPictureYuv(TComPicYuv*   pcPicYuvIn, TComPicYuv*   pcPicYuvOut)
    562539{
    563540  Int upsampledRowWidthLuma = pcPicYuvOut->getStride(); // 2 * pcPicYuvOut->getLumaMargin() + pcPicYuvOut->getWidth();
     
    585562
    586563#if REF_IDX_MFM
    587 #if !REUSE_BLKMAPPING
    588 Void TComPic::deriveUnitIdxBase( UInt upsamplePelX, UInt upsamplePelY, UInt ratio, UInt& baseCUAddr, UInt& baseAbsPartIdx )
    589 {
    590   //pixel in the base layer
    591 
    592   UInt pelX       = (upsamplePelX<<1)/ratio;
    593   UInt pelY       = (upsamplePelY<<1)/ratio;
    594   UInt baseWidth  = getPicYuvRec()->getWidth();
    595   UInt baseHeight = getPicYuvRec()->getHeight();
    596  
    597   UInt widthInCU       = ( baseWidth % g_uiMaxCUWidth  ) ? baseWidth /g_uiMaxCUWidth  + 1 : baseWidth /g_uiMaxCUWidth;
    598 
    599 #if MFM_CLIPPING_FIX
    600   pelX     = (UInt)Clip3<UInt>(0, getPicYuvRec()->getWidth() - 1, pelX);
    601   pelY     = (UInt)Clip3<UInt>(0, getPicYuvRec()->getHeight() - 1, pelY);
    602 #else
    603   UInt heightInCU      = ( baseHeight% g_uiMaxCUHeight ) ? baseHeight/ g_uiMaxCUHeight + 1 : baseHeight/ g_uiMaxCUHeight;
    604 
    605   pelX     = (UInt)Clip3<UInt>(0, widthInCU * g_uiMaxCUWidth - 1, pelX);
    606   pelY     = (UInt)Clip3<UInt>(0, heightInCU * g_uiMaxCUHeight - 1, pelY);
    607 #endif
    608  
    609   baseCUAddr = pelY / g_uiMaxCUHeight * widthInCU + pelX / g_uiMaxCUWidth;
    610 
    611   UInt widthMinPU = g_uiMaxCUWidth / (1<<g_uiMaxCUDepth);
    612   UInt heightMinPU = g_uiMaxCUHeight/(1<<g_uiMaxCUDepth);
    613  
    614   UInt absPelX = pelX - (pelX / g_uiMaxCUWidth) * g_uiMaxCUWidth;
    615   UInt absPelY = pelY - (pelY / g_uiMaxCUHeight) * g_uiMaxCUHeight;
    616 
    617   UInt rasterIdx = absPelY / heightMinPU * (g_uiMaxCUWidth/widthMinPU) + absPelX / widthMinPU;
    618   baseAbsPartIdx = g_auiRasterToZscan[rasterIdx];
    619 
    620   return;
    621 }
    622 #endif
    623 
    624564Void TComPic::copyUpsampledMvField(TComPic* pcPicBase)
    625565{
    626 #if !REUSE_MVSCALE || !REUSE_BLKMAPPING || AVC_SYNTAX
     566#if AVC_SYNTAX && !ILP_DECODED_PICTURE
    627567  const Window &confBL = pcPicBase->getConformanceWindow();
    628568  const Window &confEL = getPicYuvRec()->getConformanceWindow();
     
    633573  Int widthEL   = getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset();
    634574  Int heightEL  = getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
    635 #endif
    636  
    637 #if !REUSE_MVSCALE  || !REUSE_BLKMAPPING
    638   UInt upSampleRatio = 0;
    639   if(widthEL == widthBL && heightEL == heightBL)
    640   {
    641     upSampleRatio = 2;
    642   }
    643   else if(2*widthEL == 3*widthBL && 2*heightEL == 3*heightBL)
    644   {
    645     upSampleRatio = 3;
    646   }
    647   else if(widthEL == 2*widthBL && heightEL == 2*heightBL)
    648   {
    649     upSampleRatio = 4;
    650   }
    651   else
    652   {
    653     assert(0);
    654   }
    655575#endif
    656576
     
    671591      UInt baseCUAddr, baseAbsPartIdx;
    672592
    673 #if REUSE_BLKMAPPING
    674593      TComDataCU *pcColCU = 0;
    675594      pcColCU = pcCUDes->getBaseColCU(pelX + 8, pelY + 8, baseCUAddr, baseAbsPartIdx);
    676 #else
    677       pcPicBase->deriveUnitIdxBase(pelX + 8, pelY + 8, upSampleRatio, baseCUAddr, baseAbsPartIdx);
    678 #endif
    679 
    680 #if AVC_SYNTAX
     595
     596#if AVC_SYNTAX && !ILP_DECODED_PICTURE
    681597      Int xBL = ( (pelX + 8) * widthBL + widthEL/2 ) / widthEL;
    682598      Int yBL = ( (pelY + 8) * heightBL+ heightEL/2 ) / heightEL;
    683599
    684 #if REUSE_BLKMAPPING
    685600      if( ( xBL < widthBL && yBL < heightBL ) && pcColCU && (pcColCU->getPredictionMode(baseAbsPartIdx) != MODE_NONE) && (pcColCU->getPredictionMode(baseAbsPartIdx) != MODE_INTRA) )  //base layer unit not skip and invalid mode
    686601#else
    687       if( ( xBL < widthBL && yBL < heightBL ) && (pcPicBase->getCU(baseCUAddr)->getPredictionMode(baseAbsPartIdx) != MODE_NONE) && (pcPicBase->getCU(baseCUAddr)->getPredictionMode(baseAbsPartIdx) != MODE_INTRA) )  //base layer unit not skip and invalid mode
    688 #endif
    689 #else
    690 #if REUSE_BLKMAPPING
    691602      if( pcColCU && (pcColCU->getPredictionMode(baseAbsPartIdx) != MODE_NONE) && (pcColCU->getPredictionMode(baseAbsPartIdx) != MODE_INTRA) )  //base layer unit not skip and invalid mode
    692 #else
    693       if( (pcPicBase->getCU(baseCUAddr)->getPredictionMode(baseAbsPartIdx) != MODE_NONE) && (pcPicBase->getCU(baseCUAddr)->getPredictionMode(baseAbsPartIdx) != MODE_INTRA) )  //base layer unit not skip and invalid mode
    694 #endif
    695603#endif
    696604      {
    697605        for(UInt refPicList = 0; refPicList < 2; refPicList++)  //for each reference list
    698606        {
    699 #if REUSE_MVSCALE
    700607          TComMvField sMvFieldBase, sMvField;
    701 #if REUSE_BLKMAPPING
    702608          pcColCU->getMvField( pcColCU, baseAbsPartIdx, (RefPicList)refPicList, sMvFieldBase);
    703 #else
    704           pcPicBase->getCU(baseCUAddr)->getMvField( pcPicBase->getCU(baseCUAddr), baseAbsPartIdx, (RefPicList)refPicList, sMvFieldBase);
    705 #endif
    706609          pcCUDes->scaleBaseMV( sMvField, sMvFieldBase );
    707 #else
    708           TComMv cMv = pcPicBase->getCU(baseCUAddr)->getCUMvField((RefPicList)refPicList)->getMv(baseAbsPartIdx);
    709           Int refIdx = pcPicBase->getCU(baseCUAddr)->getCUMvField((RefPicList)refPicList)->getRefIdx(baseAbsPartIdx);
    710 
    711           Int hor =  ((Int)upSampleRatio * cMv.getHor())/2 ;
    712           Int ver =  ((Int)upSampleRatio * cMv.getVer())/2 ;
    713 
    714           TComMv cScaledMv(hor, ver);
    715           TComMvField sMvField;
    716           sMvField.setMvField(cScaledMv, refIdx);
    717 #endif
    718610
    719611          pcCUDes->getCUMvField((RefPicList)refPicList)->setMvField(sMvField, absPartIdx);
     
    739631  }
    740632}
    741 #endif
    742 
    743 #if RAP_MFM_INIT
     633
    744634Void TComPic::initUpsampledMvField()
    745635{
     
    774664  }
    775665
     666#if ILP_DECODED_PICTURE
     667  UInt   width      = this->getPicYuvRec()->getWidth();
     668  UInt   height     = this->getPicYuvRec()->getHeight();
     669#else
    776670  const Window &conf = this->getPicYuvRec()->getConformanceWindow();
    777671  UInt   width      = this->getPicYuvRec()->getWidth() - conf.getWindowLeftOffset() - conf.getWindowRightOffset();
    778672  UInt   height     = this->getPicYuvRec()->getHeight() - conf.getWindowTopOffset() - conf.getWindowBottomOffset();
     673#endif
    779674  UInt64 poc        = (UInt64)this->getPOC();
    780675  UInt   partWidth  = width / 4;
     
    853748  }
    854749
     750#if ILP_DECODED_PICTURE
     751  UInt   width       = this->getPicYuvRec()->getWidth();
     752  UInt   height      = this->getPicYuvRec()->getHeight();
     753#else
    855754  const Window &conf = this->getConformanceWindow();
    856755  UInt   width       = this->getPicYuvRec()->getWidth() - conf.getWindowLeftOffset() - conf.getWindowRightOffset();
    857756  UInt   height      = this->getPicYuvRec()->getHeight() - conf.getWindowTopOffset() - conf.getWindowBottomOffset();
     757#endif
    858758
    859759  UInt64 poc        = (UInt64)this->getPOC();
  • trunk/source/Lib/TLibCommon/TComPic.h

    r125 r189  
    103103  Void          create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, Window &conformanceWindow, Window &defaultDisplayWindow,
    104104                        Int *numReorderPics, TComSPS* pcSps = NULL, Bool bIsVirtual = false );
    105 #if REF_IDX_FRAMEWORK
    106   Void          createWithOutYuv( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, TComSPS* pcSps = NULL, Bool bIsVirtual = false ); 
    107   Void          setPicYuvRec(TComPicYuv *pPicYuv) { m_apcPicYuv[1]=pPicYuv; }
    108 #endif
    109105#else
    110106  Void          create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, Window &conformanceWindow, Window &defaultDisplayWindow,
     
    124120#endif
    125121#if REF_IDX_ME_ZEROMV || ENCODER_FAST_MODE || REF_IDX_MFM
    126   Bool          isILR( UInt refLayer = 0 )   {return (getIsLongTerm() && m_layerId == refLayer);}
     122  Bool          isILR( UInt currLayerId )   { return ( getIsLongTerm() && m_layerId < currLayerId ); }
    127123#endif
    128124
    129125#if REF_IDX_MFM
    130126  Void          copyUpsampledMvField  (  TComPic* pcPicBase );
    131 #if !REUSE_BLKMAPPING
    132   Void          deriveUnitIdxBase     (  UInt upsamplePelX, UInt upsamplePelY, UInt ratio, UInt& baseCUAddr, UInt& baseAbsPartIdx );
    133 #endif
    134 #if RAP_MFM_INIT
    135127  Void          initUpsampledMvField  ();
    136 #endif
    137128#endif
    138129
  • trunk/source/Lib/TLibCommon/TComPicYuv.cpp

    r125 r189  
    6060  m_piPicOrgU       = NULL;
    6161  m_piPicOrgV       = NULL;
     62 
    6263  m_bIsBorderExtended = false;
    6364}
  • trunk/source/Lib/TLibCommon/TComPrediction.cpp

    r125 r189  
    8383  if( m_piYuvExt == NULL )
    8484  {
    85     Int extWidth  = g_uiMaxCUWidth + 16;
    86     Int extHeight = g_uiMaxCUHeight + 1;
     85    Int extWidth  = MAX_CU_SIZE + 16;
     86    Int extHeight = MAX_CU_SIZE + 1;
    8787    Int i, j;
    8888    for (i = 0; i < 4; i++)
     
    9494      }
    9595    }
    96     m_iYuvExtHeight  = ((g_uiMaxCUHeight + 2) << 4);
    97     m_iYuvExtStride = ((g_uiMaxCUWidth  + 8) << 4);
     96    m_iYuvExtHeight  = ((MAX_CU_SIZE + 2) << 4);
     97    m_iYuvExtStride = ((MAX_CU_SIZE  + 8) << 4);
    9898    m_piYuvExt = new Int[ m_iYuvExtStride * m_iYuvExtHeight ];
    9999
    100100    // new structure
    101     m_acYuvPred[0] .create( g_uiMaxCUWidth, g_uiMaxCUHeight );
    102     m_acYuvPred[1] .create( g_uiMaxCUWidth, g_uiMaxCUHeight );
    103 
    104     m_cYuvPredTemp.create( g_uiMaxCUWidth, g_uiMaxCUHeight );
    105   }
    106 
    107   if (m_iLumaRecStride != (g_uiMaxCUWidth>>1) + 1)
    108   {
    109     m_iLumaRecStride =  (g_uiMaxCUWidth>>1) + 1;
     101    m_acYuvPred[0] .create( MAX_CU_SIZE, MAX_CU_SIZE );
     102    m_acYuvPred[1] .create( MAX_CU_SIZE, MAX_CU_SIZE );
     103
     104    m_cYuvPredTemp.create( MAX_CU_SIZE, MAX_CU_SIZE );
     105  }
     106
     107  if (m_iLumaRecStride != (MAX_CU_SIZE>>1) + 1)
     108  {
     109    m_iLumaRecStride =  (MAX_CU_SIZE>>1) + 1;
    110110    if (!m_pLumaRecBuffer)
    111111    {
     
    495495
    496496#if REF_IDX_ME_ZEROMV
    497   assert( ( pcCU->getSlice()->getRefPic(eRefPicList, iRefIdx)->isILR() && cMv.getHor() == 0 && cMv.getVer() == 0 ) || pcCU->getSlice()->getRefPic(eRefPicList, iRefIdx)->isILR() == false );
     497  assert( ( pcCU->getSlice()->getRefPic(eRefPicList, iRefIdx)->isILR(pcCU->getLayerId()) && cMv.getHor() == 0 && cMv.getVer() == 0 ) || pcCU->getSlice()->getRefPic(eRefPicList, iRefIdx)->isILR(pcCU->getLayerId()) == false );
    498498#endif
    499499
     
    773773
    774774#if SVC_UPSAMPLING
     775#if SCALED_REF_LAYER_OFFSETS
     776Void TComPrediction::upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window)
     777{
     778  m_cUsf.upsampleBasePic( pcUsPic, pcBasePic, pcTempPic, window);
     779}
     780#else
    775781Void TComPrediction::upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic)
    776782{
    777783  m_cUsf.upsampleBasePic( pcUsPic, pcBasePic, pcTempPic);
    778784}
     785#endif
    779786#endif
    780787//! \}
  • trunk/source/Lib/TLibCommon/TComPrediction.h

    r125 r189  
    122122
    123123#if SVC_UPSAMPLING
     124#if SCALED_REF_LAYER_OFFSETS
     125  Void upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window );
     126#else
    124127  Void upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic );
     128#endif
    125129#endif
    126130};
  • trunk/source/Lib/TLibCommon/TComRom.cpp

    r125 r189  
    6262  g_aucConvertToBit[ i ] = c;
    6363 
    64   // g_auiFrameScanXY[ g_aucConvertToBit[ transformSize ] ]: zigzag scan array for transformSize
    6564  c=2;
    6665  for ( i=0; i<MAX_CU_DEPTH; i++ )
     
    7776Void destroyROM()
    7877{
    79   Int i;
    80  
    81   for ( i=0; i<MAX_CU_DEPTH; i++ )
     78  for (Int i=0; i<MAX_CU_DEPTH; i++ )
    8279  {
    8380    delete[] g_auiSigLastScan[0][i];
     
    521518Int  g_eTTable[4] = {0,3,1,2};
    522519
     520#if SIMPLIFIED_MV_POS_SCALING
     521Int g_mvScalingFactor  [MAX_LAYERS][2] = {{0,0}, {0,0}};
     522Int g_posScalingFactor [MAX_LAYERS][2] = {{0,0}, {0,0}};
     523#endif
     524
    523525//! \}
  • trunk/source/Lib/TLibCommon/TComRom.h

    r125 r189  
    273273extern UInt g_scalingListNum  [SCALING_LIST_SIZE_NUM];
    274274extern Int  g_eTTable[4];
     275
     276#if SIMPLIFIED_MV_POS_SCALING
     277extern Int g_mvScalingFactor  [MAX_LAYERS][2];
     278extern Int g_posScalingFactor [MAX_LAYERS][2];
     279#endif
     280
    275281//! \}
    276282
  • trunk/source/Lib/TLibCommon/TComSlice.cpp

    r125 r189  
    5454, m_iPOC                          ( 0 )
    5555, m_iLastIDR                      ( 0 )
    56 , m_eNalUnitType                  ( NAL_UNIT_CODED_SLICE_IDR )
     56, m_eNalUnitType                  ( NAL_UNIT_CODED_SLICE_IDR_W_RADL )
    5757, m_eSliceType                    ( I_SLICE )
    5858, m_iSliceQp                      ( 0 )
     
    6565, m_deblockingFilterBetaOffsetDiv2 ( 0 )
    6666, m_deblockingFilterTcOffsetDiv2   ( 0 )
     67#if !L0034_COMBINED_LIST_CLEANUP
    6768, m_bRefPicListModificationFlagLC ( false )
    6869, m_bRefPicListCombinationFlag    ( false )
     70#endif
    6971, m_bCheckLDC                     ( false )
    7072, m_iSliceQpDelta                 ( 0 )
     
    8486, m_dLambda                       ( 0.0 )
    8587#endif
    86 , m_bNoBackPredFlag               ( false )
     88#if !L0034_COMBINED_LIST_CLEANUP
     89, m_bNoBackPredFlag             ( false )
     90#endif
    8791, m_uiTLayer                      ( 0 )
    8892#if SVC_EXTENSION
     
    113117, m_enableTMVPFlag                ( true )
    114118{
     119#if L0034_COMBINED_LIST_CLEANUP
     120  m_aiNumRefIdx[0] = m_aiNumRefIdx[1] = 0;
     121#else
    115122  m_aiNumRefIdx[0] = m_aiNumRefIdx[1] = m_aiNumRefIdx[2] = 0;
     123#endif
    116124 
    117 #if REF_LIST_BUGFIX
    118   m_aiNumILRRefIdx = 0;
    119 #endif
     125#if REF_IDX_FRAMEWORK
     126#if JCTVC_M0458_INTERLAYER_RPS_SIG
     127  m_activeNumILRRefIdx        = 0;
     128  m_interLayerPredEnabledFlag = 0;
     129  ::memset( m_interLayerPredLayerIdc, 0, sizeof(m_interLayerPredLayerIdc) );
     130#else
     131  m_numILRRefIdx = 0;
     132#endif
     133#endif
     134
    120135  initEqualRef();
    121136 
     137#if L0034_COMBINED_LIST_CLEANUP
     138  for ( Int idx = 0; idx < MAX_NUM_REF; idx++ )
     139  {
     140    m_list1IdxToList0Idx[idx] = -1;
     141  }
     142#else
    122143  for(Int iNumCount = 0; iNumCount < MAX_NUM_REF_LC; iNumCount++)
    123144  {
     
    129150    m_iRefIdxOfL1FromRefIdxOfL0[iNumCount] = -1;
    130151  }   
     152#endif
    131153  for(Int iNumCount = 0; iNumCount < MAX_NUM_REF; iNumCount++)
    132154  {
     
    136158    m_aiRefPOCList  [1][iNumCount] = 0;
    137159  }
    138   resetWpScaling(m_weightPredTable);
     160  resetWpScaling();
    139161  initWpAcDcParam();
    140162  m_saoEnabledFlag = false;
     
    159181  m_aiNumRefIdx[0]      = 0;
    160182  m_aiNumRefIdx[1]      = 0;
    161 #if REF_LIST_BUGFIX
    162   if(layerId)
    163   {
    164     m_aiNumILRRefIdx      = 1;  // to be set to NumDirectRefLayers[LayerIdInVps[nuh_layer_id]]
    165   }
    166   else
    167   {
    168     m_aiNumILRRefIdx = 0;
    169   }
     183#if REF_IDX_FRAMEWORK
     184#if JCTVC_M0458_INTERLAYER_RPS_SIG
     185  m_activeNumILRRefIdx        = 0;
     186  m_interLayerPredEnabledFlag = 0;
     187#else
     188  m_numILRRefIdx              = 0;
     189#endif 
     190
    170191#endif
    171192  m_colFromL0Flag = 1;
     
    173194  m_colRefIdx = 0;
    174195  initEqualRef();
     196#if !L0034_COMBINED_LIST_CLEANUP
    175197  m_bNoBackPredFlag = false;
    176198  m_bRefPicListCombinationFlag = false;
    177199  m_bRefPicListModificationFlagLC = false;
     200#endif
    178201  m_bCheckLDC = false;
    179202  m_iSliceQpDeltaCb = 0;
    180203  m_iSliceQpDeltaCr = 0;
    181204
     205#if !L0034_COMBINED_LIST_CLEANUP
    182206  m_aiNumRefIdx[REF_PIC_LIST_C]      = 0;
     207#endif
    183208
    184209  m_maxNumMergeCand = MRG_MAX_NUM_CANDS;
     
    194219Bool TComSlice::getRapPicFlag()
    195220{
    196   return getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR
     221  return getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL
    197222      || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP
    198223      || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP
    199       || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT
    200       || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA
     224      || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
     225      || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
    201226      || getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA;
    202227}
     
    213238}
    214239
    215 Void  TComSlice::sortPicList        (TComList<TComPic*>& rcListPic)
     240Void  TComSlice::sortPicList(TComList<TComPic*>& rcListPic)
    216241{
    217242  TComPic*    pcPicExtract;
     
    268293
    269294
    270 TComPic* TComSlice::xGetLongTermRefPic (TComList<TComPic*>& rcListPic,
    271                                         Int                 poc)
     295TComPic* TComSlice::xGetLongTermRefPic(TComList<TComPic*>& rcListPic, Int poc, Bool pocHasMsb)
    272296{
    273297  TComList<TComPic*>::iterator  iterPic = rcListPic.begin(); 
    274298  TComPic*                      pcPic = *(iterPic);
    275299  TComPic*                      pcStPic = pcPic;
     300 
     301  Int pocCycle = 1 << getSPS()->getBitsForPOC();
     302  if (!pocHasMsb)
     303  {
     304    poc = poc % pocCycle;
     305  }
     306 
    276307  while ( iterPic != rcListPic.end() )
    277308  {
    278309    pcPic = *(iterPic);
    279     if(pcPic && (pcPic->getPOC()%(1<<getSPS()->getBitsForPOC())) == (poc%(1<<getSPS()->getBitsForPOC())))
    280     {
    281       if(pcPic->getIsLongTerm())
     310    if (pcPic && pcPic->getPOC()!=this->getPOC() && pcPic->getSlice( 0 )->isReferenced())
     311    {
     312      Int picPoc = pcPic->getPOC();
     313      if (!pocHasMsb)
     314      {
     315        picPoc = picPoc % pocCycle;
     316      }
     317     
     318      if (poc == picPoc)
     319      {
     320       if (pcPic->getIsLongTerm())
    282321      {
    283322        return pcPic;
     
    289328      break;
    290329    }
     330    }
    291331
    292332    iterPic++;
    293333  }
     334 
    294335  return  pcStPic;
    295336}
    296337
    297 Void TComSlice::setRefPOCList       ()
     338Void TComSlice::setRefPOCList()
    298339{
    299340  for (Int iDir = 0; iDir < 2; iDir++)
     
    307348}
    308349
     350#if L0034_COMBINED_LIST_CLEANUP
     351Void TComSlice::setList1IdxToList0Idx()
     352{
     353  Int idxL0, idxL1;
     354  for ( idxL1 = 0; idxL1 < getNumRefIdx( REF_PIC_LIST_1 ); idxL1++ )
     355  {
     356    m_list1IdxToList0Idx[idxL1] = -1;
     357    for ( idxL0 = 0; idxL0 < getNumRefIdx( REF_PIC_LIST_0 ); idxL0++ )
     358    {
     359      if ( m_apcRefPicList[REF_PIC_LIST_0][idxL0]->getPOC() == m_apcRefPicList[REF_PIC_LIST_1][idxL1]->getPOC() )
     360      {
     361        m_list1IdxToList0Idx[idxL1] = idxL0;
     362        break;
     363      }
     364    }
     365  }
     366}
     367#else
    309368Void TComSlice::generateCombinedList()
    310369{
     
    369428  }
    370429}
    371 
    372 Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic)
    373 {
    374 #if REF_IDX_FRAMEWORK
    375   if( m_eSliceType == I_SLICE || ( getSPS()->getLayerId() &&
    376       (getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA) &&
    377       (getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) ) )
    378 #else
    379   if (m_eSliceType == I_SLICE)
    380 #endif
    381   {
    382     ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList));
    383     ::memset( m_aiNumRefIdx,   0, sizeof ( m_aiNumRefIdx ));
    384    
    385     return;
    386   }
     430#endif
     431
     432#if FIX1071
     433Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr, TComPic** ilpPic)
     434#else
     435Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic )
     436#endif
     437{
     438#if FIX1071
     439  if (!checkNumPocTotalCurr)
     440#endif
     441  {
     442    if( m_eSliceType == I_SLICE )
     443    {
     444      ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList));
     445      ::memset( m_aiNumRefIdx,   0, sizeof ( m_aiNumRefIdx ));
     446      return;
     447    }
    387448 
    388   m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0);
    389   m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1);
     449    m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0);
     450    m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1);
     451  }
    390452
    391453  TComPic*  pcRefPic= NULL;
     
    398460  Int i;
    399461
     462#if REF_IDX_FRAMEWORK
     463#if ZERO_NUM_DIRECT_LAYERS
     464  if( m_layerId == 0 || ( m_layerId > 0 && ( m_activeNumILRRefIdx == 0 || !((getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP) && (getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA)) ) ) )
     465#else
     466  if ((getLayerId() == 0) ||
     467      ((getSPS()->getLayerId()) &&  !((getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP) &&
     468       (getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA)) )
     469     )
     470#endif
     471  {
     472#endif
    400473  for(i=0; i < m_pcRPS->getNumberOfNegativePictures(); i++)
    401474  {
     
    410483    }
    411484  }
     485 
    412486  for(; i < m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures(); i++)
    413487  {
     
    422496    }
    423497  }
     498 
    424499  for(i = m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()+m_pcRPS->getNumberOfLongtermPictures()-1; i > m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()-1 ; i--)
    425500  {
    426501    if(m_pcRPS->getUsed(i))
    427502    {
    428       pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i));
     503      pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i));
    429504      pcRefPic->setIsLongTerm(1);
    430505      pcRefPic->getPicYuvRec()->extendPicBorder();
     
    434509    if(pcRefPic==NULL)
    435510    {
    436       pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i));
     511      pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i));
    437512    }
    438513    pcRefPic->setCheckLTMSBPresent(m_pcRPS->getCheckLTMSBPresent(i)); 
    439514  }
    440 
     515#if REF_IDX_FRAMEWORK
     516  }
     517#endif
     518
     519#if REF_IDX_FRAMEWORK
     520  //inter-layer reference picture
     521#if REF_IDX_MFM
     522#if ZERO_NUM_DIRECT_LAYERS
     523  if( m_layerId > 0 && m_activeNumILRRefIdx > 0 )
     524#else
     525  if (getLayerId())
     526#endif
     527  {
     528    if(!(getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) && getSPS()->getMFMEnabledFlag())
     529    {
     530      ilpPic[0]->copyUpsampledMvField(getBaseColPic());
     531    }
     532    else
     533    {
     534      ilpPic[0]->initUpsampledMvField();
     535    }
     536  #endif
     537    ilpPic[0]->setIsLongTerm(1);
     538  }
     539#endif
    441540  // ref_pic_list_init
    442541  TComPic*  rpsCurrList0[MAX_NUM_REF+1];
    443542  TComPic*  rpsCurrList1[MAX_NUM_REF+1];
     543#if REF_IDX_FRAMEWORK
     544#if JCTVC_M0458_INTERLAYER_RPS_SIG
     545  Int numPocTotalCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr + m_activeNumILRRefIdx;
     546#else
     547  Int numPocTotalCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr + m_numILRRefIdx;
     548#endif
     549#else
    444550  Int numPocTotalCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr;
    445 
    446   {
     551#endif
     552#if FIX1071
     553  if (checkNumPocTotalCurr)
     554  {
     555    // The variable NumPocTotalCurr is derived as specified in subclause 7.4.7.2. It is a requirement of bitstream conformance that the following applies to the value of NumPocTotalCurr:
     556    // – If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0.
     557    // – Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0.
     558    if (getRapPicFlag())
     559    {
     560      assert(numPocTotalCurr == 0);
     561    }
     562
     563    if (m_eSliceType == I_SLICE)
     564  {
     565      ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList));
     566      ::memset( m_aiNumRefIdx,   0, sizeof ( m_aiNumRefIdx ));
     567     
     568      return;
     569    }
     570   
     571    assert(numPocTotalCurr != 0);
     572   
     573    m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0);
     574    m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1);
     575  }
     576#endif
     577 
    447578    Int cIdx = 0;
    448579    for ( i=0; i<NumPocStCurr0; i++, cIdx++)
     
    458589      rpsCurrList0[cIdx] = RefPicSetLtCurr[i];
    459590    }
    460   }
    461 
     591#if REF_IDX_FRAMEWORK
     592    if(getLayerId())
     593    {
     594#if JCTVC_M0458_INTERLAYER_RPS_SIG
     595      for( i = 0; i < m_activeNumILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++)     
     596#else
     597      for( i = 0; i < m_numILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++)
     598#endif
     599      {
     600        rpsCurrList0[cIdx] = ilpPic[i];
     601      }
     602    }
     603#endif
    462604  if (m_eSliceType==B_SLICE)
    463605  {
    464     Int cIdx = 0;
     606    cIdx = 0;
    465607    for ( i=0; i<NumPocStCurr1; i++, cIdx++)
    466608    {
     
    475617      rpsCurrList1[cIdx] = RefPicSetLtCurr[i];
    476618    }
     619#if REF_IDX_FRAMEWORK
     620    if(getLayerId())
     621    {
     622#if JCTVC_M0458_INTERLAYER_RPS_SIG
     623      for( i = 0; i < m_activeNumILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++)
     624#else
     625      for( i = 0; i < m_numILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++)
     626#endif
     627      {
     628        rpsCurrList1[cIdx] = ilpPic[i];
     629      }
     630    }
     631#endif
    477632  }
    478633
     
    501656}
    502657
    503 #if REF_LIST_BUGFIX
     658#if REF_IDX_FRAMEWORK
    504659Void TComSlice::setRefPicListModificationSvc()
    505660{
     
    509664  }
    510665
    511   if(this->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA && this->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA)
     666  if(this->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && this->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA)
     667  {
    512668    return;
     669  }
    513670
    514671  TComRefPicListModification* refPicListModification = this->getRefPicListModification();
     
    537694    else
    538695    {
    539       for(Int i = m_aiNumILRRefIdx; i > 0; i-- )
     696#if JCTVC_M0458_INTERLAYER_RPS_SIG
     697      for(Int i = m_activeNumILRRefIdx; i > 0; i-- )
     698#else
     699      for(Int i = m_numILRRefIdx; i > 0; i-- )
     700#endif
    540701      {
    541702        refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfRpsCurrTempList - i);
     
    563724    else
    564725    {
    565       for(Int i = m_aiNumILRRefIdx; i > 0; i-- )
     726#if JCTVC_M0458_INTERLAYER_RPS_SIG
     727      for(Int i = m_activeNumILRRefIdx; i > 0; i-- )
     728#else
     729      for(Int i = m_numILRRefIdx; i > 0; i-- )
     730#endif
    566731      {
    567732        refPicListModification->setRefPicSetIdxL1(m_aiNumRefIdx[REF_PIC_LIST_1] - i, numberOfRpsCurrTempList - i);
     
    569734    }
    570735  }
    571   return;
    572 }
    573 
    574 Void TComSlice::setRefPicListSvc( TComList<TComPic*>& rcListPic, TComPic** ilpPic )
    575 {
    576   assert(getLayerId() > 0);
    577 
    578   m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0);
    579   m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1);
    580 
    581   TComPic*  pcRefPic= NULL;
    582   TComPic*  RefPicSetStCurr0[16];
    583   TComPic*  RefPicSetStCurr1[16];
    584   TComPic*  RefPicSetLtCurr[16];
    585   UInt NumPocStCurr0 = 0;
    586   UInt NumPocStCurr1 = 0;
    587   UInt NumPocLtCurr = 0;
    588   Int i;
    589 
    590   //temporal reference pictures
    591   if( !(getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA && getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) )
    592   {
    593     for(i=0; i < m_pcRPS->getNumberOfNegativePictures(); i++)
    594     {
    595       if(m_pcRPS->getUsed(i))
    596       {
    597         pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i));
    598         pcRefPic->setIsLongTerm(0);
    599         pcRefPic->getPicYuvRec()->extendPicBorder();
    600         RefPicSetStCurr0[NumPocStCurr0] = pcRefPic;
    601         NumPocStCurr0++;
    602         pcRefPic->setCheckLTMSBPresent(false); 
    603       }
    604     }
    605     for(; i < m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures(); i++)
    606     {
    607       if(m_pcRPS->getUsed(i))
    608       {
    609         pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i));
    610         pcRefPic->setIsLongTerm(0);
    611         pcRefPic->getPicYuvRec()->extendPicBorder();
    612         RefPicSetStCurr1[NumPocStCurr1] = pcRefPic;
    613         NumPocStCurr1++;
    614         pcRefPic->setCheckLTMSBPresent(false); 
    615       }
    616     }
    617     for(i = m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()+m_pcRPS->getNumberOfLongtermPictures()-1; i > m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()-1 ; i--)
    618     {
    619       if(m_pcRPS->getUsed(i))
    620       {
    621         pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i));
    622         pcRefPic->setIsLongTerm(1);
    623         pcRefPic->getPicYuvRec()->extendPicBorder();
    624         RefPicSetLtCurr[NumPocLtCurr] = pcRefPic;
    625         NumPocLtCurr++;
    626       }
    627       if(pcRefPic==NULL)
    628       {
    629         pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i));
    630       }
    631       pcRefPic->setCheckLTMSBPresent(m_pcRPS->getCheckLTMSBPresent(i)); 
    632     }
    633   }
    634 
    635   //inter-layer reference picture
    636 #if REF_IDX_MFM
    637   assert(m_aiNumILRRefIdx == 1);
    638   if(!(getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA && getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) && getSPS()->getMFMEnabledFlag())
    639   {
    640     ilpPic[0]->copyUpsampledMvField(getBaseColPic());
    641   }
    642   else
    643   {
    644     ilpPic[0]->initUpsampledMvField();
    645   }
    646 #endif
    647   ilpPic[0]->setIsLongTerm(1);
    648 
    649   // ref_pic_list_init
    650   UInt cIdx = 0;
    651   UInt num_ref_idx_l0_active_minus1 = m_aiNumRefIdx[0] - 1;
    652   UInt num_ref_idx_l1_active_minus1 = m_aiNumRefIdx[1] - 1;
    653   TComPic*  refPicListTemp0[MAX_NUM_REF+1];
    654   TComPic*  refPicListTemp1[MAX_NUM_REF+1];
    655   Int  numRpsCurrTempList0, numRpsCurrTempList1;
    656 
    657   numRpsCurrTempList0 = numRpsCurrTempList1 = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr + m_aiNumILRRefIdx;
    658   if (numRpsCurrTempList0 <= num_ref_idx_l0_active_minus1)
    659   {
    660     numRpsCurrTempList0 = num_ref_idx_l0_active_minus1 + 1;
    661   }
    662   if (numRpsCurrTempList1 <= num_ref_idx_l1_active_minus1)
    663   {
    664     numRpsCurrTempList1 = num_ref_idx_l1_active_minus1 + 1;
    665   }
    666 
    667   assert(numRpsCurrTempList0 <= MAX_NUM_REF);
    668   assert(numRpsCurrTempList1 <= MAX_NUM_REF);
    669 
    670   cIdx = 0;
    671   while (cIdx < numRpsCurrTempList0)
    672   {
    673     for ( i=0; i<NumPocStCurr0 && cIdx<numRpsCurrTempList0; cIdx++,i++)
    674       refPicListTemp0[cIdx] = RefPicSetStCurr0[ i ];   
    675     for ( i=0; i<NumPocStCurr1 && cIdx<numRpsCurrTempList0; cIdx++,i++)
    676       refPicListTemp0[cIdx] = RefPicSetStCurr1[ i ];
    677     for ( i=0; i<NumPocLtCurr && cIdx<numRpsCurrTempList0; cIdx++,i++)
    678       refPicListTemp0[cIdx] = RefPicSetLtCurr[ i ];
    679     for ( i=0; i<m_aiNumILRRefIdx && cIdx<numRpsCurrTempList0; cIdx++,i++)
    680       refPicListTemp0[cIdx] = ilpPic[ i ];
    681   }
    682   cIdx = 0;
    683   while (cIdx<numRpsCurrTempList1 && m_eSliceType==B_SLICE)
    684   {
    685     for ( i=0; i<NumPocStCurr1 && cIdx<numRpsCurrTempList1; cIdx++,i++)
    686       refPicListTemp1[cIdx] = RefPicSetStCurr1[ i ];
    687     for ( i=0; i<NumPocStCurr0 && cIdx<numRpsCurrTempList1; cIdx++,i++)
    688       refPicListTemp1[cIdx] = RefPicSetStCurr0[ i ];
    689     for ( i=0; i<NumPocLtCurr && cIdx<numRpsCurrTempList1; cIdx++,i++)
    690       refPicListTemp1[cIdx] = RefPicSetLtCurr[ i ];
    691     for ( i=0; i<m_aiNumILRRefIdx && cIdx<numRpsCurrTempList1; cIdx++,i++)
    692       refPicListTemp1[cIdx] = ilpPic[ i ];
    693   }
    694   ::memset(m_bIsUsedAsLongTerm, 0, sizeof(m_bIsUsedAsLongTerm));
    695   for (Int rIdx = 0; rIdx <= (m_aiNumRefIdx[0]-1); rIdx ++)
    696   {
    697     m_apcRefPicList[0][rIdx] = m_RefPicListModification.getRefPicListModificationFlagL0() ? refPicListTemp0[ m_RefPicListModification.getRefPicSetIdxL0(rIdx) ] : refPicListTemp0[rIdx % numRpsCurrTempList0];
    698     m_bIsUsedAsLongTerm[0][rIdx] = m_RefPicListModification.getRefPicListModificationFlagL0() ? (m_RefPicListModification.getRefPicSetIdxL0(rIdx) >= (NumPocStCurr0 + NumPocStCurr1))
    699       : ((rIdx % numRpsCurrTempList0) >= (NumPocStCurr0 + NumPocStCurr1));
    700   }
    701   if ( m_eSliceType == P_SLICE )
    702   {
    703     m_aiNumRefIdx[1] = 0;
    704     ::memset( m_apcRefPicList[1], 0, sizeof(m_apcRefPicList[1]));
    705   }
    706   else
    707   {
    708     for (Int rIdx = 0; rIdx <= (m_aiNumRefIdx[1]-1); rIdx ++)
    709     {
    710       m_apcRefPicList[1][rIdx] = m_RefPicListModification.getRefPicListModificationFlagL1() ? refPicListTemp1[ m_RefPicListModification.getRefPicSetIdxL1(rIdx) ] : refPicListTemp1[rIdx % numRpsCurrTempList1];
    711       m_bIsUsedAsLongTerm[1][rIdx] = m_RefPicListModification.getRefPicListModificationFlagL1() ?
    712         (m_RefPicListModification.getRefPicSetIdxL1(rIdx) >= (NumPocStCurr0 + NumPocStCurr1)): ((rIdx % numRpsCurrTempList1) >= (NumPocStCurr0 + NumPocStCurr1));
    713     }
    714   }
    715 
    716736  return;
    717737}
     
    724744#if REF_IDX_FRAMEWORK
    725745  if( m_eSliceType == I_SLICE || ( getSPS()->getLayerId() &&
    726     (getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA) &&
     746    (getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP) &&
    727747    (getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) ) )
    728748#else
     
    730750#endif
    731751  {
    732 #if REF_LIST_BUGFIX
    733     return m_aiNumILRRefIdx;
     752#if REF_IDX_FRAMEWORK
     753#if JCTVC_M0458_INTERLAYER_RPS_SIG
     754    return m_activeNumILRRefIdx;
     755#else
     756    return getNumILRRefIdx();
     757#endif
    734758#else
    735759    return 0;
     
    743767    }
    744768  }
    745 #if REF_LIST_BUGFIX
     769#if REF_IDX_FRAMEWORK
    746770  if(getLayerId())
    747771  {
     772#if JCTVC_M0458_INTERLAYER_RPS_SIG
     773    numRpsCurrTempList += m_activeNumILRRefIdx;
     774#else
    748775    numRpsCurrTempList += getNumILRRefIdx();
     776#endif
    749777  }
    750778#endif
     
    793821}
    794822
    795 Void TComSlice::checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, Bool& prevRAPisBLA)
     823Void TComSlice::checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, Bool& prevRAPisBLA, TComList<TComPic *>& rcListPic)
    796824{
    797825  for(Int i = 0; i < pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i++)
     
    806834    if(pocCRA < MAX_UINT && getPOC() > pocCRA)
    807835    {
     836      if (!pReferencePictureSet->getCheckLTMSBPresent(i))
     837      {
     838        assert(xGetLongTermRefPic(rcListPic, pReferencePictureSet->getPOC(i), false)->getPOC() >= pocCRA);
     839      }
     840      else
     841      {
    808842      assert(pReferencePictureSet->getPOC(i) >= pocCRA);
    809843    }
    810844  }
    811   if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) // IDR picture found
     845  }
     846  if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) // IDR picture found
    812847  {
    813848    pocCRA = getPOC();
     
    819854    prevRAPisBLA = false;
    820855  }
    821   else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA
    822          || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT
     856  else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
     857         || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
    823858         || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) // BLA picture found
    824859  {
     
    851886  Int pocCurr = getPOC();
    852887
    853   if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA
    854     || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT
     888  if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
     889    || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
    855890    || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP
    856     || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR
     891    || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL
    857892    || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP )  // IDR or BLA picture
    858893  {
     
    866901      iterPic++;
    867902    }
    868     if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA
    869       || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT
     903    if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
     904      || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
    870905      || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP )
    871906    {
     
    881916      {
    882917        rpcPic = *(iterPic);
    883         if (rpcPic->getPOC() != pocCurr && rpcPic->getPOC() != pocCRA) rpcPic->getSlice(0)->setReferenced(false);
     918        if (rpcPic->getPOC() != pocCurr && rpcPic->getPOC() != pocCRA)
     919        {
     920          rpcPic->getSlice(0)->setReferenced(false);
     921        }
    884922        iterPic++;
    885923      }
     
    912950  m_deblockingFilterTcOffsetDiv2 = pSrc->m_deblockingFilterTcOffsetDiv2;
    913951 
     952#if L0034_COMBINED_LIST_CLEANUP
     953  for (i = 0; i < 2; i++)
     954#else
    914955  for (i = 0; i < 3; i++)
     956#endif
    915957  {
    916958    m_aiNumRefIdx[i]     = pSrc->m_aiNumRefIdx[i];
    917959  }
    918960
     961#if L0034_COMBINED_LIST_CLEANUP
     962  for (i = 0; i < MAX_NUM_REF; i++)
     963  {
     964    m_list1IdxToList0Idx[i] = pSrc->m_list1IdxToList0Idx[i];
     965  }
     966#else
    919967  for (i = 0; i < 2; i++)
    920968  {
     
    933981  m_bRefPicListModificationFlagLC = pSrc->m_bRefPicListModificationFlagLC;
    934982  m_bRefPicListCombinationFlag    = pSrc->m_bRefPicListCombinationFlag;
     983#endif
    935984  m_bCheckLDC             = pSrc->m_bCheckLDC;
    936985  m_iSliceQpDelta        = pSrc->m_iSliceQpDelta;
     
    9581007
    9591008  // access channel
     1009#if SVC_EXTENSION
     1010  m_pcVPS                = pSrc->m_pcVPS;
     1011#if JCTVC_M0458_INTERLAYER_RPS_SIG
     1012  m_activeNumILRRefIdx         = pSrc->m_activeNumILRRefIdx;
     1013  m_interLayerPredEnabledFlag  = pSrc->m_interLayerPredEnabledFlag;
     1014  m_numInterLayerRefPics       = pSrc->m_numInterLayerRefPics;
     1015  memcpy( m_interLayerPredLayerIdc, pSrc->m_interLayerPredLayerIdc, sizeof( m_interLayerPredLayerIdc ) );
     1016#elif REF_IDX_FRAMEWORK
     1017  m_numILRRefIdx               = pSrc->m_numILRRefIdx;
     1018#endif
     1019#endif
    9601020  m_pcSPS                = pSrc->m_pcSPS;
    9611021  m_pcPPS                = pSrc->m_pcPPS;
     
    9841044  }
    9851045
     1046#if !L0034_COMBINED_LIST_CLEANUP
    9861047  m_bNoBackPredFlag      = pSrc->m_bNoBackPredFlag;
     1048#endif
    9871049  m_uiTLayer                      = pSrc->m_uiTLayer;
    9881050  m_bTLayerSwitchingFlag          = pSrc->m_bTLayerSwitchingFlag;
     
    10181080
    10191081Int TComSlice::m_prevPOC = 0;
     1082
    10201083/** Function for setting the slice's temporal layer ID and corresponding temporal_layer_switching_point_flag.
    10211084 * \param uiTLayer Temporal layer ID of the current slice
     
    10781141  Int i, isReference;
    10791142
    1080   Int j = 0;
    10811143  // loop through all pictures in the reference picture buffer
    10821144  TComList<TComPic*>::iterator iterPic = rcListPic.begin();
    10831145  while ( iterPic != rcListPic.end())
    10841146  {
    1085     j++;
    10861147    rpcPic = *(iterPic++);
     1148
     1149    if(!rpcPic->getSlice( 0 )->isReferenced())
     1150    {
     1151      continue;
     1152    }
    10871153
    10881154    isReference = 0;
     
    11231189    {           
    11241190      rpcPic->getSlice( 0 )->setReferenced( false );   
     1191      rpcPic->setUsedByCurr(0);
    11251192      rpcPic->setIsLongTerm(0);
    11261193    }
     
    11281195    assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getTLayer()<=this->getTLayer());
    11291196    //check that pictures of higher or equal temporal layer are not in the RPS if the current picture is a TSA picture
    1130     if(this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TLA || this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N)
     1197    if(this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TLA_R || this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N)
    11311198    {
    11321199      assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getTLayer()<this->getTLayer());
     
    11451212{
    11461213  TComPic* rpcPic;
    1147   Int i, isAvailable, j;
     1214  Int i, isAvailable;
    11481215  Int atLeastOneLost = 0;
    11491216  Int atLeastOneRemoved = 0;
     
    11541221  for(i=pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i<pReferencePictureSet->getNumberOfPictures();i++)
    11551222  {
    1156     j = 0;
    11571223    isAvailable = 0;
    11581224    // loop through all pictures in the reference picture buffer
     
    11601226    while ( iterPic != rcListPic.end())
    11611227    {
    1162       j++;
    11631228      rpcPic = *(iterPic++);
    11641229      if(pReferencePictureSet->getCheckLTMSBPresent(i)==true)
     
    11831248      while ( iterPic != rcListPic.end())
    11841249      {
    1185         j++;
    11861250        rpcPic = *(iterPic++);
    11871251
    1188         if((rpcPic->getPicSym()->getSlice(0)->getPOC()%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC())) == (this->getPOC() + pReferencePictureSet->getDeltaPOC(i))%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC()) && rpcPic->getSlice(0)->isReferenced())
     1252        Int pocCycle = 1 << rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC();
     1253        Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC();
     1254        Int refPoc = pReferencePictureSet->getPOC(i);
     1255        if (!pReferencePictureSet->getCheckLTMSBPresent(i))
     1256        {
     1257          curPoc = curPoc % pocCycle;
     1258          refPoc = refPoc % pocCycle;
     1259        }
     1260       
     1261        if (rpcPic->getSlice(0)->isReferenced() && curPoc == refPoc)
    11891262        {
    11901263          isAvailable = 1;
     
    12241297  for(i=0;i<pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i++)
    12251298  {
    1226     j = 0;
    12271299    isAvailable = 0;
    12281300    // loop through all pictures in the reference picture buffer
     
    12301302    while ( iterPic != rcListPic.end())
    12311303    {
    1232       j++;
    12331304      rpcPic = *(iterPic++);
    12341305
     
    12471318        {
    12481319          if(printErrors)
     1320          {
    12491321            printf("\nShort-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i));
     1322          }
    12501323          atLeastOneRemoved = 1;
    12511324        }
     
    12531326        {
    12541327          if(printErrors)
     1328          {
    12551329            printf("\nShort-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i));
     1330          }
    12561331          atLeastOneLost = 1;
    12571332          iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i);
     
    13991474 * \returns Void
    14001475 */
    1401 Void  TComSlice::resetWpScaling(wpScalingParam  wp[2][MAX_NUM_REF][3])
     1476Void  TComSlice::resetWpScaling()
    14021477{
    14031478  for ( Int e=0 ; e<2 ; e++ )
     
    14071482      for ( Int yuv=0 ; yuv<3 ; yuv++ )
    14081483      {
    1409         wpScalingParam  *pwp = &(wp[e][i][yuv]);
     1484        wpScalingParam  *pwp = &(m_weightPredTable[e][i][yuv]);
    14101485        pwp->bPresentFlag      = false;
    14111486        pwp->uiLog2WeightDenom = 0;
     
    14231498Void  TComSlice::initWpScaling()
    14241499{
    1425   initWpScaling(m_weightPredTable);
    1426 }
    1427 
    1428 /** set WP tables
    1429  * \param wpScalingParam
    1430  * \returns Void
    1431  */
    1432 Void  TComSlice::initWpScaling(wpScalingParam  wp[2][MAX_NUM_REF][3])
    1433 {
    14341500  for ( Int e=0 ; e<2 ; e++ )
    14351501  {
     
    14381504      for ( Int yuv=0 ; yuv<3 ; yuv++ )
    14391505      {
    1440         wpScalingParam  *pwp = &(wp[e][i][yuv]);
    1441         if ( !pwp->bPresentFlag ) {
     1506        wpScalingParam  *pwp = &(m_weightPredTable[e][i][yuv]);
     1507        if ( !pwp->bPresentFlag )
     1508        {
    14421509          // Inferring values not present :
    14431510          pwp->iWeight = (1 << pwp->uiLog2WeightDenom);
     
    14771544, m_numOutputLayerSets        (0) 
    14781545#endif
    1479 {
    1480 
     1546#if VPS_PROFILE_OUTPUT_LAYERS
     1547, m_numProfileTierLevel       (0)
     1548, m_moreOutputLayerSetsThanDefaultFlag (false)
     1549, m_numAddOutputLayerSets     (0)
     1550, m_defaultOneTargetOutputLayerFlag    (false)
     1551#endif
     1552{
    14811553  for( Int i = 0; i < MAX_TLAYER; i++)
    14821554  {
    14831555    m_numReorderPics[i] = 0;
     1556#if L0323_DPB
     1557    m_uiMaxDecPicBuffering[i] = 1;
     1558#else
    14841559    m_uiMaxDecPicBuffering[i] = 0;
     1560#endif
    14851561    m_uiMaxLatencyIncrease[i] = 0;
    14861562  }
     
    15121588  ::memset(m_refLayerId,           0, sizeof(m_refLayerId          ));
    15131589#endif
     1590#if DERIVE_LAYER_ID_LIST_VARIABLES
     1591  ::memset(m_layerSetLayerIdList,  0, sizeof(m_layerSetLayerIdList));
     1592  ::memset(m_numLayerInIdList,     0, sizeof(m_numLayerInIdList   ));
     1593#endif
     1594#if VPS_PROFILE_OUTPUT_LAYERS
     1595  ::memset(m_profileLevelTierIdx,  0, sizeof(m_profileLevelTierIdx));
     1596#endif
     1597#if JCTVC_M0458_INTERLAYER_RPS_SIG
     1598  m_maxOneActiveRefLayerFlag = true;
     1599#endif
    15141600}
    15151601
    15161602TComVPS::~TComVPS()
    15171603{
    1518   if( m_hrdParameters    != NULL )     delete m_hrdParameters;
    1519   if( m_hrdOpSetIdx      != NULL )     delete m_hrdOpSetIdx;
    1520   if( m_cprmsPresentFlag != NULL )     delete m_cprmsPresentFlag;
    1521 }
    1522 
     1604  if( m_hrdParameters    != NULL )     delete[] m_hrdParameters;
     1605  if( m_hrdOpSetIdx      != NULL )     delete[] m_hrdOpSetIdx;
     1606  if( m_cprmsPresentFlag != NULL )     delete[] m_cprmsPresentFlag;
     1607}
     1608#if DERIVE_LAYER_ID_LIST_VARIABLES
     1609Void TComVPS::deriveLayerIdListVariables()
     1610{
     1611  // For layer 0
     1612  setNumLayersInIdList(0, 1);
     1613  setLayerSetLayerIdList(0, 0, 0);
     1614
     1615  // For other layers
     1616  Int i, m, n;
     1617  for( i = 1; i <= getNumLayerSets() - 1; i++ )
     1618  {
     1619    n = 0;
     1620    for( m = 0; m <= this->getMaxLayerId(); m++)
     1621    {
     1622      if(this->getLayerIdIncludedFlag(i, m))
     1623      {
     1624        setLayerSetLayerIdList(i, n, m);
     1625        n++;
     1626      }
     1627    }
     1628    setNumLayersInIdList(i, n);
     1629  }
     1630}
     1631#endif
    15231632// ------------------------------------------------------------------------------------------------
    15241633// Sequence parameter set (SPS)
     
    15331642, m_picWidthInLumaSamples     (352)
    15341643, m_picHeightInLumaSamples    (288)
     1644, m_log2MinCodingBlockSize    (  0)
     1645, m_log2DiffMaxMinCodingBlockSize (0)
    15351646, m_uiMaxCUWidth              ( 32)
    15361647, m_uiMaxCUHeight             ( 32)
    15371648, m_uiMaxCUDepth              (  3)
    1538 , m_uiMinTrDepth              (  0)
    1539 , m_uiMaxTrDepth              (  1)
    15401649, m_bLongTermRefsPresent      (false)
    15411650, m_uiQuadtreeTULog2MaxSize   (  0)
     
    15471656, m_pcmLog2MaxSize            (  5)
    15481657, m_uiPCMLog2MinSize          (  7)
     1658#if !L0034_COMBINED_LIST_CLEANUP
    15491659, m_bUseLComb                 (false)
     1660#endif
    15501661, m_bitDepthY                 (  8)
    15511662, m_bitDepthC                 (  8)
     
    15721683  {
    15731684    m_uiMaxLatencyIncrease[i] = 0;
     1685#if L0323_DPB
     1686    m_uiMaxDecPicBuffering[i] = 1;
     1687#else
    15741688    m_uiMaxDecPicBuffering[i] = 0;
     1689#endif
    15751690    m_numReorderPics[i]       = 0;
    15761691  }
     
    15911706  m_RPSList.create(numRPS);
    15921707}
     1708
    15931709Void TComSPS::setHrdParameters( UInt frameRate, UInt numDU, UInt bitRate, Bool randomAccess )
    15941710{
     
    18351951  return m_POC[bufferNum];
    18361952}
     1953
    18371954Void TComReferencePictureSet::setPOC(Int bufferNum, Int POC)
    18381955{
    18391956  m_POC[bufferNum] = POC;
    18401957}
     1958
    18411959Bool TComReferencePictureSet::getCheckLTMSBPresent(Int bufferNum)
    18421960{
    18431961  return m_bCheckLTMSB[bufferNum];
    18441962}
     1963
    18451964Void TComReferencePictureSet::setCheckLTMSBPresent(Int bufferNum, Bool b)
    18461965{
     
    20222141  return (defaultCounter == (SCALING_LIST_NUM * SCALING_LIST_SIZE_NUM - 4)) ? false : true; // -4 for 32x32
    20232142}
     2143
    20242144/** get scaling matrix from RefMatrixID
    20252145 * \param sizeId size index
     
    20312151  ::memcpy(getScalingListAddress(sizeId, listId),((listId == refListId)? getScalingListDefaultAddress(sizeId, refListId): getScalingListAddress(sizeId, refListId)),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]));
    20322152}
     2153
    20332154/** parse syntax infomation
    20342155 *  \param pchFile syntax infomation
     
    21232244  m_scalingListCoef[SCALING_LIST_32x32][3] = m_scalingListCoef[SCALING_LIST_32x32][1]; // copy address for 32x32
    21242245}
     2246
    21252247/** destroy quantization matrix array
    21262248 */
     
    21352257  }
    21362258}
     2259
    21372260/** get default address of quantization matrix
    21382261 * \param sizeId size index
     
    21642287  return src;
    21652288}
     2289
    21662290/** process of default matrix
    21672291 * \param sizeId size index
     
    21732297  setScalingListDC(sizeId,listId,SCALING_LIST_DC);
    21742298}
     2299
    21752300/** check DC value of matrix for default matrix signaling
    21762301 */
     
    22402365//! activate a PPS and depending on isIDR parameter also SPS and VPS
    22412366//! \returns true, if activation is successful
    2242 Bool ParameterSetManager::activatePPS(Int ppsId, Bool isIDR)
     2367Bool ParameterSetManager::activatePPS(Int ppsId, Bool isIRAP)
    22432368{
    22442369  TComPPS *pps = m_ppsMap.getPS(ppsId);
     
    22462371  {
    22472372    Int spsId = pps->getSPSId();
    2248     if (!isIDR && (spsId != m_activeSPSId))
    2249     {
    2250       printf("Warning: tried to activate PPS referring to a inactive SPS at non-IDR.");
     2373    if (!isIRAP && (spsId != m_activeSPSId))
     2374    {
     2375      printf("Warning: tried to activate PPS referring to a inactive SPS at non-IRAP.");
    22512376      return false;
    22522377    }
     
    22552380    {
    22562381      Int vpsId = sps->getVPSId();
    2257       if (!isIDR && (vpsId != m_activeVPSId))
    2258       {
    2259         printf("Warning: tried to activate PPS referring to a inactive VPS at non-IDR.");
     2382      if (!isIRAP && (vpsId != m_activeVPSId))
     2383      {
     2384        printf("Warning: tried to activate PPS referring to a inactive VPS at non-IRAP.");
    22602385        return false;
    22612386      }
     
    23452470// Assumed that RPL of the base layer is same to the EL, otherwise this information should be also dumped and read from the metadata file
    23462471  setPOC( pcSlice->getPOC() );
    2347   if( pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA )
     2472  if( pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA )
    23482473  {
    23492474    setSliceType( I_SLICE );
     
    23952520#endif
    23962521
    2397 #if REF_IDX_FRAMEWORK
    2398 Void TComSlice::addRefPicList( TComPic **pIlpPicList, Int iRefPicNum, Int iInsertOffset )
    2399 {
    2400   if(getSPS()->getLayerId() && m_eSliceType != I_SLICE)
    2401   {
    2402 #if REF_IDX_MFM
    2403     assert(iRefPicNum == 1);
    2404 #if RAP_MFM_INIT
    2405     if(!(getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA && getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) && getSPS()->getMFMEnabledFlag())
    2406 #else
    2407     if( getPOC() != 0 )
    2408 #endif
    2409     {
    2410       pIlpPicList[0]->copyUpsampledMvField(getBaseColPic());
    2411     }
    2412 #if RAP_MFM_INIT
    2413     else
    2414     {
    2415       pIlpPicList[0]->initUpsampledMvField();
    2416     }
    2417 #endif
    2418 #endif
    2419     //add to list 0;
    2420     Int iOffset;
    2421     m_aiNumRefIdx[REF_PIC_LIST_0] += iInsertOffset;
    2422     iOffset = m_aiNumRefIdx[REF_PIC_LIST_0];
    2423     for (Int i=0; i<iRefPicNum; i++)
    2424     {
    2425       pIlpPicList[i]->setIsLongTerm(1);  //mark ilp as long-term reference
    2426       m_bIsUsedAsLongTerm[REF_PIC_LIST_0][iOffset + i] = 1; //mark ilp as long-term reference
    2427       m_apcRefPicList[REF_PIC_LIST_0][iOffset + i] = pIlpPicList[i];
    2428       m_aiNumRefIdx[REF_PIC_LIST_0]++;
    2429       //m_aiNumRefIdx[REF_PIC_LIST_C]++;
    2430     }
    2431     if(m_eSliceType == B_SLICE)
    2432     {
    2433       m_aiNumRefIdx[REF_PIC_LIST_1] += iInsertOffset;
    2434       iOffset = m_aiNumRefIdx[REF_PIC_LIST_1];
    2435       for (Int i=0; i<iRefPicNum; i++)
    2436       {
    2437         pIlpPicList[i]->setIsLongTerm(1);  //mark ilp as long-term reference
    2438         m_bIsUsedAsLongTerm[REF_PIC_LIST_1][iOffset + i] = 1; //mark ilp as long-term reference
    2439         m_apcRefPicList[REF_PIC_LIST_1][iOffset + i] = pIlpPicList[i];
    2440         m_aiNumRefIdx[REF_PIC_LIST_1]++;
    2441         //m_aiNumRefIdx[REF_PIC_LIST_C]++;
    2442       }
    2443     }
    2444   }
    2445 }
    2446 
    24472522#if REF_IDX_MFM
    24482523Void TComSlice::setRefPOCListILP( TComPic** ilpPic, TComPic *pcRefPicBL )
     
    24532528  assert(thePoc == pcRefPicBL->getPOC());
    24542529
    2455 #if REUSE_MVSCALE || REUSE_BLKMAPPING
    24562530  ilpPic[0]->getSlice(0)->setBaseColPic( pcRefPicBL );
    2457 #endif
    24582531
    24592532  //copy reference pictures marking from the reference layer
     
    24862559#endif
    24872560
    2488 
    2489 #endif
    24902561//! \}
  • trunk/source/Lib/TLibCommon/TComSlice.h

    r125 r189  
    504504  Bool        m_layerIdIncludedFlag[MAX_VPS_OP_SETS_PLUS1][MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1];
    505505#endif
    506 
     506#if DERIVE_LAYER_ID_LIST_VARIABLES
     507  Int         m_layerSetLayerIdList[MAX_VPS_LAYER_SETS_PLUS1][MAX_VPS_LAYER_ID_PLUS1];
     508  Int         m_numLayerInIdList[MAX_VPS_LAYER_SETS_PLUS1];
     509#endif
    507510  TComPTL     m_pcPTL;
    508511#if SIGNAL_BITRATE_PICRATE_IN_VPS
     
    547550  UInt       m_refLayerId[MAX_VPS_LAYER_ID_PLUS1][MAX_VPS_LAYER_ID_PLUS1];
    548551#endif
    549 
     552#if VPS_PROFILE_OUTPUT_LAYERS
     553  UInt       m_numProfileTierLevel;
     554  Bool       m_moreOutputLayerSetsThanDefaultFlag;
     555  Int        m_numAddOutputLayerSets;
     556  Bool       m_defaultOneTargetOutputLayerFlag;
     557  Int        m_profileLevelTierIdx[64];     
     558#endif
     559#if JCTVC_M0458_INTERLAYER_RPS_SIG
     560  Bool       m_maxOneActiveRefLayerFlag;
     561#endif
    550562public:
    551563  TComVPS();
     
    604616  Bool    getLayerIdIncludedFlag(UInt opsIdx, UInt id)          { return m_layerIdIncludedFlag[opsIdx][id]; }
    605617  Void    setLayerIdIncludedFlag(Bool v, UInt opsIdx, UInt id)  { m_layerIdIncludedFlag[opsIdx][id] = v;    }
    606 
     618#if DERIVE_LAYER_ID_LIST_VARIABLES
     619  Int     getLayerSetLayerIdList(Int set, Int layerId)          { return m_layerSetLayerIdList[set][layerId]; }
     620  Void    setLayerSetLayerIdList(Int set, Int layerId, Int x)   { m_layerSetLayerIdList[set][layerId] = x   ; }
     621
     622  Int     getNumLayersInIdList(Int set)                          { return m_numLayerInIdList[set]; }
     623  Void    setNumLayersInIdList(Int set, Int x)                   { m_numLayerInIdList[set] = x   ; }
     624
     625  Void    deriveLayerIdListVariables();
     626#endif
    607627  TComPTL* getPTL() { return &m_pcPTL; }
    608628#if SIGNAL_BITRATE_PICRATE_IN_VPS
     
    663683#if VPS_EXTN_DIRECT_REF_LAYERS
    664684  // Direct dependency of layers
    665   Bool   getDirectDependencyFlag(Int i, Int j)                  { return m_directDependencyFlag[i][j]; }
    666   Void   setDirectDependencyFlag(Int i, Int j, Bool x)          { m_directDependencyFlag[i][j] = x;    }
    667  
    668   UInt   getNumDirectRefLayers(Int i)                                { return m_numDirectRefLayers[i];         }
    669   Void   setNumDirectRefLayers(Int i, UInt x)                        { m_numDirectRefLayers[i] = x;            }
    670 
    671   UInt   getRefLayerId(Int i, Int j)                            { return m_refLayerId[i][j];           }
    672   Void   setRefLayerId(Int i, Int j, UInt x)                    { m_refLayerId[i][j] = x;              }
    673 #endif
     685  Bool   getDirectDependencyFlag(Int currLayerId, Int refLayerId)               { return m_directDependencyFlag[currLayerId][refLayerId]; }
     686  Void   setDirectDependencyFlag(Int currLayerId, Int refLayerId, Bool x)       { m_directDependencyFlag[currLayerId][refLayerId] = x;    }
     687 
     688  UInt   getNumDirectRefLayers(Int layerId)                                     { return m_numDirectRefLayers[layerId];                   }
     689  Void   setNumDirectRefLayers(Int layerId, UInt refLayerNum)                   { m_numDirectRefLayers[layerId] = refLayerNum;            }
     690
     691  UInt   getRefLayerId(Int layerId, Int refLayerIdx)                            { return m_refLayerId[layerId][refLayerIdx];              }
     692  Void   setRefLayerId(Int layerId, Int refLayerIdx, UInt refLayerId)           { m_refLayerId[layerId][refLayerIdx] = refLayerId;        }
     693#endif
     694#if VPS_PROFILE_OUTPUT_LAYERS
     695  UInt   getNumProfileTierLevel()                                { return m_numProfileTierLevel; }
     696  Void   setNumProfileTierLevel(Int x)                           { m_numProfileTierLevel = x;    }
     697
     698  Bool   getMoreOutputLayerSetsThanDefaultFlag()                 { return m_moreOutputLayerSetsThanDefaultFlag;}
     699  Void   setMoreOutputLayerSetsThanDefaultFlag(Bool x)           { m_moreOutputLayerSetsThanDefaultFlag = x   ;}
     700
     701  Int    getNumAddOutputLayerSets()                              { return m_numAddOutputLayerSets; }
     702  Void   setNumAddOutputLayerSets(Int x)                         { m_numAddOutputLayerSets = x   ; }
     703
     704  Bool   getDefaultOneTargetOutputLayerFlag()                 { return m_defaultOneTargetOutputLayerFlag;}
     705  Void   setDefaultOneTargetOutputLayerFlag(Bool x)           { m_defaultOneTargetOutputLayerFlag= x    ;}
     706
     707  Int    getProfileLevelTierIdx(Int i)                        { return m_profileLevelTierIdx[i]; }
     708  Void   setProfileLevelTierIdx(Int i, Int x)                 { m_profileLevelTierIdx[i] = x   ; }
     709#endif
     710#if JCTVC_M0458_INTERLAYER_RPS_SIG
     711  Bool   getMaxOneActiveRefLayerFlag()                                          { return m_maxOneActiveRefLayerFlag;                      }
     712  Void   setMaxOneActiveRefLayerFlag(Bool x)                                    { m_maxOneActiveRefLayerFlag = x;                         }
     713#endif
    674714};
    675715
     
    908948  UInt        m_picHeightInLumaSamples;
    909949 
    910   Window      m_conformanceWindow;
    911 
     950  Int         m_log2MinCodingBlockSize;
     951  Int         m_log2DiffMaxMinCodingBlockSize;
    912952  UInt        m_uiMaxCUWidth;
    913953  UInt        m_uiMaxCUHeight;
    914954  UInt        m_uiMaxCUDepth;
    915   UInt        m_uiMinTrDepth;
    916   UInt        m_uiMaxTrDepth;
     955
     956  Window      m_conformanceWindow;
     957
    917958  TComRPSList m_RPSList;
    918959  Bool        m_bLongTermRefsPresent;
     
    930971  Bool        m_useAMP;
    931972
     973#if !L0034_COMBINED_LIST_CLEANUP
    932974  Bool        m_bUseLComb;
     975#endif
    933976 
    934977  // Parameter
     
    9781021  Bool m_bMFMEnabledFlag;
    9791022#endif
     1023#if SCALED_REF_LAYER_OFFSETS
     1024  Window      m_scaledRefLayerWindow;
     1025#endif
    9801026public:
    9811027  TComSPS();
     
    10091055  Bool getUsedByCurrPicLtSPSFlag(Int i)        {return m_usedByCurrPicLtSPSFlag[i];}
    10101056  Void setUsedByCurrPicLtSPSFlag(Int i, Bool x)      { m_usedByCurrPicLtSPSFlag[i] = x;}
     1057
     1058  Int  getLog2MinCodingBlockSize() const           { return m_log2MinCodingBlockSize; }
     1059  Void setLog2MinCodingBlockSize(Int val)          { m_log2MinCodingBlockSize = val; }
     1060  Int  getLog2DiffMaxMinCodingBlockSize() const    { return m_log2DiffMaxMinCodingBlockSize; }
     1061  Void setLog2DiffMaxMinCodingBlockSize(Int val)   { m_log2DiffMaxMinCodingBlockSize = val; }
     1062
    10111063  Void setMaxCUWidth  ( UInt u ) { m_uiMaxCUWidth = u;      }
    10121064  UInt getMaxCUWidth  ()         { return  m_uiMaxCUWidth;  }
     
    10251077  Bool getUseAMP() { return m_useAMP; }
    10261078  Void setUseAMP( Bool b ) { m_useAMP = b; }
    1027   Void setMinTrDepth  ( UInt u ) { m_uiMinTrDepth = u;      }
    1028   UInt getMinTrDepth  ()         { return  m_uiMinTrDepth;  }
    1029   Void setMaxTrDepth  ( UInt u ) { m_uiMaxTrDepth = u;      }
    1030   UInt getMaxTrDepth  ()         { return  m_uiMaxTrDepth;  }
    10311079  Void setQuadtreeTULog2MaxSize( UInt u ) { m_uiQuadtreeTULog2MaxSize = u;    }
    10321080  UInt getQuadtreeTULog2MaxSize()         { return m_uiQuadtreeTULog2MaxSize; }
     
    10501098 
    10511099  // Tool list
     1100#if !L0034_COMBINED_LIST_CLEANUP
    10521101  Void setUseLComb    (Bool b)   { m_bUseLComb = b;         }
    10531102  Bool getUseLComb    ()         { return m_bUseLComb;      }
     1103#endif
    10541104
    10551105  Bool getUseLossless ()         { return m_useLossless; }
     
    11121162  Void     setMFMEnabledFlag(Bool flag) {m_bMFMEnabledFlag = flag;}
    11131163  Bool     getMFMEnabledFlag()          {return m_bMFMEnabledFlag;}
     1164#endif
     1165#if SCALED_REF_LAYER_OFFSETS
     1166  Window&  getScaledRefLayerWindow(     )   { return m_scaledRefLayerWindow; }
    11141167#endif
    11151168};
     
    13701423  Int         m_deblockingFilterBetaOffsetDiv2;    //< beta offset for deblocking filter
    13711424  Int         m_deblockingFilterTcOffsetDiv2;      //< tc offset for deblocking filter
    1372  
     1425#if JCTVC_M0458_INTERLAYER_RPS_SIG
     1426  Int         m_activeNumILRRefIdx;        //< Active inter-layer reference pictures
     1427  Int         m_interLayerPredLayerIdc  [MAX_VPS_LAYER_ID_PLUS1];
     1428#else
     1429#if REF_IDX_FRAMEWORK
     1430  Int         m_numILRRefIdx;       //< for inter-layer reference picture ser
     1431#endif
     1432#endif
     1433#if L0034_COMBINED_LIST_CLEANUP
     1434  Int         m_list1IdxToList0Idx[MAX_NUM_REF];
     1435  Int         m_aiNumRefIdx   [2];    //  for multiple reference of current slice
     1436#else
    13731437  Int         m_aiNumRefIdx   [3];    //  for multiple reference of current slice
    1374 
    1375 #if REF_LIST_BUGFIX
    1376   Int         m_aiNumILRRefIdx;       //< for inter-layer reference picture ser
    1377 #endif
    1378 
    13791438  Int         m_iRefIdxOfLC[2][MAX_NUM_REF_LC];
    13801439  Int         m_eListIdFromIdxOfLC[MAX_NUM_REF_LC];
     
    13841443  Bool        m_bRefPicListModificationFlagLC;
    13851444  Bool        m_bRefPicListCombinationFlag;
     1445#endif
    13861446
    13871447  Bool        m_bCheckLDC;
     
    14211481
    14221482  Bool        m_abEqualRef  [2][MAX_NUM_REF][MAX_NUM_REF];
    1423  
     1483#if !L0034_COMBINED_LIST_CLEANUP
    14241484  Bool        m_bNoBackPredFlag;
     1485#endif
    14251486  UInt        m_uiTLayer;
    14261487#if SVC_EXTENSION
     
    14621523
    14631524  Bool       m_enableTMVPFlag;
     1525#if JCTVC_M0458_INTERLAYER_RPS_SIG
     1526  Bool       m_interLayerPredEnabledFlag;
     1527  Int        m_numInterLayerRefPics;
     1528#endif
    14641529public:
    14651530  TComSlice();
     
    15171582  Int       getDeblockingFilterBetaOffsetDiv2()         { return  m_deblockingFilterBetaOffsetDiv2; }
    15181583  Int       getDeblockingFilterTcOffsetDiv2()           { return  m_deblockingFilterTcOffsetDiv2; }
    1519 #if REF_LIST_BUGFIX
    1520   Int       getNumILRRefIdx     ( )                     { return  m_aiNumILRRefIdx; }
    1521   Void      setNumILRRefIdx     ( Int i )                     { m_aiNumILRRefIdx = i; }
    1522 #endif
     1584
    15231585  Int       getNumRefIdx        ( RefPicList e )                { return  m_aiNumRefIdx[e];             }
    15241586  TComPic*  getPic              ()                              { return  m_pcPic;                      }
     
    15331595  Bool      getMvdL1ZeroFlag ()                                  { return m_bLMvdL1Zero;    }
    15341596  Int       getNumRpsCurrTempList();
     1597#if L0034_COMBINED_LIST_CLEANUP
     1598  Int       getList1IdxToList0Idx ( Int list1Idx )               { return m_list1IdxToList0Idx[list1Idx]; }
     1599#else
    15351600  Int       getRefIdxOfLC       (RefPicList e, Int iRefIdx)     { return m_iRefIdxOfLC[e][iRefIdx];           }
    15361601  Int       getListIdFromIdxOfLC(Int iRefIdx)                   { return m_eListIdFromIdxOfLC[iRefIdx];       }
     
    15421607  Bool      getRefPicListCombinationFlag()                      {return m_bRefPicListCombinationFlag;}
    15431608  Void      setRefPicListCombinationFlag(Bool bflag)            {m_bRefPicListCombinationFlag=bflag;}   
     1609#endif
    15441610  Void      setReferenced(Bool b)                               { m_bRefenced = b; }
    15451611  Bool      isReferenced()                                      { return m_bRefenced; }
    15461612  Void      setPOC              ( Int i )                       { m_iPOC              = i; if(getTLayer()==0) m_prevPOC=i; }
    15471613  Void      setNalUnitType      ( NalUnitType e )               { m_eNalUnitType      = e;      }
    1548   NalUnitType getNalUnitType    ()                              { return m_eNalUnitType;        }
     1614  NalUnitType getNalUnitType    () const                        { return m_eNalUnitType;        }
    15491615  Bool      getRapPicFlag       (); 
    1550   Bool      getIdrPicFlag       ()                              { return getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP; }
    1551   Void      checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, Bool& prevRAPisBLA);
     1616  Bool      getIdrPicFlag       ()                              { return getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP; }
     1617  Bool      isIRAP              () const                        { return (getNalUnitType() >= 16) && (getNalUnitType() <= 23); } 
     1618  Void      checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, Bool& prevRAPisBLA, TComList<TComPic *>& rcListPic);
    15521619  Void      decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic);
    15531620  Void      setSliceType        ( SliceType e )                 { m_eSliceType        = e;      }
     
    15691636  Void      setPic              ( TComPic* p )                  { m_pcPic             = p;      }
    15701637  Void      setDepth            ( Int iDepth )                  { m_iDepth            = iDepth; }
    1571  
    1572 #if SVC_EXTENSION 
    1573   Void      setBaseColPic       ( TComPic* p)                   { m_pcBaseColPic = p; }
    1574   Void      setBaseColPic       ( TComList<TComPic*>& rcListPic , UInt layerID );
    1575   TComPic*  getBaseColPic       ()  { return m_pcBaseColPic; }
    1576 
    1577   Void      setLayerId (UInt layerId) { m_layerId = layerId; }
    1578   UInt      getLayerId ()               { return m_layerId; }
    1579 
    1580   Void        setFullPelBaseRec   ( TComPicYuv* p) { m_pcFullPelBaseRec = p; }
    1581   TComPicYuv* getFullPelBaseRec   ()  { return  m_pcFullPelBaseRec;  }
    1582 
    1583 #if AVC_SYNTAX
    1584   Void      initBaseLayerRPL( TComSlice *pcSlice );
    1585 #endif
    1586 #endif
    1587 
    1588 #if REF_IDX_MFM
    1589   Void      setRefPOCListILP(TComPic** ilpPic, TComPic *pcRefPicBL);
    1590 #endif
    1591 
     1638
     1639#if FIX1071
     1640  Void      setRefPicList       ( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr = false, TComPic** ilpPic = NULL );
     1641#else
    15921642  Void      setRefPicList       ( TComList<TComPic*>& rcListPic );
     1643#endif
    15931644  Void      setRefPOCList       ();
    15941645  Void      setColFromL0Flag    ( UInt colFromL0 ) { m_colFromL0Flag = colFromL0; }
     
    15961647  Void      setCheckLDC         ( Bool b )                      { m_bCheckLDC = b; }
    15971648  Void      setMvdL1ZeroFlag     ( Bool b)                       { m_bLMvdL1Zero = b; }
    1598 
    1599 #if REF_LIST_BUGFIX
    1600   Void      setRefPicListModificationSvc();
    1601   Void      setRefPicListSvc    ( TComList<TComPic*>& rcListPic, TComPic** ilpPic );
    1602 #endif
    16031649
    16041650  Bool      isIntra         ()                          { return  m_eSliceType == I_SLICE;  }
     
    16281674 
    16291675  static Void      sortPicList         ( TComList<TComPic*>& rcListPic );
    1630  
     1676#if L0034_COMBINED_LIST_CLEANUP
     1677  Void setList1IdxToList0Idx();
     1678#else
    16311679  Bool getNoBackPredFlag() { return m_bNoBackPredFlag; }
    16321680  Void setNoBackPredFlag( Bool b ) { m_bNoBackPredFlag = b; }
    16331681  Void generateCombinedList       ();
     1682#endif
    16341683
    16351684  UInt getTLayer             ()                            { return m_uiTLayer;                      }
     
    16791728  Void  getWpScaling    ( RefPicList e, Int iRefIdx, wpScalingParam *&wp);
    16801729
    1681   Void  resetWpScaling  (wpScalingParam  wp[2][MAX_NUM_REF][3]);
    1682   Void  initWpScaling    (wpScalingParam  wp[2][MAX_NUM_REF][3]);
     1730  Void  resetWpScaling  ();
    16831731  Void  initWpScaling   ();
    16841732  inline Bool applyWP   () { return( (m_eSliceType==P_SLICE && m_pcPPS->getUseWP()) || (m_eSliceType==B_SLICE && m_pcPPS->getWPBiPred()) ); }
     
    17141762  Void      setEnableTMVPFlag     ( Bool   b )    { m_enableTMVPFlag = b; }
    17151763  Bool      getEnableTMVPFlag     ()              { return m_enableTMVPFlag;}
     1764
     1765#if SVC_EXTENSION
     1766  Void      setBaseColPic       ( TComList<TComPic*>& rcListPic , UInt layerID );
     1767  Void      setBaseColPic       ( TComPic* p)     { m_pcBaseColPic = p; }
     1768  TComPic*  getBaseColPic       ()                { return m_pcBaseColPic; }
     1769
     1770  Void      setLayerId (UInt layerId)   { m_layerId = layerId; }
     1771  UInt      getLayerId ()               { return m_layerId;    }
     1772
     1773  Void        setFullPelBaseRec   ( TComPicYuv* p) { m_pcFullPelBaseRec = p; }
     1774  TComPicYuv* getFullPelBaseRec   ()               { return  m_pcFullPelBaseRec;  }
     1775
     1776#if AVC_SYNTAX
     1777  Void      initBaseLayerRPL( TComSlice *pcSlice );
     1778#endif
     1779
    17161780#if REF_IDX_FRAMEWORK
    1717   Void      addRefPicList( TComPic **pIlpPicList, Int iRefPicNum, Int iInsertOffset=0 );
    1718 #endif
     1781  Void      setRefPicListModificationSvc();
     1782  Int       getNumILRRefIdx     ( )                     { return  m_pcVPS->getNumDirectRefLayers( m_layerId ); }
     1783
     1784#if REF_IDX_MFM
     1785  Void      setRefPOCListILP(TComPic** ilpPic, TComPic *pcRefPicBL);
     1786#endif
     1787
     1788#if JCTVC_M0458_INTERLAYER_RPS_SIG
     1789  Int       getActiveNumILRRefIdx     ( )               { return  m_activeNumILRRefIdx; }
     1790  Void      setActiveNumILRRefIdx     ( Int i )         { m_activeNumILRRefIdx = i;     } 
     1791
     1792  Int       getInterLayerPredLayerIdc (UInt Idx )               { return  m_interLayerPredLayerIdc[Idx];}
     1793  Void      setInterLayerPredLayerIdc (UInt val, UInt Idx)      { m_interLayerPredLayerIdc[Idx] = val;  }
     1794
     1795  Void      setInterLayerPredEnabledFlag     ( Bool   val )    { m_interLayerPredEnabledFlag = val; }
     1796  Bool      getInterLayerPredEnabledFlag     ()                { return m_interLayerPredEnabledFlag;}
     1797
     1798  Void      setNumInterLayerRefPics          ( UInt   val )    { m_numInterLayerRefPics = val; }
     1799  UInt      getNumInterLayerRefPics          ()                { return m_numInterLayerRefPics;} 
     1800#else
     1801  Void      setNumILRRefIdx     ( Int i )               { m_numILRRefIdx = i;     }
     1802#endif
     1803#endif
     1804
     1805#endif //SVC_EXTENSION
     1806
    17191807protected:
    17201808  TComPic*  xGetRefPic  (TComList<TComPic*>& rcListPic,
    17211809                         Int                 poc);
    1722   TComPic*  xGetLongTermRefPic  (TComList<TComPic*>& rcListPic,
    1723                          Int                 poc);
     1810  TComPic*  xGetLongTermRefPic(TComList<TComPic*>& rcListPic, Int poc, Bool pocHasMsb);
    17241811};// END CLASS DEFINITION TComSlice
    17251812
     
    18051892  //! activate a PPS and depending on isIDR parameter also SPS and VPS
    18061893  //! \returns true, if activation is successful
    1807   Bool activatePPS(Int ppsId, Bool isIDR);
     1894  Bool activatePPS(Int ppsId, Bool isIRAP);
    18081895
    18091896  TComVPS* getActiveVPS(){ return m_vpsMap.getPS(m_activeVPSId); };
  • trunk/source/Lib/TLibCommon/TComTrQuant.cpp

    r125 r189  
    20072007          }
    20082008         
    2009           if(piQCoef[minPos] == 32767 || piQCoef[minPos] == -32768)
     2009          if(piDstCoeff[minPos] == 32767 || piDstCoeff[minPos] == -32768)
    20102010          {
    20112011            finalChange = -1;
  • trunk/source/Lib/TLibCommon/TComUpsampleFilter.cpp

    r125 r189  
    128128}
    129129
     130#if SCALED_REF_LAYER_OFFSETS
     131Void TComUpsampleFilter::upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window )
     132#else
    130133Void TComUpsampleFilter::upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic )
     134#endif
    131135{
    132136  assert ( NTAPS_US_LUMA == 8 );
     
    136140
    137141  //========== Y component upsampling ===========
     142#if SCALED_REF_LAYER_OFFSETS
     143  const Window &scalEL = window;
     144
     145  Int widthBL   = pcBasePic->getWidth ();
     146  Int heightBL  = pcBasePic->getHeight();
     147  Int strideBL  = pcBasePic->getStride();
     148
     149  Int widthEL   = pcUsPic->getWidth () - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();
     150  Int heightEL  = pcUsPic->getHeight() - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
     151  Int strideEL  = pcUsPic->getStride();
     152#else
    138153  const Window &confBL = pcBasePic->getConformanceWindow();
    139154  const Window &confEL = pcUsPic->getConformanceWindow();
     
    146161  Int heightEL  = pcUsPic->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
    147162  Int strideEL  = pcUsPic->getStride();
    148  
     163#endif
    149164  Pel* piTempBufY = pcTempPic->getLumaAddr();
    150165  Pel* piSrcBufY  = pcBasePic->getLumaAddr();
     
    329344  const Double sFactor12 = sFactor * 12;
    330345#endif
     346#if ILP_DECODED_PICTURE
     347  widthBL   = pcBasePic->getWidth ();
     348  heightBL  = pcBasePic->getHeight();
     349
     350  widthEL   = pcUsPic->getWidth ();
     351  heightEL  = pcUsPic->getHeight();
     352#endif
     353#if SCALED_REF_LAYER_OFFSETS
     354  Int leftStartL = scalEL.getWindowLeftOffset();
     355  Int rightEndL  = pcUsPic->getWidth() - scalEL.getWindowRightOffset();
     356  Int topStartL  = scalEL.getWindowTopOffset();
     357  Int bottomEndL = pcUsPic->getHeight() - scalEL.getWindowBottomOffset();
     358#endif
    331359
    332360  //========== horizontal upsampling ===========
    333361  for( i = 0; i < widthEL; i++ )
    334362  {
     363#if SCALED_REF_LAYER_OFFSETS
     364    Int x = Clip3( leftStartL, rightEndL - 1, i );
     365#endif
    335366#if PHASE_DERIVATION_IN_INTEGER
     367#if SCALED_REF_LAYER_OFFSETS
     368    refPos16 = (((x - leftStartL)*scaleX + addX) >> shiftXM4) - deltaX;
     369#else
    336370    refPos16 = ((i*scaleX + addX) >> shiftXM4) - deltaX;
     371#endif
    337372    phase    = refPos16 & 15;
    338373    refPos   = refPos16 >> 4;
     
    366401  Int iOffset = 1 << (nShift - 1);
    367402
     403#if SCALED_REF_LAYER_OFFSETS
     404  for( j = 0; j < pcTempPic->getHeight(); j++ )
     405#else
    368406  for( j = 0; j < heightEL; j++ )
    369   {
     407#endif
     408  {
     409#if SCALED_REF_LAYER_OFFSETS
     410    Int y = Clip3(topStartL, bottomEndL - 1, j);
     411#endif
    370412#if PHASE_DERIVATION_IN_INTEGER
     413#if SCALED_REF_LAYER_OFFSETS
     414    refPos16 = ((( y - topStartL )*scaleY + addY) >> shiftYM4) - deltaY;
     415#else
    371416    refPos16 = ((j*scaleY + addY) >> shiftYM4) - deltaY;
     417#endif
    372418    phase    = refPos16 & 15;
    373419    refPos   = refPos16 >> 4;
     
    382428    piSrcY = piTempBufY + (refPos -((NTAPS_US_LUMA>>1) - 1))*strideEL;
    383429    piDstY = piDstBufY + j * strideEL;
    384 
     430#if SCALED_REF_LAYER_OFFSETS
     431    for( i = 0; i < pcTempPic->getWidth(); i++ )
     432#else
    385433    for( i = 0; i < widthEL; i++ )
     434#endif
    386435    {
    387436      *piDstY = ClipY( (sumLumaVer(piSrcY, coeff, strideEL) + iOffset) >> (nShift));
     437#if SCALED_REF_LAYER_OFFSETS
     438      // Only increase the x position of reference upsample picture when within the window
     439      // "-2" to ensure that pointer doesn't go beyond the boundary rightEndL-1
     440      if( (i >= leftStartL) && (i <= rightEndL-2) )
     441      {
     442        piSrcY++;
     443      }
     444#else
    388445      piSrcY++;
     446#endif
    389447      piDstY++;
    390448    }
    391449  }
     450
     451#if ILP_DECODED_PICTURE
     452#if SCALED_REF_LAYER_OFFSETS
     453  widthBL   = pcBasePic->getWidth ();
     454  heightBL  = pcBasePic->getHeight();
     455
     456  widthEL   = pcUsPic->getWidth () - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();
     457  heightEL  = pcUsPic->getHeight() - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
     458#else
     459  widthBL   = pcBasePic->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset();
     460  heightBL  = pcBasePic->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset();
     461
     462  widthEL   = pcUsPic->getWidth () - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset();
     463  heightEL  = pcUsPic->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
     464#endif
     465#endif
    392466
    393467  //========== UV component upsampling ===========
     
    401475  strideBL  = pcBasePic->getCStride();
    402476  strideEL  = pcUsPic->getCStride();
     477#if SCALED_REF_LAYER_OFFSETS
     478  Int leftStartC = scalEL.getWindowLeftOffset() >> 1;
     479  Int rightEndC  = (pcUsPic->getWidth() >> 1) - (scalEL.getWindowRightOffset() >> 1);
     480  Int topStartC  = scalEL.getWindowTopOffset() >> 1;
     481  Int bottomEndC = (pcUsPic->getHeight() >> 1) - (scalEL.getWindowBottomOffset() >> 1);
     482#endif
    403483
    404484#if PHASE_DERIVATION_IN_INTEGER
     
    422502#endif
    423503
     504#if ILP_DECODED_PICTURE
     505  widthBL   = pcBasePic->getWidth () >> 1;
     506  heightBL  = pcBasePic->getHeight() >> 1;
     507
     508  widthEL   = pcUsPic->getWidth () >> 1;
     509  heightEL  = pcUsPic->getHeight() >> 1;
     510#endif
     511
    424512  //========== horizontal upsampling ===========
    425513  for( i = 0; i < widthEL; i++ )
    426514  {
     515#if SCALED_REF_LAYER_OFFSETS
     516    Int x = Clip3(leftStartC, rightEndC - 1, i);
     517#endif
    427518#if PHASE_DERIVATION_IN_INTEGER
     519#if SCALED_REF_LAYER_OFFSETS
     520    refPos16 = (((x - leftStartC)*scaleX + addX) >> shiftXM4) - deltaX;
     521#else
    428522    refPos16 = ((i*scaleX + addX) >> shiftXM4) - deltaX;
     523#endif
    429524    phase    = refPos16 & 15;
    430525    refPos   = refPos16 >> 4;
     
    460555  pcTempPic->setHeight(heightEL << 1);
    461556
    462   for( j = 0; j < heightEL; j++ )
    463   {
     557#if SCALED_REF_LAYER_OFFSETS
     558  for( j = 0; j < pcTempPic->getHeight() >> 1; j++ )
     559#else
     560    for( j = 0; j < heightEL; j++ )
     561#endif
     562  {
     563#if SCALED_REF_LAYER_OFFSETS
     564    Int y = Clip3(topStartC, bottomEndC - 1, j);
     565#endif
    464566#if PHASE_DERIVATION_IN_INTEGER
     567#if SCALED_REF_LAYER_OFFSETS
     568    refPos16 = (((y - topStartC)*scaleY + addY) >> shiftYM4) - deltaY;
     569#else
    465570    refPos16 = ((j*scaleY + addY) >> shiftYM4) - deltaY;
     571#endif
    466572    phase    = refPos16 & 15;
    467573    refPos   = refPos16 >> 4;
     
    488594    piDstV = piDstBufV + j*strideEL;
    489595
     596#if SCALED_REF_LAYER_OFFSETS
     597    for( i = 0; i < pcTempPic->getWidth() >> 1; i++ )
     598#else
    490599    for( i = 0; i < widthEL; i++ )
     600#endif
    491601    {
    492602      *piDstU = ClipC( (sumChromaVer(piSrcU, coeff, strideEL) + iOffset) >> (nShift));
    493603      *piDstV = ClipC( (sumChromaVer(piSrcV, coeff, strideEL) + iOffset) >> (nShift));
    494604
     605#if SCALED_REF_LAYER_OFFSETS
     606      // Only increase the x position of reference upsample picture when within the window
     607      // "-2" to ensure that pointer doesn't go beyond the boundary rightEndC-1
     608      if( (i >= leftStartC) && (i <= rightEndC-2) )
     609      {
     610        piSrcU++;
     611        piSrcV++;
     612      }
     613#else
    495614      piSrcU++;
    496615      piSrcV++;
     616#endif
    497617      piDstU++;
    498618      piDstV++;
  • trunk/source/Lib/TLibCommon/TComUpsampleFilter.h

    r2 r189  
    5252  ~TComUpsampleFilter(void);
    5353
     54#if SCALED_REF_LAYER_OFFSETS
     55  Void upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window );
     56#else
    5457 Void upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic );
     58#endif
    5559};
    5660
  • trunk/source/Lib/TLibCommon/TypeDef.h

    r125 r189  
    4444
    4545#if SVC_EXTENSION
     46#define SCALED_REF_LAYER_OFFSETS         1      ///< M0309: Signal scaled reference layer offsets in SPS
     47#define MAX_LAYERS                       2      ///< max number of layers the codec is supposed to handle
     48
    4649#define VPS_RENAME                       1      ///< Rename variables max_layer_id and num_layer_sets_minus1 in VPS
    4750#define VPS_EXTNS                        1      ///< Include function structure for VPS extensions
     
    5154#define VPS_EXTN_PROFILE_INFO            1      ///< Include profile information for layer sets in VPS extension
    5255#define VPS_EXTN_DIRECT_REF_LAYERS       1      ///< Include indication of direct dependency of layers in VPS extension
    53 #endif
    54 #define MAX_LAYERS                       2      ///< max number of layers the codec is supposed to handle
     56#define VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE   1
     57#define VPS_OUTPUT_LAYER_SET_IDX         1      ///< M0268: Signal output_layer_set_idx[i] as output_layer_set_idx_minus1[i]
     58#define VPS_MOVE_DIR_DEPENDENCY_FLAG     1      ///< M0268: Move the syntax element direct_dependency_flag to follow the syntax element dimension_id
     59#define VPS_PROFILE_OUTPUT_LAYERS        1      ///< M0268: Signal profile information and output layer information as in Sec. 3 of M0268v2
     60#endif
     61
     62#define DERIVE_LAYER_ID_LIST_VARIABLES   1      ///< Derived variables based on the variables in VPS - for use in syntax table parsing
    5563
    5664#define SVC_COL_BLK                      1      ///< get co-located block
     
    6068#define CHROMA_UPSAMPLING                1      ///< L0335: Chroma upsampling with 5 bits coefficients
    6169
    62 #define MV_SCALING_FIX                   1      ///< fixing the base layer MV scaling
    63 #define MV_SCALING_POS_FIX               1      ///< use center pixels to get co-located base layer block
    64 #define MFM_CLIPPING_FIX                 1      ///< set the right picture size for the clipping
    65 
    66 #define AVC_BASE                         0      ///< YUV BL reading for AVC base SVC
    67 #define REF_IDX_FRAMEWORK                0      ///< inter-layer reference framework
    68 
    69 #if SVC_UPSAMPLING
     70#define SIMPLIFIED_MV_POS_SCALING        1      ///< M0133/M0449: inter-layer MV scaling and pixel mapping position calculation
     71#define ILP_DECODED_PICTURE              1      ///< M0274: use decoded picture for inter-layer prediction
     72#define JCTVC_M0259_LAMBDAREFINEMENT     1      ///< JCTVC-M0259: lambda refinement (encoder only optimization)
     73
     74#define REF_IDX_FRAMEWORK                1      ///< inter-layer reference framework
     75
     76#if SVC_UPSAMPLING && !ILP_DECODED_PICTURE
    7077#define JCTVC_L0178                      1      ///< implementation of JCTVC-L0178 (code only supports right and bottom croppping offsets)
    7178#endif
     
    7380#define IDR_ALIGNMENT                    1      ///< align IDR picures across layers
    7481
     82#define AVC_BASE                         1      ///< YUV BL reading for AVC base SVC
    7583#if AVC_BASE
    76 #define AVC_SYNTAX                       1      ///< Syntax reading for AVC base
     84#define AVC_SYNTAX                       0      ///< Syntax reading for AVC base
    7785#endif
    7886
     
    8088#define REF_IDX_ME_ZEROMV                1      ///< L0051: use zero motion for inter-layer reference picture (without fractional ME)
    8189#define ENCODER_FAST_MODE                1      ///< 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.
    82 #if !AVC_BASE || AVC_SYNTAX
    8390#define REF_IDX_MFM                      1      ///< L0336: motion vector mapping of inter-layer reference picture
    84 #endif
    85 
    86 #if REF_IDX_MFM
    87 #define REUSE_MVSCALE                    1      ///< using the base layer MV scaling function
    88 #define REUSE_BLKMAPPING                 1      ///< using the base layer get co-located block function
    89 #define RAP_MFM_INIT                     1      ///< initilizing MFM when base layer is RAP picture
    90 #define REF_LIST_BUGFIX                  1
    91 #endif
    92 
     91#define JCTVC_M0458_INTERLAYER_RPS_SIG   1      ///< implementation of JCTVC-L0178 (currently only one reference layer is supported )
     92#if JCTVC_M0458_INTERLAYER_RPS_SIG
     93#define ZERO_NUM_DIRECT_LAYERS           1      ///< support of zero direct reference layers
     94#endif
    9395#else
    9496#define INTRA_BL                         1      ///< inter-layer texture prediction
     
    9799#define INTRA_BL_DST4x4                  1      ///< L0067/L0204: DST4x4 for Intra BL
    98100#define NO_RESIDUAL_FLAG_FOR_BLPRED      1      ///< L0437: Root cbf for Intra_BL
     101#define IL_MRG_SIMPLIFIED_PRUNING        1      ///< M0124: simplified pruning, Only the left and above candidates are checked with BL-C candidate for redundancy removal
     102#define INTRA_BL_CTX_CHANGE              1      ///< M0075: spatial dependency removal for IntraBL flag context derivation
    99103
    100104// Hooks
     
    109113#endif
    110114#else
     115#define ILP_DECODED_PICTURE              0
    111116#define SYNTAX_OUTPUT                    0
    112117#endif
     
    114119//! \ingroup TLibCommon
    115120//! \{
     121
     122#define FIX1071 1 ///< Temporary fix for issue #1071
     123
     124#define L0208_SOP_DESCRIPTION_SEI     1 ///< L0208: add SOP descrioption SEI
     125#define MAX_NUM_PICS_IN_SOP           1024
     126
     127#define K0180_SCALABLE_NESTING_SEI  1   ///JCTVC-K0180 scalable nesting sei message
     128#define MAX_NESTING_NUM_OPS         1024
     129#define MAX_NESTING_NUM_LAYER       64
     130
     131#define J0149_TONE_MAPPING_SEI        1 ///< J0149: Tone mapping information SEI
    116132#define L0363_DU_BIT_RATE             1 ///< L0363: add bit_rate_du_value_minus1 to HRD parameters
    117133#define L0328_SPLICING                1 ///< L0328: splicing support in HRD
     
    138154#define SIGNAL_BITRATE_PICRATE_IN_VPS               0  ///< K0125: Signal bit_rate and pic_rate in VPS
    139155#define L0232_RD_PENALTY           1  ///< L0232: RD-penalty for 32x32 TU for intra in non-intra slices
     156#define L0386_DB_METRIC            1  ///< L0386: non-normative blockiness metric (automatically configures deblocking parameters in bitstream)
     157#define L0323_DPB                     1 ///< L0323: Specification of active reference indices and decoded picture buffer
     158
     159#define L0034_COMBINED_LIST_CLEANUP 1
    140160
    141161#if VPS_EXTN_MASK_AND_DIM_INFO
     
    144164#if VPS_RENAME
    145165#define MAX_VPS_LAYER_SETS_PLUS1                  1024
    146 #define MAX_VPS_LAYER_ID_PLUS1                    2
     166#define MAX_VPS_LAYER_ID_PLUS1                    MAX_LAYERS
    147167#else
    148168#define MAX_VPS_NUM_HRD_PARAMETERS                1
     
    477497  REF_PIC_LIST_0 = 0,   ///< reference list 0
    478498  REF_PIC_LIST_1 = 1,   ///< reference list 1
     499#if !L0034_COMBINED_LIST_CLEANUP
    479500  REF_PIC_LIST_C = 2,   ///< combined reference list for uni-prediction in B-Slices
     501#endif
    480502  REF_PIC_LIST_X = 100  ///< special mark
    481503};
  • trunk/source/Lib/TLibDecoder/NALread.cpp

    r125 r189  
    5050//! \ingroup TLibDecoder
    5151//! \{
    52 static void convertPayloadToRBSP(vector<uint8_t>& nalUnitBuf, Bool isVclNalUnit)
     52static void convertPayloadToRBSP(vector<uint8_t>& nalUnitBuf, TComInputBitstream *bitstream, Bool isVclNalUnit)
    5353{
    5454  UInt zeroCount = 0;
    5555  vector<uint8_t>::iterator it_read, it_write;
    5656
    57   for (it_read = it_write = nalUnitBuf.begin(); it_read != nalUnitBuf.end(); it_read++, it_write++)
     57  UInt pos = 0;
     58  bitstream->clearEmulationPreventionByteLocation();
     59  for (it_read = it_write = nalUnitBuf.begin(); it_read != nalUnitBuf.end(); it_read++, it_write++, pos++)
    5860  {
    5961    assert(zeroCount < 2 || *it_read >= 0x03);
    6062    if (zeroCount == 2 && *it_read == 0x03)
    6163    {
     64      bitstream->pushEmulationPreventionByteLocation( pos );
     65      pos++;
    6266      it_read++;
    6367      zeroCount = 0;
     
    109113  if ( nalu.m_temporalId )
    110114  {
    111     assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA
    112          && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLANT
     115    assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA_W_LP
     116         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA_W_RADL
    113117         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA_N_LP
    114          && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_IDR
     118         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_IDR_W_RADL
    115119         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_IDR_N_LP
    116120         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_CRA
     
    122126  else
    123127  {
    124     assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TLA
     128    assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TLA_R
    125129         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TSA_N
    126130         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_STSA_R
     
    136140  /* perform anti-emulation prevention */
    137141  TComInputBitstream *pcBitstream = new TComInputBitstream(NULL);
    138   convertPayloadToRBSP(nalUnitBuf, (nalUnitBuf[0] & 64) == 0);
     142  convertPayloadToRBSP(nalUnitBuf, pcBitstream, (nalUnitBuf[0] & 64) == 0);
    139143 
    140144  nalu.m_Bitstream = new TComInputBitstream(&nalUnitBuf);
     145  nalu.m_Bitstream->setEmulationPreventionByteLocation(pcBitstream->getEmulationPreventionByteLocation());
    141146  delete pcBitstream;
    142147  readNalUnitHeader(nalu);
  • trunk/source/Lib/TLibDecoder/SEIread.cpp

    r125 r189  
    9090    fprintf( g_hTrace, "=========== Decoding Unit Information SEI message ===========\n");
    9191    break;
     92#if J0149_TONE_MAPPING_SEI
     93  case SEI::TONE_MAPPING_INFO:
     94    fprintf( g_hTrace, "===========Tone Mapping Info SEI message ===========\n");
     95    break;
     96#endif
     97#if L0208_SOP_DESCRIPTION_SEI
     98  case SEI::SOP_DESCRIPTION:
     99    fprintf( g_hTrace, "=========== SOP Description SEI message ===========\n");
     100    break;
     101#endif
     102#if K0180_SCALABLE_NESTING_SEI
     103  case SEI::SCALABLE_NESTING:
     104    fprintf( g_hTrace, "=========== Scalable Nesting SEI message ===========\n");
     105    break;
     106#endif
    92107  default:
    93108    fprintf( g_hTrace, "=========== Unknown SEI message ===========\n");
     
    154169  SEI *sei = NULL;
    155170
    156   if(nalUnitType == NAL_UNIT_SEI)
     171  if(nalUnitType == NAL_UNIT_PREFIX_SEI)
    157172  {
    158173    switch (payloadType)
     
    219234      xParseSEIGradualDecodingRefreshInfo((SEIGradualDecodingRefreshInfo&) *sei, payloadSize);
    220235      break;
     236#if J0149_TONE_MAPPING_SEI
     237    case SEI::TONE_MAPPING_INFO:
     238      sei = new SEIToneMappingInfo;
     239      xParseSEIToneMappingInfo((SEIToneMappingInfo&) *sei, payloadSize);
     240      break;
     241#endif
     242#if L0208_SOP_DESCRIPTION_SEI
     243    case SEI::SOP_DESCRIPTION:
     244      sei = new SEISOPDescription;
     245      xParseSEISOPDescription((SEISOPDescription&) *sei, payloadSize);
     246      break;
     247#endif
     248#if K0180_SCALABLE_NESTING_SEI
     249    case SEI::SCALABLE_NESTING:
     250      sei = new SEIScalableNesting;
     251      xParseSEIScalableNesting((SEIScalableNesting&) *sei, nalUnitType, payloadSize, sps);
     252      break;
     253#endif
    221254    default:
    222255      for (UInt i = 0; i < payloadSize; i++)
     
    284317    {
    285318      UInt reservedPayloadExtensionData;
    286       READ_CODE (1, reservedPayloadExtensionData, "reserved_payload_extension_data");
     319      READ_FLAG (reservedPayloadExtensionData, "reserved_payload_extension_data");
    287320    }
    288321
    289322    UInt dummy;
    290     READ_CODE (1, dummy, "payload_bit_equal_to_one");
    291     READ_CODE (payloadBitsRemaining-1, dummy, "payload_bit_equal_to_zero");
     323    READ_FLAG (dummy, "payload_bit_equal_to_one"); payloadBitsRemaining--;
     324    while (payloadBitsRemaining)
     325    {
     326      READ_FLAG (dummy, "payload_bit_equal_to_zero"); payloadBitsRemaining--;
     327    }
    292328  }
    293329
     
    632668}
    633669
     670#if J0149_TONE_MAPPING_SEI
     671Void SEIReader::xParseSEIToneMappingInfo(SEIToneMappingInfo& sei, UInt /*payloadSize*/)
     672{
     673  Int i;
     674  UInt val;
     675  READ_UVLC( val, "tone_map_id" );                         sei.m_toneMapId = val;
     676  READ_FLAG( val, "tone_map_cancel_flag" );                sei.m_toneMapCancelFlag = val;
     677
     678  if ( !sei.m_toneMapCancelFlag )
     679  {
     680    READ_FLAG( val, "tone_map_persistence_flag" );         sei.m_toneMapPersistenceFlag = val;
     681    READ_CODE( 8, val, "coded_data_bit_depth" );           sei.m_codedDataBitDepth = val;
     682    READ_CODE( 8, val, "target_bit_depth" );               sei.m_targetBitDepth = val;
     683    READ_UVLC( val, "model_id" );                          sei.m_modelId = val;
     684    switch(sei.m_modelId)
     685    {
     686    case 0:
     687      {
     688        READ_CODE( 32, val, "min_value" );                 sei.m_minValue = val;
     689        READ_CODE( 32, val, "max_value" );                 sei.m_maxValue = val;
     690        break;
     691      }
     692    case 1:
     693      {
     694        READ_CODE( 32, val, "sigmoid_midpoint" );          sei.m_sigmoidMidpoint = val;
     695        READ_CODE( 32, val, "sigmoid_width" );             sei.m_sigmoidWidth = val;
     696        break;
     697      }
     698    case 2:
     699      {
     700        UInt num = 1u << sei.m_targetBitDepth;
     701        sei.m_startOfCodedInterval.resize(num+1);
     702        for(i = 0; i < num; i++)
     703        {
     704          READ_CODE( ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "start_of_coded_interval" );
     705          sei.m_startOfCodedInterval[i] = val;
     706        }
     707        sei.m_startOfCodedInterval[num] = 1u << sei.m_codedDataBitDepth;
     708        break;
     709      }
     710    case 3:
     711      {
     712        READ_CODE( 16, val,  "num_pivots" );                       sei.m_numPivots = val;
     713        sei.m_codedPivotValue.resize(sei.m_numPivots);
     714        sei.m_targetPivotValue.resize(sei.m_numPivots);
     715        for(i = 0; i < sei.m_numPivots; i++ )
     716        {
     717          READ_CODE( ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "coded_pivot_value" );
     718          sei.m_codedPivotValue[i] = val;
     719          READ_CODE( ((( sei.m_targetBitDepth + 7 ) >> 3 ) << 3),    val, "target_pivot_value" );
     720          sei.m_targetPivotValue[i] = val;
     721        }
     722        break;
     723      }
     724    case 4:
     725      {
     726        READ_CODE( 8, val, "camera_iso_speed_idc" );                     sei.m_cameraIsoSpeedValue = val;
     727        if( sei.m_cameraIsoSpeedValue == 255) //Extended_ISO
     728        {
     729          READ_CODE( 32,   val,   "camera_iso_speed_value" );            sei.m_cameraIsoSpeedValue = val;
     730        }
     731        READ_FLAG( val, "exposure_compensation_value_sign_flag" );       sei.m_exposureCompensationValueSignFlag = val;
     732        READ_CODE( 16, val, "exposure_compensation_value_numerator" );   sei.m_exposureCompensationValueNumerator = val;
     733        READ_CODE( 16, val, "exposure_compensation_value_denom_idc" );   sei.m_exposureCompensationValueDenomIdc = val;
     734        READ_CODE( 32, val, "ref_screen_luminance_white" );              sei.m_refScreenLuminanceWhite = val;
     735        READ_CODE( 32, val, "extended_range_white_level" );              sei.m_extendedRangeWhiteLevel = val;
     736        READ_CODE( 16, val, "nominal_black_level_luma_code_value" );     sei.m_nominalBlackLevelLumaCodeValue = val;
     737        READ_CODE( 16, val, "nominal_white_level_luma_code_value" );     sei.m_nominalWhiteLevelLumaCodeValue= val;
     738        READ_CODE( 16, val, "extended_white_level_luma_code_value" );    sei.m_extendedWhiteLevelLumaCodeValue = val;
     739        break;
     740      }
     741    default:
     742      {
     743        assert(!"Undefined SEIToneMapModelId");
     744        break;
     745      }
     746    }//switch model id
     747  }// if(!sei.m_toneMapCancelFlag)
     748
     749  xParseByteAlign();
     750}
     751#endif
     752
     753#if L0208_SOP_DESCRIPTION_SEI
     754Void SEIReader::xParseSEISOPDescription(SEISOPDescription &sei, UInt payloadSize)
     755{
     756  Int iCode;
     757  UInt uiCode;
     758
     759  READ_UVLC( uiCode,           "sop_seq_parameter_set_id"            ); sei.m_sopSeqParameterSetId = uiCode;
     760  READ_UVLC( uiCode,           "num_pics_in_sop_minus1"              ); sei.m_numPicsInSopMinus1 = uiCode;
     761  for (UInt i = 0; i <= sei.m_numPicsInSopMinus1; i++)
     762  {
     763    READ_CODE( 6, uiCode,                     "sop_desc_vcl_nalu_type" );  sei.m_sopDescVclNaluType[i] = uiCode;
     764    READ_CODE( 3, sei.m_sopDescTemporalId[i], "sop_desc_temporal_id"   );  sei.m_sopDescTemporalId[i] = uiCode;
     765    if (sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_W_RADL && sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_N_LP)
     766    {
     767      READ_UVLC( sei.m_sopDescStRpsIdx[i],    "sop_desc_st_rps_idx"    ); sei.m_sopDescStRpsIdx[i] = uiCode;
     768    }
     769    if (i > 0)
     770    {
     771      READ_SVLC( iCode,                       "sop_desc_poc_delta"     ); sei.m_sopDescPocDelta[i] = iCode;
     772    }
     773  }
     774
     775  xParseByteAlign();
     776}
     777#endif
     778
     779#if K0180_SCALABLE_NESTING_SEI
     780Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComSPS *sps)
     781{
     782  UInt uiCode;
     783  SEIMessages seis;
     784
     785  READ_FLAG( uiCode,            "bitstream_subset_flag"         ); sei.m_bitStreamSubsetFlag = uiCode;
     786  READ_FLAG( uiCode,            "nesting_op_flag"               ); sei.m_nestingOpFlag = uiCode;
     787  if (sei.m_nestingOpFlag)
     788  {
     789    READ_FLAG( uiCode,            "default_op_flag"               ); sei.m_defaultOpFlag = uiCode;
     790    READ_UVLC( uiCode,            "nesting_num_ops_minus1"        ); sei.m_nestingNumOpsMinus1 = uiCode;
     791    for (UInt i = sei.m_defaultOpFlag; i <= sei.m_nestingNumOpsMinus1; i++)
     792    {
     793      READ_CODE( 3,        uiCode,  "nesting_max_temporal_id_plus1"   ); sei.m_nestingMaxTemporalIdPlus1[i] = uiCode;
     794      READ_UVLC( uiCode,            "nesting_op_idx"                  ); sei.m_nestingOpIdx[i] = uiCode;
     795    }
     796  }
     797  else
     798  {
     799    READ_FLAG( uiCode,            "all_layers_flag"               ); sei.m_allLayersFlag       = uiCode;
     800    if (!sei.m_allLayersFlag)
     801    {
     802      READ_CODE( 3,        uiCode,  "nesting_no_op_max_temporal_id_plus1"  ); sei.m_nestingNoOpMaxTemporalIdPlus1 = uiCode;
     803      READ_UVLC( uiCode,            "nesting_num_layers_minus1"            ); sei.m_nestingNumLayersMinus1        = uiCode;
     804      for (UInt i = 0; i <= sei.m_nestingNumLayersMinus1; i++)
     805      {
     806        READ_CODE( 6,           uiCode,     "nesting_layer_id"      ); sei.m_nestingLayerId[i]   = uiCode;
     807      }
     808    }
     809  }
     810
     811  // byte alignment
     812  while ( m_pcBitstream->getNumBitsRead() % 8 != 0 )
     813  {
     814    UInt code;
     815    READ_FLAG( code, "nesting_zero_bit" );
     816  }
     817
     818  sei.m_callerOwnsSEIs = false;
     819
     820  // read nested SEI messages
     821  do {
     822    xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps);
     823  } while (m_pcBitstream->getNumBitsLeft() > 8);
     824
     825}
     826#endif
     827
    634828Void SEIReader::xParseByteAlign()
    635829{
  • trunk/source/Lib/TLibDecoder/SEIread.h

    r125 r189  
    7070  Void xParseSEITemporalLevel0Index   (SEITemporalLevel0Index &sei, UInt payloadSize);
    7171  Void xParseSEIGradualDecodingRefreshInfo (SEIGradualDecodingRefreshInfo &sei, UInt payloadSize);
     72#if J0149_TONE_MAPPING_SEI
     73  Void xParseSEIToneMappingInfo       (SEIToneMappingInfo& sei, UInt payloadSize);
     74#endif
     75#if L0208_SOP_DESCRIPTION_SEI
     76  Void xParseSEISOPDescription        (SEISOPDescription &sei, UInt payloadSize);
     77#endif
     78#if K0180_SCALABLE_NESTING_SEI
     79  Void xParseSEIScalableNesting       (SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComSPS *sps);
     80#endif
    7281  Void xParseByteAlign();
    7382};
  • trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp

    r125 r189  
    593593
    594594  READ_UVLC(     uiCode, "bit_depth_luma_minus8" );
    595   g_bitDepthY = 8 + uiCode;
    596   pcSPS->setBitDepthY(g_bitDepthY);
     595  pcSPS->setBitDepthY( uiCode + 8 );
    597596  pcSPS->setQpBDOffsetY( (Int) (6*uiCode) );
    598597
    599598  READ_UVLC( uiCode,    "bit_depth_chroma_minus8" );
    600   g_bitDepthC = 8 + uiCode;
    601   pcSPS->setBitDepthC(g_bitDepthC);
     599  pcSPS->setBitDepthC( uiCode + 8 );
    602600  pcSPS->setQpBDOffsetC( (Int) (6*uiCode) );
    603601
     
    608606  for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++)
    609607  {
     608#if L0323_DPB
     609    READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1");
     610    pcSPS->setMaxDecPicBuffering( uiCode + 1, i);
     611#else
    610612    READ_UVLC ( uiCode, "sps_max_dec_pic_buffering");
    611613    pcSPS->setMaxDecPicBuffering( uiCode, i);
     614#endif
    612615    READ_UVLC ( uiCode, "sps_num_reorder_pics" );
    613616    pcSPS->setNumReorderPics(uiCode, i);
     
    628631
    629632  READ_UVLC( uiCode, "log2_min_coding_block_size_minus3" );
    630   UInt log2MinCUSize = uiCode + 3;
     633  Int log2MinCUSize = uiCode + 3;
     634  pcSPS->setLog2MinCodingBlockSize(log2MinCUSize);
    631635  READ_UVLC( uiCode, "log2_diff_max_min_coding_block_size" );
    632   UInt uiMaxCUDepthCorrect = uiCode;
    633   pcSPS->setMaxCUWidth  ( 1<<(log2MinCUSize + uiMaxCUDepthCorrect) ); g_uiMaxCUWidth  = 1<<(log2MinCUSize + uiMaxCUDepthCorrect);
    634   pcSPS->setMaxCUHeight ( 1<<(log2MinCUSize + uiMaxCUDepthCorrect) ); g_uiMaxCUHeight = 1<<(log2MinCUSize + uiMaxCUDepthCorrect);
     636  pcSPS->setLog2DiffMaxMinCodingBlockSize(uiCode);
     637  Int maxCUDepthDelta = uiCode;
     638  pcSPS->setMaxCUWidth  ( 1<<(log2MinCUSize + maxCUDepthDelta) );
     639  pcSPS->setMaxCUHeight ( 1<<(log2MinCUSize + maxCUDepthDelta) );
    635640  READ_UVLC( uiCode, "log2_min_transform_block_size_minus2" );   pcSPS->setQuadtreeTULog2MinSize( uiCode + 2 );
    636641
     
    640645  READ_UVLC( uiCode, "max_transform_hierarchy_depth_inter" );    pcSPS->setQuadtreeTUMaxDepthInter( uiCode+1 );
    641646  READ_UVLC( uiCode, "max_transform_hierarchy_depth_intra" );    pcSPS->setQuadtreeTUMaxDepthIntra( uiCode+1 );
    642   g_uiAddCUDepth = 0;
    643   while( ( pcSPS->getMaxCUWidth() >> uiMaxCUDepthCorrect ) > ( 1 << ( pcSPS->getQuadtreeTULog2MinSize() + g_uiAddCUDepth )  ) )
    644   {
    645     g_uiAddCUDepth++;
    646   }
    647   pcSPS->setMaxCUDepth( uiMaxCUDepthCorrect+g_uiAddCUDepth  );
    648   g_uiMaxCUDepth  = uiMaxCUDepthCorrect+g_uiAddCUDepth;
    649   // BB: these parameters may be removed completly and replaced by the fixed values
    650   pcSPS->setMinTrDepth( 0 );
    651   pcSPS->setMaxTrDepth( 1 );
     647
     648  Int addCuDepth = max (0, log2MinCUSize - (Int)pcSPS->getQuadtreeTULog2MinSize() );
     649  pcSPS->setMaxCUDepth( maxCUDepthDelta + addCuDepth );
     650
    652651  READ_FLAG( uiCode, "scaling_list_enabled_flag" );                 pcSPS->setScalingListFlag ( uiCode );
    653652  if(pcSPS->getScalingListFlag())
     
    712711    parseVUI(pcSPS->getVuiParameters(), pcSPS);
    713712  }
     713
     714#if SCALED_REF_LAYER_OFFSETS
     715  if( pcSPS->getLayerId() > 0 )
     716  {
     717    Int iCode;
     718    Window& scaledWindow = pcSPS->getScaledRefLayerWindow();
     719    READ_SVLC( iCode, "scaled_ref_layer_left_offset" );    scaledWindow.setWindowLeftOffset  (iCode << 1);
     720    READ_SVLC( iCode, "scaled_ref_layer_top_offset" );     scaledWindow.setWindowTopOffset   (iCode << 1);
     721    READ_SVLC( iCode, "scaled_ref_layer_right_offset" );   scaledWindow.setWindowRightOffset (iCode << 1);
     722    READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" );  scaledWindow.setWindowBottomOffset(iCode << 1);
     723  }
     724#endif
    714725
    715726  READ_FLAG( uiCode, "sps_extension_flag");
     
    746757  for(UInt i = 0; i <= pcVPS->getMaxTLayers()-1; i++)
    747758  {
     759#if L0323_DPB
     760    READ_UVLC( uiCode,  "vps_max_dec_pic_buffering_minus1[i]" );     pcVPS->setMaxDecPicBuffering( uiCode + 1, i );
     761#else
    748762    READ_UVLC( uiCode,  "vps_max_dec_pic_buffering[i]" );     pcVPS->setMaxDecPicBuffering( uiCode, i );
     763#endif
    749764    READ_UVLC( uiCode,  "vps_num_reorder_pics[i]" );          pcVPS->setNumReorderPics( uiCode, i );
    750765    READ_UVLC( uiCode,  "vps_max_latency_increase[i]" );      pcVPS->setMaxLatencyIncrease( uiCode, i );
     
    785800    }
    786801  }
     802#if DERIVE_LAYER_ID_LIST_VARIABLES
     803  pcVPS->deriveLayerIdListVariables();
     804#endif
    787805#if L0043_TIMING_INFO
    788806  TimingInfo *timingInfo = pcVPS->getTimingInfo();
     
    900918  }
    901919#endif
     920#if VPS_MOVE_DIR_DEPENDENCY_FLAG
     921#if VPS_EXTN_DIRECT_REF_LAYERS
     922  // For layer 0
     923  vps->setNumDirectRefLayers(0, 0);
     924  // For other layers
     925  for( Int layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++)
     926  {
     927    UInt numDirectRefLayers = 0;
     928    for( Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++)
     929    {
     930      READ_FLAG(uiCode, "direct_dependency_flag[i][j]" ); vps->setDirectDependencyFlag(layerCtr, refLayerCtr, uiCode? true : false);
     931      if(uiCode)
     932      {
     933        vps->setRefLayerId(layerCtr, numDirectRefLayers, refLayerCtr);
     934        numDirectRefLayers++;
     935      }
     936    }
     937    vps->setNumDirectRefLayers(layerCtr, numDirectRefLayers);
     938  }
     939#endif
     940#endif
    902941
    903942#if VPS_EXTN_PROFILE_INFO
    904943  // Profile-tier-level signalling
     944#if VPS_PROFILE_OUTPUT_LAYERS
     945  READ_CODE( 10, uiCode, "vps_number_layer_sets_minus1" );     assert( uiCode == (vps->getNumLayerSets() - 1) );
     946  READ_CODE(  6, uiCode, "vps_num_profile_tier_level_minus1"); vps->setNumProfileTierLevel( uiCode + 1 );
     947  vps->getPTLForExtnPtr()->resize(vps->getNumProfileTierLevel());
     948  for(Int idx = 1; idx <= vps->getNumProfileTierLevel() - 1; idx++)
     949#else
    905950  vps->getPTLForExtnPtr()->resize(vps->getNumLayerSets());
    906951  for(Int idx = 1; idx <= vps->getNumLayerSets() - 1; idx++)
     952#endif
    907953  {
    908954    READ_FLAG( uiCode, "vps_profile_present_flag[i]" ); vps->setProfilePresentFlag(idx, uiCode ? true : false);
    909955    if( !vps->getProfilePresentFlag(idx) )
    910956    {
     957#if VPS_PROFILE_OUTPUT_LAYERS
     958      READ_CODE( 6, uiCode, "profile_ref_minus1[i]" ); vps->setProfileLayerSetRef(idx, uiCode + 1);
     959#else
    911960      READ_UVLC( uiCode, "vps_profile_layer_set_ref_minus1[i]" ); vps->setProfileLayerSetRef(idx, uiCode + 1);
     961#endif
    912962      assert( vps->getProfileLayerSetRef(idx) < idx );
    913963      // Copy profile information as indicated
     
    918968#endif
    919969
     970#if VPS_PROFILE_OUTPUT_LAYERS
     971  READ_FLAG( uiCode, "more_output_layer_sets_than_default_flag" ); vps->setMoreOutputLayerSetsThanDefaultFlag( uiCode ? true : false );
     972  Int numOutputLayerSets = 0;
     973  if(! vps->getMoreOutputLayerSetsThanDefaultFlag() )
     974  {
     975    numOutputLayerSets = vps->getNumLayerSets();
     976  }
     977  else
     978  {
     979    READ_CODE( 10, uiCode, "num_add_output_layer_sets" );          vps->setNumAddOutputLayerSets( uiCode );
     980    numOutputLayerSets = vps->getNumLayerSets() + vps->getNumAddOutputLayerSets();
     981  }
     982  if( numOutputLayerSets > 1 )
     983  {
     984    READ_FLAG( uiCode, "default_one_target_output_layer_flag" );   vps->setDefaultOneTargetOutputLayerFlag( uiCode ? true : false );
     985  }
     986  vps->setNumOutputLayerSets( numOutputLayerSets );
     987
     988  for(i = 1; i < numOutputLayerSets; i++)
     989  {
     990    if( i > (vps->getNumLayerSets() - 1) )
     991    {
     992      Int numBits = 1;
     993      while ((1 << numBits) < (vps->getNumLayerSets() - 1))
     994      {
     995        numBits++;
     996      }
     997      READ_CODE( numBits, uiCode, "output_layer_set_idx_minus1");   vps->setOutputLayerSetIdx( i, uiCode + 1);
     998      Int lsIdx = vps->getOutputLayerSetIdx(i);
     999      for(j = 0; j < vps->getNumLayersInIdList(lsIdx) - 1; j++)
     1000      {
     1001        READ_FLAG( uiCode, "output_layer_flag[i][j]"); vps->setOutputLayerFlag(i, j, uiCode);
     1002      }
     1003    }
     1004    else
     1005    {
     1006      // i <= (vps->getNumLayerSets() - 1)
     1007      // Assign OutputLayerFlag depending on default_one_target_output_layer_flag
     1008      Int lsIdx = i;
     1009      if( vps->getDefaultOneTargetOutputLayerFlag() )
     1010      {
     1011        for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++)
     1012        {
     1013          vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1)));
     1014        }
     1015      }
     1016      else
     1017      {
     1018        for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++)
     1019        {
     1020          vps->setOutputLayerFlag(i, j, 1);
     1021        }
     1022      }
     1023    }
     1024    Int numBits = 1;
     1025    while ((1 << numBits) < (vps->getNumProfileTierLevel()))
     1026    {
     1027      numBits++;
     1028    }
     1029    READ_CODE( numBits, uiCode, "profile_level_tier_idx[i]" );     vps->setProfileLevelTierIdx(i, uiCode);
     1030  }
     1031#else
    9201032#if VPS_EXTN_OP_LAYER_SETS
    9211033  // Target output layer signalling
     
    9231035  for(i = 0; i < vps->getNumOutputLayerSets(); i++)
    9241036  {
     1037#if VPS_OUTPUT_LAYER_SET_IDX
     1038    READ_UVLC( uiCode,           "vps_output_layer_set_idx_minus1[i]"); vps->setOutputLayerSetIdx(i, uiCode + 1);
     1039#else
    9251040    READ_UVLC( uiCode,           "vps_output_layer_set_idx[i]"); vps->setOutputLayerSetIdx(i, uiCode);
     1041#endif
    9261042    Int lsIdx = vps->getOutputLayerSetIdx(i);
    9271043    for(j = 0; j <= vps->getMaxLayerId(); j++)
     
    9321048      }
    9331049    }
    934   } 
    935 #endif
     1050  }
     1051#endif
     1052#endif
     1053#if JCTVC_M0458_INTERLAYER_RPS_SIG
     1054   READ_FLAG(uiCode, "max_one_active_ref_layer_flag" );
     1055   vps->setMaxOneActiveRefLayerFlag(uiCode);   
     1056#endif
     1057
     1058#if !VPS_MOVE_DIR_DEPENDENCY_FLAG
    9361059#if VPS_EXTN_DIRECT_REF_LAYERS
    9371060  // For layer 0
     
    9521075    vps->setNumDirectRefLayers(layerCtr, numDirectRefLayers);
    9531076  }
     1077#endif
    9541078#endif
    9551079}
     
    10741198        iPOCmsb = iPrevPOCmsb;
    10751199      }
    1076       if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA
    1077         || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT
     1200      if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
     1201        || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
    10781202        || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP )
    10791203      {
     
    10841208
    10851209      TComReferencePictureSet* rps;
     1210      rps = rpcSlice->getLocalRPS();
     1211      rpcSlice->setRPS(rps);
    10861212      READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" );
    10871213      if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header
    10881214      {
    1089         rps = rpcSlice->getLocalRPS();
    10901215        parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets());
    1091         rpcSlice->setRPS(rps);
    10921216      }
    10931217      else // use reference to short-term reference picture set in PPS
     
    11061230          uiCode = 0;
    11071231        }
    1108         rpcSlice->setRPS(sps->getRPSList()->getReferencePictureSet(uiCode));
    1109 
    1110         rps = rpcSlice->getRPS();
     1232        memcpy(rps,sps->getRPSList()->getReferencePictureSet(uiCode),sizeof(TComReferencePictureSet));
    11111233      }
    11121234      if(sps->getLongTermRefsPresent())
     
    11311253        rps->setNumberOfLongtermPictures(numOfLtrp);
    11321254        Int maxPicOrderCntLSB = 1 << rpcSlice->getSPS()->getBitsForPOC();
    1133         Int prevLSB = 0, prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;;
     1255        Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;;
    11341256        for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++)
    11351257        {
     
    11581280            READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" );
    11591281            Bool deltaFlag = false;
    1160             //            First LTRP                               || First LTRP from SH           || curr LSB    != prev LSB
    1161             if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) || (pocLsbLt != prevLSB) )
     1282            //            First LTRP                               || First LTRP from SH
     1283            if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) )
    11621284            {
    11631285              deltaFlag = true;
     
    11841306            rps->setCheckLTMSBPresent(j,false); 
    11851307          }
    1186           prevLSB = pocLsbLt;
    11871308          prevDeltaMSB = deltaPocMSBCycleLT;
    11881309        }
     
    11901311        rps->setNumberOfPictures(offset);       
    11911312      } 
    1192       if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA
    1193         || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT
     1313      if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
     1314        || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
    11941315        || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP )
    11951316      {
     
    12021323        rpcSlice->setRPS(rps);
    12031324      }
     1325
     1326
    12041327      if (rpcSlice->getSPS()->getTMVPFlagsPresent())
    12051328      {
     
    12121335      }
    12131336    }
     1337
     1338#if REF_IDX_FRAMEWORK
     1339#if JCTVC_M0458_INTERLAYER_RPS_SIG   
     1340    rpcSlice->setActiveNumILRRefIdx(0);
     1341    if((sps->getLayerId() > 0)  &&  (rpcSlice->getNumILRRefIdx() > 0) )
     1342    {     
     1343      READ_FLAG(uiCode,"inter_layer_pred_enabled_flag");
     1344      rpcSlice->setInterLayerPredEnabledFlag(uiCode);
     1345      if( rpcSlice->getInterLayerPredEnabledFlag())
     1346      {
     1347        if(rpcSlice->getNumILRRefIdx() > 1)
     1348        {
     1349          Int numBits = 1;
     1350          while ((1 << numBits) < rpcSlice->getNumILRRefIdx())
     1351          {
     1352            numBits++;
     1353          }
     1354          if( !rpcSlice->getVPS()->getMaxOneActiveRefLayerFlag())
     1355          {
     1356            READ_CODE( numBits, uiCode,"num_inter_layer_ref_pics_minus1" );
     1357            rpcSlice->setActiveNumILRRefIdx(uiCode + 1);         
     1358          }
     1359          else
     1360          {
     1361            rpcSlice->setActiveNumILRRefIdx(1);         
     1362          }
     1363          for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ )
     1364          {
     1365            READ_CODE( numBits,uiCode,"inter_layer_pred_layer_idc[i]" ); 
     1366            rpcSlice->setInterLayerPredLayerIdc(uiCode,i);         
     1367          }
     1368        }
     1369        else
     1370        {
     1371          rpcSlice->setActiveNumILRRefIdx(1);         
     1372          rpcSlice->setInterLayerPredLayerIdc(0,0);     
     1373        }
     1374      }
     1375    }
     1376#else
     1377    if( rpcSlice->getLayerId() > 0 )
     1378    {
     1379      rpcSlice->setNumILRRefIdx( rpcSlice->getVPS()->getNumDirectRefLayers( rpcSlice->getLayerId() ) );
     1380    }
     1381#endif
     1382#endif
     1383
    12141384    if(sps->getUseSAO())
    12151385    {
     
    14231593        if(!rpcSlice->getDeblockingFilterDisable())
    14241594        {
    1425           READ_SVLC( iCode, "beta_offset_div2" );                       rpcSlice->setDeblockingFilterBetaOffsetDiv2(iCode);
    1426           READ_SVLC( iCode, "tc_offset_div2" );                         rpcSlice->setDeblockingFilterTcOffsetDiv2(iCode);
     1595          READ_SVLC( iCode, "slice_beta_offset_div2" );                       rpcSlice->setDeblockingFilterBetaOffsetDiv2(iCode);
     1596          assert(rpcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 &&
     1597                 rpcSlice->getDeblockingFilterBetaOffsetDiv2() <=  6);
     1598          READ_SVLC( iCode, "slice_tc_offset_div2" );                         rpcSlice->setDeblockingFilterTcOffsetDiv2(iCode);
     1599          assert(rpcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 &&
     1600                 rpcSlice->getDeblockingFilterTcOffsetDiv2() <=  6);
    14271601        }
    14281602      }
     
    14561630  }
    14571631 
    1458   if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() )
    1459   {
    14601632    UInt *entryPointOffset          = NULL;
    14611633    UInt numEntryPointOffsets, offsetLenMinus1;
    1462 
     1634  if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() )
     1635  {
    14631636    READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); rpcSlice->setNumEntryPointOffsets ( numEntryPointOffsets );
    14641637    if (numEntryPointOffsets>0)
     
    14771650#endif
    14781651    }
     1652  }
     1653  else
     1654  {
     1655    rpcSlice->setNumEntryPointOffsets ( 0 );
     1656  }
     1657
     1658  if(pps->getSliceHeaderExtensionPresentFlag())
     1659  {
     1660    READ_UVLC(uiCode,"slice_header_extension_length");
     1661    for(Int i=0; i<uiCode; i++)
     1662    {
     1663      UInt ignore;
     1664      READ_CODE(8,ignore,"slice_header_extension_data_byte");
     1665    }
     1666  }
     1667  m_pcBitstream->readByteAlignment();
     1668
     1669  if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() )
     1670  {
     1671    Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation();
     1672    Int  curEntryPointOffset     = 0;
     1673    Int  prevEntryPointOffset    = 0;
     1674    for (UInt idx=0; idx<numEntryPointOffsets; idx++)
     1675    {
     1676      curEntryPointOffset += entryPointOffset[ idx ];
     1677
     1678      Int emulationPreventionByteCount = 0;
     1679      for ( UInt curByteIdx  = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ )
     1680      {
     1681        if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) &&
     1682             m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) <  ( curEntryPointOffset  + endOfSliceHeaderLocation ) )
     1683        {
     1684          emulationPreventionByteCount++;
     1685        }
     1686      }
     1687
     1688      entryPointOffset[ idx ] -= emulationPreventionByteCount;
     1689      prevEntryPointOffset = curEntryPointOffset;
     1690    }
    14791691
    14801692    if ( pps->getTilesEnabledFlag() )
     
    15121724    }
    15131725  }
    1514   else
    1515   {
    1516     rpcSlice->setNumEntryPointOffsets ( 0 );
    1517   }
    1518 
    1519   if(pps->getSliceHeaderExtensionPresentFlag())
    1520   {
    1521     READ_UVLC(uiCode,"slice_header_extension_length");
    1522     for(Int i=0; i<uiCode; i++)
    1523     {
    1524       UInt ignore;
    1525       READ_CODE(8,ignore,"slice_header_extension_data_byte");
    1526     }
    1527   }
    1528   m_pcBitstream->readByteAlignment();
     1726
    15291727  return;
    15301728}
     
    17711969// ====================================================================================================================
    17721970
    1773 
    1774 /** Parse PCM alignment zero bits.
    1775 * \returns Void
    1776 */
    1777 Void TDecCavlc::xReadPCMAlignZero( )
    1778 {
    1779   UInt uiNumberOfBits = m_pcBitstream->getNumBitsUntilByteAligned();
    1780 
    1781   if(uiNumberOfBits)
    1782   {
    1783     UInt uiBits;
    1784     UInt uiSymbol;
    1785 
    1786     for(uiBits = 0; uiBits < uiNumberOfBits; uiBits++)
    1787     {
    1788       xReadFlag( uiSymbol );
    1789       assert( uiSymbol == 0 );
    1790     }
    1791   }
    1792 }
    1793 
    1794 Void TDecCavlc::xReadUnaryMaxSymbol( UInt& ruiSymbol, UInt uiMaxSymbol )
    1795 {
    1796   if (uiMaxSymbol == 0)
    1797   {
    1798     ruiSymbol = 0;
    1799     return;
    1800   }
    1801 
    1802   xReadFlag( ruiSymbol );
    1803 
    1804   if (ruiSymbol == 0 || uiMaxSymbol == 1)
    1805   {
    1806     return;
    1807   }
    1808 
    1809   UInt uiSymbol = 0;
    1810   UInt uiCont;
    1811 
    1812   do
    1813   {
    1814     xReadFlag( uiCont );
    1815     uiSymbol++;
    1816   }
    1817   while( uiCont && (uiSymbol < uiMaxSymbol-1) );
    1818 
    1819   if( uiCont && (uiSymbol == uiMaxSymbol-1) )
    1820   {
    1821     uiSymbol++;
    1822   }
    1823 
    1824   ruiSymbol = uiSymbol;
    1825 }
    1826 
    1827 Void TDecCavlc::xReadExGolombLevel( UInt& ruiSymbol )
    1828 {
    1829   UInt uiSymbol ;
    1830   UInt uiCount = 0;
    1831   do
    1832   {
    1833     xReadFlag( uiSymbol );
    1834     uiCount++;
    1835   }
    1836   while( uiSymbol && (uiCount != 13));
    1837 
    1838   ruiSymbol = uiCount-1;
    1839 
    1840   if( uiSymbol )
    1841   {
    1842     xReadEpExGolomb( uiSymbol, 0 );
    1843     ruiSymbol += uiSymbol+1;
    1844   }
    1845 
    1846   return;
    1847 }
    1848 
    1849 Void TDecCavlc::xReadEpExGolomb( UInt& ruiSymbol, UInt uiCount )
    1850 {
    1851   UInt uiSymbol = 0;
    1852   UInt uiBit = 1;
    1853 
    1854 
    1855   while( uiBit )
    1856   {
    1857     xReadFlag( uiBit );
    1858     uiSymbol += uiBit << uiCount++;
    1859   }
    1860 
    1861   uiCount--;
    1862   while( uiCount-- )
    1863   {
    1864     xReadFlag( uiBit );
    1865     uiSymbol += uiBit << uiCount;
    1866   }
    1867 
    1868   ruiSymbol = uiSymbol;
    1869 
    1870   return;
    1871 }
    1872 
    1873 UInt TDecCavlc::xGetBit()
    1874 {
    1875   UInt ruiCode;
    1876   m_pcBitstream->read( 1, ruiCode );
    1877   return ruiCode;
    1878 }
    1879 
    1880 
    18811971/** parse explicit wp tables
    18821972* \param TComSlice* pcSlice
     
    18951985  // decode delta_luma_log2_weight_denom :
    18961986  READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" );     // ue(v): luma_log2_weight_denom
     1987  assert( uiLog2WeightDenomLuma <= 7 );
    18971988  if( bChroma )
    18981989  {
    18991990    READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" );     // se(v): delta_chroma_log2_weight_denom
    19001991    assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)>=0);
     1992    assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)<=7);
    19011993    uiLog2WeightDenomChroma = (UInt)(iDeltaDenom + uiLog2WeightDenomLuma);
    19021994  }
     
    19372029        Int iDeltaWeight;
    19382030        READ_SVLC( iDeltaWeight, "delta_luma_weight_lX" );  // se(v): delta_luma_weight_l0[i]
     2031        assert( iDeltaWeight >= -128 );
     2032        assert( iDeltaWeight <=  127 );
    19392033        wp[0].iWeight = (iDeltaWeight + (1<<wp[0].uiLog2WeightDenom));
    19402034        READ_SVLC( wp[0].iOffset, "luma_offset_lX" );       // se(v): luma_offset_l0[i]
     2035        assert( wp[0].iOffset >= -128 );
     2036        assert( wp[0].iOffset <=  127 );
    19412037      }
    19422038      else
     
    19532049            Int iDeltaWeight;
    19542050            READ_SVLC( iDeltaWeight, "delta_chroma_weight_lX" );  // se(v): chroma_weight_l0[i][j]
     2051            assert( iDeltaWeight >= -128 );
     2052            assert( iDeltaWeight <=  127 );
    19552053            wp[j].iWeight = (iDeltaWeight + (1<<wp[1].uiLog2WeightDenom));
    19562054
    19572055            Int iDeltaChroma;
    19582056            READ_SVLC( iDeltaChroma, "delta_chroma_offset_lX" );  // se(v): delta_chroma_offset_l0[i][j]
     2057            assert( iDeltaChroma >= -512 );
     2058            assert( iDeltaChroma <=  511 );
    19592059            Int pred = ( 128 - ( ( 128*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) );
    19602060            wp[j].iOffset = Clip3(-128, 127, (iDeltaChroma + pred) );
  • trunk/source/Lib/TLibDecoder/TDecCAVLC.h

    r125 r189  
    6161 
    6262protected:
    63   Void  xReadEpExGolomb       ( UInt& ruiSymbol, UInt uiCount );
    64   Void  xReadExGolombLevel    ( UInt& ruiSymbol );
    65   Void  xReadUnaryMaxSymbol   ( UInt& ruiSymbol, UInt uiMaxSymbol );
    66  
    67   Void  xReadPCMAlignZero     ();
    68 
    69   UInt  xGetBit             ();
    70  
    7163  void  parseShortTermRefPicSet            (TComSPS* pcSPS, TComReferencePictureSet* pcRPS, Int idx);
    72 private:
    7364 
    7465public:
  • trunk/source/Lib/TLibDecoder/TDecCu.cpp

    r125 r189  
    370370  m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]);
    371371#endif
    372  
     372
    373373  // Coefficient decoding
    374374  Bool bCodeDQP = getdQPFlag();
  • trunk/source/Lib/TLibDecoder/TDecGop.cpp

    r125 r189  
    247247    for (Int iRefIndex = 0; iRefIndex < pcSlice->getNumRefIdx(RefPicList(iRefList)); iRefIndex++)
    248248    {
     249#if REF_IDX_FRAMEWORK && VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE
     250      if( pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->isILR( m_layerId ) )
     251      {
     252        printf( "%d(%d) ", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex), pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->getLayerId() );
     253      }
     254      else
     255#endif
    249256      printf ("%d ", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex));
    250257    }
  • trunk/source/Lib/TLibDecoder/TDecSlice.h

    r125 r189  
    9191  Void      initCtxMem(  UInt i );
    9292  Void      setCtxMem( TDecSbac* sb, Int b )   { CTXMem[b] = sb; }
     93  Int       getCtxMemSize( )                   { return (Int)CTXMem.size(); }
    9394#if SVC_EXTENSION
    9495  TDecTop*  getLayerDec   ( UInt LayerId )  { return m_ppcTDecTop[LayerId]; } 
  • trunk/source/Lib/TLibDecoder/TDecTop.cpp

    r125 r189  
    113113    if(m_cIlpPic[i])
    114114    {
    115       //m_cIlpPic[i]->setPicYuvRec(NULL);
    116115      m_cIlpPic[i]->destroy();
    117116      delete m_cIlpPic[i];
     
    143142  if(m_layerId>0)
    144143  {
     144    g_bitDepthY     = pcSPS->getBitDepthY();
     145    g_bitDepthC     = pcSPS->getBitDepthC();
     146    g_uiMaxCUWidth  = pcSPS->getMaxCUWidth();
     147    g_uiMaxCUHeight = pcSPS->getMaxCUHeight();
     148    g_uiMaxCUDepth  = pcSPS->getMaxCUDepth();
     149    g_uiAddCUDepth  = max (0, pcSPS->getLog2MinCodingBlockSize() - (Int)pcSPS->getQuadtreeTULog2MinSize() );
     150
    145151    Int  numReorderPics[MAX_TLAYER];
    146152    Window &conformanceWindow = pcSPS->getConformanceWindow();
     
    154160    if (m_cIlpPic[0] == NULL)
    155161    {
    156       for (Int j=0; j<1/*MAX_NUM_REF*/; j++)
    157       {
     162      for (Int j=0; j< 1/*MAX_NUM_REF*/; j++)  // to be set to NumDirectRefLayers[LayerIdInVps[nuh_layer_id]]
     163      {
     164
    158165        m_cIlpPic[j] = new  TComPic;
    159         //m_cIlpPic[j]->createWithOutYuv(m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, &m_cSPS, true);
    160166#if SVC_UPSAMPLING
    161167        m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true);
     
    176182  if(m_cIlpPic[0])
    177183  {
    178     //m_cIlpPic[0]->setPicYuvRec(pcPic->getFullPelBaseRec());
    179184    m_cIlpPic[0]->copyUpsampledPictureYuv(pcPic->getFullPelBaseRec(), m_cIlpPic[0]->getPicYuvRec());
    180185    m_cIlpPic[0]->getSlice(0)->setPOC(pcPic->getPOC());
    181     m_cIlpPic[0]->setLayerId(0); //set reference layerId
     186    m_cIlpPic[0]->setLayerId(pcPic->getSlice(0)->getBaseColPic()->getLayerId()); //set reference layerId
    182187    m_cIlpPic[0]->getPicYuvRec()->setBorderExtension(false);
    183188    m_cIlpPic[0]->getPicYuvRec()->extendPicBorder();
     
    231236  }
    232237
     238#if L0323_DPB
     239  m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer())+pcSlice->getSPS()->getNumReorderPics(pcSlice->getTLayer());     // m_uiMaxDecPicBuffering has the space for the picture currently being decoded
     240#else
    233241  m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer())+pcSlice->getSPS()->getNumReorderPics(pcSlice->getTLayer()) + 1; // +1 to have space for the picture currently being decoded
     242#endif
    234243  if (m_cListPic.size() < (UInt)m_iMaxRefPicNum)
    235244  {
     
    239248    if(m_layerId > 0)
    240249    {
     250#if VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE
     251      TDecTop *pcTDecTopBase = (TDecTop *)getRefLayerDec( m_layerId );
     252#else
    241253      TDecTop *pcTDecTopBase = (TDecTop *)getLayerDec( m_layerId-1 );
     254#endif
    242255      //TComPic*                      pcPic = *(pcTDecTopBase->getListPic()->begin());
    243256      TComPicYuv* pcPicYuvRecBase = (*(pcTDecTopBase->getListPic()->begin()))->getPicYuvRec();
     
    339352  cFillSlice.setSPS( m_parameterSetManagerDecoder[m_layerId].getFirstSPS() );
    340353  cFillSlice.setPPS( m_parameterSetManagerDecoder[m_layerId].getFirstPPS() );
     354  cFillSlice.setVPS( m_parameterSetManagerDecoder[m_layerId].getFirstVPS() );
    341355  cFillSlice.initSlice( m_layerId );
    342356#else
     
    350364  cFillPic->getSlice(0)->setSPS( m_parameterSetManagerDecoder[m_layerId].getFirstSPS() );
    351365  cFillPic->getSlice(0)->setPPS( m_parameterSetManagerDecoder[m_layerId].getFirstPPS() );
     366  cFillPic->getSlice(0)->setVPS( m_parameterSetManagerDecoder[m_layerId].getFirstVPS() );
    352367  cFillPic->getSlice(0)->initSlice( m_layerId );
    353368#else
     
    405420  assert (sps != 0);
    406421
    407   if( false == m_parameterSetManagerDecoder[m_layerId].activatePPS(m_apcSlicePilot->getPPSId(), m_apcSlicePilot->getIdrPicFlag()) )
     422  if( false == m_parameterSetManagerDecoder[m_layerId].activatePPS(m_apcSlicePilot->getPPSId(), m_apcSlicePilot->isIRAP()) )
    408423#else
    409424  m_parameterSetManagerDecoder.applyPrefetchedPS();
     
    415430  assert (sps != 0);
    416431
    417   if (false == m_parameterSetManagerDecoder.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->getIdrPicFlag()))
     432  if (false == m_parameterSetManagerDecoder.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP()))
    418433#endif
    419434  {
     
    422437  }
    423438
     439  if( pps->getDependentSliceSegmentsEnabledFlag() )
     440  {
     441    Int NumCtx = pps->getEntropyCodingSyncEnabledFlag()?2:1;
     442
     443    if (m_cSliceDecoder.getCtxMemSize() != NumCtx)
     444    {
     445      m_cSliceDecoder.initCtxMem(NumCtx);
     446      for ( UInt st = 0; st < NumCtx; st++ )
     447      {
     448        TDecSbac* ctx = NULL;
     449        ctx = new TDecSbac;
     450        ctx->init( &m_cBinCABAC );
     451        m_cSliceDecoder.setCtxMem( ctx, st );
     452      }
     453    }
     454  }
     455
    424456  m_apcSlicePilot->setPPS(pps);
    425457  m_apcSlicePilot->setSPS(sps);
     458
    426459  pps->setSPS(sps);
    427460  pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumColumnsMinus1() + 1) : 1);
    428461  pps->setMinCuDQPSize( sps->getMaxCUWidth() >> ( pps->getMaxCuDQPDepth()) );
    429462
    430   for (Int i = 0; i < sps->getMaxCUDepth() - g_uiAddCUDepth; i++)
     463  g_bitDepthY     = sps->getBitDepthY();
     464  g_bitDepthC     = sps->getBitDepthC();
     465  g_uiMaxCUWidth  = sps->getMaxCUWidth();
     466  g_uiMaxCUHeight = sps->getMaxCUHeight();
     467  g_uiMaxCUDepth  = sps->getMaxCUDepth();
     468  g_uiAddCUDepth  = max (0, sps->getLog2MinCodingBlockSize() - (Int)sps->getQuadtreeTULog2MinSize() );
     469
     470  for (Int i = 0; i < sps->getLog2DiffMaxMinCodingBlockSize(); i++)
    431471  {
    432472    sps->setAMPAcc( i, sps->getUseAMP() );
    433473  }
    434474
    435   for (Int i = sps->getMaxCUDepth() - g_uiAddCUDepth; i < sps->getMaxCUDepth(); i++)
     475  for (Int i = sps->getLog2DiffMaxMinCodingBlockSize(); i < sps->getMaxCUDepth(); i++)
    436476  {
    437477    sps->setAMPAcc( i, 0 );
     
    439479
    440480  m_cSAO.destroy();
    441   m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight );
    442   m_cLoopFilter.        create( g_uiMaxCUDepth );
     481  m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight() );
     482  m_cLoopFilter.create( sps->getMaxCUDepth() );
    443483}
    444484
     
    451491  TComPic*&   pcPic         = m_pcPic;
    452492#if SVC_EXTENSION
     493  m_apcSlicePilot->setVPS( m_parameterSetManagerDecoder[m_layerId].getPrefetchedVPS(0) );
    453494  m_apcSlicePilot->initSlice( nalu.m_layerId );
    454495#else
     
    467508
    468509  m_apcSlicePilot->setNalUnitType(nalu.m_nalUnitType);
    469   if((m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N) ||
    470      (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N) ||
    471      (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N))
    472   {
    473     m_apcSlicePilot->setTemporalLayerNonReferenceFlag(true);
    474   }
     510  Bool nonReferenceFlag = (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N ||
     511                           m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N   ||
     512                           m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N  ||
     513                           m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N  ||
     514                           m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N);
     515  m_apcSlicePilot->setTemporalLayerNonReferenceFlag(nonReferenceFlag);
     516 
    475517  m_apcSlicePilot->setReferenced(true); // Putting this as true ensures that picture is referenced the first time it is in an RPS
    476518  m_apcSlicePilot->setTLayerInfo(nalu.m_temporalId);
     
    481523  m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder);
    482524#endif
    483   if (m_apcSlicePilot->isNextSlice())
    484   {
    485     // Skip pictures due to random access
    486     if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay))
    487     {
    488       return false;
    489     }
    490     // Skip TFD pictures associated with BLA/BLANT pictures
    491     if (isSkipPictureForBLA(iPOCLastDisplay))
    492     {
    493       return false;
    494     }
    495   }
     525
     526  // Skip pictures due to random access
     527  if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay))
     528  {
     529    return false;
     530  }
     531  // Skip TFD pictures associated with BLA/BLANT pictures
     532  if (isSkipPictureForBLA(iPOCLastDisplay))
     533  {
     534    return false;
     535  }
    496536
    497537  // exit when a new picture is found
     
    506546  }
    507547#else
    508   if (m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence)
     548  //we should only get a different poc for a new picture (with CTU address==0)
     549  if (m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence && (!m_apcSlicePilot->getSliceCurStartCUAddr()==0))
     550  {
     551    printf ("Warning, the first slice of a picture might have been lost!\n");
     552  }
     553  // exit when a new picture is found
     554  if (m_apcSlicePilot->isNextSlice() && (m_apcSlicePilot->getSliceCurStartCUAddr() == 0 && !m_bFirstSliceInPicture) && !m_bFirstSliceInSequence )
    509555  {
    510556    if (m_prevPOC >= m_pocRandomAccess)
     
    537583  {
    538584#if AVC_BASE
    539   if( m_layerId == 1 )
    540   {
    541     TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin());
    542     fstream* pFile  = m_ppcTDecTop[0]->getBLReconFile();
    543     const Window &conf = pBLPic->getConformanceWindow();
    544     UInt uiWidth    = pBLPic->getPicYuvRec()->getWidth() - conf.getWindowLeftOffset() - conf.getWindowRightOffset();
    545     UInt uiHeight   = pBLPic->getPicYuvRec()->getHeight() - conf.getWindowTopOffset() - conf.getWindowBottomOffset();
    546        
    547     if( pFile->good() )
    548     {
    549       UInt64 uiPos = (UInt64) m_apcSlicePilot->getPOC() * uiWidth * uiHeight * 3 / 2;
    550 
    551       pFile->seekg((UInt)uiPos, ios::beg );
    552 
    553       Pel* pPel = pBLPic->getPicYuvRec()->getLumaAddr();
    554       UInt uiStride = pBLPic->getPicYuvRec()->getStride();
    555       for( Int i = 0; i < uiHeight; i++ )
    556       {
    557         for( Int j = 0; j < uiWidth; j++ )
     585    if( m_layerId == 1 && m_parameterSetManagerDecoder[0].getPrefetchedVPS(0)->getAvcBaseLayerFlag() )
     586    {
     587      TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin());
     588      fstream* pFile  = m_ppcTDecTop[0]->getBLReconFile();
     589#if ILP_DECODED_PICTURE
     590      UInt uiWidth    = pBLPic->getPicYuvRec()->getWidth();
     591      UInt uiHeight   = pBLPic->getPicYuvRec()->getHeight();
     592#else
     593      const Window &conf = pBLPic->getConformanceWindow();
     594      UInt uiWidth    = pBLPic->getPicYuvRec()->getWidth() - conf.getWindowLeftOffset() - conf.getWindowRightOffset();
     595      UInt uiHeight   = pBLPic->getPicYuvRec()->getHeight() - conf.getWindowTopOffset() - conf.getWindowBottomOffset();
     596#endif
     597
     598      if( pFile->good() )
     599      {
     600        UInt64 uiPos = (UInt64) m_apcSlicePilot->getPOC() * uiWidth * uiHeight * 3 / 2;
     601
     602        pFile->seekg((UInt)uiPos, ios::beg );
     603
     604        Pel* pPel = pBLPic->getPicYuvRec()->getLumaAddr();
     605        UInt uiStride = pBLPic->getPicYuvRec()->getStride();
     606        for( Int i = 0; i < uiHeight; i++ )
    558607        {
    559           pPel[j] = pFile->get();
     608          for( Int j = 0; j < uiWidth; j++ )
     609          {
     610            pPel[j] = pFile->get();
     611          }
     612          pPel += uiStride;
    560613        }
    561         pPel += uiStride;
    562       }
    563 
    564       pPel = pBLPic->getPicYuvRec()->getCbAddr();
    565       uiStride = pBLPic->getPicYuvRec()->getCStride();
    566       for( Int i = 0; i < uiHeight/2; i++ )
    567       {
    568         for( Int j = 0; j < uiWidth/2; j++ )
     614
     615        pPel = pBLPic->getPicYuvRec()->getCbAddr();
     616        uiStride = pBLPic->getPicYuvRec()->getCStride();
     617        for( Int i = 0; i < uiHeight/2; i++ )
    569618        {
    570           pPel[j] = pFile->get();
     619          for( Int j = 0; j < uiWidth/2; j++ )
     620          {
     621            pPel[j] = pFile->get();
     622          }
     623          pPel += uiStride;
    571624        }
    572         pPel += uiStride;
    573       }
    574 
    575       pPel = pBLPic->getPicYuvRec()->getCrAddr();
    576       uiStride = pBLPic->getPicYuvRec()->getCStride();
    577       for( Int i = 0; i < uiHeight/2; i++ )
    578       {
    579         for( Int j = 0; j < uiWidth/2; j++ )
     625
     626        pPel = pBLPic->getPicYuvRec()->getCrAddr();
     627        uiStride = pBLPic->getPicYuvRec()->getCStride();
     628        for( Int i = 0; i < uiHeight/2; i++ )
    580629        {
    581           pPel[j] = pFile->get();
     630          for( Int j = 0; j < uiWidth/2; j++ )
     631          {
     632            pPel[j] = pFile->get();
     633          }
     634          pPel += uiStride;
    582635        }
    583         pPel += uiStride;
    584       }
    585     }
    586   }
     636      }
     637    }
    587638#endif
    588639
     
    732783  if (bNextSlice)
    733784  {
    734     pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_prevRAPisBLA );
     785    pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_prevRAPisBLA, m_cListPic );
    735786    // Set reference list
    736 #if REF_LIST_BUGFIX
     787#if REF_IDX_FRAMEWORK
    737788    if (m_layerId == 0)
    738     {
    739       pcSlice->setRefPicList( m_cListPic );
    740     }
     789#endif
     790#if FIX1071
     791    pcSlice->setRefPicList( m_cListPic, true );
    741792#else
    742793    pcSlice->setRefPicList( m_cListPic );
     
    747798    {
    748799#if AVC_BASE
    749       pcSlice->setBaseColPic ( *m_ppcTDecTop[0]->getListPic()->begin() );
     800      if( m_parameterSetManagerDecoder[0].getActiveVPS()->getAvcBaseLayerFlag() )
     801      {
     802        pcSlice->setBaseColPic ( *m_ppcTDecTop[0]->getListPic()->begin() );
    750803#if AVC_SYNTAX
    751       TComPic* pBLPic = pcSlice->getBaseColPic();
    752       if( pcSlice->getPOC() == 0 )
    753       {
    754         // initialize partition order.
    755         UInt* piTmp = &g_auiZscanToRaster[0];
    756         initZscanToRaster( pBLPic->getPicSym()->getMaxDepth() + 1, 1, 0, piTmp );
    757         initRasterToZscan( pBLPic->getPicSym()->getMaxCUWidth(), pBLPic->getPicSym()->getMaxCUHeight(), pBLPic->getPicSym()->getMaxDepth() + 1 );
    758       }     
    759       pBLPic->getSlice( 0 )->initBaseLayerRPL( pcSlice );
    760       pBLPic->readBLSyntax( m_ppcTDecTop[0]->getBLSyntaxFile(), SYNTAX_BYTES );
    761 #endif
    762 
     804        TComPic* pBLPic = pcSlice->getBaseColPic();
     805        if( pcSlice->getPOC() == 0 )
     806        {
     807          // initialize partition order.
     808          UInt* piTmp = &g_auiZscanToRaster[0];
     809          initZscanToRaster( pBLPic->getPicSym()->getMaxDepth() + 1, 1, 0, piTmp );
     810          initRasterToZscan( pBLPic->getPicSym()->getMaxCUWidth(), pBLPic->getPicSym()->getMaxCUHeight(), pBLPic->getPicSym()->getMaxDepth() + 1 );
     811        }     
     812        pBLPic->getSlice( 0 )->initBaseLayerRPL( pcSlice );
     813        pBLPic->readBLSyntax( m_ppcTDecTop[0]->getBLSyntaxFile(), SYNTAX_BYTES );
     814#endif
     815      }
     816      else
     817      {
     818#if VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE
     819        TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( m_layerId );
     820#else
     821        TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 );
     822#endif
     823        TComList<TComPic*> *cListPic = pcTDecTop->getListPic();
     824        pcSlice->setBaseColPic ( *cListPic, m_layerId );
     825      }
     826#else
     827#if VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE
     828      TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( m_layerId );
    763829#else
    764830      TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 );
     831#endif
    765832      TComList<TComPic*> *cListPic = pcTDecTop->getListPic();
    766833      pcSlice->setBaseColPic ( *cListPic, m_layerId );
     
    769836      if ( pcPic->isSpatialEnhLayer())
    770837      {   
     838#if SCALED_REF_LAYER_OFFSETS
     839        m_cPrediction.upsampleBasePic( pcPic->getFullPelBaseRec(), pcSlice->getBaseColPic()->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow() );
     840#else
    771841        m_cPrediction.upsampleBasePic( pcPic->getFullPelBaseRec(), pcSlice->getBaseColPic()->getPicYuvRec(), pcPic->getPicYuvRec() );
     842#endif
    772843      }
    773844      else
     
    778849#endif
    779850    }
    780 #endif
    781851
    782852#if REF_IDX_FRAMEWORK
     
    785855      setILRPic(pcPic);
    786856#if REF_IDX_MFM
    787       pcSlice->setRefPOCListILP(m_ppcTDecTop[m_layerId]->m_cIlpPic, pcSlice->getBaseColPic());
    788 #endif
    789 #if REF_LIST_BUGFIX
    790       pcSlice->setRefPicListSvc( m_cListPic, m_cIlpPic);
    791 #else
    792       pcSlice->addRefPicList ( m_cIlpPic,
    793                                1,
    794                                ((pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA) &&
    795                                 (pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA)) ? 0: -1);
    796 #endif
    797     }
    798 #endif
     857      if( pcSlice->getSPS()->getMFMEnabledFlag() )
     858      {
     859        pcSlice->setRefPOCListILP(m_ppcTDecTop[m_layerId]->m_cIlpPic, pcSlice->getBaseColPic());
     860      }
     861#endif
     862      pcSlice->setRefPicList( m_cListPic, false, m_cIlpPic);
     863    }
     864#endif
     865
     866#endif //SVC_EXTENSION
    799867
    800868    // For generalized B
     
    839907    //---------------
    840908    pcSlice->setRefPOCList();
     909#if !L0034_COMBINED_LIST_CLEANUP
    841910    pcSlice->setNoBackPredFlag( false );
    842911    if ( pcSlice->getSliceType() == B_SLICE )
     
    855924      }
    856925    }
     926#endif
    857927  }
    858928
     
    878948    m_cTrQuant.setUseScalingList(false);
    879949  }
     950
     951#if SIMPLIFIED_MV_POS_SCALING
     952  if (m_layerId > 0)
     953  {
     954#if SCALED_REF_LAYER_OFFSETS
     955    const Window &scalEL = pcSlice->getSPS()->getScaledRefLayerWindow();
     956
     957    Int widthBL   = pcSlice->getBaseColPic()->getPicYuvRec()->getWidth();
     958    Int heightBL  = pcSlice->getBaseColPic()->getPicYuvRec()->getHeight();
     959
     960    Int widthEL   = pcPic->getPicYuvRec()->getWidth()  - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();
     961    Int heightEL  = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
     962#else
     963    const Window &confBL = pcSlice->getBaseColPic()->getPicYuvRec()->getConformanceWindow();
     964    const Window &confEL = pcPic->getPicYuvRec()->getConformanceWindow();
     965
     966    Int widthBL   = pcSlice->getBaseColPic()->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset();
     967    Int heightBL  = pcSlice->getBaseColPic()->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset();
     968
     969    Int widthEL   = pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset();
     970    Int heightEL  = pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
     971#endif
     972    g_mvScalingFactor[m_layerId][0] = Clip3(-4096, 4095, ((widthEL  << 8) + (widthBL  >> 1)) / widthBL);
     973    g_mvScalingFactor[m_layerId][1] = Clip3(-4096, 4095, ((heightEL << 8) + (heightBL >> 1)) / heightBL);
     974
     975    g_posScalingFactor[m_layerId][0] = ((widthBL  << 16) + (widthEL  >> 1)) / widthEL;
     976    g_posScalingFactor[m_layerId][1] = ((heightBL << 16) + (heightEL >> 1)) / heightEL;
     977  }
     978#endif
    880979
    881980  //  Decode a picture
     
    9471046{
    9481047#if SVC_EXTENSION
    949   if(nalUnitType == NAL_UNIT_SEI_SUFFIX)
     1048  if(nalUnitType == NAL_UNIT_SUFFIX_SEI)
    9501049  {
    9511050    m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder[m_layerId].getActiveSPS() );
     
    9671066  }
    9681067#else
    969   if(nalUnitType == NAL_UNIT_SEI_SUFFIX)
     1068  if(nalUnitType == NAL_UNIT_SUFFIX_SEI)
    9701069  {
    9711070    m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() );
     
    10031102    case NAL_UNIT_VPS:
    10041103      xDecodeVPS();
     1104#if AVC_BASE
     1105      if( m_parameterSetManagerDecoder[0].getPrefetchedVPS(0)->getAvcBaseLayerFlag() )
     1106      {
     1107        if( !m_ppcTDecTop[0]->getBLReconFile()->good() )
     1108        {
     1109          printf( "Base layer YUV input reading error\n" );
     1110          exit(EXIT_FAILURE);
     1111        }       
     1112#if AVC_SYNTAX
     1113        if( !m_ppcTDecTop[0]->getBLSyntaxFile()->good() )
     1114        {
     1115          printf( "Base layer syntax input reading error\n" );
     1116          exit(EXIT_FAILURE);
     1117        }
     1118#endif
     1119      }
     1120      else
     1121      {
     1122        TComList<TComPic*> *cListPic = m_ppcTDecTop[0]->getListPic();
     1123        cListPic->clear();
     1124      }
     1125#endif
    10051126      return false;
    10061127     
     
    10081129      xDecodeSPS();
    10091130#if AVC_BASE
     1131      if( m_parameterSetManagerDecoder[0].getPrefetchedVPS(0)->getAvcBaseLayerFlag() )
    10101132      {
    10111133        TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin());
     
    10191141#if AVC_SYNTAX
    10201142
    1021           pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, sps, true);
    1022 #else
    1023           pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, NULL, true);
    1024 #endif
    1025 #else
    1026           pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, onformanceWindow, defaultDisplayWindow, numReorderPics, true);
     1143          pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, sps, true);
     1144#else
     1145          pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, NULL, true);
     1146#endif
     1147#else
     1148          pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), onformanceWindow, defaultDisplayWindow, numReorderPics, true);
    10271149#endif
    10281150        }
     
    10351157      return false;
    10361158     
    1037     case NAL_UNIT_SEI:
    1038     case NAL_UNIT_SEI_SUFFIX:
     1159    case NAL_UNIT_PREFIX_SEI:
     1160    case NAL_UNIT_SUFFIX_SEI:
    10391161      xDecodeSEI( nalu.m_Bitstream, nalu.m_nalUnitType );
    10401162      return false;
     
    10421164    case NAL_UNIT_CODED_SLICE_TRAIL_R:
    10431165    case NAL_UNIT_CODED_SLICE_TRAIL_N:
    1044     case NAL_UNIT_CODED_SLICE_TLA:
     1166    case NAL_UNIT_CODED_SLICE_TLA_R:
    10451167    case NAL_UNIT_CODED_SLICE_TSA_N:
    10461168    case NAL_UNIT_CODED_SLICE_STSA_R:
    10471169    case NAL_UNIT_CODED_SLICE_STSA_N:
    1048     case NAL_UNIT_CODED_SLICE_BLA:
    1049     case NAL_UNIT_CODED_SLICE_BLANT:
     1170    case NAL_UNIT_CODED_SLICE_BLA_W_LP:
     1171    case NAL_UNIT_CODED_SLICE_BLA_W_RADL:
    10501172    case NAL_UNIT_CODED_SLICE_BLA_N_LP:
    1051     case NAL_UNIT_CODED_SLICE_IDR:
     1173    case NAL_UNIT_CODED_SLICE_IDR_W_RADL:
    10521174    case NAL_UNIT_CODED_SLICE_IDR_N_LP:
    10531175    case NAL_UNIT_CODED_SLICE_CRA:
    10541176    case NAL_UNIT_CODED_SLICE_RADL_N:
    1055     case NAL_UNIT_CODED_SLICE_DLP:
     1177    case NAL_UNIT_CODED_SLICE_RADL_R:
    10561178    case NAL_UNIT_CODED_SLICE_RASL_N:
    1057     case NAL_UNIT_CODED_SLICE_TFD:
     1179    case NAL_UNIT_CODED_SLICE_RASL_R:
    10581180#if SVC_EXTENSION
    10591181      return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay, curLayerId, bNewPOC);
     
    10771199Bool TDecTop::isSkipPictureForBLA(Int& iPOCLastDisplay)
    10781200{
    1079   if (m_prevRAPisBLA && m_apcSlicePilot->getPOC() < m_pocCRA && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TFD || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N))
     1201  if (m_prevRAPisBLA && m_apcSlicePilot->getPOC() < m_pocCRA && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N))
    10801202  {
    10811203    iPOCLastDisplay++;
     
    11081230  {
    11091231    if (   m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA
    1110         || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA
     1232        || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
    11111233        || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP
    1112         || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT )
     1234        || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL )
    11131235    {
    11141236      // set the POC random access since we need to skip the reordered pictures in the case of CRA/CRANT/BLA/BLANT.
    11151237      m_pocRandomAccess = m_apcSlicePilot->getPOC();
    11161238    }
    1117     else if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP )
     1239    else if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP )
    11181240    {
    11191241      m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable.
     
    11311253  }
    11321254  // skip the reordered pictures, if necessary
    1133   else if (m_apcSlicePilot->getPOC() < m_pocRandomAccess && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TFD || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N))
     1255  else if (m_apcSlicePilot->getPOC() < m_pocRandomAccess && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N))
    11341256  {
    11351257    iPOCLastDisplay++;
     
    11401262}
    11411263
     1264#if VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE
     1265TDecTop* TDecTop::getRefLayerDec( UInt layerId )
     1266{
     1267  TComVPS* vps = m_parameterSetManagerDecoder[0].getActiveVPS();
     1268  if( vps->getNumDirectRefLayers( m_layerId ) <= 0 )
     1269  {
     1270#if ZERO_NUM_DIRECT_LAYERS
     1271    return (TDecTop *)getLayerDec( 0 );
     1272#else
     1273    return NULL;
     1274#endif
     1275  }
     1276
     1277  // currently only one reference layer is supported
     1278  assert( vps->getNumDirectRefLayers( m_layerId ) == 1 );
     1279#if JCTVC_M0458_INTERLAYER_RPS_SIG
     1280  assert( vps->getMaxOneActiveRefLayerFlag() == 1 );
     1281#endif
     1282 
     1283  return (TDecTop *)getLayerDec( vps->getRefLayerId( m_layerId, 0 ) );
     1284}
     1285#endif
     1286
    11421287//! \}
  • trunk/source/Lib/TLibDecoder/TDecTop.h

    r125 r189  
    154154  Void      setNumLayer           (UInt uiNum)   { m_numLayer = uiNum;  }
    155155  TComList<TComPic*>*      getListPic() { return &m_cListPic; }
    156   Void                setLayerDec(TDecTop **p)    { m_ppcTDecTop = p; }
    157   TDecTop*            getLayerDec(UInt layer)   { return m_ppcTDecTop[layer]; }
     156  Void      setLayerDec(TDecTop **p)    { m_ppcTDecTop = p; }
     157  TDecTop*  getLayerDec(UInt layer)     { return m_ppcTDecTop[layer]; }
     158#if VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE
     159  TDecTop*  getRefLayerDec(UInt layerId);
     160#endif
    158161#if AVC_BASE
    159162  Void      setBLReconFile( fstream* pFile ) { m_pBLReconFile = pFile; }
  • trunk/source/Lib/TLibEncoder/SEIwrite.cpp

    r125 r189  
    8484    fprintf( g_hTrace, "=========== Decoding Unit Information SEI message ===========\n");
    8585    break;
     86#if J0149_TONE_MAPPING_SEI
     87  case SEI::TONE_MAPPING_INFO:
     88    fprintf( g_hTrace, "=========== Tone Mapping Info SEI message ===========\n");
     89    break;
     90#endif
     91#if L0208_SOP_DESCRIPTION_SEI
     92  case SEI::SOP_DESCRIPTION:
     93    fprintf( g_hTrace, "=========== SOP Description SEI message ===========\n");
     94    break;
     95#endif
     96#if K0180_SCALABLE_NESTING_SEI
     97  case SEI::SCALABLE_NESTING:
     98    fprintf( g_hTrace, "=========== Scalable Nesting SEI message ===========\n");
     99    break;
     100#endif
    86101  default:
    87102    fprintf( g_hTrace, "=========== Unknown SEI message ===========\n");
     
    91106#endif
    92107
     108#if K0180_SCALABLE_NESTING_SEI
     109void SEIWriter::xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, TComSPS *sps)
     110#else
    93111void SEIWriter::xWriteSEIpayloadData(const SEI& sei, TComSPS *sps)
     112#endif
    94113{
    95114  switch (sei.payloadType())
     
    128147    xWriteSEIGradualDecodingRefreshInfo(*static_cast<const SEIGradualDecodingRefreshInfo*>(&sei));
    129148    break;
     149#if J0149_TONE_MAPPING_SEI
     150  case SEI::TONE_MAPPING_INFO:
     151    xWriteSEIToneMappingInfo(*static_cast<const SEIToneMappingInfo*>(&sei));
     152    break;
     153#endif
     154#if L0208_SOP_DESCRIPTION_SEI
     155  case SEI::SOP_DESCRIPTION:
     156    xWriteSEISOPDescription(*static_cast<const SEISOPDescription*>(&sei));
     157    break;
     158#endif
     159#if K0180_SCALABLE_NESTING_SEI
     160  case SEI::SCALABLE_NESTING:
     161    xWriteSEIScalableNesting(bs, *static_cast<const SEIScalableNesting*>(&sei), sps);
     162    break;
     163#endif
    130164  default:
    131165    assert(!"Unhandled SEI message");
     
    145179  setBitstream(&bs_count);
    146180
     181
     182#if K0180_SCALABLE_NESTING_SEI
     183
     184#if ENC_DEC_TRACE
     185  Bool traceEnable = g_HLSTraceEnable;
     186  g_HLSTraceEnable = false;
     187#endif
     188  xWriteSEIpayloadData(bs_count, sei, sps);
     189#if ENC_DEC_TRACE
     190  g_HLSTraceEnable = traceEnable;
     191#endif
     192
     193#else
     194
    147195#if ENC_DEC_TRACE
    148196  g_HLSTraceEnable = false;
     
    152200  g_HLSTraceEnable = true;
    153201#endif
     202
     203#endif
     204
    154205  UInt payload_data_num_bits = bs_count.getNumberOfWrittenBits();
    155206  assert(0 == payload_data_num_bits % 8);
     
    158209
    159210#if ENC_DEC_TRACE
     211#if K0180_SCALABLE_NESTING_SEI
     212  if (g_HLSTraceEnable)
     213#endif
    160214  xTraceSEIHeader();
    161215#endif
     
    177231  /* payloadData */
    178232#if ENC_DEC_TRACE
     233#if K0180_SCALABLE_NESTING_SEI
     234  if (g_HLSTraceEnable)
     235#endif
    179236  xTraceSEIMessageType(sei.payloadType());
    180237#endif
    181238
     239#if K0180_SCALABLE_NESTING_SEI
     240  xWriteSEIpayloadData(bs, sei, sps);
     241#else
    182242  xWriteSEIpayloadData(sei, sps);
     243#endif
    183244}
    184245
     
    421482  xWriteByteAlign();
    422483}
     484
     485#if J0149_TONE_MAPPING_SEI
     486Void SEIWriter::xWriteSEIToneMappingInfo(const SEIToneMappingInfo& sei)
     487{
     488  Int i;
     489  WRITE_UVLC( sei.m_toneMapId,                    "tone_map_id" );
     490  WRITE_FLAG( sei.m_toneMapCancelFlag,            "tone_map_cancel_flag" );
     491  if( !sei.m_toneMapCancelFlag )
     492  {
     493    WRITE_FLAG( sei.m_toneMapPersistenceFlag,     "tone_map_persistence_flag" );
     494    WRITE_CODE( sei.m_codedDataBitDepth,    8,    "coded_data_bit_depth" );
     495    WRITE_CODE( sei.m_targetBitDepth,       8,    "target_bit_depth" );
     496    WRITE_UVLC( sei.m_modelId,                    "model_id" );
     497    switch(sei.m_modelId)
     498    {
     499    case 0:
     500      {
     501        WRITE_CODE( sei.m_minValue,  32,        "min_value" );
     502        WRITE_CODE( sei.m_maxValue, 32,         "max_value" );
     503        break;
     504      }
     505    case 1:
     506      {
     507        WRITE_CODE( sei.m_sigmoidMidpoint, 32,  "sigmoid_midpoint" );
     508        WRITE_CODE( sei.m_sigmoidWidth,    32,  "sigmoid_width"    );
     509        break;
     510      }
     511    case 2:
     512      {
     513        UInt num = 1u << sei.m_targetBitDepth;
     514        for(i = 0; i < num; i++)
     515        {
     516          WRITE_CODE( sei.m_startOfCodedInterval[i], (( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3,  "start_of_coded_interval" );
     517        }
     518        break;
     519      }
     520    case 3:
     521      {
     522        WRITE_CODE( sei.m_numPivots, 16,          "num_pivots" );
     523        for(i = 0; i < sei.m_numPivots; i++ )
     524        {
     525          WRITE_CODE( sei.m_codedPivotValue[i], (( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3,       "coded_pivot_value" );
     526          WRITE_CODE( sei.m_targetPivotValue[i], (( sei.m_targetBitDepth + 7 ) >> 3 ) << 3,         "target_pivot_value");
     527        }
     528        break;
     529      }
     530    case 4:
     531      {
     532        WRITE_CODE( sei.m_cameraIsoSpeedIdc,    8,    "camera_iso_speed_idc" );
     533        if( sei.m_cameraIsoSpeedIdc == 255) //Extended_ISO
     534        {
     535          WRITE_CODE( sei.m_cameraIsoSpeedValue,    32,    "camera_iso_speed_value" );
     536        }
     537        WRITE_FLAG( sei.m_exposureCompensationValueSignFlag,           "exposure_compensation_value_sign_flag" );
     538        WRITE_CODE( sei.m_exposureCompensationValueNumerator,     16,  "exposure_compensation_value_numerator" );
     539        WRITE_CODE( sei.m_exposureCompensationValueDenomIdc,      16,  "exposure_compensation_value_denom_idc" );
     540        WRITE_CODE( sei.m_refScreenLuminanceWhite,                32,  "ref_screen_luminance_white" );
     541        WRITE_CODE( sei.m_extendedRangeWhiteLevel,                32,  "extended_range_white_level" );
     542        WRITE_CODE( sei.m_nominalBlackLevelLumaCodeValue,         16,  "nominal_black_level_luma_code_value" );
     543        WRITE_CODE( sei.m_nominalWhiteLevelLumaCodeValue,         16,  "nominal_white_level_luma_code_value" );
     544        WRITE_CODE( sei.m_extendedWhiteLevelLumaCodeValue,        16,  "extended_white_level_luma_code_value" );
     545        break;
     546      }
     547    default:
     548      {
     549        assert(!"Undefined SEIToneMapModelId");
     550        break;
     551      }
     552    }//switch m_modelId
     553  }//if(!sei.m_toneMapCancelFlag)
     554
     555  xWriteByteAlign();
     556}
     557#endif
     558
    423559Void SEIWriter::xWriteSEIDisplayOrientation(const SEIDisplayOrientation &sei)
    424560{
     
    455591}
    456592
     593#if L0208_SOP_DESCRIPTION_SEI
     594Void SEIWriter::xWriteSEISOPDescription(const SEISOPDescription& sei)
     595{
     596  WRITE_UVLC( sei.m_sopSeqParameterSetId,           "sop_seq_parameter_set_id"               );
     597  WRITE_UVLC( sei.m_numPicsInSopMinus1,             "num_pics_in_sop_minus1"               );
     598  for (UInt i = 0; i <= sei.m_numPicsInSopMinus1; i++)
     599  {
     600    WRITE_CODE( sei.m_sopDescVclNaluType[i], 6, "sop_desc_vcl_nalu_type" );
     601    WRITE_CODE( sei.m_sopDescTemporalId[i],  3, "sop_desc_temporal_id" );
     602    if (sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_W_RADL && sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_N_LP)
     603    {
     604      WRITE_UVLC( sei.m_sopDescStRpsIdx[i],           "sop_desc_st_rps_idx"               );
     605    }
     606    if (i > 0)
     607    {
     608      WRITE_SVLC( sei.m_sopDescPocDelta[i],           "sop_desc_poc_delta"               );
     609    }
     610  }
     611
     612  xWriteByteAlign();
     613}
     614#endif
     615
     616#if K0180_SCALABLE_NESTING_SEI
     617Void SEIWriter::xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, TComSPS *sps)
     618{
     619  WRITE_FLAG( sei.m_bitStreamSubsetFlag,             "bitstream_subset_flag"         );
     620  WRITE_FLAG( sei.m_nestingOpFlag,                   "nesting_op_flag      "         );
     621  if (sei.m_nestingOpFlag)
     622  {
     623    WRITE_FLAG( sei.m_defaultOpFlag,                 "default_op_flag"               );
     624    WRITE_UVLC( sei.m_nestingNumOpsMinus1,           "nesting_num_ops"               );
     625    for (UInt i = (sei.m_defaultOpFlag ? 1 : 0); i <= sei.m_nestingNumOpsMinus1; i++)
     626    {
     627      WRITE_CODE( sei.m_nestingNoOpMaxTemporalIdPlus1, 3, "nesting_no_op_max_temporal_id" );
     628      WRITE_CODE( sei.m_nestingMaxTemporalIdPlus1[i], 3,  "nesting_max_temporal_id"       );
     629      WRITE_UVLC( sei.m_nestingOpIdx[i],                  "nesting_op_idx"                );
     630    }
     631  }
     632  else
     633  {
     634    WRITE_FLAG( sei.m_allLayersFlag,                      "all_layers_flag"               );
     635    if (!sei.m_allLayersFlag)
     636    {
     637      WRITE_CODE( sei.m_nestingNoOpMaxTemporalIdPlus1, 3, "nesting_no_op_max_temporal_id" );
     638      WRITE_UVLC( sei.m_nestingNumLayersMinus1,           "nesting_num_layers"            );
     639      for (UInt i = 0; i <= sei.m_nestingNumLayersMinus1; i++)
     640      {
     641        WRITE_CODE( sei.m_nestingLayerId[i], 6,           "nesting_layer_id"              );
     642      }
     643    }
     644  }
     645 
     646  // byte alignment
     647  while ( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 )
     648  {
     649    WRITE_FLAG( 0, "nesting_zero_bit" );
     650  }
     651
     652  // write nested SEI messages
     653  for (SEIMessages::const_iterator it = sei.m_nestedSEIs.begin(); it != sei.m_nestedSEIs.end(); it++)
     654  {
     655    writeSEImessage(bs, *(*it), sps);
     656  }
     657}
     658#endif
     659
    457660Void SEIWriter::xWriteByteAlign()
    458661{
  • trunk/source/Lib/TLibEncoder/SEIwrite.h

    r125 r189  
    5050
    5151protected:
     52#if K0180_SCALABLE_NESTING_SEI
     53  Void xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, TComSPS *sps);
     54#else
    5255  Void xWriteSEIpayloadData(const SEI& sei, TComSPS *sps);
     56#endif
    5357  Void xWriteSEIuserDataUnregistered(const SEIuserDataUnregistered &sei);
    5458  Void xWriteSEIActiveParameterSets(const SEIActiveParameterSets& sei);
     
    6367  Void xWriteSEITemporalLevel0Index(const SEITemporalLevel0Index &sei);
    6468  Void xWriteSEIGradualDecodingRefreshInfo(const SEIGradualDecodingRefreshInfo &sei);
     69#if J0149_TONE_MAPPING_SEI
     70  Void xWriteSEIToneMappingInfo(const SEIToneMappingInfo& sei);
     71#endif
     72#if L0208_SOP_DESCRIPTION_SEI
     73  Void xWriteSEISOPDescription(const SEISOPDescription& sei);
     74#endif
     75#if K0180_SCALABLE_NESTING_SEI
     76  Void xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, TComSPS *sps);
     77#endif
    6578  Void xWriteByteAlign();
    6679};
  • trunk/source/Lib/TLibEncoder/TEncCavlc.cpp

    r125 r189  
    3939#include "TEncCavlc.h"
    4040#include "SEIwrite.h"
    41 
     41#include <iostream>
    4242//! \ingroup TLibEncoder
    4343//! \{
     
    285285  WRITE_FLAG(pcVUI->getNeutralChromaIndicationFlag(),           "neutral_chroma_indication_flag");
    286286  WRITE_FLAG(pcVUI->getFieldSeqFlag(),                          "field_seq_flag");
    287   assert(pcVUI->getFieldSeqFlag() == 0);                        // not currently supported
    288287  WRITE_FLAG(pcVUI->getFrameFieldInfoPresentFlag(),             "frame_field_info_present_flag");
    289288
     
    474473  for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++)
    475474  {
     475#if L0323_DPB
     476    WRITE_UVLC( pcSPS->getMaxDecPicBuffering(i) - 1,       "sps_max_dec_pic_buffering_minus1[i]" );
     477#else
    476478    WRITE_UVLC( pcSPS->getMaxDecPicBuffering(i),           "sps_max_dec_pic_buffering[i]" );
     479#endif
    477480    WRITE_UVLC( pcSPS->getNumReorderPics(i),               "sps_num_reorder_pics[i]" );
    478481    WRITE_UVLC( pcSPS->getMaxLatencyIncrease(i),           "sps_max_latency_increase[i]" );
     
    484487  assert( pcSPS->getMaxCUWidth() == pcSPS->getMaxCUHeight() );
    485488 
    486   UInt MinCUSize = pcSPS->getMaxCUWidth() >> ( pcSPS->getMaxCUDepth()-g_uiAddCUDepth );
    487   UInt log2MinCUSize = 0;
    488   while(MinCUSize > 1)
    489   {
    490     MinCUSize >>= 1;
    491     log2MinCUSize++;
    492   }
    493 
    494   WRITE_UVLC( log2MinCUSize - 3,                                                     "log2_min_coding_block_size_minus3" );
    495   WRITE_UVLC( pcSPS->getMaxCUDepth()-g_uiAddCUDepth,                                 "log2_diff_max_min_coding_block_size" );
     489  WRITE_UVLC( pcSPS->getLog2MinCodingBlockSize() - 3,                                "log2_min_coding_block_size_minus3" );
     490  WRITE_UVLC( pcSPS->getLog2DiffMaxMinCodingBlockSize(),                             "log2_diff_max_min_coding_block_size" );
    496491  WRITE_UVLC( pcSPS->getQuadtreeTULog2MinSize() - 2,                                 "log2_min_transform_block_size_minus2" );
    497492  WRITE_UVLC( pcSPS->getQuadtreeTULog2MaxSize() - pcSPS->getQuadtreeTULog2MinSize(), "log2_diff_max_min_transform_block_size" );
     
    558553      codeVUI(pcSPS->getVuiParameters(), pcSPS);
    559554  }
     555#if SCALED_REF_LAYER_OFFSETS
     556  if( pcSPS->getLayerId() > 0 )
     557  {
     558    Window scaledWindow = pcSPS->getScaledRefLayerWindow();
     559    WRITE_SVLC( scaledWindow.getWindowLeftOffset()   >> 1, "scaled_ref_layer_left_offset" );
     560    WRITE_SVLC( scaledWindow.getWindowTopOffset()    >> 1, "scaled_ref_layer_top_offset" );
     561    WRITE_SVLC( scaledWindow.getWindowRightOffset()  >> 1, "scaled_ref_layer_right_offset" );
     562    WRITE_SVLC( scaledWindow.getWindowBottomOffset() >> 1, "scaled_ref_layer_bottom_offset" );
     563  }
     564#endif
    560565
    561566  WRITE_FLAG( 0, "sps_extension_flag" );
     
    583588  for(UInt i=0; i <= pcVPS->getMaxTLayers()-1; i++)
    584589  {
     590#if L0323_DPB
     591    WRITE_UVLC( pcVPS->getMaxDecPicBuffering(i) - 1,       "vps_max_dec_pic_buffering_minus1[i]" );
     592#else
    585593    WRITE_UVLC( pcVPS->getMaxDecPicBuffering(i),           "vps_max_dec_pic_buffering[i]" );
     594#endif
    586595    WRITE_UVLC( pcVPS->getNumReorderPics(i),               "vps_num_reorder_pics[i]" );
    587596    WRITE_UVLC( pcVPS->getMaxLatencyIncrease(i),           "vps_max_latency_increase[i]" );
     
    623632    }
    624633  }
     634#if DERIVE_LAYER_ID_LIST_VARIABLES
     635  pcVPS->deriveLayerIdListVariables();
     636#endif
    625637#if L0043_TIMING_INFO
    626638  TimingInfo *timingInfo = pcVPS->getTimingInfo();
     
    703715  }
    704716#endif
     717#if VPS_MOVE_DIR_DEPENDENCY_FLAG
     718#if VPS_EXTN_DIRECT_REF_LAYERS
     719  for( Int layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++)
     720  {
     721    for( Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++)
     722    {
     723      WRITE_FLAG(vps->getDirectDependencyFlag(layerCtr, refLayerCtr), "direct_dependency_flag[i][j]" );
     724    }
     725  }
     726#endif
     727#endif
    705728#if VPS_EXTN_PROFILE_INFO
    706729  // Profile-tier-level signalling
     730#if VPS_PROFILE_OUTPUT_LAYERS
     731  WRITE_CODE( vps->getNumLayerSets() - 1   , 10, "vps_number_layer_sets_minus1" );     
     732  WRITE_CODE( vps->getNumProfileTierLevel() - 1,  6, "vps_num_profile_tier_level_minus1");
     733  for(Int idx = 1; idx <= vps->getNumProfileTierLevel() - 1; idx++)
     734#else
    707735  for(Int idx = 1; idx <= vps->getNumLayerSets() - 1; idx++)
     736#endif
    708737  {
    709738    WRITE_FLAG( vps->getProfilePresentFlag(idx),       "vps_profile_present_flag[i]" );
    710739    if( !vps->getProfilePresentFlag(idx) )
    711740    {
     741#if VPS_PROFILE_OUTPUT_LAYERS
     742      WRITE_CODE( vps->getProfileLayerSetRef(idx) - 1, 6, "profile_ref_minus1[i]" );
     743#else
    712744      WRITE_UVLC( vps->getProfileLayerSetRef(idx) - 1, "vps_profile_layer_set_ref_minus1[i]" );
     745#endif
    713746    }
    714747    codePTL( vps->getPTLForExtn(idx), vps->getProfilePresentFlag(idx), vps->getMaxTLayers() - 1 );
    715748  }
    716749#endif
     750
     751#if VPS_PROFILE_OUTPUT_LAYERS
     752  Int numOutputLayerSets = vps->getNumOutputLayerSets() ;
     753  WRITE_FLAG(  (numOutputLayerSets > vps->getNumLayerSets()), "more_output_layer_sets_than_default_flag" );
     754  if(numOutputLayerSets > vps->getNumLayerSets())
     755  {
     756    WRITE_CODE( numOutputLayerSets - vps->getNumLayerSets(), 10, "num_add_output_layer_sets" );
     757  }
     758  if( numOutputLayerSets > 1 )
     759  {
     760    WRITE_FLAG( vps->getDefaultOneTargetOutputLayerFlag(), "default_one_target_output_layer_flag" );   
     761  }
     762
     763  for(i = 1; i < numOutputLayerSets; i++)
     764  {
     765    if( i > (vps->getNumLayerSets() - 1) )
     766    {
     767      Int numBits = 1;
     768      while ((1 << numBits) < (vps->getNumLayerSets() - 1))
     769      {
     770        numBits++;
     771      }
     772      WRITE_CODE( vps->getOutputLayerSetIdx(i) - 1, numBits, "output_layer_set_idx_minus1"); 
     773      Int lsIdx = vps->getOutputLayerSetIdx(i);
     774      for(j = 0; j < vps->getNumLayersInIdList(lsIdx) - 1; j++)
     775      {
     776        WRITE_FLAG( vps->getOutputLayerFlag(i,j), "output_layer_flag[i][j]");
     777      }
     778    }
     779    Int numBits = 1;
     780    while ((1 << numBits) < (vps->getNumProfileTierLevel()))
     781    {
     782      numBits++;
     783    }
     784    WRITE_CODE( vps->getProfileLevelTierIdx(i), numBits, "profile_level_tier_idx[i]" );     
     785  }
     786#else
    717787#if VPS_EXTN_OP_LAYER_SETS
    718788  // Target output layer signalling
     
    720790  for(i = 0; i < vps->getNumOutputLayerSets(); i++)
    721791  {
     792#if VPS_OUTPUT_LAYER_SET_IDX
     793    assert(vps->getOutputLayerSetIdx(i) > 0);
     794    WRITE_UVLC( vps->getOutputLayerSetIdx(i) - 1,           "vps_output_layer_set_idx_minus1[i]");
     795#else
    722796    WRITE_UVLC( vps->getOutputLayerSetIdx(i),           "vps_output_layer_set_idx[i]");
     797#endif
    723798    Int lsIdx = vps->getOutputLayerSetIdx(i);
    724799    for(j = 0; j <= vps->getMaxLayerId(); j++)
     
    731806  }
    732807#endif
     808#endif
     809#if JCTVC_M0458_INTERLAYER_RPS_SIG
     810      WRITE_FLAG(vps->getMaxOneActiveRefLayerFlag(), "max_one_active_ref_layer_flag");
     811#endif
     812#if !VPS_MOVE_DIR_DEPENDENCY_FLAG
    733813#if VPS_EXTN_DIRECT_REF_LAYERS
    734814  for( Int layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++)
     
    739819    }
    740820  }
     821#endif
    741822#endif
    742823}
     
    810891      WRITE_CODE( picOrderCntLSB, pcSlice->getSPS()->getBitsForPOC(), "pic_order_cnt_lsb");
    811892      TComReferencePictureSet* rps = pcSlice->getRPS();
     893     
     894#if FIX1071
     895      // Deal with bitstream restriction stating that:
     896      // – If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0.
     897      // Ideally this process should not be repeated for each slice in a picture
     898      TComReferencePictureSet altRps;
     899      Bool useAltRps = false;
     900#if SVC_EXTENSION
     901      if( pcSlice->getLayerId() == 0 )
     902#endif
     903      if (pcSlice->getRapPicFlag())
     904      {
     905        for (Int picIdx = 0; !useAltRps && picIdx < rps->getNumberOfPictures(); picIdx++)
     906        {
     907          useAltRps = rps->getUsed(picIdx);
     908        }
     909        if (useAltRps)
     910        {
     911          memcpy(&altRps, rps, sizeof(TComReferencePictureSet));
     912          rps = &altRps;
     913          for (Int picIdx = 0; picIdx < rps->getNumberOfPictures(); picIdx++)
     914          {
     915            rps->setUsed(picIdx, false);
     916          }
     917        }
     918      }
     919
     920      if(pcSlice->getRPSidx() < 0 || useAltRps)
     921#else
    812922      if(pcSlice->getRPSidx() < 0)
     923#endif
    813924      {
    814925        WRITE_FLAG( 0, "short_term_ref_pic_set_sps_flag");
     
    9021013        }
    9031014      }
     1015
    9041016      if (pcSlice->getSPS()->getTMVPFlagsPresent())
    9051017      {
     
    9071019      }
    9081020    }
     1021
     1022#if JCTVC_M0458_INTERLAYER_RPS_SIG   
     1023    if((pcSlice->getSPS()->getLayerId() > 0)  &&  (pcSlice->getNumILRRefIdx() > 0) )
     1024    {
     1025      WRITE_FLAG(pcSlice->getInterLayerPredEnabledFlag(),"inter_layer_pred_enabled_flag");
     1026      if( pcSlice->getInterLayerPredEnabledFlag())
     1027      {
     1028        if(pcSlice->getNumILRRefIdx() > 1)
     1029        {
     1030          Int numBits = 1;
     1031          while ((1 << numBits) < pcSlice->getNumILRRefIdx())
     1032          {
     1033            numBits++;
     1034          }
     1035          if( !pcSlice->getVPS()->getMaxOneActiveRefLayerFlag())
     1036          {
     1037            WRITE_CODE(pcSlice->getNumInterLayerRefPics(), numBits,"num_inter_layer_ref_pics_minus1");
     1038          }       
     1039          for(Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ )
     1040            WRITE_CODE(pcSlice->getInterLayerPredLayerIdc(i),numBits,"inter_layer_pred_layer_idc[i]");   
     1041        }
     1042      }
     1043    }     
     1044#endif
     1045
    9091046    if(pcSlice->getSPS()->getUseSAO())
    9101047    {
     
    10651202    }
    10661203  }
     1204
    10671205  if(pcSlice->getPPS()->getSliceHeaderExtensionPresentFlag())
    10681206  {
     
    13891527// ====================================================================================================================
    13901528
    1391 
    1392 /** Write PCM alignment bits.
    1393  * \returns Void
    1394  */
    1395 Void  TEncCavlc::xWritePCMAlignZero    ()
    1396 {
    1397   m_pcBitIf->writeAlignZero();
    1398 }
    1399 
    1400 Void TEncCavlc::xWriteUnaryMaxSymbol( UInt uiSymbol, UInt uiMaxSymbol )
    1401 {
    1402   if (uiMaxSymbol == 0)
    1403   {
    1404     return;
    1405   }
    1406   xWriteFlag( uiSymbol ? 1 : 0 );
    1407   if ( uiSymbol == 0 )
    1408   {
    1409     return;
    1410   }
    1411  
    1412   Bool bCodeLast = ( uiMaxSymbol > uiSymbol );
    1413  
    1414   while( --uiSymbol )
    1415   {
    1416     xWriteFlag( 1 );
    1417   }
    1418   if( bCodeLast )
    1419   {
    1420     xWriteFlag( 0 );
    1421   }
    1422   return;
    1423 }
    1424 
    1425 Void TEncCavlc::xWriteExGolombLevel( UInt uiSymbol )
    1426 {
    1427   if( uiSymbol )
    1428   {
    1429     xWriteFlag( 1 );
    1430     UInt uiCount = 0;
    1431     Bool bNoExGo = (uiSymbol < 13);
    1432    
    1433     while( --uiSymbol && ++uiCount < 13 )
    1434     {
    1435       xWriteFlag( 1 );
    1436     }
    1437     if( bNoExGo )
    1438     {
    1439       xWriteFlag( 0 );
    1440     }
    1441     else
    1442     {
    1443       xWriteEpExGolomb( uiSymbol, 0 );
    1444     }
    1445   }
    1446   else
    1447   {
    1448     xWriteFlag( 0 );
    1449   }
    1450   return;
    1451 }
    1452 
    1453 Void TEncCavlc::xWriteEpExGolomb( UInt uiSymbol, UInt uiCount )
    1454 {
    1455   while( uiSymbol >= (UInt)(1<<uiCount) )
    1456   {
    1457     xWriteFlag( 1 );
    1458     uiSymbol -= 1<<uiCount;
    1459     uiCount  ++;
    1460   }
    1461   xWriteFlag( 0 );
    1462   while( uiCount-- )
    1463   {
    1464     xWriteFlag( (uiSymbol>>uiCount) & 1 );
    1465   }
    1466   return;
    1467 }
    1468 
    14691529/** code explicit wp tables
    14701530 * \param TComSlice* pcSlice
  • trunk/source/Lib/TLibEncoder/TEncCavlc.h

    r125 r189  
    6868  TComSlice*    m_pcSlice;
    6969  UInt          m_uiCoeffCost;
    70 
    71   Void  xWritePCMAlignZero    ();
    72   Void  xWriteEpExGolomb      ( UInt uiSymbol, UInt uiCount );
    73   Void  xWriteExGolombLevel    ( UInt uiSymbol );
    74   Void  xWriteUnaryMaxSymbol  ( UInt uiSymbol, UInt uiMaxSymbol );
    7570
    7671  Void codeShortTermRefPicSet              ( TComSPS* pcSPS, TComReferencePictureSet* pcRPS, Bool calledFromSliceHeader, Int idx );
  • trunk/source/Lib/TLibEncoder/TEncCfg.h

    r125 r189  
    158158  Int       m_loopFilterTcOffsetDiv2;
    159159  Bool      m_DeblockingFilterControlPresent;
     160#if L0386_DB_METRIC
     161  Bool      m_DeblockingFilterMetric;
     162#endif
    160163  Bool      m_bUseSAO;
    161164  Int       m_maxNumOffsetsPerPic;
     
    188191  Bool      m_bUseASR;
    189192  Bool      m_bUseHADME;
     193#if !L0034_COMBINED_LIST_CLEANUP
    190194  Bool      m_bUseLComb;
     195#endif
    191196  Bool      m_useRDOQ;
    192197  Bool      m_useRDOQTS;
     
    234239  Int       m_pictureTimingSEIEnabled;
    235240  Int       m_recoveryPointSEIEnabled;
     241#if J0149_TONE_MAPPING_SEI
     242  Bool      m_toneMappingInfoSEIEnabled;
     243  Int       m_toneMapId;
     244  Bool      m_toneMapCancelFlag;
     245  Bool      m_toneMapPersistenceFlag;
     246  Int       m_codedDataBitDepth;
     247  Int       m_targetBitDepth;
     248  Int       m_modelId;
     249  Int       m_minValue;
     250  Int       m_maxValue;
     251  Int       m_sigmoidMidpoint;
     252  Int       m_sigmoidWidth;
     253  Int       m_numPivots;
     254  Int       m_cameraIsoSpeedIdc;
     255  Int       m_cameraIsoSpeedValue;
     256  Int       m_exposureCompensationValueSignFlag;
     257  Int       m_exposureCompensationValueNumerator;
     258  Int       m_exposureCompensationValueDenomIdc;
     259  Int       m_refScreenLuminanceWhite;
     260  Int       m_extendedRangeWhiteLevel;
     261  Int       m_nominalBlackLevelLumaCodeValue;
     262  Int       m_nominalWhiteLevelLumaCodeValue;
     263  Int       m_extendedWhiteLevelLumaCodeValue;
     264  Int*      m_startOfCodedInterval;
     265  Int*      m_codedPivotValue;
     266  Int*      m_targetPivotValue;
     267#endif
    236268  Int       m_framePackingSEIEnabled;
    237269  Int       m_framePackingSEIType;
     
    243275  Int       m_gradualDecodingRefreshInfoEnabled;
    244276  Int       m_decodingUnitInfoSEIEnabled;
     277#if L0208_SOP_DESCRIPTION_SEI
     278  Int       m_SOPDescriptionSEIEnabled;
     279#endif
     280#if K0180_SCALABLE_NESTING_SEI
     281  Int       m_scalableNestingSEIEnabled;
     282#endif
    245283  //====== Weighted Prediction ========
    246284  Bool      m_useWeightedPred;       //< Use of Weighting Prediction (P_SLICE)
     
    379417  Void      setLoopFilterTcOffset           ( Int   i )      { m_loopFilterTcOffsetDiv2    = i; }
    380418  Void      setDeblockingFilterControlPresent ( Bool b ) { m_DeblockingFilterControlPresent = b; }
     419#if L0386_DB_METRIC
     420  Void      setDeblockingFilterMetric       ( Bool  b )      { m_DeblockingFilterMetric = b; }
     421#endif
    381422
    382423  //====== Motion search ========
     
    433474  Int       getLoopFilterTcOffset           ()      { return m_loopFilterTcOffsetDiv2; }
    434475  Bool      getDeblockingFilterControlPresent()  { return  m_DeblockingFilterControlPresent; }
     476#if L0386_DB_METRIC
     477  Bool      getDeblockingFilterMetric       ()      { return m_DeblockingFilterMetric; }
     478#endif
    435479
    436480  //==== Motion search ========
     
    450494  Void      setUseASR                       ( Bool  b )     { m_bUseASR     = b; }
    451495  Void      setUseHADME                     ( Bool  b )     { m_bUseHADME   = b; }
     496#if !L0034_COMBINED_LIST_CLEANUP
    452497  Void      setUseLComb                     ( Bool  b )     { m_bUseLComb   = b; }
     498#endif
    453499  Void      setUseRDOQ                      ( Bool  b )     { m_useRDOQ    = b; }
    454500  Void      setUseRDOQTS                    ( Bool  b )     { m_useRDOQTS  = b; }
     
    472518  Bool      getUseASR                       ()      { return m_bUseASR;     }
    473519  Bool      getUseHADME                     ()      { return m_bUseHADME;   }
     520#if !L0034_COMBINED_LIST_CLEANUP
    474521  Bool      getUseLComb                     ()      { return m_bUseLComb;   }
     522#endif
    475523  Bool      getUseRDOQ                      ()      { return m_useRDOQ;    }
    476524  Bool      getUseRDOQTS                    ()      { return m_useRDOQTS;  }
     
    569617  Void  setRecoveryPointSEIEnabled(Int b)                { m_recoveryPointSEIEnabled = b; }
    570618  Int   getRecoveryPointSEIEnabled()                     { return m_recoveryPointSEIEnabled; }
     619#if J0149_TONE_MAPPING_SEI
     620  Void  setToneMappingInfoSEIEnabled(Bool b)                 {  m_toneMappingInfoSEIEnabled = b;  }
     621  Bool  getToneMappingInfoSEIEnabled()                       {  return m_toneMappingInfoSEIEnabled;  }
     622  Void  setTMISEIToneMapId(Int b)                            {  m_toneMapId = b;  }
     623  Int   getTMISEIToneMapId()                                 {  return m_toneMapId;  }
     624  Void  setTMISEIToneMapCancelFlag(Bool b)                   {  m_toneMapCancelFlag=b;  }
     625  Bool  getTMISEIToneMapCancelFlag()                         {  return m_toneMapCancelFlag;  }
     626  Void  setTMISEIToneMapPersistenceFlag(Bool b)              {  m_toneMapPersistenceFlag = b;  }
     627  Bool   getTMISEIToneMapPersistenceFlag()                   {  return m_toneMapPersistenceFlag;  }
     628  Void  setTMISEICodedDataBitDepth(Int b)                    {  m_codedDataBitDepth = b;  }
     629  Int   getTMISEICodedDataBitDepth()                         {  return m_codedDataBitDepth;  }
     630  Void  setTMISEITargetBitDepth(Int b)                       {  m_targetBitDepth = b;  }
     631  Int   getTMISEITargetBitDepth()                            {  return m_targetBitDepth;  }
     632  Void  setTMISEIModelID(Int b)                              {  m_modelId = b;  }
     633  Int   getTMISEIModelID()                                   {  return m_modelId;  }
     634  Void  setTMISEIMinValue(Int b)                             {  m_minValue = b;  }
     635  Int   getTMISEIMinValue()                                  {  return m_minValue;  }
     636  Void  setTMISEIMaxValue(Int b)                             {  m_maxValue = b;  }
     637  Int   getTMISEIMaxValue()                                  {  return m_maxValue;  }
     638  Void  setTMISEISigmoidMidpoint(Int b)                      {  m_sigmoidMidpoint = b;  }
     639  Int   getTMISEISigmoidMidpoint()                           {  return m_sigmoidMidpoint;  }
     640  Void  setTMISEISigmoidWidth(Int b)                         {  m_sigmoidWidth = b;  }
     641  Int   getTMISEISigmoidWidth()                              {  return m_sigmoidWidth;  }
     642  Void  setTMISEIStartOfCodedInterva( Int*  p )              {  m_startOfCodedInterval = p;  }
     643  Int*  getTMISEIStartOfCodedInterva()                       {  return m_startOfCodedInterval;  }
     644  Void  setTMISEINumPivots(Int b)                            {  m_numPivots = b;  }
     645  Int   getTMISEINumPivots()                                 {  return m_numPivots;  }
     646  Void  setTMISEICodedPivotValue( Int*  p )                  {  m_codedPivotValue = p;  }
     647  Int*  getTMISEICodedPivotValue()                           {  return m_codedPivotValue;  }
     648  Void  setTMISEITargetPivotValue( Int*  p )                 {  m_targetPivotValue = p;  }
     649  Int*  getTMISEITargetPivotValue()                          {  return m_targetPivotValue;  }
     650  Void  setTMISEICameraIsoSpeedIdc(Int b)                    {  m_cameraIsoSpeedIdc = b;  }
     651  Int   getTMISEICameraIsoSpeedIdc()                         {  return m_cameraIsoSpeedIdc;  }
     652  Void  setTMISEICameraIsoSpeedValue(Int b)                  {  m_cameraIsoSpeedValue = b;  }
     653  Int   getTMISEICameraIsoSpeedValue()                       {  return m_cameraIsoSpeedValue;  }
     654  Void  setTMISEIExposureCompensationValueSignFlag(Int b)    {  m_exposureCompensationValueSignFlag = b;  }
     655  Int   getTMISEIExposureCompensationValueSignFlag()         {  return m_exposureCompensationValueSignFlag;  }
     656  Void  setTMISEIExposureCompensationValueNumerator(Int b)   {  m_exposureCompensationValueNumerator = b;  }
     657  Int   getTMISEIExposureCompensationValueNumerator()        {  return m_exposureCompensationValueNumerator;  }
     658  Void  setTMISEIExposureCompensationValueDenomIdc(Int b)    {  m_exposureCompensationValueDenomIdc =b;  }
     659  Int   getTMISEIExposureCompensationValueDenomIdc()         {  return m_exposureCompensationValueDenomIdc;  }
     660  Void  setTMISEIRefScreenLuminanceWhite(Int b)              {  m_refScreenLuminanceWhite = b;  }
     661  Int   getTMISEIRefScreenLuminanceWhite()                   {  return m_refScreenLuminanceWhite;  }
     662  Void  setTMISEIExtendedRangeWhiteLevel(Int b)              {  m_extendedRangeWhiteLevel = b;  }
     663  Int   getTMISEIExtendedRangeWhiteLevel()                   {  return m_extendedRangeWhiteLevel;  }
     664  Void  setTMISEINominalBlackLevelLumaCodeValue(Int b)       {  m_nominalBlackLevelLumaCodeValue = b;  }
     665  Int   getTMISEINominalBlackLevelLumaCodeValue()            {  return m_nominalBlackLevelLumaCodeValue;  }
     666  Void  setTMISEINominalWhiteLevelLumaCodeValue(Int b)       {  m_nominalWhiteLevelLumaCodeValue = b;  }
     667  Int   getTMISEINominalWhiteLevelLumaCodeValue()            {  return m_nominalWhiteLevelLumaCodeValue;  }
     668  Void  setTMISEIExtendedWhiteLevelLumaCodeValue(Int b)      {  m_extendedWhiteLevelLumaCodeValue =b;  }
     669  Int   getTMISEIExtendedWhiteLevelLumaCodeValue()           {  return m_extendedWhiteLevelLumaCodeValue;  }
     670#endif
    571671  Void  setFramePackingArrangementSEIEnabled(Int b)      { m_framePackingSEIEnabled = b; }
    572672  Int   getFramePackingArrangementSEIEnabled()           { return m_framePackingSEIEnabled; }
     
    587687  Void  setDecodingUnitInfoSEIEnabled(Int b)                { m_decodingUnitInfoSEIEnabled = b;    }
    588688  Int   getDecodingUnitInfoSEIEnabled()                     { return m_decodingUnitInfoSEIEnabled; }
     689#if L0208_SOP_DESCRIPTION_SEI
     690  Void  setSOPDescriptionSEIEnabled(Int b)                { m_SOPDescriptionSEIEnabled = b; }
     691  Int   getSOPDescriptionSEIEnabled()                     { return m_SOPDescriptionSEIEnabled; }
     692#endif
     693#if K0180_SCALABLE_NESTING_SEI
     694  Void  setScalableNestingSEIEnabled(Int b)                { m_scalableNestingSEIEnabled = b; }
     695  Int   getScalableNestingSEIEnabled()                     { return m_scalableNestingSEIEnabled; }
     696#endif
    589697  Void      setUseWP               ( Bool b )    { m_useWeightedPred   = b;    }
    590698  Void      setWPBiPred            ( Bool b )    { m_useWeightedBiPred = b;    }
  • trunk/source/Lib/TLibEncoder/TEncGOP.cpp

    r125 r189  
    9696#if L0045_NON_NESTED_SEI_RESTRICTIONS
    9797  xResetNonNestedSEIPresentFlags();
     98#if K0180_SCALABLE_NESTING_SEI
     99  xResetNestedSEIPresentFlags();
     100#endif
    98101#endif
    99102#if SVC_UPSAMPLING
     
    134137  m_pcSliceEncoder       = pcTEncTop->getSliceEncoder();
    135138  m_pcListPic            = pcTEncTop->getListPic(); 
     139 
    136140  m_pcEntropyCoder       = pcTEncTop->getEntropyCoder();
    137141  m_pcCavlcCoder         = pcTEncTop->getCavlcCoder();
     
    210214}
    211215
     216#if J0149_TONE_MAPPING_SEI
     217SEIToneMappingInfo*  TEncGOP::xCreateSEIToneMappingInfo()
     218{
     219  SEIToneMappingInfo *seiToneMappingInfo = new SEIToneMappingInfo();
     220  seiToneMappingInfo->m_toneMapId = m_pcCfg->getTMISEIToneMapId();
     221  seiToneMappingInfo->m_toneMapCancelFlag = m_pcCfg->getTMISEIToneMapCancelFlag();
     222  seiToneMappingInfo->m_toneMapPersistenceFlag = m_pcCfg->getTMISEIToneMapPersistenceFlag();
     223
     224  seiToneMappingInfo->m_codedDataBitDepth = m_pcCfg->getTMISEICodedDataBitDepth();
     225  assert(seiToneMappingInfo->m_codedDataBitDepth >= 8 && seiToneMappingInfo->m_codedDataBitDepth <= 14);
     226  seiToneMappingInfo->m_targetBitDepth = m_pcCfg->getTMISEITargetBitDepth();
     227  assert( (seiToneMappingInfo->m_targetBitDepth >= 1 && seiToneMappingInfo->m_targetBitDepth <= 17) || (seiToneMappingInfo->m_targetBitDepth  == 255) );
     228  seiToneMappingInfo->m_modelId = m_pcCfg->getTMISEIModelID();
     229  assert(seiToneMappingInfo->m_modelId >=0 &&seiToneMappingInfo->m_modelId<=4);
     230
     231  switch( seiToneMappingInfo->m_modelId)
     232  {
     233  case 0:
     234    {
     235      seiToneMappingInfo->m_minValue = m_pcCfg->getTMISEIMinValue();
     236      seiToneMappingInfo->m_maxValue = m_pcCfg->getTMISEIMaxValue();
     237      break;
     238    }
     239  case 1:
     240    {
     241      seiToneMappingInfo->m_sigmoidMidpoint = m_pcCfg->getTMISEISigmoidMidpoint();
     242      seiToneMappingInfo->m_sigmoidWidth = m_pcCfg->getTMISEISigmoidWidth();
     243      break;
     244    }
     245  case 2:
     246    {
     247      UInt num = 1u<<(seiToneMappingInfo->m_targetBitDepth);
     248      seiToneMappingInfo->m_startOfCodedInterval.resize(num);
     249      Int* ptmp = m_pcCfg->getTMISEIStartOfCodedInterva();
     250      if(ptmp)
     251      {
     252        for(int i=0; i<num;i++)
     253        {
     254          seiToneMappingInfo->m_startOfCodedInterval[i] = ptmp[i];
     255        }
     256      }
     257      break;
     258    }
     259  case 3:
     260    {
     261      seiToneMappingInfo->m_numPivots = m_pcCfg->getTMISEINumPivots();
     262      seiToneMappingInfo->m_codedPivotValue.resize(seiToneMappingInfo->m_numPivots);
     263      seiToneMappingInfo->m_targetPivotValue.resize(seiToneMappingInfo->m_numPivots);
     264      Int* ptmpcoded = m_pcCfg->getTMISEICodedPivotValue();
     265      Int* ptmptarget = m_pcCfg->getTMISEITargetPivotValue();
     266      if(ptmpcoded&&ptmptarget)
     267      {
     268        for(int i=0; i<(seiToneMappingInfo->m_numPivots);i++)
     269        {
     270          seiToneMappingInfo->m_codedPivotValue[i]=ptmpcoded[i];
     271          seiToneMappingInfo->m_targetPivotValue[i]=ptmptarget[i];
     272         }
     273       }
     274       break;
     275     }
     276  case 4:
     277     {
     278       seiToneMappingInfo->m_cameraIsoSpeedIdc = m_pcCfg->getTMISEICameraIsoSpeedIdc();
     279       seiToneMappingInfo->m_cameraIsoSpeedValue = m_pcCfg->getTMISEICameraIsoSpeedValue();
     280       assert( seiToneMappingInfo->m_cameraIsoSpeedValue !=0 );
     281       seiToneMappingInfo->m_exposureCompensationValueSignFlag = m_pcCfg->getTMISEIExposureCompensationValueSignFlag();
     282       seiToneMappingInfo->m_exposureCompensationValueNumerator = m_pcCfg->getTMISEIExposureCompensationValueNumerator();
     283       seiToneMappingInfo->m_exposureCompensationValueDenomIdc = m_pcCfg->getTMISEIExposureCompensationValueDenomIdc();
     284       seiToneMappingInfo->m_refScreenLuminanceWhite = m_pcCfg->getTMISEIRefScreenLuminanceWhite();
     285       seiToneMappingInfo->m_extendedRangeWhiteLevel = m_pcCfg->getTMISEIExtendedRangeWhiteLevel();
     286       assert( seiToneMappingInfo->m_extendedRangeWhiteLevel >= 100 );
     287       seiToneMappingInfo->m_nominalBlackLevelLumaCodeValue = m_pcCfg->getTMISEINominalBlackLevelLumaCodeValue();
     288       seiToneMappingInfo->m_nominalWhiteLevelLumaCodeValue = m_pcCfg->getTMISEINominalWhiteLevelLumaCodeValue();
     289       assert( seiToneMappingInfo->m_nominalWhiteLevelLumaCodeValue > seiToneMappingInfo->m_nominalBlackLevelLumaCodeValue );
     290       seiToneMappingInfo->m_extendedWhiteLevelLumaCodeValue = m_pcCfg->getTMISEIExtendedWhiteLevelLumaCodeValue();
     291       assert( seiToneMappingInfo->m_extendedWhiteLevelLumaCodeValue >= seiToneMappingInfo->m_nominalWhiteLevelLumaCodeValue );
     292       break;
     293    }
     294  default:
     295    {
     296      assert(!"Undefined SEIToneMapModelId");
     297      break;
     298    }
     299  }
     300  return seiToneMappingInfo;
     301}
     302#endif
    212303Void TEncGOP::xCreateLeadingSEIMessages (/*SEIMessages seiMessages,*/ AccessUnit &accessUnit, TComSPS *sps)
    213304{
    214   OutputNALUnit nalu(NAL_UNIT_SEI);
     305  OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
    215306
    216307  if(m_pcCfg->getActiveParameterSetsSEIEnabled())
     
    233324    SEIFramePacking *sei = xCreateSEIFramePacking ();
    234325
    235     nalu = NALUnit(NAL_UNIT_SEI);
     326    nalu = NALUnit(NAL_UNIT_PREFIX_SEI);
    236327    m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    237328    m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);
     
    244335    SEIDisplayOrientation *sei = xCreateSEIDisplayOrientation();
    245336
    246     nalu = NALUnit(NAL_UNIT_SEI);
     337    nalu = NALUnit(NAL_UNIT_PREFIX_SEI);
    247338    m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    248339    m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);
     
    251342    delete sei;
    252343  }
     344#if J0149_TONE_MAPPING_SEI
     345  if(m_pcCfg->getToneMappingInfoSEIEnabled())
     346  {
     347    SEIToneMappingInfo *sei = xCreateSEIToneMappingInfo ();
     348     
     349    nalu = NALUnit(NAL_UNIT_PREFIX_SEI);
     350    m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     351    m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);
     352    writeRBSPTrailingBits(nalu.m_Bitstream);
     353    accessUnit.push_back(new NALUnitEBSP(nalu));
     354    delete sei;
     355  }
     356#endif
    253357}
    254358
     
    276380  m_iNumPicCoded = 0;
    277381  SEIPictureTiming pictureTimingSEI;
     382#if L0208_SOP_DESCRIPTION_SEI
     383  Bool writeSOP = m_pcCfg->getSOPDescriptionSEIEnabled();
     384#endif
     385#if K0180_SCALABLE_NESTING_SEI
     386  // Initialize Scalable Nesting SEI with single layer values
     387  SEIScalableNesting scalableNestingSEI;
     388  scalableNestingSEI.m_bitStreamSubsetFlag           = 1;      // If the nested SEI messages are picture buffereing SEI mesages, picure timing SEI messages or sub-picture timing SEI messages, bitstream_subset_flag shall be equal to 1
     389  scalableNestingSEI.m_nestingOpFlag                 = 0;
     390  scalableNestingSEI.m_nestingNumOpsMinus1           = 0;      //nesting_num_ops_minus1
     391  scalableNestingSEI.m_allLayersFlag                 = 0;
     392  scalableNestingSEI.m_nestingNoOpMaxTemporalIdPlus1 = 6 + 1;  //nesting_no_op_max_temporal_id_plus1
     393  scalableNestingSEI.m_nestingNumLayersMinus1        = 1 - 1;  //nesting_num_layers_minus1
     394  scalableNestingSEI.m_nestingLayerId[0]             = 0;
     395  scalableNestingSEI.m_callerOwnsSEIs                = true;
     396#endif
    278397#if L0044_DU_DPB_OUTPUT_DELAY_HRD
    279398  Int picSptDpbOutputDuDelay = 0;
     
    348467    }
    349468
    350     if( getNalUnitType(pocCurr) == NAL_UNIT_CODED_SLICE_IDR || getNalUnitType(pocCurr) == NAL_UNIT_CODED_SLICE_IDR_N_LP )
     469    if( getNalUnitType(pocCurr, m_iLastIDR) == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType(pocCurr, m_iLastIDR) == NAL_UNIT_CODED_SLICE_IDR_N_LP )
    351470    {
    352471      m_iLastIDR = pocCurr;
     
    364483#if SVC_EXTENSION
    365484    pcPic->setLayerId( m_layerId );
    366 #endif
    367 
     485    m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getSPS(), m_pcEncTop->getPPS(), m_pcEncTop->getVPS() );
     486#else
    368487    m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getSPS(), m_pcEncTop->getPPS() );
     488#endif
    369489    pcSlice->setLastIDR(m_iLastIDR);
    370490    pcSlice->setSliceIdx(0);
     
    411531    }
    412532    // Set the nal unit type
    413     pcSlice->setNalUnitType(getNalUnitType(pocCurr));
     533    pcSlice->setNalUnitType(getNalUnitType(pocCurr, m_iLastIDR));
    414534#if IDR_ALIGNMENT
    415535    if (m_layerId > 0)
    416536    {
     537#if VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE
     538      TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId]->getRefLayerEnc(m_layerId)->getListPic();
     539#else
    417540      TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId-1]->getListPic();
     541#endif
    418542      pcSlice->setBaseColPic (*cListPic, m_layerId );
    419543    }
     
    424548    {
    425549#if IDR_ALIGNMENT
    426       if( pcSlice->getBaseColPic()->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR )
    427       {
    428         pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_IDR);
     550      if( pcSlice->getBaseColPic()->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || pcSlice->getBaseColPic()->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP )
     551      {
     552        pcSlice->setNalUnitType(pcSlice->getBaseColPic()->getSlice(0)->getNalUnitType());
    429553      }
    430554      else
     
    432556      pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_CRA);
    433557    }
     558#if ZERO_NUM_DIRECT_LAYERS
     559    if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() == 0 && pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA )
     560    {
     561      pcSlice->setSliceType(I_SLICE);
     562    }
     563    else
     564#endif
    434565    if( m_layerId > 0 && !m_pcEncTop->getElRapSliceTypeB() )
    435566    {
    436       if( (pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA) &&
     567      if( (pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP) &&
    437568          (pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) &&
    438569           pcSlice->getSliceType() == B_SLICE )
     
    442573    }
    443574#endif
    444     if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_TRAIL_R)
    445     {
    446       if(pcSlice->getTemporalLayerNonReferenceFlag())
     575    if(pcSlice->getTemporalLayerNonReferenceFlag())
     576    {
     577      if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_TRAIL_R)
    447578      {
    448579        pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TRAIL_N);
     580    }
     581      if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_RADL_R)
     582      {
     583        pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_RADL_N);
     584      }
     585      if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_RASL_R)
     586      {
     587        pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_RASL_N);
    449588      }
    450589    }
     
    471610        else
    472611        {
    473           pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TLA);
     612          pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TLA_R);
    474613        }
    475614      }
     
    524663    pcSlice->setNumRefIdx(REF_PIC_LIST_1,min(m_pcCfg->getGOPEntry(iGOPid).m_numRefPicsActive,pcSlice->getRPS()->getNumberOfPictures()));
    525664
    526 #if REF_LIST_BUGFIX
     665#if REF_IDX_FRAMEWORK
     666#if ZERO_NUM_DIRECT_LAYERS
     667    if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() )
     668#else
    527669    if(m_layerId > 0)
    528     {
    529       if( pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA )
     670#endif
     671    {
     672#if JCTVC_M0458_INTERLAYER_RPS_SIG
     673      if( pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA )
     674      {
     675        pcSlice->setNumRefIdx(REF_PIC_LIST_0, pcSlice->getActiveNumILRRefIdx());
     676        pcSlice->setNumRefIdx(REF_PIC_LIST_1, pcSlice->getActiveNumILRRefIdx());
     677      }
     678      else
     679      {
     680        pcSlice->setNumRefIdx(REF_PIC_LIST_0, pcSlice->getNumRefIdx(REF_PIC_LIST_0)+pcSlice->getActiveNumILRRefIdx());
     681        pcSlice->setNumRefIdx(REF_PIC_LIST_1, pcSlice->getNumRefIdx(REF_PIC_LIST_1)+pcSlice->getActiveNumILRRefIdx());
     682      }
     683#else
     684      if( pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA )
    530685      {
    531686        pcSlice->setNumRefIdx(REF_PIC_LIST_0, pcSlice->getNumILRRefIdx());
     
    537692        pcSlice->setNumRefIdx(REF_PIC_LIST_1, pcSlice->getNumRefIdx(REF_PIC_LIST_1)+pcSlice->getNumILRRefIdx());
    538693      }
     694#endif
    539695    }
    540696#endif
     
    545701
    546702#if SVC_EXTENSION     
     703#if ZERO_NUM_DIRECT_LAYERS
     704    if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() )
     705#else
    547706    if(m_layerId > 0)
     707#endif
    548708    {
    549709#if !IDR_ALIGNMENT
     
    553713#if SVC_UPSAMPLING
    554714      if ( pcPic->isSpatialEnhLayer())
    555       {   
     715      {
     716#if SCALED_REF_LAYER_OFFSETS
     717        m_pcPredSearch->upsampleBasePic( pcPic->getFullPelBaseRec(), pcSlice->getBaseColPic()->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow() );
     718#else
    556719        m_pcPredSearch->upsampleBasePic( pcPic->getFullPelBaseRec(), pcSlice->getBaseColPic()->getPicYuvRec(), pcPic->getPicYuvRec() );
     720#endif
    557721      }
    558722      else
     
    573737
    574738    //  Set reference list
    575 #if REF_LIST_BUGFIX
     739#if REF_IDX_FRAMEWORK
     740#if ZERO_NUM_DIRECT_LAYERS
     741    if(m_layerId ==  0 || ( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() == 0 ) )
     742#else
    576743    if(m_layerId ==  0)
     744#endif
    577745    {
    578746      pcSlice->setRefPicList( rcListPic);
     
    582750#endif
    583751#if REF_IDX_FRAMEWORK
     752#if ZERO_NUM_DIRECT_LAYERS
     753    if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() )
     754#else
    584755    if(m_layerId > 0)
     756#endif
    585757    {
    586758      m_pcEncTop->setILRPic(pcPic);
     
    592764      }
    593765#endif
    594 #if REF_LIST_BUGFIX
    595766      pcSlice->setRefPicListModificationSvc();
    596       pcSlice->setRefPicListSvc( rcListPic, m_pcEncTop->getIlpList() );
    597 #else
    598       pcSlice->addRefPicList ( m_pcEncTop->getIlpList(), 1);
    599 #endif
     767      pcSlice->setRefPicList( rcListPic, false, m_pcEncTop->getIlpList());
    600768
    601769#if REF_IDX_MFM
     
    607775        for(Int colIdx = 0; colIdx < pcSlice->getNumRefIdx( RefPicList(1 - ColFromL0Flag) ); colIdx++)
    608776        {
    609           if( pcSlice->getRefPic( RefPicList(1 - ColFromL0Flag), colIdx)->isILR() )
     777          if( pcSlice->getRefPic( RefPicList(1 - ColFromL0Flag), colIdx)->isILR(m_layerId) )
    610778          {
    611779            ColRefIdx = colIdx;
     
    620788          for(Int colIdx = 0; colIdx < pcSlice->getNumRefIdx( RefPicList(1 - ColFromL0Flag) ); colIdx++)
    621789          {
    622             if( pcSlice->getRefPic( RefPicList(1 - ColFromL0Flag), colIdx)->isILR() )
     790            if( pcSlice->getRefPic( RefPicList(1 - ColFromL0Flag), colIdx)->isILR(m_layerId) )
    623791            {
    624792              ColRefIdx = colIdx;
     
    644812      pcSlice->setSliceType ( P_SLICE );
    645813    }
    646 
     814#if !L0034_COMBINED_LIST_CLEANUP
    647815    if (pcSlice->getSliceType() != B_SLICE || !pcSlice->getSPS()->getUseLComb())
    648816    {
     
    656824      pcSlice->setNumRefIdx(REF_PIC_LIST_C, pcSlice->getNumRefIdx(REF_PIC_LIST_0));
    657825    }
     826#endif
    658827
    659828    if (pcSlice->getSliceType() == B_SLICE)
     
    683852      pcSlice->setCheckLDC(bLowDelay); 
    684853    }
     854    else
     855    {
     856      pcSlice->setCheckLDC(true); 
     857    }
    685858
    686859    uiColDir = 1-uiColDir;
     
    689862    pcSlice->setRefPOCList();
    690863
     864#if L0034_COMBINED_LIST_CLEANUP
     865    pcSlice->setList1IdxToList0Idx();
     866#else
    691867    pcSlice->setNoBackPredFlag( false );
    692868    if ( pcSlice->getSliceType() == B_SLICE && !pcSlice->getRefPicListCombinationFlag())
     
    712888    }
    713889    pcSlice->generateCombinedList();
     890#endif
    714891
    715892    if (m_pcEncTop->getTMVPModeId() == 2)
     
    8311008    UInt uiNumSlices = 1;
    8321009
     1010#if SIMPLIFIED_MV_POS_SCALING
     1011    if (m_layerId > 0)
     1012    {
     1013#if SCALED_REF_LAYER_OFFSETS
     1014      const Window &scalEL = m_pcEncTop->getScaledRefLayerWindow();
     1015
     1016      Int widthBL   = pcSlice->getBaseColPic()->getPicYuvRec()->getWidth();
     1017      Int heightBL  = pcSlice->getBaseColPic()->getPicYuvRec()->getHeight();
     1018
     1019      Int widthEL   = pcPic->getPicYuvRec()->getWidth()  - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();
     1020      Int heightEL  = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
     1021#else
     1022      const Window &confBL = pcSlice->getBaseColPic()->getPicYuvRec()->getConformanceWindow();
     1023      const Window &confEL = pcPic->getPicYuvRec()->getConformanceWindow();
     1024
     1025      Int widthBL   = pcSlice->getBaseColPic()->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset();
     1026      Int heightBL  = pcSlice->getBaseColPic()->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset();
     1027
     1028      Int widthEL   = pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset();
     1029      Int heightEL  = pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
     1030#endif
     1031      g_mvScalingFactor[m_layerId][0] = Clip3(-4096, 4095, ((widthEL  << 8) + (widthBL  >> 1)) / widthBL);
     1032      g_mvScalingFactor[m_layerId][1] = Clip3(-4096, 4095, ((heightEL << 8) + (heightBL >> 1)) / heightBL);
     1033
     1034      g_posScalingFactor[m_layerId][0] = ((widthBL  << 16) + (widthEL  >> 1)) / widthEL;
     1035      g_posScalingFactor[m_layerId][1] = ((heightBL << 16) + (heightEL >> 1)) / heightEL;
     1036    }
     1037#endif
     1038
    8331039    UInt uiInternalAddress = pcPic->getNumPartInCU()-4;
    8341040    UInt uiExternalAddress = pcPic->getPicSym()->getNumberOfCUsInFrame()-1;
     
    9491155    startCUAddrSliceSegmentIdx++;
    9501156#if AVC_BASE
    951     if( m_layerId == 0 )
     1157    if( m_layerId == 0 && m_pcEncTop->getVPS()->getAvcBaseLayerFlag() )
    9521158    {
    9531159      pcPic->getPicYuvOrg()->copyToPic( pcPic->getPicYuvRec() );
     
    10271233    Bool bLFCrossTileBoundary = pcSlice->getPPS()->getLoopFilterAcrossTilesEnabledFlag();
    10281234    m_pcLoopFilter->setCfg(bLFCrossTileBoundary);
     1235#if L0386_DB_METRIC
     1236    if ( m_pcCfg->getDeblockingFilterMetric() )
     1237    {
     1238      dblMetric(pcPic, uiNumSlices);
     1239    }
     1240#endif
    10291241    m_pcLoopFilter->loopFilterPic( pcPic );
    10301242
     
    10591271      OutputNALUnit nalu(NAL_UNIT_VPS, 0, m_layerId);
    10601272#if AVC_BASE
    1061       if( m_layerId == 1 )
     1273      if( ( m_layerId == 1 && m_pcEncTop->getVPS()->getAvcBaseLayerFlag() ) || ( m_layerId == 0 && !m_pcEncTop->getVPS()->getAvcBaseLayerFlag() ) )
    10621274#else
    10631275      if( m_layerId == 0 )
     
    11331345    }
    11341346
     1347#if L0208_SOP_DESCRIPTION_SEI
     1348    if (writeSOP) // write SOP description SEI (if enabled) at the beginning of GOP
     1349    {
     1350      Int SOPcurrPOC = pocCurr;
     1351
     1352      OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
     1353      m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
     1354      m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     1355
     1356      SEISOPDescription SOPDescriptionSEI;
     1357      SOPDescriptionSEI.m_sopSeqParameterSetId = pcSlice->getSPS()->getSPSId();
     1358
     1359      UInt i = 0;
     1360      UInt prevEntryId = iGOPid;
     1361      for (j = iGOPid; j < m_iGopSize; j++)
     1362      {
     1363        Int deltaPOC = m_pcCfg->getGOPEntry(j).m_POC - m_pcCfg->getGOPEntry(prevEntryId).m_POC;
     1364        if ((SOPcurrPOC + deltaPOC) < m_pcCfg->getFramesToBeEncoded())
     1365        {
     1366          SOPcurrPOC += deltaPOC;
     1367          SOPDescriptionSEI.m_sopDescVclNaluType[i] = getNalUnitType(SOPcurrPOC, m_iLastIDR);
     1368          SOPDescriptionSEI.m_sopDescTemporalId[i] = m_pcCfg->getGOPEntry(j).m_temporalId;
     1369          SOPDescriptionSEI.m_sopDescStRpsIdx[i] = m_pcEncTop->getReferencePictureSetIdxForSOP(pcSlice, SOPcurrPOC, j);
     1370          SOPDescriptionSEI.m_sopDescPocDelta[i] = deltaPOC;
     1371
     1372          prevEntryId = j;
     1373          i++;
     1374        }
     1375      }
     1376
     1377      SOPDescriptionSEI.m_numPicsInSopMinus1 = i - 1;
     1378
     1379      m_seiWriter.writeSEImessage( nalu.m_Bitstream, SOPDescriptionSEI, pcSlice->getSPS());
     1380      writeRBSPTrailingBits(nalu.m_Bitstream);
     1381      accessUnit.push_back(new NALUnitEBSP(nalu));
     1382
     1383      writeSOP = false;
     1384    }
     1385#endif
     1386
    11351387    if( ( m_pcCfg->getPictureTimingSEIEnabled() || m_pcCfg->getDecodingUnitInfoSEIEnabled() ) &&
    11361388        ( pcSlice->getSPS()->getVuiParametersPresentFlag() ) &&
     
    11781430       || ( pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getVclHrdParametersPresentFlag() ) ) )
    11791431    {
    1180       OutputNALUnit nalu(NAL_UNIT_SEI);
     1432      OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
    11811433      m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    11821434      m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     
    12191471      writeRBSPTrailingBits(nalu.m_Bitstream);
    12201472#if L0045_NON_NESTED_SEI_RESTRICTIONS
     1473      {
    12211474      UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit);
    12221475      UInt offsetPosition = m_activeParameterSetSEIPresentInAU;   // Insert BP SEI after APS SEI
     
    12281481      accessUnit.insert(it, new NALUnitEBSP(nalu));
    12291482      m_bufferingPeriodSEIPresentInAU = true;
     1483      }
    12301484#else
    12311485      accessUnit.push_back(new NALUnitEBSP(nalu));
     1486#endif
     1487
     1488#if K0180_SCALABLE_NESTING_SEI
     1489      if (m_pcCfg->getScalableNestingSEIEnabled())
     1490      {
     1491        OutputNALUnit naluTmp(NAL_UNIT_PREFIX_SEI);
     1492        m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
     1493        m_pcEntropyCoder->setBitstream(&naluTmp.m_Bitstream);
     1494        scalableNestingSEI.m_nestedSEIs.clear();
     1495        scalableNestingSEI.m_nestedSEIs.push_back(&sei_buffering_period);
     1496        m_seiWriter.writeSEImessage( naluTmp.m_Bitstream, scalableNestingSEI, pcSlice->getSPS());
     1497        writeRBSPTrailingBits(naluTmp.m_Bitstream);
     1498#if L0045_NON_NESTED_SEI_RESTRICTIONS
     1499        UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit);
     1500        UInt offsetPosition = m_activeParameterSetSEIPresentInAU + m_bufferingPeriodSEIPresentInAU + m_pictureTimingSEIPresentInAU;   // Insert BP SEI after non-nested APS, BP and PT SEIs
     1501        AccessUnit::iterator it;
     1502        for(j = 0, it = accessUnit.begin(); j < seiPositionInAu + offsetPosition; j++)
     1503        {
     1504          it++;
     1505        }
     1506        accessUnit.insert(it, new NALUnitEBSP(naluTmp));
     1507        m_nestedBufferingPeriodSEIPresentInAU = true;
     1508#else
     1509        accessUnit.push_back(new NALUnitEBSP(naluTmp));
     1510#endif
     1511      }
    12321512#endif
    12331513
     
    12411521      {
    12421522        // Gradual decoding refresh SEI
    1243         OutputNALUnit nalu(NAL_UNIT_SEI);
     1523        OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
    12441524        m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    12451525        m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     
    12531533      }
    12541534    // Recovery point SEI
    1255       OutputNALUnit nalu(NAL_UNIT_SEI);
     1535      OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
    12561536      m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    12571537      m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     
    14441724
    14451725          pcSlice->setTileOffstForMultES( uiOneBitstreamPerSliceLength );
    1446           if (!sliceSegment)
    1447           {
    14481726            pcSlice->setTileLocationCount ( 0 );
    1449             m_pcSliceEncoder->encodeSlice(pcPic, pcBitstreamRedirect, pcSubstreamsOut); // redirect is only used for CAVLC tile position info.
    1450           }
    1451           else
    1452           {
    1453             m_pcSliceEncoder->encodeSlice(pcPic, &nalu.m_Bitstream, pcSubstreamsOut); // nalu.m_Bitstream is only used for CAVLC tile position info.
    1454           }
     1727          m_pcSliceEncoder->encodeSlice(pcPic, pcSubstreamsOut);
    14551728
    14561729          {
     
    14841757              if (ui+1 < pcSlice->getPPS()->getNumSubstreams())
    14851758              {
    1486                 puiSubstreamSizes[ui] = pcSubstreamsOut[ui].getNumberOfWrittenBits();
     1759                puiSubstreamSizes[ui] = pcSubstreamsOut[ui].getNumberOfWrittenBits() + (pcSubstreamsOut[ui].countStartCodeEmulations()<<3);
    14871760              }
    14881761            }
     
    15161789          // If current NALU is the last NALU of slice and a NALU was buffered, then (a) Write current NALU (b) Update an write buffered NALU at approproate location in NALU list.
    15171790          Bool bNALUAlignedWrittenToList    = false; // used to ensure current NALU is not written more than once to the NALU list.
    1518           xWriteTileLocationToSliceHeader(nalu, pcBitstreamRedirect, pcSlice);
     1791          xAttachSliceDataToNalUnit(nalu, pcBitstreamRedirect);
    15191792          accessUnit.push_back(new NALUnitEBSP(nalu));
    15201793#if RATE_CONTROL_LAMBDA_DOMAIN
     
    15441817            {
    15451818              UInt numRBSPBytes_nal = UInt((*it)->m_nalUnitData.str().size());
    1546               if ((*it)->m_nalUnitType != NAL_UNIT_SEI && (*it)->m_nalUnitType != NAL_UNIT_SEI_SUFFIX)
     1819              if ((*it)->m_nalUnitType != NAL_UNIT_PREFIX_SEI && (*it)->m_nalUnitType != NAL_UNIT_SUFFIX_SEI)
    15471820              {
    15481821                numRBSPBytes += numRBSPBytes_nal;
     
    16401913        }
    16411914#if SVC_EXTENSION
    1642         OutputNALUnit nalu(NAL_UNIT_SEI_SUFFIX, pcSlice->getTLayer(), m_layerId);
    1643 #else
    1644         OutputNALUnit nalu(NAL_UNIT_SEI_SUFFIX, pcSlice->getTLayer());
     1915        OutputNALUnit nalu(NAL_UNIT_SUFFIX_SEI, pcSlice->getTLayer(), m_layerId);
     1916#else
     1917        OutputNALUnit nalu(NAL_UNIT_SUFFIX_SEI, pcSlice->getTLayer());
    16451918#endif
    16461919
     
    16671940        sei_temporal_level0_index.rapIdx = m_rapIdx;
    16681941
    1669         OutputNALUnit nalu(NAL_UNIT_SEI);
     1942        OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
    16701943
    16711944        /* write the SEI messages */
     
    18072080        if( m_pcCfg->getPictureTimingSEIEnabled() )
    18082081        {
    1809           OutputNALUnit nalu(NAL_UNIT_SEI, pcSlice->getTLayer());
     2082          {
     2083            OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI, pcSlice->getTLayer());
    18102084          m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    18112085          m_seiWriter.writeSEImessage(nalu.m_Bitstream, pictureTimingSEI, pcSlice->getSPS());
     
    18272101#endif
    18282102        }
     2103#if K0180_SCALABLE_NESTING_SEI
     2104          if ( m_pcCfg->getScalableNestingSEIEnabled() ) // put picture timing SEI into scalable nesting SEI
     2105          {
     2106            OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI, pcSlice->getTLayer());
     2107            m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
     2108            scalableNestingSEI.m_nestedSEIs.clear();
     2109            scalableNestingSEI.m_nestedSEIs.push_back(&pictureTimingSEI);
     2110            m_seiWriter.writeSEImessage(nalu.m_Bitstream, scalableNestingSEI, pcSlice->getSPS());
     2111            writeRBSPTrailingBits(nalu.m_Bitstream);
     2112#if L0045_NON_NESTED_SEI_RESTRICTIONS
     2113            UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit);
     2114            UInt offsetPosition = m_activeParameterSetSEIPresentInAU
     2115              + m_bufferingPeriodSEIPresentInAU + m_pictureTimingSEIPresentInAU + m_nestedBufferingPeriodSEIPresentInAU;    // Insert PT SEI after APS and BP SEI
     2116            AccessUnit::iterator it;
     2117            for(j = 0, it = accessUnit.begin(); j < seiPositionInAu + offsetPosition; j++)
     2118            {
     2119              it++;
     2120            }
     2121            accessUnit.insert(it, new NALUnitEBSP(nalu));
     2122            m_nestedPictureTimingSEIPresentInAU = true;
     2123#else
     2124            AccessUnit::iterator it = find_if(accessUnit.begin(), accessUnit.end(), mem_fun(&NALUnit::isSlice));
     2125            accessUnit.insert(it, new NALUnitEBSP(nalu));
     2126#endif
     2127          }
     2128#endif
     2129
     2130        }
    18292131        if( m_pcCfg->getDecodingUnitInfoSEIEnabled() && hrd->getSubPicCpbParamsPresentFlag() )
    18302132        {             
     
    18322134          for( Int i = 0; i < ( pictureTimingSEI.m_numDecodingUnitsMinus1 + 1 ); i ++ )
    18332135          {
    1834             OutputNALUnit nalu(NAL_UNIT_SEI, pcSlice->getTLayer());
     2136            OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI, pcSlice->getTLayer());
    18352137
    18362138            SEIDecodingUnitInfo tempSEI;
     
    18802182                  break;
    18812183                }
    1882                 if ((*it)->m_nalUnitType != NAL_UNIT_SEI && (*it)->m_nalUnitType != NAL_UNIT_SEI_SUFFIX)
     2184                if ((*it)->m_nalUnitType != NAL_UNIT_PREFIX_SEI && (*it)->m_nalUnitType != NAL_UNIT_SUFFIX_SEI)
    18832185                {
    18842186                  ctr++;
     
    18912193#if L0045_NON_NESTED_SEI_RESTRICTIONS
    18922194      xResetNonNestedSEIPresentFlags();
     2195#if K0180_SCALABLE_NESTING_SEI
     2196      xResetNestedSEIPresentFlags();
     2197#endif
    18932198#endif
    18942199      pcPic->getPicYuvRec()->copyToPic(pcPicYuvRecOut);
     
    21132418    case NAL_UNIT_CODED_SLICE_TRAIL_R: return "TRAIL_R";
    21142419    case NAL_UNIT_CODED_SLICE_TRAIL_N: return "TRAIL_N";
    2115     case NAL_UNIT_CODED_SLICE_TLA: return "TLA";
     2420    case NAL_UNIT_CODED_SLICE_TLA_R:      return "TLA_R";
    21162421    case NAL_UNIT_CODED_SLICE_TSA_N: return "TSA_N";
    21172422    case NAL_UNIT_CODED_SLICE_STSA_R: return "STSA_R";
    21182423    case NAL_UNIT_CODED_SLICE_STSA_N: return "STSA_N";
    2119     case NAL_UNIT_CODED_SLICE_BLA: return "BLA";
    2120     case NAL_UNIT_CODED_SLICE_BLANT: return "BLANT";
     2424    case NAL_UNIT_CODED_SLICE_BLA_W_LP:   return "BLA_W_LP";
     2425    case NAL_UNIT_CODED_SLICE_BLA_W_RADL: return "BLA_W_RADL";
    21212426    case NAL_UNIT_CODED_SLICE_BLA_N_LP: return "BLA_N_LP";
    2122     case NAL_UNIT_CODED_SLICE_IDR: return "IDR";
     2427    case NAL_UNIT_CODED_SLICE_IDR_W_RADL: return "IDR_W_RADL";
    21232428    case NAL_UNIT_CODED_SLICE_IDR_N_LP: return "IDR_N_LP";
    21242429    case NAL_UNIT_CODED_SLICE_CRA: return "CRA";
    2125     case NAL_UNIT_CODED_SLICE_DLP: return "DLP";
    2126     case NAL_UNIT_CODED_SLICE_TFD: return "TFD";
     2430    case NAL_UNIT_CODED_SLICE_RADL_R:     return "RADL_R";
     2431    case NAL_UNIT_CODED_SLICE_RASL_R:     return "RASL_R";
    21272432    case NAL_UNIT_VPS: return "VPS";
    21282433    case NAL_UNIT_SPS: return "SPS";
     
    21322437    case NAL_UNIT_EOB: return "EOB";
    21332438    case NAL_UNIT_FILLER_DATA: return "FILLER";
    2134     case NAL_UNIT_SEI: return "SEI";
     2439    case NAL_UNIT_PREFIX_SEI:             return "SEI";
     2440    case NAL_UNIT_SUFFIX_SEI:             return "SEI";
    21352441    default: return "UNK";
    21362442  }
     
    22232529    printf("*** %6s numBytesInNALunit: %u\n", nalUnitTypeToString((*it)->m_nalUnitType), numRBSPBytes_nal);
    22242530#endif
    2225     if ((*it)->m_nalUnitType != NAL_UNIT_SEI && (*it)->m_nalUnitType != NAL_UNIT_SEI_SUFFIX)
     2531    if ((*it)->m_nalUnitType != NAL_UNIT_PREFIX_SEI && (*it)->m_nalUnitType != NAL_UNIT_SUFFIX_SEI)
    22262532    {
    22272533      numRBSPBytes += numRBSPBytes_nal;
     
    23142620    for (Int iRefIndex = 0; iRefIndex < pcSlice->getNumRefIdx(RefPicList(iRefList)); iRefIndex++)
    23152621    {
     2622#if REF_IDX_FRAMEWORK && VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE
     2623      if( pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->isILR(m_layerId) )
     2624      {
     2625        printf( "%d(%d) ", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex)-pcSlice->getLastIDR(), pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->getLayerId() );
     2626      }
     2627      else
     2628#endif
    23162629      printf ("%d ", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex)-pcSlice->getLastIDR());
    23172630    }
     
    23252638 * This function checks the configuration and returns the appropriate nal_unit_type for the picture.
    23262639 */
    2327 NalUnitType TEncGOP::getNalUnitType(Int pocCurr)
     2640NalUnitType TEncGOP::getNalUnitType(Int pocCurr, Int lastIDR)
    23282641{
    23292642  if (pocCurr == 0)
    23302643  {
    2331     return NAL_UNIT_CODED_SLICE_IDR;
     2644    return NAL_UNIT_CODED_SLICE_IDR_W_RADL;
    23322645  }
    23332646  if (pocCurr % m_pcCfg->getIntraPeriod() == 0)
     
    23392652    else if (m_pcCfg->getDecodingRefreshType() == 2)
    23402653    {
    2341       return NAL_UNIT_CODED_SLICE_IDR;
     2654      return NAL_UNIT_CODED_SLICE_IDR_W_RADL;
    23422655    }
    23432656  }
     
    23512664      // controlling the reference pictures used for encoding that leading picture. Such a leading
    23522665      // picture need not be marked as a TFD picture.
    2353       return NAL_UNIT_CODED_SLICE_TFD;
     2666      return NAL_UNIT_CODED_SLICE_RASL_R;
     2667    }
     2668  }
     2669  if (lastIDR>0)
     2670  {
     2671    if (pocCurr < lastIDR)
     2672    {
     2673      return NAL_UNIT_CODED_SLICE_RADL_R;
    23542674    }
    23552675  }
     
    24022722}
    24032723
    2404 /** Determine the difference between consecutive tile sizes (in bytes) and writes it to  bistream rNalu [slice header]
    2405  * \param rpcBitstreamRedirect contains the bitstream to be concatenated to rNalu. rpcBitstreamRedirect contains slice payload. rpcSlice contains tile location information.
    2406  * \returns Updates rNalu to contain concatenated bitstream. rpcBitstreamRedirect is cleared at the end of this function call.
     2724/** Attaches the input bitstream to the stream in the output NAL unit
     2725    Updates rNalu to contain concatenated bitstream. rpcBitstreamRedirect is cleared at the end of this function call.
     2726 *  \param codedSliceData contains the coded slice data (bitstream) to be concatenated to rNalu
     2727 *  \param rNalu          target NAL unit
    24072728 */
    2408 Void TEncGOP::xWriteTileLocationToSliceHeader (OutputNALUnit& rNalu, TComOutputBitstream*& rpcBitstreamRedirect, TComSlice*& rpcSlice)
     2729Void TEncGOP::xAttachSliceDataToNalUnit (OutputNALUnit& rNalu, TComOutputBitstream*& codedSliceData)
    24092730{
    24102731  // Byte-align
     
    24122733
    24132734  // Perform bitstream concatenation
    2414   if (rpcBitstreamRedirect->getNumberOfWrittenBits() > 0)
    2415   {
    2416     UInt uiBitCount  = rpcBitstreamRedirect->getNumberOfWrittenBits();
    2417     if (rpcBitstreamRedirect->getByteStreamLength()>0)
    2418     {
    2419       UChar *pucStart  =  reinterpret_cast<UChar*>(rpcBitstreamRedirect->getByteStream());
    2420       UInt uiWriteByteCount = 0;
    2421       while (uiWriteByteCount < (uiBitCount >> 3) )
    2422       {
    2423         UInt uiBits = (*pucStart);
    2424         rNalu.m_Bitstream.write(uiBits, 8);
    2425         pucStart++;
    2426         uiWriteByteCount++;
    2427       }
    2428     }
    2429     UInt uiBitsHeld = (uiBitCount & 0x07);
    2430     for (UInt uiIdx=0; uiIdx < uiBitsHeld; uiIdx++)
    2431     {
    2432       rNalu.m_Bitstream.write((rpcBitstreamRedirect->getHeldBits() & (1 << (7-uiIdx))) >> (7-uiIdx), 1);
    2433     }         
     2735  if (codedSliceData->getNumberOfWrittenBits() > 0)
     2736    {
     2737    rNalu.m_Bitstream.addSubstream(codedSliceData);
    24342738  }
    24352739
    24362740  m_pcEntropyCoder->setBitstream(&rNalu.m_Bitstream);
    24372741
    2438   delete rpcBitstreamRedirect;
    2439   rpcBitstreamRedirect = new TComOutputBitstream;
     2742  codedSliceData->clear();
    24402743}
    24412744
     
    25622865     }               
    25632866  }
    2564   assert(it != accessUnit.end());
     2867//  assert(it != accessUnit.end());  // Triggers with some legit configurations
    25652868  return seiStartPos;
    25662869}
    25672870#endif
     2871
     2872#if L0386_DB_METRIC
     2873Void TEncGOP::dblMetric( TComPic* pcPic, UInt uiNumSlices )
     2874{
     2875  TComPicYuv* pcPicYuvRec = pcPic->getPicYuvRec();
     2876  Pel* Rec    = pcPicYuvRec->getLumaAddr( 0 );
     2877  Pel* tempRec = Rec;
     2878  Int  stride = pcPicYuvRec->getStride();
     2879  UInt log2maxTB = pcPic->getSlice(0)->getSPS()->getQuadtreeTULog2MaxSize();
     2880  UInt maxTBsize = (1<<log2maxTB);
     2881  const UInt minBlockArtSize = 8;
     2882  const UInt picWidth = pcPicYuvRec->getWidth();
     2883  const UInt picHeight = pcPicYuvRec->getHeight();
     2884  const UInt noCol = (picWidth>>log2maxTB);
     2885  const UInt noRows = (picHeight>>log2maxTB);
     2886  UInt64 *colSAD = (UInt64*)malloc(noCol*sizeof(UInt64));
     2887  UInt64 *rowSAD = (UInt64*)malloc(noRows*sizeof(UInt64));
     2888  UInt colIdx = 0;
     2889  UInt rowIdx = 0;
     2890  Pel p0, p1, p2, q0, q1, q2;
     2891 
     2892  Int qp = pcPic->getSlice(0)->getSliceQp();
     2893  Int bitdepthScale = 1 << (g_bitDepthY-8);
     2894  Int beta = TComLoopFilter::getBeta( qp ) * bitdepthScale;
     2895  const Int thr2 = (beta>>2);
     2896  const Int thr1 = 2*bitdepthScale;
     2897  UInt a = 0;
     2898 
     2899  memset(colSAD, 0, noCol*sizeof(UInt64));
     2900  memset(rowSAD, 0, noRows*sizeof(UInt64));
     2901 
     2902  if (maxTBsize > minBlockArtSize)
     2903  {
     2904    // Analyze vertical artifact edges
     2905    for(Int c = maxTBsize; c < picWidth; c += maxTBsize)
     2906    {
     2907      for(Int r = 0; r < picHeight; r++)
     2908      {
     2909        p2 = Rec[c-3];
     2910        p1 = Rec[c-2];
     2911        p0 = Rec[c-1];
     2912        q0 = Rec[c];
     2913        q1 = Rec[c+1];
     2914        q2 = Rec[c+2];
     2915        a = ((abs(p2-(p1<<1)+p0)+abs(q0-(q1<<1)+q2))<<1);
     2916        if ( thr1 < a && a < thr2)
     2917        {
     2918          colSAD[colIdx] += abs(p0 - q0);
     2919        }
     2920        Rec += stride;
     2921      }
     2922      colIdx++;
     2923      Rec = tempRec;
     2924    }
     2925   
     2926    // Analyze horizontal artifact edges
     2927    for(Int r = maxTBsize; r < picHeight; r += maxTBsize)
     2928    {
     2929      for(Int c = 0; c < picWidth; c++)
     2930      {
     2931        p2 = Rec[c + (r-3)*stride];
     2932        p1 = Rec[c + (r-2)*stride];
     2933        p0 = Rec[c + (r-1)*stride];
     2934        q0 = Rec[c + r*stride];
     2935        q1 = Rec[c + (r+1)*stride];
     2936        q2 = Rec[c + (r+2)*stride];
     2937        a = ((abs(p2-(p1<<1)+p0)+abs(q0-(q1<<1)+q2))<<1);
     2938        if (thr1 < a && a < thr2)
     2939        {
     2940          rowSAD[rowIdx] += abs(p0 - q0);
     2941        }
     2942      }
     2943      rowIdx++;
     2944    }
     2945  }
     2946 
     2947  UInt64 colSADsum = 0;
     2948  UInt64 rowSADsum = 0;
     2949  for(Int c = 0; c < noCol-1; c++)
     2950  {
     2951    colSADsum += colSAD[c];
     2952  }
     2953  for(Int r = 0; r < noRows-1; r++)
     2954  {
     2955    rowSADsum += rowSAD[r];
     2956  }
     2957 
     2958  colSADsum <<= 10;
     2959  rowSADsum <<= 10;
     2960  colSADsum /= (noCol-1);
     2961  colSADsum /= picHeight;
     2962  rowSADsum /= (noRows-1);
     2963  rowSADsum /= picWidth;
     2964 
     2965  UInt64 avgSAD = ((colSADsum + rowSADsum)>>1);
     2966  avgSAD >>= (g_bitDepthY-8);
     2967 
     2968  if ( avgSAD > 2048 )
     2969  {
     2970    avgSAD >>= 9;
     2971    Int offset = Clip3(2,6,(Int)avgSAD);
     2972    for (Int i=0; i<uiNumSlices; i++)
     2973    {
     2974      pcPic->getSlice(i)->setDeblockingFilterOverrideFlag(true);
     2975      pcPic->getSlice(i)->setDeblockingFilterDisable(false);
     2976      pcPic->getSlice(i)->setDeblockingFilterBetaOffsetDiv2( offset );
     2977      pcPic->getSlice(i)->setDeblockingFilterTcOffsetDiv2( offset );
     2978    }
     2979  }
     2980  else
     2981  {
     2982    for (Int i=0; i<uiNumSlices; i++)
     2983    {
     2984      pcPic->getSlice(i)->setDeblockingFilterOverrideFlag(false);
     2985      pcPic->getSlice(i)->setDeblockingFilterDisable(        pcPic->getSlice(i)->getPPS()->getPicDisableDeblockingFilterFlag() );
     2986      pcPic->getSlice(i)->setDeblockingFilterBetaOffsetDiv2( pcPic->getSlice(i)->getPPS()->getDeblockingFilterBetaOffsetDiv2() );
     2987      pcPic->getSlice(i)->setDeblockingFilterTcOffsetDiv2(   pcPic->getSlice(i)->getPPS()->getDeblockingFilterTcOffsetDiv2()   );
     2988    }
     2989  }
     2990 
     2991  free(colSAD);
     2992  free(rowSAD);
     2993}
     2994#endif
    25682995//! \}
  • trunk/source/Lib/TLibEncoder/TEncGOP.h

    r125 r189  
    131131  Bool                    m_bufferingPeriodSEIPresentInAU;
    132132  Bool                    m_pictureTimingSEIPresentInAU;
     133#if K0180_SCALABLE_NESTING_SEI
     134  Bool                    m_nestedBufferingPeriodSEIPresentInAU;
     135  Bool                    m_nestedPictureTimingSEIPresentInAU;
     136#endif
    133137#endif
    134138public:
     
    149153  Void  compressGOP ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP );
    150154#endif
    151   Void xWriteTileLocationToSliceHeader (OutputNALUnit& rNalu, TComOutputBitstream*& rpcBitstreamRedirect, TComSlice*& rpcSlice);
     155  Void  xAttachSliceDataToNalUnit (OutputNALUnit& rNalu, TComOutputBitstream*& rpcBitstreamRedirect);
    152156
    153157 
     
    160164 
    161165  TEncSlice*  getSliceEncoder()   { return m_pcSliceEncoder; }
    162   NalUnitType getNalUnitType( Int pocCurr );
     166  NalUnitType getNalUnitType( Int pocCurr, Int lastIdr );
    163167  Void arrangeLongtermPicturesInRPS(TComSlice *, TComList<TComPic*>& );
    164168protected:
     
    178182  SEIFramePacking*        xCreateSEIFramePacking();
    179183  SEIDisplayOrientation*  xCreateSEIDisplayOrientation();
     184
     185#if J0149_TONE_MAPPING_SEI
     186  SEIToneMappingInfo*     xCreateSEIToneMappingInfo();
     187#endif
    180188
    181189  Void xCreateLeadingSEIMessages (/*SEIMessages seiMessages,*/ AccessUnit &accessUnit, TComSPS *sps);
     
    188196    m_pictureTimingSEIPresentInAU      = false;
    189197  }
     198#if K0180_SCALABLE_NESTING_SEI
     199  Void xResetNestedSEIPresentFlags()
     200  {
     201    m_nestedBufferingPeriodSEIPresentInAU    = false;
     202    m_nestedPictureTimingSEIPresentInAU      = false;
     203  }
     204#endif
     205#endif
     206#if L0386_DB_METRIC
     207  Void dblMetric( TComPic* pcPic, UInt uiNumSlices );
    190208#endif
    191209};// END CLASS DEFINITION TEncGOP
  • trunk/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp

    r125 r189  
    16771677#endif
    16781678{
    1679 #if SAO_CHROMA_LAMBDA
    1680   m_dLambdaLuma    = dLambdaLuma;
    1681   m_dLambdaChroma  = dLambdaChroma;
    1682 #else
    1683   m_dLambdaLuma    = dLambda;
    1684   m_dLambdaChroma  = dLambda;
    1685 #endif
    1686 
    16871679  if(m_bUseNIF)
    16881680  {
  • trunk/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.h

    r125 r189  
    5757{
    5858private:
    59   Double            m_dLambdaLuma;
    60   Double            m_dLambdaChroma;
    61 
    6259  TEncEntropy*      m_pcEntropyCoder;
    6360  TEncSbac***       m_pppcRDSbacCoder;              ///< for CABAC
  • trunk/source/Lib/TLibEncoder/TEncSbac.h

    r125 r189  
    109109  Void  xWriteEpExGolomb     ( UInt uiSymbol, UInt uiCount );
    110110  Void  xWriteCoefRemainExGolomb ( UInt symbol, UInt &rParam );
    111   Void  xWriteTerminatingBit ( UInt uiBit );
    112111 
    113112  Void  xCopyFrom            ( TEncSbac* pSrc );
  • trunk/source/Lib/TLibEncoder/TEncSearch.cpp

    r125 r189  
    32493249    UInt          uiBitsTempL0[MAX_NUM_REF];
    32503250
     3251#if L0034_COMBINED_LIST_CLEANUP
     3252    TComMv        mvValidList1;
     3253    Int           refIdxValidList1 = 0;
     3254    UInt          bitsValidList1 = MAX_UINT;
     3255    UInt          costValidList1 = MAX_UINT;
     3256#endif
     3257
    32513258#if (ENCODER_FAST_MODE)
    32523259    Bool          testILR;
     
    32893296#if (ENCODER_FAST_MODE)
    32903297        TComPic* pcPic    = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxTemp );
    3291         if( !testILR && pcPic->isILR() && (ePartSize == SIZE_2Nx2N) )
     3298        if( !testILR && pcPic->isILR(pcCU->getLayerId()) && (ePartSize == SIZE_2Nx2N) )
    32923299        {
    32933300          continue;
     
    33263333        uiBitsTemp += m_auiMVPIdxCost[aaiMvpIdx[iRefList][iRefIdxTemp]][AMVP_MAX_NUM_CANDS];
    33273334#if ZERO_MVD_EST
     3335#if L0034_COMBINED_LIST_CLEANUP
     3336        if ( iRefList == 0 || pcCU->getSlice()->getList1IdxToList0Idx( iRefIdxTemp ) < 0 )
     3337#else
    33283338        if ((iRefList != 1 || !pcCU->getSlice()->getNoBackPredFlag()) &&
    33293339            (pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) <= 0 || pcCU->getSlice()->getRefIdxOfLC(eRefPicList, iRefIdxTemp)>=0))
     3340#endif
    33303341        {
    33313342          uiZeroMvdBitsTemp = uiBitsTemp;
     
    33473358       
    33483359#if GPB_SIMPLE_UNI
     3360#if L0034_COMBINED_LIST_CLEANUP
     3361        if ( iRefList == 1 )    // list 1
     3362        {
     3363          if ( pcCU->getSlice()->getList1IdxToList0Idx( iRefIdxTemp ) >= 0 )
     3364          {
     3365            cMvTemp[1][iRefIdxTemp] = cMvTemp[0][pcCU->getSlice()->getList1IdxToList0Idx( iRefIdxTemp )];
     3366            uiCostTemp = uiCostTempL0[pcCU->getSlice()->getList1IdxToList0Idx( iRefIdxTemp )];
     3367            /*first subtract the bit-rate part of the cost of the other list*/
     3368            uiCostTemp -= m_pcRdCost->getCost( uiBitsTempL0[pcCU->getSlice()->getList1IdxToList0Idx( iRefIdxTemp )] );
     3369            /*correct the bit-rate part of the current ref*/
     3370            m_pcRdCost->setPredictor  ( cMvPred[iRefList][iRefIdxTemp] );
     3371            uiBitsTemp += m_pcRdCost->getBits( cMvTemp[1][iRefIdxTemp].getHor(), cMvTemp[1][iRefIdxTemp].getVer() );
     3372            /*calculate the correct cost*/
     3373            uiCostTemp += m_pcRdCost->getCost( uiBitsTemp );
     3374          }
     3375          else
     3376          {
     3377            xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp );
     3378          }
     3379        }
     3380        else
     3381        {
     3382          xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp );
     3383        }
     3384#else
    33493385        if ( pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0)
    33503386        {
     
    33883424          }       
    33893425        }
     3426#endif
    33903427#else
    33913428        xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp );
     
    33943431        xCheckBestMVP(pcCU, eRefPicList, cMvTemp[iRefList][iRefIdxTemp], cMvPred[iRefList][iRefIdxTemp], aaiMvpIdx[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp);
    33953432
     3433#if L0034_COMBINED_LIST_CLEANUP
     3434        if ( iRefList == 0 )
     3435        {
     3436          uiCostTempL0[iRefIdxTemp] = uiCostTemp;
     3437          uiBitsTempL0[iRefIdxTemp] = uiBitsTemp;
     3438        }
     3439        if ( uiCostTemp < uiCost[iRefList] )
     3440        {
     3441          uiCost[iRefList] = uiCostTemp;
     3442          uiBits[iRefList] = uiBitsTemp; // storing for bi-prediction
     3443
     3444          // set motion
     3445          cMv[iRefList]     = cMvTemp[iRefList][iRefIdxTemp];
     3446          iRefIdx[iRefList] = iRefIdxTemp;
     3447        }
     3448
     3449        if ( iRefList == 1 && uiCostTemp < costValidList1 && pcCU->getSlice()->getList1IdxToList0Idx( iRefIdxTemp ) < 0 )
     3450        {
     3451          costValidList1 = uiCostTemp;
     3452          bitsValidList1 = uiBitsTemp;
     3453
     3454          // set motion
     3455          mvValidList1     = cMvTemp[iRefList][iRefIdxTemp];
     3456          refIdxValidList1 = iRefIdxTemp;
     3457        }
     3458#else
    33963459        if(pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0 && !pcCU->getSlice()->getNoBackPredFlag())
    33973460        {
     
    34493512            }
    34503513          }
     3514#endif
    34513515      }
    34523516    }
     
    35163580       
    35173581        Int         iRefList    = iIter % 2;
     3582#if L0034_COMBINED_LIST_CLEANUP
     3583        if ( m_pcEncCfg->getUseFastEnc() )
     3584        {
     3585          if( uiCost[0] <= uiCost[1] )
     3586          {
     3587            iRefList = 1;
     3588          }
     3589          else
     3590          {
     3591            iRefList = 0;
     3592          }
     3593        }
     3594        else if ( iIter == 0 )
     3595        {
     3596          iRefList = 0;
     3597        }
     3598        if ( iIter == 0 && !pcCU->getSlice()->getMvdL1ZeroFlag())
     3599        {
     3600          pcCU->getCUMvField(RefPicList(1-iRefList))->setAllMv( cMv[1-iRefList], ePartSize, uiPartAddr, 0, iPartIdx );
     3601          pcCU->getCUMvField(RefPicList(1-iRefList))->setAllRefIdx( iRefIdx[1-iRefList], ePartSize, uiPartAddr, 0, iPartIdx );
     3602          TComYuv*  pcYuvPred = &m_acYuvPred[1-iRefList];
     3603          motionCompensation ( pcCU, pcYuvPred, RefPicList(1-iRefList), iPartIdx );
     3604        }
     3605#else
    35183606        if ( m_pcEncCfg->getUseFastEnc() && (pcCU->getSlice()->getNoBackPredFlag() || (pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0 && pcCU->getSlice()->getRefIdxOfL0FromRefIdxOfL1(0)==0 )) )
    35193607        {
    35203608          iRefList = 1;
    35213609        }
     3610#endif
    35223611        RefPicList  eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 );
    35233612
     
    35333622        Bool     testIter = true;
    35343623        TComPic* pcPic    = pcCU->getSlice()->getRefPic( RefPicList(1 - iRefList), iRefIdxBi[1 - iRefList] );
    3535         if(pcPic->isILR() && (ePartSize == SIZE_2Nx2N))
     3624        if(pcPic->isILR(pcCU->getLayerId()) && (ePartSize == SIZE_2Nx2N))
    35363625        {
    35373626          testIter = false;  //the fixed part is ILR, skip this iteration       
     
    35483637          Bool testRefIdx = true;
    35493638          pcPic           = pcCU->getSlice()->getRefPic( RefPicList(iRefList) , iRefIdxTemp );
    3550           if(pcPic->isILR() && (ePartSize == SIZE_2Nx2N))
     3639          if(pcPic->isILR(pcCU->getLayerId()) && (ePartSize == SIZE_2Nx2N))
    35513640          {
    35523641            testRefIdx = false;  //the refined part is ILR, skip this reference pic           
     
    36803769    UInt uiMEBits = 0;
    36813770    // Set Motion Field_
     3771#if L0034_COMBINED_LIST_CLEANUP
     3772    cMv[1] = mvValidList1;
     3773    iRefIdx[1] = refIdxValidList1;
     3774    uiBits[1] = bitsValidList1;
     3775    uiCost[1] = costValidList1;
     3776#else
    36823777    if ( pcCU->getSlice()->getNoBackPredFlag() || (pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0 && pcCU->getSlice()->getRefIdxOfL0FromRefIdxOfL1(0)==0 ) )
    36833778    {
    36843779      uiCost[1] = MAX_UINT;
    36853780    }
     3781#endif
    36863782#if AMP_MRG
    36873783    if (bTestNormalMC)
     
    42124308  //  Do integer search
    42134309#if REF_IDX_ME_ZEROMV
    4214   if( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxPred )->isILR())  //ILR reference pic
     4310  if( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxPred )->isILR(pcCU->getLayerId()))  //ILR reference pic
    42154311  {
    42164312    rcMv.setZero();  //use Mv(0, 0) for integer ME
     
    42454341  {
    42464342#if REF_IDX_ME_ZEROMV
    4247     if( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxPred )->isILR())  //ILR reference pic
     4343    if( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxPred )->isILR(pcCU->getLayerId()))  //ILR reference pic
    42484344    {
    42494345      xPatternSearchFracDIFMv0( pcCU, pcPatternKey, piRefY, iRefStride, &rcMv, cMvHalf, cMvQter, ruiCost, bBi );
     
    46634759    while( pcCU->getWidth(0) > (pcCU->getSlice()->getSPS()->getMaxTrSize()<<uiTrLevel) ) uiTrLevel++;
    46644760  }
    4665   UInt uiMaxTrMode = pcCU->getSlice()->getSPS()->getMaxTrDepth() + uiTrLevel;
     4761  UInt uiMaxTrMode = 1 + uiTrLevel;
    46664762 
    46674763  while((uiWidth>>uiMaxTrMode) < (g_uiMaxCUWidth>>g_uiMaxCUDepth)) uiMaxTrMode--;
     
    62196315    for( Int refIdx = 0; refIdx < pcCU->getSlice()->getNumRefIdx(eRefPicList); refIdx++ )
    62206316    {
    6221       if( pcCU->getSlice()->getRefPic(eRefPicList, refIdx)->isILR() )
     6317      if( pcCU->getSlice()->getRefPic(eRefPicList, refIdx)->isILR(pcCU->getLayerId()) )
    62226318      {
    62236319        iRefIdxTemp = refIdx;
  • trunk/source/Lib/TLibEncoder/TEncSlice.cpp

    r125 r189  
    178178 \param pPPS          PPS associated with the slice
    179179 */
     180#if SVC_EXTENSION
     181//\param vps          VPS associated with the slice
     182Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, TComVPS *vps )
     183#else
    180184Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS )
     185#endif
    181186{
    182187  Double dQP;
     
    189194  rpcSlice->setPic( pcPic );
    190195#if SVC_EXTENSION
    191   rpcSlice->initSlice( pcPic->getLayerId() );
     196  UInt layerId = pcPic->getLayerId();
     197  rpcSlice->setVPS( vps );
     198  rpcSlice->initSlice( layerId );
    192199#else
    193200  rpcSlice->initSlice();
     
    337344  }
    338345
     346#if JCTVC_M0259_LAMBDAREFINEMENT
     347  if( rpcSlice->getLayerId() > 0 && depth >= 3 && m_pcCfg->getGOPSize() == ( 1 << depth ) )
     348  {
     349    Int nCurLayer = rpcSlice->getLayerId();
     350    Double gamma = xCalEnhLambdaFactor( m_ppcTEncTop[nCurLayer-1]->getQP() - m_ppcTEncTop[nCurLayer]->getQP() ,
     351      1.0 * m_ppcTEncTop[nCurLayer]->getSourceWidth() * m_ppcTEncTop[nCurLayer]->getSourceHeight()
     352      / m_ppcTEncTop[nCurLayer-1]->getSourceWidth() / m_ppcTEncTop[nCurLayer-1]->getSourceHeight() );
     353    dLambda *= gamma;
     354  }
     355#endif
     356
    339357  // store lambda
    340358  m_pcRdCost ->setLambda( dLambda );
     
    354372  qpc = Clip3( 0, 57, iQP + chromaQPOffset);
    355373  weight = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 );  // takes into account of the chroma qp mapping and chroma qp Offset
     374#if JCTVC_M0259_LAMBDAREFINEMENT
     375  if( rpcSlice->getLayerId() > 0 && m_pcCfg->getGOPSize() >= 8 && rpcSlice->isIntra() == false && depth == 0 )
     376  {
     377    dLambda *= 1.1;
     378    weight *= 1.15;
     379  }
     380#endif
    356381  m_pcRdCost->setCrDistortionWeight(weight);
    357382#endif
     
    400425  rpcSlice->setNumRefIdx(REF_PIC_LIST_1,m_pcCfg->getGOPEntry(iGOPid).m_numRefPicsActive);
    401426 
     427#if L0386_DB_METRIC
     428  if ( m_pcCfg->getDeblockingFilterMetric() )
     429  {
     430    rpcSlice->setDeblockingFilterOverrideFlag(true);
     431    rpcSlice->setDeblockingFilterDisable(false);
     432    rpcSlice->setDeblockingFilterBetaOffsetDiv2( 0 );
     433    rpcSlice->setDeblockingFilterTcOffsetDiv2( 0 );
     434  } else
     435#endif
    402436  if (rpcSlice->getPPS()->getDeblockingFilterControlPresentFlag())
    403437  {
     
    452486  rpcSlice->setMaxNumMergeCand        ( m_pcCfg->getMaxNumMergeCand()        );
    453487  xStoreWPparam( pPPS->getUseWP(), pPPS->getWPBiPred() );
     488
     489#if SVC_EXTENSION && REF_IDX_FRAMEWORK
     490  if( layerId > 0 )
     491  {
     492#if JCTVC_M0458_INTERLAYER_RPS_SIG
     493  // currently only one reference layer is supported in software and no decision logic to select yet.
     494  // hence num of active inter layer references is set to one always
     495    if( rpcSlice->getNumILRRefIdx() > 0 )
     496    {
     497      rpcSlice->setActiveNumILRRefIdx(1);
     498      rpcSlice->setInterLayerPredEnabledFlag(1);
     499    }
     500#else
     501    rpcSlice->setNumILRRefIdx( rpcSlice->getVPS()->getNumDirectRefLayers( layerId ) );
     502#endif
     503  }
     504
     505#endif
    454506}
    455507
     
    11821234 \retval rpcBitstream  bitstream class
    11831235 */
    1184 Void TEncSlice::encodeSlice   ( TComPic*& rpcPic, TComOutputBitstream* pcBitstream, TComOutputBitstream* pcSubstreams )
     1236Void TEncSlice::encodeSlice   ( TComPic*& rpcPic, TComOutputBitstream* pcSubstreams )
    11851237{
    11861238  UInt       uiCUAddr;
     
    13621414      }
    13631415      {
    1364           UInt uiCounter = 0;
    1365           vector<uint8_t>& rbsp   = pcSubstreams[uiSubStrm].getFIFO();
    1366           for (vector<uint8_t>::iterator it = rbsp.begin(); it != rbsp.end();)
    1367           {
    1368             /* 1) find the next emulated 00 00 {00,01,02,03}
    1369              * 2a) if not found, write all remaining bytes out, stop.
    1370              * 2b) otherwise, write all non-emulated bytes out
    1371              * 3) insert emulation_prevention_three_byte
    1372              */
    1373             vector<uint8_t>::iterator found = it;
    1374             do
    1375             {
    1376               /* NB, end()-1, prevents finding a trailing two byte sequence */
    1377               found = search_n(found, rbsp.end()-1, 2, 0);
    1378               found++;
    1379               /* if not found, found == end, otherwise found = second zero byte */
    1380               if (found == rbsp.end())
    1381               {
    1382                 break;
    1383               }
    1384               if (*(++found) <= 3)
    1385               {
    1386                 break;
    1387               }
    1388             } while (true);
    1389             it = found;
    1390             if (found != rbsp.end())
    1391             {
    1392               it++;
    1393               uiCounter++;
    1394             }
    1395           }
    1396        
     1416        UInt numStartCodeEmulations = pcSubstreams[uiSubStrm].countStartCodeEmulations();
    13971417        UInt uiAccumulatedSubstreamLength = 0;
    13981418        for (Int iSubstrmIdx=0; iSubstrmIdx < iNumSubstreams; iSubstrmIdx++)
     
    14021422        // add bits coded in previous dependent slices + bits coded so far
    14031423        // add number of emulation prevention byte count in the tile
    1404         pcSlice->addTileLocation( ((pcSlice->getTileOffstForMultES() + uiAccumulatedSubstreamLength - uiBitsOriginallyInSubstreams) >> 3) + uiCounter );
     1424        pcSlice->addTileLocation( ((pcSlice->getTileOffstForMultES() + uiAccumulatedSubstreamLength - uiBitsOriginallyInSubstreams) >> 3) + numStartCodeEmulations );
    14051425      }
    14061426    }
     
    18751895}
    18761896
     1897#if JCTVC_M0259_LAMBDAREFINEMENT
     1898Double TEncSlice::xCalEnhLambdaFactor( Double deltaQP , Double beta )
     1899{
     1900  double tmp = beta * pow( 2.0 , deltaQP / 6 );
     1901  double gamma = tmp / ( tmp + 1 );
     1902  return( gamma );
     1903}
     1904#endif
    18771905//! \}
  • trunk/source/Lib/TLibEncoder/TEncSlice.h

    r125 r189  
    116116 
    117117  /// preparation of slice encoding (reference marking, QP and lambda)
     118#if SVC_EXTENSION
     119  Void    initEncSlice        ( TComPic*  pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd,
     120                                Int iGOPid,   TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, TComVPS *vps );
     121#else
    118122  Void    initEncSlice        ( TComPic*  pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd,
    119123                                Int iGOPid,   TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS );
     124#endif
     125
    120126#if RATE_CONTROL_LAMBDA_DOMAIN
    121127  Void    resetQP             ( TComPic* pic, Int sliceQP, Double lambda );
     
    126132  Void    precompressSlice    ( TComPic*& rpcPic                                );      ///< precompress slice for multi-loop opt.
    127133  Void    compressSlice       ( TComPic*& rpcPic                                );      ///< analysis stage of slice
    128   Void    encodeSlice         ( TComPic*& rpcPic, TComOutputBitstream* rpcBitstream, TComOutputBitstream* pcSubstreams  );
     134  Void    encodeSlice         ( TComPic*& rpcPic, TComOutputBitstream* pcSubstreams  );
    129135 
    130136  // misc. functions
     
    141147private:
    142148  Double  xGetQPValueAccordingToLambda ( Double lambda );
     149
     150#if JCTVC_M0259_LAMBDAREFINEMENT
     151private:
     152  Double  xCalEnhLambdaFactor( Double deltaQP , Double beta );
     153#endif
    143154};
    144155
  • trunk/source/Lib/TLibEncoder/TEncTop.cpp

    r125 r189  
    294294    if(m_cIlpPic[i])
    295295    {
    296       //m_cIlpPic[i]->setPicYuvRec(NULL);
    297296      m_cIlpPic[i]->destroy();
    298297      delete m_cIlpPic[i];
     
    500499    {
    501500      TEncPic* pcEPic = new TEncPic;
     501
    502502#if SVC_EXTENSION //Temporal solution, should be modified
    503503      if(m_layerId > 0)
    504504      {
     505#if VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE
     506        TEncTop *pcEncTopBase = (TEncTop *)getRefLayerEnc( m_layerId );
     507#else
    505508        TEncTop *pcEncTopBase = (TEncTop *)getLayerEnc( m_layerId-1 );
     509#endif
    506510        if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() )
    507511        {
     
    527531      if(m_layerId > 0)
    528532      {
     533#if VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE
     534        TEncTop *pcEncTopBase = (TEncTop *)getRefLayerEnc( m_layerId );
     535#else
    529536        TEncTop *pcEncTopBase = (TEncTop *)getLayerEnc( m_layerId-1 );
     537#endif
    530538        if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() )
    531539        {
     
    543551#endif
    544552    }
     553
    545554    if (getUseSAO())
    546555    {
     
    566575#if REF_IDX_MFM
    567576  m_cSPS.setMFMEnabledFlag(m_bMFMEnabledFlag);
     577#endif
     578#if SCALED_REF_LAYER_OFFSETS
     579  m_cSPS.getScaledRefLayerWindow() = m_scaledRefLayerWindow;
    568580#endif
    569581  ProfileTierLevel& profileTierLevel = *m_cSPS.getPTL()->getGeneralPTL();
     
    599611  m_cSPS.setMaxCUHeight   ( g_uiMaxCUHeight     );
    600612  m_cSPS.setMaxCUDepth    ( g_uiMaxCUDepth      );
    601   m_cSPS.setMinTrDepth    ( 0                   );
    602   m_cSPS.setMaxTrDepth    ( 1                   );
     613
     614  Int minCUSize = m_cSPS.getMaxCUWidth() >> ( m_cSPS.getMaxCUDepth()-g_uiAddCUDepth );
     615  Int log2MinCUSize = 0;
     616  while(minCUSize > 1)
     617  {
     618    minCUSize >>= 1;
     619    log2MinCUSize++;
     620  }
     621
     622  m_cSPS.setLog2MinCodingBlockSize(log2MinCUSize);
     623  m_cSPS.setLog2DiffMaxMinCodingBlockSize(m_cSPS.getMaxCUDepth()-g_uiAddCUDepth);
    603624#if SVC_EXTENSION
    604625  m_cSPS.setSPSId         ( m_iSPSIdCnt       );
     
    618639
    619640  m_cSPS.setMaxTrSize   ( 1 << m_uiQuadtreeTULog2MaxSize );
    620  
     641#if !L0034_COMBINED_LIST_CLEANUP
    621642  m_cSPS.setUseLComb    ( m_bUseLComb           );
     643#endif
    622644 
    623645  Int i;
     
    763785  m_cPPS.setOutputFlagPresentFlag( false );
    764786  m_cPPS.setSignHideFlag(getSignHideFlag());
     787#if L0386_DB_METRIC
     788  if ( getDeblockingFilterMetric() )
     789  {
     790    m_cPPS.setDeblockingFilterControlPresentFlag (true);
     791    m_cPPS.setDeblockingFilterOverrideEnabledFlag(true);
     792    m_cPPS.setPicDisableDeblockingFilterFlag(false);
     793    m_cPPS.setDeblockingFilterBetaOffsetDiv2(0);
     794    m_cPPS.setDeblockingFilterTcOffsetDiv2(0);
     795  }
     796  else
     797  {
    765798  m_cPPS.setDeblockingFilterControlPresentFlag (m_DeblockingFilterControlPresent );
     799  }
     800#else
     801  m_cPPS.setDeblockingFilterControlPresentFlag (m_DeblockingFilterControlPresent );
     802#endif
    766803  m_cPPS.setLog2ParallelMergeLevelMinus2   (m_log2ParallelMergeLevelMinus2 );
    767804  m_cPPS.setCabacInitPresentFlag(CABAC_INIT_PRESENT_FLAG);
     
    810847    }
    811848  }
    812 #if REF_LIST_BUGFIX
     849#if REF_IDX_FRAMEWORK
    813850  if (!m_layerId)
    814851  {
     
    10361073}
    10371074
     1075#if L0208_SOP_DESCRIPTION_SEI
     1076Int TEncTop::getReferencePictureSetIdxForSOP(TComSlice* slice, Int POCCurr, Int GOPid )
     1077{
     1078  int rpsIdx = GOPid;
     1079
     1080  for(Int extraNum=m_iGOPSize; extraNum<m_extraRPSs+m_iGOPSize; extraNum++)
     1081  {   
     1082    if(m_uiIntraPeriod > 0 && getDecodingRefreshType() > 0)
     1083    {
     1084      Int POCIndex = POCCurr%m_uiIntraPeriod;
     1085      if(POCIndex == 0)
     1086      {
     1087        POCIndex = m_uiIntraPeriod;
     1088      }
     1089      if(POCIndex == m_GOPList[extraNum].m_POC)
     1090      {
     1091        rpsIdx = extraNum;
     1092      }
     1093    }
     1094    else
     1095    {
     1096      if(POCCurr==m_GOPList[extraNum].m_POC)
     1097      {
     1098        rpsIdx = extraNum;
     1099      }
     1100    }
     1101  }
     1102
     1103  return rpsIdx;
     1104}
     1105#endif
     1106
    10381107Void  TEncTop::xInitPPSforTiles()
    10391108{
     
    11181187}
    11191188
     1189#if SVC_EXTENSION
     1190#if VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE
     1191TEncTop* TEncTop::getRefLayerEnc( UInt layerId )
     1192{
     1193  if( m_ppcTEncTop[m_layerId]->getNumDirectRefLayers() <= 0 )
     1194  {
     1195#if ZERO_NUM_DIRECT_LAYERS
     1196    return (TEncTop *)getLayerEnc( 0 );
     1197#else
     1198    return NULL;
     1199#endif
     1200  }
     1201
     1202  // currently only one reference layer is supported
     1203  assert( m_ppcTEncTop[m_layerId]->getNumDirectRefLayers() == 1 );
     1204
     1205  return (TEncTop *)getLayerEnc( getVPS()->getRefLayerId( m_layerId, 0 ) );
     1206}
     1207#endif
     1208
    11201209#if REF_IDX_FRAMEWORK
    11211210Void TEncTop::xInitILRP()
     
    11231212  if(m_layerId>0)
    11241213  {
     1214    g_bitDepthY     = m_cSPS.getBitDepthY();
     1215    g_bitDepthC     = m_cSPS.getBitDepthC();
     1216    g_uiMaxCUWidth  = m_cSPS.getMaxCUWidth();
     1217    g_uiMaxCUHeight = m_cSPS.getMaxCUHeight();
     1218    g_uiMaxCUDepth  = m_cSPS.getMaxCUDepth();
     1219    g_uiAddCUDepth  = max (0, m_cSPS.getLog2MinCodingBlockSize() - (Int)m_cSPS.getQuadtreeTULog2MinSize() );
     1220
    11251221    Int  numReorderPics[MAX_TLAYER];
    11261222    Window &conformanceWindow = m_cSPS.getConformanceWindow();
     
    11321228      {
    11331229        m_cIlpPic[j] = new  TComPic;
    1134         //m_cIlpPic[j]->createWithOutYuv(m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, &m_cSPS, true);
    11351230#if SVC_UPSAMPLING
    11361231        m_cIlpPic[j]->create(m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, &m_cSPS, true);
     
    11511246  if(m_cIlpPic[0])
    11521247  {
    1153     //m_cIlpPic[0]->setPicYuvRec(pcPic->getFullPelBaseRec());
    11541248    m_cIlpPic[0]->copyUpsampledPictureYuv(pcPic->getFullPelBaseRec(), m_cIlpPic[0]->getPicYuvRec());
    11551249    m_cIlpPic[0]->getSlice(0)->setPOC(pcPic->getPOC());
    1156     m_cIlpPic[0]->setLayerId(0); //set reference layerId
     1250    m_cIlpPic[0]->setLayerId(pcPic->getSlice(0)->getBaseColPic()->getLayerId()); //set reference layerId
    11571251    m_cIlpPic[0]->getPicYuvRec()->setBorderExtension(false);
    11581252    m_cIlpPic[0]->getPicYuvRec()->extendPicBorder();
     
    11601254}
    11611255#endif
     1256#endif
    11621257//! \}
  • trunk/source/Lib/TLibEncoder/TEncTop.h

    r125 r189  
    139139  Bool                    m_bMFMEnabledFlag;
    140140#endif
     141#if SCALED_REF_LAYER_OFFSETS
     142  Window                  m_scaledRefLayerWindow;
     143#endif
    141144protected:
    142145  Void  xGetNewPicBuffer  ( TComPic*& rpcPic );           ///< get picture buffer which will be processed
     
    192195  TComPPS*                getPPS                () { return  &m_cPPS;                 }
    193196  Void selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid );
     197#if L0208_SOP_DESCRIPTION_SEI
     198  Int getReferencePictureSetIdxForSOP(TComSlice* slice, Int POCCurr, Int GOPid );
     199#endif
    194200  TComScalingList*        getScalingList        () { return  &m_scalingList;         }
    195201#if SVC_EXTENSION
     
    200206  Void                    setNumPicRcvd         ( Int num ) { m_iNumPicRcvd = num;      }
    201207#endif
     208#if SCALED_REF_LAYER_OFFSETS
     209  Window&  getScaledRefLayerWindow()            { return m_scaledRefLayerWindow; }
     210#endif
    202211
    203212  // -------------------------------------------------------------------------------------------------------------------
     
    209218#if REF_IDX_FRAMEWORK
    210219  TComPic** getIlpList() { return m_cIlpPic; }
    211   Void setILRPic(TComPic *pcPic);
     220  Void      setILRPic(TComPic *pcPic);
    212221#endif
    213222#if REF_IDX_MFM
    214   Void setMFMEnabledFlag       (Bool flag)   {m_bMFMEnabledFlag = flag;}
    215   Bool getMFMEnabledFlag()                   {return m_bMFMEnabledFlag;}   
     223  Void      setMFMEnabledFlag       (Bool flag)   {m_bMFMEnabledFlag = flag;}
     224  Bool      getMFMEnabledFlag()                   {return m_bMFMEnabledFlag;}   
    216225#endif
    217226#if AVC_SYNTAX
     
    219228  fstream*  getBLSyntaxFile() { return m_pBLSyntaxFile; }
    220229#endif
    221   Void encode( TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut,
    222               std::list<AccessUnit>& accessUnitsOut, Int iPicIdInGOP  );
    223   Void encodePrep( TComPicYuv* pcPicYuvOrg );
     230  Void      encode( TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int iPicIdInGOP  );
     231  Void      encodePrep( TComPicYuv* pcPicYuvOrg );
     232#if VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE
     233  TEncTop*  getRefLayerEnc(UInt layerId);
     234#endif
    224235#else
    225236  Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut,
  • trunk/source/Lib/TLibEncoder/WeightPredAnalysis.cpp

    r125 r189  
    235235        Int offset = (Int)( ((currDC<<log2Denom) - ((Int64)weight * refDC) + (Int64)realOffset) >> realLog2Denom );
    236236
    237         // Chroma offset range limination
     237        // Chroma offset range limitation
    238238        if(comp)
    239239        {
    240           Int shift = 1 << (g_bitDepthC - 1);
    241           Int pred = ( shift - ( ( shift*weight)>>(log2Denom) ) );
     240          Int pred = ( 128 - ( ( 128*weight)>>(log2Denom) ) );
    242241          Int deltaOffset = Clip3( -512, 511, (offset - pred) );    // signed 10bit
    243242          offset = Clip3( -128, 127, (deltaOffset + pred) );        // signed 8bit
     243        }
     244        // Luma offset range limitation
     245        else
     246        {
     247          offset = Clip3( -128, 127, offset);
    244248        }
    245249
Note: See TracChangeset for help on using the changeset viewer.