FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
hwcontext_opencl.c File Reference
#include <string.h>
#include "config.h"
#include "avassert.h"
#include "avstring.h"
#include "common.h"
#include "hwcontext.h"
#include "hwcontext_internal.h"
#include "hwcontext_opencl.h"
#include "mem.h"
#include "pixdesc.h"

Go to the source code of this file.

Data Structures

struct  OpenCLDeviceContext
 
struct  OpenCLFramesContext
 
struct  OpenCLDeviceSelector
 
struct  OpenCLMapping
 

Macros

#define CL_USE_DEPRECATED_OPENCL_1_2_APIS
 
#define CL_FUNC(name, desc)
 
#define CHANNEL_ORDER(order, type)   case order: image_format->image_channel_order = type; break;
 

Functions

static void CL_CALLBACK opencl_error_callback (const char *errinfo, const void *private_info, size_t cb, void *user_data)
 
static void opencl_device_free (AVHWDeviceContext *hwdev)
 
static char * opencl_get_platform_string (cl_platform_id platform_id, cl_platform_info key)
 
static char * opencl_get_device_string (cl_device_id device_id, cl_device_info key)
 
static int opencl_check_platform_extension (cl_platform_id platform_id, const char *name)
 
static int opencl_check_device_extension (cl_device_id device_id, const char *name)
 
static av_unused int opencl_check_extension (AVHWDeviceContext *hwdev, const char *name)
 
static int opencl_enumerate_platforms (AVHWDeviceContext *hwdev, cl_uint *nb_platforms, cl_platform_id **platforms, void *context)
 
static int opencl_filter_platform (AVHWDeviceContext *hwdev, cl_platform_id platform_id, const char *platform_name, void *context)
 
static int opencl_enumerate_devices (AVHWDeviceContext *hwdev, cl_platform_id platform_id, const char *platform_name, cl_uint *nb_devices, cl_device_id **devices, void *context)
 
static int opencl_filter_device (AVHWDeviceContext *hwdev, cl_device_id device_id, const char *device_name, void *context)
 
static int opencl_device_create_internal (AVHWDeviceContext *hwdev, const OpenCLDeviceSelector *selector, cl_context_properties *props)
 
static int opencl_device_create (AVHWDeviceContext *hwdev, const char *device, AVDictionary *opts, int flags)
 
static int opencl_device_init (AVHWDeviceContext *hwdev)
 
static void opencl_device_uninit (AVHWDeviceContext *hwdev)
 
static int opencl_device_derive (AVHWDeviceContext *hwdev, AVHWDeviceContext *src_ctx, int flags)
 
static int opencl_get_plane_format (enum AVPixelFormat pixfmt, int plane, int width, int height, cl_image_format *image_format, cl_image_desc *image_desc)
 
static int opencl_frames_get_constraints (AVHWDeviceContext *hwdev, const void *hwconfig, AVHWFramesConstraints *constraints)
 
static void opencl_pool_free (void *opaque, uint8_t *data)
 
static AVBufferRefopencl_pool_alloc (void *opaque, int size)
 
static int opencl_frames_init_command_queue (AVHWFramesContext *hwfc)
 
static int opencl_frames_init (AVHWFramesContext *hwfc)
 
static void opencl_frames_uninit (AVHWFramesContext *hwfc)
 
static int opencl_get_buffer (AVHWFramesContext *hwfc, AVFrame *frame)
 
static int opencl_transfer_get_formats (AVHWFramesContext *hwfc, enum AVHWFrameTransferDirection dir, enum AVPixelFormat **formats)
 
static int opencl_wait_events (AVHWFramesContext *hwfc, cl_event *events, int nb_events)
 
static int opencl_transfer_data_from (AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src)
 
static int opencl_transfer_data_to (AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src)
 
static void opencl_unmap_frame (AVHWFramesContext *hwfc, HWMapDescriptor *hwmap)
 
static int opencl_map_frame (AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src, int flags)
 
static cl_mem_flags opencl_mem_flags_for_mapping (int map_flags)
 
static int opencl_map_from (AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src, int flags)
 
