Re: [RFC PATCH 1/3] media: uapi: Introduce new control for video encoder ROI
From: Dmitry Baryshkov
Date: Thu Jan 15 2026 - 14:48:00 EST
On Wed, Jan 14, 2026 at 04:20:52PM -0800, Deepa Guthyappa Madivalara wrote:
>
> On 1/14/2026 8:14 AM, Nicolas Dufresne wrote:
> > Hi,
> >
> > Le mardi 13 janvier 2026 à 12:33 -0800, Deepa Guthyappa Madivalara a écrit :
> > > Add compound control, V4L2_CID_MPEG_VIDEO_ENC_ROI, for
> > > video encoder Region of Interest to allow applications to specify
> > > different quality levels for specific regions in video frames. Define
> > > struct v4l2_ctrl_enc_roi_params to hold up to 10 rectangular ROI,
> > > regions and their corresponding delta_qp value (v4l2_roi_param)
> > > that adjust quantization relative to the frame's base value.
> > >
> > > This enables use cases like prioritizing quality for faces in video
> > > conferencing or important objects in surveillance footage while reducing
> > > bitrate for less critical areas.
> > >
> > > Signed-off-by: Deepa Guthyappa Madivalara <deepa.madivalara@xxxxxxxxxxxxxxxx>
> > > ---
> > > .../userspace-api/media/v4l/ext-ctrls-codec.rst | 7 +++++++
> > > include/media/v4l2-ctrls.h | 1 +
> > > include/uapi/linux/v4l2-controls.h | 1 +
> > > include/uapi/linux/videodev2.h | 17 +++++++++++++++++
> > > 4 files changed, 26 insertions(+)
> > >
> > > diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
> > > index c8890cb5e00ac05649e6c344c2a6b938b2ec1b24..0eecb46bb356c01411dfc313b92376593bcd86f6 100644
> > > --- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
> > > +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
> > > @@ -1668,6 +1668,13 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type -
> > > Codecs need to always use the specified range, rather then a HW custom range.
> > > Applicable to encoders
> > > +``V4L2_CID_MPEG_VIDEO_ENC_ROI (struct)``
> > > + Defines the control id to configure specific delta QP for one or more
> > > + rectangular regions of interest. The struct v4l2_ctrl_enc_roi_params
> > > + is defined to hold up to 10 v4l2_rect regions and their corresponding
> > > + delta_qp with a range of -31 to 30.
> > > + Applicable to encoders
> > Any justification for this range ? Also, I believe I've seen hardware support
> > both delta and absolute values. Since it meant to be generic, some research is
> > needed. If we delibaritly ignore absolute, perhaps the CID should be named
> > accordingly ? Something like V4L2_CID_MPEG_VIDEO_ENC__DELTAQP_ROI ?
>
> As per Android ROI API - MediaCodec API QP from the app is an offset QP,
> meaning userspace will received offset Qp and it converts it to deltaQp
> before passing onto the driver in Android HAL. I have used the same idea.
> Delta MbQP = frame QP + Offset Qp. This is clamped to -31 to 30 currently
> and set to driver as delta QP, hence I have it as -31 to 30.
Please reference Vulkan Video instead, if possible.
--
With best wishes
Dmitry