image_intensities 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/ext/image_intensities/Makefile +73 -4
  3. data/ext/image_intensities/turbojpeg/cderror.h +137 -0
  4. data/ext/image_intensities/turbojpeg/cdjpeg.h +157 -0
  5. data/ext/image_intensities/turbojpeg/cmyk.h +61 -0
  6. data/ext/image_intensities/turbojpeg/jaricom.c +157 -0
  7. data/ext/image_intensities/turbojpeg/jcapimin.c +295 -0
  8. data/ext/image_intensities/turbojpeg/jcapistd.c +162 -0
  9. data/ext/image_intensities/turbojpeg/jcarith.c +932 -0
  10. data/ext/image_intensities/turbojpeg/jccoefct.c +449 -0
  11. data/ext/image_intensities/turbojpeg/jccolext.c +144 -0
  12. data/ext/image_intensities/turbojpeg/jccolor.c +710 -0
  13. data/ext/image_intensities/turbojpeg/jcdctmgr.c +721 -0
  14. data/ext/image_intensities/turbojpeg/jchuff.c +1096 -0
  15. data/ext/image_intensities/turbojpeg/jchuff.h +42 -0
  16. data/ext/image_intensities/turbojpeg/jcicc.c +105 -0
  17. data/ext/image_intensities/turbojpeg/jcinit.c +77 -0
  18. data/ext/image_intensities/turbojpeg/jcmainct.c +162 -0
  19. data/ext/image_intensities/turbojpeg/jcmarker.c +664 -0
  20. data/ext/image_intensities/turbojpeg/jcmaster.c +640 -0
  21. data/ext/image_intensities/turbojpeg/jcomapi.c +109 -0
  22. data/ext/image_intensities/turbojpeg/jconfig.h +73 -0
  23. data/ext/image_intensities/turbojpeg/jconfigint.h +31 -0
  24. data/ext/image_intensities/turbojpeg/jcparam.c +541 -0
  25. data/ext/image_intensities/turbojpeg/jcphuff.c +1105 -0
  26. data/ext/image_intensities/turbojpeg/jcprepct.c +351 -0
  27. data/ext/image_intensities/turbojpeg/jcsample.c +539 -0
  28. data/ext/image_intensities/turbojpeg/jctrans.c +400 -0
  29. data/ext/image_intensities/turbojpeg/jdapimin.c +407 -0
  30. data/ext/image_intensities/turbojpeg/jdapistd.c +639 -0
  31. data/ext/image_intensities/turbojpeg/jdarith.c +773 -0
  32. data/ext/image_intensities/turbojpeg/jdatadst-tj.c +203 -0
  33. data/ext/image_intensities/turbojpeg/jdatadst.c +293 -0
  34. data/ext/image_intensities/turbojpeg/jdatasrc-tj.c +194 -0
  35. data/ext/image_intensities/turbojpeg/jdatasrc.c +295 -0
  36. data/ext/image_intensities/turbojpeg/jdcoefct.c +692 -0
  37. data/ext/image_intensities/turbojpeg/jdcoefct.h +82 -0
  38. data/ext/image_intensities/turbojpeg/jdcol565.c +384 -0
  39. data/ext/image_intensities/turbojpeg/jdcolext.c +143 -0
  40. data/ext/image_intensities/turbojpeg/jdcolor.c +883 -0
  41. data/ext/image_intensities/turbojpeg/jdct.h +208 -0
  42. data/ext/image_intensities/turbojpeg/jddctmgr.c +352 -0
  43. data/ext/image_intensities/turbojpeg/jdhuff.c +831 -0
  44. data/ext/image_intensities/turbojpeg/jdhuff.h +238 -0
  45. data/ext/image_intensities/turbojpeg/jdicc.c +171 -0
  46. data/ext/image_intensities/turbojpeg/jdinput.c +408 -0
  47. data/ext/image_intensities/turbojpeg/jdmainct.c +460 -0
  48. data/ext/image_intensities/turbojpeg/jdmainct.h +71 -0
  49. data/ext/image_intensities/turbojpeg/jdmarker.c +1377 -0
  50. data/ext/image_intensities/turbojpeg/jdmaster.c +737 -0
  51. data/ext/image_intensities/turbojpeg/jdmaster.h +28 -0
  52. data/ext/image_intensities/turbojpeg/jdmerge.c +617 -0
  53. data/ext/image_intensities/turbojpeg/jdmrg565.c +354 -0
  54. data/ext/image_intensities/turbojpeg/jdmrgext.c +184 -0
  55. data/ext/image_intensities/turbojpeg/jdphuff.c +687 -0
  56. data/ext/image_intensities/turbojpeg/jdpostct.c +294 -0
  57. data/ext/image_intensities/turbojpeg/jdsample.c +518 -0
  58. data/ext/image_intensities/turbojpeg/jdsample.h +50 -0
  59. data/ext/image_intensities/turbojpeg/jdtrans.c +155 -0
  60. data/ext/image_intensities/turbojpeg/jerror.c +251 -0
  61. data/ext/image_intensities/turbojpeg/jfdctflt.c +169 -0
  62. data/ext/image_intensities/turbojpeg/jfdctfst.c +227 -0
  63. data/ext/image_intensities/turbojpeg/jfdctint.c +288 -0
  64. data/ext/image_intensities/turbojpeg/jidctflt.c +240 -0
  65. data/ext/image_intensities/turbojpeg/jidctfst.c +371 -0
  66. data/ext/image_intensities/turbojpeg/jidctint.c +2627 -0
  67. data/ext/image_intensities/turbojpeg/jidctred.c +409 -0
  68. data/ext/image_intensities/turbojpeg/jinclude.h +88 -0
  69. data/ext/image_intensities/turbojpeg/jmemmgr.c +1179 -0
  70. data/ext/image_intensities/turbojpeg/jmemnobs.c +115 -0
  71. data/ext/image_intensities/turbojpeg/jmemsys.h +178 -0
  72. data/ext/image_intensities/turbojpeg/jpeg_nbits_table.h +4098 -0
  73. data/ext/image_intensities/turbojpeg/jpegcomp.h +31 -0
  74. data/ext/image_intensities/turbojpeg/jquant1.c +859 -0
  75. data/ext/image_intensities/turbojpeg/jquant2.c +1285 -0
  76. data/ext/image_intensities/turbojpeg/jsimd.h +117 -0
  77. data/ext/image_intensities/turbojpeg/jsimd_none.c +418 -0
  78. data/ext/image_intensities/turbojpeg/jsimddct.h +70 -0
  79. data/ext/image_intensities/turbojpeg/jstdhuff.c +143 -0
  80. data/ext/image_intensities/turbojpeg/jutils.c +133 -0
  81. data/ext/image_intensities/turbojpeg/jversion.h +52 -0
  82. data/ext/image_intensities/turbojpeg/libturbojpeg.a +0 -0
  83. data/ext/image_intensities/turbojpeg/rdbmp.c +689 -0
  84. data/ext/image_intensities/turbojpeg/rdppm.c +766 -0
  85. data/ext/image_intensities/turbojpeg/tjutil.h +47 -0
  86. data/ext/image_intensities/turbojpeg/transupp.c +1628 -0
  87. data/ext/image_intensities/turbojpeg/transupp.h +210 -0
  88. data/ext/image_intensities/turbojpeg/turbojpeg.c +2150 -0
  89. data/ext/image_intensities/turbojpeg/wrbmp.c +558 -0
  90. data/ext/image_intensities/turbojpeg/wrppm.c +365 -0
  91. data/image_intensities.gemspec +1 -1
  92. data/lib/image_intensities/version.rb +1 -1
  93. metadata +91 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 464455d1063af5fd09dba024cfd681137290db2c3294d97ad36d20bef49b74a8
