diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-07-02 21:19:41 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-07-02 21:19:41 +0200 |
commit | b286383bd2b13fdf59aecdb23d8514323460483b (patch) | |
tree | 4f8ee9745d719e2918843d0d8ebcf053ac220ef4 /libavformat/apetag.c | |
parent | 7c84e7d33762a4bccc0002476a3b20e0b8f26fcc (diff) | |
parent | 5e745cefc0f89cf698c4cf0104182472fe0f603e (diff) |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
asfdec: read attached pictures.
apetag: reindent
apetag: export attached covers as video streams.
apetag: fix the amount of data read from binary tags.
apetag: make sure avio_get_str() doesn't read more than it should.
mov: read itunes cover art.
snow: remove VLA in mc_block()
intfloat: Don't use designated initializers in the public headers
snow: remove a VLA.
doc: Remind devs to check return values, especially for malloc() et al
MS ATC Screen (aka MSS3) decoder
vf_yadif: move x86 init code to x86/yadif.c
vf_gradfun: move x86 init code to x86/gradfun.c
roqvideo: Remove a totally unused dspcontext
smacker: remove some unused code
dsicin: remove dead assignment
aacdec: remove dead assignment
rl2: remove dead assignment
proresenc: make a variable local to the loop where it is used
alsdec: remove dead assignments
Conflicts:
Changelog
doc/developer.texi
libavcodec/allcodecs.c
libavcodec/avcodec.h
libavcodec/version.h
libavfilter/gradfun.h
libavfilter/x86/gradfun.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/apetag.c')
-rw-r--r-- | libavformat/apetag.c | 46 |
1 files changed, 37 insertions, 9 deletions
diff --git a/libavformat/apetag.c b/libavformat/apetag.c index 4d0b8acf08..4d25a8e969 100644 --- a/libavformat/apetag.c +++ b/libavformat/apetag.c @@ -24,6 +24,7 @@ #include "libavutil/dict.h" #include "avformat.h" #include "apetag.h" +#include "internal.h" #define APE_TAG_VERSION 2000 #define APE_TAG_FOOTER_BYTES 32 @@ -56,20 +57,47 @@ static int ape_tag_read_field(AVFormatContext *s) return -1; if (flags & APE_TAG_FLAG_IS_BINARY) { uint8_t filename[1024]; + enum CodecID id; AVStream *st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); - avio_get_str(pb, INT_MAX, filename, sizeof(filename)); - st->codec->extradata = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); - if (!st->codec->extradata) - return AVERROR(ENOMEM); - if (avio_read(pb, st->codec->extradata, size) != size) { - av_freep(&st->codec->extradata); - return AVERROR(EIO); + + size -= avio_get_str(pb, size, filename, sizeof(filename)); + if (size <= 0) { + av_log(s, AV_LOG_WARNING, "Skipping binary tag '%s'.\n", key); + return 0; } - st->codec->extradata_size = size; + av_dict_set(&st->metadata, key, filename, 0); - st->codec->codec_type = AVMEDIA_TYPE_ATTACHMENT; + + if ((id = ff_guess_image2_codec(filename)) != CODEC_ID_NONE) { + AVPacket pkt; + int ret; + + ret = av_get_packet(s->pb, &pkt, size); + if (ret < 0) { + av_log(s, AV_LOG_ERROR, "Error reading cover art.\n"); + return ret; + } + + st->disposition |= AV_DISPOSITION_ATTACHED_PIC; + st->codec->codec_type = AVMEDIA_TYPE_VIDEO; + st->codec->codec_id = id; + + st->attached_pic = pkt; + st->attached_pic.stream_index = st->index; + st->attached_pic.flags |= AV_PKT_FLAG_KEY; + } else { + st->codec->extradata = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); + if (!st->codec->extradata) + return AVERROR(ENOMEM); + if (avio_read(pb, st->codec->extradata, size) != size) { + av_freep(&st->codec->extradata); + return AVERROR(EIO); + } + st->codec->extradata_size = size; + st->codec->codec_type = AVMEDIA_TYPE_ATTACHMENT; + } } else { value = av_malloc(size+1); if (!value) |