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 B39964615E for ; Mon, 8 May 2023 09:21:14 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C3CCE68C1FD; Mon, 8 May 2023 12:18:26 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 647F268C17B for ; Mon, 8 May 2023 12:18:05 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 42AF32405F9 for ; Mon, 8 May 2023 11:18:03 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id NMSkmhhqrROn for ; Mon, 8 May 2023 11:18: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 717092406CE 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 6398B3A11DB 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:30 +0200 Message-Id: <20230508091738.20813-14-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 14/22] fftools/ffmpeg: simplify tracking -readrate start time 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: There is no point in having a per-stream wallclock start time, since they are all computed at the same instant. Keep a per-file start time instead, initialized when the demuxer thread starts. --- fftools/ffmpeg.c | 8 -------- fftools/ffmpeg.h | 2 -- fftools/ffmpeg_demux.c | 6 +++++- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 9cf94f2a22..40e97ad486 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1498,14 +1498,6 @@ static int transcode_init(void) { int ret = 0; - /* init framerate emulation */ - for (int i = 0; i < nb_input_files; i++) { - InputFile *ifile = input_files[i]; - if (ifile->readrate) - for (int j = 0; j < ifile->nb_streams; j++) - ifile->streams[j]->start = av_gettime_relative(); - } - /* discard unused programs */ for (int i = 0; i < nb_input_files; i++) { InputFile *ifile = input_files[i]; diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 7eb6301c74..d1af94590d 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -362,8 +362,6 @@ typedef struct InputStream { AVRational framerate_guessed; - int64_t start; /* time when read started */ - // pts/estimated duration of the last decoded frame // * in decoder timebase for video, // * in last_frame_tb (may change during decoding) for audio diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index d5924c05aa..1f8f3a73bd 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -88,6 +88,8 @@ typedef struct Demuxer { // name used for logging char log_name[32]; + int64_t wallclock_start; + /* number of times input stream should be looped */ int loop; /* actual duration of the longest stream in a file at the moment when @@ -517,7 +519,7 @@ static void readrate_sleep(Demuxer *d) int64_t stream_ts_offset, pts, now; stream_ts_offset = FFMAX(ds->first_dts != AV_NOPTS_VALUE ? ds->first_dts : 0, file_start); pts = av_rescale(ds->dts, 1000000, AV_TIME_BASE); - now = (av_gettime_relative() - ist->start) * f->readrate + stream_ts_offset; + now = (av_gettime_relative() - d->wallclock_start) * f->readrate + stream_ts_offset; if (pts - burst_until > now) av_usleep(pts - burst_until - now); } @@ -546,6 +548,8 @@ static void *input_thread(void *arg) thread_set_name(f); + d->wallclock_start = av_gettime_relative(); + while (1) { DemuxMsg msg = { NULL }; -- 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".