2020-09-21 13:05:59

by Dikshita Agarwal

[permalink] [raw]
Subject: [PATCH v2 0/2] Add new controls for QP and layer bitrate

This series adds frame specific min/max qp controls for hevc and layer
wise bitrate control for h264.

Chnage since v1:
corrected email.

Dikshita Agarwal (2):
media: v4l2-ctrl: Add frame-specific min/max qp controls for hevc
media: v4l2-ctrl: Add layer wise bitrate controls for h264

.../userspace-api/media/v4l/ext-ctrls-codec.rst | 74 +++++++++++++++++++++-
drivers/media/v4l2-core/v4l2-ctrls.c | 15 +++++
include/uapi/linux/v4l2-controls.h | 17 +++++
3 files changed, 104 insertions(+), 2 deletions(-)

--
1.9.1


2020-09-21 13:06:43

by Dikshita Agarwal

[permalink] [raw]
Subject: [PATCH v2 1/2] media: v4l2-ctrl: Add frame-specific min/max qp controls for hevc

- Adds min/max qp controls for B frame for h264.
- Adds min/max qp controls for I/P/B frames for hevc similar to h264.
- Update valid range of mim/max qp for hevc to accommodate 10 bit.

Signed-off-by: Dikshita Agarwal <[email protected]>
---
.../userspace-api/media/v4l/ext-ctrls-codec.rst | 54 +++++++++++++++++++++-
drivers/media/v4l2-core/v4l2-ctrls.c | 8 ++++
include/uapi/linux/v4l2-controls.h | 9 ++++
3 files changed, 69 insertions(+), 2 deletions(-)

diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
index ce728c75..26f8220 100644
--- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
+++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
@@ -1182,6 +1182,18 @@ enum v4l2_mpeg_video_h264_entropy_mode -
V4L2_CID_MPEG_VIDEO_H264_MAX_QP is also set, the quantization parameter
should be chosen to meet both requirements.

+``V4L2_CID_MPEG_VIDEO_H264_B_FRAME_MIN_QP (integer)``
+ Minimum quantization parameter for the H264 B frame to limit B frame
+ quality to a range. Valid range: from 0 to 51. If
+ V4L2_CID_MPEG_VIDEO_H264_MIN_QP is also set, the quantization parameter
+ should be chosen to meet both requirements.
+
+``V4L2_CID_MPEG_VIDEO_H264_B_FRAME_MAX_QP (integer)``
+ Maximum quantization parameter for the H264 B frame to limit B frame
+ quality to a range. Valid range: from 0 to 51. If
+ V4L2_CID_MPEG_VIDEO_H264_MAX_QP is also set, the quantization parameter
+ should be chosen to meet both requirements.
+
``V4L2_CID_MPEG_VIDEO_MPEG4_I_FRAME_QP (integer)``
Quantization parameter for an I frame for MPEG4. Valid range: from 1
to 31.
@@ -3441,11 +3453,13 @@ HEVC/H.265 Control IDs

``V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP (integer)``
Minimum quantization parameter for HEVC.
- Valid range: from 0 to 51.
+ Valid range: from 0 - 51 for 8 bit and
+ 0 - 63 for 10 bit.

``V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP (integer)``
Maximum quantization parameter for HEVC.
- Valid range: from 0 to 51.
+ Valid range: from 0 - 51 for 8 bit and
+ 0 - 63 for 10 bit

``V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_QP (integer)``
Quantization parameter for an I frame for HEVC.
@@ -3462,6 +3476,42 @@ HEVC/H.265 Control IDs
Valid range: [V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP,
V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP].

