diff mbox series

[FFmpeg-devel] avcodec/internal: Move AVCodecInternal to a header of its own

Message ID GV1P250MB07375D3E989DC408630724448F31A@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM
State New
Headers show
Series [FFmpeg-devel] avcodec/internal: Move AVCodecInternal to a header of its own | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt July 11, 2023, 1:10 a.m. UTC
This allows to avoid exposing AVCodecInternal to files that
don't need it and only include internal.h for something else
(like the avpriv functions which are of course included outside
of libavcodec where AVCodecInternal should never be visible).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/aacdec_template.c      |   2 +-
 libavcodec/amfenc.c               |   2 +-
 libavcodec/amfenc_av1.c           |   2 +-
 libavcodec/amfenc_h264.c          |   2 +-
 libavcodec/amfenc_hevc.c          |   2 +-
 libavcodec/aptxenc.c              |   2 +-
 libavcodec/audiotoolboxenc.c      |   2 +-
 libavcodec/av1dec.c               |   2 +-
 libavcodec/avcodec.c              |   3 +-
 libavcodec/avcodecinternal.h      | 139 ++++++++++++++++++++++++++++++
 libavcodec/binkaudio.c            |   2 +-
 libavcodec/cfhd.c                 |   3 +-
 libavcodec/cngdec.c               |   3 +-
 libavcodec/crystalhd.c            |   2 +-
 libavcodec/cuviddec.c             |   2 +-
 libavcodec/decode.c               |   6 +-
 libavcodec/dxva2_internal.h       |   2 +-
 libavcodec/encode.c               |   2 +-
 libavcodec/frame_thread_encoder.c |   2 +-
 libavcodec/get_buffer.c           |   1 +
 libavcodec/h264dec.c              |   1 +
 libavcodec/hevcdec.c              |   2 +-
 libavcodec/internal.h             | 104 ----------------------
 libavcodec/libaomenc.c            |   1 +
 libavcodec/libaribcaption.c       |   2 +-
 libavcodec/libdav1d.c             |   2 +-
 libavcodec/libjxldec.c            |   2 +-
 libavcodec/libopusdec.c           |   2 +-
 libavcodec/librav1e.c             |   2 +-
 libavcodec/libx264.c              |   1 +
 libavcodec/mediacodecdec.c        |   2 +-
 libavcodec/mfenc.c                |   2 +-
 libavcodec/mjpegdec.c             |   3 +-
 libavcodec/mmaldec.c              |   2 +-
 libavcodec/mpegpicture.c          |   1 -
 libavcodec/mpegvideo_enc.c        |   1 +
 libavcodec/nvdec.c                |   2 +-
 libavcodec/nvdec_av1.c            |   2 +-
 libavcodec/nvdec_h264.c           |   2 +-
 libavcodec/nvdec_hevc.c           |   2 +-
 libavcodec/nvdec_mjpeg.c          |   2 +-
 libavcodec/nvdec_mpeg12.c         |   2 +-
 libavcodec/nvdec_mpeg4.c          |   2 +-
 libavcodec/nvdec_vc1.c            |   2 +-
 libavcodec/nvdec_vp8.c            |   2 +-
 libavcodec/nvdec_vp9.c            |   2 +-
 libavcodec/opus_parse.c           |   2 +-
 libavcodec/pthread_frame.c        |   2 +-
 libavcodec/pthread_slice.c        |   5 +-
 libavcodec/qsvdec.c               |   2 +-
 libavcodec/rawdec.c               |   2 +-
 libavcodec/snowenc.c              |   2 +-
 libavcodec/v210_template.c        |   1 -
 libavcodec/vaapi_av1.c            |   2 +-
 libavcodec/vaapi_decode.c         |   2 +-
 libavcodec/vdpau.c                |   2 +-
 libavcodec/vdpau_av1.c            |   2 +-
 libavcodec/videotoolbox.c         |   2 +-
 libavcodec/videotoolbox_vp9.c     |   2 +-
 libavcodec/videotoolboxenc.c      |   2 +-
 libavcodec/vorbisdec.c            |   2 +-
 libavcodec/vulkan_decode.h        |   2 +-
 libavcodec/wmadec.c               |   2 +-
 libavcodec/wmaprodec.c            |   2 +-
 64 files changed, 199 insertions(+), 172 deletions(-)
 create mode 100644 libavcodec/avcodecinternal.h

Comments

James Almer July 11, 2023, 1:15 a.m. UTC | #1
On 7/10/2023 10:10 PM, Andreas Rheinhardt wrote:
> This allows to avoid exposing AVCodecInternal to files that
> don't need it and only include internal.h for something else
> (like the avpriv functions which are of course included outside
> of libavcodec where AVCodecInternal should never be visible).
> 
> Signed-off-by: Andreas Rheinhardt<andreas.rheinhardt@outlook.com>
> ---
>   libavcodec/aacdec_template.c      |   2 +-
>   libavcodec/amfenc.c               |   2 +-
>   libavcodec/amfenc_av1.c           |   2 +-
>   libavcodec/amfenc_h264.c          |   2 +-
>   libavcodec/amfenc_hevc.c          |   2 +-
>   libavcodec/aptxenc.c              |   2 +-
>   libavcodec/audiotoolboxenc.c      |   2 +-
>   libavcodec/av1dec.c               |   2 +-
>   libavcodec/avcodec.c              |   3 +-
>   libavcodec/avcodecinternal.h      | 139 ++++++++++++++++++++++++++++++

I prefer avcodec_internal.h, to be in line with other similar internal 
headers from modules with a public one.

That aside it LGTM if checkheaders passes. The more files include only 
what they need, the less likely to experience tree-wide recompilation 
for changing a single header.
Andreas Rheinhardt July 11, 2023, 1:26 a.m. UTC | #2
James Almer:
> On 7/10/2023 10:10 PM, Andreas Rheinhardt wrote:
>> This allows to avoid exposing AVCodecInternal to files that
>> don't need it and only include internal.h for something else
>> (like the avpriv functions which are of course included outside
>> of libavcodec where AVCodecInternal should never be visible).
>>
>> Signed-off-by: Andreas Rheinhardt<andreas.rheinhardt@outlook.com>
>> ---
>>   libavcodec/aacdec_template.c      |   2 +-
>>   libavcodec/amfenc.c               |   2 +-
>>   libavcodec/amfenc_av1.c           |   2 +-
>>   libavcodec/amfenc_h264.c          |   2 +-
>>   libavcodec/amfenc_hevc.c          |   2 +-
>>   libavcodec/aptxenc.c              |   2 +-
>>   libavcodec/audiotoolboxenc.c      |   2 +-
>>   libavcodec/av1dec.c               |   2 +-
>>   libavcodec/avcodec.c              |   3 +-
>>   libavcodec/avcodecinternal.h      | 139 ++++++++++++++++++++++++++++++
> 
> I prefer avcodec_internal.h, to be in line with other similar internal
> headers from modules with a public one.
> 

avcodec_internal.h is already taken by the header for the generic codec
layer (i.e. the one that must not be included by individual codecs).

> That aside it LGTM if checkheaders passes. The more files include only
> what they need, the less likely to experience tree-wide recompilation
> for changing a single header.

True. Almost no files need both headers.

- Andreas
James Almer July 11, 2023, 1:32 a.m. UTC | #3
On 7/10/2023 10:26 PM, Andreas Rheinhardt wrote:
> James Almer:
>> On 7/10/2023 10:10 PM, Andreas Rheinhardt wrote:
>>> This allows to avoid exposing AVCodecInternal to files that
>>> don't need it and only include internal.h for something else
>>> (like the avpriv functions which are of course included outside
>>> of libavcodec where AVCodecInternal should never be visible).
>>>
>>> Signed-off-by: Andreas Rheinhardt<andreas.rheinhardt@outlook.com>
>>> ---
>>>    libavcodec/aacdec_template.c      |   2 +-
>>>    libavcodec/amfenc.c               |   2 +-
>>>    libavcodec/amfenc_av1.c           |   2 +-
>>>    libavcodec/amfenc_h264.c          |   2 +-
>>>    libavcodec/amfenc_hevc.c          |   2 +-
>>>    libavcodec/aptxenc.c              |   2 +-
>>>    libavcodec/audiotoolboxenc.c      |   2 +-
>>>    libavcodec/av1dec.c               |   2 +-
>>>    libavcodec/avcodec.c              |   3 +-
>>>    libavcodec/avcodecinternal.h      | 139 ++++++++++++++++++++++++++++++
>>
>> I prefer avcodec_internal.h, to be in line with other similar internal
>> headers from modules with a public one.
>>
> 
> avcodec_internal.h is already taken by the header for the generic codec
> layer (i.e. the one that must not be included by individual codecs).

Then IMO those prototypes should be moved into separate 
decode_internal.h and encode_internal.h headers, to free this name.
They are needed by four files, so it's a waste of namespace and this 
change as is will make the tree more confusing.

> 
>> That aside it LGTM if checkheaders passes. The more files include only
>> what they need, the less likely to experience tree-wide recompilation
>> for changing a single header.
> 
> True. Almost no files need both headers.
> 
> - Andreas
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Anton Khirnov July 11, 2023, 10:13 a.m. UTC | #4
Quoting Andreas Rheinhardt (2023-07-11 03:10:38)
> This allows to avoid exposing AVCodecInternal to files that
> don't need it and only include internal.h for something else
> (like the avpriv functions which are of course included outside
> of libavcodec where AVCodecInternal should never be visible).

Actually looking at all those other things in internal.h it seems to me
that (almost?) all of them belong somewhere else.

Multiple functions are only used in one place, some others are
encoding-only and belong in encode.h, etc.
Andreas Rheinhardt Aug. 2, 2023, 3:37 p.m. UTC | #5
Anton Khirnov:
> Quoting Andreas Rheinhardt (2023-07-11 03:10:38)
>> This allows to avoid exposing AVCodecInternal to files that
>> don't need it and only include internal.h for something else
>> (like the avpriv functions which are of course included outside
>> of libavcodec where AVCodecInternal should never be visible).
> 
> Actually looking at all those other things in internal.h it seems to me
> that (almost?) all of them belong somewhere else.
> 
> Multiple functions are only used in one place, some others are
> encoding-only and belong in encode.h, etc.
> 

I just sent some patches that moved some of those functions to their
only callers; there is one more, namely ff_alloc_timecode_sei(), but I
am unsure of how intentional it was to put it in utils.c.

ff_guess_coded_bitrate() could be moved to encode.h, but I am unsure
whether the implementation should not be moved to encode.c (or to a new
encode_utils.c?) in this case. Furthermore this function is only used by
encoders, but it is used to set a field (namely AVCodecContext.bit_rate)
which encoders are not allowed to set (for raw codecs the bitrate that
will be used is actually determined by other factors (like dimensions
fps, pixel/sample format), but normally bitrate is an input parameter
when encoding).

ff_add_cpb_side_data() is used by mostly encoders, but also used by
mpeg12dec.c, so there is currently no better place for this.

The two avpriv functions as well as ff_toupper4() (duplicated into lavf
for shared builds) can't be moved to their only callers, obviously.

ff_exp2fi() is only used by two places and could be moved to e.g.
mathops.h, but then this function would be included in so many places
where it is not used.

ff_match_2uint16() could be used to e.g. mpegutils.h, but that is just
based upon the current users and not about the function itself.

FF_SANE_NB_CHANNELS is used in several demuxers (which is the reason why
I want to separate AVCodecInternal out of internal.h).

So I conclude that one can't move everything except AVCodecInternal out
of internal.h into existing headers/callers. So either one adds a new
header misc.h or utils.h for the rest or one adds a new header for
AVCodecInternal. Or one leaves everything as it is.

- Andreas
diff mbox series

Patch

diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
index 444dc4fa9d..50f904bd35 100644
--- a/libavcodec/aacdec_template.c
+++ b/libavcodec/aacdec_template.c
@@ -91,8 +91,8 @@ 
 
 #include "libavutil/channel_layout.h"
 #include "libavutil/thread.h"
+#include "avcodecinternal.h"
 #include "decode.h"
-#include "internal.h"
 
 static VLC vlc_scalefactors;
 static VLC vlc_spectral[11];
diff --git a/libavcodec/amfenc.c b/libavcodec/amfenc.c
index cb48f8c273..3e6ab0d3d0 100644
--- a/libavcodec/amfenc.c
+++ b/libavcodec/amfenc.c
@@ -34,8 +34,8 @@ 
 #include "libavutil/time.h"
 
 #include "amfenc.h"
+#include "avcodecinternal.h"
 #include "encode.h"
-#include "internal.h"
 
 #if CONFIG_D3D11VA
 #include <d3d11.h>
diff --git a/libavcodec/amfenc_av1.c b/libavcodec/amfenc_av1.c
index 30c0a9fad2..6ab3271685 100644
--- a/libavcodec/amfenc_av1.c
+++ b/libavcodec/amfenc_av1.c
@@ -19,8 +19,8 @@ 
 #include "libavutil/internal.h"
 #include "libavutil/opt.h"
 #include "amfenc.h"
+#include "avcodecinternal.h"
 #include "codec_internal.h"
-#include "internal.h"
 
 #define OFFSET(x) offsetof(AmfContext, x)
 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
diff --git a/libavcodec/amfenc_h264.c b/libavcodec/amfenc_h264.c
index 2380aa4e90..b70b00b42d 100644
--- a/libavcodec/amfenc_h264.c
+++ b/libavcodec/amfenc_h264.c
@@ -20,8 +20,8 @@ 
 #include "libavutil/internal.h"
 #include "libavutil/opt.h"
 #include "amfenc.h"
+#include "avcodecinternal.h"
 #include "codec_internal.h"
-#include "internal.h"
 #include <AMF/components/PreAnalysis.h>
 
 #define OFFSET(x) offsetof(AmfContext, x)
diff --git a/libavcodec/amfenc_hevc.c b/libavcodec/amfenc_hevc.c
index dd232cc8ac..c3a38e63b8 100644
--- a/libavcodec/amfenc_hevc.c
+++ b/libavcodec/amfenc_hevc.c
@@ -19,8 +19,8 @@ 
 #include "libavutil/internal.h"
 #include "libavutil/opt.h"
 #include "amfenc.h"
+#include "avcodecinternal.h"
 #include "codec_internal.h"
-#include "internal.h"
 #include <AMF/components/PreAnalysis.h>
 
 #define OFFSET(x) offsetof(AmfContext, x)
diff --git a/libavcodec/aptxenc.c b/libavcodec/aptxenc.c
index 6deebaf2cb..1ad0bea58b 100644
--- a/libavcodec/aptxenc.c
+++ b/libavcodec/aptxenc.c
@@ -25,9 +25,9 @@ 
 #include "libavutil/channel_layout.h"
 #include "aptx.h"
 #include "audio_frame_queue.h"
+#include "avcodecinternal.h"
 #include "codec_internal.h"
 #include "encode.h"
-#include "internal.h"
 
 typedef struct AptXEncContext {
     AptXContext common;
diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c
index 1ccfda4d20..f06b4b8143 100644
--- a/libavcodec/audiotoolboxenc.c
+++ b/libavcodec/audiotoolboxenc.c
@@ -28,10 +28,10 @@ 
 #include "config.h"
 #include "audio_frame_queue.h"
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "bytestream.h"
 #include "codec_internal.h"
 #include "encode.h"
-#include "internal.h"
 #include "libavformat/isom.h"
 #include "libavutil/avassert.h"
 #include "libavutil/channel_layout.h"
diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index e7f98a6c81..3452aded47 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -26,6 +26,7 @@ 
 #include "libavutil/pixdesc.h"
 #include "libavutil/opt.h"
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "av1_parse.h"
 #include "decode.h"
 #include "av1dec.h"
@@ -33,7 +34,6 @@ 
 #include "bytestream.h"
 #include "codec_internal.h"
 #include "decode.h"
-#include "internal.h"
 #include "hwconfig.h"
 #include "profiles.h"
 #include "thread.h"
diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index 8ccc610227..174715b0ed 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -28,17 +28,16 @@ 
 #include "libavutil/avstring.h"
 #include "libavutil/bprint.h"
 #include "libavutil/channel_layout.h"
-#include "libavutil/fifo.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/mem.h"
 #include "libavutil/opt.h"
 #include "libavutil/thread.h"
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "avcodec_internal.h"
 #include "bsf.h"
 #include "codec_internal.h"
 #include "decode.h"
-#include "encode.h"
 #include "frame_thread_encoder.h"
 #include "hwconfig.h"
 #include "internal.h"
diff --git a/libavcodec/avcodecinternal.h b/libavcodec/avcodecinternal.h
new file mode 100644
index 0000000000..6a708e9462
--- /dev/null
+++ b/libavcodec/avcodecinternal.h
@@ -0,0 +1,139 @@ 
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Header containing AVCodecInternal, to be included by codecs
+ * and internal APIs for codecs needing to access it.
+ */
+
+#ifndef AVCODEC_AVCODECINTERNAL_H
+#define AVCODEC_AVCODECINTERNAL_H
+
+#include <stdint.h>
+
+#include "config.h"
+
+#include "libavutil/buffer.h"
+#include "libavutil/channel_layout.h"
+#include "libavutil/frame.h"
+#include "packet.h"
+
+#if CONFIG_LCMS2
+# include "fflcms2.h"
+#endif
+
+typedef struct AVCodecInternal {
+    /**
+     * When using frame-threaded decoding, this field is set for the first
+     * worker thread (e.g. to decode extradata just once).
+     */
+    int is_copy;
+
+    /**
+     * Audio encoders can set this flag during init to indicate that they
+     * want the small last frame to be padded to a multiple of pad_samples.
+     */
+    int pad_samples;
+
+    AVBufferRef *pool;
+
+    void *thread_ctx;
+
+    /**
+     * This packet is used to hold the packet given to decoders
+     * implementing the .decode API; it is unused by the generic
+     * code for decoders implementing the .receive_frame API and
+     * may be freely used (but not freed) by them with the caveat
+     * that the packet will be unreferenced generically in
+     * avcodec_flush_buffers().
+     */
+    AVPacket *in_pkt;
+    struct AVBSFContext *bsf;
+
+    /**
+     * Properties (timestamps+side data) extracted from the last packet passed
+     * for decoding.
+     */
+    AVPacket *last_pkt_props;
+
+    /**
+     * temporary buffer used for encoders to store their bitstream
+     */
+    uint8_t *byte_buffer;
+    unsigned int byte_buffer_size;
+
+    void *frame_thread_encoder;
+
+    /**
+     * The input frame is stored here for encoders implementing the simple
+     * encode API.
+     *
+     * Not allocated in other cases.
+     */
+    AVFrame *in_frame;
+
+    /**
+     * When the AV_CODEC_FLAG_RECON_FRAME flag is used. the encoder should store
+     * here the reconstructed frame corresponding to the last returned packet.
+     *
+     * Not allocated in other cases.
+     */
+    AVFrame *recon_frame;
+
+    /**
+     * If this is set, then FFCodec->close (if existing) needs to be called
+     * for the parent AVCodecContext.
+     */
+    int needs_close;
+
+    /**
+     * Number of audio samples to skip at the start of the next decoded frame
+     */
+    int skip_samples;
+
+    /**
+     * hwaccel-specific private data
+     */
+    void *hwaccel_priv_data;
+
+    /**
+     * checks API usage: after codec draining, flush is required to resume operation
+     */
+    int draining;
+
+    /**
+     * Temporary buffers for newly received or not yet output packets/frames.
+     */
+    AVPacket *buffer_pkt;
+    AVFrame *buffer_frame;
+    int draining_done;
+
+    /* used when avctx flag AV_CODEC_FLAG_DROPCHANGED is set */
+    int changed_frames_dropped;
+    int initial_format;
+    int initial_width, initial_height;
+    int initial_sample_rate;
+    AVChannelLayout initial_ch_layout;
+
+#if CONFIG_LCMS2
+    FFIccContext icc; /* used to read and write embedded ICC profiles */
+#endif
+} AVCodecInternal;
+
+#endif /* AVCODEC_AVCODECINTERNAL_H */
diff --git a/libavcodec/binkaudio.c b/libavcodec/binkaudio.c
index 265f93a822..bb42ec1a9f 100644
--- a/libavcodec/binkaudio.c
+++ b/libavcodec/binkaudio.c
@@ -37,10 +37,10 @@ 
 
 #define BITSTREAM_READER_LE
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "decode.h"
 #include "get_bits.h"
 #include "codec_internal.h"
-#include "internal.h"
 #include "wma_freqs.h"
 
 #define MAX_DCT_CHANNELS 6
diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
index 42d7dcc3f6..28711d868a 100644
--- a/libavcodec/cfhd.c
+++ b/libavcodec/cfhd.c
@@ -24,17 +24,16 @@ 
  */
 
 #include "libavutil/attributes.h"
-#include "libavutil/buffer.h"
 #include "libavutil/common.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/pixdesc.h"
 
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "bytestream.h"
 #include "codec_internal.h"
 #include "decode.h"
 #include "get_bits.h"
-#include "internal.h"
 #include "thread.h"
 #include "cfhd.h"
 
diff --git a/libavcodec/cngdec.c b/libavcodec/cngdec.c
index 5cf5dc9bcf..bae3b19357 100644
--- a/libavcodec/cngdec.c
+++ b/libavcodec/cngdec.c
@@ -23,12 +23,11 @@ 
 
 #include "libavutil/common.h"
 #include "libavutil/ffmath.h"
-#include "libavutil/intreadwrite.h"
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "celp_filters.h"
 #include "codec_internal.h"
 #include "decode.h"
-#include "internal.h"
 #include "libavutil/lfg.h"
 
 typedef struct CNGContext {
diff --git a/libavcodec/crystalhd.c b/libavcodec/crystalhd.c
index 86f6cfa6c1..b5d1833f2f 100644
--- a/libavcodec/crystalhd.c
+++ b/libavcodec/crystalhd.c
@@ -57,9 +57,9 @@ 
 #include <libcrystalhd/libcrystalhd_if.h>
 
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "codec_internal.h"
 #include "decode.h"
-#include "internal.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/opt.h"
diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
index 814bc53f70..d1773cd54a 100644
--- a/libavcodec/cuviddec.c
+++ b/libavcodec/cuviddec.c
@@ -34,12 +34,12 @@ 
 #include "libavutil/pixdesc.h"
 
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "bsf.h"
 #include "codec_internal.h"
 #include "decode.h"
 #include "hwconfig.h"
 #include "nvdec.h"
-#include "internal.h"
 
 #if !NVDECAPI_CHECK_VERSION(9, 0)
 #define cudaVideoSurfaceFormat_YUV444 2
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index a47abeca06..0e1be092f8 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -28,19 +28,15 @@ 
 #endif
 
 #include "libavutil/avassert.h"
-#include "libavutil/avstring.h"
-#include "libavutil/bprint.h"
 #include "libavutil/channel_layout.h"
 #include "libavutil/common.h"
-#include "libavutil/fifo.h"
 #include "libavutil/frame.h"
 #include "libavutil/hwcontext.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
-#include "libavutil/intmath.h"
-#include "libavutil/opt.h"
 
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "avcodec_internal.h"
 #include "bytestream.h"
 #include "bsf.h"
diff --git a/libavcodec/dxva2_internal.h b/libavcodec/dxva2_internal.h
index b822af59cd..d83b0064cc 100644
--- a/libavcodec/dxva2_internal.h
+++ b/libavcodec/dxva2_internal.h
@@ -51,7 +51,7 @@ 
 #include "libavutil/hwcontext.h"
 
 #include "avcodec.h"
-#include "internal.h"
+#include "avcodecinternal.h"
 
 typedef void DECODER_BUFFER_DESC;
 
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 58eab5b001..0f93bc4a16 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -27,11 +27,11 @@ 
 #include "libavutil/samplefmt.h"
 
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "avcodec_internal.h"
 #include "codec_internal.h"
 #include "encode.h"
 #include "frame_thread_encoder.h"
-#include "internal.h"
 
 typedef struct EncodeContext {
     AVCodecInternal avci;
diff --git a/libavcodec/frame_thread_encoder.c b/libavcodec/frame_thread_encoder.c
index 62d9580ad4..f6ba995df1 100644
--- a/libavcodec/frame_thread_encoder.c
+++ b/libavcodec/frame_thread_encoder.c
@@ -27,8 +27,8 @@ 
 #include "libavutil/opt.h"
 #include "libavutil/thread.h"
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "encode.h"
-#include "internal.h"
 #include "pthread_internal.h"
 
 #define MAX_THREADS 64
diff --git a/libavcodec/get_buffer.c b/libavcodec/get_buffer.c
index a04fd878de..dc07e01c20 100644
--- a/libavcodec/get_buffer.c
+++ b/libavcodec/get_buffer.c
@@ -31,6 +31,7 @@ 
 #include "libavutil/version.h"
 
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "internal.h"
 
 typedef struct FramePool {
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index 19f8dba131..27d3cb06f2 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -35,6 +35,7 @@ 
 #include "libavutil/thread.h"
 #include "libavutil/video_enc_params.h"
 
+#include "avcodecinternal.h"
 #include "codec_internal.h"
 #include "internal.h"
 #include "error_resilience.h"
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index fcf19b4eb6..4bf53c18a8 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -37,6 +37,7 @@ 
 #include "libavutil/pixdesc.h"
 #include "libavutil/timecode.h"
 
+#include "avcodecinternal.h"
 #include "bswapdsp.h"
 #include "bytestream.h"
 #include "cabac_functions.h"
@@ -48,7 +49,6 @@ 
 #include "hevc_parse.h"
 #include "hevcdec.h"
 #include "hwconfig.h"
-#include "internal.h"
 #include "profiles.h"
 #include "thread.h"
 #include "threadframe.h"
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 868dd46b48..8f4cc7ded7 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -26,17 +26,11 @@ 
 
 #include <stdint.h>
 
-#include "libavutil/buffer.h"
-#include "libavutil/channel_layout.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/pixfmt.h"
 #include "avcodec.h"
 #include "config.h"
 
-#if CONFIG_LCMS2
-# include "fflcms2.h"
-#endif
-
 #define FF_SANE_NB_CHANNELS 512U
 
 #if HAVE_SIMD_ALIGN_64
@@ -49,104 +43,6 @@ 
 #   define STRIDE_ALIGN 8
 #endif
 
-typedef struct AVCodecInternal {
-    /**
-     * When using frame-threaded decoding, this field is set for the first
-     * worker thread (e.g. to decode extradata just once).
-     */
-    int is_copy;
-
-    /**
-     * Audio encoders can set this flag during init to indicate that they
-     * want the small last frame to be padded to a multiple of pad_samples.
-     */
-    int pad_samples;
-
-    AVBufferRef *pool;
-
-    void *thread_ctx;
-
-    /**
-     * This packet is used to hold the packet given to decoders
-     * implementing the .decode API; it is unused by the generic
-     * code for decoders implementing the .receive_frame API and
-     * may be freely used (but not freed) by them with the caveat
-     * that the packet will be unreferenced generically in
-     * avcodec_flush_buffers().
-     */
-    AVPacket *in_pkt;
-    struct AVBSFContext *bsf;
-
-    /**
-     * Properties (timestamps+side data) extracted from the last packet passed
-     * for decoding.
-     */
-    AVPacket *last_pkt_props;
-
-    /**
-     * temporary buffer used for encoders to store their bitstream
-     */
-    uint8_t *byte_buffer;
-    unsigned int byte_buffer_size;
-
-    void *frame_thread_encoder;
-
-    /**
-     * The input frame is stored here for encoders implementing the simple
-     * encode API.
-     *
-     * Not allocated in other cases.
-     */
-    AVFrame *in_frame;
-
-    /**
-     * When the AV_CODEC_FLAG_RECON_FRAME flag is used. the encoder should store
-     * here the reconstructed frame corresponding to the last returned packet.
-     *
-     * Not allocated in other cases.
-     */
-    AVFrame *recon_frame;
-
-    /**
-     * If this is set, then FFCodec->close (if existing) needs to be called
-     * for the parent AVCodecContext.
-     */
-    int needs_close;
-
-    /**
-     * Number of audio samples to skip at the start of the next decoded frame
-     */
-    int skip_samples;
-
-    /**
-     * hwaccel-specific private data
-     */
-    void *hwaccel_priv_data;
-
-    /**
-     * checks API usage: after codec draining, flush is required to resume operation
-     */
-    int draining;
-
-    /**
-     * Temporary buffers for newly received or not yet output packets/frames.
-     */
-    AVPacket *buffer_pkt;
-    AVFrame *buffer_frame;
-    int draining_done;
-
-    /* used when avctx flag AV_CODEC_FLAG_DROPCHANGED is set */
-    int changed_frames_dropped;
-    int initial_format;
-    int initial_width, initial_height;
-    int initial_sample_rate;
-    AVChannelLayout initial_ch_layout;
-
-#if CONFIG_LCMS2
-    FFIccContext icc; /* used to read and write embedded ICC profiles */
-#endif
-} AVCodecInternal;
-
 /**
  * Return the index into tab at which {a,b} match elements {[0],[1]} of tab.
  * If there is no such matching pair then size is returned.
diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index 16747e7e92..a8f160f198 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -40,6 +40,7 @@ 
 
 #include "av1.h"
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "bsf.h"
 #include "codec_internal.h"
 #include "encode.h"
diff --git a/libavcodec/libaribcaption.c b/libavcodec/libaribcaption.c
index 747ca8a2e4..072722bf78 100644
--- a/libavcodec/libaribcaption.c
+++ b/libavcodec/libaribcaption.c
@@ -20,8 +20,8 @@ 
  */
 
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "codec_internal.h"
-#include "internal.h"
 #include "libavcodec/ass.h"
 #include "libavutil/avstring.h"
 #include "libavutil/avutil.h"
diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c
index c263157a2a..7deb256ba3 100644
--- a/libavcodec/libdav1d.c
+++ b/libavcodec/libdav1d.c
@@ -32,10 +32,10 @@ 
 #include "atsc_a53.h"
 #include "av1_parse.h"
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "bytestream.h"
 #include "codec_internal.h"
 #include "decode.h"
-#include "internal.h"
 
 #define FF_DAV1D_VERSION_AT_LEAST(x,y) \
     (DAV1D_API_VERSION_MAJOR > (x) || DAV1D_API_VERSION_MAJOR == (x) && DAV1D_API_VERSION_MINOR >= (y))
diff --git a/libavcodec/libjxldec.c b/libavcodec/libjxldec.c
index e45ac02c07..70f7734d41 100644
--- a/libavcodec/libjxldec.c
+++ b/libavcodec/libjxldec.c
@@ -35,9 +35,9 @@ 
 #include "libavutil/frame.h"
 
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "codec_internal.h"
 #include "decode.h"
-#include "internal.h"
 
 #include <jxl/decode.h>
 #include <jxl/thread_parallel_runner.h>
diff --git a/libavcodec/libopusdec.c b/libavcodec/libopusdec.c
index 9b9a610343..9fae4c1190 100644
--- a/libavcodec/libopusdec.c
+++ b/libavcodec/libopusdec.c
@@ -28,9 +28,9 @@ 
 #include "libavutil/opt.h"
 
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "codec_internal.h"
 #include "decode.h"
-#include "internal.h"
 #include "mathops.h"
 #include "libopus.h"
 #include "vorbis_data.h"
diff --git a/libavcodec/librav1e.c b/libavcodec/librav1e.c
index 56539435a7..4cb316e722 100644
--- a/libavcodec/librav1e.c
+++ b/libavcodec/librav1e.c
@@ -31,9 +31,9 @@ 
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "codec_internal.h"
 #include "encode.h"
-#include "internal.h"
 
 typedef struct librav1eContext {
     const AVClass *class;
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 5736f1efa7..97efe772e8 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -31,6 +31,7 @@ 
 #include "libavutil/time.h"
 #include "libavutil/intreadwrite.h"
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "codec_internal.h"
 #include "encode.h"
 #include "internal.h"
diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c
index 21464900d1..1ca2693425 100644
--- a/libavcodec/mediacodecdec.c
+++ b/libavcodec/mediacodecdec.c
@@ -33,13 +33,13 @@ 
 #include "libavutil/internal.h"
 
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "codec_internal.h"
 #include "decode.h"
 #include "h264_parse.h"
 #include "h264_ps.h"
 #include "hevc_parse.h"
 #include "hwconfig.h"
-#include "internal.h"
 #include "jni.h"
 #include "mediacodec_wrapper.h"
 #include "mediacodecdec_common.h"
diff --git a/libavcodec/mfenc.c b/libavcodec/mfenc.c
index 8d950a3109..3f2ab36800 100644
--- a/libavcodec/mfenc.c
+++ b/libavcodec/mfenc.c
@@ -22,13 +22,13 @@ 
 #define _WIN32_WINNT 0x0602
 #endif
 
+#include "avcodecinternal.h"
 #include "encode.h"
 #include "mf_utils.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/opt.h"
 #include "libavutil/time.h"
 #include "codec_internal.h"
-#include "internal.h"
 #include "compat/w32dlfcn.h"
 
 typedef struct MFContext {
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index ab7fa73819..272200a721 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -37,20 +37,19 @@ 
 #include "libavutil/avassert.h"
 #include "libavutil/opt.h"
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "blockdsp.h"
 #include "codec_internal.h"
 #include "copy_block.h"
 #include "decode.h"
 #include "hwconfig.h"
 #include "idctdsp.h"
-#include "internal.h"
 #include "jpegtables.h"
 #include "mjpeg.h"
 #include "mjpegdec.h"
 #include "jpeglsdec.h"
 #include "profiles.h"
 #include "put_bits.h"
-#include "tiff.h"
 #include "exif.h"
 #include "bytestream.h"
 #include "tiff_common.h"
diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c
index 9bfb6778b6..ccd699c693 100644
--- a/libavcodec/mmaldec.c
+++ b/libavcodec/mmaldec.c
@@ -34,10 +34,10 @@ 
 #include <stdatomic.h>
 
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "codec_internal.h"
 #include "decode.h"
 #include "hwconfig.h"
-#include "internal.h"
 #include "libavutil/avassert.h"
 #include "libavutil/buffer.h"
 #include "libavutil/common.h"
diff --git a/libavcodec/mpegpicture.c b/libavcodec/mpegpicture.c
index 71c7a3fd70..d1ccb8def5 100644
--- a/libavcodec/mpegpicture.c
+++ b/libavcodec/mpegpicture.c
@@ -27,7 +27,6 @@ 
 
 #include "avcodec.h"
 #include "encode.h"
-#include "internal.h"
 #include "decode.h"
 #include "motion_est.h"
 #include "mpegpicture.h"
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 9bdf5dbe07..79f03684c0 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -43,6 +43,7 @@ 
 #include "libavutil/opt.h"
 #include "libavutil/thread.h"
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "dct.h"
 #include "encode.h"
 #include "idctdsp.h"
diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c
index a477449d14..a3d6fbbae3 100644
--- a/libavcodec/nvdec.c
+++ b/libavcodec/nvdec.c
@@ -32,9 +32,9 @@ 
 #include "libavutil/pixfmt.h"
 
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "decode.h"
 #include "nvdec.h"
-#include "internal.h"
 
 #if !NVDECAPI_CHECK_VERSION(9, 0)
 #define cudaVideoSurfaceFormat_YUV444 2
diff --git a/libavcodec/nvdec_av1.c b/libavcodec/nvdec_av1.c
index 3bbcd76123..61eff285a4 100644
--- a/libavcodec/nvdec_av1.c
+++ b/libavcodec/nvdec_av1.c
@@ -21,9 +21,9 @@ 
  */
 
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "nvdec.h"
 #include "decode.h"
-#include "internal.h"
 #include "av1dec.h"
 
 
diff --git a/libavcodec/nvdec_h264.c b/libavcodec/nvdec_h264.c
index 116bd4fb5d..1ffae3790e 100644
--- a/libavcodec/nvdec_h264.c
+++ b/libavcodec/nvdec_h264.c
@@ -24,9 +24,9 @@ 
 #include <string.h>
 
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "nvdec.h"
 #include "decode.h"
-#include "internal.h"
 #include "h264dec.h"
 
 static void dpb_add(const H264Context *h, CUVIDH264DPBENTRY *dst, const H264Picture *src,
diff --git a/libavcodec/nvdec_hevc.c b/libavcodec/nvdec_hevc.c
index cd549d2ef6..d1e33933ab 100644
--- a/libavcodec/nvdec_hevc.c
+++ b/libavcodec/nvdec_hevc.c
@@ -24,9 +24,9 @@ 
 #include <string.h>
 
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "nvdec.h"
 #include "decode.h"
-#include "internal.h"
 #include "hevcdec.h"
 #include "hevc_data.h"
 
diff --git a/libavcodec/nvdec_mjpeg.c b/libavcodec/nvdec_mjpeg.c
index fce464c1f8..ad3813d7e2 100644
--- a/libavcodec/nvdec_mjpeg.c
+++ b/libavcodec/nvdec_mjpeg.c
@@ -21,7 +21,7 @@ 
  */
 
 #include "avcodec.h"
-#include "internal.h"
+#include "avcodecinternal.h"
 #include "mjpegdec.h"
 #include "nvdec.h"
 #include "decode.h"
diff --git a/libavcodec/nvdec_mpeg12.c b/libavcodec/nvdec_mpeg12.c
index 3b9ff60734..dc1f4497a8 100644
--- a/libavcodec/nvdec_mpeg12.c
+++ b/libavcodec/nvdec_mpeg12.c
@@ -23,7 +23,7 @@ 
 #include "config_components.h"
 
 #include "avcodec.h"
-#include "internal.h"
+#include "avcodecinternal.h"
 #include "mpegvideo.h"
 #include "nvdec.h"
 #include "decode.h"
diff --git a/libavcodec/nvdec_mpeg4.c b/libavcodec/nvdec_mpeg4.c
index c193f6b6e4..9652bffff5 100644
--- a/libavcodec/nvdec_mpeg4.c
+++ b/libavcodec/nvdec_mpeg4.c
@@ -21,7 +21,7 @@ 
  */
 
 #include "avcodec.h"
-#include "internal.h"
+#include "avcodecinternal.h"
 #include "mpeg4videodec.h"
 #include "mpeg4videodefs.h"
 #include "nvdec.h"
diff --git a/libavcodec/nvdec_vc1.c b/libavcodec/nvdec_vc1.c
index fae1cb0ab2..a806a51d5c 100644
--- a/libavcodec/nvdec_vc1.c
+++ b/libavcodec/nvdec_vc1.c
@@ -23,7 +23,7 @@ 
 #include "config_components.h"
 
 #include "avcodec.h"
-#include "internal.h"
+#include "avcodecinternal.h"
 #include "nvdec.h"
 #include "decode.h"
 #include "vc1.h"
diff --git a/libavcodec/nvdec_vp8.c b/libavcodec/nvdec_vp8.c
index f174ca430f..0dc5236479 100644
--- a/libavcodec/nvdec_vp8.c
+++ b/libavcodec/nvdec_vp8.c
@@ -21,9 +21,9 @@ 
  */
 
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "nvdec.h"
 #include "decode.h"
-#include "internal.h"
 #include "vp8.h"
 
 static unsigned char safe_get_ref_idx(VP8Frame *frame)
diff --git a/libavcodec/nvdec_vp9.c b/libavcodec/nvdec_vp9.c
index a76bcf9943..3518babf6f 100644
--- a/libavcodec/nvdec_vp9.c
+++ b/libavcodec/nvdec_vp9.c
@@ -23,9 +23,9 @@ 
 #include "libavutil/pixdesc.h"
 
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "nvdec.h"
 #include "decode.h"
-#include "internal.h"
 #include "vp9shared.h"
 
 static int nvdec_vp9_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
diff --git a/libavcodec/opus_parse.c b/libavcodec/opus_parse.c
index e922d1f304..3929c07aef 100644
--- a/libavcodec/opus_parse.c
+++ b/libavcodec/opus_parse.c
@@ -32,7 +32,7 @@ 
 #include "libavutil/mem.h"
 
 #include "avcodec.h"
-#include "internal.h"
+#include "avcodecinternal.h"
 #include "mathops.h"
 #include "opus.h"
 #include "opus_parse.h"
diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index bc305f561f..491e4ee583 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -28,11 +28,11 @@ 
 #include <stdint.h>
 
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "avcodec_internal.h"
 #include "codec_internal.h"
 #include "decode.h"
 #include "hwconfig.h"
-#include "internal.h"
 #include "pthread_internal.h"
 #include "thread.h"
 #include "threadframe.h"
diff --git a/libavcodec/pthread_slice.c b/libavcodec/pthread_slice.c
index a4d31c6f4d..04b1f5be01 100644
--- a/libavcodec/pthread_slice.c
+++ b/libavcodec/pthread_slice.c
@@ -22,15 +22,12 @@ 
  * @see doc/multithreading.txt
  */
 
-#include "config.h"
-
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "codec_internal.h"
-#include "internal.h"
 #include "pthread_internal.h"
 #include "thread.h"
 
-#include "libavutil/avassert.h"
 #include "libavutil/common.h"
 #include "libavutil/cpu.h"
 #include "libavutil/mem.h"
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index da700f25e9..229bee1831 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -44,8 +44,8 @@ 
 #include "libavutil/mastering_display_metadata.h"
 
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "codec_internal.h"
-#include "internal.h"
 #include "decode.h"
 #include "hwconfig.h"
 #include "qsv.h"
diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c
index 8e9358f95d..dc89ac1dbf 100644
--- a/libavcodec/rawdec.c
+++ b/libavcodec/rawdec.c
@@ -25,11 +25,11 @@ 
  */
 
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "bswapdsp.h"
 #include "codec_internal.h"
 #include "decode.h"
 #include "get_bits.h"
-#include "internal.h"
 #include "raw.h"
 #include "libavutil/avassert.h"
 #include "libavutil/buffer.h"
diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c
index 1360343aec..6da507d515 100644
--- a/libavcodec/snowenc.c
+++ b/libavcodec/snowenc.c
@@ -24,9 +24,9 @@ 
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "codec_internal.h"
 #include "encode.h"
-#include "internal.h" //For AVCodecInternal.recon_frame
 #include "me_cmp.h"
 #include "packet_internal.h"
 #include "snow_dwt.h"
diff --git a/libavcodec/v210_template.c b/libavcodec/v210_template.c
index 9f40bfe97c..28bc5cddfb 100644
--- a/libavcodec/v210_template.c
+++ b/libavcodec/v210_template.c
@@ -20,7 +20,6 @@ 
  */
 
 #include "bytestream.h"
-#include "internal.h"
 
 static void RENAME(v210_enc)(AVCodecContext *avctx,
         uint8_t *dst, const AVFrame *pic)
diff --git a/libavcodec/vaapi_av1.c b/libavcodec/vaapi_av1.c
index d0339b2705..6b4dd1c0db 100644
--- a/libavcodec/vaapi_av1.c
+++ b/libavcodec/vaapi_av1.c
@@ -20,9 +20,9 @@ 
 
 #include "libavutil/frame.h"
 #include "libavutil/pixdesc.h"
+#include "avcodecinternal.h"
 #include "hwconfig.h"
 #include "vaapi_decode.h"
-#include "internal.h"
 #include "av1dec.h"
 #include "thread.h"
 
diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
index dd55cbd6f1..bcca155535 100644
--- a/libavcodec/vaapi_decode.c
+++ b/libavcodec/vaapi_decode.c
@@ -23,8 +23,8 @@ 
 #include "libavutil/pixdesc.h"
 
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "decode.h"
-#include "internal.h"
 #include "vaapi_decode.h"
 #include "vaapi_hevc.h"
 
diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c
index 0bb793c010..bdee8d07dc 100644
--- a/libavcodec/vdpau.c
+++ b/libavcodec/vdpau.c
@@ -26,8 +26,8 @@ 
 #include <limits.h>
 
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "decode.h"
-#include "internal.h"
 #include "mpegvideodec.h"
 #include "vc1.h"
 #include "vdpau.h"
diff --git a/libavcodec/vdpau_av1.c b/libavcodec/vdpau_av1.c
index 3c3c8e61d1..caeafb1b58 100644
--- a/libavcodec/vdpau_av1.c
+++ b/libavcodec/vdpau_av1.c
@@ -23,7 +23,7 @@ 
 #include <vdpau/vdpau.h>
 #include "libavutil/pixdesc.h"
 #include "avcodec.h"
-#include "internal.h"
+#include "avcodecinternal.h"
 #include "av1dec.h"
 #include "hwconfig.h"
 #include "vdpau.h"
diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
index 6444325591..b11eb6ac6f 100644
--- a/libavcodec/videotoolbox.c
+++ b/libavcodec/videotoolbox.c
@@ -28,9 +28,9 @@ 
 #include "libavutil/avutil.h"
 #include "libavutil/hwcontext.h"
 #include "libavutil/pixdesc.h"
+#include "avcodecinternal.h"
 #include "bytestream.h"
 #include "decode.h"
-#include "internal.h"
 #include "h264dec.h"
 #include "hevcdec.h"
 #include "mpegvideo.h"
diff --git a/libavcodec/videotoolbox_vp9.c b/libavcodec/videotoolbox_vp9.c
index a998f36d1a..085139590a 100644
--- a/libavcodec/videotoolbox_vp9.c
+++ b/libavcodec/videotoolbox_vp9.c
@@ -21,6 +21,7 @@ 
  */
 
 #include "config.h"
+#include "avcodecinternal.h"
 #include "videotoolbox.h"
 #include "libavutil/hwcontext_videotoolbox.h"
 #include "vt_internal.h"
@@ -31,7 +32,6 @@ 
 #include "libavutil/intreadwrite.h"
 #include "libavutil/pixdesc.h"
 #include "decode.h"
-#include "internal.h"
 #include "vp9shared.h"
 
 enum VPX_CHROMA_SUBSAMPLING
diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index 6114351392..83074fe7fa 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -24,6 +24,7 @@ 
 #include <TargetConditionals.h>
 #include <Availability.h>
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "libavutil/opt.h"
 #include "libavutil/avassert.h"
 #include "libavutil/avstring.h"
@@ -31,7 +32,6 @@ 
 #include "libavutil/pixdesc.h"
 #include "libavutil/hwcontext_videotoolbox.h"
 #include "codec_internal.h"
-#include "internal.h"
 #include <pthread.h>
 #include "atsc_a53.h"
 #include "encode.h"
diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c
index 1d2a099760..b5c7dc7a93 100644
--- a/libavcodec/vorbisdec.c
+++ b/libavcodec/vorbisdec.c
@@ -35,10 +35,10 @@ 
 
 #define BITSTREAM_READER_LE
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "codec_internal.h"
 #include "decode.h"
 #include "get_bits.h"
-#include "internal.h"
 #include "vorbis.h"
 #include "vorbisdsp.h"
 #include "vorbis_data.h"
diff --git a/libavcodec/vulkan_decode.h b/libavcodec/vulkan_decode.h
index 4e45cbde71..e7310ab2ba 100644
--- a/libavcodec/vulkan_decode.h
+++ b/libavcodec/vulkan_decode.h
@@ -19,9 +19,9 @@ 
 #ifndef AVCODEC_VULKAN_DECODE_H
 #define AVCODEC_VULKAN_DECODE_H
 
+#include "avcodecinternal.h"
 #include "decode.h"
 #include "hwconfig.h"
-#include "internal.h"
 
 #include "vulkan_video.h"
 
diff --git a/libavcodec/wmadec.c b/libavcodec/wmadec.c
index bc18d18222..ac19d75e58 100644
--- a/libavcodec/wmadec.c
+++ b/libavcodec/wmadec.c
@@ -39,9 +39,9 @@ 
 #include "libavutil/ffmath.h"
 
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "codec_internal.h"
 #include "decode.h"
-#include "internal.h"
 #include "wma.h"
 
 #define EXPVLCBITS 8
diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c
index f523f3637f..8b943d5ef8 100644
--- a/libavcodec/wmaprodec.c
+++ b/libavcodec/wmaprodec.c
@@ -98,10 +98,10 @@ 
 #include "libavutil/thread.h"
 
 #include "avcodec.h"
+#include "avcodecinternal.h"
 #include "codec_internal.h"
 #include "decode.h"
 #include "get_bits.h"
-#include "internal.h"
 #include "put_bits.h"
 #include "wmaprodata.h"
 #include "sinewin.h"