Ticket #1354: jctvc_hm_enc.patch

File jctvc_hm_enc.patch, 17.0 KB (added by kolya, 10 years ago)

encoder patch

  • source/Lib/TLibEncoder/TEncCavlc.cpp

    diff --git a/source/Lib/TLibEncoder/TEncCavlc.cpp b/source/Lib/TLibEncoder/TEncCavlc.cpp
    index ccd9007..1bb6679 100644
    a b  
    266266
    267267            if (pcPPS->getUseTransformSkip())
    268268            {
    269               WRITE_UVLC( pcPPS->getTransformSkipLog2MaxSize()-2,                 "log2_transform_skip_max_size_minus2");
     269              WRITE_UVLC( pcPPS->getTransformSkipLog2MaxSize()-2,                 "log2_max_transform_skip_block_size_minus2");
    270270            }
    271271
    272             WRITE_FLAG((pcPPS->getUseCrossComponentPrediction() ? 1 : 0),         "cross_component_prediction_flag" );
     272            WRITE_FLAG((pcPPS->getUseCrossComponentPrediction() ? 1 : 0),         "cross_component_prediction_enabled_flag" );
    273273
    274             WRITE_FLAG(UInt(pcPPS->getChromaQpAdjTableSize() > 0),                "chroma_qp_adjustment_enabled_flag" );
     274            WRITE_FLAG(UInt(pcPPS->getChromaQpAdjTableSize() > 0),                "chroma_qp_offset_list_enabled_flag " );
    275275            if (pcPPS->getChromaQpAdjTableSize() > 0)
    276276            {
    277               WRITE_UVLC(pcPPS->getMaxCuChromaQpAdjDepth(),                       "diff_cu_chroma_qp_adjustment_depth");
    278               WRITE_UVLC(pcPPS->getChromaQpAdjTableSize() - 1,                    "chroma_qp_adjustment_table_size_minus1");
     277              WRITE_UVLC(pcPPS->getMaxCuChromaQpAdjDepth(),                       "diff_cu_chroma_qp_offset_depth");
     278              WRITE_UVLC(pcPPS->getChromaQpAdjTableSize() - 1,                    "chroma_qp_offset_list_len_minus1");
    279279              /* skip zero index */
    280280              for (Int chromaQpAdjustmentIndex = 1; chromaQpAdjustmentIndex <= pcPPS->getChromaQpAdjTableSize(); chromaQpAdjustmentIndex++)
    281281              {
    282                 WRITE_SVLC(pcPPS->getChromaQpAdjTableAt(chromaQpAdjustmentIndex).u.comp.CbOffset,     "cb_qp_adjustnemt[i]");
    283                 WRITE_SVLC(pcPPS->getChromaQpAdjTableAt(chromaQpAdjustmentIndex).u.comp.CrOffset,     "cr_qp_adjustnemt[i]");
     282                WRITE_SVLC(pcPPS->getChromaQpAdjTableAt(chromaQpAdjustmentIndex).u.comp.CbOffset,     "cb_qp_offset_list[i]");
     283                WRITE_SVLC(pcPPS->getChromaQpAdjTableAt(chromaQpAdjustmentIndex).u.comp.CrOffset,     "cr_qp_offset_list[i]");
    284284              }
    285285            }
    286286
    287             WRITE_UVLC( pcPPS->getSaoOffsetBitShift(CHANNEL_TYPE_LUMA),           "sao_luma_bit_shift"   );
    288             WRITE_UVLC( pcPPS->getSaoOffsetBitShift(CHANNEL_TYPE_CHROMA),         "sao_chroma_bit_shift" );
     287            WRITE_UVLC( pcPPS->getSaoOffsetBitShift(CHANNEL_TYPE_LUMA),           "log2_sao_offset_scale_luma"   );
     288            WRITE_UVLC( pcPPS->getSaoOffsetBitShift(CHANNEL_TYPE_CHROMA),         "log2_sao_offset_scale_chroma" );
    289289            break;
    290290          default:
    291291            assert(pps_extension_flags[i]==false); // Should never get here with an active PPS extension flag.
     
    326326    {
    327327      WRITE_CODE(pcVUI->getColourPrimaries(), 8,                "colour_primaries");
    328328      WRITE_CODE(pcVUI->getTransferCharacteristics(), 8,        "transfer_characteristics");
    329       WRITE_CODE(pcVUI->getMatrixCoefficients(), 8,             "matrix_coefficients");
     329      WRITE_CODE(pcVUI->getMatrixCoefficients(), 8,             "matrix_coeffs");
    330330    }
    331331  }
    332332
     
    376376    WRITE_FLAG(pcVUI->getRestrictedRefPicListsFlag(),           "restricted_ref_pic_lists_flag");
    377377    WRITE_UVLC(pcVUI->getMinSpatialSegmentationIdc(),           "min_spatial_segmentation_idc");
    378378    WRITE_UVLC(pcVUI->getMaxBytesPerPicDenom(),                 "max_bytes_per_pic_denom");
    379     WRITE_UVLC(pcVUI->getMaxBitsPerMinCuDenom(),                "max_bits_per_mincu_denom");
     379    WRITE_UVLC(pcVUI->getMaxBitsPerMinCuDenom(),                "max_bits_per_min_cu_denom");
    380380    WRITE_UVLC(pcVUI->getLog2MaxMvLengthHorizontal(),           "log2_max_mv_length_horizontal");
    381381    WRITE_UVLC(pcVUI->getLog2MaxMvLengthVertical(),             "log2_max_mv_length_vertical");
    382382  }
     
    390390    WRITE_FLAG( hrd->getVclHrdParametersPresentFlag() ? 1 : 0 ,  "vcl_hrd_parameters_present_flag" );
    391391    if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() )
    392392    {
    393       WRITE_FLAG( hrd->getSubPicCpbParamsPresentFlag() ? 1 : 0,  "sub_pic_cpb_params_present_flag" );
     393      WRITE_FLAG( hrd->getSubPicCpbParamsPresentFlag() ? 1 : 0,  "sub_pic_hrd_params_present_flag" );
    394394      if( hrd->getSubPicCpbParamsPresentFlag() )
    395395      {
    396396        WRITE_CODE( hrd->getTickDivisorMinus2(), 8,              "tick_divisor_minus2" );
     
    497497  for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++)
    498498  {
    499499    WRITE_UVLC( pcSPS->getMaxDecPicBuffering(i) - 1,       "sps_max_dec_pic_buffering_minus1[i]" );
    500     WRITE_UVLC( pcSPS->getNumReorderPics(i),               "sps_num_reorder_pics[i]" );
     500    WRITE_UVLC( pcSPS->getNumReorderPics(i),               "sps_max_num_reorder_pics[i]" );
    501501    WRITE_UVLC( pcSPS->getMaxLatencyIncrease(i),           "sps_max_latency_increase_plus1[i]" );
    502502    if (!subLayerOrderingInfoPresentFlag)
    503503    {
     
    506506  }
    507507  assert( pcSPS->getMaxCUWidth() == pcSPS->getMaxCUHeight() );
    508508
    509   WRITE_UVLC( pcSPS->getLog2MinCodingBlockSize() - 3,                                "log2_min_coding_block_size_minus3" );
    510   WRITE_UVLC( pcSPS->getLog2DiffMaxMinCodingBlockSize(),                             "log2_diff_max_min_coding_block_size" );
    511   WRITE_UVLC( pcSPS->getQuadtreeTULog2MinSize() - 2,                                 "log2_min_transform_block_size_minus2" );
    512   WRITE_UVLC( pcSPS->getQuadtreeTULog2MaxSize() - pcSPS->getQuadtreeTULog2MinSize(), "log2_diff_max_min_transform_block_size" );
     509  WRITE_UVLC( pcSPS->getLog2MinCodingBlockSize() - 3,                                "log2_min_luma_coding_block_size_minus3" );
     510  WRITE_UVLC( pcSPS->getLog2DiffMaxMinCodingBlockSize(),                             "log2_diff_max_min_luma_coding_block_size " );
     511  WRITE_UVLC( pcSPS->getQuadtreeTULog2MinSize() - 2,                                 "log2_min_luma_transform_block_size_minus2" );
     512  WRITE_UVLC( pcSPS->getQuadtreeTULog2MaxSize() - pcSPS->getQuadtreeTULog2MinSize(), "log2_diff_max_min_luma_transform_block_size " );
    513513  WRITE_UVLC( pcSPS->getQuadtreeTUMaxDepthInter() - 1,                               "max_transform_hierarchy_depth_inter" );
    514514  WRITE_UVLC( pcSPS->getQuadtreeTUMaxDepthIntra() - 1,                               "max_transform_hierarchy_depth_intra" );
    515515  WRITE_FLAG( pcSPS->getScalingListFlag() ? 1 : 0,                                   "scaling_list_enabled_flag" );
     
    547547  WRITE_FLAG( pcSPS->getLongTermRefsPresent() ? 1 : 0,         "long_term_ref_pics_present_flag" );
    548548  if (pcSPS->getLongTermRefsPresent())
    549549  {
    550     WRITE_UVLC(pcSPS->getNumLongTermRefPicSPS(), "num_long_term_ref_pic_sps" );
     550    WRITE_UVLC(pcSPS->getNumLongTermRefPicSPS(), "num_long_term_ref_pics_sps" );
    551551    for (UInt k = 0; k < pcSPS->getNumLongTermRefPicSPS(); k++)
    552552    {
    553553      WRITE_CODE( pcSPS->getLtRefPicPocLsbSps(k), pcSPS->getBitsForPOC(), "lt_ref_pic_poc_lsb_sps");
     
    605605
    606606            WRITE_FLAG( (pcSPS->getUseResidualRotation() ? 1 : 0),                  "transform_skip_rotation_enabled_flag");
    607607            WRITE_FLAG( (pcSPS->getUseSingleSignificanceMapContext() ? 1 : 0),      "transform_skip_context_enabled_flag");
    608             WRITE_FLAG( (pcSPS->getUseResidualDPCM(RDPCM_SIGNAL_IMPLICIT) ? 1 : 0), "residual_dpcm_implicit_enabled_flag" );
    609             WRITE_FLAG( (pcSPS->getUseResidualDPCM(RDPCM_SIGNAL_EXPLICIT) ? 1 : 0), "residual_dpcm_explicit_enabled_flag" );
     608            WRITE_FLAG( (pcSPS->getUseResidualDPCM(RDPCM_SIGNAL_IMPLICIT) ? 1 : 0), "implicit_rdpcm_enabled_flag" );
     609            WRITE_FLAG( (pcSPS->getUseResidualDPCM(RDPCM_SIGNAL_EXPLICIT) ? 1 : 0), "explicit_rdpcm_enabled_flag" );
    610610            WRITE_FLAG( (pcSPS->getUseExtendedPrecision() ? 1 : 0),                 "extended_precision_processing_flag" );
    611611            WRITE_FLAG( (pcSPS->getDisableIntraReferenceSmoothing() ? 1 : 0),       "intra_smoothing_disabled_flag" );
    612             WRITE_FLAG( (pcSPS->getUseHighPrecisionPredictionWeighting() ? 1 : 0),  "high_precision_prediction_weighting_flag" );
    613             WRITE_FLAG( (pcSPS->getUseGolombRiceParameterAdaptation() ? 1 : 0),     "golomb_rice_parameter_adaptation_flag" );
     612            WRITE_FLAG( (pcSPS->getUseHighPrecisionPredictionWeighting() ? 1 : 0),  "high_precision_offsets_enabled_flag" );
     613            WRITE_FLAG( (pcSPS->getUseGolombRiceParameterAdaptation() ? 1 : 0),     "persistent_rice_adaptation_enabled_flag" );
    614614            WRITE_FLAG( (pcSPS->getAlignCABACBeforeBypass() ? 1 : 0),               "cabac_bypass_alignment_enabled_flag" );
    615615            break;
    616616          default:
     
    630630  WRITE_CODE( pcVPS->getMaxTLayers() - 1,           3,        "vps_max_sub_layers_minus1" );
    631631  WRITE_FLAG( pcVPS->getTemporalNestingFlag(),                "vps_temporal_id_nesting_flag" );
    632632  assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag());
    633   WRITE_CODE( 0xffff,                              16,        "vps_reserved_ffff_16bits" );
     633  WRITE_CODE( 0xffff,                              16,        "vps_reserved_0xffff_16bits" );
    634634  codePTL( pcVPS->getPTL(), true, pcVPS->getMaxTLayers() - 1 );
    635635  const Bool subLayerOrderingInfoPresentFlag = 1;
    636636  WRITE_FLAG(subLayerOrderingInfoPresentFlag,              "vps_sub_layer_ordering_info_present_flag");
    637637  for(UInt i=0; i <= pcVPS->getMaxTLayers()-1; i++)
    638638  {
    639639    WRITE_UVLC( pcVPS->getMaxDecPicBuffering(i) - 1,       "vps_max_dec_pic_buffering_minus1[i]" );
    640     WRITE_UVLC( pcVPS->getNumReorderPics(i),               "vps_num_reorder_pics[i]" );
     640    WRITE_UVLC( pcVPS->getNumReorderPics(i),               "vps_max_num_reorder_pics[i]" );
    641641    WRITE_UVLC( pcVPS->getMaxLatencyIncrease(i),           "vps_max_latency_increase_plus1[i]" );
    642642    if (!subLayerOrderingInfoPresentFlag)
    643643    {
     
    647647
    648648  assert( pcVPS->getNumHrdParameters() <= MAX_VPS_NUM_HRD_PARAMETERS );
    649649  assert( pcVPS->getMaxNuhReservedZeroLayerId() < MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1 );
    650   WRITE_CODE( pcVPS->getMaxNuhReservedZeroLayerId(), 6,     "vps_max_nuh_reserved_zero_layer_id" );
    651   WRITE_UVLC( pcVPS->getMaxOpSets() - 1,                    "vps_max_op_sets_minus1" );
     650  WRITE_CODE( pcVPS->getMaxNuhReservedZeroLayerId(), 6,     "vps_max_layer_id" );
     651  WRITE_UVLC( pcVPS->getMaxOpSets() - 1,                    "vps_num_layer_sets_minus1" );
    652652  for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getMaxOpSets() - 1 ); opsIdx ++ )
    653653  {
    654654    // Operation point set
     
    677677      for( UInt i = 0; i < pcVPS->getNumHrdParameters(); i ++ )
    678678      {
    679679        // Only applicable for version 1
    680         WRITE_UVLC( pcVPS->getHrdOpSetIdx( i ),                "hrd_op_set_idx" );
     680        WRITE_UVLC( pcVPS->getHrdOpSetIdx( i ),                "hrd_layer_set_idx" );
    681681        if( i > 0 )
    682682        {
    683683          WRITE_FLAG( pcVPS->getCprmsPresentFlag( i ) ? 1 : 0, "cprms_present_flag[i]" );
     
    733733  {
    734734    for (Int i = 0; i < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++)
    735735    {
    736       assert(!!"slice_reserved_undetermined_flag[]");
    737       WRITE_FLAG(0, "slice_reserved_undetermined_flag[]");
     736      assert(!!"slice_reserved_flag[]");
     737      WRITE_FLAG(0, "slice_reserved_flag[]");
    738738    }
    739739
    740740    WRITE_UVLC( pcSlice->getSliceType(),       "slice_type" );
     
    866866      }
    867867      if (pcSlice->getSPS()->getTMVPFlagsPresent())
    868868      {
    869         WRITE_FLAG( pcSlice->getEnableTMVPFlag() ? 1 : 0, "slice_temporal_mvp_enable_flag" );
     869        WRITE_FLAG( pcSlice->getEnableTMVPFlag() ? 1 : 0, "slice_temporal_mvp_enabled_flag" );
    870870      }
    871871    }
    872872    if(pcSlice->getSPS()->getUseSAO())
     
    996996    {
    997997      if (numberValidComponents > COMPONENT_Cb)
    998998      {
    999         WRITE_SVLC( pcSlice->getSliceChromaQpDelta(COMPONENT_Cb), "slice_qp_delta_cb" );
     999        WRITE_SVLC( pcSlice->getSliceChromaQpDelta(COMPONENT_Cb), "slice_cb_qp_offset" );
    10001000      }
    10011001      if (numberValidComponents > COMPONENT_Cr)
    10021002      {
    1003         WRITE_SVLC( pcSlice->getSliceChromaQpDelta(COMPONENT_Cr), "slice_qp_delta_cr" );
     1003        WRITE_SVLC( pcSlice->getSliceChromaQpDelta(COMPONENT_Cr), "slice_cr_qp_offset" );
    10041004      }
    10051005      assert(numberValidComponents <= COMPONENT_Cr+1);
    10061006    }
    10071007
    10081008    if (pcSlice->getPPS()->getChromaQpAdjTableSize() > 0)
    10091009    {
    1010       WRITE_FLAG(pcSlice->getUseChromaQpAdj(), "slice_chroma_qp_adjustment_enabled_flag");
     1010      WRITE_FLAG(pcSlice->getUseChromaQpAdj(), "slice_chroma_qp_offset_list_enabled_flag ");
    10111011    }
    10121012
    10131013    if (pcSlice->getPPS()->getDeblockingFilterControlPresentFlag())
     
    10371037  }
    10381038  if(pcSlice->getPPS()->getSliceHeaderExtensionPresentFlag())
    10391039  {
    1040     WRITE_UVLC(0,"slice_header_extension_length");
     1040    WRITE_UVLC(0,"slice_segment_header_extension_length");
    10411041  }
    10421042}
    10431043
     
    10811081}
    10821082Void TEncCavlc::codeProfileTier( const ProfileTierLevel* ptl )
    10831083{
    1084   WRITE_CODE( ptl->getProfileSpace(), 2 ,     "XXX_profile_space[]");
    1085   WRITE_FLAG( ptl->getTierFlag()==Level::HIGH, "XXX_tier_flag[]"    );
    1086   WRITE_CODE( Int(ptl->getProfileIdc()), 5 ,  "XXX_profile_idc[]"  );
     1084  WRITE_CODE( ptl->getProfileSpace(), 2 ,     "general_profile_space[]");
     1085  WRITE_FLAG( ptl->getTierFlag()==Level::HIGH, "general_tier_flag[]"    );
     1086  WRITE_CODE( Int(ptl->getProfileIdc()), 5 ,  "general_profile_idc[]"  );
    10871087  for(Int j = 0; j < 32; j++)
    10881088  {
    10891089    WRITE_FLAG( ptl->getProfileCompatibilityFlag(j), "XXX_profile_compatibility_flag[][j]");
     
    11071107    WRITE_FLAG(ptl->getIntraConstraintFlag(),        "general_intra_constraint_flag");
    11081108    WRITE_FLAG(0,                                    "general_one_picture_only_constraint_flag");
    11091109    WRITE_FLAG(ptl->getLowerBitRateConstraintFlag(), "general_lower_bit_rate_constraint_flag");
    1110     WRITE_CODE(0 , 16, "XXX_reserved_zero_35bits[0..15]");
    1111     WRITE_CODE(0 , 16, "XXX_reserved_zero_35bits[16..31]");
    1112     WRITE_CODE(0 ,  3, "XXX_reserved_zero_35bits[32..34]");
     1110    WRITE_CODE(0 , 16, "general_reserved_zero_35bits[0..15]");
     1111    WRITE_CODE(0 , 16, "general_reserved_zero_35bits[16..31]");
     1112    WRITE_CODE(0 ,  3, "general_reserved_zero_35bits[32..34]");
    11131113  }
    11141114  else
    11151115  {
    1116     WRITE_CODE(0x0000 , 16, "XXX_reserved_zero_44bits[0..15]");
    1117     WRITE_CODE(0x0000 , 16, "XXX_reserved_zero_44bits[16..31]");
    1118     WRITE_CODE(0x000  , 12, "XXX_reserved_zero_44bits[32..43]");
     1116    WRITE_CODE(0x0000 , 16, "general_reserved_zero_44bits[0..15]");
     1117    WRITE_CODE(0x0000 , 16, "general_reserved_zero_44bits[16..31]");
     1118    WRITE_CODE(0x000  , 12, "general_reserved_zero_44bits[32..43]");
    11191119  }
    11201120}
    11211121
     
    13571357          }
    13581358          bDenomCoded = true;
    13591359        }
    1360         WRITE_FLAG( wp[COMPONENT_Y].bPresentFlag, "luma_weight_lX_flag" );               // u(1): luma_weight_lX_flag
     1360        WRITE_FLAG( wp[COMPONENT_Y].bPresentFlag, "luma_weight_l0_flag" );               // u(1): luma_weight_l0_flag
    13611361        uiTotalSignalledWeightFlags += wp[COMPONENT_Y].bPresentFlag;
    13621362      }
    13631363      if (bChroma)
     
    13661366        {
    13671367          pcSlice->getWpScaling(eRefPicList, iRefIdx, wp);
    13681368          assert(wp[COMPONENT_Cb].bPresentFlag == wp[COMPONENT_Cr].bPresentFlag); // check the channel-type settings are consistent across components.
    1369           WRITE_FLAG( wp[COMPONENT_Cb].bPresentFlag, "chroma_weight_lX_flag" );           // u(1): chroma_weight_lX_flag
     1369          WRITE_FLAG( wp[COMPONENT_Cb].bPresentFlag, "chroma_weight_l0_flag" );           // u(1): chroma_weight_l0_flag
    13701370          uiTotalSignalledWeightFlags += 2*wp[COMPONENT_Cb].bPresentFlag;
    13711371        }
    13721372      }
     
    13771377        if ( wp[COMPONENT_Y].bPresentFlag )
    13781378        {
    13791379          Int iDeltaWeight = (wp[COMPONENT_Y].iWeight - (1<<wp[COMPONENT_Y].uiLog2WeightDenom));
    1380           WRITE_SVLC( iDeltaWeight, "delta_luma_weight_lX" );                            // se(v): delta_luma_weight_lX
    1381           WRITE_SVLC( wp[COMPONENT_Y].iOffset, "luma_offset_lX" );                       // se(v): luma_offset_lX
     1380          WRITE_SVLC( iDeltaWeight, "delta_luma_weight_l0" );                            // se(v): delta_luma_weight_l0
     1381          WRITE_SVLC( wp[COMPONENT_Y].iOffset, "luma_offset_l0" );                       // se(v): luma_offset_l0
    13821382        }
    13831383
    13841384        if ( bChroma )
     
    13891389            {
    13901390              assert(wp[COMPONENT_Cb].uiLog2WeightDenom == wp[COMPONENT_Cr].uiLog2WeightDenom);
    13911391              Int iDeltaWeight = (wp[j].iWeight - (1<<wp[COMPONENT_Cb].uiLog2WeightDenom));
    1392               WRITE_SVLC( iDeltaWeight, "delta_chroma_weight_lX" );            // se(v): delta_chroma_weight_lX
     1392              WRITE_SVLC( iDeltaWeight, "delta_chroma_weight_l0" );            // se(v): delta_chroma_weight_l0
    13931393
    13941394              Int range=pcSlice->getSPS()->getUseHighPrecisionPredictionWeighting() ? (1<<g_bitDepth[CHANNEL_TYPE_CHROMA])/2 : 128;
    13951395              Int pred = ( range - ( ( range*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) );
    13961396              Int iDeltaChroma = (wp[j].iOffset - pred);
    1397               WRITE_SVLC( iDeltaChroma, "delta_chroma_offset_lX" );            // se(v): delta_chroma_offset_lX
     1397              WRITE_SVLC( iDeltaChroma, "delta_chroma_offset_l0" );            // se(v): delta_chroma_offset_l0
    13981398            }
    13991399          }
    14001400        }