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

Zeger Knops zeger at customsoft.nl
Wed May 27 17:49:37 CEST 2009


Hi,

I've switched to another mailer which shouldn't break threads.

On Tue, 2009-05-26 at 00:58 +0200, Stefano Sabatini wrote:
> > > Docs and example go to doc/vfilters.texi. 
> > 
> > Removed them.
> 
> Uh, what about to move them to doc/vfilters.texi?

Added to the patch.

> > > And a PTS var may be useful too. 
> > > 
> > 
> > Working on that.

pts has been added.
 
> > 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? 
> 
> Yes, I believe so. Maybe simply adding some vars for the normalized
> values will be fine.

Wouldn't adding the vars make things tricky when evaluating the
expression? How would the expression Y=pow(Yn,0.25)+Y (where Yn is Y
normalized) be evaluated?

> Some nits:
> 
> > +    if ( out->data[3] )
> 
> I believe (out->data[3]) style is preferred.
> 
> > +        alpharow = out->data[3] + y * out->linesize[3];
> > +
> > +    for(i = 0; i < h; i ++) {
> > +        applyfn->var_values[y] = i;
> > +        i_sub = i >> applyfn->hsub;
> > +        for(j = 0; j < link->w; j ++)
> > +        {
> > +           j_sub = j >> applyfn->hsub;
> 
> Not K&R style (for brace not on the same line as the for), and weird
> indent.
> 
> > +            applyfn->var_values[x] = j;
> > +
> > +            applyfn->var_values[Y] = inrow_0[j];
> > +            applyfn->var_values[U] = inrow_1[j_sub];
> > +            applyfn->var_values[V] = inrow_2[j_sub];
> > +
> > +            applyfn->var_values[A] = out->data[3] ? alpharow[j] : 0;
> > +
> > +            outrow_0[j]     = ff_parse_eval(applyfn->Y_evalexpr, applyfn->var_values, applyfn);
> > +            outrow_1[j_sub] = ff_parse_eval(applyfn->U_evalexpr, applyfn->var_values, applyfn);
> > +            outrow_2[j_sub] = ff_parse_eval(applyfn->V_evalexpr, applyfn->var_values, applyfn);
> > +
> > +            if ( out->data[3] )
>                   ^^^^^^^^^^^^^^^^
> > +                alpharow[j] = ff_parse_eval(applyfn->A_evalexpr, applyfn->var_values, applyfn);
> > +
> > +        }
> > +        inrow_0  += in-> linesize[0];
> > +        outrow_0 += out->linesize[0];
> > +
> > +        if ( out->data[3] )
>               ^^^^^^^^^^^^^^^^
> 
> > +            alpharow += out->linesize[3];
> > +
> > +        inrow_1  = inrow_1_off  + in-> data[1] + i_sub * in-> linesize[1];
> > +        inrow_2  = inrow_2_off  + in-> data[2] + i_sub * in-> linesize[2];
> > +        outrow_1 = outrow_1_off + out->data[1] + i_sub * out->linesize[1];
> > +        outrow_2 = outrow_2_off + out->data[2] + i_sub * out->linesize[2];
> > +    }
> > +
> > +    avfilter_draw_slice(link->dst->outputs[0], y, h);
> > +}
> > +
> > +AVFilter avfilter_vf_applyfn =
> > +{
> > +    .name      = "applyfn",
> > +    .init      = init,
> 

Updated to K&R style.

> Rethinking at it, I wrote a very similar filter named vf_eval.c but
> which worked in the RGB colorspace.
> 
> Maybe it would be less confusing for the users to give to this filters
> some related names, for example:
> rgbeval and yuveval,
> or
> yuvapplyfn and rgbapplyfn.
> 
> If you don't mind consider to change accordingly the name of the
> filter (but await for others devs opinion, Vitor?).

I don't mind renaming the filter. 

The filter has been updated to support remapping of x and y, so
flipping the video can be done with applyfn="x_exp=W-x" or
apply="x_exp=H-y". A cheesy water effect is achieved with
applyfn="x_exp=x+10*sin((y/H)*PI*10+(N/4))". 

Thanks for the feedback,

Zeger Knops
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vf_applyfn_3.diff
Type: text/x-patch
Size: 9831 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-soc/attachments/20090527/fd917e82/attachment.bin>


More information about the FFmpeg-soc mailing list