From patchwork Tue Jun 16 12:29:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 188451 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C97A9C433DF for ; Tue, 16 Jun 2020 12:31:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A893D20734 for ; Tue, 16 Jun 2020 12:31:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="di0k6irK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728615AbgFPMbg (ORCPT ); Tue, 16 Jun 2020 08:31:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728782AbgFPMbf (ORCPT ); Tue, 16 Jun 2020 08:31:35 -0400 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB58CC08C5C3 for ; Tue, 16 Jun 2020 05:31:34 -0700 (PDT) Received: by mail-ed1-x542.google.com with SMTP id s28so12037400edw.11 for ; Tue, 16 Jun 2020 05:31:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mF+JQd+IF6PC7hSV5l8PoaKlbsKGhrqeRetXtUoVSHs=; b=di0k6irKRJ+g2vp5YaQg/DO7fnWR2AELf8GZANx0Y5AVqc2GM/yo128odbAPjwi0+7 LZxHsEp2sN2zbPRYhUpBV2BMecMH+wMhfBJxPJ1KAor/++YzPrHsbDQZy5s9Rs5xmoyY gCXoTG3devaIwQshEONY5bHgzarNfHq+1w4825uEB1e4K3X7kTB/epzSreX0608ln8hL uDlMqcBpqp1RnvC4sc/7oRVRgbPgrgrOU2btQfyWIMn17fTZEKJbH0vVqnxeKhUlc51g t+KKqe7g+NjWJS5Une5UXJXIhJjy7EepvIi+Hn0bfd1hWcgY9UWFxQTuiAdqCM7SxPiI SxSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mF+JQd+IF6PC7hSV5l8PoaKlbsKGhrqeRetXtUoVSHs=; b=Bz/Er8cALUg75wCakm0m5lF9RHybg2I7iLNdeoi4CuYgor0XhzSbzxS/EZHOXKQ9cs O4RTAcm9Z/Mhg9EFvg7nMJSMz+yUjRhkMSbV9+cLImOz1o4n64Tl6ee+pzF3XOA4B2a4 kdNtUlK/L4GUJhdNGjKNwQY7HQJmHyxcL/1L6sqbOC6HTLYpnQ4yaGxO8jbAtXyOmhm9 AFihTAJfXbuXs2EjMpEhgkZ1uwUwy4YH9m+E9reQPBPGMz+DkgVLNW7M2iec5wUIQdGM uqvnXSqMG51L9XyzqMRQv2CTw/N991bIPP6Bjsx1XqZVn6Dy0O4ThxS4CSx106EJ1mxR cURQ== X-Gm-Message-State: AOAM531n6ZF3L/PSr2S1YOL19rSa5UzEdw9isIotXKlxfn237S3XrBbI gXfhsAdPipnSkWzZsIkLh3yqcg== X-Google-Smtp-Source: ABdhPJwa4abVKH2y/LcU2JPL1QA9Z3cgfaWYrNBEqtgA33F0xUZb6Gh/4af2MSCBfhoi3qVGtH/KmA== X-Received: by 2002:a50:f985:: with SMTP id q5mr2305480edn.180.1592310693139; Tue, 16 Jun 2020 05:31:33 -0700 (PDT) Received: from localhost.localdomain (212-5-158-38.ip.btc-net.bg. [212.5.158.38]) by smtp.gmail.com with ESMTPSA id p6sm11071983ejb.71.2020.06.16.05.31.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jun 2020 05:31:32 -0700 (PDT) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Cc: Hans Verkuil , Ezequiel Garcia , Maheshwar Ajja , Mauro Carvalho Chehab , Stanimir Varbanov Subject: [PATCH 1/4] media: v4l2-ctrls: Add encoder constant quality control Date: Tue, 16 Jun 2020 15:29:58 +0300 Message-Id: <20200616123001.11321-2-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616123001.11321-1-stanimir.varbanov@linaro.org> References: <20200616123001.11321-1-stanimir.varbanov@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Maheshwar Ajja When V4L2_CID_MPEG_VIDEO_BITRATE_MODE value is V4L2_MPEG_VIDEO_BITRATE_MODE_CQ, encoder will produce constant quality output indicated by V4L2_CID_MPEG_VIDEO_CONSTANT_QUALITY control value. Encoder will choose appropriate quantization parameter and bitrate to produce requested frame quality level. Signed-off-by: Maheshwar Ajja Signed-off-by: Stanimir Varbanov --- v3: moved description around line 925 - Hans .../userspace-api/media/v4l/ext-ctrls-codec.rst | 10 ++++++++++ drivers/media/v4l2-core/v4l2-ctrls.c | 2 ++ include/uapi/linux/v4l2-controls.h | 2 ++ 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 d0d506a444b1..b9d3f7ae6486 100644 --- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst @@ -581,6 +581,8 @@ enum v4l2_mpeg_video_bitrate_mode - - Variable bitrate * - ``V4L2_MPEG_VIDEO_BITRATE_MODE_CBR`` - Constant bitrate + * - ``V4L2_MPEG_VIDEO_BITRATE_MODE_CQ`` + - Constant quality @@ -592,6 +594,14 @@ enum v4l2_mpeg_video_bitrate_mode - the average video bitrate. It is ignored if the video bitrate mode is set to constant bitrate. +``V4L2_CID_MPEG_VIDEO_CONSTANT_QUALITY (integer)`` + Constant quality level control. This control is applicable when + ``V4L2_CID_MPEG_VIDEO_BITRATE_MODE`` value is + ``V4L2_MPEG_VIDEO_BITRATE_MODE_CQ``. Valid range is 1 to 100 + where 1 indicates lowest quality and 100 indicates highest quality. + Encoder will decide the appropriate quantization parameter and + bitrate to produce requested frame quality. + ``V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION (integer)`` For every captured frame, skip this many subsequent frames (default 0). diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index 3f3fbcd60cc6..bc00d02e411f 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -200,6 +200,7 @@ const char * const *v4l2_ctrl_get_menu(u32 id) static const char * const mpeg_video_bitrate_mode[] = { "Variable Bitrate", "Constant Bitrate", + "Constant Quality", NULL }; static const char * const mpeg_stream_type[] = { @@ -832,6 +833,7 @@ const char *v4l2_ctrl_get_name(u32 id) case V4L2_CID_MPEG_VIDEO_GOP_CLOSURE: return "Video GOP Closure"; case V4L2_CID_MPEG_VIDEO_PULLDOWN: return "Video Pulldown"; case V4L2_CID_MPEG_VIDEO_BITRATE_MODE: return "Video Bitrate Mode"; + case V4L2_CID_MPEG_VIDEO_CONSTANT_QUALITY: return "Constant Quality"; case V4L2_CID_MPEG_VIDEO_BITRATE: return "Video Bitrate"; case V4L2_CID_MPEG_VIDEO_BITRATE_PEAK: return "Video Peak Bitrate"; case V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION: return "Video Temporal Decimation"; diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h index 62271418c1be..0f7e4388dcce 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -375,6 +375,7 @@ enum v4l2_mpeg_video_aspect { enum v4l2_mpeg_video_bitrate_mode { V4L2_MPEG_VIDEO_BITRATE_MODE_VBR = 0, V4L2_MPEG_VIDEO_BITRATE_MODE_CBR = 1, + V4L2_MPEG_VIDEO_BITRATE_MODE_CQ = 2, }; #define V4L2_CID_MPEG_VIDEO_BITRATE (V4L2_CID_MPEG_BASE+207) #define V4L2_CID_MPEG_VIDEO_BITRATE_PEAK (V4L2_CID_MPEG_BASE+208) @@ -742,6 +743,7 @@ enum v4l2_cid_mpeg_video_hevc_size_of_length_field { #define V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L6_BR (V4L2_CID_MPEG_BASE + 642) #define V4L2_CID_MPEG_VIDEO_REF_NUMBER_FOR_PFRAMES (V4L2_CID_MPEG_BASE + 643) #define V4L2_CID_MPEG_VIDEO_PREPEND_SPSPPS_TO_IDR (V4L2_CID_MPEG_BASE + 644) +#define V4L2_CID_MPEG_VIDEO_CONSTANT_QUALITY (V4L2_CID_MPEG_BASE + 645) /* MPEG-class control IDs specific to the CX2341x driver as defined by V4L2 */ #define V4L2_CID_MPEG_CX2341X_BASE (V4L2_CTRL_CLASS_MPEG | 0x1000) From patchwork Tue Jun 16 12:29:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 188016 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp3606747ilo; Tue, 16 Jun 2020 05:31:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIFOZN8OW27iZs69gvfOQjHgDDQyamd48P0f0RShiUQZ+iaxUGk7E1d+6FtQlNDCXrWhuW X-Received: by 2002:a05:6402:221b:: with SMTP id cq27mr2264036edb.302.1592310699483; Tue, 16 Jun 2020 05:31:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592310699; cv=none; d=google.com; s=arc-20160816; b=xClAvwNARP6vD1xxl3OvqDJmv19nBgjvPwBA88769p4HfGsrD1Gwmyd/G5WanA9cNL 7VJLwJkPc+LJIH2qumz2aUzXRhJdmmPCPHt13w3FyItcmbk3eQyd+LFPfi8c3kekHfic GMqlDiEYAc2OROQAEZ9E4OdHWCbKjYjI0sfHSyT1+QQZVnIUPpft+x/cl0n3oxr5Blc6 8D/ShMtOwdTjSu5DzUFSw2QomYy0SeDudMMVXvOIoq/fcIp+t7OguXj1/ErBs5Trf5zL E3E2GSlZMfPAObTQEY7y8i/Px1AYcSkpFVB/FpJHaVztf2GTSNl5A8oOzkrRRXVRnV9I gTBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=Dvi8JfbBrV+2ddKi5DN+7RJijpQ/Ouj52VNCZEqpYYk=; b=iDR00Tj7wNhhLFWMoJYR1QWtSu9NIKYIoDBGf1DEEOWoVdoSENZC0pzJZY96r6fZc/ 9lpSJx2XQgwVPIGFub6WkoP2360aDih5/uhJ+1hjjvtrYZdXsjrpnVmD7eZhz1RR5c4O 77O0iiogyo0Xu+aXYwiclDyYtBZzGf/iV3oO6GASKvyRQKDmT5BZVux6cgm6p7cNCCHj 6yocDkf+/GWEWutX96RMjrgM4TjZWcGDtjkeW/dCRaxHHW6rjJ26+fH+UB1fnoIHCNbR bLktFV8yycVnRIJDc3pD6LNZ9dUNvlgaaeohPWpcNEqC3MBwreBON4QnnAGL14X67fBd Cg1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EdWyIPkF; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h5si9498422edr.201.2020.06.16.05.31.39; Tue, 16 Jun 2020 05:31:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EdWyIPkF; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728849AbgFPMbi (ORCPT + 16 others); Tue, 16 Jun 2020 08:31:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728820AbgFPMbh (ORCPT ); Tue, 16 Jun 2020 08:31:37 -0400 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C675DC08C5C2 for ; Tue, 16 Jun 2020 05:31:36 -0700 (PDT) Received: by mail-ed1-x542.google.com with SMTP id c35so14125678edf.5 for ; Tue, 16 Jun 2020 05:31:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Dvi8JfbBrV+2ddKi5DN+7RJijpQ/Ouj52VNCZEqpYYk=; b=EdWyIPkFWo8jvAbm0kCDVrGTr5Q6GcbXhZa6ipb2GTYbO2kqpKpcEaej1jUKTaQmnl 0gDyl4qzdAESK3p4EKf/jjCqVjEfuOmKHhuM4gmIXiHIu/3IEpoJTVVCmsl7A0YJqCEY ipH7mmXz0PWStcwAS4PsINSqM6yDOokLELSs+TAJ8YGZuS4m7TfLcR0TqNvbiAKhvnlB wO55Q/82beGzUjY5VXOFrF5WqyxqWc3LYfUrlSOs3FrFw+FdR4WsIjRioKWViEVVjD6/ UMv7tYgEp2ocTe0DrfhA1wU4uBhsJuIF1nSMuF1LfEFZkIqpLxz08yVFUBeaQzvSR/Yp umjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Dvi8JfbBrV+2ddKi5DN+7RJijpQ/Ouj52VNCZEqpYYk=; b=bo94JPsdCYZhBxTZI+GgJEOj1ItPCgb9EmWJQhgdT5gnTjhd+2x6G0CoYfWJssAUmC TJcEWgtzZxpEFsuelaLCeKy8bafMT6/lMXaiFnYhtstwIbMLIuCeJXIdXwa73XqkF7d1 /VQv2ve8DPkP1urj6nznqtuwi2dw64g32G5EahkGo1RretuTrsDrEcg9dn0d2Gv2Sw6K mvvmZ/vtXTQey8lnqkmVC623jGe3cdXWdRb8vWSJp+t2TdzlBcfb3VzH0iHapsmlKW21 OE0me3402iroEbR6qZrqCtg+76y3o01UDs1pKNxOC/n2KuIgJBsJuE0J975SGj2hut2b CImA== X-Gm-Message-State: AOAM532cOpl5xSQgB3Xqr7+LRtY68jtKt4ZMZOZcgxk6I/CQau7eWmmE YtrhYd7apeNB+NNozpmEEDZ7xQ== X-Received: by 2002:a50:8d18:: with SMTP id s24mr2314905eds.303.1592310695502; Tue, 16 Jun 2020 05:31:35 -0700 (PDT) Received: from localhost.localdomain (212-5-158-38.ip.btc-net.bg. [212.5.158.38]) by smtp.gmail.com with ESMTPSA id p6sm11071983ejb.71.2020.06.16.05.31.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jun 2020 05:31:35 -0700 (PDT) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Cc: Hans Verkuil , Ezequiel Garcia , Maheshwar Ajja , Mauro Carvalho Chehab , Stanimir Varbanov Subject: [PATCH 2/4] venus: venc: Add support for constant quality control Date: Tue, 16 Jun 2020 15:29:59 +0300 Message-Id: <20200616123001.11321-3-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616123001.11321-1-stanimir.varbanov@linaro.org> References: <20200616123001.11321-1-stanimir.varbanov@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Adds implementation of V4L2_CID_MPEG_VIDEO_CONSTANT_QUALITY v4l control when the bitrate mode is CQ. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/core.h | 1 + drivers/media/platform/qcom/venus/hfi_cmds.c | 49 ++++++++++++++++++- .../media/platform/qcom/venus/hfi_helper.h | 4 +- drivers/media/platform/qcom/venus/venc.c | 4 +- .../media/platform/qcom/venus/venc_ctrls.c | 6 +++ 5 files changed, 61 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index 7118612673c9..1bac30d4cf50 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -201,6 +201,7 @@ struct venc_controls { u32 bitrate; u32 bitrate_peak; u32 rc_enable; + u32 const_quality; u32 h264_i_period; u32 h264_entropy_mode; diff --git a/drivers/media/platform/qcom/venus/hfi_cmds.c b/drivers/media/platform/qcom/venus/hfi_cmds.c index c67e412f8201..de6660c5335d 100644 --- a/drivers/media/platform/qcom/venus/hfi_cmds.c +++ b/drivers/media/platform/qcom/venus/hfi_cmds.c @@ -1218,6 +1218,50 @@ pkt_session_set_property_4xx(struct hfi_session_set_property_pkt *pkt, return 0; } +static int +pkt_session_set_property_6xx(struct hfi_session_set_property_pkt *pkt, + void *cookie, u32 ptype, void *pdata) +{ + void *prop_data; + + if (!pkt || !cookie || !pdata) + return -EINVAL; + + prop_data = &pkt->data[1]; + + pkt->shdr.hdr.size = sizeof(*pkt); + pkt->shdr.hdr.pkt_type = HFI_CMD_SESSION_SET_PROPERTY; + pkt->shdr.session_id = hash32_ptr(cookie); + pkt->num_properties = 1; + pkt->data[0] = ptype; + + switch (ptype) { + case HFI_PROPERTY_PARAM_VENC_RATE_CONTROL: { + u32 *in = pdata; + + switch (*in) { + case HFI_RATE_CONTROL_OFF: + case HFI_RATE_CONTROL_CBR_CFR: + case HFI_RATE_CONTROL_CBR_VFR: + case HFI_RATE_CONTROL_VBR_CFR: + case HFI_RATE_CONTROL_VBR_VFR: + case HFI_RATE_CONTROL_CQ: + break; + default: + return -EINVAL; + } + + pkt->data[1] = *in; + pkt->shdr.hdr.size += sizeof(u32) * 2; + break; + } + default: + return pkt_session_set_property_4xx(pkt, cookie, ptype, pdata); + } + + return 0; +} + int pkt_session_get_property(struct hfi_session_get_property_pkt *pkt, void *cookie, u32 ptype) { @@ -1236,7 +1280,10 @@ int pkt_session_set_property(struct hfi_session_set_property_pkt *pkt, if (hfi_ver == HFI_VERSION_3XX) return pkt_session_set_property_3xx(pkt, cookie, ptype, pdata); - return pkt_session_set_property_4xx(pkt, cookie, ptype, pdata); + if (hfi_ver == HFI_VERSION_4XX) + return pkt_session_set_property_4xx(pkt, cookie, ptype, pdata); + + return pkt_session_set_property_6xx(pkt, cookie, ptype, pdata); } void pkt_set_version(enum hfi_version version) diff --git a/drivers/media/platform/qcom/venus/hfi_helper.h b/drivers/media/platform/qcom/venus/hfi_helper.h index f6613df1d16b..db29a6d4a293 100644 --- a/drivers/media/platform/qcom/venus/hfi_helper.h +++ b/drivers/media/platform/qcom/venus/hfi_helper.h @@ -231,6 +231,7 @@ #define HFI_RATE_CONTROL_VBR_CFR 0x1000003 #define HFI_RATE_CONTROL_CBR_VFR 0x1000004 #define HFI_RATE_CONTROL_CBR_CFR 0x1000005 +#define HFI_RATE_CONTROL_CQ 0x1000008 #define HFI_VIDEO_CODEC_H264 0x00000002 #define HFI_VIDEO_CODEC_H263 0x00000004 @@ -520,7 +521,8 @@ enum hfi_version { HFI_VERSION_1XX, HFI_VERSION_3XX, - HFI_VERSION_4XX + HFI_VERSION_4XX, + HFI_VERSION_6XX, }; struct hfi_buffer_info { diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index feed648550d1..c70cba29387a 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -740,8 +740,10 @@ static int venc_set_properties(struct venus_inst *inst) rate_control = HFI_RATE_CONTROL_OFF; else if (ctr->bitrate_mode == V4L2_MPEG_VIDEO_BITRATE_MODE_VBR) rate_control = HFI_RATE_CONTROL_VBR_CFR; - else + else if (ctr->bitrate_mode == V4L2_MPEG_VIDEO_BITRATE_MODE_CBR) rate_control = HFI_RATE_CONTROL_CBR_CFR; + else if (ctr->const_quality) + rate_control = HFI_RATE_CONTROL_CQ; ptype = HFI_PROPERTY_PARAM_VENC_RATE_CONTROL; ret = hfi_session_set_property(inst, ptype, &rate_control); diff --git a/drivers/media/platform/qcom/venus/venc_ctrls.c b/drivers/media/platform/qcom/venus/venc_ctrls.c index 8362dde7949e..43c50cf3199c 100644 --- a/drivers/media/platform/qcom/venus/venc_ctrls.c +++ b/drivers/media/platform/qcom/venus/venc_ctrls.c @@ -202,6 +202,9 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE: ctr->rc_enable = ctrl->val; break; + case V4L2_CID_MPEG_VIDEO_CONSTANT_QUALITY: + ctr->const_quality = ctrl->val; + break; default: return -EINVAL; } @@ -357,6 +360,9 @@ int venc_ctrl_init(struct venus_inst *inst) v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops, V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE, 0, 1, 1, 1); + v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops, + V4L2_CID_MPEG_VIDEO_CONSTANT_QUALITY, 0, 100, 1, 0); + ret = inst->ctrl_handler.error; if (ret) goto err; From patchwork Tue Jun 16 12:30:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 188017 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp3606786ilo; Tue, 16 Jun 2020 05:31:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHBAg350CfOY9koPOXkJZckJ0l3a300IdOYLUQQAOXYWCArupv/yU2BOe+pvWkjOdbszLU X-Received: by 2002:a05:6402:221b:: with SMTP id cq27mr2264177edb.302.1592310701694; Tue, 16 Jun 2020 05:31:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592310701; cv=none; d=google.com; s=arc-20160816; b=gXxXdNHjt/Qxv/v6X366GXf2XZpShVOz0JjinChDiquB+wBRbCVzOwAv7deq8j39Gj x0iKK8xKQJYqN+bmPOeXQzUELBXdBrcqS+RMMNyevFlop5qsevbrMCTQ3F79PC2vmZd3 MEAU+ZJhpWKczWj4lTqDQyDaL0tJdKW7c4MEKjH3lBXK4Uvda812MyE2X7gCkxvGbUIm nuzxlxX8DHjZyTOYu7NwIhmf4cBEeAOeEttG89qW6qcyW3eC77x2eFwI3YcGcwN595k7 mI6CNUbMOKZohOyzJmxZcxkVHSCwQXGKA2DCPkhWdznb4PBDmH8nhMt8hnsbPnVwgem0 v3tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=gW9cbjjRPD6R6Z7AF3iL+tqbW8lQcn4mBsQDieJZv9Y=; b=h9f6BdrLs1JnandrLUXicjBmmfcCXrpkdi11lnaiHepBcVC6mweeQpzn7y2v0oTIRF g2ZP91XGRQ/5zYdQXCm3Wj2z96EWu8PssDdb+e5uNpV67Ewz56CfZWbTz7hbrMhUHATY 4XFgEDaUd/wvuKS/IIAlLYlp5lJ2lmXP4hmPAXOgqLvmJfpZSbnJWJreiPa8Z6rN1Llc oj0Sks2TBu/5vcYk8z0SQkvmXmtv3F2x6famvbRO7KHgw8WJW4+cqnjOFPe9o1DLCSyy wSMCc0WDAu+q53tvelOMCn4fGuZ8rtTADsLSZAPQbTS5XW75AVaefzBedO5W+D92QxjX H+3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BZHtCB60; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h5si9498422edr.201.2020.06.16.05.31.41; Tue, 16 Jun 2020 05:31:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BZHtCB60; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728815AbgFPMbk (ORCPT + 16 others); Tue, 16 Jun 2020 08:31:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728880AbgFPMbj (ORCPT ); Tue, 16 Jun 2020 08:31:39 -0400 Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7959C08C5C2 for ; Tue, 16 Jun 2020 05:31:38 -0700 (PDT) Received: by mail-ed1-x541.google.com with SMTP id t21so14095468edr.12 for ; Tue, 16 Jun 2020 05:31:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gW9cbjjRPD6R6Z7AF3iL+tqbW8lQcn4mBsQDieJZv9Y=; b=BZHtCB60tWJPdqElhEU3iZEXInx6mH3ofR+IpXPVtDhfBby5ky8JIGXj4QtcCqkj7h Zz2+4sSRk8avHt4Zlj9NZ3teh6An3qOt85dgFhKaOuHAbH58rL5X1jG8hxZDFYzpLa2e Bz89PwSbZS79/kgQ0ifr9aCkseQ7BZXfqY85+EFY21XxVZepl4V3owbqKEh91o0oKgSs /IsGCx082Db1nRRc9Znmwks+4CwvnbDFr2TSpcU91ciPywQ2dBWOwwM50tVxJ4C0EDAq oGDGrPO88ruGiy0A21SdE6fEId2egf6i/cVexHbzU9mRCCCR8Ae3E+vt9KK6xHojewzZ lyJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gW9cbjjRPD6R6Z7AF3iL+tqbW8lQcn4mBsQDieJZv9Y=; b=qegqJs47bigtnYyyi3RuxMETkA+zyPTlF8WRsbxkev7VsE3wxE0zvp459gcR9XjY7R tg6Yi4VDHzgoPvy3rOS5ry32LcE5BJ4wX/ruYymswGvI5aeVd4en55jnPT1Pclml4yWG Yc+0FqqjPPeT/U5ICRVpjIF3eh1gei3dEk99lT2cjFx2CBHsL9H7EW6EvBpKOAArBJJ4 GoLkWZRlLWnkOsLzW8HaCPnS8NHfrzKJ5xyjvIa/yur+/Ej0+hB7GuuK1n4GenpW4scI O9LzSHGKQH/4eeb+MXvxWhLsmTsfLlGh87Kn61Y3KCEpXGdjuZ0RaSEpsl8FQ8QaRXjC arnw== X-Gm-Message-State: AOAM533ktAaUmIJHH/fcGJKrz/EnCW0hi4xFnGKb9pWuVqs8HkRDMSAB ch3mtBcrk/hGkNbuCZLFABaqVg== X-Received: by 2002:a50:fe07:: with SMTP id f7mr2338476edt.315.1592310697650; Tue, 16 Jun 2020 05:31:37 -0700 (PDT) Received: from localhost.localdomain (212-5-158-38.ip.btc-net.bg. [212.5.158.38]) by smtp.gmail.com with ESMTPSA id p6sm11071983ejb.71.2020.06.16.05.31.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jun 2020 05:31:37 -0700 (PDT) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Cc: Hans Verkuil , Ezequiel Garcia , Maheshwar Ajja , Mauro Carvalho Chehab , Stanimir Varbanov Subject: [PATCH 3/4] v4l2-ctrl: Add control for intra only decode Date: Tue, 16 Jun 2020 15:30:00 +0300 Message-Id: <20200616123001.11321-4-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616123001.11321-1-stanimir.varbanov@linaro.org> References: <20200616123001.11321-1-stanimir.varbanov@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org This adds a new decoder control to instruct the decoders to produce on its output intra frames only. Usually in this mode decoders might lower the count of output decoder buffers and hence reduce memory usage. Signed-off-by: Stanimir Varbanov --- .../userspace-api/media/v4l/ext-ctrls-codec.rst | 9 +++++++++ drivers/media/v4l2-core/v4l2-ctrls.c | 2 ++ include/uapi/linux/v4l2-controls.h | 1 + 3 files changed, 12 insertions(+) -- 2.17.1 diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst index b9d3f7ae6486..d7f34596f95b 100644 --- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst @@ -652,6 +652,15 @@ enum v4l2_mpeg_video_bitrate_mode - otherwise the decoder expects a single frame in per buffer. Applicable to the decoder, all codecs. +``V4L2_CID_MPEG_VIDEO_DECODE_INTRA_FRAMES_ONLY (boolean)`` + If enabled the decoder should start decoding only intra frames. The + decoder consume first input buffer for progressive stream (or first + two buffers for interlace). Decoder might not allocate more output + buffers than it is required to consume one input frame. Usually the + decoder input buffers will contain only intra frames but it is not + mandatory. This control could be used for thumbnails generation. + Applicable to the decoder, all codecs. + ``V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_ENABLE (boolean)`` Enable writing sample aspect ratio in the Video Usability Information. Applicable to the H264 encoder. diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index bc00d02e411f..2b1fb8dcd360 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -846,6 +846,7 @@ const char *v4l2_ctrl_get_name(u32 id) 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"; case V4L2_CID_MPEG_VIDEO_MAX_REF_PIC: return "Max Number of Reference Pics"; + case V4L2_CID_MPEG_VIDEO_DECODE_INTRA_FRAMES_ONLY: return "Decode intra frames only"; case V4L2_CID_MPEG_VIDEO_H263_I_FRAME_QP: return "H263 I-Frame QP Value"; case V4L2_CID_MPEG_VIDEO_H263_P_FRAME_QP: return "H263 P-Frame QP Value"; case V4L2_CID_MPEG_VIDEO_H263_B_FRAME_QP: return "H263 B-Frame QP Value"; @@ -1197,6 +1198,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, case V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_ENABLE: case V4L2_CID_MPEG_VIDEO_MPEG4_QPEL: case V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER: + case V4L2_CID_MPEG_VIDEO_DECODE_INTRA_FRAMES_ONLY: case V4L2_CID_WIDE_DYNAMIC_RANGE: case V4L2_CID_IMAGE_STABILIZATION: case V4L2_CID_RDS_RECEPTION: diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h index 0f7e4388dcce..c64471e64aa7 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -744,6 +744,7 @@ enum v4l2_cid_mpeg_video_hevc_size_of_length_field { #define V4L2_CID_MPEG_VIDEO_REF_NUMBER_FOR_PFRAMES (V4L2_CID_MPEG_BASE + 643) #define V4L2_CID_MPEG_VIDEO_PREPEND_SPSPPS_TO_IDR (V4L2_CID_MPEG_BASE + 644) #define V4L2_CID_MPEG_VIDEO_CONSTANT_QUALITY (V4L2_CID_MPEG_BASE + 645) +#define V4L2_CID_MPEG_VIDEO_DECODE_INTRA_FRAMES_ONLY (V4L2_CID_MPEG_BASE + 646) /* MPEG-class control IDs specific to the CX2341x driver as defined by V4L2 */ #define V4L2_CID_MPEG_CX2341X_BASE (V4L2_CTRL_CLASS_MPEG | 0x1000)