[FFmpeg-devel] [PATCH] avcodec/libx264: remove support for x262 MPEG-2 encoder

Gyan Doshi ffmpeg at gyani.pro
Fri May 27 11:29:22 EEST 2022


Support for 'libx262' was added in e56f14659f by merging
Libav e1319aa1c1.

The Libav commit author believed that "x262 is a subfeature of x264"
but this is not the case. Kieran Kuhnya added support for MPEG-2
encoding in *his fork* of x264.
See https://github.com/kierank/x262/commit/6851000e27

So there are two issues:
1) Our configure enables libx262 implicitly if libx264 is enabled
and a x262 constant is defined in x264.h; this will never be fulfilled
with native x264. Users would have to build x262 and use the libx264
generated there. Which brings us to the 2nd issue.
2) Development on the x262 repo stopped in 2015. So, it's likely API
and ABI incompatible with native x264 and thus our current wrapper.

If support for x262 is desired it will have to be added as a distinct
component or by integrating the fork changes in x264.
---
 Changelog              |  1 +
 configure              |  5 +----
 libavcodec/Makefile    |  1 -
 libavcodec/allcodecs.c |  1 -
 libavcodec/libx264.c   | 34 ----------------------------------
 5 files changed, 2 insertions(+), 40 deletions(-)

diff --git a/Changelog b/Changelog
index 53130f072f..40fbaf0ff2 100644
--- a/Changelog
+++ b/Changelog
@@ -17,6 +17,7 @@ version 5.1:
 - multiply video filter
 - PGS subtitle frame merge bitstream filter
 - blurdetect filter
+- removed libx262 support
 
 
 version 5.0:
diff --git a/configure b/configure
index 5a167613a4..29cb63019b 100755
--- a/configure
+++ b/configure
@@ -2472,7 +2472,6 @@ CONFIG_EXTRA="
     ividsp
     jpegtables
     lgplv3
-    libx262
     llauddsp
     llviddsp
     llvidencdsp
@@ -3375,7 +3374,6 @@ libvpx_vp9_decoder_deps="libvpx"
 libvpx_vp9_encoder_deps="libvpx"
 libwebp_encoder_deps="libwebp"
 libwebp_anim_encoder_deps="libwebp"
-libx262_encoder_deps="libx262"
 libx264_encoder_deps="libx264"
 libx264_encoder_select="atsc_a53"
 libx264rgb_encoder_deps="libx264"
@@ -6661,8 +6659,7 @@ enabled libwebp           && {
 enabled libx264           && { check_pkg_config libx264 x264 "stdint.h x264.h" x264_encoder_encode ||
                                { require libx264 "stdint.h x264.h" x264_encoder_encode "-lx264 $pthreads_extralibs $libm_extralibs" &&
                                  warn "using libx264 without pkg-config"; } } &&
-                             require_cpp_condition libx264 x264.h "X264_BUILD >= 118" &&
-                             check_cpp_condition libx262 x264.h "X264_MPEG2"
+                             require_cpp_condition libx264 x264.h "X264_BUILD >= 118"
 enabled libx265           && require_pkg_config libx265 x265 x265.h x265_api_get &&
                              require_cpp_condition libx265 x265.h "X265_BUILD >= 70"
 enabled libxavs           && require libxavs "stdint.h xavs.h" xavs_encoder_encode "-lxavs $pthreads_extralibs $libm_extralibs"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 38425d2f22..2c6be86b1e 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1096,7 +1096,6 @@ OBJS-$(CONFIG_LIBVPX_VP9_DECODER)         += libvpxdec.o libvpx.o
 OBJS-$(CONFIG_LIBVPX_VP9_ENCODER)         += libvpxenc.o libvpx.o
 OBJS-$(CONFIG_LIBWEBP_ENCODER)            += libwebpenc_common.o libwebpenc.o
 OBJS-$(CONFIG_LIBWEBP_ANIM_ENCODER)       += libwebpenc_common.o libwebpenc_animencoder.o
-OBJS-$(CONFIG_LIBX262_ENCODER)            += libx264.o
 OBJS-$(CONFIG_LIBX264_ENCODER)            += libx264.o
 OBJS-$(CONFIG_LIBX265_ENCODER)            += libx265.o
 OBJS-$(CONFIG_LIBXAVS_ENCODER)            += libxavs.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index c47133aa18..f7320fceee 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -780,7 +780,6 @@ extern FFCodec ff_libvpx_vp9_decoder;
 /* preferred over libwebp */
 extern const FFCodec ff_libwebp_anim_encoder;
 extern const FFCodec ff_libwebp_encoder;
-extern const FFCodec ff_libx262_encoder;
 #if CONFIG_LIBX264_ENCODER
 #include <x264.h>
 #if X264_BUILD < 153
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 4ce3791ae8..ad86665d15 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -644,12 +644,6 @@ static av_cold int X264_init(AVCodecContext *avctx)
     if (avctx->global_quality > 0)
         av_log(avctx, AV_LOG_WARNING, "-qscale is ignored, -crf is recommended.\n");
 
-#if CONFIG_LIBX262_ENCODER
-    if (avctx->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
-        x4->params.b_mpeg2 = 1;
-        x264_param_default_mpeg2(&x4->params);
-    } else
-#endif
     x264_param_default(&x4->params);
 
     x4->params.b_deblocking_filter         = avctx->flags & AV_CODEC_FLAG_LOOP_FILTER;
@@ -1275,31 +1269,3 @@ const FFCodec ff_libx264rgb_encoder = {
                       ,
 };
 #endif
-
-#if CONFIG_LIBX262_ENCODER
-static const AVClass X262_class = {
-    .class_name = "libx262",
-    .item_name  = av_default_item_name,
-    .option     = options,
-    .version    = LIBAVUTIL_VERSION_INT,
-};
-
-const FFCodec ff_libx262_encoder = {
-    .p.name           = "libx262",
-    .p.long_name      = NULL_IF_CONFIG_SMALL("libx262 MPEG2VIDEO"),
-    .p.type           = AVMEDIA_TYPE_VIDEO,
-    .p.id             = AV_CODEC_ID_MPEG2VIDEO,
-    .p.capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
-                        AV_CODEC_CAP_OTHER_THREADS |
-                        AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
-    .p.pix_fmts       = pix_fmts_8bit,
-    .p.priv_class     = &X262_class,
-    .p.wrapper_name   = "libx264",
-    .priv_data_size   = sizeof(X264Context),
-    .init             = X264_init,
-    FF_CODEC_ENCODE_CB(X264_frame),
-    .close            = X264_close,
-    .defaults         = x264_defaults,
-    .caps_internal    = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_AUTO_THREADS,
-};
-#endif
-- 
2.36.1



More information about the ffmpeg-devel mailing list