wangfei | 1a7d9f3 | 2015-03-26 18:30:00 +0800 | [diff] [blame] | 1 | /* |
| 2 | * function: kernel_csc_rgbatonv12 |
| 3 | * input: image2d_t as read only |
| 4 | * output: image2d_t as write only |
| 5 | * vertical_offset, vertical offset from y to uv |
| 6 | */ |
| 7 | |
| 8 | "__kernel void kernel_csc_rgbatonv12 (__read_only image2d_t input, __write_only image2d_t output, uint vertical_offset) " |
| 9 | "{ " |
| 10 | " int x = get_global_id (0); " |
| 11 | " int y = get_global_id (1); " |
| 12 | " sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_NONE | CLK_FILTER_NEAREST; " |
| 13 | " float4 pixel_in1 = read_imagef(input, sampler, (int2)(2*x,2*y)); " |
| 14 | " float4 pixel_in2 = read_imagef(input, sampler, (int2)(2*x+1,2*y)); " |
| 15 | " float4 pixel_in3 = read_imagef(input, sampler, (int2)(2*x,2*y+1)); " |
| 16 | " float4 pixel_in4 = read_imagef(input, sampler, (int2)(2*x+1,2*y+1)); " |
| 17 | " float4 pixel_out_y1,pixel_out_y2,pixel_out_y3,pixel_out_y4,pixel_out_u,pixel_out_v; " |
| 18 | " pixel_out_y1.x = 0.3*pixel_in1.x + 0.59*pixel_in1.y + 0.11*pixel_in1.z; " |
| 19 | " pixel_out_y1.y = 0.0; " |
| 20 | " pixel_out_y1.z = 0.0; " |
| 21 | " pixel_out_y1.w= 1.0; " |
| 22 | " pixel_out_y2.x = 0.3*pixel_in2.x + 0.59*pixel_in2.y + 0.11*pixel_in2.z; " |
| 23 | " pixel_out_y2.y = 0.0; " |
| 24 | " pixel_out_y2.z = 0.0; " |
| 25 | " pixel_out_y2.w= 1.0; " |
| 26 | " pixel_out_y3.x = 0.3*pixel_in3.x + 0.59*pixel_in3.y + 0.11*pixel_in3.z; " |
| 27 | " pixel_out_y3.y = 0.0; " |
| 28 | " pixel_out_y3.z = 0.0; " |
| 29 | " pixel_out_y3.w= 1.0; " |
| 30 | " pixel_out_y4.x = 0.3*pixel_in4.x + 0.59*pixel_in4.y + 0.11*pixel_in4.z; " |
| 31 | " pixel_out_y4.y = 0.0; " |
| 32 | " pixel_out_y4.z = 0.0; " |
| 33 | " pixel_out_y4.w= 1.0; " |
| 34 | " pixel_out_u.x = (0.493*(pixel_in1.z - (0.3*pixel_in1.x + 0.59*pixel_in1.y + 0.11*pixel_in1.z))*255.0 +128.0)/255.0; " |
| 35 | " pixel_out_u.y = 0.0; " |
| 36 | " pixel_out_u.z = 0.0; " |
| 37 | " pixel_out_u.w= 1.0; " |
| 38 | " pixel_out_v.x = (0.877*(pixel_in1.x - (0.3*pixel_in1.x + 0.59*pixel_in1.y + 0.11*pixel_in1.z))*255.0 +128.0)/255.0; " |
| 39 | " pixel_out_v.y = 0.0; " |
| 40 | " pixel_out_v.z = 0.0; " |
| 41 | " pixel_out_v.w= 1.0; " |
| 42 | " write_imagef(output, (int2)(2*x,2*y), pixel_out_y1); " |
| 43 | " write_imagef(output, (int2)(2*x+1,2*y), pixel_out_y2); " |
| 44 | " write_imagef(output, (int2)(2*x,2*y+1), pixel_out_y3); " |
| 45 | " write_imagef(output, (int2)(2*x+1,2*y+1), pixel_out_y4); " |
| 46 | " write_imagef(output, (int2)(2*x,y + vertical_offset), pixel_out_u); " |
| 47 | " write_imagef(output, (int2)(2*x+1,y + vertical_offset), pixel_out_v); " |
| 48 | "} " |
| 49 | |