[FFmpeg-devel] [PATCH v3] avcodec/libvpxenc: fix potential memory leak.
Nicolas George
george at nsup.org
Wed Feb 17 19:48:45 EET 2021
Wonkap Jang (12021-02-17):
> Or are you saying after getting the string with en->value, I should just
> parse through the string without dictionary?
Yes, exactly.
You would use a dictionary if you need to keep all the values for a
later use. But in this case, there is no later use, you only iterate on
the values once, and immediately.
> My purpose here is not to envoke av_dict_set for each parameter, but rather
> get all parameters in one call (using "ref-frame-config"), and parse
> through each parameter internally. And, in order to do that, I had to parse
> the whole string into a key-value pairs, and then recurse through them.
Yes, that is the "simple" way to do it, when you use a high-level
language and do not worry about optimizations: use a high-level
function, store into a high-level data structure, then use a high-level
construct to exploit that data structure.
But FFmpeg is low-level and cares about optimization.
So you use a low-level parsing function, and do the strict necessary to
achieve the result.
The code should look like:
loop
parse one pair
check for error and return
stop if it's the end
do with the pair
free the pair
end loop
I suggest you look at the code for av_dict_parse_string() if this does
not seem easy to you (it should!) or if you are not familiar with the
other helper function available. Your code will be similar, but instead
of av_dict_set(), you do the libvpx stuff.
Regards,
--
Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20210217/1556b12a/attachment.sig>
More information about the ffmpeg-devel
mailing list