]> git.sesse.net Git - ffmpeg/commitdiff
lavc: reimplement avcodec_get_type() using codec descriptors
authorwm4 <nfxjfg@googlemail.com>
Sat, 26 Sep 2015 16:42:50 +0000 (18:42 +0200)
committerAnton Khirnov <anton@khirnov.net>
Mon, 28 Sep 2015 08:50:38 +0000 (10:50 +0200)
Signed-off-by: Anton Khirnov <anton@khirnov.net>
libavcodec/codec_desc.c
libavcodec/utils.c

index c1be40bd857bc8eff02ae9d1840bc0e6bdf82f7d..31d3555c25621785daa47e119fe9d811cf314d9c 100644 (file)
@@ -2435,3 +2435,9 @@ const AVCodecDescriptor *avcodec_descriptor_get_by_name(const char *name)
             return desc;
     return NULL;
 }
+
+enum AVMediaType avcodec_get_type(enum AVCodecID codec_id)
+{
+    const AVCodecDescriptor *desc = avcodec_descriptor_get(codec_id);
+    return desc ? desc->type : AVMEDIA_TYPE_UNKNOWN;
+}
index a94e4a6058349e8d5a0625617e0a181297df7d4e..1721c09129e8ebbfcbc677d04b3c658f1f4a0516 100644 (file)
@@ -2320,20 +2320,6 @@ void ff_thread_await_progress(ThreadFrame *f, int progress, int field)
 
 #endif
 
-enum AVMediaType avcodec_get_type(enum AVCodecID codec_id)
-{
-    if (codec_id <= AV_CODEC_ID_NONE)
-        return AVMEDIA_TYPE_UNKNOWN;
-    else if (codec_id < AV_CODEC_ID_FIRST_AUDIO)
-        return AVMEDIA_TYPE_VIDEO;
-    else if (codec_id < AV_CODEC_ID_FIRST_SUBTITLE)
-        return AVMEDIA_TYPE_AUDIO;
-    else if (codec_id < AV_CODEC_ID_FIRST_UNKNOWN)
-        return AVMEDIA_TYPE_SUBTITLE;
-
-    return AVMEDIA_TYPE_UNKNOWN;
-}
-
 int avcodec_is_open(AVCodecContext *s)
 {
     return !!s->internal;