static int opencl_map_to (AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src, int flags)
 
static int opencl_frames_derive_to (AVHWFramesContext *dst_fc, AVHWFramesContext *src_fc, int flags)
 

Variables

struct {
   const char *   key
 
   cl_platform_info   name
 
opencl_platform_params []
 
struct {
   const char *   key
 
   cl_device_info   name
 
opencl_device_params []
 
struct {
   const char *   key
 
   cl_device_type   type
 
opencl_device_types []
 
const HWContextType ff_hwcontext_type_opencl
 

Macro Definition Documentation

#define CL_USE_DEPRECATED_OPENCL_1_2_APIS

Definition at line 19 of file hwcontext_opencl.c.

#define CL_FUNC (   name,
  desc 
)
Value:
do { \
if (fail) \
break; \
priv->name = clGetExtensionFunctionAddressForPlatform( \
priv->platform_id, #name); \
if (!priv->name) { \
desc " function not found (%s).\n", #name); \
fail = 1; \
} else { \
desc " function found (%s).\n", #name); \
} \
} while (0)
const char * desc
Definition: nvenc.c:65
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:192
#define av_log(a,...)
#define fail()
Definition: checkasm.h:117
if(ret< 0)
Definition: vf_mcdeint.c:279
const char * name
Definition: opengl_enc.c:103

Referenced by opencl_device_init().

#define CHANNEL_ORDER (   order,
  type 
)    case order: image_format->image_channel_order = type; break;

Referenced by opencl_get_plane_format().

Function Documentation

static void CL_CALLBACK opencl_error_callback ( const char *  errinfo,
const void private_info,
size_t  cb,
void user_data 
)
static

Definition at line 146 of file hwcontext_opencl.c.

Referenced by opencl_device_create_internal().

static void opencl_device_free ( AVHWDeviceContext hwdev)
static

Definition at line 155 of file hwcontext_opencl.c.

Referenced by opencl_device_create_internal().

static char* opencl_get_platform_string ( cl_platform_id  platform_id,
cl_platform_info  key 
)
static
static char* opencl_get_device_string ( cl_device_id  device_id,
cl_device_info  key 
)
static
static int opencl_check_platform_extension ( cl_platform_id  platform_id,
const char *  name 
)
static

Definition at line 244 of file hwcontext_opencl.c.

Referenced by opencl_check_extension().

static int opencl_check_device_extension ( cl_device_id  device_id,
const char *  name 
)
static

Definition at line 257 of file hwcontext_opencl.c.

Referenced by opencl_check_extension().

static av_unused int opencl_check_extension ( AVHWDeviceContext hwdev,
const char *  name 
)
static

Definition at line 270 of file hwcontext_opencl.c.

Referenced by opencl_device_init().

static int opencl_enumerate_platforms ( AVHWDeviceContext hwdev,
cl_uint *  nb_platforms,
cl_platform_id **  platforms,
void context 
)
static

Definition at line 291 of file hwcontext_opencl.c.

Referenced by opencl_device_create(), and opencl_device_derive().

static int opencl_filter_platform ( AVHWDeviceContext hwdev,
cl_platform_id  platform_id,
const char *  platform_name,
void context 
)
static

Definition at line 322 of file hwcontext_opencl.c.

Referenced by opencl_device_create(), and opencl_device_derive().

static int opencl_enumerate_devices ( AVHWDeviceContext hwdev,
cl_platform_id  platform_id,
const char *  platform_name,
cl_uint *  nb_devices,
cl_device_id **  devices,
void context 
)
static
static int opencl_filter_device ( AVHWDeviceContext hwdev,
cl_device_id  device_id,
const char *  device_name,
void context 
)
static

Definition at line 397 of file hwcontext_opencl.c.

Referenced by opencl_device_create().

static int opencl_device_create_internal ( AVHWDeviceContext hwdev,
const OpenCLDeviceSelector selector,
cl_context_properties *  props 
)
static

Definition at line 487 of file hwcontext_opencl.c.

Referenced by opencl_device_create(), and opencl_device_derive().

static int opencl_device_create ( AVHWDeviceContext hwdev,
const char *  device,
AVDictionary opts,
int  flags 
)
static

Definition at line 617 of file hwcontext_opencl.c.

static int opencl_device_init ( AVHWDeviceContext hwdev)
static

Definition at line 650 of file hwcontext_opencl.c.

static void opencl_device_uninit ( AVHWDeviceContext hwdev)
static

Definition at line 886 of file hwcontext_opencl.c.

static int opencl_device_derive ( AVHWDeviceContext hwdev,
AVHWDeviceContext src_ctx,
int  flags 
)
static

Definition at line 1193 of file hwcontext_opencl.c.

static int opencl_get_plane_format ( enum AVPixelFormat  pixfmt,
int  plane,
int  width,
int  height,
cl_image_format *  image_format,
cl_image_desc *  image_desc 
)
static
static int opencl_frames_get_constraints ( AVHWDeviceContext hwdev,
const void hwconfig,
AVHWFramesConstraints constraints 
)
static

Definition at line 1475 of file hwcontext_opencl.c.

static void opencl_pool_free ( void opaque,
uint8_t data 
)
static

Definition at line 1602 of file hwcontext_opencl.c.

Referenced by opencl_pool_alloc().

static AVBufferRef* opencl_pool_alloc ( void opaque,
int  size 
)
static

Definition at line 1620 of file hwcontext_opencl.c.

Referenced by opencl_frames_init().

static int opencl_frames_init_command_queue ( AVHWFramesContext hwfc)
static

Definition at line 1676 of file hwcontext_opencl.c.

Referenced by opencl_frames_derive_to(), and opencl_frames_init().

static int opencl_frames_init ( AVHWFramesContext hwfc)
static

Definition at line 1695 of file hwcontext_opencl.c.

static void opencl_frames_uninit ( AVHWFramesContext hwfc)
static

Definition at line 1708 of file hwcontext_opencl.c.

static int opencl_get_buffer ( AVHWFramesContext hwfc,
AVFrame frame 
)
static

Definition at line 1736 of file hwcontext_opencl.c.

static int opencl_transfer_get_formats ( AVHWFramesContext hwfc,
enum AVHWFrameTransferDirection  dir,
enum AVPixelFormat **  formats 
)
static

Definition at line 1757 of file hwcontext_opencl.c.

static int opencl_wait_events ( AVHWFramesContext hwfc,
cl_event *  events,
int  nb_events 
)
static
static int opencl_transfer_data_from ( AVHWFramesContext hwfc,
AVFrame dst,
const AVFrame src 
)
static

Definition at line 1798 of file hwcontext_opencl.c.

static int opencl_transfer_data_to ( AVHWFramesContext hwfc,
AVFrame dst,
const AVFrame src 
)
static

Definition at line 1853 of file hwcontext_opencl.c.

static void opencl_unmap_frame ( AVHWFramesContext hwfc,
HWMapDescriptor hwmap 
)
static

Definition at line 1915 of file hwcontext_opencl.c.

Referenced by opencl_map_frame().

static int opencl_map_frame ( AVHWFramesContext hwfc,
AVFrame dst,
const AVFrame src,
int  flags 
)
static

Definition at line 1944 of file hwcontext_opencl.c.

Referenced by opencl_map_from().

static cl_mem_flags opencl_mem_flags_for_mapping ( int  map_flags)
inlinestatic

Definition at line 2182 of file hwcontext_opencl.c.

static int opencl_map_from ( AVHWFramesContext hwfc,
AVFrame dst,
const AVFrame src,
int  flags 
)
static

Definition at line 2798 of file hwcontext_opencl.c.

static int opencl_map_to ( AVHWFramesContext hwfc,
AVFrame dst,
const AVFrame src,
int  flags 
)
static

Definition at line 2807 of file hwcontext_opencl.c.

static int opencl_frames_derive_to ( AVHWFramesContext dst_fc,
AVHWFramesContext src_fc,
int  flags 
)
static

Definition at line 2848 of file hwcontext_opencl.c.

Variable Documentation

const char* key

Definition at line 168 of file hwcontext_opencl.c.

Referenced by aa_read_header(), add_metadata(), add_opt(), ape_tag_read_field(), av_opt_get_key_value(), av_opt_query_ranges(), av_opt_set_from_string(), av_packet_unpack_dictionary(), av_tree_insert(), avformat_match_stream_specifier(), avi_read_packet(), avi_read_tag(), check_keyboard_interaction(), cmp_id_key(), decode_header(), do_encrypt(), ea_read_packet(), epic_hash_add(), extract_line(), ff_AMediaFormat_getBuffer(), ff_AMediaFormat_getFloat(), ff_AMediaFormat_getInt32(), ff_AMediaFormat_getInt64(), ff_AMediaFormat_getString(), ff_AMediaFormat_setBuffer(), ff_AMediaFormat_setFloat(), ff_AMediaFormat_setInt32(), ff_AMediaFormat_setInt64(), ff_AMediaFormat_setString(), ff_id3v2_parse_priv_dict(), ff_metadata_conv(), ff_parse_key_value(), ff_read_riff_info(), ff_tee_parse_slave_options(), filter_frame(), free_segment_dynarray(), gain_entry_compare(), glyph_cmp(), hls_encryption_start(), hpel_motion_search(), id3v2_3_metadata_split_date(), init_report(), ivr_read_header(), matroska_convert_tag(), microdvd_close_no_persistent_tags(), microdvd_init(), microdvd_open_tags(), mkv_write_simpletag(), mov_metadata_loci(), mov_parse_vc1_frame(), mov_read_custom(), mov_read_udta_string(), mpegts_write_pes(), multiswap_dec(), multiswap_enc(), mxf_parse_package_comments(), mxf_read_indirect_value(), mxf_write_opatom_body_partition(), nist_read_header(), nuv_read_dts(), open_input(), open_output_file(), opencl_filter_device(), opencl_filter_platform(), opt_preset(), parse_audio(), parse_key(), parse_key_value_pair(), parse_legacy_attrib(), parse_metadata(), parse_playlist(), process_options(), read_comment(), read_info_chunk(), read_odml_index(), read_tag(), read_uslt(), redspark_probe(), redspark_read_header(), sab_diamond_search(), small_diamond_search(), subviewer_read_header(), update_metadata(), url_alloc_for_protocol(), vivo_read_header(), and write_sm_data().

cl_device_info name

Definition at line 169 of file hwcontext_opencl.c.

struct { ... } opencl_platform_params[]
Initial value:
= {
{ "platform_profile", CL_PLATFORM_PROFILE },
{ "platform_version", CL_PLATFORM_VERSION },
{ "platform_name", CL_PLATFORM_NAME },
{ "platform_vendor", CL_PLATFORM_VENDOR },
{ "platform_extensions", CL_PLATFORM_EXTENSIONS },
}

Referenced by opencl_filter_platform().

struct { ... } opencl_device_params[]
Initial value:
= {
{ "device_name", CL_DEVICE_NAME },
{ "device_vendor", CL_DEVICE_VENDOR },
{ "driver_version", CL_DRIVER_VERSION },
{ "device_version", CL_DEVICE_VERSION },
{ "device_profile", CL_DEVICE_PROFILE },
{ "device_extensions", CL_DEVICE_EXTENSIONS },
}

Referenced by opencl_filter_device().

cl_device_type type

Definition at line 192 of file hwcontext_opencl.c.

struct { ... } opencl_device_types[]
Initial value:
= {
{ "cpu", CL_DEVICE_TYPE_CPU },
{ "gpu", CL_DEVICE_TYPE_GPU },
{ "accelerator", CL_DEVICE_TYPE_ACCELERATOR },
{ "custom", CL_DEVICE_TYPE_CUSTOM },
{ "default", CL_DEVICE_TYPE_DEFAULT },
{ "all", CL_DEVICE_TYPE_ALL },
}

Referenced by opencl_filter_device().

const HWContextType ff_hwcontext_type_opencl

Definition at line 2908 of file hwcontext_opencl.c.