It is extremely funny that the go4vl library advertises "zero-copy IO using memory mapped buffers" and yet explicitly calls copy() on each frame.
I think this can be remedied:
- Do not call
Start() at all. Instead, call InitBuffers and MapMemoryBuffers manually, by creating a custom FrameAllocator that does this and using that frame allocator for the v4l source
- The frame forwarder should be modified to allow more than one frame to be in the "writing" state
- The number of allocated frames should be split in two: some frames in the v4l writing queue (
Nw), and some frames available for readers (Nr)
- On source startup, get
Nw frames from the frame forwarder for writing and enqueue them into v4l
- On each dequeue, call
FinishedWriting on the frame, get a new frame for writing and enqueue it
This would basically be a zero-copy, sequential rewrite of the current v4l stream loop that should be much faster
It is extremely funny that the
go4vllibrary advertises "zero-copy IO using memory mapped buffers" and yet explicitly calls copy() on each frame.I think this can be remedied:
Start()at all. Instead, callInitBuffersandMapMemoryBuffersmanually, by creating a customFrameAllocatorthat does this and using that frame allocator for the v4l sourceNw), and some frames available for readers (Nr)Nwframes from the frame forwarder for writing and enqueue them into v4lFinishedWritingon the frame, get a new frame for writing and enqueue itThis would basically be a zero-copy, sequential rewrite of the current v4l stream loop that should be much faster