]> git.sesse.net Git - ffmpeg/blobdiff - libavutil/common.h
new avm2 (flash 9) muxer, patch by Paul Egan, paulegan at mail dot com
[ffmpeg] / libavutil / common.h
index b9fd06d94b31d7e62309e1768978d17978e57661..f2dd83b3236c227d4aa992d3170e27dcd8e81f18 100644 (file)
@@ -23,8 +23,8 @@
  * common internal and external api header.
  */
 
-#ifndef COMMON_H
-#define COMMON_H
+#ifndef FFMPEG_COMMON_H
+#define FFMPEG_COMMON_H
 
 #include <inttypes.h>
 
 #ifndef av_always_inline
 #if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
 #    define av_always_inline __attribute__((always_inline)) inline
-#    define av_noinline __attribute__((noinline))
 #else
 #    define av_always_inline inline
+#endif
+#endif
+
+#ifndef av_noinline
+#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
+#    define av_noinline __attribute__((noinline))
+#else
 #    define av_noinline
 #endif
 #endif
@@ -186,6 +192,17 @@ static inline uint8_t av_clip_uint8(int a)
     else          return a;
 }
 
+/**
+ * clip a signed integer value into the -32768,32767 range
+ * @param a value to clip
+ * @return clipped value
+ */
+static inline int16_t av_clip_int16(int a)
+{
+    if ((a+32768) & ~65535) return (a>>31) ^ 32767;
+    else                    return a;
+}
+
 /* math */
 int64_t ff_gcd(int64_t a, int64_t b);
 
@@ -268,6 +285,7 @@ static inline int ff_get_fourcc(const char *s){
     }
 
 #if defined(ARCH_X86) || defined(ARCH_POWERPC) || defined(ARCH_BFIN)
+#define AV_READ_TIME read_time
 #if defined(ARCH_X86_64)
 static inline uint64_t read_time(void)
 {
@@ -319,13 +337,17 @@ static inline uint64_t read_time(void)
      return (((uint64_t)tbu)<<32) | (uint64_t)tbl;
 }
 #endif
+#elif defined(HAVE_GETHRTIME)
+#define AV_READ_TIME gethrtime
+#endif
 
+#ifdef AV_READ_TIME
 #define START_TIMER \
 uint64_t tend;\
-uint64_t tstart= read_time();\
+uint64_t tstart= AV_READ_TIME();\
 
 #define STOP_TIMER(id) \
-tend= read_time();\
+tend= AV_READ_TIME();\
 {\
   static uint64_t tsum=0;\
   static int tcount=0;\
@@ -344,4 +366,4 @@ tend= read_time();\
 #define STOP_TIMER(id) {}
 #endif
 
-#endif /* COMMON_H */
+#endif /* FFMPEG_COMMON_H */