Merge commit 'e1319aa1c1be9b64117c19170344fb78841dd67c'
authorMichael Niedermayer <michael@niedermayer.cc>
Fri, 17 Jul 2015 19:21:03 +0000 (21:21 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Fri, 17 Jul 2015 19:21:03 +0000 (21:21 +0200)
* commit 'e1319aa1c1be9b64117c19170344fb78841dd67c':
  libx264: Add support for the MPEG2 encoder

Conflicts:
configure
libavcodec/Makefile
libavcodec/libx264.c

Merged-by: Michael Niedermayer <michael@niedermayer.cc>
1  2 
configure
libavcodec/Makefile
libavcodec/allcodecs.c
libavcodec/libx264.c

diff --cc configure
+++ b/configure
@@@ -1920,9 -1607,8 +1920,10 @@@ CONFIG_EXTRA=
      imdct15
      intrax8
      jpegtables
+     libx262
      lgplv3
 +    llauddsp
 +    llviddsp
      lpc
      me_cmp
      mpeg_er
@@@ -2503,10 -2109,8 +2504,11 @@@ libvpx_vp9_decoder_deps="libvpx
  libvpx_vp9_encoder_deps="libvpx"
  libwavpack_encoder_deps="libwavpack"
  libwebp_encoder_deps="libwebp"
 +libwebp_anim_encoder_deps="libwebp"
+ libx262_encoder_deps="libx262"
  libx264_encoder_deps="libx264"
 +libx264rgb_encoder_deps="libx264"
 +libx264rgb_encoder_select="libx264_encoder"
  libx265_encoder_deps="libx265"
  libxavs_encoder_deps="libxavs"
  libxvid_encoder_deps="libxvid"
@@@ -5219,16 -4349,13 +5221,18 @@@ enabled libvpx            && 
          die "libvpx enabled but no supported decoders found"
      fi
  }
 +
  enabled libwavpack        && require libwavpack wavpack/wavpack.h WavpackOpenFileOutput  -lwavpack
 -enabled libwebp           && require_pkg_config libwebp webp/encode.h WebPGetEncoderVersion
 -enabled libx264           && require_pkg_config x264 "stdint.h x264.h" x264_encoder_encode &&
 +enabled libwebp           && {
 +    enabled libwebp_encoder      && require_pkg_config "libwebp >= 0.2.0" webp/encode.h WebPGetEncoderVersion
 +    enabled libwebp_anim_encoder && { use_pkg_config "libwebpmux >= 0.4.0" webp/mux.h WebPAnimEncoderOptionsInit || disable libwebp_anim_encoder; } }
 +enabled libx264           && { use_pkg_config x264 "stdint.h x264.h" x264_encoder_encode ||
 +                               { require libx264 x264.h x264_encoder_encode -lx264 &&
 +                                 warn "using libx264 without pkg-config"; } } &&
                               { check_cpp_condition x264.h "X264_BUILD >= 118" ||
-                                die "ERROR: libx264 must be installed and version must be >= 0.118."; }
 -                               die "ERROR: libx264 version must be >= 0.118."; } &&
++                               die "ERROR: libx264 must be installed and version must be >= 0.118."; } &&
+                              { check_cpp_condition x264.h "X264_MPEG2" &&
+                                enable libx262; }
  enabled libx265           && require_pkg_config x265 x265.h x265_api_get &&
                               { check_cpp_condition x265.h "X265_BUILD >= 57" ||
                                 die "ERROR: libx265 version must be >= 57."; }
