[FFmpeg-cvslog] lavu/opt: support NULL and special "none" values for size and pixel format options
Stefano Sabatini
git at videolan.org
Wed Sep 5 16:12:55 CEST 2012
ffmpeg | branch: master | Stefano Sabatini <stefasab at gmail.com> | Thu Aug 9 22:55:49 2012 +0200| [5666a1b270ffffb2f7d5485b9176758cab399df5] | committer: Stefano Sabatini
lavu/opt: support NULL and special "none" values for size and pixel format options
Allow to specify NULL values explicitly, thus overriding the default
values set in the context.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5666a1b270ffffb2f7d5485b9176758cab399df5
---
libavutil/opt.c | 12 ++++++++++--
libavutil/version.h | 2 +-
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/libavutil/opt.c b/libavutil/opt.c
index 960170b..5f8aaad 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -241,7 +241,7 @@ int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj);
if (!o || !target_obj)
return AVERROR_OPTION_NOT_FOUND;
- if (!val && o->type != AV_OPT_TYPE_STRING)
+ if (!val && (o->type != AV_OPT_TYPE_STRING && o->type != AV_OPT_TYPE_PIXEL_FMT && o->type != AV_OPT_TYPE_IMAGE_SIZE))
return AVERROR(EINVAL);
dst = ((uint8_t*)target_obj) + o->offset;
@@ -255,11 +255,18 @@ int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
case AV_OPT_TYPE_DOUBLE:
case AV_OPT_TYPE_RATIONAL: return set_string_number(obj, o, val, dst);
case AV_OPT_TYPE_IMAGE_SIZE:
+ if (!val || !strcmp(val, "none")) {
+ *(int *)dst = *((int *)dst + 1) = 0;
+ return 0;
+ }
ret = av_parse_video_size(dst, ((int *)dst) + 1, val);
if (ret < 0)
av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as image size\n", val);
return ret;
case AV_OPT_TYPE_PIXEL_FMT:
+ if (!val || !strcmp(val, "none"))
+ ret = PIX_FMT_NONE;
+ else {
ret = av_get_pix_fmt(val);
if (ret == PIX_FMT_NONE) {
char *tail;
@@ -269,6 +276,7 @@ int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
return AVERROR(EINVAL);
}
}
+ }
*(enum PixelFormat *)dst = ret;
return 0;
}
@@ -457,7 +465,7 @@ int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
ret = snprintf(buf, sizeof(buf), "%dx%d", ((int *)dst)[0], ((int *)dst)[1]);
break;
case AV_OPT_TYPE_PIXEL_FMT:
- ret = snprintf(buf, sizeof(buf), "%s", (char *)av_x_if_null(av_get_pix_fmt_name(*(enum PixelFormat *)dst), "?"));
+ ret = snprintf(buf, sizeof(buf), "%s", (char *)av_x_if_null(av_get_pix_fmt_name(*(enum PixelFormat *)dst), "none"));
break;
default:
return AVERROR(EINVAL);
diff --git a/libavutil/version.h b/libavutil/version.h
index f8cc602..535c1af 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -40,7 +40,7 @@
#define LIBAVUTIL_VERSION_MAJOR 51
#define LIBAVUTIL_VERSION_MINOR 71
-#define LIBAVUTIL_VERSION_MICRO 100
+#define LIBAVUTIL_VERSION_MICRO 101
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \
More information about the ffmpeg-cvslog
mailing list