Makes a naughty global that other stuff can refer to - not a sane thing to do at all, but helps for testing the other patches. --- Makefile | 1 + avconv.h | 1 + avconv_opencl.c | 40 ++++++++++++++++++++++++++++++++++++++++ avconv_opt.c | 15 +++++++++++++++ 4 files changed, 57 insertions(+) create mode 100644 avconv_opencl.c
diff --git a/Makefile b/Makefile index 4e026b0..443fe7c 100644 --- a/Makefile +++ b/Makefile @@ -78,6 +78,7 @@ $(foreach prog,$(AVBASENAMES),$(eval OBJS-$(prog) += cmdutils.o)) OBJS-avconv += avconv_opt.o avconv_filter.o OBJS-avconv-$(CONFIG_LIBMFX) += avconv_qsv.o +OBJS-avconv-$(CONFIG_OPENCL) += avconv_opencl.o OBJS-avconv-$(CONFIG_VAAPI) += avconv_vaapi.o OBJS-avconv-$(CONFIG_VDA) += avconv_vda.o OBJS-avconv-$(HAVE_DXVA2_LIB) += avconv_dxva2.o diff --git a/avconv.h b/avconv.h index cffe114..8f2c824 100644 --- a/avconv.h +++ b/avconv.h @@ -500,5 +500,6 @@ int qsv_init(AVCodecContext *s); int qsv_transcode_init(OutputStream *ost); int vaapi_decode_init(AVCodecContext *avctx); int vaapi_device_init(const char *device); +int opencl_device_init(const char *device); #endif /* AVCONV_H */ diff --git a/avconv_opencl.c b/avconv_opencl.c new file mode 100644 index 0000000..e07683f --- /dev/null +++ b/avconv_opencl.c @@ -0,0 +1,40 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/hwcontext.h" + +#include "avconv.h" + +AVBufferRef *opencl_device; + +av_cold int opencl_device_init(const char *device) +{ + int err; + + err = av_hwdevice_ctx_create(&opencl_device, //&hw_device_ctx, + AV_HWDEVICE_TYPE_OPENCL, + device, NULL, 0); + if (err < 0) { + av_log(NULL, AV_LOG_ERROR, "Failed to create " + "OpenCL device %s.\n", device); + return err; + } + + return 0; +} + diff --git a/avconv_opt.c b/avconv_opt.c index 362a5b7..43672cb 100644 --- a/avconv_opt.c +++ b/avconv_opt.c @@ -326,6 +326,17 @@ static int opt_attach(void *optctx, const char *opt, const char *arg) return 0; } +#if CONFIG_OPENCL +static int opt_opencl_device(void *optctx, const char *opt, const char *arg) +{ + int err; + err = opencl_device_init(arg); + if (err < 0) + exit_program(1); + return 0; +} +#endif + #if CONFIG_VAAPI static int opt_vaapi_device(void *optctx, const char *opt, const char *arg) { @@ -2697,6 +2708,10 @@ const OptionDef options[] = { { "dcodec", HAS_ARG | OPT_DATA | OPT_PERFILE | OPT_EXPERT | OPT_INPUT | OPT_OUTPUT, { .func_arg = opt_data_codec }, "force data codec ('copy' to copy stream)", "codec" }, +#if CONFIG_OPENCL + { "opencl_device", HAS_ARG | OPT_EXPERT, { .func_arg = opt_opencl_device }, + "set OpenCL hardware device (platform index:device index)", "device" }, +#endif #if CONFIG_VAAPI { "vaapi_device", HAS_ARG | OPT_EXPERT, { .func_arg = opt_vaapi_device }, "set VAAPI hardware device (DRM path or X11 display name)", "device" }, -- 2.8.1 _______________________________________________ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel