diff options
author | 2011-05-02 00:46:03 +0300 | |
---|---|---|
committer | 2011-05-02 00:46:03 +0300 | |
commit | 7e65428712beacd416dc3410c52f22ebfd3b4c53 (patch) | |
tree | 79bb2f4388be7031b5505c7745e1a59aff6cff56 /libvo/vo_fbdev2.c | |
parent | 5c4b059f1608f6d6a981b7d81a14f1c46e40ba52 (diff) | |
parent | d0376729d171a6c0b4cc15928c168f68adefbaa6 (diff) |
Merge branch 'mplayer1_changes'
Diffstat (limited to 'libvo/vo_fbdev2.c')
-rw-r--r-- | libvo/vo_fbdev2.c | 81 |
1 files changed, 29 insertions, 52 deletions
diff --git a/libvo/vo_fbdev2.c b/libvo/vo_fbdev2.c index 612b145464..bec9fea8ff 100644 --- a/libvo/vo_fbdev2.c +++ b/libvo/vo_fbdev2.c @@ -36,6 +36,8 @@ #include "fastmemcpy.h" #include "sub/sub.h" #include "mp_msg.h" +#include "aspect.h" +#include "libavutil/common.h" static const vo_info_t info = { "Framebuffer Device", @@ -108,8 +110,6 @@ static void (*draw_alpha_p)(int w, int h, unsigned char *src, static uint8_t *next_frame = NULL; // for double buffering static int in_width; static int in_height; -static int out_width; -static int out_height; static struct fb_cmap *make_directcolor_cmap(struct fb_var_screeninfo *var) { @@ -122,42 +122,25 @@ static struct fb_cmap *make_directcolor_cmap(struct fb_var_screeninfo *var) bcols = 1 << var->blue.length; /* Make our palette the length of the deepest color */ - cols = (rcols > gcols ? rcols : gcols); - cols = (cols > bcols ? cols : bcols); + cols = FFMAX3(rcols, gcols, bcols); - red = malloc(cols * sizeof(red[0])); + red = malloc(3 * cols * sizeof(red[0])); if(!red) { mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] Can't allocate red palette with %d entries.\n", cols); return NULL; } - for(i=0; i< rcols; i++) - red[i] = (65535/(rcols-1)) * i; - - green = malloc(cols * sizeof(green[0])); - if(!green) { - mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] Can't allocate green palette with %d entries.\n", cols); - free(red); - return NULL; - } - for(i=0; i< gcols; i++) + green = red + cols; + blue = green + cols; + for (i = 0; i < cols; i++) { + red[i] = (65535/(rcols-1)) * i; green[i] = (65535/(gcols-1)) * i; - - blue = malloc(cols * sizeof(blue[0])); - if(!blue) { - mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] Can't allocate blue palette with %d entries.\n", cols); - free(red); - free(green); - return NULL; + blue[i] = (65535/(bcols-1)) * i; } - for(i=0; i< bcols; i++) - blue[i] = (65535/(bcols-1)) * i; cmap = malloc(sizeof(struct fb_cmap)); if(!cmap) { mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] Can't allocate color map\n"); free(red); - free(green); - free(blue); return NULL; } cmap->start = 0; @@ -232,20 +215,17 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, { 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); - out_width = width; - out_height = height; in_width = width; in_height = height; - if (fs) { - out_width = fb_vinfo.xres; - out_height = fb_vinfo.yres; - } - - if (out_width < in_width || out_height < in_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", - out_width, out_height, in_width, in_height); + fb_vinfo.xres, fb_vinfo.yres, in_width, in_height); return 1; } @@ -282,12 +262,12 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, 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->green); - free(cmap->blue); free(cmap); break; default: @@ -304,8 +284,8 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, } center = frame_buffer + - ( (out_width - in_width) / 2 ) * fb_pixel_size + - ( (out_height - in_height) / 2 ) * fb_line_len; + 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))) { @@ -378,13 +358,8 @@ static int draw_slice(uint8_t *src[], int stride[], int w, int h, int x, int y) uint8_t *dest = next_frame + (in_width * y + x) * fb_pixel_size; int next = in_width * fb_pixel_size; #endif - int i; - for (i = 0; i < h; i++) { - fast_memcpy(dest, in, w * fb_pixel_size); - dest += next; - in += stride[0]; - } + memcpy_pic(dest, in, w * fb_pixel_size, h, next, stride[0]); return 0; } @@ -395,14 +370,11 @@ static void check_events(void) static void flip_page(void) { #ifndef USE_CONVERT2FB - int i, out_offset = 0, in_offset = 0; + int out_offset = 0, in_offset = 0; - for (i = 0; i < in_height; i++) { - fast_memcpy(center + out_offset, next_frame + in_offset, - in_width * fb_pixel_size); - out_offset += fb_line_len; - in_offset += in_width * fb_pixel_size; - } + memcpy_pic(center + out_offset, next_frame + in_offset, + in_width * fb_pixel_size, in_height, + fb_line_len, in_width * fb_pixel_size); #endif } @@ -430,6 +402,11 @@ static int control(uint32_t request, void *data) switch (request) { case VOCTRL_QUERY_FORMAT: return query_format(*((uint32_t*)data)); + case VOCTRL_UPDATE_SCREENINFO: + vo_screenwidth = fb_vinfo.xres; + vo_screenheight = fb_vinfo.yres; + aspect_save_screenres(vo_screenwidth, vo_screenheight); + return VO_TRUE; } return VO_NOTIMPL; } |