X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Facelp_filters.c;h=94ec94792f408f50f9153fe3679d1e28f9c3733a;hb=6708cfc4d3a079527409b2ba2fc75997a7975104;hp=e05efa40e54f23508a3c18ad7f0432a736a477d7;hpb=fee37a498565c2d7bb62982411ed970a92d75351;p=ffmpeg diff --git a/libavcodec/acelp_filters.c b/libavcodec/acelp_filters.c index e05efa40e54..94ec94792f4 100644 --- a/libavcodec/acelp_filters.c +++ b/libavcodec/acelp_filters.c @@ -24,8 +24,6 @@ #include "avcodec.h" #include "acelp_filters.h" -#define FRAC_BITS 13 -#include "mathops.h" const int16_t ff_acelp_interp_filter[61] = { /* (0.15) */ @@ -47,7 +45,7 @@ void ff_acelp_interpolate( const int16_t* in, const int16_t* filter_coeffs, int precision, - int pitch_delay_frac, + int frac_pos, int filter_length, int length) { @@ -72,85 +70,17 @@ void ff_acelp_interpolate( v += R(n-i)*ff_acelp_interp_filter(t+6i) v += R(n+i+1)*ff_acelp_interp_filter(6-t+6i) */ - v += in[n + i] * filter_coeffs[idx + pitch_delay_frac]; + v += in[n + i] * filter_coeffs[idx + frac_pos]; idx += precision; i++; - v += in[n - i] * filter_coeffs[idx - pitch_delay_frac]; + v += in[n - i] * filter_coeffs[idx - frac_pos]; } - out[n] = av_clip_int16(v >> 15); + if(av_clip_int16(v>>15) != (v>>15)) + av_log(NULL, AV_LOG_WARNING, "overflow that would need cliping in ff_acelp_interpolate()\n"); + out[n] = v >> 15; } } -void ff_acelp_convolve_circ( - int16_t* fc_out, - const int16_t* fc_in, - const int16_t* filter, - int subframe_size) -{ - int i, k; - - memset(fc_out, 0, subframe_size * sizeof(int16_t)); - - /* Since there are few pulses over an entire subframe (i.e. almost - all fc_in[i] are zero) it is faster to loop over fc_in first. */ - for(i=0; i> 15; - - for(k=i; k> 15; - } - } -} - -int ff_acelp_lp_synthesis_filter( - int16_t *out, - const int16_t* filter_coeffs, - const int16_t* in, - int buffer_length, - int filter_length, - int stop_on_overflow, - int rounder) -{ - int i,n; - - // These two lines are to avoid a -1 subtraction in the main loop - filter_length++; - filter_coeffs--; - - for(n=0; n> 12) + in[n]; - - if(sum + 0x8000 > 0xFFFFU) - { - if(stop_on_overflow) - return 1; - sum = (sum >> 31) ^ 32767; - } - out[n] = sum; - } - - return 0; -} - -void ff_acelp_weighted_filter( - int16_t *out, - const int16_t* in, - const int16_t *weight_pow, - int filter_length) -{ - int n; - for(n=0; n> 15; /* (3.12) = (0.15) * (3.12) with rounding */ -} void ff_acelp_high_pass_filter( int16_t* out, @@ -163,11 +93,13 @@ void ff_acelp_high_pass_filter( for(i=0; i>13; + tmp += (hpf_f[1]* -7667LL)>>13; + tmp += 7699 * (in[i] - 2*in[i-1] + in[i-2]); - out[i] = av_clip_int16((tmp + 0x800) >> 12); /* (15.0) = 2 * (13.13) = (14.13) */ + /* With "+0x800" rounding, clipping is needed + for ALGTHM and SPEECH tests. */ + out[i] = av_clip_int16((tmp + 0x800) >> 12); hpf_f[1] = hpf_f[0]; hpf_f[0] = tmp;