demux_mkv: support ALAC

Test sample was produced with ffmpeg. Extradata handling closely follows
libavformat/matroskadec.c.
This commit is contained in:
wm4 2013-03-15 07:49:47 +01:00
parent df4b31c869
commit e837d8ddac
3 changed files with 13 additions and 0 deletions

View File

@ -104,6 +104,7 @@ static const struct mp_codec_tag mp_audio_codec_tags[] = {
{0xfffe , "pcm"}, {0xfffe , "pcm"},
// ------- internal mplayer FourCCs ------ // ------- internal mplayer FourCCs ------
{MKTAG('O', 'p', 'u', 's'), "opus"}, // demux_mkv.c {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('S', 'a', 'd', 'x'), "adpcm_adx"},
{MKTAG('A', 'M', 'V', 'A'), "adpcm_ima_amv"}, {MKTAG('A', 'M', 'V', 'A'), "adpcm_ima_amv"},
{MKTAG('R', 'o', 'Q', 'A'), "roq_dpcm"}, {MKTAG('R', 'o', 'Q', 'A'), "roq_dpcm"},

View File

@ -1321,6 +1321,7 @@ static struct mkv_audio_tag {
{ MKV_A_WAVPACK, 0, mmioFOURCC('W', 'V', 'P', 'K') }, { MKV_A_WAVPACK, 0, mmioFOURCC('W', 'V', 'P', 'K') },
{ MKV_A_TRUEHD, 0, mmioFOURCC('T', 'R', 'H', 'D') }, { MKV_A_TRUEHD, 0, mmioFOURCC('T', 'R', 'H', 'D') },
{ MKV_A_FLAC, 0, mmioFOURCC('f', 'L', 'a', 'C') }, { 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_REAL28, 0, mmioFOURCC('2', '8', '_', '8') },
{ MKV_A_REALATRC, 0, mmioFOURCC('a', 't', 'r', 'c') }, { MKV_A_REALATRC, 0, mmioFOURCC('a', 't', 'r', 'c') },
{ MKV_A_REALCOOK, 0, mmioFOURCC('c', 'o', 'o', 'k') }, { 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; sh_a->codecdata_len = size;
memcpy(sh_a->codecdata, ptr, 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') || } else if (track->a_formattag == mmioFOURCC('W', 'V', 'P', 'K') ||
track->a_formattag == mmioFOURCC('T', 'R', 'H', 'D')) { track->a_formattag == mmioFOURCC('T', 'R', 'H', 'D')) {
copy_private_data: copy_private_data:

View File

@ -52,6 +52,7 @@
#define MKV_A_QDMC "A_QUICKTIME/QDMC" #define MKV_A_QDMC "A_QUICKTIME/QDMC"
#define MKV_A_QDMC2 "A_QUICKTIME/QDM2" #define MKV_A_QDMC2 "A_QUICKTIME/QDM2"
#define MKV_A_FLAC "A_FLAC" #define MKV_A_FLAC "A_FLAC"
#define MKV_A_ALAC "A_ALAC"
#define MKV_A_TTA1 "A_TTA1" #define MKV_A_TTA1 "A_TTA1"
#define MKV_A_WAVPACK "A_WAVPACK4" #define MKV_A_WAVPACK "A_WAVPACK4"
#define MKV_A_TRUEHD "A_TRUEHD" #define MKV_A_TRUEHD "A_TRUEHD"