diff mbox series

[FFmpeg-devel,19/19] Remove unnecessary libavutil/(avutil|common|internal).h inclusions

Message ID AM7PR03MB66609FF2DEA54C40B3D5D1928F349@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Commit 636631d9db82f5e86330ab42dacc8a106684b349
Headers show
Series [FFmpeg-devel] avutil/x86/emms: Don't unnecessarily include lavu/cpu.h | expand

Checks

Context Check Description
andriy/commit_msg_armv7_RPi4 warning The first line of the commit message must start with a context terminated by a colon and a space, for example "lavu/opt: " or "doc: ".
andriy/commit_msg_aarch64_jetson warning The first line of the commit message must start with a context terminated by a colon and a space, for example "lavu/opt: " or "doc: ".
andriy/make_aarch64_jetson success Make finished
andriy/make_fate_aarch64_jetson success Make fate finished
andriy/make_armv7_RPi4 success Make finished
andriy/make_fate_armv7_RPi4 success Make fate finished
yinshiyou/commit_msg_loongarch64 warning The first line of the commit message must start with a context terminated by a colon and a space, for example "lavu/opt: " or "doc: ".
yinshiyou/configure_loongarch64 warning Failed to run configure
andriy/commit_msg_x86 warning The first line of the commit message must start with a context terminated by a colon and a space, for example "lavu/opt: " or "doc: ".
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/commit_msg_ppc warning The first line of the commit message must start with a context terminated by a colon and a space, for example "lavu/opt: " or "doc: ".
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Andreas Rheinhardt Feb. 15, 2022, 5:43 p.m. UTC
Some of these were made possible by moving several common macros to
libavutil/macros.h.

While just at it, also improve the other headers a bit.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/ac3.c                          |  3 ++-
 libavcodec/ac3.h                          |  1 +
 libavcodec/ass_split.c                    |  8 +++++++-
 libavcodec/av1_parse.h                    |  2 +-
 libavcodec/bitstream.c                    |  2 +-
 libavcodec/cabac.c                        |  5 +----
 libavcodec/celp_math.c                    |  7 +++----
 libavcodec/codec_desc.c                   |  3 ++-
 libavcodec/dca_exss.h                     |  2 +-
 libavcodec/dcadct.c                       |  2 +-
 libavcodec/dcadct.h                       |  3 ++-
 libavcodec/dcadec.h                       |  4 +++-
 libavcodec/dcahuff.c                      |  2 +-
 libavcodec/dirac_vlc.h                    |  2 +-
 libavcodec/dnxhddata.c                    |  4 +++-
 libavcodec/dnxhddata.h                    |  3 ++-
 libavcodec/dv_profile.c                   |  3 ++-
 libavcodec/elsdec.c                       |  7 +++++--
 libavcodec/exrdsp.h                       |  2 +-
 libavcodec/flacdsp.c                      |  1 +
 libavcodec/flacdsp.h                      |  2 +-
 libavcodec/flacdsp_lpc_template.c         |  2 +-
 libavcodec/flacdsp_template.c             |  2 +-
 libavcodec/fmtconvert.c                   |  3 ++-
 libavcodec/golomb.c                       |  2 +-
 libavcodec/h264_levels.c                  |  2 +-
 libavcodec/h264_redundant_pps_bsf.c       |  7 ++++---
 libavcodec/h264_sei.c                     |  2 +-
 libavcodec/huffman.c                      |  5 ++++-
 libavcodec/jfdctfst.c                     |  5 ++---
 libavcodec/jpeg2000dwt.c                  |  3 ++-
 libavcodec/jrevdct.c                      |  4 +++-
 libavcodec/lagarithrac.h                  |  1 -
 libavcodec/libopus.c                      |  1 -
 libavcodec/lsp.c                          |  4 ++--
 libavcodec/lzwenc.c                       |  2 +-
 libavcodec/mdct15.c                       |  3 ++-
 libavcodec/mips/mpegaudiodsp_mips_fixed.c |  1 +
 libavcodec/mips/mpegaudiodsp_mips_float.c |  1 +
 libavcodec/mjpegenc_huffman.c             |  3 ---
 libavcodec/mpegaudiodecheader.c           |  2 +-
 libavcodec/mpegaudiodsp.h                 |  2 +-
 libavcodec/msmpeg4data.h                  |  2 +-
 libavcodec/opusdsp.c                      |  2 ++
 libavcodec/opusdsp.h                      |  2 --
 libavcodec/pngdsp.c                       |  2 +-
 libavcodec/ra288.h                        |  2 +-
 libavcodec/rangecoder.h                   |  2 +-
 libavcodec/raw.c                          |  2 +-
 libavcodec/rle.c                          |  2 +-
 libavcodec/scpr3.h                        |  7 +------
 libavcodec/tests/cabac.c                  |  2 +-
 libavcodec/tests/jpeg2000dwt.c            |  5 +++++
 libavcodec/tests/rangecoder.c             |  1 +
 libavcodec/trace_headers_bsf.c            |  4 ++--
 libavcodec/videodsp.c                     |  3 ++-
 libavcodec/vp56data.h                     |  2 +-
 libavcodec/vp56rac.c                      |  4 +++-
 libavcodec/vp9dsp.c                       |  4 +++-
 libavcodec/wavpack.h                      |  5 ++++-
 libavcodec/wavpackenc.h                   |  2 ++
 libavcodec/x86/fdct.c                     |  3 ++-
 libavcodec/x86/mpegaudiodsp.c             |  4 +++-
 libavcodec/x86/pngdsp_init.c              |  3 ++-
 libavcodec/xiph.c                         |  2 ++
 libavcodec/xiph.h                         |  2 +-
 libavdevice/timefilter.c                  |  6 +++++-
 libavfilter/af_afir.h                     | 13 ++++++-------
 libavfilter/af_volume.h                   |  4 ++--
 libavfilter/avfiltergraph.c               |  2 --
 libavfilter/colorspace.h                  |  2 +-
 libavfilter/ebur128.c                     |  3 ++-
 libavfilter/motion_estimation.c           |  1 +
 libavfilter/motion_estimation.h           |  2 +-
 libavfilter/pthread.c                     |  6 +++---
 libavformat/argo_asf.h                    |  2 +-
 libavformat/asfcrypt.c                    |  3 ++-
 libavformat/avlanguage.c                  |  3 +--
 libavformat/hlsplaylist.h                 |  1 -
 libavformat/matroska.h                    |  2 +-
 libavformat/network.c                     |  1 -
 libavformat/riff.c                        |  3 ++-
 libavformat/tee_common.c                  |  5 +++--
 libavformat/webmdashenc.c                 |  2 ++
 libavformat/wv.c                          |  3 ++-
 libavutil/adler32.c                       |  2 +-
 libavutil/aes.c                           |  8 ++++++--
 libavutil/aes_ctr.c                       |  5 ++++-
 libavutil/avsscanf.c                      |  8 +++++---
 libavutil/avstring.c                      |  5 ++++-
 libavutil/base64.c                        |  6 ++++--
 libavutil/blowfish.c                      |  5 +++--
 libavutil/bprint.c                        |  3 ++-
 libavutil/buffer_internal.h               |  1 -
 libavutil/camellia.c                      |  6 +++++-
 libavutil/cast5.c                         |  6 +++++-
 libavutil/channel_layout.c                |  6 ++++--
 libavutil/color_utils.c                   |  1 -
 libavutil/crc.c                           |  2 +-
 libavutil/des.c                           |  6 ++++--
 libavutil/error.c                         |  7 +++++--
 libavutil/fixed_dsp.c                     |  1 +
 libavutil/fixed_dsp.h                     |  2 +-
 libavutil/lls.c                           |  2 +-
 libavutil/log.c                           |  4 +++-
 libavutil/lzo.c                           |  6 ++++--
 libavutil/mem.c                           |  9 +++++----
 libavutil/pixelutils.c                    | 12 +++++++++---
 libavutil/qsort.h                         |  2 +-
 libavutil/rc4.c                           |  5 +++--
 libavutil/ripemd.c                        |  4 +++-
 libavutil/sha.c                           |  3 ++-
 libavutil/sha512.c                        |  3 ++-
 libavutil/stereo3d.c                      |  3 ++-
 libavutil/tea.c                           |  4 ++--
 libavutil/tests/color_utils.c             |  2 ++
 libavutil/tests/pixelutils.c              |  4 ++++
 libavutil/twofish.c                       |  6 +++++-
 libavutil/video_enc_params.c              |  2 --
 libavutil/x86/imgutils_init.c             |  3 +--
 libavutil/xtea.c                          |  4 ++--
 libswscale/input.c                        |  6 ------
 libswscale/options.c                      |  2 --
 libswscale/rgb2rgb.h                      |  5 +----
 libswscale/swscale.c                      |  8 ++------
 libswscale/swscale_internal.h             |  1 -
 126 files changed, 260 insertions(+), 178 deletions(-)

Comments

Martin Storsjö Feb. 23, 2022, 3:02 p.m. UTC | #1
On Tue, 15 Feb 2022, Andreas Rheinhardt wrote:

