From patchwork Thu Mar 11 00:59:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Degawa X-Patchwork-Id: 26336 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id B46884497F0 for ; Thu, 11 Mar 2021 03:00:00 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 95CEB68ABE7; Thu, 11 Mar 2021 03:00:00 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from degawa.com (unknown [174.127.109.95]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DBFBC68AB7A for ; Thu, 11 Mar 2021 02:59:53 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=randomderp.com; s=default; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ugHOQSg9R+r6Y+hTNtklLP3TWqwOcGsC/Lnn6go7+LA=; b=lOEf6ux/KMy6+yPIZIVVFos2/i Wg26jiaJ4+W6d5dNaolxpiE8wcgg6AOvQfCb5om18OEXQUU9JQjimn2hJmJ2wXalAASfmJQYtGw2G WZaDbfc8pGPEVEyIqZ6deZv/g/CbhYuHfbkXsG/+3MZJqT+AxYt3SZE3v3LsUOBIvUOSSRA82jyWS J/57sXK+HKT9dOe5Ts6ibDhAd+6wZzp/OL3rtpJ1c+/GyzGOX/0NALLu3R4qkKSyufBIV5a7MlvOO DTerVzz020amc4ioi1vT8i/whZUvPq1jdxvy2ce7yjae4dW7Yd7LmgrBFk03iDKiSx97Ks/kLFNzg 2KCupfIQ==; Received: from 108-216-168-194.lightspeed.mmphtn.sbcglobal.net ([108.216.168.194]:46898 helo=localhost.localdomain) by slmp-550-1.slc.westdc.net with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lK9g7-0003KZ-2S; Wed, 10 Mar 2021 17:59:51 -0700 From: Christopher Degawa To: ffmpeg-devel@ffmpeg.org Date: Wed, 10 Mar 2021 18:59:46 -0600 Message-Id: <20210311005946.1764406-1-ccom@randomderp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210310061234.1412193-1-ccom@randomderp.com> References: <20210310061234.1412193-1-ccom@randomderp.com> MIME-Version: 1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - slmp-550-1.slc.westdc.net X-AntiAbuse: Original Domain - ffmpeg.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - randomderp.com X-Get-Message-Sender-Via: slmp-550-1.slc.westdc.net: authenticated_id: ccom/from_h X-Authenticated-Sender: slmp-550-1.slc.westdc.net: ccom@randomderp.com X-Source: X-Source-Args: X-Source-Dir: Subject: [FFmpeg-devel] [PATCH] libsvtav1: Add logical_processors option X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Christopher Degawa Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Christopher Degawa Used for limiting the size of memory buffers and threads for a target logical processor count, but does not set thread affinity or the total amount of threads used, although thread affinities can be controlled with an additional parameters, it is prefered to add them until a svtav1-params option or similar is added Signed-off-by: Christopher Degawa --- doc/encoders.texi | 7 +++++++ libavcodec/libsvtav1.c | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/doc/encoders.texi b/doc/encoders.texi index c9c8785afb..96dd60a899 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -1795,6 +1795,13 @@ Set log2 of the number of rows of tiles to use (0-6). @item tile_columns Set log2 of the number of columns of tiles to use (0-4). +@item logical_processors +Number of logical processors to run the encoder on, threads are managed by +the OS scheduler. Used for limiting the size of memory buffers and threads +for a target logical processor count. Does not set thread affinity or total +threads, but instead sets t * logical_processors amount of threads with t +being the amount of threads libsvtav1 sets per cpu (0 - ncpus). + @end table @section libkvazaar diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c index eb6043bcac..0f752dcdda 100644 --- a/libavcodec/libsvtav1.c +++ b/libavcodec/libsvtav1.c @@ -71,6 +71,8 @@ typedef struct SvtContext { int tile_columns; int tile_rows; + + uint32_t logical_processors; } SvtContext; static const struct { @@ -218,6 +220,8 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param, param->tile_columns = svt_enc->tile_columns; param->tile_rows = svt_enc->tile_rows; + param->logical_processors = svt_enc->logical_processors; + return 0; } @@ -533,6 +537,9 @@ static const AVOption options[] = { { "tile_columns", "Log2 of number of tile columns to use", OFFSET(tile_columns), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 4, VE}, { "tile_rows", "Log2 of number of tile rows to use", OFFSET(tile_rows), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 6, VE}, + { "logical_processors", "Number of logical processors to run the encoder on, used to limit the size of memory buffers and threads used", OFFSET(logical_processors), + AV_OPT_TYPE_INT, { .i64 = 0 }, 0, UINT_MAX, VE }, + {NULL}, };