[FFmpeg-devel] [PATCH] frei0r wrapper
Stefano Sabatini
stefano.sabatini-lala
Sun Sep 5 17:33:32 CEST 2010
On date Sunday 2010-09-05 15:43:23 +0200, Michael Niedermayer encoded:
> On Mon, Aug 30, 2010 at 08:32:01PM +0200, Stefano Sabatini wrote:
> [...]
>
> > +
> > +where @var{filter_path} is the path to the frei0r effect to load, and
> > + at var{param1}, @var{param2}, ... , @var{paramN} is a list of values
> > +separated by ":" which specify the parameters for the frei0r effect.
> > +
> > +frei0r filters are usually installed in @file{/usr/lib/frei0r-1/}.
> > +
> > +A frei0r effect parameter can be a boolean (whose values are specified
> > +with "true" and "false"), a double, a color (specified by the syntax
> > + at var{R} @var{G} @var{B}), a position (specified by the syntax
> > + at var{x} @var{y}) and a string.
> > +
> > +The number and kind of parameters depend on the loaded effect. If an
> > +effect parameter is not specified the default value is set.
> > +
> > +Follows some example:
> > + at example
> > +# apply the distort0r effect, set the first two double parameters
> > +frei0r=/usr/lib/frei0r-1/distort0r.so:0.5:0.01
>
> requirering full pathes is lame when all filters are installed in like
> one place
Depends on the distro, also you can have the distro filters in one
place and your own filters into another dir.
> [...]
> > +static int set_param(AVFilterContext *ctx, f0r_param_info_t info, int index, char *param)
> > +{
> > + Frei0rContext *frei0r = ctx->priv;
> > + void *v;
>
> > + long double ld;
>
> what are you trying to do?
>
>
> > + double d;
> > + f0r_param_color_t col;
> > + f0r_param_position_t pos;
> > + f0r_set_param_value_f f0r_set_param_value;
> > +
> > + if (!(f0r_set_param_value = load_sym(ctx, "f0r_set_param_value")))
> > + return AVERROR(EINVAL);
> > +
>
> > + switch (info.type) {
> > + case F0R_PARAM_BOOL:
>
> > + {
>
> is that way of placing it consistent?
>
>
> > + if (!strcmp(param, "true" )) d = 1.0;
> > + else if (!strcmp(param, "false")) d = 0.0;
> > + else goto fail;
>
> we should allow something shorter than true false
on/off? Imho "true"/"false" is more readable then "1"/"0", especially
when you have a long list of params.
>
>
> > + v = (void *)(&d);
>
> the cast looks unneeded
>
>
> > + }
> > + break;
> > +
> > + case F0R_PARAM_DOUBLE:
> > + {
> > + char *tail;
> > + ld = strtold(param, &tail);
> > + if (*tail || ld > DBL_MAX || ld < -DBL_MAX)
> > + goto fail;
> > + d = ld;
> > + v = (void *)(&d);
> > + }
> > + break;
> > +
>
> > + case F0R_PARAM_COLOR:
> > + {
> > + if (sscanf(param, "%f %f %f", &col.r, &col.g, &col.b) != 3)
> > + goto fail;
> > + v = (void *)(&col);
>
> dont the spaces need escaping on the command line?
Yes, suggestion for a better way of describing a color are welcome,
maybe r.g.b?
> [...]
> > + switch (info.type) {
> > + case F0R_PARAM_BOOL:
> > + v = (void *)(&d);
> > + f0r_get_param_value(frei0r->instance, v, i);
> > + av_log(ctx, AV_LOG_INFO, "value:'%s'\n", d == 1.0 ? "true" : "false");
> > + break;
> > + case F0R_PARAM_DOUBLE:
> > + v = (void *)(&d);
> > + f0r_get_param_value(frei0r->instance, v, i);
> > + av_log(ctx, AV_LOG_INFO, "value:'%f'\n", d);
> > + break;
> > + case F0R_PARAM_COLOR:
> > + v = (void *)(&col);
> > + f0r_get_param_value(frei0r->instance, v, i);
> > + av_log(ctx, AV_LOG_INFO, "value:'%f %f %f'\n", col.r, col.g, col.b);
> > + break;
> > + case F0R_PARAM_POSITION:
> > + v = (void *)(&pos);
> > + f0r_get_param_value(frei0r->instance, v, i);
> > + av_log(ctx, AV_LOG_INFO, "value:'%lf %lf'\n", pos.x, pos.y);
> > + break;
> > + default: /* F0R_PARAM_STRING */
> > + v = (void *)s;
> > + f0r_get_param_value(frei0r->instance, v, i);
> > + av_log(ctx, AV_LOG_INFO, "value:'%s'\n", s);
> > + break;
> > + }
>
> what is this good for?
Useful for debugging.
> [...]
> > +static av_cold void uninit(AVFilterContext *ctx)
> > +{
> > + Frei0rContext *frei0r = ctx->priv;
> > + f0r_destruct_f f0r_destruct;
> > + f0r_deinit_f f0r_deinit;
> > +
> > + if ((f0r_destruct = dlsym(frei0r->dll, "f0r_destruct")))
> > + f0r_destruct(frei0r->instance);
>
> all the dlsym shoudl be done in "init()" IMHO
I'll do.
--
FFmpeg = Fierce Fundamental Majestic Portable Emblematic Governor
More information about the ffmpeg-devel
mailing list