Commit cf7a11cd authored by Jean-Paul Saman's avatar Jean-Paul Saman

Aout fifo adapts it size according to the length of the first frame.

The change is needed for MPEG1/2 layer III, because the size of output pcm from mad_decoder is different.
Sadly, the buffer underruns are back ;-(.
parent 71865b97
......@@ -181,7 +181,7 @@ static int InitThread( mad_adec_thread_t * p_mad_adec )
0); /* message */
mad_decoder_options(p_mad_adec->libmad_decoder, MAD_OPTION_IGNORECRC);
mad_timer_reset(&p_mad_adec->libmad_timer);
// mad_timer_reset(&p_mad_adec->libmad_timer);
/*
* Initialize the output properties
......
......@@ -17,17 +17,11 @@
#ifndef _VLC_MAD_ADEC_H_
#define _VLC_MAD_ADEC_H_
/*****************************************************************************
* mad_adec_thread_t : mad decoder thread descriptor
*****************************************************************************/
// FIXME: Ugly define inside a decoder
#define ADEC_FRAME_SIZE (2*1152)
// MAD_BUFFER_MDLEN (511 + 2048 + MAD_BUFLEN_GUARD) and MAD_BUFLEN_GUARD is 8
#define MAD_BUFFER_SIZE (MAD_BUFFER_MDLEN)
//#define MAD_BUFFER_SIZE (ADEC_FRAME_SIZE*2)
#define MAD_OUTPUT_SIZE (ADEC_FRAME_SIZE*2)
typedef struct mad_adec_thread_s
{
/*
......@@ -35,7 +29,7 @@ typedef struct mad_adec_thread_s
*/
struct mad_decoder *libmad_decoder;
mad_timer_t libmad_timer;
byte_t buffer[MAD_BUFFER_SIZE];
byte_t buffer[MAD_BUFFER_MDLEN];
/*
* Thread properties
......
......@@ -82,7 +82,7 @@ enum mad_flow libmad_input(void *data, struct mad_stream *p_libmad_stream)
Remaining );
}
ReadStart=p_mad_adec->buffer+Remaining;
ReadSize=(MAD_BUFFER_SIZE)-Remaining;
ReadSize=(MAD_BUFFER_MDLEN)-Remaining;
/* Store time stamp of next frame */
p_mad_adec->i_current_pts = p_mad_adec->i_next_pts;
......@@ -90,7 +90,7 @@ enum mad_flow libmad_input(void *data, struct mad_stream *p_libmad_stream)
}
else
{
ReadSize=(MAD_BUFFER_SIZE);
ReadSize=(MAD_BUFFER_MDLEN);
ReadStart=p_mad_adec->buffer;
Remaining=0;
p_mad_adec->i_next_pts = 0;
......@@ -154,7 +154,7 @@ enum mad_flow libmad_input(void *data, struct mad_stream *p_libmad_stream)
* intf_ErrMsg( "mad_adec: libmad_header samplerate %d", p_libmad_header->samplerate);
*
* p_mad_adec->p_aout_fifo->i_rate = p_libmad_header->samplerate;
* mad_timer_add(&p_mad_adec->libmad_timer,p_libmad_header->duration);
* // mad_timer_add(&p_mad_adec->libmad_timer,p_libmad_header->duration);
*
* return MAD_FLOW_CONTINUE;
*}
......@@ -301,7 +301,7 @@ enum mad_flow libmad_output(void *data, struct mad_header const *p_libmad_header
AOUT_FIFO_PCM, /* fifo type */
p_libmad_pcm->channels, /* nr. of channels */
p_libmad_pcm->samplerate, /* frame rate in Hz ?*/
ADEC_FRAME_SIZE, /* frame size */
p_libmad_pcm->length*2, /* length of output buffer *2 channels*/
NULL ); /* buffer */
if ( p_mad_adec->p_aout_fifo == NULL )
......@@ -330,9 +330,9 @@ enum mad_flow libmad_output(void *data, struct mad_header const *p_libmad_header
p_mad_adec->p_aout_fifo->date[p_mad_adec->p_aout_fifo->i_end_frame]
= LAST_MDATE;
}
mad_timer_add(&p_mad_adec->libmad_timer,p_libmad_header->duration);
// mad_timer_add(&p_mad_adec->libmad_timer,p_libmad_header->duration);
buffer = ((byte_t *)p_mad_adec->p_aout_fifo->buffer) + (p_mad_adec->p_aout_fifo->i_end_frame * MAD_OUTPUT_SIZE);
buffer = ((byte_t *)p_mad_adec->p_aout_fifo->buffer) + (p_mad_adec->p_aout_fifo->i_end_frame * (p_libmad_pcm->length*4));
while (nsamples--)
{
......@@ -349,8 +349,8 @@ enum mad_flow libmad_output(void *data, struct mad_header const *p_libmad_header
*buffer++ = (byte_t) (sample >> 8);
*buffer++ = (byte_t) (sample >> 0);
#endif
if (p_libmad_pcm->channels == 2) {
if (p_libmad_pcm->channels == 2)
{
/* right audio channel */
#ifdef MPG321_ROUTINES
sample = audio_linear_dither(16, *right_ch++, &dither);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment