[FFmpeg-devel] [PATCH 13/15] lavf/asfdec: use avcodec_descriptor_get_by_mime_type
rcombs
rcombs at rcombs.me
Wed Sep 9 09:02:15 EEST 2020
---
libavformat/asfdec_f.c | 11 +++--------
libavformat/asfdec_o.c | 11 +++--------
2 files changed, 6 insertions(+), 16 deletions(-)
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);
--
2.27.0
More information about the ffmpeg-devel
mailing list