[FFmpeg-devel] [PATCH] lavu: make av_get_media_type_string() never return NULL

Scott Theisen scott.the.elm at gmail.com
Wed Feb 2 03:58:06 EET 2022


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?

> 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.


libavcodec/tests/avcodec.c: this use is a workaround to 
av_get_media_type_string() returning null; checked 3 times


Let me know which version number to bump and I will submit a new version 
that also removes the now redundant null checks from the rest of the code.

Thanks,
Scott


More information about the ffmpeg-devel mailing list