diff --git a/src/modules/_Image_JPEG/acconfig.h b/src/modules/_Image_JPEG/acconfig.h index 8c661da16a931c038b694a1f790de271b69888ba..564bc0ea6a21991620419acbc0861cd8a4b7497b 100644 --- a/src/modules/_Image_JPEG/acconfig.h +++ b/src/modules/_Image_JPEG/acconfig.h @@ -1,5 +1,5 @@ /* - * $Id: acconfig.h,v 1.4 2002/10/07 10:40:54 kiwi Exp $ + * $Id: acconfig.h,v 1.5 2002/10/08 17:11:15 norrby Exp $ */ #ifndef GMP_MACHINE_H @@ -15,8 +15,7 @@ /* Define this if you have -ljpeg */ #undef HAVE_LIBJPEG -/* Define this if you have height_in_blocks member in struct - * jpeg_component_info */ -#undef HAVE_JPEG_HEIGHT_IN_BLOCKS +/* Define this if you don't have image transformation capabilities in jpeglib*/ +#undef TRANSFORMS_NOT_SUPPORTED #endif diff --git a/src/modules/_Image_JPEG/configure.in b/src/modules/_Image_JPEG/configure.in index c7bd427febd496484931e455b4995f7896750fe8..7d1831d4ad4713acd03842a2317da8f7a447dab6 100644 --- a/src/modules/_Image_JPEG/configure.in +++ b/src/modules/_Image_JPEG/configure.in @@ -1,5 +1,5 @@ # -# $Id: configure.in,v 1.16 2002/10/07 11:55:39 kiwi Exp $ +# $Id: configure.in,v 1.17 2002/10/08 17:11:15 norrby Exp $ # AC_INIT(image_jpeg.c) AC_CONFIG_HEADER(config.h) @@ -35,7 +35,7 @@ int main(int argc, char **argv) else AC_MSG_RESULT(no) fi - AC_CHECK_FUNCS(jcopy_sample_rows jcopy_block_row jzero_far) + AC_CHECK_FUNCS(jcopy_sample_rows jcopy_block_row jzero_far jdiv_round_up jround_up) ]) AC_MSG_CHECKING([if jpeg_componment_info has the member height_in_blocks]) AC_CACHE_VAL(pike_cv_jpeg_height_in_blocks, [ @@ -56,8 +56,38 @@ int main(int argc, char **argv) ]) ]) AC_MSG_RESULT($pike_cv_jpeg_height_in_blocks) - if test "x$pike_cv_jpeg_height_in_blocks" = "xyes"; then - AC_DEFINE(HAVE_JPEG_HEIGHT_IN_BLOCKS) + if test "x$pike_cv_jpeg_height_in_blocks" = "xno"; then + AC_DEFINE(TRANSFORMS_NOT_SUPPORTED) + else :; fi + AC_MSG_CHECKING([if jpeg_decompress_struct has the member marker_list]) + AC_CACHE_VAL(pike_cv_marker_list, [ + AC_TRY_COMPILE([ +#define FILE void +#define size_t unsigned int +#include <jpeglib.h> +#include <jconfig.h> + ],[ +#define FILE void +#define size_t unsigned int +#include <jpeglib.h> +#include <jconfig.h> + +j_decompress_ptr srcinfo; +void *test_ptr; + +int main() { + test_ptr=(void*)srcinfo->marker_list; + return 0; +} + ],[ + pike_cv_marker_list=yes + ],[ + pike_cv_marker_list=no + ]) + ]) + AC_MSG_RESULT($pike_cv_marker_list) + if test "x$pike_cv_marker_list" = "xno"; then + AC_DEFINE(TRANSFORMS_NOT_SUPPORTED) else :; fi fi fi diff --git a/src/modules/_Image_JPEG/image_jpeg.c b/src/modules/_Image_JPEG/image_jpeg.c index 83e9a96b005a82a0efcb9564a553cdd21214ee50..2b8ee240b10d1c9e9ca1ec69380862c309cc854e 100644 --- a/src/modules/_Image_JPEG/image_jpeg.c +++ b/src/modules/_Image_JPEG/image_jpeg.c @@ -1,5 +1,5 @@ /* - * $Id: image_jpeg.c,v 1.54 2002/10/07 21:18:17 norrby Exp $ + * $Id: image_jpeg.c,v 1.55 2002/10/08 17:11:15 norrby Exp $ */ #include "global.h" @@ -39,7 +39,7 @@ #ifdef HAVE_STDLIB_H #undef HAVE_STDLIB_H #endif -RCSID("$Id: image_jpeg.c,v 1.54 2002/10/07 21:18:17 norrby Exp $"); +RCSID("$Id: image_jpeg.c,v 1.55 2002/10/08 17:11:15 norrby Exp $"); /* jpeglib defines EXTERN for some reason. * This is not good, since it confuses compilation.h. @@ -590,6 +590,7 @@ static void init_src(struct pike_string *raw_img, jpeg_read_header(&mds->cinfo,TRUE); } +#ifdef TRANSFORMS_SUPPORTED void set_jpeg_transform_options(INT32 args, jpeg_transform_info *options) { int transform = 0; @@ -610,6 +611,7 @@ void set_jpeg_transform_options(INT32 args, jpeg_transform_info *options) options->force_grayscale = FALSE; options->crop = FALSE; } +#endif /*TRANSFORMS_SUPPORTED*/ /*! @decl string encode(object image) *! @decl string encode(string|object image, mapping options) @@ -746,8 +748,13 @@ static void image_jpeg_encode(INT32 args) cinfo.optimize_coding=(img->xsize*img->ysize)<50000; } else { /* "Compression" from JPEG block */ - jvirt_barray_ptr *src_coef_arrays, *dst_coef_arrays; +#ifdef TRANSFORMS_SUPPORTED jpeg_transform_info transformoption; + jvirt_barray_ptr *src_coef_arrays, *dst_coef_arrays; +#else + Pike_error("Image.JPEG.encode: Raw JPEG data transformation not allowed" + " when Pike is compiled with this version of libjpeg.\n"); +#endif /*TRANSFORMS_SUPPORTED*/ jpeg_std_error(&errmgr); @@ -767,6 +774,7 @@ static void image_jpeg_encode(INT32 args) init_src(sp[-args].u.string, &errmgr, &srcmgr, &mds); +#ifdef TRANSFORMS_SUPPORTED set_jpeg_transform_options(args, &transformoption); jtransform_request_workspace(&mds.cinfo, &transformoption); src_coef_arrays = jpeg_read_coefficients(&mds.cinfo); @@ -777,16 +785,18 @@ static void image_jpeg_encode(INT32 args) src_coef_arrays, &transformoption); jpeg_write_coefficients(&cinfo, dst_coef_arrays); +#endif /*TRANSFORMS_SUPPORTED*/ + my_copy_jpeg_markers(args, &mds, &cinfo); /*jcopy_markers_execute(&mds.cinfo, &cinfo, JCOPYOPT_ALL);*/ +#ifdef TRANSFORMS_SUPPORTED jtransform_execute_transformation(&mds.cinfo, &cinfo, src_coef_arrays, &transformoption); - +#endif /*TRANSFORMS_SUPPORTED*/ } /* check configuration */ - if (args>1) { INT32 p,q=95; @@ -1515,6 +1525,7 @@ void pike_module_init(void) add_integer_constant("DEFAULT", JDCT_DEFAULT, 0); add_integer_constant("ISLOW", JDCT_ISLOW, 0); add_integer_constant("FASTEST", JDCT_FASTEST, 0); +#ifdef TRANSFORMS_SUPPORTED add_integer_constant("FLIP_H", JXFORM_FLIP_H, 0); add_integer_constant("FLIP_V", JXFORM_FLIP_V, 0); add_integer_constant("NONE", JXFORM_NONE, 0); @@ -1523,7 +1534,7 @@ void pike_module_init(void) add_integer_constant("ROT_270", JXFORM_ROT_270, 0); add_integer_constant("TRANSPOSE", JXFORM_TRANSPOSE, 0); add_integer_constant("TRANSVERSE", JXFORM_TRANSVERSE, 0); - +#endif /*TRANSFORMS_SUPPORTED*/ ADD_FUNCTION("quant_tables",image_jpeg_quant_tables, tFunc(tOr(tVoid,tInt),tMap(tInt,tArr(tArr(tInt)))),0); diff --git a/src/modules/_Image_JPEG/transupp.c b/src/modules/_Image_JPEG/transupp.c index 81cdd7d99a535d6354cd59ccfc3094cdef65976a..b1ff4dec46897bea09cd16116efd90db1837704e 100644 --- a/src/modules/_Image_JPEG/transupp.c +++ b/src/modules/_Image_JPEG/transupp.c @@ -1,5 +1,5 @@ /* - * $Id: transupp.c,v 1.6 2002/10/06 12:21:36 grubba Exp $ + * $Id: transupp.c,v 1.7 2002/10/08 17:11:16 norrby Exp $ */ #include "global.h" @@ -53,11 +53,15 @@ #include "transupp.h" /* My own external interface */ #include <ctype.h> /* to declare isdigit() */ +#ifdef TRANSFORMS_NOT_SUPPORTED +#undef TRANSFORMS_SUPPORTED +#endif +#if TRANSFORMS_SUPPORTED + #ifndef HAVE_JERR_BAD_CROP_SPEC #define JERR_BAD_CROP_SPEC JERR_BAD_LENGTH #endif /* !HAVE_JERR_BAD_CROP_SPEC */ -#if TRANSFORMS_SUPPORTED /* implementation ripped from jutils.c */ @@ -156,6 +160,31 @@ jzero_far (void FAR * target, size_t bytestozero) #endif /* HAVE_JZERO_FAR */ +GLOBAL(long) +jdiv_round_up (long a, long b) +#ifdef HAVE_JDIV_ROUND_UP + ; +#else +/* Compute a/b rounded up to next integer, ie, ceil(a/b) */ +/* Assumes a >= 0, b > 0 */ +{ + return (a + b - 1L) / b; +} +#endif + + +GLOBAL(long) +jround_up (long a, long b) +#ifdef HAVE_JROUND_UP + ; +#else +/* Compute a rounded up to next multiple of b, ie, ceil(a/b)*b */ +/* Assumes a >= 0, b > 0 */ +{ + a += b - 1L; + return a - (a % b); +} +#endif /* * Lossless image transformation routines. These routines work on DCT * coefficient arrays and thus do not require any lossy decompression diff --git a/src/modules/_Image_JPEG/transupp.h b/src/modules/_Image_JPEG/transupp.h index 4bda92a03a881382bf71799e986f0b5e34ee6f38..4a39d791b58a4c6dcdd25559538c6a4aed3c2b5d 100644 --- a/src/modules/_Image_JPEG/transupp.h +++ b/src/modules/_Image_JPEG/transupp.h @@ -18,7 +18,7 @@ */ /* If you happen not to want the image transform support, disable it here */ -#ifdef HAVE_JPEG_HEIGHT_IN_BLOCKS +#ifndef TRANSFORMS_NOT_SUPPORTED #ifndef TRANSFORMS_SUPPORTED #define TRANSFORMS_SUPPORTED 1 /* 0 disables transform code */ #endif