> Some of these were made possible by moving several common macros to
> libavutil/macros.h.
>
> While just at it, also improve the other headers a bit.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> libavcodec/ac3.c                          |  3 ++-
> libavcodec/ac3.h                          |  1 +
> libavcodec/ass_split.c                    |  8 +++++++-
> libavcodec/av1_parse.h                    |  2 +-
> libavcodec/bitstream.c                    |  2 +-
> libavcodec/cabac.c                        |  5 +----
> libavcodec/celp_math.c                    |  7 +++----
> libavcodec/codec_desc.c                   |  3 ++-
> libavcodec/dca_exss.h                     |  2 +-
> libavcodec/dcadct.c                       |  2 +-
> libavcodec/dcadct.h                       |  3 ++-
> libavcodec/dcadec.h                       |  4 +++-
> libavcodec/dcahuff.c                      |  2 +-
> libavcodec/dirac_vlc.h                    |  2 +-
> libavcodec/dnxhddata.c                    |  4 +++-
> libavcodec/dnxhddata.h                    |  3 ++-
> libavcodec/dv_profile.c                   |  3 ++-
> libavcodec/elsdec.c                       |  7 +++++--
> libavcodec/exrdsp.h                       |  2 +-
> libavcodec/flacdsp.c                      |  1 +
> libavcodec/flacdsp.h                      |  2 +-
> libavcodec/flacdsp_lpc_template.c         |  2 +-
> libavcodec/flacdsp_template.c             |  2 +-
> libavcodec/fmtconvert.c                   |  3 ++-
> libavcodec/golomb.c                       |  2 +-
> libavcodec/h264_levels.c                  |  2 +-
> libavcodec/h264_redundant_pps_bsf.c       |  7 ++++---
> libavcodec/h264_sei.c                     |  2 +-
> libavcodec/huffman.c                      |  5 ++++-
> libavcodec/jfdctfst.c                     |  5 ++---
> libavcodec/jpeg2000dwt.c                  |  3 ++-
> libavcodec/jrevdct.c                      |  4 +++-
> libavcodec/lagarithrac.h                  |  1 -
> libavcodec/libopus.c                      |  1 -
> libavcodec/lsp.c                          |  4 ++--
> libavcodec/lzwenc.c                       |  2 +-
> libavcodec/mdct15.c                       |  3 ++-
> libavcodec/mips/mpegaudiodsp_mips_fixed.c |  1 +
> libavcodec/mips/mpegaudiodsp_mips_float.c |  1 +
> libavcodec/mjpegenc_huffman.c             |  3 ---
> libavcodec/mpegaudiodecheader.c           |  2 +-
> libavcodec/mpegaudiodsp.h                 |  2 +-
> libavcodec/msmpeg4data.h                  |  2 +-
> libavcodec/opusdsp.c                      |  2 ++
> libavcodec/opusdsp.h                      |  2 --
> libavcodec/pngdsp.c                       |  2 +-
> libavcodec/ra288.h                        |  2 +-
> libavcodec/rangecoder.h                   |  2 +-
> libavcodec/raw.c                          |  2 +-
> libavcodec/rle.c                          |  2 +-
> libavcodec/scpr3.h                        |  7 +------
> libavcodec/tests/cabac.c                  |  2 +-
> libavcodec/tests/jpeg2000dwt.c            |  5 +++++
> libavcodec/tests/rangecoder.c             |  1 +
> libavcodec/trace_headers_bsf.c            |  4 ++--
> libavcodec/videodsp.c                     |  3 ++-
> libavcodec/vp56data.h                     |  2 +-
> libavcodec/vp56rac.c                      |  4 +++-
> libavcodec/vp9dsp.c                       |  4 +++-
> libavcodec/wavpack.h                      |  5 ++++-
> libavcodec/wavpackenc.h                   |  2 ++
> libavcodec/x86/fdct.c                     |  3 ++-
> libavcodec/x86/mpegaudiodsp.c             |  4 +++-
> libavcodec/x86/pngdsp_init.c              |  3 ++-
> libavcodec/xiph.c                         |  2 ++
> libavcodec/xiph.h                         |  2 +-
> libavdevice/timefilter.c                  |  6 +++++-
> libavfilter/af_afir.h                     | 13 ++++++-------
> libavfilter/af_volume.h                   |  4 ++--
> libavfilter/avfiltergraph.c               |  2 --
> libavfilter/colorspace.h                  |  2 +-
> libavfilter/ebur128.c                     |  3 ++-
> libavfilter/motion_estimation.c           |  1 +
> libavfilter/motion_estimation.h           |  2 +-
> libavfilter/pthread.c                     |  6 +++---
> libavformat/argo_asf.h                    |  2 +-
> libavformat/asfcrypt.c                    |  3 ++-
> libavformat/avlanguage.c                  |  3 +--
> libavformat/hlsplaylist.h                 |  1 -
> libavformat/matroska.h                    |  2 +-
> libavformat/network.c                     |  1 -
> libavformat/riff.c                        |  3 ++-
> libavformat/tee_common.c                  |  5 +++--
> libavformat/webmdashenc.c                 |  2 ++
> libavformat/wv.c                          |  3 ++-
> libavutil/adler32.c                       |  2 +-
> libavutil/aes.c                           |  8 ++++++--
> libavutil/aes_ctr.c                       |  5 ++++-
> libavutil/avsscanf.c                      |  8 +++++---
> libavutil/avstring.c                      |  5 ++++-
> libavutil/base64.c                        |  6 ++++--
> libavutil/blowfish.c                      |  5 +++--
> libavutil/bprint.c                        |  3 ++-
> libavutil/buffer_internal.h               |  1 -
> libavutil/camellia.c                      |  6 +++++-
> libavutil/cast5.c                         |  6 +++++-
> libavutil/channel_layout.c                |  6 ++++--
> libavutil/color_utils.c                   |  1 -
> libavutil/crc.c                           |  2 +-
> libavutil/des.c                           |  6 ++++--
> libavutil/error.c                         |  7 +++++--
> libavutil/fixed_dsp.c                     |  1 +
> libavutil/fixed_dsp.h                     |  2 +-
> libavutil/lls.c                           |  2 +-
> libavutil/log.c                           |  4 +++-
> libavutil/lzo.c                           |  6 ++++--
> libavutil/mem.c                           |  9 +++++----
> libavutil/pixelutils.c                    | 12 +++++++++---
> libavutil/qsort.h                         |  2 +-
> libavutil/rc4.c                           |  5 +++--
> libavutil/ripemd.c                        |  4 +++-
> libavutil/sha.c                           |  3 ++-
> libavutil/sha512.c                        |  3 ++-
> libavutil/stereo3d.c                      |  3 ++-
> libavutil/tea.c                           |  4 ++--
> libavutil/tests/color_utils.c             |  2 ++
> libavutil/tests/pixelutils.c              |  4 ++++
> libavutil/twofish.c                       |  6 +++++-
> libavutil/video_enc_params.c              |  2 --
> libavutil/x86/imgutils_init.c             |  3 +--
> libavutil/xtea.c                          |  4 ++--
> libswscale/input.c                        |  6 ------
> libswscale/options.c                      |  2 --
> libswscale/rgb2rgb.h                      |  5 +----
> libswscale/swscale.c                      |  8 ++------
> libswscale/swscale_internal.h             |  1 -
> 126 files changed, 260 insertions(+), 178 deletions(-)

LGTM

// Martin
diff mbox series

Patch

diff --git a/libavcodec/ac3.c b/libavcodec/ac3.c
index a0fd00138f..e1d0f12073 100644
--- a/libavcodec/ac3.c
+++ b/libavcodec/ac3.c
@@ -24,7 +24,8 @@ 
  * Common code between the AC-3 encoder and decoder.
  */
 
-#include "libavutil/common.h"
+#include "libavutil/error.h"
+#include "libavutil/macros.h"
 
 #include "ac3.h"
 
diff --git a/libavcodec/ac3.h b/libavcodec/ac3.h
index 0e52028111..dabd49f4cc 100644
--- a/libavcodec/ac3.h
+++ b/libavcodec/ac3.h
@@ -78,6 +78,7 @@  typedef int                     INTFLOAT;
 typedef int16_t                 SHORTFLOAT;
 
 #else /* USE_FIXED */
+#include "libavutil/libm.h"
 
 #define FIXR(x)                 ((float)(x))
 #define FIXR12(x)               ((float)(x))
diff --git a/libavcodec/ass_split.c b/libavcodec/ass_split.c
index 05c5453e53..73ef6196c5 100644
--- a/libavcodec/ass_split.c
+++ b/libavcodec/ass_split.c
@@ -19,8 +19,14 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavutil/common.h"
+#include <limits.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+
 #include "libavutil/error.h"
+#include "libavutil/macros.h"
 #include "libavutil/mem.h"
 #include "ass_split.h"
 
diff --git a/libavcodec/av1_parse.h b/libavcodec/av1_parse.h
index 3861d80b4c..f4a5d2830e 100644
--- a/libavcodec/av1_parse.h
+++ b/libavcodec/av1_parse.h
@@ -24,9 +24,9 @@ 
 #include <limits.h>
 #include <stdint.h>
 
-#include "libavutil/common.h"
 #include "libavutil/error.h"
 #include "libavutil/intmath.h"
+#include "libavutil/macros.h"
 
 #include "av1.h"
 #include "get_bits.h"
diff --git a/libavcodec/bitstream.c b/libavcodec/bitstream.c
index 2dd0226614..c948c889b6 100644
--- a/libavcodec/bitstream.c
+++ b/libavcodec/bitstream.c
@@ -36,11 +36,11 @@ 
 #include "config.h"
 #include "libavutil/avassert.h"
 #include "libavutil/bswap.h"
-#include "libavutil/common.h"
 #include "libavutil/error.h"
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/log.h"
+#include "libavutil/macros.h"
 #include "libavutil/mem.h"
 #include "libavutil/qsort.h"
 #include "mathops.h"
diff --git a/libavcodec/cabac.c b/libavcodec/cabac.c
index 6649feebeb..7d41cd2ae6 100644
--- a/libavcodec/cabac.c
+++ b/libavcodec/cabac.c
@@ -24,13 +24,10 @@ 
  * Context Adaptive Binary Arithmetic Coder.
  */
 
-#include <string.h>
-
-#include "libavutil/common.h"
+#include "libavutil/error.h"
 #include "libavutil/mem_internal.h"
 
 #include "cabac.h"
