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 8E96C4603E for ; Tue, 2 May 2023 13:44:25 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D63A868C159; Tue, 2 May 2023 16:44:06 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A013A68C148 for ; Tue, 2 May 2023 16:43:59 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 640682404EC; Tue, 2 May 2023 15:43:59 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id iCnItp_jiFEE; Tue, 2 May 2023 15:43:58 +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 750392404EE; Tue, 2 May 2023 15:43:57 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 13B973A11B4; Tue, 2 May 2023 15:43:57 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 2 May 2023 15:43:15 +0200 Message-Id: <20230502134316.10496-3-anton@khirnov.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230502134316.10496-1-anton@khirnov.net> References: <20230502134316.10496-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/4] fftools/ffmpeg: reduce -re to -readrate 1 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 Cc: ddurham@davyandbeth.com 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: They are exactly equivalent, so there is no point in maintaining a separate flag for -re. --- fftools/ffmpeg.c | 2 +- fftools/ffmpeg.h | 1 - fftools/ffmpeg_demux.c | 16 ++++++++-------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index be9a3b2e34..27bfc28798 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1564,7 +1564,7 @@ static int transcode_init(void) /* init framerate emulation */ for (int i = 0; i < nb_input_files; i++) { InputFile *ifile = input_files[i]; - if (ifile->readrate || ifile->rate_emu) + if (ifile->readrate) for (int j = 0; j < ifile->nb_streams; j++) ifile->streams[j]->start = av_gettime_relative(); } diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index a03a6b0302..b30f0758ec 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -484,7 +484,6 @@ typedef struct InputFile { InputStream **streams; int nb_streams; - int rate_emu; float readrate; int accurate_seek; diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index e6f700f6c3..9eea5a4eec 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -450,13 +450,12 @@ int ifile_get_packet(InputFile *f, AVPacket **pkt) return ret; } - if (f->readrate || f->rate_emu) { + if (f->readrate) { int i; int64_t file_start = copy_ts * ( (f->start_time_effective != AV_NOPTS_VALUE ? f->start_time_effective * !start_at_zero : 0) + (f->start_time != AV_NOPTS_VALUE ? f->start_time : 0) ); - float scale = f->rate_emu ? 1.0 : f->readrate; int64_t burst_until = AV_TIME_BASE * d->readrate_initial_burst; for (i = 0; i < f->nb_streams; i++) { InputStream *ist = f->streams[i]; @@ -464,7 +463,7 @@ int ifile_get_packet(InputFile *f, AVPacket **pkt) if (!ist->nb_packets) continue; stream_ts_offset = FFMAX(ist->first_dts != AV_NOPTS_VALUE ? ist->first_dts : 0, file_start); pts = av_rescale(ist->dts, 1000000, AV_TIME_BASE); - now = (av_gettime_relative() - ist->start) * scale + stream_ts_offset; + now = (av_gettime_relative() - ist->start) * f->readrate + stream_ts_offset; if (pts - burst_until > now) return AVERROR(EAGAIN); } @@ -1223,7 +1222,6 @@ int ifile_open(const OptionsContext *o, const char *filename) f->input_sync_ref = o->input_sync_ref; f->input_ts_offset = o->input_ts_offset; f->ts_offset = o->input_ts_offset - (copy_ts ? (start_at_zero && ic->start_time != AV_NOPTS_VALUE ? ic->start_time : 0) : timestamp); - f->rate_emu = o->rate_emu; f->accurate_seek = o->accurate_seek; d->loop = o->loop; d->duration = 0; @@ -1234,12 +1232,14 @@ int ifile_open(const OptionsContext *o, const char *filename) av_log(d, AV_LOG_ERROR, "Option -readrate is %0.3f; it must be non-negative.\n", f->readrate); exit_program(1); } - if (f->readrate && f->rate_emu) { - av_log(d, AV_LOG_WARNING, "Both -readrate and -re set. Using -readrate %0.3f.\n", f->readrate); - f->rate_emu = 0; + if (o->rate_emu) { + if (f->readrate) { + av_log(d, AV_LOG_WARNING, "Both -readrate and -re set. Using -readrate %0.3f.\n", f->readrate); + } else + f->readrate = 1.0f; } - if (f->readrate || f->rate_emu) { + if (f->readrate) { d->readrate_initial_burst = o->readrate_initial_burst ? o->readrate_initial_burst : 0.5; if (d->readrate_initial_burst < 0.0) { av_log(d, AV_LOG_ERROR, -- 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".