4
- data.tar.gz: 2f60420eb22106e56d85d54d11f659461894ea2542dcdb6299f7ff0e4548d52f
3
+ metadata.gz: 3aaacd34e0e75848ce4bf6e2e94115abeac38896535cfe3e936f2521250df2f2
4
+ data.tar.gz: c14d7aa5c7427af35499ae983d5ca4440b3936b4038b6b734378f9e7aa9830a4
5
5
  SHA512:
6
- metadata.gz: 8146a851d0d1d7f615e9f03d3b17d66dbf32d5dfafb46cededb3063da8ca4d4261625f5927d62f39ac9b7d4e4229cb31a5776ea6b580415dfb32e25e9d969a74
7
- data.tar.gz: 77a2ccd9318bbc4f17c615f44f8b61b19689695185b1ef05ca4b16f7e7c8784c0e4a5dfcc2fe39c2193c2cfe8fdfa207bdbecef7dafe3bbf8966c399b9fe4ad8
6
+ metadata.gz: 8ac29ecdfc07d1edffcc140286846cc923f3321c37c0b21c623e27f4424c923ce4aebd065538728e9ca7d62a4f014609c75dcaf1880ba71070174619e23ec8dd
7
+ data.tar.gz: cfb26975f59fed4713e59d891aba47f4f42aa0c6c5f7bb083e65a124c60e504f22952bc26bab4eb8af9072a99f2d2296aaf41eea7cb69225ae5c8dcfc6e99e9b
@@ -1,14 +1,83 @@
1
1
  CC ?= cc
2
- RM ?= rm -rf
2
+ AR ?= ar
3
+ RM ?= rm
3
4
  MKDIR ?= mkdir
4
5
 
