On 08.11.2014 19:36, Michael Niedermayer wrote:
On Sat, Nov 08, 2014 at 06:13:53PM +0100, Lukasz Marek wrote:
Signed-off-by: Lukasz Marek <lukasz.m.lu...@gmail.com>
---
  libavutil/opt.c | 7 +++++++
  1 file changed, 7 insertions(+)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index 0692393..86d3ddf 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -1596,6 +1596,13 @@ int av_opt_copy(void *dst, void *src)
              *(int*)(field_dst8 + 1) = len;
          } else if (o->type == AV_OPT_TYPE_CONST) {
              // do nothing
+        } else if (o->type == AV_OPT_TYPE_DICT) {
+            if (*field_dst8 != *field_src8)
+                av_dict_free(field_dst8);
+            *field_dst8 = NULL;
+            av_dict_copy(field_dst8, *field_src8, 0);
+            if (av_dict_count(*field_src8) != av_dict_count(*field_dst8))
+                ret = AVERROR(ENOMEM);

this results in some warnings:

libavutil/opt.c:1601:17: warning: passing argument 1 of ‘av_dict_free’ from 
incompatible pointer type [enabled by default]
libavutil/dict.h:172:6: note: expected ‘struct AVDictionary **’ but argument is 
of type ‘uint8_t **’
libavutil/opt.c:1603:13: warning: passing argument 1 of ‘av_dict_copy’ from 
incompatible pointer type [enabled by default]
libavutil/dict.h:166:6: note: expected ‘struct AVDictionary **’ but argument is 
of type ‘uint8_t **’
libavutil/opt.c:1603:13: warning: passing argument 2 of ‘av_dict_copy’ from 
incompatible pointer type [enabled by default]
libavutil/dict.h:166:6: note: expected ‘const struct AVDictionary *’ but 
argument is of type ‘uint8_t *’
libavutil/opt.c:1604:13: warning: passing argument 1 of ‘av_dict_count’ from 
incompatible pointer type [enabled by default]
libavutil/dict.h:113:5: note: expected ‘const struct AVDictionary *’ but 
argument is of type ‘uint8_t *’
libavutil/opt.c:1604:13: warning: passing argument 1 of ‘av_dict_count’ from 
incompatible pointer type [enabled by default]

OK, sorry
I attached fixed version

>From 0b84cf7c4615fb8deeaa3103dacad1616aa0bba2 Mon Sep 17 00:00:00 2001
From: Lukasz Marek <lukasz.m.lu...@gmail.com>
Date: Sat, 8 Nov 2014 18:12:56 +0100
Subject: [PATCH] lavu/opt: copy dict in av_opt_copy

Signed-off-by: Lukasz Marek <lukasz.m.lu...@gmail.com>
---
 libavutil/opt.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index 325ca6b..8dd03e9 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -1596,6 +1596,15 @@ int av_opt_copy(void *dst, void *src)
             *(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));
         }
-- 
1.9.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to