Re: [PATCH v1 1/4] media: v4l2-controls: Add control for background detection
From: Nicolas Dufresne
Date: Tue Apr 28 2026 - 16:01:15 EST
Le mardi 24 mars 2026 à 14:03 +0900, Jackson.lee a écrit :
> From: Jackson Lee <jackson.lee@xxxxxxxxxxxxxxx>
>
> Add a generic V4L2 boolean control V4L2_CID_MPEG_VIDEO_BACKGROUND_DETECTION
> that allows encoders to detect background regions in a frame and use fewer
> bits or skip mode to encode them, potentially reducing bitrate for streams
> with stationary scenes.
>
> Signed-off-by: Jackson Lee <jackson.lee@xxxxxxxxxxxxxxx>
> Signed-off-by: Nas Chung <nas.chung@xxxxxxxxxxxxxxx>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@xxxxxxxxxxxxx>
> ---
> Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst | 6 ++++++
> drivers/media/v4l2-core/v4l2-ctrls-defs.c | 2 ++
> include/uapi/linux/v4l2-controls.h | 2 ++
> 3 files changed, 10 insertions(+)
>
> diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
> b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
> index c8890cb5e00a..ab865a1a6ba9 100644
> --- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
> +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
> @@ -737,6 +737,12 @@ enum v4l2_mpeg_video_frame_skip_mode -
> Enable writing sample aspect ratio in the Video Usability
> Information. Applicable to the H264 encoder.
>
> +``V4L2_CID_MPEG_VIDEO_BACKGROUND_DETECTION (boolean)``
> + If enabled, the encoder detect a background region in frame and
> + use low bits or skip mode to encode the background region.
> + If a lot of scenes are stationary or background, It may help to
> + reduce the video bitrate. Applicable to the encoder.
> +
> .. _v4l2-mpeg-video-h264-vui-sar-idc:
>
> ``V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_IDC``
> diff --git a/drivers/media/v4l2-core/v4l2-ctrls-defs.c b/drivers/media/v4l2-
> core/v4l2-ctrls-defs.c
> index 551426c4cd01..e062f2088490 100644
> --- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c
> +++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c
> @@ -889,6 +889,7 @@ const char *v4l2_ctrl_get_name(u32 id)
> case V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY: return
> "Display Delay";
> case V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY_ENABLE: return
> "Display Delay Enable";
> case V4L2_CID_MPEG_VIDEO_AU_DELIMITER: return
> "Generate Access Unit Delimiters";
> + case V4L2_CID_MPEG_VIDEO_BACKGROUND_DETECTION: return
> "Background Detection";
> case V4L2_CID_MPEG_VIDEO_H263_I_FRAME_QP: return "H263
> I-Frame QP Value";
> case V4L2_CID_MPEG_VIDEO_H263_P_FRAME_QP: return "H263
> P-Frame QP Value";
> case V4L2_CID_MPEG_VIDEO_H263_B_FRAME_QP: return "H263
> B-Frame QP Value";
> @@ -1296,6 +1297,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum
> v4l2_ctrl_type *type,
> case V4L2_CID_MPEG_VIDEO_MPEG4_QPEL:
> case V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER:
> case V4L2_CID_MPEG_VIDEO_AU_DELIMITER:
> + case V4L2_CID_MPEG_VIDEO_BACKGROUND_DETECTION:
> case V4L2_CID_WIDE_DYNAMIC_RANGE:
> case V4L2_CID_IMAGE_STABILIZATION:
> case V4L2_CID_RDS_RECEPTION:
> diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-
> controls.h
> index 68dd0c4e47b2..affec0ab4781 100644
> --- a/include/uapi/linux/v4l2-controls.h
> +++ b/include/uapi/linux/v4l2-controls.h
> @@ -464,6 +464,8 @@ enum v4l2_mpeg_video_intra_refresh_period_type {
> V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD_TYPE_CYCLIC = 1,
> };
>
> +#define V4L2_CID_MPEG_VIDEO_BACKGROUND_DETECTION (V4L2_CID_CODEC_BASE
> + 238)
> +
> /* CIDs for the MPEG-2 Part 2 (H.262) codec */
> #define
> V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL (V4L2_CID_CODEC_BASE+270)
> enum v4l2_mpeg_video_mpeg2_level {
Attachment:
signature.asc
Description: This is a digitally signed message part