6
+ JPEG_OBJECTS := turbojpeg/jsimd_none.o \
7
+ turbojpeg/jchuff.o \
8
+ turbojpeg/jcapimin.o \
9
+ turbojpeg/jcapistd.o \
10
+ turbojpeg/jccolor.o \
11
+ turbojpeg/jcicc.o \
12
+ turbojpeg/jccoefct.o \
13
+ turbojpeg/jcinit.o \
14
+ turbojpeg/jcdctmgr.o \
15
+ turbojpeg/jcmainct.o \
16
+ turbojpeg/jcmarker.o \
17
+ turbojpeg/jcmaster.o \
18
+ turbojpeg/jcomapi.o \
19
+ turbojpeg/jcparam.o \
20
+ turbojpeg/jcphuff.o \
21
+ turbojpeg/jcprepct.o \
22
+ turbojpeg/jcsample.o \
23
+ turbojpeg/jctrans.o \
24
+ turbojpeg/jdapimin.o \
25
+ turbojpeg/jdapistd.o \
26
+ turbojpeg/jdatadst.o \
27
+ turbojpeg/jdatasrc.o \
28
+ turbojpeg/jdcoefct.o \
29
+ turbojpeg/jdcolor.o \
30
+ turbojpeg/jddctmgr.o \
31
+ turbojpeg/jdhuff.o \
32
+ turbojpeg/jdicc.o \
33
+ turbojpeg/jdinput.o \
34
+ turbojpeg/jdmainct.o \
35
+ turbojpeg/jdmarker.o \
36
+ turbojpeg/jdmaster.o \
37
+ turbojpeg/jdmerge.o \
38
+ turbojpeg/jdphuff.o \
39
+ turbojpeg/jdpostct.o \
40
+ turbojpeg/jdsample.o \
41
+ turbojpeg/jdtrans.o \
42
+ turbojpeg/jerror.o \
43
+ turbojpeg/jfdctflt.o \
44
+ turbojpeg/jfdctfst.o \
45
+ turbojpeg/jfdctint.o \
46
+ turbojpeg/jidctflt.o \
47
+ turbojpeg/jidctfst.o \
48
+ turbojpeg/jidctint.o \
49
+ turbojpeg/jidctred.o \
50
+ turbojpeg/jquant1.o \
51
+ turbojpeg/jquant2.o \
52
+ turbojpeg/jutils.o \
53
+ turbojpeg/jmemmgr.o \
54
+ turbojpeg/jmemnobs.o \
55
+ turbojpeg/jaricom.o \
56
+ turbojpeg/jdarith.o \
57
+ turbojpeg/jcarith.o \
58
+ turbojpeg/turbojpeg.o \
59
+ turbojpeg/transupp.o \
60
+ turbojpeg/jdatadst-tj.o \
61
+ turbojpeg/jdatasrc-tj.o \
62
+ turbojpeg/rdbmp.o \
63
+ turbojpeg/rdppm.o \
64
+ turbojpeg/wrbmp.o \
65
+ turbojpeg/wrppm.o
66
+
5
67
  .PHONY: all clean
6
68
 
7
69
  all: lib/libimage_intensities.so
8
70
 
9
- lib/libimage_intensities.so: definitions.h intensities.c png.c jpeg.c
71
+ lib/libimage_intensities.so: definitions.h intensities.c png.c jpeg.c turbojpeg/libturbojpeg.a
10
72
  $(MKDIR) -p lib
11
- $(CC) intensities.c png.c jpeg.c -fPIC -shared -o lib/libimage_intensities.so -lturbojpeg -lpng
73
+ $(CC) intensities.c png.c jpeg.c turbojpeg/libturbojpeg.a -fPIC -shared -o lib/libimage_intensities.so -lpng
74
+
75
+ turbojpeg/libturbojpeg.a: $(JPEG_OBJECTS)
76
+ $(AR) rcs $@ $^
77
+
78
+ turbojpeg/%.o: turbojpeg/%.c
79
+ $(CC) $< -c -o $@ -fPIC -shared -O3 -DPPM_SUPPORTED -DBMP_SUPPORTED -Iturbojpeg
12
80
 
13
81
  clean:
