1 /* Copyright 2019 Scott Moreau */ 2 3 #pragma once 4 5 #define CL_TARGET_OPENCL_VERSION 110 6 7 #include <CL/opencl.h> 8 #include "frame-writer.hpp" 9 10 class OpenCL 11 { 12 cl_device_id device_id; 13 cl_mem yuv420_buffer, rgb_buffer; 14 unsigned int argbSize, yuv420Size, width, height, halfWidth, halfHeight; 15 cl_kernel kernel; 16 cl_context context; 17 cl_command_queue command_queue; 18 cl_program program; 19 cl_int ret = 0; 20 uint8_t *local_yuv420_buffer; 21 cl_device_id get_device_id(int device); 22 23 public: 24 25 OpenCL(int device); 26 ~OpenCL(); 27 28 int 29 init(int width, int height); 30 31 int 32 do_frame(const uint8_t* pixels, AVFrame *encoder_frame, AVPixelFormat format, bool y_invert); 33 }; 34