Enlightenment CVS committal
Author : moom16
Project : e17
Module : libs/emotion
Dir : e17/libs/emotion/src/modules/xine
Modified Files:
emotion_xine_vo_out.c
Log Message:
* Have rewritten the yuy2->rgb converter to avoid license problems.
So now, emotion_xine supports yuy2-encoded movies (such as .wmv).
===================================================================
RCS file:
/cvsroot/enlightenment/e17/libs/emotion/src/modules/xine/emotion_xine_vo_out.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -3 -r1.8 -r1.9
--- emotion_xine_vo_out.c 8 Jul 2005 20:28:50 -0000 1.8
+++ emotion_xine_vo_out.c 8 Jul 2005 23:08:48 -0000 1.9
@@ -94,6 +94,8 @@
static void _emotion_overlay_mem_blend_8 (uint8_t *mem, uint8_t val,
uint8_t o, size_t sz);
static void _emotion_overlay_blend_yuv (uint8_t *dst_base[3],
vo_overlay_t * img_overl, int dst_width, int dst_height, int dst_pitches[3]);
+static void _emotion_yuy2_to_bgra32 (int width, int height,
unsigned char *src, unsigned char *dst);
+
/***************************************************************************/
static vo_info_t _emotion_info =
{
@@ -215,7 +217,7 @@
dv = (Emotion_Driver *)vo_driver;
// printf("emotion: _emotion_capabilities_get()\n");
- return VO_CAP_YV12;
+ return VO_CAP_YV12 | VO_CAP_YUY2;
}
/***************************************************************************/
@@ -358,6 +360,7 @@
{
int y_size, uv_size;
+ fr->frame.format = EMOTION_YV12;
fr->vo_frame.pitches[0] = 8 * ((width + 7) / 8);
fr->vo_frame.pitches[1] = 8 * ((width + 15) / 16);
fr->vo_frame.pitches[2] = 8 * ((width + 15) / 16);
@@ -374,19 +377,49 @@
fr->frame.y = fr->vo_frame.base[0];
fr->frame.u = fr->vo_frame.base[1];
fr->frame.v = fr->vo_frame.base[2];
+ fr->frame.bgra_data = NULL;
fr->frame.y_stride = fr->vo_frame.pitches[0];
fr->frame.u_stride = fr->vo_frame.pitches[1];
fr->frame.v_stride = fr->vo_frame.pitches[2];
fr->frame.obj = dv->ev->obj;
}
break;
+ case XINE_IMGFMT_YUY2:
+ {
+ int y_size, uv_size;
+
+ fr->frame.format = EMOTION_BGRA;
+ fr->vo_frame.pitches[0] = 8 * ((width + 3) / 4);
+ fr->vo_frame.pitches[1] = 0;
+ fr->vo_frame.pitches[2] = 0;
+
+ fr->vo_frame.base[0] = malloc(fr->vo_frame.pitches[0] *
height);
+ fr->vo_frame.base[1] = NULL;
+ fr->vo_frame.base[2] = NULL;
+
+ fr->frame.w = fr->width;
+ fr->frame.h = fr->height;
+ fr->frame.ratio = fr->vo_frame.ratio;
+ fr->frame.y = NULL;
+ fr->frame.u = NULL;
+ fr->frame.v = NULL;
+ fr->frame.bgra_data = malloc(fr->width * fr->height * 4);
+ fr->frame.y_stride = 0;
+ fr->frame.u_stride = 0;
+ fr->frame.v_stride = 0;
+ fr->frame.obj = dv->ev->obj;
+ }
+ break;
default:
break;
}
if (((format == XINE_IMGFMT_YV12)
&& ((fr->vo_frame.base[0] == NULL)
|| (fr->vo_frame.base[1] == NULL)
- || (fr->vo_frame.base[2] == NULL))))
+ || (fr->vo_frame.base[2] == NULL)))
+ || ((format == XINE_IMGFMT_YUY2)
+ && ((fr->vo_frame.base[0] == NULL)
+ || (fr->frame.bgra_data == NULL))))
{
_emotion_frame_data_free(fr);
}
@@ -408,6 +441,11 @@
{
void *buf;
int ret;
+
+ if (fr->format == XINE_IMGFMT_YUY2)
+ {
+ _emotion_yuy2_to_bgra32(fr->width, fr->height, fr->vo_frame.base[0],
fr->frame.bgra_data);
+ }
buf = &(fr->frame);
fr->frame.timestamp = (double)fr->vo_frame.vpts / 90000.0;
@@ -444,6 +482,11 @@
fr->frame.u = fr->vo_frame.base[1];
fr->frame.v = fr->vo_frame.base[2];
}
+ if (fr->frame.bgra_data)
+ {
+ free(fr->frame.bgra_data);
+ fr->frame.bgra_data = NULL;
+ }
}
static void
@@ -672,3 +715,34 @@
}
}
}
+
+//TODO: Really need to improve this converter!
+#define LIMIT(x) ((x) > 0xff ? 0xff : ((x) < 0 ? 0 : (x)))
+
+static void
+_emotion_yuy2_to_bgra32(int width, int height, unsigned char *src, unsigned
char *dst)
+{
+ int i, j;
+ unsigned char *y, *u, *v;
+
+ y = src;
+ u = src + 1;
+ v = src + 3;
+ for (i = 0; i < width; i++)
+ {
+ for (j = 0; j < height; j++)
+ {
+ *dst++ = LIMIT(1.164 * (*y - 16) + 2.018 * (*u - 128));
+ *dst++ = LIMIT(1.164 * (*y - 16) - 0.813 * (*v - 128) - 0.391 * (*u -
128));
+ *dst++ = LIMIT(1.164 * (*y - 16) + 1.596 * (*v - 128));
+ *dst++ = 0;
+
+ y += 2;
+ if (j % 2 == 1)
+ {
+ u += 4;
+ v += 4;
+ }
+ }
+ }
+}
-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs