1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-17 04:58:06 +00:00

av_common: allow calling mp_codec_to_av_codec_id() with NULL

Helps reducing special cases.
This commit is contained in:
wm4 2013-04-15 21:22:58 +02:00
parent 2adb1aaa5d
commit 5ac50f88c9

View File

@ -75,13 +75,15 @@ void mp_add_lavc_decoders(struct mp_decoder_list *list, enum AVMediaType type)
int mp_codec_to_av_codec_id(const char *codec) int mp_codec_to_av_codec_id(const char *codec)
{ {
int id = AV_CODEC_ID_NONE; int id = AV_CODEC_ID_NONE;
const AVCodecDescriptor *desc = avcodec_descriptor_get_by_name(codec); if (codec) {
if (desc) const AVCodecDescriptor *desc = avcodec_descriptor_get_by_name(codec);
id = desc->id; if (desc)
if (id == AV_CODEC_ID_NONE) { id = desc->id;
AVCodec *avcodec = avcodec_find_decoder_by_name(codec); if (id == AV_CODEC_ID_NONE) {
if (avcodec) AVCodec *avcodec = avcodec_find_decoder_by_name(codec);
id = avcodec->id; if (avcodec)
id = avcodec->id;
}
} }
return id; return id;
} }