From patchwork Thu Apr 13 14:12:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41155 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1288412pzb; Thu, 13 Apr 2023 07:18:04 -0700 (PDT) X-Google-Smtp-Source: AKy350bfuObpAIYH4OcaSkwuST3sPZSWOuSU8IirIUcFGwNXU7l3h6+ohGarNcS5E18vzUriMo1n X-Received: by 2002:a17:907:210d:b0:930:9f89:65ef with SMTP id qn13-20020a170907210d00b009309f8965efmr2922533ejb.11.1681395484540; Thu, 13 Apr 2023 07:18:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681395484; cv=none; d=google.com; s=arc-20160816; b=fmVdCy5o3c2l0mwSyrQ9/Xgx8oZJ1Blp4buqS1kNB71lgB7d78XnHUbazPViD+tYO0 r+l26WWyMQ7ID8a7k9gnj3N+r4MoAlN9P4Jifxwwe+86g7N7cYCj6cUjztFvKgGhDrxd OtTOa/3ensRSFLsTcd2vNE07xhAbG6m3NnuTxz9jUi9Pq9TC4EE3oZH7ExSW1RmJ3WMf VHUZ134olSiT1kSx0bRZHYqpqPmr0YHiqSKJ195dzt7V9Ewf6rU0VN0al+cwwKpZSZZ9 0iMMg2Cex4TcZJxGvb4oyTYgUOE4zL9E5D7TDV5okhWsrFQycvVldb75WXDoZ5abSAWe lmIQ== 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=aF8wG3G/uohGr0E3o3qY1lXA+yMMsw0YCKF/srfIk30=; b=SY++8NjVpnawvGBaZXbY5WfuS0XGOqmloDQJz6ETCVTzHxaMxUjUB9zmjgE/gF2gRJ CswI6KdFer2jUU11PjS9s3XVOpwFOBMXCuzQ6G8IGrGIjk8BBAvxE1XR3NrP7w2q8URv 2h4Hk13mFjZ5Xj/WLH0yTNrfxvWuZbAT/pb9s+5roJcDJZcWqs3+PEaclmihd+OY4kCZ T9Q3NxC5+sgECRklv7PojdP+SLqHx38X9gbchpIFugVkQ8REAl3zTUfrl5NbHzvr8wPY +7yRAPHj/n59PqAYYBB+uwrbF6nxB9kt0i9EVZOJTSUNqs3k7Laba/yWQ+ozGxFtLNNj VAuA== 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 n19-20020aa7db53000000b00501d70c10bbsi1917402edt.72.2023.04.13.07.18.04; Thu, 13 Apr 2023 07:18:04 -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 0D54268BEC0; Thu, 13 Apr 2023 17:16: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 5CBA868BE34 for ; Thu, 13 Apr 2023 17:15:59 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 84E4D2405B5 for ; Thu, 13 Apr 2023 16:15:56 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id tE84ITRLB44G for ; Thu, 13 Apr 2023 16:15: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 4147F2405EC for ; Thu, 13 Apr 2023 16:15:53 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 3006A3A039B for ; Thu, 13 Apr 2023 16:15:53 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 13 Apr 2023 16:12:07 +0200 Message-Id: <20230413141223.17245-9-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230413141223.17245-1-anton@khirnov.net> References: <20230413141223.17245-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 09/25] fftools/ffmpeg: add a function adding a destination filter for InputStream 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: 4hwJLMhRT/4M This way filtering code does not directly mess with InputStream internals. Will become more useful in following commits. --- fftools/ffmpeg.h | 1 + fftools/ffmpeg_demux.c | 6 ++++++ fftools/ffmpeg_filter.c | 8 +++----- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 17076f018d..d25377514e 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -880,6 +880,7 @@ void ifile_close(InputFile **f); int ifile_get_packet(InputFile *f, AVPacket **pkt); void ist_output_add(InputStream *ist, OutputStream *ost); +void ist_filter_add(InputStream *ist, InputFilter *ifilter); /* iterate over all input streams in all input files; * pass NULL to start iteration */ diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index b9849d1669..2d46dbf876 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -567,6 +567,12 @@ void ist_output_add(InputStream *ist, OutputStream *ost) ist->outputs[ist->nb_outputs - 1] = ost; } +void ist_filter_add(InputStream *ist, InputFilter *ifilter) +{ + GROW_ARRAY(ist->filters, ist->nb_filters); + ist->filters[ist->nb_filters - 1] = ifilter; +} + static const AVCodec *choose_decoder(const OptionsContext *o, AVFormatContext *s, AVStream *st, enum HWAccelID hwaccel_id, enum AVHWDeviceType hwaccel_device_type) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 584f51ac3f..d2a185cf98 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -212,12 +212,11 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost) if (!ifilter->frame_queue) report_and_exit(AVERROR(ENOMEM)); - GROW_ARRAY(ist->filters, ist->nb_filters); - ist->filters[ist->nb_filters - 1] = ifilter; - GROW_ARRAY(filtergraphs, nb_filtergraphs); filtergraphs[nb_filtergraphs - 1] = fg; + ist_filter_add(ist, ifilter); + return 0; } @@ -319,8 +318,7 @@ static void init_input_filter(FilterGraph *fg, AVFilterInOut *in) if (!ifilter->frame_queue) report_and_exit(AVERROR(ENOMEM)); - GROW_ARRAY(ist->filters, ist->nb_filters); - ist->filters[ist->nb_filters - 1] = ifilter; + ist_filter_add(ist, ifilter); } static int read_binary(const char *path, uint8_t **data, int *len)