Re: [FFmpeg-devel] [PATCH] avcodec/libx265: use x265 Multi-library Interface to query the API
On 5/11/2015 5:57 AM, Gopu Govindaswamy wrote: Thanks for review, Do i need to send a new patch or this patch itself can move into ffmpeg repo? I fixed and pushed it. I was out of the country for a few days, hence the delay. - Derek ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] avcodec/libx265: use x265 Multi-library Interface to query the API
Hello, this patch is ffmpeg can now use the x265 multi-library interface to make a run-time selection between a number of libx265 libraries (perhaps 8bpp and 16bpp). I have attached the patch with this mail, 0001-avcodec-libx265-use-x265-Multi-library-Interface-to-.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] avcodec/libx265: use x265 Multi-library Interface to query the API
From 24fc78ebee006693f235ea2fd07994f7829b367e Mon Sep 17 00:00:00 2001 From: Gopu Govindaswamy g...@multicorewareinc.com Date: Wed, 6 May 2015 12:47:21 +0530 Subject: [PATCH] avcodec/libx265: use x265 Multi-library Interface to query the API ffmpeg can now use the x265 multi-library interface to make a runtime selection between a number of libx265 libraries (perhaps 8bpp and 16bpp). ffmpeg will link to one build of libx265 (statically or dynamically) and this linked version of libx265 will support one bit-depth (8 or 10 bits). At runtime, ffmpeg now has the option to request the encoder to use a different bit depth(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 ffmpeg requests a different bit-depth, the linked libx265 will attempt to dynamically bind a shared library with the requested bit-depth from the install location (default or user-specified). new x265 API: const x265_api* api = x265_api_get(int bitDepth); x265_api - holds the libx265 public API functions bitDepth - requested API for 8bpp or 16bpp note: Use 0 to indicate native bit depth of the linked libx265 and x265_api_get(0) is guaranteed to return a non-null pointer --- configure| 4 ++-- libavcodec/libx265.c | 32 +--- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/configure b/configure index d3f23c8..7c5d13a 100755 --- a/configure +++ b/configure @@ -5111,8 +5111,8 @@ enabled libx264{ use_pkg_config x264 stdint.h x264.h x264_encode { check_cpp_condition x264.h X264_BUILD = 118 || die ERROR: libx264 must be installed and version must be = 0.118.; } enabled libx265require_pkg_config x265 x265.h x265_encoder_encode - { check_cpp_condition x265.h X265_BUILD = 17 || - die ERROR: libx265 version must be = 17.; } + { check_cpp_condition x265.h X265_BUILD = 56 || + die ERROR: libx265 version must be = 56.; } enabled libxavsrequire libxavs xavs.h xavs_encoder_encode -lxavs enabled libxvidrequire libxvid xvid.h xvid_global -lxvidcore enabled libzmq require_pkg_config libzmq zmq.h zmq_ctx_new diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c index 8924657..c055c76 100644 --- a/libavcodec/libx265.c +++ b/libavcodec/libx265.c @@ -39,6 +39,7 @@ typedef struct libx265Context { x265_encoder *encoder; x265_param *params; +const x265_api *api; 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,15 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx) { libx265Context *ctx = avctx-priv_data; +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); +return AVERROR_EXTERNAL; +} + if (avctx-strict_std_compliance FF_COMPLIANCE_EXPERIMENTAL !av_pix_fmt_desc_get(avctx-pix_fmt)-log2_chroma_w) { av_log(avctx, AV_LOG_ERROR, @@ -93,13 +103,13 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx) return AVERROR(ENOMEM); } -ctx-params = x265_param_alloc(); +ctx-params = ctx-api-param_alloc(); if (!ctx-params) { av_log(avctx, AV_LOG_ERROR, Could not allocate x265 param structure.\n); return AVERROR(ENOMEM); } -if (x265_param_default_preset(ctx-params, ctx-preset, ctx-tune) 0) { +if (ctx-api-param_default_preset(ctx-params, ctx-preset, ctx-tune) 0) { int i; av_log(avctx, AV_LOG_ERROR, Error setting preset/tune %s/%s.\n, ctx-preset, ctx-tune); @@ -148,7 +158,7 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx) avctx-sample_aspect_ratio.num, avctx-sample_aspect_ratio.den, 65535); snprintf(sar, sizeof(sar), %d:%d, sar_num, sar_den); -if (x265_param_parse(ctx-params, sar, sar) == X265_PARAM_BAD_VALUE) { +if (ctx-api-param_parse(ctx-params, sar, sar) == X265_PARAM_BAD_VALUE) { av_log(avctx, AV_LOG_ERROR, Invalid SAR: %d:%d.\n, sar_num, sar_den); return AVERROR_INVALIDDATA; } @@ -173,7 +183,7 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx) char crf[6]; snprintf(crf, sizeof(crf), %2.2f, ctx-crf); -if
[FFmpeg-devel] [PATCH] avcodec/libx265: use x265 Multi-library Interface to query the API
From c882bbf42b0f13f98fb706139b7d3fbc53665319 Mon Sep 17 00:00:00 2001 From: Gopu Govindaswamy g...@multicorewareinc.com Date: Tue, 5 May 2015 12:24:44 +0530 Subject: [PATCH] avcodec/libx265: use x265 Multi-library Interface to query the API 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 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) --- libavcodec/libx265.c | 33 ++--- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c index 8924657..a6923b1 100644 --- a/libavcodec/libx265.c +++ b/libavcodec/libx265.c @@ -39,6 +39,7 @@ typedef struct libx265Context { x265_encoder *encoder; x265_param *params; +const x265_api *api; 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; +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); +return AVERROR(ENOSYS); +} + if (avctx-strict_std_compliance FF_COMPLIANCE_EXPERIMENTAL !av_pix_fmt_desc_get(avctx-pix_fmt)-log2_chroma_w) { av_log(avctx, AV_LOG_ERROR, @@ -93,13 +104,13 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx) return AVERROR(ENOMEM); } -ctx-params = x265_param_alloc(); +ctx-params = ctx-api-param_alloc(); if (!ctx-params) { av_log(avctx, AV_LOG_ERROR, Could not allocate x265 param structure.\n); return AVERROR(ENOMEM); } -if (x265_param_default_preset(ctx-params, ctx-preset, ctx-tune) 0) { +if (ctx-api-param_default_preset(ctx-params, ctx-preset, ctx-tune) 0) { int i; av_log(avctx, AV_LOG_ERROR, Error setting preset/tune %s/%s.\n, ctx-preset, ctx-tune); @@ -148,7 +159,7 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx) avctx-sample_aspect_ratio.num, avctx-sample_aspect_ratio.den, 65535); snprintf(sar, sizeof(sar), %d:%d, sar_num, sar_den); -if (x265_param_parse(ctx-params, sar, sar) == X265_PARAM_BAD_VALUE) { +if (ctx-api-param_parse(ctx-params, sar, sar) == X265_PARAM_BAD_VALUE) { av_log(avctx, AV_LOG_ERROR, Invalid SAR: %d:%d.\n, sar_num, sar_den); return AVERROR_INVALIDDATA; } @@ -173,7 +184,7 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx) char crf[6]; snprintf(crf, sizeof(crf), %2.2f, ctx-crf); -if (x265_param_parse(ctx-params, crf, crf) == X265_PARAM_BAD_VALUE) { +if (ctx-api-param_parse(ctx-params, crf, crf) == X265_PARAM_BAD_VALUE) { av_log(avctx, AV_LOG_ERROR, Invalid crf: %2.2f.\n, ctx-crf); return AVERROR(EINVAL); } @@ -191,7 +202,7 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx) if (!av_dict_parse_string(dict, ctx-x265_opts, =, :, 0)) { while ((en = av_dict_get(dict, , en, AV_DICT_IGNORE_SUFFIX))) { -int parse_ret = x265_param_parse(ctx-params, en-key, en-value); +int parse_ret = ctx-api-param_parse(ctx-params, en-key, en-value); switch (parse_ret) { case X265_PARAM_BAD_NAME: @@ -210,7 +221,7 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx) } } -ctx-encoder = x265_encoder_open(ctx-params); +ctx-encoder = ctx-api-encoder_open(ctx-params); if (!ctx-encoder) { av_log(avctx, AV_LOG_ERROR, Cannot open libx265 encoder.\n); libx265_encode_close(avctx); @@ -221,7 +232,7 @@ static av_cold int
Re: [FFmpeg-devel] [PATCH] avcodec/libx265: use x265 Multi-library Interface to query the API
On 5/5/2015 9:54 AM, Gopu Govindaswamy wrote: From c882bbf42b0f13f98fb706139b7d3fbc53665319 Mon Sep 17 00:00:00 2001 From: Gopu Govindaswamy g...@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 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel