]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
media: v4l2-controls: Add control for background detection
authorJackson Lee <jackson.lee@chipsnmedia.com>
Tue, 24 Mar 2026 05:03:57 +0000 (14:03 +0900)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Mon, 4 May 2026 06:35:14 +0000 (08:35 +0200)
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@chipsnmedia.com>
Signed-off-by: Nas Chung <nas.chung@chipsnmedia.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
drivers/media/v4l2-core/v4l2-ctrls-defs.c
include/uapi/linux/v4l2-controls.h

index c8890cb5e00ac05649e6c344c2a6b938b2ec1b24..ab865a1a6ba929f1725ce2ab0fd3aeee4a69329a 100644 (file)
@@ -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``
index 551426c4cd01638ed2bc1dc085c2a9f4a72f1588..e062f2088490470c42d6c579ff7675be454a29b0 100644 (file)
@@ -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:
index 68dd0c4e47b2d7baea7ac20da78715e153d44f21..affec0ab4781507be761cb791ff737460acf9cb7 100644 (file)
@@ -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 {