This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Capture using one buffer

I need to capture a single frame from a 5Mpixel image sensor on DM355. The idea is that I capture and compress (JPEG) one frame at a time. This application could require only one buffer of 5Mbytes (for raw frame). IPIPEing and JPEGging could be done in small steps/chunks. So the whole process would be relatively fast since when running IPIPE, CPU is not doing anything and might as well be JPEGging something. In this case I would need only about 7Mbytes or so: 5Mbytes for raw Bayer data, two 1Mbyte (or even 512K) buffers for ping-ponging between IPIPE and JPEG encoder and one small circular buffer for JPEG output. And yes, I would use separate threads to handle JPEG and IPIPE. This could be fast, small, and sweet. One problem though.

I am not sure how to capture one frame from the VPFE driver. Most examples I've seen use tree buffers queued up in the capture buffer.  VIDIOC_DQBUF is used to get one buffer out and shortly after VIDIOC_QBUF is used to put it back in the queue. This way the driver always has a buffer to store the next frame. It's fine and dandy if you are capturing video. In my case I need to capture only one frame and having multiple buffers seems unnecessary and waists precious memory bytes. I tried using only one buffer but the code was getting stuck on VIDIOC_DQBUF. First, I queue the buffer, then tell image sensor to spit out the frame, then try DQBUF the buffer and this is where it hangs. To make sure that data was coming out, I tried video mode. Still was getting stuck. As soon as I tried two buffers it worked.

The question is: how to use capture driver/device (/dev/video0)  with just one buffer?

  • Hello,

    Not sure if using one buffer is possible unless you modify v4l2 driver in kernel. Conceptually driver maintains two buffer queues, an incoming and an outgoing queue and the minimum and maximum number of buffers can be queried by using REQBUF ioctl. IIRC, the minimum buffer is 3 and thats why you see that most of application use this as number.  You can refer v4l2 spec for more information http://v4l2spec.bytesex.org/spec/x5791.htm

    HTH.

    Thanks

    Brijesh