summaryrefslogtreecommitdiffstats
path: root/libvo
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2009-03-07 01:04:41 +0200
committerUoti Urpala <uau@glyph.nonexistent.invalid>2009-03-07 01:04:41 +0200
commite0172b96e3b6cc6a8b62ee5a52f780941a43de8b (patch)
treef652f6d15740667d5434e526db3fd12a0573aa0f /libvo
parent0c6f667896620943ee6ae899d6e36c3da5c98c54 (diff)
parent7e253f01715811e0c4f5f5b54317b098f2cd59d9 (diff)
downloadmpv-e0172b96e3b6cc6a8b62ee5a52f780941a43de8b.tar.bz2
mpv-e0172b96e3b6cc6a8b62ee5a52f780941a43de8b.tar.xz
Merge svn changes up to r28862
Diffstat (limited to 'libvo')
-rw-r--r--libvo/video_out.c2
-rw-r--r--libvo/video_out.h2
-rw-r--r--libvo/vo_gl.c79
-rw-r--r--libvo/vo_vdpau.c73
-rw-r--r--libvo/x11_common.c6
5 files changed, 128 insertions, 34 deletions
diff --git a/libvo/video_out.c b/libvo/video_out.c
index ed72a765ef..2791ba54b3 100644
--- a/libvo/video_out.c
+++ b/libvo/video_out.c
@@ -56,7 +56,7 @@ int vo_refresh_rate=0;
int vo_keepaspect=1;
int vo_rootwin=0;
int vo_border=1;
-int WinID = -1;
+int64_t WinID = -1;
int vo_pts=0; // for hw decoding
float vo_fps=0;
diff --git a/libvo/video_out.h b/libvo/video_out.h
index c2f7daa859..6d4b405e56 100644
--- a/libvo/video_out.h
+++ b/libvo/video_out.h
@@ -299,7 +299,7 @@ extern char *vo_subdevice;
extern int vo_colorkey;
-extern int WinID;
+extern int64_t WinID;
typedef struct {
float min;
diff --git a/libvo/vo_gl.c b/libvo/vo_gl.c
index 73ab5dbf82..2c9f48d0e1 100644
--- a/libvo/vo_gl.c
+++ b/libvo/vo_gl.c
@@ -76,6 +76,13 @@ static GLuint osdtex[MAX_OSD_PARTS];
static GLuint osdatex[MAX_OSD_PARTS];
#endif
static GLuint *eosdtex;
+#define LARGE_EOSD_TEX_SIZE 512
+#define TINYTEX_SIZE 16
+#define TINYTEX_COLS (LARGE_EOSD_TEX_SIZE/TINYTEX_SIZE)
+#define TINYTEX_MAX (TINYTEX_COLS*TINYTEX_COLS)
+#define SMALLTEX_SIZE 32
+#define SMALLTEX_COLS (LARGE_EOSD_TEX_SIZE/SMALLTEX_SIZE)
+#define SMALLTEX_MAX (SMALLTEX_COLS*SMALLTEX_COLS)
static GLuint largeeosdtex[2];
//! Display lists that draw the OSD parts
static GLuint osdDispList[MAX_OSD_PARTS];
@@ -284,6 +291,26 @@ static void clearEOSD(void) {
eosdtex = NULL;
}
+static void do_render_osd(int);
+
+static inline int is_tinytex(ass_image_t *i, int tinytexcur) {
+ return i->w < TINYTEX_SIZE && i->h < TINYTEX_SIZE && tinytexcur < TINYTEX_MAX;
+}
+
+static inline int is_smalltex(ass_image_t *i, int smalltexcur) {
+ return i->w < SMALLTEX_SIZE && i->h < SMALLTEX_SIZE && smalltexcur < SMALLTEX_MAX;
+}
+
+static inline void tinytex_pos(int tinytexcur, int *x, int *y) {
+ *x = (tinytexcur % TINYTEX_COLS) * TINYTEX_SIZE;
+ *y = (tinytexcur / TINYTEX_COLS) * TINYTEX_SIZE;
+}
+
+static inline void smalltex_pos(int smalltexcur, int *x, int *y) {
+ *x = (smalltexcur % SMALLTEX_COLS) * SMALLTEX_SIZE;
+ *y = (smalltexcur / SMALLTEX_COLS) * SMALLTEX_SIZE;
+}
+
/**
* \brief construct display list from ass image list
* \param img image list to create OSD from.
@@ -309,17 +336,17 @@ static void genEOSD(mp_eosd_images_t *imgs) {
if (!largeeosdtex[0]) {
glGenTextures(2, largeeosdtex);
BindTexture(gl_target, largeeosdtex[0]);
- glCreateClearTex(gl_target, GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, scale_type, 512, 512, 0);
+ glCreateClearTex(gl_target, GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, scale_type, LARGE_EOSD_TEX_SIZE, LARGE_EOSD_TEX_SIZE, 0);
BindTexture(gl_target, largeeosdtex[1]);
- glCreateClearTex(gl_target, GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, scale_type, 512, 512, 0);
+ glCreateClearTex(gl_target, GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, scale_type, LARGE_EOSD_TEX_SIZE, LARGE_EOSD_TEX_SIZE, 0);
}
for (i = img; i; i = i->next)
{
if (i->w <= 0 || i->h <= 0 || i->stride < i->w)
continue;
- if (i->w < 16 && i->h < 16 && tinytexcur < 1024)
+ if (is_tinytex(i, tinytexcur))
tinytexcur++;
- else if (i->w < 32 && i->h < 32 && smalltexcur < 256)
+ else if (is_smalltex(i, smalltexcur))
smalltexcur++;
else
eosdtexCnt++;
@@ -337,14 +364,12 @@ static void genEOSD(mp_eosd_images_t *imgs) {
mp_msg(MSGT_VO, MSGL_V, "Invalid dimensions OSD for part!\n");
continue;
}
- if (i->w < 16 && i->h < 16 && tinytexcur < 1024) {
- x = (tinytexcur & 31) << 4;
- y = (tinytexcur >> 5) << 4;
+ if (is_tinytex(i, tinytexcur)) {
+ tinytex_pos(tinytexcur, &x, &y);
BindTexture(gl_target, largeeosdtex[0]);
tinytexcur++;
- } else if (i->w < 32 && i->h < 32 && smalltexcur < 256) {
- x = (smalltexcur & 15) << 5;
- y = (smalltexcur >> 4) << 5;
+ } else if (is_smalltex(i, smalltexcur)) {
+ smalltex_pos(smalltexcur, &x, &y);
BindTexture(gl_target, largeeosdtex[1]);
smalltexcur++;
} else {
@@ -364,16 +389,14 @@ skip_upload:
if (i->w <= 0 || i->h <= 0 || i->stride < i->w)
continue;
glColor4ub(i->color >> 24, (i->color >> 16) & 0xff, (i->color >> 8) & 0xff, 255 - (i->color & 0xff));
- if (i->w < 16 && i->h < 16 && tinytexcur < 1024) {
- x = (tinytexcur & 31) << 4;
- y = (tinytexcur >> 5) << 4;
- sx = sy = 512;
+ if (is_tinytex(i, tinytexcur)) {
+ tinytex_pos(tinytexcur, &x, &y);
+ sx = sy = LARGE_EOSD_TEX_SIZE;
BindTexture(gl_target, largeeosdtex[0]);
tinytexcur++;
- } else if (i->w < 32 && i->h < 32 && smalltexcur < 256) {
- x = (smalltexcur & 15) << 5;
- y = (smalltexcur >> 4) << 5;
- sx = sy = 512;
+ } else if (is_smalltex(i, smalltexcur)) {
+ smalltex_pos(smalltexcur, &x, &y);
+ sx = sy = LARGE_EOSD_TEX_SIZE;
BindTexture(gl_target, largeeosdtex[1]);
smalltexcur++;
} else {
@@ -630,8 +653,6 @@ static void create_osd_texture(int x0, int y0, int w, int h,
osdtexCnt++;
}
-static void do_render_osd(void);
-
static void draw_osd(void)
{
if (!use_osd) return;
@@ -643,7 +664,7 @@ static void draw_osd(void)
vo_draw_text_ext(osd_w, osd_h, ass_border_x, ass_border_y, ass_border_x, ass_border_y,
image_width, image_height, create_osd_texture);
}
- if (vo_doublebuffering) do_render_osd();
+ if (vo_doublebuffering) do_render_osd(1);
}
static void do_render(void) {
@@ -662,8 +683,11 @@ static void do_render(void) {
glDisableYUVConversion(gl_target, yuvconvtype);
}
-static void do_render_osd(void) {
- if (osdtexCnt > 0 || eosdDispList) {
+/**
+ * \param type bit 0: render OSD, bit 1: render EOSD
+ */
+static void do_render_osd(int type) {
+ if (((type & 1) && osdtexCnt > 0) || ((type & 2) && eosdDispList)) {
// set special rendering parameters
if (!scaled_osd) {
glMatrixMode(GL_PROJECTION);
@@ -672,11 +696,11 @@ static void do_render_osd(void) {
glOrtho(0, vo_dwidth, vo_dheight, 0, -1, 1);
}
glEnable(GL_BLEND);
- if (eosdDispList) {
+ if ((type & 2) && eosdDispList) {
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glCallList(eosdDispList);
}
- if (osdtexCnt > 0) {
+ if ((type & 1) && osdtexCnt > 0) {
glColor4ub((osd_color >> 16) & 0xff, (osd_color >> 8) & 0xff, osd_color & 0xff, 0xff - (osd_color >> 24));
// draw OSD
#ifndef FAST_OSD
@@ -702,14 +726,14 @@ static void flip_page(void) {
glClear(GL_COLOR_BUFFER_BIT);
} else {
do_render();
- do_render_osd();
+ do_render_osd(3);
if (use_glFinish) glFinish();
else glFlush();
}
}
static void redraw(void) {
- if (vo_doublebuffering) { do_render(); do_render_osd(); }
+ if (vo_doublebuffering) { do_render(); do_render_osd(3); }
flip_page();
}
@@ -1113,6 +1137,7 @@ static int control(uint32_t request, void *data)
if (!data)
return VO_FALSE;
genEOSD(data);
+ if (vo_doublebuffering) do_render_osd(2);
return VO_TRUE;
case VOCTRL_GET_EOSD_RES:
{
diff --git a/libvo/vo_vdpau.c b/libvo/vo_vdpau.c
index 08f5975fdc..fec166c78e 100644
--- a/libvo/vo_vdpau.c
+++ b/libvo/vo_vdpau.c
@@ -49,6 +49,7 @@
#include "gui/interface.h"
#include "libavutil/common.h"
+#include "libavutil/mathematics.h"
#include "libass/ass.h"
#include "libass/ass_mp.h"
@@ -140,6 +141,8 @@ static VdpDecoderCreate *vdp_decoder_create;
static VdpDecoderDestroy *vdp_decoder_destroy;
static VdpDecoderRender *vdp_decoder_render;
+static VdpGenerateCSCMatrix *vdp_generate_csc_matrix;
+
static void *vdpau_lib_handle;
/* output_surfaces[NUM_OUTPUT_SURFACES] is misused for OSD. */
#define osd_surface output_surfaces[NUM_OUTPUT_SURFACES]
@@ -193,12 +196,17 @@ struct {
static int eosd_render_count;
static int eosd_surface_count;
+// Video equalizer
+static VdpProcamp procamp;
+
/*
* X11 specific
*/
static int visible_buf;
static int int_pause;
+static void draw_eosd(void);
+
static void video_to_output_surface(void)
{
VdpTime dummy;
@@ -212,8 +220,11 @@ static void video_to_output_surface(void)
for (i = 0; i <= !!(deint > 1); i++) {
int field = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME;
VdpOutputSurface output_surface;
- if (i)
+ if (i) {
+ draw_eosd();
+ draw_osd();
flip_page();
+ }
if (deint)
field = top_field_first == i ?
VDP_VIDEO_MIXER_PICTURE_STRUCTURE_BOTTOM_FIELD:
@@ -337,6 +348,7 @@ static int win_x11_init_vdpau_procs(void)
&vdp_bitmap_surface_putbits_native},
{VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_BITMAP_SURFACE,
&vdp_output_surface_render_bitmap_surface},
+ {VDP_FUNC_ID_GENERATE_CSC_MATRIX, &vdp_generate_csc_matrix},
{0, NULL}
};
@@ -733,7 +745,6 @@ static void draw_osd(void)
{
mp_msg(MSGT_VO, MSGL_DBG2, "DRAW_OSD\n");
- draw_eosd();
vo_draw_text_ext(vo_dwidth, vo_dheight, border_x, border_y, border_x, border_y,
vid_width, vid_height, draw_osd_I8A8);
}
@@ -785,6 +796,11 @@ static int draw_slice(uint8_t *image[], int stride[], int w, int h,
}
vdp_st = vdp_decoder_create(vdp_device, vdp_decoder_profile, vid_width, vid_height, max_refs, &decoder);
CHECK_ST_WARNING("Failed creating VDPAU decoder");
+ if (vdp_st != VDP_STATUS_OK) {
+ decoder = VDP_INVALID_HANDLE;
+ decoder_max_refs = 0;
+ return VO_FALSE;
+ }
decoder_max_refs = max_refs;
}
vdp_st = vdp_decoder_render(decoder, rndr->surface, (void *)&rndr->info, rndr->bitstream_buffers_used, rndr->bitstream_buffers);
@@ -996,7 +1012,7 @@ static int preinit(const char *arg)
for (i = 0; i < MAX_VIDEO_SURFACES; i++)
surface_render[i].surface = VDP_INVALID_HANDLE;
video_mixer = VDP_INVALID_HANDLE;
- for (i = 0; i < NUM_OUTPUT_SURFACES; i++)
+ for (i = 0; i <= NUM_OUTPUT_SURFACES; i++)
output_surfaces[i] = VDP_INVALID_HANDLE;
vdp_flip_queue = VDP_INVALID_HANDLE;
output_surface_width = output_surface_height = -1;
@@ -1011,9 +1027,55 @@ static int preinit(const char *arg)
eosd_surfaces = NULL;
eosd_targets = NULL;
+ procamp.struct_version = VDP_PROCAMP_VERSION;
+ procamp.brightness = 0.0;
+ procamp.contrast = 1.0;
+ procamp.saturation = 1.0;
+ procamp.hue = 0.0;
+
return 0;
}
+static int get_equalizer(char *name, int *value) {
+ if (!strcasecmp(name, "brightness"))
+ *value = procamp.brightness * 100;
+ else if (!strcasecmp(name, "contrast"))
+ *value = (procamp.contrast-1.0) * 100;
+ else if (!strcasecmp(name, "saturation"))
+ *value = (procamp.saturation-1.0) * 100;
+ else if (!strcasecmp(name, "hue"))
+ *value = procamp.hue * 100 / M_PI;
+ else
+ return VO_NOTIMPL;
+ return VO_TRUE;
+}
+
+static int set_equalizer(char *name, int value) {
+ VdpStatus vdp_st;
+ VdpCSCMatrix matrix;
+ static const VdpVideoMixerAttribute attributes[] = {VDP_VIDEO_MIXER_ATTRIBUTE_CSC_MATRIX};
+ const void *attribute_values[] = {&matrix};
+
+ if (!strcasecmp(name, "brightness"))
+ procamp.brightness = value / 100.0;
+ else if (!strcasecmp(name, "contrast"))
+ procamp.contrast = value / 100.0 + 1.0;
+ else if (!strcasecmp(name, "saturation"))
+ procamp.saturation = value / 100.0 + 1.0;
+ else if (!strcasecmp(name, "hue"))
+ procamp.hue = value / 100.0 * M_PI;
+ else
+ return VO_NOTIMPL;
+
+ vdp_st = vdp_generate_csc_matrix(&procamp, VDP_COLOR_STANDARD_ITUR_BT_601,
+ &matrix);
+ CHECK_ST_WARNING("Error when generating CSC matrix")
+ vdp_st = vdp_video_mixer_set_attribute_values(video_mixer, 1, attributes,
+ attribute_values);
+ CHECK_ST_WARNING("Error when setting CSC matrix")
+ return VO_TRUE;
+}
+
static int control(uint32_t request, void *data)
{
switch (request) {
@@ -1052,12 +1114,12 @@ static int control(uint32_t request, void *data)
return VO_TRUE;
case VOCTRL_SET_EQUALIZER: {
struct voctrl_set_equalizer_args *args = data;
- return vo_x11_set_equalizer(args->name, args->value);
+ return set_equalizer(args->name, args->value);
}
case VOCTRL_GET_EQUALIZER:
{
struct voctrl_get_equalizer_args *args = data;
- return vo_x11_get_equalizer(args->name, args->valueptr);
+ return get_equalizer(args->name, args->valueptr);
}
case VOCTRL_ONTOP:
vo_x11_ontop();
@@ -1069,6 +1131,7 @@ static int control(uint32_t request, void *data)
if (!data)
return VO_FALSE;
generate_eosd(data);
+ draw_eosd();
return VO_TRUE;
case VOCTRL_GET_EOSD_RES: {
mp_eosd_res_t *r = data;
diff --git a/libvo/x11_common.c b/libvo/x11_common.c
index 0b070a868b..b70c0b8dd6 100644
--- a/libvo/x11_common.c
+++ b/libvo/x11_common.c
@@ -1111,6 +1111,12 @@ void vo_x11_create_vo_window(struct vo *vo, XVisualInfo *vis, int x, int y,
vo_x11_nofs_sizepos(vo, vo->dx, vo->dy, width, height);
if (!!vo_fs != !!(flags & VOFLAG_FULLSCREEN))
vo_x11_fullscreen(vo);
+ else if (vo_fs) {
+ // if we are already in fullscreen do not switch back and forth, just
+ // set the size values right.
+ vo->dwidth = vo->opts->vo_screenwidth;
+ vo->dheight = vo->opts->vo_screenheight;
+ }
final:
if (x11->vo_gc != None)
XFreeGC(mDisplay, x11->vo_gc);