demux_mkv: support some raw PCM variants

This affects 64 bit floats and big endian integer PCM variants
(basically crap nobody uses). Possibly not all MS-muxed files work, but
I couldn't get or produce any samples.

Remove a bunch of format tags that are not needed anymore. Most of these
were used by demux_mov, which is long gone. Repurpose/abuse 'twos' as
mpv-internal tag for dealing with the PCM variants mentioned above.
This commit is contained in:
wm4 2013-11-11 18:40:59 +01:00
parent 149ab3afa2
commit d8882bbfb7
4 changed files with 15 additions and 26 deletions

View File

@ -68,12 +68,10 @@ const m_option_t ad_lavc_decode_opts_conf[] = {
struct pcm_map struct pcm_map
{ {
int tag; int tag;
const char *codecs[5]; // {any, 1byte, 2bytes, 3bytes, 4bytes} const char *codecs[6]; // {any, 1byte, 2bytes, 3bytes, 4bytes, 8bytes}
}; };
// NOTE: some of these are needed to make rawaudio with demux_mkv and others // NOTE: these are needed to make rawaudio with demux_mkv work.
// work. ffmpeg does similar mapping internally, not part of the public
// API. Some of these might be dead leftovers for demux_mov support.
static const struct pcm_map tag_map[] = { static const struct pcm_map tag_map[] = {
// Microsoft PCM // Microsoft PCM
{0x0, {NULL, "pcm_u8", "pcm_s16le", "pcm_s24le", "pcm_s32le"}}, {0x0, {NULL, "pcm_u8", "pcm_s16le", "pcm_s24le", "pcm_s32le"}},
@ -81,26 +79,12 @@ static const struct pcm_map tag_map[] = {
// MS PCM, Extended // MS PCM, Extended
{0xfffe, {NULL, "pcm_u8", "pcm_s16le", "pcm_s24le", "pcm_s32le"}}, {0xfffe, {NULL, "pcm_u8", "pcm_s16le", "pcm_s24le", "pcm_s32le"}},
// IEEE float // IEEE float
{0x3, {"pcm_f32le"}}, {0x3, {"pcm_f32le", [5] = "pcm_f64le"}},
// 'raw ' // 'raw '
{0x20776172, {"pcm_s16be", [1] = "pcm_u8"}}, {0x20776172, {"pcm_s16be", [1] = "pcm_u8"}},
// 'twos'/'sowt' // 'twos', used by demux_mkv.c internally
{0x736F7774, {"pcm_s16be", [1] = "pcm_s8"}}, {MKTAG('t', 'w', 'o', 's'),
{0x74776F73, {"pcm_s16be", [1] = "pcm_s8"}}, {NULL, "pcm_s8", "pcm_s16be", "pcm_s24be", "pcm_s32be"}},
// 'fl32'/'FL32'
{0x32336c66, {"pcm_f32be"}},
{0x32334C46, {"pcm_f32be"}},
// '23lf'/'lpcm'
{0x666c3332, {"pcm_f32le"}},
{0x6D63706C, {"pcm_f32le"}},
// 'in24', bigendian int24
{0x34326e69, {"pcm_s24be"}},
// '42ni', little endian int24, MPlayer internal fourCC
{0x696e3234, {"pcm_s24le"}},
// 'in32', bigendian int32
{0x32336e69, {"pcm_s32be"}},
// '23ni', little endian int32, MPlayer internal fourCC
{0x696e3332, {"pcm_s32le"}},
{-1}, {-1},
}; };
@ -123,6 +107,8 @@ static const struct pcm_map af_map[] = {
{AF_FORMAT_S32_BE, {"pcm_s32be"}}, {AF_FORMAT_S32_BE, {"pcm_s32be"}},
{AF_FORMAT_FLOAT_LE, {"pcm_f32le"}}, {AF_FORMAT_FLOAT_LE, {"pcm_f32le"}},
{AF_FORMAT_FLOAT_BE, {"pcm_f32be"}}, {AF_FORMAT_FLOAT_BE, {"pcm_f32be"}},
{AF_FORMAT_DOUBLE_LE, {"pcm_f64le"}},
{AF_FORMAT_DOUBLE_BE, {"pcm_f64be"}},
{-1}, {-1},
}; };
@ -130,11 +116,13 @@ static const char *find_pcm_decoder(const struct pcm_map *map, int format,
int bits_per_sample) int bits_per_sample)
{ {
int bytes = (bits_per_sample + 7) / 8; int bytes = (bits_per_sample + 7) / 8;
if (bytes == 8)
bytes = 5; // 64 bit entry
for (int n = 0; map[n].tag != -1; n++) { for (int n = 0; map[n].tag != -1; n++) {
const struct pcm_map *entry = &map[n]; const struct pcm_map *entry = &map[n];
if (entry->tag == format) { if (entry->tag == format) {
const char *dec = NULL; const char *dec = NULL;
if (bytes >= 1 && bytes <= 4) if (bytes >= 1 && bytes <= 5)
dec = entry->codecs[bytes]; dec = entry->codecs[bytes];
if (!dec) if (!dec)
dec = entry->codecs[0]; dec = entry->codecs[0];

View File

@ -132,7 +132,6 @@ static const struct mp_codec_tag mp_audio_codec_tags[] = {
{MKTAG('B', 'P', 'C', 'M'), "pcm_bluray"}, {MKTAG('B', 'P', 'C', 'M'), "pcm_bluray"},
{MKTAG('P', 'L', 'X', 'F'), "pcm_lxf"}, {MKTAG('P', 'L', 'X', 'F'), "pcm_lxf"},
{MKTAG('T', 'W', 'I', '2'), "twinvq"}, {MKTAG('T', 'W', 'I', '2'), "twinvq"},
{0x20776172, "pcm"}, // demux_mpg.c dvdpcm
{0}, {0},
}; };

View File

@ -1355,6 +1355,7 @@ static struct mkv_audio_tag {
{ MKV_A_DTS, 0, 0x2001 }, { MKV_A_DTS, 0, 0x2001 },
{ MKV_A_PCM, 0, 0x0001 }, { MKV_A_PCM, 0, 0x0001 },
{ MKV_A_PCM_BE, 0, 0x0001 }, { MKV_A_PCM_BE, 0, 0x0001 },
{ MKV_A_PCM_FLT, 0, 0x0003 },
{ MKV_A_AAC_2MAIN, 0, MP_FOURCC('M', 'P', '4', 'A') }, { MKV_A_AAC_2MAIN, 0, MP_FOURCC('M', 'P', '4', 'A') },
{ MKV_A_AAC_2LC, 1, MP_FOURCC('M', 'P', '4', 'A') }, { MKV_A_AAC_2LC, 1, MP_FOURCC('M', 'P', '4', 'A') },
{ MKV_A_AAC_2SSR, 0, MP_FOURCC('M', 'P', '4', 'A') }, { MKV_A_AAC_2SSR, 0, MP_FOURCC('M', 'P', '4', 'A') },
@ -1464,10 +1465,10 @@ static int demux_mkv_open_audio(demuxer_t *demuxer, mkv_track_t *track)
free(sh_a->wf); free(sh_a->wf);
sh_a->wf = NULL; sh_a->wf = NULL;
} else if (track->a_formattag == 0x0001) { /* PCM || PCM_BE */ } else if (track->a_formattag == 0x0001) { /* PCM || PCM_BE */
sh_a->wf->nAvgBytesPerSec = sh_a->channels.num * sh_a->samplerate * 2;
sh_a->wf->nBlockAlign = sh_a->wf->nAvgBytesPerSec;
if (!strcmp(track->codec_id, MKV_A_PCM_BE)) if (!strcmp(track->codec_id, MKV_A_PCM_BE))
sh_a->format = MP_FOURCC('t', 'w', 'o', 's'); sh_a->format = MP_FOURCC('t', 'w', 'o', 's');
} else if (track->a_formattag == 0x0003) { /* PCM_FLT */
/* ok */
} else if (!strcmp(track->codec_id, MKV_A_QDMC) } else if (!strcmp(track->codec_id, MKV_A_QDMC)
|| !strcmp(track->codec_id, MKV_A_QDMC2)) { || !strcmp(track->codec_id, MKV_A_QDMC2)) {
sh_a->wf->nAvgBytesPerSec = 16000; sh_a->wf->nAvgBytesPerSec = 16000;

View File

@ -40,6 +40,7 @@
#define MKV_A_MP3 "A_MPEG/L3" #define MKV_A_MP3 "A_MPEG/L3"
#define MKV_A_PCM "A_PCM/INT/LIT" #define MKV_A_PCM "A_PCM/INT/LIT"
#define MKV_A_PCM_BE "A_PCM/INT/BIG" #define MKV_A_PCM_BE "A_PCM/INT/BIG"
#define MKV_A_PCM_FLT "A_PCM/FLOAT/IEEE"
#define MKV_A_VORBIS "A_VORBIS" #define MKV_A_VORBIS "A_VORBIS"
#define MKV_A_OPUS "A_OPUS" #define MKV_A_OPUS "A_OPUS"
#define MKV_A_OPUS_EXP "A_OPUS/EXPERIMENTAL" #define MKV_A_OPUS_EXP "A_OPUS/EXPERIMENTAL"