summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEwald Snel <esnel@users.sourceforge.net>2003-02-02 13:38:24 +0000
committerEwald Snel <esnel@users.sourceforge.net>2003-02-02 13:38:24 +0000
commit64209c1471e0233275f034fde449e353ae42772a (patch)
treed630fe5029cacec668423065fdb3fd7af94c748c /src
parent9fefd435c683d35684017b2f60163d3d93c63f4e (diff)
downloadxine-lib-64209c1471e0233275f034fde449e353ae42772a.tar.gz
xine-lib-64209c1471e0233275f034fde449e353ae42772a.tar.bz2
Fix brightness, saturation control for MMX yuv2rgb using the XShm driver
TODO: don't use globals, fix contrast, fix non-MMX yuv2rgb CVS patchset: 4089 CVS date: 2003/02/02 13:38:24
Diffstat (limited to 'src')
-rw-r--r--src/video_out/video_out_xshm.c31
-rw-r--r--src/video_out/yuv2rgb.c4
-rw-r--r--src/video_out/yuv2rgb.h3
-rw-r--r--src/video_out/yuv2rgb_mmx.c42
4 files changed, 61 insertions, 19 deletions
diff --git a/src/video_out/video_out_xshm.c b/src/video_out/video_out_xshm.c
index 6d8f4e5b6..b98130dda 100644
--- a/src/video_out/video_out_xshm.c
+++ b/src/video_out/video_out_xshm.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: video_out_xshm.c,v 1.103 2003/02/02 12:44:04 esnel Exp $
+ * $Id: video_out_xshm.c,v 1.104 2003/02/02 13:38:24 esnel Exp $
*
* video_out_xshm.c, X11 shared memory extension interface for xine
*
@@ -302,7 +302,8 @@ static void dispose_ximage (xshm_driver_t *this,
*/
static uint32_t xshm_get_capabilities (vo_driver_t *this_gen) {
- return VO_CAP_COPIES_IMAGE | VO_CAP_YV12 | VO_CAP_YUY2 | VO_CAP_BRIGHTNESS;
+ return VO_CAP_COPIES_IMAGE | VO_CAP_YV12 | VO_CAP_YUY2 |
+ VO_CAP_BRIGHTNESS | VO_CAP_CONTRAST | VO_CAP_SATURATION;
}
static void xshm_frame_copy (vo_frame_t *vo_img, uint8_t **src) {
@@ -817,7 +818,7 @@ static int xshm_set_property (vo_driver_t *this_gen,
printf ("video_out_xshm: aspect ratio changed to %s\n",
vo_scale_aspect_ratio_name(value));
- } else if ( property == VO_PROP_BRIGHTNESS) {
+ } else if (property == VO_PROP_BRIGHTNESS) {
this->yuv2rgb_brightness = value;
this->yuv2rgb_factory->set_csc_levels (this->yuv2rgb_factory,
@@ -826,9 +827,27 @@ static int xshm_set_property (vo_driver_t *this_gen,
this->yuv2rgb_saturation);
this->sc.force_redraw = 1;
-#ifdef LOG
- printf ("video_out_xshm: gamma changed to %d\n",value);
-#endif
+
+ } else if (property == VO_PROP_CONTRAST) {
+
+ this->yuv2rgb_contrast = value;
+ this->yuv2rgb_factory->set_csc_levels (this->yuv2rgb_factory,
+ this->yuv2rgb_brightness,
+ this->yuv2rgb_contrast,
+ this->yuv2rgb_saturation);
+
+ this->sc.force_redraw = 1;
+
+ } else if (property == VO_PROP_SATURATION) {
+
+ this->yuv2rgb_saturation = value;
+ this->yuv2rgb_factory->set_csc_levels (this->yuv2rgb_factory,
+ this->yuv2rgb_brightness,
+ this->yuv2rgb_contrast,
+ this->yuv2rgb_saturation);
+
+ this->sc.force_redraw = 1;
+
} else {
printf ("video_out_xshm: tried to set unsupported property %d\n", property);
}
diff --git a/src/video_out/yuv2rgb.c b/src/video_out/yuv2rgb.c
index 76ee74e5b..94664721f 100644
--- a/src/video_out/yuv2rgb.c
+++ b/src/video_out/yuv2rgb.c
@@ -22,7 +22,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: yuv2rgb.c,v 1.38 2003/02/02 12:44:05 esnel Exp $
+ * $Id: yuv2rgb.c,v 1.39 2003/02/02 13:38:24 esnel Exp $
*/
#include "config.h"
@@ -3136,7 +3136,7 @@ void yuv2rgb_set_csc_levels (yuv2rgb_factory_t *this,
(uint8_t *)this->table_bU[i] += this->entry_size*(gamma - this->gamma);
}
#ifdef ARCH_X86
- mmx_yuv2rgb_set_gamma(gamma);
+ mmx_yuv2rgb_set_csc_levels (this, brightness, contrast, saturation);
#endif
this->gamma = gamma;
}
diff --git a/src/video_out/yuv2rgb.h b/src/video_out/yuv2rgb.h
index dc65adbb7..a85d37458 100644
--- a/src/video_out/yuv2rgb.h
+++ b/src/video_out/yuv2rgb.h
@@ -156,7 +156,8 @@ yuv2rgb_factory_t *yuv2rgb_factory_init (int mode, int swapped, uint8_t *colorma
* internal stuff below this line
*/
-void mmx_yuv2rgb_set_gamma(int gamma);
+void mmx_yuv2rgb_set_csc_levels(yuv2rgb_factory_t *this,
+ int brightness, int contrast, int saturation);
void yuv2rgb_init_mmxext (yuv2rgb_factory_t *this);
void yuv2rgb_init_mmx (yuv2rgb_factory_t *this);
void yuv2rgb_init_mlib (yuv2rgb_factory_t *this);
diff --git a/src/video_out/yuv2rgb_mmx.c b/src/video_out/yuv2rgb_mmx.c
index 3de843500..b85acd313 100644
--- a/src/video_out/yuv2rgb_mmx.c
+++ b/src/video_out/yuv2rgb_mmx.c
@@ -49,16 +49,25 @@ do { \
static mmx_t mmx_subYw = {0x1010101010101010};
static mmx_t mmx_addYw = {0x0000000000000000};
+static mmx_t mmx_U_green = {0xf37df37df37df37d};
+static mmx_t mmx_U_blue = {0x4093409340934093};
+static mmx_t mmx_V_red = {0x3312331233123312};
+static mmx_t mmx_V_green = {0xe5fce5fce5fce5fc};
+static mmx_t mmx_Y_coeff = {0x253f253f253f253f};
-void mmx_yuv2rgb_set_gamma(int gamma)
+extern const int32_t Inverse_Table_6_9[8][4];
+
+void mmx_yuv2rgb_set_csc_levels(yuv2rgb_factory_t *this,
+ int brightness, int contrast, int saturation)
{
-int a,s,i;
+ int a,s,i;
+ int crv, cbu, cgu, cgv;
- if( gamma <= 16 ) {
+ if( brightness <= 16 ) {
a = 0;
- s = 16 - gamma;
+ s = 16 - brightness;
} else {
- a = gamma - 16;
+ a = brightness - 16;
s = 0;
}
@@ -66,17 +75,30 @@ int a,s,i;
*((unsigned char *)&mmx_subYw + i) = s;
*((unsigned char *)&mmx_addYw + i) = a;
}
+
+ saturation = (saturation > 242) ? 242 : saturation;
+
+ crv = Inverse_Table_6_9[this->matrix_coefficients][0];
+ crv = (crv * saturation + 512) / 1024;
+ cbu = Inverse_Table_6_9[this->matrix_coefficients][1];
+ cbu = (cbu * saturation + 512) / 1024;
+ cgu = Inverse_Table_6_9[this->matrix_coefficients][2];
+ cgu = (cgu * saturation + 512) / 1024;
+ cgv = Inverse_Table_6_9[this->matrix_coefficients][3];
+ cgv = (cgv * saturation + 512) / 1024;
+
+ for (i=0; i < 4; i++) {
+ *((int16_t *)&mmx_U_green + i) = -cgu;
+ *((int16_t *)&mmx_U_blue + i) = cbu;
+ *((int16_t *)&mmx_V_red + i) = crv;
+ *((int16_t *)&mmx_V_green + i) = -cgv;
+ }
}
static inline void mmx_yuv2rgb (uint8_t * py, uint8_t * pu, uint8_t * pv)
{
static mmx_t mmx_80w = {0x0080008000800080};
- static mmx_t mmx_U_green = {0xf37df37df37df37d};
- static mmx_t mmx_U_blue = {0x4093409340934093};
- static mmx_t mmx_V_red = {0x3312331233123312};
- static mmx_t mmx_V_green = {0xe5fce5fce5fce5fc};
static mmx_t mmx_00ffw = {0x00ff00ff00ff00ff};
- static mmx_t mmx_Y_coeff = {0x253f253f253f253f};
movq_m2r (*py, mm6); // mm6 = Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0
pxor_r2r (mm4, mm4); // mm4 = 0