diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/demuxers/demux_dts.c | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/src/demuxers/demux_dts.c b/src/demuxers/demux_dts.c index 2ea119858..c99a0688a 100644 --- a/src/demuxers/demux_dts.c +++ b/src/demuxers/demux_dts.c @@ -154,42 +154,48 @@ static int open_dts_file(demux_dts_t *this) { /* 16 bits and big endian bitstream */ if (syncword == 0x7ffe8001) { dts_version = 0; + break; } - /* 14 bits and little endian bitstream */ - if ((syncword == 0xff1f00e8) && - ((peak[i] & 0xf0) == 0xf0) && (peak[i+1] == 0x07)) { + else if ((syncword == 0xff1f00e8) && + ((peak[i] & 0xf0) == 0xf0) && (peak[i+1] == 0x07)) { dts_version = 3; - } - - if ( dts_version != -1 ) { - this->data_start = i-4; - lprintf("found DTS syncword at offset %d\n", i-4); - break; + break; } syncword = (syncword << 8) | peak[i]; } + if (dts_version == -1) { + xprintf (this->stream->xine, XINE_VERBOSITY_LOG, + LOG_MODULE ": unsupported DTS stream type, or not a DTS stream\n"); + return 0; + } + + this->data_start = i-4; + lprintf("found DTS syncword at offset %d\n", i-4); + if (i < peak_size-9) { unsigned int nblks, fsize, sfreq; - /* 16 bits and big endian bitstream */ - if (dts_version == 0) { + switch (dts_version) + { + case 0: /* BE16 */ 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; - } + break; - /* 14 bits and little endian bitstream */ - if (dts_version == 3) { + case 3: /* LE14 */ 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; + break; + } if ((sfreq > sizeof(dts_sample_rates)/sizeof(int)) || @@ -199,13 +205,16 @@ static int open_dts_file(demux_dts_t *this) { /* Big assumption - this is CBR data */ this->samples_per_frame = (nblks + 1) * 32; - /* 16 bits and big endian bitstream */ - if (dts_version == 0) { + switch (dts_version) + { + case 0: /* BE16 */ + case 1: /* LE16 */ this->frame_size = fsize * 8 / 16 * 2; - } - /* 14 bits and little endian bitstream */ - else if (dts_version == 3) { + break; + case 2: /* BE14 */ + case 3: /* LE14 */ this->frame_size = fsize * 8 / 14 * 2; + break; } this->sample_rate = dts_sample_rates[sfreq]; |