X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Foggparsevorbis.c;h=c19b54552c9a5b3688ce601aa74de20fd9cbf6ae;hb=72072bf9de3241848ea86f68d2297b7a5d6ad49b;hp=1804e9a6af8b1dd5f08a69394ce9adb4554a5dd2;hpb=ed9245dba83f9add60f55718b537b0af2105c60e;p=ffmpeg diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c index 1804e9a6af8..c19b54552c9 100644 --- a/libavformat/oggparsevorbis.c +++ b/libavformat/oggparsevorbis.c @@ -25,12 +25,14 @@ #include #include "libavutil/avstring.h" +#include "libavutil/base64.h" #include "libavutil/bswap.h" #include "libavutil/dict.h" #include "libavcodec/bytestream.h" #include "libavcodec/get_bits.h" #include "libavcodec/vorbis_parser.h" #include "avformat.h" +#include "flac_picture.h" #include "internal.h" #include "oggdec.h" #include "vorbiscomment.h" @@ -118,9 +120,7 @@ int ff_vorbis_comment(AVFormatContext *as, AVDictionary **m, if (!tt || !ct) { av_freep(&tt); av_freep(&ct); - av_log(as, AV_LOG_WARNING, - "out-of-memory error. skipping VorbisComment tag.\n"); - continue; + return AVERROR(ENOMEM); } for (j = 0; j < tl; j++) @@ -130,7 +130,31 @@ int ff_vorbis_comment(AVFormatContext *as, AVDictionary **m, memcpy(ct, v, vl); ct[vl] = 0; - if (!ogm_chapter(as, tt, ct)) + /* The format in which the pictures are stored is the FLAC format. + * Xiph says: "The binary FLAC picture structure is base64 encoded + * and placed within a VorbisComment with the tag name + * 'METADATA_BLOCK_PICTURE'. This is the preferred and + * recommended way of embedding cover art within VorbisComments." + */ + if (!strcmp(tt, "METADATA_BLOCK_PICTURE")) { + int ret; + char *pict = av_malloc(vl); + + if (!pict) { + av_freep(&tt); + av_freep(&ct); + return AVERROR(ENOMEM); + } + if ((ret = av_base64_decode(pict, ct, vl)) > 0) + ret = ff_flac_parse_picture(as, pict, ret); + av_freep(&tt); + av_freep(&ct); + av_freep(&pict); + if (ret < 0) { + av_log(as, AV_LOG_WARNING, "Failed to parse cover art block.\n"); + continue; + } + } else if (!ogm_chapter(as, tt, ct)) av_dict_set(m, tt, ct, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);