Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp399689pxu; Tue, 1 Dec 2020 14:16:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJzg0UJxuhrAM1127YdJDBVJqPfEJrqS+EPYWoFO5bCawxjdzposNMAvl5d9676mV6rZlvdh X-Received: by 2002:a05:6402:104d:: with SMTP id e13mr5234921edu.179.1606860993754; Tue, 01 Dec 2020 14:16:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606860993; cv=none; d=google.com; s=arc-20160816; b=iG0tZrj5V2+yWSSfLPGLneb6VMQIEKxfy9XhG3N6GxAtnFzUgoJxq/jysCFSD9y5Bj rV0WsZiPWgjfJ8mOVHCrnE/eabHH5FEVUyFfKk2EL+6QTDqTpTAR7tK/vbPpwvE0DTHn GHdXN+rHcMKufSHR0ZY43y2Ra0h4nSNq/p6i6JwMkD2lgVEHpl5AK1PljDV4D9wAIQrj BpXyDeiytOAzKYMH9p0H79/lGDez9YW6txvWqVNqJfl880nOvqKeWFb9RtjLslT00XnY tlMIqLpIbF8M0xt7s9idbrs8weujosRdAYg/gQaibxBiL0X84DRPN5AmNw6jnNDnyKl+ 7/3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=VNG+7nq241AqH05XqEr24Tcqb9Rc3nZj+GQwsYj+VCw=; b=PtZg1/ZbXypFK6YhYemRGLs7WpJSHhvMm9kpAcPghkJNeeJFseP2qFO1zvhqScY7mx vbymNdd90Ag//6ASdxuZuwIDVgIGhwr4Do1XE9PXRDTENacm8VLGq0F+Y7dhtbZhQ5r0 iNShaBcZb9U82qRihWs/SBxMTFnjPlZQDkF6pR4dRje8OFvBkgHnVWeBuO5fqLDOCu7/ pnH7yTeUOdQmj7mgHdJ7b6+8YJ6Z5kIKGy7b5FNcoNL3Jvye8IIEjmUZWybBWjp+WZ7i e12ysalqqKBAyfxZmR/fubHKG4zTwIj1QskNj0qyT8jvjKnUMDa6f5CDhxiJd3+4uauc fITg== 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 h2si784151ejb.710.2020.12.01.14.16.11; Tue, 01 Dec 2020 14:16:33 -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 S1728640AbgLAIPC (ORCPT + 99 others); Tue, 1 Dec 2020 03:15:02 -0500 Received: from alexa-out.qualcomm.com ([129.46.98.28]:35165 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726619AbgLAIPC (ORCPT ); Tue, 1 Dec 2020 03:15:02 -0500 Received: from ironmsg09-lv.qualcomm.com ([10.47.202.153]) by alexa-out.qualcomm.com with ESMTP; 01 Dec 2020 00:14:20 -0800 X-QCInternal: smtphost Received: from ironmsg01-blr.qualcomm.com ([10.86.208.130]) by ironmsg09-lv.qualcomm.com with ESMTP/TLS/AES256-SHA; 01 Dec 2020 00:14:19 -0800 X-QCInternal: smtphost Received: from dikshita-linux.qualcomm.com ([10.204.65.237]) by ironmsg01-blr.qualcomm.com with ESMTP; 01 Dec 2020 13:44:02 +0530 Received: by dikshita-linux.qualcomm.com (Postfix, from userid 347544) id D1A662130E; Tue, 1 Dec 2020 13:44:00 +0530 (IST) From: Dikshita Agarwal To: linux-media@vger.kernel.org, hverkuil-cisco@xs4all.nl, nicolas@ndufresne.ca, stanimir.varbanov@linaro.org Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, vgarodia@codeaurora.org, Dikshita Agarwal Subject: [PATCH v4] media: v4l2-ctrl: add control for long term reference. Date: Tue, 1 Dec 2020 13:43:57 +0530 Message-Id: <1606810437-2797-1-git-send-email-dikshita@codeaurora.org> X-Mailer: git-send-email 2.7.4 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 | 18 ++++++++++++++++++ drivers/media/v4l2-core/v4l2-ctrls.c | 14 ++++++++++++++ include/uapi/linux/v4l2-controls.h | 3 +++ 3 files changed, 35 insertions(+) diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst index 3b86959..40634f8 100644 --- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst @@ -4450,3 +4450,21 @@ enum v4l2_mpeg_video_hevc_size_of_length_field - - Selecting this value specifies that HEVC slices are expected to be prefixed by Annex B start codes. According to :ref:`hevc` valid start codes can be 3-bytes 0x000001 or 4-bytes 0x00000001. + +``V4L2_CID_MPEG_VIDEO_LTR_COUNT (integer)`` + Specifies the number of Long Term Reference (LTR) frames encoder needs + to generate or keep. This is applicable to H264 and HEVC encoder. + +``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 H264 and HEVC encoder and can be applied using + Request Api. + 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 H264 and HEVC encoder and can be applied using + Request Api. diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index e5b726f..0b81b39 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -958,6 +958,9 @@ const char *v4l2_ctrl_get_name(u32 id) case V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE: return "Vertical MV Search Range"; 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_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 Frame(s)"; 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_MPEG_VIDEO_FWHT_PARAMS: return "FWHT Stateless Parameters"; @@ -1273,6 +1276,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 e37b85f..710bc53 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -421,6 +421,9 @@ enum v4l2_mpeg_video_multi_slice_mode { #define V4L2_CID_MPEG_VIDEO_MV_H_SEARCH_RANGE (V4L2_CID_MPEG_BASE+227) #define V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE (V4L2_CID_MPEG_BASE+228) #define V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME (V4L2_CID_MPEG_BASE+229) +#define V4L2_CID_MPEG_VIDEO_LTR_COUNT (V4L2_CID_MPEG_BASE + 230) +#define V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX (V4L2_CID_MPEG_BASE + 231) +#define V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES (V4L2_CID_MPEG_BASE + 232) /* CIDs for the MPEG-2 Part 2 (H.262) codec */ #define V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL (V4L2_CID_MPEG_BASE+270) -- 2.7.4