diff --git a/doc/examples/filtering_audio.c b/doc/examples/filtering_audio.c
index 508c19c60b..2af73a7031 100644
--- a/doc/examples/filtering_audio.c
+++ b/doc/examples/filtering_audio.c
@@ -34,6 +34,7 @@
 #include <libavformat/avformat.h>
 #include <libavfilter/buffersink.h>
 #include <libavfilter/buffersrc.h>
+#include <libavutil/channel_layout.h>
 #include <libavutil/opt.h>
 
 static const char *filter_descr = "aresample=8000,aformat=sample_fmts=s16:channel_layouts=mono";
diff --git a/doc/examples/transcode_aac.c b/doc/examples/transcode_aac.c
index 711076b5a5..1cf6317e27 100644
--- a/doc/examples/transcode_aac.c
+++ b/doc/examples/transcode_aac.c
@@ -38,6 +38,7 @@
 #include "libavutil/audio_fifo.h"
 #include "libavutil/avassert.h"
 #include "libavutil/avstring.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/frame.h"
 #include "libavutil/opt.h"
 
diff --git a/doc/examples/transcoding.c b/doc/examples/transcoding.c
index 3a97426e2c..51c120dfb7 100644
--- a/doc/examples/transcoding.c
+++ b/doc/examples/transcoding.c
@@ -32,6 +32,7 @@
 #include <libavformat/avformat.h>
 #include <libavfilter/buffersink.h>
 #include <libavfilter/buffersrc.h>
+#include <libavutil/channel_layout.h>
 #include <libavutil/opt.h>
 #include <libavutil/pixdesc.h>
 
diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index f72231790f..553ef0fe4f 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -41,6 +41,7 @@
 #include "libavutil/avassert.h"
 #include "libavutil/avstring.h"
 #include "libavutil/bprint.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/display.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/imgutils.h"
diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index 826c3ba5b4..833830bfc8 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -31,6 +31,7 @@
 #include <stdint.h>
 
 #include "libavutil/avstring.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/eval.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/pixdesc.h"
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 2d452c212e..9ca28c93e7 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -33,6 +33,7 @@
 #include "libavutil/avassert.h"
 #include "libavutil/avstring.h"
 #include "libavutil/bprint.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/display.h"
 #include "libavutil/hash.h"
 #include "libavutil/hdr_dynamic_metadata.h"
diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
index d78e60ec2e..fd46a7d222 100644
--- a/libavcodec/aacdec_template.c
+++ b/libavcodec/aacdec_template.c
@@ -89,6 +89,7 @@
            Parametric Stereo.
  */
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/thread.h"
 
 static VLC vlc_scalefactors;
diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
index 23bfa20eaf..e462566078 100644
--- a/libavcodec/aacenc.c
+++ b/libavcodec/aacenc.c
@@ -30,6 +30,7 @@
  ***********************************/
 #include <float.h>
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/libm.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/opt.h"
diff --git a/libavcodec/aacenc.h b/libavcodec/aacenc.h
index 8ffc94f99b..b106910ce0 100644
--- a/libavcodec/aacenc.h
+++ b/libavcodec/aacenc.h
@@ -22,6 +22,7 @@
 #ifndef AVCODEC_AACENC_H
 #define AVCODEC_AACENC_H
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/mem_internal.h"
 
diff --git a/libavcodec/aacenctab.h b/libavcodec/aacenctab.h
index dbbdf61dfd..f54dd16bed 100644
--- a/libavcodec/aacenctab.h
+++ b/libavcodec/aacenctab.h
@@ -28,6 +28,7 @@
 #ifndef AVCODEC_AACENCTAB_H
 #define AVCODEC_AACENCTAB_H
 
+#include "libavutil/channel_layout.h"
 #include "aac.h"
 
 /** Total number of usable codebooks **/
diff --git a/libavcodec/aptxdec.c b/libavcodec/aptxdec.c
index e7e5459bbf..bdcc076c41 100644
--- a/libavcodec/aptxdec.c
+++ b/libavcodec/aptxdec.c
@@ -20,6 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/channel_layout.h"
 #include "aptx.h"
 
 /*
diff --git a/libavcodec/aptxenc.c b/libavcodec/aptxenc.c
index 733ebc42c3..5ea6053c26 100644
--- a/libavcodec/aptxenc.c
+++ b/libavcodec/aptxenc.c
@@ -20,6 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/channel_layout.h"
 #include "aptx.h"
 #include "encode.h"
 
diff --git a/libavcodec/atrac9dec.c b/libavcodec/atrac9dec.c
index eebb412145..1063044815 100644
--- a/libavcodec/atrac9dec.c
+++ b/libavcodec/atrac9dec.c
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/thread.h"
 
 #include "internal.h"
diff --git a/libavcodec/audiotoolboxdec.c b/libavcodec/audiotoolboxdec.c
index cbd381ef12..a222cde62e 100644
--- a/libavcodec/audiotoolboxdec.c
+++ b/libavcodec/audiotoolboxdec.c
@@ -29,6 +29,7 @@
 #include "internal.h"
 #include "mpegaudiodecheader.h"
 #include "libavutil/avassert.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/opt.h"
 #include "libavutil/log.h"
 
diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c
index f599802b7b..9245aa9dc4 100644
--- a/libavcodec/audiotoolboxenc.c
+++ b/libavcodec/audiotoolboxenc.c
@@ -33,6 +33,7 @@
 #include "internal.h"
 #include "libavformat/isom.h"
 #include "libavutil/avassert.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/opt.h"
 #include "libavutil/log.h"
 
diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index 3b3a3ef05a..6d60026c07 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -27,6 +27,7 @@
 #include "libavutil/avassert.h"
 #include "libavutil/avstring.h"
 #include "libavutil/bprint.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/mem.h"
 #include "libavutil/opt.h"
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index f6d2cde441..292c373c68 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -33,7 +33,6 @@
 #include "libavutil/avutil.h"
 #include "libavutil/buffer.h"
 #include "libavutil/cpu.h"
-#include "libavutil/channel_layout.h"
 #include "libavutil/dict.h"
 #include "libavutil/frame.h"
 #include "libavutil/hwcontext.h"
diff --git a/libavcodec/dca_core.c b/libavcodec/dca_core.c
index accc5efd51..f0a3c18d62 100644
--- a/libavcodec/dca_core.c
+++ b/libavcodec/dca_core.c
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/channel_layout.h"
 #include "dcaadpcm.h"
 #include "dcadec.h"
 #include "dcadata.h"
diff --git a/libavcodec/dca_xll.c b/libavcodec/dca_xll.c
index d265cab8df..ab14dbcc88 100644
--- a/libavcodec/dca_xll.c
+++ b/libavcodec/dca_xll.c
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/channel_layout.h"
 #include "dcadec.h"
 #include "dcadata.h"
 #include "dcamath.h"
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 6def4047e5..71c76d33b2 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -30,6 +30,7 @@
 #include "libavutil/avassert.h"
 #include "libavutil/avstring.h"
 #include "libavutil/bprint.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/common.h"
 #include "libavutil/frame.h"
 #include "libavutil/hwcontext.h"
diff --git a/libavcodec/dolby_e.c b/libavcodec/dolby_e.c
index cd4c8c2c3c..6c0d54be4c 100644
--- a/libavcodec/dolby_e.c
+++ b/libavcodec/dolby_e.c
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/thread.h"
 #include "libavutil/mem.h"
diff --git a/libavcodec/dolby_e_parser.c b/libavcodec/dolby_e_parser.c
index ab8f1b6ef1..23bddd14f3 100644
--- a/libavcodec/dolby_e_parser.c
+++ b/libavcodec/dolby_e_parser.c
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/channel_layout.h"
 #include "avcodec.h"
 #include "dolby_e.h"
 #include "get_bits.h"
diff --git a/libavcodec/dvaudiodec.c b/libavcodec/dvaudiodec.c
index e12f43c485..82e6dbe36c 100644
--- a/libavcodec/dvaudiodec.c
+++ b/libavcodec/dvaudiodec.c
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/intreadwrite.h"
 #include "avcodec.h"
 #include "internal.h"
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index a569904f2c..98dfbfdff3 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -20,6 +20,7 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/avassert.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/frame.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
diff --git a/libavcodec/evrcdec.c b/libavcodec/evrcdec.c
index 75de6cf803..59fcb14c52 100644
--- a/libavcodec/evrcdec.c
+++ b/libavcodec/evrcdec.c
@@ -25,6 +25,7 @@
  * @author Paul B Mahol
  */
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/opt.h"
 #include "avcodec.h"
diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c
index de36d33333..595928927d 100644
--- a/libavcodec/flacenc.c
+++ b/libavcodec/flacenc.c
@@ -20,6 +20,7 @@
  */
 
 #include "libavutil/avassert.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/crc.h"
 #include "libavutil/intmath.h"
 #include "libavutil/md5.h"
diff --git a/libavcodec/g722enc.c b/libavcodec/g722enc.c
index bb011fb81b..75b926ef8e 100644
--- a/libavcodec/g722enc.c
+++ b/libavcodec/g722enc.c
@@ -28,6 +28,7 @@
  */
 
 #include "libavutil/avassert.h"
+#include "libavutil/channel_layout.h"
 #include "avcodec.h"
 #include "encode.h"
 #include "internal.h"
diff --git a/libavcodec/ilbcdec.c b/libavcodec/ilbcdec.c
index 3df46b242f..4d0465087f 100644
--- a/libavcodec/ilbcdec.c
+++ b/libavcodec/ilbcdec.c
@@ -30,6 +30,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include "libavutil/channel_layout.h"
 #include "avcodec.h"
 #include "internal.h"
 #include "get_bits.h"
diff --git a/libavcodec/libcodec2.c b/libavcodec/libcodec2.c
index 2996dc42f5..ab9250143b 100644
--- a/libavcodec/libcodec2.c
+++ b/libavcodec/libcodec2.c
@@ -20,6 +20,7 @@
  */
 
 #include <codec2/codec2.h>
+#include "libavutil/channel_layout.h"
 #include "avcodec.h"
 #include "libavutil/opt.h"
 #include "encode.h"
diff --git a/libavcodec/libgsmenc.c b/libavcodec/libgsmenc.c
index 97ba789046..a2f6c1c62e 100644
--- a/libavcodec/libgsmenc.c
+++ b/libavcodec/libgsmenc.c
@@ -34,6 +34,7 @@
 #include <gsm/gsm.h>
 #endif
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/common.h"
 
 #include "avcodec.h"
diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c
index 6602500f26..82002ac346 100644
--- a/libavcodec/libopusenc.c
+++ b/libavcodec/libopusenc.c
@@ -22,6 +22,7 @@
 #include <opus.h>
 #include <opus_multistream.h>
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/opt.h"
 #include "avcodec.h"
 #include "bytestream.h"
diff --git a/libavcodec/libshine.c b/libavcodec/libshine.c
index 04d5914701..fbc84846ae 100644
--- a/libavcodec/libshine.c
+++ b/libavcodec/libshine.c
@@ -21,6 +21,7 @@
 
 #include <shine/layer3.h>
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/intreadwrite.h"
 #include "audio_frame_queue.h"
 #include "avcodec.h"
diff --git a/libavcodec/libtwolame.c b/libavcodec/libtwolame.c
index 1f6808b6f5..a71febc91f 100644
--- a/libavcodec/libtwolame.c
+++ b/libavcodec/libtwolame.c
@@ -26,6 +26,7 @@
 
 #include <twolame.h>
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/common.h"
 #include "libavutil/opt.h"
 
diff --git a/libavcodec/libvorbisenc.c b/libavcodec/libvorbisenc.c
index ec674695d4..fa0d5f4b42 100644
--- a/libavcodec/libvorbisenc.c
+++ b/libavcodec/libvorbisenc.c
@@ -21,6 +21,7 @@
 #include <vorbis/vorbisenc.h>
 
 #include "libavutil/avassert.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/fifo.h"
 #include "libavutil/opt.h"
 #include "avcodec.h"
