diff --git a/libavcodec/dct.c b/libavcodec/dct.c
index 52f082d062..7581b3241f 100644
--- a/libavcodec/dct.c
+++ b/libavcodec/dct.c
@@ -30,7 +30,9 @@
 #include <math.h>
 #include <string.h>
 
+#include "libavutil/error.h"
 #include "libavutil/mathematics.h"
+#include "libavutil/mem.h"
 #include "dct.h"
 #include "dct32.h"
 
diff --git a/libavcodec/mpegaudiodec_common.c b/libavcodec/mpegaudiodec_common.c
index a963f6683a..ed2de8adbb 100644
--- a/libavcodec/mpegaudiodec_common.c
+++ b/libavcodec/mpegaudiodec_common.c
@@ -28,6 +28,7 @@
 #include <stdint.h>
 
 #include "libavutil/avassert.h"
+#include "libavutil/libm.h"
 #include "libavutil/thread.h"
 
 #include "mpegaudiodata.h"
diff --git a/libavcodec/mqcenc.c b/libavcodec/mqcenc.c
index 6d0368f827..a8c35c8db3 100644
--- a/libavcodec/mqcenc.c
+++ b/libavcodec/mqcenc.c
@@ -25,6 +25,8 @@
  * @author Kamil Nowosad
  */
 
+#include <string.h>
+
 #include "libavutil/avassert.h"
 #include "mqc.h"
 
diff --git a/libavcodec/put_bits.h b/libavcodec/put_bits.h
index 689c6b282e..4b4f977ad5 100644
--- a/libavcodec/put_bits.h
+++ b/libavcodec/put_bits.h
@@ -32,6 +32,7 @@
 #include "config.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/avassert.h"
+#include "libavutil/common.h"
 
 #if ARCH_X86_64
 // TODO: Benchmark and optionally enable on other 64-bit architectures.
diff --git a/libavcodec/rdft.c b/libavcodec/rdft.c
index 6ba7484238..8228eb247b 100644
--- a/libavcodec/rdft.c
+++ b/libavcodec/rdft.c
@@ -20,6 +20,7 @@
  */
 #include <stdlib.h>
 #include <math.h>
+#include "libavutil/error.h"
 #include "libavutil/mathematics.h"
 #include "rdft.h"
 
diff --git a/libavcodec/tests/fft.c b/libavcodec/tests/fft.c
index 9a5e5bd1c0..cc951b0dd4 100644
--- a/libavcodec/tests/fft.c
+++ b/libavcodec/tests/fft.c
@@ -38,6 +38,7 @@
 #include <string.h>
 
 #include "libavutil/cpu.h"
+#include "libavutil/error.h"
 #include "libavutil/lfg.h"
 #include "libavutil/log.h"
 #include "libavutil/mathematics.h"
diff --git a/libavcodec/x86/mdct15_init.c b/libavcodec/x86/mdct15_init.c
index 641bfd043f..31ce19d31c 100644
--- a/libavcodec/x86/mdct15_init.c
+++ b/libavcodec/x86/mdct15_init.c
@@ -20,6 +20,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <string.h>
+
 #include "config.h"
 
 #include "libavutil/attributes.h"
diff --git a/libavfilter/colorspacedsp.c b/libavfilter/colorspacedsp.c
index b8ba5c06e4..65ea74c584 100644
--- a/libavfilter/colorspacedsp.c
+++ b/libavfilter/colorspacedsp.c
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/common.h"
 #include "colorspacedsp.h"
 
 /*
diff --git a/libavfilter/window_func.h b/libavfilter/window_func.h
index b7c8c00270..bff1fa6041 100644
--- a/libavfilter/window_func.h
+++ b/libavfilter/window_func.h
@@ -24,6 +24,7 @@
 
 #include <math.h>
 #include "libavutil/avassert.h"
+#include "libavutil/common.h"
 
 enum WindowFunc     { WFUNC_RECT, WFUNC_HANNING, WFUNC_HAMMING, WFUNC_BLACKMAN,
                       WFUNC_BARTLETT, WFUNC_WELCH, WFUNC_FLATTOP,
diff --git a/libavutil/avassert.h b/libavutil/avassert.h
index 9abeadea4a..51e462bbae 100644
--- a/libavutil/avassert.h
+++ b/libavutil/avassert.h
@@ -28,8 +28,8 @@
 #define AVUTIL_AVASSERT_H
 
 #include <stdlib.h>
-#include "avutil.h"
 #include "log.h"
+#include "macros.h"
 
 /**
  * assert() equivalent, that is always enabled.
diff --git a/libavutil/mathematics.c b/libavutil/mathematics.c
index f4e541fa24..b878317d63 100644
--- a/libavutil/mathematics.c
+++ b/libavutil/mathematics.c
@@ -26,6 +26,7 @@
 #include <stdint.h>
 #include <limits.h>
 
+#include "avutil.h"
 #include "mathematics.h"
 #include "libavutil/intmath.h"
 #include "libavutil/common.h"
diff --git a/libavutil/slicethread.c b/libavutil/slicethread.c
index 867ce32238..ea1c9c8311 100644
--- a/libavutil/slicethread.c
+++ b/libavutil/slicethread.c
@@ -18,6 +18,7 @@
 
 #include <stdatomic.h>
 #include "cpu.h"
+#include "internal.h"
 #include "slicethread.h"
 #include "mem.h"
 #include "thread.h"
diff --git a/libavutil/tests/aes_ctr.c b/libavutil/tests/aes_ctr.c
index 9dbf0af8aa..486dae3348 100644
--- a/libavutil/tests/aes_ctr.c
+++ b/libavutil/tests/aes_ctr.c
@@ -16,6 +16,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <string.h>
+
 #include "libavutil/log.h"
 #include "libavutil/mem_internal.h"
 #include "libavutil/aes_ctr.h"
diff --git a/libavutil/tests/encryption_info.c b/libavutil/tests/encryption_info.c
index d489612b7d..55c668c6d5 100644
--- a/libavutil/tests/encryption_info.c
+++ b/libavutil/tests/encryption_info.c
@@ -22,6 +22,7 @@
 #include <string.h>
 
 #include "libavutil/avassert.h"
+#include "libavutil/mem.h"
 
 static const AVSubsampleEncryptionInfo test_subsamples[] = {{1, 2}, {3, 4}, {5, 6}, {7, 8}};
 static const size_t test_subsample_count = sizeof(test_subsamples) / sizeof(test_subsamples[0]);
