Message ID | 20240729193219.1260463-2-frkoenig@chromium.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [v2,1/3] media: venus: Reorder encoder property setting | expand |
On 7/30/2024 12:49 AM, Fritz Koenig wrote: > Configure the generic controls before the codec specific ones. > Some codec specific controls can override the generic ones. > > Signed-off-by: Fritz Koenig <frkoenig@chromium.org> > --- > v2: > - requested testing methodology added to cover letter > > drivers/media/platform/qcom/venus/venc.c | 183 +++++++++++------------ > 1 file changed, 91 insertions(+), 92 deletions(-) > > diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c > index 3ec2fb8d9fab..ae24de125c56 100644 > --- a/drivers/media/platform/qcom/venus/venc.c > +++ b/drivers/media/platform/qcom/venus/venc.c > @@ -688,98 +688,6 @@ static int venc_set_properties(struct venus_inst *inst) > if (ret) > return ret; > > - if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264) { > - struct hfi_h264_vui_timing_info info; > - struct hfi_h264_entropy_control entropy; > - struct hfi_h264_db_control deblock; > - struct hfi_h264_8x8_transform h264_transform; > - > - ptype = HFI_PROPERTY_PARAM_VENC_H264_VUI_TIMING_INFO; > - info.enable = 1; > - info.fixed_framerate = 1; > - info.time_scale = NSEC_PER_SEC; > - > - ret = hfi_session_set_property(inst, ptype, &info); > - if (ret) > - return ret; > - > - ptype = HFI_PROPERTY_PARAM_VENC_H264_ENTROPY_CONTROL; > - entropy.entropy_mode = venc_v4l2_to_hfi( > - V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE, > - ctr->h264_entropy_mode); > - entropy.cabac_model = HFI_H264_CABAC_MODEL_0; > - > - ret = hfi_session_set_property(inst, ptype, &entropy); > - if (ret) > - return ret; > - > - ptype = HFI_PROPERTY_PARAM_VENC_H264_DEBLOCK_CONTROL; > - deblock.mode = venc_v4l2_to_hfi( > - V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE, > - ctr->h264_loop_filter_mode); > - deblock.slice_alpha_offset = ctr->h264_loop_filter_alpha; > - deblock.slice_beta_offset = ctr->h264_loop_filter_beta; > - > - ret = hfi_session_set_property(inst, ptype, &deblock); > - if (ret) > - return ret; > - > - ptype = HFI_PROPERTY_PARAM_VENC_H264_TRANSFORM_8X8; > - h264_transform.enable_type = 0; > - if (ctr->profile.h264 == V4L2_MPEG_VIDEO_H264_PROFILE_HIGH || > - ctr->profile.h264 == V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_HIGH) > - h264_transform.enable_type = ctr->h264_8x8_transform; > - > - ret = hfi_session_set_property(inst, ptype, &h264_transform); > - if (ret) > - return ret; > - > - } > - > - if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264 || > - inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC) { > - /* IDR periodicity, n: > - * n = 0 - only the first I-frame is IDR frame > - * n = 1 - all I-frames will be IDR frames > - * n > 1 - every n-th I-frame will be IDR frame > - */ > - ptype = HFI_PROPERTY_CONFIG_VENC_IDR_PERIOD; > - idrp.idr_period = 0; > - ret = hfi_session_set_property(inst, ptype, &idrp); > - if (ret) > - return ret; > - } > - > - if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC && > - ctr->profile.hevc == V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10) { > - struct hfi_hdr10_pq_sei hdr10; > - unsigned int c; > - > - ptype = HFI_PROPERTY_PARAM_VENC_HDR10_PQ_SEI; > - > - for (c = 0; c < 3; c++) { > - hdr10.mastering.display_primaries_x[c] = > - ctr->mastering.display_primaries_x[c]; > - hdr10.mastering.display_primaries_y[c] = > - ctr->mastering.display_primaries_y[c]; > - } > - > - hdr10.mastering.white_point_x = ctr->mastering.white_point_x; > - hdr10.mastering.white_point_y = ctr->mastering.white_point_y; > - hdr10.mastering.max_display_mastering_luminance = > - ctr->mastering.max_display_mastering_luminance; > - hdr10.mastering.min_display_mastering_luminance = > - ctr->mastering.min_display_mastering_luminance; > - > - hdr10.cll.max_content_light = ctr->cll.max_content_light_level; > - hdr10.cll.max_pic_average_light = > - ctr->cll.max_pic_average_light_level; > - > - ret = hfi_session_set_property(inst, ptype, &hdr10); > - if (ret) > - return ret; > - } > - > if (ctr->num_b_frames) { > u32 max_num_b_frames = NUM_B_FRAMES_MAX; > > @@ -922,6 +830,97 @@ static int venc_set_properties(struct venus_inst *inst) > if (ret) > return ret; > > + if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264) { > + struct hfi_h264_vui_timing_info info; > + struct hfi_h264_entropy_control entropy; > + struct hfi_h264_db_control deblock; > + struct hfi_h264_8x8_transform h264_transform; > + > + ptype = HFI_PROPERTY_PARAM_VENC_H264_VUI_TIMING_INFO; > + info.enable = 1; > + info.fixed_framerate = 1; > + info.time_scale = NSEC_PER_SEC; > + > + ret = hfi_session_set_property(inst, ptype, &info); > + if (ret) > + return ret; > + > + ptype = HFI_PROPERTY_PARAM_VENC_H264_ENTROPY_CONTROL; > + entropy.entropy_mode = venc_v4l2_to_hfi( > + V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE, > + ctr->h264_entropy_mode); > + entropy.cabac_model = HFI_H264_CABAC_MODEL_0; > + > + ret = hfi_session_set_property(inst, ptype, &entropy); > + if (ret) > + return ret; > + > + ptype = HFI_PROPERTY_PARAM_VENC_H264_DEBLOCK_CONTROL; > + deblock.mode = venc_v4l2_to_hfi( > + V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE, > + ctr->h264_loop_filter_mode); > + deblock.slice_alpha_offset = ctr->h264_loop_filter_alpha; > + deblock.slice_beta_offset = ctr->h264_loop_filter_beta; > + > + ret = hfi_session_set_property(inst, ptype, &deblock); > + if (ret) > + return ret; > + > + ptype = HFI_PROPERTY_PARAM_VENC_H264_TRANSFORM_8X8; > + h264_transform.enable_type = 0; > + if (ctr->profile.h264 == V4L2_MPEG_VIDEO_H264_PROFILE_HIGH || > + ctr->profile.h264 == V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_HIGH) > + h264_transform.enable_type = ctr->h264_8x8_transform; > + > + ret = hfi_session_set_property(inst, ptype, &h264_transform); > + if (ret) > + return ret; > + } > + > + if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264 || > + inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC) { > + /* IDR periodicity, n: > + * n = 0 - only the first I-frame is IDR frame > + * n = 1 - all I-frames will be IDR frames > + * n > 1 - every n-th I-frame will be IDR frame > + */ > + ptype = HFI_PROPERTY_CONFIG_VENC_IDR_PERIOD; > + idrp.idr_period = 0; > + ret = hfi_session_set_property(inst, ptype, &idrp); > + if (ret) > + return ret; > + } > + > + if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC && > + ctr->profile.hevc == V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10) { > + struct hfi_hdr10_pq_sei hdr10; > + unsigned int c; > + > + ptype = HFI_PROPERTY_PARAM_VENC_HDR10_PQ_SEI; > + > + for (c = 0; c < 3; c++) { > + hdr10.mastering.display_primaries_x[c] = > + ctr->mastering.display_primaries_x[c]; > + hdr10.mastering.display_primaries_y[c] = > + ctr->mastering.display_primaries_y[c]; > + } > + > + hdr10.mastering.white_point_x = ctr->mastering.white_point_x; > + hdr10.mastering.white_point_y = ctr->mastering.white_point_y; > + hdr10.mastering.max_display_mastering_luminance = > + ctr->mastering.max_display_mastering_luminance; > + hdr10.mastering.min_display_mastering_luminance = > + ctr->mastering.min_display_mastering_luminance; > + > + hdr10.cll.max_content_light = ctr->cll.max_content_light_level; > + hdr10.cll.max_pic_average_light = > + ctr->cll.max_pic_average_light_level; > + > + ret = hfi_session_set_property(inst, ptype, &hdr10); > + if (ret) > + return ret; > + } > + > switch (inst->hfi_codec) { > case HFI_VIDEO_CODEC_H264: > profile = ctr->profile.h264; Changing the order might cause issue for other functionalities. Also, Client should either set the commutative bitrate or layerwise bitrate. So, if the motive behind this re-order is to not update the commutative bitrate, then that is expected and this way there might not be a need to change current order. Thanks, Dikshita
On Tue, Aug 13, 2024 at 9:38 PM Dikshita Agarwal <quic_dikshita@quicinc.com> wrote: > > > > On 7/30/2024 12:49 AM, Fritz Koenig wrote: > > Configure the generic controls before the codec specific ones. > > Some codec specific controls can override the generic ones. > > > > Signed-off-by: Fritz Koenig <frkoenig@chromium.org> > > --- > > v2: > > - requested testing methodology added to cover letter > > > > drivers/media/platform/qcom/venus/venc.c | 183 +++++++++++------------ > > 1 file changed, 91 insertions(+), 92 deletions(-) > > > > diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c > > index 3ec2fb8d9fab..ae24de125c56 100644 > > --- a/drivers/media/platform/qcom/venus/venc.c > > +++ b/drivers/media/platform/qcom/venus/venc.c > > @@ -688,98 +688,6 @@ static int venc_set_properties(struct venus_inst *inst) > > if (ret) > > return ret; > > > > - if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264) { > > - struct hfi_h264_vui_timing_info info; > > - struct hfi_h264_entropy_control entropy; > > - struct hfi_h264_db_control deblock; > > - struct hfi_h264_8x8_transform h264_transform; > > - > > - ptype = HFI_PROPERTY_PARAM_VENC_H264_VUI_TIMING_INFO; > > - info.enable = 1; > > - info.fixed_framerate = 1; > > - info.time_scale = NSEC_PER_SEC; > > - > > - ret = hfi_session_set_property(inst, ptype, &info); > > - if (ret) > > - return ret; > > - > > - ptype = HFI_PROPERTY_PARAM_VENC_H264_ENTROPY_CONTROL; > > - entropy.entropy_mode = venc_v4l2_to_hfi( > > - V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE, > > - ctr->h264_entropy_mode); > > - entropy.cabac_model = HFI_H264_CABAC_MODEL_0; > > - > > - ret = hfi_session_set_property(inst, ptype, &entropy); > > - if (ret) > > - return ret; > > - > > - ptype = HFI_PROPERTY_PARAM_VENC_H264_DEBLOCK_CONTROL; > > - deblock.mode = venc_v4l2_to_hfi( > > - V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE, > > - ctr->h264_loop_filter_mode); > > - deblock.slice_alpha_offset = ctr->h264_loop_filter_alpha; > > - deblock.slice_beta_offset = ctr->h264_loop_filter_beta; > > - > > - ret = hfi_session_set_property(inst, ptype, &deblock); > > - if (ret) > > - return ret; > > - > > - ptype = HFI_PROPERTY_PARAM_VENC_H264_TRANSFORM_8X8; > > - h264_transform.enable_type = 0; > > - if (ctr->profile.h264 == V4L2_MPEG_VIDEO_H264_PROFILE_HIGH || > > - ctr->profile.h264 == V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_HIGH) > > - h264_transform.enable_type = ctr->h264_8x8_transform; > > - > > - ret = hfi_session_set_property(inst, ptype, &h264_transform); > > - if (ret) > > - return ret; > > - > > - } > > - > > - if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264 || > > - inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC) { > > - /* IDR periodicity, n: > > - * n = 0 - only the first I-frame is IDR frame > > - * n = 1 - all I-frames will be IDR frames > > - * n > 1 - every n-th I-frame will be IDR frame > > - */ > > - ptype = HFI_PROPERTY_CONFIG_VENC_IDR_PERIOD; > > - idrp.idr_period = 0; > > - ret = hfi_session_set_property(inst, ptype, &idrp); > > - if (ret) > > - return ret; > > - } > > - > > - if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC && > > - ctr->profile.hevc == V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10) { > > - struct hfi_hdr10_pq_sei hdr10; > > - unsigned int c; > > - > > - ptype = HFI_PROPERTY_PARAM_VENC_HDR10_PQ_SEI; > > - > > - for (c = 0; c < 3; c++) { > > - hdr10.mastering.display_primaries_x[c] = > > - ctr->mastering.display_primaries_x[c]; > > - hdr10.mastering.display_primaries_y[c] = > > - ctr->mastering.display_primaries_y[c]; > > - } > > - > > - hdr10.mastering.white_point_x = ctr->mastering.white_point_x; > > - hdr10.mastering.white_point_y = ctr->mastering.white_point_y; > > - hdr10.mastering.max_display_mastering_luminance = > > - ctr->mastering.max_display_mastering_luminance; > > - hdr10.mastering.min_display_mastering_luminance = > > - ctr->mastering.min_display_mastering_luminance; > > - > > - hdr10.cll.max_content_light = ctr->cll.max_content_light_level; > > - hdr10.cll.max_pic_average_light = > > - ctr->cll.max_pic_average_light_level; > > - > > - ret = hfi_session_set_property(inst, ptype, &hdr10); > > - if (ret) > > - return ret; > > - } > > - > > if (ctr->num_b_frames) { > > u32 max_num_b_frames = NUM_B_FRAMES_MAX; > > > > @@ -922,6 +830,97 @@ static int venc_set_properties(struct venus_inst *inst) > > if (ret) > > return ret; > > > > + if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264) { > > + struct hfi_h264_vui_timing_info info; > > + struct hfi_h264_entropy_control entropy; > > + struct hfi_h264_db_control deblock; > > + struct hfi_h264_8x8_transform h264_transform; > > + > > + ptype = HFI_PROPERTY_PARAM_VENC_H264_VUI_TIMING_INFO; > > + info.enable = 1; > > + info.fixed_framerate = 1; > > + info.time_scale = NSEC_PER_SEC; > > + > > + ret = hfi_session_set_property(inst, ptype, &info); > > + if (ret) > > + return ret; > > + > > + ptype = HFI_PROPERTY_PARAM_VENC_H264_ENTROPY_CONTROL; > > + entropy.entropy_mode = venc_v4l2_to_hfi( > > + V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE, > > + ctr->h264_entropy_mode); > > + entropy.cabac_model = HFI_H264_CABAC_MODEL_0; > > + > > + ret = hfi_session_set_property(inst, ptype, &entropy); > > + if (ret) > > + return ret; > > + > > + ptype = HFI_PROPERTY_PARAM_VENC_H264_DEBLOCK_CONTROL; > > + deblock.mode = venc_v4l2_to_hfi( > > + V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE, > > + ctr->h264_loop_filter_mode); > > + deblock.slice_alpha_offset = ctr->h264_loop_filter_alpha; > > + deblock.slice_beta_offset = ctr->h264_loop_filter_beta; > > + > > + ret = hfi_session_set_property(inst, ptype, &deblock); > > + if (ret) > > + return ret; > > + > > + ptype = HFI_PROPERTY_PARAM_VENC_H264_TRANSFORM_8X8; > > + h264_transform.enable_type = 0; > > + if (ctr->profile.h264 == V4L2_MPEG_VIDEO_H264_PROFILE_HIGH || > > + ctr->profile.h264 == V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_HIGH) > > + h264_transform.enable_type = ctr->h264_8x8_transform; > > + > > + ret = hfi_session_set_property(inst, ptype, &h264_transform); > > + if (ret) > > + return ret; > > + } > > + > > + if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264 || > > + inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC) { > > + /* IDR periodicity, n: > > + * n = 0 - only the first I-frame is IDR frame > > + * n = 1 - all I-frames will be IDR frames > > + * n > 1 - every n-th I-frame will be IDR frame > > + */ > > + ptype = HFI_PROPERTY_CONFIG_VENC_IDR_PERIOD; > > + idrp.idr_period = 0; > > + ret = hfi_session_set_property(inst, ptype, &idrp); > > + if (ret) > > + return ret; > > + } > > + > > + if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC && > > + ctr->profile.hevc == V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10) { > > + struct hfi_hdr10_pq_sei hdr10; > > + unsigned int c; > > + > > + ptype = HFI_PROPERTY_PARAM_VENC_HDR10_PQ_SEI; > > + > > + for (c = 0; c < 3; c++) { > > + hdr10.mastering.display_primaries_x[c] = > > + ctr->mastering.display_primaries_x[c]; > > + hdr10.mastering.display_primaries_y[c] = > > + ctr->mastering.display_primaries_y[c]; > > + } > > + > > + hdr10.mastering.white_point_x = ctr->mastering.white_point_x; > > + hdr10.mastering.white_point_y = ctr->mastering.white_point_y; > > + hdr10.mastering.max_display_mastering_luminance = > > + ctr->mastering.max_display_mastering_luminance; > > + hdr10.mastering.min_display_mastering_luminance = > > + ctr->mastering.min_display_mastering_luminance; > > + > > + hdr10.cll.max_content_light = ctr->cll.max_content_light_level; > > + hdr10.cll.max_pic_average_light = > > + ctr->cll.max_pic_average_light_level; > > + > > + ret = hfi_session_set_property(inst, ptype, &hdr10); > > + if (ret) > > + return ret; > > + } > > + > > switch (inst->hfi_codec) { > > case HFI_VIDEO_CODEC_H264: > > profile = ctr->profile.h264; > > Changing the order might cause issue for other functionalities. > > Also, Client should either set the commutative bitrate or layerwise > bitrate. So, if the motive behind this re-order is to not update the > commutative bitrate, then that is expected and this way there might not be > a need to change current order. > > Thanks, > Dikshita Somewhat orthogonal, how should the max bitrate be handled? If ctr->bitrate_peak is not set, it is based off of the commutative bitrate. Should it be based off of the bitrate of layer 0? or the highest bitrate of the layers? -Fritz
diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index 3ec2fb8d9fab..ae24de125c56 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -688,98 +688,6 @@ static int venc_set_properties(struct venus_inst *inst) if (ret) return ret; - if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264) { - struct hfi_h264_vui_timing_info info; - struct hfi_h264_entropy_control entropy; - struct hfi_h264_db_control deblock; - struct hfi_h264_8x8_transform h264_transform; - - ptype = HFI_PROPERTY_PARAM_VENC_H264_VUI_TIMING_INFO; - info.enable = 1; - info.fixed_framerate = 1; - info.time_scale = NSEC_PER_SEC; - - ret = hfi_session_set_property(inst, ptype, &info); - if (ret) - return ret; - - ptype = HFI_PROPERTY_PARAM_VENC_H264_ENTROPY_CONTROL; - entropy.entropy_mode = venc_v4l2_to_hfi( - V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE, - ctr->h264_entropy_mode); - entropy.cabac_model = HFI_H264_CABAC_MODEL_0; - - ret = hfi_session_set_property(inst, ptype, &entropy); - if (ret) - return ret; - - ptype = HFI_PROPERTY_PARAM_VENC_H264_DEBLOCK_CONTROL; - deblock.mode = venc_v4l2_to_hfi( - V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE, - ctr->h264_loop_filter_mode); - deblock.slice_alpha_offset = ctr->h264_loop_filter_alpha; - deblock.slice_beta_offset = ctr->h264_loop_filter_beta; - - ret = hfi_session_set_property(inst, ptype, &deblock); - if (ret) - return ret; - - ptype = HFI_PROPERTY_PARAM_VENC_H264_TRANSFORM_8X8; - h264_transform.enable_type = 0; - if (ctr->profile.h264 == V4L2_MPEG_VIDEO_H264_PROFILE_HIGH || - ctr->profile.h264 == V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_HIGH) - h264_transform.enable_type = ctr->h264_8x8_transform; - - ret = hfi_session_set_property(inst, ptype, &h264_transform); - if (ret) - return ret; - - } - - if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264 || - inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC) { - /* IDR periodicity, n: - * n = 0 - only the first I-frame is IDR frame - * n = 1 - all I-frames will be IDR frames - * n > 1 - every n-th I-frame will be IDR frame - */ - ptype = HFI_PROPERTY_CONFIG_VENC_IDR_PERIOD; - idrp.idr_period = 0; - ret = hfi_session_set_property(inst, ptype, &idrp); - if (ret) - return ret; - } - - if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC && - ctr->profile.hevc == V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10) { - struct hfi_hdr10_pq_sei hdr10; - unsigned int c; - - ptype = HFI_PROPERTY_PARAM_VENC_HDR10_PQ_SEI; - - for (c = 0; c < 3; c++) { - hdr10.mastering.display_primaries_x[c] = - ctr->mastering.display_primaries_x[c]; - hdr10.mastering.display_primaries_y[c] = - ctr->mastering.display_primaries_y[c]; - } - - hdr10.mastering.white_point_x = ctr->mastering.white_point_x; - hdr10.mastering.white_point_y = ctr->mastering.white_point_y; - hdr10.mastering.max_display_mastering_luminance = - ctr->mastering.max_display_mastering_luminance; - hdr10.mastering.min_display_mastering_luminance = - ctr->mastering.min_display_mastering_luminance; - - hdr10.cll.max_content_light = ctr->cll.max_content_light_level; - hdr10.cll.max_pic_average_light = - ctr->cll.max_pic_average_light_level; - - ret = hfi_session_set_property(inst, ptype, &hdr10); - if (ret) - return ret; - } - if (ctr->num_b_frames) { u32 max_num_b_frames = NUM_B_FRAMES_MAX; @@ -922,6 +830,97 @@ static int venc_set_properties(struct venus_inst *inst) if (ret) return ret; + if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264) { + struct hfi_h264_vui_timing_info info; + struct hfi_h264_entropy_control entropy; + struct hfi_h264_db_control deblock; + struct hfi_h264_8x8_transform h264_transform; + + ptype = HFI_PROPERTY_PARAM_VENC_H264_VUI_TIMING_INFO; + info.enable = 1; + info.fixed_framerate = 1; + info.time_scale = NSEC_PER_SEC; + + ret = hfi_session_set_property(inst, ptype, &info); + if (ret) + return ret; + + ptype = HFI_PROPERTY_PARAM_VENC_H264_ENTROPY_CONTROL; + entropy.entropy_mode = venc_v4l2_to_hfi( + V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE, + ctr->h264_entropy_mode); + entropy.cabac_model = HFI_H264_CABAC_MODEL_0; + + ret = hfi_session_set_property(inst, ptype, &entropy); + if (ret) + return ret; + + ptype = HFI_PROPERTY_PARAM_VENC_H264_DEBLOCK_CONTROL; + deblock.mode = venc_v4l2_to_hfi( + V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE, + ctr->h264_loop_filter_mode); + deblock.slice_alpha_offset = ctr->h264_loop_filter_alpha; + deblock.slice_beta_offset = ctr->h264_loop_filter_beta; + + ret = hfi_session_set_property(inst, ptype, &deblock); + if (ret) + return ret; + + ptype = HFI_PROPERTY_PARAM_VENC_H264_TRANSFORM_8X8; + h264_transform.enable_type = 0; + if (ctr->profile.h264 == V4L2_MPEG_VIDEO_H264_PROFILE_HIGH || + ctr->profile.h264 == V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_HIGH) + h264_transform.enable_type = ctr->h264_8x8_transform; + + ret = hfi_session_set_property(inst, ptype, &h264_transform); + if (ret) + return ret; + } + + if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264 || + inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC) { + /* IDR periodicity, n: + * n = 0 - only the first I-frame is IDR frame + * n = 1 - all I-frames will be IDR frames + * n > 1 - every n-th I-frame will be IDR frame + */ + ptype = HFI_PROPERTY_CONFIG_VENC_IDR_PERIOD; + idrp.idr_period = 0; + ret = hfi_session_set_property(inst, ptype, &idrp); + if (ret) + return ret; + } + + if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC && + ctr->profile.hevc == V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10) { + struct hfi_hdr10_pq_sei hdr10; + unsigned int c; + + ptype = HFI_PROPERTY_PARAM_VENC_HDR10_PQ_SEI; + + for (c = 0; c < 3; c++) { + hdr10.mastering.display_primaries_x[c] = + ctr->mastering.display_primaries_x[c]; + hdr10.mastering.display_primaries_y[c] = + ctr->mastering.display_primaries_y[c]; + } + + hdr10.mastering.white_point_x = ctr->mastering.white_point_x; + hdr10.mastering.white_point_y = ctr->mastering.white_point_y; + hdr10.mastering.max_display_mastering_luminance = + ctr->mastering.max_display_mastering_luminance; + hdr10.mastering.min_display_mastering_luminance = + ctr->mastering.min_display_mastering_luminance; + + hdr10.cll.max_content_light = ctr->cll.max_content_light_level; + hdr10.cll.max_pic_average_light = + ctr->cll.max_pic_average_light_level; + + ret = hfi_session_set_property(inst, ptype, &hdr10); + if (ret) + return ret; + } + switch (inst->hfi_codec) { case HFI_VIDEO_CODEC_H264: profile = ctr->profile.h264;
Configure the generic controls before the codec specific ones. Some codec specific controls can override the generic ones. Signed-off-by: Fritz Koenig <frkoenig@chromium.org> --- v2: - requested testing methodology added to cover letter drivers/media/platform/qcom/venus/venc.c | 183 +++++++++++------------ 1 file changed, 91 insertions(+), 92 deletions(-)