[FFmpeg-devel] [PATCH] new function get_sbits_long()

Måns Rullgård mans
Mon Mar 2 20:43:54 CET 2009


Michael Niedermayer <michaelni at gmx.at> writes:

> On Mon, Mar 02, 2009 at 08:03:29PM +0100, Michael Niedermayer wrote:
>> On Mon, Mar 02, 2009 at 06:18:24PM +0000, M?ns Rullg?rd wrote:
>> > Michael Niedermayer <michaelni at gmx.at> writes:
>> > 
>> > > On Mon, Mar 02, 2009 at 12:39:05PM -0500, Justin Ruggles wrote:
>> > >> Hi,
>> > >> 
>> > >> I need a get_sbits_long() function to support FLAC files that are more
>> > >> than 24-bit.  There might be a better way to do it, but this works.
>> > >
>> > > only where int is 32bit which isnt guranteed even if likely
>> > 
>> > I still think we should put a sign_extend() function in mathops.h or
>> > similar.
>> 
>> i agree
>
> also it should be considered that if the amount of sign extension is
> known at compile time then a + and xor is enough and no shifts are
> needed which may be faster
>
> 4 ways to sign extend 8->16bit without shifts
> (u + 0xFF80) ^ 0xFF80
> (u - 0x0080) ^ 0xFF80
> (u ^ 0xFF80) - 0xFF80
> (u ^ 0xFF80) + 0x0080

Some architectures have specific instructions for sign extension.  We
should make sure that those get used where available, whether the
compiler is smart enough or we use inline asm.

-- 
M?ns Rullg?rd
mans at mansr.com




More information about the ffmpeg-devel mailing list