diff --git a/fftools/ffmpeg_qsv.c b/fftools/ffmpeg_qsv.c
index 960c88b69d..7bd999d310 100644
--- a/fftools/ffmpeg_qsv.c
+++ b/fftools/ffmpeg_qsv.c
@@ -22,7 +22,6 @@
 #include "libavutil/dict.h"
 #include "libavutil/hwcontext.h"
 #include "libavutil/hwcontext_qsv.h"
-#include "libavutil/mem.h"
 #include "libavutil/opt.h"
 #include "libavcodec/qsv.h"
 
diff --git a/libavcodec/aactab.c b/libavcodec/aactab.c
index fa5420fec6..0553f41a61 100644
--- a/libavcodec/aactab.c
+++ b/libavcodec/aactab.c
@@ -28,7 +28,6 @@
  */
 
 #include "config.h"
-#include "libavutil/mem.h"
 #include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
 #include "aac.h"
diff --git a/libavcodec/arbc.c b/libavcodec/arbc.c
index 06970f140b..20e9581ccd 100644
--- a/libavcodec/arbc.c
+++ b/libavcodec/arbc.c
@@ -26,7 +26,6 @@
 #include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem.h"
 
 #include "avcodec.h"
 #include "bytestream.h"
diff --git a/libavcodec/argo.c b/libavcodec/argo.c
index 6b4d449935..5cd591329e 100644
--- a/libavcodec/argo.c
+++ b/libavcodec/argo.c
@@ -26,7 +26,6 @@
 #include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem.h"
 
 #include "avcodec.h"
 #include "bytestream.h"
diff --git a/libavcodec/dcadsp.c b/libavcodec/dcadsp.c
index faf244c8ad..b2ef8b3e87 100644
--- a/libavcodec/dcadsp.c
+++ b/libavcodec/dcadsp.c
@@ -18,7 +18,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavutil/mem.h"
 #include "libavutil/mem_internal.h"
 
 #include "dcadsp.h"
diff --git a/libavcodec/dss_sp.c b/libavcodec/dss_sp.c
index 568757d212..6e1a78b6b4 100644
--- a/libavcodec/dss_sp.c
+++ b/libavcodec/dss_sp.c
@@ -21,7 +21,6 @@
 
 #include "libavutil/channel_layout.h"
 #include "libavutil/common.h"
-#include "libavutil/mem.h"
 #include "libavutil/mem_internal.h"
 #include "libavutil/opt.h"
 
diff --git a/libavcodec/dvbsub_parser.c b/libavcodec/dvbsub_parser.c
index b7a3d6154c..a38ac6693b 100644
--- a/libavcodec/dvbsub_parser.c
+++ b/libavcodec/dvbsub_parser.c
@@ -23,7 +23,6 @@
 #include <string.h>
 
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem.h"
 
 #include "avcodec.h"
 #include "internal.h"
diff --git a/libavcodec/h264_redundant_pps_bsf.c b/libavcodec/h264_redundant_pps_bsf.c
index 6ba40291d5..fb678beef3 100644
--- a/libavcodec/h264_redundant_pps_bsf.c
+++ b/libavcodec/h264_redundant_pps_bsf.c
@@ -19,7 +19,6 @@
 #include <string.h>
 
 #include "libavutil/common.h"
-#include "libavutil/mem.h"
 
 #include "bsf.h"
 #include "bsf_internal.h"
diff --git a/libavcodec/libvo-amrwbenc.c b/libavcodec/libvo-amrwbenc.c
index 77d0ccef15..b57ab87971 100644
--- a/libavcodec/libvo-amrwbenc.c
+++ b/libavcodec/libvo-amrwbenc.c
@@ -25,7 +25,6 @@
 
 #include "libavutil/avstring.h"
 #include "libavutil/internal.h"
-#include "libavutil/mem.h"
 #include "libavutil/opt.h"
 #include "avcodec.h"
 #include "internal.h"
