X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fmathops.h;h=4d88ed14c9b41c28fb3959225027d2488b9668d6;hb=81a646140f80c3e15c1e68883a5ecfb9b2bc8a6a;hp=1477ba652bf30287b7fdfea3ad0bb0c8d5b1fe16;hpb=e20a4f53a091ae74e6c9e9a280eefe5c59c7ebe4;p=ffmpeg diff --git a/libavcodec/mathops.h b/libavcodec/mathops.h index 1477ba652bf..4d88ed14c9b 100644 --- a/libavcodec/mathops.h +++ b/libavcodec/mathops.h @@ -26,8 +26,12 @@ #if ARCH_ARM # include "arm/mathops.h" +#elif ARCH_AVR32 +# include "avr32/mathops.h" #elif ARCH_BFIN # include "bfin/mathops.h" +#elif ARCH_MIPS +# include "mips/mathops.h" #elif ARCH_PPC # include "ppc/mathops.h" #elif ARCH_X86 @@ -49,6 +53,12 @@ static av_always_inline int MULH(int a, int b){ } #endif +#ifndef UMULH +static av_always_inline unsigned UMULH(unsigned a, unsigned b){ + return ((uint64_t)(a) * (uint64_t)(b))>>32; +} +#endif + #ifndef MUL64 # define MUL64(a,b) ((int64_t)(a) * (int64_t)(b)) #endif @@ -108,9 +118,65 @@ static inline av_const int mid_pred(int a, int b, int c) #ifndef sign_extend static inline av_const int sign_extend(int val, unsigned bits) { - return (val << (INT_BIT - bits)) >> (INT_BIT - bits); + return (val << ((8 * sizeof(int)) - bits)) >> ((8 * sizeof(int)) - bits); } #endif +#ifndef zero_extend +static inline av_const unsigned zero_extend(unsigned val, unsigned bits) +{ + return (val << ((8 * sizeof(int)) - bits)) >> ((8 * sizeof(int)) - bits); +} +#endif + +#ifndef COPY3_IF_LT +#define COPY3_IF_LT(x, y, a, b, c, d)\ +if ((y) < (x)) {\ + (x) = (y);\ + (a) = (b);\ + (c) = (d);\ +} +#endif + +#ifndef NEG_SSR32 +# define NEG_SSR32(a,s) ((( int32_t)(a))>>(32-(s))) +#endif + +#ifndef NEG_USR32 +# define NEG_USR32(a,s) (((uint32_t)(a))>>(32-(s))) +#endif + +#if HAVE_BIGENDIAN +# ifndef PACK_2U8 +# define PACK_2U8(a,b) (((a) << 8) | (b)) +# endif +# ifndef PACK_4U8 +# define PACK_4U8(a,b,c,d) (((a) << 24) | ((b) << 16) | ((c) << 8) | (d)) +# endif +# ifndef PACK_2U16 +# define PACK_2U16(a,b) (((a) << 16) | (b)) +# endif +#else +# ifndef PACK_2U8 +# define PACK_2U8(a,b) (((b) << 8) | (a)) +# endif +# ifndef PACK_4U2 +# define PACK_4U8(a,b,c,d) (((d) << 24) | ((c) << 16) | ((b) << 8) | (a)) +# endif +# ifndef PACK_2U16 +# define PACK_2U16(a,b) (((b) << 16) | (a)) +# endif +#endif + +#ifndef PACK_2S8 +# define PACK_2S8(a,b) PACK_2U8((a)&255, (b)&255) +#endif +#ifndef PACK_4S8 +# define PACK_4S8(a,b,c,d) PACK_4U8((a)&255, (b)&255, (c)&255, (d)&255) +#endif +#ifndef PACK_2S16 +# define PACK_2S16(a,b) PACK_2U16((a)&0xffff, (b)&0xffff) +#endif + #endif /* AVCODEC_MATHOPS_H */