summaryrefslogtreecommitdiffstats
path: root/libvo/vo_gl2.c
diff options
context:
space:
mode:
authorarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-10-29 20:27:47 +0000
committerarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-10-29 20:27:47 +0000
commite5947d8b27b073c78ab3efa9fdde3cc3b0c04e86 (patch)
treeb701474234709c16b62f7a0403b6b5959aad9439 /libvo/vo_gl2.c
parentde382c1b8c5b393963f9abc4c4f781f6f311c759 (diff)
downloadmpv-e5947d8b27b073c78ab3efa9fdde3cc3b0c04e86.tar.bz2
mpv-e5947d8b27b073c78ab3efa9fdde3cc3b0c04e86.tar.xz
here is a somewhat generic equalizer implementation for the X11 vo drivers
using the window's colormap (DirectColor). this method is using the video card's hardware gamma ramp so it involves no performance penalties at all. patch by lucho <lucho@haemimont.bg> git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@7965 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo/vo_gl2.c')
-rw-r--r--libvo/vo_gl2.c70
1 files changed, 67 insertions, 3 deletions
diff --git a/libvo/vo_gl2.c b/libvo/vo_gl2.c
index 12e8e27881..a10567ed84 100644
--- a/libvo/vo_gl2.c
+++ b/libvo/vo_gl2.c
@@ -598,6 +598,50 @@ static void draw_alpha_15(int x0,int y0, int w,int h, unsigned char* src, unsign
static void draw_alpha_null(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){
}
+static int choose_glx_visual(Display *dpy, int scr, XVisualInfo *res_vi)
+{
+ XVisualInfo template, *vi_list;
+ int vi_num, i, best_i, best_weight;
+
+ template.screen = scr;
+ vi_list = XGetVisualInfo(dpy, VisualScreenMask, &template, &vi_num);
+ if (!vi_list) return -1;
+ best_weight = 1000000;
+ for (i = 0; i < vi_num; i++) {
+ int val, res, w = 0;
+ /* of course, the visual must support OpenGL rendering... */
+ res = glXGetConfig(dpy, vi_list + i, GLX_USE_GL, &val);
+ if (res || val == False) continue;
+ /* also it must be doublebuffered ... */
+ res = glXGetConfig(dpy, vi_list + i, GLX_DOUBLEBUFFER, &val);
+ if (res || val == False) continue;
+ /* furthermore it must be RGBA (not color indexed) ... */
+ res = glXGetConfig(dpy, vi_list + i, GLX_RGBA, &val);
+ if (res || val == False) continue;
+ /* prefer less depth buffer size, */
+ res = glXGetConfig(dpy, vi_list + i, GLX_DEPTH_SIZE, &val);
+ if (res) continue;
+ w += val*2;
+ /* stencil buffer size */
+ res = glXGetConfig(dpy, vi_list + i, GLX_STENCIL_SIZE, &val);
+ if (res) continue;
+ w += val*2;
+ /* and colorbuffer alpha size */
+ res = glXGetConfig(dpy, vi_list + i, GLX_ALPHA_SIZE, &val);
+ if (res) continue;
+ w += val;
+ /* and finally, prefer DirectColor-ed visuals to allow color corrections */
+ if (vi_list[i].class != DirectColor) w += 100;
+ if (w < best_weight) {
+ best_weight = w;
+ best_i = i;
+ }
+ }
+ if (best_weight < 1000000) *res_vi = vi_list[best_i];
+ XFree(vi_list);
+ return (best_weight < 1000000) ? 0 : -1;
+}
+
/* connect to server, create and map window,
* allocate colors and (shared) memory
*/
@@ -609,7 +653,7 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
char *hello = (title == NULL) ? "OpenGL rulez" : title;
// char *name = ":0.0";
XSizeHints hint;
- XVisualInfo *vinfo;
+ XVisualInfo *vinfo, vinfo_buf;
XEvent xev;
// XGCValues xgcv;
@@ -655,7 +699,7 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
// XGetWindowAttributes(mDisplay, DefaultRootWindow(mDisplay), &attribs);
// XMatchVisualInfo(mDisplay, screen, depth, TrueColor, &vinfo);
- vinfo=glXChooseVisual( mDisplay,mScreen,wsGLXAttrib );
+ vinfo = choose_glx_visual(mDisplay,mScreen,&vinfo_buf) < 0 ? NULL : &vinfo_buf;
if (vinfo == NULL)
{
printf("[gl2] no GLX support present\n");
@@ -664,7 +708,7 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
xswa.background_pixel = 0;
xswa.border_pixel = 1;
- xswa.colormap = XCreateColormap(mDisplay, mRootWin, vinfo->visual, AllocNone);
+ xswa.colormap = vo_x11_create_colormap(vinfo);
xswamask = CWBackPixel | CWBorderPixel | CWColormap;
if ( vo_window == None )
@@ -1115,6 +1159,26 @@ static uint32_t control(uint32_t request, void *data, ...)
switch (request) {
case VOCTRL_QUERY_FORMAT:
return query_format(*((uint32_t*)data));
+ case VOCTRL_SET_EQUALIZER:
+ {
+ va_list ap;
+ int value;
+
+ va_start(ap, data);
+ value = va_arg(ap, int);
+ va_end(ap);
+ return vo_x11_set_equalizer(data, value);
+ }
+ case VOCTRL_GET_EQUALIZER:
+ {
+ va_list ap;
+ int *value;
+
+ va_start(ap, data);
+ value = va_arg(ap, int *);
+ va_end(ap);
+ return vo_x11_get_equalizer(data, value);
+ }
}
return VO_NOTIMPL;
}