From: Piotr S. <ps...@us...> - 2009-09-17 12:05:39
|
Update of /cvsroot/ayttm/ayttm/modules/image_filter In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv12682/modules/image_filter Modified Files: img2jpc.c video_capture.c Log Message: reformatted source code Index: img2jpc.c =================================================================== RCS file: /cvsroot/ayttm/ayttm/modules/image_filter/img2jpc.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- img2jpc.c 27 Jul 2009 16:42:03 -0000 1.9 +++ img2jpc.c 17 Sep 2009 12:04:58 -0000 1.10 @@ -13,21 +13,18 @@ #include <jasper/jasper.h> - /******************************************************************************* * Begin Module Code ******************************************************************************/ /* Module defines */ #ifndef USE_POSIX_DLOPEN - #define plugin_info img2jpc_LTX_plugin_info - #define module_version img2jpc_LTX_module_version +#define plugin_info img2jpc_LTX_plugin_info +#define module_version img2jpc_LTX_module_version #endif - static int plugin_init(); static int plugin_finish(); - /* Module Exports */ PLUGIN_INFO plugin_info = { PLUGIN_FILTER, @@ -41,17 +38,21 @@ NULL, NULL }; + /* End Module Exports */ -unsigned int module_version() {return CORE_VERSION;} +unsigned int module_version() +{ + return CORE_VERSION; +} -static unsigned char * img_2_jpg(const unsigned char *in_img, long *size); -static unsigned char * img_2_jpc(const unsigned char *in_img, long *size); +static unsigned char *img_2_jpg(const unsigned char *in_img, long *size); +static unsigned char *img_2_jpc(const unsigned char *in_img, long *size); -static unsigned char *(*old_img_2_jpg)(const unsigned char *, long *) = NULL; -static unsigned char *(*old_img_2_jpc)(const unsigned char *, long *) = NULL; +static unsigned char *(*old_img_2_jpg) (const unsigned char *, long *) = NULL; +static unsigned char *(*old_img_2_jpc) (const unsigned char *, long *) = NULL; -static int do_jpc_encoding=0; +static int do_jpc_encoding = 0; static int plugin_init() { @@ -62,10 +63,10 @@ plugin_info.prefs = il; il->widget.checkbox.value = &do_jpc_encoding; il->name = "do_jpc_encoding"; - il->label= _("Send JPEG2000 images (creates huge data transfers)"); + il->label = _("Send JPEG2000 images (creates huge data transfers)"); il->type = EB_INPUT_CHECKBOX; - if(!jas_init()) { + if (!jas_init()) { old_img_2_jpg = image_2_jpg; image_2_jpg = img_2_jpg; @@ -91,56 +92,58 @@ * End Module Code ******************************************************************************/ -static unsigned char * img_2_img(const unsigned char *in_img, long *size, int outfmt, const char *soutfmt, const char *enc_opts) +static unsigned char *img_2_img(const unsigned char *in_img, long *size, + int outfmt, const char *soutfmt, const char *enc_opts) { - unsigned char * out_img = NULL; + unsigned char *out_img = NULL; jas_stream_t *in, *out; jas_image_t *image; int infmt; /* - static int ctr; - char fn[100]; - FILE *fp; - snprintf(fn, sizeof(fn), "ayttm-img-%03d.jpc", ctr++); - fp = fopen(fn, "wb"); - if(fp) { - fwrite(in_img, 1, *size, fp); - fclose(fp); - } - */ - if(jas_init()) { + static int ctr; + char fn[100]; + FILE *fp; + snprintf(fn, sizeof(fn), "ayttm-img-%03d.jpc", ctr++); + fp = fopen(fn, "wb"); + if(fp) { + fwrite(in_img, 1, *size, fp); + fclose(fp); + } + */ + if (jas_init()) { eb_debug(DBG_MOD, "Could not init jasper\n"); return ay_memdup(in_img, *size); } - if(!(in = jas_stream_memopen((char *)in_img, *size))) { + if (!(in = jas_stream_memopen((char *)in_img, *size))) { eb_debug(DBG_MOD, "Could not open jasper input stream\n"); return ay_memdup(in_img, *size); } infmt = jas_image_getfmt(in); - eb_debug(DBG_MOD, "Got input image format: %d %s\n", infmt, jas_image_fmttostr(infmt)); - if(infmt <= 0) + eb_debug(DBG_MOD, "Got input image format: %d %s\n", infmt, + jas_image_fmttostr(infmt)); + if (infmt <= 0) return ay_memdup(in_img, *size); - if(!strcmp(jas_image_fmttostr(infmt), soutfmt)) { + if (!strcmp(jas_image_fmttostr(infmt), soutfmt)) { /* image is already in correct format */ jas_stream_close(in); return ay_memdup(in_img, *size); } - if(!(image = jas_image_decode(in, infmt, NULL))) { + if (!(image = jas_image_decode(in, infmt, NULL))) { eb_debug(DBG_MOD, "Could not decode image format\n"); return ay_memdup(in_img, *size); } - if(!(out = jas_stream_memopen((char *)out_img, 0))) { + if (!(out = jas_stream_memopen((char *)out_img, 0))) { eb_debug(DBG_MOD, "Could not open output stream\n"); return ay_memdup(in_img, *size); } eb_debug(DBG_MOD, "Encoding to format: %d %s\n", outfmt, soutfmt); - if((jas_image_encode(image, out, outfmt, (char *) enc_opts))) { + if ((jas_image_encode(image, out, outfmt, (char *)enc_opts))) { eb_debug(DBG_MOD, "Could not encode image format\n"); return ay_memdup(in_img, *size); } @@ -149,27 +152,27 @@ *size = ((jas_stream_memobj_t *)out->obj_)->bufsize_; eb_debug(DBG_MOD, "Encoded size is: %ld\n", *size); jas_stream_close(in); - out_img=ay_memdup(((jas_stream_memobj_t *)out->obj_)->buf_, *size); + out_img = ay_memdup(((jas_stream_memobj_t *)out->obj_)->buf_, *size); jas_stream_close(out); jas_image_destroy(image); return out_img; } -static unsigned char * img_2_jpg(const unsigned char *in_img, long *size) +static unsigned char *img_2_jpg(const unsigned char *in_img, long *size) { static int outfmt; - if(!outfmt) + if (!outfmt) outfmt = jas_image_strtofmt("jpg"); return img_2_img(in_img, size, outfmt, "jpg", NULL); } -static unsigned char * img_2_jpc(const unsigned char *in_img, long *size) +static unsigned char *img_2_jpc(const unsigned char *in_img, long *size) { static int outfmt; - if(!do_jpc_encoding) + if (!do_jpc_encoding) return ay_memdup(in_img, *size); - if(!outfmt) + if (!outfmt) outfmt = jas_image_strtofmt("jpc"); return img_2_img(in_img, size, outfmt, "jpc", "rate=0.0219\nmode=real"); } Index: video_capture.c =================================================================== RCS file: /cvsroot/ayttm/ayttm/modules/image_filter/video_capture.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- video_capture.c 27 Jul 2009 16:42:03 -0000 1.4 +++ video_capture.c 17 Sep 2009 12:04:58 -0000 1.5 @@ -35,15 +35,15 @@ ******************************************************************************/ /* Module defines */ #ifndef USE_POSIX_DLOPEN - #define plugin_info video_capture_LTX_plugin_info - #define module_version video_capture_LTX_module_version +#define plugin_info video_capture_LTX_plugin_info +#define module_version video_capture_LTX_module_version #endif - static int plugin_init(); static int plugin_finish(); -static char frame_grabber[MAX_PREF_LEN]= AYTTM_BIN_DIR "/ayttm_streamer_wrapper.sh -d %d"; +static char frame_grabber[MAX_PREF_LEN] = + AYTTM_BIN_DIR "/ayttm_streamer_wrapper.sh -d %d"; /* Module Exports */ PLUGIN_INFO plugin_info = { @@ -58,13 +58,17 @@ 0, 0 }; + /* End Module Exports */ -unsigned int module_version() {return CORE_VERSION;} +unsigned int module_version() +{ + return CORE_VERSION; +} static long int grab_frame(unsigned char **image); -static long int (*old_grab_frame)(unsigned char **); +static long int (*old_grab_frame) (unsigned char **); static int plugin_init() { @@ -73,7 +77,7 @@ plugin_info.prefs = il; il->widget.entry.value = frame_grabber; il->name = "frame_grabber"; - il->label= _("Frame grabber command:"); + il->label = _("Frame grabber command:"); il->type = EB_INPUT_ENTRY; old_grab_frame = video_grab_frame; @@ -97,32 +101,32 @@ { FILE *grabber_fp; unsigned char buff[1024]; - unsigned char *outbuf=0; - long int nsize=0, n; + unsigned char *outbuf = 0; + long int nsize = 0, n; char *cmd = strdup(frame_grabber); - while(strstr(cmd, "%d")) { + while (strstr(cmd, "%d")) { char *tmp = strstr(cmd, "%d"); - char *rest=0; - if(*(tmp+2)) - rest = strdup(tmp+2); + char *rest = 0; + if (*(tmp + 2)) + rest = strdup(tmp + 2); *tmp = 0; cmd = ay_string_append(cmd, eb_config_dir()); - if(rest) + if (rest) cmd = ay_string_append(cmd, rest); } grabber_fp = popen(cmd, "r"); ay_free(cmd); - if(!grabber_fp) + if (!grabber_fp) return -1; - while(! (feof(grabber_fp) || ferror(grabber_fp)) ) { + while (!(feof(grabber_fp) || ferror(grabber_fp))) { n = fread(buff, 1, sizeof(buff), grabber_fp); - outbuf = ay_renew(unsigned char, outbuf, n+nsize); - memcpy(outbuf+nsize, buff, n); - nsize+=n; + outbuf = ay_renew(unsigned char, outbuf, n + nsize); + memcpy(outbuf + nsize, buff, n); + nsize += n; } pclose(grabber_fp); @@ -130,4 +134,3 @@ *image = outbuf; return nsize; } - |