aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil/opt.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-02-20 02:01:13 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-02-20 02:01:13 +0100
commit6a24d77929e0d5425c79a081034719ac68199602 (patch)
tree5300b75b67ae1494e494333730e4234a16562839 /libavutil/opt.c
parentf4c8d002231afbc181e97c512e459ec6860f7098 (diff)
parentc3ecd968f0e78da6e77f0c06c2f785b266d83cf1 (diff)
downloadffmpeg-6a24d77929e0d5425c79a081034719ac68199602.tar.gz
Merge commit 'c3ecd968f0e78da6e77f0c06c2f785b266d83cf1'
* commit 'c3ecd968f0e78da6e77f0c06c2f785b266d83cf1': AVOptions: add flags for read/read-only options Conflicts: libavutil/opt.c libavutil/opt.h libavutil/version.h Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil/opt.c')
-rw-r--r--libavutil/opt.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/libavutil/opt.c b/libavutil/opt.c
index c74f220ca1..bff3b6e555 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -374,6 +374,9 @@ int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
o->type != AV_OPT_TYPE_CHANNEL_LAYOUT))
return AVERROR(EINVAL);
+ if (o->flags & AV_OPT_FLAG_READONLY)
+ return AVERROR(EINVAL);
+
dst = ((uint8_t*)target_obj) + o->offset;
switch (o->type) {
case AV_OPT_TYPE_STRING: return set_string(obj, o, val, dst);
@@ -425,7 +428,7 @@ int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
#define OPT_EVAL_NUMBER(name, opttype, vartype)\
int av_opt_eval_ ## name(void *obj, const AVOption *o, const char *val, vartype *name ## _out)\
{\
- if (!o || o->type != opttype)\
+ if (!o || o->type != opttype || o->flags & AV_OPT_FLAG_READONLY)\
return AVERROR(EINVAL);\
return set_string_number(obj, obj, o, val, name ## _out);\
}
@@ -446,6 +449,9 @@ static int set_number(void *obj, const char *name, double num, int den, int64_t
if (!o || !target_obj)
return AVERROR_OPTION_NOT_FOUND;
+ if (o->flags & AV_OPT_FLAG_READONLY)
+ return AVERROR(EINVAL);
+
dst = ((uint8_t*)target_obj) + o->offset;
return write_number(obj, o, dst, num, den, intnum);
}
@@ -502,7 +508,7 @@ int av_opt_set_bin(void *obj, const char *name, const uint8_t *val, int len, int
if (!o || !target_obj)
return AVERROR_OPTION_NOT_FOUND;
- if (o->type != AV_OPT_TYPE_BINARY)
+ if (o->type != AV_OPT_TYPE_BINARY || o->flags & AV_OPT_FLAG_READONLY)
return AVERROR(EINVAL);
ptr = len ? av_malloc(len) : NULL;
@@ -1042,6 +1048,8 @@ static void opt_list(void *obj, void *av_log_obj, const char *unit,
av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_VIDEO_PARAM ) ? 'V' : '.');
av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_AUDIO_PARAM ) ? 'A' : '.');
av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_SUBTITLE_PARAM) ? 'S' : '.');
+ av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_EXPORT) ? 'X' : '.');
+ av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_READONLY) ? 'R' : '.');
if (opt->help)
av_log(av_log_obj, AV_LOG_INFO, " %s", opt->help);
@@ -1145,6 +1153,10 @@ void av_opt_set_defaults2(void *s, int mask, int flags)
if ((opt->flags & mask) != flags)
continue;
#endif
+
+ if (opt->flags & AV_OPT_FLAG_READONLY)
+ continue;
+
switch (opt->type) {
case AV_OPT_TYPE_CONST:
/* Nothing to be done here */