GraphicsMagick: coders/jpeg.c: Optionally enable arithmetic code...
GraphicsMagick Commits <[email protected]>
| Newsgroups | gmane.comp.video.graphicsmagick.cvs |
|---|---|
| Message-ID | <mailman.291.1651299607.1633.graphicsmagick-commit@lists.sourceforge.net> |
changeset f8516a12cf46 in /hg/GraphicsMagick details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=f8516a12cf46 summary: coders/jpeg.c: Optionally enable arithmetic coder in JPG images. diffstat: ChangeLog | 7 ++++++- coders/jpeg.c | 44 ++++++++++++++++++++++++++++++-------------- 2 files changed, 36 insertions(+), 15 deletions(-) diffs (83 lines): diff -r e0f6acd5c623 -r f8516a12cf46 ChangeLog --- a/ChangeLog Wed Apr 27 18:51:37 2022 -0500 +++ b/ChangeLog Sat Apr 30 08:19:29 2022 +0200 @@ -1,6 +1,11 @@ +2022-04-30 Fojtik Jaroslav <[email protected]> + + * coders/jpeg.c: Optionally enable arithmetic coder in JPG images. + gm convert -define jpeg:arithmetic=true testimg.jpg arith.jpg + 2022-04-27 Fojtik Jaroslav <[email protected]> - * jpeg/: Update aged JPG library. + * jpeg/: Update aged JPG library to version 9d. 2022-04-23 Bob Friesenhahn <[email protected]> diff -r e0f6acd5c623 -r f8516a12cf46 coders/jpeg.c --- a/coders/jpeg.c Wed Apr 27 18:51:37 2022 -0500 +++ b/coders/jpeg.c Sat Apr 30 08:19:29 2022 +0200 @@ -2792,33 +2792,49 @@ const char *value; - huffman_memory=0; - if ((value=AccessDefinition(image_info,"jpeg","optimize-coding"))) + huffman_memory = 0; + +#ifdef C_ARITH_CODING_SUPPORTED + /* + Allow the user to turn on/off arithmetic coder. + */ + if ((value=AccessDefinition(image_info,"jpeg","arithmetic"))) { if (LocaleCompare(value,"FALSE") == 0) - jpeg_info.optimize_coding=MagickFalse; + jpeg_info.arith_code = False; else - jpeg_info.optimize_coding=MagickTrue; + jpeg_info.arith_code = True; } - else - { + if(!jpeg_info.arith_code) /* jpeg_info.optimize_coding must not be set to enable arithmetic. */ +#endif + { + if ((value=AccessDefinition(image_info,"jpeg","optimize-coding"))) + { + if (LocaleCompare(value,"FALSE") == 0) + jpeg_info.optimize_coding=MagickFalse; + else + jpeg_info.optimize_coding=MagickTrue; + } + else + { /* Huffman optimization requires that the whole image be buffered in memory. Since this is such a large consumer, obtain a memory resource for the memory to be consumed. If the memory resource fails to be acquired, then don't enable huffman optimization. */ - huffman_memory=(magick_int64_t) jpeg_info.input_components* - image->columns*image->rows*sizeof(JSAMPLE); - jpeg_info.optimize_coding=AcquireMagickResource(MemoryResource, + huffman_memory=(magick_int64_t) jpeg_info.input_components* + image->columns*image->rows*sizeof(JSAMPLE); + jpeg_info.optimize_coding=AcquireMagickResource(MemoryResource, huffman_memory); - } - if (!jpeg_info.optimize_coding) - huffman_memory=0; - if (image->logging) - (void) LogMagickEvent(CoderEvent,GetMagickModule(), + } + if (!jpeg_info.optimize_coding) + huffman_memory=0; + if (image->logging) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), "Huffman optimization is %s", (jpeg_info.optimize_coding ? "enabled" : "disabled")); + } } #if (JPEG_LIB_VERSION >= 61) && defined(C_PROGRESSIVE_SUPPORTED)