--- jpeg/jpeg.c 2013-04-09 15:10:34.000000000 -0400 +++ jpeg/jpeg.c 2014-06-09 13:53:53.000000000 -0400 @@ -56,5 +56,9 @@ #endif #include "tkimg.h" -#include "jpegtcl.h" +#ifdef EXTERN +# undef EXTERN +#endif +#include +#include static int SetupJPegLibrary(Tcl_Interp *interp); @@ -137,86 +141,11 @@ - static int SetupJPegLibrary (interp) Tcl_Interp *interp; { - struct jpeg_compress_struct *cinfo; /* libjpeg's parameter structure */ - struct my_error_mgr jerror; /* for controlling libjpeg error handling */ - int i; - - if (Jpegtcl_InitStubs(interp, JPEGTCL_VERSION, 0) == NULL) { - return TCL_ERROR; - } - - /* The followin code tries to determine if the JPEG library is - valid at all. The library might be configured differently, - which will produce core dumps. Also it might be that - fields appear in different places in jpeg_compress_struct - or jpeg_decompress_struct. This will make the library totally - unusable. In stead of a core-dump, we better have a proper - error message */ - - /* overallocat size, so we don't get a core-dump if the library - thinks that the structure is much larger */ - - cinfo = (struct jpeg_compress_struct *) ckalloc(8*sizeof(struct jpeg_compress_struct)); - cinfo->err = jpeg_std_error(&jerror.pub); - jerror.pub.error_exit = my_error_exit; - jerror.pub.output_message = my_output_message; - /* Establish the setjmp return context for my_error_exit to use. */ - if (setjmp(jerror.setjmp_buffer)) { - /* If we get here, the JPEG library is invalid. */ - jpeg_destroy_compress(cinfo); - ckfree((char *)cinfo); - - if (interp) { - Tcl_AppendResult(interp, "couldn't use \"", "jpegtcl", - "\": please upgrade to at least version 6a", (char *) NULL); - } - return TCL_ERROR; - } - - /* Now we can initialize libjpeg. */ - ((char *) cinfo)[sizeof(struct jpeg_compress_struct)] = 53; - jpeg_create_compress(cinfo); - if (((char *) cinfo)[sizeof(struct jpeg_compress_struct)] != 53) { - /* Oops. The library changed this value, which is outside the - * structure. Definitely, the library is invalid!!!! */ - ERREXIT(cinfo, JMSG_NOMESSAGE); - } - - /* Set up JPEG compression parameters. */ - cinfo->image_width = 16; - cinfo->image_height = 16; - cinfo->input_components = 3; - cinfo->in_color_space = JCS_RGB; - cinfo->data_precision = -1; - cinfo->optimize_coding = TRUE; - cinfo->dct_method = -1; - cinfo->X_density = 0; - cinfo->Y_density = 0; - jpeg_set_defaults(cinfo); - - if ((cinfo->data_precision != BITS_IN_JSAMPLE) || - (cinfo->optimize_coding != FALSE) || - (cinfo->dct_method != JDCT_DEFAULT) || - (cinfo->X_density != 1) || - (cinfo->Y_density != 1)) { - ERREXIT(cinfo, JMSG_NOMESSAGE); - } - for (i = 0; i < NUM_ARITH_TBLS; i++) { - if ((cinfo->arith_dc_L[i] != 0) || - (cinfo->arith_dc_U[i] != 1) || - (cinfo->arith_ac_K[i] != 5)) { - ERREXIT(cinfo, JMSG_NOMESSAGE); - } - } - jpeg_destroy_compress(cinfo); - ckfree((char *) cinfo); return TCL_OK; } - /* *----------------------------------------------------------------------