aboutsummaryrefslogtreecommitdiffstats
path: root/graphics/libimg/files/patch-jpeg
blob: 59585e6c695613e3bec851da85d71d3421a869ad (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
--- jpeg/jpeg.c 2018-09-14 09:53:49.000000000 -0400
+++ jpeg/jpeg.c 2020-01-20 21:56:13.089925000 -0500
@@ -62,5 +62,9 @@
 
 #include "tkimg.h"
-#include "jpegtcl.h"
+#ifdef EXTERN
+#  undef EXTERN
+#endif
+#include <jpeglib.h>
+#include <jerror.h>
 
 static int SetupJPegLibrary(Tcl_Interp *interp);
@@ -143,86 +147,11 @@
 
 
-
 static int
 SetupJPegLibrary (interp)
     Tcl_Interp *interp;
 {
-    struct jpeg_compress_struct *cinfo; /* libjpeg's parameter structure */
-    struct my_error_mgr jerror;    /* for controlling libjpeg error handling */
-    int i;
-
-    if (Jpegtcl_InitStubs(interp, JPEGTCL_VERSION, 0) == NULL) {
-        return TCL_ERROR;
-    }
-
-    /* The followin code tries to determine if the JPEG library is
-       valid at all. The library might be configured differently,
-       which will produce core dumps. Also it might be that
-       fields appear in different places in jpeg_compress_struct
-       or jpeg_decompress_struct. This will make the library totally
-       unusable. In stead of a core-dump, we better have a proper
-       error message */
-
-    /* overallocat size, so we don't get a core-dump if the library
-       thinks that the structure is much larger */
-
-    cinfo = (struct jpeg_compress_struct *) ckalloc(8*sizeof(struct jpeg_compress_struct));
-    cinfo->err = jpeg_std_error(&jerror.pub);
-    jerror.pub.error_exit = my_error_exit;
-    jerror.pub.output_message = my_output_message;
-    /* Establish the setjmp return context for my_error_exit to use. */
-    if (setjmp(jerror.setjmp_buffer)) {
-      /* If we get here, the JPEG library is invalid. */
-      jpeg_destroy_compress(cinfo);
-      ckfree((char *)cinfo);
-
-      if (interp) {
-   Tcl_AppendResult(interp, "couldn't use \"", "jpegtcl",
-       "\": please upgrade to at least version 6a", (char *) NULL);
-      }
-      return TCL_ERROR;
-    }
-
-    /* Now we can initialize libjpeg. */
-    ((char *) cinfo)[sizeof(struct jpeg_compress_struct)] = 53;
-    jpeg_create_compress(cinfo);
-    if (((char *) cinfo)[sizeof(struct jpeg_compress_struct)] != 53) {
-   /* Oops. The library changed this value, which is outside the
-    * structure. Definitely, the library is invalid!!!! */
-   ERREXIT(cinfo, JMSG_NOMESSAGE);
-    }
-
-    /* Set up JPEG compression parameters. */
-    cinfo->image_width = 16;
-    cinfo->image_height = 16;
-    cinfo->input_components = 3;
-    cinfo->in_color_space = JCS_RGB;
-    cinfo->data_precision = -1;
-    cinfo->optimize_coding = TRUE;
-    cinfo->dct_method = -1;
-    cinfo->X_density = 0;
-    cinfo->Y_density = 0;
-    jpeg_set_defaults(cinfo);
-
-    if ((cinfo->data_precision != BITS_IN_JSAMPLE) ||
-       (cinfo->optimize_coding != FALSE) ||
-       (cinfo->dct_method != JDCT_DEFAULT) ||
-       (cinfo->X_density != 1) ||
-       (cinfo->Y_density != 1)) {
-   ERREXIT(cinfo, JMSG_NOMESSAGE);
-    }
-    for (i = 0; i < NUM_ARITH_TBLS; i++) {
-   if ((cinfo->arith_dc_L[i] != 0) ||
-       (cinfo->arith_dc_U[i] != 1) ||
-       (cinfo->arith_ac_K[i] != 5)) {
-       ERREXIT(cinfo, JMSG_NOMESSAGE);
-   }
-    }
-    jpeg_destroy_compress(cinfo);
-    ckfree((char *) cinfo);
     return TCL_OK;
 }
 
-
 /*
  *----------------------------------------------------------------------
@@ -860,8 +789,6 @@
        }
        case 2: {
-           if (jpeg_simple_progression != NULL) {
-           /* Select simple progressive mode. */
-           jpeg_simple_progression(cinfo);
-           }
+           /* Select simple progressive mode. */
+           jpeg_simple_progression(cinfo);
            break;
        }
@@ -899,5 +826,5 @@
     greenOffset = blockPtr->offset[1] - blockPtr->offset[0];
     blueOffset = blockPtr->offset[2] - blockPtr->offset[0];
-    if ((jpeg_set_colorspace != NULL) &&
+    if (
        (grayscale || (!greenOffset && !blueOffset))) {
    /* Generate monochrome JPEG file if source block is grayscale. */
--- tests/jpeg.test 2016-07-30 10:30:48.000000000 -0400
+++ tests/jpeg.test 2020-01-20 21:43:20.086115000 -0500
@@ -24,5 +24,5 @@
     source $file2.base64
 
-    test jpeg-1.1 {} -setup {
+    test jpeg-1.1 {} -constraints nonPortable -setup {
         catch {image delete i}
     } -body {
@@ -33,5 +33,5 @@
     } -result $imgdata2
 
-    test jpeg-1.2 {} -setup {
+    test jpeg-1.2 {} -constraints nonPortable -setup {
         catch {image delete i}
     } -body {
@@ -42,5 +42,5 @@
     } -result $imgdata2
 
-    test jpeg-1.3 {} -setup {
+    test jpeg-1.3 {} -constraints nonPortable -setup {
         catch {image delete i}
     } -body {
@@ -52,5 +52,5 @@
     } -result $imgdata2
 
-    test jpeg-1.4 {} -setup {
+    test jpeg-1.4 {} -constraints nonPortable -setup {
         catch {image delete i}
     } -body {