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 6870C4390F for ; Wed, 3 Aug 2022 14:01:53 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 36B1A68B999; Wed, 3 Aug 2022 16:59:19 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D353768B878 for ; Wed, 3 Aug 2022 16:59:06 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 206352405F0 for ; Wed, 3 Aug 2022 15:59:06 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id WJ_8xSSDkB8Z for ; Wed, 3 Aug 2022 15:59:05 +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 1E0BB240688 for ; Wed, 3 Aug 2022 15:58:55 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 3F4B43A0656; Wed, 3 Aug 2022 15:58:52 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 3 Aug 2022 15:58:39 +0200 Message-Id: <20220803135844.16662-20-anton@khirnov.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220803135844.16662-1-anton@khirnov.net> References: <20220803135844.16662-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 20/25] fftools/ffmpeg: move get_input_packet() to ffmpeg_demux.c 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: Also rename it to use the ifile_* namespace. --- fftools/ffmpeg.c | 30 ++---------------------------- fftools/ffmpeg.h | 1 + fftools/ffmpeg_demux.c | 26 ++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 37f52f0208..497a847101 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -3610,32 +3610,6 @@ static int check_keyboard_interaction(int64_t cur_time) return 0; } -static int get_input_packet(InputFile *f, AVPacket **pkt) -{ - if (f->readrate || f->rate_emu) { - int i; - int64_t file_start = copy_ts * ( - (f->ctx->start_time != AV_NOPTS_VALUE ? f->ctx->start_time * !start_at_zero : 0) + - (f->start_time != AV_NOPTS_VALUE ? f->start_time : 0) - ); - float scale = f->rate_emu ? 1.0 : f->readrate; - for (i = 0; i < f->nb_streams; i++) { - InputStream *ist = input_streams[f->ist_index + i]; - int64_t stream_ts_offset, pts, now; - if (!ist->nb_packets || (ist->decoding_needed && !ist->got_output)) 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; - if (pts > now) - return AVERROR(EAGAIN); - } - } - - return av_thread_message_queue_recv(f->in_thread_queue, pkt, - f->non_blocking ? - AV_THREAD_MESSAGE_NONBLOCK : 0); -} - static int got_eagain(void) { int i; @@ -3752,7 +3726,7 @@ static int process_input(int file_index) int disable_discontinuity_correction = copy_ts; is = ifile->ctx; - ret = get_input_packet(ifile, &pkt); + ret = ifile_get_packet(ifile, &pkt); if (ret == AVERROR(EAGAIN)) { ifile->eagain = 1; @@ -3777,7 +3751,7 @@ static int process_input(int file_index) if (ret < 0) av_log(NULL, AV_LOG_WARNING, "Seek to start failed.\n"); else - ret = get_input_packet(ifile, &pkt); + ret = ifile_get_packet(ifile, &pkt); if (ret == AVERROR(EAGAIN)) { ifile->eagain = 1; return ret; diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 81356fd566..f983d077d9 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -710,6 +710,7 @@ int64_t of_filesize(OutputFile *of); AVChapter * const * of_get_chapters(OutputFile *of, unsigned int *nb_chapters); +int ifile_get_packet(InputFile *f, AVPacket **pkt); int init_input_threads(void); int init_input_thread(int i); void free_input_threads(void); diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index 66cb6ebd5f..1e95be349c 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -163,3 +163,29 @@ int init_input_threads(void) } return 0; } + +int ifile_get_packet(InputFile *f, AVPacket **pkt) +{ + if (f->readrate || f->rate_emu) { + int i; + int64_t file_start = copy_ts * ( + (f->ctx->start_time != AV_NOPTS_VALUE ? f->ctx->start_time * !start_at_zero : 0) + + (f->start_time != AV_NOPTS_VALUE ? f->start_time : 0) + ); + float scale = f->rate_emu ? 1.0 : f->readrate; + for (i = 0; i < f->nb_streams; i++) { + InputStream *ist = input_streams[f->ist_index + i]; + int64_t stream_ts_offset, pts, now; + if (!ist->nb_packets || (ist->decoding_needed && !ist->got_output)) 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; + if (pts > now) + return AVERROR(EAGAIN); + } + } + + return av_thread_message_queue_recv(f->in_thread_queue, pkt, + f->non_blocking ? + AV_THREAD_MESSAGE_NONBLOCK : 0); +} -- 2.34.1 _______________________________________________ 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".