diff options
author | mplayer-svn <svn@mplayerhq.hu> | 2012-03-24 19:19:03 +0000 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-08-03 02:18:22 +0200 |
commit | ca2be52db5fd747b40a8ae3c9673b8fcd2413a70 (patch) | |
tree | 4cc454b4269c698f661a4ba898c9733b76b1de9d /libmpcodecs | |
parent | a428aaf3af51807e487feb5ffaf89ef4bc956244 (diff) |
ad_mad: cleanups
Remove unnecessary casts.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34827 b3059339-0415-0410-9bf9-f77b7e298cf2
Replace malloc+memset by calloc.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34828 b3059339-0415-0410-9bf9-f77b7e298cf2
libmad: set i_bps only if it is not already set.
Since that value is only based on the very first MP3 frame,
it is very likely to be much less accurate than any existing
value from a demuxer.
Patch by Benoît Thébaudeau.
Signed-off-by: "Benoît Thébaudeau" <benoit.thebaudeau@advansee.com>
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34829 b3059339-0415-0410-9bf9-f77b7e298cf2
Author: reimar
Diffstat (limited to 'libmpcodecs')
-rw-r--r-- | libmpcodecs/ad_libmad.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/libmpcodecs/ad_libmad.c b/libmpcodecs/ad_libmad.c index 08dbe72857..81475374e1 100644 --- a/libmpcodecs/ad_libmad.c +++ b/libmpcodecs/ad_libmad.c @@ -52,8 +52,7 @@ typedef struct mad_decoder_s { static int preinit(sh_audio_t *sh){ - mad_decoder_t *this = malloc(sizeof(mad_decoder_t)); - memset(this,0,sizeof(mad_decoder_t)); + mad_decoder_t *this = calloc(1, sizeof(mad_decoder_t)); sh->context = this; mad_synth_init (&this->synth); @@ -67,7 +66,7 @@ static int preinit(sh_audio_t *sh){ } static int read_frame(sh_audio_t *sh){ - mad_decoder_t *this = (mad_decoder_t *) sh->context; + mad_decoder_t *this = sh->context; int len; while((len=demux_read_data(sh->ds,&sh->a_in_buffer[sh->a_in_buffer_len], @@ -94,21 +93,22 @@ return 0; } static int init(sh_audio_t *sh){ - mad_decoder_t *this = (mad_decoder_t *) sh->context; + mad_decoder_t *this = sh->context; this->have_frame=read_frame(sh); if(!this->have_frame) return 0; // failed to sync... sh->channels=(this->frame.header.mode == MAD_MODE_SINGLE_CHANNEL) ? 1 : 2; sh->samplerate=this->frame.header.samplerate; - sh->i_bps=this->frame.header.bitrate/8; + if (sh->i_bps < 1) + sh->i_bps=this->frame.header.bitrate/8; sh->samplesize=2; return 1; } static void uninit(sh_audio_t *sh){ - mad_decoder_t *this = (mad_decoder_t *) sh->context; + mad_decoder_t *this = sh->context; mad_synth_finish (&this->synth); mad_frame_finish (&this->frame); mad_stream_finish(&this->stream); @@ -131,7 +131,7 @@ static inline signed int scale(mad_fixed_t sample) { } static int decode_audio(sh_audio_t *sh,unsigned char *buf,int minlen,int maxlen){ - mad_decoder_t *this = (mad_decoder_t *) sh->context; + mad_decoder_t *this = sh->context; int len=0; while(len<minlen && len+4608<=maxlen){ @@ -170,7 +170,7 @@ static int decode_audio(sh_audio_t *sh,unsigned char *buf,int minlen,int maxlen) } static int control(sh_audio_t *sh,int cmd,void* arg, ...){ - mad_decoder_t *this = (mad_decoder_t *) sh->context; + mad_decoder_t *this = sh->context; // various optional functions you MAY implement: switch(cmd){ case ADCTRL_RESYNC_STREAM: |