diff --git a/libavcodec/mpegaudiodsp_template.c b/libavcodec/mpegaudiodsp_template.c
index 97317967a2..fbbd94e486 100644
--- a/libavcodec/mpegaudiodsp_template.c
+++ b/libavcodec/mpegaudiodsp_template.c
@@ -21,7 +21,6 @@
 #include <stdint.h>
 
 #include "libavutil/attributes.h"
-#include "libavutil/mem.h"
 #include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
 
diff --git a/libavcodec/opustab.h b/libavcodec/opustab.h
index 4525837942..16011db758 100644
--- a/libavcodec/opustab.h
+++ b/libavcodec/opustab.h
@@ -23,8 +23,6 @@
 #ifndef AVCODEC_OPUSTAB_H
 #define AVCODEC_OPUSTAB_H
 
-#include "libavutil/mem.h"
-
 #include <stdint.h>
 
 extern const uint8_t  ff_celt_band_end[];
diff --git a/libavcodec/rl.c b/libavcodec/rl.c
index 93153ff723..fab96d63a1 100644
--- a/libavcodec/rl.c
+++ b/libavcodec/rl.c
@@ -21,7 +21,6 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/avassert.h"
-#include "libavutil/mem.h"
 
 #include "rl.h"
 
diff --git a/libavcodec/snappy.c b/libavcodec/snappy.c
index f5c4c6578b..91dd84fad4 100644
--- a/libavcodec/snappy.c
+++ b/libavcodec/snappy.c
@@ -19,8 +19,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavutil/mem.h"
-
 #include "bytestream.h"
 #include "snappy.h"
 
diff --git a/libavcodec/truemotion2rt.c b/libavcodec/truemotion2rt.c
index e3ab998fda..af88bf1cc2 100644
--- a/libavcodec/truemotion2rt.c
+++ b/libavcodec/truemotion2rt.c
@@ -25,7 +25,6 @@
 #include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem.h"
 
 #define BITSTREAM_READER_LE
 #include "avcodec.h"
diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c
index 044d35338b..16cab650fe 100644
--- a/libavcodec/v210dec.c
+++ b/libavcodec/v210dec.c
@@ -26,7 +26,6 @@
 #include "v210dec.h"
 #include "libavutil/bswap.h"
 #include "libavutil/internal.h"
-#include "libavutil/mem.h"
 #include "libavutil/intreadwrite.h"
 #include "thread.h"
 
diff --git a/libavcodec/v210x.c b/libavcodec/v210x.c
index f6a453aabf..e92e0b33b8 100644
--- a/libavcodec/v210x.c
+++ b/libavcodec/v210x.c
@@ -22,7 +22,6 @@
 #include "internal.h"
 #include "libavutil/bswap.h"
 #include "libavutil/internal.h"
