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 DE85046141 for ; Mon, 8 May 2023 09:19:29 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C6D3068C19F; Mon, 8 May 2023 12:18:14 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EE03968C143 for ; Mon, 8 May 2023 12:18:05 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id E3DC02406D0 for ; Mon, 8 May 2023 11:18:04 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id PybNbrDaNPwE for ; Mon, 8 May 2023 11:18: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 AB030240D03 for ; Mon, 8 May 2023 11:17:57 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 9B3B13A01C0 for ; Mon, 8 May 2023 11:17:57 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 8 May 2023 11:17:35 +0200 Message-Id: <20230508091738.20813-19-anton@khirnov.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230508091738.20813-1-anton@khirnov.net> References: <20230508091738.20813-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 19/22] fftools/ffmpeg: stop accessing input format from decoding code 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: Export the corresponding flag in InputFile instead. This will allow making the demuxer AVFormatContext private in future commits, similarly to what was previously done for muxers. --- fftools/ffmpeg.c | 5 ++--- fftools/ffmpeg.h | 3 +++ fftools/ffmpeg_demux.c | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 092c5e179a..45efa75047 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -976,7 +976,6 @@ static int decode_audio(InputStream *ist, const AVPacket *pkt, int *got_output, static int64_t video_duration_estimate(const InputStream *ist, const AVFrame *frame) { const InputFile *ifile = input_files[ist->file_index]; - const int container_nots = !!(ifile->ctx->iformat->flags & AVFMT_NOTIMESTAMPS); int64_t codec_duration = 0; // XXX lavf currently makes up frame durations when they are not provided by @@ -986,7 +985,7 @@ static int64_t video_duration_estimate(const InputStream *ist, const AVFrame *fr // durations, then this should be simplified. // prefer frame duration for containers with timestamps - if (frame->duration > 0 && !container_nots) + if (frame->duration > 0 && !ifile->format_nots) return frame->duration; if (ist->dec_ctx->framerate.den && ist->dec_ctx->framerate.num) { @@ -998,7 +997,7 @@ static int64_t video_duration_estimate(const InputStream *ist, const AVFrame *fr } // prefer codec-layer duration for containers without timestamps - if (codec_duration > 0 && container_nots) + if (codec_duration > 0 && ifile->format_nots) return codec_duration; // when timestamps are available, repeat last frame's actual duration diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index d1af94590d..5863ca1faf 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -442,6 +442,9 @@ typedef struct InputFile { int index; + // input format has no timestamps + int format_nots; + AVFormatContext *ctx; int eof_reached; /* true if eof reached */ int eagain; /* true if last read attempt returned EAGAIN */ diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index 1d596d1b29..2882f4308a 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -1504,6 +1504,8 @@ int ifile_open(const OptionsContext *o, const char *filename) d->duration = 0; d->time_base = (AVRational){ 1, 1 }; + f->format_nots = !!(ic->iformat->flags & AVFMT_NOTIMESTAMPS); + f->readrate = o->readrate ? o->readrate : 0.0; if (f->readrate < 0.0f) { av_log(d, AV_LOG_ERROR, "Option -readrate is %0.3f; it must be non-negative.\n", f->readrate); -- 2.39.2 _______________________________________________ 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".