Stateless H.264 de-staging
Subsystems (5)
v2 cover Stateless H.264 de-staging
Now that H.264 stateless controls are solid, we can get it out of staging.
Following some guidelines from Hans, this series creates a new stateless control class for the stable codec controls to land.
While here, I'm including a patch from Jonas adding profiles and levels to Rkvdec, and also made a similar fix for Cedrus.
This series was tested on a i.MX8MQ EVK board, using GStreamer:
https://gitlab.freedesktop.org/ezequielgarcia/gst-plugins-bad/-/commits/h264_stable_uapi
In case someone wants to give this a test.
Note that v4l2-compliance isn't passing, as the Hantro driver doesn't set legal default values for the H264 SPS, PPS, etc controls.
That's something we should fix, although it's since it's just meant to please v4l2-compliance, we could also argue that these controls shouldn't be expected to have any default value.
Thanks,
Ezequiel
v2:
* Split destage changes in several patches so it's easier to review.
* Added missing changes to drivers/media/v4l2-core/v4l2-ctrls.c.
* Renamed V4L2_CID_CODEC_CX2341X_ and V4L2_CID_MPEG_MFC51_
* Moved the compatibility macros for MPEG to the end of the header.
Ezequiel Garcia (8):
media: cedrus: h264: Support profile and level controls
media: Rename stateful codec control macros
media: Clean stateless control includes
media: controls: Add the stateless codec control class
media: uapi: Move parsed H264 pixel format out of staging
media: uapi: Move the H264 stateless control types out of staging
media: uapi: move H264 stateless controls out of staging
media: docs: Move the H264 stateless codec uAPI
Jonas Karlman (1):
media: rkvdec: h264: Support profile and level controls
.../userspace-api/media/v4l/common.rst | 1 + .../userspace-api/media/v4l/dev-mem2mem.rst | 2 +- .../media/v4l/ext-ctrls-codec-stateless.rst | 674 +++++++++++++++ .../media/v4l/ext-ctrls-codec.rst | 696 +--------------- .../media/v4l/extended-controls.rst | 8 +- .../media/v4l/pixfmt-compressed.rst | 14 +- .../media/v4l/vidioc-g-ext-ctrls.rst | 6 +- drivers/media/common/cx2341x.c | 4 +- drivers/media/platform/s5p-mfc/s5p_mfc_dec.c | 2 +- drivers/media/platform/s5p-mfc/s5p_mfc_enc.c | 2 +- drivers/media/v4l2-core/v4l2-ctrls.c | 45 +- drivers/staging/media/hantro/hantro_drv.c | 26 +- drivers/staging/media/hantro/hantro_h264.c | 8 +- drivers/staging/media/hantro/hantro_hw.h | 4 +- drivers/staging/media/rkvdec/rkvdec-h264.c | 8 +- drivers/staging/media/rkvdec/rkvdec.c | 39 +- drivers/staging/media/sunxi/cedrus/cedrus.c | 45 +- .../staging/media/sunxi/cedrus/cedrus_dec.c | 12 +- include/media/fwht-ctrls.h | 2 +- include/media/h264-ctrls.h | 27 +- include/media/hevc-ctrls.h | 10 +- include/media/mpeg2-ctrls.h | 4 +- include/media/v4l2-ctrls.h | 1 - include/media/v4l2-h264.h | 2 +- include/media/vp8-ctrls.h | 2 +- include/uapi/linux/v4l2-controls.h | 788 +++++++++++++----- include/uapi/linux/videodev2.h | 8 + 27 files changed, 1422 insertions(+), 1018 deletions(-) create mode 100644 Documentation/userspace-api/media/v4l/ext-ctrls-codec-stateless.rst
Signature · 1 line
2.27.0
PATCH v2 1/9 media: rkvdec: h264: Support profile and level controls
From: Jonas Karlman <[email protected]>
The Rockchip Video Decoder used in RK3399 supports H.264 profiles from Baseline to High 4:2:2 up to Level 5.1, except for the Extended profile.
Expose the V4L2_CID_MPEG_VIDEO_H264_PROFILE and the V4L2_CID_MPEG_VIDEO_H264_LEVEL control, so that userspace can query the driver for the list of supported profiles and level.
For now, we don't expose 4:2:2 since the driver doesn't implement the required support.
--- drivers/staging/media/rkvdec/rkvdec.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/staging/media/rkvdec/rkvdec.c +13 -0
@@ -82,6 +82,19 @@ static const struct rkvdec_ctrl_desc rkvdec_h264_ctrl_descs[] = { .cfg.def = V4L2_MPEG_VIDEO_H264_START_CODE_ANNEX_B, .cfg.max = V4L2_MPEG_VIDEO_H264_START_CODE_ANNEX_B, }, + { + .cfg.id = V4L2_CID_MPEG_VIDEO_H264_PROFILE, + .cfg.min = V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE, + .cfg.max = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH, + .cfg.menu_skip_mask = + BIT(V4L2_MPEG_VIDEO_H264_PROFILE_EXTENDED), + .cfg.def = V4L2_MPEG_VIDEO_H264_PROFILE_MAIN, + }, + { + .cfg.id = V4L2_CID_MPEG_VIDEO_H264_LEVEL, + .cfg.min = V4L2_MPEG_VIDEO_H264_LEVEL_1_0, + .cfg.max = V4L2_MPEG_VIDEO_H264_LEVEL_5_1, + }, }; static const struct rkvdec_ctrls rkvdec_h264_ctrls = {
Signature · 1 line
2.27.0
PATCH v2 2/9 media: cedrus: h264: Support profile and level controls
In reply to Ezequiel GarciaCedrus supports H.264 profiles from Baseline to High, up to Level 5.1, except for the Extended profile
Expose the V4L2_CID_MPEG_VIDEO_H264_PROFILE and V4L2_CID_MPEG_VIDEO_H264_LEVEL so that userspace can query the driver for the supported profiles and levels.
--- drivers/staging/media/sunxi/cedrus/cedrus.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
drivers/staging/media/sunxi/cedrus/cedrus.c +21 -0
@@ -103,6 +103,27 @@ static const struct cedrus_control cedrus_controls[] = { .codec = CEDRUS_CODEC_H264, .required = false, }, + { + .cfg = { + .id = V4L2_CID_MPEG_VIDEO_H264_PROFILE, + .min = V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE, + .def = V4L2_MPEG_VIDEO_H264_PROFILE_MAIN, + .max = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH, + .menu_skip_mask = + BIT(V4L2_MPEG_VIDEO_H264_PROFILE_EXTENDED), + }, + .codec = CEDRUS_CODEC_H264, + .required = false, + }, + { + .cfg = { + .id = V4L2_CID_MPEG_VIDEO_H264_LEVEL, + .min = V4L2_MPEG_VIDEO_H264_LEVEL_1_0, + .max = V4L2_MPEG_VIDEO_H264_LEVEL_5_1, + }, + .codec = CEDRUS_CODEC_H264, + .required = false, + }, { .cfg = { .id = V4L2_CID_MPEG_VIDEO_HEVC_SPS,
Signature · 1 line
2.27.0
Re: [PATCH v2 2/9] media: cedrus: h264: Support profile and level controls
Hi Ezequiel,
sorry for late review.
First of all, this patch doesn't break anything. However, see comment below.
Dne petek, 13. november 2020 ob 22:51:14 CET je Ezequiel Garcia napisal(a):
drivers/staging/
Quoted 13 lines
Cedrus supports H.264 profiles from Baseline to High, up to Level 5.1, except for the Extended profile
Expose the
V4L2_CID_MPEG_VIDEO_H264_PROFILEandV4L2_CID_MPEG_VIDEO_H264_LEVELso that userspace can query the driver for the supported profiles and levels.Signed-off-by Ezequiel Garcia <[email protected]>--- drivers/staging/media/sunxi/cedrus/cedrus.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)drivers/staging/ renamed from drivers/staging/media/sunxi/cedrus/cedrus.c +0
-0
media/sunxi/cedrus/cedrus.c
drivers/staging/media/sunxi/cedrus/cedrus.c static const struct cedrus_control cedrus_controls[] =
Quoted 4 lines
index
9a102b7c1bb9..8b0e97752d27100644drivers/staging/media/sunxi/cedrus/cedrus.c +0
-0@@ -103,6 +103,27 @@ static const struct cedrus_control cedrus_controls[] =
{
drivers/staging/media/sunxi/cedrus/cedrus.c static const struct cedrus_control cedrus_controls[] = {
Quoted 6 lines
drivers/staging/media/sunxi/cedrus/cedrus.c +3
-0.codec = CEDRUS_CODEC_H264, .required = false, }, + { + .cfg = { + .id =
V4L2_CID_MPEG_VIDEO_H264_PROFILE,
drivers/staging/media/sunxi/cedrus/cedrus.c static const struct cedrus_control cedrus_controls[] = · line 109
Quoted 1 line
drivers/staging/media/sunxi/cedrus/cedrus.c +1
-0+ .min =
V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE,
drivers/staging/media/sunxi/cedrus/cedrus.c static const struct cedrus_control cedrus_controls[] = · line 110
Quoted 1 line
drivers/staging/media/sunxi/cedrus/cedrus.c +1
-0+ .def =
V4L2_MPEG_VIDEO_H264_PROFILE_MAIN,
drivers/staging/media/sunxi/cedrus/cedrus.c static const struct cedrus_control cedrus_controls[] = · line 111
Quoted 1 line
drivers/staging/media/sunxi/cedrus/cedrus.c +1
-0+ .max =
V4L2_MPEG_VIDEO_H264_PROFILE_HIGH,
drivers/staging/media/sunxi/cedrus/cedrus.c static const struct cedrus_control cedrus_controls[] = · line 113
Quoted 2 lines
drivers/staging/media/sunxi/cedrus/cedrus.c +2
-0+ .menu_skip_mask = +
BIT(V4L2_MPEG_VIDEO_H264_PROFILE_EXTENDED),
drivers/staging/media/sunxi/cedrus/cedrus.c static const struct cedrus_control cedrus_controls[] = { · line 122
Quoted 9 lines
drivers/staging/media/sunxi/cedrus/cedrus.c +9
-0+ }, + .codec = CEDRUS_CODEC_H264, + .required = false, + }, + { + .cfg = { + .id = V4L2_CID_MPEG_VIDEO_H264_LEVEL, + .min = V4L2_MPEG_VIDEO_H264_LEVEL_1_0, + .max = V4L2_MPEG_VIDEO_H264_LEVEL_5_1,
I went through several datasheets and only newer ones (H6, H616) state max. supported level, which is 4.2. Please change it in next revision.
After that, you can add
Best regards,
Jernej
Quoted 11 lines
drivers/staging/media/sunxi/cedrus/cedrus.c +4
-0+ }, + .codec = CEDRUS_CODEC_H264, + .required = false, + }, { .cfg = { .id = V4L2_CID_MPEG_VIDEO_HEVC_SPS,Signature · 1 line
2.27.0
Re: [PATCH v2 2/9] media: cedrus: h264: Support profile and level controls
Quoted 55 lines · Jernej Škrabec
Hi Ezequiel,
sorry for late review.
First of all, this patch doesn't break anything. However, see comment below.
Dne petek, 13. november 2020 ob 22:51:14 CET je Ezequiel Garcia napisal(a):
drivers/staging/
Quoted 13 lines
Cedrus supports H.264 profiles from Baseline to High, up to Level 5.1, except for the Extended profile
Expose the
V4L2_CID_MPEG_VIDEO_H264_PROFILEandV4L2_CID_MPEG_VIDEO_H264_LEVELso that userspace can query the driver for the supported profiles and levels.Signed-off-by Ezequiel Garcia <[email protected]>--- drivers/staging/media/sunxi/cedrus/cedrus.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)drivers/staging/ renamed from drivers/staging/media/sunxi/cedrus/cedrus.c +0
-0
media/sunxi/cedrus/cedrus.cdrivers/staging/media/sunxi/cedrus/cedrus.c static const struct cedrus_control cedrus_controls[] =
Quoted 4 lines
index
9a102b7c1bb9..8b0e97752d27100644drivers/staging/media/sunxi/cedrus/cedrus.c +0
-0@@ -103,6 +103,27 @@ static const struct cedrus_control cedrus_controls[] ={
drivers/staging/media/sunxi/cedrus/cedrus.c static const struct cedrus_control cedrus_controls[] = {
Quoted 6 lines
drivers/staging/media/sunxi/cedrus/cedrus.c +3
-0.codec = CEDRUS_CODEC_H264, .required = false, }, + { + .cfg = { + .id =
V4L2_CID_MPEG_VIDEO_H264_PROFILE,drivers/staging/media/sunxi/cedrus/cedrus.c static const struct cedrus_control cedrus_controls[] = · line 109
Quoted 1 line
drivers/staging/media/sunxi/cedrus/cedrus.c +1
-0+ .min =
V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE,drivers/staging/media/sunxi/cedrus/cedrus.c static const struct cedrus_control cedrus_controls[] = · line 110
Quoted 1 line
drivers/staging/media/sunxi/cedrus/cedrus.c +1
-0+ .def =
V4L2_MPEG_VIDEO_H264_PROFILE_MAIN,drivers/staging/media/sunxi/cedrus/cedrus.c static const struct cedrus_control cedrus_controls[] = · line 111
Quoted 1 line
drivers/staging/media/sunxi/cedrus/cedrus.c +1
-0+ .max =
V4L2_MPEG_VIDEO_H264_PROFILE_HIGH,drivers/staging/media/sunxi/cedrus/cedrus.c static const struct cedrus_control cedrus_controls[] = · line 113
Quoted 2 lines
drivers/staging/media/sunxi/cedrus/cedrus.c +2
-0+ .menu_skip_mask = +
BIT(V4L2_MPEG_VIDEO_H264_PROFILE_EXTENDED),drivers/staging/media/sunxi/cedrus/cedrus.c static const struct cedrus_control cedrus_controls[] = { · line 122
Quoted 9 lines
drivers/staging/media/sunxi/cedrus/cedrus.c +9
-0+ }, + .codec = CEDRUS_CODEC_H264, + .required = false, + }, + { + .cfg = { + .id = V4L2_CID_MPEG_VIDEO_H264_LEVEL, + .min = V4L2_MPEG_VIDEO_H264_LEVEL_1_0, + .max = V4L2_MPEG_VIDEO_H264_LEVEL_5_1,I went through several datasheets and only newer ones (H6, H616) state max. supported level, which is 4.2. Please change it in next revision.
Quoted 3 lines
After that, you can add
Reviewed-by Jernej Skrabec <[email protected]>
Note that I used level 5.1 based on a commit from you:
"""
media: cedrus: h264: Fix 4K decoding on H6
Due to unknown reason, H6 needs larger intraprediction buffer for 4K videos than other SoCs. This was discovered by playing 4096x2304 video, which is maximum what H6 VPU is supposed to support.
"""
I guessed this meant it supported level 5 or higher. (Now that I think about it, I meant at least H6, does).
According to https://en.wikipedia.org/wiki/Advanced_Video_Coding#Levels,
level 4.2 is up to 2,048×1,[email protected].
Frankly, I'm open to put whatever value makes you happy.
Thanks,
Ezequiel
Quoted 16 lines
Best regards,
JernejQuoted 11 lines
drivers/staging/media/sunxi/cedrus/cedrus.c +4
-0+ }, + .codec = CEDRUS_CODEC_H264, + .required = false, + }, { .cfg = { .id = V4L2_CID_MPEG_VIDEO_HEVC_SPS,Signature · 1 line
2.27.0
Re: Re: [PATCH v2 2/9] media: cedrus: h264: Support profile and level controls
Dne torek, 17. november 2020 ob 20:40:09 CET je Ezequiel Garcia napisal(a):
Quoted 6 lines · Jernej Škrabec
Quoted 5 lines
Hi Ezequiel,
sorry for late review.
First of all, this patch doesn't break anything. However, see comment
below.
Quoted 2 lines
Quoted 2 lines
Dne petek, 13. november 2020 ob 22:51:14 CET je Ezequiel Garcia
napisal(a):
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Cedrus supports H.264 profiles from Baseline to High, up to Level 5.1, except for the Extended profile
Expose the
V4L2_CID_MPEG_VIDEO_H264_PROFILEandV4L2_CID_MPEG_VIDEO_H264_LEVELso that userspace can query the driver for the supported profiles and levels.
Quoted 6 lines
Quoted 6 lines
drivers/
Quoted 6 lines
Signed-off-by Ezequiel Garcia <[email protected]>--- drivers/staging/media/sunxi/cedrus/cedrus.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)drivers/ renamed from drivers/staging/media/sunxi/cedrus/cedrus.c +0
-0
staging/
Quoted 5 lines
Quoted 5 lines
media/sunxi/cedrus/cedrus.cdrivers/staging/media/sunxi/cedrus/cedrus.c static const struct cedrus_control
Quoted 4 lines
index
9a102b7c1bb9..8b0e97752d27100644drivers/staging/media/sunxi/cedrus/cedrus.c +0
-0@@ -103,6 +103,27 @@ static const struct cedrus_control
cedrus_controls[] =
Quoted 17 lines
Quoted 17 lines
{
drivers/staging/media/sunxi/cedrus/cedrus.c static const struct cedrus_control cedrus_controls[] = {
Quoted 6 lines
drivers/staging/media/sunxi/cedrus/cedrus.c +3
-0.codec = CEDRUS_CODEC_H264, .required = false, }, + { + .cfg = { + .id =
V4L2_CID_MPEG_VIDEO_H264_PROFILE,drivers/staging/media/sunxi/cedrus/cedrus.c static const struct cedrus_control · line 109
Quoted 1 line
drivers/staging/media/sunxi/cedrus/cedrus.c +1
-0+ .min =
V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE,drivers/staging/media/sunxi/cedrus/cedrus.c static const struct cedrus_control · line 110
Quoted 1 line
drivers/staging/media/sunxi/cedrus/cedrus.c +1
-0+ .def =
V4L2_MPEG_VIDEO_H264_PROFILE_MAIN,drivers/staging/media/sunxi/cedrus/cedrus.c static const struct cedrus_control · line 111
Quoted 1 line
drivers/staging/media/sunxi/cedrus/cedrus.c +1
-0+ .max =
V4L2_MPEG_VIDEO_H264_PROFILE_HIGH,drivers/staging/media/sunxi/cedrus/cedrus.c static const struct cedrus_control · line 113
Quoted 2 lines
drivers/staging/media/sunxi/cedrus/cedrus.c +2
-0+ .menu_skip_mask = +
BIT(V4L2_MPEG_VIDEO_H264_PROFILE_EXTENDED),
Quoted 11 lines
Quoted 11 lines
drivers/staging/media/sunxi/cedrus/cedrus.c static const struct cedrus_control cedrus_controls[] = { · line 122
Quoted 9 lines
drivers/staging/media/sunxi/cedrus/cedrus.c +9
-0+ }, + .codec = CEDRUS_CODEC_H264, + .required = false, + }, + { + .cfg = { + .id = V4L2_CID_MPEG_VIDEO_H264_LEVEL, + .min = V4L2_MPEG_VIDEO_H264_LEVEL_1_0, + .max = V4L2_MPEG_VIDEO_H264_LEVEL_5_1,I went through several datasheets and only newer ones (H6, H616) state
max.
Quoted 15 lines
Quoted 5 lines
supported level, which is 4.2. Please change it in next revision.
After that, you can add
Reviewed-by Jernej Skrabec <[email protected]>Note that I used level 5.1 based on a commit from you:
"""
media: cedrus: h264: Fix 4K decoding on H6Due to unknown reason, H6 needs larger intraprediction buffer for 4K videos than other SoCs. This was discovered by playing 4096x2304 video, which is maximum what H6 VPU is supposed to support.
"""
Quoted 5 lines
I guessed this meant it supported level 5 or higher. (Now that I think about it, I meant at least H6, does).
According to https://en.wikipedia.org/wiki/Advanced_Video_Coding#Levels,
level 4.2 is up to 2,048×1,[email protected].
Strange, then I guess datasheet is wrong (wouldn't be first time). Unfortunatelly there is no documentation for Cedrus capabilities, so everything is either educated guess or tested on HW. Documentation for older than H6 SoCs always mention only 1080p @ 60fps limit, even though several of them are capable of decoding 4K H264 videos (I'm not sure about max. fps though).
Quoted 2 lines
Frankly, I'm open to put whatever value makes you happy.
To be honest, I'm not sure what is correct value here. It may depend on Cedrus core variant.
Best regards,
Jernej
Quoted 23 lines
Thanks,
EzequielQuoted 16 lines
Best regards,
JernejQuoted 11 lines
drivers/staging/media/sunxi/cedrus/cedrus.c +4
-0+ }, + .codec = CEDRUS_CODEC_H264, + .required = false, + }, { .cfg = { .id = V4L2_CID_MPEG_VIDEO_HEVC_SPS,Signature · 1 line
2.27.0
Re: Re: [PATCH v2 2/9] media: cedrus: h264: Support profile and level controls
Quoted 87 lines · Jernej Škrabec
Dne torek, 17. november 2020 ob 20:40:09 CET je Ezequiel Garcia napisal(a):
Quoted 6 lines · Jernej Škrabec
Quoted 5 lines
Hi Ezequiel,
sorry for late review.
First of all, this patch doesn't break anything. However, see comment
below.
Quoted 1 line
Quoted 1 line
Dne petek, 13. november 2020 ob 22:51:14 CET je Ezequiel Garcia
napisal(a):
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Cedrus supports H.264 profiles from Baseline to High, up to Level 5.1, except for the Extended profile
Expose the
V4L2_CID_MPEG_VIDEO_H264_PROFILEandV4L2_CID_MPEG_VIDEO_H264_LEVELso that userspace can query the driver for the supported profiles and levels.Quoted 6 lines
Quoted 6 lines
drivers/
Quoted 6 lines
Signed-off-by Ezequiel Garcia <[email protected]>--- drivers/staging/media/sunxi/cedrus/cedrus.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)drivers/ renamed from drivers/staging/media/sunxi/cedrus/cedrus.c +0
-0staging/
Quoted 5 lines
Quoted 5 lines
media/sunxi/cedrus/cedrus.cdrivers/staging/media/sunxi/cedrus/cedrus.c static const struct cedrus_control
Quoted 4 lines
index
9a102b7c1bb9..8b0e97752d27100644drivers/staging/media/sunxi/cedrus/cedrus.c +0
-0@@ -103,6 +103,27 @@ static const struct cedrus_controlcedrus_controls[] =
Quoted 17 lines
Quoted 17 lines
{
drivers/staging/media/sunxi/cedrus/cedrus.c static const struct cedrus_control cedrus_controls[] = {
Quoted 6 lines
drivers/staging/media/sunxi/cedrus/cedrus.c +3
-0.codec = CEDRUS_CODEC_H264, .required = false, }, + { + .cfg = { + .id =
V4L2_CID_MPEG_VIDEO_H264_PROFILE,drivers/staging/media/sunxi/cedrus/cedrus.c static const struct cedrus_control · line 109
Quoted 1 line
drivers/staging/media/sunxi/cedrus/cedrus.c +1
-0+ .min =
V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE,drivers/staging/media/sunxi/cedrus/cedrus.c static const struct cedrus_control · line 110
Quoted 1 line
drivers/staging/media/sunxi/cedrus/cedrus.c +1
-0+ .def =
V4L2_MPEG_VIDEO_H264_PROFILE_MAIN,drivers/staging/media/sunxi/cedrus/cedrus.c static const struct cedrus_control · line 111
Quoted 1 line
drivers/staging/media/sunxi/cedrus/cedrus.c +1
-0+ .max =
V4L2_MPEG_VIDEO_H264_PROFILE_HIGH,drivers/staging/media/sunxi/cedrus/cedrus.c static const struct cedrus_control · line 113
Quoted 2 lines
drivers/staging/media/sunxi/cedrus/cedrus.c +2
-0+ .menu_skip_mask = +
BIT(V4L2_MPEG_VIDEO_H264_PROFILE_EXTENDED),Quoted 11 lines
Quoted 11 lines
drivers/staging/media/sunxi/cedrus/cedrus.c static const struct cedrus_control cedrus_controls[] = { · line 122
Quoted 9 lines
drivers/staging/media/sunxi/cedrus/cedrus.c +9
-0+ }, + .codec = CEDRUS_CODEC_H264, + .required = false, + }, + { + .cfg = { + .id = V4L2_CID_MPEG_VIDEO_H264_LEVEL, + .min = V4L2_MPEG_VIDEO_H264_LEVEL_1_0, + .max = V4L2_MPEG_VIDEO_H264_LEVEL_5_1,I went through several datasheets and only newer ones (H6, H616) state
max.
Quoted 15 lines
Quoted 5 lines
supported level, which is 4.2. Please change it in next revision.
After that, you can add
Reviewed-by Jernej Skrabec <[email protected]>Note that I used level 5.1 based on a commit from you:
"""
media: cedrus: h264: Fix 4K decoding on H6Due to unknown reason, H6 needs larger intraprediction buffer for 4K videos than other SoCs. This was discovered by playing 4096x2304 video, which is maximum what H6 VPU is supposed to support.
"""Quoted 5 lines
I guessed this meant it supported level 5 or higher. (Now that I think about it, I meant at least H6, does).
According to https://en.wikipedia.org/wiki/Advanced_Video_Coding#Levels,
level 4.2 is up to 2,048×1,[email protected].Strange, then I guess datasheet is wrong (wouldn't be first time). Unfortunatelly there is no documentation for Cedrus capabilities, so everything is either educated guess or tested on HW. Documentation for older than H6 SoCs always mention only 1080p @ 60fps limit, even though several of them are capable of decoding 4K H264 videos (I'm not sure about max. fps though).
Quoted 5 lines
Quoted 1 line
Frankly, I'm open to put whatever value makes you happy.
To be honest, I'm not sure what is correct value here. It may depend on Cedrus core variant.
We can drop the level information as well, and just keep the profile one.
Maximum resolution is already enforced, via TRY_FMT, anyway.
Thanks,
Ezequiel
Quoted 25 lines
Best regards,
JernejQuoted 20 lines
Thanks,
EzequielQuoted 14 lines
Best regards,
JernejQuoted 11 lines
drivers/staging/media/sunxi/cedrus/cedrus.c +4
-0+ }, + .codec = CEDRUS_CODEC_H264, + .required = false, + }, { .cfg = { .id = V4L2_CID_MPEG_VIDEO_HEVC_SPS,Signature · 1 line
2.27.0
PATCH v2 3/9 media: Rename stateful codec control macros
In reply to Ezequiel GarciaFor historical reasons, stateful codec controls are named as {}_MPEG_{}. While we can't at this point sanely
change all control IDs (such as V4L2_CID_MPEG_VIDEO_VP8_FRAME_HEADER), we can least change the more meaningful macros such as classes macros.
--- .../userspace-api/media/v4l/dev-mem2mem.rst | 2 +- .../media/v4l/ext-ctrls-codec.rst | 4 +- .../media/v4l/extended-controls.rst | 8 +- .../media/v4l/vidioc-g-ext-ctrls.rst | 6 +- drivers/media/common/cx2341x.c | 4 +- drivers/media/platform/s5p-mfc/s5p_mfc_dec.c | 2 +- drivers/media/platform/s5p-mfc/s5p_mfc_enc.c | 2 +- drivers/media/v4l2-core/v4l2-ctrls.c | 4 +- include/media/fwht-ctrls.h | 2 +- include/media/h264-ctrls.h | 16 +- include/media/hevc-ctrls.h | 10 +- include/media/mpeg2-ctrls.h | 4 +- include/media/vp8-ctrls.h | 2 +- include/uapi/linux/v4l2-controls.h | 409 +++++++++--------- 14 files changed, 242 insertions(+), 233 deletions(-)
Documentation/userspace-api/media/v4l/dev-mem2mem.rst +1 -1
@@ -32,7 +32,7 @@ file handle is visible through another file handle). One of the most common memory-to-memory device is the codec. Codecs are more complicated than most and require additional setup for their codec parameters. This is done through codec controls. -See :ref:`mpeg-controls`. More details on how to use codec memory-to-memory +See :ref:`codec-controls`. More details on how to use codec memory-to-memory devices are given in the following sections. .. toctree::
Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +2 -2
@@ -1,6 +1,6 @@ .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later -.. _mpeg-controls: +.. _codec-controls: *********************** Codec Control Reference
@@ -26,7 +26,7 @@ Generic Codec Controls Codec Control IDs ----------------- -``V4L2_CID_MPEG_CLASS (class)`` +``V4L2_CID_CODEC_CLASS (class)`` The Codec class descriptor. Calling :ref:`VIDIOC_QUERYCTRL` for this control will return a description of this control class. This description can be
Documentation/userspace-api/media/v4l/extended-controls.rst +4 -4
@@ -55,8 +55,8 @@ controls in that array and a control class. Control classes are used to group similar controls into a single class. For example, control class ``V4L2_CTRL_CLASS_USER`` contains all user controls (i. e. all controls that can also be set using the old :ref:`VIDIOC_S_CTRL <VIDIOC_G_CTRL>` -ioctl). Control class ``V4L2_CTRL_CLASS_MPEG`` contains all controls -relating to MPEG encoding, etc. +ioctl). Control class ``V4L2_CTRL_CLASS_CODEC`` contains all controls +relating to stateful codecs. All controls in the control array must belong to the specified control class. An error is returned if this is not the case.
@@ -130,9 +130,9 @@ control class is found: .. code-block:: c - qctrl.id = V4L2_CTRL_CLASS_MPEG | V4L2_CTRL_FLAG_NEXT_CTRL; + qctrl.id = V4L2_CTRL_CLASS_CODEC | V4L2_CTRL_FLAG_NEXT_CTRL; while (0 == ioctl(fd, VIDIOC_QUERYCTRL, &qctrl)) { - if (V4L2_CTRL_ID2CLASS(qctrl.id) != V4L2_CTRL_CLASS_MPEG) + if (V4L2_CTRL_ID2CLASS(qctrl.id) != V4L2_CTRL_CLASS_CODEC) break; /* ... */ qctrl.id |= V4L2_CTRL_FLAG_NEXT_CTRL;
Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst +3 -3
@@ -322,10 +322,10 @@ still cause this situation. :ref:`VIDIOC_S_CTRL <VIDIOC_G_CTRL>` and :ref:`VIDIOC_G_CTRL <VIDIOC_G_CTRL>` ioctl belong to this class. - * - ``V4L2_CTRL_CLASS_MPEG`` + * - ``V4L2_CTRL_CLASS_CODEC`` - 0x990000 - - The class containing MPEG compression controls. These controls are - described in :ref:`mpeg-controls`. + - The class containing stateful codec controls. These controls are + described in :ref:`codec-controls`. * - ``V4L2_CTRL_CLASS_CAMERA`` - 0x9a0000 - The class containing camera controls. These controls are described
drivers/media/common/cx2341x.c +2 -2
@@ -166,7 +166,7 @@ static void cx2341x_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *ty/* Must be sorted from low to high control ID! */ const u32 cx2341x_mpeg_ctrls[] = { -V4L2_CID_MPEG_CLASS , +V4L2_CID_CODEC_CLASS ,V4L2_CID_MPEG_STREAM_TYPE ,V4L2_CID_MPEG_STREAM_VBI_FMT ,V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ ,
@@ -574,7 +574,7 @@ int cx2341x_ctrl_query(const struct cx2341x_mpeg_params *params,int err;switch (qctrl->id) { -case V4L2_CID_MPEG_CLASS : +case V4L2_CID_CODEC_CLASS :return v4l2_ctrl_query_fill (qctrl,0 ,0 ,0 ,0 );case V4L2_CID_MPEG_STREAM_TYPE : return v4l2_ctrl_query_fill(qctrl,
drivers/media/platform/s5p-mfc/s5p_mfc_dec.c +1 -1
@@ -1109,7 +1109,7 @@ const struct v4l2_ioctl_ops *get_dec_v4l2_ioctl_ops(void)return &s5p_mfc_dec_ioctl_ops; } -#define IS_MFC51_PRIV (x) ((V4L2_CTRL_ID2WHICH(x) == V4L2_CTRL_CLASS_MPEG) \ +#define IS_MFC51_PRIV (x) ((V4L2_CTRL_ID2WHICH(x) == V4L2_CTRL_CLASS_CODEC) \ && V4L2_CTRL_DRIVER_PRIV(x))int s5p_mfc_dec_ctrls_setup (struct s5p_mfc_ctx *ctx)
drivers/media/platform/s5p-mfc/s5p_mfc_enc.c +1 -1
@@ -2614,7 +2614,7 @@ const struct v4l2_ioctl_ops *get_enc_v4l2_ioctl_ops(void)return &s5p_mfc_enc_ioctl_ops; } -#define IS_MFC51_PRIV (x) ((V4L2_CTRL_ID2WHICH(x) == V4L2_CTRL_CLASS_MPEG) \ +#define IS_MFC51_PRIV (x) ((V4L2_CTRL_ID2WHICH(x) == V4L2_CTRL_CLASS_CODEC) \ && V4L2_CTRL_DRIVER_PRIV(x))int s5p_mfc_enc_ctrls_setup (struct s5p_mfc_ctx *ctx)
drivers/media/v4l2-core/v4l2-ctrls.c +2 -2
@@ -830,7 +830,7 @@ const char *v4l2_ctrl_get_name(u32 id)/* The MPEG controls are applicable to all codec controls * and the 'MPEG' part of the define is historical */ /* Keep the order of the 'case's the same as in videodev2.h! */ -case V4L2_CID_MPEG_CLASS :return "Codec Controls" ; +case V4L2_CID_CODEC_CLASS :return "Codec Controls" ;case V4L2_CID_MPEG_STREAM_TYPE :return "Stream Type" ;case V4L2_CID_MPEG_STREAM_PID_PMT :return "Stream PMT Program ID" ;case V4L2_CID_MPEG_STREAM_PID_AUDIO :return "Stream Audio Program ID" ;
@@ -1358,7 +1358,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,break ;case V4L2_CID_USER_CLASS :case V4L2_CID_CAMERA_CLASS : -case V4L2_CID_MPEG_CLASS : +case V4L2_CID_CODEC_CLASS :case V4L2_CID_FM_TX_CLASS :case V4L2_CID_FLASH_CLASS :case V4L2_CID_JPEG_CLASS :
include/media/fwht-ctrls.h +1 -1
@@ -13,7 +13,7 @@#define V4L2_CTRL_TYPE_FWHT_PARAMS 0x0105 -#define V4L2_CID_MPEG_VIDEO_FWHT_PARAMS (V4L2_CID_MPEG_BASE + 292) +#define V4L2_CID_MPEG_VIDEO_FWHT_PARAMS (V4L2_CID_CODEC_BASE + 292)struct v4l2_ctrl_fwht_params {__u64 backward_ref_ts;
include/media/h264-ctrls.h +8 -8
@@ -29,14 +29,14 @@* would be added during the phase where those controls are not * stable. It should be fixed eventually. */ -#define V4L2_CID_MPEG_VIDEO_H264_SPS (V4L2_CID_MPEG_BASE+1000) -#define V4L2_CID_MPEG_VIDEO_H264_PPS (V4L2_CID_MPEG_BASE+1001) -#define V4L2_CID_MPEG_VIDEO_H264_SCALING_MATRIX (V4L2_CID_MPEG_BASE+1002) -#define V4L2_CID_MPEG_VIDEO_H264_SLICE_PARAMS (V4L2_CID_MPEG_BASE+1003) -#define V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS (V4L2_CID_MPEG_BASE+1004) -#define V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE (V4L2_CID_MPEG_BASE+1005) -#define V4L2_CID_MPEG_VIDEO_H264_START_CODE (V4L2_CID_MPEG_BASE+1006) -#define V4L2_CID_MPEG_VIDEO_H264_PRED_WEIGHTS (V4L2_CID_MPEG_BASE+1007) +#define V4L2_CID_MPEG_VIDEO_H264_SPS (V4L2_CID_CODEC_BASE+1000) +#define V4L2_CID_MPEG_VIDEO_H264_PPS (V4L2_CID_CODEC_BASE+1001) +#define V4L2_CID_MPEG_VIDEO_H264_SCALING_MATRIX (V4L2_CID_CODEC_BASE+1002) +#define V4L2_CID_MPEG_VIDEO_H264_SLICE_PARAMS (V4L2_CID_CODEC_BASE+1003) +#define V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS (V4L2_CID_CODEC_BASE+1004) +#define V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE (V4L2_CID_CODEC_BASE+1005) +#define V4L2_CID_MPEG_VIDEO_H264_START_CODE (V4L2_CID_CODEC_BASE+1006) +#define V4L2_CID_MPEG_VIDEO_H264_PRED_WEIGHTS (V4L2_CID_CODEC_BASE+1007)/* enum v4l2_ctrl_type type values */ #define V4L2_CTRL_TYPE_H264_SPS 0x0110
include/media/hevc-ctrls.h +5 -5
@@ -16,11 +16,11 @@/* The pixel format isn't stable at the moment and will likely be renamed. */ #define V4L2_PIX_FMT_HEVC_SLICE v4l2_fourcc('S', '2', '6', '5')/* HEVC parsed slices */ -#define V4L2_CID_MPEG_VIDEO_HEVC_SPS (V4L2_CID_MPEG_BASE + 1008) -#define V4L2_CID_MPEG_VIDEO_HEVC_PPS (V4L2_CID_MPEG_BASE + 1009) -#define V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS (V4L2_CID_MPEG_BASE + 1010) -#define V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE (V4L2_CID_MPEG_BASE + 1015) -#define V4L2_CID_MPEG_VIDEO_HEVC_START_CODE (V4L2_CID_MPEG_BASE + 1016) +#define V4L2_CID_MPEG_VIDEO_HEVC_SPS (V4L2_CID_CODEC_BASE + 1008) +#define V4L2_CID_MPEG_VIDEO_HEVC_PPS (V4L2_CID_CODEC_BASE + 1009) +#define V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS (V4L2_CID_CODEC_BASE + 1010) +#define V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE (V4L2_CID_CODEC_BASE + 1015) +#define V4L2_CID_MPEG_VIDEO_HEVC_START_CODE (V4L2_CID_CODEC_BASE + 1016)/* enum v4l2_ctrl_type type values */ #define V4L2_CTRL_TYPE_HEVC_SPS 0x0120
include/media/mpeg2-ctrls.h +2 -2
@@ -11,8 +11,8 @@#ifndef _MPEG2_CTRLS_H_#define _MPEG2_CTRLS_H_ -#define V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS (V4L2_CID_MPEG_BASE+250) -#define V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION (V4L2_CID_MPEG_BASE+251) +#define V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS (V4L2_CID_CODEC_BASE+250) +#define V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION (V4L2_CID_CODEC_BASE+251)/* enum v4l2_ctrl_type type values */ #define V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS 0x0103
include/media/vp8-ctrls.h +1 -1
@@ -15,7 +15,7 @@#define V4L2_PIX_FMT_VP8_FRAME v4l2_fourcc('V', 'P', '8', 'F') -#define V4L2_CID_MPEG_VIDEO_VP8_FRAME_HEADER (V4L2_CID_MPEG_BASE + 2000) +#define V4L2_CID_MPEG_VIDEO_VP8_FRAME_HEADER (V4L2_CID_CODEC_BASE + 2000)#define V4L2_CTRL_TYPE_VP8_FRAME_HEADER 0x301#define V4L2_VP8_SEGMENT_HEADER_FLAG_ENABLED 0x01
include/uapi/linux/v4l2-controls.h +209 -200
720 lines not on this page · raw message
Signature · 1 line
2.27.0
Re: [PATCH v2 3/9] media: Rename stateful codec control macros
Quoted 24 lines · Ezequiel Garcia
For historical reasons, stateful codec controls are named as {}_MPEG_{}. While we can't at this point sanely
change all control IDs (such asV4L2_CID_MPEG_VIDEO_VP8_FRAME_HEADER), we can least change the more meaningful macros such as classes macros.Signed-off-by Ezequiel Garcia <[email protected]>--- .../userspace-api/media/v4l/dev-mem2mem.rst | 2 +- .../media/v4l/ext-ctrls-codec.rst | 4 +- .../media/v4l/extended-controls.rst | 8 +- .../media/v4l/vidioc-g-ext-ctrls.rst | 6 +- drivers/media/common/cx2341x.c | 4 +- drivers/media/platform/s5p-mfc/s5p_mfc_dec.c | 2 +- drivers/media/platform/s5p-mfc/s5p_mfc_enc.c | 2 +- drivers/media/v4l2-core/v4l2-ctrls.c | 4 +- include/media/fwht-ctrls.h | 2 +- include/media/h264-ctrls.h | 16 +- include/media/hevc-ctrls.h | 10 +- include/media/mpeg2-ctrls.h | 4 +- include/media/vp8-ctrls.h | 2 +- include/uapi/linux/v4l2-controls.h | 409 +++++++++--------- 14 files changed, 242 insertions(+), 233 deletions(-)
<snip>
include/uapi/linux/v4l2-controls.h enum v4l2_detect_md_mode { · line 1186
Quoted 11 lines
include/uapi/linux/v4l2-controls.h +7
-0@@ -1177,4 +1177,13 @@ enum v4l2_detect_md_mode {#define V4L2_CID_DETECT_MD_THRESHOLD_GRID (V4L2_CID_DETECT_CLASS_BASE + 3)#define V4L2_CID_DETECT_MD_REGION_GRID (V4L2_CID_DETECT_CLASS_BASE + 4) +/* MPEG-compression definitions kept for backwards compatibility */ +#ifndef __KERNEL__ +#define V4L2_CTRL_CLASS_MPEG V4L2_CTRL_CLASS_CODEC +#define V4L2_CID_MPEG_CLASS (V4L2_CTRL_CLASS_MPEG | 1) +#define V4L2_CID_MPEG_BASE (V4L2_CTRL_CLASS_MPEG | 0x900) +#define V4L2_CID_MPEG_CX2341X_BASE (V4L2_CTRL_CLASS_MPEG | 0x1000) +#define V4L2_CID_MPEG_MFC51_BASE (V4L2_CTRL_CLASS_MPEG | 0x1100)
Don't copy the offset value here, just keep this as a straight aliases, e.g.:
#define V4L2_CID_MPEG_MFC51_BASE V4L2_CID_CODEC_MFC51_BASE
It's safer that way.
Regards,
Hans
Quoted 4 lines
include/uapi/linux/v4l2-controls.h +2
-0+#endif +#endif
Re: [PATCH v2 3/9] media: Rename stateful codec control macros
Quoted 42 lines · Hans Verkuil
Quoted 24 lines · Ezequiel Garcia
For historical reasons, stateful codec controls are named as {}_MPEG_{}. While we can't at this point sanely
change all control IDs (such asV4L2_CID_MPEG_VIDEO_VP8_FRAME_HEADER), we can least change the more meaningful macros such as classes macros.Signed-off-by Ezequiel Garcia <[email protected]>--- .../userspace-api/media/v4l/dev-mem2mem.rst | 2 +- .../media/v4l/ext-ctrls-codec.rst | 4 +- .../media/v4l/extended-controls.rst | 8 +- .../media/v4l/vidioc-g-ext-ctrls.rst | 6 +- drivers/media/common/cx2341x.c | 4 +- drivers/media/platform/s5p-mfc/s5p_mfc_dec.c | 2 +- drivers/media/platform/s5p-mfc/s5p_mfc_enc.c | 2 +- drivers/media/v4l2-core/v4l2-ctrls.c | 4 +- include/media/fwht-ctrls.h | 2 +- include/media/h264-ctrls.h | 16 +- include/media/hevc-ctrls.h | 10 +- include/media/mpeg2-ctrls.h | 4 +- include/media/vp8-ctrls.h | 2 +- include/uapi/linux/v4l2-controls.h | 409 +++++++++--------- 14 files changed, 242 insertions(+), 233 deletions(-)<snip>
include/uapi/linux/v4l2-controls.h enum v4l2_detect_md_mode { · line 1186
Quoted 11 lines
include/uapi/linux/v4l2-controls.h +7
-0@@ -1177,4 +1177,13 @@ enum v4l2_detect_md_mode {#define V4L2_CID_DETECT_MD_THRESHOLD_GRID (V4L2_CID_DETECT_CLASS_BASE + 3)#define V4L2_CID_DETECT_MD_REGION_GRID (V4L2_CID_DETECT_CLASS_BASE + 4) +/* MPEG-compression definitions kept for backwards compatibility */ +#ifndef __KERNEL__ +#define V4L2_CTRL_CLASS_MPEG V4L2_CTRL_CLASS_CODEC +#define V4L2_CID_MPEG_CLASS (V4L2_CTRL_CLASS_MPEG | 1) +#define V4L2_CID_MPEG_BASE (V4L2_CTRL_CLASS_MPEG | 0x900) +#define V4L2_CID_MPEG_CX2341X_BASE (V4L2_CTRL_CLASS_MPEG | 0x1000) +#define V4L2_CID_MPEG_MFC51_BASE (V4L2_CTRL_CLASS_MPEG | 0x1100)Don't copy the offset value here, just keep this as a straight aliases, e.g.:
Quoted 4 lines
#define
V4L2_CID_MPEG_MFC51_BASEV4L2_CID_CODEC_MFC51_BASEIt's safer that way.
Yes, indeed.
Thanks,
Ezequiel
PATCH v2 4/9 media: Clean stateless control includes
In reply to Ezequiel GarciaAvoid including h264-ctrls.h, vp8-ctrls.h, etc, and instead just include v4l2-ctrls.h which does the right thing.
This is in preparation for moving the stateless controls out of staging, which will mean removing some of these headers.
--- drivers/staging/media/hantro/hantro_hw.h | 4 +--- include/media/v4l2-h264.h | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/staging/media/hantro/hantro_hw.h +1 -3
@@ -11,9 +11,7 @@#include <linux/interrupt.h> #include <linux/v4l2-controls.h> -#include <media/h264-ctrls.h> -#include <media/mpeg2-ctrls.h> -#include <media/vp8-ctrls.h> +#include <media/v4l2-ctrls.h> #include <media/videobuf2-core.h> #define DEC_8190_ALIGN_MASK 0x07U
include/media/v4l2-h264.h +1 -1
@@ -10,7 +10,7 @@#ifndef _MEDIA_V4L2_H264_H#define _MEDIA_V4L2_H264_H -#include <media/h264-ctrls.h> +#include <media/v4l2-ctrls.h> /** * struct v4l2_h264_reflist_builder - Reference list builder object
Signature · 1 line
2.27.0
PATCH v2 5/9 media: controls: Add the stateless codec control class
In reply to Ezequiel GarciaAdd a new control class to hold the stateless codecs controls that are ready to be moved out of staging.
--- drivers/media/v4l2-core/v4l2-ctrls.c | 5 +++++ include/uapi/linux/v4l2-controls.h | 7 +++++++ 2 files changed, 12 insertions(+)
drivers/media/v4l2-core/v4l2-ctrls.c +5 -0
@@ -1181,6 +1181,10 @@ const char *v4l2_ctrl_get_name(u32 id)case V4L2_CID_DETECT_MD_GLOBAL_THRESHOLD :return "MD Global Threshold" ;case V4L2_CID_DETECT_MD_THRESHOLD_GRID :return "MD Threshold Grid" ;case V4L2_CID_DETECT_MD_REGION_GRID :return "MD Region Grid" ; + +/* Codec controls */ +/* Keep the order of the 'case's the same as in v4l2-controls.h! */ +case V4L2_CID_CODEC_STATELESS_CLASS :return "Stateless Codec Controls" ;default :return NULL ; }
@@ -1368,6 +1372,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,case V4L2_CID_FM_RX_CLASS :case V4L2_CID_RF_TUNER_CLASS :case V4L2_CID_DETECT_CLASS : +case V4L2_CID_CODEC_STATELESS_CLASS : *type =V4L2_CTRL_TYPE_CTRL_CLASS ;/* You can neither read not write these */ *flags |=V4L2_CTRL_FLAG_READ_ONLY |V4L2_CTRL_FLAG_WRITE_ONLY ;
include/uapi/linux/v4l2-controls.h +7 -0
@@ -65,6 +65,7 @@#define V4L2_CTRL_CLASS_FM_RX 0x00a10000/* FM Receiver controls */ #define V4L2_CTRL_CLASS_RF_TUNER 0x00a20000/* RF tuner controls */ #define V4L2_CTRL_CLASS_DETECT 0x00a30000/* Detection controls */ +#define V4L2_CTRL_CLASS_CODEC_STATELESS 0x00a40000/* Stateless codecs controls */ /* User-class control IDs */
@@ -1177,6 +1178,12 @@ enum v4l2_detect_md_mode {#define V4L2_CID_DETECT_MD_THRESHOLD_GRID (V4L2_CID_DETECT_CLASS_BASE + 3)#define V4L2_CID_DETECT_MD_REGION_GRID (V4L2_CID_DETECT_CLASS_BASE + 4) + +/* Stateless CODECs controls */ +#define V4L2_CID_CODEC_STATELESS_BASE (V4L2_CTRL_CLASS_CODEC_STATELESS | 0x900) +#define V4L2_CID_CODEC_STATELESS_CLASS (V4L2_CTRL_CLASS_CODEC_STATELESS | 1) + +/* MPEG-compression definitions kept for backwards compatibility */ #ifndef __KERNEL__#define V4L2_CTRL_CLASS_MPEG V4L2_CTRL_CLASS_CODEC
Signature · 1 line
2.27.0
PATCH v2 6/9 media: uapi: Move parsed H264 pixel format out of staging
In reply to Ezequiel GarciaSince we are ready to stabilize the H264 stateless API, start by first moving the parsed H264 pixel format.
--- include/media/h264-ctrls.h | 3 --- include/uapi/linux/videodev2.h | 1 + 2 files changed, 1 insertion(+), 3 deletions(-)
include/media/h264-ctrls.h +0 -3
@@ -21,9 +21,6 @@#define V4L2_H264_REF_LIST_LEN (2 * V4L2_H264_NUM_DPB_ENTRIES) -/* Our pixel format isn't stable at the moment */ -#define V4L2_PIX_FMT_H264_SLICE v4l2_fourcc('S', '2', '6', '4')/* H264 parsed slices */ -/* * This is put insanely high to avoid conflicting with controls that * would be added during the phase where those controls are not
include/uapi/linux/videodev2.h +1 -0
@@ -703,6 +703,7 @@ struct v4l2_pix_format {#define V4L2_PIX_FMT_HEVC v4l2_fourcc('H', 'E', 'V', 'C')/* HEVC aka H.265 */ #define V4L2_PIX_FMT_FWHT v4l2_fourcc('F', 'W', 'H', 'T')/* Fast Walsh Hadamard Transform (vicodec) */ #define V4L2_PIX_FMT_FWHT_STATELESS v4l2_fourcc('S', 'F', 'W', 'H')/* Stateless FWHT (vicodec) */ +#define V4L2_PIX_FMT_H264_SLICE v4l2_fourcc('S', '2', '6', '4')/* H264 parsed slices */ /* Vendor-specific formats */ #define V4L2_PIX_FMT_CPIA1 v4l2_fourcc('C', 'P', 'I', 'A')/* cpia1 YUV */
Signature · 1 line
2.27.0
PATCH v2 7/9 media: uapi: Move the H264 stateless control types out of staging
In reply to Ezequiel GarciaMove the H264 stateless control types out of staging, and re-number them to avoid any confusion.
--- include/media/h264-ctrls.h | 8 -------- include/uapi/linux/videodev2.h | 7 +++++++ 2 files changed, 7 insertions(+), 8 deletions(-)
include/media/h264-ctrls.h +0 -8
@@ -35,14 +35,6 @@#define V4L2_CID_MPEG_VIDEO_H264_START_CODE (V4L2_CID_CODEC_BASE+1006)#define V4L2_CID_MPEG_VIDEO_H264_PRED_WEIGHTS (V4L2_CID_CODEC_BASE+1007) -/* enum v4l2_ctrl_type type values */ -#define V4L2_CTRL_TYPE_H264_SPS 0x0110 -#define V4L2_CTRL_TYPE_H264_PPS 0x0111 -#define V4L2_CTRL_TYPE_H264_SCALING_MATRIX 0x0112 -#define V4L2_CTRL_TYPE_H264_SLICE_PARAMS 0x0113 -#define V4L2_CTRL_TYPE_H264_DECODE_PARAMS 0x0114 -#define V4L2_CTRL_TYPE_H264_PRED_WEIGHTS 0x0115 -/** * enum v4l2_mpeg_video_h264_decode_mode - Decoding mode *
include/uapi/linux/videodev2.h +7 -0
@@ -1776,6 +1776,13 @@ enum v4l2_ctrl_type {V4L2_CTRL_TYPE_U16 =0x0101 ,V4L2_CTRL_TYPE_U32 =0x0102 ,V4L2_CTRL_TYPE_AREA =0x0106 , + +V4L2_CTRL_TYPE_H264_SPS =0x0200 , +V4L2_CTRL_TYPE_H264_PPS =0x0201 , +V4L2_CTRL_TYPE_H264_SCALING_MATRIX =0x0202 , +V4L2_CTRL_TYPE_H264_SLICE_PARAMS =0x0203 , +V4L2_CTRL_TYPE_H264_DECODE_PARAMS =0x0204 , + V4L2_CTRL_TYPE_H264_PRED_WEIGHTS = 0x0205, };/* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */
Signature · 1 line
2.27.0
PATCH v2 8/9 media: uapi: move H264 stateless controls out of staging
In reply to Ezequiel GarciaThe H264 stateless controls is ready to be part
of the stable uAPI.
Re-number the control IDs, move them to the newly
created stateless control class, and updates all
the drivers accordingly.
--- drivers/media/v4l2-core/v4l2-ctrls.c | 36 +- drivers/staging/media/hantro/hantro_drv.c | 26 +- drivers/staging/media/hantro/hantro_h264.c | 8 +- drivers/staging/media/rkvdec/rkvdec-h264.c | 8 +- drivers/staging/media/rkvdec/rkvdec.c | 26 +- drivers/staging/media/sunxi/cedrus/cedrus.c | 24 +- .../staging/media/sunxi/cedrus/cedrus_dec.c | 12 +- include/media/v4l2-ctrls.h | 1 - include/uapi/linux/v4l2-controls.h | 372 ++++++++++++++++++ 9 files changed, 442 insertions(+), 71 deletions(-)
drivers/media/v4l2-core/v4l2-ctrls.c +18 -18
@@ -693,9 +693,9 @@ const char * const *v4l2_ctrl_get_menu(u32 id)return h264_fp_arrangement_type;case V4L2_CID_MPEG_VIDEO_H264_FMO_MAP_TYPE :return h264_fmo_map_type; -case V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE : +case V4L2_CID_STATELESS_H264_DECODE_MODE :return h264_decode_mode; -case V4L2_CID_MPEG_VIDEO_H264_START_CODE : +case V4L2_CID_STATELESS_H264_START_CODE :return h264_start_code;case V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL :return mpeg_mpeg2_level;
@@ -920,14 +920,6 @@ const char *v4l2_ctrl_get_name(u32 id)case V4L2_CID_MPEG_VIDEO_H264_I_FRAME_MAX_QP :return "H264 I-Frame Maximum QP Value" ;case V4L2_CID_MPEG_VIDEO_H264_P_FRAME_MIN_QP :return "H264 P-Frame Minimum QP Value" ;case V4L2_CID_MPEG_VIDEO_H264_P_FRAME_MAX_QP :return "H264 P-Frame Maximum QP Value" ; -case V4L2_CID_MPEG_VIDEO_H264_SPS :return "H264 Sequence Parameter Set" ; -case V4L2_CID_MPEG_VIDEO_H264_PPS :return "H264 Picture Parameter Set" ; -case V4L2_CID_MPEG_VIDEO_H264_SCALING_MATRIX :return "H264 Scaling Matrix" ; -case V4L2_CID_MPEG_VIDEO_H264_SLICE_PARAMS :return "H264 Slice Parameters" ; -case V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS :return "H264 Decode Parameters" ; -case V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE :return "H264 Decode Mode" ; -case V4L2_CID_MPEG_VIDEO_H264_START_CODE :return "H264 Start Code" ; -case V4L2_CID_MPEG_VIDEO_H264_PRED_WEIGHTS :return "H264 Prediction Weight Table" ;case V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL :return "MPEG2 Level" ;case V4L2_CID_MPEG_VIDEO_MPEG2_PROFILE :return "MPEG2 Profile" ;case V4L2_CID_MPEG_VIDEO_MPEG4_I_FRAME_QP :return "MPEG4 I-Frame QP Value" ;
@@ -1185,6 +1177,14 @@ const char *v4l2_ctrl_get_name(u32 id)/* Codec controls */ /* Keep the order of the 'case's the same as in v4l2-controls.h! */ case V4L2_CID_CODEC_STATELESS_CLASS :return "Stateless Codec Controls" ; +case V4L2_CID_STATELESS_H264_DECODE_MODE :return "H264 Decode Mode" ; +case V4L2_CID_STATELESS_H264_START_CODE :return "H264 Start Code" ; +case V4L2_CID_STATELESS_H264_SPS :return "H264 Sequence Parameter Set" ; +case V4L2_CID_STATELESS_H264_PPS :return "H264 Picture Parameter Set" ; +case V4L2_CID_STATELESS_H264_SCALING_MATRIX :return "H264 Scaling Matrix" ; +case V4L2_CID_STATELESS_H264_PRED_WEIGHTS :return "H264 Prediction Weight Table" ; +case V4L2_CID_STATELESS_H264_SLICE_PARAMS :return "H264 Slice Parameters" ; +case V4L2_CID_STATELESS_H264_DECODE_PARAMS :return "H264 Decode Parameters" ;default :return NULL ; }
@@ -1310,8 +1310,6 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,case V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_IDC :case V4L2_CID_MPEG_VIDEO_H264_SEI_FP_ARRANGEMENT_TYPE :case V4L2_CID_MPEG_VIDEO_H264_FMO_MAP_TYPE : -case V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE : -case V4L2_CID_MPEG_VIDEO_H264_START_CODE :case V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL :case V4L2_CID_MPEG_VIDEO_MPEG2_PROFILE :case V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL :
@@ -1342,6 +1340,8 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,case V4L2_CID_MPEG_VIDEO_HEVC_LOOP_FILTER_MODE :case V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE :case V4L2_CID_MPEG_VIDEO_HEVC_START_CODE : +case V4L2_CID_STATELESS_H264_DECODE_MODE : +case V4L2_CID_STATELESS_H264_START_CODE :case V4L2_CID_CAMERA_ORIENTATION : *type =V4L2_CTRL_TYPE_MENU ;break ;
@@ -1436,22 +1436,22 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,case V4L2_CID_MPEG_VIDEO_FWHT_PARAMS : *type =V4L2_CTRL_TYPE_FWHT_PARAMS ;break ; -case V4L2_CID_MPEG_VIDEO_H264_SPS : +case V4L2_CID_STATELESS_H264_SPS : *type =V4L2_CTRL_TYPE_H264_SPS ;break ; -case V4L2_CID_MPEG_VIDEO_H264_PPS : +case V4L2_CID_STATELESS_H264_PPS : *type =V4L2_CTRL_TYPE_H264_PPS ;break ; -case V4L2_CID_MPEG_VIDEO_H264_SCALING_MATRIX : +case V4L2_CID_STATELESS_H264_SCALING_MATRIX : *type =V4L2_CTRL_TYPE_H264_SCALING_MATRIX ;break ; -case V4L2_CID_MPEG_VIDEO_H264_SLICE_PARAMS : +case V4L2_CID_STATELESS_H264_SLICE_PARAMS : *type =V4L2_CTRL_TYPE_H264_SLICE_PARAMS ;break ; -case V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS : +case V4L2_CID_STATELESS_H264_DECODE_PARAMS : *type =V4L2_CTRL_TYPE_H264_DECODE_PARAMS ;break ; -case V4L2_CID_MPEG_VIDEO_H264_PRED_WEIGHTS : +case V4L2_CID_STATELESS_H264_PRED_WEIGHTS : *type =V4L2_CTRL_TYPE_H264_PRED_WEIGHTS ;break ;case V4L2_CID_MPEG_VIDEO_VP8_FRAME_HEADER :
drivers/staging/media/hantro/hantro_drv.c +13 -13
@@ -231,7 +231,7 @@ queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *dst_vq)static int hantro_try_ctrl (struct v4l2_ctrl *ctrl) { -if (ctrl->id ==V4L2_CID_MPEG_VIDEO_H264_SPS ) { +if (ctrl->id ==V4L2_CID_STATELESS_H264_SPS ) {const struct v4l2_ctrl_h264_sps *sps = ctrl->p_new.p_h264_sps;if (sps->chroma_format_idc >1 )
@@ -304,39 +304,39 @@ static const struct hantro_ctrl controls[] = { }, { .codec = HANTRO_H264_DECODER, .cfg = { - .id = V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS, + .id = V4L2_CID_STATELESS_H264_DECODE_PARAMS, }, }, { .codec = HANTRO_H264_DECODER, .cfg = { - .id = V4L2_CID_MPEG_VIDEO_H264_SPS, + .id = V4L2_CID_STATELESS_H264_SPS, .ops = &hantro_ctrl_ops, }, }, { .codec = HANTRO_H264_DECODER, .cfg = { - .id = V4L2_CID_MPEG_VIDEO_H264_PPS, + .id = V4L2_CID_STATELESS_H264_PPS, }, }, { .codec = HANTRO_H264_DECODER, .cfg = { - .id = V4L2_CID_MPEG_VIDEO_H264_SCALING_MATRIX, + .id = V4L2_CID_STATELESS_H264_SCALING_MATRIX, }, }, { .codec = HANTRO_H264_DECODER, .cfg = { - .id = V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE, - .min = V4L2_MPEG_VIDEO_H264_DECODE_MODE_FRAME_BASED, - .def = V4L2_MPEG_VIDEO_H264_DECODE_MODE_FRAME_BASED, - .max = V4L2_MPEG_VIDEO_H264_DECODE_MODE_FRAME_BASED, + .id = V4L2_CID_STATELESS_H264_DECODE_MODE, + .min = V4L2_STATELESS_H264_DECODE_MODE_FRAME_BASED, + .def = V4L2_STATELESS_H264_DECODE_MODE_FRAME_BASED, + .max = V4L2_STATELESS_H264_DECODE_MODE_FRAME_BASED, }, }, { .codec = HANTRO_H264_DECODER, .cfg = { - .id = V4L2_CID_MPEG_VIDEO_H264_START_CODE, - .min = V4L2_MPEG_VIDEO_H264_START_CODE_ANNEX_B, - .def = V4L2_MPEG_VIDEO_H264_START_CODE_ANNEX_B, - .max = V4L2_MPEG_VIDEO_H264_START_CODE_ANNEX_B, + .id = V4L2_CID_STATELESS_H264_START_CODE, + .min = V4L2_STATELESS_H264_START_CODE_ANNEX_B, + .def = V4L2_STATELESS_H264_START_CODE_ANNEX_B, + .max = V4L2_STATELESS_H264_START_CODE_ANNEX_B, }, }, { .codec = HANTRO_H264_DECODER,
drivers/staging/media/hantro/hantro_h264.c +4 -4
@@ -344,22 +344,22 @@ int hantro_h264_dec_prepare_run(struct hantro_ctx *ctx)hantro_start_prepare_run (ctx); ctrls->scaling = -hantro_get_ctrl (ctx,V4L2_CID_MPEG_VIDEO_H264_SCALING_MATRIX ); +hantro_get_ctrl (ctx,V4L2_CID_STATELESS_H264_SCALING_MATRIX );if (WARN_ON (!ctrls->scaling))return -EINVAL ; ctrls->decode = -hantro_get_ctrl (ctx,V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS ); +hantro_get_ctrl (ctx,V4L2_CID_STATELESS_H264_DECODE_PARAMS );if (WARN_ON (!ctrls->decode))return -EINVAL ; ctrls->sps = -hantro_get_ctrl (ctx,V4L2_CID_MPEG_VIDEO_H264_SPS ); +hantro_get_ctrl (ctx,V4L2_CID_STATELESS_H264_SPS );if (WARN_ON (!ctrls->sps))return -EINVAL ; ctrls->pps = -hantro_get_ctrl (ctx,V4L2_CID_MPEG_VIDEO_H264_PPS ); +hantro_get_ctrl (ctx,V4L2_CID_STATELESS_H264_PPS );if (WARN_ON (!ctrls->pps))return -EINVAL ;
drivers/staging/media/rkvdec/rkvdec-h264.c +4 -4
@@ -1067,16 +1067,16 @@ static void rkvdec_h264_run_preamble(struct rkvdec_ctx *ctx,struct v4l2_ctrl *ctrl; ctrl =v4l2_ctrl_find (&ctx->ctrl_hdl, -V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS ); +V4L2_CID_STATELESS_H264_DECODE_PARAMS ); run->decode_params = ctrl ? ctrl->p_cur.p :NULL ; ctrl =v4l2_ctrl_find (&ctx->ctrl_hdl, -V4L2_CID_MPEG_VIDEO_H264_SPS ); +V4L2_CID_STATELESS_H264_SPS ); run->sps = ctrl ? ctrl->p_cur.p :NULL ; ctrl =v4l2_ctrl_find (&ctx->ctrl_hdl, -V4L2_CID_MPEG_VIDEO_H264_PPS ); +V4L2_CID_STATELESS_H264_PPS ); run->pps = ctrl ? ctrl->p_cur.p :NULL ; ctrl =v4l2_ctrl_find (&ctx->ctrl_hdl, -V4L2_CID_MPEG_VIDEO_H264_SCALING_MATRIX ); +V4L2_CID_STATELESS_H264_SCALING_MATRIX ); run->scaling_matrix = ctrl ? ctrl->p_cur.p :NULL ;rkvdec_run_preamble (ctx, &run->base);
drivers/staging/media/rkvdec/rkvdec.c +13 -13
@@ -29,7 +29,7 @@static int rkvdec_try_ctrl (struct v4l2_ctrl *ctrl) { -if (ctrl->id ==V4L2_CID_MPEG_VIDEO_H264_SPS ) { +if (ctrl->id ==V4L2_CID_STATELESS_H264_SPS ) {const struct v4l2_ctrl_h264_sps *sps = ctrl->p_new.p_h264_sps;/* * TODO: The hardware supports 10-bit and 4:2:2 profiles,
@@ -56,31 +56,31 @@ static const struct v4l2_ctrl_ops rkvdec_ctrl_ops = {static const struct rkvdec_ctrl_desc rkvdec_h264_ctrl_descs[] = { { .mandatory = true, - .cfg.id =V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS , + .cfg.id =V4L2_CID_STATELESS_H264_DECODE_PARAMS , }, { .mandatory = true, - .cfg.id =V4L2_CID_MPEG_VIDEO_H264_SPS , + .cfg.id =V4L2_CID_STATELESS_H264_SPS , .cfg.ops = &rkvdec_ctrl_ops, }, { .mandatory = true, - .cfg.id =V4L2_CID_MPEG_VIDEO_H264_PPS , + .cfg.id =V4L2_CID_STATELESS_H264_PPS , }, { - .cfg.id =V4L2_CID_MPEG_VIDEO_H264_SCALING_MATRIX , + .cfg.id =V4L2_CID_STATELESS_H264_SCALING_MATRIX , }, { - .cfg.id =V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE , - .cfg.min =V4L2_MPEG_VIDEO_H264_DECODE_MODE_FRAME_BASED , - .cfg.max =V4L2_MPEG_VIDEO_H264_DECODE_MODE_FRAME_BASED , - .cfg.def =V4L2_MPEG_VIDEO_H264_DECODE_MODE_FRAME_BASED , + .cfg.id =V4L2_CID_STATELESS_H264_DECODE_MODE , + .cfg.min =V4L2_STATELESS_H264_DECODE_MODE_FRAME_BASED , + .cfg.max =V4L2_STATELESS_H264_DECODE_MODE_FRAME_BASED , + .cfg.def =V4L2_STATELESS_H264_DECODE_MODE_FRAME_BASED , }, { - .cfg.id =V4L2_CID_MPEG_VIDEO_H264_START_CODE , - .cfg.min =V4L2_MPEG_VIDEO_H264_START_CODE_ANNEX_B , - .cfg.def =V4L2_MPEG_VIDEO_H264_START_CODE_ANNEX_B , - .cfg.max =V4L2_MPEG_VIDEO_H264_START_CODE_ANNEX_B , + .cfg.id =V4L2_CID_STATELESS_H264_START_CODE , + .cfg.min =V4L2_STATELESS_H264_START_CODE_ANNEX_B , + .cfg.def =V4L2_STATELESS_H264_START_CODE_ANNEX_B , + .cfg.max =V4L2_STATELESS_H264_START_CODE_ANNEX_B , }, { .cfg.id =V4L2_CID_MPEG_VIDEO_H264_PROFILE ,
drivers/staging/media/sunxi/cedrus/cedrus.c +12 -12
@@ -45,60 +45,60 @@ static const struct cedrus_control cedrus_controls[] = { }, { .cfg = { - .id = V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS, + .id = V4L2_CID_STATELESS_H264_DECODE_PARAMS, }, .codec = CEDRUS_CODEC_H264, .required = true, }, { .cfg = { - .id = V4L2_CID_MPEG_VIDEO_H264_SLICE_PARAMS, + .id = V4L2_CID_STATELESS_H264_SLICE_PARAMS, }, .codec = CEDRUS_CODEC_H264, .required = true, }, { .cfg = { - .id = V4L2_CID_MPEG_VIDEO_H264_SPS, + .id = V4L2_CID_STATELESS_H264_SPS, }, .codec = CEDRUS_CODEC_H264, .required = true, }, { .cfg = { - .id = V4L2_CID_MPEG_VIDEO_H264_PPS, + .id = V4L2_CID_STATELESS_H264_PPS, }, .codec = CEDRUS_CODEC_H264, .required = true, }, { .cfg = { - .id = V4L2_CID_MPEG_VIDEO_H264_SCALING_MATRIX, + .id = V4L2_CID_STATELESS_H264_SCALING_MATRIX, }, .codec = CEDRUS_CODEC_H264, .required = false, }, { .cfg = { - .id = V4L2_CID_MPEG_VIDEO_H264_PRED_WEIGHTS, + .id = V4L2_CID_STATELESS_H264_PRED_WEIGHTS, }, .codec = CEDRUS_CODEC_H264, .required = false, }, { .cfg = { - .id = V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE, - .max = V4L2_MPEG_VIDEO_H264_DECODE_MODE_SLICE_BASED, - .def = V4L2_MPEG_VIDEO_H264_DECODE_MODE_SLICE_BASED, + .id = V4L2_CID_STATELESS_H264_DECODE_MODE, + .max = V4L2_STATELESS_H264_DECODE_MODE_SLICE_BASED, + .def = V4L2_STATELESS_H264_DECODE_MODE_SLICE_BASED, }, .codec = CEDRUS_CODEC_H264, .required = false, }, { .cfg = { - .id = V4L2_CID_MPEG_VIDEO_H264_START_CODE, - .max = V4L2_MPEG_VIDEO_H264_START_CODE_NONE, - .def = V4L2_MPEG_VIDEO_H264_START_CODE_NONE, + .id = V4L2_CID_STATELESS_H264_START_CODE, + .max = V4L2_STATELESS_H264_START_CODE_NONE, + .def = V4L2_STATELESS_H264_START_CODE_NONE, }, .codec = CEDRUS_CODEC_H264, .required = false,
drivers/staging/media/sunxi/cedrus/cedrus_dec.c +6 -6
@@ -48,17 +48,17 @@ void cedrus_device_run(void *priv)case V4L2_PIX_FMT_H264_SLICE : run.h264.decode_params =cedrus_find_control_data (ctx, -V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS ); +V4L2_CID_STATELESS_H264_DECODE_PARAMS ); run.h264.pps =cedrus_find_control_data (ctx, -V4L2_CID_MPEG_VIDEO_H264_PPS ); +V4L2_CID_STATELESS_H264_PPS ); run.h264.scaling_matrix =cedrus_find_control_data (ctx, -V4L2_CID_MPEG_VIDEO_H264_SCALING_MATRIX ); +V4L2_CID_STATELESS_H264_SCALING_MATRIX ); run.h264.slice_params =cedrus_find_control_data (ctx, -V4L2_CID_MPEG_VIDEO_H264_SLICE_PARAMS ); +V4L2_CID_STATELESS_H264_SLICE_PARAMS ); run.h264.sps =cedrus_find_control_data (ctx, -V4L2_CID_MPEG_VIDEO_H264_SPS ); +V4L2_CID_STATELESS_H264_SPS ); run.h264.pred_weights =cedrus_find_control_data (ctx, -V4L2_CID_MPEG_VIDEO_H264_PRED_WEIGHTS ); +V4L2_CID_STATELESS_H264_PRED_WEIGHTS );break ;case V4L2_PIX_FMT_HEVC_SLICE :
include/media/v4l2-ctrls.h +0 -1
@@ -19,7 +19,6 @@*/ #include <media/mpeg2-ctrls.h> #include <media/fwht-ctrls.h> -#include <media/h264-ctrls.h> #include <media/vp8-ctrls.h> #include <media/hevc-ctrls.h>
include/uapi/linux/v4l2-controls.h +372 -0
378 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH v2 9/9 media: docs: Move the H264 stateless codec uAPI
In reply to Ezequiel GarciaNow that we've destaged the H264 stateless codec controls, and with all the pieces in place, update the documentation and move it to its own section.
--- .../userspace-api/media/v4l/common.rst | 1 + .../media/v4l/ext-ctrls-codec-stateless.rst | 674 +++++++++++++++++ .../media/v4l/ext-ctrls-codec.rst | 692 ------------------ .../media/v4l/pixfmt-compressed.rst | 14 +- 4 files changed, 682 insertions(+), 699 deletions(-) create mode 100644 Documentation/userspace-api/media/v4l/ext-ctrls-codec-stateless.rst
Documentation/userspace-api/media/v4l/common.rst +1 -0
@@ -44,6 +44,7 @@ applicable to all devices. ext-ctrls-image-source ext-ctrls-image-process ext-ctrls-codec + ext-ctrls-codec-stateless ext-ctrls-jpeg ext-ctrls-dv ext-ctrls-rf-tuner
Documentation/userspace-api/media/v4l/ext-ctrls-codec-stateless.rst new file +674 -0
674 lines not on this page · raw message
Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +0 -692
698 lines not on this page · raw message
Documentation/userspace-api/media/v4l/pixfmt-compressed.rst +7 -7
@@ -59,14 +59,14 @@ Compressed Formats This format is adapted for stateless video decoders that implement an H264 pipeline (using the :ref:`mem2mem` and :ref:`media-request-api`). This pixelformat has two modifiers that must be set at least once - through the ``V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE`` - and ``V4L2_CID_MPEG_VIDEO_H264_START_CODE`` controls. + through the ``V4L2_CID_STATELESS_H264_DECODE_MODE`` + and ``V4L2_CID_STATELESS_H264_START_CODE`` controls. In addition, metadata associated with the frame to decode are - required to be passed through the ``V4L2_CID_MPEG_VIDEO_H264_SPS``, - ``V4L2_CID_MPEG_VIDEO_H264_PPS``, - ``V4L2_CID_MPEG_VIDEO_H264_SCALING_MATRIX``, - ``V4L2_CID_MPEG_VIDEO_H264_SLICE_PARAMS`` and - ``V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS`` controls. See the + required to be passed through the ``V4L2_CID_STATELESS_H264_SPS``, + ``V4L2_CID_STATELESS_H264_PPS``, + ``V4L2_CID_STATELESS_H264_SCALING_MATRIX``, + ``V4L2_CID_STATELESS_H264_SLICE_PARAMS`` and + ``V4L2_CID_STATELESS_H264_DECODE_PARAMS`` controls. See the :ref:`associated Codec Control IDs <v4l2-mpeg-h264>`. Exactly one output and one capture buffer must be provided for use with this pixel format. The output buffer must contain the
Signature · 1 line
2.27.0
Re: [PATCH v2 9/9] media: docs: Move the H264 stateless codec uAPI
Quoted 13 lines · Ezequiel Garcia
Now that we've destaged the H264 stateless codec controls, and with all the pieces in place, update the documentation and move it to its own section.
Signed-off-by Ezequiel Garcia <[email protected]>--- .../userspace-api/media/v4l/common.rst | 1 + .../media/v4l/ext-ctrls-codec-stateless.rst | 674 +++++++++++++++++ .../media/v4l/ext-ctrls-codec.rst | 692 ------------------ .../media/v4l/pixfmt-compressed.rst | 14 +- 4 files changed, 682 insertions(+), 699 deletions(-) create mode 100644 Documentation/userspace-api/media/v4l/ext-ctrls-codec-stateless.rst
<snip>
Quoted 17 lines
Documentation/userspace-api/media/v4l/pixfmt-compressed.rst +2
-5@@ -59,14 +59,14 @@ Compressed Formats This format is adapted for stateless video decoders that implement an H264 pipeline (using the :ref:`mem2mem` and :ref:`media-request-api`). This pixelformat has two modifiers that must be set at least once - through the ``V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE`` - and ``V4L2_CID_MPEG_VIDEO_H264_START_CODE`` controls. + through the ``V4L2_CID_STATELESS_H264_DECODE_MODE`` + and ``V4L2_CID_STATELESS_H264_START_CODE`` controls. In addition, metadata associated with the frame to decode are - required to be passed through the ``V4L2_CID_MPEG_VIDEO_H264_SPS``, - ``V4L2_CID_MPEG_VIDEO_H264_PPS``, - ``V4L2_CID_MPEG_VIDEO_H264_SCALING_MATRIX``,
Documentation/userspace-api/media/v4l/pixfmt-compressed.rst Compressed Formats · line 72
Quoted 10 lines
Documentation/userspace-api/media/v4l/pixfmt-compressed.rst +5
-2- ``V4L2_CID_MPEG_VIDEO_H264_SLICE_PARAMS`` and - ``V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS`` controls. See the + required to be passed through the ``V4L2_CID_STATELESS_H264_SPS``, + ``V4L2_CID_STATELESS_H264_PPS``, + ``V4L2_CID_STATELESS_H264_SCALING_MATRIX``, + ``V4L2_CID_STATELESS_H264_SLICE_PARAMS`` and + ``V4L2_CID_STATELESS_H264_DECODE_PARAMS`` controls. See the :ref:`associated Codec Control IDs <v4l2-mpeg-h264>`. Exactly one output and one capture buffer must be provided for use with this pixel format. The output buffer must contain the
There is a note about this 'format not yet part of the public API' that needs to be deleted as well.
Regards,
Hans
Re: [PATCH v2 9/9] media: docs: Move the H264 stateless codec uAPI
Quoted 39 lines · Hans Verkuil
Quoted 13 lines · Ezequiel Garcia
Now that we've destaged the H264 stateless codec controls, and with all the pieces in place, update the documentation and move it to its own section.
Signed-off-by Ezequiel Garcia <[email protected]>--- .../userspace-api/media/v4l/common.rst | 1 + .../media/v4l/ext-ctrls-codec-stateless.rst | 674 +++++++++++++++++ .../media/v4l/ext-ctrls-codec.rst | 692 ------------------ .../media/v4l/pixfmt-compressed.rst | 14 +- 4 files changed, 682 insertions(+), 699 deletions(-) create mode 100644 Documentation/userspace-api/media/v4l/ext-ctrls-codec-stateless.rst<snip>
Quoted 22 lines
Documentation/userspace-api/media/v4l/pixfmt-compressed.rst +6
-7@@ -59,14 +59,14 @@ Compressed Formats This format is adapted for stateless video decoders that implement an H264 pipeline (using the :ref:`mem2mem` and :ref:`media-request-api`). This pixelformat has two modifiers that must be set at least once - through the ``V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE`` - and ``V4L2_CID_MPEG_VIDEO_H264_START_CODE`` controls. + through the ``V4L2_CID_STATELESS_H264_DECODE_MODE`` + and ``V4L2_CID_STATELESS_H264_START_CODE`` controls. In addition, metadata associated with the frame to decode are - required to be passed through the ``V4L2_CID_MPEG_VIDEO_H264_SPS``, - ``V4L2_CID_MPEG_VIDEO_H264_PPS``, - ``V4L2_CID_MPEG_VIDEO_H264_SCALING_MATRIX``, - ``V4L2_CID_MPEG_VIDEO_H264_SLICE_PARAMS`` and - ``V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS`` controls. See the + required to be passed through the ``V4L2_CID_STATELESS_H264_SPS``, + ``V4L2_CID_STATELESS_H264_PPS``, + ``V4L2_CID_STATELESS_H264_SCALING_MATRIX``, + ``V4L2_CID_STATELESS_H264_SLICE_PARAMS`` and
Quoted 9 lines
Documentation/userspace-api/media/v4l/pixfmt-compressed.rst Compressed Formats · line 72
Quoted 5 lines
Documentation/userspace-api/media/v4l/pixfmt-compressed.rst +1
-0+ ``V4L2_CID_STATELESS_H264_DECODE_PARAMS`` controls. See the :ref:`associated Codec Control IDs <v4l2-mpeg-h264>`. Exactly one output and one capture buffer must be provided for use with this pixel format. The output buffer must contain theThere is a note about this 'format not yet part of the public API' that needs to be deleted as well.
Good catch.
Thanks,
Eze
Quoted 3 lines
Quoted 15 lines · Ezequiel Garcia
Now that H.264 stateless controls are solid, we can get it out of staging.
Following some guidelines from Hans, this series creates a new stateless control class for the stable codec controls to land.
While here, I'm including a patch from Jonas adding profiles and levels to Rkvdec, and also made a similar fix for Cedrus.
This series was tested on a i.MX8MQ EVK board, using GStreamer:
https://gitlab.freedesktop.org/ezequielgarcia/gst-plugins-bad/-/commits/h264_stable_uapi
In case someone wants to give this a test.
Quoted 7 lines
Note that v4l2-compliance isn't passing, as the Hantro driver doesn't set legal default values for the H264 SPS, PPS, etc controls.
That's something we should fix, although it's since it's just meant to please v4l2-compliance, we could also argue that these controls shouldn't be expected to have any default value.
This really needs to be fixed. I've ignored this issue since the API was in staging and still changing, but when we move it out of staging, then this issue should be tackled.
It should likely be done in std_init_compound() in v4l2-ctrls.c.
It is probably a good idea to also verify std_validate_compound(), making sure that everything there is still valid and up to date.
And std_log() should be taught about these new controls. For compound controls I would just log the type name, e.g. "H264_SPS" and not the values of these compound controls.
Regards,
Hans
Quoted 53 lines
Thanks,
Ezequielv2:
* Split destage changes in several patches so it's easier to review.
* Added missing changes todrivers/media/v4l2-core/v4l2-ctrls.c.
* RenamedV4L2_CID_CODEC_CX2341X_andV4L2_CID_MPEG_MFC51_
* Moved the compatibility macros for MPEG to the end of the header.Ezequiel Garcia (8):
media: cedrus: h264: Support profile and level controls
media: Rename stateful codec control macros
media: Clean stateless control includes
media: controls: Add the stateless codec control class
media: uapi: Move parsed H264 pixel format out of staging
media: uapi: Move the H264 stateless control types out of staging
media: uapi: move H264 stateless controls out of staging
media: docs: Move the H264 stateless codec uAPIJonas Karlman (1):
media: rkvdec: h264: Support profile and level controls.../userspace-api/media/v4l/common.rst | 1 + .../userspace-api/media/v4l/dev-mem2mem.rst | 2 +- .../media/v4l/ext-ctrls-codec-stateless.rst | 674 +++++++++++++++ .../media/v4l/ext-ctrls-codec.rst | 696 +--------------- .../media/v4l/extended-controls.rst | 8 +- .../media/v4l/pixfmt-compressed.rst | 14 +- .../media/v4l/vidioc-g-ext-ctrls.rst | 6 +- drivers/media/common/cx2341x.c | 4 +- drivers/media/platform/s5p-mfc/s5p_mfc_dec.c | 2 +- drivers/media/platform/s5p-mfc/s5p_mfc_enc.c | 2 +- drivers/media/v4l2-core/v4l2-ctrls.c | 45 +- drivers/staging/media/hantro/hantro_drv.c | 26 +- drivers/staging/media/hantro/hantro_h264.c | 8 +- drivers/staging/media/hantro/hantro_hw.h | 4 +- drivers/staging/media/rkvdec/rkvdec-h264.c | 8 +- drivers/staging/media/rkvdec/rkvdec.c | 39 +- drivers/staging/media/sunxi/cedrus/cedrus.c | 45 +- .../staging/media/sunxi/cedrus/cedrus_dec.c | 12 +- include/media/fwht-ctrls.h | 2 +- include/media/h264-ctrls.h | 27 +- include/media/hevc-ctrls.h | 10 +- include/media/mpeg2-ctrls.h | 4 +- include/media/v4l2-ctrls.h | 1 - include/media/v4l2-h264.h | 2 +- include/media/vp8-ctrls.h | 2 +- include/uapi/linux/v4l2-controls.h | 788 +++++++++++++----- include/uapi/linux/videodev2.h | 8 + 27 files changed, 1422 insertions(+), 1018 deletions(-) create mode 100644 Documentation/userspace-api/media/v4l/ext-ctrls-codec-stateless.rst
Hi Hans,
Thanks for the quick review.
Quoted 16 lines · Hans Verkuil
Quoted 15 lines · Ezequiel Garcia
Now that H.264 stateless controls are solid, we can get it out of staging.
Following some guidelines from Hans, this series creates a new stateless control class for the stable codec controls to land.
While here, I'm including a patch from Jonas adding profiles and levels to Rkvdec, and also made a similar fix for Cedrus.
This series was tested on a i.MX8MQ EVK board, using GStreamer:
https://gitlab.freedesktop.org/ezequielgarcia/gst-plugins-bad/-/commits/h264_stable_uapi
In case someone wants to give this a test.
Quoted 8 lines
Quoted 7 lines
Note that v4l2-compliance isn't passing, as the Hantro driver doesn't set legal default values for the H264 SPS, PPS, etc controls.
That's something we should fix, although it's since it's just meant to please v4l2-compliance, we could also argue that these controls shouldn't be expected to have any default value.
Looking into more detail, v4l2-compliance was failing due to checks in std_validate_compound for VP8 controls.
H264 controls are not currently validated (but sounds like we'll want to, from below discussion).
Quoted 4 lines
This really needs to be fixed. I've ignored this issue since the API was in staging and still changing, but when we move it out of staging, then this issue should be tackled.
Sure.
Quoted 2 lines
It should likely be done in
std_init_compound()inv4l2-ctrls.c.
Yes, MPEG2 controls are already initialized over there.
Quoted 4 lines
It is probably a good idea to also verify
std_validate_compound(), making sure that everything there is still valid and up to date.
Indeed. I'm actually more concerned about std_validate_compound, which should do some parameter sanitization. Thanks for catching this.
Quoted 4 lines
And
std_log()should be taught about these new controls. For compound controls I would just log the type name, e.g. "H264_SPS" and not the values of these compound controls.
I guess this makes some sense, if only for consistency.
Is there any other reason to have this? The codec drivers are not implementing VIDIOC_LOG_STATUS. If we were to use v4l2_ctrl_log_status, we'd only get something like this:
v4l2-ctrls: hantro-vpu 38300000.video-codec: H264 Sequence Parameter Set: H264_SPS
v4l2-ctrls: hantro-vpu 38300000.video-codec: H264 Picture Parameter Set: H264_PPS
...
v4l2-ctrls: hantro-vpu 38300000.video-codec: H264 Decode Mode: Frame-Based
v4l2-ctrls: hantro-vpu 38300000.video-codec: H264 Start Code: Annex B Start Code
v4l2-ctrls: hantro-vpu 38300000.video-codec: H264 Profile: Main
Also...
Another thing I missed is here is driver destaging. I would really want to start getting the drivers out of staging as well. Can we have some VIDEO_V4L2_UNSTABLE_STATELESS option in media/staging, so we can use that in drivers?
This way, we would not offer the staging controls and pixel formats unless the user explicitly enables that option.
The core could also print a warning when the option is enabled, and controls are first created.
So we'd move cedrus, hantro and rkvdec out of staging on this series as well, supporting H264 only, by default.
Thanks!
Ezequiel
Quoted 56 lines
Regards,
Hans
Quoted 52 lines
Thanks,
Ezequielv2:
* Split destage changes in several patches so it's easier to review.
* Added missing changes todrivers/media/v4l2-core/v4l2-ctrls.c.
* RenamedV4L2_CID_CODEC_CX2341X_andV4L2_CID_MPEG_MFC51_
* Moved the compatibility macros for MPEG to the end of the header.Ezequiel Garcia (8):
media: cedrus: h264: Support profile and level controls
media: Rename stateful codec control macros
media: Clean stateless control includes
media: controls: Add the stateless codec control class
media: uapi: Move parsed H264 pixel format out of staging
media: uapi: Move the H264 stateless control types out of staging
media: uapi: move H264 stateless controls out of staging
media: docs: Move the H264 stateless codec uAPIJonas Karlman (1):
media: rkvdec: h264: Support profile and level controls.../userspace-api/media/v4l/common.rst | 1 + .../userspace-api/media/v4l/dev-mem2mem.rst | 2 +- .../media/v4l/ext-ctrls-codec-stateless.rst | 674 +++++++++++++++ .../media/v4l/ext-ctrls-codec.rst | 696 +--------------- .../media/v4l/extended-controls.rst | 8 +- .../media/v4l/pixfmt-compressed.rst | 14 +- .../media/v4l/vidioc-g-ext-ctrls.rst | 6 +- drivers/media/common/cx2341x.c | 4 +- drivers/media/platform/s5p-mfc/s5p_mfc_dec.c | 2 +- drivers/media/platform/s5p-mfc/s5p_mfc_enc.c | 2 +- drivers/media/v4l2-core/v4l2-ctrls.c | 45 +- drivers/staging/media/hantro/hantro_drv.c | 26 +- drivers/staging/media/hantro/hantro_h264.c | 8 +- drivers/staging/media/hantro/hantro_hw.h | 4 +- drivers/staging/media/rkvdec/rkvdec-h264.c | 8 +- drivers/staging/media/rkvdec/rkvdec.c | 39 +- drivers/staging/media/sunxi/cedrus/cedrus.c | 45 +- .../staging/media/sunxi/cedrus/cedrus_dec.c | 12 +- include/media/fwht-ctrls.h | 2 +- include/media/h264-ctrls.h | 27 +- include/media/hevc-ctrls.h | 10 +- include/media/mpeg2-ctrls.h | 4 +- include/media/v4l2-ctrls.h | 1 - include/media/v4l2-h264.h | 2 +- include/media/vp8-ctrls.h | 2 +- include/uapi/linux/v4l2-controls.h | 788 +++++++++++++----- include/uapi/linux/videodev2.h | 8 + 27 files changed, 1422 insertions(+), 1018 deletions(-) create mode 100644 Documentation/userspace-api/media/v4l/ext-ctrls-codec-stateless.rst