changeset 4229:9a33ad2f3547

gamma correction support
author nick
date Fri, 18 Jan 2002 09:11:11 +0000
parents bcbe3359e88f
children 7444f7901ae2
files cfg-mplayer.h libvo/video_out.c libvo/vosub_vidix.c vidix/drivers/radeon_vid.c
diffstat 4 files changed, 84 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/cfg-mplayer.h	Fri Jan 18 09:10:00 2002 +0000
+++ b/cfg-mplayer.h	Fri Jan 18 09:11:11 2002 +0000
@@ -39,6 +39,14 @@
 extern int vo_doublebuffering;
 extern int vo_fsmode;
 extern int vo_dbpp;
+/* gamma correction */
+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;
 #endif
 
 #ifdef USE_SUB
@@ -237,6 +245,13 @@
 	{"fsmode", &vo_fsmode, CONF_TYPE_INT, CONF_RANGE, 0, 15, NULL},
 	{"double", &vo_doublebuffering, CONF_TYPE_FLAG, 0, 0, 1, NULL},
 	{"nodouble", &vo_doublebuffering, CONF_TYPE_FLAG, 0, 1, 0, NULL},
+	{"brightness",&vo_gamma_brightness, CONF_TYPE_INT, CONF_RANGE, -1000, 1000, NULL},
+	{"saturation",&vo_gamma_saturation, CONF_TYPE_INT, CONF_RANGE, -1000, 1000, NULL},
+	{"constrast",&vo_gamma_contrast, CONF_TYPE_INT, CONF_RANGE, -1000, 1000, NULL},
+	{"hue",&vo_gamma_hue, CONF_TYPE_INT, CONF_RANGE, -1000, 1000, NULL},
+	{"red_instense",&vo_gamma_red_intense, CONF_TYPE_INT, CONF_RANGE, -1000, 1000, NULL},
+	{"green_intense",&vo_gamma_green_intense, CONF_TYPE_INT, CONF_RANGE, -1000, 1000, NULL},
+	{"blue_intense",&vo_gamma_blue_intense, CONF_TYPE_INT, CONF_RANGE, -1000, 1000, NULL},
 #endif
 
 #ifdef HAVE_AA
--- a/libvo/video_out.c	Fri Jan 18 09:10:00 2002 +0000
+++ b/libvo/video_out.c	Fri Jan 18 09:11:11 2002 +0000
@@ -47,7 +47,16 @@
 float vo_fps=0; // for mp1e rte
 
 char *vo_subdevice = NULL;
-
+/****************************************
+*	GAMMA CORRECTION		*
+****************************************/
+int vo_gamma_brightness=0;
+int vo_gamma_saturation=0;
+int vo_gamma_contrast=0;
+int vo_gamma_hue=0;
+int vo_gamma_red_intense=0;
+int vo_gamma_green_intense=0;
+int vo_gamma_blue_intense=0;
 //
 // Externally visible list of all vo drivers
 //
--- a/libvo/vosub_vidix.c	Fri Jan 18 09:10:00 2002 +0000
+++ b/libvo/vosub_vidix.c	Fri Jan 18 09:11:11 2002 +0000
@@ -154,15 +154,51 @@
 	return 0;  
 }
 
+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;
+
+vidix_video_eq_t vid_eq;
+
 void vidix_start(void)
 {
     int err;
 
+    if(verbose > 1)
+    {
+	printf("vosub_vidix: vo_gamma_brightness=%i\n"
+	       "vosub_vidix: vo_gamma_saturation=%i\n"
+	       "vosub_vidix: vo_gamma_contrast=%i\n"
+	       "vosub_vidix: vo_gamma_hue=%i\n"
+	       "vosub_vidix: vo_gamma_red_intense=%i\n"
+	       "vosub_vidix: vo_gamma_green_intense=%i\n"
+	       "vosub_vidix: vo_gamma_blue_intense=%i\n"
+	       ,vo_gamma_brightness
+	       ,vo_gamma_saturation
+	       ,vo_gamma_contrast
+	       ,vo_gamma_hue
+	       ,vo_gamma_red_intense
+	       ,vo_gamma_green_intense
+	       ,vo_gamma_blue_intense);
+    }
     if((err=vdlPlaybackOn(vidix_handler))!=0)
     {
 	printf("vosub_vidix: Can't start playback: %s\n",strerror(err));
 	return -1;
     }
+    vid_eq.brightness = vo_gamma_brightness;
+    vid_eq.saturation = vo_gamma_saturation;
+    vid_eq.contrast = vo_gamma_contrast;
+    vid_eq.hue = vo_gamma_hue;
+    vid_eq.red_intense = vo_gamma_red_intense;
+    vid_eq.green_intense = vo_gamma_green_intense;
+    vid_eq.blue_intense = vo_gamma_blue_intense;
+    vid_eq.flags = VEQ_FLG_ITU_R_BT_601;
+    vdlPlaybackSetEq(vidix_handler,&vid_eq);
     return 0;
 }
 
--- a/vidix/drivers/radeon_vid.c	Fri Jan 18 09:10:00 2002 +0000
+++ b/vidix/drivers/radeon_vid.c	Fri Jan 18 09:11:11 2002 +0000
@@ -1070,20 +1070,39 @@
   return 0;
 }
 
+#ifndef RAGE128
+#define RTFSaturation(a)   (1.0 + ((a)*1.0)/1000.0)
+#define RTFBrightness(a)   (((a)*1.0)/2000.0)
+#define RTFContrast(a)   (1.0 + ((a)*1.0)/1000.0)
+#define RTFHue(a)   (((a)*3.1416)/1000.0)
+#define RTFCheckParam(a) {if((a)<-1000) (a)=-1000; if((a)>1000) (a)=1000;}
+#endif
+
 int 	vixPlaybackSetEq( const vidix_video_eq_t * eq)
 {
 #ifdef RAGE128
   int br,sat;
+#else
+  int itu_space;
 #endif
     memcpy(&equal,eq,sizeof(vidix_video_eq_t));
 #ifdef RAGE128
     br = equal.brightness * 64 / 1000;
-    sat = equal.saturation * 32 / 1000;
-    if(sat < 0) sat = 0;
+    if(br < -64) br = -64; if(br > 63) br = 63;
+    sat = (equal.saturation + 1000) * 32 / 1000;
+    if(sat < 0) sat = 0; if(sat > 31) sat = 31;
     OUTREG(OV0_COLOUR_CNTL, (br & 0x7f) | (sat << 8) | (sat << 16));
 #else
-  radeon_set_transform(equal.brightness,equal.contrast,
-		       equal.saturation,equal.hue,0);
+  itu_space = equal.flags == VEQ_FLG_ITU_R_BT_709 ? 1 : 0;
+  RTFCheckParam(equal.brightness);
+  RTFCheckParam(equal.saturation);
+  RTFCheckParam(equal.contrast);
+  RTFCheckParam(equal.hue);
+  radeon_set_transform(RTFBrightness(equal.brightness),
+		       RTFContrast(equal.contrast),
+		       RTFSaturation(equal.saturation),
+		       RTFHue(equal.hue),
+		       itu_space);
 #endif
   return 0;
 }