[FFmpeg-cvslog] avfilter/settb: switch to activate
Paul B Mahol
git at videolan.org
Wed Oct 23 13:41:34 EEST 2019
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sat Oct 19 17:01:38 2019 +0200| [7df808ea8443808d31465dab81c94e89172070d2] | committer: Paul B Mahol
avfilter/settb: switch to activate
Now correctly updates EOF timestamp.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7df808ea8443808d31465dab81c94e89172070d2
---
libavfilter/settb.c | 51 ++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 44 insertions(+), 7 deletions(-)
diff --git a/libavfilter/settb.c b/libavfilter/settb.c
index 83616c1361..dba52cff31 100644
--- a/libavfilter/settb.c
+++ b/libavfilter/settb.c
@@ -34,6 +34,7 @@
#include "libavutil/rational.h"
#include "audio.h"
#include "avfilter.h"
+#include "filters.h"
#include "internal.h"
#include "video.h"
@@ -104,22 +105,58 @@ static int config_output_props(AVFilterLink *outlink)
return 0;
}
-static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
+static int64_t rescale_pts(AVFilterLink *inlink, AVFilterLink *outlink, int64_t orig_pts)
{
AVFilterContext *ctx = inlink->dst;
- AVFilterLink *outlink = ctx->outputs[0];
+ int64_t new_pts = orig_pts;
if (av_cmp_q(inlink->time_base, outlink->time_base)) {
- int64_t orig_pts = frame->pts;
- frame->pts = av_rescale_q(frame->pts, inlink->time_base, outlink->time_base);
+ new_pts = av_rescale_q(orig_pts, inlink->time_base, outlink->time_base);
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, orig_pts,
- outlink->time_base.num, outlink->time_base.den, frame->pts);
+ outlink->time_base.num, outlink->time_base.den, new_pts);
}
+ return new_pts;
+}
+
+static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
+{
+ AVFilterContext *ctx = inlink->dst;
+ AVFilterLink *outlink = ctx->outputs[0];
+
+ frame->pts = rescale_pts(inlink, outlink, frame->pts);
+
return ff_filter_frame(outlink, frame);
}
+static int activate(AVFilterContext *ctx)
+{
+ AVFilterLink *inlink = ctx->inputs[0];
+ AVFilterLink *outlink = ctx->outputs[0];
+ AVFrame *in;
+ int status;
+ int64_t pts;
+ int ret;
+
+ FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink);
+
+ ret = ff_inlink_consume_frame(inlink, &in);
+ if (ret < 0)
+ return ret;
+ if (ret > 0)
+ return filter_frame(inlink, in);
+
+ if (ff_inlink_acknowledge_status(inlink, &status, &pts)) {
+ ff_outlink_set_status(outlink, status, rescale_pts(inlink, outlink, pts));
+ return 0;
+ }
+
+ FF_FILTER_FORWARD_WANTED(outlink, inlink);
+
+ return FFERROR_NOT_READY;
+}
+
#if CONFIG_SETTB_FILTER
DEFINE_OPTIONS(settb, VIDEO);
@@ -129,7 +166,6 @@ static const AVFilterPad avfilter_vf_settb_inputs[] = {
{
.name = "default",
.type = AVMEDIA_TYPE_VIDEO,
- .filter_frame = filter_frame,
},
{ NULL }
};
@@ -150,6 +186,7 @@ AVFilter ff_vf_settb = {
.priv_class = &settb_class,
.inputs = avfilter_vf_settb_inputs,
.outputs = avfilter_vf_settb_outputs,
+ .activate = activate,
};
#endif /* CONFIG_SETTB_FILTER */
@@ -162,7 +199,6 @@ static const AVFilterPad avfilter_af_asettb_inputs[] = {
{
.name = "default",
.type = AVMEDIA_TYPE_AUDIO,
- .filter_frame = filter_frame,
},
{ NULL }
};
@@ -183,5 +219,6 @@ AVFilter ff_af_asettb = {
.inputs = avfilter_af_asettb_inputs,
.outputs = avfilter_af_asettb_outputs,
.priv_class = &asettb_class,
+ .activate = activate,
};
#endif /* CONFIG_ASETTB_FILTER */
More information about the ffmpeg-cvslog
mailing list