Hi,
I am writing a video pipeline which uses CUDA NPP to process images and then encodes them with the multimedia API. The input format for the encoder is multiplanar YUV420 and I have been trying to use NPP to work with YUV images directly (rather than converting them to RGB), however the encoded frames appears to have pitch issues which I believe to be caused by an issue with the cudaEglFrame
returned when mapping the buffer to CUDA.
I have created a testing pipeline which does the following;
- dequeues an output plane from the encoder (the plane is
MMAP
but exported as aDMABUF
) - calls
NvEGLImageFromFd
,cudaGraphicsEGLRegisterImage
, andcudaGraphicsResourceGetMappedEglFrame
to map the buffer as an EGL frame in CUDA - synchronize the CUDA device
- uses
nppiSet_8u_C1R
to set each of the planes to128 using theptr
,pitch
,xsize
, andysize
obtained from thecudaPitchedPtr
array of thecudaEglFrame
- synchronize the CUDA device
- unmaps the buffer with
cudaGraphicsUnregisterResource
andNvDestroyEGLImage
- enqueue the buffer to the encoder
This pipeline is supposed to return a constant grey image, however there are staggered green bars in the image indicating that there is a pitch problem in the call to nppiSet_8u_C1R
. The green bars are light green indicating that the Y plane was correctly set, but the UV planes had an issue with pitch.
My encoder is configured to encode 2160x1080
images, so I printed the xsize
, ysize
, and pitch
for each plane from the cudaPitchedPtr
and got 2160x1088(2304) 1080x544(1152) 1080x544(1152)
(note that UV pitch of 1152
is exactly half of the Y pitch of 2304
). I modified the test a little bit to draw a box in the corner and experimentally discovered that the image was correct when the UV planes had a pitch of 1280
instead of the 1152
in the cudaPitchedPtr
. For the next test, I halved the dimensions to 1080x540
and got the values from cudaPitchedPtr
of 1088x544(1280) 544x272(640) 544x272(640)
. Note that the pitch of the Y plane is 1280
and not 1152
even though the Y plane has dimensions 1088x544
which is the same as the UV planes from the previous test.
Based on this investigation, my best guess is that there is a bug where the pitch for UV is being reported as half the Y pitch rather than the actual pitch used in the allocation of the buffer. This test was run on a Jetson Nano with L4T r32.5.1.
Please let me know if there any more information required or if there is an issue with my test.
Thanks,
Kevin