Merge commit 'c6558e8840fbb2386bf8742e4d68dd6e067d262e'
authorJames Almer <jamrial@gmail.com>
Thu, 28 Dec 2017 00:09:45 +0000 (21:09 -0300)
committerJames Almer <jamrial@gmail.com>
Thu, 28 Dec 2017 00:11:10 +0000 (21:11 -0300)
* commit 'c6558e8840fbb2386bf8742e4d68dd6e067d262e':
  x264: Support version 153

See
2a111c99a60fdf4fe5eea2b073901630190c6c93
7e60c74329353db28db00552028bc88cd2a52346

Merged-by: James Almer <jamrial@gmail.com>
1  2 
libavcodec/libx264.c

@@@ -272,20 -237,22 +272,23 @@@ static int X264_frame(AVCodecContext *c
                        int *got_packet)
  {
      X264Context *x4 = ctx->priv_data;
-     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(ctx->pix_fmt);
      x264_nal_t *nal;
      int nnal, i, ret;
 -    x264_picture_t pic_out;
 +    x264_picture_t pic_out = {0};
 +    int pict_type;
  
      x264_picture_init( &x4->pic );
      x4->pic.img.i_csp   = x4->params.i_csp;
-     if (desc->comp[0].depth > 8)
+ #if X264_BUILD >= 153
+     if (x4->params.i_bitdepth > 8)
+ #else
+     if (x264_bit_depth > 8)
+ #endif
          x4->pic.img.i_csp |= X264_CSP_HIGH_DEPTH;
 -    x4->pic.img.i_plane = 3;
 +    x4->pic.img.i_plane = avfmt2_num_planes(ctx->pix_fmt);
  
      if (frame) {
 -        for (i = 0; i < 3; i++) {
 +        for (i = 0; i < x4->pic.img.i_plane; i++) {
              x4->pic.img.plane[i]    = frame->data[i];
              x4->pic.img.i_stride[i] = frame->linesize[i];
          }
@@@ -491,9 -399,10 +494,12 @@@ static av_cold int X264_init(AVCodecCon
      x4->params.p_log_private        = avctx;
      x4->params.i_log_level          = X264_LOG_DEBUG;
      x4->params.i_csp                = convert_pix_fmt(avctx->pix_fmt);
+ #if X264_BUILD >= 153
+     x4->params.i_bitdepth           = av_pix_fmt_desc_get(avctx->pix_fmt)->comp[0].depth;
+ #endif
  
 +    PARSE_X264_OPT("weightp", wpredp);
 +
      if (avctx->bit_rate) {
          x4->params.rc.i_bitrate   = avctx->bit_rate / 1000;
          x4->params.rc.i_rc_method = X264_RC_ABR;
@@@ -724,16 -571,10 +730,13 @@@ FF_ENABLE_DEPRECATION_WARNING
  
      x4->params.i_width          = avctx->width;
      x4->params.i_height         = avctx->height;
- #if X264_BUILD >= 153
-     x4->params.i_bitdepth       = av_pix_fmt_desc_get(avctx->pix_fmt)->comp[0].depth;
- #endif
 -    x4->params.vui.i_sar_width  = avctx->sample_aspect_ratio.num;
 -    x4->params.vui.i_sar_height = avctx->sample_aspect_ratio.den;
 -    x4->params.i_fps_num = x4->params.i_timebase_den = avctx->time_base.den;
 -    x4->params.i_fps_den = x4->params.i_timebase_num = avctx->time_base.num;
 +    av_reduce(&sw, &sh, avctx->sample_aspect_ratio.num, avctx->sample_aspect_ratio.den, 4096);
 +    x4->params.vui.i_sar_width  = sw;
 +    x4->params.vui.i_sar_height = sh;
 +    x4->params.i_timebase_den = avctx->time_base.den;
 +    x4->params.i_timebase_num = avctx->time_base.num;
 +    x4->params.i_fps_num = avctx->time_base.den;
 +    x4->params.i_fps_den = avctx->time_base.num * avctx->ticks_per_frame;
  
      x4->params.analyse.b_psnr = avctx->flags & AV_CODEC_FLAG_PSNR;
  
      return 0;
  }
  
- static const enum AVPixelFormat pix_fmts[] = {
 -#if X264_BUILD < 153
+ static const enum AVPixelFormat pix_fmts_8bit[] = {
      AV_PIX_FMT_YUV420P,
      AV_PIX_FMT_YUVJ420P,
      AV_PIX_FMT_YUV422P,
  #endif
      AV_PIX_FMT_NONE
  };
- static const enum AVPixelFormat pix_fmts_8bit[] = {
+ static const enum AVPixelFormat pix_fmts_9bit[] = {
+     AV_PIX_FMT_YUV420P9,
+     AV_PIX_FMT_YUV444P9,
+     AV_PIX_FMT_NONE
+ };
+ static const enum AVPixelFormat pix_fmts_10bit[] = {
+     AV_PIX_FMT_YUV420P10,
+     AV_PIX_FMT_YUV422P10,
+     AV_PIX_FMT_YUV444P10,
+     AV_PIX_FMT_NV20,
+     AV_PIX_FMT_NONE
+ };
 -#else
+ static const enum AVPixelFormat pix_fmts_all[] = {
      AV_PIX_FMT_YUV420P,
      AV_PIX_FMT_YUVJ420P,
      AV_PIX_FMT_YUV422P,
      AV_PIX_FMT_YUVJ444P,
      AV_PIX_FMT_NV12,
      AV_PIX_FMT_NV16,
 +#ifdef X264_CSP_NV21
      AV_PIX_FMT_NV21,
-     AV_PIX_FMT_NONE
- };
- static const enum AVPixelFormat pix_fmts_9bit[] = {
-     AV_PIX_FMT_YUV420P9,
-     AV_PIX_FMT_YUV444P9,
-     AV_PIX_FMT_NONE
- };
- static const enum AVPixelFormat pix_fmts_10bit[] = {
 +#endif
      AV_PIX_FMT_YUV420P10,
      AV_PIX_FMT_YUV422P10,
      AV_PIX_FMT_YUV444P10,