media: v4l2-ctrls: add encoder skip frames control
PATCH 1/1 media: v4l2-ctrls: add encoder skip frames control
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
--- 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(+)
Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +7 -0
@@ -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.
drivers/media/v4l2-core/v4l2-ctrls.c +2 -0
@@ -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 :
include/uapi/linux/v4l2-controls.h +1 -0
@@ -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)
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 20 lines · Maheshwar Ajja
If
V4L2_CID_MPEG_VIDEO_ENC_SKIP_FRAMEScontrol 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.pdfSigned-off-by Maheshwar Ajja <[email protected]>--- 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(+)Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +0
-0
Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst enum v4l2_mpeg_video_h264_entropy_mode - · line 1089
Quoted 9 lines
Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +6
-0@@ -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.
It's a bit unclear for which bitrate modes this control is valid: only for MODE_CBR, or also for the constant quality bitrate mode? Or both?
The phrase 'control is set' is meaningless for a menu control: it really is always 'set'. So that needs to be reworked so it is more explicit.
Also note that there is an Exynos MFC control that appears to do something
similar: V4L2_CID_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE.
To what extent does that overlap with the functionality proposed here?
It looks like this proposed control is basically the equivalent of setting V4L2_CID_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE to V4L2_MPEG_MFC51_FRAME_SKIP_MODE_LEVEL_LIMIT.
So perhaps this MFC control should be promoted to a standard MPEG control instead of inventing a new control?
Regards,
Hans
Quoted 37 lines
Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +1
-0+ ``V4L2_CID_MPEG_VIDEO_MPEG4_QPEL (boolean)`` Quarter pixel motion estimation for MPEG4. Applicable to the MPEG4 encoder.drivers/media/v4l2-core/v4l2-ctrls.c +2
-0@@ -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 :include/uapi/linux/v4l2-controls.h +1
-0@@ -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)