I've been experimenting with adding an x-window monitoring the captured 
video to lavrec, and so have had to study
"The video capture loop" in lavrec_record() in liblavrec.c
carefully to hook in my video monitor code.

Anyway, I think there may be a bug in liblavrec.c - or else somthing I
don't understand.

(This may only apply to hardware mjpeg encoding; I use an LML33 zoran
card)

Starting at around line 2068 of liblavrec.c from mjpegtools-1.6.2
(CVS looks the same, although line numbers may be different),
a summary of the code looks like:

   while (settings->state == LAVREC_STATE_RECORDING) {
      /* sync on a frame */
      lavrec_sync_buffer(); /* ioctl(video_fd, MJPIOC_SYNC, b) */

        /* audio stuff */
        /* single-frame and time_lapse ignored for clarity */

        nfout = 1;

         /* Check if we have to insert/delete frames to stay in sync */
         if (info->sync_correction > 1) {
            if( stats.tdiff1 - stats.tdiff2 < -settings->sync_lim)
               nfout++;
            if( stats.tdiff1 - stats.tdiff2 > settings->sync_lim)
               nfout--;
         }

        /* write it out */
         if (info->software_encoding) {  /* omitted */
         } else if(write_frame && nfout > 0) {
                video_captured();  /* write frame to file nfout times */
                lavrec_queue_buffer();  
                        /* ioctl(video_fd, MJPIOC_QBUF_CAPT, b.frame) */
     }



Shouldn't a recording application always re-queue every frame-buffer that
ioctl(MPJIO_SYNC) reports back by eventually calling MPJIOC_QBUF_CAPT on 
the buffer after it processed it?  


If the audio sync correction code above deletes a frame (by decrementing
nfout to 0), it looks like that frame will never get re-queued with
ioctl(MPJIOC_QBUF_CAPT) because the lavrec_queue_buffer() call is inside
the "if(write_frame && nfout > 0) {"
Won't that buffer then be unused from then on, sort of a leak?

If all this is correct, the fix seems obvious - always requeue the buffer,
even if it wasn't written out to the file.

Does this make sense to Ronald or anyone?  
Or am I all wet about how this works?  

I'm currently doing some long captures to see if I can test all this.

Steve


-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE
FREE OODBMS DOWNLOAD - A multidimensional database that combines
robust object and relational technologies, making it a perfect match
for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8
_______________________________________________
Mjpeg-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mjpeg-users

Reply via email to