summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiguel Freitas <miguelfreitas@users.sourceforge.net>2001-11-30 12:31:58 +0000
committerMiguel Freitas <miguelfreitas@users.sourceforge.net>2001-11-30 12:31:58 +0000
commit007547a49a8e47984bfaf782031e3554bdba831c (patch)
treef94aaa6d4978664648e5148fec745bfbe6a29321
parent734cc322c4ad155c4be0b9cc19034318dfc7731f (diff)
downloadxine-lib-007547a49a8e47984bfaf782031e3554bdba831c.tar.gz
xine-lib-007547a49a8e47984bfaf782031e3554bdba831c.tar.bz2
blend_yuy2 now available
CVS patchset: 1141 CVS date: 2001/11/30 12:31:58
-rw-r--r--src/video_out/alphablend.c106
-rw-r--r--src/video_out/alphablend.h3
-rw-r--r--src/video_out/video_out_xv.c12
3 files changed, 112 insertions, 9 deletions
diff --git a/src/video_out/alphablend.c b/src/video_out/alphablend.c
index 56d1624d4..430b2de83 100644
--- a/src/video_out/alphablend.c
+++ b/src/video_out/alphablend.c
@@ -64,7 +64,7 @@ static void mem_blend24(uint8_t *mem, uint8_t r, uint8_t g, uint8_t b,
}
}
-static void mem_blend32(uint8_t *mem, uint8_t r, uint8_t g, uint8_t b,
+static void mem_blend24_32(uint8_t *mem, uint8_t r, uint8_t g, uint8_t b,
uint8_t o, int len) {
uint8_t *limit = mem + len*4;
while (mem < limit) {
@@ -77,6 +77,20 @@ static void mem_blend32(uint8_t *mem, uint8_t r, uint8_t g, uint8_t b,
}
}
+static void mem_blend32(uint8_t *mem, uint8_t *src, uint8_t o, int len) {
+ uint8_t *limit = mem + len*4;
+ while (mem < limit) {
+ *mem = BLEND_BYTE(*mem, src[0], o);
+ mem++;
+ *mem = BLEND_BYTE(*mem, src[1], o);
+ mem++;
+ *mem = BLEND_BYTE(*mem, src[2], o);
+ mem++;
+ *mem = BLEND_BYTE(*mem, src[3], o);
+ mem++;
+ }
+}
+
/*
* Some macros for fixed point arithmetic.
@@ -278,7 +292,7 @@ void blend_rgb32 (uint8_t * img, vo_overlay_t * img_overl,
x2_scaled = SCALED_TO_INT((x + rle->len) * x_scale);
if (o && mask) {
- mem_blend32(img_pix + x1_scaled*4, clut[clr].cb,
+ mem_blend24_32(img_pix + x1_scaled*4, clut[clr].cb,
clut[clr].cr, clut[clr].y,
o, x2_scaled-x1_scaled);
}
@@ -384,6 +398,10 @@ void blend_yuv (uint8_t * dst_img, vo_overlay_t * img_overl,
}
}
+
+/* why this function is needed?? only syncfb uses it and it is
+ almost the same as blend_yuv!
+*/
void blend_yuv_vo_frame(vo_frame_t* dst_img, vo_overlay_t* img_overl)
{
clut_t *my_clut;
@@ -451,3 +469,87 @@ void blend_yuv_vo_frame(vo_frame_t* dst_img, vo_overlay_t* img_overl)
}
}
}
+
+
+void blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl,
+ int dst_width, int dst_height)
+{
+ clut_t *my_clut;
+ uint8_t *my_trans;
+
+ int src_width = img_overl->width;
+ int src_height = img_overl->height;
+ rle_elem_t *rle = img_overl->rle;
+ rle_elem_t *rle_limit = rle + img_overl->num_rle;
+ int x_off = img_overl->x;
+ int y_off = img_overl->y;
+ int mask;
+ int x, y;
+ int l;
+ uint32_t yuy2;
+
+ uint8_t *dst_y = dst_img + 2 * (dst_width * y_off + x_off);
+ uint8_t *dst;
+
+ my_clut = (clut_t*) img_overl->color;
+ my_trans = img_overl->trans;
+
+ for (y = 0; y < src_height; y++) {
+ mask = !(img_overl->clip_top > y || img_overl->clip_bottom < y);
+
+ dst = dst_y;
+ for (x = 0; x < src_width;) {
+ uint8_t clr;
+ uint16_t o;
+
+ clr = rle->color;
+ o = my_trans[clr];
+
+ /* These three lines assume that menu buttons are "clean" separated
+ * and do not overlap with the button clip borders */
+ if (o) if (img_overl->clip_left > x ||
+ img_overl->clip_right < x)
+ o = 0;
+
+ if (o && mask) {
+ l = rle->len>>1;
+ if( !(x & 1) ) {
+ yuy2 = my_clut[clr].y + (my_clut[clr].cb << 8) +
+ (my_clut[clr].y << 16) + (my_clut[clr].cr << 24);
+ } else {
+ yuy2 = my_clut[clr].y + (my_clut[clr].cr << 8) +
+ (my_clut[clr].y << 16) + (my_clut[clr].cb << 24);
+ }
+
+ if (o >= 15) {
+ while(l--) {
+ *((uint32_t *)dst)++ = yuy2;
+ }
+ if(rle->len & 1)
+ *((uint16_t *)dst)++ = yuy2 & 0xffff;
+ } else {
+ if( l ) {
+ mem_blend32(dst, (uint8_t *)&yuy2, o, l);
+ dst += 4*l;
+ }
+
+ if(rle->len & 1) {
+ *dst = BLEND_BYTE(*dst, *((uint8_t *)&yuy2), o);
+ dst++;
+ *dst = BLEND_BYTE(*dst, *((uint8_t *)&yuy2+1), o);
+ dst++;
+ }
+ }
+ } else {
+ dst += rle->len*2;
+ }
+
+ x += rle->len;
+ rle++;
+ if (rle >= rle_limit) break;
+ }
+ if (rle >= rle_limit) break;
+
+ dst_y += dst_width*2;
+ }
+}
diff --git a/src/video_out/alphablend.h b/src/video_out/alphablend.h
index bb3f4ae59..799dcd789 100644
--- a/src/video_out/alphablend.h
+++ b/src/video_out/alphablend.h
@@ -51,6 +51,9 @@ void blend_yuv (uint8_t * dst_img, vo_overlay_t * img_overl,
void blend_yuv_vo_frame(vo_frame_t* dst_img, vo_overlay_t* img_overl);
+void blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl,
+ int dst_width, int dst_height);
+
void crop_overlay (vo_overlay_t * overlay);
#endif
diff --git a/src/video_out/video_out_xv.c b/src/video_out/video_out_xv.c
index 938d6349f..4bb5c60d8 100644
--- a/src/video_out/video_out_xv.c
+++ b/src/video_out/video_out_xv.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_xv.c,v 1.81 2001/11/28 22:19:12 miguelfreitas Exp $
+ * $Id: video_out_xv.c,v 1.82 2001/11/30 12:32:01 miguelfreitas Exp $
*
* video_out_xv.c, X11 video extension interface for xine
*
@@ -784,7 +784,10 @@ static void xv_overlay_blend (vo_driver_t *this_gen, vo_frame_t *frame_gen, vo_o
*/
if (overlay->rle) {
- blend_yuv( frame->image->data, overlay, frame->width, frame->height);
+ if( frame->format == IMGFMT_YV12 )
+ blend_yuv( frame->image->data, overlay, frame->width, frame->height);
+ else
+ blend_yuy2( frame->image->data, overlay, frame->width, frame->height);
}
}
@@ -841,11 +844,6 @@ static void xv_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen) {
xv_calc_format (this, frame->width, frame->height, frame->ratio_code);
}
- /* Alpha Blend here
- if (this->overlay) {
- blend_yuv( frame->image->data, this->overlay, frame->width, frame->height);
- } */
-
if (this->deinterlace_enabled && this->deinterlace_method)
xv_deinterlace_frame (this);