diff --git a/libavcodec/cavsdec.c b/libavcodec/cavsdec.c
index 51b88785019e3cb8be8bb15ac86c330166e84786..a455a34bd0bf421c0552dd5d4217838ccc394df4 100644
--- a/libavcodec/cavsdec.c
+++ b/libavcodec/cavsdec.c
@@ -31,7 +31,6 @@
 #include "cavs.h"
 #include "internal.h"
 #include "mpeg12data.h"
-#include "mpegvideo.h"
 
 static const uint8_t mv_scan[4] = {
     MV_FWD_X0, MV_FWD_X1,
diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c
index d4ac98d07858ada62b5ef1ebdcfb92e48b93afed..6a7dd53310a8cf6c96960e7f7d2d653fe131215a 100644
--- a/libavcodec/dxva2.c
+++ b/libavcodec/dxva2.c
@@ -27,7 +27,6 @@
 #include "libavutil/time.h"
 
 #include "avcodec.h"
-#include "mpegvideo.h"
 #include "dxva2_internal.h"
 
 void *ff_dxva2_get_surface(const AVFrame *frame)
diff --git a/libavcodec/dxva2_internal.h b/libavcodec/dxva2_internal.h
index 7155123b5d0c8f64de50a1af1a368ae43020e662..30aec8b93c7a6c30e0cca7928dcef1cf14fcf444 100644
--- a/libavcodec/dxva2_internal.h
+++ b/libavcodec/dxva2_internal.h
@@ -47,7 +47,6 @@
 #endif
 
 #include "avcodec.h"
-#include "mpegvideo.h"
 
 typedef void DECODER_BUFFER_DESC;
 
diff --git a/libavcodec/dxva2_mpeg2.c b/libavcodec/dxva2_mpeg2.c
index 99a0787be6178420845cb5726ee60ed0432d136a..62308b403eff3e31c238fac2f18dc796eae2e1ca 100644
--- a/libavcodec/dxva2_mpeg2.c
+++ b/libavcodec/dxva2_mpeg2.c
@@ -23,6 +23,7 @@
 #include "libavutil/log.h"
 #include "dxva2_internal.h"
 #include "mpegutils.h"
+#include "mpegvideo.h"
 
 #define MAX_SLICES 1024
 struct dxva2_picture_context {
diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c
index 1ab8e56964db9970437e0f648537bfaa9d5d3b8c..4b24ca6292b379a2384e71941197875f98282e80 100644
--- a/libavcodec/libxvid.c
+++ b/libavcodec/libxvid.c
@@ -25,18 +25,21 @@
  * @author Adam Thayer (krevnik@comcast.net)
  */
 
+#include <stdio.h>
+#include <string.h>
 #include <unistd.h>
 #include <xvid.h>
 
 #include "libavutil/cpu.h"
+#include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/mathematics.h"
+#include "libavutil/opt.h"
 
 #include "avcodec.h"
 #include "internal.h"
 #include "libxvid.h"
 #include "mpegutils.h"
-#include "mpegvideo.h"
 
 /**
  * Buffer management macros.
diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c
index 4e02e3c9065bfad1aec82cc4102cc8f4da592330..41dba89b7b3f8c5b268395bc8ebac94c10a2564a 100644
--- a/libavcodec/ljpegenc.c
+++ b/libavcodec/ljpegenc.c
@@ -39,7 +39,6 @@
 #include "internal.h"
 #include "jpegtables.h"
 #include "mjpegenc_common.h"
-#include "mpegvideo.h"
 #include "mjpeg.h"
 #include "mjpegenc.h"
 
diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c
index 83b83d02adb8deb5060d39ee738eb3ce54811563..39395e2ea98b0ba8a1be933c72d96182f69977b4 100644
--- a/libavcodec/mdec.c
+++ b/libavcodec/mdec.c
@@ -30,7 +30,6 @@
 #include "avcodec.h"
 #include "blockdsp.h"
 #include "idctdsp.h"
-#include "mpegvideo.h"
 #include "mpeg12.h"
 #include "thread.h"
 
diff --git a/libavcodec/vaapi.c b/libavcodec/vaapi.c
index aa907939522b45996b690b7ad9f11f15021f2e89..d00be2fc98eaa0126001a30a6d6ff737ced91337 100644
--- a/libavcodec/vaapi.c
+++ b/libavcodec/vaapi.c
@@ -22,6 +22,7 @@
  */
 
 #include "h264.h"
+#include "mpegvideo.h"
 #include "vaapi_internal.h"
 
 /**
diff --git a/libavcodec/vaapi_internal.h b/libavcodec/vaapi_internal.h
index d0fa7ae9173e2293e6a0cb2d835259cdf71a9d00..5e2a6ca63137a2e03dee979f95a5eafb54d416c2 100644
--- a/libavcodec/vaapi_internal.h
+++ b/libavcodec/vaapi_internal.h
@@ -27,7 +27,6 @@
 #include <va/va.h>
 #include "vaapi.h"
 #include "avcodec.h"
-#include "mpegvideo.h"
 
 /**
  * @addtogroup VAAPI_Decoding
diff --git a/libavcodec/vaapi_mpeg2.c b/libavcodec/vaapi_mpeg2.c
index d41a14a790cb6d22580a969fc6f7bb8d4ef96d47..7d0e205932555c0b758028f2c2ff1612d4a9b042 100644
--- a/libavcodec/vaapi_mpeg2.c
+++ b/libavcodec/vaapi_mpeg2.c
@@ -21,6 +21,7 @@
  */
 
 #include "mpegutils.h"
+#include "mpegvideo.h"
 #include "vaapi_internal.h"
 #include "internal.h"
 
diff --git a/libavcodec/vaapi_mpeg4.c b/libavcodec/vaapi_mpeg4.c
index 49d5f07e43dda65bcfcddcadeb7efafab075f984..1b9053c79b27697b257f68d4844a3d43c4bd9b2a 100644
--- a/libavcodec/vaapi_mpeg4.c
+++ b/libavcodec/vaapi_mpeg4.c
@@ -24,6 +24,7 @@
 #include "internal.h"
 #include "h263.h"
 #include "mpeg4video.h"
+#include "mpegvideo.h"
 
 /** Reconstruct bitstream intra_dc_vlc_thr */
 static int mpeg4_get_intra_dc_vlc_thr(Mpeg4DecContext *s)