int av_opencl_create_kernel(AVOpenCLKernelEnv *env, const char *kernel_name)

{

    cl_int status;

    int i, ret = 0;

    LOCK_OPENCL;

    if (strlen(kernel_name) + 1 > AV_OPENCL_MAX_KERNEL_NAME_SIZE) {

        av_log(&openclutils, AV_LOG_ERROR, "Created kernel name %s is too long\n", kernel_name);

        ret = AVERROR(EINVAL);

        goto end;

    }

    if (!env->kernel) {

        if (gpu_env.kernel_count >= MAX_KERNEL_NUM) {

            av_log(&openclutils, AV_LOG_ERROR,

            "Could not create kernel with name '%s', maximum number of kernels %d already reached\n",

                kernel_name, MAX_KERNEL_NUM);

            ret = AVERROR(EINVAL);

            goto end;

        }

        for (i = 0; i < gpu_env.program_count; i++) {

            env->kernel = clCreateKernel(gpu_env.programs[i], kernel_name, &status);

            if (status == CL_SUCCESS)

                break;

        }

        if (status != CL_SUCCESS) {

            av_log(&openclutils, AV_LOG_ERROR, "Could not create OpenCL kernel: %s\n", opencl_errstr(status));

            ret = AVERROR_EXTERNAL;

            goto end;

        }

        gpu_env.kernel_count++;

        env->command_queue = gpu_env.command_queue;

        av_strlcpy(env->kernel_name, kernel_name, sizeof(env->kernel_name));

    }

end:

    UNLOCK_OPENCL;

    return ret;

}

int av_opencl_create_kernel(AVOpenCLKernelEnv *env, const char *kernel_name)

{

    cl_int status;

    int i, ret = 0;

    LOCK_OPENCL;

    if (strlen(kernel_name) + 1 > AV_OPENCL_MAX_KERNEL_NAME_SIZE) {

        av_log(&openclutils, AV_LOG_ERROR, "Created kernel name %s is too long\n", kernel_name);

        ret = AVERROR(EINVAL);

        goto end;

    }

    if (!env->kernel) {

        if (gpu_env.kernel_count >= MAX_KERNEL_NUM) {

            av_log(&openclutils, AV_LOG_ERROR,

            "Could not create kernel with name '%s', maximum number of kernels %d already reached\n",

                kernel_name, MAX_KERNEL_NUM);

            ret = AVERROR(EINVAL);

            goto end;

        }

        for (i = 0; i < gpu_env.program_count; i++) {

            env->kernel = clCreateKernel(gpu_env.programs[i], kernel_name, &status);

            if (status == CL_SUCCESS)

                break;

        }

        if (status != CL_SUCCESS) {

            av_log(&openclutils, AV_LOG_ERROR, "Could not create OpenCL kernel: %s\n", opencl_errstr(status));

            ret = AVERROR_EXTERNAL;

            goto end;

        }

        gpu_env.kernel_count++;

        env->command_queue = gpu_env.command_queue;

        av_strlcpy(env->kernel_name, kernel_name, sizeof(env->kernel_name));

    }

end:

    UNLOCK_OPENCL;

    return ret;

}

int FUNC_0(AVOpenCLKernelEnv *VAR_0, const char *VAR_1)

{

    cl_int status;

    int VAR_2, VAR_3 = 0;

    LOCK_OPENCL;

    if (strlen(VAR_1) + 1 > AV_OPENCL_MAX_KERNEL_NAME_SIZE) {

        av_log(&openclutils, AV_LOG_ERROR, "Created kernel name %s is too long\n", VAR_1);

        VAR_3 = AVERROR(EINVAL);

        goto end;

    }

    if (!VAR_0->kernel) {

        if (gpu_env.kernel_count >= MAX_KERNEL_NUM) {

            av_log(&openclutils, AV_LOG_ERROR,

            "Could not create kernel with name '%s', maximum number of kernels %d already reached\n",

                VAR_1, MAX_KERNEL_NUM);

            VAR_3 = AVERROR(EINVAL);

            goto end;

        }

        for (VAR_2 = 0; VAR_2 < gpu_env.program_count; VAR_2++) {

            VAR_0->kernel = clCreateKernel(gpu_env.programs[VAR_2], VAR_1, &status);

            if (status == CL_SUCCESS)

                break;

        }

        if (status != CL_SUCCESS) {

            av_log(&openclutils, AV_LOG_ERROR, "Could not create OpenCL kernel: %s\n", opencl_errstr(status));

            VAR_3 = AVERROR_EXTERNAL;

            goto end;

        }

        gpu_env.kernel_count++;

        VAR_0->command_queue = gpu_env.command_queue;

        av_strlcpy(VAR_0->VAR_1, VAR_1, sizeof(VAR_0->VAR_1));

    }

end:

    UNLOCK_OPENCL;

    return VAR_3;

}

int FUNC_0(AVOpenCLKernelEnv *VAR_0, const char *VAR_1)
{ cl_int status; int VAR_2, VAR_3 = 0; LOCK_OPENCL; if (strlen(VAR_1) + 1 > AV_OPENCL_MAX_KERNEL_NAME_SIZE) { av_log(&openclutils, AV_LOG_ERROR, "Created kernel name %s is too long\n", VAR_1); VAR_3 = AVERROR(EINVAL); goto end; } if (!VAR_0->kernel) { if (gpu_env.kernel_count >= MAX_KERNEL_NUM) { av_log(&openclutils, AV_LOG_ERROR,
"Could not create kernel with name '%s', maximum number of kernels %d already reached\n",
VAR_1, MAX_KERNEL_NUM); VAR_3 = AVERROR(EINVAL); goto end; } for (VAR_2 = 0; VAR_2 < gpu_env.program_count; VAR_2++) { VAR_0->kernel = clCreateKernel(gpu_env.programs[VAR_2], VAR_1, &status); if (status == CL_SUCCESS)
break; } if (status != CL_SUCCESS) { av_log(&openclutils, AV_LOG_ERROR, "Could not create OpenCL kernel: %s\n", opencl_errstr(status)); VAR_3 = AVERROR_EXTERNAL; goto end; } gpu_env.kernel_count++; VAR_0->command_queue = gpu_env.command_queue; av_strlcpy(VAR_0->VAR_1, VAR_1, sizeof(VAR_0->VAR_1)); } end:
UNLOCK_OPENCL; return VAR_3; }