[FFmpeg-devel] [PATCH] Implement options parsing for avfilter filters
Stefano Sabatini
stefano.sabatini-lala
Sun Apr 19 13:23:09 CEST 2009
On date Sunday 2009-04-19 13:11:36 +0200, Vitor Sessak encoded:
> Stefano Sabatini wrote:
>> Hi,
>> as recently discussed, plus application to the libavfilter-soc scale
>> filter.
>>
>> I'm not very happy with the parse_options.[hc] name, suggestions are
>> welcome.
>
>> static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
>> {
>> ScaleContext *scale = ctx->priv;
>> char sws_opts[256];
>> - char *p;
>> /* default to no scaling */
>> + scale->av_class = &vf_scale_class;
>> + av_opt_set_defaults2(scale, 0, 0);
>> +
>> scale->w =
>> scale->h = 0;
>> @@ -55,11 +69,11 @@
>> if(args)
>> sscanf(args, "%d:%d:%255s", &scale->w, &scale->h, sws_opts);
>> - if ((p = strstr(sws_opts, "sws_flags="))) {
>> - char sws_flags[256];
>> - sscanf(p, "sws_flags=%255[^:]", sws_flags);
>> + if (avfilter_parse_options(scale, sws_opts) < 0)
>
> Why not simply pass ctx to avfilter_parse_options()? It would avoid the
> need of the CREATE_FILTER_CLASS macro...
I considered that solution but I don't believe it can be achieved.
av_opt_set* functions work by setting values in an AVClass context,
with respect to the the offset defined in that context.
When I define the options I need to pass the offsets of the ScaleContext
struct, since I cannot extend AVFilterContext to contain fields
specific to each filter.
Regards.
--
FFmpeg = Faboulous Fostering Minimalistic Puristic Enlightened Genius
More information about the ffmpeg-devel
mailing list