[FFmpeg-cvslog] Merge commit '564b4591bbe223bdc5f36a1131eaef103f23f5d0'

Derek Buitenhuis git at videolan.org
Tue Apr 19 20:20:44 CEST 2016


ffmpeg | branch: master | Derek Buitenhuis <derek.buitenhuis at gmail.com> | Tue Apr 19 19:17:50 2016 +0100| [e344646c808c4f2d0e9db32c5c1cbedb5871f171] | committer: Derek Buitenhuis

Merge commit '564b4591bbe223bdc5f36a1131eaef103f23f5d0'

* commit '564b4591bbe223bdc5f36a1131eaef103f23f5d0':
  opt: Add av_opt_copy()

Merged-by: Derek Buitenhuis <derek.buitenhuis at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e344646c808c4f2d0e9db32c5c1cbedb5871f171
---

 libavutil/opt.c     |   12 ++++++++----
 libavutil/version.h |    2 +-
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index eae4f75..cbe36df 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -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_COLOR:     return 4;
     }
-    return 0;
+    return AVERROR(EINVAL);
 }
 
 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;
 
     if (!src)
-        return 0;
+        return AVERROR(EINVAL);
 
     c = *(AVClass**)src;
-    if (*(AVClass**)dst && c != *(AVClass**)dst)
+    if (!c || c != *(AVClass**)dst)
         return AVERROR(EINVAL);
 
     while ((o = av_opt_next(src, o))) {
@@ -1637,7 +1637,11 @@ int av_opt_copy(void *dst, const void *src)
             if (av_dict_count(*sdict) != av_dict_count(*ddict))
                 ret = AVERROR(ENOMEM);
         } 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;
diff --git a/libavutil/version.h b/libavutil/version.h
index cf7458e..24bd0d0 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -65,7 +65,7 @@
 
 #define LIBAVUTIL_VERSION_MAJOR  55
 #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, \
                                                LIBAVUTIL_VERSION_MINOR, \


======================================================================

diff --cc libavutil/opt.c
index eae4f75,0150243..cbe36df
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@@ -1579,15 -766,10 +1579,15 @@@ static int opt_size(enum AVOptionType 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;
+     return AVERROR(EINVAL);
  }
  
  int av_opt_copy(void *dst, const void *src)
@@@ -1627,17 -812,12 +1627,21 @@@
              *(int*)(field_dst8 + 1) = len;
          } else if (o->type == AV_OPT_TYPE_CONST) {
              // do nothing
 +        } else if (o->type == AV_OPT_TYPE_DICT) {
 +            AVDictionary **sdict = (AVDictionary **) field_src;
 +            AVDictionary **ddict = (AVDictionary **) field_dst;
 +            if (*sdict != *ddict)
 +                av_dict_free(ddict);
 +            *ddict = NULL;
 +            av_dict_copy(ddict, *sdict, 0);
 +            if (av_dict_count(*sdict) != av_dict_count(*ddict))
 +                ret = AVERROR(ENOMEM);
          } 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;
diff --cc libavutil/version.h
index cf7458e,186ebd8..24bd0d0
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@@ -63,9 -53,9 +63,9 @@@
   * @{
   */
  
 -#define LIBAVUTIL_VERSION_MAJOR 55
 -#define LIBAVUTIL_VERSION_MINOR 10
 -#define LIBAVUTIL_VERSION_MICRO  0
 +#define LIBAVUTIL_VERSION_MAJOR  55
 +#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, \
                                                 LIBAVUTIL_VERSION_MINOR, \



More information about the ffmpeg-cvslog mailing list