[FFmpeg-devel] [PATCH 3/3] ffmpeg: add opencl options to ffmpeg 20130410
Stefano Sabatini
stefasab at gmail.com
Wed Apr 10 14:58:46 CEST 2013
On date Wednesday 2013-04-10 17:33:44 +0800, Wei Gao encoded:
>
> From 31ee08818a2c69011269d6e91c28219c0123700a Mon Sep 17 00:00:00 2001
> From: highgod0401 <highgod0401 at gmail.com>
> Date: Wed, 10 Apr 2013 17:21:35 +0800
> Subject: [PATCH 3/3] add opencl options to ffmpeg 20130410
>
> ---
> ffmpeg_opt.c | 31 +++++++++++++++++++++++++++++++
> 1 file changed, 31 insertions(+)
Missing updates in doc/ffmpeg.texi.
>
> diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
> index 63a238d..3c63a66 100644
> --- a/ffmpeg_opt.c
> +++ b/ffmpeg_opt.c
> @@ -41,6 +41,9 @@
> #include "libavutil/parseutils.h"
> #include "libavutil/pixdesc.h"
> #include "libavutil/pixfmt.h"
> +#if CONFIG_OPENCL
> +#include "libavutil/opencl.h"
> +#endif
>
> #define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)\
> {\
> @@ -317,6 +320,30 @@ static int opt_attach(void *optctx, const char *opt, const char *arg)
> return 0;
> }
>
> +#if CONFIG_OPENCL
> +static int opt_opencl(void *optctx, const char *opt, const char *arg)
> +{
> + char *content[2] = {0};
> + const char *temp = arg;
> + int i, ret = 0;
> + while (*temp) {
> + for (i = 0; i < FF_ARRAY_ELEMS(content); i++) {
> + content[i] = av_get_token(&temp, "=:");
> + if (!(*temp) || !(*(temp + 1))) {
> + if (i == 1)
> + ret = av_opencl_set_option(content[0], content[1]);
> + return ret;
> + }
> + temp++;
> + }
> + ret = av_opencl_set_option(content[0], content[1]);
> + if (ret < 0)
> + return ret;
> + }
> + return ret;
> +}
> +#endif
Possibly simpler: you just set an option -opencl_option key=value,
which you can iterate, for example:
-opencl_option build_options="-I" -opencl_option device_idx=3 -opencl_option device_platform_idx=32
and you use av_opencl_set_option(), so you simplify parsing.
> +
> static int opt_map_channel(void *optctx, const char *opt, const char *arg)
> {
> OptionsContext *o = optctx;
> @@ -2835,5 +2862,9 @@ const OptionDef options[] = {
> { "dn", OPT_BOOL | OPT_VIDEO | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(data_disable) },
> "disable data" },
>
> +#if CONFIG_OPENCL
> + { "opencl_options", HAS_ARG, { .func_arg = opt_opencl },
> + "set opencl environment options" },
Nit: set OpenCL environment options
--
FFmpeg = Fiendish and Furious Mystic Portable EniGma
More information about the ffmpeg-devel
mailing list