summaryrefslogtreecommitdiff
path: root/libavformat/matroskadec.c
diff options
context:
space:
mode:
authorMoritz Bunkus <moritz@bunkus.org>2012-08-05 16:25:48 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-08-05 17:59:12 +0200
commitbc3b4220296e24e2cdd1213208a470853fcb76c3 (patch)
tree8f9252f1fb0648d52f802ddaa1d756b99461c9d3 /libavformat/matroskadec.c
parentd106ffd942e2e1837d8b100161cb1df1aa7b617a (diff)
matroskadec: Implement support for ALAC
This patch implements support reading ALAC from Matroska files. The only non-trivial thing about it is that only the ALAC magic cookie is stored in Matroska's CodecPrivate element but not the "atom size", "tag" and "tag version" fields that FFMPEG's ALAC decoder expects. However, those are trivial to re-create. Sample files are available: http://www.bunkus.org/videotools/mkvtoolnix/samples/alac/alac-in-matroska.mka and the CoreAudio file it was created from with today's mkvmerge: http://www.bunkus.org/videotools/mkvtoolnix/samples/alac/alac-in-matroska-source.caf Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/matroskadec.c')
-rw-r--r--libavformat/matroskadec.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 2c954afa05..0f1808773b 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -1580,6 +1580,18 @@ static int matroska_read_header(AVFormatContext *s)
&& (track->codec_priv.data != NULL)) {
fourcc = AV_RL32(track->codec_priv.data);
codec_id = ff_codec_get_id(ff_codec_movvideo_tags, fourcc);
+ } else if (codec_id == CODEC_ID_ALAC && track->codec_priv.size) {
+ /* Only ALAC's magic cookie is stored in Matroska's track headers.
+ Create the "atom size", "tag", and "tag version" fields the
+ decoder expects manually. */
+ extradata_size = 12 + track->codec_priv.size;
+ extradata = av_mallocz(extradata_size);
+ if (extradata == NULL)
+ return AVERROR(ENOMEM);
+ AV_WB32(extradata, extradata_size);
+ memcpy(&extradata[4], "alac", 4);
+ AV_WB32(&extradata[8], 0);
+ memcpy(&extradata[12], track->codec_priv.data, track->codec_priv.size);
} else if (codec_id == CODEC_ID_PCM_S16BE) {
switch (track->audio.bitdepth) {
case 8: codec_id = CODEC_ID_PCM_U8; break;