Commit b4c33598 authored by Stefano Sabatini's avatar Stefano Sabatini

lavfi/asettb: do not create a new reference in filter_samples()

There is no need to duplicate the input reference, since a filter should
not pass along a reference which is later modified. If this happens the
filter passing the reference should be fixed.

Also improve consistency with start_frame() of settb, allowing a pending
factorization.
parent a7c3720e
...@@ -116,22 +116,20 @@ static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) ...@@ -116,22 +116,20 @@ static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
return ff_start_frame(outlink, picref); return ff_start_frame(outlink, picref);
} }
static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref)
{ {
AVFilterContext *ctx = inlink->dst; AVFilterContext *ctx = inlink->dst;
AVFilterLink *outlink = ctx->outputs[0]; AVFilterLink *outlink = ctx->outputs[0];
AVFilterBufferRef *outsamples = insamples;
if (av_cmp_q(inlink->time_base, outlink->time_base)) { if (av_cmp_q(inlink->time_base, outlink->time_base)) {
outsamples = avfilter_ref_buffer(insamples, ~0); int64_t orig_pts = samplesref->pts;
outsamples->pts = av_rescale_q(insamples->pts, inlink->time_base, outlink->time_base); samplesref->pts = av_rescale_q(samplesref->pts, inlink->time_base, outlink->time_base);
av_log(ctx, AV_LOG_DEBUG, "tb:%d/%d pts:%"PRId64" -> tb:%d/%d pts:%"PRId64"\n", av_log(ctx, AV_LOG_DEBUG, "tb:%d/%d pts:%"PRId64" -> tb:%d/%d pts:%"PRId64"\n",
inlink ->time_base.num, inlink ->time_base.den, insamples ->pts, inlink ->time_base.num, inlink ->time_base.den, orig_pts,
outlink->time_base.num, outlink->time_base.den, outsamples->pts); outlink->time_base.num, outlink->time_base.den, samplesref->pts);
avfilter_unref_buffer(insamples);
} }
return ff_filter_samples(outlink, outsamples); return ff_filter_samples(outlink, samplesref);
} }
#if CONFIG_SETTB_FILTER #if CONFIG_SETTB_FILTER
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment