[FFmpeg-devel] [PATCH] bswap: add macros to byteswap constants

Måns Rullgård mans
Thu Apr 29 16:15:59 CEST 2010

Michael Niedermayer <michaelni at gmx.at> writes:

> On Thu, Apr 29, 2010 at 02:26:50PM +0100, Mans Rullgard wrote:
>> The normal byteswap functions might use inline asm which is suboptimal
>> with constants (and cannot be used in static initialisers), so special
>> macros for constants only is needed.
>> We should not rely on the gcc __builtin_constant_p() test since it is
>> not always available.
> if its not available then this kind of optimization is not possible

I intended these to be used where the value is a constant expression,
e.g. bswap(0x1234).  This would be useful for building constant tables
that depend on the byte order.

> adding even more complexity, ifdefery, and burden to support partial
> optimizations in extreemly primitive compilers is imho not a good idea.

Not all non-gcc compilers are extremely primitive.  In fact, many of
them are far superior.

> If one wants optimized
> code a compiler with the (optimization relevant) feature set of gcc is
> imho the minimum requirement.
> thats besides that this patch is just a brick of a huge wall that would

Look who's talking.

> be needed for this hack, you would need to duplicate every use of le/be
> code as well. The bitstream readers is just the next step, and then all
> uses of the bitstream code would have to be reviewed if the values are
> compiletime constant or not. Thats huge amounts of work for a primitive
> compiler. id much rather completely drop support for such compilers

You (deliberately?) misunderstood the purpose of this patch.

M?ns Rullg?rd
mans at mansr.com

More information about the ffmpeg-devel mailing list