aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas George <george@nsup.org>2016-12-20 16:53:23 +0100
committerNicolas George <george@nsup.org>2017-01-12 14:06:16 +0100
commit0e3d2496e2eec1c911b169682067d53ea9a0388c (patch)
treedbfdded20ac4e20d1f8b6f608fcfe7fdb81ceb22
parent846f1421349e923b100ce290ba25b5b5b897b437 (diff)
downloadffmpeg-0e3d2496e2eec1c911b169682067d53ea9a0388c.tar.gz
lavfi: add ff_inlink_process_commands().
-rw-r--r--libavfilter/avfilter.c25
-rw-r--r--libavfilter/filters.h7
2 files changed, 23 insertions, 9 deletions
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 590ffa8b9e..1699df8795 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -1100,7 +1100,6 @@ static int ff_filter_frame_framed(AVFilterLink *link, AVFrame *frame)
AVFilterContext *dstctx = link->dst;
AVFilterPad *dst = link->dstpad;
int ret;
- AVFilterCommand *cmd= link->dst->command_queue;
int64_t pts;
if (!(filter_frame = dst->filter_frame))
@@ -1112,14 +1111,7 @@ static int ff_filter_frame_framed(AVFilterLink *link, AVFrame *frame)
goto fail;
}
- while(cmd && cmd->time <= frame->pts * av_q2d(link->time_base)){
- av_log(link->dst, AV_LOG_DEBUG,
- "Processing command time:%f command:%s arg:%s\n",
- cmd->time, cmd->command, cmd->arg);
- avfilter_process_command(link->dst, cmd->command, cmd->arg, 0, 0, cmd->flags);
- ff_command_queue_pop(link->dst);
- cmd= link->dst->command_queue;
- }
+ ff_inlink_process_commands(link, frame);
pts = frame->pts;
if (dstctx->enable_str) {
@@ -1568,6 +1560,21 @@ int ff_inlink_make_frame_writable(AVFilterLink *link, AVFrame **rframe)
return 0;
}
+int ff_inlink_process_commands(AVFilterLink *link, const AVFrame *frame)
+{
+ AVFilterCommand *cmd = link->dst->command_queue;
+
+ while(cmd && cmd->time <= frame->pts * av_q2d(link->time_base)){
+ av_log(link->dst, AV_LOG_DEBUG,
+ "Processing command time:%f command:%s arg:%s\n",
+ cmd->time, cmd->command, cmd->arg);
+ avfilter_process_command(link->dst, cmd->command, cmd->arg, 0, 0, cmd->flags);
+ ff_command_queue_pop(link->dst);
+ cmd= link->dst->command_queue;
+ }
+ return 0;
+}
+
const AVClass *avfilter_get_class(void)
{
return &avfilter_class;
diff --git a/libavfilter/filters.h b/libavfilter/filters.h
index 3036ba27a6..7535f1df90 100644
--- a/libavfilter/filters.h
+++ b/libavfilter/filters.h
@@ -40,6 +40,13 @@
void ff_filter_set_ready(AVFilterContext *filter, unsigned priority);
/**
+ * Process the commands queued in the link up to the time of the frame.
+ * Commands will trigger the process_command() callback.
+ * @return >= 0 or AVERROR code.
+ */
+int ff_inlink_process_commands(AVFilterLink *link, const AVFrame *frame);
+
+/**
* Make sure a frame is writable.
* This is similar to av_frame_make_writable() except it uses the link's
* buffer allocation callback, and therefore allows direct rendering.