summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-04-15 21:22:58 +0200
committerwm4 <wm4@nowhere>2013-04-20 23:28:26 +0200
commit5ac50f88c90167e9ade0c998ac62e935e259acee (patch)
treea0c57694bd44916cc6a52c3279d9b2379d2cb882 /core
parent2adb1aaa5d5e7a8240cab8afba639b768e486fca (diff)
downloadmpv-5ac50f88c90167e9ade0c998ac62e935e259acee.tar.bz2
mpv-5ac50f88c90167e9ade0c998ac62e935e259acee.tar.xz
av_common: allow calling mp_codec_to_av_codec_id() with NULL
Helps reducing special cases.
Diffstat (limited to 'core')
-rw-r--r--core/av_common.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/core/av_common.c b/core/av_common.c
index bf1af853d9..5e6c8a4352 100644
--- a/core/av_common.c
+++ b/core/av_common.c
@@ -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 id = AV_CODEC_ID_NONE;
- const AVCodecDescriptor *desc = avcodec_descriptor_get_by_name(codec);
- if (desc)
- id = desc->id;
- if (id == AV_CODEC_ID_NONE) {
- AVCodec *avcodec = avcodec_find_decoder_by_name(codec);
- if (avcodec)
- id = avcodec->id;
+ if (codec) {
+ const AVCodecDescriptor *desc = avcodec_descriptor_get_by_name(codec);
+ if (desc)
+ id = desc->id;
+ if (id == AV_CODEC_ID_NONE) {
+ AVCodec *avcodec = avcodec_find_decoder_by_name(codec);
+ if (avcodec)
+ id = avcodec->id;
+ }
}
return id;
}