[FFmpeg-devel] [PATCH] lavu: make av_get_media_type_string() never return NULL
Andreas Rheinhardt
andreas.rheinhardt at outlook.com
Wed Feb 2 04:13:12 EET 2022
Scott Theisen:
> On 2/1/22 17:34, James Almer wrote:
>> This is an API breakage, so it's not ok.
> I'm new, so would this require a bump to the MINOR or MICRO version number?
>
That would need an announcement in doc/APIchanges; it can then be
changed at the next major version bump after two years have passed.
>> The doxy states it returns NULL if media_type is unknown, so you're
>> expected to check the returned pointer before trying to use it.
>
> git grep -E --count "av_get_media_type_string"
>
> doc/APIchanges:1
> doc/examples/demuxing_decoding.c:5
> doc/examples/extract_mvs.c:2
> fftools/cmdutils.c:1
> fftools/cmdutils.h:1
> fftools/ffmpeg.c:5
> fftools/ffmpeg_opt.c:1
> fftools/ffplay.c:2
> fftools/ffprobe.c:3
> libavcodec/avcodec.c:1
> libavcodec/tests/avcodec.c:1
> libavdevice/dshow.c:2
> libavfilter/avfilter.c:2
> libavfilter/avfiltergraph.c:2
> libavfilter/src_movie.c:3
> libavformat/avienc.c:1
> libavformat/flvenc.c:1
> libavformat/framehash.c:1
> libavformat/mov.c:1
> libavformat/mpegenc.c:1
> libavformat/mpegts.c:1
> libavformat/mxfdec.c:1
> libavformat/segment.c:1
> libavformat/tee.c:1
> libavformat/uncodedframecrcenc.c:1
> libavutil/avutil.h:1
> libavutil/utils.c:1
>
> 44 total - 1 non-code - 1 prototype - 1 definition + 4 via macro - 1
> macro = 44 uses
>
> The following uses of av_get_media_type_string() do not check for null:
> doc/examples/demuxing_decoding.c: 5
> doc/examples/extract_mvs.c: 2
> fftools/cmdutils.c: 2 via the define in cmdutils.h
> fftools/ffmpeg.c: 7, 2 via the define in cmdutils.h
> fftools/ffmpeg_opt.c:1
> fftools/ffplay.c:2
> libavfilter/avfiltergraph.c:2
> libavfilter/src_movie.c:3
> libavformat/flvenc.c:1
> libavformat/framehash.c:1
> libavformat/mov.c:1
> libavformat/mpegenc.c:1
> libavformat/mpegts.c:1
> libavformat/mxfdec.c:1
> libavformat/segment.c:1
> libavformat/tee.c:1
>
> 32/44 uses do not check for null.
Who sets invalid media types?
(In case of fftools/*: If they don't set it themselves, they (and all
our users) should be able to rely on our libraries to not set invalid
values. The same goes for all demuxers (as they set this value
themselves). Checks are only necessary where the media type comes from
the user; this means muxers (where the check should be done generically)
and possibly avfiltergraph.c (I am pretty sure that the type has already
been checked earlier for filters).)
- Andreas
More information about the ffmpeg-devel
mailing list