[FFmpeg-devel] [PATCH v2 5/6] libavutil: Add AVMap

Nicolas George george at nsup.org
Tue Apr 15 22:14:42 EEST 2025


Michael Niedermayer (HE12025-04-15):
> Where exactly would that benefit FFmpeg ?
> Dictionaries generally are used to move stuff aorund, like metadata or
> options.
> Or may be used in the future to keep track of some mappings like
> timestamps to file positions during demuxing or muxing
> Or maybe codecs/formats lookup from name
> None of these are confined to a single local function

	AVMap opts = av_map_create(cmp, NULL, NULL);
	av_map_add(opts, "threads", "12");
	av_map_add(opts, "crf", "18");
	av_map_add(opts, "preset", "veryslow");
	av_map_assert_small(opts);
	ret = av_codec_open3(ctx, codec, opts);

> i like av_map_new() because "new" is short

The exact name does not matter to me. I forgot that we usually use
_alloc() for the case you implemented, so _new() is absolutely fine for
this.

av_map_assert_small() should assert that no dynamic allocation happened,
and at assert level 2 that the internal buffer is less than halfway full.

> and sizeof(AVMap) is not public API

It should be public API like I did for BPrint, that is my point.

Regards,

-- 
  Nicolas George


More information about the ffmpeg-devel mailing list