2 * vo_zr.c - playback on zoran cards
3 * Copyright (C) Rik Snel 2001,2002, License GNU GPL v2
15 #include <sys/types.h>
18 #include <sys/ioctl.h>
19 #include <linux/types.h>
20 #include <linux/videodev.h>
21 #include "videodev_mjpeg.h"
25 #include "video_out.h"
26 #include "video_out_internal.h"
27 #include "../mp_msg.h"
28 #include "../m_option.h"
29 #include "fastmemcpy.h"
33 static vo_info_t info
=
35 "Zoran ZR360[56]7/ZR36060 Driver (DC10(+)/buz/lml33/MatroxRR)",
37 "Rik Snel <snel@phys.uu.nl>",
43 #define ZR_MAX_DEVICES 4
44 /* General variables */
54 static int zr_count
= 1;
55 static int zr_parsing
= 0;
59 /* commandline args given for this device (and defaults) */
60 int vdec
, hdec
; /* requested decimation 1,2,4 */
61 int fd
; /* force decimation */
62 int xdoff
, ydoff
; /* offset from upperleft of screen
63 * default is 'centered' */
64 int quality
; /* jpeg quality 1=best, 20=bad */
65 geo_t g
; /* view window (zrcrop) */
66 char *device
; /* /dev/video1 */
67 int bw
; /* if bw == 1, display in black&white */
68 int norm
; /* PAL/NTSC */
69 int buffer_size
; /* MJPEG buffer size */
71 /* buffers + pointers + info */
74 int image_width
, image_height
, size
;
75 int off_y
, off_c
, stride
; /* for use by 'draw slice/frame' */
77 unsigned char *buf
; /* the jpeg images will be placed here */
78 unsigned int buf_allocated
; /* size of the block actually allocated */
80 unsigned char *y_data
, *u_data
, *v_data
; /* used by the jpeg encoder */
81 int y_stride
, u_stride
, v_stride
; /* these point somewhere in image */
83 /* information for (and about) the zoran card */
85 int vdes
; /* file descriptor of card */
86 int frame
, synco
, queue
; /* buffer management */
87 struct mjpeg_sync zs
; /* state information */
88 struct mjpeg_params p
;
89 struct video_capability vc
; /* max resolution and so on */
90 int fields
, stretchy
; /* must the *image be interlaced
91 or stretched to fit on the screen? */
94 static zr_info_t zr_info
[ZR_MAX_DEVICES
] = {
95 {1, 1, 1, -1, -1, 2, {0, 0, 0, 0, 0}, NULL
, 0, VIDEO_MODE_AUTO
, 128, NULL
, 0, 0, 0, 0, 0,
96 0, NULL
, 0, NULL
, NULL
, NULL
, NULL
, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
97 {1, 1, 1, -1, -1, 2, {0, 0, 0, 0, 0}, NULL
, 0, VIDEO_MODE_AUTO
, 128, NULL
, 0, 0, 0, 0, 0,
98 0, NULL
, 0, NULL
, NULL
, NULL
, NULL
, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
99 {1, 1, 1, -1, -1, 2, {0, 0, 0, 0, 0}, NULL
, 0, VIDEO_MODE_AUTO
, 128, NULL
, 0, 0, 0, 0, 0,
100 0, NULL
, 0, NULL
, NULL
, NULL
, NULL
, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
101 {1, 1, 1, -1, -1, 2, {0, 0, 0, 0, 0}, NULL
, 0, VIDEO_MODE_AUTO
, 128, NULL
, 0, 0, 0, 0, 0,
102 0, NULL
, 0, NULL
, NULL
, NULL
, NULL
, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
107 #define MJPEG_NBUFFERS 2
108 /*#define MJPEG_SIZE 1024*128*/
111 int zoran_getcap(zr_info_t
*zr
) {
118 const char *devs
[] = {
130 if ((stat(devs
[i
], &vstat
) == 0) && S_ISCHR(vstat
.st_mode
))
133 mp_msg(MSGT_VO
, MSGL_V
, "zr: found video device %s\n", dev
);
136 } while (devs
[++i
] != NULL
);
140 mp_msg(MSGT_VO
, MSGL_ERR
, "zr: unable to find video device\n");
145 zr
->vdes
= open(dev
, O_RDWR
);
148 mp_msg(MSGT_VO
, MSGL_ERR
, "zr: error opening %s: %s\n",
149 dev
, strerror(errno
));
153 /* before we can ask for the maximum resolution, we must set
154 * the correct tv norm */
156 if (ioctl(zr
->vdes
, MJPIOC_G_PARAMS
, &zr
->p
) < 0) {
157 mp_msg(MSGT_VO
, MSGL_ERR
, "zr: device at %s is probably not a DC10(+)/buz/lml33\n", dev
);
161 if (zr
->p
.norm
!= zr
->norm
&& zr
->norm
!= VIDEO_MODE_AUTO
) {
162 /* attempt to set requested norm */
163 zr
->p
.norm
= zr
->norm
;
164 if (ioctl(zr
->vdes
, MJPIOC_S_PARAMS
, &zr
->p
) < 0) {
165 mp_msg(MSGT_VO
, MSGL_ERR
,
166 "zr: unable to change video norm, use another program to change it (XawTV)\n");
169 ioctl(zr
->vdes
, MJPIOC_G_PARAMS
, &zr
->p
);
170 if (zr
->norm
!= zr
->p
.norm
) {
171 mp_msg(MSGT_VO
, MSGL_ERR
,
172 "zr: unable to change video norm, use another program to change it (XawTV)\n");
177 if (ioctl(zr
->vdes
, VIDIOCGCAP
, &zr
->vc
) < 0) {
178 mp_msg(MSGT_VO
, MSGL_ERR
, "zr: error getting video capabilities from %s\n", dev
);
181 mp_msg(MSGT_VO
, MSGL_V
, "zr: MJPEG card reports maxwidth=%d, maxheight=%d\n", zr
->vc
.maxwidth
, zr
->vc
.maxheight
);
186 int init_zoran(zr_info_t
*zr
, int stretchx
, int stretchy
) {
187 struct mjpeg_requestbuffers zrq
;
188 /* center the image, and stretch it as far as possible (try to keep
189 * aspect) and check if it fits */
190 if (zr
->image_width
> zr
->vc
.maxwidth
) {
191 mp_msg(MSGT_VO
, MSGL_ERR
, "zr: movie to be played is too wide, max width currenty %d\n", zr
->vc
.maxwidth
);
195 if (zr
->image_height
> zr
->vc
.maxheight
) {
196 mp_msg(MSGT_VO
, MSGL_ERR
, "zr: movie to be played is too high, max height currenty %d\n", zr
->vc
.maxheight
);
200 zr
->p
.decimation
= 0;
201 zr
->p
.HorDcm
= stretchx
;
202 zr
->p
.VerDcm
= stretchy
;
204 zr
->p
.field_per_buff
= zr
->fields
;
205 if (zr
->xdoff
== -1) {
206 zr
->p
.img_x
= (zr
->vc
.maxwidth
-
207 zr
->p
.HorDcm
*(int)zr
->image_width
/zr
->hdec
)/2;
209 zr
->p
.img_x
= zr
->xdoff
;
211 if (zr
->ydoff
== -1) {
212 zr
->p
.img_y
= (zr
->vc
.maxheight
- zr
->p
.VerDcm
*
213 (3-zr
->fields
)*(int)zr
->image_height
)/4;
215 zr
->p
.img_y
= zr
->ydoff
;
217 zr
->p
.img_width
= zr
->p
.HorDcm
*zr
->image_width
/zr
->hdec
;
218 zr
->p
.img_height
= zr
->p
.VerDcm
*zr
->image_height
/zr
->fields
;
219 mp_msg(MSGT_VO
, MSGL_V
, "zr: geometry (after 'scaling'): %dx%d+%d+%d fields=%d, w=%d, h=%d\n", zr
->p
.img_width
, (3-zr
->fields
)*zr
->p
.img_height
, zr
->p
.img_x
, zr
->p
.img_y
, zr
->fields
, zr
->image_width
/zr
->hdec
, zr
->image_height
);
221 if (ioctl(zr
->vdes
, MJPIOC_S_PARAMS
, &zr
->p
) < 0) {
222 mp_msg(MSGT_VO
, MSGL_ERR
, "zr: error setting display parameters\n");
226 zrq
.count
= MJPEG_NBUFFERS
;
227 zrq
.size
= 1024*zr
->buffer_size
;
229 if (ioctl(zr
->vdes
, MJPIOC_REQBUFS
, &zrq
)) {
230 mp_msg(MSGT_VO
, MSGL_ERR
, "zr: error requesting %d buffers of size %d\n", zrq
.count
, zrq
.size
);
234 /* the buffer count allocated may be different to the request */
235 zr
->buf_allocated
= zrq
.count
* zrq
.size
;
236 zr
->buf
= (unsigned char*)mmap(0, zrq
.count
*zrq
.size
,
237 PROT_READ
|PROT_WRITE
, MAP_SHARED
, zr
->vdes
, 0);
239 if (zr
->buf
== MAP_FAILED
) {
240 mp_msg(MSGT_VO
, MSGL_ERR
, "zr: error requesting %d buffers of size %d\n", zrq
.count
, zrq
.size
);
250 void uninit_zoran(zr_info_t
*zr
) {
255 while (zr
->queue
> zr
->synco
+ 1) {
256 if (ioctl(zr
->vdes
, MJPIOC_SYNC
, &zr
->zs
) < 0)
257 mp_msg(MSGT_VO
, MSGL_ERR
, "zr: error waiting for buffers to become free\n");
262 if (ioctl(zr
->vdes
, MJPIOC_QBUF_PLAY
, &zr
->frame
) < 0)
263 mp_msg(MSGT_VO
, MSGL_ERR
, "zr: error stopping playback of last frame\n");
264 if (munmap(zr
->buf
,zr
->buf_allocated
))
265 mp_msg(MSGT_VO
, MSGL_ERR
, "zr: error unmapping buffer\n");
269 int zr_geometry_sane(geo_t
*g
, unsigned int width
, unsigned int height
) {
271 if (g
->width
%2 != 0 || g
->height
%2 != 0 ||
272 g
->xoff
%2 != 0 || g
->yoff
%2 != 0) {
273 mp_msg(MSGT_VO
, MSGL_ERR
, "zr: arguments in -zrcrop must be multiples of 2\n");
276 if (g
->width
<= 0 || g
->height
<= 0 ||
277 g
->xoff
< 0 || g
->yoff
< 0) {
278 mp_msg(MSGT_VO
, MSGL_ERR
, "zr: width and height must be positive and offset nonnegative\n");
281 if (g
->width
+ g
->xoff
> width
) {
282 mp_msg(MSGT_VO
, MSGL_ERR
, "zr: width+xoffset (%d+%d>%d) is too big\n", g
->width
, g
->xoff
, width
);
285 if (g
->height
+ g
->yoff
> height
) {
286 mp_msg(MSGT_VO
, MSGL_ERR
, "zr: height+yoffset (%d+%d>%d) is too big\n", g
->height
, g
->yoff
, height
);
300 static uint32_t config(uint32_t width
, uint32_t height
, uint32_t d_width
,
301 uint32_t d_height
, uint32_t fullscreen
, char *title
, uint32_t format
)
303 int i
, tmp
, stretchx
, stretchy
;
305 if (format
!= IMGFMT_YV12
&& format
!= IMGFMT_YUY2
) {
306 printf("vo_zr called with wrong format");
309 for (i
= 0; i
< zr_count
; i
++) {
310 zr_info_t
*zr
= &zr_info
[i
];
313 zr
->stride
= 2*width
;
314 if (zr_geometry_sane(g
, width
, height
)) return 1;
316 /* we must know the maximum resolution of the device
317 * it differs for DC10+ and buz for example */
318 zoran_getcap(zr
); /*must be called before init_zoran */
319 /* make the scaling decision
320 * we are capable of stretching the image in the horizontal
321 * direction by factors 1, 2 and 4
322 * we can stretch the image in the vertical direction by a
323 * factor of 1 and 2 AND we must decide about interlacing */
324 if (g
->width
> zr
->vc
.maxwidth
/2 ||
325 g
->height
> zr
->vc
.maxheight
/2) {
331 } else if (zr
->vdec
== 4) {
336 } else if (g
->width
> zr
->vc
.maxwidth
/4 ||
337 g
->height
> zr
->vc
.maxheight
/4) {
343 } else if (zr
->vdec
== 4) {
345 mp_msg(MSGT_VO
, MSGL_WARN
, "zr: vertical decimation too high, changing to 2 (use -zrfd to keep vdec=4)\n");
352 } else if (zr
->hdec
== 4){
354 mp_msg(MSGT_VO
, MSGL_WARN
, "zr: horizontal decimation too high, changing to 2 (use -zrfd to keep hdec=4)\n");
360 /* output image is maximally stretched */
364 if (zr
->vdec
!= 1 && !zr
->fd
) {
365 mp_msg(MSGT_VO
, MSGL_WARN
, "zr: vertical decimation too high, changing to 1 (use -zrfd to keep vdec=%d)\n", zr
->vdec
);
368 if (zr
->hdec
!= 1 && !zr
->fd
) {
369 mp_msg(MSGT_VO
, MSGL_WARN
, "zr: vertical decimation too high, changing to 1 (use -zrfd to keep hdec=%d)\n", zr
->hdec
);
373 /* It can be that the original frame was too big for display,
374 * or that the width of the decimated image (for example) after
375 * padding up to a multiple of 16 has become too big. (orig
376 * width 720 (exactly right for the Buz) after decimation 360,
377 * after padding up to a multiple of 16 368, display 736 -> too
378 * large). In these situations we auto(re)crop. */
379 tmp
= 16*((g
->width
- 1)/(zr
->hdec
*16) + 1);
380 if (stretchx
*tmp
> zr
->vc
.maxwidth
) {
381 g
->xoff
+= 2*((g
->width
- zr
->hdec
*(tmp
-16))/4);
382 /* g->off must be a multiple of 2 */
383 g
->width
= zr
->hdec
*(tmp
- 16);
384 g
->set
= 0; /* we abuse this field to
385 report that g has changed*/
387 tmp
= 8*zr
->fields
*((g
->height
- 1)/(zr
->vdec
*zr
->fields
*8)+1);
388 if (stretchy
*tmp
> zr
->vc
.maxheight
) {
389 g
->yoff
+= 2*((g
->height
- zr
->vdec
*
390 (tmp
- 8*zr
->fields
))/4);
391 g
->height
= zr
->vdec
*(tmp
- 8*zr
->fields
);
395 mp_msg(MSGT_VO
, MSGL_V
, "zr: auto(re)cropping %dx%d+%d+%d to make the image fit on the screen\n", g
->width
, g
->height
, g
->xoff
, g
->yoff
);
397 /* the height must be a multiple of fields*8 and the width
398 * must be a multiple of 16 */
399 /* add some black borders to make it so, and center the image*/
400 zr
->image_height
= zr
->fields
*8*((g
->height
/zr
->vdec
- 1)/
402 zr
->image_width
= (zr
->hdec
*16)*((g
->width
- 1)/(zr
->hdec
*16) + 1);
403 zr
->off_y
= (zr
->image_height
- g
->height
/zr
->vdec
)/2;
404 if (zr
->off_y
%2 != 0) zr
->off_y
++;
405 zr
->off_y
*= zr
->image_width
;
406 zr
->off_c
= zr
->off_y
/4;
407 zr
->off_y
+= (zr
->image_width
- g
->width
)/2;
408 if (zr
->off_y
%2 != 0) zr
->off_y
--;
409 zr
->off_c
+= (zr
->image_width
- g
->width
)/4;
410 zr
->size
= zr
->image_width
*zr
->image_height
;
411 mp_msg(MSGT_VO
, MSGL_V
, "zr: input: %dx%d, cropped: %dx%d, output: %dx%d, off_y=%d, off_c=%d\n", width
, height
, g
->width
, g
->height
, zr
->image_width
, zr
->image_height
, zr
->off_y
, zr
->off_c
);
413 zr
->image
= malloc(2*zr
->size
); /* this buffer allows for YUV422 data,
414 * so it is a bit too big for YUV420 */
416 mp_msg(MSGT_VO
, MSGL_ERR
, "zr: Memory exhausted\n");
419 /* and make sure that the borders are _really_ black */
422 memset(zr
->image
, 0, zr
->size
);
423 memset(zr
->image
+ zr
->size
, 0x80, zr
->size
/4);
424 memset(zr
->image
+ 3*zr
->size
/2, 0x80, zr
->size
/4);
425 zr
->y_data
= zr
->image
;
426 zr
->u_data
= zr
->image
+ zr
->size
;
427 zr
->v_data
= zr
->image
+ 3*zr
->size
/2;
429 zr
->y_stride
= zr
->image_width
;
430 zr
->u_stride
= zr
->image_width
/2;
431 zr
->v_stride
= zr
->image_width
/2;
433 zr
->j
= jpeg_enc_init(zr
->image_width
/zr
->hdec
,
434 zr
->image_height
/zr
->fields
,
435 zr
->hdec
, zr
->y_stride
*zr
->fields
,
436 zr
->hdec
, zr
->u_stride
*zr
->fields
,
437 zr
->hdec
, zr
->v_stride
*zr
->fields
,
438 1, zr
->quality
, zr
->bw
);
441 for (tmp
= 0; tmp
< 2*zr
->size
; tmp
+=4) {
443 zr
->image
[tmp
+1] = 0x80;
444 zr
->image
[tmp
+2] = 0;
445 zr
->image
[tmp
+3] = 0x80;
448 zr
->y_data
= zr
->image
;
449 zr
->u_data
= zr
->image
+ 1;
450 zr
->v_data
= zr
->image
+ 3;
452 zr
->y_stride
= 2*zr
->image_width
;
453 zr
->u_stride
= 2*zr
->image_width
;
454 zr
->v_stride
= 2*zr
->image_width
;
456 zr
->j
= jpeg_enc_init(zr
->image_width
/zr
->hdec
,
457 zr
->image_height
/zr
->fields
,
459 zr
->y_stride
*zr
->fields
,
461 zr
->u_stride
*zr
->fields
,
463 zr
->v_stride
*zr
->fields
,
464 0, zr
->quality
, zr
->bw
);
467 mp_msg(MSGT_VO
, MSGL_FATAL
, "zr: internal inconsistency in vo_zr\n");
472 mp_msg(MSGT_VO
, MSGL_ERR
, "zr: error initializing the jpeg encoder\n");
476 if (init_zoran(zr
, stretchx
, stretchy
)) {
484 static void draw_osd(void) {
487 static void flip_page (void) {
490 //char filename[100];
491 /* do we have a free buffer? */
492 for (j
= 0; j
< zr_count
; j
++) {
493 zr_info_t
*zr
= &zr_info
[j
];
494 if (zr
->queue
-zr
->synco
< MJPEG_NBUFFERS
) {
495 zr
->frame
= zr
->queue
;
497 if (ioctl(zr
->vdes
, MJPIOC_SYNC
, &zr
->zs
) < 0)
498 mp_msg(MSGT_VO
, MSGL_ERR
, "zr: error waiting for buffers to become free\n");
499 zr
->frame
= zr
->zs
.frame
;
503 for (i
= 0; i
< zr
->fields
; i
++)
504 k
+=jpeg_enc_frame(zr
->j
, zr
->y_data
+ i
*zr
->y_stride
,
505 zr
->u_data
+ i
*zr
->u_stride
,
506 zr
->v_data
+ i
*zr
->v_stride
,
508 1024*zr
->frame
*zr
->buffer_size
+k
);
509 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");
511 /* Warning: Only the first jpeg image contains huffman- and
512 * quantisation tables, so don't expect files other than
513 * test0001.jpg to be readable */
514 /*sprintf(filename, "test%04d.jpg", framenum);
515 fp = fopen(filename, "w");
517 fwrite(buf+frame*zrq.size, 1, k, fp);
519 /*fp = fopen("test1.jpg", "r");
520 fread(buf+frame*zrq.size, 1, 2126, fp);
523 for (j
= 0; j
< zr_count
; j
++) {
524 zr_info_t
*zr
= &zr_info
[j
];
525 if (ioctl(zr
->vdes
, MJPIOC_QBUF_PLAY
, &zr
->frame
) < 0)
526 mp_msg(MSGT_VO
, MSGL_ERR
, "zr: error queueing buffer for playback\n");
534 static uint32_t draw_frame(uint8_t * src
[]) {
537 //printf("draw frame called\n");
538 for (j
= 0; j
< zr_count
; j
++) {
539 zr_info_t
*zr
= &zr_info
[j
];
541 source
= src
[0] + 2*g
->yoff
*zr
->vdec
*zr
->stride
+ 2*g
->xoff
;
542 dest
= zr
->image
+ 2*zr
->off_y
;
543 for (i
= 0; i
< g
->height
/zr
->vdec
; i
++) {
544 memcpy(dest
, source
, zr
->image_width
*2);
545 dest
+= 2*zr
->image_width
;
546 source
+= zr
->vdec
*zr
->stride
;
552 static uint32_t query_format(uint32_t format
) {
553 if(format
==IMGFMT_YV12
|| format
==IMGFMT_YUY2
)
554 return VFCAP_CSP_SUPPORTED
|VFCAP_CSP_SUPPORTED_BY_HW
;
558 static void uninit(void) {
560 mp_msg(MSGT_VO
, MSGL_V
, "zr: uninit called\n");
561 for (j
= 0; j
< zr_count
; j
++) {
562 jpeg_enc_uninit(zr_info
[j
].j
);
563 uninit_zoran(&zr_info
[j
]);
567 static void check_events(void) {
571 static uint32_t draw_slice(uint8_t *srcimg
[], int stride
[],
572 int wf
, int hf
, int xf
, int yf
) {
573 int i
, j
, w
, h
, x
, y
;
574 /* Apply 'geometry', crop unwanted parts */
576 //printf("before: w=%d, h=%d, x=%d, y=%d, src0=%p, src1=%p, src2=%p\n", w, h, x, y, srcimg[0], srcimg[1], srcimg[2]);
577 for (j
= 0; j
< zr_count
; j
++) {
578 uint8_t *src
=srcimg
[0];
579 uint8_t *src1
=srcimg
[1];
580 uint8_t *src2
=srcimg
[2];
581 zr_info_t
*zr
= &zr_info
[j
];
583 w
= wf
; h
= hf
; x
= xf
; y
= yf
;
586 src1
+= (g
->xoff
- x
)/2;
587 src2
+= (g
->xoff
- x
)/2;
589 if (w
< 0) break; //return 0;
594 if (x
+ w
> g
->width
) {
596 if (w
< 0) break; //return 0;
599 src
+= (g
->yoff
- y
)*stride
[0];
600 src1
+= ((g
->yoff
- y
)/2)*stride
[1];
601 src2
+= ((g
->yoff
- y
)/2)*stride
[2];
603 if (h
< 0) break; //return 0;
608 if (y
+ h
> g
->height
) {
610 if (h
< 0) break; //return 0;
612 //printf("after: w=%d, h=%d, x=%d, y=%d, src0=%p, src1=%p, src2=%p\n", w, h, x, y, srcimg[0], srcimg[1], srcimg[2]);
613 dst
=zr
->image
+ zr
->off_y
+ zr
->image_width
*(y
/zr
->vdec
)+x
;
615 for (i
= 0; i
< h
; i
++) {
616 if ((i
+ x
)%zr
->vdec
== 0) {
618 dst
+=zr
->image_width
;
625 uint8_t *dst1
=zr
->image
+ zr
->size
+ zr
->off_c
+ (y
/(zr
->vdec
*2))*zr
->image_width
/2+(x
/2);
626 uint8_t *dst2
=zr
->image
+ 3*zr
->size
/2 + zr
->off_c
+
628 zr
->image_width
/2+(x
/2);
629 for (i
= 0; i
< h
/2; i
++) {
630 if ((i
+x
/2)%zr
->vdec
== 0) {
631 memcpy(dst1
,src1
,w
/2);
632 memcpy(dst2
,src2
,w
/2);
633 dst1
+=zr
->image_width
/2;
634 dst2
+=zr
->image_width
/2;
645 /* copied and adapted from vo_aa_parseoption */
647 vo_zr_parseoption(m_option_t
* conf
, char *opt
, char *param
){
648 /* got an option starting with zr */
649 zr_info_t
*zr
= &zr_info
[zr_parsing
];
651 /* do WE need it ?, always */
652 if (!strcasecmp(opt
, "zrdev")) {
653 if (param
== NULL
) return ERR_MISSING_PARAM
;
654 //if ((i=getcolor(param))==-1) return ERR_OUT_OF_RANGE;
657 zr
->device
= malloc(strlen(param
)+1);
658 strcpy(zr
->device
, param
);
659 mp_msg(MSGT_VO
, MSGL_V
, "zr: using device %s\n", zr
->device
);
661 } else if (!strcasecmp(opt
, "zrbw")) {
663 return ERR_OUT_OF_RANGE
;
667 } else if (!strcasecmp(opt
, "zrfd")) {
669 return ERR_OUT_OF_RANGE
;
673 } else if (!strcasecmp(opt
, "zrcrop")){
678 zr
= &zr_info
[zr_parsing
];
681 mp_msg(MSGT_VO
, MSGL_ERR
, "zr: too many simultaneus display devices requested (max. is 4)\n");
682 return ERR_OUT_OF_RANGE
;
685 if (param
== NULL
) return ERR_MISSING_PARAM
;
686 if (sscanf(param
, "%dx%d+%d+%d", &g
->width
, &g
->height
,
687 &g
->xoff
, &g
->yoff
) != 4) {
688 g
->xoff
= 0; g
->yoff
= 0;
689 if (sscanf(param
, "%dx%d", &g
->width
, &g
->height
) != 2) {
690 mp_msg(MSGT_VO
, MSGL_ERR
, "zr: argument to -zrcrop must be of the form 352x288+16+0\n");
691 return ERR_OUT_OF_RANGE
;
695 mp_msg(MSGT_VO
, MSGL_V
, "zr: cropping %s\n", param
);
697 }else if (!strcasecmp(opt
, "zrhdec")) {
699 if (i
!= 1 && i
!= 2 && i
!= 4) return ERR_OUT_OF_RANGE
;
702 }else if (!strcasecmp(opt
, "zrbsize")) {
704 if (i
< 32) return ERR_OUT_OF_RANGE
;
707 }else if (!strcasecmp(opt
, "zrvdec")) {
709 if (i
!= 1 && i
!= 2 && i
!= 4) return ERR_OUT_OF_RANGE
;
712 }else if (!strcasecmp(opt
, "zrxdoff")) {
716 }else if (!strcasecmp(opt
, "zrydoff")) {
720 }else if (!strcasecmp(opt
, "zrquality")) {
722 if (i
< 1 || i
> 20) return ERR_OUT_OF_RANGE
;
725 }else if (!strcasecmp(opt
, "zrnorm")) {
726 if (param
== NULL
) return ERR_MISSING_PARAM
;
727 if (!strcasecmp(param
, "NTSC")) {
728 mp_msg(MSGT_VO
, MSGL_V
, "zr: Norm set to NTSC\n");
729 zr
->norm
= VIDEO_MODE_NTSC
;
731 } else if (!strcasecmp(param
, "PAL")) {
732 mp_msg(MSGT_VO
, MSGL_V
, "zr: Norm set to PAL\n");
733 zr
->norm
= VIDEO_MODE_PAL
;
736 return ERR_OUT_OF_RANGE
;
738 }else if (!strcasecmp(opt
, "zrhelp")){
739 printf("Help for -vo zr: Zoran ZR360[56]7/ZR36060 based MJPEG capture/playback cards\n");
741 printf("Here are the zr options:\n");
744 " -zrcrop specify part of the input image that\n"
745 " you want to see as an x-style geometry string\n"
746 " example: -zrcrop 352x288+16+0\n"
747 " -zrvdec vertical decimation 1, 2 or 4\n"
748 " -zrhdec horizontal decimation 1, 2 or 4\n"
749 " -zrfd decimation is only done if the primitive\n"
750 " hardware upscaler can correct for the decimation,\n"
751 " this switch allows you to see the effects\n"
752 " of too much decimation\n"
753 " -zrbw display in black&white (speed increase)\n"
754 " -zrxdoff x offset from upper-left of TV screen (default is 'centered')\n"
755 " -zrydoff y offset from upper-left of TV screen (default is 'centered')\n"
756 " -zrquality jpeg compression quality [BEST] 1 - 20 [VERY BAD]\n"
757 " -zrdev playback device (example -zrdev /dev/video1)\n"
758 " -zrnorm specify norm PAL/NTSC (default: leave at current setting)\n"
759 " -zrbsize set the MPJEG buffer size to a number of kilobytes (def. 128)\n"
760 " use this if MPlayer complains about the MJPEG buffer size\n"
761 " being too small, 256kB is recommended. If your card/mobo\n"
762 " doesn't allow buffers > 128kB lower the jpeg encoding\n"
763 " quality or the resolution of the movie\n"
765 "Cinerama support: additional occurances of -zrcrop activate cinerama mode,\n"
766 "suppose you have a 704x272 movie, two DC10+ cards and two beamers (or tv's),\n"
767 "then you would issue the following command:\n\n"
768 "mplayer -vo zr -zrcrop 352x272+0+0 -zrdev /dev/video0 -zrcrop 352x272+352+0 \\\n"
769 " -zrdev /dev/video1 movie.avi\n\n"
770 "Options appearing after the second -zrcrop apply to the second card, it is\n"
771 "possible to dispay at a different jpeg quality or at different decimations.\n\n"
772 "The parameters -zrxdoff and -zrydoff can be used to align the two images.\n"
773 "The maximum number of zoran cards participating in cinerama is 4, so you can\n"
774 "build a 2x2 vidiwall. (untested for obvious reasons, the setup wit a buz and\n"
775 "a DC10+ (and no beamers) is tested, however)\n"
780 return ERR_NOT_AN_OPTION
;
783 void vo_zr_revertoption(m_option_t
* opt
,char* param
) {
785 zr_info_t
*zr
= &zr_info
[1];
789 if (!strcasecmp(param
, "zrdev")) {
793 } else if (!strcasecmp(param
, "zrbw"))
795 else if (!strcasecmp(param
, "zrfd"))
797 else if (!strcasecmp(param
, "zrcrop"))
798 zr
->g
.set
= zr
->g
.xoff
= zr
->g
.yoff
= 0;
799 else if (!strcasecmp(param
, "zrbsize"))
800 zr
->buffer_size
= 128;
801 else if (!strcasecmp(param
, "zrhdec"))
803 else if (!strcasecmp(param
, "zrvdec"))
805 else if (!strcasecmp(param
, "zrxdoff"))
807 else if (!strcasecmp(param
, "zrydoff"))
809 else if (!strcasecmp(param
, "zrquality"))
811 else if (!strcasecmp(param
, "zrnorm"))
812 zr
->norm
= VIDEO_MODE_AUTO
;
816 static uint32_t preinit(const char *arg
)
820 printf("vo_zr: Unknown subdevice: %s\n",arg
);
826 static uint32_t control(uint32_t request
, void *data
, ...)
829 case VOCTRL_QUERY_FORMAT
:
830 return query_format(*((uint32_t*)data
));