summaryrefslogtreecommitdiff
path: root/legacy
diff options
context:
space:
mode:
authormoom16 <moom16>2005-07-08 23:08:48 +0000
committermoom16 <moom16@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>2005-07-08 23:08:48 +0000
commitee5135f71f2c18ead808851f55f43c4d087b4036 (patch)
treedd49ea346794d16d76c6def4e73de054cb6a0271 /legacy
parent8e204f7f5668256ec7508a6f88f8c9f8a3c4255e (diff)
* Have rewritten the yuy2->rgb converter to avoid license problems.
So now, emotion_xine supports yuy2-encoded movies (such as .wmv). SVN revision: 15678
Diffstat (limited to '')
-rw-r--r--legacy/emotion/src/lib/emotion_private.h12
-rw-r--r--legacy/emotion/src/lib/emotion_smart.c63
-rw-r--r--legacy/emotion/src/modules/emotion_xine.c40
-rw-r--r--legacy/emotion/src/modules/emotion_xine.h2
-rw-r--r--legacy/emotion/src/modules/xine/emotion_xine_vo_out.c78
5 files changed, 164 insertions, 31 deletions
diff --git a/legacy/emotion/src/lib/emotion_private.h b/legacy/emotion/src/lib/emotion_private.h
index 15eab8e56d..8afc748d4b 100644
--- a/legacy/emotion/src/lib/emotion_private.h
+++ b/legacy/emotion/src/lib/emotion_private.h
@@ -15,8 +15,16 @@
15#define META_TRACK_YEAR 6 15#define META_TRACK_YEAR 6
16#define META_TRACK_DISCID 7 16#define META_TRACK_DISCID 7
17 17
18typedef enum _Emotion_Format Emotion_Format;
18typedef struct _Emotion_Video_Module Emotion_Video_Module; 19typedef struct _Emotion_Video_Module Emotion_Video_Module;
19 20
21enum _Emotion_Format
22{
23 EMOTION_YV12,
24 EMOTION_YUY2, /* unused for now since evas does not support yuy2 format */
25 EMOTION_BGRA
26};
27
20struct _Emotion_Video_Module 28struct _Emotion_Video_Module
21{ 29{
22 unsigned char (*init) (Evas_Object *obj, void **video); 30 unsigned char (*init) (Evas_Object *obj, void **video);
@@ -35,8 +43,10 @@ struct _Emotion_Video_Module
35 int (*audio_handled) (void *ef); 43 int (*audio_handled) (void *ef);
36 int (*seekable) (void *ef); 44 int (*seekable) (void *ef);
37 void (*frame_done) (void *ef); 45 void (*frame_done) (void *ef);
38 void (*yuv_size_get) (void *ef, int *w, int *h); 46 Emotion_Format (*format_get) (void *ef);
47 void (*video_data_size_get) (void *ef, int *w, int *h);
39 int (*yuv_rows_get) (void *ef, int w, int h, unsigned char **yrows, unsigned char **urows, unsigned char **vrows); 48 int (*yuv_rows_get) (void *ef, int w, int h, unsigned char **yrows, unsigned char **urows, unsigned char **vrows);
49 int (*bgra_data_get) (void *ef, unsigned char **bgra_data);
40 void (*event_feed) (void *ef, int event); 50 void (*event_feed) (void *ef, int event);
41 void (*event_mouse_button_feed) (void *ef, int button, int x, int y); 51 void (*event_mouse_button_feed) (void *ef, int button, int x, int y);
42 void (*event_mouse_move_feed) (void *ef, int x, int y); 52 void (*event_mouse_move_feed) (void *ef, int x, int y);
diff --git a/legacy/emotion/src/lib/emotion_smart.c b/legacy/emotion/src/lib/emotion_smart.c
index 834841b038..a5596cb685 100644
--- a/legacy/emotion/src/lib/emotion_smart.c
+++ b/legacy/emotion/src/lib/emotion_smart.c
@@ -982,42 +982,55 @@ _pos_set_job(void *data)
982static void 982static void
983_pixels_get(void *data, Evas_Object *obj) 983_pixels_get(void *data, Evas_Object *obj)
984{ 984{
985 Evas_Pixel_Import_Source ps;
986 int iw, ih, w, h; 985 int iw, ih, w, h;
987 int i;
988 unsigned char **rows;
989 Smart_Data *sd; 986 Smart_Data *sd;
987 Emotion_Format format;
990 988
991 sd = data; 989 sd = data;
992 evas_object_image_size_get(obj, &iw, &ih); 990 evas_object_image_size_get(obj, &iw, &ih);
993 sd->module->yuv_size_get(sd->video, &w, &h); 991 sd->module->video_data_size_get(sd->video, &w, &h);
994 if ((w != iw) || (h != ih)) 992 if ((w != iw) || (h != ih))
995 { 993 {
996 evas_object_image_size_set(obj, w, h); 994 evas_object_image_size_set(obj, w, h);
997 iw = w; 995 iw = w;
998 ih = h; 996 ih = h;
999 } 997 }
1000 ps.format = EVAS_PIXEL_FORMAT_YUV420P_601; 998 format = sd->module->format_get(sd->video);
1001 ps.w = iw; 999 if (format == EMOTION_YV12)
1002 ps.h = ih; 1000 {
1001 unsigned char **rows;
1002 Evas_Pixel_Import_Source ps;
1003 1003
1004 ps.rows = malloc(ps.h * 2 * sizeof(void *)); 1004 ps.format = EVAS_PIXEL_FORMAT_YUV420P_601;
1005 if (!ps.rows) 1005 ps.w = iw;
1006 ps.h = ih;
1007
1008 ps.rows = malloc(ps.h * 2 * sizeof(void *));
1009 if (!ps.rows)
1010 {
1011 sd->module->frame_done(sd->video);
1012 return;
1013 }
1014
1015 rows = (unsigned char **)ps.rows;
1016
1017 if (sd->module->yuv_rows_get(sd->video, iw, ih,
1018 rows,
1019 &rows[ps.h],
1020 &rows[ps.h + (ps.h / 2)]))
1021 evas_object_image_pixels_import(obj, &ps);
1022 evas_object_image_pixels_dirty_set(obj, 0);
1023 free(ps.rows);
1024 }
1025 else if (format == EMOTION_BGRA)
1006 { 1026 {
1007 sd->module->frame_done(sd->video); 1027 unsigned char *bgra_data;
1008 return; 1028 if (sd->module->bgra_data_get(sd->video, &bgra_data));
1029 {
1030 evas_object_image_data_set(obj, bgra_data);
1031 }
1009 } 1032 }
1010 1033
1011
1012 rows = (unsigned char **)ps.rows;
1013
1014 if (sd->module->yuv_rows_get(sd->video, iw, ih,
1015 rows,
1016 &rows[ps.h],
1017 &rows[ps.h + (ps.h / 2)]))
1018 evas_object_image_pixels_import(obj, &ps);
1019 evas_object_image_pixels_dirty_set(obj, 0);
1020 free(ps.rows);
1021 sd->module->frame_done(sd->video); 1034 sd->module->frame_done(sd->video);
1022} 1035}
1023 1036
diff --git a/legacy/emotion/src/modules/emotion_xine.c b/legacy/emotion/src/modules/emotion_xine.c
index d7c225bd0a..d2c53acd50 100644
--- a/legacy/emotion/src/modules/emotion_xine.c
+++ b/legacy/emotion/src/modules/emotion_xine.c
@@ -16,8 +16,10 @@ static double em_pos_get(void *ef);
16static double em_ratio_get(void *ef); 16static double em_ratio_get(void *ef);
17static int em_seekable(void *ef); 17static int em_seekable(void *ef);
18static void em_frame_done(void *ef); 18static void em_frame_done(void *ef);
19static void em_yuv_size_get(void *ef, int *w, int *h); 19static Emotion_Format em_format_get(void *ef);
20static void em_video_data_size_get(void *ef, int *w, int *h);
20static int em_yuv_rows_get(void *ef, int w, int h, unsigned char **yrows, unsigned char **urows, unsigned char **vrows); 21static int em_yuv_rows_get(void *ef, int w, int h, unsigned char **yrows, unsigned char **urows, unsigned char **vrows);
22static int em_bgra_data_get(void *ef, unsigned char **bgra_data);
21static void em_event_feed(void *ef, int event); 23static void em_event_feed(void *ef, int event);
22static void em_event_mouse_button_feed(void *ef, int button, int x, int y); 24static void em_event_mouse_button_feed(void *ef, int button, int x, int y);
23static void em_event_mouse_move_feed(void *ef, int x, int y); 25static void em_event_mouse_move_feed(void *ef, int x, int y);
@@ -544,8 +546,21 @@ em_frame_done(void *ef)
544 } 546 }
545} 547}
546 548
549static Emotion_Format em_format_get(void *ef)
550{
551 Emotion_Xine_Video *ev;
552 Emotion_Xine_Video_Frame *fr;
553
554 ev = (Emotion_Xine_Video *)ef;
555 fr = ev->cur_frame;
556
557 if (fr)
558 return fr->format;
559 return EMOTION_YV12;
560}
561
547static void 562static void
548em_yuv_size_get(void *ef, int *w, int *h) 563em_video_data_size_get(void *ef, int *w, int *h)
549{ 564{
550 Emotion_Xine_Video *ev; 565 Emotion_Xine_Video *ev;
551 Emotion_Xine_Video_Frame *fr; 566 Emotion_Xine_Video_Frame *fr;
@@ -583,6 +598,23 @@ em_yuv_rows_get(void *ef, int w, int h, unsigned char **yrows, unsigned char **u
583 return 0; 598 return 0;
584} 599}
585 600
601static int
602em_bgra_data_get(void *ef, unsigned char **bgra_data)
603{
604 Emotion_Xine_Video *ev;
605 Emotion_Xine_Video_Frame *fr;
606
607 ev = (Emotion_Xine_Video *)ef;
608 fr = ev->cur_frame;
609 if (!fr) return 0;
610 if (fr->bgra_data)
611 {
612 *bgra_data = fr->bgra_data;
613 return 1;
614 }
615 return 0;
616}
617
586static void 618static void
587em_event_feed(void *ef, int event) 619em_event_feed(void *ef, int event)
588{ 620{
@@ -1337,8 +1369,10 @@ static Emotion_Video_Module em_module =
1337 em_audio_handled, /* audio_handled */ 1369 em_audio_handled, /* audio_handled */
1338 em_seekable, /* seekable */ 1370 em_seekable, /* seekable */
1339 em_frame_done, /* frame_done */ 1371 em_frame_done, /* frame_done */
1340 em_yuv_size_get, /* yuv_size_get */ 1372 em_format_get, /* format_get */
1373 em_video_data_size_get, /* video_data_size_get */
1341 em_yuv_rows_get, /* yuv_rows_get */ 1374 em_yuv_rows_get, /* yuv_rows_get */
1375 em_bgra_data_get, /* bgra_data_get */
1342 em_event_feed, /* event_feed */ 1376 em_event_feed, /* event_feed */
1343 em_event_mouse_button_feed, /* event_mouse_button_feed */ 1377 em_event_mouse_button_feed, /* event_mouse_button_feed */
1344 em_event_mouse_move_feed, /* event_mouse_move_feed */ 1378 em_event_mouse_move_feed, /* event_mouse_move_feed */
diff --git a/legacy/emotion/src/modules/emotion_xine.h b/legacy/emotion/src/modules/emotion_xine.h
index f796bc9369..47bab1a73a 100644
--- a/legacy/emotion/src/modules/emotion_xine.h
+++ b/legacy/emotion/src/modules/emotion_xine.h
@@ -57,7 +57,9 @@ struct _Emotion_Xine_Video_Frame
57{ 57{
58 int w, h; 58 int w, h;
59 double ratio; 59 double ratio;
60 Emotion_Format format;
60 unsigned char *y, *u, *v; 61 unsigned char *y, *u, *v;
62 unsigned char *bgra_data;
61 int y_stride, u_stride, v_stride; 63 int y_stride, u_stride, v_stride;
62 Evas_Object *obj; 64 Evas_Object *obj;
63 double timestamp; 65 double timestamp;
diff --git a/legacy/emotion/src/modules/xine/emotion_xine_vo_out.c b/legacy/emotion/src/modules/xine/emotion_xine_vo_out.c
index 391f9acfd1..1650b094d7 100644
--- a/legacy/emotion/src/modules/xine/emotion_xine_vo_out.c
+++ b/legacy/emotion/src/modules/xine/emotion_xine_vo_out.c
@@ -94,6 +94,8 @@ static void _emotion_overlay_blend (vo_driver_t *vo_driver, vo_f
94static void _emotion_overlay_mem_blend_8 (uint8_t *mem, uint8_t val, uint8_t o, size_t sz); 94static void _emotion_overlay_mem_blend_8 (uint8_t *mem, uint8_t val, uint8_t o, size_t sz);
95static 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]); 95static 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]);
96 96
97static void _emotion_yuy2_to_bgra32 (int width, int height, unsigned char *src, unsigned char *dst);
98
97/***************************************************************************/ 99/***************************************************************************/
98static vo_info_t _emotion_info = 100static vo_info_t _emotion_info =
99{ 101{
@@ -215,7 +217,7 @@ _emotion_capabilities_get(vo_driver_t *vo_driver)
215 217
216 dv = (Emotion_Driver *)vo_driver; 218 dv = (Emotion_Driver *)vo_driver;
217// printf("emotion: _emotion_capabilities_get()\n"); 219// printf("emotion: _emotion_capabilities_get()\n");
218 return VO_CAP_YV12; 220 return VO_CAP_YV12 | VO_CAP_YUY2;
219} 221}
220 222
221/***************************************************************************/ 223/***************************************************************************/
@@ -358,6 +360,7 @@ _emotion_frame_format_update(vo_driver_t *vo_driver, vo_frame_t *vo_frame, uint3
358 { 360 {
359 int y_size, uv_size; 361 int y_size, uv_size;
360 362
363 fr->frame.format = EMOTION_YV12;
361 fr->vo_frame.pitches[0] = 8 * ((width + 7) / 8); 364 fr->vo_frame.pitches[0] = 8 * ((width + 7) / 8);
362 fr->vo_frame.pitches[1] = 8 * ((width + 15) / 16); 365 fr->vo_frame.pitches[1] = 8 * ((width + 15) / 16);
363 fr->vo_frame.pitches[2] = 8 * ((width + 15) / 16); 366 fr->vo_frame.pitches[2] = 8 * ((width + 15) / 16);
@@ -374,19 +377,49 @@ _emotion_frame_format_update(vo_driver_t *vo_driver, vo_frame_t *vo_frame, uint3
374 fr->frame.y = fr->vo_frame.base[0]; 377 fr->frame.y = fr->vo_frame.base[0];
375 fr->frame.u = fr->vo_frame.base[1]; 378 fr->frame.u = fr->vo_frame.base[1];
376 fr->frame.v = fr->vo_frame.base[2]; 379 fr->frame.v = fr->vo_frame.base[2];
380 fr->frame.bgra_data = NULL;
377 fr->frame.y_stride = fr->vo_frame.pitches[0]; 381 fr->frame.y_stride = fr->vo_frame.pitches[0];
378 fr->frame.u_stride = fr->vo_frame.pitches[1]; 382 fr->frame.u_stride = fr->vo_frame.pitches[1];
379 fr->frame.v_stride = fr->vo_frame.pitches[2]; 383 fr->frame.v_stride = fr->vo_frame.pitches[2];
380 fr->frame.obj = dv->ev->obj; 384 fr->frame.obj = dv->ev->obj;
381 } 385 }
382 break; 386 break;
387 case XINE_IMGFMT_YUY2:
388 {
389 int y_size, uv_size;
390
391 fr->frame.format = EMOTION_BGRA;
392 fr->vo_frame.pitches[0] = 8 * ((width + 3) / 4);
393 fr->vo_frame.pitches[1] = 0;
394 fr->vo_frame.pitches[2] = 0;
395
396 fr->vo_frame.base[0] = malloc(fr->vo_frame.pitches[0] * height);
397 fr->vo_frame.base[1] = NULL;
398 fr->vo_frame.base[2] = NULL;
399
400 fr->frame.w = fr->width;
401 fr->frame.h = fr->height;
402 fr->frame.ratio = fr->vo_frame.ratio;
403 fr->frame.y = NULL;
404 fr->frame.u = NULL;
405 fr->frame.v = NULL;
406 fr->frame.bgra_data = malloc(fr->width * fr->height * 4);
407 fr->frame.y_stride = 0;
408 fr->frame.u_stride = 0;
409 fr->frame.v_stride = 0;
410 fr->frame.obj = dv->ev->obj;
411 }
412 break;
383 default: 413 default:
384 break; 414 break;
385 } 415 }
386 if (((format == XINE_IMGFMT_YV12) 416 if (((format == XINE_IMGFMT_YV12)
387 && ((fr->vo_frame.base[0] == NULL) 417 && ((fr->vo_frame.base[0] == NULL)
388 || (fr->vo_frame.base[1] == NULL) 418 || (fr->vo_frame.base[1] == NULL)
389 || (fr->vo_frame.base[2] == NULL)))) 419 || (fr->vo_frame.base[2] == NULL)))
420 || ((format == XINE_IMGFMT_YUY2)
421 && ((fr->vo_frame.base[0] == NULL)
422 || (fr->frame.bgra_data == NULL))))
390 { 423 {
391 _emotion_frame_data_free(fr); 424 _emotion_frame_data_free(fr);
392 } 425 }
@@ -408,6 +441,11 @@ _emotion_frame_display(vo_driver_t *vo_driver, vo_frame_t *vo_frame)
408 { 441 {
409 void *buf; 442 void *buf;
410 int ret; 443 int ret;
444
445 if (fr->format == XINE_IMGFMT_YUY2)
446 {
447 _emotion_yuy2_to_bgra32(fr->width, fr->height, fr->vo_frame.base[0], fr->frame.bgra_data);
448 }
411 449
412 buf = &(fr->frame); 450 buf = &(fr->frame);
413 fr->frame.timestamp = (double)fr->vo_frame.vpts / 90000.0; 451 fr->frame.timestamp = (double)fr->vo_frame.vpts / 90000.0;
@@ -444,6 +482,11 @@ _emotion_frame_data_free(Emotion_Frame *fr)
444 fr->frame.u = fr->vo_frame.base[1]; 482 fr->frame.u = fr->vo_frame.base[1];
445 fr->frame.v = fr->vo_frame.base[2]; 483 fr->frame.v = fr->vo_frame.base[2];
446 } 484 }
485 if (fr->frame.bgra_data)
486 {
487 free(fr->frame.bgra_data);
488 fr->frame.bgra_data = NULL;
489 }
447} 490}
448 491
449static void 492static void
@@ -672,3 +715,34 @@ static void _emotion_overlay_blend_yuv(uint8_t *dst_base[3], vo_overlay_t * img_
672 } 715 }
673 } 716 }
674} 717}
718
719//TODO: Really need to improve this converter!
720#define LIMIT(x) ((x) > 0xff ? 0xff : ((x) < 0 ? 0 : (x)))
721
722static void
723_emotion_yuy2_to_bgra32(int width, int height, unsigned char *src, unsigned char *dst)
724{
725 int i, j;
726 unsigned char *y, *u, *v;
727
728 y = src;
729 u = src + 1;
730 v = src + 3;
731 for (i = 0; i < width; i++)
732 {
733 for (j = 0; j < height; j++)
734 {
735 *dst++ = LIMIT(1.164 * (*y - 16) + 2.018 * (*u - 128));
736 *dst++ = LIMIT(1.164 * (*y - 16) - 0.813 * (*v - 128) - 0.391 * (*u - 128));
737 *dst++ = LIMIT(1.164 * (*y - 16) + 1.596 * (*v - 128));
738 *dst++ = 0;
739
740 y += 2;
741 if (j % 2 == 1)
742 {
743 u += 4;
744 v += 4;
745 }
746 }
747 }
748}