[FFmpeg-devel] [PATCH] lavfi/select: add support to branch option

Stefano Sabatini stefasab at gmail.com
Wed Apr 17 23:14:52 CEST 2013


On date Wednesday 2013-04-17 01:40:23 +0200, Stefano Sabatini encoded:
> On date Tuesday 2013-04-16 22:50:55 +0200, Clément Bœsch encoded:
> > On Mon, Apr 15, 2013 at 09:05:55PM +0200, Stefano Sabatini wrote:
> [...] 
> > > +    select->select_out =
> > > +        res == 0 ? -1 : /* drop */
> > > +        isnan(res) || res < 0 ? 0 : /* first output */
> > > +        FFMIN(ceilf(res)-1, select->nb_outputs); /* other outputs */
> > 
> > select->nb_outputs - 1?
> 
> yes
>  
> > Also, if you want a compact if/else code, please use something like
> > 
> >     if      (res == 0)              select->select_out = -1; // drop
> >     else if (isnan(res) || res < 0) select->select_out =  0; // first output
> >     else                            select->select_out = FFMIN(...); // other outputs
> > 
> > ...instead of hardly readable nested ?:
> > 
> > > +    av_log(inlink->dst, AV_LOG_DEBUG, " -> select:%f out:%d\n", res, select->select_out);
> > >  
> > 
> > nit: put "out" into parenthesis to show that it's directly related to the
> > select value.
> 
> changed in a different way (more grep-friendly)
> 
> > 
> > >      if (res) {
> > >          select->var_values[VAR_PREV_SELECTED_N]   = select->var_values[VAR_N];
> > > @@ -326,11 +345,12 @@ static void select_frame(AVFilterContext *ctx, AVFrame *frame)
> > >  
> > >  static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
> > >  {
> > > -    SelectContext *select = inlink->dst->priv;
> > > +    AVFilterContext *ctx = inlink->dst;
> > > +    SelectContext *select = ctx->priv;
> > >  
> > > -    select_frame(inlink->dst, frame);
> > > +    select_frame(ctx, frame);
> > >      if (select->select)
> > > -        return ff_filter_frame(inlink->dst->outputs[0], frame);
> > > +        return ff_filter_frame(ctx->outputs[select->select_out], frame);
> > >  
> > >      av_frame_free(&frame);
> > >      return 0;
> > > @@ -341,13 +361,13 @@ static int request_frame(AVFilterLink *outlink)
> > >      AVFilterContext *ctx = outlink->src;
> > >      SelectContext *select = ctx->priv;
> > >      AVFilterLink *inlink = outlink->src->inputs[0];
> > > -    select->select = 0;
> > > +    int out_no = FF_OUTLINK_IDX(outlink);
> > >  
> > 
> > >      do {
> > >          int ret = ff_request_frame(inlink);
> > >          if (ret < 0)
> > >              return ret;
> > > -    } while (!select->select);
> > > +    } while (select->select_out != out_no);
> > >  
> > 
> > Is this code still required with the new request frame system? (if you
> > have the flag set)
> 
> The flag is not set yet.
> 
> Updated, will push tomorrow if I read no more comments (Nicolas?).
> -- 
> FFmpeg = Frenzy and Fostering Magic Proud Enhancing Governor

> From 231c0d32f631bd1500b1f0c94ecf386fbb09e0dd Mon Sep 17 00:00:00 2001
> From: Stefano Sabatini <stefasab at gmail.com>
> Date: Mon, 8 Apr 2013 12:58:56 +0200
> Subject: [PATCH] lavfi/select: add support for dynamic number of outputs
> 
> TODO: bump micro
> ---
>  doc/filters.texi       |   23 ++++++++++++++---
>  libavfilter/f_select.c |   67 +++++++++++++++++++++++++++++-------------------
>  2 files changed, 61 insertions(+), 29 deletions(-)
[...]

Applied, thanks.
-- 
FFmpeg = Fascinating and Fiendish Mega Proud Extended Glue


More information about the ffmpeg-devel mailing list