diff mbox series

[FFmpeg-devel,08/15] lavf/id3v2enc: use codec-desc-provided MIME types

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

Checks

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

Commit Message

Ridley Combs Sept. 9, 2020, 6:02 a.m. UTC
---
 libavformat/id3v2enc.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/id3v2enc.c b/libavformat/id3v2enc.c
index 5d821ea4db..a7f251652f 100644
--- a/libavformat/id3v2enc.c
+++ b/libavformat/id3v2enc.c
@@ -352,23 +352,18 @@  int ff_id3v2_write_apic(AVFormatContext *s, ID3v2EncContext *id3, AVPacket *pkt)
 {
     AVStream *st = s->streams[pkt->stream_index];
     AVDictionaryEntry *e;
+    const AVCodecDescriptor *cdesc = avcodec_descriptor_get(st->codecpar->codec_id);
 
     AVIOContext *dyn_buf;
     uint8_t     *buf;
-    const CodecMime *mime = ff_id3v2_mime_tags;
     const char  *mimetype = NULL, *desc = "";
     int enc = id3->version == 3 ? ID3v2_ENCODING_UTF16BOM :
                                   ID3v2_ENCODING_UTF8;
     int i, len, type = 0, ret;
 
     /* get the mimetype*/
-    while (mime->id != AV_CODEC_ID_NONE) {
-        if (mime->id == st->codecpar->codec_id) {
-            mimetype = mime->str;
-            break;
-        }
-        mime++;
-    }
+    if (cdesc && cdesc->mime_types)
+        mimetype = cdesc->mime_types[0];
     if (!mimetype) {
         av_log(s, AV_LOG_ERROR, "No mimetype is known for stream %d, cannot "
                "write an attached picture.\n", st->index);