Commit 66825547 authored by Lenny Wang's avatar Lenny Wang Committed by Michael Niedermayer

avutil/opencl: compile kernels separately

Reviewed-by: 's avatarWei Gao <highgod0401@gmail.com>
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent e3f384b4
This diff is collapsed.
/* /*
* Copyright (C) 2012 Peng Gao <peng@multicorewareinc.com> * Copyright (C) 2012 Peng Gao <peng@multicorewareinc.com>
* Copyright (C) 2012 Li Cao <li@multicorewareinc.com> * Copyright (C) 2012 Li Cao <li@multicorewareinc.com>
* Copyright (C) 2012 Wei Gao <weigao@multicorewareinc.com> * Copyright (C) 2012 Wei Gao <weigao@multicorewareinc.com>
* Copyright (C) 2013 Lenny Wang <lwanghpc@gmail.com>
* *
* This file is part of FFmpeg. * This file is part of FFmpeg.
* *
...@@ -39,6 +40,8 @@ ...@@ -39,6 +40,8 @@
#endif #endif
#include "dict.h" #include "dict.h"
#include "libavutil/version.h"
#define AV_OPENCL_KERNEL( ... )# __VA_ARGS__ #define AV_OPENCL_KERNEL( ... )# __VA_ARGS__
#define AV_OPENCL_MAX_KERNEL_NAME_SIZE 150 #define AV_OPENCL_MAX_KERNEL_NAME_SIZE 150
...@@ -65,11 +68,13 @@ typedef struct { ...@@ -65,11 +68,13 @@ typedef struct {
AVOpenCLPlatformNode **platform_node; AVOpenCLPlatformNode **platform_node;
} AVOpenCLDeviceList; } AVOpenCLDeviceList;
#if FF_API_OLD_OPENCL
typedef struct { typedef struct {
cl_command_queue command_queue; cl_command_queue command_queue;
cl_kernel kernel; cl_kernel kernel;
char kernel_name[AV_OPENCL_MAX_KERNEL_NAME_SIZE]; char kernel_name[AV_OPENCL_MAX_KERNEL_NAME_SIZE];
} AVOpenCLKernelEnv; } AVOpenCLKernelEnv;
#endif
typedef struct { typedef struct {
cl_platform_id platform_id; cl_platform_id platform_id;
...@@ -107,7 +112,6 @@ void av_opencl_free_device_list(AVOpenCLDeviceList **device_list); ...@@ -107,7 +112,6 @@ void av_opencl_free_device_list(AVOpenCLDeviceList **device_list);
* av_opencl_init() operation. * av_opencl_init() operation.
* *
* The currently accepted options are: * The currently accepted options are:
* - build_options: set options to compile registered kernels code
* - platform: set index of platform in device list * - platform: set index of platform in device list
* - device: set index of device in device list * - device: set index of device in device list
* *
...@@ -174,15 +178,15 @@ const char *av_opencl_errstr(cl_int status); ...@@ -174,15 +178,15 @@ const char *av_opencl_errstr(cl_int status);
int av_opencl_register_kernel_code(const char *kernel_code); int av_opencl_register_kernel_code(const char *kernel_code);
/** /**
* Initialize the run time OpenCL environment and compile the kernel * Initialize the run time OpenCL environment
* code registered with av_opencl_register_kernel_code().
* *
* @param ext_opencl_env external OpenCL environment, created by an * @param ext_opencl_env external OpenCL environment, created by an
* application program, ignored if set to NULL * application program, ignored if set to NULL
* @return >=0 on success, a negative error code in case of failure * @return >=0 on success, a negative error code in case of failure
*/ */
int av_opencl_init(AVOpenCLExternalEnv *ext_opencl_env); int av_opencl_init(AVOpenCLExternalEnv *ext_opencl_env);
#if FF_API_OLD_OPENCL
/** /**
* Create kernel object in the specified kernel environment. * Create kernel object in the specified kernel environment.
* *
...@@ -190,8 +194,27 @@ int av_opencl_register_kernel_code(const char *kernel_code); ...@@ -190,8 +194,27 @@ int av_opencl_register_kernel_code(const char *kernel_code);
* the environment used to run the kernel * the environment used to run the kernel
* @param kernel_name kernel function name * @param kernel_name kernel function name
* @return >=0 on success, a negative error code in case of failure * @return >=0 on success, a negative error code in case of failure
* @deprecated, use clCreateKernel
*/ */
int av_opencl_create_kernel(AVOpenCLKernelEnv *env, const char *kernel_name); int av_opencl_create_kernel(AVOpenCLKernelEnv *env, const char *kernel_name);
#endif
/**
* compile specific OpenCL kernel source
*
* @param program_name pointer to a program name used for identification
* @param build_opts pointer to a string that describes the preprocessor
* build options to be used for building the program
* @return a cl_program object
*/
cl_program av_opencl_compile(const char *program_name, const char* build_opts);
/**
* get OpenCL command queue
*
* @return a cl_command_queue object
*/
cl_command_queue av_opencl_get_command_queue(void);
/** /**
* Create OpenCL buffer. * Create OpenCL buffer.
...@@ -268,13 +291,16 @@ int av_opencl_buffer_read_image(uint8_t **dst_data, int *plane_size, int plane_n ...@@ -268,13 +291,16 @@ int av_opencl_buffer_read_image(uint8_t **dst_data, int *plane_size, int plane_n
*/ */
void av_opencl_buffer_release(cl_mem *cl_buf); void av_opencl_buffer_release(cl_mem *cl_buf);
#if FF_API_OLD_OPENCL
/** /**
* Release kernel object. * Release kernel object.
* *
* @param env kernel environment where the kernel object was created * @param env kernel environment where the kernel object was created
* with av_opencl_create_kernel() * with av_opencl_create_kernel()
* @deprecated, use clReleaseKernel
*/ */
void av_opencl_release_kernel(AVOpenCLKernelEnv *env); void av_opencl_release_kernel(AVOpenCLKernelEnv *env);
#endif
/** /**
* Release OpenCL environment. * Release OpenCL environment.
......
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
*/ */
#define LIBAVUTIL_VERSION_MAJOR 52 #define LIBAVUTIL_VERSION_MAJOR 52
#define LIBAVUTIL_VERSION_MINOR 51 #define LIBAVUTIL_VERSION_MINOR 52
#define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
...@@ -141,6 +141,9 @@ ...@@ -141,6 +141,9 @@
#ifndef FF_API_GET_CHANNEL_LAYOUT_COMPAT #ifndef FF_API_GET_CHANNEL_LAYOUT_COMPAT
#define FF_API_GET_CHANNEL_LAYOUT_COMPAT (LIBAVUTIL_VERSION_MAJOR < 53) #define FF_API_GET_CHANNEL_LAYOUT_COMPAT (LIBAVUTIL_VERSION_MAJOR < 53)
#endif #endif
#ifndef FF_API_OLD_OPENCL
#define FF_API_OLD_OPENCL (LIBAVUTIL_VERSION_MAJOR < 53)
#endif
/** /**
* @} * @}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment