On Mon, 30 May 2011 22:18:31 +0200, Stefano Sabatini <[email protected]> wrote: > On date Monday 2011-05-30 21:15:20 +0200, Anton Khirnov encoded: > > --- > > libavutil/log.h | 7 +++++++ > > libavutil/opt.c | 18 ++++++++++++++++++ > > libavutil/opt.h | 20 ++++++++++++++++++++ > > 3 files changed, 45 insertions(+), 0 deletions(-) > > > > diff --git a/libavutil/log.h b/libavutil/log.h > > index 1cd9269..67682a2 100644 > > --- a/libavutil/log.h > > +++ b/libavutil/log.h > > @@ -70,6 +70,13 @@ typedef struct { > > * can be NULL of course > > */ > > int parent_log_context_offset; > > + > > + /** > > + * A function for extended searching. E.g. scanning possible > > + * children objects. > > + */ > > + const struct AVOption* (*opt_find)(void *obj, const char *name, const > > char *unit, > > + int opt_flags, int search_flags); > > } AVClass; > > > > /* av_log API */ > > diff --git a/libavutil/opt.c b/libavutil/opt.c > > index e7f7780..a1fd13f 100644 > > --- a/libavutil/opt.c > > +++ b/libavutil/opt.c > > @@ -541,6 +541,24 @@ int avopt_process(void *obj, AVMetadata **options) > > return ret; > > } > > > > +const AVOption *avopt_find(void *obj, const char *name, const char *unit, > > + int opt_flags, int search_flags) > > +{ > > + AVClass *c = *(AVClass**)obj; > > + const AVOption *o = NULL; > > + > > + if (c->opt_find && search_flags & AVOPT_SEARCH_CHILDREN && > > + (o = c->opt_find(obj, name, unit, opt_flags, search_flags))) > > + return o; > > + > > + while ((o = av_next_option(obj, o))) { > > + if (!strcmp(o->name, name) && (!unit || (o->unit && > > !strcmp(o->unit, unit))) && > > + (o->flags & opt_flags) == opt_flags) > > + return o; > > + } > > + return NULL; > > +} > > + > > #ifdef TEST > > > > #undef printf > > diff --git a/libavutil/opt.h b/libavutil/opt.h > > index 5424d86..e3157ba 100644 > > --- a/libavutil/opt.h > > +++ b/libavutil/opt.h > > @@ -189,4 +189,24 @@ int av_set_options_string(void *ctx, const char *opts, > > */ > > int avopt_process(void *obj, struct AVMetadata **options); > > > > +#define AVOPT_SEARCH_CHILDREN 0x0001 /**< Search also in possible > > children of the given object. */ > > + > > +/** > > + * Look for an option in obj. Look only for the options which > > + * have the specified flags set. > > This is missing the mask av_find_opt() mechanism. Not sure it is a > problem though. >
I tried to imagine a situation where it's useful to have mask != flags and failed. Ideas welcome. > > + * > > + * @param[in] obj A pointer to a struct whose first element is a > > + * pointer to an AVClass. > > + * @param[in] name The name of the option to look for. > > + * @param[in] unit When searching for named constants, name of the unit > > + * it belongs to. > > + * @param opt_flags Find only options with those flags set (AV_OPT_FLAG). > > + * @param search_flags A combination of AVOPT_SEARCH_*. > > + * > > + * @return A pointer to the option found, or NULL if no option > > + * has been found. > > + */ > > +const AVOption *avopt_find(void *obj, const char *name, const char *unit, > > + int opt_flags, int search_flags); > > Namescheme: av_opt_find() looks better (consistent with the av_opt_ > scheme), I'm not sure this is meant as a general replacement for > av_find_opt() though. Yes it is, av_find_opt is meant to be deprecated. As for the naming bikeshed, avopt_* namespace is consistent with avcodec_, avformat_, avfilter_, avio_ etc. It also saves you one character ;) -- Anton Khirnov _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
