History

lavc: add opt_find to AVCodecContext class.

Fixes encoder private options, which are broken now in ffmpeg, because opt_default2() can't find them, thus making opt_default() to fail.

Anton Khirnov committed 15 years ago

Commit 78440c01 parent 3803af21 file · +20 −1Browse files

Unified · Split

libavcodec/options.c+20−1
@@ -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
40static 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 C60#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 readable61//these names are too long to be readable
@@ -457,7 +476,7 @@ static const AVOption options[]={ · 414 unmodified lines
457#undef D476#undef D
458#undef DEFAULT477#undef DEFAULT
459 478
460static const AVClass av_codec_context_class = { "AVCodecContext", context_to_name, options, LIBAVUTIL_VERSION_INT, OFFSET(log_level_offset) };479static const AVClass av_codec_context_class = { "AVCodecContext", context_to_name, options, LIBAVUTIL_VERSION_INT, OFFSET(log_level_offset), .opt_find = opt_find};
461 480
462void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType codec_type){481void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType codec_type){
463 int flags=0;482 int flags=0;

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