Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1575350pxb; Thu, 4 Mar 2021 15:16:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJzwiVGeRcvWwOcxU9HnZKHZ11qaj9ry1cqWLdDupVFXABqb0Oa0Gbxd1Bz/LMCYnm/31kUF X-Received: by 2002:a05:6e02:1044:: with SMTP id p4mr6345344ilj.238.1614899776303; Thu, 04 Mar 2021 15:16:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614899776; cv=none; d=google.com; s=arc-20160816; b=GPrenZIdouZYRzHpexUlino54fiigBu7iZ0UxCO7mNyV17KCurXWUC3IRo6Ldhv1/B NENcjM8uWP/18EDGV0B9duHeQQA532EPqPo/Hx5e3nYpOt5Yy0lBltIdwQw8Z84kV5t/ sJtxixW8UU+29Utk+CxPxUOtp4L33a9cZIaUXkSgTX8txyJbZ1E11c/geH2CQctbP6Ik swSMRY0qCmEohUsotsUSZTLhZUoJmaxFeIVuUbb3GibgDL8KT78WrgOV2Yb/3KdzkVrA fCAv1hZGP9rQX89QlqVHiHWyNvF4YLRTOO6iz3quPu2gLmjDwIFwycxbvjRsoNb85/PY J4mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=2vguEVYxBo4B2mL5S/vEBDa2DFOjBOgG8aHD2agTL1Q=; b=kbUBas2TyZ/akrVA/q5Sm4mBBm8Keu/jvymzlBDamgYVP4W/vnNd7lNBQaiFIZB1lY cT6Mpma1QeOi03U0qLigLW4vlgBD2U4IUXlDoO0YfoP98jajuz3uMewMK8rcrjz4MrXB D9R261oy3Dz3k2UQJAlotmrdDSebaoOFBLEKv6rn1I7Je0PkH5X8dqfmUKuejDcYYIWA GwlQSRavPnJ7w9Gu/03jbVm0JDCK9hMHxDbB6YhwxdDS9D4Vj9tsk5zW5AVk6FTyujtg P0Zp2N8FtHzoI1HlPLCMIZOZBSRXZ30h4HXbN2U4NarmX63K3oC+lOl5nlZ/wYi1h0UY kkjg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w18si628577iod.102.2021.03.04.15.16.03; Thu, 04 Mar 2021 15:16:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384448AbhCCQIB (ORCPT + 99 others); Wed, 3 Mar 2021 11:08:01 -0500 Received: from alexa-out.qualcomm.com ([129.46.98.28]:62405 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232418AbhCCL3O (ORCPT ); Wed, 3 Mar 2021 06:29:14 -0500 Received: from ironmsg07-lv.qualcomm.com (HELO ironmsg07-lv.qulacomm.com) ([10.47.202.151]) by alexa-out.qualcomm.com with ESMTP; 03 Mar 2021 03:10:20 -0800 X-QCInternal: smtphost Received: from ironmsg01-blr.qualcomm.com ([10.86.208.130]) by ironmsg07-lv.qulacomm.com with ESMTP/TLS/AES256-SHA; 03 Mar 2021 03:10:18 -0800 X-QCInternal: smtphost Received: from dikshita-linux.qualcomm.com ([10.204.65.237]) by ironmsg01-blr.qualcomm.com with ESMTP; 03 Mar 2021 16:40:06 +0530 Received: by dikshita-linux.qualcomm.com (Postfix, from userid 347544) id E667521308; Wed, 3 Mar 2021 16:40:04 +0530 (IST) From: Dikshita Agarwal To: linux-media@vger.kernel.org, hverkuil-cisco@xs4all.nl, stanimir.varbanov@linaro.org Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, vgarodia@codeaurora.org, Dikshita Agarwal Subject: [PATCH v7 1/2] media: v4l2-ctrl: add controls for long term reference. Date: Wed, 3 Mar 2021 16:39:46 +0530 Message-Id: <1614769787-26922-2-git-send-email-dikshita@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1614769787-26922-1-git-send-email-dikshita@codeaurora.org> References: <1614769787-26922-1-git-send-email-dikshita@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- .../userspace-api/media/v4l/ext-ctrls-codec.rst | 17 +++++++++++++++++ drivers/media/v4l2-core/v4l2-ctrls.c | 14 ++++++++++++++ include/uapi/linux/v4l2-controls.h | 3 +++ 3 files changed, 34 insertions(+) diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst index 00944e9..21fa9a5 100644 --- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst @@ -3646,3 +3646,20 @@ enum v4l2_mpeg_video_hevc_size_of_length_field - so this has to come from client. This is applicable to H264 and valid Range is from 0 to 63. Source Rec. ITU-T H.264 (06/2019); G.7.4.1.1, G.8.8.1. + +``V4L2_CID_MPEG_VIDEO_LTR_COUNT (integer)`` + Specifies the maximum number of Long Term Reference (LTR) frames at any + given time that the encoder can keep. + This is applicable to the H264 and HEVC encoders. + +``V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX (integer)`` + The current frame is marked as a Long Term Reference (LTR) frame + and given this LTR index which ranges from 0 to LTR_COUNT-1. + This is applicable to the H264 and HEVC encoders. + Source Rec. ITU-T H.264 (06/2019); Table 7.9 + +``V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES (bitmask)`` + Specifies the Long Term Reference (LTR) frame(s) to be used for + encoding the current frame. + This provides a bitmask which consists of bits [0, LTR_COUNT-1]. + This is applicable to the H264 and HEVC encoders. diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index 016cf62..4d444de 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -951,6 +951,9 @@ const char *v4l2_ctrl_get_name(u32 id) case V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER: return "Repeat Sequence Header"; case V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME: return "Force Key Frame"; case V4L2_CID_MPEG_VIDEO_BASELAYER_PRIORITY_ID: return "Base Layer Priority ID"; + case V4L2_CID_MPEG_VIDEO_LTR_COUNT: return "LTR Count"; + case V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX: return "Frame LTR Index"; + case V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES: return "Use LTR Frames"; case V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS: return "MPEG-2 Slice Parameters"; case V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION: return "MPEG-2 Quantization Matrices"; case V4L2_CID_FWHT_I_FRAME_QP: return "FWHT I-Frame QP Value"; @@ -1278,6 +1281,17 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, case V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE: *type = V4L2_CTRL_TYPE_INTEGER; break; + case V4L2_CID_MPEG_VIDEO_LTR_COUNT: + *type = V4L2_CTRL_TYPE_INTEGER; + break; + case V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX: + *type = V4L2_CTRL_TYPE_INTEGER; + *flags |= V4L2_CTRL_FLAG_EXECUTE_ON_WRITE; + break; + case V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES: + *type = V4L2_CTRL_TYPE_BITMASK; + *flags |= V4L2_CTRL_FLAG_EXECUTE_ON_WRITE; + break; case V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME: case V4L2_CID_PAN_RESET: case V4L2_CID_TILT_RESET: diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h index 039c0d7..fedbb54 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -428,6 +428,9 @@ 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_LTR_COUNT (V4L2_CID_CODEC_BASE+231) +#define V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX (V4L2_CID_CODEC_BASE+232) +#define V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES (V4L2_CID_CODEC_BASE+233) /* CIDs for the MPEG-2 Part 2 (H.262) codec */ #define V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL (V4L2_CID_CODEC_BASE+270) -- 2.7.4