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

2020-11-11 Thread Hans Verkuil
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 
> ---
>  .../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 

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

2020-09-21 Thread Dikshita Agarwal
- 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 
---
 .../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