changeset 7962:1d2d47aa8717

some card/mobo combos can't handle buffers larger than 128kB, we change the default buffer to 128kB, add warnings if the buffer becomes full, add a commandline option to enlarge the buffer and give suggestions to users to lessen the buffer size requirements (lower quality/resolution). 128kB should, however, be enough for everybody :-). Bug reported by Brain Edmonds, cause explained (to allow me to fix the driver) by Ronald Bultje (mjpegtools developer)
author rik
date Tue, 29 Oct 2002 19:06:26 +0000
parents 78e0f2776da7
children 0a5d69e6f2a2
files libvo/vo_zr.c
diffstat 1 files changed, 22 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/vo_zr.c	Tue Oct 29 18:51:52 2002 +0000
+++ b/libvo/vo_zr.c	Tue Oct 29 19:06:26 2002 +0000
@@ -66,6 +66,7 @@
 	char *device;		/* /dev/video1 */
 	int bw;			/* if bw == 1, display in black&white */
 	int norm;	 	/* PAL/NTSC */
+	int buffer_size;	/* MJPEG buffer size */
 
 	/* buffers + pointers + info */
 
@@ -90,20 +91,20 @@
 } zr_info_t;
 
 static zr_info_t zr_info[ZR_MAX_DEVICES] = {
-	{1, 1, 1, -1, -1, 2, {0, 0, 0, 0, 0}, NULL, 0, VIDEO_MODE_AUTO, NULL, 0, 0, 0, 0, 0, 
+	{1, 1, 1, -1, -1, 2, {0, 0, 0, 0, 0}, NULL, 0, VIDEO_MODE_AUTO, 128, NULL, 0, 0, 0, 0, 0, 
 	0, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-	{1, 1, 1, -1, -1, 2, {0, 0, 0, 0, 0}, NULL, 0, VIDEO_MODE_AUTO, NULL, 0, 0, 0, 0, 0, 
+	{1, 1, 1, -1, -1, 2, {0, 0, 0, 0, 0}, NULL, 0, VIDEO_MODE_AUTO, 128, NULL, 0, 0, 0, 0, 0, 
 	0, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-	{1, 1, 1, -1, -1, 2, {0, 0, 0, 0, 0}, NULL, 0, VIDEO_MODE_AUTO, NULL, 0, 0, 0, 0, 0, 
+	{1, 1, 1, -1, -1, 2, {0, 0, 0, 0, 0}, NULL, 0, VIDEO_MODE_AUTO, 128, NULL, 0, 0, 0, 0, 0, 
 	0, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-	{1, 1, 1, -1, -1, 2, {0, 0, 0, 0, 0}, NULL, 0, VIDEO_MODE_AUTO, NULL, 0, 0, 0, 0, 0, 
+	{1, 1, 1, -1, -1, 2, {0, 0, 0, 0, 0}, NULL, 0, VIDEO_MODE_AUTO, 128, NULL, 0, 0, 0, 0, 0, 
 	0, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
 
 
 
 
 #define MJPEG_NBUFFERS	2
-#define MJPEG_SIZE	1024*256
+/*#define MJPEG_SIZE	1024*128*/
 
 
 int zoran_getcap(zr_info_t *zr) {
@@ -224,7 +225,7 @@
 	}
 
 	zrq.count = MJPEG_NBUFFERS;
-	zrq.size = MJPEG_SIZE;
+	zrq.size = 1024*zr->buffer_size;
 
 	if (ioctl(zr->vdes, MJPIOC_REQBUFS, &zrq)) {
 		mp_msg(MSGT_VO, MSGL_ERR, "zr: error requesting %d buffers of size %d\n", zrq.count, zrq.size);
@@ -500,7 +501,9 @@
 			k+=jpeg_enc_frame(zr->j, zr->y_data + i*zr->y_stride, 
 					zr->u_data + i*zr->u_stride, 
 					zr->v_data + i*zr->v_stride, 
-					zr->buf+zr->frame*MJPEG_SIZE+k);
+					zr->buf+
+					1024*zr->frame*zr->buffer_size+k);
+		if (k > 1024*zr->buffer_size) mp_msg(MSGT_VO, MSGL_WARN, "zr: jpeg image too large or buffer size too small, try -zrbsize 256. If your\nmotherboard/card combo can't handle that: lower the jpeg encoding quality\nor the resolution of the movie. Image may become distorted, MPlayer may crash.\nDon't bugreport, it is a known problem. The standard buffer size of 128kB\nshould be sufficient and is a safe-for-almost-all choice.\n");
 	}
 	/* Warning: Only the first jpeg image contains huffman- and 
 	 * quantisation tables, so don't expect files other than
@@ -693,6 +696,11 @@
 	if (i != 1 && i != 2 && i != 4) return ERR_OUT_OF_RANGE;
 	zr->hdec = i;
 	return 1;
+    }else if (!strcasecmp(opt, "zrbsize")) {
+        i = atoi(param);
+	if (i < 32) return ERR_OUT_OF_RANGE;
+	zr->buffer_size = i;
+	return 1;
     }else if (!strcasecmp(opt, "zrvdec")) {
         i = atoi(param);
 	if (i != 1 && i != 2 && i != 4) return ERR_OUT_OF_RANGE;
@@ -745,6 +753,11 @@
 		    "  -zrquality  jpeg compression quality [BEST] 1 - 20 [VERY BAD]\n"
 		    "  -zrdev      playback device (example -zrdev /dev/video1)\n"
 		    "  -zrnorm     specify norm PAL/NTSC (default: leave at current setting)\n"
+		    "  -zrbsize    set the MPJEG buffer size to a number of kilobytes (def. 128)\n"
+		    "              use this if MPlayer complains about the MJPEG buffer size\n"
+		    "              being too small, 256kB is recommended. If your card/mobo\n"
+		    "              doesn't allow buffers > 128kB lower the jpeg encoding\n"
+		    "              quality or the resolution of the movie\n"
 		    "\n"
 		    "Cinerama support: additional occurances of -zrcrop activate cinerama mode,\n"
 		    "suppose you have a 704x272 movie, two DC10+ cards and two beamers (or tv's),\n"              
@@ -780,6 +793,8 @@
     zr->fd=0;
   else if (!strcasecmp(param, "zrcrop"))
     zr->g.set = zr->g.xoff = zr->g.yoff = 0;
+  else if (!strcasecmp(param, "zrbsize"))
+    zr->buffer_size = 128;
   else if (!strcasecmp(param, "zrhdec"))
     zr->hdec = 1;
   else if (!strcasecmp(param, "zrvdec"))