From 53774b8bf9262552cedd6221778b192e6fdb9cf9 Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Sat, 15 Sep 2018 16:09:33 +0200 Subject: [PATCH] Added support for arithmetic coding to the jpeg encoder. --- ChangeLog | 4 ++++ coders/jpeg.c | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/ChangeLog b/ChangeLog index 48bed6bd7..555be3efa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,10 @@ 2018-09-09 7.0.8-12 Cristy * Release ImageMagick version 7.0.8-12, GIT revision 14729:798fbdb5b:20180828 +2018-09-15 7.0.8-12 Dirk Lemstra + * Added support for arithmetic coding to the jpeg encoder: + -define jpeg:arithmetic-coding=true. + 2018-09-08 7.0.8-12 Cristy * Fixed numerous use of uninitialized values, integer overflow, memory exceeded, and timeouts (credit to OSS Fuzz). diff --git a/coders/jpeg.c b/coders/jpeg.c index c29982887..d046c6a46 100644 --- a/coders/jpeg.c +++ b/coders/jpeg.c @@ -1337,6 +1337,10 @@ static Image *ReadJPEGImage(const ImageInfo *image_info, (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double) jpeg_info.out_color_space); (void) SetImageProperty(image,"jpeg:colorspace",value,exception); +#if defined(D_ARITH_CODING_SUPPORTED) + if (jpeg_info.arith_code == TRUE) + (void) SetImageProperty(image,"jpeg:coding","arithmetic",exception); +#endif if (image_info->ping != MagickFalse) { jpeg_destroy_decompress(&jpeg_info); @@ -2371,6 +2375,14 @@ static MagickBooleanType WriteJPEGImage(const ImageInfo *image_info, jpeg_info.optimize_coding=status == MagickFalse ? FALSE : TRUE; } } +#if defined(C_ARITH_CODING_SUPPORTED) + option=GetImageOption(image_info,"jpeg:arithmetic-coding"); + if (option != (const char *) NULL) + { + jpeg_info.arith_code=IsStringTrue(option) != MagickFalse ? TRUE : FALSE; + jpeg_info.optimize_coding=FALSE; // Not supported. + } +#endif #if (JPEG_LIB_VERSION >= 61) && defined(C_PROGRESSIVE_SUPPORTED) if ((LocaleCompare(image_info->magick,"PJPEG") == 0) || (image_info->interlace != NoInterlace)) -- 2.40.0