[FFmpeg-soc] [RFC] Apply function to pixel filter: vf_applyfn

zeger at customsoft.nl zeger at customsoft.nl
Mon May 25 15:47:59 CEST 2009


Hi, 

----- "Stefano Sabatini" <stefano.sabatini-lala at poste.it> wrote: 
> I believe pow *is* supported out of the box by the eval code. 

It is not enabled in the parse_primary(Parser *p) function.

> Docs and example go to doc/vfilters.texi. 

Removed them.

> enum VarName { 
> ... 
> VARS_NB 
> }; 
> 
> is better. 

Done.

> 
> And a PTS var may be useful too. 
> 

Working on that.

> > +static const char *applyfn_symbols[POV_NULL+1]={ 
>                                               ^^ 
> Why +1? 

I copied the code from vf_setpts, didn't gave it second thought. 

> > +        ApplyfnContext *applyfn = ctx->priv;
> > +        char Y_expr[256], U_expr[256], V_expr[256], A_expr[256];
> > +       const char *error;
> 
> Weird indent. 
> 

Fixed.

> > + sscanf(args, "%255[^:]:%255[^:]:%255[^:]:%255[^:]", Y_expr, U_expr, V_expr, A_expr) 
> 
> I believe here it would be nice to use av_set_options_string, check 
> vf_pad.c in the archive for an usage example. 

Done.

> > +        applyfn->value_V = ff_parse(V_expr, applyfn_symbols,
> > +                                NULL, NULL, NULL, NULL, &error);
> > +        if (!applyfn->value_V )
> > +            av_log(ctx, AV_LOG_ERROR,
> > +                   "init() cannot parse V expression due to %s\n", error);
> > +
> > +        applyfn->value_A = ff_parse(A_expr, applyfn_symbols,
> > +                                NULL, NULL, NULL, NULL, &error);
> > +        if (!applyfn->value_A )
> > +            av_log(ctx, AV_LOG_ERROR,
> > +                   "init() cannot parse A expression due to %s\n", error);
> This can be factorized (check again vf_pad.c to see how), maybe even a 
> macro may be used. 

I created a macro for it, I'm not sure if it is okay according to 
FFmpeg coding standards.

> > +static void draw_slice(AVFilterLink *link, int y, int h)
> > +{
> > +    ApplyfnContext *applyfn = link->dst->priv;
> > +    AVFilterPicRef *in  = link->cur_pic;
> > +    AVFilterPicRef *out = link->dst->outputs[0]->outpic;
> > +    uint8_t *inrow_0, *outrow_0, *alpharow, *outrow_1, *outrow_2, *inrow_1, *inrow_2;
> > +    int i, j, i_sub, j_sub, outrow_1_off, outrow_2_off, inrow_1_off, inrow_2_off;
> > +
> > +    applyfn->values[POV_N] += 1.0;
> 
> Ouch, this is wrong, as draw_slice() is called for every slice(), and 
> you don't know how many slices there are. This update should be done 
> in start_frame() / end_frame() (same for W and H, since they're not 
> supposed to change between a slice and another one). 
> 

Moved the code to start_frame. 

For some functions it would be much easier to normalize the YUV values
to [0.0..1.0][-0.5..0.5][-0.5..0.5] beforehand, would it be an addition 
if this were to be an option? 

Thanks for the feedback!

Zeger Knops
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vf_applyfn_2.diff
Type: text/x-diff
Size: 8665 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-soc/attachments/20090525/25361a4a/attachment.diff>


More information about the FFmpeg-soc mailing list