diff mbox series

[FFmpeg-devel,09/27] fftools/ffmpeg: stop accessing OutputStream.last_dropped in print_report()

Message ID 20230919191044.18873-10-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,01/27] fftools/ffmpeg: move derivation of frame duration from filter framerate | expand

Commit Message

Anton Khirnov Sept. 19, 2023, 7:10 p.m. UTC
That field is used by the framerate code to track whether any output has
been generated for the last input frame(*). Its use in the last
invocation of print_report() is meant to meant to account (in the number
of dropped frames printed in the log) for the very last filtered frame
being dropped. However, that is a highly inappropriate place to do so,
as it makes assumptions about vsync logic in completely unrelated code.
Move the increment to encoder flush instead.

(*) the name is misleading, as the input frame has not yet been dropped
    and may still be output in the future
---
 fftools/ffmpeg.c     | 3 ---
 fftools/ffmpeg_enc.c | 3 +++
 2 files changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 14f55cbec7..a854589bef 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -566,9 +566,6 @@  static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
                     pts -= copy_ts_first_pts;
             }
         }
-
-        if (is_last_report)
-            nb_frames_drop += ost->last_dropped;
     }
 
     us    = FFABS64U(pts) % AV_TIME_BASE;
diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index 0ad3a7b6b1..2250d22bd3 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -761,6 +761,9 @@  static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame)
 
         if (frame->sample_aspect_ratio.num && !ost->frame_aspect_ratio.num)
             enc->sample_aspect_ratio = frame->sample_aspect_ratio;
+    } else if (ost->last_dropped) {
+        ost->nb_frames_drop++;
+        ost->last_dropped = 0;
     }
 
     update_benchmark(NULL);