From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 57A1749193 for ; Fri, 5 Apr 2024 16:15:41 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 91A4168D27D; Fri, 5 Apr 2024 19:13:26 +0300 (EEST) Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5DDD068D198 for ; Fri, 5 Apr 2024 19:13:10 +0300 (EEST) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=Xyz4Rpt0; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 7EE9F4D92 for ; Fri, 5 Apr 2024 18:13:07 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id ezEe9EEvz9fp for ; Fri, 5 Apr 2024 18:13:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712333583; bh=CNg5CWI9DmgtiFTE5dXFmeF7DH1vce1+93UtMJm4gtc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Xyz4Rpt0euPsIMX5jDrflMRq5V2d3p6eYMX0ZZXHP0iIJ4OMnjLK2iQ1f4ehMkcEM Oljoa7Vx1aX2aaK02FcFIDl2wW8yKmsPbvNRbHd6J1GQQ2Tb7//HsNI9q8YTiwgeIC sp8dVDzSua+ZmNoc6xDirLET4bAIoAIH7Q6TO8RNDOCWYDm8f2o/hLuntj5yLx7rjx 3xQvnsxPODJFTYz1uTHbkU/RILwIsMDGeM7JEDRJsv3uPZDmueMyxe6uE2i8dO/O9O Um21l8/Bd5QYU1DM3fM4rhXrGwtJn6xmXbI5VwSTVxLYu0xWM3itb8w807GGzwHCYF 3qiIy15BTSxkA== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 95A164D8D for ; Fri, 5 Apr 2024 18:13:02 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 98E7F3A1826 for ; Fri, 5 Apr 2024 18:12:56 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Apr 2024 18:12:06 +0200 Message-ID: <20240405161212.26167-25-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240405161212.26167-1-anton@khirnov.net> References: <20240405161212.26167-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 25/31] fftools/ffmpeg_filter: accept encoder thread count through OutputFilterOptions X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Stop digging through encoder options manually. Will allow decoupling filtering from encoding in future commits. --- fftools/ffmpeg.h | 2 ++ fftools/ffmpeg_filter.c | 20 ++++++++++++++------ fftools/ffmpeg_mux_init.c | 5 +++++ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 7135d9563c..f77ec956b3 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -291,6 +291,8 @@ typedef struct OutputFilterOptions { AVDictionary *sws_opts; AVDictionary *swr_opts; + const char *nb_threads; + // A combination of OFilterFlags. unsigned flags; diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index ec17e99494..9fc6e32960 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -59,6 +59,8 @@ typedef struct FilterGraphPriv { const char *graph_desc; + char *nb_threads; + // frame for temporarily holding output from the filtergraph AVFrame *frame; // frame for sending output to the encoder @@ -976,6 +978,7 @@ void fg_free(FilterGraph **pfg) } av_freep(&fg->outputs); av_freep(&fgp->graph_desc); + av_freep(&fgp->nb_threads); av_frame_free(&fgp->frame); av_frame_free(&fgp->frame_enc); @@ -1165,6 +1168,13 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost, if (ret < 0) return ret; + if (opts->nb_threads) { + av_freep(&fgp->nb_threads); + fgp->nb_threads = av_strdup(opts->nb_threads); + if (!fgp->nb_threads) + return AVERROR(ENOMEM); + } + return 0; } @@ -1735,17 +1745,15 @@ static int configure_filtergraph(FilterGraph *fg, FilterGraphThread *fgt) if (simple) { OutputFilterPriv *ofp = ofp_from_ofilter(fg->outputs[0]); - OutputStream *ost = fg->outputs[0]->ost; if (filter_nbthreads) { ret = av_opt_set(fgt->graph, "threads", filter_nbthreads, 0); if (ret < 0) goto fail; - } else { - const AVDictionaryEntry *e = NULL; - e = av_dict_get(ost->encoder_opts, "threads", NULL, 0); - if (e) - av_opt_set(fgt->graph, "threads", e->value, 0); + } else if (fgp->nb_threads) { + ret = av_opt_set(fgt->graph, "threads", fgp->nb_threads, 0); + if (ret < 0) + return ret; } if (av_dict_count(ofp->sws_opts)) { diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index ffcc20a504..10421ae1b0 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -1370,6 +1370,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, if (ost->enc && (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) { + const AVDictionaryEntry *e; char name[16]; OutputFilterOptions opts = { .enc = enc, @@ -1395,6 +1396,10 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, snprintf(name, sizeof(name), "#%d:%d", mux->of.index, ost->index); + e = av_dict_get(ost->encoder_opts, "threads", NULL, 0); + if (e) + opts.nb_threads = e->value; + // MJPEG encoder exports a full list of supported pixel formats, // but the full-range ones are experimental-only. // Restrict the auto-conversion list unless -strict experimental -- 2.43.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".