summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMiguel Freitas <miguelfreitas@users.sourceforge.net>2001-10-29 02:15:22 +0000
committerMiguel Freitas <miguelfreitas@users.sourceforge.net>2001-10-29 02:15:22 +0000
commit1ff753619b7732db28e76b4ae1e3c06ee00f0ef4 (patch)
treefccad01fcb74e44953f2a90e578298557fc796d2 /src
parent9091514f5cef881fca3ff256e6da28404fd91601 (diff)
downloadxine-lib-1ff753619b7732db28e76b4ae1e3c06ee00f0ef4.tar.gz
xine-lib-1ff753619b7732db28e76b4ae1e3c06ee00f0ef4.tar.bz2
XShm gamma adjusting (brightness)
CVS patchset: 906 CVS date: 2001/10/29 02:15:22
Diffstat (limited to 'src')
-rw-r--r--src/video_out/video_out_xshm.c21
-rw-r--r--src/video_out/yuv2rgb.c25
-rw-r--r--src/video_out/yuv2rgb.h11
-rw-r--r--src/video_out/yuv2rgb_mmx.c26
4 files changed, 73 insertions, 10 deletions
diff --git a/src/video_out/video_out_xshm.c b/src/video_out/video_out_xshm.c
index f6e02a773..115883a6c 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.48 2001/10/22 00:52:10 guenter Exp $
+ * $Id: video_out_xshm.c,v 1.49 2001/10/29 02:15:22 miguelfreitas Exp $
*
* video_out_xshm.c, X11 shared memory extension interface for xine
*
@@ -346,7 +346,7 @@ 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;
+ return VO_CAP_COPIES_IMAGE | VO_CAP_YV12 | VO_CAP_YUY2 | VO_CAP_BRIGHTNESS;
}
static void xshm_frame_copy (vo_frame_t *vo_img, uint8_t **src) {
@@ -843,6 +843,8 @@ static int xshm_get_property (vo_driver_t *this_gen, int property) {
if ( property == VO_PROP_ASPECT_RATIO) {
return this->user_ratio ;
+ } else if ( property == VO_PROP_BRIGHTNESS) {
+ return yuv2rgb_get_gamma(this->yuv2rgb);
} else {
printf ("video_out_xshm: tried to get unsupported property %d\n", property);
}
@@ -880,6 +882,10 @@ static int xshm_set_property (vo_driver_t *this_gen,
this->gui_changed |= GUI_ASPECT_CHANGED;
printf("video_out_xshm: aspect ratio changed to %s\n",
aspect_ratio_name(value));
+ } else if ( property == VO_PROP_BRIGHTNESS) {
+ yuv2rgb_set_gamma(this->yuv2rgb,value);
+ this->config->set_int (this->config, "xshm_gamma", value);
+ printf("video_out_xshm: gamma changed to %d\n",value);
} else {
printf ("video_out_xshm: tried to set unsupported property %d\n", property);
}
@@ -891,9 +897,13 @@ static void xshm_get_property_min_max (vo_driver_t *this_gen,
int property, int *min, int *max) {
/* xshm_driver_t *this = (xshm_driver_t *) this_gen; */
-
- *min = 0;
- *max = 0;
+ if ( property == VO_PROP_BRIGHTNESS) {
+ *min = -100;
+ *max = +100;
+ } else {
+ *min = 0;
+ *max = 0;
+ }
}
@@ -1330,6 +1340,7 @@ vo_driver_t *init_video_out_plugin (config_values_t *config, void *visual_gen) {
}
this->yuv2rgb = yuv2rgb_init (mode, swapped, this->fast_rgb);
+ yuv2rgb_set_gamma(this->yuv2rgb, config->lookup_int (config, "xshm_gamma", 0));
return &this->vo_driver;
}
diff --git a/src/video_out/yuv2rgb.c b/src/video_out/yuv2rgb.c
index b7b28adfb..ec1015b82 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.25 2001/10/21 00:18:22 miguelfreitas Exp $
+ * $Id: yuv2rgb.c,v 1.26 2001/10/29 02:15:22 miguelfreitas Exp $
*/
#include "config.h"
@@ -2251,7 +2251,7 @@ static void yuv2rgb_setup_tables (yuv2rgb_t *this, int mode, int swapped)
fprintf (stderr, "mode %d not supported by yuv2rgb\n", mode);
exit (1);
}
-
+
for (i = 0; i < 256; i++) {
this->table_rV[i] = (((uint8_t *) table_r) +
entry_size * div_round (crv * (i-128), 76309));
@@ -2261,6 +2261,8 @@ static void yuv2rgb_setup_tables (yuv2rgb_t *this, int mode, int swapped)
this->table_bU[i] = (((uint8_t *)table_b) +
entry_size * div_round (cbu * (i-128), 76309));
}
+ this->gamma = 0;
+ this->entry_size = entry_size;
}
static uint32_t yuv2rgb_single_pixel_32 (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v)
@@ -3015,3 +3017,22 @@ yuv2rgb_t *yuv2rgb_init (int mode, int swapped, uint8_t *colormap) {
return this;
}
+void yuv2rgb_set_gamma (yuv2rgb_t *this, int gamma)
+{
+ int i;
+
+ for (i = 0; i < 256; i++) {
+ (uint8_t *)this->table_rV[i] += this->entry_size*(gamma - this->gamma);
+ (uint8_t *)this->table_gU[i] += this->entry_size*(gamma - this->gamma);
+ (uint8_t *)this->table_bU[i] += this->entry_size*(gamma - this->gamma);
+ }
+#ifdef ARCH_X86
+ mmx_yuv2rgb_set_gamma(gamma);
+#endif
+ this->gamma = gamma;
+}
+
+int yuv2rgb_get_gamma (yuv2rgb_t *this)
+{
+ return this->gamma;
+}
diff --git a/src/video_out/yuv2rgb.h b/src/video_out/yuv2rgb.h
index 9502f100d..493481260 100644
--- a/src/video_out/yuv2rgb.h
+++ b/src/video_out/yuv2rgb.h
@@ -72,6 +72,9 @@ struct yuv2rgb_s {
uint8_t *fast_rgb;
scale_line_func_t scale_line;
+
+ int gamma;
+ int entry_size;
} ;
@@ -88,10 +91,18 @@ int yuv2rgb_setup (yuv2rgb_t *this,
int dest_width, int dest_height,
int rgb_stride);
+/* adjust gamma (-100 to 100 looks fine) */
+void yuv2rgb_set_gamma (yuv2rgb_t *this, int gamma);
+
+/* get gamma value */
+int yuv2rgb_get_gamma (yuv2rgb_t *this);
+
+
/*
* internal stuff below this line
*/
+void mmx_yuv2rgb_set_gamma(int gamma);
void yuv2rgb_init_mmxext (yuv2rgb_t *this, int mode, int swapped);
void yuv2rgb_init_mmx (yuv2rgb_t *this, int mode, int swapped);
void yuv2rgb_init_mlib (yuv2rgb_t *this, int mode, int swapped);
diff --git a/src/video_out/yuv2rgb_mmx.c b/src/video_out/yuv2rgb_mmx.c
index ea4cf9698..d085fc635 100644
--- a/src/video_out/yuv2rgb_mmx.c
+++ b/src/video_out/yuv2rgb_mmx.c
@@ -49,6 +49,27 @@ do { \
movq_r2m (src, dest); \
} while (0)
+static mmx_t mmx_subYw = {0x1010101010101010};
+static mmx_t mmx_addYw = {0x0000000000000000};
+
+void mmx_yuv2rgb_set_gamma(int gamma)
+{
+int a,s,i;
+
+ if( gamma <= 16 ) {
+ a = 0;
+ s = 16 - gamma;
+ } else {
+ a = gamma - 16;
+ s = 0;
+ }
+
+ for( i = 0; i < 8; i++ ) {
+ *((unsigned char *)&mmx_subYw + i) = s;
+ *((unsigned char *)&mmx_addYw + i) = a;
+ }
+}
+
static inline void mmx_yuv2rgb (uint8_t * py, uint8_t * pu, uint8_t * pv)
{
static mmx_t mmx_80w = {0x0080008000800080};
@@ -56,15 +77,14 @@ static inline void mmx_yuv2rgb (uint8_t * py, uint8_t * pu, uint8_t * pv)
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_10w = {0x1010101010101010};
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
- psubusb_m2r (mmx_10w, mm6); // Y -= 16
-
+ psubusb_m2r (mmx_subYw, mm6); // Y -= 16
+ paddusb_m2r (mmx_addYw, mm6);
movd_m2r (*pu, mm0); // mm0 = 00 00 00 00 u3 u2 u1 u0
movq_r2r (mm6, mm7); // mm7 = Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0