-#include "cabac_functions.h"
 
 DECLARE_ASM_ALIGNED(1, const uint8_t, ff_h264_cabac_tables)[512 + 4*2*64 + 4*64 + 63] = {
     9,8,7,7,6,6,6,6,5,5,5,5,5,5,5,5,
diff --git a/libavcodec/celp_math.c b/libavcodec/celp_math.c
index 920995a879..f4bbd158ab 100644
--- a/libavcodec/celp_math.c
+++ b/libavcodec/celp_math.c
@@ -20,14 +20,13 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include <inttypes.h>
-#include <limits.h>
+#include <stdint.h>
 
+#include "config.h"
 #include "libavutil/avassert.h"
-#include "avcodec.h"
+#include "libavutil/intmath.h"
 #include "mathops.h"
 #include "celp_math.h"
-#include "libavutil/common.h"
 
 #ifdef G729_BITEXACT
 static const uint16_t exp2a[]=
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 0974ee03de..725c687b00 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -19,10 +19,11 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <stdlib.h>
 #include <string.h>
 
-#include "libavutil/common.h"
 #include "libavutil/internal.h"
+#include "libavutil/macros.h"
 
 #include "codec_id.h"
 #include "codec_desc.h"
diff --git a/libavcodec/dca_exss.h b/libavcodec/dca_exss.h
index 208fae1b85..9e91b00bfd 100644
--- a/libavcodec/dca_exss.h
+++ b/libavcodec/dca_exss.h
@@ -21,7 +21,7 @@ 
 #ifndef AVCODEC_DCA_EXSS_H
 #define AVCODEC_DCA_EXSS_H
 
-#include "libavutil/common.h"
+#include <stdint.h>
 
 #include "avcodec.h"
 #include "get_bits.h"
diff --git a/libavcodec/dcadct.c b/libavcodec/dcadct.c
index 1082aa884d..a0eda3d2bb 100644
--- a/libavcodec/dcadct.c
+++ b/libavcodec/dcadct.c
@@ -18,7 +18,7 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavutil/common.h"
+#include <stdlib.h>
 
 #include "dcadct.h"
 #include "dcamath.h"
diff --git a/libavcodec/dcadct.h b/libavcodec/dcadct.h
index 518c9f9032..2ef60c16db 100644
--- a/libavcodec/dcadct.h
+++ b/libavcodec/dcadct.h
@@ -21,7 +21,8 @@ 
 #ifndef AVCODEC_DCADCT_H
 #define AVCODEC_DCADCT_H
 
-#include "libavutil/common.h"
+#include <stdint.h>
+#include "libavutil/attributes.h"
 
 typedef struct DCADCTContext {
     void (*imdct_half[2])(int32_t *output, const int32_t *input);
diff --git a/libavcodec/dcadec.h b/libavcodec/dcadec.h
index 9da8d3b444..0f371eca14 100644
--- a/libavcodec/dcadec.h
+++ b/libavcodec/dcadec.h
@@ -21,9 +21,11 @@ 
 #ifndef AVCODEC_DCADEC_H
 #define AVCODEC_DCADEC_H
 
-#include "libavutil/common.h"
+#include <stdint.h>
+
 #include "libavutil/crc.h"
 #include "libavutil/float_dsp.h"
+#include "libavutil/log.h"
 
 #include "avcodec.h"
 #include "get_bits.h"
diff --git a/libavcodec/dcahuff.c b/libavcodec/dcahuff.c
index fec60771ec..fa36735c0b 100644
--- a/libavcodec/dcahuff.c
+++ b/libavcodec/dcahuff.c
@@ -23,7 +23,7 @@ 
 #include <stddef.h>
 
 #include "libavutil/avassert.h"
-#include "libavutil/common.h"
+#include "libavutil/macros.h"
 
 #include "dcahuff.h"
 #include "put_bits.h"
diff --git a/libavcodec/dirac_vlc.h b/libavcodec/dirac_vlc.h
index bfcfa136a1..5adb9ef631 100644
--- a/libavcodec/dirac_vlc.h
+++ b/libavcodec/dirac_vlc.h
@@ -19,7 +19,7 @@ 
 #ifndef AVCODEC_DIRAC_VLC_H
 #define AVCODEC_DIRAC_VLC_H
 
-#include "libavutil/avutil.h"
+#include <stdint.h>
 
 int ff_dirac_golomb_read_16bit(const uint8_t *buf, int bytes,
                                uint8_t *_dst, int coeffs);
diff --git a/libavcodec/dnxhddata.c b/libavcodec/dnxhddata.c
index cb3d4a4c72..d52abe87dd 100644
--- a/libavcodec/dnxhddata.c
+++ b/libavcodec/dnxhddata.c
@@ -19,9 +19,11 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <stddef.h>
+#include "libavutil/log.h"
+#include "libavutil/macros.h"
 #include "avcodec.h"
 #include "dnxhddata.h"
-#include "libavutil/common.h"
 
 /* The quantization tables below are in zigzag order! */
 
diff --git a/libavcodec/dnxhddata.h b/libavcodec/dnxhddata.h
index 861faca4ca..ea36feb0a2 100644
--- a/libavcodec/dnxhddata.h
+++ b/libavcodec/dnxhddata.h
@@ -24,8 +24,9 @@ 
 
 #include <stdint.h>
 #include "avcodec.h"
-#include "libavutil/internal.h"
+#include "libavutil/attributes.h"
 #include "libavutil/intreadwrite.h"
+#include "libavutil/rational.h"
 
 /** Additional profile info flags */
 #define DNXHD_INTERLACED   (1<<0)
diff --git a/libavcodec/dv_profile.c b/libavcodec/dv_profile.c
index 0fc227dd04..f403114184 100644
--- a/libavcodec/dv_profile.c
+++ b/libavcodec/dv_profile.c
@@ -18,11 +18,12 @@ 
 
 #include "config.h"
 
+#include <stddef.h>
 #include <stdint.h>
 
-#include "libavutil/common.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/log.h"
+#include "libavutil/macros.h"
 #include "libavutil/pixdesc.h"
 
 #include "avcodec.h"
diff --git a/libavcodec/elsdec.c b/libavcodec/elsdec.c
index ecb5757066..9ae932cdf7 100644
--- a/libavcodec/elsdec.c
+++ b/libavcodec/elsdec.c
@@ -25,11 +25,14 @@ 
  * Entropy Logarithmic-Scale binary arithmetic decoder
  */
 
-#include <math.h>
+#include <stddef.h>
 #include <stdint.h>
+#include <string.h>
 
-#include "libavutil/common.h"
+#include "libavutil/error.h"
 #include "libavutil/intreadwrite.h"
+#include "libavutil/macros.h"
+#include "libavutil/mem.h"
 
 #include "elsdec.h"
 
diff --git a/libavcodec/exrdsp.h b/libavcodec/exrdsp.h
index 2c4dc3af88..aba3d3cf51 100644
--- a/libavcodec/exrdsp.h
+++ b/libavcodec/exrdsp.h
@@ -19,8 +19,8 @@ 
 #ifndef AVCODEC_EXRDSP_H
 #define AVCODEC_EXRDSP_H
 
+#include <stddef.h>
 #include <stdint.h>
-#include "libavutil/common.h"
 
 typedef struct ExrDSPContext {
     void (*reorder_pixels)(uint8_t *dst, const uint8_t *src, ptrdiff_t size);
diff --git a/libavcodec/flacdsp.c b/libavcodec/flacdsp.c
index bc9a5dbed9..6b6d578d64 100644
--- a/libavcodec/flacdsp.c
+++ b/libavcodec/flacdsp.c
@@ -19,6 +19,7 @@ 
  */
 
 #include "libavutil/attributes.h"
+#include "libavutil/internal.h"
 #include "libavutil/samplefmt.h"
 #include "flacdsp.h"
 #include "config.h"
diff --git a/libavcodec/flacdsp.h b/libavcodec/flacdsp.h
index 7bb0dd0e9a..4a7a36064a 100644
--- a/libavcodec/flacdsp.h
+++ b/libavcodec/flacdsp.h
@@ -20,7 +20,7 @@ 
 #define AVCODEC_FLACDSP_H
 
 #include <stdint.h>
-#include "libavutil/internal.h"
+
 #include "libavutil/samplefmt.h"
 
 typedef struct FLACDSPContext {
diff --git a/libavcodec/flacdsp_lpc_template.c b/libavcodec/flacdsp_lpc_template.c
index 5d532e0673..dd847d3b32 100644
--- a/libavcodec/flacdsp_lpc_template.c
+++ b/libavcodec/flacdsp_lpc_template.c
@@ -17,7 +17,7 @@ 
  */
 
 #include <stdint.h>
-#include "libavutil/avutil.h"
+#include "libavutil/common.h"
 #include "mathops.h"
 
 #undef FUNC
diff --git a/libavcodec/flacdsp_template.c b/libavcodec/flacdsp_template.c
index 892418cddc..0a6fe59e28 100644
--- a/libavcodec/flacdsp_template.c
+++ b/libavcodec/flacdsp_template.c
@@ -19,7 +19,7 @@ 
  */
 
 #include <stdint.h>
-#include "libavutil/avutil.h"
+#include "libavutil/macros.h"
 
 #undef FUNC
 #undef FSUF
diff --git a/libavcodec/fmtconvert.c b/libavcodec/fmtconvert.c
index 3b33af61ef..3e1f133bf1 100644
--- a/libavcodec/fmtconvert.c
+++ b/libavcodec/fmtconvert.c
@@ -20,9 +20,10 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "config.h"
+#include "libavutil/attributes.h"
 #include "avcodec.h"
 #include "fmtconvert.h"
-#include "libavutil/common.h"
 
 static void int32_to_float_fmul_scalar_c(float *dst, const int32_t *src,
                                          float mul, int len)
diff --git a/libavcodec/golomb.c b/libavcodec/golomb.c
index 937ac22ce1..f9ca8149eb 100644
--- a/libavcodec/golomb.c
+++ b/libavcodec/golomb.c
@@ -26,7 +26,7 @@ 
  * @author Michael Niedermayer <michaelni@gmx.at>
  */
 
-#include "libavutil/common.h"
+#include <stdint.h>
 
 const uint8_t ff_golomb_vlc_len[512]={
 19,17,15,15,13,13,13,13,11,11,11,11,11,11,11,11,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
diff --git a/libavcodec/h264_levels.c b/libavcodec/h264_levels.c
index 1b9f78da04..f7ed9a6e37 100644
--- a/libavcodec/h264_levels.c
+++ b/libavcodec/h264_levels.c
@@ -17,7 +17,7 @@ 
  */
 
 #include <stddef.h>
-#include "libavutil/common.h"
+#include "libavutil/macros.h"
 #include "h264_levels.h"
 
 // H.264 table A-1.
diff --git a/libavcodec/h264_redundant_pps_bsf.c b/libavcodec/h264_redundant_pps_bsf.c
index 769946abfd..d64b064590 100644
--- a/libavcodec/h264_redundant_pps_bsf.c
+++ b/libavcodec/h264_redundant_pps_bsf.c
@@ -16,16 +16,17 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include <string.h>
+#include <inttypes.h>
 
-#include "libavutil/common.h"
+#include "libavutil/log.h"
 
 #include "bsf.h"
-#include "bsf_internal.h"
 #include "cbs.h"
 #include "cbs_bsf.h"
 #include "cbs_h264.h"
+#include "codec_id.h"
 #include "h264.h"
+#include "packet.h"
 
 #define NEW_GLOBAL_PIC_INIT_QP 26
 
diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
index 329c2ea4f2..034ddb8f1c 100644
--- a/libavcodec/h264_sei.c
+++ b/libavcodec/h264_sei.c
@@ -28,9 +28,9 @@ 
 #include <limits.h>
 #include <stdio.h>
 #include <string.h>
-#include "libavutil/common.h"
 #include "libavutil/error.h"
 #include "libavutil/log.h"
+#include "libavutil/macros.h"
 #include "libavutil/mem.h"
 #include "atsc_a53.h"
 #include "get_bits.h"
diff --git a/libavcodec/huffman.c b/libavcodec/huffman.c
index be351ba2d6..99aa39c565 100644
--- a/libavcodec/huffman.c
+++ b/libavcodec/huffman.c
@@ -26,8 +26,11 @@ 
 
 #include <stdint.h>
 
+#include "libavutil/error.h"
+#include "libavutil/log.h"
+#include "libavutil/macros.h"
+#include "libavutil/mem.h"
 #include "libavutil/qsort.h"
-#include "libavutil/common.h"
 
 #include "huffman.h"
 #include "vlc.h"
diff --git a/libavcodec/jfdctfst.c b/libavcodec/jfdctfst.c
index bbcf598490..805e05808c 100644
--- a/libavcodec/jfdctfst.c
+++ b/libavcodec/jfdctfst.c
@@ -66,9 +66,8 @@ 
  * Independent JPEG Group's fast AAN dct.
  */
 
-#include <stdlib.h>
-#include <stdio.h>
-#include "libavutil/common.h"
+#include <stdint.h>
+#include "libavutil/attributes.h"
 #include "dct.h"
 
 #define DCTSIZE 8
diff --git a/libavcodec/jpeg2000dwt.c b/libavcodec/jpeg2000dwt.c
index ed24091fe8..f2da7307c4 100644
--- a/libavcodec/jpeg2000dwt.c
+++ b/libavcodec/jpeg2000dwt.c
@@ -25,7 +25,8 @@ 
  * Discrete wavelet transform
  */
 
-#include "libavutil/common.h"
+#include "libavutil/error.h"
+#include "libavutil/macros.h"
 #include "libavutil/mem.h"
 #include "jpeg2000dwt.h"
 
diff --git a/libavcodec/jrevdct.c b/libavcodec/jrevdct.c
index a1a0f571ad..36160cb663 100644
--- a/libavcodec/jrevdct.c
+++ b/libavcodec/jrevdct.c
@@ -62,7 +62,9 @@ 
  * Independent JPEG Group's LLM idct.
  */
 
-#include "libavutil/common.h"
+#include <stddef.h>
+#include <stdint.h>
+
 #include "libavutil/intreadwrite.h"
 
 #include "dct.h"
diff --git a/libavcodec/lagarithrac.h b/libavcodec/lagarithrac.h
index ee836d01db..a31b054dbb 100644
--- a/libavcodec/lagarithrac.h
+++ b/libavcodec/lagarithrac.h
@@ -31,7 +31,6 @@ 
 #define AVCODEC_LAGARITHRAC_H
 
 #include <stdint.h>
-#include "libavutil/common.h"
 #include "libavutil/intreadwrite.h"
 #include "avcodec.h"
 #include "get_bits.h"
diff --git a/libavcodec/libopus.c b/libavcodec/libopus.c
index 16395c73df..3d3b740a83 100644
--- a/libavcodec/libopus.c
+++ b/libavcodec/libopus.c
@@ -21,7 +21,6 @@ 
 
 #include <opus_defines.h>
 
-#include "libavutil/common.h"
 #include "libavutil/error.h"
 #include "libopus.h"
 
diff --git a/libavcodec/lsp.c b/libavcodec/lsp.c
index 29055fd478..90f2efaafe 100644
--- a/libavcodec/lsp.c
+++ b/libavcodec/lsp.c
@@ -21,10 +21,10 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include <inttypes.h>
+#include <math.h>
 
 #define FRAC_BITS 14
-#include "libavutil/common.h"
+#include "libavutil/macros.h"
 #include "mathops.h"
 #include "lsp.h"
 #include "libavcodec/mips/lsp_mips.h"
diff --git a/libavcodec/lzwenc.c b/libavcodec/lzwenc.c
index bb8eb2e1dd..ae1816a03e 100644
--- a/libavcodec/lzwenc.c
+++ b/libavcodec/lzwenc.c
@@ -27,7 +27,7 @@ 
 
 #include <stdint.h>
 #include "libavutil/avassert.h"
-#include "libavutil/common.h"
+#include "libavutil/macros.h"
 #include "lzw.h"
 #include "put_bits.h"
 
diff --git a/libavcodec/mdct15.c b/libavcodec/mdct15.c
index 6f35059bfe..3a735c77d4 100644
--- a/libavcodec/mdct15.c
+++ b/libavcodec/mdct15.c
@@ -27,11 +27,12 @@ 
 #include <float.h>
 #include <math.h>
 #include <stddef.h>
+#include <stdint.h>
 
 #include "config.h"
 
 #include "libavutil/attributes.h"
-#include "libavutil/common.h"
+#include "libavutil/error.h"
 
 #include "mdct15.h"
 
diff --git a/libavcodec/mips/mpegaudiodsp_mips_fixed.c b/libavcodec/mips/mpegaudiodsp_mips_fixed.c
index 1c9c68d23c..ef9750a44e 100644
--- a/libavcodec/mips/mpegaudiodsp_mips_fixed.c
+++ b/libavcodec/mips/mpegaudiodsp_mips_fixed.c
@@ -54,6 +54,7 @@ 
 
 #include <string.h>
 
+#include "config.h"
 #include "libavutil/mips/asmdefs.h"
 #include "libavcodec/mpegaudiodsp.h"
 
diff --git a/libavcodec/mips/mpegaudiodsp_mips_float.c b/libavcodec/mips/mpegaudiodsp_mips_float.c
index ae130c752e..53b77619c9 100644
--- a/libavcodec/mips/mpegaudiodsp_mips_float.c
+++ b/libavcodec/mips/mpegaudiodsp_mips_float.c
@@ -55,6 +55,7 @@ 
 
 #include <string.h>
 
+#include "config.h"
 #include "libavutil/mips/asmdefs.h"
 #include "libavcodec/mpegaudiodsp.h"
 
diff --git a/libavcodec/mjpegenc_huffman.c b/libavcodec/mjpegenc_huffman.c
index 0e63f8066b..9bfcb7e785 100644
--- a/libavcodec/mjpegenc_huffman.c
+++ b/libavcodec/mjpegenc_huffman.c
@@ -21,10 +21,7 @@ 
 
 #include <string.h>
 #include <stdint.h>
-#include <stdlib.h>
 #include "libavutil/avassert.h"
-#include "libavutil/common.h"
-#include "libavutil/error.h"
 #include "libavutil/qsort.h"
 #include "mjpegenc_huffman.h"
 
diff --git a/libavcodec/mpegaudiodecheader.c b/libavcodec/mpegaudiodecheader.c
index 446a6e29d8..ef63befbf4 100644
--- a/libavcodec/mpegaudiodecheader.c
+++ b/libavcodec/mpegaudiodecheader.c
@@ -24,7 +24,7 @@ 
  * MPEG Audio header decoder.
  */
 
-#include "libavutil/common.h"
+#include "libavutil/macros.h"
 
 #include "mpegaudio.h"
 #include "mpegaudiodata.h"
diff --git a/libavcodec/mpegaudiodsp.h b/libavcodec/mpegaudiodsp.h
index 4577d515d9..7bc635191a 100644
--- a/libavcodec/mpegaudiodsp.h
+++ b/libavcodec/mpegaudiodsp.h
@@ -22,7 +22,7 @@ 
 #include <stddef.h>
 #include <stdint.h>
 
-#include "libavutil/common.h"
+#include "libavutil/macros.h"
 
 typedef struct MPADSPContext {
     void (*apply_window_float)(float *synth_buf, float *window,
diff --git a/libavcodec/msmpeg4data.h b/libavcodec/msmpeg4data.h
index 87b4057d97..ec7957c126 100644
--- a/libavcodec/msmpeg4data.h
+++ b/libavcodec/msmpeg4data.h
@@ -30,7 +30,7 @@ 
 #ifndef AVCODEC_MSMPEG4DATA_H
 #define AVCODEC_MSMPEG4DATA_H
 
-#include "libavutil/common.h"
+#include <stdint.h>
 
 #include "rl.h"
 #include "vlc.h"
diff --git a/libavcodec/opusdsp.c b/libavcodec/opusdsp.c
index 08df87ffbe..2c46afa839 100644
--- a/libavcodec/opusdsp.c
+++ b/libavcodec/opusdsp.c
@@ -16,6 +16,8 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "config.h"
+#include "libavutil/attributes.h"
 #include "opusdsp.h"
 
 static void postfilter_c(float *data, int period, float *gains, int len)
diff --git a/libavcodec/opusdsp.h b/libavcodec/opusdsp.h
index ee3186dd44..3ea3d14bf0 100644
--- a/libavcodec/opusdsp.h
+++ b/libavcodec/opusdsp.h
@@ -19,8 +19,6 @@ 
 #ifndef AVCODEC_OPUSDSP_H
 #define AVCODEC_OPUSDSP_H
 
-#include "libavutil/common.h"
-
 #define CELT_EMPH_COEFF 0.8500061035f
 
 typedef struct OpusDSP {
diff --git a/libavcodec/pngdsp.c b/libavcodec/pngdsp.c
index d2753163da..f450a4c5ee 100644
--- a/libavcodec/pngdsp.c
+++ b/libavcodec/pngdsp.c
@@ -19,8 +19,8 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "config.h"
 #include "libavutil/attributes.h"
-#include "libavutil/common.h"
 #include "png.h"
 #include "pngdsp.h"
 
diff --git a/libavcodec/ra288.h b/libavcodec/ra288.h
index 96b074bffb..e7b12c5fa6 100644
--- a/libavcodec/ra288.h
+++ b/libavcodec/ra288.h
@@ -23,7 +23,7 @@ 
 #define AVCODEC_RA288_H
 
 #include <stdint.h>
-#include "libavutil/common.h"
+#include "libavutil/macros.h"
 #include "libavutil/mem_internal.h"
 
 static const float amptable[8]={
diff --git a/libavcodec/rangecoder.h b/libavcodec/rangecoder.h
index 4495f6df1a..89d178ac31 100644
--- a/libavcodec/rangecoder.h
+++ b/libavcodec/rangecoder.h
@@ -29,8 +29,8 @@ 
 
 #include <stdint.h>
 
-#include "libavutil/common.h"
 #include "libavutil/avassert.h"
+#include "libavutil/intmath.h"
 
 typedef struct RangeCoder {
     int low;
diff --git a/libavcodec/raw.c b/libavcodec/raw.c
index 5efc1eb465..a371bb36c4 100644
--- a/libavcodec/raw.c
+++ b/libavcodec/raw.c
@@ -24,9 +24,9 @@ 
  * Raw Video Codec
  */
 
+#include "libavutil/macros.h"
 #include "avcodec.h"
 #include "raw.h"
-#include "libavutil/common.h"
 
 static const PixelFormatTag raw_pix_fmt_tags[] = {
     { AV_PIX_FMT_YUV420P, MKTAG('I', '4', '2', '0') }, /* Planar formats */
diff --git a/libavcodec/rle.c b/libavcodec/rle.c
index 1ef6077a6b..cebd238264 100644
--- a/libavcodec/rle.c
+++ b/libavcodec/rle.c
@@ -21,7 +21,7 @@ 
 
 #include <string.h>
 
-#include "libavutil/common.h"
+#include "libavutil/macros.h"
 
 #include "rle.h"
 
diff --git a/libavcodec/scpr3.h b/libavcodec/scpr3.h
index 92ad968882..8988300ce0 100644
--- a/libavcodec/scpr3.h
+++ b/libavcodec/scpr3.h
@@ -23,12 +23,7 @@ 
 #ifndef AVCODEC_SCPR3_H
 #define AVCODEC_SCPR3_H
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "avcodec.h"
-#include "internal.h"
+#include <stdint.h>
 
 typedef struct PixelModel3 {
     uint8_t    type;
diff --git a/libavcodec/tests/cabac.c b/libavcodec/tests/cabac.c
index b84a96ce81..d9f98c68e0 100644
--- a/libavcodec/tests/cabac.c
+++ b/libavcodec/tests/cabac.c
@@ -18,12 +18,12 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavcodec/cabac_functions.h"
 #include "libavcodec/cabac.c"
 
 #define SIZE 10240
 
 #include "libavutil/lfg.h"
-#include "libavcodec/avcodec.h"
 #include "libavcodec/put_bits.h"
 
 typedef struct CABACTestContext {
diff --git a/libavcodec/tests/jpeg2000dwt.c b/libavcodec/tests/jpeg2000dwt.c
index 80b33bee79..0e5a6ed947 100644
--- a/libavcodec/tests/jpeg2000dwt.c
+++ b/libavcodec/tests/jpeg2000dwt.c
@@ -20,6 +20,11 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <inttypes.h>
+#include <stdio.h>
+
+#include "libavutil/common.h"
+
 #include "libavcodec/jpeg2000dwt.c"
 
 #include "libavutil/lfg.h"
diff --git a/libavcodec/tests/rangecoder.c b/libavcodec/tests/rangecoder.c
index ca96e13c99..fd858535a5 100644
--- a/libavcodec/tests/rangecoder.c
+++ b/libavcodec/tests/rangecoder.c
@@ -19,6 +19,7 @@ 
 #include <stdint.h>
 #include <string.h>
 
+#include "libavutil/error.h"
 #include "libavutil/lfg.h"
 #include "libavutil/log.h"
 
diff --git a/libavcodec/trace_headers_bsf.c b/libavcodec/trace_headers_bsf.c
index a9b0247412..96a52fac53 100644
--- a/libavcodec/trace_headers_bsf.c
+++ b/libavcodec/trace_headers_bsf.c
@@ -16,10 +16,10 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include <stdio.h>
+#include <inttypes.h>
 
 #include "libavutil/avstring.h"
-#include "libavutil/common.h"
+#include "libavutil/avutil.h"
 #include "libavutil/log.h"
 
 #include "bsf.h"
diff --git a/libavcodec/videodsp.c b/libavcodec/videodsp.c
index 212147984f..2198d46c15 100644
--- a/libavcodec/videodsp.c
+++ b/libavcodec/videodsp.c
@@ -18,9 +18,10 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "config.h"
 #include "libavutil/attributes.h"
 #include "libavutil/avassert.h"
-#include "libavutil/common.h"
+#include "libavutil/macros.h"
 #include "videodsp.h"
 
 #define BIT_DEPTH 8
diff --git a/libavcodec/vp56data.h b/libavcodec/vp56data.h
index 3be268c317..aaca1fd088 100644
--- a/libavcodec/vp56data.h
+++ b/libavcodec/vp56data.h
@@ -26,7 +26,7 @@ 
 #ifndef AVCODEC_VP56DATA_H
 #define AVCODEC_VP56DATA_H
 
-#include "libavutil/common.h"
+#include <stdint.h>
 #include "vp56.h"
 
 extern const uint8_t ff_vp56_b2p[];
diff --git a/libavcodec/vp56rac.c b/libavcodec/vp56rac.c
index 64fb6a99b4..19e7dcf2bb 100644
--- a/libavcodec/vp56rac.c
+++ b/libavcodec/vp56rac.c
@@ -19,7 +19,9 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavutil/common.h"
+#include <stdint.h>
+#include "libavutil/error.h"
+#include "bytestream.h"
 #include "vp56.h"
 
 const uint8_t ff_vp56_norm_shift[256]= {
diff --git a/libavcodec/vp9dsp.c b/libavcodec/vp9dsp.c
index 82bfe394d1..3441419e2d 100644
--- a/libavcodec/vp9dsp.c
+++ b/libavcodec/vp9dsp.c
@@ -21,8 +21,10 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "config.h"
+
+#include "libavutil/attributes.h"
 #include "libavutil/avassert.h"
-#include "libavutil/common.h"
 #include "libavutil/mem_internal.h"
 
 #include "vp9dsp.h"
diff --git a/libavcodec/wavpack.h b/libavcodec/wavpack.h
index 7e7dfce2b7..9f62f8406d 100644
--- a/libavcodec/wavpack.h
+++ b/libavcodec/wavpack.h
@@ -22,7 +22,10 @@ 
 #ifndef AVCODEC_WAVPACK_H
 #define AVCODEC_WAVPACK_H
 
-#include "libavutil/common.h"
+#include <limits.h>
+#include <stdint.h>
+#include "libavutil/attributes.h"
+#include "libavutil/intmath.h"
 
 #define MAX_TERMS      16
 #define MAX_TERM        8
diff --git a/libavcodec/wavpackenc.h b/libavcodec/wavpackenc.h
index 11914337cf..b6d12e8a5c 100644
--- a/libavcodec/wavpackenc.h
+++ b/libavcodec/wavpackenc.h
@@ -21,6 +21,8 @@ 
 #ifndef AVCODEC_WAVPACKENC_H
 #define AVCODEC_WAVPACKENC_H
 
+#include <stdint.h>
+#include "libavutil/macros.h"
 #include "wavpack.h"
 
 typedef struct WavPackDecorrSpec {
diff --git a/libavcodec/x86/fdct.c b/libavcodec/x86/fdct.c
index 033ff1ccc5..835fcc2b28 100644
--- a/libavcodec/x86/fdct.c
+++ b/libavcodec/x86/fdct.c
@@ -30,8 +30,9 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "config.h"
 #include "libavutil/attributes.h"
-#include "libavutil/common.h"
+#include "libavutil/macros.h"
 #include "libavutil/mem_internal.h"
 #include "libavutil/x86/asm.h"
 #include "fdct.h"
diff --git a/libavcodec/x86/mpegaudiodsp.c b/libavcodec/x86/mpegaudiodsp.c
index 50692f29ce..dcea94a1f5 100644
--- a/libavcodec/x86/mpegaudiodsp.c
+++ b/libavcodec/x86/mpegaudiodsp.c
@@ -19,9 +19,11 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <stddef.h>
+
+#include "config.h"
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
-#include "libavutil/internal.h"
 #include "libavutil/mem_internal.h"
 #include "libavutil/x86/asm.h"
 #include "libavutil/x86/cpu.h"
diff --git a/libavcodec/x86/pngdsp_init.c b/libavcodec/x86/pngdsp_init.c
index 7dca62c675..edbe866c22 100644
--- a/libavcodec/x86/pngdsp_init.c
+++ b/libavcodec/x86/pngdsp_init.c
@@ -19,8 +19,9 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <stdint.h>
+#include "config.h"
 #include "libavutil/attributes.h"
-#include "libavutil/common.h"
 #include "libavutil/x86/cpu.h"
 #include "libavcodec/pngdsp.h"
 
diff --git a/libavcodec/xiph.c b/libavcodec/xiph.c
index 3073315e63..218b0813e9 100644
--- a/libavcodec/xiph.c
+++ b/libavcodec/xiph.c
@@ -18,6 +18,8 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <limits.h>
+#include "libavutil/error.h"
 #include "libavutil/intreadwrite.h"
 #include "xiph.h"
 
diff --git a/libavcodec/xiph.h b/libavcodec/xiph.h
index 1741a51b65..4ab2469528 100644
--- a/libavcodec/xiph.h
+++ b/libavcodec/xiph.h
@@ -21,7 +21,7 @@ 
 #ifndef AVCODEC_XIPH_H
 #define AVCODEC_XIPH_H
 
-#include "libavutil/common.h"
+#include <stdint.h>
 
 /**
  * Split a single extradata buffer into the three headers that most
diff --git a/libavdevice/timefilter.c b/libavdevice/timefilter.c
index ad6485d5e7..a97afc5fdc 100644
--- a/libavdevice/timefilter.c
+++ b/libavdevice/timefilter.c
@@ -22,7 +22,11 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavutil/common.h"
+#include <math.h>
+#include <stddef.h>
+
+#include "libavutil/macros.h"
+#include "libavutil/mathematics.h"
 #include "libavutil/mem.h"
 
 #include "timefilter.h"
diff --git a/libavfilter/af_afir.h b/libavfilter/af_afir.h
index 8f40c1b2f4..cf00dbfc66 100644
--- a/libavfilter/af_afir.h
+++ b/libavfilter/af_afir.h
@@ -21,15 +21,14 @@ 
 #ifndef AVFILTER_AFIR_H
 #define AVFILTER_AFIR_H
 
+#include <stddef.h>
+#include <stdint.h>
+
 #include "libavutil/tx.h"
-#include "libavutil/common.h"
 #include "libavutil/float_dsp.h"
-#include "libavutil/opt.h"
-
-#include "audio.h"
-#include "avfilter.h"
-#include "formats.h"
-#include "internal.h"
+#include "libavutil/frame.h"
+#include "libavutil/log.h"
+#include "libavutil/rational.h"
 
 typedef struct AudioFIRSegment {
     int nb_partitions;
diff --git a/libavfilter/af_volume.h b/libavfilter/af_volume.h
index af46e34ff6..c97902969e 100644
--- a/libavfilter/af_volume.h
+++ b/libavfilter/af_volume.h
@@ -24,10 +24,10 @@ 
 #ifndef AVFILTER_VOLUME_H
 #define AVFILTER_VOLUME_H
 
-#include "libavutil/common.h"
+#include <stdint.h>
 #include "libavutil/eval.h"
 #include "libavutil/float_dsp.h"
-#include "libavutil/opt.h"
+#include "libavutil/log.h"
 #include "libavutil/samplefmt.h"
 
 enum PrecisionType {
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index b8b432e98b..74bfbe2103 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -25,11 +25,9 @@ 
 #include <string.h>
 
 #include "libavutil/avassert.h"
-#include "libavutil/avstring.h"
 #include "libavutil/bprint.h"
 #include "libavutil/channel_layout.h"
 #include "libavutil/imgutils.h"
-#include "libavutil/internal.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 
diff --git a/libavfilter/colorspace.h b/libavfilter/colorspace.h
index 459a5df60d..a4c5078d5f 100644
--- a/libavfilter/colorspace.h
+++ b/libavfilter/colorspace.h
@@ -20,8 +20,8 @@ 
 #ifndef AVFILTER_COLORSPACE_H
 #define AVFILTER_COLORSPACE_H
 
-#include "libavutil/common.h"
 #include "libavutil/frame.h"
+#include "libavutil/pixfmt.h"
 
 #define REFERENCE_WHITE 100.0f
 
diff --git a/libavfilter/ebur128.c b/libavfilter/ebur128.c
index 1a85a90360..062099e206 100644
--- a/libavfilter/ebur128.c
+++ b/libavfilter/ebur128.c
@@ -47,7 +47,8 @@ 
 #include <limits.h>
 #include <math.h>               /* You may have to define _USE_MATH_DEFINES if you use MSVC */
 
-#include "libavutil/common.h"
+#include "libavutil/error.h"
+#include "libavutil/macros.h"
 #include "libavutil/mem.h"
 #include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
diff --git a/libavfilter/motion_estimation.c b/libavfilter/motion_estimation.c
index 0f9ba21784..2bf5ce6155 100644
--- a/libavfilter/motion_estimation.c
+++ b/libavfilter/motion_estimation.c
@@ -18,6 +18,7 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/common.h"
 #include "motion_estimation.h"
 
 static const int8_t sqr1[8][2]  = {{ 0,-1}, { 0, 1}, {-1, 0}, { 1, 0}, {-1,-1}, {-1, 1}, { 1,-1}, { 1, 1}};
diff --git a/libavfilter/motion_estimation.h b/libavfilter/motion_estimation.h
index 6ae29dd9e3..be627ec3b0 100644
--- a/libavfilter/motion_estimation.h
+++ b/libavfilter/motion_estimation.h
@@ -21,7 +21,7 @@ 
 #ifndef AVFILTER_MOTION_ESTIMATION_H
 #define AVFILTER_MOTION_ESTIMATION_H
 
-#include "libavutil/avutil.h"
+#include <stdint.h>
 
 #define AV_ME_METHOD_ESA        1
 #define AV_ME_METHOD_TSS        2
diff --git a/libavfilter/pthread.c b/libavfilter/pthread.c
index 34fc699505..1a063d3cc0 100644
--- a/libavfilter/pthread.c
+++ b/libavfilter/pthread.c
@@ -21,11 +21,11 @@ 
  * Libavfilter multithreading support
  */
 
-#include "config.h"
+#include <stddef.h>
 
-#include "libavutil/common.h"
+#include "libavutil/error.h"
+#include "libavutil/macros.h"
 #include "libavutil/mem.h"
-#include "libavutil/thread.h"
 #include "libavutil/slicethread.h"
 
 #include "avfilter.h"
diff --git a/libavformat/argo_asf.h b/libavformat/argo_asf.h
index 1fab31a90b..948459d0b7 100644
--- a/libavformat/argo_asf.h
+++ b/libavformat/argo_asf.h
@@ -24,7 +24,7 @@ 
 #define AVFORMAT_ARGO_ASF_H
 
 #include <stdint.h>
-#include "libavutil/common.h"
+#include "libavutil/macros.h"
 
 #include "avformat.h"
 
diff --git a/libavformat/asfcrypt.c b/libavformat/asfcrypt.c
index 221a8a89bc..c77e37503e 100644
--- a/libavformat/asfcrypt.c
+++ b/libavformat/asfcrypt.c
@@ -20,10 +20,11 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <stddef.h>
 #include "libavutil/bswap.h"
-#include "libavutil/common.h"
 #include "libavutil/des.h"
 #include "libavutil/intreadwrite.h"
+#include "libavutil/mem.h"
 #include "libavutil/rc4.h"
 #include "asfcrypt.h"
 
diff --git a/libavformat/avlanguage.c b/libavformat/avlanguage.c
index c36893c999..782a58adb2 100644
--- a/libavformat/avlanguage.c
+++ b/libavformat/avlanguage.c
@@ -19,8 +19,7 @@ 
  */
 
 #include "avlanguage.h"
-#include "libavutil/avstring.h"
-#include "libavutil/common.h"
+#include "libavutil/macros.h"
 #include <stdlib.h>
 #include <stdint.h>
 #include <string.h>
diff --git a/libavformat/hlsplaylist.h b/libavformat/hlsplaylist.h
index 29487da3ed..1928fe787d 100644
--- a/libavformat/hlsplaylist.h
+++ b/libavformat/hlsplaylist.h
@@ -25,7 +25,6 @@ 
 
 #include <stdint.h>
 
-#include "libavutil/common.h"
 #include "avformat.h"
 #include "avio.h"
 
diff --git a/libavformat/matroska.h b/libavformat/matroska.h
index 16491aae22..45077ed33f 100644
--- a/libavformat/matroska.h
+++ b/libavformat/matroska.h
@@ -23,8 +23,8 @@ 
 #define AVFORMAT_MATROSKA_H
 
 #include "libavcodec/codec_id.h"
+#include "avformat.h"
 #include "metadata.h"
-#include "internal.h"
 
 /* EBML version supported */
 #define EBML_VERSION 1
diff --git a/libavformat/network.c b/libavformat/network.c
index 96fe636745..1ced314c92 100644
--- a/libavformat/network.c
+++ b/libavformat/network.c
@@ -22,7 +22,6 @@ 
 #include "network.h"
 #include "tls.h"
 #include "url.h"
-#include "libavutil/avutil.h"
 #include "libavutil/avassert.h"
 #include "libavutil/mem.h"
 #include "libavutil/time.h"
diff --git a/libavformat/riff.c b/libavformat/riff.c
index 27a9706510..0c19d3f784 100644
--- a/libavformat/riff.c
+++ b/libavformat/riff.c
@@ -19,8 +19,9 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <stddef.h>
 #include "config.h"
-#include "libavutil/common.h"
+#include "libavutil/macros.h"
 #include "avformat.h"
 #include "internal.h"
 #include "metadata.h"
diff --git a/libavformat/tee_common.c b/libavformat/tee_common.c
index a9608871b5..e516b0a603 100644
--- a/libavformat/tee_common.c
+++ b/libavformat/tee_common.c
@@ -19,8 +19,9 @@ 
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavutil/avutil.h"
-#include "libavutil/avstring.h"
+#include <string.h>
+
+#include "libavutil/log.h"
 #include "libavutil/opt.h"
 
 #include "tee_common.h"
diff --git a/libavformat/webmdashenc.c b/libavformat/webmdashenc.c
index cf69bd35b1..a942c484e9 100644
--- a/libavformat/webmdashenc.c
+++ b/libavformat/webmdashenc.c
@@ -38,6 +38,8 @@ 
 #include "libavutil/opt.h"
 #include "libavutil/time_internal.h"
 
+#include "libavcodec/codec_desc.h"
+
 typedef struct AdaptationSet {
     char id[10];
     int *streams;
diff --git a/libavformat/wv.c b/libavformat/wv.c
index 0f4f80761a..b260bb9fc3 100644
--- a/libavformat/wv.c
+++ b/libavformat/wv.c
@@ -21,8 +21,9 @@ 
 #include <stdint.h>
 #include <string.h>
 
-#include "libavutil/common.h"
+#include "libavutil/error.h"
 #include "libavutil/intreadwrite.h"
+#include "libavutil/macros.h"
 
 #include "wv.h"
 
diff --git a/libavutil/adler32.c b/libavutil/adler32.c
index f7d3062265..7124f18802 100644
--- a/libavutil/adler32.c
+++ b/libavutil/adler32.c
@@ -32,8 +32,8 @@ 
 
 #include "config.h"
 #include "adler32.h"
-#include "common.h"
 #include "intreadwrite.h"
+#include "macros.h"
 
 #define BASE 65521L /* largest prime smaller than 65536 */
 
diff --git a/libavutil/aes.c b/libavutil/aes.c
index 397ea77389..029d738f87 100644
--- a/libavutil/aes.c
+++ b/libavutil/aes.c
@@ -20,11 +20,15 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "common.h"
+#include <string.h>
+
+#include "config.h"
 #include "aes.h"
 #include "aes_internal.h"
+#include "error.h"
 #include "intreadwrite.h"
-#include "timer.h"
+#include "macros.h"
+#include "mem.h"
 
 const int av_aes_size= sizeof(AVAES);
 
diff --git a/libavutil/aes_ctr.c b/libavutil/aes_ctr.c
index 517d09cf96..c2d6d570e7 100644
--- a/libavutil/aes_ctr.c
+++ b/libavutil/aes_ctr.c
@@ -19,10 +19,13 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "common.h"
+#include <string.h>
+
 #include "aes_ctr.h"
 #include "aes.h"
 #include "aes_internal.h"
+#include "macros.h"
+#include "mem.h"
 #include "random_seed.h"
 
 #define AES_BLOCK_SIZE (16)
diff --git a/libavutil/avsscanf.c b/libavutil/avsscanf.c
index a034407d14..7061e6d965 100644
--- a/libavutil/avsscanf.c
+++ b/libavutil/avsscanf.c
@@ -21,16 +21,18 @@ 
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
+#include <errno.h>
+#include <limits.h>
+#include <math.h>
 #include <stdarg.h>
+#include <stddef.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <string.h>
 #include <float.h>
 
-#include "config.h"
-#include "common.h"
 #include "avstring.h"
-#include "bprint.h"
+#include "libm.h"
 
 typedef struct FFFILE {
     size_t buf_size;
diff --git a/libavutil/avstring.c b/libavutil/avstring.c
index 49e8df55aa..5ddbe9219e 100644
--- a/libavutil/avstring.c
+++ b/libavutil/avstring.c
@@ -19,17 +19,20 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <limits.h>
 #include <stdarg.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <string.h>
 
 #include "config.h"
-#include "common.h"
 #include "mem.h"
 #include "avassert.h"
 #include "avstring.h"
 #include "bprint.h"
+#include "error.h"
+#include "macros.h"
+#include "version.h"
 
 int av_strstart(const char *str, const char *pfx, const char **ptr)
 {
diff --git a/libavutil/base64.c b/libavutil/base64.c
index a1316b9438..3e66f4fcbe 100644
--- a/libavutil/base64.c
+++ b/libavutil/base64.c
@@ -24,10 +24,12 @@ 
  * @author Ryan Martell <rdm4@martellventures.com> (with lots of Michael)
  */
 
-#include "common.h"
+#include <limits.h>
+#include <stddef.h>
+
 #include "base64.h"
+#include "error.h"
 #include "intreadwrite.h"
-#include "timer.h"
 
 /* ---------------- private code */
 static const uint8_t map2[256] =
diff --git a/libavutil/blowfish.c b/libavutil/blowfish.c
index abc0e03d4d..6df60150ea 100644
--- a/libavutil/blowfish.c
+++ b/libavutil/blowfish.c
@@ -21,8 +21,9 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "avutil.h"
-#include "common.h"
+#include <string.h>
+
+#include "attributes.h"
 #include "intreadwrite.h"
 #include "mem.h"
 #include "blowfish.h"
diff --git a/libavutil/bprint.c b/libavutil/bprint.c
index ea51d9b09c..5b540ebc9e 100644
--- a/libavutil/bprint.c
+++ b/libavutil/bprint.c
@@ -18,15 +18,16 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <limits.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <string.h>
 #include <time.h>
 #include "avstring.h"
 #include "bprint.h"
-#include "common.h"
 #include "compat/va_copy.h"
 #include "error.h"
+#include "macros.h"
 #include "mem.h"
 
 #define av_bprint_room(buf) ((buf)->size - FFMIN((buf)->len, (buf)->size))
diff --git a/libavutil/buffer_internal.h b/libavutil/buffer_internal.h
index bdff1b5b32..adb916aaa2 100644
--- a/libavutil/buffer_internal.h
+++ b/libavutil/buffer_internal.h
@@ -22,7 +22,6 @@ 
 #include <stdatomic.h>
 #include <stdint.h>
 
-#include "internal.h"
 #include "buffer.h"
 #include "thread.h"
 
diff --git a/libavutil/camellia.c b/libavutil/camellia.c
index f33ee9babc..3fc3b08291 100644
--- a/libavutil/camellia.c
+++ b/libavutil/camellia.c
@@ -18,9 +18,13 @@ 
  * License along with FFmpeg; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
+
+#include <string.h>
+
 #include "camellia.h"
-#include "common.h"
+#include "error.h"
 #include "intreadwrite.h"
+#include "mem.h"
 #include "attributes.h"
 
 #define LR32(x,c) ((x) << (c) | (x) >> (32 - (c)))
diff --git a/libavutil/cast5.c b/libavutil/cast5.c
index 445eb55c12..0bf8ae9929 100644
--- a/libavutil/cast5.c
+++ b/libavutil/cast5.c
@@ -18,9 +18,13 @@ 
  * License along with FFmpeg; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
+
+#include <string.h>
+
 #include "cast5.h"
-#include "common.h"
+#include "error.h"
 #include "intreadwrite.h"
+#include "mem.h"
 #include "attributes.h"
 
 #define IA(x) ((x) >> 24)
diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c
index ac773a9e63..b9507b1bff 100644
--- a/libavutil/channel_layout.c
+++ b/libavutil/channel_layout.c
@@ -24,12 +24,14 @@ 
  */
 
 #include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
 
-#include "avstring.h"
-#include "avutil.h"
 #include "channel_layout.h"
 #include "bprint.h"
 #include "common.h"
+#include "error.h"
+#include "macros.h"
 
 struct channel_name {
     const char *name;
diff --git a/libavutil/color_utils.c b/libavutil/color_utils.c
index eb8bc7b5fc..5e221fb798 100644
--- a/libavutil/color_utils.c
+++ b/libavutil/color_utils.c
@@ -21,7 +21,6 @@ 
 #include <stddef.h>
 #include <math.h>
 
-#include "common.h"
 #include "libavutil/color_utils.h"
 #include "libavutil/pixfmt.h"
 
diff --git a/libavutil/crc.c b/libavutil/crc.c
index c45ea63a62..703b56f4e0 100644
--- a/libavutil/crc.c
+++ b/libavutil/crc.c
@@ -23,8 +23,8 @@ 
 #include "thread.h"
 #include "avassert.h"
 #include "bswap.h"
-#include "common.h"
 #include "crc.h"
+#include "error.h"
 
 #if CONFIG_HARDCODED_TABLES
 static const AVCRC av_crc_table[AV_CRC_MAX][257] = {
diff --git a/libavutil/des.c b/libavutil/des.c
index 6957666184..e0e9a86660 100644
--- a/libavutil/des.c
+++ b/libavutil/des.c
@@ -19,10 +19,12 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "config.h"
+
 #include <stdint.h>
 
-#include "avutil.h"
-#include "common.h"
+#include "attributes.h"
+#include "error.h"
 #include "intreadwrite.h"
 #include "mem.h"
 #include "des.h"
diff --git a/libavutil/error.c b/libavutil/error.c
index b96304837b..938a8bc000 100644
--- a/libavutil/error.c
+++ b/libavutil/error.c
@@ -18,9 +18,12 @@ 
 
 #undef _GNU_SOURCE
 #define _XOPEN_SOURCE 600 /* XSI-compliant version of strerror_r */
-#include "avutil.h"
+#include <stdio.h>
+#include <string.h>
+#include "config.h"
 #include "avstring.h"
-#include "common.h"
+#include "error.h"
+#include "macros.h"
 
 struct error_entry {
     int num;
diff --git a/libavutil/fixed_dsp.c b/libavutil/fixed_dsp.c
index f1b195f184..098ef9c061 100644
--- a/libavutil/fixed_dsp.c
+++ b/libavutil/fixed_dsp.c
@@ -45,6 +45,7 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "common.h"
 #include "fixed_dsp.h"
 
 static void vector_fmul_add_c(int *dst, const int *src0, const int *src1, const int *src2, int len){
diff --git a/libavutil/fixed_dsp.h b/libavutil/fixed_dsp.h
index f554cb5038..fec806ff2d 100644
--- a/libavutil/fixed_dsp.h
+++ b/libavutil/fixed_dsp.h
@@ -49,8 +49,8 @@ 
 #define AVUTIL_FIXED_DSP_H
 
 #include <stdint.h>
+#include "config.h"
 #include "attributes.h"
-#include "common.h"
 #include "libavcodec/mathops.h"
 
 typedef struct AVFixedDSPContext {
diff --git a/libavutil/lls.c b/libavutil/lls.c
index 3a136baa2d..ea2d80e662 100644
--- a/libavutil/lls.c
+++ b/libavutil/lls.c
@@ -28,8 +28,8 @@ 
 #include <math.h>
 #include <string.h>
 
+#include "config.h"
 #include "attributes.h"
-#include "internal.h"
 #include "lls.h"
 
 static void update_lls(LLSModel *m, const double *var)
diff --git a/libavutil/log.c b/libavutil/log.c
index 66defa9c42..5948e50467 100644
--- a/libavutil/log.c
+++ b/libavutil/log.c
@@ -32,9 +32,11 @@ 
 #if HAVE_IO_H
 #include <io.h>
 #endif
+#include <inttypes.h>
 #include <stdarg.h>
+#include <stdio.h>
 #include <stdlib.h>
-#include "avutil.h"
+#include <string.h>
 #include "bprint.h"
 #include "common.h"
 #include "internal.h"
diff --git a/libavutil/lzo.c b/libavutil/lzo.c
index 1ae076e335..bcbe2c861d 100644
--- a/libavutil/lzo.c
+++ b/libavutil/lzo.c
@@ -19,13 +19,15 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <limits.h>
+#include <stdint.h>
 #include <string.h>
 
-#include "avutil.h"
 #include "avassert.h"
-#include "common.h"
 #include "intreadwrite.h"
 #include "lzo.h"
+#include "macros.h"
+#include "mem.h"
 
 /// Define if we may write up to 12 bytes beyond the output buffer.
 #define OUTBUF_PADDED 1
diff --git a/libavutil/mem.c b/libavutil/mem.c
index 194d880587..a0c9a42849 100644
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -37,10 +37,13 @@ 
 #include <malloc.h>
 #endif
 
-#include "avutil.h"
-#include "common.h"
+#include "attributes.h"
+#include "avassert.h"
 #include "dynarray.h"
+#include "error.h"
+#include "internal.h"
 #include "intreadwrite.h"
+#include "macros.h"
 #include "mem.h"
 
 #ifdef MALLOC_PREFIX
@@ -59,8 +62,6 @@  void  free(void *ptr);
 
 #endif /* MALLOC_PREFIX */
 
-#include "mem_internal.h"
-
 #define ALIGN (HAVE_AVX512 ? 64 : (HAVE_AVX ? 32 : 16))
 
 /* NOTE: if you want to override these functions with your own
diff --git a/libavutil/pixelutils.c b/libavutil/pixelutils.c
index ebee3d6f90..820889a143 100644
--- a/libavutil/pixelutils.c
+++ b/libavutil/pixelutils.c
@@ -16,12 +16,17 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <stddef.h>
+
 #include "config.h"
-#include "common.h"
 #include "pixelutils.h"
-#include "internal.h"
 
 #if CONFIG_PIXELUTILS
+#include <stdlib.h>
+#include <string.h>
+
+#include "attributes.h"
+#include "macros.h"
 
 #include "x86/pixelutils.h"
 
@@ -60,7 +65,8 @@  static const av_pixelutils_sad_fn sad_c[] = {
     block_sad_16x16_c,
     block_sad_32x32_c,
 };
-
+#else
+#include "log.h"
 #endif /* CONFIG_PIXELUTILS */
 
 av_pixelutils_sad_fn av_pixelutils_get_sad_fn(int w_bits, int h_bits, int aligned, void *log_ctx)
diff --git a/libavutil/qsort.h b/libavutil/qsort.h
index 39b7a08852..6014f88be3 100644
--- a/libavutil/qsort.h
+++ b/libavutil/qsort.h
@@ -21,7 +21,7 @@ 
 #ifndef AVUTIL_QSORT_H
 #define AVUTIL_QSORT_H
 
-#include "common.h"
+#include "macros.h"
 
 
 /**
diff --git a/libavutil/rc4.c b/libavutil/rc4.c
index ffcb112142..74c1f4892e 100644
--- a/libavutil/rc4.c
+++ b/libavutil/rc4.c
@@ -20,8 +20,9 @@ 
  * License along with FFmpeg; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
-#include "avutil.h"
-#include "common.h"
+
+#include "error.h"
+#include "macros.h"
 #include "mem.h"
 #include "rc4.h"
 
diff --git a/libavutil/ripemd.c b/libavutil/ripemd.c
index b8e9761a24..e170c69f42 100644
--- a/libavutil/ripemd.c
+++ b/libavutil/ripemd.c
@@ -22,10 +22,12 @@ 
 #include <stddef.h>
 #include <string.h>
 
+#include "config.h"
 #include "attributes.h"
-#include "avutil.h"
 #include "bswap.h"
+#include "error.h"
 #include "intreadwrite.h"
+#include "macros.h"
 #include "ripemd.h"
 #include "mem.h"
 
diff --git a/libavutil/sha.c b/libavutil/sha.c
index ab42869c7b..0df044032f 100644
--- a/libavutil/sha.c
+++ b/libavutil/sha.c
@@ -23,9 +23,10 @@ 
 
 #include <string.h>
 
+#include "config.h"
 #include "attributes.h"
-#include "avutil.h"
 #include "bswap.h"
+#include "error.h"
 #include "sha.h"
 #include "intreadwrite.h"
 #include "mem.h"
diff --git a/libavutil/sha512.c b/libavutil/sha512.c
index 97aaaa865c..0574a46f94 100644
--- a/libavutil/sha512.c
+++ b/libavutil/sha512.c
@@ -23,9 +23,10 @@ 
 
 #include <string.h>
 
+#include "config.h"
 #include "attributes.h"
-#include "avutil.h"
 #include "bswap.h"
+#include "error.h"
 #include "sha512.h"
 #include "intreadwrite.h"
 #include "mem.h"
diff --git a/libavutil/stereo3d.c b/libavutil/stereo3d.c
index 279fcc1ff3..9c29ab01b5 100644
--- a/libavutil/stereo3d.c
+++ b/libavutil/stereo3d.c
@@ -21,7 +21,8 @@ 
 #include <string.h>
 
 #include "avstring.h"
-#include "common.h"
+#include "frame.h"
+#include "macros.h"
 #include "mem.h"
 #include "stereo3d.h"
 
diff --git a/libavutil/tea.c b/libavutil/tea.c
index b138f8bea1..93a3795368 100644
--- a/libavutil/tea.c
+++ b/libavutil/tea.c
@@ -22,9 +22,9 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "avutil.h"
-#include "common.h"
+#include <string.h>
 #include "intreadwrite.h"
+#include "mem.h"
 #include "tea.h"
 
 typedef struct AVTEA {
diff --git a/libavutil/tests/color_utils.c b/libavutil/tests/color_utils.c
index ea0127158b..4bdc550330 100644
--- a/libavutil/tests/color_utils.c
+++ b/libavutil/tests/color_utils.c
@@ -18,7 +18,9 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <stdio.h>
 #include "libavutil/color_utils.c"
+#include "libavutil/macros.h"
 
 int main(int argc, char *argv[])
 {
diff --git a/libavutil/tests/pixelutils.c b/libavutil/tests/pixelutils.c
index 2f807584b3..927c8d9217 100644
--- a/libavutil/tests/pixelutils.c
+++ b/libavutil/tests/pixelutils.c
@@ -16,6 +16,10 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <stdio.h>
+
+#include "libavutil/internal.h"
+#include "libavutil/mem.h"
 #include "libavutil/pixelutils.c"
 
 #define W1 320
diff --git a/libavutil/twofish.c b/libavutil/twofish.c
index 649b4bc41b..9f9687eccb 100644
--- a/libavutil/twofish.c
+++ b/libavutil/twofish.c
@@ -18,9 +18,13 @@ 
  * License along with FFmpeg; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
+
+#include <string.h>
+
 #include "twofish.h"
-#include "common.h"
+#include "error.h"
 #include "intreadwrite.h"
+#include "mem.h"
 #include "attributes.h"
 
 #define LR(x, n) ((x) << (n) | (x) >> (32 - (n)))
diff --git a/libavutil/video_enc_params.c b/libavutil/video_enc_params.c
index 7d903af385..54bfed0ed9 100644
--- a/libavutil/video_enc_params.c
+++ b/libavutil/video_enc_params.c
@@ -16,12 +16,10 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include <limits.h>
 #include <stddef.h>
 #include <stdint.h>
 
 #include "buffer.h"
-#include "common.h"
 #include "frame.h"
 #include "mem.h"
 #include "video_enc_params.h"
diff --git a/libavutil/x86/imgutils_init.c b/libavutil/x86/imgutils_init.c
index 4ea398205e..91a16cf594 100644
--- a/libavutil/x86/imgutils_init.c
+++ b/libavutil/x86/imgutils_init.c
@@ -21,9 +21,8 @@ 
 
 #include "libavutil/cpu.h"
 #include "libavutil/error.h"
-#include "libavutil/imgutils.h"
 #include "libavutil/imgutils_internal.h"
-#include "libavutil/internal.h"
+#include "libavutil/macros.h"
 
 #include "cpu.h"
 
diff --git a/libavutil/xtea.c b/libavutil/xtea.c
index f7892af9fb..6f376c365c 100644
--- a/libavutil/xtea.c
+++ b/libavutil/xtea.c
@@ -28,8 +28,8 @@ 
  * @ingroup lavu_xtea
  */
 
-#include "avutil.h"
-#include "common.h"
+#include <string.h>
+#include "config.h"
 #include "intreadwrite.h"
 #include "mem.h"
 #include "xtea.h"
diff --git a/libswscale/input.c b/libswscale/input.c
index 6acc39f89f..fe0c27d743 100644
--- a/libswscale/input.c
+++ b/libswscale/input.c
@@ -21,17 +21,11 @@ 
 #include <math.h>
 #include <stdint.h>
 #include <stdio.h>
-#include <string.h>
 
-#include "libavutil/avutil.h"
 #include "libavutil/bswap.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/mathematics.h"
-#include "libavutil/pixdesc.h"
 #include "libavutil/avassert.h"
 #include "config.h"
-#include "rgb2rgb.h"
-#include "swscale.h"
 #include "swscale_internal.h"
 
 #define input_pixel(pos) (isBE(origin) ? AV_RB16(pos) : AV_RL16(pos))
diff --git a/libswscale/options.c b/libswscale/options.c
index f6ea9e1f9d..4d41b835b1 100644
--- a/libswscale/options.c
+++ b/libswscale/options.c
@@ -18,9 +18,7 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavutil/avutil.h"
 #include "libavutil/opt.h"
-#include "libavutil/pixfmt.h"
 #include "swscale.h"
 #include "swscale_internal.h"
 
diff --git a/libswscale/rgb2rgb.h b/libswscale/rgb2rgb.h
index 48bba1586a..7272e98c57 100644
--- a/libswscale/rgb2rgb.h
+++ b/libswscale/rgb2rgb.h
@@ -26,10 +26,7 @@ 
 #ifndef SWSCALE_RGB2RGB_H
 #define SWSCALE_RGB2RGB_H
 
-#include <inttypes.h>
-
-#include "libavutil/avutil.h"
-#include "swscale.h"
+#include <stdint.h>
 
 /* A full collection of RGB to RGB(BGR) converters */
 extern void (*rgb24tobgr32)(const uint8_t *src, uint8_t *dst, int src_size);
diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index feef3482d2..3ed547d526 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -18,22 +18,18 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include <inttypes.h>
-#include <math.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <string.h>
 
 #include "libavutil/avassert.h"
-#include "libavutil/avutil.h"
 #include "libavutil/bswap.h"
+#include "libavutil/common.h"
 #include "libavutil/cpu.h"
-#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"
 #include "swscale_internal.h"
 #include "swscale.h"
 
diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index 2be23458a1..78979f1c7b 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -26,7 +26,6 @@ 
 #include "config.h"
 
 #include "libavutil/avassert.h"
-#include "libavutil/avutil.h"
 #include "libavutil/common.h"
 #include "libavutil/frame.h"
 #include "libavutil/intreadwrite.h"