Module: Mesa Branch: main Commit: 9e82c5d864f59154bccfc890d7e7320d3ad64556 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9e82c5d864f59154bccfc890d7e7320d3ad64556
Author: David Rosca <[email protected]> Date: Wed Oct 4 16:51:05 2023 +0200 frontends/va: Parse H264 SPS for max_num_reorder_frames Reviewed-by: Ruijing Dong <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25565> --- src/gallium/frontends/va/picture_h264_enc.c | 48 +++++++++++++++++++++++++++++ src/gallium/include/pipe/p_video_state.h | 1 + 2 files changed, 49 insertions(+) diff --git a/src/gallium/frontends/va/picture_h264_enc.c b/src/gallium/frontends/va/picture_h264_enc.c index 48403b17e78..87b427b0ec5 100644 --- a/src/gallium/frontends/va/picture_h264_enc.c +++ b/src/gallium/frontends/va/picture_h264_enc.c @@ -325,9 +325,28 @@ vlVaHandleVAEncMiscParameterTypeFrameRateH264(vlVaContext *context, VAEncMiscPar return VA_STATUS_SUCCESS; } +static void parseEncHrdParamsH264(struct vl_rbsp *rbsp) +{ + unsigned i, cpb_cnt_minus1; + + cpb_cnt_minus1 = vl_rbsp_ue(rbsp); + vl_rbsp_u(rbsp, 4); /* bit_rate_scale */ + vl_rbsp_u(rbsp, 4); /* cpb_size_scale */ + for (i = 0; i <= cpb_cnt_minus1; ++i) { + vl_rbsp_ue(rbsp); /* bit_rate_value_minus1[i] */ + vl_rbsp_ue(rbsp); /* cpb_size_value_minus1[i] */ + vl_rbsp_u(rbsp, 1); /* cbr_flag[i] */ + } + vl_rbsp_u(rbsp, 5); /* initial_cpb_removal_delay_length_minus1 */ + vl_rbsp_u(rbsp, 5); /* cpb_removal_delay_length_minus1 */ + vl_rbsp_u(rbsp, 5); /* dpb_output_delay_length_minus1 */ + vl_rbsp_u(rbsp, 5); /* time_offset_length */ +} + static void parseEncSpsParamsH264(vlVaContext *context, struct vl_rbsp *rbsp) { unsigned i, profile_idc, num_ref_frames_in_pic_order_cnt_cycle; + unsigned nal_hrd_parameters_present_flag, vcl_hrd_parameters_present_flag; profile_idc = vl_rbsp_u(rbsp, 8); @@ -412,6 +431,35 @@ static void parseEncSpsParamsH264(vlVaContext *context, struct vl_rbsp *rbsp) context->desc.h264enc.seq.chroma_sample_loc_type_top_field = vl_rbsp_ue(rbsp); context->desc.h264enc.seq.chroma_sample_loc_type_bottom_field = vl_rbsp_ue(rbsp); } + + if (vl_rbsp_u(rbsp, 1)) { /* timing_info_present_flag */ + vl_rbsp_u(rbsp, 32); /* num_units_in_tick */ + vl_rbsp_u(rbsp, 32); /* time_scale */ + vl_rbsp_u(rbsp, 1); /* fixed_frame_rate_flag */ + } + + nal_hrd_parameters_present_flag = vl_rbsp_u(rbsp, 1); + if (nal_hrd_parameters_present_flag) + parseEncHrdParamsH264(rbsp); + + vcl_hrd_parameters_present_flag = vl_rbsp_u(rbsp, 1); + if (vcl_hrd_parameters_present_flag) + parseEncHrdParamsH264(rbsp); + + if (nal_hrd_parameters_present_flag || vcl_hrd_parameters_present_flag) + vl_rbsp_u(rbsp, 1); /* low_delay_hrd_flag */ + + vl_rbsp_u(rbsp, 1); /* pic_struct_present_flag */ + + if (vl_rbsp_u(rbsp, 1)) { /* bitstream_restriction_flag */ + vl_rbsp_u(rbsp, 1); /* motion_vectors_over_pic_boundaries_flag */ + vl_rbsp_ue(rbsp); /* max_bytes_per_pic_denom */ + vl_rbsp_ue(rbsp); /* max_bits_per_mb_denom */ + vl_rbsp_ue(rbsp); /* log2_max_mv_length_horizontal */ + vl_rbsp_ue(rbsp); /* log2_max_mv_length_vertical */ + context->desc.h264enc.seq.max_num_reorder_frames = vl_rbsp_ue(rbsp); + vl_rbsp_ue(rbsp); /* max_dec_frame_buffering */ + } } } diff --git a/src/gallium/include/pipe/p_video_state.h b/src/gallium/include/pipe/p_video_state.h index c3fe4371256..9cb34c55aa0 100644 --- a/src/gallium/include/pipe/p_video_state.h +++ b/src/gallium/include/pipe/p_video_state.h @@ -528,6 +528,7 @@ struct pipe_h264_enc_seq_param uint32_t matrix_coefficients; uint32_t chroma_sample_loc_type_top_field; uint32_t chroma_sample_loc_type_bottom_field; + uint32_t max_num_reorder_frames; }; struct pipe_h264_enc_picture_desc
