diff mbox series

[FFmpeg-devel,13/15] lavf/asfdec: use avcodec_descriptor_get_by_mime_type

Message ID 20200909060217.25794-13-rcombs@rcombs.me
State New
Headers show
Series [FFmpeg-devel,01/15] lavc/codec_desc: add MIME type to AV_CODEC_ID_TEXT | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

rcombs Sept. 9, 2020, 6:02 a.m. UTC
---
 libavformat/asfdec_f.c | 11 +++--------
 libavformat/asfdec_o.c | 11 +++--------
 2 files changed, 6 insertions(+), 16 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c
index e9ddca7151..c35b81550b 100644
--- a/libavformat/asfdec_f.c
+++ b/libavformat/asfdec_f.c
@@ -218,7 +218,7 @@  static int get_value(AVIOContext *pb, int type, int type2_size)
 static int asf_read_picture(AVFormatContext *s, int len)
 {
     AVPacket pkt          = { 0 };
-    const CodecMime *mime = ff_id3v2_mime_tags;
+    const AVCodecDescriptor *cdesc;
     enum  AVCodecID id    = AV_CODEC_ID_NONE;
     char mimetype[64];
     uint8_t  *desc = NULL;
@@ -245,13 +245,8 @@  static int asf_read_picture(AVFormatContext *s, int len)
 
     /* picture MIME type */
     len -= avio_get_str16le(s->pb, len, mimetype, sizeof(mimetype));
-    while (mime->id != AV_CODEC_ID_NONE) {
-        if (!strncmp(mime->str, mimetype, sizeof(mimetype))) {
-            id = mime->id;
-            break;
-        }
-        mime++;
-    }
+    if ((cdesc = avcodec_descriptor_get_by_mime_type(mimetype, "image")))
+        id = cdesc->id;
     if (id == AV_CODEC_ID_NONE) {
         av_log(s, AV_LOG_ERROR, "Unknown attached picture mimetype: %s.\n",
                mimetype);
diff --git a/libavformat/asfdec_o.c b/libavformat/asfdec_o.c
index 1b10e47907..970748c6cf 100644
--- a/libavformat/asfdec_o.c
+++ b/libavformat/asfdec_o.c
@@ -359,7 +359,7 @@  static int asf_read_picture(AVFormatContext *s, int len)
 {
     ASFContext *asf       = s->priv_data;
     AVPacket pkt          = { 0 };
-    const CodecMime *mime = ff_id3v2_mime_tags;
+    const AVCodecDescriptor *cdesc;
     enum  AVCodecID id    = AV_CODEC_ID_NONE;
     char mimetype[64];
     uint8_t  *desc = NULL;
@@ -387,13 +387,8 @@  static int asf_read_picture(AVFormatContext *s, int len)
 
     /* picture MIME type */
     len -= avio_get_str16le(s->pb, len, mimetype, sizeof(mimetype));
-    while (mime->id != AV_CODEC_ID_NONE) {
-        if (!strncmp(mime->str, mimetype, sizeof(mimetype))) {
-            id = mime->id;
-            break;
-        }
-        mime++;
-    }
+    if ((cdesc = avcodec_descriptor_get_by_mime_type(mimetype, "image")))
+        id = cdesc->id;
     if (id == AV_CODEC_ID_NONE) {
         av_log(s, AV_LOG_ERROR, "Unknown attached picture mimetype: %s.\n",
                mimetype);