2021-03-02 21:43:32

by Stanimir Varbanov

[permalink] [raw]
Subject: [PATCH v3 0/2] Intra-refresh period control

Hi,

This series add a new intra-refresh period control for encoders. The
series is a continuation of [1]. Comments addressed:
* A typo in .rst (Hans)
* Clarified the relationship with CYCLIC_INTRA_REFRESH_MB (Hans)

Comments are welcome!

regards,
Stan

[1] https://www.spinics.net/lists/linux-media/msg183019.html

Stanimir Varbanov (2):
media: v4l2-ctrls: Add intra-refresh period control
venus: venc: Add support for intra-refresh period

.../media/v4l/ext-ctrls-codec.rst | 12 ++++++++
drivers/media/platform/qcom/venus/core.h | 1 +
drivers/media/platform/qcom/venus/venc.c | 28 +++++++++++++++++++
.../media/platform/qcom/venus/venc_ctrls.c | 13 ++++-----
drivers/media/v4l2-core/v4l2-ctrls.c | 2 ++
include/uapi/linux/v4l2-controls.h | 1 +
6 files changed, 50 insertions(+), 7 deletions(-)

--
2.25.1


2021-03-04 06:09:13

by Stanimir Varbanov

[permalink] [raw]
Subject: [PATCH v3 1/2] media: v4l2-ctrls: Add intra-refresh period control

Add a control to set intra-refresh period.

Signed-off-by: Stanimir Varbanov <[email protected]>
---
.../userspace-api/media/v4l/ext-ctrls-codec.rst | 12 ++++++++++++
drivers/media/v4l2-core/v4l2-ctrls.c | 2 ++
include/uapi/linux/v4l2-controls.h | 1 +
3 files changed, 15 insertions(+)

diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
index 00944e97d638..49e6d364ded7 100644
--- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
+++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
@@ -1104,6 +1104,18 @@ enum v4l2_mpeg_video_h264_entropy_mode -
macroblocks is refreshed until the cycle completes and starts from
the top of the frame. Applicable to H264, H263 and MPEG4 encoder.

+``V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD (integer)``
+ Intra macroblock refresh period. This sets the period to refresh
+ the whole frame. In other words, this defines the number of frames
+ for which the whole frame will be intra-refreshed. An example:
+ setting period to 1 means that the whole frame will be refreshed,
+ setting period to 2 means that the half of macroblocks will be
+ intra-refreshed on frameX and the other half of macroblocks
+ will be refreshed in frameX + 1 and so on. Setting period to zero
+ means no period is specified. Note that intra-refresh is mutually
+ exclusive with V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB control.
+ Applicable to H264 and HEVC encoders.
+
``V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE (boolean)``
Frame level rate control enable. If this control is disabled then
the quantization parameter for each frame type is constant and set
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
index 016cf6204cbb..2ee463e08f1e 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -869,6 +869,7 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_MPEG_VIDEO_DECODER_SLICE_INTERFACE: return "Decoder Slice Interface";
case V4L2_CID_MPEG_VIDEO_DECODER_MPEG4_DEBLOCK_FILTER: return "MPEG4 Loop Filter Enable";
case V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB: return "Number of Intra Refresh MBs";
+ case V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD: return "Intra Refresh Period";
case V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE: return "Frame Level Rate Control Enable";
case V4L2_CID_MPEG_VIDEO_MB_RC_ENABLE: return "H264 MB Level Rate Control";
case V4L2_CID_MPEG_VIDEO_HEADER_MODE: return "Sequence Header Mode";
@@ -1276,6 +1277,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
break;
case V4L2_CID_MPEG_VIDEO_MV_H_SEARCH_RANGE:
case V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE:
+ case V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD:
*type = V4L2_CTRL_TYPE_INTEGER;
break;
case V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME:
diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
index 039c0d7add1b..1fddd9f0d4f1 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -428,6 +428,7 @@ enum v4l2_mpeg_video_multi_slice_mode {
#define V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE (V4L2_CID_CODEC_BASE+228)
#define V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME (V4L2_CID_CODEC_BASE+229)
#define V4L2_CID_MPEG_VIDEO_BASELAYER_PRIORITY_ID (V4L2_CID_CODEC_BASE+230)
+#define V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD (V4L2_CID_CODEC_BASE+231)

/* CIDs for the MPEG-2 Part 2 (H.262) codec */
#define V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL (V4L2_CID_CODEC_BASE+270)
--
2.25.1

2021-04-13 21:25:31

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH v3 0/2] Intra-refresh period control

On 13/04/2021 17:49, Stanimir Varbanov wrote:
> Hi Hans,
>
> Any comments?

Thanks for the reminder, I replied to the patch.

Regards,

Hans

>
> On 3/2/21 11:53 AM, Stanimir Varbanov wrote:
>> Hi,
>>
>> This series add a new intra-refresh period control for encoders. The
>> series is a continuation of [1]. Comments addressed:
>> * A typo in .rst (Hans)
>> * Clarified the relationship with CYCLIC_INTRA_REFRESH_MB (Hans)
>>
>> Comments are welcome!
>>
>> regards,
>> Stan
>>
>> [1] https://www.spinics.net/lists/linux-media/msg183019.html
>>
>> Stanimir Varbanov (2):
>> media: v4l2-ctrls: Add intra-refresh period control
>> venus: venc: Add support for intra-refresh period
>>
>> .../media/v4l/ext-ctrls-codec.rst | 12 ++++++++
>> drivers/media/platform/qcom/venus/core.h | 1 +
>> drivers/media/platform/qcom/venus/venc.c | 28 +++++++++++++++++++
>> .../media/platform/qcom/venus/venc_ctrls.c | 13 ++++-----
>> drivers/media/v4l2-core/v4l2-ctrls.c | 2 ++
>> include/uapi/linux/v4l2-controls.h | 1 +
>> 6 files changed, 50 insertions(+), 7 deletions(-)
>>
>

