| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -7,19 +7,19 @@ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					#include "common/clutil.h" | 
					 | 
					 | 
					 | 
					#include "common/clutil.h" | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					ModelFrame::ModelFrame(cl_device_id device_id, cl_context context) { | 
					 | 
					 | 
					 | 
					ModelFrame::ModelFrame(cl_device_id device_id, cl_context context) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  input_frames = std::make_unique<float[]>(buf_size); | 
					 | 
					 | 
					 | 
					  input_frames = std::make_unique<uint8_t[]>(buf_size); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  q = CL_CHECK_ERR(clCreateCommandQueue(context, device_id, 0, &err)); | 
					 | 
					 | 
					 | 
					  q = CL_CHECK_ERR(clCreateCommandQueue(context, device_id, 0, &err)); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  y_cl = CL_CHECK_ERR(clCreateBuffer(context, CL_MEM_READ_WRITE, MODEL_WIDTH * MODEL_HEIGHT, NULL, &err)); | 
					 | 
					 | 
					 | 
					  y_cl = CL_CHECK_ERR(clCreateBuffer(context, CL_MEM_READ_WRITE, MODEL_WIDTH * MODEL_HEIGHT, NULL, &err)); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  u_cl = CL_CHECK_ERR(clCreateBuffer(context, CL_MEM_READ_WRITE, (MODEL_WIDTH / 2) * (MODEL_HEIGHT / 2), NULL, &err)); | 
					 | 
					 | 
					 | 
					  u_cl = CL_CHECK_ERR(clCreateBuffer(context, CL_MEM_READ_WRITE, (MODEL_WIDTH / 2) * (MODEL_HEIGHT / 2), NULL, &err)); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  v_cl = CL_CHECK_ERR(clCreateBuffer(context, CL_MEM_READ_WRITE, (MODEL_WIDTH / 2) * (MODEL_HEIGHT / 2), NULL, &err)); | 
					 | 
					 | 
					 | 
					  v_cl = CL_CHECK_ERR(clCreateBuffer(context, CL_MEM_READ_WRITE, (MODEL_WIDTH / 2) * (MODEL_HEIGHT / 2), NULL, &err)); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  net_input_cl = CL_CHECK_ERR(clCreateBuffer(context, CL_MEM_READ_WRITE, MODEL_FRAME_SIZE * sizeof(float), NULL, &err)); | 
					 | 
					 | 
					 | 
					  net_input_cl = CL_CHECK_ERR(clCreateBuffer(context, CL_MEM_READ_WRITE, MODEL_FRAME_SIZE * sizeof(uint8_t), NULL, &err)); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  transform_init(&transform, context, device_id); | 
					 | 
					 | 
					 | 
					  transform_init(&transform, context, device_id); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  loadyuv_init(&loadyuv, context, device_id, MODEL_WIDTH, MODEL_HEIGHT); | 
					 | 
					 | 
					 | 
					  loadyuv_init(&loadyuv, context, device_id, MODEL_WIDTH, MODEL_HEIGHT); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					} | 
					 | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					float* ModelFrame::prepare(cl_mem yuv_cl, int frame_width, int frame_height, int frame_stride, int frame_uv_offset, const mat3 &projection, cl_mem *output) { | 
					 | 
					 | 
					 | 
					uint8_t* ModelFrame::prepare(cl_mem yuv_cl, int frame_width, int frame_height, int frame_stride, int frame_uv_offset, const mat3 &projection, cl_mem *output) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  transform_queue(&this->transform, q, | 
					 | 
					 | 
					 | 
					  transform_queue(&this->transform, q, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                yuv_cl, frame_width, frame_height, frame_stride, frame_uv_offset, | 
					 | 
					 | 
					 | 
					                yuv_cl, frame_width, frame_height, frame_stride, frame_uv_offset, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                y_cl, u_cl, v_cl, MODEL_WIDTH, MODEL_HEIGHT, projection); | 
					 | 
					 | 
					 | 
					                y_cl, u_cl, v_cl, MODEL_WIDTH, MODEL_HEIGHT, projection); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -27,8 +27,8 @@ float* ModelFrame::prepare(cl_mem yuv_cl, int frame_width, int frame_height, int | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  if (output == NULL) { | 
					 | 
					 | 
					 | 
					  if (output == NULL) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    loadyuv_queue(&loadyuv, q, y_cl, u_cl, v_cl, net_input_cl); | 
					 | 
					 | 
					 | 
					    loadyuv_queue(&loadyuv, q, y_cl, u_cl, v_cl, net_input_cl); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    std::memmove(&input_frames[0], &input_frames[MODEL_FRAME_SIZE], sizeof(float) * MODEL_FRAME_SIZE); | 
					 | 
					 | 
					 | 
					    std::memmove(&input_frames[0], &input_frames[MODEL_FRAME_SIZE], sizeof(uint8_t) * MODEL_FRAME_SIZE); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    CL_CHECK(clEnqueueReadBuffer(q, net_input_cl, CL_TRUE, 0, MODEL_FRAME_SIZE * sizeof(float), &input_frames[MODEL_FRAME_SIZE], 0, nullptr, nullptr)); | 
					 | 
					 | 
					 | 
					    CL_CHECK(clEnqueueReadBuffer(q, net_input_cl, CL_TRUE, 0, MODEL_FRAME_SIZE * sizeof(uint8_t), &input_frames[MODEL_FRAME_SIZE], 0, nullptr, nullptr)); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    clFinish(q); | 
					 | 
					 | 
					 | 
					    clFinish(q); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    return &input_frames[0]; | 
					 | 
					 | 
					 | 
					    return &input_frames[0]; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  } else { | 
					 | 
					 | 
					 | 
					  } else { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |