summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGuenter Bartsch <guenter@users.sourceforge.net>2001-06-03 20:16:33 +0000
committerGuenter Bartsch <guenter@users.sourceforge.net>2001-06-03 20:16:33 +0000
commitc650633545f27f73ee43b2d9930504191788321f (patch)
tree8b0cf64733bd0d09f1aea1b2cbc5877bc0963cba /src
parent2a517f1e7f8f969e831a00484de007a495340acf (diff)
downloadxine-lib-c650633545f27f73ee43b2d9930504191788321f.tar.gz
xine-lib-c650633545f27f73ee43b2d9930504191788321f.tar.bz2
fixed mpeg block demuxer content detection and audio channel selection
CVS patchset: 120 CVS date: 2001/06/03 20:16:33
Diffstat (limited to 'src')
-rw-r--r--src/demuxers/demux_mpeg_block.c36
-rw-r--r--src/xine-engine/audio_decoder.c129
2 files changed, 81 insertions, 84 deletions
diff --git a/src/demuxers/demux_mpeg_block.c b/src/demuxers/demux_mpeg_block.c
index eddded0bb..ce1215038 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.11 2001/05/31 22:54:39 guenter Exp $
+ * $Id: demux_mpeg_block.c,v 1.12 2001/06/03 20:16:33 guenter Exp $
*
* demultiplexer for mpeg 1/2 program streams
*
@@ -244,6 +244,8 @@ static void demux_mpeg_block_parse_pack (demux_mpeg_block_t *this) {
if(this->audio_fifo)
this->audio_fifo->put (this->audio_fifo, buf);
+ else
+ buf->free_buffer(buf);
return ;
} else if ((p[0]&0xf0) == 0xa0) {
@@ -268,6 +270,8 @@ static void demux_mpeg_block_parse_pack (demux_mpeg_block_t *this) {
if(this->audio_fifo)
this->audio_fifo->put (this->audio_fifo, buf);
+ else
+ buf->free_buffer(buf);
return ;
}
@@ -303,6 +307,8 @@ static void demux_mpeg_block_parse_pack (demux_mpeg_block_t *this) {
if(this->audio_fifo)
this->audio_fifo->put (this->audio_fifo, buf);
+ else
+ buf->free_buffer(buf);
return ;
@@ -423,31 +429,21 @@ static int demux_mpeg_block_open(demux_plugin_t *this_gen,
this->blocksize = input->get_blocksize(input);
if (!this->blocksize)
- return DEMUX_CANNOT_HANDLE;
+ this->blocksize = 2048;
+
+ /* make sure it's mpeg-2 */
if (input->read(input, buf, this->blocksize)) {
- if(buf[0] || buf[1] || (buf[2] != 0x01))
+ if(buf[0] || buf[1] || (buf[2] != 0x01) || (buf[3] != 0xba))
return DEMUX_CANNOT_HANDLE;
-
- switch(buf[3]) {
- case 0xba:
- if((buf[4] & 0xc0) == 0x40) {
- this->input = input;
- return DEMUX_CAN_HANDLE;
- }
- break;
+ if ((buf[4]>>4) != 4)
+ return DEMUX_CANNOT_HANDLE;
- case 0xe0:
- if((buf[6] & 0xc0) == 0x80) {
- this->input = input;
- return DEMUX_CAN_HANDLE;
- }
- break;
-
- }
- }
+ this->input = input;
+ return DEMUX_CAN_HANDLE;
+ }
}
return DEMUX_CANNOT_HANDLE;
}
diff --git a/src/xine-engine/audio_decoder.c b/src/xine-engine/audio_decoder.c
index 3aceebeec..6ce7b8bf9 100644
--- a/src/xine-engine/audio_decoder.c
+++ b/src/xine-engine/audio_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: audio_decoder.c,v 1.12 2001/06/03 18:08:56 guenter Exp $
+ * $Id: audio_decoder.c,v 1.13 2001/06/03 20:16:33 guenter Exp $
*
*
* functions that implement audio decoding
@@ -64,69 +64,6 @@ void *audio_decoder_loop (void *this_gen) {
break;
- case BUF_AUDIO_AC3:
- case BUF_AUDIO_MPEG:
- case BUF_AUDIO_LPCM:
- case BUF_AUDIO_AVI:
-
- /* printf ("audio_decoder: got an audio buffer, type %08x\n", buf->type); */
-
- /* update track map */
-
- i = 0;
- while ( (i<this->audio_track_map_entries) && (this->audio_track_map[i]<buf->type) )
- i++;
-
- if ( (i==this->audio_track_map_entries) || (this->audio_track_map[i] != buf->type) ) {
-
- /* printf ("audio_decoder: inserting audio type %08x into track map\n", buf->type); */
-
- j = this->audio_track_map_entries;
- while (j>i) {
- this->audio_track_map[j] = this->audio_track_map[j-1];
- j--;
- }
- this->audio_track_map[i] = buf->type;
- this->audio_track_map_entries++;
-
- if (i<=this->audio_channel) {
- /* printf ("audio_decoder: resetting audio decoder because of new channel\n"); */
-
- if (this->cur_audio_decoder_plugin) {
- this->cur_audio_decoder_plugin->close (this->cur_audio_decoder_plugin);
- this->cur_audio_decoder_plugin = NULL;
- }
- }
- }
-
- /* now, decode this buffer if it's the right track */
-
- if (buf->type == this->audio_track_map[this->audio_channel]) {
-
- int streamtype = (buf->type>>16) & 0xFF;
-
- /* printf ("audio_decoder_c: buffer is from the right track => decode it\n"); */
-
-
- decoder = this->audio_decoder_plugins [streamtype];
-
- if (decoder) {
- if (this->cur_audio_decoder_plugin != decoder) {
-
- if (this->cur_audio_decoder_plugin)
- this->cur_audio_decoder_plugin->close (this->cur_audio_decoder_plugin);
-
- this->cur_audio_decoder_plugin = decoder;
- this->cur_audio_decoder_plugin->init (this->cur_audio_decoder_plugin, this->audio_out);
-
- }
-
- decoder->decode_data (decoder, buf);
- }
- }
-
- break;
-
case BUF_CONTROL_END:
if (this->cur_audio_decoder_plugin) {
this->cur_audio_decoder_plugin->close (this->cur_audio_decoder_plugin);
@@ -153,6 +90,70 @@ void *audio_decoder_loop (void *this_gen) {
running = 0;
break;
+ default:
+ if ( (buf->type & 0xFF000000) == BUF_AUDIO_BASE ) {
+
+ /* printf ("audio_decoder: got an audio buffer, type %08x\n", buf->type); */
+
+ /* update track map */
+
+ i = 0;
+ while ( (i<this->audio_track_map_entries) && (this->audio_track_map[i]<buf->type) )
+ i++;
+
+ /*
+ printf ("audio_decoder: got an audio buffer, type %08x, %d map entries, i=%d\n",
+ buf->type, this->audio_track_map_entries, i);
+ */
+
+ if ( (i==this->audio_track_map_entries) || (this->audio_track_map[i] != buf->type) ) {
+
+ j = this->audio_track_map_entries;
+ while (j>i) {
+ this->audio_track_map[j] = this->audio_track_map[j-1];
+ j--;
+ }
+ this->audio_track_map[i] = buf->type;
+ this->audio_track_map_entries++;
+
+ if (i<=this->audio_channel) {
+ /* printf ("audio_decoder: resetting audio decoder because of new channel\n"); */
+
+ if (this->cur_audio_decoder_plugin) {
+ this->cur_audio_decoder_plugin->close (this->cur_audio_decoder_plugin);
+ this->cur_audio_decoder_plugin = NULL;
+ }
+ }
+
+ }
+
+ /* now, decode this buffer if it's the right track */
+
+ if (buf->type == this->audio_track_map[this->audio_channel]) {
+
+ int streamtype = (buf->type>>16) & 0xFF;
+
+ /* printf ("audio_decoder_c: buffer is from the right track => decode it\n"); */
+
+
+ decoder = this->audio_decoder_plugins [streamtype];
+
+ if (decoder) {
+ if (this->cur_audio_decoder_plugin != decoder) {
+
+ if (this->cur_audio_decoder_plugin)
+ this->cur_audio_decoder_plugin->close (this->cur_audio_decoder_plugin);
+
+ this->cur_audio_decoder_plugin = decoder;
+ this->cur_audio_decoder_plugin->init (this->cur_audio_decoder_plugin, this->audio_out);
+
+ }
+
+ decoder->decode_data (decoder, buf);
+ }
+ }
+ } else
+ printf ("audio_decoder: unknown buffer type: %08x\n", buf->type);
}
}
else {