public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: v4l2-ctrls: add encoder skip frames control
@ 2020-05-19  2:05 Maheshwar Ajja
  2020-05-19  6:53 ` Hans Verkuil
  0 siblings, 1 reply; 2+ messages in thread
From: Maheshwar Ajja @ 2020-05-19  2:05 UTC (permalink / raw)
  To: mchehab, hverkuil-cisco, ezequiel, p.zabel, paul.kocialkowski,
	jonas, posciak, boris.brezillon, ribalda, tglx, sumitg,
	linux-media, linux-kernel
  Cc: Maheshwar Ajja

If V4L2_CID_MPEG_VIDEO_ENC_SKIP_FRAMES control is enabled
encoder can drop frames, if required, to achieve target bitrate
instead of modifying the quantization parameter which lowers
the encoded frame quality.

Reference: 4.3.8.1 OMX_Video_ControlRateConstantSkipFrames
https://www.khronos.org/registry/OpenMAX-IL/specs/OpenMAX_IL_1_1_2_Specification.pdf

Signed-off-by: Maheshwar Ajja <majja@codeaurora.org>
---
 Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst | 7 +++++++
 drivers/media/v4l2-core/v4l2-ctrls.c                      | 2 ++
 include/uapi/linux/v4l2-controls.h                        | 1 +
 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 d0d506a..bc9265d 100644
--- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
+++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
@@ -1081,6 +1081,13 @@ enum v4l2_mpeg_video_h264_entropy_mode -
     Macroblock level rate control enable. Applicable to the MPEG4 and
     H264 encoders.
 
+``V4L2_CID_MPEG_VIDEO_ENC_SKIP_FRAMES (boolean)``
+    Encoder skip frames enable. This control is applicable only if
+    ``V4L2_CID_MPEG_VIDEO_BITRATE_MODE`` control is set. If this control
+    is enabled encoder can drop frames, if required, to achieve target
+    bitrate instead of modifying the quantization parameter which lowers
+    the encoded frame quality.
+
 ``V4L2_CID_MPEG_VIDEO_MPEG4_QPEL (boolean)``
     Quarter pixel motion estimation for MPEG4. Applicable to the MPEG4
     encoder.
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
index 1c617b4..d2cb766 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -914,6 +914,7 @@ const char *v4l2_ctrl_get_name(u32 id)
 	case V4L2_CID_MPEG_VIDEO_FWHT_PARAMS:			return "FWHT Stateless Parameters";
 	case V4L2_CID_FWHT_I_FRAME_QP:				return "FWHT I-Frame QP Value";
 	case V4L2_CID_FWHT_P_FRAME_QP:				return "FWHT P-Frame QP Value";
+	case V4L2_CID_MPEG_VIDEO_ENC_SKIP_FRAMES:		return "Encoder Skip Frames";
 
 	/* VPX controls */
 	case V4L2_CID_MPEG_VIDEO_VPX_NUM_PARTITIONS:		return "VPX Number of Partitions";
@@ -1180,6 +1181,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
 	case V4L2_CID_MPEG_VIDEO_DECODER_SLICE_INTERFACE:
 	case V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE:
 	case V4L2_CID_MPEG_VIDEO_MB_RC_ENABLE:
+	case V4L2_CID_MPEG_VIDEO_ENC_SKIP_FRAMES:
 	case V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM:
 	case V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_ENABLE:
 	case V4L2_CID_MPEG_VIDEO_MPEG4_QPEL:
diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
index 0ba1005..d3bc015 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -742,6 +742,7 @@ enum v4l2_cid_mpeg_video_hevc_size_of_length_field {
 #define V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L6_BR	(V4L2_CID_MPEG_BASE + 642)
 #define V4L2_CID_MPEG_VIDEO_REF_NUMBER_FOR_PFRAMES	(V4L2_CID_MPEG_BASE + 643)
 #define V4L2_CID_MPEG_VIDEO_PREPEND_SPSPPS_TO_IDR	(V4L2_CID_MPEG_BASE + 644)
+#define V4L2_CID_MPEG_VIDEO_ENC_SKIP_FRAMES		(V4L2_CID_MPEG_BASE + 645)
 
 /*  MPEG-class control IDs specific to the CX2341x driver as defined by V4L2 */
 #define V4L2_CID_MPEG_CX2341X_BASE				(V4L2_CTRL_CLASS_MPEG | 0x1000)
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-19  6:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-19  2:05 [PATCH] media: v4l2-ctrls: add encoder skip frames control Maheshwar Ajja
2020-05-19  6:53 ` Hans Verkuil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox