35 for (i = 0; i <
len; i++) {
36 dst[i] = counter1[i] + counter2[i];
43 int counter_size =
sizeof(uint32_t) * (2 * step + 1);
44 uint32_t *temp1_counter, *temp2_counter, **counter;
55 counter =
av_mallocz(
sizeof(uint32_t *) * (2 * step + 1));
60 for (i = 0; i < 2 * step + 1; i++) {
67 for (i = 0; i < 2 * step + 1; i++) {
68 memset(temp1_counter, 0, counter_size);
70 for (z = 0; z < step * 2; z += 2) {
72 memcpy(counter[z], temp1_counter, counter_size);
74 memcpy(counter[z + 1], temp2_counter, counter_size);
77 memcpy(mask, temp1_counter, counter_size);
81 for (i = 0; i < 2 * step + 1; i++) {
92 size_t size_matrix =
sizeof(uint32_t) * (2 * step_x + 1) * (2 * step_y + 1);
93 mask_x =
av_mallocz(
sizeof(uint32_t) * (2 * step_x + 1));
98 mask_y =
av_mallocz(
sizeof(uint32_t) * (2 * step_y + 1));
114 for (j = 0; j < 2 * step_y + 1; j++) {
115 for (i = 0; i < 2 * step_x + 1; i++) {
116 mask_matrix[i + j * (2 * step_x + 1)] = mask_y[j] * mask_x[i];
130 int i,
ret = 0, step_x[2], step_y[2];
132 mask_matrix[0] = unsharp->opencl_ctx.cl_luma_mask;
133 mask_matrix[1] = unsharp->opencl_ctx.cl_chroma_mask;
138 if (!mask_matrix[0] || !mask_matrix[1]) {
142 for (i = 0; i < 2; i++) {
158 const size_t global_work_size = link->
w * link->
h + 2 * ch * cw;
161 opencl_param.
ctx = ctx;
162 opencl_param.
kernel = unsharp->opencl_ctx.kernel_env.kernel;
189 status = clEnqueueNDRangeKernel(unsharp->opencl_ctx.kernel_env.command_queue,
190 unsharp->opencl_ctx.kernel_env.kernel, 1, NULL,
191 &global_work_size, NULL, 0, NULL, NULL);
192 if (status != CL_SUCCESS) {
196 clFinish(unsharp->opencl_ctx.kernel_env.command_queue);
198 unsharp->opencl_ctx.plane_num, unsharp->opencl_ctx.cl_outbuf,
199 unsharp->opencl_ctx.cl_outbuf_size);
211 CL_MEM_READ_ONLY, NULL);
216 CL_MEM_READ_ONLY, NULL);
222 unsharp->opencl_ctx.plane_num =
PLANE_NUM;
223 if (!unsharp->opencl_ctx.kernel_env.kernel) {
251 if ((!unsharp->opencl_ctx.cl_inbuf) || (!unsharp->opencl_ctx.cl_outbuf)) {
252 unsharp->opencl_ctx.in_plane_size[0] = (in->
linesize[0] * in->
height);
253 unsharp->opencl_ctx.in_plane_size[1] = (in->
linesize[1] * ch);
254 unsharp->opencl_ctx.in_plane_size[2] = (in->
linesize[2] * ch);
255 unsharp->opencl_ctx.out_plane_size[0] = (out->
linesize[0] * out->
height);
256 unsharp->opencl_ctx.out_plane_size[1] = (out->
linesize[1] * ch);
257 unsharp->opencl_ctx.out_plane_size[2] = (out->
linesize[2] * ch);
258 unsharp->opencl_ctx.cl_inbuf_size = unsharp->opencl_ctx.in_plane_size[0] +
259 unsharp->opencl_ctx.in_plane_size[1] +
260 unsharp->opencl_ctx.in_plane_size[2];
261 unsharp->opencl_ctx.cl_outbuf_size = unsharp->opencl_ctx.out_plane_size[0] +
262 unsharp->opencl_ctx.out_plane_size[1] +
263 unsharp->opencl_ctx.out_plane_size[2];
264 if (!unsharp->opencl_ctx.cl_inbuf) {
266 unsharp->opencl_ctx.cl_inbuf_size,
267 CL_MEM_READ_ONLY, NULL);
271 if (!unsharp->opencl_ctx.cl_outbuf) {
273 unsharp->opencl_ctx.cl_outbuf_size,
274 CL_MEM_READ_WRITE, NULL);
280 unsharp->opencl_ctx.cl_inbuf_size,
281 0, in->
data, unsharp->opencl_ctx.in_plane_size,
282 unsharp->opencl_ctx.plane_num);