summaryrefslogtreecommitdiff
path: root/src/video_out/yuv2rgb_mmx.c
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/video_out/yuv2rgb_mmx.c
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/video_out/yuv2rgb_mmx.c')
-rw-r--r--src/video_out/yuv2rgb_mmx.c42
1 files changed, 32 insertions, 10 deletions
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