History

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.

Andreas Rheinhardt committed 5 years ago

Commit bd50e711 parent a5daadd1 file · +66 −74Browse files

Unified · Split

libavutil/common.h+66−74
@@ -115,8 +115,72 @@ · 114 unmodified lines
115115 # include "intmath.h"
116116 #endif
117117
118−/* Pull in unguarded fallback defines at the end of this file. */
119−#include "common.h"
118+#ifndef av_ceil_log2
119+# define av_ceil_log2 av_ceil_log2_c
120+#endif
121+#ifndef av_clip
122+# define av_clip av_clip_c
123+#endif
124+#ifndef av_clip64
125+# define av_clip64 av_clip64_c
126+#endif
127+#ifndef av_clip_uint8
128+# define av_clip_uint8 av_clip_uint8_c
129+#endif
130+#ifndef av_clip_int8
131+# define av_clip_int8 av_clip_int8_c
132+#endif
133+#ifndef av_clip_uint16
134+# define av_clip_uint16 av_clip_uint16_c
135+#endif
136+#ifndef av_clip_int16
137+# define av_clip_int16 av_clip_int16_c
138+#endif
139+#ifndef av_clipl_int32
140+# define av_clipl_int32 av_clipl_int32_c
141+#endif
142+#ifndef av_clip_intp2
143+# define av_clip_intp2 av_clip_intp2_c
144+#endif
145+#ifndef av_clip_uintp2
146+# define av_clip_uintp2 av_clip_uintp2_c
147+#endif
148+#ifndef av_mod_uintp2
149+# define av_mod_uintp2 av_mod_uintp2_c
150+#endif
151+#ifndef av_sat_add32
152+# define av_sat_add32 av_sat_add32_c
153+#endif
154+#ifndef av_sat_dadd32
155+# define av_sat_dadd32 av_sat_dadd32_c
156+#endif
157+#ifndef av_sat_sub32
158+# define av_sat_sub32 av_sat_sub32_c
159+#endif
160+#ifndef av_sat_dsub32
161+# define av_sat_dsub32 av_sat_dsub32_c
162+#endif
163+#ifndef av_sat_add64
164+# define av_sat_add64 av_sat_add64_c
165+#endif
166+#ifndef av_sat_sub64
167+# define av_sat_sub64 av_sat_sub64_c
168+#endif
169+#ifndef av_clipf
170+# define av_clipf av_clipf_c
171+#endif
172+#ifndef av_clipd
173+# define av_clipd av_clipd_c
174+#endif
175+#ifndef av_popcount
176+# define av_popcount av_popcount_c
177+#endif
178+#ifndef av_popcount64
179+# define av_popcount64 av_popcount64_c
180+#endif
181+#ifndef av_parity
182+# define av_parity av_parity_c
183+#endif
120184
121185 #ifndef av_log2
122186 av_const int av_log2(unsigned v);
@@ -542,75 +606,3 @@ static av_always_inline av_const int av_parity_c(uint32_t v) · 419 unmodified lines
542606 #endif /* HAVE_AV_CONFIG_H */
543607
544608 #endif /* AVUTIL_COMMON_H */
545−
546−/*
547− * The following definitions are outside the multiple inclusion guard
548− * to ensure they are immediately available in intmath.h.
549− */
550−
551−#ifndef av_ceil_log2
552−# define av_ceil_log2 av_ceil_log2_c
553−#endif
554−#ifndef av_clip
555−# define av_clip av_clip_c
556−#endif
557−#ifndef av_clip64
558−# define av_clip64 av_clip64_c
559−#endif
560−#ifndef av_clip_uint8
561−# define av_clip_uint8 av_clip_uint8_c
562−#endif
563−#ifndef av_clip_int8
564−# define av_clip_int8 av_clip_int8_c
565−#endif
566−#ifndef av_clip_uint16
567−# define av_clip_uint16 av_clip_uint16_c
568−#endif
569−#ifndef av_clip_int16
570−# define av_clip_int16 av_clip_int16_c
571−#endif
572−#ifndef av_clipl_int32
573−# define av_clipl_int32 av_clipl_int32_c
574−#endif
575−#ifndef av_clip_intp2
576−# define av_clip_intp2 av_clip_intp2_c
577−#endif
578−#ifndef av_clip_uintp2
579−# define av_clip_uintp2 av_clip_uintp2_c
580−#endif
581−#ifndef av_mod_uintp2
582−# define av_mod_uintp2 av_mod_uintp2_c
583−#endif
584−#ifndef av_sat_add32
585−# define av_sat_add32 av_sat_add32_c
586−#endif
587−#ifndef av_sat_dadd32
588−# define av_sat_dadd32 av_sat_dadd32_c
589−#endif
590−#ifndef av_sat_sub32
591−# define av_sat_sub32 av_sat_sub32_c
592−#endif
593−#ifndef av_sat_dsub32
594−# define av_sat_dsub32 av_sat_dsub32_c
595−#endif
596−#ifndef av_sat_add64
597−# define av_sat_add64 av_sat_add64_c
598−#endif
599−#ifndef av_sat_sub64
600−# define av_sat_sub64 av_sat_sub64_c
601−#endif
602−#ifndef av_clipf
603−# define av_clipf av_clipf_c
604−#endif
605−#ifndef av_clipd
606−# define av_clipd av_clipd_c
607−#endif
608−#ifndef av_popcount
609−# define av_popcount av_popcount_c
610−#endif
611−#ifndef av_popcount64
612−# define av_popcount64 av_popcount64_c
613−#endif
614−#ifndef av_parity
615−# define av_parity av_parity_c
616−#endif

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t