[FFmpeg-devel] [PATCH] avcodec/libx265: use x265 Multi-library Interface to query the API

Derek Buitenhuis derek.buitenhuis at gmail.com
Tue May 5 12:31:33 CEST 2015


On 5/5/2015 9:54 AM, Gopu Govindaswamy wrote:
>>From c882bbf42b0f13f98fb706139b7d3fbc53665319 Mon Sep 17 00:00:00 2001
> From: Gopu Govindaswamy <gopu at multicorewareinc.com>
> Date: Tue, 5 May 2015 12:24:44 +0530
> Subject: [PATCH] avcodec/libx265: use x265 Multi-library Interface to query
>  the API

The patch is malformed. Please use git-email.

> If Application might want to make a runtime selection between
> a number of libx265 libraries (perhaps 8bpp and 16bpp), then we want
> to use the multi-library interface,
> 
> The Application must link to one build of libx265 (statically or
> dynamically) and this linked version of libx265 will support one
> bit-depth (8 or 10 bits).

[...]

> If the application must now request the API for the bitDepth you would
> prefer the encoder to use (8 or 10). If the requested bitdepth is zero,
> or if it matches the bitdepth of the system default libx265 (the
> currently linked library), then this library will be used for encode.
> If you request a different bit-depth, the linked libx265 will attempt
> to dynamically bind a shared library with a name appropriate for the
> requested bit-depth

You should mention this is a new x265 API meant specifically for this.

> This changes enables the ffmpeg  to query an API for
> the bitdepth of the input pixels, to make a runtime selection between
> a number of libx265 libraries (perhaps 8bpp and 16bpp)

Remove this bit.

> ---
>  libavcodec/libx265.c | 33 ++++++++++++++++++++++-----------
>  1 file changed, 22 insertions(+), 11 deletions(-)

You need to update the API requirements in the check in configure.

>      x265_encoder *encoder;
>      x265_param   *params;
> +    const x265_api     *api;

Broken spacing.

> 
>      float crf;
>      char *preset;
> @@ -67,10 +68,10 @@ static av_cold int libx265_encode_close(AVCodecContext
> *avctx)
> 
>      av_frame_free(&avctx->coded_frame);
> 
> -    x265_param_free(ctx->params);
> +    ctx->api->param_free(ctx->params);
> 
>      if (ctx->encoder)
> -        x265_encoder_close(ctx->encoder);
> +        ctx->api->encoder_close(ctx->encoder);
> 
>      return 0;
>  }
> @@ -79,6 +80,16 @@ static av_cold int libx265_encode_init(AVCodecContext
> *avctx)
>  {
>      libx265Context *ctx = avctx->priv_data;
> 
> +    ctx->api = NULL;

Not needed. Private data is always zero-initialized.

> +    ctx->api =
> x265_api_get(av_pix_fmt_desc_get(avctx->pix_fmt)->comp[0].depth_minus1 + 1);
> +    if (!ctx->api)
> +        ctx->api = x265_api_get(0);
> +
> +    if (!ctx->api) {
> +        av_log(avctx, AV_LOG_ERROR, "Could not get x265 API. \n");

Extra space at end of log message.

> +        return AVERROR(ENOSYS);

I think we have AVERROR_EXTERNAL now.

Rest is probably OK.

- Derek


More information about the ffmpeg-devel mailing list