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