diff --git a/libvo/vo_zr.c b/libvo/vo_zr.c index 368141bb68..912735231f 100644 --- a/libvo/vo_zr.c +++ b/libvo/vo_zr.c @@ -66,6 +66,7 @@ typedef struct { 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 @@ typedef struct { } 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 @@ int init_zoran(zr_info_t *zr, int stretchx, int stretchy) { } 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 @@ static void flip_page (void) { 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 @@ vo_zr_parseoption(struct config * conf, char *opt, char *param){ 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 @@ vo_zr_parseoption(struct config * conf, char *opt, char *param){ " -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 @@ void vo_zr_revertoption(config_t* opt,char* param) { 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"))