avutil/opt: add opt_size()

If people want, this could be exported as av_opt_size()
This commit is contained in:
Michael Niedermayer 2014-05-30 21:02:07 +02:00
parent c4d88311cd
commit f028b7af7b

View File

@ -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;