Have you wrapped the code that writes the input frame with DMA_BUF_IOCTL_SYNC, or just the output frame?
Yes, performing DMA_BUF_IOCTL_SYNC when populating the buffer and also when reading it back:
Code:
int main(){ EglDmaBufTest e; e.init(); e.makeBuffers(); struct dma_buf_sync dma_sync {}; int ret; { const char *filePath = "/home/pi/placeholder.raw"; size_t width = 4064; size_t height = 2160; size_t bytesPerPixel = 2; size_t expectedSize = width * height * bytesPerPixel; // Open the file FILE *file = fopen(filePath, "rb"); if (file == NULL) { perror("Failed to open the RAW file"); return 1; } dma_sync.flags = DMA_BUF_SYNC_START | DMA_BUF_SYNC_WRITE; ret = ::ioctl(e.buffers[0].fd, DMA_BUF_IOCTL_SYNC, &dma_sync); // Read the file content into the image buffer size_t bytesRead = fread(e.buffers[0].data, 1, expectedSize, file); if (bytesRead != expectedSize) { fprintf(stderr, "Error: Expected %zu bytes, but read %zu bytes\n", expectedSize, bytesRead); fclose(file); return 1; } dma_sync.flags = DMA_BUF_SYNC_END | DMA_BUF_SYNC_WRITE; ret = ::ioctl(e.buffers[0].fd, DMA_BUF_IOCTL_SYNC, &dma_sync); // Close the file fclose(file); } e.compute(); { dma_sync.flags = DMA_BUF_SYNC_START | DMA_BUF_SYNC_READ; ret = ::ioctl(e.buffers[1].fd, DMA_BUF_IOCTL_SYNC, &dma_sync); mmap_to_file(e.buffers[1].data, e.buffers[1].size, "output_image.bin"); dma_sync.flags = DMA_BUF_SYNC_END | DMA_BUF_SYNC_READ; ret = ::ioctl(e.buffers[1].fd, DMA_BUF_IOCTL_SYNC, &dma_sync); } return 0;}
Statistics: Posted by cpdev — Fri Nov 22, 2024 6:39 pm