static string try_resolution P4C(const_string, fontname, unsigned, dpi, kpse_file_format_type, format, kpse_glyph_file_type *, glyph_file) { string ret = try_size (fontname, dpi, format, glyph_file); if (!ret) { unsigned r; unsigned tolerance = KPSE_BITMAP_TOLERANCE (dpi); /* Cast to unsigned to shut up stupid compilers. */ unsigned lower_bound = (int) (dpi - tolerance) < 0 ? 0 : (unsigned)(dpi - tolerance); unsigned upper_bound = (unsigned)(dpi + tolerance); /* Prefer scaling up to scaling down, since scaling down can omit character features (Tom did this in dvips). */ for (r = lower_bound; !ret && r <= upper_bound; r++) if (r != dpi) ret = try_size (fontname, r, format, glyph_file); } return ret; }
static string try_resolution P4C(const_string, font_name, unsigned, dpi, string *, glyph_paths, kpse_font_file_type *, font_file) { string ret = try_size (font_name, dpi, glyph_paths, font_file); if (!ret) { unsigned r; unsigned tolerance = KPSE_BITMAP_TOLERANCE (dpi); unsigned lower_bound = (int) (dpi - tolerance) < 0 ? 0 : dpi - tolerance; unsigned upper_bound = dpi + tolerance; /* Prefer scaling up to scaling down, since scaling down can omit character features (Tom did this in dvips). */ for (r = lower_bound; !ret && r <= upper_bound; r++) if (r != dpi) ret = try_size (font_name, r, glyph_paths, font_file); } return ret; }
static int v4l_configure(V4lState *s) { struct video_channel chan; struct video_picture pict; struct video_capability cap; int err; int i; int fps = 0; int found=0; memset(&chan,0,sizeof(chan)); memset(&pict,0,sizeof(pict)); memset(&cap,0,sizeof(cap)); err=ioctl(s->fd,VIDIOCGCAP,&cap); if (err!=0) { ms_warning("MSV4l: cannot get device capabilities: %s.",strerror(errno)); return -1; } ms_message("Found %s device. (maxsize=%ix%i, minsize=%ix%i)",cap.name, cap.maxwidth, cap.maxheight, cap.minwidth, cap.minheight); for (i=0;i<cap.channels;i++) { chan.channel=i; err=ioctl(s->fd,VIDIOCGCHAN,&chan); if (err==0) { ms_message("Getting video channel %s",chan.name); switch(chan.type){ case VIDEO_TYPE_TV: ms_message("Channel is a TV."); break; case VIDEO_TYPE_CAMERA: ms_message("Channel is a camera"); break; default: ms_warning("unknown video channel type."); } found=1; break; /* find the first channel */ } } if (found) ms_message("A valid video channel was found."); /* select this channel */ ioctl(s->fd,VIDIOCSCHAN,&chan); /* get picture properties */ err=ioctl(s->fd,VIDIOCGPICT,&pict); if (err<0){ ms_warning("Could not get picture properties: %s",strerror(errno)); return -1; } ms_message("Default picture properties: brightness=%i,hue=%i,colour=%i,contrast=%i,depth=%i, palette=%i.", pict.brightness,pict.hue,pict.colour, pict.contrast,pict.depth, pict.palette); /* trying color format */ if (try_format(s->fd,&pict,VIDEO_PALETTE_YUV420P,16)){ ms_message("Driver supports YUV420P, using that format."); s->pix_fmt=MS_YUV420P; }else if (try_format(s->fd, &pict,VIDEO_PALETTE_RGB24,24)){ ms_message("Driver supports RGB24, using that format."); s->pix_fmt=MS_RGB24; }else if (try_format(s->fd, &pict,VIDEO_PALETTE_YUV422, 16)){ ms_message("Driver supports YUV422, using that format."); s->pix_fmt=MS_YUYV; }else if (try_format(s->fd, &pict,VIDEO_PALETTE_UYVY, 16)){ ms_message("Driver supports UYVY, using that format."); s->pix_fmt=MS_UYVY; }else{ s->vsize.width=MS_VIDEO_SIZE_CIF_W; s->vsize.height=MS_VIDEO_SIZE_CIF_H; s->pix_fmt=MS_YUV420P; ms_fatal("Unsupported video pixel format."); return -1; } if (!try_size(s,s->vsize)) { if (!try_size(s,MS_VIDEO_SIZE_NS1)){ if (!try_size(s,MS_VIDEO_SIZE_VGA)){ if (!try_size(s,MS_VIDEO_SIZE_CIF)) { if (!try_size(s,MS_VIDEO_SIZE_QCIF)) { if (!try_size(s,MS_VIDEO_SIZE_QVGA)) { if (!try_size(s,MS_VIDEO_SIZE_4CIF)) { if (!try_size(s,MS_VIDEO_SIZE_1024)) { return -1; } } } } } } } } /* Try HW frame rate control */ fps = s->fps; if (ioctl(s->fd, VIDIOSFPS, &fps) < 0 ) ms_message("v4l_configure: cannot set HW frame rate control"); else ms_message("v4l_configure: set HW fps to be : %d", fps); return 0; }