AnsweredAssumed Answered

Execute OpenCL Kernel from Gstreamer Plugin

Question asked by Ankit Patel on Nov 7, 2014
Latest reply on Mar 17, 2015 by Andre Silva

Hi All,

Is it possible to execute OpenCL ' Kernel from Gstreamer Plugin during running Gstreamer pipeline?

I want to use OpenCL from gstreamer plugin while running any video through gst-launch.

I am adding one sample Gstreamer Plugin (e.g. sampleocl-plugin) into the Gstreamer Pipeline. From 'sampleocl-plugin' i am creating OpenCL Context, creating two Image2D memory object using clCreateImage2D, creating & loading kernel, creating command queue, setargs for kernel (clSetKernelArg(.....,  &srcimage2D)  , clSetKernelArg(...., &dstimage3D)).

Then executing kernel clEnqueueNDRangeKernel with 2 dimensional NDRangeKernel, global work size set to global[0]=640, global[1]=480. & wait for completion of execution of kernel.

 

My kernel is simply doing memcpy from SRC image to DST image.

code snippet of kernel is :

////////////// START

__constant sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;

_kernel void copy_image (

__read_only image2d_t input,

__write_only image2d_t output)

{

  const int2 pos = {get_global_id(0), get_global_id(1)};

  float4 sum = read_imagef(input, sampler, pos);

  write_imagef (output, (int2)(pos.x, pos.y), sum);

}

/////////////// END

 

What i am observed here that, after completion of my kernel execution, i received only one pixel from SRC image to DST image & i.e from (x=0,y=0) only.

All global Work Items  {global[0]=640, global[0]=480 } MUST execute same Kernel & result MUST all pixels copied from SRC to DST.

 

I have done/ executed exactly same thing from one simple unit test (executable file), & its working fine. I received entire SRC image in DST image.

 

In gstreamer, only one pixel copied ? Is something wrong ?

Or any other way should i execute OpenCL from gstreamer ?

 

I am using YOCTO build system.

 

 

-Ankit.

Outcomes