summaryrefslogtreecommitdiffstats
path: root/libvo
diff options
context:
space:
mode:
authorUoti Urpala <uau@mplayer2.org>2011-05-02 00:46:03 +0300
committerUoti Urpala <uau@mplayer2.org>2011-05-02 00:46:03 +0300
commit7e65428712beacd416dc3410c52f22ebfd3b4c53 (patch)
tree79bb2f4388be7031b5505c7745e1a59aff6cff56 /libvo
parent5c4b059f1608f6d6a981b7d81a14f1c46e40ba52 (diff)
parentd0376729d171a6c0b4cc15928c168f68adefbaa6 (diff)
downloadmpv-7e65428712beacd416dc3410c52f22ebfd3b4c53.tar.bz2
mpv-7e65428712beacd416dc3410c52f22ebfd3b4c53.tar.xz
Merge branch 'mplayer1_changes'
Diffstat (limited to 'libvo')
-rw-r--r--libvo/vo_fbdev.c22
-rw-r--r--libvo/vo_fbdev2.c81
-rw-r--r--libvo/vo_gl.c2
3 files changed, 45 insertions, 60 deletions
diff --git a/libvo/vo_fbdev.c b/libvo/vo_fbdev.c
index 7d2e9fb6a9..6d70cca0fe 100644
--- a/libvo/vo_fbdev.c
+++ b/libvo/vo_fbdev.c
@@ -34,6 +34,7 @@
#include <sys/ioctl.h>
#include <sys/kd.h>
#include <linux/fb.h>
+#include <libavutil/common.h>
#include "config.h"
#include "video_out.h"
@@ -43,7 +44,6 @@
#include "geometry.h"
#include "aspect.h"
#include "mp_msg.h"
-#include "libavutil/common.h"
static const vo_info_t info = {
"Framebuffer Device",
@@ -480,7 +480,7 @@ static fb_mode_t *find_best_mode(int xres, int yres, range_t *hfreq,
return best;
}
-static void set_bpp(struct fb_var_screeninfo *p, int bpp)
+static void set_bpp(struct fb_var_screeninfo *p, int bpp, int rgb)
{
p->bits_per_pixel = FFALIGN(bpp, 2);
p->red.msb_right = p->green.msb_right = p->blue.msb_right = p->transp.msb_right = 0;
@@ -519,15 +519,19 @@ static void set_bpp(struct fb_var_screeninfo *p, int bpp)
p->blue.length = 4;
break;
}
+ if (rgb) {
+ p->blue.offset = p->red.offset;
+ p->red.offset = 0;
+ }
}
-static void fb_mode2fb_vinfo(fb_mode_t *m, struct fb_var_screeninfo *v)
+static void fb_mode2fb_vinfo(fb_mode_t *m, struct fb_var_screeninfo *v, int rgb)
{
v->xres = m->xres;
v->yres = m->yres;
v->xres_virtual = m->vxres;
v->yres_virtual = m->vyres;
- set_bpp(v, m->depth);
+ set_bpp(v, m->depth, rgb);
v->pixclock = m->pixclock;
v->left_margin = m->left;
v->right_margin = m->right;
@@ -563,6 +567,7 @@ static struct fb_var_screeninfo fb_vinfo;
static unsigned short fb_ored[256], fb_ogreen[256], fb_oblue[256];
static struct fb_cmap fb_oldcmap = { 0, 256, fb_ored, fb_ogreen, fb_oblue };
static int fb_cmap_changed = 0;
+static int fb_rgb;
static int fb_pixel_size; // 32: 4 24: 3 16: 2 15: 2
static int fb_bpp; // 32: 32 24: 24 16: 16 15: 15
static int fb_bpp_we_want; // 32: 32 24: 24 16: 16 15: 15
@@ -687,6 +692,7 @@ static int fb_preinit(int reset)
mp_msg(MSGT_VO, MSGL_ERR, "notice: Can't open /dev/tty: %s\n", strerror(errno));
}
+ fb_rgb = !fb_vinfo.red.offset;
fb_bpp = fb_vinfo.bits_per_pixel;
if (fb_bpp == 16)
fb_bpp = fb_vinfo.red.length + fb_vinfo.green.length + fb_vinfo.blue.length;
@@ -779,7 +785,7 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
mp_msg(MSGT_VO, MSGL_ERR, "can't find requested video mode\n");
return 1;
}
- fb_mode2fb_vinfo(fb_mode, &fb_vinfo);
+ fb_mode2fb_vinfo(fb_mode, &fb_vinfo, fb_rgb);
} else if (vm) {
monitor_hfreq = str2range(monitor_hfreq_str);
monitor_vfreq = str2range(monitor_vfreq_str);
@@ -796,10 +802,10 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
}
mp_msg(MSGT_VO, MSGL_V, "using mode %dx%d @ %.1fHz\n", fb_mode->xres,
fb_mode->yres, vsf(fb_mode));
- fb_mode2fb_vinfo(fb_mode, &fb_vinfo);
+ fb_mode2fb_vinfo(fb_mode, &fb_vinfo, fb_rgb);
}
fb_bpp_we_want = fb_bpp;
- set_bpp(&fb_vinfo, fb_bpp);
+ set_bpp(&fb_vinfo, fb_bpp, fb_rgb);
fb_vinfo.xres_virtual = fb_vinfo.xres;
fb_vinfo.yres_virtual = fb_vinfo.yres;
fb_page = 0;
@@ -955,7 +961,7 @@ static int query_format(uint32_t format)
{
if (!fb_preinit(0))
return 0;
- if ((format & IMGFMT_BGR_MASK) == IMGFMT_BGR) {
+ if ((format & IMGFMT_BGR_MASK) == (fb_rgb ? IMGFMT_RGB : IMGFMT_BGR)) {
int bpp = format & 0xff;
if (bpp == fb_bpp)
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;
}
diff --git a/libvo/vo_gl.c b/libvo/vo_gl.c
index d2f98a26fe..e663057beb 100644
--- a/libvo/vo_gl.c
+++ b/libvo/vo_gl.c
@@ -1393,6 +1393,8 @@ static int control(uint32_t request, void *data)
if (!(eq_map[i].supportmask & (1 << use_yuv)))
break;
*eq_map[i].value = args->value;
+ if (strcmp(args->name, "gamma") == 0)
+ eq_rgamma = eq_ggamma = eq_bgamma = args->value;
update_yuvconv();
return VO_TRUE;
}