From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id ED9F34038A for ; Wed, 14 Feb 2024 18:26:05 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6B0C868D233; Wed, 14 Feb 2024 20:24:56 +0200 (EET) Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4845568D228 for ; Wed, 14 Feb 2024 20:24:47 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=sibum0Tz; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 9F2A94492 for ; Wed, 14 Feb 2024 19:24:42 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id zpXrLATQlfhL for ; Wed, 14 Feb 2024 19:24:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1707935078; bh=vwl8u+FRaLdugeRToHcvJju3qgXqivtW55Plxw0+U0M=; h=From:To:Subject:Date:In-Reply-To:References:From; b=sibum0Tz2o3PAGQvdD2w2H0AH0CFD4wufVSrXfbN96Fa9+1Zc5b/BiygqOVG1XnZB kCHqpeeV2scU85soEEhCLKMJ90CHM+inJ4WTIJr/2pqAksa+RRCv63jTqSD2PGiIdb IwQMy9ZdS5chqiGoQFPnGZuqfjdkdMcfi6mWd2PBxhYFX0xGgeUnclJ8pe63DuHeQ3 NYW8pxuJCQFLRU+dgXLbhogWyaeLPg+lPlhp/n6rcGVOg9VQE+Zw99aOhp3jzfUsOk ixrvLis2EhDAFC9vbT/fpJPe5bO0lwp8SRIQi7U7l+KIC5WR2FZfGpflCyXL9y3M9s qgxSr2uRrAP4A== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 9E219449E for ; Wed, 14 Feb 2024 19:24:38 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 8AF273A22DE for ; Wed, 14 Feb 2024 19:24:38 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 14 Feb 2024 19:24:31 +0100 Message-ID: <20240214182435.31380-6-anton@khirnov.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240214182435.31380-1-anton@khirnov.net> References: <20240214182435.31380-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 06/10] fftools/ffmpeg_filter: pass framerate through InputFilterOptions 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Rather than read it directly from InputStream. This is a step towards avoiding the assumption that filtergraph inputs are always fed by demuxers. --- fftools/ffmpeg.h | 10 ++++++++-- fftools/ffmpeg_demux.c | 10 +++++++--- fftools/ffmpeg_filter.c | 9 +++------ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 9942342f03..1fdc835723 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -253,6 +253,7 @@ typedef struct OptionsContext { enum IFilterFlags { IFILTER_FLAG_AUTOROTATE = (1 << 0), IFILTER_FLAG_REINIT = (1 << 1), + IFILTER_FLAG_CFR = (1 << 2), }; typedef struct InputFilterOptions { @@ -261,6 +262,13 @@ typedef struct InputFilterOptions { uint8_t *name; + /* When IFILTER_FLAG_CFR is set, the stream is guaranteed to be CFR with + * this framerate. + * + * Otherwise, this is an estimate that should not be relied upon to be + * accurate */ + AVRational framerate; + int sub2video_width; int sub2video_height; @@ -365,8 +373,6 @@ typedef struct InputStream { Decoder *decoder; const AVCodec *dec; - AVRational framerate_guessed; - /* framerate forced with -r */ AVRational framerate; #if FFMPEG_OPT_TOP diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index 317e27e294..e543c4215c 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -992,7 +992,13 @@ int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple, if (ret < 0) return ret; - if (ist->par->codec_type == AVMEDIA_TYPE_SUBTITLE) { + if (ist->par->codec_type == AVMEDIA_TYPE_VIDEO) { + if (ist->framerate.num > 0 && ist->framerate.den > 0) { + opts->framerate = ist->framerate; + opts->flags |= IFILTER_FLAG_CFR; + } else + opts->framerate = av_guess_frame_rate(d->f.ctx, ist->st, NULL); + } else if (ist->par->codec_type == AVMEDIA_TYPE_SUBTITLE) { /* Compute the size of the canvas for the subtitles stream. If the subtitles codecpar has set a size, use it. Otherwise use the maximum dimensions of the video streams in the same file. */ @@ -1359,8 +1365,6 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st) MATCH_PER_STREAM_OPT(top_field_first, i, ist->top_field_first, ic, st); #endif - ist->framerate_guessed = av_guess_frame_rate(ic, st, NULL); - break; case AVMEDIA_TYPE_AUDIO: { int guess_layout_max = INT_MAX; diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 56aa3edd78..dc65b441a6 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1486,7 +1486,7 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph, const AVFilter *buffer_filt = avfilter_get_by_name("buffer"); const AVPixFmtDescriptor *desc; InputStream *ist = ifp->ist; - AVRational fr = ist->framerate; + AVRational fr = ifp->opts.framerate; AVRational sar; AVBPrint args; char name[255]; @@ -1495,14 +1495,11 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph, if (!par) return AVERROR(ENOMEM); - if (!fr.num) - fr = ist->framerate_guessed; - if (ifp->type_src == AVMEDIA_TYPE_SUBTITLE) sub2video_prepare(ifp); - ifp->time_base = ist->framerate.num ? av_inv_q(ist->framerate) : - ist->st->time_base; + ifp->time_base = (ifp->opts.flags & IFILTER_FLAG_CFR) ? + av_inv_q(ifp->opts.framerate) : ist->st->time_base; sar = ifp->sample_aspect_ratio; if(!sar.den) -- 2.42.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".