summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuergen Keil <jkeil@users.sourceforge.net>2001-08-31 17:57:54 +0000
committerJuergen Keil <jkeil@users.sourceforge.net>2001-08-31 17:57:54 +0000
commitec36f886cce3ca43625dd9e9c8273e5eac30b97c (patch)
treef3fac40f41b203296f95ffe292fa690de4f297c1
parent075e273780d61d1be2cffb586de4a394f97dfd0f (diff)
downloadxine-lib-ec36f886cce3ca43625dd9e9c8273e5eac30b97c.tar.gz
xine-lib-ec36f886cce3ca43625dd9e9c8273e5eac30b97c.tar.bz2
Fix byte order problems for AVI files with LPCM sound.
CVS patchset: 534 CVS date: 2001/08/31 17:57:54
-rw-r--r--src/demuxers/demux_avi.c4
-rw-r--r--src/demuxers/demux_mpeg_block.c4
-rw-r--r--src/demuxers/demux_ts.c4
-rw-r--r--src/liblpcm/xine_decoder.c23
-rw-r--r--src/xine-engine/buffer.h7
5 files changed, 28 insertions, 14 deletions
diff --git a/src/demuxers/demux_avi.c b/src/demuxers/demux_avi.c
index 3780df6d8..4a138c001 100644
--- a/src/demuxers/demux_avi.c
+++ b/src/demuxers/demux_avi.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: demux_avi.c,v 1.28 2001/08/30 12:46:31 jkeil Exp $
+ * $Id: demux_avi.c,v 1.29 2001/08/31 17:57:54 jkeil Exp $
*
* demultiplexer for avi streams
*
@@ -864,7 +864,7 @@ static void demux_avi_start (demux_plugin_t *this_gen,
this->no_audio = 0;
switch (this->avi->a_fmt) {
case 0x01:
- this->avi->audio_type = BUF_AUDIO_LPCM;
+ this->avi->audio_type = BUF_AUDIO_LPCM_LE;
break;
case 0x2000:
this->avi->audio_type = BUF_AUDIO_A52;
diff --git a/src/demuxers/demux_mpeg_block.c b/src/demuxers/demux_mpeg_block.c
index 8a78fbb10..ee6ebdf40 100644
--- a/src/demuxers/demux_mpeg_block.c
+++ b/src/demuxers/demux_mpeg_block.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: demux_mpeg_block.c,v 1.33 2001/08/29 11:14:12 guenter Exp $
+ * $Id: demux_mpeg_block.c,v 1.34 2001/08/31 17:57:54 jkeil Exp $
*
* demultiplexer for mpeg 1/2 program streams
*
@@ -312,7 +312,7 @@ static void demux_mpeg_block_parse_pack (demux_mpeg_block_t *this, int preview_m
buf->content = p+pcm_offset;
buf->size = nPacketLen-pcm_offset;
- buf->type = BUF_AUDIO_LPCM + nTrack;
+ buf->type = BUF_AUDIO_LPCM_BE + nTrack;
buf->PTS = nPTS;
buf->DTS = nDTS ;
buf->input_pos = this->input->get_current_pos(this->input);
diff --git a/src/demuxers/demux_ts.c b/src/demuxers/demux_ts.c
index 3a89196ba..335ca5502 100644
--- a/src/demuxers/demux_ts.c
+++ b/src/demuxers/demux_ts.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: demux_ts.c,v 1.9 2001/08/28 22:44:09 jcdutton Exp $
+ * $Id: demux_ts.c,v 1.10 2001/08/31 17:57:54 jkeil Exp $
*
* Demultiplexer for MPEG2 Transport Streams.
*
@@ -977,7 +977,7 @@ static void demux_ts_queue_pes(
buf->content = p+pcm_offset;
buf->size = nPacketLen-pcm_offset;
- buf->type = BUF_AUDIO_LPCM;
+ buf->type = BUF_AUDIO_LPCM_BE;
buf->PTS = nPTS;
buf->DTS = nDTS ;
buf->input_pos = this->input->seek(this->input, 0, SEEK_CUR);
diff --git a/src/liblpcm/xine_decoder.c b/src/liblpcm/xine_decoder.c
index f2063ed6a..cd3e33b45 100644
--- a/src/liblpcm/xine_decoder.c
+++ b/src/liblpcm/xine_decoder.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: xine_decoder.c,v 1.4 2001/08/31 01:07:55 jcdutton Exp $
+ * $Id: xine_decoder.c,v 1.5 2001/08/31 17:57:54 jkeil Exp $
*
* 31-8-2001 Added LPCM rate sensing.
* (c) 2001 James Courtier-Dutton James@superbug.demon.co.uk
@@ -48,11 +48,14 @@ typedef struct lpcm_decoder_s {
ao_instance_t *audio_out;
int output_open;
-
+ int cpu_be; /* TRUE, if we're a Big endian CPU */
} lpcm_decoder_t;
int lpcm_can_handle (audio_decoder_t *this_gen, int buf_type) {
- return ((buf_type & 0xFFFF0000) == BUF_AUDIO_LPCM) ;
+ buf_type &= 0xFFFF0000;
+
+ return ( buf_type == BUF_AUDIO_LPCM_BE ||
+ buf_type == BUF_AUDIO_LPCM_LE );
}
@@ -66,6 +69,8 @@ void lpcm_init (audio_decoder_t *this_gen, ao_instance_t *audio_out) {
this->last_pts = 0;
this->last_size = 0;
this->rate = 0;
+
+ this->cpu_be = ( htons(1) == 1 );
}
@@ -73,8 +78,10 @@ void lpcm_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
lpcm_decoder_t *this = (lpcm_decoder_t *) this_gen;
int16_t *sample_buffer=(int16_t *)buf->content;
- this->last_pts=this->pts;
- this->pts = buf->PTS;
+ int stream_be;
+
+ this->last_pts=this->pts;
+ this->pts = buf->PTS;
if (buf->decoder_info[0] == 0)
return;
if ((this->last_pts > 0) && (this->pts > 0) && (this->rate == 0)) {
@@ -90,6 +97,12 @@ void lpcm_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
}
if (!this->output_open)
return;
+
+ /* Swap LPCM samples into native byte order, if necessary */
+ stream_be = ( buf->type == BUF_AUDIO_LPCM_BE );
+ if (stream_be != this->cpu_be)
+ swab(sample_buffer, sample_buffer, buf->size);
+
this->audio_out->write (this->audio_out,
sample_buffer,
buf->size/4,
diff --git a/src/xine-engine/buffer.h b/src/xine-engine/buffer.h
index c7396b49f..de98971f5 100644
--- a/src/xine-engine/buffer.h
+++ b/src/xine-engine/buffer.h
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: buffer.h,v 1.6 2001/08/28 19:16:20 guenter Exp $
+ * $Id: buffer.h,v 1.7 2001/08/31 17:57:54 jkeil Exp $
*
*
* contents:
@@ -88,8 +88,9 @@ extern "C" {
#define BUF_AUDIO_BASE 0x03000000
#define BUF_AUDIO_A52 0x03000000
#define BUF_AUDIO_MPEG 0x03010000
-#define BUF_AUDIO_LPCM 0x03020000
-#define BUF_AUDIO_AVI 0x03030000
+#define BUF_AUDIO_LPCM_BE 0x03020000
+#define BUF_AUDIO_LPCM_LE 0x03030000
+#define BUF_AUDIO_AVI 0x03040000
/* spu buffer types: */