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 driver confict with codec engine?

Hi all:

           I found that capture driver will confict with encode, here is my test case for you reference:

          Case #1: get buffer and encode at the same thread work well

                   /* determine ready buffer */
                   rc = ioctl(Me->raw.capture_fd, VIDIOC_DQBUF, &buf);

                  /* encode the frame by raw data*/
                  .....
                  VIDENC1_process()
                  .....

 

                   /* return the buffer to driver */
                   rc = ioctl(Me->raw.capture_fd, VIDIOC_QBUF, &buf);

          Case #2: get buffer at thread #1 and encode at thread #2,  we will got error when call ioctl() in thread #1

                   /* determine ready buffer */
                   rc = ioctl(Me->raw.capture_fd, VIDIOC_DQBUF, &buf);

                   /* wake up encode thread */

 

                   /* return the buffer to driver */
                   rc = ioctl(Me->raw.capture_fd, VIDIOC_QBUF, &buf);

                  /* encode the frame by raw data*/
                  .....
                  VIDENC1_process()
                  .....

 

                 Anyone who can help on this?
 

  • Tracy,

    The demo code in DVSDK already has implementation like your case #2. We use two threads, one for capture and other for encode. You can refer to the encode demo.

     

    Does your error come in the first DQBUF itself?

    Regards,

    Anshuman

  • HI Anshuman:

          Appreciate for you help!

          The demo code in DVSDK support encode and capture in different thread, but that can't match my request, in capture thead the "VIDIOC_DQBUF" and "VIDIOC_QBUF" is in group, the sequence is:

                 VIDIOC_DQBUF -> VIDIOC_QBUF -> VIDIOC_DQBUF ->VIDIOC_QBUF->....

         When I try to change the sequence to :

                 VIDIOC_DQBUF -> VIDIOC_DQBUF  -> VIDIOC_DQBUF -> VIDIOC_DQBUF -> VIDIOC_QBUF -> VIDIOC_QBUF -> VIDIOC_DQBUF

         We may got error under some case, right?

         BTW, when i try to add select before ioctl, i found that the encode performance is bad, under normal case the VIDENC1_process() may cost 27 milliseconds on encode 720P frame, when add select at the same time, it will cost 29 milliseconds, so i guess there may be some resource conflict between encode and capture.

  • Hi Tracy,

    I have not tested your sequence, but one thing to note is that you cannot dequeue all the buffers from capture driver. Ideally, you should be queueuing all the buffers and then for every dequeue, you should put one buffer in the queue. Only for the first time, you might be doing two dequeues before doing a queue.

    In case your consumer of the capture buffer is slower in performance, it might happen that you might be dequeuing faster than queue, but then at one point of time your dequeue will start failing to give you any more buffer till you queue.

    For your question on VIDENC1_process taking more time with select, i dont see any reason why encoder performance would be slower other than

    1. OS thread for encoder is getting switched out more often

     

    Regards,

    Anshuman