aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhang, Boyuan <[email protected]>2019-12-04 14:16:29 +0000
committerMarge Bot <[email protected]>2020-01-31 07:47:36 +0000
commit00edb82fde2cfebe97457cb7819e7e560c4d3a4c (patch)
tree1274a2d99e66092fb1a6ce05972f4df7695ae43c
parentd902e23d8094a01f752d3404ec484e0c059eb193 (diff)
radeonsi: Add support for midstream bitrate change in encoder
BACKPORT: Remove |picture| argument from enc->begin in radeon_vcn_enc.c Signed-off-by: Satyajit Sahu <[email protected]> Reviewed-by: Boyuan Zhang <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3426> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3426>
-rw-r--r--src/gallium/drivers/radeon/radeon_vce.c3
-rw-r--r--src/gallium/drivers/radeon/radeon_vcn_enc.c15
2 files changed, 17 insertions, 1 deletions
diff --git a/src/gallium/drivers/radeon/radeon_vce.c b/src/gallium/drivers/radeon/radeon_vce.c
index 652b4250654..3e909d8b318 100644
--- a/src/gallium/drivers/radeon/radeon_vce.c
+++ b/src/gallium/drivers/radeon/radeon_vce.c
@@ -272,7 +272,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 0bcce867327..9cabbd4678e 100644
--- a/src/gallium/drivers/radeon/radeon_vcn_enc.c
+++ b/src/gallium/drivers/radeon/radeon_vcn_enc.c
@@ -254,6 +254,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);
@@ -273,6 +284,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);
+ flush(enc);
+ }
}
static void radeon_enc_encode_bitstream(struct pipe_video_codec *encoder,