[Mesa-dev] [PATCH] radeonsi: Add support for midstream bitrate change in encoder

Zhang, Boyuan Boyuan.Zhang at amd.com
Wed Dec 4 14:16:29 UTC 2019


Patch is
Reviewed-by: Boyuan Zhang <Boyuan.Zhang at amd.com<mailto:Boyuan.Zhang at amd.com>>

Regards,
Boyuan

From: Liu, Leo <Leo.Liu at amd.com>
Sent: December 3, 2019 9:08 PM
To: Marek Olšák <maraeo at gmail.com>; Sahu, Satyajit <Satyajit.Sahu at amd.com>; Zhang, Boyuan <Boyuan.Zhang at amd.com>
Cc: ML Mesa-dev <mesa-dev at lists.freedesktop.org>; Sharma, Deepak <Deepak.Sharma at amd.com>
Subject: Re: [Mesa-dev] [PATCH] radeonsi: Add support for midstream bitrate change in encoder

+Boyuan
________________________________
From: Marek Olšák <maraeo at gmail.com<mailto:maraeo at gmail.com>>
Sent: December 3, 2019 7:21:23 PM
To: Sahu, Satyajit <Satyajit.Sahu at amd.com<mailto:Satyajit.Sahu at amd.com>>; Liu, Leo <Leo.Liu at amd.com<mailto:Leo.Liu at amd.com>>
Cc: ML Mesa-dev <mesa-dev at lists.freedesktop.org<mailto:mesa-dev at lists.freedesktop.org>>; Sharma, Deepak <Deepak.Sharma at amd.com<mailto:Deepak.Sharma at amd.com>>
Subject: Re: [Mesa-dev] [PATCH] radeonsi: Add support for midstream bitrate change in encoder

+Leo

On Mon, Dec 2, 2019 at 11:31 PM Satyajit Sahu <satyajit.sahu at amd.com<mailto:satyajit.sahu at amd.com>> wrote:
Added support for bitrate change in between encoding.

Signed-off-by: Satyajit Sahu <satyajit.sahu at amd.com<mailto:satyajit.sahu at amd.com>>

diff --git a/src/gallium/drivers/radeon/radeon_vce.c b/src/gallium/drivers/radeon/radeon_vce.c
index 84d3c1e2fa4..7d7a2fa4eb3 100644
--- a/src/gallium/drivers/radeon/radeon_vce.c
+++ b/src/gallium/drivers/radeon/radeon_vce.c
@@ -268,7 +268,8 @@ static void rvce_begin_frame(struct pipe_video_codec *encoder,
                enc->pic.rate_ctrl.rate_ctrl_method != pic->rate_ctrl.rate_ctrl_method ||
                enc->pic.quant_i_frames != pic->quant_i_frames ||
                enc->pic.quant_p_frames != pic->quant_p_frames ||
-               enc->pic.quant_b_frames != pic->quant_b_frames;
+               enc->pic.quant_b_frames != pic->quant_b_frames ||
+               enc->pic.rate_ctrl.target_bitrate != pic->rate_ctrl.target_bitrate;

        enc->pic = *pic;
        si_get_pic_param(enc, pic);
diff --git a/src/gallium/drivers/radeon/radeon_vcn_enc.c b/src/gallium/drivers/radeon/radeon_vcn_enc.c
index aa9182f273b..c4fb9a7bd92 100644
--- a/src/gallium/drivers/radeon/radeon_vcn_enc.c
+++ b/src/gallium/drivers/radeon/radeon_vcn_enc.c
@@ -247,6 +247,17 @@ static void radeon_enc_begin_frame(struct pipe_video_codec *encoder,
 {
        struct radeon_encoder *enc = (struct radeon_encoder*)encoder;
        struct vl_video_buffer *vid_buf = (struct vl_video_buffer *)source;
+       bool need_rate_control = false;
+
+       if (u_reduce_video_profile(enc->base.profile) == PIPE_VIDEO_FORMAT_MPEG4_AVC) {
+               struct pipe_h264_enc_picture_desc *pic = (struct pipe_h264_enc_picture_desc *)picture;
+               need_rate_control =
+                       enc->enc_pic.rc_layer_init.target_bit_rate != pic->rate_ctrl.target_bitrate;
+       } else if (u_reduce_video_profile(picture->profile) == PIPE_VIDEO_FORMAT_HEVC) {
+                struct pipe_h265_enc_picture_desc *pic = (struct pipe_h265_enc_picture_desc *)picture;
+               need_rate_control =
+                       enc->enc_pic.rc_layer_init.target_bit_rate != pic->rc.target_bitrate;
+       }

        radeon_vcn_enc_get_param(enc, picture);

@@ -266,6 +277,10 @@ static void radeon_enc_begin_frame(struct pipe_video_codec *encoder,
                flush(enc);
                si_vid_destroy_buffer(&fb);
        }
+       if (need_rate_control) {
+               enc->begin(enc, picture);
+               flush(enc);
+       }
 }

 static void radeon_enc_encode_bitstream(struct pipe_video_codec *encoder,
--
2.17.1

_______________________________________________
mesa-dev mailing list
mesa-dev at lists.freedesktop.org<mailto:mesa-dev at lists.freedesktop.org>
https://lists.freedesktop.org/mailman/listinfo/mesa-dev<https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Fmesa-dev&data=02%7C01%7Cleo.liu%40amd.com%7Cae84ee699f3246cb915708d7784ffad3%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637110157225190450&sdata=dw2yJa%2BgZ3t1BlOH87PypwWIhmH2y7pZ8vU5SiWBkO8%3D&reserved=0>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20191204/f2d9159e/attachment.html>


More information about the mesa-dev mailing list