Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Anton Khirnov <anton@khirnov.net>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 8/9] fftools/ffmpeg: rename OutputStream.sync_opts to next_pts
Date: Wed, 28 Sep 2022 11:55:55 +0200
Message-ID: <20220928095556.28209-8-anton@khirnov.net> (raw)
In-Reply-To: <20220928095556.28209-1-anton@khirnov.net>

The current name is confusing.
---
 fftools/ffmpeg.c | 22 ++++++++++++----------
 fftools/ffmpeg.h |  6 +++---
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 40c01b1c65..6deca8bfbf 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1044,12 +1044,12 @@ static void do_audio_out(OutputFile *of, OutputStream *ost,
 
     adjust_frame_pts_to_encoder_tb(of, ost, frame);
 
-    if (!check_recording_time(ost, ost->sync_opts, ost->enc_ctx->time_base))
+    if (!check_recording_time(ost, ost->next_pts, ost->enc_ctx->time_base))
         return;
 
     if (frame->pts == AV_NOPTS_VALUE)
-        frame->pts = ost->sync_opts;
-    ost->sync_opts = frame->pts + frame->nb_samples;
+        frame->pts = ost->next_pts;
+    ost->next_pts = frame->pts + frame->nb_samples;
 
     ret = submit_encode_frame(of, ost, frame);
     if (ret < 0 && ret != AVERROR_EOF)
@@ -1230,7 +1230,9 @@ static void do_video_out(OutputFile *of,
                                           ost->last_nb0_frames[1],
                                           ost->last_nb0_frames[2]);
     } else {
-        delta0 = sync_ipts - ost->sync_opts; // delta0 is the "drift" between the input frame (next_picture) and where it would fall in the output.
+        /* delta0 is the "drift" between the input frame (next_picture) and
+         * where it would fall in the output. */
+        delta0 = sync_ipts - ost->next_pts;
         delta  = delta0 + duration;
 
         /* by default, we output a single frame */
@@ -1245,7 +1247,7 @@ static void do_video_out(OutputFile *of,
                 av_log(NULL, AV_LOG_VERBOSE, "Past duration %f too large\n", -delta0);
             } else
                 av_log(NULL, AV_LOG_DEBUG, "Clipping frame in rate conversion by %f\n", -delta0);
-            sync_ipts = ost->sync_opts;
+            sync_ipts = ost->next_pts;
             duration += delta0;
             delta0 = 0;
         }
@@ -1256,7 +1258,7 @@ static void do_video_out(OutputFile *of,
                 av_log(NULL, AV_LOG_DEBUG, "Not duplicating %d initial frames\n", (int)lrintf(delta0));
                 delta = duration;
                 delta0 = 0;
-                ost->sync_opts = llrint(sync_ipts);
+                ost->next_pts = llrint(sync_ipts);
             }
         case VSYNC_CFR:
             // FIXME set to 0.5 after we fix some dts/pts bugs like in avidec.c
@@ -1275,13 +1277,13 @@ static void do_video_out(OutputFile *of,
             if (delta <= -0.6)
                 nb_frames = 0;
             else if (delta > 0.6)
-                ost->sync_opts = llrint(sync_ipts);
+                ost->next_pts = llrint(sync_ipts);
             next_picture->duration = duration;
             break;
         case VSYNC_DROP:
         case VSYNC_PASSTHROUGH:
             next_picture->duration = duration;
-            ost->sync_opts = llrint(sync_ipts);
+            ost->next_pts = llrint(sync_ipts);
             break;
         default:
             av_assert0(0);
@@ -1335,7 +1337,7 @@ static void do_video_out(OutputFile *of,
         if (!in_picture)
             return;
 
-        in_picture->pts = ost->sync_opts;
+        in_picture->pts = ost->next_pts;
 
         if (!check_recording_time(ost, in_picture->pts, ost->enc_ctx->time_base))
             return;
@@ -1347,7 +1349,7 @@ static void do_video_out(OutputFile *of,
         if (ret < 0 && ret != AVERROR_EOF)
             exit_program(1);
 
-        ost->sync_opts++;
+        ost->next_pts++;
         ost->vsync_frame_number++;
     }
 
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index a9883c0442..d466a1ff9f 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -492,9 +492,9 @@ typedef struct OutputStream {
     AVStream *st;            /* stream in the output file */
     /* number of frames emitted by the video-encoding sync code */
     int64_t vsync_frame_number;
-    /* input pts and corresponding output pts
-       for A/V sync */
-    int64_t sync_opts;       /* output frame counter, could be changed to some true timestamp */ // FIXME look at frame_number
+    /* predicted pts of the next frame to be encoded
+     * audio/video encoding only */
+    int64_t next_pts;
     /* dts of the last packet sent to the muxing queue, in AV_TIME_BASE_Q */
     int64_t last_mux_dts;
     /* pts of the last frame received from the filters, in AV_TIME_BASE_Q */
-- 
2.35.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  parent reply	other threads:[~2022-09-28  9:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-28  9:55 [FFmpeg-devel] [PATCH 1/9] fftools/ffmpeg: drop the -async option Anton Khirnov
2022-09-28  9:55 ` [FFmpeg-devel] [PATCH 2/9] fftools/ffmpeg: drop always-true conditions Anton Khirnov
2022-09-28  9:55 ` [FFmpeg-devel] [PATCH 3/9] fftools/ffmpeg: move forced keyframe processing into its own function Anton Khirnov
2022-09-28  9:55 ` [FFmpeg-devel] [PATCH 4/9] fftools/ffmpeg: cosmetics Anton Khirnov
2022-09-28  9:55 ` [FFmpeg-devel] [PATCH 5/9] fftools/ffmpeg: drop never-set OutputStream.first_pts Anton Khirnov
2022-09-28  9:55 ` [FFmpeg-devel] [PATCH 6/9] fftools/ffmpeg: stop setting OutputStream.sync_opts for streamcopy Anton Khirnov
2022-09-28  9:55 ` [FFmpeg-devel] [PATCH 7/9] fftools/ffmpeg: pass the timestamp to check_recording_time() Anton Khirnov
2022-09-28  9:55 ` Anton Khirnov [this message]
2022-09-28  9:55 ` [FFmpeg-devel] [PATCH 9/9] fftools/ffmpeg: move some code from init_output_stream() to init_output_stream_encode() Anton Khirnov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220928095556.28209-8-anton@khirnov.net \
    --to=anton@khirnov.net \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git