From 8071dca3d595a4fc5f9b3ee9f667e2c3e4a35517 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 14 Sep 2012 22:26:14 +0200 Subject: matroska: implement support for ALAC Support Matroska native formatting. On demuxing reconstruct the 36-bytes QuickTime atom that the ALAC decoder expects by prepending the "atom size", "tag" and "tag version" fields missing from the Matroska's CodecPrivate element. On muxing remove the initial 12 bytes 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: Luca Barbato --- libavformat/matroskaenc.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'libavformat/matroskaenc.c') diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 9d9c223dbb..521f6b5c1a 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -475,6 +475,16 @@ static int mkv_write_codecprivate(AVFormatContext *s, AVIOContext *pb, AVCodecCo ret = ff_flac_write_header(dyn_cp, codec, 1); else if (codec->codec_id == AV_CODEC_ID_H264) ret = ff_isom_write_avcc(dyn_cp, codec->extradata, codec->extradata_size); + else if (codec->codec_id == AV_CODEC_ID_ALAC) { + if (codec->extradata_size < 36) { + av_log(s, AV_LOG_ERROR, + "Invalid extradata found, ALAC expects a 36-byte " + "QuickTime atom."); + ret = AVERROR_INVALIDDATA; + } else + avio_write(dyn_cp, codec->extradata + 12, + codec->extradata_size - 12); + } else if (codec->extradata_size) avio_write(dyn_cp, codec->extradata, codec->extradata_size); } else if (codec->codec_type == AVMEDIA_TYPE_VIDEO) { -- cgit v1.2.3