[FFmpeg-devel] [PATCH 05/17] lavfi: add ff_inlink_process_commands().

Michael Niedermayer michael at niedermayer.cc
Thu Dec 29 22:25:02 EET 2016


On Thu, Dec 29, 2016 at 03:33:51PM +0100, Nicolas George wrote:
> Signed-off-by: Nicolas George <george at nsup.org>
> ---
>  libavfilter/avfilter.c | 24 +++++++++++++++---------
>  libavfilter/filters.h  |  6 ++++++
>  2 files changed, 21 insertions(+), 9 deletions(-)
> 
> 
> Changes in this commit: rename ff_link -> ff_inlink and move to filters.h.
> 
> 
> diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
> index 2c41ea8c22..2fe8b980e0 100644
> --- a/libavfilter/avfilter.c
> +++ b/libavfilter/avfilter.c
> @@ -1099,7 +1099,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))
> @@ -1111,14 +1110,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) {
> @@ -1565,6 +1557,20 @@ int ff_inlink_make_frame_writable(AVFilterLink *link, AVFrame **rframe)
>      return 0;
>  }
>  
> +void 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;
> +    }
> +}
> +
>  const AVClass *avfilter_get_class(void)
>  {
>      return &avfilter_class;
> diff --git a/libavfilter/filters.h b/libavfilter/filters.h
> index 543f4df680..efbef2918d 100644
> --- a/libavfilter/filters.h
> +++ b/libavfilter/filters.h
> @@ -33,6 +33,12 @@
>  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.
> + */
> +void ff_inlink_process_commands(AVFilterLink *link, const AVFrame *frame);

avfilter_process_command() has a return code, should this be checked
or passed on somehow ?

gut feeling but, if the only thing from the frame that is used is the
pts, it may be more flexible to pass the pts instead of the frame.


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Old school: Use the lowest level language in which you can solve the problem
            conveniently.
New school: Use the highest level language in which the latest supercomputer
            can solve the problem without the user falling asleep waiting.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20161229/65fe54ae/attachment.sig>


More information about the ffmpeg-devel mailing list