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

Anton Khirnov git at videolan.org
Mon Jun 5 17:30:49 EEST 2023


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Sun May 28 16:51:57 2023 +0200| [ba1141d8a9a50f66b7cdc62bec59a536f6ece568] | committer: Anton Khirnov

fftools/ffmpeg_enc: move nb_frames{dup,drop} globals into OutputStream

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ba1141d8a9a50f66b7cdc62bec59a536f6ece568
---

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

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;
         }



More information about the ffmpeg-cvslog mailing list