Enlightenment CVS committal Author : tilman Project : misc Module : enthrall
Dir : misc/enthrall/src Modified Files: enthrall.c rgb2yuv420.c rgb2yuv420.h theora.c theora.h Log Message: fixed handling of odd-shaped windows (non-4bit-aligned ones). since teaching the rgb2yuv conversion about these seems to be non-trivial, just use a properly sized imlib image. =================================================================== RCS file: /cvs/e/misc/enthrall/src/enthrall.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -3 -r1.12 -r1.13 --- enthrall.c 20 Oct 2006 20:50:22 -0000 1.12 +++ enthrall.c 22 Oct 2006 19:12:21 -0000 1.13 @@ -57,7 +57,8 @@ struct { Ecore_X_Window id; - int w, h; + int w, h, w16, h16; + int offset_x, offset_y; } window; struct { @@ -110,9 +111,10 @@ tmp = IMG_FROM_RECT (e->damage); /* and blend it onto the previous shot */ - imlib_blend_image_onto_image (tmp, true, - 0, 0, e->damage.width, e->damage.height, - e->damage.x, e->damage.y, + imlib_blend_image_onto_image (tmp, true, 0, 0, + e->damage.width, e->damage.height, + e->damage.x + e->window.offset_x, + e->damage.y + e->window.offset_y, e->damage.width, e->damage.height); /* free the temporary grab */ @@ -128,13 +130,13 @@ if (b == True) imlib_blend_image_onto_image (e->cursor.id, true, 0, 0, e->cursor.w, e->cursor.h, - ptr_x, ptr_y, + ptr_x + e->window.offset_x, + ptr_y + e->window.offset_y, e->cursor.w, e->cursor.h); } data = imlib_image_get_data_for_reading_only (); - rgb2yuv420 (data, e->window.w, e->window.h, e->y, e->u, e->v, - e->theora.yuv.y_stride, e->theora.yuv.uv_stride); + rgb2yuv420 (data, e->window.w16, e->window.h16, e->y, e->u, e->v); imlib_image_put_back_data (data); enthrall_theora_encode_frame (&e->theora, false); @@ -229,7 +231,9 @@ main (int argc, char **argv) { Enthrall e; + Imlib_Image tmp; char pointer_img[PATH_MAX], output_file[PATH_MAX] = {0}; + uint32_t *data; double start; bool s; int fps = 25, quality = 90; @@ -319,8 +323,12 @@ init_imlib (&e); + e.window.w16 = e.window.w; + e.window.h16 = e.window.h; + s = enthrall_theora_init (&e.theora, output_file, - quality, e.window.w, e.window.h, + quality, &e.window.w16, &e.window.h16, + &e.window.offset_x, &e.window.offset_y, &e.y, &e.u, &e.v); if (!s) { fprintf (stderr, "Error: Cannot initialize theora encoder.\n"); @@ -338,8 +346,19 @@ e.damage.height = e.window.h; e.damage_valid = true; - e.prev_img = IMG_FROM_RECT (e.damage); + e.prev_img = imlib_create_image (e.window.w16, e.window.h16); imlib_context_set_image (e.prev_img); + + /* init image data */ + data = imlib_image_get_data (); + memset (data, 0, e.window.w16 * e.window.h16 * 4); + imlib_image_put_back_data (data); + + tmp = IMG_FROM_RECT (e.damage); + imlib_blend_image_onto_image (tmp, true, 0, 0, + e.window.w, e.window.h, + e.window.offset_x, e.window.offset_y, + e.window.w, e.window.h); printf ("Starting recording...\n"); ecore_main_loop_begin (); =================================================================== RCS file: /cvs/e/misc/enthrall/src/rgb2yuv420.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- rgb2yuv420.c 21 Oct 2006 15:32:13 -0000 1.2 +++ rgb2yuv420.c 22 Oct 2006 19:12:21 -0000 1.3 @@ -36,8 +36,7 @@ */ void rgb2yuv420 (uint32_t *data_rgb, int width, int height, - uint8_t *data_y, uint8_t *data_u, uint8_t *data_v, - int y_stride, int uv_stride) + uint8_t *data_y, uint8_t *data_u, uint8_t *data_v) { int x, y, row_stride = width * 4; uint8_t *rgb, *Y = data_y, *U = data_u, *V = data_v; @@ -57,8 +56,6 @@ int32_t GtoVCoeff = (int32_t) (-94.154 * 256 + 0.5); int32_t BtoVCoeff = (int32_t) (-18.285 * 256 + 0.5); - int y_edge = y_stride - width, uv_edge = uv_stride - (width / 2); - /* Y plane */ rgb = (uint8_t *) data_rgb; @@ -72,8 +69,6 @@ Y++; rgb += 4; } - - Y += y_edge; } /* U and V planes */ @@ -122,7 +117,5 @@ } rgb += row_stride; - U += uv_edge; - V += uv_edge; } } =================================================================== RCS file: /cvs/e/misc/enthrall/src/rgb2yuv420.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- rgb2yuv420.h 21 Oct 2006 15:32:13 -0000 1.2 +++ rgb2yuv420.h 22 Oct 2006 19:12:21 -0000 1.3 @@ -25,7 +25,6 @@ #define __RGB2YUV420_H void rgb2yuv420 (uint32_t *data_rgb, int width, int height, - uint8_t *data_y, uint8_t *data_u, uint8_t *data_v, - int y_stride, int uv_stride); + uint8_t *data_y, uint8_t *data_u, uint8_t *data_v); #endif =================================================================== RCS file: /cvs/e/misc/enthrall/src/theora.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- theora.c 20 Oct 2006 20:50:22 -0000 1.1 +++ theora.c 22 Oct 2006 19:12:21 -0000 1.2 @@ -70,7 +70,8 @@ bool enthrall_theora_init (EnthrallTheora *et, const char *filename, - int quality, int width, int height, + int quality, int *width, int *height, + int *offset_x, int *offset_y, uint8_t **y, uint8_t **u, uint8_t **v) { ogg_stream_state vo; @@ -78,7 +79,7 @@ ogg_packet op; /* one raw packet of data for decode */ theora_info ti; theora_comment tc; - int serial1, serial2, offs; + int serial1, serial2; et->file = fopen (filename, "wb"); if (!et->file) @@ -100,22 +101,22 @@ /* Set up Theora encoder */ theora_info_init (&ti); - ti.frame_width = width; - ti.frame_height = height; + ti.frame_width = *width; + ti.frame_height = *height; /* Theora has a divisible-by-sixteen restriction for the encoded * video size. * scale the frame size up to the nearest /16 and calculate offsets. */ - ti.width = (width + 15) & ~15; - ti.height = (height + 15) & ~15; + ti.width = *width = (ti.frame_width + 15) & ~15; + ti.height = *height = (ti.frame_height + 15) & ~15; /* We force the offset to be even. * This ensures that the chroma samples align properly with * the luma samples. */ - ti.offset_x = ((ti.width - width) / 2) & ~1; - ti.offset_y = ((ti.height - height) / 2) & ~1; + ti.offset_x = *offset_x = ((ti.width - ti.frame_width) / 2) & ~1; + ti.offset_y = *offset_y = ((ti.height - ti.frame_height) / 2) & ~1; /* 25 fps */ ti.fps_numerator = 25; @@ -147,11 +148,6 @@ et->yuv.u = *u = malloc (ti.width * ti.height / 4); et->yuv.v = *v = malloc (ti.width * ti.height / 4); - /* black border */ - memset (et->yuv.y, 16, ti.width * ti.height); - memset (et->yuv.u, 128, ti.width * ti.height / 4); - memset (et->yuv.v, 128, ti.width * ti.height / 4); - et->yuv.y_width = ti.width; et->yuv.y_height = ti.height; et->yuv.y_stride = et->yuv.y_width; @@ -159,13 +155,6 @@ et->yuv.uv_width = ti.width / 2; et->yuv.uv_height = ti.height / 2; et->yuv.uv_stride = et->yuv.uv_width; - - offs = ti.offset_x + (et->yuv.y_stride * ti.offset_y); - *y += offs; - - offs = (ti.offset_x / 2) + (et->yuv.uv_stride * (ti.offset_y / 2)); - *u += offs; - *v += offs; theora_info_clear (&ti); =================================================================== RCS file: /cvs/e/misc/enthrall/src/theora.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- theora.h 20 Oct 2006 20:50:22 -0000 1.1 +++ theora.h 22 Oct 2006 19:12:21 -0000 1.2 @@ -26,7 +26,8 @@ } EnthrallTheora; bool enthrall_theora_init (EnthrallTheora *et, const char *filename, - int quality, int width, int height, + int quality, int *width, int *height, + int *offset_x, int *offset_y, uint8_t **y, uint8_t **u, uint8_t **v); void enthrall_theora_encode_frame (EnthrallTheora *et, bool final_frame); ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs