[FFmpeg-devel] AVDictionary for binary tags

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sat Jan 21 09:55:42 CET 2012


On Sat, Jan 21, 2012 at 10:15:06AM +0200, Dmitry Kostjuchenko wrote:
> Reimar,
> 
> >I find it hard to believe that it would be significant.
> 
> It may be less significant on modern PC CPUs and significant on
> mobile platforms with low-power ARM CPUs with slower CPUs and lower
> memory. Moreover converting image to base64 would waste some RAM:
> besides storage in form of string, the process of converting back to
> binary representation will cause additional memory allocation.
> 
> In case additional function is added as it was proposed in my patch
> memory allocation is done only once. Storing binary is treight
> forward - allocate memory, read from file, store pointer in
> dictionary. So it is fast, and avoid freq. memory allocations. Even
> if platform is fast, why spending CPU for just passing data :)

Because it breaks both API and ABI.
The smallest issues is a type of char * simply isn't appropriate
for binary data since it is unpredictable whether it is signed
or unsigned (admittedly, in the light of UTF-8 it was always a
bad choice).
Applications that are not updated to support it (thus no longer
working with older FFmpeg) cannot use it.
Worse, the way you implemented it a non-updated application encountering
a binary key might just crash.
Then it also complicates the code a lot, and is likely to add a good
deal of new bugs.
For example it seems you decided to use bsize=0 to indicate a string.
However what if someone tries to put some 0-sized binary data?
What if someone tries to add 6GB large binary data? Or exactly 4 GB?
No, this would not work "well" at all with base64-encoded data, but
at least those issues aren't almost certain to cause a crash or similar.


More information about the ffmpeg-devel mailing list