[FFmpeg-devel] [PATCH 00/72] Implement support for Vulkan multiplane images and video decoding

Anton Khirnov anton at khirnov.net
Mon Feb 20 19:40:51 EET 2023


Quoting Lynne (2023-02-17 04:43:50)
> From 4645f1fb3249f8249fdebaf9b3edffc848b9af3c Mon Sep 17 00:00:00 2001
> From: Lynne <dev at lynne.ee>
> Date: Wed, 14 Dec 2022 00:18:42 +0100
> Subject: [PATCH 17/72] hevc_ps: expose and parse scc range extension fields
> 
> ---
>  libavcodec/hevc.h    |  2 ++
>  libavcodec/hevc_ps.c | 63 ++++++++++++++++++++++++++++++++++++++++----
>  libavcodec/hevc_ps.h | 26 ++++++++++++++++++
>  3 files changed, 86 insertions(+), 5 deletions(-)
> 
> diff --git a/libavcodec/hevc.h b/libavcodec/hevc.h
> index 1804755327..913c7d4e2e 100644
> --- a/libavcodec/hevc.h
> +++ b/libavcodec/hevc.h
> @@ -154,6 +154,8 @@ enum {
>      // get near that, though, so set a lower limit here with the maximum
>      // possible value for 4K video (at most 135 16x16 Ctb rows).
>      HEVC_MAX_ENTRY_POINT_OFFSETS = HEVC_MAX_TILE_COLUMNS * 135,
> +
> +    HEVC_PREDICTOR_PALETTE_COMP_ENTRIES_LIST_SIZE = 128,
>  };
>  
>  
> diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
> index a740da9f82..b03f59efef 100644
> --- a/libavcodec/hevc_ps.c
> +++ b/libavcodec/hevc_ps.c
> @@ -856,7 +856,7 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,
>      int ret = 0;
>      int log2_diff_max_min_transform_block_size;
>      int bit_depth_chroma, start;
> -    int i;
> +    int i, j;
>  
>      // Coded parameters
>  
> @@ -1077,9 +1077,12 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,
>      if (sps->vui_present)
>          decode_vui(gb, avctx, apply_defdispwin, sps);
>  
> -    if (get_bits1(gb)) { // sps_extension_flag
> +    sps->sps_extension_present_flag = get_bits1(gb);
> +    if (sps->sps_extension_present_flag) { // sps_extension_flag

// department of redundancy department called

>          sps->sps_range_extension_flag = get_bits1(gb);
> -        skip_bits(gb, 7); //sps_extension_7bits = get_bits(gb, 7);
> +        skip_bits(gb, 2);
> +        sps->sps_scc_extension_flag = get_bits1(gb);
> +        skip_bits(gb, 4);
>          if (sps->sps_range_extension_flag) {
>              sps->transform_skip_rotation_enabled_flag = get_bits1(gb);
>              sps->transform_skip_context_enabled_flag  = get_bits1(gb);
> @@ -1105,6 +1108,26 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,
>                  av_log(avctx, AV_LOG_WARNING,
>                     "cabac_bypass_alignment_enabled_flag not yet implemented\n");
>          }
> +        if (sps->sps_scc_extension_flag) {
> +            sps->sps_curr_pic_ref_enabled_flag = get_bits1(gb);
> +            sps->palette_mode_enabled_flag = get_bits1(gb);
> +            if (sps->palette_mode_enabled_flag) {
> +                sps->palette_max_size = get_ue_golomb_long(gb);
> +                sps->delta_palette_max_predictor_size = get_ue_golomb_long(gb);
> +
> +                sps->sps_palette_predictor_initializer_present_flag = get_bits1(gb);
> +                if (sps->sps_palette_predictor_initializer_present_flag) {
> +                    sps->sps_num_palette_predictor_initializer_minus1 = get_ue_golomb_long(gb);
> +                    for (i = 0; i < (sps->chroma_format_idc ? 3 : 1); i++) {
> +                        for (j = 0; j <= sps->sps_num_palette_predictor_initializer_minus1; j++)
> +                            sps->palette_predictor_initializers[i][j] = get_ue_golomb_long(gb);
> +                    }
> +                }
> +            }
> +
> +            sps->motion_vector_resolution_control_idc = get_bits(gb, 2);
> +            sps->intra_boundary_filtering_disable_flag = get_bits1(gb);
> +        }
>      }
>      if (apply_defdispwin) {
>          sps->output_window.left_offset   += sps->vui.def_disp_win.left_offset;
> @@ -1446,7 +1469,7 @@ int ff_hevc_decode_nal_pps(GetBitContext *gb, AVCodecContext *avctx,
>                             HEVCParamSets *ps)
>  {
>      HEVCSPS      *sps = NULL;
> -    int i, ret = 0;
> +    int i, j, ret = 0;
>      unsigned int pps_id = 0;
>      ptrdiff_t nal_size;
>      unsigned log2_parallel_merge_level_minus2;
> @@ -1664,11 +1687,41 @@ int ff_hevc_decode_nal_pps(GetBitContext *gb, AVCodecContext *avctx,
>      pps->pps_extension_present_flag = get_bits1(gb);
>      if (pps->pps_extension_present_flag) {
>          pps->pps_range_extensions_flag = get_bits1(gb);
> -        skip_bits(gb, 7); // pps_extension_7bits
> +        skip_bits(gb, 2);
> +        pps->pps_scc_extension_flag = get_bits1(gb);
> +        skip_bits(gb, 4);
>          if (sps->ptl.general_ptl.profile_idc == FF_PROFILE_HEVC_REXT && pps->pps_range_extensions_flag) {
>              if ((ret = pps_range_extensions(gb, avctx, pps, sps)) < 0)
>                  goto err;
>          }
> +        if (pps->pps_scc_extension_flag) {
> +            pps->pps_curr_pic_ref_enabled_flag = get_bits1(gb);
> +            pps->residual_adaptive_colour_transform_enabled_flag = get_bits1(gb);
> +
> +            if (pps->residual_adaptive_colour_transform_enabled_flag) {
> +                pps->pps_slice_act_qp_offsets_present_flag = get_bits1(gb);
> +                pps->pps_act_y_qp_offset_plus5 = get_se_golomb(gb);
> +                pps->pps_act_cb_qp_offset_plus5 = get_se_golomb(gb);
> +                pps->pps_act_cr_qp_offset_plus3 = get_se_golomb(gb);
> +            }
> +
> +            pps->pps_palette_predictor_initializer_present_flag = get_bits1(gb);
> +            if (pps->pps_palette_predictor_initializer_present_flag) {
> +                pps->pps_num_palette_predictor_initializer = get_ue_golomb_long(gb);
> +                if (pps->pps_num_palette_predictor_initializer) {
> +                    pps->monochrome_palette_flag = get_bits1(gb);
> +                    pps->luma_bit_depth_entry_minus8 = get_ue_golomb_long(gb);
> +
> +                    if (!pps->monochrome_palette_flag)
> +                        pps->chroma_bit_depth_entry_minus8 = get_ue_golomb_long(gb);
> +
> +                    for (i = 0; i < (pps->monochrome_palette_flag ? 1 : 3); i++) {
> +                        for (j = 0; j < pps->pps_num_palette_predictor_initializer; j++)

You're allowed to declare loop variables inside loops now.

> +                            pps->palette_predictor_initializers[i][j] = get_ue_golomb_long(gb);
> +                    }
> +                }
> +            }
> +        }
>      }
>  
>      ret = setup_pps(avctx, gb, pps, sps);
> diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h
> index 549e0bdf57..8dddf7ef8d 100644
> --- a/libavcodec/hevc_ps.h
> +++ b/libavcodec/hevc_ps.h
> @@ -210,6 +210,18 @@ typedef struct HEVCSPS {
>      VUI vui;
>      PTL ptl;
>  
> +    int sps_extension_present_flag;
> +    int sps_scc_extension_flag;
> +    int sps_curr_pic_ref_enabled_flag;
> +    int palette_mode_enabled_flag;
> +    uint8_t palette_max_size;
> +    uint8_t delta_palette_max_predictor_size;
> +    uint8_t motion_vector_resolution_control_idc;
> +    uint8_t sps_num_palette_predictor_initializer_minus1;
> +    int sps_palette_predictor_initializer_present_flag;
> +    int intra_boundary_filtering_disable_flag;
> +    uint16_t palette_predictor_initializers[3][HEVC_PREDICTOR_PALETTE_COMP_ENTRIES_LIST_SIZE];
> +
>      uint8_t scaling_list_enable_flag;
>      int scaling_list_data_present_flag;
>      ScalingList scaling_list;
> @@ -341,6 +353,20 @@ typedef struct HEVCPPS {
>      uint8_t log2_sao_offset_scale_luma;
>      uint8_t log2_sao_offset_scale_chroma;
>  
> +    int pps_scc_extension_flag;
> +    int pps_curr_pic_ref_enabled_flag;
> +    int residual_adaptive_colour_transform_enabled_flag;
> +    int pps_slice_act_qp_offsets_present_flag;
> +    int pps_palette_predictor_initializer_present_flag;
> +    int pps_num_palette_predictor_initializer;
> +    int monochrome_palette_flag;
> +    int luma_bit_depth_entry_minus8;
> +    int chroma_bit_depth_entry_minus8;
> +    int pps_act_y_qp_offset_plus5;
> +    int pps_act_cb_qp_offset_plus5;
> +    int pps_act_cr_qp_offset_plus3;

All those pps_ and sps_ and prefices are redundant pleonasms and make the
code more cluttered.

The _plusminus100500 are quite annoying too.

-- 
Anton Khirnov


More information about the ffmpeg-devel mailing list