X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Faudio_filter%2Fconverter%2Fmpgatofixed32.c;h=4a3efcf76b03013ca095e73bc659c45a0d082d03;hb=5b55ee1bb0a0212b967f8f4a33824ffc6b7c7f09;hp=b3c02cccb2d173095694a6b50e157278228bd0b2;hpb=fe087a38282e93addb25fa9598393e40ea233b09;p=vlc diff --git a/modules/audio_filter/converter/mpgatofixed32.c b/modules/audio_filter/converter/mpgatofixed32.c index b3c02cccb2..4a3efcf76b 100644 --- a/modules/audio_filter/converter/mpgatofixed32.c +++ b/modules/audio_filter/converter/mpgatofixed32.c @@ -6,13 +6,13 @@ * $Id$ * * Authors: Christophe Massiot - * Jean-Paul Saman - * + * Jean-Paul Saman + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -20,20 +20,22 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ /***************************************************************************** * Preamble *****************************************************************************/ -#include /* malloc(), free() */ -#include /* strdup() */ #include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include -#include -#include "aout_internal.h" +#include +#include #include "vlc_filter.h" /***************************************************************************** @@ -41,7 +43,7 @@ *****************************************************************************/ static int Create ( vlc_object_t * ); static void Destroy ( vlc_object_t * ); -static void DoWork ( aout_instance_t *, aout_filter_t *, aout_buffer_t *, +static void DoWork ( aout_instance_t *, aout_filter_t *, aout_buffer_t *, aout_buffer_t * ); static int OpenFilter ( vlc_object_t * ); @@ -54,8 +56,10 @@ static block_t *Convert( filter_t *, block_t * ); struct filter_sys_t { struct mad_stream mad_stream; - struct mad_frame mad_frame; - struct mad_synth mad_synth; + struct mad_frame mad_frame; + struct mad_synth mad_synth; + + int i_reject_count; }; /***************************************************************************** @@ -75,7 +79,7 @@ vlc_module_begin(); vlc_module_end(); /***************************************************************************** - * Create: + * Create: *****************************************************************************/ static int Create( vlc_object_t *p_this ) { @@ -109,6 +113,7 @@ static int Create( vlc_object_t *p_this ) mad_frame_init( &p_sys->mad_frame ); mad_synth_init( &p_sys->mad_synth ); mad_stream_options( &p_sys->mad_stream, MAD_OPTION_IGNORECRC ); + p_sys->i_reject_count = 0; p_filter->pf_do_work = DoWork; p_filter->b_in_place = 0; @@ -125,7 +130,7 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter, filter_sys_t *p_sys = (filter_sys_t *)p_filter->p_sys; p_out_buf->i_nb_samples = p_in_buf->i_nb_samples; - p_out_buf->i_nb_bytes = p_in_buf->i_nb_samples * sizeof(vlc_fixed_t) * + p_out_buf->i_nb_bytes = p_in_buf->i_nb_samples * sizeof(vlc_fixed_t) * aout_FormatNbChannels( &p_filter->output ); /* Do the actual decoding now. */ @@ -135,11 +140,20 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter, { msg_Dbg( p_aout, "libmad error: %s", mad_stream_errorstr( &p_sys->mad_stream ) ); + p_sys->i_reject_count = 3; + } + else if( p_in_buf->b_discontinuity ) + { + p_sys->i_reject_count = 3; + } + + if( p_sys->i_reject_count > 0 ) + { if( p_filter->output.i_format == VLC_FOURCC('f','l','3','2') ) { int i; int i_size = p_out_buf->i_nb_bytes / sizeof(float); - + float * a = (float *)p_out_buf->p_buffer; for ( i = 0 ; i < i_size ; i++ ) *a++ = 0.0; @@ -148,9 +162,11 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter, { memset( p_out_buf->p_buffer, 0, p_out_buf->i_nb_bytes ); } + p_sys->i_reject_count--; return; } + mad_synth_frame( &p_sys->mad_synth, &p_sys->mad_frame ); if ( p_filter->output.i_format == VLC_FOURCC('f','i','3','2') ) @@ -199,8 +215,7 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter, break; case 1: - p_filter->p_vlc->pf_memcpy( p_samples, p_left, - i_samples * sizeof(mad_fixed_t) ); + vlc_memcpy( p_samples, p_left, i_samples * sizeof(mad_fixed_t) ); break; default: @@ -284,7 +299,7 @@ static void Destroy( vlc_object_t *p_this ) } /***************************************************************************** - * OpenFilter: + * OpenFilter: *****************************************************************************/ static int OpenFilter( vlc_object_t *p_this ) { @@ -304,6 +319,7 @@ static int OpenFilter( vlc_object_t *p_this ) msg_Err( p_filter, "out of memory" ); return -1; } + p_sys->i_reject_count = 0; p_filter->pf_audio_filter = Convert; @@ -313,7 +329,7 @@ static int OpenFilter( vlc_object_t *p_this ) mad_synth_init( &p_sys->mad_synth ); mad_stream_options( &p_sys->mad_stream, MAD_OPTION_IGNORECRC ); - if( p_this->p_libvlc->i_cpu & CPU_CAPABILITY_FPU ) + if( vlc_CPU() & CPU_CAPABILITY_FPU ) p_filter->fmt_out.i_codec = VLC_FOURCC('f','l','3','2'); else p_filter->fmt_out.i_codec = VLC_FOURCC('f','i','3','2'); @@ -380,6 +396,7 @@ static block_t *Convert( filter_t *p_filter, block_t *p_block ) aout_filter.output.i_format = p_filter->fmt_out.i_codec; in_buf.p_buffer = p_block->p_buffer; + in_buf.b_discontinuity = false; in_buf.i_nb_bytes = p_block->i_buffer; in_buf.i_nb_samples = p_block->i_samples; out_buf.p_buffer = p_out->p_buffer;