diff options
author | David Walter Seikel | 2013-01-13 18:54:10 +1000 |
---|---|---|
committer | David Walter Seikel | 2013-01-13 18:54:10 +1000 |
commit | 959831f4ef5a3e797f576c3de08cd65032c997ad (patch) | |
tree | e7351908be5995f0b325b2ebeaa02d5a34b82583 /libraries/irrlicht-1.8/source/Irrlicht/jpeglib/jutils.c | |
parent | Add info about changes to Irrlicht. (diff) | |
download | SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.zip SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.gz SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.bz2 SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.xz |
Remove damned ancient DOS line endings from Irrlicht. Hopefully I did not go overboard.
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/jpeglib/jutils.c')
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/jpeglib/jutils.c | 454 |
1 files changed, 227 insertions, 227 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/jpeglib/jutils.c b/libraries/irrlicht-1.8/source/Irrlicht/jpeglib/jutils.c index 037a795..5b16b6d 100644 --- a/libraries/irrlicht-1.8/source/Irrlicht/jpeglib/jutils.c +++ b/libraries/irrlicht-1.8/source/Irrlicht/jpeglib/jutils.c | |||
@@ -1,227 +1,227 @@ | |||
1 | /* | 1 | /* |
2 | * jutils.c | 2 | * jutils.c |
3 | * | 3 | * |
4 | * Copyright (C) 1991-1996, Thomas G. Lane. | 4 | * Copyright (C) 1991-1996, Thomas G. Lane. |
5 | * Modified 2009-2011 by Guido Vollbeding. | 5 | * Modified 2009-2011 by Guido Vollbeding. |
6 | * This file is part of the Independent JPEG Group's software. | 6 | * This file is part of the Independent JPEG Group's software. |
7 | * For conditions of distribution and use, see the accompanying README file. | 7 | * For conditions of distribution and use, see the accompanying README file. |
8 | * | 8 | * |
9 | * This file contains tables and miscellaneous utility routines needed | 9 | * This file contains tables and miscellaneous utility routines needed |
10 | * for both compression and decompression. | 10 | * for both compression and decompression. |
11 | * Note we prefix all global names with "j" to minimize conflicts with | 11 | * Note we prefix all global names with "j" to minimize conflicts with |
12 | * a surrounding application. | 12 | * a surrounding application. |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #define JPEG_INTERNALS | 15 | #define JPEG_INTERNALS |
16 | #include "jinclude.h" | 16 | #include "jinclude.h" |
17 | #include "jpeglib.h" | 17 | #include "jpeglib.h" |
18 | 18 | ||
19 | 19 | ||
20 | /* | 20 | /* |
21 | * jpeg_zigzag_order[i] is the zigzag-order position of the i'th element | 21 | * jpeg_zigzag_order[i] is the zigzag-order position of the i'th element |
22 | * of a DCT block read in natural order (left to right, top to bottom). | 22 | * of a DCT block read in natural order (left to right, top to bottom). |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #if 0 /* This table is not actually needed in v6a */ | 25 | #if 0 /* This table is not actually needed in v6a */ |
26 | 26 | ||
27 | const int jpeg_zigzag_order[DCTSIZE2] = { | 27 | const int jpeg_zigzag_order[DCTSIZE2] = { |
28 | 0, 1, 5, 6, 14, 15, 27, 28, | 28 | 0, 1, 5, 6, 14, 15, 27, 28, |
29 | 2, 4, 7, 13, 16, 26, 29, 42, | 29 | 2, 4, 7, 13, 16, 26, 29, 42, |
30 | 3, 8, 12, 17, 25, 30, 41, 43, | 30 | 3, 8, 12, 17, 25, 30, 41, 43, |
31 | 9, 11, 18, 24, 31, 40, 44, 53, | 31 | 9, 11, 18, 24, 31, 40, 44, 53, |
32 | 10, 19, 23, 32, 39, 45, 52, 54, | 32 | 10, 19, 23, 32, 39, 45, 52, 54, |
33 | 20, 22, 33, 38, 46, 51, 55, 60, | 33 | 20, 22, 33, 38, 46, 51, 55, 60, |
34 | 21, 34, 37, 47, 50, 56, 59, 61, | 34 | 21, 34, 37, 47, 50, 56, 59, 61, |
35 | 35, 36, 48, 49, 57, 58, 62, 63 | 35 | 35, 36, 48, 49, 57, 58, 62, 63 |
36 | }; | 36 | }; |
37 | 37 | ||
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | /* | 40 | /* |
41 | * jpeg_natural_order[i] is the natural-order position of the i'th element | 41 | * jpeg_natural_order[i] is the natural-order position of the i'th element |
42 | * of zigzag order. | 42 | * of zigzag order. |
43 | * | 43 | * |
44 | * When reading corrupted data, the Huffman decoders could attempt | 44 | * When reading corrupted data, the Huffman decoders could attempt |
45 | * to reference an entry beyond the end of this array (if the decoded | 45 | * to reference an entry beyond the end of this array (if the decoded |
46 | * zero run length reaches past the end of the block). To prevent | 46 | * zero run length reaches past the end of the block). To prevent |
47 | * wild stores without adding an inner-loop test, we put some extra | 47 | * wild stores without adding an inner-loop test, we put some extra |
48 | * "63"s after the real entries. This will cause the extra coefficient | 48 | * "63"s after the real entries. This will cause the extra coefficient |
49 | * to be stored in location 63 of the block, not somewhere random. | 49 | * to be stored in location 63 of the block, not somewhere random. |
50 | * The worst case would be a run-length of 15, which means we need 16 | 50 | * The worst case would be a run-length of 15, which means we need 16 |
51 | * fake entries. | 51 | * fake entries. |
52 | */ | 52 | */ |
53 | 53 | ||
54 | const int jpeg_natural_order[DCTSIZE2+16] = { | 54 | const int jpeg_natural_order[DCTSIZE2+16] = { |
55 | 0, 1, 8, 16, 9, 2, 3, 10, | 55 | 0, 1, 8, 16, 9, 2, 3, 10, |
56 | 17, 24, 32, 25, 18, 11, 4, 5, | 56 | 17, 24, 32, 25, 18, 11, 4, 5, |
57 | 12, 19, 26, 33, 40, 48, 41, 34, | 57 | 12, 19, 26, 33, 40, 48, 41, 34, |
58 | 27, 20, 13, 6, 7, 14, 21, 28, | 58 | 27, 20, 13, 6, 7, 14, 21, 28, |
59 | 35, 42, 49, 56, 57, 50, 43, 36, | 59 | 35, 42, 49, 56, 57, 50, 43, 36, |
60 | 29, 22, 15, 23, 30, 37, 44, 51, | 60 | 29, 22, 15, 23, 30, 37, 44, 51, |
61 | 58, 59, 52, 45, 38, 31, 39, 46, | 61 | 58, 59, 52, 45, 38, 31, 39, 46, |
62 | 53, 60, 61, 54, 47, 55, 62, 63, | 62 | 53, 60, 61, 54, 47, 55, 62, 63, |
63 | 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ | 63 | 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ |
64 | 63, 63, 63, 63, 63, 63, 63, 63 | 64 | 63, 63, 63, 63, 63, 63, 63, 63 |
65 | }; | 65 | }; |
66 | 66 | ||
67 | const int jpeg_natural_order7[7*7+16] = { | 67 | const int jpeg_natural_order7[7*7+16] = { |
68 | 0, 1, 8, 16, 9, 2, 3, 10, | 68 | 0, 1, 8, 16, 9, 2, 3, 10, |
69 | 17, 24, 32, 25, 18, 11, 4, 5, | 69 | 17, 24, 32, 25, 18, 11, 4, 5, |
70 | 12, 19, 26, 33, 40, 48, 41, 34, | 70 | 12, 19, 26, 33, 40, 48, 41, 34, |
71 | 27, 20, 13, 6, 14, 21, 28, 35, | 71 | 27, 20, 13, 6, 14, 21, 28, 35, |
72 | 42, 49, 50, 43, 36, 29, 22, 30, | 72 | 42, 49, 50, 43, 36, 29, 22, 30, |
73 | 37, 44, 51, 52, 45, 38, 46, 53, | 73 | 37, 44, 51, 52, 45, 38, 46, 53, |
74 | 54, | 74 | 54, |
75 | 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ | 75 | 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ |
76 | 63, 63, 63, 63, 63, 63, 63, 63 | 76 | 63, 63, 63, 63, 63, 63, 63, 63 |
77 | }; | 77 | }; |
78 | 78 | ||
79 | const int jpeg_natural_order6[6*6+16] = { | 79 | const int jpeg_natural_order6[6*6+16] = { |
80 | 0, 1, 8, 16, 9, 2, 3, 10, | 80 | 0, 1, 8, 16, 9, 2, 3, 10, |
81 | 17, 24, 32, 25, 18, 11, 4, 5, | 81 | 17, 24, 32, 25, 18, 11, 4, 5, |
82 | 12, 19, 26, 33, 40, 41, 34, 27, | 82 | 12, 19, 26, 33, 40, 41, 34, 27, |
83 | 20, 13, 21, 28, 35, 42, 43, 36, | 83 | 20, 13, 21, 28, 35, 42, 43, 36, |
84 | 29, 37, 44, 45, | 84 | 29, 37, 44, 45, |
85 | 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ | 85 | 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ |
86 | 63, 63, 63, 63, 63, 63, 63, 63 | 86 | 63, 63, 63, 63, 63, 63, 63, 63 |
87 | }; | 87 | }; |
88 | 88 | ||
89 | const int jpeg_natural_order5[5*5+16] = { | 89 | const int jpeg_natural_order5[5*5+16] = { |
90 | 0, 1, 8, 16, 9, 2, 3, 10, | 90 | 0, 1, 8, 16, 9, 2, 3, 10, |
91 | 17, 24, 32, 25, 18, 11, 4, 12, | 91 | 17, 24, 32, 25, 18, 11, 4, 12, |
92 | 19, 26, 33, 34, 27, 20, 28, 35, | 92 | 19, 26, 33, 34, 27, 20, 28, 35, |
93 | 36, | 93 | 36, |
94 | 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ | 94 | 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ |
95 | 63, 63, 63, 63, 63, 63, 63, 63 | 95 | 63, 63, 63, 63, 63, 63, 63, 63 |
96 | }; | 96 | }; |
97 | 97 | ||
98 | const int jpeg_natural_order4[4*4+16] = { | 98 | const int jpeg_natural_order4[4*4+16] = { |
99 | 0, 1, 8, 16, 9, 2, 3, 10, | 99 | 0, 1, 8, 16, 9, 2, 3, 10, |
100 | 17, 24, 25, 18, 11, 19, 26, 27, | 100 | 17, 24, 25, 18, 11, 19, 26, 27, |
101 | 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ | 101 | 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ |
102 | 63, 63, 63, 63, 63, 63, 63, 63 | 102 | 63, 63, 63, 63, 63, 63, 63, 63 |
103 | }; | 103 | }; |
104 | 104 | ||
105 | const int jpeg_natural_order3[3*3+16] = { | 105 | const int jpeg_natural_order3[3*3+16] = { |
106 | 0, 1, 8, 16, 9, 2, 10, 17, | 106 | 0, 1, 8, 16, 9, 2, 10, 17, |
107 | 18, | 107 | 18, |
108 | 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ | 108 | 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ |
109 | 63, 63, 63, 63, 63, 63, 63, 63 | 109 | 63, 63, 63, 63, 63, 63, 63, 63 |
110 | }; | 110 | }; |
111 | 111 | ||
112 | const int jpeg_natural_order2[2*2+16] = { | 112 | const int jpeg_natural_order2[2*2+16] = { |
113 | 0, 1, 8, 9, | 113 | 0, 1, 8, 9, |
114 | 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ | 114 | 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ |
115 | 63, 63, 63, 63, 63, 63, 63, 63 | 115 | 63, 63, 63, 63, 63, 63, 63, 63 |
116 | }; | 116 | }; |
117 | 117 | ||
118 | 118 | ||
119 | /* | 119 | /* |
120 | * Arithmetic utilities | 120 | * Arithmetic utilities |
121 | */ | 121 | */ |
122 | 122 | ||
123 | GLOBAL(long) | 123 | GLOBAL(long) |
124 | jdiv_round_up (long a, long b) | 124 | jdiv_round_up (long a, long b) |
125 | /* Compute a/b rounded up to next integer, ie, ceil(a/b) */ | 125 | /* Compute a/b rounded up to next integer, ie, ceil(a/b) */ |
126 | /* Assumes a >= 0, b > 0 */ | 126 | /* Assumes a >= 0, b > 0 */ |
127 | { | 127 | { |
128 | return (a + b - 1L) / b; | 128 | return (a + b - 1L) / b; |
129 | } | 129 | } |
130 | 130 | ||
131 | 131 | ||
132 | GLOBAL(long) | 132 | GLOBAL(long) |
133 | jround_up (long a, long b) | 133 | jround_up (long a, long b) |
134 | /* Compute a rounded up to next multiple of b, ie, ceil(a/b)*b */ | 134 | /* Compute a rounded up to next multiple of b, ie, ceil(a/b)*b */ |
135 | /* Assumes a >= 0, b > 0 */ | 135 | /* Assumes a >= 0, b > 0 */ |
136 | { | 136 | { |
137 | a += b - 1L; | 137 | a += b - 1L; |
138 | return a - (a % b); | 138 | return a - (a % b); |
139 | } | 139 | } |
140 | 140 | ||
141 | 141 | ||
142 | /* On normal machines we can apply MEMCOPY() and MEMZERO() to sample arrays | 142 | /* On normal machines we can apply MEMCOPY() and MEMZERO() to sample arrays |
143 | * and coefficient-block arrays. This won't work on 80x86 because the arrays | 143 | * and coefficient-block arrays. This won't work on 80x86 because the arrays |
144 | * are FAR and we're assuming a small-pointer memory model. However, some | 144 | * are FAR and we're assuming a small-pointer memory model. However, some |
145 | * DOS compilers provide far-pointer versions of memcpy() and memset() even | 145 | * DOS compilers provide far-pointer versions of memcpy() and memset() even |
146 | * in the small-model libraries. These will be used if USE_FMEM is defined. | 146 | * in the small-model libraries. These will be used if USE_FMEM is defined. |
147 | * Otherwise, the routines below do it the hard way. (The performance cost | 147 | * Otherwise, the routines below do it the hard way. (The performance cost |
148 | * is not all that great, because these routines aren't very heavily used.) | 148 | * is not all that great, because these routines aren't very heavily used.) |
149 | */ | 149 | */ |
150 | 150 | ||
151 | #ifndef NEED_FAR_POINTERS /* normal case, same as regular macro */ | 151 | #ifndef NEED_FAR_POINTERS /* normal case, same as regular macro */ |
152 | #define FMEMCOPY(dest,src,size) MEMCOPY(dest,src,size) | 152 | #define FMEMCOPY(dest,src,size) MEMCOPY(dest,src,size) |
153 | #else /* 80x86 case, define if we can */ | 153 | #else /* 80x86 case, define if we can */ |
154 | #ifdef USE_FMEM | 154 | #ifdef USE_FMEM |
155 | #define FMEMCOPY(dest,src,size) _fmemcpy((void FAR *)(dest), (const void FAR *)(src), (size_t)(size)) | 155 | #define FMEMCOPY(dest,src,size) _fmemcpy((void FAR *)(dest), (const void FAR *)(src), (size_t)(size)) |
156 | #else | 156 | #else |
157 | /* This function is for use by the FMEMZERO macro defined in jpegint.h. | 157 | /* This function is for use by the FMEMZERO macro defined in jpegint.h. |
158 | * Do not call this function directly, use the FMEMZERO macro instead. | 158 | * Do not call this function directly, use the FMEMZERO macro instead. |
159 | */ | 159 | */ |
160 | GLOBAL(void) | 160 | GLOBAL(void) |
161 | jzero_far (void FAR * target, size_t bytestozero) | 161 | jzero_far (void FAR * target, size_t bytestozero) |
162 | /* Zero out a chunk of FAR memory. */ | 162 | /* Zero out a chunk of FAR memory. */ |
163 | /* This might be sample-array data, block-array data, or alloc_large data. */ | 163 | /* This might be sample-array data, block-array data, or alloc_large data. */ |
164 | { | 164 | { |
165 | register char FAR * ptr = (char FAR *) target; | 165 | register char FAR * ptr = (char FAR *) target; |
166 | register size_t count; | 166 | register size_t count; |
167 | 167 | ||
168 | for (count = bytestozero; count > 0; count--) { | 168 | for (count = bytestozero; count > 0; count--) { |
169 | *ptr++ = 0; | 169 | *ptr++ = 0; |
170 | } | 170 | } |
171 | } | 171 | } |
172 | #endif | 172 | #endif |
173 | #endif | 173 | #endif |
174 | 174 | ||
175 | 175 | ||
176 | GLOBAL(void) | 176 | GLOBAL(void) |
177 | jcopy_sample_rows (JSAMPARRAY input_array, int source_row, | 177 | jcopy_sample_rows (JSAMPARRAY input_array, int source_row, |
178 | JSAMPARRAY output_array, int dest_row, | 178 | JSAMPARRAY output_array, int dest_row, |
179 | int num_rows, JDIMENSION num_cols) | 179 | int num_rows, JDIMENSION num_cols) |
180 | /* Copy some rows of samples from one place to another. | 180 | /* Copy some rows of samples from one place to another. |
181 | * num_rows rows are copied from input_array[source_row++] | 181 | * num_rows rows are copied from input_array[source_row++] |
182 | * to output_array[dest_row++]; these areas may overlap for duplication. | 182 | * to output_array[dest_row++]; these areas may overlap for duplication. |
183 | * The source and destination arrays must be at least as wide as num_cols. | 183 | * The source and destination arrays must be at least as wide as num_cols. |
184 | */ | 184 | */ |
185 | { | 185 | { |
186 | register JSAMPROW inptr, outptr; | 186 | register JSAMPROW inptr, outptr; |
187 | #ifdef FMEMCOPY | 187 | #ifdef FMEMCOPY |
188 | register size_t count = (size_t) (num_cols * SIZEOF(JSAMPLE)); | 188 | register size_t count = (size_t) (num_cols * SIZEOF(JSAMPLE)); |
189 | #else | 189 | #else |
190 | register JDIMENSION count; | 190 | register JDIMENSION count; |
191 | #endif | 191 | #endif |
192 | register int row; | 192 | register int row; |
193 | 193 | ||
194 | input_array += source_row; | 194 | input_array += source_row; |
195 | output_array += dest_row; | 195 | output_array += dest_row; |
196 | 196 | ||
197 | for (row = num_rows; row > 0; row--) { | 197 | for (row = num_rows; row > 0; row--) { |
198 | inptr = *input_array++; | 198 | inptr = *input_array++; |
199 | outptr = *output_array++; | 199 | outptr = *output_array++; |
200 | #ifdef FMEMCOPY | 200 | #ifdef FMEMCOPY |
201 | FMEMCOPY(outptr, inptr, count); | 201 | FMEMCOPY(outptr, inptr, count); |
202 | #else | 202 | #else |
203 | for (count = num_cols; count > 0; count--) | 203 | for (count = num_cols; count > 0; count--) |
204 | *outptr++ = *inptr++; /* needn't bother with GETJSAMPLE() here */ | 204 | *outptr++ = *inptr++; /* needn't bother with GETJSAMPLE() here */ |
205 | #endif | 205 | #endif |
206 | } | 206 | } |
207 | } | 207 | } |
208 | 208 | ||
209 | 209 | ||
210 | GLOBAL(void) | 210 | GLOBAL(void) |
211 | jcopy_block_row (JBLOCKROW input_row, JBLOCKROW output_row, | 211 | jcopy_block_row (JBLOCKROW input_row, JBLOCKROW output_row, |
212 | JDIMENSION num_blocks) | 212 | JDIMENSION num_blocks) |
213 | /* Copy a row of coefficient blocks from one place to another. */ | 213 | /* Copy a row of coefficient blocks from one place to another. */ |
214 | { | 214 | { |
215 | #ifdef FMEMCOPY | 215 | #ifdef FMEMCOPY |
216 | FMEMCOPY(output_row, input_row, num_blocks * (DCTSIZE2 * SIZEOF(JCOEF))); | 216 | FMEMCOPY(output_row, input_row, num_blocks * (DCTSIZE2 * SIZEOF(JCOEF))); |
217 | #else | 217 | #else |
218 | register JCOEFPTR inptr, outptr; | 218 | register JCOEFPTR inptr, outptr; |
219 | register long count; | 219 | register long count; |
220 | 220 | ||
221 | inptr = (JCOEFPTR) input_row; | 221 | inptr = (JCOEFPTR) input_row; |
222 | outptr = (JCOEFPTR) output_row; | 222 | outptr = (JCOEFPTR) output_row; |
223 | for (count = (long) num_blocks * DCTSIZE2; count > 0; count--) { | 223 | for (count = (long) num_blocks * DCTSIZE2; count > 0; count--) { |
224 | *outptr++ = *inptr++; | 224 | *outptr++ = *inptr++; |
225 | } | 225 | } |
226 | #endif | 226 | #endif |
227 | } | 227 | } |