diff mbox series

[FFmpeg-devel,15/21] avcodec/internal: Move ff_get_buffer() to decode.h

Message ID DB6PR0101MB22144D43B6DF4E75BAF863E28F729@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com
State Accepted
Commit 66b691f99f77ebb59d5c192aab4eefec4d200be8
Headers show
Series [FFmpeg-devel,01/11] avcodec/tests/avcodec: Mark frame-thrd encoder incompatible with delay | expand

Commit Message

Andreas Rheinhardt Aug. 25, 2022, 4:33 p.m. UTC
Only used by decoders (encoders have ff_encode_alloc_frame()).

Also clean up the other headers a bit while removing now redundant
internal.h inclusions.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/012v.c                  | 2 +-
 libavcodec/4xm.c                   | 2 +-
 libavcodec/8bps.c                  | 5 +----
 libavcodec/8svx.c                  | 2 +-
 libavcodec/aacdec_template.c       | 1 +
 libavcodec/ac3dec.c                | 1 +
 libavcodec/adpcm.c                 | 2 +-
 libavcodec/adxdec.c                | 2 +-
 libavcodec/agm.c                   | 1 +
 libavcodec/aliaspixdec.c           | 1 +
 libavcodec/alsdec.c                | 1 +
 libavcodec/amrnbdec.c              | 3 +--
 libavcodec/amrwbdec.c              | 3 +--
 libavcodec/apedec.c                | 2 +-
 libavcodec/aptxdec.c               | 2 +-
 libavcodec/arbc.c                  | 7 +------
 libavcodec/asvdec.c                | 2 +-
 libavcodec/atrac1.c                | 4 +---
 libavcodec/atrac3.c                | 3 +--
 libavcodec/atrac3plusdec.c         | 2 +-
 libavcodec/atrac9dec.c             | 2 +-
 libavcodec/audiotoolboxdec.c       | 2 +-
 libavcodec/aura.c                  | 2 +-
 libavcodec/avrndec.c               | 2 +-
 libavcodec/avuidec.c               | 2 +-
 libavcodec/bfi.c                   | 2 +-
 libavcodec/bink.c                  | 2 --
 libavcodec/bintext.c               | 2 +-
 libavcodec/bmp.c                   | 1 +
 libavcodec/bmvaudio.c              | 2 +-
 libavcodec/bmvvideo.c              | 2 +-
 libavcodec/brenderpix.c            | 1 +
 libavcodec/cavsdec.c               | 1 +
 libavcodec/cdxl.c                  | 1 +
 libavcodec/cljrdec.c               | 2 +-
 libavcodec/cngdec.c                | 1 +
 libavcodec/cook.c                  | 2 +-
 libavcodec/cyuv.c                  | 4 +---
 libavcodec/dca_core.c              | 1 +
 libavcodec/dca_lbr.c               | 1 +
 libavcodec/dca_xll.c               | 1 +
 libavcodec/dds.c                   | 1 +
 libavcodec/decode.h                | 7 +++++++
 libavcodec/dfa.c                   | 2 +-
 libavcodec/dfpwmdec.c              | 2 +-
 libavcodec/diracdec.c              | 1 +
 libavcodec/dolby_e.c               | 2 +-
 libavcodec/dpcm.c                  | 3 +--
 libavcodec/dpx.c                   | 1 +
 libavcodec/dsddec.c                | 1 +
 libavcodec/dsicinaudio.c           | 4 ++--
 libavcodec/dss_sp.c                | 3 +--
 libavcodec/dstdec.c                | 3 +--
 libavcodec/dvaudiodec.c            | 2 +-
 libavcodec/dxa.c                   | 5 +----
 libavcodec/eacmv.c                 | 1 +
 libavcodec/eamad.c                 | 1 +
 libavcodec/eatgq.c                 | 1 +
 libavcodec/eatgv.c                 | 1 +
 libavcodec/eatqi.c                 | 1 +
 libavcodec/escape124.c             | 2 +-
 libavcodec/escape130.c             | 2 +-
 libavcodec/evrcdec.c               | 2 +-
 libavcodec/fastaudio.c             | 5 +----
 libavcodec/ffwavesynth.c           | 2 +-
 libavcodec/fitsdec.c               | 1 +
 libavcodec/fmvc.c                  | 3 +--
 libavcodec/frwu.c                  | 2 +-
 libavcodec/g2meet.c                | 1 +
 libavcodec/g722dec.c               | 2 +-
 libavcodec/g723_1dec.c             | 3 +--
 libavcodec/g726.c                  | 2 +-
 libavcodec/g729dec.c               | 3 +--
 libavcodec/gdv.c                   | 1 -
 libavcodec/gemdec.c                | 1 +
 libavcodec/gsmdec.c                | 2 +-
 libavcodec/hcadec.c                | 3 +--
 libavcodec/hcom.c                  | 2 +-
 libavcodec/hnm4video.c             | 2 +-
 libavcodec/hq_hqa.c                | 1 +
 libavcodec/idcinvideo.c            | 4 +---
 libavcodec/iff.c                   | 3 +--
 libavcodec/ilbcdec.c               | 2 +-
 libavcodec/imc.c                   | 3 +--
 libavcodec/imm4.c                  | 1 +
 libavcodec/indeo3.c                | 1 +
 libavcodec/internal.h              | 7 -------
 libavcodec/interplayacm.c          | 2 +-
 libavcodec/interplayvideo.c        | 2 --
 libavcodec/ivi.c                   | 1 +
 libavcodec/jvdec.c                 | 1 -
 libavcodec/kgv1dec.c               | 1 +
 libavcodec/kmvc.c                  | 2 --
 libavcodec/libaomdec.c             | 1 +
 libavcodec/libcelt_dec.c           | 2 +-
 libavcodec/libcodec2.c             | 2 +-
 libavcodec/libfdk-aacdec.c         | 2 +-
 libavcodec/libgsmdec.c             | 2 +-
 libavcodec/libilbc.c               | 2 +-
 libavcodec/libjxldec.c             | 1 +
 libavcodec/libopencore-amr.c       | 2 +-
 libavcodec/libopenh264dec.c        | 1 +
 libavcodec/libopusdec.c            | 1 +
 libavcodec/librsvgdec.c            | 1 +
 libavcodec/libspeexdec.c           | 2 +-
 libavcodec/libuavs3d.c             | 1 +
 libavcodec/libvorbisdec.c          | 2 +-
 libavcodec/loco.c                  | 2 +-
 libavcodec/m101.c                  | 2 +-
 libavcodec/mace.c                  | 2 +-
 libavcodec/mlpdec.c                | 1 +
 libavcodec/mpc7.c                  | 2 +-
 libavcodec/mpc8.c                  | 2 +-
 libavcodec/mpeg12dec.c             | 1 +
 libavcodec/mpegaudiodec_template.c | 2 +-
 libavcodec/mscc.c                  | 3 +--
 libavcodec/msp2dec.c               | 2 +-
 libavcodec/mss2.c                  | 1 -
 libavcodec/mv30.c                  | 5 ++---
 libavcodec/mvcdec.c                | 1 +
 libavcodec/mvha.c                  | 7 +------
 libavcodec/mwsc.c                  | 4 +---
 libavcodec/mxpegdec.c              | 2 +-
 libavcodec/nellymoserdec.c         | 3 +--
 libavcodec/on2avc.c                | 2 +-
 libavcodec/opusdec.c               | 4 +---
 libavcodec/pafaudio.c              | 2 +-
 libavcodec/pcm-bluray.c            | 2 +-
 libavcodec/pcm-dvd.c               | 2 +-
 libavcodec/pcm.c                   | 3 +--
 libavcodec/pcx.c                   | 1 +
 libavcodec/pgxdec.c                | 2 +-
 libavcodec/pictordec.c             | 1 +
 libavcodec/pnmdec.c                | 2 +-
 libavcodec/prosumer.c              | 3 +--
 libavcodec/psd.c                   | 1 +
 libavcodec/ptx.c                   | 2 +-
 libavcodec/qcelpdec.c              | 4 +---
 libavcodec/qdm2.c                  | 3 +--
 libavcodec/qdmc.c                  | 3 +--
 libavcodec/qdrw.c                  | 1 +
 libavcodec/qpeg.c                  | 1 -
 libavcodec/r210dec.c               | 2 +-
 libavcodec/ra144dec.c              | 2 +-
 libavcodec/ra288.c                 | 2 +-
 libavcodec/ralf.c                  | 2 +-
 libavcodec/rasc.c                  | 3 +--
 libavcodec/rl2.c                   | 1 +
 libavcodec/s302m.c                 | 3 +--
 libavcodec/sanm.c                  | 1 +
 libavcodec/sbcdec.c                | 2 +-
 libavcodec/scpr.c                  | 3 ---
 libavcodec/scpr3.c                 | 1 -
 libavcodec/sga.c                   | 1 +
 libavcodec/sgidec.c                | 1 +
 libavcodec/sgirledec.c             | 2 +-
 libavcodec/shorten.c               | 2 +-
 libavcodec/sipr.c                  | 2 +-
 libavcodec/siren.c                 | 3 +--
 libavcodec/smacker.c               | 5 +----
 libavcodec/snow.c                  | 7 +------
 libavcodec/sonic.c                 | 2 +-
 libavcodec/speedhq.c               | 3 +--
 libavcodec/speexdec.c              | 2 +-
 libavcodec/sunrast.c               | 1 +
 libavcodec/svq1dec.c               | 1 +
 libavcodec/svq3.c                  | 1 +
 libavcodec/targa.c                 | 1 +
 libavcodec/targa_y216dec.c         | 2 +-
 libavcodec/tdsc.c                  | 1 +
 libavcodec/tmv.c                   | 2 +-
 libavcodec/truemotion2rt.c         | 1 +
 libavcodec/truespeech.c            | 3 +--
 libavcodec/twinvq.c                | 2 +-
 libavcodec/txd.c                   | 1 +
 libavcodec/v210x.c                 | 2 +-
 libavcodec/v308dec.c               | 2 +-
 libavcodec/v408dec.c               | 2 +-
 libavcodec/vb.c                    | 5 +----
 libavcodec/vbndec.c                | 1 +
 libavcodec/vc1dec.c                | 1 -
 libavcodec/vcr1.c                  | 2 +-
 libavcodec/vima.c                  | 2 +-
 libavcodec/vmdaudio.c              | 2 +-
 libavcodec/vmdvideo.c              | 2 +-
 libavcodec/vorbisdec.c             | 2 +-
 libavcodec/vp56.c                  | 1 +
 libavcodec/wmadec.c                | 1 +
 libavcodec/wmalosslessdec.c        | 3 +--
 libavcodec/wmaprodec.c             | 3 ++-
 libavcodec/wmavoice.c              | 2 +-
 libavcodec/wnv1.c                  | 2 +-
 libavcodec/ws-snd1.c               | 2 +-
 libavcodec/xan.c                   | 4 +---
 libavcodec/xbmdec.c                | 1 +
 libavcodec/xfacedec.c              | 4 +---
 libavcodec/xl.c                    | 2 +-
 libavcodec/xpmdec.c                | 2 +-
 libavcodec/xwddec.c                | 1 +
 libavcodec/y41pdec.c               | 2 +-
 libavcodec/yuv4dec.c               | 2 +-
 libavcodec/zerocodec.c             | 2 +-
 libavcodec/zmbv.c                  | 5 ++---
 203 files changed, 202 insertions(+), 229 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/012v.c b/libavcodec/012v.c
index 805aaed221..700feb3024 100644
--- a/libavcodec/012v.c
+++ b/libavcodec/012v.c
@@ -22,7 +22,7 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "libavutil/intreadwrite.h"
 
 static av_cold int zero12v_decode_init(AVCodecContext *avctx)
diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c
index 94d1cbe98a..2ee05766ab 100644
--- a/libavcodec/4xm.c
+++ b/libavcodec/4xm.c
@@ -37,8 +37,8 @@ 
 #include "bswapdsp.h"
 #include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
-#include "internal.h"
 
 
 #define BLOCK_TYPE_VLC_BITS 5
diff --git a/libavcodec/8bps.c b/libavcodec/8bps.c
index 3bac9f64c4..c7dfeb81ee 100644
--- a/libavcodec/8bps.c
+++ b/libavcodec/8bps.c
@@ -30,16 +30,13 @@ 
  *         : RGB32 (RGB 32bpp, 4th plane is alpha)
  */
 
-#include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
 
+#include "libavutil/bswap.h"
 #include "libavutil/internal.h"
-#include "libavutil/intreadwrite.h"
 #include "avcodec.h"
 #include "codec_internal.h"
 #include "decode.h"
-#include "internal.h"
 
 
 static const enum AVPixelFormat pixfmt_rgb24[] = {
diff --git a/libavcodec/8svx.c b/libavcodec/8svx.c
index 0af68d2d9a..1c6d78379d 100644
--- a/libavcodec/8svx.c
+++ b/libavcodec/8svx.c
@@ -42,7 +42,7 @@ 
 #include "libavutil/avassert.h"
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "libavutil/common.h"
 
 /** decoder context */
diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
index 149c171c83..4a9513d53e 100644
--- a/libavcodec/aacdec_template.c
+++ b/libavcodec/aacdec_template.c
@@ -91,6 +91,7 @@ 
 
 #include "libavutil/channel_layout.h"
 #include "libavutil/thread.h"
+#include "decode.h"
 #include "internal.h"
 
 static VLC vlc_scalefactors;
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index ad2b3615c8..b1db3dc9e6 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -44,6 +44,7 @@ 
 #include "ac3dec.h"
 #include "ac3dec_data.h"
 #include "ac3defs.h"
+#include "decode.h"
 #include "kbdwin.h"
 
 /**
diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index c4bcafbb7e..5db46752ab 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -43,7 +43,7 @@ 
 #include "adpcm.h"
 #include "adpcm_data.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 /**
  * @file
diff --git a/libavcodec/adxdec.c b/libavcodec/adxdec.c
index b5c09eaae5..cdded477ca 100644
--- a/libavcodec/adxdec.c
+++ b/libavcodec/adxdec.c
@@ -23,8 +23,8 @@ 
 #include "avcodec.h"
 #include "adx.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
-#include "internal.h"
 
 /**
  * @file
diff --git a/libavcodec/agm.c b/libavcodec/agm.c
index 0f65a820ca..08a5f05b91 100644
--- a/libavcodec/agm.c
+++ b/libavcodec/agm.c
@@ -32,6 +32,7 @@ 
 #include "bytestream.h"
 #include "codec_internal.h"
 #include "copy_block.h"
+#include "decode.h"
 #include "get_bits.h"
 #include "idctdsp.h"
 #include "internal.h"
diff --git a/libavcodec/aliaspixdec.c b/libavcodec/aliaspixdec.c
index 73c83528f5..522b894af5 100644
--- a/libavcodec/aliaspixdec.c
+++ b/libavcodec/aliaspixdec.c
@@ -24,6 +24,7 @@ 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 
 #define ALIAS_HEADER_SIZE 10
diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
index 38c823ffa1..4bb232c42a 100644
--- a/libavcodec/alsdec.c
+++ b/libavcodec/alsdec.c
@@ -34,6 +34,7 @@ 
 #include "bgmc.h"
 #include "bswapdsp.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 #include "mlz.h"
 #include "libavutil/samplefmt.h"
diff --git a/libavcodec/amrnbdec.c b/libavcodec/amrnbdec.c
index 8c1073916e..dcf66c1dde 100644
--- a/libavcodec/amrnbdec.c
+++ b/libavcodec/amrnbdec.c
@@ -44,7 +44,6 @@ 
 #include <math.h>
 
 #include "libavutil/channel_layout.h"
-#include "libavutil/float_dsp.h"
 #include "avcodec.h"
 #include "libavutil/common.h"
 #include "libavutil/avassert.h"
@@ -56,7 +55,7 @@ 
 #include "lsp.h"
 #include "amr.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 #include "amrnbdata.h"
 
diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c
index 6a5b79f52c..f9a67c43b7 100644
--- a/libavcodec/amrwbdec.c
+++ b/libavcodec/amrwbdec.c
@@ -26,7 +26,6 @@ 
 
 #include "libavutil/channel_layout.h"
 #include "libavutil/common.h"
-#include "libavutil/float_dsp.h"
 #include "libavutil/lfg.h"
 
 #include "avcodec.h"
@@ -37,7 +36,7 @@ 
 #include "acelp_vectors.h"
 #include "acelp_pitch_delay.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 #define AMR_USE_16BIT_TABLES
 #include "amr.h"
diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
index e7baa2e77f..805b9af3c3 100644
--- a/libavcodec/apedec.c
+++ b/libavcodec/apedec.c
@@ -31,7 +31,7 @@ 
 #include "bswapdsp.h"
 #include "bytestream.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "get_bits.h"
 #include "unary.h"
 
diff --git a/libavcodec/aptxdec.c b/libavcodec/aptxdec.c
index 27cf056751..1d7a7842f7 100644
--- a/libavcodec/aptxdec.c
+++ b/libavcodec/aptxdec.c
@@ -25,7 +25,7 @@ 
 #include "libavutil/channel_layout.h"
 #include "aptx.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 /*
  * Half-band QMF synthesis filter realized with a polyphase FIR filter.
diff --git a/libavcodec/arbc.c b/libavcodec/arbc.c
index d981d2228b..7155d65196 100644
--- a/libavcodec/arbc.c
+++ b/libavcodec/arbc.c
@@ -19,18 +19,13 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 typedef struct ARBCContext {
     GetByteContext gb;
diff --git a/libavcodec/asvdec.c b/libavcodec/asvdec.c
index 5bb4600084..2105d55e33 100644
--- a/libavcodec/asvdec.c
+++ b/libavcodec/asvdec.c
@@ -32,8 +32,8 @@ 
 #include "blockdsp.h"
 #include "codec_internal.h"
 #include "config_components.h"
+#include "decode.h"
 #include "idctdsp.h"
-#include "internal.h"
 #include "mpeg12data.h"
 
 #define CCP_VLC_BITS         5
diff --git a/libavcodec/atrac1.c b/libavcodec/atrac1.c
index a05fb6e801..3b60cee259 100644
--- a/libavcodec/atrac1.c
+++ b/libavcodec/atrac1.c
@@ -29,17 +29,15 @@ 
 /* Many thanks to Tim Craig for all the help! */
 
 #include <math.h>
-#include <stddef.h>
-#include <stdio.h>
 
 #include "libavutil/float_dsp.h"
 #include "libavutil/mem_internal.h"
 
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
 #include "fft.h"
-#include "internal.h"
 #include "sinewin.h"
 
 #include "atrac.h"
diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c
index 93f5f4d2d6..79260c8760 100644
--- a/libavcodec/atrac3.c
+++ b/libavcodec/atrac3.c
@@ -34,7 +34,6 @@ 
 
 #include <math.h>
 #include <stddef.h>
-#include <stdio.h>
 
 #include "libavutil/attributes.h"
 #include "libavutil/float_dsp.h"
@@ -45,9 +44,9 @@ 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "fft.h"
 #include "get_bits.h"
-#include "internal.h"
 
 #include "atrac.h"
 #include "atrac3data.h"
diff --git a/libavcodec/atrac3plusdec.c b/libavcodec/atrac3plusdec.c
index 644a7e87c6..771c213bad 100644
--- a/libavcodec/atrac3plusdec.c
+++ b/libavcodec/atrac3plusdec.c
@@ -43,8 +43,8 @@ 
 #include "libavutil/thread.h"
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
-#include "internal.h"
 #include "atrac.h"
 #include "atrac3plus.h"
 
diff --git a/libavcodec/atrac9dec.c b/libavcodec/atrac9dec.c
index 3c572560c1..71ff6e0151 100644
--- a/libavcodec/atrac9dec.c
+++ b/libavcodec/atrac9dec.c
@@ -23,7 +23,7 @@ 
 #include "libavutil/thread.h"
 
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "get_bits.h"
 #include "fft.h"
 #include "atrac9tab.h"
diff --git a/libavcodec/audiotoolboxdec.c b/libavcodec/audiotoolboxdec.c
index dc3f790636..220101e9eb 100644
--- a/libavcodec/audiotoolboxdec.c
+++ b/libavcodec/audiotoolboxdec.c
@@ -28,7 +28,7 @@ 
 #include "ac3_parser_internal.h"
 #include "bytestream.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "mpegaudiodecheader.h"
 #include "libavutil/avassert.h"
 #include "libavutil/channel_layout.h"
diff --git a/libavcodec/aura.c b/libavcodec/aura.c
index 23e976f219..938706629d 100644
--- a/libavcodec/aura.c
+++ b/libavcodec/aura.c
@@ -25,7 +25,7 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "libavutil/internal.h"
 
 static av_cold int aura_decode_init(AVCodecContext *avctx)
diff --git a/libavcodec/avrndec.c b/libavcodec/avrndec.c
index 10bde74172..f0257cd860 100644
--- a/libavcodec/avrndec.c
+++ b/libavcodec/avrndec.c
@@ -21,7 +21,7 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "libavutil/imgutils.h"
 
 typedef struct {
diff --git a/libavcodec/avuidec.c b/libavcodec/avuidec.c
index ce96219bf5..9e698b02ec 100644
--- a/libavcodec/avuidec.c
+++ b/libavcodec/avuidec.c
@@ -22,7 +22,7 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "libavutil/intreadwrite.h"
 
 static av_cold int avui_decode_init(AVCodecContext *avctx)
diff --git a/libavcodec/bfi.c b/libavcodec/bfi.c
index 12eba8f399..9df5bcdf5e 100644
--- a/libavcodec/bfi.c
+++ b/libavcodec/bfi.c
@@ -30,7 +30,7 @@ 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 typedef struct BFIContext {
     AVCodecContext *avctx;
diff --git a/libavcodec/bink.c b/libavcodec/bink.c
index e6d9bdc2fa..a3cd4667d6 100644
--- a/libavcodec/bink.c
+++ b/libavcodec/bink.c
@@ -35,8 +35,6 @@ 
 #include "decode.h"
 #include "get_bits.h"
 #include "hpeldsp.h"
-#include "internal.h"
-#include "mathops.h"
 
 #define BINK_FLAG_ALPHA 0x00100000
 #define BINK_FLAG_GRAY  0x00020000
diff --git a/libavcodec/bintext.c b/libavcodec/bintext.c
index 7039760c19..c3cf14f6dd 100644
--- a/libavcodec/bintext.c
+++ b/libavcodec/bintext.c
@@ -36,7 +36,7 @@ 
 #include "cga_data.h"
 #include "bintext.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 #define FONT_WIDTH 8
 
diff --git a/libavcodec/bmp.c b/libavcodec/bmp.c
index 410065aba1..7bbaabcda4 100644
--- a/libavcodec/bmp.c
+++ b/libavcodec/bmp.c
@@ -25,6 +25,7 @@ 
 #include "bytestream.h"
 #include "bmp.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 #include "msrledec.h"
 
diff --git a/libavcodec/bmvaudio.c b/libavcodec/bmvaudio.c
index 08f24c3c8b..d772f72d71 100644
--- a/libavcodec/bmvaudio.c
+++ b/libavcodec/bmvaudio.c
@@ -24,7 +24,7 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 static const int bmv_aud_mults[16] = {
     16512, 8256, 4128, 2064, 1032, 516, 258, 192, 129, 88, 64, 56, 48, 40, 36, 32
diff --git a/libavcodec/bmvvideo.c b/libavcodec/bmvvideo.c
index 9872396990..6a55d49494 100644
--- a/libavcodec/bmvvideo.c
+++ b/libavcodec/bmvvideo.c
@@ -25,7 +25,7 @@ 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 enum BMVFlags{
     BMV_NOP = 0,
diff --git a/libavcodec/brenderpix.c b/libavcodec/brenderpix.c
index 9807a11cf9..2d8e978c1e 100644
--- a/libavcodec/brenderpix.c
+++ b/libavcodec/brenderpix.c
@@ -26,6 +26,7 @@ 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 
 #define HEADER1_CHUNK    0x03
diff --git a/libavcodec/cavsdec.c b/libavcodec/cavsdec.c
index 7ac4359123..417c73bd2e 100644
--- a/libavcodec/cavsdec.c
+++ b/libavcodec/cavsdec.c
@@ -31,6 +31,7 @@ 
 #include "golomb.h"
 #include "cavs.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 #include "mathops.h"
 #include "mpeg12data.h"
diff --git a/libavcodec/cdxl.c b/libavcodec/cdxl.c
index b005442fdc..64fcdffba4 100644
--- a/libavcodec/cdxl.c
+++ b/libavcodec/cdxl.c
@@ -32,6 +32,7 @@ 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
 #include "internal.h"
 
diff --git a/libavcodec/cljrdec.c b/libavcodec/cljrdec.c
index 21fa8ee019..0550e1dc05 100644
--- a/libavcodec/cljrdec.c
+++ b/libavcodec/cljrdec.c
@@ -26,8 +26,8 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
-#include "internal.h"
 
 static int decode_frame(AVCodecContext *avctx, AVFrame *p,
                         int *got_frame, AVPacket *avpkt)
diff --git a/libavcodec/cngdec.c b/libavcodec/cngdec.c
index c89dfee033..e698d142dd 100644
--- a/libavcodec/cngdec.c
+++ b/libavcodec/cngdec.c
@@ -27,6 +27,7 @@ 
 #include "avcodec.h"
 #include "celp_filters.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 #include "libavutil/lfg.h"
 
diff --git a/libavcodec/cook.c b/libavcodec/cook.c
index 01005d3a50..5ccabb03ed 100644
--- a/libavcodec/cook.c
+++ b/libavcodec/cook.c
@@ -52,8 +52,8 @@ 
 #include "get_bits.h"
 #include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "fft.h"
-#include "internal.h"
 #include "sinewin.h"
 #include "unary.h"
 
diff --git a/libavcodec/cyuv.c b/libavcodec/cyuv.c
index 48846b56c2..8a7cef6b74 100644
--- a/libavcodec/cyuv.c
+++ b/libavcodec/cyuv.c
@@ -30,13 +30,11 @@ 
 
 #include "config_components.h"
 
-#include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
 
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "libavutil/internal.h"
 
 
diff --git a/libavcodec/dca_core.c b/libavcodec/dca_core.c
index 2b19807ef4..b181171104 100644
--- a/libavcodec/dca_core.c
+++ b/libavcodec/dca_core.c
@@ -25,6 +25,7 @@ 
 #include "dcahuff.h"
 #include "dcamath.h"
 #include "dca_syncwords.h"
+#include "decode.h"
 #include "internal.h"
 
 #if ARCH_ARM
diff --git a/libavcodec/dca_lbr.c b/libavcodec/dca_lbr.c
index 2b8594cd75..ec55404c7b 100644
--- a/libavcodec/dca_lbr.c
+++ b/libavcodec/dca_lbr.c
@@ -28,6 +28,7 @@ 
 #include "dcahuff.h"
 #include "dca_syncwords.h"
 #include "bytestream.h"
+#include "decode.h"
 #include "internal.h"
 
 #define AMP_MAX     56
diff --git a/libavcodec/dca_xll.c b/libavcodec/dca_xll.c
index 17626b3614..242c3a13fe 100644
--- a/libavcodec/dca_xll.c
+++ b/libavcodec/dca_xll.c
@@ -23,6 +23,7 @@ 
 #include "dcadata.h"
 #include "dcamath.h"
 #include "dca_syncwords.h"
+#include "decode.h"
 #include "internal.h"
 #include "unary.h"
 
diff --git a/libavcodec/dds.c b/libavcodec/dds.c
index 1e3901111c..63f63efca2 100644
--- a/libavcodec/dds.c
+++ b/libavcodec/dds.c
@@ -34,6 +34,7 @@ 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 #include "texturedsp.h"
 #include "thread.h"
diff --git a/libavcodec/decode.h b/libavcodec/decode.h
index d9014d3e0f..25db4a9e4d 100644
--- a/libavcodec/decode.h
+++ b/libavcodec/decode.h
@@ -112,6 +112,13 @@  int ff_decode_preinit(AVCodecContext *avctx);
  */
 int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt);
 
+/**
+ * Get a buffer for a frame. This is a wrapper around
+ * AVCodecContext.get_buffer() and should be used instead calling get_buffer()
+ * directly.
+ */
+int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags);
+
 #define FF_REGET_BUFFER_FLAG_READONLY 1 ///< the returned buffer does not need to be writable
 /**
  * Identical in function to ff_get_buffer(), except it reuses the existing buffer
diff --git a/libavcodec/dfa.c b/libavcodec/dfa.c
index 0996bf5a7e..dadb64d87e 100644
--- a/libavcodec/dfa.c
+++ b/libavcodec/dfa.c
@@ -25,7 +25,7 @@ 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 #include "libavutil/avassert.h"
 #include "libavutil/imgutils.h"
diff --git a/libavcodec/dfpwmdec.c b/libavcodec/dfpwmdec.c
index c036f8e141..975afba4cc 100644
--- a/libavcodec/dfpwmdec.c
+++ b/libavcodec/dfpwmdec.c
@@ -29,7 +29,7 @@ 
 #include "avcodec.h"
 #include "codec_id.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 typedef struct {
     int fq, q, s, lt;
diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c
index aef6ab20a3..59c5e81904 100644
--- a/libavcodec/diracdec.c
+++ b/libavcodec/diracdec.c
@@ -33,6 +33,7 @@ 
 #include "get_bits.h"
 #include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 #include "golomb.h"
 #include "dirac_arith.h"
diff --git a/libavcodec/dolby_e.c b/libavcodec/dolby_e.c
index e6a262403d..de852ecc0a 100644
--- a/libavcodec/dolby_e.c
+++ b/libavcodec/dolby_e.c
@@ -26,7 +26,7 @@ 
 #include "libavutil/opt.h"
 
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "get_bits.h"
 #include "dolby_e.h"
 #include "kbdwin.h"
diff --git a/libavcodec/dpcm.c b/libavcodec/dpcm.c
index e360045ec3..34f3799b80 100644
--- a/libavcodec/dpcm.c
+++ b/libavcodec/dpcm.c
@@ -37,11 +37,10 @@ 
  * the fourcc 'Axan' in the 'auds' chunk of the AVI header.
  */
 
-#include "libavutil/intreadwrite.h"
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "mathops.h"
 
 typedef struct DPCMContext {
diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c
index bb2c5e588e..c3f0d3f95a 100644
--- a/libavcodec/dpx.c
+++ b/libavcodec/dpx.c
@@ -27,6 +27,7 @@ 
 #include "bytestream.h"
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 
 enum DPX_TRC {
diff --git a/libavcodec/dsddec.c b/libavcodec/dsddec.c
index d724e427bf..0fdc2af565 100644
--- a/libavcodec/dsddec.c
+++ b/libavcodec/dsddec.c
@@ -29,6 +29,7 @@ 
 #include "libavcodec/internal.h"
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "dsd.h"
 
 #define DSD_SILENCE 0x69
diff --git a/libavcodec/dsicinaudio.c b/libavcodec/dsicinaudio.c
index 8be4350625..ea37e68ea2 100644
--- a/libavcodec/dsicinaudio.c
+++ b/libavcodec/dsicinaudio.c
@@ -25,11 +25,11 @@ 
  */
 
 #include "libavutil/channel_layout.h"
+#include "libavutil/intreadwrite.h"
 
 #include "avcodec.h"
-#include "bytestream.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "mathops.h"
 
 typedef struct CinAudioContext {
diff --git a/libavcodec/dss_sp.c b/libavcodec/dss_sp.c
index d2f71a4450..74419514d4 100644
--- a/libavcodec/dss_sp.c
+++ b/libavcodec/dss_sp.c
@@ -22,12 +22,11 @@ 
 #include "libavutil/channel_layout.h"
 #include "libavutil/common.h"
 #include "libavutil/mem_internal.h"
-#include "libavutil/opt.h"
 
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
-#include "internal.h"
 
 #define SUBFRAMES 4
 #define PULSE_MAX 8
diff --git a/libavcodec/dstdec.c b/libavcodec/dstdec.c
index 9ad763ab6b..59f8e900d8 100644
--- a/libavcodec/dstdec.c
+++ b/libavcodec/dstdec.c
@@ -29,11 +29,10 @@ 
 #include "libavutil/mem_internal.h"
 #include "libavutil/reverse.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "get_bits.h"
 #include "avcodec.h"
 #include "golomb.h"
-#include "mathops.h"
 #include "dsd.h"
 
 #define DST_MAX_CHANNELS 6
diff --git a/libavcodec/dvaudiodec.c b/libavcodec/dvaudiodec.c
index d65fc469ff..96bcadeb57 100644
--- a/libavcodec/dvaudiodec.c
+++ b/libavcodec/dvaudiodec.c
@@ -22,7 +22,7 @@ 
 #include "libavutil/intreadwrite.h"
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "dvaudio.h"
 
 typedef struct DVAudioContext {
diff --git a/libavcodec/dxa.c b/libavcodec/dxa.c
index fa633cd208..a557501104 100644
--- a/libavcodec/dxa.c
+++ b/libavcodec/dxa.c
@@ -24,15 +24,12 @@ 
  * DXA Video decoder
  */
 
-#include <stdio.h>
-#include <stdlib.h>
-
 #include "libavutil/common.h"
 #include "libavutil/intreadwrite.h"
 #include "bytestream.h"
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 #include <zlib.h>
 
diff --git a/libavcodec/eacmv.c b/libavcodec/eacmv.c
index b05d0f32a9..733cc2a1c0 100644
--- a/libavcodec/eacmv.c
+++ b/libavcodec/eacmv.c
@@ -33,6 +33,7 @@ 
 #include "libavutil/imgutils.h"
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 
 typedef struct CmvContext {
diff --git a/libavcodec/eamad.c b/libavcodec/eamad.c
index ce74bf0c62..70cea0ed6c 100644
--- a/libavcodec/eamad.c
+++ b/libavcodec/eamad.c
@@ -35,6 +35,7 @@ 
 #include "bytestream.h"
 #include "bswapdsp.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
 #include "aandcttab.h"
 #include "eaidct.h"
diff --git a/libavcodec/eatgq.c b/libavcodec/eatgq.c
index a28cc521c3..5d57fb34f8 100644
--- a/libavcodec/eatgq.c
+++ b/libavcodec/eatgq.c
@@ -36,6 +36,7 @@ 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "eaidct.h"
 #include "get_bits.h"
 #include "idctdsp.h"
diff --git a/libavcodec/eatgv.c b/libavcodec/eatgv.c
index a6af789552..b1483cc586 100644
--- a/libavcodec/eatgv.c
+++ b/libavcodec/eatgv.c
@@ -35,6 +35,7 @@ 
 #include "avcodec.h"
 #include "get_bits.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 
 #define EA_PREAMBLE_SIZE    8
diff --git a/libavcodec/eatqi.c b/libavcodec/eatqi.c
index a19202ac1c..013e5415d2 100644
--- a/libavcodec/eatqi.c
+++ b/libavcodec/eatqi.c
@@ -32,6 +32,7 @@ 
 #include "blockdsp.h"
 #include "bswapdsp.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
 #include "aandcttab.h"
 #include "eaidct.h"
diff --git a/libavcodec/escape124.c b/libavcodec/escape124.c
index 170d76f052..6906992305 100644
--- a/libavcodec/escape124.c
+++ b/libavcodec/escape124.c
@@ -22,8 +22,8 @@ 
 #define BITSTREAM_READER_LE
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
-#include "internal.h"
 
 typedef union MacroBlock {
     uint16_t pixels[4];
diff --git a/libavcodec/escape130.c b/libavcodec/escape130.c
index b292343b20..5bf1a5d745 100644
--- a/libavcodec/escape130.c
+++ b/libavcodec/escape130.c
@@ -25,8 +25,8 @@ 
 #define BITSTREAM_READER_LE
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
-#include "internal.h"
 
 typedef struct Escape130Context {
     uint8_t *old_y_avg;
diff --git a/libavcodec/evrcdec.c b/libavcodec/evrcdec.c
index 19e7e58b5f..2ac98b8e76 100644
--- a/libavcodec/evrcdec.c
+++ b/libavcodec/evrcdec.c
@@ -30,7 +30,7 @@ 
 #include "libavutil/opt.h"
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "get_bits.h"
 #include "evrcdata.h"
 #include "acelp_vectors.h"
diff --git a/libavcodec/fastaudio.c b/libavcodec/fastaudio.c
index 6093a06900..262e2bea7c 100644
--- a/libavcodec/fastaudio.c
+++ b/libavcodec/fastaudio.c
@@ -21,13 +21,10 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavutil/intreadwrite.h"
-
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
-#include "internal.h"
-#include "mathops.h"
+#include "decode.h"
 
 typedef struct ChannelItems {
     float f[8];
diff --git a/libavcodec/ffwavesynth.c b/libavcodec/ffwavesynth.c
index 04be7761b2..728650b057 100644
--- a/libavcodec/ffwavesynth.c
+++ b/libavcodec/ffwavesynth.c
@@ -23,7 +23,7 @@ 
 #include "libavutil/log.h"
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 
 #define SIN_BITS 14
diff --git a/libavcodec/fitsdec.c b/libavcodec/fitsdec.c
index b60c2bd441..28954f370c 100644
--- a/libavcodec/fitsdec.c
+++ b/libavcodec/fitsdec.c
@@ -32,6 +32,7 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 #include <float.h>
 #include "libavutil/intreadwrite.h"
diff --git a/libavcodec/fmvc.c b/libavcodec/fmvc.c
index fe86204b2f..b3a4e7184c 100644
--- a/libavcodec/fmvc.c
+++ b/libavcodec/fmvc.c
@@ -21,13 +21,12 @@ 
  */
 
 #include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 #define BLOCK_HEIGHT 112u
 #define BLOCK_WIDTH  84u
diff --git a/libavcodec/frwu.c b/libavcodec/frwu.c
index e6ee0506ac..225667b4c4 100644
--- a/libavcodec/frwu.c
+++ b/libavcodec/frwu.c
@@ -23,7 +23,7 @@ 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "libavutil/opt.h"
 
 typedef struct {
diff --git a/libavcodec/g2meet.c b/libavcodec/g2meet.c
index 66ccd9a28c..f2300e1ca6 100644
--- a/libavcodec/g2meet.c
+++ b/libavcodec/g2meet.c
@@ -36,6 +36,7 @@ 
 #include "blockdsp.h"
 #include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "elsdec.h"
 #include "get_bits.h"
 #include "idctdsp.h"
diff --git a/libavcodec/g722dec.c b/libavcodec/g722dec.c
index de2f666a1f..23598cb71f 100644
--- a/libavcodec/g722dec.c
+++ b/libavcodec/g722dec.c
@@ -38,9 +38,9 @@ 
 #include "libavutil/opt.h"
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
 #include "g722.h"
-#include "internal.h"
 
 #define OFFSET(x) offsetof(G722Context, x)
 #define AD AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM
diff --git a/libavcodec/g723_1dec.c b/libavcodec/g723_1dec.c
index 257a4e6c30..3904840eba 100644
--- a/libavcodec/g723_1dec.c
+++ b/libavcodec/g723_1dec.c
@@ -33,10 +33,9 @@ 
 #include "acelp_vectors.h"
 #include "avcodec.h"
 #include "celp_filters.h"
-#include "celp_math.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
-#include "internal.h"
 #include "g723_1.h"
 
 #define CNG_RANDOM_SEED 12345
diff --git a/libavcodec/g726.c b/libavcodec/g726.c
index 6c9406d3fd..320bc55d15 100644
--- a/libavcodec/g726.c
+++ b/libavcodec/g726.c
@@ -30,8 +30,8 @@ 
 #include "libavutil/opt.h"
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "encode.h"
-#include "internal.h"
 #include "get_bits.h"
 #include "put_bits.h"
 
diff --git a/libavcodec/g729dec.c b/libavcodec/g729dec.c
index b678510f34..bcaee44d9d 100644
--- a/libavcodec/g729dec.c
+++ b/libavcodec/g729dec.c
@@ -27,12 +27,11 @@ 
 #include "get_bits.h"
 #include "audiodsp.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 
 #include "g729.h"
 #include "lsp.h"
-#include "celp_math.h"
 #include "celp_filters.h"
 #include "acelp_filters.h"
 #include "acelp_pitch_delay.h"
diff --git a/libavcodec/gdv.c b/libavcodec/gdv.c
index 148204d4f8..19b4d4bdbb 100644
--- a/libavcodec/gdv.c
+++ b/libavcodec/gdv.c
@@ -25,7 +25,6 @@ 
 #include "bytestream.h"
 #include "codec_internal.h"
 #include "decode.h"
-#include "internal.h"
 
 typedef struct GDVContext {
     AVCodecContext *avctx;
diff --git a/libavcodec/gemdec.c b/libavcodec/gemdec.c
index 0d6acd5303..39bfedb560 100644
--- a/libavcodec/gemdec.c
+++ b/libavcodec/gemdec.c
@@ -27,6 +27,7 @@ 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 
 static const uint32_t gem_color_palette[16]={
diff --git a/libavcodec/gsmdec.c b/libavcodec/gsmdec.c
index dd8d80e07b..c44c9d992f 100644
--- a/libavcodec/gsmdec.c
+++ b/libavcodec/gsmdec.c
@@ -29,8 +29,8 @@ 
 #include "libavutil/channel_layout.h"
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
-#include "internal.h"
 #include "msgsmdec.h"
 
 #include "gsmdec_template.c"
diff --git a/libavcodec/hcadec.c b/libavcodec/hcadec.c
index 4c81aa405b..82276589fc 100644
--- a/libavcodec/hcadec.c
+++ b/libavcodec/hcadec.c
@@ -18,15 +18,14 @@ 
 
 #include "libavutil/crc.h"
 #include "libavutil/float_dsp.h"
-#include "libavutil/intreadwrite.h"
 #include "libavutil/mem_internal.h"
 #include "libavutil/tx.h"
 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
-#include "internal.h"
 #include "hca_data.h"
 
 typedef struct ChannelContext {
diff --git a/libavcodec/hcom.c b/libavcodec/hcom.c
index 9fd47b4273..301b1e02d6 100644
--- a/libavcodec/hcom.c
+++ b/libavcodec/hcom.c
@@ -22,8 +22,8 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
-#include "internal.h"
 
 typedef struct HEntry {
     int16_t l, r;
diff --git a/libavcodec/hnm4video.c b/libavcodec/hnm4video.c
index db4c877ea4..f68badf195 100644
--- a/libavcodec/hnm4video.c
+++ b/libavcodec/hnm4video.c
@@ -29,7 +29,7 @@ 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 #define HNM4_CHUNK_ID_PL 19536
 #define HNM4_CHUNK_ID_IZ 23113
diff --git a/libavcodec/hq_hqa.c b/libavcodec/hq_hqa.c
index a17fa18bf8..e0fbf7de65 100644
--- a/libavcodec/hq_hqa.c
+++ b/libavcodec/hq_hqa.c
@@ -27,6 +27,7 @@ 
 #include "bytestream.h"
 #include "canopus.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
 #include "internal.h"
 
diff --git a/libavcodec/idcinvideo.c b/libavcodec/idcinvideo.c
index 1535e6aced..4d3bcd3e86 100644
--- a/libavcodec/idcinvideo.c
+++ b/libavcodec/idcinvideo.c
@@ -44,14 +44,12 @@ 
  * decoding algorithm and it worked fine on much lower spec machines.
  */
 
-#include <stdio.h>
-#include <stdlib.h>
+#include <stddef.h>
 #include <string.h>
 
 #include "avcodec.h"
 #include "codec_internal.h"
 #include "decode.h"
-#include "internal.h"
 #include "libavutil/internal.h"
 
 #define HUFFMAN_TABLE_SIZE 64 * 1024
diff --git a/libavcodec/iff.c b/libavcodec/iff.c
index cd78352350..e31dc4cbd0 100644
--- a/libavcodec/iff.c
+++ b/libavcodec/iff.c
@@ -33,8 +33,7 @@ 
 #include "bytestream.h"
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
-#include "mathops.h"
+#include "decode.h"
 
 // TODO: masking bits
 typedef enum {
diff --git a/libavcodec/ilbcdec.c b/libavcodec/ilbcdec.c
index 2bc559a3e8..1ee59ef5c9 100644
--- a/libavcodec/ilbcdec.c
+++ b/libavcodec/ilbcdec.c
@@ -33,7 +33,7 @@ 
 #include "libavutil/channel_layout.h"
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "get_bits.h"
 #include "ilbcdata.h"
 
diff --git a/libavcodec/imc.c b/libavcodec/imc.c
index e9c51a1760..e751c1da8d 100644
--- a/libavcodec/imc.c
+++ b/libavcodec/imc.c
@@ -33,7 +33,6 @@ 
 
 #include <math.h>
 #include <stddef.h>
-#include <stdio.h>
 
 #include "libavutil/channel_layout.h"
 #include "libavutil/ffmath.h"
@@ -45,9 +44,9 @@ 
 #include "avcodec.h"
 #include "bswapdsp.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
 #include "fft.h"
-#include "internal.h"
 #include "sinewin.h"
 
 #include "imcdata.h"
diff --git a/libavcodec/imm4.c b/libavcodec/imm4.c
index fe4e15f381..b2840a2c3f 100644
--- a/libavcodec/imm4.c
+++ b/libavcodec/imm4.c
@@ -30,6 +30,7 @@ 
 #include "avcodec.h"
 #include "bswapdsp.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "copy_block.h"
 #include "get_bits.h"
 #include "idctdsp.h"
diff --git a/libavcodec/indeo3.c b/libavcodec/indeo3.c
index e634cf3dfd..95708f3636 100644
--- a/libavcodec/indeo3.c
+++ b/libavcodec/indeo3.c
@@ -34,6 +34,7 @@ 
 #include "libavutil/thread.h"
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "copy_block.h"
 #include "bytestream.h"
 #include "get_bits.h"
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index fde0cc0ad6..0c581a4cf3 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -213,13 +213,6 @@  static av_always_inline float ff_exp2fi(int x) {
         return 0;
 }
 
-/**
- * Get a buffer for a frame. This is a wrapper around
- * AVCodecContext.get_buffer() and should be used instead calling get_buffer()
- * directly.
- */
-int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags);
-
 int avpriv_h264_has_num_reorder_frames(AVCodecContext *avctx);
 
 int avpriv_codec_get_cap_skip_frame_fill_param(const AVCodec *codec);
diff --git a/libavcodec/interplayacm.c b/libavcodec/interplayacm.c
index 3b14919288..069b1ca704 100644
--- a/libavcodec/interplayacm.c
+++ b/libavcodec/interplayacm.c
@@ -24,8 +24,8 @@ 
 #define BITSTREAM_READER_LE
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
-#include "internal.h"
 
 static const int8_t map_1bit[]      = { -1, +1 };
 static const int8_t map_2bit_near[] = { -2, -1, +1, +2 };
diff --git a/libavcodec/interplayvideo.c b/libavcodec/interplayvideo.c
index 75feb8335a..21ceb75210 100644
--- a/libavcodec/interplayvideo.c
+++ b/libavcodec/interplayvideo.c
@@ -35,7 +35,6 @@ 
  */
 
 #include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
 
 #include "libavutil/intreadwrite.h"
@@ -47,7 +46,6 @@ 
 #include "decode.h"
 #include "get_bits.h"
 #include "hpeldsp.h"
-#include "internal.h"
 
 #define PALETTE_COUNT 256
 
diff --git a/libavcodec/ivi.c b/libavcodec/ivi.c
index 6577fa335f..cddef6f51e 100644
--- a/libavcodec/ivi.c
+++ b/libavcodec/ivi.c
@@ -34,6 +34,7 @@ 
 
 #define BITSTREAM_READER_LE
 #include "avcodec.h"
+#include "decode.h"
 #include "get_bits.h"
 #include "internal.h"
 #include "ivi.h"
diff --git a/libavcodec/jvdec.c b/libavcodec/jvdec.c
index 420a00a790..9bca18e32c 100644
--- a/libavcodec/jvdec.c
+++ b/libavcodec/jvdec.c
@@ -32,7 +32,6 @@ 
 #include "codec_internal.h"
 #include "decode.h"
 #include "get_bits.h"
-#include "internal.h"
 
 typedef struct JvContext {
     BlockDSPContext bdsp;
diff --git a/libavcodec/kgv1dec.c b/libavcodec/kgv1dec.c
index 47c2a31b69..0dfb796483 100644
--- a/libavcodec/kgv1dec.c
+++ b/libavcodec/kgv1dec.c
@@ -29,6 +29,7 @@ 
 #include "libavutil/imgutils.h"
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 
 typedef struct KgvContext {
diff --git a/libavcodec/kmvc.c b/libavcodec/kmvc.c
index d5da5412a0..1e37c233f4 100644
--- a/libavcodec/kmvc.c
+++ b/libavcodec/kmvc.c
@@ -25,13 +25,11 @@ 
  */
 
 #include <stdio.h>
-#include <stdlib.h>
 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
 #include "decode.h"
-#include "internal.h"
 #include "libavutil/common.h"
 
 #define KMVC_KEYFRAME 0x80
diff --git a/libavcodec/libaomdec.c b/libavcodec/libaomdec.c
index cb672b0e65..274c67baaa 100644
--- a/libavcodec/libaomdec.c
+++ b/libavcodec/libaomdec.c
@@ -32,6 +32,7 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 #include "libaom.h"
 #include "profiles.h"
diff --git a/libavcodec/libcelt_dec.c b/libavcodec/libcelt_dec.c
index a9c9962b71..0c41a660bc 100644
--- a/libavcodec/libcelt_dec.c
+++ b/libavcodec/libcelt_dec.c
@@ -23,7 +23,7 @@ 
 #include <celt/celt_header.h>
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "libavutil/intreadwrite.h"
 
 struct libcelt_context {
diff --git a/libavcodec/libcodec2.c b/libavcodec/libcodec2.c
index 0f2e671ab1..11e9d14d3a 100644
--- a/libavcodec/libcodec2.c
+++ b/libavcodec/libcodec2.c
@@ -24,8 +24,8 @@ 
 #include "avcodec.h"
 #include "libavutil/opt.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "encode.h"
-#include "internal.h"
 #include "codec2utils.h"
 
 typedef struct {
diff --git a/libavcodec/libfdk-aacdec.c b/libavcodec/libfdk-aacdec.c
index 87e412f75c..c148d46208 100644
--- a/libavcodec/libfdk-aacdec.c
+++ b/libavcodec/libfdk-aacdec.c
@@ -24,7 +24,7 @@ 
 #include "libavutil/opt.h"
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 #ifdef AACDECODER_LIB_VL0
 #define FDKDEC_VER_AT_LEAST(vl0, vl1) \
diff --git a/libavcodec/libgsmdec.c b/libavcodec/libgsmdec.c
index 6e37122261..ad0b3c2f2a 100644
--- a/libavcodec/libgsmdec.c
+++ b/libavcodec/libgsmdec.c
@@ -40,7 +40,7 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "gsm.h"
 
 typedef struct LibGSMDecodeContext {
diff --git a/libavcodec/libilbc.c b/libavcodec/libilbc.c
index 250c5fde5b..485762f66c 100644
--- a/libavcodec/libilbc.c
+++ b/libavcodec/libilbc.c
@@ -26,8 +26,8 @@ 
 #include "libavutil/opt.h"
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "encode.h"
-#include "internal.h"
 
 #ifndef LIBILBC_VERSION_MAJOR
 #define LIBILBC_VERSION_MAJOR 2
diff --git a/libavcodec/libjxldec.c b/libavcodec/libjxldec.c
index f54701596b..f0c5533a8b 100644
--- a/libavcodec/libjxldec.c
+++ b/libavcodec/libjxldec.c
@@ -36,6 +36,7 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 
 #include <jxl/decode.h>
diff --git a/libavcodec/libopencore-amr.c b/libavcodec/libopencore-amr.c
index 46c8516010..0d398ff02b 100644
--- a/libavcodec/libopencore-amr.c
+++ b/libavcodec/libopencore-amr.c
@@ -30,8 +30,8 @@ 
 #include "avcodec.h"
 #include "audio_frame_queue.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "encode.h"
-#include "internal.h"
 
 #if CONFIG_LIBOPENCORE_AMRNB_DECODER || CONFIG_LIBOPENCORE_AMRWB_DECODER
 static int amr_decode_fix_avctx(AVCodecContext *avctx)
diff --git a/libavcodec/libopenh264dec.c b/libavcodec/libopenh264dec.c
index 04157d8e34..df270c77df 100644
--- a/libavcodec/libopenh264dec.c
+++ b/libavcodec/libopenh264dec.c
@@ -31,6 +31,7 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 #include "libopenh264.h"
 
diff --git a/libavcodec/libopusdec.c b/libavcodec/libopusdec.c
index 7b7d9c8a84..fa7aba9d8a 100644
--- a/libavcodec/libopusdec.c
+++ b/libavcodec/libopusdec.c
@@ -29,6 +29,7 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 #include "vorbis.h"
 #include "mathops.h"
diff --git a/libavcodec/librsvgdec.c b/libavcodec/librsvgdec.c
index 6e949fe3d5..bfb83da614 100644
--- a/libavcodec/librsvgdec.c
+++ b/libavcodec/librsvgdec.c
@@ -21,6 +21,7 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 #include "libavutil/opt.h"
 #include "librsvg-2.0/librsvg/rsvg.h"
diff --git a/libavcodec/libspeexdec.c b/libavcodec/libspeexdec.c
index af0f224b34..b1512549d6 100644
--- a/libavcodec/libspeexdec.c
+++ b/libavcodec/libspeexdec.c
@@ -27,7 +27,7 @@ 
 #include "libavutil/common.h"
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 typedef struct LibSpeexContext {
     SpeexBits bits;
diff --git a/libavcodec/libuavs3d.c b/libavcodec/libuavs3d.c
index 5ccd9893a5..f2649540be 100644
--- a/libavcodec/libuavs3d.c
+++ b/libavcodec/libuavs3d.c
@@ -30,6 +30,7 @@ 
 #include "avcodec.h"
 #include "avs3.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 #include "uavs3d.h"
 
diff --git a/libavcodec/libvorbisdec.c b/libavcodec/libvorbisdec.c
index 38a8314760..f0f16f27cf 100644
--- a/libavcodec/libvorbisdec.c
+++ b/libavcodec/libvorbisdec.c
@@ -23,7 +23,7 @@ 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 typedef struct OggVorbisDecContext {
     vorbis_info vi;                     /**< vorbis_info used during init   */
diff --git a/libavcodec/loco.c b/libavcodec/loco.c
index 4a37cd6fd8..a31bbf38c1 100644
--- a/libavcodec/loco.c
+++ b/libavcodec/loco.c
@@ -26,9 +26,9 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
 #include "golomb.h"
-#include "internal.h"
 #include "mathops.h"
 
 enum LOCO_MODE {
diff --git a/libavcodec/m101.c b/libavcodec/m101.c
index 16ea6ede32..7c719006ec 100644
--- a/libavcodec/m101.c
+++ b/libavcodec/m101.c
@@ -22,7 +22,7 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 
 static av_cold int m101_decode_init(AVCodecContext *avctx)
diff --git a/libavcodec/mace.c b/libavcodec/mace.c
index 675725a60e..bf45b36a20 100644
--- a/libavcodec/mace.c
+++ b/libavcodec/mace.c
@@ -26,7 +26,7 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "libavutil/common.h"
 
 /*
diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index 8bf7c1586d..dba2b9ac34 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -36,6 +36,7 @@ 
 #include "libavutil/thread.h"
 #include "libavutil/opt.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
 #include "internal.h"
 #include "libavutil/crc.h"
diff --git a/libavcodec/mpc7.c b/libavcodec/mpc7.c
index 5dabc1b5ff..0f203033ef 100644
--- a/libavcodec/mpc7.c
+++ b/libavcodec/mpc7.c
@@ -33,8 +33,8 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
-#include "internal.h"
 #include "mpegaudiodsp.h"
 
 #include "mpc.h"
diff --git a/libavcodec/mpc8.c b/libavcodec/mpc8.c
index f9277e6e62..4ffdb32483 100644
--- a/libavcodec/mpc8.c
+++ b/libavcodec/mpc8.c
@@ -30,8 +30,8 @@ 
 #include "libavutil/thread.h"
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
-#include "internal.h"
 #include "mpegaudiodsp.h"
 
 #include "mpc.h"
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 0e0bb3d762..34e9ed3505 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -40,6 +40,7 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "error_resilience.h"
 #include "hwconfig.h"
 #include "idctdsp.h"
diff --git a/libavcodec/mpegaudiodec_template.c b/libavcodec/mpegaudiodec_template.c
index a711154a3c..3e4ee79be6 100644
--- a/libavcodec/mpegaudiodec_template.c
+++ b/libavcodec/mpegaudiodec_template.c
@@ -36,8 +36,8 @@ 
 #include "libavutil/thread.h"
 
 #include "avcodec.h"
+#include "decode.h"
 #include "get_bits.h"
-#include "internal.h"
 #include "mathops.h"
 #include "mpegaudiodsp.h"
 
diff --git a/libavcodec/mscc.c b/libavcodec/mscc.c
index f7d33e131c..574a3b1526 100644
--- a/libavcodec/mscc.c
+++ b/libavcodec/mscc.c
@@ -21,13 +21,12 @@ 
  */
 
 #include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "zlib_wrapper.h"
 
 #include <zlib.h>
diff --git a/libavcodec/msp2dec.c b/libavcodec/msp2dec.c
index 5374c4be81..f51075e961 100644
--- a/libavcodec/msp2dec.c
+++ b/libavcodec/msp2dec.c
@@ -27,7 +27,7 @@ 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 static int msp2_decode_frame(AVCodecContext *avctx, AVFrame *p,
                              int *got_frame, AVPacket *avpkt)
diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c
index f7dade4a29..7dfb626014 100644
--- a/libavcodec/mss2.c
+++ b/libavcodec/mss2.c
@@ -27,7 +27,6 @@ 
 #include "codec_internal.h"
 #include "decode.h"
 #include "error_resilience.h"
-#include "internal.h"
 #include "mpeg_er.h"
 #include "mpegvideodec.h"
 #include "msmpeg4dec.h"
diff --git a/libavcodec/mv30.c b/libavcodec/mv30.c
index 88c360fbd3..4633fb86bc 100644
--- a/libavcodec/mv30.c
+++ b/libavcodec/mv30.c
@@ -20,8 +20,7 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include <stdio.h>
-#include <stdlib.h>
+#include <stddef.h>
 #include <string.h>
 
 #include "libavutil/thread.h"
@@ -30,10 +29,10 @@ 
 #include "bytestream.h"
 #include "codec_internal.h"
 #include "copy_block.h"
+#include "decode.h"
 #include "mathops.h"
 #include "blockdsp.h"
 #include "get_bits.h"
-#include "internal.h"
 #include "aandcttab.h"
 
 #define CBP_VLC_BITS  9
diff --git a/libavcodec/mvcdec.c b/libavcodec/mvcdec.c
index 3fa665a5df..d2e9f4b631 100644
--- a/libavcodec/mvcdec.c
+++ b/libavcodec/mvcdec.c
@@ -31,6 +31,7 @@ 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 
 typedef struct MvcContext {
diff --git a/libavcodec/mvha.c b/libavcodec/mvha.c
index 097a52eff7..c58fd239a7 100644
--- a/libavcodec/mvha.c
+++ b/libavcodec/mvha.c
@@ -20,18 +20,13 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
 #define CACHED_BITSTREAM_READER !ARCH_X86_32
 #include "libavutil/intreadwrite.h"
 
 #include "avcodec.h"
-#include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
-#include "internal.h"
 #include "lossless_videodsp.h"
 #include "zlib_wrapper.h"
 
diff --git a/libavcodec/mwsc.c b/libavcodec/mwsc.c
index d804433cbb..8d971fa331 100644
--- a/libavcodec/mwsc.c
+++ b/libavcodec/mwsc.c
@@ -21,13 +21,11 @@ 
  */
 
 #include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "zlib_wrapper.h"
 
 #include <zlib.h>
diff --git a/libavcodec/mxpegdec.c b/libavcodec/mxpegdec.c
index a9f2a2bc2b..b3862c7791 100644
--- a/libavcodec/mxpegdec.c
+++ b/libavcodec/mxpegdec.c
@@ -26,7 +26,7 @@ 
  */
 
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "mjpeg.h"
 #include "mjpegdec.h"
 
diff --git a/libavcodec/nellymoserdec.c b/libavcodec/nellymoserdec.c
index 5c8b23ecb3..3f1d1e028c 100644
--- a/libavcodec/nellymoserdec.c
+++ b/libavcodec/nellymoserdec.c
@@ -35,14 +35,13 @@ 
 #include "libavutil/float_dsp.h"
 #include "libavutil/lfg.h"
 #include "libavutil/mem_internal.h"
-#include "libavutil/random_seed.h"
 
 #define BITSTREAM_READER_LE
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "fft.h"
 #include "get_bits.h"
-#include "internal.h"
 #include "nellymoser.h"
 #include "sinewin.h"
 
diff --git a/libavcodec/on2avc.c b/libavcodec/on2avc.c
index 1fccdc8745..3aadac4baf 100644
--- a/libavcodec/on2avc.c
+++ b/libavcodec/on2avc.c
@@ -28,9 +28,9 @@ 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "fft.h"
 #include "get_bits.h"
-#include "internal.h"
 
 #include "on2avcdata.h"
 
diff --git a/libavcodec/opusdec.c b/libavcodec/opusdec.c
index 17a4fc96c1..792eeb1507 100644
--- a/libavcodec/opusdec.c
+++ b/libavcodec/opusdec.c
@@ -44,9 +44,7 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "get_bits.h"
-#include "internal.h"
-#include "mathops.h"
+#include "decode.h"
 #include "opus.h"
 #include "opustab.h"
 #include "opus_celt.h"
diff --git a/libavcodec/pafaudio.c b/libavcodec/pafaudio.c
index fc642db2ed..16f440dd87 100644
--- a/libavcodec/pafaudio.c
+++ b/libavcodec/pafaudio.c
@@ -24,7 +24,7 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "mathops.h"
 #include "paf.h"
 
diff --git a/libavcodec/pcm-bluray.c b/libavcodec/pcm-bluray.c
index 54338e679f..365b69b599 100644
--- a/libavcodec/pcm-bluray.c
+++ b/libavcodec/pcm-bluray.c
@@ -28,7 +28,7 @@ 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 /*
  * Channel Mapping according to
diff --git a/libavcodec/pcm-dvd.c b/libavcodec/pcm-dvd.c
index 0f37c6e08e..358c9d5b0f 100644
--- a/libavcodec/pcm-dvd.c
+++ b/libavcodec/pcm-dvd.c
@@ -27,7 +27,7 @@ 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 typedef struct PCMDVDContext {
     uint32_t last_header;    // Cached header to see if parsing is needed
diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
index d097900235..8e87679329 100644
--- a/libavcodec/pcm.c
+++ b/libavcodec/pcm.c
@@ -33,9 +33,8 @@ 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "encode.h"
-#include "internal.h"
-#include "mathops.h"
 #include "pcm_tablegen.h"
 
 static av_cold int pcm_encode_init(AVCodecContext *avctx)
diff --git a/libavcodec/pcx.c b/libavcodec/pcx.c
index b21bdce5ce..7a47ef827c 100644
--- a/libavcodec/pcx.c
+++ b/libavcodec/pcx.c
@@ -26,6 +26,7 @@ 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
 #include "internal.h"
 
diff --git a/libavcodec/pgxdec.c b/libavcodec/pgxdec.c
index 52e2c2a36c..dcbf2a32dd 100644
--- a/libavcodec/pgxdec.c
+++ b/libavcodec/pgxdec.c
@@ -23,7 +23,7 @@ 
 #include "internal.h"
 #include "bytestream.h"
 #include "codec_internal.h"
-#include "libavutil/imgutils.h"
+#include "decode.h"
 
 static int pgx_get_number(AVCodecContext *avctx, GetByteContext *g, int *number) {
     int ret = AVERROR_INVALIDDATA;
diff --git a/libavcodec/pictordec.c b/libavcodec/pictordec.c
index ed0292c797..f215f0d220 100644
--- a/libavcodec/pictordec.c
+++ b/libavcodec/pictordec.c
@@ -29,6 +29,7 @@ 
 #include "bytestream.h"
 #include "cga_data.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 
 typedef struct PicContext {
diff --git a/libavcodec/pnmdec.c b/libavcodec/pnmdec.c
index fbed282e93..6e807a7ac1 100644
--- a/libavcodec/pnmdec.c
+++ b/libavcodec/pnmdec.c
@@ -25,7 +25,7 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "put_bits.h"
 #include "pnm.h"
 
diff --git a/libavcodec/prosumer.c b/libavcodec/prosumer.c
index c038b9db64..974b1657c3 100644
--- a/libavcodec/prosumer.c
+++ b/libavcodec/prosumer.c
@@ -23,7 +23,6 @@ 
 #include <stdlib.h>
 #include <string.h>
 
-#include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/mem.h"
@@ -31,7 +30,7 @@ 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 typedef struct ProSumerContext {
     GetByteContext gb;
diff --git a/libavcodec/psd.c b/libavcodec/psd.c
index 1d92163408..5a5c57e856 100644
--- a/libavcodec/psd.c
+++ b/libavcodec/psd.c
@@ -21,6 +21,7 @@ 
 
 #include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 
 enum PsdCompr {
diff --git a/libavcodec/ptx.c b/libavcodec/ptx.c
index 1102049347..412df4d763 100644
--- a/libavcodec/ptx.c
+++ b/libavcodec/ptx.c
@@ -21,9 +21,9 @@ 
 
 #include "libavutil/common.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/imgutils.h"
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 
 static int ptx_decode_frame(AVCodecContext *avctx, AVFrame *p,
diff --git a/libavcodec/qcelpdec.c b/libavcodec/qcelpdec.c
index 8a46ec5dab..f9da514834 100644
--- a/libavcodec/qcelpdec.c
+++ b/libavcodec/qcelpdec.c
@@ -27,14 +27,12 @@ 
  * @remark Development mentored by Benjamin Larson
  */
 
-#include <stddef.h>
-
 #include "libavutil/avassert.h"
 #include "libavutil/channel_layout.h"
 #include "libavutil/float_dsp.h"
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "get_bits.h"
 #include "qcelpdata.h"
 #include "celp_filters.h"
diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c
index 12db585aa2..51ca1fb516 100644
--- a/libavcodec/qdm2.c
+++ b/libavcodec/qdm2.c
@@ -33,7 +33,6 @@ 
 
 #include <math.h>
 #include <stddef.h>
-#include <stdio.h>
 
 #include "libavutil/channel_layout.h"
 #include "libavutil/mem_internal.h"
@@ -44,7 +43,7 @@ 
 #include "get_bits.h"
 #include "bytestream.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "mpegaudio.h"
 #include "mpegaudiodsp.h"
 #include "rdft.h"
diff --git a/libavcodec/qdmc.c b/libavcodec/qdmc.c
index 0a66d66441..77bb8d1742 100644
--- a/libavcodec/qdmc.c
+++ b/libavcodec/qdmc.c
@@ -21,7 +21,6 @@ 
 
 #include <math.h>
 #include <stddef.h>
-#include <stdio.h>
 
 #define BITSTREAM_READER_LE
 
@@ -32,8 +31,8 @@ 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
-#include "internal.h"
 
 typedef struct QDMCTone {
     uint8_t mode;
diff --git a/libavcodec/qdrw.c b/libavcodec/qdrw.c
index ff8f97713d..1aac7c8010 100644
--- a/libavcodec/qdrw.c
+++ b/libavcodec/qdrw.c
@@ -31,6 +31,7 @@ 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 
 enum QuickdrawOpcodes {
diff --git a/libavcodec/qpeg.c b/libavcodec/qpeg.c
index ea92b693cd..ea11e10b1a 100644
--- a/libavcodec/qpeg.c
+++ b/libavcodec/qpeg.c
@@ -28,7 +28,6 @@ 
 #include "bytestream.h"
 #include "codec_internal.h"
 #include "decode.h"
-#include "internal.h"
 
 typedef struct QpegContext{
     AVCodecContext *avctx;
diff --git a/libavcodec/r210dec.c b/libavcodec/r210dec.c
index 5ac285f286..163e203c73 100644
--- a/libavcodec/r210dec.c
+++ b/libavcodec/r210dec.c
@@ -23,7 +23,7 @@ 
 #include "avcodec.h"
 #include "codec_internal.h"
 #include "config_components.h"
-#include "internal.h"
+#include "decode.h"
 #include "libavutil/bswap.h"
 #include "libavutil/common.h"
 
diff --git a/libavcodec/ra144dec.c b/libavcodec/ra144dec.c
index a56d4f7d51..f9c0900de0 100644
--- a/libavcodec/ra144dec.c
+++ b/libavcodec/ra144dec.c
@@ -25,8 +25,8 @@ 
 #include "libavutil/channel_layout.h"
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
-#include "internal.h"
 #include "ra144.h"
 
 
diff --git a/libavcodec/ra288.c b/libavcodec/ra288.c
index 4b2cc188b4..73242669d3 100644
--- a/libavcodec/ra288.c
+++ b/libavcodec/ra288.c
@@ -28,8 +28,8 @@ 
 #include "avcodec.h"
 #include "celp_filters.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
-#include "internal.h"
 #include "lpc.h"
 #include "ra288.h"
 
diff --git a/libavcodec/ralf.c b/libavcodec/ralf.c
index ff4556b707..5efa919e09 100644
--- a/libavcodec/ralf.c
+++ b/libavcodec/ralf.c
@@ -30,9 +30,9 @@ 
 #include "libavutil/channel_layout.h"
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
 #include "golomb.h"
-#include "internal.h"
 #include "unary.h"
 #include "ralfdata.h"
 
diff --git a/libavcodec/rasc.c b/libavcodec/rasc.c
index 805e29338d..a74b4d145c 100644
--- a/libavcodec/rasc.c
+++ b/libavcodec/rasc.c
@@ -21,15 +21,14 @@ 
  */
 
 #include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
 
-#include "libavutil/imgutils.h"
 #include "libavutil/opt.h"
 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 #include "zlib_wrapper.h"
 
diff --git a/libavcodec/rl2.c b/libavcodec/rl2.c
index fc022ff43e..e7c3800f9e 100644
--- a/libavcodec/rl2.c
+++ b/libavcodec/rl2.c
@@ -35,6 +35,7 @@ 
 #include "libavutil/mem.h"
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 
 
diff --git a/libavcodec/s302m.c b/libavcodec/s302m.c
index fb7b6e240b..07d036e932 100644
--- a/libavcodec/s302m.c
+++ b/libavcodec/s302m.c
@@ -27,8 +27,7 @@ 
 #include "libavutil/reverse.h"
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
-#include "mathops.h"
+#include "decode.h"
 
 #define AES3_HEADER_LEN 4
 
diff --git a/libavcodec/sanm.c b/libavcodec/sanm.c
index 775768b7a0..064e812e51 100644
--- a/libavcodec/sanm.c
+++ b/libavcodec/sanm.c
@@ -28,6 +28,7 @@ 
 #include "bytestream.h"
 #include "copy_block.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 
 #define NGLYPHS 256
diff --git a/libavcodec/sbcdec.c b/libavcodec/sbcdec.c
index b7e59d7124..3c955d5b96 100644
--- a/libavcodec/sbcdec.c
+++ b/libavcodec/sbcdec.c
@@ -32,7 +32,7 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "libavutil/channel_layout.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/mem_internal.h"
diff --git a/libavcodec/scpr.c b/libavcodec/scpr.c
index ff78041386..3abde1c17a 100644
--- a/libavcodec/scpr.c
+++ b/libavcodec/scpr.c
@@ -20,15 +20,12 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
 #include "decode.h"
-#include "internal.h"
 #include "scpr.h"
 #include "scpr3.h"
 
diff --git a/libavcodec/scpr3.c b/libavcodec/scpr3.c
index 78c58889cb..d9ea6af1c1 100644
--- a/libavcodec/scpr3.c
+++ b/libavcodec/scpr3.c
@@ -28,7 +28,6 @@ 
 
 #include "avcodec.h"
 #include "bytestream.h"
-#include "internal.h"
 #include "scpr.h"
 
 static void renew_table3(uint32_t nsym, uint32_t *cntsum,
diff --git a/libavcodec/sga.c b/libavcodec/sga.c
index 27918ee2b3..febe950424 100644
--- a/libavcodec/sga.c
+++ b/libavcodec/sga.c
@@ -23,6 +23,7 @@ 
 #include "get_bits.h"
 #include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 
 #define PALDATA_FOLLOWS_TILEDATA 4
diff --git a/libavcodec/sgidec.c b/libavcodec/sgidec.c
index 965461de5f..c1070d5c95 100644
--- a/libavcodec/sgidec.c
+++ b/libavcodec/sgidec.c
@@ -23,6 +23,7 @@ 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 #include "sgi.h"
 
diff --git a/libavcodec/sgirledec.c b/libavcodec/sgirledec.c
index a9fd24c406..c1d1da25c4 100644
--- a/libavcodec/sgirledec.c
+++ b/libavcodec/sgirledec.c
@@ -30,7 +30,7 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 static av_cold int sgirle_decode_init(AVCodecContext *avctx)
 {
diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c
index 39aa1475bd..02864d06ae 100644
--- a/libavcodec/shorten.c
+++ b/libavcodec/shorten.c
@@ -30,9 +30,9 @@ 
 #include "bswapdsp.h"
 #include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
 #include "golomb.h"
-#include "internal.h"
 
 #define MAX_CHANNELS 8
 #define MAX_BLOCKSIZE 65535
diff --git a/libavcodec/sipr.c b/libavcodec/sipr.c
index bf8d627e16..d28bc760ca 100644
--- a/libavcodec/sipr.c
+++ b/libavcodec/sipr.c
@@ -32,8 +32,8 @@ 
 #define BITSTREAM_READER_LE
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
-#include "internal.h"
 #include "lsp.h"
 #include "acelp_vectors.h"
 #include "acelp_pitch_delay.h"
diff --git a/libavcodec/siren.c b/libavcodec/siren.c
index e7a5a33553..8a22825615 100644
--- a/libavcodec/siren.c
+++ b/libavcodec/siren.c
@@ -28,9 +28,8 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
-#include "internal.h"
-#include "mathops.h"
 
 static const uint8_t index_table[8] = {4, 4, 3, 3, 2, 2, 1, 0};
 static const uint8_t vector_dimension[8] = { 2, 2, 2, 4, 4, 5, 5, 1 };
diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c
index 5ef84a068f..2b1c4aebb5 100644
--- a/libavcodec/smacker.c
+++ b/libavcodec/smacker.c
@@ -28,8 +28,7 @@ 
  * Based on http://wiki.multimedia.cx/index.php?title=Smacker
  */
 
-#include <stdio.h>
-#include <stdlib.h>
+#include <stddef.h>
 
 #include "libavutil/channel_layout.h"
 
@@ -53,8 +52,6 @@ 
 #include "codec_internal.h"
 #include "decode.h"
 #include "get_bits.h"
-#include "internal.h"
-#include "mathops.h"
 
 typedef struct SmackVContext {
     AVCodecContext *avctx;
diff --git a/libavcodec/snow.c b/libavcodec/snow.c
index 5e0033063d..aa15fccc42 100644
--- a/libavcodec/snow.c
+++ b/libavcodec/snow.c
@@ -18,21 +18,16 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavutil/intmath.h"
 #include "libavutil/log.h"
-#include "libavutil/opt.h"
 #include "libavutil/thread.h"
 #include "avcodec.h"
+#include "decode.h"
 #include "encode.h"
 #include "me_cmp.h"
 #include "snow_dwt.h"
-#include "internal.h"
 #include "snow.h"
 #include "snowdata.h"
 
-#include "rangecoder.h"
-#include "mathops.h"
-
 
 void ff_snow_inner_add_yblock(const uint8_t *obmc, const int obmc_stride, uint8_t * * block, int b_w, int b_h,
                               int src_x, int src_y, int src_stride, slice_buffer * sb, int add, uint8_t * dst8){
diff --git a/libavcodec/sonic.c b/libavcodec/sonic.c
index 2dc6ac3f2d..50fd171231 100644
--- a/libavcodec/sonic.c
+++ b/libavcodec/sonic.c
@@ -23,10 +23,10 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "encode.h"
 #include "get_bits.h"
 #include "golomb.h"
-#include "internal.h"
 #include "put_golomb.h"
 #include "rangecoder.h"
 
diff --git a/libavcodec/speedhq.c b/libavcodec/speedhq.c
index c43de4f199..b3b3f091d6 100644
--- a/libavcodec/speedhq.c
+++ b/libavcodec/speedhq.c
@@ -26,7 +26,6 @@ 
 
 #define BITSTREAM_READER_LE
 
-#include "config.h"
 #include "config_components.h"
 #include "libavutil/attributes.h"
 #include "libavutil/mem_internal.h"
@@ -34,9 +33,9 @@ 
 #include "avcodec.h"
 #include "blockdsp.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
 #include "idctdsp.h"
-#include "internal.h"
 #include "libavutil/thread.h"
 #include "mathops.h"
 #include "mpeg12dec.h"
diff --git a/libavcodec/speexdec.c b/libavcodec/speexdec.c
index 92a4f392a7..d16317ddec 100644
--- a/libavcodec/speexdec.c
+++ b/libavcodec/speexdec.c
@@ -56,8 +56,8 @@ 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
-#include "internal.h"
 #include "speexdata.h"
 
 #define SPEEX_NB_MODES 3
diff --git a/libavcodec/sunrast.c b/libavcodec/sunrast.c
index e543757a39..51695c353c 100644
--- a/libavcodec/sunrast.c
+++ b/libavcodec/sunrast.c
@@ -24,6 +24,7 @@ 
 #include "libavutil/imgutils.h"
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 #include "sunrast.h"
 
diff --git a/libavcodec/svq1dec.c b/libavcodec/svq1dec.c
index 27feac354c..e091e4279f 100644
--- a/libavcodec/svq1dec.c
+++ b/libavcodec/svq1dec.c
@@ -37,6 +37,7 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
 #include "h263data.h"
 #include "hpeldsp.h"
diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c
index 1c3ed3c2fd..d4fff0557b 100644
--- a/libavcodec/svq3.c
+++ b/libavcodec/svq3.c
@@ -47,6 +47,7 @@ 
 #include "libavutil/mem_internal.h"
 
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 #include "avcodec.h"
 #include "mpegutils.h"
diff --git a/libavcodec/targa.c b/libavcodec/targa.c
index 833576c6b3..2901d908de 100644
--- a/libavcodec/targa.c
+++ b/libavcodec/targa.c
@@ -24,6 +24,7 @@ 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 #include "targa.h"
 
diff --git a/libavcodec/targa_y216dec.c b/libavcodec/targa_y216dec.c
index 1c19857547..ab98597492 100644
--- a/libavcodec/targa_y216dec.c
+++ b/libavcodec/targa_y216dec.c
@@ -21,7 +21,7 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 static av_cold int y216_decode_init(AVCodecContext *avctx)
 {
diff --git a/libavcodec/tdsc.c b/libavcodec/tdsc.c
index 7e16a32093..c4e4d35ee8 100644
--- a/libavcodec/tdsc.c
+++ b/libavcodec/tdsc.c
@@ -41,6 +41,7 @@ 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 
 #define BITMAPINFOHEADER_SIZE 0x28
diff --git a/libavcodec/tmv.c b/libavcodec/tmv.c
index 22329f2db0..fff3806e04 100644
--- a/libavcodec/tmv.c
+++ b/libavcodec/tmv.c
@@ -30,7 +30,7 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "libavutil/internal.h"
 #include "libavutil/xga_font_data.h"
 
diff --git a/libavcodec/truemotion2rt.c b/libavcodec/truemotion2rt.c
index 46452a772b..265ca87456 100644
--- a/libavcodec/truemotion2rt.c
+++ b/libavcodec/truemotion2rt.c
@@ -29,6 +29,7 @@ 
 #define BITSTREAM_READER_LE
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
 #include "internal.h"
 
diff --git a/libavcodec/truespeech.c b/libavcodec/truespeech.c
index f0cfada11c..2493a944cf 100644
--- a/libavcodec/truespeech.c
+++ b/libavcodec/truespeech.c
@@ -20,14 +20,13 @@ 
  */
 
 #include "libavutil/channel_layout.h"
-#include "libavutil/intreadwrite.h"
 #include "libavutil/mem_internal.h"
 
 #include "avcodec.h"
 #include "bswapdsp.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
-#include "internal.h"
 
 #include "truespeech_data.h"
 /**
diff --git a/libavcodec/twinvq.c b/libavcodec/twinvq.c
index ba84c8c6b0..da10923d78 100644
--- a/libavcodec/twinvq.c
+++ b/libavcodec/twinvq.c
@@ -25,8 +25,8 @@ 
 #include "libavutil/channel_layout.h"
 #include "libavutil/float_dsp.h"
 #include "avcodec.h"
+#include "decode.h"
 #include "fft.h"
-#include "internal.h"
 #include "lsp.h"
 #include "sinewin.h"
 #include "twinvq.h"
diff --git a/libavcodec/txd.c b/libavcodec/txd.c
index 8b1da773a3..8862f14bd8 100644
--- a/libavcodec/txd.c
+++ b/libavcodec/txd.c
@@ -26,6 +26,7 @@ 
 #include "bytestream.h"
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 #include "texturedsp.h"
 
diff --git a/libavcodec/v210x.c b/libavcodec/v210x.c
index f388a1cf9a..dc188eb8a3 100644
--- a/libavcodec/v210x.c
+++ b/libavcodec/v210x.c
@@ -20,7 +20,7 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "libavutil/bswap.h"
 #include "libavutil/internal.h"
 
diff --git a/libavcodec/v308dec.c b/libavcodec/v308dec.c
index a6a699cab7..ee9d723dd6 100644
--- a/libavcodec/v308dec.c
+++ b/libavcodec/v308dec.c
@@ -21,7 +21,7 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 static av_cold int v308_decode_init(AVCodecContext *avctx)
 {
diff --git a/libavcodec/v408dec.c b/libavcodec/v408dec.c
index 694ee96b77..0c1d0244d0 100644
--- a/libavcodec/v408dec.c
+++ b/libavcodec/v408dec.c
@@ -23,7 +23,7 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 static av_cold int v408_decode_init(AVCodecContext *avctx)
 {
diff --git a/libavcodec/vb.c b/libavcodec/vb.c
index 0bd2cb6185..9024f0947c 100644
--- a/libavcodec/vb.c
+++ b/libavcodec/vb.c
@@ -24,13 +24,10 @@ 
  * VB Video decoder
  */
 
-#include <stdio.h>
-#include <stdlib.h>
-
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 enum VBFlags {
     VB_HAS_GMC     = 0x01,
diff --git a/libavcodec/vbndec.c b/libavcodec/vbndec.c
index 8be625c89e..706760f376 100644
--- a/libavcodec/vbndec.c
+++ b/libavcodec/vbndec.c
@@ -26,6 +26,7 @@ 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 #include "texturedsp.h"
 #include "vbn.h"
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 065b43cb11..60e86acfd9 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -34,7 +34,6 @@ 
 #include "decode.h"
 #include "get_bits.h"
 #include "hwconfig.h"
-#include "internal.h"
 #include "mpeg_er.h"
 #include "mpegvideo.h"
 #include "mpegvideodec.h"
diff --git a/libavcodec/vcr1.c b/libavcodec/vcr1.c
index b149c9f162..a97412fe7d 100644
--- a/libavcodec/vcr1.c
+++ b/libavcodec/vcr1.c
@@ -26,7 +26,7 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "libavutil/avassert.h"
 #include "libavutil/internal.h"
 
diff --git a/libavcodec/vima.c b/libavcodec/vima.c
index 9a7726168b..0ccf2dd877 100644
--- a/libavcodec/vima.c
+++ b/libavcodec/vima.c
@@ -31,8 +31,8 @@ 
 #include "adpcm_data.h"
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
-#include "internal.h"
 
 static uint16_t predict_table[5786 * 2];
 
diff --git a/libavcodec/vmdaudio.c b/libavcodec/vmdaudio.c
index e54e341f90..158b02f6d9 100644
--- a/libavcodec/vmdaudio.c
+++ b/libavcodec/vmdaudio.c
@@ -42,7 +42,7 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 #define BLOCK_TYPE_AUDIO    1
 #define BLOCK_TYPE_INITIAL  2
diff --git a/libavcodec/vmdvideo.c b/libavcodec/vmdvideo.c
index 131e013a94..3e530e6ee5 100644
--- a/libavcodec/vmdvideo.c
+++ b/libavcodec/vmdvideo.c
@@ -40,7 +40,7 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "bytestream.h"
 
 #define VMD_HEADER_SIZE 0x330
diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c
index b94b4a34e0..8addc07dcf 100644
--- a/libavcodec/vorbisdec.c
+++ b/libavcodec/vorbisdec.c
@@ -35,9 +35,9 @@ 
 #define BITSTREAM_READER_LE
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "fft.h"
 #include "get_bits.h"
-#include "internal.h"
 #include "vorbis.h"
 #include "vorbisdsp.h"
 #include "xiph.h"
diff --git a/libavcodec/vp56.c b/libavcodec/vp56.c
index 3863af15e5..1c58096bdb 100644
--- a/libavcodec/vp56.c
+++ b/libavcodec/vp56.c
@@ -25,6 +25,7 @@ 
 
 #include "avcodec.h"
 #include "bytestream.h"
+#include "decode.h"
 #include "internal.h"
 #include "h264chroma.h"
 #include "vp56.h"
diff --git a/libavcodec/wmadec.c b/libavcodec/wmadec.c
index 755fd39521..c3badcd5f9 100644
--- a/libavcodec/wmadec.c
+++ b/libavcodec/wmadec.c
@@ -40,6 +40,7 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 #include "wma.h"
 
diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c
index 6ba9f04d25..fa4230c1b5 100644
--- a/libavcodec/wmalosslessdec.c
+++ b/libavcodec/wmalosslessdec.c
@@ -30,11 +30,10 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "get_bits.h"
 #include "put_bits.h"
 #include "lossless_audiodsp.h"
-#include "wma.h"
 #include "wma_common.h"
 
 /** current decoder limitations */
diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c
index 136522bbf6..b90fd581f0 100644
--- a/libavcodec/wmaprodec.c
+++ b/libavcodec/wmaprodec.c
@@ -98,8 +98,9 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "get_bits.h"
+#include "internal.h"
 #include "put_bits.h"
 #include "wmaprodata.h"
 #include "sinewin.h"
diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c
index 6f6cc949f9..6b7e9d5a31 100644
--- a/libavcodec/wmavoice.c
+++ b/libavcodec/wmavoice.c
@@ -33,7 +33,7 @@ 
 #include "libavutil/thread.h"
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "get_bits.h"
 #include "put_bits.h"
 #include "wmavoice_data.h"
diff --git a/libavcodec/wnv1.c b/libavcodec/wnv1.c
index 8e568e7386..ff5238eed0 100644
--- a/libavcodec/wnv1.c
+++ b/libavcodec/wnv1.c
@@ -29,8 +29,8 @@ 
 #define BITSTREAM_READER_LE
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
-#include "internal.h"
 
 static const uint8_t code_tab[16][2] = {
     {  7, 1 }, {  8, 3 }, {  6, 3 }, { 9, 4 }, {  5, 4 }, { 10, 5 }, {  4, 5 },
diff --git a/libavcodec/ws-snd1.c b/libavcodec/ws-snd1.c
index ceda57597f..6dcb8d2a24 100644
--- a/libavcodec/ws-snd1.c
+++ b/libavcodec/ws-snd1.c
@@ -26,7 +26,7 @@ 
 #include "libavutil/intreadwrite.h"
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 /**
  * @file
diff --git a/libavcodec/xan.c b/libavcodec/xan.c
index cdc302f6d1..d9df569a04 100644
--- a/libavcodec/xan.c
+++ b/libavcodec/xan.c
@@ -28,8 +28,6 @@ 
  * The xan_wc3 decoder outputs PAL8 data.
  */
 
-#include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
 
 #include "libavutil/intreadwrite.h"
@@ -39,8 +37,8 @@ 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
-#include "internal.h"
 
 #define RUNTIME_GAMMA 0
 
diff --git a/libavcodec/xbmdec.c b/libavcodec/xbmdec.c
index 62ce46f3a7..a28da08a29 100644
--- a/libavcodec/xbmdec.c
+++ b/libavcodec/xbmdec.c
@@ -25,6 +25,7 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 #include "mathops.h"
 
diff --git a/libavcodec/xfacedec.c b/libavcodec/xfacedec.c
index 880a62c976..eb16bb6727 100644
--- a/libavcodec/xfacedec.c
+++ b/libavcodec/xfacedec.c
@@ -24,11 +24,9 @@ 
  * X-Face decoder, based on libcompface, by James Ashton.
  */
 
-#include "libavutil/pixdesc.h"
 #include "avcodec.h"
-#include "bytestream.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "xface.h"
 
 static int pop_integer(BigInt *b, const ProbRange *pranges)
diff --git a/libavcodec/xl.c b/libavcodec/xl.c
index 6fb050d71f..ada0959346 100644
--- a/libavcodec/xl.c
+++ b/libavcodec/xl.c
@@ -28,7 +28,7 @@ 
 #include "libavutil/intreadwrite.h"
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 static const int xl_table[32] = {
    0,   1,   2,   3,   4,   5,   6,   7,
diff --git a/libavcodec/xpmdec.c b/libavcodec/xpmdec.c
index 26d076d2e8..a1d5635874 100644
--- a/libavcodec/xpmdec.c
+++ b/libavcodec/xpmdec.c
@@ -21,10 +21,10 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavutil/parseutils.h"
 #include "libavutil/avstring.h"
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 
 #define MIN_ELEMENT ' '
diff --git a/libavcodec/xwddec.c b/libavcodec/xwddec.c
index f8afab598d..43d4bb5e84 100644
--- a/libavcodec/xwddec.c
+++ b/libavcodec/xwddec.c
@@ -26,6 +26,7 @@ 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 #include "xwd.h"
 
diff --git a/libavcodec/y41pdec.c b/libavcodec/y41pdec.c
index 717909745b..7d63228937 100644
--- a/libavcodec/y41pdec.c
+++ b/libavcodec/y41pdec.c
@@ -22,7 +22,7 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 static av_cold int y41p_decode_init(AVCodecContext *avctx)
 {
diff --git a/libavcodec/yuv4dec.c b/libavcodec/yuv4dec.c
index 4a1551eb6c..274b8b7b2d 100644
--- a/libavcodec/yuv4dec.c
+++ b/libavcodec/yuv4dec.c
@@ -22,7 +22,7 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 static av_cold int yuv4_decode_init(AVCodecContext *avctx)
 {
diff --git a/libavcodec/zerocodec.c b/libavcodec/zerocodec.c
index 8a0d8bc677..c369ff8e3c 100644
--- a/libavcodec/zerocodec.c
+++ b/libavcodec/zerocodec.c
@@ -20,7 +20,7 @@ 
 
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "zlib_wrapper.h"
 #include "libavutil/common.h"
 
diff --git a/libavcodec/zmbv.c b/libavcodec/zmbv.c
index a6d9824197..edbd88eb73 100644
--- a/libavcodec/zmbv.c
+++ b/libavcodec/zmbv.c
@@ -24,15 +24,14 @@ 
  * Zip Motion Blocks Video decoder
  */
 
-#include <stdio.h>
-#include <stdlib.h>
+#include <stddef.h>
 
 #include "libavutil/common.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/intreadwrite.h"
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "zlib_wrapper.h"
 
 #include <zlib.h>