2021-04-14 01:33:05

by Stanimir Varbanov

[permalink] [raw]
Subject: Re: [PATCH v3 0/2] Intra-refresh period control

Hi Hans,

Any comments?

On 3/2/21 11:53 AM, Stanimir Varbanov wrote:
> Hi,
>
> This series add a new intra-refresh period control for encoders. The
> series is a continuation of [1]. Comments addressed:
> * A typo in .rst (Hans)
> * Clarified the relationship with CYCLIC_INTRA_REFRESH_MB (Hans)
>
> Comments are welcome!
>
> regards,
> Stan
>
> [1] https://www.spinics.net/lists/linux-media/msg183019.html
>
> Stanimir Varbanov (2):
> media: v4l2-ctrls: Add intra-refresh period control
> venus: venc: Add support for intra-refresh period
>
> .../media/v4l/ext-ctrls-codec.rst | 12 ++++++++
> drivers/media/platform/qcom/venus/core.h | 1 +
> drivers/media/platform/qcom/venus/venc.c | 28 +++++++++++++++++++
> .../media/platform/qcom/venus/venc_ctrls.c | 13 ++++-----
> drivers/media/v4l2-core/v4l2-ctrls.c | 2 ++
> include/uapi/linux/v4l2-controls.h | 1 +
> 6 files changed, 50 insertions(+), 7 deletions(-)
>

--
regards,
Stan

2021-04-14 02:07:24

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH v3 1/2] media: v4l2-ctrls: Add intra-refresh period control

On 02/03/2021 10:53, Stanimir Varbanov wrote:
> Add a control to set intra-refresh period.
>
> Signed-off-by: Stanimir Varbanov <[email protected]>
> ---
> .../userspace-api/media/v4l/ext-ctrls-codec.rst | 12 ++++++++++++
> drivers/media/v4l2-core/v4l2-ctrls.c | 2 ++
> include/uapi/linux/v4l2-controls.h | 1 +
> 3 files changed, 15 insertions(+)
>
> diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
> index 00944e97d638..49e6d364ded7 100644
> --- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
> +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
> @@ -1104,6 +1104,18 @@ enum v4l2_mpeg_video_h264_entropy_mode -
> macroblocks is refreshed until the cycle completes and starts from
> the top of the frame. Applicable to H264, H263 and MPEG4 encoder.
>
> +``V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD (integer)``
> + Intra macroblock refresh period. This sets the period to refresh
> + the whole frame. In other words, this defines the number of frames
> + for which the whole frame will be intra-refreshed. An example:
> + setting period to 1 means that the whole frame will be refreshed,
> + setting period to 2 means that the half of macroblocks will be
> + intra-refreshed on frameX and the other half of macroblocks
> + will be refreshed in frameX + 1 and so on. Setting period to zero
> + means no period is specified. Note that intra-refresh is mutually

Double space after 'intra-refresh'

> + exclusive with V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB control.

1) The same must be mentioned in the V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB
control documentation as well.
2) What does it mean: 'mutually exclusive'? Does that mean that a driver
implements only one or the other? If not, and both can be implemented, then
how does userspace know which control is applied?

Also, you mentioned that V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB is
enumerated in the venus driver, but doesn't do anything. Wouldn't it be
better to remove it?

Regards,

Hans

> + Applicable to H264 and HEVC encoders.
> +
> ``V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE (boolean)``
> Frame level rate control enable. If this control is disabled then
> the quantization parameter for each frame type is constant and set
> diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
> index 016cf6204cbb..2ee463e08f1e 100644
> --- a/drivers/media/v4l2-core/v4l2-ctrls.c
> +++ b/drivers/media/v4l2-core/v4l2-ctrls.c
> @@ -869,6 +869,7 @@ const char *v4l2_ctrl_get_name(u32 id)
> case V4L2_CID_MPEG_VIDEO_DECODER_SLICE_INTERFACE: return "Decoder Slice Interface";
> case V4L2_CID_MPEG_VIDEO_DECODER_MPEG4_DEBLOCK_FILTER: return "MPEG4 Loop Filter Enable";
> case V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB: return "Number of Intra Refresh MBs";
> + case V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD: return "Intra Refresh Period";
> case V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE: return "Frame Level Rate Control Enable";
> case V4L2_CID_MPEG_VIDEO_MB_RC_ENABLE: return "H264 MB Level Rate Control";
> case V4L2_CID_MPEG_VIDEO_HEADER_MODE: return "Sequence Header Mode";
> @@ -1276,6 +1277,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
> break;
> case V4L2_CID_MPEG_VIDEO_MV_H_SEARCH_RANGE:
> case V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE:
> + case V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD:
> *type = V4L2_CTRL_TYPE_INTEGER;
> break;
> case V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME:
> diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
> index 039c0d7add1b..1fddd9f0d4f1 100644
> --- a/include/uapi/linux/v4l2-controls.h
> +++ b/include/uapi/linux/v4l2-controls.h
> @@ -428,6 +428,7 @@ enum v4l2_mpeg_video_multi_slice_mode {
> #define V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE (V4L2_CID_CODEC_BASE+228)
> #define V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME (V4L2_CID_CODEC_BASE+229)
> #define V4L2_CID_MPEG_VIDEO_BASELAYER_PRIORITY_ID (V4L2_CID_CODEC_BASE+230)
> +#define V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD (V4L2_CID_CODEC_BASE+231)
>
> /* CIDs for the MPEG-2 Part 2 (H.262) codec */
> #define V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL (V4L2_CID_CODEC_BASE+270)
>