From e837d8ddaca6f72e29c69833bd46a0454d36221f Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 15 Mar 2013 07:49:47 +0100 Subject: [PATCH] demux_mkv: support ALAC Test sample was produced with ffmpeg. Extradata handling closely follows libavformat/matroskadec.c. --- demux/codec_tags.c | 1 + demux/demux_mkv.c | 11 +++++++++++ demux/matroska.h | 1 + 3 files changed, 13 insertions(+) diff --git a/demux/codec_tags.c b/demux/codec_tags.c index 8f535ba487..70b7a9a26e 100644 --- a/demux/codec_tags.c +++ b/demux/codec_tags.c @@ -104,6 +104,7 @@ static const struct mp_codec_tag mp_audio_codec_tags[] = { {0xfffe , "pcm"}, // ------- internal mplayer FourCCs ------ {MKTAG('O', 'p', 'u', 's'), "opus"}, // demux_mkv.c + {MKTAG('a', 'L', 'a', 'C'), "alac"}, // demux_mkv.c {MKTAG('S', 'a', 'd', 'x'), "adpcm_adx"}, {MKTAG('A', 'M', 'V', 'A'), "adpcm_ima_amv"}, {MKTAG('R', 'o', 'Q', 'A'), "roq_dpcm"}, diff --git a/demux/demux_mkv.c b/demux/demux_mkv.c index 012ddba516..3917621384 100644 --- a/demux/demux_mkv.c +++ b/demux/demux_mkv.c @@ -1321,6 +1321,7 @@ static struct mkv_audio_tag { { MKV_A_WAVPACK, 0, mmioFOURCC('W', 'V', 'P', 'K') }, { MKV_A_TRUEHD, 0, mmioFOURCC('T', 'R', 'H', 'D') }, { MKV_A_FLAC, 0, mmioFOURCC('f', 'L', 'a', 'C') }, + { MKV_A_ALAC, 0, mmioFOURCC('a', 'L', 'a', 'C') }, { MKV_A_REAL28, 0, mmioFOURCC('2', '8', '_', '8') }, { MKV_A_REALATRC, 0, mmioFOURCC('a', 't', 'r', 'c') }, { MKV_A_REALCOOK, 0, mmioFOURCC('c', 'o', 'o', 'k') }, @@ -1549,6 +1550,16 @@ static int demux_mkv_open_audio(demuxer_t *demuxer, mkv_track_t *track, sh_a->codecdata_len = size; memcpy(sh_a->codecdata, ptr, size); } + } else if (!strcmp(track->codec_id, MKV_A_ALAC)) { + if (track->private_size && track->private_size < 10000000) { + sh_a->codecdata_len = track->private_size + 12; + sh_a->codecdata = malloc(sh_a->codecdata_len); + char *data = sh_a->codecdata; + AV_WB32(data + 0, sh_a->codecdata_len); + memcpy(data + 4, "alac", 4); + AV_WB32(data + 8, 0); + memcpy(data + 12, track->private_data, track->private_size); + } } else if (track->a_formattag == mmioFOURCC('W', 'V', 'P', 'K') || track->a_formattag == mmioFOURCC('T', 'R', 'H', 'D')) { copy_private_data: diff --git a/demux/matroska.h b/demux/matroska.h index 2d424e2a40..be28f34282 100644 --- a/demux/matroska.h +++ b/demux/matroska.h @@ -52,6 +52,7 @@ #define MKV_A_QDMC "A_QUICKTIME/QDMC" #define MKV_A_QDMC2 "A_QUICKTIME/QDM2" #define MKV_A_FLAC "A_FLAC" +#define MKV_A_ALAC "A_ALAC" #define MKV_A_TTA1 "A_TTA1" #define MKV_A_WAVPACK "A_WAVPACK4" #define MKV_A_TRUEHD "A_TRUEHD"