Skip to content

Commit

Permalink
TTA support on the matroska demuxer
Browse files Browse the repository at this point in the history
Code from libavformat's demuxer.
  • Loading branch information
Kovensky committed Apr 2, 2010
1 parent c4132cc commit 07694a8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions libmpdemux/demux_mkv.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
#include "libavutil/lzo.h"
#include "ffmpeg_files/intreadwrite.h"
#include "libavutil/avstring.h"
#include "libavformat/avformat.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},
Expand Down Expand Up @@ -1353,6 +1354,8 @@ static int demux_mkv_open_audio(demuxer_t *demuxer, mkv_track_t *track,
track->a_formattag = mmioFOURCC('Q', 'D', 'M', 'C');
else if (!strcmp(track->codec_id, MKV_A_QDMC2))
track->a_formattag = mmioFOURCC('Q', 'D', 'M', '2');
else if (!strcmp(track->codec_id, MKV_A_TTA1))
track->a_formattag = mmioFOURCC('T', 'T', 'A', '1');
else if (!strcmp(track->codec_id, MKV_A_WAVPACK))
track->a_formattag = mmioFOURCC('W', 'V', 'P', 'K');
else if (!strcmp(track->codec_id, MKV_A_TRUEHD))
Expand Down Expand Up @@ -1562,6 +1565,22 @@ 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 (track->a_formattag == mmioFOURCC('T', 'T', 'A', '1')) {
sh_a->codecdata_len = 30;
sh_a->codecdata = av_mallocz(sh_a->codecdata_len);
if (! sh_a->codecdata) {
free_sh_audio(demuxer, track->tnum);
return 1;
}
ByteIOContext b;
init_put_byte(&b, sh_a->codecdata, sh_a->codecdata_len, 1,
NULL, NULL, NULL, NULL);
put_buffer(&b, "TTA1", 4);
put_le16(&b, 1);
put_le16(&b, sh_a->channels);
put_le16(&b, sh_a->wf->wBitsPerSample);
put_le32(&b, sh_a->samplerate);
put_le32(&b, (demuxer->movi_end - demuxer->movi_start) * sh_a->samplerate);
} else if (track->a_formattag == mmioFOURCC('W', 'V', 'P', 'K') || track->a_formattag == mmioFOURCC('T', 'R', 'H', 'D')) { /* do nothing, still works */
} else if (!track->ms_compat
|| (track->private_size < sizeof(WAVEFORMATEX))) {
Expand Down
1 change: 1 addition & 0 deletions libmpdemux/matroska.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,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"

Expand Down

0 comments on commit 07694a8

Please sign in to comment.