]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/mathops.h
4xm: prevent overflow during block alignment calculation
[ffmpeg] / libavcodec / mathops.h
index 5168dc2ce00f4eb8c711a8053b6fd007c50d6151..2cc8963a98c5a1509c7c186be90794ed1e54b334 100644 (file)
@@ -25,6 +25,7 @@
 #include <stdint.h>
 
 #include "libavutil/common.h"
+#include "libavutil/reverse.h"
 #include "config.h"
 
 #define MAX_NEG_CROP 1024
@@ -249,4 +250,12 @@ 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 */