[FFmpeg-devel] [RFC] Lowpass filter

Michael Niedermayer michaelni
Wed Aug 27 14:58:07 CEST 2008


On Wed, Aug 27, 2008 at 08:00:14AM +0300, Kostya wrote:
> On Tue, Aug 26, 2008 at 07:33:28PM +0200, Michael Niedermayer wrote:
> > On Tue, Aug 26, 2008 at 07:48:07PM +0300, Kostya wrote:
[...]
> > [...]
> > > /**
> > >  * IIR filter state
> > >  */
> > > typedef struct FFFilterState{
> > >     float *x;
> > > }FFFilterState;
> > 
> > no, we do not want to do the extra pointer dereference nor do we want an
> > extra pointer to be stored, the correct way is:
> > 
> > typedef struct FFFilterState{
> >     float x[];
> > }
> 
> only with your own compiler, gcc results in
> iirfilter.c:45: error: flexible array member in otherwise empty struct

then use
float x[1];
and subtract that 1 during malloc

or use a void * and cast to float*


[...]

> struct FFIIRFilterState* ff_iir_filter_init_state(int order)
> {
>     FFIIRFilterState* s = av_mallocz(sizeof(FFIIRFilterState) + sizeof(s->x[0]) * order);

>     s->x = (void*)s + sizeof(FFIIRFilterState);

this is not legal C, arithmetic on void* is not alowed or undefined

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

It is not what we do, but why we do it that matters.
-------------- 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/20080827/a9cea93a/attachment.pgp>



More information about the ffmpeg-devel mailing list