diff options
author | Carl Eugen Hoyos <cehoyos@ag.or.at> | 2015-08-27 03:29:29 +0200 |
---|---|---|
committer | Carl Eugen Hoyos <cehoyos@ag.or.at> | 2015-08-27 03:29:29 +0200 |
commit | 33908f08377dd6abb219b4a080f65cb2eec938e6 (patch) | |
tree | 7dde9e9772feaf47d132feb5205ccf9457ba9454 /libavformat/mov.c | |
parent | 7f9656f10df564a3d9b913420c7aca0e24f17f82 (diff) | |
download | ffmpeg-33908f08377dd6abb219b4a080f65cb2eec938e6.tar.gz |
lavf/mov: Support unusual alac files without frma and alac atoms.
Fixes ticket #4747.
Diffstat (limited to 'libavformat/mov.c')
-rw-r--r-- | libavformat/mov.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/libavformat/mov.c b/libavformat/mov.c index efde072c38..45367d39f7 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1436,6 +1436,32 @@ static int mov_read_wave(MOVContext *c, AVIOContext *pb, MOVAtom atom) if (ret < 0) return ret; } else if (atom.size > 8) { /* to read frma, esds atoms */ + if (st->codec->codec_id == AV_CODEC_ID_ALAC && atom.size >= 24) { + uint64_t buffer; + ret = ffio_ensure_seekback(pb, 8); + if (ret < 0) + return ret; + buffer = avio_rb64(pb); + atom.size -= 8; + if ( (buffer & 0xFFFFFFFF) == MKBETAG('f','r','m','a') + && buffer >> 32 <= atom.size + && buffer >> 32 >= 8) { + avio_skip(pb, -8); + atom.size += 8; + } else if (!st->codec->extradata_size) { +#define ALAC_EXTRADATA_SIZE 36 + st->codec->extradata = av_mallocz(ALAC_EXTRADATA_SIZE + AV_INPUT_BUFFER_PADDING_SIZE); + if (!st->codec->extradata) + return AVERROR(ENOMEM); + st->codec->extradata_size = ALAC_EXTRADATA_SIZE; + AV_WB32(st->codec->extradata , ALAC_EXTRADATA_SIZE); + AV_WB32(st->codec->extradata + 4, MKTAG('a','l','a','c')); + AV_WB64(st->codec->extradata + 12, buffer); + avio_read(pb, st->codec->extradata + 20, 16); + avio_skip(pb, atom.size - 24); + return 0; + } + } if ((ret = mov_read_default(c, pb, atom)) < 0) return ret; } else |