History

AVOptions: add AV_OPT_SEARCH_FAKE_OBJ flag for av_opt_find().

It allows to search for options only with AVClass, without allocating the corresponding context.

Anton Khirnov committed 15 years ago

Commit c11fb821 parent 5938e025 files · +15 −3Browse files

Unified · Split

5 files
  1. doc/APIchanges +3 −0
  2. libavcodec/options.c +1 −1
  3. libavformat/options.c +1 −1
  4. libavutil/avutil.h +1 −1
  5. libavutil/opt.h +9 −0
doc/APIchanges+3−0
@@ -13,6 +13,9 @@ libavutil: 2011-04-18 · 12 unmodified lines
13 13
14API changes, most recent first:14API changes, most recent first:
15 15
162011-08-xx - xxxxxxx - lavu 51.10.0
17 Add AV_OPT_SEARCH_FAKE_OBJ flag for av_opt_find() function.
18
162011-08-xx - xxxxxx - lavu 51.9.0192011-08-xx - xxxxxx - lavu 51.9.0
17 Add av_fifo_peek2(), deprecate av_fifo_peek().20 Add av_fifo_peek2(), deprecate av_fifo_peek().
18 21
libavcodec/options.c+1−1
@@ -44,7 +44,7 @@ static const AVOption *opt_find(void *obj, const char *name, const char *unit, i · 43 unmodified lines
44 AVCodecContext *s = obj;44 AVCodecContext *s = obj;
45 AVCodec *c = NULL;45 AVCodec *c = NULL;
46 46
47 if (s->priv_data) {47 if (!(search_flags & AV_OPT_SEARCH_FAKE_OBJ) && s->priv_data) {
48 if (s->codec->priv_class)48 if (s->codec->priv_class)
49 return av_opt_find(s->priv_data, name, unit, opt_flags, search_flags);49 return av_opt_find(s->priv_data, name, unit, opt_flags, search_flags);
50 return NULL;50 return NULL;
libavformat/options.c+1−1
@@ -38,7 +38,7 @@ static const AVOption *opt_find(void *obj, const char *name, const char *unit, i · 37 unmodified lines
38 AVFormatContext *s = obj;38 AVFormatContext *s = obj;
39 AVInputFormat *ifmt = NULL;39 AVInputFormat *ifmt = NULL;
40 AVOutputFormat *ofmt = NULL;40 AVOutputFormat *ofmt = NULL;
41 if (s->priv_data) {41 if (!(search_flags & AV_OPT_SEARCH_FAKE_OBJ) && s->priv_data) {
42 if ((s->iformat && !s->iformat->priv_class) ||42 if ((s->iformat && !s->iformat->priv_class) ||
43 (s->oformat && !s->oformat->priv_class))43 (s->oformat && !s->oformat->priv_class))
44 return NULL;44 return NULL;
libavutil/avutil.h+1−1
@@ -40,7 +40,7 @@ · 39 unmodified lines
40#define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)40#define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
41 41
42#define LIBAVUTIL_VERSION_MAJOR 5142#define LIBAVUTIL_VERSION_MAJOR 51
43#define LIBAVUTIL_VERSION_MINOR 943#define LIBAVUTIL_VERSION_MINOR 10
44#define LIBAVUTIL_VERSION_MICRO 044#define LIBAVUTIL_VERSION_MICRO 0
45 45
46#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \46#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
libavutil/opt.h+9−0
@@ -215,6 +215,13 @@ int av_opt_set_dict(void *obj, struct AVDictionary **options); · 214 unmodified lines
215 215
216#define AV_OPT_SEARCH_CHILDREN 0x0001 /**< Search in possible children of the216#define AV_OPT_SEARCH_CHILDREN 0x0001 /**< Search in possible children of the
217 given object first. */217 given object first. */
218/**
219 * The obj passed to av_opt_find() is fake -- only a double pointer to AVClass
220 * instead of a required pointer to a struct containing AVClass. This is
221 * useful for searching for options without needing to allocate the corresponding
222 * object.
223 */
224#define AV_OPT_SEARCH_FAKE_OBJ 0x0002
218 225
219/**226/**
220 * Look for an option in an object. Consider only options which227 * Look for an option in an object. Consider only options which
@@ -222,6 +229,8 @@ int av_opt_set_dict(void *obj, struct AVDictionary **options); · 1 unmodified line
222 *229 *
223 * @param[in] obj A pointer to a struct whose first element is a230 * @param[in] obj A pointer to a struct whose first element is a
224 * pointer to an AVClass.231 * pointer to an AVClass.
232 * Alternatively a double pointer to an AVClass, if
233 * AV_OPT_SEARCH_FAKE_OBJ search flag is set.
225 * @param[in] name The name of the option to look for.234 * @param[in] name The name of the option to look for.
226 * @param[in] unit When searching for named constants, name of the unit235 * @param[in] unit When searching for named constants, name of the unit
227 * it belongs to.236 * it belongs to.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t