#pragma once #include #include #include #define CL_USE_DEPRECATED_OPENCL_1_2_APIS #ifdef __APPLE__ #include #else #include #endif #include "common/mat.h" #include "selfdrive/modeld/transforms/loadyuv.h" #include "selfdrive/modeld/transforms/transform.h" class ModelFrame { public: ModelFrame(cl_device_id device_id, cl_context context); ~ModelFrame(); uint8_t* prepare(cl_mem yuv_cl, int width, int height, int frame_stride, int frame_uv_offset, const mat3& transform, cl_mem *output); const int MODEL_WIDTH = 512; const int MODEL_HEIGHT = 256; const int MODEL_FRAME_SIZE = MODEL_WIDTH * MODEL_HEIGHT * 3 / 2; const int buf_size = MODEL_FRAME_SIZE * 2; const size_t frame_size_bytes = MODEL_FRAME_SIZE * sizeof(uint8_t); private: Transform transform; LoadYUVState loadyuv; cl_command_queue q; cl_mem y_cl, u_cl, v_cl, img_buffer_20hz_cl, last_img_cl; cl_buffer_region region; std::unique_ptr input_frames; };