Message ID | 20201206102717.19000-2-stanimir.varbanov@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | Add random IR and AUD encoder controls | expand |
On 06/12/2020 11:27, Stanimir Varbanov wrote: > Add a control to set intra-refresh period. > > Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> > --- > .../userspace-api/media/v4l/ext-ctrls-codec.rst | 11 +++++++++++ > drivers/media/v4l2-core/v4l2-ctrls.c | 2 ++ > include/uapi/linux/v4l2-controls.h | 1 + > 3 files changed, 14 insertions(+) > > diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst > index 454ecd9a0f83..d65d7c1381b7 100644 > --- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst > +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst > @@ -1104,6 +1104,17 @@ 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. With other words, this defines the number of frames With -> In > + 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. > + Applicable to H264 and HEVC encoders. I'm confused. Isn't this the same as V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB? Except that here you don't give the number of macroblocks but instead the number of frames it will take to fully refresh a frame and leave it to the driver to calculate the number of macroblocks? If I am right, then you need to clearly document the relationship between the two controls, and what happens if you set them both. It seems the venus driver already supports V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB, so why add this control as well? Regards, Hans > + > ``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 5cbe0ffbf501..ac44848d2d6e 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"; > @@ -1260,6 +1261,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 823b214aac0c..54b9072ac49d 100644 > --- a/include/uapi/linux/v4l2-controls.h > +++ b/include/uapi/linux/v4l2-controls.h > @@ -422,6 +422,7 @@ enum v4l2_mpeg_video_multi_slice_mode { > #define V4L2_CID_MPEG_VIDEO_MV_H_SEARCH_RANGE (V4L2_CID_CODEC_BASE+227) > #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_INTRA_REFRESH_PERIOD (V4L2_CID_CODEC_BASE+230) > > /* CIDs for the MPEG-2 Part 2 (H.262) codec */ > #define V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL (V4L2_CID_CODEC_BASE+270) >
On 1/12/21 12:05 PM, Hans Verkuil wrote: > On 06/12/2020 11:27, Stanimir Varbanov wrote: >> Add a control to set intra-refresh period. >> >> Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> >> --- >> .../userspace-api/media/v4l/ext-ctrls-codec.rst | 11 +++++++++++ >> drivers/media/v4l2-core/v4l2-ctrls.c | 2 ++ >> include/uapi/linux/v4l2-controls.h | 1 + >> 3 files changed, 14 insertions(+) >> >> diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst >> index 454ecd9a0f83..d65d7c1381b7 100644 >> --- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst >> +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst >> @@ -1104,6 +1104,17 @@ 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. With other words, this defines the number of frames > > With -> In > >> + 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. >> + Applicable to H264 and HEVC encoders. > > I'm confused. Isn't this the same as V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB? > Except that here you don't give the number of macroblocks but instead the number > of frames it will take to fully refresh a frame and leave it to the driver to > calculate the number of macroblocks? Yes, correct. The periodic control looks more generic because it doesn't limit the type of intra-refresh (cyclic vs random vs adaptive) but instead set the number of frames to fully refresh the whole frame and is also taken from Android mediacodec [1], where the user doesn't care too much what intra-refresh type will be used but instead how much frames are needed to fully refresh. > > If I am right, then you need to clearly document the relationship between the > two controls, and what happens if you set them both. Yep, I can add such description. One note here; the CYCLIC_INTRA_REFRESH_MB and INTRA_REFRESH_PERIOD are not interchangeable because intra-refresh period could use different type of inter-refresh, eg. random vs cyclic. > > It seems the venus driver already supports V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB, > so why add this control as well? The cyclic intra-refresh control in Venus driver is just enumerable but ignored when set, in other words it does nothing. > > Regards, > > Hans > [1] https://developer.android.com/reference/android/media/MediaFormat#KEY_INTRA_REFRESH_PERIOD
diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst index 454ecd9a0f83..d65d7c1381b7 100644 --- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst @@ -1104,6 +1104,17 @@ 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. With 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. + 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 5cbe0ffbf501..ac44848d2d6e 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"; @@ -1260,6 +1261,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 823b214aac0c..54b9072ac49d 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -422,6 +422,7 @@ enum v4l2_mpeg_video_multi_slice_mode { #define V4L2_CID_MPEG_VIDEO_MV_H_SEARCH_RANGE (V4L2_CID_CODEC_BASE+227) #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_INTRA_REFRESH_PERIOD (V4L2_CID_CODEC_BASE+230) /* CIDs for the MPEG-2 Part 2 (H.262) codec */ #define V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL (V4L2_CID_CODEC_BASE+270)
Add a control to set intra-refresh period. Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> --- .../userspace-api/media/v4l/ext-ctrls-codec.rst | 11 +++++++++++ drivers/media/v4l2-core/v4l2-ctrls.c | 2 ++ include/uapi/linux/v4l2-controls.h | 1 + 3 files changed, 14 insertions(+) -- 2.17.1