diff options
author | Anton Khirnov <anton@khirnov.net> | 2023-03-27 08:12:14 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2023-04-13 15:11:56 +0200 |
commit | fd91ac11ed5aa2a22a02a89f8a363551a368c638 (patch) | |
tree | 3f0d08f88d8c53db6e181d02b32d88bf968bd273 | |
parent | 83da6d3f54fc85784e0ef843ee6e0c03e338722e (diff) | |
download | ffmpeg-fd91ac11ed5aa2a22a02a89f8a363551a368c638.tar.gz |
fftools/ffmpeg: move OutputStream.last_filter_pts to OutputFilter
This value is associated with the filtergraph output rather than the
output stream, so this is a more appropriate place for it.
-rw-r--r-- | fftools/ffmpeg.c | 8 | ||||
-rw-r--r-- | fftools/ffmpeg.h | 5 | ||||
-rw-r--r-- | fftools/ffmpeg_filter.c | 21 | ||||
-rw-r--r-- | 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); |