diff options
-rw-r--r-- | libavcodec/mathops.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/libavcodec/mathops.h b/libavcodec/mathops.h index ec76eaae29..45b1ecf1ae 100644 --- a/libavcodec/mathops.h +++ b/libavcodec/mathops.h @@ -116,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 |