Creating Cuda Filter for GStreamer with RGBA IN/OUT and Zero Copy

HI Folks,

I have a 3D table image processing kernel and associated software I made using Cuda. Now I want to write a plugin(filter) that takes in RGBA video, do the processing and output RGBA video. I would like this to be zero copy. Where is there an example of how to use Cuda for a filter and get the image data passed in to the filter. Is there an example of a Cuda filter I can use as a template?

Hi,
Please try nvivafilter. The following link is a sample of applying alpha effect:
https://devtalk.nvidia.com/default/topic/1046218/jetson-tx2/unable-to-overlay-text-when-using-udpsrc-/post/5310313/#5310313

Here is the inspect results. Does that mean if will provide RGBA data for the cuda processing in the custom library? I need RGBA input for our cuda processing. Thanks, Tom

Pad Templates:
SRC template: ‘src’
Availability: Always
Capabilities:
video/x-raw(memory:NVMM)
format: { (string)NV12, (string)RGBA }
width: [ 1, 2147483647 ]
height: [ 1, 2147483647 ]
framerate: [ 0/1, 2147483647/1 ]

SINK template: ‘sink’
Availability: Always
Capabilities:
video/x-raw(memory:NVMM)
format: { (string)I420, (string)NV12 }
width: [ 1, 2147483647 ]
height: [ 1, 2147483647 ]
framerate: [ 0/1, 2147483647/1 ]

Quick followup. If using niviafilter is appropriate how do I get the width and height of the image?
Sample doesn’t show how that can be done in the cuda processing code. Thanks. Tom

Concerning the pre and post functions I’m assuming the parameters passed to them can’t be changed is that correct? I’m also assuming they are called only once for the life of the filter element versus the cuda processing function which is called every time a frame is available. Thanks. Tom

Hi Folks,

Got my plugin working. Here is what I found out.

1. You can get the width and height from the EGLFrame object directly.

2. The pre and post processing appear to take place just once for the life of the plugin.

3. Zero copy is standard if you can use the image memory as both input and output(in place processing).

4. The cuda processing can receive the image data as RGBA if you add the format after the plugin on the pipeline command line.

Hi Folks,

The alpha reference helped me with the zero copy question and I believe also has info on getting the image width and height.

Hi,
Good to hear that you work it out. You can get width, height, and more information in CUeglFrame.
https://docs.nvidia.com/cuda/cuda-driver-api/structCUeglFrame.html#structCUeglFrame