1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-27 17:42:17 +00:00

demux_mkv: TTA support

Code from libavformat's demuxer.

Merged by wm4. It looks like the byte stream writer API is private in
newer ffmpeg, so use the macros from <libavutil/intreadwrite.h>
instead.

It's not really known how to correctly set the field that is used by
the decoder to calculate the length of the last frame. The original
patch used:

    put_le32(&b, (demuxer->movi_end - demuxer->movi_start) * sh_a->samplerate);

This doesn't seem to be correct. Write 0 instead. This is also
incorrect, but better than writing an essentially random value.
This commit is contained in:
Kovensky 2010-04-02 10:00:42 -03:00 committed by wm4
parent ed2c54cea9
commit d53d75e080
2 changed files with 15 additions and 1 deletions

View File

@ -50,7 +50,6 @@
#include "mp_msg.h"
static const unsigned char sipr_swaps[38][2] = {
{0,63},{1,22},{2,44},{3,90},{5,81},{7,31},{8,86},{9,58},{10,36},{12,68},
{13,39},{14,73},{15,53},{16,69},{17,57},{19,88},{20,34},{21,71},{24,46},
@ -1301,6 +1300,7 @@ static struct mkv_audio_tag {
{ MKV_A_REALCOOK, 0, mmioFOURCC('c', 'o', 'o', 'k') },
{ MKV_A_REALDNET, 0, mmioFOURCC('d', 'n', 'e', 't') },
{ MKV_A_REALSIPR, 0, mmioFOURCC('s', 'i', 'p', 'r') },
{ MKV_A_TTA1, 0, mmioFOURCC('T', 'T', 'A', '1') },
{ NULL },
};
@ -1532,6 +1532,19 @@ static int demux_mkv_open_audio(demuxer_t *demuxer, mkv_track_t *track,
sh_a->codecdata_len = track->private_size;
memcpy(sh_a->codecdata, track->private_data, track->private_size);
}
} else if (track->a_formattag == mmioFOURCC('T', 'T', 'A', '1')) {
sh_a->codecdata_len = 30;
sh_a->codecdata = calloc(1, sh_a->codecdata_len);
if (!sh_a->codecdata)
goto error;
char *data = sh_a->codecdata;
memcpy(data + 0, "TTA1", 4);
AV_WL16(data + 4, 1);
AV_WL16(data + 6, sh_a->channels);
AV_WL16(data + 8, sh_a->wf->wBitsPerSample);
AV_WL32(data + 10, sh_a->samplerate);
// Bogus: last frame won't be played.
AV_WL32(data + 14, 0);
} else if (!track->ms_compat) {
goto error;
}

View File

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