#ifndef AVUTIL_COMMON_H
#define AVUTIL_COMMON_H
-#include <ctype.h>
#include <errno.h>
#include <inttypes.h>
#include <limits.h>
#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"
/* 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
#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;\
}
/**
* 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