summaryrefslogtreecommitdiff
path: root/libavutil
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-05-30 21:02:07 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-06-01 20:47:50 +0200
commitf028b7af7b785d8c69732b09cbddca61f641435a (patch)
tree03b601b2189fd51cab3b6a52d7436548f70d3765 /libavutil
parentc4d88311cd90cfe5ec676413963140fa9ef41f41 (diff)
avutil/opt: add opt_size()
If people want, this could be exported as av_opt_size()
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/opt.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/libavutil/opt.c b/libavutil/opt.c
index 199eadbc05..b4dd0fd0c1 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -1517,6 +1517,28 @@ void *av_opt_ptr(const AVClass *class, void *obj, const char *name)
return (uint8_t*)obj + opt->offset;
}
+static int opt_size(enum AVOptionType type)
+{
+ switch(type) {
+ case AV_OPT_TYPE_INT:
+ case AV_OPT_TYPE_FLAGS: return sizeof(int);
+ case AV_OPT_TYPE_DURATION:
+ case AV_OPT_TYPE_CHANNEL_LAYOUT:
+ case AV_OPT_TYPE_INT64: return sizeof(int64_t);
+ case AV_OPT_TYPE_DOUBLE: return sizeof(double);
+ case AV_OPT_TYPE_FLOAT: return sizeof(float);
+ case AV_OPT_TYPE_STRING: return sizeof(uint8_t*);
+ case AV_OPT_TYPE_VIDEO_RATE:
+ case AV_OPT_TYPE_RATIONAL: return sizeof(AVRational);
+ case AV_OPT_TYPE_BINARY: return sizeof(uint8_t*) + sizeof(int);
+ case AV_OPT_TYPE_IMAGE_SIZE:return sizeof(int[2]);
+ case AV_OPT_TYPE_PIXEL_FMT: return sizeof(enum AVPixelFormat);
+ case AV_OPT_TYPE_SAMPLE_FMT:return sizeof(enum AVSampleFormat);
+ case AV_OPT_TYPE_COLOR: return 4;
+ }
+ return 0;
+}
+
int av_opt_query_ranges(AVOptionRanges **ranges_arg, void *obj, const char *key, int flags)
{
int ret;