[libav-devel] [PATCH] x264: Support version 155

James Almer jamrial at gmail.com
Tue Dec 26 13:54:47 CET 2017


On 12/26/2017 8:33 AM, Luca Barbato wrote:
> It has native 8 and 10 bit support.
> ---
>  libavcodec/libx264.c | 30 ++++++++++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
> 
> diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
> index 0dec12edd2..6aadf33c94 100644
> --- a/libavcodec/libx264.c
> +++ b/libavcodec/libx264.c
> @@ -243,7 +243,11 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame,
>  
>      x264_picture_init( &x4->pic );
>      x4->pic.img.i_csp   = x4->params.i_csp;
> +#if X264_BUILD >= 155
> +    if (x4->params.i_bitdepth > 8)
> +#else
>      if (x264_bit_depth > 8)
> +#endif

Wouldn't using av_pix_fmt_desc_get(avctx->pix_fmt)->comp[0].depth here
as well be cleaner?

>          x4->pic.img.i_csp |= X264_CSP_HIGH_DEPTH;
>      x4->pic.img.i_plane = 3;
>  
> @@ -395,6 +399,9 @@ static av_cold int X264_init(AVCodecContext *avctx)
>      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 >= 155
> +    x4->params.i_bitdepth           = av_pix_fmt_desc_get(avctx->pix_fmt)->comp[0].depth;
> +#endif
>  
>      if (avctx->bit_rate) {
>          x4->params.rc.i_bitrate   = avctx->bit_rate / 1000;
> @@ -659,6 +666,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
>      return 0;
>  }
>  
> +#if X264_BUILD < 155
>  static const enum AVPixelFormat pix_fmts_8bit[] = {
>      AV_PIX_FMT_YUV420P,
>      AV_PIX_FMT_YUVJ420P,
> @@ -685,15 +693,37 @@ static const enum AVPixelFormat pix_fmts_10bit[] = {
>      AV_PIX_FMT_NV20,
>      AV_PIX_FMT_NONE
>  };
> +#endif
> +
> +static const enum AVPixelFormat pix_fmts_all[] = {
> +    AV_PIX_FMT_YUV420P,
> +    AV_PIX_FMT_YUVJ420P,
> +    AV_PIX_FMT_YUV422P,
> +    AV_PIX_FMT_YUVJ422P,
> +    AV_PIX_FMT_YUV444P,
> +    AV_PIX_FMT_YUVJ444P,
> +    AV_PIX_FMT_NV12,
> +    AV_PIX_FMT_NV16,
> +    AV_PIX_FMT_NV21,
> +    AV_PIX_FMT_YUV420P10,
> +    AV_PIX_FMT_YUV422P10,
> +    AV_PIX_FMT_YUV444P10,
> +    AV_PIX_FMT_NV20,
> +    AV_PIX_FMT_NONE
> +};
>  
>  static av_cold void X264_init_static(AVCodec *codec)
>  {
> +#if X264_BUILD < 155
>      if (x264_bit_depth == 8)
>          codec->pix_fmts = pix_fmts_8bit;
>      else if (x264_bit_depth == 9)
>          codec->pix_fmts = pix_fmts_9bit;
>      else if (x264_bit_depth == 10)
>          codec->pix_fmts = pix_fmts_10bit;
> +#else
> +    codec->pix_fmts = pix_fmts_all;
> +#endif

You can still build libx264 with support for only 8 and 10 bits after
this multibitdepth change, so ideally you'd still check for what's
available based on X264_BIT_DEPTH and use the new enum array if it's 0.

I have a patch doing this but was waiting for some feedback elsewhere
before sending it.


>  }
>  
>  #define OFFSET(x) offsetof(X264Context, x)
> 



More information about the libav-devel mailing list