diff mbox series

[FFmpeg-devel,37/49] fftools/ffmpeg: only set OutputStream.frame_number for video encoding

Message ID 20220404113037.13070-38-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,01/49] fftools/ffmpeg: drop an obsolete hack | expand

Checks

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

Commit Message

Anton Khirnov April 4, 2022, 11:30 a.m. UTC
It is unused otherwise.

Rename the field to vsync_frame_number to better reflect its current
purpose.
---
 fftools/ffmpeg.c     | 10 +++++-----
 fftools/ffmpeg.h     |  3 ++-
 fftools/ffmpeg_mux.c | 11 -----------
 3 files changed, 7 insertions(+), 17 deletions(-)
diff mbox series

Patch

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 53b3657ec9..701baa3a28 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1108,7 +1108,7 @@  static void do_video_out(OutputFile *of,
 
         switch (ost->vsync_method) {
         case VSYNC_VSCFR:
-            if (ost->frame_number == 0 && delta0 >= 0.5) {
+            if (ost->vsync_frame_number == 0 && delta0 >= 0.5) {
                 av_log(NULL, AV_LOG_DEBUG, "Not duplicating %d initial frames\n", (int)lrintf(delta0));
                 delta = duration;
                 delta0 = 0;
@@ -1116,7 +1116,7 @@  static void do_video_out(OutputFile *of,
             }
         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->frame_number) {
+            if (frame_drop_threshold && delta < frame_drop_threshold && ost->vsync_frame_number) {
                 nb_frames = 0;
             } else if (delta < -1.1)
                 nb_frames = 0;
@@ -1146,7 +1146,7 @@  static void do_video_out(OutputFile *of,
      * But there may be reordering, so we can't throw away frames on encoder
      * flush, we need to limit them here, before they go into encoder.
      */
-    nb_frames = FFMIN(nb_frames, ost->max_frames - ost->frame_number);
+    nb_frames = FFMIN(nb_frames, ost->max_frames - ost->vsync_frame_number);
     nb0_frames = FFMIN(nb0_frames, nb_frames);
 
     memmove(ost->last_nb0_frames + 1,
@@ -1158,7 +1158,7 @@  static void do_video_out(OutputFile *of,
         nb_frames_drop++;
         av_log(NULL, AV_LOG_VERBOSE,
                "*** dropping frame %d from stream %d at ts %"PRId64"\n",
-               ost->frame_number, ost->st->index, ost->last_frame->pts);
+               ost->vsync_frame_number, ost->st->index, ost->last_frame->pts);
     }
     if (nb_frames > (nb0_frames && ost->last_dropped) + (nb_frames > nb0_frames)) {
         if (nb_frames > dts_error_threshold * 30) {
@@ -1255,7 +1255,7 @@  static void do_video_out(OutputFile *of,
         av_frame_remove_side_data(in_picture, AV_FRAME_DATA_A53_CC);
 
         ost->sync_opts++;
-        ost->frame_number++;
+        ost->vsync_frame_number++;
     }
 
     av_frame_unref(ost->last_frame);
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index dfda6ccbe9..962867b783 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -457,7 +457,8 @@  typedef struct OutputStream {
     int source_index;        /* InputStream index */
     AVStream *st;            /* stream in the output file */
     int encoding_needed;     /* true if encoding needed for this stream */
-    int frame_number;
+    /* number of frames emitted by the video-encoding sync code */
+    int vsync_frame_number;
     /* input pts and corresponding output pts
        for A/V sync */
     struct InputStream *sync_ist; /* input stream to sync against */
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 11d5a0a885..1d8827277d 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -269,17 +269,6 @@  static void submit_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost)
 
 void of_submit_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int eof)
 {
-    AVStream *st = ost->st;
-
-    if (!eof) {
-        /*
-         * Counting encoded video frames needs to be done separately because of
-         * reordering, see do_video_out().
-         */
-        if (!(st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && ost->encoding_needed))
-            ost->frame_number++;
-    }
-
     if (ost->sq_idx_mux >= 0) {
         int ret = sq_send(of->sq_mux, ost->sq_idx_mux,
                           SQPKT(eof ? NULL: pkt));