[FFmpeg-devel] [PATCH 2/3] x86: asm for sign/zero_extend()
Michael Niedermayer
michaelni
Sun Feb 21 03:09:03 CET 2010
On Sun, Feb 21, 2010 at 12:35:58AM +0000, Mans Rullgard wrote:
> ---
> libavcodec/x86/mathops.h | 18 ++++++++++++++++++
> 1 files changed, 18 insertions(+), 0 deletions(-)
>
> diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
> index 010cfb7..0c17f35 100644
> --- a/libavcodec/x86/mathops.h
> +++ b/libavcodec/x86/mathops.h
> @@ -97,4 +97,22 @@ static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
> return a;
> }
>
> +#define sign_extend sign_extend
> +static inline int sign_extend(int val, unsigned bits)
> +{
> + __asm__ ("shll %1, %0 \n\t"
> + "sarl %1, %0 \n\t"
> + : "+&r" (val) : "ic" ((uint8_t)-bits));
> + return val;
> +}
> +
> +#define zero_extend zero_extend
> +static inline unsigned zero_extend(unsigned val, unsigned bits)
> +{
> + __asm__ ("shll %1, %0 \n\t"
> + "shrl %1, %0 \n\t"
> + : "+&r" (val) : "ic" ((uint8_t)-bits));
> + return val;
if bits is a constant (which i guess it is quite often)
then this is quite inefficient.
val & 0x00007FFF
for example is more efficient in that case.
also its not certain 2 shifts are faster than =-1, >>, &
on all x86 cpus
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The real ebay dictionary, page 1
"Used only once" - "Some unspecified defect prevented a second use"
"In good condition" - "Can be repaird by experienced expert"
"As is" - "You wouldnt want it even if you were payed for it, if you knew ..."
-------------- 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/20100221/66a9d9cc/attachment.pgp>
More information about the ffmpeg-devel
mailing list