14
- rm -rf lib
82
+ $(RM) -rf $(JPEG_OBJECTS)
83
+ $(RM) -rf lib
@@ -0,0 +1,137 @@
1
+ /*
2
+ * cderror.h
3
+ *
4
+ * Copyright (C) 1994-1997, Thomas G. Lane.
5
+ * Modified 2009-2017 by Guido Vollbeding.
6
+ * This file is part of the Independent JPEG Group's software.
7
+ * For conditions of distribution and use, see the accompanying README.ijg
8
+ * file.
9
+ *
10
+ * This file defines the error and message codes for the cjpeg/djpeg
11
+ * applications. These strings are not needed as part of the JPEG library
12
+ * proper.
13
+ * Edit this file to add new codes, or to translate the message strings to
14
+ * some other language.
15
+ */
16
+
17
+ /*
18
+ * To define the enum list of message codes, include this file without
19
+ * defining macro JMESSAGE. To create a message string table, include it
20
+ * again with a suitable JMESSAGE definition (see jerror.c for an example).
21
+ */
22
+ #ifndef JMESSAGE
23
+ #ifndef CDERROR_H
24
+ #define CDERROR_H
25
+ /* First time through, define the enum list */
26
+ #define JMAKE_ENUM_LIST
27
+ #else
28
+ /* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */
29
+ #define JMESSAGE(code, string)
30
+ #endif /* CDERROR_H */
31
+ #endif /* JMESSAGE */
32
+
33
+ #ifdef JMAKE_ENUM_LIST
34
+
35
+ typedef enum {
36
+
37
+ #define JMESSAGE(code, string) code,
38
+
39
+ #endif /* JMAKE_ENUM_LIST */
40
+
41
+ JMESSAGE(JMSG_FIRSTADDONCODE = 1000, NULL) /* Must be first entry! */
42
+
43
+ #ifdef BMP_SUPPORTED
44
+ JMESSAGE(JERR_BMP_BADCMAP, "Unsupported BMP colormap format")
45
+ JMESSAGE(JERR_BMP_BADDEPTH, "Only 8- and 24-bit BMP files are supported")
46
+ JMESSAGE(JERR_BMP_BADHEADER, "Invalid BMP file: bad header length")
47
+ JMESSAGE(JERR_BMP_BADPLANES, "Invalid BMP file: biPlanes not equal to 1")
48
+ JMESSAGE(JERR_BMP_COLORSPACE, "BMP output must be grayscale or RGB")
49
+ JMESSAGE(JERR_BMP_COMPRESSED, "Sorry, compressed BMPs not yet supported")
50
+ JMESSAGE(JERR_BMP_EMPTY, "Empty BMP image")
51
+ JMESSAGE(JERR_BMP_NOT, "Not a BMP file - does not start with BM")
52
+ JMESSAGE(JERR_BMP_OUTOFRANGE, "Numeric value out of range in BMP file")
53
+ JMESSAGE(JTRC_BMP, "%ux%u 24-bit BMP image")
54
+ JMESSAGE(JTRC_BMP_MAPPED, "%ux%u 8-bit colormapped BMP image")
55
+ JMESSAGE(JTRC_BMP_OS2, "%ux%u 24-bit OS2 BMP image")
56
+ JMESSAGE(JTRC_BMP_OS2_MAPPED, "%ux%u 8-bit colormapped OS2 BMP image")
57
+ #endif /* BMP_SUPPORTED */
58
+
59
+ #ifdef GIF_SUPPORTED
60
+ JMESSAGE(JERR_GIF_BUG, "GIF output got confused")
61
+ JMESSAGE(JERR_GIF_CODESIZE, "Bogus GIF codesize %d")
62
+ JMESSAGE(JERR_GIF_COLORSPACE, "GIF output must be grayscale or RGB")
63
+ JMESSAGE(JERR_GIF_IMAGENOTFOUND, "Too few images in GIF file")
64
+ JMESSAGE(JERR_GIF_NOT, "Not a GIF file")
65
+ JMESSAGE(JTRC_GIF, "%ux%ux%d GIF image")
66
+ JMESSAGE(JTRC_GIF_BADVERSION,
67
+ "Warning: unexpected GIF version number '%c%c%c'")
68
+ JMESSAGE(JTRC_GIF_EXTENSION, "Ignoring GIF extension block of type 0x%02x")
69
+ JMESSAGE(JTRC_GIF_NONSQUARE, "Caution: nonsquare pixels in input")
70
+ JMESSAGE(JWRN_GIF_BADDATA, "Corrupt data in GIF file")
71
+ JMESSAGE(JWRN_GIF_CHAR, "Bogus char 0x%02x in GIF file, ignoring")
72
+ JMESSAGE(JWRN_GIF_ENDCODE, "Premature end of GIF image")
73
+ JMESSAGE(JWRN_GIF_NOMOREDATA, "Ran out of GIF bits")
74
+ #endif /* GIF_SUPPORTED */
75
+
76
+ #ifdef PPM_SUPPORTED
77
+ JMESSAGE(JERR_PPM_COLORSPACE, "PPM output must be grayscale or RGB")
78
+ JMESSAGE(JERR_PPM_NONNUMERIC, "Nonnumeric data in PPM file")
79
+ JMESSAGE(JERR_PPM_NOT, "Not a PPM/PGM file")
80
+ JMESSAGE(JERR_PPM_OUTOFRANGE, "Numeric value out of range in PPM file")
81
+ JMESSAGE(JTRC_PGM, "%ux%u PGM image")
82
+ JMESSAGE(JTRC_PGM_TEXT, "%ux%u text PGM image")
83
+ JMESSAGE(JTRC_PPM, "%ux%u PPM image")
84
+ JMESSAGE(JTRC_PPM_TEXT, "%ux%u text PPM image")
85
+ #endif /* PPM_SUPPORTED */
86
+
87
+ #ifdef RLE_SUPPORTED
88
+ JMESSAGE(JERR_RLE_BADERROR, "Bogus error code from RLE library")
89
+ JMESSAGE(JERR_RLE_COLORSPACE, "RLE output must be grayscale or RGB")
90
+ JMESSAGE(JERR_RLE_DIMENSIONS, "Image dimensions (%ux%u) too large for RLE")
91
+ JMESSAGE(JERR_RLE_EMPTY, "Empty RLE file")
92
+ JMESSAGE(JERR_RLE_EOF, "Premature EOF in RLE header")
93
+ JMESSAGE(JERR_RLE_MEM, "Insufficient memory for RLE header")
94
+ JMESSAGE(JERR_RLE_NOT, "Not an RLE file")
95
+ JMESSAGE(JERR_RLE_TOOMANYCHANNELS, "Cannot handle %d output channels for RLE")
96
+ JMESSAGE(JERR_RLE_UNSUPPORTED, "Cannot handle this RLE setup")
97
+ JMESSAGE(JTRC_RLE, "%ux%u full-color RLE file")
98
+ JMESSAGE(JTRC_RLE_FULLMAP, "%ux%u full-color RLE file with map of length %d")
99
+ JMESSAGE(JTRC_RLE_GRAY, "%ux%u grayscale RLE file")
100
+ JMESSAGE(JTRC_RLE_MAPGRAY, "%ux%u grayscale RLE file with map of length %d")
101
+ JMESSAGE(JTRC_RLE_MAPPED, "%ux%u colormapped RLE file with map of length %d")
102
+ #endif /* RLE_SUPPORTED */
103
+
104
+ #ifdef TARGA_SUPPORTED
105
+ JMESSAGE(JERR_TGA_BADCMAP, "Unsupported Targa colormap format")
106
+ JMESSAGE(JERR_TGA_BADPARMS, "Invalid or unsupported Targa file")
107
+ JMESSAGE(JERR_TGA_COLORSPACE, "Targa output must be grayscale or RGB")
108
+ JMESSAGE(JTRC_TGA, "%ux%u RGB Targa image")
109
+ JMESSAGE(JTRC_TGA_GRAY, "%ux%u grayscale Targa image")
110
+ JMESSAGE(JTRC_TGA_MAPPED, "%ux%u colormapped Targa image")
111
+ #else
112
+ JMESSAGE(JERR_TGA_NOTCOMP, "Targa support was not compiled")
113
+ #endif /* TARGA_SUPPORTED */
114
+
115
+ JMESSAGE(JERR_BAD_CMAP_FILE,
116
+ "Color map file is invalid or of unsupported format")
117
+ JMESSAGE(JERR_TOO_MANY_COLORS,
118
+ "Output file format cannot handle %d colormap entries")
119
+ JMESSAGE(JERR_UNGETC_FAILED, "ungetc failed")
120
+ #ifdef TARGA_SUPPORTED
121
+ JMESSAGE(JERR_UNKNOWN_FORMAT,
122
+ "Unrecognized input file format --- perhaps you need -targa")
123
+ #else
124
+ JMESSAGE(JERR_UNKNOWN_FORMAT, "Unrecognized input file format")
125
+ #endif
126
+ JMESSAGE(JERR_UNSUPPORTED_FORMAT, "Unsupported output file format")
127
+
128
+ #ifdef JMAKE_ENUM_LIST
129
+
130
+ JMSG_LASTADDONCODE
131
+ } ADDON_MESSAGE_CODE;
132
+
133
+ #undef JMAKE_ENUM_LIST
134
+ #endif /* JMAKE_ENUM_LIST */
135
+
136
+ /* Zap JMESSAGE macro so that future re-inclusions do nothing by default */
137
+ #undef JMESSAGE
@@ -0,0 +1,157 @@
1
+ /*
2
+ * cdjpeg.h
3
+ *
4
+ * This file was part of the Independent JPEG Group's software:
5
+ * Copyright (C) 1994-1997, Thomas G. Lane.
6
+ * libjpeg-turbo Modifications:
7
+ * Copyright (C) 2017, D. R. Commander.
8
+ * For conditions of distribution and use, see the accompanying README.ijg
9
+ * file.
10
+ *
11
+ * This file contains common declarations for the sample applications
12
+ * cjpeg and djpeg. It is NOT used by the core JPEG library.
13
+ */
14
+
15
+ #define JPEG_CJPEG_DJPEG /* define proper options in jconfig.h */
16
+ #define JPEG_INTERNAL_OPTIONS /* cjpeg.c,djpeg.c need to see xxx_SUPPORTED */
17
+ #include "jinclude.h"
18
+ #include "jpeglib.h"
19
+ #include "jerror.h" /* get library error codes too */
20
+ #include "cderror.h" /* get application-specific error codes */
21
+
22
+
23
+ /*
24
+ * Object interface for cjpeg's source file decoding modules
25
+ */
26
+
27
+ typedef struct cjpeg_source_struct *cjpeg_source_ptr;
28
+
29
+ struct cjpeg_source_struct {
30
+ void (*start_input) (j_compress_ptr cinfo, cjpeg_source_ptr sinfo);
31
+ JDIMENSION (*get_pixel_rows) (j_compress_ptr cinfo, cjpeg_source_ptr sinfo);
32
+ void (*finish_input) (j_compress_ptr cinfo, cjpeg_source_ptr sinfo);
33
+
34
+ FILE *input_file;
35
+
36
+ JSAMPARRAY buffer;
37
+ JDIMENSION buffer_height;
38
+ };
39
+
40
+
41
+ /*
42
+ * Object interface for djpeg's output file encoding modules
43
+ */
44
+
45
+ typedef struct djpeg_dest_struct *djpeg_dest_ptr;
46
+
47
+ struct djpeg_dest_struct {
48
+ /* start_output is called after jpeg_start_decompress finishes.
49
+ * The color map will be ready at this time, if one is needed.
50
+ */
51
+ void (*start_output) (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo);
52
+ /* Emit the specified number of pixel rows from the buffer. */
53
+ void (*put_pixel_rows) (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
54
+ JDIMENSION rows_supplied);
55
+ /* Finish up at the end of the image. */
56
+ void (*finish_output) (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo);
57
+ /* Re-calculate buffer dimensions based on output dimensions (for use with
58
+ partial image decompression.) If this is NULL, then the output format
59
+ does not support partial image decompression (BMP and RLE, in particular,
60
+ cannot support partial decompression because they use an inversion buffer
61
+ to write the image in bottom-up order.) */
62
+ void (*calc_buffer_dimensions) (j_decompress_ptr cinfo,
63
+ djpeg_dest_ptr dinfo);
64
+
65
+
66
+ /* Target file spec; filled in by djpeg.c after object is created. */
67
+ FILE *output_file;
68
+
69
+ /* Output pixel-row buffer. Created by module init or start_output.
70
+ * Width is cinfo->output_width * cinfo->output_components;
71
+ * height is buffer_height.
72
+ */
73
+ JSAMPARRAY buffer;
74
+ JDIMENSION buffer_height;
75
+ };
76
+
77
+
78
+ /*
79
+ * cjpeg/djpeg may need to perform extra passes to convert to or from
80
+ * the source/destination file format. The JPEG library does not know
81
+ * about these passes, but we'd like them to be counted by the progress
82
+ * monitor. We use an expanded progress monitor object to hold the
83
+ * additional pass count.
84
+ */
85
+
86
+ struct cdjpeg_progress_mgr {
87
+ struct jpeg_progress_mgr pub; /* fields known to JPEG library */
88
+ int completed_extra_passes; /* extra passes completed */
89
+ int total_extra_passes; /* total extra */
90
+ /* last printed percentage stored here to avoid multiple printouts */
91
+ int percent_done;
92
+ };
93
+
94
+ typedef struct cdjpeg_progress_mgr *cd_progress_ptr;
95
+
96
+
97
+ /* Module selection routines for I/O modules. */
98
+
99
+ EXTERN(cjpeg_source_ptr) jinit_read_bmp(j_compress_ptr cinfo,
100
+ boolean use_inversion_array);
101
+ EXTERN(djpeg_dest_ptr) jinit_write_bmp(j_decompress_ptr cinfo, boolean is_os2,
102
+ boolean use_inversion_array);
103
+ EXTERN(cjpeg_source_ptr) jinit_read_gif(j_compress_ptr cinfo);
104
+ EXTERN(djpeg_dest_ptr) jinit_write_gif(j_decompress_ptr cinfo);
105
+ EXTERN(cjpeg_source_ptr) jinit_read_ppm(j_compress_ptr cinfo);
106
+ EXTERN(djpeg_dest_ptr) jinit_write_ppm(j_decompress_ptr cinfo);
107
+ EXTERN(cjpeg_source_ptr) jinit_read_rle(j_compress_ptr cinfo);
108
+ EXTERN(djpeg_dest_ptr) jinit_write_rle(j_decompress_ptr cinfo);
109
+ EXTERN(cjpeg_source_ptr) jinit_read_targa(j_compress_ptr cinfo);
110
+ EXTERN(djpeg_dest_ptr) jinit_write_targa(j_decompress_ptr cinfo);
111
+
112
+ /* cjpeg support routines (in rdswitch.c) */
113
+
114
+ EXTERN(boolean) read_quant_tables(j_compress_ptr cinfo, char *filename,
115
+ boolean force_baseline);
116
+ EXTERN(boolean) read_scan_script(j_compress_ptr cinfo, char *filename);
117
+ EXTERN(boolean) set_quality_ratings(j_compress_ptr cinfo, char *arg,
118
+ boolean force_baseline);
119
+ EXTERN(boolean) set_quant_slots(j_compress_ptr cinfo, char *arg);
120
+ EXTERN(boolean) set_sample_factors(j_compress_ptr cinfo, char *arg);
121
+
122
+ /* djpeg support routines (in rdcolmap.c) */
123
+
124
+ EXTERN(void) read_color_map(j_decompress_ptr cinfo, FILE *infile);
125
+
126
+ /* common support routines (in cdjpeg.c) */
127
+
128
+ EXTERN(void) enable_signal_catcher(j_common_ptr cinfo);
129
+ EXTERN(void) start_progress_monitor(j_common_ptr cinfo,
130
+ cd_progress_ptr progress);
131
+ EXTERN(void) end_progress_monitor(j_common_ptr cinfo);
132
+ EXTERN(boolean) keymatch(char *arg, const char *keyword, int minchars);
133
+ EXTERN(FILE *) read_stdin(void);
134
+ EXTERN(FILE *) write_stdout(void);
135
+
136
+ /* miscellaneous useful macros */
137
+
138
+ #ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */
139
+ #define READ_BINARY "r"
140
+ #define WRITE_BINARY "w"
141
+ #else
142
+ #define READ_BINARY "rb"
143
+ #define WRITE_BINARY "wb"
144
+ #endif
145
+
146
+ #ifndef EXIT_FAILURE /* define exit() codes if not provided */
147
+ #define EXIT_FAILURE 1
148
+ #endif
149
+ #ifndef EXIT_SUCCESS
150
+ #define EXIT_SUCCESS 0
151
+ #endif
152
+ #ifndef EXIT_WARNING
153
+ #define EXIT_WARNING 2
154
+ #endif
155
+
156
+ #define IsExtRGB(cs) \
157
+ (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
@@ -0,0 +1,61 @@
1
+ /*
2
+ * cmyk.h
3
+ *
4
+ * Copyright (C) 2017-2018, D. R. Commander.
5
+ * For conditions of distribution and use, see the accompanying README.ijg
6
+ * file.
7
+ *
8
+ * This file contains convenience functions for performing quick & dirty
9
+ * CMYK<->RGB conversion. This algorithm is suitable for testing purposes
10
+ * only. Properly converting between CMYK and RGB requires a color management
11
+ * system.
12
+ */
13
+
14
+ #ifndef CMYK_H
15
+ #define CMYK_H
16
+
17
+ #include <jinclude.h>
18
+ #define JPEG_INTERNALS
19
+ #include <jpeglib.h>
20
+ #include "jconfigint.h"
21
+
22
+
23
+ /* Fully reversible */
24
+
25
+ INLINE
26
+ LOCAL(void)
27
+ rgb_to_cmyk(JSAMPLE r, JSAMPLE g, JSAMPLE b, JSAMPLE *c, JSAMPLE *m,
28
+ JSAMPLE *y, JSAMPLE *k)
29
+ {
30
+ double ctmp = 1.0 - ((double)r / 255.0);
31
+ double mtmp = 1.0 - ((double)g / 255.0);
32
+ double ytmp = 1.0 - ((double)b / 255.0);
33
+ double ktmp = MIN(MIN(ctmp, mtmp), ytmp);
34
+
35
+ if (ktmp == 1.0) ctmp = mtmp = ytmp = 0.0;
36
+ else {
37
+ ctmp = (ctmp - ktmp) / (1.0 - ktmp);
38
+ mtmp = (mtmp - ktmp) / (1.0 - ktmp);
39
+ ytmp = (ytmp - ktmp) / (1.0 - ktmp);
40
+ }
41
+ *c = (JSAMPLE)(255.0 - ctmp * 255.0 + 0.5);
42
+ *m = (JSAMPLE)(255.0 - mtmp * 255.0 + 0.5);
43
+ *y = (JSAMPLE)(255.0 - ytmp * 255.0 + 0.5);
44
+ *k = (JSAMPLE)(255.0 - ktmp * 255.0 + 0.5);
45
+ }
46
+
47
+
48
+ /* Fully reversible only for C/M/Y/K values generated with rgb_to_cmyk() */
49
+
50
+ INLINE
51
+ LOCAL(void)
52
+ cmyk_to_rgb(JSAMPLE c, JSAMPLE m, JSAMPLE y, JSAMPLE k, JSAMPLE *r, JSAMPLE *g,
53
+ JSAMPLE *b)
54
+ {
55
+ *r = (JSAMPLE)((double)c * (double)k / 255.0 + 0.5);
56
+ *g = (JSAMPLE)((double)m * (double)k / 255.0 + 0.5);
57
+ *b = (JSAMPLE)((double)y * (double)k / 255.0 + 0.5);
58
+ }
59
+
60
+
61
+ #endif /* CMYK_H */
@@ -0,0 +1,157 @@
1
+ /*
2
+ * jaricom.c
3
+ *
4
+ * This file was part of the Independent JPEG Group's software:
5
+ * Developed 1997-2009 by Guido Vollbeding.
6
+ * libjpeg-turbo Modifications:
7
+ * Copyright (C) 2015, 2018, D. R. Commander.
8
+ * For conditions of distribution and use, see the accompanying README.ijg
9
+ * file.
10
+ *
11
+ * This file contains probability estimation tables for common use in
12
+ * arithmetic entropy encoding and decoding routines.
13
+ *
14
+ * This data represents Table D.2 in
15
+ * Recommendation ITU-T T.81 (1992) | ISO/IEC 10918-1:1994 and Table 24 in
16
+ * Recommendation ITU-T T.82 (1993) | ISO/IEC 11544:1993.
17
+ */
18
+
19
+ #define JPEG_INTERNALS
20
+ #include "jinclude.h"
21
+ #include "jpeglib.h"
22
+
23
+ /* The following #define specifies the packing of the four components
24
+ * into the compact JLONG representation.
25
+ * Note that this formula must match the actual arithmetic encoder
26
+ * and decoder implementation. The implementation has to be changed
27
+ * if this formula is changed.
28
+ * The current organization is leaned on Markus Kuhn's JBIG
29
+ * implementation (jbig_tab.c).
30
+ */
31
+
32
+ #define V(i, a, b, c, d) \
33
+ (((JLONG)a << 16) | ((JLONG)c << 8) | ((JLONG)d << 7) | b)
34
+
35
+ const JLONG jpeg_aritab[113 + 1] = {
36
+ /*
37
+ * Index, Qe_Value, Next_Index_LPS, Next_Index_MPS, Switch_MPS
38
+ */
39
+ V( 0, 0x5a1d, 1, 1, 1 ),
40
+ V( 1, 0x2586, 14, 2, 0 ),
41
+ V( 2, 0x1114, 16, 3, 0 ),
42
+ V( 3, 0x080b, 18, 4, 0 ),
43
+ V( 4, 0x03d8, 20, 5, 0 ),
44
+ V( 5, 0x01da, 23, 6, 0 ),
45
+ V( 6, 0x00e5, 25, 7, 0 ),
46
+ V( 7, 0x006f, 28, 8, 0 ),
47
+ V( 8, 0x0036, 30, 9, 0 ),
48
+ V( 9, 0x001a, 33, 10, 0 ),
49
+ V( 10, 0x000d, 35, 11, 0 ),
50
+ V( 11, 0x0006, 9, 12, 0 ),
51
+ V( 12, 0x0003, 10, 13, 0 ),
52
+ V( 13, 0x0001, 12, 13, 0 ),
53
+ V( 14, 0x5a7f, 15, 15, 1 ),
54
+ V( 15, 0x3f25, 36, 16, 0 ),
55
+ V( 16, 0x2cf2, 38, 17, 0 ),
56
+ V( 17, 0x207c, 39, 18, 0 ),
57
+ V( 18, 0x17b9, 40, 19, 0 ),
58
+ V( 19, 0x1182, 42, 20, 0 ),
59
+ V( 20, 0x0cef, 43, 21, 0 ),
60
+ V( 21, 0x09a1, 45, 22, 0 ),
61
+ V( 22, 0x072f, 46, 23, 0 ),
62
+ V( 23, 0x055c, 48, 24, 0 ),
63
+ V( 24, 0x0406, 49, 25, 0 ),
64
+ V( 25, 0x0303, 51, 26, 0 ),
65
+ V( 26, 0x0240, 52, 27, 0 ),
66
+ V( 27, 0x01b1, 54, 28, 0 ),
67
+ V( 28, 0x0144, 56, 29, 0 ),
68
+ V( 29, 0x00f5, 57, 30, 0 ),
69
+ V( 30, 0x00b7, 59, 31, 0 ),
70
+ V( 31, 0x008a, 60, 32, 0 ),
71
+ V( 32, 0x0068, 62, 33, 0 ),
72
+ V( 33, 0x004e, 63, 34, 0 ),
73
+ V( 34, 0x003b, 32, 35, 0 ),
74
+ V( 35, 0x002c, 33, 9, 0 ),
75
+ V( 36, 0x5ae1, 37, 37, 1 ),
76
+ V( 37, 0x484c, 64, 38, 0 ),
77
+ V( 38, 0x3a0d, 65, 39, 0 ),
78
+ V( 39, 0x2ef1, 67, 40, 0 ),
79
+ V( 40, 0x261f, 68, 41, 0 ),
80
+ V( 41, 0x1f33, 69, 42, 0 ),
81
+ V( 42, 0x19a8, 70, 43, 0 ),
82
+ V( 43, 0x1518, 72, 44, 0 ),
83
+ V( 44, 0x1177, 73, 45, 0 ),
84
+ V( 45, 0x0e74, 74, 46, 0 ),
85
+ V( 46, 0x0bfb, 75, 47, 0 ),
86
+ V( 47, 0x09f8, 77, 48, 0 ),
87
+ V( 48, 0x0861, 78, 49, 0 ),
88
+ V( 49, 0x0706, 79, 50, 0 ),
89
+ V( 50, 0x05cd, 48, 51, 0 ),
90
+ V( 51, 0x04de, 50, 52, 0 ),
91
+ V( 52, 0x040f, 50, 53, 0 ),
92
+ V( 53, 0x0363, 51, 54, 0 ),
93
+ V( 54, 0x02d4, 52, 55, 0 ),
94
+ V( 55, 0x025c, 53, 56, 0 ),
95
+ V( 56, 0x01f8, 54, 57, 0 ),
96
+ V( 57, 0x01a4, 55, 58, 0 ),
97
+ V( 58, 0x0160, 56, 59, 0 ),
98
+ V( 59, 0x0125, 57, 60, 0 ),
99
+ V( 60, 0x00f6, 58, 61, 0 ),
100
+ V( 61, 0x00cb, 59, 62, 0 ),
101
+ V( 62, 0x00ab, 61, 63, 0 ),
102
+ V( 63, 0x008f, 61, 32, 0 ),
103
+ V( 64, 0x5b12, 65, 65, 1 ),
104
+ V( 65, 0x4d04, 80, 66, 0 ),
105
+ V( 66, 0x412c, 81, 67, 0 ),
106
+ V( 67, 0x37d8, 82, 68, 0 ),
107
+ V( 68, 0x2fe8, 83, 69, 0 ),
108
+ V( 69, 0x293c, 84, 70, 0 ),
109
+ V( 70, 0x2379, 86, 71, 0 ),
110
+ V( 71, 0x1edf, 87, 72, 0 ),
111
+ V( 72, 0x1aa9, 87, 73, 0 ),
112
+ V( 73, 0x174e, 72, 74, 0 ),
113
+ V( 74, 0x1424, 72, 75, 0 ),
114
+ V( 75, 0x119c, 74, 76, 0 ),
115
+ V( 76, 0x0f6b, 74, 77, 0 ),
116
+ V( 77, 0x0d51, 75, 78, 0 ),
117
+ V( 78, 0x0bb6, 77, 79, 0 ),
118
+ V( 79, 0x0a40, 77, 48, 0 ),
119
+ V( 80, 0x5832, 80, 81, 1 ),
120
+ V( 81, 0x4d1c, 88, 82, 0 ),
121
+ V( 82, 0x438e, 89, 83, 0 ),
122
+ V( 83, 0x3bdd, 90, 84, 0 ),
123
+ V( 84, 0x34ee, 91, 85, 0 ),
124
+ V( 85, 0x2eae, 92, 86, 0 ),
125
+ V( 86, 0x299a, 93, 87, 0 ),
126
+ V( 87, 0x2516, 86, 71, 0 ),
127
+ V( 88, 0x5570, 88, 89, 1 ),
128
+ V( 89, 0x4ca9, 95, 90, 0 ),
129
+ V( 90, 0x44d9, 96, 91, 0 ),
130
+ V( 91, 0x3e22, 97, 92, 0 ),
131
+ V( 92, 0x3824, 99, 93, 0 ),
132
+ V( 93, 0x32b4, 99, 94, 0 ),
133
+ V( 94, 0x2e17, 93, 86, 0 ),
134
+ V( 95, 0x56a8, 95, 96, 1 ),
135
+ V( 96, 0x4f46, 101, 97, 0 ),
136
+ V( 97, 0x47e5, 102, 98, 0 ),
137
+ V( 98, 0x41cf, 103, 99, 0 ),
138
+ V( 99, 0x3c3d, 104, 100, 0 ),
139
+ V( 100, 0x375e, 99, 93, 0 ),
140
+ V( 101, 0x5231, 105, 102, 0 ),
141
+ V( 102, 0x4c0f, 106, 103, 0 ),
142
+ V( 103, 0x4639, 107, 104, 0 ),
143
+ V( 104, 0x415e, 103, 99, 0 ),
144
+ V( 105, 0x5627, 105, 106, 1 ),
145
+ V( 106, 0x50e7, 108, 107, 0 ),
146
+ V( 107, 0x4b85, 109, 103, 0 ),
147
+ V( 108, 0x5597, 110, 109, 0 ),
148
+ V( 109, 0x504f, 111, 107, 0 ),
149
+ V( 110, 0x5a10, 110, 111, 1 ),
150
+ V( 111, 0x5522, 112, 109, 0 ),
151
+ V( 112, 0x59eb, 112, 111, 1 ),
152
+ /*
153
+ * This last entry is used for fixed probability estimate of 0.5
154
+ * as recommended in Section 10.3 Table 5 of ITU-T Rec. T.851.
155
+ */
156
+ V( 113, 0x5a1d, 113, 113, 0 )
157
+ };