Module: Mesa
Branch: main
Commit: 8e76b8fb3517a227351d138a710b336e535257c1
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8e76b8fb3517a227351d138a710b336e535257c1

Author: David Rosca <[email protected]>
Date:   Wed Sep  6 12:07:50 2023 +0200

frontends/va: Parse chroma sample location in H264/HEVC SPS

Reviewed-by: Boyuan Zhang <[email protected]>
Reviewed-by: Sil Vilerino <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25078>

---

 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 1db984c90b5..e11895195ff 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 b0d5a8ef71f..36d31bef6c1 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 8ca665966b8..c3fe4371256 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

Reply via email to