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 12A9745A16 for ; Sun, 9 Apr 2023 14:09:20 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id ADABC68BB61; Sun, 9 Apr 2023 17:09:17 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EC150689CE2 for ; Sun, 9 Apr 2023 17:09:10 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id B575A240D1B for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 7XDobzYtMak0 for ; Sun, 9 Apr 2023 16:09:10 +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 16FB12404EE for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id BA57D3A038E for ; Sun, 9 Apr 2023 16:09:09 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Apr 2023 16:08:25 +0200 Message-Id: <20230409140853.28858-1-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/29] fftools/ffmpeg: move OutputStream.vsync_frame_number to Encoder 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: It is video encoding-only and does not need to be visible outside of ffmpeg_enc.c --- fftools/ffmpeg.h | 2 -- fftools/ffmpeg_enc.c | 11 +++++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 8193dabb57..886124d874 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -571,8 +571,6 @@ typedef struct OutputStream { InputStream *ist; AVStream *st; /* stream in the output file */ - /* number of frames emitted by the video-encoding sync code */ - int64_t vsync_frame_number; /* predicted pts of the next frame to be encoded * audio/video encoding only */ int64_t next_pts; diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 2f1803a74c..5266026945 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -45,6 +45,8 @@ struct Encoder { AVFrame *last_frame; + /* number of frames emitted by the video-encoding sync code */ + int64_t vsync_frame_number; }; static uint64_t dup_warning = 1000; @@ -832,6 +834,7 @@ static void video_sync_process(OutputFile *of, OutputStream *ost, AVFrame *next_picture, double duration, int64_t *nb_frames, int64_t *nb_frames_prev) { + Encoder *e = ost->enc; double delta0, delta; double sync_ipts = adjust_frame_pts_to_encoder_tb(of, ost, next_picture); @@ -861,7 +864,7 @@ static void video_sync_process(OutputFile *of, OutputStream *ost, switch (ost->vsync_method) { case VSYNC_VSCFR: - if (ost->vsync_frame_number == 0 && delta0 >= 0.5) { + if (e->vsync_frame_number == 0 && delta0 >= 0.5) { av_log(ost, AV_LOG_DEBUG, "Not duplicating %d initial frames\n", (int)lrintf(delta0)); delta = duration; delta0 = 0; @@ -869,7 +872,7 @@ static void video_sync_process(OutputFile *of, OutputStream *ost, } case VSYNC_CFR: // FIXME set to 0.5 after we fix some dts/pts bugs like in avidec.c - if (frame_drop_threshold && delta < frame_drop_threshold && ost->vsync_frame_number) { + if (frame_drop_threshold && delta < frame_drop_threshold && e->vsync_frame_number) { *nb_frames = 0; } else if (delta < -1.1) *nb_frames = 0; @@ -998,7 +1001,7 @@ static void do_video_out(OutputFile *of, nb_frames_drop++; av_log(ost, AV_LOG_VERBOSE, "*** dropping frame %"PRId64" at ts %"PRId64"\n", - ost->vsync_frame_number, e->last_frame->pts); + e->vsync_frame_number, e->last_frame->pts); } if (nb_frames > (nb_frames_prev && ost->last_dropped) + (nb_frames > nb_frames_prev)) { if (nb_frames > dts_error_threshold * 30) { @@ -1043,7 +1046,7 @@ static void do_video_out(OutputFile *of, exit_program(1); ost->next_pts++; - ost->vsync_frame_number++; + e->vsync_frame_number++; } av_frame_unref(e->last_frame); -- 2.39.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".