summaryrefslogtreecommitdiff
path: root/libavutil/common.h
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2021-02-04 14:57:30 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2021-02-11 09:07:10 +0100
commitbd50e715a95ca58e10ed79e2d4bf796467339460 (patch)
tree1bcd02ab15c8ab0ced019958cf9033a6b85626df /libavutil/common.h
parenta5daadd3a9352462dde1fbccac3ae7a0bd037172 (diff)
avutil/common: Move everything inside inclusion guards
libavutil/common.h is a public header that provides generic math functions whereas libavutil/intmath.h is a private header that contains plattform-specific optimized versions of said math functions. common.h includes intmath.h (when building the FFmpeg libraries) so that the optimized versions are used for them. This interdependency sometimes causes trouble: intmath.h once contained an inlined ff_sqrt function that relied upon av_log2_16bit. In case there was no optimized logarithm available on this plattform, intmath.h needed to include common.h to get the generic implementation and this has been done after the optimized versions (if any) have been provided so that common.h used the optimized versions; it also needed to be done before ff_sqrt. Yet when intmath.h was included from common.h and if an ordinary inclusion guard was used by common.h, the #include "common.h" in intmath.h was a no-op and therefore av_log2_16bit was still unknown at the end of intmath.h (and also in ff_sqrt) if no optimized version was available. Before a955b5965825631986ba854d007d4e934e466c7d this was solved by duplicating the #ifndef av_log2_16bit check after the inclusion of common.h in intmath.h; said commit instead moved these checks to the end of common.h, outside the inclusion guards and made common.h include itself to get these unguarded defines. This is still the current state of affairs. Yet this is unnecessary since 9734b8ba56d05e970c353dfd5baafa43fdb08024 as said commit removed ff_sqrt as well as the #include "common.h" from intmath.h. Therefore this commit moves everything inside the inclusion guards and makes common.h not include itself. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavutil/common.h')
-rw-r--r--libavutil/common.h140
1 files changed, 66 insertions, 74 deletions
diff --git a/libavutil/common.h b/libavutil/common.h
index 5ccbed90b1..aee353d399 100644
--- a/libavutil/common.h
+++ b/libavutil/common.h
@@ -115,8 +115,72 @@
# include "intmath.h"
#endif
-/* Pull in unguarded fallback defines at the end of this file. */
-#include "common.h"
+#ifndef av_ceil_log2
+# define av_ceil_log2 av_ceil_log2_c
+#endif
+#ifndef av_clip
+# define av_clip av_clip_c
+#endif
+#ifndef av_clip64
+# define av_clip64 av_clip64_c
+#endif
+#ifndef av_clip_uint8
+# define av_clip_uint8 av_clip_uint8_c
+#endif
+#ifndef av_clip_int8
+# define av_clip_int8 av_clip_int8_c
+#endif
+#ifndef av_clip_uint16
+# define av_clip_uint16 av_clip_uint16_c
+#endif
+#ifndef av_clip_int16
+# define av_clip_int16 av_clip_int16_c
+#endif
+#ifndef av_clipl_int32
+# define av_clipl_int32 av_clipl_int32_c
+#endif
+#ifndef av_clip_intp2
+# define av_clip_intp2 av_clip_intp2_c
+#endif
+#ifndef av_clip_uintp2
+# define av_clip_uintp2 av_clip_uintp2_c
+#endif
+#ifndef av_mod_uintp2
+# define av_mod_uintp2 av_mod_uintp2_c
+#endif
+#ifndef av_sat_add32
+# define av_sat_add32 av_sat_add32_c
+#endif
+#ifndef av_sat_dadd32
+# define av_sat_dadd32 av_sat_dadd32_c
+#endif
+#ifndef av_sat_sub32
+# define av_sat_sub32 av_sat_sub32_c
+#endif
+#ifndef av_sat_dsub32
+# define av_sat_dsub32 av_sat_dsub32_c
+#endif
+#ifndef av_sat_add64
+# define av_sat_add64 av_sat_add64_c
+#endif
+#ifndef av_sat_sub64
+# define av_sat_sub64 av_sat_sub64_c
+#endif
+#ifndef av_clipf
+# define av_clipf av_clipf_c
+#endif
+#ifndef av_clipd
+# define av_clipd av_clipd_c
+#endif
+#ifndef av_popcount
+# define av_popcount av_popcount_c
+#endif
+#ifndef av_popcount64
+# define av_popcount64 av_popcount64_c
+#endif
+#ifndef av_parity
+# define av_parity av_parity_c
+#endif
#ifndef av_log2
av_const int av_log2(unsigned v);
@@ -542,75 +606,3 @@ static av_always_inline av_const int av_parity_c(uint32_t v)
#endif /* HAVE_AV_CONFIG_H */
#endif /* AVUTIL_COMMON_H */
-
-/*
- * The following definitions are outside the multiple inclusion guard
- * to ensure they are immediately available in intmath.h.
- */
-
-#ifndef av_ceil_log2
-# define av_ceil_log2 av_ceil_log2_c
-#endif
-#ifndef av_clip
-# define av_clip av_clip_c
-#endif
-#ifndef av_clip64
-# define av_clip64 av_clip64_c
-#endif
-#ifndef av_clip_uint8
-# define av_clip_uint8 av_clip_uint8_c
-#endif
-#ifndef av_clip_int8
-# define av_clip_int8 av_clip_int8_c
-#endif
-#ifndef av_clip_uint16
-# define av_clip_uint16 av_clip_uint16_c
-#endif
-#ifndef av_clip_int16
-# define av_clip_int16 av_clip_int16_c
-#endif
-#ifndef av_clipl_int32
-# define av_clipl_int32 av_clipl_int32_c
-#endif
-#ifndef av_clip_intp2
-# define av_clip_intp2 av_clip_intp2_c
-#endif
-#ifndef av_clip_uintp2
-# define av_clip_uintp2 av_clip_uintp2_c
-#endif
-#ifndef av_mod_uintp2
-# define av_mod_uintp2 av_mod_uintp2_c
-#endif
-#ifndef av_sat_add32
-# define av_sat_add32 av_sat_add32_c
-#endif
-#ifndef av_sat_dadd32
-# define av_sat_dadd32 av_sat_dadd32_c
-#endif
-#ifndef av_sat_sub32
-# define av_sat_sub32 av_sat_sub32_c
-#endif
-#ifndef av_sat_dsub32
-# define av_sat_dsub32 av_sat_dsub32_c
-#endif
-#ifndef av_sat_add64
-# define av_sat_add64 av_sat_add64_c
-#endif
-#ifndef av_sat_sub64
-# define av_sat_sub64 av_sat_sub64_c
-#endif
-#ifndef av_clipf
-# define av_clipf av_clipf_c
-#endif
-#ifndef av_clipd
-# define av_clipd av_clipd_c
-#endif
-#ifndef av_popcount
-# define av_popcount av_popcount_c
-#endif
-#ifndef av_popcount64
-# define av_popcount64 av_popcount64_c
-#endif
-#ifndef av_parity
-# define av_parity av_parity_c
-#endif