[FFmpeg-devel] [PATCH 2/2] lavu/mem: move the DECLARE_ALIGNED macro family to mem_internal on next+1 bump

Anton Khirnov anton at khirnov.net
Thu Dec 10 12:23:40 EET 2020


They are not properly namespaced and not intended for public use.
---
 libavcodec/4xm.c                           |  1 +
 libavcodec/aac.h                           |  1 +
 libavcodec/aacenc.h                        |  2 +
 libavcodec/aacps.h                         |  2 +
 libavcodec/aacps_fixed_tablegen.h          |  1 +
 libavcodec/aacsbr_tablegen_common.h        |  2 +-
 libavcodec/aacsbrdata.h                    |  2 +-
 libavcodec/aactab.c                        |  1 +
 libavcodec/aactab.h                        |  2 +-
 libavcodec/ac3dec.h                        |  2 +
 libavcodec/ac3dsp.c                        |  2 +
 libavcodec/ac3tab.c                        |  2 +-
 libavcodec/agm.c                           |  2 +
 libavcodec/aic.c                           |  2 +
 libavcodec/arm/sbcdsp_init_arm.c           |  1 +
 libavcodec/asv.h                           |  2 +-
 libavcodec/atrac1.c                        |  2 +
 libavcodec/atrac3.c                        |  1 +
 libavcodec/atrac3plus.h                    |  2 +
 libavcodec/atrac3plusdec.c                 |  1 +
 libavcodec/atrac9dec.c                     |  1 +
 libavcodec/binkaudio.c                     |  1 +
 libavcodec/cabac.c                         |  1 +
 libavcodec/cavs.c                          |  2 +
 libavcodec/cavs.h                          |  2 +
 libavcodec/clearvideo.c                    |  1 +
 libavcodec/cook.c                          |  1 +
 libavcodec/dca_core.h                      |  2 +-
 libavcodec/dca_lbr.h                       |  2 +-
 libavcodec/dca_xll.h                       |  2 +-
 libavcodec/dcadata.c                       |  2 +-
 libavcodec/dirac_vlc.c                     |  2 +
 libavcodec/diracdec.c                      |  1 +
 libavcodec/dnxhddec.c                      |  2 +
 libavcodec/dnxhdenc.h                      |  2 +
 libavcodec/dolby_e.h                       |  2 +-
 libavcodec/dss_sp.c                        |  1 +
 libavcodec/dstdec.c                        |  1 +
 libavcodec/eamad.c                         |  2 +
 libavcodec/eatgq.c                         |  3 +
 libavcodec/eatqi.c                         |  2 +
 libavcodec/fft.h                           |  3 +-
 libavcodec/fic.c                           |  1 +
 libavcodec/g2meet.c                        |  1 +
 libavcodec/h264_mvpred.h                   |  1 +
 libavcodec/h264dec.h                       |  1 +
 libavcodec/hcadec.c                        |  1 +
 libavcodec/hevcdec.h                       |  1 +
 libavcodec/hevcdsp.h                       |  2 +
 libavcodec/hq_hqa.h                        |  2 +
 libavcodec/hqx.h                           |  3 +-
 libavcodec/imm4.c                          |  1 +
 libavcodec/mdct15.h                        |  2 +
 libavcodec/mdec.c                          |  2 +
 libavcodec/mimic.c                         |  1 +
 libavcodec/mips/constants.c                |  2 +-
 libavcodec/mips/h264dsp_mmi.c              |  1 +
 libavcodec/mips/simple_idct_mmi.c          |  1 +
 libavcodec/mips/vc1dsp_mmi.c               |  2 +
 libavcodec/mips/vp8dsp_mmi.c               |  1 +
 libavcodec/mips/xvid_idct_mmi.c            |  2 +
 libavcodec/mjpegdec.h                      |  1 +
 libavcodec/mlpdec.c                        |  1 +
 libavcodec/mpc.h                           |  1 +
 libavcodec/mpegaudiodec_template.c         |  2 +
 libavcodec/mpegaudiodsp_template.c         |  2 +
 libavcodec/nellymoserdec.c                 |  1 +
 libavcodec/on2avc.c                        |  2 +
 libavcodec/opus.h                          |  1 +
 libavcodec/opus_celt.h                     |  1 +
 libavcodec/opus_pvq.h                      |  2 +
 libavcodec/opusenc.c                       |  1 +
 libavcodec/opusenc_psy.h                   |  2 +
 libavcodec/opustab.c                       |  2 +
 libavcodec/ppc/h264chroma_template.c       |  2 +-
 libavcodec/ppc/h264dsp.c                   |  2 +-
 libavcodec/ppc/h264qpel.c                  |  1 +
 libavcodec/ppc/mpegvideo_altivec.c         |  1 +
 libavcodec/ppc/mpegvideodsp.c              |  2 +-
 libavcodec/ppc/vp8dsp_altivec.c            |  2 +-
 libavcodec/proresenc_kostya.c              |  1 +
 libavcodec/qdm2.c                          |  1 +
 libavcodec/ra144.h                         |  3 +
 libavcodec/ra288.h                         |  1 +
 libavcodec/rtjpeg.h                        |  2 +-
 libavcodec/rv34.h                          |  2 +
 libavcodec/sbc.h                           |  1 +
 libavcodec/sbcdec.c                        |  1 +
 libavcodec/sbcdsp.h                        |  2 +
 libavcodec/sbcdsp_data.c                   |  2 +
 libavcodec/sbr.h                           |  3 +
 libavcodec/sinewin.h                       |  2 +-
 libavcodec/sipr.h                          |  2 +-
 libavcodec/siren.c                         |  1 +
 libavcodec/svq1_cb.h                       |  2 +-
 libavcodec/svq1enc.h                       |  1 +
 libavcodec/svq3.c                          |  1 +
 libavcodec/tableprint.h                    |  1 +
 libavcodec/takdec.c                        |  1 +
 libavcodec/truespeech.c                    |  2 +
 libavcodec/vorbis_data.c                   |  3 +-
 libavcodec/vp3.c                           |  1 +
 libavcodec/vp56.h                          |  2 +
 libavcodec/vp8.h                           |  1 +
 libavcodec/vp9dec.h                        |  1 +
 libavcodec/vp9dsp.c                        |  2 +
 libavcodec/wma.h                           |  1 +
 libavcodec/wmalosslessdec.c                |  1 +
 libavcodec/wmaprodec.c                     |  2 +
 libavcodec/wmavoice.c                      |  2 +-
 libavcodec/wmv2.h                          |  2 +
 libavcodec/x86/constants.c                 |  2 +-
 libavcodec/x86/fdct.c                      |  1 +
 libavcodec/x86/me_cmp_init.c               |  1 +
 libavcodec/x86/mpegvideoenc.c              |  1 +
 libavfilter/ebur128.c                      |  1 +
 libavfilter/vf_colorspace.c                |  1 +
 libavfilter/vf_dctdnoiz.c                  |  1 +
 libavfilter/vf_fspp.c                      |  1 +
 libavfilter/vf_gradfun.c                   |  1 +
 libavfilter/vf_owdenoise.c                 |  1 +
 libavfilter/vf_pp7.c                       |  1 +
 libavfilter/vf_spp.c                       |  1 +
 libavfilter/vf_uspp.c                      |  1 +
 libavutil/aes_internal.h                   |  2 +-
 libavutil/internal.h                       |  1 -
 libavutil/lls.h                            |  2 +-
 libavutil/mem.h                            |  6 ++
 libavutil/mem_internal.h                   | 70 ++++++++++++++++++++++
 libavutil/tests/aes_ctr.c                  |  1 +
 libavutil/tests/des.c                      |  1 +
 libavutil/tx_priv.h                        |  1 +
 libavutil/version.h                        |  3 +
 libpostproc/postprocess_altivec_template.c |  1 +
 libpostproc/postprocess_internal.h         |  1 +
 libpostproc/postprocess_template.c         |  1 +
 libswscale/output.c                        |  1 +
 libswscale/ppc/yuv2rgb_altivec.c           |  1 +
 libswscale/swscale.c                       |  1 +
 libswscale/swscale_internal.h              |  1 +
 libswscale/swscale_unscaled.c              |  1 +
 libswscale/x86/hscale_fast_bilinear_simd.c |  1 +
 libswscale/x86/rgb2rgb.c                   |  2 +
 libswscale/x86/swscale.c                   |  1 +
 144 files changed, 264 insertions(+), 27 deletions(-)

diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c
index 336c651d31..4d58b093f7 100644
--- a/libavcodec/4xm.c
+++ b/libavcodec/4xm.c
@@ -30,6 +30,7 @@
 #include "libavutil/frame.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/intreadwrite.h"
+#include "libavutil/mem_internal.h"
 #include "avcodec.h"
 #include "blockdsp.h"
 #include "bswapdsp.h"
diff --git a/libavcodec/aac.h b/libavcodec/aac.h
index d422ea5b13..1e82f56ca9 100644
--- a/libavcodec/aac.h
+++ b/libavcodec/aac.h
@@ -34,6 +34,7 @@
 #include "aac_defines.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/fixed_dsp.h"
+#include "libavutil/mem_internal.h"
 #include "avcodec.h"
 #if !USE_FIXED
 #include "mdct15.h"
diff --git a/libavcodec/aacenc.h b/libavcodec/aacenc.h
index 5a015ca92e..8ffc94f99b 100644
--- a/libavcodec/aacenc.h
+++ b/libavcodec/aacenc.h
@@ -23,6 +23,8 @@
 #define AVCODEC_AACENC_H
 
 #include "libavutil/float_dsp.h"