+``V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_MIN_QP (integer)``
+ Minimum quantization parameter for the HEVC I frame to limit I frame
+ quality to a range. Valid range: from 0 to 51 for 8 bit, 0 - 63 for 10 bit.
+ If V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP is also set, the quantization parameter
+ should be chosen to meet both requirements.
+
+``V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_MAX_QP (integer)``
+ Maximum quantization parameter for the HEVC I frame to limit I frame
+ quality to a range. Valid range: from 0 to 51 for 8 bit, 0 - 63 for 10 bit.
+ If V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP is also set, the quantization parameter
+ should be chosen to meet both requirements.
+
+``V4L2_CID_MPEG_VIDEO_HEVC_P_FRAME_MIN_QP (integer)``
+ Minimum quantization parameter for the HEVC P frame to limit P frame
+ quality to a range. Valid range: from 0 to 51 for 8 bit, 0 - 63 for 10 bit.
+ If V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP is also set, the quantization parameter
+ should be chosen to meet both requirements.
+
+``V4L2_CID_MPEG_VIDEO_HEVC_P_FRAME_MAX_QP (integer)``
+ Maximum quantization parameter for the HEVC P frame to limit P frame
+ quality to a range. Valid range: from 0 to 51 for 8 bit, 0 - 63 for 10 bit.
+ If V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP is also set, the quantization parameter
+ should be chosen to meet both requirements.
+
+``V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_MIN_QP (integer)``
+ Minimum quantization parameter for the HEVC B frame to limit B frame
+ quality to a range. Valid range: from 0 to 51 for 8 bit, 0 - 63 for 10 bit.
+ If V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP is also set, the quantization parameter
+ should be chosen to meet both requirements.
+
+``V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_MAX_QP (integer)``
+ Maximum quantization parameter for the HEVC B frame to limit B frame
+ quality to a range. Valid range: from 0 to 51 for 8 bit, 0 - 63 for 10 bit.
+ If V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP is also set, the quantization parameter
+ should be chosen to meet both requirements.
+
``V4L2_CID_MPEG_VIDEO_HEVC_HIER_QP (boolean)``
HIERARCHICAL_QP allows the host to specify the quantization parameter
values for each temporal layer through HIERARCHICAL_QP_LAYER. This is
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
index bd7f330..abef73e 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -920,6 +920,8 @@ 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_B_FRAME_MIN_QP: return "H264 B-Frame Minimum QP Value";
+ case V4L2_CID_MPEG_VIDEO_H264_B_FRAME_MAX_QP: return "H264 B-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";
@@ -978,6 +980,12 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_QP: return "HEVC B-Frame QP Value";
case V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP: return "HEVC Minimum QP Value";
case V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP: return "HEVC Maximum QP Value";
+ case V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_MIN_QP: return "HEVC I-Frame Minimum QP Value";
+ case V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_MAX_QP: return "HEVC I-Frame Maximum QP Value";
+ case V4L2_CID_MPEG_VIDEO_HEVC_P_FRAME_MIN_QP: return "HEVC P-Frame Minimum QP Value";
+ case V4L2_CID_MPEG_VIDEO_HEVC_P_FRAME_MAX_QP: return "HEVC P-Frame Maximum QP Value";
+ case V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_MIN_QP: return "HEVC B-Frame Minimum QP Value";
+ case V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_MAX_QP: return "HEVC B-Frame Maximum QP Value";
case V4L2_CID_MPEG_VIDEO_HEVC_PROFILE: return "HEVC Profile";
case V4L2_CID_MPEG_VIDEO_HEVC_LEVEL: return "HEVC Level";
case V4L2_CID_MPEG_VIDEO_HEVC_TIER: return "HEVC Tier";
diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
index a184c49..7ba05fe 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -578,6 +578,8 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type {
#define V4L2_CID_MPEG_VIDEO_H264_I_FRAME_MAX_QP (V4L2_CID_MPEG_BASE+386)
#define V4L2_CID_MPEG_VIDEO_H264_P_FRAME_MIN_QP (V4L2_CID_MPEG_BASE+387)
#define V4L2_CID_MPEG_VIDEO_H264_P_FRAME_MAX_QP (V4L2_CID_MPEG_BASE+388)
+#define V4L2_CID_MPEG_VIDEO_H264_B_FRAME_MIN_QP (V4L2_CID_MPEG_BASE+389)
+#define V4L2_CID_MPEG_VIDEO_H264_B_FRAME_MAX_QP (V4L2_CID_MPEG_BASE+390)
#define V4L2_CID_MPEG_VIDEO_MPEG4_I_FRAME_QP (V4L2_CID_MPEG_BASE+400)
#define V4L2_CID_MPEG_VIDEO_MPEG4_P_FRAME_QP (V4L2_CID_MPEG_BASE+401)
#define V4L2_CID_MPEG_VIDEO_MPEG4_B_FRAME_QP (V4L2_CID_MPEG_BASE+402)
@@ -762,6 +764,13 @@ enum v4l2_cid_mpeg_video_hevc_size_of_length_field {
#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_FRAME_SKIP_MODE (V4L2_CID_MPEG_BASE + 646)
+#define V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_MIN_QP (V4L2_CID_MPEG_BASE+647)
+#define V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_MAX_QP (V4L2_CID_MPEG_BASE+648)
+#define V4L2_CID_MPEG_VIDEO_HEVC_P_FRAME_MIN_QP (V4L2_CID_MPEG_BASE+649)
+#define V4L2_CID_MPEG_VIDEO_HEVC_P_FRAME_MAX_QP (V4L2_CID_MPEG_BASE+650)
+#define V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_MIN_QP (V4L2_CID_MPEG_BASE+651)
+#define V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_MAX_QP (V4L2_CID_MPEG_BASE+652)
+
enum v4l2_mpeg_video_frame_skip_mode {
V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_DISABLED = 0,
V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_LEVEL_LIMIT = 1,
--
1.9.1

2020-09-21 13:07:20

by Dikshita Agarwal

[permalink] [raw]
Subject: [PATCH v2 2/2] media: v4l2-ctrl: Add layer wise bitrate controls for h264

Adds bitrate control for all coding layers for h264
same as hevc.

Signed-off-by: Dikshita Agarwal <[email protected]>
---
.../userspace-api/media/v4l/ext-ctrls-codec.rst | 20 ++++++++++++++++++++
drivers/media/v4l2-core/v4l2-ctrls.c | 7 +++++++
include/uapi/linux/v4l2-controls.h | 8 ++++++++
3 files changed, 35 insertions(+)

diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
index 26f8220..690b066 100644
--- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
+++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
@@ -1513,6 +1513,26 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type -
* - Bit 16:32
- Layer number

+``V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L0_BR (integer)``
+ Indicates bit rate for hierarchical coding layer 0 for H264 encoder.
+
+``V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L1_BR (integer)``
+ Indicates bit rate for hierarchical coding layer 1 for H264 encoder.
+
+``V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L2_BR (integer)``
+ Indicates bit rate for hierarchical coding layer 2 for H264 encoder.
+
+``V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L3_BR (integer)``
+ Indicates bit rate for hierarchical coding layer 3 for H264 encoder.
+
+``V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L4_BR (integer)``
+ Indicates bit rate for hierarchical coding layer 4 for H264 encoder.
+
+``V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L5_BR (integer)``
+ Indicates bit rate for hierarchical coding layer 5 for H264 encoder.
+
+``V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L6_BR (integer)``
+ Indicates bit rate for hierarchical coding layer 6 for H264 encoder.

.. _v4l2-mpeg-h264:

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
index abef73e..9296294 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -922,6 +922,13 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_MPEG_VIDEO_H264_P_FRAME_MAX_QP: return "H264 P-Frame Maximum QP Value";
case V4L2_CID_MPEG_VIDEO_H264_B_FRAME_MIN_QP: return "H264 B-Frame Minimum QP Value";
case V4L2_CID_MPEG_VIDEO_H264_B_FRAME_MAX_QP: return "H264 B-Frame Maximum QP Value";
+ case V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L0_BR: return "H264 Hierarchical Lay 0 BitRate";
+ case V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L1_BR: return "H264 Hierarchical Lay 1 BitRate";
+ case V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L2_BR: return "H264 Hierarchical Lay 2 BitRate";
+ case V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L3_BR: return "H264 Hierarchical Lay 3 BitRate";
+ case V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L4_BR: return "H264 Hierarchical Lay 4 BitRate";
+ case V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L5_BR: return "H264 Hierarchical Lay 5 BitRate";
+ case V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L6_BR: return "H264 Hierarchical Lay 6 BitRate";
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";
diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
index 7ba05fe..b869b54 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -580,12 +580,20 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type {
#define V4L2_CID_MPEG_VIDEO_H264_P_FRAME_MAX_QP (V4L2_CID_MPEG_BASE+388)
#define V4L2_CID_MPEG_VIDEO_H264_B_FRAME_MIN_QP (V4L2_CID_MPEG_BASE+389)
#define V4L2_CID_MPEG_VIDEO_H264_B_FRAME_MAX_QP (V4L2_CID_MPEG_BASE+390)
+#define V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L0_BR (V4L2_CID_MPEG_BASE + 391)
+#define V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L1_BR (V4L2_CID_MPEG_BASE + 392)
+#define V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L2_BR (V4L2_CID_MPEG_BASE + 393)
+#define V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L3_BR (V4L2_CID_MPEG_BASE + 394)
+#define V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L4_BR (V4L2_CID_MPEG_BASE + 395)
+#define V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L5_BR (V4L2_CID_MPEG_BASE + 396)
+#define V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L6_BR (V4L2_CID_MPEG_BASE + 397)
#define V4L2_CID_MPEG_VIDEO_MPEG4_I_FRAME_QP (V4L2_CID_MPEG_BASE+400)
#define V4L2_CID_MPEG_VIDEO_MPEG4_P_FRAME_QP (V4L2_CID_MPEG_BASE+401)
#define V4L2_CID_MPEG_VIDEO_MPEG4_B_FRAME_QP (V4L2_CID_MPEG_BASE+402)
#define V4L2_CID_MPEG_VIDEO_MPEG4_MIN_QP (V4L2_CID_MPEG_BASE+403)
#define V4L2_CID_MPEG_VIDEO_MPEG4_MAX_QP (V4L2_CID_MPEG_BASE+404)
#define V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL (V4L2_CID_MPEG_BASE+405)
+
enum v4l2_mpeg_video_mpeg4_level {
V4L2_MPEG_VIDEO_MPEG4_LEVEL_0 = 0,
V4L2_MPEG_VIDEO_MPEG4_LEVEL_0B = 1,
--
1.9.1

2020-09-24 17:43:49

by Nicolas Dufresne

[permalink] [raw]
Subject: Re: [PATCH v2 0/2] Add new controls for QP and layer bitrate

Le lundi 21 septembre 2020 à 18:33 +0530, Dikshita Agarwal a écrit :
> This series adds frame specific min/max qp controls for hevc and layer
> wise bitrate control for h264.

Any chance you could append your driver changes with this set ? I don't
think new APIs ever make it without a driver using it.

>
> Chnage since v1:
> corrected email.
>
> Dikshita Agarwal (2):
> media: v4l2-ctrl: Add frame-specific min/max qp controls for hevc
> media: v4l2-ctrl: Add layer wise bitrate controls for h264
>
> .../userspace-api/media/v4l/ext-ctrls-codec.rst | 74 +++++++++++++++++++++-
> drivers/media/v4l2-core/v4l2-ctrls.c | 15 +++++
> include/uapi/linux/v4l2-controls.h | 17 +++++
> 3 files changed, 104 insertions(+), 2 deletions(-)
>

2020-11-11 11:51:17

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH v2 0/2] Add new controls for QP and layer bitrate

On 24/09/2020 19:42, Nicolas Dufresne wrote:
> Le lundi 21 septembre 2020 à 18:33 +0530, Dikshita Agarwal a écrit :
>> This series adds frame specific min/max qp controls for hevc and layer
>> wise bitrate control for h264.
>
> Any chance you could append your driver changes with this set ? I don't
> think new APIs ever make it without a driver using it.

Indeed. I'll mark this as 'Changes Requested' in patchwork: I do need a
version that actually uses these new controls in a driver.

Regards,

Hans

>
>>
>> Chnage since v1:
>> corrected email.
>>
>> Dikshita Agarwal (2):
>> media: v4l2-ctrl: Add frame-specific min/max qp controls for hevc
>> media: v4l2-ctrl: Add layer wise bitrate controls for h264
>>
>> .../userspace-api/media/v4l/ext-ctrls-codec.rst | 74 +++++++++++++++++++++-
>> drivers/media/v4l2-core/v4l2-ctrls.c | 15 +++++
>> include/uapi/linux/v4l2-controls.h | 17 +++++
>> 3 files changed, 104 insertions(+), 2 deletions(-)
>>
>

2020-11-11 11:59:35

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] media: v4l2-ctrl: Add layer wise bitrate controls for h264

On 21/09/2020 15:04, Dikshita Agarwal wrote:
> Adds bitrate control for all coding layers for h264
> same as hevc.
>
> Signed-off-by: Dikshita Agarwal <[email protected]>
> ---
> .../userspace-api/media/v4l/ext-ctrls-codec.rst | 20 ++++++++++++++++++++
> drivers/media/v4l2-core/v4l2-ctrls.c | 7 +++++++
> include/uapi/linux/v4l2-controls.h | 8 ++++++++
> 3 files changed, 35 insertions(+)
>
> diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
> index 26f8220..690b066 100644
> --- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
> +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
> @@ -1513,6 +1513,26 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type -
> * - Bit 16:32
> - Layer number
>
> +``V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L0_BR (integer)``
> + Indicates bit rate for hierarchical coding layer 0 for H264 encoder.
> +
> +``V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L1_BR (integer)``
> + Indicates bit rate for hierarchical coding layer 1 for H264 encoder.
> +
> +``V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L2_BR (integer)``
> + Indicates bit rate for hierarchical coding layer 2 for H264 encoder.
> +
> +``V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L3_BR (integer)``
> + Indicates bit rate for hierarchical coding layer 3 for H264 encoder.
> +
> +``V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L4_BR (integer)``
> + Indicates bit rate for hierarchical coding layer 4 for H264 encoder.
> +
> +``V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L5_BR (integer)``
> + Indicates bit rate for hierarchical coding layer 5 for H264 encoder.
> +
> +``V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L6_BR (integer)``
> + Indicates bit rate for hierarchical coding layer 6 for H264 encoder.

The unit isn't specified here. I assume it is bits per second, but that should
be stated explicitly.

>
> .. _v4l2-mpeg-h264:
>
> diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
> index abef73e..9296294 100644
> --- a/drivers/media/v4l2-core/v4l2-ctrls.c
> +++ b/drivers/media/v4l2-core/v4l2-ctrls.c
> @@ -922,6 +922,13 @@ const char *v4l2_ctrl_get_name(u32 id)
> case V4L2_CID_MPEG_VIDEO_H264_P_FRAME_MAX_QP: return "H264 P-Frame Maximum QP Value";
> case V4L2_CID_MPEG_VIDEO_H264_B_FRAME_MIN_QP: return "H264 B-Frame Minimum QP Value";
> case V4L2_CID_MPEG_VIDEO_H264_B_FRAME_MAX_QP: return "H264 B-Frame Maximum QP Value";
> + case V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L0_BR: return "H264 Hierarchical Lay 0 BitRate";
> + case V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L1_BR: return "H264 Hierarchical Lay 1 BitRate";
> + case V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L2_BR: return "H264 Hierarchical Lay 2 BitRate";
> + case V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L3_BR: return "H264 Hierarchical Lay 3 BitRate";
> + case V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L4_BR: return "H264 Hierarchical Lay 4 BitRate";
> + case V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L5_BR: return "H264 Hierarchical Lay 5 BitRate";
> + case V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L6_BR: return "H264 Hierarchical Lay 6 BitRate";

BitRate -> Bitrate

> 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";
> diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
> index 7ba05fe..b869b54 100644
> --- a/include/uapi/linux/v4l2-controls.h
> +++ b/include/uapi/linux/v4l2-controls.h
> @@ -580,12 +580,20 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type {
> #define V4L2_CID_MPEG_VIDEO_H264_P_FRAME_MAX_QP (V4L2_CID_MPEG_BASE+388)
> #define V4L2_CID_MPEG_VIDEO_H264_B_FRAME_MIN_QP (V4L2_CID_MPEG_BASE+389)
> #define V4L2_CID_MPEG_VIDEO_H264_B_FRAME_MAX_QP (V4L2_CID_MPEG_BASE+390)
> +#define V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L0_BR (V4L2_CID_MPEG_BASE + 391)
> +#define V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L1_BR (V4L2_CID_MPEG_BASE + 392)
> +#define V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L2_BR (V4L2_CID_MPEG_BASE + 393)
> +#define V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L3_BR (V4L2_CID_MPEG_BASE + 394)
> +#define V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L4_BR (V4L2_CID_MPEG_BASE + 395)
> +#define V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L5_BR (V4L2_CID_MPEG_BASE + 396)
> +#define V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L6_BR (V4L2_CID_MPEG_BASE + 397)
> #define V4L2_CID_MPEG_VIDEO_MPEG4_I_FRAME_QP (V4L2_CID_MPEG_BASE+400)
> #define V4L2_CID_MPEG_VIDEO_MPEG4_P_FRAME_QP (V4L2_CID_MPEG_BASE+401)
> #define V4L2_CID_MPEG_VIDEO_MPEG4_B_FRAME_QP (V4L2_CID_MPEG_BASE+402)
> #define V4L2_CID_MPEG_VIDEO_MPEG4_MIN_QP (V4L2_CID_MPEG_BASE+403)
> #define V4L2_CID_MPEG_VIDEO_MPEG4_MAX_QP (V4L2_CID_MPEG_BASE+404)
> #define V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL (V4L2_CID_MPEG_BASE+405)
> +
> enum v4l2_mpeg_video_mpeg4_level {
> V4L2_MPEG_VIDEO_MPEG4_LEVEL_0 = 0,
> V4L2_MPEG_VIDEO_MPEG4_LEVEL_0B = 1,
>

Regards,

Hans

2020-11-11 12:03:17

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] media: v4l2-ctrl: Add frame-specific min/max qp controls for hevc

On 21/09/2020 15:03, Dikshita Agarwal wrote:
> - Adds min/max qp controls for B frame for h264.
> - Adds min/max qp controls for I/P/B frames for hevc similar to h264.
> - Update valid range of mim/max qp for hevc to accommodate 10 bit.
>
> Signed-off-by: Dikshita Agarwal <[email protected]>
> ---
> .../userspace-api/media/v4l/ext-ctrls-codec.rst | 54 +++++++++++++++++++++-
> drivers/media/v4l2-core/v4l2-ctrls.c | 8 ++++
> include/uapi/linux/v4l2-controls.h | 9 ++++
> 3 files changed, 69 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
> index ce728c75..26f8220 100644
> --- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
> +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
> @@ -1182,6 +1182,18 @@ enum v4l2_mpeg_video_h264_entropy_mode -
> V4L2_CID_MPEG_VIDEO_H264_MAX_QP is also set, the quantization parameter
> should be chosen to meet both requirements.
>
> +``V4L2_CID_MPEG_VIDEO_H264_B_FRAME_MIN_QP (integer)``
> + Minimum quantization parameter for the H264 B frame to limit B frame
> + quality to a range. Valid range: from 0 to 51. If
> + V4L2_CID_MPEG_VIDEO_H264_MIN_QP is also set, the quantization parameter
> + should be chosen to meet both requirements.
> +
> +``V4L2_CID_MPEG_VIDEO_H264_B_FRAME_MAX_QP (integer)``
> + Maximum quantization parameter for the H264 B frame to limit B frame
> + quality to a range. Valid range: from 0 to 51. If
> + V4L2_CID_MPEG_VIDEO_H264_MAX_QP is also set, the quantization parameter
> + should be chosen to meet both requirements.
> +
> ``V4L2_CID_MPEG_VIDEO_MPEG4_I_FRAME_QP (integer)``
> Quantization parameter for an I frame for MPEG4. Valid range: from 1
> to 31.
> @@ -3441,11 +3453,13 @@ HEVC/H.265 Control IDs
>
> ``V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP (integer)``
> Minimum quantization parameter for HEVC.
> - Valid range: from 0 to 51.
> + Valid range: from 0 - 51 for 8 bit and
> + 0 - 63 for 10 bit.

This can be on one line.

>
> ``V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP (integer)``
> Maximum quantization parameter for HEVC.
> - Valid range: from 0 to 51.
> + Valid range: from 0 - 51 for 8 bit and
> + 0 - 63 for 10 bit

Same here, but this is also missing a period at the end.

>
> ``V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_QP (integer)``
> Quantization parameter for an I frame for HEVC.
> @@ -3462,6 +3476,42 @@ HEVC/H.265 Control IDs
> Valid range: [V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP,
> V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP].
>
> +``V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_MIN_QP (integer)``
> + Minimum quantization parameter for the HEVC I frame to limit I frame
> + quality to a range. Valid range: from 0 to 51 for 8 bit, 0 - 63 for 10 bit.
> + If V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP is also set, the quantization parameter
> + should be chosen to meet both requirements.
> +
> +``V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_MAX_QP (integer)``
> + Maximum quantization parameter for the HEVC I frame to limit I frame
> + quality to a range. Valid range: from 0 to 51 for 8 bit, 0 - 63 for 10 bit.
> + If V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP is also set, the quantization parameter
> + should be chosen to meet both requirements.
> +
> +``V4L2_CID_MPEG_VIDEO_HEVC_P_FRAME_MIN_QP (integer)``
> + Minimum quantization parameter for the HEVC P frame to limit P frame
> + quality to a range. Valid range: from 0 to 51 for 8 bit, 0 - 63 for 10 bit.
> + If V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP is also set, the quantization parameter
> + should be chosen to meet both requirements.
> +
> +``V4L2_CID_MPEG_VIDEO_HEVC_P_FRAME_MAX_QP (integer)``
> + Maximum quantization parameter for the HEVC P frame to limit P frame
> + quality to a range. Valid range: from 0 to 51 for 8 bit, 0 - 63 for 10 bit.
> + If V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP is also set, the quantization parameter
> + should be chosen to meet both requirements.
> +
> +``V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_MIN_QP (integer)``
> + Minimum quantization parameter for the HEVC B frame to limit B frame
> + quality to a range. Valid range: from 0 to 51 for 8 bit, 0 - 63 for 10 bit.
> + If V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP is also set, the quantization parameter
> + should be chosen to meet both requirements.
> +
> +``V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_MAX_QP (integer)``
> + Maximum quantization parameter for the HEVC B frame to limit B frame
> + quality to a range. Valid range: from 0 to 51 for 8 bit, 0 - 63 for 10 bit.
> + If V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP is also set, the quantization parameter
> + should be chosen to meet both requirements.
> +
> ``V4L2_CID_MPEG_VIDEO_HEVC_HIER_QP (boolean)``
> HIERARCHICAL_QP allows the host to specify the quantization parameter
> values for each temporal layer through HIERARCHICAL_QP_LAYER. This is
> diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
> index bd7f330..abef73e 100644
> --- a/drivers/media/v4l2-core/v4l2-ctrls.c
> +++ b/drivers/media/v4l2-core/v4l2-ctrls.c
> @@ -920,6 +920,8 @@ 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_B_FRAME_MIN_QP: return "H264 B-Frame Minimum QP Value";
> + case V4L2_CID_MPEG_VIDEO_H264_B_FRAME_MAX_QP: return "H264 B-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";
> @@ -978,6 +980,12 @@ const char *v4l2_ctrl_get_name(u32 id)
> case V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_QP: return "HEVC B-Frame QP Value";
> case V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP: return "HEVC Minimum QP Value";
> case V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP: return "HEVC Maximum QP Value";
> + case V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_MIN_QP: return "HEVC I-Frame Minimum QP Value";
> + case V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_MAX_QP: return "HEVC I-Frame Maximum QP Value";
> + case V4L2_CID_MPEG_VIDEO_HEVC_P_FRAME_MIN_QP: return "HEVC P-Frame Minimum QP Value";
> + case V4L2_CID_MPEG_VIDEO_HEVC_P_FRAME_MAX_QP: return "HEVC P-Frame Maximum QP Value";
> + case V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_MIN_QP: return "HEVC B-Frame Minimum QP Value";
> + case V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_MAX_QP: return "HEVC B-Frame Maximum QP Value";
> case V4L2_CID_MPEG_VIDEO_HEVC_PROFILE: return "HEVC Profile";
> case V4L2_CID_MPEG_VIDEO_HEVC_LEVEL: return "HEVC Level";
> case V4L2_CID_MPEG_VIDEO_HEVC_TIER: return "HEVC Tier";
> diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
> index a184c49..7ba05fe 100644
> --- a/include/uapi/linux/v4l2-controls.h
> +++ b/include/uapi/linux/v4l2-controls.h
> @@ -578,6 +578,8 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type {
> #define V4L2_CID_MPEG_VIDEO_H264_I_FRAME_MAX_QP (V4L2_CID_MPEG_BASE+386)
> #define V4L2_CID_MPEG_VIDEO_H264_P_FRAME_MIN_QP (V4L2_CID_MPEG_BASE+387)
> #define V4L2_CID_MPEG_VIDEO_H264_P_FRAME_MAX_QP (V4L2_CID_MPEG_BASE+388)
> +#define V4L2_CID_MPEG_VIDEO_H264_B_FRAME_MIN_QP (V4L2_CID_MPEG_BASE+389)
> +#define V4L2_CID_MPEG_VIDEO_H264_B_FRAME_MAX_QP (V4L2_CID_MPEG_BASE+390)
> #define V4L2_CID_MPEG_VIDEO_MPEG4_I_FRAME_QP (V4L2_CID_MPEG_BASE+400)
> #define V4L2_CID_MPEG_VIDEO_MPEG4_P_FRAME_QP (V4L2_CID_MPEG_BASE+401)
> #define V4L2_CID_MPEG_VIDEO_MPEG4_B_FRAME_QP (V4L2_CID_MPEG_BASE+402)
> @@ -762,6 +764,13 @@ enum v4l2_cid_mpeg_video_hevc_size_of_length_field {
> #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_FRAME_SKIP_MODE (V4L2_CID_MPEG_BASE + 646)
> +#define V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_MIN_QP (V4L2_CID_MPEG_BASE+647)
> +#define V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_MAX_QP (V4L2_CID_MPEG_BASE+648)
> +#define V4L2_CID_MPEG_VIDEO_HEVC_P_FRAME_MIN_QP (V4L2_CID_MPEG_BASE+649)
> +#define V4L2_CID_MPEG_VIDEO_HEVC_P_FRAME_MAX_QP (V4L2_CID_MPEG_BASE+650)
> +#define V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_MIN_QP (V4L2_CID_MPEG_BASE+651)
> +#define V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_MAX_QP (V4L2_CID_MPEG_BASE+652)
> +
> enum v4l2_mpeg_video_frame_skip_mode {
> V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_DISABLED = 0,
> V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_LEVEL_LIMIT = 1,
>

Regards,

Hans