linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Maheshwar Ajja <majja@codeaurora.org>
To: mchehab@kernel.org, hverkuil-cisco@xs4all.nl,
	ezequiel@collabora.com, p.zabel@pengutronix.de,
	paul.kocialkowski@bootlin.com, jonas@kwiboo.se,
	posciak@chromium.org, boris.brezillon@collabora.com,
	ribalda@kernel.org, tglx@linutronix.de, sumitg@nvidia.com,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Maheshwar Ajja <majja@codeaurora.org>
Subject: [PATCH] media: v4l2-ctrls: add encoder skip frames control
Date: Mon, 18 May 2020 19:05:51 -0700	[thread overview]
Message-ID: <1589853951-27948-1-git-send-email-majja@codeaurora.org> (raw)

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


             reply	other threads:[~2020-05-19  2:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-19  2:05 Maheshwar Ajja [this message]
2020-05-19  6:53 ` [PATCH] media: v4l2-ctrls: add encoder skip frames control Hans Verkuil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1589853951-27948-1-git-send-email-majja@codeaurora.org \
    --to=majja@codeaurora.org \
    --cc=boris.brezillon@collabora.com \
    --cc=ezequiel@collabora.com \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=jonas@kwiboo.se \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=paul.kocialkowski@bootlin.com \
    --cc=posciak@chromium.org \
    --cc=ribalda@kernel.org \
    --cc=sumitg@nvidia.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).