[MPlayer-dev-eng] [PATCH] v4l grabbing with more than two buffers

Carsten Schultz carsten at gnocchi.dialup.fu-berlin.de
Sun Dec 29 23:08:21 CET 2002


Hi everybody,

this is my first message here, so let me first thank everyone here for
MPlayer!

So far, when v4l offered more than two buffers for grabbing, these
were used, but never more than two at once, so grabbing wasn't any
better than with only two buffers.

I fixed that, and now using four buffers (bttv module option:
gbuffers=4) makes a real difference on my machine.  I can (sometimes)
grab at 480x768 and encode with qscale=2, while, with two buffers,
mencoder misses frames even at lower resolutions and with low
bitrates.

I hope, that the format of the (very short) patch is correct.

A great 2003 to you!

Carsten

-- 
Carsten Schultz (2:40, 33:47), FB Mathematik, FU Berlin
http://www.math.fu-berlin.de/~cschultz/
PGP/GPG key on the pgp.net key servers, 
fingerprint on my home page.
-------------- next part --------------
diff -Naur MPlayer-20021229/libmpdemux/tvi_v4l.c MPlayer-20021229-cas/libmpdemux/tvi_v4l.c
--- MPlayer-20021229/libmpdemux/tvi_v4l.c	Sat Dec 28 23:57:39 2002
+++ MPlayer-20021229-cas/libmpdemux/tvi_v4l.c	Sun Dec 29 22:18:41 2002
@@ -9,6 +9,9 @@
   Multithreading, a/v sync and native ALSA support by
     Jindrich Makovicka <makovick at kmlinux.fjfi.cvut.cz>
 
+  Modifications for grabbing with !=2 buffers by
+    Carsten Schultz <cschultz at math.fu-berlin.de>
+
   CODE IS UNDER DEVELOPMENT, NO FEATURE REQUESTS PLEASE!
 */
 
@@ -1224,19 +1227,19 @@
     priv_t *priv = (priv_t*)data;
     struct timeval curtime;
     long long skew, prev_skew, xskew, interval, prev_interval;
-    int frame, nextframe;
+    int frame;
     int i;
     int first = 1;
     int framecount;
 
     /* start the capture process */
-    if (ioctl(priv->video_fd, VIDIOCMCAPTURE, &priv->buf[0]) == -1)
-    {
-	mp_msg(MSGT_TV, MSGL_ERR, "\nioctl mcapture failed: %s\n", strerror(errno));
+
+    for (i=0; i < priv->nbuf; i++) {
+	if (ioctl(priv->video_fd, VIDIOCMCAPTURE, &priv->buf[i]) == -1)
+	{
+	    mp_msg(MSGT_TV, MSGL_ERR, "\nioctl mcapture failed: %s\n", strerror(errno));
+	}
     }
-    while (ioctl(priv->video_fd, VIDIOCSYNC, &priv->buf[1].frame) < 0 &&
-	   (errno == EAGAIN || errno == EINTR));
-    mp_dbg(MSGT_TV, MSGL_DBG3, "\npicture sync failed\n");
 
     prev_interval = 0;
     prev_skew = 0;
@@ -1255,14 +1258,7 @@
 	    }
 		
 	    frame = i;
-	    nextframe = (i+1)%priv->nbuf;
-	    
-	    if (ioctl(priv->video_fd, VIDIOCMCAPTURE, &priv->buf[nextframe]) == -1)
-	    {
-		mp_msg(MSGT_TV, MSGL_ERR, "\nioctl mcapture failed: %s\n", strerror(errno));
-		continue;
-	    }
-	    
+
 	    while (ioctl(priv->video_fd, VIDIOCSYNC, &priv->buf[frame].frame) < 0 &&
 		   (errno == EAGAIN || errno == EINTR));
 	    mp_dbg(MSGT_TV, MSGL_DBG3, "\npicture sync failed\n");
@@ -1355,6 +1351,12 @@
 		priv->video_cnt++;
 	    }
 
+	    if (ioctl(priv->video_fd, VIDIOCMCAPTURE, &priv->buf[frame]) == -1)
+	    {
+		mp_msg(MSGT_TV, MSGL_ERR, "\nioctl mcapture failed: %s\n", strerror(errno));
+		continue;
+	    }
+
 	}
 
     }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 240 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20021229/7d23f2a2/attachment.pgp>


More information about the MPlayer-dev-eng mailing list