Index: patched-ffmpeg-mt/libavutil/common.h |
=================================================================== |
--- patched-ffmpeg-mt/libavutil/common.h (revision 41250) |
+++ patched-ffmpeg-mt/libavutil/common.h (working copy) |
@@ -34,93 +34,8 @@ |
#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
+#include "attributes.h" |
-#ifdef HAVE_AV_CONFIG_H |
-#include "config.h" |
-#endif |
- |
-#ifdef __GNUC__ |
-# define AV_GCC_VERSION_AT_LEAST(x,y) (__GNUC__ > x || __GNUC__ == x && __GNUC_MINOR__ >= y) |
-#else |
-# define AV_GCC_VERSION_AT_LEAST(x,y) 0 |
-#endif |
- |
-#ifndef av_always_inline |
-#if AV_GCC_VERSION_AT_LEAST(3,1) |
-# define av_always_inline __attribute__((always_inline)) inline |
-#else |
-# define av_always_inline inline |
-#endif |
-#endif |
- |
-#ifndef av_noinline |
-#if AV_GCC_VERSION_AT_LEAST(3,1) |
-# define av_noinline __attribute__((noinline)) |
-#else |
-# define av_noinline |
-#endif |
-#endif |
- |
-#ifndef av_pure |
-#if AV_GCC_VERSION_AT_LEAST(3,1) |
-# define av_pure __attribute__((pure)) |
-#else |
-# define av_pure |
-#endif |
-#endif |
- |
-#ifndef av_const |
-#if AV_GCC_VERSION_AT_LEAST(2,6) |
-# define av_const __attribute__((const)) |
-#else |
-# define av_const |
-#endif |
-#endif |
- |
-#ifndef av_cold |
-#if (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(4,3) |
-# define av_cold __attribute__((cold)) |
-#else |
-# define av_cold |
-#endif |
-#endif |
- |
-#ifndef av_flatten |
-#if (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(4,1) |
-# define av_flatten __attribute__((flatten)) |
-#else |
-# define av_flatten |
-#endif |
-#endif |
- |
-#ifndef attribute_deprecated |
-#if AV_GCC_VERSION_AT_LEAST(3,1) |
-# define attribute_deprecated __attribute__((deprecated)) |
-#else |
-# define attribute_deprecated |
-#endif |
-#endif |
- |
-#ifndef av_unused |
-#if defined(__GNUC__) |
-# define av_unused __attribute__((unused)) |
-#else |
-# define av_unused |
-#endif |
-#endif |
- |
-#ifndef av_uninit |
-#if defined(__GNUC__) && !defined(__ICC) |
-# define av_uninit(x) x=x |
-#else |
-# define av_uninit(x) x |
-#endif |
-#endif |
- |
-#ifdef HAVE_AV_CONFIG_H |
-# include "intmath.h" |
-#endif |
- |
//rounded division & shift |
#define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b)) |
/* assume b>0 */ |
@@ -142,8 +57,7 @@ |
extern const uint8_t av_reverse[256]; |
-#ifndef av_log2 |
-static inline av_const int av_log2(unsigned int v) |
+static inline av_const int av_log2_c(unsigned int v) |
{ |
int n = 0; |
if (v & 0xffff0000) { |
@@ -158,10 +72,8 @@ |
return n; |
} |
-#endif |
-#ifndef av_log2_16bit |
-static inline av_const int av_log2_16bit(unsigned int v) |
+static inline av_const int av_log2_16bit_c(unsigned int v) |
{ |
int n = 0; |
if (v & 0xff00) { |
@@ -172,8 +84,19 @@ |
return n; |
} |
+ |
+#ifdef HAVE_AV_CONFIG_H |
+# include "config.h" |
+# include "intmath.h" |
#endif |
+#ifndef av_log2 |
+# define av_log2 av_log2_c |
+#endif |
+#ifndef av_log2_16bit |
+# define av_log2_16bit av_log2_16bit_c |
+#endif |
+ |
/** |
* Clips a signed integer value into the amin-amax range. |
* @param a value to clip |
@@ -335,6 +258,36 @@ |
}\ |
} |
+/*! |
+ * \def PUT_UTF16(val, tmp, PUT_16BIT) |
+ * Converts a 32-bit Unicode character to its UTF-16 encoded form (2 or 4 bytes). |
+ * \param val is an input-only argument and should be of type uint32_t. It holds |
+ * a UCS-4 encoded Unicode character that is to be converted to UTF-16. If |
+ * val is given as a function it is executed only once. |
+ * \param tmp is a temporary variable and should be of type uint16_t. It |
+ * represents an intermediate value during conversion that is to be |
+ * output by PUT_16BIT. |
+ * \param PUT_16BIT writes the converted UTF-16 data to any proper destination |
+ * in desired endianness. It could be a function or a statement, and uses tmp |
+ * as the input byte. For example, PUT_BYTE could be "*output++ = tmp;" |
+ * PUT_BYTE will be executed 1 or 2 times depending on input character. |
+ */ |
+#define PUT_UTF16(val, tmp, PUT_16BIT)\ |
+ {\ |
+ uint32_t in = val;\ |
+ if (in < 0x10000) {\ |
+ tmp = in;\ |
+ PUT_16BIT\ |
+ } else {\ |
+ tmp = 0xD800 | ((in - 0x10000) >> 10);\ |
+ PUT_16BIT\ |
+ tmp = 0xDC00 | ((in - 0x10000) & 0x3FF);\ |
+ PUT_16BIT\ |
+ }\ |
+ }\ |
+ |
+ |
+ |
#include "mem.h" |
#ifdef HAVE_AV_CONFIG_H |