Imported Upstream version 6.1
[platform/upstream/ffmpeg.git] / libavcodec / mathops.h
index 1c35664..a1dc323 100644 (file)
 
 #include <stdint.h>
 
+#include "libavutil/attributes_internal.h"
 #include "libavutil/common.h"
-#include "libavutil/reverse.h"
 #include "config.h"
 
 #define MAX_NEG_CROP 1024
 
 extern const uint32_t ff_inverse[257];
+extern const uint8_t ff_log2_run[41];
 extern const uint8_t ff_sqrt_tab[256];
-extern const uint8_t ff_crop_tab[256 + 2 * MAX_NEG_CROP];
+extern const uint8_t attribute_visibility_hidden ff_crop_tab[256 + 2 * MAX_NEG_CROP];
 extern const uint8_t ff_zigzag_direct[64];
 extern const uint8_t ff_zigzag_scan[16+1];
 
@@ -126,6 +127,8 @@ static inline av_const int median4(int a, int b, int c, int d)
 }
 #endif
 
+#define FF_SIGNBIT(x) ((x) >> CHAR_BIT * sizeof(x) - 1)
+
 #ifndef sign_extend
 static inline av_const int sign_extend(int val, unsigned bits)
 {
@@ -135,6 +138,15 @@ static inline av_const int sign_extend(int val, unsigned bits)
 }
 #endif
 
+#ifndef sign_extend64
+static inline av_const int64_t sign_extend64(int64_t val, unsigned bits)
+{
+    unsigned shift = 8 * sizeof(int64_t) - bits;
+    union { uint64_t u; int64_t s; } v = { (uint64_t) val << shift };
+    return v.s >> shift;
+}
+#endif
+
 #ifndef zero_extend
 static inline av_const unsigned zero_extend(unsigned val, unsigned bits)
 {
@@ -240,12 +252,4 @@ static inline int8_t ff_u8_to_s8(uint8_t a)
     return b.s8;
 }
 
-static av_always_inline uint32_t bitswap_32(uint32_t x)
-{
-    return (uint32_t)ff_reverse[ x        & 0xFF] << 24 |
-           (uint32_t)ff_reverse[(x >> 8)  & 0xFF] << 16 |
-           (uint32_t)ff_reverse[(x >> 16) & 0xFF] << 8  |
-           (uint32_t)ff_reverse[ x >> 24];
-}
-
 #endif /* AVCODEC_MATHOPS_H */