From patchwork Wed May 17 10:20:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41678 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:ba91:b0:105:feb:71f2 with SMTP id fb17csp1079511pzb; Wed, 17 May 2023 03:24:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7purN/6nkybq2xnoO7KFmlFhLPfFvUMi+aZRy0AVP8xnOOQJaJ6CdxPE/r6QM4nQDg/C85 X-Received: by 2002:a17:907:7b92:b0:94e:edf3:dccd with SMTP id ne18-20020a1709077b9200b0094eedf3dccdmr39328434ejc.0.1684319059044; Wed, 17 May 2023 03:24:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684319059; cv=none; d=google.com; s=arc-20160816; b=T9lJtayzJnDT0pRZl6IFX0fAcObY90inI82jKELVItasd0d3bQID795sXXylWy23JJ /uXMFz/KkYLjSbxvSkVXzaxoDn3wWspQaNlS6fBN3571ruw9fwICZn180Loyl8a5aNok LD5voyGD0uJ3M8cpcOeOzxcq2SAOC2XiW8bE5LUwsRQm5gglE3hXhw+HYqzYkkgWYw8g tx2KfddxaTNrYdyc1DZCt7++E+32zyEyeEK+T5g/iNAWRA9s7pCs0gM/4+v1QV9pDtf/ Qg62ciQYo6tHENwvwkM0Q84pnTODch9TaMbSvD3b5qyQZizUGZqxc0Tv9eeaSPDc3G/6 pf8Q== 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=F1bUsXyv+4YpNK3lJEj927QFwny3sXOBzgNAkT2+bn0=; b=F3mCEXwR+OhtF7IsMn8q9Yz7juXND3HTfs1BWAMwnltp/gZ/axq6lor8XmKohl283z JA8LDuFGIjzerF7bTclQzDYoGnk261uApxdtHLkPTWxKCqbbEjJv1ffVc5GhCbijp1Tl PNA5k6o4U8lZNjKEiPxtNcLjZlVQeZUuNS5XnY2OwyXSUmd96RedZ92nG3mYWCm6egOv zxHcaxcBk5MWd89ehL8i94Dj+kOQPLoA0rr+iNJ+9OzGMmOjn69j9X3Nr0FSEo9Yypr6 bQOZnCmYDaMhVEEjytDI0HoeGUHRoIPvUzk90Xsb7W6RJEqhkBo0EXjb8Xt2tT9pyHO4 l87Q== 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 d13-20020a17090648cd00b009662eab40basi15384777ejt.415.2023.05.17.03.24.18; Wed, 17 May 2023 03:24: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 893A068C1BC; Wed, 17 May 2023 13:21: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 3BFD268C131 for ; Wed, 17 May 2023 13:20:53 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id A46122405F9 for ; Wed, 17 May 2023 12:20:51 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id y5-VCsWyRTiN for ; Wed, 17 May 2023 12:20:51 +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 1B6A12406CD for ; Wed, 17 May 2023 12:20:46 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 3DE1D3A1AF1 for ; Wed, 17 May 2023 12:20:40 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 17 May 2023 12:20:12 +0200 Message-Id: <20230517102029.541-19-anton@khirnov.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230517102029.541-1-anton@khirnov.net> References: <20230517102029.541-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 19/36] fftools/ffmpeg_filter: keep track of the real filter input type X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 1TiEmfI2lvSQ Avoid extracting it from various remote sources. --- fftools/ffmpeg_filter.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 5656fa87df..c699431831 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -60,8 +60,11 @@ typedef struct InputFilterPriv { // used to hold submitted input AVFrame *frame; - // AVMEDIA_TYPE_SUBTITLE for sub2video + // filter data type enum AVMediaType type; + // source data type: AVMEDIA_TYPE_SUBTITLE for sub2video, + // same as type otherwise + enum AVMediaType type_src; int eof; @@ -267,7 +270,9 @@ static InputFilter *ifilter_alloc(FilterGraph *fg, InputStream *ist) ifp->format = -1; ifp->fallback.format = -1; ifp->ist = ist; - ifp->type = ist->st->codecpar->codec_type; + ifp->type_src = ist->st->codecpar->codec_type; + ifp->type = ifp->type_src == AVMEDIA_TYPE_SUBTITLE ? + AVMEDIA_TYPE_VIDEO : ifp->type_src; ifp->frame_queue = av_fifo_alloc2(8, sizeof(AVFrame*), AV_FIFO_FLAG_AUTO_GROW); if (!ifp->frame_queue) @@ -1205,7 +1210,7 @@ static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter, static int configure_input_filter(FilterGraph *fg, InputFilter *ifilter, AVFilterInOut *in) { - switch (avfilter_pad_get_type(in->filter_ctx->input_pads, in->pad_idx)) { + switch (ifp_from_ifilter(ifilter)->type) { case AVMEDIA_TYPE_VIDEO: return configure_input_video_filter(fg, ifilter, in); case AVMEDIA_TYPE_AUDIO: return configure_input_audio_filter(fg, ifilter, in); default: av_assert0(0); return 0; @@ -1459,8 +1464,8 @@ int ifilter_has_all_input_formats(FilterGraph *fg) int i; for (i = 0; i < fg->nb_inputs; i++) { InputFilterPriv *ifp = ifp_from_ifilter(fg->inputs[i]); - if (ifp->format < 0 && (ifp->type == AVMEDIA_TYPE_AUDIO || - ifp->type == AVMEDIA_TYPE_VIDEO)) + if (ifp->format < 0 && (ifp->type_src == AVMEDIA_TYPE_AUDIO || + ifp->type_src == AVMEDIA_TYPE_VIDEO)) return 0; } return 1; @@ -1564,7 +1569,9 @@ int ifilter_send_eof(InputFilter *ifilter, int64_t pts, AVRational tb) } } - if (ifp->format < 0 && (ifp->type == AVMEDIA_TYPE_AUDIO || ifp->type == AVMEDIA_TYPE_VIDEO)) { + if (ifp->format < 0 && + (ifp->type_src == AVMEDIA_TYPE_AUDIO || + ifp->type_src == AVMEDIA_TYPE_VIDEO)) { av_log(NULL, AV_LOG_ERROR, "Cannot determine format of input stream %d:%d after EOF\n", ifp->ist->file_index, ifp->ist->st->index); @@ -1585,7 +1592,7 @@ int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame, int keep_reference) /* determine if the parameters for this input changed */ need_reinit = ifp->format != frame->format; - switch (ifp->ist->par->codec_type) { + switch (ifp->type) { case AVMEDIA_TYPE_AUDIO: need_reinit |= ifp->sample_rate != frame->sample_rate || av_channel_layout_compare(&ifp->ch_layout, &frame->ch_layout);