[FFmpeg-devel] [PATCH 07/11] lavu/dict: add av_dict_serialize

Lukasz Marek lukasz.m.luki2 at gmail.com
Tue Nov 18 01:28:42 CET 2014


On 17.11.2014 14:01, Michael Niedermayer wrote:
> On Mon, Nov 17, 2014 at 02:46:54AM +0100, Lukasz Marek wrote:
>> TODO: bump minor, update doc/APIchanges
>>
>> Signed-off-by: Lukasz Marek <lukasz.m.luki2 at gmail.com>
>> ---
>>   libavutil/dict.c | 27 +++++++++++++++++++++++++++
>>   libavutil/dict.h | 16 ++++++++++++++++
>>   2 files changed, 43 insertions(+)
>>
>> diff --git a/libavutil/dict.c b/libavutil/dict.c
>> index 475e906..a41d61e 100644
>> --- a/libavutil/dict.c
>> +++ b/libavutil/dict.c
>> @@ -24,6 +24,7 @@
>>   #include "dict.h"
>>   #include "internal.h"
>>   #include "mem.h"
>> +#include "bprint.h"
>>
>>   struct AVDictionary {
>>       int count;
>
>> @@ -207,3 +208,29 @@ void av_dict_copy(AVDictionary **dst, FF_CONST_AVUTIL53 AVDictionary *src, int f
>>       while ((t = av_dict_get(src, "", t, AV_DICT_IGNORE_SUFFIX)))
>>           av_dict_set(dst, t->key, t->value, flags);
>>   }
>> +
>> +int av_dict_serialize(const AVDictionary *m, char **buffer,
>> +                      const char pairs_sep, const char key_val_sep)
>> +{
>> +    AVDictionaryEntry *t = NULL;
>> +    AVBPrint bprint;
>> +    int cnt = 0;
>> +
>> +    if (!m || !buffer)
>> +        return AVERROR(EINVAL);
>
> It should be also possible to serialize an empty dictionary
>
> the serialization string should also contain a serialization format
> identifer/version otherwise future maintaince could become hard
> this identifer should specify the used separator chars

Escaping OK, added. But what is the point of this? It will just require 
additional function to remove these and pass it to av_dict_parse_string.
Of course user will not have to remember separators.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-lavu-dict-add-av_dict_serialize.patch
Type: text/x-patch
Size: 4797 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20141118/bd02d24d/attachment.bin>


More information about the ffmpeg-devel mailing list