diff options
author | Stefano Sabatini <stefasab@gmail.com> | 2012-11-25 15:45:58 +0100 |
---|---|---|
committer | Stefano Sabatini <stefasab@gmail.com> | 2012-11-30 00:01:53 +0100 |
commit | 08d0969c1402ccec4dce44bd430128fb59d7b790 (patch) | |
tree | 60a36c18b0619a928b74081552f7f3a6bc7efec8 /libavutil/opt.c | |
parent | 0b28abf903cd1fd61ba4a06009cd2cb7cc40e6e0 (diff) | |
download | ffmpeg-streaming-08d0969c1402ccec4dce44bd430128fb59d7b790.zip ffmpeg-streaming-08d0969c1402ccec4dce44bd430128fb59d7b790.tar.gz |
lavu/opt: change the way default pixel and sample format value is set
Use the i64 field rather than the string value. Using a string to set a
default sample/pixel format is weird, also the new interface is more
consistent with the rest of the API.
This is technically an API break, but hopefully there are no applications
using this feature outside of FFmpeg. In order to save backward
compatibility with mixed libraries in case libavutil is updated but not
the other libraries, some ifdeffery hacks are added.
Note that the version check is only performed when class->version != 0,
since if it is not defined then we assume that no version was defined and
the class is not affected by the change.
We will luckily get rid of the hack at the next major bump.
Diffstat (limited to 'libavutil/opt.c')
-rw-r--r-- | libavutil/opt.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/libavutil/opt.c b/libavutil/opt.c index b9da676..930ace5 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -813,6 +813,7 @@ void av_opt_set_defaults(void *s) void av_opt_set_defaults2(void *s, int mask, int flags) { #endif + const AVClass *class = *(AVClass **)s; const AVOption *opt = NULL; while ((opt = av_opt_next(s, opt)) != NULL) { #if FF_API_OLD_AVOPTIONS @@ -843,9 +844,23 @@ void av_opt_set_defaults2(void *s, int mask, int flags) break; case AV_OPT_TYPE_STRING: case AV_OPT_TYPE_IMAGE_SIZE: + av_opt_set(s, opt->name, opt->default_val.str, 0); + break; case AV_OPT_TYPE_PIXEL_FMT: +#if LIBAVUTIL_VERSION_MAJOR < 53 + if (class->version && class->version < AV_VERSION_INT(52, 10, 100)) + av_opt_set(s, opt->name, opt->default_val.str, 0); + else +#endif + av_opt_set_pixel_fmt(s, opt->name, opt->default_val.i64, 0); + break; case AV_OPT_TYPE_SAMPLE_FMT: - av_opt_set(s, opt->name, opt->default_val.str, 0); +#if LIBAVUTIL_VERSION_MAJOR < 53 + if (class->version && class->version < AV_VERSION_INT(52, 10, 100)) + av_opt_set(s, opt->name, opt->default_val.str, 0); + else +#endif + av_opt_set_sample_fmt(s, opt->name, opt->default_val.i64, 0); break; case AV_OPT_TYPE_BINARY: /* Cannot set default for binary */ @@ -1164,8 +1179,8 @@ static const AVOption test_options[]= { {"lame", "set lame flag ", 0, AV_OPT_TYPE_CONST, {.i64 = TEST_FLAG_LAME}, INT_MIN, INT_MAX, 0, "flags" }, {"mu", "set mu flag ", 0, AV_OPT_TYPE_CONST, {.i64 = TEST_FLAG_MU}, INT_MIN, INT_MAX, 0, "flags" }, {"size", "set size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE,{0}, 0, 0 }, -{"pix_fmt", "set pixfmt", OFFSET(pix_fmt), AV_OPT_TYPE_PIXEL_FMT,{0}, 0, 0 }, -{"sample_fmt", "set samplefmt", OFFSET(sample_fmt), AV_OPT_TYPE_SAMPLE_FMT,{0}, 0, 0 }, +{"pix_fmt", "set pixfmt", OFFSET(pix_fmt), AV_OPT_TYPE_PIXEL_FMT, {.i64 = AV_PIX_FMT_NONE}}, +{"sample_fmt", "set samplefmt", OFFSET(sample_fmt), AV_OPT_TYPE_SAMPLE_FMT, {.i64 = AV_SAMPLE_FMT_NONE}}, {NULL}, }; |