vlc-0.2.90-modules3 [IPAQ port]
Jean-Paul Saman
jpsaman at wxs.nl
Tue Nov 6 17:19:49 CET 2001
Hi guys,
Currently I'm trying to get the libmad audio decoder into vlc as a
decoder plugin/builtin.
I have trouble figuring out how to get the decoded pcm data into the
aout_fifo. Can someone explain/help?
As far as I understand I have an input fifo (let's call it
p_mad_adec->p_fifo) and an output fifo (let's call it
p_mad_adec->aout_fifo.
I feed the libmad decoder a stream of bits that get casted to unsigned
char. The stream of bits is taken from p_mad_adec->bit_stream (just like
in mpeg_adec) and put into a buffer that is feed to mad_stream_buffer().
Like this:
/*****************************************************************************
* libmad_input: this function is called by libmad when the input buffer
needs
* to be filled.
*****************************************************************************/
enum mad_flow libmad_input(void *data, struct mad_stream
*p_libmad_stream)
{
mad_adec_thread_t *p_mad_adec = NULL;
u32 buffer;
p_mad_adec = (mad_adec_thread_t *) data;
/* first try - TODO: make a bigger buffer
* Fetch data as one word at a time, 32 bits in this case
*/
buffer = GetBits32(&p_mad_adec->bit_stream);
if ( p_mad_adec->p_fifo->b_die == 1 )
return MAD_FLOW_STOP;
if ( p_mad_adec->p_fifo->b_error == 1 )
return MAD_FLOW_IGNORE;
/* is the length meant to be in bits or in bytes ??? */
mad_stream_buffer(p_libmad_stream, (unsigned char*) &buffer,
sizeof(buffer) );
return MAD_FLOW_CONTINUE;
}
The 'libmad' decoder calls the callback function libmad_output when a
frame is decoded. It delivers a pcm frame. In vlc source code I couldn't
figure out how p_aout_fifo was supposed to be used with decoded frames.
Does somebody now?
/*****************************************************************************
* libmad_ouput: this function is called just after the frame is decoded
*****************************************************************************/
enum mad_flow libmad_output(void *data, struct mad_header const
*p_libmad_header, struct mad_pcm *p_libmad_pcm)
{
mad_adec_thread_t *p_mad_adec;
p_mad_adec = (mad_adec_thread_t *) data;
vlc_mutex_lock (&p_mad_adec->p_aout_fifo->data_lock);
/*
* CAN I DO SOMETHING LIKE THIS - what is the format
p_aout_fifo->buffer expects??
*/
p_mad_adec->p_aout_fifo->buffer =
memcp(p_mad_adec->p_aout_fifo->buffer,
p_libmad_pcm->samples, p_libmad_pcm->length );
vlc_cond_signal (&p_mad_adec->p_aout_fifo->data_wait);
vlc_mutex_unlock (&p_mad_adec->p_aout_fifo->data_lock);
return MAD_FLOW_CONTINUE;
}
Greetings,
Jean-Paul Saman
More information about the vlc-devel
mailing list