X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fmathops.h;h=45b1ecf1ae435d47601d24f5e5363d7edb4a0c13;hb=2467d8d9eaae52eb8e18e276a44a15d1d8fd7f97;hp=d74bc1ed70e8bec5ac1b0b38e755cc2209d696ff;hpb=005db470115ebe2c973688bed9695356f487d674;p=ffmpeg diff --git a/libavcodec/mathops.h b/libavcodec/mathops.h index d74bc1ed70e..45b1ecf1ae4 100644 --- a/libavcodec/mathops.h +++ b/libavcodec/mathops.h @@ -23,6 +23,7 @@ #define AVCODEC_MATHOPS_H #include "libavutil/common.h" +#include "config.h" #if ARCH_ARM # include "arm/mathops.h" @@ -40,13 +41,17 @@ /* generic implementation */ +#ifndef MUL64 +# define MUL64(a,b) ((int64_t)(a) * (int64_t)(b)) +#endif + #ifndef MULL -# define MULL(a,b,s) (((int64_t)(a) * (int64_t)(b)) >> (s)) +# define MULL(a,b,s) (MUL64(a, b) >> (s)) #endif #ifndef MULH static av_always_inline int MULH(int a, int b){ - return ((int64_t)(a) * (int64_t)(b))>>32; + return MUL64(a, b) >> 32; } #endif @@ -56,10 +61,6 @@ static av_always_inline unsigned UMULH(unsigned a, unsigned b){ } #endif -#ifndef MUL64 -# define MUL64(a,b) ((int64_t)(a) * (int64_t)(b)) -#endif - #ifndef MAC64 # define MAC64(d, a, b) ((d) += MUL64(a, b)) #endif @@ -115,7 +116,9 @@ 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 << ((8 * sizeof(int)) - bits)) >> ((8 * sizeof(int)) - bits); + unsigned shift = 8 * sizeof(int) - bits; + union { unsigned u; int s; } v = { (unsigned) val << shift }; + return v.s >> shift; } #endif