+#include "libavutil/mem_internal.h"
+
 #include "avcodec.h"
 #include "put_bits.h"
 
diff --git a/libavcodec/aacps.h b/libavcodec/aacps.h
index 61edce3549..cf0aaeeed2 100644
--- a/libavcodec/aacps.h
+++ b/libavcodec/aacps.h
@@ -24,6 +24,8 @@
 
 #include <stdint.h>
 
+#include "libavutil/mem_internal.h"
+
 #include "aacpsdsp.h"
 #include "avcodec.h"
 #include "get_bits.h"
diff --git a/libavcodec/aacps_fixed_tablegen.h b/libavcodec/aacps_fixed_tablegen.h
index 8b82deb596..356fb8b293 100644
--- a/libavcodec/aacps_fixed_tablegen.h
+++ b/libavcodec/aacps_fixed_tablegen.h
@@ -37,6 +37,7 @@
 #include "libavutil/common.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/mem.h"
+#include "libavutil/mem_internal.h"
 
 #include "aac_defines.h"
 #include "libavutil/softfloat.h"
diff --git a/libavcodec/aacsbr_tablegen_common.h b/libavcodec/aacsbr_tablegen_common.h
index 8e0dd9e1fd..cbd669fae1 100644
--- a/libavcodec/aacsbr_tablegen_common.h
+++ b/libavcodec/aacsbr_tablegen_common.h
@@ -23,7 +23,7 @@
 #ifndef AVCODEC_AACSBR_TABLEGEN_COMMON_H
 #define AVCODEC_AACSBR_TABLEGEN_COMMON_H
 #include "aac_defines.h"
-#include "libavutil/mem.h"
+#include "libavutil/mem_internal.h"
 
 ///< window coefficients for analysis/synthesis QMF banks
 static DECLARE_ALIGNED(32, INTFLOAT, sbr_qmf_window_ds)[320];
diff --git a/libavcodec/aacsbrdata.h b/libavcodec/aacsbrdata.h
index 4ff8fae913..d4a94084f6 100644
--- a/libavcodec/aacsbrdata.h
+++ b/libavcodec/aacsbrdata.h
@@ -29,7 +29,7 @@
 #define AVCODEC_AACSBRDATA_H
 
 #include <stdint.h>
-#include "libavutil/mem.h"
+#include "libavutil/mem_internal.h"
 #include "aac_defines.h"
 
 ///< Huffman tables for SBR
diff --git a/libavcodec/aactab.c b/libavcodec/aactab.c
index abe5fd7567..fa5420fec6 100644
--- a/libavcodec/aactab.c
+++ b/libavcodec/aactab.c
@@ -29,6 +29,7 @@
 
 #include "config.h"
 #include "libavutil/mem.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
 #include "aac.h"
 #include "aactab.h"
diff --git a/libavcodec/aactab.h b/libavcodec/aactab.h
index 8a354e8186..9b1450c2eb 100644
--- a/libavcodec/aactab.h
+++ b/libavcodec/aactab.h
@@ -30,7 +30,7 @@
 #ifndef AVCODEC_AACTAB_H
 #define AVCODEC_AACTAB_H
 
-#include "libavutil/mem.h"
+#include "libavutil/mem_internal.h"
 #include "aac.h"
 
 #include <stdint.h>
diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h
index ce1434b55c..85653990cf 100644
--- a/libavcodec/ac3dec.h
+++ b/libavcodec/ac3dec.h
@@ -53,6 +53,8 @@
 #include "libavutil/float_dsp.h"
 #include "libavutil/fixed_dsp.h"
 #include "libavutil/lfg.h"
+#include "libavutil/mem_internal.h"
+
 #include "ac3.h"
 #include "ac3dsp.h"
 #include "bswapdsp.h"
diff --git a/libavcodec/ac3dsp.c b/libavcodec/ac3dsp.c
index 43438da131..382f87c05f 100644
--- a/libavcodec/ac3dsp.c
+++ b/libavcodec/ac3dsp.c
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/mem_internal.h"
+
 #include "avcodec.h"
 #include "ac3.h"
 #include "ac3dsp.h"
diff --git a/libavcodec/ac3tab.c b/libavcodec/ac3tab.c
index ef2a41bc59..d018110331 100644
--- a/libavcodec/ac3tab.c
+++ b/libavcodec/ac3tab.c
@@ -25,7 +25,7 @@
  */
 
 #include "libavutil/channel_layout.h"
-#include "libavutil/mem.h"
+#include "libavutil/mem_internal.h"
 
 #include "avcodec.h"
 #include "ac3tab.h"
diff --git a/libavcodec/agm.c b/libavcodec/agm.c
index f60cbf1a18..f39383140f 100644
--- a/libavcodec/agm.c
+++ b/libavcodec/agm.c
@@ -26,6 +26,8 @@
 
 #define BITSTREAM_READER_LE
 
+#include "libavutil/mem_internal.h"
+
 #include "avcodec.h"
 #include "bytestream.h"
 #include "copy_block.h"
diff --git a/libavcodec/aic.c b/libavcodec/aic.c
index f027fa99ef..cf5b0782be 100644
--- a/libavcodec/aic.c
+++ b/libavcodec/aic.c
@@ -22,6 +22,8 @@
 
 #include <inttypes.h>
 
+#include "libavutil/mem_internal.h"
+
 #include "avcodec.h"
 #include "bytestream.h"
 #include "internal.h"
diff --git a/libavcodec/arm/sbcdsp_init_arm.c b/libavcodec/arm/sbcdsp_init_arm.c
index 6bf7e729ef..b8fa5a35ab 100644
--- a/libavcodec/arm/sbcdsp_init_arm.c
+++ b/libavcodec/arm/sbcdsp_init_arm.c
@@ -30,6 +30,7 @@
  */
 
 #include "libavutil/cpu.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/arm/cpu.h"
 #include "libavcodec/sbcdsp.h"
 
diff --git a/libavcodec/asv.h b/libavcodec/asv.h
index e778c72d34..269bbe7c18 100644
--- a/libavcodec/asv.h
+++ b/libavcodec/asv.h
@@ -28,7 +28,7 @@
 
 #include <stdint.h>
 
-#include "libavutil/mem.h"
+#include "libavutil/mem_internal.h"
 
 #include "avcodec.h"
 #include "blockdsp.h"
diff --git a/libavcodec/atrac1.c b/libavcodec/atrac1.c
index 0dd8b87bf5..54f9b1c2d8 100644
--- a/libavcodec/atrac1.c
+++ b/libavcodec/atrac1.c
@@ -33,6 +33,8 @@
 #include <stdio.h>
 
 #include "libavutil/float_dsp.h"
+#include "libavutil/mem_internal.h"
+
 #include "avcodec.h"
 #include "get_bits.h"
 #include "fft.h"
diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c
index 633032786f..37ccbcc946 100644
--- a/libavcodec/atrac3.c
+++ b/libavcodec/atrac3.c
@@ -39,6 +39,7 @@
 #include "libavutil/attributes.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/libm.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
 
 #include "avcodec.h"
diff --git a/libavcodec/atrac3plus.h b/libavcodec/atrac3plus.h
index 82fe0fe1f8..a588436e2a 100644
--- a/libavcodec/atrac3plus.h
+++ b/libavcodec/atrac3plus.h
@@ -31,6 +31,8 @@
 #include <stdint.h>
 
 #include "libavutil/float_dsp.h"
+#include "libavutil/mem_internal.h"
+
 #include "atrac.h"
 #include "avcodec.h"
 #include "fft.h"
diff --git a/libavcodec/atrac3plusdec.c b/libavcodec/atrac3plusdec.c
index 2ae03d838f..c024ab6bde 100644
--- a/libavcodec/atrac3plusdec.c
+++ b/libavcodec/atrac3plusdec.c
@@ -39,6 +39,7 @@
 
 #include "libavutil/channel_layout.h"
 #include "libavutil/float_dsp.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
 #include "avcodec.h"
 #include "get_bits.h"
diff --git a/libavcodec/atrac9dec.c b/libavcodec/atrac9dec.c
index f0fcd0cb13..58dd2e3cad 100644
--- a/libavcodec/atrac9dec.c
+++ b/libavcodec/atrac9dec.c
@@ -27,6 +27,7 @@
 #include "atrac9tab.h"
 #include "libavutil/lfg.h"
 #include "libavutil/float_dsp.h"
+#include "libavutil/mem_internal.h"
 
 #define ATRAC9_SF_VLC_BITS 8
 #define ATRAC9_COEFF_VLC_BITS 9
diff --git a/libavcodec/binkaudio.c b/libavcodec/binkaudio.c
index 7b5965ede1..381fc4cd15 100644
--- a/libavcodec/binkaudio.c
+++ b/libavcodec/binkaudio.c
@@ -30,6 +30,7 @@
 
 #include "libavutil/channel_layout.h"
 #include "libavutil/intfloat.h"
+#include "libavutil/mem_internal.h"
 
 #define BITSTREAM_READER_LE
 #include "avcodec.h"
diff --git a/libavcodec/cabac.c b/libavcodec/cabac.c
index 54e9bb4d8f..3bbecf50dd 100644
--- a/libavcodec/cabac.c
+++ b/libavcodec/cabac.c
@@ -27,6 +27,7 @@
 #include <string.h>
 
 #include "libavutil/common.h"
+#include "libavutil/mem_internal.h"
 
 #include "cabac.h"
 #include "cabac_functions.h"