diff --git a/libavcodec/mlp.c b/libavcodec/mlp.c
index 74363c3b95..dcec145eb0 100644
--- a/libavcodec/mlp.c
+++ b/libavcodec/mlp.c
@@ -21,6 +21,7 @@
 
 #include <stdint.h>
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/crc.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/thread.h"
diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c
index 7693feb127..8b61fc6b1e 100644
--- a/libavcodec/mlpenc.c
+++ b/libavcodec/mlpenc.c
@@ -25,6 +25,7 @@
 #include "internal.h"
 #include "put_bits.h"
 #include "audio_frame_queue.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/crc.h"
 #include "libavutil/avstring.h"
 #include "libavutil/samplefmt.h"
diff --git a/libavcodec/mpegaudioenc_fixed.c b/libavcodec/mpegaudioenc_fixed.c
index ce8963fd0b..fb1ba4e1bf 100644
--- a/libavcodec/mpegaudioenc_fixed.c
+++ b/libavcodec/mpegaudioenc_fixed.c
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/channel_layout.h"
 #include "mpegaudioenc_template.c"
 
 const AVCodec ff_mp2fixed_encoder = {
diff --git a/libavcodec/mpegaudioenc_float.c b/libavcodec/mpegaudioenc_float.c
index ba3b096579..accb909a6f 100644
--- a/libavcodec/mpegaudioenc_float.c
+++ b/libavcodec/mpegaudioenc_float.c
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/channel_layout.h"
 #define USE_FLOATS 1
 #include "mpegaudioenc_template.c"
 
diff --git a/libavcodec/opus.c b/libavcodec/opus.c
index 64de246720..5ca6ca92f3 100644
--- a/libavcodec/opus.c
+++ b/libavcodec/opus.c
@@ -26,6 +26,7 @@
 
 #include <stdint.h>
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/error.h"
 #include "libavutil/ffmath.h"
 
diff --git a/libavcodec/opusenc.c b/libavcodec/opusenc.c
index 7b22b929f7..b7f4760a25 100644
--- a/libavcodec/opusenc.c
+++ b/libavcodec/opusenc.c
@@ -25,6 +25,7 @@
 #include "opusenc_psy.h"
 #include "opustab.h"
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/mem_internal.h"
 #include "libavutil/opt.h"
diff --git a/libavcodec/pafaudio.c b/libavcodec/pafaudio.c
index cb80f3a186..969eb7fa97 100644
--- a/libavcodec/pafaudio.c
+++ b/libavcodec/pafaudio.c
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/intreadwrite.h"
 
 #include "avcodec.h"
diff --git a/libavcodec/pcm-dvdenc.c b/libavcodec/pcm-dvdenc.c
index ae7de65f1d..c9afac69d2 100644
--- a/libavcodec/pcm-dvdenc.c
+++ b/libavcodec/pcm-dvdenc.c
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/channel_layout.h"
 #include "avcodec.h"
 #include "bytestream.h"
 #include "encode.h"
diff --git a/libavcodec/ra144enc.c b/libavcodec/ra144enc.c
index 4d12294c97..7a96354633 100644
--- a/libavcodec/ra144enc.c
+++ b/libavcodec/ra144enc.c
@@ -27,6 +27,7 @@
 
 #include <float.h>
 
+#include "libavutil/channel_layout.h"
 #include "avcodec.h"
 #include "audio_frame_queue.h"
 #include "celp_filters.h"
diff --git a/libavcodec/s302m.c b/libavcodec/s302m.c
index 60d1547884..b09c1293a0 100644
--- a/libavcodec/s302m.c
+++ b/libavcodec/s302m.c
@@ -20,6 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/opt.h"
 #include "libavutil/log.h"
diff --git a/libavcodec/s302menc.c b/libavcodec/s302menc.c
index 33633627f6..528d712e79 100644
--- a/libavcodec/s302menc.c
+++ b/libavcodec/s302menc.c
@@ -20,6 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/channel_layout.h"
 #include "avcodec.h"
 #include "encode.h"
 #include "internal.h"
diff --git a/libavcodec/sbcdec.c b/libavcodec/sbcdec.c
index db61f43a5a..e14d8c8958 100644
--- a/libavcodec/sbcdec.c
+++ b/libavcodec/sbcdec.c
@@ -32,6 +32,7 @@
 
 #include "avcodec.h"
 #include "internal.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/mem_internal.h"
 #include "sbc.h"
diff --git a/libavcodec/sbcenc.c b/libavcodec/sbcenc.c
index 5f9a214a1a..45156277b7 100644
--- a/libavcodec/sbcenc.c
+++ b/libavcodec/sbcenc.c
@@ -30,6 +30,7 @@
  * SBC encoder implementation
  */
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/opt.h"
 #include "avcodec.h"
 #include "encode.h"
diff --git a/libavcodec/siren.c b/libavcodec/siren.c
index 5937f0d56c..87464808a4 100644
--- a/libavcodec/siren.c
+++ b/libavcodec/siren.c
@@ -21,6 +21,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/tx.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/mem_internal.h"
diff --git a/libavcodec/tak.c b/libavcodec/tak.c
index 8aa956b661..7221a80094 100644
--- a/libavcodec/tak.c
+++ b/libavcodec/tak.c
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/crc.h"
 #include "libavutil/intreadwrite.h"
 
diff --git a/libavcodec/tta.c b/libavcodec/tta.c
index f628071ba3..d9ff45fad6 100644
--- a/libavcodec/tta.c
+++ b/libavcodec/tta.c
@@ -29,6 +29,7 @@
 
 #include <limits.h>
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/crc.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/opt.h"
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 342709353f..0b12ae2930 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -28,6 +28,7 @@
 #include "config.h"
 #include "libavutil/avassert.h"
 #include "libavutil/avstring.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/mem.h"
 #include "libavutil/pixdesc.h"
diff --git a/libavcodec/wavpackenc.c b/libavcodec/wavpackenc.c
index bd548a5c30..dc4f4e303b 100644
--- a/libavcodec/wavpackenc.c
+++ b/libavcodec/wavpackenc.c
@@ -20,6 +20,7 @@
 
 #define BITSTREAM_WRITER_LE
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/opt.h"
 #include "avcodec.h"
diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
index bad3760159..5f46c97596 100644
--- a/libavdevice/avfoundation.m
+++ b/libavdevice/avfoundation.m
@@ -28,6 +28,7 @@
 #import <AVFoundation/AVFoundation.h>
 #include <pthread.h>
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/opt.h"
 #include "libavutil/avstring.h"
diff --git a/libavdevice/pulse_audio_enc.c b/libavdevice/pulse_audio_enc.c
index bfd7be4f37..4ff425d33f 100644
--- a/libavdevice/pulse_audio_enc.c
+++ b/libavdevice/pulse_audio_enc.c
@@ -23,6 +23,7 @@
 #include <pulse/error.h>
 #include "libavformat/avformat.h"
 #include "libavformat/internal.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/internal.h"
 #include "libavutil/opt.h"
 #include "libavutil/time.h"
diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c
index 26d61d4c0f..309eb3dd2e 100644
--- a/libavfilter/af_afir.c
+++ b/libavfilter/af_afir.c
@@ -26,6 +26,7 @@
 #include <float.h>
 
 #include "libavutil/avstring.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/common.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/intreadwrite.h"
diff --git a/libavfilter/af_apulsator.c b/libavfilter/af_apulsator.c
index 6be61eb905..56ff4579d6 100644
--- a/libavfilter/af_apulsator.c
+++ b/libavfilter/af_apulsator.c
@@ -19,6 +19,7 @@
  */
 
 #include "libavutil/avassert.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/opt.h"
 #include "avfilter.h"
 #include "internal.h"
diff --git a/libavfilter/af_biquads.c b/libavfilter/af_biquads.c
index c477906f87..0baf5541fd 100644
--- a/libavfilter/af_biquads.c
+++ b/libavfilter/af_biquads.c
@@ -63,6 +63,7 @@
  */
 
 #include "libavutil/avassert.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/ffmath.h"
 #include "libavutil/opt.h"
 #include "audio.h"
diff --git a/libavfilter/af_firequalizer.c b/libavfilter/af_firequalizer.c
index c0b7b1aa4d..a4de76ee0f 100644
--- a/libavfilter/af_firequalizer.c
+++ b/libavfilter/af_firequalizer.c
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/opt.h"
 #include "libavutil/eval.h"
 #include "libavutil/avassert.h"
diff --git a/libavfilter/af_hdcd.c b/libavfilter/af_hdcd.c
index badac0cce6..144c0d31ed 100644
--- a/libavfilter/af_hdcd.c
+++ b/libavfilter/af_hdcd.c
@@ -43,6 +43,7 @@
  * HDCD decoding filter
  */
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/opt.h"
 #include "libavutil/avassert.h"
 #include "avfilter.h"
diff --git a/libavfilter/af_speechnorm.c b/libavfilter/af_speechnorm.c
index a2b51a1bd8..d044177352 100644
--- a/libavfilter/af_speechnorm.c
+++ b/libavfilter/af_speechnorm.c
@@ -28,6 +28,7 @@
 #include <float.h>
 
 #include "libavutil/avassert.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/opt.h"
 
 #define FF_BUFQUEUE_SIZE (1024)
diff --git a/libavfilter/asrc_afirsrc.c b/libavfilter/asrc_afirsrc.c
index 4002118d6a..0ede722ba1 100644
--- a/libavfilter/asrc_afirsrc.c
+++ b/libavfilter/asrc_afirsrc.c
@@ -18,6 +18,7 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/eval.h"
 #include "libavutil/opt.h"
 #include "libavutil/tx.h"
diff --git a/libavfilter/asrc_anoisesrc.c b/libavfilter/asrc_anoisesrc.c
index 286334acc8..0aab14b58f 100644
--- a/libavfilter/asrc_anoisesrc.c
+++ b/libavfilter/asrc_anoisesrc.c
@@ -18,6 +18,7 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/opt.h"
 #include "audio.h"
 #include "avfilter.h"
diff --git a/libavfilter/asrc_hilbert.c b/libavfilter/asrc_hilbert.c
index 64e566084c..e7d596ee46 100644
--- a/libavfilter/asrc_hilbert.c
+++ b/libavfilter/asrc_hilbert.c
@@ -18,6 +18,7 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/opt.h"
 #include "audio.h"
 #include "avfilter.h"
diff --git a/libavfilter/asrc_sinc.c b/libavfilter/asrc_sinc.c
index e4aa51c0d0..5397d89c77 100644
--- a/libavfilter/asrc_sinc.c
+++ b/libavfilter/asrc_sinc.c
@@ -20,6 +20,7 @@
  */
 
 #include "libavutil/avassert.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/opt.h"
 
 #include "libavcodec/avfft.h"
diff --git a/libavfilter/avf_showcqt.c b/libavfilter/avf_showcqt.c
index 996a6f63c5..37589dd151 100644
--- a/libavfilter/avf_showcqt.c
+++ b/libavfilter/avf_showcqt.c
@@ -21,6 +21,7 @@
 #include "config.h"
 #include "libavcodec/avfft.h"
 #include "libavutil/avassert.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/opt.h"
 #include "libavutil/xga_font_data.h"
 #include "libavutil/eval.h"
diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c
index 54f6738f9a..92b092fac6 100644
--- a/libavfilter/src_movie.c
+++ b/libavfilter/src_movie.c
@@ -33,6 +33,7 @@
 #include "libavutil/attributes.h"
 #include "libavutil/avstring.h"
 #include "libavutil/avassert.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/opt.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
diff --git a/libavfilter/tests/formats.c b/libavfilter/tests/formats.c
index ee497f3b90..c1e30e73ee 100644
--- a/libavfilter/tests/formats.c
+++ b/libavfilter/tests/formats.c
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/channel_layout.h"
 #include "libavfilter/formats.c"
 
 #undef printf
diff --git a/libavformat/alp.c b/libavformat/alp.c
index bc19f02083..0d74e73c0b 100644
--- a/libavformat/alp.c
+++ b/libavformat/alp.c
@@ -19,6 +19,8 @@
  * License along with FFmpeg; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
+
+#include "libavutil/channel_layout.h"
 #include "avformat.h"
 #include "internal.h"
 #include "rawenc.h"
diff --git a/libavformat/apm.c b/libavformat/apm.c
index 6ae53b8712..d5499f1d90 100644
--- a/libavformat/apm.c
+++ b/libavformat/apm.c
@@ -23,6 +23,7 @@
 #include "internal.h"
 #include "rawenc.h"
 #include "libavutil/avassert.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
 
diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c
index c3ac49fdc2..23e1437209 100644
--- a/libavformat/argo_asf.c
+++ b/libavformat/argo_asf.c
@@ -21,6 +21,7 @@
  */
 #include "avformat.h"
 #include "internal.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/avassert.h"
 #include "libavutil/opt.h"
diff --git a/libavformat/argo_cvg.c b/libavformat/argo_cvg.c
index 73db777199..60bc598eb4 100644
--- a/libavformat/argo_cvg.c
+++ b/libavformat/argo_cvg.c
@@ -19,6 +19,8 @@
  * License along with FFmpeg; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
+
+#include "libavutil/channel_layout.h"
 #include "avformat.h"
 #include "internal.h"
 #include "libavutil/opt.h"
diff --git a/libavformat/codec2.c b/libavformat/codec2.c
index ce249d4470..271d2dc703 100644
--- a/libavformat/codec2.c
+++ b/libavformat/codec2.c
@@ -21,6 +21,7 @@
 
 #include <memory.h>
 #include "libavcodec/codec2utils.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/intreadwrite.h"
 #include "avio_internal.h"
 #include "avformat.h"
diff --git a/libavformat/derf.c b/libavformat/derf.c
index a09433ba07..d50a853194 100644
--- a/libavformat/derf.c
+++ b/libavformat/derf.c
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/intreadwrite.h"
 #include "avformat.h"
 #include "internal.h"
diff --git a/libavformat/dsfdec.c b/libavformat/dsfdec.c
index 690fd02bb3..02ee4c1231 100644
--- a/libavformat/dsfdec.c
+++ b/libavformat/dsfdec.c
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/intreadwrite.h"
 #include "avformat.h"
 #include "internal.h"
diff --git a/libavformat/eacdata.c b/libavformat/eacdata.c
index 86b1101d6b..0ad1c937a9 100644
--- a/libavformat/eacdata.c
+++ b/libavformat/eacdata.c
@@ -28,6 +28,7 @@
  *  http://wiki.multimedia.cx/index.php?title=EA_Command_And_Conquer_3_Audio_Codec
  */
 
+#include "libavutil/channel_layout.h"
 #include "avformat.h"
 #include "internal.h"
 
diff --git a/libavformat/framehash.c b/libavformat/framehash.c
index 8d90793d7c..04c40825b9 100644
--- a/libavformat/framehash.c
+++ b/libavformat/framehash.c
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/channel_layout.h"
 #include "internal.h"
 
 int ff_framehash_write_header(AVFormatContext *s)
diff --git a/libavformat/fwse.c b/libavformat/fwse.c
index 970d5ffe89..ed8cd3a6db 100644
--- a/libavformat/fwse.c
+++ b/libavformat/fwse.c
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/intreadwrite.h"
 #include "avformat.h"
 #include "internal.h"
diff --git a/libavformat/genh.c b/libavformat/genh.c
index 6d36e5f5fc..f9b222d8cd 100644
--- a/libavformat/genh.c
+++ b/libavformat/genh.c
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/intreadwrite.h"
 #include "libavcodec/internal.h"
 #include "avformat.h"
diff --git a/libavformat/ifv.c b/libavformat/ifv.c
index f82328ada0..b3b9213aa5 100644
--- a/libavformat/ifv.c
+++ b/libavformat/ifv.c
@@ -20,6 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/channel_layout.h"
 #include "avformat.h"
 #include "internal.h"
 #include "avio_internal.h"
diff --git a/libavformat/imx.c b/libavformat/imx.c
index e26f3728ff..6d3a5ad8d7 100644
--- a/libavformat/imx.c
+++ b/libavformat/imx.c
@@ -24,6 +24,7 @@
 #include "internal.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/avassert.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/internal.h"
 
 #define IMX_TAG MKTAG('I', 'M', 'A', 'X')
diff --git a/libavformat/isom.c b/libavformat/isom.c
index 35c5eb982e..4df5440023 100644
--- a/libavformat/isom.c
+++ b/libavformat/isom.c
@@ -27,6 +27,7 @@
 #include "libavcodec/mpeg4audio.h"
 #include "libavcodec/mpegaudiodata.h"
 #include "libavutil/avstring.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/intreadwrite.h"
 
 /* http://www.mp4ra.org */
diff --git a/libavformat/kvag.c b/libavformat/kvag.c
index 94dc1ddc04..04e9ec813e 100644
--- a/libavformat/kvag.c
+++ b/libavformat/kvag.c
@@ -19,6 +19,8 @@
  * License along with FFmpeg; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
+
+#include "libavutil/channel_layout.h"
 #include "avformat.h"
 #include "internal.h"
 #include "rawenc.h"
diff --git a/libavformat/libopenmpt.c b/libavformat/libopenmpt.c
index 628b0939dc..ebf1839572 100644
--- a/libavformat/libopenmpt.c
+++ b/libavformat/libopenmpt.c
@@ -31,6 +31,7 @@
 #endif
 
 #include "libavutil/avstring.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/opt.h"
 #include "avformat.h"
 #include "internal.h"
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 04f3e94158..7562b2e24d 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -43,6 +43,7 @@
 #include "libavcodec/raw.h"
 #include "internal.h"
 #include "libavutil/avstring.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/intfloat.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/libm.h"
diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index 178e71d891..7e88367938 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/channel_layout.h"
 #include "avformat.h"
 #include "avio_internal.h"
 #include "internal.h"
diff --git a/libavformat/pp_bnk.c b/libavformat/pp_bnk.c
index 9455a575b7..41c883dafe 100644
--- a/libavformat/pp_bnk.c
+++ b/libavformat/pp_bnk.c
@@ -23,6 +23,7 @@
 #include "internal.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/avassert.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/internal.h"
 
 #define PP_BNK_MAX_READ_SIZE    4096
diff --git a/libavformat/riffenc.c b/libavformat/riffenc.c
index df04b31893..43c8bf957a 100644
--- a/libavformat/riffenc.c
+++ b/libavformat/riffenc.c
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/dict.h"
 #include "libavutil/log.h"
 #include "libavutil/mathematics.h"
diff --git a/libavformat/sbgdec.c b/libavformat/sbgdec.c
index dafdc4a1cc..bd72db5f08 100644
--- a/libavformat/sbgdec.c
+++ b/libavformat/sbgdec.c
@@ -22,6 +22,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
+#include "libavutil/channel_layout.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/log.h"
 #include "libavutil/opt.h"
diff --git a/libavformat/sga.c b/libavformat/sga.c
index 3dc62317a1..16e8fe516d 100644
--- a/libavformat/sga.c
+++ b/libavformat/sga.c
@@ -22,6 +22,7 @@
 
 #include "libavutil/intreadwrite.h"
 #include "libavutil/avassert.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/internal.h"
 #include "avformat.h"
 #include "internal.h"
diff --git a/libavformat/wsddec.c b/libavformat/wsddec.c
index 169a96c71f..1ce9cb0b61 100644
--- a/libavformat/wsddec.c
+++ b/libavformat/wsddec.c
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/timecode.h"
 #include "avformat.h"
diff --git a/libswresample/options.c b/libswresample/options.c
index 00d4f7c1c9..6911709157 100644
--- a/libswresample/options.c
+++ b/libswresample/options.c
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/opt.h"
 #include "swresample_internal.h"
 
diff --git a/libswresample/swresample_frame.c b/libswresample/swresample_frame.c
index 2853266d6c..d95c1cc537 100644
--- a/libswresample/swresample_frame.c
+++ b/libswresample/swresample_frame.c
@@ -20,6 +20,7 @@
  */
 
 #include "swresample_internal.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/frame.h"
 #include "libavutil/opt.h"
 
diff --git a/tests/api/api-flac-test.c b/tests/api/api-flac-test.c
index 88b15e8722..b4f52b191f 100644
--- a/tests/api/api-flac-test.c
+++ b/tests/api/api-flac-test.c
@@ -28,6 +28,7 @@
  */
 
 #include "libavcodec/avcodec.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/common.h"
 #include "libavutil/samplefmt.h"
 
