summaryrefslogtreecommitdiff
path: root/src/video_out/video_out_opengl.c
diff options
context:
space:
mode:
authorDarren Salt <linux@youmustbejoking.demon.co.uk>2009-12-17 18:48:07 +0000
committerDarren Salt <linux@youmustbejoking.demon.co.uk>2009-12-17 18:48:07 +0000
commit926093783c7367a23291063bcafc199aee2b12eb (patch)
tree4165a6c04853d315293b39be646acef485684cc1 /src/video_out/video_out_opengl.c
parent44a9e76d27c08c715df5c79f2ad3308eeadef205 (diff)
parent8bd8e600bf475426cbcd5b8f8f89fb2d6e53ec29 (diff)
downloadxine-lib-926093783c7367a23291063bcafc199aee2b12eb.tar.gz
xine-lib-926093783c7367a23291063bcafc199aee2b12eb.tar.bz2
Merge from 1.2 main.
Diffstat (limited to 'src/video_out/video_out_opengl.c')
-rw-r--r--src/video_out/video_out_opengl.c124
1 files changed, 62 insertions, 62 deletions
diff --git a/src/video_out/video_out_opengl.c b/src/video_out/video_out_opengl.c
index d66e85ae9..f39a8714c 100644
--- a/src/video_out/video_out_opengl.c
+++ b/src/video_out/video_out_opengl.c
@@ -1,13 +1,13 @@
/*
* Copyright (C) 2000-2003 the xine project
- *
+ *
* This file is part of xine, a free video player.
- *
+ *
* xine is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* xine is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -147,7 +147,7 @@ typedef struct {
double ratio;
uint8_t *rgb, *rgb_dst;
-
+
yuv2rgb_t *yuv2rgb; /* yuv2rgb converter set up for this frame */
} opengl_frame_t;
@@ -203,7 +203,7 @@ typedef struct {
PFNMYGLPROGRAMENVPARAMETER4FARBPROC glProgramEnvParameter4fARB;
PFNMYGLGENTEXTURESEXTPROC glGenTexturesEXT;
PFNMYGLBINDTEXTUREEXTPROC glBindTextureEXT;
-
+
int yuv2rgb_brightness;
int yuv2rgb_contrast;
int yuv2rgb_saturation;
@@ -238,7 +238,7 @@ typedef struct {
int (*setup)(opengl_driver_t *);
/* Flag: needs output converted to rgb (is able to do YUV otherwise) */
int needsrgb;
- /* Default action: what to do if there's no new image
+ /* Default action: what to do if there's no new image
* typically either RENDER_NONE or RENDER_DRAW (for animated render's) */
enum render_e defaction;
/* Fallback: change to following render backend if this one doesn't work */
@@ -332,7 +332,7 @@ static void render_cyl (opengl_driver_t *this, opengl_frame_t *frame) {
float off;
float tx, ty;
struct timeval curtime;
-
+
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
/* Calc timing + texture coords */
@@ -346,10 +346,10 @@ static void render_cyl (opengl_driver_t *this, opengl_frame_t *frame) {
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
glTranslatef (0, 0, -10);
- glRotatef (off * CYCLE_FACTOR1, 1, 0, 0);
- glRotatef (off, 0, 0, 1);
- glRotatef (off * CYCLE_FACTOR2, 0, 1, 0);
-
+ glRotatef (off * CYCLE_FACTOR1, 1, 0, 0);
+ glRotatef (off, 0, 0, 1);
+ glRotatef (off * CYCLE_FACTOR2, 0, 1, 0);
+
/* Note that this is not aspect ratio corrected */
glBegin (GL_QUADS);
for (i = 0; i < CYL_TESSELATION; i++) {
@@ -368,7 +368,7 @@ static void render_cyl (opengl_driver_t *this, opengl_frame_t *frame) {
}
/* Animated spinning environment mapped torus */
-#define DIST_FACTOR 16.568542 /* 2 * (sqrt(2)-1) * 20 */
+#define DIST_FACTOR 16.568542 /* 2 * (sqrt(2)-1) * 20 */
static void render_env_tor (opengl_driver_t *this, opengl_frame_t *frame) {
float off;
float x1, y1, x2, y2, tx, ty;
@@ -402,7 +402,7 @@ static void render_env_tor (opengl_driver_t *this, opengl_frame_t *frame) {
glLoadIdentity ();
glDepthFunc (GL_ALWAYS);
glDepthMask (GL_FALSE);
-
+
glBegin (GL_QUADS);
glColor3f (1, 1, 1);
glTexCoord2f (tx, 0); glVertex3f (x2, y2, -20);
@@ -410,7 +410,7 @@ static void render_env_tor (opengl_driver_t *this, opengl_frame_t *frame) {
glTexCoord2f (0, ty); glVertex3f (x1, y1, -20);
glTexCoord2f (tx, ty); glVertex3f (x2, y1, -20);
glEnd ();
-
+
glPopMatrix ();
glDepthFunc (GL_LEQUAL);
glDepthMask (GL_TRUE);
@@ -447,7 +447,7 @@ static int render_help_image_tex (opengl_driver_t *this, int new_w, int new_h,
tex_w <<= 1;
while (tex_h < new_h)
tex_h <<= 1;
-
+
if (tex_w != this->tex_width || tex_h != this->tex_height) {
char *tmp = calloc (tex_w * tex_h, 4); /* 4 enough until RGBA */
if (this->glBindTextureEXT)
@@ -463,7 +463,7 @@ static int render_help_image_tex (opengl_driver_t *this, int new_w, int new_h,
this->tex_width = tex_w;
this->tex_height = tex_h;
lprintf ("* new texsize: %dx%d\n", tex_w, tex_h);
- }
+ }
this->last_width = new_w;
this->last_height = new_h;
return 1;
@@ -486,7 +486,7 @@ static int render_help_image_tiledtex (opengl_driver_t *this,
tex_w <<= 1;
while (tex_h < new_h)
tex_h <<= 1;
-
+
if (tex_w != this->tex_width || tex_h != this->tex_height) {
char *tmp = calloc (tex_w * tex_h, 4); /* 4 enough until RGBA */
if (this->glBindTextureEXT)
@@ -526,7 +526,7 @@ static int render_help_image_tiledtex (opengl_driver_t *this,
this->tex_width = tex_w;
this->tex_height = tex_h;
lprintf ("* new texsize: %dx%d on %d tiles\n", tex_w, tex_h, num);
- }
+ }
this->last_width = new_w;
this->last_height = new_h;
return 1;
@@ -715,7 +715,7 @@ static void *getdladdr (const GLubyte *_funcName) {
handle = dlopen (NULL, RTLD_LAZY);
}
return dlsym (handle, funcName);
-
+
#else /* all other Un*xes */
return dlsym (0, funcName);
@@ -888,7 +888,7 @@ static int render_setup_cyl (opengl_driver_t *this) {
static int render_setup_torus (opengl_driver_t *this) {
int i, j, k;
int ret;
-
+
ret = render_setup_3d (this);
ret &= render_help_setup_tex (this);
@@ -942,7 +942,7 @@ static int render_setup_fp_yuv (opengl_driver_t *this) {
"MAD res, { 0, -.391, 2.018 }, tmp.xxxw, res;"
"MAD result.color, { 1.596, -.813, 0 }, tmp.yyyw, res;"
"END";
-
+
ret = render_setup_tex2d (this);
if (! this->has_fragprog)
return 0;
@@ -968,7 +968,7 @@ static int render_setup_fp_yuv (opengl_driver_t *this) {
*/
/* name, display, image, setup, needsrgb, defaction, fallback */
static const opengl_render_t opengl_rb[] = {
- { "2D_Tex_Fragprog", render_tex2d, render_image_fp_yuv,
+ { "2D_Tex_Fragprog", render_tex2d, render_image_fp_yuv,
render_setup_fp_yuv, 0, RENDER_NONE, 1 },
{ "2D_Tex", render_tex2d, render_image_tex,
render_setup_tex2d, 1, RENDER_NONE, 2 },
@@ -1009,10 +1009,10 @@ static void *render_run (opengl_driver_t *this) {
struct timeval curtime;
struct timespec timeout;
const opengl_render_t *render;
-
+
lprintf ("* render thread created\n");
while (1) {
-
+
/* Wait for render action */
pthread_mutex_lock (&this->render_action_mutex);
if (! this->render_action) {
@@ -1216,28 +1216,28 @@ static uint32_t opengl_get_capabilities (vo_driver_t *this_gen) {
static void opengl_frame_proc_slice (vo_frame_t *vo_img, uint8_t **src) {
opengl_frame_t *frame = (opengl_frame_t *) vo_img ;
/* opengl_driver_t *this = (opengl_driver_t *) vo_img->driver; */
-
+
vo_img->proc_called = 1;
if (! frame->rgb_dst)
return;
/* lprintf ("%p: frame_copy src %p=%p to %p\n", frame, src[0], frame->chunk[0], frame->rgb_dst); */
- if( frame->vo_frame.crop_left || frame->vo_frame.crop_top ||
+ if( frame->vo_frame.crop_left || frame->vo_frame.crop_top ||
frame->vo_frame.crop_right || frame->vo_frame.crop_bottom )
{
/* TODO: opengl *could* support this?!? */
/* cropping will be performed by video_out.c */
return;
}
-
+
if (frame->format == XINE_IMGFMT_YV12)
frame->yuv2rgb->yuv2rgb_fun (frame->yuv2rgb, frame->rgb_dst,
src[0], src[1], src[2]);
else
frame->yuv2rgb->yuy22rgb_fun (frame->yuv2rgb, frame->rgb_dst,
src[0]);
-
+
/* lprintf ("frame_copy...done\n"); */
}
@@ -1248,7 +1248,7 @@ static void opengl_frame_field (vo_frame_t *vo_img, int which_field) {
/* lprintf ("%p: frame_field rgb %p which_field %x\n", frame, frame->rgb, which_field); */
if (! opengl_rb[this->render_fun_id].needsrgb) {
- frame->rgb_dst = NULL;
+ frame->rgb_dst = NULL;
return;
}
@@ -1296,7 +1296,7 @@ static vo_frame_t *opengl_alloc_frame (vo_driver_t *this_gen) {
*/
frame->vo_frame.proc_slice = opengl_frame_proc_slice;
frame->vo_frame.proc_frame = NULL;
- frame->vo_frame.field = opengl_frame_field;
+ frame->vo_frame.field = opengl_frame_field;
frame->vo_frame.dispose = opengl_frame_dispose;
frame->vo_frame.driver = this_gen;
@@ -1350,7 +1350,7 @@ static void opengl_update_frame_format (vo_driver_t *this_gen,
/* lprintf ("updating frame to %d x %d (ratio=%g, format=%08x)\n", width, height, ratio, format); */
flags &= VO_BOTH_FIELDS;
-
+
XLockDisplay (this->display);
/* (re-) allocate render space */
@@ -1401,7 +1401,7 @@ static void opengl_update_frame_format (vo_driver_t *this_gen,
frame->height = height;
frame->format = format;
- XUnlockDisplay (this->display);
+ XUnlockDisplay (this->display);
opengl_frame_field ((vo_frame_t *)frame, flags);
}
@@ -1435,7 +1435,7 @@ static void opengl_overlay_clut_yuv2rgb(opengl_driver_t *this, vo_overlay_t *ov
}
}
-static void opengl_overlay_begin (vo_driver_t *this_gen,
+static void opengl_overlay_begin (vo_driver_t *this_gen,
vo_frame_t *frame_gen, int changed) {
opengl_driver_t *this = (opengl_driver_t *) this_gen;
@@ -1443,10 +1443,10 @@ static void opengl_overlay_begin (vo_driver_t *this_gen,
if (this->ovl_changed && this->xoverlay) {
XLockDisplay (this->display);
- x11osd_clear(this->xoverlay);
+ x11osd_clear(this->xoverlay);
XUnlockDisplay (this->display);
}
-
+
this->alphablend_extra_data.offset_x = frame_gen->overlay_offset_x;
this->alphablend_extra_data.offset_y = frame_gen->overlay_offset_y;
}
@@ -1463,7 +1463,7 @@ static void opengl_overlay_end (vo_driver_t *this_gen, vo_frame_t *vo_img) {
this->ovl_changed = 0;
}
-static void opengl_overlay_blend (vo_driver_t *this_gen,
+static void opengl_overlay_blend (vo_driver_t *this_gen,
vo_frame_t *frame_gen, vo_overlay_t *overlay) {
opengl_driver_t *this = (opengl_driver_t *) this_gen;
opengl_frame_t *frame = (opengl_frame_t *) frame_gen;
@@ -1473,7 +1473,7 @@ static void opengl_overlay_blend (vo_driver_t *this_gen,
if (overlay->unscaled) {
if (this->ovl_changed && this->xoverlay) {
XLockDisplay (this->display);
- x11osd_blend (this->xoverlay, overlay);
+ x11osd_blend (this->xoverlay, overlay);
XUnlockDisplay (this->display);
}
} else {
@@ -1514,7 +1514,7 @@ static int opengl_redraw_needed (vo_driver_t *this_gen) {
opengl_compute_ideal_size(this);
- if( _x_vo_scale_redraw_needed( &this->sc ) ) {
+ if( _x_vo_scale_redraw_needed( &this->sc ) ) {
opengl_compute_rgb_size(this);
pthread_mutex_lock (&this->render_action_mutex);
if (this->render_action <= RENDER_CLEAN) {
@@ -1524,10 +1524,10 @@ static int opengl_redraw_needed (vo_driver_t *this_gen) {
pthread_mutex_unlock (&this->render_action_mutex);
ret = 1;
}
- }
+ }
else
ret = 1;
-
+
/* lprintf ("done...redraw_needed: %d\n", ret); */
return ret;
}
@@ -1547,7 +1547,7 @@ static void opengl_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen)
this->frame[0] = frame;
this->render_frame_changed = 1;
/* lprintf ("video_out_opengl: cur_frame updated to %d\n", frame->vo_frame.id); */
-
+
/*
* let's see if this frame is different in size / aspect
* ratio from the previous one
@@ -1558,7 +1558,7 @@ static void opengl_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen)
/* lprintf("frame format changed\n"); */
this->sc.force_redraw = 1; /* trigger re-calc of output size */
}
-
+
/*
* tell gui that we are about to display a frame,
* ask for offset and output size
@@ -1594,14 +1594,14 @@ static int opengl_get_property (vo_driver_t *this_gen, int property) {
case VO_PROP_WINDOW_HEIGHT:
return this->sc.gui_height;
default:
- xprintf(this->xine, XINE_VERBOSITY_DEBUG,
+ xprintf(this->xine, XINE_VERBOSITY_DEBUG,
"video_out_opengl: tried to get unsupported property %d\n", property);
}
return 0;
}
-static int opengl_set_property (vo_driver_t *this_gen,
+static int opengl_set_property (vo_driver_t *this_gen,
int property, int value) {
opengl_driver_t *this = (opengl_driver_t *) this_gen;
@@ -1613,7 +1613,7 @@ static int opengl_set_property (vo_driver_t *this_gen,
opengl_compute_ideal_size (this);
this->sc.force_redraw = 1; /* trigger re-calc of output size */
- xprintf(this->xine, XINE_VERBOSITY_DEBUG,
+ xprintf(this->xine, XINE_VERBOSITY_DEBUG,
"video_out_opengl: aspect ratio changed to %s\n", _x_vo_scale_aspect_ratio_name_table[value]);
break;
case VO_PROP_BRIGHTNESS:
@@ -1641,7 +1641,7 @@ static int opengl_set_property (vo_driver_t *this_gen,
this->sc.force_redraw = 1;
break;
default:
- xprintf (this->xine, XINE_VERBOSITY_DEBUG,
+ xprintf (this->xine, XINE_VERBOSITY_DEBUG,
"video_out_opengl: tried to set unsupported property %d\n", property);
}
@@ -1664,7 +1664,7 @@ static void opengl_get_property_min_max (vo_driver_t *this_gen,
}
}
-static int opengl_gui_data_exchange (vo_driver_t *this_gen,
+static int opengl_gui_data_exchange (vo_driver_t *this_gen,
int data_type, void *data) {
opengl_driver_t *this = (opengl_driver_t *) this_gen;
@@ -1679,7 +1679,7 @@ static int opengl_gui_data_exchange (vo_driver_t *this_gen,
/* lprintf ("expose event\n"); */
if (this->frame[0]) {
XExposeEvent * xev = (XExposeEvent *) data;
-
+
if (xev && xev->count == 0) {
pthread_mutex_lock (&this->render_action_mutex);
if (this->render_action <= RENDER_CLEAN) {
@@ -1716,9 +1716,9 @@ static int opengl_gui_data_exchange (vo_driver_t *this_gen,
&this->render_action_mutex);
pthread_mutex_unlock (&this->render_action_mutex);
break;
-
+
case XINE_GUI_SEND_DRAWABLE_CHANGED:
-
+
pthread_mutex_lock (&this->render_action_mutex);
this->render_action = RENDER_RELEASE;
pthread_cond_signal (&this->render_action_cond);
@@ -1746,7 +1746,7 @@ static int opengl_gui_data_exchange (vo_driver_t *this_gen,
if (this->frame[0]) {
x11_rectangle_t *rect = data;
int x1, y1, x2, y2;
-
+
_x_vo_scale_translate_gui2video(&this->sc,
rect->x, rect->y,
&x1, &y1);
@@ -1775,7 +1775,7 @@ static void opengl_dispose (vo_driver_t *this_gen) {
this->render_action = RENDER_EXIT;
pthread_cond_signal (&this->render_action_cond);
pthread_mutex_unlock (&this->render_action_mutex);
- pthread_join (this->render_thread, NULL);
+ pthread_join (this->render_thread, NULL);
pthread_mutex_destroy (&this->render_action_mutex);
pthread_cond_destroy (&this->render_action_cond);
pthread_cond_destroy (&this->render_return_cond);
@@ -1793,7 +1793,7 @@ static void opengl_dispose (vo_driver_t *this_gen) {
}
_x_alphablend_free(&this->alphablend_extra_data);
-
+
free (this);
}
@@ -1820,7 +1820,7 @@ static vo_driver_t *opengl_open_plugin (video_driver_class_t *class_gen, const v
opengl_driver_t *this;
char **render_fun_names;
int i;
-
+
this = (opengl_driver_t *) calloc(1, sizeof(opengl_driver_t));
if (!this)
@@ -1834,9 +1834,9 @@ static vo_driver_t *opengl_open_plugin (video_driver_class_t *class_gen, const v
this->sc.dest_size_cb = visual->dest_size_cb;
this->sc.user_data = visual->user_data;
this->sc.user_ratio = XINE_VO_ASPECT_AUTO;
-
+
_x_alphablend_init (&this->alphablend_extra_data, class->xine);
-
+
this->drawable = visual->d;
this->gui_width = this->gui_height = -1;
this->last_width = this->last_height = -1;
@@ -1846,7 +1846,7 @@ static vo_driver_t *opengl_open_plugin (video_driver_class_t *class_gen, const v
this->ovl_changed = 0;
this->xine = class->xine;
this->config = config;
-
+
this->vo_driver.get_capabilities = opengl_get_capabilities;
this->vo_driver.alloc_frame = opengl_alloc_frame;
this->vo_driver.update_frame_format = opengl_update_frame_format;
@@ -1864,8 +1864,8 @@ static vo_driver_t *opengl_open_plugin (video_driver_class_t *class_gen, const v
this->yuv2rgb_brightness = 0;
this->yuv2rgb_contrast = 128;
this->yuv2rgb_saturation = 128;
-
- this->yuv2rgb_factory = yuv2rgb_factory_init (YUV_FORMAT, YUV_SWAP_MODE,
+
+ this->yuv2rgb_factory = yuv2rgb_factory_init (YUV_FORMAT, YUV_SWAP_MODE,
NULL);
this->yuv2rgb_factory->set_csc_levels (this->yuv2rgb_factory,
this->yuv2rgb_brightness,
@@ -1917,7 +1917,7 @@ static vo_driver_t *opengl_open_plugin (video_driver_class_t *class_gen, const v
"it also reduces flickering a lot.\n"
"It should not have any performance impact."),
20, NULL, NULL);
-
+
pthread_mutex_init (&this->render_action_mutex, NULL);
pthread_cond_init (&this->render_action_cond, NULL);
pthread_cond_init (&this->render_return_cond, NULL);
@@ -1947,7 +1947,7 @@ static vo_driver_t *opengl_open_plugin (video_driver_class_t *class_gen, const v
xprintf (this->xine, XINE_VERBOSITY_LOG,
"video_out_opengl: default visual not OpenGL capable\n"
" plugin will only work with clients supporting XINE_GUI_SEND_SELECT_VISUAL.\n");
-
+
return &this->vo_driver;
}
@@ -2036,7 +2036,7 @@ static const vo_info_t vo_info_opengl = {
*/
const plugin_info_t xine_plugin_info[] EXPORTED = {
- /* type, API, "name", version, special_info, init_function */
+ /* type, API, "name", version, special_info, init_function */
{ PLUGIN_VIDEO_OUT, 22, "opengl", XINE_VERSION_CODE, &vo_info_opengl, opengl_init_class },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};