From 8e76b8fb3517a227351d138a710b336e535257c1 Mon Sep 17 00:00:00 2001 From: David Rosca Date: Wed, 6 Sep 2023 12:07:50 +0200 Subject: [PATCH] frontends/va: Parse chroma sample location in H264/HEVC SPS Reviewed-by: Boyuan Zhang Reviewed-by: Sil Vilerino Part-of: --- src/gallium/frontends/va/picture_h264_enc.c | 6 ++++++ src/gallium/frontends/va/picture_hevc_enc.c | 6 ++++++ src/gallium/include/pipe/p_video_state.h | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/src/gallium/frontends/va/picture_h264_enc.c b/src/gallium/frontends/va/picture_h264_enc.c index 1db984c..e118951 100644 --- a/src/gallium/frontends/va/picture_h264_enc.c +++ b/src/gallium/frontends/va/picture_h264_enc.c @@ -399,6 +399,12 @@ static void parseEncSpsParamsH264(vlVaContext *context, struct vl_rbsp *rbsp) context->desc.h264enc.seq.matrix_coefficients = vl_rbsp_u(rbsp, 8); } } + + context->desc.h264enc.seq.vui_flags.chroma_loc_info_present_flag = vl_rbsp_u(rbsp, 1); + if (context->desc.h264enc.seq.vui_flags.chroma_loc_info_present_flag) { + 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); + } } } diff --git a/src/gallium/frontends/va/picture_hevc_enc.c b/src/gallium/frontends/va/picture_hevc_enc.c index b0d5a8e..36d31be 100644 --- a/src/gallium/frontends/va/picture_hevc_enc.c +++ b/src/gallium/frontends/va/picture_hevc_enc.c @@ -425,6 +425,12 @@ static void parseEncSpsParamsH265(vlVaContext *context, struct vl_rbsp *rbsp) context->desc.h265enc.seq.matrix_coefficients = vl_rbsp_u(rbsp, 8); } } + + context->desc.h265enc.seq.vui_flags.chroma_loc_info_present_flag = vl_rbsp_u(rbsp, 1); + if (context->desc.h265enc.seq.vui_flags.chroma_loc_info_present_flag) { + context->desc.h265enc.seq.chroma_sample_loc_type_top_field = vl_rbsp_ue(rbsp); + context->desc.h265enc.seq.chroma_sample_loc_type_bottom_field = vl_rbsp_ue(rbsp); + } } } diff --git a/src/gallium/include/pipe/p_video_state.h b/src/gallium/include/pipe/p_video_state.h index 8ca6659..c3fe437 100644 --- a/src/gallium/include/pipe/p_video_state.h +++ b/src/gallium/include/pipe/p_video_state.h @@ -514,6 +514,7 @@ struct pipe_h264_enc_seq_param uint32_t timing_info_present_flag: 1; uint32_t video_signal_type_present_flag: 1; uint32_t colour_description_present_flag: 1; + uint32_t chroma_loc_info_present_flag: 1; } vui_flags; uint32_t aspect_ratio_idc; uint32_t sar_width; @@ -525,6 +526,8 @@ struct pipe_h264_enc_seq_param uint32_t colour_primaries; uint32_t transfer_characteristics; uint32_t matrix_coefficients; + uint32_t chroma_sample_loc_type_top_field; + uint32_t chroma_sample_loc_type_bottom_field; }; struct pipe_h264_enc_picture_desc @@ -605,6 +608,7 @@ struct pipe_h265_enc_seq_param uint32_t timing_info_present_flag: 1; uint32_t video_signal_type_present_flag: 1; uint32_t colour_description_present_flag: 1; + uint32_t chroma_loc_info_present_flag: 1; } vui_flags; uint32_t aspect_ratio_idc; uint32_t sar_width; @@ -616,6 +620,8 @@ struct pipe_h265_enc_seq_param uint32_t colour_primaries; uint32_t transfer_characteristics; uint32_t matrix_coefficients; + uint32_t chroma_sample_loc_type_top_field; + uint32_t chroma_sample_loc_type_bottom_field; }; struct pipe_h265_enc_pic_param -- 2.7.4