vlc-0.2.90-modules3 [IPAQ port]

Christophe Massiot massiot at via.ecp.fr
Tue Nov 6 19:10:54 CET 2001


On Tue, Nov 06, 2001, Jean-Paul Saman wrote:

> Currently I'm trying to get the libmad audio decoder into vlc as a
> decoder plugin/builtin.  

This looks like an excellent work.

> /*****************************************************************************
>  * 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;

You can probably write
mad_adec_thread_t *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);

What you're looking for is GetChunk() :).

>   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 ??? */

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?

At first you need to create the fifo with the good parameters (or update
the parameters when you know the rate and stuff - see audio_output.c:RunThread).
Thereafter it expects data in the format you indicated.
I suggest you have a look at lpcm_decoder_thread.c instead, it is
much simpler and does exactly what you expect.

> /*****************************************************************************
>  * 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 );
 
That's it, provided you tell the output thread the format of the data...

>   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;
> }

-- 
Christophe Massiot.




More information about the vlc-devel mailing list