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/mov.c | |
parent | 7c84e7d33762a4bccc0002476a3b20e0b8f26fcc (diff) | |
parent | 5e745cefc0f89cf698c4cf0104182472fe0f603e (diff) | |
download | ffmpeg-b286383bd2b13fdf59aecdb23d8514323460483b.tar.gz |
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/mov.c')
-rw-r--r-- | libavformat/mov.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/libavformat/mov.c b/libavformat/mov.c index faa8c65246..5010ec8df5 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -168,6 +168,48 @@ static int mov_read_mac_string(MOVContext *c, AVIOContext *pb, int len, return p - dst; } +static int mov_read_covr(MOVContext *c, AVIOContext *pb, int type, int len) +{ + AVPacket pkt; + AVStream *st; + MOVStreamContext *sc; + enum CodecID id; + int ret; + + switch (type) { + case 0xd: id = CODEC_ID_MJPEG; break; + case 0xe: id = CODEC_ID_PNG; break; + case 0x1b: id = CODEC_ID_BMP; break; + default: + av_log(c->fc, AV_LOG_WARNING, "Unknown cover type: 0x%x.\n", type); + avio_skip(pb, len); + return 0; + } + + st = avformat_new_stream(c->fc, NULL); + if (!st) + return AVERROR(ENOMEM); + sc = av_mallocz(sizeof(*sc)); + if (!sc) + return AVERROR(ENOMEM); + st->priv_data = sc; + + ret = av_get_packet(pb, &pkt, len); + if (ret < 0) + return ret; + + st->disposition |= AV_DISPOSITION_ATTACHED_PIC; + + st->attached_pic = pkt; + st->attached_pic.stream_index = st->index; + st->attached_pic.flags |= AV_PKT_FLAG_KEY; + + st->codec->codec_type = AVMEDIA_TYPE_VIDEO; + st->codec->codec_id = id; + + return 0; +} + static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom) { #ifdef MOV_EXPORT_ALL_METADATA @@ -228,6 +270,14 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom) avio_rb32(pb); // unknown str_size = data_size - 16; atom.size -= 16; + + if (atom.type == MKTAG('c', 'o', 'v', 'r')) { + int ret = mov_read_covr(c, pb, data_type, str_size); + if (ret < 0) { + av_log(c->fc, AV_LOG_ERROR, "Error parsing cover art.\n"); + return ret; + } + } } else return 0; } else if (atom.size > 4 && key && !c->itunes_metadata) { str_size = avio_rb16(pb); // string length |