Skip to content

Commit f15c54c

Browse files
Dikshita Agarwalmchehab
authored andcommitted
media: v4l2-ctrl: add controls for long term reference.
Long Term Reference (LTR) frames are the frames that are encoded sometime in the past and stored in the DPB buffer list to be used as reference to encode future frames. This change adds controls to enable this feature. Signed-off-by: Dikshita Agarwal <[email protected]> Reviewed-by: Hans Verkuil <[email protected]> Signed-off-by: Stanimir Varbanov <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent ddbcd0c commit f15c54c

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3427,3 +3427,21 @@ enum v4l2_mpeg_video_hevc_size_of_length_field -
34273427
so this has to come from client.
34283428
This is applicable to H264 and valid Range is from 0 to 63.
34293429
Source Rec. ITU-T H.264 (06/2019); G.7.4.1.1, G.8.8.1.
3430+
3431+
``V4L2_CID_MPEG_VIDEO_LTR_COUNT (integer)``
3432+
Specifies the maximum number of Long Term Reference (LTR) frames at any
3433+
given time that the encoder can keep.
3434+
This is applicable to the H264 and HEVC encoders.
3435+
3436+
``V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX (integer)``
3437+
After setting this control the frame that will be queued next
3438+
will be marked as a Long Term Reference (LTR) frame
3439+
and given this LTR index which ranges from 0 to LTR_COUNT-1.
3440+
This is applicable to the H264 and HEVC encoders.
3441+
Source Rec. ITU-T H.264 (06/2019); Table 7.9
3442+
3443+
``V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES (bitmask)``
3444+
Specifies the Long Term Reference (LTR) frame(s) to be used for
3445+
encoding the next frame queued after setting this control.
3446+
This provides a bitmask which consists of bits [0, LTR_COUNT-1].
3447+
This is applicable to the H264 and HEVC encoders.

drivers/media/v4l2-core/v4l2-ctrls.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,9 @@ const char *v4l2_ctrl_get_name(u32 id)
961961
case V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER: return "Repeat Sequence Header";
962962
case V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME: return "Force Key Frame";
963963
case V4L2_CID_MPEG_VIDEO_BASELAYER_PRIORITY_ID: return "Base Layer Priority ID";
964+
case V4L2_CID_MPEG_VIDEO_LTR_COUNT: return "LTR Count";
965+
case V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX: return "Frame LTR Index";
966+
case V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES: return "Use LTR Frames";
964967
case V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS: return "MPEG-2 Slice Parameters";
965968
case V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION: return "MPEG-2 Quantization Matrices";
966969
case V4L2_CID_FWHT_I_FRAME_QP: return "FWHT I-Frame QP Value";
@@ -1291,6 +1294,17 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
12911294
case V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY:
12921295
*type = V4L2_CTRL_TYPE_INTEGER;
12931296
break;
1297+
case V4L2_CID_MPEG_VIDEO_LTR_COUNT:
1298+
*type = V4L2_CTRL_TYPE_INTEGER;
1299+
break;
1300+
case V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX:
1301+
*type = V4L2_CTRL_TYPE_INTEGER;
1302+
*flags |= V4L2_CTRL_FLAG_EXECUTE_ON_WRITE;
1303+
break;
1304+
case V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES:
1305+
*type = V4L2_CTRL_TYPE_BITMASK;
1306+
*flags |= V4L2_CTRL_FLAG_EXECUTE_ON_WRITE;
1307+
break;
12941308
case V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME:
12951309
case V4L2_CID_PAN_RESET:
12961310
case V4L2_CID_TILT_RESET:

include/uapi/linux/v4l2-controls.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,9 @@ enum v4l2_mpeg_video_multi_slice_mode {
429429
#define V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME (V4L2_CID_CODEC_BASE+229)
430430
#define V4L2_CID_MPEG_VIDEO_BASELAYER_PRIORITY_ID (V4L2_CID_CODEC_BASE+230)
431431
#define V4L2_CID_MPEG_VIDEO_AU_DELIMITER (V4L2_CID_CODEC_BASE+231)
432+
#define V4L2_CID_MPEG_VIDEO_LTR_COUNT (V4L2_CID_CODEC_BASE+232)
433+
#define V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX (V4L2_CID_CODEC_BASE+233)
434+
#define V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES (V4L2_CID_CODEC_BASE+234)
432435

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

0 commit comments

Comments
 (0)