[Mplayer-cvslog] CVS: main/libmpcodecs vf_scale.c,1.30,1.31

Michael Niedermayer CVS michael at mplayerhq.hu
Fri Feb 21 21:35:20 CET 2003


Update of /cvsroot/mplayer/main/libmpcodecs
In directory mail:/var/tmp.root/cvs-serv8199/libmpcodecs

Modified Files:
	vf_scale.c 
Log Message:
yuv2rgb brightness/contrast/saturation/different colorspaces support finished
yuv2rgb deglobalize
yuv2rgb optimizations / cleanup
bugs?


Index: vf_scale.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf_scale.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- vf_scale.c	4 Feb 2003 17:51:39 -0000	1.30
+++ vf_scale.c	21 Feb 2003 20:35:08 -0000	1.31
@@ -220,6 +220,59 @@
     return vf_next_put_image(vf,dmpi);
 }
 
+static int control(struct vf_instance_s* vf, int request, void* data){
+    int *table;
+    int *inv_table;
+    int r;
+    int brightness, contrast, saturation, srcRange, dstRange;
+    vf_equalizer_t *eq;
+
+    switch(request){
+    case VFCTRL_GET_EQUALIZER:
+	r= sws_getColorspaceDetails(vf->priv->ctx, &inv_table, &srcRange, &table, &dstRange, &brightness, &contrast, &saturation);
+	if(r<0) break;
+
+	eq = data;
+	if (!strcmp(eq->item,"brightness")) {
+		eq->value =  ((brightness*100) + (1<<15))>>16;
+	}
+	else if (!strcmp(eq->item,"contrast")) {
+		eq->value = (((contrast  *100) + (1<<15))>>16) - 100;
+	}
+	else if (!strcmp(eq->item,"saturation")) {
+		eq->value = (((saturation*100) + (1<<15))>>16) - 100;
+	}
+	else
+		break;
+	return CONTROL_TRUE;
+    case VFCTRL_SET_EQUALIZER:
+	r= sws_getColorspaceDetails(vf->priv->ctx, &inv_table, &srcRange, &table, &dstRange, &brightness, &contrast, &saturation);
+	if(r<0) break;
+//printf("set %f %f %f\n", brightness/(float)(1<<16), contrast/(float)(1<<16), saturation/(float)(1<<16));
+	eq = data;
+
+	if (!strcmp(eq->item,"brightness")) {
+		brightness = (( eq->value     <<16) + 50)/100;
+	}
+	else if (!strcmp(eq->item,"contrast")) {
+		contrast   = (((eq->value+100)<<16) + 50)/100;
+	}
+	else if (!strcmp(eq->item,"saturation")) {
+		saturation = (((eq->value+100)<<16) + 50)/100;
+	}
+	else
+		break;
+
+	r= sws_setColorspaceDetails(vf->priv->ctx, inv_table, srcRange, table, dstRange, brightness, contrast, saturation);
+	if(r<0) break;
+
+	return CONTROL_TRUE;
+    default:
+    }
+    
+    return vf_next_control(vf,request,data);
+}
+
 //===========================================================================//
 
 //  supported Input formats: YV12, I420, IYUV, YUY2, UYVY, BGR32, BGR24, BGR16, BGR15, RGB32, RGB24, Y8, Y800
@@ -263,6 +316,7 @@
     vf->config=config;
     vf->put_image=put_image;
     vf->query_format=query_format;
+    vf->control= control;
     vf->priv=malloc(sizeof(struct vf_priv_s));
     // TODO: parse args ->
     vf->priv->ctx=NULL;



More information about the MPlayer-cvslog mailing list