[Mesa-dev] [PATCH 4/4] radeon/vce: handle newly added parameters
Samuel Pitoiset
samuel.pitoiset at gmail.com
Fri Jun 24 12:42:42 UTC 2016
On 06/24/2016 02:39 PM, Christian König wrote:
>> + if (pic->enable_low_level_control == true) {
>
> Well using this enable_low_level_control switch to choose between two
> sets of hardcoded values is clearly a no go.
>
> For the motion estimation and most of the other flags I would say just
> try to expose the parameters we have in the hardware structure in the
> pipe interface as well.
>
> Only for the bit rate control I'm absolutely not sure what to do. Is
> that an AMD specific extension what you do there? Cause I can't really
> understand why you do it like this.
>
> Ilia and/or maybe other nouveau developers: You guys don't have any
> plans to expose the NVidia encoding functionality through the
> OpenMAX/VA-API state trackers in the near future don't you?
Not in my plan, but maybe Ilia does want to?
>
> Regards,
> Christian.
>
> Am 22.06.2016 um 23:44 schrieb Boyuan Zhang:
>> Signed-off-by: Boyuan Zhang <boyuan.zhang at amd.com>
>> ---
>> src/gallium/drivers/radeon/radeon_vce_52.c | 107
>> +++++++++++++++++++++--------
>> 1 file changed, 79 insertions(+), 28 deletions(-)
>>
>> diff --git a/src/gallium/drivers/radeon/radeon_vce_52.c
>> b/src/gallium/drivers/radeon/radeon_vce_52.c
>> index 56b6dd8..ac577e3 100644
>> --- a/src/gallium/drivers/radeon/radeon_vce_52.c
>> +++ b/src/gallium/drivers/radeon/radeon_vce_52.c
>> @@ -48,36 +48,65 @@ static void get_rate_control_param(struct
>> rvce_encoder *enc, struct pipe_h264_en
>> enc->enc_pic.rc.quant_i_frames = pic->quant_i_frames;
>> enc->enc_pic.rc.quant_p_frames = pic->quant_p_frames;
>> enc->enc_pic.rc.quant_b_frames = pic->quant_b_frames;
>> + enc->enc_pic.rc.gop_size = pic->gop_size;
>> enc->enc_pic.rc.frame_rate_num = pic->rate_ctrl.frame_rate_num;
>> enc->enc_pic.rc.frame_rate_den = pic->rate_ctrl.frame_rate_den;
>> enc->enc_pic.rc.max_qp = 51;
>> - enc->enc_pic.rc.vbv_buffer_size = pic->rate_ctrl.vbv_buffer_size;
>> - enc->enc_pic.rc.vbv_buf_lv = 0;
>> - enc->enc_pic.rc.fill_data_enable = 0;
>> - enc->enc_pic.rc.enforce_hrd = 0;
>> - enc->enc_pic.rc.target_bits_picture =
>> pic->rate_ctrl.target_bits_picture;
>> - enc->enc_pic.rc.peak_bits_picture_integer =
>> pic->rate_ctrl.peak_bits_picture_integer;
>> - enc->enc_pic.rc.peak_bits_picture_fraction =
>> pic->rate_ctrl.peak_bits_picture_fraction;
>> + if (pic->enable_low_level_control == true) {
>> + enc->enc_pic.rc.vbv_buffer_size = 20000000;
>> + if (pic->rate_ctrl.frame_rate_num == 0)
>> + enc->enc_pic.rc.frame_rate_num = 30;
>> + if (pic->rate_ctrl.frame_rate_den == 0)
>> + enc->enc_pic.rc.frame_rate_den = 1;
>> + enc->enc_pic.rc.vbv_buf_lv = 48;
>> + enc->enc_pic.rc.fill_data_enable = 1;
>> + enc->enc_pic.rc.enforce_hrd = 1;
>> + enc->enc_pic.rc.target_bits_picture =
>> enc->enc_pic.rc.target_bitrate / enc->enc_pic.rc.frame_rate_num;
>> + enc->enc_pic.rc.peak_bits_picture_integer =
>> enc->enc_pic.rc.peak_bitrate / enc->enc_pic.rc.frame_rate_num;
>> + enc->enc_pic.rc.peak_bits_picture_fraction = 0;
>> + } else {
>> + enc->enc_pic.rc.vbv_buffer_size =
>> pic->rate_ctrl.vbv_buffer_size;
>> + enc->enc_pic.rc.vbv_buf_lv = 0;
>> + enc->enc_pic.rc.fill_data_enable = 0;
>> + enc->enc_pic.rc.enforce_hrd = 0;
>> + enc->enc_pic.rc.target_bits_picture =
>> pic->rate_ctrl.target_bits_picture;
>> + enc->enc_pic.rc.peak_bits_picture_integer =
>> pic->rate_ctrl.peak_bits_picture_integer;
>> + enc->enc_pic.rc.peak_bits_picture_fraction =
>> pic->rate_ctrl.peak_bits_picture_fraction;
>> + }
>> }
>> static void get_motion_estimation_param(struct rvce_encoder *enc,
>> struct pipe_h264_enc_picture_desc *pic)
>> {
>> -
>> - enc->enc_pic.me.motion_est_quarter_pixel = 0x00000000;
>> - enc->enc_pic.me.enc_disable_sub_mode = 0x000000fe;
>> - enc->enc_pic.me.lsmvert = 0x00000000;
>> - enc->enc_pic.me.enc_en_ime_overw_dis_subm = 0x00000000;
>> - enc->enc_pic.me.enc_ime_overw_dis_subm_no = 0x00000000;
>> - enc->enc_pic.me.enc_ime2_search_range_x = 0x00000001;
>> - enc->enc_pic.me.enc_ime2_search_range_y = 0x00000001;
>> - enc->enc_pic.me.enc_ime_decimation_search = 0x00000001;
>> - enc->enc_pic.me.motion_est_half_pixel = 0x00000001;
>> - enc->enc_pic.me.enc_search_range_x = 0x00000010;
>> - enc->enc_pic.me.enc_search_range_y = 0x00000010;
>> - enc->enc_pic.me.enc_search1_range_x = 0x00000010;
>> - enc->enc_pic.me.enc_search1_range_y = 0x00000010;
>> -
>> + if (pic->enable_low_level_control == true) {
>> + enc->enc_pic.me.motion_est_quarter_pixel = 0x00000001;
>> + enc->enc_pic.me.enc_disable_sub_mode = 0x00000078;
>> + enc->enc_pic.me.lsmvert = 0x00000002;
>> + enc->enc_pic.me.enc_en_ime_overw_dis_subm = 0x00000001;
>> + enc->enc_pic.me.enc_ime_overw_dis_subm_no = 0x00000001;
>> + enc->enc_pic.me.enc_ime2_search_range_x = 0x00000004;
>> + enc->enc_pic.me.enc_ime2_search_range_y = 0x00000004;
>> + enc->enc_pic.me.enc_ime_decimation_search = 0x00000001;
>> + enc->enc_pic.me.motion_est_half_pixel = 0x00000001;
>> + enc->enc_pic.me.enc_search_range_x = 0x00000010;
>> + enc->enc_pic.me.enc_search_range_y = 0x00000010;
>> + enc->enc_pic.me.enc_search1_range_x = 0x00000010;
>> + enc->enc_pic.me.enc_search1_range_y = 0x00000010;
>> + } else {
>> + enc->enc_pic.me.motion_est_quarter_pixel = 0x00000000;
>> + enc->enc_pic.me.enc_disable_sub_mode = 0x000000fe;
>> + enc->enc_pic.me.lsmvert = 0x00000000;
>> + enc->enc_pic.me.enc_en_ime_overw_dis_subm = 0x00000000;
>> + enc->enc_pic.me.enc_ime_overw_dis_subm_no = 0x00000000;
>> + enc->enc_pic.me.enc_ime2_search_range_x = 0x00000001;
>> + enc->enc_pic.me.enc_ime2_search_range_y = 0x00000001;
>> + enc->enc_pic.me.enc_ime_decimation_search = 0x00000001;
>> + enc->enc_pic.me.motion_est_half_pixel = 0x00000001;
>> + enc->enc_pic.me.enc_search_range_x = 0x00000010;
>> + enc->enc_pic.me.enc_search_range_y = 0x00000010;
>> + enc->enc_pic.me.enc_search1_range_x = 0x00000010;
>> + enc->enc_pic.me.enc_search1_range_y = 0x00000010;
>> + }
>> }
>> static void get_pic_control_param(struct rvce_encoder *enc, struct
>> pipe_h264_enc_picture_desc *pic)
>> @@ -93,11 +122,17 @@ static void get_pic_control_param(struct
>> rvce_encoder *enc, struct pipe_h264_enc
>> enc->enc_pic.pc.enc_max_num_ref_frames =
>> enc->base.max_references + 1;
>> enc->enc_pic.pc.enc_num_default_active_ref_l0 = 0x00000001;
>> enc->enc_pic.pc.enc_num_default_active_ref_l1 = 0x00000001;
>> - enc->enc_pic.pc.enc_cabac_enable = 0x00000000;
>> - enc->enc_pic.pc.enc_constraint_set_flags = 0x00000040;
>> - enc->enc_pic.pc.enc_num_default_active_ref_l0 = 0x00000001;
>> - enc->enc_pic.pc.enc_num_default_active_ref_l1 = 0x00000001;
>> -
>> + if (pic->enable_low_level_control == true) {
>> + enc->enc_pic.pc.enc_cabac_enable = 0x00000001;
>> + enc->enc_pic.pc.enc_constraint_set_flags = 0x00000040;
>> + enc->enc_pic.pc.enc_num_default_active_ref_l0 = 0x00000001;
>> + enc->enc_pic.pc.enc_num_default_active_ref_l1 = 0x00000001;
>> + } else {
>> + enc->enc_pic.pc.enc_cabac_enable = 0x00000000;
>> + enc->enc_pic.pc.enc_constraint_set_flags = 0x00000040;
>> + enc->enc_pic.pc.enc_num_default_active_ref_l0 = 0x00000001;
>> + enc->enc_pic.pc.enc_num_default_active_ref_l1 = 0x00000001;
>> + }
>> }
>> static void get_task_info_param(struct rvce_encoder *enc)
>> @@ -117,7 +152,10 @@ static void get_config_ext_param(struct
>> rvce_encoder *enc)
>> static void get_vui_param(struct rvce_encoder *enc, struct
>> pipe_h264_enc_picture_desc *pic)
>> {
>> - enc->enc_pic.enable_vui = (pic->rate_ctrl.frame_rate_num != 0);
>> + if (pic->enable_low_level_control == true)
>> + enc->enc_pic.enable_vui = 0;
>> + else
>> + enc->enc_pic.enable_vui = (pic->rate_ctrl.frame_rate_num != 0);
>> enc->enc_pic.vui.video_format = 0x00000005;
>> enc->enc_pic.vui.color_prim = 0x00000002;
>> enc->enc_pic.vui.transfer_char = 0x00000002;
>> @@ -143,6 +181,8 @@ static void get_vui_param(struct rvce_encoder
>> *enc, struct pipe_h264_enc_picture
>> void radeon_vce_52_get_param(struct rvce_encoder *enc, struct
>> pipe_h264_enc_picture_desc *pic)
>> {
>> + if (pic->enable_low_level_control == true)
>> + enc->enc_pic.ref_pic_mode = 0x01000201;
>> get_rate_control_param(enc, pic);
>> get_motion_estimation_param(enc, pic);
>> get_pic_control_param(enc, pic);
>> @@ -153,10 +193,21 @@ void radeon_vce_52_get_param(struct rvce_encoder
>> *enc, struct pipe_h264_enc_pict
>> enc->enc_pic.picture_type = pic->picture_type;
>> enc->enc_pic.frame_num = pic->frame_num;
>> + enc->enc_pic.frame_num_cnt = pic->frame_num_cnt;
>> + enc->enc_pic.p_remain = pic->p_remain;
>> + enc->enc_pic.i_remain = pic->i_remain;
>> + enc->enc_pic.gop_cnt = pic->gop_cnt;
>> enc->enc_pic.pic_order_cnt = pic->pic_order_cnt;
>> enc->enc_pic.ref_idx_l0 = pic->ref_idx_l0;
>> enc->enc_pic.ref_idx_l1 = pic->ref_idx_l1;
>> enc->enc_pic.not_referenced = pic->not_referenced;
>> + enc->enc_pic.is_idr = pic->is_idr;
>> + enc->enc_pic.has_ref_pic_list = pic->has_ref_pic_list;
>> + for (int i = 0; i < 32 ; i++) {
>> + enc->enc_pic.ref_pic_list_0[i] = pic->ref_pic_list_0[i];
>> + enc->enc_pic.ref_pic_list_1[i] = pic->ref_pic_list_1[i];
>> + enc->enc_pic.frame_idx[i] = pic->frame_idx[i];
>> + }
>> }
>> static void create(struct rvce_encoder *enc)
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
--
-Samuel
More information about the mesa-dev
mailing list