[FFmpeg-devel] [PATCH] Lowpass functionality for lavc
Michael Niedermayer
michaelni
Tue Aug 12 14:31:35 CEST 2008
On Tue, Aug 12, 2008 at 02:23:55PM +0300, Kostya wrote:
> $subj, made as a separate module.
[...]
> /**
> * Initialize filter coefficients.
> *
> * @param coeffs filter coefficients
> * @param freq input frequency (sample rate/2)
> * @param cutoff cutoff frequency
> *
> * @return zero if filter creation succeeded, a negative value if filter could not be created
> */
> int ff_lowpass_filter_init_coeffs(LPFilterCoeffs *coeffs, int freq, int cutoff);
the filter order should also be a parameter
>
> /**
> * Filter input value.
> *
> * @param coeffs filter coefficients
> * @param s filter state
> * @param in input value
> *
> * @return filtered value
> */
> static av_always_inline float ff_lowpass_filter(LPFilterCoeffs *coeffs, LPFilterState *s, float in)
> {
> int i;
> for(i = 0; i < LOWPASS_FILTER_ORDER; i++){
> s->x[i] = s->x[i+1];
> s->y[i] = s->y[i+1];
> }
> s->x[LOWPASS_FILTER_ORDER] = in * coeffs->gain;
> //FIXME: made only for 4th order filter
> s->y[LOWPASS_FILTER_ORDER] = (s->x[0] + s->x[4])*1
> + (s->x[1] + s->x[3])*4
> + s->x[2] *6
> + coeffs->c[0]*s->y[0] + coeffs->c[1]*s->y[1]
> + coeffs->c[2]*s->y[2] + coeffs->c[3]*s->y[3];
> return s->y[LOWPASS_FILTER_ORDER];
> }
as already said in my other reply this should be unrolled so it needs no
moving of samples.
> int ff_lowpass_filter_init_coeffs(LPFilterCoeffs *coeffs, int freq, int cutoff)
> {
> int i, j, size;
> float cutoff_ratio;
>
> //since I'm too lazy to calculate coefficients, I take more or less matching ones from the table
> //TODO: generic version
hmm
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Asymptotically faster algorithms should always be preferred if you have
asymptotical amounts of data
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080812/473e2f8f/attachment.pgp>
More information about the ffmpeg-devel
mailing list