Re: [PATCH v2 3/3] media: venus: Enable h.264 hierarchical coding

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 5, 2024 at 9:03 AM Fritz Koenig <frkoenig@xxxxxxxxxxxx> wrote:
>
> On Mon, Aug 5, 2024 at 3:23 AM Dikshita Agarwal
> <quic_dikshita@xxxxxxxxxxx> wrote:
> >
> >
> >
> > On 7/30/2024 12:49 AM, Fritz Koenig wrote:
> > > The series of V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING* controls
> > > provides the functionality for temporal layering. These controls allow
> > > for different framerates in a single stream.
> > >
> > > HFI supports hierarchical P encoding and the ability to specify the
> > > bitrate for the different layers.
> > >
> > > Connect the controls that V4L2 provides and HFI supports.
> > >
> > > Signed-off-by: Fritz Koenig <frkoenig@xxxxxxxxxxxx>
> > > ---
> > > v2:
> > > - update commit message
> > >
> > >  drivers/media/platform/qcom/venus/core.h      |  4 +
> > >  drivers/media/platform/qcom/venus/venc.c      | 24 ++++++
> > >  .../media/platform/qcom/venus/venc_ctrls.c    | 84 +++++++++++++++++++
> > >  3 files changed, 112 insertions(+)
> > >
> > > diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h
> > > index 55202b89e1b9..fc9552311a71 100644
> > > --- a/drivers/media/platform/qcom/venus/core.h
> > > +++ b/drivers/media/platform/qcom/venus/core.h
> > > @@ -274,6 +274,10 @@ struct venc_controls {
> > >       s32 h264_loop_filter_beta;
> > >       u32 h264_8x8_transform;
> > >
> > > +     u32 h264_hier_enabled;
> > > +     u32 h264_hier_p_layers;
> > > +     u32 h264_hier_p_bitrate[6];
> > > +
> > >       u32 hevc_i_qp;
> > >       u32 hevc_p_qp;
> > >       u32 hevc_b_qp;
> > > diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c
> > > index ae24de125c56..301b0015b356 100644
> > > --- a/drivers/media/platform/qcom/venus/venc.c
> > > +++ b/drivers/media/platform/qcom/venus/venc.c
> > > @@ -875,6 +875,30 @@ static int venc_set_properties(struct venus_inst *inst)
> > >               ret = hfi_session_set_property(inst, ptype, &h264_transform);
> > >               if (ret)
> > >                       return ret;
> > > +
> > > +             if (ctr->h264_hier_enabled) {
> > > +                     unsigned int i;
> > > +
> > > +                     ptype = HFI_PROPERTY_PARAM_VENC_HIER_P_MAX_NUM_ENH_LAYER;
> > > +                     ret = hfi_session_set_property(inst, ptype, &ctr->h264_hier_p_layers);
> > > +                     if (ret)
> > > +                             return ret;
> > > +
> > > +                     ptype = HFI_PROPERTY_CONFIG_VENC_HIER_P_ENH_LAYER;
> > > +                     ret = hfi_session_set_property(inst, ptype, &ctr->h264_hier_p_layers);
> > > +                     if (ret)
> > > +                             return ret;
> > > +
> > > +                     for (i = 0; i < ctr->h264_hier_p_layers; ++i) {
> > > +                             ptype = HFI_PROPERTY_CONFIG_VENC_TARGET_BITRATE;
> > > +                             brate.bitrate = ctr->h264_hier_p_bitrate[i];
> > > +                             brate.layer_id = i;
> > > +
> > > +                             ret = hfi_session_set_property(inst, ptype, &brate);
> > > +                             if (ret)
> > > +                                     return ret;
> > > +                     }
> > > +             }
> > >       }
> > >
> > >       if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264 ||
> > > diff --git a/drivers/media/platform/qcom/venus/venc_ctrls.c b/drivers/media/platform/qcom/venus/venc_ctrls.c
> > > index 6304cc97d37f..4cad8058339a 100644
> > > --- a/drivers/media/platform/qcom/venus/venc_ctrls.c
> > > +++ b/drivers/media/platform/qcom/venus/venc_ctrls.c
> > > @@ -345,6 +345,52 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl)
> > >
> > >               ctr->h264_8x8_transform = ctrl->val;
> > >               break;
> > > +     case V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_TYPE:
> > > +             if (ctrl->val != V4L2_MPEG_VIDEO_H264_HIERARCHICAL_CODING_P)
> > > +                     return -EINVAL;
> > > +             break;
> > > +     case V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING:
> > > +             ctr->h264_hier_enabled = ctrl->val;
> > > +             break;
> > > +     case V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_LAYER:
> > > +             ctr->h264_hier_p_layers = ctrl->val;
> > > +             break;
> > > +     case V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L0_BR:
> > > +             ctr->h264_hier_p_bitrate[0] = ctrl->val;
> > > +             ret = dynamic_bitrate_update(inst, ctr->h264_hier_p_bitrate[0], 0);
> > > +             if (ret)
> > > +                     return ret;
> > > +             break;
> > > +     case V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L1_BR:
> > > +             ctr->h264_hier_p_bitrate[1] = ctrl->val;
> > > +             ret = dynamic_bitrate_update(inst, ctr->h264_hier_p_bitrate[1], 1);
> > > +             if (ret)
> > > +                     return ret;
> > > +             break;
> > > +     case V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L2_BR:
> > > +             ctr->h264_hier_p_bitrate[2] = ctrl->val;
> > > +             ret = dynamic_bitrate_update(inst, ctr->h264_hier_p_bitrate[2], 2);
> > > +             if (ret)
> > > +                     return ret;
> > > +             break;
> > > +     case V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L3_BR:
> > > +             ctr->h264_hier_p_bitrate[3] = ctrl->val;
> > > +             ret = dynamic_bitrate_update(inst, ctr->h264_hier_p_bitrate[3], 3);
> > > +             if (ret)
> > > +                     return ret;
> > > +             break;
> > > +     case V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L4_BR:
> > > +             ctr->h264_hier_p_bitrate[4] = ctrl->val;
> > > +             ret = dynamic_bitrate_update(inst, ctr->h264_hier_p_bitrate[4], 4);
> > > +             if (ret)
> > > +                     return ret;
> > > +             break;
> > > +     case V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L5_BR:
> > > +             ctr->h264_hier_p_bitrate[5] = ctrl->val;
> > > +             ret = dynamic_bitrate_update(inst, ctr->h264_hier_p_bitrate[5], 5);
> > > +             if (ret)
> > > +                     return ret;
> > > +             break;
> > >       default:
> > >               return -EINVAL;
> > >       }
> > > @@ -627,6 +673,44 @@ int venc_ctrl_init(struct venus_inst *inst)
> > >                         V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD, 0,
> > >                         ((4096 * 2304) >> 8), 1, 0);
> > >
> > > +     if (IS_V4(inst->core) || IS_V6(inst->core)) {
> > Hi Fritz,
> > is this change tested on any V6 device?
> >
> No, it has only been tested on V4 (SC7180)
>
This series has now also been tested on SC7280 as well
> -Fritz
> > Thanks,
> > Dikshita
> > > +             v4l2_ctrl_new_std_menu(&inst->ctrl_handler, &venc_ctrl_ops,
> > > +                                    V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_TYPE,
> > > +                                    V4L2_MPEG_VIDEO_H264_HIERARCHICAL_CODING_P,
> > > +                                    1, V4L2_MPEG_VIDEO_H264_HIERARCHICAL_CODING_P);
> > > +
> > > +             v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
> > > +                               V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING, 0, 1, 1, 0);
> > > +
> > > +             v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
> > > +                               V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_LAYER, 0,
> > > +                               6, 1, 0);
> > > +
> > > +             v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
> > > +                               V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L0_BR, BITRATE_MIN, BITRATE_MAX,
> > > +                               BITRATE_STEP, BITRATE_DEFAULT);
> > > +
> > > +             v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
> > > +                               V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L1_BR, BITRATE_MIN, BITRATE_MAX,
> > > +                               BITRATE_STEP, BITRATE_DEFAULT);
> > > +
> > > +             v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
> > > +                               V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L2_BR, BITRATE_MIN, BITRATE_MAX,
> > > +                               BITRATE_STEP, BITRATE_DEFAULT);
> > > +
> > > +             v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
> > > +                               V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L3_BR, BITRATE_MIN, BITRATE_MAX,
> > > +                               BITRATE_STEP, BITRATE_DEFAULT);
> > > +
> > > +             v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
> > > +                               V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L4_BR, BITRATE_MIN, BITRATE_MAX,
> > > +                               BITRATE_STEP, BITRATE_DEFAULT);
> > > +
> > > +             v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
> > > +                               V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L5_BR, BITRATE_MIN, BITRATE_MAX,
> > > +                               BITRATE_STEP, BITRATE_DEFAULT);
> > > +     }
> > > +
> > >       ret = inst->ctrl_handler.error;
> > >       if (ret)
> > >               goto err;





[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux