Changeset 302 in SHVCSoftware


Ignore:
Timestamp:
28 Jun 2013, 00:40:00 (12 years ago)
Author:
seregin
Message:

update to HM11.0

Location:
branches/SHM-2.1-dev/source
Files:
48 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-2.1-dev/source/App/TAppDecoder/decmain.cpp

    r191 r302  
    5656  // print information
    5757  fprintf( stdout, "\n" );
     58#if SVC_EXTENSION
    5859  fprintf( stdout, "SHM software: Decoder Version [%s]", NV_VERSION );
     60#else
     61  fprintf( stdout, "HM software: Decoder Version [%s]", NV_VERSION );
     62#endif
    5963  fprintf( stdout, NVM_ONOS );
    6064  fprintf( stdout, NVM_COMPILEDBY );
  • branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncCfg.cpp

    r298 r302  
    9696{
    9797  m_aidQP = NULL;
    98 #if J0149_TONE_MAPPING_SEI
    9998  m_startOfCodedInterval = NULL;
    10099  m_codedPivotValue = NULL;
    101100  m_targetPivotValue = NULL;
    102 #endif
    103101}
    104102#endif
     
    114112    delete[] m_aidQP;
    115113  }
    116 #if J0149_TONE_MAPPING_SEI
    117114  if ( m_startOfCodedInterval )
    118115  {
     
    130127    m_targetPivotValue = NULL;
    131128  }
    132 #endif
    133129  free(m_pchInputFile);
    134130#endif
     
    326322}
    327323
    328 #if SIGNAL_BITRATE_PICRATE_IN_VPS
    329 Void readBoolString(const string inpString, const Int numEntries, Bool* &memberArray, const char *elementName);
    330 Void readIntString(const string inpString, const Int numEntries, Int* &memberArray, const char *elementName);
    331 #endif
    332324// ====================================================================================================================
    333325// Public member functions
     
    450442  string cfg_RowHeight;
    451443  string cfg_ScalingListFile;
    452 #if J0149_TONE_MAPPING_SEI
    453444  string cfg_startOfCodedInterval;
    454445  string cfg_codedPivotValue;
    455446  string cfg_targetPivotValue;
    456 #endif
    457 #if SIGNAL_BITRATE_PICRATE_IN_VPS
    458   string cfg_bitRateInfoPresentFlag;
    459   string cfg_picRateInfoPresentFlag;
    460   string cfg_avgBitRate;
    461   string cfg_maxBitRate;
    462   string cfg_avgPicRate;
    463   string cfg_constantPicRateIdc;
    464 #endif
    465447  po::Options opts;
    466448  opts.addOptions()
     
    556538  ("Tier",    m_levelTier, Level::MAIN,   "Tier to use for interpretation of --Level")
    557539
    558 #if L0046_CONSTRAINT_FLAGS
    559540  ("ProgressiveSource", m_progressiveSourceFlag, false, "Indicate that source is progressive")
    560541  ("InterlacedSource",  m_interlacedSourceFlag,  false, "Indicate that source is interlaced")
    561542  ("NonPackedSource",   m_nonPackedConstraintFlag, false, "Indicate that source does not contain frame packing")
    562543  ("FrameOnly",         m_frameOnlyConstraintFlag, false, "Indicate that the bitstream contains only frames")
    563 #endif
    564544
    565545  // Unit definition parameters
     
    585565  ("DecodingRefreshType,-dr", m_iDecodingRefreshType,       0, "Intra refresh type (0:none 1:CRA 2:IDR)")
    586566  ("GOPSize,g",               m_iGOPSize,                   1, "GOP size of temporal structure")
    587 #if !L0034_COMBINED_LIST_CLEANUP
    588   ("ListCombination,-lc",     m_bUseLComb,               true, "Combined reference list for uni-prediction estimation in B-slices")
    589 #endif
    590567  // motion options
    591568  ("FastSearch",              m_iFastSearch,                1, "0:Full search  1:Diamond  2:PMVFAST")
     
    633610  ("RDOQ",                          m_useRDOQ,                  true )
    634611  ("RDOQTS",                        m_useRDOQTS,                true )
    635 #if L0232_RD_PENALTY
    636612  ("RDpenalty",                     m_rdPenalty,                0,  "RD-penalty for 32x32 TU for intra in non-intra slices. 0:disbaled  1:RD-penalty  2:maximum RD-penalty")
    637 #endif
    638613  // Entropy coding parameters
    639614  ("SBACRD",                         m_bUseSBACRD,                      true, "SBAC based RD estimation")
     
    645620  ("LoopFilterTcOffset_div2",        m_loopFilterTcOffsetDiv2,             0 )
    646621  ("DeblockingFilterControlPresent", m_DeblockingFilterControlPresent, false )
    647 #if L0386_DB_METRIC
    648622  ("DeblockingFilterMetric",         m_DeblockingFilterMetric,         false )
    649 #endif
    650623
    651624  // Coding tools
     
    722695  ( "RateControl",         m_RCEnableRateControl,   false, "Rate control: enable rate control" )
    723696  ( "TargetBitrate",       m_RCTargetBitrate,           0, "Rate control: target bitrate" )
     697#if M0036_RC_IMPROVEMENT
     698  ( "KeepHierarchicalBit", m_RCKeepHierarchicalBit,     0, "Rate control: 0: equal bit allocation; 1: fixed ratio bit allocation; 2: adaptive ratio bit allocation" )
     699#else
    724700  ( "KeepHierarchicalBit", m_RCKeepHierarchicalBit, false, "Rate control: keep hierarchical bit allocation in rate control algorithm" )
     701#endif
    725702  ( "LCULevelRateControl", m_RCLCULevelRC,           true, "Rate control: true: LCU level RC; false: picture level RC" )
    726703  ( "RCLCUSeparateModel",  m_RCUseLCUSeparateModel,  true, "Rate control: use LCU level separate R-lambda model" )
     
    775752  ("SEIBufferingPeriod",             m_bufferingPeriodSEIEnabled,              0, "Control generation of buffering period SEI messages")
    776753  ("SEIPictureTiming",               m_pictureTimingSEIEnabled,                0, "Control generation of picture timing SEI messages")
    777 #if J0149_TONE_MAPPING_SEI
    778754  ("SEIToneMappingInfo",                       m_toneMappingInfoSEIEnabled,    false, "Control generation of Tone Mapping SEI messages")
    779755  ("SEIToneMapId",                             m_toneMapId,                        0, "Specifies Id of Tone Mapping SEI message for a given session")
     
    806782  ("SEIToneMapNominalWhiteLevelLumaCodeValue",        m_nominalWhiteLevelLumaCodeValue,         235, "Specifies luma sample value of the nominal white level assigned decoded pictures")
    807783  ("SEIToneMapExtendedWhiteLevelLumaCodeValue",       m_extendedWhiteLevelLumaCodeValue,        300, "Specifies luma sample value of the extended dynamic range assigned decoded pictures")
    808 #endif
    809784  ("SEIFramePacking",                m_framePackingSEIEnabled,                 0, "Control generation of frame packing SEI messages")
    810785  ("SEIFramePackingType",            m_framePackingSEIType,                    0, "Define frame packing arrangement\n"
     
    830805  ("SEILayersPresent",               m_layersPresentSEIEnabled,                0, "Control generation of layers present SEI message")
    831806#endif
    832 #if L0208_SOP_DESCRIPTION_SEI
    833807  ("SEISOPDescription",              m_SOPDescriptionSEIEnabled,              0, "Control generation of SOP description SEI messages")
    834 #endif
    835 #if K0180_SCALABLE_NESTING_SEI
    836808  ("SEIScalableNesting",             m_scalableNestingSEIEnabled,              0, "Control generation of scalable nesting SEI messages")
    837 #endif
    838 #if SIGNAL_BITRATE_PICRATE_IN_VPS
    839   ("BitRatePicRateMaxTLayers",   m_bitRatePicRateMaxTLayers,           0, "Maximum number of sub-layers signalled; can be inferred otherwise; here for easy parsing of config. file")
    840   ("BitRateInfoPresent",         cfg_bitRateInfoPresentFlag,          string(""), "Control signalling of bit rate information of avg. bit rate and max. bit rate in VPS\n"
    841                                                                           "\t0: Do not sent bit rate info\n"
    842                                                                           "\tN (N > 0): Send bit rate info for N sub-layers. N should equal maxTempLayers.")                                                                     
    843   ("PicRateInfoPresent",         cfg_picRateInfoPresentFlag,          string(""), "Control signalling of picture rate information of avg. bit rate and max. bit rate in VPS\n"
    844                                                                           "\t0: Do not sent picture rate info\n"
    845                                                                           "\tN (N > 0): Send picture rate info for N sub-layers. N should equal maxTempLayers.")                                                                     
    846   ("AvgBitRate",                   cfg_avgBitRate,                    string(""), "List of avg. bit rates for the different sub-layers; include non-negative number even if corresponding flag is 0")
    847   ("MaxBitRate",                   cfg_maxBitRate,                    string(""), "List of max. bit rates for the different sub-layers; include non-negative number even if corresponding flag is 0")
    848   ("AvgPicRate",                   cfg_avgPicRate,                    string(""), "List of avg. picture rates for the different sub-layers; include non-negative number even if corresponding flag is 0")
    849   ("ConstantPicRateIdc",           cfg_constantPicRateIdc,            string(""), "List of constant picture rate IDCs; include non-negative number even if corresponding flag is 0")
    850 #endif
    851809#if M0040_ADAPTIVE_RESOLUTION_CHANGE
    852810  ("AdaptiveResolutionChange",     m_adaptiveResolutionChange, 0, "Adaptive resolution change frame number. Should coincide with EL RAP picture. (0: disable)")
     
    11531111  }
    11541112#endif
    1155 #if SIGNAL_BITRATE_PICRATE_IN_VPS
    1156   readBoolString(cfg_bitRateInfoPresentFlag, m_bitRatePicRateMaxTLayers, m_bitRateInfoPresentFlag, "bit rate info. present flag" );
    1157   readIntString (cfg_avgBitRate,             m_bitRatePicRateMaxTLayers, m_avgBitRate,             "avg. bit rate"               );
    1158   readIntString (cfg_maxBitRate,             m_bitRatePicRateMaxTLayers, m_maxBitRate,             "max. bit rate"               );
    1159   readBoolString(cfg_picRateInfoPresentFlag, m_bitRatePicRateMaxTLayers, m_picRateInfoPresentFlag, "bit rate info. present flag" );
    1160   readIntString (cfg_avgPicRate,             m_bitRatePicRateMaxTLayers, m_avgPicRate,             "avg. pic rate"               );
    1161   readIntString (cfg_constantPicRateIdc,     m_bitRatePicRateMaxTLayers, m_constantPicRateIdc,     "constant pic rate Idc"       );
    1162 #endif
    11631113  m_scalingListFile = cfg_ScalingListFile.empty() ? NULL : strdup(cfg_ScalingListFile.c_str());
    11641114 
     
    12691219  m_iWaveFrontSubstreams = m_iWaveFrontSynchro ? (m_iSourceHeight + m_uiMaxCUHeight - 1) / m_uiMaxCUHeight : 1;
    12701220#endif
    1271 #if J0149_TONE_MAPPING_SEI
    12721221  if( m_toneMappingInfoSEIEnabled && !m_toneMapCancelFlag )
    12731222  {
     
    13281277    }
    13291278  }
    1330 #endif
    13311279  // check validity of input parameters
    13321280  xCheckParameter();
     
    13401288  return true;
    13411289}
    1342 #if SIGNAL_BITRATE_PICRATE_IN_VPS
    1343 Void readBoolString(const string inpString, const Int numEntries, Bool* &memberArray, const char *elementName)
    1344 {
    1345   Char* inpArray = inpString.empty() ? NULL : strdup(inpString.c_str());
    1346   Int i = 0;
    1347   if(numEntries)
    1348   {
    1349     Char* tempArray = strtok(inpArray, " ,-");
    1350     memberArray = new Bool[numEntries];
    1351     while( tempArray != NULL )
    1352     {
    1353       if( i >= numEntries )
    1354       {
    1355         printf( "The number of %s defined is larger than the allowed number\n", elementName );
    1356         exit( EXIT_FAILURE );
    1357       }
    1358       assert( (atoi(tempArray) == 0) || (atoi(tempArray) == 1) );
    1359       *( memberArray + i ) = atoi(tempArray);
    1360       tempArray = strtok(NULL, " ,-");
    1361       i++;
    1362     }
    1363     if( i < numEntries )
    1364     {
    1365       printf( "Some %s are not defined\n", elementName );
    1366       exit( EXIT_FAILURE );
    1367     }
    1368   }
    1369   else
    1370   {
    1371     memberArray = NULL;
    1372   }
    1373 }
    1374 
    1375 Void readIntString(const string inpString, const Int numEntries, Int* &memberArray, const char *elementName)
    1376 {
    1377   Char* inpArray = inpString.empty() ? NULL : strdup(inpString.c_str());
    1378   Int i = 0;
    1379   if(numEntries)
    1380   {
    1381     Char* tempArray = strtok(inpArray, " ,-");
    1382     memberArray = new Int[numEntries];
    1383     while( tempArray != NULL )
    1384     {
    1385       if( i >= numEntries )
    1386       {
    1387         printf( "The number of %s defined is larger than the allowed number\n", elementName );
    1388         exit( EXIT_FAILURE );
    1389       }
    1390       *( memberArray + i ) = atoi(tempArray);
    1391       tempArray = strtok(NULL, " ,-");
    1392       i++;
    1393     }
    1394     if( i < numEntries )
    1395     {
    1396       printf( "Some %s are not defined\n", elementName );
    1397       exit( EXIT_FAILURE );
    1398     }
    1399   }
    1400   else
    1401   {
    1402     memberArray = NULL;
    1403   }
    1404 }
    1405 #endif
    14061290// ====================================================================================================================
    14071291// Private member functions
     
    14191303    fprintf(stderr, "**          decoder requires this option to be enabled.         **\n");
    14201304    fprintf(stderr, "******************************************************************\n");
     1305  }
     1306  if( m_profile==Profile::NONE )
     1307  {
     1308    fprintf(stderr, "***************************************************************************\n");
     1309    fprintf(stderr, "** WARNING: For conforming bitstreams a valid Profile value must be set! **\n");
     1310    fprintf(stderr, "***************************************************************************\n");
     1311  }
     1312  if( m_level==Level::NONE )
     1313  {
     1314    fprintf(stderr, "***************************************************************************\n");
     1315    fprintf(stderr, "** WARNING: For conforming bitstreams a valid Level value must be set!   **\n");
     1316    fprintf(stderr, "***************************************************************************\n");
    14211317  }
    14221318
     
    14391335  xConfirmPara( m_iQP <  -6 * (m_internalBitDepthY - 8) || m_iQP > 51,                    "QP exceeds supported range (-QpBDOffsety to 51)" );
    14401336#endif
    1441   xConfirmPara( m_loopFilterBetaOffsetDiv2 < -13 || m_loopFilterBetaOffsetDiv2 > 13,          "Loop Filter Beta Offset div. 2 exceeds supported range (-13 to 13)");
    1442   xConfirmPara( m_loopFilterTcOffsetDiv2 < -13 || m_loopFilterTcOffsetDiv2 > 13,              "Loop Filter Tc Offset div. 2 exceeds supported range (-13 to 13)");
     1337  xConfirmPara( m_loopFilterBetaOffsetDiv2 < -6 || m_loopFilterBetaOffsetDiv2 > 6,          "Loop Filter Beta Offset div. 2 exceeds supported range (-6 to 6)");
     1338  xConfirmPara( m_loopFilterTcOffsetDiv2 < -6 || m_loopFilterTcOffsetDiv2 > 6,              "Loop Filter Tc Offset div. 2 exceeds supported range (-6 to 6)");
    14431339  xConfirmPara( m_iFastSearch < 0 || m_iFastSearch > 2,                                     "Fast Search Mode is not supported value (0:Full search  1:Diamond  2:PMVFAST)" );
    14441340  xConfirmPara( m_iSearchRange < 0 ,                                                        "Search Range must be more than 0" );
     
    16011497    }
    16021498  }
    1603 #endif 
    1604 
    1605 #if SVC_EXTENSION
     1499
    16061500  // verify layer configuration parameters
    16071501  for(UInt layer=0; layer<m_numLayers; layer++)
     
    18281722  {
    18291723    m_numReorderPics[i] = 0;
    1830 #if L0323_DPB
    18311724    m_maxDecPicBuffering[i] = 1;
    1832 #else
    1833     m_maxDecPicBuffering[i] = 0;
    1834 #endif
    18351725  }
    18361726  for(Int i=0; i<m_iGOPSize; i++)
    18371727  {
    1838 #if L0323_DPB
    18391728    if(m_GOPList[i].m_numRefPics+1 > m_maxDecPicBuffering[m_GOPList[i].m_temporalId])
    1840 #else
    1841     if(m_GOPList[i].m_numRefPics > m_maxDecPicBuffering[m_GOPList[i].m_temporalId])
    1842 #endif
    1843     {
    1844 #if L0323_DPB
     1729    {
    18451730      m_maxDecPicBuffering[m_GOPList[i].m_temporalId] = m_GOPList[i].m_numRefPics + 1;
    1846 #else
    1847       m_maxDecPicBuffering[m_GOPList[i].m_temporalId] = m_GOPList[i].m_numRefPics;
    1848 #endif
    18491731    }
    18501732    Int highestDecodingNumberWithLowerPOC = 0;
     
    18771759      m_numReorderPics[i+1] = m_numReorderPics[i];
    18781760    }
    1879 #if L0323_DPB
    18801761    // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ] - 1, inclusive
    18811762    if(m_numReorderPics[i] > m_maxDecPicBuffering[i] - 1)
     
    18831764      m_maxDecPicBuffering[i] = m_numReorderPics[i] + 1;
    18841765    }
    1885 #else
    1886     // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ], inclusive
    1887     if(m_numReorderPics[i] > m_maxDecPicBuffering[i])
    1888     {
    1889       m_maxDecPicBuffering[i] = m_numReorderPics[i];
    1890     }
    1891 #endif
    18921766    // a lower layer can not have higher value of m_uiMaxDecPicBuffering than a higher layer
    18931767    if(m_maxDecPicBuffering[i+1] < m_maxDecPicBuffering[i])
     
    18981772
    18991773
    1900 #if L0323_DPB
    19011774  // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ] -  1, inclusive
    19021775  if(m_numReorderPics[MAX_TLAYER-1] > m_maxDecPicBuffering[MAX_TLAYER-1] - 1)
     
    19041777    m_maxDecPicBuffering[MAX_TLAYER-1] = m_numReorderPics[MAX_TLAYER-1] + 1;
    19051778  }
    1906 #else
    1907   // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ], inclusive
    1908   if(m_numReorderPics[MAX_TLAYER-1] > m_maxDecPicBuffering[MAX_TLAYER-1])
    1909   {
    1910     m_maxDecPicBuffering[MAX_TLAYER-1] = m_numReorderPics[MAX_TLAYER-1];
    1911   }
    1912 #endif
    19131779
    19141780#if SVC_EXTENSION // ToDo: it should be checked for the case when parameters are different for the layers
     
    19941860  }
    19951861#endif
    1996 #if !L0034_COMBINED_LIST_CLEANUP
    1997   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.
    1998 #endif
    19991862  xConfirmPara( m_iWaveFrontSynchro < 0, "WaveFrontSynchro cannot be negative" );
    20001863#if !SVC_EXTENSION
     
    20051868  xConfirmPara( m_decodedPictureHashSEIEnabled<0 || m_decodedPictureHashSEIEnabled>3, "this hash type is not correct!\n");
    20061869
    2007 #if J0149_TONE_MAPPING_SEI
    20081870  if (m_toneMappingInfoSEIEnabled)
    20091871  {
     
    20161878    xConfirmPara( m_extendedWhiteLevelLumaCodeValue < m_nominalWhiteLevelLumaCodeValue, "SEIToneMapExtendedWhiteLevelLumaCodeValue shall be greater than or equal to SEIToneMapNominalWhiteLevelLumaCodeValue");
    20171879  }
    2018 #endif
    20191880
    20201881#if RATE_CONTROL_LAMBDA_DOMAIN
     
    20661927
    20671928  xConfirmPara(m_log2ParallelMergeLevel < 2, "Log2ParallelMergeLevel should be larger than or equal to 2");
    2068 #if L0444_FPA_TYPE
    20691929  if (m_framePackingSEIEnabled)
    20701930  {
    20711931    xConfirmPara(m_framePackingSEIType < 3 || m_framePackingSEIType > 5 , "SEIFramePackingType must be in rage 3 to 5");
    20721932  }
    2073 #endif
    20741933#if VPS_EXTN_DIRECT_REF_LAYERS
    20751934#if M0457_PREDICTION_INDICATIONS
     
    22662125  printf("RDQ:%d ", m_useRDOQ            );
    22672126  printf("RDQTS:%d ", m_useRDOQTS        );
    2268 #if L0232_RD_PENALTY
    22692127  printf("RDpenalty:%d ", m_rdPenalty  );
    2270 #endif
    22712128  printf("SQP:%d ", m_uiDeltaQpRD         );
    22722129  printf("ASR:%d ", m_bUseASR             );
    2273 #if !L0034_COMBINED_LIST_CLEANUP
    2274   printf("LComb:%d ", m_bUseLComb         );
    2275 #endif
    22762130  printf("FEN:%d ", m_bUseFastEnc         );
    22772131  printf("ECU:%d ", m_bUseEarlyCU         );
  • branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncCfg.h

    r297 r302  
    9999  Level::Tier   m_levelTier;
    100100  Level::Name   m_level;
    101 #if L0046_CONSTRAINT_FLAGS
    102101  Bool m_progressiveSourceFlag;
    103102  Bool m_interlacedSourceFlag;
    104103  Bool m_nonPackedConstraintFlag;
    105104  Bool m_frameOnlyConstraintFlag;
    106 #endif
    107105 
    108106  // coding structure
     
    115113  GOPEntry  m_GOPList[MAX_GOP];                               ///< the coding structure entries from the config file
    116114  Int       m_numReorderPics[MAX_TLAYER];                     ///< total number of reorder pictures
    117 #if L0323_DPB
    118115  Int       m_maxDecPicBuffering[MAX_TLAYER];                 ///< total number of pictures in the decoded picture buffer
    119 #else
    120   Int       m_maxDecPicBuffering[MAX_TLAYER];                 ///< total number of reference pictures needed for decoding
    121 #endif
    122 #if !L0034_COMBINED_LIST_CLEANUP
    123   Bool      m_bUseLComb;                                      ///< flag for using combined reference list for uni-prediction in B-slices (JCTVC-D421)
    124 #endif
    125116  Bool      m_useTransformSkip;                               ///< flag for enabling intra transform skipping
    126117  Bool      m_useTransformSkipFast;                           ///< flag for enabling fast intra transform skipping
     
    184175  Int       m_loopFilterTcOffsetDiv2;                       ///< tc offset for deblocking filter
    185176  Bool      m_DeblockingFilterControlPresent;                 ///< deblocking filter control present flag in PPS
    186 #if L0386_DB_METRIC
    187177  Bool      m_DeblockingFilterMetric;                         ///< blockiness metric in encoder
    188 #endif
    189178 
    190179  // coding tools (PCM)
     
    200189  Bool      m_useRDOQ;                                       ///< flag for using RD optimized quantization
    201190  Bool      m_useRDOQTS;                                     ///< flag for using RD optimized quantization for transform skip
    202 #if L0232_RD_PENALTY
    203191  Int      m_rdPenalty;                                      ///< RD-penalty for 32x32 TU for intra in non-intra slices (0: no RD-penalty, 1: RD-penalty, 2: maximum RD-penalty)
    204 #endif
    205192  Int       m_iFastSearch;                                    ///< ME mode, 0 = full, 1 = diamond, 2 = PMVFAST
    206193  Int       m_iSearchRange;                                   ///< ME search range
     
    241228  Int       m_bufferingPeriodSEIEnabled;
    242229  Int       m_pictureTimingSEIEnabled;
    243 #if J0149_TONE_MAPPING_SEI
    244230  Bool      m_toneMappingInfoSEIEnabled;
    245231  Int       m_toneMapId;
     
    267253  Int*      m_codedPivotValue;
    268254  Int*      m_targetPivotValue;
    269 #endif
    270255  Int       m_framePackingSEIEnabled;
    271256  Int       m_framePackingSEIType;
     
    280265  Int       m_layersPresentSEIEnabled;
    281266#endif
    282 #if L0208_SOP_DESCRIPTION_SEI
    283267  Int       m_SOPDescriptionSEIEnabled;
    284 #endif
    285 #if K0180_SCALABLE_NESTING_SEI
    286268  Int       m_scalableNestingSEIEnabled;
    287 #endif
    288269  // weighted prediction
    289270  Bool      m_useWeightedPred;                    ///< Use of weighted prediction in P slices
     
    299280  Bool      m_RCEnableRateControl;                ///< enable rate control or not
    300281  Int       m_RCTargetBitrate;                    ///< target bitrate when rate control is enabled
     282#if M0036_RC_IMPROVEMENT
     283  Int       m_RCKeepHierarchicalBit;              ///< 0: equal bit allocation; 1: fixed ratio bit allocation; 2: adaptive ratio bit allocation
     284#else
    301285  Bool      m_RCKeepHierarchicalBit;              ///< whether keeping hierarchical bit allocation structure or not
     286#endif
    302287  Bool      m_RCLCULevelRC;                       ///< true: LCU level rate control; false: picture level rate control
    303288  Bool      m_RCUseLCUSeparateModel;              ///< use separate R-lambda model at LCU level
     
    363348  Void  xPrintParameter ();                                   ///< print configuration values
    364349  Void  xPrintUsage     ();                                   ///< print usage
    365 #if SIGNAL_BITRATE_PICRATE_IN_VPS
    366   Int       m_bitRatePicRateMaxTLayers;                       ///< Indicates max. number of sub-layers for which bit rate is signalled.
    367   Bool*     m_bitRateInfoPresentFlag;                         ///< Indicates whether bit rate information is signalled
    368   Bool*     m_picRateInfoPresentFlag;                         ///< Indicates whether pic rate information is signalled
    369   Int*      m_avgBitRate;                                     ///< Indicates avg. bit rate information for various sub-layers
    370   Int*      m_maxBitRate;                                     ///< Indicates max. bit rate information for various sub-layers
    371   Int*      m_avgPicRate;                                     ///< Indicates avg. picture rate information for various sub-layers
    372   Int*      m_constantPicRateIdc;                                ///< Indicates constant picture rate idc for various sub-layers
    373 #endif
    374350#if M0040_ADAPTIVE_RESOLUTION_CHANGE
    375351  Int       m_adaptiveResolutionChange;                       ///< Indicate adaptive resolution change frame
  • branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncTop.cpp

    r297 r302  
    104104    m_acTEncTop[layer].setProfile(m_profile);
    105105    m_acTEncTop[layer].setLevel(m_levelTier, m_level);
    106 #if L0046_CONSTRAINT_FLAGS
    107106    m_acTEncTop[layer].setProgressiveSourceFlag(m_progressiveSourceFlag);
    108107    m_acTEncTop[layer].setInterlacedSourceFlag(m_interlacedSourceFlag);
    109108    m_acTEncTop[layer].setNonPackedConstraintFlag(m_nonPackedConstraintFlag);
    110109    m_acTEncTop[layer].setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag);
    111 #endif
    112110
    113111#if REF_IDX_MFM
     
    244242    m_acTEncTop[layer].setLoopFilterTcOffset           ( m_loopFilterTcOffsetDiv2    );
    245243    m_acTEncTop[layer].setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent);
    246 #if L0386_DB_METRIC
    247244    m_acTEncTop[layer].setDeblockingFilterMetric       ( m_DeblockingFilterMetric );
    248 #endif
    249245
    250246    //====== Motion search ========
     
    280276    m_acTEncTop[layer].setUseHADME                     ( m_bUseHADME    );
    281277    m_acTEncTop[layer].setUseLossless                  ( m_useLossless );
    282 #if !L0034_COMBINED_LIST_CLEANUP
    283     m_cTEncTop.setUseLComb                             ( m_bUseLComb    );
    284 #endif
    285278    m_acTEncTop[layer].setdQPs                         ( m_acLayerCfg[layer].getdQPs() );
    286279    m_acTEncTop[layer].setUseRDOQ                      ( m_useRDOQ     );
    287280    m_acTEncTop[layer].setUseRDOQTS                    ( m_useRDOQTS   );
    288 #if L0232_RD_PENALTY
    289281    m_acTEncTop[layer].setRDpenalty                    ( m_rdPenalty );
    290 #endif
    291282    m_acTEncTop[layer].setQuadtreeTULog2MaxSize        ( m_uiQuadtreeTULog2MaxSize );
    292283    m_acTEncTop[layer].setQuadtreeTULog2MinSize        ( m_uiQuadtreeTULog2MinSize );
     
    355346    m_acTEncTop[layer].setBufferingPeriodSEIEnabled( m_bufferingPeriodSEIEnabled );
    356347    m_acTEncTop[layer].setPictureTimingSEIEnabled( m_pictureTimingSEIEnabled );
    357 #if J0149_TONE_MAPPING_SEI
    358348    m_acTEncTop[layer].setToneMappingInfoSEIEnabled                 ( m_toneMappingInfoSEIEnabled );
    359349    m_acTEncTop[layer].setTMISEIToneMapId                           ( m_toneMapId );
     
    381371    m_acTEncTop[layer].setTMISEINominalWhiteLevelLumaCodeValue      ( m_nominalWhiteLevelLumaCodeValue );
    382372    m_acTEncTop[layer].setTMISEIExtendedWhiteLevelLumaCodeValue     ( m_extendedWhiteLevelLumaCodeValue );
    383 #endif
    384373    m_acTEncTop[layer].setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled );
    385374    m_acTEncTop[layer].setFramePackingArrangementSEIType( m_framePackingSEIType );
     
    394383    m_acTEncTop[layer].setLayersPresentSEIEnabled( m_layersPresentSEIEnabled );
    395384#endif
    396 #if L0208_SOP_DESCRIPTION_SEI
    397385    m_acTEncTop[layer].setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled );
    398 #endif
    399 #if K0180_SCALABLE_NESTING_SEI
    400386    m_acTEncTop[layer].setScalableNestingSEIEnabled( m_scalableNestingSEIEnabled );
    401 #endif
    402387    m_acTEncTop[layer].setUniformSpacingIdr          ( m_iUniformSpacingIdr );
    403388    m_acTEncTop[layer].setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
     
    478463    m_acTEncTop[layer].setLog2MaxMvLengthHorizontal( m_log2MaxMvLengthHorizontal );
    479464    m_acTEncTop[layer].setLog2MaxMvLengthVertical( m_log2MaxMvLengthVertical );
    480 #if SIGNAL_BITRATE_PICRATE_IN_VPS
    481     TComBitRatePicRateInfo *bitRatePicRateInfo = m_cTEncTop[layer].getVPS()->getBitratePicrateInfo();
    482     // The number of bit rate/pic rate have to equal to number of sub-layers.
    483     if(m_bitRatePicRateMaxTLayers)
    484     {
    485       assert(m_bitRatePicRateMaxTLayers == m_cTEncTop[layer].getVPS()->getMaxTLayers());
    486     }
    487     for(Int i = 0; i < m_bitRatePicRateMaxTLayers; i++)
    488     {
    489       bitRatePicRateInfo->setBitRateInfoPresentFlag( i, m_bitRateInfoPresentFlag[i] );
    490       if( bitRatePicRateInfo->getBitRateInfoPresentFlag(i) )
    491       {
    492         bitRatePicRateInfo->setAvgBitRate(i, m_avgBitRate[i]);
    493         bitRatePicRateInfo->setMaxBitRate(i, m_maxBitRate[i]);
    494       }
    495     }
    496     for(Int i = 0; i < m_bitRatePicRateMaxTLayers; i++)
    497     {
    498       bitRatePicRateInfo->setPicRateInfoPresentFlag( i, m_picRateInfoPresentFlag[i] );
    499       if( bitRatePicRateInfo->getPicRateInfoPresentFlag(i) )
    500       {
    501         bitRatePicRateInfo->setAvgPicRate     (i, m_avgPicRate[i]);
    502         bitRatePicRateInfo->setConstantPicRateIdc(i, m_constantPicRateIdc[i]);
    503       }
    504     }
    505 #endif
    506465#if REF_IDX_FRAMEWORK
    507466    m_acTEncTop[layer].setElRapSliceTypeB(layer == 0? 0 : m_elRapSliceBEnabled);
     
    543502  m_cTEncTop.setProfile(m_profile);
    544503  m_cTEncTop.setLevel(m_levelTier, m_level);
    545 #if L0046_CONSTRAINT_FLAGS
    546504  m_cTEncTop.setProgressiveSourceFlag(m_progressiveSourceFlag);
    547505  m_cTEncTop.setInterlacedSourceFlag(m_interlacedSourceFlag);
    548506  m_cTEncTop.setNonPackedConstraintFlag(m_nonPackedConstraintFlag);
    549507  m_cTEncTop.setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag);
    550 #endif
    551508
    552509  m_cTEncTop.setFrameRate                    ( m_iFrameRate );
     
    587544  m_cTEncTop.setLoopFilterTcOffset           ( m_loopFilterTcOffsetDiv2    );
    588545  m_cTEncTop.setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent);
    589 #if L0386_DB_METRIC
    590546  m_cTEncTop.setDeblockingFilterMetric       ( m_DeblockingFilterMetric );
    591 #endif
    592547
    593548  //====== Motion search ========
     
    623578  m_cTEncTop.setUseHADME                     ( m_bUseHADME    );
    624579  m_cTEncTop.setUseLossless                  ( m_useLossless );
    625 #if !L0034_COMBINED_LIST_CLEANUP
    626   m_cTEncTop.setUseLComb                     ( m_bUseLComb    );
    627 #endif
    628580  m_cTEncTop.setdQPs                         ( m_aidQP        );
    629581  m_cTEncTop.setUseRDOQ                      ( m_useRDOQ     );
    630582  m_cTEncTop.setUseRDOQTS                    ( m_useRDOQTS   );
    631 #if L0232_RD_PENALTY
    632583  m_cTEncTop.setRDpenalty                 ( m_rdPenalty );
    633 #endif
    634584  m_cTEncTop.setQuadtreeTULog2MaxSize        ( m_uiQuadtreeTULog2MaxSize );
    635585  m_cTEncTop.setQuadtreeTULog2MinSize        ( m_uiQuadtreeTULog2MinSize );
     
    698648  m_cTEncTop.setBufferingPeriodSEIEnabled( m_bufferingPeriodSEIEnabled );
    699649  m_cTEncTop.setPictureTimingSEIEnabled( m_pictureTimingSEIEnabled );
    700 #if J0149_TONE_MAPPING_SEI
    701650  m_cTEncTop.setToneMappingInfoSEIEnabled                 ( m_toneMappingInfoSEIEnabled );
    702651  m_cTEncTop.setTMISEIToneMapId                           ( m_toneMapId );
     
    724673  m_cTEncTop.setTMISEINominalWhiteLevelLumaCodeValue      ( m_nominalWhiteLevelLumaCodeValue );
    725674  m_cTEncTop.setTMISEIExtendedWhiteLevelLumaCodeValue     ( m_extendedWhiteLevelLumaCodeValue );
    726 #endif
    727675  m_cTEncTop.setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled );
    728676  m_cTEncTop.setFramePackingArrangementSEIType( m_framePackingSEIType );
     
    737685  m_cTEncTop.setLayersPresentSEIEnabled( m_layersPresentSEIEnabled );
    738686#endif
    739 #if L0208_SOP_DESCRIPTION_SEI
    740687  m_cTEncTop.setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled );
    741 #endif
    742 #if K0180_SCALABLE_NESTING_SEI
    743688  m_cTEncTop.setScalableNestingSEIEnabled( m_scalableNestingSEIEnabled );
    744 #endif
    745689  m_cTEncTop.setUniformSpacingIdr          ( m_iUniformSpacingIdr );
    746690  m_cTEncTop.setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
     
    811755  m_cTEncTop.setLog2MaxMvLengthHorizontal( m_log2MaxMvLengthHorizontal );
    812756  m_cTEncTop.setLog2MaxMvLengthVertical( m_log2MaxMvLengthVertical );
    813 #if SIGNAL_BITRATE_PICRATE_IN_VPS
    814   TComBitRatePicRateInfo *bitRatePicRateInfo = m_cTEncTop.getVPS()->getBitratePicrateInfo();
    815   // The number of bit rate/pic rate have to equal to number of sub-layers.
    816   if(m_bitRatePicRateMaxTLayers)
    817   {
    818     assert(m_bitRatePicRateMaxTLayers == m_cTEncTop.getVPS()->getMaxTLayers());
    819   }
    820   for(Int i = 0; i < m_bitRatePicRateMaxTLayers; i++)
    821   {
    822     bitRatePicRateInfo->setBitRateInfoPresentFlag( i, m_bitRateInfoPresentFlag[i] );
    823     if( bitRatePicRateInfo->getBitRateInfoPresentFlag(i) )
    824     {
    825       bitRatePicRateInfo->setAvgBitRate(i, m_avgBitRate[i]);
    826       bitRatePicRateInfo->setMaxBitRate(i, m_maxBitRate[i]);
    827     }
    828   }
    829   for(Int i = 0; i < m_bitRatePicRateMaxTLayers; i++)
    830   {
    831     bitRatePicRateInfo->setPicRateInfoPresentFlag( i, m_picRateInfoPresentFlag[i] );
    832     if( bitRatePicRateInfo->getPicRateInfoPresentFlag(i) )
    833     {
    834       bitRatePicRateInfo->setAvgPicRate     (i, m_avgPicRate[i]);
    835       bitRatePicRateInfo->setConstantPicRateIdc(i, m_constantPicRateIdc[i]);
    836     }
    837   }
    838 #endif
    839757}
    840758#endif
  • branches/SHM-2.1-dev/source/App/TAppEncoder/encmain.cpp

    r191 r302  
    5757  // print information
    5858  fprintf( stdout, "\n" );
     59#if SVC_EXTENSION
    5960  fprintf( stdout, "SHM software: Encoder Version [%s]", NV_VERSION );
     61#else
     62  fprintf( stdout, "HM software: Encoder Version [%s]", NV_VERSION );
     63#endif
    6064  fprintf( stdout, NVM_ONOS );
    6165  fprintf( stdout, NVM_COMPILEDBY );
  • branches/SHM-2.1-dev/source/Lib/TLibCommon/CommonDef.h

    r194 r302  
    5656// ====================================================================================================================
    5757
     58#if SVC_EXTENSION
    5859#define NV_VERSION        "2.1"                 ///< Current software version
     60#else
     61#define NV_VERSION        "11.0"                ///< Current software version
     62#endif
    5963
    6064// ====================================================================================================================
     
    110114#define MAX_NUM_REF_PICS            16          ///< max. number of pictures used for reference
    111115#define MAX_NUM_REF                 16          ///< max. number of entries in picture reference list
    112 #if !L0034_COMBINED_LIST_CLEANUP
    113 #define MAX_NUM_REF_LC              MAX_NUM_REF_PICS  // TODO: remove this macro definition (leftover from combined list concept)
    114 #endif
    115116
    116117#define MAX_UINT                    0xFFFFFFFFU ///< max. value of unsigned 32-bit integer
  • branches/SHM-2.1-dev/source/Lib/TLibCommon/NAL.h

    r191 r302  
    9191        || m_nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R;
    9292  }
    93 #if L0045_NON_NESTED_SEI_RESTRICTIONS
    9493  Bool isSei()
    9594  {
     
    102101    return ( (UInt)m_nalUnitType < 32 );
    103102  }
    104 #endif
    105103};
    106104
  • branches/SHM-2.1-dev/source/Lib/TLibCommon/SEI.cpp

    r189 r302  
    3939#include "SEI.h"
    4040
    41 #if J0149_TONE_MAPPING_SEI
    4241//Table D-7 Meaning of camera iso sensitivity indicator and exposure index rating indicator
    4342Int  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
    4543
    4644SEIMessages getSeisByType(SEIMessages &seiList, SEI::PayloadType seiType)
  • branches/SHM-2.1-dev/source/Lib/TLibCommon/SEI.h

    r292 r302  
    127127
    128128  SEIActiveParameterSets()
    129 #if !L0047_APS_FLAGS
    130     :numSpsIdsMinus1(0)
    131 #else
    132129    : activeVPSId            (0)
    133130    , m_fullRandomAccessFlag (false)
    134131    , m_noParamSetUpdateFlag (false)
    135132    , numSpsIdsMinus1        (0)
    136 #endif
    137133  {}
    138134  virtual ~SEIActiveParameterSets() {}
    139135
    140136  Int activeVPSId;
    141 #if L0047_APS_FLAGS
    142137  Bool m_fullRandomAccessFlag;
    143138  Bool m_noParamSetUpdateFlag;
    144 #endif
    145139  Int numSpsIdsMinus1;
    146140  std::vector<Int> activeSeqParamSetId;
     
    153147
    154148  SEIBufferingPeriod()
    155 #if L0044_CPB_DPB_DELAY_OFFSET
    156149  : m_bpSeqParameterSetId (0)
    157150  , m_rapCpbParamsPresentFlag (false)
     
    164157    ::memset(m_initialAltCpbRemovalDelayOffset, 0, sizeof(m_initialAltCpbRemovalDelayOffset));
    165158  }
    166 #else
    167   {}
    168 #endif
    169159  virtual ~SEIBufferingPeriod() {}
    170160
    171161  UInt m_bpSeqParameterSetId;
    172162  Bool m_rapCpbParamsPresentFlag;
    173 #if L0044_CPB_DPB_DELAY_OFFSET
    174163  Bool m_cpbDelayOffset;
    175164  Bool m_dpbDelayOffset;
    176 #endif
    177165  UInt m_initialCpbRemovalDelay         [MAX_CPB_CNT][2];
    178166  UInt m_initialCpbRemovalDelayOffset   [MAX_CPB_CNT][2];
    179167  UInt m_initialAltCpbRemovalDelay      [MAX_CPB_CNT][2];
    180168  UInt m_initialAltCpbRemovalDelayOffset[MAX_CPB_CNT][2];
    181 #if L0328_SPLICING
    182169  Bool m_concatenationFlag;
    183170  UInt m_auCpbRemovalDelayDelta;
    184 #endif
    185171};
    186172class SEIPictureTiming : public SEI
     
    191177  SEIPictureTiming()
    192178  : m_picStruct               (0)
    193 #if L0046_RENAME_PROG_SRC_IDC
    194179  , m_sourceScanType          (0)
    195 #else
    196   , m_progressiveSourceIdc    (0)
    197 #endif
    198180  , m_duplicateFlag           (false)
    199 #if L0044_DU_DPB_OUTPUT_DELAY_HRD
    200181  , m_picDpbOutputDuDelay     (0)
    201 #endif
    202182  , m_numNalusInDuMinus1      (NULL)
    203183  , m_duCpbRemovalDelayMinus1 (NULL)
     
    216196
    217197  UInt  m_picStruct;
    218 #if L0046_RENAME_PROG_SRC_IDC
    219198  UInt  m_sourceScanType;
    220 #else
    221   UInt  m_progressiveSourceIdc;
    222 #endif
    223199  Bool  m_duplicateFlag;
    224200
    225201  UInt  m_auCpbRemovalDelay;
    226202  UInt  m_picDpbOutputDelay;
    227 #if L0044_DU_DPB_OUTPUT_DELAY_HRD
    228203  UInt  m_picDpbOutputDuDelay;
    229 #endif
    230204  UInt  m_numDecodingUnitsMinus1;
    231205  Bool  m_duCommonCpbRemovalDelayFlag;
     
    243217    : m_decodingUnitIdx(0)
    244218    , m_duSptCpbRemovalDelay(0)
    245 #if L0044_DU_DPB_OUTPUT_DELAY_HRD
    246219    , m_dpbOutputDuDelayPresentFlag(false)
    247220    , m_picSptDpbOutputDuDelay(0)
    248 #endif
    249221  {}
    250222  virtual ~SEIDecodingUnitInfo() {}
    251223  Int m_decodingUnitIdx;
    252224  Int m_duSptCpbRemovalDelay;
    253 #if L0044_DU_DPB_OUTPUT_DELAY_HRD
    254225  Bool m_dpbOutputDuDelayPresentFlag;
    255226  Int m_picSptDpbOutputDuDelay;
    256 #endif
    257227};
    258228
     
    293263  Int  m_frame1GridPositionY;
    294264  Int  m_arrangementReservedByte;
    295 #if L0045_PERSISTENCE_FLAGS
    296265  Bool m_arrangementPersistenceFlag;
    297 #else
    298   Int  m_arrangementRepetetionPeriod;
    299 #endif
    300266  Bool m_upsampledAspectRatio;
    301267};
     
    308274  SEIDisplayOrientation()
    309275    : cancelFlag(true)
    310 #if L0045_PERSISTENCE_FLAGS
    311276    , persistenceFlag(0)
    312 #else
    313     , repetitionPeriod(1)
    314 #endif
    315277    , extensionFlag(false)
    316278    {}
     
    322284
    323285  UInt anticlockwiseRotation;
    324 #if L0045_PERSISTENCE_FLAGS
    325286  Bool persistenceFlag;
    326 #else
    327   UInt repetitionPeriod;
    328 #endif
    329287  Bool extensionFlag;
    330288};
     
    373331#endif
    374332
    375 #if L0208_SOP_DESCRIPTION_SEI
    376333class SEISOPDescription : public SEI
    377334{
     
    390347  Int m_sopDescPocDelta[MAX_NUM_PICS_IN_SOP];
    391348};
    392 #endif
    393 
    394 #if J0149_TONE_MAPPING_SEI
     349
    395350class SEIToneMappingInfo : public SEI
    396351{
     
    425380  Int    m_extendedWhiteLevelLumaCodeValue;
    426381};
    427 #endif
    428382
    429383typedef std::list<SEI*> SEIMessages;
     
    438392Void deleteSEIs (SEIMessages &seiList);
    439393
    440 #if K0180_SCALABLE_NESTING_SEI
    441394class SEIScalableNesting : public SEI
    442395{
     
    468421  SEIMessages m_nestedSEIs;
    469422};
    470 #endif
    471423
    472424//! \}
  • branches/SHM-2.1-dev/source/Lib/TLibCommon/TComBitStream.h

    r191 r302  
    193193  }
    194194
     195  Void        peekPreviousByte( UInt &byte )
     196  {
     197    assert(m_fifo_idx > 0);
     198    byte = (*m_fifo)[m_fifo_idx - 1];
     199  }
     200 
    195201  Void        readOutTrailingBits ();
    196202  UChar getHeldBits  ()          { return m_held_bits;          }
  • branches/SHM-2.1-dev/source/Lib/TLibCommon/TComDataCU.cpp

    r291 r302  
    589589  }
    590590
    591   UInt uiTmp = uhWidth*uhHeight;
    592 
    593591  if(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU >= getSlice()->getSliceSegmentCurStartCUAddr())
    594592  {
    595593    m_acCUMvField[0].clearMvField();
    596594    m_acCUMvField[1].clearMvField();
    597     uiTmp = uhWidth*uhHeight;
     595    UInt uiTmp = uhWidth*uhHeight;
    598596   
    599597    memset( m_pcTrCoeffY,    0, uiTmp * sizeof( *m_pcTrCoeffY    ) );
     
    794792  m_uiCUPelY           = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
    795793 
    796   UInt uiWidth         = g_uiMaxCUWidth  >> uiDepth;
    797   UInt uiHeight        = g_uiMaxCUHeight >> uiDepth;
    798  
    799794  m_skipFlag=pcCU->getSkipFlag()          + uiPart;
    800795
     
    838833  m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1);
    839834 
    840   UInt uiTmp = uiWidth*uiHeight;
    841835  UInt uiMaxCuWidth=pcCU->getSlice()->getSPS()->getMaxCUWidth();
    842836  UInt uiMaxCuHeight=pcCU->getSlice()->getSPS()->getMaxCUHeight();
     
    850844  m_pcIPCMSampleY = pcCU->getPCMSampleY() + uiCoffOffset;
    851845
    852   uiTmp >>= 2;
    853846  uiCoffOffset >>=2;
    854847  m_pcTrCoeffCb=pcCU->getCoeffCb() + uiCoffOffset;
     
    15771570    return getSlice()->getSliceQp();
    15781571  }
    1579   else
    1580   if ( iLastValidPartIdx >= 0 )
     1572  else if ( iLastValidPartIdx >= 0 )
    15811573  {
    15821574    return getQP( iLastValidPartIdx );
     
    28602852    //>> MTK colocated-RightBottom
    28612853    UInt uiPartIdxRB;
    2862     Int uiLCUIdx = getAddr();
    28632854
    28642855    deriveRightBottomIdx( uiPUIdx, uiPartIdxRB ); 
     
    28692860    TComMv cColMv;
    28702861    Int iRefIdx;
     2862    Int uiLCUIdx = -1;
    28712863
    28722864    if      ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() )  // image boundary check
    28732865    {
    2874       uiLCUIdx = -1;
    28752866    }
    28762867    else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() )
    28772868    {
    2878       uiLCUIdx = -1;
    28792869    }
    28802870    else
     
    28892879      {
    28902880        uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ];
    2891         uiLCUIdx = -1 ;
    28922881      }
    28932882      else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU
     
    28992888      {
    29002889        uiAbsPartAddr = 0;
    2901         uiLCUIdx = -1 ;
    29022890      }
    29032891    }
     
    31633151    if (!bAdded)
    31643152    {
    3165       bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT );
     3153      xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT );
    31663154    }
    31673155  }
     
    31763164  if(!bAdded)
    31773165  {
    3178     bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT);
     3166    xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT);
    31793167  }
    31803168  bAdded = bAddedSmvp;
     
    31913179    if(!bAdded)
    31923180    {
    3193       bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT);
     3181      xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT);
    31943182    }
    31953183  }
     
    32113199    UInt uiAbsPartIdx; 
    32123200    UInt uiAbsPartAddr;
    3213     Int uiLCUIdx = getAddr();
    32143201
    32153202    deriveRightBottomIdx( uiPartIdx, uiPartIdxRB );
     
    32183205    //----  co-located RightBottom Temporal Predictor (H) ---//
    32193206    uiAbsPartIdx = g_auiZscanToRaster[uiPartIdxRB];
     3207    Int uiLCUIdx = -1;
    32203208    if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdx] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() )  // image boundary check
    32213209    {
    3222       uiLCUIdx = -1;
    32233210    }
    32243211    else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdx] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() )
    32253212    {
    3226       uiLCUIdx = -1;
    32273213    }
    32283214    else
     
    32373223      {
    32383224        uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdx + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ];
    3239         uiLCUIdx      = -1 ;
    32403225      }
    32413226      else if ( uiAbsPartIdx / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU
     
    32473232      {
    32483233        uiAbsPartAddr = 0;
    3249         uiLCUIdx      = -1 ;
    32503234      }
    32513235    }
     
    33093293UInt TComDataCU::getIntraSizeIdx(UInt uiAbsPartIdx)
    33103294{
    3311   UInt uiShift = ( (m_puhTrIdx[uiAbsPartIdx]==0) && (m_pePartSize[uiAbsPartIdx]==SIZE_NxN) ) ? m_puhTrIdx[uiAbsPartIdx]+1 : m_puhTrIdx[uiAbsPartIdx];
    3312   uiShift = ( m_pePartSize[uiAbsPartIdx]==SIZE_NxN ? 1 : 0 );
     3295  UInt uiShift = ( m_pePartSize[uiAbsPartIdx]==SIZE_NxN ? 1 : 0 );
    33133296 
    33143297  UChar uiWidth = m_puhWidth[uiAbsPartIdx]>>uiShift;
     
    33963379  }
    33973380 
    3398 #if L0363_MVP_POC
    33993381  if ( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0 && m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC() == pcTmpCU->getSlice()->getRefPOC( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ))
    3400 #else
    3401   if ( m_pcSlice->isEqualRef(eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx), iRefIdx) )
    3402 #endif
    34033382  {
    34043383    TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
     
    36023581  }
    36033582  iCurrPOC = m_pcSlice->getPOC();   
    3604   iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC();
    36053583  iColPOC = pColCU->getSlice()->getPOC(); 
    36063584
  • branches/SHM-2.1-dev/source/Lib/TLibCommon/TComLoopFilter.cpp

    r191 r302  
    461461        if ( ((piRefP0==piRefQ0)&&(piRefP1==piRefQ1)) || ((piRefP0==piRefQ1)&&(piRefP1==piRefQ0)) )
    462462        {
    463           uiBs = 0;
    464463          if ( piRefP0 != piRefP1 )   // Different L0 & L1
    465464          {
     
    694693  for ( UInt iIdx = 0; iIdx < uiNumParts; iIdx++ )
    695694  {
    696     ucBs = 0;
    697    
    698695    uiBsAbsIdx = xCalcBsIdx( pcCU, uiAbsZorderIdx, iDir, iEdge, iIdx);
    699696    ucBs = m_aapucBS[iDir][uiBsAbsIdx];
  • branches/SHM-2.1-dev/source/Lib/TLibCommon/TComPrediction.cpp

    r282 r302  
    122122Pel TComPrediction::predIntraGetPredValDC( Int* pSrc, Int iSrcStride, UInt iWidth, UInt iHeight, Bool bAbove, Bool bLeft )
    123123{
     124  assert(iWidth > 0 && iHeight > 0);
    124125  Int iInd, iSum = 0;
    125126  Pel pDcVal;
  • branches/SHM-2.1-dev/source/Lib/TLibCommon/TComRdCost.cpp

    r191 r302  
    485485}
    486486
    487 #if RATE_CONTROL_LAMBDA_DOMAIN
     487#if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT
    488488UInt TComRdCost::getSADPart ( Int bitDepth, Pel* pelCur, Int curStride,  Pel* pelOrg, Int orgStride, UInt width, UInt height )
    489489{
  • branches/SHM-2.1-dev/source/Lib/TLibCommon/TComRdCost.h

    r191 r302  
    168168#if RATE_CONTROL_LAMBDA_DOMAIN
    169169  Double  getLambda() { return m_dLambda; }
     170#if M0036_RC_IMPROVEMENT
     171  Double  getChromaWeight () {return((m_cbDistortionWeight+m_crDistortionWeight)/2.0);}
     172#endif
    170173#endif
    171174 
     
    264267#endif
    265268
    266 #if RATE_CONTROL_LAMBDA_DOMAIN
     269#if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT
    267270  UInt   getSADPart ( Int bitDepth, Pel* pelCur, Int curStride,  Pel* pelOrg, Int orgStride, UInt width, UInt height );
    268271#endif
  • branches/SHM-2.1-dev/source/Lib/TLibCommon/TComSlice.cpp

    r300 r302  
    6565, m_deblockingFilterBetaOffsetDiv2 ( 0 )
    6666, m_deblockingFilterTcOffsetDiv2   ( 0 )
    67 #if !L0034_COMBINED_LIST_CLEANUP
    68 , m_bRefPicListModificationFlagLC ( false )
    69 , m_bRefPicListCombinationFlag    ( false )
    70 #endif
    7167, m_bCheckLDC                     ( false )
    7268, m_iSliceQpDelta                 ( 0 )
     
    8884#else
    8985, m_dLambda                       ( 0.0 )
    90 #endif
    91 #if !L0034_COMBINED_LIST_CLEANUP
    92 , m_bNoBackPredFlag             ( false )
    9386#endif
    9487, m_uiTLayer                      ( 0 )
     
    119112, m_enableTMVPFlag                ( true )
    120113{
    121 #if L0034_COMBINED_LIST_CLEANUP
    122114  m_aiNumRefIdx[0] = m_aiNumRefIdx[1] = 0;
    123 #else
    124   m_aiNumRefIdx[0] = m_aiNumRefIdx[1] = m_aiNumRefIdx[2] = 0;
    125 #endif
    126115
    127116#if SVC_EXTENSION
     
    148137  initEqualRef();
    149138 
    150 #if L0034_COMBINED_LIST_CLEANUP
    151139  for ( Int idx = 0; idx < MAX_NUM_REF; idx++ )
    152140  {
    153141    m_list1IdxToList0Idx[idx] = -1;
    154142  }
    155 #else
    156   for(Int iNumCount = 0; iNumCount < MAX_NUM_REF_LC; iNumCount++)
    157   {
    158     m_iRefIdxOfLC[REF_PIC_LIST_0][iNumCount]=-1;
    159     m_iRefIdxOfLC[REF_PIC_LIST_1][iNumCount]=-1;
    160     m_eListIdFromIdxOfLC[iNumCount]=0;
    161     m_iRefIdxFromIdxOfLC[iNumCount]=0;
    162     m_iRefIdxOfL0FromRefIdxOfL1[iNumCount] = -1;
    163     m_iRefIdxOfL1FromRefIdxOfL0[iNumCount] = -1;
    164   }   
    165 #endif
    166143  for(Int iNumCount = 0; iNumCount < MAX_NUM_REF; iNumCount++)
    167144  {
     
    210187  m_colRefIdx = 0;
    211188  initEqualRef();
    212 #if !L0034_COMBINED_LIST_CLEANUP
    213   m_bNoBackPredFlag = false;
    214   m_bRefPicListCombinationFlag = false;
    215   m_bRefPicListModificationFlagLC = false;
    216 #endif
    217189  m_bCheckLDC = false;
    218190  m_iSliceQpDeltaCb = 0;
    219191  m_iSliceQpDeltaCr = 0;
    220 
    221 #if !L0034_COMBINED_LIST_CLEANUP
    222   m_aiNumRefIdx[REF_PIC_LIST_C]      = 0;
    223 #endif
    224192
    225193  m_maxNumMergeCand = MRG_MAX_NUM_CANDS;
     
    364332}
    365333
    366 #if L0034_COMBINED_LIST_CLEANUP
    367334Void TComSlice::setList1IdxToList0Idx()
    368335{
     
    381348  }
    382349}
    383 #else
    384 Void TComSlice::generateCombinedList()
    385 {
    386   if(m_aiNumRefIdx[REF_PIC_LIST_C] > 0)
    387   {
    388     m_aiNumRefIdx[REF_PIC_LIST_C]=0;
    389     for(Int iNumCount = 0; iNumCount < MAX_NUM_REF_LC; iNumCount++)
    390     {
    391       m_iRefIdxOfLC[REF_PIC_LIST_0][iNumCount]=-1;
    392       m_iRefIdxOfLC[REF_PIC_LIST_1][iNumCount]=-1;
    393       m_eListIdFromIdxOfLC[iNumCount]=0;
    394       m_iRefIdxFromIdxOfLC[iNumCount]=0;
    395       m_iRefIdxOfL0FromRefIdxOfL1[iNumCount] = -1;
    396       m_iRefIdxOfL1FromRefIdxOfL0[iNumCount] = -1;
    397     }
    398 
    399     for (Int iNumRefIdx = 0; iNumRefIdx < MAX_NUM_REF; iNumRefIdx++)
    400     {
    401       if(iNumRefIdx < m_aiNumRefIdx[REF_PIC_LIST_0])
    402       {
    403         Bool bTempRefIdxInL2 = true;
    404         for ( Int iRefIdxLC = 0; iRefIdxLC < m_aiNumRefIdx[REF_PIC_LIST_C]; iRefIdxLC++ )
    405         {
    406           if ( m_apcRefPicList[REF_PIC_LIST_0][iNumRefIdx]->getPOC() == m_apcRefPicList[m_eListIdFromIdxOfLC[iRefIdxLC]][m_iRefIdxFromIdxOfLC[iRefIdxLC]]->getPOC() )
    407           {
    408             m_iRefIdxOfL1FromRefIdxOfL0[iNumRefIdx] = m_iRefIdxFromIdxOfLC[iRefIdxLC];
    409             m_iRefIdxOfL0FromRefIdxOfL1[m_iRefIdxFromIdxOfLC[iRefIdxLC]] = iNumRefIdx;
    410             bTempRefIdxInL2 = false;
    411             break;
    412           }
    413         }
    414 
    415         if(bTempRefIdxInL2 == true)
    416         {
    417           m_eListIdFromIdxOfLC[m_aiNumRefIdx[REF_PIC_LIST_C]] = REF_PIC_LIST_0;
    418           m_iRefIdxFromIdxOfLC[m_aiNumRefIdx[REF_PIC_LIST_C]] = iNumRefIdx;
    419           m_iRefIdxOfLC[REF_PIC_LIST_0][iNumRefIdx] = m_aiNumRefIdx[REF_PIC_LIST_C]++;
    420         }
    421       }
    422 
    423       if(iNumRefIdx < m_aiNumRefIdx[REF_PIC_LIST_1])
    424       {
    425         Bool bTempRefIdxInL2 = true;
    426         for ( Int iRefIdxLC = 0; iRefIdxLC < m_aiNumRefIdx[REF_PIC_LIST_C]; iRefIdxLC++ )
    427         {
    428           if ( m_apcRefPicList[REF_PIC_LIST_1][iNumRefIdx]->getPOC() == m_apcRefPicList[m_eListIdFromIdxOfLC[iRefIdxLC]][m_iRefIdxFromIdxOfLC[iRefIdxLC]]->getPOC() )
    429           {
    430             m_iRefIdxOfL0FromRefIdxOfL1[iNumRefIdx] = m_iRefIdxFromIdxOfLC[iRefIdxLC];
    431             m_iRefIdxOfL1FromRefIdxOfL0[m_iRefIdxFromIdxOfLC[iRefIdxLC]] = iNumRefIdx;
    432             bTempRefIdxInL2 = false;
    433             break;
    434           }
    435         }
    436         if(bTempRefIdxInL2 == true)
    437         {
    438           m_eListIdFromIdxOfLC[m_aiNumRefIdx[REF_PIC_LIST_C]] = REF_PIC_LIST_1;
    439           m_iRefIdxFromIdxOfLC[m_aiNumRefIdx[REF_PIC_LIST_C]] = iNumRefIdx;
    440           m_iRefIdxOfLC[REF_PIC_LIST_1][iNumRefIdx] = m_aiNumRefIdx[REF_PIC_LIST_C]++;
    441         }
    442       }
    443     }
    444   }
    445 }
    446 #endif
    447350
    448351#if FIX1071
     352#if SVC_EXTENSION
    449353Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr, TComPic** ilpPic)
     354#else
     355Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr )
     356#endif
    450357#else
    451358Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic )
     
    456363#endif
    457364  {
    458     if( m_eSliceType == I_SLICE )
     365    if (m_eSliceType == I_SLICE)
    459366    {
    460367      ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList));
    461368      ::memset( m_aiNumRefIdx,   0, sizeof ( m_aiNumRefIdx ));
     369     
    462370      return;
    463371    }
     
    672580    }
    673581   
    674     assert(numPocTotalCurr != 0);
     582    assert(numPocTotalCurr > 0);
    675583   
    676584    m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0);
     
    699607    {
    700608      rpsCurrList0[cIdx] = RefPicSetLtCurr[i];
    701     }
     609    }   
     610
    702611#if REF_IDX_FRAMEWORK
    703612    if( m_layerId > 0 )
     
    718627    }
    719628#endif
     629  assert(cIdx == numPocTotalCurr);
     630
    720631  if (m_eSliceType==B_SLICE)
    721632  {
     
    732643    {
    733644      rpsCurrList1[cIdx] = RefPicSetLtCurr[i];
    734     }
     645    }   
     646
    735647#if REF_IDX_FRAMEWORK
    736648    if( m_layerId > 0 )
     
    751663    }
    752664#endif
     665
     666    assert(cIdx == numPocTotalCurr);
    753667  }
    754668
    755669  ::memset(m_bIsUsedAsLongTerm, 0, sizeof(m_bIsUsedAsLongTerm));
    756670
    757   for (Int rIdx = 0; rIdx <= (m_aiNumRefIdx[0]-1); rIdx ++)
    758   {
    759     m_apcRefPicList[0][rIdx] = m_RefPicListModification.getRefPicListModificationFlagL0() ? rpsCurrList0[ m_RefPicListModification.getRefPicSetIdxL0(rIdx) ] : rpsCurrList0[rIdx % numPocTotalCurr];
    760     m_bIsUsedAsLongTerm[0][rIdx] = m_RefPicListModification.getRefPicListModificationFlagL0() ? (m_RefPicListModification.getRefPicSetIdxL0(rIdx) >= (NumPocStCurr0 + NumPocStCurr1))
    761                                   : ((rIdx % numPocTotalCurr) >= (NumPocStCurr0 + NumPocStCurr1));
    762   }
    763   if ( m_eSliceType == P_SLICE )
     671  for (Int rIdx = 0; rIdx < m_aiNumRefIdx[0]; rIdx ++)
     672  {
     673    cIdx = m_RefPicListModification.getRefPicListModificationFlagL0() ? m_RefPicListModification.getRefPicSetIdxL0(rIdx) : rIdx % numPocTotalCurr;
     674    assert(cIdx >= 0 && cIdx < numPocTotalCurr);
     675    m_apcRefPicList[0][rIdx] = rpsCurrList0[ cIdx ];
     676    m_bIsUsedAsLongTerm[0][rIdx] = ( cIdx >= NumPocStCurr0 + NumPocStCurr1 );
     677  }
     678  if ( m_eSliceType != B_SLICE )
    764679  {
    765680    m_aiNumRefIdx[1] = 0;
     
    768683  else
    769684  {
    770     for (Int rIdx = 0; rIdx <= (m_aiNumRefIdx[1]-1); rIdx ++)
    771     {
    772       m_apcRefPicList[1][rIdx] = m_RefPicListModification.getRefPicListModificationFlagL1() ? rpsCurrList1[ m_RefPicListModification.getRefPicSetIdxL1(rIdx) ] : rpsCurrList1[rIdx % numPocTotalCurr];
    773       m_bIsUsedAsLongTerm[1][rIdx] = m_RefPicListModification.getRefPicListModificationFlagL1() ?
    774                                   (m_RefPicListModification.getRefPicSetIdxL1(rIdx) >= (NumPocStCurr0 + NumPocStCurr1)): ((rIdx % numPocTotalCurr) >= (NumPocStCurr0 + NumPocStCurr1));
     685    for (Int rIdx = 0; rIdx < m_aiNumRefIdx[1]; rIdx ++)
     686    {
     687      cIdx = m_RefPicListModification.getRefPicListModificationFlagL1() ? m_RefPicListModification.getRefPicSetIdxL1(rIdx) : rIdx % numPocTotalCurr;
     688      assert(cIdx >= 0 && cIdx < numPocTotalCurr);
     689      m_apcRefPicList[1][rIdx] = rpsCurrList1[ cIdx ];
     690      m_bIsUsedAsLongTerm[1][rIdx] = ( cIdx >= NumPocStCurr0 + NumPocStCurr1 );
    775691    }
    776692  }
     
    1071987  m_deblockingFilterTcOffsetDiv2 = pSrc->m_deblockingFilterTcOffsetDiv2;
    1072988 
    1073 #if L0034_COMBINED_LIST_CLEANUP
    1074989  for (i = 0; i < 2; i++)
    1075 #else
    1076   for (i = 0; i < 3; i++)
    1077 #endif
    1078990  {
    1079991    m_aiNumRefIdx[i]     = pSrc->m_aiNumRefIdx[i];
    1080992  }
    1081993
    1082 #if L0034_COMBINED_LIST_CLEANUP
    1083994  for (i = 0; i < MAX_NUM_REF; i++)
    1084995  {
    1085996    m_list1IdxToList0Idx[i] = pSrc->m_list1IdxToList0Idx[i];
    1086997  }
    1087 #else
    1088   for (i = 0; i < 2; i++)
    1089   {
    1090     for (j = 0; j < MAX_NUM_REF_LC; j++)
    1091     {
    1092        m_iRefIdxOfLC[i][j]  = pSrc->m_iRefIdxOfLC[i][j];
    1093     }
    1094   }
    1095   for (i = 0; i < MAX_NUM_REF_LC; i++)
    1096   {
    1097     m_eListIdFromIdxOfLC[i] = pSrc->m_eListIdFromIdxOfLC[i];
    1098     m_iRefIdxFromIdxOfLC[i] = pSrc->m_iRefIdxFromIdxOfLC[i];
    1099     m_iRefIdxOfL1FromRefIdxOfL0[i] = pSrc->m_iRefIdxOfL1FromRefIdxOfL0[i];
    1100     m_iRefIdxOfL0FromRefIdxOfL1[i] = pSrc->m_iRefIdxOfL0FromRefIdxOfL1[i];
    1101   }
    1102   m_bRefPicListModificationFlagLC = pSrc->m_bRefPicListModificationFlagLC;
    1103   m_bRefPicListCombinationFlag    = pSrc->m_bRefPicListCombinationFlag;
    1104 #endif
    1105998  m_bCheckLDC             = pSrc->m_bCheckLDC;
    1106999  m_iSliceQpDelta        = pSrc->m_iSliceQpDelta;
     
    11641057  }
    11651058
    1166 #if !L0034_COMBINED_LIST_CLEANUP
    1167   m_bNoBackPredFlag      = pSrc->m_bNoBackPredFlag;
    1168 #endif
    11691059  m_uiTLayer                      = pSrc->m_uiTLayer;
    11701060  m_bTLayerSwitchingFlag          = pSrc->m_bTLayerSwitchingFlag;
     
    14711361/** Function for constructing an explicit Reference Picture Set out of the available pictures in a referenced Reference Picture Set
    14721362*/
     1363#if FIX1071
     1364Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool isRAP)
     1365#else
    14731366Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet)
     1367#endif
    14741368{
    14751369  TComPic* rpcPic;
     
    14961390        // and should be added to the explicit Reference Picture Set
    14971391        pcRPS->setDeltaPOC(k, pReferencePictureSet->getDeltaPOC(i));
     1392#if FIX1071
     1393        pcRPS->setUsed(k, pReferencePictureSet->getUsed(i) && (!isRAP));
     1394#else
    14981395        pcRPS->setUsed(k, pReferencePictureSet->getUsed(i));
     1396#endif
    14991397        if(pcRPS->getDeltaPOC(k) < 0)
    15001398        {
     
    16741572  {
    16751573    m_numReorderPics[i] = 0;
    1676 #if L0323_DPB
    16771574    m_uiMaxDecPicBuffering[i] = 1;
    1678 #else
    1679     m_uiMaxDecPicBuffering[i] = 0;
    1680 #endif
    16811575    m_uiMaxLatencyIncrease[i] = 0;
    16821576  }
     
    17861680, m_pcmLog2MaxSize            (  5)
    17871681, m_uiPCMLog2MinSize          (  7)
    1788 #if !L0034_COMBINED_LIST_CLEANUP
    1789 , m_bUseLComb                 (false)
    1790 #endif
    17911682, m_bitDepthY                 (  8)
    17921683, m_bitDepthC                 (  8)
     
    18201711  {
    18211712    m_uiMaxLatencyIncrease[i] = 0;
    1822 #if L0323_DPB
    18231713    m_uiMaxDecPicBuffering[i] = 1;
    1824 #else
    1825     m_uiMaxDecPicBuffering[i] = 0;
    1826 #endif
    18271714    m_numReorderPics[i]       = 0;
    18281715  }
     
    18621749  TComHRD *hrd = vui->getHrdParameters();
    18631750
    1864 #if L0043_TIMING_INFO
    18651751  TimingInfo *timingInfo = vui->getTimingInfo();
    18661752  timingInfo->setTimingInfoPresentFlag( true );
     
    18861772    break;
    18871773  }
    1888 #else
    1889   hrd->setTimingInfoPresentFlag( true );
    1890   switch( frameRate )
    1891   {
    1892   case 24:
    1893     hrd->setNumUnitsInTick( 1125000 );    hrd->setTimeScale    ( 27000000 );
    1894     break;
    1895   case 25:
    1896     hrd->setNumUnitsInTick( 1080000 );    hrd->setTimeScale    ( 27000000 );
    1897     break;
    1898   case 30:
    1899     hrd->setNumUnitsInTick( 900900 );     hrd->setTimeScale    ( 27000000 );
    1900     break;
    1901   case 50:
    1902     hrd->setNumUnitsInTick( 540000 );     hrd->setTimeScale    ( 27000000 );
    1903     break;
    1904   case 60:
    1905     hrd->setNumUnitsInTick( 450450 );     hrd->setTimeScale    ( 27000000 );
    1906     break;
    1907   default:
    1908     hrd->setNumUnitsInTick( 1001 );       hrd->setTimeScale    ( 60000 );
    1909     break;
    1910   }
    1911 #endif
    19121774
    19131775  Bool rateCnt = ( bitRate > 0 );
     
    19221784    hrd->setDuCpbRemovalDelayLengthMinus1( 7 );                    // 8-bit precision ( plus 1 for last DU in AU )
    19231785    hrd->setSubPicCpbParamsInPicTimingSEIFlag( true );
    1924 #if L0044_DU_DPB_OUTPUT_DELAY_HRD
    19251786    hrd->setDpbOutputDelayDuLengthMinus1( 5 + 7 );                 // With sub-clock tick factor of 100, at least 7 bits to have the same value as AU dpb delay
    1926 #endif
    19271787  }
    19281788  else
     
    19531813  UInt birateValue, cpbSizeValue;
    19541814  UInt ducpbSizeValue;
    1955 #if L0363_DU_BIT_RATE
    19561815  UInt duBitRateValue = 0;
    1957 #endif
    19581816
    19591817  for( i = 0; i < MAX_TLAYER; i ++ )
     
    19671825    cpbSizeValue = bitRate;                                     // 1 second
    19681826    ducpbSizeValue = bitRate/numDU;
    1969 #if L0363_DU_BIT_RATE
    19701827    duBitRateValue = bitRate;
    1971 #endif
    19721828    for( j = 0; j < ( hrd->getCpbCntMinus1( i ) + 1 ); j ++ )
    19731829    {
     
    19801836      hrd->setCpbSizeValueMinus1( i, j, 1, ( cpbSizeValue - 1 ) );
    19811837      hrd->setDuCpbSizeValueMinus1( i, j, 1, ( ducpbSizeValue - 1 ) );
    1982 #if L0363_DU_BIT_RATE
    19831838      hrd->setDuBitRateValueMinus1( i, j, 1, ( duBitRateValue - 1 ) );
    1984 #endif
    19851839      hrd->setCbrFlag( i, j, 1, ( j == 0 ) );
    19861840    }
     
    25592413  , m_profileIdc      (0)
    25602414  , m_levelIdc        (0)
    2561 #if L0046_CONSTRAINT_FLAGS
    25622415, m_progressiveSourceFlag  (false)
    25632416, m_interlacedSourceFlag   (false)
    25642417, m_nonPackedConstraintFlag(false)
    25652418, m_frameOnlyConstraintFlag(false)
    2566 #endif
    25672419{
    25682420  ::memset(m_profileCompatibilityFlag, 0, sizeof(m_profileCompatibilityFlag));
     
    25952447  // Copy all information related to general profile
    25962448  this->getGeneralPTL()->copyProfileInfo(ptl->getGeneralPTL());
    2597 }
    2598 #endif
    2599 #if SIGNAL_BITRATE_PICRATE_IN_VPS
    2600 TComBitRatePicRateInfo::TComBitRatePicRateInfo()
    2601 {
    2602   ::memset(m_bitRateInfoPresentFlag, 0, sizeof(m_bitRateInfoPresentFlag));
    2603   ::memset(m_picRateInfoPresentFlag, 0, sizeof(m_picRateInfoPresentFlag));
    2604   ::memset(m_avgBitRate,             0, sizeof(m_avgBitRate));
    2605   ::memset(m_maxBitRate,             0, sizeof(m_maxBitRate));
    2606   ::memset(m_constantPicRateIdc,     0, sizeof(m_constantPicRateIdc));
    2607   ::memset(m_avgPicRate,             0, sizeof(m_avgPicRate));
    26082449}
    26092450#endif
  • branches/SHM-2.1-dev/source/Lib/TLibCommon/TComSlice.h

    r300 r302  
    191191  Int     m_levelIdc;
    192192
    193 #if L0046_CONSTRAINT_FLAGS
    194193  Bool m_progressiveSourceFlag;
    195194  Bool m_interlacedSourceFlag;
    196195  Bool m_nonPackedConstraintFlag;
    197196  Bool m_frameOnlyConstraintFlag;
    198 #endif
    199197 
    200198public:
     
    216214  Void  setLevelIdc(Int x)      { m_levelIdc = x; }
    217215 
    218 #if L0046_CONSTRAINT_FLAGS
    219216  Bool getProgressiveSourceFlag() const { return m_progressiveSourceFlag; }
    220217  Void setProgressiveSourceFlag(Bool b) { m_progressiveSourceFlag = b; }
     
    228225  Bool getFrameOnlyConstraintFlag() const { return m_frameOnlyConstraintFlag; }
    229226  Void setFrameOnlyConstraintFlag(Bool b) { m_frameOnlyConstraintFlag = b; }
    230 #endif
    231227#if VPS_EXTN_PROFILE_INFO
    232228  Void copyProfileInfo(ProfileTierLevel *ptl);
     
    257253};
    258254/// VPS class
    259 
    260 #if SIGNAL_BITRATE_PICRATE_IN_VPS
    261 class TComBitRatePicRateInfo
    262 {
    263   Bool        m_bitRateInfoPresentFlag[MAX_TLAYER];
    264   Bool        m_picRateInfoPresentFlag[MAX_TLAYER];
    265   Int         m_avgBitRate[MAX_TLAYER];
    266   Int         m_maxBitRate[MAX_TLAYER];
    267   Int         m_constantPicRateIdc[MAX_TLAYER];
    268   Int         m_avgPicRate[MAX_TLAYER];
    269 public:
    270   TComBitRatePicRateInfo();
    271   Bool        getBitRateInfoPresentFlag(Int i) {return m_bitRateInfoPresentFlag[i];}
    272   Void        setBitRateInfoPresentFlag(Int i, Bool x) {m_bitRateInfoPresentFlag[i] = x;}
    273 
    274   Bool        getPicRateInfoPresentFlag(Int i) {return m_picRateInfoPresentFlag[i];}
    275   Void        setPicRateInfoPresentFlag(Int i, Bool x) {m_picRateInfoPresentFlag[i] = x;}
    276 
    277   Int         getAvgBitRate(Int i) {return m_avgBitRate[i];}
    278   Void        setAvgBitRate(Int i, Int x) {m_avgBitRate[i] = x;}
    279 
    280   Int         getMaxBitRate(Int i) {return m_maxBitRate[i];}
    281   Void        setMaxBitRate(Int i, Int x) {m_maxBitRate[i] = x;}
    282 
    283   Int         getConstantPicRateIdc(Int i) {return m_constantPicRateIdc[i];}
    284   Void        setConstantPicRateIdc(Int i, Int x) {m_constantPicRateIdc[i] = x;}
    285 
    286   Int         getAvgPicRate(Int i) {return m_avgPicRate[i];}
    287   Void        setAvgPicRate(Int i, Int x) {m_avgPicRate[i] = x;}
    288 };
    289 #endif
    290255
    291256struct HrdSubLayerInfo
     
    300265  UInt ducpbSizeValue    [MAX_CPB_CNT][2];
    301266  UInt cbrFlag           [MAX_CPB_CNT][2];
    302 #if L0363_DU_BIT_RATE
    303267  UInt duBitRateValue    [MAX_CPB_CNT][2];
    304 #endif
    305268};
    306269
     
    308271{
    309272private:
    310 #if !L0043_TIMING_INFO
    311   Bool m_timingInfoPresentFlag;
    312   UInt m_numUnitsInTick;
    313   UInt m_timeScale;
    314 #endif
    315273  Bool m_nalHrdParametersPresentFlag;
    316274  Bool m_vclHrdParametersPresentFlag;
     
    319277  UInt m_duCpbRemovalDelayLengthMinus1;
    320278  Bool m_subPicCpbParamsInPicTimingSEIFlag;
    321 #if L0044_DU_DPB_OUTPUT_DELAY_HRD
    322279  UInt m_dpbOutputDelayDuLengthMinus1;
    323 #endif
    324280  UInt m_bitRateScale;
    325281  UInt m_cpbSizeScale;
     
    333289public:
    334290  TComHRD()
    335 #if !L0043_TIMING_INFO
    336   :m_timingInfoPresentFlag(false)
    337   ,m_numUnitsInTick(1001)
    338   ,m_timeScale(60000)
    339   ,m_nalHrdParametersPresentFlag(0)
    340 #else
    341291  :m_nalHrdParametersPresentFlag(0)
    342 #endif
    343292  ,m_vclHrdParametersPresentFlag(0)
    344293  ,m_subPicCpbParamsPresentFlag(false)
     
    346295  ,m_duCpbRemovalDelayLengthMinus1(0)
    347296  ,m_subPicCpbParamsInPicTimingSEIFlag(false)
    348 #if L0044_DU_DPB_OUTPUT_DELAY_HRD
    349297  ,m_dpbOutputDelayDuLengthMinus1(0)
    350 #endif
    351298  ,m_bitRateScale(0)
    352299  ,m_cpbSizeScale(0)
     
    357304
    358305  virtual ~TComHRD() {}
    359 #if !L0043_TIMING_INFO
    360   Void setTimingInfoPresentFlag             ( Bool flag )  { m_timingInfoPresentFlag = flag;               }
    361   Bool getTimingInfoPresentFlag             ( )            { return m_timingInfoPresentFlag;               }
    362 
    363   Void setNumUnitsInTick                    ( UInt value ) { m_numUnitsInTick = value;                     }
    364   UInt getNumUnitsInTick                    ( )            { return m_numUnitsInTick;                      }
    365 
    366   Void setTimeScale                         ( UInt value ) { m_timeScale = value;                          }
    367   UInt getTimeScale                         ( )            { return m_timeScale;                           }
    368 #endif
    369306
    370307  Void setNalHrdParametersPresentFlag       ( Bool flag )  { m_nalHrdParametersPresentFlag = flag;         }
     
    386323  Bool getSubPicCpbParamsInPicTimingSEIFlag ()             { return m_subPicCpbParamsInPicTimingSEIFlag;   }
    387324
    388 #if L0044_DU_DPB_OUTPUT_DELAY_HRD
    389325  Void setDpbOutputDelayDuLengthMinus1      (UInt value )  { m_dpbOutputDelayDuLengthMinus1 = value;       }
    390326  UInt getDpbOutputDelayDuLengthMinus1      ()             { return m_dpbOutputDelayDuLengthMinus1;        }
    391 #endif
    392327
    393328  Void setBitRateScale                      ( UInt value ) { m_bitRateScale = value;                       }
     
    430365  Void setDuCpbSizeValueMinus1     ( Int layer, Int cpbcnt, Int nalOrVcl, UInt value ) { m_HRD[layer].ducpbSizeValue[cpbcnt][nalOrVcl] = value;       }
    431366  UInt getDuCpbSizeValueMinus1     ( Int layer, Int cpbcnt, Int nalOrVcl            )  { return m_HRD[layer].ducpbSizeValue[cpbcnt][nalOrVcl];        }
    432 #if L0363_DU_BIT_RATE
    433367  Void setDuBitRateValueMinus1     ( Int layer, Int cpbcnt, Int nalOrVcl, UInt value ) { m_HRD[layer].duBitRateValue[cpbcnt][nalOrVcl] = value;       }
    434368  UInt getDuBitRateValueMinus1     (Int layer, Int cpbcnt, Int nalOrVcl )              { return m_HRD[layer].duBitRateValue[cpbcnt][nalOrVcl];        }
    435 #endif
    436369  Void setCbrFlag                ( Int layer, Int cpbcnt, Int nalOrVcl, UInt value ) { m_HRD[layer].cbrFlag[cpbcnt][nalOrVcl] = value;            }
    437370  Bool getCbrFlag                ( Int layer, Int cpbcnt, Int nalOrVcl             ) { return m_HRD[layer].cbrFlag[cpbcnt][nalOrVcl];             }
     
    439372  Void setNumDU                              ( UInt value ) { m_numDU = value;                            }
    440373  UInt getNumDU                              ( )            { return m_numDU;          }
    441 #if L0045_CONDITION_SIGNALLING
    442374  Bool getCpbDpbDelaysPresentFlag() { return getNalHrdParametersPresentFlag() || getVclHrdParametersPresentFlag(); }
    443 #endif
    444375};
    445376
    446 #if L0043_TIMING_INFO
    447377class TimingInfo
    448378{
     
    475405  Void setNumTicksPocDiffOneMinus1          (Int x       ) { m_numTicksPocDiffOneMinus1 = x;               }
    476406};
    477 #endif
    478407
    479408class TComVPS
     
    487416  UInt        m_numReorderPics[MAX_TLAYER];
    488417  UInt        m_uiMaxDecPicBuffering[MAX_TLAYER];
    489   UInt        m_uiMaxLatencyIncrease[MAX_TLAYER];
     418  UInt        m_uiMaxLatencyIncrease[MAX_TLAYER]; // Really max latency increase plus 1 (value 0 expresses no limit)
    490419
    491420  UInt        m_numHrdParameters;
     
    509438#endif
    510439  TComPTL     m_pcPTL;
    511 #if SIGNAL_BITRATE_PICRATE_IN_VPS
    512   TComBitRatePicRateInfo    m_bitRatePicRateInfo;
    513 #endif
    514 #if L0043_TIMING_INFO
    515440  TimingInfo  m_timingInfo;
    516 #endif
    517441
    518442  // ------------------------------------------
     
    636560#endif
    637561  TComPTL* getPTL() { return &m_pcPTL; }
    638 #if SIGNAL_BITRATE_PICRATE_IN_VPS
    639   TComBitRatePicRateInfo *getBitratePicrateInfo() { return &m_bitRatePicRateInfo; }
    640 #endif
    641 #if L0043_TIMING_INFO
    642562  TimingInfo* getTimingInfo() { return &m_timingInfo; }
    643 #endif
    644563#if VPS_EXTN_MASK_AND_DIM_INFO
    645564  Bool   getAvcBaseLayerFlag()                                  { return m_avcBaseLayerFlag;       }
     
    814733  Int  m_log2MaxMvLengthVertical;
    815734  TComHRD m_hrdParameters;
    816 #if L0043_TIMING_INFO
    817735  TimingInfo m_timingInfo;
    818 #else
    819   Bool m_pocProportionalToTimingFlag;
    820   Int  m_numTicksPocDiffOneMinus1;
    821 #endif
    822736#if M0464_TILE_BOUNDARY_ALIGNED_FLAG
    823737  Bool m_tileBoundariesAlignedFlag;
     
    856770    ,m_log2MaxMvLengthHorizontal(15)
    857771    ,m_log2MaxMvLengthVertical(15)
    858 #if !L0043_TIMING_INFO 
    859     ,m_pocProportionalToTimingFlag(false)
    860     ,m_numTicksPocDiffOneMinus1(0)
    861 #endif
    862772#if M0464_TILE_BOUNDARY_ALIGNED_FLAG
    863773    ,m_tileBoundariesAlignedFlag(true)
     
    957867
    958868  TComHRD* getHrdParameters                 ()             { return &m_hrdParameters; }
    959 #if L0043_TIMING_INFO
    960869  TimingInfo* getTimingInfo() { return &m_timingInfo; }
    961 #else
    962   Bool getPocProportionalToTimingFlag() {return m_pocProportionalToTimingFlag; }
    963   Void setPocProportionalToTimingFlag(Bool x) {m_pocProportionalToTimingFlag = x;}
    964   Int  getNumTicksPocDiffOneMinus1() {return m_numTicksPocDiffOneMinus1;}
    965   Void setNumTicksPocDiffOneMinus1(Int x) { m_numTicksPocDiffOneMinus1 = x;}
    966 #endif
    967870#if M0464_TILE_BOUNDARY_ALIGNED_FLAG
    968871  Bool getTileBoundariesAlignedFlag(  ) { return m_tileBoundariesAlignedFlag; }
     
    1008911  Bool        m_useAMP;
    1009912
    1010 #if !L0034_COMBINED_LIST_CLEANUP
    1011   Bool        m_bUseLComb;
    1012 #endif
    1013  
    1014913  // Parameter
    1015914  Int         m_bitDepthY;
     
    1040939  TComScalingList*     m_scalingList;   //!< ScalingList class pointer
    1041940  UInt        m_uiMaxDecPicBuffering[MAX_TLAYER];
    1042   UInt        m_uiMaxLatencyIncrease[MAX_TLAYER];
     941  UInt        m_uiMaxLatencyIncrease[MAX_TLAYER];  // Really max latency increase plus 1 (value 0 expresses no limit)
    1043942
    1044943  Bool        m_useDF;
     
    11461045 
    11471046  // Tool list
    1148 #if !L0034_COMBINED_LIST_CLEANUP
    1149   Void setUseLComb    (Bool b)   { m_bUseLComb = b;         }
    1150   Bool getUseLComb    ()         { return m_bUseLComb;      }
    1151 #endif
    1152 
    11531047  Bool getUseLossless ()         { return m_useLossless; }
    11541048  Void setUseLossless ( Bool b ) { m_useLossless  = b; }
     
    15041398  Bool        m_interLayerSamplePredOnlyFlag;
    15051399#endif
    1506 #if L0034_COMBINED_LIST_CLEANUP
    15071400  Int         m_list1IdxToList0Idx[MAX_NUM_REF];
    15081401  Int         m_aiNumRefIdx   [2];    //  for multiple reference of current slice
    1509 #else
    1510   Int         m_aiNumRefIdx   [3];    //  for multiple reference of current slice
    1511   Int         m_iRefIdxOfLC[2][MAX_NUM_REF_LC];
    1512   Int         m_eListIdFromIdxOfLC[MAX_NUM_REF_LC];
    1513   Int         m_iRefIdxFromIdxOfLC[MAX_NUM_REF_LC];
    1514   Int         m_iRefIdxOfL1FromRefIdxOfL0[MAX_NUM_REF_LC];
    1515   Int         m_iRefIdxOfL0FromRefIdxOfL1[MAX_NUM_REF_LC];
    1516   Bool        m_bRefPicListModificationFlagLC;
    1517   Bool        m_bRefPicListCombinationFlag;
    1518 #endif
    15191402
    15201403  Bool        m_bCheckLDC;
     
    15581441
    15591442  Bool        m_abEqualRef  [2][MAX_NUM_REF][MAX_NUM_REF];
    1560 #if !L0034_COMBINED_LIST_CLEANUP
    1561   Bool        m_bNoBackPredFlag;
    1562 #endif
    15631443  UInt        m_uiTLayer;
    15641444#if SVC_EXTENSION
     
    16801560  Bool      getMvdL1ZeroFlag ()                                  { return m_bLMvdL1Zero;    }
    16811561  Int       getNumRpsCurrTempList();
    1682 #if L0034_COMBINED_LIST_CLEANUP
    16831562  Int       getList1IdxToList0Idx ( Int list1Idx )               { return m_list1IdxToList0Idx[list1Idx]; }
    1684 #else
    1685   Int       getRefIdxOfLC       (RefPicList e, Int iRefIdx)     { return m_iRefIdxOfLC[e][iRefIdx];           }
    1686   Int       getListIdFromIdxOfLC(Int iRefIdx)                   { return m_eListIdFromIdxOfLC[iRefIdx];       }
    1687   Int       getRefIdxFromIdxOfLC(Int iRefIdx)                   { return m_iRefIdxFromIdxOfLC[iRefIdx];       }
    1688   Int       getRefIdxOfL0FromRefIdxOfL1(Int iRefIdx)            { return m_iRefIdxOfL0FromRefIdxOfL1[iRefIdx];}
    1689   Int       getRefIdxOfL1FromRefIdxOfL0(Int iRefIdx)            { return m_iRefIdxOfL1FromRefIdxOfL0[iRefIdx];}
    1690   Bool      getRefPicListModificationFlagLC()                   {return m_bRefPicListModificationFlagLC;}
    1691   Void      setRefPicListModificationFlagLC(Bool bflag)         {m_bRefPicListModificationFlagLC=bflag;}     
    1692   Bool      getRefPicListCombinationFlag()                      {return m_bRefPicListCombinationFlag;}
    1693   Void      setRefPicListCombinationFlag(Bool bflag)            {m_bRefPicListCombinationFlag=bflag;}   
    1694 #endif
    16951563  Void      setReferenced(Bool b)                               { m_bRefenced = b; }
    16961564  Bool      isReferenced()                                      { return m_bRefenced; }
     
    17331601
    17341602#if FIX1071
     1603#if SVC_EXTENSION
    17351604  Void      setRefPicList       ( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr = false, TComPic** ilpPic = NULL );
     1605#else
     1606  Void      setRefPicList       ( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr = false );
     1607#endif
    17361608#else
    17371609  Void      setRefPicList       ( TComList<TComPic*>& rcListPic );
     
    17691641 
    17701642  static Void      sortPicList         ( TComList<TComPic*>& rcListPic );
    1771 #if L0034_COMBINED_LIST_CLEANUP
    17721643  Void setList1IdxToList0Idx();
    1773 #else
    1774   Bool getNoBackPredFlag() { return m_bNoBackPredFlag; }
    1775   Void setNoBackPredFlag( Bool b ) { m_bNoBackPredFlag = b; }
    1776   Void generateCombinedList       ();
    1777 #endif
    17781644
    17791645  UInt getTLayer             ()                            { return m_uiTLayer;                      }
     
    17861652  Bool isStepwiseTemporalLayerSwitchingPointCandidate( TComList<TComPic*>& rcListPic );
    17871653  Int       checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess = 0);
     1654#if FIX1071
     1655  Void      createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool isRAP);
     1656#else
    17881657  Void      createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet);
     1658#endif
    17891659
    17901660  Void setMaxNumMergeCand               (UInt val )         { m_maxNumMergeCand = val;                    }
  • branches/SHM-2.1-dev/source/Lib/TLibCommon/TComTrQuant.cpp

    r191 r302  
    10751075    Int iTransformShift = MAX_TR_DYNAMIC_RANGE - uiBitDepth - uiLog2TrSize;  // Represents scaling through forward transform
    10761076
    1077     Int iQBits = QUANT_SHIFT + m_cQP.m_iPer + iTransformShift;                // Right shift of non-RDOQ quantizer;  level = (coeff*uiQ + offset)>>q_bits
    1078 
    1079     iAdd = (pcCU->getSlice()->getSliceType()==I_SLICE ? 171 : 85) << (iQBits-9);
    1080 
    10811077#if ADAPTIVE_QP_SELECTION
    1082     iQBits = QUANT_SHIFT + cQpBase.m_iPer + iTransformShift;
     1078    Int iQBits = QUANT_SHIFT + cQpBase.m_iPer + iTransformShift;
    10831079    iAdd = (pcCU->getSlice()->getSliceType()==I_SLICE ? 171 : 85) << (iQBits-9);
    10841080    Int iQBitsC = QUANT_SHIFT + cQpBase.m_iPer + iTransformShift - ARL_C_PRECISION; 
    10851081    Int iAddC   = 1 << (iQBitsC-1);
     1082#else
     1083    Int iQBits = QUANT_SHIFT + m_cQP.m_iPer + iTransformShift;                // Right shift of non-RDOQ quantizer;  level = (coeff*uiQ + offset)>>q_bits
     1084    iAdd = (pcCU->getSlice()->getSliceType()==I_SLICE ? 171 : 85) << (iQBits-9);
    10861085#endif
    10871086
     
    13641363#else
    13651364  Int j;
    1366   {
    1367     Short block[ 64 * 64 ];
    1368     Short coeff[ 64 * 64 ];
    1369     {
    1370       for (j = 0; j < iHeight; j++)
    1371       {   
    1372         memcpy( block + j * iWidth, piBlkResi + j * uiStride, iWidth * sizeof( Short ) );
    1373       }
    1374     }
    1375     xTrMxN(bitDepth, block, coeff, iWidth, iHeight, uiMode );
    1376     for ( j = 0; j < iHeight * iWidth; j++ )
    1377     {   
    1378       psCoeff[ j ] = coeff[ j ];
    1379     }
    1380     return ;
     1365  Short block[ 32 * 32 ];
     1366  Short coeff[ 32 * 32 ];
     1367  for (j = 0; j < iHeight; j++)
     1368  {   
     1369    memcpy( block + j * iWidth, piBlkResi + j * uiStride, iWidth * sizeof( Short ) );
     1370  }
     1371  xTrMxN(bitDepth, block, coeff, iWidth, iHeight, uiMode );
     1372  for ( j = 0; j < iHeight * iWidth; j++ )
     1373  {   
     1374    psCoeff[ j ] = coeff[ j ];
    13811375  }
    13821376#endif 
     
    13991393  Int j;
    14001394  {
    1401     Short block[ 64 * 64 ];
    1402     Short coeff[ 64 * 64 ];
     1395    Short block[ 32 * 32 ];
     1396    Short coeff[ 32 * 32 ];
    14031397    for ( j = 0; j < iHeight * iWidth; j++ )
    14041398    {   
     
    15221516                                                      UInt                            uiAbsPartIdx )
    15231517{
    1524   Int    iQBits      = m_cQP.m_iBits;
    1525   Double dTemp       = 0;
    15261518  UInt uiLog2TrSize = g_aucConvertToBit[ uiWidth ] + 2;
    1527   Int uiQ = g_quantScales[m_cQP.rem()];
    15281519 
    15291520  UInt uiBitDepth = eTType == TEXT_LUMA ? g_bitDepthY : g_bitDepthC;
     
    15361527  assert(scalingListType < 6);
    15371528 
    1538   iQBits = QUANT_SHIFT + m_cQP.m_iPer + iTransformShift;                   // Right shift of non-RDOQ quantizer;  level = (coeff*uiQ + offset)>>q_bits
    1539   Double dErrScale   = 0;
     1529  Int iQBits = QUANT_SHIFT + m_cQP.m_iPer + iTransformShift;                   // Right shift of non-RDOQ quantizer;  level = (coeff*uiQ + offset)>>q_bits
    15401530  Double *pdErrScaleOrg = getErrScaleCoeff(scalingListType,uiLog2TrSize-2,m_cQP.m_iRem);
    15411531  Int *piQCoefOrg = getQuantCoeff(scalingListType,m_cQP.m_iRem,uiLog2TrSize-2);
     
    15891579  Double  d64BaseCost         = 0;
    15901580  Int     iLastScanPos        = -1;
    1591   dTemp                       = dErrScale;
    15921581 
    15931582  UInt    c1Idx     = 0;
     
    16181607      UInt    uiBlkPos          = scan[iScanPos];
    16191608      // set coeff
    1620       uiQ  = piQCoef[uiBlkPos];
    1621       dTemp = pdErrScale[uiBlkPos];
     1609      Int uiQ  = piQCoef[uiBlkPos];
     1610      Double dTemp = pdErrScale[uiBlkPos];
    16221611      Int lLevelDouble          = plSrcCoeff[ uiBlkPos ];
    16231612      lLevelDouble              = (Int)min<Int64>((Int64)abs((Int)lLevelDouble) * uiQ , MAX_INT - (1 << (iQBits - 1)));
  • branches/SHM-2.1-dev/source/Lib/TLibCommon/TComWeightPrediction.cpp

    r191 r302  
    271271Void TComWeightPrediction::getWpScaling( TComDataCU* pcCU, Int iRefIdx0, Int iRefIdx1, wpScalingParam *&wp0, wpScalingParam *&wp1)
    272272{
     273  assert(iRefIdx0 >= 0 || iRefIdx1 >= 0);
     274 
    273275  TComSlice*      pcSlice       = pcCU->getSlice();
    274276  TComPPS*        pps           = pcCU->getSlice()->getPPS();
  • branches/SHM-2.1-dev/source/Lib/TLibCommon/TypeDef.h

    r300 r302  
    4444
    4545#if SVC_EXTENSION
     46#define MAX_LAYERS                       2      ///< max number of layers the codec is supposed to handle
     47
    4648#define M0464_TILE_BOUNDARY_ALIGNED_FLAG 1      ///< VUI flag to indicate tile boundary alignment
    4749#define M0463_VUI_EXT_ILP_REF            1      ///< VUI extension inter-layer dependency offset signalling
     
    4951#define SCALED_REF_LAYER_OFFSET_FLAG     0      ///< M0309: Signal scaled reference layer offsets in SPS
    5052#define SCALED_REF_LAYER_OFFSETS         1      ///< M0309: Signal scaled reference layer offsets in SPS
    51 #define MAX_LAYERS                       2      ///< max number of layers the codec is supposed to handle
    5253
    5354#define VPS_RENAME                       1      ///< Rename variables max_layer_id and num_layer_sets_minus1 in VPS
     
    7374#define SVC_COL_BLK                      1      ///< get co-located block
    7475#define SVC_UPSAMPLING                   1      ///< upsampling filters
    75 #define ENCODER_BUGFIX                   1      ///< L0167: encoder bug fix for inter mode
    7676#define CHROMA_UPSAMPLING                1      ///< L0335: Chroma upsampling with 5 bits coefficients
    7777
     
    129129#endif
    130130#endif
    131 #else
    132 #define ILP_DECODED_PICTURE              0
    133 #define SYNTAX_OUTPUT                    0
    134 #endif
    135131
    136132#define FAST_INTRA_SHVC                  1      ///< M0115: reduction number of intra modes in the EL (encoder only)
     
    139135#endif
    140136
     137#define RC_SHVC_HARMONIZATION            1  ///< JCTVC-M0037, rate control for SHVC
     138
     139#else
     140#define ILP_DECODED_PICTURE              0
     141#define SYNTAX_OUTPUT                    0
     142#endif // SVC_EXTENSION
     143
     144
    141145//! \ingroup TLibCommon
    142146//! \{
    143147
    144 #define FIX1071 1 ///< Temporary fix for issue #1071
    145 
    146 
    147 #define M0043_LAYERS_PRESENT_SEI      0 ///< M0043: add layers present SEI
    148 #define L0208_SOP_DESCRIPTION_SEI     1 ///< L0208: add SOP descrioption SEI
     148#define FIX1071 1 ///< fix for issue #1071
     149
    149150#define MAX_NUM_PICS_IN_SOP           1024
    150151
    151 #define K0180_SCALABLE_NESTING_SEI  1   ///JCTVC-K0180 scalable nesting sei message
    152152#define MAX_NESTING_NUM_OPS         1024
    153153#define MAX_NESTING_NUM_LAYER       64
    154 
    155 #define J0149_TONE_MAPPING_SEI        1 ///< J0149: Tone mapping information SEI
    156 #define L0363_DU_BIT_RATE             1 ///< L0363: add bit_rate_du_value_minus1 to HRD parameters
    157 #define L0328_SPLICING                1 ///< L0328: splicing support in HRD
    158 #define L0044_DU_DPB_OUTPUT_DELAY_HRD 1 ///< L0044: Include dpb_output_delay_du_length_minus1 in hrd_parameters(), dpb_output_du_delay in
    159                                         ///<        picture timing SEI and DU information SEI
    160 #define L0045_PERSISTENCE_FLAGS  1      ///< L0045: Replace "repetition_period" syntax elements in SEI with "persistence_flag"
    161 #define L0045_NON_NESTED_SEI_RESTRICTIONS 1 ///< L0045; Include restriction on the order of APS and non-nested BP, PT and DU info SEI messages
    162 #define L0044_CPB_DPB_DELAY_OFFSET 1  ///< L0044: Include syntax elements cpb_delay_offset and dpb_delay_offset in the BP SEI message
    163 #define L0047_APS_FLAGS            1  ///< L0047: Include full_random_access_flag and no_param_set_update_flag in the active parameter set SEI message
    164 #define L0043_TIMING_INFO          1  ///< L0043: Timing information is signalled in VUI outside hrd_parameters()
    165 #define L0046_RENAME_PROG_SRC_IDC  1  ///< L0046: Rename progressive_source_idc to source_scan_type
    166 #define L0045_CONDITION_SIGNALLING 1  ///< L0045: Condition the signaling of some syntax elements in picture timing SEI message
    167 #define L0043_MSS_IDC 1
    168 #define L0116_ENTRY_POINT 1
    169 #define L0363_MORE_BITS 1
    170 #define L0363_MVP_POC 1
    171 #define L0363_BYTE_ALIGN 1
    172 #define L0363_SEI_ALLOW_SUFFIX 1
    173 #define L0323_LIMIT_DEFAULT_LIST_SIZE 1
    174 #define L0046_CONSTRAINT_FLAGS 1
    175 #define L0255_MOVE_PPS_FLAGS       1  ///< move some flags to earlier positions in the PPS
    176 #define L0444_FPA_TYPE             1  ///< allow only FPA types 3, 4 and 5
    177 #define L0372 1
    178 #define SIGNAL_BITRATE_PICRATE_IN_VPS               0  ///< K0125: Signal bit_rate and pic_rate in VPS
    179 #define L0232_RD_PENALTY           1  ///< L0232: RD-penalty for 32x32 TU for intra in non-intra slices
    180 #define L0386_DB_METRIC            1  ///< L0386: non-normative blockiness metric (automatically configures deblocking parameters in bitstream)
    181 #define L0323_DPB                     1 ///< L0323: Specification of active reference indices and decoded picture buffer
    182 
    183 #define L0034_COMBINED_LIST_CLEANUP 1
    184154
    185155#if VPS_EXTN_MASK_AND_DIM_INFO
     
    195165#endif
    196166#define RATE_CONTROL_LAMBDA_DOMAIN                  1  ///< JCTVC-K0103, rate control by R-lambda model
    197 #define L0033_RC_BUGFIX                             1  ///< JCTVC-L0033, bug fix for R-lambda model based rate control
    198 #define RC_SHVC_HARMONIZATION                       1  ///< JCTVC-M0037, rate control for SHVC
     167#define M0036_RC_IMPROVEMENT                        1  ///< JCTVC-M0036, improvement for R-lambda model based rate control
     168#define TICKET_1090_FIX                             1
     169
     170#define RC_FIX                                      1  /// suggested fix for M0036
     171#define RATE_CONTROL_INTRA                          1  ///< JCTVC-M0257, rate control for intra
    199172
    200173#define MAX_CPB_CNT                     32  ///< Upper bound of (cpb_cnt_minus1 + 1)
     
    217190
    218191#define REMOVE_SAO_LCU_ENC_CONSTRAINTS_3 1  ///< disable the encoder constraint that conditionally disable SAO for chroma for entire slice in interleaved mode
    219 
    220 #define REMOVE_SINGLE_SEI_EXTENSION_FLAGS 1 ///< remove display orientation SEI extension flag (there is a generic SEI extension mechanism now)
    221192
    222193#define SAO_ENCODING_CHOICE              1  ///< I0184: picture early termination
     
    232203#define MAX_NUM_SPS                16
    233204#define MAX_NUM_PPS                64
    234 
    235 
    236205
    237206#define WEIGHTED_CHROMA_DISTORTION  1   ///< F386: weighting of chroma for RDO
     
    522491  REF_PIC_LIST_0 = 0,   ///< reference list 0
    523492  REF_PIC_LIST_1 = 1,   ///< reference list 1
    524 #if !L0034_COMBINED_LIST_CLEANUP
    525   REF_PIC_LIST_C = 2,   ///< combined reference list for uni-prediction in B-Slices
    526 #endif
    527493  REF_PIC_LIST_X = 100  ///< special mark
    528494};
  • branches/SHM-2.1-dev/source/Lib/TLibDecoder/SEIread.cpp

    r292 r302  
    9090    fprintf( g_hTrace, "=========== Decoding Unit Information SEI message ===========\n");
    9191    break;
    92 #if J0149_TONE_MAPPING_SEI
    9392  case SEI::TONE_MAPPING_INFO:
    9493    fprintf( g_hTrace, "===========Tone Mapping Info SEI message ===========\n");
    9594    break;
    96 #endif
    9795#if M0043_LAYERS_PRESENT_SEI
    9896  case SEI::LAYERS_PRESENT:
     
    10098    break;
    10199#endif
    102 #if L0208_SOP_DESCRIPTION_SEI
    103100  case SEI::SOP_DESCRIPTION:
    104101    fprintf( g_hTrace, "=========== SOP Description SEI message ===========\n");
    105102    break;
    106 #endif
    107 #if K0180_SCALABLE_NESTING_SEI
    108103  case SEI::SCALABLE_NESTING:
    109104    fprintf( g_hTrace, "=========== Scalable Nesting SEI message ===========\n");
    110105    break;
    111 #endif
    112106  default:
    113107    fprintf( g_hTrace, "=========== Unknown SEI message ===========\n");
     
    251245      xParseSEIGradualDecodingRefreshInfo((SEIGradualDecodingRefreshInfo&) *sei, payloadSize);
    252246      break;
    253 #if J0149_TONE_MAPPING_SEI
    254247    case SEI::TONE_MAPPING_INFO:
    255248      sei = new SEIToneMappingInfo;
    256249      xParseSEIToneMappingInfo((SEIToneMappingInfo&) *sei, payloadSize);
    257250      break;
    258 #endif
    259251#if M0043_LAYERS_PRESENT_SEI
    260252    case SEI::LAYERS_PRESENT:
     
    270262      break;
    271263#endif
    272 #if L0208_SOP_DESCRIPTION_SEI
    273264    case SEI::SOP_DESCRIPTION:
    274265      sei = new SEISOPDescription;
    275266      xParseSEISOPDescription((SEISOPDescription&) *sei, payloadSize);
    276267      break;
    277 #endif
    278 #if K0180_SCALABLE_NESTING_SEI
    279268    case SEI::SCALABLE_NESTING:
    280269      sei = new SEIScalableNesting;
     
    285274#endif
    286275      break;
    287 #endif
    288276    default:
    289277      for (UInt i = 0; i < payloadSize; i++)
     
    299287    switch (payloadType)
    300288    {
    301 #if L0363_SEI_ALLOW_SUFFIX
    302289      case SEI::USER_DATA_UNREGISTERED:
    303290        sei = new SEIuserDataUnregistered;
    304291        xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize);
    305292        break;
    306 #endif
    307293      case SEI::DECODED_PICTURE_HASH:
    308294        sei = new SEIDecodedPictureHash;
     
    436422  UInt val;
    437423  READ_CODE(4, val, "active_vps_id");      sei.activeVPSId = val;
    438 #if L0047_APS_FLAGS
    439424  READ_FLAG( val, "full_random_access_flag");  sei.m_fullRandomAccessFlag = val ? true : false;
    440425  READ_FLAG( val, "no_param_set_update_flag"); sei.m_noParamSetUpdateFlag = val ? true : false;
    441 #endif
    442426  READ_UVLC(   val, "num_sps_ids_minus1"); sei.numSpsIdsMinus1 = val;
    443427
     
    472456    sei.m_duSptCpbRemovalDelay = 0;
    473457  }
    474 #if L0044_DU_DPB_OUTPUT_DELAY_HRD
    475458  READ_FLAG( val, "dpb_output_du_delay_present_flag"); sei.m_dpbOutputDuDelayPresentFlag = val ? true : false;
    476459  if(sei.m_dpbOutputDuDelayPresentFlag)
     
    479462    sei.m_picSptDpbOutputDuDelay = val;
    480463  }
    481 #endif
    482464  xParseByteAlign();
    483465}
     
    496478    READ_FLAG( code, "rap_cpb_params_present_flag" );                   sei.m_rapCpbParamsPresentFlag = code;
    497479  }
    498 #if L0328_SPLICING
    499480  //read splicing flag and cpb_removal_delay_delta
    500481  READ_FLAG( code, "concatenation_flag");
     
    502483  READ_CODE( ( pHRD->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_delta_minus1" );
    503484  sei.m_auCpbRemovalDelayDelta = code + 1;
    504 #endif
    505 #if L0044_CPB_DPB_DELAY_OFFSET
    506485  if( sei.m_rapCpbParamsPresentFlag )
    507486  {
     
    509488    READ_CODE( pHRD->getDpbOutputDelayLengthMinus1()  + 1, code, "dpb_delay_offset" );      sei.m_dpbDelayOffset = code;
    510489  }
    511 #endif
    512490  for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ )
    513491  {
     
    541519  TComHRD *hrd = vui->getHrdParameters();
    542520
    543 #if !L0045_CONDITION_SIGNALLING
    544   // This condition was probably OK before the pic_struct, progressive_source_idc, duplicate_flag were added
    545   if( !hrd->getNalHrdParametersPresentFlag() && !hrd->getVclHrdParametersPresentFlag() )
    546   {
    547     return;
    548   }
    549 #endif
    550 
    551521  if( vui->getFrameFieldInfoPresentFlag() )
    552522  {
    553523    READ_CODE( 4, code, "pic_struct" );             sei.m_picStruct            = code;
    554 #if L0046_RENAME_PROG_SRC_IDC
    555524    READ_CODE( 2, code, "source_scan_type" );       sei.m_sourceScanType = code;
    556 #else
    557     READ_CODE( 2, code, "progressive_source_idc" ); sei.m_progressiveSourceIdc = code;
    558 #endif
    559525    READ_FLAG(    code, "duplicate_flag" );         sei.m_duplicateFlag        = ( code == 1 ? true : false );
    560526  }
    561527
    562 #if L0045_CONDITION_SIGNALLING
    563528  if( hrd->getCpbDpbDelaysPresentFlag())
    564529  {
    565 #endif
    566530    READ_CODE( ( hrd->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_minus1" );
    567531    sei.m_auCpbRemovalDelay = code + 1;
     
    569533    sei.m_picDpbOutputDelay = code;
    570534
    571 #if L0044_DU_DPB_OUTPUT_DELAY_HRD
    572535    if(hrd->getSubPicCpbParamsPresentFlag())
    573536    {
     
    575538      sei.m_picDpbOutputDuDelay = code;
    576539    }
    577 #endif
    578540    if( hrd->getSubPicCpbParamsPresentFlag() && hrd->getSubPicCpbParamsInPicTimingSEIFlag() )
    579541    {
     
    609571      }
    610572    }
    611 #if L0045_CONDITION_SIGNALLING
    612   }
    613 #endif
     573  }
    614574  xParseByteAlign();
    615575}
     
    632592  {
    633593    READ_CODE( 7, val, "frame_packing_arrangement_type" );          sei.m_arrangementType = val;
    634 #if L0444_FPA_TYPE
    635594    assert((sei.m_arrangementType > 2) && (sei.m_arrangementType < 6) );
    636 #endif
    637595    READ_FLAG( val, "quincunx_sampling_flag" );                     sei.m_quincunxSamplingFlag = val;
    638596
     
    654612
    655613    READ_CODE( 8, val, "frame_packing_arrangement_reserved_byte" );   sei.m_arrangementReservedByte = val;
    656 #if L0045_PERSISTENCE_FLAGS
    657614    READ_FLAG( val,  "frame_packing_arrangement_persistence_flag" );  sei.m_arrangementPersistenceFlag = val ? true : false;
    658 #else
    659     READ_UVLC( val, "frame_packing_arrangement_repetition_period" );  sei.m_arrangementRepetetionPeriod = val;
    660 #endif
    661615  }
    662616  READ_FLAG( val, "upsampled_aspect_ratio" );                       sei.m_upsampledAspectRatio = val;
     
    674628    READ_FLAG( val,     "ver_flip" );                              sei.verFlip               = val;
    675629    READ_CODE( 16, val, "anticlockwise_rotation" );                sei.anticlockwiseRotation = val;
    676 #if L0045_PERSISTENCE_FLAGS
    677630    READ_FLAG( val,     "display_orientation_persistence_flag" );  sei.persistenceFlag       = val;
    678 #else
    679     READ_UVLC( val,     "display_orientation_repetition_period" ); sei.repetitionPeriod      = val;
    680 #endif
    681 #if !REMOVE_SINGLE_SEI_EXTENSION_FLAGS
    682     READ_FLAG( val,     "display_orientation_extension_flag" );    sei.extensionFlag         = val;
    683     assert( !sei.extensionFlag );
    684 #endif
    685631  }
    686632  xParseByteAlign();
     
    702648}
    703649
    704 #if J0149_TONE_MAPPING_SEI
    705650Void SEIReader::xParseSEIToneMappingInfo(SEIToneMappingInfo& sei, UInt /*payloadSize*/)
    706651{
     
    783728  xParseByteAlign();
    784729}
    785 #endif
    786730
    787731#if M0043_LAYERS_PRESENT_SEI
     
    806750#endif
    807751
    808 #if L0208_SOP_DESCRIPTION_SEI
    809752Void SEIReader::xParseSEISOPDescription(SEISOPDescription &sei, UInt payloadSize)
    810753{
     
    830773  xParseByteAlign();
    831774}
    832 #endif
    833 
    834 
    835 #if K0180_SCALABLE_NESTING_SEI
     775
    836776#if M0043_LAYERS_PRESENT_SEI
    837777Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComVPS *vps, TComSPS *sps)
     
    888828
    889829}
    890 #endif
    891830
    892831Void SEIReader::xParseByteAlign()
  • branches/SHM-2.1-dev/source/Lib/TLibDecoder/SEIread.h

    r292 r302  
    7878  Void xParseSEITemporalLevel0Index   (SEITemporalLevel0Index &sei, UInt payloadSize);
    7979  Void xParseSEIGradualDecodingRefreshInfo (SEIGradualDecodingRefreshInfo &sei, UInt payloadSize);
    80 #if J0149_TONE_MAPPING_SEI
    8180  Void xParseSEIToneMappingInfo       (SEIToneMappingInfo& sei, UInt payloadSize);
    82 #endif
     81  Void xParseSEISOPDescription        (SEISOPDescription &sei, UInt payloadSize);
    8382#if M0043_LAYERS_PRESENT_SEI
    8483  Void xParseSEILayersPresent         (SEILayersPresent &sei, UInt payloadSize, TComVPS *vps);
    85 #endif
    86 #if L0208_SOP_DESCRIPTION_SEI
    87   Void xParseSEISOPDescription        (SEISOPDescription &sei, UInt payloadSize);
    88 #endif
    89 #if K0180_SCALABLE_NESTING_SEI
    90 #if M0043_LAYERS_PRESENT_SEI
    9184  Void xParseSEIScalableNesting       (SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComVPS *vps, TComSPS *sps);
    9285#else
    9386  Void xParseSEIScalableNesting       (SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComSPS *sps);
    94 #endif
    9587#endif
    9688  Void xParseByteAlign();
  • branches/SHM-2.1-dev/source/Lib/TLibDecoder/TDecBinCoder.h

    r191 r302  
    5454  virtual Void  start             ()                                          = 0;
    5555  virtual Void  finish            ()                                          = 0;
    56   virtual Void  flush            ()                                           = 0;
    5756
    5857  virtual Void  decodeBin         ( UInt& ruiBin, ContextModel& rcCtxModel )  = 0;
     
    6160  virtual Void  decodeBinTrm      ( UInt& ruiBin                           )  = 0;
    6261 
    63   virtual Void  resetBac          ()                                          = 0;
    64   virtual Void  decodePCMAlignBits()                                          = 0;
    6562  virtual Void  xReadPCMCode      ( UInt uiLength, UInt& ruiCode)              = 0;
    6663
  • branches/SHM-2.1-dev/source/Lib/TLibDecoder/TDecBinCoderCABAC.cpp

    r191 r302  
    7575TDecBinCABAC::finish()
    7676{
    77 }
    78 
    79 Void
    80 TDecBinCABAC::flush()
    81 {
    82   while (m_pcTComBitstream->getNumBitsLeft() > 0 && m_pcTComBitstream->getNumBitsUntilByteAligned() != 0)
    83   {
    84     UInt uiBits;
    85     m_pcTComBitstream->read ( 1, uiBits );
    86   }
    87   start();
     77  UInt lastByte;
     78
     79  m_pcTComBitstream->peekPreviousByte( lastByte );
     80  // Check for proper stop/alignment pattern
     81  assert( ((lastByte << (8 + m_bitsNeeded)) & 0xff) == 0x80 );
    8882}
    8983
     
    241235}
    242236
    243 /** Reset BAC register values.
    244  * \returns Void
    245  */
    246 Void TDecBinCABAC::resetBac()
    247 {
    248   m_uiRange    = 510;
    249   m_bitsNeeded = -8;
    250   m_uiValue    = m_pcTComBitstream->read( 16 );
    251 }
    252 
    253 /** Decode PCM alignment zero bits.
    254  * \returns Void
    255  */
    256 Void TDecBinCABAC::decodePCMAlignBits()
    257 {
    258   Int iNum = m_pcTComBitstream->getNumBitsUntilByteAligned();
    259  
    260   UInt uiBit = 0;
    261   m_pcTComBitstream->read( iNum, uiBit );
    262 }
    263 
    264237/** Read a PCM code.
    265238 * \param uiLength code bit-depth
  • branches/SHM-2.1-dev/source/Lib/TLibDecoder/TDecBinCoderCABAC.h

    r191 r302  
    5656  Void  start             ();
    5757  Void  finish            ();
    58   Void  flush             ();
    5958 
    6059  Void  decodeBin         ( UInt& ruiBin, ContextModel& rcCtxModel );
     
    6362  Void  decodeBinTrm      ( UInt& ruiBin                           );
    6463 
    65   Void  resetBac          ();
    66   Void  decodePCMAlignBits();
    6764  Void  xReadPCMCode      ( UInt uiLength, UInt& ruiCode );
    6865 
  • branches/SHM-2.1-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp

    r300 r302  
    175175}
    176176
    177 /** copy SAO parameter
    178 * \param dst
    179 * \param src
    180 */
    181 inline Void copySaoOneLcuParam(SaoLcuParam* dst,  SaoLcuParam* src)
    182 {
    183   Int i;
    184   dst->partIdx = src->partIdx;
    185   dst->typeIdx = src->typeIdx;
    186   if (dst->typeIdx != -1)
    187   {
    188     dst->subTypeIdx = src->subTypeIdx ;
    189     dst->length  = src->length;
    190     for (i=0;i<dst->length;i++)
    191     {
    192       dst->offset[i] = src->offset[i];
    193     }
    194   }
    195   else
    196   {
    197     dst->length  = 0;
    198     for (i=0;i<SAO_BO_LEN;i++)
    199     {
    200       dst->offset[i] = 0;
    201     }
    202   }
    203 }
    204 
    205177Void TDecCavlc::parsePPS(TComPPS* pcPPS)
    206178{
     
    212184  Int   iCode;
    213185
    214   READ_UVLC( uiCode, "pps_pic_parameter_set_id");                     pcPPS->setPPSId (uiCode);
    215   READ_UVLC( uiCode, "pps_seq_parameter_set_id");                     pcPPS->setSPSId (uiCode);
     186  READ_UVLC( uiCode, "pps_pic_parameter_set_id");
     187  assert(uiCode <= 63);
     188  pcPPS->setPPSId (uiCode);
     189 
     190  READ_UVLC( uiCode, "pps_seq_parameter_set_id");
     191  assert(uiCode <= 15);
     192  pcPPS->setSPSId (uiCode);
     193 
    216194  READ_FLAG( uiCode, "dependent_slice_segments_enabled_flag"    );    pcPPS->setDependentSliceSegmentsEnabledFlag   ( uiCode == 1 );
    217 #if L0255_MOVE_PPS_FLAGS
    218195  READ_FLAG( uiCode, "output_flag_present_flag" );                    pcPPS->setOutputFlagPresentFlag( uiCode==1 );
    219196
    220197  READ_CODE(3, uiCode, "num_extra_slice_header_bits");                pcPPS->setNumExtraSliceHeaderBits(uiCode);
    221 #endif
    222198  READ_FLAG ( uiCode, "sign_data_hiding_flag" ); pcPPS->setSignHideFlag( uiCode );
    223199
    224200  READ_FLAG( uiCode,   "cabac_init_present_flag" );            pcPPS->setCabacInitPresentFlag( uiCode ? true : false );
    225201
    226 #if L0323_LIMIT_DEFAULT_LIST_SIZE
    227202  READ_UVLC(uiCode, "num_ref_idx_l0_default_active_minus1");
    228203  assert(uiCode <= 14);
     
    232207  assert(uiCode <= 14);
    233208  pcPPS->setNumRefIdxL1DefaultActive(uiCode+1);
    234 #else
    235   READ_UVLC(uiCode, "num_ref_idx_l0_default_active_minus1");       pcPPS->setNumRefIdxL0DefaultActive(uiCode+1);
    236   READ_UVLC(uiCode, "num_ref_idx_l1_default_active_minus1");       pcPPS->setNumRefIdxL1DefaultActive(uiCode+1);
    237 #endif
    238209
    239210  READ_SVLC(iCode, "init_qp_minus26" );                            pcPPS->setPicInitQPMinus26(iCode);
     
    270241  pcPPS->setWPBiPred( uiCode==1 );
    271242
    272 #if !L0255_MOVE_PPS_FLAGS
    273   READ_FLAG( uiCode, "output_flag_present_flag" );
    274   pcPPS->setOutputFlagPresentFlag( uiCode==1 );
    275 #endif
    276243  READ_FLAG( uiCode, "transquant_bypass_enable_flag");
    277244  pcPPS->setTransquantBypassEnableFlag(uiCode ? true : false);
     
    335302  pcPPS->setLog2ParallelMergeLevelMinus2 (uiCode);
    336303
    337 #if !L0255_MOVE_PPS_FLAGS
    338   READ_CODE(3, uiCode, "num_extra_slice_header_bits");
    339   pcPPS->setNumExtraSliceHeaderBits(uiCode);
    340 #endif
    341304  READ_FLAG( uiCode, "slice_segment_header_extension_present_flag");
    342305  pcPPS->setSliceHeaderExtensionPresentFlag(uiCode);
     
    400363
    401364  READ_FLAG(     uiCode, "field_seq_flag");                           pcVUI->setFieldSeqFlag(uiCode);
    402   assert(pcVUI->getFieldSeqFlag() == false);        // not supported yet
    403365
    404366  READ_FLAG(uiCode, "frame_field_info_present_flag");                 pcVUI->setFrameFieldInfoPresentFlag(uiCode);
     
    413375    READ_UVLC(   uiCode, "def_disp_win_bottom_offset" );              defDisp.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) );
    414376  }
    415 #if L0043_TIMING_INFO
    416377  TimingInfo *timingInfo = pcVUI->getTimingInfo();
    417378  READ_FLAG(       uiCode, "vui_timing_info_present_flag");         timingInfo->setTimingInfoPresentFlag      (uiCode ? true : false);
     
    425386      READ_UVLC(   uiCode, "vui_num_ticks_poc_diff_one_minus1");    timingInfo->setNumTicksPocDiffOneMinus1   (uiCode);
    426387    }
    427 #endif
    428388  READ_FLAG(     uiCode, "hrd_parameters_present_flag");              pcVUI->setHrdParametersPresentFlag(uiCode);
    429389  if( pcVUI->getHrdParametersPresentFlag() )
     
    431391    parseHrdParameters( pcVUI->getHrdParameters(), 1, pcSPS->getMaxTLayers() - 1 );
    432392  }
    433 #if L0043_TIMING_INFO
    434   }
    435 #endif
    436 #if !L0043_TIMING_INFO
    437   READ_FLAG( uiCode, "poc_proportional_to_timing_flag" ); pcVUI->setPocProportionalToTimingFlag(uiCode ? true : false);
    438   if( pcVUI->getPocProportionalToTimingFlag() && pcVUI->getHrdParameters()->getTimingInfoPresentFlag() )
    439   {
    440     READ_UVLC( uiCode, "num_ticks_poc_diff_one_minus1" ); pcVUI->setNumTicksPocDiffOneMinus1(uiCode);
    441   }
    442 #endif
     393  }
    443394  READ_FLAG(     uiCode, "bitstream_restriction_flag");               pcVUI->setBitstreamRestrictionFlag(uiCode);
    444395  if (pcVUI->getBitstreamRestrictionFlag())
     
    453404    READ_FLAG(   uiCode, "motion_vectors_over_pic_boundaries_flag");  pcVUI->setMotionVectorsOverPicBoundariesFlag(uiCode);
    454405    READ_FLAG(   uiCode, "restricted_ref_pic_lists_flag");            pcVUI->setRestrictedRefPicListsFlag(uiCode);
    455 #if L0043_MSS_IDC
    456406    READ_UVLC( uiCode, "min_spatial_segmentation_idc");            pcVUI->setMinSpatialSegmentationIdc(uiCode);
    457407    assert(uiCode < 4096);
    458 #else
    459     READ_CODE( 8, uiCode, "min_spatial_segmentation_idc");            pcVUI->setMinSpatialSegmentationIdc(uiCode);
    460 #endif
    461408    READ_UVLC(   uiCode, "max_bytes_per_pic_denom" );                 pcVUI->setMaxBytesPerPicDenom(uiCode);
    462409    READ_UVLC(   uiCode, "max_bits_per_mincu_denom" );                pcVUI->setMaxBitsPerMinCuDenom(uiCode);
     
    471418  if( commonInfPresentFlag )
    472419  {
    473 #if !L0043_TIMING_INFO
    474     READ_FLAG( uiCode, "timing_info_present_flag" );                  hrd->setTimingInfoPresentFlag( uiCode == 1 ? true : false );
    475     if( hrd->getTimingInfoPresentFlag() )
    476     {
    477       READ_CODE( 32, uiCode, "num_units_in_tick" );                   hrd->setNumUnitsInTick( uiCode );
    478       READ_CODE( 32, uiCode, "time_scale" );                          hrd->setTimeScale( uiCode );
    479     }
    480 #endif
    481420    READ_FLAG( uiCode, "nal_hrd_parameters_present_flag" );           hrd->setNalHrdParametersPresentFlag( uiCode == 1 ? true : false );
    482421    READ_FLAG( uiCode, "vcl_hrd_parameters_present_flag" );           hrd->setVclHrdParametersPresentFlag( uiCode == 1 ? true : false );
     
    489428        READ_CODE( 5, uiCode, "du_cpb_removal_delay_length_minus1" ); hrd->setDuCpbRemovalDelayLengthMinus1( uiCode );
    490429        READ_FLAG( uiCode, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); hrd->setSubPicCpbParamsInPicTimingSEIFlag( uiCode == 1 ? true : false );
    491 #if L0044_DU_DPB_OUTPUT_DELAY_HRD
    492430        READ_CODE( 5, uiCode, "dpb_output_delay_du_length_minus1"  ); hrd->setDpbOutputDelayDuLengthMinus1( uiCode );
    493 #endif
    494431      }
    495432      READ_CODE( 4, uiCode, "bit_rate_scale" );                       hrd->setBitRateScale( uiCode );
     
    516453      hrd->setFixedPicRateWithinCvsFlag( i, true );
    517454    }
    518 #if L0372
    519455    hrd->setLowDelayHrdFlag( i, 0 ); // Infered to be 0 when not present
    520456    hrd->setCpbCntMinus1   ( i, 0 ); // Infered to be 0 when not present
    521 #endif
    522457    if( hrd->getFixedPicRateWithinCvsFlag( i ) )
    523458    {
    524459      READ_UVLC( uiCode, "elemental_duration_in_tc_minus1" );             hrd->setPicDurationInTcMinus1( i, uiCode );
    525460    }
    526 #if L0372
    527461    else
    528462    {
     
    533467      READ_UVLC( uiCode, "cpb_cnt_minus1" );                          hrd->setCpbCntMinus1( i, uiCode );
    534468    }
    535 #else
    536     READ_FLAG( uiCode, "low_delay_hrd_flag" );                      hrd->setLowDelayHrdFlag( i, uiCode == 1 ? true : false  );
    537     READ_UVLC( uiCode, "cpb_cnt_minus1" );                          hrd->setCpbCntMinus1( i, uiCode );
    538 #endif
    539469    for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ )
    540470    {
     
    548478          if( hrd->getSubPicCpbParamsPresentFlag() )
    549479          {
    550 #if L0363_DU_BIT_RATE
     480            READ_UVLC( uiCode, "cpb_size_du_value_minus1" );       hrd->setDuCpbSizeValueMinus1( i, j, nalOrVcl, uiCode );
    551481            READ_UVLC( uiCode, "bit_rate_du_value_minus1" );       hrd->setDuBitRateValueMinus1( i, j, nalOrVcl, uiCode );
    552 #endif
    553             READ_UVLC( uiCode, "cpb_size_du_value_minus1" );       hrd->setDuCpbSizeValueMinus1( i, j, nalOrVcl, uiCode );
    554482          }
    555483          READ_FLAG( uiCode, "cbr_flag" );                          hrd->setCbrFlag( i, j, nalOrVcl, uiCode == 1 ? true : false  );
     
    577505#endif
    578506    READ_CODE( 3,  uiCode, "sps_max_sub_layers_minus1" );          pcSPS->setMaxTLayers   ( uiCode+1 );
     507    assert(uiCode <= 6);
     508 
    579509    READ_FLAG( uiCode, "sps_temporal_id_nesting_flag" );               pcSPS->setTemporalIdNestingFlag ( uiCode > 0 ? true : false );
    580510#if SPS_SUB_LAYER_INFO
     
    598528  parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1);
    599529  READ_UVLC(     uiCode, "sps_seq_parameter_set_id" );           pcSPS->setSPSId( uiCode );
     530  assert(uiCode <= 15);
     531 
    600532  READ_UVLC(     uiCode, "chroma_format_idc" );                  pcSPS->setChromaFormatIdc( uiCode );
     533  assert(uiCode <= 3);
    601534  // in the first version we only support chroma_format_idc equal to 1 (4:2:0), so separate_colour_plane_flag cannot appear in the bitstream
    602535  assert (uiCode == 1);
     
    619552
    620553  READ_UVLC(     uiCode, "bit_depth_luma_minus8" );
     554  assert(uiCode <= 6);
    621555  pcSPS->setBitDepthY( uiCode + 8 );
    622556  pcSPS->setQpBDOffsetY( (Int) (6*uiCode) );
    623557
    624558  READ_UVLC( uiCode,    "bit_depth_chroma_minus8" );
     559  assert(uiCode <= 6);
    625560  pcSPS->setBitDepthC( uiCode + 8 );
    626561  pcSPS->setQpBDOffsetC( (Int) (6*uiCode) );
    627562
    628563  READ_UVLC( uiCode,    "log2_max_pic_order_cnt_lsb_minus4" );   pcSPS->setBitsForPOC( 4 + uiCode );
     564  assert(uiCode <= 12);
    629565
    630566  UInt subLayerOrderingInfoPresentFlag;
    631567  READ_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag");
     568 
    632569  for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++)
    633570  {
    634 #if L0323_DPB
    635571    READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1");
    636572    pcSPS->setMaxDecPicBuffering( uiCode + 1, i);
    637 #else
    638     READ_UVLC ( uiCode, "sps_max_dec_pic_buffering");
    639     pcSPS->setMaxDecPicBuffering( uiCode, i);
    640 #endif
    641573    READ_UVLC ( uiCode, "sps_num_reorder_pics" );
    642574    pcSPS->setNumReorderPics(uiCode, i);
    643     READ_UVLC ( uiCode, "sps_max_latency_increase");
     575    READ_UVLC ( uiCode, "sps_max_latency_increase_plus1");
    644576    pcSPS->setMaxLatencyIncrease( uiCode, i );
    645577
     
    698630
    699631  READ_UVLC( uiCode, "num_short_term_ref_pic_sets" );
     632  assert(uiCode <= 64);
    700633  pcSPS->createRPSList(uiCode);
    701634
     
    823756  READ_CODE( 16, uiCode,  "vps_reserved_ffff_16bits" );           assert(uiCode == 0xffff);
    824757  parsePTL ( pcVPS->getPTL(), true, pcVPS->getMaxTLayers()-1);
    825 #if SIGNAL_BITRATE_PICRATE_IN_VPS
    826   parseBitratePicRateInfo( pcVPS->getBitratePicrateInfo(), 0, pcVPS->getMaxTLayers() - 1);
    827 #endif
    828758  UInt subLayerOrderingInfoPresentFlag;
    829759  READ_FLAG(subLayerOrderingInfoPresentFlag, "vps_sub_layer_ordering_info_present_flag");
    830760  for(UInt i = 0; i <= pcVPS->getMaxTLayers()-1; i++)
    831761  {
    832 #if L0323_DPB
    833762    READ_UVLC( uiCode,  "vps_max_dec_pic_buffering_minus1[i]" );     pcVPS->setMaxDecPicBuffering( uiCode + 1, i );
    834 #else
    835     READ_UVLC( uiCode,  "vps_max_dec_pic_buffering[i]" );     pcVPS->setMaxDecPicBuffering( uiCode, i );
    836 #endif
    837763    READ_UVLC( uiCode,  "vps_num_reorder_pics[i]" );          pcVPS->setNumReorderPics( uiCode, i );
    838     READ_UVLC( uiCode,  "vps_max_latency_increase[i]" );      pcVPS->setMaxLatencyIncrease( uiCode, i );
     764    READ_UVLC( uiCode,  "vps_max_latency_increase_plus1[i]" );      pcVPS->setMaxLatencyIncrease( uiCode, i );
    839765
    840766    if (!subLayerOrderingInfoPresentFlag)
     
    876802  pcVPS->deriveLayerIdListVariables();
    877803#endif
    878 #if L0043_TIMING_INFO
    879804  TimingInfo *timingInfo = pcVPS->getTimingInfo();
    880805  READ_FLAG(       uiCode, "vps_timing_info_present_flag");         timingInfo->setTimingInfoPresentFlag      (uiCode ? true : false);
     
    888813      READ_UVLC(   uiCode, "vps_num_ticks_poc_diff_one_minus1");    timingInfo->setNumTicksPocDiffOneMinus1   (uiCode);
    889814    }
    890 #endif
    891815    READ_UVLC( uiCode, "vps_num_hrd_parameters" );                  pcVPS->setNumHrdParameters( uiCode );
    892816
     
    904828      parseHrdParameters(pcVPS->getHrdParameters(i), pcVPS->getCprmsPresentFlag( i ), pcVPS->getMaxTLayers() - 1);
    905829    }
    906 #if L0043_TIMING_INFO
    907   }
    908 #endif
     830  }
    909831  READ_FLAG( uiCode,  "vps_extension_flag" );
    910832  if (uiCode)
     
    13531275          uiCode = 0;
    13541276        }
    1355         memcpy(rps,sps->getRPSList()->getReferencePictureSet(uiCode),sizeof(TComReferencePictureSet));
     1277        *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode));
    13561278      }
    13571279      if(sps->getLongTermRefsPresent())
     
    14461368        rpcSlice->setRPS(rps);
    14471369      }
    1448 
    1449 
    14501370      if (rpcSlice->getSPS()->getTMVPFlagsPresent())
    14511371      {
     
    17941714    for (UInt idx=0; idx<numEntryPointOffsets; idx++)
    17951715    {
    1796 #if L0116_ENTRY_POINT
    17971716      READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset_minus1");
    17981717      entryPointOffset[ idx ] = uiCode + 1;
    1799 #else
    1800       READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset");
    1801       entryPointOffset[ idx ] = uiCode;
    1802 #endif
    18031718    }
    18041719  }
     
    18221737  {
    18231738    Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation();
     1739   
     1740    // Adjust endOfSliceHeaderLocation to account for emulation prevention bytes in the slice segment header
     1741    for ( UInt curByteIdx  = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ )
     1742    {
     1743      if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < endOfSliceHeaderLocation )
     1744      {
     1745        endOfSliceHeaderLocation++;
     1746      }
     1747    }
     1748
    18241749    Int  curEntryPointOffset     = 0;
    18251750    Int  prevEntryPointOffset    = 0;
     
    18891814  READ_CODE( 8, uiCode, "general_level_idc" );    rpcPTL->getGeneralPTL()->setLevelIdc(uiCode);
    18901815
    1891 #if L0363_BYTE_ALIGN
    18921816  for (Int i = 0; i < maxNumSubLayersMinus1; i++)
    18931817  {
     
    19071831    }
    19081832  }
    1909 #endif
    19101833
    19111834  for(Int i = 0; i < maxNumSubLayersMinus1; i++)
    19121835  {
    1913 #if !L0363_BYTE_ALIGN
    1914     if(profilePresentFlag)
    1915     {
    1916       READ_FLAG( uiCode, "sub_layer_profile_present_flag[i]" ); rpcPTL->setSubLayerProfilePresentFlag(i, uiCode);
    1917     }
    1918     READ_FLAG( uiCode, "sub_layer_level_present_flag[i]"   ); rpcPTL->setSubLayerLevelPresentFlag  (i, uiCode);
    1919 #endif
    19201836    if( profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) )
    19211837    {
     
    19391855    READ_FLAG(  uiCode, "XXX_profile_compatibility_flag[][j]");   ptl->setProfileCompatibilityFlag(j, uiCode ? 1 : 0);
    19401856  }
    1941 #if L0046_CONSTRAINT_FLAGS
    19421857  READ_FLAG(uiCode, "general_progressive_source_flag");
    19431858  ptl->setProgressiveSourceFlag(uiCode ? true : false);
     
    19551870  READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[16..31]");
    19561871  READ_CODE(12, uiCode, "XXX_reserved_zero_44bits[32..43]");
    1957 #elif L0363_MORE_BITS
    1958   READ_CODE(16, uiCode, "XXX_reserved_zero_48bits[0..15]");
    1959   READ_CODE(16, uiCode, "XXX_reserved_zero_48bits[16..31]");
    1960   READ_CODE(16, uiCode, "XXX_reserved_zero_48bits[32..47]");
    1961 #else
    1962   READ_CODE(16, uiCode, "XXX_reserved_zero_16bits[]");  assert( uiCode == 0 );
    1963 #endif
    1964 }
    1965 #if SIGNAL_BITRATE_PICRATE_IN_VPS
    1966 Void TDecCavlc::parseBitratePicRateInfo(TComBitRatePicRateInfo *info, Int tempLevelLow, Int tempLevelHigh)
    1967 {
    1968   UInt uiCode;
    1969   for(Int i = tempLevelLow; i <= tempLevelHigh; i++)
    1970   {
    1971     READ_FLAG( uiCode, "bit_rate_info_present_flag[i]" ); info->setBitRateInfoPresentFlag(i, uiCode ? true : false);
    1972     READ_FLAG( uiCode, "pic_rate_info_present_flag[i]" ); info->setPicRateInfoPresentFlag(i, uiCode ? true : false);
    1973     if(info->getBitRateInfoPresentFlag(i))
    1974     {
    1975       READ_CODE( 16, uiCode, "avg_bit_rate[i]" ); info->setAvgBitRate(i, uiCode);
    1976       READ_CODE( 16, uiCode, "max_bit_rate[i]" ); info->setMaxBitRate(i, uiCode);
    1977     }
    1978     if(info->getPicRateInfoPresentFlag(i))
    1979     {
    1980       READ_CODE(  2, uiCode,  "constant_pic_rate_idc[i]" ); info->setConstantPicRateIdc(i, uiCode);
    1981       READ_CODE( 16, uiCode,  "avg_pic_rate[i]"          ); info->setAvgPicRate(i, uiCode);
    1982     }
    1983   }
    1984 }
    1985 #endif
     1872}
     1873
    19861874Void TDecCavlc::parseTerminatingBit( UInt& ruiBit )
    19871875{
  • branches/SHM-2.1-dev/source/Lib/TLibDecoder/TDecCAVLC.h

    r226 r302  
    8888  Void  parsePTL            ( TComPTL *rpcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1 );
    8989  Void  parseProfileTier    (ProfileTierLevel *ptl);
    90 #if SIGNAL_BITRATE_PICRATE_IN_VPS
    91   Void  parseBitratePicRateInfo(TComBitRatePicRateInfo *info, Int tempLevelLow, Int tempLevelHigh);
    92 #endif
    9390  Void  parseHrdParameters  (TComHRD *hrd, Bool cprms_present_flag, UInt tempLevelHigh);
    9491  Void  parseSliceHeader    ( TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager);
  • branches/SHM-2.1-dev/source/Lib/TLibDecoder/TDecEntropy.cpp

    r191 r302  
    188188      decodeMergeIndex( pcCU, uiPartIdx, uiSubPartIdx, uiDepth );
    189189      UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
    190 #if 0 //REF_IDX_FRAMEWORK  // HM bug fix
    191       if(uiPartIdx)
    192       {
    193         for(UInt ui=0; ui<uiMergeIndex+1; ui++)
    194         {
    195           cMvFieldNeighbours[(ui<<1)].setMvField(TComMv(), NOT_VALID);
    196           cMvFieldNeighbours[(ui<<1)+1].setMvField(TComMv(), NOT_VALID);
    197         }
    198       }
    199 #endif
    200190      if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 )
    201191      {
  • branches/SHM-2.1-dev/source/Lib/TLibDecoder/TDecSbac.cpp

    r191 r302  
    158158  UInt uiBit;
    159159  m_pcTDecBinIf->decodeBinTrm(uiBit);
     160  assert(uiBit); // end_of_sub_stream_one_bit must be equal to 1
    160161  m_pcTDecBinIf->finish(); 
    161162  m_pcBitstream->readOutTrailingBits();
     
    196197{
    197198  m_pcTDecBinIf->decodeBinTrm( ruiBit );
     199  if ( ruiBit )
     200  {
     201    m_pcTDecBinIf->finish();
     202  }
    198203}
    199204
     
    318323{
    319324  UInt uiSymbol;
    320   Bool readPCMSampleFlag = false;
    321325
    322326    m_pcTDecBinIf->decodeBinTrm(uiSymbol);
     
    324328    if (uiSymbol)
    325329    {
    326       readPCMSampleFlag = true;
    327       m_pcTDecBinIf->decodePCMAlignBits();
    328     }
    329 
    330   if (readPCMSampleFlag == true)
    331   {
    332330    Bool bIpcmFlag = true;
    333331
     
    395393    }
    396394
    397       m_pcTDecBinIf->resetBac();
     395    m_pcTDecBinIf->start();
    398396  }
    399397}
     
    681679    else
    682680    {
    683       intraPredMode = 0;
    684681      m_pcTDecBinIf->decodeBinsEP( symbol, 5 );
    685682      intraPredMode = symbol;
     
    917914  else
    918915  {
    919     iDQp=0;
    920916    qp = pcCU->getRefQP(uiAbsPartIdx);
    921917  }
     
    11021098
    11031099  //===== decode significance flags =====
    1104   UInt uiScanPosLast = uiBlkPosLast;
     1100  UInt uiScanPosLast;
    11051101  const UInt *scan   = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize-1 ];
    11061102  for( uiScanPosLast = 0; uiScanPosLast < uiMaxNumCoeffM1; uiScanPosLast++ )
  • branches/SHM-2.1-dev/source/Lib/TLibDecoder/TDecSlice.cpp

    r191 r302  
    384384    pcSbacDecoders[uiSubStrm].load(pcSbacDecoder);
    385385
     386    if ( uiCol == rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iCUAddr))->getRightEdgePosInCU()
     387        && pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()
     388        && !uiIsLast )
     389    {
     390      // Parse end_of_substream_one_bit for WPP case
     391      UInt binVal;
     392      pcSbacDecoder->parseTerminatingBit( binVal );
     393      assert( binVal );
     394    }
     395
    386396    //Store probabilities of second LCU in line into buffer
    387397    if ( (uiCol == uiTileLCUX+1)&& (depSliceSegmentsEnabled || (pcSlice->getPPS()->getNumSubstreams() > 1)) && (pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) )
  • branches/SHM-2.1-dev/source/Lib/TLibDecoder/TDecTop.cpp

    r297 r302  
    241241  }
    242242
    243 #if L0323_DPB
    244   m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer())+pcSlice->getSPS()->getNumReorderPics(pcSlice->getTLayer());     // m_uiMaxDecPicBuffering has the space for the picture currently being decoded
    245 #else
    246   m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer())+pcSlice->getSPS()->getNumReorderPics(pcSlice->getTLayer()) + 1; // +1 to have space for the picture currently being decoded
    247 #endif
     243  m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer());     // m_uiMaxDecPicBuffering has the space for the picture currently being decoded
    248244  if (m_cListPic.size() < (UInt)m_iMaxRefPicNum)
    249245  {
     
    476472  m_apcSlicePilot->setPPS(pps);
    477473  m_apcSlicePilot->setSPS(sps);
    478 
    479474  pps->setSPS(sps);
    480475  pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumColumnsMinus1() + 1) : 1);
     
    991986    //---------------
    992987    pcSlice->setRefPOCList();
    993 #if !L0034_COMBINED_LIST_CLEANUP
    994     pcSlice->setNoBackPredFlag( false );
    995     if ( pcSlice->getSliceType() == B_SLICE )
    996     {
    997       if ( pcSlice->getNumRefIdx(RefPicList( 0 ) ) == pcSlice->getNumRefIdx(RefPicList( 1 ) ) )
    998       {
    999         pcSlice->setNoBackPredFlag( true );
    1000         for ( i=0; i < pcSlice->getNumRefIdx(RefPicList( 1 ) ); i++ )
    1001         {
    1002           if ( pcSlice->getRefPOC(RefPicList(1), i) != pcSlice->getRefPOC(RefPicList(0), i) )
    1003           {
    1004             pcSlice->setNoBackPredFlag( false );
    1005             break;
    1006           }
    1007         }
    1008       }
    1009     }
    1010 #endif
    1011988  }
    1012989
  • branches/SHM-2.1-dev/source/Lib/TLibEncoder/SEIwrite.cpp

    r292 r302  
    8484    fprintf( g_hTrace, "=========== Decoding Unit Information SEI message ===========\n");
    8585    break;
    86 #if J0149_TONE_MAPPING_SEI
    8786  case SEI::TONE_MAPPING_INFO:
    8887    fprintf( g_hTrace, "=========== Tone Mapping Info SEI message ===========\n");
    8988    break;
    90 #endif
    9189#if M0043_LAYERS_PRESENT_SEI
    9290  case SEI::LAYERS_PRESENT:
     
    9492    break;
    9593#endif
    96 #if L0208_SOP_DESCRIPTION_SEI
    9794  case SEI::SOP_DESCRIPTION:
    9895    fprintf( g_hTrace, "=========== SOP Description SEI message ===========\n");
    9996    break;
    100 #endif
    101 #if K0180_SCALABLE_NESTING_SEI
    10297  case SEI::SCALABLE_NESTING:
    10398    fprintf( g_hTrace, "=========== Scalable Nesting SEI message ===========\n");
    10499    break;
    105 #endif
    106100  default:
    107101    fprintf( g_hTrace, "=========== Unknown SEI message ===========\n");
     
    111105#endif
    112106
    113 #if K0180_SCALABLE_NESTING_SEI
    114107void SEIWriter::xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, TComSPS *sps)
    115 #else
    116 void SEIWriter::xWriteSEIpayloadData(const SEI& sei, TComSPS *sps)
    117 #endif
    118108{
    119109  switch (sei.payloadType())
     
    152142    xWriteSEIGradualDecodingRefreshInfo(*static_cast<const SEIGradualDecodingRefreshInfo*>(&sei));
    153143    break;
    154 #if J0149_TONE_MAPPING_SEI
    155144  case SEI::TONE_MAPPING_INFO:
    156145    xWriteSEIToneMappingInfo(*static_cast<const SEIToneMappingInfo*>(&sei));
    157146    break;
    158 #endif
    159147#if M0043_LAYERS_PRESENT_SEI
    160148  case SEI::LAYERS_PRESENT:
     
    162150    break;
    163151#endif
    164 #if L0208_SOP_DESCRIPTION_SEI
    165152  case SEI::SOP_DESCRIPTION:
    166153    xWriteSEISOPDescription(*static_cast<const SEISOPDescription*>(&sei));
    167154    break;
    168 #endif
    169 #if K0180_SCALABLE_NESTING_SEI
    170155  case SEI::SCALABLE_NESTING:
    171156    xWriteSEIScalableNesting(bs, *static_cast<const SEIScalableNesting*>(&sei), sps);
    172157    break;
    173 #endif
    174158  default:
    175159    assert(!"Unhandled SEI message");
     
    190174
    191175
    192 #if K0180_SCALABLE_NESTING_SEI
    193 
    194176#if ENC_DEC_TRACE
    195177  Bool traceEnable = g_HLSTraceEnable;
     
    201183#endif
    202184
    203 #else
    204 
    205 #if ENC_DEC_TRACE
    206   g_HLSTraceEnable = false;
    207 #endif
    208   xWriteSEIpayloadData(sei, sps);
    209 #if ENC_DEC_TRACE
    210   g_HLSTraceEnable = true;
    211 #endif
    212 
    213 #endif
    214 
    215185  UInt payload_data_num_bits = bs_count.getNumberOfWrittenBits();
    216186  assert(0 == payload_data_num_bits % 8);
     
    219189
    220190#if ENC_DEC_TRACE
    221 #if K0180_SCALABLE_NESTING_SEI
    222191  if (g_HLSTraceEnable)
    223 #endif
    224192  xTraceSEIHeader();
    225193#endif
     
    241209  /* payloadData */
    242210#if ENC_DEC_TRACE
    243 #if K0180_SCALABLE_NESTING_SEI
    244211  if (g_HLSTraceEnable)
    245 #endif
    246212  xTraceSEIMessageType(sei.payloadType());
    247213#endif
    248214
    249 #if K0180_SCALABLE_NESTING_SEI
    250215  xWriteSEIpayloadData(bs, sei, sps);
    251 #else
    252   xWriteSEIpayloadData(sei, sps);
    253 #endif
    254216}
    255217
     
    306268{
    307269  WRITE_CODE(sei.activeVPSId,     4, "active_vps_id");
    308 #if L0047_APS_FLAGS
    309270  WRITE_FLAG(sei.m_fullRandomAccessFlag, "full_random_access_flag");
    310271  WRITE_FLAG(sei.m_noParamSetUpdateFlag, "no_param_set_update_flag");
    311 #endif
    312272  WRITE_UVLC(sei.numSpsIdsMinus1,    "num_sps_ids_minus1");
    313273
     
    340300    WRITE_CODE( sei.m_duSptCpbRemovalDelay, (vui->getHrdParameters()->getDuCpbRemovalDelayLengthMinus1() + 1), "du_spt_cpb_removal_delay");
    341301  }
    342 #if L0044_DU_DPB_OUTPUT_DELAY_HRD
    343302  WRITE_FLAG( sei.m_dpbOutputDuDelayPresentFlag, "dpb_output_du_delay_present_flag");
    344303  if(sei.m_dpbOutputDuDelayPresentFlag)
     
    346305    WRITE_CODE(sei.m_picSptDpbOutputDuDelay, vui->getHrdParameters()->getDpbOutputDelayDuLengthMinus1() + 1, "pic_spt_dpb_output_du_delay");
    347306  }
    348 #endif
    349307  xWriteByteAlign();
    350308}
     
    361319    WRITE_FLAG( sei.m_rapCpbParamsPresentFlag, "rap_cpb_params_present_flag" );
    362320  }
    363 #if L0328_SPLICING
    364321  WRITE_FLAG( sei.m_concatenationFlag, "concatenation_flag");
    365322  WRITE_CODE( sei.m_auCpbRemovalDelayDelta - 1, ( hrd->getCpbRemovalDelayLengthMinus1() + 1 ), "au_cpb_removal_delay_delta_minus1" );
    366 #endif
    367 #if L0044_CPB_DPB_DELAY_OFFSET
    368323  if( sei.m_rapCpbParamsPresentFlag )
    369324  {
     
    371326    WRITE_CODE( sei.m_dpbDelayOffset, hrd->getDpbOutputDelayLengthMinus1()  + 1, "dpb_delay_offset" );
    372327  }
    373 #endif
    374328  for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ )
    375329  {
     
    397351  TComHRD *hrd = vui->getHrdParameters();
    398352
    399 #if !L0045_CONDITION_SIGNALLING
    400   // This condition was probably OK before the pic_struct, progressive_source_idc, duplicate_flag were added
    401   if( !hrd->getNalHrdParametersPresentFlag() && !hrd->getVclHrdParametersPresentFlag() )
    402     return;
    403 #endif
    404353  if( vui->getFrameFieldInfoPresentFlag() )
    405354  {
    406355    WRITE_CODE( sei.m_picStruct, 4,              "pic_struct" );
    407 #if L0046_RENAME_PROG_SRC_IDC
    408356    WRITE_CODE( sei.m_sourceScanType, 2,         "source_scan_type" );
    409 #else
    410     WRITE_CODE( sei.m_progressiveSourceIdc, 2,   "progressive_source_idc" );
    411 #endif
    412357    WRITE_FLAG( sei.m_duplicateFlag ? 1 : 0,     "duplicate_flag" );
    413358  }
    414359
    415 #if L0045_CONDITION_SIGNALLING
    416360  if( hrd->getCpbDpbDelaysPresentFlag() )
    417361  {
    418 #endif
    419362    WRITE_CODE( sei.m_auCpbRemovalDelay - 1, ( hrd->getCpbRemovalDelayLengthMinus1() + 1 ),                                         "au_cpb_removal_delay_minus1" );
    420363    WRITE_CODE( sei.m_picDpbOutputDelay, ( hrd->getDpbOutputDelayLengthMinus1() + 1 ),                                          "pic_dpb_output_delay" );
    421 #if L0044_DU_DPB_OUTPUT_DELAY_HRD
    422364    if(hrd->getSubPicCpbParamsPresentFlag())
    423365    {
    424366      WRITE_CODE(sei.m_picDpbOutputDuDelay, hrd->getDpbOutputDelayDuLengthMinus1()+1, "pic_dpb_output_du_delay" );
    425367    }
    426 #endif
    427368    if( hrd->getSubPicCpbParamsPresentFlag() && hrd->getSubPicCpbParamsInPicTimingSEIFlag() )
    428369    {
     
    442383      }
    443384    }
    444 #if L0045_CONDITION_SIGNALLING
    445   }
    446 #endif
     385  }
    447386  xWriteByteAlign();
    448387}
     
    481420
    482421    WRITE_CODE( sei.m_arrangementReservedByte, 8,   "frame_packing_arrangement_reserved_byte" );
    483 #if L0045_PERSISTENCE_FLAGS
    484422    WRITE_FLAG( sei.m_arrangementPersistenceFlag,   "frame_packing_arrangement_persistence_flag" );
    485 #else
    486     WRITE_UVLC( sei.m_arrangementRepetetionPeriod,  "frame_packing_arrangement_repetition_period" );
    487 #endif
    488423  }
    489424
     
    493428}
    494429
    495 #if J0149_TONE_MAPPING_SEI
    496430Void SEIWriter::xWriteSEIToneMappingInfo(const SEIToneMappingInfo& sei)
    497431{
     
    565499  xWriteByteAlign();
    566500}
    567 #endif
    568501
    569502Void SEIWriter::xWriteSEIDisplayOrientation(const SEIDisplayOrientation &sei)
     
    575508    WRITE_FLAG( sei.verFlip,                   "ver_flip" );
    576509    WRITE_CODE( sei.anticlockwiseRotation, 16, "anticlockwise_rotation" );
    577 #if L0045_PERSISTENCE_FLAGS
    578510    WRITE_FLAG( sei.persistenceFlag,          "display_orientation_persistence_flag" );
    579 #else
    580     WRITE_UVLC( sei.repetitionPeriod,          "display_orientation_repetition_period" );
    581 #endif
    582 #if !REMOVE_SINGLE_SEI_EXTENSION_FLAGS
    583     WRITE_FLAG( sei.extensionFlag,             "display_orientation_extension_flag" );
    584     assert( !sei.extensionFlag );
    585 #endif
    586511  }
    587512  xWriteByteAlign();
     
    613538#endif
    614539
    615 #if L0208_SOP_DESCRIPTION_SEI
    616540Void SEIWriter::xWriteSEISOPDescription(const SEISOPDescription& sei)
    617541{
     
    634558  xWriteByteAlign();
    635559}
    636 #endif
    637 
    638 #if K0180_SCALABLE_NESTING_SEI
     560
    639561Void SEIWriter::xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, TComSPS *sps)
    640562{
     
    678600  }
    679601}
    680 #endif
    681602
    682603Void SEIWriter::xWriteByteAlign()
  • branches/SHM-2.1-dev/source/Lib/TLibEncoder/SEIwrite.h

    r292 r302  
    5050
    5151protected:
    52 #if K0180_SCALABLE_NESTING_SEI
    5352  Void xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, TComSPS *sps);
    54 #else
    55   Void xWriteSEIpayloadData(const SEI& sei, TComSPS *sps);
    56 #endif
    5753  Void xWriteSEIuserDataUnregistered(const SEIuserDataUnregistered &sei);
    5854  Void xWriteSEIActiveParameterSets(const SEIActiveParameterSets& sei);
     
    6763  Void xWriteSEITemporalLevel0Index(const SEITemporalLevel0Index &sei);
    6864  Void xWriteSEIGradualDecodingRefreshInfo(const SEIGradualDecodingRefreshInfo &sei);
    69 #if J0149_TONE_MAPPING_SEI
    7065  Void xWriteSEIToneMappingInfo(const SEIToneMappingInfo& sei);
    71 #endif
    7266#if M0043_LAYERS_PRESENT_SEI
    7367  Void xWriteSEILayersPresent(const SEILayersPresent& sei);
    7468#endif
    75 #if L0208_SOP_DESCRIPTION_SEI
    7669  Void xWriteSEISOPDescription(const SEISOPDescription& sei);
    77 #endif
    78 #if K0180_SCALABLE_NESTING_SEI
    7970  Void xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, TComSPS *sps);
    80 #endif
    8171  Void xWriteByteAlign();
    8272};
  • branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncCavlc.cpp

    r300 r302  
    3939#include "TEncCavlc.h"
    4040#include "SEIwrite.h"
    41 #include <iostream>
     41
    4242//! \ingroup TLibEncoder
    4343//! \{
     
    163163  WRITE_UVLC( pcPPS->getSPSId(),                             "pps_seq_parameter_set_id" );
    164164  WRITE_FLAG( pcPPS->getDependentSliceSegmentsEnabledFlag()    ? 1 : 0, "dependent_slice_segments_enabled_flag" );
    165 #if L0255_MOVE_PPS_FLAGS
    166165  WRITE_FLAG( pcPPS->getOutputFlagPresentFlag() ? 1 : 0,     "output_flag_present_flag" );
    167166  WRITE_CODE( pcPPS->getNumExtraSliceHeaderBits(), 3,        "num_extra_slice_header_bits");
    168 #endif
    169167  WRITE_FLAG( pcPPS->getSignHideFlag(), "sign_data_hiding_flag" );
    170168  WRITE_FLAG( pcPPS->getCabacInitPresentFlag() ? 1 : 0,   "cabac_init_present_flag" );
     
    186184  WRITE_FLAG( pcPPS->getUseWP() ? 1 : 0,  "weighted_pred_flag" );   // Use of Weighting Prediction (P_SLICE)
    187185  WRITE_FLAG( pcPPS->getWPBiPred() ? 1 : 0, "weighted_bipred_flag" );  // Use of Weighting Bi-Prediction (B_SLICE)
    188 #if !L0255_MOVE_PPS_FLAGS
    189   WRITE_FLAG( pcPPS->getOutputFlagPresentFlag() ? 1 : 0,  "output_flag_present_flag" );
    190 #endif
    191186  WRITE_FLAG( pcPPS->getTransquantBypassEnableFlag() ? 1 : 0, "transquant_bypass_enable_flag" );
    192187  WRITE_FLAG( pcPPS->getTilesEnabledFlag()             ? 1 : 0, "tiles_enabled_flag" );
     
    235230  WRITE_FLAG( pcPPS->getListsModificationPresentFlag(), "lists_modification_present_flag");
    236231  WRITE_UVLC( pcPPS->getLog2ParallelMergeLevelMinus2(), "log2_parallel_merge_level_minus2");
    237 #if !L0255_MOVE_PPS_FLAGS
    238   WRITE_CODE( pcPPS->getNumExtraSliceHeaderBits(), 3, "num_extra_slice_header_bits");
    239 #endif
    240232  WRITE_FLAG( pcPPS->getSliceHeaderExtensionPresentFlag() ? 1 : 0, "slice_segment_header_extension_present_flag");
    241233  WRITE_FLAG( 0, "pps_extension_flag" );
     
    296288    WRITE_UVLC(defaultDisplayWindow.getWindowBottomOffset(),    "def_disp_win_bottom_offset");
    297289  }
    298 #if L0043_TIMING_INFO
    299290  TimingInfo *timingInfo = pcVUI->getTimingInfo();
    300291  WRITE_FLAG(timingInfo->getTimingInfoPresentFlag(),          "vui_timing_info_present_flag");
     
    308299      WRITE_UVLC(timingInfo->getNumTicksPocDiffOneMinus1(),   "vui_num_ticks_poc_diff_one_minus1");
    309300    }
    310 #endif
    311301  WRITE_FLAG(pcVUI->getHrdParametersPresentFlag(),              "hrd_parameters_present_flag");
    312302  if( pcVUI->getHrdParametersPresentFlag() )
     
    314304    codeHrdParameters(pcVUI->getHrdParameters(), 1, pcSPS->getMaxTLayers() - 1 );
    315305  }
    316 #if L0043_TIMING_INFO
    317   }
    318 #endif
    319 #if !L0043_TIMING_INFO
    320   WRITE_FLAG( pcVUI->getPocProportionalToTimingFlag(), "poc_proportional_to_timing_flag" );
    321   if( pcVUI->getPocProportionalToTimingFlag() && pcVUI->getHrdParameters()->getTimingInfoPresentFlag() )
    322   {
    323     WRITE_UVLC( pcVUI->getNumTicksPocDiffOneMinus1(), "num_ticks_poc_diff_one_minus1" );
    324   }
    325 #endif
     306  }
    326307
    327308  WRITE_FLAG(pcVUI->getBitstreamRestrictionFlag(),              "bitstream_restriction_flag");
     
    337318    WRITE_FLAG(pcVUI->getMotionVectorsOverPicBoundariesFlag(),  "motion_vectors_over_pic_boundaries_flag");
    338319    WRITE_FLAG(pcVUI->getRestrictedRefPicListsFlag(),           "restricted_ref_pic_lists_flag");
    339 #if L0043_MSS_IDC
    340320    WRITE_UVLC(pcVUI->getMinSpatialSegmentationIdc(),           "min_spatial_segmentation_idc");
    341 #else
    342     WRITE_CODE(pcVUI->getMinSpatialSegmentationIdc(),        8, "min_spatial_segmentation_idc");
    343 #endif
    344321    WRITE_UVLC(pcVUI->getMaxBytesPerPicDenom(),                 "max_bytes_per_pic_denom");
    345322    WRITE_UVLC(pcVUI->getMaxBitsPerMinCuDenom(),                "max_bits_per_mincu_denom");
     
    353330  if( commonInfPresentFlag )
    354331  {
    355 #if !L0043_TIMING_INFO
    356     WRITE_FLAG( hrd->getTimingInfoPresentFlag() ? 1 : 0,        "timing_info_present_flag" );
    357     if( hrd->getTimingInfoPresentFlag() )
    358     {
    359       WRITE_CODE( hrd->getNumUnitsInTick(), 32,                  "num_units_in_tick" );
    360       WRITE_CODE( hrd->getTimeScale(),      32,                  "time_scale" );
    361     }
    362 #endif
    363332    WRITE_FLAG( hrd->getNalHrdParametersPresentFlag() ? 1 : 0 ,  "nal_hrd_parameters_present_flag" );
    364333    WRITE_FLAG( hrd->getVclHrdParametersPresentFlag() ? 1 : 0 ,  "vcl_hrd_parameters_present_flag" );
     
    371340        WRITE_CODE( hrd->getDuCpbRemovalDelayLengthMinus1(), 5,  "du_cpb_removal_delay_length_minus1" );
    372341        WRITE_FLAG( hrd->getSubPicCpbParamsInPicTimingSEIFlag() ? 1 : 0, "sub_pic_cpb_params_in_pic_timing_sei_flag" );
    373 #if L0044_DU_DPB_OUTPUT_DELAY_HRD
    374342        WRITE_CODE( hrd->getDpbOutputDelayDuLengthMinus1(), 5,   "dpb_output_delay_du_length_minus1"  );
    375 #endif
    376343      }
    377344      WRITE_CODE( hrd->getBitRateScale(), 4,                     "bit_rate_scale" );
     
    402369      WRITE_UVLC( hrd->getPicDurationInTcMinus1( i ),           "elemental_duration_in_tc_minus1");
    403370    }
    404 #if L0372
    405371    else
    406372    {
     
    411377      WRITE_UVLC( hrd->getCpbCntMinus1( i ),                      "cpb_cnt_minus1");
    412378    }
    413 #else
    414     WRITE_FLAG( hrd->getLowDelayHrdFlag( i ) ? 1 : 0,           "low_delay_hrd_flag");
    415     WRITE_UVLC( hrd->getCpbCntMinus1( i ),                      "cpb_cnt_minus1");
    416 #endif
    417379   
    418380    for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ )
     
    427389          if( hrd->getSubPicCpbParamsPresentFlag() )
    428390          {
    429 #if L0363_DU_BIT_RATE
     391            WRITE_UVLC( hrd->getDuCpbSizeValueMinus1( i, j, nalOrVcl ), "cpb_size_du_value_minus1"); 
    430392            WRITE_UVLC( hrd->getDuBitRateValueMinus1( i, j, nalOrVcl ), "bit_rate_du_value_minus1");
    431 #endif
    432             WRITE_UVLC( hrd->getDuCpbSizeValueMinus1( i, j, nalOrVcl ), "cpb_size_du_value_minus1"); 
    433393          }
    434394          WRITE_FLAG( hrd->getCbrFlag( i, j, nalOrVcl ) ? 1 : 0, "cbr_flag");
     
    486446  for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++)
    487447  {
    488 #if L0323_DPB
    489448    WRITE_UVLC( pcSPS->getMaxDecPicBuffering(i) - 1,       "sps_max_dec_pic_buffering_minus1[i]" );
    490 #else
    491     WRITE_UVLC( pcSPS->getMaxDecPicBuffering(i),           "sps_max_dec_pic_buffering[i]" );
    492 #endif
    493449    WRITE_UVLC( pcSPS->getNumReorderPics(i),               "sps_num_reorder_pics[i]" );
    494     WRITE_UVLC( pcSPS->getMaxLatencyIncrease(i),           "sps_max_latency_increase[i]" );
     450    WRITE_UVLC( pcSPS->getMaxLatencyIncrease(i),           "sps_max_latency_increase_plus1[i]" );
    495451    if (!subLayerOrderingInfoPresentFlag)
    496452    {
     
    639595  WRITE_CODE( 0xffff,                              16,        "vps_reserved_ffff_16bits" );
    640596  codePTL( pcVPS->getPTL(), true, pcVPS->getMaxTLayers() - 1 );
    641 #if SIGNAL_BITRATE_PICRATE_IN_VPS
    642   codeBitratePicRateInfo(pcVPS->getBitratePicrateInfo(), 0, pcVPS->getMaxTLayers() - 1);
    643 #endif 
    644597  const Bool subLayerOrderingInfoPresentFlag = 1;
    645598  WRITE_FLAG(subLayerOrderingInfoPresentFlag,              "vps_sub_layer_ordering_info_present_flag");
    646599  for(UInt i=0; i <= pcVPS->getMaxTLayers()-1; i++)
    647600  {
    648 #if L0323_DPB
    649601    WRITE_UVLC( pcVPS->getMaxDecPicBuffering(i) - 1,       "vps_max_dec_pic_buffering_minus1[i]" );
    650 #else
    651     WRITE_UVLC( pcVPS->getMaxDecPicBuffering(i),           "vps_max_dec_pic_buffering[i]" );
    652 #endif
    653602    WRITE_UVLC( pcVPS->getNumReorderPics(i),               "vps_num_reorder_pics[i]" );
    654     WRITE_UVLC( pcVPS->getMaxLatencyIncrease(i),           "vps_max_latency_increase[i]" );
     603    WRITE_UVLC( pcVPS->getMaxLatencyIncrease(i),           "vps_max_latency_increase_plus1[i]" );
    655604    if (!subLayerOrderingInfoPresentFlag)
    656605    {
     
    693642  pcVPS->deriveLayerIdListVariables();
    694643#endif
    695 #if L0043_TIMING_INFO
    696644  TimingInfo *timingInfo = pcVPS->getTimingInfo();
    697645  WRITE_FLAG(timingInfo->getTimingInfoPresentFlag(),          "vps_timing_info_present_flag");
     
    705653      WRITE_UVLC(timingInfo->getNumTicksPocDiffOneMinus1(),   "vps_num_ticks_poc_diff_one_minus1");
    706654    }
    707 #endif
    708655    pcVPS->setNumHrdParameters( 0 );
    709656    WRITE_UVLC( pcVPS->getNumHrdParameters(),                 "vps_num_hrd_parameters" );
     
    724671      codeHrdParameters(pcVPS->getHrdParameters(i), pcVPS->getCprmsPresentFlag( i ), pcVPS->getMaxTLayers() - 1);
    725672    }
    726 #if L0043_TIMING_INFO
    727   }
    728 #endif
     673  }
    729674#if !VPS_EXTNS
    730675  WRITE_FLAG( 0,                     "vps_extension_flag" );
     
    994939     
    995940#if FIX1071
    996       // Deal with bitstream restriction stating that:
    997       // If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0.
     941      // check for bitstream restriction stating that:
     942      // If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0.
    998943      // Ideally this process should not be repeated for each slice in a picture
    999       TComReferencePictureSet altRps;
    1000       Bool useAltRps = false;
    1001944#if SVC_EXTENSION
    1002945      if( pcSlice->getLayerId() == 0 )
    1003946#endif
    1004       if (pcSlice->getRapPicFlag())
    1005       {
    1006         for (Int picIdx = 0; !useAltRps && picIdx < rps->getNumberOfPictures(); picIdx++)
    1007         {
    1008           useAltRps = rps->getUsed(picIdx);
    1009         }
    1010         if (useAltRps)
    1011         {
    1012           memcpy(&altRps, rps, sizeof(TComReferencePictureSet));
    1013           rps = &altRps;
    1014           for (Int picIdx = 0; picIdx < rps->getNumberOfPictures(); picIdx++)
    1015           {
    1016             rps->setUsed(picIdx, false);
    1017           }
    1018         }
    1019       }
    1020 
    1021       if(pcSlice->getRPSidx() < 0 || useAltRps)
    1022 #else
     947      if (pcSlice->isIRAP())
     948      {
     949        for (Int picIdx = 0; picIdx < rps->getNumberOfPictures(); picIdx++)
     950        {
     951          assert (!rps->getUsed(picIdx));
     952        }
     953      }
     954#endif
     955
    1023956      if(pcSlice->getRPSidx() < 0)
    1024 #endif
    1025957      {
    1026958        WRITE_FLAG( 0, "short_term_ref_pic_set_sps_flag");
     
    11141046        }
    11151047      }
    1116 
    11171048      if (pcSlice->getSPS()->getTMVPFlagsPresent())
    11181049      {
     
    13261257    }
    13271258  }
    1328 
    13291259  if(pcSlice->getPPS()->getSliceHeaderExtensionPresentFlag())
    13301260  {
     
    13411271  WRITE_CODE( pcPTL->getGeneralPTL()->getLevelIdc(), 8, "general_level_idc" );
    13421272
    1343 #if L0363_BYTE_ALIGN
    13441273  for (Int i = 0; i < maxNumSubLayersMinus1; i++)
    13451274  {
     
    13591288    }
    13601289  }
    1361 #endif
    13621290 
    13631291  for(Int i = 0; i < maxNumSubLayersMinus1; i++)
    13641292  {
    1365 #if !L0363_BYTE_ALIGN
    1366     if(profilePresentFlag)
    1367     {
    1368       WRITE_FLAG( pcPTL->getSubLayerProfilePresentFlag(i), "sub_layer_profile_present_flag[i]" );
    1369     }
    1370 
    1371     WRITE_FLAG( pcPTL->getSubLayerLevelPresentFlag(i),   "sub_layer_level_present_flag[i]" );
    1372 #endif
    13731293    if( profilePresentFlag && pcPTL->getSubLayerProfilePresentFlag(i) )
    13741294    {
     
    13911311  }
    13921312
    1393 #if L0046_CONSTRAINT_FLAGS
    13941313  WRITE_FLAG(ptl->getProgressiveSourceFlag(),   "general_progressive_source_flag");
    13951314  WRITE_FLAG(ptl->getInterlacedSourceFlag(),    "general_interlaced_source_flag");
     
    14001319  WRITE_CODE(0 , 16, "XXX_reserved_zero_44bits[16..31]");
    14011320  WRITE_CODE(0 , 12, "XXX_reserved_zero_44bits[32..43]");
    1402 #elif L0363_MORE_BITS
    1403   WRITE_CODE(0 , 16, "XXX_reserved_zero_48bits[0..15]");
    1404   WRITE_CODE(0 , 16, "XXX_reserved_zero_48bits[16..31]");
    1405   WRITE_CODE(0 , 16, "XXX_reserved_zero_48bits[32..47]");
    1406 #else
    1407   WRITE_CODE(0 , 16, "XXX_reserved_zero_16bits[]");
    1408 #endif
    1409 }
    1410 #if SIGNAL_BITRATE_PICRATE_IN_VPS
    1411 Void TEncCavlc::codeBitratePicRateInfo(TComBitRatePicRateInfo *info, Int tempLevelLow, Int tempLevelHigh)
    1412 {
    1413   for(Int i = tempLevelLow; i <= tempLevelHigh; i++)
    1414   {
    1415     WRITE_FLAG( info->getBitRateInfoPresentFlag(i),  "bit_rate_info_present_flag[i]" );
    1416     WRITE_FLAG( info->getPicRateInfoPresentFlag(i),  "pic_rate_info_present_flag[i]" );
    1417     if(info->getBitRateInfoPresentFlag(i))
    1418     {
    1419       WRITE_CODE( info->getAvgBitRate(i), 16, "avg_bit_rate[i]" );
    1420       WRITE_CODE( info->getMaxBitRate(i), 16, "max_bit_rate[i]" );
    1421     }
    1422     if(info->getPicRateInfoPresentFlag(i))
    1423     {
    1424       WRITE_CODE( info->getConstantPicRateIdc(i),  2, "constant_pic_rate_idc[i]" );
    1425       WRITE_CODE( info->getAvgPicRate(i),         16, "avg_pic_rate[i]"          );
    1426     }
    1427   }
    1428 }
    1429 #endif 
     1321}
     1322
    14301323/**
    14311324 - write wavefront substreams sizes for the slice header.
     
    14971390  for (UInt idx=0; idx<numEntryPointOffsets; idx++)
    14981391  {
    1499 #if L0116_ENTRY_POINT
    15001392    WRITE_CODE(entryPointOffset[ idx ]-1, offsetLenMinus1+1, "entry_point_offset_minus1");
    1501 #else
    1502     WRITE_CODE(entryPointOffset[ idx ], offsetLenMinus1+1, "entry_point_offset");
    1503 #endif
    15041393  }
    15051394
  • branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncCavlc.h

    r226 r302  
    9696  Void  codePTL                 ( TComPTL* pcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1);
    9797  Void  codeProfileTier         ( ProfileTierLevel* ptl );
    98 #if SIGNAL_BITRATE_PICRATE_IN_VPS
    99   Void codeBitratePicRateInfo(TComBitRatePicRateInfo *info, Int tempLevelLow, Int tempLevelHigh);
    100 #endif
    10198  Void  codeHrdParameters       ( TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1 );
    10299  Void  codeTilesWPPEntryPoint( TComSlice* pSlice );
  • branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncCfg.h

    r296 r302  
    116116  Level::Tier   m_levelTier;
    117117  Level::Name   m_level;
    118 #if L0046_CONSTRAINT_FLAGS
    119118  Bool m_progressiveSourceFlag;
    120119  Bool m_interlacedSourceFlag;
    121120  Bool m_nonPackedConstraintFlag;
    122121  Bool m_frameOnlyConstraintFlag;
    123 #endif
    124122
    125123  //====== Coding Structure ========
     
    169167  Int       m_loopFilterTcOffsetDiv2;
    170168  Bool      m_DeblockingFilterControlPresent;
    171 #if L0386_DB_METRIC
    172169  Bool      m_DeblockingFilterMetric;
    173 #endif
    174170  Bool      m_bUseSAO;
    175171  Int       m_maxNumOffsetsPerPic;
     
    202198  Bool      m_bUseASR;
    203199  Bool      m_bUseHADME;
    204 #if !L0034_COMBINED_LIST_CLEANUP
    205   Bool      m_bUseLComb;
    206 #endif
    207200  Bool      m_useRDOQ;
    208201  Bool      m_useRDOQTS;
    209 #if L0232_RD_PENALTY
    210202  UInt      m_rdPenalty;
    211 #endif
    212203  Bool      m_bUseFastEnc;
    213204  Bool      m_bUseEarlyCU;
     
    253244  Int       m_pictureTimingSEIEnabled;
    254245  Int       m_recoveryPointSEIEnabled;
    255 #if J0149_TONE_MAPPING_SEI
    256246  Bool      m_toneMappingInfoSEIEnabled;
    257247  Int       m_toneMapId;
     
    279269  Int*      m_codedPivotValue;
    280270  Int*      m_targetPivotValue;
    281 #endif
    282271  Int       m_framePackingSEIEnabled;
    283272  Int       m_framePackingSEIType;
     
    292281  Int       m_layersPresentSEIEnabled;
    293282#endif
    294 #if L0208_SOP_DESCRIPTION_SEI
    295283  Int       m_SOPDescriptionSEIEnabled;
    296 #endif
    297 #if K0180_SCALABLE_NESTING_SEI
    298284  Int       m_scalableNestingSEIEnabled;
    299 #endif
    300285  //====== Weighted Prediction ========
    301286  Bool      m_useWeightedPred;       //< Use of Weighting Prediction (P_SLICE)
     
    310295  Bool      m_RCEnableRateControl;
    311296  Int       m_RCTargetBitrate;
     297#if M0036_RC_IMPROVEMENT
     298  Int       m_RCKeepHierarchicalBit;
     299#else
    312300  Bool      m_RCKeepHierarchicalBit;
     301#endif
    313302  Bool      m_RCLCULevelRC;
    314303  Bool      m_RCUseLCUSeparateModel;
     
    463452  Void      setLoopFilterTcOffset           ( Int   i )      { m_loopFilterTcOffsetDiv2    = i; }
    464453  Void      setDeblockingFilterControlPresent ( Bool b ) { m_DeblockingFilterControlPresent = b; }
    465 #if L0386_DB_METRIC
    466454  Void      setDeblockingFilterMetric       ( Bool  b )      { m_DeblockingFilterMetric = b; }
    467 #endif
    468455
    469456  //====== Motion search ========
     
    520507  Int       getLoopFilterTcOffset           ()      { return m_loopFilterTcOffsetDiv2; }
    521508  Bool      getDeblockingFilterControlPresent()  { return  m_DeblockingFilterControlPresent; }
    522 #if L0386_DB_METRIC
    523509  Bool      getDeblockingFilterMetric       ()      { return m_DeblockingFilterMetric; }
    524 #endif
    525510
    526511  //==== Motion search ========
     
    540525  Void      setUseASR                       ( Bool  b )     { m_bUseASR     = b; }
    541526  Void      setUseHADME                     ( Bool  b )     { m_bUseHADME   = b; }
    542 #if !L0034_COMBINED_LIST_CLEANUP
    543   Void      setUseLComb                     ( Bool  b )     { m_bUseLComb   = b; }
    544 #endif
    545527  Void      setUseRDOQ                      ( Bool  b )     { m_useRDOQ    = b; }
    546528  Void      setUseRDOQTS                    ( Bool  b )     { m_useRDOQTS  = b; }
    547 #if L0232_RD_PENALTY
    548529  Void      setRDpenalty                 ( UInt  b )     { m_rdPenalty  = b; }
    549 #endif
    550530  Void      setUseFastEnc                   ( Bool  b )     { m_bUseFastEnc = b; }
    551531  Void      setUseEarlyCU                   ( Bool  b )     { m_bUseEarlyCU = b; }
     
    567547  Bool      getUseASR                       ()      { return m_bUseASR;     }
    568548  Bool      getUseHADME                     ()      { return m_bUseHADME;   }
    569 #if !L0034_COMBINED_LIST_CLEANUP
    570   Bool      getUseLComb                     ()      { return m_bUseLComb;   }
    571 #endif
    572549  Bool      getUseRDOQ                      ()      { return m_useRDOQ;    }
    573550  Bool      getUseRDOQTS                    ()      { return m_useRDOQTS;  }
    574 #if L0232_RD_PENALTY
    575551  Int      getRDpenalty                  ()      { return m_rdPenalty;  }
    576 #endif
    577552  Bool      getUseFastEnc                   ()      { return m_bUseFastEnc; }
    578553  Bool      getUseEarlyCU                   ()      { return m_bUseEarlyCU; }
     
    669644  Void  setRecoveryPointSEIEnabled(Int b)                { m_recoveryPointSEIEnabled = b; }
    670645  Int   getRecoveryPointSEIEnabled()                     { return m_recoveryPointSEIEnabled; }
    671 #if J0149_TONE_MAPPING_SEI
    672646  Void  setToneMappingInfoSEIEnabled(Bool b)                 {  m_toneMappingInfoSEIEnabled = b;  }
    673647  Bool  getToneMappingInfoSEIEnabled()                       {  return m_toneMappingInfoSEIEnabled;  }
     
    720694  Void  setTMISEIExtendedWhiteLevelLumaCodeValue(Int b)      {  m_extendedWhiteLevelLumaCodeValue =b;  }
    721695  Int   getTMISEIExtendedWhiteLevelLumaCodeValue()           {  return m_extendedWhiteLevelLumaCodeValue;  }
    722 #endif
    723696  Void  setFramePackingArrangementSEIEnabled(Int b)      { m_framePackingSEIEnabled = b; }
    724697  Int   getFramePackingArrangementSEIEnabled()           { return m_framePackingSEIEnabled; }
     
    743716  Int   getLayersPresentSEIEnabled()                     { return m_layersPresentSEIEnabled; }
    744717#endif
    745 #if L0208_SOP_DESCRIPTION_SEI
    746718  Void  setSOPDescriptionSEIEnabled(Int b)                { m_SOPDescriptionSEIEnabled = b; }
    747719  Int   getSOPDescriptionSEIEnabled()                     { return m_SOPDescriptionSEIEnabled; }
    748 #endif
    749 #if K0180_SCALABLE_NESTING_SEI
    750720  Void  setScalableNestingSEIEnabled(Int b)                { m_scalableNestingSEIEnabled = b; }
    751721  Int   getScalableNestingSEIEnabled()                     { return m_scalableNestingSEIEnabled; }
    752 #endif
    753722  Void      setUseWP               ( Bool b )    { m_useWeightedPred   = b;    }
    754723  Void      setWPBiPred            ( Bool b )    { m_useWeightedBiPred = b;    }
     
    772741  Int       getTargetBitrate       ()              { return m_RCTargetBitrate;       }
    773742  Void      setTargetBitrate       ( Int bitrate ) { m_RCTargetBitrate  = bitrate;   }
     743#if M0036_RC_IMPROVEMENT
     744  Int       getKeepHierBit         ()              { return m_RCKeepHierarchicalBit; }
     745  Void      setKeepHierBit         ( Int i )       { m_RCKeepHierarchicalBit = i;    }
     746#else
    774747  Bool      getKeepHierBit         ()              { return m_RCKeepHierarchicalBit; }
    775748  Void      setKeepHierBit         ( Bool b )      { m_RCKeepHierarchicalBit = b;    }
     749#endif
    776750  Bool      getLCULevelRC          ()              { return m_RCLCULevelRC; }
    777751  Void      setLCULevelRC          ( Bool b )      { m_RCLCULevelRC = b; }
     
    865839  Void      setLog2MaxMvLengthVertical(Int i)             { m_log2MaxMvLengthVertical = i; }
    866840 
    867 #if L0046_CONSTRAINT_FLAGS
    868841  Bool getProgressiveSourceFlag() const { return m_progressiveSourceFlag; }
    869842  Void setProgressiveSourceFlag(Bool b) { m_progressiveSourceFlag = b; }
     
    877850  Bool getFrameOnlyConstraintFlag() const { return m_frameOnlyConstraintFlag; }
    878851  Void setFrameOnlyConstraintFlag(Bool b) { m_frameOnlyConstraintFlag = b; }
    879 #endif
    880852
    881853#if SVC_EXTENSION
  • branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncCu.cpp

    r297 r302  
    9595 
    9696  m_bEncodeDQP = false;
    97 #if RATE_CONTROL_LAMBDA_DOMAIN
     97#if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT
    9898  m_LCUPredictionSAD = 0;
    9999  m_addSADDepth      = 0;
     
    108108  // initialize conversion matrix from partition index to pel
    109109  initRasterToPelXY( uiMaxWidth, uiMaxHeight, m_uhTotalDepth );
    110 
    111110}
    112111
     
    245244  m_ppcTempCU[0]->initCU( rpcCU->getPic(), rpcCU->getAddr() );
    246245
    247 #if RATE_CONTROL_LAMBDA_DOMAIN
     246#if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT
    248247  m_addSADDepth      = 0;
    249248  m_LCUPredictionSAD = 0;
     
    548547    }
    549548
    550 #if RATE_CONTROL_LAMBDA_DOMAIN
     549#if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT
    551550    if ( uiDepth <= m_addSADDepth )
    552551    {
     
    822821  {
    823822    bBoundary = true;
    824 #if RATE_CONTROL_LAMBDA_DOMAIN
     823#if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT
    825824    m_addSADDepth++;
    826825#endif
     
    12521251}
    12531252
     1253#if RATE_CONTROL_INTRA
     1254Int xCalcHADs8x8_ISlice(Pel *piOrg, Int iStrideOrg)
     1255{
     1256  Int k, i, j, jj;
     1257  Int diff[64], m1[8][8], m2[8][8], m3[8][8], iSumHad = 0;
     1258
     1259  for( k = 0; k < 64; k += 8 )
     1260  {
     1261    diff[k+0] = piOrg[0] ;
     1262    diff[k+1] = piOrg[1] ;
     1263    diff[k+2] = piOrg[2] ;
     1264    diff[k+3] = piOrg[3] ;
     1265    diff[k+4] = piOrg[4] ;
     1266    diff[k+5] = piOrg[5] ;
     1267    diff[k+6] = piOrg[6] ;
     1268    diff[k+7] = piOrg[7] ;
     1269 
     1270    piOrg += iStrideOrg;
     1271  }
     1272 
     1273  //horizontal
     1274  for (j=0; j < 8; j++)
     1275  {
     1276    jj = j << 3;
     1277    m2[j][0] = diff[jj  ] + diff[jj+4];
     1278    m2[j][1] = diff[jj+1] + diff[jj+5];
     1279    m2[j][2] = diff[jj+2] + diff[jj+6];
     1280    m2[j][3] = diff[jj+3] + diff[jj+7];
     1281    m2[j][4] = diff[jj  ] - diff[jj+4];
     1282    m2[j][5] = diff[jj+1] - diff[jj+5];
     1283    m2[j][6] = diff[jj+2] - diff[jj+6];
     1284    m2[j][7] = diff[jj+3] - diff[jj+7];
     1285   
     1286    m1[j][0] = m2[j][0] + m2[j][2];
     1287    m1[j][1] = m2[j][1] + m2[j][3];
     1288    m1[j][2] = m2[j][0] - m2[j][2];
     1289    m1[j][3] = m2[j][1] - m2[j][3];
     1290    m1[j][4] = m2[j][4] + m2[j][6];
     1291    m1[j][5] = m2[j][5] + m2[j][7];
     1292    m1[j][6] = m2[j][4] - m2[j][6];
     1293    m1[j][7] = m2[j][5] - m2[j][7];
     1294   
     1295    m2[j][0] = m1[j][0] + m1[j][1];
     1296    m2[j][1] = m1[j][0] - m1[j][1];
     1297    m2[j][2] = m1[j][2] + m1[j][3];
     1298    m2[j][3] = m1[j][2] - m1[j][3];
     1299    m2[j][4] = m1[j][4] + m1[j][5];
     1300    m2[j][5] = m1[j][4] - m1[j][5];
     1301    m2[j][6] = m1[j][6] + m1[j][7];
     1302    m2[j][7] = m1[j][6] - m1[j][7];
     1303  }
     1304 
     1305  //vertical
     1306  for (i=0; i < 8; i++)
     1307  {
     1308    m3[0][i] = m2[0][i] + m2[4][i];
     1309    m3[1][i] = m2[1][i] + m2[5][i];
     1310    m3[2][i] = m2[2][i] + m2[6][i];
     1311    m3[3][i] = m2[3][i] + m2[7][i];
     1312    m3[4][i] = m2[0][i] - m2[4][i];
     1313    m3[5][i] = m2[1][i] - m2[5][i];
     1314    m3[6][i] = m2[2][i] - m2[6][i];
     1315    m3[7][i] = m2[3][i] - m2[7][i];
     1316   
     1317    m1[0][i] = m3[0][i] + m3[2][i];
     1318    m1[1][i] = m3[1][i] + m3[3][i];
     1319    m1[2][i] = m3[0][i] - m3[2][i];
     1320    m1[3][i] = m3[1][i] - m3[3][i];
     1321    m1[4][i] = m3[4][i] + m3[6][i];
     1322    m1[5][i] = m3[5][i] + m3[7][i];
     1323    m1[6][i] = m3[4][i] - m3[6][i];
     1324    m1[7][i] = m3[5][i] - m3[7][i];
     1325   
     1326    m2[0][i] = m1[0][i] + m1[1][i];
     1327    m2[1][i] = m1[0][i] - m1[1][i];
     1328    m2[2][i] = m1[2][i] + m1[3][i];
     1329    m2[3][i] = m1[2][i] - m1[3][i];
     1330    m2[4][i] = m1[4][i] + m1[5][i];
     1331    m2[5][i] = m1[4][i] - m1[5][i];
     1332    m2[6][i] = m1[6][i] + m1[7][i];
     1333    m2[7][i] = m1[6][i] - m1[7][i];
     1334  }
     1335 
     1336  for (i = 0; i < 8; i++)
     1337  {
     1338    for (j = 0; j < 8; j++)
     1339    {
     1340      iSumHad += abs(m2[i][j]);
     1341    }
     1342  }
     1343  iSumHad -= abs(m2[0][0]);
     1344  iSumHad =(iSumHad+2)>>2;
     1345  return(iSumHad);
     1346}
     1347
     1348Int  TEncCu::updateLCUDataISlice(TComDataCU* pcCU, Int LCUIdx, Int width, Int height)
     1349{
     1350  Int  xBl, yBl;
     1351  const Int iBlkSize = 8;
     1352
     1353  Pel* pOrgInit   = pcCU->getPic()->getPicYuvOrg()->getLumaAddr(pcCU->getAddr(), 0);
     1354  Int  iStrideOrig = pcCU->getPic()->getPicYuvOrg()->getStride();
     1355  Pel  *pOrg;
     1356
     1357  Int iSumHad = 0;
     1358  for ( yBl=0; (yBl+iBlkSize)<=height; yBl+= iBlkSize)
     1359  {
     1360    for ( xBl=0; (xBl+iBlkSize)<=width; xBl+= iBlkSize)
     1361    {
     1362      pOrg = pOrgInit + iStrideOrig*yBl + xBl;
     1363      iSumHad += xCalcHADs8x8_ISlice(pOrg, iStrideOrig);
     1364    }
     1365  }
     1366  return(iSumHad);
     1367}
     1368#endif
     1369
    12541370/** check RD costs for a CU block encoded with merge
    12551371 * \param rpcBestCU
     
    12601376{
    12611377  assert( rpcTempCU->getSlice()->getSliceType() != I_SLICE );
    1262   TComMvField  cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
     1378  TComMvField  cMvFieldNeighbours[ 2 * MRG_MAX_NUM_CANDS ]; // double length for mv of both lists
    12631379  UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
    12641380  Int numValidMergeCand = 0;
     
    12741390
    12751391  Int mergeCandBuffer[MRG_MAX_NUM_CANDS];
    1276   for( UInt ui = 0; ui < rpcTempCU->getSlice()->getMaxNumMergeCand(); ++ui )
     1392  for( UInt ui = 0; ui < numValidMergeCand; ++ui )
    12771393  {
    12781394    mergeCandBuffer[ui] = 0;
     
    13001416      {
    13011417#endif
    1302         if(!(uiNoResidual==1 && mergeCandBuffer[uiMergeCand]==1))
    1303         {
    1304 
     1418      if(!(uiNoResidual==1 && mergeCandBuffer[uiMergeCand]==1))
     1419      {
    13051420        if( !(bestIsSkip && uiNoResidual == 0) )
    13061421        {
     
    13141429          rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
    13151430          rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
    1316 
    1317        // do MC
    1318        m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] );
    1319        // estimate residual and encode everything
    1320        m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU,
    1321          m_ppcOrigYuv    [uhDepth],
    1322          m_ppcPredYuvTemp[uhDepth],
    1323          m_ppcResiYuvTemp[uhDepth],
    1324          m_ppcResiYuvBest[uhDepth],
    1325          m_ppcRecoYuvTemp[uhDepth],
    1326          (uiNoResidual? true:false));
    1327 
    1328 
    1329        if(uiNoResidual==0)
    1330        {
    1331          if(rpcTempCU->getQtRootCbf(0) == 0)
    1332          {
    1333            mergeCandBuffer[uiMergeCand] = 1;
    1334          }
    1335        }
    1336 
    1337        rpcTempCU->setSkipFlagSubParts( rpcTempCU->getQtRootCbf(0) == 0, 0, uhDepth );
     1431         
     1432          // do MC
     1433          m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] );
     1434          // estimate residual and encode everything
     1435          m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU,
     1436                                                    m_ppcOrigYuv    [uhDepth],
     1437                                                    m_ppcPredYuvTemp[uhDepth],
     1438                                                    m_ppcResiYuvTemp[uhDepth],
     1439                                                    m_ppcResiYuvBest[uhDepth],
     1440                                                    m_ppcRecoYuvTemp[uhDepth],
     1441                                                    (uiNoResidual? true:false));
     1442         
     1443         
     1444          if ( uiNoResidual == 0 && rpcTempCU->getQtRootCbf(0) == 0 )
     1445          {
     1446            // If no residual when allowing for one, then set mark to not try case where residual is forced to 0
     1447            mergeCandBuffer[uiMergeCand] = 1;
     1448          }
     1449         
     1450          rpcTempCU->setSkipFlagSubParts( rpcTempCU->getQtRootCbf(0) == 0, 0, uhDepth );
    13381451          Int orgQP = rpcTempCU->getQP( 0 );
    13391452          xCheckDQP( rpcTempCU );
    13401453          xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth);
    13411454          rpcTempCU->initEstData( uhDepth, orgQP );
    1342 
    1343 
    1344       if( m_pcEncCfg->getUseFastDecisionForMerge() && !bestIsSkip )
    1345       {
    1346         bestIsSkip = rpcBestCU->getQtRootCbf(0) == 0;
    1347       }
    1348 
    1349     }
    1350     }
     1455         
     1456          if( m_pcEncCfg->getUseFastDecisionForMerge() && !bestIsSkip )
     1457          {
     1458            bestIsSkip = rpcBestCU->getQtRootCbf(0) == 0;
     1459          }
     1460        }
    13511461#if REF_IDX_ME_ZEROMV
    1352    }
    1353 #endif
     1462        }
     1463#endif
     1464      }
    13541465  }
    13551466
     
    14171528#endif
    14181529
    1419 #if RATE_CONTROL_LAMBDA_DOMAIN
     1530#if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT
    14201531  if ( m_pcEncCfg->getUseRateCtrl() && m_pcEncCfg->getLCULevelRC() && ePartSize == SIZE_2Nx2N && uhDepth <= m_addSADDepth )
    14211532  {
  • branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncCu.h

    r282 r302  
    106106  Bool                    m_bUseSBACRD;
    107107  TEncRateCtrl*           m_pcRateCtrl;
    108 #if RATE_CONTROL_LAMBDA_DOMAIN
     108#if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT
    109109  UInt                    m_LCUPredictionSAD;
    110110  Int                     m_addSADDepth;
     
    128128 
    129129  Void setBitCounter        ( TComBitCounter* pcBitCounter ) { m_pcBitCounter = pcBitCounter; }
    130 #if RATE_CONTROL_LAMBDA_DOMAIN
     130#if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT
    131131  UInt getLCUPredictionSAD() { return m_LCUPredictionSAD; }
     132#endif
     133#if RATE_CONTROL_INTRA
     134  Int   updateLCUDataISlice ( TComDataCU* pcCU, Int LCUIdx, Int width, Int height );
    132135#endif
    133136#if INTRA_BL
  • branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncGOP.cpp

    r297 r302  
    9494  m_cpbRemovalDelay   = 0;
    9595  m_lastBPSEI         = 0;
    96 #if L0045_NON_NESTED_SEI_RESTRICTIONS
    9796  xResetNonNestedSEIPresentFlags();
    98 #if K0180_SCALABLE_NESTING_SEI
    9997  xResetNestedSEIPresentFlags();
    100 #endif
    101 #endif
    10298#if SVC_UPSAMPLING
    10399  m_pcPredSearch        = NULL;
     
    163159  SEIActiveParameterSets *seiActiveParameterSets = new SEIActiveParameterSets();
    164160  seiActiveParameterSets->activeVPSId = m_pcCfg->getVPS()->getVPSId();
    165 #if L0047_APS_FLAGS
    166161  seiActiveParameterSets->m_fullRandomAccessFlag = false;
    167162  seiActiveParameterSets->m_noParamSetUpdateFlag = false;
    168 #endif
    169163  seiActiveParameterSets->numSpsIdsMinus1 = 0;
    170164  seiActiveParameterSets->activeSeqParamSetId.resize(seiActiveParameterSets->numSpsIdsMinus1 + 1);
     
    198192  seiFramePacking->m_arrangementCancelFlag = 0;
    199193  seiFramePacking->m_arrangementType = m_pcCfg->getFramePackingArrangementSEIType();
    200 #if L0444_FPA_TYPE
    201194  assert((seiFramePacking->m_arrangementType > 2) && (seiFramePacking->m_arrangementType < 6) );
    202 #endif
    203195  seiFramePacking->m_quincunxSamplingFlag = m_pcCfg->getFramePackingArrangementSEIQuincunx();
    204196  seiFramePacking->m_contentInterpretationType = m_pcCfg->getFramePackingArrangementSEIInterpretation();
     
    214206  seiFramePacking->m_frame1GridPositionY = 0;
    215207  seiFramePacking->m_arrangementReservedByte = 0;
    216 #if L0045_PERSISTENCE_FLAGS
    217208  seiFramePacking->m_arrangementPersistenceFlag = true;
    218 #else
    219   seiFramePacking->m_arrangementRepetetionPeriod = 1;
    220 #endif
    221209  seiFramePacking->m_upsampledAspectRatio = 0;
    222210  return seiFramePacking;
     
    233221}
    234222
    235 #if J0149_TONE_MAPPING_SEI
    236223SEIToneMappingInfo*  TEncGOP::xCreateSEIToneMappingInfo()
    237224{
     
    244231  assert(seiToneMappingInfo->m_codedDataBitDepth >= 8 && seiToneMappingInfo->m_codedDataBitDepth <= 14);
    245232  seiToneMappingInfo->m_targetBitDepth = m_pcCfg->getTMISEITargetBitDepth();
    246   assert( (seiToneMappingInfo->m_targetBitDepth >= 1 && seiToneMappingInfo->m_targetBitDepth <= 17) || (seiToneMappingInfo->m_targetBitDepth  == 255) );
     233  assert( seiToneMappingInfo->m_targetBitDepth >= 1 && seiToneMappingInfo->m_targetBitDepth <= 17 );
    247234  seiToneMappingInfo->m_modelId = m_pcCfg->getTMISEIModelID();
    248235  assert(seiToneMappingInfo->m_modelId >=0 &&seiToneMappingInfo->m_modelId<=4);
     
    319306  return seiToneMappingInfo;
    320307}
    321 #endif
     308
    322309Void TEncGOP::xCreateLeadingSEIMessages (/*SEIMessages seiMessages,*/ AccessUnit &accessUnit, TComSPS *sps)
    323310{
     
    334321    accessUnit.push_back(new NALUnitEBSP(nalu));
    335322    delete sei;
    336 #if L0045_NON_NESTED_SEI_RESTRICTIONS
    337323    m_activeParameterSetSEIPresentInAU = true;
    338 #endif
    339324  }
    340325
     
    373358    delete sei;
    374359  }
    375 #if J0149_TONE_MAPPING_SEI
    376360  if(m_pcCfg->getToneMappingInfoSEIEnabled())
    377361  {
     
    385369    delete sei;
    386370  }
    387 #endif
    388371}
    389372
     
    411394  m_iNumPicCoded = 0;
    412395  SEIPictureTiming pictureTimingSEI;
    413 #if L0208_SOP_DESCRIPTION_SEI
    414396  Bool writeSOP = m_pcCfg->getSOPDescriptionSEIEnabled();
    415 #endif
    416 #if K0180_SCALABLE_NESTING_SEI
    417397  // Initialize Scalable Nesting SEI with single layer values
    418398  SEIScalableNesting scalableNestingSEI;
     
    425405  scalableNestingSEI.m_nestingLayerId[0]             = 0;
    426406  scalableNestingSEI.m_callerOwnsSEIs                = true;
    427 #endif
    428 #if L0044_DU_DPB_OUTPUT_DELAY_HRD
    429407  Int picSptDpbOutputDuDelay = 0;
    430 #endif
    431408  UInt *accumBitsDU = NULL;
    432409  UInt *accumNalsDU = NULL;
     
    706683    pcSlice->getRPS()->setNumberOfLongtermPictures(0);
    707684
     685#if FIX1071
     686    if ((pcSlice->checkThatAllRefPicsAreAvailable(rcListPic, pcSlice->getRPS(), false) != 0) || (pcSlice->isIRAP()))
     687    {
     688      pcSlice->createExplicitReferencePictureSetFromReference(rcListPic, pcSlice->getRPS(), pcSlice->isIRAP());
     689    }
     690#else
    708691    if(pcSlice->checkThatAllRefPicsAreAvailable(rcListPic, pcSlice->getRPS(), false) != 0)
    709692    {
    710693      pcSlice->createExplicitReferencePictureSetFromReference(rcListPic, pcSlice->getRPS());
    711694    }
     695#endif
    712696    pcSlice->applyReferencePictureSet(rcListPic, pcSlice->getRPS());
    713697
     
    921905      pcSlice->setSliceType ( P_SLICE );
    922906    }
    923 #if !L0034_COMBINED_LIST_CLEANUP
    924     if (pcSlice->getSliceType() != B_SLICE || !pcSlice->getSPS()->getUseLComb())
    925     {
    926       pcSlice->setNumRefIdx(REF_PIC_LIST_C, 0);
    927       pcSlice->setRefPicListCombinationFlag(false);
    928       pcSlice->setRefPicListModificationFlagLC(false);
    929     }
    930     else
    931     {
    932       pcSlice->setRefPicListCombinationFlag(pcSlice->getSPS()->getUseLComb());
    933       pcSlice->setNumRefIdx(REF_PIC_LIST_C, pcSlice->getNumRefIdx(REF_PIC_LIST_0));
    934     }
    935 #endif
    936907
    937908#if M0457_IL_SAMPLE_PRED_ONLY_FLAG
     
    975946    pcSlice->setRefPOCList();
    976947
    977 #if L0034_COMBINED_LIST_CLEANUP
    978948    pcSlice->setList1IdxToList0Idx();
    979 #else
    980     pcSlice->setNoBackPredFlag( false );
    981     if ( pcSlice->getSliceType() == B_SLICE && !pcSlice->getRefPicListCombinationFlag())
    982     {
    983       if ( pcSlice->getNumRefIdx(RefPicList( 0 ) ) == pcSlice->getNumRefIdx(RefPicList( 1 ) ) )
    984       {
    985         pcSlice->setNoBackPredFlag( true );
    986         Int i;
    987         for ( i=0; i < pcSlice->getNumRefIdx(RefPicList( 1 ) ); i++ )
    988         {
    989           if ( pcSlice->getRefPOC(RefPicList(1), i) != pcSlice->getRefPOC(RefPicList(0), i) )
    990           {
    991             pcSlice->setNoBackPredFlag( false );
    992             break;
    993           }
    994         }
    995       }
    996     }
    997 
    998     if(pcSlice->getNoBackPredFlag())
    999     {
    1000       pcSlice->setNumRefIdx(REF_PIC_LIST_C, 0);
    1001     }
    1002     pcSlice->generateCombinedList();
    1003 #endif
    1004949
    1005950    if (m_pcEncTop->getTMVPModeId() == 2)
     
    10681013
    10691014#if RATE_CONTROL_LAMBDA_DOMAIN
    1070     Int sliceQP              = pcSlice->getSliceQp();
    10711015    Double lambda            = 0.0;
    10721016    Int actualHeadBits       = 0;
     
    10841028      estimatedBits = m_pcRateCtrl->getRCPic()->getTargetBits();
    10851029
     1030      Int sliceQP = m_pcCfg->getInitialQP();
    10861031      if ( ( pcSlice->getPOC() == 0 && m_pcCfg->getInitialQP() > 0 ) || ( frameLevel == 0 && m_pcCfg->getForceIntraQP() ) ) // QP is specified
    10871032      {
    1088         sliceQP              = m_pcCfg->getInitialQP();
    10891033        Int    NumberBFrames = ( m_pcCfg->getGOPSize() - 1 );
    10901034        Double dLambda_scale = 1.0 - Clip3( 0.0, 0.5, 0.05*(Double)NumberBFrames );
     
    10971041      else if ( frameLevel == 0 )   // intra case, but use the model
    10981042      {
     1043#if RATE_CONTROL_INTRA
     1044        m_pcSliceEncoder->calCostSliceI(pcPic);
     1045#endif
    10991046        if ( m_pcCfg->getIntraPeriod() != 1 )   // do not refine allocated bits for all intra case
    11001047        {
    11011048          Int bits = m_pcRateCtrl->getRCSeq()->getLeftAverageBits();
     1049#if RATE_CONTROL_INTRA
     1050          bits = m_pcRateCtrl->getRCPic()->getRefineBitsForIntra( bits );
     1051#else
    11021052          bits = m_pcRateCtrl->getRCSeq()->getRefineBitsForIntra( bits );
     1053#endif
    11031054          if ( bits < 200 )
    11041055          {
     
    11091060
    11101061        list<TEncRCPic*> listPreviousPicture = m_pcRateCtrl->getPicList();
     1062#if RATE_CONTROL_INTRA
     1063        m_pcRateCtrl->getRCPic()->getLCUInitTargetBits();
     1064        lambda  = m_pcRateCtrl->getRCPic()->estimatePicLambda( listPreviousPicture, pcSlice->getSliceType());
     1065#else
    11111066        lambda  = m_pcRateCtrl->getRCPic()->estimatePicLambda( listPreviousPicture );
     1067#endif
    11121068        sliceQP = m_pcRateCtrl->getRCPic()->estimatePicQP( lambda, listPreviousPicture );
    11131069      }
     
    11151071      {
    11161072        list<TEncRCPic*> listPreviousPicture = m_pcRateCtrl->getPicList();
     1073#if RATE_CONTROL_INTRA
     1074        lambda  = m_pcRateCtrl->getRCPic()->estimatePicLambda( listPreviousPicture, pcSlice->getSliceType());
     1075#else
    11171076        lambda  = m_pcRateCtrl->getRCPic()->estimatePicLambda( listPreviousPicture );
     1077#endif
    11181078        sliceQP = m_pcRateCtrl->getRCPic()->estimatePicQP( lambda, listPreviousPicture );
    11191079      }
     
    13241284    Bool bLFCrossTileBoundary = pcSlice->getPPS()->getLoopFilterAcrossTilesEnabledFlag();
    13251285    m_pcLoopFilter->setCfg(bLFCrossTileBoundary);
    1326 #if L0386_DB_METRIC
    13271286    if ( m_pcCfg->getDeblockingFilterMetric() )
    13281287    {
    13291288      dblMetric(pcPic, uiNumSlices);
    13301289    }
    1331 #endif
    13321290    m_pcLoopFilter->loopFilterPic( pcPic );
    13331291
     
    14001358        UInt maxCU = m_pcCfg->getSliceArgument() >> ( pcSlice->getSPS()->getMaxCUDepth() << 1);
    14011359        UInt numDU = ( m_pcCfg->getSliceMode() == 1 ) ? ( pcPic->getNumCUsInFrame() / maxCU ) : ( 0 );
    1402         if( pcPic->getNumCUsInFrame() % maxCU != 0 )
     1360        if( pcPic->getNumCUsInFrame() % maxCU != 0 || numDU == 0 )
    14031361        {
    14041362          numDU ++;
     
    14361394    }
    14371395
    1438 #if L0208_SOP_DESCRIPTION_SEI
    14391396    if (writeSOP) // write SOP description SEI (if enabled) at the beginning of GOP
    14401397    {
     
    14741431      writeSOP = false;
    14751432    }
    1476 #endif
    14771433
    14781434    if( ( m_pcCfg->getPictureTimingSEIEnabled() || m_pcCfg->getDecodingUnitInfoSEIEnabled() ) &&
     
    15061462      pictureTimingSEI.m_auCpbRemovalDelay = std::max<Int>(1, m_totalCoded - m_lastBPSEI); // Syntax element signalled as minus, hence the .
    15071463      pictureTimingSEI.m_picDpbOutputDelay = pcSlice->getSPS()->getNumReorderPics(0) + pcSlice->getPOC() - m_totalCoded;
    1508 #if L0044_DU_DPB_OUTPUT_DELAY_HRD
    15091464      Int factor = pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getTickDivisorMinus2() + 2;
    15101465      pictureTimingSEI.m_picDpbOutputDuDelay = factor * pictureTimingSEI.m_picDpbOutputDelay;
     
    15131468        picSptDpbOutputDuDelay = factor * pictureTimingSEI.m_picDpbOutputDelay;
    15141469      }
    1515 #endif
    15161470    }
    15171471
     
    15331487      sei_buffering_period.m_initialCpbRemovalDelayOffset[0][1]     = uiInitialCpbRemovalDelay;
    15341488
    1535 #if L0043_TIMING_INFO
    15361489      Double dTmp = (Double)pcSlice->getSPS()->getVuiParameters()->getTimingInfo()->getNumUnitsInTick() / (Double)pcSlice->getSPS()->getVuiParameters()->getTimingInfo()->getTimeScale();
    1537 #else
    1538       Double dTmp = (Double)pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getNumUnitsInTick() / (Double)pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getTimeScale();
    1539 #endif
    15401490
    15411491      UInt uiTmp = (UInt)( dTmp * 90000.0 );
     
    15481498
    15491499      sei_buffering_period.m_rapCpbParamsPresentFlag              = 0;
    1550 #if L0328_SPLICING
    15511500      //for the concatenation, it can be set to one during splicing.
    15521501      sei_buffering_period.m_concatenationFlag = 0;
    15531502      //since the temporal layer HRD is not ready, we assumed it is fixed
    15541503      sei_buffering_period.m_auCpbRemovalDelayDelta = 1;
    1555 #endif
    1556 #if L0044_CPB_DPB_DELAY_OFFSET
    15571504      sei_buffering_period.m_cpbDelayOffset = 0;
    15581505      sei_buffering_period.m_dpbDelayOffset = 0;
    1559 #endif
    15601506
    15611507      m_seiWriter.writeSEImessage( nalu.m_Bitstream, sei_buffering_period, pcSlice->getSPS());
    15621508      writeRBSPTrailingBits(nalu.m_Bitstream);
    1563 #if L0045_NON_NESTED_SEI_RESTRICTIONS
    15641509      {
    15651510      UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit);
     
    15731518      m_bufferingPeriodSEIPresentInAU = true;
    15741519      }
    1575 #else
    1576       accessUnit.push_back(new NALUnitEBSP(nalu));
    1577 #endif
    1578 
    1579 #if K0180_SCALABLE_NESTING_SEI
     1520
    15801521      if (m_pcCfg->getScalableNestingSEIEnabled())
    15811522      {
     
    15871528        m_seiWriter.writeSEImessage( naluTmp.m_Bitstream, scalableNestingSEI, pcSlice->getSPS());
    15881529        writeRBSPTrailingBits(naluTmp.m_Bitstream);
    1589 #if L0045_NON_NESTED_SEI_RESTRICTIONS
    15901530        UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit);
    15911531        UInt offsetPosition = m_activeParameterSetSEIPresentInAU + m_bufferingPeriodSEIPresentInAU + m_pictureTimingSEIPresentInAU;   // Insert BP SEI after non-nested APS, BP and PT SEIs
     
    15971537        accessUnit.insert(it, new NALUnitEBSP(naluTmp));
    15981538        m_nestedBufferingPeriodSEIPresentInAU = true;
    1599 #else
    1600         accessUnit.push_back(new NALUnitEBSP(naluTmp));
    1601 #endif
    1602       }
    1603 #endif
     1539      }
    16041540
    16051541      m_lastBPSEI = m_totalCoded;
     
    20652001      if ( m_pcCfg->getUseRateCtrl() )
    20662002      {
     2003#if !M0036_RC_IMPROVEMENT
    20672004        Double effectivePercentage = m_pcRateCtrl->getRCPic()->getEffectivePercentage();
     2005#endif
    20682006        Double avgQP     = m_pcRateCtrl->getRCPic()->calAverageQP();
    20692007        Double avgLambda = m_pcRateCtrl->getRCPic()->calAverageLambda();
     
    20722010          avgLambda = lambda;
    20732011        }
     2012#if M0036_RC_IMPROVEMENT
     2013#if RATE_CONTROL_INTRA
     2014        m_pcRateCtrl->getRCPic()->updateAfterPicture( actualHeadBits, actualTotalBits, avgQP, avgLambda, pcSlice->getSliceType());
     2015#else
     2016        m_pcRateCtrl->getRCPic()->updateAfterPicture( actualHeadBits, actualTotalBits, avgQP, avgLambda );
     2017#endif
     2018#else
    20742019        m_pcRateCtrl->getRCPic()->updateAfterPicture( actualHeadBits, actualTotalBits, avgQP, avgLambda, effectivePercentage );
     2020#endif
    20752021        m_pcRateCtrl->getRCPic()->addToPictureLsit( m_pcRateCtrl->getPicList() );
    20762022
     
    20922038      }
    20932039#endif
     2040
    20942041      if( ( m_pcCfg->getPictureTimingSEIEnabled() || m_pcCfg->getDecodingUnitInfoSEIEnabled() ) &&
    20952042          ( pcSlice->getSPS()->getVuiParametersPresentFlag() ) &&
     
    21262073            for( i = ( numDU - 2 ); i >= 0; i -- )
    21272074            {
    2128 #if L0043_TIMING_INFO
    21292075              ui64Tmp = ( ( ( accumBitsDU[ numDU - 1 ]  - accumBitsDU[ i ] ) * ( vui->getTimingInfo()->getTimeScale() / vui->getTimingInfo()->getNumUnitsInTick() ) * ( hrd->getTickDivisorMinus2() + 2 ) ) / ( m_pcCfg->getTargetBitrate() ) );
    2130 #else
    2131               ui64Tmp = ( ( ( accumBitsDU[ numDU - 1 ]  - accumBitsDU[ i ] ) * ( hrd->getTimeScale() / hrd->getNumUnitsInTick() ) * ( hrd->getTickDivisorMinus2() + 2 ) ) / ( m_pcCfg->getTargetBitrate() ) );
    2132 #endif
    21332076              if( (UInt)ui64Tmp > maxDiff )
    21342077              {
     
    21422085            {
    21432086              flag = 0;
    2144 #if L0043_TIMING_INFO
    21452087              ui64Tmp = ( ( ( accumBitsDU[ numDU - 1 ]  - accumBitsDU[ i ] ) * ( vui->getTimingInfo()->getTimeScale() / vui->getTimingInfo()->getNumUnitsInTick() ) * ( hrd->getTickDivisorMinus2() + 2 ) ) / ( m_pcCfg->getTargetBitrate() ) );
    2146 #else
    2147               ui64Tmp = ( ( ( accumBitsDU[ numDU - 1 ]  - accumBitsDU[ i ] ) * ( hrd->getTimeScale() / hrd->getNumUnitsInTick() ) * ( hrd->getTickDivisorMinus2() + 2 ) ) / ( m_pcCfg->getTargetBitrate() ) );
    2148 #endif
    21492088
    21502089              if( (UInt)ui64Tmp > maxDiff )
     
    21782117          m_seiWriter.writeSEImessage(nalu.m_Bitstream, pictureTimingSEI, pcSlice->getSPS());
    21792118          writeRBSPTrailingBits(nalu.m_Bitstream);
    2180 #if L0045_NON_NESTED_SEI_RESTRICTIONS
    21812119          UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit);
    21822120          UInt offsetPosition = m_activeParameterSetSEIPresentInAU
     
    21892127          accessUnit.insert(it, new NALUnitEBSP(nalu));
    21902128          m_pictureTimingSEIPresentInAU = true;
    2191 #else
    2192           AccessUnit::iterator it = find_if(accessUnit.begin(), accessUnit.end(), mem_fun(&NALUnit::isSlice));
    2193           accessUnit.insert(it, new NALUnitEBSP(nalu));
    2194 #endif
    2195         }
    2196 #if K0180_SCALABLE_NESTING_SEI
     2129        }
    21972130          if ( m_pcCfg->getScalableNestingSEIEnabled() ) // put picture timing SEI into scalable nesting SEI
    21982131          {
     
    22032136            m_seiWriter.writeSEImessage(nalu.m_Bitstream, scalableNestingSEI, pcSlice->getSPS());
    22042137            writeRBSPTrailingBits(nalu.m_Bitstream);
    2205 #if L0045_NON_NESTED_SEI_RESTRICTIONS
    22062138            UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit);
    22072139            UInt offsetPosition = m_activeParameterSetSEIPresentInAU
     
    22142146            accessUnit.insert(it, new NALUnitEBSP(nalu));
    22152147            m_nestedPictureTimingSEIPresentInAU = true;
    2216 #else
    2217             AccessUnit::iterator it = find_if(accessUnit.begin(), accessUnit.end(), mem_fun(&NALUnit::isSlice));
    2218             accessUnit.insert(it, new NALUnitEBSP(nalu));
    2219 #endif
    22202148          }
    2221 #endif
    2222 
    22232149        }
    22242150        if( m_pcCfg->getDecodingUnitInfoSEIEnabled() && hrd->getSubPicCpbParamsPresentFlag() )
     
    22322158            tempSEI.m_decodingUnitIdx = i;
    22332159            tempSEI.m_duSptCpbRemovalDelay = pictureTimingSEI.m_duCpbRemovalDelayMinus1[i] + 1;
    2234 #if L0044_DU_DPB_OUTPUT_DELAY_HRD
    22352160            tempSEI.m_dpbOutputDuDelayPresentFlag = false;
    22362161            tempSEI.m_picSptDpbOutputDuDelay = picSptDpbOutputDuDelay;
    2237 #endif
    22382162
    22392163            AccessUnit::iterator it;
     
    22452169              writeRBSPTrailingBits(nalu.m_Bitstream);
    22462170
    2247 #if L0045_NON_NESTED_SEI_RESTRICTIONS
    22482171              UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit);
    22492172              UInt offsetPosition = m_activeParameterSetSEIPresentInAU
     
    22552178              }
    22562179              accessUnit.insert(it, new NALUnitEBSP(nalu));
    2257 #else
    2258               it = find_if(accessUnit.begin(), accessUnit.end(), mem_fun(&NALUnit::isSlice));
    2259               accessUnit.insert(it, new NALUnitEBSP(nalu));
    2260 #endif
    22612180            }
    22622181            else
     
    22842203        }
    22852204      }
    2286 #if L0045_NON_NESTED_SEI_RESTRICTIONS
    22872205      xResetNonNestedSEIPresentFlags();
    2288 #if K0180_SCALABLE_NESTING_SEI
    22892206      xResetNestedSEIPresentFlags();
    2290 #endif
    2291 #endif
    22922207      pcPic->getPicYuvRec()->copyToPic(pcPicYuvRecOut);
    22932208
     
    24452360  }
    24462361 
    2447   assert (rpcPic->getPOC() == pocCurr);
     2362  assert( rpcPic != NULL );
     2363  assert( rpcPic->getPOC() == pocCurr );
    24482364 
    24492365  return;
     
    29452861}
    29462862
    2947 #if L0045_NON_NESTED_SEI_RESTRICTIONS
    29482863/** Function for finding the position to insert the first of APS and non-nested BP, PT, DU info SEI messages.
    29492864 * \param accessUnit Access Unit of the current picture
     
    29652880  return seiStartPos;
    29662881}
    2967 #endif
    2968 
    2969 #if L0386_DB_METRIC
     2882
    29702883Void TEncGOP::dblMetric( TComPic* pcPic, UInt uiNumSlices )
    29712884{
     
    29812894  const UInt noCol = (picWidth>>log2maxTB);
    29822895  const UInt noRows = (picHeight>>log2maxTB);
     2896  assert(noCol > 1);
     2897  assert(noRows > 1);
    29832898  UInt64 *colSAD = (UInt64*)malloc(noCol*sizeof(UInt64));
    29842899  UInt64 *rowSAD = (UInt64*)malloc(noRows*sizeof(UInt64));
     
    30893004  free(rowSAD);
    30903005}
    3091 #endif
    30923006
    30933007#if M0457_COL_PICTURE_SIGNALING
  • branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncGOP.h

    r292 r302  
    127127  UInt                    m_tl0Idx;
    128128  UInt                    m_rapIdx;
    129 #if L0045_NON_NESTED_SEI_RESTRICTIONS
    130129  Bool                    m_activeParameterSetSEIPresentInAU;
    131130  Bool                    m_bufferingPeriodSEIPresentInAU;
    132131  Bool                    m_pictureTimingSEIPresentInAU;
    133 #if K0180_SCALABLE_NESTING_SEI
    134132  Bool                    m_nestedBufferingPeriodSEIPresentInAU;
    135133  Bool                    m_nestedPictureTimingSEIPresentInAU;
    136 #endif
    137 #endif
    138134public:
    139135  TEncGOP();
     
    186182  SEIDisplayOrientation*  xCreateSEIDisplayOrientation();
    187183
    188 #if J0149_TONE_MAPPING_SEI
    189184  SEIToneMappingInfo*     xCreateSEIToneMappingInfo();
    190 #endif
    191185
    192186  Void xCreateLeadingSEIMessages (/*SEIMessages seiMessages,*/ AccessUnit &accessUnit, TComSPS *sps);
    193 #if L0045_NON_NESTED_SEI_RESTRICTIONS
    194187  Int xGetFirstSeiLocation (AccessUnit &accessUnit);
    195188  Void xResetNonNestedSEIPresentFlags()
     
    199192    m_pictureTimingSEIPresentInAU      = false;
    200193  }
    201 #if K0180_SCALABLE_NESTING_SEI
    202194  Void xResetNestedSEIPresentFlags()
    203195  {
     
    205197    m_nestedPictureTimingSEIPresentInAU      = false;
    206198  }
    207 #endif
    208 #endif
    209 #if L0386_DB_METRIC
    210199  Void dblMetric( TComPic* pcPic, UInt uiNumSlices );
    211 #endif
    212200#if M0457_COL_PICTURE_SIGNALING
    213201  TComPic* getMotionPredIlp(TComSlice* pcSlice);
  • branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncRateCtrl.cpp

    r191 r302  
    6767  m_bitsLeft            = 0;
    6868  m_useLCUSeparateModel = false;
     69#if M0036_RC_IMPROVEMENT
     70  m_adaptiveBit         = 0;
     71  m_lastLambda          = 0.0;
     72#endif
    6973}
    7074
     
    7478}
    7579
     80#if M0036_RC_IMPROVEMENT
     81Void TEncRCSeq::create( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Int numberOfLevel, Bool useLCUSeparateModel, Int adaptiveBit )
     82#else
    7683Void TEncRCSeq::create( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Int numberOfLevel, Bool useLCUSeparateModel )
     84#endif
    7785{
    7886  destroy();
     
    101109    m_betaUpdate  = 0.025;
    102110  }
    103   else
     111#if M0036_RC_IMPROVEMENT
     112  else if ( m_seqTargetBpp < 0.2 )
    104113  {
    105114    m_alphaUpdate = 0.1;
    106115    m_betaUpdate  = 0.05;
    107116  }
     117  else if ( m_seqTargetBpp < 0.5 )
     118  {
     119    m_alphaUpdate = 0.2;
     120    m_betaUpdate  = 0.1;
     121  }
     122  else
     123  {
     124    m_alphaUpdate = 0.4;
     125    m_betaUpdate  = 0.2;
     126  }
     127#else
     128  else
     129  {
     130    m_alphaUpdate = 0.1;
     131    m_betaUpdate  = 0.05;
     132  }
     133#endif
    108134  m_averageBits     = (Int)(m_targetBits / totalFrames);
    109135  Int picWidthInBU  = ( m_picWidth  % m_LCUWidth  ) == 0 ? m_picWidth  / m_LCUWidth  : m_picWidth  / m_LCUWidth  + 1;
     
    146172  m_framesLeft = m_totalFrames;
    147173  m_bitsLeft   = m_targetBits;
     174#if M0036_RC_IMPROVEMENT
     175  m_adaptiveBit = adaptiveBit;
     176  m_lastLambda = 0.0;
     177#endif
    148178}
    149179
     
    203233    for ( Int i=0; i<m_numberOfLevel; i++ )
    204234    {
     235#if RATE_CONTROL_INTRA
     236      if (i>0)
     237      {
    205238      m_picPara[i].m_alpha = 3.2003;
    206239      m_picPara[i].m_beta  = -1.367;
    207240    }
     241      else
     242      {
     243        m_picPara[i].m_alpha = ALPHA;   
     244        m_picPara[i].m_beta  = BETA2;
     245      }
     246#else
     247      m_picPara[i].m_alpha = 3.2003;
     248      m_picPara[i].m_beta  = -1.367;
     249#endif
     250    }
    208251  }
    209252  else
     
    228271      for ( Int j=0; j<m_numberOfLCU; j++)
    229272      {
     273#if RATE_CONTROL_INTRA
     274        m_LCUPara[i][j].m_alpha = m_picPara[i].m_alpha;
     275        m_LCUPara[i][j].m_beta  = m_picPara[i].m_beta;
     276#else
    230277        m_LCUPara[i][j].m_alpha = 3.2003;
    231278        m_LCUPara[i][j].m_beta  = -1.367;
     279#endif
    232280      }
    233281    }
     
    251299}
    252300
     301#if !RATE_CONTROL_INTRA
    253302Int TEncRCSeq::getRefineBitsForIntra( Int orgBits )
    254303{
     
    264313  return orgBits * 10;
    265314}
     315#endif
     316
     317#if M0036_RC_IMPROVEMENT
     318Void TEncRCSeq::setAllBitRatio( Double basicLambda, Double* equaCoeffA, Double* equaCoeffB )
     319{
     320  Int* bitsRatio = new Int[m_GOPSize];
     321  for ( Int i=0; i<m_GOPSize; i++ )
     322  {
     323    bitsRatio[i] = (Int)( equaCoeffA[i] * pow( basicLambda, equaCoeffB[i] ) * m_numberOfPixel );
     324  }
     325  initBitsRatio( bitsRatio );
     326  delete[] bitsRatio;
     327}
     328#endif
    266329
    267330//GOP level
     
    286349  Int targetBits = xEstGOPTargetBits( encRCSeq, numPic );
    287350
     351#if M0036_RC_IMPROVEMENT
     352  if ( encRCSeq->getAdaptiveBits() > 0 && encRCSeq->getLastLambda() > 0.1 )
     353  {
     354    Double targetBpp = (Double)targetBits / encRCSeq->getNumPixel();
     355    Double basicLambda = 0.0;
     356    Double* lambdaRatio = new Double[encRCSeq->getGOPSize()];
     357    Double* equaCoeffA = new Double[encRCSeq->getGOPSize()];
     358    Double* equaCoeffB = new Double[encRCSeq->getGOPSize()];
     359
     360    if ( encRCSeq->getAdaptiveBits() == 1 )   // for GOP size =4, low delay case
     361    {
     362      if ( encRCSeq->getLastLambda() < 120.0 )
     363      {
     364        lambdaRatio[1] = 0.725 * log( encRCSeq->getLastLambda() ) + 0.5793;
     365        lambdaRatio[0] = 1.3 * lambdaRatio[1];
     366        lambdaRatio[2] = 1.3 * lambdaRatio[1];
     367        lambdaRatio[3] = 1.0;
     368      }
     369      else
     370      {
     371        lambdaRatio[0] = 5.0;
     372        lambdaRatio[1] = 4.0;
     373        lambdaRatio[2] = 5.0;
     374        lambdaRatio[3] = 1.0;
     375      }
     376    }
     377    else if ( encRCSeq->getAdaptiveBits() == 2 )  // for GOP size = 8, random access case
     378    {
     379      if ( encRCSeq->getLastLambda() < 90.0 )
     380      {
     381        lambdaRatio[0] = 1.0;
     382        lambdaRatio[1] = 0.725 * log( encRCSeq->getLastLambda() ) + 0.7963;
     383        lambdaRatio[2] = 1.3 * lambdaRatio[1];
     384        lambdaRatio[3] = 3.25 * lambdaRatio[1];
     385        lambdaRatio[4] = 3.25 * lambdaRatio[1];
     386        lambdaRatio[5] = 1.3  * lambdaRatio[1];
     387        lambdaRatio[6] = 3.25 * lambdaRatio[1];
     388        lambdaRatio[7] = 3.25 * lambdaRatio[1];
     389      }
     390      else
     391      {
     392        lambdaRatio[0] = 1.0;
     393        lambdaRatio[1] = 4.0;
     394        lambdaRatio[2] = 5.0;
     395        lambdaRatio[3] = 12.3;
     396        lambdaRatio[4] = 12.3;
     397        lambdaRatio[5] = 5.0;
     398        lambdaRatio[6] = 12.3;
     399        lambdaRatio[7] = 12.3;
     400      }
     401    }
     402
     403    xCalEquaCoeff( encRCSeq, lambdaRatio, equaCoeffA, equaCoeffB, encRCSeq->getGOPSize() );
     404    basicLambda = xSolveEqua( targetBpp, equaCoeffA, equaCoeffB, encRCSeq->getGOPSize() );
     405    encRCSeq->setAllBitRatio( basicLambda, equaCoeffA, equaCoeffB );
     406
     407    delete []lambdaRatio;
     408    delete []equaCoeffA;
     409    delete []equaCoeffB;
     410  }
     411#endif
     412
    288413  m_picTargetBitInGOP = new Int[numPic];
    289414  Int i;
     
    297422  {
    298423    currPicRatio = encRCSeq->getBitRatio( i );
     424#if M0036_RC_IMPROVEMENT
     425    m_picTargetBitInGOP[i] = (Int)( ((Double)targetBits) * currPicRatio / totalPicRatio );
     426#else
    299427    m_picTargetBitInGOP[i] = targetBits * currPicRatio / totalPicRatio;
     428#endif
    300429  }
    301430
     
    306435  m_bitsLeft     = m_targetBits;
    307436}
     437
     438#if M0036_RC_IMPROVEMENT
     439Void TEncRCGOP::xCalEquaCoeff( TEncRCSeq* encRCSeq, Double* lambdaRatio, Double* equaCoeffA, Double* equaCoeffB, Int GOPSize )
     440{
     441  for ( Int i=0; i<GOPSize; i++ )
     442  {
     443    Int frameLevel = encRCSeq->getGOPID2Level(i);
     444    Double alpha   = encRCSeq->getPicPara(frameLevel).m_alpha;
     445    Double beta    = encRCSeq->getPicPara(frameLevel).m_beta;
     446    equaCoeffA[i] = pow( 1.0/alpha, 1.0/beta ) * pow( lambdaRatio[i], 1.0/beta );
     447    equaCoeffB[i] = 1.0/beta;
     448  }
     449}
     450
     451Double TEncRCGOP::xSolveEqua( Double targetBpp, Double* equaCoeffA, Double* equaCoeffB, Int GOPSize )
     452{
     453  Double solution = 100.0;
     454  Double minNumber = 0.1;
     455  Double maxNumber = 10000.0;
     456  for ( Int i=0; i<g_RCIterationNum; i++ )
     457  {
     458    Double fx = 0.0;
     459    for ( Int j=0; j<GOPSize; j++ )
     460    {
     461      fx += equaCoeffA[j] * pow( solution, equaCoeffB[j] );
     462    }
     463
     464    if ( fabs( fx - targetBpp ) < 0.000001 )
     465    {
     466      break;
     467    }
     468
     469    if ( fx > targetBpp )
     470    {
     471      minNumber = solution;
     472      solution = ( solution + maxNumber ) / 2.0;
     473    }
     474    else
     475    {
     476      maxNumber = solution;
     477      solution = ( solution + minNumber ) / 2.0;
     478    }
     479  }
     480
     481  solution = Clip3( 0.1, 10000.0, solution );
     482  return solution;
     483}
     484#endif
    308485
    309486Void TEncRCGOP::destroy()
     
    357534
    358535  m_LCUs         = NULL;
     536#if !M0036_RC_IMPROVEMENT
    359537  m_lastPicture  = NULL;
     538#endif
    360539  m_picActualHeaderBits = 0;
     540#if !M0036_RC_IMPROVEMENT
    361541  m_totalMAD            = 0.0;
     542#endif
    362543  m_picActualBits       = 0;
    363544  m_picQP               = 0;
     
    384565  }
    385566
     567#if M0036_RC_IMPROVEMENT
     568  targetBits  = Int( ((Double)GOPbitsLeft) * currPicRatio / totalPicRatio );
     569#else
    386570  targetBits  = Int( GOPbitsLeft * currPicRatio / totalPicRatio );
     571#endif
    387572
    388573  if ( targetBits < 100 )
     
    480665      m_LCUs[LCUIdx].m_lambda     = 0.0;
    481666      m_LCUs[LCUIdx].m_targetBits = 0;
     667#if M0036_RC_IMPROVEMENT
     668      m_LCUs[LCUIdx].m_bitWeight  = 1.0;
     669#else
    482670      m_LCUs[LCUIdx].m_MAD        = 0.0;
     671#endif
    483672      Int currWidth  = ( (i == picWidthInLCU -1) ? picWidth  - LCUWidth *(picWidthInLCU -1) : LCUWidth  );
    484673      Int currHeight = ( (j == picHeightInLCU-1) ? picHeight - LCUHeight*(picHeightInLCU-1) : LCUHeight );
     
    487676  }
    488677  m_picActualHeaderBits = 0;
     678#if !M0036_RC_IMPROVEMENT
    489679  m_totalMAD            = 0.0;
     680#endif
    490681  m_picActualBits       = 0;
    491682  m_picQP               = 0;
    492683  m_picLambda           = 0.0;
    493684
     685#if !M0036_RC_IMPROVEMENT
    494686  m_lastPicture = NULL;
    495687  list<TEncRCPic*>::reverse_iterator it;
     
    502694    }
    503695  }
     696#endif
    504697}
    505698
     
    515708}
    516709
     710
     711#if RATE_CONTROL_INTRA
     712Double TEncRCPic::estimatePicLambda( list<TEncRCPic*>& listPreviousPictures, SliceType eSliceType)
     713#else
    517714Double TEncRCPic::estimatePicLambda( list<TEncRCPic*>& listPreviousPictures )
     715#endif
    518716{
    519717  Double alpha         = m_encRCSeq->getPicPara( m_frameLevel ).m_alpha;
    520718  Double beta          = m_encRCSeq->getPicPara( m_frameLevel ).m_beta;
    521719  Double bpp       = (Double)m_targetBits/(Double)m_numberOfPixel;
     720#if RATE_CONTROL_INTRA
     721  Double estLambda;
     722  if (eSliceType == I_SLICE)
     723  {
     724    estLambda = calculateLambdaIntra(alpha, beta, pow(m_totalCostIntra/(Double)m_numberOfPixel, BETA1), bpp);
     725  }
     726  else
     727  {
     728    estLambda = alpha * pow( bpp, beta );
     729  }
     730#else
    522731  Double estLambda = alpha * pow( bpp, beta );
     732#endif 
     733 
    523734  Double lastLevelLambda = -1.0;
    524735  Double lastPicLambda   = -1.0;
     
    566777
    567778  m_estPicLambda = estLambda;
     779
     780#if M0036_RC_IMPROVEMENT
     781  Double totalWeight = 0.0;
     782  // initial BU bit allocation weight
     783  for ( Int i=0; i<m_numberOfLCU; i++ )
     784  {
     785#if RC_FIX
     786    Double alphaLCU, betaLCU;
     787    if ( m_encRCSeq->getUseLCUSeparateModel() )
     788    {
     789      alphaLCU = m_encRCSeq->getLCUPara( m_frameLevel, i ).m_alpha;
     790      betaLCU  = m_encRCSeq->getLCUPara( m_frameLevel, i ).m_beta;
     791    }
     792    else
     793    {
     794      alphaLCU = m_encRCSeq->getPicPara( m_frameLevel ).m_alpha;
     795      betaLCU  = m_encRCSeq->getPicPara( m_frameLevel ).m_beta;
     796    }
     797#else
     798    Double alphaLCU = m_encRCSeq->getLCUPara( m_frameLevel, i ).m_alpha;
     799    Double betaLCU  = m_encRCSeq->getLCUPara( m_frameLevel, i ).m_beta;
     800#endif
     801
     802    m_LCUs[i].m_bitWeight =  m_LCUs[i].m_numberOfPixel * pow( estLambda/alphaLCU, 1.0/betaLCU );
     803
     804    if ( m_LCUs[i].m_bitWeight < 0.01 )
     805    {
     806      m_LCUs[i].m_bitWeight = 0.01;
     807    }
     808    totalWeight += m_LCUs[i].m_bitWeight;
     809  }
     810  for ( Int i=0; i<m_numberOfLCU; i++ )
     811  {
     812    Double BUTargetBits = m_targetBits * m_LCUs[i].m_bitWeight / totalWeight;
     813    m_LCUs[i].m_bitWeight = BUTargetBits;
     814  }
     815#endif
     816
    568817  return estLambda;
    569818}
     
    607856}
    608857
     858#if RATE_CONTROL_INTRA
     859Double TEncRCPic::getLCUTargetBpp(SliceType eSliceType) 
     860#else
    609861Double TEncRCPic::getLCUTargetBpp()
     862#endif
    610863{
    611864  Int   LCUIdx    = getLCUCoded();
    612865  Double bpp      = -1.0;
    613866  Int avgBits     = 0;
     867#if !M0036_RC_IMPROVEMENT
    614868  Double totalMAD = -1.0;
    615869  Double MAD      = -1.0;
    616 
     870#endif
     871
     872#if RATE_CONTROL_INTRA
     873  if (eSliceType == I_SLICE){
     874    Int noOfLCUsLeft = m_numberOfLCU - LCUIdx + 1;
     875    Int bitrateWindow = min(4,noOfLCUsLeft);
     876    Double MAD      = getLCU(LCUIdx).m_costIntra;
     877
     878    if (m_remainingCostIntra > 0.1 )
     879    {
     880      Double weightedBitsLeft = (m_bitsLeft*bitrateWindow+(m_bitsLeft-getLCU(LCUIdx).m_targetBitsLeft)*noOfLCUsLeft)/(Double)bitrateWindow;
     881      avgBits = Int( MAD*weightedBitsLeft/m_remainingCostIntra );
     882    }
     883    else
     884    {
     885      avgBits = Int( m_bitsLeft / m_LCULeft );
     886    }
     887    m_remainingCostIntra -= MAD;
     888  }
     889  else
     890  {
     891#endif
     892#if M0036_RC_IMPROVEMENT
     893  Double totalWeight = 0;
     894  for ( Int i=LCUIdx; i<m_numberOfLCU; i++ )
     895  {
     896    totalWeight += m_LCUs[i].m_bitWeight;
     897  }
     898  Int realInfluenceLCU = min( g_RCLCUSmoothWindowSize, getLCULeft() );
     899  avgBits = (Int)( m_LCUs[LCUIdx].m_bitWeight - ( totalWeight - m_bitsLeft ) / realInfluenceLCU + 0.5 );
     900#else
    617901  if ( m_lastPicture == NULL )
    618902  {
     
    637921    }
    638922  }
    639 
    640 #if L0033_RC_BUGFIX
     923#endif
     924#if RATE_CONTROL_INTRA
     925  }
     926#endif
     927
    641928  if ( avgBits < 1 )
    642929  {
    643930    avgBits = 1;
    644931  }
    645 #else
    646   if ( avgBits < 5 )
    647   {
    648     avgBits = 5;
    649   }
    650 #endif
    651932
    652933  bpp = ( Double )avgBits/( Double )m_LCUs[ LCUIdx ].m_numberOfPixel;
     
    716997  //for Lambda clip, LCU level clip
    717998  Int clipNeighbourQP = g_RCInvalidQPValue;
    718 #if L0033_RC_BUGFIX
    719999  for ( int i=LCUIdx - 1; i>=0; i-- )
    720 #else
    721   for ( int i=LCUIdx; i>=0; i-- )
    722 #endif
    7231000  {
    7241001    if ( (getLCU(i)).m_QP > g_RCInvalidQPValue )
     
    7731050    beta  *= ( 1.0 - m_encRCSeq->getBetaUpdate() / 2.0 );
    7741051
     1052#if M0036_RC_IMPROVEMENT
     1053    alpha = Clip3( g_RCAlphaMinValue, g_RCAlphaMaxValue, alpha );
     1054    beta  = Clip3( g_RCBetaMinValue,  g_RCBetaMaxValue,  beta  );
     1055#else
    7751056    alpha = Clip3( 0.05, 20.0, alpha );
    7761057    beta  = Clip3( -3.0, -0.1, beta  );
     1058#endif
    7771059
    7781060    TRCParameter rcPara;
     
    7871069  alpha += m_encRCSeq->getAlphaUpdate() * ( log( inputLambda ) - log( calLambda ) ) * alpha;
    7881070  double lnbpp = log( bpp );
     1071#if M0036_RC_IMPROVEMENT
     1072  lnbpp = Clip3( -5.0, -0.1, lnbpp );
     1073#else
    7891074  lnbpp = Clip3( -5.0, 1.0, lnbpp );
     1075#endif
    7901076  beta  += m_encRCSeq->getBetaUpdate() * ( log( inputLambda ) - log( calLambda ) ) * lnbpp;
    7911077
     1078#if M0036_RC_IMPROVEMENT
     1079  alpha = Clip3( g_RCAlphaMinValue, g_RCAlphaMaxValue, alpha );
     1080  beta  = Clip3( g_RCBetaMinValue,  g_RCBetaMaxValue,  beta  );
     1081#else
    7921082  alpha = Clip3( 0.05, 20.0, alpha );
    7931083  beta  = Clip3( -3.0, -0.1, beta  );
     1084#endif
    7941085  TRCParameter rcPara;
    7951086  rcPara.m_alpha = alpha;
     
    7991090}
    8001091
     1092#if !M0036_RC_IMPROVEMENT
    8011093Double TEncRCPic::getEffectivePercentage()
    8021094{
     
    8161108  return effectivePixelPercentage;
    8171109}
     1110#endif
    8181111
    8191112Double TEncRCPic::calAverageQP()
     
    8711164}
    8721165
     1166#if M0036_RC_IMPROVEMENT
     1167#if RATE_CONTROL_INTRA
     1168Void TEncRCPic::updateAfterPicture( Int actualHeaderBits, Int actualTotalBits, Double averageQP, Double averageLambda, SliceType eSliceType)
     1169#else
     1170Void TEncRCPic::updateAfterPicture( Int actualHeaderBits, Int actualTotalBits, Double averageQP, Double averageLambda )
     1171#endif
     1172#else
    8731173Void TEncRCPic::updateAfterPicture( Int actualHeaderBits, Int actualTotalBits, Double averageQP, Double averageLambda, Double effectivePercentage )
     1174#endif
    8741175{
    8751176  m_picActualHeaderBits = actualHeaderBits;
     
    8841185  }
    8851186  m_picLambda           = averageLambda;
     1187#if !M0036_RC_IMPROVEMENT
    8861188  for ( Int i=0; i<m_numberOfLCU; i++ )
    8871189  {
    8881190    m_totalMAD += m_LCUs[i].m_MAD;
    8891191  }
     1192#endif
    8901193
    8911194  Double alpha = m_encRCSeq->getPicPara( m_frameLevel ).m_alpha;
    8921195  Double beta  = m_encRCSeq->getPicPara( m_frameLevel ).m_beta;
    893 
     1196#if RATE_CONTROL_INTRA
     1197  if (eSliceType == I_SLICE)
     1198  {
     1199    updateAlphaBetaIntra(&alpha, &beta);
     1200  }
     1201  else
     1202  {
     1203#endif
    8941204  // update parameters
    8951205  Double picActualBits = ( Double )m_picActualBits;
     
    8981208  Double inputLambda   = m_picLambda;
    8991209
     1210#if M0036_RC_IMPROVEMENT
     1211  if ( inputLambda < 0.01 || calLambda < 0.01 || picActualBpp < 0.0001 )
     1212#else
    9001213  if ( inputLambda < 0.01 || calLambda < 0.01 || picActualBpp < 0.0001 || effectivePercentage < 0.05 )
     1214#endif
    9011215  {
    9021216    alpha *= ( 1.0 - m_encRCSeq->getAlphaUpdate() / 2.0 );
    9031217    beta  *= ( 1.0 - m_encRCSeq->getBetaUpdate() / 2.0 );
    9041218
     1219#if M0036_RC_IMPROVEMENT
     1220    alpha = Clip3( g_RCAlphaMinValue, g_RCAlphaMaxValue, alpha );
     1221    beta  = Clip3( g_RCBetaMinValue,  g_RCBetaMaxValue,  beta  );
     1222#else
    9051223    alpha = Clip3( 0.05, 20.0, alpha );
    9061224    beta  = Clip3( -3.0, -0.1, beta  );
     1225#endif
    9071226    TRCParameter rcPara;
    9081227    rcPara.m_alpha = alpha;
     
    9161235  alpha += m_encRCSeq->getAlphaUpdate() * ( log( inputLambda ) - log( calLambda ) ) * alpha;
    9171236  double lnbpp = log( picActualBpp );
     1237#if M0036_RC_IMPROVEMENT
     1238  lnbpp = Clip3( -5.0, -0.1, lnbpp );
     1239#else
    9181240  lnbpp = Clip3( -5.0, 1.0, lnbpp );
     1241#endif
    9191242  beta  += m_encRCSeq->getBetaUpdate() * ( log( inputLambda ) - log( calLambda ) ) * lnbpp;
    9201243
     1244#if M0036_RC_IMPROVEMENT
     1245  alpha = Clip3( g_RCAlphaMinValue, g_RCAlphaMaxValue, alpha );
     1246  beta  = Clip3( g_RCBetaMinValue,  g_RCBetaMaxValue,  beta  );
     1247#else
    9211248  alpha = Clip3( 0.05, 20.0, alpha );
    9221249  beta  = Clip3( -3.0, -0.1, beta  );
     1250#endif
     1251#if RATE_CONTROL_INTRA
     1252  }
     1253#endif
    9231254
    9241255  TRCParameter rcPara;
     
    9271258
    9281259  m_encRCSeq->setPicPara( m_frameLevel, rcPara );
    929 }
     1260
     1261#if M0036_RC_IMPROVEMENT
     1262  if ( m_frameLevel == 1 )
     1263  {
     1264    Double currLambda = Clip3( 0.1, 10000.0, m_picLambda );
     1265    Double updateLastLambda = g_RCWeightHistoryLambda * m_encRCSeq->getLastLambda() + g_RCWeightCurrentLambda * currLambda;
     1266    m_encRCSeq->setLastLambda( updateLastLambda );
     1267  }
     1268#endif
     1269}
     1270
     1271#if RATE_CONTROL_INTRA
     1272Int TEncRCPic::getRefineBitsForIntra( Int orgBits )
     1273{
     1274  Double alpha=0.25, beta=0.5582;
     1275  Int iIntraBits;
     1276
     1277  if (orgBits*40 < m_numberOfPixel)
     1278  {
     1279    alpha=0.25;
     1280  }
     1281  else
     1282  {
     1283    alpha=0.30;
     1284  }
     1285
     1286  iIntraBits = (Int)(alpha* pow(m_totalCostIntra*4.0/(Double)orgBits, beta)*(Double)orgBits+0.5);
     1287 
     1288  return iIntraBits;
     1289}
     1290
     1291Double TEncRCPic::calculateLambdaIntra(double alpha, double beta, double MADPerPixel, double bitsPerPixel)
     1292{
     1293  return ( (alpha/256.0) * pow( MADPerPixel/bitsPerPixel, beta ) );
     1294}
     1295
     1296Void TEncRCPic::updateAlphaBetaIntra(double *alpha, double *beta)
     1297{
     1298  Double lnbpp = log(pow(m_totalCostIntra / (Double)m_numberOfPixel, BETA1));
     1299  Double diffLambda = (*beta)*(log((Double)m_picActualBits)-log((Double)m_targetBits));
     1300
     1301  diffLambda = Clip3(-0.125, 0.125, 0.25*diffLambda);
     1302  *alpha    =  (*alpha) * exp(diffLambda);
     1303  *beta     =  (*beta) + diffLambda / lnbpp;
     1304}
     1305
     1306
     1307Void TEncRCPic::getLCUInitTargetBits() 
     1308{
     1309  Int iAvgBits     = 0;
     1310
     1311  m_remainingCostIntra = m_totalCostIntra;
     1312  for (Int i=m_numberOfLCU-1; i>=0; i--)
     1313  {
     1314    iAvgBits += Int(m_targetBits * getLCU(i).m_costIntra/m_totalCostIntra);
     1315    getLCU(i).m_targetBitsLeft = iAvgBits;
     1316  }
     1317}
     1318
     1319
     1320Double TEncRCPic::getLCUEstLambdaAndQP(Double bpp, Int clipPicQP, Int *estQP)
     1321{
     1322  Int   LCUIdx = getLCUCoded();
     1323
     1324  Double   alpha = m_encRCSeq->getPicPara( m_frameLevel ).m_alpha;
     1325  Double   beta  = m_encRCSeq->getPicPara( m_frameLevel ).m_beta;
     1326
     1327  Double costPerPixel = getLCU(LCUIdx).m_costIntra/(Double)getLCU(LCUIdx).m_numberOfPixel;
     1328  costPerPixel = pow(costPerPixel, BETA1);
     1329  Double estLambda = calculateLambdaIntra(alpha, beta, costPerPixel, bpp);
     1330
     1331  Int clipNeighbourQP = g_RCInvalidQPValue;
     1332  for (int i=LCUIdx-1; i>=0; i--)
     1333  {
     1334    if ((getLCU(i)).m_QP > g_RCInvalidQPValue)
     1335    {
     1336      clipNeighbourQP = getLCU(i).m_QP;
     1337      break;
     1338    }
     1339  }
     1340
     1341  Int minQP = clipPicQP - 2;
     1342  Int maxQP = clipPicQP + 2;
     1343
     1344  if ( clipNeighbourQP > g_RCInvalidQPValue )
     1345  {
     1346    maxQP = min(clipNeighbourQP + 1, maxQP);
     1347    minQP = max(clipNeighbourQP - 1, minQP);
     1348  }
     1349
     1350  Double maxLambda=exp(((Double)(maxQP+0.49)-13.7122)/4.2005);
     1351  Double minLambda=exp(((Double)(minQP-0.49)-13.7122)/4.2005);
     1352
     1353  estLambda = Clip3(minLambda, maxLambda, estLambda);
     1354
     1355  *estQP = Int( 4.2005 * log(estLambda) + 13.7122 + 0.5 );
     1356  *estQP = Clip3(minQP, maxQP, *estQP);
     1357
     1358  return estLambda;
     1359}
     1360#endif
    9301361
    9311362TEncRateCtrl::TEncRateCtrl()
     
    9611392}
    9621393
     1394#if M0036_RC_IMPROVEMENT
     1395Void TEncRateCtrl::init( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Int keepHierBits, Bool useLCUSeparateModel, GOPEntry  GOPList[MAX_GOP] )
     1396#else
    9631397Void TEncRateCtrl::init( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Bool keepHierBits, Bool useLCUSeparateModel, GOPEntry  GOPList[MAX_GOP] )
     1398#endif
    9641399{
    9651400  destroy();
     
    9761411
    9771412  Int numberOfLevel = 1;
     1413#if M0036_RC_IMPROVEMENT
     1414  Int adaptiveBit = 0;
     1415  if ( keepHierBits > 0 )
     1416#else
    9781417  if ( keepHierBits )
     1418#endif
    9791419  {
    9801420    numberOfLevel = Int( log((Double)GOPSize)/log(2.0) + 0.5 ) + 1;
     
    9981438    }
    9991439  }
     1440
     1441#if M0036_RC_IMPROVEMENT
     1442  if ( keepHierBits > 0 )
     1443#else
    10001444  if ( keepHierBits )
     1445#endif
    10011446  {
    10021447    Double bpp = (Double)( targetBitrate / (Double)( frameRate*picWidth*picHeight ) );
     
    10311476        bitsRatio[3] = 14;
    10321477      }
     1478#if M0036_RC_IMPROVEMENT
     1479      if ( keepHierBits == 2 )
     1480      {
     1481        adaptiveBit = 1;
     1482      }
     1483#endif
    10331484    }
    10341485    else if ( GOPSize == 8 && !isLowdelay )
     
    10781529        bitsRatio[7] = 1;
    10791530      }
     1531#if M0036_RC_IMPROVEMENT
     1532      if ( keepHierBits == 2 )
     1533      {
     1534        adaptiveBit = 2;
     1535      }
     1536#endif
    10801537    }
    10811538    else
    10821539    {
     1540#if M0036_RC_IMPROVEMENT
     1541      printf( "\n hierarchical bit allocation is not support for the specified coding structure currently.\n" );
     1542#else
    10831543      printf( "\n hierarchical bit allocation is not support for the specified coding structure currently." );
     1544#endif
    10841545    }
    10851546  }
     
    10941555    }
    10951556  }
     1557#if M0036_RC_IMPROVEMENT
     1558  if ( keepHierBits > 0 )
     1559#else
    10961560  if ( keepHierBits )
     1561#endif
    10971562  {
    10981563    if ( GOPSize == 4 && isLowdelay )
     
    11291594
    11301595  m_encRCSeq = new TEncRCSeq;
     1596#if M0036_RC_IMPROVEMENT
     1597  m_encRCSeq->create( totalFrames, targetBitrate, frameRate, GOPSize, picWidth, picHeight, LCUWidth, LCUHeight, numberOfLevel, useLCUSeparateModel, adaptiveBit );
     1598#else
    11311599  m_encRCSeq->create( totalFrames, targetBitrate, frameRate, GOPSize, picWidth, picHeight, LCUWidth, LCUHeight, numberOfLevel, useLCUSeparateModel );
     1600#endif
    11321601  m_encRCSeq->initBitsRatio( bitsRatio );
    11331602  m_encRCSeq->initGOPID2Level( GOPID2Level );
  • branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncRateCtrl.h

    r191 r302  
    6565const Double g_RCWeightPicTargetBitInGOP    = 0.9;
    6666const Double g_RCWeightPicRargetBitInBuffer = 1.0 - g_RCWeightPicTargetBitInGOP;
     67#if M0036_RC_IMPROVEMENT
     68const Int g_RCIterationNum = 20;
     69const Double g_RCWeightHistoryLambda = 0.5;
     70const Double g_RCWeightCurrentLambda = 1.0 - g_RCWeightHistoryLambda;
     71const Int g_RCLCUSmoothWindowSize = 4;
     72const Double g_RCAlphaMinValue = 0.05;
     73const Double g_RCAlphaMaxValue = 500.0;
     74const Double g_RCBetaMinValue  = -3.0;
     75const Double g_RCBetaMaxValue  = -0.1;
     76#endif
     77
     78#if RATE_CONTROL_INTRA
     79#define ALPHA     6.7542;
     80#define BETA1     1.2517
     81#define BETA2     1.7860
     82#endif
    6783
    6884struct TRCLCU
     
    7288  Int m_targetBits;
    7389  Double m_lambda;
     90#if M0036_RC_IMPROVEMENT
     91  Double m_bitWeight;
     92#else
    7493  Double m_MAD;
     94#endif
    7595  Int m_numberOfPixel;
     96#if RATE_CONTROL_INTRA
     97  Double m_costIntra;
     98  Int m_targetBitsLeft;
     99#endif
    76100};
    77101
     
    89113
    90114public:
     115#if M0036_RC_IMPROVEMENT
     116  Void create( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Int numberOfLevel, Bool useLCUSeparateModel, Int adaptiveBit );
     117#else
    91118  Void create( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Int numberOfLevel, Bool useLCUSeparateModel );
     119#endif
    92120  Void destroy();
    93121  Void initBitsRatio( Int bitsRatio[] );
     
    96124  Void initLCUPara( TRCParameter** LCUPara = NULL );    // NULL to initial with default value
    97125  Void updateAfterPic ( Int bits );
     126#if !RATE_CONTROL_INTRA
    98127  Int  getRefineBitsForIntra( Int orgBits );
     128#endif
     129#if M0036_RC_IMPROVEMENT
     130  Void setAllBitRatio( Double basicLambda, Double* equaCoeffA, Double* equaCoeffB );
     131#endif
    99132
    100133public:
     
    134167  Double getBetaUpdate()                { return m_betaUpdate; }
    135168
     169#if M0036_RC_IMPROVEMENT
     170  Int    getAdaptiveBits()              { return m_adaptiveBit;  }
     171  Double getLastLambda()                { return m_lastLambda;   }
     172  Void   setLastLambda( Double lamdba ) { m_lastLambda = lamdba; }
     173#endif
     174
    136175private:
    137176  Int m_totalFrames;
     
    160199  Double m_betaUpdate;
    161200  Bool m_useLCUSeparateModel;
     201
     202#if M0036_RC_IMPROVEMENT
     203  Int m_adaptiveBit;
     204  Double m_lastLambda;
     205#endif
    162206};
    163207
     
    175219private:
    176220  Int  xEstGOPTargetBits( TEncRCSeq* encRCSeq, Int GOPSize );
     221#if M0036_RC_IMPROVEMENT
     222  Void   xCalEquaCoeff( TEncRCSeq* encRCSeq, Double* lambdaRatio, Double* equaCoeffA, Double* equaCoeffB, Int GOPSize );
     223  Double xSolveEqua( Double targetBpp, Double* equaCoeffA, Double* equaCoeffB, Int GOPSize );
     224#endif
    177225
    178226public:
     
    203251  Void destroy();
    204252
     253#if !RATE_CONTROL_INTRA
    205254  Double estimatePicLambda( list<TEncRCPic*>& listPreviousPictures );
     255#endif
    206256  Int    estimatePicQP    ( Double lambda, list<TEncRCPic*>& listPreviousPictures );
     257#if RATE_CONTROL_INTRA
     258  Int    getRefineBitsForIntra(Int orgBits);
     259  Double calculateLambdaIntra(double alpha, double beta, double MADPerPixel, double bitsPerPixel);
     260  Double estimatePicLambda( list<TEncRCPic*>& listPreviousPictures, SliceType eSliceType);
     261
     262  Void   updateAlphaBetaIntra(double *alpha, double *beta);
     263
     264  Double getLCUTargetBpp(SliceType eSliceType);
     265  Double getLCUEstLambdaAndQP(Double bpp, Int clipPicQP, Int *estQP);
     266#else
    207267  Double getLCUTargetBpp();
     268#endif
    208269  Double getLCUEstLambda( Double bpp );
    209270  Int    getLCUEstQP( Double lambda, Int clipPicQP );
    210271
    211272  Void updateAfterLCU( Int LCUIdx, Int bits, Int QP, Double lambda, Bool updateLCUParameter = true );
     273#if M0036_RC_IMPROVEMENT
     274#if RATE_CONTROL_INTRA
     275  Void updateAfterPicture( Int actualHeaderBits, Int actualTotalBits, Double averageQP, Double averageLambda, SliceType eSliceType);
     276#else
     277  Void updateAfterPicture( Int actualHeaderBits, Int actualTotalBits, Double averageQP, Double averageLambda );
     278#endif
     279#else
    212280  Void updateAfterPicture( Int actualHeaderBits, Int actualTotalBits, Double averageQP, Double averageLambda, Double effectivePercentage );
     281#endif
    213282
    214283  Void addToPictureLsit( list<TEncRCPic*>& listPreviousPictures );
     284#if !M0036_RC_IMPROVEMENT
    215285  Double getEffectivePercentage();
     286#endif
    216287  Double calAverageQP();
    217288  Double calAverageLambda();
     
    229300  Int  getNumberOfLCU()                                   { return m_numberOfLCU; }
    230301  Int  getTargetBits()                                    { return m_targetBits; }
     302#if !RATE_CONTROL_INTRA
    231303  Void setTargetBits( Int bits )                          { m_targetBits = bits; }
     304#endif
    232305  Int  getEstHeaderBits()                                 { return m_estHeaderBits; }
    233306  Int  getLCULeft()                                       { return m_LCULeft; }
     
    239312  TRCLCU& getLCU( Int LCUIdx )                            { return m_LCUs[LCUIdx]; }
    240313  Int  getPicActualHeaderBits()                           { return m_picActualHeaderBits; }
     314#if !M0036_RC_IMPROVEMENT
    241315  Double getTotalMAD()                                    { return m_totalMAD; }
    242316  Void   setTotalMAD( Double MAD )                        { m_totalMAD = MAD; }
     317#endif
     318#if RATE_CONTROL_INTRA
     319  Void setTargetBits( Int bits )                          { m_targetBits = bits; m_bitsLeft = bits;}
     320  Void setTotalIntraCost(Double cost)                     { m_totalCostIntra = cost; }
     321  Void getLCUInitTargetBits();
     322#endif
     323
    243324  Int  getPicActualBits()                                 { return m_picActualBits; }
    244325  Int  getPicActualQP()                                   { return m_picQP; }
     
    267348  TRCLCU* m_LCUs;
    268349  Int m_picActualHeaderBits;    // only SH and potential APS
     350#if !M0036_RC_IMPROVEMENT
    269351  Double m_totalMAD;
     352#endif
     353#if RATE_CONTROL_INTRA
     354  Double m_totalCostIntra;
     355  Double m_remainingCostIntra;
     356#endif
    270357  Int m_picActualBits;          // the whole picture, including header
    271358  Int m_picQP;                  // in integer form
    272359  Double m_picLambda;
     360#if !M0036_RC_IMPROVEMENT
    273361  TEncRCPic* m_lastPicture;
     362#endif
    274363};
    275364
     
    281370
    282371public:
     372#if M0036_RC_IMPROVEMENT
     373  Void init( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Int keepHierBits, Bool useLCUSeparateModel, GOPEntry GOPList[MAX_GOP] );
     374#else
    283375  Void init( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Bool keepHierBits, Bool useLCUSeparateModel, GOPEntry GOPList[MAX_GOP] );
     376#endif
    284377  Void destroy();
    285378  Void initRCPic( Int frameLevel );
  • branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp

    r191 r302  
    299299        m_iTypePartBest[iPartIdx] = -1;
    300300        if( m_bUseSBACRD )
     301        {
    301302          m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[pOnePart->PartLevel][CI_TEMP_BEST] );
     303        }
    302304      }
    303305    }
  • branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncSearch.cpp

    r282 r302  
    14101410 
    14111411#if HHI_RQT_INTRA_SPEEDUP
    1412 #if L0232_RD_PENALTY
    14131412  Int maxTuSize = pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize();
    14141413  Int isIntraSlice = (pcCU->getSlice()->getSliceType() == I_SLICE);
     
    14271426  }
    14281427  if( bCheckFirst && noSplitIntraMaxTuSize )
     1428  {
     1429    bCheckSplit = false;
     1430  }
    14291431#else
    1430   if( bCheckFirst && bCheckFull )
    1431 #endif
    1432   {
    1433     bCheckSplit = false;
    1434   }
    1435 #else
    1436 #if L0232_RD_PENALTY
    14371432  Int maxTuSize = pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize();
    14381433  Int isIntraSlice = (pcCU->getSlice()->getSliceType() == I_SLICE);
     
    14421437    bCheckFull    = ( uiLog2TrSize  <= min(maxTuSize,4));
    14431438  }
    1444 #endif
    14451439#endif
    14461440  Double  dSingleCost   = MAX_DOUBLE;
     
    16171611      //----- determine rate and r-d cost -----
    16181612      UInt uiSingleBits = xGetIntraBitsQT( pcCU, uiTrDepth, uiAbsPartIdx, true, !bLumaOnly, false );
    1619 #if L0232_RD_PENALTY
    16201613      if(m_pcEncCfg->getRDpenalty() && (uiLog2TrSize==5) && !isIntraSlice)
    16211614      {
    16221615        uiSingleBits=uiSingleBits*4;
    16231616      }
    1624 #endif
    16251617      dSingleCost       = m_pcRdCost->calcRdCost( uiSingleBits, uiSingleDistY + uiSingleDistC );
    16261618    }
     
    30963088  Int iHeight = 0;
    30973089
    3098 #if 0 //REF_IDX_FRAMEWORK  // HM bug fix
    3099   for( UInt uiMergeCand = 0; uiMergeCand < pcCU->getSlice()->getMaxNumMergeCand(); ++uiMergeCand )
    3100   {
    3101     uhInterDirNeighbours[uiMergeCand] = 0;
    3102     cMvFieldNeighbours[0 + 2*uiMergeCand].setMvField(TComMv(), NOT_VALID);
    3103     cMvFieldNeighbours[1 + 2*uiMergeCand].setMvField(TComMv(), NOT_VALID);
    3104   }
    3105 #endif
    31063090  pcCU->getPartIndexAndSize( iPUIdx, uiAbsPartIdx, iWidth, iHeight );
    31073091  UInt uiDepth = pcCU->getDepth( uiAbsPartIdx );
     
    32803264    UInt          uiBitsTempL0[MAX_NUM_REF];
    32813265
    3282 #if L0034_COMBINED_LIST_CLEANUP
    32833266    TComMv        mvValidList1;
    32843267    Int           refIdxValidList1 = 0;
    32853268    UInt          bitsValidList1 = MAX_UINT;
    32863269    UInt          costValidList1 = MAX_UINT;
    3287 #endif
    32883270
    32893271    xGetBlkBits( ePartSize, pcCU->getSlice()->isInterP(), iPartIdx, uiLastMode, uiMbBits);
     
    33493331        uiBitsTemp += m_auiMVPIdxCost[aaiMvpIdx[iRefList][iRefIdxTemp]][AMVP_MAX_NUM_CANDS];
    33503332#if ZERO_MVD_EST
    3351 #if L0034_COMBINED_LIST_CLEANUP
    33523333        if ( iRefList == 0 || pcCU->getSlice()->getList1IdxToList0Idx( iRefIdxTemp ) < 0 )
    3353 #else
    3354         if ((iRefList != 1 || !pcCU->getSlice()->getNoBackPredFlag()) &&
    3355             (pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) <= 0 || pcCU->getSlice()->getRefIdxOfLC(eRefPicList, iRefIdxTemp)>=0))
    3356 #endif
    33573334        {
    33583335          uiZeroMvdBitsTemp = uiBitsTemp;
     
    33743351       
    33753352#if GPB_SIMPLE_UNI
    3376 #if L0034_COMBINED_LIST_CLEANUP
    33773353        if ( iRefList == 1 )    // list 1
    33783354        {
     
    33993375        }
    34003376#else
    3401         if ( pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0)
    3402         {
    3403           if ( iRefList && ( pcCU->getSlice()->getNoBackPredFlag() || (pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0 && !pcCU->getSlice()->getNoBackPredFlag() && pcCU->getSlice()->getRefIdxOfL0FromRefIdxOfL1(iRefIdxTemp)>=0 ) ) )
    3404             {
    3405               if ( pcCU->getSlice()->getNoBackPredFlag() )
    3406               {
    3407                 cMvTemp[1][iRefIdxTemp] = cMvTemp[0][iRefIdxTemp];
    3408                 uiCostTemp = uiCostTempL0[iRefIdxTemp];
    3409                 /*first subtract the bit-rate part of the cost of the other list*/
    3410                 uiCostTemp -= m_pcRdCost->getCost( uiBitsTempL0[iRefIdxTemp] );
    3411               }
    3412               else
    3413               {
    3414                 cMvTemp[1][iRefIdxTemp] = cMvTemp[0][pcCU->getSlice()->getRefIdxOfL0FromRefIdxOfL1(iRefIdxTemp)];
    3415                 uiCostTemp = uiCostTempL0[pcCU->getSlice()->getRefIdxOfL0FromRefIdxOfL1(iRefIdxTemp)];
    3416                 /*first subtract the bit-rate part of the cost of the other list*/
    3417                 uiCostTemp -= m_pcRdCost->getCost( uiBitsTempL0[pcCU->getSlice()->getRefIdxOfL0FromRefIdxOfL1(iRefIdxTemp)] );
    3418               }
    3419               /*correct the bit-rate part of the current ref*/
    3420               m_pcRdCost->setPredictor  ( cMvPred[iRefList][iRefIdxTemp] );
    3421               uiBitsTemp += m_pcRdCost->getBits( cMvTemp[1][iRefIdxTemp].getHor(), cMvTemp[1][iRefIdxTemp].getVer() );
    3422               /*calculate the correct cost*/
    3423               uiCostTemp += m_pcRdCost->getCost( uiBitsTemp );
    3424             }
    3425             else
    3426             {
    3427               xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp );
    3428             }
    3429         }
    3430         else
    3431         {
    3432           if (iRefList && pcCU->getSlice()->getNoBackPredFlag())
    3433           {
    3434             uiCostTemp = MAX_UINT;
    3435             cMvTemp[1][iRefIdxTemp] = cMvTemp[0][iRefIdxTemp];
    3436           }
    3437           else
    3438           {
    3439             xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp );
    3440           }       
    3441         }
    3442 #endif
    3443 #else
    34443377        xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp );
    34453378#endif
     
    34473380        xCheckBestMVP(pcCU, eRefPicList, cMvTemp[iRefList][iRefIdxTemp], cMvPred[iRefList][iRefIdxTemp], aaiMvpIdx[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp);
    34483381
    3449 #if L0034_COMBINED_LIST_CLEANUP
    34503382        if ( iRefList == 0 )
    34513383        {
     
    34723404          refIdxValidList1 = iRefIdxTemp;
    34733405        }
    3474 #else
    3475         if(pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0 && !pcCU->getSlice()->getNoBackPredFlag())
    3476         {
    3477           if(iRefList==REF_PIC_LIST_0)
    3478           {
    3479             uiCostTempL0[iRefIdxTemp] = uiCostTemp;
    3480             uiBitsTempL0[iRefIdxTemp] = uiBitsTemp;
    3481             if(pcCU->getSlice()->getRefIdxOfLC(REF_PIC_LIST_0, iRefIdxTemp)<0)
    3482             {
    3483               uiCostTemp = MAX_UINT;
    3484             }
    3485           }
    3486           else
    3487           {
    3488             if(pcCU->getSlice()->getRefIdxOfLC(REF_PIC_LIST_1, iRefIdxTemp)<0)
    3489             {
    3490               uiCostTemp = MAX_UINT;
    3491             }           
    3492           }
    3493         }
    3494 
    3495 #if ENCODER_BUGFIX
    3496         if ( ( iRefList == 0 && uiCostTemp < uiCost[iRefList] ) ||
    3497             ( iRefList == 1 &&  pcCU->getSlice()->getNoBackPredFlag() && iRefIdxTemp == iRefIdx[0] ) ||
    3498             ( iRefList == 1 && !pcCU->getSlice()->getNoBackPredFlag() && uiCostTemp < uiCost[iRefList] ) )
    3499 #else
    3500         if ( ( iRefList == 0 && uiCostTemp < uiCost[iRefList] ) ||
    3501             ( iRefList == 1 &&  pcCU->getSlice()->getNoBackPredFlag() && iRefIdxTemp == iRefIdx[0] ) ||
    3502             ( iRefList == 1 && (pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0) && (iRefIdxTemp==0 || iRefIdxTemp == iRefIdx[0]) && !pcCU->getSlice()->getNoBackPredFlag() && (iRefIdxTemp == pcCU->getSlice()->getRefIdxOfL0FromRefIdxOfL1(iRefIdxTemp)) ) ||
    3503             ( iRefList == 1 && !pcCU->getSlice()->getNoBackPredFlag() && uiCostTemp < uiCost[iRefList] ) )
    3504 #endif
    3505           {
    3506             uiCost[iRefList] = uiCostTemp;
    3507             uiBits[iRefList] = uiBitsTemp; // storing for bi-prediction
    3508            
    3509             // set motion
    3510             cMv[iRefList]     = cMvTemp[iRefList][iRefIdxTemp];
    3511             iRefIdx[iRefList] = iRefIdxTemp;
    3512             pcCU->getCUMvField(eRefPicList)->setAllMv( cMv[iRefList], ePartSize, uiPartAddr, 0, iPartIdx );
    3513             pcCU->getCUMvField(eRefPicList)->setAllRefIdx( iRefIdx[iRefList], ePartSize, uiPartAddr, 0, iPartIdx );
    3514 
    3515             if(!pcCU->getSlice()->getMvdL1ZeroFlag())
    3516             {
    3517               // storing list 1 prediction signal for iterative bi-directional prediction
    3518               if ( eRefPicList == REF_PIC_LIST_1 )
    3519               {
    3520                 TComYuv*  pcYuvPred = &m_acYuvPred[iRefList];
    3521                 motionCompensation ( pcCU, pcYuvPred, eRefPicList, iPartIdx );
    3522               }
    3523               if ( (pcCU->getSlice()->getNoBackPredFlag() || (pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0 && pcCU->getSlice()->getRefIdxOfL0FromRefIdxOfL1(0)==0 )) && eRefPicList == REF_PIC_LIST_0 )
    3524               {
    3525                 TComYuv*  pcYuvPred = &m_acYuvPred[iRefList];
    3526                 motionCompensation ( pcCU, pcYuvPred, eRefPicList, iPartIdx );
    3527               }
    3528             }
    3529           }
    3530 #endif
    35313406      }
    35323407    }
     
    35963471       
    35973472        Int         iRefList    = iIter % 2;
    3598 #if L0034_COMBINED_LIST_CLEANUP
    35993473        if ( m_pcEncCfg->getUseFastEnc() )
    36003474        {
     
    36193493          motionCompensation ( pcCU, pcYuvPred, RefPicList(1-iRefList), iPartIdx );
    36203494        }
    3621 #else
    3622         if ( m_pcEncCfg->getUseFastEnc() && (pcCU->getSlice()->getNoBackPredFlag() || (pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0 && pcCU->getSlice()->getRefIdxOfL0FromRefIdxOfL1(0)==0 )) )
    3623         {
    3624           iRefList = 1;
    3625         }
    3626 #endif
    36273495        RefPicList  eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 );
    36283496
     
    37853653    UInt uiMEBits = 0;
    37863654    // Set Motion Field_
    3787 #if L0034_COMBINED_LIST_CLEANUP
    37883655    cMv[1] = mvValidList1;
    37893656    iRefIdx[1] = refIdxValidList1;
    37903657    uiBits[1] = bitsValidList1;
    37913658    uiCost[1] = costValidList1;
    3792 #else
    3793     if ( pcCU->getSlice()->getNoBackPredFlag() || (pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0 && pcCU->getSlice()->getRefIdxOfL0FromRefIdxOfL1(0)==0 ) )
    3794     {
    3795       uiCost[1] = MAX_UINT;
    3796     }
    3797 #endif
    37983659#if AMP_MRG
    37993660    if (bTestNormalMC)
  • branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncSlice.cpp

    r296 r302  
    425425  rpcSlice->setNumRefIdx(REF_PIC_LIST_1,m_pcCfg->getGOPEntry(iGOPid).m_numRefPicsActive);
    426426 
    427 #if L0386_DB_METRIC
    428427  if ( m_pcCfg->getDeblockingFilterMetric() )
    429428  {
     
    433432    rpcSlice->setDeblockingFilterTcOffsetDiv2( 0 );
    434433  } else
    435 #endif
    436434  if (rpcSlice->getPPS()->getDeblockingFilterControlPresentFlag())
    437435  {
     
    519517  // store lambda
    520518  slice->setSliceQp( sliceQP );
    521 #if L0033_RC_BUGFIX
    522519  slice->setSliceQpBase ( sliceQP );
    523 #endif
    524520  m_pcRdCost ->setLambda( lambda );
    525521#if WEIGHTED_CHROMA_DISTORTION
     
    828824/** \param rpcPic   picture class
    829825 */
     826#if RATE_CONTROL_INTRA
     827Void TEncSlice::calCostSliceI(TComPic*& rpcPic)
     828{
     829  UInt    uiCUAddr;
     830  UInt    uiStartCUAddr;
     831  UInt    uiBoundingCUAddr;
     832  Int     iSumHad, shift = g_bitDepthY-8, offset = (shift>0)?(1<<(shift-1)):0;;
     833  Double  iSumHadSlice = 0;
     834
     835  rpcPic->getSlice(getSliceIdx())->setSliceSegmentBits(0);
     836  TComSlice* pcSlice            = rpcPic->getSlice(getSliceIdx());
     837  xDetermineStartAndBoundingCUAddr ( uiStartCUAddr, uiBoundingCUAddr, rpcPic, false );
     838
     839  UInt uiEncCUOrder;
     840  uiCUAddr = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU());
     841  for( uiEncCUOrder = uiStartCUAddr/rpcPic->getNumPartInCU();
     842       uiEncCUOrder < (uiBoundingCUAddr+(rpcPic->getNumPartInCU()-1))/rpcPic->getNumPartInCU();
     843       uiCUAddr = rpcPic->getPicSym()->getCUOrderMap(++uiEncCUOrder) )
     844  {
     845    // initialize CU encoder
     846    TComDataCU*& pcCU = rpcPic->getCU( uiCUAddr );
     847    pcCU->initCU( rpcPic, uiCUAddr );
     848
     849    Int height  = min( pcSlice->getSPS()->getMaxCUHeight(),pcSlice->getSPS()->getPicHeightInLumaSamples() - uiCUAddr / rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUHeight() );
     850    Int width   = min( pcSlice->getSPS()->getMaxCUWidth(),pcSlice->getSPS()->getPicWidthInLumaSamples() - uiCUAddr % rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUWidth() );
     851
     852    iSumHad = m_pcCuEncoder->updateLCUDataISlice(pcCU, uiCUAddr, width, height);
     853
     854    (m_pcRateCtrl->getRCPic()->getLCU(uiCUAddr)).m_costIntra=(iSumHad+offset)>>shift;
     855    iSumHadSlice += (m_pcRateCtrl->getRCPic()->getLCU(uiCUAddr)).m_costIntra;
     856
     857  }
     858  m_pcRateCtrl->getRCPic()->setTotalIntraCost(iSumHadSlice);
     859}
     860#endif
     861
    830862Void TEncSlice::compressSlice( TComPic*& rpcPic )
    831863{
     
    10911123        Double bpp       = -1.0;
    10921124
     1125#if M0036_RC_IMPROVEMENT
     1126        if ( ( rpcPic->getSlice( 0 )->getSliceType() == I_SLICE && m_pcCfg->getForceIntraQP() ) || !m_pcCfg->getLCULevelRC() )
     1127#else
    10931128        if ( rpcPic->getSlice( 0 )->getSliceType() == I_SLICE || !m_pcCfg->getLCULevelRC() )
     1129#endif
    10941130        {
    10951131          estQP = pcSlice->getSliceQp();
     
    10971133        else
    10981134        {
     1135#if RATE_CONTROL_INTRA
     1136          bpp = m_pcRateCtrl->getRCPic()->getLCUTargetBpp(pcSlice->getSliceType());
     1137          if ( rpcPic->getSlice( 0 )->getSliceType() == I_SLICE)
     1138          {
     1139            estLambda = m_pcRateCtrl->getRCPic()->getLCUEstLambdaAndQP(bpp, pcSlice->getSliceQp(), &estQP);
     1140          }
     1141          else
     1142          {
     1143            estLambda = m_pcRateCtrl->getRCPic()->getLCUEstLambda( bpp );
     1144            estQP     = m_pcRateCtrl->getRCPic()->getLCUEstQP    ( estLambda, pcSlice->getSliceQp() );
     1145          }
     1146#else
    10991147          bpp       = m_pcRateCtrl->getRCPic()->getLCUTargetBpp();
    11001148          estLambda = m_pcRateCtrl->getRCPic()->getLCUEstLambda( bpp );
    11011149          estQP     = m_pcRateCtrl->getRCPic()->getLCUEstQP    ( estLambda, pcSlice->getSliceQp() );
     1150#endif
     1151
    11021152          estQP     = Clip3( -pcSlice->getSPS()->getQpBDOffsetY(), MAX_QP, estQP );
    11031153
    11041154          m_pcRdCost->setLambda(estLambda);
     1155#if M0036_RC_IMPROVEMENT
     1156#if RDOQ_CHROMA_LAMBDA
     1157          // set lambda for RDOQ
     1158          Double weight=m_pcRdCost->getChromaWeight();
     1159          m_pcTrQuant->setLambda( estLambda, estLambda / weight );
     1160#else
     1161          m_pcTrQuant->setLambda( estLambda );
     1162#endif
     1163#endif
    11051164        }
    11061165
    11071166        m_pcRateCtrl->setRCQP( estQP );
    1108 #if L0033_RC_BUGFIX
    11091167        pcCU->getSlice()->setSliceQpBase( estQP );
    1110 #endif
    11111168      }
    11121169#endif
     
    11151172      m_pcCuEncoder->compressCU( pcCU );
    11161173
     1174#if !TICKET_1090_FIX
    11171175#if RATE_CONTROL_LAMBDA_DOMAIN
    11181176      if ( m_pcCfg->getUseRateCtrl() )
    11191177      {
     1178#if !M0036_RC_IMPROVEMENT
    11201179        UInt SAD    = m_pcCuEncoder->getLCUPredictionSAD();
    11211180        Int height  = min( pcSlice->getSPS()->getMaxCUHeight(),pcSlice->getSPS()->getPicHeightInLumaSamples() - uiCUAddr / rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUHeight() );
     
    11241183        MAD = MAD * MAD;
    11251184        ( m_pcRateCtrl->getRCPic()->getLCU(uiCUAddr) ).m_MAD = MAD;
     1185#endif
    11261186
    11271187        Int actualQP        = g_RCInvalidQPValue;
     
    11471207        }
    11481208        m_pcRdCost->setLambda(oldLambda);
    1149 
     1209#if RATE_CONTROL_INTRA
     1210        m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda,
     1211          pcCU->getSlice()->getSliceType() == I_SLICE ? 0 : m_pcCfg->getLCULevelRC() );
     1212#else
    11501213        m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda, m_pcCfg->getLCULevelRC() );
    1151       }
     1214#endif
     1215      }
     1216#endif
    11521217#endif
    11531218     
     
    11831248        }
    11841249      }
     1250
     1251#if TICKET_1090_FIX
     1252#if RATE_CONTROL_LAMBDA_DOMAIN
     1253      if ( m_pcCfg->getUseRateCtrl() )
     1254      {
     1255#if !M0036_RC_IMPROVEMENT
     1256        UInt SAD    = m_pcCuEncoder->getLCUPredictionSAD();
     1257        Int height  = min( pcSlice->getSPS()->getMaxCUHeight(),pcSlice->getSPS()->getPicHeightInLumaSamples() - uiCUAddr / rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUHeight() );
     1258        Int width   = min( pcSlice->getSPS()->getMaxCUWidth(),pcSlice->getSPS()->getPicWidthInLumaSamples() - uiCUAddr % rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUWidth() );
     1259        Double MAD = (Double)SAD / (Double)(height * width);
     1260        MAD = MAD * MAD;
     1261        ( m_pcRateCtrl->getRCPic()->getLCU(uiCUAddr) ).m_MAD = MAD;
     1262#endif
     1263
     1264        Int actualQP        = g_RCInvalidQPValue;
     1265        Double actualLambda = m_pcRdCost->getLambda();
     1266        Int actualBits      = pcCU->getTotalBits();
     1267        Int numberOfEffectivePixels    = 0;
     1268        for ( Int idx = 0; idx < rpcPic->getNumPartInCU(); idx++ )
     1269        {
     1270          if ( pcCU->getPredictionMode( idx ) != MODE_NONE && ( !pcCU->isSkipped( idx ) ) )
     1271          {
     1272            numberOfEffectivePixels = numberOfEffectivePixels + 16;
     1273            break;
     1274          }
     1275        }
     1276
     1277        if ( numberOfEffectivePixels == 0 )
     1278        {
     1279          actualQP = g_RCInvalidQPValue;
     1280        }
     1281        else
     1282        {
     1283          actualQP = pcCU->getQP( 0 );
     1284        }
     1285        m_pcRdCost->setLambda(oldLambda);
     1286
     1287#if RATE_CONTROL_INTRA
     1288        m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda,
     1289          pcCU->getSlice()->getSliceType() == I_SLICE ? 0 : m_pcCfg->getLCULevelRC() );
     1290#else
     1291        m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda, m_pcCfg->getLCULevelRC() );
     1292#endif
     1293      }
     1294#endif
     1295#endif
    11851296    }
    11861297    // other case: encodeCU is not called
  • branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncSlice.h

    r191 r302  
    132132  Void    precompressSlice    ( TComPic*& rpcPic                                );      ///< precompress slice for multi-loop opt.
    133133  Void    compressSlice       ( TComPic*& rpcPic                                );      ///< analysis stage of slice
     134#if RATE_CONTROL_INTRA
     135  Void    calCostSliceI       ( TComPic*& rpcPic );
     136#endif
    134137  Void    encodeSlice         ( TComPic*& rpcPic, TComOutputBitstream* pcSubstreams  );
    135138 
  • branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncTop.cpp

    r291 r302  
    313313  /* set the VPS profile information */
    314314  *m_cVPS.getPTL() = *m_cSPS.getPTL();
    315 #if L0043_TIMING_INFO
    316315  m_cVPS.getTimingInfo()->setTimingInfoPresentFlag       ( false );
    317 #endif
    318316  // initialize PPS
    319317  m_cPPS.setSPS(&m_cSPS);
     
    615613  profileTierLevel.setProfileIdc(m_profile);
    616614  profileTierLevel.setProfileCompatibilityFlag(m_profile, 1);
    617 #if L0046_CONSTRAINT_FLAGS
    618615  profileTierLevel.setProgressiveSourceFlag(m_progressiveSourceFlag);
    619616  profileTierLevel.setInterlacedSourceFlag(m_interlacedSourceFlag);
    620617  profileTierLevel.setNonPackedConstraintFlag(m_nonPackedConstraintFlag);
    621618  profileTierLevel.setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag);
    622 #endif
    623619 
    624620  if (m_profile == Profile::MAIN10 && g_bitDepthY == 8 && g_bitDepthC == 8)
     
    670666
    671667  m_cSPS.setMaxTrSize   ( 1 << m_uiQuadtreeTULog2MaxSize );
    672 #if !L0034_COMBINED_LIST_CLEANUP
    673   m_cSPS.setUseLComb    ( m_bUseLComb           );
    674 #endif
    675668 
    676669  Int i;
     
    737730    pcVUI->setFieldSeqFlag(false);
    738731    pcVUI->setHrdParametersPresentFlag(false);
    739 #if L0043_TIMING_INFO
    740732    pcVUI->getTimingInfo()->setPocProportionalToTimingFlag(getPocProportionalToTimingFlag());
    741733    pcVUI->getTimingInfo()->setNumTicksPocDiffOneMinus1   (getNumTicksPocDiffOneMinus1()   );
    742 #else
    743     pcVUI->setPocProportionalToTimingFlag(getPocProportionalToTimingFlag());
    744     pcVUI->setNumTicksPocDiffOneMinus1   (getNumTicksPocDiffOneMinus1()   );
    745 #endif
    746734    pcVUI->setBitstreamRestrictionFlag(getBitstreamRestrictionFlag());
    747735    pcVUI->setTilesFixedStructureFlag(getTilesFixedStructureFlag());
     
    816804  m_cPPS.setOutputFlagPresentFlag( false );
    817805  m_cPPS.setSignHideFlag(getSignHideFlag());
    818 #if L0386_DB_METRIC
    819806  if ( getDeblockingFilterMetric() )
    820807  {
     
    829816  m_cPPS.setDeblockingFilterControlPresentFlag (m_DeblockingFilterControlPresent );
    830817  }
    831 #else
    832   m_cPPS.setDeblockingFilterControlPresentFlag (m_DeblockingFilterControlPresent );
    833 #endif
    834818  m_cPPS.setLog2ParallelMergeLevelMinus2   (m_log2ParallelMergeLevelMinus2 );
    835819  m_cPPS.setCabacInitPresentFlag(CABAC_INIT_PRESENT_FLAG);
     
    855839    }
    856840  }
    857 #if L0323_LIMIT_DEFAULT_LIST_SIZE
    858841  assert(bestPos <= 15);
    859 #endif
    860842  m_cPPS.setNumRefIdxL0DefaultActive(bestPos);
    861843  m_cPPS.setNumRefIdxL1DefaultActive(bestPos);
     
    11041086}
    11051087
    1106 #if L0208_SOP_DESCRIPTION_SEI
    11071088Int TEncTop::getReferencePictureSetIdxForSOP(TComSlice* slice, Int POCCurr, Int GOPid )
    11081089{
     
    11341115  return rpsIdx;
    11351116}
    1136 #endif
    11371117
    11381118Void  TEncTop::xInitPPSforTiles()
  • branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncTop.h

    r297 r302  
    199199  TComPPS*                getPPS                () { return  &m_cPPS;                 }
    200200  Void selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid );
    201 #if L0208_SOP_DESCRIPTION_SEI
    202201  Int getReferencePictureSetIdxForSOP(TComSlice* slice, Int POCCurr, Int GOPid );
    203 #endif
    204202  TComScalingList*        getScalingList        () { return  &m_scalingList;         }
    205203#if SVC_EXTENSION
Note: See TracChangeset for help on using the changeset viewer.