summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/demuxers/demux_mpeg_block.c38
-rw-r--r--src/liblpcm/xine_decoder.c49
-rw-r--r--src/xine-engine/buffer.h20
3 files changed, 67 insertions, 40 deletions
diff --git a/src/demuxers/demux_mpeg_block.c b/src/demuxers/demux_mpeg_block.c
index 1f9144505..9507e287a 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.108 2002/07/17 18:17:48 miguelfreitas Exp $
+ * $Id: demux_mpeg_block.c,v 1.109 2002/07/19 03:03:36 miguelfreitas Exp $
*
* demultiplexer for mpeg 1/2 program streams
*
@@ -91,11 +91,6 @@ typedef struct demux_mpeg_block_s {
int send_newpts;
int buf_flag_seek;
-
- int pcm_bits;
- int pcm_rate;
- int pcm_channels;
-
} demux_mpeg_block_t ;
@@ -255,7 +250,9 @@ static void demux_mpeg_block_parse_pack (demux_mpeg_block_t *this, int preview_m
p = buf->content; /* len = this->mnBlocksize; */
if (preview_mode)
buf->decoder_flags = BUF_FLAG_PREVIEW;
-
+ else
+ buf->decoder_flags = 0;
+
buf->input_pos = this->input->get_current_pos (this->input);
buf->input_length = this->input->get_length (this->input);
@@ -588,26 +585,11 @@ static void demux_mpeg_block_parse_pack (demux_mpeg_block_t *this, int preview_m
}
dynamic_range = p[6];
- /* send header with audio parameters */
- if( !preview_mode &&
- (this->pcm_rate != sample_rate ||
- this->pcm_bits != bits_per_sample ||
- this->pcm_channels != num_channels) ) {
-
- buf_element_t *buf2;
-
- buf2 = this->video_fifo->buffer_pool_alloc (this->video_fifo);
-
- buf2->type = BUF_AUDIO_LPCM_BE + track;
- buf2->decoder_flags = BUF_FLAG_HEADER;
-
- buf2->decoder_info[1] = this->pcm_rate = sample_rate;
- buf2->decoder_info[2] = this->pcm_bits = bits_per_sample;
- buf2->decoder_info[3] = this->pcm_channels = num_channels;
-
- this->video_fifo->put(this->video_fifo, buf2);
- }
-
+ /* send lpcm config byte */
+ buf->decoder_flags |= BUF_FLAG_SPECIAL;
+ buf->decoder_info[1] = BUF_SPECIAL_LPCM_CONFIG;
+ buf->decoder_info[2] = p[5];
+
pcm_offset = 7;
buf->content = p+pcm_offset;
@@ -934,8 +916,6 @@ static int demux_mpeg_block_start (demux_plugin_t *this_gen,
this->video_fifo = video_fifo;
this->audio_fifo = audio_fifo;
- this->pcm_bits = this->pcm_rate = this->pcm_channels = 0;
-
if((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) != 0) {
if (!this->blocksize)
this->blocksize = demux_mpeg_detect_blocksize( this, this->input );
diff --git a/src/liblpcm/xine_decoder.c b/src/liblpcm/xine_decoder.c
index a8328906b..0c287cb6a 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.29 2002/07/17 18:17:49 miguelfreitas Exp $
+ * $Id: xine_decoder.c,v 1.30 2002/07/19 03:03:37 miguelfreitas Exp $
*
* 31-8-2001 Added LPCM rate sensing.
* (c) 2001 James Courtier-Dutton James@superbug.demon.co.uk
@@ -86,30 +86,61 @@ void lpcm_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
int16_t *sample_buffer=(int16_t *)buf->content;
int stream_be;
audio_buffer_t *audio_buffer;
+ int format_changed = 0;
+
/* Drop preview data */
if (buf->decoder_flags & BUF_FLAG_PREVIEW)
return;
+ /* get config byte from mpeg2 stream */
+ if ( (buf->decoder_flags & BUF_FLAG_SPECIAL) &&
+ buf->decoder_info[1] == BUF_SPECIAL_LPCM_CONFIG ) {
+ int bits_per_sample = 16;
+ int sample_rate;
+ int num_channels;
+
+ num_channels = (buf->decoder_info[2] & 0x7) + 1;
+ sample_rate = buf->decoder_info[2] & 0x10 ? 96000 : 48000;
+ switch ((buf->decoder_info[2]>>6) & 3) {
+ case 0: bits_per_sample = 16; break;
+ case 1: bits_per_sample = 20; break;
+ case 2: bits_per_sample = 24; break;
+ }
+
+ if( this->bits_per_sample != bits_per_sample ||
+ this->number_of_channels != num_channels ||
+ this->rate != sample_rate ||
+ !this->output_open ) {
+ this->bits_per_sample = bits_per_sample;
+ this->number_of_channels = num_channels;
+ this->rate = sample_rate;
+ format_changed++;
+ }
+ }
+
+ if( buf->decoder_flags & BUF_FLAG_HEADER ) {
+ this->rate=buf->decoder_info[1];
+ this->bits_per_sample=buf->decoder_info[2] ;
+ this->number_of_channels=buf->decoder_info[3] ;
+ format_changed++;
+ }
+
/*
* (re-)open output device
*/
- if ( buf->decoder_flags & BUF_FLAG_HEADER ) {
-
+ if ( format_changed ) {
if (this->output_open)
this->audio_out->close (this->audio_out);
- this->rate=buf->decoder_info[1];
- this->bits_per_sample=buf->decoder_info[2] ;
- this->number_of_channels=buf->decoder_info[3] ;
this->ao_cap_mode=(this->number_of_channels == 2) ? AO_CAP_MODE_STEREO : AO_CAP_MODE_MONO;
-
+
this->output_open = this->audio_out->open (this->audio_out,
- this->bits_per_sample,
+ (this->bits_per_sample>16)?16:this->bits_per_sample,
this->rate,
this->ao_cap_mode) ;
}
- if (!this->output_open)
+ if (!this->output_open || (buf->decoder_flags & BUF_FLAG_HEADER) )
return;
audio_buffer = this->audio_out->get_buffer (this->audio_out);
diff --git a/src/xine-engine/buffer.h b/src/xine-engine/buffer.h
index 622af913a..1bc0213e2 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.60 2002/07/17 20:29:04 miguelfreitas Exp $
+ * $Id: buffer.h,v 1.61 2002/07/19 03:03:37 miguelfreitas Exp $
*
*
* contents:
@@ -248,6 +248,8 @@ struct buf_element_s {
* decoder_info[1] = BUF_SPECIAL_DECODER_CONFIG
* decoder_info[2] = data size
* decoder_info[3] = pointer to data
+ * This buffer is used to pass config information from .mp4 files
+ * (atom esds) to decoders. both mpeg4 and aac streams use that.
*/
#define BUF_SPECIAL_DECODER_CONFIG 4
@@ -255,10 +257,24 @@ struct buf_element_s {
* In a BUF_SPECIAL_SAMPLE_SIZE_TABLE buffer:
* decoder_info[1] = BUF_SPECIAL_SAMPLE_SIZE_TABLE
* decoder_info[2] =
- * decoder_info[3] = pointer to table with sample sizes (within current frame)
+ * decoder_info[3] = pointer to table with sample sizes
+ * (within current frame)
+ * libfaad needs to decode data on sample-sized chunks.
+ * unfortunately original sample sizes are not know at decoder stage.
+ * this buffer is used to pass such information.
*/
#define BUF_SPECIAL_SAMPLE_SIZE_TABLE 5
+/*
+ * In a BUF_SPECIAL_LPCM_CONFIG buffer:
+ * decoder_info[1] = BUF_SPECIAL_LPCM_CONFIG
+ * decoder_info[2] = config data
+ * lpcm data encoded into mpeg2 streams have a format configuration
+ * byte in every frame. this is used to detect the sample rate,
+ * number of bits and channels.
+ */
+#define BUF_SPECIAL_LPCM_CONFIG 6
+
typedef struct palette_entry_s palette_entry_t;
struct palette_entry_s