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

Author: Ruijing Dong <[email protected]>
Date:   Tue Apr 18 16:39:23 2023 -0400

radeonsi/vcn: merge get_output_format_param function

reason:
so far, the output_format_param function can be shared
by different encoders, and just for h264 encoder, there
is no 10bit encoding supported. This is to reduce
the repeated code before having av1 encoder.

Reviewed-by: Boyuan Zhang <[email protected]>
Signed-off-by: Ruijing Dong <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22585>

---

 src/gallium/drivers/radeonsi/radeon_vcn_enc.c | 45 ++++++++++-----------------
 1 file changed, 17 insertions(+), 28 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/radeon_vcn_enc.c 
b/src/gallium/drivers/radeonsi/radeon_vcn_enc.c
index 15073b71a57..63af54a4f4f 100644
--- a/src/gallium/drivers/radeonsi/radeon_vcn_enc.c
+++ b/src/gallium/drivers/radeonsi/radeon_vcn_enc.c
@@ -216,13 +216,22 @@ static void 
radeon_vcn_enc_h264_get_slice_ctrl_param(struct radeon_encoder *enc,
    enc->enc_pic.slice_ctrl.num_mbs_per_slice = num_mbs_in_slice;
 }
 
-static void radeon_vcn_enc_h264_get_output_format_param(struct radeon_encoder 
*enc,
-                                                        struct 
pipe_h264_enc_picture_desc *pic)
+static void radeon_vcn_enc_get_output_format_param(struct radeon_encoder *enc)
 {
-   enc->enc_pic.enc_output_format.output_color_volume = 
RENCODE_COLOR_VOLUME_G22_BT709;
-   enc->enc_pic.enc_output_format.output_color_range = 
RENCODE_COLOR_RANGE_FULL;
-   enc->enc_pic.enc_output_format.output_chroma_location = 
RENCODE_CHROMA_LOCATION_INTERSTITIAL;
-   enc->enc_pic.enc_output_format.output_color_bit_depth = 
RENCODE_COLOR_BIT_DEPTH_8_BIT;
+   switch (enc->enc_pic.bit_depth_luma_minus8) {
+   case 2: /* 10 bits */
+      enc->enc_pic.enc_output_format.output_color_volume = 
RENCODE_COLOR_VOLUME_G22_BT709;
+      enc->enc_pic.enc_output_format.output_color_range = 
RENCODE_COLOR_RANGE_FULL;
+      enc->enc_pic.enc_output_format.output_chroma_location = 
RENCODE_CHROMA_LOCATION_INTERSTITIAL;
+      enc->enc_pic.enc_output_format.output_color_bit_depth = 
RENCODE_COLOR_BIT_DEPTH_10_BIT;
+      break;
+   default: /* 8 bits */
+      enc->enc_pic.enc_output_format.output_color_volume = 
RENCODE_COLOR_VOLUME_G22_BT709;
+      enc->enc_pic.enc_output_format.output_color_range = 
RENCODE_COLOR_RANGE_FULL;
+      enc->enc_pic.enc_output_format.output_chroma_location = 
RENCODE_CHROMA_LOCATION_INTERSTITIAL;
+      enc->enc_pic.enc_output_format.output_color_bit_depth = 
RENCODE_COLOR_BIT_DEPTH_8_BIT;
+      break;
+   }
 }
 
 static void radeon_vcn_enc_get_input_format_param(struct radeon_encoder *enc,
@@ -271,7 +280,7 @@ static void radeon_vcn_enc_h264_get_param(struct 
radeon_encoder *enc,
    radeon_vcn_enc_h264_get_vui_param(enc, pic);
    radeon_vcn_enc_h264_get_slice_ctrl_param(enc, pic);
    radeon_vcn_enc_get_input_format_param(enc, &pic->base);
-   radeon_vcn_enc_h264_get_output_format_param(enc, pic);
+   radeon_vcn_enc_get_output_format_param(enc);
 }
 
 static void radeon_vcn_enc_hevc_get_cropping_param(struct radeon_encoder *enc,
@@ -412,25 +421,6 @@ static void 
radeon_vcn_enc_hevc_get_slice_ctrl_param(struct radeon_encoder *enc,
       num_ctbs_in_slice;
 }
 
-static void radeon_vcn_enc_hevc_get_output_format_param(struct radeon_encoder 
*enc,
-                                                        struct 
pipe_h265_enc_picture_desc *pic)
-{
-   switch (enc->enc_pic.bit_depth_luma_minus8) {
-   case 2: /* 10 bits */
-      enc->enc_pic.enc_output_format.output_color_volume = 
RENCODE_COLOR_VOLUME_G22_BT709;
-      enc->enc_pic.enc_output_format.output_color_range = 
RENCODE_COLOR_RANGE_FULL;
-      enc->enc_pic.enc_output_format.output_chroma_location = 
RENCODE_CHROMA_LOCATION_INTERSTITIAL;
-      enc->enc_pic.enc_output_format.output_color_bit_depth = 
RENCODE_COLOR_BIT_DEPTH_10_BIT;
-      break;
-   default: /* 8 bits */
-      enc->enc_pic.enc_output_format.output_color_volume = 
RENCODE_COLOR_VOLUME_G22_BT709;
-      enc->enc_pic.enc_output_format.output_color_range = 
RENCODE_COLOR_RANGE_FULL;
-      enc->enc_pic.enc_output_format.output_chroma_location = 
RENCODE_CHROMA_LOCATION_INTERSTITIAL;
-      enc->enc_pic.enc_output_format.output_color_bit_depth = 
RENCODE_COLOR_BIT_DEPTH_8_BIT;
-      break;
-   }
-}
-
 static void radeon_vcn_enc_hevc_get_param(struct radeon_encoder *enc,
                                           struct pipe_h265_enc_picture_desc 
*pic)
 {
@@ -485,11 +475,10 @@ static void radeon_vcn_enc_hevc_get_param(struct 
radeon_encoder *enc,
    radeon_vcn_enc_hevc_get_spec_misc_param(enc, pic);
    radeon_vcn_enc_hevc_get_dbk_param(enc, pic);
    radeon_vcn_enc_hevc_get_rc_param(enc, pic);
-   radeon_vcn_enc_hevc_get_rc_param(enc, pic);
    radeon_vcn_enc_hevc_get_vui_param(enc, pic);
    radeon_vcn_enc_hevc_get_slice_ctrl_param(enc, pic);
    radeon_vcn_enc_get_input_format_param(enc, &pic->base);
-   radeon_vcn_enc_hevc_get_output_format_param(enc, pic);
+   radeon_vcn_enc_get_output_format_param(enc);
 }
 
 static void radeon_vcn_enc_get_param(struct radeon_encoder *enc, struct 
pipe_picture_desc *picture)

Reply via email to