-#include "libavutil/mem.h"
 
 static av_cold int decode_init(AVCodecContext *avctx)
 {
diff --git a/libavcodec/x86/ac3dsp_init.c b/libavcodec/x86/ac3dsp_init.c
index 2ae762af46..923c3e0a31 100644
--- a/libavcodec/x86/ac3dsp_init.c
+++ b/libavcodec/x86/ac3dsp_init.c
@@ -20,7 +20,6 @@
  */
 
 #include "libavutil/attributes.h"
-#include "libavutil/mem.h"
 #include "libavutil/x86/asm.h"
 #include "libavutil/x86/cpu.h"
 #include "libavcodec/ac3.h"
diff --git a/libavcodec/x86/lpc.c b/libavcodec/x86/lpc.c
index 6c72e21bac..544083bd37 100644
--- a/libavcodec/x86/lpc.c
+++ b/libavcodec/x86/lpc.c
@@ -21,7 +21,7 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
-#include "libavutil/mem.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/x86/asm.h"
 #include "libavutil/x86/cpu.h"
 #include "libavcodec/lpc.h"
diff --git a/libavcodec/x86/rv40dsp_init.c b/libavcodec/x86/rv40dsp_init.c
index 79a617ffbe..7a05ab14ad 100644
--- a/libavcodec/x86/rv40dsp_init.c
+++ b/libavcodec/x86/rv40dsp_init.c
@@ -28,7 +28,6 @@
 
 #include "libavcodec/rv34dsp.h"
 #include "libavutil/attributes.h"
-#include "libavutil/mem.h"
 #include "libavutil/mem_internal.h"
 #include "libavutil/x86/cpu.h"
 #include "hpeldsp.h"
diff --git a/libavcodec/x86/vc1dsp_mmx.c b/libavcodec/x86/vc1dsp_mmx.c
index 6541dda429..a57930e46c 100644
--- a/libavcodec/x86/vc1dsp_mmx.c
+++ b/libavcodec/x86/vc1dsp_mmx.c
@@ -25,7 +25,6 @@
  */
 
 #include "libavutil/cpu.h"
-#include "libavutil/mem.h"
 #include "libavutil/mem_internal.h"
 #include "libavutil/x86/asm.h"
 #include "libavutil/x86/cpu.h"
diff --git a/libavcodec/x86/videodsp_init.c b/libavcodec/x86/videodsp_init.c
index eeebb41547..961424aa13 100644
--- a/libavcodec/x86/videodsp_init.c
+++ b/libavcodec/x86/videodsp_init.c
@@ -24,7 +24,6 @@
 #include "libavutil/avassert.h"
 #include "libavutil/common.h"
 #include "libavutil/cpu.h"
-#include "libavutil/mem.h"
 #include "libavutil/x86/asm.h"
 #include "libavutil/x86/cpu.h"
 #include "libavcodec/videodsp.h"
diff --git a/libavcodec/x86/vp8dsp_init.c b/libavcodec/x86/vp8dsp_init.c
index dffa7a2418..289f1d5115 100644
--- a/libavcodec/x86/vp8dsp_init.c
+++ b/libavcodec/x86/vp8dsp_init.c
@@ -22,7 +22,6 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
-#include "libavutil/mem.h"
 #include "libavutil/mem_internal.h"
 #include "libavutil/x86/cpu.h"
 #include "libavcodec/vp8dsp.h"
diff --git a/libavcodec/x86/vp9dsp_init.c b/libavcodec/x86/vp9dsp_init.c
index 837cce8508..8d11dbc348 100644
--- a/libavcodec/x86/vp9dsp_init.c
+++ b/libavcodec/x86/vp9dsp_init.c
@@ -22,7 +22,6 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
-#include "libavutil/mem.h"
 #include "libavutil/x86/cpu.h"
 #include "libavcodec/vp9dsp.h"
 #include "libavcodec/x86/vp9dsp_init.h"
diff --git a/libavcodec/x86/vp9dsp_init_16bpp_template.c b/libavcodec/x86/vp9dsp_init_16bpp_template.c
index b56afc7f50..f93ea2468e 100644
--- a/libavcodec/x86/vp9dsp_init_16bpp_template.c
+++ b/libavcodec/x86/vp9dsp_init_16bpp_template.c
@@ -22,7 +22,6 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
-#include "libavutil/mem.h"
 #include "libavutil/x86/cpu.h"
 #include "libavcodec/vp9dsp.h"
 #include "libavcodec/x86/vp9dsp_init.h"
diff --git a/libavdevice/fbdev_dec.c b/libavdevice/fbdev_dec.c
index 6a51816868..f0abaf4eca 100644
--- a/libavdevice/fbdev_dec.c
+++ b/libavdevice/fbdev_dec.c
@@ -36,7 +36,6 @@
 
 #include "libavutil/internal.h"
 #include "libavutil/log.h"
-#include "libavutil/mem.h"
 #include "libavutil/opt.h"
 #include "libavutil/time.h"
 #include "libavutil/parseutils.h"
diff --git a/libavdevice/fbdev_enc.c b/libavdevice/fbdev_enc.c
index 4191596825..1f1885cf8e 100644
--- a/libavdevice/fbdev_enc.c
+++ b/libavdevice/fbdev_enc.c
@@ -25,7 +25,6 @@
 #include <linux/fb.h>
 #include "libavutil/pixdesc.h"
 #include "libavutil/log.h"
-#include "libavutil/mem.h"
 #include "libavutil/opt.h"
 #include "libavformat/avformat.h"
 #include "fbdev_common.h"
diff --git a/libavdevice/libcdio.c b/libavdevice/libcdio.c
index a4c9f52337..bd8a5baa42 100644
--- a/libavdevice/libcdio.c
+++ b/libavdevice/libcdio.c
@@ -34,7 +34,6 @@
 #endif
 
 #include "libavutil/log.h"
-#include "libavutil/mem.h"
 #include "libavutil/opt.h"
 
 #include "libavformat/avformat.h"
diff --git a/libavfilter/boxblur.h b/libavfilter/boxblur.h
index 5694722a9d..214d4e0c93 100644
--- a/libavfilter/boxblur.h
+++ b/libavfilter/boxblur.h
@@ -25,7 +25,6 @@
 
 #include "libavutil/eval.h"
 #include "libavutil/pixdesc.h"
-#include "libavutil/mem.h"
 
 #include "avfilter.h"
 
diff --git a/libavfilter/drawutils.c b/libavfilter/drawutils.c
index 71fe25692c..33f0fecb32 100644
--- a/libavfilter/drawutils.c
+++ b/libavfilter/drawutils.c
@@ -25,7 +25,6 @@
 #include "libavutil/avutil.h"
 #include "libavutil/colorspace.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem.h"
 #include "libavutil/pixdesc.h"
 #include "drawutils.h"
 #include "formats.h"
diff --git a/libavfilter/vf_deinterlace_vaapi.c b/libavfilter/vf_deinterlace_vaapi.c
index 71809eb01a..e5e7faaea8 100644
--- a/libavfilter/vf_deinterlace_vaapi.c
+++ b/libavfilter/vf_deinterlace_vaapi.c
@@ -20,7 +20,6 @@
 
 #include "libavutil/avassert.h"
 #include "libavutil/common.h"
-#include "libavutil/mem.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 
diff --git a/libavfilter/vf_misc_vaapi.c b/libavfilter/vf_misc_vaapi.c
index 5814ff8c2e..e84c6ef2ca 100644
--- a/libavfilter/vf_misc_vaapi.c
+++ b/libavfilter/vf_misc_vaapi.c
@@ -18,7 +18,6 @@
 #include <string.h>
 
 #include "libavutil/avassert.h"
-#include "libavutil/mem.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 
diff --git a/libavfilter/vf_neighbor_opencl.c b/libavfilter/vf_neighbor_opencl.c
index fb40132d95..87a81b4cc2 100644
--- a/libavfilter/vf_neighbor_opencl.c
+++ b/libavfilter/vf_neighbor_opencl.c
@@ -20,7 +20,6 @@
 
 #include "libavutil/common.h"
 #include "libavutil/imgutils.h"
-#include "libavutil/mem.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/avstring.h"
diff --git a/libavfilter/vf_overlay_cuda.c b/libavfilter/vf_overlay_cuda.c
index 2f0f860e50..c7c115bf14 100644
--- a/libavfilter/vf_overlay_cuda.c
+++ b/libavfilter/vf_overlay_cuda.c
@@ -24,7 +24,6 @@
  */
 
 #include "libavutil/log.h"
-#include "libavutil/mem.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/hwcontext.h"
diff --git a/libavfilter/vf_overlay_opencl.c b/libavfilter/vf_overlay_opencl.c
index e9c853203b..718df73fdb 100644
--- a/libavfilter/vf_overlay_opencl.c
+++ b/libavfilter/vf_overlay_opencl.c
@@ -17,7 +17,6 @@
  */
 
 #include "libavutil/log.h"
-#include "libavutil/mem.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 
diff --git a/libavfilter/vf_procamp_vaapi.c b/libavfilter/vf_procamp_vaapi.c
index 7342048583..240ab09e20 100644
--- a/libavfilter/vf_procamp_vaapi.c
+++ b/libavfilter/vf_procamp_vaapi.c
@@ -18,7 +18,6 @@
 #include <string.h>
 
 #include "libavutil/avassert.h"
-#include "libavutil/mem.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 
diff --git a/libavfilter/vf_scale_vaapi.c b/libavfilter/vf_scale_vaapi.c
index b9a5eeff65..01983d5996 100644
--- a/libavfilter/vf_scale_vaapi.c
+++ b/libavfilter/vf_scale_vaapi.c
@@ -19,7 +19,6 @@
 #include <string.h>
 
 #include "libavutil/avassert.h"
-#include "libavutil/mem.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 
diff --git a/libavfilter/vf_tonemap_opencl.c b/libavfilter/vf_tonemap_opencl.c
index 2681ebd1b5..695c6c9eb8 100644
--- a/libavfilter/vf_tonemap_opencl.c
+++ b/libavfilter/vf_tonemap_opencl.c
@@ -20,7 +20,6 @@
 #include "libavutil/avassert.h"
 #include "libavutil/common.h"
 #include "libavutil/imgutils.h"
-#include "libavutil/mem.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 
diff --git a/libavfilter/vf_tonemap_vaapi.c b/libavfilter/vf_tonemap_vaapi.c
index 2f41b90424..0e22b859b8 100644
--- a/libavfilter/vf_tonemap_vaapi.c
+++ b/libavfilter/vf_tonemap_vaapi.c
@@ -18,7 +18,6 @@
 #include <string.h>
 
 #include "libavutil/avassert.h"
-#include "libavutil/mem.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/mastering_display_metadata.h"
diff --git a/libavfilter/vf_transpose_opencl.c b/libavfilter/vf_transpose_opencl.c
index dd678e91cd..ecf4b48bec 100644
--- a/libavfilter/vf_transpose_opencl.c
+++ b/libavfilter/vf_transpose_opencl.c
@@ -20,7 +20,6 @@
 #include "libavutil/avassert.h"
 #include "libavutil/common.h"
 #include "libavutil/imgutils.h"
-#include "libavutil/mem.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 
diff --git a/libavfilter/vf_transpose_vaapi.c b/libavfilter/vf_transpose_vaapi.c
index a4c654266d..6d2bb3a341 100644
--- a/libavfilter/vf_transpose_vaapi.c
+++ b/libavfilter/vf_transpose_vaapi.c
@@ -18,7 +18,6 @@
 #include <string.h>
 
 #include "libavutil/avassert.h"
-#include "libavutil/mem.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 
diff --git a/libavfilter/vf_xfade_opencl.c b/libavfilter/vf_xfade_opencl.c
index 4736043147..8cc1253dc5 100644
--- a/libavfilter/vf_xfade_opencl.c
+++ b/libavfilter/vf_xfade_opencl.c
@@ -17,7 +17,6 @@
  */
 
 #include "libavutil/log.h"
-#include "libavutil/mem.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 
diff --git a/libavfilter/video.c b/libavfilter/video.c
index 7a8e587798..ee1d440bb2 100644
--- a/libavfilter/video.c
+++ b/libavfilter/video.c
@@ -27,7 +27,6 @@
 #include "libavutil/buffer.h"
 #include "libavutil/hwcontext.h"
 #include "libavutil/imgutils.h"
-#include "libavutil/mem.h"
 
 #include "avfilter.h"
 #include "internal.h"
diff --git a/libavfilter/x86/vf_atadenoise_init.c b/libavfilter/x86/vf_atadenoise_init.c
index 3f87f3c445..e7a653f191 100644
--- a/libavfilter/x86/vf_atadenoise_init.c
+++ b/libavfilter/x86/vf_atadenoise_init.c
@@ -20,7 +20,6 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
-#include "libavutil/mem.h"
 #include "libavutil/x86/asm.h"
 #include "libavutil/x86/cpu.h"
 #include "libavfilter/atadenoise.h"
diff --git a/libavfilter/x86/vf_bwdif_init.c b/libavfilter/x86/vf_bwdif_init.c
index b1e70b3bc6..f632c4f340 100644
--- a/libavfilter/x86/vf_bwdif_init.c
+++ b/libavfilter/x86/vf_bwdif_init.c
@@ -20,7 +20,6 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
-#include "libavutil/mem.h"
 #include "libavutil/x86/asm.h"
 #include "libavutil/x86/cpu.h"
 #include "libavfilter/bwdif.h"
diff --git a/libavfilter/x86/vf_eq_init.c b/libavfilter/x86/vf_eq_init.c
index 274325074a..113056e76b 100644
--- a/libavfilter/x86/vf_eq_init.c
+++ b/libavfilter/x86/vf_eq_init.c
@@ -21,7 +21,6 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
-#include "libavutil/mem.h"
 #include "libavutil/x86/cpu.h"
 #include "libavutil/x86/asm.h"
 #include "libavfilter/vf_eq.h"
diff --git a/libavfilter/x86/vf_gradfun_init.c b/libavfilter/x86/vf_gradfun_init.c
index 4009711701..56e6774a79 100644
--- a/libavfilter/x86/vf_gradfun_init.c
+++ b/libavfilter/x86/vf_gradfun_init.c
@@ -21,7 +21,6 @@
 #include "config.h"
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
-#include "libavutil/mem.h"
 #include "libavutil/x86/cpu.h"
 #include "libavfilter/gradfun.h"
 
diff --git a/libavfilter/x86/vf_idet_init.c b/libavfilter/x86/vf_idet_init.c
index ca175e2d40..d4d9bd0893 100644
--- a/libavfilter/x86/vf_idet_init.c
+++ b/libavfilter/x86/vf_idet_init.c
@@ -18,7 +18,6 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
-#include "libavutil/mem.h"
 #include "libavutil/x86/asm.h"
 #include "libavutil/x86/cpu.h"
 #include "libavfilter/vf_idet.h"
diff --git a/libavfilter/x86/vf_maskedclamp_init.c b/libavfilter/x86/vf_maskedclamp_init.c
index 53153f80ea..2a5388abac 100644
--- a/libavfilter/x86/vf_maskedclamp_init.c
+++ b/libavfilter/x86/vf_maskedclamp_init.c
@@ -20,7 +20,6 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
-#include "libavutil/mem.h"
 #include "libavutil/x86/asm.h"
 #include "libavutil/x86/cpu.h"
 #include "libavfilter/maskedclamp.h"
diff --git a/libavfilter/x86/vf_transpose_init.c b/libavfilter/x86/vf_transpose_init.c
index 6bb9908725..95c56eab73 100644
--- a/libavfilter/x86/vf_transpose_init.c
+++ b/libavfilter/x86/vf_transpose_init.c
@@ -20,7 +20,6 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
-#include "libavutil/mem.h"
 #include "libavutil/x86/asm.h"
 #include "libavutil/x86/cpu.h"
 #include "libavfilter/transpose.h"
diff --git a/libavfilter/x86/vf_w3fdif_init.c b/libavfilter/x86/vf_w3fdif_init.c
index d4534bb1ed..16202fba76 100644
--- a/libavfilter/x86/vf_w3fdif_init.c
+++ b/libavfilter/x86/vf_w3fdif_init.c
@@ -20,7 +20,6 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
-#include "libavutil/mem.h"
 #include "libavutil/x86/asm.h"
 #include "libavutil/x86/cpu.h"
 #include "libavfilter/w3fdif.h"
diff --git a/libavfilter/x86/vf_yadif_init.c b/libavfilter/x86/vf_yadif_init.c
index c39bc44da6..66cbee8510 100644
--- a/libavfilter/x86/vf_yadif_init.c
+++ b/libavfilter/x86/vf_yadif_init.c
@@ -20,7 +20,6 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
-#include "libavutil/mem.h"
 #include "libavutil/x86/cpu.h"
 #include "libavfilter/yadif.h"
 
diff --git a/libavformat/replaygain.c b/libavformat/replaygain.c
index 707d3cd4f1..24f5c74183 100644
--- a/libavformat/replaygain.c
+++ b/libavformat/replaygain.c
@@ -29,7 +29,6 @@
 #include "libavutil/dict.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/mathematics.h"
-#include "libavutil/mem.h"
 #include "libavutil/replaygain.h"
 
 #include "avformat.h"
diff --git a/libavutil/avsscanf.c b/libavutil/avsscanf.c
index b7f0f71c2d..a20cb15b01 100644
--- a/libavutil/avsscanf.c
+++ b/libavutil/avsscanf.c
@@ -29,7 +29,6 @@
 
 #include "config.h"
 #include "common.h"
-#include "mem.h"
 #include "avassert.h"
 #include "avstring.h"
 #include "bprint.h"
diff --git a/libavutil/tests/aes_ctr.c b/libavutil/tests/aes_ctr.c
index 53d0e4a244..9dbf0af8aa 100644
--- a/libavutil/tests/aes_ctr.c
+++ b/libavutil/tests/aes_ctr.c
@@ -17,7 +17,6 @@
  */
 
 #include "libavutil/log.h"
-#include "libavutil/mem.h"
 #include "libavutil/mem_internal.h"
 #include "libavutil/aes_ctr.h"
 
diff --git a/libavutil/tx_priv.h b/libavutil/tx_priv.h
index 18a07c312c..7edaa8d8c6 100644
--- a/libavutil/tx_priv.h
+++ b/libavutil/tx_priv.h
@@ -22,7 +22,6 @@
 #include "tx.h"
 #include <stddef.h>
 #include "thread.h"
-#include "mem.h"
 #include "mem_internal.h"
 #include "avassert.h"
 #include "attributes.h"
diff --git a/tests/checkasm/llviddspenc.c b/tests/checkasm/llviddspenc.c
index 132f6d2771..4ec46c96bd 100644
--- a/tests/checkasm/llviddspenc.c
+++ b/tests/checkasm/llviddspenc.c
@@ -22,7 +22,6 @@
 
 #include "libavutil/common.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem.h"
 #include "libavutil/mem_internal.h"
 
 #include "libavcodec/lossless_videoencdsp.h"
diff --git a/tests/checkasm/sw_rgb.c b/tests/checkasm/sw_rgb.c
index c29b75d09b..7cd815e5be 100644
--- a/tests/checkasm/sw_rgb.c
+++ b/tests/checkasm/sw_rgb.c
@@ -21,7 +21,6 @@
 
 #include "libavutil/common.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem.h"
 #include "libavutil/mem_internal.h"
 
 #include "libswscale/rgb2rgb.h"
diff --git a/tests/checkasm/sw_scale.c b/tests/checkasm/sw_scale.c
index 8741b3943c..41ee9ba4cc 100644
--- a/tests/checkasm/sw_scale.c
+++ b/tests/checkasm/sw_scale.c
@@ -21,7 +21,6 @@
 
 #include "libavutil/common.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem.h"
 #include "libavutil/mem_internal.h"
 
 #include "libswscale/swscale.h"
diff --git a/tools/ffhash.c b/tools/ffhash.c
index 6942527732..3034aa863f 100644
--- a/tools/ffhash.c
+++ b/tools/ffhash.c
@@ -24,7 +24,6 @@
 #include "libavutil/avstring.h"
 #include "libavutil/error.h"
 #include "libavutil/hash.h"
-#include "libavutil/mem.h"
 
 #include <errno.h>
 #include <fcntl.h>
