From patchwork Fri Apr 5 16:11:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47831 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1069074pzd; Fri, 5 Apr 2024 09:13:42 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVASiUL9UI4LCnm3c7hRtMZXfu92D+IdivNhoHQNDiKlklV9Rw26Ajptd+M1CodPX3Y7/9B44nHJGj3+/4xDLRKKpzM0tc2Vypm7g== X-Google-Smtp-Source: AGHT+IHeAv+WbiF1ELVPPz1HahvhmYsMFboiFlokPFN4+lC4VkePsVM4Bv3Lzl0B3wwBi17ej6rM X-Received: by 2002:ac2:5194:0:b0:516:d24a:3d72 with SMTP id u20-20020ac25194000000b00516d24a3d72mr1279650lfi.8.1712333622367; Fri, 05 Apr 2024 09:13:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712333622; cv=none; d=google.com; s=arc-20160816; b=IErFzrvOJnISIjBAuXzw/trg5umAEAlW8nCrKSzHWd4imE8NfsnAF5NC6Yew+ubDFk NVkH4mwIhHhF8Sy4yydEtwQtpsPti4Pqkxg60HYdp+U9NAhEkwLJGEfIsIJfsa6pFht6 j2uJ+7aziqDt1PSVQHVwUu1qXJBcHNH+c45V0xQ8BxdjP/+wAsKAmH/+X4NGESwNbhGc IPHhGae6Jcrwnsitl3NqDtWKLJ9owaokLVAGRjbn57sviSlb+4ayQRM8FtXRhoyMUE3z mtUEyEjKhsq6/KJMZck7C2rsZ0XDg0fNj/Bh+Ppqq1jrLdlimL/Hx7eT597cVMjt+cLw WbiA== 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:message-id:date:to:from :dkim-signature:delivered-to; bh=kHQkG0gKLhp2splwx1xeH53vJJS9KJ60a7vA7Wi3Gr4=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=e5zW5UnWSeOcpqd/bI42Skk0IsZIxS0nynjn8riankVZrzGY6Wjbzh4nwk5okbWnuq aIWvGMOU2ZJkFoSQdFsmobsT9+0siHMyoWBtAPNUoekUB1ynj9eb4oRkcnzM5ztbco6X iyuZ3dsYAKD3GO5W95D2zTYcG4Ipcxg+XdtbDqpiSZCORoKrhl0gRh6ehcDR6R6RSmky AXDOBeZd4bd3CFGxD2/Xb2zMmUGJoGOfNPqr1+Ll/gTsxd/YmFh+p0cmo2IFRVLoQ4LJ +mVfM9TNEPvLwUjC9/dRd9fNOl4WxJLDZXW+hkEn/sBmp9xMSmG5MH6OtB9QQA7eQj35 fznA==; 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=YNYvXRa0; 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 c8-20020a05640227c800b0056e0ddfcf73si893679ede.204.2024.04.05.09.13.40; Fri, 05 Apr 2024 09:13:42 -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=YNYvXRa0; 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 B4CCA68D222; Fri, 5 Apr 2024 19:13:13 +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 821E368D14A for ; Fri, 5 Apr 2024 19:13:04 +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=YNYvXRa0; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id A061F4D48 for ; Fri, 5 Apr 2024 18:13:03 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id GHflJiXBYuch for ; Fri, 5 Apr 2024 18:13:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712333581; bh=6FYi36CTa/QLDAuLPHC24g8bMkCPqd5xv0tGgCJve1M=; h=From:To:Subject:Date:From; b=YNYvXRa0IAHDu61FPequXCZYAJhAal1Q3NbWd61r8S1kzNZnJkWmFIZAmYrda8Nd8 srbzgdZlXaVZGYW+UvXfRzv6UXzS4maPAQsjIyLd3ev/K4WOMoHPfn8hmpQXVGPxNM PljinozLrMT606Ffz42sDv6pNJ5VIJ7YDHFjkjIyu+5Q0tyK0Gdeo+NeNrPeDnUoa/ tKigodfBy8VJsWrEeBF9LG+dJfWzF4ngfT3HLvlF/jgNttkjmP6kiYE8IUXTlI7c6y 5RP1f50ME3GtZVUYCyVa3CjR+jWhbxqUBWIpY84i+69k6Y7S/WlPdTNpCGA/tS3/A+ OT2wbix2hOAXA== 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 E3CBA1C2D for ; Fri, 5 Apr 2024 18:13:01 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 730F83A03D8 for ; Fri, 5 Apr 2024 18:12:55 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Apr 2024 18:11:42 +0200 Message-ID: <20240405161212.26167-1-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/31] lavfi/vf_scale: fix AVOption flags for "size"/"s" 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: AcF0+LmYXWlv --- libavfilter/vf_scale.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index fc0e3802db..1c07daeddf 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -998,8 +998,8 @@ static const AVOption scale_options[] = { { "height","Output video height", OFFSET(h_expr), AV_OPT_TYPE_STRING, .flags = TFLAGS }, { "flags", "Flags to pass to libswscale", OFFSET(flags_str), AV_OPT_TYPE_STRING, { .str = "" }, .flags = FLAGS }, { "interl", "set interlacing", OFFSET(interlaced), AV_OPT_TYPE_BOOL, {.i64 = 0 }, -1, 1, FLAGS }, - { "size", "set video size", OFFSET(size_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, FLAGS }, - { "s", "set video size", OFFSET(size_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, FLAGS }, + { "size", "set video size", OFFSET(size_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, .flags = FLAGS }, + { "s", "set video size", OFFSET(size_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, .flags = FLAGS }, { "in_color_matrix", "set input YCbCr type", OFFSET(in_color_matrix), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, AVCOL_SPC_NB-1, .flags = FLAGS, .unit = "color" }, { "out_color_matrix", "set output YCbCr type", OFFSET(out_color_matrix), AV_OPT_TYPE_INT, { .i64 = AVCOL_SPC_UNSPECIFIED }, 0, AVCOL_SPC_NB-1, .flags = FLAGS, .unit = "color"}, { "auto", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = -1 }, 0, 0, FLAGS, .unit = "color" }, From patchwork Fri Apr 5 16:11:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47830 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1068937pzd; Fri, 5 Apr 2024 09:13:29 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVTn3P7fVmUezjCjV2PCmX/VVSoDU3XhfSr43lwhM6ICnxaz045TSH1jS9VBy9mzo3tupw1ikk9Q69dA8HxT9zo3Re3wRqVVcjngw== X-Google-Smtp-Source: AGHT+IFmdsQDcw51CF6HRWjqddYdUP1wJiI0TWhyqSWrVjCWk6vCbQkOpQ6U/B+FxmkY3iQe6gJQ X-Received: by 2002:a17:906:4e93:b0:a51:9d6e:a77b with SMTP id v19-20020a1709064e9300b00a519d6ea77bmr1186825eju.0.1712333609286; Fri, 05 Apr 2024 09:13:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712333609; cv=none; d=google.com; s=arc-20160816; b=Xx5FyCVUtE5wZtMQzAwDA0ZnA4b/7CpVkpHgJFGVkAhr6y69RAFRiNa9AIIHui+5h0 m7L7u+W5jGiuJEOhDFCyRQGmUAgZ3ulLll0jTfPe4rUjx8Cg+dJbVuBhibSj8dZK9T54 oRIhHdnqGlr5oU6247mm6S1R9GNabry3lxr8ERGXW0bqDYEYdOIcc2ViG3zgRCqihOkJ e4coy0SmY2dlfy6pdfAKlz06Iubt5es6J7psPGpOltTnFNy5HILD9ixP+CbievblDMor bFKX0kfNeDuhA91hlnik+d9mA89J8qwZgzHZYEY2taOXNnWscE7O8K/tyUDb1n23XkfH W6oA== 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:dkim-signature:delivered-to; bh=N0iESBcrJYJemGorFK2IH1Vf2Mlp42ani3IEgkHT1Zo=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=VsEiEItspiQX7xMEAn9qnb/koJJEqZXO4gZFhagEbPEq3T7MsYXiXwP5Cem/aBTgiF YhgVUf8sWckiK4r077yAKjyhEjYmiNArStcFHoHZcajJrWRJDLtr8iSRyQfw78sq/VqR tS9ybC8GOM+kk+iQZwkgKP+HPECbwkOTilCEx62AHvhwaggDLYdO+Pn+s/jRWtakZQ9x HP+u+r7mgaBV+pMZ6cNeWjSHlk5WEg8GTllW78VPTHYPVHhjCLWgIhkXe1E+g5lenA0Y wJt17XBkSfh2L+OTHwpqZAaCllZHkm11t5CoTvTabeUYSii2N8lZAViAhzi2yPBTvCys 62QA==; 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=dDl6lncR; 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 ck7-20020a170906c44700b00a4720ded97dsi830621ejb.185.2024.04.05.09.13.28; Fri, 05 Apr 2024 09:13:29 -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=dDl6lncR; 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 AE5B868D21C; Fri, 5 Apr 2024 19:13:12 +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 7FA1A68D13B for ; Fri, 5 Apr 2024 19:13:04 +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=dDl6lncR; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 2299C4D82 for ; Fri, 5 Apr 2024 18:13:03 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id 6Jn5xOhxd7-K for ; Fri, 5 Apr 2024 18:13:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712333581; bh=UrFHyr8qZGnTT44anfv00nQz36JzG9zeVTol9PuXHzw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=dDl6lncROGeSOZO6HnAUNsx/8AXrVj8Vv78U4vLVip7T3U9ULaSFZzy/4cm0trC5o qCtfszSAsLJWZqOte2Q8i7gyN29FioKo1JQkaIE+cEkp3wlGW7lw+cwhe34zu5HKmk WpA3pVmE7nLuKQ6YgE2rFAdiutwoZapfCuIdECUhSS44LQHypdKDhca4npln9sViU6 sem7tZ1cQP2jgJFw8QlmVlszYk++Qil0N7IfYDxaWV2nHIJaQGNVcJBE8GBvL9VcVG idjhsEr95DTDAgXMSEX34rwkUmMr3YR2tUHzzGOqNLlxMSS37SvDreeQBl2bF69Bct llRzn1OSx/7Fw== 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 E126025F for ; Fri, 5 Apr 2024 18:13:01 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 802233A059E for ; Fri, 5 Apr 2024 18:12:55 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Apr 2024 18:11:43 +0200 Message-ID: <20240405161212.26167-2-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 02/31] lavfi/avfilter: add an "auto" constant to the threads option 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: WdeBf0OcIjhR Analogous to the same constant in avfiltergraph and avcodec. Cf. f599ae88c25. --- libavfilter/avfilter.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 7f94e71fbc..049e4f62ca 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -652,7 +652,8 @@ static const AVOption avfilter_options[] = { { "slice", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AVFILTER_THREAD_SLICE }, .flags = FLAGS, .unit = "thread_type" }, { "enable", "set enable expression", OFFSET(enable_str), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = TFLAGS }, { "threads", "Allowed number of threads", OFFSET(nb_threads), AV_OPT_TYPE_INT, - { .i64 = 0 }, 0, INT_MAX, FLAGS }, + { .i64 = 0 }, 0, INT_MAX, FLAGS, .unit = "threads" }, + {"auto", "autodetect a suitable number of threads to use", 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, .flags = FLAGS, .unit = "threads"}, { "extra_hw_frames", "Number of extra hardware frames to allocate for the user", OFFSET(extra_hw_frames), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS }, { NULL }, From patchwork Fri Apr 5 16:11:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47832 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1069172pzd; Fri, 5 Apr 2024 09:13:50 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUt5AvCDXJcup0Owgz/ZWOVOWglAGQtRHH9JFPvPbz7OjGVVTAUR/gulMMLMku5INam5CLwO9tfu3xLlKejJSf48wGuFbtniYhdHA== X-Google-Smtp-Source: AGHT+IHe6Un1yUjQggVu75P6BBfymuJlIE6tlk5k58ID19p+0f46Y1FJw2lCt2LpSg2Uw4M+HE+5 X-Received: by 2002:a05:6402:4313:b0:56e:3535:9617 with SMTP id m19-20020a056402431300b0056e35359617mr1301226edc.1.1712333630133; Fri, 05 Apr 2024 09:13:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712333630; cv=none; d=google.com; s=arc-20160816; b=TTtvtyu9qhiLX/bMtwPGzlDY/D6AyDW4gYEBNYqSMoP5pT2zkdBjEdvNELeb34GOvT ZjByipIWJGvYKWCL74nn7jkr6LqoFzmDuIarke7sT0eMDa1G0ty44o16eRNVIzJAeOT+ cTIxVAwShPeZ+PTBi6k05MjZDoTDm7MTX+FwqPtnmklVGQu1QkalnWkvTyccJT8NDW8L 23loa5tNXqG7dpzXX8k/HlyOL94B2dpuHhG9rGE0OsbtDiIPmgdGCbLVhMWe3YrpyXmK /ZGfgcyrvVzXTcJcrXWZet+dW4BeuPwQIZysWCm0dA/Z1Mta13XgktPEGAUkzTNXnuk6 Jcfw== 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:dkim-signature:delivered-to; bh=VWCl2Qfrd9wVRvEXUNgIKFmOt/C9n4ELsTto7mGbqZQ=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=FUMJh3mtVwyYOeKsrgrZDP/wV6H8HEbEtGeuVIDtIDZldJJ3xoHQZXpEQyyFmviPoT hykJ7TcxkvGnLfLrVWsLXO1ZZziRxFnI4iDCHj7qMwBO+pVRljQ3YleH1rLdDMq7rXEk Z4T0gmlFqzx1B9X0Vr+HYOtOwyY6CKDKw1hvp5jQFNF09YO3xb6SwaFOJ5xH7BGd/pIT B6vehlvwsnxsqD47UsDfhzGvZsfmc6gsIC3CwN7svrfw9rhxYK4knjBOP6FNtM6PWkAL latXbpRewOg3ltY04sugK5XbhzrFV1w7CVbZfj5wyncmZ4F7qmE74dRUuMbUO6WGl1ar WqoQ==; 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=hWkqHJtr; 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 c22-20020a50f616000000b0056e2acef875si878944edn.669.2024.04.05.09.13.49; Fri, 05 Apr 2024 09:13: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; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=hWkqHJtr; 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 C5BF768D13B; Fri, 5 Apr 2024 19:13:14 +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 D159768D10C for ; Fri, 5 Apr 2024 19:13:04 +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=hWkqHJtr; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 200C14D84 for ; Fri, 5 Apr 2024 18:13:04 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id ncUp68X5ZAHE for ; Fri, 5 Apr 2024 18:13:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712333582; bh=xqWxSQyQ/nzidDuU4sRuLBofwJZsF/RKf0LbszjNWBY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=hWkqHJtrwE5ZDRitLLeDWFH23o3kV9muXlA2ZcnzgPKLW9t3hc6N0cHT6LhUi3SQp 7BCGyLZmFH2mieF2Mq5PTUVfMaoyG4RnYiOgbUagJyk98aOPSxK4WMiw+dLBaLP5IY FEOACwdbkfcGxfela4I80UGi5jd6Uso3ZS8Qz4GA619/VoRMeGPwSacp5QNmjIKMtx XwIB+wcQmES0HCxE3TzvFClAN2sGbP1uVHhmRVFCaTk7O2oq70Sj5LtbeRvHnYYGRE T2AiEHJn0QWp2okcrWuRE/Zo9VL4+taWz1ut7pqs//KyAS4P06gShFCoGIQIyPIOKt B5FzDBNLPQ8/Q== 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 E92B94D58 for ; Fri, 5 Apr 2024 18:13:01 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 8B1633A07B9 for ; Fri, 5 Apr 2024 18:12:55 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Apr 2024 18:11:44 +0200 Message-ID: <20240405161212.26167-3-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 03/31] fftools/ffmpeg_filter: do not pass OutputStream to set_channel_layout() 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: 89r9vAF1ee3X It only needs a list of allowed layouts and the requested layout. --- fftools/ffmpeg_filter.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 2308abf82a..ba6c6c7673 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -722,42 +722,42 @@ static int ifilter_bind_dec(InputFilterPriv *ifp, Decoder *dec) return 0; } -static int set_channel_layout(OutputFilterPriv *f, OutputStream *ost) +static int set_channel_layout(OutputFilterPriv *f, const AVChannelLayout *layouts_allowed, + const AVChannelLayout *layout_requested) { - const AVCodec *c = ost->enc_ctx->codec; int i, err; - if (ost->enc_ctx->ch_layout.order != AV_CHANNEL_ORDER_UNSPEC) { + if (layout_requested->order != AV_CHANNEL_ORDER_UNSPEC) { /* Pass the layout through for all orders but UNSPEC */ - err = av_channel_layout_copy(&f->ch_layout, &ost->enc_ctx->ch_layout); + err = av_channel_layout_copy(&f->ch_layout, layout_requested); if (err < 0) return err; return 0; } /* Requested layout is of order UNSPEC */ - if (!c->ch_layouts) { + if (!layouts_allowed) { /* Use the default native layout for the requested amount of channels when the encoder doesn't have a list of supported layouts */ - av_channel_layout_default(&f->ch_layout, ost->enc_ctx->ch_layout.nb_channels); + av_channel_layout_default(&f->ch_layout, layout_requested->nb_channels); return 0; } /* Encoder has a list of supported layouts. Pick the first layout in it with the same amount of channels as the requested layout */ - for (i = 0; c->ch_layouts[i].nb_channels; i++) { - if (c->ch_layouts[i].nb_channels == ost->enc_ctx->ch_layout.nb_channels) + for (i = 0; layouts_allowed[i].nb_channels; i++) { + if (layouts_allowed[i].nb_channels == layout_requested->nb_channels) break; } - if (c->ch_layouts[i].nb_channels) { + if (layouts_allowed[i].nb_channels) { /* Use it if one is found */ - err = av_channel_layout_copy(&f->ch_layout, &c->ch_layouts[i]); + err = av_channel_layout_copy(&f->ch_layout, &layouts_allowed[i]); if (err < 0) return err; return 0; } /* If no layout for the amount of channels requested was found, use the default native layout for it. */ - av_channel_layout_default(&f->ch_layout, ost->enc_ctx->ch_layout.nb_channels); + av_channel_layout_default(&f->ch_layout, layout_requested->nb_channels); return 0; } @@ -844,7 +844,7 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, ofp->sample_rates = c->supported_samplerates; } if (ost->enc_ctx->ch_layout.nb_channels) { - int ret = set_channel_layout(ofp, ost); + int ret = set_channel_layout(ofp, c->ch_layouts, &ost->enc_ctx->ch_layout); if (ret < 0) return ret; } else if (c->ch_layouts) { From patchwork Fri Apr 5 16:11:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47857 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1071700pzd; Fri, 5 Apr 2024 09:17:30 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX8/vfePX5gWXGp9Dw1JKGCgAthinXrTRRZV1YqDh+YY/U7CtgwBD2Bw1+xTCMupkltQC3dJSN7OBdYFIkEWjFtkTpzsPQzoFClQw== X-Google-Smtp-Source: AGHT+IHH0F0vfAUxLl5HIJAQxTuR6TXhDGtDzBZWupmr6r0l2rSYqAH1S7D3Q5cUQk/1yyAWedbK X-Received: by 2002:a17:906:3e12:b0:a4e:37ac:79c8 with SMTP id k18-20020a1709063e1200b00a4e37ac79c8mr1263332eji.5.1712333849826; Fri, 05 Apr 2024 09:17:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712333849; cv=none; d=google.com; s=arc-20160816; b=qzRM+P9PhE6qcGPwSxDLuMH9eLQOqxbvhNfh+GA0REdNCb3mr+mPpnupAhZUJiScre FHYYQiPpmaW24hOPQh4b/nVoAOGqSslHozLNJE1yv/sU8hw0Urhc67LTkNisJNQnzYqV KhMeZ1jJ7vunQMMCFSMehCQLKM2G5mIPWQ7MGOJ09R++jmDXj2+9l8wVb86COav5KN+1 ewvWGAFBJqXOfpGf+tyHxs5uUHvJLQJnHyXYwA+4c7ahwcWiyCRceAHrfSk0dDc3vQht IKGy13DhkmBE4k+Q5w46iT4ai2D+o7DLLMPwsMXoTVShLeGtnog4CO90TNw02vgyx4zv 5UJA== 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:dkim-signature:delivered-to; bh=W2sqAnj4wYv/SlHceyCIZ+o4s9O214vncinDNLPMp1s=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=lcuKzEXOQZ+OtnyGAWtjkSxZ5rVRhHNY7PHRL6+TozEoWCe3PbGRZw+At0AEaTkcd9 56CG0ocMDuJasnzvGCtXA91iKVQDLGvs3mt5rMSfuR/RO44zjCKUPpkksQHTsl3G8ztp HxaWz6INIPqJgQYgy/6rkrYnQr1rdBIMpR+hk8cjS5piinyHdlyIWOd9iZ+woyf6hOgp /s3uQYOi0LpWPiqndqGQ8Uczv/k4jOmxOBdjeC5TZxpEaHf2GrPVv6cFSzT/SUX0gJgm nZ9sjRwla17wnCFK2xFQT2xhuv7tckb1XcygUZKMJNbBN1u80t1fCbMYMgqndF1o7YA1 WXlQ==; 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=TNmRvIOu; 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 dv25-20020a170906b81900b00a4e2acb2d37si833778ejb.231.2024.04.05.09.17.29; Fri, 05 Apr 2024 09:17:29 -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=TNmRvIOu; 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 D0E0B68D375; Fri, 5 Apr 2024 19:13:39 +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 D307168D225 for ; Fri, 5 Apr 2024 19:13:09 +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=TNmRvIOu; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 043AA4D5C for ; Fri, 5 Apr 2024 18:13:05 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id J_fsP5cMrXaZ for ; Fri, 5 Apr 2024 18:13:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712333582; bh=RM1Ur/F1AhrB7CWVlgjyaiMIm5oiwTPXRnAv8vBaqFg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=TNmRvIOu7mTFF3SZJ6ZCDmJt9H0u372dImBSg8w8axn4SB1xom4u/I7xUQUh986o/ 1mt1iblE1g7i0c13RdCsyOztage9PKUrcZo3/8KZtLot0KBVSmGzP7yYT7EXz4292l lqty2kKkizyk+gL5PDHogPuDjnPKEmtnG834JxazTuNkugPI9Y/inygOP0KLFj4t90 1xGphvEuj6lL+2mHijyCM9S4QvfzGf8mWP+YVJ5aDa+YfnZeqYDNoDMaGGS/fzdF18 gE3O6CoFUDxlBTNHCYvof3GEK5GHMfwbB0xzQgvxZa9UeRlkZKFyozvmK5UflEyVCx IpSDygAA/ifeA== 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 E5CFD1D2E for ; Fri, 5 Apr 2024 18:13:01 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 9732D3A0B52 for ; Fri, 5 Apr 2024 18:12:55 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Apr 2024 18:11:45 +0200 Message-ID: <20240405161212.26167-4-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 04/31] fftools/ffmpeg_filter: stop accessing AVCodecContext.codec 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: OOionlN+G0Ub Instead pass the encoder through a newly-added output options struct, analogous to previously added input options. Will allow decoupling filtering from encoding in future commits. --- fftools/ffmpeg.h | 11 +++++++++-- fftools/ffmpeg_filter.c | 36 +++++++++++++++++++----------------- fftools/ffmpeg_mux_init.c | 8 ++++++-- 3 files changed, 34 insertions(+), 21 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index a575ee70d5..8455cb23e4 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -263,6 +263,11 @@ typedef struct InputFilterOptions { AVFrame *fallback; } InputFilterOptions; +typedef struct OutputFilterOptions { + // Codec used for encoding, may be NULL + const AVCodec *enc; +} OutputFilterOptions; + typedef struct InputFilter { struct FilterGraph *graph; uint8_t *name; @@ -684,7 +689,8 @@ int parse_and_set_vsync(const char *arg, int *vsync_var, int file_idx, int st_id int filtergraph_is_simple(const FilterGraph *fg); int init_simple_filtergraph(InputStream *ist, OutputStream *ost, char *graph_desc, - Scheduler *sch, unsigned sch_idx_enc); + Scheduler *sch, unsigned sch_idx_enc, + const OutputFilterOptions *opts); int fg_finalise_bindings(FilterGraph *fg); /** @@ -699,7 +705,8 @@ FrameData *packet_data (AVPacket *pkt); const FrameData *packet_data_c(AVPacket *pkt); int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, - unsigned sched_idx_enc); + unsigned sched_idx_enc, + const OutputFilterOptions *opts); /** * Create a new filtergraph in the global filtergraph list. diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index ba6c6c7673..0d359303f7 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -763,13 +763,13 @@ static int set_channel_layout(OutputFilterPriv *f, const AVChannelLayout *layout } int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, - unsigned sched_idx_enc) + unsigned sched_idx_enc, + const OutputFilterOptions *opts) { const OutputFile *of = ost->file; OutputFilterPriv *ofp = ofp_from_ofilter(ofilter); FilterGraph *fg = ofilter->graph; FilterGraphPriv *fgp = fgp_from_fg(fg); - const AVCodec *c = ost->enc_ctx->codec; int ret; av_assert0(!ofilter->ost); @@ -786,14 +786,14 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, ofp->height = ost->enc_ctx->height; if (ost->enc_ctx->pix_fmt != AV_PIX_FMT_NONE) { ofp->format = ost->enc_ctx->pix_fmt; - } else { - ofp->formats = c->pix_fmts; + } else if (opts->enc) { + ofp->formats = opts->enc->pix_fmts; // 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 // has been specified. - if (!strcmp(c->name, "mjpeg")) { + if (!strcmp(opts->enc->name, "mjpeg")) { // FIXME: YUV420P etc. are actually supported with full color range, // yet the latter information isn't available here. static const enum AVPixelFormat mjpeg_formats[] = @@ -822,11 +822,11 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, ofp->fps.framerate = ost->frame_rate; ofp->fps.framerate_max = ost->max_frame_rate; - ofp->fps.framerate_supported = ost->force_fps ? - NULL : c->supported_framerates; + ofp->fps.framerate_supported = ost->force_fps && opts->enc ? + NULL : opts->enc->supported_framerates; // reduce frame rate for mpeg4 to be within the spec limits - if (c->id == AV_CODEC_ID_MPEG4) + if (opts->enc && opts->enc->id == AV_CODEC_ID_MPEG4) ofp->fps.framerate_clip = 65535; ofp->fps.dup_warning = 1000; @@ -835,20 +835,21 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, case AVMEDIA_TYPE_AUDIO: if (ost->enc_ctx->sample_fmt != AV_SAMPLE_FMT_NONE) { ofp->format = ost->enc_ctx->sample_fmt; - } else { - ofp->formats = c->sample_fmts; + } else if (opts->enc) { + ofp->formats = opts->enc->sample_fmts; } if (ost->enc_ctx->sample_rate) { ofp->sample_rate = ost->enc_ctx->sample_rate; - } else { - ofp->sample_rates = c->supported_samplerates; + } else if (opts->enc) { + ofp->sample_rates = opts->enc->supported_samplerates; } if (ost->enc_ctx->ch_layout.nb_channels) { - int ret = set_channel_layout(ofp, c->ch_layouts, &ost->enc_ctx->ch_layout); + int ret = set_channel_layout(ofp, opts->enc ? opts->enc->ch_layouts : NULL, + &ost->enc_ctx->ch_layout); if (ret < 0) return ret; - } else if (c->ch_layouts) { - ofp->ch_layouts = c->ch_layouts; + } else if (opts->enc) { + ofp->ch_layouts = opts->enc->ch_layouts; } break; } @@ -1079,7 +1080,8 @@ fail: int init_simple_filtergraph(InputStream *ist, OutputStream *ost, char *graph_desc, - Scheduler *sch, unsigned sched_idx_enc) + Scheduler *sch, unsigned sched_idx_enc, + const OutputFilterOptions *opts) { FilterGraph *fg; FilterGraphPriv *fgp; @@ -1111,7 +1113,7 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost, if (ret < 0) return ret; - ret = ofilter_bind_ost(fg->outputs[0], ost, sched_idx_enc); + ret = ofilter_bind_ost(fg->outputs[0], ost, sched_idx_enc, opts); if (ret < 0) return ret; diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index d3d7d022ff..b5869feb80 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -1371,14 +1371,18 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, if (ost->enc && (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) { + OutputFilterOptions opts = { + .enc = enc, + }; + if (ofilter) { ost->filter = ofilter; - ret = ofilter_bind_ost(ofilter, ost, ms->sch_idx_enc); + ret = ofilter_bind_ost(ofilter, ost, ms->sch_idx_enc, &opts); if (ret < 0) return ret; } else { ret = init_simple_filtergraph(ost->ist, ost, filters, - mux->sch, ms->sch_idx_enc); + mux->sch, ms->sch_idx_enc, &opts); if (ret < 0) { av_log(ost, AV_LOG_ERROR, "Error initializing a simple filtergraph\n"); From patchwork Fri Apr 5 16:11:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47827 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1068795pzd; Fri, 5 Apr 2024 09:13:16 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU0pHU8alTu6z5ECwzH96CAvUlfXgyJycipnjWZcFJUl7duxijMfhYDy456PCgkszS+lzRlKAHZrAB1evrm0T9YYZ7H5P/A3bhTyg== X-Google-Smtp-Source: AGHT+IE8FPdWenAkT9cnQa0Na1mvnEsV0GNLvOJ8xIepvXUKvo7nYWNLt9Tqgx5Y0t+aPgm1TOXP X-Received: by 2002:a17:906:aeda:b0:a51:a0eb:91b6 with SMTP id me26-20020a170906aeda00b00a51a0eb91b6mr1143478ejb.1.1712333596371; Fri, 05 Apr 2024 09:13:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712333596; cv=none; d=google.com; s=arc-20160816; b=brBxdPylkdln6qXFg3kvnSKgK9OD4KJdMdBOaY9kvf4gkQ0hmRbjwTShpiiitnScir TlxbzUQtxxYvWLr14bWdaV+Xud9EZIXWLeCYZAuMff02WxZgE3swo+M2n5//kLn982K7 SP1KChRdjcc0TFPMbgUcpmWAvCmwXUKq+vPjQzqr+pjLHqlsscriWw1qk4zTnIIuANLl BfuZAVnPW4xRP1SicIM5l7SjAN/BHoe6T2uRFg8z4VeCSJq2y3Y1KT+0g2erdXUAAozh bonCx9ayN7xxVwxsuGzy1RobzVTw8Ij85voEnMwsR2hI8Bhk+7N6n7JaFdi5r3FOSnSV U2Ug== 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:dkim-signature:delivered-to; bh=/i/q6KGip83kJgegjb2hZob2NZKHY0dLMSscaHhyRJw=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=B2i+e5rtJtf3LD20mvB+kZQS7LfyRCx5KTtoMhwuJ2Yv7z+LnPboZdGtxtsyPoYhpP WXRbqqV54gHj6KvXPHO7yQC5T+M//OeQVabqLDk5w0AtRBiGfpb6+/70iqRFribHltZf TRnrGdgcZxoVnGbK4xkfAAvCsbjVcq+EPyq3/8H/sHDPhi0GSd4vC7n60KuCb/3avZDM Aaagk+5Im+5Y7d0s4eu28dQ70ZYILwm3gZdoG1Lli7C+tYviNFNfCeruTOrdbkm+ErW2 Fakbki5PrU+GZqCOe4UFucaBJIMjBxsjQp3Exi1qpkud8YNKas5sWfjbr+vsm8MYnOcF wRVA==; 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="O/jRJ458"; 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 a10-20020a170906190a00b00a474a3e1176si823662eje.865.2024.04.05.09.13.15; Fri, 05 Apr 2024 09:13:16 -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="O/jRJ458"; 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 AA2BA68D1D2; Fri, 5 Apr 2024 19:13:11 +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 7D9C968D10C for ; Fri, 5 Apr 2024 19:13:04 +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=O/jRJ458; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 6870225F for ; Fri, 5 Apr 2024 18:13:03 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id SuRssl6cdNdO for ; Fri, 5 Apr 2024 18:13:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712333581; bh=tUwM9Blnv46o5ZFLkpyFlRlohowJDflbNWM+HWJgm1E=; h=From:To:Subject:Date:In-Reply-To:References:From; b=O/jRJ458URmPa0U7aaVssr9BgDCMfSagMcn9jpu5JYRCVgnTmdKUV0HPxRiTCayaY 0gPygZLsK4XDK0BQZk55f87pY4Kwy5axdTIWYWbDgWgO5aqkCIDb67fOeDA+jKvQO3 32+EYAaWrLRqUJhV3vfDIDnoxEkG7qjPUdD5N8hcjbjuPip3B+iKLRqJ8Ch6mPsxyR ynibcB7WAvj0Gr/ff7FYZ4VhQ+bBCNU5R4yWsMx5FyJcrXVnuA6UIZX2voBD7zjkp1 uuv2HMQIhrT+O/uzgPpHWZ0nkKbeQeCe7uljtiy8Tzl4FH6d/U71AeRKxSCcDc7weZ C9WCvHJSvMiXQ== 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 E7B7C4D48 for ; Fri, 5 Apr 2024 18:13:01 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id A2E6A3A0C79 for ; Fri, 5 Apr 2024 18:12:55 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Apr 2024 18:11:46 +0200 Message-ID: <20240405161212.26167-5-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 05/31] fftools/ffmpeg_filter: check that filter type matches output stream type 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: xV3jRXCEm9wH For simple filtergraphs. For complex filtergraphs they always match. --- fftools/ffmpeg_filter.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 0d359303f7..a59c61b312 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -773,6 +773,7 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, int ret; av_assert0(!ofilter->ost); + av_assert0(ofilter->type == ost->type); ofilter->ost = ost; av_freep(&ofilter->linklabel); @@ -1106,6 +1107,13 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost, graph_desc, fg->nb_inputs, fg->nb_outputs); return AVERROR(EINVAL); } + if (fg->outputs[0]->type != ost->type) { + av_log(fg, AV_LOG_ERROR, "Filtergraph has a %s output, cannot connect " + "it to %s output stream\n", + av_get_media_type_string(fg->outputs[0]->type), + av_get_media_type_string(ost->type)); + return AVERROR(EINVAL); + } ost->filter = fg->outputs[0]; From patchwork Fri Apr 5 16:11:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47856 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1071617pzd; Fri, 5 Apr 2024 09:17:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW8DF2ghMaKDNppMw/ehD6pZuYXyXiSLWZO8hNubqAJObJTu2P0fo3vV6CEONW2TtCdA+OAvHpDnkvNYhCSbn1nTmfPDaCd5gI6KQ== X-Google-Smtp-Source: AGHT+IG1MPZHsW+riZ54naJ5pr4UgfU5uRCP10jTyn4jJ7lzpJhKw0LBs2U+YWWeM90kybILV8Hh X-Received: by 2002:a50:c04f:0:b0:56e:2e4d:884e with SMTP id u15-20020a50c04f000000b0056e2e4d884emr2113310edd.0.1712333841485; Fri, 05 Apr 2024 09:17:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712333841; cv=none; d=google.com; s=arc-20160816; b=G/ii3no03fV3PYzpJ8/d80Z1E2Qh5JU29VQ4B6GP+PfQSPku+y1cU6kcJX+C2xH2Sf qoN11bk1G1xAlL8Elm9C5oh0o2EwYmVG6JxD6GhYj2j/VEzk4Ay4+jrVCDtmrmiY1ElY 4/GI0Bj6RDf8gDXj6TwEBcptRaAfkL+gBqNeLpK21flvbmCzUIPhoANYadsD0W9GlrWU sbNP7mBVkwXvZ5drYJMoKdcPiuVxpZU7cbxHz949ywKc73eDGKb7uDbEQ6hbfHWuaXBw MP1Xy2I5p/0ULIm7xvV/sf0/BdUlCEqvsp7mn97W+czUv9ABVeMEhXRLzolTD8CAxl9J YCkw== 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:dkim-signature:delivered-to; bh=sqMS18EKIMDtCnulGR5Gve/tr7V3rtkQHuZgVaSYYt8=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=KqyRInrGNHWkZci+EaAuiK0Jzqh770rHO4bvbb+rG/IXoHT6nSJ+Lo9KghNKJp+nO/ w5ChzFIBPnEtUo3oxGqNXxXVyCqFwtGEuuK0xCJ/DdkaYKYieuDTT+/YT3cqtQnfhEOY ZcSqmMj68CzeChVYHsZh5AZHDe3QpjsqKmAWOCfkx8wRdRXVYmBeFCYFcOjMb2PH0zR0 3CvB27YBtaScMsS+YwM5A764vGdUl6DK56Vdz90aG50O00mR6W7HnW0f+iC1lnqUUywo /Cgzb8O/D3mUGE7EKMHt0jHPF8FCEnLLrKvK2sZ0PTjgZcV3vfZg7IK96Kf9Dy212W9+ a7qg==; 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=mBV09OAg; 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 q18-20020a50cc92000000b0056e249c1609si850444edi.235.2024.04.05.09.17.21; Fri, 05 Apr 2024 09:17:21 -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=mBV09OAg; 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 D765068D35F; Fri, 5 Apr 2024 19:13:38 +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 CA97B68D217 for ; Fri, 5 Apr 2024 19:13:09 +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=mBV09OAg; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 9034F4D58 for ; Fri, 5 Apr 2024 18:13:04 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id YWfC_fLGsHVK for ; Fri, 5 Apr 2024 18:13:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712333582; bh=p0Sc0CE4/gD6ipX7bvBbCeNAwMgREceesGzemxdhZhk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=mBV09OAgb5mnmcxpnH8/D0vS7X3Tr7yLjhYxw933oo2r7FPToYb1iPlS3xjmxvSYW BxnVUsmTZNhJq5Jp9YkepozLFdf+ORLIBwm70zGWC9Jh/molLESnaPaPwD7gvckWE8 uD0HYLAdE1wM/4O/KD4aPHRjqF2TBgZTqoAPZSRdoz4D3UO9QWm+5sTeuI2KTRg0m8 xsiB5xI9G5IfiiSh58BKIAbbyYUgNzG+xY14QYe608khTfwqcipJ4xFAvOMr2PAPfH HTSVYzG3J3N1i1i5K3k1rhwxqhBy+irNxsLUdTo6rBlI+cCUM4BWOAJ+CFUFKuxLff LXl9H5rK4gCYA== 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 108674D5C 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 AE1A53A0C7C for ; Fri, 5 Apr 2024 18:12:55 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Apr 2024 18:11:47 +0200 Message-ID: <20240405161212.26167-6-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 06/31] fftools/ffmpeg_filter: pass ts offset 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: eJSPdNkPLT+X Reduces the need to access OutputFile, which will allow decoupling filtering from encoding in future commits. --- fftools/ffmpeg.h | 2 ++ fftools/ffmpeg_filter.c | 3 +-- fftools/ffmpeg_mux_init.c | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 8455cb23e4..7288a48aa1 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -266,6 +266,8 @@ typedef struct InputFilterOptions { typedef struct OutputFilterOptions { // Codec used for encoding, may be NULL const AVCodec *enc; + + int64_t ts_offset; } OutputFilterOptions; typedef struct InputFilter { diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index a59c61b312..8b05262622 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -766,7 +766,6 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, unsigned sched_idx_enc, const OutputFilterOptions *opts) { - const OutputFile *of = ost->file; OutputFilterPriv *ofp = ofp_from_ofilter(ofilter); FilterGraph *fg = ofilter->graph; FilterGraphPriv *fgp = fgp_from_fg(fg); @@ -778,7 +777,7 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, ofilter->ost = ost; av_freep(&ofilter->linklabel); - ofp->ts_offset = of->start_time == AV_NOPTS_VALUE ? 0 : of->start_time; + ofp->ts_offset = opts->ts_offset; ofp->enc_timebase = ost->enc_timebase; switch (ost->enc_ctx->codec_type) { diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index b5869feb80..83eab4276e 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -1373,6 +1373,8 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) { OutputFilterOptions opts = { .enc = enc, + .ts_offset = mux->of.start_time == AV_NOPTS_VALUE ? + 0 : mux->of.start_time, }; if (ofilter) { From patchwork Fri Apr 5 16:11:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47833 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1069263pzd; Fri, 5 Apr 2024 09:14:01 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUifR/2Vw382dw7gTs4MOO6S/C5xF/OSjgU8FANXy9orU+PbU9gcQCWTCmvXzp8ga+C2MIy54/m1WIeXwMhn3RAA3dEur+XLFyznQ== X-Google-Smtp-Source: AGHT+IESuPnoHqjWP8Dwx+r+JcFUfFuxjPjzft2pkRM8KMyRDsBEZQ1fh6bu/RqutHrP9wYdoSwt X-Received: by 2002:a05:6512:ac5:b0:513:e249:65fc with SMTP id n5-20020a0565120ac500b00513e24965fcmr1712418lfu.61.1712333640153; Fri, 05 Apr 2024 09:14:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712333640; cv=none; d=google.com; s=arc-20160816; b=Tb1BMUztIwBq7OC8BVoDpb5dQEI1R+1qaBI7YsS87DeZqiUp3CkrPV3V2JQ2aAb7BZ m7LIlL+CQXy/voP+nuHpsLx9OZhDeZa9w10CLd1eRTqq5IZC5wvW8zxUo/iT8bg4Iu71 xb0bilkeIikzbrIrzpUIGcAXkf50bW+1tvWB49KQkx+ic0MGGSjP0EFH+oloKPluns/t eeH9WJTFA+BHLO6x1elMkQ4+/eUbqd41nD2xL0RkGGHAH5CU7azPbZFPfT295amCj6oM hTwFXeZsO4aVXVVJB/0ErVMwT2JBB12GfzjoXsp8PY/riWSwDyGf19885oD1SmL3mcEF iCAg== 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:dkim-signature:delivered-to; bh=OGiHSeREIrnwvJ9ChtdS6AVKPYk8J41/GPjY9DWc2jA=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=VMFo4TT1R93Kf8mjKPgdF/4FNcSShmhCsLCoI9StHqxPEK8tQTLTj1gYcgpH0UXMIU y+sJoj9xiYu73Q84rCAO10sJOfQj46lkacSNX3bmhSRKxB+shAd6+3wHs3UiaNCGdSeD QWDQQ65DiYHXaIWb8BCGZaw7fil2kuimwp92fIUEBCUmDr+XcY7I0jhAboY1/IBtQXAO YYxWpHXL8+gulosewyS6fYksSMwGl2LNlHYIQ5ZaU0U+4xhrrzpe3fbKrQzs4cEyLOXd ZWp4uKOOsXQh6bj0+MpNw2XaiQaEGoXKchtWFSeawrKUbrpOJl66I9SV2eml6lE2Wv3b rYWQ==; 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=LKehudCC; 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 p22-20020a170906229600b00a5187f82094si810030eja.1.2024.04.05.09.13.59; Fri, 05 Apr 2024 09:14:00 -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=LKehudCC; 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 BDBFD68D226; Fri, 5 Apr 2024 19:13:15 +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 D94B168D158 for ; Fri, 5 Apr 2024 19:13:04 +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=LKehudCC; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id DDB491C2D for ; Fri, 5 Apr 2024 18:13:03 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id nFOUmjVfoRrN for ; Fri, 5 Apr 2024 18:13:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712333582; bh=dWjQT1LCqbuxp7FoipYB5TAkxT59bPzdJZK/3av37l8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=LKehudCCCu+tuKTuvOd1WMRupcY6VOyVYiaVftOj8A1X2HTXNOzODuDfqWhTAiqyl qw0ay9i0SnIAVFumeMo8CcN46FCnG7yGVxZln3xiY1kktyd06WbmhMPP+kuyuC6LU3 ErBZCEDc+FWhKZzH9C+vYG0Ym6auO8+AzpiJTFwJP14FEoN2LhTxEe6ZuMYeL77UuM lVhgPOEdg1VQSRb+Q7SbH4+hNtnDT658tkxvBOb7dznTJMXKBoQ0NAkhbC8WqAhIzl Jx5YmBc/m1crlLOeSXWsZPNv4b9r0LdmvJuxptfyGOhNc/q9WwpwNKlNgCi9wKWYxX 4I5Tvck2ZkyxQ== 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 1B1B64D66 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 B91FB3A0CB6 for ; Fri, 5 Apr 2024 18:12:55 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Apr 2024 18:11:48 +0200 Message-ID: <20240405161212.26167-7-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 07/31] fftools/ffmpeg_filter: pass keep_pix_fmt 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: F56orE2o6SzL Reduces the need to access OutputStream, which will allow decoupling filtering from encoding in future commits. --- fftools/ffmpeg.h | 9 +++++++-- fftools/ffmpeg_filter.c | 8 +++++--- fftools/ffmpeg_mux_init.c | 9 +++++---- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 7288a48aa1..300ad8a987 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -263,11 +263,18 @@ typedef struct InputFilterOptions { AVFrame *fallback; } InputFilterOptions; +enum OFilterFlags { + OFILTER_FLAG_DISABLE_CONVERT = (1 << 0), +}; + typedef struct OutputFilterOptions { // Codec used for encoding, may be NULL const AVCodec *enc; int64_t ts_offset; + + // A combination of OFilterFlags. + unsigned flags; } OutputFilterOptions; typedef struct InputFilter { @@ -556,8 +563,6 @@ typedef struct OutputStream { char *attachment_filename; - int keep_pix_fmt; - /* stats */ // number of packets send to the muxer atomic_uint_least64_t packets_written; diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 8b05262622..5f2dbc387e 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -214,6 +214,8 @@ typedef struct OutputFilterPriv { int64_t ts_offset; int64_t next_pts; FPSConvContext fps; + + unsigned flags; } OutputFilterPriv; static OutputFilterPriv *ofp_from_ofilter(OutputFilter *ofilter) @@ -355,11 +357,10 @@ static int choose_pix_fmts(OutputFilter *ofilter, AVBPrint *bprint, const char **dst) { OutputFilterPriv *ofp = ofp_from_ofilter(ofilter); - OutputStream *ost = ofilter->ost; *dst = NULL; - if (ost->keep_pix_fmt || ofp->format != AV_PIX_FMT_NONE) { + if (ofp->flags & OFILTER_FLAG_DISABLE_CONVERT || ofp->format != AV_PIX_FMT_NONE) { *dst = ofp->format == AV_PIX_FMT_NONE ? NULL : av_get_pix_fmt_name(ofp->format); } else if (ofp->formats) { @@ -777,6 +778,7 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, ofilter->ost = ost; av_freep(&ofilter->linklabel); + ofp->flags = opts->flags; ofp->ts_offset = opts->ts_offset; ofp->enc_timebase = ost->enc_timebase; @@ -814,7 +816,7 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, } } - fgp->disable_conversions |= ost->keep_pix_fmt; + fgp->disable_conversions |= !!(ofp->flags & OFILTER_FLAG_DISABLE_CONVERT); ofp->fps.last_frame = av_frame_alloc(); if (!ofp->fps.last_frame) diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 83eab4276e..d79ae1f491 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -580,7 +580,7 @@ static enum AVPixelFormat pix_fmt_parse(OutputStream *ost, const char *name) } static int new_stream_video(Muxer *mux, const OptionsContext *o, - OutputStream *ost) + OutputStream *ost, int *keep_pix_fmt) { AVFormatContext *oc = mux->fc; AVStream *st; @@ -638,7 +638,7 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o, MATCH_PER_STREAM_OPT(frame_pix_fmts, str, frame_pix_fmt, oc, st); if (frame_pix_fmt && *frame_pix_fmt == '+') { - ost->keep_pix_fmt = 1; + *keep_pix_fmt = 1; if (!*++frame_pix_fmt) frame_pix_fmt = NULL; } @@ -1041,7 +1041,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, OutputStream *ost; const AVCodec *enc; AVStream *st; - int ret = 0; + int ret = 0, keep_pix_fmt = 0; const char *bsfs = NULL, *time_base = NULL; char *filters = NULL, *next, *codec_tag = NULL; double qscale = -1; @@ -1356,7 +1356,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, ms->copy_initial_nonkeyframes, oc, st); switch (type) { - case AVMEDIA_TYPE_VIDEO: ret = new_stream_video (mux, o, ost); break; + case AVMEDIA_TYPE_VIDEO: ret = new_stream_video (mux, o, ost, &keep_pix_fmt); break; case AVMEDIA_TYPE_AUDIO: ret = new_stream_audio (mux, o, ost); break; case AVMEDIA_TYPE_SUBTITLE: ret = new_stream_subtitle (mux, o, ost); break; } @@ -1375,6 +1375,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, .enc = enc, .ts_offset = mux->of.start_time == AV_NOPTS_VALUE ? 0 : mux->of.start_time, + .flags = OFILTER_FLAG_DISABLE_CONVERT * !!keep_pix_fmt, }; if (ofilter) { From patchwork Fri Apr 5 16:11:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47837 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1069732pzd; Fri, 5 Apr 2024 09:14:43 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWSLBUqaR6R3xB83KJRnOBlUrl3te8/+xigZUy5GXcEkTOJhTn5pE//GiOh9J03Zbyo5bmHkwNT3E1plhE4dd6kE932U9KEXWSC3A== X-Google-Smtp-Source: AGHT+IHEsYm/Iecu7EowUdTrSHon9z2DVVvU79/5G8cgEMGPiNxDGqb+Fz7UJuMzSM98ggxIah1R X-Received: by 2002:a17:907:75e7:b0:a4e:7b34:ef76 with SMTP id jz7-20020a17090775e700b00a4e7b34ef76mr1092317ejc.4.1712333683054; Fri, 05 Apr 2024 09:14:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712333683; cv=none; d=google.com; s=arc-20160816; b=RcaPOjXttiKd7dHT9igcm5lQE/U5dPzRgtkMsfaOKFsv8NpJ7oNo5n/CIWRQuDDh5x MjLmzj1noUq5xEA1TPxBe8Cpt3PPoPY4fOpdmdtBMLsrhWVmpXEphnTZcIHOhyyZzJ8R eoT7sqDlFDETrpiZkMSZ/QXGDfRgoJiouQImzREAMDIRUcHaeY5V1OsAa8AsAK8TS6hy EbG65joHKpmS/oL6bmCI8CDG00biTDKKu7u733tenYBlxnuNi5JQ/nnnpMQvO6fLvtVc 8DjTP2wC8Ep/5iNOxkCM3Yoyh1GCREvj2ik5EMQtDafIyCvWy7hAtYDdYk8OiYkKBj7H JJFw== 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:dkim-signature:delivered-to; bh=/dCJti1IV30vJflj7ZGXZKkz0RsE7LJdd9Xs0YpLW84=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=syv+PUerkV+9PTdOd++K6IhK4viQ2MCFPbVTVkB8GTqGA12FKKrSt+hY+AKC/ej6zv yWpUqJK9z2LnECuQY5VryRspDU06SM6GBabzuVykoswssXjaH5uPbyS/Zho9qeJ6oa8g 41/sAcjmsNOAbiCO/P2Vo9OAAgp4QNxLfiQ+Ztdyj9L7HAbVEeTrQL049oU6izrEyjn7 2wwxg7egnd191ZPaD0OHd0yT/9HPAkSarIIm+JrqICZ3J4vml1ZivpO0mRBWzooEt5bs ikSHxvoSUIjq54l7v8EwjVWn1a8R90lEgmc6sB6gX6cHYGkVZo4U+k3yzxXD2vj3q3F1 QSxw==; 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="AF3U/3AW"; 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 y10-20020a17090668ca00b00a5197fb9ee6si812435ejr.93.2024.04.05.09.14.42; Fri, 05 Apr 2024 09:14:43 -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="AF3U/3AW"; 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 2792D68D1D9; Fri, 5 Apr 2024 19:13:20 +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 3EBE968D16C 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=AF3U/3AW; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 5BAD54D99 for ; Fri, 5 Apr 2024 18:13:05 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id Pqjl7kQ0Mprh for ; Fri, 5 Apr 2024 18:13:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712333582; bh=Rmpult1ygaWVFUP6R21T1hgIAjJV1mp1GmA3h2Xr+dA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=AF3U/3AWfspPitSMmthzmP53Vn68kmt4MLjKbeuEEhGygrfV1PNBcudngtgWAbkFN 7kHIK+RyRucuGhw8N4Y94iKCRTWaBPRyWGglBmw2bnSvDT9NZf/z+M1QjzgnUBHvQk zoEWYvYrLz0G9KN98b7rLbveoFaYEWfslFLMPC7jy+EqVg0K6nOFdaFseKEOnQ4eBZ gqpF23UeY1Gp5l/pfQVc7p5IKKG5nJ4Fiv/R7UEpNfrWnpIXs1yyzMEiea1u3CxwMA EkMvtwTTC8sZ4jwRp8dloKO7T5LILA9x/qzSNKJeLcdpR2S/qSsSpReNIdFVjbXMPf 0IGzfafj9DemQ== 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 2FC354D78 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 C4D653A0DA0 for ; Fri, 5 Apr 2024 18:12:55 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Apr 2024 18:11:49 +0200 Message-ID: <20240405161212.26167-8-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 08/31] fftools/ffmpeg: warn about ignored -enc_time_base for subtitles earlier 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: RETfr3CXapyc Can do it as soon as that option is parsed, no need to postpone it until opening the encoder. --- fftools/ffmpeg_enc.c | 3 --- fftools/ffmpeg_mux_init.c | 6 +++++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index d1d1526830..618ba193ff 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -280,9 +280,6 @@ int enc_open(void *opaque, const AVFrame *frame) break; } case AVMEDIA_TYPE_SUBTITLE: - if (ost->enc_timebase.num) - av_log(ost, AV_LOG_WARNING, - "-enc_time_base not supported for subtitles, ignoring\n"); enc_ctx->time_base = AV_TIME_BASE_Q; if (!enc_ctx->width) { diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index d79ae1f491..8b03d3b108 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -1233,8 +1233,12 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, } MATCH_PER_STREAM_OPT(enc_time_bases, str, enc_time_base, oc, st); - if (enc_time_base) { + if (enc_time_base && type == AVMEDIA_TYPE_SUBTITLE) + av_log(ost, AV_LOG_WARNING, + "-enc_time_base not supported for subtitles, ignoring\n"); + else if (enc_time_base) { AVRational q; + if (!strcmp(enc_time_base, "demux")) { q = (AVRational){ ENC_TIME_BASE_DEMUX, 0 }; } else if (!strcmp(enc_time_base, "filter")) { From patchwork Fri Apr 5 16:11:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47839 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1069927pzd; Fri, 5 Apr 2024 09:14:59 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX1pEg2hPgx9CUgLnY2dpY5rtriogs1z5jrm+qL2libYb2TMmYs5PF+taUd3B5vCHglD38A3qVOPvbNUQ3eNrSW23hpF+boeYQpjw== X-Google-Smtp-Source: AGHT+IEluCKfjpHRN1frfqRlANNw7JNBPtRR/kZgoN3asvipm94E+BW7qfp0dE6OfCF1Eb1zHoId X-Received: by 2002:a19:c514:0:b0:515:c7c9:b14e with SMTP id w20-20020a19c514000000b00515c7c9b14emr1143532lfe.57.1712333699319; Fri, 05 Apr 2024 09:14:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712333699; cv=none; d=google.com; s=arc-20160816; b=p86Oe4Hq+3RWCWkPf2QRjZIybOwgly/9aC78sv5BAqgj/85JX7q5FMXmqNAkNoOSho A6IcdC1rytk6+Ye8rlQnCem9qfF47esdaxqCwJXM81VLvCjcQJTcik5DeZ6Q24VDXTtR S+6nUKgjeKEqrQGg1X6dIKAp+dtEnf87OFVkMy+bdD2a3uwmL29R1WLgpJahwAx/Ev1G qp9T8voOiDicOts5BM0I/wYS9i843zmKacnyJfvFNLNjymReZag9a45RtPqO7s/0I2sp UMWu1IOnEuD5YUf/MmtPj39+98s2I0k99+VfvFz4GwlpV6bH+JzcMFf0033WBP38xb52 pNIg== 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:dkim-signature:delivered-to; bh=/XsinMCmCzpJZdLdyJcU3lQn0pADlPZRFPxdXE+qt+Q=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=OWH8kL10WfCM0vpLktxLFAbQDj/cU/eXm47OLMhkAxz8l95Z2EH9WAu499mxpzsK8S tu+pNm0ELNhADoqt1ObA8gJZeIfjWaXG6F3xCmu0XEYUhkaYEQghpeYNMRy03rc8PVaB titXI2dYKcpuOdLSREGwX1Yu+n3Dk6neElUqZ2P6xXokxkvTZQF3wuvqlWaNQwW5n0bL nOo1xl5uq0SGR9TtrEN+tLv4hdLyDUrVLlNTHtuiSDvulIq/UFo+xpoDgT9PwdDCejri zmIU9ao6H6jpFYV5j4hplyLYlj41jSMCwG65uum1xTmTiO6eNmAVnbILaIjpXlGLEXPX GN1w==; 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=nyvYLYR0; 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 t6-20020a17090616c600b00a518557a252si859653ejd.48.2024.04.05.09.14.51; Fri, 05 Apr 2024 09:14:59 -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=nyvYLYR0; 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 1A60568D1FA; Fri, 5 Apr 2024 19:13:21 +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 43B7568D16F 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=nyvYLYR0; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 622211D2E for ; Fri, 5 Apr 2024 18:13:05 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id P-Me3p3WDc_t for ; Fri, 5 Apr 2024 18:13:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712333582; bh=VqtqOo/fLxgM+iVFqoPTDZl02r6vM4X8orDqE3a/ggw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=nyvYLYR0Bks9nDVis+A+e6IT9gc3Vqau809NmRJXW3KdMdrz1f2aQc9IrEXRVxF1o RuVhdtIZv9bJG8rY1+zhKzz+JPkUal6tYWpP5ARwyO6miMaVcBaAsAAZMztRI6XFWt yN11oD/sdS8U9Vo+czFsPF+Agl9vuA+qqwfuulxbam/xUebRjJzESOiTKVCMPSgiyo i+asVBo0QDAjLyNVvRQ9auXakjUajeHlGqHdIzCV9FTPki7Y0IUgbtKZlj5ix2IxE6 YGTah/Z1ig6cFKGxsQ/NM77Y346W+uiHQoRvfEmh+L3c9uZ0tgiDwAvfjlsP1g3c3o 84qheZ71L9lpQ== 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 2FCC74D7C 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 D09783A0DA6 for ; Fri, 5 Apr 2024 18:12:55 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Apr 2024 18:11:50 +0200 Message-ID: <20240405161212.26167-9-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 09/31] fftools/ffmpeg_filter: pass enc_timebase 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: K4TrsqDIk1fS Reduces the need to access OutputStream, which will allow decoupling filtering from encoding in future commits. --- fftools/ffmpeg.h | 7 +++++-- fftools/ffmpeg_filter.c | 2 +- fftools/ffmpeg_mux_init.c | 4 +++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 300ad8a987..56c2fedcc4 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -273,6 +273,11 @@ typedef struct OutputFilterOptions { int64_t ts_offset; + /* Desired output timebase. + * Numerator can be one of EncTimeBase values, or 0 when no preference. + */ + AVRational output_tb; + // A combination of OFilterFlags. unsigned flags; } OutputFilterOptions; @@ -529,8 +534,6 @@ typedef struct OutputStream { AVStream *st; /* stream in the output file */ - AVRational enc_timebase; - Encoder *enc; AVCodecContext *enc_ctx; diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 5f2dbc387e..0b78898af0 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -780,7 +780,7 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, ofp->flags = opts->flags; ofp->ts_offset = opts->ts_offset; - ofp->enc_timebase = ost->enc_timebase; + ofp->enc_timebase = opts->output_tb; switch (ost->enc_ctx->codec_type) { case AVMEDIA_TYPE_VIDEO: diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 8b03d3b108..28090423c6 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -1042,6 +1042,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, const AVCodec *enc; AVStream *st; int ret = 0, keep_pix_fmt = 0; + AVRational enc_tb = { 0, 0 }; const char *bsfs = NULL, *time_base = NULL; char *filters = NULL, *next, *codec_tag = NULL; double qscale = -1; @@ -1260,7 +1261,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, #endif } - ost->enc_timebase = q; + enc_tb = q; } } else { ret = filter_codec_opts(o->g->codec_opts, AV_CODEC_ID_NONE, oc, st, @@ -1377,6 +1378,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) { OutputFilterOptions opts = { .enc = enc, + .output_tb = enc_tb, .ts_offset = mux->of.start_time == AV_NOPTS_VALUE ? 0 : mux->of.start_time, .flags = OFILTER_FLAG_DISABLE_CONVERT * !!keep_pix_fmt, From patchwork Fri Apr 5 16:11:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47835 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1069562pzd; Fri, 5 Apr 2024 09:14:26 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU6aersAup83d/edTkfiqcflmBhGW5vAtpXOZW/yH4kD3a74BtU9fxd9I07Z6+qL9+sgP9SoSdxA60/HM36p51JQjFOi25Pkh/x9A== X-Google-Smtp-Source: AGHT+IGnVJ4tjzfNi2noCcp9wN2QAddBNsv5/lytWDTZDKa2tbSTJ4Pax5vu2ed2qfkMfQQXksWO X-Received: by 2002:a17:907:75d7:b0:a4d:f5e0:6157 with SMTP id jl23-20020a17090775d700b00a4df5e06157mr1250294ejc.7.1712333666042; Fri, 05 Apr 2024 09:14:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712333666; cv=none; d=google.com; s=arc-20160816; b=iMbcAgpHtjwBY9lNS+/mo8gH6KDSYz1fpD7FpFPiU0Au15P3isghIMN176f6LvPNUM nP9cz1YMKVLelW8gkoNJAHoZxNQLYL6JeZxZtArTQqvCMHYf60VtkTfFrBNt1HiMosDq Ti9fMwWNZY6I+Qqtb7vokGQtCIdxXAKbBrqvH3uh5ppfg/SGaglDs4VQgbV7acb70UJw g3kGTKPVRI6+00OvBIWOrjYx6UJ0Eh2vVQ6XVslYvilPnOScD5sxQ4uT8z2Vf6NM/web AzLkR8mJDdwRVxO5iDxTzRffzHgpF20dmYlg7MQWTQ0+Fk6XBPPQjHkRPnqBfNEQzbpy hstQ== 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:dkim-signature:delivered-to; bh=nnseFfKfwqw+NlEGRel0w7wwU0yrvH0XsRC6p/YCdA0=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=So6OJJdbbJ78EYvEjtEG8vkR2yISOsRRW1/7ZA9xgLn+UQVS5buRcSHeGFgqTIneIo UxzquwBHjEf0dmR+AErnBaw1tELTUUoKBc6P0+2xqpTi312ebR7WIgmjxbvi6CUZBH4S zVTtTU+CvvaJ6aEbucR1avfbCUp5C9YPHHI882my2qfyOTUSOeA+UggXCYf2AVOu4kd6 KDRIVAA+YKPCthNyuX49N1unk+wUFxN2qv/wBU1tb5Uwuw2PQW0D11+Fh53H+3LOsFES NiaUAocn5qTU3Ymi9111AkSs19j1ixEb0OVdsesTyT4QHvHltI9jMXYQj41NhHnDjn5M g/0Q==; 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=P76rwBwc; 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 o25-20020a1709062e9900b00a51a78f4ed7si615954eji.220.2024.04.05.09.14.25; Fri, 05 Apr 2024 09:14:26 -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=P76rwBwc; 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 530E168D18A; Fri, 5 Apr 2024 19:13:18 +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 415EC68D16D 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=P76rwBwc; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id F419F4D79 for ; Fri, 5 Apr 2024 18:13:04 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id LDcD4bHljEtx for ; Fri, 5 Apr 2024 18:13:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712333582; bh=Ev6m59ZqcZ3VXvTbzJz+b4jr9WP+wE/ldwFphrMydJU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=P76rwBwcc4wajCWlJeeEzEFc8OnJXXt8GzZz1gRnpWa2by/L+J88wCupAkw/zlO4m GAKlDNyCQls0HAvcePEuqE0uvM8zhTHgxMjnVFvCJsxROV6qbqUUby4eFuuz0Orviz Jja/Df47IX48rO1s3RV+xadd0LHR4uPaxcgPiOpa2gZ18TVOz6Zy4DhqI6FqpGznwv qNpdtTVwS91/WuT6I78E/yQuFbLFZavx0E0Lp3qu+mN6vrYCCZfwcmlzzp1jvcMKcB b4RJOasD2ZiPUP4zNhrBcnZtw1BNM6Xslyn9puPDmgeFyqWrmWV0xol68pM3NssGGR zs8OCCLTLP5Mw== 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 3BACC4D7D 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 DC7403A0F49 for ; Fri, 5 Apr 2024 18:12:55 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Apr 2024 18:11:51 +0200 Message-ID: <20240405161212.26167-10-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 10/31] fftools/ffmpeg_filter: move the MJPEG format selection hack to muxer setup 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: YJ1QaFyfxIe1 That, if anywhere, is a more appropriate place for it. --- fftools/ffmpeg.h | 2 ++ fftools/ffmpeg_filter.c | 29 +++-------------------------- fftools/ffmpeg_mux_init.c | 24 ++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 56c2fedcc4..d0e896dbe7 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -270,6 +270,8 @@ enum OFilterFlags { typedef struct OutputFilterOptions { // Codec used for encoding, may be NULL const AVCodec *enc; + // Overrides encoder pixel formats when set. + const enum AVPixelFormat *pix_fmts; int64_t ts_offset; diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 0b78898af0..5661dc960a 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -788,34 +788,11 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, ofp->height = ost->enc_ctx->height; if (ost->enc_ctx->pix_fmt != AV_PIX_FMT_NONE) { ofp->format = ost->enc_ctx->pix_fmt; - } else if (opts->enc) { + } else if (opts->pix_fmts) + ofp->formats = opts->pix_fmts; + else if (opts->enc) ofp->formats = opts->enc->pix_fmts; - // 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 - // has been specified. - if (!strcmp(opts->enc->name, "mjpeg")) { - // FIXME: YUV420P etc. are actually supported with full color range, - // yet the latter information isn't available here. - static const enum AVPixelFormat mjpeg_formats[] = - { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, - AV_PIX_FMT_NONE }; - - const AVDictionaryEntry *strict = av_dict_get(ost->encoder_opts, "strict", NULL, 0); - int strict_val = ost->enc_ctx->strict_std_compliance; - - if (strict) { - const AVOption *o = av_opt_find(ost->enc_ctx, strict->key, NULL, 0, 0); - av_assert0(o); - av_opt_eval_int(ost->enc_ctx, o, strict->value, &strict_val); - } - - if (strict_val > FF_COMPLIANCE_UNOFFICIAL) - ofp->formats = mjpeg_formats; - } - } - fgp->disable_conversions |= !!(ofp->flags & OFILTER_FLAG_DISABLE_CONVERT); ofp->fps.last_frame = av_frame_alloc(); diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 28090423c6..04642f5c8b 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -1384,6 +1384,30 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, .flags = OFILTER_FLAG_DISABLE_CONVERT * !!keep_pix_fmt, }; + // 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 + // has been specified. + if (!strcmp(enc->name, "mjpeg")) { + // FIXME: YUV420P etc. are actually supported with full color range, + // yet the latter information isn't available here. + static const enum AVPixelFormat mjpeg_formats[] = + { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, + AV_PIX_FMT_NONE }; + + const AVDictionaryEntry *strict = av_dict_get(ost->encoder_opts, "strict", NULL, 0); + int strict_val = ost->enc_ctx->strict_std_compliance; + + if (strict) { + const AVOption *o = av_opt_find(ost->enc_ctx, strict->key, NULL, 0, 0); + av_assert0(o); + av_opt_eval_int(ost->enc_ctx, o, strict->value, &strict_val); + } + + if (strict_val > FF_COMPLIANCE_UNOFFICIAL) + opts.pix_fmts = mjpeg_formats; + } + if (ofilter) { ost->filter = ofilter; ret = ofilter_bind_ost(ofilter, ost, ms->sch_idx_enc, &opts); From patchwork Fri Apr 5 16:11:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47834 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1069366pzd; Fri, 5 Apr 2024 09:14:08 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXXFxohn3OVeHJZ5fzMO/nWntUxTnyFEgcDn+SyW7Xy+kro12HQOawlcvaKcjlb0XOEig0ROt10/5tMj5pJcCtjJ4ULGtYHJSNwng== X-Google-Smtp-Source: AGHT+IHCBTvLik0qaEO2xvBMhfUPk99LRjxJ7PkTkx+J3ay14r2RZ8rdVDkP3LzD49QM0HrKl8FD X-Received: by 2002:a17:907:9611:b0:a4e:2189:d06b with SMTP id gb17-20020a170907961100b00a4e2189d06bmr1722581ejc.60.1712333648664; Fri, 05 Apr 2024 09:14:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712333648; cv=none; d=google.com; s=arc-20160816; b=jSpKnmhQHVax5gzjnR3LHR4LU37+cET86ymRisTaumqEvpvCQiK++G5F8aIiNsbJts Bf/+TKMtaenOmccKEf2LeorlTAoOXKiCPJyBM3oTXb8JOaTth4qixPdYwnm+wWXPF0BM I4TIkLWtAq8jcbPjFFgo11AJHRD+s6nWFVcUzZRqpGPNNJ2Cq2YR4E7NawBguq2RpqWx 7sgsIKRsFolRofrzvwuuhziuL82rkfo1tC5F5VDfy5FFk1GNoTq+54F7iONn7wRlf8Er ndiAON1Jz0TZ8T43j0cJ5sYLb9KKNl2bPXnIVNKmWsMz8asJhROKHsOmSklkkSui6c4W m0Zg== 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:dkim-signature:delivered-to; bh=Eu82G4tQj0yCjHtGOFeV0oaQPdC56EYRZkj2O2LZaXk=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=lNwBVmpk7jkMtXbUjSz0CKAOoMML0Awe8BFqNVS953BL7BVanNI5eqKUWM2Uj8/KwQ OScXlCqi8s2AvlgHWlaMIyLuQQH20DcNU3LnHW4RRF+g3Qfj7HPePCIzQUhQHPi0YUUr BlyoMrV+93dUcasEbDzKFr6IoJxYobWvRXiRG+qT5ebNH1YEuYCmHyhyBe1eN0/MAOYI lHSOilgmkhqPWazCI2vmkpy/WsegQnwOnnPBQOJnbU2XNxIQXGRkJz8mMyC7rQQibO8j Cfrj0LwagMySB6Bb/U+19mHKD/kqcgKoG6UactoQgdnz9u7j69jSL/YrPo1Y1l/ELkDt Lbmg==; 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=LDnDP9PX; 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 le30-20020a170907171e00b00a46485678b2si803159ejc.651.2024.04.05.09.14.08; Fri, 05 Apr 2024 09:14:08 -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=LDnDP9PX; 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 9D5C368D22E; Fri, 5 Apr 2024 19:13:16 +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 3B6ED68D158 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=LDnDP9PX; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id C2EF84D66 for ; Fri, 5 Apr 2024 18:13:05 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id MeO202554SSs for ; Fri, 5 Apr 2024 18:13:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712333582; bh=oNILVF1XefeTJpSRCuVtuKvXwkp3Nv8i/YSnCeDTfSg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=LDnDP9PXPnFNc0DldM7acZAVkp4fWs3AzKSKPEgL08Cc3BIwxhmyi3r9hZbhrKRCZ Eaj67W5ZekvAW6z/lPG9SDnY3JYJ2wy24xIQ3M7Kadk3l5eRipl+v0/1hnoNc/lOUT O6Rw32vKv+WRuLIiRMYtfQLkmkQ71I+SfxXBzl5snptyKH+73RtlATPb/gSk3H9q6q Hw5g47ixKXUJqlJNuGoke2hNfAFZmNtdqKfGrPD1D3alhH77nZG7DvBDwgaHqoL3ni hds/xkIS168e917VAr4U2/PDcAFwUdnC7ZeyD70243mDA5Cz4JGvgoD9cqxX3osqRx vla1F+oVd4HcQ== 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 41BE14D7E 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 E7F683A0FB8 for ; Fri, 5 Apr 2024 18:12:55 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Apr 2024 18:11:52 +0200 Message-ID: <20240405161212.26167-11-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 11/31] fftools/ffmpeg_filter: stop accessing encoder AVCodecContext 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: OroplGCQE+sO Pass all the necessary value through OutputFilterOptions. Will allow decoupling filtering from encoding in future commits. --- fftools/ffmpeg.h | 7 +++++++ fftools/ffmpeg_filter.c | 22 +++++++++++----------- fftools/ffmpeg_mux_init.c | 6 ++++++ 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index d0e896dbe7..598ca2fa96 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -282,6 +282,13 @@ typedef struct OutputFilterOptions { // A combination of OFilterFlags. unsigned flags; + + int format; + int width; + int height; + + int sample_rate; + AVChannelLayout ch_layout; } OutputFilterOptions; typedef struct InputFilter { diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 5661dc960a..3c25d2ed65 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -782,12 +782,12 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, ofp->ts_offset = opts->ts_offset; ofp->enc_timebase = opts->output_tb; - switch (ost->enc_ctx->codec_type) { + switch (ofilter->type) { case AVMEDIA_TYPE_VIDEO: - ofp->width = ost->enc_ctx->width; - ofp->height = ost->enc_ctx->height; - if (ost->enc_ctx->pix_fmt != AV_PIX_FMT_NONE) { - ofp->format = ost->enc_ctx->pix_fmt; + ofp->width = opts->width; + ofp->height = opts->height; + if (opts->format != AV_PIX_FMT_NONE) { + ofp->format = opts->format; } else if (opts->pix_fmts) ofp->formats = opts->pix_fmts; else if (opts->enc) @@ -812,19 +812,19 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, break; case AVMEDIA_TYPE_AUDIO: - if (ost->enc_ctx->sample_fmt != AV_SAMPLE_FMT_NONE) { - ofp->format = ost->enc_ctx->sample_fmt; + if (opts->format != AV_SAMPLE_FMT_NONE) { + ofp->format = opts->format; } else if (opts->enc) { ofp->formats = opts->enc->sample_fmts; } - if (ost->enc_ctx->sample_rate) { - ofp->sample_rate = ost->enc_ctx->sample_rate; + if (opts->sample_rate) { + ofp->sample_rate = opts->sample_rate; } else if (opts->enc) { ofp->sample_rates = opts->enc->supported_samplerates; } - if (ost->enc_ctx->ch_layout.nb_channels) { + if (opts->ch_layout.nb_channels) { int ret = set_channel_layout(ofp, opts->enc ? opts->enc->ch_layouts : NULL, - &ost->enc_ctx->ch_layout); + &opts->ch_layout); if (ret < 0) return ret; } else if (opts->enc) { diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 04642f5c8b..b031cc59d2 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -1378,6 +1378,12 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) { OutputFilterOptions opts = { .enc = enc, + .format = (type == AVMEDIA_TYPE_VIDEO) ? + ost->enc_ctx->pix_fmt : ost->enc_ctx->sample_fmt, + .width = ost->enc_ctx->width, + .height = ost->enc_ctx->height, + .sample_rate = ost->enc_ctx->sample_rate, + .ch_layout = ost->enc_ctx->ch_layout, .output_tb = enc_tb, .ts_offset = mux->of.start_time == AV_NOPTS_VALUE ? 0 : mux->of.start_time, From patchwork Fri Apr 5 16:11:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47850 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1071114pzd; Fri, 5 Apr 2024 09:16:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU+8VuFcHGnH14nXzwNTfWYnuIRug27xdxLpBiTlnb4DVcUDLK9zTOvz7E16muz1TrMja0DicMu3sulwTZMMZ8q4ILSik4qCC0opg== X-Google-Smtp-Source: AGHT+IF8CsdDUNbEos8i8LBdkamYCi/SDsvxjQTCHb4CDBR+PSCL/7m+ETco1Zyg+QkaPnQhy91W X-Received: by 2002:a17:906:6a1a:b0:a4e:4278:8a01 with SMTP id qw26-20020a1709066a1a00b00a4e42788a01mr1866043ejc.11.1712333793428; Fri, 05 Apr 2024 09:16:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712333793; cv=none; d=google.com; s=arc-20160816; b=P/1ska02evQkjuv0ol0HF/GAwlir4qdtmCr9OMXnOs5pWOkmhIHyXRLuwPy0nmxzst xz5YcKSOkeXN7gq5FY0W1SX1Wlwx5ObhiMuWOmcnL+rjJkWR4BPzw4UhQ+v59Ik/9sLm PSJJC0TXjSInfDzc/gAAz6/VI2c/MudhJVaO/54buCov0ph5HVSRCuazt4c+LgoMDVtZ T9j4RcYNDjF+y2k/WZMLOsRruX+dY2njuwpoJ6qz3goF5Vy/oyt82C7DjFHmJeSUqSrX H5WtPk4eFOxzwsgG6O7E0qIOQABUSFCryUb9CPn/Lc9h7TCcxo+H7nh3N9uKZrYY2ilE Nd4Q== 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:dkim-signature:delivered-to; bh=DUbNg9Oac9/PhSZ2N79RI26LhIPEzTzN8CyCGVh5AK8=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=lEULMgSQXv+D6s6UVGNs62YRjUIXlIfEwOlUTlLN0csq762AfeLjKUYvMg73tYr0NF tC+wspmz6KkpGCqRTgXpzmW7eSRe5/84+UZbJU7znrNJ3l3hhy88tgmRdg7Z0BLGAw7G g0ZAIRzzNv17dsIu8ip6qh6UnXjLlNwE2qVxSFRlLJnd2JVP9aFKmdvxuoOqfLMNME5X R4DJeFYaNRg2jMdTaqb/je7/h9btq/ZjtqssBHshoD8ssUyZZaJChS0wHYA7N5CF8MSa AE7iDqHFxNxD+34KqRcG0a1gzvJuGwI+IOZWaye7YWg7QkkTmUMVagKUuArRdo6VmZJ/ QwOg==; 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=DnleQnKk; 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 p22-20020a170906229600b00a519413794dsi818418eja.218.2024.04.05.09.16.32; Fri, 05 Apr 2024 09:16:33 -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=DnleQnKk; 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 08F7A68D2E4; Fri, 5 Apr 2024 19:13:33 +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 7172268D158 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=DnleQnKk; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 28B1D4D9D for ; Fri, 5 Apr 2024 18:13:09 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id qvoLktBHUMgj 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=sdwGf+jXopf+LjVHjXtu5JUX0A0sTl/TpYRUIlWcOrI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=DnleQnKkYX78hL16Qd/cjQmfccQCF1rHe1jnrF0DJ70KPChzsUBAW5hznfD7sXwvi TaLQevSqDgggq125kDcXwRd7teYkf9psBxAiUPxgMS2ZQ4CC33Ud0s83M3zdx2N3ku yJmvpbvVFnCX+Ug1A850Aovb4PhZtsMfS4LM3Ls9v25hdROJeerrICUTlSWsStA2H6 4LnyZDGSsw7k7csJG6UiCl7bIXExHwjUg3SMUByVvhXL+OP1BgBONricxx9Mg4I2m8 4cgwMF3ugqlH5OGezrQLXEm1ymahzah0YK1exFfCV3EmdQ4G0VlVI3U16yDtaNWVSF KekUD5qWfcJIA== 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 4C4C84D81 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 F3ADF3A1050 for ; Fri, 5 Apr 2024 18:12:55 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Apr 2024 18:11:53 +0200 Message-ID: <20240405161212.26167-12-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 12/31] fftools/ffmpeg_filter: pass vsync method 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: alI1fUhyyMAi Do not read it from OutputStream directly. Will allow decoupling filtering from encoding in future commits. --- fftools/ffmpeg.h | 3 ++- fftools/ffmpeg_filter.c | 9 +++++--- fftools/ffmpeg_mux.c | 2 +- fftools/ffmpeg_mux.h | 3 +++ fftools/ffmpeg_mux_init.c | 45 ++++++++++++++++++++++----------------- 5 files changed, 38 insertions(+), 24 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 598ca2fa96..fa8f7d8324 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -287,6 +287,8 @@ typedef struct OutputFilterOptions { int width; int height; + enum VideoSyncMethod vsync_method; + int sample_rate; AVChannelLayout ch_layout; } OutputFilterOptions; @@ -549,7 +551,6 @@ typedef struct OutputStream { /* video only */ AVRational frame_rate; AVRational max_frame_rate; - enum VideoSyncMethod vsync_method; int is_cfr; int force_fps; #if FFMPEG_OPT_TOP diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 3c25d2ed65..d906b72576 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -175,6 +175,8 @@ typedef struct FPSConvContext { int last_dropped; int dropped_keyframe; + enum VideoSyncMethod vsync_method; + AVRational framerate; AVRational framerate_max; const AVRational *framerate_supported; @@ -799,6 +801,7 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, if (!ofp->fps.last_frame) return AVERROR(ENOMEM); + ofp->fps.vsync_method = opts->vsync_method; ofp->fps.framerate = ost->frame_rate; ofp->fps.framerate_max = ost->max_frame_rate; ofp->fps.framerate_supported = ost->force_fps && opts->enc ? @@ -2072,9 +2075,9 @@ static void video_sync_process(OutputFilterPriv *ofp, AVFrame *frame, if (delta0 < 0 && delta > 0 && - ost->vsync_method != VSYNC_PASSTHROUGH + fps->vsync_method != VSYNC_PASSTHROUGH #if FFMPEG_OPT_VSYNC_DROP - && ost->vsync_method != VSYNC_DROP + && fps->vsync_method != VSYNC_DROP #endif ) { if (delta0 < -0.6) { @@ -2086,7 +2089,7 @@ static void video_sync_process(OutputFilterPriv *ofp, AVFrame *frame, delta0 = 0; } - switch (ost->vsync_method) { + switch (fps->vsync_method) { case VSYNC_VSCFR: if (fps->frame_number == 0 && delta0 >= 0.5) { av_log(ost, AV_LOG_DEBUG, "Not duplicating %d initial frames\n", (int)lrintf(delta0)); diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index e8e5c677b8..253c2e58d4 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -140,7 +140,7 @@ static int mux_fixup_ts(Muxer *mux, MuxStream *ms, AVPacket *pkt) OutputStream *ost = &ms->ost; #if FFMPEG_OPT_VSYNC_DROP - if (ost->type == AVMEDIA_TYPE_VIDEO && ost->vsync_method == VSYNC_DROP) + if (ost->type == AVMEDIA_TYPE_VIDEO && ms->ts_drop) pkt->pts = pkt->dts = AV_NOPTS_VALUE; #endif diff --git a/fftools/ffmpeg_mux.h b/fftools/ffmpeg_mux.h index 16af6d38ba..f8b6f7a790 100644 --- a/fftools/ffmpeg_mux.h +++ b/fftools/ffmpeg_mux.h @@ -75,6 +75,9 @@ typedef struct MuxStream { int copy_initial_nonkeyframes; int copy_prior_start; int streamcopy_started; +#if FFMPEG_OPT_VSYNC_DROP + int ts_drop; +#endif } MuxStream; typedef struct Muxer { diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index b031cc59d2..6ffa4b7491 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -580,8 +580,10 @@ static enum AVPixelFormat pix_fmt_parse(OutputStream *ost, const char *name) } static int new_stream_video(Muxer *mux, const OptionsContext *o, - OutputStream *ost, int *keep_pix_fmt) + OutputStream *ost, int *keep_pix_fmt, + enum VideoSyncMethod *vsync_method) { + MuxStream *ms = ms_from_ost(ost); AVFormatContext *oc = mux->fc; AVStream *st; char *frame_rate = NULL, *max_frame_rate = NULL, *frame_aspect_ratio = NULL; @@ -773,49 +775,52 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o, #endif #if FFMPEG_OPT_VSYNC - ost->vsync_method = video_sync_method; + *vsync_method = video_sync_method; #else - ost->vsync_method = VSYNC_AUTO; + *vsync_method = VSYNC_AUTO; #endif MATCH_PER_STREAM_OPT(fps_mode, str, fps_mode, oc, st); if (fps_mode) { - ret = parse_and_set_vsync(fps_mode, &ost->vsync_method, ost->file->index, ost->index, 0); + ret = parse_and_set_vsync(fps_mode, vsync_method, ost->file->index, ost->index, 0); if (ret < 0) return ret; } if ((ost->frame_rate.num || ost->max_frame_rate.num) && - !(ost->vsync_method == VSYNC_AUTO || - ost->vsync_method == VSYNC_CFR || ost->vsync_method == VSYNC_VSCFR)) { + !(*vsync_method == VSYNC_AUTO || + *vsync_method == VSYNC_CFR || *vsync_method == VSYNC_VSCFR)) { av_log(ost, AV_LOG_FATAL, "One of -r/-fpsmax was specified " "together a non-CFR -vsync/-fps_mode. This is contradictory.\n"); return AVERROR(EINVAL); } - if (ost->vsync_method == VSYNC_AUTO) { + if (*vsync_method == VSYNC_AUTO) { if (ost->frame_rate.num || ost->max_frame_rate.num) { - ost->vsync_method = VSYNC_CFR; + *vsync_method = VSYNC_CFR; } else if (!strcmp(oc->oformat->name, "avi")) { - ost->vsync_method = VSYNC_VFR; + *vsync_method = VSYNC_VFR; } else { - ost->vsync_method = (oc->oformat->flags & AVFMT_VARIABLE_FPS) ? - ((oc->oformat->flags & AVFMT_NOTIMESTAMPS) ? - VSYNC_PASSTHROUGH : VSYNC_VFR) : - VSYNC_CFR; + *vsync_method = (oc->oformat->flags & AVFMT_VARIABLE_FPS) ? + ((oc->oformat->flags & AVFMT_NOTIMESTAMPS) ? + VSYNC_PASSTHROUGH : VSYNC_VFR) : VSYNC_CFR; } - if (ost->ist && ost->vsync_method == VSYNC_CFR) { + if (ost->ist && *vsync_method == VSYNC_CFR) { const InputFile *ifile = ost->ist->file; if (ifile->nb_streams == 1 && ifile->input_ts_offset == 0) - ost->vsync_method = VSYNC_VSCFR; + *vsync_method = VSYNC_VSCFR; } - if (ost->vsync_method == VSYNC_CFR && copy_ts) { - ost->vsync_method = VSYNC_VSCFR; + if (*vsync_method == VSYNC_CFR && copy_ts) { + *vsync_method = VSYNC_VSCFR; } } - ost->is_cfr = (ost->vsync_method == VSYNC_CFR || ost->vsync_method == VSYNC_VSCFR); + ost->is_cfr = (*vsync_method == VSYNC_CFR || *vsync_method == VSYNC_VSCFR); +#if FFMPEG_OPT_VSYNC_DROP + if (*vsync_method == VSYNC_DROP) + ms->ts_drop = 1; +#endif } return 0; @@ -1043,6 +1048,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, AVStream *st; int ret = 0, keep_pix_fmt = 0; AVRational enc_tb = { 0, 0 }; + enum VideoSyncMethod vsync_method = VSYNC_AUTO; const char *bsfs = NULL, *time_base = NULL; char *filters = NULL, *next, *codec_tag = NULL; double qscale = -1; @@ -1361,7 +1367,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, ms->copy_initial_nonkeyframes, oc, st); switch (type) { - case AVMEDIA_TYPE_VIDEO: ret = new_stream_video (mux, o, ost, &keep_pix_fmt); break; + case AVMEDIA_TYPE_VIDEO: ret = new_stream_video (mux, o, ost, &keep_pix_fmt, &vsync_method); break; case AVMEDIA_TYPE_AUDIO: ret = new_stream_audio (mux, o, ost); break; case AVMEDIA_TYPE_SUBTITLE: ret = new_stream_subtitle (mux, o, ost); break; } @@ -1382,6 +1388,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, ost->enc_ctx->pix_fmt : ost->enc_ctx->sample_fmt, .width = ost->enc_ctx->width, .height = ost->enc_ctx->height, + .vsync_method = vsync_method, .sample_rate = ost->enc_ctx->sample_rate, .ch_layout = ost->enc_ctx->ch_layout, .output_tb = enc_tb, From patchwork Fri Apr 5 16:11:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47844 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1070406pzd; Fri, 5 Apr 2024 09:15:35 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU/4+evNWuVoTJeYdGOsAD7SyedpQtQv4U0fm4pYH2Ti29VCeTCQfwf6+SiycN7VqQlpaIFWDFY/jlGwaLg0HGr/Du8q27X4NeNaQ== X-Google-Smtp-Source: AGHT+IGxEKekg9yaxNs2frVXhZjvbBU0rIrwAUWmam+GMLs0cI3M/sD9LyATZQ6SjuBNN49y44xF X-Received: by 2002:a17:906:6a1a:b0:a4e:7d39:dff1 with SMTP id qw26-20020a1709066a1a00b00a4e7d39dff1mr2014850ejc.8.1712333735185; Fri, 05 Apr 2024 09:15:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712333735; cv=none; d=google.com; s=arc-20160816; b=c2ZRYoym3x1VxgdAdVvJOiS2tJEvih7ZHNFhA/UNEPLQZC5yxNwSPFYY436PWwZsJR pQ4XgYXjRY35rl18R+jhJ+uw4MroG3Rw36UmYTLFX/hOUbYePsgFDKDeDFkPPaDBvp6l XA2bLEcq/FIzX0SP08vJ+DEZrMWhoxU4DzlX+8P8NLKGIDnu28v+9M6Hte8n7bcp1jrc xJiQtA4NTpCDm1t9bJzg48dICj4GgwgAwqseHnQK77VMxWMDQXemkEiNEW4VtFOKRKwC 2ObaYjh9LJbFR1zqfQkiif2KBsN+3jUVPCsP6IncjVGSJoym3UnN45c6NLthwnzzcXdt upzA== 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:dkim-signature:delivered-to; bh=iV4BI2oe1+Jjsa1HXZVcRfwKCNsUA481iQGpjld8Plw=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=kyox7YfRkyzai9uBjLoS3y8DkH2v3sM+/cMYvWN2cKcgJd7X9a0kLVVCvp2m7EbUh5 kOm7SMnKsvJxYPITJ4Jo5tj4L1MpiNUdn0Bs9DmLgamIdyCfCn98yFp0CiW3oZT/LkvL M76p9yEXnkYtfgRaInYr07YyYos+33d2M0uiU9Vr3DL8mwIUAORDbCf5MmLBbJiCa9zz ta8rZ3gQhhM9pcP/4IuHQOcUwLWTUCNRNFFfWqBEWaViKDYjRfQTvL8Q/NuX5z20T9zz pPgxHZP5aPvflUnTLprBrf6SYWe0oCrNkdVCdZCmZbhpSjZv1llJMBS36l7G9FW92iGY nSJA==; 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=sGVZpLki; 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 oz41-20020a1709077da900b00a51a909a7d7si611112ejc.405.2024.04.05.09.15.34; Fri, 05 Apr 2024 09:15:35 -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=sGVZpLki; 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 B6BDA68D276; Fri, 5 Apr 2024 19:13:25 +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 5699E68D188 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=sGVZpLki; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id BB7F04D8A for ; Fri, 5 Apr 2024 18:13:06 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id YXfc14gQRN0C for ; Fri, 5 Apr 2024 18:13:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712333582; bh=S9WvVJmwvhe3BimRAgw/faOL9qSrogA5WHFNof012oA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=sGVZpLkiCsGE06qjgBtxUcLmhVcj2sRJ71MlP4JnSeMeQu87pfNJkfZ76mNF658gN 9tY3FG26Xwz85tnr0VSNviYP32aNQIF4HbEGcj9SOjyOa7E7AfmlHGAVx0eeVk6JV+ JsnUJXDElbBlayW5233yR/9EgcqXrMB9CPhlUorvjr72r4dj6oTVqUxFIYr6Pf1ufm /WSnI6OCBqBku1ajmdvbphQYtcJp3jcBnDiYtzovRvwWulHzsoGJhC42+wX8HQLPFu Zuarr1wv/NHchOUhXJBZVLI9TP0fss56Z9okASV4woC6m90Q8RtYqOVqh7WNnNAs9G Fz9KMEV5PRfPg== 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 C95354D8E 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 0B5163A11E7 for ; Fri, 5 Apr 2024 18:12:56 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Apr 2024 18:11:54 +0200 Message-ID: <20240405161212.26167-13-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 13/31] fftools/ffmpeg: drop OutputStream.is_cfr 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: +sIQ90zsmkON It is used in a single place in the filtering code, so it is better to inline it there. --- fftools/ffmpeg.h | 1 - fftools/ffmpeg_filter.c | 2 +- fftools/ffmpeg_mux_init.c | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index fa8f7d8324..16497105e1 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -551,7 +551,6 @@ typedef struct OutputStream { /* video only */ AVRational frame_rate; AVRational max_frame_rate; - int is_cfr; int force_fps; #if FFMPEG_OPT_TOP int top_field_first; diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index d906b72576..022c42e9c7 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1956,7 +1956,7 @@ static int choose_out_timebase(OutputFilterPriv *ofp, AVFrame *frame) fr = fr_sink; } - if (ofilter->ost->is_cfr) { + if (fps->vsync_method == VSYNC_CFR || fps->vsync_method == VSYNC_VSCFR) { if (!fr.num && !fps->framerate_max.num) { fr = (AVRational){25, 1}; av_log(ofilter->ost, AV_LOG_WARNING, diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 6ffa4b7491..1791905d7e 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -816,7 +816,6 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o, *vsync_method = VSYNC_VSCFR; } } - ost->is_cfr = (*vsync_method == VSYNC_CFR || *vsync_method == VSYNC_VSCFR); #if FFMPEG_OPT_VSYNC_DROP if (*vsync_method == VSYNC_DROP) ms->ts_drop = 1; From patchwork Fri Apr 5 16:11:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47853 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1071366pzd; Fri, 5 Apr 2024 09:16:58 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX+9i4dJwcIcjFd5UBMdyZyHZuZyXL38H53dFFJ9sqCyrtLuKdPRB6NvUEzFpggG4ryGUewYFTnHwNE1O29JSCfu2qHYd9QUPWS1A== X-Google-Smtp-Source: AGHT+IH+gSwPAJSpYMTD18j+PH/Hu8v+fXaD0iV+AoWmhMBbZ8RC4svj9a/Y3ehwjk7lLHc/fo8q X-Received: by 2002:a2e:9887:0:b0:2d8:5af9:90c5 with SMTP id b7-20020a2e9887000000b002d85af990c5mr1999449ljj.39.1712333817912; Fri, 05 Apr 2024 09:16:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712333817; cv=none; d=google.com; s=arc-20160816; b=v6F+i3Klw67szg3K4eH3YZrevLKVWtDoPjm5TozJ9B9ZoJbvCxVepFBvvs4sOjVkLS 9ufatGAG2LoWcCSzMgIC/ffwIpy32jR2SrOvGlGqk3bwFPVcC2MUlg7+LMOiXEWnZIcS Yc/PZVQBgC5JK/UH+XMc/pCPfXT4xoyRMON8wxwAJtzSTsfpmhsbS8MllpKBv8YHY208 L3jndrfC8kxUgCm7l0X3pbvZX9gLYKWsdxEK72cMfn97LUvJaSAmOeavH5dBKmo3nPds 7tXtp/Ya07o2s2VGfBDCe0eR+crNUtk64Ext6Ta/T+l2Z3UoLI+Wv1llaDE+5XA413gx y2dg== 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:dkim-signature:delivered-to; bh=BTbrE7vQNtLZ8C/+LKv+VYjXZ5reUCk3yNQsrk8p8NI=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=h+ItBu1mtfIDYNkkllLgQaLpaDU3R/EsPkv+/BPSBOejzlyrCNeAy38bcuJaMuCkl9 pJnqdO95wwLLmX7n/AuMKafeHguebMw4X8k+WEVFr5B1k9AgtOXaN9QjLnysEXhQ8v7H lOevBuMhcEFqe5DT43G4MIQ0stlm21MvBpXrFwLfE3ZqrCNV8SZrUErMc7SjR3SL6b7k z9GwKu1dFRNWBmdALjKlyEPYHL4hFTLkSlrCNCb7GuESR21tbKB4Cf0dO+o9mVLKumSN AtoeJPAxDUNCGfd11fQLB+H2z1eVInQ9OKQ0k3wsYpG7S/69wP1ZPwCat7xXC7xEaGGA 0gnA==; 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=qkwjmLDy; 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 s6-20020a1709067b8600b00a4e6cdf8ea3si822180ejo.715.2024.04.05.09.16.57; Fri, 05 Apr 2024 09:16:57 -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=qkwjmLDy; 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 E8D6968D315; Fri, 5 Apr 2024 19:13:35 +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 9471F68D16C 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=qkwjmLDy; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id B03614D91 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 VGFObdOn88gg 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=Eoq48a4W1o2ejS3sixphWC3FuMbNCjYVuYNqJWqNeIk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=qkwjmLDySheq1dwWENN+P5e9N2M7tUgFNNLvtsYjMHNkoKIbsxbd44ZQsM6yqkIGu QlI4pd3fOQXhdTuSSKNrjmMgA3+5O72XFtyqKh2ctIwaqlTZb1ATzGTOoZ9YrW6HM2 ucSX7NWFnCucWdYPe1qNPAqWUWEQqJgUkZFUdOJ1CygR0Vh3Ge329O/oyndohCgc5k KuVu+otpw3uRa5Lxt++uo2mMDQ/kbRCMM1FWEqMrg2JCOkcUZgSeyOqaYu7bPibCJA 0iFvyg7aFlAhIhC6dIshZ5YVMQgiXIRNAtsIcN55JR5mCSa/lv070Ukk2Q0Thbkmll +t+HR0hqZhK1A== 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 5610F4D88 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 173023A11EF for ; Fri, 5 Apr 2024 18:12:56 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Apr 2024 18:11:55 +0200 Message-ID: <20240405161212.26167-14-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 14/31] fftools/ffmpeg_filter: accept a caller-provided output name 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: zAWWWLyWhUgS Do not construct it from OutputStream manually. Will allow decoupling filtering from encoding in future commits. --- fftools/ffmpeg.h | 3 +++ fftools/ffmpeg_filter.c | 36 +++++++++++++++++++----------------- fftools/ffmpeg_mux_init.c | 4 ++++ 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 16497105e1..3c196c25e5 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -268,6 +268,9 @@ enum OFilterFlags { }; typedef struct OutputFilterOptions { + // Caller-provided name for this output + char *name; + // Codec used for encoding, may be NULL const AVCodec *enc; // Overrides encoder pixel formats when set. diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 022c42e9c7..ceab58da19 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -188,6 +188,8 @@ typedef struct OutputFilterPriv { int index; + char *name; + AVFilterContext *filter; /* desired output stream properties */ @@ -784,6 +786,10 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, ofp->ts_offset = opts->ts_offset; ofp->enc_timebase = opts->output_tb; + ofp->name = av_strdup(opts->name); + if (!ofp->name) + return AVERROR(EINVAL); + switch (ofilter->type) { case AVMEDIA_TYPE_VIDEO: ofp->width = opts->width; @@ -911,6 +917,7 @@ void fg_free(FilterGraph **pfg) av_freep(&ofilter->linklabel); av_freep(&ofilter->name); + av_freep(&ofp->name); av_channel_layout_uninit(&ofp->ch_layout); av_freep(&fg->outputs[j]); } @@ -1076,9 +1083,8 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost, fgp->is_simple = 1; - snprintf(fgp->log_name, sizeof(fgp->log_name), "%cf#%d:%d", - av_get_media_type_string(ost->type)[0], - ost->file->index, ost->index); + snprintf(fgp->log_name, sizeof(fgp->log_name), "%cf%s", + av_get_media_type_string(ost->type)[0], opts->name); if (fg->nb_inputs != 1 || fg->nb_outputs != 1) { av_log(fg, AV_LOG_ERROR, "Simple filtergraph '%s' was expected " @@ -1305,7 +1311,7 @@ static int configure_output_video_filter(FilterGraph *fg, AVFilterGraph *graph, const char *pix_fmts; char name[255]; - snprintf(name, sizeof(name), "out_%d_%d", ost->file->index, ost->index); + snprintf(name, sizeof(name), "out_%s", ofp->name); ret = avfilter_graph_create_filter(&ofp->filter, avfilter_get_by_name("buffersink"), name, NULL, NULL, graph); @@ -1325,8 +1331,7 @@ static int configure_output_video_filter(FilterGraph *fg, AVFilterGraph *graph, av_strlcatf(args, sizeof(args), ":%s=%s", e->key, e->value); } - snprintf(name, sizeof(name), "scaler_out_%d_%d", - ost->file->index, ost->index); + snprintf(name, sizeof(name), "scaler_out_%s", ofp->name); if ((ret = avfilter_graph_create_filter(&filter, avfilter_get_by_name("scale"), name, args, NULL, graph)) < 0) return ret; @@ -1358,8 +1363,7 @@ static int configure_output_video_filter(FilterGraph *fg, AVFilterGraph *graph, pad_idx = 0; } - snprintf(name, sizeof(name), "trim_out_%d_%d", - ost->file->index, ost->index); + snprintf(name, sizeof(name), "trim_out_%s", ofp->name); ret = insert_trim(of->start_time, of->recording_time, &last_filter, &pad_idx, name); if (ret < 0) @@ -1384,7 +1388,7 @@ static int configure_output_audio_filter(FilterGraph *fg, AVFilterGraph *graph, char name[255]; int ret; - snprintf(name, sizeof(name), "out_%d_%d", ost->file->index, ost->index); + snprintf(name, sizeof(name), "out_%s", ofp->name); ret = avfilter_graph_create_filter(&ofp->filter, avfilter_get_by_name("abuffersink"), name, NULL, NULL, graph); @@ -1424,8 +1428,7 @@ static int configure_output_audio_filter(FilterGraph *fg, AVFilterGraph *graph, if (args.len) { AVFilterContext *format; - snprintf(name, sizeof(name), "format_out_%d_%d", - ost->file->index, ost->index); + snprintf(name, sizeof(name), "format_out_%s", ofp->name); ret = avfilter_graph_create_filter(&format, avfilter_get_by_name("aformat"), name, args.str, NULL, graph); @@ -1452,8 +1455,7 @@ static int configure_output_audio_filter(FilterGraph *fg, AVFilterGraph *graph, } } - snprintf(name, sizeof(name), "trim for output stream %d:%d", - ost->file->index, ost->index); + snprintf(name, sizeof(name), "trim for output %s", ofp->name); ret = insert_trim(of->start_time, of->recording_time, &last_filter, &pad_idx, name); if (ret < 0) @@ -2699,10 +2701,10 @@ static void fg_thread_set_name(const FilterGraph *fg) { char name[16]; if (filtergraph_is_simple(fg)) { - OutputStream *ost = fg->outputs[0]->ost; - snprintf(name, sizeof(name), "%cf#%d:%d", - av_get_media_type_string(ost->type)[0], - ost->file->index, ost->index); + OutputFilterPriv *ofp = ofp_from_ofilter(fg->outputs[0]); + snprintf(name, sizeof(name), "%cf%s", + av_get_media_type_string(ofp->ofilter.type)[0], + ofp->name); } else { snprintf(name, sizeof(name), "fc%d", fg->index); } diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 1791905d7e..219be5f965 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -1381,8 +1381,10 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, if (ost->enc && (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) { + char name[16]; OutputFilterOptions opts = { .enc = enc, + .name = name, .format = (type == AVMEDIA_TYPE_VIDEO) ? ost->enc_ctx->pix_fmt : ost->enc_ctx->sample_fmt, .width = ost->enc_ctx->width, @@ -1396,6 +1398,8 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, .flags = OFILTER_FLAG_DISABLE_CONVERT * !!keep_pix_fmt, }; + snprintf(name, sizeof(name), "#%d:%d", mux->of.index, ost->index); + // 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 From patchwork Fri Apr 5 16:11:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47855 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1071542pzd; Fri, 5 Apr 2024 09:17:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWOspCisNOGVpCbN8StDqR0ak7aS5jkElewGg22aTHoKe3BWcITPKrZyKUQ4NNPLoCMBEuL31fwjzzPcAxDYfvjfb0N6jiMIwxW4g== X-Google-Smtp-Source: AGHT+IFQruicgAwmt6GtrzkeHF6oYDjPUqMGiGuECPQj0ZapxmQNfgUCgamWfFuUubV0E+ldmNpr X-Received: by 2002:ac2:5e91:0:b0:513:13eb:c99b with SMTP id b17-20020ac25e91000000b0051313ebc99bmr1494783lfq.62.1712333834147; Fri, 05 Apr 2024 09:17:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712333834; cv=none; d=google.com; s=arc-20160816; b=nEna0Dr1379GfPVq6dxxSSrAyjMiJ9i+P4TC6hb1enfk29VWPYPRd6iSkeFqsTfLU3 u7MWRuJNpUtrXQka9LRYD15KM3S1TJOB9L5beUF9zh+YKkft4bBP5JWFZGNkr5Il6v4g OhZxN0OqOS5uQglyWEIs3HOvLIlF1/XPHr4s6eQfPTgyZvyZDyBZwH3oG+ZZTeAnGQAp B/2zhE4L4//V+bM0K3sybqlChT344aODxUlwV5ohXiU/VsCv6EwAtmVqA9sOq4EPLgxO J6hBl/fFBeXnGMj5bGuuhlcDNlA4F5BpY7AHxidGP96Mji6ZUemYZXso4//92SLbQwDh E3tw== 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:dkim-signature:delivered-to; bh=B2PjNWg5A1YOamd3/ISRDs5cQfliVnRZHPI9ame4UHk=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=KB0UGgCMeKGb2oAJeRYif/5+ND/m79yX8Z8aLz0tR/Jc4fP+yIoK0/ZwoaW4UR0NCi QlGegxJ+Py+UNAbYe8ASmCrd4RCjAvS4CJrVDBagCPYJjtH7fQRslsCnIzNlRGcKuqpH +mtaWlwNu5rHClP169a0UyKSpQ3wcbGD5OiSZ67CswexAWggMnMR/ifkr2hfxIHUYUxz dQ42whWFzWcGnri2egHRZYo4fMmLM/lGQT1j88qUmZdt7Xp+qaE8H4fFi7iT83QfytQ9 tGNrBH+XOerFEzybv5wiWkPOgE5Pc2RP+DP9SJ/RUNCRveNUl5XM0PLQG1stm3CSk5DP C58Q==; 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=KZGl1MFA; 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 h26-20020a170906111a00b00a5197312ca1si850061eja.29.2024.04.05.09.17.13; Fri, 05 Apr 2024 09:17:14 -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=KZGl1MFA; 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 E198C68D34A; Fri, 5 Apr 2024 19:13:37 +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 A4B1468D1CC 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=KZGl1MFA; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id A79094D98 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 HgXnpwGNbKNS 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=w1ibmGMawq4YNzGz/se/JtbepQjT564Jqbp/2DMKnE4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=KZGl1MFAfME5UyjKZjplHnEaJ9VGgTW8ML6PUmf89wOS1mVQJ1DxCJ0SgqNFiuqR9 T07XM49k1detFLewpQEmdYk/paveX7x4DYbZWRkikg9LTcsm+UvkgbMhzWJZBf6MAh dHV4ZKKq+ptxME1k6AwBtzYnUKXyh6vs6GJm5BThfEIPR0GK4hwW2DulIInE1R91kp jfHpaISwBzkPagGnM30TNUibRMuLiA4s6KXMUxRMeiGMjtK2euH7YA4a4jptWtlJ6z 0+JbMv2+6wpj/+VlQUjCKnPschS0r1b9dyB6H5SHWPqmlsJPPJ2ARBKIw7pNsvZYkO 8je6BMWsAMJ1g== 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 560AE4D86 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 22BC03A131E for ; Fri, 5 Apr 2024 18:12:56 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Apr 2024 18:11:56 +0200 Message-ID: <20240405161212.26167-15-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 15/31] fftools/ffmpeg_filter: drop a redundant check 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: v13gCVtiUPJ5 fg_finalise_bindings() already checks that all filtergraph outputs are connected. --- fftools/ffmpeg_filter.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index ceab58da19..41d96267bc 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1472,11 +1472,6 @@ fail: static int configure_output_filter(FilterGraph *fg, AVFilterGraph *graph, OutputFilter *ofilter, AVFilterInOut *out) { - if (!ofilter->ost) { - av_log(fg, AV_LOG_FATAL, "Filter %s has an unconnected output\n", ofilter->name); - return AVERROR(EINVAL); - } - switch (avfilter_pad_get_type(out->filter_ctx->output_pads, out->pad_idx)) { case AVMEDIA_TYPE_VIDEO: return configure_output_video_filter(fg, graph, ofilter, out); case AVMEDIA_TYPE_AUDIO: return configure_output_audio_filter(fg, graph, ofilter, out); From patchwork Fri Apr 5 16:11:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47842 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1070167pzd; Fri, 5 Apr 2024 09:15:18 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX2+a1SPr9M+44X2ddDTF5wpGUX7+5Fk6cjt/Yw1r2MvQJzqizd9Dpxpxe9PAT/HX4IF9Py33QscmvS2pjImSMyPWDPiDHnpguJJw== X-Google-Smtp-Source: AGHT+IEpO73G4c1awhh7T7aiscPDuvLsHdas8ZniCB6hUacH17CZygECBHQBnRFCND9ru2RacURm X-Received: by 2002:a50:d599:0:b0:56c:5990:813e with SMTP id v25-20020a50d599000000b0056c5990813emr1453332edi.13.1712333718337; Fri, 05 Apr 2024 09:15:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712333718; cv=none; d=google.com; s=arc-20160816; b=Q/DvwZ4RdYRW162eWvouw6jRm0xBuyKVN733MBEw+UHrGcv82AXUK/ZmQXVR3Wvrrg +W21+YtuoBTUebPhL1bKai8YyUVymQ5TE+0Jzh9fwEt6evUUb4/qQ+Zue0uVYXE/c/Ce ytkFgOdvFQrVhd1eoFs/q5sZNATHfqXMFVEqZWFloU6UuOinWjnciagxM//CZw0BVvQQ Olu4d3yQA0mJHVm3PbTqtXpe0CpYsPLXV9dK36fOwRsHWmLTKmCxYJ6hGwIEjll+d/D+ KOqYMUDjGtF63/czwMZPwAsDs/ttevYcBG7+2pfRN/QLpQS41XFUGOjWPfNjMknXOQC8 m6KA== 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:dkim-signature:delivered-to; bh=SRMbfQRIJHP1ZDBOQDYC4a1xHugeEiqOZLZ7LooyAK8=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=BA66JcA0JfpbFni3Mo7LzjSKd9Z4eqG11lXtMMaZzhGv4d8+pY2ELzjz8lFedMTcI5 r+dRXkddzAhnOo82x73IJ8pp4fK0n27FZ9w4oU997Ewu1iLiScvAXxEZlAWrov6RGZnv kFkBnxzRHtPgCVw8hTycgh8TaruamVEEpSgOl4e3cFEpud8sA3UucwuWIL9A4WHmRPeU gLnVjdzL/J3Lf9q3JIoJJfiKpgKNYJjGQU/f/n9st9Og55K1yhjoVwbjoLSjey1YRD6O HT6VUGKa5F33xWjEFkR2uZFK/ymOZJXi8kA130fBh8S5PHHZDxQSmaLMM2yuP7tOmA+b SXqg==; 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="h7O5H/tX"; 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 a15-20020a05640213cf00b0056e35a7b0d5si378824edx.390.2024.04.05.09.15.17; Fri, 05 Apr 2024 09:15:18 -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="h7O5H/tX"; 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 DF34D68D25F; Fri, 5 Apr 2024 19:13:23 +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 56A8E68D189 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=h7O5H/tX; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id D94AB4D8C for ; Fri, 5 Apr 2024 18:13:06 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id ebzqU8dLzwKl for ; Fri, 5 Apr 2024 18:13:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712333582; bh=MYyh6JhpJ3p6aC8RdXJjeSMVfoaxQXmHIPV4fBf/vd8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=h7O5H/tXbcNzG+K4/fcpQksgKFoLgIj275YNXDDu75YuaKujpU/qHQL2ZfW5syXVB 988IlWHNnP6Zu3ee4ZwSzWvEypGe6+1y30ugowgHjek0u6Bq5dZNeXD6YwC66lTEGW 2YU3r6UMs3fB+ZYt+AJ/GivyFHxN38fps6FtoSDCsRjgtMhWKx3VmqAaHloJ3ZyiwU CV1pqAuyCgnV8Q+hpO73Oa19Nnpuyu5wVRYq2ppfNFlXU/CRbHUOT51K4/56rf+2Rv QH1jSb1KlwriYKCTown+6Ylq/QP++nLtUU01CI3ZXetP8hFX6Yr16QJ0KU8KXxzpgc IvcvS4navDs0Q== 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 561464D89 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 2F7113A134E for ; Fri, 5 Apr 2024 18:12:56 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Apr 2024 18:11:57 +0200 Message-ID: <20240405161212.26167-16-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 16/31] fftools/ffmpeg_filter: simplify retrieving filter type 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: H7t57WSbPEuo --- fftools/ffmpeg_filter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 41d96267bc..ffbc13eb70 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1472,7 +1472,7 @@ fail: static int configure_output_filter(FilterGraph *fg, AVFilterGraph *graph, OutputFilter *ofilter, AVFilterInOut *out) { - switch (avfilter_pad_get_type(out->filter_ctx->output_pads, out->pad_idx)) { + switch (ofilter->type) { case AVMEDIA_TYPE_VIDEO: return configure_output_video_filter(fg, graph, ofilter, out); case AVMEDIA_TYPE_AUDIO: return configure_output_audio_filter(fg, graph, ofilter, out); default: av_assert0(0); return 0; From patchwork Fri Apr 5 16:11:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47838 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1069739pzd; Fri, 5 Apr 2024 09:14:43 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCULNSJdsvmfoTreU5YFevZTm4TbClQwcYii0LTAP5l2qjKY1UWs5p9ikIJmosPeSkMfY11uRIIX7FVt+kZcykcu2dnpZAj6M0a/dw== X-Google-Smtp-Source: AGHT+IFdIiYuDUfHQ6AJIlGdaQ0srFi3hCR8qAawBoSsgm3QeAH5/HTojxNhbIfeTeUNtNM8sVFj X-Received: by 2002:a17:906:fccc:b0:a51:7c31:24a7 with SMTP id qx12-20020a170906fccc00b00a517c3124a7mr2466027ejb.5.1712333683340; Fri, 05 Apr 2024 09:14:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712333683; cv=none; d=google.com; s=arc-20160816; b=RKmvGQvD6mHVQmlXtTsMOwvf7lvoXAwGGRMl+bZAOtcUjPXwV7aEDwIAkz3L5ZtDsw 4NVTDJn42UAvJzR8d7r5aH1AqrfOOTRB2cNPDLcaZRIVFakmFyZw7vH8HKB5uMYH0QGd Y5ykPOdm7vYbcjrc3ItLjHK2+v9AyuaM64YI/7GBAEMbwha86KBrZD/1wjyZQGC7yNde N3by/q2a+8F6cUhOXaQnwe1FRqjcFKmpIlVChM9kiI/EreqfzN44NuWIsiPn0COezpNG kpMvOzLYQp8nQfo9JV9xRGYMtv7Er0SV+oUPrP6kaSClmTdm//nvhkcFHwfvCP6Qm1Rn 7ghA== 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:dkim-signature:delivered-to; bh=IAO+1aWp6e/oav7shEnaFe+mKD91/nts3IDUkA0TrsA=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=bUSySJ7e3VRg/fzk7Gv1zMbDJHIt3PKFShDauUI6JuDRegyWK3xm0Sshz/5VMx0VJG 5wZYJkpLwKq0Rb0CPA4YtyOS7WmPmKTKtrcl6EjyQLDhSJruCMAnqxZJd5YYMWvyRljy fqwME/z0cFtPc2ch1Pi23gljmxMxMGyeLU5x/qtaqv69Iwxixl0HFZmsD+K4dorHJmYB h3hXTHW/o347U+8LkBli9zA/f9Vwimvf4R3gCtTxbs8Q6xf0DQarx333UiOoH/pjqZoW DL5Ve8EmDmvAPy+UXCKASWCfibPMA1r6bu4/gy6FaCIJxDoPqpwfXM1zYb1t5eBSf/Sd z1bg==; 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=hCmES+iY; 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 z22-20020a1709060ad600b00a4e6c0b39casi823969ejf.30.2024.04.05.09.14.16; Fri, 05 Apr 2024 09:14:43 -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=hCmES+iY; 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 7647E68D234; Fri, 5 Apr 2024 19:13:17 +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 3BA2168D15D 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=hCmES+iY; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 01BEE4D78 for ; Fri, 5 Apr 2024 18:13:06 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id ZMpf4tEyyhkq for ; Fri, 5 Apr 2024 18:13:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712333582; bh=LqeWBf3jrvlD3bUN0mTqjs72nlHByuX8HLo8m+d69Xg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=hCmES+iYVlTciiD2vv5DP2ETlk5OCs9bkC1qBreVdBQLsZa/VyFBUez+zQgdmR6dU Fyk42ksFl1IOpmOvdCYL60NJ/+j26r6lmm9I7s3VTYQu06208S3cXlBs0BFIIt7Y/V sgDNdqyL7Wb32+XvL9k5IqQuF/C+S5cn4uU71sJZ9/4rmugovZ26VGapOM+hMBb46D xmMG/rPka3Z1Xd3eaha5wbLqBPckAV9uxc08/lcmAg1vddJUZL5kP2G43wzUPyhGm+ gJqUuZthWQ0SNXdhG3N4WgCTLBD6Dcwc0AA6xxPRa5nd+9E/6yzuZV/S5pykURamKQ U8CPDHKvvefOw== 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 6232C4D8A 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 3B4AC3A157E for ; Fri, 5 Apr 2024 18:12:56 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Apr 2024 18:11:58 +0200 Message-ID: <20240405161212.26167-17-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 17/31] fftools/ffmpeg_filter: add an AVClass to OutputFilter 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: YVIJ4ZKNn6DO Use it for logging where appropriate, avoid logging to OutputStream as we do not own it. This is a step towards decoupling filtering from encoding. --- fftools/ffmpeg.h | 2 ++ fftools/ffmpeg_filter.c | 68 +++++++++++++++++++++++++++++------------ 2 files changed, 51 insertions(+), 19 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 3c196c25e5..786f925bc6 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -302,6 +302,8 @@ typedef struct InputFilter { } InputFilter; typedef struct OutputFilter { + const AVClass *class; + struct OutputStream *ost; struct FilterGraph *graph; uint8_t *name; diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index ffbc13eb70..840502bd62 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -188,6 +188,9 @@ typedef struct OutputFilterPriv { int index; + void *log_parent; + char log_name[32]; + char *name; AVFilterContext *filter; @@ -629,7 +632,21 @@ static char *describe_filter_link(FilterGraph *fg, AVFilterInOut *inout, int in) avfilter_pad_get_name(pads, inout->pad_idx)); } -static OutputFilter *ofilter_alloc(FilterGraph *fg) +static const char *ofilter_item_name(void *obj) +{ + OutputFilterPriv *ofp = obj; + return ofp->log_name; +} + +static const AVClass ofilter_class = { + .class_name = "OutputFilter", + .version = LIBAVUTIL_VERSION_INT, + .item_name = ofilter_item_name, + .parent_log_context_offset = offsetof(OutputFilterPriv, log_parent), + .category = AV_CLASS_CATEGORY_FILTER, +}; + +static OutputFilter *ofilter_alloc(FilterGraph *fg, enum AVMediaType type) { OutputFilterPriv *ofp; OutputFilter *ofilter; @@ -639,10 +656,16 @@ static OutputFilter *ofilter_alloc(FilterGraph *fg) return NULL; ofilter = &ofp->ofilter; + ofilter->class = &ofilter_class; + ofp->log_parent = fg; ofilter->graph = fg; + ofilter->type = type; ofp->format = -1; ofp->index = fg->nb_outputs - 1; + snprintf(ofp->log_name, sizeof(ofp->log_name), "%co%d", + av_get_media_type_string(type)[0], ofp->index); + return ofilter; } @@ -790,6 +813,14 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, if (!ofp->name) return AVERROR(EINVAL); + if (fgp->is_simple) { + // for simple filtergraph there is just one output, + // so use only graph-level information for logging + ofp->log_parent = NULL; + av_strlcpy(ofp->log_name, fgp->log_name, sizeof(ofp->log_name)); + } else + av_strlcatf(ofp->log_name, sizeof(ofp->log_name), "->%s", ofp->name); + switch (ofilter->type) { case AVMEDIA_TYPE_VIDEO: ofp->width = opts->width; @@ -1025,7 +1056,9 @@ int fg_create(FilterGraph **pfg, char *graph_desc, Scheduler *sch) } for (AVFilterInOut *cur = outputs; cur; cur = cur->next) { - OutputFilter *const ofilter = ofilter_alloc(fg); + const enum AVMediaType type = avfilter_pad_get_type(cur->filter_ctx->output_pads, + cur->pad_idx); + OutputFilter *const ofilter = ofilter_alloc(fg, type); if (!ofilter) { ret = AVERROR(ENOMEM); @@ -1035,8 +1068,6 @@ int fg_create(FilterGraph **pfg, char *graph_desc, Scheduler *sch) ofilter->linklabel = cur->name; cur->name = NULL; - ofilter->type = avfilter_pad_get_type(cur->filter_ctx->output_pads, - cur->pad_idx); ofilter->name = describe_filter_link(fg, cur, 0); if (!ofilter->name) { ret = AVERROR(ENOMEM); @@ -1400,7 +1431,7 @@ static int configure_output_audio_filter(FilterGraph *fg, AVFilterGraph *graph, #define AUTO_INSERT_FILTER(opt_name, filter_name, arg) do { \ AVFilterContext *filt_ctx; \ \ - av_log(fg, AV_LOG_INFO, opt_name " is forwarded to lavfi " \ + av_log(ofilter, AV_LOG_INFO, opt_name " is forwarded to lavfi " \ "similarly to -af " filter_name "=%s.\n", arg); \ \ ret = avfilter_graph_create_filter(&filt_ctx, \ @@ -1929,7 +1960,7 @@ static int choose_out_timebase(OutputFilterPriv *ofp, AVFrame *frame) // apply -enc_time_base if (ofp->enc_timebase.num == ENC_TIME_BASE_DEMUX && (fd->dec.tb.num <= 0 || fd->dec.tb.den <= 0)) { - av_log(ofilter->ost, AV_LOG_ERROR, + av_log(ofp, AV_LOG_ERROR, "Demuxing timebase not available - cannot use it for encoding\n"); return AVERROR(EINVAL); } @@ -1956,7 +1987,7 @@ static int choose_out_timebase(OutputFilterPriv *ofp, AVFrame *frame) if (fps->vsync_method == VSYNC_CFR || fps->vsync_method == VSYNC_VSCFR) { if (!fr.num && !fps->framerate_max.num) { fr = (AVRational){25, 1}; - av_log(ofilter->ost, AV_LOG_WARNING, + av_log(ofp, AV_LOG_WARNING, "No information " "about the input framerate is available. Falling " "back to a default value of 25fps. Use the -r option " @@ -2039,7 +2070,6 @@ static void video_sync_process(OutputFilterPriv *ofp, AVFrame *frame, int64_t *nb_frames, int64_t *nb_frames_prev) { OutputFilter *ofilter = &ofp->ofilter; - OutputStream *ost = ofilter->ost; FPSConvContext *fps = &ofp->fps; double delta0, delta, sync_ipts, duration; @@ -2078,9 +2108,9 @@ static void video_sync_process(OutputFilterPriv *ofp, AVFrame *frame, #endif ) { if (delta0 < -0.6) { - av_log(ost, AV_LOG_VERBOSE, "Past duration %f too large\n", -delta0); + av_log(ofp, AV_LOG_VERBOSE, "Past duration %f too large\n", -delta0); } else - av_log(ost, AV_LOG_DEBUG, "Clipping frame in rate conversion by %f\n", -delta0); + av_log(ofp, AV_LOG_DEBUG, "Clipping frame in rate conversion by %f\n", -delta0); sync_ipts = ofp->next_pts; duration += delta0; delta0 = 0; @@ -2089,7 +2119,7 @@ static void video_sync_process(OutputFilterPriv *ofp, AVFrame *frame, switch (fps->vsync_method) { case VSYNC_VSCFR: if (fps->frame_number == 0 && delta0 >= 0.5) { - av_log(ost, AV_LOG_DEBUG, "Not duplicating %d initial frames\n", (int)lrintf(delta0)); + av_log(ofp, AV_LOG_DEBUG, "Not duplicating %d initial frames\n", (int)lrintf(delta0)); delta = duration; delta0 = 0; ofp->next_pts = llrint(sync_ipts); @@ -2133,23 +2163,23 @@ finish: if (*nb_frames_prev == 0 && fps->last_dropped) { atomic_fetch_add(&ofilter->nb_frames_drop, 1); - av_log(ost, AV_LOG_VERBOSE, + av_log(ofp, AV_LOG_VERBOSE, "*** dropping frame %"PRId64" at ts %"PRId64"\n", fps->frame_number, fps->last_frame->pts); } if (*nb_frames > (*nb_frames_prev && fps->last_dropped) + (*nb_frames > *nb_frames_prev)) { uint64_t nb_frames_dup; if (*nb_frames > dts_error_threshold * 30) { - av_log(ost, AV_LOG_ERROR, "%"PRId64" frame duplication too large, skipping\n", *nb_frames - 1); + av_log(ofp, AV_LOG_ERROR, "%"PRId64" frame duplication too large, skipping\n", *nb_frames - 1); atomic_fetch_add(&ofilter->nb_frames_drop, 1); *nb_frames = 0; return; } nb_frames_dup = atomic_fetch_add(&ofilter->nb_frames_dup, *nb_frames - (*nb_frames_prev && fps->last_dropped) - (*nb_frames > *nb_frames_prev)); - av_log(ost, AV_LOG_VERBOSE, "*** %"PRId64" dup!\n", *nb_frames - 1); + av_log(ofp, AV_LOG_VERBOSE, "*** %"PRId64" dup!\n", *nb_frames - 1); if (nb_frames_dup > fps->dup_warning) { - av_log(ost, AV_LOG_WARNING, "More than %"PRIu64" frames duplicated\n", fps->dup_warning); + av_log(ofp, AV_LOG_WARNING, "More than %"PRIu64" frames duplicated\n", fps->dup_warning); fps->dup_warning *= 10; } } @@ -2191,7 +2221,7 @@ static int close_output(OutputFilterPriv *ofp, FilterGraphThread *fgt) av_assert0(!frame->buf[0]); - av_log(ofp->ofilter.ost, AV_LOG_WARNING, + av_log(ofp, AV_LOG_WARNING, "No filtered frames for output stream, trying to " "initialize anyway.\n"); @@ -2308,7 +2338,7 @@ static int fg_output_step(OutputFilterPriv *ofp, FilterGraphThread *fgt, } else if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) { return 1; } else if (ret < 0) { - av_log(fgp, AV_LOG_WARNING, + av_log(ofp, AV_LOG_WARNING, "Error in retrieving a frame from the filtergraph: %s\n", av_err2str(ret)); return ret; @@ -2322,7 +2352,7 @@ static int fg_output_step(OutputFilterPriv *ofp, FilterGraphThread *fgt, frame->time_base = av_buffersink_get_time_base(filter); if (debug_ts) - av_log(fgp, AV_LOG_INFO, "filter_raw -> pts:%s pts_time:%s time_base:%d/%d\n", + av_log(ofp, AV_LOG_INFO, "filter_raw -> pts:%s pts_time:%s time_base:%d/%d\n", av_ts2str(frame->pts), av_ts2timestr(frame->pts, &frame->time_base), frame->time_base.num, frame->time_base.den); @@ -2330,7 +2360,7 @@ static int fg_output_step(OutputFilterPriv *ofp, FilterGraphThread *fgt, if (!ofp->tb_out_locked) { ret = choose_out_timebase(ofp, frame); if (ret < 0) { - av_log(ost, AV_LOG_ERROR, "Could not choose an output time base\n"); + av_log(ofp, AV_LOG_ERROR, "Could not choose an output time base\n"); av_frame_unref(frame); return ret; } From patchwork Fri Apr 5 16:11:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47836 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1069691pzd; Fri, 5 Apr 2024 09:14:38 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW4vjRnyktwU6k889IabwWb3EOLCq/0T4pVkC1cec0CNRuBtZjWWmf8OkL4MErSaQgsyN1vFuwyL5TahyjPpA5J6fKVNW7hoRVUmw== X-Google-Smtp-Source: AGHT+IFJToUq/kFy2PaztK4ULDmkXnCQQj3seMhan/QHQFpgUx/BsnIMyD93TgrMsybA46ttoow3 X-Received: by 2002:a17:906:1390:b0:a51:9341:a37f with SMTP id f16-20020a170906139000b00a519341a37fmr1345500ejc.71.1712333678302; Fri, 05 Apr 2024 09:14:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712333678; cv=none; d=google.com; s=arc-20160816; b=aXH1byIk1yV0279Z+2VGmu1AFe8JMJVfJwwygn0zaaIRZrJbI569HFr97tJLpusq1e cnH2vlU6LhvBVqv1Dc4ybdX0ctbBsmq6scfQ/8DtsoKNyyFKiC9s4CP6rZzol1VFkT0J top/oEnnzJBX/zsG3tVjoi4ZeTAWR+uqCJhrL1cGRz9d9LjlrQP3WaHOiA+0TJA5ruB0 QUKj0mN/jXUi1S0wZTZ+4hyn3ZBSA8E8rkUaVvIWghLXT/lDiXvVw87L/tJqEwVsxrvW J5eopmRLOHtAYx0b5kwZ8pQ09OKct+7Uc+U8E7Imq36StLejlJPw0AfWCDeRDuIHQREM TrFA== 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:dkim-signature:delivered-to; bh=oy2AHXmiwXqix8rehGa+KUJMwah2erqJZv4BZthkevc=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=A/zbbAhRuoHPW2lmLpiahbX1jrNAWb3I7F0QBT07I3ZoTM2KCJxOfskhMOmcQGy+/w TxNDKROKI2OTuNXU16zGrGGWMIW37aduWKxpVhgLzMYJoImNtkuUc7T/Q0UEH4yeX1Xa WAxYRokwtPsaEFrAMf6pTRL28MPBtMYd3SGihITtGRam6iKVLVj8OWRKQ+f2tOXQ2U3/ TPstdqV+0qRl/ENFdoNjAJdlunfOdwGa0W1C6QYz3z8voHp0KvZtjTXFHUF7oxTP4UCJ JMcd8enZXzzwtFJ7fEzc3GydvAxb7KcxZYs0Tv+9sfYGJcfnpAjC+2JN4Y9gUXOfCZaw GjGw==; 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=Ya0VC5dn; 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 qx13-20020a170906fccd00b00a51a0a1e87asi820230ejb.175.2024.04.05.09.14.34; Fri, 05 Apr 2024 09:14:38 -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=Ya0VC5dn; 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 3BC8368D202; Fri, 5 Apr 2024 19:13:19 +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 3BCE168D168 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=Ya0VC5dn; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 288974D7C for ; Fri, 5 Apr 2024 18:13:06 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id dQP0dKCBvQKs for ; Fri, 5 Apr 2024 18:13:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712333582; bh=c8RF8cb8P68x1fKu9/fqzJQ+wLWHY8HLJ2lzY9FOYS4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Ya0VC5dntZflv097WyTmIKIII0r1f4s8HYtUhqN2qxbGECEtO15pzx566U10m3DEY hggeKFPkmXl3md695Dapr9U3ZDLWJrk070BfKcuBoUOITGLFXUYKYQzoGqwUw6FoqU Di28TjTyYo9/xUOL8iVPWxiHB9hha2yqmRdsDSrv2nqaRJEIHgrW2GnTPn16jCtpBJ HfJrY3/otAmZp3py7D0q9Jcc+1WobK3ichqZekZ9oVfUXvgaSYPaBmgF2Avc9/F7uo IpiIq48FXOm5yOFVqaMJxKXCcEhHTWlcPm/8Qozg8BJMc1s9Fk4Y7QsqkPnkDrOE39 UWwhyae5CHxHA== 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 737F34D8C 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 46D023A1581 for ; Fri, 5 Apr 2024 18:12:56 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Apr 2024 18:11:59 +0200 Message-ID: <20240405161212.26167-18-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 18/31] fftools/ffmpeg_filter: drop an unnecessary use of OutputStream 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: CE6fR6tCoHOL OutputFilter.type contains the same information. --- fftools/ffmpeg_filter.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 840502bd62..d2fd26af7e 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -2325,7 +2325,6 @@ static int fg_output_step(OutputFilterPriv *ofp, FilterGraphThread *fgt, AVFrame *frame) { FilterGraphPriv *fgp = fgp_from_fg(ofp->ofilter.graph); - OutputStream *ost = ofp->ofilter.ost; AVFilterContext *filter = ofp->filter; FrameData *fd; int ret; @@ -2379,7 +2378,7 @@ static int fg_output_step(OutputFilterPriv *ofp, FilterGraphThread *fgt, if (!fgp->is_meta) fd->bits_per_raw_sample = 0; - if (ost->type == AVMEDIA_TYPE_VIDEO) { + if (ofp->ofilter.type == AVMEDIA_TYPE_VIDEO) { if (!frame->duration) { AVRational fr = av_buffersink_get_frame_rate(filter); if (fr.num > 0 && fr.den > 0) From patchwork Fri Apr 5 16:12:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47840 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1069949pzd; Fri, 5 Apr 2024 09:15:01 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVR4IrlgAwq57RpewAnfd6cnz8krzIOhWQo1bjAgkMYDX5R9WJd71fMOUt3yqGF/lA+wzDZkOCu8Il/jDuQ6tWudIAULzHPtXs9Aw== X-Google-Smtp-Source: AGHT+IEKNd6Klq9DJ8sR9u6j61+h0GHbQy43kqXB3w3r4YmM4+/iUQsI83XFMVwwHXTdf4dNGmNA X-Received: by 2002:a50:d69e:0:b0:56b:ff5d:8bdc with SMTP id r30-20020a50d69e000000b0056bff5d8bdcmr1130358edi.32.1712333700951; Fri, 05 Apr 2024 09:15:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712333700; cv=none; d=google.com; s=arc-20160816; b=eyPF3M6i3l+m2/OIku6BBeqGGm7AgmdTfuBy7zLLaWwd1BkzgkjTghYXId+G448R0w LdQ0z2qLiMnfa8a9hGTE0G6sILmTzz8YHzcPwU3WAYfqMs1wMrJ6f7+7ubWz+0FtV9mN t+C+6vF2sGIRNAikqHTDuXByJO3XvWCwiCuBpF3epnEbOha35dd/iCQ+k+ygG4OGGzrK Snm3n4Q2Xki88e0GNoPda2g8c/E9nZGjd7c1s5rzYxof+zaD+Sr4WhcWYMWCVoB6Q/1u 7RFqWNvvRBVu3mv1mxu5/ruphnoCE5n9z+kWAVX6ZzBATnQzeFsotWiH7LUrtXFkDTuY TmZA== 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:dkim-signature:delivered-to; bh=rjezfMw/UBFxqibrdz1ggG9MrODI7RHv5Fdh/zM5GqM=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=uhvLuFkyy0bCmcyNrCtzLmc+HwoevJEroqb1f0IIOfI+LtoHKuSfxSc4gTcPEgs5Wc xl5UhJRTdkuQQdJJCgO2LGuxzIA0KPLMaqxNtr/DAdxMx74gwup1GYAaazrVxq1s+zMn DclFEwqjFAnTg11iWqDNqA0Z+/gIU7ETHeDUF1vKZNM09MtYJ606GftVqUJvAqBLYvBt 3uXtbAmQH2B3TaH9UDZTjrJfvhpahUAZ6OfncPjCFISNNbOPJHkWulj7687ukp7NJOhF /puy/crd0W01JoCslPdGS+v9ZovlKxcStnuYxk7N5WQOSKyHlO28XFd6HMrm9J3SF11k Nw9w==; 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=sAWCcBG4; 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 15-20020a508e4f000000b0056e332f32casi573994edx.540.2024.04.05.09.15.00; Fri, 05 Apr 2024 09:15:00 -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=sAWCcBG4; 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 F3E9568D244; Fri, 5 Apr 2024 19:13:21 +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 449E868D180 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=sAWCcBG4; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 91D984D7E for ; Fri, 5 Apr 2024 18:13:06 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id MEtQqlbE8LZ9 for ; Fri, 5 Apr 2024 18:13:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712333582; bh=NEFyaZ7QXM3Wh3WLYsD/jGgvrCsPNFwsTdxpiWrXtJ4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=sAWCcBG4hk7jan5OFdezAG7SLj+wb2tA0eF22toV4LfO/fF66px0dV4yi4aEpQL4r OW01acTPXPitFFnhakwkMk23otdPdugwQrJ0xmfyS1XV5oFPflazy5Btq2ulnxDKic 3Bsf33seuds9HFj/0wEh5fX0ELcguUmCjRl1GrHZR6Dftlz3obrHnnDGcgL8oLOSIT ghcO/2CV9oXheDV1j/92etrrhy+bY0z+zYOVC600vPWjbmArFirZg8t/W/xGoui6ZF YZTFPyXLGKiPrXBoBOvVWbFJrtm5yByvvWQkRcRbVL2Qdu9TJiVysNdStv0CDVEqen CIPp96yRYzUsg== 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 C95524D91 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 52B953A159F 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:00 +0200 Message-ID: <20240405161212.26167-19-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 19/31] fftools/ffmpeg_filter: pass sws/swr opts 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 4ZPK5a1W5sry Do not read them from OutputStream directly. Will allow decoupling filtering from encoding in future commits. --- fftools/ffmpeg.h | 7 +++++-- fftools/ffmpeg_filter.c | 27 ++++++++++++++++++++++----- fftools/ffmpeg_mux.c | 3 --- fftools/ffmpeg_mux_init.c | 11 ++++------- 4 files changed, 31 insertions(+), 17 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 786f925bc6..c61a670103 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -265,6 +265,8 @@ typedef struct InputFilterOptions { enum OFilterFlags { OFILTER_FLAG_DISABLE_CONVERT = (1 << 0), + // produce 24-bit audio + OFILTER_FLAG_AUDIO_24BIT = (1 << 1), }; typedef struct OutputFilterOptions { @@ -283,6 +285,9 @@ typedef struct OutputFilterOptions { */ AVRational output_tb; + AVDictionary *sws_opts; + AVDictionary *swr_opts; + // A combination of OFilterFlags. unsigned flags; @@ -574,8 +579,6 @@ typedef struct OutputStream { OutputFilter *filter; AVDictionary *encoder_opts; - AVDictionary *sws_dict; - AVDictionary *swr_opts; char *apad; char *attachment_filename; diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index d2fd26af7e..8aa4053716 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -210,6 +210,9 @@ typedef struct OutputFilterPriv { AVRational sample_aspect_ratio; + AVDictionary *sws_opts; + AVDictionary *swr_opts; + // those are only set if no format is specified and the encoder gives us multiple options // They point directly to the relevant lists of the encoder. const int *formats; @@ -813,6 +816,17 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, if (!ofp->name) return AVERROR(EINVAL); + ret = av_dict_copy(&ofp->sws_opts, opts->sws_opts, 0); + if (ret < 0) + return ret; + + ret = av_dict_copy(&ofp->swr_opts, opts->swr_opts, 0); + if (ret < 0) + return ret; + + if (opts->flags & OFILTER_FLAG_AUDIO_24BIT) + av_dict_set(&ofp->swr_opts, "output_sample_bits", "24", 0); + if (fgp->is_simple) { // for simple filtergraph there is just one output, // so use only graph-level information for logging @@ -945,6 +959,8 @@ void fg_free(FilterGraph **pfg) OutputFilterPriv *ofp = ofp_from_ofilter(ofilter); av_frame_free(&ofp->fps.last_frame); + av_dict_free(&ofp->sws_opts); + av_dict_free(&ofp->swr_opts); av_freep(&ofilter->linklabel); av_freep(&ofilter->name); @@ -1358,7 +1374,7 @@ static int configure_output_video_filter(FilterGraph *fg, AVFilterGraph *graph, snprintf(args, sizeof(args), "%d:%d", ofp->width, ofp->height); - while ((e = av_dict_iterate(ost->sws_dict, e))) { + while ((e = av_dict_iterate(ofp->sws_opts, e))) { av_strlcatf(args, sizeof(args), ":%s=%s", e->key, e->value); } @@ -1725,6 +1741,7 @@ static int configure_filtergraph(FilterGraph *fg, FilterGraphThread *fgt) return AVERROR(ENOMEM); if (simple) { + OutputFilterPriv *ofp = ofp_from_ofilter(fg->outputs[0]); OutputStream *ost = fg->outputs[0]->ost; if (filter_nbthreads) { @@ -1738,17 +1755,17 @@ static int configure_filtergraph(FilterGraph *fg, FilterGraphThread *fgt) av_opt_set(fgt->graph, "threads", e->value, 0); } - if (av_dict_count(ost->sws_dict)) { - ret = av_dict_get_string(ost->sws_dict, + if (av_dict_count(ofp->sws_opts)) { + ret = av_dict_get_string(ofp->sws_opts, &fgt->graph->scale_sws_opts, '=', ':'); if (ret < 0) goto fail; } - if (av_dict_count(ost->swr_opts)) { + if (av_dict_count(ofp->swr_opts)) { char *args; - ret = av_dict_get_string(ost->swr_opts, &args, '=', ':'); + ret = av_dict_get_string(ofp->swr_opts, &args, '=', ':'); if (ret < 0) goto fail; av_opt_set(fgt->graph, "aresample_swr_opts", args, 0); diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 253c2e58d4..557f08b3a5 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -819,9 +819,6 @@ static void ost_free(OutputStream **post) av_freep(&ost->attachment_filename); - av_dict_free(&ost->sws_dict); - av_dict_free(&ost->swr_opts); - if (ost->enc_ctx) av_freep(&ost->enc_ctx->stats_in); avcodec_free_context(&ost->enc_ctx); diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 219be5f965..8f4b73f8a7 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -1356,12 +1356,6 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, if (oc->oformat->flags & AVFMT_GLOBALHEADER && ost->enc_ctx) ost->enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; - av_dict_copy(&ost->sws_dict, o->g->sws_dict, 0); - - av_dict_copy(&ost->swr_opts, o->g->swr_opts, 0); - if (ost->enc_ctx && av_get_exact_bits_per_sample(ost->enc_ctx->codec_id) == 24) - av_dict_set(&ost->swr_opts, "output_sample_bits", "24", 0); - MATCH_PER_STREAM_OPT(copy_initial_nonkeyframes, i, ms->copy_initial_nonkeyframes, oc, st); @@ -1392,10 +1386,13 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, .vsync_method = vsync_method, .sample_rate = ost->enc_ctx->sample_rate, .ch_layout = ost->enc_ctx->ch_layout, + .sws_opts = o->g->sws_dict, + .swr_opts = o->g->swr_opts, .output_tb = enc_tb, .ts_offset = mux->of.start_time == AV_NOPTS_VALUE ? 0 : mux->of.start_time, - .flags = OFILTER_FLAG_DISABLE_CONVERT * !!keep_pix_fmt, + .flags = OFILTER_FLAG_DISABLE_CONVERT * !!keep_pix_fmt | + OFILTER_FLAG_AUDIO_24BIT * !!(av_get_exact_bits_per_sample(ost->enc_ctx->codec_id) == 24), }; snprintf(name, sizeof(name), "#%d:%d", mux->of.index, ost->index); From patchwork Fri Apr 5 16:12:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47847 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1070902pzd; Fri, 5 Apr 2024 09:16:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXtLviAqUdvvEfOlCykk8hT00GqAPY8frVweA3wAg3z+6QFo/Q2CpqIbHtNlGQkHXgoPOWf4/tK6vo9G/S6nX5K9SoKY4CDS134iA== X-Google-Smtp-Source: AGHT+IFll4ChZC0WALVN3zw6U15gZsiW2fpwCm28K++mUg/1y5OESxII2uGC+CWelP9YkJhs+87/ X-Received: by 2002:a17:907:76a4:b0:a45:40e4:8c8 with SMTP id jw4-20020a17090776a400b00a4540e408c8mr2513546ejc.16.1712333776925; Fri, 05 Apr 2024 09:16:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712333776; cv=none; d=google.com; s=arc-20160816; b=wzLKk3Rtlt1sOJ8DxgRHpqVMUBlRvuf86J11MUOjUFU9qb207LCAm+8tjn3sW5vTm+ UdPJ7VdReolVr93X4rf0VIhjYZNgauKoX6I792J+57oAJMtewSRUJLsO67sHoAzGowGw tyysYVEeTLfGIkaWVDYdMnQtW8uQ7Zmal8Ll96BA3Rn7WF4SNJq3pZPJ5ecHVwPJ4qJI QlWYIEXmOaWtpy/vnQEjGdw2K9t9DiQ+yYmLDDSqiz+eEPud4fmMXcFeM/71LkEvRiGT uYv9dtyf1GdR+xuVx2IQ2QL31r9p/7VS7qaZyN84D91lPerr0eyLZw7l2gAMuW/e3+on iCng== 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:dkim-signature:delivered-to; bh=YLsqSwajikTTgHqJG/pZtxrEXwBsh/oiL+YUwu7o/MY=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=X6yKyepPqZ9fPQldvbJSjfnJgknoLnz9c7EAsOAq5FHWcW/6A+OgdpnxtXImntwN41 85IUeXkLzdAipzWV0op0qZeGwt9OGuvs865KsbmUsTtew9plCqR2+ydanmUer8NkTBga VdqSuHPCxkbWOKAqvLvlUERsp5yw56Tr/6mCDL69T14Kur7jJPIxd3Kmje8yhtaORltS bqoH75RxuWs2+zUXz1+ytkJmg88NqTIttpjnKcUJW/+F8xU2hDujJl1FJr42XcU6+pUL yt3JZ22Pyblr9Pc8RLxaBt8iAulIglOrY3ml41BsyogR36qlhL/ke3xPRQvY17SFYGJH pfbQ==; 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=gJTvoabY; 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 fi29-20020a170906da1d00b00a4693947934si832548ejb.606.2024.04.05.09.16.16; Fri, 05 Apr 2024 09:16:16 -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=gJTvoabY; 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 0E43568D2C7; Fri, 5 Apr 2024 19:13:31 +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 7326E68D1B0 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=gJTvoabY; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 4095E4D81 for ; Fri, 5 Apr 2024 18:13:09 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id bvZIOUOhDrKU 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=H/Of/nW9VwlhWLb0dnncGr52ZVh627nM2J1F2T92/io=; h=From:To:Subject:Date:In-Reply-To:References:From; b=gJTvoabYGk398jCjmHCbIgiD0ugPlnupZ22D7gZRnRCN/0qMfV/vEEw6sgUM2BGAN N6sFY2bTO2Yy1e3XN3KFfwujdesJ15bEKnNy9Puh0ZOcTpiX9bYS/b8ZMa48DdeshC ittrWJevvhd/SGn1C8KR2EEyXM4wdLeQ1V2VdVxTGojyy5vl6OwhzOG9JBkeRyoeih HcOEPzV4OOX/EvsaQOpEOqnyAsAFKLr8S4fIoyoqUonUNbquCgG5qqITcNXMNx0FUj li+ZQnnePthWo59l8zn3D2yA77jVEr61HoYlNrj3ktl/EbO9r7SKalVOHRadaOObVo mUODf7PH6PtwQ== 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 2A0314DA2 for ; Fri, 5 Apr 2024 18:13:04 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 5E4033A167C 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:01 +0200 Message-ID: <20240405161212.26167-20-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 20/31] fftools/ffmpeg_filter: pass autoscale 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: eLH9jyRpgty5 Do not read it from OutputStream directly. Will allow decoupling filtering from encoding in future commits. --- fftools/ffmpeg.h | 2 +- fftools/ffmpeg_filter.c | 2 +- fftools/ffmpeg_mux_init.c | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index c61a670103..4059b1dcc3 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -267,6 +267,7 @@ enum OFilterFlags { OFILTER_FLAG_DISABLE_CONVERT = (1 << 0), // produce 24-bit audio OFILTER_FLAG_AUDIO_24BIT = (1 << 1), + OFILTER_FLAG_AUTOSCALE = (1 << 2), }; typedef struct OutputFilterOptions { @@ -565,7 +566,6 @@ typedef struct OutputStream { #if FFMPEG_OPT_TOP int top_field_first; #endif - int autoscale; int bitexact; int bits_per_raw_sample; diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 8aa4053716..dc9556bbc1 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1366,7 +1366,7 @@ static int configure_output_video_filter(FilterGraph *fg, AVFilterGraph *graph, if (ret < 0) return ret; - if ((ofp->width || ofp->height) && ofilter->ost->autoscale) { + if ((ofp->width || ofp->height) && (ofp->flags & OFILTER_FLAG_AUTOSCALE)) { char args[255]; AVFilterContext *filter; const AVDictionaryEntry *e = NULL; diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 8f4b73f8a7..51c31eeb72 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -1045,7 +1045,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, OutputStream *ost; const AVCodec *enc; AVStream *st; - int ret = 0, keep_pix_fmt = 0; + int ret = 0, keep_pix_fmt = 0, autoscale = 1; AVRational enc_tb = { 0, 0 }; enum VideoSyncMethod vsync_method = VSYNC_AUTO; const char *bsfs = NULL, *time_base = NULL; @@ -1170,8 +1170,8 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, return ret; MATCH_PER_STREAM_OPT(presets, str, preset, oc, st); - ost->autoscale = 1; - MATCH_PER_STREAM_OPT(autoscale, i, ost->autoscale, oc, st); + + MATCH_PER_STREAM_OPT(autoscale, i, autoscale, oc, st); if (preset && (!(ret = get_preset_file_2(preset, enc->codec->name, &s)))) { AVBPrint bprint; av_bprint_init(&bprint, 0, AV_BPRINT_SIZE_UNLIMITED); @@ -1392,6 +1392,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, .ts_offset = mux->of.start_time == AV_NOPTS_VALUE ? 0 : mux->of.start_time, .flags = OFILTER_FLAG_DISABLE_CONVERT * !!keep_pix_fmt | + OFILTER_FLAG_AUTOSCALE * !!autoscale | OFILTER_FLAG_AUDIO_24BIT * !!(av_get_exact_bits_per_sample(ost->enc_ctx->codec_id) == 24), }; From patchwork Fri Apr 5 16:12:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47851 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1071203pzd; Fri, 5 Apr 2024 09:16:42 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWdcxb5uPGv1mv20vzseS0uAW0ALb+KHZMV+FliSIPn6COzOBbEjfgCVEF/IuPAWi8TTwjug9y79Bb5tJ+MOnGXJ1LWDqGchM+mQA== X-Google-Smtp-Source: AGHT+IFjcr/0XFYUK/xhcQoxIoVE4ElaylbXNaX7/i75jJ7rWF6tsJkUptEQ32VfHidilWmsOfwN X-Received: by 2002:a17:907:9611:b0:a46:f279:8f77 with SMTP id gb17-20020a170907961100b00a46f2798f77mr1724889ejc.43.1712333801894; Fri, 05 Apr 2024 09:16:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712333801; cv=none; d=google.com; s=arc-20160816; b=yfWcTghtkN02I8Q6/5SQF6iqPhb015xdJWb0IiogZxaoRpjuJ4IfLv/dDHVgfVufKr ueflni34gHS+Xzxj+ICtjRKBlZkZQXZfNHb1mWm2LXC7wvJ0DNkWEXCjpdTQq1CA/vRQ +N1O8XpnbpaZdZ8pvCgykSZQEmJM+V3lxncuTJUiJrd+fRpr23Ah/FgRmII/VULGaf1D QN08LDgdxbJGsz/NbvTnYrNm50ok7/qRViPw0mV49JyieeVi7tgqPvWXs15tvI4bw5Nb TIeGMoRtCMlds1l9XSonixNC2refW244HVqJ0+giycFmG0cAQTYVYxNURKv2xglhrnEX ejsw== 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:dkim-signature:delivered-to; bh=M8l2J4h9FQniaOlJFRK0Zw8GXVfjwZDihhER7UO/8+k=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=iVZiEPm+SCOBNvlo+YWddkWsFymUr7PtCCdBxNv+eUC1kGe9kXMSkKSe0sFcqMorL4 lrrOMihJZCFToV5wFjEcuSKXxbaGPFh7EASxLzd0Y5m6yLyOh6MgvnFrHOiVU3Nths4U JIYE+4ehXUQiuEWN9vFsCPHznG8csQP/hDZ2zRkrPYl4Z30RfKmQDAUNvWgjeUxIteXl rD1guvjLgxtnOyXfPPEHF1DVdqPYHozbvM/Ri6U7OTe9PMcMKukOIQYj97lhfUVWHIYG Pikc7qaltq8btH39BAnpEMaiE7v1+Rb0saH5vKwJkc2AA+J4EXiajP9UOBkbZzLTcyfy EeJw==; 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="WG/sDNsr"; 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 um10-20020a170906cf8a00b00a51a9b05607si532333ejb.411.2024.04.05.09.16.41; Fri, 05 Apr 2024 09:16:41 -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="WG/sDNsr"; 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 E77EE68D2E9; Fri, 5 Apr 2024 19:13:33 +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 8B7F268D16D 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=WG/sDNsr; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 46A6B4D8E 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 DLcwAeNwRc3B for ; Fri, 5 Apr 2024 18:13:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712333583; bh=HQ/ZYQ+11mo4mitQI7BDA34AAvVpoB2M6liSOctdMm4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=WG/sDNsrmaa61vWppsa4krr9EanNV1h3kd/CcLs7DTLXe1aKy8bOMvwrQ/gl6lxsM RyzXjwxrl+6rzY31wqkWdivD3/0CQBGDE+xB5EHrM1KwuoZtcfZACJEEOP911sWLWL XtiQWtPo/1ufEb6vUIYhZnQ8V+f9AElUvspkffV+ToZ2Dfy+XUk/sTZjGbx3gBjeB6 ryn+dhyrgZTBiF44OhO7INfJw6rGRHNUlL1sb9JcikYvi1uGR9siPiU6p9zEhCIbKS oVGad3rJ2oJc5Fzk8hE7esCxd4qK6t29XgFplSLAh/s2Ld+Pb9xRMxwfxVlgnhrX8M Z1YYDpYQKlAXg== 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 D93164D96 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 6A1C63A16DC 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:02 +0200 Message-ID: <20240405161212.26167-21-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 21/31] fftools/ffmpeg_filter: pass trim parameters 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: udTrnecLPqUU Do not read them from OutputStream directly. Will allow decoupling filtering from encoding in future commits. --- fftools/ffmpeg.h | 2 ++ fftools/ffmpeg_filter.c | 11 +++++++---- fftools/ffmpeg_mux_init.c | 2 ++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 4059b1dcc3..8e773165da 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -279,6 +279,8 @@ typedef struct OutputFilterOptions { // Overrides encoder pixel formats when set. const enum AVPixelFormat *pix_fmts; + int64_t trim_start_us; + int64_t trim_duration_us; int64_t ts_offset; /* Desired output timebase. diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index dc9556bbc1..225fa4bda2 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -220,6 +220,8 @@ typedef struct OutputFilterPriv { const int *sample_rates; AVRational enc_timebase; + int64_t trim_start_us; + int64_t trim_duration_us; // offset for output timestamps, in AV_TIME_BASE_Q int64_t ts_offset; int64_t next_pts; @@ -812,6 +814,9 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, ofp->ts_offset = opts->ts_offset; ofp->enc_timebase = opts->output_tb; + ofp->trim_start_us = opts->trim_start_us; + ofp->trim_duration_us = opts->trim_duration_us; + ofp->name = av_strdup(opts->name); if (!ofp->name) return AVERROR(EINVAL); @@ -1349,8 +1354,6 @@ static int configure_output_video_filter(FilterGraph *fg, AVFilterGraph *graph, OutputFilter *ofilter, AVFilterInOut *out) { OutputFilterPriv *ofp = ofp_from_ofilter(ofilter); - OutputStream *ost = ofilter->ost; - OutputFile *of = ost->file; AVFilterContext *last_filter = out->filter_ctx; AVBPrint bprint; int pad_idx = out->pad_idx; @@ -1411,7 +1414,7 @@ static int configure_output_video_filter(FilterGraph *fg, AVFilterGraph *graph, } snprintf(name, sizeof(name), "trim_out_%s", ofp->name); - ret = insert_trim(of->start_time, of->recording_time, + ret = insert_trim(ofp->trim_start_us, ofp->trim_duration_us, &last_filter, &pad_idx, name); if (ret < 0) return ret; @@ -1503,7 +1506,7 @@ static int configure_output_audio_filter(FilterGraph *fg, AVFilterGraph *graph, } snprintf(name, sizeof(name), "trim for output %s", ofp->name); - ret = insert_trim(of->start_time, of->recording_time, + ret = insert_trim(ofp->trim_start_us, ofp->trim_duration_us, &last_filter, &pad_idx, name); if (ret < 0) goto fail; diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 51c31eeb72..6e19b98abd 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -1389,6 +1389,8 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, .sws_opts = o->g->sws_dict, .swr_opts = o->g->swr_opts, .output_tb = enc_tb, + .trim_start_us = mux->of.start_time, + .trim_duration_us = mux->of.recording_time, .ts_offset = mux->of.start_time == AV_NOPTS_VALUE ? 0 : mux->of.start_time, .flags = OFILTER_FLAG_DISABLE_CONVERT * !!keep_pix_fmt | From patchwork Fri Apr 5 16:12:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47845 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1070625pzd; Fri, 5 Apr 2024 09:15:52 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWSFPmNlXyxX2DMPwznSqF/LuqjDBj/CNcpAsWb2C+l595NaPy06VbaSDUYT8eJ8deH1hI+ZW3BI1d4YPzpTQyPFk51W/kaszQngw== X-Google-Smtp-Source: AGHT+IGNX+/5pxACRY6/PTtj/IvZg9oFrTDjjZIg7Fbr4T+VW3+PT2YZyVCqhuv1O+VZWdzrSCHw X-Received: by 2002:a50:d714:0:b0:56e:2e0:79d1 with SMTP id t20-20020a50d714000000b0056e02e079d1mr1425306edi.4.1712333752076; Fri, 05 Apr 2024 09:15:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712333752; cv=none; d=google.com; s=arc-20160816; b=SFKh/hIniAJL3FiyHfwm+jRImp6dgNkE2AwlN94F/Ru7gY95+dUMXb4Sz8S89wnaZd QcE3mokcoM9lcjHXjwGh6lHVoTtn7rjj+5K0WsrmVet2p+uQyBYIMTIMU1UKHuvopDF9 Q4Zl1W1EMg3ZOSAQ0d3nqyFMHBYSETnPec2H34HK4qLEtFUU9GzwwVIo5ERmegXUHqvk s5i6euXgvZJcS3zikoqHeXiI8uEk8gtoUNY4RR+WOCHsMVJ7NgmLO76UsOoeVba7CepO L7oewJ7TH0/yOX5wdkRs5CNMTGdqBIATNmohOx2GLdFORxZlykvs60iEsMZPTZwUWa6W mi/g== 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:dkim-signature:delivered-to; bh=PE3B7K4rnHI3o396CsUYtEs1R7bFpIY3inUpl6lriTg=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=BkJLjCqaCGLshyCitwB9MjSiHwXGaXffTYYz5mmyxbNU7/bzg37sUMZhOD6M6m2DeN vdP5QWsYIBG/pzZSREIHvP+L2bLKPtKfnkYsrjKnzMVCmllhxXzfmmaQtZtXEdb65LyD hAnzNmTclXcqyF/emXAWUmUxa9QQcjSlyAIqDkyt7dH2tjvJV0PcbLlLVmdU0UrZ9YKh pHigrHJGNmiifWJva5CZYS3ghLPfxhfTGmDj8a2Dhl9gC9RUmnEb7Vxc/mdaUb8+mnjd um4lRuImEzKzi5khZkS3o7VumyuLBhuZ318CiodzKYK+Ov6XOlIUTKk3SY3cO6zY/IxR NzrA==; 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=KUVh02gS; 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 c22-20020a50f616000000b0056e2acef875si880414edn.669.2024.04.05.09.15.51; Fri, 05 Apr 2024 09:15:52 -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=KUVh02gS; 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 EE4D368D28A; Fri, 5 Apr 2024 19:13:27 +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 5EB5668D1A6 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=KUVh02gS; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id E89E04D8D 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 09HeCaIn9FfG 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=GQEBp8yNwDFjYJ8uYNyAPQDX0WY2bCGeYzKqPYpF24Q=; h=From:To:Subject:Date:In-Reply-To:References:From; b=KUVh02gSAcrL2opXkKi0mHYPEt91SgbN7G+q3mwoVfyui4R+sWnkCfUSKSxCeMlnp 9Z5VPG7NQNkTdWkd13+GhrJDDSTG6gEAF21xlMYPVDAbzVn0mZu0wqzmgeHL4GUn+X TuFP82UipbnAppAoqBRaz8vxIuuo5P5zwf7wSg6uOOStTiHptdFWtqvZd6kESM0Pji 2TAdTdimWaqgazShXDLYL71hx1LfRYm67tqbg+GfvcTb/Rlnp05CgjRmkSfPpq77Pw wGnRH88hcybcLEwhXH0mor1EsJAfnM9VHhh1FuQqGU9iu7I++aCYQIpAaD/qO5y1bn DcEwj0kdIhj2Q== 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 753B94D76 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 75E143A1752 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:03 +0200 Message-ID: <20240405161212.26167-22-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 22/31] fftools/ffmpeg_filter: move most of -apad logic to the muxer 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: a4uBBrtSwQTn The decision whether -apad actually does anything is made based on muxer properties, and so more properly belongs there. Filtering code only receives the result. --- fftools/ffmpeg.h | 3 ++- fftools/ffmpeg_filter.c | 16 +++------------- fftools/ffmpeg_mux.c | 1 - fftools/ffmpeg_mux.h | 2 ++ fftools/ffmpeg_mux_init.c | 36 +++++++++++++++++++++++++++++------- 5 files changed, 36 insertions(+), 22 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 8e773165da..26b42a3fcd 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -320,6 +320,8 @@ typedef struct OutputFilter { * this stores the output linklabel, if any */ uint8_t *linklabel; + char *apad; + enum AVMediaType type; atomic_uint_least64_t nb_frames_dup; @@ -581,7 +583,6 @@ typedef struct OutputStream { OutputFilter *filter; AVDictionary *encoder_opts; - char *apad; char *attachment_filename; diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 225fa4bda2..ec17e99494 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -969,6 +969,7 @@ void fg_free(FilterGraph **pfg) av_freep(&ofilter->linklabel); av_freep(&ofilter->name); + av_freep(&ofilter->apad); av_freep(&ofp->name); av_channel_layout_uninit(&ofp->ch_layout); av_freep(&fg->outputs[j]); @@ -1430,8 +1431,6 @@ static int configure_output_audio_filter(FilterGraph *fg, AVFilterGraph *graph, OutputFilter *ofilter, AVFilterInOut *out) { OutputFilterPriv *ofp = ofp_from_ofilter(ofilter); - OutputStream *ost = ofilter->ost; - OutputFile *of = ost->file; AVFilterContext *last_filter = out->filter_ctx; int pad_idx = out->pad_idx; AVBPrint args; @@ -1493,17 +1492,8 @@ static int configure_output_audio_filter(FilterGraph *fg, AVFilterGraph *graph, pad_idx = 0; } - if (ost->apad && of->shortest) { - int i; - - for (i = 0; i < of->nb_streams; i++) - if (of->streams[i]->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) - break; - - if (i < of->nb_streams) { - AUTO_INSERT_FILTER("-apad", "apad", ost->apad); - } - } + if (ofilter->apad) + AUTO_INSERT_FILTER("-apad", "apad", ofilter->apad); snprintf(name, sizeof(name), "trim for output %s", ofp->name); ret = insert_trim(ofp->trim_start_us, ofp->trim_duration_us, diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 557f08b3a5..6a64cba72d 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -815,7 +815,6 @@ static void ost_free(OutputStream **post) av_expr_free(ost->kf.pexpr); av_freep(&ost->logfile_prefix); - av_freep(&ost->apad); av_freep(&ost->attachment_filename); diff --git a/fftools/ffmpeg_mux.h b/fftools/ffmpeg_mux.h index f8b6f7a790..1e9ea35412 100644 --- a/fftools/ffmpeg_mux.h +++ b/fftools/ffmpeg_mux.h @@ -78,6 +78,8 @@ typedef struct MuxStream { #if FFMPEG_OPT_VSYNC_DROP int ts_drop; #endif + + char *apad; } MuxStream; typedef struct Muxer { diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 6e19b98abd..a483fffa6e 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -828,6 +828,7 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o, static int new_stream_audio(Muxer *mux, const OptionsContext *o, OutputStream *ost) { + MuxStream *ms = ms_from_ost(ost); AVFormatContext *oc = mux->fc; AVStream *st = ost->st; @@ -836,7 +837,6 @@ static int new_stream_audio(Muxer *mux, const OptionsContext *o, int channels = 0; char *layout = NULL; char *sample_fmt = NULL; - const char *apad = NULL; MATCH_PER_STREAM_OPT(audio_channels, i, channels, oc, st); if (channels) { @@ -859,12 +859,7 @@ static int new_stream_audio(Muxer *mux, const OptionsContext *o, MATCH_PER_STREAM_OPT(audio_sample_rate, i, audio_enc->sample_rate, oc, st); - MATCH_PER_STREAM_OPT(apad, str, apad, oc, st); - if (apad) { - ost->apad = av_strdup(apad); - if (!ost->apad) - return AVERROR(ENOMEM); - } + MATCH_PER_STREAM_OPT(apad, str, ms->apad, oc, st); } return 0; @@ -1890,6 +1885,33 @@ static int create_streams(Muxer *mux, const OptionsContext *o) } } + // handle -apad + if (mux->of.shortest) { + int have_video = 0; + + for (unsigned i = 0; i < mux->of.nb_streams; i++) + if (mux->of.streams[i]->type == AVMEDIA_TYPE_VIDEO) { + have_video = 1; + break; + } + + for (unsigned i = 0; have_video && i < mux->of.nb_streams; i++) { + MuxStream *ms = ms_from_ost(mux->of.streams[i]); + OutputFilter *ofilter = ms->ost.filter; + + if (ms->ost.type != AVMEDIA_TYPE_AUDIO || !ms->apad || !ofilter) + continue; + + ofilter->apad = av_strdup(ms->apad); + if (!ofilter->apad) + return AVERROR(ENOMEM); + } + } + for (unsigned i = 0; i < mux->of.nb_streams; i++) { + MuxStream *ms = ms_from_ost(mux->of.streams[i]); + ms->apad = NULL; + } + if (!oc->nb_streams && !(oc->oformat->flags & AVFMT_NOSTREAMS)) { av_dump_format(oc, nb_output_files - 1, oc->url, 1); av_log(mux, AV_LOG_ERROR, "Output file does not contain any stream\n"); From patchwork Fri Apr 5 16:12:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47848 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1070990pzd; Fri, 5 Apr 2024 09:16:24 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUPxRi5bo44tF+LTkfMj4C4gnb/rnvnry+Iw410/1g41/rbHGdR5yZUXMM2R5/Nb0N3AZh/EXowOva+1nICT/cqAku9ISwoOq+zpA== X-Google-Smtp-Source: AGHT+IEH/gJCUUmhc/5kRlBvGJZxBPXrGxMee3z9NdKFYUo00iZwn4ClNMc2I9ZKB50VnTft7Kp8 X-Received: by 2002:ac2:4c17:0:b0:515:d445:6c13 with SMTP id t23-20020ac24c17000000b00515d4456c13mr1575172lfq.32.1712333783944; Fri, 05 Apr 2024 09:16:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712333783; cv=none; d=google.com; s=arc-20160816; b=s+0FczNT1I63mPU13d/P4BkRXMchd1xklqU9y9LWtayL62V6LzgUnxKHI7AgI/eHe9 uWiPhOeD4Sf4+YbypUOdTZjYzDyandIFiTtwsJrC1yu4a68Vc15lCLXcwPwV0wYX61c0 Y3knsxruGTl3KOvNweqJVHs3lpZBhPd7Zes07p2bipqACq3B6N1Zlt+pRGDGnf/FbAyw YwPgdCTh0NBQzvfJZj87n11J5WGcykpVX959ZqiX+7xhmvoAc7U+8D3dEXOrQ4b3B0rJ 97Axg6fJFCdUTfPoYExMi7EBoIfZZNa8ov1CWxglqgqpJFJmZ0PaJtjjMHT6Q5fy4Cls mojw== 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:dkim-signature:delivered-to; bh=Q+hpcdOL7iAvaKjpS0agIcY/x7bMFl03Zjzi6ZZdi5w=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=QCBDfJDP74/VUWQMX6VZ0xzAqsSzrvNJu+yFA0x6qYWhqp+vPjh4OvspQncvzroxJn UTxPB8YJCgXg+WyAptZCEANG5sNT9ku3cybT5nwE/USNX+qCn72BAKePFbGXbILwnN2A kPTT7MYoXr/DtcbXMonDBUhQa5WWC2h6OUNZNkqk5aB1QdD7XbIHjBbYNbRXq4Tc4XT9 RzDvMqCZ0ZJwVpRannmEdNPuRxSBEQjtWW0Gj5axGDoskX8wl5O2SONqf4O3XVhtMcQi x5BOO1zs+JSWdWUvqoWgdmSQieFFBFXqMcd3Jop2L5XvrQvdbj7maB+u9K+f9fbGST/x 7MUA==; 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=N5vns9T9; 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 m6-20020a056402510600b0056c264a3a42si884950edd.527.2024.04.05.09.16.08; Fri, 05 Apr 2024 09:16:23 -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=N5vns9T9; 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 0A12168D2B3; Fri, 5 Apr 2024 19:13:30 +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 5EABC68D19E 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=N5vns9T9; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 152544D76 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 x6kCimKyi1C7 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=065deIZngOF2mLGtJeqvHqpRWXpBKhcVww4ldJQuZe4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=N5vns9T9YMvR9kkV8zUb5AWIPuhK6WS+4wV/aHP2csP8dr178psh3X3Jv8U90cA4Z mTWQC2IQo2xk2jpKnOXOl09wEDS4n/Kg50fH96WGTbOj/ttb+iEj3KKqum2jBMx+nu 4N+lJ2ueDn23m66ag9dButZ7WVcvxw0Q+T7kEAFbF+04qMr60xIhaXSpE1GKH0/MRf yBBs+ybDx9eSNgWFeLUUicTzEAIWPKNoxhX71IeN6k3ayvCTB5AGJvMNJt5wY48haU Z/ypua89TNcbT4CjUnrhY31HfWcgBBY/Uc/v1VuoFvsv+YaPtXsA77NVGJtcI3XlB4 mwLb7ZL9AcRlA== 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 99B734D9D 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 818643A1774 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:04 +0200 Message-ID: <20240405161212.26167-23-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 23/31] fftools/ffmpeg_mux: drop OutputFile.shortest 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: 9Mz1Z4uSTx5J It is no longer needed outside of of_open() and its children. --- fftools/ffmpeg.h | 1 - fftools/ffmpeg_mux_init.c | 17 +++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 26b42a3fcd..1d32009f90 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -620,7 +620,6 @@ typedef struct OutputFile { int64_t recording_time; ///< desired length of the resulting file in microseconds == AV_TIME_BASE units int64_t start_time; ///< start time in microseconds == AV_TIME_BASE units - int shortest; int bitexact; } OutputFile; diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index a483fffa6e..9aad19a85d 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -1886,7 +1886,7 @@ static int create_streams(Muxer *mux, const OptionsContext *o) } // handle -apad - if (mux->of.shortest) { + if (o->shortest) { int have_video = 0; for (unsigned i = 0; i < mux->of.nb_streams; i++) @@ -1921,7 +1921,8 @@ static int create_streams(Muxer *mux, const OptionsContext *o) return 0; } -static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t buf_size_us) +static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, + int64_t buf_size_us, int shortest) { OutputFile *of = &mux->of; int nb_av_enc = 0, nb_audio_fs = 0, nb_interleaved = 0; @@ -1947,7 +1948,7 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t buf_size_u limit_frames_av_enc |= (ms->max_frames < INT64_MAX) && IS_AV_ENC(ost, type); } - if (!((nb_interleaved > 1 && of->shortest) || + if (!((nb_interleaved > 1 && shortest) || (nb_interleaved > 0 && limit_frames) || nb_audio_fs)) return 0; @@ -1963,7 +1964,7 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t buf_size_u * different encoders run in different threads and need external * synchronization, while muxer sync queues can be handled inside the muxer */ - if ((of->shortest && nb_av_enc > 1) || limit_frames_av_enc || nb_audio_fs) { + if ((shortest && nb_av_enc > 1) || limit_frames_av_enc || nb_audio_fs) { int sq_idx, ret; sq_idx = sch_add_sq_enc(mux->sch, buf_size_us, mux); @@ -1979,7 +1980,7 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t buf_size_u continue; ret = sch_sq_add_enc(mux->sch, sq_idx, ms->sch_idx_enc, - of->shortest || ms->max_frames < INT64_MAX, + shortest || ms->max_frames < INT64_MAX, ms->max_frames); if (ret < 0) return ret; @@ -2006,7 +2007,7 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t buf_size_u continue; ms->sq_idx_mux = sq_add_stream(mux->sq_mux, - of->shortest || ms->max_frames < INT64_MAX); + shortest || ms->max_frames < INT64_MAX); if (ms->sq_idx_mux < 0) return ms->sq_idx_mux; @@ -3043,7 +3044,6 @@ int of_open(const OptionsContext *o, const char *filename, Scheduler *sch) of->recording_time = recording_time; of->start_time = o->start_time; - of->shortest = o->shortest; mux->limit_filesize = o->limit_filesize; av_dict_copy(&mux->opts, o->g->format_opts, 0); @@ -3159,7 +3159,8 @@ int of_open(const OptionsContext *o, const char *filename, Scheduler *sch) return err; } - err = setup_sync_queues(mux, oc, o->shortest_buf_duration * AV_TIME_BASE); + err = setup_sync_queues(mux, oc, o->shortest_buf_duration * AV_TIME_BASE, + o->shortest); if (err < 0) { av_log(mux, AV_LOG_FATAL, "Error setting up output sync queues\n"); return err; From patchwork Fri Apr 5 16:12:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47854 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1071446pzd; Fri, 5 Apr 2024 09:17:06 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX+uf+cxjBvVXgfNqnENBGfw6bYMmdiG0yAqDAcYa8SUt41vNGyOgDq+epeTXc4V63oKfcBiVApWbQUJJOuXJvRAyr14lh8jYHOuw== X-Google-Smtp-Source: AGHT+IFYGWj6xOidvHltBBJ38akvnUibCePa6tTAgYi6pVogXR7Diheyia3bNjridEPI+rl+JELQ X-Received: by 2002:a05:6402:4027:b0:568:d6a2:716 with SMTP id d39-20020a056402402700b00568d6a20716mr2775925eda.7.1712333826003; Fri, 05 Apr 2024 09:17:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712333825; cv=none; d=google.com; s=arc-20160816; b=GyLCDYWrN68kKoT3xjrbxZ30kLHI2H7t0M3dbsmbjcDNyUWnBfYtOYIVp05gITD6i2 2xtZ2Umjiv4fnEVfu/WmxPk4itodr9fURiAfwBtxtT/bvd0kGSvSH6NG2+g0g1awYK1f +OfcZgvPbwkikLZr3QOGtAcOGCGvhuafPs1WfCvoMlXcIdWPJ45lEMoFuiCKbbn5BUWJ waJRVUWdZIL5Ihmht4ZWUPMs8cJI/Xq/H/B59tbGdFJt7Np40zdphxbORlBst/cYmE21 3v1ezwlyJ3/ep/yIaMTEUBpTnMXIYsO3ygts3tj8gZYZenwxnsebV5SGUo1aSU0OxdEM D5Mg== 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:dkim-signature:delivered-to; bh=EPE8FCPa2SMbT0PnKq/PJNst5naMuvJo98gURMvMGgU=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=WAfHCCJ61xxI3k4j3zWyUjJJOYKSYwbY3k3VEhBXGOFUKppYDbzC/XZ7SjBgyueuJ6 dtg11S/9yyNcd+kzZnyMG/IyVan9YWuDLEo03fBUyfYH2Cv2G5hfnmOaeWfSkyG72xXX 4nMkBuHTZb5+GQ0q8e4cdd5YKbPpkFoQbEz0H27HcKK+tS/ACo9nFFDpMm/gPaJ33K2D N5Kv0P15J/LwijtPNfyjz11H3taaGW4uu3gC6/jRqXskiKNpkHfvly7oe3AHtdC6sgeF JR6LRgP/xXHrKvf/wfLTK520ZCOcw18Sqvy6LJ/SE+gyqo9jIchS7T46XO/e7nNlhjAq kJ3g==; 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=On9yZ8wX; 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 t22-20020a056402525600b0056e1de90460si871450edd.309.2024.04.05.09.17.05; Fri, 05 Apr 2024 09:17:05 -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=On9yZ8wX; 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 E727468D32A; Fri, 5 Apr 2024 19:13:36 +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 9DB9468D1C4 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=On9yZ8wX; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 8FA034D96 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 VwQABzpP3ss4 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=1712333583; bh=WmuRTSB0QgWORW06lP9dkxzOwQ2hk8tsq0CIxoWWd7I=; h=From:To:Subject:Date:In-Reply-To:References:From; b=On9yZ8wX4Clb5PGPvAXGfzCDYCJqtVO2FaMVunuoi7RZKs1OLZCGq9u7szNcZY3xi lDzgrke1UFPTI7FdhB+TUZvDD5oYQJeeDNdURkA9+3OmviWmRsrJJG55THotuBKDwt hLXDZcqjmTPG/kgqIQCHpkmfrqsBJAm54u1OU1TMbBQm1z232krC7XUUMG4qZS+J84 SjITjLx2xNsm90W8ifmkrrsbIDzIvgVwP9Cl3X8EuoHhfk7q0QReY2lA2XAW4ujDst 7gzmlfoWgpACzp7tpWAQ4S+q33kJ7y7ltwB2ppkawtMYRXR2CkzxvmCsWLsgvl4ICH KY1AAEHZHf2Mg== 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 E4F2A4DA1 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 8D4203A17AF 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:05 +0200 Message-ID: <20240405161212.26167-24-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 24/31] fftools/ffmpeg_mux: drop OutputFile.format 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: Bd9kBirYusl+ It is no longer used outside of the muxing code (where we can access the muxer directly). --- fftools/ffmpeg.h | 1 - fftools/ffmpeg_mux.c | 15 +++++++++------ fftools/ffmpeg_mux_init.c | 1 - 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 1d32009f90..7135d9563c 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -611,7 +611,6 @@ typedef struct OutputFile { int index; - const AVOutputFormat *format; const char *url; OutputStream **streams; diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 6a64cba72d..2b7a733501 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -370,10 +370,11 @@ fail: return ret; } -static void thread_set_name(OutputFile *of) +static void thread_set_name(Muxer *mux) { char name[16]; - snprintf(name, sizeof(name), "mux%d:%s", of->index, of->format->name); + snprintf(name, sizeof(name), "mux%d:%s", + mux->of.index, mux->fc->oformat->name); ff_thread_setname(name); } @@ -417,7 +418,7 @@ int muxer_thread(void *arg) if (ret < 0) goto finish; - thread_set_name(of); + thread_set_name(mux); while (1) { OutputStream *ost; @@ -515,8 +516,10 @@ int print_sdp(const char *filename) if (!avc) return AVERROR(ENOMEM); for (int i = 0; i < nb_output_files; i++) { - if (!strcmp(output_files[i]->format->name, "rtp")) { - avc[j] = mux_from_of(output_files[i])->fc; + Muxer *mux = mux_from_of(output_files[i]); + + if (!strcmp(mux->fc->oformat->name, "rtp")) { + avc[j] = mux->fc; j++; } } @@ -756,7 +759,7 @@ int of_write_trailer(OutputFile *of) mux->last_filesize = filesize(fc->pb); - if (!(of->format->flags & AVFMT_NOFILE)) { + if (!(fc->oformat->flags & AVFMT_NOFILE)) { ret = avio_closep(&fc->pb); if (ret < 0) { av_log(mux, AV_LOG_ERROR, "Error closing file: %s\n", av_err2str(ret)); diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 9aad19a85d..ffcc20a504 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -3063,7 +3063,6 @@ int of_open(const OptionsContext *o, const char *filename, Scheduler *sch) av_strlcat(mux->log_name, oc->oformat->name, sizeof(mux->log_name)); - of->format = oc->oformat; if (recording_time != INT64_MAX) oc->duration = recording_time; From patchwork Fri Apr 5 16:12:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47829 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1070526pzd; Fri, 5 Apr 2024 09:15:44 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV54qIAmBhD5MaBFvKiFrR2EhOJIf4NjwieM8X0M/0CJ8AUMQ4kij7u8Tzv9WgO7zU1oHLy5GsMWx644ZgQXZXAEV3RmbPjGWEuNA== X-Google-Smtp-Source: AGHT+IHCjijVFiKOJ7CKf8jPK4vKs5aO8ay80Wg4ZXlwTuQkYP0vD6R0TFx5d0e8GXjFI7MOI84N X-Received: by 2002:a50:d784:0:b0:56b:9f35:65f9 with SMTP id w4-20020a50d784000000b0056b9f3565f9mr1625370edi.0.1712333743933; Fri, 05 Apr 2024 09:15:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712333743; cv=none; d=google.com; s=arc-20160816; b=cPpd6nbCbpo6Rlf4+NoeRVoZJIrpLlukWOg2QphMFOAnN7WKjkH9gkuARapWGqBiNU wk7GT1mERGG+LbdsUFHOkHcld6sGwqhaGfEV9Lai7ngtaeZgLM/RH0YhmWXOnOwp9iu5 Z9PiNmCQZ3YwA2YvdlF6gX3A66Vc9S2I3w0IZMc7qWNl+moTQbYxqqthnhpf9UfiTdgL L8wFaM8wxcsSzK31RZ+YB2HB/Fp/ix1zIGwgoVyLXNqWC1LDcXpMplaUJlwKG188Ya+g 6IzbJA2zzPzQjMhXugwr4ebVY87T1URYHVKzLCyOvxp6OElDZSqIUoe+LNyUs/uC93yf Ifuw== 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:dkim-signature:delivered-to; bh=CPXOjFFAzYaeWqn5zdqc2w4FgbvwKKFmB5ngFYLDCbM=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=Yb9ykAmg3g7tQd1a0wlsurN+HraJBovqA0+q9fMKbgpPFTdZ8rhYOCndOB2s8QaNYw xI25R1/M4WOhXndSkBPojjTxWODHKFTwCGT6dnEFOejdMWlDfwD9EHTk+HrSiUPbfBhS DQ3oLP4U4Ea3DB4JjUfo8H/aGR/bNXsh2xParP/5kdrqhrZ0PV98xyjeRGqL3Gy6vhs2 ivt6bIKp4vZSlrznWwHD1QelNrRaGBwSIvF5aYJwUzagfk0NRmxQORCPvYdy9R9QbGz5 AvFFXSEerOdaPDjsntC3yJqrCCF1IumdXkhk68+TFZRv0Z7FPjQQ6eR1+61mNiMWfijd CnVQ==; 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=Xyz4Rpt0; 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 f19-20020a056402195300b0056c3771c31csi878894edz.131.2024.04.05.09.15.43; Fri, 05 Apr 2024 09:15:43 -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=Xyz4Rpt0; 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 D005C68D281; Fri, 5 Apr 2024 19:13:26 +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 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: ucxL+uXEFw0v 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 From patchwork Fri Apr 5 16:12:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47846 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1070879pzd; Fri, 5 Apr 2024 09:16:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXP/yVL+MDPtdv9L3tvci2Zy1yamer0WKxeQmZ/j9LJqLVCy89PcW87kQrbUYasYxkKWAkNZ274uH2PGCS65SBUfOlDd8hyvcLnww== X-Google-Smtp-Source: AGHT+IE+oC+vKPFFcVJEJb22ojo+8Uop8pYyYUzAx2m4dD94pLjv1uIxH3eUMjvZqPyUmbgu0YAb X-Received: by 2002:a17:906:7f8d:b0:a51:9fbd:6ec0 with SMTP id f13-20020a1709067f8d00b00a519fbd6ec0mr1530849ejr.63.1712333774056; Fri, 05 Apr 2024 09:16:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712333774; cv=none; d=google.com; s=arc-20160816; b=Wa3t3YcvbUBvv6+mpRBGA5RXzvE7QjQ4/rm2ifquOwb9sdVEupiUYKjbGgZXZyVqCq 5ImzYyk0/2j74I1cYFdwUYKwzW4LrkaJKXRDHvLX67VuXTKxRZAEkuMBPVEnYby8QWxv 2WjJXIpVT5bc+WY/o0PcuYcrsyfcSKALfFCL09BkWVbJGpqpoQLNH0F0pCbn0ArtCNCR 9tDybECLLZUa2GTwo/aMrsKNMgxoM9BxWEw8SMqZwDUkndmueaa8/dHK6q3RWP5EHR9d PHLp14VNAMJ+Vt2AeZbc/M5cmxMx+UmZf17JD4kZOEPSS1DXBPBCua53U1kjytXOtkwB 9StQ== 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:dkim-signature:delivered-to; bh=abdIgEiN7c7ebBbvD0ysRcEF3K8vsoA5fYrzRNqeiW0=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=OeFTATX0d2GDyhfzxPCMmVAMTVzDO+B4uyduD9KeaOeiAnnPq0oYTmGOnQZAWSb6Ot 2Mp9vXNF8V8mGysMC3sfcUPesGpaMPBWKP7V0ZUXxIWPLMpi3xIJN9mrhIEC7QcdCukn YEdcmMJtybCcHHSmvLUG29gitBgSw3lG+P5jQvmn9u94qYzW3Kmmy++OaZJ3aawL93Cq BQkn/OI6MEUWuoxKSyvMtNg0QQQyxlFyu5xODYVv7bbeuHeAOVBbxS73MjJ8e4XNPnSX z+5jvHSdRx0xQRk+HkCeEKzJMjaq2ukhzHkoyOihsgfKuvMsYPemA27VxH3Z92ld2qr/ ro+w==; 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=sBsCrlhL; 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 w26-20020a170906481a00b00a51970e93acsi810033ejq.640.2024.04.05.09.16.00; Fri, 05 Apr 2024 09:16:14 -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=sBsCrlhL; 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 EC5A868D293; Fri, 5 Apr 2024 19:13:28 +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 5F73B68D1AC 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=sBsCrlhL; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 402F34D88 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 h3EQIRtjurDD 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=qNzgtm4Ys5p8ywgXNMugEuQwGRJucnBc8lMh7hDmh6k=; h=From:To:Subject:Date:In-Reply-To:References:From; b=sBsCrlhLqzY5VENLgvaK2BNsoWhFq4gqcpKult5PfnXgfutDauf01yV3R9REcV49U +E36tCing3NDO2/6HQbK+NIz7N068G/9ZBlBmEvFkv0fgKHTFknAadRsgeizhU69pU N5m78eLz2flKjQZ1WlezVAXZOcf8qbv/42nhYS+LbuWuL7589zhnEtF/JgoN/3uqXT ZUmF1kiiSJmTOM29fCJ/RMj4GaVEnjGni7AWsdovVdcdvANGtJlKn7409LVLXFm1B7 e8V4R1b6ukOO1p1+Fu/BLWXo9SFXGF8hzOEcfndeoZLkTheM1Z4tSUnVPxkayxMO+q +V58KCWj1+rHA== 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 A42564D9E 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 A49843A186D 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:07 +0200 Message-ID: <20240405161212.26167-26-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 26/31] fftools/ffmpeg_filter: drop OutputFilter.ost 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: vHbhRqBp+drD All remaining code accessing it only needs to know whether this filtergraph output has been bound or not. --- fftools/ffmpeg.h | 2 +- fftools/ffmpeg_filter.c | 6 +++--- fftools/ffmpeg_mux_init.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index f77ec956b3..6446a141b5 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -314,12 +314,12 @@ typedef struct InputFilter { typedef struct OutputFilter { const AVClass *class; - struct OutputStream *ost; struct FilterGraph *graph; uint8_t *name; /* for filters that are not yet bound to an output stream, * this stores the output linklabel, if any */ + int bound; uint8_t *linklabel; char *apad; diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 9fc6e32960..3988cf5fc2 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -806,10 +806,10 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, FilterGraphPriv *fgp = fgp_from_fg(fg); int ret; - av_assert0(!ofilter->ost); + av_assert0(!ofilter->bound); av_assert0(ofilter->type == ost->type); - ofilter->ost = ost; + ofilter->bound = 1; av_freep(&ofilter->linklabel); ofp->flags = opts->flags; @@ -1279,7 +1279,7 @@ int fg_finalise_bindings(FilterGraph *fg) for (int i = 0; i < fg->nb_outputs; i++) { OutputFilter *output = fg->outputs[i]; - if (!output->ost) { + if (!output->bound) { av_log(filtergraphs[i], AV_LOG_FATAL, "Filter %s has an unconnected output\n", output->name); return AVERROR(EINVAL); diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 10421ae1b0..6d8bd5bcdf 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -1827,7 +1827,7 @@ static int create_streams(Muxer *mux, const OptionsContext *o) for (int j = 0; j < fg->nb_outputs; j++) { OutputFilter *ofilter = fg->outputs[j]; - if (ofilter->linklabel || ofilter->ost) + if (ofilter->linklabel || ofilter->bound) continue; auto_disable |= 1 << ofilter->type; From patchwork Fri Apr 5 16:12:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47849 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1071023pzd; Fri, 5 Apr 2024 09:16:25 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVuebUfsiiKABVkTcghEJvUfwuCTIg9CmyUehP85hBEWX69Rg5y+dqeYt+PG0Jmewxgd14iC6aQ5iedjEkcPFJ7dU+d0KbylewCkQ== X-Google-Smtp-Source: AGHT+IHsd9W5gm0QFfGblDNufZ8A7jcY4SxI5DBIfr2yiv++ZhO8UI0RHziOhZdjxSQjlUObPVfe X-Received: by 2002:a19:ca4d:0:b0:513:c61c:7331 with SMTP id h13-20020a19ca4d000000b00513c61c7331mr1985177lfj.3.1712333785521; Fri, 05 Apr 2024 09:16:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712333785; cv=none; d=google.com; s=arc-20160816; b=VvAWtStL/F1aVOnEkpLY6MzyG3qdgmMTI4khMCHEs9c7CSLewn4Vr1ageSWlnuSWkj 4vTwfMgNBoK+2v7CoF87xtf5QDDqclK9XcfGilv6Iug3FIWfZdimU5k50xnYhFyYIhtk SZ5My7L1B4eNYV+9fLoXTprARD2wpSWIv20aow8gynMBozBST0p/jQbM/a4IuCtw9fXL ypM9KUMM2sX/1dnrNPaLlzjUw7uGSr/oWNkMXCAzbQwuLmikMP+HX+omOhzKghRe6a9n P2oM6TlBxsex3mI4oxSWSks386noH8CJKoiu8X+4TlMTkZ4fOYL6O/ATn34et3Rp7vTZ wzuw== 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:dkim-signature:delivered-to; bh=bES6GeQy4FREcMDNtjn4Sx8Zu20jV4QTeu2eKZtQ4GA=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=gG6pKLWLFBQKTNVLuD54Y3ACUfYeDFQJpX+TwsJUFqIaFO5KcYFx0W65L9W6Y5D9Al f9VbHsaXL/mCHiEPT80lLGyoH7pCZd8kB1KVwIQKW7CmuVEY9TzhMp8B1ZcmUHsxowGn UMgExKaBXsZ2kuPAGQpoYwIlO9t4S3BGewAII6/TPvhItnOJXYm0fjDM9ChQE/1/rTJB Dph7ctfWpv9iNqIdYe4LoxSvBTZy405/EZmkwi083EOQdGI9/324Ydd9JK8iRpwTZTuJ eFOaY1+FLFDcwgdS8LEuHB6RU0W0fz9UfxQlkM4lsmmzLNJNx78l1KSJEEYy4CD6+Iap Y2RA==; 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=I55dhm6n; 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 g11-20020a1709063b0b00b00a5188654596si823639ejf.743.2024.04.05.09.16.25; Fri, 05 Apr 2024 09:16:25 -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=I55dhm6n; 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 0691568D2D9; Fri, 5 Apr 2024 19:13:32 +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 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 6DL/uT8W8xjF 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)) From patchwork Fri Apr 5 16:12:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47841 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1070076pzd; Fri, 5 Apr 2024 09:15:10 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWAACg83NB+dlKohlCT5ttksDMas3/fcipO+JTEePVKQkP/yf6WQsTNcmUGjRZlrO5QC6TeVtw5nKpZgZ8H2gwVWGOMwchp6spQ9w== X-Google-Smtp-Source: AGHT+IHSG9irXjsHWjGPoXSst4LXF59LtjXVdzz+O0prSOsiCZcqrHf0L/V/Kh2iuNzsnNxKy/g0 X-Received: by 2002:a50:ab51:0:b0:56e:2aef:f92e with SMTP id t17-20020a50ab51000000b0056e2aeff92emr1260286edc.17.1712333709810; Fri, 05 Apr 2024 09:15:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712333709; cv=none; d=google.com; s=arc-20160816; b=cKiuVjm3u7/scxZ+XJlNILysAvY18Ty0hS33pMkWd51AZG9yr4Lh9lM65dTmoDjnN6 C7Lb/I1G2Cz9HBV9ryKJ2uC3GHL/9XvX70DJ+sFTsX/ZwZaw/B7RH/VKEWfm/vvAGVcs 8OYeaRR72kYChjMpNbL+gjp5ZmVnHEUtPCRUri4HhrmjSjXZFBlMLwc/xLR0MDqzSWGh wBWv4DcxzJqaSQJmJq7nw50wEV9BYZ8pqdgbYtKeWK/AWdOGTOUBW1KGdVwE/mIPJBf1 SOpDeCASVGYCOi+WSvZ4MDiUptga3xg3b9LXjyWQXDNkXSGNohh3txAQT1rvq0h1kcsg YZpQ== 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:dkim-signature:delivered-to; bh=Cv0w+GJ3N4cEZdSCLQ7xlceLFspzR5P6gVd3wf8tTjU=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=LclkWoKTGqlN7zdrnW3vRQqJQigsfnmsTdTdDooXzkpMIoa3Qq4Z+/Jd3WgK4EEcRU WxQj8BYKvwyLnIxMASOdMofkPYuRktoirprwRe1ANkurVVHxSwoVql2U0dV4wMOCp3Yt UjD8opgBm3mwidAyULQBLfdVtVG9A+RY/4k2KDBZJh815XzCrzNuq2x044M3NgnMRApP qQDAA18jSkJ3If9pmbPaenoNysRJAoBwrhbTXJmNCTpGrBPv/xVVznf6HIDEqwvr/B2W RDSAIRtIMev0V2CHmTUm6J2G/iJ5GFqpHNjqGsyNNfLC9ZVxJUzxU+U94YFdki58Yp0Z g7tA==; 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=OadrAsfW; 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 i28-20020a50871c000000b0056e0967bfa6si857406edb.215.2024.04.05.09.15.09; Fri, 05 Apr 2024 09:15:09 -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=OadrAsfW; 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 0451968D225; Fri, 5 Apr 2024 19:13:23 +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 5730668D18A 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=OadrAsfW; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 1FEEF4D89 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 iQk9cWF7HNNT for ; Fri, 5 Apr 2024 18:13:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712333582; bh=m+DRAjgQDkKxkGi+BL/Ov1vBvbvsyW0VESfDXyEVhSY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=OadrAsfWy/E+k8rGySfuFpCh40QcJfDTPF0WXvySH05bZn/FkDc442I3LF1+1Xfxo ryg+2e9XwePp3QT9ebtZDCnwVK3628od4owlwKQ5oiYLBWtmOEkeMghLnzozWoWlGk fIeXS4eL2B0A3lxCNoLGbFbe9dPyMtJhVTPtNDjQUFIYbQI1/9GON0bKAbPlF6jS+v H2a0rUBsFEbWrzjou18tjNWZmydt6ynj41T3/SKthscLwaIH5kegQtnCy1Ae0LWtkE iWu8WFEriX+KswShpENAYjIvXBxjRhumDXS6G3KE/8tzWaBfP6LOaQyhECJXPcZxi4 pN76QEf6bZXbQ== 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 CEA744D94 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 BC0033A18E7 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:09 +0200 Message-ID: <20240405161212.26167-28-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 28/31] fftools/ffmpeg_filter: change processing order in fg_finalise_bindings() 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: VjYPyXPzQKSS First bind all inputs in all filtergraphs, only then check that all outputs are bound. Needed by the following commit. --- fftools/ffmpeg.h | 2 +- fftools/ffmpeg_filter.c | 33 ++++++++++++++++++++++++++------- fftools/ffmpeg_opt.c | 10 ++++------ 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 882d241bdb..885a7c0c10 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -724,7 +724,7 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost, char *graph_desc, Scheduler *sch, unsigned sch_idx_enc, const OutputFilterOptions *opts); -int fg_finalise_bindings(FilterGraph *fg); +int fg_finalise_bindings(void); /** * Get our axiliary frame data attached to the frame, allocating it diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 388c8919fd..1e14962f41 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1272,7 +1272,7 @@ static int fg_complex_bind_input(FilterGraph *fg, InputFilter *ifilter) return 0; } -int fg_finalise_bindings(FilterGraph *fg) +static int bind_inputs(FilterGraph *fg) { // bind filtergraph inputs to input streams for (int i = 0; i < fg->nb_inputs; i++) { @@ -1287,14 +1287,33 @@ int fg_finalise_bindings(FilterGraph *fg) return ret; } - for (int i = 0; i < fg->nb_outputs; i++) { - OutputFilter *output = fg->outputs[i]; - if (!output->bound) { - av_log(filtergraphs[i], AV_LOG_FATAL, - "Filter %s has an unconnected output\n", output->name); - return AVERROR(EINVAL); + return 0; +} + +int fg_finalise_bindings(void) +{ + int ret; + + for (int i = 0; i < nb_filtergraphs; i++) { + ret = bind_inputs(filtergraphs[i]); + if (ret < 0) + return ret; + } + + // check that all outputs were bound + for (int i = 0; i < nb_filtergraphs; i++) { + FilterGraph *fg = filtergraphs[i]; + + for (int j = 0; j < fg->nb_outputs; j++) { + OutputFilter *output = fg->outputs[j]; + if (!output->bound) { + av_log(filtergraphs[j], AV_LOG_FATAL, + "Filter %s has an unconnected output\n", output->name); + return AVERROR(EINVAL); + } } } + return 0; } diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index f764da1ed4..6526e8e3e8 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -1264,12 +1264,10 @@ int ffmpeg_parse_options(int argc, char **argv, Scheduler *sch) } // bind unbound filtegraph inputs/outputs and check consistency - for (int i = 0; i < nb_filtergraphs; i++) { - ret = fg_finalise_bindings(filtergraphs[i]); - if (ret < 0) { - errmsg = "binding filtergraph inputs/outputs"; - goto fail; - } + ret = fg_finalise_bindings(); + if (ret < 0) { + errmsg = "binding filtergraph inputs/outputs"; + goto fail; } correct_input_start_times(); From patchwork Fri Apr 5 16:12:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47843 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1070299pzd; Fri, 5 Apr 2024 09:15:27 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVbnrnwQHqo7NQq8dHWarwdF6Z3Z9EfXJG8JRluuzPbBtb2wlxuoJEzlE1lenp8x8F3RrR6QIrAaWBYiuytY4/uQ3wC3wXQzoyyhQ== X-Google-Smtp-Source: AGHT+IEo/+14S0H6XVbpk0P4S9Z0xPYxujd2gLDbvvT0jxBtonRAUQNCBVR8PhExAPAKsTbOhZkG X-Received: by 2002:a17:907:7da9:b0:a51:abd8:8621 with SMTP id oz41-20020a1709077da900b00a51abd88621mr1199074ejc.19.1712333727002; Fri, 05 Apr 2024 09:15:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712333726; cv=none; d=google.com; s=arc-20160816; b=McHEVF75f44yGeNWLytGkbBN0XuTchwyioldEoULbgdV7skSdfx638suKTzqt2RBfg HyDSzHog3scdGSJPSNYSyTllj/meHEUs9J9t8GrA0C1RvVzGWij574E8BMWh37OuM4hJ A/8UxflxsakGHoDZZnn+JrnBbsOlWgbsSd0OrsejdJnIaEqNbMrCNDMSCQikAZR2KX3j o0SE+y0O4RAavDrrbxh0inTsEYzXXAss6JcU3hMSAW5dhvwUu8IIs4k8OVcX0ar11nps O2k+SF7FQL1UPdckirj5KbLa70+pIPtMc/zVl5feIyVAVh4yTOf0JWvhzbcKR9ozeAXi oRqA== 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:dkim-signature:delivered-to; bh=ac7YZwMGdv/6Z/bLOC7egJWfUdG0e6pnB1CT75HV8nk=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=KP//JY7oeRhNZMb2EvKzgnQOilz4A7tC8iuZJlnznKUcx9IQCjaBaVIqiticzTH200 MUYrzpCTCozLEqilfOvrG6gGD3U+w1+yQPU4e9x1yHfJuzmm+JOWh9vktw2S4hA/bQEf EsAyqlTXLgsRZmMvjzh8EUP1S7ow67zru4tb5dYnMVed6WbJPt0SPCerbx4f4WhCzE2W /+CFoIauaDSGvT5u2FPBycT7eqbI1KJswp5BRo2QsSJl5nOkISHbS5imn3VA2K7oQERk DC//q8Yo59MkENE7d9xV5ZcEJid8yVJ3p6dxHWBgvf8DBFC1HsOnJ7FhNHMrdD9lXegw 2soQ==; 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=oYRKa6cv; 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 f25-20020a170906085900b00a51a9260868si572443ejd.332.2024.04.05.09.15.26; Fri, 05 Apr 2024 09:15:26 -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=oYRKa6cv; 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 B622868D267; Fri, 5 Apr 2024 19:13:24 +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 443D368D171 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=oYRKa6cv; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 72F304D7D for ; Fri, 5 Apr 2024 18:13:06 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id W1dqV56_RHMV for ; Fri, 5 Apr 2024 18:13:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712333582; bh=Q5RY9Bu2x2oyBeQeQv0d713sv0y1ooNxNaTWsKUNjRw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=oYRKa6cvs14cC9aWf6NkNa+/tVQVKQxVCG+yO5NmbRJ0xUlEaQY6hr7yvmMCdkn97 X3Pq8gXGEAhD+xntiPME+lGxXhlR7X7JVgiQOv73QKhDLj4pAL8Xj2QiTtrmT/IJSX RHbk0oaSTvKSEqa5YD0omKVP7xjE3tyG5I8rsXSDvfftix7yPxAti7h3WzLnHP3d8x U3RrmlGL7ikhBq46WQW62rWCALxPY+faLzzE5+nZPO2jyaNc7SeDUfxJ0e6+9+KaXy O2BvAaGxDc9F0Mi98g3gBEIwS+vZow/fAIFoy/C8zqtuSSTRuD/cr1Znk0uw6Pl6/m FHeuq7icpM6HA== 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 C97C64D92 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 C7DB03A1958 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:10 +0200 Message-ID: <20240405161212.26167-29-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 29/31] fftools/ffmpeg_sched: allow filtergraphs to send to filtergraphs 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: Ct1P+jTWojMy Will be useful for filtergraph chaining that will be added in following commits. --- fftools/ffmpeg_sched.c | 94 ++++++++++++++++++++++++++---------------- fftools/ffmpeg_sched.h | 6 ++- 2 files changed, 63 insertions(+), 37 deletions(-) diff --git a/fftools/ffmpeg_sched.c b/fftools/ffmpeg_sched.c index f8485db30b..e58b00ea97 100644 --- a/fftools/ffmpeg_sched.c +++ b/fftools/ffmpeg_sched.c @@ -983,20 +983,40 @@ int sch_connect(Scheduler *sch, SchedulerNode src, SchedulerNode dst) } case SCH_NODE_TYPE_FILTER_OUT: { SchFilterOut *fo; - SchEnc *enc; av_assert0(src.idx < sch->nb_filters && src.idx_stream < sch->filters[src.idx].nb_outputs); - // filtered frames go to encoding - av_assert0(dst.type == SCH_NODE_TYPE_ENC && - dst.idx < sch->nb_enc); + fo = &sch->filters[src.idx].outputs[src.idx_stream]; - fo = &sch->filters[src.idx].outputs[src.idx_stream]; - enc = &sch->enc[dst.idx]; + av_assert0(!fo->dst.type); + fo->dst = dst; + + // filtered frames go to encoding or another filtergraph + switch (dst.type) { + case SCH_NODE_TYPE_ENC: { + SchEnc *enc; + + av_assert0(dst.idx < sch->nb_enc); + enc = &sch->enc[dst.idx]; + + av_assert0(!enc->src.type); + enc->src = src; + break; + } + case SCH_NODE_TYPE_FILTER_IN: { + SchFilterIn *fi; + + av_assert0(dst.idx < sch->nb_filters && + dst.idx_stream < sch->filters[dst.idx].nb_inputs); + fi = &sch->filters[dst.idx].inputs[dst.idx_stream]; + + av_assert0(!fi->src.type); + fi->src = src; + break; + } + default: av_assert0(0); + } - av_assert0(!fo->dst.type && !enc->src.type); - fo->dst = dst; - enc->src = src; break; } @@ -1351,24 +1371,13 @@ static int check_acyclic(Scheduler *sch) goto fail; } - // trace the transcoding graph upstream from every output stream - // fed by a filtergraph - for (unsigned i = 0; i < sch->nb_mux; i++) { - SchMux *mux = &sch->mux[i]; - - for (unsigned j = 0; j < mux->nb_streams; j++) { - SchMuxStream *ms = &mux->streams[j]; - SchedulerNode src = ms->src_sched; - - if (src.type != SCH_NODE_TYPE_FILTER_OUT) - continue; - src.idx_stream = 0; - - ret = check_acyclic_for_output(sch, src, filters_visited, filters_stack); - if (ret < 0) { - av_log(mux, AV_LOG_ERROR, "Transcoding graph has a cycle\n"); - goto fail; - } + // trace the transcoding graph upstream from every filtegraph + for (unsigned i = 0; i < sch->nb_filters; i++) { + ret = check_acyclic_for_output(sch, (SchedulerNode){ .idx = i }, + filters_visited, filters_stack); + if (ret < 0) { + av_log(&sch->filters[i], AV_LOG_ERROR, "Transcoding graph has a cycle\n"); + goto fail; } } @@ -1484,13 +1493,18 @@ static int start_prepare(Scheduler *sch) "Filtergraph input %u not connected to a source\n", j); return AVERROR(EINVAL); } - av_assert0(fi->src.type == SCH_NODE_TYPE_DEC); - dec = &sch->dec[fi->src.idx]; - switch (dec->src.type) { - case SCH_NODE_TYPE_DEMUX: fi->src_sched = dec->src; break; - case SCH_NODE_TYPE_ENC: fi->src_sched = sch->enc[dec->src.idx].src; break; - default: av_assert0(0); + if (fi->src.type == SCH_NODE_TYPE_FILTER_OUT) + fi->src_sched = fi->src; + else { + av_assert0(fi->src.type == SCH_NODE_TYPE_DEC); + dec = &sch->dec[fi->src.idx]; + + switch (dec->src.type) { + case SCH_NODE_TYPE_DEMUX: fi->src_sched = dec->src; break; + case SCH_NODE_TYPE_ENC: fi->src_sched = sch->enc[dec->src.idx].src; break; + default: av_assert0(0); + } } } @@ -2379,12 +2393,17 @@ void sch_filter_receive_finish(Scheduler *sch, unsigned fg_idx, unsigned in_idx) int sch_filter_send(Scheduler *sch, unsigned fg_idx, unsigned out_idx, AVFrame *frame) { SchFilterGraph *fg; + SchedulerNode dst; av_assert0(fg_idx < sch->nb_filters); fg = &sch->filters[fg_idx]; av_assert0(out_idx < fg->nb_outputs); - return send_to_enc(sch, &sch->enc[fg->outputs[out_idx].dst.idx], frame); + dst = fg->outputs[out_idx].dst; + + return (dst.type == SCH_NODE_TYPE_ENC) ? + send_to_enc (sch, &sch->enc[dst.idx], frame) : + send_to_filter(sch, &sch->filters[dst.idx], dst.idx_stream, frame); } static int filter_done(Scheduler *sch, unsigned fg_idx) @@ -2396,8 +2415,11 @@ static int filter_done(Scheduler *sch, unsigned fg_idx) tq_receive_finish(fg->queue, i); for (unsigned i = 0; i < fg->nb_outputs; i++) { - SchEnc *enc = &sch->enc[fg->outputs[i].dst.idx]; - int err = send_to_enc(sch, enc, NULL); + SchedulerNode dst = fg->outputs[i].dst; + int err = (dst.type == SCH_NODE_TYPE_ENC) ? + send_to_enc (sch, &sch->enc[dst.idx], NULL) : + send_to_filter(sch, &sch->filters[dst.idx], dst.idx_stream, NULL); + if (err < 0 && err != AVERROR_EOF) ret = err_merge(ret, err); } diff --git a/fftools/ffmpeg_sched.h b/fftools/ffmpeg_sched.h index e51c26cec9..7cd839016c 100644 --- a/fftools/ffmpeg_sched.h +++ b/fftools/ffmpeg_sched.h @@ -41,7 +41,8 @@ * - filtergraphs, each containing zero or more inputs (0 in case the * filtergraph contains a lavfi source filter), and one or more outputs; the * inputs and outputs need not have matching media types; - * each filtergraph input receives decoded frames from some decoder; + * each filtergraph input receives decoded frames from some decoder or another + * filtergraph output; * filtered frames from each output are sent to some encoder; * - encoders, which receive decoded frames from some decoder (subtitles) or * some filtergraph output (audio/video), encode them, and send encoded @@ -51,6 +52,9 @@ * encoder (transcoding); those packets are interleaved and written out by the * muxer. * + * The structure formed by the above components is a directed acyclic graph + * (absence of cycles is checked at startup). + * * There must be at least one muxer instance, otherwise the transcode produces * no output and is meaningless. Otherwise, in a generic transcoding scenario * there may be arbitrary number of instances of any of the above components, From patchwork Fri Apr 5 16:12:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47828 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1073436pzd; Fri, 5 Apr 2024 09:20:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW8PaobSIjREYablu3ah+WEiHLBxnlctbNcPBYaZbA2Op/ICfEsTmwc/4DtY+8PpKbSOl4AOwC47vk93P1/645lwR5oMfQLNjNogQ== X-Google-Smtp-Source: AGHT+IF/zno9ccQluV+D6ocv6af9jK5gTEmYrvJPx/6yPONlmoufiflNpZ38p2LJx/eA8lvAZrKE X-Received: by 2002:a17:907:7243:b0:a51:827d:c471 with SMTP id ds3-20020a170907724300b00a51827dc471mr1699758ejc.2.1712334021092; Fri, 05 Apr 2024 09:20:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712334021; cv=none; d=google.com; s=arc-20160816; b=IJiTFhROWHZtE5ygVsKqmc5LTK8lknVBCVtRt1syY8vxlMfX4vTUr2yNLUhfsC8YJv eO1gT0qfjoDtmCXY6Pp2nfrCo2LWMtnYCl/Q3rId/B/7xbRyt7J4LnbR42gj03Tu90SF FIsmDqsw5eXjRTn33ncwV/m9axjPDcDZGOyXISCtEWZ7OlWVKPlNQdizxXTGvawbR1RR ZFueNhsysfsv2YGkiZNITs1ogNvhxotuL9cuzFPvH8oCysM5Qndw7gmvwbhUyrSIQ6hc THTOCLhgeGLOggIxJNtJ9APratYoPJSZQTF9WGRZyTznFLjNL6vqrU2cDG0hLeaASS/F RbGg== 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:dkim-signature:delivered-to; bh=Spb9zHudEfIghjLkY4tOVGNEuc8i7q1qdgg5qPysxGw=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=dnO7hZ52iPvRTtJ1ghygsxLozedFiz3iGeTgVk8s4ILGH3IQUo63YmuSHqTr1maoj6 gBX3Q+FKPIRKTeBJBCizrGU9wOFGOJFR+8HpqcpFY+T11zax6rUgaPC1e8SAjVTIEpPF 9QiyKFuSL36BcNHU71dGmcf+w/JEOzDxfytylx2Yc1x2ROYLz0GbBgtAspHfOJrApzu1 /5y2vI2mtbpzGE/9LiWKrqexs5jJhbuHZZgU87UnrQgmJC/V5cYOOWncZRaBqf51lVmQ vXeNGVH/0eAL58lYPEE2V0+QvzwVJHYyuhq8qkUxK5z1kEVzAkijn4H1FPNKViFtsuCk Tc8A==; 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="GtM2/q3y"; 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 l10-20020a170906078a00b00a4e7817756bsi840510ejc.347.2024.04.05.09.20.20; Fri, 05 Apr 2024 09:20:21 -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="GtM2/q3y"; 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 BF6EC68D365; Fri, 5 Apr 2024 19:20:17 +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 1369068D25B for ; Fri, 5 Apr 2024 19:20:11 +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=GtM2/q3y; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id B29CA1C2D for ; Fri, 5 Apr 2024 18:20:10 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id RWf6i1Bxfjrb for ; Fri, 5 Apr 2024 18:20:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712334008; bh=9ZSssHZ8o1AwhBx6HHQaynVexzZG855zteIAYtjkN+Q=; h=From:To:Subject:Date:In-Reply-To:References:From; b=GtM2/q3yCGCOW+PtCE5hp62BFJb8ep/NqqVJagQVhrjxT+ad7HR6pWdVNnnR4LZ04 2NL3yf784j+LNUMmVahc34Q5Cf417XWpXbxCdyZqRRqTNpdZnmlfRgiq4cduxbB1K0 0wZRVPrXikYlP94r8RZ+sGUNxwieTk4K28NoKfth/oDrpHQGho226WViLpkhbergS5 QZ4Tdpm3Hus0+zXQEldyw9GE8gdvOWE3RoqfNSpo9IDIRcHLje3xcLEJ5bGkGVHcL0 x9Hws39CDSUsgZ02toBcKPND2eebhNAr9F3asE7uqz2iA9XeYvavnrtojMwQOYzmDC jotSzFmrv4JAw== 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 6F42125F for ; Fri, 5 Apr 2024 18:20:08 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id D39E83A197B 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:11 +0200 Message-ID: <20240405161212.26167-30-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 30/31] fftools/ffmpeg_filter: implement filtergraph chaining 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: D485fs+9/bgr This allows one complex filtergraph's output to be sent as input to another one, which is useful in certain situations (one is described in the docs). Chaining filtergraphs was already effectively possible by using a wrapped_avframe encoder connected to a loopback decoder, but it is ugly, non-obvious and inefficient. --- Changelog | 1 + doc/ffmpeg.texi | 58 ++++++++++++++++++++++++--- fftools/ffmpeg_filter.c | 89 +++++++++++++++++++++++++++++++++++++++-- 3 files changed, 140 insertions(+), 8 deletions(-) diff --git a/Changelog b/Changelog index 18e83b99a1..b7a1af4083 100644 --- a/Changelog +++ b/Changelog @@ -4,6 +4,7 @@ releases are sorted from youngest to oldest. version : - Raw Captions with Time (RCWT) closed caption demuxer - LC3/LC3plus decoding/encoding using external library liblc3 +- ffmpeg CLI filtergraph chaining version 7.0: diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 801c083705..9bd548ce4e 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -2145,14 +2145,62 @@ type -- see the @option{-filter} options. @var{filtergraph} is a description of the filtergraph, as described in the ``Filtergraph syntax'' section of the ffmpeg-filters manual. -Input link labels must refer to either input streams or loopback decoders. For -input streams, use the @code{[file_index:stream_specifier]} syntax (i.e. the -same as @option{-map} uses). If @var{stream_specifier} matches multiple streams, -the first one will be used. +Inputs to a complex filtergraph may come from different source types, +distinguished by the format of the corresponding link label: +@itemize +@item +To connect an input stream, use @code{[file_index:stream_specifier]} (i.e. the +same syntax as @option{-map}). If @var{stream_specifier} matches multiple +streams, the first one will be used. -For decoders, the link label must be [dec:@var{dec_idx}], where @var{dec_idx} is +@item +To connect a loopback decoder use [dec:@var{dec_idx}], where @var{dec_idx} is the index of the loopback decoder to be connected to given input. +@item +To connect an output from another complex filtergraph, use its link label. E.g +the following example: + +@example +ffmpeg -i input.mkv \ + -filter_complex '[0:v]scale=size=hd1080,split=outputs=2[for_enc][orig_scaled]' \ + -c:v libx264 -map '[for_enc]' output.mkv \ + -dec 0:0 \ + -filter_complex '[dec:0][orig_scaled]hstack[stacked]' \ + -map '[stacked]' -c:v ffv1 comparison.mkv +@end example + +reads an input video and +@itemize +@item +(line 2) uses a complex filtergraph with one input and two outputs +to scale the video to 1920x1080 and duplicate the result to both +outputs; + +@item +(line 3) encodes one scaled output with @code{libx264} and writes the result to +@file{output.mkv}; + +@item +(line 4) decodes this encoded stream with a loopback decoder; + +@item +(line 5) places the output of the loopback decoder (i.e. the +@code{libx264}-encoded video) side by side with the scaled original input; + +@item +(line 6) combined video is then losslessly encoded and written into +@file{comparison.mkv}. + +@end itemize + +Note that the two filtergraphs cannot be combined into one, because then there +would be a cycle in the transcoding pipeline (filtergraph output goes to +encoding, from there to decoding, then back to the same graph), and such cycles +are not allowed. + +@end itemize + An unlabeled input will be connected to the first unused input stream of the matching type. diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 1e14962f41..f108f8daf9 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -902,6 +902,63 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, return 0; } +static int ofilter_bind_ifilter(OutputFilter *ofilter, InputFilterPriv *ifp, + const OutputFilterOptions *opts) +{ + OutputFilterPriv *ofp = ofp_from_ofilter(ofilter); + + av_assert0(!ofilter->bound); + av_assert0(ofilter->type == ifp->type); + + ofilter->bound = 1; + av_freep(&ofilter->linklabel); + + ofp->name = av_strdup(opts->name); + if (!ofp->name) + return AVERROR(EINVAL); + + av_strlcatf(ofp->log_name, sizeof(ofp->log_name), "->%s", ofp->name); + + return 0; +} + +static int ifilter_bind_fg(InputFilterPriv *ifp, FilterGraph *fg_src, int out_idx) +{ + FilterGraphPriv *fgp = fgp_from_fg(ifp->ifilter.graph); + OutputFilter *ofilter_src = fg_src->outputs[out_idx]; + OutputFilterOptions opts; + char name[32]; + int ret; + + av_assert0(!ifp->bound); + ifp->bound = 1; + + if (ifp->type != ofilter_src->type) { + av_log(fgp, AV_LOG_ERROR, "Tried to connect %s output to %s input\n", + av_get_media_type_string(ofilter_src->type), + av_get_media_type_string(ifp->type)); + return AVERROR(EINVAL); + } + + ifp->type_src = ifp->type; + + memset(&opts, 0, sizeof(opts)); + + snprintf(name, sizeof(name), "fg:%d:%d", fgp->fg.index, ifp->index); + opts.name = name; + + ret = ofilter_bind_ifilter(ofilter_src, ifp, &opts); + if (ret < 0) + return ret; + + ret = sch_connect(fgp->sch, SCH_FILTER_OUT(fg_src->index, out_idx), + SCH_FILTER_IN(fgp->sch_idx, ifp->index)); + if (ret < 0) + return ret; + + return 0; +} + static InputFilter *ifilter_alloc(FilterGraph *fg) { InputFilterPriv *ifp; @@ -1213,12 +1270,38 @@ static int fg_complex_bind_input(FilterGraph *fg, InputFilter *ifilter) ifilter->name); return ret; } else if (ifp->linklabel) { - // bind to an explicitly specified demuxer stream AVFormatContext *s; AVStream *st = NULL; char *p; - int file_idx = strtol(ifp->linklabel, &p, 0); + int file_idx; + // try finding an unbound filtergraph output with this label + for (int i = 0; i < nb_filtergraphs; i++) { + FilterGraph *fg_src = filtergraphs[i]; + + if (fg == fg_src) + continue; + + for (int j = 0; j < fg_src->nb_outputs; j++) { + OutputFilter *ofilter = fg_src->outputs[j]; + + if (!ofilter->bound && ofilter->linklabel && + !strcmp(ofilter->linklabel, ifp->linklabel)) { + av_log(fg, AV_LOG_VERBOSE, + "Binding input with label '%s' to filtergraph output %d:%d\n", + ifp->linklabel, i, j); + + ret = ifilter_bind_fg(ifp, fg_src, j); + if (ret < 0) + av_log(fg, AV_LOG_ERROR, "Error binding filtergraph input %s\n", + ifp->linklabel); + return ret; + } + } + } + + // bind to an explicitly specified demuxer stream + file_idx = strtol(ifp->linklabel, &p, 0); if (file_idx < 0 || file_idx >= nb_input_files) { av_log(fg, AV_LOG_FATAL, "Invalid file index %d in filtergraph description %s.\n", file_idx, fgp->graph_desc); @@ -1274,7 +1357,7 @@ static int fg_complex_bind_input(FilterGraph *fg, InputFilter *ifilter) static int bind_inputs(FilterGraph *fg) { - // bind filtergraph inputs to input streams + // bind filtergraph inputs to input streams or other filtergraphs for (int i = 0; i < fg->nb_inputs; i++) { InputFilterPriv *ifp = ifp_from_ifilter(fg->inputs[i]); int ret; From patchwork Fri Apr 5 16:12:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47852 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1071269pzd; Fri, 5 Apr 2024 09:16:50 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU2jbCDJwBOLIPZ/ZxZgFliLpk+YXmDv75P3af5g5q9KdDKbXtYprZVu5xXhAIngsT44I/GPPtz30d74GSEJgWxOL1Eu76H/fwf3w== X-Google-Smtp-Source: AGHT+IHZMUH7U2NikP4B/8JwnwLUbk0gdck+SgtPZGlIM6QriipkJCbkBN7bCmf4pBUZDic7THZD X-Received: by 2002:a17:906:3b4d:b0:a4e:24af:d8a4 with SMTP id h13-20020a1709063b4d00b00a4e24afd8a4mr1389403ejf.28.1712333809963; Fri, 05 Apr 2024 09:16:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712333809; cv=none; d=google.com; s=arc-20160816; b=L3y3Cipe5q/wYeuEG0EIRqDDDr3umWgUA+VH0cAvFtgwOHjubZTyuQzL60DaD6Cd4+ PbpgUEvn75/9uk5EETNjd5qT6jbjVfTYQ+NKzCViVBfLdNKIGOzxhMobgCi42u+SvJPW KZI+NamhR88fyhEGVDxHBNQYaJGvMrBFQq7jOxXryuddUECqFaX2ZRQMaUGB3NdszZ6z pMPm92tbaCHIvjxeNNJv/YccJLg4JW4sRNpxAI0Rd9YtPmw5ojz/pzJc0PyZi6yhT0yu OdhkXQlbgFUJpHLqbSPUbFym/Kph7bMyOLW5SdPPrezMhk9zt9y+zG4ZY/OiHsJ9GoMD JFsQ== 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:dkim-signature:delivered-to; bh=soyGHZRR2gxZifVjRovgugsWt9aaNXEmBtNFBEHFeCQ=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=n9qiS81woVaFrRZ/eY0B/CLe29bZSyBv7/nBeYJNntifsMt4J7ITbMRN1HbeUrzC4M V/pL7aEf9FVw8M/ppJAUPuf0D+zJR23sU6m7kWECC1gZ2nhi0O81bMvXmYTJ+vWLMCY6 1I14gFAgEerBUwZODQq5Wtm8Z1V5b13D7met6WOfehHuu24zzJfq4A10qeBuqL7zOisT vy3X/Bm9eOz9WNwXeq3QYj50BclmLP5AGOdrJuYw5hd69KPCFh0usc3m9fIbzKJ/IuLY rWyB7FqJ1hjelGLfERo1iL0wq2Izf4VWtboGDjQHViudT8pjSv2CRijg4VdNAzuoe1FR KjiQ==; 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=hKlQhgmP; 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 qf14-20020a1709077f0e00b00a4751d6c451si865713ejc.841.2024.04.05.09.16.49; Fri, 05 Apr 2024 09:16:49 -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=hKlQhgmP; 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 0161E68D306; Fri, 5 Apr 2024 19:13:35 +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 990CE68D16F 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=hKlQhgmP; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 5C6214D94 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 aoj45qQXTnOf 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=1712333583; bh=2pa/BEwfIKh28kAJD1+r9MRGq1s4pLX9WKB/FxXmQ7w=; h=From:To:Subject:Date:In-Reply-To:References:From; b=hKlQhgmPMkbIrb6+z1mb8vHf2Uv8kew9gO97ZyDqr3ddgtDxmyLoOXjUyu4OrbHoR m1NhvR7InUzhbzKalTZck9yy2mpOWkkotEyCjPw+ZRaWehKUjyPlYF0e/eo5YKb8TQ xXARyWvDFkn+zfJpKN8PmFQfiDHMYBr0dnt5L3vg6VC55VGNMUTj1RuCNO20uHTL0/ g2yaqg2qU0e7qgAzJlm2VnV5L/HjR3BVWA+twADJ0i5m5salQ+SeMc1lUnFHL7chxq sRc1gXHslu5dT3Fqjz7iyt5sB7HGZ1v08W424p8pavBJNo7BGLpYVl00NUn6+rovJx a0Zki6vz/a36Q== 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 E17D54D98 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 DF0023A19F5 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:12 +0200 Message-ID: <20240405161212.26167-31-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 31/31] doc/ffmpeg: document that there can be multiple complex filtergraphs 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: oQlW5dIikFvs --- doc/ffmpeg.texi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 9bd548ce4e..e996ab945f 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -2143,7 +2143,8 @@ Define a complex filtergraph, i.e. one with arbitrary number of inputs and/or outputs. For simple graphs -- those with one input and one output of the same type -- see the @option{-filter} options. @var{filtergraph} is a description of the filtergraph, as described in the ``Filtergraph syntax'' section of the -ffmpeg-filters manual. +ffmpeg-filters manual. This option may be specified multiple times - each use +creates a new complex filtergraph. Inputs to a complex filtergraph may come from different source types, distinguished by the format of the corresponding link label: