diff --git a/libavcodec/cavsdec.c b/libavcodec/cavsdec.c
index 692c77eb39..894aa1b54a 100644
--- a/libavcodec/cavsdec.c
+++ b/libavcodec/cavsdec.c
@@ -32,6 +32,7 @@
 #include "cavs.h"
 #include "internal.h"
 #include "mpeg12data.h"
+#include "startcode.h"
 
 static const uint8_t mv_scan[4] = {
     MV_FWD_X0, MV_FWD_X1,
diff --git a/libavcodec/cbs_mpeg2.c b/libavcodec/cbs_mpeg2.c
index 90d667ddc8..8d45d1ceeb 100644
--- a/libavcodec/cbs_mpeg2.c
+++ b/libavcodec/cbs_mpeg2.c
@@ -21,7 +21,7 @@
 #include "cbs.h"
 #include "cbs_internal.h"
 #include "cbs_mpeg2.h"
-#include "internal.h"
+#include "startcode.h"
 
 
 #define HEADER(name) do { \
diff --git a/libavcodec/extract_extradata_bsf.c b/libavcodec/extract_extradata_bsf.c
index dbcb8508b0..027a578af1 100644
--- a/libavcodec/extract_extradata_bsf.c
+++ b/libavcodec/extract_extradata_bsf.c
@@ -18,8 +18,6 @@
 
 #include <stdint.h>
 
-#include "libavutil/common.h"
-#include "libavutil/intreadwrite.h"
 #include "libavutil/log.h"
 #include "libavutil/opt.h"
 
@@ -31,6 +29,7 @@
 #include "h2645_parse.h"
 #include "h264.h"
 #include "hevc.h"
+#include "startcode.h"
 #include "vc1_common.h"
 
 typedef struct ExtractExtradataContext {
diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c
index 4002bcad77..50810f1789 100644
--- a/libavcodec/h264_parser.c
+++ b/libavcodec/h264_parser.c
@@ -27,7 +27,6 @@
 
 #define UNCHECKED_BITSTREAM_READER 1
 
-#include <assert.h>
 #include <stdint.h>
 
 #include "libavutil/avutil.h"
@@ -46,9 +45,9 @@
 #include "h264_ps.h"
 #include "h2645_parse.h"
 #include "h264data.h"
-#include "internal.h"
 #include "mpegutils.h"
 #include "parser.h"
+#include "startcode.h"
 
 typedef struct H264ParseContext {
     ParseContext pc;
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 72ca1553f6..57a1c6206f 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -285,10 +285,6 @@ int ff_thread_can_start_frame(AVCodecContext *avctx);
 
 int avpriv_h264_has_num_reorder_frames(AVCodecContext *avctx);
 
-const uint8_t *avpriv_find_start_code(const uint8_t *p,
-                                      const uint8_t *end,
-                                      uint32_t *state);
-
 int avpriv_codec_get_cap_skip_frame_fill_param(const AVCodec *codec);
 
 /**
diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
index 58e03c05d4..5520960b74 100644
--- a/libavcodec/mpeg12.c
+++ b/libavcodec/mpeg12.c
@@ -29,18 +29,14 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/avassert.h"
-#include "libavutil/timecode.h"
 #include "libavutil/thread.h"
 
-#include "internal.h"
 #include "avcodec.h"
 #include "mpegvideo.h"
-#include "error_resilience.h"
 #include "mpeg12.h"
 #include "mpeg12data.h"
 #include "mpegvideodata.h"
-#include "bytestream.h"
-#include "thread.h"
+#include "startcode.h"
 
 static const uint8_t table_mb_ptype[7][2] = {
     { 3, 5 }, // 0x01 MB_INTRA
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 4a7bd6d466..860e86aa74 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -34,14 +34,11 @@
 #include "libavutil/mem_internal.h"
 #include "libavutil/stereo3d.h"
 #include "libavutil/timecode.h"
-#include "libavutil/video_enc_params.h"
 
 #include "avcodec.h"
-#include "bytestream.h"
 #include "error_resilience.h"
 #include "hwconfig.h"
 #include "idctdsp.h"
-#include "internal.h"
 #include "mpeg_er.h"
 #include "mpeg12.h"
 #include "mpeg12data.h"
@@ -49,6 +46,7 @@
 #include "mpegvideo.h"
 #include "mpegvideodata.h"
 #include "profiles.h"
+#include "startcode.h"
 #include "thread.h"
 #include "xvmc_internal.h"
 
diff --git a/libavcodec/mpeg4_unpack_bframes_bsf.c b/libavcodec/mpeg4_unpack_bframes_bsf.c
index 6f8595713d..ae2c129d88 100644
--- a/libavcodec/mpeg4_unpack_bframes_bsf.c
+++ b/libavcodec/mpeg4_unpack_bframes_bsf.c
@@ -21,8 +21,8 @@
 
 #include "bsf.h"
 #include "bsf_internal.h"
-#include "internal.h"
 #include "mpeg4video.h"
+#include "startcode.h"
 
 typedef struct UnpackBFramesBSFContext {
     AVBufferRef *b_frame_ref;
diff --git a/libavcodec/mpegvideo_parser.c b/libavcodec/mpegvideo_parser.c
index c5dc867d24..22666c85d9 100644
--- a/libavcodec/mpegvideo_parser.c
+++ b/libavcodec/mpegvideo_parser.c
@@ -23,7 +23,7 @@
 #include "parser.h"
 #include "mpeg12.h"
 #include "mpeg12data.h"
-#include "internal.h"
+#include "startcode.h"
 
 struct MpvParseContext {
     ParseContext pc;
diff --git a/libavcodec/remove_extradata_bsf.c b/libavcodec/remove_extradata_bsf.c
index 1d5f193f89..c698d1d7f9 100644
--- a/libavcodec/remove_extradata_bsf.c
+++ b/libavcodec/remove_extradata_bsf.c
@@ -26,7 +26,7 @@
 #include "bsf_internal.h"
 #include "h264.h"
 #include "hevc.h"
-#include "internal.h"
+#include "startcode.h"
 #include "vc1_common.h"
 
 enum RemoveFreq {
diff --git a/libavcodec/startcode.h b/libavcodec/startcode.h
index cfa02b0860..8b75832aaf 100644
--- a/libavcodec/startcode.h
+++ b/libavcodec/startcode.h
@@ -27,6 +27,10 @@
 
 #include <stdint.h>
 
+const uint8_t *avpriv_find_start_code(const uint8_t *p,
+                                      const uint8_t *end,
+                                      uint32_t *state);
+
 int ff_startcode_find_candidate_c(const uint8_t *buf, int size);
 
 #endif /* AVCODEC_STARTCODE_H */
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index b19befef21..c7c7323351 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -27,7 +27,6 @@
 
 #include "config.h"
 #include "libavutil/avassert.h"
-#include "libavutil/avstring.h"
 #include "libavutil/channel_layout.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/mem.h"
@@ -40,12 +39,9 @@
 #include "thread.h"
 #include "internal.h"
 #include "put_bits.h"
-#include "raw.h"
+#include "startcode.h"
 #include <stdlib.h>
-#include <stdarg.h>
-#include <stdatomic.h>
 #include <limits.h>
-#include <float.h>
 
 void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
 {
diff --git a/libavcodec/vc1_common.h b/libavcodec/vc1_common.h
index b46c33f7e2..c0f0c8c2eb 100644
--- a/libavcodec/vc1_common.h
+++ b/libavcodec/vc1_common.h
@@ -26,7 +26,7 @@
 #include <stdint.h>
 
 #include "libavutil/attributes.h"
-#include "internal.h"
+#include "startcode.h"
 
 /** Markers used in VC-1 AP frame data */
 //@{
diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index 86f857b1e3..0f0e6846da 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -36,7 +36,7 @@
 #include "riff.h"
 #include "libavcodec/bytestream.h"
 #include "libavcodec/exif.h"
-#include "libavcodec/internal.h"
+#include "libavcodec/startcode.h"
 
 typedef struct AVIStream {
     int64_t frame_offset;   /* current frame (video) or byte (audio) counter
diff --git a/libavformat/avs2dec.c b/libavformat/avs2dec.c
index 51908d2b63..0d5b23b65e 100644
--- a/libavformat/avs2dec.c
+++ b/libavformat/avs2dec.c
@@ -22,7 +22,7 @@
 
 #include "avformat.h"
 #include "rawdec.h"
-#include "libavcodec/internal.h"
+#include "libavcodec/startcode.h"
 #include "libavutil/intreadwrite.h"
 
 #define AVS2_ISSQH(x)  ((x) == 0xB0)
diff --git a/libavformat/avs3dec.c b/libavformat/avs3dec.c
index 253caa7c1d..2395df171b 100644
--- a/libavformat/avs3dec.c
+++ b/libavformat/avs3dec.c
@@ -22,7 +22,7 @@
  */
 
 #include "libavcodec/avs3.h"
-#include "libavcodec/internal.h"
+#include "libavcodec/startcode.h"
 #include "avformat.h"
 #include "rawdec.h"
 
diff --git a/libavformat/cavsvideodec.c b/libavformat/cavsvideodec.c
index 8900b97597..1fa3aa5e92 100644
--- a/libavformat/cavsvideodec.c
+++ b/libavformat/cavsvideodec.c
@@ -19,9 +19,9 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavcodec/startcode.h"
 #include "avformat.h"
 #include "rawdec.h"
-#include "libavcodec/internal.h"
 
 #define CAVS_SEQ_START_CODE       0x000001b0
 #define CAVS_PIC_I_START_CODE     0x000001b3
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 92b4cc8087..971b3f55d8 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -28,7 +28,7 @@
 #include "libavutil/opt.h"
 
 #include "libavcodec/ac3_parser_internal.h"
-#include "libavcodec/internal.h"
+#include "libavcodec/startcode.h"
 
 #include "avformat.h"
 #include "avio_internal.h"
diff --git a/libavformat/mpegvideodec.c b/libavformat/mpegvideodec.c
index 2d6f81aaa1..33c5d79794 100644
--- a/libavformat/mpegvideodec.c
+++ b/libavformat/mpegvideodec.c
@@ -24,7 +24,7 @@
 #include "rawdec.h"
 
 #include "libavutil/intreadwrite.h"
-#include "libavcodec/internal.h"
+#include "libavcodec/startcode.h"
 
 #define SEQ_START_CODE          0x000001b3
 #define GOP_START_CODE          0x000001b8
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index 5e068c8220..1e87dc6111 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -48,12 +48,10 @@
 #include "libavutil/mastering_display_metadata.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/time_internal.h"
-#include "libavcodec/bytestream.h"
-#include "libavcodec/dv_profile.h"
-#include "libavcodec/h264_ps.h"
 #include "libavcodec/golomb.h"
-#include "libavcodec/internal.h"
+#include "libavcodec/h264.h"
 #include "libavcodec/packet_internal.h"
+#include "libavcodec/startcode.h"
 #include "avformat.h"
 #include "avio_internal.h"
 #include "internal.h"
diff --git a/libavformat/rtpenc_mpv.c b/libavformat/rtpenc_mpv.c
index 4b45f51772..c18c75082f 100644
--- a/libavformat/rtpenc_mpv.c
+++ b/libavformat/rtpenc_mpv.c
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavcodec/internal.h"
+#include "libavcodec/startcode.h"
 #include "avformat.h"
 #include "rtpenc.h"
 
