34 #define ROUND_TO_16(a) (((((a) - 1)/16)+1)*16)
38 const float *matrix_y,
const float *matrix_uv,
45 float4 packed_matrix_lu = {matrix_y[0], matrix_y[1], matrix_y[2], matrix_y[5]};
46 float4 packed_matrix_ch = {matrix_uv[0], matrix_uv[1], matrix_uv[2], matrix_uv[5]};
49 size_t local_worksize[2] = {16, 16};
52 param_lu.
ctx = param_ch.
ctx = ctx;
53 param_lu.
kernel = deshake->opencl_ctx.kernel_luma;
54 param_ch.
kernel = deshake->opencl_ctx.kernel_chroma;
90 status = clEnqueueNDRangeKernel(deshake->opencl_ctx.command_queue,
91 deshake->opencl_ctx.kernel_luma, 2, NULL,
92 global_worksize_lu, local_worksize, 0, NULL, NULL);
93 status |= clEnqueueNDRangeKernel(deshake->opencl_ctx.command_queue,
94 deshake->opencl_ctx.kernel_chroma, 2, NULL,
95 global_worksize_ch, local_worksize, 0, NULL, NULL);
96 if (status != CL_SUCCESS) {
101 deshake->opencl_ctx.plane_num, deshake->opencl_ctx.cl_outbuf,
102 deshake->opencl_ctx.cl_outbuf_size);
115 deshake->opencl_ctx.plane_num =
PLANE_NUM;
117 if (!deshake->opencl_ctx.command_queue) {
118 av_log(ctx,
AV_LOG_ERROR,
"Unable to get OpenCL command queue in filter 'deshake'\n");
122 if (!deshake->opencl_ctx.program) {
126 if (!deshake->opencl_ctx.kernel_luma) {
127 deshake->opencl_ctx.kernel_luma = clCreateKernel(deshake->opencl_ctx.program,
128 "avfilter_transform_luma", &ret);
129 if (ret != CL_SUCCESS) {
130 av_log(ctx,
AV_LOG_ERROR,
"OpenCL failed to create kernel 'avfilter_transform_luma'\n");
134 if (!deshake->opencl_ctx.kernel_chroma) {
135 deshake->opencl_ctx.kernel_chroma = clCreateKernel(deshake->opencl_ctx.program,
136 "avfilter_transform_chroma", &ret);
137 if (ret != CL_SUCCESS) {
138 av_log(ctx,
AV_LOG_ERROR,
"OpenCL failed to create kernel 'avfilter_transform_chroma'\n");
150 clReleaseKernel(deshake->opencl_ctx.kernel_luma);
151 clReleaseKernel(deshake->opencl_ctx.kernel_chroma);
152 clReleaseProgram(deshake->opencl_ctx.program);
153 deshake->opencl_ctx.command_queue = NULL;
165 if ((!deshake->opencl_ctx.cl_inbuf) || (!deshake->opencl_ctx.cl_outbuf)) {
166 deshake->opencl_ctx.in_plane_size[0] = (in->
linesize[0] * in->
height);
167 deshake->opencl_ctx.in_plane_size[1] = (in->
linesize[1] * chroma_height);
168 deshake->opencl_ctx.in_plane_size[2] = (in->
linesize[2] * chroma_height);
169 deshake->opencl_ctx.out_plane_size[0] = (out->
linesize[0] * out->
height);
170 deshake->opencl_ctx.out_plane_size[1] = (out->
linesize[1] * chroma_height);
171 deshake->opencl_ctx.out_plane_size[2] = (out->
linesize[2] * chroma_height);
172 deshake->opencl_ctx.cl_inbuf_size = deshake->opencl_ctx.in_plane_size[0] +
173 deshake->opencl_ctx.in_plane_size[1] +
174 deshake->opencl_ctx.in_plane_size[2];
175 deshake->opencl_ctx.cl_outbuf_size = deshake->opencl_ctx.out_plane_size[0] +
176 deshake->opencl_ctx.out_plane_size[1] +
177 deshake->opencl_ctx.out_plane_size[2];
178 if (!deshake->opencl_ctx.cl_inbuf) {
180 deshake->opencl_ctx.cl_inbuf_size,
181 CL_MEM_READ_ONLY, NULL);
185 if (!deshake->opencl_ctx.cl_outbuf) {
187 deshake->opencl_ctx.cl_outbuf_size,
188 CL_MEM_READ_WRITE, NULL);
194 deshake->opencl_ctx.cl_inbuf_size,
195 0, in->
data,deshake->opencl_ctx.in_plane_size,
196 deshake->opencl_ctx.plane_num);