diff --git a/libavcodec/cavs.c b/libavcodec/cavs.c
index ba2b6ef232..74b8371501 100644
--- a/libavcodec/cavs.c
+++ b/libavcodec/cavs.c
@@ -25,6 +25,8 @@
  * @author Stefan Gehrer <stefan.gehrer at gmx.de>
  */
 
+#include "libavutil/mem_internal.h"
+
 #include "avcodec.h"
 #include "get_bits.h"
 #include "golomb.h"
diff --git a/libavcodec/cavs.h b/libavcodec/cavs.h
index 6bfb22ce48..cbc163fb4d 100644
--- a/libavcodec/cavs.h
+++ b/libavcodec/cavs.h
@@ -22,6 +22,8 @@
 #ifndef AVCODEC_CAVS_H
 #define AVCODEC_CAVS_H
 
+#include "libavutil/mem_internal.h"
+
 #include "cavsdsp.h"
 #include "blockdsp.h"
 #include "h264chroma.h"
diff --git a/libavcodec/clearvideo.c b/libavcodec/clearvideo.c
index 7342557cd2..79ba88857c 100644
--- a/libavcodec/clearvideo.c
+++ b/libavcodec/clearvideo.c
@@ -24,6 +24,7 @@
  * ClearVideo decoder
  */
 
+#include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
 
 #include "avcodec.h"
diff --git a/libavcodec/cook.c b/libavcodec/cook.c
index 1968f2f896..a9de3c8b1a 100644
--- a/libavcodec/cook.c
+++ b/libavcodec/cook.c
@@ -44,6 +44,7 @@
 
 #include "libavutil/channel_layout.h"
 #include "libavutil/lfg.h"
+#include "libavutil/mem_internal.h"
 
 #include "audiodsp.h"
 #include "avcodec.h"
diff --git a/libavcodec/dca_core.h b/libavcodec/dca_core.h
index 10128d1e32..86bfa62203 100644
--- a/libavcodec/dca_core.h
+++ b/libavcodec/dca_core.h
@@ -24,7 +24,7 @@
 #include "libavutil/common.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/fixed_dsp.h"
-#include "libavutil/mem.h"
+#include "libavutil/mem_internal.h"
 
 #include "avcodec.h"
 #include "internal.h"
diff --git a/libavcodec/dca_lbr.h b/libavcodec/dca_lbr.h
index 6d4c0a8a63..e6856a2cf7 100644
--- a/libavcodec/dca_lbr.h
+++ b/libavcodec/dca_lbr.h
@@ -23,7 +23,7 @@
 
 #include "libavutil/common.h"
 #include "libavutil/float_dsp.h"
-#include "libavutil/mem.h"
+#include "libavutil/mem_internal.h"
 
 #include "avcodec.h"
 #include "internal.h"
diff --git a/libavcodec/dca_xll.h b/libavcodec/dca_xll.h
index bc0aa65b1a..3aaad6d370 100644
--- a/libavcodec/dca_xll.h
+++ b/libavcodec/dca_xll.h
@@ -22,7 +22,7 @@
 #define AVCODEC_DCA_XLL_H
 
 #include "libavutil/common.h"
-#include "libavutil/mem.h"
+#include "libavutil/mem_internal.h"
 
 #include "avcodec.h"
 #include "internal.h"
diff --git a/libavcodec/dcadata.c b/libavcodec/dcadata.c
index 1b646a7aa6..643b0cc025 100644
--- a/libavcodec/dcadata.c
+++ b/libavcodec/dcadata.c
@@ -22,7 +22,7 @@
 
 #include <stdint.h>
 
-#include "libavutil/mem.h"
+#include "libavutil/mem_internal.h"
 
 #include "dca.h"
 #include "dcadata.h"
