• R/O
  • SSH

GM: Commit

Main GraphicsMagick source repository


Commit MetaInfo

Revisióne84d14172c099c80e3efc7c7408866272b60d85a (tree)
Tiempo2022-01-22 07:06:25
AutorBob Friesenhahn <bfriesen@Grap...>
CommiterBob Friesenhahn

Log Message

JP2: Adaptations to work with Jasper 3.0.0's jas_init_library() and other related functions.

Cambiar Resumen

Diferencia incremental

diff -r a45a3d5e77ae -r e84d14172c09 ChangeLog
--- a/ChangeLog Sun Jan 16 14:46:19 2022 -0600
+++ b/ChangeLog Fri Jan 21 16:06:25 2022 -0600
@@ -1,3 +1,8 @@
1+2022-01-21 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
2+
3+ * coders/jp2.c: Adaptations to work with Jasper 3.0.0's
4+ jas_init_library() and other related functions.
5+
16 2022-01-16 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
27
38 * coders/miff.c (ReadMIFFImage): Do not proceed to next image in
diff -r a45a3d5e77ae -r e84d14172c09 VisualMagick/installer/inc/version.isx
--- a/VisualMagick/installer/inc/version.isx Sun Jan 16 14:46:19 2022 -0600
+++ b/VisualMagick/installer/inc/version.isx Fri Jan 21 16:06:25 2022 -0600
@@ -10,5 +10,5 @@
1010
1111 #define public MagickPackageName "GraphicsMagick"
1212 #define public MagickPackageVersion "1.4"
13-#define public MagickPackageVersionAddendum ".020220116"
14-#define public MagickPackageReleaseDate "snapshot-20220116"
13+#define public MagickPackageVersionAddendum ".020220121"
14+#define public MagickPackageReleaseDate "snapshot-20220121"
diff -r a45a3d5e77ae -r e84d14172c09 coders/jp2.c
--- a/coders/jp2.c Sun Jan 16 14:46:19 2022 -0600
+++ b/coders/jp2.c Fri Jan 21 16:06:25 2022 -0600
@@ -1,5 +1,5 @@
11 /*
2-% Copyright (C) 2003-2021 GraphicsMagick Group
2+% Copyright (C) 2003-2022 GraphicsMagick Group
33 % Copyright (C) 2002 ImageMagick Studio
44 %
55 % This program is covered by multiple licenses, which are described in
@@ -92,11 +92,21 @@
9292 # undef HAVE_PGX_DECODE
9393 # endif
9494
95+#if defined(HAVE_JAS_INIT_LIBRARY)
96+# define HAVE_JAS_STREAM_IO_V3
97+#endif
98+
9599 #if 0
96-/* Development JasPer 3.0.0 jas_initialize() is not yet ready for our purposes */
97-#if !(defined(MAGICK_ENABLE_JAS_INITIALIZE) && MAGICK_ENABLE_JAS_INITIALIZE)
98-#undef HAVE_JAS_INITIALIZE
99-#endif /* if !defined(ENABLE_JAS_INITIALIZE) */
100+/* Development JasPer 3.0.0 jas_init_library() is not yet ready for our purposes */
101+#if !(defined(MAGICK_ENABLE_JAS_INIT_LIBRARY) && MAGICK_ENABLE_JAS_INIT_LIBRARY)
102+#undef HAVE_JAS_INIT_LIBRARY
103+#endif /* if !(defined(MAGICK_ENABLE_JAS_INIT_LIBRARY) && MAGICK_ENABLE_JAS_INIT_LIBRARY) */
104+#endif
105+
106+#if defined(HAVE_PTHREAD) || defined(MSWINDOWS) || defined(HAVE_OPENMP)
107+# define JP2_HAVE_THREADS 1
108+#else
109+# define JP2_HAVE_THREADS 0
100110 #endif
101111
102112
@@ -321,57 +331,66 @@
321331 int (*read_)(jas_stream_obj_t *obj, char *buf, unsigned cnt);
322332 int (*write_)(jas_stream_obj_t *obj, const char *buf, unsigned cnt);
323333
334+ In Jasper 3.0.0 the interface changed again:
335+ jas_ssize_t (*read_)(jas_stream_obj_t *obj, char *buf, size_t cnt);
336+ jas_ssize_t (*write_)(jas_stream_obj_t *obj, const char *buf, size_t cnt);
337+
324338 We have yet to find a useful way to determine the version of the
325339 JasPer library using the C pre-processor.
326340 */
327-#if !defined(MAGICK_JP2_OLD_STREAM_INTERFACE)
328-# define MAGICK_JP2_OLD_STREAM_INTERFACE 0
329-#endif /* if !defined(MAGICK_JP2_OLD_STREAM_INTERFACE) */
330341
331-#if MAGICK_JP2_OLD_STREAM_INTERFACE
332-static int BlobRead(jas_stream_obj_t *object,char *buffer,const int length)
342+/* Read characters from a file object. */
343+/* jas_ssize_t (*read_)(jas_stream_obj_t *obj, char *buf, size_t cnt); */
344+#if defined(HAVE_JAS_STREAM_IO_V3)
345+static jas_ssize_t BlobRead(jas_stream_obj_t *obj, char *buf, size_t cnt)
333346 #else
334-static int BlobRead(jas_stream_obj_t *object,char *buffer,unsigned length)
347+static int BlobRead(jas_stream_obj_t *obj, char *buf, unsigned cnt)
335348 #endif
336349 {
337350 size_t
338351 count;
339352
340353 StreamManager
341- *source = (StreamManager *) object;
354+ *source = (StreamManager *) obj;
342355
343- count=ReadBlob(source->image,(size_t) length,(void *) buffer);
344- return ((int) count);
356+ count=ReadBlob(source->image,(size_t) cnt,(void *) buf);
357+ return (count);
345358 }
346359
347-#if MAGICK_JP2_OLD_STREAM_INTERFACE
348-static int BlobWrite(jas_stream_obj_t *object,char *buffer,const int length)
360+/* Write characters to a file object. */
361+/* jas_ssize_t (*write_)(jas_stream_obj_t *obj, const char *buf, size_t cnt); */
362+#if defined(HAVE_JAS_STREAM_IO_V3)
363+static jas_ssize_t BlobWrite(jas_stream_obj_t *obj, const char *buf, size_t cnt)
349364 #else
350-static int BlobWrite(jas_stream_obj_t *object,const char *buffer,unsigned length)
365+static int BlobWrite(jas_stream_obj_t *obj, const char *buf, unsigned cnt)
351366 #endif
352367 {
353368 size_t
354369 count;
355370
356371 StreamManager
357- *source = (StreamManager *) object;
372+ *source = (StreamManager *) obj;
358373
359- count=WriteBlob(source->image,(size_t) length,(void *) buffer);
360- return((int) count);
374+ count=WriteBlob(source->image,(size_t) cnt,(void *) buf);
375+ return(count);
361376 }
362377
363-static long BlobSeek(jas_stream_obj_t *object,long offset,int origin)
378+/* Set the position for a file object. */
379+/* long (*seek_)(jas_stream_obj_t *obj, long offset, int origin); */
380+static long BlobSeek(jas_stream_obj_t *obj,long offset,int origin)
364381 {
365382 StreamManager
366- *source = (StreamManager *) object;
383+ *source = (StreamManager *) obj;
367384
368385 return (SeekBlob(source->image,offset,origin));
369386 }
370387
371-static int BlobClose(jas_stream_obj_t *object)
388+/* Close a file object. */
389+/* int (*close_)(jas_stream_obj_t *obj); */
390+static int BlobClose(jas_stream_obj_t *obj)
372391 {
373392 StreamManager
374- *source = (StreamManager *) object;
393+ *source = (StreamManager *) obj;
375394
376395 CloseBlob(source->image);
377396 jas_free(source);
@@ -395,6 +414,8 @@
395414 stream->obj_=(jas_stream_obj_t *) jas_malloc(sizeof(StreamManager));
396415 if (stream->obj_ == (jas_stream_obj_t *) NULL)
397416 {
417+ (void) LogMagickEvent(CoderEvent,GetMagickModule(),
418+ "jas_malloc() failed!");
398419 jas_free(stream);
399420 return((jas_stream_t *) NULL);
400421 }
@@ -410,24 +431,37 @@
410431 return(stream);
411432 }
412433
413-#define ThrowJP2ReaderException(code_,reason_,image_) \
414-{ \
415- for (component=0; component < (long) number_components; component++) \
416- MagickFreeResourceLimitedMemory(channel_lut[component]); \
417- if (pixels) \
418- jas_matrix_destroy(pixels); \
419- if (jp2_stream) \
420- (void) jas_stream_close(jp2_stream); \
421- if (jp2_image) \
422- jas_image_destroy(jp2_image); \
423- MagickFreeMemory(options); \
424- ThrowReaderException(code_,reason_,image_); \
425-}
434+#if defined(HAVE_JAS_INIT_LIBRARY)
435+# define JAS_CLEANUP_THREAD() jas_cleanup_thread()
436+#else
437+# define JAS_CLEANUP_THREAD()
438+#endif
439+
440+#define ThrowJP2ReaderException(code_,reason_,image_) \
441+ { \
442+ for (component=0; component < (long) number_components; component++) \
443+ MagickFreeResourceLimitedMemory(channel_lut[component]); \
444+ if (pixels) \
445+ jas_matrix_destroy(pixels); \
446+ if (jp2_stream) \
447+ (void) jas_stream_close(jp2_stream); \
448+ if (jp2_image) \
449+ jas_image_destroy(jp2_image); \
450+ MagickFreeMemory(options); \
451+ JAS_CLEANUP_THREAD(); \
452+ ThrowReaderException(code_,reason_,image_); \
453+ }
454+
455+#define ThrowJP2WriterException(code_,reason_,image_) \
456+ { \
457+ JAS_CLEANUP_THREAD(); \
458+ ThrowWriterException(code_,reason_,image_); \
459+ }
426460
427461 /*
428462 Initialize Jasper
429463 */
430-#if HAVE_JAS_INITIALIZE
464+#if HAVE_JAS_INIT_LIBRARY
431465 static void *alloc_rlm(struct jas_allocator_s *allocator, size_t size)
432466 {
433467 char *p;
@@ -452,18 +486,24 @@
452486 /* fprintf(stderr,"realloc_rlm(%p, %p, %zu) -> %p\n", allocator, pointer, new_size, p); */
453487 return p;
454488 }
455-#endif /* if HAVE_JAS_INITIALIZE */
456-static void initialize_jasper(void)
489+#endif /* if HAVE_JAS_INIT_LIBRARY */
490+static MagickPassFail initialize_jasper(ExceptionInfo *exception)
457491 {
492+ (void) exception;
458493 if (!jasper_initialized)
459494 {
460-#if HAVE_JAS_INITIALIZE
495+#if HAVE_JAS_INIT_LIBRARY
461496 {
462497 /* static jas_std_allocator_t allocator; */
463498 static jas_allocator_t allocator;
499+
464500 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
465501 "Initializing JasPer...");
502+ /*
503+ Configure the library using the default configuration settings.
504+ */
466505 jas_conf_clear();
506+
467507 /*
468508 Provide our own resource-limited memory allocation
469509 functions.
@@ -503,12 +543,23 @@
503543 /*
504544 Tell JasPer how much memory it could ever be allowed to use.
505545 */
506- jas_conf_set_max_mem((size_t) GetMagickResourceLimit(MemoryResource));
546+ jas_conf_set_max_mem_usage((size_t) GetMagickResourceLimit(MemoryResource));
507547
508- if (jas_initialize() == 0)
548+ /*
549+ Inform JasPer that app may be multi-threaded
550+ */
551+ jas_conf_set_multithread(JP2_HAVE_THREADS);
552+
553+ /* Perform global initialization for the JasPer library. */
554+ if (jas_init_library() == 0)
509555 {
510556 jasper_initialized=MagickTrue;
511557 }
558+ else
559+ {
560+ (void) LogMagickEvent(CoderEvent,GetMagickModule(),
561+ "jas_init_library() failed!");
562+ }
512563 }
513564 #else
514565 {
@@ -520,8 +571,13 @@
520571 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
521572 "Initialized JasPer");
522573 }
574+ else
575+ {
576+ (void) LogMagickEvent(CoderEvent,GetMagickModule(),
577+ "jas_init() failed!");
578+ }
523579 }
524-#endif /* HAVE_JAS_INITIALIZE */
580+#endif /* HAVE_JAS_INIT_LIBRARY */
525581
526582 if (!jasper_initialized)
527583 {
@@ -529,6 +585,8 @@
529585 "Failed to initialize JasPer!");
530586 }
531587 }
588+
589+ return jasper_initialized ? MagickPass : MagickFail;
532590 }
533591
534592
@@ -541,9 +599,12 @@
541599 {
542600 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
543601 "Destroying JasPer...");
544-#if HAVE_JAS_INITIALIZE
602+#if HAVE_JAS_INIT_LIBRARY
603+ /* Perform global cleanup for the JasPer library. */
604+ jas_cleanup_library();
605+#else
545606 jas_cleanup();
546-#endif /* if HAVE_JAS_INITIALIZE */
607+#endif /* if HAVE_JAS_INIT_LIBRARY */
547608 jasper_initialized=MagickFalse;
548609 }
549610 }
@@ -607,7 +668,23 @@
607668 /*
608669 Initialize Jasper
609670 */
610- initialize_jasper();
671+ if (initialize_jasper(exception) != MagickPass)
672+ {
673+ return (Image *) NULL;
674+ }
675+
676+#if HAVE_JAS_INIT_LIBRARY
677+ /*
678+ Perform any per-thread initialization for the JasPer library.
679+ */
680+ if (jas_init_thread())
681+ {
682+ /* Handle the initialization error. */
683+ (void) LogMagickEvent(CoderEvent,GetMagickModule(),
684+ "jas_init_thread() failed!");
685+ return (Image *) NULL;
686+ }
687+#endif /* if HAVE_JAS_INIT_LIBRARY */
611688
612689 /*
613690 Open image file.
@@ -1065,6 +1142,10 @@
10651142 MagickFreeMemory(options);
10661143 jas_image_destroy(jp2_image);
10671144 StopTimer(&image->timer);
1145+#if HAVE_JAS_INIT_LIBRARY
1146+ /* Perform any per-thread clean-up for the JasPer library. */
1147+ JAS_CLEANUP_THREAD();
1148+#endif /* if HAVE_JAS_INIT_LIBRARY */
10681149 return(image);
10691150 }
10701151 #endif /* if defined(HasJP2) */
@@ -1292,7 +1373,23 @@
12921373 /*
12931374 Initialize Jasper
12941375 */
1295- initialize_jasper();
1376+ if (initialize_jasper(&image->exception) != MagickPass)
1377+ {
1378+ return MagickFail;
1379+ }
1380+
1381+#if HAVE_JAS_INIT_LIBRARY
1382+ /*
1383+ Perform any per-thread initialization for the JasPer library.
1384+ */
1385+ if (jas_init_thread())
1386+ {
1387+ /* Handle the initialization error. */
1388+ (void) LogMagickEvent(CoderEvent,GetMagickModule(),
1389+ "jas_init_thread() failed!");
1390+ return MagickFail;
1391+ }
1392+#endif /* if HAVE_JAS_INIT_LIBRARY */
12961393
12971394 /*
12981395 Open image file.
@@ -1303,7 +1400,7 @@
13031400 assert(image->signature == MagickSignature);
13041401 status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
13051402 if (status == False)
1306- ThrowWriterException(FileOpenError,UnableToOpenFile,image);
1403+ ThrowJP2WriterException(FileOpenError,UnableToOpenFile,image);
13071404
13081405 /*
13091406 Ensure that image is in RGB space.
@@ -1379,7 +1476,7 @@
13791476 */
13801477 jp2_stream=JP2StreamManager(&StreamOperators, image);
13811478 if (jp2_stream == (jas_stream_t *) NULL)
1382- ThrowWriterException(DelegateError,UnableToManageJP2Stream,image);
1479+ ThrowJP2WriterException(DelegateError,UnableToManageJP2Stream,image);
13831480 number_components=image->matte ? 4 : 3;
13841481 if ((image_info->type != TrueColorType) &&
13851482 (characteristics.grayscale))
@@ -1387,7 +1484,7 @@
13871484
13881485 jp2_image=jas_image_create0();
13891486 if (jp2_image == (jas_image_t *) NULL)
1390- ThrowWriterException(DelegateError,UnableToCreateImage,image);
1487+ ThrowJP2WriterException(DelegateError,UnableToCreateImage,image);
13911488
13921489 for (component=0; component < number_components; component++)
13931490 {
@@ -1403,7 +1500,7 @@
14031500
14041501 if (jas_image_addcmpt(jp2_image, component,&component_info)) {
14051502 jas_image_destroy(jp2_image);
1406- ThrowWriterException(DelegateError,UnableToCreateImageComponent,image);
1503+ ThrowJP2WriterException(DelegateError,UnableToCreateImageComponent,image);
14071504 }
14081505 }
14091506
@@ -1422,7 +1519,7 @@
14221519 if (lut == (unsigned short *) NULL)
14231520 {
14241521 jas_image_destroy(jp2_image);
1425- ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,image);
1522+ ThrowJP2WriterException(ResourceLimitError,MemoryAllocationFailed,image);
14261523 }
14271524
14281525 max_value=MaxValueGivenBits(component_info.prec);
@@ -1483,7 +1580,7 @@
14831580 {
14841581 MagickFreeResourceLimitedMemory(lut);
14851582 jas_image_destroy(jp2_image);
1486- ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,image);
1583+ ThrowJP2WriterException(ResourceLimitError,MemoryAllocationFailed,image);
14871584 }
14881585
14891586 for (y=0; y < (long) image->rows; y++)
@@ -1590,7 +1687,12 @@
15901687 jas_matrix_destroy(jp2_pixels);
15911688 jas_image_destroy(jp2_image);
15921689 if (status)
1593- ThrowWriterException(DelegateError,UnableToEncodeImageFile,image);
1690+ ThrowJP2WriterException(DelegateError,UnableToEncodeImageFile,image);
1691+
1692+#if HAVE_JAS_INIT_LIBRARY
1693+ /* Perform any per-thread clean-up for the JasPer library. */
1694+ JAS_CLEANUP_THREAD();
1695+#endif /* if HAVE_JAS_INIT_LIBRARY */
15941696 return(True);
15951697 }
15961698 #endif /* if defined(HasJP2) */
diff -r a45a3d5e77ae -r e84d14172c09 configure
--- a/configure Sun Jan 16 14:46:19 2022 -0600
+++ b/configure Fri Jan 21 16:06:25 2022 -0600
@@ -26177,7 +26177,7 @@
2617726177 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
2617826178 $as_echo "yes" >&6; }
2617926179 have_jp2='yes'
26180- for ac_func in jas_initialize jp2_decode jpc_decode pgx_decode
26180+ for ac_func in jas_init_library jp2_decode jpc_decode pgx_decode
2618126181 do :
2618226182 as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
2618326183 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
diff -r a45a3d5e77ae -r e84d14172c09 configure.ac
--- a/configure.ac Sun Jan 16 14:46:19 2022 -0600
+++ b/configure.ac Fri Jan 21 16:06:25 2022 -0600
@@ -2254,7 +2254,7 @@
22542254 AC_DEFINE([HasJP2],[1],[Define if you have JPEG version 2 "Jasper" library])
22552255 AC_MSG_RESULT([yes])
22562256 have_jp2='yes'
2257- AC_CHECK_FUNCS([jas_initialize jp2_decode jpc_decode pgx_decode])
2257+ AC_CHECK_FUNCS([jas_init_library jp2_decode jpc_decode pgx_decode])
22582258 fi
22592259 else
22602260 AC_MSG_RESULT([no])
diff -r a45a3d5e77ae -r e84d14172c09 magick/magick_config.h.in
--- a/magick/magick_config.h.in Sun Jan 16 14:46:19 2022 -0600
+++ b/magick/magick_config.h.in Fri Jan 21 16:06:25 2022 -0600
@@ -146,8 +146,8 @@
146146 /* Define to 1 if you have the <inttypes.h> header file. */
147147 #undef HAVE_INTTYPES_H
148148
149-/* Define to 1 if you have the `jas_initialize' function. */
150-#undef HAVE_JAS_INITIALIZE
149+/* Define to 1 if you have the `jas_init_library' function. */
150+#undef HAVE_JAS_INIT_LIBRARY
151151
152152 /* Define to 1 if you have the `jp2_decode' function. */
153153 #undef HAVE_JP2_DECODE
diff -r a45a3d5e77ae -r e84d14172c09 magick/version.h
--- a/magick/version.h Sun Jan 16 14:46:19 2022 -0600
+++ b/magick/version.h Fri Jan 21 16:06:25 2022 -0600
@@ -38,8 +38,8 @@
3838 #define MagickLibVersion 0x262300
3939 #define MagickLibVersionText "1.4"
4040 #define MagickLibVersionNumber 26,23,0
41-#define MagickChangeDate "20220116"
42-#define MagickReleaseDate "snapshot-20220116"
41+#define MagickChangeDate "20220121"
42+#define MagickReleaseDate "snapshot-20220121"
4343
4444 /*
4545 The MagickLibInterfaceNewest and MagickLibInterfaceOldest defines
diff -r a45a3d5e77ae -r e84d14172c09 www/Changelog.html
--- a/www/Changelog.html Sun Jan 16 14:46:19 2022 -0600
+++ b/www/Changelog.html Fri Jan 21 16:06:25 2022 -0600
@@ -35,6 +35,10 @@
3535 <div class="document">
3636
3737
38+<p>2022-01-21 Bob Friesenhahn &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
39+<blockquote>
40+* coders/jp2.c: Adaptations to work with Jasper 3.0.0's
41+jas_init_library() and other related functions.</blockquote>
3842 <p>2022-01-16 Bob Friesenhahn &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
3943 <blockquote>
4044 <p>* coders/miff.c (ReadMIFFImage): Do not proceed to next image in
Show on old repository browser