It allows to search for options only with AVClass, without allocating the corresponding context.
Unified · Split
| @@ -13,6 +13,9 @@ libavutil: 2011-04-18 · 12 unmodified lines | |||
| 13 | 13 | ||
| 14 | API changes, most recent first: | 14 | API changes, most recent first: |
| 15 | 15 | ||
| 16 | 2011-08-xx - xxxxxxx - lavu 51.10.0 | ||
| 17 | Add AV_OPT_SEARCH_FAKE_OBJ flag for av_opt_find() function. | ||
| 18 | |||
| 16 | 2011-08-xx - xxxxxx - lavu 51.9.0 | 19 | 2011-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 | ||
| @@ -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; |
| @@ -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; |
| @@ -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 51 | 42 | #define LIBAVUTIL_VERSION_MAJOR 51 |
| 43 | #define LIBAVUTIL_VERSION_MINOR 9 | 43 | #define LIBAVUTIL_VERSION_MINOR 10 |
| 44 | #define LIBAVUTIL_VERSION_MICRO 0 | 44 | #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, \ |
| @@ -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 the | 216 | #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 which | 227 | * 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 a | 230 | * @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 unit | 235 | * @param[in] unit When searching for named constants, name of the unit |
| 227 | * it belongs to. | 236 | * it belongs to. |