diff --git a/libavcodec/dirac_vlc.c b/libavcodec/dirac_vlc.c
index 2e2fa7ea63..2c07440df0 100644
--- a/libavcodec/dirac_vlc.c
+++ b/libavcodec/dirac_vlc.c
@@ -16,6 +16,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/mem_internal.h"
+
 #include "dirac_vlc.h"
 
 enum {
diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c
index ed42bc366a..b9999cde01 100644
--- a/libavcodec/diracdec.c
+++ b/libavcodec/diracdec.c
@@ -26,6 +26,7 @@
  * @author Marco Gerards <marco at gnu.org>, David Conrad, Jordi Ortiz <nenjordi at gmail.com>
  */
 
+#include "libavutil/mem_internal.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/thread.h"
 #include "avcodec.h"
diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c
index e5d01e2e71..09bc6f9b59 100644
--- a/libavcodec/dnxhddec.c
+++ b/libavcodec/dnxhddec.c
@@ -25,6 +25,8 @@
  */
 
 #include "libavutil/imgutils.h"
+#include "libavutil/mem_internal.h"
+
 #include "avcodec.h"
 #include "blockdsp.h"
 #define  UNCHECKED_BITSTREAM_READER 1
diff --git a/libavcodec/dnxhdenc.h b/libavcodec/dnxhdenc.h
index 7b0d862e28..9e4c869bc4 100644
--- a/libavcodec/dnxhdenc.h
+++ b/libavcodec/dnxhdenc.h
@@ -28,6 +28,8 @@
 
 #include "config.h"
 
+#include "libavutil/mem_internal.h"
+
 #include "mpegvideo.h"
 #include "dnxhddata.h"
 
diff --git a/libavcodec/dolby_e.h b/libavcodec/dolby_e.h
index ae04bf699c..68223a62ef 100644
--- a/libavcodec/dolby_e.h
+++ b/libavcodec/dolby_e.h
@@ -23,7 +23,7 @@
 
 #include "libavutil/float_dsp.h"
 #include "libavutil/libm.h"
-#include "libavutil/mem.h"
+#include "libavutil/mem_internal.h"
 
 #include "internal.h"
 #include "get_bits.h"
diff --git a/libavcodec/dss_sp.c b/libavcodec/dss_sp.c
index 14025fcdde..cb8d54406a 100644
--- a/libavcodec/dss_sp.c
+++ b/libavcodec/dss_sp.c
@@ -22,6 +22,7 @@
 #include "libavutil/channel_layout.h"
 #include "libavutil/common.h"
 #include "libavutil/mem.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/opt.h"
 
 #include "avcodec.h"
diff --git a/libavcodec/dstdec.c b/libavcodec/dstdec.c
index 3fd710d2f6..84d19b91aa 100644
--- a/libavcodec/dstdec.c
+++ b/libavcodec/dstdec.c
@@ -27,6 +27,7 @@
 
 #include "libavutil/avassert.h"
 #include "libavutil/intreadwrite.h"
+#include "libavutil/mem_internal.h"
 #include "internal.h"
 #include "get_bits.h"
 #include "avcodec.h"
diff --git a/libavcodec/eamad.c b/libavcodec/eamad.c
index 7f28abbafe..c2e064e4f0 100644
--- a/libavcodec/eamad.c
+++ b/libavcodec/eamad.c
@@ -28,6 +28,8 @@
  * http://wiki.multimedia.cx/index.php?title=Electronic_Arts_MAD
  */
 
+#include "libavutil/mem_internal.h"
+
 #include "avcodec.h"
 #include "blockdsp.h"
 #include "bytestream.h"
diff --git a/libavcodec/eatgq.c b/libavcodec/eatgq.c
index 1308c07cff..197ba6fc6e 100644
--- a/libavcodec/eatgq.c
+++ b/libavcodec/eatgq.c
@@ -29,6 +29,9 @@
  */
 
 #define BITSTREAM_READER_LE
+
+#include "libavutil/mem_internal.h"
+
 #include "aandcttab.h"
 #include "avcodec.h"
 #include "bytestream.h"
diff --git a/libavcodec/eatqi.c b/libavcodec/eatqi.c
index 96536b1a08..9723c25acb 100644
--- a/libavcodec/eatqi.c
+++ b/libavcodec/eatqi.c
@@ -26,6 +26,8 @@
  * @see http://wiki.multimedia.cx/index.php?title=Electronic_Arts_TQI
  */
 
+#include "libavutil/mem_internal.h"
+
 #include "avcodec.h"
 #include "blockdsp.h"
 #include "bswapdsp.h"
diff --git a/libavcodec/fft.h b/libavcodec/fft.h
index c858570a21..5f67b61f06 100644
--- a/libavcodec/fft.h
+++ b/libavcodec/fft.h
@@ -32,7 +32,8 @@
 
 #include <stdint.h>
 #include "config.h"
-#include "libavutil/mem.h"
+
+#include "libavutil/mem_internal.h"
 
 #if FFT_FLOAT
 
diff --git a/libavcodec/fic.c b/libavcodec/fic.c
index 95baaedaa5..ef5f3f44d1 100644
--- a/libavcodec/fic.c
+++ b/libavcodec/fic.c
@@ -22,6 +22,7 @@
  */
 
 #include "libavutil/common.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/opt.h"
 #include "avcodec.h"
 #include "internal.h"
diff --git a/libavcodec/g2meet.c b/libavcodec/g2meet.c
index f6aa636bde..70dc8c72a3 100644
--- a/libavcodec/g2meet.c
+++ b/libavcodec/g2meet.c
@@ -30,6 +30,7 @@
 
 #include "libavutil/imgutils.h"
 #include "libavutil/intreadwrite.h"
+#include "libavutil/mem_internal.h"
 
 #include "avcodec.h"
 #include "blockdsp.h"
diff --git a/libavcodec/h264_mvpred.h b/libavcodec/h264_mvpred.h
index bf395e3fe2..19d9ee462d 100644
--- a/libavcodec/h264_mvpred.h
+++ b/libavcodec/h264_mvpred.h
@@ -33,6 +33,7 @@
 #include "h264dec.h"
 #include "mpegutils.h"
 #include "libavutil/avassert.h"
+#include "libavutil/mem_internal.h"
 
 
 static av_always_inline int fetch_diagonal_mv(const H264Context *h, H264SliceContext *sl,
diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h
index 29c4d4e42c..b3677cdbb9 100644
--- a/libavcodec/h264dec.h
+++ b/libavcodec/h264dec.h
@@ -30,6 +30,7 @@
 
 #include "libavutil/buffer.h"
 #include "libavutil/intreadwrite.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
 
 #include "cabac.h"
diff --git a/libavcodec/hcadec.c b/libavcodec/hcadec.c
index 11cb157277..9c3eda21af 100644
--- a/libavcodec/hcadec.c
+++ b/libavcodec/hcadec.c
@@ -19,6 +19,7 @@
 #include "libavutil/crc.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/intreadwrite.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/tx.h"
 
 #include "avcodec.h"
diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h
index c0a138e97a..b2aa392b43 100644
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevcdec.h
@@ -27,6 +27,7 @@
 
 #include "libavutil/buffer.h"
 #include "libavutil/md5.h"
+#include "libavutil/mem_internal.h"
 
 #include "avcodec.h"
 #include "bswapdsp.h"
diff --git a/libavcodec/hevcdsp.h b/libavcodec/hevcdsp.h
index 0ae67cba85..c605a343d6 100644
--- a/libavcodec/hevcdsp.h
+++ b/libavcodec/hevcdsp.h
@@ -25,6 +25,8 @@
 #ifndef AVCODEC_HEVCDSP_H
 #define AVCODEC_HEVCDSP_H
 
+#include "libavutil/mem_internal.h"
+
 #include "get_bits.h"
 
 #define MAX_PB_SIZE 64
diff --git a/libavcodec/hq_hqa.h b/libavcodec/hq_hqa.h
index 608e2ca1a6..08d79e7454 100644
--- a/libavcodec/hq_hqa.h
+++ b/libavcodec/hq_hqa.h
@@ -23,6 +23,8 @@
 
 #include <stdint.h>
 
+#include "libavutil/mem_internal.h"
+
 #include "avcodec.h"
 #include "bytestream.h"
 #include "hq_hqadsp.h"
diff --git a/libavcodec/hqx.h b/libavcodec/hqx.h
index 50d60f9e03..3eddaafb29 100644
--- a/libavcodec/hqx.h
+++ b/libavcodec/hqx.h
@@ -24,7 +24,8 @@
 #include <stdint.h>
 
 #include "libavutil/frame.h"
-#include "libavutil/mem.h"
+#include "libavutil/mem_internal.h"
+
 #include "get_bits.h"
 #include "hqxdsp.h"
 
diff --git a/libavcodec/imm4.c b/libavcodec/imm4.c
index 4cbafffd9d..636130dd54 100644
--- a/libavcodec/imm4.c
+++ b/libavcodec/imm4.c
@@ -24,6 +24,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
 
 #include "avcodec.h"
diff --git a/libavcodec/mdct15.h b/libavcodec/mdct15.h
index 42e60f3e10..035246ff97 100644
--- a/libavcodec/mdct15.h
+++ b/libavcodec/mdct15.h
@@ -23,6 +23,8 @@
 
 #include <stddef.h>
 
+#include "libavutil/mem_internal.h"
+
 #include "fft.h"
 
 typedef struct MDCT15Context {
diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c
index b16cbb6a79..598fcfa0ec 100644
--- a/libavcodec/mdec.c
+++ b/libavcodec/mdec.c
@@ -27,6 +27,8 @@
  * This is very similar to intra-only MPEG-1.
  */
 
+#include "libavutil/mem_internal.h"
+
 #include "avcodec.h"
 #include "blockdsp.h"
 #include "bswapdsp.h"
diff --git a/libavcodec/mimic.c b/libavcodec/mimic.c
index ea6a7efe93..407faa02da 100644
--- a/libavcodec/mimic.c
+++ b/libavcodec/mimic.c
@@ -23,6 +23,7 @@
 #include <string.h>
 #include <stdint.h>
 
+#include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
 
 #include "avcodec.h"
diff --git a/libavcodec/mips/constants.c b/libavcodec/mips/constants.c
index a7c4a5ccf6..8c990b6119 100644
--- a/libavcodec/mips/constants.c
+++ b/libavcodec/mips/constants.c
@@ -20,7 +20,7 @@
  */
 
 #include "config.h"
-#include "libavutil/mem.h"
+#include "libavutil/mem_internal.h"
 #include "constants.h"
 
 DECLARE_ALIGNED(8, const uint64_t, ff_pw_1) =       {0x0001000100010001ULL};
diff --git a/libavcodec/mips/h264dsp_mmi.c b/libavcodec/mips/h264dsp_mmi.c
index 173e191c77..d4fcef0d65 100644
--- a/libavcodec/mips/h264dsp_mmi.c
+++ b/libavcodec/mips/h264dsp_mmi.c
@@ -26,6 +26,7 @@
 #include "libavcodec/bit_depth_template.c"
 #include "h264dsp_mips.h"
 #include "libavutil/mips/mmiutils.h"
+#include "libavutil/mem_internal.h"
 
 void ff_h264_add_pixels4_8_mmi(uint8_t *dst, int16_t *src, int stride)
 {
diff --git a/libavcodec/mips/simple_idct_mmi.c b/libavcodec/mips/simple_idct_mmi.c
index 73d797ffbc..e4b58dcfdd 100644
--- a/libavcodec/mips/simple_idct_mmi.c
+++ b/libavcodec/mips/simple_idct_mmi.c
@@ -26,6 +26,7 @@
 #include "constants.h"
 #include "libavutil/mips/asmdefs.h"
 #include "libavutil/mips/mmiutils.h"
+#include "libavutil/mem_internal.h"
 
 #define W1  22725  //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
 #define W2  21407  //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
diff --git a/libavcodec/mips/vc1dsp_mmi.c b/libavcodec/mips/vc1dsp_mmi.c
index 79f19a9b39..8355cd1b26 100644
--- a/libavcodec/mips/vc1dsp_mmi.c
+++ b/libavcodec/mips/vc1dsp_mmi.c
@@ -21,6 +21,8 @@
  */
 
 #include "libavutil/avassert.h"
+#include "libavutil/mem_internal.h"
+
 #include "libavcodec/vc1dsp.h"
 #include "constants.h"
 #include "vc1dsp_mips.h"
diff --git a/libavcodec/mips/vp8dsp_mmi.c b/libavcodec/mips/vp8dsp_mmi.c
index bd80aa1445..aa6e856dd2 100644
--- a/libavcodec/mips/vp8dsp_mmi.c
+++ b/libavcodec/mips/vp8dsp_mmi.c
@@ -24,6 +24,7 @@
 #include "vp8dsp_mips.h"
 #include "constants.h"
 #include "libavutil/mips/mmiutils.h"
+#include "libavutil/mem_internal.h"
 
 #define DECLARE_DOUBLE_1            double db_1
 #define DECLARE_DOUBLE_2            double db_2
diff --git a/libavcodec/mips/xvid_idct_mmi.c b/libavcodec/mips/xvid_idct_mmi.c
index b822b8add8..034a48d2a2 100644
--- a/libavcodec/mips/xvid_idct_mmi.c
+++ b/libavcodec/mips/xvid_idct_mmi.c
@@ -21,6 +21,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/mem_internal.h"
+
 #include "idctdsp_mips.h"
 #include "xvididct_mips.h"
 
diff --git a/libavcodec/mjpegdec.h b/libavcodec/mjpegdec.h
index d9844adf4e..fcbe58bcb8 100644
--- a/libavcodec/mjpegdec.h
+++ b/libavcodec/mjpegdec.h
@@ -30,6 +30,7 @@
 #define AVCODEC_MJPEGDEC_H
 
 #include "libavutil/log.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/stereo3d.h"
 
diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index ed25b71d2d..19d53b6c38 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -30,6 +30,7 @@
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/channel_layout.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
 #include "get_bits.h"
 #include "internal.h"
diff --git a/libavcodec/mpc.h b/libavcodec/mpc.h
index 704edc9a38..f8093796a3 100644
--- a/libavcodec/mpc.h
+++ b/libavcodec/mpc.h
@@ -30,6 +30,7 @@
 #define AVCODEC_MPC_H
 
 #include "libavutil/lfg.h"
+#include "libavutil/mem_internal.h"
 
 #include "avcodec.h"
 #include "bswapdsp.h"
diff --git a/libavcodec/mpegaudiodec_template.c b/libavcodec/mpegaudiodec_template.c
index 0ceeee2d46..4fd9e3a690 100644
--- a/libavcodec/mpegaudiodec_template.c
+++ b/libavcodec/mpegaudiodec_template.c
@@ -30,7 +30,9 @@
 #include "libavutil/crc.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/libm.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
+
 #include "avcodec.h"
 #include "get_bits.h"
 #include "internal.h"
diff --git a/libavcodec/mpegaudiodsp_template.c b/libavcodec/mpegaudiodsp_template.c
index c67c456e8a..97317967a2 100644
--- a/libavcodec/mpegaudiodsp_template.c
+++ b/libavcodec/mpegaudiodsp_template.c
@@ -22,7 +22,9 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/mem.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
+
 #include "dct32.h"
 #include "mathops.h"
 #include "mpegaudiodsp.h"
diff --git a/libavcodec/nellymoserdec.c b/libavcodec/nellymoserdec.c
index 49a21b43ce..b115f9146e 100644
--- a/libavcodec/nellymoserdec.c
+++ b/libavcodec/nellymoserdec.c
@@ -34,6 +34,7 @@
 #include "libavutil/channel_layout.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/lfg.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/random_seed.h"
 
 #define BITSTREAM_READER_LE
diff --git a/libavcodec/on2avc.c b/libavcodec/on2avc.c
index 3885f9acd7..d7a3e4945a 100644
--- a/libavcodec/on2avc.c
+++ b/libavcodec/on2avc.c
@@ -23,6 +23,8 @@
 #include "libavutil/channel_layout.h"
 #include "libavutil/ffmath.h"
 #include "libavutil/float_dsp.h"
+#include "libavutil/mem_internal.h"
+
 #include "avcodec.h"
 #include "bytestream.h"
 #include "fft.h"
diff --git a/libavcodec/opus.h b/libavcodec/opus.h
index 63ecd0aff7..464179beb8 100644
--- a/libavcodec/opus.h
+++ b/libavcodec/opus.h
@@ -28,6 +28,7 @@
 #include "libavutil/audio_fifo.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/frame.h"
+#include "libavutil/mem_internal.h"
 
 #include "libswresample/swresample.h"
 
diff --git a/libavcodec/opus_celt.h b/libavcodec/opus_celt.h
index 7c1c5316b9..661ca251de 100644
--- a/libavcodec/opus_celt.h
+++ b/libavcodec/opus_celt.h
@@ -33,6 +33,7 @@
 #include "mdct15.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/libm.h"
+#include "libavutil/mem_internal.h"
 
 #define CELT_VECTORS                 11
 #define CELT_ALLOC_STEPS             6
diff --git a/libavcodec/opus_pvq.h b/libavcodec/opus_pvq.h
index 52f9a4e6d4..b30407f5ab 100644
--- a/libavcodec/opus_pvq.h
+++ b/libavcodec/opus_pvq.h
@@ -23,6 +23,8 @@
 #ifndef AVCODEC_OPUS_PVQ_H
 #define AVCODEC_OPUS_PVQ_H
 
+#include "libavutil/mem_internal.h"
+
 #include "opus_celt.h"
 
 #define QUANT_FN(name) uint32_t (name)(struct CeltPVQ *pvq, CeltFrame *f,            \
diff --git a/libavcodec/opusenc.c b/libavcodec/opusenc.c
index 953749af3a..8bc9e9dc4a 100644
--- a/libavcodec/opusenc.c
+++ b/libavcodec/opusenc.c
@@ -25,6 +25,7 @@
 #include "opustab.h"
 
 #include "libavutil/float_dsp.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/opt.h"
 #include "internal.h"
 #include "bytestream.h"
diff --git a/libavcodec/opusenc_psy.h b/libavcodec/opusenc_psy.h
index b91e4f1b8b..d4fb096a3d 100644
--- a/libavcodec/opusenc_psy.h
+++ b/libavcodec/opusenc_psy.h
@@ -22,6 +22,8 @@
 #ifndef AVCODEC_OPUSENC_PSY_H
 #define AVCODEC_OPUSENC_PSY_H
 
+#include "libavutil/mem_internal.h"
+
 #include "opusenc.h"
 #include "opusenc_utils.h"
 #include "libavfilter/window_func.h"
diff --git a/libavcodec/opustab.c b/libavcodec/opustab.c
index 64070f8299..39153464d1 100644
--- a/libavcodec/opustab.c
+++ b/libavcodec/opustab.c
@@ -20,6 +20,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/mem_internal.h"
+
 #include "opustab.h"
 
 const uint8_t ff_opus_default_coupled_streams[] = { 0, 1, 1, 2, 2, 2, 2, 3 };
diff --git a/libavcodec/ppc/h264chroma_template.c b/libavcodec/ppc/h264chroma_template.c
index 8f43e5dee1..eda98c67ec 100644
--- a/libavcodec/ppc/h264chroma_template.c
+++ b/libavcodec/ppc/h264chroma_template.c
@@ -18,7 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavutil/mem.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/ppc/util_altivec.h"
 
 /* this code assume that stride % 16 == 0 */
diff --git a/libavcodec/ppc/h264dsp.c b/libavcodec/ppc/h264dsp.c
index d8a3baa34d..779092fd76 100644
--- a/libavcodec/ppc/h264dsp.c
+++ b/libavcodec/ppc/h264dsp.c
@@ -26,7 +26,7 @@
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mem.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/ppc/cpu.h"
 #include "libavutil/ppc/util_altivec.h"
 
diff --git a/libavcodec/ppc/h264qpel.c b/libavcodec/ppc/h264qpel.c
index bef421fa4f..fe896c8453 100644
--- a/libavcodec/ppc/h264qpel.c
+++ b/libavcodec/ppc/h264qpel.c
@@ -23,6 +23,7 @@
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
 #include "libavutil/intreadwrite.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/ppc/cpu.h"
 #include "libavutil/ppc/util_altivec.h"
 
diff --git a/libavcodec/ppc/mpegvideo_altivec.c b/libavcodec/ppc/mpegvideo_altivec.c
index 2c6ff9165b..bcb59ba845 100644
--- a/libavcodec/ppc/mpegvideo_altivec.c
+++ b/libavcodec/ppc/mpegvideo_altivec.c
@@ -28,6 +28,7 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/ppc/cpu.h"
 #include "libavutil/ppc/util_altivec.h"
 
diff --git a/libavcodec/ppc/mpegvideodsp.c b/libavcodec/ppc/mpegvideodsp.c
index 990a974a4e..81f4845e6e 100644
--- a/libavcodec/ppc/mpegvideodsp.c
+++ b/libavcodec/ppc/mpegvideodsp.c
@@ -21,7 +21,7 @@
  */
 
 #include "libavutil/cpu.h"
-#include "libavutil/mem.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/ppc/cpu.h"
 #include "libavutil/ppc/util_altivec.h"
 
diff --git a/libavcodec/ppc/vp8dsp_altivec.c b/libavcodec/ppc/vp8dsp_altivec.c
index 31201ed2d8..64ee703dc7 100644
--- a/libavcodec/ppc/vp8dsp_altivec.c
+++ b/libavcodec/ppc/vp8dsp_altivec.c
@@ -23,7 +23,7 @@
 #include "config.h"
 
 #include "libavutil/cpu.h"
-#include "libavutil/mem.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/ppc/cpu.h"
 #include "libavutil/ppc/util_altivec.h"
 
diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
index 8e6f905a9f..0e70163bcc 100644
--- a/libavcodec/proresenc_kostya.c
+++ b/libavcodec/proresenc_kostya.c
@@ -23,6 +23,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/mem_internal.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "avcodec.h"
diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c
index fbc4c0cfdd..8d4ad384e9 100644
--- a/libavcodec/qdm2.c
+++ b/libavcodec/qdm2.c
@@ -36,6 +36,7 @@
 #include <stdio.h>
 
 #include "libavutil/channel_layout.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
 
 #define BITSTREAM_READER_LE
diff --git a/libavcodec/ra144.h b/libavcodec/ra144.h
index 19a4ce09fe..82ef852884 100644
--- a/libavcodec/ra144.h
+++ b/libavcodec/ra144.h
@@ -23,6 +23,9 @@
 #define AVCODEC_RA144_H
 
 #include <stdint.h>
+
+#include "libavutil/mem_internal.h"
+
 #include "lpc.h"
 #include "audio_frame_queue.h"
 #include "audiodsp.h"
diff --git a/libavcodec/ra288.h b/libavcodec/ra288.h
index fa0b528b8a..96b074bffb 100644
--- a/libavcodec/ra288.h
+++ b/libavcodec/ra288.h
@@ -24,6 +24,7 @@
 
 #include <stdint.h>
 #include "libavutil/common.h"
+#include "libavutil/mem_internal.h"
 
 static const float amptable[8]={
      0.515625,  0.90234375,  1.57910156,  2.76342773,
diff --git a/libavcodec/rtjpeg.h b/libavcodec/rtjpeg.h
index d22ff4070e..d4dc074408 100644
--- a/libavcodec/rtjpeg.h
+++ b/libavcodec/rtjpeg.h
@@ -24,7 +24,7 @@
 
 #include <stdint.h>
 
-#include "libavutil/mem.h"
+#include "libavutil/mem_internal.h"
 #include "idctdsp.h"
 
 #define RTJPEG_FILE_VERSION 0
diff --git a/libavcodec/rv34.h b/libavcodec/rv34.h
index 1d5522538b..53b29dc245 100644
--- a/libavcodec/rv34.h
+++ b/libavcodec/rv34.h
@@ -27,6 +27,8 @@
 #ifndef AVCODEC_RV34_H
 #define AVCODEC_RV34_H
 
+#include "libavutil/mem_internal.h"
+
 #include "avcodec.h"
 #include "mpegvideo.h"
 
diff --git a/libavcodec/sbc.h b/libavcodec/sbc.h
index de9c8d9aed..419c8eab90 100644
--- a/libavcodec/sbc.h
+++ b/libavcodec/sbc.h
@@ -35,6 +35,7 @@
 
 #include "avcodec.h"
 #include "libavutil/crc.h"
+#include "libavutil/mem_internal.h"
 
 #define MSBC_BLOCKS 15
 
diff --git a/libavcodec/sbcdec.c b/libavcodec/sbcdec.c
index 5361ee2c89..8146560769 100644
--- a/libavcodec/sbcdec.c
+++ b/libavcodec/sbcdec.c
@@ -33,6 +33,7 @@
 #include "avcodec.h"
 #include "internal.h"
 #include "libavutil/intreadwrite.h"
+#include "libavutil/mem_internal.h"
 #include "sbc.h"
 #include "sbcdec_data.h"
 
diff --git a/libavcodec/sbcdsp.h b/libavcodec/sbcdsp.h
index 334c058e6d..24264df51d 100644
--- a/libavcodec/sbcdsp.h
+++ b/libavcodec/sbcdsp.h
@@ -32,6 +32,8 @@
 #ifndef AVCODEC_SBCDSP_H
 #define AVCODEC_SBCDSP_H
 
+#include "libavutil/mem_internal.h"
+
 #include "sbc.h"
 #include "sbcdsp_data.h"
 
diff --git a/libavcodec/sbcdsp_data.c b/libavcodec/sbcdsp_data.c
index 78c07c0077..ad6390c7cf 100644
--- a/libavcodec/sbcdsp_data.c
+++ b/libavcodec/sbcdsp_data.c
@@ -29,6 +29,8 @@
  * miscellaneous SBC tables
  */
 
+#include "libavutil/mem_internal.h"
+
 #include "sbcdsp_data.h"
 
 #define F_PROTO(x) ((int32_t) (((x) * 2) * ((int32_t) 1 << 15) + 0.5))
diff --git a/libavcodec/sbr.h b/libavcodec/sbr.h
index eb7d1aec09..f80f122c51 100644
--- a/libavcodec/sbr.h
+++ b/libavcodec/sbr.h
@@ -30,6 +30,9 @@
 #define AVCODEC_SBR_H
 
 #include <stdint.h>
+
+#include "libavutil/mem_internal.h"
+
 #include "fft.h"
 #include "aacps.h"
 #include "sbrdsp.h"
diff --git a/libavcodec/sinewin.h b/libavcodec/sinewin.h
index 1348740905..e6de4dfe7b 100644
--- a/libavcodec/sinewin.h
+++ b/libavcodec/sinewin.h
@@ -22,7 +22,7 @@
 #define AVCODEC_SINEWIN_H
 
 #include "config.h"
-#include "libavutil/mem.h"
+#include "libavutil/mem_internal.h"
 #include "libavcodec/aac_defines.h"
 
 #if CONFIG_HARDCODED_TABLES
diff --git a/libavcodec/sipr.h b/libavcodec/sipr.h
index 34f7f994cd..e1ef35d658 100644
--- a/libavcodec/sipr.h
+++ b/libavcodec/sipr.h
@@ -26,7 +26,7 @@
 
 #include "avcodec.h"
 #include "acelp_pitch_delay.h"
-#include "libavutil/mem.h"
+#include "libavutil/mem_internal.h"
 
 #define LP_FILTER_ORDER_16k  16
 #define L_SUBFR_16k          80
diff --git a/libavcodec/siren.c b/libavcodec/siren.c
index b1b4944562..3d0cdd4554 100644
--- a/libavcodec/siren.c
+++ b/libavcodec/siren.c
@@ -23,6 +23,7 @@
 
 #include "libavutil/tx.h"
 #include "libavutil/float_dsp.h"
+#include "libavutil/mem_internal.h"
 
 #include "avcodec.h"
 #include "get_bits.h"
diff --git a/libavcodec/svq1_cb.h b/libavcodec/svq1_cb.h
index 11f79691cd..30cca19acc 100644
--- a/libavcodec/svq1_cb.h
+++ b/libavcodec/svq1_cb.h
@@ -34,7 +34,7 @@
 #include <stdint.h>
 #include <stdlib.h>
 
-#include "libavutil/mem.h"
+#include "libavutil/mem_internal.h"
 
 /* 6x16-entry codebook for inter-coded 4x2 vectors */
 DECLARE_ALIGNED(4, static const int8_t, svq1_inter_codebook_4x2)[768] = {
diff --git a/libavcodec/svq1enc.h b/libavcodec/svq1enc.h
index b4ef763417..bb6af082d5 100644
--- a/libavcodec/svq1enc.h
+++ b/libavcodec/svq1enc.h
@@ -24,6 +24,7 @@
 #include <stdint.h>
 
 #include "libavutil/frame.h"
+#include "libavutil/mem_internal.h"
 
 #include "avcodec.h"
 #include "hpeldsp.h"
diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c
index fb7b992496..54ef4add06 100644
--- a/libavcodec/svq3.c
+++ b/libavcodec/svq3.c
@@ -44,6 +44,7 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/crc.h"
+#include "libavutil/mem_internal.h"
 
 #include "internal.h"
 #include "avcodec.h"
diff --git a/libavcodec/tableprint.h b/libavcodec/tableprint.h
index 6f61c7124b..e57eeb6ca6 100644
--- a/libavcodec/tableprint.h
+++ b/libavcodec/tableprint.h
@@ -27,6 +27,7 @@
 #include <stdio.h>
 
 #include "libavutil/common.h"
+#include "libavutil/mem_internal.h"
 
 #define WRITE_1D_FUNC_ARGV(type, linebrk, fmtstr, ...)\
 void write_##type##_array(const type *data, int len)\
diff --git a/libavcodec/takdec.c b/libavcodec/takdec.c
index 9fa1cb1f7f..5eb7123c67 100644
--- a/libavcodec/takdec.c
+++ b/libavcodec/takdec.c
@@ -26,6 +26,7 @@
  */
 
 #include "libavutil/internal.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/samplefmt.h"
 
 #define BITSTREAM_READER_LE
diff --git a/libavcodec/truespeech.c b/libavcodec/truespeech.c
index 3cdae8c556..272fc43deb 100644
--- a/libavcodec/truespeech.c
+++ b/libavcodec/truespeech.c
@@ -21,6 +21,8 @@
 
 #include "libavutil/channel_layout.h"
 #include "libavutil/intreadwrite.h"
+#include "libavutil/mem_internal.h"
+
 #include "avcodec.h"
 #include "bswapdsp.h"
 #include "get_bits.h"
diff --git a/libavcodec/vorbis_data.c b/libavcodec/vorbis_data.c
index 063a075ce0..4dba6a8cd3 100644
--- a/libavcodec/vorbis_data.c
+++ b/libavcodec/vorbis_data.c
@@ -19,7 +19,8 @@
  */
 
 #include "libavutil/channel_layout.h"
-#include "libavutil/mem.h"
+#include "libavutil/mem_internal.h"
+
 #include "vorbis.h"
 
 const uint8_t ff_vorbis_channel_layout_offsets[8][8] = {
diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
index cf64a8c61e..2a1da6b062 100644
--- a/libavcodec/vp3.c
+++ b/libavcodec/vp3.c
@@ -35,6 +35,7 @@
 #include <string.h>
 
 #include "libavutil/imgutils.h"
+#include "libavutil/mem_internal.h"
 
 #include "avcodec.h"
 #include "get_bits.h"
diff --git a/libavcodec/vp56.h b/libavcodec/vp56.h
index 65cf46870a..46090f25c9 100644
--- a/libavcodec/vp56.h
+++ b/libavcodec/vp56.h
@@ -26,6 +26,8 @@
 #ifndef AVCODEC_VP56_H
 #define AVCODEC_VP56_H
 
+#include "libavutil/mem_internal.h"
+
 #include "avcodec.h"
 #include "get_bits.h"
 #include "hpeldsp.h"
diff --git a/libavcodec/vp8.h b/libavcodec/vp8.h
index 70d21e3c60..e6091dfe04 100644
--- a/libavcodec/vp8.h
+++ b/libavcodec/vp8.h
@@ -29,6 +29,7 @@
 #include <stdatomic.h>
 
 #include "libavutil/buffer.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
 
 #include "h264pred.h"
diff --git a/libavcodec/vp9dec.h b/libavcodec/vp9dec.h
index cc2440b854..d82b258a3d 100644
--- a/libavcodec/vp9dec.h
+++ b/libavcodec/vp9dec.h
@@ -29,6 +29,7 @@
 #include <stdatomic.h>
 
 #include "libavutil/buffer.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
 #include "libavutil/internal.h"
 
diff --git a/libavcodec/vp9dsp.c b/libavcodec/vp9dsp.c
index f6d73f73cd..41b8ad1ad1 100644
--- a/libavcodec/vp9dsp.c
+++ b/libavcodec/vp9dsp.c
@@ -23,6 +23,8 @@
 
 #include "libavutil/avassert.h"
 #include "libavutil/common.h"
+#include "libavutil/mem_internal.h"
+
 #include "vp9dsp.h"
 
 const DECLARE_ALIGNED(16, int16_t, ff_vp9_subpel_filters)[3][16][8] = {
diff --git a/libavcodec/wma.h b/libavcodec/wma.h
index 7935bcdb31..aea7ba28ab 100644
--- a/libavcodec/wma.h
+++ b/libavcodec/wma.h
@@ -23,6 +23,7 @@
 #define AVCODEC_WMA_H
 
 #include "libavutil/float_dsp.h"
+#include "libavutil/mem_internal.h"
 
 #include "avcodec.h"
 #include "fft.h"
diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c
index a8fd99774e..e1fcf8afeb 100644
--- a/libavcodec/wmalosslessdec.c
+++ b/libavcodec/wmalosslessdec.c
@@ -26,6 +26,7 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/avassert.h"
+#include "libavutil/mem_internal.h"
 
 #include "avcodec.h"
 #include "internal.h"
diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c
index 63e7680f9a..88ee5f4015 100644
--- a/libavcodec/wmaprodec.c
+++ b/libavcodec/wmaprodec.c
@@ -92,6 +92,8 @@
 #include "libavutil/float_dsp.h"
 #include "libavutil/intfloat.h"
 #include "libavutil/intreadwrite.h"
+#include "libavutil/mem_internal.h"
+
 #include "avcodec.h"
 #include "internal.h"
 #include "get_bits.h"
diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c
index a588bb6c84..fbdb865360 100644
--- a/libavcodec/wmavoice.c
+++ b/libavcodec/wmavoice.c
@@ -29,7 +29,7 @@
 
 #include "libavutil/channel_layout.h"
 #include "libavutil/float_dsp.h"
-#include "libavutil/mem.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
 #include "avcodec.h"
 #include "internal.h"
diff --git a/libavcodec/wmv2.h b/libavcodec/wmv2.h
index 0f459ae5ae..f425332c9a 100644
--- a/libavcodec/wmv2.h
+++ b/libavcodec/wmv2.h
@@ -21,6 +21,8 @@
 #ifndef AVCODEC_WMV2_H
 #define AVCODEC_WMV2_H
 
+#include "libavutil/mem_internal.h"
+
 #include "avcodec.h"
 #include "intrax8.h"
 #include "mpegvideo.h"
diff --git a/libavcodec/x86/constants.c b/libavcodec/x86/constants.c
index 4bfb78cc36..f2d267e85d 100644
--- a/libavcodec/x86/constants.c
+++ b/libavcodec/x86/constants.c
@@ -18,7 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavutil/mem.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/x86/asm.h" // for xmm_reg
 #include "constants.h"
 
diff --git a/libavcodec/x86/fdct.c b/libavcodec/x86/fdct.c
index 112566ded0..d77f60c86f 100644
--- a/libavcodec/x86/fdct.c
+++ b/libavcodec/x86/fdct.c
@@ -31,6 +31,7 @@
  */
 
 #include "libavutil/common.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/x86/asm.h"
 #include "fdct.h"
 
diff --git a/libavcodec/x86/me_cmp_init.c b/libavcodec/x86/me_cmp_init.c
index 6aec93e55f..701eb1ab25 100644
--- a/libavcodec/x86/me_cmp_init.c
+++ b/libavcodec/x86/me_cmp_init.c
@@ -24,6 +24,7 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/x86/asm.h"
 #include "libavutil/x86/cpu.h"
 #include "libavcodec/me_cmp.h"
diff --git a/libavcodec/x86/mpegvideoenc.c b/libavcodec/x86/mpegvideoenc.c
index c884cf121b..4bad6a87ef 100644
--- a/libavcodec/x86/mpegvideoenc.c
+++ b/libavcodec/x86/mpegvideoenc.c
@@ -21,6 +21,7 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/x86/asm.h"
 #include "libavutil/x86/cpu.h"
 #include "libavcodec/avcodec.h"
diff --git a/libavfilter/ebur128.c b/libavfilter/ebur128.c
index ca2fca0066..2e86974eba 100644
--- a/libavfilter/ebur128.c
+++ b/libavfilter/ebur128.c
@@ -49,6 +49,7 @@
 
 #include "libavutil/common.h"
 #include "libavutil/mem.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
 
 #define CHECK_ERROR(condition, errorcode, goto_point)                          \
diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c
index 39af74c221..471669500b 100644
--- a/libavfilter/vf_colorspace.c
+++ b/libavfilter/vf_colorspace.c
@@ -24,6 +24,7 @@
  */
 
 #include "libavutil/avassert.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/pixfmt.h"
diff --git a/libavfilter/vf_dctdnoiz.c b/libavfilter/vf_dctdnoiz.c
index cdbe5f853f..a89f2631c8 100644
--- a/libavfilter/vf_dctdnoiz.c
+++ b/libavfilter/vf_dctdnoiz.c
@@ -30,6 +30,7 @@
 
 #include "libavutil/avassert.h"
 #include "libavutil/eval.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/opt.h"
 #include "internal.h"
 
diff --git a/libavfilter/vf_fspp.c b/libavfilter/vf_fspp.c
index c6989046c4..e57e6f9ec6 100644
--- a/libavfilter/vf_fspp.c
+++ b/libavfilter/vf_fspp.c
@@ -37,6 +37,7 @@
 
 #include "libavutil/avassert.h"
 #include "libavutil/imgutils.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "internal.h"
diff --git a/libavfilter/vf_gradfun.c b/libavfilter/vf_gradfun.c
index f63128d72e..28da37ff93 100644
--- a/libavfilter/vf_gradfun.c
+++ b/libavfilter/vf_gradfun.c
@@ -35,6 +35,7 @@
 #include "libavutil/imgutils.h"
 #include "libavutil/common.h"
 #include "libavutil/cpu.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "avfilter.h"
diff --git a/libavfilter/vf_owdenoise.c b/libavfilter/vf_owdenoise.c
index 6d6c2a3d53..7dfe10f2f1 100644
--- a/libavfilter/vf_owdenoise.c
+++ b/libavfilter/vf_owdenoise.c
@@ -30,6 +30,7 @@
 
 #include "libavutil/imgutils.h"
 #include "libavutil/opt.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/pixdesc.h"
 #include "avfilter.h"
 #include "internal.h"
diff --git a/libavfilter/vf_pp7.c b/libavfilter/vf_pp7.c
index 570a1c90b9..66979d9a13 100644
--- a/libavfilter/vf_pp7.c
+++ b/libavfilter/vf_pp7.c
@@ -29,6 +29,7 @@
 
 #include "libavutil/avassert.h"
 #include "libavutil/imgutils.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "internal.h"
diff --git a/libavfilter/vf_spp.c b/libavfilter/vf_spp.c
index 4bcc6429e0..54457ebb0b 100644
--- a/libavfilter/vf_spp.c
+++ b/libavfilter/vf_spp.c
@@ -33,6 +33,7 @@
 
 #include "libavutil/avassert.h"
 #include "libavutil/imgutils.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "internal.h"
diff --git a/libavfilter/vf_uspp.c b/libavfilter/vf_uspp.c
index 6a814350e8..1acef67ffb 100644
--- a/libavfilter/vf_uspp.c
+++ b/libavfilter/vf_uspp.c
@@ -29,6 +29,7 @@
 
 #include "libavutil/avassert.h"
 #include "libavutil/imgutils.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "internal.h"
diff --git a/libavutil/aes_internal.h b/libavutil/aes_internal.h
index 494425878d..beee626831 100644
--- a/libavutil/aes_internal.h
+++ b/libavutil/aes_internal.h
@@ -21,7 +21,7 @@
 #ifndef AVUTIL_AES_INTERNAL_H
 #define AVUTIL_AES_INTERNAL_H
 
-#include "mem.h"
+#include "mem_internal.h"
 #include <stdint.h>
 
 typedef union {
diff --git a/libavutil/internal.h b/libavutil/internal.h
index 80c5d06326..93ea57c324 100644
--- a/libavutil/internal.h
+++ b/libavutil/internal.h
@@ -43,7 +43,6 @@
 #include "cpu.h"
 #include "dict.h"
 #include "macros.h"
-#include "mem.h"
 #include "pixfmt.h"
 #include "version.h"
 
diff --git a/libavutil/lls.h b/libavutil/lls.h
index 1a276d537d..5f849206f7 100644
--- a/libavutil/lls.h
+++ b/libavutil/lls.h
@@ -24,7 +24,7 @@
 #define AVUTIL_LLS_H
 
 #include "macros.h"
-#include "mem.h"
+#include "mem_internal.h"
 #include "version.h"
 
 #define MAX_VARS 32
diff --git a/libavutil/mem.h b/libavutil/mem.h
index 5fb1a02dd9..e21a1feaae 100644
--- a/libavutil/mem.h
+++ b/libavutil/mem.h
@@ -33,6 +33,7 @@
 #include "attributes.h"
 #include "error.h"
 #include "avutil.h"
+#include "version.h"
 
 /**
  * @addtogroup lavu_mem
@@ -49,6 +50,10 @@
  * dealing with memory consistently possible on all platforms.
  *
  * @{
+ */
+
+#if FF_API_DECLARE_ALIGNED
+/**
  *
  * @defgroup lavu_mem_macros Alignment Macros
  * Helper macros for declaring aligned variables.
@@ -125,6 +130,7 @@
 /**
  * @}
  */
+#endif
 
 /**
  * @defgroup lavu_mem_attrs Function Attributes
diff --git a/libavutil/mem_internal.h b/libavutil/mem_internal.h
index 14f45c657f..ee2575c85f 100644
--- a/libavutil/mem_internal.h
+++ b/libavutil/mem_internal.h
@@ -27,6 +27,76 @@
 
 #include "avassert.h"
 #include "mem.h"
+#include "version.h"
+
+#if !FF_API_DECLARE_ALIGNED
+/**
+ * @def DECLARE_ALIGNED(n,t,v)
+ * Declare a variable that is aligned in memory.
+ *
+ * @code{.c}
+ * DECLARE_ALIGNED(16, uint16_t, aligned_int) = 42;
+ * DECLARE_ALIGNED(32, uint8_t, aligned_array)[128];
+ *
+ * // The default-alignment equivalent would be
+ * uint16_t aligned_int = 42;
+ * uint8_t aligned_array[128];
+ * @endcode
+ *
+ * @param n Minimum alignment in bytes
+ * @param t Type of the variable (or array element)
+ * @param v Name of the variable
+ */
+
+/**
+ * @def DECLARE_ASM_ALIGNED(n,t,v)
+ * Declare an aligned variable appropriate for use in inline assembly code.
+ *
+ * @code{.c}
+ * DECLARE_ASM_ALIGNED(16, uint64_t, pw_08) = UINT64_C(0x0008000800080008);
+ * @endcode
+ *
+ * @param n Minimum alignment in bytes
+ * @param t Type of the variable (or array element)
+ * @param v Name of the variable
+ */
+
+/**
+ * @def DECLARE_ASM_CONST(n,t,v)
+ * Declare a static constant aligned variable appropriate for use in inline
+ * assembly code.
+ *
+ * @code{.c}
+ * DECLARE_ASM_CONST(16, uint64_t, pw_08) = UINT64_C(0x0008000800080008);
+ * @endcode
+ *
+ * @param n Minimum alignment in bytes
+ * @param t Type of the variable (or array element)
+ * @param v Name of the variable
+ */
+
+#if defined(__INTEL_COMPILER) && __INTEL_COMPILER < 1110 || defined(__SUNPRO_C)
+    #define DECLARE_ALIGNED(n,t,v)      t __attribute__ ((aligned (n))) v
+    #define DECLARE_ASM_ALIGNED(n,t,v)  t __attribute__ ((aligned (n))) v
+    #define DECLARE_ASM_CONST(n,t,v)    const t __attribute__ ((aligned (n))) v
+#elif defined(__DJGPP__)
+    #define DECLARE_ALIGNED(n,t,v)      t __attribute__ ((aligned (FFMIN(n, 16)))) v
+    #define DECLARE_ASM_ALIGNED(n,t,v)  t av_used __attribute__ ((aligned (FFMIN(n, 16)))) v
+    #define DECLARE_ASM_CONST(n,t,v)    static const t av_used __attribute__ ((aligned (FFMIN(n, 16)))) v
+#elif defined(__GNUC__) || defined(__clang__)
+    #define DECLARE_ALIGNED(n,t,v)      t __attribute__ ((aligned (n))) v
+    #define DECLARE_ASM_ALIGNED(n,t,v)  t av_used __attribute__ ((aligned (n))) v
+    #define DECLARE_ASM_CONST(n,t,v)    static const t av_used __attribute__ ((aligned (n))) v
+#elif defined(_MSC_VER)
+    #define DECLARE_ALIGNED(n,t,v)      __declspec(align(n)) t v
+    #define DECLARE_ASM_ALIGNED(n,t,v)  __declspec(align(n)) t v
+    #define DECLARE_ASM_CONST(n,t,v)    __declspec(align(n)) static const t v
+#else
+    #define DECLARE_ALIGNED(n,t,v)      t v
+    #define DECLARE_ASM_ALIGNED(n,t,v)  t v
+    #define DECLARE_ASM_CONST(n,t,v)    static const t v
+#endif
+#endif
 
 // Some broken preprocessors need a second expansion
 // to be forced to tokenize __VA_ARGS__
diff --git a/libavutil/tests/aes_ctr.c b/libavutil/tests/aes_ctr.c
index 00fdb05d13..53d0e4a244 100644
--- a/libavutil/tests/aes_ctr.c
+++ b/libavutil/tests/aes_ctr.c
@@ -18,6 +18,7 @@
 
 #include "libavutil/log.h"
 #include "libavutil/mem.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/aes_ctr.h"
 
 static const DECLARE_ALIGNED(8, uint8_t, plain)[] = {
diff --git a/libavutil/tests/des.c b/libavutil/tests/des.c
index f2a5c34f1a..8fa88df684 100644
--- a/libavutil/tests/des.c
+++ b/libavutil/tests/des.c
@@ -16,6 +16,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/mem_internal.h"
 #include "libavutil/timer.h"
 
 #include "libavutil/des.c"
diff --git a/libavutil/tx_priv.h b/libavutil/tx_priv.h
index e0d980abfb..a3738f68bd 100644
--- a/libavutil/tx_priv.h
+++ b/libavutil/tx_priv.h
@@ -23,6 +23,7 @@
 #include <stddef.h>
 #include "thread.h"
 #include "mem.h"
+#include "mem_internal.h"
 #include "avassert.h"
 #include "attributes.h"
 
diff --git a/libavutil/version.h b/libavutil/version.h
index 9b311b5b27..085c4e30f9 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -135,6 +135,9 @@
 #ifndef FF_API_D2STR
 #define FF_API_D2STR                    (LIBAVUTIL_VERSION_MAJOR < 58)
 #endif
+#ifndef FF_API_DECLARE_ALIGNED
+#define FF_API_DECLARE_ALIGNED          (LIBAVUTIL_VERSION_MAJOR < 58)
+#endif
 
 /**
  * @}
diff --git a/libpostproc/postprocess_altivec_template.c b/libpostproc/postprocess_altivec_template.c
index fa6ebe279d..a9d4cd29a3 100644
--- a/libpostproc/postprocess_altivec_template.c
+++ b/libpostproc/postprocess_altivec_template.c
@@ -21,6 +21,7 @@
  */
 
 #include "libavutil/avutil.h"
+#include "libavutil/mem_internal.h"
 
 #define ALTIVEC_TRANSPOSE_8x8_SHORT(src_a,src_b,src_c,src_d,src_e,src_f,src_g,src_h) \
     do {                                                          \
diff --git a/libpostproc/postprocess_internal.h b/libpostproc/postprocess_internal.h
index 765fdeb14a..5d1aee362e 100644
--- a/libpostproc/postprocess_internal.h
+++ b/libpostproc/postprocess_internal.h
@@ -30,6 +30,7 @@
 #include "libavutil/avutil.h"
 #include "libavutil/intmath.h"
 #include "libavutil/log.h"
+#include "libavutil/mem_internal.h"
 #include "postprocess.h"
 
 #define V_DEBLOCK       0x01
diff --git a/libpostproc/postprocess_template.c b/libpostproc/postprocess_template.c
index df1684d1e2..411fc41915 100644
--- a/libpostproc/postprocess_template.c
+++ b/libpostproc/postprocess_template.c
@@ -23,6 +23,7 @@
  * mmx/mmx2/3dnow postprocess code.
  */
 
+#include "libavutil/mem_internal.h"
 #include "libavutil/x86/asm.h"
 
 /* A single TEMPLATE_PP_* should be defined (to 1) when this template is
diff --git a/libswscale/output.c b/libswscale/output.c
index 4ef436e7e4..e855ad606a 100644
--- a/libswscale/output.c
+++ b/libswscale/output.c
@@ -30,6 +30,7 @@
 #include "libavutil/cpu.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/mathematics.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/pixdesc.h"
 #include "config.h"
 #include "rgb2rgb.h"
diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
index 536545293d..58e480dd2c 100644
--- a/libswscale/ppc/yuv2rgb_altivec.c
+++ b/libswscale/ppc/yuv2rgb_altivec.c
@@ -96,6 +96,7 @@
 #include "libswscale/swscale_internal.h"
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/pixdesc.h"
 #include "yuv2rgb_altivec.h"
 
diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index 9cb7e8f6ac..12160a169a 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -30,6 +30,7 @@
 #include "libavutil/imgutils.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/mathematics.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/pixdesc.h"
 #include "config.h"
 #include "rgb2rgb.h"
diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index d207d3beff..a1de95cee0 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -29,6 +29,7 @@
 #include "libavutil/common.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/log.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/pixfmt.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/ppc/util_altivec.h"
diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c
index 563de39696..4778629379 100644
--- a/libswscale/swscale_unscaled.c
+++ b/libswscale/swscale_unscaled.c
@@ -30,6 +30,7 @@
 #include "libavutil/cpu.h"
 #include "libavutil/avutil.h"
 #include "libavutil/mathematics.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/bswap.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/avassert.h"
diff --git a/libswscale/x86/hscale_fast_bilinear_simd.c b/libswscale/x86/hscale_fast_bilinear_simd.c
index 60a2cbfc50..850f0add31 100644
--- a/libswscale/x86/hscale_fast_bilinear_simd.c
+++ b/libswscale/x86/hscale_fast_bilinear_simd.c
@@ -21,6 +21,7 @@
 #include "../swscale_internal.h"
 #include "libavutil/x86/asm.h"
 #include "libavutil/x86/cpu.h"
+#include "libavutil/mem_internal.h"
 
 #define RET 0xC3 // near return opcode for x86
 #define PREFETCH "prefetchnta"
diff --git a/libswscale/x86/rgb2rgb.c b/libswscale/x86/rgb2rgb.c
index 2d6fc2ad26..4344b5f714 100644
--- a/libswscale/x86/rgb2rgb.c
+++ b/libswscale/x86/rgb2rgb.c
@@ -30,6 +30,8 @@
 #include "libavutil/x86/cpu.h"
 #include "libavutil/cpu.h"
 #include "libavutil/bswap.h"
+#include "libavutil/mem_internal.h"
+
 #include "libswscale/rgb2rgb.h"
 #include "libswscale/swscale.h"
 #include "libswscale/swscale_internal.h"
diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c
index 3160fedf04..15c0b22f20 100644
--- a/libswscale/x86/swscale.c
+++ b/libswscale/x86/swscale.c
@@ -27,6 +27,7 @@
 #include "libavutil/intreadwrite.h"
 #include "libavutil/x86/cpu.h"
 #include "libavutil/cpu.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/pixdesc.h"
 
 const DECLARE_ALIGNED(8, uint64_t, ff_dither4)[2] = {
-- 
2.28.0



More information about the ffmpeg-devel mailing list