From patchwork Fri Jul 7 09:48:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 42485 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1e:b0:12b:9ae3:586d with SMTP id c30csp7162350pzh; Fri, 7 Jul 2023 02:50:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlGZYnqHSaIIG9IzsR7THYrompEG5L/x8vLch/GdCgZ3y5CNk9cCdOGdbLDI7UyNJgBfaWvb X-Received: by 2002:aa7:d052:0:b0:51e:2a57:1d93 with SMTP id n18-20020aa7d052000000b0051e2a571d93mr3085729edo.16.1688723450836; Fri, 07 Jul 2023 02:50:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688723450; cv=none; d=google.com; s=arc-20160816; b=1GpWvne29m3SdLhvMY5G48usPXmkoNf9ByqjXAtTJ7ZO1aP0a/gu6dd0FqrvHSnklS iQazDrAbZEuIDeaypd76ndmRoKhRzU22T1547KEyFiK/zBFQSfqtIdHazkTzUoFMJMKm mBIlzYJPCHIWLHXDIj1ZK2w52LOQP7eGa8Tmrsh9cnmUNonvYrDkCtHXUwj0j2Io4/+3 Qal1b3DD6A1Xa8NikdMwg9Fs805xmg2THKTQor1n9NN5JkYuYI8AlVFWBk0ohZs4aHqH 6VUzjRvMyJSNULrMDyAEZUM4ppNg/EOiFyaTviFT3e6oJyMvZvs0nteARCbtpaP+OF+W BsFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=EXkqGeRev9wjGz32MC+VzmE+NxQEthlzB5BFtaa3z8c=; fh=8ZF2QtiKOjBtyn9wuO2cMeZaLsE4aq02Bq77gGK61E8=; b=E8khzYYMfBKjceNtkOwXGOyL5YcMD1qU2iBO2zZ4HpZw27ZkxDggFI/maV9sPcQ+Om 3gz7eHewad6gGS+18rJqPxOGjCDVS3UHbfWjzBP6Lwzb348BbAB6myXLiGn1OcE2hkAf ucnR2mxnT6M4mX4dnTT7z0PgDtgouR4E1zJY9dt45SSHm+R8vNuHx3MiNItUuEt34c48 CnadN+9rCy0IMFUhV9qH3SdQlBYVoU7p2m4s+h69tLld62smhyUmSxEm1wvhgDo5B/g3 jFjycFpVPceZkw5hbS3jmhMQ13Sd70TBGM37aRAwCm+rMBnYL4zfLFJfE1A6OE26N+GR rVtQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id f15-20020a056402160f00b0051e0caa2768si2009928edv.129.2023.07.07.02.50.50; Fri, 07 Jul 2023 02:50:50 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 37B9868C805; Fri, 7 Jul 2023 12:49:20 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C757368C7BC for ; Fri, 7 Jul 2023 12:49:08 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 917F52404EA for ; Fri, 7 Jul 2023 11:49:08 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id R3CyXLiQLKXC for ; Fri, 7 Jul 2023 11:49:08 +0200 (CEST) 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 mail0.khirnov.net (Postfix) with ESMTPS id 189B5240706 for ; Fri, 7 Jul 2023 11:49:01 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id BAE653A15A9 for ; Fri, 7 Jul 2023 11:48:54 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 7 Jul 2023 11:48:37 +0200 Message-Id: <20230707094847.25324-12-anton@khirnov.net> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230707094847.25324-1-anton@khirnov.net> References: <20230707094847.25324-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 12/22] fftools/ffmpeg_filter: consolidate calling avfilter_graph_set_auto_convert() 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: cWi7UkJga6mP Do not call it from choose_pix_fmts(), as that function is not supposed to modify random filtergraph properties. --- fftools/ffmpeg_filter.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index f60d1cd23b..caf85194c5 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -48,6 +48,7 @@ typedef struct FilterGraphPriv { // true when the filtergraph contains only meta filters // that do not modify the frame data int is_meta; + int disable_conversions; const char *graph_desc; @@ -321,8 +322,6 @@ static const char *choose_pix_fmts(OutputFilter *ofilter, AVBPrint *bprint) av_opt_set(ost->enc_ctx, "strict", strict_dict->value, 0); if (ost->keep_pix_fmt) { - avfilter_graph_set_auto_convert(ofilter->graph->graph, - AVFILTER_AUTO_CONVERT_NONE); if (ost->enc_ctx->pix_fmt == AV_PIX_FMT_NONE) return NULL; return av_get_pix_fmt_name(ost->enc_ctx->pix_fmt); @@ -679,6 +678,7 @@ void ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost) { OutputFilterPriv *ofp = ofp_from_ofilter(ofilter); FilterGraph *fg = ofilter->graph; + FilterGraphPriv *fgp = fgp_from_fg(fg); const AVCodec *c = ost->enc_ctx->codec; av_assert0(!ofilter->ost); @@ -695,6 +695,9 @@ void ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost) } else { ofp->formats = c->pix_fmts; } + + fgp->disable_conversions |= ost->keep_pix_fmt; + break; case AVMEDIA_TYPE_AUDIO: if (ost->enc_ctx->sample_fmt != AV_SAMPLE_FMT_NONE) { @@ -830,6 +833,7 @@ FilterGraph *fg_create(char *graph_desc) fg->class = &fg_class; fg->index = nb_filtergraphs - 1; fgp->graph_desc = graph_desc; + fgp->disable_conversions = !auto_conversion_filters; snprintf(fgp->log_name, sizeof(fgp->log_name), "fc#%d", fg->index); @@ -1587,7 +1591,7 @@ static int configure_filtergraph(FilterGraph *fg) configure_output_filter(fg, fg->outputs[i], cur); avfilter_inout_free(&outputs); - if (!auto_conversion_filters) + if (fgp->disable_conversions) avfilter_graph_set_auto_convert(fg->graph, AVFILTER_AUTO_CONVERT_NONE); if ((ret = avfilter_graph_config(fg->graph, NULL)) < 0) goto fail;