jpeg pushed a commit to branch master. http://git.enlightenment.org/tools/expedite.git/commit/?id=0529ce56b6fb01e9651e76461e9608e15a040fb3
commit 0529ce56b6fb01e9651e76461e9608e15a040fb3 Author: Jean-Philippe Andre <jp.an...@samsung.com> Date: Wed Jan 11 10:52:33 2017 +0900 images: Fix YUV and other image data tests --- src/bin/image_data_argb.c | 60 +++++----- src/bin/image_data_argb_alpha.c | 47 ++++---- src/bin/image_data_ycbcr601pl.c | 70 ++++-------- ...mage_data_ycbcr601pl_map_nearest_solid_rotate.c | 67 ++++------- src/bin/image_data_ycbcr601pl_map_solid_rotate.c | 66 ++++------- src/bin/image_data_ycbcr601pl_wide_stride.c | 122 ++++++++------------- 6 files changed, 174 insertions(+), 258 deletions(-) diff --git a/src/bin/image_data_argb.c b/src/bin/image_data_argb.c index 5707f36..d5889ce 100644 --- a/src/bin/image_data_argb.c +++ b/src/bin/image_data_argb.c @@ -20,13 +20,12 @@ static Evas_Object *o_images[1]; /* setup */ static void _setup(void) { - int i; Evas_Object *o; - void *pixels; - Eina_Slice slice; + Eina_Slice sl; - pixels = malloc(sizeof (int) * 640 * 480); - for (i = 0; i < 1; i++) + sl.len = 640 * 480 * 4; + sl.mem = malloc(sl.len); + for (int i = 0; i < 1; i++) { o = efl_add(EFL_CANVAS_IMAGE_CLASS, evas); o_images[i] = o; @@ -35,50 +34,53 @@ static void _setup(void) efl_gfx_fill_set(o, 0, 0, 640, 480); efl_gfx_size_set(o, 640, 480); efl_gfx_visible_set(o, EINA_TRUE); - slice = (Eina_Slice)EINA_SLICE_STR(pixels); - efl_gfx_buffer_copy_set(o_images[i], &slice, 640, 480, 640 * sizeof (int), EFL_GFX_COLORSPACE_ARGB8888, 0); + efl_gfx_buffer_managed_set(o, &sl, 640, 480, 0, EFL_GFX_COLORSPACE_ARGB8888, 0); } - free(pixels); done = 0; } /* cleanup */ static void _cleanup(void) { - int i; - for (i = 0; i < 1; i++) efl_del(o_images[i]); + for (int i = 0; i < 1; i++) + { + Evas_Object *o = o_images[i]; + Eina_Slice sl = {}; + + efl_gfx_buffer_managed_get(o, &sl, 0); + free((void *) sl.mem); + efl_del(o); + } } /* loop - do things */ static void _loop(double t, int f) { - int i, st; - Evas_Coord x, y, w, h; - Eina_Rw_Slice rw_slice; - - for (i = 0; i < 1; i++) + for (int i = 0; i < 1; i++) { - unsigned int result, *p; - int length; + Evas_Object *o = o_images[i]; + unsigned int *data, *p; + Evas_Coord x, y, w, h; + Eina_Rw_Slice sl = {}; + int st; w = 640; h = 480; x = (win_w / 2) - (w / 2); y = (win_h / 2) - (h / 2); - efl_gfx_position_set(o_images[i], x, y); - efl_gfx_size_set(o_images[i], w, h); - efl_gfx_fill_set(o_images[i], 0, 0, w, h); - result = efl_gfx_buffer_map(o_images[i], &rw_slice, - EFL_GFX_BUFFER_ACCESS_MODE_WRITE, - 0, 0, 0, 0, EFL_GFX_COLORSPACE_ARGB8888, 0, - &st); - if (!result) + efl_gfx_position_set(o, x, y); + efl_gfx_size_set(o, w, h); + efl_gfx_fill_set(o, 0, 0, w, h); + efl_gfx_buffer_map(o, &sl, EFL_GFX_BUFFER_ACCESS_MODE_WRITE, + 0, 0, 0, 0, EFL_GFX_COLORSPACE_ARGB8888, 0, &st); + data = sl.mem; + if (!data) { fprintf(stderr, "ERROR: Failed to map image!\n"); - continue; + continue; } st = st >> 2; - p = rw_slice.mem; + p = sl.mem; for (y = 0; y < h; y++) { for (x = 0; x < w; x++) @@ -88,8 +90,8 @@ static void _loop(double t, int f) } p += (st - w); } - efl_gfx_buffer_unmap(o_images[i], &rw_slice); - efl_gfx_buffer_update_add(o_images[i], 0, 0, w, h); + efl_gfx_buffer_unmap(o, &sl); + efl_gfx_buffer_update_add(o, 0, 0, w, h); } FPS_STD(NAME); } diff --git a/src/bin/image_data_argb_alpha.c b/src/bin/image_data_argb_alpha.c index a4cdabe..79f4c54 100644 --- a/src/bin/image_data_argb_alpha.c +++ b/src/bin/image_data_argb_alpha.c @@ -20,12 +20,12 @@ static Evas_Object *o_images[1]; /* setup */ static void _setup(void) { - int i; Evas_Object *o; - void *pixels; + Eina_Slice sl; - pixels = malloc(sizeof (int) * 640 * 480); - for (i = 0; i < 1; i++) + sl.len = 640 * 480 * 4; + sl.mem = malloc(sl.len); + for (int i = 0; i < 1; i++) { o = efl_add(EFL_CANVAS_IMAGE_CLASS, evas); o_images[i] = o; @@ -34,17 +34,23 @@ static void _setup(void) efl_gfx_fill_set(o, 0, 0, 640, 480); efl_gfx_size_set(o, 640, 480); efl_gfx_visible_set(o, EINA_TRUE); - efl_gfx_buffer_copy_set(o_images[i], pixels, 640, 480, 640 * sizeof (int), EFL_GFX_COLORSPACE_ARGB8888, 0); + efl_gfx_buffer_managed_set(o, &sl, 640, 480, 0, EFL_GFX_COLORSPACE_ARGB8888, 0); } - free(pixels); done = 0; } /* cleanup */ static void _cleanup(void) { - int i; - for (i = 0; i < 1; i++) efl_del(o_images[i]); + for (int i = 0; i < 1; i++) + { + Evas_Object *o = o_images[i]; + Eina_Slice sl = {}; + + efl_gfx_buffer_managed_get(o, &sl, 0); + free((void *) sl.mem); + efl_del(o); + } } /* loop - do things */ @@ -52,31 +58,30 @@ static void _loop(double t, int f) { int i, st; Evas_Coord x, y, w, h; - Eina_Rw_Slice rw_slice; for (i = 0; i < 1; i++) { - unsigned int result, *p; + Evas_Object *o = o_images[i]; + unsigned int *p; + Eina_Rw_Slice sl = {}; int a, r, g, b; w = 640; h = 480; x = (win_w / 2) - (w / 2); y = (win_h / 2) - (h / 2); - efl_gfx_position_set(o_images[i], x, y); - efl_gfx_size_set(o_images[i], w, h); - efl_gfx_fill_set(o_images[i], 0, 0, w, h); - result = efl_gfx_buffer_map(o_images[i], &rw_slice, - EFL_GFX_BUFFER_ACCESS_MODE_WRITE, - 0, 0, 0, 0, EFL_GFX_COLORSPACE_ARGB8888, 0, - &st); - if (!result) + efl_gfx_position_set(o, x, y); + efl_gfx_size_set(o, w, h); + efl_gfx_fill_set(o, 0, 0, w, h); + efl_gfx_buffer_map(o, &sl, EFL_GFX_BUFFER_ACCESS_MODE_WRITE, + 0, 0, 0, 0, EFL_GFX_COLORSPACE_ARGB8888, 0, &st); + if (!sl.mem) { fprintf(stderr, "ERROR: Failed to map image!\n"); continue; } st = st >> 2; - p = rw_slice.mem; + p = sl.mem; for (y = 0; y < h; y++) { for (x = 0; x < w; x++) @@ -97,8 +102,8 @@ static void _loop(double t, int f) } p += (st - w); } - efl_gfx_buffer_unmap(o_images[i], &rw_slice); - efl_gfx_buffer_update_add(o_images[i], 0, 0, w, h); + efl_gfx_buffer_unmap(o, &sl); + efl_gfx_buffer_update_add(o, 0, 0, w, h); } FPS_STD(NAME); } diff --git a/src/bin/image_data_ycbcr601pl.c b/src/bin/image_data_ycbcr601pl.c index 0507b9a..032d5b3 100644 --- a/src/bin/image_data_ycbcr601pl.c +++ b/src/bin/image_data_ycbcr601pl.c @@ -16,62 +16,34 @@ static int done = 0; /* private data */ static Evas_Object *o_images[1]; -static unsigned char *yp = NULL, *up = NULL, *vp = NULL; +static Eina_Slice slice[3]; /* setup */ static void _setup(void) { - int i, y; FILE *f; - unsigned char **lp; - Evas_Object *o; - Eina_Slice slice; - - for (i = 0; i < 1; i++) + for (int i = 0; i < 1; i++) { - o = efl_add(EFL_CANVAS_IMAGE_CLASS, evas); + Evas_Object *o = efl_add(EFL_CANVAS_IMAGE_CLASS, evas); o_images[i] = o; efl_image_content_hint_set(o, EVAS_IMAGE_CONTENT_HINT_DYNAMIC); efl_gfx_buffer_alpha_set(o, 0); efl_gfx_fill_set(o, 0, 0, 640, 480); efl_gfx_size_set(o, 640, 480); efl_gfx_visible_set(o, EINA_TRUE); - slice.mem = malloc(sizeof (void*) * (480 + 240 + 240)); - slice.len = (480 + 240 + 240); - yp = malloc(640 * 480); - up = malloc(320 * 240); - vp = malloc(320 * 240); - f = fopen(build_path("tp.yuv"), "rb"); - if (f) - { - fread(yp, 640 * 480, 1, f); - fread(up, 320 * 240, 1, f); - fread(vp, 320 * 240, 1, f); - fclose(f); - } - lp = (unsigned char**) slice.bytes; - for (y = 0; y < 480; y++) - { - *lp = yp + (y * 640); - lp++; - } - for (y = 0; y < 240; y++) - { - *lp = up + (y * 320); - lp++; - } - for (y = 0; y < 240; y++) + slice[0].len = 640 * 480; + slice[1].len = 320 * 240; + slice[2].len = 320 * 240; + f = fopen(build_path("tp.yuv"), "rb"); + if (!f) continue; + for (int p = 0; p < 3; p++) { - *lp = vp + (y * 320); - lp++; + slice[p].mem = malloc(slice[p].len); + fread((void *) slice[p].mem, slice[p].len, 1, f); + efl_gfx_buffer_managed_set(o, &slice[p], 640, 480, 0, EFL_GFX_COLORSPACE_YCBCR422P601_PL, p); } - /* efl_gfx_buffer_copy_set(o_images[i], &slice, 640, 480, 640 * sizeof (int), EVAS_COLORSPACE_YCBCR422P601_PL, 0); */ - free(slice.mem); - // Not a real copy in fact... - /* free(yp); */ - /* free(up); */ - /* free(vp); */ + fclose(f); } done = 0; } @@ -79,12 +51,16 @@ static void _setup(void) /* cleanup */ static void _cleanup(void) { - int i; - for (i = 0; i < 1; i++) efl_del(o_images[i]); - // FIXME: the object is not destroyed anymore so we can't free the data - /* free(yp); */ - /* free(up); */ - /* free(vp); */ + for (int i = 0; i < 1; i++) + { + Evas_Object *o = o_images[i]; + for (int p = 0; p < 3; p++) + { + efl_gfx_buffer_managed_set(o, NULL, 640, 480, 0, EFL_GFX_COLORSPACE_YCBCR422P601_PL, p); + free((void *) slice[p].mem); + } + efl_del(o); + } } /* loop - do things */ diff --git a/src/bin/image_data_ycbcr601pl_map_nearest_solid_rotate.c b/src/bin/image_data_ycbcr601pl_map_nearest_solid_rotate.c index 7413d9f..0a5bcf4 100644 --- a/src/bin/image_data_ycbcr601pl_map_nearest_solid_rotate.c +++ b/src/bin/image_data_ycbcr601pl_map_nearest_solid_rotate.c @@ -16,60 +16,34 @@ static int done = 0; /* private data */ static Evas_Object *o_images[1]; -static unsigned char *yp = NULL, *up = NULL, *vp = NULL; +static Eina_Slice slice[3]; /* setup */ static void _setup(void) { - int i, y; FILE *f; - unsigned char **data, **lp; - Evas_Object *o; - Eina_Slice slice; - - for (i = 0; i < 1; i++) + for (int i = 0; i < 1; i++) { - o = efl_add(EFL_CANVAS_IMAGE_CLASS, evas); + Evas_Object *o = efl_add(EFL_CANVAS_IMAGE_CLASS, evas); o_images[i] = o; efl_image_content_hint_set(o, EVAS_IMAGE_CONTENT_HINT_DYNAMIC); efl_gfx_buffer_alpha_set(o, 0); efl_gfx_fill_set(o, 0, 0, 640, 480); efl_gfx_size_set(o, 640, 480); - efl_image_smooth_scale_set(o, 0); efl_gfx_visible_set(o, EINA_TRUE); - data = malloc(sizeof (void*) * (480 + 240 + 240)); - yp = malloc(640 * 480); - up = malloc(320 * 240); - vp = malloc(320 * 240); + + slice[0].len = 640 * 480; + slice[1].len = 320 * 240; + slice[2].len = 320 * 240; f = fopen(build_path("tp.yuv"), "rb"); - if (f) - { - fread(yp, 640 * 480, 1, f); - fread(up, 320 * 240, 1, f); - fread(vp, 320 * 240, 1, f); - fclose(f); - } - lp = data; - for (y = 0; y < 480; y++) - { - *lp = yp + (y * 640); - lp++; - } - for (y = 0; y < 240; y++) + if (!f) continue; + for (int p = 0; p < 3; p++) { - *lp = up + (y * 320); - lp++; + slice[p].mem = malloc(slice[p].len); + fread((void *) slice[p].mem, slice[p].len, 1, f); + efl_gfx_buffer_managed_set(o, &slice[p], 640, 480, 0, EFL_GFX_COLORSPACE_YCBCR422P601_PL, p); } - for (y = 0; y < 240; y++) - { - *lp = vp + (y * 320); - lp++; - } - slice = (Eina_Slice)EINA_SLICE_STR(*data); - efl_gfx_buffer_managed_set(o_images[i], &slice, 640, 480, 0, EFL_GFX_COLORSPACE_YCBCR422P601_PL, 0); - free(yp); - free(up); - free(vp); + fclose(f); } done = 0; } @@ -77,11 +51,16 @@ static void _setup(void) /* cleanup */ static void _cleanup(void) { - int i; - for (i = 0; i < 1; i++) efl_del(o_images[i]); - /* free(yp); */ - /* free(up); */ - /* free(vp); */ + for (int i = 0; i < 1; i++) + { + Evas_Object *o = o_images[i]; + for (int p = 0; p < 3; p++) + { + efl_gfx_buffer_managed_set(o, NULL, 640, 480, 0, EFL_GFX_COLORSPACE_YCBCR422P601_PL, p); + free((void *) slice[p].mem); + } + efl_del(o); + } } /* loop - do things */ diff --git a/src/bin/image_data_ycbcr601pl_map_solid_rotate.c b/src/bin/image_data_ycbcr601pl_map_solid_rotate.c index af45b33..355293f 100644 --- a/src/bin/image_data_ycbcr601pl_map_solid_rotate.c +++ b/src/bin/image_data_ycbcr601pl_map_solid_rotate.c @@ -16,59 +16,34 @@ static int done = 0; /* private data */ static Evas_Object *o_images[1]; -static unsigned char *yp = NULL, *up = NULL, *vp = NULL; +static Eina_Slice slice[3]; /* setup */ static void _setup(void) { - int i, y; FILE *f; - unsigned char **data, **lp; - Evas_Object *o; - Eina_Slice slice; - - for (i = 0; i < 1; i++) + for (int i = 0; i < 1; i++) { - o = efl_add(EFL_CANVAS_IMAGE_CLASS, evas); + Evas_Object *o = efl_add(EFL_CANVAS_IMAGE_CLASS, evas); o_images[i] = o; efl_image_content_hint_set(o, EVAS_IMAGE_CONTENT_HINT_DYNAMIC); efl_gfx_buffer_alpha_set(o, 0); efl_gfx_fill_set(o, 0, 0, 640, 480); efl_gfx_size_set(o, 640, 480); efl_gfx_visible_set(o, EINA_TRUE); - data = malloc(sizeof (void*) * (480 + 240 + 240)); - yp = malloc(640 * 480); - up = malloc(320 * 240); - vp = malloc(320 * 240); + + slice[0].len = 640 * 480; + slice[1].len = 320 * 240; + slice[2].len = 320 * 240; f = fopen(build_path("tp.yuv"), "rb"); - if (f) - { - fread(yp, 640 * 480, 1, f); - fread(up, 320 * 240, 1, f); - fread(vp, 320 * 240, 1, f); - fclose(f); - } - lp = data; - for (y = 0; y < 480; y++) - { - *lp = yp + (y * 640); - lp++; - } - for (y = 0; y < 240; y++) + if (!f) continue; + for (int p = 0; p < 3; p++) { - *lp = up + (y * 320); - lp++; + slice[p].mem = malloc(slice[p].len); + fread((void *) slice[p].mem, slice[p].len, 1, f); + efl_gfx_buffer_managed_set(o, &slice[p], 640, 480, 0, EFL_GFX_COLORSPACE_YCBCR422P601_PL, p); } - for (y = 0; y < 240; y++) - { - *lp = vp + (y * 320); - lp++; - } - slice = (Eina_Slice)EINA_SLICE_STR(*data); - efl_gfx_buffer_managed_set(o_images[i], &slice, 640, 480, 0, EFL_GFX_COLORSPACE_YCBCR422P601_PL, 0); - free(yp); - free(up); - free(vp); + fclose(f); } done = 0; } @@ -76,11 +51,16 @@ static void _setup(void) /* cleanup */ static void _cleanup(void) { - int i; - for (i = 0; i < 1; i++) efl_del(o_images[i]); - /* free(yp); */ - /* free(up); */ - /* free(vp); */ + for (int i = 0; i < 1; i++) + { + Evas_Object *o = o_images[i]; + for (int p = 0; p < 3; p++) + { + efl_gfx_buffer_managed_set(o, NULL, 640, 480, 0, EFL_GFX_COLORSPACE_YCBCR422P601_PL, p); + free((void *) slice[p].mem); + } + efl_del(o); + } } /* loop - do things */ diff --git a/src/bin/image_data_ycbcr601pl_wide_stride.c b/src/bin/image_data_ycbcr601pl_wide_stride.c index b004a61..d4e8fa2 100644 --- a/src/bin/image_data_ycbcr601pl_wide_stride.c +++ b/src/bin/image_data_ycbcr601pl_wide_stride.c @@ -16,60 +16,40 @@ static int done = 0; /* private data */ static Evas_Object *o_images[1]; -static unsigned char *yp = NULL, *up = NULL, *vp = NULL; +static Eina_Slice slice[3]; /* setup */ static void _setup(void) { - int i, y; + int stride; FILE *f; - unsigned char **data, **lp; - Evas_Object *o; - Eina_Slice slice; - - for (i = 0; i < 1; i++) + int w = 320 - 16; + for (int i = 0; i < 1; i++) { - o = efl_add(EFL_CANVAS_IMAGE_CLASS, evas); + Evas_Object *o = efl_add(EFL_CANVAS_IMAGE_CLASS, evas); o_images[i] = o; efl_image_content_hint_set(o, EVAS_IMAGE_CONTENT_HINT_DYNAMIC); efl_gfx_buffer_alpha_set(o, 0); efl_gfx_fill_set(o, 0, 0, 640, 480); efl_gfx_size_set(o, 640, 480); efl_gfx_visible_set(o, EINA_TRUE); - data = malloc(sizeof (unsigned char*) * (480 + 240 + 240)); - yp = malloc(640 * 480); - up = malloc(320 * 240); - vp = malloc(320 * 240); + + // in this test, the stride is 640 but the width changes + slice[0].len = 640 * 480; + slice[1].len = 320 * 240; + slice[2].len = 320 * 240; f = fopen(build_path("tp.yuv"), "rb"); - if (f) + if (!f) continue; + stride = 640; + for (int p = 0; p < 3; p++) { - fread(yp, 640 * 480, 1, f); - fread(up, 320 * 240, 1, f); - fread(vp, 320 * 240, 1, f); - fclose(f); + slice[p].mem = malloc(slice[p].len); + fread((void *) slice[p].mem, slice[p].len, 1, f); + efl_gfx_buffer_managed_set(o, &slice[p], w, 480, stride, + EFL_GFX_COLORSPACE_YCBCR422P601_PL, p); + stride = 320; } - lp = data; - for (y = 0; y < 480; y++) - { - *lp = yp + (y * 640); - lp++; - } - for (y = 0; y < 240; y++) - { - *lp = up + (y * 320); - lp++; - } - for (y = 0; y < 240; y++) - { - *lp = vp + (y * 320); - lp++; - } - slice = (Eina_Slice)EINA_SLICE_STR(*data); - efl_gfx_buffer_managed_set(o_images[i], &slice, 640, 480, 0, EFL_GFX_COLORSPACE_YCBCR422P601_PL, 0); - efl_gfx_buffer_update_add(o_images[i], 0, 0, 320, 480); - free(yp); - free(up); - free(vp); + fclose(f); } done = 0; } @@ -77,11 +57,17 @@ static void _setup(void) /* cleanup */ static void _cleanup(void) { - int i; - for (i = 0; i < 1; i++) efl_del(o_images[i]); - /* free(yp); */ - /* free(up); */ - /* free(vp); */ + for (int i = 0; i < 1; i++) + { + Evas_Object *o = o_images[i]; + for (int p = 0; p < 3; p++) + { + efl_gfx_buffer_managed_set(o, NULL, 640, 480, 0, + EFL_GFX_COLORSPACE_YCBCR422P601_PL, p); + free((void *) slice[p].mem); + } + efl_del(o); + } } /* loop - do things */ @@ -89,47 +75,35 @@ static void _loop(double t, int f) { int i; Evas_Coord x, y, w, h; - Eina_Slice slice; for (i = 0; i < 1; i++) { - unsigned char **lp; + Evas_Object *o = o_images[i]; + Eina_Slice sl[3]; + int stride; + + for (int p = 0; p < 3; p++) + efl_gfx_buffer_managed_get(o, &sl[p], p); w = 640; h = 480; x = (win_w / 2) - (w / 2); y = (win_h / 2) - (h / 2); - efl_gfx_position_set(o_images[i], x, y); - efl_gfx_size_set(o_images[i], w, h); - efl_gfx_fill_set(o_images[i], 0, 0, w, h); - - w = 320 - 16 + f; - if (w < 1) w = 1; - else if (w > 640) w = 640; + efl_gfx_position_set(o, x, y); + efl_gfx_size_set(o, w, h); + efl_gfx_fill_set(o, 0, 0, w, h); - w &= ~0x1; + // logic here differs a bit from old expedite + w = 320 - 16 + (f * 2) % 336; + if (w > 640) w = 320; - slice.mem = malloc(sizeof (void*) * (480 + 240 + 240)); - slice.len = (480 + 240 + 240); - lp = slice.mem; - for (y = 0; y < 480; y++) + stride = 640; + for (int p = 0; p < 3; p++) { - *lp = yp + (y * 640); - lp++; + efl_gfx_buffer_managed_set(o, &sl[p], w, 480, stride, + EFL_GFX_COLORSPACE_YCBCR422P601_PL, p); + stride = 320; } - for (y = 0; y < 240; y++) - { - *lp = up + (y * 320); - lp++; - } - for (y = 0; y < 240; y++) - { - *lp = vp + (y * 320); - lp++; - } - - /* efl_gfx_buffer_copy_set(o_images[i], &slice, w, 480, w * sizeof (int), EVAS_COLORSPACE_YCBCR422P601_PL, 0); */ - efl_gfx_buffer_update_add(o_images[i], 0, 0, w, 480); - free(slice.mem); + efl_gfx_buffer_update_add(o, 0, 0, w, 480); } FPS_STD(NAME); } --