The nvsample_cudaprocess.cu provides sample code that overlays a green box on the video by manipulating the UV plane.
I am having difficulty manipulating the Y plane (using the NV12 format)
sformat[0] is equal to COLOR_FORMAT_Y8 (as expected)
The y plane is then accessed via sBaseAddr[0]
The documentation I have found indicates it should be a contiguous sequence of bytes, one per pixel.
That is obviously incorrect
The following works (apart from a excess pixel on the right of the block)
post_process(void **sBaseAddr
...
char * yp = NULL;
if (sformat[0] == COLOR_FORMAT_Y8) {
yp = (char *)sBaseAddr[0];
for (y = 0; y < BOX_H * 2; ++y) {
for (x = 0; x < BOX_W * 2; ++x) {
yp[(y + BOX_H * 4) * spitch[0] + (x + BOX_W * 4)] = 255;
yp[(y + 1 + BOX_H * 4) * spitch[0] + (x + BOX_W * 4)] = 255;
yp[(y + BOX_H * 4) * spitch[0] + (x + 1 + BOX_W * 4)] = 255;
yp[(y + 1 + BOX_H * 4) * spitch[0] + (x + 1 + BOX_W * 4)] = 255;
}
}
}
I was looking for documentation and/or code that explained this layout.