From 1877d7933ec44b392291c3c1ddd220e8dc66758d Mon Sep 17 00:00:00 2001 From: Stephen Hutchinson Date: Thu, 14 Feb 2013 07:23:26 -0500 Subject: demux_mkv: Support playing Opus streams in Matroska FFmpeg recently changed how it writes Opus-in-Matroska to match the A_OPUS/EXPERIMENTAL name that mkvmerge uses, with the caveat that things will change and compatibility with old files can get worked out when the spec is finalized. This adds both A_OPUS and A_OPUS/EXPERIMENTAL so that *hopefully* it can play both the newer files that use A_OPUS/EXPERIMENTAL, and older ones muxed by FFmpeg that were simply A_OPUS, since this is also what FFmpeg seems to be doing to handle the situation. --- demux/codec_tags.c | 1 + demux/demux_mkv.c | 5 +++++ demux/matroska.h | 2 ++ 3 files changed, 8 insertions(+) diff --git a/demux/codec_tags.c b/demux/codec_tags.c index d1a6cee65f..8f535ba487 100644 --- a/demux/codec_tags.c +++ b/demux/codec_tags.c @@ -103,6 +103,7 @@ static const struct mp_codec_tag mp_audio_codec_tags[] = { {0x3 , "pcm"}, // lavf: pcm_f32le {0xfffe , "pcm"}, // ------- internal mplayer FourCCs ------ + {MKTAG('O', 'p', 'u', 's'), "opus"}, // 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 a769aac127..012ddba516 100644 --- a/demux/demux_mkv.c +++ b/demux/demux_mkv.c @@ -1314,6 +1314,8 @@ static struct mkv_audio_tag { { MKV_A_AAC_4LTP, 0, mmioFOURCC('M', 'P', '4', 'A') }, { MKV_A_AAC, 0, mmioFOURCC('M', 'P', '4', 'A') }, { MKV_A_VORBIS, 0, mmioFOURCC('v', 'r', 'b', 's') }, + { MKV_A_OPUS, 0, mmioFOURCC('O', 'p', 'u', 's') }, + { MKV_A_OPUS_EXP, 0, mmioFOURCC('O', 'p', 'u', 's') }, { MKV_A_QDMC, 0, mmioFOURCC('Q', 'D', 'M', 'C') }, { MKV_A_QDMC2, 0, mmioFOURCC('Q', 'D', 'M', '2') }, { MKV_A_WAVPACK, 0, mmioFOURCC('W', 'V', 'P', 'K') }, @@ -1462,6 +1464,9 @@ static int demux_mkv_open_audio(demuxer_t *demuxer, mkv_track_t *track, memcpy((unsigned char *) (sh_a->wf + 1), track->private_data, sh_a->wf->cbSize); } + } else if (!strcmp(track->codec_id, MKV_A_OPUS) + || !strcmp(track->codec_id, MKV_A_OPUS_EXP)) { + sh_a->format = mmioFOURCC('O', 'p', 'u', 's'); } else if (!strncmp(track->codec_id, MKV_A_REALATRC, 7)) { if (track->private_size < RAPROPERTIES4_SIZE) goto error; diff --git a/demux/matroska.h b/demux/matroska.h index 41ccfe2b26..2d424e2a40 100644 --- a/demux/matroska.h +++ b/demux/matroska.h @@ -41,6 +41,8 @@ #define MKV_A_PCM "A_PCM/INT/LIT" #define MKV_A_PCM_BE "A_PCM/INT/BIG" #define MKV_A_VORBIS "A_VORBIS" +#define MKV_A_OPUS "A_OPUS" +#define MKV_A_OPUS_EXP "A_OPUS/EXPERIMENTAL" #define MKV_A_ACM "A_MS/ACM" #define MKV_A_REAL28 "A_REAL/28_8" #define MKV_A_REALATRC "A_REAL/ATRC" -- cgit v1.2.3