From d8644277a9140861b94c4653c9db2736911d36d3 Mon Sep 17 00:00:00 2001 From: nick Date: Mon, 21 Jan 2002 18:55:51 +0000 Subject: =?UTF-8?q?Gamma=20correction=20(based=20on=20patch=20of=20P=C3=A1?= =?UTF-8?q?sztor=20Szil=C3=A1rd=20)=20Seriously?= =?UTF-8?q?=20modified.=20Use=20mplayer=20specific=20command=20line=20argu?= =?UTF-8?q?ments=20for=20that:=20-brightness=20-contrast=20-saturation=20-?= =?UTF-8?q?hue=20(For=20detail=20see=20DOCS)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@4297 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_xv.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) (limited to 'libvo') diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c index e75f1c211f..ef9f2f0a92 100644 --- a/libvo/vo_xv.c +++ b/libvo/vo_xv.c @@ -46,6 +46,8 @@ static vo_info_t vo_info = "" }; +extern int verbose; + /* since it doesn't seem to be defined on some platforms */ int XShmGetEventBase(Display*); @@ -95,7 +97,6 @@ static uint32_t drwcX,drwcY,dwidth,dheight,mFullscreen; static uint32_t mdwidth,mdheight; #endif - static void (*draw_alpha_fnc)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride); static void draw_alpha_yv12(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ @@ -113,6 +114,56 @@ static void draw_alpha_uyvy(int x0,int y0, int w,int h, unsigned char* src, unsi static void draw_alpha_null(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ } +extern int vo_gamma_brightness; +extern int vo_gamma_saturation; +extern int vo_gamma_contrast; +extern int vo_gamma_hue; +extern int vo_gamma_red_intense; +extern int vo_gamma_green_intense; +extern int vo_gamma_blue_intense; + +static void set_gamma_correction( unsigned int xv_port ) +{ + XvAttribute *attributes; + int howmany; +// get available attributes + attributes = XvQueryPortAttributes(mDisplay, xv_port, &howmany); + for (i = 0; i < howmany && attributes; i++) + { + if (attributes[i].flags & XvSettable) + { + int xv_min,xv_max,xv_atomka; + xv_min = attributes[i].min_value; + xv_max = attributes[i].max_value; + xv_atomka = XInternAtom(mDisplay, attributes[i].name, True); +// since we have SET_DEFAULTS first in our list, we can check if it's available +// then trigger it if it's ok so that the other values are at default upon query + if (xv_atomka != None) + { + int port_value,port_min,port_max,port_mid; + if(strcmp(attributes[i].name,"XV_BRIGHTNESS") == 0) + port_value = vo_gamma_brightness; + else + if(strcmp(attributes[i].name,"XV_SATURATION") == 0) + port_value = vo_gamma_saturation; + else + if(strcmp(attributes[i].name,"XV_CONTRAST") == 0) + port_value = vo_gamma_contrast; + else + if(strcmp(attributes[i].name,"XV_HUE") == 0) + port_value = vo_gamma_hue; + else continue; + port_min = xv_min; + port_max = xv_max; + port_mid = (port_min + port_max) / 2; + port_value = port_mid + (port_value * (port_max - port_min)) / 2000; + if(verbose > 1) + printf("vo_xv: set gamma %s to %i (min %i max %i mid %i)\n",attributes[i].name,port_value,port_min,port_max,port_mid); + XvSetPortAttribute(mDisplay, xv_port, xv_atomka, port_value); + } + } + } +} /* * connect to server, create and map window, @@ -131,6 +182,8 @@ static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t XGCValues xgcv; XSetWindowAttributes xswa; unsigned long xswamask; + XvAttribute *attributes; + int howmany, j, notyetset = 0; aspect_save_orig(width,height); aspect_save_prescale(d_width,d_height); @@ -290,6 +343,7 @@ static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t } } #endif + set_gamma_correction(xv_port); XGetGeometry( mDisplay,mywindow,&mRoot,&drwX,&drwY,&drwWidth,&drwHeight,&drwBorderWidth,&drwDepth ); drwX=0; drwY=0; -- cgit v1.2.3