Changeset 133 in SHVCSoftware


Ignore:
Timestamp:
28 Apr 2013, 08:49:16 (12 years ago)
Author:
seregin
Message:

update to HM10.1

Location:
branches/SHM-2.0-dev/source
Files:
43 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-2.0-dev/source/App/TAppDecoder/TAppDecTop.cpp

    r125 r133  
    254254      }
    255255      if ( bNewPicture && bNewPOC &&
    256            (   nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR
     256           (   nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL
    257257            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP
    258258            || 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 ) )
     259            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL
     260            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP ) )
    261261      {
    262262        xFlushOutput( pcListPic, curLayerId );
     
    414414      }
    415415      if ( bNewPicture &&
    416            (   nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR
     416           (   nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL
    417417            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP
    418418            || 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 ) )
     419            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL
     420            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP ) )
    421421      {
    422422        xFlushOutput( pcListPic );
  • branches/SHM-2.0-dev/source/App/TAppEncoder/TAppEncCfg.cpp

    r125 r133  
    8989{
    9090  m_aidQP = NULL;
     91#if J0149_TONE_MAPPING_SEI
     92  m_startOfCodedInterval = NULL;
     93  m_codedPivotValue = NULL;
     94  m_targetPivotValue = NULL;
     95#endif
    9196}
    9297#endif
     
    102107    delete[] m_aidQP;
    103108  }
     109#if J0149_TONE_MAPPING_SEI
     110  if ( m_startOfCodedInterval )
     111  {
     112    delete[] m_startOfCodedInterval;
     113    m_startOfCodedInterval = NULL;
     114  }
     115   if ( m_codedPivotValue )
     116  {
     117    delete[] m_codedPivotValue;
     118    m_codedPivotValue = NULL;
     119  }
     120  if ( m_targetPivotValue )
     121  {
     122    delete[] m_targetPivotValue;
     123    m_targetPivotValue = NULL;
     124  }
     125#endif
    104126  free(m_pchInputFile);
    105127#endif
     
    324346  string cfg_RowHeight;
    325347  string cfg_ScalingListFile;
     348#if J0149_TONE_MAPPING_SEI
     349  string cfg_startOfCodedInterval;
     350  string cfg_codedPivotValue;
     351  string cfg_targetPivotValue;
     352#endif
    326353#if SIGNAL_BITRATE_PICRATE_IN_VPS
    327354  string cfg_bitRateInfoPresentFlag;
     
    430457  ("DecodingRefreshType,-dr", m_iDecodingRefreshType,       0, "Intra refresh type (0:none 1:CRA 2:IDR)")
    431458  ("GOPSize,g",               m_iGOPSize,                   1, "GOP size of temporal structure")
     459#if !L0034_COMBINED_LIST_CLEANUP
    432460  ("ListCombination,-lc",     m_bUseLComb,               true, "Combined reference list for uni-prediction estimation in B-slices")
     461#endif
    433462  // motion options
    434463  ("FastSearch",              m_iFastSearch,                1, "0:Full search  1:Diamond  2:PMVFAST")
     
    488517  ("LoopFilterTcOffset_div2",        m_loopFilterTcOffsetDiv2,             0 )
    489518  ("DeblockingFilterControlPresent", m_DeblockingFilterControlPresent, false )
     519#if L0386_DB_METRIC
     520  ("DeblockingFilterMetric",         m_DeblockingFilterMetric,         false )
     521#endif
    490522
    491523  // Coding tools
     
    602634  ("SEIBufferingPeriod",             m_bufferingPeriodSEIEnabled,              0, "Control generation of buffering period SEI messages")
    603635  ("SEIPictureTiming",               m_pictureTimingSEIEnabled,                0, "Control generation of picture timing SEI messages")
     636#if J0149_TONE_MAPPING_SEI
     637  ("SEIToneMappingInfo",                       m_toneMappingInfoSEIEnabled,    false, "Control generation of Tone Mapping SEI messages")
     638  ("SEIToneMapId",                             m_toneMapId,                        0, "Specifies Id of Tone Mapping SEI message for a given session")
     639  ("SEIToneMapCancelFlag",                     m_toneMapCancelFlag,            false, "Indicates that Tone Mapping SEI message cancels the persistance or follows")
     640  ("SEIToneMapPersistenceFlag",                m_toneMapPersistenceFlag,        true, "Specifies the persistence of the Tone Mapping SEI message")
     641  ("SEIToneMapCodedDataBitDepth",              m_toneMapCodedDataBitDepth,         8, "Specifies Coded Data BitDepth of Tone Mapping SEI messages")
     642  ("SEIToneMapTargetBitDepth",                 m_toneMapTargetBitDepth,            8, "Specifies Output BitDepth of Tome mapping function")
     643  ("SEIToneMapModelId",                        m_toneMapModelId,                   0, "Specifies Model utilized for mapping coded data into target_bit_depth range\n"
     644                                                                                      "\t0:  linear mapping with clipping\n"
     645                                                                                      "\t1:  sigmoidal mapping\n"
     646                                                                                      "\t2:  user-defined table mapping\n"
     647                                                                                      "\t3:  piece-wise linear mapping\n"
     648                                                                                      "\t4:  luminance dynamic range information ")
     649  ("SEIToneMapMinValue",                              m_toneMapMinValue,                          0, "Specifies the minimum value in mode 0")
     650  ("SEIToneMapMaxValue",                              m_toneMapMaxValue,                       1023, "Specifies the maxmum value in mode 0")
     651  ("SEIToneMapSigmoidMidpoint",                       m_sigmoidMidpoint,                        512, "Specifies the centre point in mode 1")
     652  ("SEIToneMapSigmoidWidth",                          m_sigmoidWidth,                           960, "Specifies the distance between 5% and 95% values of the target_bit_depth in mode 1")
     653  ("SEIToneMapStartOfCodedInterval",                  cfg_startOfCodedInterval,          string(""), "Array of user-defined mapping table")
     654  ("SEIToneMapNumPivots",                             m_numPivots,                                0, "Specifies the number of pivot points in mode 3")
     655  ("SEIToneMapCodedPivotValue",                       cfg_codedPivotValue,               string(""), "Array of pivot point")
     656  ("SEIToneMapTargetPivotValue",                      cfg_targetPivotValue,              string(""), "Array of pivot point")
     657  ("SEIToneMapCameraIsoSpeedIdc",                     m_cameraIsoSpeedIdc,                        0, "Indicates the camera ISO speed for daylight illumination")
     658  ("SEIToneMapCameraIsoSpeedValue",                   m_cameraIsoSpeedValue,                    400, "Specifies the camera ISO speed for daylight illumination of Extended_ISO")
     659  ("SEIToneMapExposureCompensationValueSignFlag",     m_exposureCompensationValueSignFlag,        0, "Specifies the sign of ExposureCompensationValue")
     660  ("SEIToneMapExposureCompensationValueNumerator",    m_exposureCompensationValueNumerator,       0, "Specifies the numerator of ExposureCompensationValue")
     661  ("SEIToneMapExposureCompensationValueDenomIdc",     m_exposureCompensationValueDenomIdc,        2, "Specifies the denominator of ExposureCompensationValue")
     662  ("SEIToneMapRefScreenLuminanceWhite",               m_refScreenLuminanceWhite,                350, "Specifies reference screen brightness setting in units of candela per square metre")
     663  ("SEIToneMapExtendedRangeWhiteLevel",               m_extendedRangeWhiteLevel,                800, "Indicates the luminance dynamic range")
     664  ("SEIToneMapNominalBlackLevelLumaCodeValue",        m_nominalBlackLevelLumaCodeValue,          16, "Specifies luma sample value of the nominal black level assigned decoded pictures")
     665  ("SEIToneMapNominalWhiteLevelLumaCodeValue",        m_nominalWhiteLevelLumaCodeValue,         235, "Specifies luma sample value of the nominal white level assigned decoded pictures")
     666  ("SEIToneMapExtendedWhiteLevelLumaCodeValue",       m_extendedWhiteLevelLumaCodeValue,        300, "Specifies luma sample value of the extended dynamic range assigned decoded pictures")
     667#endif
    604668  ("SEIFramePacking",                m_framePackingSEIEnabled,                 0, "Control generation of frame packing SEI messages")
    605669  ("SEIFramePackingType",            m_framePackingSEIType,                    0, "Define frame packing arrangement\n"
     
    622686  ("SEIGradualDecodingRefreshInfo",  m_gradualDecodingRefreshInfoEnabled,      0, "Control generation of gradual decoding refresh information SEI message")
    623687  ("SEIDecodingUnitInfo",             m_decodingUnitInfoSEIEnabled,                       0, "Control generation of decoding unit information SEI message.")
     688#if L0208_SOP_DESCRIPTION_SEI
     689  ("SEISOPDescription",              m_SOPDescriptionSEIEnabled,              0, "Control generation of SOP description SEI messages")
     690#endif
     691#if K0180_SCALABLE_NESTING_SEI
     692  ("SEIScalableNesting",             m_scalableNestingSEIEnabled,              0, "Control generation of scalable nesting SEI messages")
     693#endif
    624694#if SIGNAL_BITRATE_PICRATE_IN_VPS
    625695  ("BitRatePicRateMaxTLayers",   m_bitRatePicRateMaxTLayers,           0, "Maximum number of sub-layers signalled; can be inferred otherwise; here for easy parsing of config. file")
     
    878948  }
    879949  m_iWaveFrontSubstreams = m_iWaveFrontSynchro ? (m_iSourceHeight + m_uiMaxCUHeight - 1) / m_uiMaxCUHeight : 1;
     950#endif
     951#if J0149_TONE_MAPPING_SEI
     952  if( m_toneMappingInfoSEIEnabled && !m_toneMapCancelFlag )
     953  {
     954    Char* pcStartOfCodedInterval = cfg_startOfCodedInterval.empty() ? NULL: strdup(cfg_startOfCodedInterval.c_str());
     955    Char* pcCodedPivotValue = cfg_codedPivotValue.empty() ? NULL: strdup(cfg_codedPivotValue.c_str());
     956    Char* pcTargetPivotValue = cfg_targetPivotValue.empty() ? NULL: strdup(cfg_targetPivotValue.c_str());
     957    if( m_toneMapModelId == 2 && pcStartOfCodedInterval )
     958    {
     959      char *startOfCodedInterval;
     960      UInt num = 1u<< m_toneMapTargetBitDepth;
     961      m_startOfCodedInterval = new Int[num];
     962      ::memset( m_startOfCodedInterval, 0, sizeof(Int)*num );
     963      startOfCodedInterval = strtok(pcStartOfCodedInterval, " .");
     964      int i = 0;
     965      while( startOfCodedInterval && ( i < num ) )
     966      {
     967        m_startOfCodedInterval[i] = atoi( startOfCodedInterval );
     968        startOfCodedInterval = strtok(NULL, " .");
     969        i++;
     970      }
     971    }
     972    else
     973    {
     974      m_startOfCodedInterval = NULL;
     975    }
     976    if( ( m_toneMapModelId == 3 ) && ( m_numPivots > 0 ) )
     977    {
     978      if( pcCodedPivotValue && pcTargetPivotValue )
     979      {
     980        char *codedPivotValue;
     981        char *targetPivotValue;
     982        m_codedPivotValue = new Int[m_numPivots];
     983        m_targetPivotValue = new Int[m_numPivots];
     984        ::memset( m_codedPivotValue, 0, sizeof(Int)*( m_numPivots ) );
     985        ::memset( m_targetPivotValue, 0, sizeof(Int)*( m_numPivots ) );
     986        codedPivotValue = strtok(pcCodedPivotValue, " .");
     987        int i=0;
     988        while(codedPivotValue&&i<m_numPivots)
     989        {
     990          m_codedPivotValue[i] = atoi( codedPivotValue );
     991          codedPivotValue = strtok(NULL, " .");
     992          i++;
     993        }
     994        i=0;
     995        targetPivotValue = strtok(pcTargetPivotValue, " .");
     996        while(targetPivotValue&&i<m_numPivots)
     997        {
     998          m_targetPivotValue[i]= atoi( targetPivotValue );
     999          targetPivotValue = strtok(NULL, " .");
     1000          i++;
     1001        }
     1002      }
     1003    }
     1004    else
     1005    {
     1006      m_codedPivotValue = NULL;
     1007      m_targetPivotValue = NULL;
     1008    }
     1009  }
    8801010#endif
    8811011  // check validity of input parameters
     
    13751505  {
    13761506    m_numReorderPics[i] = 0;
     1507#if L0323_DPB
     1508    m_maxDecPicBuffering[i] = 1;
     1509#else
    13771510    m_maxDecPicBuffering[i] = 0;
     1511#endif
    13781512  }
    13791513  for(Int i=0; i<m_iGOPSize; i++)
    13801514  {
     1515#if L0323_DPB
     1516    if(m_GOPList[i].m_numRefPics+1 > m_maxDecPicBuffering[m_GOPList[i].m_temporalId])
     1517#else
    13811518    if(m_GOPList[i].m_numRefPics > m_maxDecPicBuffering[m_GOPList[i].m_temporalId])
    1382     {
     1519#endif
     1520    {
     1521#if L0323_DPB
     1522      m_maxDecPicBuffering[m_GOPList[i].m_temporalId] = m_GOPList[i].m_numRefPics + 1;
     1523#else
    13831524      m_maxDecPicBuffering[m_GOPList[i].m_temporalId] = m_GOPList[i].m_numRefPics;
     1525#endif
    13841526    }
    13851527    Int highestDecodingNumberWithLowerPOC = 0;
     
    14121554      m_numReorderPics[i+1] = m_numReorderPics[i];
    14131555    }
     1556#if L0323_DPB
     1557    // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ] - 1, inclusive
     1558    if(m_numReorderPics[i] > m_maxDecPicBuffering[i] - 1)
     1559    {
     1560      m_maxDecPicBuffering[i] = m_numReorderPics[i] + 1;
     1561    }
     1562#else
    14141563    // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ], inclusive
    14151564    if(m_numReorderPics[i] > m_maxDecPicBuffering[i])
     
    14171566      m_maxDecPicBuffering[i] = m_numReorderPics[i];
    14181567    }
     1568#endif
    14191569    // a lower layer can not have higher value of m_uiMaxDecPicBuffering than a higher layer
    14201570    if(m_maxDecPicBuffering[i+1] < m_maxDecPicBuffering[i])
     
    14231573    }
    14241574  }
     1575
     1576
     1577#if L0323_DPB
     1578  // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ] -  1, inclusive
     1579  if(m_numReorderPics[MAX_TLAYER-1] > m_maxDecPicBuffering[MAX_TLAYER-1] - 1)
     1580  {
     1581    m_maxDecPicBuffering[MAX_TLAYER-1] = m_numReorderPics[MAX_TLAYER-1] + 1;
     1582  }
     1583#else
    14251584  // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ], inclusive
    14261585  if(m_numReorderPics[MAX_TLAYER-1] > m_maxDecPicBuffering[MAX_TLAYER-1])
     
    14281587    m_maxDecPicBuffering[MAX_TLAYER-1] = m_numReorderPics[MAX_TLAYER-1];
    14291588  }
     1589#endif
    14301590
    14311591#if SVC_EXTENSION // ToDo: it should be checked for the case when parameters are different for the layers
     
    15111671  }
    15121672#endif
    1513 
     1673#if !L0034_COMBINED_LIST_CLEANUP
    15141674  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.
     1675#endif
    15151676  xConfirmPara( m_iWaveFrontSynchro < 0, "WaveFrontSynchro cannot be negative" );
    15161677#if !SVC_EXTENSION
     
    15201681
    15211682  xConfirmPara( m_decodedPictureHashSEIEnabled<0 || m_decodedPictureHashSEIEnabled>3, "this hash type is not correct!\n");
     1683
     1684#if J0149_TONE_MAPPING_SEI
     1685  if (m_toneMappingInfoSEIEnabled)
     1686  {
     1687    xConfirmPara( m_toneMapCodedDataBitDepth < 8 || m_toneMapCodedDataBitDepth > 14 , "SEIToneMapCodedDataBitDepth must be in rage 8 to 14");
     1688    xConfirmPara( m_toneMapTargetBitDepth < 1 || (m_toneMapTargetBitDepth > 16 && m_toneMapTargetBitDepth < 255) , "SEIToneMapTargetBitDepth must be in rage 1 to 16 or equal to 255");
     1689    xConfirmPara( m_toneMapModelId < 0 || m_toneMapModelId > 4 , "SEIToneMapModelId must be in rage 0 to 4");
     1690    xConfirmPara( m_cameraIsoSpeedValue == 0, "SEIToneMapCameraIsoSpeedValue shall not be equal to 0");
     1691    xConfirmPara( m_extendedRangeWhiteLevel < 100, "SEIToneMapExtendedRangeWhiteLevel should be greater than or equal to 100");
     1692    xConfirmPara( m_nominalBlackLevelLumaCodeValue >= m_nominalWhiteLevelLumaCodeValue, "SEIToneMapNominalWhiteLevelLumaCodeValue shall be greater than SEIToneMapNominalBlackLevelLumaCodeValue");
     1693    xConfirmPara( m_extendedWhiteLevelLumaCodeValue < m_nominalWhiteLevelLumaCodeValue, "SEIToneMapExtendedWhiteLevelLumaCodeValue shall be greater than or equal to SEIToneMapNominalWhiteLevelLumaCodeValue");
     1694  }
     1695#endif
    15221696
    15231697#if RATE_CONTROL_LAMBDA_DOMAIN
     
    16771851  printf("SQP:%d ", m_uiDeltaQpRD         );
    16781852  printf("ASR:%d ", m_bUseASR             );
     1853#if !L0034_COMBINED_LIST_CLEANUP
    16791854  printf("LComb:%d ", m_bUseLComb         );
     1855#endif
    16801856  printf("FEN:%d ", m_bUseFastEnc         );
    16811857  printf("ECU:%d ", m_bUseEarlyCU         );
  • branches/SHM-2.0-dev/source/App/TAppEncoder/TAppEncCfg.h

    r125 r133  
    109109  GOPEntry  m_GOPList[MAX_GOP];                               ///< the coding structure entries from the config file
    110110  Int       m_numReorderPics[MAX_TLAYER];                     ///< total number of reorder pictures
     111#if L0323_DPB
     112  Int       m_maxDecPicBuffering[MAX_TLAYER];                 ///< total number of pictures in the decoded picture buffer
     113#else
    111114  Int       m_maxDecPicBuffering[MAX_TLAYER];                 ///< total number of reference pictures needed for decoding
     115#endif
     116#if !L0034_COMBINED_LIST_CLEANUP
    112117  Bool      m_bUseLComb;                                      ///< flag for using combined reference list for uni-prediction in B-slices (JCTVC-D421)
     118#endif
    113119  Bool      m_useTransformSkip;                               ///< flag for enabling intra transform skipping
    114120  Bool      m_useTransformSkipFast;                           ///< flag for enabling fast intra transform skipping
     
    172178  Int       m_loopFilterTcOffsetDiv2;                       ///< tc offset for deblocking filter
    173179  Bool      m_DeblockingFilterControlPresent;                 ///< deblocking filter control present flag in PPS
     180#if L0386_DB_METRIC
     181  Bool      m_DeblockingFilterMetric;                         ///< blockiness metric in encoder
     182#endif
    174183 
    175184  // coding tools (PCM)
     
    223232  Int       m_bufferingPeriodSEIEnabled;
    224233  Int       m_pictureTimingSEIEnabled;
     234#if J0149_TONE_MAPPING_SEI
     235  Bool      m_toneMappingInfoSEIEnabled;
     236  Int       m_toneMapId;
     237  Bool      m_toneMapCancelFlag;
     238  Bool      m_toneMapPersistenceFlag;
     239  Int       m_toneMapCodedDataBitDepth;
     240  Int       m_toneMapTargetBitDepth;
     241  Int       m_toneMapModelId;
     242  Int       m_toneMapMinValue;
     243  Int       m_toneMapMaxValue;
     244  Int       m_sigmoidMidpoint;
     245  Int       m_sigmoidWidth;
     246  Int       m_numPivots;
     247  Int       m_cameraIsoSpeedIdc;
     248  Int       m_cameraIsoSpeedValue;
     249  Int       m_exposureCompensationValueSignFlag;
     250  Int       m_exposureCompensationValueNumerator;
     251  Int       m_exposureCompensationValueDenomIdc;
     252  Int       m_refScreenLuminanceWhite;
     253  Int       m_extendedRangeWhiteLevel;
     254  Int       m_nominalBlackLevelLumaCodeValue;
     255  Int       m_nominalWhiteLevelLumaCodeValue;
     256  Int       m_extendedWhiteLevelLumaCodeValue;
     257  Int*      m_startOfCodedInterval;
     258  Int*      m_codedPivotValue;
     259  Int*      m_targetPivotValue;
     260#endif
    225261  Int       m_framePackingSEIEnabled;
    226262  Int       m_framePackingSEIType;
     
    232268  Int       m_gradualDecodingRefreshInfoEnabled;
    233269  Int       m_decodingUnitInfoSEIEnabled;
     270#if L0208_SOP_DESCRIPTION_SEI
     271  Int       m_SOPDescriptionSEIEnabled;
     272#endif
     273#if K0180_SCALABLE_NESTING_SEI
     274  Int       m_scalableNestingSEIEnabled;
     275#endif
    234276  // weighted prediction
    235277  Bool      m_useWeightedPred;                    ///< Use of weighted prediction in P slices
  • branches/SHM-2.0-dev/source/App/TAppEncoder/TAppEncTop.cpp

    r125 r133  
    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
     
    167167    m_acTEncTop[layer].setLoopFilterTcOffset           ( m_loopFilterTcOffsetDiv2    );
    168168    m_acTEncTop[layer].setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent);
     169#if L0386_DB_METRIC
     170    m_acTEncTop[layer].setDeblockingFilterMetric       ( m_DeblockingFilterMetric );
     171#endif
    169172
    170173    //====== Motion search ========
     
    200203    m_acTEncTop[layer].setUseHADME                     ( m_bUseHADME    );
    201204    m_acTEncTop[layer].setUseLossless                  ( m_useLossless );
    202     m_acTEncTop[layer].setUseLComb                     ( m_bUseLComb    );
     205#if !L0034_COMBINED_LIST_CLEANUP
     206    m_cTEncTop.setUseLComb                             ( m_bUseLComb    );
     207#endif
    203208    m_acTEncTop[layer].setdQPs                         ( m_acLayerCfg[layer].getdQPs() );
    204209    m_acTEncTop[layer].setUseRDOQ                      ( m_useRDOQ     );
     
    270275    m_acTEncTop[layer].setBufferingPeriodSEIEnabled( m_bufferingPeriodSEIEnabled );
    271276    m_acTEncTop[layer].setPictureTimingSEIEnabled( m_pictureTimingSEIEnabled );
     277#if J0149_TONE_MAPPING_SEI
     278    m_acTEncTop[layer].setToneMappingInfoSEIEnabled                 ( m_toneMappingInfoSEIEnabled );
     279    m_acTEncTop[layer].setTMISEIToneMapId                           ( m_toneMapId );
     280    m_acTEncTop[layer].setTMISEIToneMapCancelFlag                   ( m_toneMapCancelFlag );
     281    m_acTEncTop[layer].setTMISEIToneMapPersistenceFlag              ( m_toneMapPersistenceFlag );
     282    m_acTEncTop[layer].setTMISEICodedDataBitDepth                   ( m_toneMapCodedDataBitDepth );
     283    m_acTEncTop[layer].setTMISEITargetBitDepth                      ( m_toneMapTargetBitDepth );
     284    m_acTEncTop[layer].setTMISEIModelID                             ( m_toneMapModelId );
     285    m_acTEncTop[layer].setTMISEIMinValue                            ( m_toneMapMinValue );
     286    m_acTEncTop[layer].setTMISEIMaxValue                            ( m_toneMapMaxValue );
     287    m_acTEncTop[layer].setTMISEISigmoidMidpoint                     ( m_sigmoidMidpoint );
     288    m_acTEncTop[layer].setTMISEISigmoidWidth                        ( m_sigmoidWidth );
     289    m_acTEncTop[layer].setTMISEIStartOfCodedInterva                 ( m_startOfCodedInterval );
     290    m_acTEncTop[layer].setTMISEINumPivots                           ( m_numPivots );
     291    m_acTEncTop[layer].setTMISEICodedPivotValue                     ( m_codedPivotValue );
     292    m_acTEncTop[layer].setTMISEITargetPivotValue                    ( m_targetPivotValue );
     293    m_acTEncTop[layer].setTMISEICameraIsoSpeedIdc                   ( m_cameraIsoSpeedIdc );
     294    m_acTEncTop[layer].setTMISEICameraIsoSpeedValue                 ( m_cameraIsoSpeedValue );
     295    m_acTEncTop[layer].setTMISEIExposureCompensationValueSignFlag   ( m_exposureCompensationValueSignFlag );
     296    m_acTEncTop[layer].setTMISEIExposureCompensationValueNumerator  ( m_exposureCompensationValueNumerator );
     297    m_acTEncTop[layer].setTMISEIExposureCompensationValueDenomIdc   ( m_exposureCompensationValueDenomIdc );
     298    m_acTEncTop[layer].setTMISEIRefScreenLuminanceWhite             ( m_refScreenLuminanceWhite );
     299    m_acTEncTop[layer].setTMISEIExtendedRangeWhiteLevel             ( m_extendedRangeWhiteLevel );
     300    m_acTEncTop[layer].setTMISEINominalBlackLevelLumaCodeValue      ( m_nominalBlackLevelLumaCodeValue );
     301    m_acTEncTop[layer].setTMISEINominalWhiteLevelLumaCodeValue      ( m_nominalWhiteLevelLumaCodeValue );
     302    m_acTEncTop[layer].setTMISEIExtendedWhiteLevelLumaCodeValue     ( m_extendedWhiteLevelLumaCodeValue );
     303#endif
    272304    m_acTEncTop[layer].setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled );
    273305    m_acTEncTop[layer].setFramePackingArrangementSEIType( m_framePackingSEIType );
     
    279311    m_acTEncTop[layer].setGradualDecodingRefreshInfoEnabled( m_gradualDecodingRefreshInfoEnabled );
    280312    m_acTEncTop[layer].setDecodingUnitInfoSEIEnabled( m_decodingUnitInfoSEIEnabled );
     313#if L0208_SOP_DESCRIPTION_SEI
     314    m_acTEncTop[layer].setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled );
     315#endif
     316#if K0180_SCALABLE_NESTING_SEI
     317    m_acTEncTop[layer].setScalableNestingSEIEnabled( m_scalableNestingSEIEnabled );
     318#endif
    281319    m_acTEncTop[layer].setUniformSpacingIdr          ( m_iUniformSpacingIdr );
    282320    m_acTEncTop[layer].setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
     
    442480  m_cTEncTop.setLoopFilterTcOffset           ( m_loopFilterTcOffsetDiv2    );
    443481  m_cTEncTop.setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent);
     482#if L0386_DB_METRIC
     483  m_cTEncTop.setDeblockingFilterMetric       ( m_DeblockingFilterMetric );
     484#endif
    444485
    445486  //====== Motion search ========
     
    475516  m_cTEncTop.setUseHADME                     ( m_bUseHADME    );
    476517  m_cTEncTop.setUseLossless                  ( m_useLossless );
     518#if !L0034_COMBINED_LIST_CLEANUP
    477519  m_cTEncTop.setUseLComb                     ( m_bUseLComb    );
     520#endif
    478521  m_cTEncTop.setdQPs                         ( m_aidQP        );
    479522  m_cTEncTop.setUseRDOQ                      ( m_useRDOQ     );
     
    545588  m_cTEncTop.setBufferingPeriodSEIEnabled( m_bufferingPeriodSEIEnabled );
    546589  m_cTEncTop.setPictureTimingSEIEnabled( m_pictureTimingSEIEnabled );
     590#if J0149_TONE_MAPPING_SEI
     591  m_cTEncTop.setToneMappingInfoSEIEnabled                 ( m_toneMappingInfoSEIEnabled );
     592  m_cTEncTop.setTMISEIToneMapId                           ( m_toneMapId );
     593  m_cTEncTop.setTMISEIToneMapCancelFlag                   ( m_toneMapCancelFlag );
     594  m_cTEncTop.setTMISEIToneMapPersistenceFlag              ( m_toneMapPersistenceFlag );
     595  m_cTEncTop.setTMISEICodedDataBitDepth                   ( m_toneMapCodedDataBitDepth );
     596  m_cTEncTop.setTMISEITargetBitDepth                      ( m_toneMapTargetBitDepth );
     597  m_cTEncTop.setTMISEIModelID                             ( m_toneMapModelId );
     598  m_cTEncTop.setTMISEIMinValue                            ( m_toneMapMinValue );
     599  m_cTEncTop.setTMISEIMaxValue                            ( m_toneMapMaxValue );
     600  m_cTEncTop.setTMISEISigmoidMidpoint                     ( m_sigmoidMidpoint );
     601  m_cTEncTop.setTMISEISigmoidWidth                        ( m_sigmoidWidth );
     602  m_cTEncTop.setTMISEIStartOfCodedInterva                 ( m_startOfCodedInterval );
     603  m_cTEncTop.setTMISEINumPivots                           ( m_numPivots );
     604  m_cTEncTop.setTMISEICodedPivotValue                     ( m_codedPivotValue );
     605  m_cTEncTop.setTMISEITargetPivotValue                    ( m_targetPivotValue );
     606  m_cTEncTop.setTMISEICameraIsoSpeedIdc                   ( m_cameraIsoSpeedIdc );
     607  m_cTEncTop.setTMISEICameraIsoSpeedValue                 ( m_cameraIsoSpeedValue );
     608  m_cTEncTop.setTMISEIExposureCompensationValueSignFlag   ( m_exposureCompensationValueSignFlag );
     609  m_cTEncTop.setTMISEIExposureCompensationValueNumerator  ( m_exposureCompensationValueNumerator );
     610  m_cTEncTop.setTMISEIExposureCompensationValueDenomIdc   ( m_exposureCompensationValueDenomIdc );
     611  m_cTEncTop.setTMISEIRefScreenLuminanceWhite             ( m_refScreenLuminanceWhite );
     612  m_cTEncTop.setTMISEIExtendedRangeWhiteLevel             ( m_extendedRangeWhiteLevel );
     613  m_cTEncTop.setTMISEINominalBlackLevelLumaCodeValue      ( m_nominalBlackLevelLumaCodeValue );
     614  m_cTEncTop.setTMISEINominalWhiteLevelLumaCodeValue      ( m_nominalWhiteLevelLumaCodeValue );
     615  m_cTEncTop.setTMISEIExtendedWhiteLevelLumaCodeValue     ( m_extendedWhiteLevelLumaCodeValue );
     616#endif
    547617  m_cTEncTop.setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled );
    548618  m_cTEncTop.setFramePackingArrangementSEIType( m_framePackingSEIType );
     
    554624  m_cTEncTop.setGradualDecodingRefreshInfoEnabled( m_gradualDecodingRefreshInfoEnabled );
    555625  m_cTEncTop.setDecodingUnitInfoSEIEnabled( m_decodingUnitInfoSEIEnabled );
     626#if L0208_SOP_DESCRIPTION_SEI
     627  m_cTEncTop.setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled );
     628#endif
     629#if K0180_SCALABLE_NESTING_SEI
     630  m_cTEncTop.setScalableNestingSEIEnabled( m_scalableNestingSEIEnabled );
     631#endif
    556632  m_cTEncTop.setUniformSpacingIdr          ( m_iUniformSpacingIdr );
    557633  m_cTEncTop.setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
     
    812888
    813889/**
    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 */
     890 - create internal class
     891 - initialize internal variable
     892 - until the end of input YUV file, call encoding function in TEncTop class
     893 - delete allocated buffers
     894 - destroy internal class
     895 .
     896 */
    821897#if SVC_EXTENSION
    822898Void TAppEncTop::encode()
     
    11021178
    11031179/**
    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 */
     1180 - application has picture buffer list with size of GOP
     1181 - picture buffer list acts as ring buffer
     1182 - end of the list has the latest picture
     1183 .
     1184 */
    11091185#if SVC_EXTENSION
    11101186Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, UInt layer)
     
    12221298
    12231299/** \param iNumEncoded  number of encoded frames
    1224 */
     1300 */
    12251301Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits)
    12261302{
     
    12511327
    12521328/**
    1253 *
    1254 */
     1329 *
     1330 */
    12551331void TAppEncTop::rateStatsAccum(const AccessUnit& au, const std::vector<UInt>& annexBsizes)
    12561332{
     
    12641340    case NAL_UNIT_CODED_SLICE_TRAIL_R:
    12651341    case NAL_UNIT_CODED_SLICE_TRAIL_N:
    1266     case NAL_UNIT_CODED_SLICE_TLA:
     1342    case NAL_UNIT_CODED_SLICE_TLA_R:
    12671343    case NAL_UNIT_CODED_SLICE_TSA_N:
    12681344    case NAL_UNIT_CODED_SLICE_STSA_R:
    12691345    case NAL_UNIT_CODED_SLICE_STSA_N:
    1270     case NAL_UNIT_CODED_SLICE_BLA:
    1271     case NAL_UNIT_CODED_SLICE_BLANT:
     1346    case NAL_UNIT_CODED_SLICE_BLA_W_LP:
     1347    case NAL_UNIT_CODED_SLICE_BLA_W_RADL:
    12721348    case NAL_UNIT_CODED_SLICE_BLA_N_LP:
    1273     case NAL_UNIT_CODED_SLICE_IDR:
     1349    case NAL_UNIT_CODED_SLICE_IDR_W_RADL:
    12741350    case NAL_UNIT_CODED_SLICE_IDR_N_LP:
    12751351    case NAL_UNIT_CODED_SLICE_CRA:
    12761352    case NAL_UNIT_CODED_SLICE_RADL_N:
    1277     case NAL_UNIT_CODED_SLICE_DLP:
     1353    case NAL_UNIT_CODED_SLICE_RADL_R:
    12781354    case NAL_UNIT_CODED_SLICE_RASL_N:
    1279     case NAL_UNIT_CODED_SLICE_TFD:
     1355    case NAL_UNIT_CODED_SLICE_RASL_R:
    12801356    case NAL_UNIT_VPS:
    12811357    case NAL_UNIT_SPS:
  • branches/SHM-2.0-dev/source/Lib/TLibCommon/CommonDef.h

    r125 r133  
    5656// ====================================================================================================================
    5757
    58 #define NV_VERSION        "1.2"                 ///< Current software version
     58#define NV_VERSION        "2.0"                 ///< 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,
  • branches/SHM-2.0-dev/source/Lib/TLibCommon/NAL.h

    r125 r133  
    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
  • branches/SHM-2.0-dev/source/Lib/TLibCommon/SEI.cpp

    r127 r133  
    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)
  • branches/SHM-2.0-dev/source/Lib/TLibCommon/SEI.h

    r125 r133  
    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//! \}
  • branches/SHM-2.0-dev/source/Lib/TLibCommon/TComBitStream.cpp

    r125 r133  
    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
  • branches/SHM-2.0-dev/source/Lib/TLibCommon/TComBitStream.h

    r125 r133  
    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
  • branches/SHM-2.0-dev/source/Lib/TLibCommon/TComLoopFilter.cpp

    r125 r133  
    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++ )
  • branches/SHM-2.0-dev/source/Lib/TLibCommon/TComLoopFilter.h

    r125 r133  
    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
  • branches/SHM-2.0-dev/source/Lib/TLibCommon/TComPic.cpp

    r125 r133  
    559559}
    560560
    561 Void TComPic:: copyUpsampledPictureYuv(TComPicYuv*   pcPicYuvIn, TComPicYuv*   pcPicYuvOut)
     561Void TComPic::copyUpsampledPictureYuv(TComPicYuv*   pcPicYuvIn, TComPicYuv*   pcPicYuvOut)
    562562{
    563563  Int upsampledRowWidthLuma = pcPicYuvOut->getStride(); // 2 * pcPicYuvOut->getLumaMargin() + pcPicYuvOut->getWidth();
  • branches/SHM-2.0-dev/source/Lib/TLibCommon/TComPicYuv.cpp

    r125 r133  
    6060  m_piPicOrgU       = NULL;
    6161  m_piPicOrgV       = NULL;
     62 
    6263  m_bIsBorderExtended = false;
    6364}
  • branches/SHM-2.0-dev/source/Lib/TLibCommon/TComPrediction.cpp

    r125 r133  
    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    {
  • branches/SHM-2.0-dev/source/Lib/TLibCommon/TComRom.cpp

    r125 r133  
    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];
  • branches/SHM-2.0-dev/source/Lib/TLibCommon/TComSlice.cpp

    r125 r133  
    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 
    117125#if REF_LIST_BUGFIX
     
    120128  initEqualRef();
    121129 
     130#if L0034_COMBINED_LIST_CLEANUP
     131  for ( Int idx = 0; idx < MAX_NUM_REF; idx++ )
     132  {
     133    m_list1IdxToList0Idx[idx] = -1;
     134  }
     135#else
    122136  for(Int iNumCount = 0; iNumCount < MAX_NUM_REF_LC; iNumCount++)
    123137  {
     
    129143    m_iRefIdxOfL1FromRefIdxOfL0[iNumCount] = -1;
    130144  }   
     145#endif
    131146  for(Int iNumCount = 0; iNumCount < MAX_NUM_REF; iNumCount++)
    132147  {
     
    136151    m_aiRefPOCList  [1][iNumCount] = 0;
    137152  }
    138   resetWpScaling(m_weightPredTable);
     153  resetWpScaling();
    139154  initWpAcDcParam();
    140155  m_saoEnabledFlag = false;
     
    173188  m_colRefIdx = 0;
    174189  initEqualRef();
     190#if !L0034_COMBINED_LIST_CLEANUP
    175191  m_bNoBackPredFlag = false;
    176192  m_bRefPicListCombinationFlag = false;
    177193  m_bRefPicListModificationFlagLC = false;
     194#endif
    178195  m_bCheckLDC = false;
    179196  m_iSliceQpDeltaCb = 0;
    180197  m_iSliceQpDeltaCr = 0;
    181198
     199#if !L0034_COMBINED_LIST_CLEANUP
    182200  m_aiNumRefIdx[REF_PIC_LIST_C]      = 0;
     201#endif
    183202
    184203  m_maxNumMergeCand = MRG_MAX_NUM_CANDS;
     
    194213Bool TComSlice::getRapPicFlag()
    195214{
    196   return getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR
     215  return getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL
    197216      || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP
    198217      || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP
    199       || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT
    200       || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA
     218      || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
     219      || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
    201220      || getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA;
    202221}
     
    213232}
    214233
    215 Void  TComSlice::sortPicList        (TComList<TComPic*>& rcListPic)
     234Void  TComSlice::sortPicList(TComList<TComPic*>& rcListPic)
    216235{
    217236  TComPic*    pcPicExtract;
     
    268287
    269288
    270 TComPic* TComSlice::xGetLongTermRefPic (TComList<TComPic*>& rcListPic,
    271                                         Int                 poc)
     289TComPic* TComSlice::xGetLongTermRefPic(TComList<TComPic*>& rcListPic, Int poc, Bool pocHasMsb)
    272290{
    273291  TComList<TComPic*>::iterator  iterPic = rcListPic.begin(); 
    274292  TComPic*                      pcPic = *(iterPic);
    275293  TComPic*                      pcStPic = pcPic;
     294 
     295  Int pocCycle = 1 << getSPS()->getBitsForPOC();
     296  if (!pocHasMsb)
     297  {
     298    poc = poc % pocCycle;
     299  }
     300 
    276301  while ( iterPic != rcListPic.end() )
    277302  {
    278303    pcPic = *(iterPic);
    279     if(pcPic && (pcPic->getPOC()%(1<<getSPS()->getBitsForPOC())) == (poc%(1<<getSPS()->getBitsForPOC())))
    280     {
    281       if(pcPic->getIsLongTerm())
     304    if (pcPic && pcPic->getPOC()!=this->getPOC() && pcPic->getSlice( 0 )->isReferenced())
     305    {
     306      Int picPoc = pcPic->getPOC();
     307      if (!pocHasMsb)
     308      {
     309        picPoc = picPoc % pocCycle;
     310      }
     311     
     312      if (poc == picPoc)
     313      {
     314       if (pcPic->getIsLongTerm())
    282315      {
    283316        return pcPic;
     
    289322      break;
    290323    }
     324    }
    291325
    292326    iterPic++;
    293327  }
     328 
    294329  return  pcStPic;
    295330}
    296331
    297 Void TComSlice::setRefPOCList       ()
     332Void TComSlice::setRefPOCList()
    298333{
    299334  for (Int iDir = 0; iDir < 2; iDir++)
     
    307342}
    308343
     344#if L0034_COMBINED_LIST_CLEANUP
     345Void TComSlice::setList1IdxToList0Idx()
     346{
     347  Int idxL0, idxL1;
     348  for ( idxL1 = 0; idxL1 < getNumRefIdx( REF_PIC_LIST_1 ); idxL1++ )
     349  {
     350    m_list1IdxToList0Idx[idxL1] = -1;
     351    for ( idxL0 = 0; idxL0 < getNumRefIdx( REF_PIC_LIST_0 ); idxL0++ )
     352    {
     353      if ( m_apcRefPicList[REF_PIC_LIST_0][idxL0]->getPOC() == m_apcRefPicList[REF_PIC_LIST_1][idxL1]->getPOC() )
     354      {
     355        m_list1IdxToList0Idx[idxL1] = idxL0;
     356        break;
     357      }
     358    }
     359  }
     360}
     361#else
    309362Void TComSlice::generateCombinedList()
    310363{
     
    369422  }
    370423}
    371 
    372 Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic)
    373 {
     424#endif
     425
     426#if FIX1071
     427Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr )
     428#else
     429Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic )
     430#endif
     431{
     432#if FIX1071
     433  if (!checkNumPocTotalCurr)
     434#endif
     435  {
    374436#if REF_IDX_FRAMEWORK
    375437  if( m_eSliceType == I_SLICE || ( getSPS()->getLayerId() &&
    376       (getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA) &&
     438      (getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP) &&
    377439      (getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) ) )
    378440#else
     
    388450  m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0);
    389451  m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1);
     452  }
    390453
    391454  TComPic*  pcRefPic= NULL;
     
    410473    }
    411474  }
     475 
    412476  for(; i < m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures(); i++)
    413477  {
     
    422486    }
    423487  }
     488 
    424489  for(i = m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()+m_pcRPS->getNumberOfLongtermPictures()-1; i > m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()-1 ; i--)
    425490  {
    426491    if(m_pcRPS->getUsed(i))
    427492    {
    428       pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i));
     493      pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i));
    429494      pcRefPic->setIsLongTerm(1);
    430495      pcRefPic->getPicYuvRec()->extendPicBorder();
     
    434499    if(pcRefPic==NULL)
    435500    {
    436       pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i));
     501      pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i));
    437502    }
    438503    pcRefPic->setCheckLTMSBPresent(m_pcRPS->getCheckLTMSBPresent(i)); 
     
    443508  TComPic*  rpsCurrList1[MAX_NUM_REF+1];
    444509  Int numPocTotalCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr;
    445 
    446   {
     510#if FIX1071
     511  if (checkNumPocTotalCurr)
     512  {
     513    // 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:
     514    // – If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0.
     515    // – Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0.
     516    if (getRapPicFlag())
     517    {
     518      assert(numPocTotalCurr == 0);
     519    }
     520
     521    if (m_eSliceType == I_SLICE)
     522  {
     523      ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList));
     524      ::memset( m_aiNumRefIdx,   0, sizeof ( m_aiNumRefIdx ));
     525     
     526      return;
     527    }
     528   
     529    assert(numPocTotalCurr != 0);
     530   
     531    m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0);
     532    m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1);
     533  }
     534#endif
     535 
    447536    Int cIdx = 0;
    448537    for ( i=0; i<NumPocStCurr0; i++, cIdx++)
     
    458547      rpsCurrList0[cIdx] = RefPicSetLtCurr[i];
    459548    }
    460   }
    461549
    462550  if (m_eSliceType==B_SLICE)
    463551  {
    464     Int cIdx = 0;
     552    cIdx = 0;
    465553    for ( i=0; i<NumPocStCurr1; i++, cIdx++)
    466554    {
     
    509597  }
    510598
    511   if(this->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA && this->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA)
     599  if(this->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && this->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA)
     600  {
    512601    return;
     602  }
    513603
    514604  TComRefPicListModification* refPicListModification = this->getRefPicListModification();
     
    589679
    590680  //temporal reference pictures
    591   if( !(getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA && getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) )
     681  if( !(getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) )
    592682  {
    593683    for(i=0; i < m_pcRPS->getNumberOfNegativePictures(); i++)
     
    619709      if(m_pcRPS->getUsed(i))
    620710      {
    621         pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i));
     711        pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i));
    622712        pcRefPic->setIsLongTerm(1);
    623713        pcRefPic->getPicYuvRec()->extendPicBorder();
     
    627717      if(pcRefPic==NULL)
    628718      {
    629         pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i));
     719        pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i));
    630720      }
    631721      pcRefPic->setCheckLTMSBPresent(m_pcRPS->getCheckLTMSBPresent(i)); 
     
    636726#if REF_IDX_MFM
    637727  assert(m_aiNumILRRefIdx == 1);
    638   if(!(getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA && getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) && getSPS()->getMFMEnabledFlag())
     728  if(!(getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) && getSPS()->getMFMEnabledFlag())
    639729  {
    640730    ilpPic[0]->copyUpsampledMvField(getBaseColPic());
     
    672762  {
    673763    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++)
     764    {
     765      refPicListTemp0[cIdx] = RefPicSetStCurr0[ i ];
     766    }
     767    for ( i=0; i<NumPocStCurr1 && cIdx<numRpsCurrTempList0; cIdx++,i++)
     768    {
     769      refPicListTemp0[cIdx] = RefPicSetStCurr1[ i ];
     770    }
     771    for ( i=0; i<NumPocLtCurr && cIdx<numRpsCurrTempList0; cIdx++,i++)
     772    {
    678773      refPicListTemp0[cIdx] = RefPicSetLtCurr[ i ];
     774    }
    679775    for ( i=0; i<m_aiNumILRRefIdx && cIdx<numRpsCurrTempList0; cIdx++,i++)
     776    {
    680777      refPicListTemp0[cIdx] = ilpPic[ i ];
     778    }
    681779  }
    682780  cIdx = 0;
    683781  while (cIdx<numRpsCurrTempList1 && m_eSliceType==B_SLICE)
    684782  {
    685     for ( i=0; i<NumPocStCurr1 && cIdx<numRpsCurrTempList1; cIdx++,i++)
     783    for ( i=0; i<NumPocStCurr1 && cIdx<numRpsCurrTempList1; cIdx++,i++)
     784    {
    686785      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++)
     786    }
     787    for ( i=0; i<NumPocStCurr0 && cIdx<numRpsCurrTempList1; cIdx++,i++)
     788    {
     789      refPicListTemp1[cIdx] = RefPicSetStCurr0[ i ];
     790    }
     791    for ( i=0; i<NumPocLtCurr && cIdx<numRpsCurrTempList1; cIdx++,i++)
     792    {
    690793      refPicListTemp1[cIdx] = RefPicSetLtCurr[ i ];
     794    }
    691795    for ( i=0; i<m_aiNumILRRefIdx && cIdx<numRpsCurrTempList1; cIdx++,i++)
     796    {
    692797      refPicListTemp1[cIdx] = ilpPic[ i ];
     798    }
    693799  }
    694800  ::memset(m_bIsUsedAsLongTerm, 0, sizeof(m_bIsUsedAsLongTerm));
     
    724830#if REF_IDX_FRAMEWORK
    725831  if( m_eSliceType == I_SLICE || ( getSPS()->getLayerId() &&
    726     (getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA) &&
     832    (getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP) &&
    727833    (getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) ) )
    728834#else
     
    793899}
    794900
    795 Void TComSlice::checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, Bool& prevRAPisBLA)
     901Void TComSlice::checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, Bool& prevRAPisBLA, TComList<TComPic *>& rcListPic)
    796902{
    797903  for(Int i = 0; i < pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i++)
     
    806912    if(pocCRA < MAX_UINT && getPOC() > pocCRA)
    807913    {
     914      if (!pReferencePictureSet->getCheckLTMSBPresent(i))
     915      {
     916        assert(xGetLongTermRefPic(rcListPic, pReferencePictureSet->getPOC(i), false)->getPOC() >= pocCRA);
     917      }
     918      else
     919      {
    808920      assert(pReferencePictureSet->getPOC(i) >= pocCRA);
    809921    }
    810922  }
    811   if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) // IDR picture found
     923  }
     924  if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) // IDR picture found
    812925  {
    813926    pocCRA = getPOC();
     
    819932    prevRAPisBLA = false;
    820933  }
    821   else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA
    822          || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT
     934  else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
     935         || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
    823936         || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) // BLA picture found
    824937  {
     
    851964  Int pocCurr = getPOC();
    852965
    853   if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA
    854     || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT
     966  if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
     967    || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
    855968    || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP
    856     || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR
     969    || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL
    857970    || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP )  // IDR or BLA picture
    858971  {
     
    866979      iterPic++;
    867980    }
    868     if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA
    869       || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT
     981    if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
     982      || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
    870983      || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP )
    871984    {
     
    881994      {
    882995        rpcPic = *(iterPic);
    883         if (rpcPic->getPOC() != pocCurr && rpcPic->getPOC() != pocCRA) rpcPic->getSlice(0)->setReferenced(false);
     996        if (rpcPic->getPOC() != pocCurr && rpcPic->getPOC() != pocCRA)
     997        {
     998          rpcPic->getSlice(0)->setReferenced(false);
     999        }
    8841000        iterPic++;
    8851001      }
     
    9121028  m_deblockingFilterTcOffsetDiv2 = pSrc->m_deblockingFilterTcOffsetDiv2;
    9131029 
     1030#if L0034_COMBINED_LIST_CLEANUP
     1031  for (i = 0; i < 2; i++)
     1032#else
    9141033  for (i = 0; i < 3; i++)
     1034#endif
    9151035  {
    9161036    m_aiNumRefIdx[i]     = pSrc->m_aiNumRefIdx[i];
    9171037  }
    9181038
     1039#if L0034_COMBINED_LIST_CLEANUP
     1040  for (i = 0; i < MAX_NUM_REF; i++)
     1041  {
     1042    m_list1IdxToList0Idx[i] = pSrc->m_list1IdxToList0Idx[i];
     1043  }
     1044#else
    9191045  for (i = 0; i < 2; i++)
    9201046  {
     
    9331059  m_bRefPicListModificationFlagLC = pSrc->m_bRefPicListModificationFlagLC;
    9341060  m_bRefPicListCombinationFlag    = pSrc->m_bRefPicListCombinationFlag;
     1061#endif
    9351062  m_bCheckLDC             = pSrc->m_bCheckLDC;
    9361063  m_iSliceQpDelta        = pSrc->m_iSliceQpDelta;
     
    9841111  }
    9851112
     1113#if !L0034_COMBINED_LIST_CLEANUP
    9861114  m_bNoBackPredFlag      = pSrc->m_bNoBackPredFlag;
     1115#endif
    9871116  m_uiTLayer                      = pSrc->m_uiTLayer;
    9881117  m_bTLayerSwitchingFlag          = pSrc->m_bTLayerSwitchingFlag;
     
    10181147
    10191148Int TComSlice::m_prevPOC = 0;
     1149
    10201150/** Function for setting the slice's temporal layer ID and corresponding temporal_layer_switching_point_flag.
    10211151 * \param uiTLayer Temporal layer ID of the current slice
     
    10781208  Int i, isReference;
    10791209
    1080   Int j = 0;
    10811210  // loop through all pictures in the reference picture buffer
    10821211  TComList<TComPic*>::iterator iterPic = rcListPic.begin();
    10831212  while ( iterPic != rcListPic.end())
    10841213  {
    1085     j++;
    10861214    rpcPic = *(iterPic++);
     1215
     1216    if(!rpcPic->getSlice( 0 )->isReferenced())
     1217    {
     1218      continue;
     1219    }
    10871220
    10881221    isReference = 0;
     
    11231256    {           
    11241257      rpcPic->getSlice( 0 )->setReferenced( false );   
     1258      rpcPic->setUsedByCurr(0);
    11251259      rpcPic->setIsLongTerm(0);
    11261260    }
     
    11281262    assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getTLayer()<=this->getTLayer());
    11291263    //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)
     1264    if(this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TLA_R || this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N)
    11311265    {
    11321266      assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getTLayer()<this->getTLayer());
     
    11451279{
    11461280  TComPic* rpcPic;
    1147   Int i, isAvailable, j;
     1281  Int i, isAvailable;
    11481282  Int atLeastOneLost = 0;
    11491283  Int atLeastOneRemoved = 0;
     
    11541288  for(i=pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i<pReferencePictureSet->getNumberOfPictures();i++)
    11551289  {
    1156     j = 0;
    11571290    isAvailable = 0;
    11581291    // loop through all pictures in the reference picture buffer
     
    11601293    while ( iterPic != rcListPic.end())
    11611294    {
    1162       j++;
    11631295      rpcPic = *(iterPic++);
    11641296      if(pReferencePictureSet->getCheckLTMSBPresent(i)==true)
     
    11831315      while ( iterPic != rcListPic.end())
    11841316      {
    1185         j++;
    11861317        rpcPic = *(iterPic++);
    11871318
    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())
     1319        Int pocCycle = 1 << rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC();
     1320        Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC();
     1321        Int refPoc = pReferencePictureSet->getPOC(i);
     1322        if (!pReferencePictureSet->getCheckLTMSBPresent(i))
     1323        {
     1324          curPoc = curPoc % pocCycle;
     1325          refPoc = refPoc % pocCycle;
     1326        }
     1327       
     1328        if (rpcPic->getSlice(0)->isReferenced() && curPoc == refPoc)
    11891329        {
    11901330          isAvailable = 1;
     
    12241364  for(i=0;i<pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i++)
    12251365  {
    1226     j = 0;
    12271366    isAvailable = 0;
    12281367    // loop through all pictures in the reference picture buffer
     
    12301369    while ( iterPic != rcListPic.end())
    12311370    {
    1232       j++;
    12331371      rpcPic = *(iterPic++);
    12341372
     
    12471385        {
    12481386          if(printErrors)
     1387          {
    12491388            printf("\nShort-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i));
     1389          }
    12501390          atLeastOneRemoved = 1;
    12511391        }
     
    12531393        {
    12541394          if(printErrors)
     1395          {
    12551396            printf("\nShort-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i));
     1397          }
    12561398          atLeastOneLost = 1;
    12571399          iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i);
     
    13991541 * \returns Void
    14001542 */
    1401 Void  TComSlice::resetWpScaling(wpScalingParam  wp[2][MAX_NUM_REF][3])
     1543Void  TComSlice::resetWpScaling()
    14021544{
    14031545  for ( Int e=0 ; e<2 ; e++ )
     
    14071549      for ( Int yuv=0 ; yuv<3 ; yuv++ )
    14081550      {
    1409         wpScalingParam  *pwp = &(wp[e][i][yuv]);
     1551        wpScalingParam  *pwp = &(m_weightPredTable[e][i][yuv]);
    14101552        pwp->bPresentFlag      = false;
    14111553        pwp->uiLog2WeightDenom = 0;
     
    14231565Void  TComSlice::initWpScaling()
    14241566{
    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 {
    14341567  for ( Int e=0 ; e<2 ; e++ )
    14351568  {
     
    14381571      for ( Int yuv=0 ; yuv<3 ; yuv++ )
    14391572      {
    1440         wpScalingParam  *pwp = &(wp[e][i][yuv]);
    1441         if ( !pwp->bPresentFlag ) {
     1573        wpScalingParam  *pwp = &(m_weightPredTable[e][i][yuv]);
     1574        if ( !pwp->bPresentFlag )
     1575        {
    14421576          // Inferring values not present :
    14431577          pwp->iWeight = (1 << pwp->uiLog2WeightDenom);
     
    14821616  {
    14831617    m_numReorderPics[i] = 0;
     1618#if L0323_DPB
     1619    m_uiMaxDecPicBuffering[i] = 1;
     1620#else
    14841621    m_uiMaxDecPicBuffering[i] = 0;
     1622#endif
    14851623    m_uiMaxLatencyIncrease[i] = 0;
    14861624  }
     
    15161654TComVPS::~TComVPS()
    15171655{
    1518   if( m_hrdParameters    != NULL )     delete m_hrdParameters;
    1519   if( m_hrdOpSetIdx      != NULL )     delete m_hrdOpSetIdx;
    1520   if( m_cprmsPresentFlag != NULL )     delete m_cprmsPresentFlag;
     1656  if( m_hrdParameters    != NULL )     delete[] m_hrdParameters;
     1657  if( m_hrdOpSetIdx      != NULL )     delete[] m_hrdOpSetIdx;
     1658  if( m_cprmsPresentFlag != NULL )     delete[] m_cprmsPresentFlag;
    15211659}
    15221660
     
    15331671, m_picWidthInLumaSamples     (352)
    15341672, m_picHeightInLumaSamples    (288)
     1673, m_log2MinCodingBlockSize    (  0)
     1674, m_log2DiffMaxMinCodingBlockSize (0)
    15351675, m_uiMaxCUWidth              ( 32)
    15361676, m_uiMaxCUHeight             ( 32)
    15371677, m_uiMaxCUDepth              (  3)
    1538 , m_uiMinTrDepth              (  0)
    1539 , m_uiMaxTrDepth              (  1)
    15401678, m_bLongTermRefsPresent      (false)
    15411679, m_uiQuadtreeTULog2MaxSize   (  0)
     
    15471685, m_pcmLog2MaxSize            (  5)
    15481686, m_uiPCMLog2MinSize          (  7)
     1687#if !L0034_COMBINED_LIST_CLEANUP
    15491688, m_bUseLComb                 (false)
     1689#endif
    15501690, m_bitDepthY                 (  8)
    15511691, m_bitDepthC                 (  8)
     
    15721712  {
    15731713    m_uiMaxLatencyIncrease[i] = 0;
     1714#if L0323_DPB
     1715    m_uiMaxDecPicBuffering[i] = 1;
     1716#else
    15741717    m_uiMaxDecPicBuffering[i] = 0;
     1718#endif
    15751719    m_numReorderPics[i]       = 0;
    15761720  }
     
    15911735  m_RPSList.create(numRPS);
    15921736}
     1737
    15931738Void TComSPS::setHrdParameters( UInt frameRate, UInt numDU, UInt bitRate, Bool randomAccess )
    15941739{
     
    18351980  return m_POC[bufferNum];
    18361981}
     1982
    18371983Void TComReferencePictureSet::setPOC(Int bufferNum, Int POC)
    18381984{
    18391985  m_POC[bufferNum] = POC;
    18401986}
     1987
    18411988Bool TComReferencePictureSet::getCheckLTMSBPresent(Int bufferNum)
    18421989{
    18431990  return m_bCheckLTMSB[bufferNum];
    18441991}
     1992
    18451993Void TComReferencePictureSet::setCheckLTMSBPresent(Int bufferNum, Bool b)
    18461994{
     
    20222170  return (defaultCounter == (SCALING_LIST_NUM * SCALING_LIST_SIZE_NUM - 4)) ? false : true; // -4 for 32x32
    20232171}
     2172
    20242173/** get scaling matrix from RefMatrixID
    20252174 * \param sizeId size index
     
    20312180  ::memcpy(getScalingListAddress(sizeId, listId),((listId == refListId)? getScalingListDefaultAddress(sizeId, refListId): getScalingListAddress(sizeId, refListId)),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]));
    20322181}
     2182
    20332183/** parse syntax infomation
    20342184 *  \param pchFile syntax infomation
     
    21232273  m_scalingListCoef[SCALING_LIST_32x32][3] = m_scalingListCoef[SCALING_LIST_32x32][1]; // copy address for 32x32
    21242274}
     2275
    21252276/** destroy quantization matrix array
    21262277 */
     
    21352286  }
    21362287}
     2288
    21372289/** get default address of quantization matrix
    21382290 * \param sizeId size index
     
    21642316  return src;
    21652317}
     2318
    21662319/** process of default matrix
    21672320 * \param sizeId size index
     
    21732326  setScalingListDC(sizeId,listId,SCALING_LIST_DC);
    21742327}
     2328
    21752329/** check DC value of matrix for default matrix signaling
    21762330 */
     
    22402394//! activate a PPS and depending on isIDR parameter also SPS and VPS
    22412395//! \returns true, if activation is successful
    2242 Bool ParameterSetManager::activatePPS(Int ppsId, Bool isIDR)
     2396Bool ParameterSetManager::activatePPS(Int ppsId, Bool isIRAP)
    22432397{
    22442398  TComPPS *pps = m_ppsMap.getPS(ppsId);
     
    22462400  {
    22472401    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.");
     2402    if (!isIRAP && (spsId != m_activeSPSId))
     2403    {
     2404      printf("Warning: tried to activate PPS referring to a inactive SPS at non-IRAP.");
    22512405      return false;
    22522406    }
     
    22552409    {
    22562410      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.");
     2411      if (!isIRAP && (vpsId != m_activeVPSId))
     2412      {
     2413        printf("Warning: tried to activate PPS referring to a inactive VPS at non-IRAP.");
    22602414        return false;
    22612415      }
     
    24032557    assert(iRefPicNum == 1);
    24042558#if RAP_MFM_INIT
    2405     if(!(getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA && getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) && getSPS()->getMFMEnabledFlag())
     2559    if(!(getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) && getSPS()->getMFMEnabledFlag())
    24062560#else
    24072561    if( getPOC() != 0 )
  • branches/SHM-2.0-dev/source/Lib/TLibCommon/TComSlice.h

    r125 r133  
    908908  UInt        m_picHeightInLumaSamples;
    909909 
    910   Window      m_conformanceWindow;
    911 
     910  Int         m_log2MinCodingBlockSize;
     911  Int         m_log2DiffMaxMinCodingBlockSize;
    912912  UInt        m_uiMaxCUWidth;
    913913  UInt        m_uiMaxCUHeight;
    914914  UInt        m_uiMaxCUDepth;
    915   UInt        m_uiMinTrDepth;
    916   UInt        m_uiMaxTrDepth;
     915
     916  Window      m_conformanceWindow;
     917
    917918  TComRPSList m_RPSList;
    918919  Bool        m_bLongTermRefsPresent;
     
    930931  Bool        m_useAMP;
    931932
     933#if !L0034_COMBINED_LIST_CLEANUP
    932934  Bool        m_bUseLComb;
     935#endif
    933936 
    934937  // Parameter
     
    10091012  Bool getUsedByCurrPicLtSPSFlag(Int i)        {return m_usedByCurrPicLtSPSFlag[i];}
    10101013  Void setUsedByCurrPicLtSPSFlag(Int i, Bool x)      { m_usedByCurrPicLtSPSFlag[i] = x;}
     1014
     1015  Int  getLog2MinCodingBlockSize() const           { return m_log2MinCodingBlockSize; }
     1016  Void setLog2MinCodingBlockSize(Int val)          { m_log2MinCodingBlockSize = val; }
     1017  Int  getLog2DiffMaxMinCodingBlockSize() const    { return m_log2DiffMaxMinCodingBlockSize; }
     1018  Void setLog2DiffMaxMinCodingBlockSize(Int val)   { m_log2DiffMaxMinCodingBlockSize = val; }
     1019
    10111020  Void setMaxCUWidth  ( UInt u ) { m_uiMaxCUWidth = u;      }
    10121021  UInt getMaxCUWidth  ()         { return  m_uiMaxCUWidth;  }
     
    10251034  Bool getUseAMP() { return m_useAMP; }
    10261035  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;  }
    10311036  Void setQuadtreeTULog2MaxSize( UInt u ) { m_uiQuadtreeTULog2MaxSize = u;    }
    10321037  UInt getQuadtreeTULog2MaxSize()         { return m_uiQuadtreeTULog2MaxSize; }
     
    10501055 
    10511056  // Tool list
     1057#if !L0034_COMBINED_LIST_CLEANUP
    10521058  Void setUseLComb    (Bool b)   { m_bUseLComb = b;         }
    10531059  Bool getUseLComb    ()         { return m_bUseLComb;      }
     1060#endif
    10541061
    10551062  Bool getUseLossless ()         { return m_useLossless; }
     
    13701377  Int         m_deblockingFilterBetaOffsetDiv2;    //< beta offset for deblocking filter
    13711378  Int         m_deblockingFilterTcOffsetDiv2;      //< tc offset for deblocking filter
    1372  
    1373   Int         m_aiNumRefIdx   [3];    //  for multiple reference of current slice
    1374 
    13751379#if REF_LIST_BUGFIX
    13761380  Int         m_aiNumILRRefIdx;       //< for inter-layer reference picture ser
    13771381#endif
    1378 
     1382#if L0034_COMBINED_LIST_CLEANUP
     1383  Int         m_list1IdxToList0Idx[MAX_NUM_REF];
     1384  Int         m_aiNumRefIdx   [2];    //  for multiple reference of current slice
     1385#else
     1386  Int         m_aiNumRefIdx   [3];    //  for multiple reference of current slice
    13791387  Int         m_iRefIdxOfLC[2][MAX_NUM_REF_LC];
    13801388  Int         m_eListIdFromIdxOfLC[MAX_NUM_REF_LC];
     
    13841392  Bool        m_bRefPicListModificationFlagLC;
    13851393  Bool        m_bRefPicListCombinationFlag;
     1394#endif
    13861395
    13871396  Bool        m_bCheckLDC;
     
    14211430
    14221431  Bool        m_abEqualRef  [2][MAX_NUM_REF][MAX_NUM_REF];
    1423  
     1432#if !L0034_COMBINED_LIST_CLEANUP
    14241433  Bool        m_bNoBackPredFlag;
     1434#endif
    14251435  UInt        m_uiTLayer;
    14261436#if SVC_EXTENSION
     
    15331543  Bool      getMvdL1ZeroFlag ()                                  { return m_bLMvdL1Zero;    }
    15341544  Int       getNumRpsCurrTempList();
     1545#if L0034_COMBINED_LIST_CLEANUP
     1546  Int       getList1IdxToList0Idx ( Int list1Idx )               { return m_list1IdxToList0Idx[list1Idx]; }
     1547#else
    15351548  Int       getRefIdxOfLC       (RefPicList e, Int iRefIdx)     { return m_iRefIdxOfLC[e][iRefIdx];           }
    15361549  Int       getListIdFromIdxOfLC(Int iRefIdx)                   { return m_eListIdFromIdxOfLC[iRefIdx];       }
     
    15421555  Bool      getRefPicListCombinationFlag()                      {return m_bRefPicListCombinationFlag;}
    15431556  Void      setRefPicListCombinationFlag(Bool bflag)            {m_bRefPicListCombinationFlag=bflag;}   
     1557#endif
    15441558  Void      setReferenced(Bool b)                               { m_bRefenced = b; }
    15451559  Bool      isReferenced()                                      { return m_bRefenced; }
    15461560  Void      setPOC              ( Int i )                       { m_iPOC              = i; if(getTLayer()==0) m_prevPOC=i; }
    15471561  Void      setNalUnitType      ( NalUnitType e )               { m_eNalUnitType      = e;      }
    1548   NalUnitType getNalUnitType    ()                              { return m_eNalUnitType;        }
     1562  NalUnitType getNalUnitType    () const                        { return m_eNalUnitType;        }
    15491563  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);
     1564  Bool      getIdrPicFlag       ()                              { return getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP; }
     1565  Bool      isIRAP              () const                        { return (getNalUnitType() >= 16) && (getNalUnitType() <= 23); } 
     1566  Void      checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, Bool& prevRAPisBLA, TComList<TComPic *>& rcListPic);
    15521567  Void      decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic);
    15531568  Void      setSliceType        ( SliceType e )                 { m_eSliceType        = e;      }
     
    15901605#endif
    15911606
     1607#if FIX1071
     1608  Void      setRefPicList       ( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr = false );
     1609#else
    15921610  Void      setRefPicList       ( TComList<TComPic*>& rcListPic );
     1611#endif
    15931612  Void      setRefPOCList       ();
    15941613  Void      setColFromL0Flag    ( UInt colFromL0 ) { m_colFromL0Flag = colFromL0; }
     
    16281647 
    16291648  static Void      sortPicList         ( TComList<TComPic*>& rcListPic );
    1630  
     1649#if L0034_COMBINED_LIST_CLEANUP
     1650  Void setList1IdxToList0Idx();
     1651#else
    16311652  Bool getNoBackPredFlag() { return m_bNoBackPredFlag; }
    16321653  Void setNoBackPredFlag( Bool b ) { m_bNoBackPredFlag = b; }
    16331654  Void generateCombinedList       ();
     1655#endif
    16341656
    16351657  UInt getTLayer             ()                            { return m_uiTLayer;                      }
     
    16791701  Void  getWpScaling    ( RefPicList e, Int iRefIdx, wpScalingParam *&wp);
    16801702
    1681   Void  resetWpScaling  (wpScalingParam  wp[2][MAX_NUM_REF][3]);
    1682   Void  initWpScaling    (wpScalingParam  wp[2][MAX_NUM_REF][3]);
     1703  Void  resetWpScaling  ();
    16831704  Void  initWpScaling   ();
    16841705  inline Bool applyWP   () { return( (m_eSliceType==P_SLICE && m_pcPPS->getUseWP()) || (m_eSliceType==B_SLICE && m_pcPPS->getWPBiPred()) ); }
     
    17201741  TComPic*  xGetRefPic  (TComList<TComPic*>& rcListPic,
    17211742                         Int                 poc);
    1722   TComPic*  xGetLongTermRefPic  (TComList<TComPic*>& rcListPic,
    1723                          Int                 poc);
     1743  TComPic*  xGetLongTermRefPic(TComList<TComPic*>& rcListPic, Int poc, Bool pocHasMsb);
    17241744};// END CLASS DEFINITION TComSlice
    17251745
     
    18051825  //! activate a PPS and depending on isIDR parameter also SPS and VPS
    18061826  //! \returns true, if activation is successful
    1807   Bool activatePPS(Int ppsId, Bool isIDR);
     1827  Bool activatePPS(Int ppsId, Bool isIRAP);
    18081828
    18091829  TComVPS* getActiveVPS(){ return m_vpsMap.getPS(m_activeVPSId); };
  • branches/SHM-2.0-dev/source/Lib/TLibCommon/TComTrQuant.cpp

    r125 r133  
    20072007          }
    20082008         
    2009           if(piQCoef[minPos] == 32767 || piQCoef[minPos] == -32768)
     2009          if(piDstCoeff[minPos] == 32767 || piDstCoeff[minPos] == -32768)
    20102010          {
    20112011            finalChange = -1;
  • branches/SHM-2.0-dev/source/Lib/TLibCommon/TypeDef.h

    r125 r133  
    6565
    6666#define AVC_BASE                         0      ///< YUV BL reading for AVC base SVC
    67 #define REF_IDX_FRAMEWORK                0      ///< inter-layer reference framework
     67#define REF_IDX_FRAMEWORK                1      ///< inter-layer reference framework
    6868
    6969#if SVC_UPSAMPLING
     
    114114//! \ingroup TLibCommon
    115115//! \{
     116
     117#define FIX1071 1 ///< Temporary fix for issue #1071
     118
     119#define L0208_SOP_DESCRIPTION_SEI     1 ///< L0208: add SOP descrioption SEI
     120#define MAX_NUM_PICS_IN_SOP           1024
     121
     122#define K0180_SCALABLE_NESTING_SEI  1   ///JCTVC-K0180 scalable nesting sei message
     123#define MAX_NESTING_NUM_OPS         1024
     124#define MAX_NESTING_NUM_LAYER       64
     125
     126#define J0149_TONE_MAPPING_SEI        1 ///< J0149: Tone mapping information SEI
    116127#define L0363_DU_BIT_RATE             1 ///< L0363: add bit_rate_du_value_minus1 to HRD parameters
    117128#define L0328_SPLICING                1 ///< L0328: splicing support in HRD
     
    138149#define SIGNAL_BITRATE_PICRATE_IN_VPS               0  ///< K0125: Signal bit_rate and pic_rate in VPS
    139150#define L0232_RD_PENALTY           1  ///< L0232: RD-penalty for 32x32 TU for intra in non-intra slices
     151#define L0386_DB_METRIC            1  ///< L0386: non-normative blockiness metric (automatically configures deblocking parameters in bitstream)
     152#define L0323_DPB                     1 ///< L0323: Specification of active reference indices and decoded picture buffer
     153
     154#define L0034_COMBINED_LIST_CLEANUP 1
    140155
    141156#if VPS_EXTN_MASK_AND_DIM_INFO
     
    477492  REF_PIC_LIST_0 = 0,   ///< reference list 0
    478493  REF_PIC_LIST_1 = 1,   ///< reference list 1
     494#if !L0034_COMBINED_LIST_CLEANUP
    479495  REF_PIC_LIST_C = 2,   ///< combined reference list for uni-prediction in B-Slices
     496#endif
    480497  REF_PIC_LIST_X = 100  ///< special mark
    481498};
  • branches/SHM-2.0-dev/source/Lib/TLibDecoder/NALread.cpp

    r125 r133  
    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);
  • branches/SHM-2.0-dev/source/Lib/TLibDecoder/SEIread.cpp

    r125 r133  
    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{
  • branches/SHM-2.0-dev/source/Lib/TLibDecoder/SEIread.h

    r125 r133  
    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};
  • branches/SHM-2.0-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp

    r125 r133  
    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())
     
    746745  for(UInt i = 0; i <= pcVPS->getMaxTLayers()-1; i++)
    747746  {
     747#if L0323_DPB
     748    READ_UVLC( uiCode,  "vps_max_dec_pic_buffering_minus1[i]" );     pcVPS->setMaxDecPicBuffering( uiCode + 1, i );
     749#else
    748750    READ_UVLC( uiCode,  "vps_max_dec_pic_buffering[i]" );     pcVPS->setMaxDecPicBuffering( uiCode, i );
     751#endif
    749752    READ_UVLC( uiCode,  "vps_num_reorder_pics[i]" );          pcVPS->setNumReorderPics( uiCode, i );
    750753    READ_UVLC( uiCode,  "vps_max_latency_increase[i]" );      pcVPS->setMaxLatencyIncrease( uiCode, i );
     
    10741077        iPOCmsb = iPrevPOCmsb;
    10751078      }
    1076       if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA
    1077         || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT
     1079      if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
     1080        || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
    10781081        || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP )
    10791082      {
     
    10841087
    10851088      TComReferencePictureSet* rps;
     1089      rps = rpcSlice->getLocalRPS();
     1090      rpcSlice->setRPS(rps);
    10861091      READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" );
    10871092      if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header
    10881093      {
    1089         rps = rpcSlice->getLocalRPS();
    10901094        parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets());
    1091         rpcSlice->setRPS(rps);
    10921095      }
    10931096      else // use reference to short-term reference picture set in PPS
     
    11061109          uiCode = 0;
    11071110        }
    1108         rpcSlice->setRPS(sps->getRPSList()->getReferencePictureSet(uiCode));
    1109 
    1110         rps = rpcSlice->getRPS();
     1111        memcpy(rps,sps->getRPSList()->getReferencePictureSet(uiCode),sizeof(TComReferencePictureSet));
    11111112      }
    11121113      if(sps->getLongTermRefsPresent())
     
    11311132        rps->setNumberOfLongtermPictures(numOfLtrp);
    11321133        Int maxPicOrderCntLSB = 1 << rpcSlice->getSPS()->getBitsForPOC();
    1133         Int prevLSB = 0, prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;;
     1134        Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;;
    11341135        for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++)
    11351136        {
     
    11581159            READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" );
    11591160            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) )
     1161            //            First LTRP                               || First LTRP from SH
     1162            if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) )
    11621163            {
    11631164              deltaFlag = true;
     
    11841185            rps->setCheckLTMSBPresent(j,false); 
    11851186          }
    1186           prevLSB = pocLsbLt;
    11871187          prevDeltaMSB = deltaPocMSBCycleLT;
    11881188        }
     
    11901190        rps->setNumberOfPictures(offset);       
    11911191      } 
    1192       if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA
    1193         || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT
     1192      if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
     1193        || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
    11941194        || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP )
    11951195      {
     
    14231423        if(!rpcSlice->getDeblockingFilterDisable())
    14241424        {
    1425           READ_SVLC( iCode, "beta_offset_div2" );                       rpcSlice->setDeblockingFilterBetaOffsetDiv2(iCode);
    1426           READ_SVLC( iCode, "tc_offset_div2" );                         rpcSlice->setDeblockingFilterTcOffsetDiv2(iCode);
     1425          READ_SVLC( iCode, "slice_beta_offset_div2" );                       rpcSlice->setDeblockingFilterBetaOffsetDiv2(iCode);
     1426          assert(rpcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 &&
     1427                 rpcSlice->getDeblockingFilterBetaOffsetDiv2() <=  6);
     1428          READ_SVLC( iCode, "slice_tc_offset_div2" );                         rpcSlice->setDeblockingFilterTcOffsetDiv2(iCode);
     1429          assert(rpcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 &&
     1430                 rpcSlice->getDeblockingFilterTcOffsetDiv2() <=  6);
    14271431        }
    14281432      }
     
    14561460  }
    14571461 
    1458   if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() )
    1459   {
    14601462    UInt *entryPointOffset          = NULL;
    14611463    UInt numEntryPointOffsets, offsetLenMinus1;
    1462 
     1464  if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() )
     1465  {
    14631466    READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); rpcSlice->setNumEntryPointOffsets ( numEntryPointOffsets );
    14641467    if (numEntryPointOffsets>0)
     
    14771480#endif
    14781481    }
     1482  }
     1483  else
     1484  {
     1485    rpcSlice->setNumEntryPointOffsets ( 0 );
     1486  }
     1487
     1488  if(pps->getSliceHeaderExtensionPresentFlag())
     1489  {
     1490    READ_UVLC(uiCode,"slice_header_extension_length");
     1491    for(Int i=0; i<uiCode; i++)
     1492    {
     1493      UInt ignore;
     1494      READ_CODE(8,ignore,"slice_header_extension_data_byte");
     1495    }
     1496  }
     1497  m_pcBitstream->readByteAlignment();
     1498
     1499  if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() )
     1500  {
     1501    Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation();
     1502    Int  curEntryPointOffset     = 0;
     1503    Int  prevEntryPointOffset    = 0;
     1504    for (UInt idx=0; idx<numEntryPointOffsets; idx++)
     1505    {
     1506      curEntryPointOffset += entryPointOffset[ idx ];
     1507
     1508      Int emulationPreventionByteCount = 0;
     1509      for ( UInt curByteIdx  = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ )
     1510      {
     1511        if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) &&
     1512             m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) <  ( curEntryPointOffset  + endOfSliceHeaderLocation ) )
     1513        {
     1514          emulationPreventionByteCount++;
     1515        }
     1516      }
     1517
     1518      entryPointOffset[ idx ] -= emulationPreventionByteCount;
     1519      prevEntryPointOffset = curEntryPointOffset;
     1520    }
    14791521
    14801522    if ( pps->getTilesEnabledFlag() )
     
    15121554    }
    15131555  }
    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();
     1556
    15291557  return;
    15301558}
     
    17711799// ====================================================================================================================
    17721800
    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 
    18811801/** parse explicit wp tables
    18821802* \param TComSlice* pcSlice
     
    18951815  // decode delta_luma_log2_weight_denom :
    18961816  READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" );     // ue(v): luma_log2_weight_denom
     1817  assert( uiLog2WeightDenomLuma <= 7 );
    18971818  if( bChroma )
    18981819  {
    18991820    READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" );     // se(v): delta_chroma_log2_weight_denom
    19001821    assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)>=0);
     1822    assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)<=7);
    19011823    uiLog2WeightDenomChroma = (UInt)(iDeltaDenom + uiLog2WeightDenomLuma);
    19021824  }
     
    19371859        Int iDeltaWeight;
    19381860        READ_SVLC( iDeltaWeight, "delta_luma_weight_lX" );  // se(v): delta_luma_weight_l0[i]
     1861        assert( iDeltaWeight >= -128 );
     1862        assert( iDeltaWeight <=  127 );
    19391863        wp[0].iWeight = (iDeltaWeight + (1<<wp[0].uiLog2WeightDenom));
    19401864        READ_SVLC( wp[0].iOffset, "luma_offset_lX" );       // se(v): luma_offset_l0[i]
     1865        assert( wp[0].iOffset >= -128 );
     1866        assert( wp[0].iOffset <=  127 );
    19411867      }
    19421868      else
     
    19531879            Int iDeltaWeight;
    19541880            READ_SVLC( iDeltaWeight, "delta_chroma_weight_lX" );  // se(v): chroma_weight_l0[i][j]
     1881            assert( iDeltaWeight >= -128 );
     1882            assert( iDeltaWeight <=  127 );
    19551883            wp[j].iWeight = (iDeltaWeight + (1<<wp[1].uiLog2WeightDenom));
    19561884
    19571885            Int iDeltaChroma;
    19581886            READ_SVLC( iDeltaChroma, "delta_chroma_offset_lX" );  // se(v): delta_chroma_offset_l0[i][j]
     1887            assert( iDeltaChroma >= -512 );
     1888            assert( iDeltaChroma <=  511 );
    19591889            Int pred = ( 128 - ( ( 128*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) );
    19601890            wp[j].iOffset = Clip3(-128, 127, (iDeltaChroma + pred) );
  • branches/SHM-2.0-dev/source/Lib/TLibDecoder/TDecCAVLC.h

    r125 r133  
    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:
  • branches/SHM-2.0-dev/source/Lib/TLibDecoder/TDecSlice.h

    r125 r133  
    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]; } 
  • branches/SHM-2.0-dev/source/Lib/TLibDecoder/TDecTop.cpp

    r125 r133  
    231231  }
    232232
     233#if L0323_DPB
     234  m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer())+pcSlice->getSPS()->getNumReorderPics(pcSlice->getTLayer());     // m_uiMaxDecPicBuffering has the space for the picture currently being decoded
     235#else
    233236  m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer())+pcSlice->getSPS()->getNumReorderPics(pcSlice->getTLayer()) + 1; // +1 to have space for the picture currently being decoded
     237#endif
    234238  if (m_cListPic.size() < (UInt)m_iMaxRefPicNum)
    235239  {
     
    405409  assert (sps != 0);
    406410
    407   if( false == m_parameterSetManagerDecoder[m_layerId].activatePPS(m_apcSlicePilot->getPPSId(), m_apcSlicePilot->getIdrPicFlag()) )
     411  if( false == m_parameterSetManagerDecoder[m_layerId].activatePPS(m_apcSlicePilot->getPPSId(), m_apcSlicePilot->isIRAP()) )
    408412#else
    409413  m_parameterSetManagerDecoder.applyPrefetchedPS();
     
    415419  assert (sps != 0);
    416420
    417   if (false == m_parameterSetManagerDecoder.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->getIdrPicFlag()))
     421  if (false == m_parameterSetManagerDecoder.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP()))
    418422#endif
    419423  {
    420424    printf ("Parameter set activation failed!");
    421425    assert (0);
     426  }
     427
     428  if( pps->getDependentSliceSegmentsEnabledFlag() )
     429  {
     430    Int NumCtx = pps->getEntropyCodingSyncEnabledFlag()?2:1;
     431
     432    if (m_cSliceDecoder.getCtxMemSize() != NumCtx)
     433    {
     434      m_cSliceDecoder.initCtxMem(NumCtx);
     435      for ( UInt st = 0; st < NumCtx; st++ )
     436      {
     437        TDecSbac* ctx = NULL;
     438        ctx = new TDecSbac;
     439        ctx->init( &m_cBinCABAC );
     440        m_cSliceDecoder.setCtxMem( ctx, st );
     441      }
     442    }
    422443  }
    423444
     
    428449  pps->setMinCuDQPSize( sps->getMaxCUWidth() >> ( pps->getMaxCuDQPDepth()) );
    429450
    430   for (Int i = 0; i < sps->getMaxCUDepth() - g_uiAddCUDepth; i++)
     451  g_bitDepthY     = sps->getBitDepthY();
     452  g_bitDepthC     = sps->getBitDepthC();
     453  g_uiMaxCUWidth  = sps->getMaxCUWidth();
     454  g_uiMaxCUHeight = sps->getMaxCUHeight();
     455  g_uiMaxCUDepth  = sps->getMaxCUDepth();
     456  g_uiAddCUDepth  = max (0, sps->getLog2MinCodingBlockSize() - (Int)sps->getQuadtreeTULog2MinSize() );
     457
     458  for (Int i = 0; i < sps->getLog2DiffMaxMinCodingBlockSize(); i++)
    431459  {
    432460    sps->setAMPAcc( i, sps->getUseAMP() );
    433461  }
    434462
    435   for (Int i = sps->getMaxCUDepth() - g_uiAddCUDepth; i < sps->getMaxCUDepth(); i++)
     463  for (Int i = sps->getLog2DiffMaxMinCodingBlockSize(); i < sps->getMaxCUDepth(); i++)
    436464  {
    437465    sps->setAMPAcc( i, 0 );
     
    439467
    440468  m_cSAO.destroy();
    441   m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight );
    442   m_cLoopFilter.        create( g_uiMaxCUDepth );
     469  m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight() );
     470  m_cLoopFilter.create( sps->getMaxCUDepth() );
    443471}
    444472
     
    467495
    468496  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   }
     497  Bool nonReferenceFlag = (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N ||
     498                           m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N   ||
     499                           m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N  ||
     500                           m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N  ||
     501                           m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N);
     502  m_apcSlicePilot->setTemporalLayerNonReferenceFlag(nonReferenceFlag);
     503 
    475504  m_apcSlicePilot->setReferenced(true); // Putting this as true ensures that picture is referenced the first time it is in an RPS
    476505  m_apcSlicePilot->setTLayerInfo(nalu.m_temporalId);
     
    482511#endif
    483512  if (m_apcSlicePilot->isNextSlice())
    484   {
    485513    // Skip pictures due to random access
    486514    if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay))
     
    493521      return false;
    494522    }
    495   }
    496523
    497524  // exit when a new picture is found
     
    506533  }
    507534#else
    508   if (m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence)
     535  //we should only get a different poc for a new picture (with CTU address==0)
     536  if (m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence && (!m_apcSlicePilot->getSliceCurStartCUAddr()==0))
     537  {
     538    printf ("Warning, the first slice of a picture might have been lost!\n");
     539  }
     540  // exit when a new picture is found
     541  if (m_apcSlicePilot->isNextSlice() && (m_apcSlicePilot->getSliceCurStartCUAddr() == 0 && !m_bFirstSliceInPicture) && !m_bFirstSliceInSequence )
    509542  {
    510543    if (m_prevPOC >= m_pocRandomAccess)
     
    732765  if (bNextSlice)
    733766  {
    734     pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_prevRAPisBLA );
     767    pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_prevRAPisBLA, m_cListPic );
    735768    // Set reference list
    736769#if REF_LIST_BUGFIX
    737770    if (m_layerId == 0)
    738     {
    739       pcSlice->setRefPicList( m_cListPic );
    740     }
     771#endif
     772#if FIX1071
     773    pcSlice->setRefPicList( m_cListPic, true );
    741774#else
    742775    pcSlice->setRefPicList( m_cListPic );
     
    839872    //---------------
    840873    pcSlice->setRefPOCList();
     874#if !L0034_COMBINED_LIST_CLEANUP
    841875    pcSlice->setNoBackPredFlag( false );
    842876    if ( pcSlice->getSliceType() == B_SLICE )
     
    855889      }
    856890    }
     891#endif
    857892  }
    858893
     
    947982{
    948983#if SVC_EXTENSION
    949   if(nalUnitType == NAL_UNIT_SEI_SUFFIX)
     984  if(nalUnitType == NAL_UNIT_SUFFIX_SEI)
    950985  {
    951986    m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder[m_layerId].getActiveSPS() );
     
    9671002  }
    9681003#else
    969   if(nalUnitType == NAL_UNIT_SEI_SUFFIX)
     1004  if(nalUnitType == NAL_UNIT_SUFFIX_SEI)
    9701005  {
    9711006    m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() );
     
    10351070      return false;
    10361071     
    1037     case NAL_UNIT_SEI:
    1038     case NAL_UNIT_SEI_SUFFIX:
     1072    case NAL_UNIT_PREFIX_SEI:
     1073    case NAL_UNIT_SUFFIX_SEI:
    10391074      xDecodeSEI( nalu.m_Bitstream, nalu.m_nalUnitType );
    10401075      return false;
     
    10421077    case NAL_UNIT_CODED_SLICE_TRAIL_R:
    10431078    case NAL_UNIT_CODED_SLICE_TRAIL_N:
    1044     case NAL_UNIT_CODED_SLICE_TLA:
     1079    case NAL_UNIT_CODED_SLICE_TLA_R:
    10451080    case NAL_UNIT_CODED_SLICE_TSA_N:
    10461081    case NAL_UNIT_CODED_SLICE_STSA_R:
    10471082    case NAL_UNIT_CODED_SLICE_STSA_N:
    1048     case NAL_UNIT_CODED_SLICE_BLA:
    1049     case NAL_UNIT_CODED_SLICE_BLANT:
     1083    case NAL_UNIT_CODED_SLICE_BLA_W_LP:
     1084    case NAL_UNIT_CODED_SLICE_BLA_W_RADL:
    10501085    case NAL_UNIT_CODED_SLICE_BLA_N_LP:
    1051     case NAL_UNIT_CODED_SLICE_IDR:
     1086    case NAL_UNIT_CODED_SLICE_IDR_W_RADL:
    10521087    case NAL_UNIT_CODED_SLICE_IDR_N_LP:
    10531088    case NAL_UNIT_CODED_SLICE_CRA:
    10541089    case NAL_UNIT_CODED_SLICE_RADL_N:
    1055     case NAL_UNIT_CODED_SLICE_DLP:
     1090    case NAL_UNIT_CODED_SLICE_RADL_R:
    10561091    case NAL_UNIT_CODED_SLICE_RASL_N:
    1057     case NAL_UNIT_CODED_SLICE_TFD:
     1092    case NAL_UNIT_CODED_SLICE_RASL_R:
    10581093#if SVC_EXTENSION
    10591094      return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay, curLayerId, bNewPOC);
     
    10771112Bool TDecTop::isSkipPictureForBLA(Int& iPOCLastDisplay)
    10781113{
    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))
     1114  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))
    10801115  {
    10811116    iPOCLastDisplay++;
     
    11081143  {
    11091144    if (   m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA
    1110         || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA
     1145        || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
    11111146        || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP
    1112         || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT )
     1147        || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL )
    11131148    {
    11141149      // set the POC random access since we need to skip the reordered pictures in the case of CRA/CRANT/BLA/BLANT.
    11151150      m_pocRandomAccess = m_apcSlicePilot->getPOC();
    11161151    }
    1117     else if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP )
     1152    else if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP )
    11181153    {
    11191154      m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable.
     
    11311166  }
    11321167  // 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))
     1168  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))
    11341169  {
    11351170    iPOCLastDisplay++;
  • branches/SHM-2.0-dev/source/Lib/TLibEncoder/SEIwrite.cpp

    r125 r133  
    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{
  • branches/SHM-2.0-dev/source/Lib/TLibEncoder/SEIwrite.h

    r125 r133  
    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};
  • branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncCavlc.cpp

    r125 r133  
    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" );
     
    583578  for(UInt i=0; i <= pcVPS->getMaxTLayers()-1; i++)
    584579  {
     580#if L0323_DPB
     581    WRITE_UVLC( pcVPS->getMaxDecPicBuffering(i) - 1,       "vps_max_dec_pic_buffering_minus1[i]" );
     582#else
    585583    WRITE_UVLC( pcVPS->getMaxDecPicBuffering(i),           "vps_max_dec_pic_buffering[i]" );
     584#endif
    586585    WRITE_UVLC( pcVPS->getNumReorderPics(i),               "vps_num_reorder_pics[i]" );
    587586    WRITE_UVLC( pcVPS->getMaxLatencyIncrease(i),           "vps_max_latency_increase[i]" );
     
    810809      WRITE_CODE( picOrderCntLSB, pcSlice->getSPS()->getBitsForPOC(), "pic_order_cnt_lsb");
    811810      TComReferencePictureSet* rps = pcSlice->getRPS();
     811     
     812#if FIX1071
     813      // Deal with bitstream restriction stating that:
     814      // – If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0.
     815      // Ideally this process should not be repeated for each slice in a picture
     816      TComReferencePictureSet altRps;
     817      Bool useAltRps = false;
     818      if (pcSlice->getRapPicFlag())
     819      {
     820        for (Int picIdx = 0; !useAltRps && picIdx < rps->getNumberOfPictures(); picIdx++)
     821        {
     822          useAltRps = rps->getUsed(picIdx);
     823        }
     824        if (useAltRps)
     825        {
     826          memcpy(&altRps, rps, sizeof(TComReferencePictureSet));
     827          rps = &altRps;
     828          for (Int picIdx = 0; picIdx < rps->getNumberOfPictures(); picIdx++)
     829          {
     830            rps->setUsed(picIdx, false);
     831          }
     832        }
     833      }
     834
     835      if(pcSlice->getRPSidx() < 0 || useAltRps)
     836#else
    812837      if(pcSlice->getRPSidx() < 0)
     838#endif
    813839      {
    814840        WRITE_FLAG( 0, "short_term_ref_pic_set_sps_flag");
     
    13891415// ====================================================================================================================
    13901416
    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 
    14691417/** code explicit wp tables
    14701418 * \param TComSlice* pcSlice
  • branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncCavlc.h

    r125 r133  
    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 );
  • branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncCfg.h

    r125 r133  
    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;    }
  • branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncGOP.cpp

    r125 r133  
    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;
     
    411530    }
    412531    // Set the nal unit type
    413     pcSlice->setNalUnitType(getNalUnitType(pocCurr));
     532    pcSlice->setNalUnitType(getNalUnitType(pocCurr, m_iLastIDR));
    414533#if IDR_ALIGNMENT
    415534    if (m_layerId > 0)
     
    424543    {
    425544#if IDR_ALIGNMENT
    426       if( pcSlice->getBaseColPic()->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR )
    427       {
    428         pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_IDR);
     545      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 )
     546      {
     547        pcSlice->setNalUnitType(pcSlice->getBaseColPic()->getSlice(0)->getNalUnitType());
    429548      }
    430549      else
     
    434553    if( m_layerId > 0 && !m_pcEncTop->getElRapSliceTypeB() )
    435554    {
    436       if( (pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA) &&
     555      if( (pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP) &&
    437556          (pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) &&
    438557           pcSlice->getSliceType() == B_SLICE )
     
    442561    }
    443562#endif
    444     if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_TRAIL_R)
    445     {
    446       if(pcSlice->getTemporalLayerNonReferenceFlag())
     563    if(pcSlice->getTemporalLayerNonReferenceFlag())
     564    {
     565      if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_TRAIL_R)
    447566      {
    448567        pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TRAIL_N);
     568    }
     569      if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_RADL_R)
     570      {
     571        pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_RADL_N);
     572      }
     573      if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_RASL_R)
     574      {
     575        pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_RASL_N);
    449576      }
    450577    }
     
    471598        else
    472599        {
    473           pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TLA);
     600          pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TLA_R);
    474601        }
    475602      }
     
    527654    if(m_layerId > 0)
    528655    {
    529       if( pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA )
     656      if( pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA )
    530657      {
    531658        pcSlice->setNumRefIdx(REF_PIC_LIST_0, pcSlice->getNumILRRefIdx());
     
    644771      pcSlice->setSliceType ( P_SLICE );
    645772    }
    646 
     773#if !L0034_COMBINED_LIST_CLEANUP
    647774    if (pcSlice->getSliceType() != B_SLICE || !pcSlice->getSPS()->getUseLComb())
    648775    {
     
    656783      pcSlice->setNumRefIdx(REF_PIC_LIST_C, pcSlice->getNumRefIdx(REF_PIC_LIST_0));
    657784    }
     785#endif
    658786
    659787    if (pcSlice->getSliceType() == B_SLICE)
     
    683811      pcSlice->setCheckLDC(bLowDelay); 
    684812    }
     813    else
     814    {
     815      pcSlice->setCheckLDC(true); 
     816    }
    685817
    686818    uiColDir = 1-uiColDir;
     
    689821    pcSlice->setRefPOCList();
    690822
     823#if L0034_COMBINED_LIST_CLEANUP
     824    pcSlice->setList1IdxToList0Idx();
     825#else
    691826    pcSlice->setNoBackPredFlag( false );
    692827    if ( pcSlice->getSliceType() == B_SLICE && !pcSlice->getRefPicListCombinationFlag())
     
    712847    }
    713848    pcSlice->generateCombinedList();
     849#endif
    714850
    715851    if (m_pcEncTop->getTMVPModeId() == 2)
     
    10271163    Bool bLFCrossTileBoundary = pcSlice->getPPS()->getLoopFilterAcrossTilesEnabledFlag();
    10281164    m_pcLoopFilter->setCfg(bLFCrossTileBoundary);
     1165#if L0386_DB_METRIC
     1166    if ( m_pcCfg->getDeblockingFilterMetric() )
     1167    {
     1168      dblMetric(pcPic, uiNumSlices);
     1169    }
     1170#endif
    10291171    m_pcLoopFilter->loopFilterPic( pcPic );
    10301172
     
    11331275    }
    11341276
     1277#if L0208_SOP_DESCRIPTION_SEI
     1278    if (writeSOP) // write SOP description SEI (if enabled) at the beginning of GOP
     1279    {
     1280      Int SOPcurrPOC = pocCurr;
     1281
     1282      OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
     1283      m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
     1284      m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     1285
     1286      SEISOPDescription SOPDescriptionSEI;
     1287      SOPDescriptionSEI.m_sopSeqParameterSetId = pcSlice->getSPS()->getSPSId();
     1288
     1289      UInt i = 0;
     1290      UInt prevEntryId = iGOPid;
     1291      for (j = iGOPid; j < m_iGopSize; j++)
     1292      {
     1293        Int deltaPOC = m_pcCfg->getGOPEntry(j).m_POC - m_pcCfg->getGOPEntry(prevEntryId).m_POC;
     1294        if ((SOPcurrPOC + deltaPOC) < m_pcCfg->getFramesToBeEncoded())
     1295        {
     1296          SOPcurrPOC += deltaPOC;
     1297          SOPDescriptionSEI.m_sopDescVclNaluType[i] = getNalUnitType(SOPcurrPOC, m_iLastIDR);
     1298          SOPDescriptionSEI.m_sopDescTemporalId[i] = m_pcCfg->getGOPEntry(j).m_temporalId;
     1299          SOPDescriptionSEI.m_sopDescStRpsIdx[i] = m_pcEncTop->getReferencePictureSetIdxForSOP(pcSlice, SOPcurrPOC, j);
     1300          SOPDescriptionSEI.m_sopDescPocDelta[i] = deltaPOC;
     1301
     1302          prevEntryId = j;
     1303          i++;
     1304        }
     1305      }
     1306
     1307      SOPDescriptionSEI.m_numPicsInSopMinus1 = i - 1;
     1308
     1309      m_seiWriter.writeSEImessage( nalu.m_Bitstream, SOPDescriptionSEI, pcSlice->getSPS());
     1310      writeRBSPTrailingBits(nalu.m_Bitstream);
     1311      accessUnit.push_back(new NALUnitEBSP(nalu));
     1312
     1313      writeSOP = false;
     1314    }
     1315#endif
     1316
    11351317    if( ( m_pcCfg->getPictureTimingSEIEnabled() || m_pcCfg->getDecodingUnitInfoSEIEnabled() ) &&
    11361318        ( pcSlice->getSPS()->getVuiParametersPresentFlag() ) &&
     
    11781360       || ( pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getVclHrdParametersPresentFlag() ) ) )
    11791361    {
    1180       OutputNALUnit nalu(NAL_UNIT_SEI);
     1362      OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
    11811363      m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    11821364      m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     
    12191401      writeRBSPTrailingBits(nalu.m_Bitstream);
    12201402#if L0045_NON_NESTED_SEI_RESTRICTIONS
     1403      {
    12211404      UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit);
    12221405      UInt offsetPosition = m_activeParameterSetSEIPresentInAU;   // Insert BP SEI after APS SEI
     
    12281411      accessUnit.insert(it, new NALUnitEBSP(nalu));
    12291412      m_bufferingPeriodSEIPresentInAU = true;
     1413      }
    12301414#else
    12311415      accessUnit.push_back(new NALUnitEBSP(nalu));
    12321416#endif
    12331417
     1418#if K0180_SCALABLE_NESTING_SEI
     1419      if (m_pcCfg->getScalableNestingSEIEnabled())
     1420      {
     1421        OutputNALUnit naluTmp(NAL_UNIT_PREFIX_SEI);
     1422        m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
     1423        m_pcEntropyCoder->setBitstream(&naluTmp.m_Bitstream);
     1424        scalableNestingSEI.m_nestedSEIs.clear();
     1425        scalableNestingSEI.m_nestedSEIs.push_back(&sei_buffering_period);
     1426        m_seiWriter.writeSEImessage( naluTmp.m_Bitstream, scalableNestingSEI, pcSlice->getSPS());
     1427        writeRBSPTrailingBits(naluTmp.m_Bitstream);
     1428#if L0045_NON_NESTED_SEI_RESTRICTIONS
     1429        UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit);
     1430        UInt offsetPosition = m_activeParameterSetSEIPresentInAU + m_bufferingPeriodSEIPresentInAU + m_pictureTimingSEIPresentInAU;   // Insert BP SEI after non-nested APS, BP and PT SEIs
     1431        AccessUnit::iterator it;
     1432        for(j = 0, it = accessUnit.begin(); j < seiPositionInAu + offsetPosition; j++)
     1433        {
     1434          it++;
     1435        }
     1436        accessUnit.insert(it, new NALUnitEBSP(naluTmp));
     1437        m_nestedBufferingPeriodSEIPresentInAU = true;
     1438#else
     1439        accessUnit.push_back(new NALUnitEBSP(naluTmp));
     1440#endif
     1441      }
     1442#endif
     1443
    12341444      m_lastBPSEI = m_totalCoded;
    12351445      m_cpbRemovalDelay = 0;
     
    12411451      {
    12421452        // Gradual decoding refresh SEI
    1243         OutputNALUnit nalu(NAL_UNIT_SEI);
     1453        OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
    12441454        m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    12451455        m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     
    12531463      }
    12541464    // Recovery point SEI
    1255       OutputNALUnit nalu(NAL_UNIT_SEI);
     1465      OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
    12561466      m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    12571467      m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     
    14441654
    14451655          pcSlice->setTileOffstForMultES( uiOneBitstreamPerSliceLength );
    1446           if (!sliceSegment)
    1447           {
    14481656            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           }
     1657          m_pcSliceEncoder->encodeSlice(pcPic, pcSubstreamsOut);
    14551658
    14561659          {
     
    14841687              if (ui+1 < pcSlice->getPPS()->getNumSubstreams())
    14851688              {
    1486                 puiSubstreamSizes[ui] = pcSubstreamsOut[ui].getNumberOfWrittenBits();
     1689                puiSubstreamSizes[ui] = pcSubstreamsOut[ui].getNumberOfWrittenBits() + (pcSubstreamsOut[ui].countStartCodeEmulations()<<3);
    14871690              }
    14881691            }
     
    15161719          // 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.
    15171720          Bool bNALUAlignedWrittenToList    = false; // used to ensure current NALU is not written more than once to the NALU list.
    1518           xWriteTileLocationToSliceHeader(nalu, pcBitstreamRedirect, pcSlice);
     1721          xAttachSliceDataToNalUnit(nalu, pcBitstreamRedirect);
    15191722          accessUnit.push_back(new NALUnitEBSP(nalu));
    15201723#if RATE_CONTROL_LAMBDA_DOMAIN
     
    15441747            {
    15451748              UInt numRBSPBytes_nal = UInt((*it)->m_nalUnitData.str().size());
    1546               if ((*it)->m_nalUnitType != NAL_UNIT_SEI && (*it)->m_nalUnitType != NAL_UNIT_SEI_SUFFIX)
     1749              if ((*it)->m_nalUnitType != NAL_UNIT_PREFIX_SEI && (*it)->m_nalUnitType != NAL_UNIT_SUFFIX_SEI)
    15471750              {
    15481751                numRBSPBytes += numRBSPBytes_nal;
     
    16401843        }
    16411844#if SVC_EXTENSION
    1642         OutputNALUnit nalu(NAL_UNIT_SEI_SUFFIX, pcSlice->getTLayer(), m_layerId);
     1845        OutputNALUnit nalu(NAL_UNIT_SUFFIX_SEI, pcSlice->getTLayer(), m_layerId);
    16431846#else
    1644         OutputNALUnit nalu(NAL_UNIT_SEI_SUFFIX, pcSlice->getTLayer());
     1847        OutputNALUnit nalu(NAL_UNIT_SUFFIX_SEI, pcSlice->getTLayer());
    16451848#endif
    16461849
     
    16671870        sei_temporal_level0_index.rapIdx = m_rapIdx;
    16681871
    1669         OutputNALUnit nalu(NAL_UNIT_SEI);
     1872        OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
    16701873
    16711874        /* write the SEI messages */
     
    18072010        if( m_pcCfg->getPictureTimingSEIEnabled() )
    18082011        {
    1809           OutputNALUnit nalu(NAL_UNIT_SEI, pcSlice->getTLayer());
     2012          {
     2013            OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI, pcSlice->getTLayer());
    18102014          m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    18112015          m_seiWriter.writeSEImessage(nalu.m_Bitstream, pictureTimingSEI, pcSlice->getSPS());
     
    18272031#endif
    18282032        }
     2033#if K0180_SCALABLE_NESTING_SEI
     2034          if ( m_pcCfg->getScalableNestingSEIEnabled() ) // put picture timing SEI into scalable nesting SEI
     2035          {
     2036            OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI, pcSlice->getTLayer());
     2037            m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
     2038            scalableNestingSEI.m_nestedSEIs.clear();
     2039            scalableNestingSEI.m_nestedSEIs.push_back(&pictureTimingSEI);
     2040            m_seiWriter.writeSEImessage(nalu.m_Bitstream, scalableNestingSEI, pcSlice->getSPS());
     2041            writeRBSPTrailingBits(nalu.m_Bitstream);
     2042#if L0045_NON_NESTED_SEI_RESTRICTIONS
     2043            UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit);
     2044            UInt offsetPosition = m_activeParameterSetSEIPresentInAU
     2045              + m_bufferingPeriodSEIPresentInAU + m_pictureTimingSEIPresentInAU + m_nestedBufferingPeriodSEIPresentInAU;    // Insert PT SEI after APS and BP SEI
     2046            AccessUnit::iterator it;
     2047            for(j = 0, it = accessUnit.begin(); j < seiPositionInAu + offsetPosition; j++)
     2048            {
     2049              it++;
     2050            }
     2051            accessUnit.insert(it, new NALUnitEBSP(nalu));
     2052            m_nestedPictureTimingSEIPresentInAU = true;
     2053#else
     2054            AccessUnit::iterator it = find_if(accessUnit.begin(), accessUnit.end(), mem_fun(&NALUnit::isSlice));
     2055            accessUnit.insert(it, new NALUnitEBSP(nalu));
     2056#endif
     2057          }
     2058#endif
     2059
     2060        }
    18292061        if( m_pcCfg->getDecodingUnitInfoSEIEnabled() && hrd->getSubPicCpbParamsPresentFlag() )
    18302062        {             
     
    18322064          for( Int i = 0; i < ( pictureTimingSEI.m_numDecodingUnitsMinus1 + 1 ); i ++ )
    18332065          {
    1834             OutputNALUnit nalu(NAL_UNIT_SEI, pcSlice->getTLayer());
     2066            OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI, pcSlice->getTLayer());
    18352067
    18362068            SEIDecodingUnitInfo tempSEI;
     
    18802112                  break;
    18812113                }
    1882                 if ((*it)->m_nalUnitType != NAL_UNIT_SEI && (*it)->m_nalUnitType != NAL_UNIT_SEI_SUFFIX)
     2114                if ((*it)->m_nalUnitType != NAL_UNIT_PREFIX_SEI && (*it)->m_nalUnitType != NAL_UNIT_SUFFIX_SEI)
    18832115                {
    18842116                  ctr++;
     
    18912123#if L0045_NON_NESTED_SEI_RESTRICTIONS
    18922124      xResetNonNestedSEIPresentFlags();
     2125#if K0180_SCALABLE_NESTING_SEI
     2126      xResetNestedSEIPresentFlags();
     2127#endif
    18932128#endif
    18942129      pcPic->getPicYuvRec()->copyToPic(pcPicYuvRecOut);
     
    21132348    case NAL_UNIT_CODED_SLICE_TRAIL_R: return "TRAIL_R";
    21142349    case NAL_UNIT_CODED_SLICE_TRAIL_N: return "TRAIL_N";
    2115     case NAL_UNIT_CODED_SLICE_TLA: return "TLA";
     2350    case NAL_UNIT_CODED_SLICE_TLA_R:      return "TLA_R";
    21162351    case NAL_UNIT_CODED_SLICE_TSA_N: return "TSA_N";
    21172352    case NAL_UNIT_CODED_SLICE_STSA_R: return "STSA_R";
    21182353    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";
     2354    case NAL_UNIT_CODED_SLICE_BLA_W_LP:   return "BLA_W_LP";
     2355    case NAL_UNIT_CODED_SLICE_BLA_W_RADL: return "BLA_W_RADL";
    21212356    case NAL_UNIT_CODED_SLICE_BLA_N_LP: return "BLA_N_LP";
    2122     case NAL_UNIT_CODED_SLICE_IDR: return "IDR";
     2357    case NAL_UNIT_CODED_SLICE_IDR_W_RADL: return "IDR_W_RADL";
    21232358    case NAL_UNIT_CODED_SLICE_IDR_N_LP: return "IDR_N_LP";
    21242359    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";
     2360    case NAL_UNIT_CODED_SLICE_RADL_R:     return "RADL_R";
     2361    case NAL_UNIT_CODED_SLICE_RASL_R:     return "RASL_R";
    21272362    case NAL_UNIT_VPS: return "VPS";
    21282363    case NAL_UNIT_SPS: return "SPS";
     
    21322367    case NAL_UNIT_EOB: return "EOB";
    21332368    case NAL_UNIT_FILLER_DATA: return "FILLER";
    2134     case NAL_UNIT_SEI: return "SEI";
     2369    case NAL_UNIT_PREFIX_SEI:             return "SEI";
     2370    case NAL_UNIT_SUFFIX_SEI:             return "SEI";
    21352371    default: return "UNK";
    21362372  }
     
    22232459    printf("*** %6s numBytesInNALunit: %u\n", nalUnitTypeToString((*it)->m_nalUnitType), numRBSPBytes_nal);
    22242460#endif
    2225     if ((*it)->m_nalUnitType != NAL_UNIT_SEI && (*it)->m_nalUnitType != NAL_UNIT_SEI_SUFFIX)
     2461    if ((*it)->m_nalUnitType != NAL_UNIT_PREFIX_SEI && (*it)->m_nalUnitType != NAL_UNIT_SUFFIX_SEI)
    22262462    {
    22272463      numRBSPBytes += numRBSPBytes_nal;
     
    23252561 * This function checks the configuration and returns the appropriate nal_unit_type for the picture.
    23262562 */
    2327 NalUnitType TEncGOP::getNalUnitType(Int pocCurr)
     2563NalUnitType TEncGOP::getNalUnitType(Int pocCurr, Int lastIDR)
    23282564{
    23292565  if (pocCurr == 0)
    23302566  {
    2331     return NAL_UNIT_CODED_SLICE_IDR;
     2567    return NAL_UNIT_CODED_SLICE_IDR_W_RADL;
    23322568  }
    23332569  if (pocCurr % m_pcCfg->getIntraPeriod() == 0)
     
    23392575    else if (m_pcCfg->getDecodingRefreshType() == 2)
    23402576    {
    2341       return NAL_UNIT_CODED_SLICE_IDR;
     2577      return NAL_UNIT_CODED_SLICE_IDR_W_RADL;
    23422578    }
    23432579  }
     
    23512587      // controlling the reference pictures used for encoding that leading picture. Such a leading
    23522588      // picture need not be marked as a TFD picture.
    2353       return NAL_UNIT_CODED_SLICE_TFD;
     2589      return NAL_UNIT_CODED_SLICE_RASL_R;
     2590    }
     2591  }
     2592  if (lastIDR>0)
     2593  {
     2594    if (pocCurr < lastIDR)
     2595    {
     2596      return NAL_UNIT_CODED_SLICE_RADL_R;
    23542597    }
    23552598  }
     
    24022645}
    24032646
    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.
     2647/** Attaches the input bitstream to the stream in the output NAL unit
     2648    Updates rNalu to contain concatenated bitstream. rpcBitstreamRedirect is cleared at the end of this function call.
     2649 *  \param codedSliceData contains the coded slice data (bitstream) to be concatenated to rNalu
     2650 *  \param rNalu          target NAL unit
    24072651 */
    2408 Void TEncGOP::xWriteTileLocationToSliceHeader (OutputNALUnit& rNalu, TComOutputBitstream*& rpcBitstreamRedirect, TComSlice*& rpcSlice)
     2652Void TEncGOP::xAttachSliceDataToNalUnit (OutputNALUnit& rNalu, TComOutputBitstream*& codedSliceData)
    24092653{
    24102654  // Byte-align
     
    24122656
    24132657  // 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     }         
     2658  if (codedSliceData->getNumberOfWrittenBits() > 0)
     2659    {
     2660    rNalu.m_Bitstream.addSubstream(codedSliceData);
    24342661  }
    24352662
    24362663  m_pcEntropyCoder->setBitstream(&rNalu.m_Bitstream);
    24372664
    2438   delete rpcBitstreamRedirect;
    2439   rpcBitstreamRedirect = new TComOutputBitstream;
     2665  codedSliceData->clear();
    24402666}
    24412667
     
    25622788     }               
    25632789  }
    2564   assert(it != accessUnit.end());
     2790//  assert(it != accessUnit.end());  // Triggers with some legit configurations
    25652791  return seiStartPos;
    25662792}
    25672793#endif
     2794
     2795#if L0386_DB_METRIC
     2796Void TEncGOP::dblMetric( TComPic* pcPic, UInt uiNumSlices )
     2797{
     2798  TComPicYuv* pcPicYuvRec = pcPic->getPicYuvRec();
     2799  Pel* Rec    = pcPicYuvRec->getLumaAddr( 0 );
     2800  Pel* tempRec = Rec;
     2801  Int  stride = pcPicYuvRec->getStride();
     2802  UInt log2maxTB = pcPic->getSlice(0)->getSPS()->getQuadtreeTULog2MaxSize();
     2803  UInt maxTBsize = (1<<log2maxTB);
     2804  const UInt minBlockArtSize = 8;
     2805  const UInt picWidth = pcPicYuvRec->getWidth();
     2806  const UInt picHeight = pcPicYuvRec->getHeight();
     2807  const UInt noCol = (picWidth>>log2maxTB);
     2808  const UInt noRows = (picHeight>>log2maxTB);
     2809  UInt64 *colSAD = (UInt64*)malloc(noCol*sizeof(UInt64));
     2810  UInt64 *rowSAD = (UInt64*)malloc(noRows*sizeof(UInt64));
     2811  UInt colIdx = 0;
     2812  UInt rowIdx = 0;
     2813  Pel p0, p1, p2, q0, q1, q2;
     2814 
     2815  Int qp = pcPic->getSlice(0)->getSliceQp();
     2816  Int bitdepthScale = 1 << (g_bitDepthY-8);
     2817  Int beta = TComLoopFilter::getBeta( qp ) * bitdepthScale;
     2818  const Int thr2 = (beta>>2);
     2819  const Int thr1 = 2*bitdepthScale;
     2820  UInt a = 0;
     2821 
     2822  memset(colSAD, 0, noCol*sizeof(UInt64));
     2823  memset(rowSAD, 0, noRows*sizeof(UInt64));
     2824 
     2825  if (maxTBsize > minBlockArtSize)
     2826  {
     2827    // Analyze vertical artifact edges
     2828    for(Int c = maxTBsize; c < picWidth; c += maxTBsize)
     2829    {
     2830      for(Int r = 0; r < picHeight; r++)
     2831      {
     2832        p2 = Rec[c-3];
     2833        p1 = Rec[c-2];
     2834        p0 = Rec[c-1];
     2835        q0 = Rec[c];
     2836        q1 = Rec[c+1];
     2837        q2 = Rec[c+2];
     2838        a = ((abs(p2-(p1<<1)+p0)+abs(q0-(q1<<1)+q2))<<1);
     2839        if ( thr1 < a && a < thr2)
     2840        {
     2841          colSAD[colIdx] += abs(p0 - q0);
     2842        }
     2843        Rec += stride;
     2844      }
     2845      colIdx++;
     2846      Rec = tempRec;
     2847    }
     2848   
     2849    // Analyze horizontal artifact edges
     2850    for(Int r = maxTBsize; r < picHeight; r += maxTBsize)
     2851    {
     2852      for(Int c = 0; c < picWidth; c++)
     2853      {
     2854        p2 = Rec[c + (r-3)*stride];
     2855        p1 = Rec[c + (r-2)*stride];
     2856        p0 = Rec[c + (r-1)*stride];
     2857        q0 = Rec[c + r*stride];
     2858        q1 = Rec[c + (r+1)*stride];
     2859        q2 = Rec[c + (r+2)*stride];
     2860        a = ((abs(p2-(p1<<1)+p0)+abs(q0-(q1<<1)+q2))<<1);
     2861        if (thr1 < a && a < thr2)
     2862        {
     2863          rowSAD[rowIdx] += abs(p0 - q0);
     2864        }
     2865      }
     2866      rowIdx++;
     2867    }
     2868  }
     2869 
     2870  UInt64 colSADsum = 0;
     2871  UInt64 rowSADsum = 0;
     2872  for(Int c = 0; c < noCol-1; c++)
     2873  {
     2874    colSADsum += colSAD[c];
     2875  }
     2876  for(Int r = 0; r < noRows-1; r++)
     2877  {
     2878    rowSADsum += rowSAD[r];
     2879  }
     2880 
     2881  colSADsum <<= 10;
     2882  rowSADsum <<= 10;
     2883  colSADsum /= (noCol-1);
     2884  colSADsum /= picHeight;
     2885  rowSADsum /= (noRows-1);
     2886  rowSADsum /= picWidth;
     2887 
     2888  UInt64 avgSAD = ((colSADsum + rowSADsum)>>1);
     2889  avgSAD >>= (g_bitDepthY-8);
     2890 
     2891  if ( avgSAD > 2048 )
     2892  {
     2893    avgSAD >>= 9;
     2894    Int offset = Clip3(2,6,(Int)avgSAD);
     2895    for (Int i=0; i<uiNumSlices; i++)
     2896    {
     2897      pcPic->getSlice(i)->setDeblockingFilterOverrideFlag(true);
     2898      pcPic->getSlice(i)->setDeblockingFilterDisable(false);
     2899      pcPic->getSlice(i)->setDeblockingFilterBetaOffsetDiv2( offset );
     2900      pcPic->getSlice(i)->setDeblockingFilterTcOffsetDiv2( offset );
     2901    }
     2902  }
     2903  else
     2904  {
     2905    for (Int i=0; i<uiNumSlices; i++)
     2906    {
     2907      pcPic->getSlice(i)->setDeblockingFilterOverrideFlag(false);
     2908      pcPic->getSlice(i)->setDeblockingFilterDisable(        pcPic->getSlice(i)->getPPS()->getPicDisableDeblockingFilterFlag() );
     2909      pcPic->getSlice(i)->setDeblockingFilterBetaOffsetDiv2( pcPic->getSlice(i)->getPPS()->getDeblockingFilterBetaOffsetDiv2() );
     2910      pcPic->getSlice(i)->setDeblockingFilterTcOffsetDiv2(   pcPic->getSlice(i)->getPPS()->getDeblockingFilterTcOffsetDiv2()   );
     2911    }
     2912  }
     2913 
     2914  free(colSAD);
     2915  free(rowSAD);
     2916}
     2917#endif
    25682918//! \}
  • branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncGOP.h

    r125 r133  
    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
  • branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp

    r125 r133  
    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  {
  • branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.h

    r125 r133  
    5757{
    5858private:
    59   Double            m_dLambdaLuma;
    60   Double            m_dLambdaChroma;
    61 
    6259  TEncEntropy*      m_pcEntropyCoder;
    6360  TEncSbac***       m_pppcRDSbacCoder;              ///< for CABAC
  • branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncSbac.h

    r125 r133  
    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 );
  • branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncSearch.cpp

    r125 r133  
    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;
     
    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
     
    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)
     
    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--;
  • branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncSlice.cpp

    r125 r133  
    400400  rpcSlice->setNumRefIdx(REF_PIC_LIST_1,m_pcCfg->getGOPEntry(iGOPid).m_numRefPicsActive);
    401401 
     402#if L0386_DB_METRIC
     403  if ( m_pcCfg->getDeblockingFilterMetric() )
     404  {
     405    rpcSlice->setDeblockingFilterOverrideFlag(true);
     406    rpcSlice->setDeblockingFilterDisable(false);
     407    rpcSlice->setDeblockingFilterBetaOffsetDiv2( 0 );
     408    rpcSlice->setDeblockingFilterTcOffsetDiv2( 0 );
     409  } else
     410#endif
    402411  if (rpcSlice->getPPS()->getDeblockingFilterControlPresentFlag())
    403412  {
     
    11821191 \retval rpcBitstream  bitstream class
    11831192 */
    1184 Void TEncSlice::encodeSlice   ( TComPic*& rpcPic, TComOutputBitstream* pcBitstream, TComOutputBitstream* pcSubstreams )
     1193Void TEncSlice::encodeSlice   ( TComPic*& rpcPic, TComOutputBitstream* pcSubstreams )
    11851194{
    11861195  UInt       uiCUAddr;
     
    13621371      }
    13631372      {
    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        
     1373        UInt numStartCodeEmulations = pcSubstreams[uiSubStrm].countStartCodeEmulations();
    13971374        UInt uiAccumulatedSubstreamLength = 0;
    13981375        for (Int iSubstrmIdx=0; iSubstrmIdx < iNumSubstreams; iSubstrmIdx++)
     
    14021379        // add bits coded in previous dependent slices + bits coded so far
    14031380        // add number of emulation prevention byte count in the tile
    1404         pcSlice->addTileLocation( ((pcSlice->getTileOffstForMultES() + uiAccumulatedSubstreamLength - uiBitsOriginallyInSubstreams) >> 3) + uiCounter );
     1381        pcSlice->addTileLocation( ((pcSlice->getTileOffstForMultES() + uiAccumulatedSubstreamLength - uiBitsOriginallyInSubstreams) >> 3) + numStartCodeEmulations );
    14051382      }
    14061383    }
  • branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncSlice.h

    r125 r133  
    126126  Void    precompressSlice    ( TComPic*& rpcPic                                );      ///< precompress slice for multi-loop opt.
    127127  Void    compressSlice       ( TComPic*& rpcPic                                );      ///< analysis stage of slice
    128   Void    encodeSlice         ( TComPic*& rpcPic, TComOutputBitstream* rpcBitstream, TComOutputBitstream* pcSubstreams  );
     128  Void    encodeSlice         ( TComPic*& rpcPic, TComOutputBitstream* pcSubstreams  );
    129129 
    130130  // misc. functions
  • branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncTop.cpp

    r125 r133  
    599599  m_cSPS.setMaxCUHeight   ( g_uiMaxCUHeight     );
    600600  m_cSPS.setMaxCUDepth    ( g_uiMaxCUDepth      );
    601   m_cSPS.setMinTrDepth    ( 0                   );
    602   m_cSPS.setMaxTrDepth    ( 1                   );
     601
     602  Int minCUSize = m_cSPS.getMaxCUWidth() >> ( m_cSPS.getMaxCUDepth()-g_uiAddCUDepth );
     603  Int log2MinCUSize = 0;
     604  while(minCUSize > 1)
     605  {
     606    minCUSize >>= 1;
     607    log2MinCUSize++;
     608  }
     609
     610  m_cSPS.setLog2MinCodingBlockSize(log2MinCUSize);
     611  m_cSPS.setLog2DiffMaxMinCodingBlockSize(m_cSPS.getMaxCUDepth()-g_uiAddCUDepth);
    603612#if SVC_EXTENSION
    604613  m_cSPS.setSPSId         ( m_iSPSIdCnt       );
     
    618627
    619628  m_cSPS.setMaxTrSize   ( 1 << m_uiQuadtreeTULog2MaxSize );
    620  
     629#if !L0034_COMBINED_LIST_CLEANUP
    621630  m_cSPS.setUseLComb    ( m_bUseLComb           );
     631#endif
    622632 
    623633  Int i;
     
    763773  m_cPPS.setOutputFlagPresentFlag( false );
    764774  m_cPPS.setSignHideFlag(getSignHideFlag());
     775#if L0386_DB_METRIC
     776  if ( getDeblockingFilterMetric() )
     777  {
     778    m_cPPS.setDeblockingFilterControlPresentFlag (true);
     779    m_cPPS.setDeblockingFilterOverrideEnabledFlag(true);
     780    m_cPPS.setPicDisableDeblockingFilterFlag(false);
     781    m_cPPS.setDeblockingFilterBetaOffsetDiv2(0);
     782    m_cPPS.setDeblockingFilterTcOffsetDiv2(0);
     783  }
     784  else
     785  {
    765786  m_cPPS.setDeblockingFilterControlPresentFlag (m_DeblockingFilterControlPresent );
     787  }
     788#else
     789  m_cPPS.setDeblockingFilterControlPresentFlag (m_DeblockingFilterControlPresent );
     790#endif
    766791  m_cPPS.setLog2ParallelMergeLevelMinus2   (m_log2ParallelMergeLevelMinus2 );
    767792  m_cPPS.setCabacInitPresentFlag(CABAC_INIT_PRESENT_FLAG);
     
    10361061}
    10371062
     1063#if L0208_SOP_DESCRIPTION_SEI
     1064Int TEncTop::getReferencePictureSetIdxForSOP(TComSlice* slice, Int POCCurr, Int GOPid )
     1065{
     1066  int rpsIdx = GOPid;
     1067
     1068  for(Int extraNum=m_iGOPSize; extraNum<m_extraRPSs+m_iGOPSize; extraNum++)
     1069  {   
     1070    if(m_uiIntraPeriod > 0 && getDecodingRefreshType() > 0)
     1071    {
     1072      Int POCIndex = POCCurr%m_uiIntraPeriod;
     1073      if(POCIndex == 0)
     1074      {
     1075        POCIndex = m_uiIntraPeriod;
     1076      }
     1077      if(POCIndex == m_GOPList[extraNum].m_POC)
     1078      {
     1079        rpsIdx = extraNum;
     1080      }
     1081    }
     1082    else
     1083    {
     1084      if(POCCurr==m_GOPList[extraNum].m_POC)
     1085      {
     1086        rpsIdx = extraNum;
     1087      }
     1088    }
     1089  }
     1090
     1091  return rpsIdx;
     1092}
     1093#endif
     1094
    10381095Void  TEncTop::xInitPPSforTiles()
    10391096{
  • branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncTop.h

    r125 r133  
    192192  TComPPS*                getPPS                () { return  &m_cPPS;                 }
    193193  Void selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid );
     194#if L0208_SOP_DESCRIPTION_SEI
     195  Int getReferencePictureSetIdxForSOP(TComSlice* slice, Int POCCurr, Int GOPid );
     196#endif
    194197  TComScalingList*        getScalingList        () { return  &m_scalingList;         }
    195198#if SVC_EXTENSION
  • branches/SHM-2.0-dev/source/Lib/TLibEncoder/WeightPredAnalysis.cpp

    r125 r133  
    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.