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 05/29] fftools/ffmpeg: move OutputStream.last_filter_pts to OutputFilter
Date: Sun,  9 Apr 2023 16:08:29 +0200
Message-ID: <20230409140853.28858-5-anton@khirnov.net> (raw)
In-Reply-To: <20230409140853.28858-1-anton@khirnov.net>

This value is associated with the filtergraph output rather than the
output stream, so this is a more appropriate place for it.
---
 fftools/ffmpeg.c          |  8 ++++----
 fftools/ffmpeg.h          |  5 +++--
 fftools/ffmpeg_filter.c   | 21 +++++++++++++++------
 fftools/ffmpeg_mux_init.c |  1 -
 4 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 750ab76693..1f50b82794 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -697,8 +697,8 @@ static int reap_filters(int flush)
 
             if (filtered_frame->pts != AV_NOPTS_VALUE) {
                 AVRational tb = av_buffersink_get_time_base(filter);
-                ost->last_filter_pts = av_rescale_q(filtered_frame->pts, tb,
-                                                    AV_TIME_BASE_Q);
+                ost->filter->last_pts = av_rescale_q(filtered_frame->pts, tb,
+                                                     AV_TIME_BASE_Q);
                 filtered_frame->time_base = tb;
 
                 if (debug_ts)
@@ -2391,8 +2391,8 @@ static OutputStream *choose_output(void)
     for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost)) {
         int64_t opts;
 
-        if (ost->filter && ost->last_filter_pts != AV_NOPTS_VALUE) {
-            opts = ost->last_filter_pts;
+        if (ost->filter && ost->filter->last_pts != AV_NOPTS_VALUE) {
+            opts = ost->filter->last_pts;
         } else {
             opts = ost->last_mux_dts == AV_NOPTS_VALUE ?
                    INT64_MIN : ost->last_mux_dts;
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index b45a2039ce..84ce017320 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -314,6 +314,9 @@ typedef struct OutputFilter {
     const int *formats;
     const AVChannelLayout *ch_layouts;
     const int *sample_rates;
+
+    /* pts of the last frame received from this filter, in AV_TIME_BASE_Q */
+    int64_t last_pts;
 } OutputFilter;
 
 typedef struct FilterGraph {
@@ -573,8 +576,6 @@ typedef struct OutputStream {
     AVStream *st;            /* stream in the output file */
     /* 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 */
-    int64_t last_filter_pts;
 
     // timestamp from which the streamcopied streams should start,
     // in AV_TIME_BASE_Q;
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index c9fd65e902..f48ae83a40 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -176,6 +176,18 @@ static void choose_channel_layouts(OutputFilter *ofilter, AVBPrint *bprint)
     av_bprint_chars(bprint, ':', 1);
 }
 
+static OutputFilter *ofilter_alloc(FilterGraph *fg)
+{
+    OutputFilter *ofilter;
+
+    ofilter           = ALLOC_ARRAY_ELEM(fg->outputs, fg->nb_outputs);
+    ofilter->graph    = fg;
+    ofilter->format   = -1;
+    ofilter->last_pts = AV_NOPTS_VALUE;
+
+    return ofilter;
+}
+
 int init_simple_filtergraph(InputStream *ist, OutputStream *ost)
 {
     FilterGraph *fg = av_mallocz(sizeof(*fg));
@@ -186,10 +198,8 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost)
         report_and_exit(AVERROR(ENOMEM));
     fg->index = nb_filtergraphs;
 
-    ofilter = ALLOC_ARRAY_ELEM(fg->outputs, fg->nb_outputs);
-    ofilter->ost    = ost;
-    ofilter->graph  = fg;
-    ofilter->format = -1;
+    ofilter      = ofilter_alloc(fg);
+    ofilter->ost = ost;
 
     ost->filter = ofilter;
 
@@ -502,9 +512,8 @@ int init_complex_filtergraph(FilterGraph *fg)
         init_input_filter(fg, cur);
 
     for (cur = outputs; cur;) {
-        OutputFilter *const ofilter = ALLOC_ARRAY_ELEM(fg->outputs, fg->nb_outputs);
+        OutputFilter *const ofilter = ofilter_alloc(fg);
 
-        ofilter->graph   = fg;
         ofilter->out_tmp = cur;
         ofilter->type    = avfilter_pad_get_type(cur->filter_ctx->output_pads,
                                                                          cur->pad_idx);
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index ee5829c7fe..3490c99c94 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -649,7 +649,6 @@ static OutputStream *new_output_stream(Muxer *mux, const OptionsContext *o,
         ost->ist->st->discard = ost->ist->user_set_discard;
     }
     ost->last_mux_dts = AV_NOPTS_VALUE;
-    ost->last_filter_pts = AV_NOPTS_VALUE;
 
     MATCH_PER_STREAM_OPT(copy_initial_nonkeyframes, i,
                          ost->copy_initial_nonkeyframes, oc, st);
-- 
2.39.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:[~2023-04-09 14:12 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-09 14:08 [FFmpeg-devel] [PATCH 01/29] fftools/ffmpeg: move OutputStream.vsync_frame_number to Encoder Anton Khirnov
2023-04-09 14:08 ` [FFmpeg-devel] [PATCH 02/29] fftools/ffmpeg: move OutputStream.next_pts " Anton Khirnov
2023-04-09 14:08 ` [FFmpeg-devel] [PATCH 03/29] fftools/ffmpeg: move OutputStream.sq_frame " Anton Khirnov
2023-04-09 14:08 ` [FFmpeg-devel] [PATCH 04/29] fftools/ffmpeg: move OutputStream.last_nb0_frames " Anton Khirnov
2023-04-09 14:08 ` Anton Khirnov [this message]
2023-04-09 14:08 ` [FFmpeg-devel] [PATCH 06/29] fftools/ffmpeg_enc: replace abort() with av_assert0(0) Anton Khirnov
2023-04-09 14:08 ` [FFmpeg-devel] [PATCH 07/29] fftools/ffmpeg: drop a useless goto Anton Khirnov
2023-04-09 14:08 ` [FFmpeg-devel] [PATCH 08/29] fftools/ffmpeg: move the hw_device_free_all() call to ffmpeg_cleanup() Anton Khirnov
2023-04-09 14:08 ` [FFmpeg-devel] [PATCH 09/29] fftools/ffmpeg: eliminate the main_return_code global Anton Khirnov
2023-04-09 14:08 ` [FFmpeg-devel] [PATCH 10/29] fftools/ffmpeg: factorize checking whether any output was written Anton Khirnov
2023-04-09 14:08 ` [FFmpeg-devel] [PATCH 11/29] fftools/ffmpeg: move printing verbose muxing stats to ffmpeg_mux Anton Khirnov
2023-04-09 14:08 ` [FFmpeg-devel] [PATCH 12/29] fftools/ffmpeg_mux: reindent Anton Khirnov
2023-04-09 14:08 ` [FFmpeg-devel] [PATCH 13/29] fftools/ffmpeg_mux: log final stats to muxer context Anton Khirnov
2023-04-09 14:08 ` [FFmpeg-devel] [PATCH 14/29] fftools/ffmpeg: rewrite printing the final output sizes Anton Khirnov
2023-04-09 14:08 ` [FFmpeg-devel] [PATCH 15/29] fftools/ffmpeg_mux: make data_size_mux private to ffmpeg_mux Anton Khirnov
2023-04-09 14:08 ` [FFmpeg-devel] [PATCH 16/29] fftools/ffmpeg: move printing verbose demuxing stats to ffmpeg_demux Anton Khirnov
2023-04-09 14:08 ` [FFmpeg-devel] [PATCH 17/29] fftools/ffmpeg_demux: reindent Anton Khirnov
2023-04-09 14:08 ` [FFmpeg-devel] [PATCH 18/29] fftools/ffmpeg_demux: log final stats to demuxer context Anton Khirnov
2023-04-09 14:08 ` [FFmpeg-devel] [PATCH 19/29] fftools/ffmpeg: disable and deprecate -qphist Anton Khirnov
2023-04-09 14:08 ` [FFmpeg-devel] [PATCH 20/29] fftools/ffmpeg_filter: stop setting encoder channel layout unnecessarily Anton Khirnov
2023-04-09 14:08 ` [FFmpeg-devel] [PATCH 21/29] fftools/ffmpeg_mux_init: print more meaningful error messages Anton Khirnov
2023-04-09 14:08 ` [FFmpeg-devel] [PATCH 22/29] fftools/ffmpeg: track a list of non-lavfi outputs in InputStream Anton Khirnov
2023-04-09 14:08 ` [FFmpeg-devel] [PATCH 23/29] fftools/ffmpeg: stop calling check_output_constraints() for streamcopy Anton Khirnov
2023-04-09 14:08 ` [FFmpeg-devel] [PATCH 24/29] fftools/ffmpeg: inline check_output_constraints() into its only caller Anton Khirnov
2023-04-09 14:08 ` [FFmpeg-devel] [PATCH 25/29] fftools/ffmpeg_demux: set the timebase on demuxed packets Anton Khirnov
2023-04-12  2:49   ` James Almer
2023-04-12  5:59     ` Anton Khirnov
2023-04-09 14:08 ` [FFmpeg-devel] [PATCH 26/29] fftools/ffmpeg: use AVPacket.time_base to simplify do_streamcopy() Anton Khirnov
2023-04-09 14:08 ` [FFmpeg-devel] [PATCH 27/29] fftools/ffmpeg: only set InputStream.next_pts for decoding Anton Khirnov
2023-04-09 14:08 ` [FFmpeg-devel] [PATCH 28/29] fftools/ffmpeg: move checking for input -t out of do_streamcopy() Anton Khirnov
2023-04-09 14:08 ` [FFmpeg-devel] [PATCH 29/29] fftools/ffmpeg: stop using InputStream.pts for streamcopy Anton Khirnov
2023-04-11  6:35 ` [FFmpeg-devel] [PATCH 01/29] fftools/ffmpeg: move OutputStream.vsync_frame_number to Encoder 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=20230409140853.28858-5-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