diff mbox series

[FFmpeg-devel,01/29] fftools/ffmpeg: move OutputStream.vsync_frame_number to Encoder

Message ID 20230409140853.28858-1-anton@khirnov.net
State Accepted
Commit 45202556cb4446cd154896cdf70ad4e9d66c21e2
Headers show
Series [FFmpeg-devel,01/29] fftools/ffmpeg: move OutputStream.vsync_frame_number to Encoder | expand

Commit Message

Anton Khirnov April 9, 2023, 2:08 p.m. UTC
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(-)

Comments

Anton Khirnov April 11, 2023, 6:35 a.m. UTC | #1
If anyone wants to have a closer look, the set can also be obtained from
https://git.khirnov.net/libav.git/log/?h=ffmpeg_enc_cleanup

I believe it is rather straightforward and uncontroversial, maybe except
for 19/29. If nobody has any comments, I intend to push this in two
days.
diff mbox series

Patch

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