[FFmpeg-devel] [PATCH] Command passing interface for libavfilter

Nicolas George nicolas.george at normalesup.org
Mon Aug 29 20:30:13 CEST 2011


Le duodi 12 fructidor, an CCXIX, Michael Niedermayer a écrit :
> > > the 5 patches below allow changing drawtext parameters at runtime
> > > with ffmpeg. And add a interface to pass commands to filters and
> > > their responses back. As well as queing commands for specific times

Cool. Thanks.

> +/**
> + * Send a command to one or more filter instances.
> + *
> + * @param graph  the filter graph
> + * @param target the filter(s) to which the command should be sent
> + *               "all" sends to all filters

Maybe "*" rather than "all"? It makes it more explicit that this is a
special case.

> +    if(cmd && cmd->time <= picref->pts * av_q2d(link->time_base)){
> +        avfilter_process_command(link->dst, cmd->command, cmd->arg, 0, 0, cmd->flags);
> +        command_queue_pop(link->dst);
> +    }

I believe it should be a loop, here: several command can have expired in a
single run.

> +    for (i = 0; i < graph->filter_count; i++) {
> +        AVFilterContext *filter = graph->filters[i];
> +        if(filter && (!strcmp(target, "all") || !strcmp(target, filter->name) || !strcmp(target, filter->filter->name))){
> +            AVFilterCommand **que = &filter->command_queue;
> +            while(*que) que = &(*que)->next;

This part is inefficient and requires the commands to be queued in ascending
order.

If we want to keep the ordering constraint, keeping a pointer to the last
command makes the loop useless and the insert instantaneous.

But I think it would be a better idea to change it into:

		while(*que && *que->ts <= ts)

to automatically sort the queued commands. If someone complains about
performance, he can implement a heap.

> +/**
> + * Queue a command for one or more filter instances.
> + *
> + * @param graph  the filter graph
> + * @param target the filter(s) to which the command should be sent
> + *               "all" sends to all filters
> + *               otherwise it can be a filter or filter instance name
> + *               which will send the command to all matching filters.
> + * @param cmd    the command to sent, for handling simplicity all commands must be alphanummeric only
> + * @param arg    the argument for the command
> + * @param ts     time at which the command should be sent to the filter

If we keep the constraint that ts must be ascending, that should be in the
documentation.

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110829/8fb79e40/attachment.asc>


More information about the ffmpeg-devel mailing list