Mercurial > mplayer.hg
comparison libvo/vo_zr.c @ 4668:d20978449650
migration of -vo zr to Recommended Interface definition (this obsoletes zoran.h)
author | rik |
---|---|
date | Tue, 12 Feb 2002 15:53:40 +0000 |
parents | 49f2bc22f880 |
children | 32e1f5042f65 |
comparison
equal
deleted
inserted
replaced
4667:95fa3901cafc | 4668:d20978449650 |
---|---|
13 #include <sys/time.h> | 13 #include <sys/time.h> |
14 #include <sys/mman.h> | 14 #include <sys/mman.h> |
15 #include <sys/ioctl.h> | 15 #include <sys/ioctl.h> |
16 #include <linux/types.h> | 16 #include <linux/types.h> |
17 #include <linux/videodev.h> | 17 #include <linux/videodev.h> |
18 #include "zoran.h" | 18 #include "videodev_mjpeg.h" |
19 | 19 |
20 #include "config.h" | 20 #include "config.h" |
21 | 21 |
22 #include "video_out.h" | 22 #include "video_out.h" |
23 #include "video_out_internal.h" | 23 #include "video_out_internal.h" |
69 | 69 |
70 /* Variables needed for Zoran */ | 70 /* Variables needed for Zoran */ |
71 | 71 |
72 int vdes; /* the file descriptor of the video device */ | 72 int vdes; /* the file descriptor of the video device */ |
73 int frame = 0, synco = 0, queue = 0; /* buffer management */ | 73 int frame = 0, synco = 0, queue = 0; /* buffer management */ |
74 struct zoran_params zp; | 74 struct mjpeg_params zp; |
75 struct zoran_requestbuffers zrq; | 75 struct mjpeg_requestbuffers zrq; |
76 struct zoran_sync zs; | 76 struct mjpeg_sync zs; |
77 struct video_capability vc; | 77 struct video_capability vc; |
78 #define MJPEG_NBUFFERS 2 | 78 #define MJPEG_NBUFFERS 2 |
79 #define MJPEG_SIZE 1024*256 | 79 #define MJPEG_SIZE 1024*256 |
80 | 80 |
81 //should be command line options | 81 //should be command line options |
89 char* dev = device ? device : VO_ZR_DEFAULT_DEVICE; | 89 char* dev = device ? device : VO_ZR_DEFAULT_DEVICE; |
90 vdes = open(dev, O_RDWR); | 90 vdes = open(dev, O_RDWR); |
91 /* before we can ask for the maximum resolution, we must set | 91 /* before we can ask for the maximum resolution, we must set |
92 * the correct tv norm */ | 92 * the correct tv norm */ |
93 | 93 |
94 if (ioctl(vdes, BUZIOC_G_PARAMS, &zp) < 0) { | 94 if (ioctl(vdes, MJPIOC_G_PARAMS, &zp) < 0) { |
95 mp_msg(MSGT_VO, MSGL_ERR, "device at %s is probably not a DC10(+)/buz/lml33\n", dev); | 95 mp_msg(MSGT_VO, MSGL_ERR, "device at %s is probably not a DC10(+)/buz/lml33\n", dev); |
96 return 1; | 96 return 1; |
97 } | 97 } |
98 | 98 |
99 if (zp.norm != norm && norm != VIDEO_MODE_AUTO) { | 99 if (zp.norm != norm && norm != VIDEO_MODE_AUTO) { |
100 /* attempt to set requested norm */ | 100 /* attempt to set requested norm */ |
101 zp.norm = norm; | 101 zp.norm = norm; |
102 if (ioctl(vdes, BUZIOC_S_PARAMS, &zp) < 0) { | 102 if (ioctl(vdes, MJPIOC_S_PARAMS, &zp) < 0) { |
103 mp_msg(MSGT_VO, MSGL_ERR, | 103 mp_msg(MSGT_VO, MSGL_ERR, |
104 "unable to change video norm, use another program to change it (XawTV)\n"); | 104 "unable to change video norm, use another program to change it (XawTV)\n"); |
105 return 1; | 105 return 1; |
106 } | 106 } |
107 ioctl(vdes, BUZIOC_G_PARAMS, &zp); | 107 ioctl(vdes, MJPIOC_G_PARAMS, &zp); |
108 if (norm != zp.norm) { | 108 if (norm != zp.norm) { |
109 mp_msg(MSGT_VO, MSGL_ERR, | 109 mp_msg(MSGT_VO, MSGL_ERR, |
110 "unable to change video norm, use another program to change it (XawTV)\n"); | 110 "unable to change video norm, use another program to change it (XawTV)\n"); |
111 return 1; | 111 return 1; |
112 } | 112 } |
150 zp.img_y = (vc.maxheight - zp.VerDcm*(3-fields)*(int)image_height)/4; | 150 zp.img_y = (vc.maxheight - zp.VerDcm*(3-fields)*(int)image_height)/4; |
151 zp.img_width = zp.HorDcm*image_width/hdec; | 151 zp.img_width = zp.HorDcm*image_width/hdec; |
152 zp.img_height = zp.VerDcm*image_height/fields; | 152 zp.img_height = zp.VerDcm*image_height/fields; |
153 mp_msg(MSGT_VO, MSGL_V, "zr: geometry (after 'scaling'): %dx%d+%d+%d fields=%d, w=%d, h=%d\n", zp.img_width, (3-fields)*zp.img_height, zp.img_x, zp.img_y, fields, image_width/hdec, image_height); | 153 mp_msg(MSGT_VO, MSGL_V, "zr: geometry (after 'scaling'): %dx%d+%d+%d fields=%d, w=%d, h=%d\n", zp.img_width, (3-fields)*zp.img_height, zp.img_x, zp.img_y, fields, image_width/hdec, image_height); |
154 | 154 |
155 if (ioctl(vdes, BUZIOC_S_PARAMS, &zp) < 0) { | 155 if (ioctl(vdes, MJPIOC_S_PARAMS, &zp) < 0) { |
156 mp_msg(MSGT_VO, MSGL_ERR, "error setting display parameters\n"); | 156 mp_msg(MSGT_VO, MSGL_ERR, "error setting display parameters\n"); |
157 return 1; | 157 return 1; |
158 } | 158 } |
159 | 159 |
160 zrq.count = MJPEG_NBUFFERS; | 160 zrq.count = MJPEG_NBUFFERS; |
161 zrq.size = MJPEG_SIZE; | 161 zrq.size = MJPEG_SIZE; |
162 | 162 |
163 if (ioctl(vdes, BUZIOC_REQBUFS, &zrq)) { | 163 if (ioctl(vdes, MJPIOC_REQBUFS, &zrq)) { |
164 mp_msg(MSGT_VO, MSGL_ERR, "error requesting %d buffers of size %d\n", zrq.count, zrq.size); | 164 mp_msg(MSGT_VO, MSGL_ERR, "error requesting %d buffers of size %d\n", zrq.count, zrq.size); |
165 return 1; | 165 return 1; |
166 } | 166 } |
167 | 167 |
168 buf = (char*)mmap(0, zrq.count*zrq.size, PROT_READ|PROT_WRITE, | 168 buf = (char*)mmap(0, zrq.count*zrq.size, PROT_READ|PROT_WRITE, |
179 if (image) { | 179 if (image) { |
180 free(image); | 180 free(image); |
181 image=NULL; | 181 image=NULL; |
182 } | 182 } |
183 while (queue > synco + 1) { | 183 while (queue > synco + 1) { |
184 if (ioctl(vdes, BUZIOC_SYNC, &zs) < 0) | 184 if (ioctl(vdes, MJPIOC_SYNC, &zs) < 0) |
185 mp_msg(MSGT_VO, MSGL_ERR, "error waiting for buffers to become free"); | 185 mp_msg(MSGT_VO, MSGL_ERR, "error waiting for buffers to become free"); |
186 synco++; | 186 synco++; |
187 } | 187 } |
188 /* stop streaming */ | 188 /* stop streaming */ |
189 frame = -1; | 189 frame = -1; |
190 if (ioctl(vdes, BUZIOC_QBUF_PLAY, &frame) < 0) | 190 if (ioctl(vdes, MJPIOC_QBUF_PLAY, &frame) < 0) |
191 mp_msg(MSGT_VO, MSGL_ERR, "error stopping playback of last frame"); | 191 mp_msg(MSGT_VO, MSGL_ERR, "error stopping playback of last frame"); |
192 close(vdes); | 192 close(vdes); |
193 } | 193 } |
194 | 194 |
195 static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, | 195 static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, |
404 //char filename[100]; | 404 //char filename[100]; |
405 /* do we have a free buffer? */ | 405 /* do we have a free buffer? */ |
406 if (queue-synco < zrq.count) { | 406 if (queue-synco < zrq.count) { |
407 frame = queue; | 407 frame = queue; |
408 } else { | 408 } else { |
409 if (ioctl(vdes, BUZIOC_SYNC, &zs) < 0) | 409 if (ioctl(vdes, MJPIOC_SYNC, &zs) < 0) |
410 mp_msg(MSGT_VO, MSGL_ERR, "error waiting for buffers to become free"); | 410 mp_msg(MSGT_VO, MSGL_ERR, "error waiting for buffers to become free"); |
411 frame = zs.frame; | 411 frame = zs.frame; |
412 synco++; | 412 synco++; |
413 } | 413 } |
414 k=0; | 414 k=0; |
426 fclose(fp);*/ | 426 fclose(fp);*/ |
427 /*fp = fopen("test1.jpg", "r"); | 427 /*fp = fopen("test1.jpg", "r"); |
428 fread(buf+frame*zrq.size, 1, 2126, fp); | 428 fread(buf+frame*zrq.size, 1, 2126, fp); |
429 fclose(fp);*/ | 429 fclose(fp);*/ |
430 | 430 |
431 if (ioctl(vdes, BUZIOC_QBUF_PLAY, &frame) < 0) | 431 if (ioctl(vdes, MJPIOC_QBUF_PLAY, &frame) < 0) |
432 mp_msg(MSGT_VO, MSGL_ERR, | 432 mp_msg(MSGT_VO, MSGL_ERR, |
433 "error queueing buffer for playback"); | 433 "error queueing buffer for playback"); |
434 queue++; | 434 queue++; |
435 | 435 |
436 framenum++; | 436 framenum++; |