Setting y plane in nvivafilter using post_process

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.

Hi,

NV12 arrangement should like this:

Y01 Y02 Y03 Y04 Y05 Y06
Y07 Y08 Y09 Y10 Y11 Y12
Y13 Y14 Y15 Y16 Y17 Y18
Y19 Y20 Y21 Y22 Y23 Y24
U01 V01 U02 V02 U03 V03
U04 V04 U05 V05 U06 V06

You can check this sample to find how to access the Y plane with the pitch alignment:
https://github.com/dusty-nv/jetson-utils/blob/b337733d4f1000b87979cb982ced30445d42b5b3/cuda/cudaYUV-NV12.cu#L162

Thanks.

Thank you

I determined that pre-process conforms to the documented structure for NV12 (i.e. as you indicated in your comment)