Commit e344646c authored by Derek Buitenhuis's avatar Derek Buitenhuis

Merge commit '564b4591'

* commit '564b4591':
  opt: Add av_opt_copy()
Merged-by: 's avatarDerek Buitenhuis <derek.buitenhuis@gmail.com>
parents c54d835e 564b4591
...@@ -1587,7 +1587,7 @@ static int opt_size(enum AVOptionType type) ...@@ -1587,7 +1587,7 @@ static int opt_size(enum AVOptionType type)
case AV_OPT_TYPE_SAMPLE_FMT:return sizeof(enum AVSampleFormat); case AV_OPT_TYPE_SAMPLE_FMT:return sizeof(enum AVSampleFormat);
case AV_OPT_TYPE_COLOR: return 4; case AV_OPT_TYPE_COLOR: return 4;
} }
return 0; return AVERROR(EINVAL);
} }
int av_opt_copy(void *dst, const void *src) int av_opt_copy(void *dst, const void *src)
...@@ -1597,10 +1597,10 @@ int av_opt_copy(void *dst, const void *src) ...@@ -1597,10 +1597,10 @@ int av_opt_copy(void *dst, const void *src)
int ret = 0; int ret = 0;
if (!src) if (!src)
return 0; return AVERROR(EINVAL);
c = *(AVClass**)src; c = *(AVClass**)src;
if (*(AVClass**)dst && c != *(AVClass**)dst) if (!c || c != *(AVClass**)dst)
return AVERROR(EINVAL); return AVERROR(EINVAL);
while ((o = av_opt_next(src, o))) { while ((o = av_opt_next(src, o))) {
...@@ -1637,7 +1637,11 @@ int av_opt_copy(void *dst, const void *src) ...@@ -1637,7 +1637,11 @@ int av_opt_copy(void *dst, const void *src)
if (av_dict_count(*sdict) != av_dict_count(*ddict)) if (av_dict_count(*sdict) != av_dict_count(*ddict))
ret = AVERROR(ENOMEM); ret = AVERROR(ENOMEM);
} else { } else {
memcpy(field_dst, field_src, opt_size(o->type)); int size = opt_size(o->type);
if (size < 0)
ret = size;
else
memcpy(field_dst, field_src, size);
} }
} }
return ret; return ret;
......
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
#define LIBAVUTIL_VERSION_MAJOR 55 #define LIBAVUTIL_VERSION_MAJOR 55
#define LIBAVUTIL_VERSION_MINOR 22 #define LIBAVUTIL_VERSION_MINOR 22
#define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_MICRO 101
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \ LIBAVUTIL_VERSION_MINOR, \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment