diff mbox series

[FFmpeg-devel,01/23] fftools/ffmpeg_enc: move nb_frames{dup, drop} globals into OutputStream

Message ID 20230531145453.20994-1-anton@khirnov.net
State Accepted
Commit ba1141d8a9a50f66b7cdc62bec59a536f6ece568
Headers show
Series [FFmpeg-devel,01/23] fftools/ffmpeg_enc: move nb_frames{dup, drop} globals into OutputStream | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov May 31, 2023, 2:54 p.m. UTC
---
The patchset is also available from branch 'ffmpeg_enc_tb' in
git://git.khirnov.net/libav
---

 fftools/ffmpeg.c     | 6 ++++--
 fftools/ffmpeg.h     | 6 +++---
 fftools/ffmpeg_enc.c | 8 ++++----
 3 files changed, 11 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 36b4becaf2..bcda7570e9 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -119,8 +119,6 @@  typedef struct BenchmarkTimeStamps {
 static BenchmarkTimeStamps get_benchmark_time_stamps(void);
 static int64_t getmaxrss(void);
 
-int64_t nb_frames_dup = 0;
-int64_t nb_frames_drop = 0;
 unsigned nb_output_dumped = 0;
 
 static BenchmarkTimeStamps current_time;
@@ -491,6 +489,7 @@  static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
     int64_t pts = INT64_MIN + 1;
     static int64_t last_time = -1;
     static int first_report = 1;
+    uint64_t nb_frames_dup = 0, nb_frames_drop = 0;
     int hours, mins, secs, us;
     const char *hours_sign;
     int ret;
@@ -536,6 +535,9 @@  static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
             if (is_last_report)
                 av_bprintf(&buf, "L");
 
+            nb_frames_dup  = ost->nb_frames_dup;
+            nb_frames_drop = ost->nb_frames_drop;
+
             vid = 1;
         }
         /* compute min output value */
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 966397270d..cef4b5d000 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -553,6 +553,9 @@  typedef struct OutputStream {
     Encoder *enc;
     AVCodecContext *enc_ctx;
     AVPacket *pkt;
+
+    uint64_t nb_frames_dup;
+    uint64_t nb_frames_drop;
     int64_t last_dropped;
 
     /* video only */
@@ -707,9 +710,6 @@  extern int recast_media;
 
 extern FILE *vstats_file;
 
-extern int64_t nb_frames_dup;
-extern int64_t nb_frames_drop;
-
 #if FFMPEG_OPT_PSNR
 extern int do_psnr;
 #endif
diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index 6c9cce252f..f3e291a9e4 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -1078,7 +1078,7 @@  static void do_video_out(OutputFile *of, OutputStream *ost, AVFrame *frame)
                        &nb_frames, &nb_frames_prev);
 
     if (nb_frames_prev == 0 && ost->last_dropped) {
-        nb_frames_drop++;
+        ost->nb_frames_drop++;
         av_log(ost, AV_LOG_VERBOSE,
                "*** dropping frame %"PRId64" at ts %"PRId64"\n",
                e->vsync_frame_number, e->last_frame->pts);
@@ -1086,12 +1086,12 @@  static void do_video_out(OutputFile *of, OutputStream *ost, AVFrame *frame)
     if (nb_frames > (nb_frames_prev && ost->last_dropped) + (nb_frames > nb_frames_prev)) {
         if (nb_frames > dts_error_threshold * 30) {
             av_log(ost, AV_LOG_ERROR, "%"PRId64" frame duplication too large, skipping\n", nb_frames - 1);
-            nb_frames_drop++;
+            ost->nb_frames_drop++;
             return;
         }
-        nb_frames_dup += nb_frames - (nb_frames_prev && ost->last_dropped) - (nb_frames > nb_frames_prev);
+        ost->nb_frames_dup += nb_frames - (nb_frames_prev && ost->last_dropped) - (nb_frames > nb_frames_prev);
         av_log(ost, AV_LOG_VERBOSE, "*** %"PRId64" dup!\n", nb_frames - 1);
-        if (nb_frames_dup > dup_warning) {
+        if (ost->nb_frames_dup > dup_warning) {
             av_log(ost, AV_LOG_WARNING, "More than %"PRIu64" frames duplicated\n", dup_warning);
             dup_warning *= 10;
         }