Mercurial > mplayer.hg
comparison libvo/vo_zr.c @ 4361:e7744189e03f
fix a decimation/scaling bug in vo_zr and some verbose messages have changed - patch by Rik Snel <rsnel@cube.dyndns.org>
author | arpi |
---|---|
date | Sat, 26 Jan 2002 19:01:32 +0000 |
parents | ed5b85b713a3 |
children | df8e0f71cc3c |
comparison
equal
deleted
inserted
replaced
4360:3d9ef473a622 | 4361:e7744189e03f |
---|---|
123 | 123 |
124 if (ioctl(vdes, VIDIOCGCAP, &vc) < 0) { | 124 if (ioctl(vdes, VIDIOCGCAP, &vc) < 0) { |
125 mp_msg(MSGT_VO, MSGL_ERR, "error getting video capabilities from %s\n"); | 125 mp_msg(MSGT_VO, MSGL_ERR, "error getting video capabilities from %s\n"); |
126 return 1; | 126 return 1; |
127 } | 127 } |
128 mp_msg(MSGT_VO, MSGL_V, "zr36067 reports: maxwidth=%d, maxheight=%d\n", vc.maxwidth, vc.maxheight); | 128 mp_msg(MSGT_VO, MSGL_V, "zr: MJPEG card reports maxwidth=%d, maxheight=%d\n", vc.maxwidth, vc.maxheight); |
129 | 129 |
130 return 0; | 130 return 0; |
131 } | 131 } |
132 | 132 |
133 int init_zoran(int zrhdec, int zrvdec) { | 133 int init_zoran(int zrhdec, int zrvdec) { |
134 /* center the image, and stretch it as far as possible (try to keep | 134 /* center the image, and stretch it as far as possible (try to keep |
135 * aspect) and check if it fits */ | 135 * aspect) and check if it fits */ |
136 if (image_width/hdec > vc.maxwidth) { | 136 if (image_width > vc.maxwidth) { |
137 mp_msg(MSGT_VO, MSGL_ERR, "movie to be played is too wide, max width currenty %d\n", vc.maxwidth); | 137 mp_msg(MSGT_VO, MSGL_ERR, "zr: movie to be played is too wide, max width currenty %d\n", vc.maxwidth); |
138 return 1; | 138 return 1; |
139 } | 139 } |
140 | 140 |
141 if (image_height > vc.maxheight) { | 141 if (image_height > vc.maxheight) { |
142 mp_msg(MSGT_VO, MSGL_ERR, "movie to be played is too high, max height currenty %d\n", vc.maxheight); | 142 mp_msg(MSGT_VO, MSGL_ERR, "movie to be played is too high, max height currenty %d\n", vc.maxheight); |
228 } else { | 228 } else { |
229 g.width = width; | 229 g.width = width; |
230 g.height = height; | 230 g.height = height; |
231 g.xoff = 0; | 231 g.xoff = 0; |
232 g.yoff = 0; | 232 g.yoff = 0; |
233 g.set = 1; | |
233 } | 234 } |
234 /* we must know the maximum resolution of the device | 235 /* we must know the maximum resolution of the device |
235 * it differs for DC10+ and buz for example */ | 236 * it differs for DC10+ and buz for example */ |
236 zoran_getcap(); /*must be called before init_zoran */ | 237 zoran_getcap(); /*must be called before init_zoran */ |
237 /* make the scaling decision | 238 /* make the scaling decision |
244 stretchy = 1; | 245 stretchy = 1; |
245 fields = 2; | 246 fields = 2; |
246 if (vdec == 2) { | 247 if (vdec == 2) { |
247 fields = 1; | 248 fields = 1; |
248 } else if (vdec == 4) { | 249 } else if (vdec == 4) { |
250 fields = 1; | |
249 stretchy = 2; | 251 stretchy = 2; |
250 } | 252 } |
251 stretchx = hdec; | 253 stretchx = hdec; |
252 } else if (g.width > vc.maxwidth/4 || g.height > vc.maxheight/4) { | 254 } else if (g.width > vc.maxwidth/4 || g.height > vc.maxheight/4) { |
253 stretchx = 2; | 255 stretchx = 2; |
284 if (hdec != 1 && !zrfd) { | 286 if (hdec != 1 && !zrfd) { |
285 mp_msg(MSGT_VO, MSGL_WARN, "vo_zr: vertical decimation too high, changing to 1 (use -zrfd to keep hdec=%d)\n", hdec); | 287 mp_msg(MSGT_VO, MSGL_WARN, "vo_zr: vertical decimation too high, changing to 1 (use -zrfd to keep hdec=%d)\n", hdec); |
286 hdec = 1; | 288 hdec = 1; |
287 } | 289 } |
288 } | 290 } |
291 /* It can be that the original frame was too big for display, | |
292 * or that the width of the decimated image (for example) after | |
293 * padding up to a multiple of 16 has become too big. (orig | |
294 * width 720 (exactly right for the Buz) after decimation 360, | |
295 * after padding up to a multiple of 16 368, display 736 -> too | |
296 * large). In these situations we auto(re)crop. */ | |
297 j = 16*((g.width - 1)/(hdec*16) + 1); | |
298 if (stretchx*j > vc.maxwidth) { | |
299 g.xoff += 2*((g.width - hdec*(j-16))/4); | |
300 /* g.off must be a multiple of 2 */ | |
301 g.width = hdec*(j - 16); | |
302 g.set = 0; /* we abuse this field to report that g has changed*/ | |
303 } | |
304 j = 8*fields*((g.height - 1)/(vdec*fields*8) + 1); | |
305 if (stretchy*j > vc.maxheight) { | |
306 g.yoff += 2*((g.height - vdec*(j - 8*fields))/4); | |
307 g.height = vdec*(j - 8*fields); | |
308 g.set = 0; | |
309 } | |
310 if (!g.set) | |
311 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); | |
312 | |
289 /* the height must be a multiple of fields*8 and the width | 313 /* the height must be a multiple of fields*8 and the width |
290 * must be a multiple of 16 */ | 314 * must be a multiple of 16 */ |
291 /* add some black borders to make it so, and center the image*/ | 315 /* add some black borders to make it so, and center the image*/ |
292 image_height = fields*8*((g.height/vdec - 1)/(fields*8) + 1); | 316 image_height = fields*8*((g.height/vdec - 1)/(fields*8) + 1); |
293 image_width = (hdec*16)*((g.width - 1)/(hdec*16) + 1); | 317 image_width = (hdec*16)*((g.width - 1)/(hdec*16) + 1); |
298 off_y += (image_width - g.width)/2; | 322 off_y += (image_width - g.width)/2; |
299 if (off_y%2 != 0) off_y--; | 323 if (off_y%2 != 0) off_y--; |
300 off_c += (image_width - g.width)/4; | 324 off_c += (image_width - g.width)/4; |
301 framenum = 0; | 325 framenum = 0; |
302 size = image_width*image_height; | 326 size = image_width*image_height; |
303 mp_msg(MSGT_VO, MSGL_V, "input: %dx%d, cropped: %dx%d, output: %dx%d, off_y=%d, off_c=%d\n", width/hdec, height, g.width, g.height, image_width, image_height, off_y, off_c); | 327 mp_msg(MSGT_VO, MSGL_V, "input: %dx%d, cropped: %dx%d, output: %dx%d, off_y=%d, off_c=%d\n", width, height, g.width, g.height, image_width, image_height, off_y, off_c); |
304 | 328 |
305 image = malloc(2*size); /* this buffer allows for YUV422 data, | 329 image = malloc(2*size); /* this buffer allows for YUV422 data, |
306 * so it is a bit too big for YUV420 */ | 330 * so it is a bit too big for YUV420 */ |
307 if (!image) { | 331 if (!image) { |
308 mp_msg(MSGT_VO, MSGL_ERR, "Memory exhausted\n"); | 332 mp_msg(MSGT_VO, MSGL_ERR, "Memory exhausted\n"); |