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 EC3F548532 for ; Fri, 5 Apr 2024 16:16:22 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C5AEB68D2D6; Fri, 5 Apr 2024 19:13:31 +0300 (EEST) Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 72F7D68D15D 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=I55dhm6n; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id E3C7B4D86 for ; Fri, 5 Apr 2024 18:13:08 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id lAVG3g-32z11 for ; Fri, 5 Apr 2024 18:13:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712333584; bh=9L2xsd6kBh9O0JLoDu4x12qhDVIcBDiKdDCWzjGD81Q=; h=From:To:Subject:Date:In-Reply-To:References:From; b=I55dhm6nR+awxymMl8H/VUWxHS4auhU3gv0kjnrvw96yRwectOFHNaPAurs2E4WZD 4n4WOnpZ9gY6RYbuJV6iiIQ61F6Qp4iFQewtVPAcSTSJw0QEj6nCJ0WEYtku6bEBXW WNFc87fhsNBjZxh98DnRkGMCTxRV3Bn4CfFcblgYoEd+RwaI2CGtLlq4nRJKEHBCcm yzMOdZWgBejWaZBIBwud4uczWtGiJiAdh/Zz1sFdMKR3rw3RXQ5iWjW8SMbiod4i/8 +IS4A5+mvVgAAu4WgDNvqZn5PDVW2sAOfa6P2EX2GvVve3VSOfRimMmuT3LRcfH0hV lffkSCJghBjmA== 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 998DD4D9C for ; Fri, 5 Apr 2024 18:13:03 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id B05373A1894 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:08 +0200 Message-ID: <20240405161212.26167-27-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 27/31] fftools/ffmpeg_filter: only store complex filtergraphs in global array 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: Store simple filtergraphs in the stream they feed. Keeping the two separate will be useful in following commits. --- fftools/ffmpeg.c | 5 +++++ fftools/ffmpeg.h | 3 +++ fftools/ffmpeg_filter.c | 16 +++++++++++++--- fftools/ffmpeg_mux.c | 1 + 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 0ee76d69b5..1f50ed6805 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -787,6 +787,11 @@ static int check_keyboard_interaction(int64_t cur_time) (n = sscanf(buf, "%63[^ ] %lf %255[^ ] %255[^\n]", target, &time, command, arg)) >= 3) { av_log(NULL, AV_LOG_DEBUG, "Processing command target:%s time:%f command:%s arg:%s", target, time, command, arg); + for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost)) { + if (ost->fg_simple) + fg_send_command(ost->fg_simple, time, target, command, arg, + key == 'C'); + } for (i = 0; i < nb_filtergraphs; i++) fg_send_command(filtergraphs[i], time, target, command, arg, key == 'C'); diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 6446a141b5..882d241bdb 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -582,6 +582,8 @@ typedef struct OutputStream { char *logfile_prefix; FILE *logfile; + // simple filtergraph feeding this stream, if any + FilterGraph *fg_simple; OutputFilter *filter; AVDictionary *encoder_opts; @@ -653,6 +655,7 @@ extern int nb_input_files; extern OutputFile **output_files; extern int nb_output_files; +// complex filtergraphs extern FilterGraph **filtergraphs; extern int nb_filtergraphs; diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 3988cf5fc2..388c8919fd 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1009,16 +1009,25 @@ int fg_create(FilterGraph **pfg, char *graph_desc, Scheduler *sch) AVFilterGraph *graph; int ret = 0; - fgp = allocate_array_elem(&filtergraphs, sizeof(*fgp), &nb_filtergraphs); + fgp = av_mallocz(sizeof(*fgp)); if (!fgp) return AVERROR(ENOMEM); fg = &fgp->fg; - if (pfg) + if (pfg) { *pfg = fg; + fg->index = -1; + } else { + ret = av_dynarray_add_nofree(&filtergraphs, &nb_filtergraphs, fgp); + if (ret < 0) { + av_freep(&fgp); + return ret; + } + + fg->index = nb_filtergraphs - 1; + } fg->class = &fg_class; - fg->index = nb_filtergraphs - 1; fgp->graph_desc = graph_desc; fgp->disable_conversions = !auto_conversion_filters; fgp->sch = sch; @@ -1135,6 +1144,7 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost, ret = fg_create(&fg, graph_desc, sch); if (ret < 0) return ret; + ost->fg_simple = fg; fgp = fgp_from_fg(fg); fgp->is_simple = 1; diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 2b7a733501..a1583edd61 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -797,6 +797,7 @@ static void ost_free(OutputStream **post) ms = ms_from_ost(ost); enc_free(&ost->enc); + fg_free(&ost->fg_simple); if (ost->logfile) { if (fclose(ost->logfile)) -- 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".