Corrupted images using mapbuffer with libargus.

UniqueObj<Frame> frame(iFrameConsumer->acquireFrame());
IFrame *iFrame = interface_cast<IFrame>(frame);
Image *image = iFrame->getImage();

IImage2D *iImage2D = interface_cast<IImage2D>(image);
Argus::Size size = iImage2D->getSize();

IImage *iImage = interface_cast<IImage>(image);

int fd = open("./dump.yuv", O_RDWR | O_CREAT | O_TRUNC, S_IRWXU | S_IRWXG | S_IRWXO);

for (int i = 0; i < iImage->getBufferCount(); ++i)
{
    int ssize = size.height * size.width;
    if (i > 0)
    {
        ssize = size.height * size.width / 4;
    }
    write(fd, static_cast<const uint8_t *>(iImage->mapBuffer(i, NULL)), ssize);
}
close(fd);

Using the code above i get corrupted yuv420 images.

Example: https://www.dropbox.com/s/nuvq8ekwdmtehep/Screenshot_20170314_144251.png?dl=0

writeJPEG gives correct results. How can i copy images from libargus to cpu for processing?

Hi alex,
We will do further check on this case.

Besides, there are new functions on next BSP release:
https://devtalk.nvidia.com/default/topic/996666/jetson-tx1/msync-with-ms_sync-option-failure/post/5101903/#5101903

Hi alex
There are HW mapped buffers, so if you directly CPU access them, you will have problems due to cache management. Could you tell what’s purpose to dump the YUV data here. There’s an argument that CPU access to these things is generally a bad idea for perf and memory BW so we might not want to make this easy.

Hi
Before dump the buffer please convert it to V4L2_NV_BUFFER_LAYOUT_PITCH first.
“V4L2 Video Converter” MM API can be used to convert V4L2_NV_BUFFER_LAYOUT_BLOCKLINEAR to V4L2_NV_BUFFER_LAYOUT_PITCH. (Refer partner-samples/multimedia_api/ll_samples/samples/07_video_convert)
nvbuf_utils provide APIs NvBufferMemMap/NvBufferMemSyncForCpu for CPU access of HW buffers. (Refer multimedia/utils/nvbuf_utils/nvbuf_utils.h)