[x265] [PATCH] Modify TEncSbac structure to support multiple color space formats

Steve Borho steve at borho.org
Wed Jan 8 00:52:56 CET 2014


On Fri, Jan 3, 2014 at 7:07 AM, <ashok at multicorewareinc.com> wrote:

> # HG changeset patch
> # User ashok at multicorewareinc.com
> # Date 1388754455 -19800
> #      Fri Jan 03 18:37:35 2014 +0530
> # Node ID d1f5cad1ac2f4394616633751f1b885178848b49
> # Parent  be8c07a80a181f9a20d51abd01b90ac9fe94f4ea
> Modify TEncSbac structure to support multiple color space formats
>

the white-space changes make this more difficult to review than it should
be, but it looks ok


>
> diff -r be8c07a80a18 -r d1f5cad1ac2f source/Lib/TLibEncoder/TEncSbac.cpp
> --- a/source/Lib/TLibEncoder/TEncSbac.cpp       Fri Jan 03 18:36:37 2014
> +0530
> +++ b/source/Lib/TLibEncoder/TEncSbac.cpp       Fri Jan 03 18:37:35 2014
> +0530
> @@ -327,21 +327,21 @@
>
>  void TEncSbac::codeVPS(TComVPS* vps)
>  {
> -    WRITE_CODE(vps->getVPSId(),                    4,
>  "vps_video_parameter_set_id");
> -    WRITE_CODE(3,                                    2,
>  "vps_reserved_three_2bits");
> -    WRITE_CODE(0,                                    6,
>  "vps_reserved_zero_6bits");
> -    WRITE_CODE(vps->getMaxTLayers() - 1,           3,
>  "vps_max_sub_layers_minus1");
> -    WRITE_FLAG(vps->getTemporalNestingFlag(),
>  "vps_temporal_id_nesting_flag");
> +    WRITE_CODE(vps->getVPSId(),                    4,
> "vps_video_parameter_set_id");
> +    WRITE_CODE(3,                                  2,
> "vps_reserved_three_2bits");
> +    WRITE_CODE(0,                                  6,
> "vps_reserved_zero_6bits");
> +    WRITE_CODE(vps->getMaxTLayers() - 1,           3,
> "vps_max_sub_layers_minus1");
> +    WRITE_FLAG(vps->getTemporalNestingFlag(),
> "vps_temporal_id_nesting_flag");
>      assert(vps->getMaxTLayers() > 1 || vps->getTemporalNestingFlag());
> -    WRITE_CODE(0xffff,                              16,
>  "vps_reserved_ffff_16bits");
> +    WRITE_CODE(0xffff,                             16,
>  "vps_reserved_ffff_16bits");
>      codePTL(vps->getPTL(), true, vps->getMaxTLayers() - 1);
>      const bool subLayerOrderingInfoPresentFlag = 1;
> -    WRITE_FLAG(subLayerOrderingInfoPresentFlag,
>  "vps_sub_layer_ordering_info_present_flag");
> +    WRITE_FLAG(subLayerOrderingInfoPresentFlag,
> "vps_sub_layer_ordering_info_present_flag");
>      for (uint32_t i = 0; i <= vps->getMaxTLayers() - 1; i++)
>      {
> -        WRITE_UVLC(vps->getMaxDecPicBuffering(i) - 1,
> "vps_max_dec_pic_buffering_minus1[i]");
> -        WRITE_UVLC(vps->getNumReorderPics(i),
> "vps_num_reorder_pics[i]");
> -        WRITE_UVLC(vps->getMaxLatencyIncrease(i),
> "vps_max_latency_increase_plus1[i]");
> +        WRITE_UVLC(vps->getMaxDecPicBuffering(i) - 1,
> "vps_max_dec_pic_buffering_minus1[i]");
> +        WRITE_UVLC(vps->getNumReorderPics(i),
> "vps_num_reorder_pics[i]");
> +        WRITE_UVLC(vps->getMaxLatencyIncrease(i),
> "vps_max_latency_increase_plus1[i]");
>          if (!subLayerOrderingInfoPresentFlag)
>          {
>              break;
> @@ -365,7 +365,7 @@
>      }
>
>      TimingInfo *timingInfo = vps->getTimingInfo();
> -    WRITE_FLAG(timingInfo->getTimingInfoPresentFlag(),
>  "vps_timing_info_present_flag");
> +    WRITE_FLAG(timingInfo->getTimingInfoPresentFlag(),
>  "vps_timing_info_present_flag");
>      if (timingInfo->getTimingInfoPresentFlag())
>      {
>          WRITE_CODE(timingInfo->getNumUnitsInTick(), 32,
> "vps_num_units_in_tick");
> @@ -373,10 +373,10 @@
>          WRITE_FLAG(timingInfo->getPocProportionalToTimingFlag(),
>  "vps_poc_proportional_to_timing_flag");
>          if (timingInfo->getPocProportionalToTimingFlag())
>          {
> -            WRITE_UVLC(timingInfo->getNumTicksPocDiffOneMinus1(),
> "vps_num_ticks_poc_diff_one_minus1");
> +            WRITE_UVLC(timingInfo->getNumTicksPocDiffOneMinus1(),
> "vps_num_ticks_poc_diff_one_minus1");
>          }
>          vps->setNumHrdParameters(0);
> -        WRITE_UVLC(vps->getNumHrdParameters(),
> "vps_num_hrd_parameters");
> +        WRITE_UVLC(vps->getNumHrdParameters(),
>  "vps_num_hrd_parameters");
>
>          if (vps->getNumHrdParameters() > 0)
>          {
> @@ -459,9 +459,8 @@
>      codePTL(sps->getPTL(), 1, sps->getMaxTLayers() - 1);
>      WRITE_UVLC(sps->getSPSId(),
> "sps_seq_parameter_set_id");
>      WRITE_UVLC(sps->getChromaFormatIdc(),         "chroma_format_idc");
> -    assert(sps->getChromaFormatIdc() == 1);
> -    // in the first version chroma_format_idc can only be equal to 1
> (4:2:0)
> -    if (sps->getChromaFormatIdc() == 3)
> +
> +    if (sps->getChromaFormatIdc() == CHROMA_444)
>      {
>          WRITE_FLAG(0,
>  "separate_colour_plane_flag");
>      }
> @@ -479,13 +478,13 @@
>          WRITE_UVLC(conf.m_winBottomOffset /
> TComSPS::getWinUnitY(sps->getChromaFormatIdc()), "conf_win_bottom_offset");
>      }
>
> -    WRITE_UVLC(sps->getBitDepthY() - 8,
> "bit_depth_luma_minus8");
> -    WRITE_UVLC(sps->getBitDepthC() - 8,
> "bit_depth_chroma_minus8");
> +    WRITE_UVLC(sps->getBitDepthY() - 8,
>  "bit_depth_luma_minus8");
> +    WRITE_UVLC(sps->getBitDepthC() - 8,
>  "bit_depth_chroma_minus8");
>
>      WRITE_UVLC(sps->getBitsForPOC() - 4,
> "log2_max_pic_order_cnt_lsb_minus4");
>
>      const bool subLayerOrderingInfoPresentFlag = 1;
> -    WRITE_FLAG(subLayerOrderingInfoPresentFlag,
> "sps_sub_layer_ordering_info_present_flag");
> +    WRITE_FLAG(subLayerOrderingInfoPresentFlag,
>  "sps_sub_layer_ordering_info_present_flag");
>      for (uint32_t i = 0; i <= sps->getMaxTLayers() - 1; i++)
>      {
>          WRITE_UVLC(sps->getMaxDecPicBuffering(i) - 1,
> "sps_max_dec_pic_buffering_minus1[i]");
> @@ -502,13 +501,13 @@
>      WRITE_UVLC(sps->getLog2MinCodingBlockSize() - 3,
>            "log2_min_coding_block_size_minus3");
>      WRITE_UVLC(sps->getLog2DiffMaxMinCodingBlockSize(),
>           "log2_diff_max_min_coding_block_size");
>      WRITE_UVLC(sps->getQuadtreeTULog2MinSize() - 2,
>           "log2_min_transform_block_size_minus2");
> -    WRITE_UVLC(sps->getQuadtreeTULog2MaxSize() -
> sps->getQuadtreeTULog2MinSize(), "log2_diff_max_min_transform_block_size");
> +    WRITE_UVLC(sps->getQuadtreeTULog2MaxSize() -
> sps->getQuadtreeTULog2MinSize(),
> "log2_diff_max_min_transform_block_size");
>      WRITE_UVLC(sps->getQuadtreeTUMaxDepthInter() - 1,
>           "max_transform_hierarchy_depth_inter");
>      WRITE_UVLC(sps->getQuadtreeTUMaxDepthIntra() - 1,
>           "max_transform_hierarchy_depth_intra");
>      WRITE_FLAG(sps->getScalingListFlag() ? 1 : 0,
>           "scaling_list_enabled_flag");
>      if (sps->getScalingListFlag())
>      {
> -        WRITE_FLAG(sps->getScalingListPresentFlag() ? 1 : 0,
>              "sps_scaling_list_data_present_flag");
> +        WRITE_FLAG(sps->getScalingListPresentFlag() ? 1 : 0,
>            "sps_scaling_list_data_present_flag");
>          if (sps->getScalingListPresentFlag())
>          {
>  #if SCALING_LIST_OUTPUT_RESULT
> @@ -517,17 +516,17 @@
>              codeScalingList(m_slice->getScalingList());
>          }
>      }
> -    WRITE_FLAG(sps->getUseAMP() ? 1 : 0,
>            "amp_enabled_flag");
> -    WRITE_FLAG(sps->getUseSAO() ? 1 : 0,
>            "sample_adaptive_offset_enabled_flag");
> +    WRITE_FLAG(sps->getUseAMP() ? 1 : 0,
>              "amp_enabled_flag");
> +    WRITE_FLAG(sps->getUseSAO() ? 1 : 0,
>              "sample_adaptive_offset_enabled_flag");
>
> -    WRITE_FLAG(sps->getUsePCM() ? 1 : 0,
>            "pcm_enabled_flag");
> +    WRITE_FLAG(sps->getUsePCM() ? 1 : 0,
>              "pcm_enabled_flag");
>      if (sps->getUsePCM())
>      {
>          WRITE_CODE(sps->getPCMBitDepthLuma() - 1, 4,
>              "pcm_sample_bit_depth_luma_minus1");
>          WRITE_CODE(sps->getPCMBitDepthChroma() - 1, 4,
>              "pcm_sample_bit_depth_chroma_minus1");
>          WRITE_UVLC(sps->getPCMLog2MinSize() - 3,
>              "log2_min_pcm_luma_coding_block_size_minus3");
> -        WRITE_UVLC(sps->getPCMLog2MaxSize() - sps->getPCMLog2MinSize(),
>           "log2_diff_max_min_pcm_luma_coding_block_size");
> -        WRITE_FLAG(sps->getPCMFilterDisableFlag() ? 1 : 0,
>                "pcm_loop_filter_disable_flag");
> +        WRITE_UVLC(sps->getPCMLog2MaxSize() - sps->getPCMLog2MinSize(),
>             "log2_diff_max_min_pcm_luma_coding_block_size");
> +        WRITE_FLAG(sps->getPCMFilterDisableFlag() ? 1 : 0,
>              "pcm_loop_filter_disable_flag");
>      }
>
>      assert(sps->getMaxTLayers() > 0);
> @@ -571,47 +570,47 @@
>      xTracePPSHeader(pps);
>  #endif
>
> -    WRITE_UVLC(pps->getPPSId(),
> "pps_pic_parameter_set_id");
> -    WRITE_UVLC(pps->getSPSId(),
> "pps_seq_parameter_set_id");
> -    WRITE_FLAG(0,
> "dependent_slice_segments_enabled_flag");
> -    WRITE_FLAG(pps->getOutputFlagPresentFlag() ? 1 : 0,
> "output_flag_present_flag");
> -    WRITE_CODE(pps->getNumExtraSliceHeaderBits(), 3,
>  "num_extra_slice_header_bits");
> -    WRITE_FLAG(pps->getSignHideFlag(), "sign_data_hiding_flag");
> -    WRITE_FLAG(pps->getCabacInitPresentFlag() ? 1 : 0,
> "cabac_init_present_flag");
> -    WRITE_UVLC(pps->getNumRefIdxL0DefaultActive() - 1,
> "num_ref_idx_l0_default_active_minus1");
> -    WRITE_UVLC(pps->getNumRefIdxL1DefaultActive() - 1,
> "num_ref_idx_l1_default_active_minus1");
> +    WRITE_UVLC(pps->getPPSId(),
>             "pps_pic_parameter_set_id");
> +    WRITE_UVLC(pps->getSPSId(),
>             "pps_seq_parameter_set_id");
> +    WRITE_FLAG(0,
>             "dependent_slice_segments_enabled_flag");
> +    WRITE_FLAG(pps->getOutputFlagPresentFlag() ? 1 : 0,
>             "output_flag_present_flag");
> +    WRITE_CODE(pps->getNumExtraSliceHeaderBits(), 3,
>              "num_extra_slice_header_bits");
> +    WRITE_FLAG(pps->getSignHideFlag(),
>              "sign_data_hiding_flag");
> +    WRITE_FLAG(pps->getCabacInitPresentFlag() ? 1 : 0,
>              "cabac_init_present_flag");
> +    WRITE_UVLC(pps->getNumRefIdxL0DefaultActive() - 1,
>              "num_ref_idx_l0_default_active_minus1");
> +    WRITE_UVLC(pps->getNumRefIdxL1DefaultActive() - 1,
>              "num_ref_idx_l1_default_active_minus1");
>
> -    WRITE_SVLC(pps->getPicInitQPMinus26(),
>  "init_qp_minus26");
> -    WRITE_FLAG(pps->getConstrainedIntraPred() ? 1 : 0,
>  "constrained_intra_pred_flag");
> -    WRITE_FLAG(pps->getUseTransformSkip() ? 1 : 0,
>  "transform_skip_enabled_flag");
> -    WRITE_FLAG(pps->getUseDQP() ? 1 : 0, "cu_qp_delta_enabled_flag");
> +    WRITE_SVLC(pps->getPicInitQPMinus26(),
>              "init_qp_minus26");
> +    WRITE_FLAG(pps->getConstrainedIntraPred() ? 1 : 0,
>              "constrained_intra_pred_flag");
> +    WRITE_FLAG(pps->getUseTransformSkip() ? 1 : 0,
>              "transform_skip_enabled_flag");
> +    WRITE_FLAG(pps->getUseDQP() ? 1 : 0,
>              "cu_qp_delta_enabled_flag");
>      if (pps->getUseDQP())
>      {
> -        WRITE_UVLC(pps->getMaxCuDQPDepth(), "diff_cu_qp_delta_depth");
> +        WRITE_UVLC(pps->getMaxCuDQPDepth(),
>             "diff_cu_qp_delta_depth");
>      }
> -    WRITE_SVLC(pps->getChromaCbQpOffset(),
> "pps_cb_qp_offset");
> -    WRITE_SVLC(pps->getChromaCrQpOffset(),
> "pps_cr_qp_offset");
> -    WRITE_FLAG(pps->getSliceChromaQpFlag() ? 1 : 0,
>  "pps_slice_chroma_qp_offsets_present_flag");
> +    WRITE_SVLC(pps->getChromaCbQpOffset(),
>              "pps_cb_qp_offset");
> +    WRITE_SVLC(pps->getChromaCrQpOffset(),
>              "pps_cr_qp_offset");
> +    WRITE_FLAG(pps->getSliceChromaQpFlag() ? 1 : 0,
>             "pps_slice_chroma_qp_offsets_present_flag");
>
> -    WRITE_FLAG(pps->getUseWP() ? 1 : 0,  "weighted_pred_flag");   // Use
> of Weighting Prediction (P_SLICE)
> -    WRITE_FLAG(pps->getWPBiPred() ? 1 : 0, "weighted_bipred_flag");  //
> Use of Weighting Bi-Prediction (B_SLICE)
> -    WRITE_FLAG(pps->getTransquantBypassEnableFlag() ? 1 : 0,
> "transquant_bypass_enable_flag");
> -    WRITE_FLAG(0,
> "tiles_enabled_flag");
> -    WRITE_FLAG(pps->getEntropyCodingSyncEnabledFlag() ? 1 : 0,
> "entropy_coding_sync_enabled_flag");
> -    WRITE_FLAG(1,
>    "loop_filter_across_slices_enabled_flag");
> +    WRITE_FLAG(pps->getUseWP() ? 1 : 0,
>             "weighted_pred_flag");   // Use of Weighting Prediction
> (P_SLICE)
> +    WRITE_FLAG(pps->getWPBiPred() ? 1 : 0,
>              "weighted_bipred_flag");  // Use of Weighting Bi-Prediction
> (B_SLICE)
> +    WRITE_FLAG(pps->getTransquantBypassEnableFlag() ? 1 : 0,
>              "transquant_bypass_enable_flag");
> +    WRITE_FLAG(0,
>             "tiles_enabled_flag");
> +    WRITE_FLAG(pps->getEntropyCodingSyncEnabledFlag() ? 1 : 0,
>              "entropy_coding_sync_enabled_flag");
> +    WRITE_FLAG(1,
>             "loop_filter_across_slices_enabled_flag");
>      // TODO: Here have some time sequence problem, we set below field in
> initEncSlice(), but use them in getStreamHeaders() early
> -    WRITE_FLAG(pps->getDeblockingFilterControlPresentFlag() ? 1 : 0,
>   "deblocking_filter_control_present_flag");
> +    WRITE_FLAG(pps->getDeblockingFilterControlPresentFlag() ? 1 : 0,
>              "deblocking_filter_control_present_flag");
>      if (pps->getDeblockingFilterControlPresentFlag())
>      {
> -        WRITE_FLAG(pps->getDeblockingFilterOverrideEnabledFlag() ? 1 : 0,
>  "deblocking_filter_override_enabled_flag");
> -        WRITE_FLAG(pps->getPicDisableDeblockingFilterFlag() ? 1 : 0,
>   "pps_disable_deblocking_filter_flag");
> +        WRITE_FLAG(pps->getDeblockingFilterOverrideEnabledFlag() ? 1 : 0,
>             "deblocking_filter_override_enabled_flag");
> +        WRITE_FLAG(pps->getPicDisableDeblockingFilterFlag() ? 1 : 0,
>              "pps_disable_deblocking_filter_flag");
>          if (!pps->getPicDisableDeblockingFilterFlag())
>          {
> -            WRITE_SVLC(pps->getDeblockingFilterBetaOffsetDiv2(),
>     "pps_beta_offset_div2");
> -            WRITE_SVLC(pps->getDeblockingFilterTcOffsetDiv2(),
>     "pps_tc_offset_div2");
> +            WRITE_SVLC(pps->getDeblockingFilterBetaOffsetDiv2(),
>              "pps_beta_offset_div2");
> +            WRITE_SVLC(pps->getDeblockingFilterTcOffsetDiv2(),
>              "pps_tc_offset_div2");
>          }
>      }
> -    WRITE_FLAG(pps->getScalingListPresentFlag() ? 1 : 0,
>          "pps_scaling_list_data_present_flag");
> +    WRITE_FLAG(pps->getScalingListPresentFlag() ? 1 : 0,
>              "pps_scaling_list_data_present_flag");
>      if (pps->getScalingListPresentFlag())
>      {
>  #if SCALING_LIST_OUTPUT_RESULT
> @@ -619,9 +618,9 @@
>  #endif
>          codeScalingList(m_slice->getScalingList());
>      }
> -    WRITE_FLAG(pps->getListsModificationPresentFlag(),
> "lists_modification_present_flag");
> -    WRITE_UVLC(pps->getLog2ParallelMergeLevelMinus2(),
> "log2_parallel_merge_level_minus2");
> -    WRITE_FLAG(pps->getSliceHeaderExtensionPresentFlag() ? 1 : 0,
> "slice_segment_header_extension_present_flag");
> +    WRITE_FLAG(pps->getListsModificationPresentFlag(),
>              "lists_modification_present_flag");
> +    WRITE_UVLC(pps->getLog2ParallelMergeLevelMinus2(),
>              "log2_parallel_merge_level_minus2");
> +    WRITE_FLAG(pps->getSliceHeaderExtensionPresentFlag() ? 1 : 0,
>             "slice_segment_header_extension_present_flag");
>      WRITE_FLAG(0, "pps_extension_flag");
>  }
>
> @@ -630,83 +629,83 @@
>  #if ENC_DEC_TRACE
>      fprintf(g_hTrace, "----------- vui_parameters -----------\n");
>  #endif
> -    WRITE_FLAG(vui->getAspectRatioInfoPresentFlag(),
>  "aspect_ratio_info_present_flag");
> +    WRITE_FLAG(vui->getAspectRatioInfoPresentFlag(),
>              "aspect_ratio_info_present_flag");
>      if (vui->getAspectRatioInfoPresentFlag())
>      {
> -        WRITE_CODE(vui->getAspectRatioIdc(), 8,
> "aspect_ratio_idc");
> +        WRITE_CODE(vui->getAspectRatioIdc(), 8,
>             "aspect_ratio_idc");
>          if (vui->getAspectRatioIdc() == 255)
>          {
> -            WRITE_CODE(vui->getSarWidth(), 16,
>  "sar_width");
> -            WRITE_CODE(vui->getSarHeight(), 16,
> "sar_height");
> +            WRITE_CODE(vui->getSarWidth(), 16,
>              "sar_width");
> +            WRITE_CODE(vui->getSarHeight(), 16,
>             "sar_height");
>          }
>      }
> -    WRITE_FLAG(vui->getOverscanInfoPresentFlag(),
> "overscan_info_present_flag");
> +    WRITE_FLAG(vui->getOverscanInfoPresentFlag(),
>             "overscan_info_present_flag");
>      if (vui->getOverscanInfoPresentFlag())
>      {
> -        WRITE_FLAG(vui->getOverscanAppropriateFlag(),
> "overscan_appropriate_flag");
> +        WRITE_FLAG(vui->getOverscanAppropriateFlag(),
>             "overscan_appropriate_flag");
>      }
> -    WRITE_FLAG(vui->getVideoSignalTypePresentFlag(),
>  "video_signal_type_present_flag");
> +    WRITE_FLAG(vui->getVideoSignalTypePresentFlag(),
>              "video_signal_type_present_flag");
>      if (vui->getVideoSignalTypePresentFlag())
>      {
> -        WRITE_CODE(vui->getVideoFormat(), 3,
>  "video_format");
> -        WRITE_FLAG(vui->getVideoFullRangeFlag(),
>  "video_full_range_flag");
> -        WRITE_FLAG(vui->getColourDescriptionPresentFlag(),
>  "colour_description_present_flag");
> +        WRITE_CODE(vui->getVideoFormat(), 3,
>              "video_format");
> +        WRITE_FLAG(vui->getVideoFullRangeFlag(),
>              "video_full_range_flag");
> +        WRITE_FLAG(vui->getColourDescriptionPresentFlag(),
>              "colour_description_present_flag");
>          if (vui->getColourDescriptionPresentFlag())
>          {
> -            WRITE_CODE(vui->getColourPrimaries(), 8,
>  "colour_primaries");
> -            WRITE_CODE(vui->getTransferCharacteristics(), 8,
>  "transfer_characteristics");
> -            WRITE_CODE(vui->getMatrixCoefficients(), 8,
> "matrix_coefficients");
> +            WRITE_CODE(vui->getColourPrimaries(), 8,
>              "colour_primaries");
> +            WRITE_CODE(vui->getTransferCharacteristics(), 8,
>              "transfer_characteristics");
> +            WRITE_CODE(vui->getMatrixCoefficients(), 8,
>             "matrix_coefficients");
>          }
>      }
>
> -    WRITE_FLAG(vui->getChromaLocInfoPresentFlag(),
>  "chroma_loc_info_present_flag");
> +    WRITE_FLAG(vui->getChromaLocInfoPresentFlag(),
>              "chroma_loc_info_present_flag");
>      if (vui->getChromaLocInfoPresentFlag())
>      {
> -        WRITE_UVLC(vui->getChromaSampleLocTypeTopField(),
> "chroma_sample_loc_type_top_field");
> -        WRITE_UVLC(vui->getChromaSampleLocTypeBottomField(),
>  "chroma_sample_loc_type_bottom_field");
> +        WRITE_UVLC(vui->getChromaSampleLocTypeTopField(),
>             "chroma_sample_loc_type_top_field");
> +        WRITE_UVLC(vui->getChromaSampleLocTypeBottomField(),
>              "chroma_sample_loc_type_bottom_field");
>      }
>
> -    WRITE_FLAG(vui->getNeutralChromaIndicationFlag(),
> "neutral_chroma_indication_flag");
> -    WRITE_FLAG(vui->getFieldSeqFlag(),
>  "field_seq_flag");
> -    WRITE_FLAG(vui->getFrameFieldInfoPresentFlag(),
> "frame_field_info_present_flag");
> +    WRITE_FLAG(vui->getNeutralChromaIndicationFlag(),
>             "neutral_chroma_indication_flag");
> +    WRITE_FLAG(vui->getFieldSeqFlag(),
>              "field_seq_flag");
> +    WRITE_FLAG(vui->getFrameFieldInfoPresentFlag(),
>             "frame_field_info_present_flag");
>
>      Window defaultDisplayWindow = vui->getDefaultDisplayWindow();
> -    WRITE_FLAG(defaultDisplayWindow.m_enabledFlag,
> "default_display_window_flag");
> +    WRITE_FLAG(defaultDisplayWindow.m_enabledFlag,
>              "default_display_window_flag");
>      if (defaultDisplayWindow.m_enabledFlag)
>      {
> -        WRITE_UVLC(defaultDisplayWindow.m_winLeftOffset,
>  "def_disp_win_left_offset");
> -        WRITE_UVLC(defaultDisplayWindow.m_winRightOffset,
> "def_disp_win_right_offset");
> -        WRITE_UVLC(defaultDisplayWindow.m_winTopOffset,
> "def_disp_win_top_offset");
> -        WRITE_UVLC(defaultDisplayWindow.m_winBottomOffset,
>  "def_disp_win_bottom_offset");
> +        WRITE_UVLC(defaultDisplayWindow.m_winLeftOffset,
>              "def_disp_win_left_offset");
> +        WRITE_UVLC(defaultDisplayWindow.m_winRightOffset,
>             "def_disp_win_right_offset");
> +        WRITE_UVLC(defaultDisplayWindow.m_winTopOffset,
>             "def_disp_win_top_offset");
> +        WRITE_UVLC(defaultDisplayWindow.m_winBottomOffset,
>              "def_disp_win_bottom_offset");
>      }
>      TimingInfo *timingInfo = vui->getTimingInfo();
> -    WRITE_FLAG(timingInfo->getTimingInfoPresentFlag(),
>  "vui_timing_info_present_flag");
> +    WRITE_FLAG(timingInfo->getTimingInfoPresentFlag(),
>              "vui_timing_info_present_flag");
>      if (timingInfo->getTimingInfoPresentFlag())
>      {
> -        WRITE_CODE(timingInfo->getNumUnitsInTick(), 32,
> "vui_num_units_in_tick");
> -        WRITE_CODE(timingInfo->getTimeScale(),      32,
> "vui_time_scale");
> -        WRITE_FLAG(timingInfo->getPocProportionalToTimingFlag(),
>  "vui_poc_proportional_to_timing_flag");
> +        WRITE_CODE(timingInfo->getNumUnitsInTick(), 32,
>             "vui_num_units_in_tick");
> +        WRITE_CODE(timingInfo->getTimeScale(),      32,
>             "vui_time_scale");
> +        WRITE_FLAG(timingInfo->getPocProportionalToTimingFlag(),
>              "vui_poc_proportional_to_timing_flag");
>          if (timingInfo->getPocProportionalToTimingFlag())
>          {
> -            WRITE_UVLC(timingInfo->getNumTicksPocDiffOneMinus1(),
> "vui_num_ticks_poc_diff_one_minus1");
> +            WRITE_UVLC(timingInfo->getNumTicksPocDiffOneMinus1(),
>             "vui_num_ticks_poc_diff_one_minus1");
>          }
> -        WRITE_FLAG(vui->getHrdParametersPresentFlag(),
>  "hrd_parameters_present_flag");
> +        WRITE_FLAG(vui->getHrdParametersPresentFlag(),
>              "hrd_parameters_present_flag");
>          if (vui->getHrdParametersPresentFlag())
>          {
>              codeHrdParameters(vui->getHrdParameters(), 1,
> sps->getMaxTLayers() - 1);
>          }
>      }
> -    WRITE_FLAG(vui->getBitstreamRestrictionFlag(),
>  "bitstream_restriction_flag");
> +    WRITE_FLAG(vui->getBitstreamRestrictionFlag(),
>              "bitstream_restriction_flag");
>      if (vui->getBitstreamRestrictionFlag())
>      {
> -        WRITE_FLAG(0,
>  "tiles_fixed_structure_flag");
> -        WRITE_FLAG(vui->getMotionVectorsOverPicBoundariesFlag(),
>  "motion_vectors_over_pic_boundaries_flag");
> -        WRITE_FLAG(vui->getRestrictedRefPicListsFlag(),
> "restricted_ref_pic_lists_flag");
> -        WRITE_UVLC(vui->getMinSpatialSegmentationIdc(),
> "min_spatial_segmentation_idc");
> -        WRITE_UVLC(vui->getMaxBytesPerPicDenom(),
> "max_bytes_per_pic_denom");
> -        WRITE_UVLC(vui->getMaxBitsPerMinCuDenom(),
>  "max_bits_per_mincu_denom");
> -        WRITE_UVLC(vui->getLog2MaxMvLengthHorizontal(),
> "log2_max_mv_length_horizontal");
> -        WRITE_UVLC(vui->getLog2MaxMvLengthVertical(),
> "log2_max_mv_length_vertical");
> +        WRITE_FLAG(0,
>             "tiles_fixed_structure_flag");
> +        WRITE_FLAG(vui->getMotionVectorsOverPicBoundariesFlag(),
>              "motion_vectors_over_pic_boundaries_flag");
> +        WRITE_FLAG(vui->getRestrictedRefPicListsFlag(),
>             "restricted_ref_pic_lists_flag");
> +        WRITE_UVLC(vui->getMinSpatialSegmentationIdc(),
>             "min_spatial_segmentation_idc");
> +        WRITE_UVLC(vui->getMaxBytesPerPicDenom(),
>             "max_bytes_per_pic_denom");
> +        WRITE_UVLC(vui->getMaxBitsPerMinCuDenom(),
>              "max_bits_per_mincu_denom");
> +        WRITE_UVLC(vui->getLog2MaxMvLengthHorizontal(),
>             "log2_max_mv_length_horizontal");
> +        WRITE_UVLC(vui->getLog2MaxMvLengthVertical(),
>             "log2_max_mv_length_vertical");
>      }
>  }
>
> @@ -714,36 +713,36 @@
>  {
>      if (commonInfPresentFlag)
>      {
> -        WRITE_FLAG(hrd->getNalHrdParametersPresentFlag() ? 1 : 0,
>  "nal_hrd_parameters_present_flag");
> -        WRITE_FLAG(hrd->getVclHrdParametersPresentFlag() ? 1 : 0,
>  "vcl_hrd_parameters_present_flag");
> +        WRITE_FLAG(hrd->getNalHrdParametersPresentFlag() ? 1 : 0,
>            "nal_hrd_parameters_present_flag");
> +        WRITE_FLAG(hrd->getVclHrdParametersPresentFlag() ? 1 : 0,
>            "vcl_hrd_parameters_present_flag");
>          if (hrd->getNalHrdParametersPresentFlag() ||
> hrd->getVclHrdParametersPresentFlag())
>          {
> -            WRITE_FLAG(hrd->getSubPicCpbParamsPresentFlag() ? 1 : 0,
>  "sub_pic_cpb_params_present_flag");
> +            WRITE_FLAG(hrd->getSubPicCpbParamsPresentFlag() ? 1 : 0,
>             "sub_pic_cpb_params_present_flag");
>              if (hrd->getSubPicCpbParamsPresentFlag())
>              {
> -                WRITE_CODE(hrd->getTickDivisorMinus2(), 8,
>  "tick_divisor_minus2");
> -                WRITE_CODE(hrd->getDuCpbRemovalDelayLengthMinus1(), 5,
>  "du_cpb_removal_delay_length_minus1");
> -                WRITE_FLAG(hrd->getSubPicCpbParamsInPicTimingSEIFlag() ?
> 1 : 0, "sub_pic_cpb_params_in_pic_timing_sei_flag");
> -                WRITE_CODE(hrd->getDpbOutputDelayDuLengthMinus1(), 5,
> "dpb_output_delay_du_length_minus1");
> +                WRITE_CODE(hrd->getTickDivisorMinus2(), 8,
>             "tick_divisor_minus2");
> +                WRITE_CODE(hrd->getDuCpbRemovalDelayLengthMinus1(), 5,
>             "du_cpb_removal_delay_length_minus1");
> +                WRITE_FLAG(hrd->getSubPicCpbParamsInPicTimingSEIFlag() ?
> 1 : 0,      "sub_pic_cpb_params_in_pic_timing_sei_flag");
> +                WRITE_CODE(hrd->getDpbOutputDelayDuLengthMinus1(), 5,
>            "dpb_output_delay_du_length_minus1");
>              }
> -            WRITE_CODE(hrd->getBitRateScale(), 4,
> "bit_rate_scale");
> -            WRITE_CODE(hrd->getCpbSizeScale(), 4,
> "cpb_size_scale");
> +            WRITE_CODE(hrd->getBitRateScale(), 4,
>            "bit_rate_scale");
> +            WRITE_CODE(hrd->getCpbSizeScale(), 4,
>            "cpb_size_scale");
>              if (hrd->getSubPicCpbParamsPresentFlag())
>              {
> -                WRITE_CODE(hrd->getDuCpbSizeScale(), 4,
>  "du_cpb_size_scale");
> +                WRITE_CODE(hrd->getDuCpbSizeScale(), 4,
>            "du_cpb_size_scale");
>              }
> -            WRITE_CODE(hrd->getInitialCpbRemovalDelayLengthMinus1(), 5,
> "initial_cpb_removal_delay_length_minus1");
> -            WRITE_CODE(hrd->getCpbRemovalDelayLengthMinus1(),        5,
> "au_cpb_removal_delay_length_minus1");
> -            WRITE_CODE(hrd->getDpbOutputDelayLengthMinus1(),         5,
> "dpb_output_delay_length_minus1");
> +            WRITE_CODE(hrd->getInitialCpbRemovalDelayLengthMinus1(), 5,
>            "initial_cpb_removal_delay_length_minus1");
> +            WRITE_CODE(hrd->getCpbRemovalDelayLengthMinus1(),        5,
>            "au_cpb_removal_delay_length_minus1");
> +            WRITE_CODE(hrd->getDpbOutputDelayLengthMinus1(),         5,
>            "dpb_output_delay_length_minus1");
>          }
>      }
>      int i, j, nalOrVcl;
>      for (i = 0; i <= maxNumSubLayersMinus1; i++)
>      {
> -        WRITE_FLAG(hrd->getFixedPicRateFlag(i) ? 1 : 0,
>  "fixed_pic_rate_general_flag");
> +        WRITE_FLAG(hrd->getFixedPicRateFlag(i) ? 1 : 0,
>            "fixed_pic_rate_general_flag");
>          if (!hrd->getFixedPicRateFlag(i))
>          {
> -            WRITE_FLAG(hrd->getFixedPicRateWithinCvsFlag(i) ? 1 : 0,
> "fixed_pic_rate_within_cvs_flag");
> +            WRITE_FLAG(hrd->getFixedPicRateWithinCvsFlag(i) ? 1 : 0,
>             "fixed_pic_rate_within_cvs_flag");
>          }
>          else
>          {
> @@ -751,15 +750,15 @@
>          }
>          if (hrd->getFixedPicRateWithinCvsFlag(i))
>          {
> -            WRITE_UVLC(hrd->getPicDurationInTcMinus1(i),
> "elemental_duration_in_tc_minus1");
> +            WRITE_UVLC(hrd->getPicDurationInTcMinus1(i),
>             "elemental_duration_in_tc_minus1");
>          }
>          else
>          {
> -            WRITE_FLAG(hrd->getLowDelayHrdFlag(i) ? 1 : 0,
> "low_delay_hrd_flag");
> +            WRITE_FLAG(hrd->getLowDelayHrdFlag(i) ? 1 : 0,
>             "low_delay_hrd_flag");
>          }
>          if (!hrd->getLowDelayHrdFlag(i))
>          {
> -            WRITE_UVLC(hrd->getCpbCntMinus1(i),
>  "cpb_cnt_minus1");
> +            WRITE_UVLC(hrd->getCpbCntMinus1(i),
>            "cpb_cnt_minus1");
>          }
>
>          for (nalOrVcl = 0; nalOrVcl < 2; nalOrVcl++)
> @@ -825,8 +824,8 @@
>  void TEncSbac::codeProfileTier(ProfileTierLevel* ptl)
>  {
>      WRITE_CODE(ptl->getProfileSpace(), 2,     "XXX_profile_space[]");
> -    WRITE_FLAG(ptl->getTierFlag(),         "XXX_tier_flag[]");
> -    WRITE_CODE(ptl->getProfileIdc(), 5,     "XXX_profile_idc[]");
> +    WRITE_FLAG(ptl->getTierFlag(),            "XXX_tier_flag[]");
> +    WRITE_CODE(ptl->getProfileIdc(), 5,       "XXX_profile_idc[]");
>      for (int j = 0; j < 32; j++)
>      {
>          WRITE_FLAG(ptl->getProfileCompatibilityFlag(j),
> "XXX_profile_compatibility_flag[][j]");
> @@ -1063,10 +1062,15 @@
>              WRITE_FLAG(slice->getPicOutputFlag() ? 1 : 0,
> "pic_output_flag");
>          }
>
> -        // in the first version chroma_format_idc is equal to one, thus
> colour_plane_id will not be present
> -        assert(slice->getSPS()->getChromaFormatIdc() == 1);
> -        // if( separate_colour_plane_flag  ==  1 )
> -        //   colour_plane_id                                      u(2)
> +        if (slice->getSPS()->getChromaFormatIdc() == CHROMA_444)
> +        {
> +            //In this version separate_color_plane_flag is 0
> +            if(slice->getSPS()->getSeparateColorPlaneFlag())
> +            {
> +                //plane_id values 0, 1, and 2 correspond to the Y, Cb,
> and Cr planes, respectively.
> +                //WRITE_FLAG(0, "colour_plane_id");
> +            }
> +        }
>
>          if (!slice->getIdrPicFlag())
>          {
> @@ -2163,16 +2167,6 @@
>
>      if (numSig == 0)
>          return;
> -    if (cu->getSlice()->getPPS()->getUseTransformSkip())
> -    {
> -        codeTransformSkipFlags(cu, absPartIdx, width, height, ttype);
> -    }
> -    ttype = ttype == TEXT_LUMA ? TEXT_LUMA : TEXT_CHROMA;
> -
> -    //----- encode significance map -----
> -    const uint32_t log2BlockSize = g_convertToBit[width] + 2;
> -    uint32_t scanIdx = cu->getCoefScanIdx(absPartIdx, width, ttype ==
> TEXT_LUMA, cu->isIntra(absPartIdx));
> -    const uint32_t *scan = g_sigLastScan[scanIdx][log2BlockSize - 1];
>
>      bool beValid;
>      if (cu->getCUTransquantBypass(absPartIdx))
> @@ -2184,55 +2178,57 @@
>          beValid = cu->getSlice()->getPPS()->getSignHideFlag() > 0;
>      }
>
> +    if (cu->getSlice()->getPPS()->getUseTransformSkip())
> +    {
> +        codeTransformSkipFlags(cu, absPartIdx, width, height, ttype);
> +    }
> +
> +    ttype = ttype == TEXT_LUMA ? TEXT_LUMA : TEXT_CHROMA;
> +    const uint32_t log2BlockWidth  = g_convertToBit[width] + 2;
> +    const uint32_t log2BlockHeight = g_convertToBit[height] + 2;
> +
> +    //select scans
> +    TUEntropyCodingParameters codingParameters;
> +    TComTrQuant::getTUEntropyCodingParameters(cu, codingParameters,
> absPartIdx,  width, height, ttype);
> +
> +    //----- encode significance map -----
> +
>      // Find position of last coefficient
>      int scanPosLast = -1;
>      int posLast;
>
> -    const uint32_t * scanCG;
> -    {
> -        scanCG = g_sigLastScan[scanIdx][log2BlockSize > 3 ? log2BlockSize
> - 2 - 1 : 0];
> -        if (log2BlockSize == 3)
> -        {
> -            scanCG = g_sigLastScan8x8[scanIdx];
> -        }
> -        else if (log2BlockSize == 5)
> -        {
> -            scanCG = g_sigLastScanCG32x32;
> -        }
> -    }
> -    uint32_t sigCoeffGroupFlag[MLS_GRP_NUM];
> -    static const uint32_t shift = MLS_CG_SIZE >> 1;
> -    const uint32_t numBlkSide = width >> shift;
>
> -    ::memset(sigCoeffGroupFlag, 0, sizeof(uint32_t) * MLS_GRP_NUM);
> +    uint32_t sigCoeffGroupFlag[ MLS_GRP_NUM ];
> +    memset( sigCoeffGroupFlag, 0, sizeof(uint32_t) * MLS_GRP_NUM );
>
>      do
>      {
> -        posLast = scan[++scanPosLast];
> +        posLast = codingParameters.scan[++scanPosLast];
>
> -        // get L1 sig map
> -        uint32_t posy    = posLast >> log2BlockSize;
> -        uint32_t posx    = posLast - (posy << log2BlockSize);
> -        uint32_t blkIdx  = numBlkSide * (posy >> shift) + (posx >> shift);
> -        if (coeff[posLast])
> +        if(coeff[posLast] != 0)
>          {
> +            // get L1 sig map
> +            uint32_t posy    = posLast >> log2BlockWidth;
> +            uint32_t posx    = posLast - (posy << log2BlockWidth);
> +            uint32_t blkIdx  = codingParameters.widthInGroups * (posy >>
> MLS_CG_LOG2_HEIGHT) + (posx >> MLS_CG_LOG2_WIDTH);
>              sigCoeffGroupFlag[blkIdx] = 1;
> +
> +            numSig --;
>          }
> -
> -        numSig -= (coeff[posLast] != 0);
>      }
>      while (numSig > 0);
>
> +
>      // Code position of last coefficient
> -    int posLastY = posLast >> log2BlockSize;
> -    int posLastX = posLast - (posLastY << log2BlockSize);
> -    codeLastSignificantXY(posLastX, posLastY, width, height, ttype,
> scanIdx);
> +    int posLastY = posLast >> log2BlockWidth;
> +    int posLastX = posLast - (posLastY << log2BlockWidth);
> +    codeLastSignificantXY(posLastX, posLastY, width, height, ttype,
> codingParameters.scanType);
>
>      //===== code significance flag =====
>      ContextModel * const baseCoeffGroupCtx =
> &m_contextModels[OFF_SIG_CG_FLAG_CTX + (ttype ? NUM_SIG_CG_FLAG_CTX : 0)];
>      ContextModel * const baseCtx = (ttype == TEXT_LUMA) ?
> &m_contextModels[OFF_SIG_FLAG_CTX] : &m_contextModels[OFF_SIG_FLAG_CTX +
> NUM_SIG_FLAG_CTX_LUMA];
>
> -    const int lastScanSet      = scanPosLast >> LOG2_SCAN_SET_SIZE;
> +    const int lastScanSet      = scanPosLast >> MLS_CG_SIZE;
>      uint32_t c1 = 1;
>      uint32_t goRiceParam           = 0;
>      int  scanPosSig            = scanPosLast;
> @@ -2240,16 +2236,17 @@
>      for (int subSet = lastScanSet; subSet >= 0; subSet--)
>      {
>          int numNonZero = 0;
> -        int subPos     = subSet << LOG2_SCAN_SET_SIZE;
> +        int subPos     = subSet << MLS_CG_SIZE;
>          goRiceParam    = 0;
> -        int absCoeff[16];
> +        int absCoeff[1 << MLS_CG_SIZE];
>          uint32_t coeffSigns = 0;
>
> -        int lastNZPosInCG = -1, firstNZPosInCG = SCAN_SET_SIZE;
> +        int lastNZPosInCG = -1;
> +        int firstNZPosInCG = 1 << MLS_CG_SIZE;
>
>          if (scanPosSig == scanPosLast)
>          {
> -            absCoeff[0] = abs(coeff[posLast]);
> +            absCoeff[0] = int(abs(coeff[posLast]));
>              coeffSigns    = (coeff[posLast] < 0);
>              numNonZero    = 1;
>              lastNZPosInCG  = scanPosSig;
> @@ -2258,9 +2255,10 @@
>          }
>
>          // encode significant_coeffgroup_flag
> -        int cgBlkPos = scanCG[subSet];
> -        int cgPosY   = cgBlkPos / numBlkSide;
> -        int cgPosX   = cgBlkPos - (cgPosY * numBlkSide);
> +        int cgBlkPos = codingParameters.scanCG[subSet];
> +        int cgPosY   = cgBlkPos / codingParameters.widthInGroups;
> +        int cgPosX   = cgBlkPos - (cgPosY *
> codingParameters.widthInGroups);
> +
>          if (subSet == lastScanSet || subSet == 0)
>          {
>              sigCoeffGroupFlag[cgBlkPos] = 1;
> @@ -2268,29 +2266,27 @@
>          else
>          {
>              uint32_t sigCoeffGroup = (sigCoeffGroupFlag[cgBlkPos] != 0);
> -            uint32_t ctxSig =
> TComTrQuant::getSigCoeffGroupCtxInc(sigCoeffGroupFlag, cgPosX, cgPosY,
> log2BlockSize);
> +            uint32_t ctxSig =
> TComTrQuant::getSigCoeffGroupCtxInc(sigCoeffGroupFlag, cgPosX, cgPosY,
> codingParameters.widthInGroups, codingParameters.heightInGroups);
>              m_binIf->encodeBin(sigCoeffGroup, baseCoeffGroupCtx[ctxSig]);
>          }
>
>          // encode significant_coeff_flag
>          if (sigCoeffGroupFlag[cgBlkPos])
>          {
> -            int patternSigCtx =
> TComTrQuant::calcPatternSigCtx(sigCoeffGroupFlag, cgPosX, cgPosY,
> log2BlockSize);
> -            uint32_t blkPos, posy, posx, sig, ctxSig;
> +            const int patternSigCtx =
> TComTrQuant::calcPatternSigCtx(sigCoeffGroupFlag, cgPosX, cgPosY,
> codingParameters.widthInGroups, codingParameters.heightInGroups);
> +            uint32_t blkPos, sig, ctxSig;
>              for (; scanPosSig >= subPos; scanPosSig--)
>              {
> -                blkPos  = scan[scanPosSig];
> -                posy    = blkPos >> log2BlockSize;
> -                posx    = blkPos - (posy << log2BlockSize);
> +                blkPos  = codingParameters.scan[scanPosSig];
>                  sig     = (coeff[blkPos] != 0);
>                  if (scanPosSig > subPos || subSet == 0 || numNonZero)
>                  {
> -                    ctxSig  = TComTrQuant::getSigCtxInc(patternSigCtx,
> scanIdx, posx, posy, log2BlockSize, ttype);
> +                    ctxSig  = TComTrQuant::getSigCtxInc(patternSigCtx,
> codingParameters, scanPosSig, log2BlockWidth, log2BlockHeight, ttype);
>                      m_binIf->encodeBin(sig, baseCtx[ctxSig]);
>                  }
>                  if (sig)
>                  {
> -                    absCoeff[numNonZero] = abs(coeff[blkPos]);
> +                    absCoeff[numNonZero] = int(abs(coeff[blkPos]));
>                      coeffSigns = 2 * coeffSigns + (coeff[blkPos] < 0);
>                      numNonZero++;
>                      if (lastNZPosInCG == -1)
>
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
>
>


-- 
Steve Borho
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20140107/1c1b94d7/attachment-0001.html>


More information about the x265-devel mailing list