00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 #ifdef HAVE_CONFIG_H
00058 # include "config.h"
00059 #endif
00060 #if NEED_GNUG_PRAGMAS
00061 # pragma implementation
00062 #endif
00063
00064
00065
00066
00067 #include "ZPCodec.h"
00068 #include "ByteStream.h"
00069 #include "GException.h"
00070 #include <stdlib.h>
00071 #include <assert.h>
00072 #include <math.h>
00073 #include <stdio.h>
00074
00075
00076 #ifdef HAVE_NAMESPACES
00077 namespace DJVU {
00078 # ifdef NOT_DEFINED // Just to fool emacs c++ mode
00079 }
00080 #endif
00081 #endif
00082
00084
00086
00087
00088 #ifndef ZPCODER
00089 #ifndef ZCODER
00090 #define ZPCODER
00091 #endif
00092 #endif
00093 #ifdef ZCODER
00094
00095
00096
00097
00098 #warning "The ZCODER may infringe non-LizardTech patent(s)."
00099 #warning "You should use the ZPCODER instead."
00100 #endif
00101
00102
00104
00106
00107
00108
00109
00110
00111
00112
00113 static ZPCodec::Table default_ztable[256] =
00114 {
00115 #ifdef ZPCODER
00116
00117
00118
00119
00120 { 0x8000, 0x0000, 84, 145 },
00121 { 0x8000, 0x0000, 3, 4 },
00122 { 0x8000, 0x0000, 4, 3 },
00123 { 0x6bbd, 0x10a5, 5, 1 },
00124 { 0x6bbd, 0x10a5, 6, 2 },
00125 { 0x5d45, 0x1f28, 7, 3 },
00126 { 0x5d45, 0x1f28, 8, 4 },
00127 { 0x51b9, 0x2bd3, 9, 5 },
00128 { 0x51b9, 0x2bd3, 10, 6 },
00129 { 0x4813, 0x36e3, 11, 7 },
00130 { 0x4813, 0x36e3, 12, 8 },
00131 { 0x3fd5, 0x408c, 13, 9 },
00132 { 0x3fd5, 0x408c, 14, 10 },
00133 { 0x38b1, 0x48fd, 15, 11 },
00134 { 0x38b1, 0x48fd, 16, 12 },
00135 { 0x3275, 0x505d, 17, 13 },
00136 { 0x3275, 0x505d, 18, 14 },
00137 { 0x2cfd, 0x56d0, 19, 15 },
00138 { 0x2cfd, 0x56d0, 20, 16 },
00139 { 0x2825, 0x5c71, 21, 17 },
00140 { 0x2825, 0x5c71, 22, 18 },
00141 { 0x23ab, 0x615b, 23, 19 },
00142 { 0x23ab, 0x615b, 24, 20 },
00143 { 0x1f87, 0x65a5, 25, 21 },
00144 { 0x1f87, 0x65a5, 26, 22 },
00145 { 0x1bbb, 0x6962, 27, 23 },
00146 { 0x1bbb, 0x6962, 28, 24 },
00147 { 0x1845, 0x6ca2, 29, 25 },
00148 { 0x1845, 0x6ca2, 30, 26 },
00149 { 0x1523, 0x6f74, 31, 27 },
00150 { 0x1523, 0x6f74, 32, 28 },
00151 { 0x1253, 0x71e6, 33, 29 },
00152 { 0x1253, 0x71e6, 34, 30 },
00153 { 0x0fcf, 0x7404, 35, 31 },
00154 { 0x0fcf, 0x7404, 36, 32 },
00155 { 0x0d95, 0x75d6, 37, 33 },
00156 { 0x0d95, 0x75d6, 38, 34 },
00157 { 0x0b9d, 0x7768, 39, 35 },
00158 { 0x0b9d, 0x7768, 40, 36 },
00159 { 0x09e3, 0x78c2, 41, 37 },
00160 { 0x09e3, 0x78c2, 42, 38 },
00161 { 0x0861, 0x79ea, 43, 39 },
00162 { 0x0861, 0x79ea, 44, 40 },
00163 { 0x0711, 0x7ae7, 45, 41 },
00164 { 0x0711, 0x7ae7, 46, 42 },
00165 { 0x05f1, 0x7bbe, 47, 43 },
00166 { 0x05f1, 0x7bbe, 48, 44 },
00167 { 0x04f9, 0x7c75, 49, 45 },
00168 { 0x04f9, 0x7c75, 50, 46 },
00169 { 0x0425, 0x7d0f, 51, 47 },
00170 { 0x0425, 0x7d0f, 52, 48 },
00171 { 0x0371, 0x7d91, 53, 49 },
00172 { 0x0371, 0x7d91, 54, 50 },
00173 { 0x02d9, 0x7dfe, 55, 51 },
00174 { 0x02d9, 0x7dfe, 56, 52 },
00175 { 0x0259, 0x7e5a, 57, 53 },
00176 { 0x0259, 0x7e5a, 58, 54 },
00177 { 0x01ed, 0x7ea6, 59, 55 },
00178 { 0x01ed, 0x7ea6, 60, 56 },
00179 { 0x0193, 0x7ee6, 61, 57 },
00180 { 0x0193, 0x7ee6, 62, 58 },
00181 { 0x0149, 0x7f1a, 63, 59 },
00182 { 0x0149, 0x7f1a, 64, 60 },
00183 { 0x010b, 0x7f45, 65, 61 },
00184 { 0x010b, 0x7f45, 66, 62 },
00185 { 0x00d5, 0x7f6b, 67, 63 },
00186 { 0x00d5, 0x7f6b, 68, 64 },
00187 { 0x00a5, 0x7f8d, 69, 65 },
00188 { 0x00a5, 0x7f8d, 70, 66 },
00189 { 0x007b, 0x7faa, 71, 67 },
00190 { 0x007b, 0x7faa, 72, 68 },
00191 { 0x0057, 0x7fc3, 73, 69 },
00192 { 0x0057, 0x7fc3, 74, 70 },
00193 { 0x003b, 0x7fd7, 75, 71 },
00194 { 0x003b, 0x7fd7, 76, 72 },
00195 { 0x0023, 0x7fe7, 77, 73 },
00196 { 0x0023, 0x7fe7, 78, 74 },
00197 { 0x0013, 0x7ff2, 79, 75 },
00198 { 0x0013, 0x7ff2, 80, 76 },
00199 { 0x0007, 0x7ffa, 81, 77 },
00200 { 0x0007, 0x7ffa, 82, 78 },
00201 { 0x0001, 0x7fff, 81, 79 },
00202 { 0x0001, 0x7fff, 82, 80 },
00203 { 0x5695, 0x0000, 9, 85 },
00204 { 0x24ee, 0x0000, 86, 226 },
00205 { 0x8000, 0x0000, 5, 6 },
00206 { 0x0d30, 0x0000, 88, 176 },
00207 { 0x481a, 0x0000, 89, 143 },
00208 { 0x0481, 0x0000, 90, 138 },
00209 { 0x3579, 0x0000, 91, 141 },
00210 { 0x017a, 0x0000, 92, 112 },
00211 { 0x24ef, 0x0000, 93, 135 },
00212 { 0x007b, 0x0000, 94, 104 },
00213 { 0x1978, 0x0000, 95, 133 },
00214 { 0x0028, 0x0000, 96, 100 },
00215 { 0x10ca, 0x0000, 97, 129 },
00216 { 0x000d, 0x0000, 82, 98 },
00217 { 0x0b5d, 0x0000, 99, 127 },
00218 { 0x0034, 0x0000, 76, 72 },
00219 { 0x078a, 0x0000, 101, 125 },
00220 { 0x00a0, 0x0000, 70, 102 },
00221 { 0x050f, 0x0000, 103, 123 },
00222 { 0x0117, 0x0000, 66, 60 },
00223 { 0x0358, 0x0000, 105, 121 },
00224 { 0x01ea, 0x0000, 106, 110 },
00225 { 0x0234, 0x0000, 107, 119 },
00226 { 0x0144, 0x0000, 66, 108 },
00227 { 0x0173, 0x0000, 109, 117 },
00228 { 0x0234, 0x0000, 60, 54 },
00229 { 0x00f5, 0x0000, 111, 115 },
00230 { 0x0353, 0x0000, 56, 48 },
00231 { 0x00a1, 0x0000, 69, 113 },
00232 { 0x05c5, 0x0000, 114, 134 },
00233 { 0x011a, 0x0000, 65, 59 },
00234 { 0x03cf, 0x0000, 116, 132 },
00235 { 0x01aa, 0x0000, 61, 55 },
00236 { 0x0285, 0x0000, 118, 130 },
00237 { 0x0286, 0x0000, 57, 51 },
00238 { 0x01ab, 0x0000, 120, 128 },
00239 { 0x03d3, 0x0000, 53, 47 },
00240 { 0x011a, 0x0000, 122, 126 },
00241 { 0x05c5, 0x0000, 49, 41 },
00242 { 0x00ba, 0x0000, 124, 62 },
00243 { 0x08ad, 0x0000, 43, 37 },
00244 { 0x007a, 0x0000, 72, 66 },
00245 { 0x0ccc, 0x0000, 39, 31 },
00246 { 0x01eb, 0x0000, 60, 54 },
00247 { 0x1302, 0x0000, 33, 25 },
00248 { 0x02e6, 0x0000, 56, 50 },
00249 { 0x1b81, 0x0000, 29, 131 },
00250 { 0x045e, 0x0000, 52, 46 },
00251 { 0x24ef, 0x0000, 23, 17 },
00252 { 0x0690, 0x0000, 48, 40 },
00253 { 0x2865, 0x0000, 23, 15 },
00254 { 0x09de, 0x0000, 42, 136 },
00255 { 0x3987, 0x0000, 137, 7 },
00256 { 0x0dc8, 0x0000, 38, 32 },
00257 { 0x2c99, 0x0000, 21, 139 },
00258 { 0x10ca, 0x0000, 140, 172 },
00259 { 0x3b5f, 0x0000, 15, 9 },
00260 { 0x0b5d, 0x0000, 142, 170 },
00261 { 0x5695, 0x0000, 9, 85 },
00262 { 0x078a, 0x0000, 144, 168 },
00263 { 0x8000, 0x0000, 141, 248 },
00264 { 0x050f, 0x0000, 146, 166 },
00265 { 0x24ee, 0x0000, 147, 247 },
00266 { 0x0358, 0x0000, 148, 164 },
00267 { 0x0d30, 0x0000, 149, 197 },
00268 { 0x0234, 0x0000, 150, 162 },
00269 { 0x0481, 0x0000, 151, 95 },
00270 { 0x0173, 0x0000, 152, 160 },
00271 { 0x017a, 0x0000, 153, 173 },
00272 { 0x00f5, 0x0000, 154, 158 },
00273 { 0x007b, 0x0000, 155, 165 },
00274 { 0x00a1, 0x0000, 70, 156 },
00275 { 0x0028, 0x0000, 157, 161 },
00276 { 0x011a, 0x0000, 66, 60 },
00277 { 0x000d, 0x0000, 81, 159 },
00278 { 0x01aa, 0x0000, 62, 56 },
00279 { 0x0034, 0x0000, 75, 71 },
00280 { 0x0286, 0x0000, 58, 52 },
00281 { 0x00a0, 0x0000, 69, 163 },
00282 { 0x03d3, 0x0000, 54, 48 },
00283 { 0x0117, 0x0000, 65, 59 },
00284 { 0x05c5, 0x0000, 50, 42 },
00285 { 0x01ea, 0x0000, 167, 171 },
00286 { 0x08ad, 0x0000, 44, 38 },
00287 { 0x0144, 0x0000, 65, 169 },
00288 { 0x0ccc, 0x0000, 40, 32 },
00289 { 0x0234, 0x0000, 59, 53 },
00290 { 0x1302, 0x0000, 34, 26 },
00291 { 0x0353, 0x0000, 55, 47 },
00292 { 0x1b81, 0x0000, 30, 174 },
00293 { 0x05c5, 0x0000, 175, 193 },
00294 { 0x24ef, 0x0000, 24, 18 },
00295 { 0x03cf, 0x0000, 177, 191 },
00296 { 0x2b74, 0x0000, 178, 222 },
00297 { 0x0285, 0x0000, 179, 189 },
00298 { 0x201d, 0x0000, 180, 218 },
00299 { 0x01ab, 0x0000, 181, 187 },
00300 { 0x1715, 0x0000, 182, 216 },
00301 { 0x011a, 0x0000, 183, 185 },
00302 { 0x0fb7, 0x0000, 184, 214 },
00303 { 0x00ba, 0x0000, 69, 61 },
00304 { 0x0a67, 0x0000, 186, 212 },
00305 { 0x01eb, 0x0000, 59, 53 },
00306 { 0x06e7, 0x0000, 188, 210 },
00307 { 0x02e6, 0x0000, 55, 49 },
00308 { 0x0496, 0x0000, 190, 208 },
00309 { 0x045e, 0x0000, 51, 45 },
00310 { 0x030d, 0x0000, 192, 206 },
00311 { 0x0690, 0x0000, 47, 39 },
00312 { 0x0206, 0x0000, 194, 204 },
00313 { 0x09de, 0x0000, 41, 195 },
00314 { 0x0155, 0x0000, 196, 202 },
00315 { 0x0dc8, 0x0000, 37, 31 },
00316 { 0x00e1, 0x0000, 198, 200 },
00317 { 0x2b74, 0x0000, 199, 243 },
00318 { 0x0094, 0x0000, 72, 64 },
00319 { 0x201d, 0x0000, 201, 239 },
00320 { 0x0188, 0x0000, 62, 56 },
00321 { 0x1715, 0x0000, 203, 237 },
00322 { 0x0252, 0x0000, 58, 52 },
00323 { 0x0fb7, 0x0000, 205, 235 },
00324 { 0x0383, 0x0000, 54, 48 },
00325 { 0x0a67, 0x0000, 207, 233 },
00326 { 0x0547, 0x0000, 50, 44 },
00327 { 0x06e7, 0x0000, 209, 231 },
00328 { 0x07e2, 0x0000, 46, 38 },
00329 { 0x0496, 0x0000, 211, 229 },
00330 { 0x0bc0, 0x0000, 40, 34 },
00331 { 0x030d, 0x0000, 213, 227 },
00332 { 0x1178, 0x0000, 36, 28 },
00333 { 0x0206, 0x0000, 215, 225 },
00334 { 0x19da, 0x0000, 30, 22 },
00335 { 0x0155, 0x0000, 217, 223 },
00336 { 0x24ef, 0x0000, 26, 16 },
00337 { 0x00e1, 0x0000, 219, 221 },
00338 { 0x320e, 0x0000, 20, 220 },
00339 { 0x0094, 0x0000, 71, 63 },
00340 { 0x432a, 0x0000, 14, 8 },
00341 { 0x0188, 0x0000, 61, 55 },
00342 { 0x447d, 0x0000, 14, 224 },
00343 { 0x0252, 0x0000, 57, 51 },
00344 { 0x5ece, 0x0000, 8, 2 },
00345 { 0x0383, 0x0000, 53, 47 },
00346 { 0x8000, 0x0000, 228, 87 },
00347 { 0x0547, 0x0000, 49, 43 },
00348 { 0x481a, 0x0000, 230, 246 },
00349 { 0x07e2, 0x0000, 45, 37 },
00350 { 0x3579, 0x0000, 232, 244 },
00351 { 0x0bc0, 0x0000, 39, 33 },
00352 { 0x24ef, 0x0000, 234, 238 },
00353 { 0x1178, 0x0000, 35, 27 },
00354 { 0x1978, 0x0000, 138, 236 },
00355 { 0x19da, 0x0000, 29, 21 },
00356 { 0x2865, 0x0000, 24, 16 },
00357 { 0x24ef, 0x0000, 25, 15 },
00358 { 0x3987, 0x0000, 240, 8 },
00359 { 0x320e, 0x0000, 19, 241 },
00360 { 0x2c99, 0x0000, 22, 242 },
00361 { 0x432a, 0x0000, 13, 7 },
00362 { 0x3b5f, 0x0000, 16, 10 },
00363 { 0x447d, 0x0000, 13, 245 },
00364 { 0x5695, 0x0000, 10, 2 },
00365 { 0x5ece, 0x0000, 7, 1 },
00366 { 0x8000, 0x0000, 244, 83 },
00367 { 0x8000, 0x0000, 249, 250 },
00368 { 0x5695, 0x0000, 10, 2 },
00369 { 0x481a, 0x0000, 89, 143 },
00370 { 0x481a, 0x0000, 230, 246 },
00371 #endif
00372 #ifdef ZCODER
00373
00374
00375
00376
00377 { 0x8000, 0x0000, 84, 139 },
00378 { 0x8000, 0x0000, 3, 4 },
00379 { 0x8000, 0x0000, 4, 3 },
00380 { 0x7399, 0x10a5, 5, 1 },
00381 { 0x7399, 0x10a5, 6, 2 },
00382 { 0x6813, 0x1f28, 7, 3 },
00383 { 0x6813, 0x1f28, 8, 4 },
00384 { 0x5d65, 0x2bd3, 9, 5 },
00385 { 0x5d65, 0x2bd3, 10, 6 },
00386 { 0x5387, 0x36e3, 11, 7 },
00387 { 0x5387, 0x36e3, 12, 8 },
00388 { 0x4a73, 0x408c, 13, 9 },
00389 { 0x4a73, 0x408c, 14, 10 },
00390 { 0x421f, 0x48fe, 15, 11 },
00391 { 0x421f, 0x48fe, 16, 12 },
00392 { 0x3a85, 0x5060, 17, 13 },
00393 { 0x3a85, 0x5060, 18, 14 },
00394 { 0x339b, 0x56d3, 19, 15 },
00395 { 0x339b, 0x56d3, 20, 16 },
00396 { 0x2d59, 0x5c73, 21, 17 },
00397 { 0x2d59, 0x5c73, 22, 18 },
00398 { 0x27b3, 0x615e, 23, 19 },
00399 { 0x27b3, 0x615e, 24, 20 },
00400 { 0x22a1, 0x65a7, 25, 21 },
00401 { 0x22a1, 0x65a7, 26, 22 },
00402 { 0x1e19, 0x6963, 27, 23 },
00403 { 0x1e19, 0x6963, 28, 24 },
00404 { 0x1a0f, 0x6ca3, 29, 25 },
00405 { 0x1a0f, 0x6ca3, 30, 26 },
00406 { 0x167b, 0x6f75, 31, 27 },
00407 { 0x167b, 0x6f75, 32, 28 },
00408 { 0x1353, 0x71e6, 33, 29 },
00409 { 0x1353, 0x71e6, 34, 30 },
00410 { 0x108d, 0x7403, 35, 31 },
00411 { 0x108d, 0x7403, 36, 32 },
00412 { 0x0e1f, 0x75d7, 37, 33 },
00413 { 0x0e1f, 0x75d7, 38, 34 },
00414 { 0x0c01, 0x7769, 39, 35 },
00415 { 0x0c01, 0x7769, 40, 36 },
00416 { 0x0a2b, 0x78c2, 41, 37 },
00417 { 0x0a2b, 0x78c2, 42, 38 },
00418 { 0x0895, 0x79ea, 43, 39 },
00419 { 0x0895, 0x79ea, 44, 40 },
00420 { 0x0737, 0x7ae7, 45, 41 },
00421 { 0x0737, 0x7ae7, 46, 42 },
00422 { 0x060b, 0x7bbe, 47, 43 },
00423 { 0x060b, 0x7bbe, 48, 44 },
00424 { 0x050b, 0x7c75, 49, 45 },
00425 { 0x050b, 0x7c75, 50, 46 },
00426 { 0x0431, 0x7d10, 51, 47 },
00427 { 0x0431, 0x7d10, 52, 48 },
00428 { 0x0379, 0x7d92, 53, 49 },
00429 { 0x0379, 0x7d92, 54, 50 },
00430 { 0x02dd, 0x7dff, 55, 51 },
00431 { 0x02dd, 0x7dff, 56, 52 },
00432 { 0x025b, 0x7e5b, 57, 53 },
00433 { 0x025b, 0x7e5b, 58, 54 },
00434 { 0x01ef, 0x7ea7, 59, 55 },
00435 { 0x01ef, 0x7ea7, 60, 56 },
00436 { 0x0195, 0x7ee6, 61, 57 },
00437 { 0x0195, 0x7ee6, 62, 58 },
00438 { 0x0149, 0x7f1b, 63, 59 },
00439 { 0x0149, 0x7f1b, 64, 60 },
00440 { 0x010b, 0x7f46, 65, 61 },
00441 { 0x010b, 0x7f46, 66, 62 },
00442 { 0x00d5, 0x7f6c, 67, 63 },
00443 { 0x00d5, 0x7f6c, 68, 64 },
00444 { 0x00a5, 0x7f8d, 69, 65 },
00445 { 0x00a5, 0x7f8d, 70, 66 },
00446 { 0x007b, 0x7faa, 71, 67 },
00447 { 0x007b, 0x7faa, 72, 68 },
00448 { 0x0057, 0x7fc3, 73, 69 },
00449 { 0x0057, 0x7fc3, 74, 70 },
00450 { 0x0039, 0x7fd8, 75, 71 },
00451 { 0x0039, 0x7fd8, 76, 72 },
00452 { 0x0023, 0x7fe7, 77, 73 },
00453 { 0x0023, 0x7fe7, 78, 74 },
00454 { 0x0013, 0x7ff2, 79, 75 },
00455 { 0x0013, 0x7ff2, 80, 76 },
00456 { 0x0007, 0x7ffa, 81, 77 },
00457 { 0x0007, 0x7ffa, 82, 78 },
00458 { 0x0001, 0x7fff, 81, 79 },
00459 { 0x0001, 0x7fff, 82, 80 },
00460 { 0x620b, 0x0000, 9, 85 },
00461 { 0x294a, 0x0000, 86, 216 },
00462 { 0x8000, 0x0000, 5, 6 },
00463 { 0x0db3, 0x0000, 88, 168 },
00464 { 0x538e, 0x0000, 89, 137 },
00465 { 0x0490, 0x0000, 90, 134 },
00466 { 0x3e3e, 0x0000, 91, 135 },
00467 { 0x017c, 0x0000, 92, 112 },
00468 { 0x294a, 0x0000, 93, 133 },
00469 { 0x007c, 0x0000, 94, 104 },
00470 { 0x1b75, 0x0000, 95, 131 },
00471 { 0x0028, 0x0000, 96, 100 },
00472 { 0x12fc, 0x0000, 97, 129 },
00473 { 0x000d, 0x0000, 82, 98 },
00474 { 0x0cfb, 0x0000, 99, 125 },
00475 { 0x0034, 0x0000, 76, 72 },
00476 { 0x08cd, 0x0000, 101, 123 },
00477 { 0x00a0, 0x0000, 70, 102 },
00478 { 0x05de, 0x0000, 103, 119 },
00479 { 0x0118, 0x0000, 66, 60 },
00480 { 0x03e9, 0x0000, 105, 117 },
00481 { 0x01ed, 0x0000, 106, 110 },
00482 { 0x0298, 0x0000, 107, 115 },
00483 { 0x0145, 0x0000, 66, 108 },
00484 { 0x01b6, 0x0000, 109, 113 },
00485 { 0x0237, 0x0000, 60, 54 },
00486 { 0x0121, 0x0000, 65, 111 },
00487 { 0x035b, 0x0000, 56, 48 },
00488 { 0x01f9, 0x0000, 59, 53 },
00489 { 0x05de, 0x0000, 114, 130 },
00490 { 0x02fc, 0x0000, 55, 49 },
00491 { 0x03e9, 0x0000, 116, 128 },
00492 { 0x0484, 0x0000, 51, 45 },
00493 { 0x0298, 0x0000, 118, 126 },
00494 { 0x06ca, 0x0000, 47, 39 },
00495 { 0x01b6, 0x0000, 120, 124 },
00496 { 0x0a27, 0x0000, 41, 121 },
00497 { 0x0121, 0x0000, 66, 122 },
00498 { 0x0e57, 0x0000, 37, 31 },
00499 { 0x01f9, 0x0000, 60, 54 },
00500 { 0x0f25, 0x0000, 37, 29 },
00501 { 0x02fc, 0x0000, 56, 50 },
00502 { 0x1629, 0x0000, 33, 127 },
00503 { 0x0484, 0x0000, 52, 46 },
00504 { 0x1ee8, 0x0000, 27, 21 },
00505 { 0x06ca, 0x0000, 48, 40 },
00506 { 0x200f, 0x0000, 27, 19 },
00507 { 0x0a27, 0x0000, 42, 132 },
00508 { 0x2dae, 0x0000, 21, 15 },
00509 { 0x0e57, 0x0000, 38, 32 },
00510 { 0x4320, 0x0000, 15, 7 },
00511 { 0x11a0, 0x0000, 136, 164 },
00512 { 0x620b, 0x0000, 9, 85 },
00513 { 0x0bbe, 0x0000, 138, 162 },
00514 { 0x8000, 0x0000, 135, 248 },
00515 { 0x07f3, 0x0000, 140, 160 },
00516 { 0x294a, 0x0000, 141, 247 },
00517 { 0x053e, 0x0000, 142, 158 },
00518 { 0x0db3, 0x0000, 143, 199 },
00519 { 0x0378, 0x0000, 144, 156 },
00520 { 0x0490, 0x0000, 145, 167 },
00521 { 0x024d, 0x0000, 146, 154 },
00522 { 0x017c, 0x0000, 147, 101 },
00523 { 0x0185, 0x0000, 148, 152 },
00524 { 0x007c, 0x0000, 149, 159 },
00525 { 0x0100, 0x0000, 68, 150 },
00526 { 0x0028, 0x0000, 151, 155 },
00527 { 0x01c0, 0x0000, 62, 56 },
00528 { 0x000d, 0x0000, 81, 153 },
00529 { 0x02a7, 0x0000, 58, 52 },
00530 { 0x0034, 0x0000, 75, 71 },
00531 { 0x0403, 0x0000, 54, 46 },
00532 { 0x00a0, 0x0000, 69, 157 },
00533 { 0x0608, 0x0000, 48, 42 },
00534 { 0x0118, 0x0000, 65, 59 },
00535 { 0x0915, 0x0000, 44, 38 },
00536 { 0x01ed, 0x0000, 161, 165 },
00537 { 0x0db4, 0x0000, 40, 32 },
00538 { 0x0145, 0x0000, 65, 163 },
00539 { 0x1417, 0x0000, 34, 26 },
00540 { 0x0237, 0x0000, 59, 53 },
00541 { 0x1dd6, 0x0000, 30, 166 },
00542 { 0x035b, 0x0000, 55, 47 },
00543 { 0x294a, 0x0000, 24, 18 },
00544 { 0x11a0, 0x0000, 169, 195 },
00545 { 0x31a3, 0x0000, 170, 212 },
00546 { 0x0bbe, 0x0000, 171, 193 },
00547 { 0x235a, 0x0000, 172, 208 },
00548 { 0x07f3, 0x0000, 173, 191 },
00549 { 0x18b3, 0x0000, 174, 206 },
00550 { 0x053e, 0x0000, 175, 189 },
00551 { 0x1073, 0x0000, 176, 204 },
00552 { 0x0378, 0x0000, 177, 187 },
00553 { 0x0b35, 0x0000, 178, 200 },
00554 { 0x024d, 0x0000, 179, 185 },
00555 { 0x0778, 0x0000, 180, 198 },
00556 { 0x0185, 0x0000, 181, 183 },
00557 { 0x04ed, 0x0000, 182, 194 },
00558 { 0x0100, 0x0000, 67, 59 },
00559 { 0x0349, 0x0000, 184, 192 },
00560 { 0x02a7, 0x0000, 57, 51 },
00561 { 0x022e, 0x0000, 186, 190 },
00562 { 0x0403, 0x0000, 53, 45 },
00563 { 0x0171, 0x0000, 64, 188 },
00564 { 0x0608, 0x0000, 47, 41 },
00565 { 0x0283, 0x0000, 58, 52 },
00566 { 0x0915, 0x0000, 43, 37 },
00567 { 0x03cc, 0x0000, 54, 48 },
00568 { 0x0db4, 0x0000, 39, 31 },
00569 { 0x05b6, 0x0000, 50, 42 },
00570 { 0x1417, 0x0000, 33, 25 },
00571 { 0x088a, 0x0000, 44, 196 },
00572 { 0x1dd6, 0x0000, 29, 197 },
00573 { 0x0c16, 0x0000, 40, 34 },
00574 { 0x294a, 0x0000, 23, 17 },
00575 { 0x0ce2, 0x0000, 40, 32 },
00576 { 0x31a3, 0x0000, 201, 243 },
00577 { 0x1332, 0x0000, 36, 202 },
00578 { 0x235a, 0x0000, 203, 239 },
00579 { 0x1adc, 0x0000, 30, 24 },
00580 { 0x18b3, 0x0000, 205, 237 },
00581 { 0x1be7, 0x0000, 30, 22 },
00582 { 0x1073, 0x0000, 207, 235 },
00583 { 0x294a, 0x0000, 26, 16 },
00584 { 0x0b35, 0x0000, 209, 231 },
00585 { 0x3a07, 0x0000, 20, 210 },
00586 { 0x0778, 0x0000, 211, 229 },
00587 { 0x4e30, 0x0000, 14, 8 },
00588 { 0x04ed, 0x0000, 213, 225 },
00589 { 0x4fa6, 0x0000, 14, 214 },
00590 { 0x0349, 0x0000, 215, 223 },
00591 { 0x6966, 0x0000, 8, 2 },
00592 { 0x022e, 0x0000, 217, 221 },
00593 { 0x8000, 0x0000, 218, 87 },
00594 { 0x0171, 0x0000, 63, 219 },
00595 { 0x538e, 0x0000, 220, 246 },
00596 { 0x0283, 0x0000, 57, 51 },
00597 { 0x3e3e, 0x0000, 222, 244 },
00598 { 0x03cc, 0x0000, 53, 47 },
00599 { 0x294a, 0x0000, 224, 242 },
00600 { 0x05b6, 0x0000, 49, 41 },
00601 { 0x1b75, 0x0000, 226, 240 },
00602 { 0x088a, 0x0000, 43, 227 },
00603 { 0x12fc, 0x0000, 228, 238 },
00604 { 0x0c16, 0x0000, 39, 33 },
00605 { 0x0cfb, 0x0000, 230, 234 },
00606 { 0x0ce2, 0x0000, 39, 31 },
00607 { 0x08cd, 0x0000, 112, 232 },
00608 { 0x1332, 0x0000, 35, 233 },
00609 { 0x0f25, 0x0000, 38, 30 },
00610 { 0x1adc, 0x0000, 29, 23 },
00611 { 0x1629, 0x0000, 34, 236 },
00612 { 0x1be7, 0x0000, 29, 21 },
00613 { 0x1ee8, 0x0000, 28, 22 },
00614 { 0x294a, 0x0000, 25, 15 },
00615 { 0x200f, 0x0000, 28, 20 },
00616 { 0x3a07, 0x0000, 19, 241 },
00617 { 0x2dae, 0x0000, 22, 16 },
00618 { 0x4e30, 0x0000, 13, 7 },
00619 { 0x4320, 0x0000, 16, 8 },
00620 { 0x4fa6, 0x0000, 13, 245 },
00621 { 0x620b, 0x0000, 10, 2 },
00622 { 0x6966, 0x0000, 7, 1 },
00623 { 0x8000, 0x0000, 244, 83 },
00624 { 0x8000, 0x0000, 249, 250 },
00625 { 0x620b, 0x0000, 10, 2 },
00626 { 0x538e, 0x0000, 89, 137 },
00627 { 0x538e, 0x0000, 220, 246 },
00628 #endif
00629 };
00630
00631
00632
00634
00636
00637 class ZPCodec::Encode : public ZPCodec
00638 {
00639 public:
00640 Encode(GP<ByteStream> gbs, const bool djvucompat);
00641 virtual ~Encode();
00642 private:
00643 void init(void);
00644 };
00645
00646 ZPCodec::Encode::Encode(GP<ByteStream> gbs, const bool djvucompat)
00647 : ZPCodec(gbs,true,djvucompat)
00648 {
00649 init();
00650
00651 #ifdef ZPCODEC_BITCOUNT
00652 bitcount = 0;
00653 #endif
00654 }
00655
00656 ZPCodec::Encode::~Encode()
00657 {
00658 eflush();
00659 }
00660
00661 class ZPCodec::Decode : public ZPCodec
00662 {
00663 public:
00664 Decode(GP<ByteStream> gbs, const bool djvucompat);
00665 virtual ~Decode();
00666 private:
00667 void init(void);
00668 };
00669
00670 ZPCodec::Decode::Decode(GP<ByteStream> gbs, const bool djvucompat)
00671 : ZPCodec(gbs,false,djvucompat)
00672 {
00673 init();
00674
00675 #ifdef ZPCODEC_BITCOUNT
00676 bitcount = 0;
00677 #endif
00678 }
00679
00680 ZPCodec::Decode::~Decode() {}
00681
00682 ZPCodec::ZPCodec(GP<ByteStream> xgbs, const bool xencoding, const bool djvucompat)
00683 : gbs(xgbs), bs(xgbs), encoding(xencoding), fence(0), subend(0), buffer(0), nrun(0)
00684 {
00685
00686 for (int i=0; i<256; i++)
00687 {
00688 ffzt[i]=0;
00689 for (int j=i; j&0x80; j<<=1)
00690 ffzt[i] += 1;
00691 }
00692
00693 newtable(default_ztable);
00694
00695 if (!djvucompat)
00696 {
00697 for (int j=0; j<256; j++)
00698 {
00699 unsigned short a = 0x10000-p[j];
00700 while (a>=0x8000) a=(unsigned short)(a<<1);
00701 if (m[j]>0 && a+p[j]>=0x8000 && a>=m[j])
00702 {
00703 BitContext x = default_ztable[j].dn;
00704 BitContext y = default_ztable[x].dn;
00705 dn[j] = y;
00706 }
00707 }
00708 }
00709 }
00710
00711 ZPCodec::~ZPCodec() {}
00712
00713 GP<ZPCodec>
00714 ZPCodec::create(GP<ByteStream> gbs, const bool encoding, const bool djvucompat)
00715 {
00716 GP<ZPCodec> retval;
00717 if(encoding)
00718 {
00719 retval=new ZPCodec::Encode(gbs,djvucompat);
00720 }else
00721 {
00722 retval=new ZPCodec::Decode(gbs,djvucompat);
00723 }
00724 return retval;
00725 }
00726
00728
00730
00731
00732
00733 void
00734 ZPCodec::Decode::init(void)
00735 {
00736 assert(sizeof(unsigned int)==4);
00737 assert(sizeof(unsigned short)==2);
00738 a = 0;
00739
00740 if (! bs->read((void*)&byte, 1))
00741 byte = 0xff;
00742 code = (byte<<8);
00743 if (! bs->read((void*)&byte, 1))
00744 byte = 0xff;
00745 code = code | byte;
00746
00747 delay = 25;
00748 scount = 0;
00749 preload();
00750
00751 fence = code;
00752 if (code >= 0x8000)
00753 fence = 0x7fff;
00754 }
00755
00756
00757 void
00758 ZPCodec::preload(void)
00759 {
00760 while (scount<=24)
00761 {
00762 if (bs->read((void*)&byte, 1) < 1)
00763 {
00764 byte = 0xff;
00765 if (--delay < 1)
00766 G_THROW( ByteStream::EndOfFile );
00767 }
00768 buffer = (buffer<<8) | byte;
00769 scount += 8;
00770 }
00771 }
00772
00773
00774 inline int
00775 ZPCodec::ffz(unsigned int x)
00776 {
00777
00778
00779
00780 #if defined(FASTBSR) && defined(_MSC_VER) && defined(_M_IX86)
00781 int r;
00782 __asm {
00783 mov ebx, x
00784 xor ebx, 0xffff
00785 mov eax, -1
00786 bsr eax, ebx
00787 mov r, eax
00788 }
00789 return 15 - r;
00790 #elif defined(FASTBSR) && defined(__GNUC__) && defined(__i386__)
00791 int r, dummy;
00792 __asm__ const ( "movl %2,%1\n\t"
00793 "xorl $0xffff, %1\n\t"
00794 "movl $-1, %0\n\t"
00795 "bsrl %1, %0"
00796 : "=&q" (r), "=q" (dummy) : "rm" (x) );
00797 return 15 - r;
00798 #else
00799 return (x>=0xff00) ? (ffzt[x&0xff]+8) : (ffzt[(x>>8)&0xff]);
00800 #endif
00801 }
00802
00803
00804 int
00805 ZPCodec::decode_sub(BitContext &ctx, unsigned int z)
00806 {
00807
00808 int bit = (ctx & 1);
00809
00810 #ifdef ZPCODER
00811 unsigned int d = 0x6000 + ((z+a)>>2);
00812 if (z > d)
00813 z = d;
00814 #endif
00815 #ifdef ZCODER
00816 if (z >= 0x8000)
00817 z = 0x4000 + (z>>1);
00818 #endif
00819
00820 if (z > code)
00821 {
00822
00823 z = 0x10000 - z;
00824 a = a + z;
00825 code = code + z;
00826
00827 ctx = dn[ctx];
00828
00829 int shift = ffz(a);
00830 scount -= shift;
00831 a = (unsigned short)(a<<shift);
00832 code = (unsigned short)(code<<shift) | ((buffer>>scount) & ((1<<shift)-1));
00833 #ifdef ZPCODEC_BITCOUNT
00834 bitcount += shift;
00835 #endif
00836 if (scount<16) preload();
00837
00838 fence = code;
00839 if (code >= 0x8000)
00840 fence = 0x7fff;
00841 return bit ^ 1;
00842 }
00843 else
00844 {
00845
00846 if (a >= m[ctx])
00847 ctx = up[ctx];
00848
00849 scount -= 1;
00850 a = (unsigned short)(z<<1);
00851 code = (unsigned short)(code<<1) | ((buffer>>scount) & 1);
00852 #ifdef ZPCODEC_BITCOUNT
00853 bitcount += 1;
00854 #endif
00855 if (scount<16) preload();
00856
00857 fence = code;
00858 if (code >= 0x8000)
00859 fence = 0x7fff;
00860 return bit;
00861 }
00862 }
00863
00864
00865 int
00866 ZPCodec::decode_sub_simple(int mps, unsigned int z)
00867 {
00868
00869 if (z > code)
00870 {
00871
00872 z = 0x10000 - z;
00873 a = a + z;
00874 code = code + z;
00875
00876 int shift = ffz(a);
00877 scount -= shift;
00878 a = (unsigned short)(a<<shift);
00879 code = (unsigned short)(code<<shift) | ((buffer>>scount) & ((1<<shift)-1));
00880 #ifdef ZPCODEC_BITCOUNT
00881 bitcount += shift;
00882 #endif
00883 if (scount<16) preload();
00884
00885 fence = code;
00886 if (code >= 0x8000)
00887 fence = 0x7fff;
00888 return mps ^ 1;
00889 }
00890 else
00891 {
00892
00893 scount -= 1;
00894 a = (unsigned short)(z<<1);
00895 code = (unsigned short)(code<<1) | ((buffer>>scount) & 1);
00896 #ifdef ZPCODEC_BITCOUNT
00897 bitcount += 1;
00898 #endif
00899 if (scount<16) preload();
00900
00901 fence = code;
00902 if (code >= 0x8000)
00903 fence = 0x7fff;
00904 return mps;
00905 }
00906 }
00907
00908
00909 int
00910 ZPCodec::decode_sub_nolearn(int mps, unsigned int z)
00911 {
00912 #ifdef ZPCODER
00913 unsigned int d = 0x6000 + ((z+a)>>2);
00914 if (z > d)
00915 z = d;
00916 #endif
00917 #ifdef ZCODER
00918 if (z >= 0x8000)
00919 z = 0x4000 + (z>>1);
00920 #endif
00921
00922 if (z > code)
00923 {
00924
00925 z = 0x10000 - z;
00926 a = a + z;
00927 code = code + z;
00928
00929 int shift = ffz(a);
00930 scount -= shift;
00931 a = (unsigned short)(a<<shift);
00932 code = (unsigned short)(code<<shift) | ((buffer>>scount) & ((1<<shift)-1));
00933 #ifdef ZPCODEC_BITCOUNT
00934 bitcount += shift;
00935 #endif
00936 if (scount<16) preload();
00937
00938 fence = code;
00939 if (code >= 0x8000)
00940 fence = 0x7fff;
00941 return mps ^ 1;
00942 }
00943 else
00944 {
00945
00946 scount -= 1;
00947 a = (unsigned short)(z<<1);
00948 code = (unsigned short)(code<<1) | ((buffer>>scount) & 1);
00949 #ifdef ZPCODEC_BITCOUNT
00950 bitcount += 1;
00951 #endif
00952 if (scount<16) preload();
00953
00954 fence = code;
00955 if (code >= 0x8000)
00956 fence = 0x7fff;
00957 return mps;
00958 }
00959 }
00960
00961
00962
00963
00964
00966
00968
00969
00970
00971
00972 void
00973 ZPCodec::Encode::init(void)
00974 {
00975 assert(sizeof(unsigned int)==4);
00976 assert(sizeof(unsigned short)==2);
00977 a = 0;
00978 scount = 0;
00979 byte = 0;
00980 delay = 25;
00981 subend = 0;
00982 buffer = 0xffffff;
00983 nrun = 0;
00984 }
00985
00986 void
00987 ZPCodec::outbit(int bit)
00988 {
00989 if (delay > 0)
00990 {
00991 if (delay < 0xff)
00992 delay -= 1;
00993 }
00994 else
00995 {
00996
00997 byte = (byte<<1) | bit;
00998
00999 if (++scount == 8)
01000 {
01001 if (!encoding)
01002 G_THROW( ERR_MSG("ZPCodec.no_encoding") );
01003 if (bs->write((void*)&byte, 1) != 1)
01004 G_THROW( ERR_MSG("ZPCodec.write_error") );
01005 scount = 0;
01006 byte = 0;
01007 }
01008 }
01009 }
01010
01011 void
01012 ZPCodec::zemit(int b)
01013 {
01014
01015 buffer = (buffer<<1) + b;
01016
01017 b = (buffer >> 24);
01018 buffer = (buffer & 0xffffff);
01019
01020
01021
01022
01023
01024 switch(b)
01025 {
01026
01027 case 1:
01028 outbit(1);
01029 while (nrun-- > 0)
01030 outbit(0);
01031 nrun = 0;
01032 break;
01033
01034 case 0xff:
01035 outbit(0);
01036 while (nrun-- > 0)
01037 outbit(1);
01038 nrun = 0;
01039 break;
01040
01041 case 0:
01042 nrun += 1;
01043 break;
01044 default:
01045 assert(0);
01046 }
01047
01048 #ifdef ZPCODEC_BITCOUNT
01049 bitcount += 1;
01050 #endif
01051 }
01052
01053 void
01054 ZPCodec::eflush()
01055 {
01056
01057 if (subend > 0x8000)
01058 subend = 0x10000;
01059 else if (subend > 0)
01060 subend = 0x8000;
01061
01062 while (buffer != 0xffffff || subend )
01063 {
01064 zemit(1 - (subend>>15) );
01065 subend = (unsigned short)(subend<<1);
01066 }
01067
01068 outbit(1);
01069 while (nrun-- > 0)
01070 outbit(0);
01071 nrun = 0;
01072
01073 while (scount > 0)
01074 outbit(1);
01075
01076 delay = 0xff;
01077 }
01078
01079 void
01080 ZPCodec::encode_mps(BitContext &ctx, unsigned int z)
01081 {
01082
01083 #ifdef ZPCODER
01084 unsigned int d = 0x6000 + ((z+a)>>2);
01085 if (z > d)
01086 z = d;
01087 #endif
01088 #ifdef ZCODER
01089 if (z >= 0x8000)
01090 z = 0x4000 + (z>>1);
01091 #endif
01092
01093 if (a >= m[ctx])
01094 ctx = up[ctx];
01095
01096 a = z;
01097
01098 if (a >= 0x8000)
01099 {
01100 zemit(1 - (subend>>15) );
01101 subend = (unsigned short)(subend<<1);
01102 a = (unsigned short)(a<<1);
01103 }
01104 }
01105
01106
01107 void
01108 ZPCodec::encode_lps(BitContext &ctx, unsigned int z)
01109 {
01110
01111 #ifdef ZPCODER
01112 unsigned int d = 0x6000 + ((z+a)>>2);
01113 if (z > d)
01114 z = d;
01115 #endif
01116 #ifdef ZCODER
01117 if (z >= 0x8000)
01118 z = 0x4000 + (z>>1);
01119 #endif
01120
01121 ctx = dn[ctx];
01122
01123 z = 0x10000 - z;
01124 subend += z;
01125 a += z;
01126
01127 while (a >= 0x8000)
01128 {
01129 zemit(1 - (subend>>15) );
01130 subend = (unsigned short)(subend<<1);
01131 a = (unsigned short)(a<<1);
01132 }
01133 }
01134
01135
01136 void
01137 ZPCodec::encode_mps_simple(unsigned int z)
01138 {
01139
01140 a = z;
01141
01142 if (a >= 0x8000)
01143 {
01144 zemit(1 - (subend>>15) );
01145 subend = (unsigned short)(subend<<1);
01146 a = (unsigned short)(a<<1);
01147 }
01148 }
01149
01150 void
01151 ZPCodec::encode_lps_simple(unsigned int z)
01152 {
01153
01154 z = 0x10000 - z;
01155 subend += z;
01156 a += z;
01157
01158 while (a >= 0x8000)
01159 {
01160 zemit(1 - (subend>>15) );
01161 subend = (unsigned short)(subend<<1);
01162 a = (unsigned short)(a<<1);
01163 }
01164 }
01165
01166
01167 void
01168 ZPCodec::encode_mps_nolearn(unsigned int z)
01169 {
01170 #ifdef ZPCODER
01171 unsigned int d = 0x6000 + ((z+a)>>2);
01172 if (z > d)
01173 z = d;
01174 #endif
01175 #ifdef ZCODER
01176 if (z >= 0x8000)
01177 z = 0x4000 + (z>>1);
01178 #endif
01179
01180 a = z;
01181
01182 if (a >= 0x8000)
01183 {
01184 zemit(1 - (subend>>15) );
01185 subend = (unsigned short)(subend<<1);
01186 a = (unsigned short)(a<<1);
01187 }
01188 }
01189
01190
01191 void
01192 ZPCodec::encode_lps_nolearn(unsigned int z)
01193 {
01194 #ifdef ZPCODER
01195 unsigned int d = 0x6000 + ((z+a)>>2);
01196 if (z > d)
01197 z = d;
01198 #endif
01199 #ifdef ZCODER
01200 if (z >= 0x8000)
01201 z = 0x4000 + (z>>1);
01202 #endif
01203
01204 z = 0x10000 - z;
01205 subend += z;
01206 a += z;
01207
01208 while (a >= 0x8000)
01209 {
01210 zemit(1 - (subend>>15) );
01211 subend = (unsigned short)(subend<<1);
01212 a = (unsigned short)(a<<1);
01213 }
01214 }
01215
01216
01217
01218
01219
01220
01222
01224
01225
01226
01227
01228 void
01229 ZPCodec::newtable(ZPCodec::Table *table)
01230 {
01231 for (int i=0; i<256; i++)
01232 {
01233 p[i] = table[i].p;
01234 m[i] = table[i].m;
01235 up[i] = table[i].up;
01236 dn[i] = table[i].dn;
01237 }
01238 }
01239
01240 static float
01241 p_to_plps(unsigned short p)
01242 {
01243 float fplps;
01244 float fp = (float)(p) / (float)(0x10000);
01245 const float log2 = (float)0.69314718055994530942;
01246 #ifdef ZCODER
01247 fplps = fp - (fp+0.5) * log(fp+0.5) + (fp-0.5)*log2;
01248 #endif
01249 #ifdef ZPCODER
01250 if (fp <= (1.0/6.0) )
01251 fplps = fp * 2 * log2;
01252 else
01253 fplps = (float)((1.5*fp-0.25) - (1.5*fp+0.25)*log(1.5*fp+0.25) + (0.5*fp-0.25)*log2);
01254 #endif
01255 return fplps;
01256 }
01257
01258
01259 BitContext
01260 ZPCodec::state(float prob1)
01261 {
01262
01263
01264 int mps = (prob1 <= 0.5 ? 0 : 1);
01265 float plps = (float)(mps ? 1.0 - prob1 : prob1);
01266
01267 int sz = 0;
01268 int lo = (mps ? 1 : 2);
01269 while (p[lo+sz+sz+2] < p[lo+sz+sz]) sz+=1;
01270
01271 while (sz > 1)
01272 {
01273 int nsz = sz >> 1;
01274 float nplps = p_to_plps( p[lo+nsz+nsz] );
01275 if (nplps < plps)
01276 { sz=nsz; }
01277 else
01278 { lo=lo+nsz+nsz; sz=sz-nsz; }
01279 }
01280
01281 float f1 = p_to_plps(p[lo])-plps;
01282 float f2 = plps-p_to_plps(p[lo+2]);
01283 return (f1<f2) ? lo : lo+2;
01284 }
01285
01286
01287 #ifdef HAVE_NAMESPACES
01288 }
01289 # ifndef NOT_USING_DJVU_NAMESPACE
01290 using namespace DJVU;
01291 # endif
01292 #endif