From patchwork Wed Apr 19 19:52:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41256 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp743658pzb; Wed, 19 Apr 2023 12:53:23 -0700 (PDT) X-Google-Smtp-Source: AKy350YpL1BZoizeKoouKrED4hQ1rnlMcIy/5S4UDfhWC9zN2KRu4+MvhYuDlbEDn/xRxthhDsG5 X-Received: by 2002:aa7:c916:0:b0:506:8d35:40b7 with SMTP id b22-20020aa7c916000000b005068d3540b7mr7077789edt.8.1681934003047; Wed, 19 Apr 2023 12:53:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681934003; cv=none; d=google.com; s=arc-20160816; b=g11mN8t/2fI/8xx4qNL/gVUViMd7IPcEvxZUdtYke75rk93qkr4JMsjtchUx/87Xqc MYA8cGzHyhBblbSUqwsqWkNGUsj/CY8gI02LYNtrVy1S4HUHdCj0C5umzpjxFRTnOqqD 4n5KBII+HcsQRG3IUn0fOmVwLletpUnYeuF1J2hM/EBrGRFafHNaxXs5Lgc5DOEts7GN deoEKQsdOc1B6/bLTByI0OjeU5DMJ89Ciao3d2TNAB3uVdhW2nruB7/UuW/Td8NXaf3n q6d6RdMaPwQ1auVEB0aXWCmk0F+NlcB8nIoOXhiNtDU0jOx+IH0rgTbA+q+IX4pXvv3W uB3w== 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 :delivered-to; bh=aejQHnXo/5zIEyfCisASO0GxDCA3bZt7IyTZznG9GGg=; b=QvzCvPEo2+xPN4w/E/bhXC8pJBVdM6DFPBnfshps8EXHdxjR2grTcaPlFKHolBxJZU Nzs3LDF9BOrdl64d0nC+HCkcGMineGupUZpuurExKuvQQOkdaz+m0epaIsT+Cu4wvzyj b/pbgsrSTCxgXgrNcxzrVz/72yvYCEZeLk6Zk35/G4UObwfAOiqseEhT0xE5CjFLEURr jtRNB+oWkRPgezSxGWFXWycEnjCKmP9Z7X+dv9LONiOL7Di8vc424w5WkZH6WQDxEsUX peCd7tqQtrmloR5UyXwJddE+/k7diOS4mUotUAH6GlA/FKcT9OmYlyyKYvozB+mSHauF Zlew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id l11-20020aa7c3cb000000b00506a3c698dbsi8379040edr.376.2023.04.19.12.53.22; Wed, 19 Apr 2023 12:53: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; 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 15D8E68BEB6; Wed, 19 Apr 2023 22:53:07 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EAC1C68BE76 for ; Wed, 19 Apr 2023 22:52:57 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 9A6D82404F5 for ; Wed, 19 Apr 2023 21:52:57 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id nRWMZpfsO2NB for ; Wed, 19 Apr 2023 21:52:55 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id C6FFF2404EC for ; Wed, 19 Apr 2023 21:52:55 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 5241C3A037D for ; Wed, 19 Apr 2023 21:52:55 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Apr 2023 21:52:19 +0200 Message-Id: <20230419195243.2974-1-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/25] fftools/ffmpeg_filter: drop write-only FilterGraph.reconfiguration 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: gWCFgU5eYINV --- fftools/ffmpeg.h | 1 - fftools/ffmpeg_filter.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index a9302a95f0..72020c8f3a 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -325,7 +325,6 @@ typedef struct FilterGraph { const char *graph_desc; AVFilterGraph *graph; - int reconfiguration; // true when the filtergraph contains only meta filters // that do not modify the frame data int is_meta; diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 1d88d2e3b1..52a5d19351 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1239,8 +1239,6 @@ int configure_filtergraph(FilterGraph *fg) goto fail; } - fg->reconfiguration = 1; - for (i = 0; i < fg->nb_inputs; i++) { AVFrame *tmp; while (av_fifo_read(fg->inputs[i]->frame_queue, &tmp, 1) >= 0) { From patchwork Wed Apr 19 19:52:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41255 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp743599pzb; Wed, 19 Apr 2023 12:53:13 -0700 (PDT) X-Google-Smtp-Source: AKy350ZtvYDbghYrcHAA118iw25enS3QOo7oT+gjPxgYF2g/K3IkTfrLLg1wEBgl544XIPCDcs0B X-Received: by 2002:a17:906:2797:b0:953:483e:93f8 with SMTP id j23-20020a170906279700b00953483e93f8mr3504007ejc.16.1681933993778; Wed, 19 Apr 2023 12:53:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681933993; cv=none; d=google.com; s=arc-20160816; b=uQkmVUbjREXA7GvANN4uIcE4RAuRvaZ9+TjfJ8+dvXqz9UCd2lp5FYPR3f+1LbPrgB HB8hJ3PMZEE5Qq5q8uyyhbeeGx2Pzo8yOfH/oMthpkc4w6lhh7NYlhvpIzNOwEeeL3VH wpfQ+hHe/M472NyZJDd/AEsqzQBqIgoHYWzGCCVPpMJAQmzXK+X63GH0UH9i56/2mbuC DcxJwiQZnNgiWtIJHQYd/6+WB7UvLNxC7lVDSGbNIwI0R9Sm9szPo7ApUdB78pE8h/6O QqSXJa5sHggwouHY1HfWo3XwJQKdZHv3vTTIL81bZ1zcf4hZoCJBeg0AV7qCMRixyYUL EtrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=gjge/TkcyWC4klfzqYUZrgIOE1kBrvwIBA/WLj7Wd00=; b=r0mY6vUhyCcP+AsQm1au9MTOpAjMbwKaln/+Otc3NViVpTYJ5EMtefVKUUBBrDWFR2 FA1IdUUpaRQ+d8rzB1GIH6Cx9ieESGlxA12W4NupF82WfRlZKUNgdg9rh7zhgPyWJI9m WB416K/uTJRE91YRnVp/PiTvWDfwLM0s+FSoKF5fr2P10IPALWKvtzPp/eo2+vy7GsSl sslrB6XsxBbKUNxp3LokqgVFprIW715VtClLxUlMwNjd0tqBMROYKX8ywNfgTGL/f1aj HM7IevIlWVSlxaDk4Yd5m/sBlc4vReSbEalYVJBtnRLFHTZL5jQKRpI+j9xlgJ6HHvad iCew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id g17-20020aa7c851000000b00506af240bb1si5884042edt.657.2023.04.19.12.53.13; Wed, 19 Apr 2023 12:53:13 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 63EC168BE77; Wed, 19 Apr 2023 22:53:04 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4946168BE67 for ; Wed, 19 Apr 2023 22:52:57 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id E7188240D20 for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id zHy8JYkRBv-C for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id CFFA12404F5 for ; Wed, 19 Apr 2023 21:52:55 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 5F6593A0787 for ; Wed, 19 Apr 2023 21:52:55 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Apr 2023 21:52:20 +0200 Message-Id: <20230419195243.2974-2-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230419195243.2974-1-anton@khirnov.net> References: <20230419195243.2974-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 02/25] fftools/ffmpeg_filter: drop unused AUTO_INSERT_FILTER_INPUT() 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: 78pTArZQ2sri --- fftools/ffmpeg_filter.c | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 52a5d19351..ea182089b1 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1035,27 +1035,6 @@ static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter, return ret; last_filter = ifilter->filter; -#define AUTO_INSERT_FILTER_INPUT(opt_name, filter_name, arg) do { \ - AVFilterContext *filt_ctx; \ - \ - av_log(NULL, AV_LOG_INFO, opt_name " is forwarded to lavfi " \ - "similarly to -af " filter_name "=%s.\n", arg); \ - \ - snprintf(name, sizeof(name), "graph_%d_%s_in_%d_%d", \ - fg->index, filter_name, ist->file_index, ist->st->index); \ - ret = avfilter_graph_create_filter(&filt_ctx, \ - avfilter_get_by_name(filter_name), \ - name, arg, NULL, fg->graph); \ - if (ret < 0) \ - return ret; \ - \ - ret = avfilter_link(last_filter, 0, filt_ctx, 0); \ - if (ret < 0) \ - return ret; \ - \ - last_filter = filt_ctx; \ -} while (0) - snprintf(name, sizeof(name), "trim for input stream %d:%d", ist->file_index, ist->st->index); if (copy_ts) { From patchwork Wed Apr 19 19:52:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41254 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp743528pzb; Wed, 19 Apr 2023 12:53:05 -0700 (PDT) X-Google-Smtp-Source: AKy350ZIiIBqQkS3aXONxSTuqnsgWQ0PbsRoIo5++SoQFDIb7DQF0iayoCIuquWUn7xxKDx8jroV X-Received: by 2002:a17:906:3753:b0:94f:432f:243f with SMTP id e19-20020a170906375300b0094f432f243fmr12210559ejc.13.1681933985138; Wed, 19 Apr 2023 12:53:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681933985; cv=none; d=google.com; s=arc-20160816; b=SwU4kUzGGi6QGpli1hjvE9sHlj2UOYWrHHX7ywJ6FTMyanXO1sb0vTJLOFME6Kk5o3 de6zaZPYjSmOtjYFgoMcQKxl8n9RvKYicTE99DNlOOkMWG5zbWK7eKqm9RNFvAdl+WQ7 K7cb027K5NUqLz+1SzyQs9Yh9mpdHv2uHSdOUrJBPjl97dTzZQ6xPFhdcjcsVjBxd58+ A8sCBbl4v6Hgf/bYA0Aeg8lrPx7/BsGXFfwfFpjY14sMeOFgwh3vHYvcOLR5Yj+mZri9 gomFPaPLcrCIsFGLnculTdZ3UqiH9vLZSn+KS/DbXKh02DToKg9khWQdccAaBE29aHqt f61A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=+FhGgOiglULDvDlX073ih+5AqnVTRckc9ytwS9/P0jg=; b=0zQ6qMIYvqriMnLIvE9DXElIsfP44q9HCcz9Murlzs2dpUCsLRegpN72DBFF8LN2HV ZovQ+iEb+5mbDrHXuaWel+eGHoNEH6TaYUVc1iMsp5SCiEsvI6dNBobecp1z3R25FEE8 Y2Xn6O2M/Zci213iQ6xQ6v2AehOt46T62OzKbNzetMnxVByRGif/Y+6KPS6BP4VUvMV1 EZqV7dDooYlFIr3lKjp1RZubNZxYjMT7TBLRNYRO+g4g20IDQ9zzaGcTqSFa61WoUqr7 C2DiEAy9smqqI9ySesOs5sSmqQRvGH7reh0nYb48m+bcu9nOONZqIqJQNovh74r5C0lf gKwg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id c1-20020aa7c981000000b0050670df5fdbsi16326760edt.434.2023.04.19.12.53.04; Wed, 19 Apr 2023 12:53: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; 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 74BBC68BE67; Wed, 19 Apr 2023 22:53:02 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 96DDA68BE56 for ; Wed, 19 Apr 2023 22:52:56 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 469C02406CF for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id k_j-m_DtvkgU for ; Wed, 19 Apr 2023 21:52:55 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id CDA772404EE for ; Wed, 19 Apr 2023 21:52:55 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 6A9EF3A07C2 for ; Wed, 19 Apr 2023 21:52:55 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Apr 2023 21:52:21 +0200 Message-Id: <20230419195243.2974-3-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230419195243.2974-1-anton@khirnov.net> References: <20230419195243.2974-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 03/25] lavfi/avf_concat: rescale frame durations 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: 2r1IQ3zBm2DR --- libavfilter/avf_concat.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavfilter/avf_concat.c b/libavfilter/avf_concat.c index c85c17b51f..af758c5292 100644 --- a/libavfilter/avf_concat.c +++ b/libavfilter/avf_concat.c @@ -179,6 +179,7 @@ static int push_frame(AVFilterContext *ctx, unsigned in_no, AVFrame *buf) struct concat_in *in = &cat->in[in_no]; buf->pts = av_rescale_q(buf->pts, inlink->time_base, outlink->time_base); + buf->duration = av_rescale_q(buf->duration, inlink->time_base, outlink->time_base); in->pts = buf->pts; in->nb_frames++; /* add duration to input PTS */ From patchwork Wed Apr 19 19:52:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41257 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp743736pzb; Wed, 19 Apr 2023 12:53:32 -0700 (PDT) X-Google-Smtp-Source: AKy350Z80kY4EsX8ZAgGYwWpSKk/U49Co/4hYPNTFWjPKL+W8JwPfeSq2o4S/POq5ny40z3RhPHU X-Received: by 2002:a17:907:212f:b0:953:3e29:f35c with SMTP id qo15-20020a170907212f00b009533e29f35cmr5332250ejb.45.1681934012558; Wed, 19 Apr 2023 12:53:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681934012; cv=none; d=google.com; s=arc-20160816; b=aexBAHMoiMrdnP3LnRwccu3ZjRAxWXbFDdBZrF9j8HPY8xs7zU+2+K79pVs+uaOtjy 52LOVf//VCgUFYLFltLtqhpnEGj0gGymjxoAUQu1ky3WgcdzWxJtgjBbwOe1lQJkGC+N TtMuqVtY8t/u963vV/jMWVr9hQ2kFxxXmUfn0RqWimtBZqICzt68d48AKa1KLsPKxZ0K qgsW9FmgfpeU6HIjmlyzjcLBT/Sm/wGrTTlK7TW5nTSlU7HohV01RSW/Et5GT1kihiW7 e7YE1vncEsgv/X3JuFQhjRdrEoBWglNO3CsAdujdBauKDdicIeO+DVJ3qP4173Fdk46p vF7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=S0lxvfk1/Gkus6NrKgTAttmge/lVbB2cOniake5uGBI=; b=eam2NKknJ3qGq2R4HKv0sM9GfRmIY7OsuYm6BnIgxVjtOlshGvgsk9i2G3Hwpz+K9P b7RWKM5WmHwpuRBJNOfzZq3eIzUC8cW8PThxsUX6aOvrLSbTVWHgNAEUDVbNuThajrH4 YXiueMJHPLowCSLYM+tAZbtVURXSPcKd83PNficYsF1D0B1gEFpNFsITWpL15b0/EbQx LALzwUJQEdl1nvHNkXWLzreIkZjn+cIXEQURW/3nEoRFLBQv7V1aHFmm8ClurMtWG3IO e49ZkSkwqVXnwjN/GrC3BL8U2WGitCwGVQZJiAMMxY7SBdacOJFdFURHIoJCg4a/40Jb AYpQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id vs2-20020a170907138200b0094f0742ad02si1905781ejb.761.2023.04.19.12.53.32; Wed, 19 Apr 2023 12:53:32 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 314D068BEE9; Wed, 19 Apr 2023 22:53:08 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 93D5B68BE69 for ; Wed, 19 Apr 2023 22:52:58 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 39A382404EC for ; Wed, 19 Apr 2023 21:52:58 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id b85K6yLGdGtg for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id D3CA32404F8 for ; Wed, 19 Apr 2023 21:52:55 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 769B73A07F8 for ; Wed, 19 Apr 2023 21:52:55 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Apr 2023 21:52:22 +0200 Message-Id: <20230419195243.2974-4-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230419195243.2974-1-anton@khirnov.net> References: <20230419195243.2974-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/25] fftools/ffmpeg_enc: always use video frame durations when available 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: 5idj1+dFDfaj Previously they would only be used with trivial filtergraphs, because filters did not handle frame durations. That is no longer true - most filters process frame durations properly (there may still be some that don't - this change will help finding and fixing them). Improves output video frame durations in a number of FATE tests. --- fftools/ffmpeg_enc.c | 19 +++----- tests/ref/fate/filter-concat-vfr | 66 +++++++++++++------------- tests/ref/fate/gif-disposal-restore | 2 +- tests/ref/fate/gif-gray | 72 ++++++++++++++--------------- tests/ref/fate/quickdraw | 2 +- 5 files changed, 77 insertions(+), 84 deletions(-) diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index e3dc858bc3..9aaec277f1 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -1005,24 +1005,17 @@ static void do_video_out(OutputFile *of, AVRational frame_rate; int64_t nb_frames, nb_frames_prev, i; double duration = 0; - InputStream *ist = ost->ist; AVFilterContext *filter = ost->filter->filter; - frame_rate = av_buffersink_get_frame_rate(filter); - if (frame_rate.num > 0 && frame_rate.den > 0) - duration = 1/(av_q2d(frame_rate) * av_q2d(enc->time_base)); + if (next_picture) + duration = lrintf(next_picture->duration * av_q2d(next_picture->time_base) / av_q2d(enc->time_base)); - if(ist && ist->st->start_time != AV_NOPTS_VALUE && ist->first_dts != AV_NOPTS_VALUE && ost->frame_rate.num) + if (duration <= 0 && ost->frame_rate.num) duration = FFMIN(duration, 1/(av_q2d(ost->frame_rate) * av_q2d(enc->time_base))); - if (!ost->filters_script && - !ost->filters && - (nb_filtergraphs == 0 || !filtergraphs[0]->graph_desc) && - next_picture && - ist && - lrintf(next_picture->duration * av_q2d(ist->st->time_base) / av_q2d(enc->time_base)) > 0) { - duration = lrintf(next_picture->duration * av_q2d(ist->st->time_base) / av_q2d(enc->time_base)); - } + frame_rate = av_buffersink_get_frame_rate(filter); + if (duration <= 0 && frame_rate.num > 0 && frame_rate.den > 0) + duration = 1/(av_q2d(frame_rate) * av_q2d(enc->time_base)); if (!next_picture) { //end, flushing diff --git a/tests/ref/fate/filter-concat-vfr b/tests/ref/fate/filter-concat-vfr index 7c5e12e093..66e9007da8 100644 --- a/tests/ref/fate/filter-concat-vfr +++ b/tests/ref/fate/filter-concat-vfr @@ -8,7 +8,7 @@ #codec_id 1: pcm_s16le #sample_rate 1: 44100 #channel_layout_name 1: mono -0, 0, 0, 0, 230400, 0x88c4d19a +0, 0, 0, 199999, 230400, 0x88c4d19a 1, 0, 0, 1024, 2048, 0xb3f10192 1, 1024, 1024, 1024, 2048, 0xb340fe4e 1, 2048, 2048, 1024, 2048, 0x0a5f0111 @@ -18,7 +18,7 @@ 1, 6144, 6144, 1024, 2048, 0x70a8fa17 1, 7168, 7168, 1024, 2048, 0x0dad072a 1, 8192, 8192, 1024, 2048, 0x5e810c51 -0, 200000, 200000, 0, 230400, 0x0d77c977 +0, 200000, 200000, 200000, 230400, 0x0d77c977 1, 9216, 9216, 1024, 2048, 0xbe5bf462 1, 10240, 10240, 1024, 2048, 0xbcd9faeb 1, 11264, 11264, 1024, 2048, 0x0d5bfe9c @@ -28,7 +28,7 @@ 1, 15360, 15360, 1024, 2048, 0x11a9fa03 1, 16384, 16384, 1024, 2048, 0x9a920378 1, 17408, 17408, 1024, 2048, 0x901b0525 -0, 400000, 400000, 0, 230400, 0x242629d7 +0, 400000, 400000, 200000, 230400, 0x242629d7 1, 18432, 18432, 1024, 2048, 0x74b2003f 1, 19456, 19456, 1024, 2048, 0xa20ef3ed 1, 20480, 20480, 1024, 2048, 0x44cef9de @@ -37,7 +37,7 @@ 1, 23552, 23552, 1024, 2048, 0xcab6f9e5 1, 24576, 24576, 1024, 2048, 0x67f8f608 1, 25600, 25600, 1024, 2048, 0x8d7f03fa -0, 600000, 600000, 0, 230400, 0x62cdc018 +0, 600000, 600000, 200000, 230400, 0x62cdc018 1, 26624, 26624, 1024, 2048, 0x3e1e0566 1, 27648, 27648, 1024, 2048, 0x2cfe0308 1, 28672, 28672, 1024, 2048, 0x1ceaf702 @@ -47,7 +47,7 @@ 1, 32768, 32768, 1024, 2048, 0x3e5afa28 1, 33792, 33792, 1024, 2048, 0x053ff47a 1, 34816, 34816, 1024, 2048, 0x0d28fed9 -0, 800000, 800000, 0, 230400, 0x248ad058 +0, 800000, 800000, 200000, 230400, 0x248ad058 1, 35840, 35840, 1024, 2048, 0x279805cc 1, 36864, 36864, 1024, 2048, 0xb16a0a12 1, 37888, 37888, 1024, 2048, 0xb45af340 @@ -57,72 +57,72 @@ 1, 41984, 41984, 1024, 2048, 0x503800ce 1, 43008, 43008, 1024, 2048, 0xa3bbf4af 1, 44032, 44032, 68, 136, 0xc8d751c7 -0, 1000000, 1000000, 0, 230400, 0x223d134f +0, 1000000, 1000000, 200000, 230400, 0x223d134f 1, 44100, 44100, 9600, 19200, 0x00000000 -0, 1200000, 1200000, 0, 230400, 0xbf1c3d34 +0, 1200000, 1200000, 200000, 230400, 0xbf1c3d34 1, 53700, 53700, 9600, 19200, 0x00000000 -0, 1400000, 1400000, 0, 230400, 0xae0efe96 +0, 1400000, 1400000, 200000, 230400, 0xae0efe96 1, 63300, 63300, 9600, 19200, 0x00000000 -0, 1600000, 1600000, 0, 230400, 0x0cd624d1 +0, 1600000, 1600000, 200000, 230400, 0x0cd624d1 1, 72900, 72900, 9600, 19200, 0x00000000 -0, 1800000, 1800000, 0, 230400, 0x6dedf2c0 +0, 1800000, 1800000, 200000, 230400, 0x6dedf2c0 1, 82500, 82500, 5700, 11400, 0x00000000 -0, 2000000, 2000000, 0, 230400, 0x88c4d19a +0, 2000000, 2000000, 66667, 230400, 0x88c4d19a 1, 88200, 88200, 1024, 2048, 0x283efb3a 1, 89224, 89224, 1024, 2048, 0x7692fb8f 1, 90248, 90248, 1024, 2048, 0xbaaafcc0 -0, 2066667, 2066667, 0, 230400, 0x5bbc2f63 +0, 2066667, 2066667, 66667, 230400, 0x5bbc2f63 1, 91272, 91272, 1024, 2048, 0xadc8017e 1, 92296, 92296, 1024, 2048, 0x4f4dffdc 1, 93320, 93320, 1024, 2048, 0x7ffbff48 -0, 2133333, 2133333, 0, 230400, 0x3becbfad +0, 2133333, 2133333, 66667, 230400, 0x3becbfad 1, 94344, 94344, 1024, 2048, 0x2f990719 1, 95368, 95368, 1024, 2048, 0xe2caf65c 1, 96392, 96392, 1024, 2048, 0x825208e4 -0, 2200000, 2200000, 0, 230400, 0x0d77c977 +0, 2200000, 2200000, 66667, 230400, 0x0d77c977 1, 97416, 97416, 1024, 2048, 0xf563f13b 1, 98440, 98440, 1024, 2048, 0x855d03e9 1, 99464, 99464, 1024, 2048, 0x0ba9fa4b -0, 2266667, 2266667, 0, 230400, 0x436cf4b2 +0, 2266667, 2266667, 66667, 230400, 0x436cf4b2 1, 100488, 100488, 1024, 2048, 0x83e1fb92 1, 101512, 101512, 1024, 2048, 0x1162f965 1, 102536, 102536, 1024, 2048, 0x0cfef73d -0, 2333333, 2333333, 0, 230400, 0x39210f27 +0, 2333333, 2333333, 66667, 230400, 0x39210f27 1, 103560, 103560, 1024, 2048, 0x5688ff75 1, 104584, 104584, 1024, 2048, 0xf6c0ede9 1, 105608, 105608, 1024, 2048, 0xfdb20602 -0, 2400000, 2400000, 0, 230400, 0x242629d7 +0, 2400000, 2400000, 66667, 230400, 0x242629d7 1, 106632, 106632, 1024, 2048, 0x40c5f17b 1, 107656, 107656, 1024, 2048, 0x559600b1 1, 108680, 108680, 1024, 2048, 0xccc3f930 -0, 2466667, 2466667, 0, 230400, 0x771c2293 +0, 2466667, 2466667, 66667, 230400, 0x771c2293 1, 109704, 109704, 1024, 2048, 0xdc800045 1, 110728, 110728, 1024, 2048, 0xdce4fb3e -0, 2533333, 2533333, 0, 230400, 0xec2af9a9 +0, 2533333, 2533333, 66667, 230400, 0xec2af9a9 1, 111752, 111752, 1024, 2048, 0x1e5efba9 1, 112776, 112776, 1024, 2048, 0x8c2e0832 1, 113800, 113800, 1024, 2048, 0x5c42f66d -0, 2600000, 2600000, 0, 230400, 0x62cdc018 +0, 2600000, 2600000, 66667, 230400, 0x62cdc018 1, 114824, 114824, 1024, 2048, 0x08e20b1e 1, 115848, 115848, 1024, 2048, 0x4cf7f903 1, 116872, 116872, 1024, 2048, 0xe6b90794 -0, 2666667, 2666667, 0, 230400, 0xf02c8693 +0, 2666667, 2666667, 66667, 230400, 0xf02c8693 1, 117896, 117896, 1024, 2048, 0x5956f8e6 1, 118920, 118920, 1024, 2048, 0x6632ff16 1, 119944, 119944, 1024, 2048, 0x46c8fe11 -0, 2733333, 2733333, 0, 230400, 0x14436efb +0, 2733333, 2733333, 66667, 230400, 0x14436efb 1, 120968, 120968, 1024, 2048, 0x7431f732 1, 121992, 121992, 1024, 2048, 0xa258049f 1, 123016, 123016, 1024, 2048, 0xdb71f00e -0, 2800000, 2800000, 0, 230400, 0x248ad058 +0, 2800000, 2800000, 66667, 230400, 0x248ad058 1, 124040, 124040, 1024, 2048, 0xa89b0359 1, 125064, 125064, 1024, 2048, 0xe0aff0f2 1, 126088, 126088, 1024, 2048, 0xc33e0085 -0, 2866667, 2866667, 0, 230400, 0xe87f6c52 +0, 2866667, 2866667, 66667, 230400, 0xe87f6c52 1, 127112, 127112, 1024, 2048, 0x9d09f379 1, 128136, 128136, 1024, 2048, 0x8c78fd06 1, 129160, 129160, 1024, 2048, 0x532bfbdd -0, 2933333, 2933333, 0, 230400, 0x6a0c196b +0, 2933333, 2933333, 66667, 230400, 0x6a0c196b 1, 130184, 130184, 1024, 2048, 0xfc36f5cd 1, 131208, 131208, 1024, 2048, 0x2e8f0699 1, 132232, 132232, 1024, 2048, 0x52382578 @@ -169,52 +169,52 @@ 1, 174216, 174216, 1024, 2048, 0xf86ff855 1, 175240, 175240, 1024, 2048, 0x6934061b 1, 176264, 176264, 136, 272, 0x4a458a45 -0, 4000000, 4000000, 0, 230400, 0x88c4d19a +0, 4000000, 4000000, 125000, 230400, 0x88c4d19a 1, 176400, 176400, 1024, 2048, 0xdb0cfe95 1, 177424, 177424, 1024, 2048, 0xcff3fdf1 1, 178448, 178448, 1024, 2048, 0x070cf585 1, 179472, 179472, 1024, 2048, 0xe9b8007f 1, 180496, 180496, 1024, 2048, 0xc51ffd64 1, 181520, 181520, 1024, 2048, 0xede2fbf9 -0, 4125000, 4125000, 0, 230400, 0x05c1b733 +0, 4125000, 4125000, 125000, 230400, 0x05c1b733 1, 182544, 182544, 1024, 2048, 0x51510410 1, 183568, 183568, 1024, 2048, 0x198af498 1, 184592, 184592, 1024, 2048, 0xae3603a2 1, 185616, 185616, 1024, 2048, 0x6200f7a1 1, 186640, 186640, 1024, 2048, 0xe6e3fe32 -0, 4250000, 4250000, 0, 230400, 0x0446ec19 +0, 4250000, 4250000, 125000, 230400, 0x0446ec19 1, 187664, 187664, 1024, 2048, 0xb2e2fd77 1, 188688, 188688, 1024, 2048, 0x063dff2f 1, 189712, 189712, 1024, 2048, 0xa89ffe21 1, 190736, 190736, 1024, 2048, 0x9e6ffa6d 1, 191760, 191760, 1024, 2048, 0x028b004e 1, 192784, 192784, 1024, 2048, 0x57edfa23 -0, 4375000, 4375000, 0, 230400, 0x0f9b1744 +0, 4375000, 4375000, 125000, 230400, 0x0f9b1744 1, 193808, 193808, 1024, 2048, 0x6d8efe1f 1, 194832, 194832, 1024, 2048, 0x774bfe54 1, 195856, 195856, 1024, 2048, 0xa931fcfb 1, 196880, 196880, 1024, 2048, 0x3505004b 1, 197904, 197904, 1024, 2048, 0x5001f576 -0, 4500000, 4500000, 0, 230400, 0x30cf070a +0, 4500000, 4500000, 125000, 230400, 0x30cf070a 1, 198928, 198928, 1024, 2048, 0x78ea049b 1, 199952, 199952, 1024, 2048, 0xd45bf733 1, 200976, 200976, 1024, 2048, 0x6395fead 1, 202000, 202000, 1024, 2048, 0xc126015e 1, 203024, 203024, 1024, 2048, 0xbecff8aa -0, 4625000, 4625000, 0, 230400, 0x9175aaa9 +0, 4625000, 4625000, 125000, 230400, 0x9175aaa9 1, 204048, 204048, 1024, 2048, 0x0fea06c3 1, 205072, 205072, 1024, 2048, 0xdea6f351 1, 206096, 206096, 1024, 2048, 0x35b808f0 1, 207120, 207120, 1024, 2048, 0x5487ee73 1, 208144, 208144, 1024, 2048, 0xac69050e 1, 209168, 209168, 1024, 2048, 0xcc5ffb00 -0, 4750000, 4750000, 0, 230400, 0x597f5628 +0, 4750000, 4750000, 125000, 230400, 0x597f5628 1, 210192, 210192, 1024, 2048, 0x328c00cb 1, 211216, 211216, 1024, 2048, 0xa707fd82 1, 212240, 212240, 1024, 2048, 0xe442f73d 1, 213264, 213264, 1024, 2048, 0x545c0418 1, 214288, 214288, 1024, 2048, 0x744ff3f7 -0, 4875000, 4875000, 0, 230400, 0x38a45a85 +0, 4875000, 4875000, 125000, 230400, 0x38a45a85 1, 215312, 215312, 1024, 2048, 0x01aa04fd 1, 216336, 216336, 1024, 2048, 0xa885f7cd 1, 217360, 217360, 1024, 2048, 0xcfca04f4 diff --git a/tests/ref/fate/gif-disposal-restore b/tests/ref/fate/gif-disposal-restore index b1282f61de..aca80c5e6d 100644 --- a/tests/ref/fate/gif-disposal-restore +++ b/tests/ref/fate/gif-disposal-restore @@ -4,5 +4,5 @@ #dimensions 0: 468x60 #sar 0: 0/1 0, 0, 0, 1, 112320, 0xb8afe429 -0, 1, 1, 1, 112320, 0xae588a4b +0, 1, 1, 2, 112320, 0xae588a4b 0, 3, 3, 1, 112320, 0xccdd27b7 diff --git a/tests/ref/fate/gif-gray b/tests/ref/fate/gif-gray index 18705d01fe..aa3969212d 100644 --- a/tests/ref/fate/gif-gray +++ b/tests/ref/fate/gif-gray @@ -3,39 +3,39 @@ #codec_id 0: rawvideo #dimensions 0: 480x360 #sar 0: 0/1 -0, 0, 0, 1, 691200, 0xef6c0f3d -0, 5, 5, 1, 691200, 0xc18b32de -0, 7, 7, 1, 691200, 0x2395a3d7 -0, 9, 9, 1, 691200, 0x81dc3cf2 -0, 11, 11, 1, 691200, 0xabe2390e -0, 13, 13, 1, 691200, 0xb2955c2a -0, 15, 15, 1, 691200, 0x868d9ca2 -0, 17, 17, 1, 691200, 0x3016c2b6 -0, 19, 19, 1, 691200, 0x4501cffa -0, 21, 21, 1, 691200, 0x8661d79e -0, 25, 25, 1, 691200, 0xbc96d02e -0, 27, 27, 1, 691200, 0x5f90bf5e -0, 29, 29, 1, 691200, 0xf18da09a -0, 31, 31, 1, 691200, 0x540467ce -0, 33, 33, 1, 691200, 0x60d24012 -0, 35, 35, 1, 691200, 0x24323d36 -0, 37, 37, 1, 691200, 0x9e07c84b -0, 39, 39, 1, 691200, 0xc18b32de -0, 41, 41, 1, 691200, 0xef6c0f3d -0, 46, 46, 1, 691200, 0xc9461045 -0, 48, 48, 1, 691200, 0x23ed4b99 -0, 50, 50, 1, 691200, 0x7e351d69 -0, 52, 52, 1, 691200, 0x0513e0aa -0, 54, 54, 1, 691200, 0x28a4b6f2 -0, 56, 56, 1, 691200, 0xce10a94e -0, 58, 58, 1, 691200, 0x63929d4e -0, 60, 60, 1, 691200, 0xd26c9bb6 -0, 62, 62, 1, 691200, 0xb2a29842 -0, 66, 66, 1, 691200, 0x9fd69a16 -0, 68, 68, 1, 691200, 0x10f99e46 -0, 70, 70, 1, 691200, 0xea95a9fa -0, 72, 72, 1, 691200, 0x97dbb9d6 -0, 74, 74, 1, 691200, 0xf4e9e2d6 -0, 76, 76, 1, 691200, 0x46b1230d -0, 78, 78, 1, 691200, 0xb4a54ccd -0, 80, 80, 1, 691200, 0x40cc103d +0, 0, 0, 4, 691200, 0xef6c0f3d +0, 5, 5, 2, 691200, 0xc18b32de +0, 7, 7, 2, 691200, 0x2395a3d7 +0, 9, 9, 2, 691200, 0x81dc3cf2 +0, 11, 11, 2, 691200, 0xabe2390e +0, 13, 13, 2, 691200, 0xb2955c2a +0, 15, 15, 2, 691200, 0x868d9ca2 +0, 17, 17, 2, 691200, 0x3016c2b6 +0, 19, 19, 2, 691200, 0x4501cffa +0, 21, 21, 4, 691200, 0x8661d79e +0, 25, 25, 2, 691200, 0xbc96d02e +0, 27, 27, 2, 691200, 0x5f90bf5e +0, 29, 29, 2, 691200, 0xf18da09a +0, 31, 31, 2, 691200, 0x540467ce +0, 33, 33, 2, 691200, 0x60d24012 +0, 35, 35, 2, 691200, 0x24323d36 +0, 37, 37, 2, 691200, 0x9e07c84b +0, 39, 39, 2, 691200, 0xc18b32de +0, 41, 41, 5, 691200, 0xef6c0f3d +0, 46, 46, 2, 691200, 0xc9461045 +0, 48, 48, 2, 691200, 0x23ed4b99 +0, 50, 50, 2, 691200, 0x7e351d69 +0, 52, 52, 2, 691200, 0x0513e0aa +0, 54, 54, 2, 691200, 0x28a4b6f2 +0, 56, 56, 2, 691200, 0xce10a94e +0, 58, 58, 2, 691200, 0x63929d4e +0, 60, 60, 2, 691200, 0xd26c9bb6 +0, 62, 62, 4, 691200, 0xb2a29842 +0, 66, 66, 2, 691200, 0x9fd69a16 +0, 68, 68, 2, 691200, 0x10f99e46 +0, 70, 70, 2, 691200, 0xea95a9fa +0, 72, 72, 2, 691200, 0x97dbb9d6 +0, 74, 74, 2, 691200, 0xf4e9e2d6 +0, 76, 76, 2, 691200, 0x46b1230d +0, 78, 78, 2, 691200, 0xb4a54ccd +0, 80, 80, 2, 691200, 0x40cc103d diff --git a/tests/ref/fate/quickdraw b/tests/ref/fate/quickdraw index 5746929502..44610498c8 100644 --- a/tests/ref/fate/quickdraw +++ b/tests/ref/fate/quickdraw @@ -9,7 +9,7 @@ 0, 3, 3, 1, 921600, 0xc0e68764 0, 4, 4, 1, 921600, 0xc0e68764 0, 5, 5, 1, 921600, 0xc0e68764 -0, 7, 7, 1, 921600, 0x01a16629 +0, 7, 7, 2, 921600, 0x01a16629 0, 9, 9, 1, 921600, 0x01a16629 0, 10, 10, 1, 921600, 0x01a16629 0, 11, 11, 1, 921600, 0x01a16629 From patchwork Wed Apr 19 19:52:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41268 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp744485pzb; Wed, 19 Apr 2023 12:55:12 -0700 (PDT) X-Google-Smtp-Source: AKy350Z3GmvRescp4iWCFIxk+wlZl2rkEeLnQEZlB4DvuDUTJ5ctU4rHDyKnbj6PGEIAwM4ROfq2 X-Received: by 2002:a17:906:3ce9:b0:94a:826c:df57 with SMTP id d9-20020a1709063ce900b0094a826cdf57mr18830073ejh.39.1681934112510; Wed, 19 Apr 2023 12:55:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681934112; cv=none; d=google.com; s=arc-20160816; b=TykENkbRdl/tlpcNbdjz60Oq1BAURCetsXlDrIRkOdIWgefOaju3LyEc0LvIzHaNbs XoWRfIhBxswbrh5v1zg0bMLQylV6qkQl7KGP5f/CMgYfO2QQ3Lrtf0r+Vassa+mL8095 nv2U4BHdw78ciDtIDPRriNSIHza2OBfd5Zx6C+n8aXgnpt1jPFXEbbxEDo4sYypU1D+e gLMQj31+q5nK6mrGE0PN9UXvNLzT3XiQoMM3IfcwCkUYaH9CKfc7eznvtmBdkuTnGYii WRG/NGK0037L4OuKgeI8JunzH1CreIW5c2thHf670igAJqu3EB7eksx3+M+Exj5lD1QR IHHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=2OB06f9xwMMSj1eAtOURjOLkJTT7E8KarapTxHCsyiE=; b=d0UHgrA+cACHqEjYEUo8AjW4ahalhsNbslzLCNM22d9YoAOQUW7mvyHgGQDfCo6mR6 DmQyXKJxAAc6Eshhdzy0kUZe4hr7Ob1JYbyQokeRvdx5HD9jmHfCQB3EIt3N667+irJA W9Grtlp6NmMQRY0Z3qLAUdg8JqNH4niQRtKWO3UTEmqDI7J3ekLI09oij1svhg+QTPIi 5VBm0Q1eMPDM+bzeL/I3M1fjr/ZXzYRKaCGjgLoaH6bXbOXeF8zZa7RMktkmcf+Gpq2p 1gmFCgFG1T+wq4ysToXkOUZFwZcOLXofDUzgTUcuKG8CHeD468lTB7Nyd5RNFlPUEEV+ HWhw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id t19-20020aa7d713000000b00506771c2c64si14111629edq.300.2023.04.19.12.55.11; Wed, 19 Apr 2023 12:55:12 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 43BA268BF58; Wed, 19 Apr 2023 22:53:19 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9E8EC68BEB0 for ; Wed, 19 Apr 2023 22:53:02 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 80CB82405F9 for ; Wed, 19 Apr 2023 21:53:00 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id jYd2iFQ3xqYu for ; Wed, 19 Apr 2023 21:52:57 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id D7709240591 for ; Wed, 19 Apr 2023 21:52:55 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 824613A0D68 for ; Wed, 19 Apr 2023 21:52:55 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Apr 2023 21:52:23 +0200 Message-Id: <20230419195243.2974-5-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230419195243.2974-1-anton@khirnov.net> References: <20230419195243.2974-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 05/25] fftools/ffmpeg_enc: rename next_picture to frame 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: iZ58pH3aJtyH The name is misleading, because it is not a picture in the sense of MPEG terminology (which define "picture" as "frame or field"), but always a full frame. 'next' is also redundant and/or misleading, because it is the _current_ frame to be encoded. --- fftools/ffmpeg_enc.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 9aaec277f1..e63da2ec97 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -873,14 +873,14 @@ early_exit: * desired target framerate (if any). */ static void video_sync_process(OutputFile *of, OutputStream *ost, - AVFrame *next_picture, double duration, + AVFrame *frame, double duration, int64_t *nb_frames, int64_t *nb_frames_prev) { Encoder *e = ost->enc; double delta0, delta; - double sync_ipts = adjust_frame_pts_to_encoder_tb(of, ost, next_picture); - /* delta0 is the "drift" between the input frame (next_picture) and + double sync_ipts = adjust_frame_pts_to_encoder_tb(of, ost, frame); + /* delta0 is the "drift" between the input frame and * where it would fall in the output. */ delta0 = sync_ipts - e->next_pts; delta = delta0 + duration; @@ -923,18 +923,18 @@ static void video_sync_process(OutputFile *of, OutputStream *ost, if (delta0 > 1.1) *nb_frames_prev = llrintf(delta0 - 0.6); } - next_picture->duration = 1; + frame->duration = 1; break; case VSYNC_VFR: if (delta <= -0.6) *nb_frames = 0; else if (delta > 0.6) e->next_pts = llrint(sync_ipts); - next_picture->duration = duration; + frame->duration = duration; break; case VSYNC_DROP: case VSYNC_PASSTHROUGH: - next_picture->duration = duration; + frame->duration = duration; e->next_pts = llrint(sync_ipts); break; default: @@ -994,10 +994,8 @@ force_keyframe: return AV_PICTURE_TYPE_I; } -/* May modify/reset next_picture */ -static void do_video_out(OutputFile *of, - OutputStream *ost, - AVFrame *next_picture) +/* May modify/reset frame */ +static void do_video_out(OutputFile *of, OutputStream *ost, AVFrame *frame) { int ret; Encoder *e = ost->enc; @@ -1007,8 +1005,8 @@ static void do_video_out(OutputFile *of, double duration = 0; AVFilterContext *filter = ost->filter->filter; - if (next_picture) - duration = lrintf(next_picture->duration * av_q2d(next_picture->time_base) / av_q2d(enc->time_base)); + if (frame) + duration = lrintf(frame->duration * av_q2d(frame->time_base) / av_q2d(enc->time_base)); if (duration <= 0 && ost->frame_rate.num) duration = FFMIN(duration, 1/(av_q2d(ost->frame_rate) * av_q2d(enc->time_base))); @@ -1017,13 +1015,13 @@ static void do_video_out(OutputFile *of, if (duration <= 0 && frame_rate.num > 0 && frame_rate.den > 0) duration = 1/(av_q2d(frame_rate) * av_q2d(enc->time_base)); - if (!next_picture) { + if (!frame) { //end, flushing nb_frames_prev = nb_frames = mid_pred(e->frames_prev_hist[0], e->frames_prev_hist[1], e->frames_prev_hist[2]); } else { - video_sync_process(of, ost, next_picture, duration, + video_sync_process(of, ost, frame, duration, &nb_frames, &nb_frames_prev); } @@ -1051,8 +1049,8 @@ static void do_video_out(OutputFile *of, dup_warning *= 10; } } - ost->last_dropped = nb_frames == nb_frames_prev && next_picture; - ost->kf.dropped_keyframe = ost->last_dropped && next_picture && next_picture->key_frame; + ost->last_dropped = nb_frames == nb_frames_prev && frame; + ost->kf.dropped_keyframe = ost->last_dropped && frame && frame->key_frame; /* duplicates frame if needed */ for (i = 0; i < nb_frames; i++) { @@ -1061,7 +1059,7 @@ static void do_video_out(OutputFile *of, if (i < nb_frames_prev && e->last_frame->buf[0]) { in_picture = e->last_frame; } else - in_picture = next_picture; + in_picture = frame; if (!in_picture) return; @@ -1085,8 +1083,8 @@ static void do_video_out(OutputFile *of, } av_frame_unref(e->last_frame); - if (next_picture) - av_frame_move_ref(e->last_frame, next_picture); + if (frame) + av_frame_move_ref(e->last_frame, frame); } void enc_frame(OutputStream *ost, AVFrame *frame) From patchwork Wed Apr 19 19:52:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41258 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp743797pzb; Wed, 19 Apr 2023 12:53:41 -0700 (PDT) X-Google-Smtp-Source: AKy350bgQ9gCQLY+Pn6x2wkuSH2tWYtzQ2rk4JH2u+dk6uf+ON/bkOUxf9+N7hoyU2n8XcFmLUBy X-Received: by 2002:a17:906:dd2:b0:94e:e99f:ac8 with SMTP id p18-20020a1709060dd200b0094ee99f0ac8mr15906011eji.29.1681934021710; Wed, 19 Apr 2023 12:53:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681934021; cv=none; d=google.com; s=arc-20160816; b=u4MU8RoIaQAV2UXT6LiotTIPI0ne5dmFdF0H2V9WkfmwfB5LaOarfuYvALLb6z2Boa 9IevjqDZ0eXMeRjF/LA/18TJopY1vf5XupEJBOK9a5YWgp1fF6RGbfkOQ+C+GE144Yby cBDzZ/PI4SHha/7vf10CFQeQTdir4vwRb187MWfcrGpCtGpiXm8RmYIgQYV3Ljj5gUxL Eu5VJnSUAzRfVHuAivPal1OqVtqCX2q5CTZtEnPMsOzXtsYOBuIiO0YNi8dqiZwNQdg4 B9pq5nmEwj7lQ6DljbAfXC1ubjVjQiz99ofDvl1EYZvF5IFMypQ68CW1exMKL4LwSjEo 4FSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=lAH58QmkN/z7o25FoXon8hQmGB51d94QBQFOclZz8zQ=; b=SfaFmlfemhLLrLOGmfoE7U0L/vut5fPWz9S1LwFRPJw0NG5qWpinr2+pADBgayAPZ3 qGrIG33uK/rAg6wLLUAoSLSzmPCXku2cNY+NvSFokOlV2snsnbd5NURKFg8XCZkJQ7Q1 psakKF0+9OmZ9wy7ukF0u8+OrhMBPh3RmXArqXHRQOX3z5F6sVQzCYqdY2ZrMMuQAcIt f6WS7sTpdp7z4xLY5UVPRHIAS8sTaeIJIhy0jF/fWoMgcJ1tBzwrz/wTCygIDg5HyaIa 4fteVr76BTVOEjp1nreN0AknkByBMlX9D7j0RcU6/nppH5mCiwr9Fe6qG8XSOsEqgxAt 6ybg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id vl13-20020a17090730cd00b0094fbea57d3esi5247114ejb.9.2023.04.19.12.53.41; Wed, 19 Apr 2023 12:53: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; 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 3184A68BE90; Wed, 19 Apr 2023 22:53:09 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1959668BE7F for ; Wed, 19 Apr 2023 22:52:59 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id CC9B72404F8 for ; Wed, 19 Apr 2023 21:52:58 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id Vqzk1wvOyiu3 for ; Wed, 19 Apr 2023 21:52:58 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 068052405B5 for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 8DA193A0D93 for ; Wed, 19 Apr 2023 21:52:55 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Apr 2023 21:52:24 +0200 Message-Id: <20230419195243.2974-6-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230419195243.2974-1-anton@khirnov.net> References: <20230419195243.2974-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 06/25] fftools/ffmpeg_enc: move handling final frames to video_sync_process() 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: DHbJ+f4c89ut This code properly belongs there. --- fftools/ffmpeg_enc.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index e63da2ec97..859c7fdeee 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -877,9 +877,16 @@ static void video_sync_process(OutputFile *of, OutputStream *ost, int64_t *nb_frames, int64_t *nb_frames_prev) { Encoder *e = ost->enc; - double delta0, delta; + double delta0, delta, sync_ipts; - double sync_ipts = adjust_frame_pts_to_encoder_tb(of, ost, frame); + if (!frame) { + *nb_frames_prev = *nb_frames = mid_pred(e->frames_prev_hist[0], + e->frames_prev_hist[1], + e->frames_prev_hist[2]); + goto finish; + } + + sync_ipts = adjust_frame_pts_to_encoder_tb(of, ost, frame); /* delta0 is the "drift" between the input frame and * where it would fall in the output. */ delta0 = sync_ipts - e->next_pts; @@ -940,6 +947,12 @@ static void video_sync_process(OutputFile *of, OutputStream *ost, default: av_assert0(0); } + +finish: + memmove(e->frames_prev_hist + 1, + e->frames_prev_hist, + sizeof(e->frames_prev_hist[0]) * (FF_ARRAY_ELEMS(e->frames_prev_hist) - 1)); + e->frames_prev_hist[0] = *nb_frames_prev; } static enum AVPictureType forced_kf_apply(void *logctx, KeyframeForceCtx *kf, @@ -1015,20 +1028,8 @@ static void do_video_out(OutputFile *of, OutputStream *ost, AVFrame *frame) if (duration <= 0 && frame_rate.num > 0 && frame_rate.den > 0) duration = 1/(av_q2d(frame_rate) * av_q2d(enc->time_base)); - if (!frame) { - //end, flushing - nb_frames_prev = nb_frames = mid_pred(e->frames_prev_hist[0], - e->frames_prev_hist[1], - e->frames_prev_hist[2]); - } else { - video_sync_process(of, ost, frame, duration, - &nb_frames, &nb_frames_prev); - } - - memmove(e->frames_prev_hist + 1, - e->frames_prev_hist, - sizeof(e->frames_prev_hist[0]) * (FF_ARRAY_ELEMS(e->frames_prev_hist) - 1)); - e->frames_prev_hist[0] = nb_frames_prev; + video_sync_process(of, ost, frame, duration, + &nb_frames, &nb_frames_prev); if (nb_frames_prev == 0 && ost->last_dropped) { nb_frames_drop++; From patchwork Wed Apr 19 19:52:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41259 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp743878pzb; Wed, 19 Apr 2023 12:53:51 -0700 (PDT) X-Google-Smtp-Source: AKy350bNKK0yUxbFTDgpx8k6muo6+nkZBDq6xeVTnzGPT1BciN9GkIR9vXdNCedObWEz6l+VfuI5 X-Received: by 2002:a05:6402:5141:b0:506:7f78:c4d3 with SMTP id n1-20020a056402514100b005067f78c4d3mr6298849edd.27.1681934031011; Wed, 19 Apr 2023 12:53:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681934030; cv=none; d=google.com; s=arc-20160816; b=y2L644OB04brIbiK3JLRrQN5cZdSGSpJ4I797k4xgr343/IgLNGrX30bvSaSi5HBeV 2OOYfvAKbZggWrlYEwr6teahpe8rqMDwefgFD6iz5u7eYlo4DvjYFleHnKR7PEke4ijV ZAESgZssrCBwwfGQ6K8Bb4CsBzkzHOhyxs9C0jIc1v2YNpGAA3zYjpwXD9NQaWvLNWqi T3U67RXudVu9QRJDvfqwn+WMysdXeT6NE130z+z1MyQHjzZPYn4UUDY9dcD3nFjcMWs0 dcc6pIqRMEQS/b4UQqN5Unc0pwXN/8g+qJL+mgyzF0KQ7Legz4er6t3Yhc5Nm/ppK0Hy PwpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=oKpLrpGzZwxjI3/qbEjo1Pa/B46X7MbHuBbszVBXB0Q=; b=IAxSkQOe6/sMxjc2MMDrnVOIuWVd1RWXPe0oI9AZR4J/+yI0+MfBCsGZk83dbg2z0h aAsAJCrI8LYGQ3Y1s0v+Th4E2qqNT5KMZgI7d0FuYwLKtHkHyChhRtuEJ236hFA4+WRF AOXsZmn7DyQIYYyhohmDVmIkqE8qlW5g7J+0trWz2IX48Qg+fc2dz5OdaCrM7GSfA2xY /yJrpVAcroPoW4jG/d+fuklbOWgDH4NARDrSS3j9lMWKgeljipm+1Y4DmqKn5leHLO5R V3KeIVG/fjWqS4DHRIswEH0hTevCiZz+mOAXJCLfodx0hDcdjwhjqxxnClMnAPUM4/zy WG3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a14-20020aa7cf0e000000b005069701844asi9726109edy.408.2023.04.19.12.53.50; Wed, 19 Apr 2023 12:53:50 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 376AC68BF1E; Wed, 19 Apr 2023 22:53:10 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6A5FF68BE41 for ; Wed, 19 Apr 2023 22:53:04 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id E4ABE2404EC for ; Wed, 19 Apr 2023 21:53:03 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id QSmS86dmYxEY for ; Wed, 19 Apr 2023 21:53:03 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 624942406D0 for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 989D53A0E28 for ; Wed, 19 Apr 2023 21:52:55 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Apr 2023 21:52:25 +0200 Message-Id: <20230419195243.2974-7-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230419195243.2974-1-anton@khirnov.net> References: <20230419195243.2974-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 07/25] fftools/ffmpeg: stop using InputStream.pts in ts_discontinuity_detect() 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: okQxjlV1haZf ts_discontinuity_detect() is applied right after demuxing, while InputStream.pts is a post-decoding timestamp, which may be delayed with respect to demuxing by an arbitrary amount (e.g. depending on the thread count when frame threading is used). --- fftools/ffmpeg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index a7e856e9e2..cc087ea7de 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2121,7 +2121,7 @@ static void ts_discontinuity_detect(InputFile *ifile, InputStream *ist, int64_t delta = pkt_dts - ist->next_dts; if (fmt_is_discont) { if (FFABS(delta) > 1LL * dts_delta_threshold * AV_TIME_BASE || - pkt_dts + AV_TIME_BASE/10 < FFMAX(ist->pts, ist->dts)) { + pkt_dts + AV_TIME_BASE/10 < ist->dts) { ifile->ts_offset_discont -= delta; av_log(NULL, AV_LOG_WARNING, "timestamp discontinuity for stream #%d:%d " From patchwork Wed Apr 19 19:52:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41265 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp744285pzb; Wed, 19 Apr 2023 12:54:44 -0700 (PDT) X-Google-Smtp-Source: AKy350apLlen6VFEPKJ73EUN/caW3wayc7hlx6ZPN8iH8Z4is6a0RpopQI/ewQW66PzXOgYtd5ce X-Received: by 2002:a17:906:1f57:b0:951:f54c:208c with SMTP id d23-20020a1709061f5700b00951f54c208cmr7841377ejk.41.1681934084374; Wed, 19 Apr 2023 12:54:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681934084; cv=none; d=google.com; s=arc-20160816; b=oNoetCbFC7aGl+lHNIePnnASaOm7n1Yew6/+IOffmX68p7e81YQnEE+OZnBHMcKyMK M8DHKATFQ/HGP4mhvd2kCwAaCmAll3RzW9750VTVgxlug8ZC7tAhSYVpVAh2Mlhnc0QS vxRf53xnLr8X+ckarGjNakelh20lJDZsGE8cPoWvGI5KCFxzYzI6adfqS7wONTp1qPyI srawdlbYRHQ+NFkXMf4b4Cbdkyu/np1L71gNDtS5eKjDoeEXTvE9sNUOOfykjdglv4nz gQuvuewSZlVRH2mIgYSG5M9rW5o2AdDse8Kb6ed8J7Vv98D+VTT2cXmmN2JIYbNX0Yip dKlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=adJ5etY7ZhEWFyiqGQxAywlgSZjPvsrDNdNeksgcapA=; b=NoolcTwssWZ/SAivgHpqgcU+QNqhl+bcAgXY2kbZETfh5/h6M38D22xKyRNFbSIChI qPL+btig1ufpYhIrJ4HbRvazQ4upvdkmsR+CkPGluEIzXIszAPZNbHuqRKlfahbEytkA jQIj5GoZh4PCduCC08nV7nKDAYH+uHMU7jCJ0zGnqDIBAAz1IXm5pDcPSFQrLXqA5m6L 1vsnJ9VnQpUBWYfM07OkqlL7f1xVzNsCIqSkgrNbYeLfXx/iPH7SQhf0G9PScZpK+kzH qWZhwj8dnbTYPJ+Yr0eBp6gk3QuE+w/khcDE81jbzyAjWV6eBzBz+SAQCoPypqmr1j8h GkuQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id we10-20020a170907234a00b0094ee6ba0247si13421486ejb.1010.2023.04.19.12.54.43; Wed, 19 Apr 2023 12:54:44 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3EB5968BF13; Wed, 19 Apr 2023 22:53:16 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EFE5068BEA9 for ; Wed, 19 Apr 2023 22:53:01 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 67BE52405B5 for ; Wed, 19 Apr 2023 21:52:59 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id EHYAe91sCa5L for ; Wed, 19 Apr 2023 21:52:58 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 0A1B72405EC for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id A43833A0E51 for ; Wed, 19 Apr 2023 21:52:55 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Apr 2023 21:52:26 +0200 Message-Id: <20230419195243.2974-8-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230419195243.2974-1-anton@khirnov.net> References: <20230419195243.2974-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 08/25] fftools/ffmpeg: stop setting InputStream.pts for streamcopy X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: iceBD5Brcr2r It is not used in that case anymore. Forgotten in d56652fdc8e1315309516be320a7250854550fa5. --- fftools/ffmpeg.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index cc087ea7de..f2e9832003 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1743,7 +1743,6 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo } break; } - ist->pts = ist->dts; } else if (!ist->decoding_needed) eof_reached = 1; From patchwork Wed Apr 19 19:52:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41264 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp744230pzb; Wed, 19 Apr 2023 12:54:35 -0700 (PDT) X-Google-Smtp-Source: AKy350bmNX+i+bKN3kDmZBUAW+Jn+RMo1NEHXxxwPeyqKomH+Tgh1TcQhEJTr8yMu4cxy+XHS0Wi X-Received: by 2002:aa7:ce06:0:b0:504:b325:bd4d with SMTP id d6-20020aa7ce06000000b00504b325bd4dmr6295816edv.12.1681934075127; Wed, 19 Apr 2023 12:54:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681934075; cv=none; d=google.com; s=arc-20160816; b=AdtN2TksreU2QM5VX1oKLSXW25HOw8Do7z6iL/yO023C3ckJ9UF6KfMGIfJBVguNST WPC3bn1Hc0CGlrHHnQAElU0mXQVrNSL2GFLQKNe5cOIPeS8tMw8c0qoTT7hWV+NHA/ft FWRZP7crB0HTq98YS7v5HN7FH3+KlfmXeLD05HZQgCpOyNy7b6jwgMav8n9URtR9ZX0I HPpRRJXVtggF5lbyPu9yYQTCztALvqNOl4gUWkFqbFbRMtZUKpU+nM+XtKO4L5uS43tG 8xPaKSfwVlSHJxnxwLhb6THieEQrlvta5MvnYldpV/sPGVpgtLhOQ00nXuy5gL2gcUuP NNuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=CQs/xbOMLCGXrhw9oMdj8320YnpfFU/ULzz1/PdprGI=; b=Ejndjbt65Jb4enYe35LbyZjBRYItVkToQg3yo/dEcUAcTiZ5q3NRirH585ipZwvgeN /cF4Py+iluvnz7C4zIOISiymqKFwXV+jROgojqQvKQY5AOGlJDebKBafLb22/2s2ubNs Cqdc69LTyCvCs2r6p+6RxxcASsTJIVWIJ7q6t1+NEEI+oZhiFTGOdZatm8Vgc1f5oEpv ullyatbSHuVz2EqjagMA0aGvO/pA5KrMZ36MAbj8ipG159u0Tla8WrACBdY/rgUdnn2i z7PxpC7Dt8kimX0DQSbD4JNa0uLhWJIeueXB4XkNJjy8e3BFpTngjgrryHvt6Xcf9Qc+ H1ng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id z5-20020aa7cf85000000b00504b02fcb7esi14855973edx.648.2023.04.19.12.54.34; Wed, 19 Apr 2023 12:54: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; 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 382DA68BE2E; Wed, 19 Apr 2023 22:53:15 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4828A68BE9D for ; Wed, 19 Apr 2023 22:53:06 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id D981A2404EC for ; Wed, 19 Apr 2023 21:53:05 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id VoDq9WZGStGy for ; Wed, 19 Apr 2023 21:53:05 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 627B5240705 for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id B0E683A1032 for ; Wed, 19 Apr 2023 21:52:55 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Apr 2023 21:52:27 +0200 Message-Id: <20230419195243.2974-9-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230419195243.2974-1-anton@khirnov.net> References: <20230419195243.2974-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 09/25] fftools/ffmpeg: replace stream timebase with packet one where appropriate 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: 7C8DNA6IUP1E --- fftools/ffmpeg.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index f2e9832003..e6ee3ce557 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1146,7 +1146,7 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output, decoded_frame_tb = ist->st->time_base; } else if (pkt && pkt->pts != AV_NOPTS_VALUE) { decoded_frame->pts = pkt->pts; - decoded_frame_tb = ist->st->time_base; + decoded_frame_tb = pkt->time_base; }else { decoded_frame->pts = ist->dts; decoded_frame_tb = AV_TIME_BASE_Q; @@ -1583,7 +1583,7 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo ist->pts = 0; if (pkt && pkt->pts != AV_NOPTS_VALUE && !ist->decoding_needed) { ist->first_dts = - ist->dts += av_rescale_q(pkt->pts, ist->st->time_base, AV_TIME_BASE_Q); + ist->dts += av_rescale_q(pkt->pts, pkt->time_base, AV_TIME_BASE_Q); } ist->saw_first_ts = 1; } @@ -1601,7 +1601,7 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo } if (pkt && pkt->dts != AV_NOPTS_VALUE) { - ist->next_dts = ist->dts = av_rescale_q(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q); + ist->next_dts = ist->dts = av_rescale_q(pkt->dts, pkt->time_base, AV_TIME_BASE_Q); if (par->codec_type != AVMEDIA_TYPE_VIDEO) ist->pts = ist->dts; } @@ -1627,7 +1627,7 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo &decode_failed); if (!repeating || !pkt || got_output) { if (pkt && pkt->duration) { - duration_dts = av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q); + duration_dts = av_rescale_q(pkt->duration, pkt->time_base, AV_TIME_BASE_Q); } else if(ist->dec_ctx->framerate.num != 0 && ist->dec_ctx->framerate.den != 0) { int ticks = ist->last_pkt_repeat_pict >= 0 ? ist->last_pkt_repeat_pict + 1 : @@ -1722,7 +1722,7 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo ist->next_dts += ((int64_t)AV_TIME_BASE * par->frame_size) / par->sample_rate; } else { - ist->next_dts += av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q); + ist->next_dts += av_rescale_q(pkt->duration, pkt->time_base, AV_TIME_BASE_Q); } break; case AVMEDIA_TYPE_VIDEO: @@ -1732,7 +1732,7 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo int64_t next_dts = av_rescale_q(ist->next_dts, time_base_q, av_inv_q(ist->framerate)); ist->next_dts = av_rescale_q(next_dts + 1, av_inv_q(ist->framerate), time_base_q); } else if (pkt->duration) { - ist->next_dts += av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q); + ist->next_dts += av_rescale_q(pkt->duration, pkt->time_base, AV_TIME_BASE_Q); } else if(ist->dec_ctx->framerate.num != 0) { int ticks = ist->last_pkt_repeat_pict >= 0 ? ist->last_pkt_repeat_pict + 1 : @@ -2104,13 +2104,13 @@ static void ts_discontinuity_detect(InputFile *ifile, InputStream *ist, { const int fmt_is_discont = ifile->ctx->iformat->flags & AVFMT_TS_DISCONT; int disable_discontinuity_correction = copy_ts; - int64_t pkt_dts = av_rescale_q_rnd(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q, + int64_t pkt_dts = av_rescale_q_rnd(pkt->dts, pkt->time_base, AV_TIME_BASE_Q, AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX); if (copy_ts && ist->next_dts != AV_NOPTS_VALUE && fmt_is_discont && ist->st->pts_wrap_bits < 60) { int64_t wrap_dts = av_rescale_q_rnd(pkt->dts + (1LL<st->pts_wrap_bits), - ist->st->time_base, AV_TIME_BASE_Q, + pkt->time_base, AV_TIME_BASE_Q, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX); if (FFABS(wrap_dts - ist->next_dts) < FFABS(pkt_dts - ist->next_dts)/10) disable_discontinuity_correction = 0; @@ -2128,9 +2128,9 @@ static void ts_discontinuity_detect(InputFile *ifile, InputStream *ist, ist->file_index, ist->st->index, ist->st->id, av_get_media_type_string(ist->par->codec_type), delta, ifile->ts_offset_discont); - pkt->dts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base); + pkt->dts -= av_rescale_q(delta, AV_TIME_BASE_Q, pkt->time_base); if (pkt->pts != AV_NOPTS_VALUE) - pkt->pts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base); + pkt->pts -= av_rescale_q(delta, AV_TIME_BASE_Q, pkt->time_base); } } else { if (FFABS(delta) > 1LL * dts_error_threshold * AV_TIME_BASE) { @@ -2138,7 +2138,7 @@ static void ts_discontinuity_detect(InputFile *ifile, InputStream *ist, pkt->dts = AV_NOPTS_VALUE; } if (pkt->pts != AV_NOPTS_VALUE){ - int64_t pkt_pts = av_rescale_q(pkt->pts, ist->st->time_base, AV_TIME_BASE_Q); + int64_t pkt_pts = av_rescale_q(pkt->pts, pkt->time_base, AV_TIME_BASE_Q); delta = pkt_pts - ist->next_dts; if (FFABS(delta) > 1LL * dts_error_threshold * AV_TIME_BASE) { av_log(NULL, AV_LOG_WARNING, "PTS %"PRId64", next:%"PRId64" invalid dropping st:%d\n", pkt->pts, ist->next_dts, pkt->stream_index); @@ -2154,20 +2154,20 @@ static void ts_discontinuity_detect(InputFile *ifile, InputStream *ist, av_log(NULL, AV_LOG_DEBUG, "Inter stream timestamp discontinuity %"PRId64", new offset= %"PRId64"\n", delta, ifile->ts_offset_discont); - pkt->dts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base); + pkt->dts -= av_rescale_q(delta, AV_TIME_BASE_Q, pkt->time_base); if (pkt->pts != AV_NOPTS_VALUE) - pkt->pts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base); + pkt->pts -= av_rescale_q(delta, AV_TIME_BASE_Q, pkt->time_base); } } - ifile->last_ts = av_rescale_q(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q); + ifile->last_ts = av_rescale_q(pkt->dts, pkt->time_base, AV_TIME_BASE_Q); } static void ts_discontinuity_process(InputFile *ifile, InputStream *ist, AVPacket *pkt) { int64_t offset = av_rescale_q(ifile->ts_offset_discont, AV_TIME_BASE_Q, - ist->st->time_base); + pkt->time_base); // apply previously-detected timestamp-discontinuity offset // (to all streams, not just audio/video) @@ -2275,9 +2275,9 @@ static int process_input(int file_index) av_log(NULL, AV_LOG_INFO, "demuxer+ffmpeg -> ist_index:%d:%d type:%s pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s duration:%s duration_time:%s off:%s off_time:%s\n", ifile->index, pkt->stream_index, av_get_media_type_string(ist->par->codec_type), - av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &ist->st->time_base), - av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &ist->st->time_base), - av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, &ist->st->time_base), + av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &pkt->time_base), + av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &pkt->time_base), + av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, &pkt->time_base), av_ts2str(input_files[ist->file_index]->ts_offset), av_ts2timestr(input_files[ist->file_index]->ts_offset, &AV_TIME_BASE_Q)); } From patchwork Wed Apr 19 19:52:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41266 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp744341pzb; Wed, 19 Apr 2023 12:54:53 -0700 (PDT) X-Google-Smtp-Source: AKy350ZimLMhg48cKeCYTrVtSMy7ua6UJcR+153CsALucRpzVvlDk3dXG3w7UOmNXSXAymot+LDP X-Received: by 2002:a17:907:9805:b0:94f:3cf5:6d7f with SMTP id ji5-20020a170907980500b0094f3cf56d7fmr15699197ejc.46.1681934093743; Wed, 19 Apr 2023 12:54:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681934093; cv=none; d=google.com; s=arc-20160816; b=gTlPQOtpwSyldvgJ9l7vW1eMtES6H3f0lqHjplCXQWbvcGl6UyGTBCfHGL7ek8qPpr rVJr6fDPjDzae4RHcWGA/GnSVfLSqhoVsBAy4sxstibAzp0Y5qvyJ0ARCTRHMJFT9ri4 STbi6QlgGhzHPLOnvpMn7G010PS+p0UHNu9BW3ba/ed5EyZIzF+Hbf83qfpf4dAadnIe TiP3rR0dtADtAXuloqg35scfIUEKqAXqnZG9mRFAPug1SlLndf/mBFYrCI2lvNpy5xN0 BfVNgJejp9bEWaYalIo1ahvE49jraQ/qm0MwPqJLWo3k7f5POI8n+kS2fd2RHlLPUD2L 4Lxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=butZ14GiwzC5Qz6DpJA82hwNRfN9H9Dviq2qd4l7RF4=; b=ZqWV1u7IZnEBmERL2f5yfK6VZm0BwYtxLT6xRoazgsPMAYGN30msRtS+E46Qkebfsf jxLEsPeyR3s8uMPOJla3I5mEpGcdNRWc0AX4c0nuPnaXvaQ4aQDxvFRrnhq96z4b0wg3 3VXP5rcXJFW5M/Xj2oZNSMq+olzXRPSNXl7ul12eKkKoQT0GY3SvfbIvJo0Pr8qugqHN GKuh58A6JlEYPstETD7Vuxo+cnGGbh+9U7qaYCPl2piWwQRbXjtGCEkeNqbQMI7hmGKL inMW6n+dOHYzyu2lCJvmnh/mA7DwT9epV99e/jlmqsKsy6sbttvVjyAggNyuGNZEOVZW i9xg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id eq5-20020a170907290500b0094f0647d5d5si11755042ejc.800.2023.04.19.12.54.53; Wed, 19 Apr 2023 12:54:53 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 334D068BF4F; Wed, 19 Apr 2023 22:53:17 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0869368BEB5 for ; Wed, 19 Apr 2023 22:53:02 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 3DE722405EC for ; Wed, 19 Apr 2023 21:53:00 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 4M-L5Veiji5b for ; Wed, 19 Apr 2023 21:52:59 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 127F42405F9 for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id BCB963A1049 for ; Wed, 19 Apr 2023 21:52:55 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Apr 2023 21:52:28 +0200 Message-Id: <20230419195243.2974-10-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230419195243.2974-1-anton@khirnov.net> References: <20230419195243.2974-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 10/25] fftools/ffmpeg_mux_init: consolidate handling -filter for audio/video 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: yJgq0gvaBJUd --- fftools/ffmpeg_mux_init.c | 68 +++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 38 deletions(-) diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 89c0ac90ea..7c35d6b582 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -420,33 +420,36 @@ static MuxStream *mux_stream_alloc(Muxer *mux, enum AVMediaType type) return ms; } -static char *get_ost_filters(const OptionsContext *o, AVFormatContext *oc, - OutputStream *ost) +static int ost_get_filters(const OptionsContext *o, AVFormatContext *oc, + OutputStream *ost) { + MATCH_PER_STREAM_OPT(filter_scripts, str, ost->filters_script, oc, ost->st); + MATCH_PER_STREAM_OPT(filters, str, ost->filters, oc, ost->st); + + if (!ost->enc) { + if (ost->filters_script || ost->filters) { + av_log(ost, AV_LOG_ERROR, + "%s '%s' was specified, but codec copy was selected. " + "Filtering and streamcopy cannot be used together.\n", + ost->filters ? "Filtergraph" : "Filtergraph script", + ost->filters ? ost->filters : ost->filters_script); + return AVERROR(ENOSYS); + } + return 0; + } + if (ost->filters_script && ost->filters) { av_log(ost, AV_LOG_ERROR, "Both -filter and -filter_script set\n"); exit_program(1); } if (ost->filters_script) - return file_read(ost->filters_script); + ost->avfilter = file_read(ost->filters_script); else if (ost->filters) - return av_strdup(ost->filters); - - return av_strdup(ost->type == AVMEDIA_TYPE_VIDEO ? "null" : "anull"); -} - -static void check_streamcopy_filters(const OptionsContext *o, AVFormatContext *oc, - OutputStream *ost, enum AVMediaType type) -{ - if (ost->filters_script || ost->filters) { - av_log(ost, AV_LOG_ERROR, - "%s '%s' was defined, but codec copy was selected.\n" - "Filtering and streamcopy cannot be used together.\n", - ost->filters ? "Filtergraph" : "Filtergraph script", - ost->filters ? ost->filters : ost->filters_script); - exit_program(1); - } + ost->avfilter = av_strdup(ost->filters); + else + ost->avfilter = av_strdup(ost->type == AVMEDIA_TYPE_VIDEO ? "null" : "anull"); + return ost->avfilter ? 0 : AVERROR(ENOMEM); } static void parse_matrix_coeffs(void *logctx, uint16_t *dest, const char *str) @@ -504,9 +507,6 @@ static void new_stream_video(Muxer *mux, const OptionsContext *o, ost->frame_aspect_ratio = q; } - MATCH_PER_STREAM_OPT(filter_scripts, str, ost->filters_script, oc, st); - MATCH_PER_STREAM_OPT(filters, str, ost->filters, oc, st); - if (ost->enc_ctx) { AVCodecContext *video_enc = ost->enc_ctx; const char *p = NULL, *fps_mode = NULL; @@ -692,12 +692,7 @@ static void new_stream_video(Muxer *mux, const OptionsContext *o, } } ost->is_cfr = (ost->vsync_method == VSYNC_CFR || ost->vsync_method == VSYNC_VSCFR); - - ost->avfilter = get_ost_filters(o, oc, ost); - if (!ost->avfilter) - exit_program(1); - } else - check_streamcopy_filters(o, oc, ost, AVMEDIA_TYPE_VIDEO); + } } static void new_stream_audio(Muxer *mux, const OptionsContext *o, @@ -708,10 +703,6 @@ static void new_stream_audio(Muxer *mux, const OptionsContext *o, st = ost->st; - - MATCH_PER_STREAM_OPT(filter_scripts, str, ost->filters_script, oc, st); - MATCH_PER_STREAM_OPT(filters, str, ost->filters, oc, st); - if (ost->enc_ctx) { AVCodecContext *audio_enc = ost->enc_ctx; int channels = 0; @@ -757,10 +748,6 @@ static void new_stream_audio(Muxer *mux, const OptionsContext *o, MATCH_PER_STREAM_OPT(apad, str, ost->apad, oc, st); ost->apad = av_strdup(ost->apad); - ost->avfilter = get_ost_filters(o, oc, ost); - if (!ost->avfilter) - exit_program(1); - #if FFMPEG_OPT_MAP_CHANNEL /* check for channel mapping for this audio stream */ for (int n = 0; n < o->nb_audio_channel_maps; n++) { @@ -791,8 +778,7 @@ static void new_stream_audio(Muxer *mux, const OptionsContext *o, } } #endif - } else - check_streamcopy_filters(o, oc, ost, AVMEDIA_TYPE_AUDIO); + } } static void new_stream_data(Muxer *mux, const OptionsContext *o, @@ -1223,6 +1209,12 @@ static OutputStream *ost_add(Muxer *mux, const OptionsContext *o, default: new_stream_unknown (mux, o, ost); break; } + if (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO) { + ret = ost_get_filters(o, oc, ost); + if (ret < 0) + exit_program(1); + } + if (ost->ist) { if (ost->enc && (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) { From patchwork Wed Apr 19 19:52:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41261 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp744013pzb; Wed, 19 Apr 2023 12:54:08 -0700 (PDT) X-Google-Smtp-Source: AKy350aQ7aIuRfjSqYGFx9RoN7dmt+nYqiC4X2MEpgbN9YIxyJKkACUOHPQOsO+eEojnFk6vbK// X-Received: by 2002:a17:907:9496:b0:94f:7486:85a7 with SMTP id dm22-20020a170907949600b0094f748685a7mr11887010ejc.31.1681934048483; Wed, 19 Apr 2023 12:54:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681934048; cv=none; d=google.com; s=arc-20160816; b=a6lEJKkn7gKe3qk0c8ZUh78VKqsrbFxzzWBRWa0a+H7MjqQ3/n1N/xeDqTyoRVds3R eynRubstMCiKWDtyHL5qsGvMNcMFPqapTGsVeL/E8OzXiC63X9qAxvGyTRVFIvEPOz9s GO8CnRE+qdADarolSrLNpUrZeXWTye0z2QZgmAKG6uhQgqlzFITPP6VJXjV/3u7r0KQt DsYcZuWMOl4HaRU/1fdycvBvDXRandgZ2/CorBFqOdlIs2MUiS06/fYzRVQreYeWcR1/ livZHPHEUCz3tXwqEPdN6tVSZNCeBYKYfMV7PYljzPipybPnBiNoN5BOk6rifgTi876D d8mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=bFf7qC/AmL+9wh9jWucMVoI81omSqWz+1OPV2hLuh4w=; b=AyJ/nGHbuA/wiMXgKGhtCC3zkRlIXf4P6dhnqMc3acdSc1hRSWTEZDPGag7XmeFWYv sLuyyNXcevs8mfonk+ASaUotktYOrCjUqqJmno6IgrhvL0aBWa1l8X068xeKRzn7gXuZ 0ogwuXCwBYI4hURlDeyy8SyzkxobYzG0JJxlqyK+PfuX7YZ3aW44Yn65kp3yVK41Myyl Q51OV8+6v8pXm2OvrFC3lZHgTC7sRkCagQ5cU0ZwLBRX1a27JJM74WpS5oFvsSWogPb5 vK+IdsCR/barMHSx2/zmxlfbDVgSMOhXnRZSJkzVoniwqyPDdEg7PoJN7vMULG1GZjIF BfIQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id p6-20020a170906b20600b0095381349fe2si294014ejz.951.2023.04.19.12.54.08; Wed, 19 Apr 2023 12:54: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; 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 625FA68BEA6; Wed, 19 Apr 2023 22:53:12 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C81AC68BE8D for ; Wed, 19 Apr 2023 22:53:04 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 7AC2C2404EC for ; Wed, 19 Apr 2023 21:53:04 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id bsBpFVOfmKmz for ; Wed, 19 Apr 2023 21:53:03 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 62EC6240D03 for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id C82D83A121B for ; Wed, 19 Apr 2023 21:52:55 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Apr 2023 21:52:29 +0200 Message-Id: <20230419195243.2974-11-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230419195243.2974-1-anton@khirnov.net> References: <20230419195243.2974-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 11/25] fftools/ffmpeg_mux_init: move check for mixing simple/complex filters 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: 8EH094x/2bbL Do it in ost_get_filters() together with other similar checks. Will be useful in following commits. Also, improve the log message. --- fftools/ffmpeg_mux_init.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 7c35d6b582..c82556a706 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -438,6 +438,19 @@ static int ost_get_filters(const OptionsContext *o, AVFormatContext *oc, return 0; } + if (!ost->ist) { + if (ost->filters_script || ost->filters) { + av_log(ost, AV_LOG_ERROR, + "%s '%s' was specified for a stream fed from a complex " + "filtergraph. Simple and complex filtering cannot be used " + "together for the same stream.\n", + ost->filters ? "Filtergraph" : "Filtergraph script", + ost->filters ? ost->filters : ost->filters_script); + return AVERROR(EINVAL); + } + return 0; + } + if (ost->filters_script && ost->filters) { av_log(ost, AV_LOG_ERROR, "Both -filter and -filter_script set\n"); exit_program(1); @@ -1263,18 +1276,6 @@ static void init_output_filter(OutputFilter *ofilter, const OptionsContext *o, exit_program(1); } - if (ost->avfilter && (ost->filters || ost->filters_script)) { - const char *opt = ost->filters ? "-vf/-af/-filter" : "-filter_script"; - av_log(ost, AV_LOG_ERROR, - "%s '%s' was specified through the %s option " - "for output stream %d:%d, which is fed from a complex filtergraph.\n" - "%s and -filter_complex cannot be used together for the same stream.\n", - ost->filters ? "Filtergraph" : "Filtergraph script", - ost->filters ? ost->filters : ost->filters_script, - opt, ost->file_index, ost->index, opt); - exit_program(1); - } - avfilter_inout_free(&ofilter->out_tmp); } From patchwork Wed Apr 19 19:52:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41260 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp743941pzb; Wed, 19 Apr 2023 12:53:59 -0700 (PDT) X-Google-Smtp-Source: AKy350ZhU3HE9M5b1QKLvT6aA93G1OCI8x/wK3oAxqtqDHL7dK8KGJZGnjo6ce52oO51mKf2q5Ds X-Received: by 2002:a17:907:3e02:b0:94f:35ea:d773 with SMTP id hp2-20020a1709073e0200b0094f35ead773mr18057745ejc.75.1681934039719; Wed, 19 Apr 2023 12:53:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681934039; cv=none; d=google.com; s=arc-20160816; b=gh1wV2gdq8bR4R8oSH2QNFgCYONK+sIcxiePR10X6WSp5281ClXpANUxxGDTd+OQND OUI4nQD9xNGRbV4PN9GlpBiKYCTYPl66GqVLz7xQ75ZfS/g0Z1rr0i9cNZQxO/ldbiw5 KTKPxPElQy76CEj8g4GhtanoKU6BeeV0kFey9tsNvfLPg99Dvb6iC/zS2geZaTKrnh0B DVQUG4/rBpt1G/30JVng15rSeSe1kyhd4hp33LcmUG8IxNFZAJWvPtdTLddDbJwLCd15 6/raAVtt2NVJiJRb2KjpnrIlfEkg75pkDxsa8LFd9vO9zEcuKIZBWBNDOXy8LlX6rwgW Kf+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=5PcccLgy6Bu92ssv4LLjtw7xvV42WY2L1xZ5qaDVqFk=; b=mTADZEjWi6Q1Av93vQv6ZQjZlJIUbfOqgIUnfSoYMeL+N4JXpBSDiw8vScNjMmeOBY bDwi/uJ0e3rzy1U8PXGPWyocNKN58wB+s0iyQlw0pyiR8w1hOCWqTyalYv1bzMlwqSsC V97Z9xnGfrqPtizK/SWIQ6dHcD+o6CdDAaiKfdz1dEyP0ANf3vNaUSumepK/8wEG16kj 3YwLy+EBZ1NBPnJ957PlGK5b7aSn4gfRt7vEKguCn64GbQLWDUk4HnlsF9S8+h/+fYZf 8rsvH3Y83L7G9ASV9lF6FBzFNfJWm1IBcpMFvytORDB0bT8JWRANe550I310wwkCbH6X MCnw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id fp8-20020a1709069e0800b0095317ae7667si4399647ejc.266.2023.04.19.12.53.59; Wed, 19 Apr 2023 12:53: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; 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 5E87268BF1B; Wed, 19 Apr 2023 22:53:11 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7A5DB68BE89 for ; Wed, 19 Apr 2023 22:53:04 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 366132404EE for ; Wed, 19 Apr 2023 21:53:04 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id zTP3sk0l1TpS for ; Wed, 19 Apr 2023 21:53:01 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 14A0E2406CA for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id D2EF63A122A for ; Wed, 19 Apr 2023 21:52:55 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Apr 2023 21:52:30 +0200 Message-Id: <20230419195243.2974-12-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230419195243.2974-1-anton@khirnov.net> References: <20230419195243.2974-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 12/25] fftools/ffmpeg_mux_init: drop OutputStream.filters[_script] 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: IBBhlYkNN6Zm They are not needed outside of ost_get_filters(), so make them stack variables there. --- fftools/ffmpeg.h | 2 -- fftools/ffmpeg_mux_init.c | 28 +++++++++++++++------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 72020c8f3a..c9d499efdd 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -639,8 +639,6 @@ typedef struct OutputStream { OutputFilter *filter; char *avfilter; - char *filters; ///< filtergraph associated to the -filter option - char *filters_script; ///< filtergraph script associated to the -filter_script option AVDictionary *encoder_opts; AVDictionary *sws_dict; diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index c82556a706..da3dccd6d7 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -423,43 +423,45 @@ static MuxStream *mux_stream_alloc(Muxer *mux, enum AVMediaType type) static int ost_get_filters(const OptionsContext *o, AVFormatContext *oc, OutputStream *ost) { - MATCH_PER_STREAM_OPT(filter_scripts, str, ost->filters_script, oc, ost->st); - MATCH_PER_STREAM_OPT(filters, str, ost->filters, oc, ost->st); + const char *filters = NULL, *filters_script = NULL; + + MATCH_PER_STREAM_OPT(filter_scripts, str, filters_script, oc, ost->st); + MATCH_PER_STREAM_OPT(filters, str, filters, oc, ost->st); if (!ost->enc) { - if (ost->filters_script || ost->filters) { + if (filters_script || filters) { av_log(ost, AV_LOG_ERROR, "%s '%s' was specified, but codec copy was selected. " "Filtering and streamcopy cannot be used together.\n", - ost->filters ? "Filtergraph" : "Filtergraph script", - ost->filters ? ost->filters : ost->filters_script); + filters ? "Filtergraph" : "Filtergraph script", + filters ? filters : filters_script); return AVERROR(ENOSYS); } return 0; } if (!ost->ist) { - if (ost->filters_script || ost->filters) { + if (filters_script || filters) { av_log(ost, AV_LOG_ERROR, "%s '%s' was specified for a stream fed from a complex " "filtergraph. Simple and complex filtering cannot be used " "together for the same stream.\n", - ost->filters ? "Filtergraph" : "Filtergraph script", - ost->filters ? ost->filters : ost->filters_script); + filters ? "Filtergraph" : "Filtergraph script", + filters ? filters : filters_script); return AVERROR(EINVAL); } return 0; } - if (ost->filters_script && ost->filters) { + if (filters_script && filters) { av_log(ost, AV_LOG_ERROR, "Both -filter and -filter_script set\n"); exit_program(1); } - if (ost->filters_script) - ost->avfilter = file_read(ost->filters_script); - else if (ost->filters) - ost->avfilter = av_strdup(ost->filters); + if (filters_script) + ost->avfilter = file_read(filters_script); + else if (filters) + ost->avfilter = av_strdup(filters); else ost->avfilter = av_strdup(ost->type == AVMEDIA_TYPE_VIDEO ? "null" : "anull"); return ost->avfilter ? 0 : AVERROR(ENOMEM); From patchwork Wed Apr 19 19:52:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41262 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp744086pzb; Wed, 19 Apr 2023 12:54:17 -0700 (PDT) X-Google-Smtp-Source: AKy350bW9hq9QnHp0gLc7JwkyJ7R/n8pWRq9zt5wBFnHMGK1WFVj2Q98dsIgZYZyqeuZnCWOPCWZ X-Received: by 2002:a17:906:43c5:b0:94e:cbb7:4f60 with SMTP id j5-20020a17090643c500b0094ecbb74f60mr14075325ejn.19.1681934057079; Wed, 19 Apr 2023 12:54:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681934057; cv=none; d=google.com; s=arc-20160816; b=SXHBL7dYcxbv6dWqMsMK1F53EqYSbWSRfBp/us9ezVe5tgd3sDHwXnwOIV7ULd8y5u YZNJPpHB2N2iRS+7QI22eRuvW01gvjXNCLzeaHqmuns22302MuMKgpfaDpWAQOqm08hD JYhiAWSAXHzMaIUTbDBQVV8nAtAzA9dBKMau3lC5SHHILKKgUfuKLsbm/YmldLj4IZfL bcNSlw/1A3pEKNyp4/xd0ypJ6dlU8y5RT32uFb8KV7eUk4JUk5UB/Z2l6GVeXg5m67AB x0CeBTScKRxhwEC9ZBrP2YwZ+dTOw55+h85xwvv1O9kDLnszK1RUziBqRbHJTE3Zlb+5 jxuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=DcAX9XNXfDfK4JaNy1VTQ2znv0bsjOirgRyDTMdHOzg=; b=IU1qHiPx32eoMhN2S83xwkIHrXU9va9Q0thXgvkhlLXBk10z632ixr/hEGi4OrxwTg n+XMd8wcO2N1IEFxAtugtCXD6BO3reN3hgh4MRUpDNh16MjkyjvanXAEIsXLjJVuWYvI fd27/j22HoCv5kScZZWJ6x/6aevZPdCgdHd82SepzLaH2Hab0xj8j4h9QVXTf867/P4L 9PCUyPrJc5hkKq/v/CkjNDYvNMzXN4PfEyaRboLC5cL+VHHN9OSMWXVbxxOLq14+bEH+ nt3SGQtruwSjSV3pEf+xBQf/992fKYFBmmfN87LIAdlt5ZkF/+PSaaWIhehWoJbNsPmH ajYQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id mf6-20020a1709071a4600b0094f712dac4esi1517306ejc.937.2023.04.19.12.54.16; Wed, 19 Apr 2023 12:54:17 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4828B68BF46; Wed, 19 Apr 2023 22:53:13 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D9FC868BE96 for ; Wed, 19 Apr 2023 22:53:05 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 17C832404F8 for ; Wed, 19 Apr 2023 21:53:05 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id HSSthoFSWdkn for ; Wed, 19 Apr 2023 21:53:04 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 65468240D0E for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id DE9603A037D for ; Wed, 19 Apr 2023 21:52:55 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Apr 2023 21:52:31 +0200 Message-Id: <20230419195243.2974-13-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230419195243.2974-1-anton@khirnov.net> References: <20230419195243.2974-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 13/25] fftools/ffmpeg: remove unused function arguments 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: sasklqrfC70a --- fftools/ffmpeg_mux.c | 4 ++-- fftools/ffmpeg_mux_init.c | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index a2e8873ad2..368a7000a9 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -255,7 +255,7 @@ finish: return ret == AVERROR_EOF ? 0 : ret; } -static int queue_packet(Muxer *mux, OutputStream *ost, AVPacket *pkt) +static int queue_packet(OutputStream *ost, AVPacket *pkt) { MuxStream *ms = ms_from_ost(ost); AVPacket *tmp_pkt = NULL; @@ -305,7 +305,7 @@ static int submit_packet(Muxer *mux, AVPacket *pkt, OutputStream *ost) return thread_submit_packet(mux, ost, pkt); } else { /* the muxer is not initialized yet, buffer the packet */ - ret = queue_packet(mux, ost, pkt); + ret = queue_packet(ost, pkt); if (ret < 0) { if (pkt) av_packet_unref(pkt); diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index da3dccd6d7..59d9a12c1a 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -839,8 +839,7 @@ static void new_stream_subtitle(Muxer *mux, const OptionsContext *o, } } -static int streamcopy_init(const Muxer *mux, const OptionsContext *o, - OutputStream *ost) +static int streamcopy_init(const Muxer *mux, OutputStream *ost) { MuxStream *ms = ms_from_ost(ost); @@ -1244,7 +1243,7 @@ static OutputStream *ost_add(Muxer *mux, const OptionsContext *o, } if (ost->ist && !ost->enc) { - ret = streamcopy_init(mux, o, ost); + ret = streamcopy_init(mux, ost); if (ret < 0) exit_program(1); } @@ -1946,7 +1945,7 @@ static int copy_chapters(InputFile *ifile, OutputFile *ofile, AVFormatContext *o static int copy_metadata(Muxer *mux, AVFormatContext *ic, const char *outspec, const char *inspec, int *metadata_global_manual, int *metadata_streams_manual, - int *metadata_chapters_manual, const OptionsContext *o) + int *metadata_chapters_manual) { AVFormatContext *oc = mux->fc; AVDictionary **meta_in = NULL; @@ -2050,7 +2049,7 @@ static void copy_meta(Muxer *mux, const OptionsContext *o) in_file_index >= 0 ? input_files[in_file_index]->ctx : NULL, o->metadata_map[i].specifier, *p ? p + 1 : p, &metadata_global_manual, &metadata_streams_manual, - &metadata_chapters_manual, o); + &metadata_chapters_manual); } /* copy chapters */ From patchwork Wed Apr 19 19:52:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41278 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp745137pzb; Wed, 19 Apr 2023 12:56:42 -0700 (PDT) X-Google-Smtp-Source: AKy350aZs+9NzCpwxwkY/AxzRxQTlv+uGN1BWMi45182zfcR3ocXslf5T+ns3oKYtkLDgCqINvyM X-Received: by 2002:a05:6402:278c:b0:506:bbf8:5152 with SMTP id b12-20020a056402278c00b00506bbf85152mr3618541ede.9.1681934201858; Wed, 19 Apr 2023 12:56:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681934201; cv=none; d=google.com; s=arc-20160816; b=yusJo9HpURkRJlkX6fnsSMvWsgtE7AevE4eJ/g/nNEoXCnN+SKnTKYu0mKzkBLfpBa ZEyvc5lE5vE7Y0vDI766S1qgvxfjV79UrBbxbCUZZ/LdvXkh+WtP0mKiwc+kkrzwn0bT P6WtXOyna0eaZzCN9V1bA0kuqP04qq26TrK5STeftkeQcv4wa9nyYHiASRC1PRTWB1M/ F0Zf0B26gm4RR3zJzHW5dSWdRsFnVZKdUrxoItcxJ71iIiiFFDRaCDhHg9OZNapRXIKE I1rx5LToe+edNHchhSbyaBMyos6pKg9ZjU40nPGHa5mL5OwEhTPwS7FsHER5DjKtIAGM XyAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=TPI5tQDSDOW8ASR7xxWAb4k/JBKZ5uzDGp+wsx1CYZQ=; b=s9R4nUER1acwX9HWnzHVIQvhCApSlbj2Ms4/OfKQore+fmM0gn3oFDR3ynWWjhdsyy F9HHqYRSgDdubCSDRZ64gnobpbl2qXRF8afUOdv6qiSDFkbSKGp1R9TnnN8FD6J6EsEs 6iXE3Ct+1qPD6IF7vhTeGLrJ50ZPh8AXrheHs8tMjYthAjh4HBQYXN0GvZI3wmI/rtpi 6nxaDBQzgqr+VFnhRtusrSiM0BPr+OAjJNjZBOkMNXux392l3Rjm68IOrUxoCt7gWP8/ ovCw0rdOGb/rkUmChHw0peNKabw/95xGLCyfMgDnGKKRPBxZt37SMfEZPG3DqSInT1uL di/g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id r24-20020aa7d598000000b004fafc269d55si15798404edq.113.2023.04.19.12.56.41; Wed, 19 Apr 2023 12:56: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; 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 BD93B68BFB6; Wed, 19 Apr 2023 22:53:30 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E82D068BF20 for ; Wed, 19 Apr 2023 22:53:06 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 83E792404EC for ; Wed, 19 Apr 2023 21:53:06 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id wjBFeqOFpkQY for ; Wed, 19 Apr 2023 21:53:05 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 75B59240D1C for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id E9E2C3A07C2 for ; Wed, 19 Apr 2023 21:52:55 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Apr 2023 21:52:32 +0200 Message-Id: <20230419195243.2974-14-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230419195243.2974-1-anton@khirnov.net> References: <20230419195243.2974-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 14/25] fftools/ffmpeg_mux_init: drop useless new_stream_{data, unknown} 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: deClbhdOile0 Their only function is checking that encoding was not specified for data/unknown-type streams, but the check is broken because enc_ctx will not be created in ost_add() unless a valid encoder can be found. Add an actually working check for all types for which encoding is not supported in choose_encoder(). --- fftools/ffmpeg_mux_init.c | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 59d9a12c1a..28254cb49b 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -113,8 +113,21 @@ static int choose_encoder(const OptionsContext *o, AVFormatContext *s, *enc = NULL; - if (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO || type == AVMEDIA_TYPE_SUBTITLE) { - MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, ost->st); + MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, ost->st); + + if (type != AVMEDIA_TYPE_VIDEO && + type != AVMEDIA_TYPE_AUDIO && + type != AVMEDIA_TYPE_SUBTITLE) { + if (codec_name && strcmp(codec_name, "copy")) { + const char *type_str = av_get_media_type_string(type); + av_log(ost, AV_LOG_FATAL, + "Encoder '%s' specified, but only '-codec copy' supported " + "for %s streams\n", codec_name, type_str); + return AVERROR(ENOSYS); + } + return 0; + } + if (!codec_name) { ost->par_in->codec_id = av_guess_codec(s->oformat, NULL, s->url, NULL, ost->type); @@ -130,7 +143,6 @@ static int choose_encoder(const OptionsContext *o, AVFormatContext *s, *enc = find_codec_or_die(ost, codec_name, ost->type, 1); ost->par_in->codec_id = (*enc)->id; } - } return 0; } @@ -796,24 +808,6 @@ static void new_stream_audio(Muxer *mux, const OptionsContext *o, } } -static void new_stream_data(Muxer *mux, const OptionsContext *o, - OutputStream *ost) -{ - if (ost->enc_ctx) { - av_log(ost, AV_LOG_FATAL, "Data stream encoding not supported yet (only streamcopy)\n"); - exit_program(1); - } -} - -static void new_stream_unknown(Muxer *mux, const OptionsContext *o, - OutputStream *ost) -{ - if (ost->enc_ctx) { - av_log(ost, AV_LOG_FATAL, "Unknown stream encoding not supported yet (only streamcopy)\n"); - exit_program(1); - } -} - static void new_stream_attachment(Muxer *mux, const OptionsContext *o, OutputStream *ost) { @@ -1218,9 +1212,7 @@ static OutputStream *ost_add(Muxer *mux, const OptionsContext *o, case AVMEDIA_TYPE_VIDEO: new_stream_video (mux, o, ost); break; case AVMEDIA_TYPE_AUDIO: new_stream_audio (mux, o, ost); break; case AVMEDIA_TYPE_SUBTITLE: new_stream_subtitle (mux, o, ost); break; - case AVMEDIA_TYPE_DATA: new_stream_data (mux, o, ost); break; case AVMEDIA_TYPE_ATTACHMENT: new_stream_attachment(mux, o, ost); break; - default: new_stream_unknown (mux, o, ost); break; } if (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO) { From patchwork Wed Apr 19 19:52:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41269 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp744560pzb; Wed, 19 Apr 2023 12:55:22 -0700 (PDT) X-Google-Smtp-Source: AKy350a/pj0R/X8cJ3Tuy6Wcw/SKCaVDlWKS30J8hcI6LYLQKksfS58h9SHmKv0wwAuOTDK1tcPr X-Received: by 2002:aa7:c857:0:b0:506:bf2f:65af with SMTP id g23-20020aa7c857000000b00506bf2f65afmr5967827edt.24.1681934122083; Wed, 19 Apr 2023 12:55:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681934122; cv=none; d=google.com; s=arc-20160816; b=wNedqh8cn9hzRxgZn4oqzlLFb0Bmlkjr1hLIZqKjdsnKSh0WD4nTrMsLbGTusYiGoP PN/QI9WRXDYNobGin0r2qo1QiwiJ2iCb2SGWPjfOi9G8KMHFhuqS+3aYq9jbbkRL/wpq d6+KJN+A62nL1cmWl00G5cexpIFP97H74/AsVgPFZF9gIzzgOBRn9u606B/R2KHvc+pG VXE6yt7P4bctFYVbubZf5RBjNLw2ITNZHlJHKVmg66iDf5fACygvN1x6sWRI+4y+H7Is jEXzB6DJxkSKXaNhXD7Ep3buq9vhbeAtavynBQjTbZ49Qjd7pYhJhIhB1F+1TL1dfjLk nKVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=T5iC974IrWCut3XlShqJqjP3IgEOEQpSib8VCKHQ8+A=; b=gyDwEDYWVGnEhr1nV9XwHCU3j9TcLbaEGbiTO1yWyMBsFk+R0MvYgZDbP78QP2+6S4 m88tJkitZBlAOJY4Z51twFVnM4q3fVBik0jGMo6l7OodIBalOH7+IfgUKDWHeACJFnM9 YpQ/rtLeUzq9VoG/afw0CJR/lb+LKzncXxqWwj3oYh+IUazbfiWviw3ChuVm3bM8jYLS rRiHKRUs0hmGdKvKKdsL7XCVO7FEwhchGZYptE7n7OJcKDamn8ft7tKL2y4znU//YCWW P688m9uQt8FXgh5TvfkVwfmR38yiHlGe2r9se8xjsAjYOFHBaqojq9tIQ8VV403mrez1 NQAQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id p22-20020a05640210d600b004fd1f069ba6si15978992edu.560.2023.04.19.12.55.21; Wed, 19 Apr 2023 12:55:22 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5EF1E68BF5E; Wed, 19 Apr 2023 22:53:20 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9BC3A68BE76 for ; Wed, 19 Apr 2023 22:53:02 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id D8558240591 for ; Wed, 19 Apr 2023 21:53:00 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 6zM8Q99tWMOf for ; Wed, 19 Apr 2023 21:53:00 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 15D292406CB for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 00F933A13BB for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Apr 2023 21:52:33 +0200 Message-Id: <20230419195243.2974-15-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230419195243.2974-1-anton@khirnov.net> References: <20230419195243.2974-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 15/25] fftools/ffmpeg: reindent after previous commit 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: bGsYlAo6UgfE --- fftools/ffmpeg_mux_init.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 28254cb49b..ad5a451581 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -128,21 +128,20 @@ static int choose_encoder(const OptionsContext *o, AVFormatContext *s, return 0; } - if (!codec_name) { - ost->par_in->codec_id = av_guess_codec(s->oformat, NULL, s->url, - NULL, ost->type); - *enc = avcodec_find_encoder(ost->par_in->codec_id); - if (!*enc) { - av_log(ost, AV_LOG_FATAL, "Automatic encoder selection failed " - "Default encoder for format %s (codec %s) is " - "probably disabled. Please choose an encoder manually.\n", - s->oformat->name, avcodec_get_name(ost->par_in->codec_id)); - return AVERROR_ENCODER_NOT_FOUND; - } - } else if (strcmp(codec_name, "copy")) { - *enc = find_codec_or_die(ost, codec_name, ost->type, 1); - ost->par_in->codec_id = (*enc)->id; - } + if (!codec_name) { + ost->par_in->codec_id = av_guess_codec(s->oformat, NULL, s->url, NULL, ost->type); + *enc = avcodec_find_encoder(ost->par_in->codec_id); + if (!*enc) { + av_log(ost, AV_LOG_FATAL, "Automatic encoder selection failed " + "Default encoder for format %s (codec %s) is " + "probably disabled. Please choose an encoder manually.\n", + s->oformat->name, avcodec_get_name(ost->par_in->codec_id)); + return AVERROR_ENCODER_NOT_FOUND; + } + } else if (strcmp(codec_name, "copy")) { + *enc = find_codec_or_die(ost, codec_name, ost->type, 1); + ost->par_in->codec_id = (*enc)->id; + } return 0; } From patchwork Wed Apr 19 19:52:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41272 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp744733pzb; Wed, 19 Apr 2023 12:55:49 -0700 (PDT) X-Google-Smtp-Source: AKy350YhMapVGHU4ZhEQ0/ff4Ei/ZMpGmAjJlKnU5XfHn6yDivx+fQmquvBYQhlbJl3zP4wXvQhY X-Received: by 2002:a17:906:ecba:b0:94a:8291:a1e3 with SMTP id qh26-20020a170906ecba00b0094a8291a1e3mr14991229ejb.74.1681934149032; Wed, 19 Apr 2023 12:55:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681934149; cv=none; d=google.com; s=arc-20160816; b=Kmu1512OUl3Y8Cku+ykJCl8xF18p4vwGI+5k6/ma+KNFAXFvHL5AV+x0bv46vgvr2J Bo2iZYyX2Gkpoeb7A7D9TKVndaKuTc/4OnFvvQC3+79YkB9f2qVbSdhfCKZQ8hJOsl2N tbRKSzFQ2uOpNEWDFyegi+1xooxxNQ02HpD6/u4pqMPapX2qv6KPqGIO0JHx3doZAW4m J451j92VWBAiWuLP7udv0s+FqIV72DKVA/U9Ai009kM/zmP90nxtTrLOtpgHLE+QAsMr MLIHLvLRS27bQ0sIktFzQskYH/H0ixx78LtWN43FWTBpAfpIi2vZdD6nUIQuh6H1puhx A7bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=ndXQxnT7ZkF/CpuaZ/p1VDbg3W3Q7B9VM/DN4xK1llg=; b=LOCi3kTN199On7XKy9CpyL6dYSfsCqK9YtOgOPncxv2cqPGCF6YDNjm99qnV3z+k2b xEbgFduAUCxNiQBtBX5ziajhedZbCNd7mQ5YSiUv0SlO0miLlR/a1TmFXAnST/OOoSRI xBIV6/hOIvvwgA5vXa+0ajIbxcJQPySvB84yN7Nf+8k2SO7naqTnY3NxAbQA4CzQ7Qb8 eTT5dpUIcup0uC2DWR4l/5z2lwSE3t9oHIzMQ6TnviVHSFyLmovg5OletrhZ8issNh6N HkHpFOYd1JUYcCo8R+MpGzjqVptefrUI72fsYvo7rmULchVO7EB5hIUgrlmta1qPL7fs ZzfA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id vp22-20020a17090712d600b0094f73dc4c68si8142175ejb.47.2023.04.19.12.55.48; Wed, 19 Apr 2023 12:55: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; 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 81B5268BF83; Wed, 19 Apr 2023 22:53:23 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 47D6B68BE8A for ; Wed, 19 Apr 2023 22:53:03 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id A71732406CB for ; Wed, 19 Apr 2023 21:53:01 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 49gQh6gcVCyU for ; Wed, 19 Apr 2023 21:53:00 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 228002406CC for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 0BB7E3A0787 for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Apr 2023 21:52:34 +0200 Message-Id: <20230419195243.2974-16-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230419195243.2974-1-anton@khirnov.net> References: <20230419195243.2974-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 16/25] fftools/ffmpeg_filter: add a function for creating a filtergraph 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: CzVljs4Ou9vE Code creating a new filtergraph is currently duplicated in 3 places. This commit unifies it and moves towards making filtergraphs more self-contained. --- fftools/ffmpeg.h | 8 ++++++++ fftools/ffmpeg_filter.c | 18 +++++++++++++----- fftools/ffmpeg_opt.c | 14 +++++--------- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index c9d499efdd..b181d433b0 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -803,6 +803,14 @@ int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame); int ifilter_parameters_from_codecpar(InputFilter *ifilter, AVCodecParameters *par); int ifilter_has_all_input_formats(FilterGraph *fg); +/** + * Create a new filtergraph in the global filtergraph list. + * + * @param graph_desc Graph description; an av_malloc()ed string, filtergraph + * takes ownership of it. + */ +FilterGraph *fg_create(char *graph_desc); + int ffmpeg_parse_options(int argc, char **argv); void enc_stats_write(OutputStream *ost, EncStats *es, diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index ea182089b1..7b3d9a490f 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -188,15 +188,26 @@ static OutputFilter *ofilter_alloc(FilterGraph *fg) return ofilter; } +FilterGraph *fg_create(char *graph_desc) +{ + FilterGraph *fg; + + fg = ALLOC_ARRAY_ELEM(filtergraphs, nb_filtergraphs); + fg->index = nb_filtergraphs - 1; + fg->graph_desc = graph_desc; + + return fg; +} + int init_simple_filtergraph(InputStream *ist, OutputStream *ost) { - FilterGraph *fg = av_mallocz(sizeof(*fg)); + FilterGraph *fg; OutputFilter *ofilter; InputFilter *ifilter; + fg = fg_create(NULL); if (!fg) report_and_exit(AVERROR(ENOMEM)); - fg->index = nb_filtergraphs; ofilter = ofilter_alloc(fg); ofilter->ost = ost; @@ -212,9 +223,6 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost) if (!ifilter->frame_queue) report_and_exit(AVERROR(ENOMEM)); - GROW_ARRAY(filtergraphs, nb_filtergraphs); - filtergraphs[nb_filtergraphs - 1] = fg; - ist_filter_add(ist, ifilter, 1); return 0; diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index aa9aa0e9b4..408ef121b7 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -1106,26 +1106,22 @@ static int opt_audio_qscale(void *optctx, const char *opt, const char *arg) static int opt_filter_complex(void *optctx, const char *opt, const char *arg) { - FilterGraph *fg = ALLOC_ARRAY_ELEM(filtergraphs, nb_filtergraphs); - - fg->index = nb_filtergraphs - 1; - fg->graph_desc = av_strdup(arg); - if (!fg->graph_desc) + char *graph_desc = av_strdup(arg); + if (!graph_desc) return AVERROR(ENOMEM); + fg_create(graph_desc); + return 0; } static int opt_filter_complex_script(void *optctx, const char *opt, const char *arg) { - FilterGraph *fg; char *graph_desc = file_read(arg); if (!graph_desc) return AVERROR(EINVAL); - fg = ALLOC_ARRAY_ELEM(filtergraphs, nb_filtergraphs); - fg->index = nb_filtergraphs - 1; - fg->graph_desc = graph_desc; + fg_create(graph_desc); return 0; } From patchwork Wed Apr 19 19:52:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41273 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp744806pzb; Wed, 19 Apr 2023 12:55:57 -0700 (PDT) X-Google-Smtp-Source: AKy350aqvj3mTFcXXVbg3819W1l4HexwjmF2J6ociNv9g8h3TdDUvXkbWX1L9ZjZVwwVO6l1eb67 X-Received: by 2002:aa7:d542:0:b0:506:a2bb:fc43 with SMTP id u2-20020aa7d542000000b00506a2bbfc43mr6680299edr.15.1681934157680; Wed, 19 Apr 2023 12:55:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681934157; cv=none; d=google.com; s=arc-20160816; b=Q2pGMs4Aq8kdfZPCX5AMgwn7Ieq/BzQ0uANtO+dkE/Ut6a+tnYP5+casPtqAzfX4vv yqRkqz3NGc1gOm8VLCwM+KIXFB4M/C5J6EEP2jJieATuZomTIsmm6BoX4gSn/C3BYciA OZh6bjtJNNsi2Jn/ruHj6SUqB0Kqogs+2LWSV/rgICBY9up0QuGfWwFiOA+2PrOVH1SM +Hdk9vdIUpDWb4Na8x2Q7uwM2I1GtI2g+0rokh9JjnLpAwjQ7y9GLxHMyYNFAvz/EMDO YsL01nWFAz5HG9gE6fwpyc7ApNQia/dvmuDFmnO2Q+1IRI2ayp4ZIcTXDiv69LJir/5r s/kQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=WKthd23q2aDDwy2DfhV3YGLiVvyLESk5o82NznntkDQ=; b=sB3+flHfxTKOrbkHcqM5OS8LQjH7J/9aZRE6UuafGiZGfk5YnZSGeGdMrE6dkQ+g8z Rzw+jTax5Q2JLG0Ed0f5ulHLrzIvNmj3EQb2FgZi4v671Lh/vJw4DR+zSSEy5HNLDcYh jJFbG+HHuPlsGoOlWLO6sUwpnscCgIGilxogZbUB8kUIdgpDdfcDU5p4e0ktbNROzS8T FTuZbH4smMjiZuO4l9xEgY+T4RMkovDRD47wBpbG1j++84ZRayDY2FzBdllG8pZZ78wX d/iLYttajQWlfCKLr5kJMGh4y08/xNG08+IdbhKbb0bGlzzFnitazmc+t8+0Ji6MjnqQ QZmw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id n8-20020a056402514800b005069701846csi9553107edd.416.2023.04.19.12.55.57; Wed, 19 Apr 2023 12:55: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; 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 8CA8B68BF6D; Wed, 19 Apr 2023 22:53:24 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4BDBF68BEC0 for ; Wed, 19 Apr 2023 22:53:03 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 45E312406CC for ; Wed, 19 Apr 2023 21:53:02 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id Y7S39ADdGNCY for ; Wed, 19 Apr 2023 21:53:00 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 308302406CD for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 166E23A07F8 for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Apr 2023 21:52:35 +0200 Message-Id: <20230419195243.2974-17-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230419195243.2974-1-anton@khirnov.net> References: <20230419195243.2974-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 17/25] fftools/ffmpeg_mux_init: drop a redundant assignment 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: JcTGHpv1w0uz OutputFilter.format is initialized in ofilter_alloc(). --- fftools/ffmpeg_mux_init.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index ad5a451581..1a63908074 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -1259,7 +1259,6 @@ static void init_output_filter(OutputFilter *ofilter, const OptionsContext *o, ost->filter = ofilter; ofilter->ost = ost; - ofilter->format = -1; if (!ost->enc_ctx) { av_log(ost, AV_LOG_ERROR, "Streamcopy requested for output stream fed " From patchwork Wed Apr 19 19:52:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41277 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp745073pzb; Wed, 19 Apr 2023 12:56:33 -0700 (PDT) X-Google-Smtp-Source: AKy350YAPUrIEwQZLkpH+p6cT40S5wOUNEgm1/TxmvePM0wfZ2wmrk9v21vsi0+b6eDeEsvGb5sI X-Received: by 2002:aa7:d691:0:b0:502:7d3f:1f04 with SMTP id d17-20020aa7d691000000b005027d3f1f04mr7598118edr.19.1681934192868; Wed, 19 Apr 2023 12:56:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681934192; cv=none; d=google.com; s=arc-20160816; b=076zLQ0EzvIF9LcGGeo1tRUN0oQ2SBphDWyIeFXeebEEBe14g4ZBBc8nZubT05AQGS 4F4KR7vpmEo2PC4a3vlxOrZljZdtDs9bWcsrYMDGdCc20/wk61hUuZX9pCejk6JtHGWe FVBCqTH8UAFICEfPzQEBJSNRInizR6jOjAHw3RLoGcjs+Lkab+zR048jLOUG35xtKyK8 3EQlS+5nfdW+JiQzC4Zn1DM+FV29zvlyK3xK0MzROK0ymDn29TzNYIF3uvUYhQDYdSIt S08fUCVwGyFIQVOwi77tyyCLHGJqwGDBfmNiggvA6usRWWb7DXrNAsnGYxoPG4wRS7JC unQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=2wG7E9Q/cti2pPbGEfxHvwILD2+Yxg8YjlO7PBoFOmQ=; b=qLHZsJS0xSYHdtUQCsPqlk4GidqycbRbB0rMvLbPmcYF6EI2e3IUPTvvrNxM1YYcvF x0WCzm+pPLV03EvHPvdpn6na7ttFrvods//0m6EYrU0QYCtSiDE/OQ3JDKqS8iM6Rin+ Z/4Myb9pIvp/0HtYPM4nHsxykR5LjkGXouaY9teeaRkwV3dJCcwBhiH0OmBe2EeDARm8 MNL7iuYEfdkC4tynKhPJaq0CzQCJcmtemjn4KkrypAkBFpQrRBWdfY4Di7VlatMv1wfM gjWFkvFn0rVERQLQNJeDQ1IzVyerOu59yqdtmKMJ+Wmily9vP47EA/vjPUf4VMymBk9/ j/zQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id n26-20020aa7c45a000000b0050683e02938si12229272edr.653.2023.04.19.12.56.32; Wed, 19 Apr 2023 12:56:32 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0720768BE9A; Wed, 19 Apr 2023 22:53:29 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 044EB68BF08 for ; Wed, 19 Apr 2023 22:53:04 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id C33912406CF for ; Wed, 19 Apr 2023 21:53:02 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id CAEhZWBJ2uhn for ; Wed, 19 Apr 2023 21:53:02 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 3770E2406CE for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 2362C3A0D68 for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Apr 2023 21:52:36 +0200 Message-Id: <20230419195243.2974-18-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230419195243.2974-1-anton@khirnov.net> References: <20230419195243.2974-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 18/25] fftools/ffmpeg: simplify init_output_filter() 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: Z2TPgZPz8lhO --- fftools/ffmpeg_mux_init.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 1a63908074..db1f9fa9a6 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -1245,16 +1245,7 @@ static OutputStream *ost_add(Muxer *mux, const OptionsContext *o, static void init_output_filter(OutputFilter *ofilter, const OptionsContext *o, Muxer *mux) { - OutputStream *ost; - - switch (ofilter->type) { - case AVMEDIA_TYPE_VIDEO: ost = ost_add(mux, o, AVMEDIA_TYPE_VIDEO, NULL); break; - case AVMEDIA_TYPE_AUDIO: ost = ost_add(mux, o, AVMEDIA_TYPE_AUDIO, NULL); break; - default: - av_log(mux, AV_LOG_FATAL, "Only video and audio filters are supported " - "currently.\n"); - exit_program(1); - } + OutputStream *ost = ost_add(mux, o, ofilter->type, NULL); ost->filter = ofilter; From patchwork Wed Apr 19 19:52:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41276 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp745012pzb; Wed, 19 Apr 2023 12:56:24 -0700 (PDT) X-Google-Smtp-Source: AKy350bq7RB7nKGrnF7w5gGOu5Cf9DxOBdNDSGQ+EFV0ZqDGjLWMYMZyDKHinOtYiUMGu9p2yuRH X-Received: by 2002:a05:6402:1048:b0:506:b228:7b03 with SMTP id e8-20020a056402104800b00506b2287b03mr6326483edu.13.1681934183961; Wed, 19 Apr 2023 12:56:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681934183; cv=none; d=google.com; s=arc-20160816; b=dqG7nyuGzaiRGb0nkZyYnKUrz8J21ow3WYM7XYYo/AE+WlMJDr5rG0GaGxrzDFg6a0 8c1xexQn6abFRNYETVpq3p/9DeS+mMPZUgTrtJja6FrEG585nKPz/u56La0+emD4oZGT RnegwtSIrC1do4Tl3Fr7uTa62ww5KHcezXuWvcV5qFK9PB9/+XRkAXmFC+w4lqLiLHgx Kn5GX6+Msc4GxxB5Jq6G2c2lXAd5lpRNlafjqJEMz8gZsQ8oC0I4tMChC0EW3h1Lfql4 wzcbRs8CfgTYcLYVY2E750l92Hq+SFlZeOjkv08ERNxRATzIVfF7ONk1tMR5r3B0XsB8 cMvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=R9Aj9wYk7+3HssE+3wgPaRmwI9K3m09krhqdXFfaJr8=; b=KoOZiqvYvjeRpkb+1YxkgNUB36XCnjZUYayshR89+jEqvZ+R8rbuHkTOu6AelDDfa5 eNAvQHjrY/BjNCHrg8WSHE4VoKxYvGf7cyAXCxNLcd5O+HwktzqyR7CsgcPetryNYOjx cA/KcziqGFS5gZsnMmwZBBWHrc/2bbgYOxj9XvDsZE42HMm7NotKM84Qe/ylJw65njLL qu30wqQBgQC4gkijpc43KL1gr2hUIMjJIwn9D5P6WdbflhEPJ8nKH4PHCjdvVE/sXHay hAWQMp5qxHYrmQ2Gu1QAT44zrUgEKIVlOqO2jP4v7Ymk8fxZnOJk8CQx4FuBfRa4LBEm OrTQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id q10-20020aa7d44a000000b00504a7debfe2si15647377edr.214.2023.04.19.12.56.23; Wed, 19 Apr 2023 12:56: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; 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 79CE468BF9D; Wed, 19 Apr 2023 22:53:27 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0482F68BF14 for ; Wed, 19 Apr 2023 22:53:04 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 6CE612404F5 for ; Wed, 19 Apr 2023 21:53:03 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id k1NqVbkBs714 for ; Wed, 19 Apr 2023 21:53:02 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 61BF22404EE for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 300A03A0D93 for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Apr 2023 21:52:37 +0200 Message-Id: <20230419195243.2974-19-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230419195243.2974-1-anton@khirnov.net> References: <20230419195243.2974-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 19/25] fftools/ffmpeg_mux_init: rename init_output_filter() to ost_add_from_filter() 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: Ru3HOQ6CJD0u The previous name is misleading, because the function does not actually initialize any filters - it creates a new output stream and binds a filtergraph output to it. --- fftools/ffmpeg_mux_init.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index db1f9fa9a6..7a2db9f0e8 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -1242,7 +1242,8 @@ static OutputStream *ost_add(Muxer *mux, const OptionsContext *o, return ost; } -static void init_output_filter(OutputFilter *ofilter, const OptionsContext *o, +// add a new output stream fed by the provided filtergraph output +static void ost_add_from_filter(OutputFilter *ofilter, const OptionsContext *o, Muxer *mux) { OutputStream *ost = ost_add(mux, o, ofilter->type, NULL); @@ -1438,7 +1439,7 @@ loop_end: "in any defined filter graph, or was already used elsewhere.\n", map->linklabel); exit_program(1); } - init_output_filter(ofilter, o, mux); + ost_add_from_filter(ofilter, o, mux); } else { ist = input_files[map->file_index]->streams[map->stream_index]; if (ist->user_set_discard == AVDISCARD_ALL) { @@ -1537,7 +1538,7 @@ static void create_streams(Muxer *mux, const OptionsContext *o) case AVMEDIA_TYPE_AUDIO: auto_disable_a = 1; break; case AVMEDIA_TYPE_SUBTITLE: auto_disable_s = 1; break; } - init_output_filter(ofilter, o, mux); + ost_add_from_filter(ofilter, o, mux); } } From patchwork Wed Apr 19 19:52:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41267 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp744406pzb; Wed, 19 Apr 2023 12:55:02 -0700 (PDT) X-Google-Smtp-Source: AKy350ZVCVFJ6O3dQeOKDPuTzd8yNm7meBj2T4tJjIUyGj4KYDeKt4ttB0RU1G7PLQRF8lbIcIvR X-Received: by 2002:a17:907:78ce:b0:953:83a4:a9ff with SMTP id kv14-20020a17090778ce00b0095383a4a9ffmr308286ejc.49.1681934102702; Wed, 19 Apr 2023 12:55:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681934102; cv=none; d=google.com; s=arc-20160816; b=RbYrqZYYGyQ0bRLb3ovb2Qem8avPY5/cIibPaWUFMW8TEBbkntKzHy2H5HwaXtxq06 88GoxJuGhoDa5TY98A+3Q9j2B1jNHFnvoWmkVuhcM2gBaGm8Qn5pvWGx9OjETqYe+zjQ qxST8+FPEzqehKcDHcgKoXG+gmnSfTfsJ75M8BOI9cgUIFDIDEi6l38TVV0LFFbA0XF4 gwBFnynMJFtGRnBoI7b/zDu+8TQgMExyS+cdYolmd5m+BkAJGSnrEInW3XLo4YmRDrRF Or/1b9zFC9OPZDZyRPJNHCCSHg2SAn18ge8NWAoR91bIKIYUV3ra/C1yn1Paoui04ymZ N03g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=BgcWQaW5ZdvooI0Yo5H6nVwNQTFeQzNOp3ETvDou7Fc=; b=kOXWgLrtegYHR/WJ3V1nnj2IVdisFsANgIBI6Bb0Ba4DI6qiRto/webNL2IBI0b3kU nG08BNvqit2fo/BcGhfAZ4DFh9dSXoc4yryq5qAzkm9THBsxAfhBSQEiqIoRXQJTWSNb fJyjqvWfR05d9dDb7Y0BwwR+JiF3VScl/8mWg7Oobc+aGoRbF+GOR5LGn8tUqfdCAXup pYeZnC3zwJN1W4mVSVDcNBqVjb72eSNHci5/5UaY92Xzd3rwhTRJ/kUad+ZlLBIvQCXm LsDzViWTVAlaUzSvBFEBpULe8NovDRmv0cZGpuMXri/glBTNVuNKTBu3906DbzysPVxZ 1qgQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id l23-20020a170907915700b0094f37afeea1si8262881ejs.298.2023.04.19.12.55.02; Wed, 19 Apr 2023 12:55:02 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 34A4368BF53; Wed, 19 Apr 2023 22:53:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6F48B68BE61 for ; Wed, 19 Apr 2023 22:53:07 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 0ED982404EE for ; Wed, 19 Apr 2023 21:53:07 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id KDmJbCIwY7bP for ; Wed, 19 Apr 2023 21:53:04 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 62C39240706 for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 3BBDE3A0E51 for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Apr 2023 21:52:38 +0200 Message-Id: <20230419195243.2974-20-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230419195243.2974-1-anton@khirnov.net> References: <20230419195243.2974-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 20/25] fftools/ffmpeg: move filtering functions to ffmpeg_filter 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: vSsMKbCYrmwi --- fftools/ffmpeg.c | 216 +--------------------------------------- fftools/ffmpeg.h | 20 ++++ fftools/ffmpeg_filter.c | 202 +++++++++++++++++++++++++++++++++++++ 3 files changed, 223 insertions(+), 215 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index e6ee3ce557..248c22a4ff 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -651,66 +651,6 @@ void close_output_stream(OutputStream *ost) sq_send(of->sq_encode, ost->sq_idx_encode, SQFRAME(NULL)); } -/** - * Get and encode new output from any of the filtergraphs, without causing - * activity. - * - * @return 0 for success, <0 for severe errors - */ -static int reap_filters(int flush) -{ - AVFrame *filtered_frame = NULL; - - /* Reap all buffers present in the buffer sinks */ - for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost)) { - AVFilterContext *filter; - int ret = 0; - - if (!ost->filter || !ost->filter->graph->graph) - continue; - filter = ost->filter->filter; - - filtered_frame = ost->filtered_frame; - - while (1) { - ret = av_buffersink_get_frame_flags(filter, filtered_frame, - AV_BUFFERSINK_FLAG_NO_REQUEST); - if (ret < 0) { - if (ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) { - av_log(NULL, AV_LOG_WARNING, - "Error in av_buffersink_get_frame_flags(): %s\n", av_err2str(ret)); - } else if (flush && ret == AVERROR_EOF) { - if (av_buffersink_get_type(filter) == AVMEDIA_TYPE_VIDEO) - enc_frame(ost, NULL); - } - break; - } - if (ost->finished) { - av_frame_unref(filtered_frame); - continue; - } - - if (filtered_frame->pts != AV_NOPTS_VALUE) { - AVRational tb = av_buffersink_get_time_base(filter); - ost->filter->last_pts = av_rescale_q(filtered_frame->pts, tb, - AV_TIME_BASE_Q); - filtered_frame->time_base = tb; - - if (debug_ts) - av_log(NULL, AV_LOG_INFO, "filter_raw -> pts:%s pts_time:%s time_base:%d/%d\n", - av_ts2str(filtered_frame->pts), - av_ts2timestr(filtered_frame->pts, &tb), - tb.num, tb.den); - } - - enc_frame(ost, filtered_frame); - av_frame_unref(filtered_frame); - } - } - - return 0; -} - static void print_report(int is_last_report, int64_t timer_start, int64_t cur_time) { AVBPrint buf, buf_script; @@ -944,112 +884,6 @@ int ifilter_has_all_input_formats(FilterGraph *fg) return 1; } -static int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame, int keep_reference) -{ - FilterGraph *fg = ifilter->graph; - AVFrameSideData *sd; - int need_reinit, ret; - int buffersrc_flags = AV_BUFFERSRC_FLAG_PUSH; - - if (keep_reference) - buffersrc_flags |= AV_BUFFERSRC_FLAG_KEEP_REF; - - /* determine if the parameters for this input changed */ - need_reinit = ifilter->format != frame->format; - - switch (ifilter->ist->par->codec_type) { - case AVMEDIA_TYPE_AUDIO: - need_reinit |= ifilter->sample_rate != frame->sample_rate || - av_channel_layout_compare(&ifilter->ch_layout, &frame->ch_layout); - break; - case AVMEDIA_TYPE_VIDEO: - need_reinit |= ifilter->width != frame->width || - ifilter->height != frame->height; - break; - } - - if (!ifilter->ist->reinit_filters && fg->graph) - need_reinit = 0; - - if (!!ifilter->hw_frames_ctx != !!frame->hw_frames_ctx || - (ifilter->hw_frames_ctx && ifilter->hw_frames_ctx->data != frame->hw_frames_ctx->data)) - need_reinit = 1; - - if (sd = av_frame_get_side_data(frame, AV_FRAME_DATA_DISPLAYMATRIX)) { - if (!ifilter->displaymatrix || memcmp(sd->data, ifilter->displaymatrix, sizeof(int32_t) * 9)) - need_reinit = 1; - } else if (ifilter->displaymatrix) - need_reinit = 1; - - if (need_reinit) { - ret = ifilter_parameters_from_frame(ifilter, frame); - if (ret < 0) - return ret; - } - - /* (re)init the graph if possible, otherwise buffer the frame and return */ - if (need_reinit || !fg->graph) { - if (!ifilter_has_all_input_formats(fg)) { - AVFrame *tmp = av_frame_clone(frame); - if (!tmp) - return AVERROR(ENOMEM); - - ret = av_fifo_write(ifilter->frame_queue, &tmp, 1); - if (ret < 0) - av_frame_free(&tmp); - - return ret; - } - - ret = reap_filters(1); - if (ret < 0 && ret != AVERROR_EOF) { - av_log(NULL, AV_LOG_ERROR, "Error while filtering: %s\n", av_err2str(ret)); - return ret; - } - - ret = configure_filtergraph(fg); - if (ret < 0) { - av_log(NULL, AV_LOG_ERROR, "Error reinitializing filters!\n"); - return ret; - } - } - - ret = av_buffersrc_add_frame_flags(ifilter->filter, frame, buffersrc_flags); - if (ret < 0) { - if (ret != AVERROR_EOF) - av_log(NULL, AV_LOG_ERROR, "Error while filtering: %s\n", av_err2str(ret)); - return ret; - } - - return 0; -} - -static int ifilter_send_eof(InputFilter *ifilter, int64_t pts) -{ - int ret; - - ifilter->eof = 1; - - if (ifilter->filter) { - ret = av_buffersrc_close(ifilter->filter, pts, AV_BUFFERSRC_FLAG_PUSH); - if (ret < 0) - return ret; - } else { - // the filtergraph was never configured - if (ifilter->format < 0) { - ret = ifilter_parameters_from_codecpar(ifilter, ifilter->ist->par); - if (ret < 0) - return ret; - } - if (ifilter->format < 0 && (ifilter->type == AVMEDIA_TYPE_AUDIO || ifilter->type == AVMEDIA_TYPE_VIDEO)) { - av_log(NULL, AV_LOG_ERROR, "Cannot determine format of input stream %d:%d after EOF\n", ifilter->ist->file_index, ifilter->ist->st->index); - return AVERROR_INVALIDDATA; - } - } - - return 0; -} - // This does not quite work like avcodec_decode_audio4/avcodec_decode_video2. // There is the following difference: if you got a frame, you must call // it again with pkt=NULL. pkt==NULL is treated differently from pkt->size==0 @@ -2292,54 +2126,6 @@ discard_packet: return 0; } -/** - * Perform a step of transcoding for the specified filter graph. - * - * @param[in] graph filter graph to consider - * @param[out] best_ist input stream where a frame would allow to continue - * @return 0 for success, <0 for error - */ -static int transcode_from_filter(FilterGraph *graph, InputStream **best_ist) -{ - int i, ret; - int nb_requests, nb_requests_max = 0; - InputFilter *ifilter; - InputStream *ist; - - *best_ist = NULL; - ret = avfilter_graph_request_oldest(graph->graph); - if (ret >= 0) - return reap_filters(0); - - if (ret == AVERROR_EOF) { - ret = reap_filters(1); - for (i = 0; i < graph->nb_outputs; i++) - close_output_stream(graph->outputs[i]->ost); - return ret; - } - if (ret != AVERROR(EAGAIN)) - return ret; - - for (i = 0; i < graph->nb_inputs; i++) { - ifilter = graph->inputs[i]; - ist = ifilter->ist; - if (input_files[ist->file_index]->eagain || - input_files[ist->file_index]->eof_reached) - continue; - nb_requests = av_buffersrc_get_nb_failed_requests(ifilter->filter); - if (nb_requests > nb_requests_max) { - nb_requests_max = nb_requests; - *best_ist = ist; - } - } - - if (!*best_ist) - for (i = 0; i < graph->nb_outputs; i++) - graph->outputs[i]->ost->unavailable = 1; - - return 0; -} - /** * Run a single step of transcoding. * @@ -2373,7 +2159,7 @@ static int transcode_step(void) } if (ost->filter && ost->filter->graph->graph) { - if ((ret = transcode_from_filter(ost->filter->graph, &ist)) < 0) + if ((ret = fg_transcode_step(ost->filter->graph, &ist)) < 0) return ret; if (!ist) return 0; diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index b181d433b0..07c1fc7ed6 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -799,6 +799,9 @@ int init_complex_filtergraph(FilterGraph *fg); void sub2video_update(InputStream *ist, int64_t heartbeat_pts, AVSubtitle *sub); +int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame, int keep_reference); +int ifilter_send_eof(InputFilter *ifilter, int64_t pts); + int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame); int ifilter_parameters_from_codecpar(InputFilter *ifilter, AVCodecParameters *par); int ifilter_has_all_input_formats(FilterGraph *fg); @@ -811,6 +814,23 @@ int ifilter_has_all_input_formats(FilterGraph *fg); */ FilterGraph *fg_create(char *graph_desc); +/** + * Perform a step of transcoding for the specified filter graph. + * + * @param[in] graph filter graph to consider + * @param[out] best_ist input stream where a frame would allow to continue + * @return 0 for success, <0 for error + */ +int fg_transcode_step(FilterGraph *graph, InputStream **best_ist); + +/** + * Get and encode new output from any of the filtergraphs, without causing + * activity. + * + * @return 0 for success, <0 for severe errors + */ +int reap_filters(int flush); + int ffmpeg_parse_options(int argc, char **argv); void enc_stats_write(OutputStream *ost, EncStats *es, diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 7b3d9a490f..c39cf43774 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -36,6 +36,7 @@ #include "libavutil/pixfmt.h" #include "libavutil/imgutils.h" #include "libavutil/samplefmt.h" +#include "libavutil/timestamp.h" // FIXME: YUV420P etc. are actually supported with full color range, // yet the latter information isn't available here. @@ -1300,3 +1301,204 @@ int filtergraph_is_simple(FilterGraph *fg) { return !fg->graph_desc; } + +int reap_filters(int flush) +{ + AVFrame *filtered_frame = NULL; + + /* Reap all buffers present in the buffer sinks */ + for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost)) { + AVFilterContext *filter; + int ret = 0; + + if (!ost->filter || !ost->filter->graph->graph) + continue; + filter = ost->filter->filter; + + filtered_frame = ost->filtered_frame; + + while (1) { + ret = av_buffersink_get_frame_flags(filter, filtered_frame, + AV_BUFFERSINK_FLAG_NO_REQUEST); + if (ret < 0) { + if (ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) { + av_log(NULL, AV_LOG_WARNING, + "Error in av_buffersink_get_frame_flags(): %s\n", av_err2str(ret)); + } else if (flush && ret == AVERROR_EOF) { + if (av_buffersink_get_type(filter) == AVMEDIA_TYPE_VIDEO) + enc_frame(ost, NULL); + } + break; + } + if (ost->finished) { + av_frame_unref(filtered_frame); + continue; + } + + if (filtered_frame->pts != AV_NOPTS_VALUE) { + AVRational tb = av_buffersink_get_time_base(filter); + ost->filter->last_pts = av_rescale_q(filtered_frame->pts, tb, + AV_TIME_BASE_Q); + filtered_frame->time_base = tb; + + if (debug_ts) + av_log(NULL, AV_LOG_INFO, "filter_raw -> pts:%s pts_time:%s time_base:%d/%d\n", + av_ts2str(filtered_frame->pts), + av_ts2timestr(filtered_frame->pts, &tb), + tb.num, tb.den); + } + + enc_frame(ost, filtered_frame); + av_frame_unref(filtered_frame); + } + } + + return 0; +} + +int ifilter_send_eof(InputFilter *ifilter, int64_t pts) +{ + int ret; + + ifilter->eof = 1; + + if (ifilter->filter) { + ret = av_buffersrc_close(ifilter->filter, pts, AV_BUFFERSRC_FLAG_PUSH); + if (ret < 0) + return ret; + } else { + // the filtergraph was never configured + if (ifilter->format < 0) { + ret = ifilter_parameters_from_codecpar(ifilter, ifilter->ist->par); + if (ret < 0) + return ret; + } + if (ifilter->format < 0 && (ifilter->type == AVMEDIA_TYPE_AUDIO || ifilter->type == AVMEDIA_TYPE_VIDEO)) { + av_log(NULL, AV_LOG_ERROR, "Cannot determine format of input stream %d:%d after EOF\n", ifilter->ist->file_index, ifilter->ist->st->index); + return AVERROR_INVALIDDATA; + } + } + + return 0; +} + +int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame, int keep_reference) +{ + FilterGraph *fg = ifilter->graph; + AVFrameSideData *sd; + int need_reinit, ret; + int buffersrc_flags = AV_BUFFERSRC_FLAG_PUSH; + + if (keep_reference) + buffersrc_flags |= AV_BUFFERSRC_FLAG_KEEP_REF; + + /* determine if the parameters for this input changed */ + need_reinit = ifilter->format != frame->format; + + switch (ifilter->ist->par->codec_type) { + case AVMEDIA_TYPE_AUDIO: + need_reinit |= ifilter->sample_rate != frame->sample_rate || + av_channel_layout_compare(&ifilter->ch_layout, &frame->ch_layout); + break; + case AVMEDIA_TYPE_VIDEO: + need_reinit |= ifilter->width != frame->width || + ifilter->height != frame->height; + break; + } + + if (!ifilter->ist->reinit_filters && fg->graph) + need_reinit = 0; + + if (!!ifilter->hw_frames_ctx != !!frame->hw_frames_ctx || + (ifilter->hw_frames_ctx && ifilter->hw_frames_ctx->data != frame->hw_frames_ctx->data)) + need_reinit = 1; + + if (sd = av_frame_get_side_data(frame, AV_FRAME_DATA_DISPLAYMATRIX)) { + if (!ifilter->displaymatrix || memcmp(sd->data, ifilter->displaymatrix, sizeof(int32_t) * 9)) + need_reinit = 1; + } else if (ifilter->displaymatrix) + need_reinit = 1; + + if (need_reinit) { + ret = ifilter_parameters_from_frame(ifilter, frame); + if (ret < 0) + return ret; + } + + /* (re)init the graph if possible, otherwise buffer the frame and return */ + if (need_reinit || !fg->graph) { + if (!ifilter_has_all_input_formats(fg)) { + AVFrame *tmp = av_frame_clone(frame); + if (!tmp) + return AVERROR(ENOMEM); + + ret = av_fifo_write(ifilter->frame_queue, &tmp, 1); + if (ret < 0) + av_frame_free(&tmp); + + return ret; + } + + ret = reap_filters(1); + if (ret < 0 && ret != AVERROR_EOF) { + av_log(NULL, AV_LOG_ERROR, "Error while filtering: %s\n", av_err2str(ret)); + return ret; + } + + ret = configure_filtergraph(fg); + if (ret < 0) { + av_log(NULL, AV_LOG_ERROR, "Error reinitializing filters!\n"); + return ret; + } + } + + ret = av_buffersrc_add_frame_flags(ifilter->filter, frame, buffersrc_flags); + if (ret < 0) { + if (ret != AVERROR_EOF) + av_log(NULL, AV_LOG_ERROR, "Error while filtering: %s\n", av_err2str(ret)); + return ret; + } + + return 0; +} + +int fg_transcode_step(FilterGraph *graph, InputStream **best_ist) +{ + int i, ret; + int nb_requests, nb_requests_max = 0; + InputFilter *ifilter; + InputStream *ist; + + *best_ist = NULL; + ret = avfilter_graph_request_oldest(graph->graph); + if (ret >= 0) + return reap_filters(0); + + if (ret == AVERROR_EOF) { + ret = reap_filters(1); + for (i = 0; i < graph->nb_outputs; i++) + close_output_stream(graph->outputs[i]->ost); + return ret; + } + if (ret != AVERROR(EAGAIN)) + return ret; + + for (i = 0; i < graph->nb_inputs; i++) { + ifilter = graph->inputs[i]; + ist = ifilter->ist; + if (input_files[ist->file_index]->eagain || + input_files[ist->file_index]->eof_reached) + continue; + nb_requests = av_buffersrc_get_nb_failed_requests(ifilter->filter); + if (nb_requests > nb_requests_max) { + nb_requests_max = nb_requests; + *best_ist = ist; + } + } + + if (!*best_ist) + for (i = 0; i < graph->nb_outputs; i++) + graph->outputs[i]->ost->unavailable = 1; + + return 0; +} From patchwork Wed Apr 19 19:52:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41274 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp744878pzb; Wed, 19 Apr 2023 12:56:06 -0700 (PDT) X-Google-Smtp-Source: AKy350ZCrByN01qouXsoiCSRqaLZBijgaC2J648O8r8LcJeP/jeFWkfzdXHij8AhzFFjD74GNTte X-Received: by 2002:a17:906:ccd2:b0:94e:4fac:d92b with SMTP id ot18-20020a170906ccd200b0094e4facd92bmr15983408ejb.58.1681934166298; Wed, 19 Apr 2023 12:56:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681934166; cv=none; d=google.com; s=arc-20160816; b=gHwsn7ykflnR1J9yfr9mXvq1ars/pG6p5KzSA5Ppi5fWg0WWqgYQKARmF4eHOijZEP wCBrq+KSB4Mik2L6GK3bdBRVifadmjLbKTI/+0B7BHMGX/VILAs82ehsd5FrC4qeFlHU 3XEdsfFuvHniStArWbOcG/mp35C0Tdq16XXgMmYmQpV10poit8RQmKJsxtb7U34dQ1V9 ubILUWj1EP2sWr1GWNgpk+EstjmazcGAhL+bSkWOZeScBX/aYE1TcEqQcuwEZqo9FcVQ LiO3WYhleIjatJtV3LaUR7t1N+BE/D2WxzIq4Dr2wEVYp2xc4AT0m9M56pgNUS6RSdMG iOcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=px/5JBpvqOdVkN0wRrF5gUQVIqFagbuTPwRW9MeznW0=; b=wB2P2xWPACNoFfBEhOUdiMNtwH3cxLMlEh8LUl2JaYAGXUwrXN88jdVWUXKYh7vA/M rpLNpzuWsXGTQds1CfM13+qRJhnFQn5dRpgIb4NqHrGpj8Y1g6DfLL20BI/FqDmf9h88 obY6aVkTEranSO9ss+RtpJCGv+IszmpIaWzfc6N2F73V38IE3qvSjyHgIFVGR+yQPCdP nWsEpbiEzSySpB0ZAOTyts2OBf6fl37zoNkT74UU0dX9SuzphRNJGcO9vyqDCC/AN0d7 U9ZVeKpnM2iVwxlVFIUVVqmL3OHFFqD9ppZ+v0LS1uQxOx5DgP5OChPO5fbfpPyb6Su/ x1ow== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id r1-20020a056402018100b0050476f7c049si15156218edv.682.2023.04.19.12.56.05; Wed, 19 Apr 2023 12:56:06 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8A16468BF8F; Wed, 19 Apr 2023 22:53:25 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7412C68BEC0 for ; Wed, 19 Apr 2023 22:53:08 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 37C952404F8 for ; Wed, 19 Apr 2023 21:53:08 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id Pw_pC5FSarCx for ; Wed, 19 Apr 2023 21:53:07 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 93CB8240D1F for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 4764E3A0787 for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Apr 2023 21:52:39 +0200 Message-Id: <20230419195243.2974-21-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230419195243.2974-1-anton@khirnov.net> References: <20230419195243.2974-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 21/25] fftools/ffmpeg: move freeing a filtergraph into a separate function 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: NxaOXiDCxmJb --- fftools/ffmpeg.c | 42 +++------------------------------------ fftools/ffmpeg.h | 2 ++ fftools/ffmpeg_filter.c | 44 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 39 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 248c22a4ff..2bf3ba5c74 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -487,51 +487,15 @@ const AVIOInterruptCB int_cb = { decode_interrupt_cb, NULL }; static void ffmpeg_cleanup(int ret) { - int i, j; + int i; if (do_benchmark) { int maxrss = getmaxrss() / 1024; av_log(NULL, AV_LOG_INFO, "bench: maxrss=%ikB\n", maxrss); } - for (i = 0; i < nb_filtergraphs; i++) { - FilterGraph *fg = filtergraphs[i]; - avfilter_graph_free(&fg->graph); - for (j = 0; j < fg->nb_inputs; j++) { - InputFilter *ifilter = fg->inputs[j]; - struct InputStream *ist = ifilter->ist; - - if (ifilter->frame_queue) { - AVFrame *frame; - while (av_fifo_read(ifilter->frame_queue, &frame, 1) >= 0) - av_frame_free(&frame); - av_fifo_freep2(&ifilter->frame_queue); - } - av_freep(&ifilter->displaymatrix); - if (ist->sub2video.sub_queue) { - AVSubtitle sub; - while (av_fifo_read(ist->sub2video.sub_queue, &sub, 1) >= 0) - avsubtitle_free(&sub); - av_fifo_freep2(&ist->sub2video.sub_queue); - } - av_buffer_unref(&ifilter->hw_frames_ctx); - av_freep(&ifilter->name); - av_freep(&fg->inputs[j]); - } - av_freep(&fg->inputs); - for (j = 0; j < fg->nb_outputs; j++) { - OutputFilter *ofilter = fg->outputs[j]; - - avfilter_inout_free(&ofilter->out_tmp); - av_freep(&ofilter->name); - av_channel_layout_uninit(&ofilter->ch_layout); - av_freep(&fg->outputs[j]); - } - av_freep(&fg->outputs); - av_freep(&fg->graph_desc); - - av_freep(&filtergraphs[i]); - } + for (i = 0; i < nb_filtergraphs; i++) + fg_free(&filtergraphs[i]); av_freep(&filtergraphs); /* close files */ diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 07c1fc7ed6..95591f4bba 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -814,6 +814,8 @@ int ifilter_has_all_input_formats(FilterGraph *fg); */ FilterGraph *fg_create(char *graph_desc); +void fg_free(FilterGraph **pfg); + /** * Perform a step of transcoding for the specified filter graph. * diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index c39cf43774..cfd93a0f9d 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -189,6 +189,50 @@ static OutputFilter *ofilter_alloc(FilterGraph *fg) return ofilter; } +void fg_free(FilterGraph **pfg) +{ + FilterGraph *fg = *pfg; + + if (!fg) + return; + + avfilter_graph_free(&fg->graph); + for (int j = 0; j < fg->nb_inputs; j++) { + InputFilter *ifilter = fg->inputs[j]; + struct InputStream *ist = ifilter->ist; + + if (ifilter->frame_queue) { + AVFrame *frame; + while (av_fifo_read(ifilter->frame_queue, &frame, 1) >= 0) + av_frame_free(&frame); + av_fifo_freep2(&ifilter->frame_queue); + } + av_freep(&ifilter->displaymatrix); + if (ist->sub2video.sub_queue) { + AVSubtitle sub; + while (av_fifo_read(ist->sub2video.sub_queue, &sub, 1) >= 0) + avsubtitle_free(&sub); + av_fifo_freep2(&ist->sub2video.sub_queue); + } + av_buffer_unref(&ifilter->hw_frames_ctx); + av_freep(&ifilter->name); + av_freep(&fg->inputs[j]); + } + av_freep(&fg->inputs); + for (int j = 0; j < fg->nb_outputs; j++) { + OutputFilter *ofilter = fg->outputs[j]; + + avfilter_inout_free(&ofilter->out_tmp); + av_freep(&ofilter->name); + av_channel_layout_uninit(&ofilter->ch_layout); + av_freep(&fg->outputs[j]); + } + av_freep(&fg->outputs); + av_freep(&fg->graph_desc); + + av_freep(pfg); +} + FilterGraph *fg_create(char *graph_desc) { FilterGraph *fg; From patchwork Wed Apr 19 19:52:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41263 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp744158pzb; Wed, 19 Apr 2023 12:54:26 -0700 (PDT) X-Google-Smtp-Source: AKy350ax0If/Z+XNquAx5QCppj0WDUDbnzwNo5inRyynP3lXP7H9YWYiktg35Vv+b18bbsfgG1vN X-Received: by 2002:a17:906:b091:b0:94f:8f37:d54 with SMTP id x17-20020a170906b09100b0094f8f370d54mr9772363ejy.44.1681934065792; Wed, 19 Apr 2023 12:54:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681934065; cv=none; d=google.com; s=arc-20160816; b=JHnh2o6bkfj8Y3jbUjrlwRv5rHCiOYqKtcAU89xVoy2GW1kgLQW/VYSko4M2ryty9A FjjMbvCqwnGNgqaeeC9VlPZjlBV7QoJGKO72Veke88se9YhEkqccaphE8yZcpR9v/MgE n5F8lI/8rY2D84agdZZSswoRBdRbNPTEHgGgTHFvN6h2itBVB2JiYop7+v6iqD6P8Ndx TCqhItNzPVbTBufj8rRxju1yoRvvXHDP4yD6+DJly2j6t1ReyvOzwoybaT9ZmykYKZEu FvJxifcUWlS0C5flI30/iDjBmBchmqGjfzp1wK4EmzjPqIskm5wpgVbAeS9uOSmyRWgr QlPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=5uX8WaIGdpoG39GiqGG/S8AG1JI9F0paGaOuGrj17vA=; b=THYGz7QBCE2H0PXjPnKbhMvrkln2V2lBJUhDHMftZ+91EEGfKXRExj3z0aGyJWpRst syR14UzL85HphK2mGV88NErW6jo8C9HxL5ZqKQcLhPMzOhiK1krDcMfecZTDEN/Bc/H6 9wzWAsxQA2YhWBo75mlOnqKVBSdYWB6fhBscTNeHnwYD3FtBmi89+scHkNlJl3dBmU1m Im+BxiEYdXD0lQfHXarOPIy5pDPkraAYenSuSJriBhe4d8Hb48B3cmzOf9kTzNF7Uw3i 3cZj+/lAXZys4BuL3sLy+2HIUm3dS0gNan3Z6kZQ3o0d1aeaEuOf+FHeijvl2q8Ic6KL drnA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id wl23-20020a170907311700b009333dc25e58si15124641ejb.109.2023.04.19.12.54.25; Wed, 19 Apr 2023 12:54: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; 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 2D16868BEE6; Wed, 19 Apr 2023 22:53:14 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D9DE968BE56 for ; Wed, 19 Apr 2023 22:53:05 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id CAB5A2404EE for ; Wed, 19 Apr 2023 21:53:04 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id riqGjoUHQ3sa for ; Wed, 19 Apr 2023 21:53:04 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 66860240D1A for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 533883A1049 for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Apr 2023 21:52:40 +0200 Message-Id: <20230419195243.2974-22-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230419195243.2974-1-anton@khirnov.net> References: <20230419195243.2974-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 22/25] fftools/ffmpeg_filter: reindent after previous commit 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: CQoSzWZR0Idq --- fftools/ffmpeg_filter.c | 62 ++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index cfd93a0f9d..b26160b375 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -196,39 +196,39 @@ void fg_free(FilterGraph **pfg) if (!fg) return; - avfilter_graph_free(&fg->graph); - for (int j = 0; j < fg->nb_inputs; j++) { - InputFilter *ifilter = fg->inputs[j]; - struct InputStream *ist = ifilter->ist; - - if (ifilter->frame_queue) { - AVFrame *frame; - while (av_fifo_read(ifilter->frame_queue, &frame, 1) >= 0) - av_frame_free(&frame); - av_fifo_freep2(&ifilter->frame_queue); - } - av_freep(&ifilter->displaymatrix); - if (ist->sub2video.sub_queue) { - AVSubtitle sub; - while (av_fifo_read(ist->sub2video.sub_queue, &sub, 1) >= 0) - avsubtitle_free(&sub); - av_fifo_freep2(&ist->sub2video.sub_queue); - } - av_buffer_unref(&ifilter->hw_frames_ctx); - av_freep(&ifilter->name); - av_freep(&fg->inputs[j]); + avfilter_graph_free(&fg->graph); + for (int j = 0; j < fg->nb_inputs; j++) { + InputFilter *ifilter = fg->inputs[j]; + struct InputStream *ist = ifilter->ist; + + if (ifilter->frame_queue) { + AVFrame *frame; + while (av_fifo_read(ifilter->frame_queue, &frame, 1) >= 0) + av_frame_free(&frame); + av_fifo_freep2(&ifilter->frame_queue); } - av_freep(&fg->inputs); - for (int j = 0; j < fg->nb_outputs; j++) { - OutputFilter *ofilter = fg->outputs[j]; - - avfilter_inout_free(&ofilter->out_tmp); - av_freep(&ofilter->name); - av_channel_layout_uninit(&ofilter->ch_layout); - av_freep(&fg->outputs[j]); + av_freep(&ifilter->displaymatrix); + if (ist->sub2video.sub_queue) { + AVSubtitle sub; + while (av_fifo_read(ist->sub2video.sub_queue, &sub, 1) >= 0) + avsubtitle_free(&sub); + av_fifo_freep2(&ist->sub2video.sub_queue); } - av_freep(&fg->outputs); - av_freep(&fg->graph_desc); + av_buffer_unref(&ifilter->hw_frames_ctx); + av_freep(&ifilter->name); + av_freep(&fg->inputs[j]); + } + av_freep(&fg->inputs); + for (int j = 0; j < fg->nb_outputs; j++) { + OutputFilter *ofilter = fg->outputs[j]; + + avfilter_inout_free(&ofilter->out_tmp); + av_freep(&ofilter->name); + av_channel_layout_uninit(&ofilter->ch_layout); + av_freep(&fg->outputs[j]); + } + av_freep(&fg->outputs); + av_freep(&fg->graph_desc); av_freep(pfg); } From patchwork Wed Apr 19 19:52:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41270 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp744638pzb; Wed, 19 Apr 2023 12:55:31 -0700 (PDT) X-Google-Smtp-Source: AKy350bfJAlezMYJmHfovwceFuEX5C6k6DIxR2CcOq3LYDyPeQxq0V7mLvRzsKaYPcmgYqNpBxqE X-Received: by 2002:aa7:cf11:0:b0:506:955d:a732 with SMTP id a17-20020aa7cf11000000b00506955da732mr6614317edy.25.1681934131083; Wed, 19 Apr 2023 12:55:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681934131; cv=none; d=google.com; s=arc-20160816; b=ZuhbF/cnAugeopcBwC1rJla5GEjtc1OE5UMeffRIvvDOIJiuE0bow0uMOvpJ1hhtNb AEQFPQaqEwIBVbaK3L+DvlweEsttg4FXKLTPROou9ZRagpjTbz5hq0bZhw1Fh5yuvsNv FWtq1s7o4C1LyYSEUK7tMs3ObfiVfPXubNwZZSEdWrmEWOrMv4Bzs2DTDgC45wx75oJ8 nluWQAhyTI2JxrGCD4n+Pa9UPtshNEOw0lCgWYavToa8dCu5xTBAQZ8NOAwpPqkxQtfc 9oS448YYJtICNLMAdPC1QZleyF0Zo/yBepB4WCHqdWRImzhrCTJnJ0hJ//uc0LYBa2BA G43w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=9do6WFJwOWquoBxjNTos2/1EFh38QAr9Nfqf7H/RXjI=; b=cGBxxrjjkPp4aWeB7hJhV/qtU8DuN4vJIKAC4HCNP4jpMdP7DkEN9wfJRxy1fTBBi1 hqQKSom3L7+n6J4Pbfd7NBu8V45esNEh0ez7Pj+SB9+M2Q60cCd7mVpV88R2iwpFYXIF FB1ugC5g0Z5LwAcrsg/emyIexJ4GOFkqI33xpc9rE00iYl/Gb0knacVj60VdqEe8X9im tGeKgi6KPMLDNk8z2ifcwbSSZpJIZzCzlWk/KLe4xT3+njxPgqQmXhecOeKAvl8JaUSh 3iDpehYim68gm8DJopwBlCvGsioJlUpxxGtRe04unmGeaEQ3MBABkWneaRKei6qMxh8r 1Jig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id i10-20020aa7c70a000000b00506b2449cc3si5815621edq.240.2023.04.19.12.55.30; Wed, 19 Apr 2023 12:55:31 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5654968BF63; Wed, 19 Apr 2023 22:53:21 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AD2C468BE61 for ; Wed, 19 Apr 2023 22:53:07 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 6BFCF2404F8 for ; Wed, 19 Apr 2023 21:53:07 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id gQoBrjFUBER9 for ; Wed, 19 Apr 2023 21:53:06 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 711D5240D1B for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 5EC823A07F8 for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Apr 2023 21:52:41 +0200 Message-Id: <20230419195243.2974-23-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230419195243.2974-1-anton@khirnov.net> References: <20230419195243.2974-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 23/25] fftools/ffmpeg_filter: add filtergraph private data 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: ESenHlzBv9i7 Start by moving OutputStream.filtered_frame to it, which really belong to the filtergraph rather than the output stream. --- fftools/ffmpeg.h | 1 - fftools/ffmpeg_filter.c | 31 ++++++++++++++++++++++++++----- fftools/ffmpeg_mux.c | 1 - fftools/ffmpeg_mux_init.c | 4 ---- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 95591f4bba..71f348da01 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -603,7 +603,6 @@ typedef struct OutputStream { Encoder *enc; AVCodecContext *enc_ctx; - AVFrame *filtered_frame; AVPacket *pkt; int64_t last_dropped; diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index b26160b375..edfefc9d45 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -38,6 +38,18 @@ #include "libavutil/samplefmt.h" #include "libavutil/timestamp.h" +typedef struct FilterGraphPriv { + FilterGraph fg; + + // frame for temporarily holding output from the filtergraph + AVFrame *frame; +} FilterGraphPriv; + +static FilterGraphPriv *fgp_from_fg(FilterGraph *fg) +{ + return (FilterGraphPriv*)fg; +} + // FIXME: YUV420P etc. are actually supported with full color range, // yet the latter information isn't available here. static const enum AVPixelFormat *get_compliance_normal_pix_fmts(const AVCodec *codec, const enum AVPixelFormat default_formats[]) @@ -192,9 +204,11 @@ static OutputFilter *ofilter_alloc(FilterGraph *fg) void fg_free(FilterGraph **pfg) { FilterGraph *fg = *pfg; + FilterGraphPriv *fgp; if (!fg) return; + fgp = fgp_from_fg(fg); avfilter_graph_free(&fg->graph); for (int j = 0; j < fg->nb_inputs; j++) { @@ -230,17 +244,23 @@ void fg_free(FilterGraph **pfg) av_freep(&fg->outputs); av_freep(&fg->graph_desc); + av_frame_free(&fgp->frame); + av_freep(pfg); } FilterGraph *fg_create(char *graph_desc) { - FilterGraph *fg; + FilterGraphPriv *fgp = allocate_array_elem(&filtergraphs, sizeof(*fgp), &nb_filtergraphs); + FilterGraph *fg = &fgp->fg; - fg = ALLOC_ARRAY_ELEM(filtergraphs, nb_filtergraphs); fg->index = nb_filtergraphs - 1; fg->graph_desc = graph_desc; + fgp->frame = av_frame_alloc(); + if (!fgp->frame) + report_and_exit(AVERROR(ENOMEM)); + return fg; } @@ -1348,18 +1368,19 @@ int filtergraph_is_simple(FilterGraph *fg) int reap_filters(int flush) { - AVFrame *filtered_frame = NULL; - /* Reap all buffers present in the buffer sinks */ for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost)) { + FilterGraphPriv *fgp; + AVFrame *filtered_frame; AVFilterContext *filter; int ret = 0; if (!ost->filter || !ost->filter->graph->graph) continue; filter = ost->filter->filter; + fgp = fgp_from_fg(ost->filter->graph); - filtered_frame = ost->filtered_frame; + filtered_frame = fgp->frame; while (1) { ret = av_buffersink_get_frame_flags(filter, filtered_frame, diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 368a7000a9..2a9db199c1 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -839,7 +839,6 @@ static void ost_free(OutputStream **post) av_bsf_free(&ms->bsf_ctx); - av_frame_free(&ost->filtered_frame); av_packet_free(&ost->pkt); av_dict_free(&ost->encoder_opts); diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 7a2db9f0e8..2c0e2faf4a 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -1026,10 +1026,6 @@ static OutputStream *ost_add(Muxer *mux, const OptionsContext *o, av_strlcat(ms->log_name, "/copy", sizeof(ms->log_name)); } - ost->filtered_frame = av_frame_alloc(); - if (!ost->filtered_frame) - report_and_exit(AVERROR(ENOMEM)); - ost->pkt = av_packet_alloc(); if (!ost->pkt) report_and_exit(AVERROR(ENOMEM)); From patchwork Wed Apr 19 19:52:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41275 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp744974pzb; Wed, 19 Apr 2023 12:56:19 -0700 (PDT) X-Google-Smtp-Source: AKy350b/OElbmdHAPPJlpJB+06qDS6M/f/vf7p0urlueqjgJuOwBBUxhUWcHmLSe95W/KlnlQwFc X-Received: by 2002:a17:906:6d51:b0:94a:a419:f382 with SMTP id a17-20020a1709066d5100b0094aa419f382mr16206383ejt.12.1681934179129; Wed, 19 Apr 2023 12:56:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681934179; cv=none; d=google.com; s=arc-20160816; b=vs+45zQ1BbHKIri2Yytb8If3t+RyzB8eRLbmV8c5in8likf/KmhXtTQm0eyhCSlKgn lpk1laHa7bSKMTygBS1H6pt5HVOpp5ynR6bPL58io6rODTYZ+JJhJynNnLOssfdMBHsV nnTRuW69RBl2HcZP/Y7UrubuNsa3V3JNVWagW0lSSWroklW0ilct2h67sS+tzTAqLcx/ LCZjfTM4O6FW8a2Xzw66iOt2V6XwA7VxYoO5YQE5dzwjkqrEXUS9bvk5Uvd8Uqyi5ZFH TSKOdYx5NUyqKN59RtDSxGCv3vdNZW5JYTzWrkxMWDf2MPBWdG1nS0N3e0Xoiwqr/493 Ag6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=z/WbXzL6euevizvu88p14QBlIBBX6bhhjNEPjBPhh/g=; b=D5WkN6cbU7gQ3lcuWJm5Vz7OrX1JlWgsvgEJKk2X7QM4b76VVSrXj6luI1jiXvKOJz JX5eGXVnQrgUt2sRCQdxXVOpO0NzjuYqHq54AFM/ndUeekgubbjdr271OTx1GqTWU3Lt eLdA07Gh/oRrg4xHkSyp+KrrmN3igqavJL2Lr6sN4BBi4+UsH4ER+jIAgQLxDTGLv8E/ skY8AHvvNT152qPNRxNGbPN3+u5e4BqnJStWdvSerVRPGOa0Nx9A8jW10VKvWlFwcACq aBIAucDOTEFbQHCng8Z1emdWLoWTDTSe5uVTlomqjw2ZOTLT382OHmukMudF+m75gmAX F79g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id e22-20020a056402089600b005067c1fdb13si14492241edy.641.2023.04.19.12.56.14; Wed, 19 Apr 2023 12:56:19 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 73D8468BF95; Wed, 19 Apr 2023 22:53:26 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 742EE68BEF8 for ; Wed, 19 Apr 2023 22:53:08 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 140FD2404EE for ; Wed, 19 Apr 2023 21:53:08 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 3-dhj8LzCSil for ; Wed, 19 Apr 2023 21:53:07 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 8C8A1240D1E for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 697E43A0D68 for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Apr 2023 21:52:42 +0200 Message-Id: <20230419195243.2974-24-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230419195243.2974-1-anton@khirnov.net> References: <20230419195243.2974-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 24/25] fftools/ffmpeg: deprecate -adrift_threshold 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: TeIFs64jeOZo This option has had no effect since -async was removed in 3d86a13b47b726e49c2d780c5f723c290e8a36b4 --- doc/ffmpeg.texi | 6 ------ fftools/ffmpeg.h | 2 +- fftools/ffmpeg_opt.c | 14 ++++++++++++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index cb8aa13df2..23bc03e11a 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -1748,12 +1748,6 @@ The default is -1.1. One possible usecase is to avoid framedrops in case of noisy timestamps or to increase frame drop precision in case of exact timestamps. -@item -adrift_threshold @var{time} -Set the minimum difference between timestamps and audio data (in seconds) to trigger -adding/dropping samples to make it match the timestamps. This option effectively is -a threshold to select between hard (add/drop) and soft (squeeze/stretch) compensation. -@code{-async} must be set to a positive value. - @item -apad @var{parameters} (@emph{output,per-stream}) Pad the output audio stream(s). This is the same as applying @code{-af apad}. Argument is a string of filter parameters composed the same as with the @code{apad} filter. diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 71f348da01..e3530d1699 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -55,6 +55,7 @@ #define FFMPEG_OPT_MAP_SYNC 1 #define FFMPEG_ROTATION_METADATA 1 #define FFMPEG_OPT_QPHIST 1 +#define FFMPEG_OPT_ADRIFT_THRESHOLD 1 enum VideoSyncMethod { VSYNC_AUTO = -1, @@ -727,7 +728,6 @@ extern int nb_filtergraphs; extern char *vstats_filename; extern char *sdp_filename; -extern float audio_drift_threshold; extern float dts_delta_threshold; extern float dts_error_threshold; diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 408ef121b7..24208fa068 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -1347,6 +1347,14 @@ static int opt_qphist(void *optctx, const char *opt, const char *arg) } #endif +#if FFMPEG_OPT_ADRIFT_THRESHOLD +static int opt_adrift_threshold(void *optctx, const char *opt, const char *arg) +{ + av_log(NULL, AV_LOG_WARNING, "Option -%s is deprecated and has no effect\n", opt); + return 0; +} +#endif + #define OFFSET(x) offsetof(OptionsContext, x) const OptionDef options[] = { /* main options */ @@ -1453,8 +1461,10 @@ const OptionDef options[] = { "set video sync method globally; deprecated, use -fps_mode", "" }, { "frame_drop_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, { &frame_drop_threshold }, "frame drop threshold", "" }, - { "adrift_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, { &audio_drift_threshold }, - "audio drift threshold", "threshold" }, +#if FFMPEG_OPT_ADRIFT_THRESHOLD + { "adrift_threshold", HAS_ARG | OPT_EXPERT, { .func_arg = opt_adrift_threshold }, + "deprecated, does nothing", "threshold" }, +#endif { "copyts", OPT_BOOL | OPT_EXPERT, { ©_ts }, "copy timestamps" }, { "start_at_zero", OPT_BOOL | OPT_EXPERT, { &start_at_zero }, From patchwork Wed Apr 19 19:52:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41271 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp744702pzb; Wed, 19 Apr 2023 12:55:40 -0700 (PDT) X-Google-Smtp-Source: AKy350ZtDJux4myaoBON5wpERWRGkzPFcmWqC/ksLzSpHCYihksP/hy9BDKlMmQSqTKKi28hgDdi X-Received: by 2002:a17:906:f915:b0:953:45ef:1438 with SMTP id lc21-20020a170906f91500b0095345ef1438mr4024662ejb.27.1681934140534; Wed, 19 Apr 2023 12:55:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681934140; cv=none; d=google.com; s=arc-20160816; b=NPMqwxP4elEfXC4iMJqIttRCdGPlCHrxvEyBUPo+UIUbAzkBhv9ooBklHPsfBAfuBE KGckdoKmcCOtCV8BP7uXvLWOj3iQzBL4ezNF1t4RrVIue1PN/piykJrXP1lQgBEshQoO msD/AtWxFKbo0H/gEm19YFERZPGn/J/fNWr7L+jnWtjN3nplTyqY3EKu86Q5IRnkuSCp qpeJvo0TBAi6sAwb3hkskZFVbu0F9sk5uxzr+1vwxoHUt77lpKG8/kQqA5bOGsNAhDfN hcvNyJwi0y9aolVe4DiPOWCUZhLkLlW+yFDcNcU40TZlqqWdgqfFH/PNPY3hxGLfupvC gsGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=z36DqR+rMUS7x021WIGBfrKRJXt8j+HyniKZG606VPA=; b=GBwDaQN+YZnEo6kYuHZDG/t27lU4f5LwmcXsULM8sPInGR1dgwI5qAgOwu5dAB2QZk OyEGQKRoCstAU9ikrKxhGhOW5zgQg53FAVwAICPhPCZb/qyWK3tux3CMDcVqpRgzJJzG EYQgDntPy3Z7n3DsNpyz6EW+3PLCCaHVwnrJpYfyc1yg4uZzETkyiyMct4IV50C6qXMl MRoBxc7+VmsoKc7rTEBVBhb9Ip/h004TSa5MxT0dVI0JH7k6aZ1TX0HPTS9Wx0R2Nj/1 lRpT6rTJRZWJ2ljsr0Ggc4O59zdJsNr2iuXtydXWI5tz8W66af+6E+dC9bFIHBYVAGKl hz3Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id p22-20020a170907911600b0094fbd6d6c6csi5660626ejq.629.2023.04.19.12.55.39; Wed, 19 Apr 2023 12:55:40 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6B3FD68BF69; Wed, 19 Apr 2023 22:53:22 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BB88A68BEE9 for ; Wed, 19 Apr 2023 22:53:07 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 8C1F22405B5 for ; Wed, 19 Apr 2023 21:53:07 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id O5IihZhlbdvX for ; Wed, 19 Apr 2023 21:53:07 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 8C861240D1D for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 7431D3A037D for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Apr 2023 21:52:43 +0200 Message-Id: <20230419195243.2974-25-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230419195243.2974-1-anton@khirnov.net> References: <20230419195243.2974-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 25/25] fftools/ffmpeg_filter: make ifilter_parameters_from_frame() static 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: 9twVXhNTzGkE It is no longer used outside of this file. --- fftools/ffmpeg.h | 1 - fftools/ffmpeg_filter.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index e3530d1699..43073f9a3c 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -801,7 +801,6 @@ void sub2video_update(InputStream *ist, int64_t heartbeat_pts, AVSubtitle *sub); int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame, int keep_reference); int ifilter_send_eof(InputFilter *ifilter, int64_t pts); -int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame); int ifilter_parameters_from_codecpar(InputFilter *ifilter, AVCodecParameters *par); int ifilter_has_all_input_formats(FilterGraph *fg); diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index edfefc9d45..4b7b34b05d 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1329,7 +1329,7 @@ fail: return ret; } -int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame) +static int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame) { AVFrameSideData *sd; int ret;