Message ID | 20200616201446.15996-4-stanimir.varbanov@linaro.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Add two new v4l controls and implementation | expand |
On 16/06/2020 22:14, Stanimir Varbanov wrote: > This adds a new decoder control to instruct the decoders to > produce on its output intra frames only. Usually in this mode > decoders might lower the count of output decoder buffers and > hence reduce memory usage. > > Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> > --- > .../userspace-api/media/v4l/ext-ctrls-codec.rst | 9 +++++++++ > drivers/media/v4l2-core/v4l2-ctrls.c | 2 ++ > include/uapi/linux/v4l2-controls.h | 1 + > 3 files changed, 12 insertions(+) > > diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst > index b9d3f7ae6486..d7f34596f95b 100644 > --- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst > +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst > @@ -652,6 +652,15 @@ enum v4l2_mpeg_video_bitrate_mode - > otherwise the decoder expects a single frame in per buffer. > Applicable to the decoder, all codecs. > > +``V4L2_CID_MPEG_VIDEO_DECODE_INTRA_FRAMES_ONLY (boolean)`` > + If enabled the decoder should start decoding only intra frames. The should -> will ('should' indicates something optional, that does not apply here) > + decoder consume first input buffer for progressive stream (or first > + two buffers for interlace). Decoder might not allocate more output > + buffers than it is required to consume one input frame. These last two sentences ("The decoder ... one input frame.") make no sense. The 'Decoder' does not allocate buffers, it's userspace that decides that. And the number of input buffers it consumes is also irrelevant (i.e., it's enough to be able to generate an intra frame). I'd just drop them and so the new text becomes: "If enabled the decoder should start decoding only intra frames. Usually the decoder input buffers will contain only intra frames but it is not mandatory. This control could be used for thumbnails generation. Applicable to the decoder, all codecs." Usually the > + decoder input buffers will contain only intra frames but it is not > + mandatory. This control could be used for thumbnails generation. > + Applicable to the decoder, all codecs. > + > ``V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_ENABLE (boolean)`` > Enable writing sample aspect ratio in the Video Usability > Information. Applicable to the H264 encoder. > diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c > index bc00d02e411f..2b1fb8dcd360 100644 > --- a/drivers/media/v4l2-core/v4l2-ctrls.c > +++ b/drivers/media/v4l2-core/v4l2-ctrls.c > @@ -846,6 +846,7 @@ const char *v4l2_ctrl_get_name(u32 id) > case V4L2_CID_MPEG_VIDEO_MB_RC_ENABLE: return "H264 MB Level Rate Control"; > case V4L2_CID_MPEG_VIDEO_HEADER_MODE: return "Sequence Header Mode"; > case V4L2_CID_MPEG_VIDEO_MAX_REF_PIC: return "Max Number of Reference Pics"; > + case V4L2_CID_MPEG_VIDEO_DECODE_INTRA_FRAMES_ONLY: return "Decode intra frames only"; Use capitals: "Decode Intra Frames Only" > 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"; > @@ -1197,6 +1198,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, > case V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_ENABLE: > case V4L2_CID_MPEG_VIDEO_MPEG4_QPEL: > case V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER: > + case V4L2_CID_MPEG_VIDEO_DECODE_INTRA_FRAMES_ONLY: > 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 0f7e4388dcce..c64471e64aa7 100644 > --- a/include/uapi/linux/v4l2-controls.h > +++ b/include/uapi/linux/v4l2-controls.h > @@ -744,6 +744,7 @@ enum v4l2_cid_mpeg_video_hevc_size_of_length_field { > #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_CONSTANT_QUALITY (V4L2_CID_MPEG_BASE + 645) > +#define V4L2_CID_MPEG_VIDEO_DECODE_INTRA_FRAMES_ONLY (V4L2_CID_MPEG_BASE + 646) > > /* MPEG-class control IDs specific to the CX2341x driver as defined by V4L2 */ > #define V4L2_CID_MPEG_CX2341X_BASE (V4L2_CTRL_CLASS_MPEG | 0x1000) > Regards, Hans
diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst index b9d3f7ae6486..d7f34596f95b 100644 --- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst @@ -652,6 +652,15 @@ enum v4l2_mpeg_video_bitrate_mode - otherwise the decoder expects a single frame in per buffer. Applicable to the decoder, all codecs. +``V4L2_CID_MPEG_VIDEO_DECODE_INTRA_FRAMES_ONLY (boolean)`` + If enabled the decoder should start decoding only intra frames. The + decoder consume first input buffer for progressive stream (or first + two buffers for interlace). Decoder might not allocate more output + buffers than it is required to consume one input frame. Usually the + decoder input buffers will contain only intra frames but it is not + mandatory. This control could be used for thumbnails generation. + Applicable to the decoder, all codecs. + ``V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_ENABLE (boolean)`` Enable writing sample aspect ratio in the Video Usability Information. Applicable to the H264 encoder. diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index bc00d02e411f..2b1fb8dcd360 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -846,6 +846,7 @@ const char *v4l2_ctrl_get_name(u32 id) case V4L2_CID_MPEG_VIDEO_MB_RC_ENABLE: return "H264 MB Level Rate Control"; case V4L2_CID_MPEG_VIDEO_HEADER_MODE: return "Sequence Header Mode"; case V4L2_CID_MPEG_VIDEO_MAX_REF_PIC: return "Max Number of Reference Pics"; + case V4L2_CID_MPEG_VIDEO_DECODE_INTRA_FRAMES_ONLY: return "Decode intra frames only"; 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"; @@ -1197,6 +1198,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, case V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_ENABLE: case V4L2_CID_MPEG_VIDEO_MPEG4_QPEL: case V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER: + case V4L2_CID_MPEG_VIDEO_DECODE_INTRA_FRAMES_ONLY: 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 0f7e4388dcce..c64471e64aa7 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -744,6 +744,7 @@ enum v4l2_cid_mpeg_video_hevc_size_of_length_field { #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_CONSTANT_QUALITY (V4L2_CID_MPEG_BASE + 645) +#define V4L2_CID_MPEG_VIDEO_DECODE_INTRA_FRAMES_ONLY (V4L2_CID_MPEG_BASE + 646) /* MPEG-class control IDs specific to the CX2341x driver as defined by V4L2 */ #define V4L2_CID_MPEG_CX2341X_BASE (V4L2_CTRL_CLASS_MPEG | 0x1000)
This adds a new decoder control to instruct the decoders to produce on its output intra frames only. Usually in this mode decoders might lower the count of output decoder buffers and hence reduce memory usage. Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> --- .../userspace-api/media/v4l/ext-ctrls-codec.rst | 9 +++++++++ drivers/media/v4l2-core/v4l2-ctrls.c | 2 ++ include/uapi/linux/v4l2-controls.h | 1 + 3 files changed, 12 insertions(+)