summaryrefslogtreecommitdiff
path: root/src/xine-engine/alphablend.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/xine-engine/alphablend.c')
-rw-r--r--src/xine-engine/alphablend.c302
1 files changed, 151 insertions, 151 deletions
diff --git a/src/xine-engine/alphablend.c b/src/xine-engine/alphablend.c
index 1dcd47eb7..4727740bd 100644
--- a/src/xine-engine/alphablend.c
+++ b/src/xine-engine/alphablend.c
@@ -1,7 +1,7 @@
/*
*
* Copyright (C) James Courtier-Dutton James@superbug.demon.co.uk - July 2001
- *
+ *
* Copyright (C) 2000 Thomas Mirlacher
* 2002-2004 the xine project
*
@@ -114,7 +114,7 @@ rle_img_advance_line(rle_elem_t *rle, rle_elem_t *rle_limit, int w)
/*
* heck, this function is overly complicated and currently buggy.
- * if James would like to revive it (implementing proper clipping -
+ * if James would like to revive it (implementing proper clipping -
* not to confuse with button highlight) i would have no objections,
* but for now i will be using an alternate version based on rgb24. [MF]
*
@@ -181,7 +181,7 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl,
printf("blend_rgb16: dy_step=%i, x_scale=%i\n", dy_step, x_scale);
#endif
if (img_width & 1) img_width++;
- img_offset = ( ( (y_off * img_height) / dst_height) * img_width)
+ img_offset = ( ( (y_off * img_height) / dst_height) * img_width)
+ ( (x_off * img_width) / dst_width);
#ifdef LOG_BLEND_RGB16
printf("blend_rgb16: x=%i, y=%i, w=%i, h=%i, img_offset=%lf\n", img_overl->x, img_overl->y,
@@ -190,7 +190,7 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl,
img_offset);
#endif
img_pix = (uint16_t *) img + (int)img_offset;
-/*
+/*
+ (y_off * img_height / dst_height) * img_width
+ (x_off * img_width / dst_width);
*/
@@ -200,26 +200,26 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl,
clip_right = src_width;
else
clip_right = dst_width - x_off;
-
+
if( x_off >= 0 )
clip_left = 0;
else
clip_left = -x_off;
-
+
if( y_off >= 0 )
clip_top = 0;
else
clip_top = -y_off;
-
+
if( (src_height + y_off) > dst_height )
src_height = dst_height - y_off;
-
+
/* make highlight area fit into clip area */
if( img_overl->hili_right <= clip_right )
hili_right = img_overl->hili_right;
else
hili_right = clip_right;
-
+
if( img_overl->hili_left >= clip_left )
hili_left = img_overl->hili_left;
else
@@ -233,7 +233,7 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl,
x = x1_scaled = x2_scaled = 0;
#ifdef LOG_BLEND_RGB16
- printf("blend_rgb16 started\n");
+ printf("blend_rgb16 started\n");
#endif
while (zone_state != 6) {
@@ -287,10 +287,10 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl,
mem_blend16(img_pix+x1_scaled, *((uint16_t *)&clut[clr]), o, x2_scaled-x1_scaled);
}
x += rle_this_bite;
- if (x >= src_width ) {
+ if (x >= src_width ) {
x -= src_width;
img_pix += img_width;
-
+
dy += dy_step;
if (dy >= INT_TO_SCALED(1)) {
dy -= INT_TO_SCALED(1);
@@ -304,7 +304,7 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl,
} else {
rle = rle_start; /* y-scaling, reuse the last rle encoded line */
}
- }
+ }
rle_remainder = rlelen = rle->len;
clr_next = rle->color;
rle++;
@@ -345,7 +345,7 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl,
mem_blend16(img_pix+x1_scaled, *((uint16_t *)&clut[clr]), o, x2_scaled-x1_scaled);
}
x += rle_this_bite;
- if (x >= src_width ) {
+ if (x >= src_width ) {
x -= src_width;
img_pix += img_width;
dy += dy_step;
@@ -390,7 +390,7 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl,
mem_blend16(img_pix+x1_scaled, *((uint16_t *)&clut[clr]), o, x2_scaled-x1_scaled);
}
x += rle_this_bite;
- if (x >= src_width ) {
+ if (x >= src_width ) {
x -= src_width;
img_pix += img_width;
dy += dy_step;
@@ -410,7 +410,7 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl,
zone_state = 5;
break;
}
- }
+ }
if (rle >= rle_limit) {
zone_state = 6;
}
@@ -435,7 +435,7 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl,
mem_blend16(img_pix+x1_scaled, *((uint16_t *)&clut[clr]), o, x2_scaled-x1_scaled);
}
x += rle_this_bite;
- if (x >= src_width ) {
+ if (x >= src_width ) {
x -= src_width;
img_pix += img_width;
dy += dy_step;
@@ -455,7 +455,7 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl,
zone_state = 5;
break;
}
- }
+ }
if (rle >= rle_limit) {
zone_state = 6;
}
@@ -473,7 +473,7 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl,
mem_blend16(img_pix+x1_scaled, *((uint16_t *)&clut[clr]), o, x2_scaled-x1_scaled);
}
x += rle_this_bite;
- if (x >= src_width ) {
+ if (x >= src_width ) {
x -= src_width;
img_pix += img_width;
dy += dy_step;
@@ -489,7 +489,7 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl,
} else {
rle = rle_start; /* y-scaling, reuse the last rle encoded line */
}
- }
+ }
rle_remainder = rlelen = rle->len;
clr_next = rle->color;
rle++;
@@ -513,7 +513,7 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl,
mem_blend16(img_pix+x1_scaled, *((uint16_t *)&clut[clr]), o, x2_scaled-x1_scaled);
}
x += rle_this_bite;
- if (x >= src_width ) {
+ if (x >= src_width ) {
x -= src_width;
img_pix += img_width;
dy += dy_step;
@@ -529,7 +529,7 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl,
} else {
rle = rle_start; /* y-scaling, reuse the last rle encoded line */
}
- }
+ }
rle_remainder = rlelen = rle->len;
clr_next = rle->color;
rle++;
@@ -544,7 +544,7 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl,
#ifdef LOG_BLEND_RGB16
printf("blend_rgb16 ended\n");
#endif
-
+
}
#endif
@@ -576,26 +576,26 @@ void _x_blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl,
clip_right = src_width;
else
clip_right = dst_width - x_off;
-
+
if( x_off >= 0 )
clip_left = 0;
else
clip_left = -x_off;
-
+
if( y_off >= 0 )
clip_top = 0;
else
clip_top = -y_off;
-
+
if( (src_height + y_off) > dst_height )
src_height = dst_height - y_off;
-
+
/* make highlight area fit into clip area */
if( img_overl->hili_right <= clip_right )
hili_right = img_overl->hili_right;
else
hili_right = clip_right;
-
+
if( img_overl->hili_left >= clip_left )
hili_left = img_overl->hili_left;
else
@@ -619,7 +619,7 @@ void _x_blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl,
if (rlelen <= 0) {
if (rle >= rle_limit)
break;
-
+
rlelen = rle->len;
clr = rle->color;
rle++;
@@ -627,7 +627,7 @@ void _x_blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl,
if (!mask) {
/* above or below highlight area */
-
+
rle_bite = rlelen;
/* choose palette for surrounding area */
colors = (clut_t*)img_overl->color;
@@ -646,7 +646,7 @@ void _x_blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl,
trans = img_overl->trans;
} else {
/* ends left */
-
+
rle_bite = rlelen;
/* choose palette for surrounding area */
colors = (clut_t*)img_overl->color;
@@ -666,25 +666,25 @@ void _x_blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl,
trans = img_overl->hili_trans;
} else {
/* starts right */
-
+
rle_bite = rlelen;
/* choose palette for surrounding area */
colors = (clut_t*)img_overl->color;
trans = img_overl->trans;
-
+
if( x + rle_bite >= clip_right )
clipped = 1;
}
} else {
/* starts not left and ends not right */
-
+
rle_bite = rlelen;
/* we're in the center area so choose highlight palette */
colors = (clut_t*)img_overl->hili_color;
trans = img_overl->hili_trans;
}
}
-
+
x2_scaled = SCALED_TO_INT((x + rle_bite) * x_scale);
o = trans[clr];
@@ -743,26 +743,26 @@ void _x_blend_rgb24 (uint8_t * img, vo_overlay_t * img_overl,
clip_right = src_width;
else
clip_right = dst_width - x_off;
-
+
if( x_off >= 0 )
clip_left = 0;
else
clip_left = -x_off;
-
+
if( y_off >= 0 )
clip_top = 0;
else
clip_top = -y_off;
-
+
if( (src_height + y_off) > dst_height )
src_height = dst_height - y_off;
-
+
/* make highlight area fit into clip area */
if( img_overl->hili_right <= clip_right )
hili_right = img_overl->hili_right;
else
hili_right = clip_right;
-
+
if( img_overl->hili_left >= clip_left )
hili_left = img_overl->hili_left;
else
@@ -786,7 +786,7 @@ void _x_blend_rgb24 (uint8_t * img, vo_overlay_t * img_overl,
if (rlelen <= 0) {
if (rle >= rle_limit)
break;
-
+
rlelen = rle->len;
clr = rle->color;
rle++;
@@ -794,7 +794,7 @@ void _x_blend_rgb24 (uint8_t * img, vo_overlay_t * img_overl,
if (!mask) {
/* above or below highlight area */
-
+
rle_bite = rlelen;
/* choose palette for surrounding area */
colors = (clut_t*)img_overl->color;
@@ -813,7 +813,7 @@ void _x_blend_rgb24 (uint8_t * img, vo_overlay_t * img_overl,
trans = img_overl->trans;
} else {
/* ends left */
-
+
rle_bite = rlelen;
/* choose palette for surrounding area */
colors = (clut_t*)img_overl->color;
@@ -833,25 +833,25 @@ void _x_blend_rgb24 (uint8_t * img, vo_overlay_t * img_overl,
trans = img_overl->hili_trans;
} else {
/* starts right */
-
+
rle_bite = rlelen;
/* choose palette for surrounding area */
colors = (clut_t*)img_overl->color;
trans = img_overl->trans;
-
+
if( x + rle_bite >= clip_right )
clipped = 1;
}
} else {
/* starts not left and ends not right */
-
+
rle_bite = rlelen;
/* we're in the center area so choose highlight palette */
colors = (clut_t*)img_overl->hili_color;
trans = img_overl->hili_trans;
}
}
-
+
x2_scaled = SCALED_TO_INT((x + rle_bite) * x_scale);
o = trans[clr];
@@ -910,50 +910,50 @@ void _x_blend_rgb32 (uint8_t * img, vo_overlay_t * img_overl,
clip_right = src_width;
else
clip_right = dst_width - x_off;
-
+
if( x_off >= 0 )
clip_left = 0;
else
clip_left = -x_off;
-
+
if( y_off >= 0 )
clip_top = 0;
else
clip_top = -y_off;
-
+
if( (src_height + y_off) > dst_height )
src_height = dst_height - y_off;
-
+
/* make highlight area fit into clip area */
if( img_overl->hili_right <= clip_right )
hili_right = img_overl->hili_right;
else
hili_right = clip_right;
-
+
if( img_overl->hili_left >= clip_left )
hili_left = img_overl->hili_left;
else
hili_left = clip_left;
-
+
for (y = dy = 0; y < src_height && rle < rle_limit; ) {
int mask = !(y < img_overl->hili_top || y >= img_overl->hili_bottom);
rle_elem_t *rle_start = rle;
int rlelen = 0;
uint8_t clr = 0;
-
+
for (x = x1_scaled = 0; x < src_width;) {
int rle_bite;
clut_t *colors;
uint8_t *trans;
uint16_t o;
int clipped = (y < clip_top);
-
+
/* take next element from rle list everytime an element is finished */
if (rlelen <= 0) {
if (rle >= rle_limit)
break;
-
+
rlelen = rle->len;
clr = rle->color;
rle++;
@@ -961,7 +961,7 @@ void _x_blend_rgb32 (uint8_t * img, vo_overlay_t * img_overl,
if (!mask) {
/* above or below highlight area */
-
+
rle_bite = rlelen;
/* choose palette for surrounding area */
colors = (clut_t*)img_overl->color;
@@ -980,7 +980,7 @@ void _x_blend_rgb32 (uint8_t * img, vo_overlay_t * img_overl,
trans = img_overl->trans;
} else {
/* ends left */
-
+
rle_bite = rlelen;
/* choose palette for surrounding area */
colors = (clut_t*)img_overl->color;
@@ -1000,25 +1000,25 @@ void _x_blend_rgb32 (uint8_t * img, vo_overlay_t * img_overl,
trans = img_overl->hili_trans;
} else {
/* starts right */
-
+
rle_bite = rlelen;
/* choose palette for surrounding area */
colors = (clut_t*)img_overl->color;
trans = img_overl->trans;
-
+
if( x + rle_bite >= clip_right )
clipped = 1;
}
} else {
/* starts not left and ends not right */
-
+
rle_bite = rlelen;
/* we're in the center area so choose highlight palette */
colors = (clut_t*)img_overl->hili_color;
trans = img_overl->hili_trans;
}
}
-
+
x2_scaled = SCALED_TO_INT((x + rle_bite) * x_scale);
o = trans[clr];
@@ -1056,11 +1056,11 @@ static void mem_blend8(uint8_t *mem, uint8_t val, uint8_t o, size_t sz)
}
}
-static void blend_yuv_exact(uint8_t *dst_cr, uint8_t *dst_cb, int src_width,
+static void blend_yuv_exact(uint8_t *dst_cr, uint8_t *dst_cb, int src_width,
uint8_t *(*blend_yuv_data)[ 3 ][ 2 ])
{
int x;
-
+
for (x = 0; x < src_width; x += 2) {
/* get opacity of the 4 pixels that share chroma */
int o00 = (*blend_yuv_data)[ 0 ][ 0 ][ x + 0 ];
@@ -1078,7 +1078,7 @@ static void blend_yuv_exact(uint8_t *dst_cr, uint8_t *dst_cb, int src_width,
int cr01 = (*blend_yuv_data)[ 1 ][ 0 ][ x + 1 ];
int cr10 = (*blend_yuv_data)[ 1 ][ 1 ][ x + 0 ];
int cr11 = (*blend_yuv_data)[ 1 ][ 1 ][ x + 1 ];
-
+
int cb00 = (*blend_yuv_data)[ 2 ][ 0 ][ x + 0 ];
int cb01 = (*blend_yuv_data)[ 2 ][ 0 ][ x + 1 ];
int cb10 = (*blend_yuv_data)[ 2 ][ 1 ][ x + 0 ];
@@ -1113,11 +1113,11 @@ static uint8_t *(*blend_yuv_grow_extra_data(alphablend_t *extra_data, int osd_wi
int max_width;
uint8_t *data[ 3 ][ 2 ];
} *header = (struct header_s *)extra_data->buffer;
-
+
size_t needed_buffer_size = sizeof (*header) + osd_width * sizeof (uint8_t[ 3 ][ 2 ]);
-
+
if (extra_data->buffer_size < needed_buffer_size) {
-
+
free(extra_data->buffer);
header = calloc(1, needed_buffer_size);
if (!header) {
@@ -1143,7 +1143,7 @@ static uint8_t *(*blend_yuv_grow_extra_data(alphablend_t *extra_data, int osd_wi
return &(header->data);
}
-
+
void _x_blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl,
int dst_width, int dst_height, int dst_pitches[3],
alphablend_t *extra_data)
@@ -1168,12 +1168,12 @@ void _x_blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl,
int hili_right, hili_left;
int clip_right, clip_left, clip_top;
uint8_t clr=0;
-
+
int any_line_buffered = 0;
int exact_blend_width = ((src_width <= (dst_width - x_off)) ? src_width : (dst_width - x_off));
int exact_blend_width_m2 = (x_odd + exact_blend_width + 1) & ~1; /* make it a (larger) multiple of 2 */
uint8_t *(*blend_yuv_data)[ 3 ][ 2 ] = 0;
-
+
uint8_t *dst_y = dst_base[0] + dst_pitches[0] * y_off + x_off;
uint8_t *dst_cr = dst_base[2] + (y_off / 2) * dst_pitches[1] + (x_off / 2);
uint8_t *dst_cb = dst_base[1] + (y_off / 2) * dst_pitches[2] + (x_off / 2);
@@ -1188,26 +1188,26 @@ void _x_blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl,
clip_right = src_width;
else
clip_right = dst_width - x_off;
-
+
if( x_off >= 0 )
clip_left = 0;
else
clip_left = -x_off;
-
+
if( y_off >= 0 )
clip_top = 0;
else
clip_top = -y_off;
-
+
if( (src_height + y_off) > dst_height )
src_height = dst_height - y_off;
-
+
/* make highlight area fit into clip area */
if( img_overl->hili_right <= clip_right )
hili_right = img_overl->hili_right;
else
hili_right = clip_right;
-
+
if( img_overl->hili_left >= clip_left )
hili_left = img_overl->hili_left;
else
@@ -1219,16 +1219,16 @@ void _x_blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl,
if (enable_exact_blending) {
if (exact_blend_width <= 0)
return;
-
+
blend_yuv_data = blend_yuv_grow_extra_data(extra_data, exact_blend_width_m2);
if (!blend_yuv_data)
return;
-
+
/* make linebuffer transparent */
memset(&(*blend_yuv_data)[ 0 ][ 0 ][ 0 ], 0, exact_blend_width_m2);
memset(&(*blend_yuv_data)[ 0 ][ 1 ][ 0 ], 0, exact_blend_width_m2);
}
-
+
rlelen=rle_remainder=0;
for (y = 0; y < src_height; y++) {
if (rle >= rle_limit) {
@@ -1237,7 +1237,7 @@ void _x_blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl,
#endif
break;
}
-
+
ymask = ((y < img_overl->hili_top) || (y >= img_overl->hili_bottom));
xmask = 0;
#ifdef LOG_BLEND_YUV
@@ -1247,14 +1247,14 @@ void _x_blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl,
for (x = 0; x < src_width;) {
uint16_t o;
int clipped = (y < clip_top);
-
+
if (rle >= rle_limit) {
#ifdef LOG_BLEND_YUV
printf("x-rle_limit\n");
#endif
break;
}
-
+
#ifdef LOG_BLEND_YUV
printf("1:rle_len=%d, remainder=%d, x=%d\n",rlelen, rle_remainder, x);
#endif
@@ -1263,7 +1263,7 @@ void _x_blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl,
#ifdef LOG_BLEND_YUV
printf("alphablend: major bug in blend_yuv < 0\n");
#endif
- }
+ }
if (rlelen == 0) {
rle_remainder = rlelen = rle->len;
clr = rle->color;
@@ -1281,11 +1281,11 @@ void _x_blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl,
#endif
if (ymask == 0) {
- if (x < hili_left) {
+ if (x < hili_left) {
/* Starts outside highlight area */
if ((x + rle_remainder) > hili_left ) {
#ifdef LOG_BLEND_YUV
- printf("Outside highlight left %d, ending inside\n", hili_left);
+ printf("Outside highlight left %d, ending inside\n", hili_left);
#endif
/* Cutting needed, starts outside, ends inside */
rle_this_bite = (hili_left - x);
@@ -1296,7 +1296,7 @@ void _x_blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl,
xmask = 0;
} else {
#ifdef LOG_BLEND_YUV
- printf("Outside highlight left %d, ending outside\n", hili_left);
+ printf("Outside highlight left %d, ending outside\n", hili_left);
#endif
/* no cutting needed, starts outside, ends outside */
rle_this_bite = rle_remainder;
@@ -1335,7 +1335,7 @@ void _x_blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl,
}
} else if (x >= hili_right) {
/* Starts outside highlight area, ends outside highlight area */
- if ((x + rle_remainder ) > src_width ) {
+ if ((x + rle_remainder ) > src_width ) {
#ifdef LOG_BLEND_YUV
printf("Outside highlight right %d, ending eol\n", hili_right);
#endif
@@ -1381,7 +1381,7 @@ void _x_blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl,
/* clip against right edge of destination area */
if ((x + rle_this_bite) > (dst_width - x_off)) {
int toClip = (x + rle_this_bite) - (dst_width - x_off);
-
+
rle_this_bite -= toClip;
rle_remainder += toClip;
rlelen += toClip;
@@ -1392,7 +1392,7 @@ void _x_blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl,
memset(&(*blend_yuv_data)[ 0 ][ (y + y_odd) & 1 ][ x + x_odd ], o, rle_this_bite);
any_line_buffered |= ((y + y_odd) & 1) ? 2 : 1;
}
-
+
if (o && !clipped) {
if(o >= 15) {
memset(dst_y + x, my_clut[clr].y, rle_this_bite);
@@ -1434,17 +1434,17 @@ void _x_blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl,
/* make second line transparent */
memset(&(*blend_yuv_data)[ 0 ][ 1 ][ 0 ], 0, exact_blend_width_m2);
}
-
+
blend_yuv_exact(dst_cr, dst_cb, exact_blend_width, blend_yuv_data);
-
+
any_line_buffered = 0;
}
}
-
+
dst_cr += dst_pitches[2];
dst_cb += dst_pitches[1];
}
-
+
dst_y += dst_pitches[0];
}
@@ -1455,21 +1455,21 @@ void _x_blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl,
/* make second line transparent */
memset(&(*blend_yuv_data)[ 0 ][ 1 ][ 0 ], 0, exact_blend_width_m2);
}
-
+
blend_yuv_exact(dst_cr, dst_cb, exact_blend_width, blend_yuv_data);
}
}
-
+
#ifdef LOG_BLEND_YUV
printf("overlay_blend ended\n");
#endif
}
-
+
static void blend_yuy2_exact(uint8_t *dst_cr, uint8_t *dst_cb, int src_width,
uint8_t *(*blend_yuy2_data)[ 3 ])
{
int x;
-
+
for (x = 0; x < src_width; x += 2) {
/* get opacity of the 2 pixels that share chroma */
int o0 = (*blend_yuy2_data)[ 0 ][ x + 0 ];
@@ -1481,7 +1481,7 @@ static void blend_yuy2_exact(uint8_t *dst_cr, uint8_t *dst_cb, int src_width,
/* get the chroma components of the 2 pixels */
int cr0 = (*blend_yuy2_data)[ 1 ][ x + 0 ];
int cr1 = (*blend_yuy2_data)[ 1 ][ x + 1 ];
-
+
int cb0 = (*blend_yuy2_data)[ 2 ][ x + 0 ];
int cb1 = (*blend_yuy2_data)[ 2 ][ x + 1 ];
@@ -1496,7 +1496,7 @@ static void blend_yuy2_exact(uint8_t *dst_cr, uint8_t *dst_cb, int src_width,
/*
* No need to adjust chroma values with +/- 128:
- * *dst_cb
+ * *dst_cb
* = 128 + ((*dst_cb-128) * t2 + (cb0-128) * o0 + (cb1-128) * o1) / (2 * 0xf);
* = 128 + (*dst_cb * t2 + cb0 * o0 + cb1 * o1 + (t2*(-128) - 128*o0 - 128*o1)) / (2 * 0xf);
* = 128 + (*dst_cb * t2 + cb0 * o0 + cb1 * o1 + ((2*0xf-o0-o1)*(-128) - 128*o0 - 128*o1)) / (2 * 0xf);
@@ -1512,8 +1512,8 @@ static void blend_yuy2_exact(uint8_t *dst_cr, uint8_t *dst_cb, int src_width,
* =(almost) X * 0x1112/0x10000
* = (X * 0x1112) >> 16
*
- * The tricky point is 0x1111/0xffff --> 0x1112/0x10000.
- * All calculations are done using integers and X is in
+ * The tricky point is 0x1111/0xffff --> 0x1112/0x10000.
+ * All calculations are done using integers and X is in
* range of [0 ... 0xff*0xf*4]. This results in error of
* X*0x1112/0x10000 - X/0xf
* = X*(0x1112/0x10000 - 1/0xf)
@@ -1523,7 +1523,7 @@ static void blend_yuy2_exact(uint8_t *dst_cr, uint8_t *dst_cb, int src_width,
* As the error is less than 1 and always positive, whole error
* "disappears" during truncation (>>16). Rounding to exact results is
* guaranteed by selecting 0x1112 instead of more accurate 0x1111
- * (with 0x1111 error=X*(-0.00001111...)). With 0x1112 error is
+ * (with 0x1111 error=X*(-0.00001111...)). With 0x1112 error is
* always positive, but still less than one.
* So, one can forget the "=(almost)" as it is really "=" when source
* operands are within 0...0xff (U,V) and 0...0xf (A).
@@ -1531,7 +1531,7 @@ static void blend_yuy2_exact(uint8_t *dst_cr, uint8_t *dst_cb, int src_width,
* 1/0x10000 (= >>16) was originally selected because of MMX pmullhw
* instruction; it makes possible to do whole calculation in MMX using
* uint16's (pmullhw is (X*Y)>>16).
- *
+ *
* Here X/(2*0xf) = X/0xf/2 = ((X*0x1112)>>16)>>1 = (X*0x1112)>>17
*/
@@ -1555,11 +1555,11 @@ static uint8_t *(*blend_yuy2_grow_extra_data(alphablend_t *extra_data, int osd_w
int max_width;
uint8_t *data[ 3 ];
} *header = (struct header_s *)extra_data->buffer;
-
+
size_t needed_buffer_size = sizeof (*header) + osd_width * sizeof (uint8_t[ 3 ]);
-
+
if (extra_data->buffer_size < needed_buffer_size) {
-
+
free(extra_data->buffer);
header = calloc(1, needed_buffer_size);
if (!header) {
@@ -1619,7 +1619,7 @@ void _x_blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl,
int exact_blend_width = ((src_width <= (dst_width - x_off)) ? src_width : (dst_width - x_off));
int exact_blend_width_m2 = (x_odd + exact_blend_width + 1) & ~1; /* make it a (larger) multiple of 2 */
uint8_t *(*blend_yuy2_data)[ 3 ] = 0;
-
+
uint8_t *dst_y = dst_img + dst_pitch * y_off + 2 * x_off;
uint8_t *dst;
@@ -1631,26 +1631,26 @@ void _x_blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl,
clip_right = src_width;
else
clip_right = dst_width - x_off;
-
+
if( x_off >= 0 )
clip_left = 0;
else
clip_left = -x_off;
-
+
if( y_off >= 0 )
clip_top = 0;
else
clip_top = -y_off;
-
+
if( (src_height + y_off) > dst_height )
src_height = dst_height - y_off;
-
+
/* make highlight area fit into clip area */
if( img_overl->hili_right <= clip_right )
hili_right = img_overl->hili_right;
else
hili_right = clip_right;
-
+
if( img_overl->hili_left >= clip_left )
hili_left = img_overl->hili_left;
else
@@ -1662,11 +1662,11 @@ void _x_blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl,
if (enable_exact_blending) {
if (exact_blend_width <= 0)
return;
-
+
blend_yuy2_data = blend_yuy2_grow_extra_data(extra_data, exact_blend_width_m2);
if (!blend_yuy2_data)
return;
-
+
/* make linebuffer transparent */
memset(&(*blend_yuy2_data)[ 0 ][ 0 ], 0, exact_blend_width_m2);
}
@@ -1675,7 +1675,7 @@ void _x_blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl,
for (y = 0; y < src_height; y++) {
if (rle >= rle_limit)
break;
-
+
ymask = ((y < img_overl->hili_top) || (y >= img_overl->hili_bottom));
dst = dst_y;
@@ -1685,12 +1685,12 @@ void _x_blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl,
if (rle >= rle_limit)
break;
-
+
if ((rlelen < 0) || (rle_remainder < 0)) {
#ifdef LOG_BLEND_YUV
printf("alphablend: major bug in blend_yuv < 0\n");
#endif
- }
+ }
if (rlelen == 0) {
rle_remainder = rlelen = rle->len;
clr = rle->color;
@@ -1708,11 +1708,11 @@ void _x_blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl,
#endif
if (ymask == 0) {
- if (x < hili_left) {
+ if (x < hili_left) {
/* Starts outside highlight area */
if ((x + rle_remainder) > hili_left ) {
#ifdef LOG_BLEND_YUV
- printf("Outside highlight left %d, ending inside\n", hili_left);
+ printf("Outside highlight left %d, ending inside\n", hili_left);
#endif
/* Cutting needed, starts outside, ends inside */
rle_this_bite = (hili_left - x);
@@ -1722,7 +1722,7 @@ void _x_blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl,
my_trans = img_overl->trans;
} else {
#ifdef LOG_BLEND_YUV
- printf("Outside highlight left %d, ending outside\n", hili_left);
+ printf("Outside highlight left %d, ending outside\n", hili_left);
#endif
/* no cutting needed, starts outside, ends outside */
rle_this_bite = rle_remainder;
@@ -1758,7 +1758,7 @@ void _x_blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl,
}
} else if (x >= hili_right) {
/* Starts outside highlight area, ends outsite highlight area */
- if ((x + rle_remainder ) > src_width ) {
+ if ((x + rle_remainder ) > src_width ) {
#ifdef LOG_BLEND_YUV
printf("Outside highlight right %d, ending eol\n", hili_right);
#endif
@@ -1798,7 +1798,7 @@ void _x_blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl,
/* clip against right edge of destination area */
if ((x + rle_this_bite) > (dst_width - x_off)) {
int toClip = (x + rle_this_bite) - (dst_width - x_off);
-
+
rle_this_bite -= toClip;
rle_remainder += toClip;
rlelen += toClip;
@@ -1850,7 +1850,7 @@ void _x_blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl,
mem_blend32(dst, &yuy2.b[0], o, l);
dst += 4*l;
}
-
+
if(rle_this_bite & 1) {
*dst = BLEND_BYTE(*dst, yuy2.b[0], o);
dst++;
@@ -1875,15 +1875,15 @@ void _x_blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl,
dst += rle_this_bite*2;
}
}
-
+
x += rle_this_bite;
}
-
+
if (enable_exact_blending) {
/* blend buffered line */
if (any_line_buffered) {
blend_yuy2_exact(dst_y - x_odd * 2 + 3, dst_y - x_odd * 2 + 1, exact_blend_width, blend_yuy2_data);
-
+
any_line_buffered = 0;
}
}
@@ -1892,7 +1892,7 @@ void _x_blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl,
}
}
-void _x_clear_xx44_palette(xx44_palette_t *p)
+void _x_clear_xx44_palette(xx44_palette_t *p)
{
register int i;
register uint32_t *cluts = p->cluts;
@@ -1904,20 +1904,20 @@ void _x_clear_xx44_palette(xx44_palette_t *p)
i = 2*OVL_PALETTE_SIZE;
while(i--)
*ids++ = -1;
- p->max_used=1;
+ p->max_used=1;
}
-void _x_init_xx44_palette(xx44_palette_t *p, unsigned num_entries)
+void _x_init_xx44_palette(xx44_palette_t *p, unsigned num_entries)
{
- p->size = (num_entries > XX44_PALETTE_SIZE) ? XX44_PALETTE_SIZE : num_entries;
+ p->size = (num_entries > XX44_PALETTE_SIZE) ? XX44_PALETTE_SIZE : num_entries;
}
-void _x_dispose_xx44_palette(xx44_palette_t *p)
+void _x_dispose_xx44_palette(xx44_palette_t *p)
{
}
static void colorToPalette(const uint32_t *icolor, unsigned char *palette_p,
- unsigned num_xvmc_components, char *xvmc_components)
+ unsigned num_xvmc_components, char *xvmc_components)
{
const clut_t *color = (const clut_t *) icolor;
unsigned int i;
@@ -1925,7 +1925,7 @@ static void colorToPalette(const uint32_t *icolor, unsigned char *palette_p,
switch(xvmc_components[i]) {
case 'V': *palette_p = color->cr; break;
case 'U': *palette_p = color->cb; break;
- case 'Y':
+ case 'Y':
default: *palette_p = color->y; break;
}
palette_p++;
@@ -1935,7 +1935,7 @@ static void colorToPalette(const uint32_t *icolor, unsigned char *palette_p,
void _x_xx44_to_xvmc_palette(const xx44_palette_t *p,unsigned char *xvmc_palette,
unsigned first_xx44_entry, unsigned num_xx44_entries,
- unsigned num_xvmc_components, char *xvmc_components)
+ unsigned num_xvmc_components, char *xvmc_components)
{
register unsigned int i;
register const uint32_t *cluts = p->cluts + first_xx44_entry;
@@ -1946,16 +1946,16 @@ void _x_xx44_to_xvmc_palette(const xx44_palette_t *p,unsigned char *xvmc_palette
xvmc_palette += num_xvmc_components;
}
}
-}
+}
-static int xx44_paletteIndex(xx44_palette_t *p, int color, uint32_t clut)
+static int xx44_paletteIndex(xx44_palette_t *p, int color, uint32_t clut)
{
register unsigned int i;
register uint32_t *cluts = p->cluts;
register int tmp;
- if ((tmp = p->lookup_cache[color]) >= 0)
+ if ((tmp = p->lookup_cache[color]) >= 0)
if (cluts[tmp] == clut) return tmp;
for (i=0; i<p->max_used; ++i) {
@@ -1972,7 +1972,7 @@ static int xx44_paletteIndex(xx44_palette_t *p, int color, uint32_t clut)
static void memblend_xx44(uint8_t *mem,uint8_t val, register size_t size, uint8_t mask)
{
- register uint8_t
+ register uint8_t
masked_val;
if (0 == (masked_val = val & mask)) return;
@@ -1984,16 +1984,16 @@ static void memblend_xx44(uint8_t *mem,uint8_t val, register size_t size, uint8_
}
void _x_blend_xx44 (uint8_t *dst_img, vo_overlay_t *img_overl,
- int dst_width, int dst_height, int dst_pitch,
+ int dst_width, int dst_height, int dst_pitch,
alphablend_t *extra_data,
- xx44_palette_t *palette,int ia44)
+ xx44_palette_t *palette,int ia44)
{
int src_width, src_height;
rle_elem_t *rle, *rle_limit;
int mask;
int x_off, y_off;
int x, y;
- uint8_t norm_pixel,hili_pixel;
+ uint8_t norm_pixel,hili_pixel;
uint8_t *dst_y;
uint8_t *dst;
uint8_t alphamask = (ia44) ? 0x0F : 0xF0;
@@ -2017,26 +2017,26 @@ void _x_blend_xx44 (uint8_t *dst_img, vo_overlay_t *img_overl,
clip_right = src_width;
else
clip_right = dst_width - x_off;
-
+
if( x_off >= 0 )
clip_left = 0;
else
clip_left = -x_off;
-
+
if( y_off >= 0 )
clip_top = 0;
else
clip_top = -y_off;
-
+
if( (src_height + y_off) > dst_height )
src_height = dst_height - y_off;
-
+
/* make highlight area fit into clip area */
if( img_overl->hili_right <= clip_right )
hili_right = img_overl->hili_right;
else
hili_right = clip_right;
-
+
if( img_overl->hili_left >= clip_left )
hili_left = img_overl->hili_left;
else
@@ -2053,10 +2053,10 @@ void _x_blend_xx44 (uint8_t *dst_img, vo_overlay_t *img_overl,
if (len > 0) {
norm_pixel = (uint8_t)((xx44_paletteIndex(palette,rle->color,
- img_overl->color[rle->color]) << 4) |
+ img_overl->color[rle->color]) << 4) |
(img_overl->trans[rle->color] & 0x0F));
hili_pixel = (uint8_t)((xx44_paletteIndex(palette,rle->color+OVL_PALETTE_SIZE,
- img_overl->hili_color[rle->color]) << 4) |
+ img_overl->hili_color[rle->color]) << 4) |
(img_overl->hili_trans[rle->color] & 0x0F));
if (!ia44) {
norm_pixel = ((norm_pixel & 0x0F) << 4) | ((norm_pixel & 0xF0) >> 4);
@@ -2091,7 +2091,7 @@ void _x_blend_xx44 (uint8_t *dst_img, vo_overlay_t *img_overl,
dst += len;
}
}
- } else if (x < hili_right) {
+ } else if (x < hili_right) {
if (len <= hili_right - x) {
if(!clipped)
memblend_xx44(dst,hili_pixel,len, alphamask);
@@ -2123,7 +2123,7 @@ void _x_blend_xx44 (uint8_t *dst_img, vo_overlay_t *img_overl,
x += rle->len;
rle++;
if (rle >= rle_limit) break;
- }
+ }
if (rle >= rle_limit) break;
dst_y += dst_pitch;
}
@@ -2139,7 +2139,7 @@ static void alphablend_disable_exact_osd_alpha_blending_changed(void *user_data,
void _x_alphablend_init(alphablend_t *extra_data, xine_t *xine)
{
config_values_t *config = xine->config;
-
+
extra_data->buffer = 0;
extra_data->buffer_size = 0;
extra_data->offset_x = 0;