History

lavu/opencl:add opencl set param function

highgod0401 committed 13 years ago

Commit f31247c1 parent 667159e3 files · +93 −1Browse files

Unified · Split

3 files
  1. libavutil/Makefile +1 −1
  2. libavutil/opencl_internal.c +59 −0
  3. libavutil/opencl_internal.h +33 −0
libavutil/Makefile+1−1
@@ -108,7 +108,7 @@ OBJS = adler32.o \ · 107 unmodified lines
108 xtea.o \108 xtea.o \
109 109
110OBJS-$(CONFIG_LZO) += lzo.o110OBJS-$(CONFIG_LZO) += lzo.o
111OBJS-$(CONFIG_OPENCL) += opencl.o111OBJS-$(CONFIG_OPENCL) += opencl.o opencl_internal.o
112 112
113OBJS += $(COMPAT_OBJS:%=../compat/%)113OBJS += $(COMPAT_OBJS:%=../compat/%)
114 114
libavutil/opencl_internal.c+59−0
@@ -0,0 +1,59 @@
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
26int ff_opencl_set_parameter(FFOpenclParam *opencl_param, ...)
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: %d\n", status);
51 ret = AVERROR_EXTERNAL;
52 goto end;
53 }
54 opencl_param->param_num++;
55 } while (param && param_size);
56end:
57 va_end(arg_ptr);
58 return ret;
59}
libavutil/opencl_internal.h+33−0
@@ -0,0 +1,33 @@
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.h"
24
25#define FF_OPENCL_PARAM_INFO(a) ((void*)(&(a))), (sizeof(a))
26
27typedef struct {
28 cl_kernel kernel;
29 int param_num;
30 void *ctx;
31} FFOpenclParam;
32
33int ff_opencl_set_parameter(FFOpenclParam *opencl_param, ...);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t