[vlc-devel] [PATCH] Add support for mpg123 decoder

Laurent Aimar fenrir at babylon.via.ecp.fr
Thu Apr 1 22:23:37 CEST 2010


Hi,

On Thu, Apr 01, 2010 at 12:00:49AM -0600, William Hahne wrote:
> This is my GSoC qualification patch. I don't have any mpeg layer 1 or
> 2 files so those have not been tested yet.
> diff --git a/modules/codec/mpeg_audio.c b/modules/codec/mpeg_audio.c
> old mode 100644
> new mode 100755
> index 4267f09..9906eff
> --- a/modules/codec/mpeg_audio.c
> +++ b/modules/codec/mpeg_audio.c
> @@ -465,7 +465,7 @@ static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
>                              p_buf, __MIN( (unsigned)p_sys->i_frame_size, p_out_buffer->i_buffer ) );
>  
>              /* Get beginning of next frame for libmad */
> -            if( !p_sys->b_packetizer )
> +            if( !p_sys->b_packetizer && !module_exists( "mpgatofixed32_mpg123" ) )
>              {
>                  assert( p_out_buffer->i_buffer >= (unsigned)p_sys->i_frame_size + MAD_BUFFER_GUARD );
>                  memcpy( p_buf + p_sys->i_frame_size,
> @@ -508,8 +508,12 @@ static uint8_t *GetOutBuffer( decoder_t *p_dec, block_t **pp_out_buffer )
>      p_dec->fmt_out.audio.i_rate     = p_sys->i_rate;
>      p_dec->fmt_out.audio.i_channels = p_sys->i_channels;
>      p_dec->fmt_out.audio.i_frame_length = p_sys->i_frame_length;
> -    p_dec->fmt_out.audio.i_bytes_per_frame =
> -        p_sys->i_max_frame_size + MAD_BUFFER_GUARD;
> +
> +    if ( module_exists( "mpgatofixed32_mpg123" ) )
> +        p_dec->fmt_out.audio.i_bytes_per_frame = p_sys->i_max_frame_size;
> +    else
> +        p_dec->fmt_out.audio.i_bytes_per_frame = 
> +            p_sys->i_max_frame_size + MAD_BUFFER_GUARD;
>  
>      p_dec->fmt_out.audio.i_original_channels = p_sys->i_channels_conf;
>      p_dec->fmt_out.audio.i_physical_channels =
> @@ -551,8 +555,11 @@ static aout_buffer_t *GetAoutBuffer( decoder_t *p_dec )
>          p_buf->i_flags |= BLOCK_FLAG_DISCONTINUITY;
>      p_sys->b_discontinuity = false;
>  
> -    /* Hack for libmad filter */
> -    p_buf = block_Realloc( p_buf, 0, p_sys->i_frame_size + MAD_BUFFER_GUARD );
> +    /* Only apply hack for libmad filter if using libmad */
> +    if ( module_exists( "mpgatofixed32_mpg123" ) )
> +        p_buf = block_Realloc( p_buf, 0, p_sys->i_frame_size );
> +    else
> +        p_buf = block_Realloc( p_buf, 0, p_sys->i_frame_size + MAD_BUFFER_GUARD );

 The extra data appended by mpeg_audio.c for mad decoder is really a hack that
should be moved to mpgatofixed32.c.
 This would be cleaner and will avoid all those checks on
  module_exists( "mpgatofixed32_mpg123" )
(which are not really ok, even if "mpgatofixed32_mpg123" exists, it doesn't
means it will always be used).

Regards,

-- 
fenrir



More information about the vlc-devel mailing list