Example #1
0
static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src,
                       unsigned char *srca, int stride)
{
    int bpp = pixel_stride(out_format);
    draw_alpha_func(w, h, src, srca, stride,
                    ImageData + bpp * (y0 * image_width + x0),
                    bpp * image_width);
}
static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){
   int bpp = pixel_stride(image_format);
   vo_draw_alpha_func draw = vo_get_draw_alpha(image_format);
   if (!draw) return;
   draw(w,h,src,srca,stride,ImageData+bpp*(y0*image_width+x0),bpp*image_width);
}
Example #3
0
static int config(uint32_t width, uint32_t height, uint32_t d_width,
		uint32_t d_height, uint32_t flags, char *title,
		uint32_t format)
{
	struct fb_cmap *cmap;
	int fs = flags & VOFLAG_FULLSCREEN;
	int x_offset = vo_dx + (d_width  - width ) / 2;
	int y_offset = vo_dy + (d_height - height) / 2;
	x_offset = av_clip(x_offset, 0, fb_vinfo.xres - width);
	y_offset = av_clip(y_offset, 0, fb_vinfo.yres - height);

	in_width = width;
	in_height = height;

	if (fb_vinfo.xres < in_width || fb_vinfo.yres < in_height) {
		mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] Screensize is smaller than video size (%dx%d < %dx%d)\n",
		    fb_vinfo.xres, fb_vinfo.yres, in_width, in_height);
		return 1;
	}

	draw_alpha_p = vo_get_draw_alpha(format);
	fb_pixel_size = pixel_stride(format);

	if (vo_config_count == 0) {
		if (ioctl(fb_dev_fd, FBIOGET_FSCREENINFO, &fb_finfo)) {
			mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] Can't get FSCREENINFO: %s\n", strerror(errno));
			return 1;
		}

		if (fb_finfo.type != FB_TYPE_PACKED_PIXELS) {
			mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] type %d not supported\n", fb_finfo.type);
			return 1;
		}

		switch (fb_finfo.visual) {
			case FB_VISUAL_TRUECOLOR:
				break;
			case FB_VISUAL_DIRECTCOLOR:
				mp_msg(MSGT_VO, MSGL_V, "[fbdev2] creating cmap for directcolor\n");
				if (ioctl(fb_dev_fd, FBIOGETCMAP, &fb_oldcmap)) {
					mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] can't get cmap: %s\n", strerror(errno));
					return 1;
				}
				if (!(cmap = make_directcolor_cmap(&fb_vinfo)))
					return 1;
				if (ioctl(fb_dev_fd, FBIOPUTCMAP, cmap)) {
					mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] can't put cmap: %s\n", strerror(errno));
					free(cmap->red);
					free(cmap);
					return 1;
				}
				fb_cmap_changed = 1;
				free(cmap->red);
				free(cmap);
				break;
			default:
				mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] visual: %d not yet supported\n", fb_finfo.visual);
				break;
		}

		fb_size = fb_finfo.smem_len;
		fb_line_len = fb_finfo.line_length;
		if ((frame_buffer = (uint8_t *) mmap(0, fb_size, PROT_READ | PROT_WRITE, MAP_SHARED, fb_dev_fd, 0)) == (uint8_t *) -1) {
			mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] Can't mmap %s: %s\n", fb_dev_name, strerror(errno));
			return 1;
		}
	}

	center = frame_buffer +
	         x_offset * fb_pixel_size +
		 y_offset * fb_line_len;

#ifndef USE_CONVERT2FB
	if (!(next_frame = realloc(next_frame, in_width * in_height * fb_pixel_size))) {
		mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] Can't malloc next_frame: %s\n", strerror(errno));
		return 1;
	}
#endif
	if (fs) {
		int len = fb_line_len * fb_vinfo.yres;
		int i;
		switch (format) {
		case IMGFMT_YUY2:
			for (i = 0; i < len - 3;) {
				frame_buffer[i++] = 0;
				frame_buffer[i++] = 0x80;
				frame_buffer[i++] = 0;
				frame_buffer[i++] = 0x80;
			}
			break;
		case IMGFMT_UYVY:
			for (i = 0; i < len - 3;) {
				frame_buffer[i++] = 0x80;
				frame_buffer[i++] = 0;
				frame_buffer[i++] = 0x80;
				frame_buffer[i++] = 0;
			}
			break;
		default:
			memset(frame_buffer, 0, len);
		}
	}

	return 0;
}