Enlightenment CVS committal Author : tilman Project : misc Module : enthrall
Dir : misc/enthrall/src Modified Files: enthrall.c theora.c theora.h Log Message: Refactored the enthrall/theora interface. Patch by Vincent. =================================================================== RCS file: /cvs/e/misc/enthrall/src/enthrall.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -3 -r1.14 -r1.15 --- enthrall.c 15 Feb 2007 04:24:43 -0000 1.14 +++ enthrall.c 27 May 2007 18:26:30 -0000 1.15 @@ -36,7 +36,6 @@ #include <getopt.h> #include "theora.h" -#include "rgb2yuv420.h" #define VERSION "0.0.2" @@ -53,7 +52,7 @@ struct { Ecore_X_Window id; - int w, h, w16, h16; + int w, h; int offset_x, offset_y; } window; @@ -70,7 +69,6 @@ EnthrallTheora theora; - uint8_t *y, *u, *v; int (*render)(Enthrall *e); }; @@ -154,7 +152,6 @@ Bool b; int result; uint32_t *data; - bool final_frame; int ptr_x = 0, ptr_y = 0, unused1; unsigned int unused2; Window dw, childw = None; @@ -164,13 +161,13 @@ * valid window. not sure whether this really should be * done every time we enter this function. */ - final_frame = false; result = e->render(e); if (result < 0) { - final_frame = true; fprintf(stderr, "Failed to render frame... exiting.\n"); - goto out; + + enthrall_theora_encode_frame (&e->theora, NULL); + exit (result); } /* if we have a cursor, find out where it's at */ @@ -187,20 +184,9 @@ } data = imlib_image_get_data_for_reading_only (); - rgb2yuv420 (data, e->window.w16, e->window.h16, e->y, e->u, e->v); + enthrall_theora_encode_frame (&e->theora, data); imlib_image_put_back_data (data); -out: - /* FIXME: - * According to this ticket - * https://trac.xiph.org/changeset/11119 - * it seems we can just put in an empty packet to repeat - * the last frame. - */ - enthrall_theora_encode_frame (&e->theora, final_frame); - if (result < 0) - exit(result); - return 1; /* keep going */ } @@ -289,6 +275,7 @@ Imlib_Image tmp; char pointer_img[PATH_MAX], output_file[PATH_MAX] = {0}; uint32_t *data; + int w16, h16; double start; bool s; int fps = 25, quality = 90; @@ -380,13 +367,12 @@ init_imlib (&e); - e.window.w16 = e.window.w; - e.window.h16 = e.window.h; + w16 = e.window.w; + h16 = e.window.h; s = enthrall_theora_init (&e.theora, output_file, - quality, &e.window.w16, &e.window.h16, - &e.window.offset_x, &e.window.offset_y, - &e.y, &e.u, &e.v); + quality, &w16, &h16, + &e.window.offset_x, &e.window.offset_y); if (!s) { fprintf (stderr, "Error: Cannot initialize theora encoder.\n"); @@ -403,12 +389,12 @@ e.damage.height = e.window.h; e.damage_valid = true; - e.prev_img = imlib_create_image (e.window.w16, e.window.h16); + e.prev_img = imlib_create_image (w16, 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); + memset (data, 0, w16 * h16 * 4); imlib_image_put_back_data (data); tmp = IMG_FROM_RECT (e.damage); @@ -420,7 +406,7 @@ printf ("Starting recording...\n"); ecore_main_loop_begin (); - enthrall_theora_encode_frame (&e.theora, true); + enthrall_theora_encode_frame (&e.theora, NULL); enthrall_theora_finish (&e.theora); ecore_x_shutdown (); =================================================================== RCS file: /cvs/e/misc/enthrall/src/theora.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- theora.c 22 Oct 2006 19:12:21 -0000 1.2 +++ theora.c 27 May 2007 18:26:30 -0000 1.3 @@ -44,19 +44,30 @@ #include <assert.h> #include "theora.h" +#include "rgb2yuv420.h" void -enthrall_theora_encode_frame (EnthrallTheora *et, - bool final_frame) +enthrall_theora_encode_frame (EnthrallTheora *et, uint32_t *data) { ogg_page page; ogg_packet op; + /* If data is NULL, we assume that it's the last frame. + * + * FIXME: + * According to this ticket + * https://trac.xiph.org/changeset/11119 + * it seems we can just put in an empty packet to repeat + * the last frame. + */ + if (data) + rgb2yuv420 (data, et->yuv.y_width, et->yuv.y_height, et->yuv.y, et->yuv.u, et->yuv.v); + /* Theora is a one-frame-in, one-frame-out system; * submit a frame for compression and pull out the packet. */ theora_encode_YUVin (&et->td, &et->yuv); - theora_encode_packetout (&et->td, final_frame, &op); + theora_encode_packetout (&et->td, data == NULL, &op); ogg_stream_packetin (&et->to, &op); @@ -71,8 +82,7 @@ bool enthrall_theora_init (EnthrallTheora *et, const char *filename, int quality, int *width, int *height, - int *offset_x, int *offset_y, - uint8_t **y, uint8_t **u, uint8_t **v) + int *offset_x, int *offset_y) { ogg_stream_state vo; ogg_page og; /* one Ogg bitstream page. Vorbis packets are inside */ @@ -144,9 +154,9 @@ if (theora_encode_init (&et->td, &ti)) return false; - et->yuv.y = *y = malloc (ti.width * ti.height); - et->yuv.u = *u = malloc (ti.width * ti.height / 4); - et->yuv.v = *v = malloc (ti.width * ti.height / 4); + et->yuv.y = malloc (ti.width * ti.height); + et->yuv.u = malloc (ti.width * ti.height / 4); + et->yuv.v = malloc (ti.width * ti.height / 4); et->yuv.y_width = ti.width; et->yuv.y_height = ti.height; =================================================================== RCS file: /cvs/e/misc/enthrall/src/theora.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- theora.h 22 Oct 2006 19:12:21 -0000 1.2 +++ theora.h 27 May 2007 18:26:30 -0000 1.3 @@ -27,8 +27,7 @@ bool enthrall_theora_init (EnthrallTheora *et, const char *filename, int quality, int *width, int *height, - int *offset_x, int *offset_y, - uint8_t **y, uint8_t **u, uint8_t **v); + int *offset_x, int *offset_y); -void enthrall_theora_encode_frame (EnthrallTheora *et, bool final_frame); +void enthrall_theora_encode_frame (EnthrallTheora *et, uint32_t *data); void enthrall_theora_finish (EnthrallTheora *et); ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs