[FFmpeg-devel] [PATCH 3/3] ffmpeg: add opencl options to ffmpeg 20130410

Stefano Sabatini stefasab at gmail.com
Wed Apr 10 17:02:15 CEST 2013


On date Wednesday 2013-04-10 22:22:40 +0800, Wei Gao encoded:
[...]
> From f7b5b9d3e3daa3612012213d0d9ec643b6014055 Mon Sep 17 00:00:00 2001
> From: highgod0401 <highgod0401 at gmail.com>
> Date: Wed, 10 Apr 2013 22:19:33 +0800
> Subject: [PATCH 3/3] add opencl options to ffmpeg 20130410 new
> 
> ---
>  doc/ffmpeg.texi |  9 +++++++++
>  ffmpeg_opt.c    | 31 +++++++++++++++++++++++++++++++
>  2 files changed, 40 insertions(+)
> 
> diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
> index eb981d7..e8bc677 100644
> --- a/doc/ffmpeg.texi
> +++ b/doc/ffmpeg.texi
> @@ -487,6 +487,15 @@ ffmpeg -i foo.mov -c:v libxvid -pass 1 -an -f rawvideo -y NUL
>  ffmpeg -i foo.mov -c:v libxvid -pass 1 -an -f rawvideo -y /dev/null
>  @end example
>  
> + at item -opencl_options @var{options}
> +Set options for running opencl.
> +build_options: set opencl build options.
> +platform: set platform for opencl.
> +device: set device for opencl.

Set options for running OpenCL. Only available if FFmpeg was configured with
@code{--enable-opencl}.

See "OpenCL Options" section in the ffmpeg-utils manual.

...

Also I think you could move this option to cmdutils.c, so it can be
used by all the ff* tools.

> + at example
> +ffmpeg -i INPUT -vf filter=opencl=1 -opencl_options build_options=-I.:platform=0:device=0 OUTPUT
> + at end example
> +
>  @item -passlogfile[:@var{stream_specifier}] @var{prefix} (@emph{output,per-stream})
>  Set two-pass log file name prefix to @var{prefix}, the default file name
>  prefix is ``ffmpeg2pass''. The complete file name will be
> diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
> index 63a238d..93d7a64 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++;
> +        }

av_opt_get_key_value()?

> +        ret = av_opencl_set_option(content[0], content[1]);
> +        if (ret < 0)
> +            return ret;
> +    }
> +    return ret;
> +}
> +#endif
> +
>  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" },
> +#endif
>      { NULL, },
>  };
[...]
-- 
FFmpeg = Fundamentalist Fundamentalist Magic Portentous Esoteric Guide


More information about the ffmpeg-devel mailing list