[FFmpeg-cvslog] lavc: reimplement avcodec_get_type() using codec descriptors

wm4 git at videolan.org
Tue Sep 29 13:45:59 CEST 2015


ffmpeg | branch: master | wm4 <nfxjfg at googlemail.com> | Sat Sep 26 18:42:50 2015 +0200| [a5d58fea68b9212e0065a71939e921505504a9bb] | committer: Anton Khirnov

lavc: reimplement avcodec_get_type() using codec descriptors

Signed-off-by: Anton Khirnov <anton at khirnov.net>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a5d58fea68b9212e0065a71939e921505504a9bb
---

 libavcodec/codec_desc.c |    6 ++++++
 libavcodec/utils.c      |   14 --------------
 2 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index c1be40b..31d3555 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -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;
+}
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index a94e4a6..1721c09 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -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;



More information about the ffmpeg-cvslog mailing list