Hi DaneLLL
Please note that I am first processing frame on CPU (i.e. accessing frames on CPU ) and then giving it to encoder via appsrc.
I am not sure, my method to map frame on CPU is right one. In code given in link above, this is how I am mapping camera from on CPU - (aaCamCapture.cpp)
char *m_datamem = (char *)mmap(NULL, fsize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, params.offset[0]);
char *m_datamemU = (char *)mmap(NULL, fsizeU,PROT_READ | PROT_WRITE, MAP_SHARED, fd, params.offset[1]);
char *m_datamemV = (char *)mmap(NULL, fsizeV,PROT_READ | PROT_WRITE, MAP_SHARED, fd, params.offset[2]);
If I write Y in a file -
fwrite(m_datamem, sizeof(char), fize, fp)
then display image as grayscale - it comes out fine. However when I write U and V also in same file like -
fwrite(m_datamem, sizeof(char), fize, fp)
fwrite(m_datamemU, sizeof(char), fizeU, fp)
fwrite(m_datamemV, sizeof(char), fizeV, fp)
then display image as yuv color image, the colors do not come out well. Could there be possibility of data partially stuck in CPU caches ? In that case DDR buffer will not get updated and encoder will not pick up right data .
Do I need to be using APIs like
int NvBufferMemMap (int dmabuf_fd, unsigned int plane, NvBufferMemFlags memflag, void **pVirtAddr);
int NvBufferMemSyncForCpu (int dmabuf_fd, unsigned int plane, void **pVirtAddr);
int NvBufferMemUnMap (int dmabuf_fd, unsigned int plane, void **pVirtAddr);
As you suggested in this thread -
https://devtalk.nvidia.com/default/topic/1025494/how-to-receive-csi-camera-frame-in-unified-memory-buffer/
Thanks