diff options
author | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2007-03-19 16:42:32 +0000 |
---|---|---|
committer | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2007-03-19 16:42:32 +0000 |
commit | a926bc137b195d5fa9d2fa52914c9f87eba6568a (patch) | |
tree | 35afce4d869e7f013b6832d4f99991578be59428 | |
parent | 47570caa9246581fc158606fd6701cc4e8f9475c (diff) | |
download | xine-lib-a926bc137b195d5fa9d2fa52914c9f87eba6568a.tar.gz xine-lib-a926bc137b195d5fa9d2fa52914c9f87eba6568a.tar.bz2 |
Cleanup block-based support in AC3 and DTS demuxers. Original patch by Matthias Kretz.
CVS patchset: 8713
CVS date: 2007/03/19 16:42:32
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | src/demuxers/demux_ac3.c | 40 | ||||
-rw-r--r-- | src/demuxers/demux_dts.c | 38 |
3 files changed, 36 insertions, 44 deletions
@@ -39,6 +39,8 @@ xine-lib (1.1.5) (Unreleased) (downplayed to 16-bit). * Added centre-cutout (4:3 in 16:9) to the expand plugin. Patch by Reinhard Nissl. + * Fix support of block devices for AC3 and DTS demuxers. Thanks to Matthias + Kretz for the original patch. xine-lib (1.1.4) * Mark string-type configuration items according to whether they're plain diff --git a/src/demuxers/demux_ac3.c b/src/demuxers/demux_ac3.c index f81fef5d7..7f3dadeb7 100644 --- a/src/demuxers/demux_ac3.c +++ b/src/demuxers/demux_ac3.c @@ -23,7 +23,7 @@ * This demuxer detects raw AC3 data in a file and shovels AC3 data * directly to the AC3 decoder. * - * $Id: demux_ac3.c,v 1.20 2007/01/19 00:26:40 dgp85 Exp $ + * $Id: demux_ac3.c,v 1.21 2007/03/19 16:42:32 dgp85 Exp $ */ #ifdef HAVE_CONFIG_H @@ -51,7 +51,6 @@ #include "group_audio.h" #define DATA_TAG 0x61746164 -#define PEAK_SIZE 7056 /* 3 raw cd frames */ typedef struct { demux_plugin_t demux_plugin; @@ -129,31 +128,29 @@ static const struct frmsize_s frmsizecod_tbl[64] = static int open_ac3_file(demux_ac3_t *this) { int i; int offset = 0; - int peak_size = 0; + size_t peak_size = 0; int spdif_mode = 0; uint32_t syncword = 0; uint32_t blocksize; - uint8_t peak[PEAK_SIZE]; + uint8_t *peak; - lprintf("open_ac3_file\n"); - - /* block based demuxer (i.e. cdda) will only allow reads in block - * sized pieces */ blocksize = this->input->get_blocksize(this->input); - if (blocksize && INPUT_IS_SEEKABLE(this->input)) { - int read; - + if (blocksize) { this->input->seek(this->input, 0, SEEK_SET); - while (peak_size < PEAK_SIZE) { - read = this->input->read(this->input, &peak[peak_size], blocksize); - if (read) - peak_size += read; - else - break; - } + buf_element_t *buf = this->input->read_block(this->input, + this->audio_fifo, + blocksize); this->input->seek(this->input, 0, SEEK_SET); + + if (!buf) + return 0; + + peak = alloca(peak_size = buf->size); + xine_fast_memcpy(peak, buf->content, peak_size); + + buf->free_buffer(buf); } else { - peak_size = MAX_PREVIEW_SIZE; + peak = alloca(peak_size = MAX_PREVIEW_SIZE); if (_x_demux_read_header(this->input, peak, peak_size) != peak_size) return 0; @@ -163,10 +160,7 @@ static int open_ac3_file(demux_ac3_t *this) { /* Check for wav header, as we'll handle AC3 with a wav header shoved * on the front for CD burning */ - if ((peak[0] == 'R') && (peak[1] == 'I') && (peak[2] == 'F') && - (peak[3] == 'F') && (peak[8] == 'W') && (peak[9] == 'A') && - (peak[10] == 'V') && (peak[11] == 'E') && (peak[12] == 'f') && - (peak[13] == 'm') && (peak[14] == 't') && (peak[15] == ' ')) { + if ( memcmp(peak, "RIFF", 4) == 0 || memcmp(&peak[8], "WAVEfmt ", 8) == 0 ) { /* Check this looks like a cd audio wav */ unsigned int audio_type; xine_waveformatex *wave = (xine_waveformatex *) &peak[20]; diff --git a/src/demuxers/demux_dts.c b/src/demuxers/demux_dts.c index 98726a569..7baeae377 100644 --- a/src/demuxers/demux_dts.c +++ b/src/demuxers/demux_dts.c @@ -19,7 +19,7 @@ * * Raw DTS Demuxer by James Stembridge (jstembridge@gmail.com) * - * $Id: demux_dts.c,v 1.7 2007/01/19 00:26:40 dgp85 Exp $ + * $Id: demux_dts.c,v 1.8 2007/03/19 16:42:32 dgp85 Exp $ */ #ifdef HAVE_CONFIG_H @@ -47,7 +47,6 @@ #include "group_audio.h" #define DATA_TAG 0x61746164 -#define PEAK_SIZE 7056 /* 3 raw cd frames */ typedef struct { demux_plugin_t demux_plugin; @@ -79,29 +78,29 @@ static const int dts_sample_rates[] = static int open_dts_file(demux_dts_t *this) { int i, offset = 0; uint32_t syncword = 0; - int peak_size = 0; + size_t peak_size = 0; uint32_t blocksize; - uint8_t peak[PEAK_SIZE]; + uint8_t *peak; lprintf("open_dts_file\n"); - /* block based demuxer (i.e. cdda) will only allow reads in block - * sized pieces */ blocksize = this->input->get_blocksize(this->input); - if (blocksize && INPUT_IS_SEEKABLE(this->input)) { - int read; - + if (blocksize) { this->input->seek(this->input, 0, SEEK_SET); - while (peak_size < PEAK_SIZE) { - read = this->input->read(this->input, &peak[peak_size], blocksize); - if (read) - peak_size += read; - else - break; - } + buf_element_t *buf = this->input->read_block(this->input, + this->audio_fifo, + blocksize); this->input->seek(this->input, 0, SEEK_SET); + + if (!buf) + return 0; + + peak = alloca(peak_size = buf->size); + xine_fast_memcpy(peak, buf->content, peak_size); + + buf->free_buffer(buf); } else { - peak_size = MAX_PREVIEW_SIZE; + peak = alloca(peak_size = MAX_PREVIEW_SIZE); if (_x_demux_read_header(this->input, peak, peak_size) != peak_size) return 0; @@ -111,10 +110,7 @@ static int open_dts_file(demux_dts_t *this) { /* Check for wav header, as we'll handle DTS with a wav header shoved * on the front for CD burning */ - if ((peak[0] == 'R') && (peak[1] == 'I') && (peak[2] == 'F') && - (peak[3] == 'F') && (peak[8] == 'W') && (peak[9] == 'A') && - (peak[10] == 'V') && (peak[11] == 'E') && (peak[12] == 'f') && - (peak[13] == 'm') && (peak[14] == 't') && (peak[15] == ' ')) { + if ( memcmp(peak, "RIFF", 4) == 0 || memcmp(&peak[8], "WAVEfmt ", 8) == 0 ) { /* Check this looks like a cd audio wav */ unsigned int audio_type; xine_waveformatex *wave = (xine_waveformatex *) &peak[20]; |