From patchwork Sat Sep 28 09:53:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 51906 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:d8ca:0:b0:48e:c0f8:d0de with SMTP id dy10csp897894vqb; Sat, 28 Sep 2024 03:01:24 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX/ZP7iOAZEnP65QhQWJwGVsaAGAbr1d0PVcII4GzghmG4M0bxTt5oAQMXAqibfIt1Pwjh1ZtAlNpmgTPcD/FWt@gmail.com X-Google-Smtp-Source: AGHT+IFA7zLl97aRVNxcgnMXSfBpkD70+apWAiHkvUlxctq2hKr8CHVDBp+JkTfvu2R2OKumOyc7 X-Received: by 2002:a05:651c:198c:b0:2f7:7c97:22b0 with SMTP id 38308e7fff4ca-2f9c6c58239mr37055851fa.4.1727517684372; Sat, 28 Sep 2024 03:01:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727517684; cv=none; d=google.com; s=arc-20240605; b=cezb5y9dF6h3iSoA6StkerskaU4M4x/YAfqtPtuIufgABIfGHrhxYPuMTkeRjELqvn 9WB6l3u/iF0+mrFvpnGlL3JbCFj+n1NltSdqLyTHZaufIbbXcSWmFlqbaops9ow/n1QF ldbJ4LjdISAe9cm0MnaR+xgkequ6PrrIBe7Nn4ISJx7z0F1t/oJJ5W8wXdbWRyA2EdL9 UyiQtEJx9wRoeCGxp3hoq6fjieherBHumBSMbdFctCj045QufY5GO46m1bFkDM/BmPQD ZiFGod84eRLT9J/bCYfbqRHiX3akApOZtBIvtQa6Ko3NMh3PFwvDmG7ZZKI7CAHx5FgZ WAZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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:dkim-signature:delivered-to; bh=1kAtPixJGk0fV1ewnV0YoznqRH6Ctde1ubvvpwC639Q=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=Oiu2OZw1zDPNlqV8/elyMhZlT2ZKym+l4Psyj6K4YSuHPvvh6ZXqmxEKKlF8F/WLmu kojGLuKtvrqe8VUpvv73odWg71OH7Gqo+OEfK8oWcWheh2qDYMRzRL+DAs5nZnuELhX8 Yk3DBJ6MINbghFxJmOXFyB/TgTMDflBzneIVMhgvPLEk9wPqdjjf2ppPorT3aO+Lc79X DyYFFVdx2XjeDjVBP2NT7Q4rj9QbOCDJCUt8PbWIBeJqPqVd43nESsOTyZ3q+sps48kv ILVmdRVu4EsW3xNTZ5LbCtkJ70s1MRovtMrbih0l29rM857LEnZjKQ0Von5V9MLgDrEy /aAA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=nQA+gBib; 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 38308e7fff4ca-2f9d4649a32si12317311fa.558.2024.09.28.03.01.23; Sat, 28 Sep 2024 03:01:24 -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; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=nQA+gBib; 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 E4B9968DC56; Sat, 28 Sep 2024 12:54:06 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5AAEC68DB31 for ; Sat, 28 Sep 2024 12:54:02 +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=nQA+gBib; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 2FEC44DF6 for ; Sat, 28 Sep 2024 11:53:57 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id FYUSbpQbPBI1 for ; Sat, 28 Sep 2024 11:53:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1727517234; bh=T6Sk6HHbhBUqmQloPKltj49LQCeQN6xVSZVarsY2dIc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=nQA+gBibu6Uqpovj9zj4Lfb9P8VvmcHujUsgKZVPf7g/+4Sc6KYfSt5me1NV06DEn csKePBkcxVk2tzfG9FUURRhi9M7V2gii4227DXqg55hZn3S1BvLheBAWf3WVUrLHoS W3WTmjtjx5BsL3XjHfHUKzrkSdFJyS6gIC/EmHbXKMsbYFbjVfueFBOGP+tnhe7vzl IL20UMiA2jQsyBzMfXsATBWoYblc26xDLnMQaTj+hUh3vYpnE6xdjKh2s1TeNR+lBz ZbxX7wSDP+/mAPGKSsagEFv5HIyCSzlJRiM4JlzkZ2hftmcAIJuzn1wB3kEUA+wC3r FKf2qiS8+Cq4g== 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 CC6534E0B for ; Sat, 28 Sep 2024 11:53:54 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 999F33A164C for ; Sat, 28 Sep 2024 11:53:48 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 28 Sep 2024 11:53:39 +0200 Message-ID: <20240928095341.15552-7-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240928095341.15552-1-anton@khirnov.net> References: <20240928095341.15552-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 7/9] fftools/ffmpeg_mux_init: move the check for filtering+streamcopy 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: /lNSThoijfDe To streamcopy_init(). This will allow to simplify the control flow in ost_add() by moving the ost_get_filters() call (which previously had to handle both encoding and streamcopy streams) to ost_bind_filter() (which is only called for audio/video encoding). Also, return EINVAL rather than ENOSYS, as trying to combine filtering with streamcopy is a parameter error. --- fftools/ffmpeg_mux_init.c | 52 ++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 117b1a4338..1ddd1d7492 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -424,27 +424,6 @@ static int ost_get_filters(const OptionsContext *o, AVFormatContext *oc, #endif opt_match_per_stream_str(ost, &o->filters, oc, ost->st, &filters); - if (!ost->enc) { - if ( -#if FFMPEG_OPT_FILTER_SCRIPT - filters_script || -#endif - filters) { - av_log(ost, AV_LOG_ERROR, - "%s '%s' was specified, but codec copy was selected. " - "Filtering and streamcopy cannot be used together.\n", -#if FFMPEG_OPT_FILTER_SCRIPT - filters ? "Filtergraph" : "Filtergraph script", - filters ? filters : filters_script -#else - "Filtergraph", filters -#endif - ); - return AVERROR(ENOSYS); - } - return 0; - } - if (!ost->ist) { if ( #if FFMPEG_OPT_FILTER_SCRIPT @@ -1028,7 +1007,8 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, OutputFilter *ofilter, return ret; } -static int streamcopy_init(const Muxer *mux, OutputStream *ost, AVDictionary **encoder_opts) +static int streamcopy_init(const OptionsContext *o, const Muxer *mux, + OutputStream *ost, AVDictionary **encoder_opts) { MuxStream *ms = ms_from_ost(ost); @@ -1044,6 +1024,32 @@ static int streamcopy_init(const Muxer *mux, OutputStream *ost, AVDictionary **e int ret = 0; + const char *filters = NULL; +#if FFMPEG_OPT_FILTER_SCRIPT + const char *filters_script = NULL; + + opt_match_per_stream_str(ost, &o->filter_scripts, mux->fc, ost->st, &filters_script); +#endif + opt_match_per_stream_str(ost, &o->filters, mux->fc, ost->st, &filters); + + if ( +#if FFMPEG_OPT_FILTER_SCRIPT + filters_script || +#endif + filters) { + av_log(ost, AV_LOG_ERROR, + "%s '%s' was specified, but codec copy was selected. " + "Filtering and streamcopy cannot be used together.\n", +#if FFMPEG_OPT_FILTER_SCRIPT + filters ? "Filtergraph" : "Filtergraph script", + filters ? filters : filters_script +#else + "Filtergraph", filters +#endif + ); + return AVERROR(EINVAL); + } + codec_ctx = avcodec_alloc_context3(NULL); if (!codec_ctx) return AVERROR(ENOMEM); @@ -1562,7 +1568,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, } if (ost->ist && !ost->enc) { - ret = streamcopy_init(mux, ost, &encoder_opts); + ret = streamcopy_init(o, mux, ost, &encoder_opts); if (ret < 0) goto fail; }