From patchwork Tue Jan 30 11:23:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kumar Garg X-Patchwork-Id: 194017 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1146546dyb; Tue, 30 Jan 2024 03:25:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IH8mqAnZivrLTnFWPZ3uN1T/4i8vAd0f52c54qPD81FJ9nUFKxeyOPYh0U5N8sgkubMmoYl X-Received: by 2002:a05:6402:17ce:b0:55f:1ae8:2f1d with SMTP id s14-20020a05640217ce00b0055f1ae82f1dmr2352726edy.11.1706613909919; Tue, 30 Jan 2024 03:25:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706613909; cv=pass; d=google.com; s=arc-20160816; b=u+bBRrE0mX9jSge1dszz7kFs2H9Y/vp+2+BqKuDfSM43Kry8KxJAMhEYRWdTcEswKV g/F3i5LiZ8FhJ3DdIn0mSUv64BlmSRbi+hiCgIvt0EIJWTz8v/g+2bF3ESWIe6lAkWpa +ZBpvSzO0JJn0CRc+pi4UARP8LsucpL24ES3MS2t9WmFvsAdd6NSYpSb55IJMlRjrlkQ i/PQ51aV30m86qv75E1mIf8xyNlekhdNAyAMowhPZztMdKwaqlhsGC/SxuiLxw2wRyPc 4rmaAgnpQOPcH+aiZK2rByUWagdC6Qv8x4urOYL1kaWiSOlJG+4xD8Hd9/ygQL9Jbo4V 4KoQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=19/E3FYg6etQ1bcM7OtOpZ5QOGxHV/AWg0H8PpSM8FA=; fh=RUIHxiPuysnITYgi1zfYboGnIViDNq7v9yrNqYwC7bs=; b=QTxobouKqRqEFb81bOjY3npSsQ4ipkrj4HOByZM7JjgHnwl6t6SA5Jn8qx2qcUsd5z FB0Wjh/XdPziIjbqemIwwutjmgAZ0ANR/QKSJ2p1KnMQnaRDoeORgV/VUwOw3bVp8g7S 2hQuteb784PHs3/sDKEQPTET84NnvdQCO+TGOrQGU9J4hg26oR70WRRnMSxQdJk0BkiJ 0LXARS8ZZd5NVKve04jGf5gF3NR5EzB/gA1oaHqxruLx6z6QFRb47zeOWp30B1Aa8Iz/ aiKdYV0qK/ZNzqWnrnuA8Puq5UJ5bwYBrY8rHaX/hVg2NqBEf25mDqXC4zBoHcTRHfNh sMgQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=GyqDZ84M; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-44504-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44504-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id i28-20020a50d75c000000b0055eee49de08si2303311edj.250.2024.01.30.03.25.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 03:25:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-44504-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=GyqDZ84M; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-44504-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44504-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8B6F41F22624 for ; Tue, 30 Jan 2024 11:25:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A878567A01; Tue, 30 Jan 2024 11:24:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="GyqDZ84M" Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 64D1B66B5F; Tue, 30 Jan 2024 11:24:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706613872; cv=none; b=HOciMSD2Zmuz0hZ/CO1K0nM/ddUhYNyO9pFa4GaF49OeXaLTU6WVxgleWxE8E++JRI5b2FglT7XIreIPFwEX4WT5a+HWtEMKEvwDnCojmWwBB8Ouidvw5gkgdZRhloPNmzrnm3o+lK14iYSInWr8JLlGh0FjiMcy7C01Evf8se4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706613872; c=relaxed/simple; bh=s9YWx0niqq/0hb6eo0iRhIrN+Gm4N4nnCpUXz+Ce8zM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=V5krBxMpEjO1uAfUWVqA9HEQtNmJvGRUj0qR3evRDAtHstLz/u5LYYugqH1ssB/Oax+4un26v/OD3huMoV+HmFSJCQGUvXHeVDYPWyTQLFAmkNS0K2dwqeSLzEHuK7KOsUtbcYNfuSVcCTqpR6mgjpPZjqZW+ttGVkQYjKuCD7M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=GyqDZ84M; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40UATqTk004958; Tue, 30 Jan 2024 11:24:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= qcppdkim1; bh=19/E3FYg6etQ1bcM7OtOpZ5QOGxHV/AWg0H8PpSM8FA=; b=Gy qDZ84MLyhSN1m/EYlxbWJM7b+0h+A+/gDkizI8xfzDdomosS3QIGiZ82Hj42SjSr km1y2Am4K6AktAwNeUJpjgrdPM+B1AX6DDGrDgc46Cy14NTkrEoJO2Hx9ZvcqsKK 1JDCRSB853Tx5F1aHgFA3egnJ6HBLOW/ZIYkfLEUVXxqtYaG8Wuxk2Yd5R1CwAu3 C9QLCp8/JhLIGRZ2B/QKH1oGdXr7o4SV0lJXVRn8M1ka5drX+PtBSZEFKVPX9RB4 7jfPDUomJMLlRNGMPwYBgBwRpEXLjJA036hO2payrfqYiHgmBM/s3xKCXVtSoRV2 j3EkjZ5zpyAo2hMpBQKg== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vxydh03fn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 30 Jan 2024 11:24:26 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 40UBOQsg020891 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 30 Jan 2024 11:24:26 GMT Received: from hu-sachinku-hyd.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Tue, 30 Jan 2024 03:24:22 -0800 From: Sachin Kumar Garg To: , Mauro Carvalho Chehab , Stanimir Varbanov , Vikash Garodia , Andy Gross , Bjorn Andersson , Konrad Dybcio CC: Bryan O'Donoghue , , , Subject: [PATCH v2 1/2] media: v4l2-ctrls: add encoder maximum bitrate control Date: Tue, 30 Jan 2024 16:53:59 +0530 Message-ID: <20240130112400.2636143-2-quic_sachinku@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240130112400.2636143-1-quic_sachinku@quicinc.com> References: <20240130112400.2636143-1-quic_sachinku@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: EwQWnUDYolg4O80HRohGrAu06qJPOck8 X-Proofpoint-GUID: EwQWnUDYolg4O80HRohGrAu06qJPOck8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-30_05,2024-01-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 phishscore=0 mlxscore=0 malwarescore=0 clxscore=1011 spamscore=0 impostorscore=0 lowpriorityscore=0 suspectscore=0 priorityscore=1501 mlxlogscore=771 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401190000 definitions=main-2401300083 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789514387113811444 X-GMAIL-MSGID: 1789514387113811444 Introduce V4L2_MPEG_VIDEO_BITRATE_MODE_MBR rate control to limit the frame level maximum bit rate. Encoder will choose appropriate quantization parameter and do the smart bit allocation to set the frame maximum bitrate level as per the Bitrate value configured. Signed-off-by: Sachin Kumar Garg --- Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst | 2 ++ drivers/media/v4l2-core/v4l2-ctrls-defs.c | 1 + include/uapi/linux/v4l2-controls.h | 1 + 3 files changed, 4 insertions(+) diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst index 2a165ae063fb..05ef4a70e3f5 100644 --- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst @@ -576,6 +576,8 @@ enum v4l2_mpeg_video_bitrate_mode - - Constant bitrate * - ``V4L2_MPEG_VIDEO_BITRATE_MODE_CQ`` - Constant quality + * - ``V4L2_MPEG_VIDEO_BITRATE_MODE_MBR`` + - Maximum bitrate diff --git a/drivers/media/v4l2-core/v4l2-ctrls-defs.c b/drivers/media/v4l2-core/v4l2-ctrls-defs.c index 8696eb1cdd61..e0597b61ffb9 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c +++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c @@ -154,6 +154,7 @@ const char * const *v4l2_ctrl_get_menu(u32 id) "Variable Bitrate", "Constant Bitrate", "Constant Quality", + "Maximum Bitrate", NULL }; static const char * const mpeg_stream_type[] = { diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h index 99c3f5e99da7..7c74d6c417d1 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -393,6 +393,7 @@ 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, + V4L2_MPEG_VIDEO_BITRATE_MODE_MBR = 3, }; #define V4L2_CID_MPEG_VIDEO_BITRATE (V4L2_CID_CODEC_BASE+207) #define V4L2_CID_MPEG_VIDEO_BITRATE_PEAK (V4L2_CID_CODEC_BASE+208) From patchwork Tue Jan 30 11:24:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kumar Garg X-Patchwork-Id: 194020 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1148218dyb; Tue, 30 Jan 2024 03:28:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IEXXws/hf8Ubq5T6YgQ+FT2z2lHbXaREvgx9bsdBBpdoiN+1cVwagcIGRlrH7HR2gHJaLVw X-Received: by 2002:a17:90a:6889:b0:292:6c68:fc70 with SMTP id a9-20020a17090a688900b002926c68fc70mr5259853pjd.20.1706614133640; Tue, 30 Jan 2024 03:28:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706614133; cv=pass; d=google.com; s=arc-20160816; b=z4Opz64KTQ0ASfGE2WlHsB/4s4v1vq+hWtTUBdjL6p/erKeimGnF9jPdWBlIjxjbz7 VKCPPYgu9/DppWlH+pTXjhoIDHZxXEwWUySZfl1K7NLqm978p5+Tb1rrISCR92WZhcRO gXtjf8Dl1hiKtP4c8AVi1VuE/wL6cpeI6f1zVvkToL3pxmoiTx5++/kASDgn7xzgC2xb yW2u57803HcNFLXC1HWwX4K97ncfKqHvWSiGImDjHrQ/1QSUyxvfz7qm2seW5EgEnDvL EW8p8irYo0MM1WdzUvOKNj+3bcTZzA/mqFKMHIwMGK2L28VI4dJgoKg/EJRs7ExPZuyk gRbA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=uiCF3OXqUPyaGiKkRjUFI/DkOvlguaMrc70vArbkT24=; fh=RUIHxiPuysnITYgi1zfYboGnIViDNq7v9yrNqYwC7bs=; b=GUu6dqyL41Gt56sFW2K98YYATPjKF8P+iW+VBge6dNCp3516ntH+eKZlV58BmO1FB/ 5syjO+3ChBiNbDWYwZ4yXkP//Y6v4b7ohMK64auqNMAs0L9GzRm9yJklzCzVGUCDP8g3 +re1SJmr5kgDH2GHeLvK5GcrqIA3yBS7bAsKClYVYgwJAQxu1bv8i5QmtJOZFnsmjMzt GBQeFgINaHKD3FyAbbteTzp3IrDxTJioANWbkZAbcUKN+nPD7dN5jAPew6q/RSquZQjK +R3Hi8Q8eVUdoXGi7la26HrWwuXWEb+WSI0MiZYYUZ0AUe9460Y8C+z4hn+Aer+Pvzvn zbbA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=XKWO2fZ9; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-44505-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44505-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id go19-20020a17090b03d300b00293e1a93496si7411574pjb.63.2024.01.30.03.28.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 03:28:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-44505-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=XKWO2fZ9; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-44505-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44505-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 0CB622924A2 for ; Tue, 30 Jan 2024 11:25:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 262AA67E6A; Tue, 30 Jan 2024 11:24:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="XKWO2fZ9" Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9ECF667A00; Tue, 30 Jan 2024 11:24:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706613877; cv=none; b=QsZPSg+NlbuyQUYqvD9z1rz7MxDCP2BzQcjvqVQqFnf8OKkDTTooIa4QVbJS9Us/WskRj4t9zzXiYS4OotBDQb0PKH3OpCHJzYie/FvTMF7kt5v0xvy2OZfjsJXqvPq1KrGTdO2xTEfC8xx6qJaqhPjj2Fuspmflc28+iH6xfaA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706613877; c=relaxed/simple; bh=Bz35TTRa8a3uBvuKzhZpF+dDo7xUztE14B9CFHxL7nU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mCjQH86wBIT5LDD9tsGzpZkLxseHaVkQR6Y0tu3UZJbmot0vNT6AKLVET2arUCNEUw1uJzZC6jKT3A3OWtrZ3yJTMVYl6zN9ywXdIgBNj8pJziy0QZLLfib5axwG4eerkBlVBPgsvaQsupuSDegf9OH44c/4QPRzkdLCDoCVGog= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=XKWO2fZ9; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40U9Rh2s022976; Tue, 30 Jan 2024 11:24:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= qcppdkim1; bh=uiCF3OXqUPyaGiKkRjUFI/DkOvlguaMrc70vArbkT24=; b=XK WO2fZ9c6Jxke5SBtQTu8uH4NxKVudz30Ufu0i7M2HOqWklSAcQ/Ekpv18TwzcFtD q5ke+wsNdZcFqGVY9tpbAi2qVMnHsIlp0oRlGuZntemXEZ9NA9CXtyYPSZoXRypu 6pCGtTNul/823r8velApSFtXBX/+oSQ8z68F8U8ivtohCBjonMdraG/u4QGx6MuM T9U1togjb9TPU0tABrPJKNNtQSxnIqK19yEwwYFJe3V4rZY08+5I2cSRPUCib8gt ArIkEN09qUZ7t7Z8S78PGkOQ0G69wxclTQFnWbBCRumQEa9fGhj1h2lzuBKMRKIU Pc6lohwKZY0zAfr41nTQ== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vxwwv8ack-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 30 Jan 2024 11:24:30 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 40UBOUbA015606 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 30 Jan 2024 11:24:30 GMT Received: from hu-sachinku-hyd.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Tue, 30 Jan 2024 03:24:26 -0800 From: Sachin Kumar Garg To: , Mauro Carvalho Chehab , Stanimir Varbanov , Vikash Garodia , Andy Gross , Bjorn Andersson , Konrad Dybcio CC: Bryan O'Donoghue , , , Subject: [PATCH v2 2/2] media: venus: add new rate control type MBR for encoder Date: Tue, 30 Jan 2024 16:54:00 +0530 Message-ID: <20240130112400.2636143-3-quic_sachinku@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240130112400.2636143-1-quic_sachinku@quicinc.com> References: <20240130112400.2636143-1-quic_sachinku@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: gorfjEJiDiRxGyYaIggDmceUlcq636uk X-Proofpoint-ORIG-GUID: gorfjEJiDiRxGyYaIggDmceUlcq636uk X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-30_05,2024-01-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxscore=0 suspectscore=0 lowpriorityscore=0 priorityscore=1501 malwarescore=0 spamscore=0 phishscore=0 bulkscore=0 adultscore=0 clxscore=1015 mlxlogscore=870 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401190000 definitions=main-2401300083 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789514621539199865 X-GMAIL-MSGID: 1789514621539199865 There is no limit on the maximum level of the bit rate with the existing VBR rate control. V4L2_MPEG_VIDEO_BITRATE_MODE_MBR rate control will limit the frame maximum bit rate range to the +/- 10% of the configured bit-rate value. Encoder will choose appropriate quantization parameter and do the smart bit allocation to set the frame maximum bitrate level. Signed-off-by: Sachin Kumar Garg --- Changes since v1: - Addressed comment related to code replication - Addressed comment for handling of MBR RC for non supported SOCs drivers/media/platform/qcom/venus/hfi_cmds.c | 7 +++++++ drivers/media/platform/qcom/venus/hfi_helper.h | 1 + drivers/media/platform/qcom/venus/venc.c | 2 ++ drivers/media/platform/qcom/venus/venc_ctrls.c | 5 +++-- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/qcom/venus/hfi_cmds.c b/drivers/media/platform/qcom/venus/hfi_cmds.c index 3418d2dd9371..b6a9e8b54fe1 100644 --- a/drivers/media/platform/qcom/venus/hfi_cmds.c +++ b/drivers/media/platform/qcom/venus/hfi_cmds.c @@ -653,6 +653,13 @@ static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, case HFI_RATE_CONTROL_VBR_VFR: case HFI_RATE_CONTROL_CQ: break; + case HFI_RATE_CONTROL_MBR_CFR: + if (hfi_ver == HFI_VERSION_4XX) { + break; + } else { + ret = -ENOTSUPP; + break; + } default: ret = -EINVAL; break; diff --git a/drivers/media/platform/qcom/venus/hfi_helper.h b/drivers/media/platform/qcom/venus/hfi_helper.h index e4c05d62cfc7..a0fd857f5c4b 100644 --- a/drivers/media/platform/qcom/venus/hfi_helper.h +++ b/drivers/media/platform/qcom/venus/hfi_helper.h @@ -232,6 +232,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_MBR_CFR 0x1000006 #define HFI_RATE_CONTROL_CQ 0x1000008 #define HFI_VIDEO_CODEC_H264 0x00000002 diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index 3ec2fb8d9fab..8acbb05f6ce8 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -807,6 +807,8 @@ static int venc_set_properties(struct venus_inst *inst) HFI_RATE_CONTROL_CBR_CFR; else if (ctr->bitrate_mode == V4L2_MPEG_VIDEO_BITRATE_MODE_CQ) rate_control = HFI_RATE_CONTROL_CQ; + else if (ctr->bitrate_mode == V4L2_MPEG_VIDEO_BITRATE_MODE_MBR) + rate_control = HFI_RATE_CONTROL_MBR_CFR; 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 d9d2a293f3ef..c9c3b1b45525 100644 --- a/drivers/media/platform/qcom/venus/venc_ctrls.c +++ b/drivers/media/platform/qcom/venus/venc_ctrls.c @@ -387,10 +387,11 @@ int venc_ctrl_init(struct venus_inst *inst) v4l2_ctrl_new_std_menu(&inst->ctrl_handler, &venc_ctrl_ops, V4L2_CID_MPEG_VIDEO_BITRATE_MODE, - V4L2_MPEG_VIDEO_BITRATE_MODE_CBR, + V4L2_MPEG_VIDEO_BITRATE_MODE_MBR, ~((1 << V4L2_MPEG_VIDEO_BITRATE_MODE_VBR) | (1 << V4L2_MPEG_VIDEO_BITRATE_MODE_CBR) | - (1 << V4L2_MPEG_VIDEO_BITRATE_MODE_CQ)), + (1 << V4L2_MPEG_VIDEO_BITRATE_MODE_CQ) | + (1 << V4L2_MPEG_VIDEO_BITRATE_MODE_MBR)), V4L2_MPEG_VIDEO_BITRATE_MODE_VBR); v4l2_ctrl_new_std_menu(&inst->ctrl_handler, &venc_ctrl_ops,