@ -28,18 +28,16 @@
# include "avcodec.h"
# include "avcodec.h"
# include "get_bits.h"
# include "get_bits.h"
# include "dsputil.h"
# include "dsputil.h"
# include "mathops.h"
/*
/*
* TODO :
* TODO :
* - in low precision mode , use more 16 bit multiplies in synth filter
* - test lsf / mpeg25 extensively .
* - test lsf / mpeg25 extensively .
*/
*/
# include "mpegaudio.h"
# include "mpegaudio.h"
# include "mpegaudiodecheader.h"
# include "mpegaudiodecheader.h"
# include "mathops.h"
# if CONFIG_FLOAT
# if CONFIG_FLOAT
# define SHR(a,b) ((a)*(1.0f / (1<<(b))))
# define SHR(a,b) ((a)*(1.0f / (1<<(b))))
# define compute_antialias compute_antialias_float
# define compute_antialias compute_antialias_float
@ -248,14 +246,6 @@ static inline int l3_unscale(int value, int exponent)
static int dev_4_3_coefs [ DEV_ORDER ] ;
static int dev_4_3_coefs [ DEV_ORDER ] ;
#if 0 /* unused */
static int pow_mult3 [ 3 ] = {
POW_FIX ( 1.0 ) ,
POW_FIX ( 1.25992104989487316476 ) ,
POW_FIX ( 1.58740105196819947474 ) ,
} ;
# endif
static av_cold void int_pow_init ( void )
static av_cold void int_pow_init ( void )
{
{
int i , a ;
int i , a ;
@ -267,53 +257,6 @@ static av_cold void int_pow_init(void)
}
}
}
}
#if 0 /* unused, remove? */
/* return the mantissa and the binary exponent */
static int int_pow ( int i , int * exp_ptr )
{
int e , er , eq , j ;
int a , a1 ;
/* renormalize */
a = i ;
e = POW_FRAC_BITS ;
while ( a < ( 1 < < ( POW_FRAC_BITS - 1 ) ) ) {
a = a < < 1 ;
e - - ;
}
a - = ( 1 < < POW_FRAC_BITS ) ;
a1 = 0 ;
for ( j = DEV_ORDER - 1 ; j > = 0 ; j - - )
a1 = POW_MULL ( a , dev_4_3_coefs [ j ] + a1 ) ;
a = ( 1 < < POW_FRAC_BITS ) + a1 ;
/* exponent compute (exact) */
e = e * 4 ;
er = e % 3 ;
eq = e / 3 ;
a = POW_MULL ( a , pow_mult3 [ er ] ) ;
while ( a > = 2 * POW_FRAC_ONE ) {
a = a > > 1 ;
eq + + ;
}
/* convert to float */
while ( a < POW_FRAC_ONE ) {
a = a < < 1 ;
eq - - ;
}
/* now POW_FRAC_ONE <= a < 2 * POW_FRAC_ONE */
# if POW_FRAC_BITS > FRAC_BITS
a = ( a + ( 1 < < ( POW_FRAC_BITS - FRAC_BITS - 1 ) ) ) > > ( POW_FRAC_BITS - FRAC_BITS ) ;
/* correct overflow */
if ( a > = 2 * ( 1 < < FRAC_BITS ) ) {
a = a > > 1 ;
eq + + ;
}
# endif
* exp_ptr = eq ;
return a ;
}
# endif
static av_cold int decode_init ( AVCodecContext * avctx )
static av_cold int decode_init ( AVCodecContext * avctx )
{
{
MPADecodeContext * s = avctx - > priv_data ;
MPADecodeContext * s = avctx - > priv_data ;
@ -540,24 +483,6 @@ static inline float round_sample(float *sum)
# define MLSS(rt, ra, rb) rt-=(ra)*(rb)
# define MLSS(rt, ra, rb) rt-=(ra)*(rb)
# elif FRAC_BITS <= 15
static inline int round_sample ( int * sum )
{
int sum1 ;
sum1 = ( * sum ) > > OUT_SHIFT ;
* sum & = ( 1 < < OUT_SHIFT ) - 1 ;
return av_clip ( sum1 , OUT_MIN , OUT_MAX ) ;
}
/* signed 16x16 -> 32 multiply add accumulate */
# define MACS(rt, ra, rb) MAC16(rt, ra, rb)
/* signed 16x16 -> 32 multiply */
# define MULS(ra, rb) MUL16(ra, rb)
# define MLSS(rt, ra, rb) MLS16(rt, ra, rb)
# else
# else
static inline int round_sample ( int64_t * sum )
static inline int round_sample ( int64_t * sum )
@ -624,8 +549,6 @@ void av_cold RENAME(ff_mpa_synth_init)(MPA_INT *window)
v = ff_mpa_enwindow [ i ] ;
v = ff_mpa_enwindow [ i ] ;
# if CONFIG_FLOAT
# if CONFIG_FLOAT
v * = 1.0 / ( 1LL < < ( 16 + FRAC_BITS ) ) ;
v * = 1.0 / ( 1LL < < ( 16 + FRAC_BITS ) ) ;
# elif WFRAC_BITS < 16
v = ( v + ( 1 < < ( 16 - WFRAC_BITS - 1 ) ) ) > > ( 16 - WFRAC_BITS ) ;
# endif
# endif
window [ i ] = v ;
window [ i ] = v ;
if ( ( i & 63 ) ! = 0 )
if ( ( i & 63 ) ! = 0 )
@ -652,8 +575,6 @@ static void apply_window_mp3_c(MPA_INT *synth_buf, MPA_INT *window,
OUT_INT * samples2 ;
OUT_INT * samples2 ;
# if CONFIG_FLOAT
# if CONFIG_FLOAT
float sum , sum2 ;
float sum , sum2 ;
# elif FRAC_BITS <= 15
int sum , sum2 ;
# else
# else
int64_t sum , sum2 ;
int64_t sum , sum2 ;
# endif
# endif
@ -710,25 +631,11 @@ void ff_mpa_synth_filter(MPA_INT *synth_buf_ptr, int *synth_buf_offset,
{
{
register MPA_INT * synth_buf ;
register MPA_INT * synth_buf ;
int offset ;
int offset ;
# if FRAC_BITS <= 15
int32_t tmp [ 32 ] ;
int j ;
# endif
offset = * synth_buf_offset ;
offset = * synth_buf_offset ;
synth_buf = synth_buf_ptr + offset ;
synth_buf = synth_buf_ptr + offset ;
# if FRAC_BITS <= 15
dct32 ( tmp , sb_samples ) ;
for ( j = 0 ; j < 32 ; j + + ) {
/* NOTE: can cause a loss in precision if very high amplitude
sound */
synth_buf [ j ] = av_clip_int16 ( tmp [ j ] ) ;
}
# else
dct32 ( synth_buf , sb_samples ) ;
dct32 ( synth_buf , sb_samples ) ;
# endif
apply_window_mp3_c ( synth_buf , window , dither_state , samples , incr ) ;
apply_window_mp3_c ( synth_buf , window , dither_state , samples , incr ) ;
offset = ( offset - 32 ) & 511 ;
offset = ( offset - 32 ) & 511 ;