[FFmpeg-devel] [PATCH] Lowpass functionality for lavc
Michael Niedermayer
michaelni
Tue Aug 12 19:08:47 CEST 2008
On Tue, Aug 12, 2008 at 07:58:20PM +0300, Kostya wrote:
> On Tue, Aug 12, 2008 at 02:31:35PM +0200, Michael Niedermayer wrote:
> > 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
>
> added
not in the attached patch
>
> > >
> > > /**
> > > * 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.
>
> unrolled
neither in the attached patch
>
> > > 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
>
> Calculating actual filter parameters requires complex math
> (I've looked into code of mkfilt by T.Fisher which I used for obtaining
> filter coefficients and I should remember more of complex numbers than
> Euler's formula to understand it).
> I will do generic version when I get free time and refresh my algebra.
fine, its not important ATM
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.
-------------- 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/b0f97e33/attachment.pgp>
More information about the ffmpeg-devel
mailing list