FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
opencl_internal.c
Go to the documentation of this file.
1 /*
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>
5  *
6  * This file is part of FFmpeg.
7  *
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.
12  *
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.
17  *
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
21  */
22 
23 #include "opencl_internal.h"
24 #include "libavutil/log.h"
25 
27 {
28  int ret = 0;
29  va_list arg_ptr;
30  void *param;
31  size_t param_size;
32  cl_int status;
33  if (!opencl_param->kernel) {
34  av_log(opencl_param->ctx, AV_LOG_ERROR, "OpenCL kernel must be set\n");
35  return AVERROR(EINVAL);
36  }
37  va_start(arg_ptr, opencl_param);
38  do {
39  param = va_arg(arg_ptr, void *);
40  if (!param)
41  break;
42  param_size = va_arg(arg_ptr, size_t);
43  if (!param_size) {
44  av_log(opencl_param->ctx, AV_LOG_ERROR, "Parameter size must not be 0\n");
45  ret = AVERROR(EINVAL);
46  goto end;
47  }
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;
52  goto end;
53  }
54  opencl_param->param_num++;
55  } while (param && param_size);
56 end:
57  va_end(arg_ptr);
58  return ret;
59 }
const char * av_opencl_errstr(cl_int status)
Get OpenCL error string.
Definition: opencl.c:165
static av_cold int end(AVCodecContext *avctx)
Definition: avrndec.c:67
#define av_log(a,...)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
#define AVERROR(e)
Definition: error.h:43
int avpriv_opencl_set_parameter(FFOpenclParam *opencl_param,...)
ret
Definition: avfilter.c:974
cl_kernel kernel
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:57