@@@ -802,8 -670,8 +802,9 @@@ OBJS-$(CONFIG_LIBVPX_VP8_ENCODER
  OBJS-$(CONFIG_LIBVPX_VP9_DECODER)         += libvpxdec.o libvpx.o
  OBJS-$(CONFIG_LIBVPX_VP9_ENCODER)         += libvpxenc.o libvpx.o
  OBJS-$(CONFIG_LIBWAVPACK_ENCODER)         += libwavpackenc.o
 -OBJS-$(CONFIG_LIBWEBP_ENCODER)            += libwebpenc.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
@@@ -548,10 -472,9 +548,11 @@@ void avcodec_register_all(void
      REGISTER_ENCDEC (LIBVPX_VP8,        libvpx_vp8);
      REGISTER_ENCDEC (LIBVPX_VP9,        libvpx_vp9);
      REGISTER_ENCODER(LIBWAVPACK,        libwavpack);
 +    REGISTER_ENCODER(LIBWEBP_ANIM,      libwebp_anim);  /* preferred over libwebp */
      REGISTER_ENCODER(LIBWEBP,           libwebp);
+     REGISTER_ENCODER(LIBX262,           libx262);
      REGISTER_ENCODER(LIBX264,           libx264);
 +    REGISTER_ENCODER(LIBX264RGB,        libx264rgb);
      REGISTER_ENCODER(LIBX265,           libx265);
      REGISTER_ENCODER(LIBXAVS,           libxavs);
      REGISTER_ENCODER(LIBXVID,           libxvid);
@@@ -379,12 -322,15 +379,19 @@@ static int convert_pix_fmt(enum AVPixel
  static av_cold int X264_init(AVCodecContext *avctx)
  {
      X264Context *x4 = avctx->priv_data;
 +    int sw,sh;
 +
 +    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
+ #else
      x264_param_default(&x4->params);
+ #endif
  
      x4->params.b_deblocking_filter         = avctx->flags & CODEC_FLAG_LOOP_FILTER;
  
@@@ -887,6 -698,14 +880,21 @@@ static const AVCodecDefault x264_defaul
      { NULL },
  };
  
 -static const AVClass class = {
+ #if CONFIG_LIBX264_ENCODER
++static const AVClass x264_class = {
+     .class_name = "libx264",
+     .item_name  = av_default_item_name,
+     .option     = options,
+     .version    = LIBAVUTIL_VERSION_INT,
+ };
++static const AVClass rgbclass = {
++    .class_name = "libx264rgb",
++    .item_name  = av_default_item_name,
++    .option     = options,
++    .version    = LIBAVUTIL_VERSION_INT,
++};
++
  AVCodec ff_libx264_encoder = {
      .name             = "libx264",
      .long_name        = NULL_IF_CONFIG_SMALL("libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"),
      .caps_internal    = FF_CODEC_CAP_INIT_THREADSAFE |
                          FF_CODEC_CAP_INIT_CLEANUP,
  };
 +
 +AVCodec ff_libx264rgb_encoder = {
 +    .name           = "libx264rgb",
 +    .long_name      = NULL_IF_CONFIG_SMALL("libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 RGB"),
 +    .type           = AVMEDIA_TYPE_VIDEO,
 +    .id             = AV_CODEC_ID_H264,
 +    .priv_data_size = sizeof(X264Context),
 +    .init           = X264_init,
 +    .encode2        = X264_frame,
 +    .close          = X264_close,
 +    .capabilities   = CODEC_CAP_DELAY | CODEC_CAP_AUTO_THREADS,
 +    .priv_class     = &rgbclass,
 +    .defaults       = x264_defaults,
 +    .pix_fmts       = pix_fmts_8bit_rgb,
 +};
+ #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,
+ };
+ AVCodec ff_libx262_encoder = {
+     .name             = "libx262",
+     .long_name        = NULL_IF_CONFIG_SMALL("libx262 MPEG2VIDEO"),
+     .type             = AVMEDIA_TYPE_VIDEO,
+     .id               = AV_CODEC_ID_MPEG2VIDEO,
+     .priv_data_size   = sizeof(X264Context),
+     .init             = X264_init,
+     .encode2          = X264_frame,
+     .close            = X264_close,
+     .capabilities     = CODEC_CAP_DELAY | CODEC_CAP_AUTO_THREADS,
+     .priv_class       = &X262_class,
+     .defaults         = x264_defaults,
+     .pix_fmts         = pix_fmts_8bit,
+     .caps_internal    = FF_CODEC_CAP_INIT_THREADSAFE |
+                         FF_CODEC_CAP_INIT_CLEANUP,
+ };
+ #endif