I want to convert (try to set red channel to 0) gstreamer buffer using cuda. There is a snippet of code:
__global__ void transform( guint8 *data, int width ){
uint x = (blockIdx.x * blockDim.x) + threadIdx.x;
uint y = (blockIdx.y * blockDim.y) + threadIdx.y;
uint pixPos = (y * width + x) * 4;
data[pixPos + 2] = 0; // BGRA format
}
void simple_transform( guint8 *data, int width, int height ){
guint8 *d_data;
guint8 size = width * height * 4;
checkCudaErrors( cudaMalloc( (void**)&d_data, size ) );
// copy original buffer into device
checkCudaErrors( cudaMemcpy( d_data, data, size, cudaMemcpyHostToDevice ) );
dim3 threads = dim3(8, 8);
dim3 blocks = dim3(width / threads.x, height / threads.y);
// execute kernel
transform<<< blocks, threads >>>( d_data, width );
// move back converted data to original buffer
checkCudaErrors( cudaMemcpy( data, d_data, size, cudaMemcpyDeviceToHost ) );
cudaFree( d_data );
}
The problem is that video shows without any changes. I want to see blue-green picture, but can't. Where is my mistake?