diff options
author | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2007-03-02 20:07:33 +0000 |
---|---|---|
committer | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2007-03-02 20:07:33 +0000 |
commit | 18771879b638629eab26644c85e6a962b3faf5b3 (patch) | |
tree | 2c6f21e3247d373efce6d6cc9d95de3a10b2ab3d | |
parent | cee06643c91eb698d2ea619ee4cf2c63b3fc841c (diff) | |
download | xine-lib-18771879b638629eab26644c85e6a962b3faf5b3.tar.gz xine-lib-18771879b638629eab26644c85e6a962b3faf5b3.tar.bz2 |
Fixed content type detection for AAC (seekable) streams with ID3v2 tags prefixed clobbering the preview buffer, by skipping over the tag.
CVS patchset: 8632
CVS date: 2007/03/02 20:07:33
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | src/demuxers/demux_aac.c | 61 |
2 files changed, 48 insertions, 19 deletions
@@ -7,6 +7,8 @@ xine-lib (1.1.5) Vincent Torri, Jamey Sharp and Christophe Thommeret. * Fix race condition in alsa audio out driver. * Fixed a crash in the eq2 plugin. [Bug 1644312] + * Fixed content type detection for AAC (seekable) streams with ID3v2 + tags prefixed clobbering the preview buffer, by skipping over the tag. xine-lib (1.1.4) * Mark string-type configuration items according to whether they're plain @@ -31,7 +33,7 @@ xine-lib (1.1.4) by Roland Kay. [bug #1602631] * Don't check for libpostproc version and assume that if libavcodec is found correctly, libpostproc is of the same version, too. Reported by Ville - Skyttä. [bug #1617344] + Skyttä. [bug #1617344] * Fix Shorten demuxer: the whole "ajkg" signature has to be found, not only one character of it. [bug #1601134] * Implement at least a partial content-based detection of ModPlug-decoded @@ -1276,7 +1278,7 @@ xine (0.5.0) unstable; urgency=low * artsd support * dxr3/h+ support now finally in the official tree * 4/5/5.1 audio channel output (OSS/ ALSA?) - * a new default skin by Jérôme Villette + * a new default skin by Jérôme Villette -- Guenter Bartsch <guenter@users.sourceforge.net> Sun, 22 Jul 2001 13:10:52 +0200 diff --git a/src/demuxers/demux_aac.c b/src/demuxers/demux_aac.c index 3a81404c1..26a273017 100644 --- a/src/demuxers/demux_aac.c +++ b/src/demuxers/demux_aac.c @@ -21,7 +21,7 @@ * This demuxer detects ADIF and ADTS headers in AAC files. * Then it shovels buffer-sized chunks over to the AAC decoder. * - * $Id: demux_aac.c,v 1.13 2007/01/19 00:26:39 dgp85 Exp $ + * $Id: demux_aac.c,v 1.14 2007/03/02 20:07:33 dgp85 Exp $ */ #ifdef HAVE_CONFIG_H @@ -37,9 +37,9 @@ #define LOG_MODULE "demux_aac" #define LOG_VERBOSE -/* + #define LOG -*/ + #include "xine_internal.h" #include "xineutils.h" @@ -57,7 +57,6 @@ typedef struct { input_plugin_t *input; int status; - off_t data_start; off_t data_size; int seek_flag; /* this is set when a seek just occurred */ @@ -72,11 +71,30 @@ static int open_aac_file(demux_aac_t *this) { int i; uint8_t peak[MAX_PREVIEW_SIZE]; uint16_t syncword = 0; + uint32_t id3size = 0; + off_t data_start; /* Check for an ADIF header - should be at the start of the file */ if (_x_demux_read_header(this->input, peak, 4) != 4) return 0; + /* Skip the ID3v2 tag at the start */ + if ( peak[0] == 'I' && peak[1] == 'D' && peak[2] == '3' ) { + + this->input->seek(this->input, 6, SEEK_SET); + if ( this->input->read(this->input, peak, 4) != 4 ) + return 0; + + id3size = (peak[0] << 7*3) + (peak[1] << 7*2) + (peak[2] << 7) + peak[3] + 10; + + lprintf("ID3v2 tag encountered, skipping %u bytes.\n", id3size); + + this->input->seek(this->input, id3size-10, SEEK_CUR); + + if ( this->input->read(this->input, peak, 4) != 4 ) + return 0; + } + if ((peak[0] == 'A') && (peak[1] == 'D') && (peak[2] == 'I') && (peak[3] == 'F')) { lprintf("found ADIF header\n"); @@ -84,13 +102,22 @@ static int open_aac_file(demux_aac_t *this) { } /* Look for an ADTS header - might not be at the start of the file */ - if (_x_demux_read_header(this->input, peak, MAX_PREVIEW_SIZE) != - MAX_PREVIEW_SIZE) + if ( id3size != 0 && this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE ) { + lprintf("Getting a buffer of size %u starting from %u\n", MAX_PREVIEW_SIZE, id3size); + + this->input->seek(this->input, id3size, SEEK_SET); + if ( this->input->read(this->input, peak, MAX_PREVIEW_SIZE) != MAX_PREVIEW_SIZE ) + return 0; + this->input->seek(this->input, 0, SEEK_SET); + } else if (_x_demux_read_header(this->input, peak, MAX_PREVIEW_SIZE) != + MAX_PREVIEW_SIZE) return 0; + data_start = 0; + for (i=0; i<MAX_PREVIEW_SIZE; i++) { if ((syncword & 0xfff6) == 0xfff0) { - this->data_start = i - 2; + data_start = i - 2; lprintf("found ADTS header at offset %d\n", i-2); break; } @@ -99,27 +126,27 @@ static int open_aac_file(demux_aac_t *this) { } /* Look for second ADTS header to confirm it's really aac */ - if (this->data_start + 5 < MAX_PREVIEW_SIZE) { - int frame_size = ((peak[this->data_start+3] & 0x03) << 11) | - (peak[this->data_start+4] << 3) | - ((peak[this->data_start+5] & 0xe0) >> 5); + if (data_start + 5 < MAX_PREVIEW_SIZE) { + int frame_size = ((peak[data_start+3] & 0x03) << 11) | + (peak[data_start+4] << 3) | + ((peak[data_start+5] & 0xe0) >> 5); lprintf("first frame size %d\n", frame_size); if ((frame_size > 0) && - (this->data_start+frame_size < MAX_PREVIEW_SIZE-1) && + (data_start+frame_size < MAX_PREVIEW_SIZE-1) && /* first 28 bits must be identical */ - (peak[this->data_start ] ==peak[this->data_start+frame_size ]) && - (peak[this->data_start+1] ==peak[this->data_start+frame_size+1]) && - (peak[this->data_start+2] ==peak[this->data_start+frame_size+2]) && - (peak[this->data_start+3]>>4==peak[this->data_start+frame_size+3]>>4)) + (peak[data_start ] ==peak[data_start+frame_size ]) && + (peak[data_start+1] ==peak[data_start+frame_size+1]) && + (peak[data_start+2] ==peak[data_start+frame_size+2]) && + (peak[data_start+3]>>4==peak[data_start+frame_size+3]>>4)) { lprintf("found second ADTS header\n"); _x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_VIDEO, 0); _x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_AUDIO, 1); - this->input->seek(this->input, this->data_start, SEEK_SET); + this->input->seek(this->input, data_start+id3size, SEEK_SET); return 1; } } |