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
1313
1414 API changes, most recent first:
1515
16+2011-08-xx - xxxxxxx - lavu 51.10.0
17+ Add AV_OPT_SEARCH_FAKE_OBJ flag for av_opt_find() function.
18+
1619 2011-08-xx - xxxxxx - lavu 51.9.0
1720 Add av_fifo_peek2(), deprecate av_fifo_peek().
1821
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
4444 AVCodecContext *s = obj;
4545 AVCodec *c = NULL;
4646
47− if (s->priv_data) {
47+ if (!(search_flags & AV_OPT_SEARCH_FAKE_OBJ) && s->priv_data) {
4848 if (s->codec->priv_class)
4949 return av_opt_find(s->priv_data, name, unit, opt_flags, search_flags);
5050 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
3838 AVFormatContext *s = obj;
3939 AVInputFormat *ifmt = NULL;
4040 AVOutputFormat *ofmt = NULL;
41− if (s->priv_data) {
41+ if (!(search_flags & AV_OPT_SEARCH_FAKE_OBJ) && s->priv_data) {
4242 if ((s->iformat && !s->iformat->priv_class) ||
4343 (s->oformat && !s->oformat->priv_class))
4444 return NULL;
libavutil/avutil.h+1−1
@@ -40,7 +40,7 @@ · 39 unmodified lines
4040 #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
4141
4242 #define LIBAVUTIL_VERSION_MAJOR 51
43−#define LIBAVUTIL_VERSION_MINOR 9
43+#define LIBAVUTIL_VERSION_MINOR 10
4444 #define LIBAVUTIL_VERSION_MICRO 0
4545
4646 #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
215215
216216 #define AV_OPT_SEARCH_CHILDREN 0x0001 /**< Search in possible children of the
217217 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
218225
219226 /**
220227 * 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
222229 *
223230 * @param[in] obj A pointer to a struct whose first element is a
224231 * pointer to an AVClass.
232+ * Alternatively a double pointer to an AVClass, if
233+ * AV_OPT_SEARCH_FAKE_OBJ search flag is set.
225234 * @param[in] name The name of the option to look for.
226235 * @param[in] unit When searching for named constants, name of the unit
227236 * 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