[MPlayer-dev-eng] [PATCH] libbs2b audio filter

Reimar Döffinger Reimar.Doeffinger at gmx.de
Thu Mar 5 14:31:19 CET 2009


On Thu, Mar 05, 2009 at 03:49:48PM +0300, Andrew Savchenko wrote:
> Note concerning -Wno-pointer-arith: ISO C stardard (ISO/IEC 
> 9899:TC3), section 6.2.4, paragraph 27 states: "A pointer to void 
> shall have the same representation and alignment requirements as a
> pointer to a character type.", but gcc (as of version 4.3.0) issues 
> a warning in this case and this warning must be disabled as bogus.

That section does not define pointer arithmetic, section 6.5.6 does
that.
And that section says "If the pointer operand points to an element of an array object, ..."
To my knowledge void * are not considered to point to anything, thus
arithmetic on it would be undefined.
Quote paragraph only guarantees that void * can be cast to char *.

> Necessity of using void* pointers and pointer to function ensues 
> from aiming to avoid six different play functions for different 
> types of audio data

Using void * does not mean you have to do arithmetic on them, you can
e.g. make i uint8_t *.

> or even worse alternative: switch statement 
> inside single play function.

Now you have a switch inside the config...
There may well be reasons to do it this way, but if you just _assume_ it
is faster or simpler like this, you may well assume wrong.
Indirect function calls can be slower on some architectures, as well as
adds with a runtime values instead of a constant, though I don't think
it gets any more inefficient than one function call per sample, such an
inner loop obviously belongs into the library, particularly since that
one-sample-a-time approach makes SIMD-optimization near impossible.
Anyway just using uint8_t * instead of void * should work well enough.



More information about the MPlayer-dev-eng mailing list