Fixes encoder private options, which are broken now in ffmpeg, because opt_default2() can't find them, thus making opt_default() to fail.
Unified · Split
| @@ -37,6 +37,25 @@ static const char* context_to_name(void* ptr) { · 36 unmodified lines | |||
| 37 | return "NULL"; | 37 | return "NULL"; |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | static const AVOption *opt_find(void *obj, const char *name, const char *unit, int opt_flags, int search_flags) | ||
| 41 | { | ||
| 42 | AVCodecContext *s = obj; | ||
| 43 | AVCodec *c = NULL; | ||
| 44 | |||
| 45 | if (s->priv_data) { | ||
| 46 | if (s->codec->priv_class) | ||
| 47 | return av_opt_find(s->priv_data, name, unit, opt_flags, search_flags); | ||
| 48 | return NULL; | ||
| 49 | } | ||
| 50 | |||
| 51 | while ((c = av_codec_next(c))) { | ||
| 52 | const AVOption *o; | ||
| 53 | if (c->priv_class && (o = av_opt_find(&c->priv_class, name, unit, opt_flags, search_flags))) | ||
| 54 | return o; | ||
| 55 | } | ||
| 56 | return NULL; | ||
| 57 | } | ||
| 58 | |||
| 40 | #define OFFSET(x) offsetof(AVCodecContext,x) | 59 | #define OFFSET(x) offsetof(AVCodecContext,x) |
| 41 | #define DEFAULT 0 //should be NAN but it does not work as it is not a constant in glibc as required by ANSI/ISO C | 60 | #define DEFAULT 0 //should be NAN but it does not work as it is not a constant in glibc as required by ANSI/ISO C |
| 42 | //these names are too long to be readable | 61 | //these names are too long to be readable |
| @@ -457,7 +476,7 @@ static const AVOption options[]={ · 414 unmodified lines | |||
| 457 | #undef D | 476 | #undef D |
| 458 | #undef DEFAULT | 477 | #undef DEFAULT |
| 459 | 478 | ||
| 460 | static const AVClass av_codec_context_class = { "AVCodecContext", context_to_name, options, LIBAVUTIL_VERSION_INT, OFFSET(log_level_offset) }; | 479 | static const AVClass av_codec_context_class = { "AVCodecContext", context_to_name, options, LIBAVUTIL_VERSION_INT, OFFSET(log_level_offset), .opt_find = opt_find}; |
| 461 | 480 | ||
| 462 | void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType codec_type){ | 481 | void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType codec_type){ |
| 463 | int flags=0; | 482 | int flags=0; |