]> git.sesse.net Git - ffmpeg/blobdiff - libavutil/common.h
vdpau: deprecate old codec-specific pixel formats
[ffmpeg] / libavutil / common.h
index 433e8e490aae5cb3d57cc6ddf23b353f99bda4f5..caa6b1963b3425e2ac18c39d09bc7d4c19f7b216 100644 (file)
@@ -26,7 +26,6 @@
 #ifndef AVUTIL_COMMON_H
 #define AVUTIL_COMMON_H
 
-#include <ctype.h>
 #include <errno.h>
 #include <inttypes.h>
 #include <limits.h>
@@ -34,7 +33,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+
 #include "attributes.h"
+#include "version.h"
 #include "libavutil/avconfig.h"
 
 #if AV_HAVE_BIGENDIAN
 #define FFALIGN(x, a) (((x)+(a)-1)&~((a)-1))
 
 /* misc math functions */
-extern const uint8_t ff_log2_tab[256];
-
-extern const uint8_t av_reverse[256];
-
-static av_always_inline av_const int av_log2_c(unsigned int v)
-{
-    int n = 0;
-    if (v & 0xffff0000) {
-        v >>= 16;
-        n += 16;
-    }
-    if (v & 0xff00) {
-        v >>= 8;
-        n += 8;
-    }
-    n += ff_log2_tab[v];
 
-    return n;
-}
-
-static av_always_inline av_const int av_log2_16bit_c(unsigned int v)
-{
-    int n = 0;
-    if (v & 0xff00) {
-        v >>= 8;
-        n += 8;
-    }
-    n += ff_log2_tab[v];
-
-    return n;
-}
+#if FF_API_AV_REVERSE
+extern attribute_deprecated const uint8_t av_reverse[256];
+#endif
 
 #ifdef HAVE_AV_CONFIG_H
 #   include "config.h"
@@ -100,6 +74,14 @@ static av_always_inline av_const int av_log2_16bit_c(unsigned int v)
 /* Pull in unguarded fallback defines at the end of this file. */
 #include "common.h"
 
+#ifndef av_log2
+av_const int av_log2(unsigned v);
+#endif
+
+#ifndef av_log2_16bit
+av_const int av_log2_16bit(unsigned v);
+#endif
+
 /**
  * Clip a signed integer value into the amin-amax range.
  * @param a value to clip
@@ -269,16 +251,17 @@ static av_always_inline av_const int av_popcount64_c(uint64_t x)
 #define GET_UTF8(val, GET_BYTE, ERROR)\
     val= GET_BYTE;\
     {\
-        int ones= 7 - av_log2(val ^ 255);\
-        if(ones==1)\
+        uint32_t top = (val & 128) >> 1;\
+        if ((val & 0xc0) == 0x80)\
             ERROR\
-        val&= 127>>ones;\
-        while(--ones > 0){\
+        while (val & top) {\
             int tmp= GET_BYTE - 128;\
             if(tmp>>6)\
                 ERROR\
             val= (val<<6) + tmp;\
+            top <<= 5;\
         }\
+        val &= (top << 1) - 1;\
     }
 
 /**
@@ -381,12 +364,6 @@ static av_always_inline av_const int av_popcount64_c(uint64_t x)
  * to ensure they are immediately available in intmath.h.
  */
 
-#ifndef av_log2
-#   define av_log2       av_log2_c
-#endif
-#ifndef av_log2_16bit
-#   define av_log2_16bit av_log2_16bit_c
-#endif
 #ifndef av_ceil_log2
 #   define av_ceil_log2     av_ceil_log2_c
 #endif