2 * Copyright (C) 2012 Peng Gao <peng@multicorewareinc.com>
3 * Copyright (C) 2012 Li Cao <li@multicorewareinc.com>
4 * Copyright (C) 2012 Wei Gao <weigao@multicorewareinc.com>
6 * This file is part of FFmpeg.
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #include "opencl_internal.h"
24 #include "libavutil/log.h"
26 int avpriv_opencl_set_parameter(FFOpenclParam
*opencl_param
, ...)
33 if (!opencl_param
->kernel
) {
34 av_log(opencl_param
->ctx
, AV_LOG_ERROR
, "OpenCL kernel must be set\n");
35 return AVERROR(EINVAL
);
37 va_start(arg_ptr
, opencl_param
);
39 param
= va_arg(arg_ptr
, void *);
42 param_size
= va_arg(arg_ptr
, size_t);
44 av_log(opencl_param
->ctx
, AV_LOG_ERROR
, "Parameter size must not be 0\n");
45 ret
= AVERROR(EINVAL
);
48 status
= clSetKernelArg(opencl_param
->kernel
, opencl_param
->param_num
, param_size
, param
);
49 if (status
!= CL_SUCCESS
) {
50 av_log(opencl_param
->ctx
, AV_LOG_ERROR
, "Cannot set kernel argument: %s\n", av_opencl_errstr(status
));
51 ret
= AVERROR_EXTERNAL
;
54 opencl_param
->param_num
++;
55 } while (param
&& param_size
);