X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fmathops.h;h=4d88ed14c9b41c28fb3959225027d2488b9668d6;hb=34630b93dc7cf028a4b483c19c4f6ca4162c25c0;hp=4e24350ef25e6d384d1a6e5ea9e4a6ad9f2a5cbc;hpb=b7904f78c1d6fd081b18b506f819e2186d9e0ae1;p=ffmpeg diff --git a/libavcodec/mathops.h b/libavcodec/mathops.h index 4e24350ef25..4d88ed14c9b 100644 --- a/libavcodec/mathops.h +++ b/libavcodec/mathops.h @@ -53,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 @@ -112,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 */