How does NvBufSurfaceMemTag affect the creation of a dma buffer?

NVIDIA Jetson Orin NX 16GB, Jetpack 5.1.2, L4T 35.4.1

I am try to write own realization nv_video_encoder. In begin I copy bgr image to argb NvBufSurface. Transfrom argb NvBufSurface to yuv NvBufSurface. After that I want to queue fd yuv NvBufSurface to output capture. And I don’t understand if it’s possible to do this. In Jetson Multimedia api sample 07_video_convert when allocate NvBufSurface use NvBufSurfaceTag_VIDEO_CONVERT. In sample 05_jpeg_encode use NvBufSurfaceTag_VIDEO_CONVERT and don’t use NvBufSurfaceTag_JPEG. In sample 00_video_decode use NvBufSurfaceTag_VIDEO_CONVERT and NvBufSurfaceTag_VIDEO_DEC. In sample 01_video_encode use NvBufSurfaceTag_VIDEO_ENC.

I also modify the 05_jpeg_encoder example to find the difference between tags. I change the perf loop to 3000, write the size of the encoded image in the console, try different memtag. And run with

./jpeg_encode ../../data/Picture/nvidia-logo.yuv 1920 1080 test.jpg --encode-fd --perf

Jpeg encoder always work. It encode image with different memtag. But output buffer size is 104690 with
NvBufSurfaceTag_VIDEO_CONVERT and 104589 with NvBufSurfaceTag_JPEG/ NvBufSurfaceTag_NONE/NvBufSurfaceTag_VIDEO_ENC. How does NvBufSurfaceMemTag affect dma buffer creation ? Can I use one NvBufSurface for output color convert and input 'output queue` in video encode ? Or I need create another NvBufSurface with different tag and copy it with NvBufSurfaceCopy ?

Sorry for the late response.

Is this still an issue to support? Any result can be shared?

Yep. I just want to fully understand what is NvBufSurfaceTag and which i need to set if I use one NvBufSurface for color transform and for encode with codec h264/h265/av1.

To reproduce different sizes in 05_jpeg_encoder:

  1. run sample with
./jpeg_encode ../../data/Picture/nvidia-logo.yuv 1920 1080 video_convert_tag.jpg
  1. change params.memtag to NvBufSurfaceTag_JPEG for src_dma_fd and dst_dma_fd
  2. run sample again
./jpeg_encode ../../data/Picture/nvidia-logo.yuv 1920 1080 with_jpeg_tag.jpg
  1. run ll for check size
104690  video_convert_tag.jpg
104589  video_jpeg_tag.jpg