From 9bf7c5d2554e1f6fc8a525b609a90ffce17caec8 Mon Sep 17 00:00:00 2001 From: Kirill Belokurov Date: Fri, 22 Feb 2008 14:26:49 +0200 Subject: added patch for 16bit big endian DTS detection --HG-- extra : transplant_source : %5C%D4ln%1C%B8Up%88%96R%09%1A%05HQ%3C%F8%CE%08 --- src/demuxers/demux_dts.c | 51 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_dts.c b/src/demuxers/demux_dts.c index 7c9b47fcd..2ea119858 100644 --- a/src/demuxers/demux_dts.c +++ b/src/demuxers/demux_dts.c @@ -140,11 +140,29 @@ static int open_dts_file(demux_dts_t *this) { } } + /* DTS bitstream encoding version + * -1 - not detected + * 0 - 16 bits and big endian + * 1 - 16 bits and low endian (detection not implemented) + * 2 - 14 bits and big endian (detection not implemented) + * 3 - 14 bits and low endian + */ + int dts_version = -1; + /* Look for a valid DTS syncword */ for (i=offset; idata_start = i-4; lprintf("found DTS syncword at offset %d\n", i-4); break; @@ -155,14 +173,24 @@ static int open_dts_file(demux_dts_t *this) { if (i < peak_size-9) { unsigned int nblks, fsize, sfreq; + /* 16 bits and big endian bitstream */ + if (dts_version == 0) { + nblks = ((peak[this->data_start+4] & 0x01) << 6) | + ((peak[this->data_start+5] & 0xfc) >> 2); + fsize = (((peak[this->data_start+5] & 0x03) << 12) |(peak[this->data_start+6] << 4) | + ((peak[this->data_start+7] & 0xf0) >> 4)) + 1; + sfreq = (peak[this->data_start+8] & 0x3c) >> 2; + } /* 14 bits and little endian bitstream */ - nblks = ((peak[this->data_start+4] & 0x07) << 4) | - ((peak[this->data_start+7] & 0x3c) >> 2); - fsize = (((peak[this->data_start+7] & 0x03) << 12) | - (peak[this->data_start+6] << 4) | - ((peak[this->data_start+9] & 0x3c) >> 2)) + 1; - sfreq = peak[this->data_start+8] & 0x0f; + if (dts_version == 3) { + nblks = ((peak[this->data_start+4] & 0x07) << 4) | + ((peak[this->data_start+7] & 0x3c) >> 2); + fsize = (((peak[this->data_start+7] & 0x03) << 12) | + (peak[this->data_start+6] << 4) | + ((peak[this->data_start+9] & 0x3c) >> 2)) + 1; + sfreq = peak[this->data_start+8] & 0x0f; + } if ((sfreq > sizeof(dts_sample_rates)/sizeof(int)) || (dts_sample_rates[sfreq] == 0)) @@ -170,7 +198,16 @@ static int open_dts_file(demux_dts_t *this) { /* Big assumption - this is CBR data */ this->samples_per_frame = (nblks + 1) * 32; - this->frame_size = fsize * 8 / 14 * 2; + + /* 16 bits and big endian bitstream */ + if (dts_version == 0) { + this->frame_size = fsize * 8 / 16 * 2; + } + /* 14 bits and little endian bitstream */ + else if (dts_version == 3) { + this->frame_size = fsize * 8 / 14 * 2; + } + this->sample_rate = dts_sample_rates[sfreq]; lprintf("samples per frame: %d\n", this->samples_per_frame); -- cgit v1.2.3