From eec0ef527f18c5978c4476c9490f4de4c4249628 Mon Sep 17 00:00:00 2001 From: Henry Stiles Date: Sun, 26 Jul 1998 07:36:41 +0000 Subject: Initial revision git-svn-id: http://svn.ghostscript.com/ghostpcl/trunk/ghostpcl@246 06663e23-700e-0410-b217-a244a6096597 --- gs/bug-form.txt | 61 + gs/c-style.txt | 329 ++ gs/commprod.txt | 220 ++ gs/copying | 10 + gs/current.txt | 119 + gs/devices.txt | 2352 ++++++++++++++ gs/dll.txt | 554 ++++ gs/doc/Gs-vms.hlp | 290 ++ gs/doc/Public | 215 ++ gs/doc/ps2epsi.txt | 62 + gs/drivers.txt | 1355 ++++++++ gs/examples/ridt91.eps | 135 + gs/fonts.txt | 480 +++ gs/gdevpfax.c | 213 ++ gs/helpers.txt | 170 + gs/hershey.txt | 261 ++ gs/history1.txt | 341 ++ gs/history2.txt | 5160 +++++++++++++++++++++++++++++ gs/history3.txt | 8284 +++++++++++++++++++++++++++++++++++++++++++++++ gs/humor.txt | 50 + gs/install.txt | 256 ++ gs/jpeg/Makefile | 274 ++ gs/jpeg/README | 383 +++ gs/jpeg/ansi2knr | Bin 0 -> 7605 bytes gs/jpeg/ansi2knr.1 | 36 + gs/jpeg/ansi2knr.c | 693 ++++ gs/jpeg/cderror.h | 132 + gs/jpeg/cdjpeg.c | 179 + gs/jpeg/cdjpeg.h | 179 + gs/jpeg/change.log | 152 + gs/jpeg/cjpeg | Bin 0 -> 72722 bytes gs/jpeg/cjpeg.1 | 282 ++ gs/jpeg/cjpeg.c | 606 ++++ gs/jpeg/ckconfig.c | 402 +++ gs/jpeg/coderules.doc | 118 + gs/jpeg/config.log | 20 + gs/jpeg/config.status | 199 ++ gs/jpeg/configure | 1731 ++++++++++ gs/jpeg/djpeg | Bin 0 -> 88700 bytes gs/jpeg/djpeg.1 | 248 ++ gs/jpeg/djpeg.c | 604 ++++ gs/jpeg/example.c | 433 +++ gs/jpeg/filelist.doc | 203 ++ gs/jpeg/install.doc | 931 ++++++ gs/jpeg/jcapimin.c | 236 ++ gs/jpeg/jcapistd.c | 161 + gs/jpeg/jccoefct.c | 448 +++ gs/jpeg/jccolor.c | 459 +++ gs/jpeg/jcdctmgr.c | 387 +++ gs/jpeg/jchuff.c | 846 +++++ gs/jpeg/jchuff.h | 34 + gs/jpeg/jcinit.c | 72 + gs/jpeg/jcmainct.c | 293 ++ gs/jpeg/jcmarker.c | 641 ++++ gs/jpeg/jcmaster.c | 578 ++++ gs/jpeg/jcomapi.c | 94 + gs/jpeg/jconfig.bcc | 48 + gs/jpeg/jconfig.cfg | 44 + gs/jpeg/jconfig.dj | 38 + gs/jpeg/jconfig.doc | 155 + gs/jpeg/jconfig.h | 45 + gs/jpeg/jconfig.manx | 43 + gs/jpeg/jconfig.mc6 | 52 + gs/jpeg/jconfig.sas | 43 + gs/jpeg/jconfig.st | 42 + gs/jpeg/jconfig.vms | 37 + gs/jpeg/jconfig.wat | 38 + gs/jpeg/jcparam.c | 574 ++++ gs/jpeg/jcphuff.c | 829 +++++ gs/jpeg/jcprepct.c | 354 ++ gs/jpeg/jcsample.c | 519 +++ gs/jpeg/jctrans.c | 371 +++ gs/jpeg/jdapimin.c | 406 +++ gs/jpeg/jdapistd.c | 275 ++ gs/jpeg/jdatadst.c | 151 + gs/jpeg/jdatasrc.c | 212 ++ gs/jpeg/jdcoefct.c | 735 +++++ gs/jpeg/jdcolor.c | 367 +++ gs/jpeg/jdct.h | 176 + gs/jpeg/jddctmgr.c | 269 ++ gs/jpeg/jdhuff.c | 574 ++++ gs/jpeg/jdhuff.h | 202 ++ gs/jpeg/jdinput.c | 381 +++ gs/jpeg/jdmainct.c | 512 +++ gs/jpeg/jdmarker.c | 1055 ++++++ gs/jpeg/jdmaster.c | 555 ++++ gs/jpeg/jdmerge.c | 400 +++ gs/jpeg/jdphuff.c | 642 ++++ gs/jpeg/jdpostct.c | 290 ++ gs/jpeg/jdsample.c | 478 +++ gs/jpeg/jdtrans.c | 122 + gs/jpeg/jerror.c | 228 ++ gs/jpeg/jerror.h | 277 ++ gs/jpeg/jfdctflt.c | 168 + gs/jpeg/jfdctfst.c | 224 ++ gs/jpeg/jfdctint.c | 283 ++ gs/jpeg/jidctflt.c | 241 ++ gs/jpeg/jidctfst.c | 367 +++ gs/jpeg/jidctint.c | 388 +++ gs/jpeg/jidctred.c | 397 +++ gs/jpeg/jinclude.h | 91 + gs/jpeg/jmemansi.c | 167 + gs/jpeg/jmemdos.c | 634 ++++ gs/jpeg/jmemdosa.asm | 379 +++ gs/jpeg/jmemmac.c | 199 ++ gs/jpeg/jmemmgr.c | 1115 +++++++ gs/jpeg/jmemname.c | 271 ++ gs/jpeg/jmemnobs.c | 109 + gs/jpeg/jmemsys.h | 183 ++ gs/jpeg/jmorecfg.h | 362 +++ gs/jpeg/jpegint.h | 388 +++ gs/jpeg/jpeglib.h | 1055 ++++++ gs/jpeg/jpegtran | Bin 0 -> 70882 bytes gs/jpeg/jpegtran.1 | 150 + gs/jpeg/jpegtran.c | 372 +++ gs/jpeg/jquant1.c | 856 +++++ gs/jpeg/jquant2.c | 1310 ++++++++ gs/jpeg/jutils.c | 179 + gs/jpeg/jversion.h | 14 + gs/jpeg/libjpeg.a | Bin 0 -> 150240 bytes gs/jpeg/libjpeg.doc | 2772 ++++++++++++++++ gs/jpeg/makcjpeg.st | 37 + gs/jpeg/makdjpeg.st | 37 + gs/jpeg/makefile.ansi | 210 ++ gs/jpeg/makefile.bcc | 279 ++ gs/jpeg/makefile.cfg | 274 ++ gs/jpeg/makefile.dj | 234 ++ gs/jpeg/makefile.manx | 210 ++ gs/jpeg/makefile.mc6 | 233 ++ gs/jpeg/makefile.mms | 214 ++ gs/jpeg/makefile.sas | 244 ++ gs/jpeg/makefile.unix | 224 ++ gs/jpeg/makefile.vms | 141 + gs/jpeg/makefile.wat | 229 ++ gs/jpeg/makljpeg.st | 69 + gs/jpeg/maktjpeg.st | 30 + gs/jpeg/makvms.opt | 4 + gs/jpeg/rdbmp.c | 439 +++ gs/jpeg/rdcolmap.c | 253 ++ gs/jpeg/rdgif.c | 683 ++++ gs/jpeg/rdjpgcom | Bin 0 -> 7666 bytes gs/jpeg/rdjpgcom.1 | 45 + gs/jpeg/rdjpgcom.c | 476 +++ gs/jpeg/rdppm.c | 450 +++ gs/jpeg/rdrle.c | 387 +++ gs/jpeg/rdswitch.c | 332 ++ gs/jpeg/rdtarga.c | 500 +++ gs/jpeg/structure.doc | 948 ++++++ gs/jpeg/testimg.gif | Bin 0 -> 21846 bytes gs/jpeg/testimg.jpg | Bin 0 -> 5756 bytes gs/jpeg/testimg.ppm | 4 + gs/jpeg/testimgp.jpg | Bin 0 -> 5645 bytes gs/jpeg/testorig.jpg | Bin 0 -> 5770 bytes gs/jpeg/testprog.jpg | Bin 0 -> 5655 bytes gs/jpeg/usage.doc | 475 +++ gs/jpeg/wizard.doc | 211 ++ gs/jpeg/wrbmp.c | 442 +++ gs/jpeg/wrgif.c | 505 +++ gs/jpeg/wrjpgcom | Bin 0 -> 8922 bytes gs/jpeg/wrjpgcom.1 | 103 + gs/jpeg/wrjpgcom.c | 575 ++++ gs/jpeg/wrppm.c | 268 ++ gs/jpeg/wrrle.c | 305 ++ gs/jpeg/wrtarga.c | 253 ++ gs/language.txt | 768 +++++ gs/lib.txt | 363 +++ gs/lib/Fontmap | 399 +++ gs/lib/Fontmap.ATB | 169 + gs/lib/Fontmap.ATM | 186 ++ gs/lib/Fontmap.GS | 399 +++ gs/lib/Fontmap.OS2 | 215 ++ gs/lib/Fontmap.OSF | 163 + gs/lib/Fontmap.Sol | 482 +++ gs/lib/Fontmap.Ult | 143 + gs/lib/Fontmap.VMS | 120 + gs/lib/_vc_make.bat | 5 + gs/lib/_wm_cdir.bat | 1 + gs/lib/acctest.ps | 99 + gs/lib/align.ps | 71 + gs/lib/alphabet.ps | 56 + gs/lib/bdftops | 2 + gs/lib/bdftops.bat | 1 + gs/lib/bdftops.ps | 793 +++++ gs/lib/bjc610a0.upp | 44 + gs/lib/bjc610a1.upp | 44 + gs/lib/bjc610a2.upp | 44 + gs/lib/bjc610a3.upp | 44 + gs/lib/bjc610a4.upp | 45 + gs/lib/bjc610a5.upp | 44 + gs/lib/bjc610a6.upp | 44 + gs/lib/bjc610a7.upp | 44 + gs/lib/bjc610a8.upp | 44 + gs/lib/bjc610b1.upp | 44 + gs/lib/bjc610b2.upp | 44 + gs/lib/bjc610b3.upp | 44 + gs/lib/bjc610b4.upp | 45 + gs/lib/bjc610b6.upp | 44 + gs/lib/bjc610b7.upp | 44 + gs/lib/bjc610b8.upp | 44 + gs/lib/bughunt.sh | 119 + gs/lib/caption.ps | 57 + gs/lib/cbjc600.ppd | 404 +++ gs/lib/cbjc800.ppd | 389 +++ gs/lib/cdj550.upp | 48 + gs/lib/cheq.ps | 945 ++++++ gs/lib/chess.ps | 101 + gs/lib/colorcir.ps | 120 + gs/lib/cp.bat | 10 + gs/lib/decrypt.ps | 13 + gs/lib/docie.ps | 219 ++ gs/lib/escher.ps | 379 +++ gs/lib/font2c | 2 + gs/lib/font2c.bat | 1 + gs/lib/font2c.ps | 686 ++++ gs/lib/golfer.ps | 1398 ++++++++ gs/lib/grayalph.ps | 61 + gs/lib/gs_btokn.ps | 283 ++ gs/lib/gs_ccfnt.ps | 93 + gs/lib/gs_cff.ps | 605 ++++ gs/lib/gs_cidfn.ps | 428 +++ gs/lib/gs_cmap.ps | 242 ++ gs/lib/gs_cmdl.ps | 181 ++ gs/lib/gs_dbt_e.ps | 60 + gs/lib/gs_diskf.ps | 225 ++ gs/lib/gs_dpnxt.ps | 30 + gs/lib/gs_dps.ps | 54 + gs/lib/gs_dps1.ps | 136 + gs/lib/gs_dps2.ps | 203 ++ gs/lib/gs_epsf.ps | 60 + gs/lib/gs_fform.ps | 110 + gs/lib/gs_fonts.ps | 912 ++++++ gs/lib/gs_init.ps | 1458 +++++++++ gs/lib/gs_iso_e.ps | 67 + gs/lib/gs_kanji.ps | 159 + gs/lib/gs_ksb_e.ps | 65 + gs/lib/gs_l2img.ps | 186 ++ gs/lib/gs_lev2.ps | 459 +++ gs/lib/gs_mex_e.ps | 65 + gs/lib/gs_mro_e.ps | 58 + gs/lib/gs_pdf.ps | 646 ++++ gs/lib/gs_pdf_e.ps | 45 + gs/lib/gs_pdfwr.ps | 377 +++ gs/lib/gs_pfile.ps | 128 + gs/lib/gs_res.ps | 665 ++++ gs/lib/gs_setpd.ps | 667 ++++ gs/lib/gs_statd.ps | 270 ++ gs/lib/gs_std_e.ps | 74 + gs/lib/gs_sym_e.ps | 84 + gs/lib/gs_ttf.ps | 461 +++ gs/lib/gs_typ42.ps | 45 + gs/lib/gs_type1.ps | 136 + gs/lib/gs_wan_e.ps | 45 + gs/lib/gs_wl1_e.ps | 67 + gs/lib/gs_wl2_e.ps | 67 + gs/lib/gs_wl5_e.ps | 67 + gs/lib/gsbj | 2 + gs/lib/gsbj.bat | 1 + gs/lib/gsdj | 2 + gs/lib/gsdj.bat | 1 + gs/lib/gsdj500 | 2 + gs/lib/gsdj500.bat | 1 + gs/lib/gslj | 2 + gs/lib/gslj.bat | 1 + gs/lib/gslp | 2 + gs/lib/gslp.bat | 1 + gs/lib/gslp.ps | 537 +++ gs/lib/gsnd | 2 + gs/lib/gsnd.bat | 1 + gs/lib/gsndt.bat | 1 + gs/lib/gst.bat | 1 + gs/lib/gstt.bat | 1 + gs/lib/impath.ps | 180 + gs/lib/landscap.ps | 29 + gs/lib/level1.ps | 2 + gs/lib/lines.ps | 152 + gs/lib/lprsetup.sh | 188 ++ gs/lib/markhint.ps | 131 + gs/lib/markpath.ps | 60 + gs/lib/mv.bat | 1 + gs/lib/necp2x.upp | 35 + gs/lib/necp2x6.upp | 35 + gs/lib/packfile.ps | 334 ++ gs/lib/pcharstr.ps | 127 + gs/lib/pdf2dsc | 24 + gs/lib/pdf2dsc.ps | 120 + gs/lib/pdf2ps | 19 + gs/lib/pdf2ps.bat | 21 + gs/lib/pdf_2ps.ps | 273 ++ gs/lib/pdf_base.ps | 456 +++ gs/lib/pdf_draw.ps | 449 +++ gs/lib/pdf_font.ps | 454 +++ gs/lib/pdf_main.ps | 507 +++ gs/lib/pdf_sec.ps | 58 + gs/lib/pfbtogs.ps | 113 + gs/lib/pftogsf.bat | 18 + gs/lib/pj-gs.sh | 288 ++ gs/lib/ppath.ps | 55 + gs/lib/prfont.ps | 153 + gs/lib/printafm | 6 + gs/lib/printafm.ps | 146 + gs/lib/ps2ai.ps | 542 ++++ gs/lib/ps2ascii | 16 + gs/lib/ps2ascii.bat | 12 + gs/lib/ps2ascii.ps | 1310 ++++++++ gs/lib/ps2epsi | 82 + gs/lib/ps2epsi.bat | 25 + gs/lib/ps2epsi.ps | 253 ++ gs/lib/ps2pdf | 33 + gs/lib/ps2pdf.bat | 62 + gs/lib/pv.sh | 36 + gs/lib/quit.ps | 1 + gs/lib/ras1.upp | 8 + gs/lib/ras24.upp | 8 + gs/lib/ras3.upp | 8 + gs/lib/ras32.upp | 8 + gs/lib/ras4.upp | 8 + gs/lib/ras8m.upp | 8 + gs/lib/rm.bat | 9 + gs/lib/rollconv.ps | 372 +++ gs/lib/showchar.ps | 94 + gs/lib/showpage.ps | 1 + gs/lib/snowflak.ps | 90 + gs/lib/stc.upp | 53 + gs/lib/stc1520h.upp | 58 + gs/lib/stc2.upp | 53 + gs/lib/stc2_h.upp | 53 + gs/lib/stc2s_h.upp | 57 + gs/lib/stc500p.upp | 48 + gs/lib/stc500ph.upp | 48 + gs/lib/stc600ih.upp | 58 + gs/lib/stc600p.upp | 34 + gs/lib/stc600pl.upp | 34 + gs/lib/stc800ih.upp | 58 + gs/lib/stc800p.upp | 34 + gs/lib/stc800pl.upp | 34 + gs/lib/stc_h.upp | 53 + gs/lib/stc_l.upp | 26 + gs/lib/stcany.upp | 24 + gs/lib/stcinfo.ps | 799 +++++ gs/lib/stcolor.ps | 171 + gs/lib/sysvlp.sh | 45 + gs/lib/t1tot2.ps | 485 +++ gs/lib/test.ps | 9 + gs/lib/tiger.ps | 2733 ++++++++++++++++ gs/lib/traceimg.ps | 43 + gs/lib/traceop.ps | 79 + gs/lib/type1enc.ps | 66 + gs/lib/type1ops.ps | 238 ++ gs/lib/uninfo.ps | 221 ++ gs/lib/unix-lpr.sh | 160 + gs/lib/unprot.ps | 61 + gs/lib/viewcmyk.ps | 68 + gs/lib/viewgif.ps | 162 + gs/lib/viewjpeg.ps | 144 + gs/lib/viewpbm.ps | 135 + gs/lib/viewpcx.ps | 133 + gs/lib/viewps2a.ps | 33 + gs/lib/waterfal.ps | 74 + gs/lib/wftopfa | 2 + gs/lib/wftopfa.ps | 304 ++ gs/lib/winmaps.ps | 107 + gs/lib/wmakebat.bat | 2 + gs/lib/wrfont.ps | 663 ++++ gs/lib/writecff.ps | 366 +++ gs/lib/zeroline.ps | 101 + gs/libpng/CHANGES | 169 + gs/libpng/README | 166 + gs/libpng/TODO | 19 + gs/libpng/ansi2knr.c | 488 +++ gs/libpng/build.bat | 2 + gs/libpng/descrip.mms | 52 + gs/libpng/example.c | 667 ++++ gs/libpng/libpng.a | Bin 0 -> 105305 bytes gs/libpng/libpng.txt | 1519 +++++++++ gs/libpng/makefile | 68 + gs/libpng/makefile.aco | 221 ++ gs/libpng/makefile.ama | 42 + gs/libpng/makefile.atr | 31 + gs/libpng/makefile.bor | 168 + gs/libpng/makefile.dj2 | 52 + gs/libpng/makefile.elf | 86 + gs/libpng/makefile.knr | 73 + gs/libpng/makefile.mip | 62 + gs/libpng/makefile.msc | 86 + gs/libpng/makefile.std | 68 + gs/libpng/makefile.sun | 72 + gs/libpng/makefile.tc | 78 + gs/libpng/makevms.com | 125 + gs/libpng/png.c | 358 ++ gs/libpng/png.h | 1835 +++++++++++ gs/libpng/pngconf.h | 445 +++ gs/libpng/pngerror.c | 112 + gs/libpng/pngget.c | 300 ++ gs/libpng/pngmem.c | 311 ++ gs/libpng/pngpread.c | 1102 +++++++ gs/libpng/pngread.c | 750 +++++ gs/libpng/pngrio.c | 137 + gs/libpng/pngrtran.c | 3153 ++++++++++++++++++ gs/libpng/pngrutil.c | 2137 ++++++++++++ gs/libpng/pngset.c | 312 ++ gs/libpng/pngtest | Bin 0 -> 105015 bytes gs/libpng/pngtest.c | 377 +++ gs/libpng/pngtest.png | Bin 0 -> 8634 bytes gs/libpng/pngtrans.c | 565 ++++ gs/libpng/pngwio.c | 193 ++ gs/libpng/pngwrite.c | 847 +++++ gs/libpng/pngwtran.c | 392 +++ gs/libpng/pngwutil.c | 1917 +++++++++++ gs/make.txt | 1540 +++++++++ gs/man/ansi2knr.1 | 36 + gs/man/gs.1 | 406 +++ gs/man/pdf2dsc.1 | 52 + gs/man/pdf2ps.1 | 21 + gs/man/ps2ascii.1 | 37 + gs/man/ps2epsi.1 | 100 + gs/man/ps2pdf.1 | 35 + gs/new-user.txt | 570 ++++ gs/news | 5241 ++++++++++++++++++++++++++++++ gs/ps2image.ps | 4 + gs/ps2pdf.txt | 110 + gs/psfiles.txt | 241 ++ gs/public.txt | 75 + gs/readme | 187 ++ gs/src/_vc_temp.mak | 10 + gs/src/ansi2knr.c | 546 ++++ gs/src/ansihead.mak | 283 ++ gs/src/append_l.com | 19 + gs/src/bcc32.cfg | 5 + gs/src/bcwin32.mak | 434 +++ gs/src/bench.c | 360 ++ gs/src/bfont.h | 63 + gs/src/bseq.h | 61 + gs/src/btoken.h | 60 + gs/src/cc-head.mak | 287 ++ gs/src/ccfont.h | 93 + gs/src/ccgs | 40 + gs/src/cfonts.mak | 442 +++ gs/src/copy_one.com | 14 + gs/src/cp.cmd | 2 + gs/src/ctype_.h | 26 + gs/src/devs.mak | 1626 ++++++++++ gs/src/dgc-head.mak | 267 ++ gs/src/dirent_.h | 46 + gs/src/dodebug.h | 29 + gs/src/dos_.h | 77 + gs/src/dpmainc.c | 310 ++ gs/src/dstack.h | 279 ++ gs/src/dvx-gcc.mak | 5696 ++++++++++++++++++++++++++++++++ gs/src/dvx-head.mak | 70 + gs/src/dvx-tail.mak | 91 + gs/src/dw32c.def | 6 + gs/src/dwdll.cpp | 343 ++ gs/src/dwdll.h | 118 + gs/src/dwimg.cpp | 415 +++ gs/src/dwimg.h | 51 + gs/src/dwmain.cpp | 412 +++ gs/src/dwmain.h | 5 + gs/src/dwmain.rc | 30 + gs/src/dwmain16.def | 7 + gs/src/dwmain32.def | 7 + gs/src/dwmainc.cpp | 219 ++ gs/src/dwnodll.cpp | 349 ++ gs/src/dwtext.cpp | 964 ++++++ gs/src/dwtext.h | 144 + gs/src/echogs.c | 294 ++ gs/src/errno_.h | 30 + gs/src/errors.h | 177 + gs/src/estack.h | 135 + gs/src/files.h | 137 + gs/src/fname.h | 33 + gs/src/gcc-head.mak | 295 ++ gs/src/gconf.c | 121 + gs/src/gdebug.h | 113 + gs/src/gdev3852.c | 187 ++ gs/src/gdev3b1.c | 791 +++++ gs/src/gdev4081.c | 95 + gs/src/gdev4693.c | 168 + gs/src/gdev8510.c | 144 + gs/src/gdev8bcm.c | 76 + gs/src/gdev8bcm.h | 68 + gs/src/gdevabuf.c | 364 +++ gs/src/gdevadmp.c | 407 +++ gs/src/gdevasyn.c | 661 ++++ gs/src/gdevbbox.c | 759 +++++ gs/src/gdevbbox.h | 74 + gs/src/gdevbgi.c | 661 ++++ gs/src/gdevbit.c | 341 ++ gs/src/gdevbj10.c | 385 +++ gs/src/gdevbjc.h | 282 ++ gs/src/gdevbmp.c | 264 ++ gs/src/gdevccr.c | 294 ++ gs/src/gdevcdj.c | 3916 ++++++++++++++++++++++ gs/src/gdevcgm.c | 474 +++ gs/src/gdevcgml.c | 990 ++++++ gs/src/gdevcgml.h | 403 +++ gs/src/gdevcgmx.h | 182 ++ gs/src/gdevcif.c | 98 + gs/src/gdevcp50.c | 223 ++ gs/src/gdevddrw.c | 477 +++ gs/src/gdevdfax.c | 111 + gs/src/gdevdflt.c | 911 ++++++ gs/src/gdevdjet.c | 608 ++++ gs/src/gdevdjtc.c | 276 ++ gs/src/gdevdm24.c | 289 ++ gs/src/gdevegaa.asm | 277 ++ gs/src/gdevemap.c | 59 + gs/src/gdevepsc.c | 458 +++ gs/src/gdevepsn.c | 497 +++ gs/src/gdevescp.c | 415 +++ gs/src/gdevevga.c | 108 + gs/src/gdevherc.c | 482 +++ gs/src/gdevht.c | 212 ++ gs/src/gdevht.h | 42 + gs/src/gdevimgn.c | 572 ++++ gs/src/gdevjpeg.c | 288 ++ gs/src/gdevl256.c | 311 ++ gs/src/gdevlbp8.c | 213 ++ gs/src/gdevlj56.c | 269 ++ gs/src/gdevlp8k.c | 412 +++ gs/src/gdevm1.c | 685 ++++ gs/src/gdevm16.c | 149 + gs/src/gdevm2.c | 239 ++ gs/src/gdevm24.c | 490 +++ gs/src/gdevm32.c | 228 ++ gs/src/gdevm4.c | 202 ++ gs/src/gdevm8.c | 220 ++ gs/src/gdevmem.c | 377 +++ gs/src/gdevmem.h | 214 ++ gs/src/gdevmgr.c | 433 +++ gs/src/gdevmgr.h | 116 + gs/src/gdevmiff.c | 84 + gs/src/gdevmpla.c | 177 + gs/src/gdevmrop.c | 1333 ++++++++ gs/src/gdevmrop.h | 63 + gs/src/gdevmswn.c | 477 +++ gs/src/gdevmswn.h | 109 + gs/src/gdevmsxf.c | 451 +++ gs/src/gdevn533.c | 209 ++ gs/src/gdevnfwd.c | 560 ++++ gs/src/gdevnp6.c | 257 ++ gs/src/gdevo182.c | 311 ++ gs/src/gdevokii.c | 327 ++ gs/src/gdevos2p.c | 701 ++++ gs/src/gdevp2up.c | 148 + gs/src/gdevpbm.c | 717 ++++ gs/src/gdevpccm.c | 173 + gs/src/gdevpccm.h | 34 + gs/src/gdevpcfb.c | 900 +++++ gs/src/gdevpcfb.h | 191 ++ gs/src/gdevpcl.c | 216 ++ gs/src/gdevpcl.h | 42 + gs/src/gdevpcx.c | 461 +++ gs/src/gdevpdf.c | 1337 ++++++++ gs/src/gdevpdfd.c | 381 +++ gs/src/gdevpdfi.c | 1023 ++++++ gs/src/gdevpdfm.c | 788 +++++ gs/src/gdevpdfp.c | 189 ++ gs/src/gdevpdft.c | 755 +++++ gs/src/gdevpdfx.h | 445 +++ gs/src/gdevpe.c | 362 +++ gs/src/gdevpipe.c | 69 + gs/src/gdevpjet.c | 251 ++ gs/src/gdevpm.c | 1262 ++++++++ gs/src/gdevpm.h | 35 + gs/src/gdevpng.c | 258 ++ gs/src/gdevprn.c | 919 ++++++ gs/src/gdevprn.h | 524 +++ gs/src/gdevprna.h | 174 + gs/src/gdevps.c | 798 +++++ gs/src/gdevpsdf.c | 613 ++++ gs/src/gdevpsdf.h | 191 ++ gs/src/gdevpsim.c | 246 ++ gs/src/gdevpstr.c | 143 + gs/src/gdevpstr.h | 73 + gs/src/gdevpx.c | 1566 +++++++++ gs/src/gdevpxat.h | 133 + gs/src/gdevpxen.h | 239 ++ gs/src/gdevpxop.h | 108 + gs/src/gdevrrgb.c | 230 ++ gs/src/gdevrun.c | 434 +++ gs/src/gdevs3ga.c | 239 ++ gs/src/gdevsco.c | 275 ++ gs/src/gdevsgi.c | 220 ++ gs/src/gdevsgi.h | 66 + gs/src/gdevsj48.c | 293 ++ gs/src/gdevsnfb.c | 116 + gs/src/gdevsppr.c | 188 ++ gs/src/gdevstc.c | 3552 ++++++++++++++++++++ gs/src/gdevstc.h | 252 ++ gs/src/gdevstc1.c | 127 + gs/src/gdevstc2.c | 427 +++ gs/src/gdevstc3.c | 107 + gs/src/gdevstc4.c | 301 ++ gs/src/gdevsun.c | 685 ++++ gs/src/gdevsvga.c | 952 ++++++ gs/src/gdevsvga.h | 92 + gs/src/gdevtfax.c | 424 +++ gs/src/gdevtfnx.c | 186 ++ gs/src/gdevtifs.c | 238 ++ gs/src/gdevtifs.h | 206 ++ gs/src/gdevtknk.c | 253 ++ gs/src/gdevupd.c | 6269 +++++++++++++++++++++++++++++++++++ gs/src/gdevvec.c | 852 +++++ gs/src/gdevvec.h | 328 ++ gs/src/gdevvglb.c | 389 +++ gs/src/gdevwddb.c | 604 ++++ gs/src/gdevwdib.c | 674 ++++ gs/src/gdevwpr2.c | 804 +++++ gs/src/gdevwprn.c | 665 ++++ gs/src/gdevx.c | 1250 +++++++ gs/src/gdevx.h | 177 + gs/src/gdevxalt.c | 723 +++++ gs/src/gdevxini.c | 1001 ++++++ gs/src/gdevxxf.c | 465 +++ gs/src/genarch.c | 122 + gs/src/genconf.c | 640 ++++ gs/src/geninit.c | 231 ++ gs/src/ghost.h | 22 + gs/src/gp.h | 196 ++ gs/src/gp_dosfb.c | 200 ++ gs/src/gp_dosfe.c | 145 + gs/src/gp_dosfs.c | 86 + gs/src/gp_dvx.c | 110 + gs/src/gp_itbc.c | 212 ++ gs/src/gp_iwatc.c | 154 + gs/src/gp_msdos.c | 123 + gs/src/gp_msio.c | 200 ++ gs/src/gp_mslib.c | 45 + gs/src/gp_mswin.c | 852 +++++ gs/src/gp_mswin.h | 52 + gs/src/gp_nofb.c | 49 + gs/src/gp_ntfs.c | 192 ++ gs/src/gp_os2.c | 907 ++++++ gs/src/gp_os9.c | 138 + gs/src/gp_sysv.c | 66 + gs/src/gp_unifn.c | 53 + gs/src/gp_unifs.c | 419 +++ gs/src/gp_unix.c | 165 + gs/src/gp_vms.c | 422 +++ gs/src/gp_win32.c | 253 ++ gs/src/gpcheck.h | 53 + gs/src/gpsync.h | 50 + gs/src/gs.c | 68 + gs/src/gs.mak | 339 ++ gs/src/gs16spl.c | 220 ++ gs/src/gs16spl.def | 7 + gs/src/gs16spl.rc | 38 + gs/src/gsalloc.c | 1282 ++++++++ gs/src/gsalloc.h | 53 + gs/src/gsargs.c | 159 + gs/src/gsargs.h | 70 + gs/src/gsbitmap.h | 187 ++ gs/src/gsbitops.c | 601 ++++ gs/src/gsbitops.h | 173 + gs/src/gsbittab.c | 126 + gs/src/gsbittab.h | 73 + gs/src/gsccode.h | 64 + gs/src/gsccolor.h | 46 + gs/src/gscdef.c | 71 + gs/src/gscdefs.h | 50 + gs/src/gschar.c | 1432 ++++++++ gs/src/gschar.h | 123 + gs/src/gschar0.c | 373 +++ gs/src/gscie.c | 1189 +++++++ gs/src/gscie.h | 472 +++ gs/src/gscolor.c | 366 +++ gs/src/gscolor.h | 40 + gs/src/gscolor1.c | 229 ++ gs/src/gscolor1.h | 44 + gs/src/gscolor2.c | 198 ++ gs/src/gscolor2.h | 127 + gs/src/gscoord.c | 471 +++ gs/src/gscoord.h | 51 + gs/src/gscpm.h | 33 + gs/src/gscrypt1.h | 45 + gs/src/gscsel.h | 37 + gs/src/gscsepr.c | 176 + gs/src/gscsepr.h | 22 + gs/src/gscspace.h | 189 ++ gs/src/gsdcolor.h | 310 ++ gs/src/gsdevice.c | 448 +++ gs/src/gsdevice.h | 88 + gs/src/gsdevmem.c | 216 ++ gs/src/gsdll.c | 192 ++ gs/src/gsdll.h | 128 + gs/src/gsdll16.def | 20 + gs/src/gsdll16.rc | 26 + gs/src/gsdll2.def | 12 + gs/src/gsdll2.rc | 22 + gs/src/gsdll32.def | 17 + gs/src/gsdll32.rc | 26 + gs/src/gsdparam.c | 615 ++++ gs/src/gsdps.c | 129 + gs/src/gsdps.h | 26 + gs/src/gsdps1.c | 231 ++ gs/src/gsdsc.c | 315 ++ gs/src/gsdsrc.c | 107 + gs/src/gsdsrc.h | 101 + gs/src/gserror.h | 35 + gs/src/gserrors.h | 43 + gs/src/gserver.c | 290 ++ gs/src/gsexit.h | 34 + gs/src/gsfcmap.c | 153 + gs/src/gsfcmap.h | 58 + gs/src/gsfemu.c | 722 +++++ gs/src/gsflip.c | 293 ++ gs/src/gsflip.h | 35 + gs/src/gsfont.c | 527 +++ gs/src/gsfont.h | 66 + gs/src/gsfont0.c | 121 + gs/src/gsfunc.c | 68 + gs/src/gsfunc.h | 114 + gs/src/gsfunc0.c | 246 ++ gs/src/gsfunc0.h | 59 + gs/src/gsgc.h | 83 + gs/src/gsgraph.icx | 48 + gs/src/gshsb.c | 136 + gs/src/gshsb.h | 23 + gs/src/gsht.c | 552 ++++ gs/src/gsht.h | 70 + gs/src/gsht1.c | 356 ++ gs/src/gsht1.h | 53 + gs/src/gshtscr.c | 529 +++ gs/src/gsimage.c | 311 ++ gs/src/gsimage.h | 45 + gs/src/gsimpath.c | 183 ++ gs/src/gsinit.c | 69 + gs/src/gsio.h | 60 + gs/src/gsiodev.c | 265 ++ gs/src/gsiparam.h | 167 + gs/src/gsjconf.h | 59 + gs/src/gsjerror.c | 27 + gs/src/gsjerror.h | 383 +++ gs/src/gsjmorec.h | 50 + gs/src/gsjpglib.h | 938 ++++++ gs/src/gslib.c | 549 ++++ gs/src/gslib.h | 34 + gs/src/gsline.c | 302 ++ gs/src/gsline.h | 66 + gs/src/gslparam.h | 44 + gs/src/gsmatrix.c | 426 +++ gs/src/gsmatrix.h | 75 + gs/src/gsmdebug.h | 45 + gs/src/gsmemfix.c | 414 +++ gs/src/gsmemfix.h | 64 + gs/src/gsmemlok.c | 320 ++ gs/src/gsmemlok.h | 52 + gs/src/gsmemory.c | 472 +++ gs/src/gsmemory.h | 390 +++ gs/src/gsmemraw.h | 73 + gs/src/gsmisc.c | 815 +++++ gs/src/gsnogc.c | 329 ++ gs/src/gsos2.def | 3 + gs/src/gsos2.icx | 209 ++ gs/src/gsos2.rc | 22 + gs/src/gspaint.c | 308 ++ gs/src/gspaint.h | 31 + gs/src/gsparam.c | 558 ++++ gs/src/gsparam.h | 445 +++ gs/src/gsparams.c | 400 +++ gs/src/gsparams.h | 44 + gs/src/gspath.c | 416 +++ gs/src/gspath.h | 72 + gs/src/gspath1.c | 376 +++ gs/src/gspath2.h | 30 + gs/src/gspcolor.c | 991 ++++++ gs/src/gspenum.h | 34 + gs/src/gspmdrv.c | 1252 +++++++ gs/src/gspmdrv.def | 3 + gs/src/gspmdrv.h | 28 + gs/src/gspmdrv.icx | 209 ++ gs/src/gspmdrv.rc | 40 + gs/src/gsrefct.h | 136 + gs/src/gsrop.c | 96 + gs/src/gsrop.h | 43 + gs/src/gsropt.h | 189 ++ gs/src/gsroptab.c | 372 +++ gs/src/gsstate.c | 1046 ++++++ gs/src/gsstate.h | 76 + gs/src/gsstruct.h | 672 ++++ gs/src/gstext.icx | 48 + gs/src/gstype1.c | 588 ++++ gs/src/gstype1.h | 250 ++ gs/src/gstype2.c | 658 ++++ gs/src/gstype42.c | 444 +++ gs/src/gstypes.h | 79 + gs/src/gsuid.h | 67 + gs/src/gsutil.c | 216 ++ gs/src/gsutil.h | 61 + gs/src/gswin.rc | 29 + gs/src/gswin32.rc | 36 + gs/src/gswin386.rc | 4 + gs/src/gsxfont.h | 38 + gs/src/gx.h | 38 + gs/src/gxacpath.c | 447 +++ gs/src/gxalloc.h | 373 +++ gs/src/gxarith.h | 78 + gs/src/gxband.h | 63 + gs/src/gxbcache.c | 142 + gs/src/gxbcache.h | 116 + gs/src/gxbitmap.h | 120 + gs/src/gxccache.c | 440 +++ gs/src/gxccman.c | 763 +++++ gs/src/gxchar.h | 155 + gs/src/gxcht.c | 585 ++++ gs/src/gxcindex.h | 96 + gs/src/gxclbits.c | 742 +++++ gs/src/gxcldev.h | 636 ++++ gs/src/gxclfile.c | 145 + gs/src/gxclimag.c | 1234 +++++++ gs/src/gxclio.h | 89 + gs/src/gxclip2.c | 375 +++ gs/src/gxclip2.h | 56 + gs/src/gxclist.c | 1187 +++++++ gs/src/gxclist.h | 301 ++ gs/src/gxcllzw.c | 47 + gs/src/gxclmem.c | 1129 +++++++ gs/src/gxclmem.h | 141 + gs/src/gxclpage.c | 113 + gs/src/gxclpage.h | 53 + gs/src/gxclpath.c | 1230 +++++++ gs/src/gxclpath.h | 201 ++ gs/src/gxclread.c | 2491 ++++++++++++++ gs/src/gxclrect.c | 616 ++++ gs/src/gxclzlib.c | 50 + gs/src/gxcmap.c | 776 +++++ gs/src/gxcmap.h | 95 + gs/src/gxcolor2.h | 72 + gs/src/gxcoord.h | 33 + gs/src/gxcpath.c | 1020 ++++++ gs/src/gxcpath.h | 119 + gs/src/gxcspace.h | 172 + gs/src/gxctable.c | 140 + gs/src/gxctable.h | 58 + gs/src/gxcvalue.h | 41 + gs/src/gxdcconv.c | 146 + gs/src/gxdcconv.h | 31 + gs/src/gxdcolor.c | 210 ++ gs/src/gxdcolor.h | 184 ++ gs/src/gxdda.h | 145 + gs/src/gxdevice.h | 1004 ++++++ gs/src/gxdevmem.h | 150 + gs/src/gxdevrop.h | 31 + gs/src/gxdht.h | 251 ++ gs/src/gxdither.c | 478 +++ gs/src/gxdither.h | 78 + gs/src/gxfarith.h | 129 + gs/src/gxfcache.h | 250 ++ gs/src/gxfcmap.h | 93 + gs/src/gxfill.c | 1507 +++++++++ gs/src/gxfixed.h | 227 ++ gs/src/gxfmap.h | 92 + gs/src/gxfont.h | 207 ++ gs/src/gxfont0.h | 66 + gs/src/gxfont1.h | 105 + gs/src/gxfont42.h | 58 + gs/src/gxfrac.h | 91 + gs/src/gxftype.h | 51 + gs/src/gxfunc.h | 55 + gs/src/gxhint1.c | 254 ++ gs/src/gxhint2.c | 402 +++ gs/src/gxhint3.c | 518 +++ gs/src/gxht.c | 458 +++ gs/src/gxht.h | 142 + gs/src/gxhttile.h | 47 + gs/src/gxhttype.h | 38 + gs/src/gximage.h | 275 ++ gs/src/gximage0.c | 200 ++ gs/src/gximage2.c | 470 +++ gs/src/gximage3.c | 332 ++ gs/src/gximage4.c | 299 ++ gs/src/gximage5.c | 243 ++ gs/src/gxiodev.h | 172 + gs/src/gxistate.h | 216 ++ gs/src/gxline.h | 70 + gs/src/gxlum.h | 26 + gs/src/gxmatrix.h | 76 + gs/src/gxobj.h | 209 ++ gs/src/gxop1.h | 69 + gs/src/gxpageq.c | 305 ++ gs/src/gxpageq.h | 186 ++ gs/src/gxpaint.c | 65 + gs/src/gxpaint.h | 108 + gs/src/gxpath.c | 552 ++++ gs/src/gxpath.h | 193 ++ gs/src/gxpath2.c | 452 +++ gs/src/gxpcache.h | 52 + gs/src/gxpcmap.c | 583 ++++ gs/src/gxpcolor.h | 125 + gs/src/gxpcopy.c | 806 +++++ gs/src/gxpdash.c | 187 ++ gs/src/gxpflat.c | 452 +++ gs/src/gxsample.c | 186 ++ gs/src/gxsample.h | 71 + gs/src/gxstate.h | 76 + gs/src/gxstroke.c | 1282 ++++++++ gs/src/gxsync.c | 140 + gs/src/gxsync.h | 73 + gs/src/gxtmap.h | 37 + gs/src/gxtype1.c | 419 +++ gs/src/gxtype1.h | 320 ++ gs/src/gxxfont.h | 167 + gs/src/gzacpath.h | 50 + gs/src/gzcpath.h | 47 + gs/src/gzline.h | 29 + gs/src/gzpath.h | 293 ++ gs/src/gzstate.h | 121 + gs/src/ialloc.c | 259 ++ gs/src/ialloc.h | 117 + gs/src/iastate.h | 24 + gs/src/iastruct.h | 22 + gs/src/ibnum.c | 208 ++ gs/src/ibnum.h | 59 + gs/src/iccfont.c | 313 ++ gs/src/iccinit0.c | 25 + gs/src/icfontab.c | 51 + gs/src/ichar.h | 62 + gs/src/icharout.h | 48 + gs/src/icie.h | 72 + gs/src/icolor.h | 43 + gs/src/iconf.c | 73 + gs/src/icontext.c | 117 + gs/src/icontext.h | 73 + gs/src/icsmap.h | 34 + gs/src/idebug.c | 262 ++ gs/src/idebug.h | 36 + gs/src/idict.c | 1003 ++++++ gs/src/idict.h | 240 ++ gs/src/idparam.c | 342 ++ gs/src/idparam.h | 75 + gs/src/ifilter.h | 72 + gs/src/ifont.h | 82 + gs/src/ifunc.h | 48 + gs/src/igc.c | 1249 +++++++ gs/src/igc.h | 79 + gs/src/igcref.c | 682 ++++ gs/src/igcstr.c | 362 +++ gs/src/igcstr.h | 30 + gs/src/igstate.h | 162 + gs/src/iht.h | 26 + gs/src/iimage.h | 36 + gs/src/iinit.c | 462 +++ gs/src/ilevel.h | 24 + gs/src/ilocate.c | 405 +++ gs/src/imain.c | 612 ++++ gs/src/imain.h | 266 ++ gs/src/imainarg.c | 704 ++++ gs/src/imainarg.h | 47 + gs/src/imemory.h | 100 + gs/src/iminst.h | 72 + gs/src/iname.c | 602 ++++ gs/src/iname.h | 100 + gs/src/inamedef.h | 207 ++ gs/src/int.mak | 1223 +++++++ gs/src/interp.c | 1565 +++++++++ gs/src/interp.h | 71 + gs/src/ipacked.h | 124 + gs/src/iparam.c | 1053 ++++++ gs/src/iparam.h | 99 + gs/src/iparray.h | 31 + gs/src/ireclaim.c | 200 ++ gs/src/iref.h | 376 +++ gs/src/isave.c | 987 ++++++ gs/src/isave.h | 106 + gs/src/iscan.c | 1035 ++++++ gs/src/iscan.h | 143 + gs/src/iscanbin.c | 576 ++++ gs/src/iscannum.c | 377 +++ gs/src/iscannum.h | 25 + gs/src/isstate.h | 35 + gs/src/istack.c | 500 +++ gs/src/istack.h | 248 ++ gs/src/istream.h | 32 + gs/src/istruct.h | 65 + gs/src/iutil.c | 599 ++++ gs/src/iutil.h | 107 + gs/src/iutil2.c | 95 + gs/src/iutil2.h | 41 + gs/src/iutilasm.asm | 696 ++++ gs/src/ivmspace.h | 104 + gs/src/jpeg.mak | 361 +++ gs/src/lib.mak | 1278 ++++++++ gs/src/libpng.mak | 108 + gs/src/main.h | 88 + gs/src/malloc_.h | 46 + gs/src/math_.h | 81 + gs/src/memory_.h | 81 + gs/src/msvc32.mak | 367 +++ gs/src/msvccmd.mak | 185 ++ gs/src/msvccom.mak | 225 ++ gs/src/msvclib.mak | 342 ++ gs/src/msvctail.mak | 39 + gs/src/mv.cmd | 1 + gs/src/opcheck.h | 67 + gs/src/opdef.h | 138 + gs/src/openvms.mak | 402 +++ gs/src/oper.h | 95 + gs/src/opextern.h | 103 + gs/src/os2.mak | 553 ++++ gs/src/ostack.h | 88 + gs/src/overlay.h | 38 + gs/src/rm.cmd | 9 + gs/src/rm_all.com | 15 + gs/src/rm_one.com | 9 + gs/src/sa85x.h | 40 + gs/src/sbcp.c | 232 ++ gs/src/sbhc.c | 269 ++ gs/src/sbhc.h | 85 + gs/src/sbtx.h | 34 + gs/src/sbwbs.c | 471 +++ gs/src/sbwbs.h | 66 + gs/src/scanchar.h | 64 + gs/src/scantab.c | 106 + gs/src/scf.h | 176 + gs/src/scfd.c | 781 +++++ gs/src/scfdgen.c | 203 ++ gs/src/scfdtab.c | 938 ++++++ gs/src/scfe.c | 500 +++ gs/src/scfetab.c | 156 + gs/src/scfx.h | 122 + gs/src/scommon.h | 152 + gs/src/sdct.h | 92 + gs/src/sdctc.c | 33 + gs/src/sdctd.c | 274 ++ gs/src/sdcte.c | 165 + gs/src/seexec.c | 177 + gs/src/sfilter.h | 125 + gs/src/sfilter1.c | 287 ++ gs/src/sfilter2.c | 279 ++ gs/src/sfxboth.c | 25 + gs/src/sfxfd.c | 313 ++ gs/src/sfxstdio.c | 241 ++ gs/src/shc.c | 69 + gs/src/shc.h | 245 ++ gs/src/shcgen.c | 462 +++ gs/src/shcgen.h | 50 + gs/src/siscale.c | 483 +++ gs/src/siscale.h | 131 + gs/src/sjpeg.h | 70 + gs/src/sjpegc.c | 264 ++ gs/src/sjpegd.c | 84 + gs/src/sjpege.c | 110 + gs/src/sjpegerr.c | 80 + gs/src/slzwc.c | 42 + gs/src/slzwce.c | 155 + gs/src/slzwd.c | 368 +++ gs/src/slzwx.h | 66 + gs/src/smtf.c | 166 + gs/src/smtf.h | 38 + gs/src/spcxd.c | 72 + gs/src/spcxx.h | 25 + gs/src/spdiff.c | 297 ++ gs/src/spdiffx.h | 44 + gs/src/spngp.c | 334 ++ gs/src/spngpx.h | 50 + gs/src/srld.c | 123 + gs/src/srle.c | 194 ++ gs/src/srlx.h | 65 + gs/src/sstring.c | 435 +++ gs/src/sstring.h | 61 + gs/src/stat_.h | 46 + gs/src/std.h | 220 ++ gs/src/stdio_.h | 48 + gs/src/stdpre.h | 378 +++ gs/src/store.h | 238 ++ gs/src/stream.c | 803 +++++ gs/src/stream.h | 318 ++ gs/src/strimpl.h | 147 + gs/src/string_.h | 48 + gs/src/szlibc.c | 57 + gs/src/szlibd.c | 94 + gs/src/szlibe.c | 93 + gs/src/szlibx.h | 54 + gs/src/time_.h | 77 + gs/src/turboc.cfg | 5 + gs/src/ugcclib.mak | 158 + gs/src/unix-cc.mak | 5775 +++++++++++++++++++++++++++++++++ gs/src/unix-end.mak | 137 + gs/src/unix-gcc.mak | 5783 +++++++++++++++++++++++++++++++++ gs/src/unixansi.mak | 5771 +++++++++++++++++++++++++++++++++ gs/src/unixhead.mak | 76 + gs/src/unixtail.mak | 144 + gs/src/version.mak | 34 + gs/src/vms-cc.mak | 102 + gs/src/vms-decc.mak | 112 + gs/src/vms-gcc.mak | 99 + gs/src/vms.mak | 2245 +++++++++++++ gs/src/vmsmath.h | 37 + gs/src/watc.mak | 230 ++ gs/src/watclib.mak | 109 + gs/src/watcw32.mak | 414 +++ gs/src/wccommon.mak | 191 ++ gs/src/wctail.mak | 75 + gs/src/windows_.h | 39 + gs/src/winint.mak | 96 + gs/src/winlib.mak | 135 + gs/src/wmin.mak | 60 + gs/src/x_.h | 166 + gs/src/zarith.c | 291 ++ gs/src/zarray.c | 120 + gs/src/zbseq.c | 269 ++ gs/src/zchar.c | 661 ++++ gs/src/zchar1.c | 646 ++++ gs/src/zchar2.c | 317 ++ gs/src/zchar42.c | 174 + gs/src/zcharout.c | 234 ++ gs/src/zcid.c | 91 + gs/src/zcie.c | 627 ++++ gs/src/zcolor.c | 242 ++ gs/src/zcolor1.c | 235 ++ gs/src/zcolor2.c | 175 + gs/src/zcontext.c | 709 ++++ gs/src/zcontrol.c | 804 +++++ gs/src/zcrd.c | 311 ++ gs/src/zcsindex.c | 218 ++ gs/src/zcssepr.c | 171 + gs/src/zdevcal.c | 70 + gs/src/zdevice.c | 362 +++ gs/src/zdevice2.c | 330 ++ gs/src/zdict.c | 494 +++ gs/src/zdosio.c | 91 + gs/src/zdouble.c | 488 +++ gs/src/zdpnext.c | 438 +++ gs/src/zdps.c | 182 ++ gs/src/zdps1.c | 417 +++ gs/src/zfbcp.c | 86 + gs/src/zfcmap.c | 336 ++ gs/src/zfdctc.c | 364 +++ gs/src/zfdctd.c | 95 + gs/src/zfdcte.c | 262 ++ gs/src/zfdecode.c | 345 ++ gs/src/zfile.c | 882 +++++ gs/src/zfileio.c | 782 +++++ gs/src/zfilter.c | 417 +++ gs/src/zfilter2.c | 149 + gs/src/zfilterx.c | 314 ++ gs/src/zfname.c | 106 + gs/src/zfont.c | 423 +++ gs/src/zfont0.c | 319 ++ gs/src/zfont1.c | 241 ++ gs/src/zfont2.c | 547 ++++ gs/src/zfont42.c | 115 + gs/src/zfproc.c | 332 ++ gs/src/zfunc.c | 216 ++ gs/src/zfunc0.c | 103 + gs/src/zfzlib.c | 103 + gs/src/zgeneric.c | 496 +++ gs/src/zgstate.c | 453 +++ gs/src/zhsb.c | 59 + gs/src/zht.c | 243 ++ gs/src/zht1.c | 143 + gs/src/zht2.c | 326 ++ gs/src/zimage.c | 477 +++ gs/src/zimage2.c | 158 + gs/src/ziodev.c | 396 +++ gs/src/ziodev2.c | 134 + gs/src/zlib.mak | 162 + gs/src/zmath.c | 260 ++ gs/src/zmatrix.c | 326 ++ gs/src/zmedia2.c | 444 +++ gs/src/zmisc.c | 308 ++ gs/src/zmisc1.c | 140 + gs/src/zmisc2.c | 243 ++ gs/src/zpacked.c | 232 ++ gs/src/zpaint.c | 80 + gs/src/zpath.c | 178 + gs/src/zpath1.c | 251 ++ gs/src/zpcolor.c | 245 ++ gs/src/zrelbit.c | 310 ++ gs/src/zrop.c | 118 + gs/src/zstack.c | 262 ++ gs/src/zstring.c | 156 + gs/src/zsysvm.c | 141 + gs/src/ztoken.c | 227 ++ gs/src/ztype.c | 463 +++ gs/src/zupath.c | 561 ++++ gs/src/zusparam.c | 572 ++++ gs/src/zvmem.c | 365 +++ gs/src/zvmem2.c | 151 + gs/src/zwppm.c | 170 + gs/unix-lpr.txt | 141 + gs/use.txt | 1247 +++++++ gs/xfonts.txt | 164 + gs/zlib/ChangeLog | 239 ++ gs/zlib/INDEX | 51 + gs/zlib/Make_vms.com | 115 + gs/zlib/Makefile | 130 + gs/zlib/Makefile.in | 130 + gs/zlib/Makefile.riscos | 46 + gs/zlib/README | 99 + gs/zlib/adler32.c | 48 + gs/zlib/algorithm.doc | 105 + gs/zlib/compress.c | 57 + gs/zlib/configure | 86 + gs/zlib/crc32.c | 162 + gs/zlib/deflate.c | 1207 +++++++ gs/zlib/deflate.h | 275 ++ gs/zlib/descrip.mms | 48 + gs/zlib/example | Bin 0 -> 44638 bytes gs/zlib/example.c | 503 +++ gs/zlib/gzio.c | 523 +++ gs/zlib/infblock.c | 402 +++ gs/zlib/infblock.h | 37 + gs/zlib/infcodes.c | 247 ++ gs/zlib/infcodes.h | 27 + gs/zlib/inffast.c | 168 + gs/zlib/inffast.h | 17 + gs/zlib/inflate.c | 345 ++ gs/zlib/inftrees.c | 470 +++ gs/zlib/inftrees.h | 59 + gs/zlib/infutil.c | 87 + gs/zlib/infutil.h | 99 + gs/zlib/libz.a | Bin 0 -> 50486 bytes gs/zlib/makefile.b32 | 104 + gs/zlib/makefile.bor | 105 + gs/zlib/makefile.dj2 | 93 + gs/zlib/makefile.msc | 101 + gs/zlib/makefile.sas | 64 + gs/zlib/makefile.tc | 105 + gs/zlib/makefile.wat | 103 + gs/zlib/minigzip | Bin 0 -> 41362 bytes gs/zlib/minigzip.c | 246 ++ gs/zlib/trees.c | 1141 +++++++ gs/zlib/uncompr.c | 58 + gs/zlib/zconf.h | 184 ++ gs/zlib/zlib.def | 46 + gs/zlib/zlib.h | 780 +++++ gs/zlib/zlib.rc | 32 + gs/zlib/zutil.c | 211 ++ gs/zlib/zutil.h | 203 ++ 1230 files changed, 387163 insertions(+) create mode 100644 gs/bug-form.txt create mode 100644 gs/c-style.txt create mode 100644 gs/commprod.txt create mode 100644 gs/copying create mode 100644 gs/current.txt create mode 100644 gs/devices.txt create mode 100644 gs/dll.txt create mode 100644 gs/doc/Gs-vms.hlp create mode 100644 gs/doc/Public create mode 100644 gs/doc/ps2epsi.txt create mode 100644 gs/drivers.txt create mode 100644 gs/examples/ridt91.eps create mode 100644 gs/fonts.txt create mode 100644 gs/gdevpfax.c create mode 100644 gs/helpers.txt create mode 100644 gs/hershey.txt create mode 100644 gs/history1.txt create mode 100644 gs/history2.txt create mode 100644 gs/history3.txt create mode 100644 gs/humor.txt create mode 100644 gs/install.txt create mode 100644 gs/jpeg/Makefile create mode 100644 gs/jpeg/README create mode 100755 gs/jpeg/ansi2knr create mode 100644 gs/jpeg/ansi2knr.1 create mode 100644 gs/jpeg/ansi2knr.c create mode 100644 gs/jpeg/cderror.h create mode 100644 gs/jpeg/cdjpeg.c create mode 100644 gs/jpeg/cdjpeg.h create mode 100644 gs/jpeg/change.log create mode 100755 gs/jpeg/cjpeg create mode 100644 gs/jpeg/cjpeg.1 create mode 100644 gs/jpeg/cjpeg.c create mode 100644 gs/jpeg/ckconfig.c create mode 100644 gs/jpeg/coderules.doc create mode 100644 gs/jpeg/config.log create mode 100755 gs/jpeg/config.status create mode 100755 gs/jpeg/configure create mode 100755 gs/jpeg/djpeg create mode 100644 gs/jpeg/djpeg.1 create mode 100644 gs/jpeg/djpeg.c create mode 100644 gs/jpeg/example.c create mode 100644 gs/jpeg/filelist.doc create mode 100644 gs/jpeg/install.doc create mode 100644 gs/jpeg/jcapimin.c create mode 100644 gs/jpeg/jcapistd.c create mode 100644 gs/jpeg/jccoefct.c create mode 100644 gs/jpeg/jccolor.c create mode 100644 gs/jpeg/jcdctmgr.c create mode 100644 gs/jpeg/jchuff.c create mode 100644 gs/jpeg/jchuff.h create mode 100644 gs/jpeg/jcinit.c create mode 100644 gs/jpeg/jcmainct.c create mode 100644 gs/jpeg/jcmarker.c create mode 100644 gs/jpeg/jcmaster.c create mode 100644 gs/jpeg/jcomapi.c create mode 100644 gs/jpeg/jconfig.bcc create mode 100644 gs/jpeg/jconfig.cfg create mode 100644 gs/jpeg/jconfig.dj create mode 100644 gs/jpeg/jconfig.doc create mode 100644 gs/jpeg/jconfig.h create mode 100644 gs/jpeg/jconfig.manx create mode 100644 gs/jpeg/jconfig.mc6 create mode 100644 gs/jpeg/jconfig.sas create mode 100644 gs/jpeg/jconfig.st create mode 100644 gs/jpeg/jconfig.vms create mode 100644 gs/jpeg/jconfig.wat create mode 100644 gs/jpeg/jcparam.c create mode 100644 gs/jpeg/jcphuff.c create mode 100644 gs/jpeg/jcprepct.c create mode 100644 gs/jpeg/jcsample.c create mode 100644 gs/jpeg/jctrans.c create mode 100644 gs/jpeg/jdapimin.c create mode 100644 gs/jpeg/jdapistd.c create mode 100644 gs/jpeg/jdatadst.c create mode 100644 gs/jpeg/jdatasrc.c create mode 100644 gs/jpeg/jdcoefct.c create mode 100644 gs/jpeg/jdcolor.c create mode 100644 gs/jpeg/jdct.h create mode 100644 gs/jpeg/jddctmgr.c create mode 100644 gs/jpeg/jdhuff.c create mode 100644 gs/jpeg/jdhuff.h create mode 100644 gs/jpeg/jdinput.c create mode 100644 gs/jpeg/jdmainct.c create mode 100644 gs/jpeg/jdmarker.c create mode 100644 gs/jpeg/jdmaster.c create mode 100644 gs/jpeg/jdmerge.c create mode 100644 gs/jpeg/jdphuff.c create mode 100644 gs/jpeg/jdpostct.c create mode 100644 gs/jpeg/jdsample.c create mode 100644 gs/jpeg/jdtrans.c create mode 100644 gs/jpeg/jerror.c create mode 100644 gs/jpeg/jerror.h create mode 100644 gs/jpeg/jfdctflt.c create mode 100644 gs/jpeg/jfdctfst.c create mode 100644 gs/jpeg/jfdctint.c create mode 100644 gs/jpeg/jidctflt.c create mode 100644 gs/jpeg/jidctfst.c create mode 100644 gs/jpeg/jidctint.c create mode 100644 gs/jpeg/jidctred.c create mode 100644 gs/jpeg/jinclude.h create mode 100644 gs/jpeg/jmemansi.c create mode 100644 gs/jpeg/jmemdos.c create mode 100644 gs/jpeg/jmemdosa.asm create mode 100644 gs/jpeg/jmemmac.c create mode 100644 gs/jpeg/jmemmgr.c create mode 100644 gs/jpeg/jmemname.c create mode 100644 gs/jpeg/jmemnobs.c create mode 100644 gs/jpeg/jmemsys.h create mode 100644 gs/jpeg/jmorecfg.h create mode 100644 gs/jpeg/jpegint.h create mode 100644 gs/jpeg/jpeglib.h create mode 100755 gs/jpeg/jpegtran create mode 100644 gs/jpeg/jpegtran.1 create mode 100644 gs/jpeg/jpegtran.c create mode 100644 gs/jpeg/jquant1.c create mode 100644 gs/jpeg/jquant2.c create mode 100644 gs/jpeg/jutils.c create mode 100644 gs/jpeg/jversion.h create mode 100644 gs/jpeg/libjpeg.a create mode 100644 gs/jpeg/libjpeg.doc create mode 100644 gs/jpeg/makcjpeg.st create mode 100644 gs/jpeg/makdjpeg.st create mode 100644 gs/jpeg/makefile.ansi create mode 100644 gs/jpeg/makefile.bcc create mode 100644 gs/jpeg/makefile.cfg create mode 100644 gs/jpeg/makefile.dj create mode 100644 gs/jpeg/makefile.manx create mode 100644 gs/jpeg/makefile.mc6 create mode 100644 gs/jpeg/makefile.mms create mode 100644 gs/jpeg/makefile.sas create mode 100644 gs/jpeg/makefile.unix create mode 100644 gs/jpeg/makefile.vms create mode 100644 gs/jpeg/makefile.wat create mode 100644 gs/jpeg/makljpeg.st create mode 100644 gs/jpeg/maktjpeg.st create mode 100644 gs/jpeg/makvms.opt create mode 100644 gs/jpeg/rdbmp.c create mode 100644 gs/jpeg/rdcolmap.c create mode 100644 gs/jpeg/rdgif.c create mode 100755 gs/jpeg/rdjpgcom create mode 100644 gs/jpeg/rdjpgcom.1 create mode 100644 gs/jpeg/rdjpgcom.c create mode 100644 gs/jpeg/rdppm.c create mode 100644 gs/jpeg/rdrle.c create mode 100644 gs/jpeg/rdswitch.c create mode 100644 gs/jpeg/rdtarga.c create mode 100644 gs/jpeg/structure.doc create mode 100644 gs/jpeg/testimg.gif create mode 100644 gs/jpeg/testimg.jpg create mode 100644 gs/jpeg/testimg.ppm create mode 100644 gs/jpeg/testimgp.jpg create mode 100644 gs/jpeg/testorig.jpg create mode 100644 gs/jpeg/testprog.jpg create mode 100644 gs/jpeg/usage.doc create mode 100644 gs/jpeg/wizard.doc create mode 100644 gs/jpeg/wrbmp.c create mode 100644 gs/jpeg/wrgif.c create mode 100755 gs/jpeg/wrjpgcom create mode 100644 gs/jpeg/wrjpgcom.1 create mode 100644 gs/jpeg/wrjpgcom.c create mode 100644 gs/jpeg/wrppm.c create mode 100644 gs/jpeg/wrrle.c create mode 100644 gs/jpeg/wrtarga.c create mode 100644 gs/language.txt create mode 100644 gs/lib.txt create mode 100644 gs/lib/Fontmap create mode 100644 gs/lib/Fontmap.ATB create mode 100644 gs/lib/Fontmap.ATM create mode 100644 gs/lib/Fontmap.GS create mode 100644 gs/lib/Fontmap.OS2 create mode 100644 gs/lib/Fontmap.OSF create mode 100644 gs/lib/Fontmap.Sol create mode 100644 gs/lib/Fontmap.Ult create mode 100644 gs/lib/Fontmap.VMS create mode 100755 gs/lib/_vc_make.bat create mode 100755 gs/lib/_wm_cdir.bat create mode 100644 gs/lib/acctest.ps create mode 100644 gs/lib/align.ps create mode 100644 gs/lib/alphabet.ps create mode 100755 gs/lib/bdftops create mode 100755 gs/lib/bdftops.bat create mode 100644 gs/lib/bdftops.ps create mode 100644 gs/lib/bjc610a0.upp create mode 100644 gs/lib/bjc610a1.upp create mode 100644 gs/lib/bjc610a2.upp create mode 100644 gs/lib/bjc610a3.upp create mode 100644 gs/lib/bjc610a4.upp create mode 100644 gs/lib/bjc610a5.upp create mode 100644 gs/lib/bjc610a6.upp create mode 100644 gs/lib/bjc610a7.upp create mode 100644 gs/lib/bjc610a8.upp create mode 100644 gs/lib/bjc610b1.upp create mode 100644 gs/lib/bjc610b2.upp create mode 100644 gs/lib/bjc610b3.upp create mode 100644 gs/lib/bjc610b4.upp create mode 100644 gs/lib/bjc610b6.upp create mode 100644 gs/lib/bjc610b7.upp create mode 100644 gs/lib/bjc610b8.upp create mode 100755 gs/lib/bughunt.sh create mode 100644 gs/lib/caption.ps create mode 100644 gs/lib/cbjc600.ppd create mode 100644 gs/lib/cbjc800.ppd create mode 100644 gs/lib/cdj550.upp create mode 100644 gs/lib/cheq.ps create mode 100644 gs/lib/chess.ps create mode 100644 gs/lib/colorcir.ps create mode 100755 gs/lib/cp.bat create mode 100644 gs/lib/decrypt.ps create mode 100644 gs/lib/docie.ps create mode 100644 gs/lib/escher.ps create mode 100755 gs/lib/font2c create mode 100755 gs/lib/font2c.bat create mode 100644 gs/lib/font2c.ps create mode 100644 gs/lib/golfer.ps create mode 100644 gs/lib/grayalph.ps create mode 100644 gs/lib/gs_btokn.ps create mode 100644 gs/lib/gs_ccfnt.ps create mode 100644 gs/lib/gs_cff.ps create mode 100644 gs/lib/gs_cidfn.ps create mode 100644 gs/lib/gs_cmap.ps create mode 100644 gs/lib/gs_cmdl.ps create mode 100644 gs/lib/gs_dbt_e.ps create mode 100644 gs/lib/gs_diskf.ps create mode 100644 gs/lib/gs_dpnxt.ps create mode 100644 gs/lib/gs_dps.ps create mode 100644 gs/lib/gs_dps1.ps create mode 100644 gs/lib/gs_dps2.ps create mode 100644 gs/lib/gs_epsf.ps create mode 100644 gs/lib/gs_fform.ps create mode 100644 gs/lib/gs_fonts.ps create mode 100644 gs/lib/gs_init.ps create mode 100644 gs/lib/gs_iso_e.ps create mode 100644 gs/lib/gs_kanji.ps create mode 100644 gs/lib/gs_ksb_e.ps create mode 100644 gs/lib/gs_l2img.ps create mode 100644 gs/lib/gs_lev2.ps create mode 100644 gs/lib/gs_mex_e.ps create mode 100644 gs/lib/gs_mro_e.ps create mode 100644 gs/lib/gs_pdf.ps create mode 100644 gs/lib/gs_pdf_e.ps create mode 100644 gs/lib/gs_pdfwr.ps create mode 100644 gs/lib/gs_pfile.ps create mode 100644 gs/lib/gs_res.ps create mode 100644 gs/lib/gs_setpd.ps create mode 100644 gs/lib/gs_statd.ps create mode 100644 gs/lib/gs_std_e.ps create mode 100644 gs/lib/gs_sym_e.ps create mode 100644 gs/lib/gs_ttf.ps create mode 100644 gs/lib/gs_typ42.ps create mode 100644 gs/lib/gs_type1.ps create mode 100644 gs/lib/gs_wan_e.ps create mode 100644 gs/lib/gs_wl1_e.ps create mode 100644 gs/lib/gs_wl2_e.ps create mode 100644 gs/lib/gs_wl5_e.ps create mode 100755 gs/lib/gsbj create mode 100755 gs/lib/gsbj.bat create mode 100755 gs/lib/gsdj create mode 100755 gs/lib/gsdj.bat create mode 100755 gs/lib/gsdj500 create mode 100755 gs/lib/gsdj500.bat create mode 100755 gs/lib/gslj create mode 100755 gs/lib/gslj.bat create mode 100755 gs/lib/gslp create mode 100755 gs/lib/gslp.bat create mode 100644 gs/lib/gslp.ps create mode 100755 gs/lib/gsnd create mode 100755 gs/lib/gsnd.bat create mode 100755 gs/lib/gsndt.bat create mode 100755 gs/lib/gst.bat create mode 100755 gs/lib/gstt.bat create mode 100644 gs/lib/impath.ps create mode 100644 gs/lib/landscap.ps create mode 100644 gs/lib/level1.ps create mode 100644 gs/lib/lines.ps create mode 100755 gs/lib/lprsetup.sh create mode 100644 gs/lib/markhint.ps create mode 100644 gs/lib/markpath.ps create mode 100755 gs/lib/mv.bat create mode 100644 gs/lib/necp2x.upp create mode 100644 gs/lib/necp2x6.upp create mode 100644 gs/lib/packfile.ps create mode 100644 gs/lib/pcharstr.ps create mode 100755 gs/lib/pdf2dsc create mode 100644 gs/lib/pdf2dsc.ps create mode 100755 gs/lib/pdf2ps create mode 100755 gs/lib/pdf2ps.bat create mode 100644 gs/lib/pdf_2ps.ps create mode 100644 gs/lib/pdf_base.ps create mode 100644 gs/lib/pdf_draw.ps create mode 100644 gs/lib/pdf_font.ps create mode 100644 gs/lib/pdf_main.ps create mode 100644 gs/lib/pdf_sec.ps create mode 100644 gs/lib/pfbtogs.ps create mode 100755 gs/lib/pftogsf.bat create mode 100755 gs/lib/pj-gs.sh create mode 100644 gs/lib/ppath.ps create mode 100644 gs/lib/prfont.ps create mode 100755 gs/lib/printafm create mode 100644 gs/lib/printafm.ps create mode 100644 gs/lib/ps2ai.ps create mode 100755 gs/lib/ps2ascii create mode 100755 gs/lib/ps2ascii.bat create mode 100644 gs/lib/ps2ascii.ps create mode 100755 gs/lib/ps2epsi create mode 100755 gs/lib/ps2epsi.bat create mode 100644 gs/lib/ps2epsi.ps create mode 100755 gs/lib/ps2pdf create mode 100644 gs/lib/ps2pdf.bat create mode 100755 gs/lib/pv.sh create mode 100644 gs/lib/quit.ps create mode 100644 gs/lib/ras1.upp create mode 100644 gs/lib/ras24.upp create mode 100644 gs/lib/ras3.upp create mode 100644 gs/lib/ras32.upp create mode 100644 gs/lib/ras4.upp create mode 100644 gs/lib/ras8m.upp create mode 100755 gs/lib/rm.bat create mode 100644 gs/lib/rollconv.ps create mode 100644 gs/lib/showchar.ps create mode 100644 gs/lib/showpage.ps create mode 100644 gs/lib/snowflak.ps create mode 100644 gs/lib/stc.upp create mode 100644 gs/lib/stc1520h.upp create mode 100644 gs/lib/stc2.upp create mode 100644 gs/lib/stc2_h.upp create mode 100644 gs/lib/stc2s_h.upp create mode 100644 gs/lib/stc500p.upp create mode 100644 gs/lib/stc500ph.upp create mode 100644 gs/lib/stc600ih.upp create mode 100644 gs/lib/stc600p.upp create mode 100644 gs/lib/stc600pl.upp create mode 100644 gs/lib/stc800ih.upp create mode 100644 gs/lib/stc800p.upp create mode 100644 gs/lib/stc800pl.upp create mode 100644 gs/lib/stc_h.upp create mode 100644 gs/lib/stc_l.upp create mode 100644 gs/lib/stcany.upp create mode 100644 gs/lib/stcinfo.ps create mode 100644 gs/lib/stcolor.ps create mode 100755 gs/lib/sysvlp.sh create mode 100644 gs/lib/t1tot2.ps create mode 100644 gs/lib/test.ps create mode 100644 gs/lib/tiger.ps create mode 100644 gs/lib/traceimg.ps create mode 100644 gs/lib/traceop.ps create mode 100644 gs/lib/type1enc.ps create mode 100644 gs/lib/type1ops.ps create mode 100644 gs/lib/uninfo.ps create mode 100755 gs/lib/unix-lpr.sh create mode 100644 gs/lib/unprot.ps create mode 100644 gs/lib/viewcmyk.ps create mode 100644 gs/lib/viewgif.ps create mode 100644 gs/lib/viewjpeg.ps create mode 100644 gs/lib/viewpbm.ps create mode 100644 gs/lib/viewpcx.ps create mode 100644 gs/lib/viewps2a.ps create mode 100644 gs/lib/waterfal.ps create mode 100755 gs/lib/wftopfa create mode 100644 gs/lib/wftopfa.ps create mode 100644 gs/lib/winmaps.ps create mode 100644 gs/lib/wmakebat.bat create mode 100644 gs/lib/wrfont.ps create mode 100644 gs/lib/writecff.ps create mode 100644 gs/lib/zeroline.ps create mode 100644 gs/libpng/CHANGES create mode 100644 gs/libpng/README create mode 100644 gs/libpng/TODO create mode 100644 gs/libpng/ansi2knr.c create mode 100644 gs/libpng/build.bat create mode 100644 gs/libpng/descrip.mms create mode 100644 gs/libpng/example.c create mode 100644 gs/libpng/libpng.a create mode 100644 gs/libpng/libpng.txt create mode 100644 gs/libpng/makefile create mode 100644 gs/libpng/makefile.aco create mode 100644 gs/libpng/makefile.ama create mode 100644 gs/libpng/makefile.atr create mode 100644 gs/libpng/makefile.bor create mode 100644 gs/libpng/makefile.dj2 create mode 100644 gs/libpng/makefile.elf create mode 100644 gs/libpng/makefile.knr create mode 100644 gs/libpng/makefile.mip create mode 100644 gs/libpng/makefile.msc create mode 100644 gs/libpng/makefile.std create mode 100644 gs/libpng/makefile.sun create mode 100644 gs/libpng/makefile.tc create mode 100644 gs/libpng/makevms.com create mode 100644 gs/libpng/png.c create mode 100644 gs/libpng/png.h create mode 100644 gs/libpng/pngconf.h create mode 100644 gs/libpng/pngerror.c create mode 100644 gs/libpng/pngget.c create mode 100644 gs/libpng/pngmem.c create mode 100644 gs/libpng/pngpread.c create mode 100644 gs/libpng/pngread.c create mode 100644 gs/libpng/pngrio.c create mode 100644 gs/libpng/pngrtran.c create mode 100644 gs/libpng/pngrutil.c create mode 100644 gs/libpng/pngset.c create mode 100755 gs/libpng/pngtest create mode 100644 gs/libpng/pngtest.c create mode 100644 gs/libpng/pngtest.png create mode 100644 gs/libpng/pngtrans.c create mode 100644 gs/libpng/pngwio.c create mode 100644 gs/libpng/pngwrite.c create mode 100644 gs/libpng/pngwtran.c create mode 100644 gs/libpng/pngwutil.c create mode 100644 gs/make.txt create mode 100644 gs/man/ansi2knr.1 create mode 100644 gs/man/gs.1 create mode 100644 gs/man/pdf2dsc.1 create mode 100644 gs/man/pdf2ps.1 create mode 100644 gs/man/ps2ascii.1 create mode 100644 gs/man/ps2epsi.1 create mode 100644 gs/man/ps2pdf.1 create mode 100644 gs/new-user.txt create mode 100644 gs/news create mode 100644 gs/ps2image.ps create mode 100644 gs/ps2pdf.txt create mode 100644 gs/psfiles.txt create mode 100644 gs/public.txt create mode 100644 gs/readme create mode 100755 gs/src/_vc_temp.mak create mode 100644 gs/src/ansi2knr.c create mode 100644 gs/src/ansihead.mak create mode 100644 gs/src/append_l.com create mode 100644 gs/src/bcc32.cfg create mode 100644 gs/src/bcwin32.mak create mode 100644 gs/src/bench.c create mode 100644 gs/src/bfont.h create mode 100644 gs/src/bseq.h create mode 100644 gs/src/btoken.h create mode 100644 gs/src/cc-head.mak create mode 100644 gs/src/ccfont.h create mode 100644 gs/src/ccgs create mode 100644 gs/src/cfonts.mak create mode 100644 gs/src/copy_one.com create mode 100755 gs/src/cp.cmd create mode 100644 gs/src/ctype_.h create mode 100644 gs/src/devs.mak create mode 100644 gs/src/dgc-head.mak create mode 100644 gs/src/dirent_.h create mode 100644 gs/src/dodebug.h create mode 100644 gs/src/dos_.h create mode 100644 gs/src/dpmainc.c create mode 100644 gs/src/dstack.h create mode 100755 gs/src/dvx-gcc.mak create mode 100644 gs/src/dvx-head.mak create mode 100644 gs/src/dvx-tail.mak create mode 100644 gs/src/dw32c.def create mode 100644 gs/src/dwdll.cpp create mode 100644 gs/src/dwdll.h create mode 100644 gs/src/dwimg.cpp create mode 100644 gs/src/dwimg.h create mode 100644 gs/src/dwmain.cpp create mode 100644 gs/src/dwmain.h create mode 100644 gs/src/dwmain.rc create mode 100644 gs/src/dwmain16.def create mode 100644 gs/src/dwmain32.def create mode 100644 gs/src/dwmainc.cpp create mode 100644 gs/src/dwnodll.cpp create mode 100644 gs/src/dwtext.cpp create mode 100644 gs/src/dwtext.h create mode 100644 gs/src/echogs.c create mode 100644 gs/src/errno_.h create mode 100644 gs/src/errors.h create mode 100644 gs/src/estack.h create mode 100644 gs/src/files.h create mode 100644 gs/src/fname.h create mode 100644 gs/src/gcc-head.mak create mode 100644 gs/src/gconf.c create mode 100644 gs/src/gdebug.h create mode 100644 gs/src/gdev3852.c create mode 100644 gs/src/gdev3b1.c create mode 100644 gs/src/gdev4081.c create mode 100644 gs/src/gdev4693.c create mode 100644 gs/src/gdev8510.c create mode 100644 gs/src/gdev8bcm.c create mode 100644 gs/src/gdev8bcm.h create mode 100644 gs/src/gdevabuf.c create mode 100644 gs/src/gdevadmp.c create mode 100644 gs/src/gdevasyn.c create mode 100644 gs/src/gdevbbox.c create mode 100644 gs/src/gdevbbox.h create mode 100644 gs/src/gdevbgi.c create mode 100644 gs/src/gdevbit.c create mode 100644 gs/src/gdevbj10.c create mode 100644 gs/src/gdevbjc.h create mode 100644 gs/src/gdevbmp.c create mode 100644 gs/src/gdevccr.c create mode 100644 gs/src/gdevcdj.c create mode 100644 gs/src/gdevcgm.c create mode 100644 gs/src/gdevcgml.c create mode 100644 gs/src/gdevcgml.h create mode 100644 gs/src/gdevcgmx.h create mode 100644 gs/src/gdevcif.c create mode 100644 gs/src/gdevcp50.c create mode 100644 gs/src/gdevddrw.c create mode 100644 gs/src/gdevdfax.c create mode 100644 gs/src/gdevdflt.c create mode 100644 gs/src/gdevdjet.c create mode 100644 gs/src/gdevdjtc.c create mode 100644 gs/src/gdevdm24.c create mode 100644 gs/src/gdevegaa.asm create mode 100644 gs/src/gdevemap.c create mode 100644 gs/src/gdevepsc.c create mode 100644 gs/src/gdevepsn.c create mode 100644 gs/src/gdevescp.c create mode 100644 gs/src/gdevevga.c create mode 100644 gs/src/gdevherc.c create mode 100644 gs/src/gdevht.c create mode 100644 gs/src/gdevht.h create mode 100644 gs/src/gdevimgn.c create mode 100644 gs/src/gdevjpeg.c create mode 100644 gs/src/gdevl256.c create mode 100644 gs/src/gdevlbp8.c create mode 100644 gs/src/gdevlj56.c create mode 100644 gs/src/gdevlp8k.c create mode 100644 gs/src/gdevm1.c create mode 100644 gs/src/gdevm16.c create mode 100644 gs/src/gdevm2.c create mode 100644 gs/src/gdevm24.c create mode 100644 gs/src/gdevm32.c create mode 100644 gs/src/gdevm4.c create mode 100644 gs/src/gdevm8.c create mode 100644 gs/src/gdevmem.c create mode 100644 gs/src/gdevmem.h create mode 100644 gs/src/gdevmgr.c create mode 100644 gs/src/gdevmgr.h create mode 100644 gs/src/gdevmiff.c create mode 100644 gs/src/gdevmpla.c create mode 100644 gs/src/gdevmrop.c create mode 100644 gs/src/gdevmrop.h create mode 100644 gs/src/gdevmswn.c create mode 100644 gs/src/gdevmswn.h create mode 100644 gs/src/gdevmsxf.c create mode 100644 gs/src/gdevn533.c create mode 100644 gs/src/gdevnfwd.c create mode 100644 gs/src/gdevnp6.c create mode 100644 gs/src/gdevo182.c create mode 100644 gs/src/gdevokii.c create mode 100644 gs/src/gdevos2p.c create mode 100644 gs/src/gdevp2up.c create mode 100644 gs/src/gdevpbm.c create mode 100644 gs/src/gdevpccm.c create mode 100644 gs/src/gdevpccm.h create mode 100644 gs/src/gdevpcfb.c create mode 100644 gs/src/gdevpcfb.h create mode 100644 gs/src/gdevpcl.c create mode 100644 gs/src/gdevpcl.h create mode 100644 gs/src/gdevpcx.c create mode 100644 gs/src/gdevpdf.c create mode 100644 gs/src/gdevpdfd.c create mode 100644 gs/src/gdevpdfi.c create mode 100644 gs/src/gdevpdfm.c create mode 100644 gs/src/gdevpdfp.c create mode 100644 gs/src/gdevpdft.c create mode 100644 gs/src/gdevpdfx.h create mode 100644 gs/src/gdevpe.c create mode 100644 gs/src/gdevpipe.c create mode 100644 gs/src/gdevpjet.c create mode 100644 gs/src/gdevpm.c create mode 100644 gs/src/gdevpm.h create mode 100644 gs/src/gdevpng.c create mode 100644 gs/src/gdevprn.c create mode 100644 gs/src/gdevprn.h create mode 100644 gs/src/gdevprna.h create mode 100644 gs/src/gdevps.c create mode 100644 gs/src/gdevpsdf.c create mode 100644 gs/src/gdevpsdf.h create mode 100644 gs/src/gdevpsim.c create mode 100644 gs/src/gdevpstr.c create mode 100644 gs/src/gdevpstr.h create mode 100644 gs/src/gdevpx.c create mode 100644 gs/src/gdevpxat.h create mode 100644 gs/src/gdevpxen.h create mode 100644 gs/src/gdevpxop.h create mode 100644 gs/src/gdevrrgb.c create mode 100644 gs/src/gdevrun.c create mode 100644 gs/src/gdevs3ga.c create mode 100644 gs/src/gdevsco.c create mode 100644 gs/src/gdevsgi.c create mode 100644 gs/src/gdevsgi.h create mode 100644 gs/src/gdevsj48.c create mode 100644 gs/src/gdevsnfb.c create mode 100644 gs/src/gdevsppr.c create mode 100644 gs/src/gdevstc.c create mode 100644 gs/src/gdevstc.h create mode 100644 gs/src/gdevstc1.c create mode 100644 gs/src/gdevstc2.c create mode 100644 gs/src/gdevstc3.c create mode 100644 gs/src/gdevstc4.c create mode 100644 gs/src/gdevsun.c create mode 100644 gs/src/gdevsvga.c create mode 100644 gs/src/gdevsvga.h create mode 100644 gs/src/gdevtfax.c create mode 100644 gs/src/gdevtfnx.c create mode 100644 gs/src/gdevtifs.c create mode 100644 gs/src/gdevtifs.h create mode 100644 gs/src/gdevtknk.c create mode 100644 gs/src/gdevupd.c create mode 100644 gs/src/gdevvec.c create mode 100644 gs/src/gdevvec.h create mode 100644 gs/src/gdevvglb.c create mode 100644 gs/src/gdevwddb.c create mode 100644 gs/src/gdevwdib.c create mode 100644 gs/src/gdevwpr2.c create mode 100644 gs/src/gdevwprn.c create mode 100644 gs/src/gdevx.c create mode 100644 gs/src/gdevx.h create mode 100644 gs/src/gdevxalt.c create mode 100644 gs/src/gdevxini.c create mode 100644 gs/src/gdevxxf.c create mode 100644 gs/src/genarch.c create mode 100644 gs/src/genconf.c create mode 100644 gs/src/geninit.c create mode 100644 gs/src/ghost.h create mode 100644 gs/src/gp.h create mode 100644 gs/src/gp_dosfb.c create mode 100644 gs/src/gp_dosfe.c create mode 100644 gs/src/gp_dosfs.c create mode 100644 gs/src/gp_dvx.c create mode 100644 gs/src/gp_itbc.c create mode 100644 gs/src/gp_iwatc.c create mode 100644 gs/src/gp_msdos.c create mode 100644 gs/src/gp_msio.c create mode 100644 gs/src/gp_mslib.c create mode 100644 gs/src/gp_mswin.c create mode 100644 gs/src/gp_mswin.h create mode 100644 gs/src/gp_nofb.c create mode 100644 gs/src/gp_ntfs.c create mode 100644 gs/src/gp_os2.c create mode 100644 gs/src/gp_os9.c create mode 100644 gs/src/gp_sysv.c create mode 100644 gs/src/gp_unifn.c create mode 100644 gs/src/gp_unifs.c create mode 100644 gs/src/gp_unix.c create mode 100644 gs/src/gp_vms.c create mode 100644 gs/src/gp_win32.c create mode 100644 gs/src/gpcheck.h create mode 100644 gs/src/gpsync.h create mode 100644 gs/src/gs.c create mode 100644 gs/src/gs.mak create mode 100644 gs/src/gs16spl.c create mode 100644 gs/src/gs16spl.def create mode 100644 gs/src/gs16spl.rc create mode 100644 gs/src/gsalloc.c create mode 100644 gs/src/gsalloc.h create mode 100644 gs/src/gsargs.c create mode 100644 gs/src/gsargs.h create mode 100644 gs/src/gsbitmap.h create mode 100644 gs/src/gsbitops.c create mode 100644 gs/src/gsbitops.h create mode 100644 gs/src/gsbittab.c create mode 100644 gs/src/gsbittab.h create mode 100644 gs/src/gsccode.h create mode 100644 gs/src/gsccolor.h create mode 100644 gs/src/gscdef.c create mode 100644 gs/src/gscdefs.h create mode 100644 gs/src/gschar.c create mode 100644 gs/src/gschar.h create mode 100644 gs/src/gschar0.c create mode 100644 gs/src/gscie.c create mode 100644 gs/src/gscie.h create mode 100644 gs/src/gscolor.c create mode 100644 gs/src/gscolor.h create mode 100644 gs/src/gscolor1.c create mode 100644 gs/src/gscolor1.h create mode 100644 gs/src/gscolor2.c create mode 100644 gs/src/gscolor2.h create mode 100644 gs/src/gscoord.c create mode 100644 gs/src/gscoord.h create mode 100644 gs/src/gscpm.h create mode 100644 gs/src/gscrypt1.h create mode 100644 gs/src/gscsel.h create mode 100644 gs/src/gscsepr.c create mode 100644 gs/src/gscsepr.h create mode 100644 gs/src/gscspace.h create mode 100644 gs/src/gsdcolor.h create mode 100644 gs/src/gsdevice.c create mode 100644 gs/src/gsdevice.h create mode 100644 gs/src/gsdevmem.c create mode 100644 gs/src/gsdll.c create mode 100644 gs/src/gsdll.h create mode 100644 gs/src/gsdll16.def create mode 100644 gs/src/gsdll16.rc create mode 100644 gs/src/gsdll2.def create mode 100644 gs/src/gsdll2.rc create mode 100644 gs/src/gsdll32.def create mode 100644 gs/src/gsdll32.rc create mode 100644 gs/src/gsdparam.c create mode 100644 gs/src/gsdps.c create mode 100644 gs/src/gsdps.h create mode 100644 gs/src/gsdps1.c create mode 100644 gs/src/gsdsc.c create mode 100644 gs/src/gsdsrc.c create mode 100644 gs/src/gsdsrc.h create mode 100644 gs/src/gserror.h create mode 100644 gs/src/gserrors.h create mode 100644 gs/src/gserver.c create mode 100644 gs/src/gsexit.h create mode 100644 gs/src/gsfcmap.c create mode 100644 gs/src/gsfcmap.h create mode 100644 gs/src/gsfemu.c create mode 100644 gs/src/gsflip.c create mode 100644 gs/src/gsflip.h create mode 100644 gs/src/gsfont.c create mode 100644 gs/src/gsfont.h create mode 100644 gs/src/gsfont0.c create mode 100644 gs/src/gsfunc.c create mode 100644 gs/src/gsfunc.h create mode 100644 gs/src/gsfunc0.c create mode 100644 gs/src/gsfunc0.h create mode 100644 gs/src/gsgc.h create mode 100644 gs/src/gsgraph.icx create mode 100644 gs/src/gshsb.c create mode 100644 gs/src/gshsb.h create mode 100644 gs/src/gsht.c create mode 100644 gs/src/gsht.h create mode 100644 gs/src/gsht1.c create mode 100644 gs/src/gsht1.h create mode 100644 gs/src/gshtscr.c create mode 100644 gs/src/gsimage.c create mode 100644 gs/src/gsimage.h create mode 100644 gs/src/gsimpath.c create mode 100644 gs/src/gsinit.c create mode 100644 gs/src/gsio.h create mode 100644 gs/src/gsiodev.c create mode 100644 gs/src/gsiparam.h create mode 100644 gs/src/gsjconf.h create mode 100644 gs/src/gsjerror.c create mode 100644 gs/src/gsjerror.h create mode 100644 gs/src/gsjmorec.h create mode 100644 gs/src/gsjpglib.h create mode 100644 gs/src/gslib.c create mode 100644 gs/src/gslib.h create mode 100644 gs/src/gsline.c create mode 100644 gs/src/gsline.h create mode 100644 gs/src/gslparam.h create mode 100644 gs/src/gsmatrix.c create mode 100644 gs/src/gsmatrix.h create mode 100644 gs/src/gsmdebug.h create mode 100644 gs/src/gsmemfix.c create mode 100644 gs/src/gsmemfix.h create mode 100644 gs/src/gsmemlok.c create mode 100644 gs/src/gsmemlok.h create mode 100644 gs/src/gsmemory.c create mode 100644 gs/src/gsmemory.h create mode 100644 gs/src/gsmemraw.h create mode 100644 gs/src/gsmisc.c create mode 100644 gs/src/gsnogc.c create mode 100644 gs/src/gsos2.def create mode 100644 gs/src/gsos2.icx create mode 100644 gs/src/gsos2.rc create mode 100644 gs/src/gspaint.c create mode 100644 gs/src/gspaint.h create mode 100644 gs/src/gsparam.c create mode 100644 gs/src/gsparam.h create mode 100644 gs/src/gsparams.c create mode 100644 gs/src/gsparams.h create mode 100644 gs/src/gspath.c create mode 100644 gs/src/gspath.h create mode 100644 gs/src/gspath1.c create mode 100644 gs/src/gspath2.h create mode 100644 gs/src/gspcolor.c create mode 100644 gs/src/gspenum.h create mode 100644 gs/src/gspmdrv.c create mode 100644 gs/src/gspmdrv.def create mode 100644 gs/src/gspmdrv.h create mode 100644 gs/src/gspmdrv.icx create mode 100644 gs/src/gspmdrv.rc create mode 100644 gs/src/gsrefct.h create mode 100644 gs/src/gsrop.c create mode 100644 gs/src/gsrop.h create mode 100644 gs/src/gsropt.h create mode 100644 gs/src/gsroptab.c create mode 100644 gs/src/gsstate.c create mode 100644 gs/src/gsstate.h create mode 100644 gs/src/gsstruct.h create mode 100644 gs/src/gstext.icx create mode 100644 gs/src/gstype1.c create mode 100644 gs/src/gstype1.h create mode 100644 gs/src/gstype2.c create mode 100644 gs/src/gstype42.c create mode 100644 gs/src/gstypes.h create mode 100644 gs/src/gsuid.h create mode 100644 gs/src/gsutil.c create mode 100644 gs/src/gsutil.h create mode 100644 gs/src/gswin.rc create mode 100644 gs/src/gswin32.rc create mode 100644 gs/src/gswin386.rc create mode 100644 gs/src/gsxfont.h create mode 100644 gs/src/gx.h create mode 100644 gs/src/gxacpath.c create mode 100644 gs/src/gxalloc.h create mode 100644 gs/src/gxarith.h create mode 100644 gs/src/gxband.h create mode 100644 gs/src/gxbcache.c create mode 100644 gs/src/gxbcache.h create mode 100644 gs/src/gxbitmap.h create mode 100644 gs/src/gxccache.c create mode 100644 gs/src/gxccman.c create mode 100644 gs/src/gxchar.h create mode 100644 gs/src/gxcht.c create mode 100644 gs/src/gxcindex.h create mode 100644 gs/src/gxclbits.c create mode 100644 gs/src/gxcldev.h create mode 100644 gs/src/gxclfile.c create mode 100644 gs/src/gxclimag.c create mode 100644 gs/src/gxclio.h create mode 100644 gs/src/gxclip2.c create mode 100644 gs/src/gxclip2.h create mode 100644 gs/src/gxclist.c create mode 100644 gs/src/gxclist.h create mode 100644 gs/src/gxcllzw.c create mode 100644 gs/src/gxclmem.c create mode 100644 gs/src/gxclmem.h create mode 100644 gs/src/gxclpage.c create mode 100644 gs/src/gxclpage.h create mode 100644 gs/src/gxclpath.c create mode 100644 gs/src/gxclpath.h create mode 100644 gs/src/gxclread.c create mode 100644 gs/src/gxclrect.c create mode 100644 gs/src/gxclzlib.c create mode 100644 gs/src/gxcmap.c create mode 100644 gs/src/gxcmap.h create mode 100644 gs/src/gxcolor2.h create mode 100644 gs/src/gxcoord.h create mode 100644 gs/src/gxcpath.c create mode 100644 gs/src/gxcpath.h create mode 100644 gs/src/gxcspace.h create mode 100644 gs/src/gxctable.c create mode 100644 gs/src/gxctable.h create mode 100644 gs/src/gxcvalue.h create mode 100644 gs/src/gxdcconv.c create mode 100644 gs/src/gxdcconv.h create mode 100644 gs/src/gxdcolor.c create mode 100644 gs/src/gxdcolor.h create mode 100644 gs/src/gxdda.h create mode 100644 gs/src/gxdevice.h create mode 100644 gs/src/gxdevmem.h create mode 100644 gs/src/gxdevrop.h create mode 100644 gs/src/gxdht.h create mode 100644 gs/src/gxdither.c create mode 100644 gs/src/gxdither.h create mode 100644 gs/src/gxfarith.h create mode 100644 gs/src/gxfcache.h create mode 100644 gs/src/gxfcmap.h create mode 100644 gs/src/gxfill.c create mode 100644 gs/src/gxfixed.h create mode 100644 gs/src/gxfmap.h create mode 100644 gs/src/gxfont.h create mode 100644 gs/src/gxfont0.h create mode 100644 gs/src/gxfont1.h create mode 100644 gs/src/gxfont42.h create mode 100644 gs/src/gxfrac.h create mode 100644 gs/src/gxftype.h create mode 100644 gs/src/gxfunc.h create mode 100644 gs/src/gxhint1.c create mode 100644 gs/src/gxhint2.c create mode 100644 gs/src/gxhint3.c create mode 100644 gs/src/gxht.c create mode 100644 gs/src/gxht.h create mode 100644 gs/src/gxhttile.h create mode 100644 gs/src/gxhttype.h create mode 100644 gs/src/gximage.h create mode 100644 gs/src/gximage0.c create mode 100644 gs/src/gximage2.c create mode 100644 gs/src/gximage3.c create mode 100644 gs/src/gximage4.c create mode 100644 gs/src/gximage5.c create mode 100644 gs/src/gxiodev.h create mode 100644 gs/src/gxistate.h create mode 100644 gs/src/gxline.h create mode 100644 gs/src/gxlum.h create mode 100644 gs/src/gxmatrix.h create mode 100644 gs/src/gxobj.h create mode 100644 gs/src/gxop1.h create mode 100644 gs/src/gxpageq.c create mode 100644 gs/src/gxpageq.h create mode 100644 gs/src/gxpaint.c create mode 100644 gs/src/gxpaint.h create mode 100644 gs/src/gxpath.c create mode 100644 gs/src/gxpath.h create mode 100644 gs/src/gxpath2.c create mode 100644 gs/src/gxpcache.h create mode 100644 gs/src/gxpcmap.c create mode 100644 gs/src/gxpcolor.h create mode 100644 gs/src/gxpcopy.c create mode 100644 gs/src/gxpdash.c create mode 100644 gs/src/gxpflat.c create mode 100644 gs/src/gxsample.c create mode 100644 gs/src/gxsample.h create mode 100644 gs/src/gxstate.h create mode 100644 gs/src/gxstroke.c create mode 100644 gs/src/gxsync.c create mode 100644 gs/src/gxsync.h create mode 100644 gs/src/gxtmap.h create mode 100644 gs/src/gxtype1.c create mode 100644 gs/src/gxtype1.h create mode 100644 gs/src/gxxfont.h create mode 100644 gs/src/gzacpath.h create mode 100644 gs/src/gzcpath.h create mode 100644 gs/src/gzline.h create mode 100644 gs/src/gzpath.h create mode 100644 gs/src/gzstate.h create mode 100644 gs/src/ialloc.c create mode 100644 gs/src/ialloc.h create mode 100644 gs/src/iastate.h create mode 100644 gs/src/iastruct.h create mode 100644 gs/src/ibnum.c create mode 100644 gs/src/ibnum.h create mode 100644 gs/src/iccfont.c create mode 100644 gs/src/iccinit0.c create mode 100644 gs/src/icfontab.c create mode 100644 gs/src/ichar.h create mode 100644 gs/src/icharout.h create mode 100644 gs/src/icie.h create mode 100644 gs/src/icolor.h create mode 100644 gs/src/iconf.c create mode 100644 gs/src/icontext.c create mode 100644 gs/src/icontext.h create mode 100644 gs/src/icsmap.h create mode 100644 gs/src/idebug.c create mode 100644 gs/src/idebug.h create mode 100644 gs/src/idict.c create mode 100644 gs/src/idict.h create mode 100644 gs/src/idparam.c create mode 100644 gs/src/idparam.h create mode 100644 gs/src/ifilter.h create mode 100644 gs/src/ifont.h create mode 100644 gs/src/ifunc.h create mode 100644 gs/src/igc.c create mode 100644 gs/src/igc.h create mode 100644 gs/src/igcref.c create mode 100644 gs/src/igcstr.c create mode 100644 gs/src/igcstr.h create mode 100644 gs/src/igstate.h create mode 100644 gs/src/iht.h create mode 100644 gs/src/iimage.h create mode 100644 gs/src/iinit.c create mode 100644 gs/src/ilevel.h create mode 100644 gs/src/ilocate.c create mode 100644 gs/src/imain.c create mode 100644 gs/src/imain.h create mode 100644 gs/src/imainarg.c create mode 100644 gs/src/imainarg.h create mode 100644 gs/src/imemory.h create mode 100644 gs/src/iminst.h create mode 100644 gs/src/iname.c create mode 100644 gs/src/iname.h create mode 100644 gs/src/inamedef.h create mode 100644 gs/src/int.mak create mode 100644 gs/src/interp.c create mode 100644 gs/src/interp.h create mode 100644 gs/src/ipacked.h create mode 100644 gs/src/iparam.c create mode 100644 gs/src/iparam.h create mode 100644 gs/src/iparray.h create mode 100644 gs/src/ireclaim.c create mode 100644 gs/src/iref.h create mode 100644 gs/src/isave.c create mode 100644 gs/src/isave.h create mode 100644 gs/src/iscan.c create mode 100644 gs/src/iscan.h create mode 100644 gs/src/iscanbin.c create mode 100644 gs/src/iscannum.c create mode 100644 gs/src/iscannum.h create mode 100644 gs/src/isstate.h create mode 100644 gs/src/istack.c create mode 100644 gs/src/istack.h create mode 100644 gs/src/istream.h create mode 100644 gs/src/istruct.h create mode 100644 gs/src/iutil.c create mode 100644 gs/src/iutil.h create mode 100644 gs/src/iutil2.c create mode 100644 gs/src/iutil2.h create mode 100644 gs/src/iutilasm.asm create mode 100644 gs/src/ivmspace.h create mode 100644 gs/src/jpeg.mak create mode 100644 gs/src/lib.mak create mode 100644 gs/src/libpng.mak create mode 100644 gs/src/main.h create mode 100644 gs/src/malloc_.h create mode 100644 gs/src/math_.h create mode 100644 gs/src/memory_.h create mode 100644 gs/src/msvc32.mak create mode 100644 gs/src/msvccmd.mak create mode 100644 gs/src/msvccom.mak create mode 100644 gs/src/msvclib.mak create mode 100644 gs/src/msvctail.mak create mode 100755 gs/src/mv.cmd create mode 100644 gs/src/opcheck.h create mode 100644 gs/src/opdef.h create mode 100644 gs/src/openvms.mak create mode 100644 gs/src/oper.h create mode 100644 gs/src/opextern.h create mode 100644 gs/src/os2.mak create mode 100644 gs/src/ostack.h create mode 100644 gs/src/overlay.h create mode 100755 gs/src/rm.cmd create mode 100644 gs/src/rm_all.com create mode 100644 gs/src/rm_one.com create mode 100644 gs/src/sa85x.h create mode 100644 gs/src/sbcp.c create mode 100644 gs/src/sbhc.c create mode 100644 gs/src/sbhc.h create mode 100644 gs/src/sbtx.h create mode 100644 gs/src/sbwbs.c create mode 100644 gs/src/sbwbs.h create mode 100644 gs/src/scanchar.h create mode 100644 gs/src/scantab.c create mode 100644 gs/src/scf.h create mode 100644 gs/src/scfd.c create mode 100644 gs/src/scfdgen.c create mode 100644 gs/src/scfdtab.c create mode 100644 gs/src/scfe.c create mode 100644 gs/src/scfetab.c create mode 100644 gs/src/scfx.h create mode 100644 gs/src/scommon.h create mode 100644 gs/src/sdct.h create mode 100644 gs/src/sdctc.c create mode 100644 gs/src/sdctd.c create mode 100644 gs/src/sdcte.c create mode 100644 gs/src/seexec.c create mode 100644 gs/src/sfilter.h create mode 100644 gs/src/sfilter1.c create mode 100644 gs/src/sfilter2.c create mode 100644 gs/src/sfxboth.c create mode 100644 gs/src/sfxfd.c create mode 100644 gs/src/sfxstdio.c create mode 100644 gs/src/shc.c create mode 100644 gs/src/shc.h create mode 100644 gs/src/shcgen.c create mode 100644 gs/src/shcgen.h create mode 100644 gs/src/siscale.c create mode 100644 gs/src/siscale.h create mode 100644 gs/src/sjpeg.h create mode 100644 gs/src/sjpegc.c create mode 100644 gs/src/sjpegd.c create mode 100644 gs/src/sjpege.c create mode 100644 gs/src/sjpegerr.c create mode 100644 gs/src/slzwc.c create mode 100644 gs/src/slzwce.c create mode 100644 gs/src/slzwd.c create mode 100644 gs/src/slzwx.h create mode 100644 gs/src/smtf.c create mode 100644 gs/src/smtf.h create mode 100644 gs/src/spcxd.c create mode 100644 gs/src/spcxx.h create mode 100644 gs/src/spdiff.c create mode 100644 gs/src/spdiffx.h create mode 100644 gs/src/spngp.c create mode 100644 gs/src/spngpx.h create mode 100644 gs/src/srld.c create mode 100644 gs/src/srle.c create mode 100644 gs/src/srlx.h create mode 100644 gs/src/sstring.c create mode 100644 gs/src/sstring.h create mode 100644 gs/src/stat_.h create mode 100644 gs/src/std.h create mode 100644 gs/src/stdio_.h create mode 100644 gs/src/stdpre.h create mode 100644 gs/src/store.h create mode 100644 gs/src/stream.c create mode 100644 gs/src/stream.h create mode 100644 gs/src/strimpl.h create mode 100644 gs/src/string_.h create mode 100644 gs/src/szlibc.c create mode 100644 gs/src/szlibd.c create mode 100644 gs/src/szlibe.c create mode 100644 gs/src/szlibx.h create mode 100644 gs/src/time_.h create mode 100755 gs/src/turboc.cfg create mode 100644 gs/src/ugcclib.mak create mode 100755 gs/src/unix-cc.mak create mode 100644 gs/src/unix-end.mak create mode 100755 gs/src/unix-gcc.mak create mode 100755 gs/src/unixansi.mak create mode 100644 gs/src/unixhead.mak create mode 100644 gs/src/unixtail.mak create mode 100644 gs/src/version.mak create mode 100644 gs/src/vms-cc.mak create mode 100644 gs/src/vms-decc.mak create mode 100644 gs/src/vms-gcc.mak create mode 100644 gs/src/vms.mak create mode 100644 gs/src/vmsmath.h create mode 100644 gs/src/watc.mak create mode 100644 gs/src/watclib.mak create mode 100644 gs/src/watcw32.mak create mode 100644 gs/src/wccommon.mak create mode 100644 gs/src/wctail.mak create mode 100644 gs/src/windows_.h create mode 100644 gs/src/winint.mak create mode 100644 gs/src/winlib.mak create mode 100644 gs/src/wmin.mak create mode 100644 gs/src/x_.h create mode 100644 gs/src/zarith.c create mode 100644 gs/src/zarray.c create mode 100644 gs/src/zbseq.c create mode 100644 gs/src/zchar.c create mode 100644 gs/src/zchar1.c create mode 100644 gs/src/zchar2.c create mode 100644 gs/src/zchar42.c create mode 100644 gs/src/zcharout.c create mode 100644 gs/src/zcid.c create mode 100644 gs/src/zcie.c create mode 100644 gs/src/zcolor.c create mode 100644 gs/src/zcolor1.c create mode 100644 gs/src/zcolor2.c create mode 100644 gs/src/zcontext.c create mode 100644 gs/src/zcontrol.c create mode 100644 gs/src/zcrd.c create mode 100644 gs/src/zcsindex.c create mode 100644 gs/src/zcssepr.c create mode 100644 gs/src/zdevcal.c create mode 100644 gs/src/zdevice.c create mode 100644 gs/src/zdevice2.c create mode 100644 gs/src/zdict.c create mode 100644 gs/src/zdosio.c create mode 100644 gs/src/zdouble.c create mode 100644 gs/src/zdpnext.c create mode 100644 gs/src/zdps.c create mode 100644 gs/src/zdps1.c create mode 100644 gs/src/zfbcp.c create mode 100644 gs/src/zfcmap.c create mode 100644 gs/src/zfdctc.c create mode 100644 gs/src/zfdctd.c create mode 100644 gs/src/zfdcte.c create mode 100644 gs/src/zfdecode.c create mode 100644 gs/src/zfile.c create mode 100644 gs/src/zfileio.c create mode 100644 gs/src/zfilter.c create mode 100644 gs/src/zfilter2.c create mode 100644 gs/src/zfilterx.c create mode 100644 gs/src/zfname.c create mode 100644 gs/src/zfont.c create mode 100644 gs/src/zfont0.c create mode 100644 gs/src/zfont1.c create mode 100644 gs/src/zfont2.c create mode 100644 gs/src/zfont42.c create mode 100644 gs/src/zfproc.c create mode 100644 gs/src/zfunc.c create mode 100644 gs/src/zfunc0.c create mode 100644 gs/src/zfzlib.c create mode 100644 gs/src/zgeneric.c create mode 100644 gs/src/zgstate.c create mode 100644 gs/src/zhsb.c create mode 100644 gs/src/zht.c create mode 100644 gs/src/zht1.c create mode 100644 gs/src/zht2.c create mode 100644 gs/src/zimage.c create mode 100644 gs/src/zimage2.c create mode 100644 gs/src/ziodev.c create mode 100644 gs/src/ziodev2.c create mode 100644 gs/src/zlib.mak create mode 100644 gs/src/zmath.c create mode 100644 gs/src/zmatrix.c create mode 100644 gs/src/zmedia2.c create mode 100644 gs/src/zmisc.c create mode 100644 gs/src/zmisc1.c create mode 100644 gs/src/zmisc2.c create mode 100644 gs/src/zpacked.c create mode 100644 gs/src/zpaint.c create mode 100644 gs/src/zpath.c create mode 100644 gs/src/zpath1.c create mode 100644 gs/src/zpcolor.c create mode 100644 gs/src/zrelbit.c create mode 100644 gs/src/zrop.c create mode 100644 gs/src/zstack.c create mode 100644 gs/src/zstring.c create mode 100644 gs/src/zsysvm.c create mode 100644 gs/src/ztoken.c create mode 100644 gs/src/ztype.c create mode 100644 gs/src/zupath.c create mode 100644 gs/src/zusparam.c create mode 100644 gs/src/zvmem.c create mode 100644 gs/src/zvmem2.c create mode 100644 gs/src/zwppm.c create mode 100644 gs/unix-lpr.txt create mode 100644 gs/use.txt create mode 100644 gs/xfonts.txt create mode 100644 gs/zlib/ChangeLog create mode 100644 gs/zlib/INDEX create mode 100644 gs/zlib/Make_vms.com create mode 100644 gs/zlib/Makefile create mode 100644 gs/zlib/Makefile.in create mode 100644 gs/zlib/Makefile.riscos create mode 100644 gs/zlib/README create mode 100644 gs/zlib/adler32.c create mode 100644 gs/zlib/algorithm.doc create mode 100644 gs/zlib/compress.c create mode 100755 gs/zlib/configure create mode 100644 gs/zlib/crc32.c create mode 100644 gs/zlib/deflate.c create mode 100644 gs/zlib/deflate.h create mode 100644 gs/zlib/descrip.mms create mode 100755 gs/zlib/example create mode 100644 gs/zlib/example.c create mode 100644 gs/zlib/gzio.c create mode 100644 gs/zlib/infblock.c create mode 100644 gs/zlib/infblock.h create mode 100644 gs/zlib/infcodes.c create mode 100644 gs/zlib/infcodes.h create mode 100644 gs/zlib/inffast.c create mode 100644 gs/zlib/inffast.h create mode 100644 gs/zlib/inflate.c create mode 100644 gs/zlib/inftrees.c create mode 100644 gs/zlib/inftrees.h create mode 100644 gs/zlib/infutil.c create mode 100644 gs/zlib/infutil.h create mode 100644 gs/zlib/libz.a create mode 100644 gs/zlib/makefile.b32 create mode 100644 gs/zlib/makefile.bor create mode 100644 gs/zlib/makefile.dj2 create mode 100644 gs/zlib/makefile.msc create mode 100644 gs/zlib/makefile.sas create mode 100644 gs/zlib/makefile.tc create mode 100644 gs/zlib/makefile.wat create mode 100755 gs/zlib/minigzip create mode 100644 gs/zlib/minigzip.c create mode 100644 gs/zlib/trees.c create mode 100644 gs/zlib/uncompr.c create mode 100644 gs/zlib/zconf.h create mode 100644 gs/zlib/zlib.def create mode 100644 gs/zlib/zlib.h create mode 100644 gs/zlib/zlib.rc create mode 100644 gs/zlib/zutil.c create mode 100644 gs/zlib/zutil.h (limited to 'gs') diff --git a/gs/bug-form.txt b/gs/bug-form.txt new file mode 100644 index 000000000..a97f57aa1 --- /dev/null +++ b/gs/bug-form.txt @@ -0,0 +1,61 @@ + Copyright (C) 1996, 1997 Aladdin Enterprises. All rights reserved. + + This file is part of Aladdin Ghostscript. + + Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author + or distributor accepts any responsibility for the consequences of using it, + or for whether it serves any particular purpose or works at all, unless he + or she says so in writing. Refer to the Aladdin Ghostscript Free Public + License (the "License") for full details. + + Every copy of Aladdin Ghostscript must include a copy of the License, + normally in a plain ASCII text file named PUBLIC. The License grants you + the right to copy, modify and redistribute Aladdin Ghostscript, but only + under certain conditions described in the License. Among other things, the + License requires that the copyright notice and this notice be preserved on + all copies. + +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +This file, bug-form.txt, contains an e-mailable form for reporting problems. +Please read the section titled "If you need help" in new-user.txt before +using the form below. For an overview of Ghostscript and a list of the +documentation files, see README. + +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +Please e-mail the completed form to ghost@aladdin.com. We can't promise to +investigate every reported problem, but we do give priority to those +reported using this form. Thanks. + +------snip------snip------snip------snip------snip------snip------snip------ + +Ghostscript version: + +Where you got Ghostscript: + +Hardware you are using: + +Operating system you are using: + +(If you compiled Ghostscript yourself) +C compiler you are using (including compiler version): + +(If you compiled Ghostscript yourself) +Changes you made to the makefile(s), if any: + +Environment variables (GS_DEVICE, GS_FONTPATH, GS_LIB, GS_OPTIONS): + +Command line: + +URL or FTP location of test file(s) +(or include the data at the end of this form if short): + +(Use as much space as you need for the remaining items.) +Symptoms: + +Suggested fix (if any): + +Other comments: + +------snip------snip------snip------snip------snip------snip------snip------ diff --git a/gs/c-style.txt b/gs/c-style.txt new file mode 100644 index 000000000..1b59f99b1 --- /dev/null +++ b/gs/c-style.txt @@ -0,0 +1,329 @@ + Copyright (C) 1996, 1997 Aladdin Enterprises. All rights reserved. + + This file is part of Aladdin Ghostscript. + + Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author + or distributor accepts any responsibility for the consequences of using it, + or for whether it serves any particular purpose or works at all, unless he + or she says so in writing. Refer to the Aladdin Ghostscript Free Public + License (the "License") for full details. + + Every copy of Aladdin Ghostscript must include a copy of the License, + normally in a plain ASCII text file named PUBLIC. The License grants you + the right to copy, modify and redistribute Aladdin Ghostscript, but only + under certain conditions described in the License. Among other things, the + License requires that the copyright notice and this notice be preserved on + all copies. + +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +This file, c-style.txt, describes Aladdin's C coding guidelines. + +For an overview of Ghostscript and a list of the documentation files, see +README. + +Generalities +============ + +All the rules below are meant to produce code that is easy to read. If you +find a rule getting in your way or producing ugly-looking results once in a +while, it's OK to break it. + +Indentation +----------- + +Tab stops are set every 8 columns. However, tabs are not equivalent to +logical nesting levels for C code: see below for details. + +File layout +----------- + +Every code file should start with comments containing a copyright notice, +the name of the file, and a half-to-one-line summary of what the file +contains. If you create a file by copying the boilerplate from another +file, make sure to edit the copyright year and the file name. + +C code +====== + +makefiles +--------- + +For each #include "xxx.h", make sure there is a dependency on $(xxx_h) in +the makefile. If xxx ends with a _, this rule still holds: e.g., #include +"math_.h" should create a dependency on $(math__h) (two underscores). + +List the dependencies bottom-to-top, like the #includes themselves; within +each level, list them alphabetically. Also do this with the #includes +themselves whenever possible (but sometimes there are inter-header +dependencies that require bending this). + +Headers +------- + +In header files, always use the following to prevent double inclusion: + + << copyright notice, file name, 1-line file description >> + + #ifndef _INCLUDED + # define _INCLUDED + + << contents of file >> + + #endif /* _INCLUDED */ + +The header file is the first place that a reader will go to find out +information about procedures, structures, constants, etc. Make sure that +every procedure and structure has a comment that says what it does. Divide +procedures into meaningful groups set off by some distinguished form of +comment. + +#include lists +-------------- + +List #includes from "bottom" to "top", i.e., in the following order: + System includes ("xxx_.h") + g*.h + s*.h + pl*.h + p[cg]*.h + +Indentation +----------- + +Put the first indentation point at the first tab stop; thereafter, each +level of logical nesting indents by an additional 4 columns. Proceed as +follows: + + { ... in-line compound statement ... + ... (indented +2 columns) + } + ... construct requiring subordinate code ... + ... subordinate simple statement ... (indented +2 columns) + ... construct requiring subordinate code ... + { ... subordinate code ... + ... (indented +4 columns) + } + +Or you can do this if you prefer: + + { + ... in-line compound statement ... + } + ... construct requiring subordinate code ... + ... subordinate simple statement ... + ... construct requiring subordinate code ... + { + ... subordinate code ... + } + +But not this: + + if ... { + ... subordinate code ... + } else { + ... subordinate code ... + } + +Spaces +------ + +Do put a space: + - after every comma and semicolon, unless it ends a line; + - around every binary operator, although you can omit the spaces + around the innermost operator in a nested expression if you like; + - on both sides of the the parentheses of an if, for, or while. + +Don't put a space: + - at the end of a line; + - before a comma or semicolon; + - after unary prefix operators; + - before the parenthesis of a macro or procedure call. + +Parentheses +----------- + +There are just a few places where parentheses are important: + + - In expressions that mix && and ||, around the inner + subexpressions, even if not required by precedence, e.g., + (xx && yy) || zz + + - In expressions that mix &, |, and/or shifts, especially if + mixing these with other operators, around the inner subexpressions + similarly, e.g., + (x << 3) | (y >> 5) + + - In macro definitions, around every use of an argument that + logically could be an expression, e.g., + ((x) * (x) + (y) * (y)) + +Anywhere else, given the choice, use fewer parentheses. + +For stylistic consistency with the existing Ghostscript code, put +parentheses around conditional expressions, even if they aren't +syntactically required, unless you really dislike doing this. Note that the +parentheses should go around the entire expression, not the condition: e.g., +instead of + + hpgl_add_point_to_path(pgls, arccoord_x, arccoord_y, + (pgls->g.pen_down) ? gs_lineto : gs_moveto); + +use + + hpgl_add_point_to_path(pgls, arccoord_x, arccoord_y, + (pgls->g.pen_down ? gs_lineto : gs_moveto)); + +Types +----- + +Use 'private' instead of 'static' for constructs (procedures and variables) +declared at the outermost scope. This allows making such constructs either +visible or invisible to profilers with a single changed #define. + +Use const wherever possible and appropriate. + +If you find yourself wanting to use void *, try to find an alternative using +unions or (in the case of super- and subclasses) casts, unless you're +writing something like a memory manager that really treats memory as opaque. + +Use anonymous structures as little as possible. Declare structure types +like this (the _t on the type name is preferable but not required): + + typedef struct xxx_yyy_s { + ... members ... + } xxx_yyy_t; + +Don't declare parameters as being of type float, short, or char. If you do +this and forget to include the prototype at a call site, ANSI compilers will +generate incompatible calling sequences. Use floatp (a synonym for double) +instead of float, and use [u]int instead of short or char. + +If you have a parameter that is itself a procedure, do list its parameter +types rather than just using (). + +Names +----- + +Use fully spelled-out English words in names rather than contractions. This +is most important for procedure and macro names, global variables and +constants, #defined and enum values, structure and other typedef names, and +structure member names, and for argument and variable names which have +uninformative types like int. It's not very important for arguments or +local variables of distinctive types, or for local index or count variables. + +Avoid names that run English words together. hpgl_compute_arc_center is +preferable to hpgl_compute_arccenter. + +Procedures, variables, and structures visible outside a single .c file +should generally have a prefix that indicates what subsystem they belong to +(in the case of Ghostscript, gs_ or gx_). This rule isn't followed very +consistently. + +Commenting +---------- + +The most important descriptive comments are ones in header files that +describe structures, including invariants. But every procedure or structure +declaration, or group of other declarations, should have a comment. + +Other formatting +---------------- + +Format procedures as follows: + +scope return_type +proc_name(type1 arg1, type2 arg2, type3 arg3, type4 verylongargument4, + type5 argument5) +{ ... body ... +} + +Leave a blank line after the declarations of local variables in a procedure +or compound statement, unless there's only 1 variable and the scope is less +than 10 lines or so. + +Other +----- + +When calling a variable or parameter procedure, do use explicit indirection, +e.g., (*func)(...) rather than func(...). It makes it clearer to the reader +what is going on. Also, not all compilers accept the elision. (gcc accepts +a dismaying number of constructs that other compilers dislike.) + +ANSI compilers in their default mode do all floating point computations in +double precision, so never cast a float to a double explicitly. + +Unless there's a good reason for doing otherwise, return floatp (double) +rather than float values. Many FPUs do everything in double internally and +have to do extra work to convert between double and float. + +In general, don't create procedures that are private and only called from +one place. However, if a compound statement (especially an arm of a +conditional) is long enough that the eye can't easily match up its } with +its { (i.e., it's longer than 10 or 15 lines), and it doesn't use or set a +lot of state held in outer local variables, putting it in a procedure may +help readability. + +Global variables +---------------- + +Avoid global variables (non-const data) like the plague. Avoid global const +data, but don't knock yourself out over it. + +Local variables +--------------- + +Avoid assigning new values to procedure parameters. It makes debugging very +confusing when the parameter values printed for a procedure are not the ones +actually supplied by the caller. Instead, use a separate local variable +that is initialized to the value of the parameter. + +If a local variable only gets assigned a value once, assign it that value at +its declaration, if convenient. E.g., + + int x = ; + +rather than + + int x; + ... + x = ; + +Error handling +-------------- + +By convention, nearly all procedures return an int that indicates the +outcome of the call: 0 indicates a normal return, >0 indicates a non-error +return other than the normal case, and <0 indicates an error. All callers +should check for error returns and, in general, propagate them to *their* +caller. + +Preprocessor conditionals +------------------------- + +Conditionals can easily lead to unreadable code, since the eye really wants +to read linearly rather than having to parse the conditionals just to figure +out what code is relevant. It's OK to use conditionals that have small +scope and that don't change the structure or logic of the program +(typically, they select between different sets of values depending on some +configuration parameter), but where possible, break up source modules rather +than use conditionals that affect the structure or logic. + +Preprocessor macros +------------------- + +If you define a macro that looks like a procedure, make sure it will work +wherever a procedure will work. In particular, put parentheses around every +use of a macro argument, so that the macro will parse correctly if some of +the arguments are expressions. + +PostScript code +=============== + +Put indentation points every 3 spaces. + +Format procedure definitions like this: + +/procname % procname + { ...code... + } bind def diff --git a/gs/commprod.txt b/gs/commprod.txt new file mode 100644 index 000000000..e1ec055b5 --- /dev/null +++ b/gs/commprod.txt @@ -0,0 +1,220 @@ + Copyright (C) 1993, 1994, 1995 Aladdin Enterprises. All rights reserved. + +Permission to copy and distribute this document unmodified for any +purpose is hereby granted without fee, provided that the above +copyright notice and this permission notice appear in all copies. + +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +This file, commprod.txt, sets forth the conditions under which Ghostscript +may be distributed in a commercial context: under a written license from +Artifex Software Inc., Aladdin Enterprises' exclusive commercial licensing +partner, or under certain other very limited conditions. + +For an overview of Ghostscript and a list of the documentation files, see +the README file in the Ghostscript fileset. + + + The Use of the Public Access "Free" Version of Ghostscript + ---------------------------------------------------------- + +Ghostscript is a copyrighted work whose copyright is owned by Aladdin +Enterprises. Some versions of Ghostscript are distributed freely under the +name Aladdin Ghostscript; these versions are always distributed with a +license, called the Aladdin Ghostscript Free Public License (also known as +the AGFPL), which permits Aladdin Ghostscript to be redistributed freely +under certain conditions. These conditions will almost always be met easily +by individuals in their personal use of Aladdin Ghostscript. Aladdin +Ghostscript may be *used* freely, including by commercial entities for +evaluation or unsupported internal use. However, *distribution* for +commercial purposes of Ghostscript, or anything containing or derived from +Ghostscript in whole or in part, generally requires a written commercial +license from Artifex Software Inc., the sole entity authorized by Aladdin +Enterprises to grant such licenses. More specifically, the AGFPL states: + + Distribution of the Program or any work based on the Program by a + commercial organization to any third party is prohibited if any payment is + made in connection with such distribution, whether directly (as in payment + for a copy of the Program) or indirectly (as in payment for some service + related to the Program, or payment for some product or service that + includes a copy of the Program "without charge"; these are only examples, + and not an exhaustive enumeration of prohibited activities). However, the + following methods of distribution involving payment shall not in and of + themselves be a violation of this restriction: + + (i) Posting the Program on a public access information storage and + retrieval service for which a fee is received for retrieving information + (such as an on-line service), provided that the fee is not + content-dependent (i.e., the fee would be the same for retrieving the same + volume of information consisting of random data). + + (ii) Distributing the Program on a CD-ROM, provided that the files + containing the Program are reproduced entirely and verbatim on such + CD-ROM, and provided further that all information on such CD-ROM be + redistributable for non-commercial purposes without charge. + +The intent of the exception provided in clause (i) is to allow commercial +organizations operating an FTP server or a bulletin board to distribute +Aladdin Ghostscript freely from it, provided that: + + (1) the organization complies with the other provisions of the +AGFPL, which include among other things a requirement to distribute the +full source code of Aladdin Ghostscript and of any derived work, and to +distribute the AGFPL itself along with Aladdin Ghostscript; + + (2) the only charge for downloading Aladdin Ghostscript is a charge +based on the distribution service and not one based on the content of the +information being retrieved (i.e., the charge would be the same for +retrieving a random collection of bits of the same size); + + (3) the server or BBS is accessible to the general public, i.e., +the phone number or IP address is not kept secret, and anyone may obtain +access to the information (possibly by paying a subscription or access fee +that is not dependent on or related to purchasing anything else). + +Similarly, the exception in clause (ii) is intended to allow inclusion of +Aladdin Ghostscript on "freeware" CD-ROMs that contain only material that is +in the public domain, or is freely redistributable provided only that a +copyright notice is retained (such as the Independent JPEG Group libraries), +or is distributed under some other kind of license allowing free +redistribution such as the GNU General Public License. + +If you want to distribute software in a commercial context that incorporates +Ghostscript and you do *not* want to meet these conditions, you should +contact Artifex Software to find out about commercial licensing. Commercial +licenses involve a (negotiated) payment, and include support and other +benefits. These are the only ways you legally can distribute Ghostscript or +anything containing Ghostscript: either by distributing Aladdin Ghostscript +under the requirements of the AGFPL, or by getting a commercial license from +Artifex Software. + +For commercial licensing, please contact: + + Miles Jones + Director of Marketing + Artifex Software Inc. + 454 Las Gallinas Ave., suite 108 + San Rafael, CA 94903 U.S.A. + voice +1-415-492-9861 + fax +1-415-492-9862 + e-mail: info@arsoft.com + +If you have any questions about any of the information in this document, +please contact: + + Aladdin Enterprises + 203 Santa Margarita Ave. + Menlo Park, CA 94025 U.S.A. + voice +1-650-322-0103 (8:30 AM - noon, Monday - Friday) + fax +1-650-322-1734 + e-mail: ghost@aladdin.com + +Appendix: The GNU General Public License +---------------------------------------- + +Older versions of Ghostscript (versions of 2.6.1 and previous) were +distributed with a license called the GNU General Public License (also known +as the "GNU License", the "GPL", or the "copyleft"), which allowed +distribution with commercial products under certain conditions. Aladdin +Enterprises may choose to distribute other versions of Ghostscript with the +GPL in the future; however, these versions will be identified as "GNU +Ghostscript." The remainder of this Appendix applies only to versions +identified explicitly as GNU Ghostscript versions; the generic name +Ghostscript, when applied to versions above 2.6.1, refers to Aladdin +Ghostscript, which is governed by the Aladdin Ghostscript Free Public +License, not the GPL. + +For those unfamiliar with the GPL, we now summarize its provisions. The +full GPL is included under the name COPYING in the fileset that comprises +GNU Ghostscript, and can also be obtained from: + Free Software Foundation, Inc. (FSF) + 59 Temple Place - Suite 330 + Boston, MA 02111-1307 + U.S.A. + tel. +1-617-542-5942 + fax (including Japan): +1-617-542-2652 + e-mail gnu@prep.ai.mit.edu + Free Dial Fax (in Japan): 0031-13-2473 (KDD) + 0066-3382-0158 (IDC) +In case of doubt or conflict, the contents of the COPYING file or the +document obtained from the FSF, not this summary, are authoritative. + + 1. Anyone may copy and distribute GNU Ghostscript (both source and +object code), but they must distribute the source code as well as the +object code (or, if they distribute only the object code, they must +include an offer in writing to provide the source code at no more than +reproduction cost), keep all copyright and other notices, and include the +GPL with the copies. (Note that this allows anyone receiving such a copy +to distribute it freely as well.) + + 2. Anyone may modify GNU Ghostscript, but the provisions of #1 +apply to modified or derived works as well. + + 3. GNU Ghostscript may be "aggregated" with another program; in +this case, #1 and #2 do not apply to the other program, but only to GNU +Ghostscript. + +Provision #1 makes it much harder to have a commercial business based only +on selling copies of GNU Ghostscript (as distributed with the GPL) or +products that contain GNU Ghostscript, since any customer is free to make +as many copies as they want for any purpose. Provision #2 effectively +prevents the development of proprietary commercial products that +incorporate GNU Ghostscript without a commercial license as a part, since +these are "derived works" in the legal sense. + +Questions have arisen at times in particular cases regarding provision #3 +as to whether GNU Ghostscript is "aggregated" with other parts of a +commercial product, or whether the product has become a "derived work." +Normally, combining GNU Ghostscript with another piece of software creates +a "derived work"; we consider GNU Ghostscript to be "aggregated" with +another piece of software, which we will refer to as "the application", +only if all of the following conditions are met: + + - The code and documentation for GNU Ghostscript are physically + separated from the code and documentation for the application. + For electronic form, it is both necessary and sufficient to put + the GNU Ghostscript code and documentation in their own directory + tree(s). + + - GNU Ghostscript, as delivered with the application, is usable + independently of the application. More precisely, if a user + deletes from the computer system all files delivered with the + application except those in the GNU Ghostscript directories, the + user will still be able to use GNU Ghostscript as described in + GNU Ghostscript's documentation. Among other things, this + requires that GNU Ghostscript not call any routines in the + application, and not require any data or other files supplied as + part of the application. + + - The application calls GNU Ghostscript in a way that allows an + ordinary user to substitute another program for GNU Ghostscript. + (Typically this requires use of a shell script or batch file, or a + system call like `exec'.) More precisely, if the user deletes + from the computer system all the files in the GNU Ghostscript + directories, and replaces the GNU Ghostscript executable with + another program with the same name and conforming to the same + documentation, the application will continue to work with it. One + implication of this is that the GNU Ghostscript documentation must + specify all properties of GNU Ghostscript on which the application + relies; for example, if GNU Ghostscript has been modified by the + addition of command line switches or language elements such as new + operators, the documentation must describe any such additions that + the application uses. + + - The conditions of the GPL are met with respect to GNU + Ghostscript, including the requirement for propagation of the GPL + and the requirement for delivering (or an offer to deliver) source + code. + +Regarding this last point, the GPL clearly intends that if the distributor +only offers to provide the GNU Ghostscript source code (as opposed to +actually distributing the source code with every copy of the application), +then they must deliver the source code in a timely way to anyone +requesting it. + +The GPL makes it clear that if someone receives GNU Ghostscript only in +its GPL-licensed form, they only have a right to distribute it if they +comply with the GPL. Aladdin Enterprises, as the copyright holder, takes +this requirement very seriously, and will, if necessary, take legal action +to ensure that anyone distributing GNU Ghostscript with the GPL complies +with the conditions set forth above. diff --git a/gs/copying b/gs/copying new file mode 100644 index 000000000..1d6e21632 --- /dev/null +++ b/gs/copying @@ -0,0 +1,10 @@ + + THIS IS *NOT* THE GNU GENERAL PUBLIC LICENSE + + Many versions of Ghostscript, including all versions created before +June 1993, are customarily distributed with a license called the GNU +General Public License; in these versions, a file named COPYING contains a +copy of the license. This copy of Ghostscript is governed not by the GNU +License, but by a substantially different license in a similar spirit, the +Aladdin Ghostscript Free Public License; the file PUBLIC contains a copy of +this license. diff --git a/gs/current.txt b/gs/current.txt new file mode 100644 index 000000000..e2c281abe --- /dev/null +++ b/gs/current.txt @@ -0,0 +1,119 @@ + Copyright (C) 1990, 1995, 1996, 1997, 1998 Aladdin Enterprises. All rights reserved. + + This file is part of Aladdin Ghostscript. + + Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author + or distributor accepts any responsibility for the consequences of using it, + or for whether it serves any particular purpose or works at all, unless he + or she says so in writing. Refer to the Aladdin Ghostscript Free Public + License (the "License") for full details. + + Every copy of Aladdin Ghostscript must include a copy of the License, + normally in a plain ASCII text file named PUBLIC. The License grants you + the right to copy, modify and redistribute Aladdin Ghostscript, but only + under certain conditions described in the License. Among other things, the + License requires that the copyright notice and this notice be preserved on + all copies. + +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +This file, current.txt, describes problems and new features in the current +release of Ghostscript. This file describes version 5.13 of Ghostscript. + +For an overview of Ghostscript and a list of the documentation files, see +README. + +New features (since release 5.03) +============ + +(This is not a complete list of new features: see NEWS for details.) + +ps2pdf (and the pdfwrite device) now produces much more compact output. By +default, the output is compatible only with Acrobat 3.x; for Acrobat +2.x-compatible output, use + ps2pdf -dCompatibilityLevel=1.1 ... + +ps2pdf now has more flexibility about the handling of unencoded glyphs. See +gdevpdft.c for details. + +ps2pdf now recognizes the CompressPages, CompatibilityLevel, and +UseFlateCompression device (distiller) parameters. + +The PDF interpreter now handles Lab and Separation color spaces, images with +color space resources, embedded font subsets, undefined operators with +BX/EX, and Functions. + +Changes +======= + +The RGB<->CMYK conversion rules have been changed back to Adobe's documented +rules. + +Known problems +============== + +(This is not a complete list of known problems: see NEWS for details.) + +Usage +----- + +On a MS-DOS system, interrupting the interpreter by typing ^C doesn't +restore the display mode. + +Limitations +----------- + +serialnumber returns the same value in all copies. + +Some floating point exceptions terminate the interpreter, rather than +producing a limitcheck error. + +The DCTEncode filter disregards the Blend parameter, and uses different +QuantTables and HuffTables from Adobe's. + +The DCT filters do not support nonintegral sample ratios. Also, DCTEncode +will not create files with Sum(HS*VS)>10 (regardless of the value of the +Relax parameter) because they violate the JPEG standard; but DCTDecode will +read such files. + +The size of the execution stack cannot be changed dynamically. (However, +the sizes of the operand and dictionary stacks can be changed.) + +Separation color spaces are implemented, but devices that actually produce +color separations are not supported. The special color separations All and +None, and the primary separations (Red, Green, etc.), are not supported. + +execform and ucache are implemented, but they do not actually do any +caching; setucacheparams and ucachestatus are dummies. (This only impacts +performance, not functionality.) + +The image operator only honors the Interpolate flag in the image dictionary +if the combined transformation (ImageMatrix + CTM) doesn't involve rotation, +skewing, or X-reflection; imagemask doesn't honor Interpolate at all. + +Some path building operations that would generate a device coordinate larger +than +/-2^19 will cause a limitcheck. However, the common ones ([r]moveto, +[r]lineto, [r]curveto, closepath) will not. + +Graphics bugs +------------- + +Opening more than one window device at the same time doesn't work. +This is the case for both X Windows and Microsoft Windows. + +cshow doesn't work with composite fonts. + +Non-graphics bugs +----------------- + +The %statementedit pseudo-file is equivalent to %lineedit. As a +consequence, the interactive interpreter requires that every statement fit +on a line, i.e., you can't have an unpaired (, {, or <. + +The following operators that expect arrays won't accept packed arrays: + definefont (Subrs (type 1 fonts)) + +Syntax errors occurring within a binary token do not produce the error +message specified by the Adobe documentation. + +save doesn't save, and restore doesn't restore, the user parameters. diff --git a/gs/devices.txt b/gs/devices.txt new file mode 100644 index 000000000..ff2d2bc97 --- /dev/null +++ b/gs/devices.txt @@ -0,0 +1,2352 @@ + Copyright (C) 1992, 1995 Aladdin Enterprises. All rights reserved. + + This file is part of Aladdin Ghostscript. + + Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author + or distributor accepts any responsibility for the consequences of using it, + or for whether it serves any particular purpose or works at all, unless he + or she says so in writing. Refer to the Aladdin Ghostscript Free Public + License (the "License") for full details. + + Every copy of Aladdin Ghostscript must include a copy of the License, + normally in a plain ASCII text file named PUBLIC. The License grants you + the right to copy, modify and redistribute Aladdin Ghostscript, but only + under certain conditions described in the License. Among other things, the + License requires that the copyright notice and this notice be preserved on + all copies. + +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +This file, devices.txt, gives more detailed documentation about +certain specific devices for which Ghostscript can produce output. + +For an overview of Ghostscript and a list of the documentation files, see +README. + +Devices for which this file currently contains documentation: + SPARCprinter + HP DeskJet 520, 540, and 560C + HP DeskJet 500C & 550C + HP PaintJet, XL, and XL300 + DEC LJ250 + Apple Dot Matrix Printer (and Imagewriter) + Epson Stylus Color Printer + ESC/P, ESC/P2 Color-Printers + Canon BJC-600/BJC-4000/BJC-70 and BJC-800 BubbleJet Color Printers + (and Apple StyleWriter 2x00) + uniprint - a configurable ESC/P, ESC/P2 & HP-RTL/PCL-Driver + JPEG files + +### ------------------------- The SPARCprinter ------------------------- ### + +This section was written by Martin Schulte. + +Introduction +------------ + +The SPARCprinter is is connected to SPARCStation via a special SBUS card's +video interface, the picture is composed on the host and only a bitmap is +send to the printer unit. + +Together with a SPARCprinter, you always buy (as far as I know) software +that enables you to do postscript-printing on your SPARCPrinter. + +So, the need for a Ghostscript-Interface to the SPARCPrinter seems low, +but on the other hand some Postscript drawings are not correctly printed +with SUN's software: on some pages occurred a thin vertical line of rubbish +(reproduceable), on some Mathematica drawings the text at the axes wasn't +rotated. + +I tried all of these with Ghostscript and always got the expected results. + +However, replacing proprietary software should never be a bad idea. + +The problem is that there has yet been no effort to make the SPARCPrinter- +driver behave like a BSD output-filter, I made my tests using the script +mentioned under Installation. + +Installation +------------ + +Add sparc.dev to DEVICE_DEVS and compile ghostscript as described in +make.txt. + +Afterwards, you can use the following script (the way of handling standard +input versus filename-arguments doesn't look very clever, has anyone a +better idea ?) to print if you substitute by the place where you +installed the ghostscript binary: + +outcmd1='/vol/local/lib/troff2/psxlate -r' +outcmd2=' -I/home/schulte/gs252 -sDEVICE=sparc -sOUTPUTFILE=/dev/lpvi0 -' + +if [ $# -eq 0 ] +then + $outcmd1 | $outcmd2 +else + cat $* | $outcmd1 | $outcmd2 +fi + +Problems +-------- + +Since /dev/lpvi can only be opened for exclusive use, another job having +opened it (engine_ctl_sparc or another ghostscript as the most probable +candidates) will cause to stop ghostscript with "Error: /invalidfileaccess +in --.outputpage--" + +In case of common printer problems like out of paper, a warning describing +the reason will be printed to stdout, the driver will try to access again +and again each five seconds. + +Due to a problem with the device-driver (in the kernel) the reason of +printer failure is not always correctly reported to program. This is the +case at least if you open the top cover (Error in the display: E5). Look +to the display at the printer if a "Printer problem with unknown reason" +is reported. + +Fatal errors will cause the print-job to be terminated. + +### ------------------------------ End --------------------------------- ### + +### ------------------- H-P color inkjet printers ---------------------- ### +### (DeskJet 500C, DeskJet 550C, PaintJet, PaintJet XL, PaintJet XL300 ### +### and the DEC LJ250 which can operate in a Paintjet-compatible mode) ### + +This section was written by George Cameron. + +Information and tips on usage for the drivers contained in gdevcdj.c +==================================================================== + +OVERVIEW: + +There are 6 generic drivers contained in the source module: + + 1 - cdj500: HP DeskJet 500C and 540C + 2 - cdj550: HP DeskJet 550C, 560C, 660C, 660Cse + 3 - pjxl300: HP PaintJet XL300 and DeskJet 1200C + 4 - pjtest: HP PaintJet + 5 - pjxltest: HP PaintJet XL + 6 - declj250: DEC LJ250 + + All of these drivers have 8-bit (monochrome), 16-bit and 24-bit + (colour) and for the DJ 550C 32-bit, (colour, cmyk mode) + options in addition to standard colour and mono drivers. + It is also possible to set various printer-specific parameters + from the gs command line, eg. + + gs -sDEVICE=cdeskjet -dBitsPerPixel=16 -dDepletion=1 -dShingling=2 tiger.ps + +NB/ The old names cdeskjet, cdjcolor and cdjmono drivers have been retained; + however, their functionality duplicates that available using the above + drivers (and cdeskjet is identical to cdj500), ie. we can use: + + gs -sDEVICE=cdj500 -dBitsPerPixel=24 ... for cdjcolor, and + gs -sDEVICE=cdj500 -dBitsPerPixel=1 ... for cdjmono + + +DEFAULT PAPER SIZE: + + If the preprocessor symbol A4 is defined, the default paper size is the + European A4 size; otherwise it is the U.S. letter size (8.5"x11"). Other + paper sizes (including A3 for the PaintJet XL and PaintJet XL300) may be + specified on the command line as explained in the Ghostscript documentation. + + +DEFAULT BITS-PER-PIXEL: + + If the preprocessor symbol BITSPERPIXEL is defined as an integer (see below + for the range of allowable values), this number will be used to define the + default bits-per-pixel (ie. bit depth) for the generic drivers. If the + symbol is not defined, the default is set to 24 bits per pixel. It is + of course still possible to specify the value from the command line, as + described below. Note also that the cdeskjet, cdjcolor and cdjmono + drivers are unaffected by setting this symbol, as their default settings + are predefined to be 1, 3 and 24 respectively. + + +DESKJET PHYSICAL LIMITS: + + Maximum printing width = 2400 dots = 8". The printer manuals say that the + maximum recommended printing height on the page is 10.3", but since this + is obviously not true for A4 paper, and I have been unable to detect any + problems in printing longer page lengths, this would seem to be a rather + artificial restriction. + + All Deskjets have 1/2" unprintable bottom margin, due to the mechanical + arrangement used to grab the paper. Side margins are approximately 0.25" + for US Letter paper, and 0.15" for A4. + + +COMMAND LINE PARAMETERS: + + Several printer 'properties' have been implemented for these printers. + Those available so far are all integer quantities, and thus may be + specified as eg. + + gs -dBitsPerPixel=32 -dShingling=1 ... + + which sets the BitsPerPixel parameter to 32 and the Shingling parameter + to 1. + + +BITS-PER-PIXEL: + + All of the drivers in gdevcdj.c accept a command line option to set the + BitsPerPixel property. This gives considerable flexibility in choosing + various trade-offs between speed/quality/colour etc. The valid numbers + are: + + 1: This is a standard Ghostscript monochrome driver, and uses + black ink (by installing the separate mono cartridge in + the case of the DeskJet 500C, or automatically for the + other printers) + + 3: A standard Ghostscript colour driver, using internal + dithering. This is fast to compute and to print, but + the clustered dithering can lose some detail and + colour fidelity. + + 8: An 'error-diffusion' monochrome driver which uses + Floyd-Steinberg dithering to print greyscale images. + The patterns are much more randomised than with the + normal clustered dithering, but the data files can + be much larger and somewhat slower to print. + + 16: This is a 'cheaper' version of the following (24-bit) + driver, which generates a Floyd-Steinberg colour dithered + output using the minimum amount of memory (this may be + helpful when using IBM PC's when Ghostscript has not + been compiled using a 32-bit 386-style compiler). The + quality can be almost as good as the 24-bit version. + + 24: A high-quality colour driver using Floyd-Steinberg dithering + for maximum detail and colour range. However it is very + memory intensive and thus can be slow to compute (and it + tends to produce rather larger raw data files, so they + can also be slower to print). + + 32: This is for the DeskJet 550C only, which uses the black + cartridge and the colour cartridge simultaneously (ie. + CMYK printing). This printer can be both faster and give + higher quality than the DeskJet 500C, because of the + true black ink. (Note that the 24-bit mode also permits + CMYK printing on this printer, and uses less memory. Any + differences between 24-bit and 32-bit should be very small.) + + +DESKJET PROPERTIES: + + The additional properties available for the DeskJets are: + + BlackCorrect (int) /* Colour correction to give + * better blacks when using the DJ500C + * in colour mode, eg. the default of 4 + * reduces the cyan component to 4/5 + * Range accepted: 0 - 9 (0 = none) */ + Shingling (int) /* Interlaced, multi-pass printing + * 0 = none, 1 = 50%, 2 = 25%, 2 is + * best & slowest */ + Depletion (int) /* 'Intelligent' dot-removal + * 0 = none, 1 = 25%, 2 = 50%, 1 best + * for graphics? + * Use 0 for transparencies */ + +PAINTJET XL300/PAINTJET XL PROPERTIES: + + PrintQuality (int) /* Mechanical print quality + * -1 = fast, 0 = normal, 1 = presentation + * Fast mode reduces ink usage and uses + * single-pass operation for some media + * types. Presentation uses more ink and + * max number of passes, ie. slowest + * printing for highest quality */ + RenderType (int) /* 0 = driver does dithering + * 1 = snap to primaries + * 2 = snap black -> white, others to black + * 3 = ordered dither + * 4 = error diffusion + * 5 = monochrome ordered dither + * 6 = monochrome error diffusion + * 7 = cluster ordered dither + * 8 = monochrome cluster ordered dither + * 9 = user-defined dither (not supported) + * 10 = monochrome user-defined dither ns. */ + +PAINTJET PROPERTIES: + + No additional properties + + +GAMMA CORRECTION: + + One consequence of using Floyd-Steinberg dithering rather than Ghostscript's + default clustered ordered dither is that it is much more obvious that the + ink dots are rather larger on the page than their nominal 1/180" or 1/300" + size (clustering the dots tends to minimise this effect). Thus it is often + the case that the printed result is rather too dark. A simple empirical + correction for this may be achieved by preceding the actual postscript + file to be printed by a short file which effectively sets the gamma for + the device, eg. + + gs ... gamma.ps colorpic.ps -c quit + + where gamma.ps is + +%! +{0.333 exp} dup dup currenttransfer setcolortransfer + + This example sets the gamma for r, g, and b to 3, which seems to work + reasonably well in practice. + + +GENERAL TIPS: + + For all the above printers, the paper is critically important to the + final results. Smoother, less fibrous paper is generally better (and + suggested types are given in the printer manuals). In particular, the + special ink-jet paper can make a big difference; the colours are + brighter, but most importantly, there is almost no colour bleed, even + with adjacent areas of very heavy inking. Similarly, the special coated + transparencies also work well (and ordinary transparencies do not work + at all!) + + The unix-lpr.sh provides one example of setting up a multi-option + colour postscript lpr queue on Unix systems, and includes the ability + to choose a range of different colour options and printer accounting + and error logging. + + +CAVEAT EMPTOR!: + + It is not always easy for me to test all of these drivers, as the only + colour printer I have here is the DeskJet 500C. I rely on others testing + drivers for the additional machines and reporting their findings back to + me. + +HP's 600x300 dpi resolution-enhanced mode for inkjet printers +============================================================= + +This feature is available on HP's more recent inkjet printers, +including the Deskjet 520 (mono) 540 (mono or colour) and 560C (mono +and colour). + +The colour and monochrome drivers for the HP deskjet 550c are +(probably) the best you will get for use with ghostscript, for the +following reasons: + +These printers do not offer true 600x300 dpi resolution. Those that +print in colour are strictly 300x300 dpi in colour mode, while in mono +mode there is a pseudo 600x300 dot mode, with the restriction that you +can't print two adjacent dots. Thus, in effect what you have is 600 dpi +dot positioning, but on average you don't get more dots per line. + +What this does give is the possibility to have eg. sharper character +outlines, as you can place dots on the edges nearer to their ideal +positions - this is why it is worth doing. + +However, HP will not support user-level programming of this +resolution-enhanced mode, one reason being that (I understand) all the +dot spacing has to be done by the driver, and if you get it wrong, you +can actually damage the print head. + +To summarise, you may lose a smidgin of (potential) text clarity using +the 550c drivers (cdj550, cdjcolor, cdjmono etc.), but other than that, +they are the ones for the job. + +### ------------------------------ End --------------------------------- ### + +### ------------------- Apple Dot Matrix Printer ---------------------- ### + +This section was written by Mark Wedel. + + The Dot Matrix Driver (DMP) driver is a simple driver I wrote. It +could more more efficient, but it seems to print the images fine. + + The Dot Matrix Printer was a parallel predecessor to the Imagewriter +printer. As far as I know, the Imagewriter commands are a superset +to those of the Dot Matrix printer, so the driver should work fine at +generating output that can be printed on Imagewriters. + + A few notes (from the gdevadmp.c file): + + * To print out images, it sets the printer for unidirectional printing + * and 15 cpi (120 dpi). It sets the line feed to 1/9 of an inch (72 dpi). + * When finished, it sets things back to bidirectional printing, 1/8" line + * feeds, and 12 cpi. There does not appear to be a way to reset + * things to initial values. + * + * This code does not set for 8 bit characters (which is required). It + * also assumes that carriage return/newline is needed, and not just + * carriage return. These are all switch settings on the DMP, and + * I have configured them for 8 bit data and cr only. + * + * You can search for the strings Init and Reset (in devdemp.c) to find the + * strings that set up the printer and clear things when finished, and change + * them to meet your needs. + * + * Also, you need to make sure that the printer daemon (assuming unix) + * doesn't change the data as it is being printed. I have set my + * printcap file (sunos 4.1.1) with the string: + * ms=pass8,-opost + * and it works fine. + + Mark Wedel +master@cats.ucsc.edu + +### ------------------------------ End --------------------------------- ### + +### ------------------ The Epson Stylus Color printer ------------------ ### +/* + Epson Stylus-Color Driver, contributed by Gunther Hess (address: see below) + +I N T R O D U C T I O N +======================= +This documentation accompanies version 1.90 of the stcolor-driver. +Compared to version 1.21 (gs3.53) there are just a few, but somehow +important chages: + + - Default: noWeave escpBand=1 (-> default works with all known models) + - added Parameter "Softweave" (useful only with Original STC and PRO-Series) + - added Compile-Option (-DSTC_SIGNAL) to catch interrupts during printing + (thanks to Frederic Loyer) + - compatibility with ansi2knr + - compatibility with 64Bit Processors + - clarification of usage with Pro-XL and Stylus Color II + +A Note on the Version-Numbering: Version 1.xx comes to it's end. +Any 1.xx > 1.90 will have only Bug-Fixes. Maybe that Version 2.xx +comes to life, if this is the case it will include full support of +the newer models. + +U S A G E +========= +This driver is selected with "-sDEVICE=stcolor" and produces output for an +Epson Stylus-Color at 360DpI resolution by default, but it can do much +more with this printer and with significantly better quality, than with +the default-mode and it can also produce code for the monochrome-versions +of this printer. + +This can be achieved either via command-line options or via ghostscript-input. +For convenience a Postscript-File is supplied, that can be used as initial +inputfile. Thus, assumed that ghostscript is invoked via "gs" on your computer, +try the following command: + + gs -sDEVICE=stcolor -rXDPIxYDPI stcolor.ps ... (e.g.: your input-files) + +were XDPI is one of 180/360/720 and YDPI is one of (90/)180/360/720. The result +should be significantly better, you may use "stcolor.ps" with other devices +too, but I do not recommend this, since it does nothing then. "stcolor.ps" +should be available with binary distributions and should reside in the +ghostscript input-directory. Thus if ghostscript is part of your +printer-spooler, you can insert + + (stcolor.ps) findlibfile { pop run } if pop + +to the files you want to run through the improved algorithms and you may want +to adapt this file to your specific needs. The methods and options for this +are described here, but this description is restricted to the gs-options, while +their manipulation at the Postscript-level is documented in "language.txt" and +in the mentioned "stcolor.ps". + +Next thing is to explain the options (as written on my unix-system). +The order is somehow related to their use during the printing-Process: + + -dUnidirectional - Force unidirectional printing, + recommended for transparencies + + -dMicroweave - enable the printers "microweave"-feature. + -dnoWeave - disable any Weaving, overrides -dMicroweave + -dSoftweave - enable internal weaving of the driver. + +* Weave-Note: Softweave works *ONLY* with the original Stylus-Color +* and the PRO-Series. + + -sDithering="name" - select another dithering-algorithm, available are: + "gscmyk" : fast color-output, with CMYK-ProcessColorModel [D] + "gsmono" : fast black & white output + "gsrgb" : fast color-output, with RGB-ProcessColorModel + "fsmono" : Floyd-Steinberg, Monochrome + "fsrgb" : Floyd-Steinberg, with RGB-ProcessColorModel + (Almost identical to cdj550/mjcxxx-Algorithm) + "fsx4" : Floyd-Steinberg, with CMYK-ProcessColorModel + (shares code with fsmono & fsrgb, but is + algorithmically really bad) + "fscmyk" : Floyd-Steinberg, with CMYK-ProcessColorModel + and proper modifications for CMYK + "hscmyk" : modified Floyd-Steinberg with CMYK-Model + ("hs" stands for "hess" nor for "high speed", + but the major difference to "fscmyk" is speed) + "fs2" : algorithm by Steven Singer (RGB) + should be identical to escp2cfs2. + + -dBitsPerPixel=1...32 - number of bits used for pixel-storage, the larger + the value, the better the quality - at least in + theory. In fsrgb one can gain some speed, when + restricting to 24 Bits, rather than the default + of 30. + + -dFlag0 - causes some algorithms to select a uniform + initialisation rather than a set of random-values. + May yield "sharper" image-impression at the + cost of "dithering-artifacts". + (applies to hscmyk and all fs-modi, except for fs2, + which always uses a constant initialization.) + + -dFlag1 ... -dFlag4 - available to future algorithms. + + -dColorAdjustMatrix={3/9/16 x float}' + - This is a Matrix to adjust the colors. Values should + be between -1.0 and 1.0, and the number of + values depend on the colormodel used by the + selected algorithm. In RGB- and CMYK-modi a matrix + with 1.0 on the diagonal produces no transformation. + (I could not identify a similar feature at the + language-level, so this option was implemented, it + is really required, but I don't know reasonable + values yet.) + + -dCtransfer='{float float ...}', -dMtransfer=..., -dY..., -dK... or + -dRtransfer='{float float ...}', -dG..., -dB... or + -dKtransfer='{float float ...}' + - which is used, depends on the algorithm, which + maybe either either CMYK, RGB or monochrome. + The values are arrays of floats in the range from + 0 to 1.0, which represent the visible + color-intensity for the device. One may achieve + similar effects with "setcolortransfer" at the + language-level, but this takes more time and the + underlying-code for the driver-specific parameters + is still required. The size of the arrays is + arbitrary and the defaults are {0.0 1.0}, which + is a linear characteristic, most of the code in + "stcolor.ps" are better transfer-arrays. + + -dKcoding='{float...}', -dC..., -dM... etc. + - this are again arrays between 0.0 and 1.0, and + they control the internal coding of the + color-values. Clever usage of this arrays may + yield further enhancements, but no experience yet. + [To be discontinued with version >= 2.x] + + -sModel=st800 - causes output to be suitable for the monochrome + Stylus 800 (no Weaving, no Color). + + -sOutputCode= - can be either "plain", "runlength" or "deltarow" + and changes the ESC/P2 (TM) coding-technique used + by the driver. The default is to use the + runlength-encoding. "plain" selects uncompressed + encoding and yields enormous amounts of data to + generated. + + -descp_Band=1/8/15/24 - Number of Nozzles of scanlines used in printing. + Useful only with -dnoWeave. Larger Values yield + smaller code, but this doesn't increase the + Printing-Speed. + + -descp_Width= - Number of Pixels Printed in each scan-Line. + (Useful when tuning Margins only, se below) + + -descp_Height= - Length of the entire Page in Pixels + (Parameter of "ESC(C" in default initialization) + + -descp_Top= - Top-Margin in scanlines. + (1st Parameter of "ESC(c" in default initialization) + + -descp_Bottom= - Bottom-Margin in scanlines. + (2nd Parameter of "ESC(c" in default initialization) + + -sescp_Init="..." - Override for the initialization-sequence. + (Must set Graphics-Mode-1 & Units) + + -sescp_Release="..." - Overrides the release-sequence. + (ESC @ FF by default) + + Valid Resolutions: + any, ESC/P2 allows in theory, but only the following are + known to work with most printers: + + -r360x360 (Default) + -r720x720 (not on STC-IIs ? and st800) + + Valid Option Combinations: (Stylus I & PRO-Series only) + + escp_Band ?Weave escp_Band/#Passes + 180x 90 15 no-Weave + 180x180 1 , 8, 24 no/u-Weave 15/2 sWeave + 180x360 15/4 sWeave + 180x720 15/8 sWeave + 360x 90 15 no-Weave + 360x180 1, 8, 24 no/u-Weave 15/2 sWeave + 360x360 1, 8, 24 no/u-Weave 15/4 sWeave + 360x720 15/8 sWeave + 720x 90 15 no-Weave + 720x180 15/2 sWeave + 720x360 15/4 sWeave + 720x720 1 no/u-Weave 15/8 sWeave + +************************************************************************* +************************************************************************* +** ** +** BEWARE: There are only few validity-checks for parameters. A good ** +** example is "escp_Band": if you set this, the driver tries ** +** to use your value, even if this value is not supported by ** +** the printer: ** +** ** +** YOU ASKED FOR IT, AND YOU GOT IT! ** +** ** +************************************************************************* +************************************************************************* + + +A P P L I C A T I O N - N O T E +================================ + +Quite a bunch of Parameters. Hopefully you never need any of them, besides +feeding "stcolor.ps" to ghostscript in front of your input. + +After answering some questions over 50 Times, I prepared a STC-FAQ-Collection. +I am currently unable offer this FAQ on the net. +But thanks to Bill Davidson it is available as: + + http://www.isisnet.com/bdavidson/gs_stc.FAQ.html + +And here it comes (as plain text): + +VERSION: +This FAQ refers to ghostscript > 3.50 with stcolor > 1.20. The former +release (ghostscript-3.33/stcolor-1.12) used different parameters and +had some severe bugs. This FAQ is itself version 1.3. + +TOPIC: Pro XL? +Yes, this driver supports the A3-Size Printer. Simply set the required +pagesize and margins. A simple way to do this, is to specify the +parameter "-sPAPERSIZE=a3" on the command line or to include the +procedure-call "a3" in the postscript-Prolog section. If you want +to optimize the printable area and/or set the proper Margins, see +topic Margins, PageSize. + +TOPIC: Margins, PageSize +Different than other drivers, i refuse to add code to the stcolor-driver, +that tries to guess the proper margins or pagesize. This is due to the +fact, that i found that such guessing is usually wrong and needs correction +either in the source or the parameters. The following code can be +inserted to "stcolor.ps" after the line: + + mark % prepare stack for "putdeviceprops" + +And this is the new code: + +/.HWMargins [9.0 39.96 12.6 9.0] % Left, Bottom, Right, Top (1/72") +/PageSize [597.6 842.4] % Paper, including Marings (1/72") +/Margins [ % neg. Offset to Left/Top in Pixels + 4 index 0 get STCold /HWResolution get 0 get mul 72 div neg + 5 index 3 get STCold /HWResolution get 1 get mul 72 div neg +] + +Feel free to change the Values for ".HWMargins" and "PageSize" to match +your needs. The given Values are the defaults from the driver, when +compiled with "-DA4" set. + +This Option -or it's omission- may cause trouble: The Stylus Color can +print exactly 8" or 2880Pixel@360DpI. The remaining paper is the +margin, where the left margin varies only slightly with the papersize, +while the right margin ist significantly increased for wider paper, +such as letter. + +-> If you are using stcolor > 1.20, compiled without "-DA4", on european + paper, then the Default-Margin is too large. You need to add the + proper ".HWMargins" to the command line or stolor.ps + + +TOPIC: Stylus Color II / IIs and 1500. +First the good news: The driver can print on the Stylus Color II. +And the bad ones: +- According to Epson-Support the driver "abuses" the color-capabilities. + (See topic "Future Plans" for details.) +- You need some parameters on the command-line (or in stcolor.ps). +- I doubted that it would be usable with the Stylus Color IIs. + *BUT* it is usable and suffers from the mixing-Problems!!. + +To make thinks work, you *MUST* disable the drivers internal +weaving ("Softweave"). This can be done in two ways: + + gs .... -dMicroweave .... + +or + gs ... -dnoWeave -descp_Band=1 .... + +[1.90 fixes this "bug" due to a changed default-behaviour] + +I experienced significantly increased printing speed with the second +variant on the old Stylus Color, when printing mostly monochrome data. + +TOPIC: Future Plans +Actually i thought, that the driver is finished by now, but an answer +from Epson triggered future development. This was the answer from +Epson-Support: + +To: Klaus-Gunther Hess +Subject: Help: Need Programming Info for Stylus-(Color)-Printers + +The differentiation is necessary, as the printers produce the graphics +differently. To wit: + + CMY Class - ( Stylus Color IIs ) The Stylus Color IIs prints color + graphics with the three different color inks (cyan, magenta, and yellow). + Also, black is printed using composit black (mixture of CMY). For high + quality laser like black, a separate black ink cartridge should be used. + + CMY + K Class - ( Stylus Color II ) This printer has both a CMY and a + black ink (K) cartridge installed at the same time. However, due to the + nature of the black ink it can not be mixed or overlaid with the color + inks. Therefore, when black is needed, composite black is used. + If the image calls for pure black (e.g., text), the black cartridge is used. + + CMYK Class - ( Stylus Color, Stylus Pro and Pro XL ) These printers + have a mixable black (K) ink. This ink is compatible with the CMY inks + and will not bleed when combined or printed next to the CMY inks. + +Bruce U. +The Epson Connection + +Thus I am working on a version, that supports CMY and CMY + K dithering. +Actually there are also some new (*undocumented*) instructions used by +the windows-driver in conjunction withe the Stylus Color II/IIs, that +raises the need for some more "escp_*" Parameters. + + +A C K N O W L E D G E M E N T S +=============================== + +This driver was "copied" from gdevcdj.c (ghostscript-3.12), which was +contributed by: + George Cameron - g.cameron@biomed.abdn.ac.uk + Koert Zeilstra - koert@zen.cais.com + Eckhard Rueggeberg - eckhard@ts.go.dlr.de + +Some of the ESC/P2-code was drawn from gdevescp.c, contributed by + Richard Brown - rab@eos.ncsu.edu + +The POSIX-Interrupt-Code is from (Compile-Time-Option -DSTC_SIGNAL) + Frederic Loyer - loyer@ensta.fr + +And several improvements are based on discussions with + Brian Converse - BCONVERSE@ids.net + Bill Davidson - bdavidson@ra.isisnet.com + Gero Guenther - gero@cs.tu-berlin.de + Jason Patterson - jason@reflections.com.au + ? Rueschstroer - rue@ibe.med.uni-muenchen.de + Steven Singer - S.Singer@ph.surrey.ac.uk + +While I wish to thank all this people mentioned above, they are by no means +responsible for bugs in the stcolor-driver - just for the features. + +Duisburg 8-May-1996, Gunther Hess + +up to sometime E-Mail: gunther@elmos.de +After that time, one should use snail-mail or phone: + +Gunther Hess phone: ++49 203 376273 +Richard Wagner Strasse 112 +D-47057 Duisburg +Germany + +R E C O M M E N D A T I O N S +============================= + +The next section is a contribution from Jason Patterson +who evaluated a previous version (1.17). GhostScript was invoked as follows: + + gs -sDEVICE=stcolor [-r720x720] -sDithering=... -sOutputFile=escp.out \ + stcolor.ps whatsoever.ps + +where "..." is the name of the desired algorithm. "stcolor.ps" was omitted +for the gs-algorithms (gsmono, gsrgb and gscmyk), for which it is useless +*and* it would not allow the selection of "gscmyk". + +So here comes a very truncated version of Jasons text: + + COLOR DITHERING EXPERIMENTS with gdevstc-1.21 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Here's a bit of feedback about the EPSON Stylus Color driver's different +dithering methods, based on a little experiment using 4 good quality +scanned images of quite varied nature. + +Here is a summary of the results of the four experiments... + + + gsmono: Pretty much what you'd expect from a mono ordered pattern. Looks + like what a lot of mono laser printers produce. + + fsmono: Excellent for monochrome. + + gscmyk: Not very good, but then you'd expect that from an ordered pattern. + + gsrgb: A little better than gscmyk. More consistent looking. + + fs2: Good, but not quite as good as fsrgb. Gets the brightness wrong, + too light at 720dpi, too dark at 360dpi. + + fsrgb: Very good, but a little too dark and has a slight blue tint. + + hscmyk: Excellent. Slightly better than fsrgb and fs2. Better than fscmyk on + some images, almost the same on most. + + fscmyk: Best. Very, *very* slightly better than hscmyk. On some images, + nearly as good as the EPSON demos (which were done with the + MS-Windows driver). + + Overall Visual Quality (out of ten): + + gsmono |********* + fsmono |***************** + | + gscmyk |******** + gsrgb |********* + fs2 |**************** + fsrgb |***************** + hscmyk |****************** + fscmyk |****************** + +--------------------- + 0 1 2 3 4 5 6 7 8 9 10 + + best-to-worst order: color: fscmyk hscmyk fsrgb fs2 gsrgb gscmyk + mono: fsmono gsmono + + +SANITY NOTE: The above results are only from *four* images, a total of 24 + printouts (8 on 720dpi paper, 16 on plain paper). Your results + will almost certainly vary, and your standards might not be + the same as mine, so use these results as a *guide* only, not + as a formal evaluation. + +C O L O R - T R A N S F O R M A T I O N +======================================= + +*NOTE*: Things are changing with version gdevstc > 2.00! + +In the initial version of the driver, distributed with Ghostscript-3.33, +the parameter "SpotSize" was the only way to manipulate the colors at the +driver-level. According to the parameters enumerated above, this has changed +significantly with version 1.16 and above. This is the result of +an ongoing discussion about dithering-algorithms and "false color" on the +Epson-Stylus-Color. This initiated the transformation of the stcolor-driver +into a framework for different dithering-algorithms, that provides a generalized +interface to the internal Ghostscript-Color-Models and the other data-structures +related to Ghostscript-Drivers. + +The main thing such a framework should be able to do is to deliver the +values the dithering-algorithm needs and since this influences directly +the optical image impression, this transformation should be adjustable without +the need for recompilation and relinking. + +In general the process can be described as follows: + + ColorAdjustMatrix Coding Transfer + +---------------------+ +---------------------+ +------------------+ + | Ghostscript Color | | Ghostscript Raster | | Dithering Data | + | | => | 1/2/4/8/16/24/32Bit | => | 1/3/4x Values | + | 1/3/4x16Bit Values | | for all components | | (arbitrary type) | + +---------------------+ +---------------------+ +------------------+ + +Due to the limitations on raster-storage, information is lost in the first +transformation step, except for the 16Bit Monochrome-Mode. So any color +adjustment should take place before this step and this is where the optional +ColorAdjustMatrix works. + +The first transformation-step is called "coding" and is controlled by the +?coding-Arrays. The Decoding-process expands the range of values +pontentially to a larger range than that provided by the initial ghostscript +color-model. It is therefore a reasonable place to make device- and/or +algorithm-specific adjustments. This is the place where the ?transfer-Arrays +are used. Array-Access might be not the fastest method, but its generality +is superior, so this step is always based upon internally algorithm-specific +array-access. If 8Bits are stored per color-component and if the algorithm +uses bytes too, the second transformation is included within the first, what +saves significant computation-time when printing the data. + + +ColorAdjustMatrix +----------------- + +The driver supports different "ProcessColorModel"-Values, which raises the +need for different color-adjustments. In the following "CAM" stands for +ColorAdjustMatrix: + + DeviceGray: (3 Floats): + if((r == g) && (g == b)) + K' = 1.0 - R; + else + K' = 1.0 - CAM[0] * R + CAM[1] * G + CAM[2] * B; + + According to the documentation in drivers.txt, the latter should + never happen. + + DeviceRGB: (9 Floats) + if((r == g) && (g == b)) + R' = B' = G' = R; + else + R' = CAM[0]*R + CAM[1]*G + CAM[2]*B; + G' = CAM[3]*R + CAM[4]*G + CAM[5]*B; + B' = CAM[6]*R + CAM[7]*G + CAM[8]*B; + + The Printer uses always four inks, thus a special treatment of black + is provided. Algorithms may take special action, if r==g==b. Maybe + that in future versions Kcoding & Ktransfer become active in RGB-Mode. + + DeviceCMYK: (16 Floats) + + if((c == m) && (m == y)) + K' = max(C,K); + C' = M' = Y' = 0; + else + K = min(C,M,Y); + if((K > 0) && ColorAdjustMatrix_present) { => UCR + C -= K; + M -= K; + Y -= K; + } + + C' = CAM[ 0]*C + CAM[ 1]*M + CAM[ 2]*Y + CAM[ 3]*K; + M' = CAM[ 4]*C + CAM[ 5]*M + CAM[ 6]*Y + CAM[ 7]*K; + Y' = CAM[ 8]*C + CAM[ 9]*M + CAM[10]*Y + CAM[11]*K; + K' = CAM[12]*C + CAM[13]*M + CAM[14]*Y + CAM[15]*K; + + Again we have a special black-treatment. "max(C,K)" was introduced + because of a slight misbehaviour of ghostscript, that delivers + black under certain circumstances as (1,1,1,0). Normally, when + no special "Black Separation" and "Undercolor Removal" procedures + are defined at the postscript-level, either (c,m,y,0) or (0,0,0,k) + values are mapped. This would make the extended ColorAdjustMatrix + quite tedious, thus during mapping black-separation is done for + (c,m,y,0)-Requests and if there is a ColorAdjustMatrix, undercolor- + removal is used too. In other words the Default-Matrix is: + + 1 0 0 1 + 0 1 0 1 + 0 0 1 1 + 0 0 0 1 + + and it is applied to CMYK-Values with separated and removed Black. + Raising the CMY-Coefficients while lowering the K-coefficients + reduces black and intensifies color. But be careful, even low + deviations from the default cause drastic changes. + +If no ColorAdjustMatrix is set, the matrix-computations are skipped. Thus +the transformation reduces to: + + - Range-Inversion in Monochrome-Mode + - Black-Separation in CMYK-Mode + + +RGB/CMYK-coding & -transfer and BitsPerPixel +-------------------------------------------- + +This two (groups) of parameters are arrays of floating point numbers in the +range 0.0 to 1.0. They control the truncation to the desired number of +bits stored in the raster-memory (BitsPerPixel) and the ink-density. + +The "truncation" may become a nonlinear-function, if any of the ?coding-arrays +are set. Assume the following Ghostscript invocation: + + gs -sDEVICE=stcolor -sDithering=fscmyk -dBitsPerPixel=16 \ + -dMcoding='{ 0.0 0.09 0.9 1.0 }' \ + -dYtransfer='{ 0.0 0.09 0.9 1.0 }' \ + -dKcoding='{ 0.0 0.09 0.9 1.0 }' -dKtransfer='{ 0.0 0.09 0.9 1.0 }' \ + +We may have ?coding and/or ?transfer, thus four combinations are possible +and this four combinations appear in the given example. The resulting mapping +is given in the following tables, where except for the internal Indices +(4 Components * 4 Bits = 16 BitsPerPixel), all values are normalized to the +Range 0-1. The actual range is 0 to 65535 for the ghostscript-color and +0 to 16777215 (2^24-1) for the ink-values delivered to the fscmyk-algorithm. +Sorry for the bunch of numbers following, but you may try this example in +conjunction with "stcinfo.ps", what should give you a graphical +printout of the following numbers, when you issue a "showpage"-command: + + CYAN MAGENTA + CI/15 gs_color_values CI ink gs_color_values CI ink + 0.000 0.000 - 0.062 0 0.000 -0.123 - 0.123 0 0.000 + 0.067 0.063 - 0.125 1 0.067 0.123 - 0.299 1 0.247 + 0.133 0.125 - 0.187 2 0.133 0.299 - 0.365 2 0.351 + 0.200 0.188 - 0.250 3 0.200 0.365 - 0.392 3 0.379 + 0.267 0.250 - 0.312 4 0.267 0.392 - 0.420 4 0.406 + 0.333 0.313 - 0.375 5 0.333 0.420 - 0.447 5 0.433 + 0.400 0.375 - 0.437 6 0.400 0.447 - 0.475 6 0.461 + 0.467 0.438 - 0.500 7 0.467 0.475 - 0.502 7 0.488 + 0.533 0.500 - 0.562 8 0.533 0.502 - 0.529 8 0.516 + 0.600 0.563 - 0.625 9 0.600 0.529 - 0.557 9 0.543 + 0.667 0.625 - 0.687 10 0.667 0.557 - 0.584 10 0.571 + 0.733 0.688 - 0.750 11 0.733 0.584 - 0.612 11 0.598 + 0.800 0.750 - 0.812 12 0.800 0.612 - 0.639 12 0.626 + 0.867 0.813 - 0.875 13 0.867 0.639 - 0.715 13 0.653 + 0.933 0.875 - 0.937 14 0.933 0.715 - 0.889 14 0.778 + 1.000 0.938 - 1.000 15 1.000 0.889 - 1.111 15 1.000 + +The difference between Cyan and Magenta is the presence of a Coding-Array. +The coding-process must map a range of color-values to each of the 16 +component-indices. If no coding-array is given, this is accomplished +by a division with 4096 -equivalent to a right-shift by 12 Bits-. The +final ink-density resides in the given interval and moves form the left to +the right side from 0 to 15. In the Magenta-case, there is a coding array +and the ink-value matches the center of the intervals. But the distribution +of the mapped intervals follows the given Coding-Array and is nonlinear in +the linear color-space of ghostscript. + +Now let us take a look at the case with Transfer-Arrays: + + YELLOW BLACK + CI/15 gs_color_values CI ink gs_color_values CI ink + 0.000 0.000 - 0.062 0 0.000 -0.123-0.123 0 0.000 + 0.067 0.063 - 0.125 1 0.018 0.123-0.299 1 0.067 + 0.133 0.125 - 0.187 2 0.036 0.299-0.365 2 0.133 + 0.200 0.188 - 0.250 3 0.054 0.365-0.392 3 0.200 + 0.267 0.250 - 0.312 4 0.072 0.392-0.420 4 0.267 + 0.333 0.313 - 0.375 5 0.090 0.420-0.447 5 0.333 + 0.400 0.375 - 0.437 6 0.252 0.447-0.475 6 0.400 + 0.467 0.438 - 0.500 7 0.414 0.475-0.502 7 0.467 + 0.533 0.500 - 0.562 8 0.576 0.502-0.529 8 0.533 + 0.600 0.563 - 0.625 9 0.738 0.529-0.557 9 0.600 + 0.667 0.625 - 0.687 10 0.900 0.557-0.584 10 0.667 + 0.733 0.688 - 0.750 11 0.920 0.584-0.612 11 0.733 + 0.800 0.750 - 0.812 12 0.940 0.612-0.639 12 0.800 + 0.867 0.813 - 0.875 13 0.960 0.639-0.715 13 0.867 + 0.933 0.875 - 0.937 14 0.980 0.715-0.889 14 0.933 + 1.000 0.938 - 1.000 15 1.000 0.889-1.111 15 1.000 + +Yellow uses a transfer-array. There is no linear correspondence between +the color- and the ink-values. This correspondence is defined through the +given array. In other words: the Transfer-arrays define a nonlinear +ink-characteristic, what is exactly the same functionality, that +Postscript's "(color)transfer"-function provides. + +While in the case of Yellow, the intervals match the intervals used with Cyan, +the intervals used for Black match the Magenta-Intervals, but watch +the correspondence between the CI/15-values and the Ink-Density for Black: +This is a linear distribution in the Ink-domain. + +Not a bad idea, I think. Consider the fs2-algorithm: It uses values in +the range 0-255 (Bytes). If any transfer-array would be supplied alone, +some of the 256 possible values would never be used and others will be +used for adjacent intervals several times. Establishing an identical +coding-array solves this problem, so that the full potential of the +algorithm is utilized. + +Another useful feature of the coding-arrays is, that they are internally +normalized to the 0-1 Range. In the 720x720Dpi-Mode the transfer-arrays +in stcolor.ps limit the Dot-Density to about 50%, thus this arrays end +at 0.5 (respectively start at 0.5 in the RGB-case). Due to the automatic +normalization this arrays can be used as coding-arrays too. But of course +in the fs2-case mentioned above, values from 0-127 will never be delivered +to the algorithm, while values 128-255 are delivered for adjacent intervals. + +To clearify the intended use of the three parameters/parameter-groups the +following statements should be kept in mind: + +- ColorAdjustMatrix is never used, when transferring gray-values. This + restricts it to what the name says: Adjustment of Colors e.g. the + correction for miscolored ink. Do not use it for saturation or + brightness-control. + +- ?transfer-arrays control the values delivered to the driver, which in + turn controls the ink-quantity. This arrays should be used for control + of saturation and brightness. Maybe that a Postscript-Header for the + manipulation of brightness and so on will be provided with future + versions. In general this arrays are identical for all inks. + If they differ they provide a simpler scheme for color-correction, + which is not necessarily faster than the ColorAdjustMatrix. + +- ?coding-arrays control the color-value-intervals mapped to + the internal color-indices. + +P R I N T - M O D I +=================== + +The parameters "Unidirectional", "Microweave", "noWeave", +"OutputCode", "Model" and the given resolution provide control over the +data generated for the printer. + +Unidirectional +-------------- +Simply toggles the unidirectional-mode of the printer. Setting "Unidirectional" +definitely decreases printing-speed, but may increase the quality. I use +this for printing tranparencies, where fast head-movement could smear the ink. + +Microweave, noWeave and OutputCode=deltarow +------------------------------------------- +The first are two Booleans, what immediately tells, that 4 combinations are +possible. Actually only three exist (if you don't count for deltarow): + + 1. Softweave + 2. Microweave + 3. noWeave + +First and second are functionally identical, their difference is that either +the driver or the printer does the job. So the question + + What is weaving ? + +arises. The Epson Stylus Color has a Head-Assembly that contains two physically +identifiable Heads. One for Black and one for Cyan/Magenta/Yellow. This +makes 4 logical Heads, one for each color-component. Each of this four heads +has several jets at some Y-distance, so several horizontal lines can be printed +during one pass of the heads. From the experience I think there are 15 Jets +per color spaced at 1/90". + +So the question arises, how to print at a Y-Resolution of 360Dpi with this +90DpI-Jets. Simply by division, one gets 360/90 = 4, what tells us, that +4 Passes of the head-assembly are required to achieve a Y-resolution of +360DpI. Weaving is just the scheme how the 15 jets are utilized to print +adjacent horizontal rows: + + Weaving noWeave + Pass: 1 2 3 4 1 2 3 4 + 0/360" jet0 - - - jet0 - - - + 1/360" - jet1 - - - jet0 - - + 2/360" - - jet2 - - - jet0 - + 3/360" - - - jet3 - - - jet0 + 4/360" jet1 - - - jet1 - - - + 5/360" - jet2 - - - jet1 - - + 6/360" - - jet3 - - - jet1 - + .... + +Now let us assume, that the dot-diameter is different for each individual +jet, but the average among the jets matches the desired resolution. With +weaving adjacent rows are printed by different jets, thus the some averaging +takes place. Without weaving adjacent rows are printed by the same jet and +this makes the dot-diameter-deviations visible as 1/90"-stripes in the printout. + +In Softweave-Mode (the default) the driver sends the data properly arranged to +the printer, while in Microweave-Mode the printer does the same job. But in +general the host-processor is much faster than the printers processor and +thus it is advantageous to let the host do this job. In addition to that, for +720DpI 8 Passes are required and the amount of buffer-space required to buffer +the data for the passes is far beyond the printers memory. Softweave requires +an odd value of "escp_Band", the Stylus Color provides 15 for that. + +"OutputCode" controls the encoding used. In the basic modi, the choice consists +of "plain" and "runlength". The computation of runlength-encoded data does not +take much time, at least less than the data tranfer to the printer, thus this +is the recommended mode and of course the default. With the Stylus Color +Epson introduced some new encoding principles, namely "tiff" and "deltarow". +While the first was omitted from this driver, since there were not potential +advantages found, "deltarow" is available as an option. "Softweave" cannot +be used with this encoding, so if "OutputCode=deltarow" is set, Microweave +becomes the default. Maybe that the size of the ESC/P2-code becomes smaller, +but I have never observed increased printing-speed - things tend to become +slower with deltarow compared to Softweave. + +Model +----- +Some ESC/P2-Printers, such as the Stylus 800, do not offer Microweave or +the commands required to do Softweave. Setting Model just changes the defaults +and omits some parts of the initialization-sequence, which are not compatible +with the given printer model. Currently only "st800" is supported besides the +default (stcolor). + + +BEWARE: BUGS & PITFALLS +======================= + +* The given ?coding and ?transfer arrays should be strictly monotonic. + +* It is impossible to change WHITE: that's your paper. + Thus R/G/B-transfer should end at 1.0 and C/M/Y/K-transfer should + start at 0.0. + +* Usually 8Bits per component yields fastest operation. + +* The ColorAdjustMatrix is not used in the reverse-transformation, which + is used, when Ghostscript does the dithering (gs*-Modi). Expect funny + results. + +* If BitsPerPixel is less than 6, the entire coding/transfer-process + does not work. This is always true for the gs*-modi and becomes true + for the other modi, if BitsPerPixel is forced to low values. + +* 720x720Dpi-Printing should never select the gs-modi and should always + use stcolor.ps. (I prefer 360x720) + +T E S T S (version 1.13 and above) +================================== + +This section should give an overview over the performance in terms of +processing- & printing-time. Printing is done offline (via cp-instruction) +to measure real printing-speed, since at high-resolutions processing-time +is in the same order of magnitude and thus may become the limiting factor. + +The various OutputCodes +----------------------- + +I ran several files though ghostscript and recorded the size of the code, +the processing time and the printing-time, at least for some of the files. +Always the following options were used: + + "-sDEVICE=stcolor -sPAPERSIZE=a4 stcolor.ps - < file.ps" + +(Actually "-sPAPERSIZE=a4" is in my gs_init.ps since I'm a germ.) + +"Softweave" means actually, that nothing else was used, it is the default and +implies that odd v=40/h=10/m=15 mode (ESC . 1 40 10 15). + +"Microweave" is just "-dMicroweave", which is equivalent to "ESC . 1 10 10 1", +with full skip-optimization and microweave-activated. + +"deltarow" is the new encoding principle ("ESC . 3 10 10 1") with Microweave on. +It is activated with "-sOutputCode=deltarow". + +Finally I wanted to see the plain Kathy Ireland and used "-sOutputCode=plain", +which is just replacing RLE by no encoding, thus "ESC . 0 40 10 15" is +used then. +[So sorry ;-) Kathy was still blue dressed in front of the blue sea on a blue +air-cushion - nice to see but hard to dither] + +So here are the results: + + golfer.ps colorcir.ps drawing.ps brief.ps + +deltarow 572751/48.180u 643374/41.690u 90142/46.180u/1:50 178563/49.350u/2:22 +Softweave 559593/46.810u 669966/44.960u 296168/48.160u/1:30 269808/43.320u/1:55 +Microweave 590999/56.060u 754276/42.890u 338885/47.060u/1:50 282314/44.690u/2:22 + + kathy.ps +deltarow 3975334/111.940u/5:35 +Softweave 3897112/101.940u/3:10 +Microweave 4062829/100.990u/3:15 +plain/soft 5072255/104.390u/3:05 + +Evaluation: + +A.) Might be, that I've not chosen the optimal deltarow-code, but even if + it saves at lot of bytes, printing-speed is not increased. + +B.) At least the printer prefers plain-kathy. In other words: Sending a + 1 Megabyte or 20% more data, has no impact on printing speed. + [drawing.ps is an exception to this rule: plain prints slower than rle] + +C.) But "unclever" coding -especially with deltarow- can significantly + slows down printing. But even if very significant advantages in the + size of the code ar achieved, "deltarow" is not competitive. + [colorcir.ps shows savings in deltarow, but printing is a mess.] + + +Printing-Time related to other options +-------------------------------------- + +Full page halftone images printed, unless otherwise noted. + + DpI print-mode Size Time comments +180x180 mono -/uni 358KB 1:15 + -/bi 358KB 0:45 + micro/bi 205KB 0:45 (not weaving) + soft/bi 179KB 1:25 + color -/bi 641KB 2:45 + soft/bi 556KB 1:32 + +360x360 mono -/uni 269KB 0:50 (b/w Text) + -/bi 269KB 0:35 (b/w Text) + micro/bi 269KB 2:25 (b/w Text) + soft/uni 250KB 3:15 (b/w Text) + soft/bi 250KB 1:55 (b/w Text) + color -/bi 346KB 1:00 (sparse color-page, visible displacements) + micro/bi 346KB 1:50 (sparse color-page, looks buggy - printer?) + soft/bi 294KB 1:30 (sparse color-page, O.K.) + -/bi 2218KB 2:45 (visible stripes) + micro/bi 5171KB 3:17 + soft/bi 3675KB 3:05 + +360x720 mono soft/bi 2761KB 5:40 + color soft/bi 7789KB 6:15 (just a small difference!) + +720x360 color soft/bi 7182KB 5:40 + +720x720 color micro/bi 14748KB 30:26 (actually beyond printers capabilities) + soft/bi 14407KB 11:08 +### ------------------------------ End --------------------------------- ### + +### ------------ uniprint - an unified (?) printer driver ------------- ### + +uniprint -- ESC/P, ESC/P2 and PCL/RTL-Driver by Gunther Hess gunther@elmos.de +============================================================================= + +This driver is intended to _become_ a unified printer driver. If you +consider it ugly, please send me your suggestions for improvements. The +driver will be updated with them. Thus the full explanation of the drivers +name is: + + Ugly- -> Updated- -> Unified-Printer-Driver + +But probably you want to know, something about the functionality: +At the time of this writing uniprint drives: + + NEC Pinwriter P2X (24Pin B/W Impact printer, ESC/P-Style) + Several Epson Stylus Color Models (ESC/P2-Style) + HP-Deskjet 550c (Basic HP-RTL) + Canon BJC 610 + +It can be configured for various other printers _without_ recompilation +and offers uncompressed (== ugly) SUN-Rasterfiles as another format, but +this format is intended for testing purposes rather than real use. + +The usage of this driver is quite simple, the typical command line looks +like this: + + gs @MODEL.upp -sOutputFile=PRINT_FILE POSTSCRIPT_FILE -c quit + +with MODEL, PRINT_FILE and POSTSCRIPT_FILE replaced by actual filenames +as in the following example from my Linux-Box: + + gs @stc.upp -sOutputFile=/dev/lp1 tiger.ps -c quit + +There are several Unified-Printer-Parameterfiles (.upp) distributed +with Ghostscript: + + bjc610a0 - Canon BJC 610, 360x360DpI, plain paper high speed, color, rendered + bjc610a1 - Canon BJC 610, 360x360DpI, plain paper, color, rendered + bjc610a2 - Canon BJC 610, 360x360DpI, coated paper, color, rendered + bjc610a3 - Canon BJC 610, 360x360DpI, transparency film, color, rendered + bjc610a4 - Canon BJC 610, 360x360DpI, back print film, color, rendered + bjc610a5 - Canon BJC 610, 360x360DpI, fabric sheet, color, rendered + bjc610a6 - Canon BJC 610, 360x360DpI, glossy paper, color, rendered + bjc610a7 - Canon BJC 610, 360x360DpI, high gloss film, color, rendered + bjc610a8 - Canon BJC 610, 360x360DpI, high resolution paper, color, rendered + + bjc610b1 - Canon BJC 610, 720x720DpI, plain paper, color, rendered + bjc610b2 - Canon BJC 610, 720x720DpI, coated paper, color, rendered + bjc610b3 - Canon BJC 610, 720x720DpI, transparency film, color, rendered + bjc610b4 - Canon BJC 610, 720x720DpI, back print film, color, rendered + bjc610b6 - Canon BJC 610, 720x720DpI, glossy paper, color, rendered + bjc610b8 - Canon BJC 610, 720x720DpI, high resolution paper, color, rendered + + cdj550 - HP Deskjet 550C, 300DpI, 32Bit-CMYK + + necp2x - NEC P2X at 360x360DpI, 8Bit (Floyd-Steinberg) + + stcany - Any Epson Stylus Color, 360x360DpI, 4Bit, POSTSCRIPT-Halftoning + + The next group is suitable for Original Stylus & Stylus Pro. + stc - Epson Stylus Color, 360x360DpI, 32Bit-CMYK, 15 Pin + stc_l - ditto, but 360x360DpI, 4Bit, POSTSCRIPT-Halftoning, Weaved noWeave + stc_h - ditto, but 720x720DpI, 32Bit-CMYK, 15 Pin Weave + + stc2 - Epson Stylus Color II(s), 360x360DpI, 32Bit-CMYK, 20Pin + stc2_h - Epson Stylus Color II, 720x720DpI, 32Bit-CMYK, 20Pin + stc2s_h - Epson Stylus Color IIs, 720x720DpI, 32Bit-CMYK, 20Pin + + Thanks to Mark Goldberg, the following two are known to have + good transfer-curves for plain-paper. + stc500p - Espon Stylus Color 500, 360DpI, 32Bit-CMYK, noWeave, plain paper + stc500ph - ditto, 720x720DpI, 32Bit-CMYK, noWeave, plain paper + + The Stylus Color 600 does 32/90"-Weaving + stc600pl - Epson Stylus Color 800, 360DpI, 32Bit-CMYK, 32 Pin, plain paper + stc600p - Epson Stylus Color 800, 720DpI, 32Bit-CMYK, 32 Pin, plain paper + stc600ih - Epson Stylus Color 800, 1440DpI 32Bit-CMYK, 30 Pin, inkjet paper + + The Stylus Color 800 does 64/180"-Weaving + stc800pl - Epson Stylus Color 800, 360DpI, 32Bit-CMYK, 64 Pin, plain paper + stc800p - Epson Stylus Color 800, 720DpI, 32Bit-CMYK, 64 Pin, plain paper + stc800ih - Epson Stylus Color 800, 1440DpI 32Bit-CMYK, 62 Pin, inkjet paper + + ras1 - SUN rasterfile, 1Bit, monochrome (Ghostscript) + ras8m - SUN rasterfile, 8Bit, grayscale (Floyd-Steinberg) + + ras3 - SUN rasterfile, 3Bit, RGB (Ghostscript) + ras24 - SUN rasterfile, 24Bit, RGB (Floyd-Steinberg) + + ras4 - SUN rasterfile, 4Bit, CMYK (Ghostscript) + ras32 - SUN rasterfile, 32Bit, CMYK (CMYK-Floyd-Steinberg) + +There may be more parameter files available. I am trying to keep them together +with the latest version of the driver-sources and some additional stuff at: + + http://www-md.e-technik.uni-rostock.de/ma/gunther/gs/index.html + +At the time of this writing (21-Sep-1997) the contents of the website is +outdated, but i still live in the hope to update it. I am becoming 42 in +November, Thus all answers might be available on the web then. + +Please note the following: + + - Changing the resolution via the -r-Parameter of Ghostscript is + usually _not_ possible. + + - For Epson Stylus Color Models not listed above, the two stc500-Variants + are likely to work besides stcany, but the Gamma-Correction might be wrong. + +A few notes on the state of this driver +======================================= + +The coding of uniprint was triggered by the requirements of the various +Stylus Color models and some personal needs for HP- and NEC-Drivers. Thus +the Epson-Models are well represented among the distributed Parameter-Files. +When this driver entered the beta testphase, three other drivers appreared on +the scene, that could/should at least partially integrated into uniprint: + + cdj850 by Uli Wortmann (available via ftp://bonk.ethz.ch) + hpdj by Martin Lottermoser + bjc610 by Helmut Riegler + +Uli addresses features of the more recent Deskjet-Models, that will not be +available in uniprint soon. Martin taught me a lesson on HP-PCL3-Headers, +that will be available in uniprint soon. Helmut in turn followed an almost +similar idea, but targetted primarily for printing on Canon-Printers from +the pbmplus-Library. Starting with Version 1.68 of uniprint, the bjc-support +is available. The work on the hpdj-Integration will start after the update of +my website. + +A few notes on the uniprint-background +====================================== + +Uniprint is actually an update of stcolor, but much more versatile than +its predecessor. Stcolor in turn started as a clone of the Color-Deskjet +family of drivers (cdj*). Finally cdj* can be considered as an addition +of features to the simpler Monochrome-Drivers of Ghostscript. This +addition of features is useful to get an idea of the functionality of +uniprint: + +1. Monochrome -> advanced Color (cdj*): + This adds color-mapping and rendering-functions to the driver. + Especially the Error-Diffusion is important for the printout quality. + +2.1. HP-Color -> Epson-Color (stcolor) + The Epson Stylus Color offered two features simultaneously: It could + produce 720x720Dpi-Output and it could soak the paper. In other words + it required more color-management-features inside the driver. This is + still the major conceptual difference in the data-generation + for HP- and Epson-Printers. + +2.2. Weaving-Techniques (stcolor) + Besides the internal color-management the Stylus Color did not provide + enough buffer-space to operate the printer fast at the 720x720DpI. + The use of Weaving could yield the triple print-speed. Weaving, also + called interleaving, is present in some monochrome-drivers too. The new + thing in stcolor was the combination with Error-Diffusion. Unfortunately + the weaving was somehow hardcoded, as the problems with the newer + members of the Stylus Color family of printers demonstrated. + +3. Generalized Output-Format and Weaving (uniprint) + The features mentioned above yielded about 90% of stolors source-code, + only 10% were related to the formatting of the output. The idea to + make the Output-Format switchable came up soon after completing + stcolor. But the final design of uniprint became triggered by the + (personal) necessity to drive a NEC-P2X and a Designjet 750c. (If + you are missing the dnj750-parameter-file: a temporary version will + be available soon, but a reasonable one requires some additions to + uniprint, which will take some time.) + +Thus uniprint accumulates almost any features, that can be found among +the printer drivers. Clearly this has some disadvantages in terms of +processing speed. This is still true for the current version (1.75), +since it is targetted for the functionality and several speed-gaining +features were (willingly) omitted. + +To summarize and to introduce the terms used in the description of the +Parameters, the features of uniprint, that can be parameterized are: + + 1. The Color-Mapping + 2. The Color-Renderining (alias Error-Diffusion or Floyd-Steinberg) + 3. The Output-Format, including + 4. The Weaving + +And the Parameters used for that are: + +upAbortCommand upAdjustBottomMarginCommand +upAdjustMediaSizeCommand upAdjustPageLengthCommand +upAdjustPageWidthCommand upAdjustTopMarginCommand +upAdjustResolutionCommand upBeginJobCommand +upBeginPageCommand upBlackTransfer +upBlueTransfer upColorInfo +upColorModel upColorModelInitialized +upComponentBits upComponentShift +upCyanTransfer upEndJobCommand +upEndPageCommand upErrorDetected +upFSFixedDirection upFSProcessWhiteSpace +upFSReverseDirection upFSZeroInit +upFormatXabsolute upFormatYabsolute +upGreenTransfer upMagentaTransfer +upMargins upModel +upOutputAborted upOutputBuffers +upOutputComponentOrder upOutputComponents +upOutputFormat upOutputFormatInitialized +upOutputHeight upOutputPins +upOutputWidth upOutputXOffset +upOutputXStep upOutputYOffset +upOutputYStep upRasterBufferInitialized +upRedTransfer upRendering +upRenderingInitialized upSelectComponentCommands +upSetLineFeedCommand upVersion +upWeaveFinalPins upWeaveFinalScan +upWeaveFinalXStarts upWeaveFinalYFeeds +upWeaveInitialPins upWeaveInitialScan +upWeaveInitialXStarts upWeaveInitialYFeeds +upWeavePasses upWeaveXPasses +upWeaveXStarts upWeaveYFeeds +upWeaveYOffset upWeaveYPasses +upWhiteTransfer upWriteComponentCommands +upWroteData upXMoveCommand +upXStepCommand upYFlip +upYMoveCommand upYStepCommand +upYellowTransfer + +All this Parameters are specific to uniprint. But since the names are +choosen to be self-explanatory, you can now go ahead and write your +own parameterfile ;-). + +Godzillas Guide to the Creation of Unified-Printer-Parameterfiles +================================================================= + +Learning by example might be a good idea, thus here is one of the +distributed parameter files (stc_l.upp) with some added "--"-Comments: + + -supModel="Epson Stylus Color I (and PRO Series), 360x360DpI, noWeave" + -sDEVICE=uniprint -- Select the Driver + -dNOPAUSE -- Useful with Printers + -dSAFER -- Provides some Security + -dupColorModel=/DeviceCMYK -- Selects the Color-Mapping + -dupRendering=/ErrorDiffusion -- Selects the Color-Rendering + -dupOutputFormat=/EscP2 -- Selects the Output-Format + -r360x360 -- Adjusts the Resolution + -dupMargins="{ 9.0 39.96 9.0 9.0}" -- Establishes (L/B/R/T-Margins 1/72") + -dupComponentBits="{1 1 1 1}" -- Map: Bit's Per Component (Default: 8) + -dupWeaveYPasses=4 -- Weave: Y-Passes (Default: 1) + -dupOutputPins=15 -- Format/Weave: Scans per Command + -dupBeginPageCommand="< -- Goes to the Printer (second-data) + 1b40 1b40 -- ESC '@' ESC '@' -> dual reset + 1b2847 0100 01 -- ESC '(' 'G' 1 0 1 -> Graphics + 1b2869 0100 00 -- ESC '(' 'i' 1 0 1 -> no HW-Weave + 1b2855 0100 0A -- ESC '(' 'U' 1 0 10 -> 360DpI + 1b5500 -- ESC 'U' 0 -> Bidir-Print + 1b2843 0200 0000 -- ESC '(' 'C' 2 0 xx -> Page-Length + 1b2863 0400 0000 0000 -- ESC '(' 'c' 4 0 xxxx -> Margins + >" -- as it is, unless: + -dupAdjustPageLengthCommand -- Adjust Pagelength in BOP requested + -dupAdjustTopMarginCommand -- Adjust Top-Margin in BOP + -dupAdjustBottomMarginCommand -- Adjust Bottom-Margin in BOP + -dupEndPageCommand="(\033@\014)" -- Last (but one) data to the Printer + -dupAbortCommand="(\033@\15\12\12\12\12 Printout-Aborted\15\014)" + +That's short, and if one removes the "upWeaveYPasses" and "upOutputPins" +this becomes shorter and almost "stcany.upp". This miniature-size +is the result of the fact, that I am most familiar with ESC/P2 and was able +to add defaults for the omitted parameters. + +Just a few notes about the parameters used in this example: + +- upModel, is a string serving as a comment (and nothing else) + +- DEVICE, NOPAUSE, SAFER are well known Ghostscript-Parameters + +- upColorModel, is one of major uniprint-Parameters and selects the + color-mapping and in turn the Postscript-ColorModel. The following + values are currently supported: + + /DeviceGray, /DeviceRGBW, /DeviceRGB, /DeviceCMYK, /DeviceCMYKgenerate + +- upRendering, is the next major uniprint-Parameter and selects the + (Color-) Rendering. The following values are currently supported: + + /ErrorDiffusion, /FSCMYK32 + + The first is similar to fsmono, fsrgb and fsx4 of stcolor, while the + second is (almost) identical to fscmyk/hscmyk, but is restricted to + 32Bit-Data and should be used in conjunction with /DeviceCMYKgenerate. + +- upOutputFormat, is the final major uniprint-Parameter and selects the + Output-Method. The following values are currently supported: + + /SunRaster, /Epson, /EscP2, /EscP2XY, /Pcl + + /SunRaster creates the Raster-Files and requires no other Parameters. + /Epson is used for the elderly ESC/P-Format (used by many printers) + /EscP2 is used by more recent Epson-printers (no X-Weaving supported) + /EscP2XY supports X-Weaving, used with 1440DpI-Printers and in stc2s_h + /Pcl is the HP-PCL/RTL-Style output-formatter without weaving. + +- -r360x360 is the Standard Resolution-Parameter of Ghostscript + +- upMargins="{ 9.0 39.96 9.0 9.0} + Has a similar function as the normal Ghostscript-Parameter ".HWMargins", + it sets the Left/Bottom/Right/Top-Margins in 1/72" units. Uniprint + provides this parameter to enable automatic L<>R exchange, if upYFlip + is active. + +- upComponentBits, is an array of integers, that selects the Bits stored + in Raster-Memory. The Default is to store 8 Bits per component. In this + example 1 Bit is selected for each component, thus turning down the + Floyd-Steinberg-Algorithm (But the time consuming computation is + still carried out, but this will change in future Versions). There is + a related Parameter "upComponentShift", which offers control over the + positioning of the components within the raster-memory. Each of the + given numbers corresponds to a component, and which depends on the + selected "upColorModel": + + /DeviceGray /DeviceRGBW /DeviceRGB /DeviceCMYK, /DeviceCMYKgenerate + 0 White White Red Black Black + 1 - Red Green Cyan Cyan + 2 - Green Blue Magenta Magenta + 3 - Blue - Yellow Yellow + + This order may not be suitable for some printers, thus there is + another Parameter to select the Output-Order. This is an array + of integers too, is named "upOutputComponentOrder" and uses the + numbers on the left. + +One group of very important Parameters, not used in the example above +deserves to be mentioned here: The Transfer-Arrays, named + + "upTransfer" + +where is one of the names in the table above. These are arrays +of floats in the range from 0.0 to 1.0 and represent the colortransfer +functions. They are used during mapping _and_ rendering. In the simplest +case, this arrays ensure an equidistant distribution of the stored +values within the device-space (Which means a non-linear mapping +from Ghostscript's point of view). If the given array does not cover +the entire range from 0 to 1, which applies for the Stylus Color Family +at high resolution for some media, only the relevant part gets mapped to +the raster-memory (thus it is fully utilized) and the rendering takes +care of the "overhang" (In this case the Post-Diffusion of 1 Bit components +makes sense). + +Finally an important note on the Transfer-Arrays: In the case of monochrome +devices, the stored Component is White, which is the way Postscript defines +this devices, but most printers require "Black", thus one has to provide +a falling "upWhiteTransfer" for such printers. + +- upWeaveYPasses, is an integer, that gives the number of printhead passes + required to achieve the requested Y-DpI. This makes sense only if + +- upOutputPins ist set to something greater than 1, thus multiple Pins/Nozzles + are transferred with a single command and of course such a command must + be supported by the device. + +If no other Weave-Parameters are given, uniprint computes several defaults, +which altogether do no weaving. The /Epson and /EscP2XY-Formats take care +of "upWeaveXPasses" too. + +- upBeginPageCommand, represents the data transferred to the printer, + whenever a new Page begins. Prior to that, the "upBeginJobCommand" + is written to the device only once per OutputFile. (Intended for the + HP-PJL-Sequences). + +- upAdjustBottomMarginCommand, upAdjustMediaSize, upAdjustPageLengthCommand, + upAdjustPageWidthCommand, upAdjustResolutionCommand, + upAdjustTopMarginCommand + Normally uniprint does not change the "upBeginPageCommand" nor does it + provide a default. But if the above boolean values are set, the corresponding + values are changed. (Provided that the code of the formatters supports + this change and the commands to be adjusted are included in the + BOP-String) + +- upEndPageCommand is the fixed termination sequence for each page and + of course there is a "upEndJobCommand" too. + +- "upAbortCommand" is written, if the interrupt-detection in uniprint + is enabled and a signal is caught. It _replaces_ the "upEndPageCommand" + _and_ the "upEndJobCommand", thus allowing the indication of an + aborted job. (Ghostscript gets an error-return from uniprint in this + case and abandons further processing.) + +For the ESC/P(2) formats all commands represent binary data, while for +the PCL/RTL-Formatter some of them are formats for fprintf. This strings +_must_ have explicitly a trailing '\0'. + +I should write more, but time is short and the only recommendation is to +take a look at the various parameter-files. But at least three more hints +should be given: + + 1. If the Driver rejects a Configuration, nothing happens until a + showpage occurs. Then an error is raised and a message with + "CALL-REJECTED upd_print_page..." is printed on stderr. + + 2. uniprint has lots of messages that can be activated by setting bits + in the preprocessor macro UPD_MESSAGES. I usually use the compile- + time option -DUPD_MESSAGES=0x17 for Configuration-Development. + (For the semantics, check the UPD_M_... macros in the source.) + + 3. There is a file "uninfo.ps" distributed. This file prints (on + the terminal, not on the printer) the contents of the + current-pagedevice-dictionary in alphabetical order. This includes + the parameters generated/changed by uniprint. + +Quick comments on all Parameters in alphabetical order +====================================================== +String upAbortCommand - End of Page & File upon Interrupt +Bool upAdjustBottomMarginCommand - Manipulate B-Marg in upBeginPageCommand +Bool upAdjustMediaSize - Manipulate Mediasize [intended] +Bool upAdjustPageLengthCommand - Manipulate P-Lngth in upBeginPageCommand +Bool upAdjustPageWidthCommand - Manipulate P-Wdth in upBeginPageCommand +Bool upAdjustResolutionCommand - Manipulate Resolution +Bool upAdjustTopMarginCommand - Manipulate T-Marg in upBeginPageCommand +String upBeginJobCommand - Begin of each OutputFile +String upBeginPageCommand - Begin of each Page +Float[] upBlackTransfer - Black-Transfer (CMKY* only!) +Float[] upBlueTransfer - Blue-Transfer +Int[] upColorInfo - struct gx_device_color_info +Name upColorModel - Selects Color-Mapping +Bool/RO upColorModelInitialized - Color-Mapping O.K. (readonly) +Int[] upComponentBits - Bits stored per Component +Int[] upComponentShift - Positioning within gx_color_index +Float[] upCyanTransfer - Cyan-Transfer +String upEndJobCommand - End of each File unless upAbortCommand +String upEndPageCommand - End of each Page unless upAbortCommand +Bool/RO upErrorDetected - Severe (VM) Error, not fully operational +Bool upFSFixedDirection - Inhbits Direction-Toggling in Rendering +Bool upFSProcessWhiteSpace - Causes White-Space Rendering +Bool upFSReverseDirection - Run Rendering in Reverse (if fixed) +Bool upFSZeroInit - Non-Random Rendering-Initialization +Bool upFormatXabsolute - Write absolute X-Coordinates +Bool upFormatYabsolute - Write absolute Y-Coordinates +Float[] upGreenTransfer - Green-Transfer +Float[] upMagentaTransfer - Magenta-Transfer +Float[] upMargins - L/B/R/T-Margins in 1/72" +String upModel - Comment-String, holds some info +Bool/RO upOutputAborted - Caught an Interrupt +Int upOutputBuffers - # of Rendering buffers (2^n) +Int[] upOutputComponentOrder - Order of Comps when Printing +Int upOutputComponents - # written Comps, not fully operational +Name upOutputFormat - Selects Output-Format +Bool/RO upOutputFormatInitialized - Format-Data o.k. (readonly) +Int upOutputHeight - Output-Height in Pixels +Int upOutputPins - # Pins/Nozzles per command +Int upOutputWidth - Output Width in Pixels +Int upOutputXOffset - Offset in Pixels, if upFormatXabsolute +Int upOutputXStep - Divisor / Multiplier for X-Coords +Int upOutputYOffset - Offset in Pixels, if upFormatYabsolute +Int upOutputYStep - Divisor / Multiplier for Y-Coords +Bool/RO upRasterBufferInitialized - GS-Buffer o.k. (readonly) +Float[] upRedTransfer - Red-Transfer +Name upRendering - Selects Rendering Algorithm +Bool/RO upRenderingInitialized - Rendering-Parameters o.k. (readonly) +String[] upSelectComponentCommands - Establishes Color (Output-Order!) +String upSetLineFeedCommand - Adjust Linefeed (/Epson only) +String/RO upVersion - Source code Version (readonly) +Int[] upWeaveFinalPins - # of Bottom pins on EOP-Passes +Int upWeaveFinalScan - Begin of EOP-Passes (Y-coord) +Int[] upWeaveFinalXStarts - X-Pass indices for EOP-Passes +Int[] upWeaveFinalYFeeds - Y-Increments for EOP-Passes +Int[] upWeaveInitialPins - # of Top pins on BOP-Passes +Int upWeaveInitialScan - End of BOP-Passes (Y-Coord) +Int[] upWeaveInitialXStarts - X-Pass indices for BOP-Passes +int[] upWeaveInitialYFeeds - Y-Increments for BOP-Passes +Int upWeavePasses - XPasses * YPasses +Int upWeaveXPasses - Number of X-Passes +Int[] upWeaveXStarts - X-Pass indices for normal Passes +Int[] upWeaveYFeeds - Y-Increments for normal Passes +Int upWeaveYOffset - # of blank/incomplete scans at BOP +Int upWeaveYPasses - Number of X-Passes +Float[] upWhiteTransfer - White Transfer (Monochrome Devices!) +String[] upWriteComponentCommands - Commands to write each component +Bool/RO upWroteData - Something (BeginJob) written to Output +String upXMoveCommand - X-Positioning-command +String upXStepCommand - Single Step to the right +Bool upYFlip - Flips Output along the Y-Axis +String upYMoveCommand - Y-Positioning-Command +String upYStepCommand - Single Step down +Float[] upYellowTransfer - Yellow Transfer + +Uniprint's Roll of Honor +======================== + +I should mention all of the people, who were involved in stcolors +evolution, but I've decided to start from scratch here: + +John P. Beale - for testing the stc600-modi +Bill Davidson - who triggered some weaving-research (and tested stc2s_h) +L. Peter Deutsch - who triggered an ease of configuration +Mark Goldberg - who prepared the stc500-Transfers +Scott F. Johnston and +Scott J. Kramer - for testing the stc800-modi +Martin Lottermoser - for his great commented hpdj-driver +Helmut Riegler - for the BJC-Extension +Hans-Gerd Straeter - for some measured transfer-curves and more +Uli Wortmann - for discussions and his cdj850-driver + +my family - for tolerating my printer-driver-hacking, + +Duisburg 21-Sep-1997, Gunther Hess + +Gunther Hess phone: ++49 203 376273 (MET-evening hours) +Richard Wagner Strasse 112 E-Mail: gunther@elmos.de +D-47057 Duisburg +Germany + +### ------------------------------ End --------------------------------- ### + +### -- The BJC-600/BJC-4000/BJC-70/Stylewriter 2x00, BJC-800 printers -- ### + +This section was written by Yves Arrouye . + + +HISTORY +------- + +The BJC-600 driver was written in the first place by Yoshio Kuniyoshi + and later modified by me, Yves Arrouye +. We both tried to make it evolve synchronously, +though Yoshio cannot be reached since a long time. + +The drivers are based on code for the HP printers by George Cameron + (in fact, they are in the same file!), +so he's the first person to thank! + +The 2.00 version of the drivers was a complete rewrite of the driver +(arguments, optimization, colour handling, in short: everything!) by +Yves Arrouye. The 2.x release is also the first one to be able to +use the full width of an A3 paper size... + +With the 2.15 release, PostScript Printer Description (PPD) files for +the drivers are released. They are not complete at the moment but they +can be used to drive the printers' main features. + +VERSION INFORMATION +------------------- + +The BJC-600 driver is version 2.17.00 dated 5/23/96. +The BJC-800 driver is version 2.17.00 dated 5/23/96. + + +COMPILATION NOTES +----------------- + +Configuration +------------- + +* Default values for options and other stuff + +Configuration for the drivers can be made by modifying default values +in the file gdevbjc.h or on the compilation line. If you don't do +that, the drivers use reasonable defaults that make them work "as +expected". + All default values given below are defined in this file if you need +to change them to customize your installation (a bad idea, better use +options...). + +* CMYK to RGB color conversion + +By default, the drivers use the same algorithm as Ghostscript to +convert CMYK colors to RGB. If you prefer to use Adobe formulaes, +define USE_ADOBE_CMYK_RGB when compiling. (See the top of the +gdevcdj.c file to see the difference between the two.) + +* Vertical centering of the printable area + +The drivers center the imageable area horizontally, but not vertically +so that what can be printed does use the most of the output media. If +you define BJC_DEFAULT_CENTEREDAREA when compiling, then the top and +bottom margins will be the same, resulting in a (smaller) vertically +centered imageable area too. + +* Margins + +If you define USE_RECOMMENDED_MARGINS then the top and bottom margins +will be the same (i.e. BJC_DEFAULT_CENTEREDAREA will be defined for +you) and these margins will be those recommended by Canon, 12.4 mm. + Because margins are a complicated thing (due to the fact that one +does rely on the mechanical precision of the printer), the drivers do +something about the bottom margin: by default the bottom margin is +9.54 mm for the bjc600 driver and 7 mm for the bjc800 one. If you +define USE_TIGHT_MARGINS then the bottom margin is 7 mm for both +drivers (but I never managed to get my own bjc600 print a line on this +low bound, hence the greater default). Regardless of the presence of +this define, USE_FIXED_MARGINS will not allow the bjc800 to use the +lower 7 mm bottom margin, so if you have a problem with the bottom +margin on a bjc800, just define that (without defining USE_TIGHT_MARGINS, +of course). + +Compilation +----------- + +Make sure the bjc600 and/or bjc800 devices are in your DEVICE_DEVS +variable. That is look in the makefile for your platform and add them +if necessary. This means for example adding them to the DEVICE_DEVS6 +variable. The line should read something like that: + + DEVICE_DEVS6=bj10e.dev bj200.dev bjc600.dev bjc800.dev + +Now if you get an error from make saying that it does not know how to +make bjc800.dev it's because you have an old makefile with only the +bjc600 device in it. You then have to copy the lines explaining how to +make bjc800.dev in your makefile. These lines are in devs.mak (under +the lines for making bjc600.dev) and should go just after the lines +for making bjc600.dev. + +Testing the margins +------------------- + +A quick way to be sure that the margins you selected (see above) are +okay is to print a file whose contents are: + + %! + clippath stroke showpage + +If the margins are okay, you will obtain a rectangle surrounding the +printable area. + +USE OF THE DRIVERS +------------------ + +There are two drivers here: the "bjc600" one supports the BJC-600 and +BJC-4000 (maybe the BJC-70 as well) and the "bjc800" one supports the +BJC-800 series. When remarks here apply to both drivers, the name +"bjc" will be used. + +Supported Options and Defaults +------------------------------ + +(Note: the names "options", "properties" and "parameters" will be used +to designate the same thing: device parameters that you can change.) + +Preamble: if an option is given an incorrect value, an error will +occur. Unless stated otherwise, this error will be a rangecheckerror. + Options may be set from the gs command-line (using the -d and -s +switches or other predetermined switches if they have an effect on the +driver) or using the setpagedevice Level 2 operator if Ghostscript has +been compiled with the level2 device (it should ;-)). There are *no* +special-purpose operators as one was able to find in Level 1 printers. + +The default number of bits per pixel for the bjc is 24 (unless you +change the value of BJC_BITSPERPIXEL) and corresponds to a CMYK +printing. Supported modes are 1 bpp and 4 bpp (gray levels), 8 bpp, 16 +bpp, 24 bpp and 32 bpp (colours). Colours are preferrably stored in +the CMYK model (which means that with 16 bpp there are only 16 +different shades of each color, for example) but it is possible to +store them as RGB color for some depths. + Some modes do Floyd-Steinberg dithering while some others don't and +use the default Ghostscript halftoning (in fact, when halftoning is used +dithering takes also place but due to the low point density it is +usually not efficient and thus invisible). + +Here is a short description of each printing mode (expressed in +bpp/colors): + + 32/4 CMYK Colour printing, Floyd-Steinberg dithering. + 24/4 Id. (But each primary colour is stored on 6 bits instead of 8.) + + 24/3 RGB colour printing, Floyd-Steinberg dithering. This mode will + *not* use the black cartridge (that's why it exists, for when you + don't want to use it ;-)). Each primary colour is stored on 8 + bits as in the 32/4 mode, but black generation and under-color + removal are done on the driver side and not by Ghostscript so you + do not have any control on it. (This mode is not supported anymore + on this driver.) + + 16/4 CMYK colour printing, halftoned by Ghostscript. FS dithering + is still visible here (but the halftone patterns are visible + too!). + + 8/4 Id. (But each primary colour is stored on 2 bits instead of 4.) + + 8/3 RGB colour printing. This mode is not intended to be + used. What I mean is that it should be used only if you + want to use custom halftone screens *and* the halftoning is + broken using the 8/4 mode (some versions of gs have this + problem). + + 8/1 Gray-levels printing, Floyd-Steinberg dithering. + + 1/1 Gray-levels printing, halftoned by GhostScript. + +These modes are selected using the BitsPerPixel *and* Colors integers +options (either from the command line or in a PostScript program using +setpagedevice). See below. + +A note about darkness of what is printed: Canon printers do print dark, +really. And the Floyd-Steinberg dithering may eventually darken your image +too. So you may need to apply gamma correction by calling gs as in + + % gs -sDEVICE=bjc600 gamma.ps myfile.ps + +where gamma.ps changes the gamma correction (here to 3 for all colors): + + { 0.45 exp } dup dup currenttransfer setcolortransfer + +(0.45 being value giving good results for me, your mileage may vary; +the bigger the value the lighter the output). + +The drivers support printing at 90 dpi, 180 dpi and 360 dpi. Horizontal and +vertical resolutions must be the same or a limitcheck error will happen. A +rangecheck will happen too if the resolution is not 90 * 2**n. (If the +driver is compiled with -DBJC_STRICT a rangecheck will also happen if +the resolution is not one of those supported. This is not the case as we +expect that there may be a 720 dpi bjc someday). + +Here are the various options supported by the bjc drivers, along with +their type, supported values, effect(s) and usage: + + BitsPerPixel (int) Choose the depth of the page. Valid values are + 1, 8, 16, 24 and 32. Default is 24. + Note that when this is set for the first + time, the Colors property is automatically + adjusted unless it is also specified. Defaults + adjustments are show in the table below, + default choices are indicated by a star (*). + This table gives also the corresponding + color models and the rendering method that is + visible (GS means Ghostscript halftoning, FS + Floyd-Steinberg dithering, and if both are + present it means that the dithering of + halftones is visible). + + +-----+--------+---+----------+-------+ + | Bpp | Colors | * | C. Model | Dith. | + +-----+--------+---+----------+-------+ + | 32 | 4 | | CMYK | FS | + +-----+--------+---+----------+-------+ + | 24 | 4 | * | CMYK | FS | + | | 3 | | RGB | FS | + +-----+--------+---+----------+-------+ + | 16 | 4 | | CMYK | GS FS | + +-----+--------+---+----------+-------+ + | 8 | 4 | * | CMYK | GS | + | | 3 | | RGB | GS | + | | 1 | | K (CMYK) | FS | + +-----+--------+---+----------+-------+ + | 1 | 1 | * | K (CMYK) | GS | + +-----+--------+---+----------+-------+ + + Valid Colors values for allowed + BitsPerPixel values. + + Also note that automagical change of one + parameter depending on the other one does not + work in a setpagedevice call. This means that + if you want to change BitsPerPixel to a value + whose valid Colors values do not include the + actual Colors value, you must change Colors + too. + + Colors (int) Choose the number of color components. Valid + values are 1, 3 and 4. Default is 4. + This setting cannot be used in a PostScript + program, only on Ghostscript's command-line. + See ProcessColorModel below for what to use to + change the number of colors with PostScript + code. + Note that setting this property does limit + the choices of BitsPerPixel. As for the + previous property, its first setting may + induce a setting of the "other value" (namely + BitsPerPixel, here). Valid combinations are + shown in the table below (XX indicates that + the combination is valid, ** that this is the + default). + + +--------+------+------------------------+ + | | | BitsPerPixel ok values | + | Colors | Type +----+----+----+----+----+ + | | | 32 | 24 | 16 | 8 | 1 | + +--------+------+----+----+----+----+----+ + | 4 | CMYK | XX | ** | XX | XX | | + | 3 | RGB | | ** | | XX | | + | 1 | K | | | | XX | ** | + +--------+------+----+----+----+----+----+ + + Valid BitsPerPixel values + for allowed Colors values. + + Also note that automagical change of one + parameter depending on the other one does not + work in a setpagedevice call. This means that + if you want to change Colors to a value whose + valid BitsPerPixel values do not include the + actual BitsPerPixel value, you must change + BitsPerPixel too. + + ProcessColorModel (symbol) + A symbol taken from /DeviceGray, /DeviceRGB + or /DeviceCMYK which can be used to select 1, + 3 or 4 colors respectively. + Note that this parameter takes precedence + over the Colors one, and that both affect the + same variable of the driver. (See Colors above + for values combined with BitsPerPixel.) + + HWResolution (floats array) + An array of 2 floats giving the horizontal and + vertical resolution in dots per inch. Supported + values are 90, 180 and 360 and both values + must be the same. Default is 360. + (On the gs command line, the resolution is + changed by saying "-rXDPIxYDPI".) + + ManualFeed (bool) Indicate that the sheets won't be fed automatically + by the printer. Default is false. + (Not meaningful on the BJC-600, I fear.) + + MediaType (string) Choose the media to print on. Values are chosen + amongst "PlainPaper", "CoatedPaper", + "TransparencyFilm", "Envelope", "Card" and "Other". + Default is "PlainPaper". + If the chosen media is "Envelope", "Card" or + "Other", the driver will make the printer go + in thick mode automatically regardless of the + media weight. + + MediaWeight (int or null) + Choose the weight of the media (in g/m2). Using + null indicates that the weight is of no + importance. Default is null. + If the specified media weight is greater + than 105 (i.e. the value of the compilation + default BJC???_MEDIAWEIGHT_THICKLIMIT) then + the printer will be setup to use thick paper. + + PrintQuality (string) Choose the quality of printing. For the bjc600 + driver it can be one of "Normal", "High" and + "Draft". For the bjc800 driver it can be one + of "Low", "Normal", "High" and "Draft". + Default is "Normal" for both drivers. + For both drivers, "High" means 200% black and + 100% cyan, magenta and yellow (on a bjc600 you + will get the "Bk+" light). + For the bjc600 driver, "Normal" lits the + "HQ" light while "Draft" unlits it. + For the bjc800 driver, "Low" has the effect + of making only two printing passes instead of + four (should be twice as fast ;-)). This is + what is known as "CN" (Color Normal) mode. + + DitheringType (string) + Choose a dithering algorithm. Actually the + only valid values are "Floyd-Steinberg" and + "None". "None" is the default for 1/1 print + mode, "Floyd-Steinberg" for other modes. + At the moment this parameter is read-only, + though no error will be generated if one tries + to change it. + This parameter is not of much value at the + moment and is mainly here to reserve the name + for future addition of dithering algorithms. + + PrintColors (int) Mask for printing color. If 0, use black for + any color. + Otherwise, the value must be the sum of any + of 1 (cyan), 2 (magenta), 4 (yellow) and 8 + (black), indicating which colors will be used + for printing. + When printing colour, only those colour + specified will be printed (this means that + some planes will be missing). + When printing grays, black is used if it is + present in the PrintColors; otherwise, the + data is printed by superimposing each + requested color. + + MonochromePrint (bool) + *For bjc600 only*. Substitute black for Cyan, + Magenta and Yellow when printing (useful for + getting some monochrome output of a dithered + printing for example). Default is false. + This is a hardware mechanism as opposed to + the previous software one. I think that using + this or setting PrintColors to 0 will give the + same results. + +Note that the MediaType and ThickMedia options will be replaced by the use +of the device InputAttributes and OutputAttributes as soon as possible. + +Please note too that the print mode may be reset at the start of a print, +not at the end. This is the expected behaviour. If you need to reset +the printer to its default state, simply print a file that does just a +showpage. + +Device Informations +------------------- + +Here are other informations published by the driver that you will find +in the deviceinfo dictionary: + + OutputFaceUp (bool) This has the boolean value true, indicating that + the sheets are stacked face up. + + Version (float) In the form M.mmpp where M is the major version, + mm the bjc drivers minor version and pp the specific + driver minor version (that is, M.mm will always be + the same for the bjc600 and bjc800 drivers). + + VersionString (string) + A string that gives the version info plus + other indications. At the moment, things like + 'a' or 'b' may follow the version to indicate + alpha or beta versions and the date of the + last change to this version is given in the + form MM/DD/YY (no, it won't adapt to your + locale!). + +Hardware Margins +---------------- + +The BJC printers have top and bottom hardware margins of 3 mm and 7.1 +mm respectively (Canon says 7 mm but this is not usable because of +the rounding of paper sizes to PostScript points).. The left margin is +3.4 mm for A4 and smaller paper sizes, 6.4 mm for US paper sizes, +envelopes and cards. It is 4.0 mm for A3 paper on the BJC-800. + +The maximum printing width of a BJC-600 printer is 203 mm, in any event. +The maximum printing width of a BJC-800 printer is 289 mm on A3 paper, +and 203 mm on letter and A4 paper. + + +POSTSCRIPT PRINTER DESCRIPTION FILES +------------------------------------ + +The BJC600.PPD and BJC800.PPD files (whose long names are, respectively, +Canon_BubbleJetColor_600.ppd and Canon_BubbleJetColor_800.ppd) are PPD +files driving the features of the bjc600 and bjc800 drivers. + +They can be used for example on NEXTSTEP systems (presumably on +OpenStep systems too) and on Unix systems with Adobe's TranScript and +pslpr (not tested). + +The files are not complete at the moment. Please note too that +NEXTSTEP's printing interface does not correctly enforce constraints +specified in these files (in UIConstraints descriptions): you must +force yourself to use valid combinations of options. + +Customization of the PPD files +------------------------------ + +By default the files say that the paper used is US Letter, and they +use a normalized transfer function. + If you choose to use A4 printing by default, you must replace Letter by +A4 in lines that match the '\*Default.*: Letter' pattern. + Some versions of Ghostscript have problems with normalized colors, +which makes them add magenta in gray levels. If you have this problem, +replace the '*DefaultTransfer: Normalized' line by the alternate (correct) +'*DefaultTransfer: Null' line. + +Also note that the 'Thick Media' option is implemented by choosing a +value of 120 or 80 (for thick and thin media respectively) for the +MediaWeight feature of the drivers. If you ever change the threshold +for thick media in the driver code, you may need to change the values +in the PPD files too. + +All customization should be done using the '*Include: ' feature of PPD +files so that your local changes will be kept if you get an update of +these PPD files. + + +OTHER INFORMATIONS +------------------ + +Reporting Problems +------------------ + +When you report a problem please be as descriptive as possible, and +please send information that can be used to reproduce the problem. + Please don't forget to tell me which driver you use and its +version. Version information can be found in this file or preferrably +by issuing the following command in a shell: + + % echo "currentpagedevice /VersionString get ==" | \ + gs -q -sDEVICE=bjc600 - + +(the % doesn't count as part of the command and the device name should +be the device you really use). + +Contact Address +--------------- + +If you have problems with this driver (or if you are extremely +satisfied with it) you may email me at Yves.Arrouye@marin.fdn.fr. + +Acknowledgements +---------------- + +I am particularly grateful to Yoshio Kuniyoshi +without whom I'd never make these drivers and also to L. Peter Deutsch + who answered *all* my (often silly) questions about +the drivers interface used by Ghostscript. + Thanks also to the people who volunteered to beta-test the v2.x BJC +drivers; David Gaudine , Robert M. Kenney +, James McPherson and Ian Thurlbeck + (in an alphabetic listing) were particularly +helpful by discovering bugs and helping find out exact paper margins on +printers I don't have access to. + And *many* thanks to Klaus-Gunther Hess for +looking at the dithering code and devising a good CMYK dithering +algorithm for the Stylus Color, which I then adapted to the code of +these drivers. + +### ------------------------------ End --------------------------------- ### + +### ---------------- MS-Windows DIB printer driver ----------------- ### + +This section was written by Russell Lang, 4 September 1996 + +The mswinpr2 device uses MS-Windows printer drivers and should work +with any printer with DIB raster capabilities. +The printer resolution cannot be selected using PostScript commands +from Ghostscript; use the printer setup in the Control Panel instead. + +If no Windows printer name is specified in -sOutputFile, Ghostscript +will prompt for a Windows printer using the standard Print Setup +dialog box. You must set the orientation to Portrait, and you must +set the page size to that expected by Ghostscript. Failure to do so +will result in the image being clipped. Ghostscript sets the physical +device size to that of the Windows printer driver, but it does not +update the PostScript clipping path. + +If a Windows printer name is specified in -sOutputFile, using +the format "\\spool\printer_name", e.g. + -sOutputFile="\\spool\Apple LaserWriter II NT" +then Ghostscript will attempt to open the Windows printer without +any prompts (except of course if the printer is connected to FILE:). +Ghostscript attempts to set the Windows printer page size and orientation +to match that expected by Ghostscript, but doesn't always succeed. +The following algorithm is used: +- If the requested page size matches one of the Windows standard + page sizes +/- 2mm, ask for that standard size. +- Otherwise if the requested page size matches one of the Windows + standard page sizes in landscape mode, ask for that standard size + in landscape. +- Otherwise ask for the page size by specifying its dimensions only. +- If using Windows NT, select a form that matches the page size. + (This isn't working at the moment) +- Merge the above requests with the defaults. + If the printer driver ignores the requested paper size, no + error will be generated. It will print on the wrong paper size. +- Open the Windows printer with the merged orientation and size. +The Ghostscript physical device size will be updated to match +the Windows printer physical device. + +### ------------------------- JPEG file format ------------------------- ### + +Ghostscript includes output drivers that can produce JPEG (JFIF) files from +Postscript images. *Please note* that JPEG is designed for continuous-tone +images (such as photographs) and is therefore quite unsuitable for the vast +majority of page images produced with Postscript. If you get crummy-looking +JPEG files, don't blame Ghostscript; instead consult a reference about uses +and abuses of JPEG, such as the JPEG FAQ available at +http://www.faqs.org/faqs/jpeg-faq/. + +There are two JPEG output drivers, "jpeg" to produce color JPEG files and +"jpeggray" to produce grayscale JPEGs. Basic usage is the same as for other +file-format drivers: specify the device name and an output file name, for +example + gs -sDEVICE=jpeg -sOutputFile=foo.jpg foo.ps +You can also use the -r switch to determine the imaging resolution and thus +the output file's size in pixels. (The default resolution is normally +72x72dpi.) + +The JPEG devices support two special parameters to control the JPEG "quality +setting" (DCT quantization level). You can write + -dJPEGQ=number +to set the quality level according to the widely used IJG quality scale; or +if you prefer Adobe's QFactor quality scale, use + -dQFactor=number +The QFactor scale is used by Postscript's DCTEncode filter but is nearly +unheard-of elsewhere. + +-dJPEGQ accepts an integer from 0 to 100, while -dQFactor expects a decimal +fraction near 1.0. The default quality level is equivalent to -dJPEGQ=75. +(At this writing, that is the same as -dQFactor=0.5; but the IJG default +quality level might change in future releases.) + +The JPEG drivers could be extended to support additional JPEG compression +options, such as the other DCTEncode filter parameters, but so far they +haven't been. + +### ------------------------------ End --------------------------------- ### diff --git a/gs/dll.txt b/gs/dll.txt new file mode 100644 index 000000000..66890133c --- /dev/null +++ b/gs/dll.txt @@ -0,0 +1,554 @@ +/* Copyright (C) 1994-1996, Russell Lang. All rights reserved. + + This file is part of Aladdin Ghostscript. + + Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author + or distributor accepts any responsibility for the consequences of using it, + or for whether it serves any particular purpose or works at all, unless he + or she says so in writing. Refer to the Aladdin Ghostscript Free Public + License (the "License") for full details. + + Every copy of Aladdin Ghostscript must include a copy of the License, + normally in a plain ASCII text file named PUBLIC. The License grants you + the right to copy, modify and redistribute Aladdin Ghostscript, but only + under certain conditions described in the License. Among other things, the + License requires that the copyright notice and this notice be preserved on + all copies. +*/ + +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +This file, dll.txt, describes how to use the Ghostscript Dynamic +Link Library. + +For an overview of Ghostscript and a list of the documentation files, see +README. + +================================== +DLL.TXT 1996-09-05 +================================== + +For the OS/2, Win16 and Win32 platforms, Ghostscript is compiled +as a dynamic link library. + +To provide the interface described in use.txt, a smaller EXE loads +this Ghostscript DLL. +This EXE provides image windows and if necessary, a text window. +The source for the EXE is in dp*.* for OS/2 and dw*.* for Windows. +Refer to these source files for examples of DLL usage. + +This document document describes the DLL interface. + +The Win16 DLL (GSDLL16.DLL) is a large memory model DLL with far +static data. Due to the limitations of 16 bit MS-Windows, the DLL +can be used by only one program at a time. + +The Win32 DLL (GSDLL32.DLL) has MULTIPLE NONSHARED data segments. +Under Win32s it can be used by only one program at a time. +Under Windows 95 or NT it can be called by multiple programs. + +The OS/2 DLL (GSDLL2.DLL) has MULTIPLE NONSHARED data segments and +can be called by multiple programs. + +The interface to the DLL consists of 8 main functions, 1 provided +by the caller and the other 7 by the DLL. Some other platform +dependant functions are provided by the DLL for display devices. + +============= +DLL functions +============= +The seven functions provided by the DLL are: + int GSDLLAPI gsdll_revision(char **product, char **copyright, + long *gs_revision, long *gs_revisiondate) + int GSDLLAPI gsdll_init(GSDLL_CALLBACK callback, HWND hwnd, + int argc, char *argv[]); + int GSDLLAPI gsdll_execute_begin(void); + int GSDLLAPI gsdll_execute_cont(const char *str, int len); + int GSDLLAPI gsdll_execute_end(void); + int GSDLLAPI gsdll_exit(void); + int GSDLLAPI gsdll_lock_device(unsigned char *device, int flag); + +For OS/2, GSDLLAPI is defined as + #define GSDLLAPI +For Win32 and Win16, GSDLLAPI is defined as + #define GSDLLAPI CALLBACK _export + +---------------- +gsdll_revision() +---------------- +This returns the revision numbers and strings of the Ghostscript DLL. +This function may be called before gsdll_init(). +An example: + char *product; + char *copyright; + long revision; + long revisiondate; + gsdll_revision(&product, ©right, &revision, &revisiondate); +NULL pointers may be used if you do not want a particular value. + +It is recommended that this function be called before gsdll_init() +to make sure that the correct version of the Ghostscript DLL +has been loaded. + +------------ +gsdll_init() +------------ +The function gsdll_init() must be called after loading +the DLL and before executing any ghostscript commands. +The arguments are the address of the callback function, +a parent window handle, the count of arguments and an +array of pointers to the arguments. +For example + char *argv[5]; + argv[0] = "gswin.exe"; + argv[1] = "-Ic:\\gs;c:\gs\\fonts"; + argv[2] = "-dNOPAUSE", + argv[3] = "-sDEVICE=djet500", + argv[4] = NULL; + }; + argc = 4; + code = gsdll_init(gsdll_callback, hwnd, argc, argv); + +hwnd is used as the parent window handle for any windows +created by Ghostscript. +hwnd may be NULL if the caller does not have any windows, but +if NULL you should avoid using devices which may open windows. + +If the return code is zero then there is no error. +gsdll_execute_begin() or gsdll_exit() may now be called. + +If the return value is non-zero then gsdll_exit() must not be called. + +A return value of GSDLL_INIT_QUIT indicates that one of the +command line files or arguments called 'quit', or that GS +was reading stdin and reached EOF. This is not an error. +gsdll_exit() must not be called. + +A return value of GSDLL_INIT_IN_USE indicates that the DLL is +in use by another application (Windows 3.1 only). +The DLL should be immediately unloaded (or the caller terminated). +gsdll_exit() must not be called. + + +--------------------- +gsdll_execute_begin() +--------------------- +This must be called after gsdll_init() and before gsdll_execute_cont(); + + +-------------------- +gsdll_execute_cont() +-------------------- +After successfully calling gsdll_init() and gsdll_execute_begin(), +commands may be given to Ghostscript with gsdll_execute_cont(). +Examples are: + char *command = "1 2 add == flush\n"; + code = gsdll_execute_cont(command, strlen(command)); + command = "qu" + code = gsdll_execute_cont(command, strlen(command)); + command = "it\n" + code = gsdll_execute_cont(command, strlen(command)); +return code is zero if there are no errors. +return code is less than zero if an error has occured. +return code is less than or equal to -100 if "quit" has been + executed or a fatal error has occured. + gsdll_exit() must then be called - do not call gsdll_execute_end(). +gsdll_execute_cont does not flush stdio - if you want to see output from +Ghostscript you must do this explicitly as shown in the example above. + +When executing a string with gsdll_execute_cont, currentfile is the +input from gsdll_execute_cont. Reading from %stdin will use the +callback. + + +------------------- +gsdll_execute_end() +------------------- +If gsdll_execute_cont() did not return an error, then gsdll_execute_end() +must be called after gsdll_execute_cont() and before gsdll_exit(); + + +---------- +gsdll_exit +---------- +To terminate the Ghostscript DLL, gsdll_exit() is called. +This must be called if a fatal error has occured (see return +value of gsdll_execute_cont). +After calling gsdll_exit(), there are two options: +1. Unload the DLL, either by terminating the application or by +calling DosFreeModule (OS/2) or FreeLibrary (MS-Windows). +2. Call gsdll_init() again to restart Ghostscript. + + +----------------- +gsdll_lock_device +----------------- +Since the caller may be multithreaded, a lock is needed to control +access to the display device. This is accessed via the following +function. + +int gsdll_lock_device(unsigned char *device, int flag); + /* Lock the device if flag = TRUE */ + /* Unlock the device if flag = FALSE */ + /* device is a pointer to Ghostscript os2dll or mswindll device */ + /* from GSDLL_DEVICE message. */ + /* Return value is the lock count. */ + +To lock the device use + gsdll_lock_device(device, 1); +To unlock the device use + gsdll_lock_device(device, 0); + +Locking the device prevents the Ghostscript DLL from closing +the device or changing the device size or depth. +Ghostscript may draw into the device bitmap or update the palette +entries while the device is locked by the caller. + +This function is typically used to lock the device while +repainting a window, or copying the device bitmap to the clipboard. + +Under OS/2, Win95 and WinNT, this lock is implemented using +a mutual exclusion semaphore (mutex). The return value is +the lock count, which will be either 0 or 1, for unlocked and +locked respectively. +This function will block until the device is locked by the caller. + +Under Win16 or Win32s, gsdll_lock_device will always return +immediately, giving a lock count as the return value. If +a lock value of 2 or more is returned, beware! +Access to the device should be controlled by checking the +windows message queue only when the bitmap is not being accessed. + +================= +Callback function +================= +A callback function must be provided by the caller and given +as an argument to gsdll_init(). +The callback function is called by the DLL for stdio and to notify +the caller about device events. + +The function provided by the caller has the following prototype: + int gsdll_callback(int message, char *str, unsigned long count); +The pascal calling convention is not used. + +An example callback function is: + int + gsdll_callback(int message, char *str, unsigned long count) + { + char *p; + switch (message) { + case GSDLL_STDIN: + p = fgets(str, count, stdin); + if (p) + return strlen(str); + else + return 0; + case GSDLL_STDOUT: + if (str != (char *)NULL) + fwrite(str, 1, count, stdout); + return count; + case GSDLL_DEVICE: + fprintf(stdout,"Callback: DEVICE %p %s\n", str, + count ? "open" : "close"); + break; + case GSDLL_SYNC: + fprintf(stdout,"Callback: SYNC %p\n", str); + break; + case GSDLL_PAGE: + fprintf(stdout,"Callback: PAGE %p\n", str); + break; + case GSDLL_SIZE: + fprintf(stdout,"Callback: SIZE %p width=%d height=%d\n", str, + (int)(count & 0xffff), (int)((count>>16) & 0xffff) ); + break; + case GSDLL_POLL: + return 0; /* no error */ + default: + fprintf(stdout,"Callback: Unknown message=%d\n",message); + break; + } + return 0; + } + + +The messages used by the callback are: + #define GSDLL_STDIN 1 /* get count characters to str from stdin */ + /* return number of characters read */ + #define GSDLL_STDOUT 2 /* put count characters from str to stdout*/ + /* return number of characters written */ + #define GSDLL_DEVICE 3 /* device = str has been opened if count=1 */ + /* or closed if count=0 */ + #define GSDLL_SYNC 4 /* sync_output for device str */ + #define GSDLL_PAGE 5 /* output_page for device str */ + #define GSDLL_SIZE 6 /* resize for device str */ + /* LOWORD(count) is new xsize */ + /* HIWORD(count) is new ysize */ + #define GSDLL_POLL 7 /* Called from gp_check_interrupt */ + /* Can be used by caller to poll the message queue */ + /* Normally returns 0 */ + /* To abort gsdll_execute_cont(), return a */ + /* non zero error code until gsdll_execute_cont() */ + /* returns */ + +========================== +Example DLL usage for OS/2 +========================== +The following example shows a minimal usage of the Ghostscript DLL. +The example callback function above is needed. + +#define INCL_DOS +#include +#include +#include "gsdll.h" + +PFN_gsdll_init pgsdll_init; +PFN_gsdll_execute_begin pgsdll_execute_begin; +PFN_gsdll_execute_cont pgsdll_execute_cont; +PFN_gsdll_execute_end pgsdll_execute_end; +PFN_gsdll_exit pgsdll_exit; + +HMODULE hmodule_gsdll; +char buf[256]; + +int +main(int argc, char *argv[]) +{ +int code; +APIRET rc; + if (!DosLoadModule(buf, sizeof(buf), "GSDLL2", &hmodule_gsdll)) { + fprintf(stderr, "Loaded GSDLL2\n"); + DosQueryProcAddr(hmodule_gsdll, 0, "gsdll_init", (PFN *)(&pgsdll_init)); + DosQueryProcAddr(hmodule_gsdll, 0, "gsdll_execute_begin", (PFN *)(&pgsdll_execute_begin)); + DosQueryProcAddr(hmodule_gsdll, 0, "gsdll_execute_cont", (PFN *)(&pgsdll_execute_cont)); + DosQueryProcAddr(hmodule_gsdll, 0, "gsdll_execute_end", (PFN *)(&pgsdll_execute_end)); + DosQueryProcAddr(hmodule_gsdll, 0, "gsdll_exit", (PFN *)(&pgsdll_exit)); + } + else { + fprintf(stderr, "Can't load GSDLL2\n"); + } + + code = (*pgsdll_init)(gsdll_callback, NULL, argc, argv); + fprintf(stdout,"gsdll_init returns %d\n", code); + code = (*pgsdll_execute_begin)(); + if (code==0) { + while (fgets(buf, sizeof(buf), stdin)) { + code = (*pgsdll_execute_cont)(buf, strlen(buf)); + fprintf(stdout,"gsdll_execute returns %d\n", code); + if (code < 0) + break; + } + if (!code) + code = (*pgsdll_execute_end)(); + code = (*pgsdll_exit)(); + fprintf(stdout,"gsdll_exit returns %d\n", code); + } + rc = DosFreeModule(hmodule_gsdll); + fprintf(stdout,"DosFreeModule returns %d\n", rc); + return 0; +} + +=============================== +Ghostscript DLL device for OS/2 +=============================== +The os2dll device is provided in the Ghostscript DLL for use +by the caller. No drawing facilities are provided by the DLL +because the DLL may be loaded by a text only (non PM) application. + +The caller will be notified via the gsdll_callback when a new +os2dll device is opened or closed (GSDLL_DEVICE), when the window +should be redrawn (GSDLL_SYNC or GSDLL_PAGE) or when the bitmap +size changes (GSDLL_SIZE). + +Note that more than one os2dll device may be opened. + +One DLL function is available for accessing the os2dll device: + +---------------- +gsdll_get_bitmap +---------------- +The following function returns a pointer to a bitmap in BMP format. +The os2dll device draws into this bitmap. + +unsigned long gsdll_get_bitmap(unsigned char *device, unsigned char **pbitmap); + /* return in pbitmap the address of the bitmap */ + /* device is a pointer to Ghostscript os2dll device from GSDLL_DEVICE message */ + +The caller can then display the bitmap however it likes, but should +lock the bitmap with gsdll_lock_device() before painting from it, +and unlock it afterwards. The bitmap address will not change until +the os2dll device is closed, however the bitmap size and palette +may change at any time the bitmap is not locked. + +===================================== +Ghostscript DLL device for MS-Windows +===================================== +The mswindll device is provided in the Ghostscript DLL for use +by the caller. + +The caller will be notified via the gsdll_callback when a new +mswindll device is opened or closed (GSDLL_DEVICE), when the window +should be redrawn (GSDLL_SYNC or GSDLL_PAGE) or when the bitmap +size changes (GSDLL_SIZE). + +Note that more than one mswindll device may be opened. + +Four extra DLL functions are available for accessing the mswindll device: + +-------------- +gsdll_copy_dib +-------------- +This function is commonly used when copying the mswindll bitmap +to the clipboard. + +/* make a copy of the device bitmap and return shared memory handle to it */ +/* device is a pointer to Ghostscript device from GSDLL_DEVICE message */ +HGLOBAL GSDLLAPI gsdll_copy_dib(unsigned char *device); + +------------------ +gsdll_copy_palette +------------------ +This function can be used when copying the mswindll palette +to the clipboard. + +/* make a copy of the device palette and return a handle to it */ +/* device is a pointer to Ghostscript device from GSDLL_DEVICE message */ +HPALETTE GSDLLAPI gsdll_copy_palette(unsigned char *device); + +---------- +gsdll_draw +---------- +This function is used for displaying output from the mswindll device. +The caller should create a window and call gsdll_draw in response to +the WM_PAINT message. The device context hdc must be for a device +because SetDIBitsToDevice() is used. + +/* copy the rectangle src from the device bitmap */ +/* to the rectangle dest on the device given by hdc */ +/* hdc must be a device context for a device (NOT a bitmap) */ +/* device is a pointer to Ghostscript device from GSDLL_DEVICE message */ +void GSDLLAPI gsdll_draw(unsigned char *device, HDC hdc, + LPRECT dest, LPRECT src); + +-------------------- +gsdll_get_bitmap_row +-------------------- +The following function returns a BMP header, a palette and a pointer +to a row in the bitmap. + +int GSDLLAPI gsdll_get_bitmap_row(unsigned char *device, LPBITMAPINFOHEADER pbmih, + LPRGBQUAD prgbquad, LPBYTE *ppbyte, unsigned int row) +/* Copy bitmap + * If pbmih nonzero, copy the BITMAPINFOHEADER. + * If prgbquad nonzero, copy the palette. + * number of entries copied is given by pbmih->biClrUsed + * If ppbyte nonzero, return pointer to row. + * pointer is only valid while device is locked + * GS can change the palette while the device is locked. + * Do not call this function while GS is busy. + * + * This function exists to allow the bitmap to be copied to a file + * or structured storage, without the overhead of having two copies + * of the bitmap in memory at the same time. + */ + +================ +MS-Windows 16bit +================ +This platform has the most problems of the three. +Support for it may be dropped in future. + +The Win16 DLL (GSDLL16.DLL) is a large memory model DLL with far +static data. Due to the limitations of 16 bit MS-Windows, the DLL +can used by only one program at a time. +However, GSDLL16 is marked as having SINGLE SHARED data segments which +allows multiple applications to load GSDLL16. (The DLL wouldn't load +at all if MULTIPLE NONSHARED was used). Applications loading GSDLL16 +should check the return value of gsdll_init(). If it is non-zero +then GSDLL16 is already in use by another application and should NOT +be used. GSDLL16 should be unloaded immediately using FreeLibrary(), +or the caller program should terminate. + +The segmented architecture of the 80286 causes the usual amount of +grief when using GSDLL16. +Because the callback is called from the DLL which is using a different +data segment, the callback must be declared as _far _export. + int _far _export gsdll_callback(int message, char *str, unsigned long count); +Instead of giving gsdll_init the address of gsdll_callback, it should +instead be given the address of a thunk created by MakeProcInstance. +This thunk changes the data segment back to that used by the caller: + FARPROC lpfnCallback; + lpfnCallback = (FARPROC)MakeProcInstance((FARPROC)gsdll_callback, hInstance); + code = (*pgsdll_init)((GSDLL_CALLBACK)lpfnCallback, NULL, argc, argv); + if (!code) { + fprintf(stderr, "GSDLL16 is already in use\n"); + return -1; + } + +================== +Changes 1996-09-05 +================== +Ghostscript locks the device just before closing it, to prevent +closing the device while the caller is drawing from it. + +Added gsdll_get_bitmap_row() to MS-Windows. + +================== +Changes 1996-07-02 +================== +gsdll_init() error code changed. + +================== +Changes 1996-05-30 +================== +gsdll_init() error code changed. + +================== +Changes 1996-05-16 +================== +Added HWND as a parameter to gsdll_init(). +THIS IS A NON BACKWARD COMPATIBLE CHANGE. + +Documented that gsdll_execute_end() must not be called if +gsdll_execute_cont() returns with error. + + +================== +Changes 1996-03-16 +================== +New call back message GSDLL_POLL. + +Removed OS/2 gsdll_lock_bitmap(). Replaced by gsdll_lock_device(). + +Add gsdll_lock_device to OS/2 and MS-Windows. + For non multi-threaded environments (Win16, Win32s) this will + return a lock count but return immediately. + For multi-threaded environments this will maintain a lock + using a mutex (which may block). + +Changed gsdll_init() to take argc and argv. Now supports the + full range of Ghostscript command line options. + +*** OS/2 has't been tested yet. + +================== +Changes 1995-07-26 +================== +gsdll_revision needs to be checked before using other APIs, + to protect against finding a later version of the GS DLL + with changed APIs. + +gsdll_execute removed. +gsdll_execute_begin/cont/end added. + Keywords can now be split across calls to gsdll_execute_cont. + DLL input can now be done without using the stdin callback + +Now use GSDLLAPI instead of WINAPI + Under Windows, the calling convention is CALLBACK, not pascal. + For Win32 this is _stdcall, for Win16 this is _far _pascal. + + +Original version 1994-07-03 + +==================== +/* end of dll.txt */ +==================== diff --git a/gs/doc/Gs-vms.hlp b/gs/doc/Gs-vms.hlp new file mode 100644 index 000000000..6a19e3ecd --- /dev/null +++ b/gs/doc/Gs-vms.hlp @@ -0,0 +1,290 @@ +1 gs + gs - Aladdin Ghostscript interpreter/previewer +! This file describes version 5.13 of Aladdin Ghostscript. +! 27 April 1998 + Usage: + $ gs [options] [file ...] + + Ghostscript is an implementation of Adobe Systems' PostScript (tm) + and Portable Document Format (PDF) languages. Gs reads files in sequence + and executes them as Ghostscript programs. After doing this, it reads + further input from the standard input stream (normally the keyboard). + Each line is interpreted separately. To exit from the interpreter, + enter the `quit' command. The interpreter also exits gracefully if it + encounters end-of-file. Typing the interrupt character (e.g. Control-C) + is also safe. + +2 Description + The interpreter recognizes several switches described below, which + may appear anywhere in the command line and apply to all files + thereafter. + + You can get a help message by invoking Ghostscript with the -h + or -? option. This message also lists the available devices. + + Ghostscript may be built with multiple output devices. Ghostscript + normally opens the first one and directs output to it. To use + device xyz as the initial output device, include the switch + "-sDEVICE=xyz" + in the command line. Note that this switch must precede the first + .ps file, and only its first invocation has any effect. For example, + for printer output in a normal configuration that includes an Epson + printer driver, you might use the command + gs "-sDEVICE=epson" myfile.ps + instead of just + gs myfile.ps + Alternatively, you can type + (epson) selectdevice + (myfile.ps) run + All output then goes to the printer instead of the display until + further notice. You can switch devices at any time by using the + selectdevice procedure, e.g., + (vga) selectdevice + or + (epson) selectdevice + As yet a third alternative, you can define a logical name GS_DEVICE + as the desired default device name. The order of precedence for these + alternatives, highest to lowest, is: + selectdevice + (command line) + GS_DEVICE + (first device in build list) + + To select the density on a printer, use + gs "-sDEVICE=" -rx + For example, on a 9-pin Epson-compatible printer, you can get the + lowest-density (fastest) mode with + gs "-sDEVICE=epson" -r60x72 + and the highest-density mode with + gs "-sDEVICE=epson" -r240x72. + + If you select a printer as the output device, Ghostscript also + allows you to control where the device sends its output. Normally, + output goes directly to a scratch file on Unix and VMS systems. To + send the output to a series of files foo1.xyz, foo2.xyz, ..., use + the switch + "-sOutputFile=foo%d.xyz" + The %d is a printf format specification; you can use other formats + like %02d. Each file will receive one page of output. Alternatively, + to send the output to a single file foo.xyz, with all the pages con- + catenated, use the switch + "-sOutputFile=foo.xyz" + + To find out what devices are available, type + devicenames == + after starting up Ghostscript. Alternatively, you can use the -h or -? + switch in the command line; the help message also lists the available + devices. + + To select a different paper size, use the command line switch + "-sPAPERSIZE=a_known_paper_size" + e.g., + "-sPAPERSIZE=a4" + or + "-sPAPERSIZE=legal" + + As of this printing, the known paper sizes, defined in gs_statd.ps, are: + + PAPERSIZE X" Y" X cm Y cm + ____________________________________________________ + 11x17 11" 17" 27.94 43.18 + a0 33.0556" 46.7778" 83.9611 118.816 + a10 1.02778" 1.45833" 2.61056 3.70417 + a1 23.3889" 33.0556" 59.4078 83.9611 + a2 16.5278" 23.3889" 41.9806 59.4078 + a3 11.6944" 16.5278" 29.7039 41.9806 + a4 8.26389" 11.6944" 20.9903 29.7039 + a5 5.84722" 8.26389" 14.8519 20.9903 + a6 4.125" 5.84722" 10.4775 14.8519 + a7 2.91667" 4.125" 7.40833 10.4775 + a8 2.05556" 2.91667" 5.22111 7.40833 + a9 1.45833" 2.05556" 3.70417 5.22111 + archA 9" 12" 22.86 30.48 + archB 12" 18" 30.48 45.72 + archC 18" 24" 45.72 60.96 + archD 24" 36" 60.96 91.44 + archE 36" 48" 91.44 121.92 + b0 39.3889" 55.6667" 100.048 141.393 + b1 27.8333" 39.3889" 70.6967 100.048 + b2 19.6944" 27.8333" 50.0239 70.6967 + b3 13.9167" 19.6944" 35.3483 50.0239 + b4 9.84722" 13.9167" 25.0119 35.3483 + b5 6.95833" 9.84722" 17.6742 25.0119 + flsa 8.5" 13" 21.59 33.02 + flse 8.5" 13" 21.59 33.02 + halfletter 5.5" 8.5" 13.97 21.59 + ledger 17" 11" 43.18 27.94 + legal 8.5" 14" 21.59 35.56 + letter 8.5" 11" 21.59 27.94 + note 7.5" 10" 19.05 25.4 + +2 Initialization_files + When looking for the initialization files (gs_*.ps), the files related + to fonts, or the file for the `run' operator, Ghostscript first tries + opening the file with the name as given (i.e., using the current + working directory if none is specified). If this fails, and the file + name doesn't specify an explicit directory or drive, Ghostscript will + try directories in the following order: + + 1. The directory/ies specified by the -I switch(es) in the command + line (see below), if any; + 2. The directory/ies specified by the GS_LIB logical, if any; + 3. The directory/ies specified by the GS_LIB_DEFAULT macro in the + Ghostscript makefile. + + Each of these (GS_LIB_DEFAULT, GS_LIB, and -I parameter) may be either + a single directory, or a list of directories separated by a `:'. + +2 X_resources + Ghostscript looks for the following resources under the program name + `Ghostscript': + + borderWidth + The border width in pixels (default = 1). + + borderColor + The name of the border color (default = black). + + geometry + The window size and placement, WxH+X+Y (default is NULL). + + xResolution + The number of x pixels per inch (default is computed from + WidthOfScreen and WidthMMOfScreen). + + yResolution + The number of y pixels per inch (default is computed from + HeightOfScreen and HeightMMOfScreen). + + useBackingPixmap + Determines whether backing store is to be used for saving display + window (default = true). + + See the file `use.txt' for a more complete list of resources. + + To set these resources, put them in a file (such as + SYS$Login:ghostscript.dat) in the following form: + + Ghostscript*geometry: 612x792-0+0 + Ghostscript*xResolution: 72 + Ghostscript*yResolution: 72 + +2 Options + Note that VMS will convert all command line arguments to lower case + if they are not within quotes. Therefore, if a certain command does + not work, try again but with quotes around it. + + -- filename arg1 ... + Takes the next argument as a file name as usual, but takes all + remaining arguments (even if they have the syntactic form of switches) + and defines the name ARGUMENTS in userdict (not systemdict) as an + array of those strings, before running the file. When Ghostscript + finishes executing the file, it exits. + + -Dname=token + -dname=token + Define a name in systemdict with the given definition. The token must + be exactly one token (as defined by the `token' operator) and must not + contain any whitespace. + + -Dname + -dname + Define a name in systemdict with value=null. + + -Sname=string + -sname=string + Define a name in systemdict with a given string as value. This is + different from -d. For example, -dname=35 is equivalent to the + program fragment + /name 35 def + whereas -sname=35 is equivalent to + /name (35) def + + -q + Quiet startup - suppress normal startup messages, and also do the + equivalent of -dQUIET. + + -gnumber1Xnumber2 + Equivalent to -dDEVICEWIDTH=number1 and -dDEVICEHEIGHT=number2. This is + for the benefit of devices (such as X11 windows) that require (or allow) + width and height to be specified. + + -rnumber + -rnumber1Xnumber2 + Equivalent to -dDEVICEXRESOLUTION=number1 and -dDEVICEYRESOLUTION=number2 + This is for the benefit of devices (such as printers) that support + multiple X and Y resolutions. (If only one number is given, it is used + for both X and Y resolutions.) + + -Idirectories + Adds the designated list of directories at the head of the search path + for library files. + + Note that gs_init.ps makes systemdict read-only, so the values of names + defined with -D/d/S/s cannot be changed (although, of course, they can + be superseded by definitions in userdict or other dictionaries.) + +2 Special_names + + -dDISKFONTS + Causes individual character outlines to be loaded from the disk the + first time they are encountered. (Normally Ghostscript loads all the + character outlines when it loads a font.) This may allow loading more + fonts into RAM, at the expense of slower rendering. + + -dNOCACHE + Disables character caching. Only useful for debugging. + + -dNOBIND + Disables the `bind' operator. Only useful for debugging. + + -dNODISPLAY + Suppresses the normal initialization of the output device. This may be + useful when debugging. + + -dNOPAUSE + Disables the prompt and pause at the end of each page. This may be + desirable for applications where another program is `driving' + Ghostscript. + + -dNOPLATFONTS + Disables the use of fonts supplied by the underlying platform (e.g. + X Windows). This may be needed if the platform fonts look undesirably + different from the scalable fonts. + + -dSAFER + Disables the deletefile and renamefile operators, and the ability to + open files in any mode other than read-only. This may be desirable + for spoolers or other sensitive environments. + + -dWRITESYSTEMDICT + Leaves systemdict writable. This is necessary when running special + utility programs such as font2c and pcharstr, which must bypass normal + PostScript access protection. + + -sDEVICE=device + Selects an alternate initial output device, as described above. + + -sOutputFile=filename + Selects an alternate output file for the initial output device, as + described above. + +2 Files +!!! Change + GS_Root:[Ghostscript.gs4_0] + Startup-files, utilities, and basic font definitions. + + GS_Root:[Ghostscript.Fonts4_0] + Additional font definitions. + + GS_Root:[Ghostscript.gs4_0.Examples] + Demo Ghostscript files. + + GS_Root:[Ghostscript.gs4_0.Doc] + Assorted document files. +!!! Change +2 See_also + The various Ghostscript document files (above). + +2 Bugs + See the network news group comp.lang.postscript. diff --git a/gs/doc/Public b/gs/doc/Public new file mode 100644 index 000000000..1b2c6b930 --- /dev/null +++ b/gs/doc/Public @@ -0,0 +1,215 @@ + ALADDIN FREE PUBLIC LICENSE + (Version 6, June 17, 1997) + + Copyright (C) 1994, 1995, 1997 Aladdin Enterprises, + Menlo Park, California, U.S.A. All rights reserved. + + NOTE: This License is not the same as any of the GNU Licenses + published by the Free Software Foundation. Its terms are + substantially different from those of the GNU Licenses. + If you are familiar with the GNU Licenses, please read this + license with extra care. + +Aladdin Enterprises hereby grants to anyone the permission to apply this +License to their own work, as long as the entire License (including the +above notices and this paragraph) is copied with no changes, additions, or +deletions except for changing the first paragraph of Section 0 to include a +suitable description of the work to which the license is being applied and +of the person or entity that holds the copyright in the work, and, if the +License is being applied to a work created in a country other than the +United States, replacing the first paragraph of Section 6 with an +appropriate reference to the laws of the appropriate country. + +0. Subject Matter + +This License applies to the computer program known as "Aladdin Ghostscript." +The "Program", below, refers to such program. The Program is a copyrighted +work whose copyright is held by Aladdin Enterprises (the "Licensor"). +Please note that Aladdin Ghostscript is neither the program known as "GNU +Ghostscript" nor the version of Ghostscript available for commercial +licensing from Artifex Software Inc. + +A "work based on the Program" means either the Program or any derivative +work of the Program, as defined in the United States Copyright Act of 1976, +such as a translation or a modification. + +BY MODIFYING OR DISTRIBUTING THE PROGRAM (OR ANY WORK BASED ON THE +PROGRAM), YOU INDICATE YOUR ACCEPTANCE OF THIS LICENSE TO DO SO, AND ALL +ITS TERMS AND CONDITIONS FOR COPYING, DISTRIBUTING OR MODIFYING THE PROGRAM +OR WORKS BASED ON IT. NOTHING OTHER THAN THIS LICENSE GRANTS YOU +PERMISSION TO MODIFY OR DISTRIBUTE THE PROGRAM OR ITS DERIVATIVE WORKS. +THESE ACTIONS ARE PROHIBITED BY LAW. IF YOU DO NOT ACCEPT THESE TERMS AND +CONDITIONS, DO NOT MODIFY OR DISTRIBUTE THE PROGRAM. + +1. Licenses. + +Licensor hereby grants you the following rights, provided that you comply +with all of the restrictions set forth in this License and provided, +further, that you distribute an unmodified copy of this License with the +Program: + +(a) You may copy and distribute literal (i.e., verbatim) copies of the +Program's source code as you receive it throughout the world, in any +medium. + +(b) You may modify the Program, create works based on the Program and +distribute copies of such throughout the world, in any medium. + +2. Restrictions. + +This license is subject to the following restrictions: + +(a) Distribution of the Program or any work based on the Program by a +commercial organization to any third party is prohibited if any payment is +made in connection with such distribution, whether directly (as in payment +for a copy of the Program) or indirectly (as in payment for some service +related to the Program, or payment for some product or service that includes +a copy of the Program "without charge"; these are only examples, and not an +exhaustive enumeration of prohibited activities). The following methods of +distribution involving payment shall not in and of themselves be a violation +of this restriction: + + (i) Posting the Program on a public access information storage and +retrieval service for which a fee is received for retrieving information +(such as an on-line service), provided that the fee is not content-dependent +(i.e., the fee would be the same for retrieving the same volume of +information consisting of random data) and that access to the service and to +the Program is available independent of any other product or service. An +example of a service that does not fall under this section is an on-line +service that is operated by a company and that is only available to +customers of that company. (This is not an exhaustive enumeration.) + + (ii) Distributing the Program on removable computer-readable media, +provided that the files containing the Program are reproduced entirely and +verbatim on such media, that all information on such media be +redistributable for non-commercial purposes without charge, and that such +media are distributed by themselves (except for accompanying documentation) +independent of any other product or service. Examples of such media include +CD-ROM, magnetic tape, and optical storage media. (This is not intended to +be an exhaustive list.) An example of a distribution that does not fall +under this section is a CD-ROM included in a book or magazine. (This is not +an exhaustive enumeration.) + +(b) Activities other than copying, distribution and modification of the +Program are not subject to this License and they are outside its scope. +Functional use (running) of the Program is not restricted, and any output +produced through the use of the Program is subject to this license only if +its contents constitute a work based on the Program (independent of having +been made by running the Program). + +(c) You must meet all of the following conditions with respect to any work +that you distribute or publish that in whole or in part contains or is +derived from the Program or any part thereof ("the Work"): + + (i) If you have modified the Program, you must cause the Work to +carry prominent notices stating that you have modified the Program's files +and the date of any change; + + (ii) You must cause the Work to be licensed as a whole and at no +charge to all third parties under the terms of this License; + + (iii) If the Work normally reads commands interactively when run, +you must cause it, at each time the Work commences operation, to print or +display an announcement including an appropriate copyright notice and a +notice that there is no warranty (or else, saying that you provide a +warranty). Such notice must also state that users may redistribute the Work +only under the conditions of this License and tell the user how to view the +copy of this License included with the Work. (Exceptions: if the Program is +interactive but normally prints or displays such an announcement only at the +request of a user, such as in an "About box", the Work is required to print +or display the notice only under the same circumstances; if the Program +itself is interactive but does not normally print such an announcement, the +Work is not required to print an announcement.); + + (iv) You must accompany the Work with the complete corresponding +machine-readable source code, delivered on a medium customarily used for +software interchange. The source code for a work means the preferred form +of the work for making modifications to it. For an executable work, +complete source code means all the source code for all modules it contains, +plus any associated interface definition files, plus the scripts used to +control compilation and installation of the executable code. If you +distribute with the Work any component that is normally distributed (in +either source or binary form) with the major components (compiler, kernel, +and so on) of the operating system on which the executable runs, you must +also distribute the source code of that component if you have it and are +allowed to do so; + + (v) If you distribute any written or printed material at all with +the Work, such material must include either a written copy of this License, +or a prominent written indication that the Work is covered by this License +and written instructions for printing and/or displaying the copy of the +License on the distribution medium; + + (vi) You may not impose any further restrictions on the recipient's +exercise of the rights granted herein. + +If distribution of executable or object code is made by offering the +equivalent ability to copy from a designated place, then offering +equivalent ability to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source code along with the object code. + +3. Reservation of Rights. + +No rights are granted to the Program except as expressly set forth herein. +You may not copy, modify, sublicense, or distribute the Program except as +expressly provided under this License. Any attempt otherwise to copy, +modify, sublicense or distribute the Program is void, and will +automatically terminate your rights under this License. However, parties +who have received copies, or rights, from you under this License will not +have their licenses terminated so long as such parties remain in full +compliance. + +4. Other Restrictions. + +If the distribution and/or use of the Program is restricted in certain +countries for any reason, Licensor may add an explicit geographical +distribution limitation excluding those countries, so that distribution is +permitted only in or among countries not thus excluded. In such case, +this License incorporates the limitation as if written in the body of this +License. + +5. Limitations. + +THE PROGRAM IS PROVIDED TO YOU "AS IS," WITHOUT WARRANTY. THERE IS NO +WARRANTY FOR THE PROGRAM, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE ENTIRE +RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD +THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY +SERVICING, REPAIR OR CORRECTION. + +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL +LICENSOR, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE +PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + +6. General. + +This License is governed by the laws of the State of California, U.S.A., +excluding choice of law rules. + +If any part of this License is found to be in conflict with the law, that +part shall be interpreted in its broadest meaning consistent with the law, +and no other parts of the License shall be affected. + +For United States Government users, the Program is provided with RESTRICTED +RIGHTS. If you are a unit or agency of the United States Government or are +acquiring the Software for any such unit or agency, the following apply: + + If the unit or agency is the Department of Defense ("DOD"), the + Software and its documentation are classified as "commercial computer + software" and "commercial computer software documentation" + respectively and, pursuant to DFAR Section 227.7202, the Government is + acquiring the Software and its documentation in accordance with the + terms of this License. If the unit or agency is other than DOD, the + Software and its documentation are classified as "commercial computer + software" and "commercial computer software documentation" + respectively and, pursuant to FAR Section 12.212, the Government is + acquiring the Software and its documentation in accordance with the + terms of this License. diff --git a/gs/doc/ps2epsi.txt b/gs/doc/ps2epsi.txt new file mode 100644 index 000000000..772aa179d --- /dev/null +++ b/gs/doc/ps2epsi.txt @@ -0,0 +1,62 @@ + NOTE: this file was contributed by a user: please contact + George Cameron + if you have questions. + +OVERVIEW: + + ps2epsi is a utility, based on Ghostscript, which takes an input postscript + file and generates a new output file which conforms to Adobe's 'Encapsulated + Postscript Interchange' or EPSI format. This is a special form of encapsulated + postscript (EPS) which adds a bitmap version of the final displayed page (in + the form of postscript comments) to the beginning of the file. This bitmap + can be used by programs which understand EPSI (usually word processors or + DTP programs) to give a preview version of the postscript on screen. The + displayed quality is often not very good (eg. low resolution, no colours), + but the final printed version uses the 'real' postscript, and thus has the + normal full postscript quality. + +FRAMEMAKER: + + The Framemaker DTP system is one application which understands EPSI files, + and ps2epsi has been tested on a number of postscript diagrams from a + variety of sources, using Framemaker 3.0 on a Sun. I believe that Framemaker + on the other platforms should also be able to use these files, although I + have not been able to test this. + +FILES: + + ps2epsi.txt - this file + ps2epsi.bat - MSDOS batch file + ps2epsi - Unix shell script + ps2epsi.ps - the Ghostscript program which does the work + +MSDOS USAGE: + + Using the supplied batch file, the command is simply: + + ps2epsi infile.ps outfile.epi + + where infile.ps is the original postscript file, and outfile.epi is the + name of the output file. + +UNIX USAGE: + + Using the supplied shell script, the command is: + + ps2epsi infile.ps [outfile.epsi] + + where infile.ps is the input file and outfile.epsi is the output EPSI + file. If the output filename is omitted, it will be generated from the + input filename - if a standard extension (.ps, .cps, .eps or .epsf) is + used, this will be replaced with the output extension .epsi . + +LIMITATIONS: + + Successful encapsulation of arbitrary postscript files cannot be guaranteed, + as there are certain restrictions in what is permitted in a postscript file + for it to be properly encapsulated. ps2epsi does a little extra work to + try to help encapsulation, and it automatically calculates the bounding box + (required for all encapsulated postscript files), so, most of the time, it + does a pretty good job. There are bound to be cases, however, where the + encapsulation will not work, because of the content of the original postscript + file. diff --git a/gs/drivers.txt b/gs/drivers.txt new file mode 100644 index 000000000..4306058ef --- /dev/null +++ b/gs/drivers.txt @@ -0,0 +1,1355 @@ + Copyright (C) 1989, 1996 Aladdin Enterprises. All rights reserved. + + This file is part of Aladdin Ghostscript. + + Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author + or distributor accepts any responsibility for the consequences of using it, + or for whether it serves any particular purpose or works at all, unless he + or she says so in writing. Refer to the Aladdin Ghostscript Free Public + License (the "License") for full details. + + Every copy of Aladdin Ghostscript must include a copy of the License, + normally in a plain ASCII text file named PUBLIC. The License grants you + the right to copy, modify and redistribute Aladdin Ghostscript, but only + under certain conditions described in the License. Among other things, the + License requires that the copyright notice and this notice be preserved on + all copies. + +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +This file, drivers.txt, describes the interface between Ghostscript and +device drivers. + +For an overview of Ghostscript and a list of the documentation files, see +README. + +******** +******** Adding a driver ******** +******** + +To add a driver to Ghostscript, all you need to do is edit devs.mak in +two places. The first is the list of devices, in the section headed + +# -------------------------------- Catalog ------------------------------- # + +Pick a name for your device, say smurf, and add smurf to the list. +(Device names must be 1 to 8 characters, consisting of only letters, +digits, and underscores, of which the first character must be a letter. +Case is significant: all current device names are lower case.) +The second is the section headed + +# ---------------------------- Device drivers ---------------------------- # + +Suppose the files containing the smurf driver are called joe and fred. +Then you should add the following lines: + +# ------ The SMURF device ------ # + +smurf_=joe.$(OBJ) fred.$(OBJ) +smurf.dev: $(smurf_) + $(SETDEV) smurf $(smurf_) + +joe.$(OBJ): joe.c ...and whatever it depends on + +fred.$(OBJ): fred.c ...and whatever it depends on + +If the smurf driver also needs special libraries, e.g., a library named +gorf, then the entry should look like this: + +smurf.dev: $(smurf_) + $(SETDEV) smurf $(smurf_) + $(ADDMOD) smurf -lib gorf + +If, as will usually be the case, your driver is a printer driver (as +discussed below), the device entry should look like this: + +smurf.dev: $(smurf_) page.dev + $(SETPDEV) smurf $(smurf_) + +or + +smurf.dev: $(smurf_) page.dev + $(SETPDEV) smurf $(smurf_) + $(ADDMOD) smurf -lib gorf + +******** +******** Keeping things simple +******** + +If you want to add a simple device (specifically, a black-and-white +printer), you probably don't need to read the rest of this document; just +use the code in an existing driver as a guide. The Epson and BubbleJet +drivers (gdevepsn.c and gdevbj10.c) are good models for dot-matrix +printers, which require presenting the data for many scan lines at once; +the DeskJet/LaserJet drivers (gdevdjet.c) are good models for laser +printers, which take a single scan line at a time but support data +compression. (For color printers, there are unfortunately no good models: +the two major color inkjet printer drivers, gdevcdj.c and gdevstc.c, are +far too complex to read.) + +On the other hand, if you're writing a driver for some more esoteric +device, you probably do need at least some of the information in the rest +of this document. It might be a good idea for you to read it in +conjunction with one of the existing drivers. + +Duplication of code, and sheer code volume, is a serious maintenance and +distribution problem for Ghostscript. If your device is similar to an +existing one, try to implement your driver by adding some parameterization +to an existing driver rather than copying code. gdevepsn.c and gdevdjet.c +are good examples of this approach. + +******** +******** Driver structure ******** +******** + +A device is represented by a structure divided into three parts: + + - procedures that are shared by all instances of each device; + + - parameters that are present in all devices but may be different + for each device or instance; and + + - device-specific parameters that may be different for each instance. + +Normally, the procedure structure is defined and initialized at compile +time. A prototype of the parameter structure (including both generic and +device-specific parameters) is defined and initialized at compile time, but +is copied and filled in when an instance of the device is created. Both of +these structures should be declared as const, but for backward +compatibility reasons are not. + +The gx_device_common macro defines the common structure elements, with the +intent that devices define and export a structure along the following +lines. Do not fill in the individual generic parameter values in the usual +way for C structures: use the macros defined for this purpose in gxdevice.h +or, if applicable, gdevprn.h. + + typedef struct smurf_device_s { + gx_device_common; + ... device-specific parameters ... + } smurf_device; + smurf_device far_data gs_smurf_device = { + ... macro for generic parameter values ..., + { ... procedures ... }, /* std_procs */ + ... device-specific parameter values if any ... + }; + +The device structure instance *must* have the name gs_smurf_device, where +smurf is the device name used in devs.mak. + +All the device procedures are called with the device as the first argument. +Since each device type is actually a different structure type, the device +procedures must be declared as taking a gx_device * as their first +argument, and must cast it to smurf_device * internally. For example, in +the code for the "memory" device, the first argument to all routines is +called dev, but the routines actually use mdev to reference elements of the +full structure, by virtue of the definition + + #define mdev ((gx_device_memory *)dev) + +(This is a cheap version of "object-oriented" programming: in C++, for +example, the cast would be unnecessary, and in fact the procedure table +would be constructed by the compiler.) + +Structure definition +-------------------- + +You should consult the definition of struct gx_device_s in gxdevice.h for +the complete details of the generic device structure. Some of the most +important members of this structure for ordinary drivers are: + + const char *dname; /* the device name */ + bool is_open; /* true if device has been opened */ + gx_device_color_info color_info; /* color information */ + int width; /* width in pixels */ + int height; /* height in pixels */ + +The name in the structure (dname) should be the same as the name in +devs.mak. + +gx_device_common is a macro consisting of just the element definitions. + +For sophisticated developers only +--------------------------------- + +If for any reason you need to change the definition of the basic device +structure, or add procedures, you must change the following places: + + - This document and NEWS (if you want to keep the + documentation up to date). + - The definition of gx_device_common and/or the procedures + in gxdevice.h. + - Possibly, the default forwarding procedures declared in gxdevice.h + and implemented in gdevnfwd.c. + - The device procedure record completion routines in gdevdflt.c. + - Possibly, the default device implementation in gdevdflt.c and + gdevddrw.c. + - If you are adding procedures that produce output, the bounding box + device in gdevbbox.c. + - The following devices that must have complete (non-defaulted) + procedure vectors: + - The null device in gdevnfwd.c. + - The command list "device" in gxclist.c. This is + not an actual device; it only defines procedures. + - The "memory" devices in gdevmem.h and gdevm*.c. + - The halftoning device in gdevht.c. + - The clip list accumulation "device" in gxacpath.c. + - The clipping "devices" in gxcpath.c and gxclip2.c. + - The Pattern accumulation "device" in gxpcmap.c. + - The hit detection "device" in zupath.c. + - The generic printer device macros in gdevprn.h. + - The generic printer device code in gdevprn.c. + - The RasterOp source device in gdevmrop.c. + +You may also have to change the code for gx_default_get_params and/or +gx_default_put_params (in gsdparam.c). + +You should not have to change any of the real devices in the standard +Ghostscript distribution (listed in devs.mak) or any of your own devices, +because all of them are supposed to use the macros in gxdevice.h or +gdevprn.h to define and initialize their state. + +******** +******** Types and coordinates ******** +******** + +Coordinate system +----------------- + +Since each driver specifies the initial transformation from user to device +coordinates, the driver can use any coordinate system it wants, as long as a +device coordinate will fit in an int. (This is only an issue on MS-DOS +systems, where ints are only 16 bits. User coordinates are represented as +floats.) Most current drivers use a coordinate system with (0,0) in the +upper left corner, with X increasing to the right and Y increasing toward +the bottom. However, there is supposed to be nothing in the rest of +Ghostscript that assumes this, and indeed some drivers use a coordinate +system with (0,0) in the lower left corner. + +Drivers must check (and, if necessary, clip) the coordinate parameters +given to them: they should not assume the coordinates will be in bounds. +The fit_fill and fit_copy macros in gxdevice.h are very helpful in doing +this. + +Color definition +---------------- + +Ghostscript represents colors internally as RGB or CMYK values. In +communicating with devices, however, it assumes that each device has a +palette of colors identified by integers (to be precise, elements of type +gx_color_index). Drivers may provide a uniformly spaced gray ramp or +color cube for halftoning, or they may do their own color approximation, +or both. + +The color_info member of the device structure defines the color and +gray-scale capabilities of the device. Its type is defined as follows: + +typedef struct gx_device_color_info_s { + int num_components; /* 1 = gray only, 3 = RGB, */ + /* 4 = CMYK */ + int depth; /* # of bits per pixel */ + gx_color_value max_gray; /* # of distinct gray levels -1 */ + gx_color_value max_rgb; /* # of distinct color levels -1 */ + /* (only relevant if num_comp. > 1) */ + gx_color_value dither_gray; /* size of gray ramp for halftoning */ + gx_color_value dither_rgb; /* size of color cube ditto */ + /* (only relevant if num_comp. > 1) */ +} gx_device_color_info; + +The following macros (in gxdevice.h) provide convenient shorthands for +initializing this structure for ordinary black-and-white or color devices: + +#define dci_black_and_white ... +#define dci_color(depth,maxv,dither) ... + +The idea is that a device has a certain number of gray levels (max_gray +1) +and a certain number of colors (max_rgb +1) that it can produce directly. +When Ghostscript wants to render a given RGB or CMYK color as a device +color, it first tests whether the color is a gray level. (If +num_components is 1, it converts all colors to gray levels.) If so: + + - If max_gray is large (>= 31), Ghostscript asks the device to +approximate the gray level directly. If the device returns a valid +gx_color_index, Ghostscript uses it. Otherwise, Ghostscript assumes that +the device can represent dither_gray distinct gray levels, equally spaced +along the diagonal of the color cube, and uses the two nearest ones to the +desired color for halftoning. + +If the color is not a gray level: + + - If max_rgb is large (>= 31), Ghostscript asks the device to +approximate the color directly. If the device returns a valid +gx_color_index, Ghostscript uses it. Otherwise, Ghostscript assumes that +the device can represent dither_rgb * dither_rgb * dither_rgb distinct +colors, equally spaced throughout the color cube, and uses two of the +nearest ones to the desired color for halftoning. + +Types +----- + +Here is a brief explanation of the various types that appear as parameters +or results of the drivers. + +gx_color_value (defined in gxdevice.h) + + This is the type used to represent RGB or CMYK color values. It is +currently equivalent to unsigned short. However, Ghostscript may use less +than the full range of the type to represent color values: +gx_color_value_bits is the number of bits actually used, and +gx_max_color_value is the maximum value (equal to 2^gx_max_color_value_bits +- 1). + +gx_device (defined in gxdevice.h) + + This is the device structure, as explained above. + +gs_matrix (defined in gsmatrix.h) + + This is a 2-D homogeneous coordinate transformation matrix, used by +many Ghostscript operators. + +gx_color_index (defined in gxdevice.h) + + This is meant to be whatever the driver uses to represent a device +color. For example, it might be an index in a color map, or it might be +R, G, and B values packed into a single integer. Ghostscript doesn't ever +do any computations with gx_color_index values: it gets them from +map_rgb_color or map_cmyk_color and hands them back as arguments to +several other procedures. The special value gx_no_color_index (defined as +(gx_color_index)(-1)) means "transparent" for some of the procedures. The +type definition is simply: + + typedef unsigned long gx_color_index; + +gs_param_list (defined in gsparam.h) + + This is a parameter list, which is used to read and set attributes +in a device. See the comments in gsparam.h, and the description of the +get_params and put_params procedures below, for more detail. + +gx_tile_bitmap (defined in gxbitmap.h) +gx_strip_bitmap (defined in gxbitmap.h) + + These structure types represent bitmaps to be used as a tile for +filling a region (rectangle). gx_tile_bitmap is an older type lacking shift +and rep_shift; gx_strip_bitmap has superseded it, and it should not be used +in new code. Here is a copy of the relevant part of the file: + +/* + * Structure for describing stored bitmaps. + * Bitmaps are stored bit-big-endian (i.e., the 2^7 bit of the first + * byte corresponds to x=0), as a sequence of bytes (i.e., you can't + * do word-oriented operations on them if you're on a little-endian + * platform like the Intel 80x86 or VAX). Each scan line must start on + * a (32-bit) word boundary, and hence is padded to a word boundary, + * although this should rarely be of concern, since the raster and width + * are specified individually. The first scan line corresponds to y=0 + * in whatever coordinate system is relevant. + * + * For bitmaps used as halftone tiles, we may replicate the tile in + * X and/or Y, but it is still valuable to know the true tile dimensions + * (i.e., the dimensions prior to replication). Requirements: + * width % rep_width = 0 + * height % rep_height = 0 + * + * For halftones at arbitrary angles, we provide for storing the halftone + * data as a strip that must be shifted in X for different values of Y. + * For an ordinary (non-shifted) halftone that has a repetition width of + * W and a repetition height of H, the pixel at coordinate (X,Y) + * corresponds to halftone pixel (X mod W, Y mod H), ignoring phase; + * for a shifted halftone with shift S, the pixel at (X,Y) corresponds + * to halftone pixel ((X + S * floor(Y/H)) mod W, Y mod H). Requirements: + * strip_shift < rep_width + * strip_height % rep_height = 0 + * shift = (strip_shift * (size.y / strip_height)) % rep_width + */ +typedef struct gx_strip_bitmap_s { + byte *data; + int raster; /* bytes per scan line */ + gs_int_point size; /* width, height */ + gx_bitmap_id id; + ushort rep_width, rep_height; /* true size of tile */ + ushort strip_height; + ushort strip_shift; + ushort shift; +} gx_strip_bitmap; + +******** +******** Coding conventions ******** +******** + +All the driver procedures defined below that return int results return 0 on +success, or an appropriate negative error code in the case of error +conditions. The error codes are defined in gserrors.h; they correspond +directly to the errors defined in the PostScript language reference +manuals. The most common ones for drivers are: + + gs_error_invalidfileaccess + An attempt to open a file failed. + + gs_error_ioerror + An error occurred in reading or writing a file. + + gs_error_limitcheck + An otherwise valid parameter value was too large for + the implementation. + + gs_error_rangecheck + A parameter was outside the valid range. + + gs_error_VMerror + An attempt to allocate memory failed. (If this + happens, the procedure should release all memory it + allocated before it returns.) + +If a driver does return an error, it should use the return_error +macro rather than a simple return statement, e.g., + + return_error(gs_error_VMerror); + +This macro is defined in gx.h, which is automatically included by +gdevprn.h but not by gserrors.h. + +Allocating storage +------------------ + +While most drivers (especially printer drivers) follow a very similar +template, there is one important coding convention that is not obvious from +reading the code for existing drivers: Driver procedures must not use +malloc to allocate any storage that stays around after the procedure +returns. Instead, they must use gs_malloc and gs_free, which have slightly +different calling conventions. (The prototypes for these are in +gsmemory.h, which is included in gx.h, which is included in gdevprn.h.) +This is necessary so that Ghostscript can clean up all allocated memory +before exiting, which is essential in environments that provide only +single-address-space multi-tasking (some versions of Microsoft Windows). + +char *gs_malloc(uint num_elements, uint element_size, + const char *client_name); + + Like calloc, but unlike malloc, gs_malloc takes an element count +and an element size. For structures, num_elements is 1 and element_size is +sizeof the structure; for byte arrays, num_elements is the number of bytes +and element_size is 1. Unlike calloc, gs_malloc does NOT clear the block +of storage. + + The client_name is used for tracing and debugging. It must be a +real string, not NULL. Normally it is the name of the procedure in which +the call occurs. + +void gs_free(char *data, uint num_elements, uint element_size, + const char *client_name); + + Unlike free, gs_free demands that num_elements and element_size be +supplied. It also requires a client name, like gs_malloc. + +Driver instance allocation +-------------------------- + +All driver instances allocated by Ghostscript's standard allocator must +point to a "structure descriptor" that tells the garbage collector how to +trace pointers in the structure. For drivers that are registered in the +normal way (using the makefile approach described above), no special care +is needed as long as instances are only created by calling the +gs_copydevice procedure defined in gsdevice.h. If you have a need to +define devices that are not registered in this way, you must fill in the +stype member in any dynamically allocated instances with a pointer to the +same structure descriptor used to allocate the instance. For more +information about structure descriptors, see gsmemory.h and gsstruct.h. + +******** +******** Printer drivers ******** +******** + +Printer drivers (which include drivers that write some kind of raster +file) are especially simple to implement. Of the driver procedures +defined in the next section, they only need implement two: map_rgb_color +(or map_cmyk_color) and map_color_rgb. In addition, they must implement a +print_page or print_page_copies procedure. There are a set of macros in +gdevprn.h that generate the device structure for such devices, of which +the simplest is prn_device; for an example, see gdevbj10.c. If you are +writing a printer driver, we suggest you start by reading gdevprn.h and +the subsection on "Color mapping" below; you may be able to ignore all the +rest of the driver procedures. + +The print_page procedures are defined as follows: + +int (*print_page)(P2(gx_device_printer *, FILE *)) +int (*print_page_copies)(P3(gx_device_printer *, FILE *, int)) + + This procedure must read out the rendered image from the device and +write whatever is appropriate to the file. To read back one or more scan +lines of the image, the print_page procedure must call one of the following +procedures: + + int gdev_prn_copy_scan_lines(P4(gx_device_printer *pdev, int y, byte *str, + uint size) + +For this procedure, str is where the data should be copied to, and size is +the size of the buffer starting at str. This procedure returns the number +of scan lines copied, or <0 for an error. str need not be aligned. + + int gdev_prn_get_bits(gx_device_printer *pdev, int y, byte *str, + byte **actual_data) + +This procedure reads out exactly one scan line. If the scan line is +available in the correct format already, *actual_data is set to point to it; +otherwise, the scan line is copied to the buffer starting at str, and +*actual_data is set to str. This saves a copying step most of the time. +str need not be aligned; however, if *actual_data is set to point to an +existing scan line, it will be aligned. (See the description of the +get_bits procedure below for more details.) + +In either case, each row of the image is stored in the form described +in the comment under gx_tile_bitmap above; each pixel takes the +number of bits specified as color_info.depth in the device structure, +and holds values returned by the device's map_{rgb,cmyk}_color +procedure. + +The print_page procedure can determine the number of bytes required to hold +a scan line by calling: + + uint gdev_prn_raster(P1(gx_device_printer *)) + +For a very simple concrete example, we suggest reading the code in +bit_print_page in gdevbit.c. + +If the device provides print_page, Ghostscript will call print_page the +requisite number of times to print the desired number of copies; if the +device provides print_page_copies, Ghostscript will call print_page_copies +once per page, passing it the desired number of copies. + +******** +******** Driver procedures ******** +******** + +Most of the procedures that a driver may implement are optional. If a +device doesn't supply an optional procedure , the entry in the +procedure structure may be either gx_default_, e.g. +gx_default_tile_rectangle, or NULL or 0. (The device procedure must also +call the gx_default_ procedure if it doesn't implement the function for +particular values of the arguments.) Since C compilers supply 0 as the +value for omitted structure elements, this convention means that +statically initialized procedure structures will continue to work even if +new (optional) members are added. + +Life cycle +---------- + +A device instance start out life in a closed state. In this state, no +output operations will occur. Only the following procedures may be called: + open_device + get_initial_matrix + get_params + put_params + get_hardware_params + +When setdevice installs a device instance in the graphics state, it checks +whether the instance is closed or open. If the instance is closed, +setdevice calls the open routine, and then sets the state to open. + +There is currently no user-accessible operation to close a device instance. +Device instances are only closed when they are about to be freed, which +occurs in three situations: + + - When a 'restore' occurs, if the instance was created since the +corresponding 'save'; + + - By the garbage collector, if the instance is no longer accessible; + + - When Ghostscript exits (terminates). + +Open/close/sync +--------------- + +int (*open_device)(P1(gx_device *)) [OPTIONAL] + + Open the device: do any initialization associated with making the +device instance valid. This must be done before any output to the device. +The default implementation does nothing. + +void (*get_initial_matrix)(P2(gx_device *, gs_matrix *)) [OPTIONAL] + + Construct the initial transformation matrix mapping user +coordinates (nominally 1/72" per unit) to device coordinates. The default +procedure computes this from width, height, and x/y_pixels_per_inch on the +assumption that the origin is in the upper left corner, i.e. + xx = x_pixels_per_inch/72, xy = 0, + yx = 0, yy = -y_pixels_per_inch/72, + tx = 0, ty = height. + +int (*sync_output)(P1(gx_device *)) [OPTIONAL] + + Synchronize the device. If any output to the device has been +buffered, send / write it now. Note that this may be called several times +in the process of constructing a page, so printer drivers should NOT +implement this by printing the page. The default implementation does +nothing. + +int (*output_page)(P3(gx_device *, int num_copies, int flush)) [OPTIONAL] + + Output a fully composed page to the device. The num_copies +argument is the number of copies that should be produced for a hardcopy +device. (This may be ignored if the driver has some other way to specify +the number of copies.) The flush argument is true for showpage, false for +copypage. The default definition just calls sync_output. Printer drivers +should implement this by printing and ejecting the page. + +int (*close_device)(P1(gx_device *)) [OPTIONAL] + + Close the device: release any associated resources. After this, +output to the device is no longer allowed. The default implementation +does nothing. + +Color/alpha mapping +------------------- + +A given driver normally will implement either map_rgb_color or +map_cmyk_color, but not both. Black-and-white drivers do not need to +implement either one. Note that the map_xxx_color procedures must not +return gx_no_color_index (all 1's). + +gx_color_index (*map_rgb_color)(P4(gx_device *, gx_color_value red, + gx_color_value green, gx_color_value blue)) [OPTIONAL] + + Map a RGB color to a device color. The range of legal values of +the RGB arguments is 0 to gx_max_color_value. The default algorithm uses +the map_cmyk_color procedure if the driver supplies one, otherwise returns +1 if any of the values exceeds gx_max_color_value/2, 0 otherwise. + + Ghostscript assumes that for devices that have color capability +(i.e., color_info.num_components > 1), map_rgb_color returns a color index +for a gray level (as opposed to a non-gray color) iff red = green = blue. + +gx_color_index (*map_cmyk_color)(P5(gx_device *, gx_color_value cyan, + gx_color_value magenta, gx_color_value yellow, gx_color_value black)) + [OPTIONAL] + + Map a CMYK color to a device color. The range of legal values of +the CMYK arguments is 0 to gx_max_color_value. The default algorithm +calls the map_rgb_color procedure, with suitably transformed arguments. + + Ghostscript assumes that for devices that have color capability +(i.e., color_info.num_components > 1), map_cmyk_color returns a color +index for a gray level (as opposed to a non-gray color) iff cyan = magenta += yellow. + +int (*map_color_rgb)(P3(gx_device *, gx_color_index color, + gx_color_value rgb[3])) [OPTIONAL] + + Map a device color code to RGB values. The default algorithm +returns (0 if color==0 else gx_max_color_value) for all three components. + +gx_color_index (*map_rgb_alpha_color)(P5(gx_device *, gx_color_value red, + gx_color_value green, gx_color_value blue, gx_color_value alpha)) [OPTIONAL] + + Map a RGB color and an opacity value to a device color. The range +of legal values of the RGB and alpha arguments is 0 to gx_max_color_value; +alpha = 0 means transparent, alpha = gx_max_color_value means fully +opaque. The default is to use the map_rgb_color procedure and ignore +alpha. + + Note that if a driver implements map_rgb_alpha_color, it must also +implement map_rgb_color, and must implement them in such a way that +map_rgb_alpha_color(dev, r, g, b, gx_max_color_value) returns the same +value as map_rgb_color(dev, r, g, b). + + Note that there is no map_cmyk_alpha_color procedure. CMYK +devices currently do not support variable opacity; alpha is ignored on +such devices. + +typedef enum { go_text, go_graphics } graphic_object_type; +int (*get_alpha_bits)(P4(gx_device *dev, graphic_object_type type)) [OPTIONAL] + + Return the number of alpha (opacity) bits that should be used in +rendering an object of the given type. The default value is 1; the only +values allowed are 1, 2, and 4. + +Drawing +------- + +All drawing operations use device coordinates and device color values. + +int (*fill_rectangle)(P6(gx_device *, int x, int y, + int width, int height, gx_color_index color)) + + Fill a rectangle with a color. The set of pixels filled is +{(px,py) | x <= px < x + width and y <= py < y + height}. In other words, +the point (x,y) is included in the rectangle, as are (x+w-1,y), (x,y+h-1), +and (x+w-1,y+h-1), but *not* (x+w,y), (x,y+h), or (x+w,y+h). If width <= +0 or height <= 0, fill_rectangle should return 0 without drawing anything. + + Note that fill_rectangle is the only non-optional procedure in the +driver interface. + +int (*draw_line)(P6(gx_device *, int x0, int y0, int x1, int y1, + gx_color_index color)) [OPTIONAL] + + Draw a minimum-thickness line from (x0,y0) to (x1,y1). The +precise set of points to be filled is defined as follows. First, if y1 < +y0, swap (x0,y0) and (x1,y1). Then the line includes the point (x0,y0) +but not the point (x1,y1). If x0=x1 and y0=y1, draw_line should return 0 +without drawing anything. + +Bitmap imaging +-------------- + +Bitmap (or pixmap) images are stored in memory in a nearly standard way. +The first byte corresponds to (0,0) in the image coordinate system: bits +(or polybit color values) are packed into it left-to-right. There may be +padding at the end of each scan line: the distance from one scan line to +the next is always passed as an explicit argument. + +int (*copy_mono)(P11(gx_device *, const unsigned char *data, int data_x, + int raster, gx_bitmap_id id, int x, int y, int width, int height, + gx_color_index color0, gx_color_index color1)) [OPTIONAL] + + Copy a monochrome image (similar to the PostScript image operator). +Each scan line is raster bytes wide. Copying begins at (data_x,0) and +transfers a rectangle of the given width and height to the device at device +coordinate (x,y). (If the transfer should start at some non-zero y value in +the data, the caller can adjust the data address by the appropriate multiple +of the raster.) The copying operation writes device color color0 at each +0-bit, and color1 at each 1-bit: if color0 or color1 is gx_no_color_index, +the device pixel is unaffected if the image bit is 0 or 1 respectively. If +id is different from gx_no_bitmap_id, it identifies the bitmap contents +unambiguously; a call with the same id will always have the same data, +raster, and data contents. + + This operation, with color0 = gx_no_color_index, is the workhorse +for text display in Ghostscript, so implementing it efficiently is very +important. + +int (*tile_rectangle)(P10(gx_device *, const gx_tile_bitmap *tile, + int x, int y, int width, int height, + gx_color_index color0, gx_color_index color1, + int phase_x, int phase_y)) [OPTIONAL] [OBSOLETE] + + This procedure is still supported, but has been superseded by +strip_tile_rectangle. New drivers should implement strip_tile_rectangle; if +they cannot cope with non-zero shift values, they should test for this +explicitly and call the default implementation +(gx_default_strip_tile_rectangle) if shift != 0. Clients should call +strip_tile_rectangle, not tile_rectangle. + +int (*strip_tile_rectangle)(P10(gx_device *, const gx_strip_bitmap *tile, + int x, int y, int width, int height, + gx_color_index color0, gx_color_index color1, + int phase_x, int phase_y)) [OPTIONAL] + + Tile a rectangle. Tiling consists of doing multiple copy_mono +operations to fill the rectangle with copies of the tile. The tiles are +aligned with the device coordinate system, to avoid "seams". +Specifically, the (phase_x, phase_y) point of the tile is aligned with the +origin of the device coordinate system. (Note that this is backwards from +the PostScript definition of halftone phase.) phase_x and phase_y are +guaranteed to be in the range [0..tile->width) and [0..tile->height) +respectively. + + If color0 and color1 are both gx_no_color_index, then the tile is +a color pixmap, not a bitmap: see the next section. + + This operation is the workhorse for halftone filling in Ghostscript, +so implementing it efficiently for solid tiles (i.e., where either color0 +and color1 are both gx_no_color_index, for colored halftones, or neither one +is gx_no_color_index, for monochrome halftones) is very important. + +Pixmap imaging +-------------- + +Pixmaps are just like bitmaps, except that each pixel occupies more than +one bit. All the bits for each pixel are grouped together (this is +sometimes called "chunky" or "Z" format). For copy_color, the number of +bits per pixel is given by the color_info.depth parameter in the device +structure: the legal values are 1, 2, 4, 8, 16, 24, or 32. The pixel +values are device color codes (i.e., whatever it is that map_rgb_color +returns). + +int (*copy_color)(P9(gx_device *, const unsigned char *data, int data_x, + int raster, gx_bitmap_id id, int x, int y, int width, int height)) + [OPTIONAL] + + Copy a color image with multiple bits per pixel. The raster is in +bytes, but x and width are in pixels, not bits. If id is different from +gx_no_bitmap_id, it identifies the bitmap contents unambiguously; a call +with the same id will always have the same data, raster, and data contents. + +We do not provide a separate procedure for tiling with a pixmap; instead, +tile_rectangle can also take colored tiles. This is indicated by the +color0 and color1 arguments both being gx_no_color_index. In this case, +as for copy_color, the raster and height in the "bitmap" are interpreted +as for real bitmaps, but the x and width are in pixels, not bits. + +int (*copy_alpha)(P11(gx_device *dev, const unsigned char *data, int data_x, + int raster, gx_bitmap_id id, int x, int y, int width, int height, + gx_color_index color, int depth)) [OPTIONAL] + + Fill a given region with a given color modified by an individual +alpha value for each pixel. depth, the number of bits per pixel, is +either 2 or 4, and in any case is always a value returned by a previous +call on the get_alpha_bits procedure. Note that if get_alpha_bits always +returns 1, this procedure will never be called. + +Bitmap/pixmap imaging +--------------------- + +int (*copy_rop)(P15(gx_device *dev, + const byte *sdata, int sourcex, uint sraster, gx_bitmap_id id, + const gx_color_index *scolors, + const gx_tile_bitmap *texture, const gx_color_index *tcolors, + int x, int y, int width, int height, + int phase_x, int phase_y, int command)) [OPTIONAL] + + This procedure is still supported, but has been superseded by +strip_copy_rop. New drivers should implement strip_copy_rop; if they cannot +cope with non-zero shift values in the texture, they should test for this +explicitly and call the default implementation (gx_default_strip_copy_rop) +if shift != 0. Clients should call strip_copy_rop, not copy_rop. + +int (*strip_copy_rop)(P15(gx_device *dev, + const byte *sdata, int sourcex, uint sraster, gx_bitmap_id id, + const gx_color_index *scolors, + const gx_strip_bitmap *texture, const gx_color_index *tcolors, + int x, int y, int width, int height, + int phase_x, int phase_y, int command)) [OPTIONAL] + + Combine an optional source image S (as for copy_mono or copy_color) +and an optional texture T (a tile, as for tile_rectangle) with the existing +bitmap or pixmap D held by the driver, pixel by pixel, using any 3-input +Boolean operation as modified by "transparency" flags: schematically, set D += f(D,S,T), computing f in RGB space rather than using actual device pixel +values. S and T may each (independently) be a solid color, a bitmap with +"foreground" and "background" colors, or a pixmap. This is a complex (and +currently rather slow) operation. The arguments are as follows: + + dev - the device, as for all driver procedures + + sdata, sourcex, sraster, id, scolors - specify S, see below + + texture, tcolors - specify T, see below + + x, y, width, height - as for the other copy/fill procedures + + phase_x, phase_y - part of T specification, see below + + command - see below + +S specification +............... + +As noted above, the source (S) may be a solid color, a bitmap, or a pixmap. + +If S is a solid color: + + - sdata, sourcex, sraster, and id are irrelevant. + + - scolors points to two gx_color_index values; scolors[0] = + scolors[1] = the color. + +If S is a bitmap: + + - sdata, sourcex, sraster, and id arguments are as for copy_mono or + copy_color (data, data_x, raster, id), and specify a source bitmap. + + - scolors points to two gx_color_index values; scolors[0] is the + background color (the color corresponding to 0-bits in the bitmap), + scolors[1] is the foreground color (the color corresponding to + 1-bits in the bitmap). + +If S is a pixmap: + + - sdata, sourcex, sraster, and id arguments are as for copy_mono or + copy_color (data, data_x, raster, id), and specify a source pixmap + whose depth is the same as the depth of the destination. + + - scolors is NULL. + +Note that if the source is a bitmap with background=0 and foreground=1, and +the destination is 1 bit deep, then the source can be treated as a pixmap +(scolors=NULL). + +T specification +............... + +Similar to the source, the texture (T) may be a solid color, a bitmap, or a +pixmap. + +If T is a solid color: + + - The texture pointer is irrelevant. + + - tcolors points to two gx_color_index values; tcolors[0] = + tcolors[1] = the color. + +If T is a bitmap: + + - The texture argument points to a gx_tile_bitmap, as for the + tile_rectangle procedure. Similarly, phase_x and phase_y specify + the offset of the texture relative to the device coordinate system + origin, again as for tile_rectangle. The tile is a bitmap (1 bit + per pixel). + + - tcolors points to two gx_color_index values; tcolors[0] is the + background color (the color corresponding to 0-bits in the bitmap), + tcolors[1] is the foreground color (the color corresponding to + 1-bits in the bitmap). + +If T is a pixmap: + + - The texture argument points to a gx_tile_bitmap whose depth is + the same as the depth of the destination. + + - tcolors is NULL. + +Again, if the texture is a bitmap with background=0 and foreground=1, and +the destination depth is 1, the texture bitmap can be treated as a pixmap +(tcolors=NULL). + +Note that while a source bitmap or pixmap has the same width and height as +the destination, a texture bitmap or pixmap has its own width and height +specified in the gx_tile_bitmap structure, and is replicated and/or clipped +as needed. + +f specification +............... + +Command indicates the raster operation and transparency as follows: + + bits 7-0: raster op + bit 8: 0 if source opaque, 1 if source transparent + bit 9: 0 if texture opaque, 1 if texture transparent + bits ?-10: unused, must be 0 + +The raster operation follows the Microsoft and H-P specification. It is an +8-element truth table that specifies the output value for each of the +possible 2x2x2 input values as follows: + + Bit Texture Source Destination + 7 1 1 1 + 6 1 1 0 + 5 1 0 1 + 4 1 0 0 + 3 0 1 1 + 2 0 1 0 + 1 0 0 1 + 0 0 0 0 + +Transparency affects the output in the following way. A source or texture +pixel is considered transparent if its value is all 1's (e.g., 1 for +bitmaps, 0xffffff for 24-bit RGB pixmaps) *and* the corresponding +transparency bit is set in the command. For each pixel, the result of the +Boolean operation is written into the destination iff neither the source nor +the texture pixel is transparent. (Note that the H-P RasterOp +specification, on which this is based, specifies that if the source and +texture are both all 1's and the command specifies transparent source and +opaque texture, the result *should* be written in the output. We think this +is an error in the documentation.) + +Notes +..... + +Note that copy_rop is defined to operate on pixels in RGB space, again +following the H-P and Microsoft specification. For devices that don't use +RGB (or gray-scale with black=0, white=all 1's) as their native color +representation, the implementation of copy_rop must convert to RGB or gray +space, do the operation, and convert back (or do the equivalent of this). + +Here are the copy_rop equivalents of the most important previous imaging +calls. Note that rop3_S may be replaced by any other Boolean operation. +For monobit devices, we assume that black = 1. We assume the following +declaration: + static const gx_color_index white2[2] = { 1, 1 }; + +/* For all devices: */ +(*fill_rectangle)(dev, x, y, w, h, color) ==> + + { gx_color_index colors[2]; + colors[0] = colors[1] = color; + (*dev_proc(dev, copy_rop))(dev, NULL, 0, 0, gx_no_bitmap_id, colors, + NULL, colors /*irrelevant*/, + x, y, w, h, 0, 0, rop3_S); + } + +/* For black-and-white devices only: */ +(*copy_mono)(dev, base, sourcex, sraster, id, + x, y, w, h, (gx_color_index)0, (gx_color_index)1) ==> + + (*dev_proc(dev, copy_rop))(dev, base, sourcex, sraster, id, NULL, + NULL, white2 /*irrelevant*/, + x, y, w, h, 0, 0, rop3_S); + +/* For color devices, where neither color0 nor color1 is gx_no_color_index: */ +(*copy_mono)(dev, base, sourcex, sraster, id, + x, y, w, h, color0, color1) ==> + + { gx_color_index colors[2]; + colors[0] = color0, colors[1] = color1; + (*dev_proc(dev, copy_rop))(dev, base, sourcex, sraster, id, colors, + NULL, white2 /*irrelevant*/, + x, y, w, h, 0, 0, rop3_S); + } + +/* For black-and-white devices only: */ +(*copy_mono)(dev, base, sourcex, sraster, id, + x, y, w, h, gx_no_color_index, (gx_color_index)1) ==> + + (*dev_proc(dev, copy_rop))(dev, base, sourcex, sraster, id, NULL, + NULL, white2 /*irrelevant*/, + x, y, w, h, 0, 0, + rop3_S | lop_S_transparent); + +/* For all devices: */ +(*copy_color)(dev, base, sourcex, sraster, id, + x, y, w, h) ==> [same as first copy_mono above] + +/* For black-and-white devices only: */ +(*tile_rectangle)(dev, tile, x, y, w, h, + (gx_color_index)0, (gx_color_index)1, px, py) ==> + + (*dev_proc(dev, copy_rop))(dev, NULL, 0, 0, gx_no_bitmap_id, + white2 /*irrelevant*/, + tile, NULL, + x, y, w, h, px, py, rop3_T) + +Polygons +-------- + +In addition to the lowest-level drawing operations that take integer device +coordinates and pure device colors, the driver interface includes +higher-level operations that draw polygons using fixed-point coordinates, +possibly halftoned colors, and possibly a non-default logical operation. + +The fill_* drawing operations all use the center-of-pixel rule: a pixel is +colored iff its center falls within the polygonal region being filled. If a +pixel center (X+0.5,Y+0.5) falls exactly on the boundary, the pixel is +filled iff the boundary is horizontal and the filled region is above it, or +the boundary is not horizontal and the filled region is to the right of it. + +int (*fill_trapezoid)(P10(gx_device *dev, + fixed fx0, fixed fw0, fixed fy0, + fixed fx1, fixed fw1, fixed fh, bool swap_axes, + const gx_drawing_color *pdcolor, gs_logical_operation_t lop)) [OPTIONAL] + + Fill a trapezoid whose parallel sides are parallel to a coordinate +axis. The corners are (fx0,fy0), (fx0+fw0,fy0), (fx1,fy0+fh), and +(fx1+fw1,fy0+fy). We require fw0 >= 0, fw1 >= 0, and fh >= 0; if fw0 = 0 or +fw1 = 0, the trapezoid is actually a triangle. If swap_axes is set, the +meanings of X and Y are interchanged. + +int (*fill_parallelogram)(P9(gx_device *dev, + fixed px, fixed py, fixed ax, fixed ay, fixed bx, fixed by, + const gx_drawing_color *pdcolor, gs_logical_operation_t lop)) [OPTIONAL] + + Fill a parallelogram whose corners are (px,py), (px+ax,py+ay), +(px+bx,py+by), and (px+ax+bx,py+ay+by). There are no constraints on the +values of any of the parameters, so the parallelogram may have any +orientation relative to the coordinate axes. + +int (*fill_triangle)(P9(gx_device *dev, + fixed px, fixed py, fixed ax, fixed ay, fixed bx, fixed by, + const gx_drawing_color *pdcolor, gs_logical_operation_t lop)) [OPTIONAL] + + Fill a triangle whose corners are (px,py), (px+ax,py+ay), and +(px+bx,py+by). + +int (*draw_thin_line)(P7(gx_device *dev, + fixed fx0, fixed fy0, fixed fx1, fixed fy1, + const gx_drawing_color *pdcolor, gs_logical_operation_t lop)) [OPTIONAL] + + Draw a one-pixel-wide line from (fx0,fy0) to (fx1,fy1). This +replaces the older draw_line procedure, which required integer coordinates, +a pure color, and no logical operation. + +High-level drawing +------------------ + +In addition to the low-level drawing operations described above, the driver +interface provides a set of high-level operations. Normally these will have +their default implementation, which converts the high-level operation to the +low-level ones just described; however, drivers that generate high-level +output formats such as CGM, or communicate with devices that have firmware +for higher-level operations such as polygon fills, may implement these +high-level operations directly. + +For more details, please consult the source code, specifically: + gxpaint.h - defines gx_fill_params, gx_stroke_params + gxfixed.h - defines fixed, gs_fixed_point (used by gx_*_params) + gxistate.h - defines gs_imager_state (used by gx_*_params) + gxline.h - defines gx_line_params (used by gs_imager_state) + gslparam.h - defines line cap/join values (used by gx_line_params) + gxmatrix.h - defines gs_matrix_fixed (used by gs_imager_state) + g[s,x,z]path.h - defines gx_path + g[x,z]cpath.h - defines gx_clip_path + +int (*fill_path)(P6(gx_device *dev, + const gx_imager_state *pis, gx_path *ppath, const gx_fill_params *params, + const gx_drawing_color *pdcolor, const gx_clip_path *pcpath)) [OPTIONAL] + + Fill the given path, clipped by the given clip path, according to +the given parameters, with the given color. The clip path pointer may be +NULL, meaning do not clip. + +int (*stroke_path)(P6(gx_device *dev, + const gx_imager_state *pis, gx_path *ppath, const gx_stroke_params *params, + const gx_drawing_color *pdcolor, const gx_clip_path *pcpath)) [OPTIONAL] + + Stroke the given path, clipped by the given clip path, according to +the given parameters, with the given color. The clip path pointer may be +NULL, meaning do not clip. + +int (*fill_mask)(P13(gx_device *dev, + const byte *data, int data_x, int raster, gx_bitmap_id id, + int x, int y, int width, int height, + const gx_drawing_color *pdcolor, int depth, + int command, const gx_clip_path *pcpath)) [OPTIONAL] + + Color the 1-bits in the given mask (or according to the alpha +values, if depth > 1), clipped by the given clip path, with the given color +and logical operation. The clip path pointer may be NULL, meaning do not +clip. The parameters data, ..., height are as for copy_mono; depth is as +for copy_alpha; command is as for copy_rop. + +High-level bitmap imaging +------------------------- + +Similar to the high-level interface for fill/stroke graphics, a high-level +interface exists for bitmap images. All of the procedures in this part of +the interface are optional; however, if begin_image is defined, image_data +and end_image also must be defined. + +A bitmap image is defined by a gs_image_t structure. We only summarize this +structure here. + +typedef struct gs_image_s { + int Width; /* Width of source image in pixels */ + int Height; /* Height ditto */ + gs_matrix ImageMatrix; /* transformation from 1x1 image space to */ + /* user space defined by imager CTM */ + int BitsPerComponent; + const gs_color_space *ColorSpace; + float Decode[8]; /* linear remapping of input values */ + bool Interpolate; /* smooth image if true */ + bool ImageMask; /* true = mask, false = solid image */ + bool adjust; /* expand bits if mask */ + bool CombineWithColor; /* use drawing color as RasterOp texture */ +} gs_image_t; +typedef enum { + gs_image_format_chunky = 0, + gs_image_format_component_planar = 1 +} gs_image_format_t; + +For more details, consult the source code in + gsiparam.h - defines parameters for an image + +int (*begin_image)(P9(gx_device *dev, + const gs_imager_state *pis, const gs_image_t *pim, gs_image_format_t format, + gs_int_rect *prect, const gx_drawing_color *pdcolor, + const gx_clip_path *pcpath, gs_memory_t *memory, void **pinfo)) [OPTIONAL] + + Begin the transmission of an image. Zero or more calls of +image_data will follow, and then a call of end_image. The parameters of +begin_image are as follows: + + pis - pointer to an imager state. The only relevant elements of the +imager state are the CTM (coordinate transformation matrix), the logical +operation (RasterOp/transparency), and the color rendering information. + + pim - pointer to the gs_image_t structure that defines the image +parameters. + + format - defines how pixels are represented for image_data. See the +description of image_data below. + + prect - if not NULL, defines a subrectangle of the image; only the +data for this subrectangle will be passed to image_data, and only this +subrectangle should be drawn. + + pdcolor - defines a drawing color, only needed for masks or if +CombineWithColor is true. + + pcpath - if not NULL, defines an optional clipping path. + + memory - defines the allocator to be used for allocating bookkeeping +information. + + pinfo - the implementation should return a pointer to its +bookkeeping structure here. + + begin_image is expected to allocate a structure for its bookkeeping +needs, using the allocator defined by the memory parameter, and return it in +*pinfo. begin_image should not assume that the structures in *pim, *prect, +or *pdcolor will survive the call on begin_image (except for the color space +in *pim->ColorSpace): it should copy any necessary parts of them into its +own bookkeeping structure. It may, however, assume that *pis, *pcpath, and +of course *memory will live at least until end_image is called. + +int (*image_data)(P6(gx_device *dev, + void *info, const byte **planes, int data_x, uint raster, int height)) + [OPTIONAL] + + This call provides more of the image source data: specifically, +height rows, with Width pixels supplied for each row. + + The data for each row are packed big-endian within each byte, as for +copy_color. The raster (number of bytes per row) may include some padding +at the end of each row. Note that for non-mask images, the input data may +be in any color space and may have any number of bits per component (1, 2, +4, 8, 12); currently mask images always have 1 bit per component, but in the +future, they might allow multiple bits of alpha. Note also that each call +of image_data passes complete pixels: e.g., for a chunky image with 24 bits +per pixel, each call of image_data passes 3N bytes of data (specifically, 3 +* Width * height). + + The interpretation of planes depends on the format argument of +begin_image: + + -- If format is gs_image_format_chunky, planes[0] points to data in +"chunky" format, in which the components follow each other (e.g., +RGBRGBRGB....) + + -- If format is gs_image_format_component_planar, planes[0 .. N-1] +point to data for the N components (e.g., N=3 for RGB data); each plane +contains samples for a single component, e.g., RR..., GG..., BB.... Note +that the planes are divided by component, not by bit: for example, for +24-bit RGB data, N=3, with 8-bit values in each plane of data. Someday we +may add gs_image_format_bit_planar, specifying that each plane would contain +only a single bit of the pixel value, but this is not currently implemented. + + If, as a result of this call, image_data has been called with all +the data for the (sub-)image, it returns 1; otherwise, it returns 0 or an +error code as usual. + + image_data, unlike most other driver procedures that take bitmaps as +arguments, does not require the data to be aligned in any way. + +int end_image(P3(gx_device *dev, + void *info, bool draw_last)) [OPTIONAL] + + Finish processing an image, either because all data have been +supplied or because the caller has decided to abandon this image. end_image +may be called at any time after begin_image. It should free the info +structure and any subsidiary structures. If draw_last is true, it should +finish drawing any buffered lines of the image. + + While there will almost never be more than one image enumeration in +progress -- i.e., after a begin_image, end_image will almost always be +called before the next begin_image -- driver code should not rely on this +property; in particular, it should store all information regarding the image +in the info structure, not in the driver structure. + + Note that if begin_image saves its parameters in the info structure, +it can decide on each call whether to use its own algorithms or to use the +default implementation. (It may need to call gx_default_begin/end_image +partway through.) [A later revision of this document may include an example +here.] + +Reading bits back +----------------- + +int (*get_bits)(P4(gx_device *, int y, byte *str, byte **actual_data)) + [OPTIONAL] + + Read one scan line of bits back from the device into the area +starting at str, namely, scan line y. If the bits cannot be read back +(e.g., from a printer), return -1; otherwise return 0. The contents of the +bits beyond the last valid bit in the scan line (as defined by the device +width) are unpredictable. str need not be aligned in any particular way. + + If actual_data is NULL, the bits are always returned at str. If +actual_data is not NULL, get_bits may either copy the bits to str and set +*actual_data = str, or it may leave the bits where they are and return a +pointer to them in *actual_data. In the latter case, the bits are +guaranteed to start on a 32-bit boundary and to be padded to a multiple of +32 bits; also in this case, the bits are not guaranteed to still be there +after the next call on get_bits. + +Parameters +---------- + +Devices may have an open-ended set of parameters, which are simply pairs +consisting of a name and a value. The value may be of various types: +integer (int or long), boolean, float, string, name, null, array of integer, +or array of float. For example, the Name of a device is a string; the +Margins of a device is an array of 2 floats. See gsparam.h for more +details. + +If a device has parameters other than the ones applicable to all devices +(or, in the case of printer devices, all printer devices), it must provide +get_params and put_params procedures. If your device has parameters beyond +those of a straightforward display or printer, we strongly advise using the +_get_params and _put_params procedures in an existing device (for example, +gdevcdj.c or gdevbit.c) as a model for your own code. + +int (*get_params)(P2(gx_device *dev, gs_param_list *plist)) [OPTIONAL] + + Read the parameters of the device into the parameter list at plist, +using the param_write_* macros/procedures defined in gsparam.h. + +int (*get_hardware_params)(P2(gx_device *, gs_param_list *plist)) + [OPTIONAL] + + Read the hardware-related parameters of the device into the parameter +list at plist. If a parameter involves significant delay or hardware action, +the driver should only determine the value of the parameter if it is +"requested" by the gs_param_list [param_requested(plist, key_name)]. +This function may cause the asynchronous rendering pipeline (if enabled) to +be drained, so it should be used sparingly. + +int (*put_params)(P2(gx_device *dev, gs_param_list *plist)) [OPTIONAL] + + Set the parameters of the device from the parameter list at plist, +using the param_read_* macros/procedures defined in gsparam.h. All +put_params procedures must use a "two-phase commit" algorithm; see gsparam.h +for details. + +External fonts +-------------- + +Drivers may include the ability to display text. More precisely, they may +supply a set of procedures that in turn implement some font and text +handling capabilities. These procedures are documented in another file, +xfonts.txt. The link between the two is the driver procedure that +supplies the font/text procedures: + +xfont_procs *(*get_xfont_procs)(P1(gx_device *dev)) [OPTIONAL] + + Return a structure of procedures for handling external fonts and +text display. A NULL value means that this driver doesn't provide this +capability. + +For technical reasons, a second procedure is also needed: + +gx_device *(*get_xfont_device)(P1(gx_device *dev)) [OPTIONAL] + + Return the device that implements get_xfont_procs in a non-default +way for this device, if any. Except for certain special internal devices, +this is always the device argument. + +Page devices +------------ + +gx_device *(*get_page_device)(P1(gx_device *dev)) [OPTIONAL] + + According to the Adobe specifications, some devices are "page +devices" and some are not. This procedure returns NULL if the device is +not a page device, or the device itself if it is a page device. In the +case of forwarding devices, get_page_device returns the underlying page +device (or NULL if the underlying device is not a page device). + +Miscellaneous +------------- + +int (*get_band)(P3(gx_device *dev, int y, int *band_start)) [OPTIONAL] + + If the device is a band device, this procedure stores in *band_start +the scan line (device Y coordinate) of the band that includes the given Y +coordinate, and returns the number of scan lines in the band. If the device +is not a band device, this procedure returns 0. The latter is the default +implementation. + +void (*get_clipping_box)(P2(gx_device *dev, gs_fixed_rect *pbox)) + [OPTIONAL] + + Stores in *pbox a rectangle that defines the device's clipping +region. For all but a few specialized devices, this is +((0,0),(width,height)). diff --git a/gs/examples/ridt91.eps b/gs/examples/ridt91.eps new file mode 100644 index 000000000..adea4cd66 --- /dev/null +++ b/gs/examples/ridt91.eps @@ -0,0 +1,135 @@ +%!PS-Adobe-3.0 EPSF-3.0 +%%BoundingBox: 0 0 380 200 +%%Creator: karl@cs.umb.edu from code by Roger Hersch +%%CreationDate: 8 March 1991 +%%Title: RIDT logo + +% Forget everything we do. +save + +% Make definitions in our own dictionary. +20 dict begin + +% However, this isn't quite a true EPS file, because we use the +% setscreen operator, which has device- and document-dependent effects. +% In particular, if the document is being printed in landscape mode, we +% have to rotate the cell by 90 degrees. The dvips translator sets the +% variable `isls' to be true in landscape mode, so we test for that. +% +/screen_angle + /isls where + { /isls get { 90 } { 0 } ifelse } + { 0 } + ifelse +def + + +% Increasing this number makes the screen finer (it isn't the actual +% frequency). +% +/screen_frequency 10 def + + +% If you change these numbers, change the bounding box comment above. +% This default size is approximately 134mm by 71mm. +/logo_width 380 def +/logo_height 200 def + +% Besides changing the size from the outside, you can also change the +% scale factor defined here. Of course then the bounding box won't be +% accurate. +/scalefactor 1 def + +% We need a string to hold the gray values. +/fountainstring 256 string def + +% Put values varying from 0 to 255 into the string; these will be values +% for the image operator. +0 1 255 + { + fountainstring exch dup + 255 div 180 mul cos neg 2 div + .5 add 255 mul cvi + put + } +bind for + + +% This procedure takes the bounding box of a rectangle, and images +% /fountainstring into it. +/fountain + { + /ury exch def + /urx exch def + /lly exch def + /llx exch def + gsave + llx lly translate + + % Scale to the size of the rectangle. + urx llx sub ury lly sub scale + + % The source image has one row of 256 8-bit values. + 1 256 8 + + % Map unit square to source. + [1 0 0 -256 0 256] + + % Image the string. + { fountainstring } image + grestore + } +bind def + + +% Draw a line across the bottom for visual anchoring. +% +0 0 moveto +logo_width 0 lineto stroke + + screen_frequency scalefactor div + screen_angle + { exch pop abs 1 exch sub } bind +setscreen + +scalefactor scalefactor scale + +/Palatino-Roman findfont 100 scalefont setfont + +% Determine the dimensions of our string. +/logo_words (RIDT 91) def + +0 0 moveto +logo_words true charpath flattenpath pathbbox +/word_height exch def +/word_width exch def +pop pop % llx and lly are zero. +newpath + +/x_offset logo_width word_width sub 2 div def +/y_offset 15 def + +% Draw the background pattern, which is dark at the top and light at the +% bottom. +% +0 0 logo_width logo_height fountain + +% Make the clipping path be `RIDT 91', twice. +x_offset y_offset moveto +logo_words true charpath +x_offset logo_height y_offset word_height add sub moveto +logo_words true charpath +clip +newpath + +% Paint the pattern again, this time with light at the top and dark at +% the bottom. +% +logo_width logo_height translate +180 rotate +0 0 logo_width logo_height fountain + +end +restore + +% showpage diff --git a/gs/fonts.txt b/gs/fonts.txt new file mode 100644 index 000000000..f7cdd9440 --- /dev/null +++ b/gs/fonts.txt @@ -0,0 +1,480 @@ + Copyright (C) 1990, 1995, 1996, 1997 Aladdin Enterprises. All rights reserved. + + This file is part of Aladdin Ghostscript. + + Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author + or distributor accepts any responsibility for the consequences of using it, + or for whether it serves any particular purpose or works at all, unless he + or she says so in writing. Refer to the Aladdin Ghostscript Free Public + License (the "License") for full details. + + Every copy of Aladdin Ghostscript must include a copy of the License, + normally in a plain ASCII text file named PUBLIC. The License grants you + the right to copy, modify and redistribute Aladdin Ghostscript, but only + under certain conditions described in the License. Among other things, the + License requires that the copyright notice and this notice be preserved on + all copies. + +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +This file, fonts.txt, describes the fonts and font facilities supplied +with Ghostscript. + +For an overview of Ghostscript and a list of the documentation files, see +README. + +About Ghostscript fonts +======================= + +Most of the font files supplied with Ghostscript have a .pfb extension; a +few have a .pfa or .gsf extension. Each file defines one (transformable) +font specified in outline form. They are ordinary Type 1 PostScript outline +fonts, and can be given to any PostScript language interpreter. Files with +.pfa or .pfb extension are also compatible with Adobe Type Manager and with +tools that don't include a full PostScript language interpreter; files with +.gsf extension are not compatible with ATM or other tools. Starting with +release 4.0, Ghostscript configurations compiled with the `ttfont' option +can also use TrueType fonts (.ttf). + +The only other font-related file that Ghostscript needs for proper operation +is a file called Fontmap. This file maps font names (such as /Times-Roman) +to font file names (such as n021003l.pfb) or aliases (such as +NimbusNo9L-Regu). + +The free fonts supplied with Ghostscript fall into three groups: + + - 35 basic PostScript fonts (Times, Helvetica, Courier, Symbol, + etc.) These are commercial-quality Type 1 fonts. See the file + `Fontmap' for the complete list. + + - Fonts derived from the public domain Hershey fonts, with + improvements (such as adding accented characters) by Thomas Wolff. + These are quite different from traditional printer or display fonts; + the file `hershey.txt' describes them in more detail. + + - A few miscellaneous fonts including Cyrillic and kana fonts. + +The 35 basic fonts are normally distributed in a file called +`ghostscript-fonts-std-N.NN.tar.gz', the rest in a file called +`ghostscript-fonts-other-N.NN.fonts.tar.gz'. + +The file gs_fonts.ps, which is loaded as part of Ghostscript initialization, +arranges to load fonts on demand using the information from Fontmap. If you +want to preload all of the known fonts, invoke the procedure + loadallfonts +This is not done by default, since the fonts occupy about 50K each and there +are a lot of them. + +If you want to try out the fonts, prfont.ps contains code for printing a +sampler. Load this program, by including it in the gs command line or by +invoking + (prfont.ps) run +and then to produce a sampler of a particular font, invoke + /fontName DoFont +e.g. + /Times-Roman DoFont + +About the Kanji fonts +--------------------- + +Mr. Tetsurou Tanaka of the Department of Engineering, University of Tokyo, +has created a set of free Kanji fonts that is freely available on the +Internet for anonymous FTP from moe.ipl.t.u-tokyo.ac.jp:/Font and is +distributed with Ghostscript. Anyone can use these fonts as they are or +with some format translation, and redistribute them without reporting. If +you redistribute them, you must inform the recipient that he can get the +original from the abovementioned FTP site, so that he could get the newest +version later. + +The fonts include a README file in Japanese. Here is some English +documentation supplied by Mr. Kiyotaka Sakai, also of the University of +Tokyo. + + The following four fonts are different styles of the same characters + (JISX208). These fonts also needs wadalab-sym.tar.Z in common. + + wadalab-mincho-0-8.tar.gz + wadalab-mincho-0-12.6.tar.gz + wadalab-gothic-0-13.5.tar.gz + wadalab-maru-0-8.4.tar.gz + + And the following two fonts are the other different styles of the same + characters(JISX0212). + + wadalab-mincho-1-8.tar.gz + wadalab-maru-1-8.tar.gz + + These fonts are postscript(type1) fonts. You can convert them to + Metafont, Type1(PFA) font, TeX font(for japanese TeX), BDF font, + Shotaikurabu font by using wftomf.c, wftopfa.c, wftodm.c, bdfmerge.c + wftovf.c in tools directory. + +In order to conform to MS-DOS naming restrictions, we have renamed the +original font files as follows: + Name Original name + ---- ------------- + got013-5.taz wadalab-gothic-0-13.5.tar.gz + mar08-4.taz wadalab-maru-0-8.4.tar.gz + mar18.taz wadalab-maru-1-8.tar.gz + min012-6.taz wadalab-mincho-0-12.6.tar.gz + min08-4.taz wadalab-mincho-0-8.4.tar.gz + min18.taz wadalab-mincho-1-8.tar.gz + sym-4.taz wadalab-sym.4.tar.gz + +Platform fonts +============== + +Starting with release 2.6.1, Ghostscript uses whatever font technology is +provided by the system on which it runs, by using the system's API for +displaying text. On MS Windows this may be TrueType, or it may be ATM; +Ghostscript neither knows nor cares. + +The PostScript language specifies that fonts are data structures with +particular contents (e.g., they include a bounding box for the font, an +Encoding vector for specifying the character set, etc.), and it is fairly +common for PostScript files to make use of this fact; also, characters can +be used as clipping regions, and can be arbitrarily rotated, skewed, +expanded/condensed, etc. algorithmically. Most of this information is +available in one form or another from the underlying graphics system, but +one crucial piece is not: the actual scalable outlines of the characters, +which Ghostscript needs in order to implement clipping with character +shapes and to implement arbitrarily transformed characters. Consequently, + + Ghostscript needs the scalable outlines of any font mentioned + in a document, and will load them from the disk (.PFA, .PFB, or + .GSF file) in the usual way, even if it uses the platform's font + machinery for displaying the characters. + +To make matters worse, platforms use different names for their standard +fonts. For example, the Times Roman font, for which PostScript files use +the name "Times-Roman", may be known as "Times-Roman", "Times Roman", "Tms +Rmn", "Times New Roman", or "TimesNewRoman". The name may even be +completely different: the usual Helvetica-equivalent TrueType font is +called "Arial". Now, it is possible to cope with this situation by +introducing aliases in Fontmap, but there are two reasons why the +current Ghostscript release does not do this: + + 1) Naming in different systems is so unstandardized that there +does not seem to be a small set of alternative names that is likely to +cover most of the situations. All 5 of the above names for Times Roman +have been seen in Windows and OS/2 environments, depending on system +version, TrueType vs. ATM, and other unknown factors. + + 2) Each alias takes up a substantial amount of space (several +hundred bytes) at run time. If each of the standard 35 fonts has 3 +additional aliases, this might amount to 50K of wasted space. This is a +lot on a PC, although running under Windows in enhanced mode, it might not +be a problem. + +If you don't seem to be getting nice characters on the screen under MS +Windows, you can try adding aliases to the Fontmap, according to the +documentation found there. + +Adding your own fonts +===================== + +Ghostscript can use any Type 0, Type 1, Type 3, Type 4, or Type 42 font that +is acceptable to other PostScript language interpreters or to ATM, including +MultiMaster fonts. Starting with release 4.0, Ghostscript can also use +TrueType fonts (if Ghostscript was compiled with the `ttfont' option). +Ghostscript also provides a way to construct a (low-quality) Type 1 font +from a bitmap font in BDF format, which is a popular format in the Unix +world. + +If you want to add fonts of your own, you must edit Fontmap to include an +entry for your new font at the end. The format for entries is documented +in the Fontmap file. Since later entries in Fontmap override earlier +entries, any fonts you add will supersede the corresponding fonts supplied +with Ghostscript. + +In the PC world, Type 1 fonts are customarily given names ending in .PFA or +.PFB. Ghostscript can use these directly; you just need to make the entry +in Fontmap. If you are going to use a commercial Type 1 font (such as fonts +obtained in conjunction with Adobe Type Manager) with Ghostscript, please +read carefully the license that accompanies the font; Aladdin Enterprises +takes no responsibility for any possible violations of such licenses. The +same applies to TrueType fonts, whose names customarily end in .TTF. + +Converting BDF fonts +-------------------- + +If you want to convert a BDF file to a scalable outline, use the program +bdftops.ps (and invoking shell script bdftops.bat or bdftops). Run the +shell command + bdftops [ ...] + [] [] +e.g., + bdftops pzdr.bdf ZapfDingbats.afm pzdr.gsf + ZapfDingbats 4100000 1000000.1.41 +(Obviously, you would enter this all on one line; the example is split so +it will fit on the page.) Then make an entry for the .gsf file in Fontmap +as described above. See the end of this document for more detail. + +For developers only +=================== + +The rest of this document is very unlikely to be of value to ordinary +users. + +Contents of fonts +----------------- + +As noted above, Ghostscript accepts fonts in the same formats as PostScript +interpreters. Type 0, 1, and 3 fonts are documented in the PostScript +Language Reference Manual (Second Edition); detailed documentation for Type +1 fonts appears in a separate Adobe book. Type 42 (encapsulated TrueType) +fonts are documented in an Adobe supplement; the TrueType format is +documented in publications available from Apple and Microsoft. Type 4 fonts +are not documented anywhere; they are essentially Type 1 fonts with a +BuildChar or BuildGlyph procedure. + +Precompiling fonts +------------------ + +You can compile any Type 1 font into C and link it into the Ghostscript +executable. (Type 1 fonts include any font whose name ends with .pfa or +.pfb, and it also includes all the Ghostscript .gsf fonts except for the +Hershey fonts.) This doesn't have any effect on rendering speed, but it +eliminates the time for loading the font dynamically, which may make a big +difference in total rendering time, especially for multi-page documents. +Fonts that have been precompiled and linked in this way do not need to +appear in the Fontmap, although if they do appear there, no harm is done. + +The utility for precompiling fonts is called font2c. Note that font2c is +a PostScript language program, so you must have Ghostscript already +running to be able to run font2c; you must also have entries in the +Fontmap for the fonts you want to compile. For example, to precompile +the Times-Italic font, + font2c Times-Italic ptmri.c +where the first argument is the font name and the second is the name of +the .c file. You can use any file name you want, as long as it ends in +.c. It doesn't have to be limited to 8 characters, unless your operating +system requires this. We suggest that you use names xxxx.c, where +xxxx.gsf or xxxx.pfa is the name of the font file in the Fontmap file, +just so you don't have to keep track of another set of names. (If you are +running on a VMS platform, or another platform where the C compiler has a +limit on the length of identifiers, you must do something slightly more +complicated; see the section 'Platforms with identifier length limits' +below. Also, on VMS, you must put quotes "" around the font name so that +the VMS command processor doesn't convert the name to lower case.) + +For VMS environments, see the directions in the file make.txt, and ignore +the rest of this section. + +Note that ncrr.c, ptmr.c, etc. are not supplied with the Ghostscript +fileset, since they are quite large and can easily be recreated using the +font2c program as described above. There is a makefile called cfonts.mak +that will run font2c on all the fonts supplied with Ghostscript. Invoke it +with + make -f cfonts.mak +On some systems, you may have to omit the space following the -f, i.e., + make -fcfonts.mak + +Besides running font2c, you must arrange things so that the fonts will be +compiled, and linked into the executable. To do this, add the compiled +fonts "feature" to your platform-specific makefile. On MS-DOS systems, you +edit tc.mak, bc.mak, bcwin.mak, msc.mak, or watc.mak; on Unix systems, you +edit ansihead.mak, cc-head.mak, or gcc-head.mak, and then execute tar_cat. +Find the definition of the FEATURE_DEVS macro in the makefile, e.g., + FEATURE_DEVS=level2.dev pdf.dev +and add ccfonts.dev, e.g., + FEATURE_DEVS=level2.dev pdf.dev ccfonts.dev + +Next, you must add the specific fonts to the generic makefile. On MS-DOS +systems, you edit gs.mak; on Unix systems, you edit makefile. The makefile +already has rules for the standard 35 fonts supplied with Ghostscript. +Find the line in the relevant makefile that says + #ccfonts1_= +Remove the # mark from this line, and from all the following lines down to +and including the one that says + #ccfonts9= +This is all you need to do for the standard fonts. The next couple of +paragraphs describe how to compile in other fonts, such as the Utopia or +Kana fonts or your own fonts. + +Suppose you want to compile the Kana fonts into the executable. First, +pick one of ccfonts10 through 15 as the place you will do this, say +ccfonts10. Add your compiled font file names, e.g., + ccfonts10_=fhirw.$(OBJ) +If the line gets too long, use another line of the same form, e.g., + ccfonts11_=fkarw.$(OBJ) +Just below this, you will find a line that says + ccfonts10_= +Add your own fonts to the end of this line, e.g., + ccfonts10=Calligraphic_Hiragana +Notice that you must replace `-' by `_' in the font name. Again, if +the line gets too long, add another line of the same form, e.g., + ccfonts10=Calligraphic_Hiragana + ccfonts11=Calligraphic_Katakana + +After all the lines of this form, add a pair of lines to compile each font, +separating these entries from the ccfonts* lines and from each other by a +blank line. In our example: + + fhirw.$(OBJ): fhirw.c $(CCFONT) + $(CCCF) fhirw.c + + fkarw.$(OBJ): fkarw.c $(CCFONT) + $(CCCF) fkarw.c + +Finally, run `make'. The executable will now include the fonts you added. +They will be present in FontDirectory when Ghostscript starts up. + +Precompiling fonts on platforms with identifier length limits +------------------------------------------------------------- + +On some platforms, the C compiler and/or linker have a limit on the number +of significant characters in an identifier. On such platforms, you must +do a little extra work. + +Let N be the maximum number of significant characters in an identifier +(typically 31). For each font whose name is longer than N-5 characters, +pick an arbitrary identifier that we will call the "short name". This can +be any string you want, as long as it contains only letters, digits, and +underscores; is no longer than N-5 characters; and is not the same as any +other font name or short name. A good choice for this would be to use the +name of the C file. (There is no harm in doing this for fonts with names +shorter than N-5 characters, it's just not necessary.) + +You must do two different things for fonts that require a short name. +First, you must supply the short name as a third argument to the font2c +program. For example, to compile NewCenturySchlbk-BoldItalic using the +short name "pncbi", + font2c NewCenturySchlbk-BoldItalic pncbi.c pncbi +Then when you add the font to the gsaddmod line in the makefile, use the +short name, not the actual font name, e.g., + ccfonts2=pncbi +instead of + ccfonts2=NewCenturySchlbk_BoldItalic +Everything else is as described above. + +This procedure doesn't change the name of the font in the Fontmap, or as +seen from within Ghostscript; it's just a workaround for a limitation of +some older compilers. + +Font names and unique IDs +------------------------- + +If you create your own fonts, and are only going to use them within your own +organization, you should use UniqueID values between 4000000 and 4999999 as +described just below; if you are going to distribute fonts, call Adobe and +get them to assign you some UniqueIDs and also an XUID for your +organization. The current (September 1993) UniqueID Coordinator is Terry +O'Donnell; he is very helpful and will probably be able to assign you the +numbers over the phone. + +The suggested temporary UniqueID for a font looks like: + 4TTWVE0 +where + TT is a two-digit number representing the typeface, + W represents the weight (normal, bold, ...), + V represents the variant (normal, italic, oblique, ...), and + E represents the expansion (normal, condensed, ...). +This scheme will not work forever. As soon there are more 99 typefaces, or +more than 9 weights or variants, we will have to do something else. But it +suffices for the near future. + +XUIDs are a Level 2 PostScript feature that serves the same function as +UniqueIDs, but is not limited to a single 24-bit integer. The bdftops +program creates XUIDs of the form [-X- 0 -U-] where -X- is the organization +XUID and -U- is the UniqueID. (Aladdin Enterprises' organization XUID is +107; do not use this for your own fonts that you distribute.) + +Ghostscript fonts are stored on files, and the file names must comply +with the 8-character limit imposed by MS-DOS and other operating systems. +We therefore construct the filename for a font in a way somewhat similar to +the construction for temporary UniqueIDs: + FTTWVVVE.gsf +where F is the foundry, TT a two-letter abbreviation for the typeface, and +W, V, and E the weight, variant, and expansion. Since a font can have +multiple variants, we allocate three letters to that (for example, Lucida +Regular Sans Typewriter Italic). If a font has four variants, you're on +your own. If a font does have multiple variants, it's best to add the +expansion letter `r', so that it is clear which letters are variants and +which the expansion. + +This scheme is very close to the one proposed in `Filenames for fonts', +published in the first 1990 issue of TUGboat (the journal of the TeX Users +Group). + +In the following tables, we made no attempt to be exhaustive. Instead, we +have simply allocated entries for those things that we needed for the fonts +that we are actually distributing. + +foundries: +---------- +b = Bitstream +f = freely distributable/public domain fonts +n = IBM +p = Adobe (`p' for PostScript) +u = URW[++] + +typefaces: +id name filename prefix +---------------------------------------------------------------- +08 = Avant Garde = pag (Adobe) +11 = Bookman = pbk (Adobe) +01 = CharterBT = bch (Bitstream) +02 = Courier = ncr (IBM) +03 = Helvetica = phv (Adobe) +04 = New Century Schoolbook = pnc (Adobe) +09 = Palatino = ppl (Adobe) +05 = Symbol = psy (Adobe) +06 = Times = ptm (Adobe) +-- Utopia = put (Adobe) +07 = Zapf Chancery = zc (public domain) +10 = Zapf Dingbats = pzd (Adobe) +12 = public domain Cyrillic = fcy (public domain) +13 = Kevin Hartig Hiragana = fhi (shareware) +14 = Kevin Hartig Katakana = fka (shareware) + +90 = Hershey Gothic English = hrge +91 = Hershey Gothic Italian = hrit +92 = Hershey Gothic German = hrgr +93 = Hershey Greek = hrgk +94 = Hershey Plain = hrpl +95 = Hershey Script = hrsc +96 = Hershey Symbol = hrsy + +weights: +-------- +0 = normal = r +1 = bold = b +2 = book = k +3 = demi = d +4 = light = l + +variants: +--------- +0 = normal = r (omitted when the weight is normal) +1 = italic = i +2 = oblique = o +3 = script/handwritten/swash = w + +expansions: +----------- +0 = normal = r (omitted when the weight and variant + are normal) +1 = narrow = n + +Converting BDF fonts to .gsf (Type 1) fonts +------------------------------------------- + +The bdftops conversion program takes the following arguments: + + bdftops xx.bdf [yy1.afm ...] zz.gsf fontname UniqueID [XUID] + [encodingname] + +These arguments have the following meanings: + + xx.bdf - the input bitmap file, a BDF file + yy*.afm - the AFM files giving the metrics (optional) + zz.gsf - the output file + fontname - the font name + UniqueID - the UniqueID, as described above + XUID - the XUID, in the form n1.n2.n3... (optional) + encodingname - the encoding for the font (optional) + +Currently, the defined encodings are StandardEncoding, ISOLatin1Encoding, +SymbolEncoding, and DingbatsEncoding. If the encoding is omitted, +StandardEncoding is assumed. diff --git a/gs/gdevpfax.c b/gs/gdevpfax.c new file mode 100644 index 000000000..b3b084489 --- /dev/null +++ b/gs/gdevpfax.c @@ -0,0 +1,213 @@ +/* Copyright (C) 1993, 1994 Aladdin Enterprises. All rights reserved. + + This file is part of Aladdin Ghostscript. + + Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author + or distributor accepts any responsibility for the consequences of using it, + or for whether it serves any particular purpose or works at all, unless he + or she says so in writing. Refer to the Aladdin Ghostscript Free Public + License (the "License") for full details. + + Every copy of Aladdin Ghostscript must include a copy of the License, + normally in a plain ASCII text file named PUBLIC. The License grants you + the right to copy, modify and redistribute Aladdin Ghostscript, but only + under certain conditions described in the License. Among other things, the + License requires that the copyright notice and this notice be preserved on + all copies. +*/ + +/* gdevpfax.c */ +/* Generic PostScript system compatible fax support */ +#include "gdevprn.h" +#include "gsparam.h" +#include "gxiodev.h" + +/* This code defines a %Fax% IODevice, and also provides decoding for */ +/* the FaxOptions dictionary in a page device. */ +/* It is still fragmentary and incomplete. */ + +#define limited_string(len)\ + struct { byte data[len]; uint size; } + +/* ------ %Fax% implementation ------ */ + +/* Define the structure for the Fax IODevice state. */ +typedef struct gx_io_device_fax_s { + gx_io_device_common; + bool ActivityReport; + bool DefaultCaptionOn; + bool DefaultConfirmOn; + bool DefaultCoversOn; + int DefaultResolution; + int DefaultRetryCount; + int DefaultRetryInterval; + int DialToneWaitPeriod; + limited_string(20) ID; + long MaxFaxBuffer; + limited_string(32) PostScriptPassword; + bool ReceivePostScript; + int Rings; + int ServiceEnable; + int Speaker; + const char *StorageDevice; + bool WaitForDialTone; +} gx_io_device_fax; + +private iodev_proc_get_params(fax_get_params); +private iodev_proc_put_params(fax_put_params); +const gx_io_device_fax gs_iodev_Fax = + { "%Fax%", "Parameters", + { iodev_no_init, iodev_no_open_device, iodev_no_open_file, + iodev_os_fopen, iodev_os_fclose, + iodev_no_delete_file, iodev_no_rename_file, iodev_no_file_status, + iodev_no_enumerate_files, NULL, NULL, + fax_get_params, fax_put_params + }, + false, /* A */ + true, true, true, 1, 0, 3, 1, /* D */ + { { 0 }, 0 }, /* I */ + 350000, /* M */ + { { 0 }, 0 }, /* P */ + true, 4 /* ? */, /* R */ + 3, 1, "%ram%", /* S */ + true /* W */ + }; + +/* The following code is shared between get and put parameters. */ +typedef struct fax_strings_s { + gs_param_string id, pwd, sd; +} fax_strings; +private int +fax_xfer_params(register gx_io_device_fax *faxdev, gs_param_list *plist, + fax_strings *pfs) +{ int code; + pfs->id.data = faxdev->ID.data, pfs->id.size = faxdev->ID.size, + pfs->id.persistent = false; + pfs->pwd.data = faxdev->PostScriptPassword.data, + pfs->pwd.size = faxdev->PostScriptPassword.size, + pfs->pwd.persistent = false; + pfs->sd.data = (const byte *)faxdev->StorageDevice, + pfs->sd.size = strlen(pfs->sd.data), + pfs->sd.persistent = true; + if ( (code = param_bool_param(plist, "ActivityReport", &faxdev->ActivityReport)) < 0 || + (code = param_bool_param(plist, "DefaultCaptionOn", &faxdev->DefaultCaptionOn)) < 0 || + (code = param_bool_param(plist, "DefaultConfirmOn", &faxdev->DefaultConfirmOn)) < 0 || + (code = param_bool_param(plist, "DefaultCoversOn", &faxdev->DefaultCoversOn)) < 0 || + (code = param_int_param(plist, "DefaultResolution", &faxdev->DefaultResolution)) < 0 || + (code = param_int_param(plist, "DefaultRetryCount", &faxdev->DefaultRetryCount)) < 0 || + (code = param_int_param(plist, "DefaultRetryInterval", &faxdev->DefaultRetryInterval)) < 0 || + (code = param_int_param(plist, "DialToneWaitPeriod", &faxdev->DialToneWaitPeriod)) < 0 || + (code = param_string_param(plist, "ID", &pfs->id)) < 0 || + (code = param_long_param(plist, "MaxFaxBuffer", &faxdev->MaxFaxBuffer)) < 0 || + (code = param_string_param(plist, "PostScriptPassword", &pfs->pwd)) < 0 || + (code = param_bool_param(plist, "ReceivePostScript", &faxdev->ReceivePostScript)) < 0 || + (code = param_int_param(plist, "Rings", &faxdev->Rings)) < 0 || + (code = param_int_param(plist, "ServiceEnable", &faxdev->ServiceEnable)) < 0 || + (code = param_int_param(plist, "Speaker", &faxdev->Speaker)) < 0 || + (code = param_string_param(plist, "StorageDevice", &pfs->sd)) < 0 || + (code = param_bool_param(plist, "WaitForDialTone", &faxdev->WaitForDialTone)) + ) + return code; + return 0; +} + +#define faxdev ((gx_io_device_fax *)iodev) + +/* Get parameters from device. */ +private int +fax_get_params(gx_io_device *iodev, gs_param_list *plist) +{ fax_strings fs; + return fax_xfer_params(faxdev, plist, &fs); +} + +/* Put parameters to device. */ +private int +fax_put_params(gx_io_device *iodev, gs_param_list *plist) +{ gx_io_device_fax tdev; + fax_strings fs; + int code; + gx_io_device *sdev; + tdev = *faxdev; + code = fax_xfer_params(&tdev, plist, &fs); + if ( code < 0 ) + return code; +#define between(v, lo, hi) (tdev.v >= (lo) && tdev.v <= (hi)) + if ( !( between(DefaultResolution, 0, 1) && + between(DefaultRetryCount, 0, 100) && + between(DefaultRetryInterval, 1, 60) && + between(DialToneWaitPeriod, 1, 10) && + fs.id.size > 20 || + tdev.MaxFaxBuffer >= 350000 && + fs.pwd.size > 32 || + between(Rings, 1, 30) && + between(ServiceEnable, 0, 3) && + between(Speaker, 0, 2) && + (sdev = gs_findiodevice(fs.sd.data, fs.sd.size)) != 0 + ) + ) + return_error(gs_error_rangecheck); +#undef between + memcpy(tdev.ID.data, fs.id.data, fs.id.size); + tdev.ID.size = fs.id.size; + memcpy(tdev.PostScriptPassword.data, fs.pwd.data, fs.pwd.size); + tdev.PostScriptPassword.size = fs.pwd.size; + tdev.StorageDevice = sdev->dname; + *faxdev = tdev; + return 0; +} + +/* ------ FaxOptions decoding ------ */ + +typedef struct fax_options_s fax_options; +typedef struct fax_custom_params_s fax_custom_params; +typedef int (*fax_custom_proc)(P2(const fax_options *, const fax_custom_params *)); +struct fax_options_s { + gs_param_string CalleePhone; + limited_string(20) CallerID; + gs_param_string CallerPhone; + fax_custom_proc Confirmation; + struct { fax_options *options; uint size; } Copies; + /* CoverNote */ + fax_custom_proc CoverSheet; + bool CoverSheetOnly; + limited_string(100) DialCallee; + bool ErrorCorrect; + int FaxType; + int MailingTime[6]; + int MaxRetries; + int nPages; + fax_custom_proc PageCaption; + limited_string(32) PostScriptPassword; + void *ProcInfo; + gs_param_string RecipientID; + gs_param_string RecipientMailStop; + gs_param_string RecipientName; + gs_param_string RecipientOrg; + gs_param_string RecipientPhone; + gs_param_string Regarding; + int RetryInterval; + bool RevertToRaster; + gs_param_string SenderID; + gs_param_string SenderMailStop; + gs_param_string SenderName; + gs_param_string SenderOrg; + gs_param_string SenderPhone; + bool TrimWhite; +}; + +/* ------ Custom fax procedure parameters ------ */ + +struct fax_custom_params_s { + limited_string(20) CalleeID; + int CallLength; + int CoverType; + int CurrentPageNo; + /* ErrorArray */ + int ErrorIndex; + bool IncludesFinalPage; + int InitialPage, LimitPage; + int NumberOfCalls; + int PagesSent; + bool SendPostScript; + int TimeSent[6]; +}; diff --git a/gs/helpers.txt b/gs/helpers.txt new file mode 100644 index 000000000..4faf8c885 --- /dev/null +++ b/gs/helpers.txt @@ -0,0 +1,170 @@ + Copyright (C) 1993, 1994, 1997 Aladdin Enterprises. All rights reserved. + + This file is part of Aladdin Ghostscript. + + Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author + or distributor accepts any responsibility for the consequences of using it, + or for whether it serves any particular purpose or works at all, unless he + or she says so in writing. Refer to the Aladdin Ghostscript Free Public + License (the "License") for full details. + + Every copy of Aladdin Ghostscript must include a copy of the License, + normally in a plain ASCII text file named PUBLIC. The License grants you + the right to copy, modify and redistribute Aladdin Ghostscript, but only + under certain conditions described in the License. Among other things, the + License requires that the copyright notice and this notice be preserved on + all copies. + +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +This file, helpers.txt, is a note of thanks to all the people who +have helped in the development of Ghostscript. + +For an overview of Ghostscript and a list of the documentation files, see +README. + +Major contributors +------------------ + +Special thanks are due to Russell Lang, for the GSview for Windows program, +for contributing most of the code for the Microsoft Windows and OS/2 +environments, and for the original version of the PNG driver; to Tim +Theisen, for the Ghostview program for X Windows and for major contributions +to the development and support of code for the X Windows environment; and to +the Independent JPEG Group, for creating the JPEG DCT library that +Ghostscript uses. + +Other contributors +------------------ + +Aladdin Enterprises would like to acknowledge and thank the following +other people (in alphabetical order) who have contributed +substantially to improving Ghostscript since its inception in 1986: + + Hitoshi Aida (for help with the SunView driver), + Pierre Arnaud (for bug reports and fixes), + William Bader (for several drivers and bug reports), + Alan Barclay (for the RGB TIFF drivers), + Karl Berry and Kathy Hargreaves (for helping create the fonts + originally distributed with Ghostscript), + James W. Birdsall (for the IBM ProPrinter driver), + Andrew Birrell (for a challenging application), + Jan Bottorff (for help with the Microsoft Windows driver), + Tom Brosnan (for the Desqview/X port), + Philip Brown (for the LaserJet IIID duplex additions), + George Cameron (for DeskJet 500C and 550C drivers), + Maurice Castro (a collaborator of Russell Lang's), + Phil Conrad (for originating the PPM utilities and the PCX and + GIF drivers, and lots of bug reports), + Michel Dagenais (for major help with the DeskJet driver), + John Desrosiers (for the final work on the Microsoft Visual C++ + makefiles), + Jim Dunham (for the OpenVMS makefile), + Gershon Elber (for improvements to the BGI driver), + Fritz Elfert (for the Unix file enumeration routine), + Mike Ferrara (for help with the LaserJet driver and HP-UX), + Andy Fyfe (for the BJ200 driver modifications to the BJ10e driver, + and for the 3B1 driver), + Tim Gallivan (for a port to the Atari ST), + J Greely (for help with the PostScript-to-ASCII filter), + Paul Haeberli (for the ideas behind better color selection + and trapezoid fill algorithms), + Karl Hakimian (for the Tek 4693d drivers), + Richard Hesketh (for GSPreview), + Gunther Hess (for the unified inkjet printer driver), + Thomas Hiller (for the Trident TVGA driver), + Frans van Hoesel (for improvements to the DeskJet driver), + Berthold K. P. Horn (for a better spot halftone screen), + Earl Johnson (for the motivation for the ps2ascii utility), + Ray Johnston (for a first draft of FAKEFONTS and EPSF recognition, + and for many small bug fixes), + Pete Kaiser (for beta testing, several versions of the OSF/1 + font map, and an HTML version of the documentation), + Norio Katayama (for the first implementation of composite fonts, + and for testing and helping debug the later implementation), + Alfred Kayser (for a DeskJet 500C driver and beta testing), + Richard Keeney (for help with the SunView driver), + Markku Koppinen (for a better circle-to-curve algorithm), + Eleftherios Koutsofios (for help with the SunView driver), + Tom Lane (for major help with adapting and integrating the IJG code), + Sam Leffler (for the original TIFF G3 driver, and for finding + some subtle bugs in the CCITTFaxEncode filter), + Jonathan Luckey (for the hi-res Imagewriter drivers), + Ian MacPhedran (for a sixel driver), + Jim Mayer (for help with the DeskJet and LaserJet drivers), + Paul McJones (for help in identifying a variety of bugs), + William L. Menninger (for a version of the PC display state + save/restore code), + Richard Mlynarik (for a nearly overwhelming volume of + improvements and suggestions), + Ulrich Mueller (for the LN03 driver), + Daniel Newman (for major help with VMS and the CCITT Fax filters), + Bjorn S. Nilsson (for major help with VMS, including many updates + of the DCL build scripts and creating the VMS help file), + Roque Donizete de Oliveira (for testing and debugging, + and a 'man' page), + Gerbert Orasche (for some minor bug fixes), + Marc Paquette (for the original PaintJet driver), + Hal Peterson (for major help with BDF fonts), + Andy Piper (for the first draft of the WindowID feature), + Martin Pirker (for fixing two major problems with TrueType fonts), + Tom Quinn (for the Canon LBP-8II driver), + Matthias Rabe (for work on an OS/2 port), + Jerry Roylance (for help with statusdict), + Dave St. Clair (for the color Epson/Fujitsu driver), + Jan Sanislo (for two subtle but vital fixes), + Clemens Schrimpe (for help with accented characters), + Scott Schwartz (for improvements to gslp.ps), + Mike Smolenski (for the Sony drivers), + Snoopy (for major help with Hershey fonts, and many other + contributions), + Karsten Spang (for the Tektronix 4695/4696 driver), + Andreas Stolcke (for help with the SunView driver), + Hans-Gerd Straeter (for finding some obscure bugs), + Christoph Strozyk (for getting the URW fonts made available), + Michael Sweet (for help with the high-density Epson driver), + Guenther Thomsen (for the mid-density Epson driver), + Gregg Townsend (for the low-resolution dithering algorithm), + Christian Tschudin (for fixes to the virtual memory package, + and for the original BubbleJet driver), + Stephen Turnbull (for help with the DesqView/X port), + Jos Vos (for the original PBM/PGM/PPM driver, and for much + beta testing), + Renze de Waal (for an improvement to the "SAFER" feature), + Allan Wax (for the AT&T 6300 modification to the BGI driver), + Mark Wedel (for the Apple DMP driver), + David Wexelblat (for the high-resolution 9-pin Epson driver), + George N. White III (for testing the PDF writer and contributing + documentation), + Elizabeth Zwicky (for some very challenging examples). + +The following people have also helped out by beta testing, by reporting +bugs and/or fixes, or in other ways: + + Juan Manual Acosta, Vikas Aggarwal, Michael Almond, + Abramo Bagnara, Malcolm Bennett, David Brooks, + Jim Collins, + Peter da Silva, Art Dederick, Paul DuBois, + Toerless Eckert, + Bernhard Fabricius, Mark Friedman, Richard Foulk, + Glenn Geers, Dave Goldblatt, Ben Goren, Dirk Grunwald, + Lars Haakedal, Howard B. Halstead, Adam Hammer, George Hartzell, + Mike Hoffmann, Charles Hulse, + Brad Jones, Terry Jones, + David Keppel, + Anthony Lee, Marty Leisner, John Lundin Jr., Lee McLoughlin, + Stergios Marinopoulos, Herb Martin, David Maynard, + Doug McDonald, Rich Murphey, + Russ Nelson, + Peter Phillips, + Mark Rawling, Philippe Robert, Tomas Rokicki, Wolfgang Rupprecht, + Bill Schelter, Larry Schwimmer, Bakul Shah, + Erik Talvola, Mark A. Thomas, Kjetil Bernhard Thomassen, + Amanda Walker, Peter Wan, John L. Wehle, Carsten Wiethoff, + Carl Witty, + Frank Yellin, + Jamie Zawinski. + +If your name appears on the above list and I've forgotten a particular +contribution you made, or if it doesn't appear at all, please forgive me: +just remind me, and you will be properly acknowledged in the next release. diff --git a/gs/hershey.txt b/gs/hershey.txt new file mode 100644 index 000000000..9a6230112 --- /dev/null +++ b/gs/hershey.txt @@ -0,0 +1,261 @@ +This file is part of Ghostscript. Unlike the rest of Ghostscript, it +consists entirely of information copied directly from public sources. It +therefore is not covered by the Ghostscript copyright or license. + +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +Mod.sources: Volume 4, Issue 42 +Submitted by: pyramid!octopus!pete (Pete Holzmann) + + +This is part 1 of five parts of the first Usenet distribution of +the Hershey Fonts. See the README file for more details. + + +Peter Holzmann, Octopus Enterprises +USPS: 19611 La Mar Court, Cupertino, CA 95014 +UUCP: {hplabs!hpdsd,pyramid}!octopus!pete +Phone: 408/996-7746 + + +This distribution is made possible through the collective encouragement +of the Usenet Font Consortium, a mailing list that sprang to life to get +this accomplished and that will now most likely disappear into the mists +of time... Thanks are especially due to Jim Hurt, who provided the packed +font data for the distribution, along with a lot of other help. + +This file describes the Hershey Fonts in general, along with a description of +the other files in this distribution and a simple re-distribution restriction. + +USE RESTRICTION: + This distribution of the Hershey Fonts may be used by anyone for + any purpose, commercial or otherwise, providing that: + 1. The following acknowledgements must be distributed with + the font data: + - The Hershey Fonts were originally created by Dr. + A. V. Hershey while working at the U. S. + National Bureau of Standards. + - The format of the Font data in this distribution + was originally created by + James Hurt + Cognition, Inc. + 900 Technology Park Drive + Billerica, MA 01821 + (mit-eddie!ci-dandelion!hurt) + 2. The font data in this distribution may be converted into + any other format *EXCEPT* the format distributed by + the U.S. NTIS (which organization holds the rights + to the distribution and use of the font data in that + particular format). Not that anybody would really + *want* to use their format... each point is described + in eight bytes as "xxx yyy:", where xxx and yyy are + the coordinate values as ASCII numbers. + +*PLEASE* be reassured: The legal implications of NTIS' attempt to control +a particular form of the Hershey Fonts *are* troubling. HOWEVER: We have +been endlessly and repeatedly assured by NTIS that they do not care what +we do with our version of the font data, they do not want to know about it, +they understand that we are distributing this information all over the world, +etc etc etc... but because it isn't in their *exact* distribution format, they +just don't care!!! So go ahead and use the data with a clear conscience! (If +you feel bad about it, take a smaller deduction for something on your taxes +next week...) + +The Hershey Fonts: + - are a set of more than 2000 glyph (symbol) descriptions in vector + ( point-to-point ) format + - can be grouped as almost 20 'occidental' (english, greek, + cyrillic) fonts, 3 or more 'oriental' (Kanji, Hiragana, + and Katakana) fonts, and a few hundred miscellaneous + symbols (mathematical, musical, cartographic, etc etc) + - are suitable for typographic quality output on a vector device + (such as a plotter) when used at an appropriate scale. + - were digitized by Dr. A. V. Hershey while working for the U.S. + Government National Bureau of Standards (NBS). + - are in the public domain, with a few caveats: + - They are available from NTIS (National Technical Info. + Service) in a computer-readable from which is *not* + in the public domain. This format is described in + a hardcopy publication "Tables of Coordinates for + Hershey's Repertory of Occidental Type Fonts and + Graphic Symbols" available from NTIS for less than + $20 US (phone number +1 703 487 4763). + - NTIS does not care about and doesn't want to know about + what happens to Hershey Font data that is not + distributed in their exact format. + - This distribution is not in the NTIS format, and thus is + only subject to the simple restriction described + at the top of this file. + +Hard Copy samples of the Hershey Fonts are best obtained by purchasing the +book described above from NTIS. It contains a sample of all of the Occidental +symbols (but none of the Oriental symbols). + +This distribution: + - contains + * a complete copy of the Font data using the original + glyph-numbering sequence + * a set of translation tables that could be used to generate + ASCII-sequence fonts in various typestyles + * a couple of sample programs in C and Fortran that are + capable of parsing the font data and displaying it + on a graphic device (we recommend that if you + wish to write programs using the fonts, you should + hack up one of these until it works on your system) + + - consists of the following files... + hershey.doc - details of the font data format, typestyles and + symbols included, etc. + hersh.oc[1-4] - The Occidental font data (these files can + be catenated into one large database) + hersh.or[1-4] - The Oriental font data (likewise here) + *.hmp - Occidental font map files. Each file is a translation + table from Hershey glyph numbers to ASCII + sequence for a particular typestyle. + hershey.f77 - A fortran program that reads and displays all + of the glyphs in a Hershey font file. + hershey.c - The same, in C, using GKS, for MS-DOS and the + PC-Color Graphics Adaptor. + +Additional Work To Be Done (volunteers welcome!): + + - Integrate this complete set of data with the hershey font typesetting + program recently distributed to mod.sources + - Come up with an integrated data structure and supporting routines + that make use of the ASCII translation tables + - Digitize additional characters for the few places where non-ideal + symbol substitutions were made in the ASCII translation tables. + - Make a version of the demo program (hershey.c or hershey.f77) that + uses the standard Un*x plot routines. + - Write a banner-style program using Hershey Fonts for input and + non-graphic terminals or printers for output. + - Anything else you'd like! + +SHAR_EOF + +This file provides a brief description of the contents of the Occidental +Hershey Font Files. For a complete listing of the fonts in hard copy, order +NBS Special Publication 424, "A contribution to computer typesetting +techniques: Tables of Coordinates for Hershey's Repertory of Occidental +Type Fonts and Graphic Symbols". You can get it from NTIS (phone number is ++1 703 487 4763) for less than twenty dollars US. + +Basic Glyph (symbol) data: + + hersh.oc1 - numbers 1 to 1199 + hersh.oc2 - numbers 1200 to 2499 + hersh.oc3 - numbers 2500 to 3199 + hersh.oc4 - numbers 3200 to 3999 + + These four files contain approximately 19 different fonts in +the A-Z alphabet plus greek and cyrillic, along with hundreds of special +symbols, described generically below. + + There are also four files of Oriental fonts (hersh.or[1-4]). These +files contain symbols from three Japanese alphabets (Kanji, Hiragana, and +Katakana). It is unknown what other symbols may be contained therein, nor +is it known what order the symbols are in (I don't know Japanese!). + + Back to the Occidental files: + +Fonts: + Roman: Plain, Simplex, Duplex, Complex Small, Complex, Triplex + Italic: Complex Small, Complex, Triplex + Script: Simplex, Complex + Gothic: German, English, Italian + Greek: Plain, Simplex, Complex Small, Complex + Cyrillic: Complex + +Symbols: + Mathematical (227-229,232,727-779,732,737-740,1227-1270,2227-2270, + 1294-1412,2294-2295,2401-2412) + Daggers (for footnotes, etc) (1276-1279, 2276-2279) + Astronomical (1281-1293,2281-2293) + Astrological (2301-2312) + Musical (2317-2382) + Typesetting (ffl,fl,fi sorts of things) (miscellaneous places) + Miscellaneous (mostly in 741-909, but also elsewhere): + - Playing card suits + - Meteorology + - Graphics (lines, curves) + - Electrical + - Geometric (shapes) + - Cartographic + - Naval + - Agricultural + - Highways + - Etc... + + +ASCII sequence translation files: + + The Hershey glyphs, while in a particular order, are not in an + ASCII sequence. I have provided translation files that give the + sequence of glyph numbers that will most closely approximate the + ASCII printing sequence (from space through ~, with the degree + circle tacked on at the end) for each of the above fonts: + + File names are made up of fffffftt.hmp, + + where ffffff is the font style, one of: + roman Roman + greek Greek + italic Italic + script Script + cyril Cyrillic (some characters not placed in + the ASCII sequence) + gothgr Gothic German + gothgb Gothic English + gothit Gothic Italian + + and tt is the font type, one of: + p Plain (very small, no lower case) + s Simplex (plain, normal size, no serifs) + d Duplex (normal size, no serifs, doubled lines) + c Complex (normal size, serifs, doubled lines) + t Triplex (normal size, serifs, tripled lines) + cs Complex Small (Complex, smaller than normal size) + +The three sizes are coded with particular base line (bottom of a capital + letter) and cap line (top of a capital letter) values for 'y': + + Size Base Line Cap Line + + Very Small -5 +4 + Small -6 +7 + Normal -9 +12 + + (Note: some glyphs in the 'Very Small' fonts are actually 'Small') + +The top line and bottom line, which are normally used to define vertical + spacing, are not given. Maybe somebody can determine appropriate + values for these! + +The left line and right line, which are used to define horizontal spacing, + are provided with each character in the database. + +SHAR_EOF + +Format of Hershey glyphs: + +5 bytes - glyphnumber +3 bytes - length of data length in 16-bit words including left&right numbers +1 byte - x value of left margin +1 byte - x value of right margin +(length*2)-2 bytes - stroke data + +left&right margins and stroke data are biased by the value of the letter 'R' +Subtract the letter 'R' to get the data. + +e.g. if the data byte is 'R', the data is 0 + if the data byte is 'T', the data is +2 + if the data byte is 'J', the data is -8 + +and so on... + +The coordinate system is x-y, with the origin (0,0) in the center of the +glyph. X increases to the right and y increases *down*. + +The stroke data is pairs of bytes, one byte for x followed by one byte for y. + +A ' R' in the stroke data indicates a 'lift pen and move' instruction. diff --git a/gs/history1.txt b/gs/history1.txt new file mode 100644 index 000000000..b3237397f --- /dev/null +++ b/gs/history1.txt @@ -0,0 +1,341 @@ + Copyright (C) 1992, 1993, 1994 Aladdin Enterprises. All rights reserved. + + This file is part of Aladdin Ghostscript. + + Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author + or distributor accepts any responsibility for the consequences of using it, + or for whether it serves any particular purpose or works at all, unless he + or she says so in writing. Refer to the Aladdin Ghostscript Free Public + License (the "License") for full details. + + Every copy of Aladdin Ghostscript must include a copy of the License, + normally in a plain ASCII text file named PUBLIC. The License grants you + the right to copy, modify and redistribute Aladdin Ghostscript, but only + under certain conditions described in the License. Among other things, the + License requires that the copyright notice and this notice be preserved on + all copies. + +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +This file, history1.txt, describes the changes in older releases of +Ghostscript numbered 1.n. For more recent changes, see the historyN.txt (N +> 1) and NEWS files. + +For an overview of Ghostscript and a list of the documentation files, see +README. + +Version 1.3 (6/20/89) +=========== + +This release should have had a lot more things in it, but time pressure +and the already long delay in getting it out made it necessary to push it +out the door in an incomplete state (e.g., no testing on X systems +whatsoever). + +Interpreter +----------- + +Makes -d and -D equivalent on the command line. Adds a new switch -s / -S +that defines a name as a string rather than a token. + +Arranges things so that if -sLIB=_a_prefix_ is defined on the command +line, (filename) run will look for _a_prefix_filename before giving up if +filename isn't the name of an accessible file. + +Changes showpage from an operator to a procedure. The definition of +showpage in ghost.ps does a copypage, beeps the console, waits for the +user to type a character (normally a , since line buffering is +always enabled), and then does an erasepage and an initgraphics. + +Adds a new initialization file, gdevs.ps, containing device-dependent +parameters. The default window size for X Windows is properly set to 612 +x 792, i.e., 8.5" x 11". + +Adds a new optional initialization file, statusd.ps, that provides dummy +definitions for the names found in statusdict on LaserWriters. + +Adds a new operator, getenv, to get information from the shell +environment. + +Adds a new predefined operator, defaultdevicename, that returns either (X) +or (EGA) according to how the interpreter was built. + +Adds a new type, devicetype, and new operators deviceparams, getscanlines, +makedevice, makeimagedevice, and setdevice. Changes currentdevice to +return a device object rather than a set of parameters. + +Makes the scanner recognize reals with 'e' exponent notation, and handle +reals with more than 9 digits. + +Fixes a bug that made names starting with digits read incorrectly. + +Fixes a bug in the exp operator that made it not pop its first argument +from the stack. + +Fixes a bug in the rand operator that made it return negative values about +half the time. + +Fixes a bug in equality comparison (eq, ne, and several other operators) +that made unequal operator objects occasionally appear to be equal on DOS +systems. + +Fixes a bug in the bind operator that made it not work on packed arrays. + +Changes the internal representation of dictionaries so they can be +expanded or contracted dynamically. Adds a new operator, setmaxlength, to +change the allocated size of a dictionary. + +Changes sstorei.h so that non-DOS compilers don't encounter the #pragma +directive used by Turbo C. + +Restores the display mode (on MS-DOS systems) when exiting. + +Fonts +----- + +Makes undefined characters in the standard font display as tilde rather +than blank (or causing an error). Unmapped character codes (those mapped +to .notdef in the encoding) still display as nothing, per the PostScript +manual. + +Library +------- + +Adds a new header file, gxbitmap.h, with some new documentation describing +the internal storage format for bitmaps. + +Makes numerous internal changes in the character / font cache, affecting +many of the routines in gxcache.c. + +Fixes a bug in gz_draw_line / gz_fill_trapezoid that made nearly +horizontal lines display wrong. + +Fixes a bug in gs_scale that made scaling not work if the coordinate +system was rotated or skewed. + +Extends the font cache so it will handle characters rotated by multiples +of 90 degrees. + +Changes the second argument of gx_path_bbox and gx_path_is_rectangle to be +a gs_fixed_rect * rather than a fixed [4]. + +Changes gs_matrix_rotate so it handles multiples of 90 degrees as a +special case. + +Changes the definition of the gx_device structure to accommodate the new +device operators, and adds corresponding library calls. + +Changes the type for a device color index from int to gx_color_index +(equivalent to unsigned long). ***NOTE***: this affects existing clients +and drivers in a non-trivial way on MS-DOS systems. + +Changes gs_malloc and gs_free to take a client name string as an argument. + +Usage procedures +---------------- + +Changes the compilation rules for Unix systems to not use the -o and -c +compiler flags together, to be compatible with more versions of cc. + +Changes the gcc makefile to use $(GCC) rather than gcc as the compiler +name. + +Moves the -1 flag for the MS-DOS compiler from the cc*.bat files to the +makefile. + +Changes CCDEBUG to CCFLAGS, and adds ASMFLAGS, in DOS makefile. + +Adds -DFOR80386 and /DFOR80386 to enable use of 80386 instructions in +assembly code on DOS systems. + +Merges the DEBUG and gs_DEBUG switches. There is now only a single DEBUG +switch that affects both the interpreter and the library. + +Adds a new compilation switch, -DNOPRIVATE, that makes private (static) +variables and procedures public for debugging and profiling (only needed +on DOS systems). + +Adds the DOS executable (gs.exe and gs.map) to the distribution fileset. + +Adds new platform-specific code files, gp-*.c, for a few things like +reading the clock. + +Adds a new documentation file, drivers.doc, that describes the interface +between Ghostscript and device drivers. + +Version 1.2 (2/22/89) +=========== + +Interpreter +----------- + +Adds the new facilities in version 25 of PostScript: //name for immediate +lookup, packed arrays (setpacking, currentpacking, packedarray operators), +and new font cache parameters (setcacheparams, currentcacheparams +operators). + +Adds new operators (setfileposition, currentfileposition) for random +access to files. + +Extends readhexstring to take either a string or a file, just like token. + +Fixes a bug that caused the 'for' operator (and a couple of others) to +randomly smash memory locations on PC platforms. + +Library +------- + +Renames the init_device driver procedure as open_device, and adds a +corresponding close_device. + +Adds new procedures to read and set the cache limit values (implementing +the currentcacheparams and setcacheparams operators). + +Usage procedures +---------------- + +Changes the name of the Unix makefile to ux-cc-x.mak, and adds a new Unix +makefile, ux-gcc-x.mak, for using gcc instead of cc. (The latter doesn't +actually work yet.) + +Changes the name of the single built-in font from uglyfont.cp to +ugly10.cp. + +Version 1.1 (2/12/89) +=========== + +Interpreter +----------- + +Makes the scanner treat ^Z (ASCII code 26) as whitespace: it erroneously +treated ^R (ASCII code 22, or octal 26) as whitespace. + +Makes the token and readline operators, and the syntax for comments, +recognize \r (code 13), \n (code 10), and \r\n as equivalent end-of-line +indicators. The token and readline operators will skip over any of these +sequences at the end of a token or line respectively, and a comment will +read through any of these sequences. The other file operators (read, +write, readstring, writestring) do nothing special with these characters. + +Changes the debug switch name from -D to -Z. Adds a -D switch for +defining names in systemdict from the command line. Defines -DDEBUG for +printing out debugging information during initialization, and -DNODISPLAY +for suppressing display output. + +Corrects a bug that prevented the error machinery from working -- in +version 1.0, errors always dumped the stacks and aborted interpretation. + +Corrects a bug that made eq and ne not work for strings. + +Makes the atan (arctangent) operator normalize its results according to +the PostScript convention. + +Makes the div operator check for zero divisor. + +Makes unimplemented operators (resetfile, echo, save, restore, strokepath, +reversepath) truly undefined. + +Makes the interactive loop exit gracefully on end-of-file: in version 1.0 +this caused an infinite loop. + +Implements the status operator. + +Corrects a bug that made the 'for' operator deliver garbage values if one +or more of the operands (start, increment, end) was a real. + +Corrects a bug that made the arc and arcn operators not pop their operands +from the stack. + +Corrects a bug that made the kshow operator crash the interpreter. + +Corrects a bug that made the print operator fail on machines that don't +pass structure arguments by simply pushing the contents of the structure. + +Adds a new operator, imagecharpath, to convert images to +addcharpath-compatible outlines. + +Changes alloc and alloc_free to use char * rather than byte *, and +alloc_free to return void rather than int, making them compatible with the +library's expectations and with malloc/free. + +Explicitly casts all expressions of the form (ptr1 - ptr2) used as +procedure arguments to unsigned, to handle an incompatibility between +Turbo C versions 1.5 and 2.0. + +Changes some of the internal conventions for operators: operators that +push on the operand stack must check for overflow explicitly, and +operators that modify the execution stack must return a special code. +(See oper.h for details.) + +Initialization (ghost.ps, gfonts.ps) +-------------- + +Modifies ghost.ps and gfonts.ps so they print debugging information only +if the name DEBUG is defined. (Presumably the user will set this from the +command line with -DDEBUG.) + +Changes ghost.ps so it initializes the nominal screen size to 640 x 350 on +MS-DOS systems as before, but to 612 x 792 on Unix systems, which is an +8.5" x 11" page at 72 pixels per inch. + +Library +------- + +Corrects a bug that made the fill and eofill operators (gs_fill and +gs_eofill) not perform a newpath afterward. + +Corrects the bug that made thin, nearly horizontal lines display wrong (as +a series of disconnected dots) in the MS-DOS implementation. + +Fixes a bug in the EGA driver that often made it fill rectangular regions +with black around information being displayed in white. + +Completely changes the internal representation of outline fonts, and +changes btoi.ps (a Ghostscript language program for converting bitmaps to +outlines) to use a new library call, gs_imagecharpath. + +Changes the extension for outline font files from .gf to .cp. + +Adds a new debugging switch, q, that traces all rectangle fill operations. + +Adds a new debugging switch, v, that traces all device-level output calls. + +Explicitly casts pointer differences passed as procedure arguments, as in +the interpreter. + +Makes stringwidth work if there is no current point. In version 1.0, this +gave a nocurrentpoint error. + +Usage procedures +---------------- + +Changes the name of the 'read me' file from READ.ME to README. + +Removes a bogus line (invoking the 'mcopy' utility) from the makefile. + +Splits up the makefile into a generic part (ghost.mak) and +platform-specific parts (dos-ega.mak, unix-x11.mak). The latter are what +is actually executed. + +Puts the definitions of the DEBUG and gs_DEBUG compilation flags into the +makefile instead of in ghost.h and gx.h respectively. + +Changes the names of the documentation files to be a little less cryptic. +Changes all the file names to lower-case in the documentation. Adds +installation information to make.doc. + +Changes all function definitions (but not prototype declarations) to ANSI +syntax, and adds a preprocessing step (ansi2knr) to convert them to K&R +syntax on Unix systems. + +Changes the normal MS-DOS link configuration to not assume the presence of +an 80x87 coprocessor, and describes how to increase performance if a +coprocessor is present. + +Changes the names of all the interpreter .c files, except stream.c, to +begin with 'i'. + +Version 1.0 (8/11/88) +=========== + +First version released to the public. diff --git a/gs/history2.txt b/gs/history2.txt new file mode 100644 index 000000000..ee4fd2def --- /dev/null +++ b/gs/history2.txt @@ -0,0 +1,5160 @@ + Copyright (C) 1994 Aladdin Enterprises. All rights reserved. + + This file is part of Aladdin Ghostscript. + + Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author + or distributor accepts any responsibility for the consequences of using it, + or for whether it serves any particular purpose or works at all, unless he + or she says so in writing. Refer to the Aladdin Ghostscript Free Public + License (the "License") for full details. + + Every copy of Aladdin Ghostscript must include a copy of the License, + normally in a plain ASCII text file named PUBLIC. The License grants you + the right to copy, modify and redistribute Aladdin Ghostscript, but only + under certain conditions described in the License. Among other things, the + License requires that the copyright notice and this notice be preserved on + all copies. + +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +This file, history2.txt, describes the changes in older releases of +Ghostscript numbered 2.n. For more recent changes, see the historyN.txt (N +> 2) and NEWS files. + +For an overview of Ghostscript and a list of the documentation files, see +README. + +Version 2.9.10-beta (7/28/94) +=================== + +This is the last 2.9 beta, since 3.0 will be released on July 31. + +Documentation +------------- + +Fixes bugs: + - A | in gs.1 had a \ in front of it instead of \\. + +Adds a paragraph in gs.1 that tells how to select paper size. + +Notes in devs.mak that the cdj550 driver is the best one for the H-P +DeskJet 520, and the pjxl300 driver is the right one for the H-P DeskJet +1200C. + +Notes in make.doc that Watcom C++ 10.0 may require a change in a makefile. + +Procedures +---------- + +Removes ICCINIT from MODULES.LIS for VMS systems. + +Updates VMS.MAK to support Motif V1.2. + +Updates jpeg.mak to work with version 5alpha4 of the IJG JPEG code. + +Utilities +--------- + +Fixes bugs: + - font2c didn't leave extra room in Type 0 font dictionaries for +entries added by definefont. + - font2c left extra information on the stack. + - ansi2knr would remove newline characters within formal argument +lists. + - font2c got an Error: /undefined in makefontprocname. + +Updates ansi2knr to work better with the GNU configure program. + +Updates ansi2knr to handle procedure formal arguments automatically. + +Drivers +------- + +Fixes bugs: + - If a file contained color or gray-scale information followed by a +masked image, the X driver would sometimes invert the polarity of the +image. + +Platforms +--------- + +Fixes bugs: + - Unix systems with a 2-argument gettimeofday returned garbage +values for the current time. + - The VMS build script for compiled fonts omitted the requirement +to load gs_ccfnt.ps. + - memory_.h didn't note that System V Unix platforms need memmove. + +On Unix systems, changes the subdirectory of $datadir/ghostscript to just +be the version number (e.g., 2.9.10 rather than gs-2.9.9). + +Fonts +----- + +Adds support code for the Wadalab (University of Tokyo) free Kanji font. + +Notes in the documentation in Fontmap that .pfa and .pfb fonts are +compatible with ATM, but .gsf fonts are not. + +Changes the names of Thomas Wolff's expanded Hershey fonts, replacing .gsf +with .pfa. + +Interpreter +----------- + +Fixes bugs: + - The scanner became confused if the literal names /<< or />> +straddled an input buffer boundary. + - .setlanguagelevel gave an invalidaccess error when +switching from level 2 to level 1. + - currentgstate, setgstate, and copy for gstates didn't do +the necessary access checks. + - The Category resource category didn't define .ResourceFile, so +/Category resourcestatus gave an error. + - The garbage collector didn't trace the structures used by +filenameforall properly on most platforms. + - Automatically expanding systemdict didn't work, but didn't give +an error. + - Automatically expanding a dictionary usually expanded it by too +much. + - systemdict was created too small. + - The garbage collector didn't trace the structures referenced only +from allocator objects, leading to attempts to access freed storage. + - If a chunk was empty, the GC tried to free it even if it had +inner chunks. +* - The outer loop in dict_find_name_by_index() could cause an +addressing fault on segmented machines when looking up Level 2 operators, +because the offset could get decremented past 0. + - The heap_available procedure in gsmemory.c didn't convert +properly to non-ANSI syntax. (New bug in 2.9.9.) + - The ledgertray procedure wasn't implemented. + - The xxxtray procedures didn't set the page size. + - The settumble operator wasn't implemented, even as a dummy. + - glyphshow didn't work with Type 3 fonts. + - Supplying a RenderTable for a CIE color space caused an error. + - The DCT filter code had the jpeg/ subdirectory name "wired in" to +the source files. + +Adds experimental filters for Burrows/Wheeler block sorting compression +(BWBlockSortEncode/Decode), described in DEC SRC Research Report #124, +move-to-front coding (MoveToFrontEncode/Decode), and a simple form of +Huffman coding (BoundedHuffmanEncode/Decode). These are experimental -- do +not rely on them remaining the same (or existing at all) in future +releases! + +Adds all function prototypes needed to pacify strict compilers. + +Removes all explicit references to userdict from the C code. + +Changes the SAFER switch so that it disallows not only explicit writing, +deleting, or renaming of files, but also disallows specifying an explicit +OutputFile for any device (except for the initial device, by means of +-sOutputFile= on the command line). + +Streams +------- + +Fixes bugs: + - Hex decoding (ASCIIHexDecode stream and <> literals) didn't treat +the data source as read-only (although it restored it to its original +contents). + +Implements move-to-front coding, a simple form of Huffman coding, and +Burrows/Wheeler block sorting compression. + +Library +------- + +Fixes bugs: +* - (The following bug fix was actually implemented somewhere around +version 2.7.) restore didn't purge character cache entries whose keys were +names created more recently than the save. + - gstype1.h declared gs_type1_state_sizeof as an extern, but this +wasn't defined anywhere. + - gs_makeimagedevice didn't set the size of the palette correctly, +which confused the GC. + - gs_makeimagedevice didn't set num_components to 1 for +mapped-color devices with only gray values. +* - The two-color halftoning algorithms truncated when computing the +halftone level, rather than rounding it. +* - If a path being filled had line segments that fell entirely to +the right of the clipping region, part of the path might not be filled. + - The optimized code for 24-bit color didn't ensure properly that +32-bit accesses would be aligned appropriately. + - The miter join check had gotten reversed somewhere along the way. +* - Because x and y were interchanged in the miter check computation, +in some situations the check was inverted. (This is a very old bug!) + - It was believed that strokepath didn't work with dashed lines; +the problem appears to have been an incorrect testing program. + +Adds all function prototypes needed to pacify strict compilers. + +Changes fixed2float so it doesn't cast the result to float, and removes +fixed2double. This produces slightly more accurate results in many places, +and may even be faster (for FPUs that normally generate double rather than +single precision results). + +Version 2.9.9-beta (6/23/94) +================== + +Documentation +------------- + +Puts a pointer to devs.mak in the section of use.doc that talks about +MS-DOS displays. + +Platforms +--------- + +Fixes bugs: + - The %pipe% IODevice was omitted on System V platforms. + - The AXP VMS build script needed /NESTED_INCLUDE=PRIMARY in +CC_QUAL to work around a bug in the DEC C compiler. + +Fonts +----- + +Fixes bugs: + - gs_lev2.ps redefined .loadFontmap incorrectly. + +Interpreter +----------- + +Fixes bugs: + - stream_compact used memcpy even though the source and destination +might overlap. + - filter applied to a closed file could cause a crash. + +Library +------- + +Fixes bugs: + - putdeviceparams to a printer didn't close and reopen the device +if only the page size or resolution was changed. + +Version 2.9.8 (6/20/94) +============= + +This is the first version that claims to be a full Level 2 implementation. +It was distributed to satisfy a contractual requirement. + +Documentation +------------- + +In make.doc: + - Adds a reference to the generic System V section at the end of +the SCO section. + - Notes that DEC OSF/1 systems may require changing the name of the +install program to installbsd. + +Updates drivers.doc to reflect the change from "properties" to +"parameters". + +Updates the Aladdin Enterprises Free Public License to version 1. + +In language.doc, notes that certain device parameters will be phased out. + +Procedures +---------- + +Fixes bugs: + - The file aa.ps was included in the distribution by mistake. + +Notes in the Unix makefiles that X11R6 probably needs SM and ICE added to +XLIBS. + +Utilities +--------- + +Fixes bugs: + - viewjpeg.ps used a non-existent file as its example. + - A temporary string in wrfont.ps was allocated too small. + +Upgrades font2c.ps so it will handle (simple) Type 0 fonts as well as Type +1. + +Drivers +------- + +Fixes bugs: + - The TIFF drivers didn't byte-align each scan line. + - gdevtfax.c applied & to an array member of a structure. + +Changes the param_list interface slightly: Implementations of the +put_params driver procedure should now use param_signal_error to report +errors, and should not give up at the first error. (Even though this is a +non-backward-compatible change, old implementations will continue to work; +they just won't deliver complete results to the setpagedevice Policies +machinery.) + +Platforms +--------- + +Fixes bugs: + - Removes the time zone adjustment from gp_get_clock in gp_unix.c, +since the value returned by all Unix systems is bogus. + - The DV/X makefile still included the dfaxhigh and dfaxlow drivers. + - gssetmod.com (VMS command file) didn't work properly if the +argument list was empty. + - vms.mak, vms-axp.mak, and modules.lis hadn't been updated to +reflect changes in 2.9.7. + - The MS Windows version wouldn't link (overflowed the 64K primary +data segment). + +Fonts +----- + +Makes the font substitution algorithm somewhat more intelligent. + +Interpreter +----------- + +Fixes bugs: + - Enumerating the pointers of a zero-length array of structures +caused a divide by zero. + - iref.h didn't protect itself against multiple inclusion. + - The CCITTFaxEncode filter didn't byte-align the final +end-of-block code if EndOfBlock and EncodedByteAlign were both true. + - make_initial_dict in iinit.c used `name' as a formal parameter +name, which some compilers believe conflicts with a typedef. + - Not all internal operators had registered names. + - The GC used memcpy, rather than bytes_copy, when compacting +objects, even though the source and destination might overlap. + - When debugging was enabled, gc_string_mark could give a spurious +error indication. + - vmstatus returned too small a value for the maximum VM. + - The scanner could get into a loop when reading a radix-85 string. + - The GC could get into a state where it was called after every +allocation (because of the patch setting global = true in ireclaim). + - The general path filling algorithm didn't skip regions that were +completely outside the clipping box. + - The gs_screen_enum structure contained a pointer (porder) that +pointed into the middle of a structure, confusing the GC. + +Implements the BitmapWidths flag in fonts. The default of false means that +we use scalable widths even with xfonts. + +Changes the Generic resource category so that ResourceFileName is optional. + +Changes the .getdeviceparams operator so that it takes an optional +dictionary giving the set of keys whose values are wanted. Changes the +.putdeviceparams operator so that it takes an optional policy dictionary +specifying the action to be taken on errors, and returns a list of keys and +errors if it fails, rather than causing an error. These are +non-backward-compatible changes, but ordinary programs do not use these +operators. + +Changes the names of some internal operators and procedures by adding +a . to the beginning: + currenttime + devicename + +Implements currentpagedevice, and a small subset of setpagedevice. Only +the following keys in the page device dictionary are known to the current +implementation, and the ones marked with * are not actually processed: + PageSize + InputAttributes + MediaColor, MediaWeight, MediaType, InsertSheet + (for InputAttributes matching only) + *ImagingBBox + OutputAttributes + OutputType + (for OutputAttributes matching only) + NumCopies + HWResolution + *Margins + *Orientation (for all devices, not just roll devices) + Policies + Install + BeginPage + EndPage +Does not implement: + - Updating InputAttributes or OutputAttributes by sensing the state + of the device; + - Retrying media matching after an initial failure; + - Automatic handling of portrait vs. landscape page size; + - Recording the CTM after Install as the one to be used for + defaultmatrix, initmatrix, and initgraphics. +Also, media matching is normally disabled (with InputAttributes = null) +for all devices. ****** We had to disable setpagedevice just before +shipping this release, because of interactions with the older device +handling machinery that we could not fix in the time available. + +Library +------- + +Fixes bugs: + - 24-bit color (mem_true24_fill_rectangle and _copy_mono) had +algorithm bugs. + - A complex conditional expression in gx_render_gray wouldn't +compile properly with the DECStation 3100 Ultrix 4.3 compiler. + - The GC routines for gx_device_clip didn't handle the case where +the 'current' pointer pointed to list.single. + - gx_add_char_bits used memcpy, rather than bytes_copy, for +compressing character bitmaps, even though the source and destination might +overlap. + - Some compilers require the definition of st_gstate_contents to +precede the definitions of the GC procedures. + - Filling a large rectangle (more than 1K of bitmap) with a colored +halftone overwrote random areas of the stack. + +Changes gs_setcachedevice[2] to take a pointer to an array of floats, +rather than 6 or 10 individual floats. THIS IS A NON-BACKWARD-COMPATIBLE +CHANGE. + +Implements the BitmapWidths flag in fonts. + +Version 2.9.7-beta (6/5/94) +================== + +Yet another pre-3.0 beta. The main features are a fairly reliable garbage +collector, and function prototypes almost everywhere they are needed. + +Documentation +------------- + +Fixes bugs: + - The comment at the beginning of the zfindlibfile procedure was +incorrect. + +Replaces the GNU License (the COPYING file) with version 0 of the new +Aladdin Enterprises Free Public License (the PUBLIC file). + +Procedures +---------- + +Fixes bugs: + - The definition of cmykread.dev in gs.mak was incorrect (it +modified color.dev). + +Adds the ability to specify a value for FONTPATH on the command line +(-sFONTPATH=), overriding GS_FONTPATH. + +Replaces the -oper2 configuration resource type with the ability to specify +in the op_def list the dictionary in which operators will be defined. (See +opdef.h for more details.) This is an internal change only. + +Utilities +--------- + +Fixes bugs: + - viewgif.ps got an error on interlaced GIF files whose height +wasn't a multiple of 8. + +Changes traceop.ps so it stores the traced operator in the same dictionary +where the operator is currently defined, if possible. + +Drivers +------- + +Fixes bugs: + - The new G3 fax drivers crashed on page widths greater than 2623 +(40 * 64 + 63) pixels. (We fixed this by disallowing page widths greater +than approximately twice this.) + - The 24-bit PCX driver had some debugging code accidentally left +in it that produced large volumes of useless console output. + +Removes the previous (Leffler) TIFF/F driver and the TruFax driver. + +Platforms +--------- + +Fixes bugs: + - time_.h, gp_unix.c, and gp_sysv.c didn't do the right thing on +SVR4 platforms, where gettimeofday only takes 1 argument. + - The final linking command on Turbo C platforms didn't specify the +COMPDIR directory for the linker. + +Fonts +----- + +Changes the standard Fontmap to use the URW contributed fonts as +work-alikes for Helvetica and Times Roman. + +Interpreter +----------- + +Fixes bugs: + - The garbage collector wasn't in a consistent state. + - In Level 2 mode, statusdict was allocated in global VM rather +than local VM. + - resourceforall gave an error on the built-in categories such as +Filter. + - The file searching algorithm didn't check the current directory +first. + - When opening a file failed, it didn't return a different error +depending on the problem. + - The CCITTFaxEncode filter crashed on widths larger than 2623 (64 +* 40 + 63) pixels. (We fixed this by disallowing page widths greater than +approximately twice this.) + - The .type1getsbw operator gave an invalidfont error if a +CharString started with anything other than a [h]sbw. (Adobe's published +specs say this is invalid, but some Adobe MultiMaster fonts start with a +callsubr and/or a callothersubr.) + - When printing out the stack with == after an error, the error +handler got a repeated (and ultimately fatal) typecheck error if it +encountered an object of non-standard type. + - The token operator could incorrectly attempt to free a structure +on the stack if it encountered an input buffer boundary. + - string_to_ref didn't correctly set the a_local flag in the string +object it created. + - If the -c switch was the last switch on the command line, +Ghostscript always exited without going into interactive mode. + - copy didn't check for errors when copying a dictionary. + +Makes many minor changes (mostly adding prototypes) to reduce error and +warning messages from gcc and other strict compilers. + +Adds files containing the 4 predefined PDF encodings (MacRoman, MacExpert, +WinAnsi, and PDFDoc). + +Library +------- + +Fixes bugs: + - image_bbox in gxccman.c could produce a division by 0 if a +0-width character was being entered into the cache. + - gx_image_cached_char incorrectly specified a scale of 2x2 rather +than 1x1 if it had to read bits from an xfont. + - Stale pointers in the halftone cache weren't cleared properly by +a restore. (We fixed this by making grestoreall clear the halftone cache.) + - setdash used gs_malloc, rather than the current allocator, for +allocating the dash pattern. + - If one attempted to fill a very wide region with a colored +halftone, gx_dc_ht_colored_fill_rectangle would loop indefinitely. + - The container_offset in clipping devices was set incorrectly, +causing the garbage collector to mangle pointers. + +Changes the fopen routine in IODevices so that it can return an arbitrary +error code, rather than simply succeeding or failing. THIS IS A +NON-BACKWARD-COMPATIBLE CHANGE. It only affects IODevice implementations, +of which there are very few. (It doesn't affect ordinary device drivers.) + +Changes the char_metrics xfont procedure so it returns the width as +floating point numbers rather than integers. THIS IS A +NON-BACKWARD-COMPATIBLE CHANGE. It only affects xfont implementations, of +which there are very few. + +Makes many minor changes (mostly adding prototypes) to reduce error and +warning messages from gcc and other strict compilers. + +Version 2.9.6-beta (5/23/94, not distributed to the public) +================== + +This, too, was supposed to be the last beta release for public release 3.0. +It was created primarily for a user who desperately needed a Level 1 system +that would run properly on a 64-bit hardware architecture. The garbage +collector is badly broken (it's in the middle of an architectural change); +setpagedevice is still not implemented. + +Documentation +------------- + +Documents the standard location of Type 1 fonts on AIX. + +Changes the last few mentions of Ghostview for Microsoft Windows to GSview +for Windows. + +Notes that Solaris 2.n provides the X11 header files in a different place. + +Changes README to reflect the differentiation between Aladdin Ghostscript +and GNU Ghostscript. + +Procedures +---------- + +Fixes bugs: + - The compilation rules for the modules that call the IJG library +used -Ijpeg rather than -I$(JPEGSRC). + - The rule for gslib.dev omitted echogs$(XE) as a prerequisite. + +Makes it possible to define the values of buildtime, copyright, revision, +revisiondate, and serialnumber in the makefile. + +Utilities +--------- + +Fixes bugs: + - The viewgif.ps utility didn't handle local color tables. + +Updates ps2ai.ps to version 1.81. + +Drivers +------- + +Fixes bugs: + - The TIFF and fax devices used some identical names, causing +linker complaints. + - The bj10e/bj200 driver inadvertently disabled the sheet feeder. +(The change may not actually fix this bug, since we don't have either of +these printers with a sheet feeder to test it on.) + - The 'bit' device didn't map colors to pixel values correctly. + - The monochrome PCL driver didn't work around the fact that the +Canon LBP4i printer didn't clear its seed row correctly. + +Adds new drivers: + - A user-contributed driver for the H-P DesignJet 650C. + - A user-contributed driver for the Canon LIPS III printer. + - A completely new tiffg3 driver with one based on the new, fast +faxg3 code. This driver does not include any external code, and carries an +Aladdin copyright. + - A tiffg4 driver, also based on the fast CCITT filter code. + +Removes the tiffg3x driver that appeared briefly in 2.9.5, and renames the +previous (Leffler) tiffg3 driver as tiffg3x. + +Adds support for A0, A1, and A2 paper sizes to PCL drivers. + +Changes all the names involving "props" to "params", for consistency with +the header files, some other internal interfaces, and Adobe's terminology. +THIS IS A NON-BACKWARD-COMPATIBLE CHANGE. However, it only affects devices +that implement their own get_props and put_props procedures, of which there +aren't very many. + +Platforms +--------- + +Fixes bugs: + - The DV/X makefile used X11 rather than X for the X11 library name. + - The DV/X makefile incorrectly included the PC display drivers. + - The DV/X makefile omitted gp_dosfs.$(OBJ) from the list of +platform-specific files. + - The DV/X makefile used : rather than ; for separating directory +names in GS_LIB_DEFAULT. + - x_.h omitted a needed alias for XtAppSetFallbackResources. + - The makefile entry for System V Unix systems didn't include +gp_unifn.$(OBJ). + - The comment before LDFLAGS in the gcc makefiles incorrectly +suggested using the -x switch on Ultrix platforms. + - The forward declaration of quant_params in zfdct.c upset the Sun +compiler because it declared a parameter as float rather than floatp. +* - The Microsoft C compiler, like the Borland C compilers, only +compares the offset part of segmented pointers. + +Fonts +----- + +Adds a fontmap suitable for use with Adobe Type Basics. + +Interpreter +----------- + +Fixes bugs: + - The STACK_LOOP_BEGIN macro in istack.h didn't work correctly on +segmented systems. + - The end_phase procedure in igc.c didn't work correctly on +segmented systems. + - Indexed color spaces didn't mark their base space properly when +garbage collecting. + - The garbage collector didn't work on segmented systems, because +it smashed the lsize field of large objects with mark/reloc information. + - Some structures didn't have correct associated GC procedures: +gs_indexed_map, gs_client_pattern, gs_pattern_instance. + - restore could free names or stack segments that were still +referenced. +* - If a packed object caused an error, the error object could be set +to garbage rather than the correct object. +* - Badly designed error handlers which use $error for temporary +storage could cause a dictfull error. + - Some compilers objected to the use of "dict" as a variable name +in a scope where it was defined as a type. + - IODevices were declared const and non-const inconsistently. + - setpagedevice popped one object too many off the stack if the +request included any subdictionaries that needed to be merged. + - More garbage collector bugs were fixed. + - If the current stack block was empty, Level 2 restore would give +a spurious typecheck error. + - The CCITTFaxEncode filter could get confused if it emptied the +input and filled the output at the same time. + - The CCITTFaxEncode filter could insert an extra EOL if it had to +suspend at certain times. + - The new parser for literal strings (as of 2.9.5) could mis-count +internal parentheses if a parenthesis caused the internal buffer collecting +the string to overflow. + - If the current stack block had fewer than 3 elements, +.type1addpath could report a spurious typecheck error. + - Text rendering operations (show, stringwidth, etc.) caused a +crash if the current color was a Pattern that hadn't already been +rasterized. + - If a program did a grestore when the graphics state stack was +empty, the graphics state was initialized to unexpected (and, in some +cases, invalid) values. + - pathforall could cause a bogus stackoverflow if it overflowed the +current stack block. + - Closing an encoding filter with a procedure as target left the +filter on the stack. +* - The outer loop in dict_lookup() could cause an addressing fault +on segmented machines when looking up Level 2 operators, because the offset +could get decremented past 0. + - There was an = instead of an == in a test in scanner_reloc_ptrs. + - The call on gs_reloc_refs in sproc_reloc_ptrs in zfproc.c omitted +the last (gcst) argument. + +(Re-)implements the 2-D case of CCITTFaxEncode, and fixes a couple of bugs +in it. + +Adds DiffEncode and DiffDecode filters that implement color prediction for +the PDF variant of the LZWDecode filter. + +Changes the specification of .oserrorstring to be similar to getenv, +where, etc. THIS IS A NON-BACKWARD-COMPATIBLE CHANGE; however, no +user-written code should be using .oserrorstring. + +Adds oversampling for better character rasterizing. + +Library +------- + +Fixes bugs: + - gx_dc_ht_colored_fill_rectangle gave a compiler warning because +of a problem with const pointers. + - dfmul2fixed_vars (in gxfixed.h) omitted the & before vda on +big-endian platforms, causing compilation errors. + - IODevices were declared const and non-const inconsistently. + - The Type 1 rasterizer never enabled overshoot suppression. + - stroke didn't fatten the line properly if stroke adjustment was +enabled, or if the line was horizontal or vertical. +* - The clipping test for characters was too strict by almost 1 +pixel, leading to unnecessary clipping of text at the edge of the clipping +box. +* - The initial clipping box was computed incorrectly for devices +whose initial transformation matrix included a rotation. + +Changed the implementation of clipping lists and show enumerators to use +separate objects rather than embedded objects, to pacify the GC. (This is +an internal change, not visible at the PostScript or API level.) + +Makes the character cache trim off left and right blank areas, as well as +top and bottom. (Internal change.) + +Adds oversampling for better character rasterizing. + +Version 2.9.5-beta (4/11/94) +================== + +This was supposed to be the last beta release before 3.0, but it won't be. +The only known major defects are the unreliable garbage collector, and the +dummy implementation of setpagedevice/currentpagedevice. + +Documentation +------------- + +Fixes bugs: + - The file commnew.doc didn't belong in the fileset. + +Notes in the makefiles that SVR4 systems may need to set EXTRALIBS=-lnsl. + +Adds a user-contributed `man' page for the ps2epsi utility. + +Procedures +---------- + +Fixes bugs: + - The IJG files didn't compile properly by themselves, because they +didn't have $(AK) in their dependency list. + +Changes back the handling of files named on the command line, so that they +are first sought in the current directory, and if that fails, use the +search path. (2.9.4-beta changed things so that files on the command line +did not use the search path, because as of that version, the search path +doesn't necessarily include the current directory. I consider the "check +the current directory and then use the search path" rule, which is the +MS-DOS standard and was used in Ghostscript prior to 2.9.4, a serious +mistake, since it is one of the best-known security holes in Unix and can +also produce confusing and unexpected results depending on the current +directory; I would much rather have a clear distinction between +user-specified files, which should not use any path searching, and system +files, that only use the defined search path. However, as of this moment, +users seem to want the convenience at the expense of insecurity and +confusion.) + +Adds '.' to the beginning of the search path for MS-DOS platforms, to +conform to the usual MS-DOS file searching convention. + +Adds a -c ("code") switch, which interprets following arguments (until the +next switch) as PostScript tokens. + +Changes the handling of FEATURE_DEVS so that either level1.dev or +level2.dev must normally be selected. THIS IS A NON-BACKWARD-COMPATIBLE +CHANGE for Level 1 systems, which formerly set FEATURE_DEVS to an empty +definition. + +Utilities +--------- + +Fixes bugs: + - bench.ps didn't switch back to local VM properly before running +the program being benchmarked. + +Adds a ppmsetpagesize command to the pstoppm utility. + +Drivers +------- + +Fixes bugs: + - The PCX and GIF drivers used an incorrect algorithm for computing +the blue component of the color palette, which could cause colors to come +out with not quite enough blue. + - The SPARCprinter driver wouldn't compile with non-ANSI compilers. + +Adds new drivers: + - A user-contributed driver for DEC sixel displays like the VT240 +(sxlcrt, in gdevln03.c, which has a FSF copyright.) + - A much larger and supposedly faster version of the TIFF/F driver +(tiffg3x, in gdevtifx.c), contributed by a user. This has the same +copyright as the TIFF/F driver (gdevtiff.c). + - A driver (faxg3, in gdevfax.c) that produces plain Group 3 fax +output with no header, using the CCITTFaxEncode filter to do the work. +(This is around 2.5-3 times as fast as the other fax drivers distributed +with Ghostscript.) + - A user-contributed driver for the Mitsubishi CP50 color printer. + +Changes the `bit' driver so one can set the Colors and *Values properties. + +Makes the color mapping for PC displays, PCX files, and GIF files identical +(they differed slightly before). + +Platforms +--------- + +Fixes bugs: + - VMS used DISPLAY rather than DECW$DISPLAY to get the display name +if opening the display failed. + - Many minor bugs relating to OS/2 and Win32 were fixed. + - On Unix and DV/X platforms, the install script didn't mkdir +$(gsdir), and didn't mkdir the intermediate directory for the man page. + - On BSD and UTek platforms, the declaration of memset in +memory_.h, and the definition in gsmisc.c, conflicted with the ANSI +declaration. + - One of the SPARC compilers compiled the intersection computation +in arc_either (gspath.c) incorrectly. + - The temporary file names created under OS/2 could exceed the 8.3 +length limit. + +Interpreter +----------- + +Fixes bugs: + - The test files for the IJG library had been damaged by EOL +conversion. + - The garbage collector didn't mark some of the most recently +created names. + - The interpreter would sometimes report a typecheck instead of a +stackunderflow. + - If aload didn't have enough room on the stack, it would report a +rangecheck rather than a stackoverflow. + - zcontext wouldn't compile, because it hadn't been updated to the +new GC interfaces. + - The definition of private_st_stream_proc_state in ifilter.h ended +with a semicolon, which upset some compilers. + - load didn't check to make sure that the dictionaries it examined +had read access. + - cvrs didn't handle negative numbers in radix 2 or 3 properly. + - The allocator could become confused if it was asked to allocate a +large array. + - readline gave an ioerror rather than a rangecheck if it +overflowed the string. + - The allocator didn't free packed arrays properly. + - The allocator's check for LIFO freeing of arrays was off by 1, so +it never succeeded. + - The undercolor removal and black generation procedures weren't +initialized properly. + - If the interpreter couldn't find gs_init.ps, it returned a random +exit code. + - If an operator expected a procedure and didn't get one, it +sometimes gave an invalidaccess rather than a typecheck. + - Unix file enumeration often did the wrong thing if there were +directories in the pattern. + - The ASCIIHexDecode filter read an extra character after the +terminating >. + - scalefont didn't fill in ScaleMatrix properly. + - The CCITTFaxEncode filter crashed if the width of the page wasn't +a multiple of 8 bits. + - The error printing code used .languagelevel, which wasn't defined +in Level 1 configurations. + - setpagedevice didn't pop its argument. + - Definitions in statusdict didn't change according to the current +language level. + - Separation color spaces didn't allow strings as color space names. + - Due to a bug in chunk_locate_ptr, the garbage collector sometimes +decided incorrectly that a pointer was pointing outside collectable space. + - (Many other garbage collector bugs were fixed.) + +Implements additional Level 2 features: + - Garbage collection for strings. + - Expandable operand and dictionary stacks, and the ability to set + the maximum size of these stacks. + - Additional user and system parameters. The following are dummies: + AccurateScreens, JobName, JobTimeout, WaitTimeout. + - Procedure-based filters usable with cvx/exec and token. + - Separation color spaces (always using the alternate space). + (These were theoretically implemented in version 2.6, but they were + never tested and were actually missing most of the implementation.) + - VMThreshold and VMReclaim for invoking GC automatically. + +Adds a hook in iscan.c for parsing DSC comments. + +Adds encoding and decoding filters for the BCP and TBCP protocols. These +are not fully implemented yet: + - The interrupt and status request characters are ignored on input, + and never generated on output; + - The TBCP encoder doesn't emit the start-of-protocol string; + - The TBCP decoder doesn't recognize the end-of-protocol string. + +Factors out Type 1 font capability as a separate feature. + +Changes the names of some files: + packed.h to ipacked.h; + bnum.h to ibnum.h. + +Changes the name of the value.index member of a ref to value.boolval. +(Internal change only.) + +Library +------- + +Fixes bugs: + - The definition of RELOC_PTRS_BEGIN in gsstruct.h wouldn't compile +properly with non-ANSI compilers. + - The JPEG library wouldn't compile properly with non-ANSI compilers. +* - The platform font machinery gave up too easily in some cases. + - CMYK devices needing halftoning converted the CMYK color to RGB. + - The debugging code in arc_add (gspath.c) didn't print the output +values correctly. + +Factors out Type 1 font capability as a separate feature. + +Version 2.9.4-beta (2/19/94) +================== + +Procedures +---------- + +Changes Ghostscript's path searching algorithm so that it does not +automatically look in the current directory first. (The former algorithm +was more MS-DOS-like; the new one is more Unix-like.) If you want to +include the current directory, you must include '.' in the search path. +THIS IS A NON-BACKWARD-COMPATIBLE CHANGE. + +Adds two new resource types for genconf.c: + - -header filexxx.h adds #include "filexxx.h" to gconfig.h. + - -libpath dir adds dir to the list of library search paths. + +Utilities +--------- + +Fixes bugs: + - impath.ps (used by bdftops) computed the starting X coordinate +incorrectly, typically causing characters to be displaced slightly to the +right. + - pstoppm.ps didn't handle local and global VM properly. + +Adds a ps2ai.ps utility, contributed by a user, for converting arbitrary +PostScript files into a form compatible with Adobe Illustrator. + +Drivers +------- + +Adds new drivers: + - A user-contributed driver for Imagen Impress laser printers. + - A user-contributed driver for the DEC LA75plus printer. + +Platforms +--------- + +Under OS/2, adds the ability to keep Ghostscript in memory for a +specified number of minutes. + +Adds support for Win32 and Win32s. + +Changes the MS Windows platform font interface so that it does not attempt +to render fonts at sizes smaller than 6 pixels. Changes the X Windows +interface, which already did this for 4-point and smaller fonts, to also +use a lower limit of 6 pixels. Also changes the X Windows platform font +machinery so it does not render fonts at sizes larger than 36 pixels: at +large sizes, Ghostscript does a perfectly good job, and some X font servers +rasterize the entire font and lock up the entire window system while doing +so. + +Interpreter +----------- + +Fixes bugs: + - currentdash always returned a new array of reals, rather than the +actual argument of setdash. + - Strings in binary object sequences read in as integers. + - Because of a bug in chunk_locate_ptr, some large objects didn't +get freed properly. + - If an error occurred while processing an image, Ghostscript would +attempt to free random blocks of storage. + - Input filters discarded trailing data, rather than filling it out +with zeros. (This is now fixed for ASCIIHexDecode and ASCII85Decode; it's +not clear what other filters it should affect.) + - The ASCII85Encode filter produced garbage output for the final +1-4 bytes before EOD. +* - The TIFF output driver produced incorrect output for the second +and subsequent pages if the output was being produced on multiple files. +* - The default handleerror did a 'stop', which was not correct. + - gpcheck.h converted all positive return codes to 0 if interrupt +checking was enabled. + - Images with multiple data sources didn't work. + - Images with 12-bit sample values didn't work. + - Images with a file as the data source read additional data beyond +what was required. + - 2 vmreclaim worked (pretty much), but 1 vmreclaim didn't. + - If %lineedit was opened multiple times, characters from later +openings overwrote characters from earlier ones. + - token returned garbage for the "remaining string" result when +reading from a string, if it actually read all of the string. (New bug in +2.9.2, probably.) + +Implements additional Level 2 features: + - DCTEncode and DCTDecode filters. + - Filters with procedures as the data source or target. + (Except for token and cvx/exec.) + - Garbage collection for names. + +Changes the error printout so that strings are always truncated at 200 +characters. + +For Level 2 systems, changes the initial setting of the object format +parameter from 0 to an appropriate non-zero value. + +* Changes the .quit operator so that it takes two operands, an error object +and an error code; if the latter is negative, the interpreter returns this +as the error code, rather than e_Quit. + +Makes StandardEncoding and ISOLatin1Encoding arrays, rather than packed +arrays, on large-memory systems, for compatibility with certain test +suites. Changes .registerencoding to accept arrays as well as packed +arrays. + +Library +------- + +Fixes bugs: + - Due to an error in cie_mult3, CIE-based colors were badly +mis-mapped. +* - Very narrow (but not empty) rectangles would disappear. +* - Small halftone cells could smash the next higher entry in the +halftone cache. + - The orientation algorithm in gxstroke.c still interchanged +clockwise and counter-clockwise coordinate systems (after having been +"fixed" at least 3 times). + - Stroking 1-pixel-wide lines shortened them, instead of +lengthening them, if non-butt caps were requested. + +Refactors mem_mapped8_copy_mono because of limitations in the bcc32 +compiler. + +Version 2.9.3-beta (1/19/94) +================== + +This version was created for evaluation purposes for a few users who +needed Level 2 capability; it was never released to anyone else, even +beta testers. + +Documentation +------------- + +Fixes bugs: + - The description of psview and xpsview was incorrect. + +Procedures +---------- + +Changes the installation directories for Unix and similar systems to put +Ghostscript data in $(datadir)/ghostscript/gs-NN.NN.NN rather than directly +in $(datadir)/ghostscript. (Fonts still go in $(datadir)/ghostscript/fonts.) + +Drivers +------- + +Fixes bugs: + - Some spaces were incorrectly replaced with tabs in the help +message in the 3B1 display driver. + - The BMP driver wrote a spurious scan line at the beginning +of its output. + - The monochrome PCX driver had the two palette elements +interchanged. + +Adds new drivers: + - A user-contributed driver for the Xerox XES printer format. This +has a FSF copyright. + - A user-contributed driver for the Epson AP3250 printer. (This is +the same as the Stylus 800, with slightly different margins.) + - A user-contributed driver for the DEC LA70 printer with some +algorithms for improving text at low resolutions. This has a FSF +copyright. + - A user-contributed driver for an intermediate-resolution mode +for 9-pin "Epson-compatible" printers. + +Changes the name of the Stylus 800 driver from escp2 to st800. + +Adds a compile-time flag to the Epson driver to cope with Panasonic 9-pin +printers, which sometimes have trouble mixing graphics and tabs. + +Platforms +--------- + +Fixes bugs: + - The MS Windows driver (gp_mswin.c) referred to iodev.h rather +than gxiodev.h. + - On Unix System V platforms, gp_unifs.c and gdevpipe.c were +incorrectly omitted from the link list. + - (Some?) System V platforms don't have the S_ISDIR macro, +requiring a change in stat_.h. + - The Unix `install' target didn't install gs_std_e.ps and +gs_iso_e.ps. + - No MODULES.LIS file was provided for VMS. + +Adds Desqview/X makefiles that actually work. + +Documents the set of H-P-supplied patches needed to make H-P's +compilers process Ghostscript. + +Changes the MS Windows driver so that if the user presses the Enter key +while the image window has the focus, the text window will be brought to +the top and made the active window. This is useful when viewing a +multi-page document with Ghostscript. + +Interpreter +----------- + +Fixes bugs: + - The definition of public_st_client_color() in gxccolor.h +included an extraneous semicolon. + - The definition of private_st_AXD_state() in sfilter.h included an +extraneous semicolon. + - saxx.c didn't include sfilter.h, which it needed for the +definition of private_st_AXD_state(). + - ialloc_struct failed to create a separate chunk if the structure +was very large. + - setcolorspace didn't allocate the colorspace object in the same +VM space as the graphics state, causing problems when the colorspace was +freed. + - In rare circumstances, currentfile could return an empty array +rather than a file. + - Dictionary keys were always allocated in global VM. + - If NOPLATFONTS was true, definefont didn't check whether the +dictionary was read-only before trying to insert an ExactSize key. + - startjob could get an invalidaccess error, because serverdict was +allocated in global VM. + - Using definefont with an already registered font created a +circular list structure. + - If a PostScript procedure appeared as a CharString in a Type 1 +font, it was always called with the character name, never the character +code. + - The SubFileDecode filter didn't work with a non-empty EOD string +(went into an endless loop). (Probably a new bug in 2.8.) + - save/restore didn't properly restore the maxlength of a +dictionary, causing data to get smashed at random. (New bug in 2.9.) + - save didn't mark objects as old, so a nested restore had no +effect. (New bug in 2.9.2.) + - After returning from an OtherSubrs callback, op_type1_free +freed the saved interpreter state incorrectly. (New bug in 2.7.) + - Level 1 configurations didn't work because .makeoperator gave an +invalidaccess error. (New bug in 2.9.2.) + - ASCII85 string literals didn't work. (Probably a new bug in 2.8.) + - If the current global/local allocation mode was different at the +end of a file than at the beginning, an addressing fault could occur +(gs_unregister_root in gs_run_string). (New bug in 2.9.2.) + - After a setfileposition on a file open for reading, +fileposition would return an incorrect value, even though the stream +was actually repositioned properly. + +Brings the dictionary unpacking code for the DCT filters into line with +Adobe Technical Note 5116, which describes the Picky parameter for +DCTDecode and the NoMarker, Resync, Blend, Picky, and Relax parameters for +DCTEncode. + +Changes the .quit operator so that if given a negative argument, the +interpreter returns this as the error code, rather than e_Quit. + +Changes the Ghostscript integer version number from 100P+10S+T to +10000P+100S+T. + +Changes the default halftone screen for high-resolution devices, both +black-and-white and color. + +Library +------- + +Fixes bugs: + - The software floating multiply code used with USE_FPU=-1 only +worked on little-endian platforms. + - Specifying a left side bearing to .type1addpath produced an +inappropriate offset. + +Version 2.9.2-beta (1/2/94) +================== + +This version was distributed only to beta testers. It adds a garbage +collector and full local and global VM support. It is the first version +that sets languagelevel = 2, i.e., claims to be a Level 2 implementation. + +Documentation +------------- + +Fixes bugs: + - make.doc still referred to use_* variables in gdevx.c, and +use.doc didn't explain the use* X resources. + +Notes that -Olimit=1000 is needed to compile Ghostscript on AXP systems +under OSF/1 1.3. + +Utilities +--------- + +Fixes bugs: + - viewgif.ps did not work with interlaced images. + - font2c.ps omitted gsmemory.h from the #include list in compiled +fonts. + +Drivers +------- + +Fixes bugs: + - The MS Windows driver hadn't been updated to work with the +new additions to the gx_device structure. + - The BMP file driver wrote one scan line too many. + - The cdj driver omitted an important cast to int in the error +diffusion code (FSdither macro). + +Changes the SuperVGA drivers to recognize erasepage and reset the +color table, like the X driver. + +Adds some fragmentary code to begin implementing the PostScript fax +extensions. + +Platforms +--------- + +Fixes bugs: + - The procedure initializers for the MS Windows console I/O +were missing the new reset element. + - The makefile entry in bcwin.mak used -fdev rather than -iodev. + - The Borland C++ makefiles exceeded MS-DOS's line length limit if +the compiler files were in the standard Borland directory (BORLANDC). + - Some procedures weren't declared with prototypes in gp_vms.c. + - Some declarations had to be reordered to pacify the VAX compiler. + - Under MS Windows, Ghostscript didn't automatically de-iconify the +text window to display messages on an error exit. + - The Unix makefile rule for gconfig_.h used echogs rather than +./echogs. + - The Microsoft C makefile referred to an obsolete file gs.tr. + - gp_unifs.c used strpbrk and strrchr, which some systems lack. + +Updates the OS/2 code and documentation for compatibility with the current +Ghostscript version. + +Fonts +----- + +Fixes bugs: + - The X11 .pfa fonts replaced their .gsf requirements in the +fontmap, but not distributed with the previous (beta) release. + +Adds fontmaps appropriate for use with DEC Ultrix and OSF/1 systems. + +Interpreter +----------- + +Fixes bugs: + - 4-value entries in the Metrics dictionary were interpreted with +the width and side bearing interchanged. + - Objects large enough to require their own chunk were not freed +properly. + - The GS_FONTPATH scanner didn't deal with the possibility that +opening a file might fail. + - The interrupt and timeout errors incorrectly pushed an error +object on the operand stack. + - imagemask gave an error if it was invoked with a dictionary +argument with a current color space with more than 1 parameter. + - definefont insisted that a new font not have a FID entry. + - Some places didn't cast char to byte when needed. + - An extra element was left on the stack when substituting the +default font for a font whose file couldn't be found. + - The CCITTFaxDecode filter didn't allow the dictionary to be +omitted. (The Adobe documentation doesn't allow this, but Adobe +implementations do.) + - When the input came from a pipe (`-') switch, opening a filter on +currentfile that required more than 1 input byte to make progress would +cause Ghostscript to hang (in sreadbuf). + - The interpreter didn't call gs_set_lib_paths before executing a +compiled-in initialization file. + - A stream could be closed more than once. (New bug in 2.8.) + - The LZW decoder produced incorrect output if a code string was +too long to fit into a single output buffer. (New bug as of 2.8.) + +Implements a special check in def to allow construction of systemdict, +which is stored in global VM but references dictionaries in local VM. + +Implements additional Level 2 features: + - %null% and %ram% IODevices. + - startjob, exitserver. + - Local and global VM (finish). + - Garbage collection (for everything except names and strings). + +Moves the procedures for selecting paper size from systemdict to userdict. + +Sets languagelevel to 2 in Level 2 mode, since essentially all of +Level 2 is now implemented. + +Factors out the Level 1 extended color facilities (CMYK color and +colorimage) as a separate configuration feature. + +Adds some preliminary code to begin implementing the Adobe BCP and TBCP +communication protocols. + +Changes the implementation of save and restore so that the bookkeeping +structures are allocated in the new area, not the old. (This is an +internal change not visible at the PostScript level.) + +Library +------- + +Fixes bugs: + - gdevprn used some preprocessor macros in formal argument +lists that ansi2knr couldn't handle. + - pick_cell_size called gs_distance_transform with a 0 argument +that non-ANSI compilers didn't automatically promote to floating point. + - gs_screen_init called hypot with integer arguments that +non-ANSI compilers didn't automatically promote to floating point. + - Some places didn't cast char to byte when needed. + - The vx/vy origin adjustment for WMode=1 wasn't implemented. + - The pattern cache wasn't initialized properly. + - Composite fonts didn't properly decode strings that started with +an escape sequence, which have a special (undocumented) decoding rule, and +also didn't properly decode strings with multiple consecutive escape +sequences. + +Factors out the Level 1 extended color facilities (CMYK color and +colorimage) as a separate configuration feature. + +Version 2.9.1-beta (12/7/93) +================== + +This version was distributed only to beta testers. + +Utilities +--------- + +Adds a viewgif.ps utility to view GIF files. The current version does not +work with interlaced data, local color tables, or files containing more +than one image. + +Interpreter +----------- + +Fixes bugs: + - putinterval and copy didn't do the right thing if the source and +destination were aliases for overlapping sections of the same array or +string. + - The DCT filter stub didn't allow the dictionary to be omitted. +(The Adobe documentation doesn't allow this, but Adobe implementations +do.) + +Adds an optional dictionary argument to the LZWDecode filter, containing +InitialCodeLength, FirstBitLowOrder, BlockData, and EarlyChange entries. +Setting these parameters appropriately allows reading (non-interlaced) GIF +data directly. + +Library +------- + +Fixes bugs: + - setdash produced inverted output if the pattern had an odd +number of elements and the offset O had the property that L <= O mod +2*L, where L was the sum of the pattern elements. + +Version 2.9-beta (12/6/93) +================ + +Like 2.7, this version was created to satisfy a contractual requirement, +and will never be distributed to anyone other than the other party to the +contract. + +Documentation +------------- + +Notes that Ghostscript runs on IBM PCs and compatibles under DR DOS +6.0. + +Notes that Ghostscript will run on IBM PCs and compatibles with +Hercules display cards if you redirect text output to a file. + +Notes that the alternate DeskJet 500C driver (djet500c) does not work +on the 550C. + +Gives a list of system-specific directories where Type 1 fonts are +likely to be installed, as a suggested setting for GS_FONTPATH. + +Procedures +---------- + +Changes the distribution script so that it stores all text files in the +main source archive with Unix end-of-line conventions, but with DOS +end-of-line conventions in the MS-DOS-specific archive. + +Changes the MS-DOS, MS Windows, and OS/2 makefiles so that 486SX and 486DX +processors are different CPU_TYPEs. (The former, designated by +CPU_TYPE=485, does not include an on-chip FPU.) + +Adds a line to gs_init.ps which can be uncommented to select A4 as +the default paper size. + +Adds a definable CFLAGS macro to the makefiles, allowing -DA4 to +select A4 as the default paper size. + +Adds the H-P printer drivers to the standard Unix configurations. + +Utilities +--------- + +Fixes bugs: + - If there were no unencoded characters, prfont.ps would get +an error. + +Changes ansi2knr to accept a wider range of function declaration syntax, +and to not depend on any Ghostscript header files. + +Drivers +------- + +Fixes bugs: + - Several drivers (DigiFax, Epson LQ-2550, NEC P6) didn't handle +A4 paper width. + - The IBM ProPrinter wasn't being initialized properly. + - The Epson driver didn't work properly with compilers that +insisted on 'char' being a signed type. + - The Epson driver ignored its end_string argument, producing +incorrect end-of-page behavior on some printers. + +Adds new drivers: + - User-contributed drivers for Bellcore MGR (a window manager most +commonly used with OS-9) devices. + - A user-contributed driver for the CIF file format. + - A user-contributed driver for the HP 2563B line printer. + +Changes the LaserJet 2p, 3, and 4 drivers so they set the initial position +to (0,0) rather than (0,0.25"). (I don't remember why it was the other +way.) + +Implements the PageCount property in all drivers, not just printer +drivers. + +Introduces a new gx_tile_bitmap type, and changes the tile_rectangle +device procedure to take it in place of gx_bitmap. THIS IS A +NON-BACKWARD-COMPATIBLE CHANGE. However, it only affects devices that +implement their own tile_rectangle procedures, of which there aren't very +many. + +Platforms +--------- + +Fixes bugs: + - The VMS module lists referred to SDCTD and SDCTE instead of +SDCT. + - The Unix install script tried to install the non-existent file +readme.doc. + - Microsoft C does something bizarre with empty macro parameters, +which caused a problem with the gs_struct_type_... macros. + - The Unix platforms didn't automatically handle the presence +or absence of . + - The DEC Alpha OSF/1 1.3 library lacks `const' in the prototype +for popen, which requires a workaround. + - The DEC Alpha OSF/1 1.3 X Windows library uses `private' as a +member name. + +Splits off gp_unifs.c, containing code common to "Unix-like" file systems. + +Adds a user-contributed OS-9 platform. + +Interpreter +----------- + +Fixes bugs: + - The currentfile cache wasn't updated properly if an executable +file appeared in the middle of a procedure. In particular, eexec-encoded +.PFB fonts often didn't work. + - There was an extraneous `goto top' in scfd.c. + - An integer constant overflowed in iname.c. + - -2147483648 (i.e., -1 << 31) was converted to a float. + - eexec didn't skip the first 4 characters correctly if they were +split across a buffer boundary. + - The font/matrix pair cache didn't properly free entries with only +an XUID that was being deallocated. + +Implements additional Level 2 features: + - Patterns, makepattern, setpattern. + - IODevice resource, setdevparams, currentdevparams. + - OutputDevice resource, setpagedevice, currentpagedevice. + (Partially implemented.) + +Adds a new type t_struct to handle miscellaneous types that are allocated +as objects and that the interpreter doesn't handle specially, and changes +condition, fontID, gstate, lock, and save types to use t_struct. (This is +an internal change, not visible at the language level.) + +Moves the maxlength of a dictionary to its own ref, eliminating the "size +of integer" hack. (This is an internal change, not visible at the +language level.) + +Adds the last OS error number to the error printout. + +Removes the obsolete framedevice operator. + +Implements resetfile (the only Level 1 operator not yet implemented!). + +Changes the name of the getdevice operator to .getdevice. + +Library +------- + +Fixes bugs: + - A couple of necessary casts from char * to byte * were omitted. + - A Sun compiler required an extra cast to (void *) in the e1 +macro in clip_rect_enum_ptrs in gxcpath.c. + - The gx_dc_ procedures defined in gxdraw.c weren't marked as +'private'. + - The number of "on" pixels in a halftone cell sometimes varied by +1 from cell to cell. + - Mapping a gray level to CMYK didn't subtract it from 1 (to +produce the K component). +* - charpath took hints into account. + +Shuffles the order of some declarations to pacify the VMS C compiler. + +Version 2.8-beta (11/10/93) +================ + +This version was distributed only to beta testers. It adds Type 0 font +support. It also includes extensive redesign of streams (to eventually +support procedure streams) and device properties (to eventually support +get/setpagedevice and get/setdevparams). + +Documentation +------------- + +Notes the change in X11 foreground/background handling. + +Changes README so it no longer claims that Ghostscript works with X11R3. + +Notes (in devs.mak) that the cdjmono driver is the best one to use for the +DeskJet 510. + +Procedures +---------- + +Fixes bugs: + - echogs wasn't always invoked with ./ on Unix systems. + +Changes the file name unix-ansi.mak to unixansi.mak, so it can be created +on a MS-DOS system. + +Adds a new "feature", ccinit.dev, which compiles and links the +initialization files (gs_*.ps) into the executable, just as ccfonts.dev +compiles and links fonts. If ccinit and ccfonts are both selected, the +only external file needed at run time is Fontmap. Note that you must have +a working version of Ghostscript already in order to create a version that +uses the ccinit feature, just as for ccfonts. + +Utilities +--------- + +Fixes bugs: + - the ps2image utility didn't put a %! on the first line of the +output. + +Drivers +------- + +Fixes bugs: + - The Hercules display driver didn't include definitions for +outport2 and PAGE_HEIGHT_INCHES, which it uses. + - The BGI driver didn't call setactivepage or setvisualpage, +which it needs to do in general. + - The Apple DMP driver declared dmp_print_page rather than +appledmp_print_page, causing a compilation error. + +Changes the X11 driver so that it doesn't use the default foreground and +background colors: you must set foreground and background explicitly for +Ghostscript if you want them to be other than black and white +respectively. + +Adds new user-contributed drivers for: + - The StarJet 48 inkjet printer; + - The Linux VGALIB display interface. + - OS/2 Presentation Manager. + +Changes the margins of the Epson driver to 0.2, 0.0, 0.0, 0.0, which +more accurately reflect the printer's capabilities. + +Changes the get_props and put_props device procedures to take property +list "objects" with a procedural interface, rather than a data structure +interface. THIS IS A NON-BACKWARD-COMPATIBLE CHANGE. It affects all +get_props and put_props procedures. Fortunately, there were only a few +devices that implemented their own get_props and put_props procedures (the +H-P color printers, and the three window systems -- X Windows, MS Windows, +and OS/2 PM). + +Platforms +--------- + +Fixes bugs: + - The meaning of the -p switch for the Watcom compile-and-link +program was changed between Watcom C/386 versions 8.5 and 9.5, causing the +make process to malfunction. + - The SCFTAB and SCFDTAB modules were omitted from the VMS link +list. + +Adds user-contributed code for OS/2. + +Removes the assumption that an 80486 CPU implies the presence of hardware +floating point, since the 486SX and Cyrix 486SLC don't have it. + +Fonts +----- + +Fixes bugs: +* - The GS_FONTPATH scanner didn't recognize .PFB fonts beginning +with %!PS-AdobeFont. +* - The GS_FONTPATH scanner often didn't recognize .PFB fonts at all. + - Type 1 fonts always set the line join, line cap, and miter limit +to known values, rather than using the current values. (Using the current +values doesn't make much sense, but it's apparently what the Adobe +implementations do.) + - DISKFONTS didn't work, because of the change in the Ghostscript +fonts to do a systemdict begin/end (in version 2.7.1). + +Interpreter +----------- + +Fixes bugs: + - == didn't produce exactly the same output as the Adobe +interpreters. (Some automated debugging and testing programs care.) + - The CCITTFaxEncode filter could get caught in an infinite loop, +because it failed to mask a byte datum when scanning for runs of black +pixels. + - The write operator gave an error for values outside the range 0 +to 255, rather than just using the low-order 8 bits. + - Some applications call a statusdict procedure named +setresolution without checking first whether it is present; Ghostscript +didn't provide one. + - Reading from a closed stream caused an error instead of +returning EOF. + - Input streams didn't close automatically at EOF. + - findfont was defined as an operator, not a procedure. + - closefile on a closed file gave an error. (It isn't obvious +that the Adobe documentation specifies that it shouldn't, but that's what +Adobe says they do.) + - The LZWDecode filter didn't handle codes representing strings +longer than the buffer size correctly. + - The LZWDecode filter only allowed 4095 codes to be used, rather +than 4096. + - The rand operator produced an infinite string of zeros if +given 0 or 0x7fffffff as the seed. + - When a CDevProc procedure was called, there was an extra +copy of the character name on the operand stack below the operands of +CDevProc. + +Replaces all stream implementations with new ones designed to allow +interruption at arbitrary times. ****** The 2-D case of CCITTFaxEncode +hasn't been converted (but it probably didn't work before, either). + +Implements additional Level 2 features: + - Type 0 (composite) fonts. + +Adds an eexecEncode filter. + +Implements setcolorscreen, which was accidentally omitted from 2.7. + +Library +------- + +Fixes bugs: +* - In colorimage, if the color space of the image was different +from the current color space, and the first data values on a scan line +were zeros, the wrong color could result. + - The new flatness testing algorithm could overflow, producing +straight lines or obvious polygons instead of curves. + - Images could fail to display pixels after the first non-blank +pixel on a line if halftoned color was required. (This bug was probably +introduced in 2.7.) + - Interpolation between transfer map entries didn't work, because +of a rounding/truncation bug in frac2bits (bug introduced in 2.7.1.) + - cshow did an extra grestore at the end. + +* Implements a hack to slightly displace 1-bit-wide or -high images. This +is necessary to work around a bug in TeX (or dvips?), which uses such +images to draw horizontal and vertical lines without positioning them to +ensure that they cover device pixel centers. + +Adds support for composite fonts (no new client procedures). + +Version 2.7.2-beta (10/11/93) +================== + +This version was distributed only to alpha testers. + +Utilities +--------- + +Fixes bugs: + - prfont.ps didn't print unencoded characters. + +Improves mergeini.ps to remove embedded comments. + +Interpreter +----------- + +Fixes bugs: + - An error occurring within the scope of an internal .stopped +didn't pop the command and error name off the stack. +* - The = and == procedures weren't re-entrant. + +* Adds a .writecvs operator that does a cvs to an internal string followed +by a writestring. + +Library +------- + +Fixes bugs: + - grestore freed the path and the clip path in an order that +was likely to lead to memory sandbars. + - moveto + closepath didn't actually close the path. + - moveto + reversepath produced an empty path (no moveto). + - moveto + closepath + reversepath produced an extra lineto. + - reversepath didn't set the current point to the end (i.e., the +former beginning) of the last subpath. + +Adds a "planar" memory device. + +Version 2.7.1-beta (10/4/93, not distributed to the public) +================== + +Like 2.7, this version was created to satisfy a contractual requirement, +and will never be distributed to anyone other than the other party to the +contract. + +Documentation +------------- + +Documents the GS_OPTIONS environment variable. + +Adds a summary of all environment variables to the documentation +(use.doc). + +Documents the existence of a third free viewer built on Ghostscript. + +Utilities +--------- + +Fixes bugs: + - wrfont didn't wrap a systemdict begin / end around the body of +the font. + - wrfont wrote out the Symbol and ZapfDingbats encodings in a way +that only worked if the encoding was known by name. + +Changes bdftops to include an XUID if desired. + +Changes bdftops so that it uses 'show' for unknown ligatures, rather than +executing the characters as subroutines; this makes such ligatures work +properly with xfonts. + +Drivers +------- + +Fixes bugs: + - The PCL drivers sent a printer reset (E) at the beginning +of every page, instead of only before the first page. + - The PCX driver didn't round up the scan line width in the +header, even though it produced scan lines with the correct (rounded) +number of bytes. + +Adds a new map_rgb_alpha_color procedure. This is a backward-compatible +change; this procedure defaults to calling map_rgb_color. + +Platforms +--------- + +Fixes bugs: + - On Unix platforms, the value of the TEMP environment variable +had to end with a '/'. + - On MS-DOS systems, printer output to devices other than PRN +(specifically, LPTn) didn't put the device into binary mode. + +Adds FPU_TYPE to the Unix makefiles, with a default value of 1. + +Removes the mention of Xmu linking problems on the SunOS platform, +since the problem no longer exists. + +Changes the order of X Windows libraries from Xt X11 Xext to Xt Xext X11. +This makes the OSF/1 linker happier. + +Fonts +----- + +Fixes bugs: + - All the fonts originated by Aladdin, and the shareware fonts, +had UniqueIDs in the 4xxxxxx range, which is only supposed to be used for +limited-distribution fonts. +* - When Ghostscript loaded a font, it pushed a scratch dictionary +on the dictionary stack, rather than userdict. (Note that this fix also +requires fixing the fonts to include a protective systemdict begin / +end; see below.) +* - When loading a font failed, Ghostscript didn't check the font +name against the default font name properly. + - Ghostscript's own fonts didn't include a systemdict begin / +end to guard against redefinition of names used in the reading +procedures (e.g., index). +* - When Ghostscript scanned a .PFB font to get the FontName, it +didn't skip over the 6-byte header, which could cause confusion or a +syntaxerror. + - Loading a .PFB font that left extra information on the +operand stack didn't work. + +Changes the ZapfDingbats font to use DingbatsEncoding rather than include +a copy of the encoding in itself, if DingbatsEncoding is known. Changes +the Symbol font similarly. + +Removes eexec encryption from the 4 URW fonts, so they will work with +DISKFONTS. + +Adds shareware Hiragana and Katakana fonts (Calligraphic-Hiragana and +Calligraphic-Katakana, by Kevin Hartig). + +Adds GS on the end of the family names of all of Aladdin's own converted +fonts. + +Replaces many of the Hershey fonts with new ones (mostly Type 1) created +by Thomas Wolff, who added accents, accented characters, and other +non-alphabetics. These too now have proper UniqueIDs. + +Interpreter +----------- + +Fixes bugs: +* - imagemask interpreted the Decode array incorrectly (inverted). + - Running out of memory when constructing a path incorrectly +signalled a limitcheck rather than a VMerror. + - restore didn't purge uncached scaled fonts properly. + +Adds alpha (opacity) to the graphics state, and setalpha and +currentalpha operators. + +Redefines erasepage in terms of a new .fillpage operator that fills +the current page with the current color and then does a sync_output. + +Redefines setdevice and putdeviceprops in terms of new .setdevice and +.putdeviceprops operators that return a boolean indicating whether the +page needs to be erased. With this change, operators that erase the page +always call erasepage at the interpreter level rather than calling +gs_erasepage directly. + +Library +------- + +Fixes bugs: + - The null device allowed its size to be reset. + - clippath didn't establish a current point if the clipping +path was empty. +* - The Type 1 font interpreter (gs_type1_interpret) flattened +curves even if it was being invoked for charpath. + - Colored halftones usually didn't come out with the correct +phase, and had several other problems. + - A show or charpath within a BuildChar procedure didn't work. + - Accented characters composed with seac used the base +character width instead of the composed character width. (The Adobe +documentation says these must be the same, but some commercial fonts +don't obey this.) + - setcurrentpoint in the accent of a character composed with +seac didn't take the accent's displacement into account. + +Adds an alpha (coverage) value to the graphics state, and +gs_setalpha/currentalpha procedures. Currently Ghostscript just passes +the alpha value to the driver; it doesn't attempt to emulate alpha +handling if the driver doesn't support it. + +Redefines gs_erasepage to call gs_fillpage. + +Bypasses the fill code if the clipping box is empty. This makes a big +difference for stringwidth, and doesn't hurt anything else. + +Changes frac_1 from 0x7fff to 0x7ff8. This allows exact representation of +practically all useful fractions, since this number (32760) is +2*2*2*3*3*5*7*13. + +Changes float to double in several matrix routines for better accuracy. + +Adds new device properties to implement the deviceinfo operator: +Colors, GrayValues, RedValues, GreenValues, BlueValues, ColorValues. +Also adds HWBitsPerPixel and HWColorMap. + +Changes the sorting algorithm for halftones to use qsort instead of +special code. + +Changes the Type 1 interpreter so that it uses the current point, rather +than (0,0), as the character origin. + +Version 2.7-beta (9/20/93, not distributed to the public) +================ + +This is the first of a series of beta-only versions planned for release +between 2.6.n and 3.0. This version, in particular, was created to +satisfy a contractual requirement, and will never be distributed to anyone +other than the other party to the contract. + +Documentation +------------- + +Fixes bugs: + - The "HP XLFD extensions" to X11R5 are not specific to H-P +platforms. + - The configuration generation script used rm rather than rm -f. + - gs.1 was installed in $(docdir) rather than $(mandir); +$(mandir) wasn't defined. + - ansi2knr.1 was installed in $(docdir), which was +inappropriate because ansi2knr itself wasn't installed anywhere. + +Moves documentation for versions 2.4.x and 2.5.x to history.doc. + +Moves the documentation on how to add devices to the configuration +from devs.mak to make.doc. + +Changes the name of readme.doc to current.doc, since the presence of +two "readme" files was confusing to users. + +Documents how to use the Microsoft Windows PostScript printer driver +to convert TrueType fonts to Type 1 fonts embedded in the document. + +Corrects several errors in the documentation of the get_bits driver +procedure. + +Documents the fact that X11R3 is no longer supported. + +Removes the last references to "Ghostscript" from the comments in the +gs_*.ps files. The only remaining reference, other than the boilerplate +comments at the beginning of each file, is in the message at the end of +gs_init.ps. + +Documents the use of WMAKEL rather than WMAKE with the Watcom compiler. + +Procedures +---------- + +Fixes bugs: +* - The Unix install script used gs rather than $(GS) as the name of +the executable. +* - The Unix install script didn't copy gs_dbt_e.ps to $(gsdatadir). + - genconf.c used ps2 as a variable name; ps2 is a predefined +preprocessor symbol in the VSC compiler used by IBM. + - @-expansion didn't interact properly with -- and -+. + - The Unix install script didn't copy COPYING to $(docdir), +and copied README to $(gsdatadir) rather than $(docdir). + - ps2ascii used /bin/sh -f, which is an incorrect flag. + +Removes all uses and mentions of USG (a now-obsolete GNU convention) +as a synonym for SYSV. + +Removes filter.dev and dps.dev from FEATURE_DEVS if level2.dev is +included, since they don't add anything beyond level2.dev. + +Changes the ccgs script to explictly remove the old .o file before +doing the mv, for the benefit of people who have changed mv to prompt +before overwriting. Changes the configuration script to use rm -f +for the same reason. + +Changes the -Z switch so an empty list of options does nothing, rather +than turning on all options. + +Adds a -@ switch which is like -- and -+ except that it does +@-expansion of arguments. + +Changes genconf so it takes patterns from the command line that describe +how to write the linker control files, rather than having the patterns +built in. + +Changes -d and -D so that if no value is supplied, the default is +true rather than null. + +Utilities +--------- + +Fixes bugs: +* - The ps2ascii script still referenced ps2ascii.ps under its +old name gs_2asc.ps. +* - ps2image.ps had a 'pop' missing in the written-out +definition of 'max' in the boilerplate code it put at the beginning +of compressed files. +* - ps2image.ps got a typecheck if a scan line had no repeated +data in it anywhere. + - wrfont.ps didn't handle CharStrings or Subrs that weren't +strings. + - mergeini.ps produced an init file that incorrectly +attempted to load the Symbol and Dingbats encodings dynamically. + +Removes the gsview.bat file, since it was confusingly named and not +generally useful. + +Changes bdftops back to using encrypted CharStrings, for compatibility +with Adobe interpreters, but also changes lenIV to 0, to save a little +more space. + +Changes the traceop utility so it makes traced operators appear to be +operators, and so it will replace a definition in systemdict if explicitly +requested to do so and systemdict is writable. + +Adds a printafm utility for printing the metrics of fonts in AFM format. + +Drivers +------- + +Fixes bugs: + - The cdj driver was missing a few type casts that were needed to +satisfy pedantic compilers. + - For banded devices, many of the non-displaying target routines +were getting called with the original device as the first argument, not +the target device. (This didn't make any difference in practice, because +gdev_prn_open explicitly copied the non-rendering procedures back into the +procedure vector.) +* - The X driver didn't catch and discard bogus errors on +XFreeColors, which faulty servers generate. +* - The X driver gave up on color allocation too easily. +* - The X driver dynamic color table size could become negative. +* - x_lookup_font could return platform fonts of very small sizes, +which have very inaccurate metrics. +* - The ESCP/2 driver was incorrectly named gdevescp2 in devs.mak. + - The Apple DMP driver used #if 0 / #endif instead of comment +brackets, and was incorrectly named "dmp" instead of "appledmp" in +the source code. +* - The X driver didn't free dynamic colors at the start of each page. +* - The X driver didn't bind foreground/background defaults tightly. +* - The X driver didn't check for GHOSTVIEW_COLORS properly. +* - The X driver freed too many colors if an allocation request failed. +* - The X driver didn't check return value of gs_malloc for being NULL. +* - The DeskJet/LaserJet driver used an incorrect command for +end-of-page. +* - The DeskJet/LaserJet driver incorrectly reset the printer at the +beginning of every page. +* - The PCX driver put an old version number in the header, and +didn't pad scan lines to an even number of bytes. + - The BMP driver used a variable named `quad', which is a +reserved word on some platforms. +* - The TIFF driver didn't handle A4 or B4 size paper correctly. +* - The X11 driver incorrectly demanded the Xmu library, which was +not needed and which caused link errors on some versions of SunOS. +* - X11 font matching scheme was too loose, causing overlaps and +other problems. +* - X11 Font Extensions (rotated and mirrored fonts) did not work +properly on NCD terminals. +* - When freeing the rgb cube/gray ramp, the parameters to gs_free() +did not exactly match the parameters to gs_malloc(). +* - Ghostscript failed to warn the user when it could not allocate +the original color cube/gray ramp and dropped back to a smaller +cube/ramp, or from color to mono. +* - x_release could cause Ghostscript to fail if a font was freed +after the device was closed. + - The X driver continued to ask the server for colors even after a +request failed, causing colored images to display very slowly. + +* Adds a pcxgray driver to provide 8-bit gray scale output in PCX format. + +Adds a pcx24b driver to provide 24-bit RGB color PCX output. + +* Adds a LaserJet 4 driver. + +Adds a user-contributed driver for the DEC LA70 (very similar to the LA75). + +Substantially improves the performance of the PxM drivers by eliminating +an unnecessary copying step and by writing each scan line with a single +fwrite when possible. + +Moves the gray-scale and 24-bit RGB device color mapping routines to +gxcmap.c from gdevpcx.c and (nowhere). + +Allows window granularities smaller than 64K in the VESA driver. + +Changes the LaserJet margins again. + +Platforms +--------- + +Fixes bugs: + - Platforms where stat doesn't return a st_blocks value +computed the block count wrong. + - In gp_vms.c, the call on SYS$FILESCAN needed two uint *s +rather than a long * and a struct *. +* - The VMS script files referenced IBSCAN instead of ISCAN2, +and omitted GDEVXXF. +* - The UUENCODEd icons for the MS Windows platform were omitted +from the fileset. +* - On MS-DOS systems, filenameforall didn't interpret * alone +as a pattern matching all files. + +Adds wildcard matching capability to filenameforall under Unix. + +Removes gp_file_status from the platform interface, since all +platforms provide identical stat calls in the C library. + +Adds DesqView/X (using djgcc and go32) as a platform. + +Removes the S3 driver from the standard PC configurations. + +Adds documentation for compiling Ghostscript on the Intergraph Clipper. + +Updates the documentation to add a better list of X Windows font +names for the Sun platform. + +Fonts +----- + +Creates an external file (gs_dbt_e.ps) with the ZapfDingbats encoding +(actually in 2.6.1, but not documented there). + +Changes the names of the Cyrillic fonts to Shareware-Cyrillic-Regular +and Shareware-Cyrillic-Italic, keeping Cyrillic, Cyrillic-Regular, +and Cyrillic-Italic as aliases. + +* Removes the requirement that the FontName in the font file be the same +as the name in Fontmap. (This requirement led to the need for aliases, +and was extremely confusing to users.) + +* Adds a GS_FONTPATH environment variable containing a list of directories +that should be scanned automatically for fonts. + +* Gets rid of the Ugly font, and changes the default to the IBM Courier +font, which is freely distributable. + +Interpreter +----------- + +Fixes bugs: + - cvs didn't check for stack underflow. +* - zht2.c didn't include alloc.h. +* - execstackoverflow cleared the e-stack instead of just +cutting it back. + - if and ifelse incorrectly reported typecheck instead of +stackunderflow. + - Copying a dictionary could alter some items even if a later +item causes an invalidaccess error because of an attempted store of a +local object into global VM. + - bitshift and cvrs assumed that longs occupied 32 bits. +* - exitserver didn't check the password, and always succeeded. + - Font loading didn't suppress all output messages if QUIET +was set. +* - The interpreter incorrectly pushed its exit procedure on +the e-stack if it was called again after an interrupt. +* - The interpreter didn't treat timeout like interrupt in +terms of re-executing the current operation. +* - `show' operators popped their operands before they were +sure they wouldn't be interrupted. +* - rotate with a matrix operand didn't check for multiples of +90 degrees. + - In the system name table, ge was misspelled eg, and +pathforall was misspelled pathfoall. +* - file_close_file attempted to free the buffer even if it was an +externally supplied string (specifically, the argument of gs_run_string). + - setprintername (in gs_statd.ps) set printername rather than +.printername. + +Implements additional Level 2 features: + - Indexed color space with lookup procedure. + - sethalftone, except for the transfer function override, + and currenthalftone. + +Implements OtherSubrs for indices greater than 3 (required for +MultiMaster fonts). + +Implements black generation and undercolor removal. + +Changes `store' from a C procedure to a PostScript procedure. + +Changes idiv back so it requires integer operands, per the Adobe +documentation but not per some old Adobe interpreters. + +* Adds many new paper sizes to gs_statd.ps. It now includes ISO a0-a10 +and b0-b10, and CAD sizes archA-archE. + +Implements `status' for non-%os% files. (This is currently a no-op, +but the framework is there.) + +Changes the error handler so it normally uses = rather than == to print +the operand stack, to avoid recursive errors. + +* Adds time slicing capability to the interpreter. + +Implements setcolorscreen/currentcolorscreen. + +Library +------- + +Fixes bugs: +* - Rectangles with vertices specified in clockwise order were +drawn as 0-width lines. +* - The string matching function reported that 'abcdefg' +matched the pattern 'abcde'. +* - The bounding box of non-rectangular clipping paths was not +being marked as valid, so cached characters would simply get +discarded as being outside the bounding box. + - erasepage filled the page with the device's white color, +not with gray level 1 passed through the transfer function. +* - Colors with equal R/G/B or C/M/Y components were rendered +incorrectly if the 3 or 4 transfer functions were not all the same. +* - Because of a bug in rc_unshare, using CIE color would give +random errors (such as /invalidaccess in --for--). +* - setbbox didn't round the coordinates properly, which could +cause erroneous rangecheck errors with coordinates on the edge of the +box. +* - Color halftones "flipped over" at the 50% point, inverting +foreground and background. + - Quite a few places assumed that longs occupied 32 bits. +* - kshow passed an incorrect c1 value to the procedure. + - The debugging code in update_x_list in gxfill.c didn't take +into account the possibility that the active line at x_first might be +deleted. + - gx_image_cached_char called the xfont render_char procedure an +extra time if it failed with required=0 and succeeded with required=1. +(This was just a small inefficiency, not a logic bug.) + - Non-rectangular clipping regions weren't computed correctly, +because accum_add_rect didn't handle overlapping rectangles. + - Drivers didn't report file system errors (such as file system +full) as an ioerror. +* - setdevice didn't reset the charpath and setcachedevice flags. + - The Zortech compiler produced wrong code for the uid_equal +macro; uid_equal is now a procedure. + +Passes OtherSubrs arguments back to the caller correctly for indices +greater than 3. + +Implements black generation and undercolor removal. + +Removes gdev_mem_ensure_byte_order, which was no longer used or useful. + +Removes gstdev.c (device tracing), since it hasn't been used in a +long time and is of little value given a reasonable debugger. + +Changes the interface to the xfont char_metrics and render_char +procedures to allow them to return 1. + +Changes 32-bit memory devices so they use CMYK color mapping rather +than RGB mapping with an unused byte. + +Implements gs_setcolorscreen/currentcolorscreen. + +Implements Level 2 halftones, except for the transfer function override. + +Implements a hack to make zero-width rectangles display as one pixel wide, +to work around a bug in the Microsoft Windows PostScript driver. +Currently the hack only works for vertical lines, not horizontal ones. + +Version 2.6.1 (5/28/93) +============= + +This is primarily a bug-fix release for 2.6, with a couple of minor +additions. + +Documentation +------------- + +Adds proper `man' pages ansi2knr.1 and gs.1. + +Procedures +---------- + +Fixes bugs: + - The Unix makefile produced an incorrect linker command if +EXTRALIBS was not empty. + - The Unix install commands didn't copy devices.doc, +ps2epsi.doc, and xfonts.doc to the documentation directory. + - echogs.c didn't include , which is needed for +time_t on some systems. + - malloc_.h used rather than on +NeXTStep systems. + +Changes the configuration procedure to use a C program rather than +complex shell scripts. + +Utilities +--------- + +Fixes bugs: + - The boilerplate produced by ps2image used the 'max' +operator, which is not a standard PostScript operator. + - The winmaps.ps utility had 'floring' instead of 'florin' in +the OEMEncoding table. + - quit.ps was omitted from the PC distribution. + +Changes the name of the dicttomark procedure to .dicttomark. + +Renames gs_2asc.ps as ps2ascii.ps, so it matches the names of the +script files. + +Drivers +------- + +Fixes bugs: + - The pbmraw driver was writing out RGG instead of RGB values. + - The X11 driver used NULL in a place where it should have +used None. + - For multi-file output, the GIF driver didn't write a header +at the beginning of each file. + - The Epson driver didn't honor the -A4 compilation switch, +didn't put (0,0) at the physical corner of the page, and was too +liberal about using tabs instead of spaces. + +Replaces the color handling algorithms in the X Windows driver with +new, much better ones. + +Makes the PC display drivers recognize the -A4 compilation switch, +like the printer drivers. + +Adds new user-contributed drivers: + - A driver for Epson printers that use the ESC/P 2 control +language, such as the Stylus 800. + - A driver for the Apple Dot Matrix Printer and Imagewriter. + +Adds a new get_xfont_device driver procedure. This is a +backward-compatible change, since there is a sensible default. + +Platforms +--------- + +Fixes bugs: + - On VMS, gconfig.h didn't have #include "gsconfig.h" as its +first line. + - gconfig.c compiled incorrectly on the RS/6000 because the +compiler evaluated a constant of the form (x< +rather than install . + +Adds a GS_OPTIONS environment variable that acts like an implicit @-file +at the beginning of the command line (i.e., may contain switches and +initialization files). + +Renames sym__enc.ps as gs_sym_e.ps. + +Adds a user-contributed shell script for using Ghostscript with an +H-P printer spooler. + +Adds level1.ps to the set of installed utility files. + +Extends the TEMP environment variable (the directory for scratch +files) to work on Unix as well as MS-DOS. + +Changes the MS Windows makefile to generate gswin.exe rather than +gs.exe, and the Watcom makefile to generate gs386.exe. + +Moves the "product" string from gs_init.ps to iinit.c. + +Adds a GS macro to the makefiles, to allow choosing the name of the +executable. + +Utilities +--------- + +Fixes bugs: +* - font2c did the wrong thing (still) for fonts that didn't +use StandardEncoding, ISOLatin1Encoding, or SymbolEncoding. +* - impath.ps had a fatal bug (wrong operand order for +charstack_write) that caused bdftops to fail. + - gslp didn't wrap or truncate lines. + - gslp didn't handle tabs in a second or subsequent column +properly. + - The definition of ashow in gs_2asc.ps incorrectly undid the +increment following the last character. + - The definition of awidthshow in gs_2asc.ps failed to pop +two entries from the stack, and also tested the character against the +wrong value. + +Adds a shell script (sysvlp.sh) that interfaces Ghostscript with the +System V 3.2 lp interface. + +Adds ps2ascii and ps2epsi script/batch files. + +Adds a new utility, mergeini.ps, for concatenating all the +Ghostscript initialization files into a single file, optionally +removing comments and blank lines. + +Adds new switches to gslp: + -q: suppress all printed output. + --detect: check whether the file begins with %!, and if so, + interpret it directly as a PostScript file. + --first-page : replaces the former -P switch. + --last-page : replaces the former -Q switch. + --(heading|footing)-(left|center|right) : define + headers/footers. # inserts the page number. + --margin-(top|bottom|left|right) : define margins. + --spacing : for double, triple, etc. spacing. +Also makes gslp ignore all the enscript flags it doesn't implement. + +Adds an option to wrfont.ps to do encryption at read-in time. (This +allows much better compression of the standard Ghostscript fonts.) +Changes bdftops to use this option. + +Changes gslp to accept wild cards in file names. + +Replaces landscap.ps with a new one contributed by a user. + +Changes the compression scheme used in ps2image to a much more +effective one. Writing images is much slower than with the previous +scheme, but reading is not. + +Platforms +--------- + +Fixes bugs: + - SCFDTAB and SCFTAB were omitted from the VMS module lists. + - Function prototypes were not being used with the Watcom +compiler. + - On MS-DOS platforms, if the value of the TEMP variable had +a trailing : or \, Ghostscript appended a \ anyway. + - Under Windows, changing the size or resolution of the image +closed and reopened the window. + - Ghostscript would not build correctly with the Watcom compiler +if DOS4G=quiet was not set, because the DOS4GW copyright message was sent +to stdout. +* - Finally gets Ghostscript to run properly on the RS/6000, by +adding a compiler bug workaround to arc_add and arc_either. +* - Finally gets Ghostscript to compile properly on Sun SPARC +systems, by adding a compiler bug workaround in scan_number. + +Changes the default MS-DOS configuration from 8086/8088 to 80286. + +Adds all the SuperVGA drivers to the BC++ and Watcom executables +(except for the VESA driver in the Watcom executable). + +Adds a makefile (msc.mak) for the Microsoft C/C++ 7.0 platform. This +is currently a MS-DOS, not a MS Windows, platform. + +Changes gp_enumerate_files_init so it takes a gs_memory_procs *, not +separate proc_alloc_t and proc_free_t arguments; also, it must +enumerate precisely the requested set of files, not a superset. THIS +IS A NON-BACKWARD-COMPATIBLE CHANGE. It affects all gp_*.c files. + +Adds the P*M drivers and bit.dev to the standard configuration on +Unix platforms. + +Changes the Watcom makefile so it uses the WATCOM environment variable (by +default) as the base directory for the Watcom executables. + +Adds the MS Windows COMMDLG.DLL and SHELL.DLL files to the set of +files incorporated in GSEXE.ZIP, since the new MS Windows code uses +them, and they aren't provided with Windows 3.0. + +Makes major revisions to the MS Windows platform and driver code, to +support the gsview front end, and also to remove the dependence on the +Borland EasyWin library. NOTE: Compiling the MS Windows code now requires +Borland C++ 3.1 (not 3.0). + +Changes time_.h so that Ghostscript will compile and run on A/UX. + +Changes the MS-DOS implementation of file enumeration so it always +treats \s in the file name as literal characters, not escapes, unless +there are two \\s in a row. This does the most sensible thing given +the DOS file naming conventions. + +Adds a %pipe% file device under Unix. + +Adds a makefile for Watcom C under MS Windows. This is very preliminary; +in particular, NO display output is supported. + +Fonts +----- + +Fixes bugs: + - fonts.mak referred to ncri and puti rather than ncrri and +putri. + - cyr and cyri had the wrong protection. + - The Hershey fonts left the font on the stack when they were +loaded. +* - The FontName of an aliased font was the original FontName +from the file, not the alias. +* - Fontmap.BTS had incorrect entries for AvantGarde-Demi and +AvantGarde-DemiOblique. + - Ghostscript pushed userdict, rather than an empty writable +dictionary, onto the stack when loading a font, leading to name clashes. + +Adds a new cfonts.mak with a full set of rules for compiling all the +standard Ghostscript fonts (except the Hershey fonts) into C. + +Adds UniqueIDs to the Hershey fonts, and removes the UniqueIDs from +the Hershey entries in the Fontmap. + +Adds a new Fontmap for VAX/VMS with DECWindows/Motif. + +Changes MakeHersheyFont so it takes the encoding as an additional +parameter, and changes the Hershey-Symbol font to use SymbolEncoding. + +Drivers +------- + +Fixes bugs: + - The !@*&^%#@$ PCL drivers *still* didn't do the right thing +about vertical spacing: the *p+Y command works on all PCL 3, +4, and 5 printers *except* the LaserJet IIp. + - The cdj driver used recursive macros (height, t_margin, +b_margin) that not all compilers handled correctly. + - The djtc driver used some assignments including =*, which +some compilers dislike. + - The S3 driver wouldn't compile correctly with the Watcom +compiler. + - The makefile entry for the S3 driver was wrong. + - The SuperVGA drivers returned an error, rather than using +the highest available resolution, if a too-high resolution was +requested. + - The GIF driver produced an incorrect header for images +wider or taller than 32K pixels. + - The GIF driver wasn't able to handle multi-page documents +correctly. + - The margins on the DeskJet were still not correct. + - Some ANSI C compilers rejected a complex expression in +gdevpccm.c. + - Printer drivers didn't recover cleanly from problems in +opening the scratch files. + - The BJ-10e driver used the same name `out' for a label and +a variable. + - The SCO ODT compiler couldn't handle sizeof(ppdev->fname). + - The Epson driver used the wrong value for ESC in the +initialization string. + +Adds new drivers: + - Drivers to produce MS Windows .BMP format output. + - A new ATI Wonder display driver (800x600, 16 colors) and a +1024x768 mode for the existing driver. + +Adds new user-contributed drivers: + - A driver for the Tektronix 4693d color printer. This carries a +university copyright. + - A driver for the SPARCprinter. + - A driver for the Canon BJ200 printer. + - A driver for the IBM ProPrinter. + - A driver for the DEC LJ250 printer, which has a +PaintJet-compatible mode. + - A replacement driver for the Sony NWP533. + - A driver that writes TIFF/F (Group 3 fax) files. This carries +an external copyright. + - A driver for the C.Itoh M8510 printer. + - A driver for the Okidata MicroLine 182 9-pin dot-matrix printer. + - A Hercules Graphics driver. + - A driver for printers under MS Windows. + - A driver for direct frame buffer addressing under SCO Unix +and Xenix and AT&T SVR4. + +Changes the get_bits driver procedure so it always reads a single +scan line, and optionally does not copy the data. THIS IS A +NON-BACKWARD-COMPATIBLE CHANGE. However, this change does not affect +any existing printer driver, since these all go through intermediate +routines in gdevprn.c. + +Changes gdevprn.h, and the relevant printer drivers, so that -DA4 +will change the default paper size for any printer driver. + +Allows the use of NULL or 0 for default procedures in the driver +procedure vector. + +Adds an optional map_cmyk_color procedure to the driver procedure +vector. + +Changes the Epson driver so that the minimum amount of white space +required to use a tab is an easily changed parameter. + +Changes the BGI driver to use separate segments for the Borland +device drivers, to reduce the risk of overflowing a segment. + +Adds an optimization option (normally enabled) to the PGM and PPM drivers +such that they revert to PBM or (for PPM) PGM if the page can be +represented that way. + +Adds a new (optional) driver procedure to get the procedure vector +for external fonts. + +Adds an argument to gp_open_printer to indicate whether the file should be +opened in binary or text mode. THIS IS A NON-BACKWARD-COMPATIBLE CHANGE. +However, this change does not affect any existing printer driver, since +these all go through intermediate routines in gdevprn.c. + +Changes the LN03/LA50/LA75 driver so it uses a text record mode to open +the output file under VMS (by adding an argument to gp_open_printer to +indicate this.) + +Allows (indeed, encourages) drivers to use far_data to declare the device +structure, primarily to avoid overflowing the 64K data segment under MS +Windows. Changes the file output drivers and many of the printer drivers +to declare their device structures as far_data. + +Replaces the AT&T 3B1 driver with an updated version (from the same +contributor). + +Changes the Epson BJ driver and the SPARCprinter driver so they align +the (0,0) point of the page with the physical corner of the paper +rather than with the origin of the printable area. + +Removes the EIZO MDB-10 driver, since it caused complications for the +EGA and VGA drivers and is not a widely used device. + +Interpreter +----------- + +Fixes bugs: + - The entry for the copydevice operator in the operator table +was initialized incorrectly. + - printobject and writeobject didn't handle nested arrays. + - restore didn't properly close the current file (if +appropriate), causing an invalidaccess error. + - buildfont required the presence of a valid, 4-element +FontBBox. (The Red Books say it's required, but Adobe interpreters +don't require it; some DEC software generates a 3-element FontBBox.) + - resourceforall had several bugs; it didn't do even +approximately the right thing. There were quite a few other problems +with the implementation of resources. + - setfont, makefont, and scalefont would accept a font with +no FID entry. +* - Loading a .PFB font left the file open (until the next +restore or quit). + - The default (null) font didn't include a PaintType entry, +which some PostScript files expected. +* - The ASCIIHexDecode filter sometimes thought the underlying +stream was at EOF even when there was (at most one buffer's worth of) +data left. + - iscan.c included before std.h, causing type name +clashes on some systems. +* - save and restore didn't handle the pointers in the graphics +state correctly; for example, the current font wasn't restored +properly. + - Binary object sequences at the top interpreter level didn't +get executed immediately. + - On high-resolution devices, the default transfer function +converted almost-white grays to very light grays rather than white. + - The `string' operator was checking the string length +against max_uint rather than max_ushort, which could cause invalid +lengths to be accepted. +* - deviceinfo caused a stackunderflow error. +* - idiv could give incorrect results for quotients or +remainders that didn't fit in 24 bits. +* - The ASCII85Encode filter padded trailing bytes with 1's +rather than 0's. +* - The ASCII85Decode filter had a typo that produced incorrect +results if there were exactly 2 trailing bytes. + - findlibfile didn't push a copy of the file name if it was +the name of a special (%) file. + - setduplexmode was not defined in statusdict, causing +/undefined errors from some poorly designed input files. +* - The CCITTFaxDecode filter had several bugs in 2-D decoding. +* - The ASCII85Decode filter didn't read ahead to detect EOD if +it fell precisely on a buffer boundary. + - If a file mentioned on the command line redefined `start', +Ghostscript would run the new definition rather than the built-in one +after processing all the files on the command line. + - The SCO ODT compiler couldn't handle the conditionals in the +ngetc (iscan.c) and sgetc* (stream.h) macros. + - makefont and scalefont didn't cache the PostScript dictionaries +for scaled fonts. + - Changing the elements of the Encoding of a font dynamically +didn't take effect if the character was already cached. + - makefont and scalefont didn't add the (undocumented) OrigFont +and ScaleMatrix entries to the new font. +* - findfont insisted that the font name be a string or a name. + - filenameforall could cause an incorrect transfer of control +if no files matched the pattern. +* - ISOLatin1Encoding had hyphen instead of minus at code 45. + - restore didn't reset saved_cbot and saved_ctop correctly; +as a result, some freed blocks could get abandoned rather than put on +the free list. + - Some numerical constants in zarith.c assumed that longs +occupied 32 bits. + +Implements additional Level 2 features: + - %device%file names (only the "os" device is provided). + - <~ ~> for ASCII-85 strings. + - Binary error messages. + - BuildGlyph. + - CCITTFaxDecode filter entries EndOfBlock, Rows, and + (undocumented) FirstBitLowOrder. + - {set/current}{color/colorspace/overprint/colorrendering/ + blackgeneration/undercolorremoval}. (See below under library + for limitations.) + - Decode for the dictionary form of image. + - File access modes a, r/w/a+. + - Font entries CDevProc, Metrics2, and WMode. + - Font operators cshow, findencoding, rootfont, and + setcachedevice2. + - glyphshow (emulated with PostScript code). + - languagelevel. + - realtime. + - setbbox. + - (Subset of) system and user parameters. + - xshow, yshow, and xyshow. + - XUIDs for fonts. + +Moves the installation of systemdict and the initial allocation of +globaldict (if relevant) and userdict from gs_init.ps to iinit.c. + +Makes Level 2 features dynamically selectable through the +.setlanguagelevel operator; disables all Level 2 features +(specifically including automatic dictionary expansion) unless the +level2 feature is included and active. + +Adds the .knownget operator for speeding up system procedures. + +Renames the type1addpath operator as .type1addpath; adds an optional +left side bearing argument; changes it so it does not do the +setcachedevice, fill, or stroke, but does do a moveto for the +character width. Changes Type1BuildChar appropriately. (All this is +needed to make WMode work.) + +Removes the .setmetrics operator, which is no longer needed. + +* Changes the meaning of the user_errors argument to gs_run_file and +gs_run_string so that -1 means always return on an error, 0 means +only return on an error not within a `stopped'. + +Adds all the necessary checks and operators for local/global VM, but +doesn't actually implement local/global mode. + +Changes setcachedevice back so that it requires 4 numbers on the +stack rather than a 4-element array. (It was changed to be the other +way in release 2.0, but that was because I didn't realize that fonts +had to have an executable FontBBox, and some of the Ghostscript fonts +didn't.) + +Changes all the filter operators from .filterxxx to .filter_xxx, and +removes the need to enumerate them in gs_init.ps. + +Adds .oserrno and .oserrorstring operators for getting the last OS +error (in the current context). + +Changes gs_finit similarly to gp_exit. Adds gs_exit_with_code that +takes both an exit status and a Ghostscript error code. + +Changes the name of name.h to iname.h. + +Adds support for the `interrupt' error (but doesn't provide any standard +way of generating one, other than through the gp_check_interrupts polling +function). + +Adds copyright to systemdict. + +Changes the spot halftone screen to an elliptical screen supplied by +Berthold K. P. Horn. + +Adds a check that the first token in gs_init.ps is an integer. In +conjunction with other code in gs_init.ps, this should catch all attempts +to run Ghostscript with a gs_init.ps that doesn't match the executable. + +Changes all relevant occurrences of sizeof to size_of in order to +work with the buggy SVR4.2 C compiler. + +Changes gp_exit so it is passed both the Ghostscript error code and +the exit status code as arguments. This is backward-compatible for +all but the pickiest compilers. + +Adds a call on gp_check_interrupts() after fwrite calls in the stream +machinery. This prevents lengthy console output from locking out +other programs. + +Changes a couple of occurrences of op_def_ptr in iinit.c to work around a +`const' bug in Sun's SC1.0 compiler. + +Adds a special hack in the 'where' operator to work around a bug in Aldus +Freehand 2.x. + +Changes all empty argument lists from () to (void), which is the ANSI +C syntax. + +Adds a hack to ignore ^[ and ^D^[ tokens, to work around the prologue +and epilogue emitted by the MS Windows LaserJet IV driver. + +Defines the processcolors operator, which should not be needed, but +is required because of bugs in Lotus 1-2-3 and Adobe PhotoShop. + +Changes the allocator (ialloc) to fill all allocated and/or freed +blocks with a marker if gs_alloc_debug is set, as gs_malloc and +gs_free already do. + +Library +------- + +Fixes bugs: + - 16-bit memory devices stored the bytes of each pixel in the +wrong order. + - copy_mono did the wrong thing when copying 1 source chunk +to 2 destination chunks with polarity inverted. (This probably +didn't affect any actual uses of Ghostscript.) +* - The compile-time check for ints being 2 or 4 bytes used the +#error directive, which most compilers don't recognize. + - arc and arcn didn't do the right thing for degenerate +(single-point) arcs, or for arcs drawn in the "wrong" direction that +were multiples of 360 degrees. + - charpath did the wrong thing with Type 3 fonts. + - copyscanlines gave an error if the buffer was too large. + - The copy_mono procedure (used for text and halftones) for +2- and 4-bit-per-pixel memory and printer devices incorrectly +incremented the destination pointer after every pixel, instead of +only after every byte. + - The fill_rectangle procedure (used for graphics) for 2- and +4-bit-per-pixel memory and printer devices, if given any color other +than all 0's or all 1's, multiplied the X coordinate and width by 2 +or 4, thereby filling the wrong area. + - The use of 'data' in both gs_type1_data and gs_font upset +the VMS compiler. + - The `Flex' feature wasn't implemented for Type 1 fonts, +which caused serious errors in rendering some fonts that use it. +(Unfortunately, some Adobe fonts violate the specification, so we had +to implement Flex to always use a curve.) +* - Stem width adjustment was too eager, producing very strange +effects on small characters with tight curves (a curve point could +get snapped to the other side of the open area). + - The allocator didn't align structures adequately on +machines where sizeof(long) or sizeof(char *) was 8 bytes. + - The test for IEEE floating point gave an incorrect +(negative) result on machines where sizeof(long) was 8 bytes. + - genarch.c assumed that the result of subtracting two +pointers was an int, leading to a garbage arch.h file on systems +where this was false. +* - The Type 1 font interpreter incorrectly reset the adjusted +path position to be the same as the unadjusted path position whenever +it returned control to the client (in particular, for callothersubr), +leading to discontinuities and distortions in the character shapes. +* - Accented characters in Type 1 fonts often misplaced the +accent to the left. + - gsmisc.c wouldn't compile on machines with 64-bit pointers, +because _pad was 0, and ANSI compilers don't accept 0-length arrays. + - pathforall got confused if the client procedures modified +the path. + - The command list file representation limited X and Y +coordinates to 15 bits. +* - stroke could produce spikes or other garbage for mitered +joins as a result of stroke adjustment. + - The params_size field of the null device was wrong, so +scaling the null device produced unpredictable results. + +Changes monobit memory devices to always store data big-endian. This +eliminates byte-swapping, at the cost of slightly slower rendering. + +Removes the memswab* routines, since they are no longer needed. + +Implements gs_cshow_[n_]init, which provides support for cshow, and +gs_xyshow_[n_]init, which provides support for {x,y,xy}show. + +Adds an optional left side bearing argument to gs_type1_interpret. + +Changes gs_type1_interpret so it does not do a setcachedevice, fill, +or stroke, but only appends the character outline to the path +(including a moveto for the character width.) + +Removes gs_setmetrics, which is no longer needed. + +Implements gs_setcachedevice2, which provides support for +setcachedevice2. + +Speeds up gsave/grestore by allocating, deallocating, and copying as +much as possible of the graphics state in a single operation. + +Implements gs_{set/current}{color/colorspace/overprint/colorrendering/ +blackgeneration/undercolorremoval}. Device, indexed (with table, not +with procedure), CIE, and (substituted) separation colors are +supported; some of the setup code for patterns is also present. + +Increases the size of temporary file names in gdevprn.h from 30 +characters to 60. + +Changes the character cache to be allocated dynamically in chunks. + +Splits gxcache.c into gxccache.c (fast "hit" code) and gxccman.c (all +other code). + +Changes all occurrences of sizeof to size_of in order to work with the +buggy SVR4.2 C compiler. + +Adds a new concept of "external fonts", which allow a driver to +substitute its own fonts for the ones obtained through the normal +font machinery. + +Changes all empty argument lists from () to (void), which is the ANSI +C syntax. + +Version 2.5.2 (9/20/92) +============= + +This is yet another bug fix release to (finally!) get the PCL drivers +working again. + +Procedures +---------- + +Fixes bugs: + - The comment in devs.mak for cdjcolor said it used 8 bits +per pixel, rather than the correct 24. + +Adds gsbj/dj/lj/lp and gslp.ps to the installed files on Unix +systems. + +Removes dps.dev and level2.dev from the standard configurations on +all platforms, since the presence of the setcolor operator was +causing the output of some common applications to fail. + +Utilities +--------- + +Fixes bugs: + - font2c produced invalid output for any font that didn't use +StandardEncoding or ISOLatin1Encoding. + +Platforms +--------- + +Fixes bugs: + - gp_sysv.c required an extern long timezone. + +Drivers +------- + +Fixes bugs: + - The PCL drivers were *still* doing the wrong thing about +zeroing the seed row for Mode 3 compression. + - Setting the resolution with -r didn't work under Windows. + - The Windows driver got a stack overflow if it was ever +asked to display a bit image wider than 32 pixels. + - The Tseng driver didn't sense the model (ET3000 vs. ET4000) +correctly. + +Adds the eps9high device to the standard MS-DOS makefiles. + +Interpreter +----------- + +Fixes bugs: + - gs_run_string used gs_user_errors (a global) rather than +user_errors (its argument) to control error handling. (This does not +affect normal operation of Ghostscript, only use as a server.) + - eexec popped the top element of the dictionary stack +afterwards even if the encrypted code had pushed something onto it. +This caused problems for some badly written PostScript code. + - The printed form of real numbers didn't always include a +decimal point, causing compatibility problems. + +Makes -s and -d work for device properties. + +Increases the cache limit on large-memory systems. + +Adds a check to ensure that the revision of gs_init.ps matches that +of the interpreter. + +Adds the .knownget operator. + +Library +------- + +Fixes bugs: + - The raster computation in clist_render_init, and the +computation of state_size in clist_open, didn't widen an operand to +long, leading to possibly incorrect operation for 24-bit-per-pixel +printers on MS-DOS systems. + - The flatness was set too large for Type 1 characters, +leading to visible straight edges instead of curves at large sizes. + - Type 1 fonts that contained out-of-range coordinates would +produce garbled output. (This was not a problem with the standard +Ghostscript fonts, or with Adobe Type Manager fonts.) + - gschar0.c wouldn't compile, because it referred to a +non-existing structure member penum->chr. (This had no effect on +Ghostscript's operation.) + - The curve flattener required line segments to be no more +than 8 x the flatness in length, leading to an enormous number of +segments. + - pathforall would cause an addressing fault if the path +consisted of only a moveto. + +Refactors some header files so that std.h is always included before +any system header file that might include sys/types.h. + +Adds logic for removing top and bottom blank rows in cached +characters. (This is the beginning of compression for the cache.) + +Changes the arguments of memswab2/4 from char * to byte *, for more +accurate type conformance. + +Version 2.5.1 (9/11/92) +============= + +This is the usual bug fix re-release. + +Procedures +---------- + +Fixes bugs: + - The makefile rules for compiled fonts had a circular +dependency. + - `make begin' didn't work properly on all platforms. + +Ensures that all batch files end with a newline. (The absence of the +newline was confusing the GNU diff program.) + +Documents the fact that the -dASCIIOUT switch no longer exists. + +Utilities +--------- + +Fixes bugs: + - pstoppm didn't `bind' its internal procedures. + - grestoreall would undo the output device selected by +pstoppm. + +Changes the utilities for reading and writing Type 1 character +outlines so they can work with stack representations as well as +arrays. + +Removes the pfbtogs.ps, phonbook.ps, and showpbm.ps utilities from +the distribution. + +Adds a gslj utility to parallel gslp and gsdj. + +Platforms +--------- + +Adds the DeskJet 500C drivers (cdeskjet/cdj*) to the MS-DOS / Borland +C++, MS-DOS / Watcom C/386, and MS-Windows configurations. + +Removes the PCX file driver from the MS Windows executable, because +the static data segment exceeded 64K. + +Makes some changes in the Unix System V platform file (gp_sysv.c) and +in time_.h and unixtail.mak to accommodate the 3B1. + +Fonts +----- + +Fixes bugs: + - The Charter-Italic font was named bchi.pfa rather than +bchri.pfa. + - The Cyrillic fonts (cyr.gsf, cyri.gsf) were omitted from +the fileset. + - Ghostscript incorrectly assumed that all Type 1 fonts had a +FontInfo dictionary. + - .loadfont used false PFBDecode, so a few .PFB fonts would +get errors because the first eexec byte would be whitespace. + +Changes font2c and its supporting code so that compiled fonts are +location-independent. + +Drivers +------- + +Fixes bugs: + - The margins for the H-P printers were still wrong. + - The H-P drivers accidentally cleared the compression seed +row when switching compression modes. + - Some of the H-P drivers used the wrong control codes for +skipping blank lines. + +Adds user-supported drivers for the AT&T 3B1 console device, and for +the NEC P6+ printer. + +Updates the SunView driver with a new version supplied by a(nother) +user. + +Changes the X Windows driver so the Ghostscript window doesn't get +input focus. + +Changes the common code for the printer drivers so that if it can +allocate a full bitmap but there isn't at least a minimum amount of +memory left afterwards, it switches to banding. + +Changes the Windows driver so it handles devices with more than 8 +bits per pixel. (We haven't been able to test this.) + +Adds a read-only PageCount device property (for printer devices +only). + +Changes all Aladdin-supported drivers to clip drawing requests to the +((0,0), (width,height)) rectangle of device space. + +Interpreter +----------- + +Fixes bugs: + - Closing a NullEncode filter always gave an ioerror. + - If a single-character name occurred 1 character before the +end of an input buffer, the character would be doubled. + - The procedures in gs_statd.ps didn't use "bind". + - Setting the page size didn't work properly with devices +with rotated coordinate systems. + - If an error occurred, and the error object wasn't the last +element of its procedure, the interpreter would re-execute the error +object after running the error handler. + - Memory devices didn't get resized if HWSize was changed, +leading to out-of-bounds memory accesses. + +Moves revision and revisiondate from gs_init.ps to iinit.c. Adds a +-v switch that just prints these out. + +Arranges things so that if Ghostscript is reading from a pipe (`-' +switch on the command line) and encounters an error, it exits with +status 1 rather than 0. + +Changes the interpreter interface so the caller explicitly passes a +pointer for storing an error object. + +Library +------- + +Fixes bugs: + - The automatic adjustment of the scaling for variant paper +sizes caused the image to get expanded when it should have been +contracted, and vice versa. + - The curve flattener insisted that each line segment be no +more than 2 x the flatness in length, leading to an enormous number +of segments even when not necessary for accuracy. + - flattenpath and strokepath discarded a trailing moveto. + - strokepath treated "0-width" lines as really having a width +of zero, rather than one pixel. + - Buffered devices weren't closed and reopened if the amount +of buffer space was changed. + - stroke used the line cap at the beginning of each subpath +even if the subpath was closed. + +Removes the requirement that the clipping rectangle fall in the +non-negative quadrant of device space. (This was causing problems +for Ghostview, but removing it required adding the extra clipping +step to the drawing routines in the drivers.) + +Version 2.5 (8/18/92) +=========== + +This version adds Type 1 hinting, CCITTFax encoding and decoding, and +Microsoft Windows support, as well as the usual minor improvements +and bug fixes. + +Procedures +---------- + +Fixes bugs: + - GSIMPATH, SLZWD, and SLZWE were omitted from the VMS +makefiles, and GSIM2OUT was not removed. + - landscap.ps messed up the current path. + +Adds new switches: + -dSAFER disables file writing and directory modification. + -dESTACKPRINT causes errors to print the execution stack with +== instead of =. + -sOutputFile= replaces -sOUTPUTFILE (which is still +recognized) for setting the output file or pipe for the default +(printer) device. + -sPAPERSIZE= initializes the paper size. + -dBufferSpace= sets the buffer size for the default +(printer) device. + +For Unix systems, changes the directories in GS_LIB_DEFAULT from +`pwd` to $(gsdatadir), i.e., normally $(datadir)/ghostscript, where +datadir is normally /usr/local/lib. + +Adds a note in the header file to the effect that the X Windows +driver expects to find header files in $(XINCLUDE)/X11, not in +$(XINCLUDE). + +Changes -q so it defines QUIET as true instead of null (so it can be +used in the middle of the command line as well as at the beginning). + +Renames the history.doc file as NEWS. + +Utilities +--------- + +Platforms +--------- + +Fixes bugs: + - The stack size was not getting increased on the Watcom +platform. + +Removes "b" from the scratch file opening modes in gp_unix.c and +(conditionally) in gdevprn.c, to pacify the DECstation Ultrix system. + +Adds a makefile (bcwin.mak) and a platform file (gp_mswin.c) for +Microsoft Windows. + +On MS-DOS platforms (including Windows), uses the TEMP environment +variable to designate the directory for scratch files. + +Changes std.h so that the VMS C compiler uses function prototypes and +'const'. + +Changes the VMS cc makefile so it doesn't use ansi2knr. + +Fonts +----- + +Fixes bugs: + - findfont left an extra entry on the stack if it couldn't +find the default font. + +Renames bchi, ncri, and puti as bchri, ncrri, and putri, to conform +with the naming scheme for other fonts. + +Adds $(CCFLAGS) to the command line used for compiling fonts. + +Converts the .pfa fonts (CharterBT, IBM Courier, and Utopia) to .gsf, +by removing eexec encryption and also removing some mysterious +unmapped characters from Courier. This makes these fonts work with +DISKFONTS. + +Changes the implementation of compiled fonts so they are read-only +and sharable (no external references). (They are, however, not +position-independent.) + +Provides a way to use compiled fonts on platforms that limit the +number of characters in an identifier. + +Adds public-domain Cyrillic and Cyrillic-Italic fonts. + +Adds a 'userdict begin' to .loadfont, because Type 3 fonts produced +by Fontographer expect a writable dictionary on the top of the stack. + +Changes definefont for Type 1 fonts to insert UnderlinePosition and +UnderlineThickness entries in FontInfo if they are absent, because +many word processors incorrectly assume these entries are present. + +Drivers +------- + +Fixes bugs: + - The documentation in use.doc said that the densities for +9-pin Epson printers were 60x60 to 240x60, rather than 60x72 to +240x72. + - gdevprn.c smashed one byte beyond the end of the string +given as the OutputFile device property. + - The X11 driver used XVisualIDFromVisual, which is not +defined in X11R3. + - The SunView driver modified the input data, which was +declared as const. + - The LaserJet IIP and III drivers shifted the page 185 +pixels to the left and 0.25" down, because the initialization string +was incorrect. + - The PCX driver wrote 16-bit values using the byte ordering +of the platform, rather than always LSB first. + - For vertical spacing, the LaserJet and DeskJet drivers used +a command that spaces N/300", rather than N scan lines, but gave it a +parameter in scan lines. + - The VESA driver didn't allocate a full 256-byte buffer for +reading the mode information from the BIOS, causing the stack to get +smashed by newer VESA implementations. + - The VESA driver didn't use the scan line length returned by +the BIOS, causing garbage output for some cards and some resolutions. + - The generic printer driver didn't free the bitmap when +closing the device, if it fit entirely in memory. + - The PaintJet driver allocated its data areas on the stack +instead of with gs_malloc. + - The generic printer driver didn't attempt to increase the +buffer size if it was too small. + - The band list driver didn't split large bitmaps properly, +leading to garbled characters at high resolutions. + - The GIF and PCX drivers used a color map that often turned +gray colors into non-grays. + +Changes the default put_props procedure so that if the device is +open, setting HWSize and/or HWResolution closes the device and +reopens it. + +Adds a driver for Microsoft Windows 3.n. + +Updates the 'cdj' and 'dj500c' DeskJet 500C drivers with new versions. +(This are user-contributed drivers.) + +Changes gdev_prn_put_props so OutputFile can be changed dynamically. + +Updates the DEC LN03 driver to also handle the LA50 and LA75. (This +is a user-contributed driver with a FSF copyright.) + +Changes the LaserJet/DeskJet driver so that -DA4 in the makefile +makes A4 paper the default. The driver now also sends an appropriate +page size selection command to the printer if the printer supports it. + +Changes all the Aladdin-supported drivers to return appropriate error +codes rather than -1. + +Adds a driver for the S3 86C911, a PC graphics accelerator used in +the popular Diamond Stealth board. This is the first driver that +uploads character bitmaps to a device; others will probably follow. + +Adds user-supplied code to the Epson driver so it will do triple +passes on 9-pin printers for higher resolution. + +Adds user-supplied code for the PaintJet XL to the PaintJet driver. + +Interpreter +----------- + +Fixes bugs: + - zdps1.c didn't include alloc.h. + - On 32-bit systems, if maxlength of a dictionary was less +than the actual allocated space, length could become larger than +maxlength. + - flushfile didn't actually flush data when reading. + - The ASCII85Decode filter signalled EOF prematurely. + - The scanner interpreted .3D.glorp as the number 0.3, rather +than as a name. + - Closing a file freed the stream structure, creating +dangling references if there were other file objects pointing to the +same stream. + - eexec called handleerror if an error occurred, instead of +letting the error propagate to an enclosing stopped. + - gs.h made perror illegal, instead of defining it in terms +of strerror. + - One-character names weren't being allocated at +initialization, so they could be left dangling after a restore. + - Internal gsaves (i.e., the ones in show and setcachedevice) +didn't also save istate, so setfont inside a BuildChar procedure +might cause the font outside to get changed. + - The allocator incorrectly freed objects in the current +chunk that were older than the current save. + - mark was just an object, rather than an operator, so 'bind' +didn't bind it. (This is theoretically a problem for null, true, and +false also, but even more unlikely to be a problem in practice.) + - packed_get didn't cast packed integers to int, so negative +integer elements of packed arrays came out wrong. + - quit just did a gs_exit, instead of returning to the driver +in an orderly way. + - Because check_type_access checked for errors in the wrong +order, sometimes type errors were reported as access errors. + - eq didn't check for stack underflow. + - Some of the stream_procs structures weren't properly +declared const, leading to link errors on VMS. + +Implements currentcolor, currentcolorspace, setcolor, and +setcolorspace (for DeviceGray, DeviceRGB, and DeviceCMYK only). + +Implements the dictionary form of image and imagemask. All the pairs +in the Decode array must be the same; Interpolate is ignored. The +only supported color spaces are DeviceGray, DeviceRGB, and +DeviceCMYK. + +Implements files as allowable sources for the image operators. + +Removes the index field from the name structure, moving it to the +'size' field of name refs. + +Changes the unread/sungetc operation to require that the character be +the same as the last one read from the file. + +Adds fflush calls to some debugging printout routines, because Unix +sometimes buffers terminal output. + +Implements the CCITTFaxEncode and CCITTFaxDecode filters. Implements +the general case of the SubFileDecode filter. + +Changes definefont to treat a UniqueID of 0 as equivalent to no +UniqueID, because Fontographer output apparently often violates the +specification in this way. + +Changes the default printer screen from 32.5 to 46 cells/inch. (The +old value was appropriate for a hand-rotated cell with two spots in +it.) + +Changes the utility routines to allow an integral real wherever an +integer parameter is expected in a dictionary, because Fontographer +produces fonts that violate the Adobe specification in this way. + +Adds a `dosio' feature that provides direct access to memory and to +I/O ports under MS-DOS. (This feature is not included in the +standard executables, of course.) + +Changes the default character cache limit to a 1/4" x 1/4" character +at the default resolution, rather than basing it on the preallocated +cache size. + +Removes support for t_color objects, which haven't actually been used +for several releases. + +Implements setcmykcolor and currentcmykcolor as operators, so they +will interact properly with setcolorspace and currentcolorspace. + +Changes the name of the file.h header file to files.h, to work around +a bug in the VMS header library. + +Adds command line switches @file (to treat file as more command line, +to get around the DOS 128-character command line limit) and -ffile +(so one can specify file names that begin with - or @). + +Changes the PFBDecode filter so it takes an additional boolean that +says whether or not to convert binary packets to hex. (Conversion to +hex and back to binary accounted for a substantial amount of the time +required to load .PFB fonts.) + +Splits off `copydevice' as a separate operator again. + +Library +------- + +Fixes bugs: + - In the VMS environment, string_.h used its own prototypes +for the str... and mem... functions instead of + - gx_alloc_char_bits declared cdsize as long, but didn't +shorten it when passing it to shorten_cached_char. + - Stroking didn't suppress fattening of the lines. + - kshow didn't update the cached CTM information in the show +enumerator when returning from the callout, so further characters +could get drawn in the wrong place. + - When a memory device returned its initial matrix, it +smashed the padding fields, which contained the interpreter's type +information. + - setcachedevice didn't set the initial matrix in the cache +memory device. + - image_set_rgb (in the image operators) didn't do a +gx_color_from_rgb, so in principle one could sometimes get incorrect +colors in an image. + - The decision about whether or not to cache a character +bitmap incorrectly compared the character size against cmax rather +than cdata_size. + - show didn't reset the in_cachedevice flag in the graphics +state, so characters rendered by a recursive show were never cached. + - clip and eoclip didn't release the intermediate flattened +clip path, causing memory to be lost. + - The tile_diff routine didn't handle the case of two +identical tiles properly; this produced garbage in the band list +file. + - stringwidth didn't round the character origin to an +integral pixel; this interacted badly with hinting, causing +improperly hinted characters to wind up in the cache. + - Bitmaps (including characters) were displaced, as well as +being clipped, if they intersected the top of a clipping region. + - In gxclist and gdevmem1, the raster computation (although +not the result) could overflow an int on 16-bit machines. + +Implements decoding (sample mapping) for image and imagemask. + +Implements hinting for Type 1 fonts, based on (but not copying) the +algorithms from the X11R5 tape. + +Changes curve rasterizing to use sampling, rather than recursive +subdivision, for characters. This produces noticeably better output. +Speed penalty for non-cached characters is less than 10% at display +resolutions, up to 50% for 300 dpi printers. + +Implements gs_setcmykcolor and gs_currentcmykcolor. These are +semi-fake, since they simply convert the color to and from RGB, but +the former does set the current color space properly. + +Changes clipping regions so they use the any-part-of-pixel rule +rather than the center-of-pixel rule. This helps avoid dropouts when +using very small regions. + +Implements stroke adjustment. + +Version 2.4.2 (5/8/92) +============= + +This is another quick release. It finally fixes rotated halftone +screens, and cleans up a few minor problems from 2.4.1. + +This release is being distributed only to beta testers and commercial +licensees, since I don't want to be distracted from working on 2.5. + +Procedures +---------- + +Fixes bugs: + - UTRACE still appeared in the VMS makefiles. + - The support files (*.bat, *.doc, *.gsf, *.ps, Fontmap, +COPYING, README) weren't included in the MS-DOS tar file. + - The Unix install script didn't install landscap.ps. + +Replaces the type1imagepath operator with PostScript code (impath.ps, +type1ops.ps) based on the new .imagepath operator. + +Renames LICENSE as COPYING. + +Utilities +--------- + +Fixes bugs: + - pcharstr.ps had an occurrence of Subrs rather than /Subrs, +causing it to not print the Subrs, or to get an error if there were +none. + - font2c.ps didn't get the const declarations for string +dictionaries quite right. + - The missing newline at the end of gsbj.bat confused GNU +diff. + - ansi2knr would go into an infinite loop if a statement +exceeded its internal buffer size. + - Compiled fonts would get processed by ansi2knr, which +messed them up. + +Platforms +--------- + +Fixes bugs: + - Ghostscript didn't supply equivalents for rename and +gettimeofday, which some System V platforms lack. + - The missing newline at the end of gp_dosfb.c confused GNU +diff. + +Changes the Borland makefiles so that stack checking is only enabled +if DEBUG or TDEBUG is set. + +Fonts +----- + +Changes the names of the Utopia fonts from utrg/utb/utbi/uti to +putr/putb/putbi/puti, for consistency with the rest of the font names. +Changes cour/courb/courbi/couri to ncrr/ncrb/ncrbi/ncri likewise. + +Replaces the Charter fonts with the CharterBT fonts donated by +Bitstream to the X11R5 distribution. + +Adds font aliasing capability to Fontmap. Replaces +Courier-[Bold]Oblique and ZapfChancery-MediumItalic by aliases. + +Changes the FontBBox of the Hershey fonts to be an executable, rather +than a literal, array. + +Drivers +------- + +Fixes bugs: + - The GIF driver omitted a `private' on the definition of +gif_print_page. + - The GIF driver wrote 16-bit values using the byte ordering +of the platform, rather than always LSB first. + - George Cameron's DeskJet 500C driver had an incorrect +control sequence for skipping blank lines. + +Adds 'const' in many places, including the tile and bitmap arguments +of the tile_rectangle, copy_mono, and copy_color driver routines. +THIS IS A DRIVER INTERFACE CHANGE. (Printer drivers are not +affected, since they don't implement these routines.) + +Adds a driver for the Trident TVGA. + +Interpreter +----------- + +Fixes bugs: + - alloc_free sometimes incorrectly chose to put an unaligned +block in an old segment on a freelist. + - The default undercolor removal function returned its +argument rather than returning 0. + +Adds NullEncode and SubFileDecode to the standard filters, since +bdftops uses the latter. + +Adds RunLengthEncode and RunLengthDecode to the optional filters. + +Removes the type1imagepath operator. (It is still available as +PostScript code, impath.ps.) Replaces it with a simpler outline +tracing operator .imagepath. + +Adds 'const' in many places. + +Makes fileposition (but not setfileposition) legal for NullEncode +filters. + +Changes the default transfer function for high-resolution devices +from the identity function to the square root function. + +Moves array_get from zgeneric.c to iutil.c. + +Changes uses of fopen to add a "b" to the access mode, rather than +relying on the _fmode global variable on MS-DOS platforms. + +Allows use of the -Z switch even when gsmain.c wasn't compiled with +-DDEBUG, since other modules might have been. + +Reorganizes gs.c and gsmain.c so that the latter can be used in +server environments. + +Replaces all uses of stdin/out/err with gs_stdin/out/err. + +Makes the number of permanent entries on the dictionary stack a +parameter, to allow inserting globaldict in the future. + +Changes BlueShift in the Type 1 font Private dictionary to allow real +numbers. (This differs from the Adobe specification, but at least +one commercial font has a real number for BlueShift.) + +Library +------- + +Fixes bugs: + - The doubling check in init_ht (gxht.c) still sometimes +thought there was enough room to double the tile when there actually +wasn't. + - Rotated halftone screens didn't work. + - gxarith.h used #ifdef vax, rather than #if +!arch_floats_are_IEEE, to test whether IEEE floats were being used. + - pathforall didn't report a trailing moveto. + +Replaces gs_type1imagepath with gs_imagepath. + +Allows sOUTPUTFILE=-, meaning output to stdout. + +Adds 'const' in many places. + +Replaces all uses of stdin/out/err with gs_stdin/out/err. + +Version 2.4.1 (4/21/92) +============= + +This is a quick release to fix minor problems discovered in 2.4, and +to add a few improvements that didn't quite make it into 2.4. It +also adds GIF and PCX file support. + +Procedures +---------- + +Fixes bugs: + - Some makefile dependencies, and the ccgs script, caused trouble +for parallel versions of `make'. + - Compiling genarch with -O with gcc on the RS/6000 produced a +buggy executable. + +Fixes some minor problems in make.doc. + +Adds DEVICE_DEVS2..5 to handle long device lists. + +Removes the need to set GS_RUN_EXE when using the Watcom compiler on +MS-DOS systems. + +Gets rid of gs_ccfnt.ps, merging its function into gs_fonts.ps. + +Gets rid of gconfig.ps; this information is now compiled in gconfig.c. + +Utilities +--------- + +Fixes bugs: + - The palette for pstoppm in 8-bit mode didn't contain all 8 +primary colors. + - font2c used just values_ to mean &values_[0]; some compilers +couldn't handle this. + +Makes font2c insert `const' in many appropriate places. + +Drivers +------- + +Fixes bugs: + - The SunView driver had not been updated properly for 2.4 and was +pretty thoroughly broken. + - None of the printer drivers worked properly with the Watcom +compiler, because stdprn was doing \n -> \r\n substitution. + - If the generic printer driver couldn't allocate the requested +size command list buffer, it gave up rather than trying to allocate a +smaller buffer. + - The SuperVGA drivers (except for the VESA driver) didn't +work with the Watcom compiler, because a couple of places in the +drivers weren't truncating the offset of "segmented" pointers +properly. + - Some of the H-P used *b#Y rather than *p+#Y for +vertical positioning; this apparently is wrong, at least for the +LJIIp. + +Removes the dependence of the X Windows driver on Xt, Xext, and Xmu. As a +result, Ghostscript will not install a standard colormap itself, but it +will use one if one is already installed. + +Adds a set of drivers for Portable Bitmap, Graymap, and Pixmap file +formats. + +Adds drivers for monochrome, EGA/VGA-style, and SuperVGA-style PCX +file formats. + +Adds drivers for monochrome and 256-color GIF file formats. + +Fonts +----- + +Adds ZapfChancery-MediumItalic as a copy of ZapfChancery-Oblique. + +Interpreter +----------- + +Fixes bugs: + - A value with l_new set could 'escape' to save level 0 on a +stack; if stored, it prevented the slot from being saved and restored +properly. + - 16#7fffffff + 1 gave the floating point equivalent of -2^31, not +2^31. + - The PFBDecode filter computed the packet length incorrectly if +the 0x8000-bit of the length was set. + - 5-byte numbers in Type 1 CharStrings complained of a rangecheck +if they exceeded 16 bits, rather than if they exceeded the integer part of +a fixed. + - (, ), and \ appearing in file name arguments in the command +line did not work properly. + +Adds 'const' in many places. + +Changes the random number generator to be the same as the one used in +Level 2 PostScript (as reported by Ed Taft on comp.lang.postscript). + +Exits with code 1 rather than code 0 on an unrecoverable error detected at +the PostScript level. + +Makes dictionaries expand automatically when they fill up. + +Adds gp_exit to complement gp_init. + +Changes dictionaries to always allocate a power of 2 entries on +32-bit machines. Changes the name table to allocate indices +scattered, so dictionary lookup doesn't have to do a multiply to +scramble the index. + +Changes the handling of currentfile to do "shallow binding" so stack +searching is almost never required. + +Library +------- + +Fixes bugs: + - arc and arcn got a numeric exception if the radius was zero. + - The undocumented 15 opcode in Type 1 fonts wasn't ignored. + - PaintType 3 wasn't allowed. (It isn't clear what it should +mean; we treat it as equivalent to 0.) + - The VAX/VMS C compiler was generating incorrect code for the +chi_bits and cmask macros in gdevmem, producing incorrect output. + - If the result of the slow algorithm for intersecting clipping +paths was a rectangle, the wrong thing happened (cbox didn't get set). + - gx_path_is_rectangle didn't recognize open rectangles. + - clist_change_tile didn't check properly whether the tile +size had changed, so changing the screen could produce invalid band +files. + - The image operators did the wrong thing in the 1-for-1 +case, interleaving N bytes of data with 7*N bytes of garbage. + - stroke sometimes handled bevel and miter joins wrong in +reflected coordinate systems. + - init_ht checked incorrectly whether there was enough room +to Y-replicate tiles, so sometimes it did it when it shouldn't have. + - stroke sometimes thought lines were thin when they weren't. + +Adds 'const' in many places. + +Adds support for 2- and 4-bit-per-pixel memory devices. + +Version 2.4 (3/25/92) +=========== + +This is a major release that adds SuperVGA support, support for Metrics, +settable device properties, and incremental font loading. It also +includes important performance improvements, based on rewrites of some key +algorithms, and quite a few new Level 2 / Display PostScript facilities. + +Procedures +---------- + +Fixes bugs: + - The rule for compiling gconfig.c didn't include the -I switches. + - .bat files were being distributed with a \n line terminator +rather than \r\n. + - A CLOSE MODULE_LIST was needed after END_COMPILE: in the VMS +command files. + - Unix systems couldn't handle multiple drivers with overlapping +sets of files. + - -s defined as a null, rather than as an empty string. + +Adds gconfig.ps to the list of needed configuration files. + +Changes the way that the makefile handles nested .h files, so that it +doesn't have to `touch' them. + +Adds the loadallfonts procedure to gs_fonts.ps. + +Changes the standard DOS configuration to include VGA, EGA, VESA, Epson, +BubbleJet, and H-P printer drivers. + +Renames ghost.mak as gs.mak, and gdevs.mak as devs.mak. + +Adds a USE_ASM flag so that one can build a DOS version of Ghostscript +without having an assembler. + +Splits off common code from the two MS-DOS makefiles into tccommon.mak. + +Replaces the COPYING and LICENSE files with a new LICENSE file containing +version 2 of the GNU General Public License. + +Removes DEVICES and DEVICE_OBJS from the makefiles, since they are no +longer needed. + +Adds a GS_DEVICE environment variable to supply a default device name if +desired. + +Adds ansihead.mak and unix-ansi.mak, to parallel [g]cc-head.mak and +unix-[g]cc.mak, for other ANSI C compilers. + +Changes the way that optional features are defined in the makefiles, so +that they actually work. + +Adds support for the Watcom C/386 compiler. + +Allows # in the command line as equivalent to =, to compensate for +brain-damaged MS-DOS shell. + +Adds -sOUTPUTFILE= to set the output file or pipe. + +Adds -dWRITESYSTEMDICT to leave systemdict writable. + +Utilities +--------- + +Fixes bugs: + - pcharstr.ps insisted on having Subrs be present in the font. + - pcharstr.ps decoded negative numbers between -108 and -1131 +incorrectly. + - pfbtogs.ps didn't handle packets longer than 64K correctly. + +Changes the bdftops utility so that it makes entries for UnderlinePosition +and UnderlineThickness in FontInfo, and so that it always records a +FullName (the FontName if no other is provided). + +Changes the name of the pfbtops utility to pfbtogs, because groff already +includes a program called pfbtops. + +Adds the gslp utility for doing "line printing" of text files, similar to +enscript + lpr. + +Adds a new variable DITHERPPI that enables a different dither pattern, +claimed to be better for printers. + +Adds the font2c utility for compiling Type 1 fonts into C, so they can be +linked into an executable rather than loaded dynamically. + +Drivers +------- + +Fixes bugs: + - gdev_prn_copy_scan_lines was erroneously masking the last byte +of data even on color printers, as was paintjet_print_page. + - The TruFax driver had a couple of compilation errors, since it +hadn't been compiled in a while. + - The BGI driver sometimes didn't consult BGIPATH when looking for +.BGI files. + - initclip did the wrong thing with memory devices. + - The BGI driver didn't look in BGIDIR for .BGI files. + - The Epson driver didn't set the right margin properly with +ESC+Q. + - The BJ-10e driver was badly broken. + - gdev_prn_open/close_printer didn't reset the command list file, +so it was taking quadratic time to print multi-page documents. + +Adds color to the SunView driver. + +Adds selectable resolution (75, 100, 150, or 300 DPI) to the +DeskJet/LaserJet driver. + +Changes gssetdev so that drivers can specify special libraries to be +loaded, as well as object files. + +Adds a driver for VESA-compliant SuperVGA displays. This driver handles +all resolutions from 640 x 400 up to 1280 x 1024, in 256-color mode. The +default is VGA resolution (640 x 480). + +Adds a driver for the ATI Wonder SuperVGA card, and for SuperVGA cards +using the Tseng Labs ET3000 or ET4000 chip such as the STB VGA EM-16 and +the Orchid ProDesigner II (256-color modes only). + +Adds a driver for Trident and Tseng Labs SuperVGA cards in 800 x 600, +16-color modes (for cards with only 256K of memory). + +Adds user-contributed drivers for the Ricoh 4081, DEC LN03, Canon LBP-8II, +and H-P DeskJet 500C printers. + +Adds Tim Theisen's Ghostview changes to the X11 driver. + +MAKES NON-BACKWARD-COMPATIBLE CHANGES TO THE DRIVER PROCEDURE INTERFACE as +follows: + + - Changes map_rgb_color and map_color_rgb to always work in a + 16-bit color value space, rather than a space defined by the + maximum number of distinct colors provided by the device. + + - Adds an argument to the output_page procedure to indicate + whether the procedure is being called for copypage or + showpage, and a num_copies argument. + + - Adds a gx_bitmap_id to the copy_ and tile_ procedures, so that + drivers can cache bitmaps in the server or device if they want + to. + + - Removes fill_trapezoid and tile_trapezoid. + + - Adds a new get_bits procedure for reading the bits back from the + driver buffer (when possible), replacing copy_scan_lines. + This procedure takes a new argument describing padding and + byte swapping, and returns a different value from + copy_scan_lines. + + - Adds get_props and put_props procedures for accessing arbitrary + additional properties of devices. The interface is quite + complex, but provides a great deal of flexibility. + +See drivers.doc for details. + +Changes gdev_mem_bytes_per_scan_line to gdev_prn_bytes_per_scan_line. + +Adds a user-contributed driver for DigiBoard, Inc.'s fax software. + +Fonts +----- + +Changes Type1BuildChar so it uses the information from the Metrics +dictionary in the font, if Metrics is present. + +Changes findfont (.loadfont) so it recognizes .PFB fonts and can load them +directly. Also changes .loadfont to disable packing temporarily, because +some fonts rely on procedures being writable (!). + +Interpreter +----------- + +Fixes bugs: + - The hypot function is not available on some Unix systems. + - Ghostscript didn't flush and close files when exiting. + - In statusdict, the /margins procedure used .leftmargin, but +/setmargins used .lmargin. + - An out-of-range putinterval would simply do nothing, rather than +reporting an error. + - If an attempt to allocate a block larger than the allocator's +chunk size (20K) failed, the allocator would erroneously think it had +succeeded. + - The bind operator made the top-level procedure read-only, as +well as interior procedures. + - gs.c copied 1 extra character for the value of strings defined +on the command line with -s...=, which could smash the first byte of the +next object in memory. + - copying a dictionary erroneously required the maxlength of the +destination to be greater than or equal to the maxlength of the source, +rather than the length of the source. + - undef didn't correctly decide when to mark a deleted entry as +deleted vs. free; as a result, some keys couldn't be looked up properly +after an undef. + - type1encrypt and type1decrypt didn't set the size of the result +properly. + - cvi and cvr didn't allow leading or trailing whitespace in +strings. + - cvs didn't cause an error if the destination string was too +short. + - Many operators didn't check correctly for stack underflow (off +by 1). + - `for' used reals, rather than integers, if the limit was a real, +even if the initial value and increment were integers. + - `restore' didn't properly invalidate copies of the save object +being restored from; `save dup restore restore' would crash. + - `restore' sometimes didn't undo stores into matrices that were +stored into by operators. (The identity matrix always had l_new set.) + - readline gave a rangecheck if the input line exactly filled the +string. + - `--' as the last switch on the command line caused a crash +rather than an error message. + - On MS-DOS systems, filenameforall didn't handle patterns with a +drive or directory specifier properly. + - stroke sometimes called gz_draw_line_fixed even if the line went +outside the clipping box by 1 pixel. + +Changes the loop that binds procedure "operators" to entirely disable the +handling of the typecheck error, rather than to use stopped. This cuts +initialization time significantly, and also eliminates about 35K of wasted +space (for saving the stacks). + +Changes the version "operator" so it returns 47.0. Adds "revision" to +define the Ghostscript version # x 100. + +Adds gscurrentresolution and gssetresolution procedures for getting and +setting the device resolution. + +Adds -r and -rx as command line options for setting +device resolution. + +Adds a facility for incrementally loading the individual CharStrings of a +Ghostscript font from the disk. This can save a lot of memory, at the +expense of slower rendering. (It is intended primarily for MS-DOS +systems.) + +Changes findlibfile to return the name of the file that was actually +opened, as well as the file itself, when the operation succeeds. + +Changes the name of the main entry to the interpreter from interpret to +gs_interpret, because of a conflict with a Data General library procedure. + +Adds the .setmetrics operator to set the metrics for the current +character for Type 1 fonts. + +Adds more LaserWriter-specific entries to statusdict. + +Gives names to all the internal `operators', so they will print out +reasonably when an error occurs. + +Extends the status operator to accept a string and return file +information, as defined for Level 2 PostScript. + +Adds the filter operator and some specific filters: ASCII85Encode, +ASCII85Decode, ASCIIHexEncode, ASCIIHexDecode, eexecDecode, NullEncode, +PFBDecode, and the null case of SubFileDecode. + +Extends the scanner to recognize the Level 2 << and >> tokens. + +Adds a facility for extracting the text strings from a PostScript file and +writing them out in a simple format (selected by -dASCIIOUT, implemented +by gs_2asc.ps). + +Implements all of the remaining Display PostScript facilities that are +also in Level 2 (i.e., everything in section A.1.3 of the PostScript +Language Reference Manual, Second Edition, that is not also in section +A.1.2). The virtual memory operations are all stubs; the new halftone +options are not fully implemented. + +Changes makeimagedevice to use a string of gray or RGB values, rather than +an array of color objects, to specify the palette. Removes +currentgscolor and setgscolor from the interpreter, but leaves t_color +objects in, since they may be useful later. + +Adds getdeviceprops and putdeviceprops for manipulating device properties. +Currently defined properties for all devices: InitialMatrix, HWResolution, +HWSize, Name. Currently defined properties for printers: BufferSpace, +MaxBitmap, OutputFile. OutputFile allows |command for piping on Unix +systems. + +Removes deviceparams and makedevice. Adds devicedefaultmatrix. + +Implements reversepath. + +Makes copy work on devices. + +MS-DOS specific +- - - - - - - - + +Fixes bugs: + - iutilasm.asm wouldn't assemble with newer versions of MASM if +CPU_TYPE was set to 286 or above. + - CPU_TYPE=386 didn't properly substitute the faster +multiply/divide routines under Turbo C++ or Borland C++, only under the +original Turbo C. + +Library +------- + +Fixes bugs: + - A curve whose first and last points were the same wouldn't get +drawn at all. + - A bug in the Turbo C++ compiler generated bad code when shifting +a long right by 1 bit. + - If stroking a dashed line ever encountered a segment that was +completely blank, Ghostscript would indirect through a null pointer. + - arc and arcn gave an error if the radius was negative. + - stroke always used the general algorithm, even if the line was +guaranteed to be thin. + - arc and arcn erroneously reduced the angles mod 360. + - Very large or negative 32-bit numbers in Type 1 fonts didn't +work properly on MS-DOS systems (the ff0000 bits got set to zero). + - Color printer devices rendering entirely in memory only +allocated a monochrome-sized bitmap. + - clip and eoclip didn't intersect the paths properly in the +general case. + - charpath erroneously rounded the current point to an integral +value, causing characters to be spaced improperly. + - The definition of max_color_param got some compilers confused. + - charpath always used quadratic time and space, and dropped all +but the last character when used with a Type 3 font. + - Stroking a path with a 180 degree angle would incorrectly miter +instead of beveling. + - Type 1 fonts used the current flatness for curves, which could +produce bad (and inconsistent) results. + - Stroking a degenerate line segment produced incorrect results. + +Changes the character cache to use the UniqueID as the key, when +available, instead of the font pointer. This dramatically improves +performance when fonts are getting removed and reloaded because of page +isolation with save/restore. + +Removes some unnecessary casts to (float) from gsmatrix.c and gscoord.c. + +Changes the Type 1 interpreter so that it rounds line and curve endpoints +to the center of the nearest half-pixel, and omits null line segments. +This both speeds up rendering at small sizes and improves output quality. + +Changes gs_deviceparams to return resolution as well as extent; changes +gs_makedevice to accept resolution as well as extent. + +Replaces the algorithm for approximating circular arcs with curves with a +more accurate one. + +Changes gs_point and gs_rect to use doubles rather than floats. + +Adds gs_setmetrics, for overriding Type 1 font metrics for the current +character. + +Changes clipping to use lists of rectangles rather than path intersection. + This makes a big difference when clipping bitmaps (including characters). + +Changes the character cache to discard entries incrementally, rather than +clearing the entire cache when it fills up. + +Changes the implementation of transfer functions to use a cached map, +built when the transfer function is set. This makes transfer functions +work properly in all situations, including images. + +Defines a .quit operator that takes an exit code, and redefines quit in +terms of it. + +Adds support for 16-bit-per-pixel devices in gdevmem. + +Adds gs_copydevice and gs_deviceinitialmatrix; removes gs_deviceparams and +gs_makedevice. + +Changes setscreen to ensure that the cell is always at least 4x4 pixels in +size. + +Version 2.3 (8/28/91) +=========== + +This is a minor release to fix two bugs and add the PaintJet driver, which +didn't make it into 2.2. + +Utilities +--------- + +Changes the pstoppm utility so it counts pages correctly even in the +presence of arbitrary saves and restores. + +Drivers +------- + +Adds a new, "supported" PaintJet driver. + +Changes the Epson driver to use ESC+D rather than ESC+\ for horizontal +positioning, since many printers don't support the latter. + +Adds horizontal double-density (two-pass) printing to the Epson driver, so +it can do 240 x 60 and 360 x 180 densities. (Vertical double density is +not supported yet.) + +Version 2.2 (6/1/91) +=========== + +The purpose of this release is to add save/restore, and a few +miscellaneous Level 2 P*stScr*pt features such as undef. It also includes +major improvements in graphics quality and in handling of high-resolution +printers. + +Procedures +---------- + +Changes the version numbering to M.mpp rather than M.m.p, so that +`version' can be a real number for those programs that insist on it. + +Renames ghost.ps as gs_init.ps, gfonts.ps as gs_fonts.ps, and statusd.ps +as gs_statd.ps. The initialization files now all are named gs_*.ps. + +Renames gdevs.{c,h,tl} as gconfig.{c,h,tl}. + +Changes the relevant makefiles and command files so that a single build +can contain several drivers that share code, e.g., the Epson driver and +the DeskJet driver. + +Changes gs_init.ps so it relies on an external gconfig.ps file rather than +making a specific test for the presence of Level 2 features. + +Adds an entry for uglyr.gsf to the makefile. + +Removes the distinction between CCA and CCNA, since most of the files now +contain constructs that require non-ANSI compilation on MS-DOS platforms. + +Adds a `man' page for the ansi2knr utility. + +Changes the documentation (use.doc) to show how to use -sDEVICE=, +or the selectdevice procedure, to select devices by name. + +Adds DEVICE_DEVS to the makefiles (analogous to DEVICES and DEVICE_OBJS). +This finally makes the make procedure fully automatic. + +Adds the name of the initialization file (gs_init.ps) as a +platform-specific makefile parameter, GS_INIT. + +Removes the test program gt.{c,tr} from the fileset, since it is not +useful to users. + +Moves the Symbol encoding vector to a separate file (symbol_e.ps), from +which it is loaded when first used. + +Changes the error handler so it can handle errors that occur while reading +the initialization files. + +Extends ansi2knr so it can handle `void' and `...' in parameter lists. + +Adds quit.ps to the set of installed files. + +MS-DOS-specific changes +- - - - - - - - - - - - + +Adds the VGA and BGI drivers to the standard MS-DOS configuration, and +makes VGA the default. + +Adds a `+' and a newline at the end of gs.tr, to avoid problems with file +transfer programs or editors that add a newline at the end of files. + +Changes the name of msdos.mak to turboc.mak, and creates a new tbcplus.mak +makefile for use with Turbo C++ and Borland C++. + +Changes the extension of the loader response files from .tl to .tr. + +Changes the default search path from c:/ghost and c:/ghost/fonts to c:/gs +and c:/gs/fonts. + +Changes the directory separator from `|' back to ';', since it appears +that DOS can handle a ; in a command line if it is prefixed with \. + +Unix-specific changes +- - - - - - - - - - - + +Changes the uses of install in unixtail.mak so they only install a single +file at a time, which is all that the standard Unix install allows. + +Removes the duplicate files (README/readme, LICENSE/license, +COPYING/copying, Fontmap/fontmap). + +Changes the ld flags from LDPLAT to LDFLAGS. + +Adds XCFLAGS and XLDFLAGS. These are concatenated with CFLAGS and LDFLAGS +respectively. The intention is that they be set from the `make' command +line if desired. + +VMS-specific changes +- - - - - - - - - - + +Repairs the omission of ZPACKED from the VMS build lists. + +Drivers +------- + +Fixes bugs: + - The SunView driver produced semi-garbage on little-endian +platforms (Sun-386i) because it didn't swap the bit order. + - The X driver would dump core if it couldn't open the display and +the DISPLAY environment variable wasn't set. + - The X driver relied on white = 0, black = ones in a couple of +places; + - The X driver would return an error, instead of clipping, if +asked to display outside the window. + - The X driver would create inappropriately sized windows, because +it believed the server's report of the screen resolution. + +Adds Fran Taylor's Private Eye driver to gdevs.mak and the fileset (not +supported by Aladdin Enterprises). + +Adds Neil Ostroff's TruFax driver to gdevs.mak and the fileset (not +supported by Aladdin Enterprises). + +Makes the scratch file template for the printer drivers a per-platform +quantity (gp_scratch_file_name_template). Puts the default scratch files +for Unix in /usr/tmp rather than /tmp. + +Changes the SunView driver to prevent the Ghostscript window from being +destroyed (which badly confuses the interpreter). + +Extends the Epson driver to handle a variety of print densities in both X +and Y, to handle 24-pin as well as 8-pin graphics, and to allow optional +specification of default density in the makefile (gdevs.mak). + +Refactors the printer drivers so that a single driver handles both DeskJet +and LaserJet. Adds LaserJet drivers that use the new compression modes on +the LJ IId/IIp and LJ III. + +Changes all the printer drivers to use band lists rather than bitmap +paging as the buffering method. (The individual drivers need only a +one-line change to replace mem_copy_scan_lines with +gdev_prn_copy_scan_lines with a different argument.) + +Adds the halftone phase as additional arguments to tile_rectangle and +tile_trapezoid. + +Adds an entirely new and much simpler PaintJet driver, using the new band +list interface. + +Adds margin information to the device structure. This is currently only +relevant for printer devices. + +Adds BGIPATH and BGIUSER environment variables, allowing additional +control of the BGI driver. + +Changes the x/y_pixels_per_inch member of the device structure from int to +float. + +Fonts +----- + +Patches gs_fonts.ps so definefont will add an isFixedPitch entry to +FontInfo if there isn't one there. + +Removes the old "type 7 path" encoding code from gs_fonts.ps. + +Changes bdftops so it puts isFixedWidth and ItalicAngle entries in the +FontInfo dictionary of the fonts it creates, since some P*stScr*pt +programs rely on this. + +Changes bdftops so it synthesizes as many missing characters as possible +out of the ones that are there (in particular: synthesizes accents out of +punctuation marks, and accented characters using seac.) The results +aren't all that good, but they're a lot better than having characters +missing out of the font. + +Utilities +--------- + +Adds a pfbtops utility for converting .PFB fonts to standard Ghostscript +fonts. + +Fixes bugs: + - ps2image didn't reset things properly between pages for +multi-page documents. + +Interpreter +----------- + +Makes Ghostscript recognize `-' alone as meaning that it should read from +standard input as though it were a file. This allows Ghostscript to +accept a pipe as input. + +Fixes bugs: + - seac in type1addpath used the current font's encoding, not +StandardEncoding. + - type1decryptfile (eexec) didn't recognize binary (as opposed to +hex) representation. + - Mentioning a name whose value was a no-access object caused an +invalidaccess error. + - There was a bogus definition of `run' in zfile.c. + - The interpreter didn't handle end-of-file on stdin properly. + - Real numbers with an 'e' or 'E' but no decimal point were not +recognized. + - On MS-DOS systems, inside strings, \ followed by a newline was +not discarded properly. + - On MS-DOS systems, the long unsigned divide routine sometimes +gave incorrect answers. Among other things, this caused alternate-radix +numbers sometimes to crash the interpreter. + - cvrs didn't do the right thing about reals or negative integers. + - .echo.mode was being reset with def instead of store, and was +defined in systemdict rather than userdict. + - setgray and settransfer didn't interact properly. + - 16#80000000 was being interpreted as a signed integer (and +converted to a real) rather than an unsigned one. + - atan returned 0 sometimes when it should have returned 180. + - currentcmykcolor was defined wrong. + +Removes the filename operator, since no standard Ghostscript code used it, +and it caused problems with some P*stScr*pt files. + +Implements new operators: filenameforall, selectfont (as a procedure), +stringmatch, undef. + +Adds new standard procedures: selectdevice. + +For MS-DOS, requires that the operand and execution stacks be located in +the data segment, and uses short pointers to address them. This produces +significantly smaller and faster code. (These changes are not visible to +users or library clients.) + +Changes the assignment of attribute bits, and adds new bits for +save/restore and the garbage collector. Changes many of the macros in +store.h to support save/restore. (These changes are not visible to users +or library clients.) Implements save and restore. + +Moves type names from gs_init.ps to ghost.h and ztype.c. + +Moves error names from gs_init.ps to errors.h and iinit.c. + +Introduces gp.h as a documented interface to the platform-specific files. + +Adds the -- switch, which allows Ghostscript programs to take arguments +from the command line. + +Changes many uses of the name `name' to something else, to avoid upsetting +the Microsoft C compiler. + +Really implements packed arrays -- they took the same amount of space as +ordinary arrays in previous versions. + +Changes exitserver in serverdict so that it just clears the stacks. (This +isn't the correct fix, but it will do as a workaround.) + +Makes many miscellaneous small changes to pacify various compilers. + +Changes gs_fonts.ps so that when "quiet" mode is selected (-q switch), +Ghostscript doesn't print anything when loading fonts or when substituting +for undefined characters. + +Defines the name consisting of just a control-D as a no-op, because some +P*stScr*pt-generating applications put control-Ds in their output. + +Implements halftone phase (sethalftonephase and currenthalftonephase +operators). + +Removes the -E switch, since it is no longer useful. + +Changes the -w and -h switches to a single -g (geometry) switch, with +usage -gx. Makes the -h switch, and a new -? switch, print +usage help. + +Implements correct handling of stack overflow errors (makes an array out +of the contents of the overflowing stack, and resets the stack, before +invoking the error handler). + +Adds t_oparray (`operators' defined as procedures) and the makeoperator +operator. This is so that programs like the Distillery that rely on all +operators being bound by `bind' will work properly. + +Adds a new NOPAUSE flag to suppress the prompt and pause at copypage and +showpage. + +Library +------- + +Fixes bugs: + - gs_type1_interpret didn't store the encryption state or the skip +count before returning to let the client handle a seac or an endchar in +the middle of a seac. + - The definition of the Type 1 operator ce_testadd was based on +wrong information; the operator takes only 2 operands and does something +unknown. + - mem_true24_copy_mono wasn't incrementing the destination pointer +if the color was transparent, leading to garbled characters. + - gx_lookup_fm_pair would sometimes look at one entry beyond the +end of the cached font/matrix pair area. (This probably had no practical +effect.) + - gs_type1_interpret didn't save the current point when returning +to the client for a callothersubr, causing some characters to be rendered +displaced (such as some of the chess pieces in chess.ps). + - gs_setgray, gs_sethsbcolor, gs_setrgbcolor, gs_setflat, and +gs_setlinewidth gave errors for out-of-range operands rather than forcing +them into range. + - Transfer functions were not actually supported. + - The area fill algorithm failed on certain complex paths. + - The current point was sometimes defined when a BuildChar +procedure was called. + - Stroking a degenerate line didn't display anything for round +caps or joins. + - If the ends of a curve had exactly the same X coordinate, the +curve sometimes wouldn't be displayed. + - Very thin lines that went outside the clipping region would +sometimes be displayed as dashed, or not at all. + - The translation in a FontMatrix was ignored. + - Very wide, shallow lines would color extraneous pixels when +using bevel or miter joins. + - Dashed lines didn't join properly at the beginning of a closed +path. + - 0-degree arcs didn't add the appropriate line (possibly +degenerate) to the path. + - gs_type1_interpret didn't reset the callsubr stack when starting +the base character of a seac, which caused confusion if the accent's +endchar fell inside a Subr. + - Non-monochrome memory memory devices weren't checking the +arguments of the drawing procedures properly. + - The initial clipping rectangle for memory devices was being +computed wrong. + - Null devices had a semi-infinite clipping rectangle instead of +an empty one. + - gs_setlinewidth was treating negative arguments as zero, instead +of taking the absolute value. + - imagemask with a dithered color used a solid color rather than +the dithered one. + +Tweaks the area fill and image rendering algorithms to be a little more +liberal with paint when being used to render characters. + +Changes the name of the 8-bit mapped color memory device from +mem_mapped_color_device to mem_mapped8_color_device. + +Changes the memory devices so that on little-endian platforms, they can +store the bytes within a word in either order. (Little-endian order +allows efficient 32-bit updating, big-endian is required when displaying +or writing to a printer or a file.) + +Implements halftone phase. + +Replaces the trapezoid fill algorithm with a much more accurate one +inspired by a contribution from Paul Haeberli. This also changes the +graphics convention back to filling only pixels whose center falls within +the region to be filled. + +Changes the character cache to allocate headers and bits contiguously out +of a single ring buffer. + +Changes gs_imagemask and gs_imagemask_init to take a thickness adjustment +parameter. + +Changes gs_setcachedevice and gs_setcharwidth to take the graphics state +as a parameter. + +Renames gx_device_memory_bitmap_size as gdev_mem_bitmap_size, +mem_copy_scan_lines as gdev_mem_copy_scan_lines, and +mem_bytes_per_scan_line as gdev_mem_bytes_per_scan_line. + +Version 2.1.1 (1/15/91) +============= + +This is a sub-release distributed to fix a few early bugs in 2.1, just in +time for the new GNU master tape. + +Build procedures +---------------- + +Removes all of the (undebugged) Level 2 code from the fileset, as well as +the (unused) file gdevvga.c. + +Changes the tar file so that the files are stored in the directory +gs rather than simply gs, e.g., gs211. + +Interpreter +----------- + +Changes the scanner so that \ is recognized within strings regardless of +whether the scanner is reading from a string or from a file. This is +compatible with newer P*stScr*pt interpreters, and with the newer +P*stSc*pt language specification, but not with the older specification in +the original PostScript Language Reference Manual. + +Drivers +------- + +Fixes the max_value macro in gdevmem.c so that compilers won't complain +about a left shift by 32. + +Adds 'byte' to the list of types that gdevx.c must sidestep because header +files use them. + +Library +------- + +Changes the computation of penum->unpack in gsimage.c so as not to upset +compilers that don't treat procedures and pointers to procedures as +compatible types for conditional expressions. + +Version 2.1 (12/31/90) +=========== + +This is primarily a bug fix release to clean up problems in 2.0. It also +implements a first cut at the new color operators. + +Build procedures +---------------- + +Changes the separator for multiple directories in MS-DOS from ';' to '|', +since there is no way to include a ';' in a command line. + +Adds /fonts to the default search path, where is c:/ghost for +MS-DOS systems and `pwd` for Unix systems. + +Adds new documentation describing how to direct output to the printer. + +Changes the PROCTYPE and USE8087 options in MSDOS.MAK to CPU_TYPE and +FPU_TYPE. The latter now indicates the type of FPU to generate code for, +if any. + +Drivers +------- + +Adds a driver for the Canon BubbleJet BJ10e. + +Modifies the EGA driver to handle (non-standard) frame buffers larger than +64K. Adds drivers for the VGA and for the EIZO MDB-10 (a 1024 x 768 frame +buffer). + +Changes the X driver so that it clips to the window dimensions, rather +than reporting an error. + +Notes that the H-P LaserJet driver, like the DeskJet driver, works under +Unix as well as MS-DOS. + +Adds support for 120 X DPI mode, and for the LQ-1500, to the Epson driver. + +Fonts +----- + +Fixes bugs in bdftops: + - It was using /UniqueId instead of /UniqueID as the key for the +font unique ID. This effectively disabled the font cache. + - The definition for .notdef was bogus -- an invalid CharString. + +Changes ghost.ps and gfonts.ps so that NullFont is the initial font, +rather than Ugly. + +Arranges things so that when attempting a font substitution, if the +default font is not found, NullFont is used instead. + +Extends bdftops so that if certain easily synthesized characters are +missing from a font, it will attempt to synthesize them using available +characters. + +Interpreter +----------- + +Extends the -T switch to allow specifying a printf template for the +arguments of the procedure being traced. + +Fixes bugs: + - /0 was interpreted as equivalent to 0 (a number) rather than a +literal name. + - packedarray was defined as being like array, instead of like +array followed by astore. + - Many minor and harmless type mismatches (and a couple of very +minor genuine bugs) were upsetting the Apollo C compiler. + - exp was incorrectly failing in certain cases with a negative +first argument. + - copyscanlines incorrectly required at least 4 elements on the +operand stack, although it correctly only used the top 3. + - readhexstring incorrectly read 1 byte even if the string length +was zero. + - Not every place that expected an array would accept a packed +array. + - Very complex paths (and infrequently other things) could produce +a 'memory leak'. + - / alone would skip following whitespace and gather following +characters, rather than creating an empty name. + - ghost.ps left newerror defined as true in $error, which resulted +in an erroneous error report if a program executed a 'stop'. + - The definition of exitserver in serverdict didn't clear the +stack. + - currentfile returned an executable file, rather than a literal +one. + - setfont for Type 1 fonts didn't check the UniqueID in the font +dictionary against the one in the font's Private dictionary. + - A value stored in a dictionary under the key /xxx couldn't be +retrieved using the key (xxx), and vice versa. + - charpath with a Type 1 font on a string containing a 'space' +would produce garbage (it released the parent path inappropriately). + - bytesavailable did not work properly for terminal input. + +Changes the interface to the memory allocator so that it always takes an +element size and an element count, like calloc instead of malloc (but note +that alloc does *not* clear just-allocated blocks). Gets rid of the +special 'dynamic' allocation procedures. + +Changes the random number operators to use a better implementation. + +Changes the idiv operator so it will accept any numbers, not just +integers, as arguments. (The PostScript manual doesn't allow this, but +implementations apparently do.) + +Provides semi-fake but usable definitions for all of the color PostScript +extensions, including a real implementation of colorimage. + +No longer uses the name 'null', which is apparently reserved by Microsoft +C. Makes a number of other minor changes required to pacify the Microsoft +C compiler. + +Implements %statementedit and %lineedit. (%statementedit is equivalent to +%lineedit, which is wrong.) Changes the interactive interpreter to use +%statementedit. + +Changes the scanner to accept null, ctrl-K (vertical tab), and ctrl-L +(form feed) as whitespace. Ctrl-L terminates a comment, null and ctrl-K +do not. + +Allows a literal string as the 'proc' argument(s) for image, imagemask, +and colorimage. + +Adds the following operators/procedures: arct, cleardictstack, deletefile, +renamefile. + +Defines =print as a synonym for =, for the benefit of LaserPrep. + +Implements non-zero PaintType for the show operators (but not for +charpath) for Type 1 fonts. + +Adds the ISOLatin1Encoding encoding vector. + +Renames currentcolor and setcolor as currentgscolor and setgscolor, to +avoid conflict with the Level 2 PostScript names. Removes colorhsb, +colorrgb, hsbcolor, and rgbcolor. + +Library +------- + +Fixes bugs: + - In a couple of places, a 0 was being passed as a pointer +argument without casting, which confused the Microsoft C compiler. + - Image devices were not recognized properly in debugging +configurations. + - Inverted-color monochrome image devices were not recognized +properly. + - Images that exactly fill the drawing area rendered very slowly, +because they erroneously used the general clipping algorithm. + - Images that are 1-for-1 with the device were incorrectly scaled +by a factor of 8 in X. + - Rounding artifacts sometimes caused characters to be unevenly +offset vertically by 1 pixel. + - Type 1 fonts that used the Flex feature resulted in garbled +images. + - The show operator routines would incorrectly fill or stroke a +path that existed at the time the show was started. + - setscreen truncated the cell size instead of rounding, which +could produce off-by-1 anomalies. + - stroke would sometimes produce garbage (or nothing at all) for +very narrow lines. + - path filling would only color the pixels whose centers fell +inside the path: the Adobe specification requires coloring a pixel if any +part of it falls inside the path. + +Changes the Epson printer driver so that it drives the printer directly +rather than writing to a file. + +Changes pathbbox so that if the path is empty but there is a current +point, it returns a null rectangle at the current point. + +Changes gs_image_init to take an additional parameter (after bps) giving +the number of samples per pixel (1, 3, or 4), and an indication of whether +the samples for each pixel are together or separated (-3 or -4). + +Renames the gs_image_data and gs_imagemask_data procedures as gs_image and +gs_imagemask, and removes the old versions of the latter. + +Adds gs_colorimage. + +Replaces Snoopy's color dithering algorithm with one contributed by Paul +Haeberli. + +Changes gs_setgray, gs_[set]hsbcolor, and gs_[set]rgbcolor so that they +coerce arguments outside the range [0..1] back into the range, instead of +signalling an error. + +Makes a number of minor changes required to pacify the Microsoft C +compiler. + +Changes gs_arcto so that if the last argument is a null pointer, the +tangent points are not returned. + +Removes gs_type1addpath, which is not useful. (Clients must call +gs_type1_init and gs_type1_interpret directly.) + +Implements the 'seac' opcode for Type 1 fonts, allowing fonts with accented +characters to display properly. + +Implements the undocumented 'testadd' opcode for Type 1 fonts, which is +used by some Adobe fonts. + +Renames gs_currentcolor and gs_setcolor as gs_currentgscolor and +gs_setgscolor. Removes gs_colorhsb, gs_colorrgb, gs_hsbcolor, and +gs_rgbcolor. + +Version 2.0 (9/12/90) +=========== + +The main purpose of this release is to add fonts, support for multiple +devices, and imaging into memory. It also fixes a number of miscellaneous +bugs. (Unfortunately, accurate records of the bugs fixed are not +available.) The changes were so extensive that we chose to increment the +major version number. + +Miscellaneous +------------- + +Doesn't attempt to open the .MAP file on Unix systems. + +Adds mention of statusd.ps to interp.doc. + +Notes that Turbo C 2.0, not 1.5, is required for building the MS-DOS +version. + +Adds a DEVICES= line to the makefile, and allows multiple devices. + +Documents, in interp.doc, the X Windows resources that Ghostscript +recognizes. + +Adds three PostScript masters to the fileset: chess.ps (+ cheq.ps), +golfer.ps, and escher.ps. + +Drivers +------- + +Changes the names of all the device drivers. See gdevs.mak for the +updated list. + +Adds a (working) driver for SunView. + +Adds drivers for the Sony NeWS frame buffer, and the Sony Microsystems +NWP533 printers. These drivers were contributed by users, so we aren't +prepared to answer questions about them. + +Adds a driver for the Borland Graphics Interface (BGI) for MS-DOS systems. +Note that to use this driver with a non-EGA/VGA display, you need a .BGI +file appropriate for your hardware. (The Ghostscript executable includes +the EGA/VGA driver.) + +Adds a driver for Epson printers. The driver has only been tested on an +LX-800, and on an H-P DeskJet in FX-80 emulation mode, but may work on +other models. The driver could be adapted to work on Unix systems, but as +distributed, it only works on MS-DOS systems. + +Adds a driver for the Hewlett-Packard DeskJet printer. The driver could +be adapted to work on Unix systems, but as distributed, it only works on +MS-DOS systems. + +The X Windows driver no longer waits for the user to type a character +before bringing up the initial display. + +Adds information to drivers.doc describing how to change the definition of +the device structure and procedure table. + +Extends the tile_rectangle and tile_trapezoid driver procedures to +interpret color0 = color1 = gx_no_color_index as meaning that the tile is +actually colored, not a mask. + +Build procedures +---------------- + +Changes the tar file so it puts everything in a directory called gs. + +Removes the -ansi switch for gcc (this was causing problems with +on some systems). + +Changes LDPLAT to the string -X, which is appropriate for most Unix +systems (but not for SunOS 4.n). + +Adds EXTRALIBS to the makefile, for specifying additional libraries to be +linked in. + +Adds a 'clean' target for 'make', to get rid of all temporary files, the +binaries, and the executable. + +Changes names of system-specific files from gp-xxx.c to gp_xxx.c. + +Adds support for VMS (gp_vms.c and ghost.dcl). + +Creates a new file gdevs.mak, and reorganizes the other makefiles, so that +the choice of which device driver(s) to include is isolated in a single +line in the platform-specific makefile. + +Changes the standard MS-DOS makefile so it builds for 8088/86 (not 80386), +with neither -DNOPRIVATE nor -DDEBUG. + +Changes the name of the MS-DOS makefile from dos-ega.mak to msdos.mak, and +the Unix makefiles from ux-[g]cc-x.mak to unix-[g]cc.mak. + +Updates drivers.doc to describe how to add new drivers in gdevs.mak. + +Removes gdevs.ps: the drivers are now responsible for specifying the size +of the imaging region. + +Interpreter +----------- + +Adds a makefile macro GS_LIB_DEFAULT and an environment variable GS_LIB to +define a search path for the library (initialization and font) files, and +implements the -I switch for the same purpose (replacing -sLIB=, which was +never actually implemented). See interp.doc for details. + +No longer clears the operand stack between interactive inputs. No longer +prints the contents of the operand stack after every input in debug mode. + +Doesn't "eat" the character that the user types to proceed after a +showpage, unless it's an isolated . + +Changes the prompt so that it says + GS> +if the operand stack is empty, or + GS +if there are n > 0 elements on the operand stack. + +Adds -w and -h switches to the command line, equivalent to -dWIDTH= and +-dHEIGHT= except that they require numeric arguments. + +Adds -q (quiet startup) switch to the command line, which suppresses some +initial messages and also has an effect equivalent to -dQUIET. + +Fixes bugs: + - = and == caused an error on some kinds of objects if the object +didn't have read access. + - cvs didn't print operator names. + - The definition of dynamic_begin in iscan.c caused the DEC VMS C +compiler to produce incorrect code. + - mul didn't return a correct (real) result when multiplying a +very large integer by an integer that wasn't very large. + - eq and ne didn't work on files, fonts, save objects, and some +operators. + - The scanner would sometimes blow up on floating point numbers +beginning with a '.'. + - flushfile didn't pop its argument from the stack. + - put and putinterval would store into a packed array. + - a few operators didn't check properly for stack underflow. + - cvrs produced wrong output for radix values greater than 10. + - The scanner would convert upper-case letters in alternate-radix +numbers wrong on Unix systems. + - String comparisons other than equality often produced the wrong +result if the strings were of different lengths. + - An ifelse as the last thing inside a forall would confuse the +execution stack. + - There were some omitted casts and 'private' declarations that +made the GNU compiler unhappy. + - There was a memory leak in the image[mask] operators that caused +516 bytes to be permanently lost each time one of them was used. + - Quoted strings of length greater than 50 and less than 100 would +get mangled when being read in. + - The scanner didn't consume the whitespace character following a +token, so programs that read data out of the program file could get +confused. + - Under rare circumstances, an object of size between 249 and 255 +bytes could get allocated on top of another object. + +Allows bind to bind packed arrays, even though they aren't normally +writable. + +Changes the length operator to allow a name as the argument. (The +PostScript manual doesn't allow this, but implementations apparently do.) + +Changes the setcachedevice operator to allow the bounding box to be +specified as a 4-element array instead of 4 scalars. (The PostScript +manual doesn't allow this, but implementations apparently do.) + +Removes a line from ghost.ps that accidentally disabled the font cache. + +Implements memory devices (makeimagedevice, copyscanlines, and makedevice +for image devices). makeimagedevice is implemented only for 1, 8, 24, and +32 bits per pixel. + +Changes the deviceparams operator so it pushes a mark on the stack below +the parameters. This is to allow for devices that have more than the +standard set of parameters. + +Replaces defaultdevicename with two new operators, getdevice and +devicename. + +Adds a flushpage operator that flushes any outstanding buffered output to +the screen. This is not the same as copypage: on printers, copypage +actually prints a page, whereas flushpage may do nothing; on displays, +flushpage and copypage may both flush output to a server. + +Adds an unread operator for pushing back a character into a file. + +Adds a description of proposed grayimage and colorimage operators to +ghost.doc, even though they aren't implemented yet. + +Changes the name of the currentfileposition operator to fileposition. + +Removes the framedevice operator, since the new device operators supersede +it. + +Adds a writeppmfile operator, for writing the contents of a memory device +to a ppm file. + +Makes Ghostscript work even when the >> operator doesn't sign-extend +negative numbers. (This has not been tested.) + +Adds the Symbol encoding to ghost.ps. + +Adds two new file-related operators, filename and findlibfile. See +ghost.doc and interp.doc for details. + +Adds type1encrypt and type1decrypt operators for manipulating Adobe Type 1 +encoded fonts. + +Changes the imagecharpath and addcharpath operators to type1imagepath and +type1addpath. These operators now work with the Adobe Type 1 font +encoding. + +Adds the type1decryptfile operator for reading Adobe Type 1 encrypted +fonts. + +Library +------- + +Fixes bugs: + - curveto and lineto didn't check for the current point being +defined. + - stringwidth would fail if there was no current point. + - There were omitted casts that made the GNU compiler unhappy. + - Line caps and joins didn't always work. + - Dashed lines didn't work at all. + - If you read out the current matrix while inside a BuildChar +procedure, the result was garbage. + - image[mask] would crash if you gave it a single string with more +than 64K-1 pixels (MS-DOS only). + - Filling with a gray pattern sometimes wrote into pixels beyond +the right edge of the region (MS-DOS only). + - The font cache would mistake fonts for each other if both fonts +had a default (unsupplied) "unique ID". + - When a character was entered into the font cache for the first +time, sometimes it would display as garbage and/or displaced vertically +from its proper position. + +Implements gs_makeimagedevice, gs_copyscanlines, gs_getdevice, +gs_devicename, gs_flushpage, gs_writeppmfile, gs_type1encrypt, +gs_type1decrypt, gs_type1imagepath, and gs_type1addpath procedures +corresponding to the new operators in the interpreter (see preceding +section). + +Changes [gs_]setdevice so that it does an erasepage when it first opens +the device. + +Changes definition of gx_device structure as follows. NOTE: THIS AFFECTS +ALL DRIVERS. + + - Removes bits_from_MSB (which wasn't actually used, in any case). + Ghostscript now assumes officially, as it always did in + practice, that device bitmaps are stored MSB first, i.e., X=0 + corresponds to the 0x80 bit in the first byte. + + - Removes the initial_matrix member, which wasn't actually being + set up. + + - Adds a new member 'name', a string giving the device name. + + - Adds new members 'x_pixels_per_inch' and 'y_pixels_per_inch'. + These are only used by the default initial_matrix procedure + (see below). + + - Adds a new procedure 'output_page'. The default implementation + (gx_default_output_page) just calls the sync_output procedure. + + - Adds a new procedure 'get_initial_matrix'. The default + procedure uses the width, height, and x/y_pixels_per_inch + members to compute the matrix, assuming that X values run from + right to left, and Y values run from top to bottom. + +Changes the names of the allocation procedure types gs_proc_alloc and +gs_proc_free to proc_alloc_t and proc_free_t, and moves them from gs.h to +std.h. + +Makes Ghostscript work even when the >> operator doesn't sign-extend +negative numbers. (This has not been tested.) + +Versions before 2.0 +=================== + +See the file history1.txt. diff --git a/gs/history3.txt b/gs/history3.txt new file mode 100644 index 000000000..55259f730 --- /dev/null +++ b/gs/history3.txt @@ -0,0 +1,8284 @@ + Copyright (C) 1996 Aladdin Enterprises. All rights reserved. + + This file is part of Aladdin Ghostscript. + + Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author + or distributor accepts any responsibility for the consequences of using it, + or for whether it serves any particular purpose or works at all, unless he + or she says so in writing. Refer to the Aladdin Ghostscript Free Public + License (the "License") for full details. + + Every copy of Aladdin Ghostscript must include a copy of the License, + normally in a plain ASCII text file named PUBLIC. The License grants you + the right to copy, modify and redistribute Aladdin Ghostscript, but only + under certain conditions described in the License. Among other things, the + License requires that the copyright notice and this notice be preserved on + all copies. + +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +This file, history3.txt, describes the changes in older releases of +Ghostscript numbered 3.n. For more recent changes, see the NEWS file. + +For an overview of Ghostscript and a list of the documentation files, see +README. + +Version 3.70 patch 1 (6/24/96) +==================== + +This contains a few last-minute patches before the release. + +Procedures +---------- + +Comments out the color inkjet drivers in the cc-based makefile, because a +bug in Sun's cc prevents them from compiling. (cc-head.mak) + +Drivers +------- + +Fixes bugs: + - The os2prn driver smashed memory. (gdevos2p.c) + - Some initialized structures weren't declared 'static'. +(gdevpdf.c, gdevpdfm.c) + - The PNG driver wouldn't compile with some older versions of the +PNG library. (gdevpng.c) + +Version 3.70(limited) (6/23/96) +===================== + +This is the candidate fileset for 4.0. Aside from one optimization for the +PDF writer, the only changes are bug fixes. + +Documentation +------------- + +Renames all the documentation files from *.doc to *.txt, since the .doc +extension didn't give any information about the format of the file. +(readme, *.doc, *.txt) + +Notes that IJG JPEG library v6[a] is now required. (jpeg.mak) + +Brings ps2pdf.1 up to date. (ps2pdf.1) + +Adds a new file describing Aladdin's C coding practices. (c-style.txt) + +Updates the man pages to refer to version 4.0. (gs.1, pdf2ps.1, ps2ascii.1, +ps2pdf.1) + +Procedures +---------- + +Changes some file names to fit within the MS-DOS 8.3 limit. (gs.mak) + +Adds the PDF writer to the remaining 32-bit configurations (Watcom, OS/2, +MSC). (watc.mak, watcwin.mak, os2.mak, msc.mak, msvcwint.mak) + +Changes the -sFONTMAP= switch so it can take a list of font names, like a +search path. (use.txt) + +Drivers +------- + +Fixes bugs: + - Signed and unsigned values were mixed inconsistently. (gdevcdj.c) + - PDF files could contain e-format floating point numbers, which the +PDF specification doesn't allow. (gdevpdfx.h, gdevpdf*.c) + - The PDF writer didn't handle glyphshow properly. (gs_pdfwr.ps) + - The PDF writer did the wrong thing with fonts whose FontMatrix had +a non-zero translation component. (gs_pdfwr.ps, gdevpdft.c) + - The stand-alone bounding box device could crash when setting +parameters. (gdevbbox.c) + - The mswinpr2 driver smashed memory. (gdevwpr2.c) + +Changes the PDF writer so that if it encounters a re-encoded character, it +tries to map it to an encoded character in the standard (ISO Latin-1) +encoding rather than converting the entire string containing it to a bitmap. +This dramatically improves output file size for files with a few divergently +encoded characters, but it may cause the text in the PDF file to differ from +the text in the PostScript input. (gdevpdft.c) + +Disallows BitsPerPixel=16 in the MS Windows and OS/2 drivers, since this bit +depth is not supported by Windows and would require special extra buffering. +(install.txt, dwtext.h, dwtext.cpp, gdevmswn.c, gdevpm.c, gdevwpr2.c) + +Platforms +--------- + +Fixes bugs: + - On the PC platforms, file names weren't changed to reflect the +value of CONFIG. (gs.mak, bc*.mak, ms*.mak, os2.mak, tc*.mak, watc*.mak, +wccommon.mak) + +Modifies some makefiles for greater reusability. (bclib.mak, watclib.mak) + +Fonts +----- + +Changes the font searching rules in the following NON-BACKWARD-COMPATIBLE +way: (gs_fonts.ps, gs_res.ps) + - -sFONTMAP=files specifies a list of files containing fontmaps; +previously, it specified only a single fontmap file. + - If -sFONTMAP= is not used, the interpreter reads the Fontmaps from +*all* directories on the search path, and does so even if FONTPATH or +GS_FONTPATH is set; previously, it read only the first Fontmap, and only if +[GS_]FONTPATH was not set. + - Fontmap(s) take precedence over [GS_]FONTPATH; previously, +[GS_]FONTPATH caused Fontmap to be ignored. (You can still force Fontmap to +be ignored with -dNOFONTMAP.) + - Earlier [GS_]FONTPATH entries take precedence over later; +previously, later entries took precedence over earlier. Note that this is +different from Fontmap: earlier Fontmaps in the search path take precedence +over later, but within a single Fontmap, later entries take precedence over +earlier (for backward compatibility). + - [GS_]FONTPATH is consulted only if there is no Fontmap entry for a +font, or no Fontmap entry leads to successful loading; previously, +[GS_]FONTPATH was always consulted at startup. + - If loading a font fails, the interpreter tries the next Fontmap +entry; previously, it fell back to font substitution. + +Interpreter +----------- + +Fixes bugs: + - Filters didn't peek ahead for an EOD (see Streams below). +(zfileio.c, zpaint.c) + +Splits up a file to allow internal access to user and system parameters even +in Level 1. (zmisc2.c, zusparam.c) + +Adds LIBPATH as a predefined name in systemdict. Its value is an array of +strings comprising the library search path. (imain.c) + +Interpreter (PDF) +----------------- + +Fixes bugs: + - A Dests dictionary entry with an array (rather than a dictionary) +value caused an error. (pdf_main.ps) + - Rotated pages could have incorrect translation and/or clipping. +(pdf_main.ps) + +Streams +------- + +Fixes bugs: + - If a buffer boundary fell just before an EOD, and the client read +exactly as much data as was present before the EOD, filters didn't consume +the EOD. (This is required as a tricky consequence of the Adobe +specification.) (stream.h, strimpl.h, stream.c) + +Library +------- + +Fixes bugs: + - An extra column of bits could get turned on at the right edge of +masked or monochrome images. (gximage2.c) + - Rasterizing very long curves could cause arithmetic errors or +floating point overflows. (gxpcopy.c) + - Banding with large line widths could truncate curves or introduce +spurious lines. (gxclpath.c) + +Version 3.69(limited) (6/14/96) +===================== + +More bug fixes, plus one irresistible new feature: the ability to use +TrueType fonts as freely as Type 1 fonts. Also, one new feature (outside +clipping) that was needed for Aladdin's PCL XL project. We incremented the +version number because of the change in trapezoid and path filling (see +under Library below). + +Documentation +------------- + +Brings documentation about fonts up to date. (fonts.doc) + +Updates current.doc to reflect changes since 3.53. (current.doc) + +Updates the DLL documentation to reflect recent changes. (dll.doc) + +Documents a workaround for the code generation bug in gcc 2.7.x. (make.doc) + +Changes the contact information for potential commercial customers in +Europe. (new-user.doc) + +Updates the OS/2 documentation to make it current. (install.doc, make.doc) + +Documents -dCOLORSCREEN=0. (use.doc) + +Procedures +---------- + +Fixes bugs: + - 'make clean' didn't work in the Watcom environment. +(wmakebat.bat, gs.mak, msc.mak, msvcwint.mak, os2.mak, tccommon.mak, +unixhead.mak, wccommon.mak) + - The X11 libraries were listed in an incorrect order. +(ansihead.mak, cc-head.mak, gcc-head.mak, ugcclib.mak, unix-end.mak) + - The OS/2 makefile didn't ignore errors from `erase' commands. +(os2.mak) + +Adds the PDF writer to the 32-bit MS Windows configuration. (bcwin32.mak) + +Adds the PNG drivers to the 32-bit MS Windows platform, since they now +compile properly. (bcwin32.mak) + +Changes the ttfont feature so that it refers to support for direct usage of +TrueType fonts; puts support for Type 42 fonts into a separate feature +(type42). (gs.mak, int.mak) + +Adds direct TrueType font support to the Windows platforms. (bcwin.mak, +bcwin32.mak) + +Rewrites vms.mak to be structured more like the other makefiles. (vms.mak, +modules.lis) + +Makes the device lists in vms-*.mak the same as those for the Unix +configurations. (vms-cc.mak, vms-decc.mak, vms-gcc.mak) + +Changes the default X library directory for gcc to /usr/X11/lib. +(gcc-head.mak) + +Adds the list of devices to --help, since HylaFax depends on this. +(imainarg.c) + +Adds -dCOLORSCREEN=0 to indicate use of 4 separate color screens with the +same frequency and angle. (gs_init.ps) + +Utilities +--------- + +Fixes bugs: + - When ps2epsi encountered a blank page, it called the +(undocumented) .quit operator with only one argument, causing a stack +underflow. (ps2epsi.ps) + - An extraneous file was included in the fileset. (checkacc.ps) + - A file was omitted from the fileset. (bench.c) + - Images in PostScript files produced by pdf2ps were processed about +50 times slower than they should have been. (gs_pdf.ps) + +Drivers +------- + +Fixes bugs: + - An #include was omitted. (gdevpdfi.c) + - The BJC driver could get into an inconsistent state. (gdevcdj.c) + - Braces were omitted around the values for two initialized byte +arrays. (gdevpcx.c) + - A function used 'float' in its argument list, causing problems in +mixed ANSI/non-ANSI compilation. (gdevcdj.c) + - signed and unsigned char pointers were used inconsistently. +(gdevcdj.c, gdevcgml.c) + - Some header files weren't protected against double inclusion. +(gdevprn.h, gdevtifs.h) + - The 24-bit PNG driver included unnecessary copies of the color +mapping procedures. (gdevpng.c) + +Fixes bugs in the PDF writer: + - The PDF writer sometimes produced a double // in front of a filter +name. (gdevpdfi.c) + - The PDF writer produced zero-width, zero-height images for +non-standard fonts. (bug introduced since 3.68) (gdevpdfi.c) + - The PDF writer got confused if the input file invoked +setpagedevice. (gdevpdfp.c) + - The PDF writer put annotations on the page after the one they were +supposed to be on. (gdevpdf.c) + - The PDF writer sometimes failed to set the font when needed. +(gdevpdf.c) + - The PDF writer could produce in-line images that were too large. +(gdevpdfi.c) + - The PDF writer didn't scale explicit character and word spacing +(ashow/widthshow/awidthshow) properly. (gdevpdft.c) + - The PDF writer didn't copy named destination or article title +strings, possibly leading to dangling pointers. (gdevpdf.c, gdevpdfm.c) + - The PDF writer produced incorrect output for re-encoded fonts. +(It now converts any string containing characters in non-standard positions +to bitmaps; this will be fixed in a later release.) (gs_pdfwr.ps, +gdevpdfx.h, gdevpdfp.c, gdevpdft.c) + +Updates a few drivers for the change in the handling of band device +procedures. (gdevcp50.c, gdevdjet.c) + +Updates the X Windows driver for strip halftones. (gdevx.c) + +Adds anti-aliasing capability to the os2pm device. (gdevpm.c) + +Increases the sizes of some tables in the PDF writer. (gdevpdfx.h) + +Platforms +--------- + +Fixes bugs: + - A patch for the MS Windows platform was accidentally omitted. +(gp_mswin.c) + - A block of code was accidentally duplicated. (dwmain.cpp) + - An identifier exceeded VAX VMS C's limit of 31 characters. +(gscspace.h) + - File name enumeration didn't work properly on Unix systems +(still/again). (gp_unifs.c) + - On MS Windows, If you closed Ghostscript with the system menu, you +only closed the text window; Ghostscript kept running and you had to use the +task manager to kill it. (dwmain.cpp, dwmainc.cpp, dwtext.cpp) + - Some DLL-related typedefs were not consistent. (dwdll.h, gsdll.h, +dpmainc.c, dwdll.cpp) + - Attempts to call the DLL before it was initialized were not +detected. (gsdll.c) + - Bitmap line lengths were rounded up even on 32-bit Windows, which +doesn't want this. (gdevwdib.c) + +Further improves the handling of attempts to use the DLL when it is already +in use. (dwdll.cpp, gsdll.c) + +Adds a DLL-compatible main program for OS/2. (dpmainc.c, gp_os2.c, gsdll.c) + +Fonts +----- + +Fixes bugs: + - The WingDings TrueType font wasn't loaded properly. (gs_ttf.ps) + +Makes changes so that TrueType fonts can appear in the Fontmap and can be +loaded directly. (gs_fonts.ps, gs_ttf.ps) + +Interpreter +----------- + +Fixes bugs: + - Executing a .quit with only 1 element on the operand stack caused +an invalid access. (zcontrol.c) + - The usage help message contained incorrect double %%s. +(imainarg.c) + - If an initialization file tried to use any Encodings other than +the 4 registered ones, it couldn't find them. (gs_init.ps, gs_res.ps) + - Places that expected arrays of coordinates (rectangles, +x/y/xyshow) didn't accept packed arrays. (ibnum.c, zdps1.c) + - filterdict was still visible after initialization. (gs_init.ps) + - The usage error message wasn't terminated by a newline. +(imainarg.c) + - setcacheparams (or setting the MaxFontCache user parameter) didn't +actually affect the size of the character cache. (zfont.c, zmisc2.c) + - The main interpreter loop declared iref as a ref *, even though it +may only be a ref_packed *. (iref.h, interp.c) + +Changes the character cache so it ignores absurd FontBBox values. Nothing +in the Adobe spec suggests doing this, but it is necessary for handling +questionable output produced by PageMaker 5.0 (an Adobe product!). +(zchar1.c) + +Changes some type declarations slightly to reduce the number of 'discarding +const' compiler warnings. (igc.h, igc.c, igcref.c) + +Adds .setclipoutside and .currentclipoutside operators for accessing the new +outside clipping capability. (zpath.c) + +Adds the dictionary stack to the information printed in case of a fatal +problem. (imain.c) + +Adds .set/currentrenderalgorithm operators for testing. (zrop.c) + +Library +------- + +Fixes bugs: + - The TrueType rasterizer didn't map quadratic to cubic splines +well, and didn't handle off-curve points at the end of a contour properly. +(gstype42.c) + - An #include was omitted. (gsimage.c, gxclimag.c) + - Some compilers complained about statements with no effect, or +comma operators with no effect on the left. (gschar.c, gxcpath.c, gxfill.c) + - TrueType or Type 42 glyphs with a repeat count that crossed a +contour boundary produced incorrect output. (gstype42.c) + - TrueType / Type 42 composite glyphs involving rotation were placed +incorrectly. (gstype42.c) + - Type 42 fonts with an absent or incorrect FontBBox could fail to +produce output. (gstype42.c) + - Some header files weren't protected against double inclusion. +(gsio.h, gdebug.h) + - Decoding filters didn't "look ahead" to detect EOD, so if the last +read operation before closing the filter ended just before the EOD mark, the +EOD mark might not be absorbed. (stream.h, stream.c) + - Filling paths consisting of multiple subpaths that overlap in Y +produced slightly inaccurate output. We were unable to find a way to fix +this without making a NON-BACKWARD-COMPATIBLE change in the interface for +the recently introduced fill_trapezoid device procedure. (gxdevice.h, +gdevbbox.c, gdevddrw.c, gdevnfwd.c, gxfill.c) + - When banding, get_bits didn't detect calls with out-of-range Y +values. (gxclread.c) + - setcacheparams didn't actually affect the size of the character +cache. (gsfont.h, gxbcache.h, gxfcache.h, gschar.c, gsfont.c, gxbcache.c, +gxccman.c, gxclbits.c) + - When banding, colored halftones could be mangled. (gxclread.c) + +Fixes bugs in the bounding box device: + - The bounding box device could give bizarre results if any objects +crossed the lower edge of the page. (gdevbbox.c) + - The bounding box device could get a memory access error when +processing image data. (gdebbox.c) + - The bounding box device ran the default drawing algorithms even if +it had no target (performance bug only). (gdevbbox.c) + - The bounding box device computed an incorrect (too small) box for +partially clipped bitmap images. (gdevbbox.c) + - The bounding box device got confused by files that filled the +entire page with a background color. (gdevbbox.c) + - The bounding box device produced infinite-height boxes for certain +kinds of data. (gdevbbox.c) + +Changes some type declarations slightly to reduce the number of 'discarding +const' compiler warnings. (gsmemory.h, gsstruct.h) + +Adds the capability of clipping to the outside rather than the inside of the +clipping path. This is required for emulating an obscure feature of the +Microsoft Windows GDI. (gspath.h, gxclpath.h, gxpath.h, gxcpath.h, +gzcpath.h, gspath.c, gxacpath.c, gxclpath.c, gxclread.c, gxcpath.c.) + +Makes it possible for band devices to select the underlying memory device +used to accumulate the actual bits. This is required for (at least) PCL5 +emulation. This requires adding a procedure to the gx_device_printer +structure, which, for devices that initialize the structure without using +the macros in gdevprn.h or access the printer-specific procedures directly, +is a NON-BACKWARD-COMPATIBLE change. (gdevprn.h, gxclist.h, gxdevice.h, +gdevdflt.c, gdevprn.c, gxclread.c) + +Speeds up handling of rotated or halftoned masked images. (gximage2.c) + +Adds an output_page procedure to the bounding box device, for testing. +(gdevbbox.c) + +Adds a sample device that keeps track of the "render algorithm", for PCL5c +emulation. (gdevrrgb.c) + +Version 3.68 patch 4 (5/23/96) +==================== + +More minor bug fixes, mostly related to the MS Windows implementation. + +Documentation +------------- + +Further updates various doc files to make them more useful to new users. +(NEWS, README, current.doc, helpers.doc, new-user.doc) + +Adds user-contributed documentation for ps2pdf. (ps2pdf.doc, unix-end.mak) + +Documents a bug in the Borland C++ 4.52 compiler, and where to find the +patch for it. (make.doc) + +Procedures +---------- + +Fixes bugs: + - A command line exceeded the MS-DOS 120 character limit. +(devs.mak) + +A file was accidentally omitted from the fileset. (wmakebat.bat) + +Drivers +------- + +Fixes bugs: + - Many of the 'show' operators didn't work properly if the PDF +writer was included in the configuration. (gs_pdfwr.ps) + - x_wrap_get_bits was ridiculously slow. (It still is, but not +quite as ridiculously.) (gxcindex.h, gdevxalt.c) + - The PDF writer generated CR instead of CalRGB, which is legal per +the Adobe spec but not compatible with some Adobe Acrobat products. +(gdevpdfi.c) + - Some signed/unsigned discrepancies caused compilation warnings. +(gdevpdfm.c, gdevpdfp.c, gdevpdft.c) + +Fixes bugs in the Windows driver: + - An accidentally opened tiny window didn't get closed. +(gdevwdib.c) + - The name DllInit was misleading, and this procedure wasn't being +called whtn the DLL was loaded, so the DLL couldn't know the instance +handle. (gp_mswin.c) + - The code didn't recognize Win32s (vs. Windows 95) correctly. +(dwmain.cpp, gdevwdib.c, gp_mswin.h, gp_mswin.c, gsdll16.rc) + - Some compiler warnings needed fixing. (gdevwdib.c) + - gsdll16.def and gsdll32.def were different. (gsdll32.def) + - A GPF leaving the 16-bit DLL loaded could make the DLL permanently +unusable. (dwmain.cpp) + - Two obsolete files were still included in the fileset. +(gswin.def, gswin32.def) + +Adds a compile-time option to the 'bit' drivers to expand 4-bit pixels to +32-bit. This was required for tracking down customer problems, because the +only tools we have available for displaying CMYK images require 32 bits per +pixel. (gdevbit.c) + +Platforms +--------- + +Fixes bugs: + - In DEC C, does define the timeval struct. (time_.h) + +Changes gsdll_init() to take an additional argument, a window handle. This +is a NON-BACKWARD-COMPATIBLE change. (dll.doc, dwdll.h, gsdll.h, dwdll.cpp, +dwmain.cpp, dwmainc.cpp, gsdll.c) + +Fonts +----- + +Updates more Fontmaps to include the new URW++ fonts. (Fontmap.OS2, +Fontmap.ATM) + +Interpreter +----------- + +Fixes bugs: + - The default operator array table wasn't big enough. (iinit.c) + - Some signed/unsigned discrepancies caused compilation warnings. +(imain.c, imainarg.c, zfile.c) + +Adds encoding vectors for Windows 3.1 Latin 1, Latin 2, and Latin 5 +encodings. None of these are loaded in the standard configuration. +(gs_wl{1,2,5}_e.ps) + +Library +------- + +Fixes bugs: + - Some tracing output was incorrect or missing. (gxdither.c) + - Resized objects in the C heap had incorrect bookkeeping +information (bug introduced in 3.68). (gsmemory.c) + - Image pixels that fell exactly on device half-pixel boundaries +could get discarded. (gximage0.c) + - The bounding box device didn't set a variable properly and didn't +implement end_image, leading to invalid memory accesses. (gdevbbox.c) + - Fonts with BuildChar routines written in C didn't work properly +with kshow or xyshow. (gschar.c) + +Adds some additional tracing output for Patterns. (gxpcmap.c) + +Adds tracing output for freeing malloc'ed blocks at the end of execution. +(gsmemory.c) + +Adds a gs_dashpath procedure that expands dashes in the same way that +gs_flattenpath expands curves. (gspath.h, gspath1.c) + +Version 3.68 patch 3 (5/17/96) +==================== + +More bug fixes during the beta test period. AccurateScreens now works +properly. + +Procedures +---------- + +Fixes bugs: + - The help message was too long to fit on a PC screen or standard +terminal. (imainarg.c) + - Failure to run tar_cat wasn't detected. (unix-end.mak, +unixtail.mak) + +Utilities +--------- + +Fixes bugs: + - In the PostScript files produced by pdf2ps, images using ASCII85 +encoding would cause a typecheck error. (gs_pdf.ps) + - pdf2ps wrote out strings longer than 200 characters incorrectly. +(pdf_2ps.ps) + +Drivers +------- + +Fixes bugs in gdevcdj.c (according to the author, we have no way to test +this): + - The driver used to use Colors as well as ProcessColorModel to +define the process color model. (devices.doc, gdevbjc.h, gdevcdj.c) + - Incorrect or inconsistent settings of BitsPerPixel and +ProcessColorModel, or setting one but not the other, could leave the driver +in an inconsistent state. (gdevcdj.c) + +Fixes bugs in the MS Windows driver: + - Insufficient memory for the backing bitmap could cause a GPF. +(gdevmswn.c, gdevwdib.c) + - Invalid parameters could cause a crash within the DLL code. +(gdevwdib.c) + +Adds a user-contributed driver for the CalComp Raster Format. (devs.mak, +gdevccr.c) + +Adds an anti-aliasing option for MS Windows. (gdevmswn.c, gdevwdib.c) + +Platforms +--------- + +Fixes bugs in the Windows platform: + - One had to type "quit" twice to exit. (dwdll.h, dwdll.cpp) + +Interpreter +----------- + +Fixes bugs: + - Platform fonts didn't work properly if the document's primary +encoding was the standard MS Windows encoding. (ifont.h, gs_wan_e.ps) + - stringwidth with a Type 1 font could give a spurious typecheck +error (bug introduced in 3.65). (zcharout.c) + - If a DOS editor added a ^Z to the end of the Fontmap file, an +error occurred during initialization. (gs_fonts.ps) + - Halftones that didn't specify a value for AccurateScreens +sometimes ignored the setting of the AccurateScreens user parameter. +(zht2.c) + +Library +------- + +Fixes bugs: + - gs_join_none was defined, but not implemented. (gxstroke.c) + - A bookkeeping list for fonts could get confused, causing invalid +memory accesses. (gsfont.c) + - An I/O error or internal error would cause the band list +rasterizer to go into an infinite loop. (gxclread.c) + - The algorithm for choosing screen angles and frequencies produced +poor results. (gshtscr.c) + - Color screens were broken (bug introduced in 3.68). (gxdht.h, +gzht.h, gsht.c, gshtscr.c) + +Version 3.68 patch 2 (5/13/96) +==================== + +This is another set of patches for the next general release. + +Documentation +------------- + +Fixes bugs: + - Windows NT and Windows 95 implementations were identified as +"under development" rather than available. (README) + - There were several other minor errors in the README file. +(README) + - The claimed current IJG JPEG version was incorrect. (jpeg.mak) + +Splits off information for new users into a separate file. (README, +new-user.doc) + +Procedures +---------- + +Fixes bugs: + - gettimeofday takes 2 arguments on SVR4 systems more recent than +SVR4.0. (make.doc, ansihead.mak, cc-head.mak, gcc-head.mak, time_.h) + +Changes the default Unix data installation directory from /usr/local/lib to +/usr/local/share, which seems to be favored by more recent Unix systems +(except for some Linux versions, which still use /usr/local/lib, and BSD/OS, +which puts Ghostscript in /usr/contrib/lib.) (ansihead.mak, cc-head.mak, +gcc-head.mak, ugcclib.mak) + +Changes the unset commands in the Unix script to assignments, because a few +older Unix shells don't provide unset. (unixtail.mak) + +Drivers +------- + +Fixes bugs: + - An #include incorrectly referred directly to a system header. +(gdevpdft.c) + - CMYK devices took an excessive amount of time clearing the page to +white. (gdevm32.c) + +Adds a compile-time option to the 'bit' drivers to remove top and bottom +whitespace. This change was required in order to track down a customer bug. +(gdevbit.c) + +Interpreter +----------- + +Updates the interpreter for the split in the gstate API. (igstate.h) + +Streams +------- + +Fixes bugs: + - Some compilers don't define NULL widely enough. (spngp.c) + +Library +------- + +Fixes bugs: + - There was a minor typo (& for &&) that didn't affect execution. +(gxccman.c) + - There was a trailing comma in an enumeration. (gsiparam.h) + - Internal and public interfaces weren't separated properly. THIS +IS A NON-BACKWARD-COMPATIBLE CHANGE for clients using certain undocumented +interfaces to the graphics state. (gsstate.h, gxstate.h, gzstate.h, +gsstate.c) + - A 'private' declaration was missing (yet again). (gxclimag.c) + +Version 3.68 patch 1 (5/10/96) +==================== + +This is the first bug fix (patch) incremental release for the next general +release. + +Procedures +---------- + +Fixes bugs: + - Many Windows-specific files were omitted from the previous +fileset: dw*.rc, dw*.cpp. + +Version 3.68(limited) (5/9/96) +===================== + +This release cleans up the new Windows files, mostly implements the +high-level driver API for bitmap images, and adds practical strip +(AccurateScreens) halftoning. This is the first "serious beta" fileset for +the next general release. It still has more problems than I would have +liked. + +Documentation +------------- + +Fixes bugs: + - The names of the executable files for MS Windows were out of date. +(make.doc) + - gxcindex.h still referred to "drawing color". (gxcindex.h) + - The name of the default font directory for Unix systems was +incorrect. (make.doc) + +Moves the list of files required for installation, and some other +installation instructions, from make.doc to install.doc. (install.doc, +make.doc) + +Adds a description of the PNGPredictor filters. (language.doc) + +Updates the documentation of the higher-level driver procedures to match the +specification changes. (drivers.doc) + +Documents the change in the Watcom build procedure. (make.doc) + +Improves the documentation of bitmap IDs. (gxbitmap.h) + +Adds documentation for the new strip_tile_rectangle and strip_copy_rop +driver procedures. (drivers.doc) + +Changes the few remaining direct FTP addresses in README to URLs. (README) + +Notes that zlib does not compile correctly on IRIX 6.n with optimization. +(make.doc) + +Adds references to PDF and TrueType fonts to language.doc. (language.doc) + +Updates fonts.doc to remove references to fonts.mak. (fonts.doc) + +Describes how to substitute an LZW compressor for the LZW-compatible +compressor provided in the standard release. (make.doc) + +Procedures +---------- + +Fixes bugs: + - Some lines had exceeded the 120-character limit of the +MS-DOS shell. (int.mak) + - The configuration files weren't generated correctly when CONFIG +wasn't an empty string. (unixhead.mak) + +Factors out shared DLL makefile rules into a new file. (bcwin.mak, +bcwin32.mak, dwcommon.mak) + +Makes the cp and rm commands into makefile parameters, allowing automatic +generation of build scripts even in the MS-DOS and MS Windows environments +where the shell requires the CALL command for sub-scripts. (*.mak, +genconf.c) + +Adds the PDF writer to the default Unix configurations. (ansihead.mak, +cc-head.mak, gcc-head.mak) + +Adds TrueType support to all Level 2 configurations. (int.mak) + +Removes fonts.mak, which is no longer relevant. (fonts.mak) + +Brings the font compilation procedures up to date. (cfonts.mak, int.mak) + +Utilities +--------- + +Fixes bugs: + - There was an extra 'show' in one file. (align.ps) + +Drivers +------- + +Fixes bugs: + - The bit devices were missing the map_color_rgb procedure. +(gdevbit.c) + - The MS Windows driver sent a redundant message. (gdevmswn.c) + +Adds a device that keeps track of the page bounding box. This device is not +included in any standard configuration. (drivers.doc, gdevbbox.h, +gsmatrix.h, gsstruct.h, gxdevice.h, gdevbbox.c, gdevnfwd.c, gsmatrix.c) + +Updates the PDF writer to track the changes in the high-level driver API, +and to write out images in a reasonable way. NOTE: the current +implementation doesn't write out CIE color space parameters, so CIE-color +images won't be colored accurately. (gdevpdf.c, gdevpdfi.c) + +Adds a forwarding procedure for tile_rectangle. (gxdevice.h, gdevnfwd.c) + +Changes the copyright notices on the PDF writer to be the same as on the +rest of Ghostscript. (gdevpdf*.[ch]) + +Updates Gunther Hess's Epson Stylus Color driver from 1.21 to 1.90. (Aladdin +Enterprises takes no responsibility for this driver: if you have questions, +contact the author.) (devices.doc, devs.mak, gdevstc*.c, gdevstc.h) + +Platforms +--------- + +Removes some obsolete MS Windows files and #defines. (gp_mswtx.h, +gp_mswtx.c, gp_mswin.h) + +Works around a memory limitation in the Watcom make utility. (wmakebat.bat) + +Fonts +----- + +Changes the standard Fontmap from using the low-quality fonts converted from +bitmaps to using high-quality fonts recently contributed by URW++. +(Fontmap, Fontmap.GS) + +Interpreter +----------- + +Fixes bugs: + - A macro containing an if-else, and a macro generating a compound +statement, could cause incorrect grouping of 'if' statements. (files.h, +ostack.h) + - .setrasterop didn't pop its operand. (zrop.c) + - A rounding inaccuracy could cause bounding box rangecheck errors. +(gsdps1.c) + - CIE-based images in PDF files didn't work. (gs_pdf.ps) + - The page parameter .MediaSize didn't get updated when PageSize was +set. (This is just the most recent manifestation of the setpagedevice +morass.) (gs_setpd.ps) + - %lineedit and %statementedit were limited to 160 characters. +(zfileio.c, ziodev.c) + - Compiled initialization files didn't work properly. (geninit.c, +gs_l2img.ps) + - Attempting to parse a command line with argc = 0 caused a crash. +(imainarg.c) + +Renames some files to allow separating the non-DLL 'main' procedure into a +separate file, and to make the file naming more consistent: + gs.c (except for 'main') => imainarg.c + gsmain.c => imain.c +gs.c now consists only of 'main'. The name gs.c is still inconsistent (it +should be i- something), but at least it's consistent with the name of the +executable. (*.mak, imain.h, iminst.h, imainarg.h, gs.c, gsmain.c, imain.c, +imainarg.c) + +Adds PNGPredictorEncode/Decode filters, and increases the size of filterdict +slightly to make room for them. (iinit.c, zfpngp.c) + +Makes zwrite external, per a customer request. (opextern.h, zfileio.c) + +Updates clients to work with the new API-based bitmap imaging calls. +(iimage.h, zcolor1.c, zimage2.c, zpaint.c) + +Updates clients for the split in gscspace.h. (zcie.c, zcolor1.c, zcolor2.c, +zcsindex.c, zcssepr.c, zimage2.c, zpaint.c, zpcolor.c) + +Updates clients for strip-based halftones. (zpcolor.c) + +Updates the initialization code to pass the correct (system) allocator to +the library initialization. (imain.c) + +Streams +------- + +Fixes bugs: + - If a filter reached EOD exactly at the end of reading data for +certain operations, it didn't get closed automatically. (stream.c) + - The LZW-compatible encoding filter reset procedure had an +incorrect return type. (slzwce.c) + +Changes the ASCIIHexEncode filter to insert \ns in fewer places, to be +somewhat more compatible with the Adobe implementation. (sstring.c) + +Adds PNGPredictorEncode/Decode filters that implement the pixel prediction +algorithms in the PNG specification. (We'd like to use the code in the PNG +library, but it's too deeply embedded in the rest of the PNG machinery, and +it also doesn't provide for suspendable I/O.) (spngpx.h, spngp.c) + +Library +------- + +Fixes bugs: + - A test for pure color was backwards, causing garbage output or +possible address or floating point exceptions. (gxclpath.c) + - A macro containing an if-else could cause incorrect grouping of +'if' statements. (gsrefct.h) + - The default implementation of RasterOp didn't handle the device +depth correctly. (gdevmrop.c) + - The memory device implementation of RasterOp truncated 24-bit +constant source or texture values to 8 bits. (gdevmrop.c) + - A typo caused the garbage collector to miss an internal buffer +used when rendering images. (gximage.h) + - gs_debug_out was only defined if DEBUG was set. (gdebug.h) + - The raster of horizontally replicated tiles was incorrect. +(gxht.c) + - A data type might not be declared, causing a compilation error. +(gscoord.h) + - Empty TrueType glyphs weren't handled properly. (gstype42.c) + - Fonts with a build procedure written in C could cause an invalid +memory access. (gschar.c) + - The initial point of a band list path sometimes didn't get +written, causing excess or missing filled regions. (gxclpath.c) + - Characters between 49 and 56 bits wide were rendered incorrectly +when banding. (gxclbits.c) + +Renames gsimage*.c as gximage*.c, to reflect more accurately the position of +these files in the architecture. (gsimage*.c, gximage*.c) + +Fully implements the high-level bitmap image calls in the driver API. This +includes some driver API changes; however, this part of the API was clearly +documented as not stable enough to rely on. (gxdevice.h, gximage.h, +gdevbbox.c, gdevddrw.c, gdevnfwd.c, gsimage.c, gximage*.c) + +Splits the color space header into client and implementation, as with many +others. (gscspace.h, gxcspace.h, gximage.h, gscie.c, gscolor.c, gscolor1.c, +gscolor2.c, gscsepr.c, gsimage.c, gspcolor.c, gsstate.c, gxcmap.c, +gxpcmap.c) + +Extends band lists to handle high-level images. NOTE: This facility is +patched out because there is not yet a way to pass the necessary color +rendering information through the band list. (gxcldev.h, gxclist.h, +gxclpath.h, gxclimag.c, gxclist.c, gxclpath.c, gxclread.c) + +Implements fixed2float and float2fixed more efficiently on machines with +slow floating point. (gxfixed.h, gscoord.c, gsmisc.c) + +Makes one further NON-BACKWARD-COMPATIBLE change in the existing +higher-level driver procedures (fill_path, stroke_path, fill_mask): we make +the imager state pointer an explicit argument, rather than a member of the +gx_fill/stroke_params structure. We now consider the specification of these +procedures stable, and have removed the "subject to change" notice from the +documentation. (gxdevice.h, gxpaint.h, gdevbbox.c, gdevnfwd.c, gxacpath.c, +gxclpath.c, gxclread.c, gxfill.c, gxpaint.c, gxstroke.c) + +Extends halftone bitmaps to include "strip" and "shift" information, +allowing halftone cells with arbitrary angles to be stored in space +proportional to the number of bits in the cell rather than the square of the +number of bits. This requires adding new (optional) strip_tile_rectangle +and strip_copy_rop driver procedures that are like tile_rectangle and +copy_rop respectively but accept a strip bitmap rather than an ordinary +tile; these procedures supersede tile_rectangle and copy_rop (although these +also remain, defined in terms of the new ones). This also requires making +small but NON-BACKWARD-COMPATIBLE changes in several internal interfaces. +(gdevmem.h, gdevprn.h, gsdcolor.h, gxbcache.h, gxbitmap.h, gxcldev.h, +gxclip2.h, gxclist.h, gxdevice.h, gxdevrop.h, gxdht.h, gxfcache.h, +gxhttile.h, gxpcolor.h, gzht.h; gdevabuf.c, gdevbbox.c, gdevdflt.c, +gdevm*.c, gdevmpla.c, gdevmrop.c, gdevnfwd.c, gsht.c, gsht1.c, gshtscr.c, +gspcolor.c, gsstate.c, gxcht.c, gxclbits.c, gxclip2.c, gxclist.c, +gxclpath.c, gxclread.c, gxcpath.c, gxdcolor.c, gxdither.c, gxht.c, +gximage2.c, gxpcmap.c, ...) + +Adds "no join" as a line join type. NOTE: this is not actually implemented +yet. (gslparam.h) + +Changes the initialization code so that it passes the system allocator as an +argument to module initialization procedures. While this is theoretically a +NON-BACKWARD-COMPATIBLE change, module initialization procedures are not +documented and presumably are not used by any code outside the +implementation. (gscdefs.h, gconf.c, gdevmrop.c, gsinit.c, gxclimag.c, +gxclpath.c) + +Splits up gs_lib_init into two procedures, allowing specification of a +different default allocator for the library. (gslib.h, gsinit.c) + +Adds a resize_object operation to the allocator API. (gsmemory.h, +gsalloc.c, gsmemory.c) + +Version 3.67(limited) (4/12/96) +===================== + +This release restructures the MS Windows and OS/2 code to be primarily DLL- +rather than EXE-based. See under Platforms below for more news. This +release was put out in a hurry in order to get the new DLL code into +testers' hands; it has more rough edges than usual. + +Documentation +------------- + +Fixes bugs: + - A definition & use comment was incorrect. (scanchar.h) + - William Bader's e-mail address was wrong. (README) + +Adds documentation for the new begin_image, image_data, and end_image +procedures. THIS INTERFACE IS STILL SUBJECT TO CHANGE. (drivers.doc) + +Procedures +---------- + +Renames all the *core.dev modules as *lib.dev. (int.mak, *lib.mak, vms.mak, +gdevmrop.c) + +Updates all the remaining makefiles to IJG JPEG version 6a. (*.mak) + +Moves the configuration parameter definitions from gconf.c to a new file +gscdefs.c. (bcwin*.mak, *lib.mak, gs.mak, int.mak, lib.mak, unixtail.mak, +vms.mak, gconf.c, gscdefs.c) + +Platforms +--------- + +Restructures the MS Windows and OS/2 code to be primarily DLL- rather than +EXE-based. This involves two minor NON-BACKWARD-COMPATIBLE changes to the DLL +interface, documented near the end of dll.doc: + + - Adding argv and argc as arguments to gsdll_init. + + - Adding a new message type, GSDLL_POLL, to the callback procedure. + +(bcwin*.mak, devs.mak, os2.mak, dll.doc, install.doc, dw*.*, gsdll*.*, +gdevms*.*, gdevpm.c, gdevw*.c, gp_mswin.c, gp_os2.c, gsos2.def, gswin.rc) + +Adds the BMP drivers to the Watcom platform. (watc.mak) + +Interpreter +----------- + +Fixes bugs: + - gs.c assumed the presence of stdio. (gs.c) + +Defines a new API entry point that is the equivalent of command line +invocation. (imain.h, imainarg.h, gs.c) + +Changes clients to conform to the changes in gsimage.h. (zimage2.c, +zpaint.c) + +Speeds up the search operator slightly. (zstring.c) + +Interpreter (PDF) +----------------- + +Fixes bugs: + - If the PDF interpreter was present, running a PostScript file +didn't close the file properly if it caused an error. (pdf_main.ps) + +Speeds up embedded font loading by making an internal buffer bigger. +(pdf_font.ps) + +Library +------- + +Fixes bugs: + - There could be some non-zero garbage between the width and the +next multiple of bitmap_align_mod for copy_alpha. (The driver API +specification explicitly allows this, but it upset one customer.) +(gxccman.c) + - Nibble-swapped alpha values could be displaced in memory by one +pixel, damaging the output. (gdevabuf.c) + +Makes further changes towards adding high-level bitmap image calls to the +driver API. This includes the following minor NON-BACKWARD-COMPATIBLE +changes to the interface defined in gsimage.h: + + - changing MultipleDataSources from a member of the gs_image_t + structure to an argument of gs_image_init; + + - changing the default image parameter values from constant + structures to procedures that initialize the structure. + +As far as we know, this doesn't affect any existing client code. +(gsimage.h, gsiparam.h, gxdevice.h, gdevddrw.c, gdevnfwd.c, gsimage.c, +gspcolor.c, gxccache.c) + +Removes an unnecessary level of call for path filling. (gxpaint.h, +gxfill.c, gxpaint.c) + +Version 3.66(limited) (4/8/96) +===================== + +This release adds support for TrueType fonts and Type 42 (encapsulated +TrueType) PostScript fonts. The MS Windows driver now interacts properly +with the garbage collector. This release also includes a new, high-quality +set of free fonts. + +Documentation +------------- + +Fixes bugs: + - The list of generic makefiles had gotten out of date. (make.doc) + +Adds a mention of the bmv program, created by a user and available under the +GPL. (README) + +Notes that a bug in gcc 2.7.x prevents these versions from compiling +Ghostscript. (make.doc) + +Clarifies the meaning of "inverted" masks. (gsimage.h) + +Improves the documentation of the stack sizing parameters. (interp.c) + +Improves the documentation of the copy_rop driver procedure. +(drivers.doc) + +Notes that all subclasses of gx_device must explicitly include the +device_finalize finalization procedure. (gxdevice.h) + +Updates the documentation of the high-level driver API to reflect the change +in gx_drawing_color, and the addition of the new polygon and image drawing +procedures. (drivers.doc) + +Updates the documentation for building zlib and libpng. (make.doc) + +Procedures +---------- + +Fixes bugs: + - The environment space overflowed on some inferior Unix systems. +(unixtail.mak) + +Adds a ttfont.dev "feature" for including the TrueType interpreter and the +ability to handle Type 42 fonts. A new procedure, .loadttfont, allows +loading a TrueType font directly (by converting it to a Type 42 on the fly). +(gs.mak, int.mak, lib.mak) + +Updates the makefiles and procedures to libpng 0.88 and zlib 1.0. +(libpng.mak, zlib.mak) + +Utilities +--------- + +Fixes bugs: + - pdf2ps could produce lines longer than 255 characters. +(pdf_2ps.ps) + +Removes some unnecessary and error-inviting code from pdf2dsc. (pdf2dsc.ps) + +Updates lines.ps to test the new stroke code more fully. (lines.ps) + +Allows omitting the second argument of ps2pdf, as for ps2epsi. (ps2pdf) + +Drivers +------- + +Fixes bugs: + - A routine was incorrectly declared "private". (I wish gcc caught +this!) (gdevpdf.c) + - A 'const' was omitted in a parameter list. (gdevpdfp.c) + - Some imported procedures didn't have prototypes declared. +(gdevpdft.c) + - The ProcSet list for PDF files didn't include Text when it was +needed. (gdevpdfx.h, gdevpdf.c, gdevpdft.c) + - Text in PDF output ignored the color setting. (gs_pdfwr.ps, +gdevpdft.c) + - Text in PDF output could be positioned incorrectly. (gdevpdft.c) + - pdfmarks could produce an error when producing PDF output. +(gs_pdfwr.ps) + +Slightly improves the text output of the PDF writer. (gs_pdfwr.ps, +gdevpdft.c) + +Defines driver procedures for filling trapezoids (with the parallel edges +parallel to a coordinate axis), parallelograms (with arbitrary orientation), +triangles (ditto), and minimum-width lines (ditto). (Note that the last of +these obsoletes the former draw_line procedure.) (gdevmem.h, gdevprn.h, +gxdevice.h, gxdraw.h (deleted), gdevddrw.c, gdevdflt.c, gdevht.c, +gdevnfwd.c, gsimage[12345].c, gxacpath.c, gxclist.c, gxclip2.c, gxcpath.c, +gxdraw.c (deleted), gxfill.c, gxpcmap.c, gxstroke.c) + +Adds "sketched" driver procedures for high-level bitmap / pixmap image +drawing. In this release, the argument lists are incomplete, and the +procedures are stubs: don't try to use them! [see previous entry] + +Changes the screen update strategy for the X Windows driver from a +compile-time option to a settable run-time variable. (gdevx.c) + +Patches around a problem with libpng 0.88 that can't be fixed without +editing a configuration file. (gdevpng.c) + +Platforms +--------- + +Fixes bugs: + - %g formats with sscanf don't work on NeXT systems. (gdevpdft.c, +iutil.c, zdouble.c) + - getenv could be declared inconsistently. (gp_unix.c) + +Fonts +----- + +Fixes bugs: + - The Type 1 font interpreter sometimes set the flatness too large. +(gstype1.c) + - Fonts defined by definefont could never be garbage collected. +(gsstruct.h, gxfcache.h, gxfont.h, gxfont0.h, gxfont1.h, gsfont.c, +gsfont0.c) + - Type 0 fonts weren't garbage collected properly. (gsfont0.c) + - Compiled fonts caused a compilation error (bug introduced in +3.65). (ifont.h) + - If a Type 1 font used hint replacement, hints could be applied +more than once, distorting the character shape. (gxtype1.h, gxhint3.c) + - Oversampling wasn't applied to large enough characters. +(gschar.c) + +Interpreter +----------- + +Fixes bugs: + - The scanner accepted /[, /], /<<, and />> as literal names (and +similarly for //). It isn't obvious from the Red Book, but the Adobe +implementations don't accept these. What a nuisance! (gs_btokn.ps, +gs_init.ps, pdf_2ps.ps, pdf_base.ps, pdf_main.ps, iscan.c) + - A spurious stackoverflow could occur under unusual conditions. +(istack.c) + - The values of OrigFont and ScaleMatrix in scaled fonts reflected +only the most recent scaling operation, not the original font and the +combined scaling operation. (zfont.c) + - The default size of systemdict had become slightly too small. +(iinit.c) + - Type 1 characters defined by PostScript procedures were called +incorrectly. (zcharout.c) + +Removes the papersize operator from statusdict, since it is not documented +anywhere in the Adobe literature and didn't interact properly with the +various ways of setting the page size. (gs_statd.ps) + +Changes the one client of sskip to match the changed API. (zpaint.c) + +Changes clients to reflect the creation of sstring.h. (iscan.h, zfilter.c) + +Adds PSStringEncode as an accessible filter. (zfilter.c) + +Adds support for TrueType and Type 42 fonts. (gs_fonts.ps, gs_ttf.ps, +gs_typ42.ps, bfont.h, icharout.h, ifont.h, zchar1.c, zchar42.c, zcharout.c, +zfont1.c, zfont2.c, zfont42.c) + +Adds a few ANSI sheet sizes (commented out, for documentation only). +(gs_statd.ps) + +Interpreter (PDF) +----------------- + +Fixes bugs: + - Clients who called pdfopen/close rather than runpdf could get an +error (PSLevel1 undefined). (pdf_main.ps) + - Some masked images were displayed with black and white inverted. +(gs_pdf.ps) + - In Level 1 output produced by pdf2ps, images caused a syntaxerror. +(gs_pdf.ps) + - If a PDF file had multiple xref sections and later sections added +new objects, an error occurred. (pdf_main.ps) + - Some very old Level 1 interpreters couldn't deal with a file +object embedded in a procedure. (gs_pdf.ps) + +Streams +------- + +Fixes bugs: + - The PSStringEncode filter didn't always produce printable 7-bit +output. (sstring.c) + - The CCITTFaxDecode filter didn't implement DamagedRowsBeforeError. +(scfx.h, scfd.c) + - Interpolated images displayed nothing if the data stream ended +before the image height was reached. (siscale.h, gsimage5.c, siscale.c) + +Changes the sskip stream procedure so that it takes an additional argument +where it returns the actual number of bytes skipped. THIS IS A +NON-BACKWARD-COMPATIBLE CHANGE in the API. However, as far as we know, +there are no external clients of this procedure. (stream.h, stream.c) + +Splits up sfilter.h so that the headers correspond more directly with the +implementations. (sfilter.h, sstring.h, sstring.c) + +Library +------- + +Fixes bugs: + - The default device in the library configuration was device 1, not +device 0. (bclib.mak, ugcclib.mak, watclib.mak, gslib.c) + - Patterns could be rendered with small gaps between them. +(gspcolor.c) + - Large characters could render inaccurately because of a numerical +boundary condition. (gxpcopy.c) + - The show_gstate pointer in the graphics state was not managed +properly, possibly leading to dangling pointers or GC errors. (gsstate.c) + - Bitmaps could get shifted to the left if ALPHA_LSB_FIRST was +selected (bug introduced in 3.53). (gsbitops.c) + - The garbage collector could move devices in memory, causing +problems with command list devices. (gxdevice.h, gsdevice.c) + +Continues restructuring the image handling code in preparation for adding a +high-level driver operation. (gsimage[12345].c) + +Starts to implement passing color mapping information (transfer function, +black generation, undercolor removal, CRD, halftoning) in the band list. +(gxfmap.h, gscolor.c, gscolor1.c, gsht1.c, gsstate.c) + +Speeds up the path filling code a little more. (gxdraw.c) + +Removes the workaround for the gcc 2.7.0/1/2 optimizer bug, since this +turned out to cause more trouble than it was worth. (stdpre.h) + +Speeds up stroking dramatically for the case of butt or square caps, bevel +or beveled miter joins, and no fill adjustment, by filling parallelograms +and triangles directly rather than constructing and filling paths. This is +an important common case for CAD drawings. (gxdraw.h, gxdraw.c, gxstroke.c) + +Adds support for TrueType and Type 42 fonts. (gxfont.h, gxfont42.h, +gstype42.c) + +Extends the memory manager to allow allocating objects that the garbage +collector won't move. THIS IS A NON-BACKWARD-COMPATIBLE CHANGE for +implementors of memory managers, but clients aren't supposed to have any of +these. (gsmemory.h, gsmemory.c, gsalloc.c) + +Makes dynamically created instances of registered devices immovable. +(gsdevice.c) + +Unifies gx_drawing_color with (makes it equivalent to) gx_device_color. +THIS IS A NON-BACKWARD-COMPATIBLE CHANGE for implementors of the +higher-level driver procedures (fill_path, stroke_path, fill_mask). We +regret that this was necessary, but the documentation in drivers.doc does +warn the reader: "DO NOT ASSUME THESE OPERATIONS WILL REMAIN UNCHANGED IN +FUTURE RELEASES." These three procedures, at least, should now be stable. +(gsdcolor.h, gxcindex.h, gxdcolor.h, gxdevice.h, gximage.h, gxpaint.h, +gxpcolor.h, gdevdflt.c, gdevpdf.c, gdevpdfi.c, gdevxalt.c, gsimage.c, +gsimage2.c, gspcolor.c, gxacpath.c, gxccache.c, gxcht.c, gxclpath.c, +gxclread.c, gxdcconv.c, gxdither.c, gxfill.c, gxdraw.c, gxht.c, gxpaint.c, +gxpcmap.c, gxstroke.c) + +Version 3.65(limited) (3/9/96) +===================== + +This release adds garbage collection for device instances. ****** NOTE: +Because of changes in memory management, if you are using the MS Windows +driver (mswin), you must run with -dNOGC. This is a temporary problem which +will be fixed before the next beta release. + +Documentation +------------- + +Documents the C API equivalent of a -d switch for setting a flag like +NOPAUSE. (imain.h) + +Splits off the NEWS entries for versions 3.0 through 3.33 into a new +file. (history3.doc) + +Adds a man page for ps2pdf. (ps2pdf.1) + +Documents the new memory management aspects of device drivers, and corrects +many other aspects of driver documentation that had become inaccurate. +(drivers.doc) + +Updates the documentation for the gs_*.ps files. (psfiles.doc) + +Replaces .type1addpath with .type1execchar. (language.doc) + +Adds some more documentation on how band lists do read/write switching. +(gxclist.h) + +Adds a reference to the new Genscript program, a free Ghostscript-based +replacement for enscript. (README) + +Notes that no further changes will be accepted for the gdevcdj.c file, which +has gotten completely out of hand. (gdevcdj.c). + +Documents the TextAlphaBits and GraphicsAlphaBits device parameters. +(language.doc) + +Procedures +---------- + +Fixes bugs: + - gs_pdfwr.ps and pdf2ps.1 weren't installed on Unix systems. +(unix-end.mak) + - The pdf2ps shell script didn't accept any options. (pdf2ps) + - The rule for srle.$(OBJ) incorrectly specified a dependency on +srld.c. (lib.mak) + - The rule for command lists didn't include stream.$(OBJ). +(lib.mak) + - The stack size for one configuration was set too small. +(watclib.mak) + +Speeds up genconf by eliminating redundant file reading and processing. +(genconf.c) + +Moves the pixel-difference filters from int.mak to lib.mak. (int.mak, +lib.mak) + +Moves the library parts of the HSB color and Level 1 path (arcs, pathbbox, +path enumeration) options from int.mak to lib.mak, and adds them to the +library makefiles. (int.mak, lib.mak; bclib.mak. ugcclib.mak, watclib.mak) + +Utilities +--------- + +Fixes bugs: + - pdf2ps would fail if it encountered a font with a standard +encoding. (pdf_2ps.ps) + +Adds new switches to pdf2ps: + -dPSBinaryOK allows writing binary image data in the output. +(pdf_2ps.ps) + -dPSLevel1 forces Level 1 compatible output. (int.mak, +unix-end.mak, gs_l2img.ps, gs_pdf.ps, pdf_2ps.ps, pdf_main.ps) + -dPSNoProcSet causes the ProcSet to be loaded at run time, not at +conversion time -- primarily useful for debugging. (pdf_2ps.ps) + +Adds a utility for viewing PCX files, so we can preview high-resolution +output in a reasonable compressed format. (unix-end.mak, viewpcx.ps) + +Drivers +------- + +Fixes bugs: + - Some compilers require an extra #include to define structures even +if they are only referenced by pointers. (int.mak, gdevpdf.c, gdevpdfp.c) + - A procedure name was duplicated. (gdevpdfi.c) + - A pdfmark between a gsave and a grestore could cause a +rangecheck error. (gdevpdfp.c) + - A pdfmark between a gsave and a grestore could cause the +grestore to do an inappropriate initgraphics. (gs_pdfwr.ps) + - The pdfwrite driver could reinitialize the output file +unpredictably. (gdevpdfp.c) + - The PCX drivers didn't clear padding bytes at the ends of scan +lines. (gdevpcx.c) + - The PCX drivers didn't set the "version" field correctly (this was +OK in 2.6.1, bug introduced sometime since then). (gdevpcx.c) + - Whoever last touched the color inkjet drivers completely broke the +handling of the BitsPerPixel parameter, again. We were able to half-fix it, +but the code is impossible to understand, let alone modify safely. +(gdevcdj.c) + - Anti-aliased characters didn't work with banding. (gxclpath.c) + - The PGM/PPM drivers didn't recognize black-and-white pages for +optimization to PBM, only gray or colored. (gdevpbm.c) + - The color inkjet drivers initialized the params_size field of the +static instance incorrectly, resulting in garbage in the last few structure +members when instances were copied. (gdevcdj.c) + - The 24-bit PCX driver didn't pad each scan line to an even number +of bytes. (gdevpcx.c) + - The svga16 driver initialized its procedures incorrectly. +(gdevpcfb.c) + +Adds text writing capability to the PDF writer. In its present form, this +is a very bad hack: it only works for the 14 built-in fonts with their +standard encodings. (gdevpdfx.h, gdevpdf.c, gdevpdfp.c, gdevpdft.c) + +Adds garbage collection and finalization for device instances (gscdefs.h, +gsdevice.h, gxdevice.h, gconf.c, gdevmrop.c, gsdevice.c, gslib.c, gsmain.c). +(See the "Driver instance allocation" section of drivers.doc for more +details about what is required to make this work.) + + - When an open device is freed (explicitly, by garbage collection, +or by 'restore'), if the device was allocated dynamically by Ghostscript's +standard allocator, the device's close procedure will be called. THIS IS A +NON-BACKWARD-COMPATIBLE CHANGE for dynamically created devices, which +formerly were not closed automatically, even when Ghostscript exited. + + - Device instances allocated in GC-able space will be traced +like other objects, assuming they have proper structure descriptors. + +Provides a (very slow but correct) default implementation of copy_alpha. +(gxcindex.h, gdevdflt.c, gsimage4.c) + +Removes the implementation of copy_alpha in gdevpbm.c, since this is now +implemented (more efficiently) in gdevm24.c. (gdevpbm.c) + +Adds TextAlphaBits and GraphicsAlphaBits as readable parameters for all +devices. (gsdparam.c, gdevpbm.c, gdevsvga.c) + +Platforms +--------- + +Fixes bugs: + - There were some attempts to coerce long to short pointers +on segmented platforms. (gsdparam.c, gstype1.c) + - The stack could overflow on the 16-bit MS Windows platform. +(gxfill.c, gxclread.c) + - The DLL callback parameter for window resize events was computed +incorrectly on 16-bit systems. (gdevwdib.c) + - A file included gxdevice.h unnecessarily. (bcwin.mak, +bcwin32.mak, msvcwint.mak, gp_mswin.c) + +Interpreter +----------- + +Fixes bugs: + - Storing into a read-only dictionary with def or store was +allowed. (dstack.h) + - If the interpreter allocated extra space for a dictionary +to round its storage size up to a power of 2, it was possible for +length to exceed maxlength. (idict.c, iinit.c) + - The if and ifelse operators didn't check that their +'procedure' arguments were actually procedures. (interp.c, zcontrol.c) + - The undef operator was defined even in Level 1 +configurations. (We need this capability for all configurations, so +we always define .undef.) (zdict.c, gs_*.ps, pdf_*.ps) + - In Level 1 configurations, copying a dictionary should copy the +access attributes, but it didn't. We have to work around this +compatibility quirk in a lot of places. (gs_cidfn.ps, gs_cmap.ps, +gs_dps1.ps, gs_fonts.ps, gs_init.ps, gs_l2img.ps, gs_lev2.ps, gs_pdf.ps, +gs_pfile.ps, gs_res.ps, gs_setpd.ps, gs_type1.ps, zdict.c) + - DSC comments that crossed a buffer boundary didn't call the +scan_dsc_proc. (iscan.c) + - "statusdict /setpage get exec" caused an error. (gs_statd.ps) + - The default size of systemdict had become slightly too small. +(iinit.c) + - Doing a showpage or copypage would cause the equivalent of a +setpagedevice at the next restore or grestore. We aren't entirely sure that +the fix we made doesn't have bad side-effects. (gs_setpd.ps) + - Not all filters accepted (and ignored) an optional dictionary +parameter on the stack. (ifilter.h, zfbcp.c, zfdecode.c, zfilter.c, +zfilterx.c, zfzlib.c, zmisc1.c) + - The PixelDifference filters required a Columns parameter, rather +than defaulting it to 1. (spdiffx.h, zfdecode.c) + - Contrary to the NEWS entry for release 3.60, the LZW filters did +not implement pixel differencing. (zfdecode.c, zfilter2.c) + - readstring with a 0-length string didn't signal a rangecheck. +This doesn't make a lot of sense to me, but it's what the Adobe +documentation specifies. Unfortunately, we have to work around this in a +number of places that assumed the sensible definition (return () true +without reading anything). (gs_l2img.ps, pdf_font.ps, zfileio.c) + - Encoded number strings didn't work (bug introduced in 3.64). +(ibnum.c) + - The allocator could produce spurious "free large 0x...... chunk +not found" messages. (These didn't cause any harm, but they were +disturbing.) (gsalloc.c) + +Changes the default transfer function for high-resolution devices so +that it is the identity function if the device is continuous-tone. +(gs_init.ps) + +Undoes the "subversion" of zgetdevice noted in release 3.61, since it +is now possible to copy devices safely. (zdevice.c) + +Changes the implementation of the garbage collector and restore so that +object finalization code may safely free objects. (igc.c, isave.c) + +Reimplements essentially all of Type 1 BuildChar in C. (gs_init.ps, +gs_type0.ps (deleted), gs_type1.ps, ifont.h, zchar.c, zchar1.c, zfont.c) + +Reimplements DISKFONTS as a separate feature (diskfont.dev), and changes it +to use Type 4 fonts rather than special machinery. Currently this feature +is included only in the makefiles for 16-bit architectures. (bc.mak, +bcwin.mak, int.mak, tc.mak, gs_diskf.ps, gs_fonts.ps, gs_type1.ps) + +Converts the library search path from a list of strings to a (PostScript) +array of strings, one string per directory. (iminst.h, main.h, gs.c, +gsmain.c, zfile.c) + +Adds a hook procedure scan_comment_proc for processing all comments, +similar to scan_dsc_proc. If both are set, scan_comment_proc is used only +for non-DSC comments. (iscan.h, iscan.c) + +Interpreter (PDF) +----------------- + +Fixes bugs: + - Encrypted PDF files produced a random error (usually ioerror in +--token--) rather than a meaningful message. (pdf_main.ps) + - Color space setting didn't work. (gs_pdf.ps) + - The algorithm for skipping a possible blank line following the +'stream' keyword wasn't robust enough. (We aren't sure the new algorithm is +exactly right, either.) (pdf_base.ps) + +Gets rid of the special handling of the LZW decoding filter, since the +filter itself now handles the Predictor facility. (pdf_base.ps) + +Streams +------- + +Fixes bugs: + - Configurations with LZW encoding but not decoding had an +undefined reference. (lib.mak, slzwc.c, slzwd.c) + - The LZW-compatible encoder didn't provide a 'reset' procedure. +(slzwce.c) + - The PixelDifference filters didn't work for most parameter +combinations in which each pixel took up more than 1 byte. (spdiff.c) + - Temporary write streams could cause an infinite loop. (We only +need such streams for the Predictor = 2 case of LZWEncode: this is why the +bug never showed up before.) (stream.c) + +Adds an optional reinitialization procedure to the stream template. Note +that this is not the same as the PostScript 'reset' operation or the stream +resetting operation invoked by sreset: the reinit procedure in the template +reinitializes any internal state of the encoder or decoder without affecting +buffered data. (scommon.h, strimpl.h, sbcp.c, sbhc.c, slzwce.c, slzwd.c, +slzwe.c, smtf.c, spdiff.c, srle.c) ****** NOT DONE YET: sbwbs.c, szlibd.c, +szlibe.c + +Adds a decoding stream for the run-length compression used in PCX. +(spcxx.h, spcxd.c) + +Library +------- + +Fixes bugs: + - A recent edit introduced an extraneous right parenthesis. +(gpcheck.h) + - A minor nit in a macro could cause incorrect grouping of 'if' +statements under implausible conditions. (gsmdebug.h) + - The first data plane buffer of an image enumerator didn't get +marked during garbage collection. (gsimage.c) + - The Watcom C compiler required splitting up a declaration. +(gxcmap.h) + - The extern declarations for the tables in gconf.c weren't gathered +together in one place. (gscdefs.h, gxiodev.h, gconf.c, gsdevice.c, gslib.c, +gsinit.c, gsiodev.c) + - charpath and show produced different output. We fixed this by +undoing a "bug fix", introduced in version 2.9, which suppressed hinting and +coordinate rounding for charpath; we aren't sure this won't cause some +obscure problems to reappear. (gstype1.c) + - Clipping with a rectangle usually created a 3-rectangle clipping +list, slowing down all drawing operations (performance bug only). +(gxacpath.c) + - stroking in a rotated coordinate system sometimes thought lines +were always thin when they actually weren't. (gxstroke.c) + - An unsigned quantity wasn't properly converted to signed, possibly +causing band path coordinates to get mangled. (gxclread.c) + - A bug in the Borland compiler caused an unsigned quantity to be +interpreted as signed, causing band path coordinates to get mangled. +(gxclread.c) + +Changes structure type pointers on 16-bit segmented systems to full +32-bit pointers. This will increase time and space requirements very +slightly on these systems. (gsmemory.h, gxobj.h) + +Changes the memory manager so that object finalization code may safely free +objects. (gsmemory.h, gsstruct.h, gsalloc.c, gsmemory.c) + +Refactors the Type 1 CharString interpreter so it can be included in +the imager library. (gstype1.h, gxtype1.h, gstype1.c) + +Starts to refactor the implementation of band lists in memory so that it can +use any encoding/decoding filter. Currently this choice is made at compile +time, but it could easily be made dynamic. (gxclmem.h, gxclmem.c) + +Starts to refactor image rendering so that, like path filling and stroking, +it only uses imager state and can be done after banding. (gxcmap.h, +gxdraw.h, gximage.h, gsimage*.c, gxcmap.c) + +Speeds up copy_mono for 2-bit-per-pixel devices a little. (gdevm2.c) + +Implements an optimized copy_alpha for 24-bit memory devices. (gdevmem.h, +gdevm24.c) + +Speeds up filling rectangles significantly. (gsbitops.c) + +Changes the band list rasterizer to use the memory space of the device +rather than the C heap: our allocator is considerably faster than malloc. +(gxclread.c) + +Speeds up stroking a little, especially in 90 degree rotated coordinate +systems. (gxstroke.c) + +Version 3.64(limited, incremental) (1/27/96) +================================== + +This release fixes a few more bugs, including some serious bugs in band +lists, and adds pdfmark processing to the PDF writer. The PDF writer is +still not fit for real use, since it converts all text characters into 720 +dpi bitmaps and turns images into zillions of tiny rectangles (!), but it +should be producing legal output. + +Documentation +------------- + +Fixes bugs: + - Frans van Hoesel's e-mail address was incorrect. (gdevdjet.c) + - The man page for ansi2knr was out of date. (ansi2knr.1) + - The description of a procedure was out of date. (gxdcolor.h) + +Notes that several "optional" features are required in order to obtain the +full PostScript Level 1 functionality at the library level. (lib.doc) + +Documents the top-level interpreter API. (imain.h) + +Adds details on differences between the imager API and the PostScript +graphics operators. (lib.doc) + +Notes (here, in NEWS) that the change for device prototypes in 3.61 made the +protection attributes of a device significant for the first time. Only the +writable attribute is significant so far. (news) + +Procedures +---------- + +Fixes bugs: + - The .dev rules in the library makefiles didn't list echogs as a +dependency. (jpeg.mak, libpng.mak, zlib.mak) + - The install rule tried to install gs.1.1 etc. rather than gs.1 +etc. (unix-end.mak) + - The install rule tried to install some nonexistent *.1 files. +(unix-end.mak) + +Adds 'help' and '?' procedures to assist users who don't read the +documentation. (gs_init.ps) + +Adds -A-, -E-, and -Z-... to turn off debugging flags. (gs.c) + +Adds a -dDELAYBIND switch to delay binding operators, to allow special +packages like pstotext to redefine them. (gs_init.ps) + +Utilities +--------- + +Fixes bugs: + - Fonts produced by rollconv.ps left a couple of items on the +operand stack, and left array packing set to true. (rollconv.ps) + +Makes ansi2knr require that the first token after a function header be a +left brace on the next line, so it can cope with some macros in IJG release +6a. Also updates it to work better without the GNU configure machinery, and +on some old compilers. (ansi2knr.c) + +Changes align.ps so it can be used directly to determine the margin +parameters. (align.ps, psfiles.doc) + +Drivers +------- + +Fixes bugs: + - The TIFF/F (G3 and G4) drivers were broken (bug introduced in +3.60). (gdevtfax.c) + - The PDF writer produced invalid output for 0-width, 0-height +images. (gdevpdfi.c) + - The PDF writer wasn't a page device. (gdevpdf.c) + - The PDF writer assigned the Contents node rather than the Pages +node as the Parent of each page. (gdevpdfx.h, gdevpdf.c) + +Corrects the margin information for the DeskJet printers to be the actual +values observed on a printer; all of the values in the file were wrong. +(gdevdjet.c) + +Adds pdfmark recognition and conversion to the PDF writer. All documented +pdfmarks (ANN, ARTICLE, DEST, DOCINFO, DOCVIEW, LNK, OUT, PAGE, PAGES, PS) +are recognized and converted, but some of them are not converted correctly. +(gs_pdfwr.ps, gdevpdfx.h, gdevpdf.c, gdevpdfm.c) + +Adds recognition of all Distiller parameters, except *ImageDict, to the PDF +writer. Currently only ASCII85EncodePages actually has any effect. +(gs_pdfwr.ps, gdevpdfx.h, gdevpdfp.c) + +Ensures that PDF output files include at least a default Info dictionary. +(gdevpdf.c) + +Changes the handling of coordinates in PDF output files so that the scale is +always 72 dpi, and so that each graphics operator is on a line by itself, +for compatibility with Adobe Illustrator. (gdevpdfx.h, gdevpdf*.c) + +Adds a driver for ImageMagick's MIFF format. The driver currently only +produces 24-bit, direct color, RLE compressed output. (gdevmiff.c) + +Platforms +--------- + +Changes the gp_check_interrupts platform procedure so that instead of just +returning a Boolean, it can now also return a negative error code. THIS IS +(THEORETICALLY) A NON-BACKWARD-COMPATIBLE CHANGE. However, since all +implementations of this procedure should only have been returning 0 or 1 up +to now, no existing code should need to be changed. (gpcheck.h, gsmisc.c) + +Interpreter +----------- + +Fixes bugs: + - devicenames was accidentally deleted. (gs_init.ps) + - -dFAKEFONTS could cause the memory manager to waste a lot of time. +(gs_dps1.ps) + - Using -r or -dFIXEDMEDIA with a non-page device caused an error. +(gs_init.ps) + - A VMS compiler reserves the word "readonly", which was used as a +parameter name. (imain.h, gsmain.c) + - A garbage collection during the execution of x/y/xyshow with an +array providing the values could get confused. (ibnum.h, ichar.h, stream.h, +ibnum.c, iscanbin.c, zchar.c, zchar2.c, zdps1.c, zupath.c) + - Errors in encoded number strings produced a typecheck rather than +a rangecheck error. (ibnum.c, zupath.c) + +Updates the DCT filters for IJG release 6a. (zfdctc.c) + +Provides an API call for getting the real stdio files. (imain.h, +gs.c, gsmain.c) + +Streams +------- + +Fixes bugs: + - If the CCITTFaxEncode stream encountered an output buffer boundary +while processing the last scan line of input, it could fail to process some +the scan line. (scfe.c) + - A couple of pointers weren't always initialized, possibly +confusing the garbage collector. (stream.c) + - The weighting coefficient structures used for image scaling +weren't declared properly for the garbage collector. (siscale.h, siscale.c) + +Library +------- + +Fixes bugs: + - Unrotated patterns always used the bounding box size as the step, +rather than XStep/YStep. (gspcolor.c) + - Alpha computations for graphics could be seriously incorrect (bug +introduced in 3.6x). (gdevabuf.c) + - The length of the next_data_x command for the fill_mask operation +was incorrect, causing the band list to become confused (bug introduced in +3.63). (gxclpath.c) + - An extern was omitted, causing linker warnings. (gxdevice.h) + - RasterOps could cause an invalid access because the palette +for a memory device wasn't set. (gdevmrop.c) + - gximage.h was included unnecessarily. (gspaint.c) + - Color screens caused a segmentation fault (bug introduced in +3.6x). (gxcht.c) + - cshow returned the width in an incorrect coordinate system. +(gscoord.h, gschar.c) + - Filling or stroking a path that lay entirely off the page in the ++X or +Y direction could corrupt memory (bug introduced in 3.6x). +(gxclpath.c) + - When banding, painting characters with halftones produced random +results (bug introduced in 3.6x). (gxclpath.c) + - When banding, characters could get clipped when they shouldn't be +(bug introduced in 3.6x). (gxclpath.c) + - The default implementation of fill_mask could discard clipped +bitmaps (bug introduced in 3.6x). (gdevdflt.c) + - Non-halftoned 24-bit colors could get garbled when banding (bug +introduced in 3.6x). (gxclist.c) + - When banding, if a stroked path had subpaths that fell entirely +outside the current band, the rest of the path was drawn in the wrong place +(bug introduced in 3.6x). (gxclpath.c) + +Speeds up image interpolation on machines with slow floating point. +(siscale.h, siscale.c) + +Speeds up interpolated images when using device color spaces. (gxcvalue.h, +gxfrac.h, gdevht.c, gxcmap.c, gsimage.c, gsimage3.c) + +Speeds up color mapping a little by removing tests and calls in favor of +code copying. (gxcmap.c) + +Implements RasterOp for 24-bit RGB devices. (gdevm8.c, gdevm24.c, +gdevmrop.c) + +Version 3.63(limited, incremental) (1/14/96) +================================== + +This release has the usual collection of bug fixes, and two significant +additions: AccurateScreens, and the first draft of a PostScript->PDF +converter ("distiller"). + +Documentation +------------- + +Fixes bugs: + - Some documentation for pstoppm.ps was out of date. (psfiles.doc) + - Documentation for acctest.ps, view*.ps, and zeroline.ps was +missing. (psfiles.doc) + - The documentation for rollconv.ps omitted the .CSR file. +(rollconv.ps) + +Removes an inappropriate RCS Id line. (gs.1) + +Adds a list of paper sizes to the man page. (gs.1) + +Suggests that driver authors use parameterization rather than copying when +possible. (drivers.doc) + +Adds an announcement of Ghostscript support on CompuServe. (README) + +Documents the new -dCOLORSCREEN switch and the existing -dDITHERPPI=lpi +switch. (use.doc) + +Notes that the OS/2 implementation now requires EMX/GCC 0.9b rather than +0.9a. (install.doc) + +Adds some new man pages. (pdf2ps.1, ps2ascii.1) + +Greatly expands lib.doc. (lib.doc) + +Procedures +---------- + +Fixes bugs: + - The pg target for Unix platforms didn't include some necessary +additional X11 libraries. (unix-end.mak) + - The Unix library makefile didn't define CCAUX or CCLEAF. +(ugcclib.mak) + - Unix systems didn't `install' some .ps files. (unix-end.mak) + +Extends genconf so that features at the library level can have +initialization procedures. (gconf.c, genconf.c, gsinit.c) + +Adds a -dCOLORSCREEN[=false] switch to force enabling or disabling of +4-color screens. (gs_init.ps, gs_setpd.ps) + +Utilities +--------- + +Fixes bugs: + - The prfont utility didn't leave enough of a margin on the left. +(prfont.ps) + - The ps2ascii utility still created files _temp_.out and _temp_.err +even though they are no longer used. (ps2ascii.ps) + - The acctest.ps file was empty, rather than including a test +program. (acctest.ps) + +Adds ps2pdf[.bat] scripts for invoking the new pdfwrite driver. (ps2pdf, +ps2pdf.bat, unix-end.mak) + +Drivers +------- + +Fixes bugs: + - The x11alpha driver had a patch that suppressed output in many +cases. (gdevxalt.c) + - The X driver set up a parameter incorrectly in copy_color. +(gdevx.c) + - An explicit cast was needed to handle a 'const' problem. +(gdevpng.c) + +Adds a pdfwrite driver that creates syntactically correct PDF output. The +output is only reasonable for fill/stroke graphics, not for text or images. +(iscan.h, sa85x.h, sfilter.h, gdevpdf.c, sfilter2.c, zfdecode.c) + +Platforms +--------- + +Fixes bugs: + - The test for WinExec failure on Win32 was incorrect. (gp_mswin.c) + - getenv was declared redundantly on OS/2. (gp_os2.c) + - gs16spl.c was missing . (gs16spl.c) + +Interpreter +----------- + +Fixes bugs: + - Images read data in smaller and smaller increments (performance +bug only). (zpaint.c) + - Images with MultipleDataSources=true and two or more DataSources +referencing the same stream could get confused. (zpaint.c) + - Invoking setpagedevice with an undefined key, even with Policy = +1, caused an error. (gs_setpd.ps) + - IEEE floats in binary tokens or encoded number strings were read +incorrectly on CPUs that use non-IEEE floating point. (ibnum.c) + +Adds a 'const' to the second parameter of zimage_setup. (zimage2.c, +zpaint.c) + +Encapsulates the filling of free memory blocks in a macro. (igc.c, +igcstr.c) + +Interpreter (PDF) +----------------- + +Fixes bugs: + - If the first line of a file began with % but the line was longer +than 255 characters, an error occurred. (pdf_main.ps) + - Masked images didn't set the color before drawing. (gs_pdf.ps) + - Extraneous blank lines in the trailer or cross-reference region +caused an error. (pdf_base.ps, pdf_main.ps) + +Streams +------- + +Speeds up image interpolation a little. Much more could be still be done. +(siscale.c) + +Library +------- + +Fixes bugs: + - An error in handling a boundary condition could cause a horizontal +streak of pixels to be turned on or off when it shouldn't be. (gxfill.c) + - The new scan-line-based filling loop could write pixels twice. +(The old trapezoid-based loop still does write pixels twice.) (gxfill.c) + - For multi-plane images, gs_image_next only sets *pused for the +last plane; this wasn't documented. (gsimage.h) + - Images with MultipleDataSources=true and two or more DataSources +referencing the same stream could get confused. (gsimage.h, gsimage0.c) + - 12-bit gray images caused an invalid memory access. (gsimage.c) + - Nearly-zero-thickness lines didn't get filled, because the hack +that compensates for this peculiarity of the MS Windows PostScript driver +accidentally got disabled. (gxfill.c) + - Some casts to remove 'const' were omitted. (gxclread.c) + - 1-line-high bitmaps could get written in the band list with an +inconsistent number of bytes, causing errors when reading. (gxcldev.h, +gxclbits.c, gxclist.c, gxclpath.c, gxclread.c) + - Isolated dots produced by round caps usually disappeared. (They +still disappear sometimes.) (gxstroke.c) + - On 16-bit platforms, the computation of t2 and t3 in +gx_curve_x_at_y could overflow, leading to incorrect output. (gxpcopy.c) + - Stroking horizontal or vertical lines could produce variations of +1 pixel in the line width. (gxstroke.c) + - The default clipping region for band rendering was too large, +leading to wasted work. (gxclread.c) + - Guarantees no double pixel writing when necessary, i.e., when a +non-idempotent RasterOp is selected. (gsropt.h, gxfill.c) + - For unrotated black-and-white images, one column of pixels at the +right edge of the image might be incorrect. (gsimage1.c) + - A const pointer was passed inappropriately. (gxistate.h, +gscoord.c) + - CIE color conversion could address 1 element beyond the end of an +array, with unpredictable results. (gscie.c) + +Separates out the higher-level band list facilities, so they can be an +optional feature. (lib.mak, gxcldev.h, gxclpath.h, gxclbits.c, gxclist.c, +gxclpath.c, gxclread.c) + +Implements bitmap (fill_mask) clipping in the band list. (gxcldev.h, +gxclpath.h, gxclist.c, gxclpath.c, gxclread.c) + +Starts to separate out the RasterOp facility as an optional feature. +(lib.mak, gxdevice.h, gxdevrop.h, gdevdflt.c, gdevmrop.c) + +Encapsulates the filling of free memory blocks in a macro, at the request of +a licensee. (gdebug.h, gsmdebug.h, gsmemory.h, gs.c, gsalloc.c, gsmemory.c, +gxbcache.c) + +Speeds up fill_rectangle for 32-bit devices. (gdevm32.c) + +Speeds up path writing in band lists a little. (gxclpath.c) + +Implements AccurateScreens along the lines described in the Adobe +documentation. The current implementation can produce very large +super-cells, so it will not always be able to actually increase the screen +accuracy. (gxdht.h, gsht.c, gshtscr.c) + +Version 3.62(limited, incremental) (12/26/95) +================================== + +This release makes some licensee-requested improvements in the garbage +collector and fixes a couple of minor bugs. It also constitutes a +checkpoint for the forthcoming forked 3.53 release. + +Documentation +------------- + +Notes that for Win32s, gs16spl.exe must be in the same directory as +gswin32.exe. (install.doc) + +Changes `3.N' to a real version number in the man page. (gs.1) + +Adds a reference to dos-psv, another "dumb terminal" user interface for +Ghostscript intended for MS-DOS users. (README) + +Procedures +---------- + +Fixes bugs: + - The stack size for some of the PC platforms was set too small. +(watc.mak, watcwin.mak) + +Changes the default value of ORIENT1 from false to true, i.e., assumes that +a value of 1 for the orientation parameter of setpageparams indicates +portrait orientation. THIS IS A NON-BACKWARD-COMPATIBLE CHANGE. It only +affects files created for roll-media imagesetters. (gs_init.ps, use.doc) + +Interpreter +----------- + +Fixes bugs: + - The definition of the op_index_op_array_table macro had an +incorrect trailing semicolon. (opdef.h) + - Setting the PageSize policy to 1 and then trying to set the page +size caused an error if FIXEDMEDIA was selected. (gs_setpd.ps) + +Changes the garbage collector marking phase so that instead of just using a +single block (allocated, free, or default) for the mark stack, it can chain +all three types of block together. (igc.h, igc.c, igcstr.c, ilocate.c) + +Refactors the garbage collector slightly to reduce inter-module +dependencies. (int.mak, igc.h, igcstr.h, igcstr.c) + +Changes the garbage collector to keep track of ranges within each chunk that +must be scanned if the mark stack overflows. (gxalloc.h, igc.c) + +Adds [write]===[only] procedures, which act like == but also print the +contents of dictionaries, and ppstack, which acts like pstack but uses ===. +Changes ESTACKPRINT and OSTACKPRINT to use === rather than ==. (gs_init.ps, +gs_setpd.ps) + +Interpreter (PDF) +----------------- + +Fixes bugs: + - If a PDF file substituted a calibrated color space for the +DeviceGray or DeviceRGB color space using a ColorSpace resource, the +PostScript file that pdf2ps produced from that PDF file caused an error. +(gs_pdf.ps) + +Library +------- + +Fixes bugs: + - The debugging code for checking the sorting of line lists didn't +check for an empty list. (gxfill.c) + +Version 3.61(limited) (12/10/95) +===================== + +This limited release fixes a few bugs (including a couple that significantly +affected character quality) and also includes some substantial performance +improvements. + +Documentation +------------- + +Fixes bugs: + - The directory name for the PNG library was incorrect. +(libpng.mak) + - The analysis of curve monotonocity in gxpcopy.c had an error. +(gxpcopy.c) + +Changes the subdirectory names for zlib and libpng to be consistent. +(make.doc) + +Documents a possible problem with object file format incompatibilities in +certain versions of Linux. (make.doc) + +Documents the new distinction between devices and device prototypes. +(language.doc) + +Adds a pointer to DEC's free pstotext utility. (README) + +Procedures +---------- + +Fixes bugs: + - zlib.mak omitted some files in the encoding module dependencies. +(zlib.mak) + - os2.mak referred to png.mak rather than libpng.mak. (os2.mak) + - The png devices didn't include gdevpccm.$(OBJ) as a required file. +(devs.mak) + - Some modules in lib.mak referred to stream.h, which was defined in +int.mak. (int.mak, lib.mak) + - Quite a few dependencies on header files were missing from the +makefiles. (int.mak, lib.mak, *.mak) + +Adds a 'pg' target to the Unix makefiles, for building profiling +configurations. (unix-end.mak) + +Utilities +--------- + +Fixes bugs: + - Type 1 fonts in which some characters are defined by PostScript +procedures couldn't be compiled. (ccfont.h, iccfont.c, font2c.ps) + - pdf2ps didn't write Widths or Encoding in the converted file, +producing incorrect spacing and incorrect characters. (pdf_2ps.ps) + - markhint.ps didn't handle the Type 1 'div' operator, causing +typecheck errors. (markhint.ps) + - markhint.ps ignored the hstem3 and vstem3 hints. (markhint.ps) + +Changes the rollconv.ps utility to produce files whose names conform to the +8.3 length restriction, and to reduce the fixed RAM overhead for Kanji +fonts. (rollconv.ps) + +Adds a utility for detecting compiler problems that affect Ghostscript. +(bughunt.sh) + +Drivers +------- + +Adds anti-aliasing capability (-dTextAlphaBits and -dGraphicsAlphaBits) to +the PGM and PPM drivers. (gdevpbm.c) + +Declares the static_procs member of the device structure as const *. This +should have been done a long time ago! (drivers.doc, gxdevice.h) + +Platforms +--------- + +Fixes bugs: + - Printing didn't work in 32-bit MS Windows environments. +(bcwin32.mak, gdevmswn.c, gp_mswin.c) + - There were some compatibility problems with IBM C. (os2.mak, +gsdll.h, gdevpm.c, gp_os2.c) + +Adds the PNG drivers to the 32-bit MS Windows and OS/2 makefiles. +(bcwin32.mak, os2.mak) + +Adds a conditional to work around a bug in gcc 2.7.x (it didn't recognize +that the target of a const T * might still be mutable through aliasing). +(stdpre.h) + +Fonts +----- + +Fixes bugs: + - Rasterizing a character in a Type 1 font with an invalid FontBBox +left some garbage on the operand stack (bug introduced in 3.52 or 3.60). +(gs_type1.ps) + - The font substitution algorithm could fail or loop. (gs_fonts.ps) + +Adds a little more support for CID fonts and CMaps. (gs_cidfn.ps, +gs_cmap.ps) + +Interpreter +----------- + +Fixes bugs: + - An #include was missing. (ziodev.h) + - Scanner-detected errors (primarily syntaxerror) didn't report the +file position. (gs_init.ps) + - Rotated characters were rendered incorrectly (bug introduced in +3.52). (gstype1.c) + - Some compilers got upset about the use of 'dict' as a variable +name. (zdict.c) + - Operand stack overflows sometimes didn't set the "requested" field +correctly. (interp.c) + - Using -dBufferSpace= with a non-printer device caused an error. +(gs_init.ps) + +Adds zlibEncode/Decode filters. (int.mak, zfzlib.c) + +Separates devices from device prototypes. Prototypes, which lack the +writable attribute, cannot be installed as the current device or have their +parameters changed. This change allows Ghostscript to be exited and +restarted without being reloaded, which solves some problems with DLL +usage. ****** WE HAD TO SUBVERT THIS CHANGE BECAUSE OF MEMORY MANAGER +PROBLEMS, by making zgetdevice return a writable reference to the +prototype. (We finally fixed this in release 3.65.) (gs_init.ps, iref.h, +opcheck.h, zdevice.c, ztype.c, zwppm.c) + +Extends the client API to allow for pushing values onto the operand stack. +(imain.h, gs.c, gsmain.c) + +Defines a .setdefaultscreen procedure that sets the default halftone screen, +transfer function, and stroke adjustment for the current device. Changes +selectdevice and setpagedevice so that they call .setdefaultscreen; +setpagedevice calls .setdefaultscreen before calling the Install procedure, +so that Install can set different parameters if it wishes. Note that +setdevice does not do this. (gs_init.ps, gs_setpd.ps) + +Interpreter (PDF) +----------------- + +Fixes bugs: + - Tf set the current text font twice, and interacted with pdf2ps in +an awkward way. (gs_pdf.ps, pdf_2ps.ps, pdf_font.ps) + - If a font had variant Widths, it could get confused in the cache +with the underlying font. (pdf_font.ps) + - If a character appeared twice in an encoding and the font +specified different Widths values for the two occurrences, the last Width +would be used. We patched this to ignore zero Widths, which is not the +correct solution but which almost always produces correct output. +(pdf_font.ps) + - Arrays containing nulls didn't print out correctly (bug introduced +in 3.60). (gs_init.ps) + - Some PDF files contain very large dictionaries, which caused a +stackoverflow. (pdf_base.ps) + +Speeds up the initial processing of PDF files by caching the map from page +numbers to page objects, and by not scanning the outlines if we aren't +producing PostScript output. (pdf_2ps.ps, pdf_base.ps, pdf_main.ps) + +Streams +------- + +Adds zlibEncode/Decode filters. (lib.mak, szlibx.h, szlibc.c, szlibd.c, +szlibe.c) + +Library +------- + +Fixes bugs: + - glyphshow displayed a character with code 0 rather than the +requested character (bug introduced in 3.60.) (gschar.c) + - If trimming white space around a character reduced its raster, the +character was garbled in the cache (bug introduced in 3.60.) (gxccman.c) + - colorimage would incorrectly convert white pixels to black if the +image color space was CMYK, the current color space was not CMYK, and the +number of bits per pixel was 4 or 8. (gsimage2.c) + - One of the clipping tests for images was backwards (bug introduced +in 3.60). (gsimage.c) + - Type 1 fonts that used the Flex feature applied hints to the path +multiple times, causing dropouts, uneven stems, and other problems (bug +probably introduced in 3.21). (gstype1.c) + - If a Type 1 font used the Flex feature within the accent of an +accented character defined with seac, the shape of the accent could be +distorted. (gxtype1.h, gstype1.c) + - If a Type 1 font changed hints using the hint replacement facility +when the last operation was a closepath, the old hints would be applied a +second time, distorting the shape. (gxhint3.c) + - Band lists could read garbage beyond the end of data for a band, +causing unpredictable errors (bug introduced in 3.60). (gxclread.c) + - If the bounding box of the path for fill_path or stroke_path went +outside the device page boundary when banding, out-of-bounds memory +references occurred (bug introduced in 3.60). (gxdevice.h, gxclpath.c) + +Adds an alternative implementation of the core path filling algorithm that +is much faster on objects with curves but doesn't handle Y fattening. This +is the implementation that will normally be used for rasterizing characters. +This implementation rasterizes curves directly, without flattening them. +(gxfixed.h, gxpath.h, gzpath.h, gsdps1.c, gxfill.c, gxpcopy.c, gxpdash.c) + +Speeds up the flattening of curves substantially by omitting more redundant +points. (gxpcopy.c) + +Speeds up character bitmap compression a little more. (gsbitops.h, +gdevabuf.c, gsbitops.c, gxccman.c) + +Speeds up anti-aliased graphics a bit by computing a bounding box before +converting from oversampling to alpha values, and by speeding up the +bounding box computation itself. (gsbitops.h, gdevabuf.c, gsbitops.c, +gxccman.c) + +Version 3.60(limited) (11/20/95) +===================== + +(Note: release numbers 3.54 through 3.59 were deliberately skipped.) This +internal release includes a major redesign of band lists in order to reduce +their size for embedded implementations, to move towards supporting "vector" +output formats, and to further separate the imager library from the language +interpreters. + +Documentation +------------- + +Fixes bugs: + - A comment was incorrect. (viewpbm.ps) + - The PixelDifference filters were not documented. (language.doc) + - The change from currenttime to .currenttime wasn't documented. +(language.doc) + - gs.1 incorrectly stated that the default font directory name +included the version number. (gs.1) + - The -g and -r switches didn't specify that the units for their +arguments are pixels and pixels per inch respectively. (use.doc) + - The PageOffset page device parameter wasn't listed. +(language.doc) + +Changes copy_mono and copy_color to optional procedures. (drivers.doc) + +Adds a reference to ps_view.ps, a "dumb terminal" user interface for +Ghostscript intended for MS-DOS users. (README) + +Splits off the documentation on installing Ghostscript into a separate file. +(readme, install.doc, use.doc) + +Adds documentation on the data format produced by the standard LZWEncode +filter. (readme, lzwce.doc) + +Clarifies XLIBDIR vs. XLIBDIRS. (make.doc) + +Adds user-contributed documentation on building Ghostscript under QNX. +(make.doc) + +Procedures +---------- + +Fixes bugs: + - The rule for building dfaxhigh.dev had a typo. (devs.mak) + - The dependencies for gdevpipe.h were missing errno__h and +string__h. (unixtail.mak) + - The geninit program (the implementation of COMPILE_INITS=1) didn't +parse the command line properly, and didn't check for PostScript files +properly. (geninit.c) + - ccfontab.c was omitted from the fileset. The easiest way to fix +this was to rename it to icfontab.c. (gs.mak, int.mak, ccfontab.c) + - The Unix makefiles installed caption.ls (a typo) rather than +caption.ps. (unix-end.mak) + - XLIBDIR, for dynamic library access, wasn't defined. (*head.mak, +*tail.mak, ugcclib.mak) + +Adds the PNG and ZLIB makefiles to the fileset. (*.mak, png.mak, zlib.mak, +tar_cat) + +Puts the PixelDifference filters in the standard Level 2 set, since the LZW +filters may invoke them (a post-Red Book addition to the PostScript language +definition). (int.mak) + +Adds -Wcast-qual to the gcc compiler flags. (gcc-head.mak) + +Adds the PNG drivers to the standard Unix configurations. +(ansi/cc-/gcc-head.mak) + +Adds a -dNOFONTPATH switch to suppress any consultation of the FONTPATH +variable or the GS_FONTPATH environment variable. (gs_fonts.ps, gs_init.ps) + +Utilities +--------- + +Fixes bugs: + - The default scaling for viewing PBM files was computed +incorrectly. (viewpbm.ps) + - ps2ascii left a value on the stack for each unrecognized character +it processed, eventually causing a stackoverflow. (ps2ascii.ps) + +Changes viewpbm.ps so that it simply defines P1 through P6, allowing PBM +files to be executed with 'run'. (viewpbm.ps) + +Adds a small benchmark to crudely measure hardware/system performance. The +same file can either be compiled as a C program or executed as a PostScript +program. (bench.c) + +Adds a few PPD files to the distribution. There will probably be more as +time goes on. (tar_gs, unix-end.mak) + +Updates the Unix lpr scripts to handle a wider variety of device options. +(unix-lpr.doc, lprsetup.sh, unix-lpr.sh) + +Adds a utility for converting files produced by Macromedia's Rollup program +to a Type 0 form directly usable by Ghostscript. (rollconv.ps) + +Drivers +------- + +Fixes bugs: + - Forwarding devices passed an incorrect first argument when +forwarding a copy_rop operation. (gsdevice.c) + - Because of a typo, the LaserJet drivers had incorrect margins. +This was probably a new bug in 3.5x. (gdevdjet.c) + - A private name was duplicated. (gdevtfax.c) + - The x11alpha driver passed invalid colors to the X library. +(gdevxalt.c) + - The x11alpha driver set the blue component of colors incorrectly. +(gdevxalt.c) + - Some `const' declarations were missing. (gdevtifs.c, gdevtfnx.c, +gdevxxf.c) + - The size of A4 paper was slightly inconsistent across drivers. +(gdevdjet.c, gdevl256.c) + +Provides default implementations of copy_mono and copy_color in terms of +fill_rectangle. (gxdevice.h, gsdevice.c) + +Adds forwarders for sync_output and output_page. (gxdevice.h, gsdevice.c) + +Adds new optional procedures to the driver interface: + - fill_path for filling a path with a color; + - stroke_path for stroking a path; + - fill_mask for painting a color through a mask. +The default implementations use the existing rasterizer algorithms. This +involves a NON-BACKWARD-COMPATIBLE change to the parameters of a few +internal routines: + gs_currentlineparams + gx_fill_path, gx_fill_path_only, gx_path_expand_dashes, gx_path_flatten +and two externally visible routines not part of standard PostScript: + gs_setfilladjust, gs_currentfilladjust +(gdevmem.h, gdevprn.h, gspath.h, gspenum.h, gxcpath.h, gxdevice.h, gxdraw.h, +gxpaint.h, gxpath.h, gscoord.c, gsdevice.c, gspaint.c, gsstate.c, +gxacpath.c, gxclist.c, gxclread.c, gxcpath.c, gxdraw.c, gxfill.c, gxpaint.c, +gxpcmap.c, gxpcopy.c, gxstroke.c) + +Makes major changes to the dithering algorithm for the color DeskJet and +BubbleJet drivers, contributed by a user. (gdevcdj.c) + +Adds a contributed 12-bit RGB TIFF driver. (gdevtfnx.c) + +Platforms +--------- + +Fixes bugs: + - The printjob created by Ghostscript was called "Ghostscirpt" +instead of "Ghostscript". (gp_os2.c) + - An "export" declaration was omitted from DllInit. (gp_mswin.c) + +Removes gp_get_clock (its interface was changed from calendar +days/milliseconds to epoch seconds/nanoseconds in an undocumented, +NON-BACKWARD-COMPATIBLE change in 3.51), and adds a new gp_get_realtime +procedure that returns epoch seconds/nanoseconds. This too is a +NON-BACKWARD-COMPATIBLE change; it is required because we overlooked the +prior change in a batch of user-contributed code. (gp.h, gp_*.c) + +Fonts +----- + +Adds Heavy as a synonym for Bold when doing intelligent font substitution. +(gs_fonts.ps) + +Interpreter +----------- + +Fixes bugs: + - The setup for the CCITTFax filters set the 'raster' element +redundantly. (zfdecode.c) + - currentscreen and currentcolorscreen could give an error if the +current screen was set with sethalftone (or, for currentscreen, +setcolorscreen). (gs_dps1.ps) + - The font operators didn't work properly if a PostScript file +redefined certain operator names. (gs_res.ps) + - The CCITTFax filters imposed a limit of 9999 Rows or Columns. The +new limit is 32000. (zfdecode.c) + - Streams could get removed from a bookkeeping list prematurely, and +wind up dangling. (zfile.c) + - The garbage collector didn't ask for large enough a mark stack, +and only used half of what it got. (This was only a performance problem.) +(igc.c) + - Two private names duplicated names in a vendor library. (zbseq.c) + - Type 1 fonts didn't enforce the maximum value of BlueScale, which +caused some faulty fonts produced by Fontographer to produce incorrect +output. (zfont1.c) + - cvs / cvrs / = didn't produce Adobe-compatible output. +(gs_init.ps, iutil.h, iutil.c, zfileio.c) + - Multiple -I switches set the search path incorrectly. (gsmain.c) + - Many `const' declarations were missing. (icie.h, idparam.h, +iref.h, iutil.h, idparam.c, iinit.c, ilocate.c, iname.c, interp.c, iparam.c, +iutil.c, zcie.c, zfile.c, zgstate.c, ziodev.c, ztype.c) + - Fonts could wind up with a pointer to the wrong VM space, causing +potential GC or save/restore confusion. (zfont2.c) + - upath could leave garbage on the stack if it failed. (gs_dps1.ps) + +Speeds up rasterizing characters into the cache a little. (gs_type0.ps) + +Changes the default limit on the size of cached characters from the maximum +of (18 points or 5 times the "average" character size) to (18 points or 1% +of the total cache size). (gs_init.ps) + +Adds the DecodedByteAlign parameter to the CCITTFax filters. (zfdecode.c) + +Updates some code for compatibility with the new fill_path driver procedure. +(zupath.c) + +Replaces .set/currentfilladjust with .set/currentfilladjust2, and defines +the former in terms of the latter. (gs_init.ps, zgstate.c) + +Extends the make[word]imagedevice operators to accept palette values of 16, +24, and 32, for creating true-color image devices. (zdevice.c) + +Changes realtime to match the definition of gp_get_realtime. (zmisc.c) + +Removes the [.]currenttime operator. realtime provides interval timing in +milliseconds; the %Calendar% IODevice provides calendar times. (zmisc.c) + +Extends the LZW filters to handle the PDF Predictor (pixel-differencing) +option. (zfdecode.c, zfilter2.c, zfpdiff.c (deleted)) + +Interpreter (PDF) +----------------- + +Fixes bugs: + - The length of an image's data was sometimes calculated +incorrectly, causing an error when converting PDF to PostScript. +(pdf_draw.ps) + - If word spacing and/or text spacing was non-zero, an error could +occur. (gs_pdf.ps) + - Text that was both filled and stroked caused an error. +(gs_pdf.ps) + +Streams +------- + +Fixes bugs: + - When closing an encoding filter stream whose target was also a +filter, the latter could get called incorrectly with last = 1, possibly more +than once, leading to premature EOD markers. (stream.c) + - The LZW-compatible encoder put out an incorrect end-of-data code. +(slzwce.c) + - The LZW-compatible encoder didn't put out a reset code soon +enough. (slzwce.c) + - Some `const' declarations were missing. (siscale.c) + - Doing a sgets on a closed stream could call sreadbuf, possibly +causing an error. (stream.c) + +Adds a new (optional) set_defaults procedure to the stream template, which +sets the stream parameters to default values. We only implement it for a +few stream types. (scfx.h, scommon.h, slzwx.h, spdiffx.h, srlx.h, +strimpl.h, scfd.c, scfe.c, slzwce.c, slzwd.c, slzwe.c, spdiff.c, srld.c, +srle.c) + +Adds a new parameter to the CCITTFax filters, DecodedByteAlign. This is an +integer N, which must be a power of 2 between 1 (2^0) and 16 (2^4), that +specifies that decoded data scan lines are always a multiple of N bytes. +The encoding filter skips data in each scan line from Columns to the next +multiple of N bytes; the decoding filter pads each scan line to a multiple +of N bytes. Default value: 1. (scfx.h, scfd.c, scfe.c) + +Increases the maximum width of a scan line for the CCITTFaxEncode filter to +32000 pixels. (scf.h) + +Library +------- + +Fixes bugs: + - Cached characters sometimes had extra blank space on the left, +leading to some unnecessary bit-shuffling when imaging them. (gxccman.c) + - In rare cases, gray halftones called gx_color_load unnecessarily. +(gxdither.c) + - The list of all-bands commands wasn't initialized/reset properly. +(gxclist.c, gxclread.c) + - Rendering an anti-aliased character to a non-anti-aliased device +didn't free the temporary bitmap, causing memory to be lost. (gxccache.c) + - Dash patterns where the offset exactly reached a run of length 0 +skipped over the 0-length run. (gsline.c) + - Rectangles closed with both lineto and closepath weren't +recognized as rectangles. This is only a performance bug. (gxpath2.c) + - Because of a typo in a macro formal parameter list, a private name +was duplicated. (gsstruct.h) + - Text display operations didn't update the current character in the +enumerator structure during the fastest path through the code. This only +matters to one very unusual commercial client. (gschar.c) + - Some `const' declarations were missing. (gsparam.h, gxistate.h, +stdpre.h; gdevm1.c, gsalloc.c, gsfont.c, gsimage3.c, gsmemory.c, gsmisc.c, +gspcolor.c, gstype1.c, gxfill.c, gxpcopy.c) + +Changes the header files to assume that gcc on Solaris defines +__svr4__ and that, in this case, has the right stuff in it. +(memory_.h) + +Refactors the character cache to share structures with a similar cache +used by band lists. Eventually the band list may be able to reference +the character cache directly, saving a lot of copying. (gxbcache.h, +gxfcache.h, gsfont.c, gxbcache.c, gxccache.c, gxccman.c) + +Speeds up getting the side bearing and width of a Type 1 charstring a +little. (gxtype1.h, gstype1.c) + +Redesigns band lists so that they can cache character bitmaps as well as +halftone bitmaps. Characters may be written for all bands, not just the +band(s) they appear in, depending on the setting of the CHAR_ALL_BANDS_COUNT +parameter in gxclbits.c. (gxcldev.h, gxclist.h, gxclbits.c, gxclist.c, +gxclread.c) + +Adds G4 fax compression for band list bitmaps. (gxcldev.h, gxclist.c, +gxclread.c) + +Incorporates the new set_defaults procedure into the memory-based band list +implementation. (gxclmem.c) + +Implements a halftoning device that can be used in a device pipeline. +(gdevht.h, gzht.h, gdevht.c, gxcht.c) + +Factors out imager state from the full graphics state. This division is +preliminary and subject to change. (gxistate.h, gxop1.h, gzstate.h, +gsline.c, gsstate.c, gstype1.c, gxhint*.c) + +Implements passing fill operations in the band list, except for pattern +color or colored halftones. (gxcldev.h, gxclist.h, gxclist.c, gxclread.c) + +Implements passing stroke operations in the band list, except for pattern +color or colored halftones. (gsline.h, gslparam.h, gxline.h, gzline.h, +gsline.c; gxcldev.h, gxclist.h, gxclist.c, gxclread.c) + +Implements the ability to represent halftoned characters in the band list. +(gxccache.c) + +Starts to implement the ability to do halftoning during the rendering phase +rather than before writing the band list (currently for black-and-white +devices only). Doing this required NON-BACKWARD-COMPATIBLE changes to the +interfaces of a few internal procedures: + gx_check_tile_size, gx_render_device_{color,gray} +(gxdcolor.h, gxdht.h, gzht.h, gsht.c, gsimage1.c, gsmisc.c, gspcolor.c, +gsstate.c, gxcht.c, gxclbits.c, gxdither.c, gxht.c) + +Implements passing clipping information in the band list. (gzcpath.h, +gxacpath.c, gxclpath.c, gxclread.c, gxcpath.c) + +Removes the gs_state * parameter from the device color fill_rectangle +procedures and many of their callers, since it is no longer needed. This is +a non-backward-compatible change to an internal API. (gdevmrop.h, +gxdcolor.h, gxdraw.h, gxpaint.h, gdevmrop.c, gsimage.c, gspcolor.c, gxcht.c, +gxclread.c, gxdraw.c, gxfill.c, gxht.c, gxpaint.c, gxstroke.c) + +Removes gxdevice.h from gzstate.h, since not all modules requiring access to +the graphics state need to know the implementation of devices. This entails +adding gxdevice.h to the include lists for some modules. (gxchar.h, +gxcpath.h, gxcvalue.h, gxdevice.h, gxtype1.h, gzstate.h; gschar.c, +gscoord.c, gsdevice.c, gsimage1.c, gsimage2.c, gsimage3.c, gspaint.c, +gspath.c, gsstate.c, gstype1.c, gxccache.c, gxccman.c, gxhint1.c, gxhint2.c, +gxhint3.c, gxpaint.c) + +Adds a compile-time option, ALPHA_LSB_FIRST, which causes alpha-sampled +characters to be nibble-reversed in the cache. This was created for a +specialized application and does not interact well with the rest of the +code. (gsbitops.c) + +Substantially reduces the space required to represent 24- or 32-bit colors +in the band list, by using more aggressive color differencing. (gxcldev.h, +gxclist.c, gxclread.c) + +Changes the allocation of unique IDs for halftone tiles to use the gray +level rather than the number of 1-bits as the increment to a base ID; this +allows more efficient (delta) representation of halftone indices in the band +list. (gxcldev.h, gxclist.c, gxclread.c, gxht.c) + +Substantially speeds up entering anti-aliased characters in the cache, by +removing white space before compressing rather than vice versa. +(gsbitops.c, gxccman.c) + +Version 3.53 (1/10/96) +============ + +This is an anomalous, out-of-sequence release requested by a commercial +licensee. It consists of 3.52 plus the following retrofits from 3.60 +through 3.63: + - PDF interpreter and pdf2ps; + - Type 1 rasterizer fixes; + - Type 1 rasterizer and polygon fill performance improvements; + - MS Windows and OS/2 fixes; + - A few other important fixes. +It does NOT fix all problems reported since 3.52. + +The list of changes below indicates which subsequent release was the source +of each change. In several cases, minor editing of the change was required +to make it compatible with 3.52. + +Documentation +------------- + +Fixes bugs: + [3.61] The analysis of curve monotonocity in gxpcopy.c had an error. +(gxpcopy.c) + +[3.63] Notes that the OS/2 implementation now requires EMX/GCC 0.9b rather +than 0.9a. (use.doc) + +[3.62] Notes that for Win32s, gs16spl.exe must be in the same directory as +gswin32.exe. (use.doc) + +[3.62] Adds a reference to dos-psv, another "dumb terminal" user interface +for Ghostscript intended for MS-DOS users. (README) + +[3.61] Adds a pointer to DEC's free pstotext utility. (README) + +[3.60] Adds a reference to ps_view.ps, a "dumb terminal" user interface for +Ghostscript intended for MS-DOS users. (README) + +Procedures +---------- + +Fixes bugs: + [3.60] The geninit program (the implementation of COMPILE_INITS=1) +didn't parse the command line properly, and didn't check for PostScript +files properly. (geninit.c) + [3.60] ccfontab.c was omitted from the fileset. The easiest way to +fix this was to rename it to icfontab.c. (gs.mak, int.mak, ccfontab.c) + [3.60] The definition of pdfread.dev did an ADDMOD, not a SETMOD. +(int.mak) + +[3.60] Adds a -dNOFONTPATH switch to suppress any consultation of the +FONTPATH variable or the GS_FONTPATH environment variable. (gs_fonts.ps, +gs_init.ps) + +Utilities +--------- + +Fixes bugs: + [3.61] pdf2ps didn't write Widths or Encoding in the converted file, +producing incorrect spacing and incorrect characters. (pdf_2ps.ps) + [3.60] ps2ascii left a value on the stack for each unrecognized +character it processed, eventually causing a stackoverflow. (ps2ascii.ps) + +[3.61] Changes the rollconv.ps utility to produce files whose names conform +to the 8.3 length restriction, and to reduce the fixed RAM overhead for +Kanji fonts. (rollconv.ps) + +[3.60] Adds a utility for converting files produced by Macromedia's Rollup +program to a Type 0 form directly usable by Ghostscript. (rollconv.ps) + +Drivers +------- + +Fixes bugs: + [3.60] Because of a typo, the LaserJet drivers had incorrect +margins. This was probably a new bug in 3.5x. (gdevdjet.c) + [3.60] A private name was duplicated. (gdevtfax.c) + [3.60] The x11alpha driver passed invalid colors to the X library. +(gdevxalt.c) + [3.60] The x11alpha driver set the blue component of colors +incorrectly. (gdevxalt.c) + +Platforms +--------- + +Fixes bugs: + [3.63] The test for WinExec failure on Win32 was incorrect. +(gp_mswin.c) + [3.63] getenv was declared redundantly on OS/2. (gp_os2.c) + [3.63] gs16spl.c was missing . (gs16spl.c) + [3.61] Printing didn't work in 32-bit MS Windows environments. +(bcwin32.mak, gdevmswn.c, gp_mswin.c) + [3.61] There were some compatibility problems with IBM C. (os2.mak, +gsdll.h, gdevpm.c, gp_os2.c) + [3.60] The printjob created by Ghostscript was called "Ghostscirpt" +instead of "Ghostscript". (gp_os2.c) + [3.60] An "export" declaration was omitted from DllInit. +(gp_mswin.c) + +[3.61] Adds a conditional to work around a bug in gcc 2.7.x (it didn't +recognize that the target of a const T * might still be mutable through +aliasing). (stdpre.h) + +Fonts +----- + +Fixes bugs: + [3.61] Rasterizing a character in a Type 1 font with an invalid +FontBBox left some garbage on the operand stack (bug introduced in 3.52 or +3.60). (gs_type1.ps) + [3.61] The font substitution algorithm could fail or loop. +(gs_fonts.ps) + +[3.60] Adds Heavy as a synonym for Bold when doing intelligent font +substitution. (gs_fonts.ps) + +Interpreter +----------- + +Fixes bugs: + [3.63] Invoking setpagedevice with an undefined key, even with +Policy = 1, caused an error. (gs_setpd.ps) + [3.62] Setting the PageSize policy to 1 and then trying to set the +page size caused an error if FIXEDMEDIA was selected. (gs_setpd.ps) + [3.61] Rotated characters were rendered incorrectly (bug introduced +in 3.52). (gstype1.c) + [3.60] currentscreen and currentcolorscreen could give an error if +the current screen was set with sethalftone (or, for currentscreen, +setcolorscreen). (gs_dps1.ps) + [3.60] Streams could get removed from a bookkeeping list +prematurely, and wind up dangling. (zfile.c) + [3.60] Multiple -I switches set the search path incorrectly. +(gsmain.c) + [3.60] Fonts could wind up with a pointer to the wrong VM space, +causing potential GC or save/restore confusion. (zfont2.c) + [3.60] upath could leave garbage on the stack if it failed. +(gs_dps1.ps) + +[3.61] Extends the client API to allow for pushing values onto the operand +stack. (imain.h, gs.c, gsmain.c) + +[3.61] Defines a .setdefaultscreen procedure that sets the default halftone +screen, transfer function, and stroke adjustment for the current device. +Changes selectdevice and setpagedevice so that they call .setdefaultscreen; +setpagedevice calls .setdefaultscreen before calling the Install procedure, +so that Install can set different parameters if it wishes. Note that +setdevice does not do this. (gs_init.ps, gs_setpd.ps) + +[3.60] Speeds up rasterizing characters into the cache a little. +(gs_type0.ps) + +[3.60] Changes the default limit on the size of cached characters from the +maximum of (18 points or 5 times the "average" character size) to (18 points +or 1% of the total cache size). (gs_init.ps) + +[3.60] Implements parts of the Type 1 BuildChar callout in C. (gs_type1.ps, +zchar.c) + +Interpreter (PDF) +----------------- + +Fixes bugs: + [3.62] If a PDF file substituted a calibrated color space for the +DeviceGray or DeviceRGB color space using a ColorSpace resource, the +PostScript file that pdf2ps produced from that PDF file caused an error. +(gs_pdf.ps) + [3.61] Tf set the current text font twice, and interacted with +pdf2ps in an awkward way. (gs_pdf.ps, pdf_2ps.ps, pdf_font.ps) + [3.61] If a font had variant Widths, it could get confused in the +cache with the underlying font. (pdf_font.ps) + [3.61] If a character appeared twice in an encoding and the font +specified different Widths values for the two occurrences, the last Width +would be used. We patched this to ignore zero Widths, which is not the +correct solution but which almost always produces correct output. +(pdf_font.ps) + [3.61] Arrays containing nulls didn't print out correctly (bug +introduced in 3.60). (gs_init.ps) + [3.61] Some PDF files contain very large dictionaries, which caused +a stackoverflow. (pdf_base.ps) + [3.60] The length of an image's data was sometimes calculated +incorrectly, causing an error when converting PDF to PostScript. +(pdf_draw.ps) + [3.60] If word spacing and/or text spacing was non-zero, an error +could occur. (gs_pdf.ps) + [3.60] Text that was both filled and stroked caused an error. +(gs_pdf.ps) + +[3.61] Speeds up the initial processing of PDF files by caching the map from +page numbers to page objects, and by not scanning the outlines if we aren't +producing PostScript output. (pdf_2ps.ps, pdf_base.ps, pdf_main.ps) + +Streams +------- + +Fixes bugs: + [3.60] When closing an encoding filter stream whose target was also +a filter, the latter could get called incorrectly with last = 1, possibly +more than once, leading to premature EOD markers. (stream.c) + [3.60] The LZW-compatible encoder put out an incorrect end-of-data +code. (slzwce.c) + [3.60] The LZW-compatible encoder didn't put out a reset code soon +enough. (slzwce.c) + [3.60] Doing a sgets on a closed stream could call sreadbuf, +possibly causing an error. (stream.c) + +Library +------- + +Fixes bugs: + [3.63] On 16-bit platforms, the computation of t2 and t3 in +gx_curve_x_at_y could overflow, leading to incorrect output. (gxpcopy.c) + [3.61] glyphshow displayed a character with code 0 rather than the +requested character (bug introduced in 3.60.) (gschar.c) + [3.61] If trimming white space around a character reduced its +raster, the character was garbled in the cache (bug introduced in 3.60.) +(gxccman.c) + [3.61] colorimage would incorrectly convert white pixels to black if +the image color space was CMYK, the current color space was not CMYK, and +the number of bits per pixel was 4 or 8. (gsimage2.c) + [3.61] Type 1 fonts that used the Flex feature applied hints to the +path multiple times, causing dropouts, uneven stems, and other problems (bug +probably introduced in 3.21). (gstype1.c) + [3.61] If a Type 1 font used the Flex feature within the accent of +an accented character defined with seac, the shape of the accent could be +distorted. (gxtype1.h, gstype1.c) + [3.61] If a Type 1 font changed hints using the hint replacement +facility when the last operation was a closepath, the old hints would be +applied a second time, distorting the shape. (gxhint2.c, gxhint3.c) + [3.60] Cached characters sometimes had extra blank space on the +left, leading to some unnecessary bit-shuffling when imaging them. +(gxccman.c) + [3.60] The list of all-bands commands wasn't initialized/reset +properly. (gxclist.c) + [3.60] Because of a typo in a macro formal parameter list, a private +name was duplicated. (gsstruct.h) + [3.60] Text display operations didn't update the current character +in the enumerator structure during the fastest path through the code. This +only matters to one very unusual commercial client. (gschar.c) + +[3.61] Adds an alternative implementation of the core path filling algorithm +that is much faster on objects with curves but doesn't handle Y fattening. +This is the implementation that will normally be used for rasterizing +characters. This implementation rasterizes curves directly, without +flattening them. (gxfixed.h, gxpath.h, gzpath.h, gxdraw.c, gxfill.c, +gxpcopy.c) + +[3.61] Speeds up the flattening of curves substantially by omitting more +redundant points. (gxpcopy.c) + +[3.61] Speeds up character bitmap compression a little more. (gsbitops.h, +gdevabuf.c, gsbitops.c, gxccman.c) + +[3.61] Speeds up anti-aliased graphics a bit by computing a bounding box +before converting from oversampling to alpha values, and by speeding up the +bounding box computation itself. (gsbitops.h, gdevabuf.c, gsbitops.c, +gxccman.c) + +[3.60] Speeds up getting the side bearing and width of a Type 1 charstring a +little. (gxtype1.h, gstype1.c) + +[3.60] Adds a compile-time option, ALPHA_LSB_FIRST, which causes +alpha-sampled characters to be nibble-reversed in the cache. This was +created for a specialized application and does not interact well with the +rest of the code. (gsbitops.c) + +[3.60] Substantially speeds up entering anti-aliased characters in the +cache, by removing white space before compressing rather than vice versa. +(gsbitops.c, gxccman.c) + +Version 3.52(limited) (10/6/95) +===================== + +This is an incremental release to fix a few problems in 3.51. Since it is +being made in an environment with no network connectivity, it will probably +not be released to the general public. ****** THE CHANGES MARKED WITH *** +BELOW WERE LOST IN THE PROCESS OF SHUFFLING FILESETS BETWEEN ENVIRONMENTS. +THEY ARE INCORPORATED IN 3.60 BUT NOT IN 3.52. ****** + +Procedures +---------- + +Fixes bugs: + - The fileset included a meaningless empty file. (acctest.ps) + *** The definition of pdfread.dev did an ADDMOD, not a SETMOD. +(int.mak) + +Interpreter +----------- + +Fixes bugs: + - The RunLengthEncode filter used with a dictionary argument could +give a spurious error. (zfilter.c) + - The fast form of the 'dup' operator failed to check for stack +overflow, which could lead to memory smashing. (interp.c) + *** Level 1 configurations gave errors during initialization. +(ialloc.c, iinit.c, ireclaim.c) + *** Attempting to look up or insert a noaccess string as a +dictionary key converted the string to a name rather than giving an error. +(idict.h, idict.c) + +Adds a C implementation of the .dicttomark (>>) procedure. (gs_init.ps, +zdict.c) + +*** Implements parts of the Type 1 BuildChar callout in C. (gs_type1.ps, +ifont.h, zchar.c, zfont1.c, zfont2.c) + +Library +------- + +Fixes bugs: + - Braces were missing in an initializer. (gxdcolor.h) + - Composite fonts with a non-zero translation in the FontMatrix +positioned characters incorrectly. (gschar.c) + *** gsparam.c wouldn't compile with some versions of the Borland +compiler. (gsparam.c) + +Speeds up the handling of curve segments in Type 1 fonts a little. +(gstype1.c) + +Speeds up displaying very short strings a little. (gschar.c) + +*** Implements parts of the Type 1 BuildChar callout in C. (gxfont.h) + +Version 3.51 (9/27/95) +============ + +This is the first public release since 3.33. Its main features are a +working setpagedevice, a working PDF interpreter, and a working PDF to PS +converter. + +Documentation +------------- + +Fixes bugs: + - The -dSHORTERRORS switch wasn't documented in enough places. +(current.doc, use.doc) + - The DLL documentation was internally inconsistent. (dll.doc) + - The %pipe% file name syntax wasn't documented. (language.doc) + +Procedures +---------- + +Fixes bugs: + - caption.ps wasn't installed properly. (unix-end.mak) + - geninit depended on $(gconfig_h) in an improper way. (geninit.c, +int.mak, *.mak) + - One script lacked the #!/bin/sh header. (gsdj500) + +Adds the 24-bit color TIFF driver to all configurations that support +black-and-white TIFF. (*.mak) + +Utilities +--------- + +Fixes bugs: + - align.ps was omitted from the fileset. (psfiles.doc, align.ps, +unix-end.mak) + +Drivers +------- + +Fixes bugs: + - A driver had some \s in formal parameter lists. (gdevcdj.c) + - A driver had some improper &s. (gdevtifs.c) + - The default MS Windows printer driver was very slow. (gdevwpr2.c) + - The (newly restructured) TIFF drivers could produce a memory +access error. (gdevtifs.c) + - The CGM drivers referred to an obsolete structure member. +(gdevcgm.c) + - The black-and-white H-P drivers didn't set the margins properly +(again). (gdevdjet.c) + - Several of the most common printer drivers omitted some scan lines +at the bottom of the page. (gdevprn.h, gdevprn.c) + +At the request of the main OS/2 developer, adds a printer device for OS/2. +(gdevos2p.c, os2.mak) + +Makes many changes to the stcolor driver, submitted by the developer just +before the release. (devices.doc, unix-end.mak, gdevstc.h, gdevstc*.c, +stcinfo.ps, stcolor.ps, stcinfo.ps) + +Platforms +--------- + +Fixes bugs: + - usertime (and realtime) were broken on VMS. (gp_vms.c) + - The 32-bit MS Windows DLL control file had a typo. (gsdll32.def) + +Removes the color inkjet drivers from the 16-bit Windows executable, because +they overflow the 64K default data segment; adds PCX, TIFF, and BMP output +formats. (bcwin.mak) + +Interpreter +----------- + +Fixes bugs: + - A routine was declared 'private' inconsistently. (zcie.c) + - -dSHORTERRORS didn't remove enough non-Adobe error output. +(gs_init.ps) + +Interpreter (PDF) +----------------- + +Fixes bugs: + - The ProcSet relied on the presence of NullFont. (gs_pdf.ps) + +Library +------- + +Fixes bugs: + - There was an extraneous \ outside a macro. (gsline.c) + - Scaling up a black-and-white image could caused many scan lines to +be inverted. (gsimage1.c) + - The initial clipping path did not take Margins into account +properly. (gxdevice.h, gdevxalt.c, gscoord.c, gsdevice.c, gsdevmem.c, +gsdparam.c, gspath.c) + - If banding was required, characters could come out as solid black +rectangles. (gxclist.c, gxclread.c) + +Version 3.50(limited) (9/24/95) +===================== + +This is the last limited bug-fix release during beta test. The color +DeskJet drivers are broken (they sometimes produce black rectangles instead +of characters); we will fix this in the next release. + +The following issues have been postponed to an unspecified future release: + - Filling areas often writes pixels twice, causing incorrect output +with certain unusual RasterOp values. [1.814] + - The tar.gz archives should include a subdirectory like gs-3.46/ in +the file names. + - The CCITTFaxDecode filter should skip initial junk if EndOfLine = +true. [1844 8/24/95, NRE] + +Procedures +---------- + +Fixes bugs: + - The name of the new 24-bit TIFF driver was incorrect in one place. +(vms.mak) + +Utilities +--------- + +Adds a new utility to put a caption in a box at the bottom of each page. +(caption.ps) + +Drivers +------- + +Fixes bugs: + - The PC display devices weren't page devices. Probably all the +other display and window system devices should be made page devices too, but +we aren't going to bother tracking them down. (gdevpcfb.c) + - There was a lot of duplicated code in the TIFF drivers. +(gdevtifs.h, gdevtfax.c, gdevtfnx.c, gdevtifs.c) + +Updates the bjc600 / bjc800 drivers with changes from the author. +(devices.doc, gdevbjc.h, gdevcdj.c) + +Interpreter +----------- + +Fixes bugs: + - Building with COMPILE_INITS=1 produced a stackunderflow error. +(gs_pdf_e.ps) + - An internal operator didn't have a name. (ztoken.c) + - Some error and information messages weren't in the Adobe format. +(gs_fonts.ps, gs_init.ps) + - Some common Adobe compatibility operators weren't implemented: +pagemargin, pageparams, setpagemargin. (gs_statd.ps, gs_lev2.ps) + - setpageparams set Margins rather than PageOffset. (gs_lev2.ps) + - setpage and setpageparams didn't set Orientation. (gs_lev2.ps) + - If the end of an input buffer fell just after the / of a literal +name, a memory access error could occur. (iscan.c) + - When the interpreter returned from gs_[main_]run_string_continue, +there could be an extra value on the operand stack. (iscan.h, istream.h, +interp.c, iscan.c, zfileio.c, zfproc.c, zpaint.c, ztoken.c) + - If the character cache was disabled, or if a character was too +large to be cached, returning from a font BuildChar procedure could do an +erasepage. (zchar.c) + +A minor change was required for compatibility with the library change for +image devices. (zdevice.c) + +Adds a -dSHORTERRORS switch that changes some of the common error and +warning messages for greater Adobe compatibility. (gs_init.ps, gs_fonts.ps) + +Interpreter (PDF) +----------------- + +Fixes bugs: + - If a CharProc for a Type 3 font did a BT/ET, the graphics state +could get confused. (gs_pdf.ps) + - If a Tf occurred inside a BT/ET, it didn't take effect on +subsequent BT/ETs. (gs_pdf.ps) + +Library +------- + +Fixes bugs: + - There was no way to control whether an image device was a page +device. Fixing this required a NON-BACKWARD-COMPATIBLE CHANGE to +gs_makewordimagedevice and gs_initialize_wordimagedevice to take a Boolean +page_device argument. Fortunately, this change affects only a few obscure +library clients. (gsdevice.h, gsdevmem.c) + +Adds translation capability to clipping devices. This isn't used anywhere +yet. (gxcpath.h, gxcpath.c) + +Adds procedures for doing unaligned copy_xxx operations. These were added +for a customer. (gxdevice.h, gsdevice.c) + +Changes the (undocumented) return value of gs_setcachedevice[2]: they used +to return 1 if the current show operation was a non-displaying one +(stringwidth or cshow), and now return 1 if the cache device was just +installed. This change was required to fix the BuildChar page clearing bug +in the interpreter. THIS IS A NON-BACKWARD-COMPATIBLE CHANGE, but as far as +I know, there aren't any external clients of these routines. (gschar.h, +gschar.c) + +Version 3.49(limited) (9/20/95) +===================== + +This is another bug-fix release during beta test. There are other bugs +outstanding, but the ones I know about right now are all platform-specific. + +Documentation +------------- + +Fixes bugs: + - make.doc didn't mention that the .def files are needed to build a +MS Windows executable. (make.doc) + +Procedures +---------- + +Fixes bugs: + - There were some forward references to macro definitions in the +makefiles. (int.mak, lib.mak) + - The default device for library configurations was the null page +device, not the first device in DEVICE_DEVS. (ugcclib.mak) + +Drivers +------- + +Fixes bugs: + - The BJC600 / BJC800 drivers were missing a header file. +(gdevbjc.h, gdevcdj.c) + - A procedure name was used in two different files. (gdevcdj.c) + - The PCX driver didn't return an error code in case of failure. +(gdevpcx.c) + - The X Windows driver produced some confusing warning messages. +(gdevxini.c) + - Some names were duplicated between drivers. (gdevepsc.c) + - The X driver maintained its own, peculiar initial matrix even if +Ghostview wasn't involved. (gdevx.c) + +With the permission of the author, changes the 24-bit TIFF license from GNU +to Aladdin. (gdevtfnx.c) + +Platforms +--------- + +Fixes bugs: + - The VMS build scripts were out of sync with the makefiles (again). +(modules.lis, vms.mak) + +Interpreter +----------- + +Fixes bugs: + - When the requested media size matched an available size exactly +with a 90 degree rotation, Orientation was ignored. (zmedia2.c) + +Makes zcurrentdevice extern. (opextern.h, zdevice.c) + +Library +------- + +Fixes bugs: + - A couple of places used memcpy instead of memmove. (gxclread.c) + - If a bitmap image was compressed with RLE compression in a band +list, it would cause an error on decompression. (gxclread.c) + - The representation of colors in the band list was needlessly +inefficient. (gxcldev.h, gxclist.c, gxclread.c) + - When using colored halftones, snowflak.ps crashed with an invalid +memory access. More generally, any use of halftones could cause the garbage +collector to make an invalid access. (gsstate.c) + +Adds some more code for paths in band lists, but again doesn't activate it. +(gxcldev.h, gxpath.h, gzline.h, gsline.c, gspath1.c, gxclist.c, gxclread.c, +gxpath.c) + +Version 3.48(limited) (9/17/95) +===================== + +This is the second bug-fix release during beta test. Among other things, it +fixes a bug introduced in 3.47 that caused all PDF files to give an error. +******NOTE: the BJC600 and BCJ800 drivers do not work in this release, +because we didn't get a file from the author in time. They will compile, +but not run. This will be fixed in the next round. + +Documentation +------------- + +Fixes bugs: + - Alan Barclay's contact information was wrong. (README) + +Procedures +---------- + +Fixes bugs: + - The linker path for Watcom C++ 10.5 was wrong. (wccommon.mak) + - There was a syntax error in a batch file. (pdf2ps.bat) + - The VMS build script didn't have entries for some printers. +(vms.mak) + +Adds the bjc600 and bjc800 devices on all platforms that already include the +color DeskJet devices. (*.mak) + +Drivers +------- + +Fixes bugs: + - The H-P drivers didn't reposition the cursor properly at the +beginning of pages after the first page, causing the image to be shifted +down slightly and cut off at the bottom. (gdevdjet.c) + - The x11alpha driver was extremely slow. (gdevxalt.c) + - The -g switch by itself didn't work for the X Windows driver. +(gdevxini.c) + - .installpagedevice can get a rangecheck on MS Windows because the +HWColorMap can change spontaneously. (gs_setpd.ps) + +Updates the bjc600 and bjc800 drivers with new versions from Yves Arrouye. +(gdevcdj.c) + +Adds a user-contributed driver that writes uncompressed 24-bit RGB TIFF +images in a format that is standard on NeXT platforms. This driver is +governed by the GNU license and is therefore separated from the rest of the +Aladdin distribution. (gdevtfnx.c) + +Platforms +--------- + +Fixes bugs: + - There was an undefined reference to clock_gettime on some Unix +systems. (gp_unix.c) + - The new gp_fopen routine had several errors. (gp_vms.c) + +Interpreter +----------- + +Fixes bugs: + - Some routines that should be main-instance-specific weren't. +(imain.h, main.h, gsmain.c) + - sethalftone with a Type 2 or Type 4 halftone didn't work on CMYK +devices. (zht2.c) + - Setting A4 paper as the default in gs_init.ps, or specifying +-dPAPERSIZE, conflicted with -g. (gs_init.ps) + - The maximum value of a single-precision float wasn't correct on +VAX systems. (math_.h, iscannum.c) + - Some integer expressions were passed as floating point arguments. +(gs.c, zmedia2.c) + - Media selection in setpagedevice was broken (again), as of 3.46. +(gs_setpd.ps, zmedia2.c) + +Interpreter (PDF) +----------------- + +Fixes bugs: + - Substituted color spaces caused an error. (gs_pdf.ps, +pdf_draw.ps) + +Library +------- + +Fixes bugs: + - If a halftone had no non-default components that matched the +device's primary colors, the result would be a solid color rather than a +halftone using the default screen. (gsht.c) + - sethalftone with a Type 2 or Type 4 halftone didn't work on CMYK +devices. (gxht.h, gsht.c, gsht1.c) + - The new gp_fopen routine wasn't being used. (gsiodev.c) + - A mixing of float and fixed values caused a clipping region to be +possibly incorrect by up to 1 pixel. (gspaint.c) + - A function definition was inconsistent with the prototype. +(gspath1.c) + +Adds preliminary code for including paths in band lists, but doesn't +activate any of it. (lib.mak, gxcldev.h, gxclist.c, gxclread.c) + +Version 3.47(limited) (9/14/95) +===================== + +This is a bug-fix release during beta test. It is meant to have no new +functionality, although in the case of setpagedevice that's stretching +things a little. + +Documentation +------------- + +Fixes bugs: + - The Mac documentation still referred to IJG JPEG v5a rather than +v6. (make.doc) + - The RasterOp texture device was identified incorrectly. +(gdevmrop.c) + - use.doc and psfiles.doc didn't mention the PDF-related files. +(psfiles.doc, use.doc) + - psview is no longer available. (README) + - current.doc didn't document the recognized setpagedevice keys. +(current.doc) + +Procedures +---------- + +Fixes bugs: + - Many utility programs weren't included in the Unix 'install' list. +(unix-end.mak) + - It wasn't at all convenient to make configurations without the BCP +or other non-standard filters. (*.mak, int.mak, modules.lis, zfilter2.c, +zfilterx.c) + - The gconfig.c and iconfig.c files weren't deleted after +compilation. (int.mak, lib.mak) + - unix-end.mak referred to the nonexistent macros INT{1,2}_MAK. +(unix-end.mak) + - The rules for building the dfax drivers were incorrect. (devs.mak) + - Omitting filter.dev produced an undefined reference. (int.mak) + +Adds a customer-contributed makefile for Microsoft Visual C++ 2.n under +Windows NT. (msvcwint.mak) + +Utilities +--------- + +Fixes bugs: + - The JPEG utility didn't support the new progressive JPEG modes, +and didn't invert Adobe Photoshop output as needed. (viewjpeg.ps) + - The printafm utility had a single font name wired in. (printafm, +printafm.ps) + - The CIE lookup simulation had several bugs. (docie.ps) + - pdf2ps[.bat] were missing from the fileset. + - Files produced by pdf_2ps didn't include the GS_PDF ProcSet. +(gs_pdf.ps, pdf_2ps.ps, pdf_base.ps, pdf_main.ps) + +Drivers +------- + +Fixes bugs: + - Bits read back from an EGA or VGA device were incorrect. +(gdevpcfb.c) + - The 24-bit PCX run length compressor used a slow algorithm. +(gdevpcx.c) + - gdevstc.c wouldn't compile with the Borland compiler. (gdevstc.c) + - There was a typo in the OS/2 PM driver. (gdevpm.c) + - .installpagedevice gets a rangecheck on X Windows because the +HWColorMap can change spontaneously. (gs_setpd.ps) + - The left margin for the DeskJet 500 was wrong. (gdevdjet.c) + - The two notions of "margin" (offset of 0,0 from physical page +corner vs. unprintable area around edges of physical page) were still +confused. We've now fixed this for the H-P monochrome printers, but it's +probably still confused for all other printers. (gdevprn.h, gdevdjet.c) + +Platforms +--------- + +Fixes bugs: + - The Windows print spooler header file wasn't included when it +needed to be, and some other Win32-specific changes were missing. +(gsdll32.def, gp_mswin.c) + - Windows DLLs didn't parse "s in the command "arguments" correctly. +(gsdll.c) + +Fonts +----- + +Fixes bugs: + - FAKEFONTS could get the font directories into inconsistent states. +(gs_dps1.ps, gs_fonts.ps) + - The substitutions for Adobe's Myriad and Minion fonts weren't +appropriate. (gs_fonts.ps) + +Interpreter +----------- + +Fixes bugs: + - If pathforall got an error computing the user-space points on a +path, it could cause an invalid access. (zpath1.c) + - A 'private' declaration were omitted. (Why doesn't gcc catch +this??) (zcie.c) + - Setting GS_FONTPATH produced a stackunderflow error. +(gs_fonts.ps) + - currentscreen caused a typecheck if the screen had been set by +setcolorscreen. (gs_dps1.ps) + - setcolorrendering tried to cache values computed from the color +space even if the current color space wasn't a CIE space. (zcrd.c) + - Out-of-range numbers like 10E38 caused a floating point exception. +(iscannum.c) + - Giving a closed readable file as input for a filter caused an +invalidaccess. (files.h, interp.c, zfilter.c) + - setpagedevice opened the default device even with -dNODISPLAY. +(gs_init.ps, gs_setpd.ps) + - realtime returned the same value as usertime. (gs_lev2.ps, +zmisc.c) + - Storing a local value into systemdict caused some redundant code +to be executed. (zdict.c) + - Files with a very long first line could cause a rangecheck error. +(gs_init.ps) + - The PageOffset page device parameter was ignored. (gs_setpd.ps) + - The Orientation page device parameter wasn't handled properly. +(gs_setpd.ps, idparam.h, idparam.c, zmedia2.c) + - setpagedevice could set device parameters twice, with an +incomplete update the first time. (gs_setpd.ps) + +Interpreter (PDF) +----------------- + +Fixes bugs: + - Readers confused the internal pdfrun procedure with the public +runpdf procedure. (pdf_*.ps) + +Streams +------- + +Fixes bugs: + - Closed streams had a NULL state pointer, causing problems for some +clients. (stream.c) + - Group 4 decoding could get an ioerror if an end-of-buffer occurred +in a horizontal code sequence between a makeup code and the termination +code. (scfd.c) + +Library +------- + +Fixes bugs: + - Some 'private' declarations were omitted. (Why doesn't gcc catch +these??) (gdevmrop.c, gxht.c) + - Patterns could produce bad output in the band list. (gxclist.c) + - RasterOp wasn't implemented at all for 2- or 4-bit devices. (In +this release, we implement only a subset, and without handling transparency +properly.) (gdevm2.c, gdevm4.c, gdevmrop.c) + - Drawing operations and text sometimes didn't apply the RasterOp +when they should, and vice versa. (gxdcolor.h, gxdraw.c) + - setcolorrendering tried to cache values computed from the color +space even if the current color space wasn't a CIE space. (gscie.h, +gscie.c) + - Some CIE color spaces produced very distorted colors. (gscie.c) + - setpagedevice opened a window even with -dNODISPLAY. (gsdevice.c, +gsdparam.c) + - realtime returned the same value as usertime. (gp.h, time_.h, +gp_*.c) + - The library level attempted to handle the Orientation page device +parameter. (gxdevice.h, gdevbit.c, gsdevice.c, gsdparam.c, gspath.c) + - Severely non-linear CIE encoding/decoding functions produced +seriously skewed colors near the ends of the color value range. This +problem can now be alleviated, at a significant cost in performance, by +changing configuration parameters at the beginning of gscie.h. (gscie.h, +gscie.c) + - Files FTP'ed in binary mode weren't being opened properly on VMS. +(gp.h, gp_*.c, gsiodev.c) + - A header file had an inconsistent declaration. (math_.h) + +Adds a new gp_get_usertime procedure to gp.h. THIS IS A +NON-BACKWARD-COMPATIBLE CHANGE, affecting only platform implementors. It +was necessary to fix the realtime/usertime bug. (gp.h, time_.h, gp_*.c) + +Adds a new gp_fopen procedure to gp.h. THIS IS A NON-BACKWARD-COMPATIBLE +CHANGE, affecting only platform implementors. It was necessary to fix the +binary file problem on VMS. (gp.h, gp_*.c) + +Version 3.46(limited) (9/4/95) +===================== + +This is the "serious beta test" release for the next public release. It +finishes implementing RasterOp in the graphics state, and the remaining +commonly used parts of setpagedevice. + +Documentation +------------- + +Documents some possible problems when building with DJGPP v2.0-beta. +(make.doc) + +Adds documentation on using Ghostscript as a PDF interpreter. (use.doc) + +Notes linking problems with the Watcom 10.0 environment. (make.doc) + +Procedures +---------- + +Fixes bugs: + - The rule for $(ccfonts).dev was wrong. (gs.mak) + +Makes some additional filters into 'features'. (devs.mak, gs.mak) + +Splits off 2 new makefiles from gs.mak, which had gotten very large: lib.mak +(graphics library) and int.mak (interpreters). (tar_cat, tar_cat.bat, +*.mak) + +Adds a new 'config-clean' target that may be helpful in changing +configuration definitions. (gs.mak) + +Notes in the relevant makefiles that on Unix and DVX systems, one should not +edit 'makefile' or the concatenated makefile, but should edit the individual +subfile and run tar_cat. (ansihead.mak, cc-head.mak, dgc-head.mak, +gcc-head.mak, devs.mak) + +Updates the Watcom makefiles to handle Watcom release 10.5, in which many +executables moved to different directories. (watc.mak, watcwin.mak, +wccommon.mak) + +Adds a pdf2ps shell script. (pdf2ps, pdf2ps.bat) + +Adds a -sFONTMAP= switch to specify the name of the Fontmap file. +(gs_fonts.ps) + +Adds a -u switch to undefine a name from systemdict. (interp.h, gs.c, +iinit.c) + +Adds a -dFIXEDRESOLUTION switch to parallel -dFIXEDMEDIA. Makes -g set +FIXEDMEDIA and -r set FIXEDRESOLUTION. (gs_init.ps, gs_setpd.ps, gs.c) + +Changes some build procedures to avoid problems with read-only source files. +(gs.mak, int.mak, lib.mak) + +Utilities +--------- + +Adds a utility for emulating the CIE color mapping algorithms. (docie.ps) + +Drivers +------- + +Changes the x11alpha device so that it uses 32-bit pixels with 8 bits of +alpha. (gdevxalt.c) + +Updates the Epson Stylus Color driver to Gunther Hess's release 1.17. +(devs.mak, unix-end.mak, devices.doc, stcolor.ps, gdevstc.h, gdevstc*.c) + +Updates the alternate X drivers for the change from PageSize to MediaSize. +(gdevxalt.c) + +Makes Duplex an optional parameter of printer devices rather than of all +devices. (gdevprn.h, gxdevice.h, gsdparam.c, gdevdjet.c, gdevprn.c) + +Platforms +--------- + +Makes pipes (%pipe% file syntax) a selectable option on Unix platforms, +rather than always being included. (ansihead.mak, cc-head.mak, +gcc-head.mak, ugcclib.mak, unixtail.mak) + +Interpreter +----------- + +Fixes bugs: + - colorimage, and the dictionary form of image with +MultipleDataSources = true, didn't check that all the data sources were of +the same type. (zpaint.c) + - colorimage, and dictionary-type images with MultipleDataSources = +true, usually didn't work properly with files. (zpaint.c) + - grestoreall left a dangling pointer to the transfer function +cache. (gsstate.c) + - Changes made by setpagedevice could get 'lost' and not installed +in the current page device dictionary. (gs_setpd.ps) + - The Install procedure was called before the new page device +dictionary had gotten installed. (gs_setpd.ps) + - If a grestore/grestoreall/restore/setgstate operation switched +page devices, the new page device didn't get installed properly. +(gs_setpd.ps, opextern.h, zdevice2.c, zdps1.c) + - If the current screen was a Type 1 halftone, currentscreen and +currentcolorscreen returned frequency = 60, angle = 0 rather than the +Frequency and Angle from the halftone (see Adobe TN 5085). (gs_dps1.ps, +gs_init.ps) + - setscreen with a Type 1 halftone dictionary didn't insert the +frequency and angle into the dictionary (see Adobe TN 5085). (gs_dps1.ps) + - upath didn't include a trailing moveto in the bounding box. +(gs_dps1.ps, zpath1.c) + - setpagedevice didn't automatically rotate or scale the image when +necessary. (gs_setpd.ps, zmedia2.c) + +Moves the RasterOp operators to a separate file. (iutil.h, iutil.c, +zgstate.c, zrop.c) + +Eliminates the unnecessary "wrapper" around .setdevice. (zdevice2.c) + +Establishes the convention that all interpreter callbacks into PostScript +code use procedure names that begin with %; documents this in gs_init.ps. +Changes Type1BuildChar and Type1BuildGlyph to %Type1BuildChar and +%Type1BuildGlyph. (gs_init.ps, gs_type1.ps, zfont0.c, zfont1.c) + +Changes image / imagemask / colorimage for the new library API. (zimage2.c, +zpaint.c) + +Reorganizes font loading to make compiled fonts and Fontmap interact better +with each other. (gs_ccfnt.ps, gs_fonts.ps, gs_init.ps, gs_res.ps) + +Implements parameter collection for the new CIEBasedDEF[G] color spaces, but +doesn't actually implement the color spaces themselves. (icie.h, zcie.c, +zcrd.c) + +Renames iconfig.c as iconf.c to avoid problems with read-only source files. +(iconf.c) + +Interpreter (PDF) +----------------- + +Fixes bugs: + - PDF to PostScript conversion didn't work. (pdf_main.ps) + +Shifts most of the work in the PDF interpreter from the reader to the +ProcSet. This simplifies the code considerably and also makes it easier to +modify. (gs_pdf.ps, pdf_draw.ps, pdf_font.ps, pdf_main.ps) + +Library +------- + +Fixes bugs: + - 'static' was omitted in a place that some compilers require it. +(gxccman.c) + - Some compilers don't allow a variable with the same name as a +preprocessor macro with arguments. (gscie.c) + - Some places did a "return -1" rather than a proper error return. +(gsdevice.c, gxclist.c) + - An external declaration had a typo. (gsrop.h) + - An extra semicolon upset some compilers. (gzpath.h) + - Printer devices that didn't use the standard macros for generating +their procedure vector wound up being considered as non-page devices. +(gdevprn.c) + - Some compilers truncated identifiers longer than 31 characters. +(gscspace.h, zcie.c, gscie.c) + - upath didn't include a trailing moveto in the bounding box. +(gspath.h, gspath1.c) + - RasterOp value 126 returned an incorrect result. (gsroptab.c) + +Finishes implementing RasterOp in the graphics state. (gdevmrop.h, gsrop.h, +gsropt.h, gsstate.h, gxbitmap.h, gxcindex.h, gxdcolor.h, gxdevice.h, +gzstate.h, gdevmrop.c, gscolor.c, gsdevice.c, gsimage.c, gsimage1.c, +gsimage2.c, gsimage3.c, gspcolor.c, gsrop.c, gsstate.c, gxacpath.c, +gxccache.c, gxcht.c, gxcmap.c, gxdither.c, gxdraw.c, gxht.c) + +Changes forwarding devices so they forward get_bits by default. This +probably doesn't affect any existing code. (gxdevice.h, gsdevice.c) + +Changes the API for gs_image[mask]_init to pass a structure rather than a +very large number of scalars. THIS IS A NON-BACKWARD-COMPATIBLE CHANGE, +motivated by the addition of further image parameters to support RasterOp. +Since there are no external clients of the library yet, it shouldn't matter. +(gsimage.h, gsimage.c, gslib.c, gxccache.c) + +Redefines the device "page size" as being the size of the actual media, +changing the name of the gx_device PageSize member to MediaSize, the name of +the PageSize device parameter to .MediaSize (but keeping PageSize as +equivalent, for backward compatibility), and the name of the +gx_device_set_page_size procedure to gx_device_set_media_size (keeping the +old name as a macro). THIS IS A NON-BACKWARD-COMPATIBLE CHANGE. It is +necessary to make setpagedevice work, and to avoid confusion about what +"page size" means. It potentially affects any device driver, but almost +none of the device drivers distributed with Ghostscript are affected, and +those have been updated. (gsparam.h, gxdevice.h, gsdevice.c, gsdparam.c, +gspath.c) + +Renames gconfig.c as gconf.c to avoid problems with read-only source files. +(gconf.c) + +Adds an API procedure for setting a bitmap pattern. (gscolor2.h, +gspcolor.c) + +Version 3.45(limited) (8/27/95) +===================== + +The purpose of this release is to fix some minor bugs reported by commercial +licensees, and to add two enhancements: optional RenderTable interpolation +for CIE color, and reducing the temporary space used during character +caching (also for a licensee). + +Documentation +------------- + +Notes that the only valid return values from get_alpha_bits are 1, 2, and 4. +(drivers.doc) + +Notes that the get_bits driver procedure will return a pointer to aligned +data, but does not require the caller's data area to be aligned. +(drivers.doc) + +Procedures +---------- + +Fixes bugs: + - Many of the printer and file output drivers in devs.mak still +included gdevprn.$(OBJ) in their dependencies. (devs.mak) + - PDEVH was used before it was defined. (devs.mak) + - GENCONF_XE was used before it was defined. (unixhead.mak, +unix-end.mak) + +Makes it possible to switch sfile implementations without editing gs.mak. +(gs.mak) + +Makes it possible to specify alternate compiled font tables without editing +gs.mak. (gs.mak) + +Allows quoted arguments in @-files, e.g., + -sOutputFile="a file name with spaces" +(gs.c) + +Utilities +--------- + +Fixes bugs: + - The ps2ascii script could fail to delete temporary files in case +of an abnormal exit. (ps2ascii) + +Drivers +------- + +Fixes bugs: + - The MS Windows printer capability test was wrong. (gdevwpr2.c) + - The MS Windows and OS/2/PM displays weren't page devices. +(gdevwdib.c, gdevpm.c) + +Gets rid of all direct references to dev->PageSize in drivers. (gdevl256.c, +gdevvglb.c) + +Platforms +--------- + +Fixes bugs: + - The 32-bit MS Windows configuration file for the Borland C++ +compiler was missing from the fileset. (bcc32.cfg, tar_gs) + +Makes the printer devices in the OS/2 implementation capable of outputting +directly to the print spooler. (use.doc, gp_os2.c) + +Makes printing on Windows NT and Windows 95 use the printer queue. +(gp_mswin.c, gswin32.rc) + +Interpreter +----------- + +Fixes bugs: + - Copying a null device produced an uninitialized pointer. +(gsdevice.c) + - The dictionary returned by deviceinfo wasn't read-only. +(gs_lev2.ps) + - If a filter's init code failed, an entry on the operand stack +(usually the top) could be smashed. (files.h, zfile.c, zfilter.c) + +Adds const in a few places that needed it. (zwppm.c) + +Adds interpolation to the CIE RenderTable lookup. (icie.h, zcie.c, zcrd.c) + +Interpreter (PDF) +----------------- + +Allows PDF files with control-character garbage at the end, and up to 250 +characters of garbage at the beginning. The latter is only supported by +runpdf, not by run. (pdf_base.ps, pdf_main.ps) + +Streams +------- + +Fixes bugs: + - A 1-D CCITTFaxDecode stream could give an error if an input buffer +boundary fell just before a 0-length termination code. (scfx.h, scfd.c) + +Library +------- + +Fixes bugs: + - A variable was used before being set, which could cause band +devices to become confused when processing colored halftones. (gxclist.c) + - Some of the color and tile bookkeeping for band lists was wrong +(as of 3.44), causing tiled areas to be filled with garbage. (gxclist.c, +gxclread.c) + - Colored Patterns showed up blank on devices whose native +representation of `black' was a non-zero value. The fix removes the +'cached' member of the gx_device structure, and requires monobit memory +devices to have a palette; this is a NON-BACKWARD-COMPATIBLE CHANGE for +anyone who was foolish enough to statically initialize a gx_device structure +without using the macros in gxdevice.h or gdevprn.h. (gdevmem.h, +gxdevice.h, gxdevmem.h, gdevm1.c, gdevmrop.c, gsdevice.c, gxcpath.c, +gxdither.c) + +Provides the framework for band devices to implement alpha (anti-aliasing). +(gxcldev.h, gdevprn.c, gsdevice.c, gxclist.c, gxclread.c) + +Implements an efficient API for enumerating paths using device coordinates. +(gspath.h, gxpath.h, gzpath.h, gspath1.c, gxpath2.c) + +Changes the character cache logic so that when rasterizing large +anti-aliased characters, it converts the oversampled bits to alpha values on +the fly rather than waiting until it has rasterized the entire character. +This saves a lot of temporary space, at the expense of some extra time and +lower quality results for Type 3 characters that don't use a single fill or +imagemask operation to draw the character. This enhancement requires adding +a member to the gx_device structure (max_fill_band), which is a +NON-BACKWARD-COMPATIBLE CHANGE for badly written drivers (see above). +(gxchar.h, gxdevice.h, gxpaint.h, gdevabuf.c, gschar.c, gspaint.c, +gxccache.c, gxccman.c, gxfill.c) + +Changes the palette member of memory devices from gs_string to +gs_const_string. (gdevmem.h, gxdevmem.h, gdevmem.c, gdevm1.c) + +Starts to decouple halftoning from the graphics state machinery, so +it can be applied after banding rather than before. (gxdcolor.h, +gxdht.h, gxdither.h, gzht.h, gxcmap.c, gxdither.c, gxdraw.c) + +Starts to decouple path filling from the graphics state machinery, so +that we can pass paths through band lists. (gxpaint.h, gxfill.c) + +Adds interpolation to the CIE RenderTable lookup. This is optional, enabled +by #define CIE_RENDER_TABLE_INTERPOLATE in gscie.h. (gscie.h, gxctable.h, +gscie.c, gxctable.c) + +Version 3.44(limited) (8/21/95) +===================== + +This includes a few bug fixes, but its main purpose is to add two new +features: monobit and 8-bit gray-scale RasterOp (at the driver level, not at +the gstate level yet), and (compressed) band lists in RAM. Of course, these +new features may have introduced new bugs! + +Documentation +------------- + +Adds contact information for a user working on NeXT machines. (README) + +Notes that Ghostscript runs on FreeBSD. (README) + +Adds copy_rop (the RasterOp operation) to the driver interface. +(drivers.doc) + +Adds FONTPATH information for more operating systems. (use.doc) + +Procedures +---------- + +Fixes bugs: + - The tar_cat script needed a #!/bin/sh to execute correctly on all +platforms. (tar_cat) + - There were a number of minor errors in the makefiles. (gs.mak, +unixhead.mak) + - Level 2 configurations without command lists had two undefined +references. (gs.mak) + - Some shells required an extra ';' to terminate an 'if' command. +(ugcclib.mak, unix-end.mak, unixtail.mak) + +Updates the JPEG code to the officially released version 6 of the IJG +library. See jpeg.mak for information on where to find this library. +(jpeg/*, jpeg.mak, *.mak, modules.lis) + +Adds a definition of XEAUX to the makefiles to parallel CCAUX, primarily for +cross-compilation environments. All references to $(XE) must +be replaced by $(_XE), where some-program={$(GS), ansi2knr, +echogs, genarch, genconf, geninit}. This is a NON-BACKWARD-COMPATIBLE +CHANGE, required in order for the makefiles to work in cross-compiled +environments. (For non-cross-compiled environments, it currently doesn't +matter.) (gs.mak, *.mak) + +Utilities +--------- + +Updates ps2ai.ps to version 2.13. (ps2ai.ps) + +Changes all the utility shell scripts to include #!/bin/sh, to use exec, and +to pass the original arguments using "$@". (bdftops, font2c, gsbj, gsdj, +gslj, gslp, gsnd, wftopfa) + +Drivers +------- + +Adds the requirement that all page-oriented devices (i.e., those that use +gdevprn.h and implement the print_page procedure) include page.dev in their +dependencies and use $(SETPDEV) rather than $(SETDEV) in their makefile rule +bodies. THIS IS A NON-BACKWARD-COMPATIBLE CHANGE. Without this change, the +command list logic (over 25K of unnecessary object code) would have to be +included in every configuration. (gs.mak, devs.mak, echogs.c) + +Adds a user-contributed driver for the Okidata Microline (IBM compatible) +dot matrix printers. (gdevokii.c) + +Adds copy_rop (the RasterOp operation) to the driver interface. Currently, +only monobit and 8-bit gray-scale devices implement it. (gxdevice.h, +gsdevice.c) + +Adds the ability to read back bits from the display to the x11 devices. +(x_.h, gdevx.c, gdevxalt.c) + +Platforms +--------- + +Makes some minor changes to support QNX. (stat_.h) + +Removes the mswinprn driver from the 16-bit Windows configuration, because +the 64K default data segment overflowed. (bcwin.mak) + +Interpreter +----------- + +Fixes bugs: + - Type 1 fonts didn't accept packed arrays for Subrs or OtherSubrs. +(zchar1.c, zfont1.c) + - TBCP-encoded files (yes, I know there isn't supposed to be any +such thing) didn't automatically activate TBCP decoding. (gs_init.ps) + - Fonts with invalid FID entries weren't detected. (zfont.c) + +Speeds up dictionary operations slightly by removing redundant checks for +nulls. (zdict.c) + +Starts adding support for the new CIEBasedDEF and CIEBasedDEFG color spaces. +(gs_l2img.ps, gs_lev2.ps, igstate.h, zcrd.c) + +Adds access operators for RasterOp and transparency in the graphics state. +(They don't actually do anything yet.) (zgstate.c) + +Interpreter (PDF) +----------------- + +Fixes bugs: + - PDFDocEncoding was missing characters 24-31. (gs_pdf_e.ps) + +Moves the definition of pdfmark from systemdict to userdict so that Adobe +PostScript files won't think the interpreter is a distiller. (gs_pdf.ps) + +Library +------- + +Fixes bugs: + - Some JPEG images had bands of garbage alternating with bands of +valid data. IJG v6 fixed this -- see above. + - With FPU_TYPE = -1, the cosine routine returned incorrect values +for angles above 270 degrees. (gsmisc.c) + - CIE color conversion didn't work on 16-bit systems. (gscie.h, +gscie.c) + +Partially implements reducing the intermediate space for rasterizing +anti-aliased characters by compressing the oversampled representation to an +alpha array incrementally. (gdevmem.h, gxchar.h, gxdevmem.h, gdevabuf.c, +gschar.c, gspaint.c, gxccman.c) + +Starts adding support for the new CIEBasedDEF and CIEBasedDEFG color spaces. +(gscie.h, gscspace.h, gscie.c) + +Completes the implementation of band lists in RAM. To select this feature, +change the definition of cl_impl in gs.mak from clfile to clmem. (Someday +we'll make this easier.) (gxclmem.h, gxclmem.c) + +Finishes implementing RasterOp and transparency at the driver level for +monobit and 8-bit gray-scale devices, and implements some of the framework +for general multiple-bit-per-pixel devices. See drivers.doc for +documentation. (gsropt.h, gxcldev.h, gxclist.h, gdevm1.c, gdevm8.c, +gdevmem.c, gdevmrop.c, gschar.c, gxclist.c, gxclread.c) + +Implements the ability to include commands applicable to all bands, rather +than an individual band, in the band list. Eventually this will be used for +passing halftones through the band list. (gxcldev.h, gxclist.h, gxclist.c) + +Adds support for 2-bit-deep 'word' memory devices. (gdevmem.h, gxdevmem.c, +gdevm2.c) + +Changes the initialization for memory devices so that they determine their +polarity from the device for which they are buffering the image (if any). +This is a subtle change. (gdevmem.h, gdevmem.c, gdevm1.c, gsdevmem.c) + +Version 3.43(limited) (8/10/95) +===================== + +Fixes a few more minor bugs, and changes FEATURE selection back to +essentially the way it was before 3.41. + +Documentation +------------- + +Fixes bugs: + - A ~ was missing in a URL. (README) + +Adds information about an Amiga port of Ghostscript. (README) + +Removes a file called gs.1.c, which appears to be an obsolete version of +gs.1. + +Adds DCX documentation to the PCX driver. (We don't support DCX yet, but we +might in the future.) (gdevpcx.c) + +Adds information about getting Type 1 fonts from H-P if you have an H-P +PostScript printer. (use.doc) + +Procedures +---------- + +Fixes bugs: + - The auxiliary programs wouldn't compile with ANSI compilers that +don't accept K&R syntax. (ccgs, gs.mak, ugcclib.mak, *head.mak, +unixtail.mak, echogs.c, genarch.c, genconf.c, geninit.c) + +Reinstates FEATURE_DEVS in the makefiles, getting rid of FEATURE1..10. THIS +IS A NON-BACKWARD-COMPATIBLE CHANGE, but it puts things back the way they +were before 3.41, with one exception: compiling the PostScript +initialization code into the executable is now a separate macro +COMPILE_INITS with a definition of 0 or 1, instead of the ccinit 'feature'. +(gs.mak, *.mak, fonts.doc, make.doc) + +Adds a CCLEAF macro to the makefiles, for optimizing the compilation of +modules containing only leaf procedures. (gs.mak, *.mak) + +Adds a CONFIG makefile variable that helps in maintaining multiple variants +in a single directory. (gs.mak, *.mak) + +Platforms +--------- + +Fixes bugs: + - An extern for exit() (in ) was omitted. (gp_vms.c) + +Fonts +----- + +Reorganizes the compiled font facility so that fonts can be compiled and +turned into a library by third parties. (gs.mak, font2c.ps, gs_ccfnt.ps, +ccfont.h, iccfont.c, ccfontab.c) + +Interpreter +----------- + +Fixes bugs: + - internaldict was implemented as a dictionary in systemdict and an +operator in userdict, rather than as an operator in systemdict. This caused +a noaccess error when loading certain Type 1 fonts. (gs_init.ps, +gs_type1.ps) + - xfonts couldn't handle modified encodings. (zfont2.c) + +Changes the build date printout in the help message to YYYY-MM-DD. (gs.c) + +Adds native support for Multiple Master fonts (WeightVector). (zfont1.c) + +Implements sin and cos more efficiently (by table lookup with linear +interpolation) on machines with slow (or no) floating point. (zmath.c) + +Separates out the code for 'reading' the .ps initialization files, for the +new COMPILE_INITS arrangement. (imain.h, gconfig.c, gsmain.c, iconfig.c, +iccinit0.c, iinit.c) + +Streams +------- + +Fixes bugs: + - The CCITTFaxDecode filter could read up to 3 bytes beyond EOD. +This fix doesn't quite cover all cases, but at least it makes things better. +(ghc.h, sbhc.c, scfd.c) + +Library +------- + +Fixes bugs: + - After a nocurrentpoint error from a show operation with a +composite font, the bookkeeping was confused and could cause an access +error. (gschar.c) + - xfonts couldn't handle modified encodings. (gsccode.h, gxchar.h, +gxfont.h, gxxfont.h, gschar.c, gxccache.c) + +Makes .charboxpath able to use cached character information. (gxchar.h, +gschar.c) + +Adds native support for Multiple Master fonts (OtherSubrs 14-18). +(gxfont1.h, gstype1.c) + +Improves the hashing functions for the character cache. (gxfcache.h, +gxccman.c) + +Adjusts the character oversampling algorithm to reduce thickening for +devices with alpha capability. (gsbitops.c) + +Improves the encoding of the band list for certain kinds of small +rectangles. (gxcldev.h, gxclist.c, gxclread.c) + +Implements sin and cos efficiently on machines with slow (or no) floating +point. (gxfarith.h, gsmatrix.c, gsmisc.c, gspath1.c) + +Version 3.42(limited) (8/2/95) +===================== + +Fixes a few significant problems in 3.41, and brings the DLL code up to +date. + +Documentation +------------- + +Fixes bugs: + - language.doc still referred to rectappend rather than .rectappend. +(language.doc) + +Adds documentation on the Macintosh port. (readme, make.doc) + +Updates the DLL documentation. (dll.doc) + +Documents the BCP and TBCP filters as non-experimental. (language.doc) + +Procedures +---------- + +Changes the build date printout to YYYY-MM-DD. (gs_init.ps) + +Platforms +--------- + +Fixes bugs: + - The VMS build script had gotten out of sync with the makefiles +(again). (vms.mak, modules.lis) + +Brings the MS Windows and OS/2 platforms up to date with the rest of the +code, including DLL support for OS/2. (os2.mak, gsdll*.def, gdevswn.c, +gdevpm.c, gdevwdib.c, gp_mswin.c, gp_os2.c, gsdll.c, gsmain.c) + +Adds a new platform-specific routine gp_do_exit, as an alias for the C +library `exit' call. (gp.h, gsdll.c, gsmain.c, gp_*.c) + +Interpreter +----------- + +Fixes bugs: + - .forgetsave at the outermost level didn't clear the l_new bit, +causing changes to be undone improperly. (isave.c) + - A 'void' formal parameter list upset some compilers (as it should +have). (gsmain.c) + +Adds a .charboxpath operator that appends to the current path the bounding +boxes of the characters of a string. (zchar.c, zchar1.c) + +Streams +------- + +Fixes bugs: + - A procedure was declared private inconsistently. (siscale.c) + +Library +------- + +Fixes bugs: + - The library test program didn't do a necessary initial gsave. +(gslib.c) + - The fix for landscape monobit images in 3.41 could smash memory. +(gsimage1.c) + - 1-pixel-wide lines drawn with image or imagemask still disappeared +sometimes. (gsimage.c) + +Does some more preparatory work for the implementation of command lists in +RAM. (gdevprn.h, gxclio.h, gxclist.h, gxclfile.c, gxclist.c, gxclread.c) + +Adds a gs_charboxpath procedure that appends to the current path the +bounding boxes of the characters of a string. (gschar.h, gscpm.h, +gstype1.h, gxchar.h, gxpath.h, gxtype1.h, gzstate.h, gschar.c, gspaint.c, +gstype1.c, gxpath.c) + +Version 3.41(limited) (7/27/95) +===================== + +Another incremental release with bug fixes and customer-requested +enhancements. This release was intended to include the full setpagedevice +media matching and adjustment algorithm, but we discovered some +architectural problems during development, and have postponed it. + +Documentation +------------- + +Replaces the build instructions for NeXTSTEP with more up-to-date and +accurate ones. (make.doc) + +Notes that some extra manual steps are required when cross-compiling. +(make.doc) + +Documents how to define new 'features' in the makefile. (gs.mak) + +Procedures +---------- + +Fixes bugs: + - The build rule for ccinit.dev was circular. Fixing this required +a small but NON-BACKWARD-COMPATIBLE change in the way that features are +selected in the makefiles (FEATURE_DEVS replaced by FEATURE1..10). (*.mak, +fonts.doc, make.doc) + +Changes the build rule for gconfig.h to be less likely to overrun MS-DOS's +command line length limit. (gs.mak) + +Adds a -dFIXEDMEDIA switch to indicate that the media size should be +considered fixed after initialization. (gs_init.ps) + +Utilities +--------- + +Fixes bugs: + - traceimg.ps incorrectly referred to .stdout. (traceimg.ps) + - prfont.ps didn't display unencoded characters correctly. +(prfont.ps) + - ps2epsi didn't give correct bounding box information. (ps2epsi, +ps2epsi.ps) + - ps2epsi produced DSC comments that didn't fully conform to the +Adobe standard. (ps2epsi, ps2epsi.ps) + +Allows viewpbm.ps to take multiple files on the command line. (viewpbm.ps) + +Drivers +------- + +Adds a preliminary, contributed PNG driver. THIS IS NOT USABLE YET -- DON'T +TRY TO USE IT. (png.mak, gdevpng.c) + +Increases the maximum allowable scan line width for the TIFF drivers from +5183 pixels to 12863 pixels. (scf.h) + +Platforms +--------- + +Updates the MS Windows DLL code to export the new, suspendable run_string +interface. (gsdll.h, gsdll.c, dll.doc) + +Fonts +----- + +Fixes bugs: + - There were several errors in cfonts.mak. (cfonts.mak) + - The compiled fonts option didn't offer both free and standard +configurations. (gs.mak) + - A bug in the handling of Encoding resources prevented compiled +fonts from working. (gs_res.ps) + +Adds a little more support for CID-keyed fonts. They still aren't anywhere +near usable. (gs_cidfn.ps, gs_type1.ps) + +Adds a new Fontmap for Solaris 2.3. (Fontmap.Solaris) + +Adds support for Type 4 fonts (Type 1 fonts with their own BuildChar +procedures), including the CCRun procedure in internaldict. (gs_fonts.ps, +gs_res.ps, gs_type1.ps) + +Interpreter +----------- + +Fixes bugs: + - showpage and copypage didn't honor NumCopies in a page device. +(gs_setpd.ps, zdevice2.c) + - currentpagedevice returned incorrect information if the current +device wasn't a page device. (gs_setpd.ps) + - currentpagedevice didn't guarantee the presence of InputAttributes +and OutputAttributes. (gs_setpd.ps) + - The l_new bit wasn't set properly when a dictionary changed from +packed to unpacked keys, leading to unnecessary saves. (idict.c) + - Streams requiring intermediate buffering could read ahead too far, +causing input data to be skipped. (zfilter.c) + - cshow didn't reset the font to the base font when calling the +procedure. (zchar2.c) + - The Install procedure in a page device didn't set the default CTM. +(gs_setpd.ps, zmatrix.c) + - findlibfile didn't handle special files like %stdin correctly. +(zfile.c) + - setpagedevice didn't implement media matching. (gs_setpd.ps, +zdevice2.c, zmedia2.c, zmatrix.c) + - Some floating point numbers didn't print out with enough digits to +read back in with the identical value. (iutil.c) + - Integers that overflowed 31 bits (but not 32 bits) were converted +to negative integers rather than correct positive reals. (iscannum.c) + +Removes an experimental operator that called the image scaling/interpolation +code. (zimage2.c) + +Adds a -sSUBSTFONT= switch that substitutes the given font for all +unknown fonts, bypassing the normal intelligent substitution algorithm. +(gs_fonts.ps) + +Adds the Revision system parameter. (zmisc2.c) + +Adds a .knownundef operator that does an undef and returns true iff the key +was formerly present. (zdict.c) + +Makes the maximum length of names be 256 if EXTEND_NAMES is being used, 16K +otherwise. (inamedef.h, iname.c) + +Adds internaldict. (gs_init.ps, iinit.c) + +Adds support for Type 4 fonts. (bfont.h, zchar.c, zchar1.c, zfont1.c, +zfont2.c) + +Changes .encodingdict to EncodingDirectory, for compatibility with Adobe +interpreters. (gs_init.ps, gs_kanji.ps, gs_res.ps) + +Adds superexec, an undocumented operator that is equivalent to exec but +suppresses all invalidaccess checks. NOT COMPLETED YET; currently superexec +is equivalent to exec. (zcontrol.c) + +Interpreter (PDF) +----------------- + +Fixes bugs: + - .stderr was used but is no longer defined. (pdf_base.ps) + +Streams +------- + +Fixes bugs: + - Not all streams initialized their state pointer. (stream.c, +sfile.c, sfileno.c) + +Adds a filter for the smoothed image scaling algorithm. Eventually this +filter will require very little intermediate storage; right now it still +needs to buffer the entire intermediate image. (siscale.h, siscale.c) + +Increases the maximum allowable scan line width for the CCITTFaxEncode +filter from 5183 pixels to 12863 pixels. (scf.h) + +Library +------- + +Fixes bugs: + - setpagedevice didn't update NumCopies correctly. (gdevprn.c, +gsdparam.c) + - The newly optimized code for monobit bitmaps could cause an +out-of-bounds memory access and/or make unaligned references. (gsimage1.c) + - setpagedevice with unknown keys could cause an /undefined error. +(gsdparam.c) + - cshow didn't reset the font to the base font when calling the +procedure. (gschar.h, gschar.c) + - The Install procedure in a page device didn't set the default CTM. +(gzstate.h, gschar.c, gscoord.c, gsdevice.c) + - Very non-linear EncodeABC procedures in a color rendering +dictionary could produce very inaccurate results. (gscie.h, gscie.c) + - The line_ptrs pointer in memory devices didn't get relocated if +the bitmap was moved during garbage collection, leading to memory smashing. +(gdevmem.c) + - setpagedevice didn't implement media matching. (gsdparam.c, +gscoord.c) + - 'word' memory devices weren't recognized as memory devices. +(gdevmem.c) + - makeimagedevice allocated, and then didn't free, an unnecessary +palette for monobit devices. (gsdevmem.c) + - The hack for 1-bit-wide images didn't work consistently, +particularly in landscape orientation. (gsimage.c, gsimage0.c) + +Adds an .IgnoreNumCopies page device parameter that causes #copies and +NumCopies to be ignored. (gxdevice.h, gsdevice.c, gsdparam.c) + +Removes the .IsPageDevice device parameter. (gsdparam.c) + +Converts the image scaling/interpolation code to a filter. (gximage.h, +gsimage.c, gsimage0.c, gsimage3.c) + +Adds support for Type 4 fonts. (gxfont.h) + +Adds a default implementation of parameter lists, designed to be usable +easily from C code. (gsparam.h, gsparam.c) + +Version 3.40(limited) (6/28/95) +===================== + +This is another incremental limited release for delivery of a couple of +important bug fixes (pixel 'holes' in rotated images, setpagedevice errors +on some platforms) and an enhancement (architectural support for band lists +in RAM). + +Documentation +------------- + +Fixes bugs: + - The FTP location of the EMX DLLs was incorrect. (use.doc) + +Procedures +---------- + +Fixes bugs: + - A couple of build rules for IJG v6 were omitted. (jpeg.mak) + +Utilities +--------- + +Fixes bugs: + - prfont.ps wouldn't print more than 128 unencoded characters. +(prfont.ps) + +Platforms +--------- + +Fixes bugs: + - setpagedevice often caused /undefined errors on MS Windows and +OS/2 platforms. (gdevmswn.c, gdevpm.c) + - The VMS module list had gotten out of sync with the makefiles +(again). (modules.lis) + +Interpreter +----------- + +Fixes bugs: + - A couple of casts betwen char * and byte * were omitted. +(gsmain.c) + - gs_[main_]run_file_open wasn't exported properly. (imain.h, +main.h, gsmain.c) + +Streams +------- + +Changes the DCTEncode filter to return an error if it wasn't supplied enough +data before being closed. (sdcte.c) + +Library +------- + +Fixes bugs: + - The coordinate computations for all filling operations were +slightly inaccurate, leading to pixel 'holes' in rotated images. (gxdda.h, +gximage.h, gsimage*.c, gxdraw.c, gxfill.c) + +Undoes an "optimization" (inlining the normal, fast case of a procedure) +that actually hurt performance. (gxclist.c) + +Refactors the command list code so that it in the future it will be able to +store command lists either in RAM or in the file system. (gdevprn.h, +gxcldev.h, gxclio.h, gxclist.h, gdevprn.c, gxclfile.c, gxclist.c, +gxclread.c) + +Changes the interface to the path filling code to take separate X and Y +adjustment values. (gxpaint.h, gspaint.c, gxfill.c) + +Makes the command list allocate a small tile cache if the device doesn't +need halftones. (gxclist.c) + +Version 3.39(limited) (6/24/95) +===================== + +This is again an incremental release primarily for delivery of enhancements +(suspendable string input in particular) to commercial customers, and with a +few bug fixes. + +Documentation +------------- + +Notes that PDF files and repositioning PostScript files do not work if +Ghostscript was compiled with VAX C. (use.doc) + +Notes the requirement for EOD lookahead in decoding filters. (strimpl.h) + +Procedures +---------- + +Fixes bugs: + - There were a number of undefined or used-before-defined variables +in the makefiles. (devs.mak, dvx-head.mak, unixhead.mak, gs.mak) + - Some commands in the makefile exceeded the MS-DOS limit of 120 +characters. (gs.mak) + +Adds a -P and -P- switch to control whether the search path automatically +includes `.' as its first element. Moves the default value of this choice +(SEARCH_HERE_FIRST) from gsmain.c to iminst.h. (iminst.h, gs.c, gsmain.c, +use.doc) + +Makes some makefile changes in anticipation of the IJG v6 release. (*.mak) + +Utilities +--------- + +Fixes bugs: + - font2c generated invalid C procedure names from font names that +contained non-alphanumerics other then '-'. (font2c.ps) + - font2c generated a single element of incorrect type for numeric +arrays of zero length. (font2c.ps) + +Platforms +--------- + +Fixes bugs: + - The VMS build scripts had gotten out of sync (again). (vms*.mak, +modules.lis) + +Fonts +----- + +Makes the FONTPATH directory scanner accept fonts that begin with +%!PS-AdobeFont or %!FontType1 with no following `-'. (gs_fonts.ps) + +Interpreter +----------- + +Fixes bugs: + - eq and ne on arrays or dictionaries required read access. +(zrelbit.c) + - An include was missing. (zcsindex.c) + - .forgetsave at the outermost level didn't reset the l_new flag in +changed slots, leading to an anomalous (although perhaps not harmful) state. +(isave.c) + - Dictionary growing or unpacking would both save and free the old +keys array, leading to a dangling reference. (idict.c) + +Changes gs_interpret so that for .quit with a negative operand <= -100, +gs_interpret returns e_Fatal rather than the operand. THIS IS A +NON-BACKWARD-COMPATIBLE CHANGE, but as far as we know, it doesn't affect +anyone. (interp.c) + +Adds an API to allow feeding string input to the interpreter in pieces. +(errors.h, imain.h, main.h, gs.c, gsmain.c, interp.c, zcontrol.c, zfilter.c) + +Adds new predicates .identeq and .identne that test "pointer equality", even +for numbers and strings. (iutil.h, iutil.c, zrelbit.c) + +Changes a few uses of return_error to return in places that don't lead +directly to a PostScript error. (idict.c) + +Streams +------- + +Fixes bugs: + - The logic for skipping up to a 0xff byte when decoding JPEG data +could skip too much. (sdctd.c, sjpegd.c) + - If a buffer boundary fell in the middle of, or just before, an +EOD, some decoding filters could stop reading too soon. (sbcp.c, smtf.c, +sstring.c) + +Makes some minor changes in anticipation of the IJG v6 release. +(gsjmorec.h) + +Library +------- + +Fixes bugs: + - A declaration should have been removed. (gsdll.c) + - The library initialization/termination API wasn't declared. +(gslib.h, gsinit.c, gsmain.c) + - A variable and a preprocessor macro with the same name confused +VAX C. (gxclist.c) + - Image devices with depth 2-8 and only gray shades in the palette +didn't set color_info correctly. (gsdevice.c) + +Speeds up unrotated black-and-white images further by making them render +directly into a memory device when possible. (gxdevmem.h, gsimage1.c) + +Version 3.38(limited) (6/18/95) +===================== + +This release incorporates several customer-requested enhancements (cleaner +separation of the graphics library from the interpreter, option for >64K +names, true garbage collection of names, better handling of halftones on +band devices). It is intended primarily for those customers, but is +intended as a dry run for the next public release. + +Documentation +------------- + +Fixes bugs: + - gx_bitmap had not been updated to gx_tile_bitmap. +(drivers.doc) + +Procedures +---------- + +Fixes bugs: + - The man page extension in the Unix makefiles was still $(manext), +not $(man1ext). (unix-end.mak) + - 'make clean' didn't remove gs_init.c. (gs.mak) + +Restructures the makefiles to better separate the language interpreters from +the graphics core. (gs.mak) + +Adds a -dNOPROMPT switch to suppress the end-of-page prompts (but still wait +for the user to type a newline). This is different from -dNOPAUSE, which +suppresses both the prompts and the wait. (gs_init.ps) + +Utilities +--------- + +Replaces the mergeini.ps program with an equivalent (actually slightly +better) version written in C. (gs.mak, *.mak, psfiles.doc, use.doc, +geninit.c) + +Drivers +------- + +Fixes bugs: + - The color DeskJet drivers wouldn't compile with a K&R compiler, +because some of the procedure definitions weren't in the restricted syntax +that ansi2knr requires. (gdevcdj.c) + - The color DeskJet drivers wouldn't compile because of a bug in +Sun's cc. (gdevcdj.c) + +Changes the BJ-10e(x) margins to be identical to those of the BJ-200. +(gdevbj10.c) + +Changes the LaserJet margins in response to a user's request. (gdevdjet.c) + +Changes the psmono driver to produce slightly larger files that execute +faster on typical Level 1 printers. (gdevpsim.c) + +Changes the psmono driver so that it does not scale the image to fit the +page size, but instead scales it to be the same physical size on the page. +THIS IS A NON BACKWARD COMPATIBLE CHANGE. However, for full-page images, it +will not have any visible effect. (gdevpsim.c) + +Platforms +--------- + +Fixes bugs: + - There were some problems associated with printing in 32-bit +Windows environments. (gp_mswin.c) + - The IBM RS/6000 needs both and . (time_.h) + +Adds the PDF interpreter to the standard MS Windows configuration. +(bcwin.mak) + +Fonts +----- + +Fixes bugs: + - The entry for Courier-BoldItalic in cfonts.mak incorrectly named +it as Courier-Italic. (cfonts.mak) + - The files for Courier-Italic in cfonts.mak were inconsistently +named ncrri instead of ncri. (cfonts.mak) + - The rules in cfonts.mak covered only the fonts distributed with +the free versions of Ghostscript, omitting some of the standard set of 35. +(cfonts.mak) + - The maximum number of stem hints per character in Type 1 fonts +wasn't large enough for complex Asian characters. (gxtype1.h) + +Adds a -dNOFONTMAP switch to suppress loading the Fontmap file. +(gs_init.ps, gs_fonts.ps) + +Interpreter +----------- + +Fixes bugs: + - One of the GC marking routines for halftones had a typo, +possibly leading to an invalid access. (zht2.c) + - The GC could store beyond the end of the mark stack, +possibly smashing some characters of a string or name. (igc.c) + - If the allocator allocated a new ref object from a +freelist, the bookkeeping for the current ref object could get +confused. (ialloc.c) + - The GC didn't remove names properly from the hash table. +(iname.c) + - If a DOS editor added a ^Z to the end of an initialization file, +an error occurred during initialization. (gs_init.ps) + - If an initialization file had any lines longer than 128 +characters, .skipeof would get an error. (gs_init.ps) + - makepattern could create structures in global VM pointing to +structures in local VM. (zpcolor.c) + - The default color rendering dictionary didn't specify large enough +ranges for some intermediate values. (gs_lev2.ps) + - Files being freed by a restore weren't unlinked properly, leading +to dangling pointers. (zfile.c) + - The interpreter used strlen without a prototype. (interp.c) + - Indexed or Separation colors with a CIE base or alternate space +didn't work. (zcie.c) + - The Watcom C 10.0 compiler produced incorrect code for an +overlapping structure assignment. (zcsindex.c) + +Removes limit of 64K names, if EXTEND_NAMES is defined at compile +time. (*.mak, idebug.h, iminst.h, iname.h, gs.c, gsmain.c, idebug.c, +iname.c) + +Makes the garbage collector really collect names. (iname.h, inamedef.h, +isstate.h, igc.c, iname.c, isave.c) + +Restructures some files to better separate the language interpreters +from their support code. (gconfig.c, iconfig.c, iinit.c) + +Restructures some files to better separate the language interpreters +from the graphics core. (iastate.h, iastruct.h, ialloc.c) + +Allows the operands of cshow to be in either order on the stack. Adobe +interpreters apparently allow this, even though it's not documented. +(zchar2.c) + +Adds a hack in cvs to truncate non-standard operator names, rather than +giving a rangecheck, to work around the "max err string" problem in some +common error handlers. (ztype.c) + +Changes the print string for unregistered operators from operator_0x... to +@0x.... (iutil.c) + +Changes the garbage collector so it tries to allocate a large mark stack, to +avoid going into its 'slow' mode if the mark stack overflows. (igc.c) + +Interpreter (PDF) +----------- + +Fixes bugs: + - Stroked text used the text matrix, rather than just the +CTM, for scaling the line width, which could lead to inappropriately +wide lines. (gs_pdf.ps) + - Fonts based on other than a 1000-unit scale (i.e., with a +FontMatrix other than [0.001 0 0 0.001 0 0]) didn't scale Widths to +match the font scaling. (pdf_font.ps) + +Implements the PDF 1.1 color space extensions, except for Lab space. +(gs_pdf.ps, pdf_draw.ps) + +Implements the Rotate key for pages. (pdf_main.ps) + +Streams +------- + +Fixes bugs: + - When the garbage collector closed a file stream, the stream +incorrectly attempted to free the buffer. (stream.c) + +Separates out some stream implementations to better distinguish the +graphics core from the language interpreters. (smtf.h, sfilter1.c, +smtf.c, srld.c, srle.c) + +Library +------- + +Fixes bugs: + - Compressing characters being entered in the cache could cause an +invalid memory access. (gsbitops.c) + - The setbbox bounding box check was slightly inaccurate. +(gsdps1.c) + - makepattern could create structures in global VM pointing to +structures in local VM. (gscolor2.h, gspcolor.c) + - Out-of-range values during CIE color conversion led to random +results. (gscie.c) + - On output devices with non-inverted Y axes (such as MS Windows), +Interpolated images would smash memory. (gsimage.c) + - 90 degree rotated zero-width images caused an invalid memory +access. (gsimage1.c) + - If #copies was zero, showpage could create bogus empty output +files. (gdevprn.c) + - PageCount didn't take #copies into account. (gsdevice.c) + - Indexed or Separation colors with a CIE base or alternate space +didn't work. (gscie.h, gscie.c) + +Implements triangular line caps and joins, in anticipation of adding +a PCL5 interpreter. (gsline.h, gxstroke.c) + +Moves some procedures around for better separation of library from +interpreter. (gsinit.c, gslib.c, gsmain.c, gsmisc.c) + +Moves the standard allocator from the interpreter to the library. +(gsalloc.h, gxalloc.h, gxobj.h, gsalloc.c) + +Starts to change the representation of paths slightly to make it possible to +identify arcs. This change is backward-compatible for all code except +callers of gx_path_add_arc. (gxpath.h, gspath1.c, gxpath.c, gxstroke.c) + +Adds some framework for keeping track of RasterOp and "transparency" in the +graphics state, although these don't actually have any effect yet. +(gsrop.h, gsropt.h, gsstate.h, gxcldev.h, gzstate.h, gsrop.c, gsstate.c, +gxclist.c, gxclread.c) + +Adds a compile-time option for using the Adobe RGB<->CMYK conversion rules. +(gxdcconv.c) + +Adds a driver procedure for identifying band devices. This change is +backward-compatible for all existing devices. (gdevmem.h, gxdevice.h, +gsdevice.c, gxclip2.c, gxclist.c, gxcpath.c) + +Speeds up gray-scale images on devices requiring banding, and enables +further optimizations, by reintroducing the distinction between banded and +non-banded devices. (gxdevice.h, gdevprn.c, gsimage1.c) + +Reduces the size of the band list for halftoned images by encoding tile +indices more compactly. (gxcldev.h, gxclist.h, gxclist.c, gxclread.c) + +Extends the band list so it can cache more than 256 halftone tiles, and to +make better decisions about tile caching. (gxcldev.h, gxclist.h, gxclist.c, +gxclread.c) + +Version 3.37(limited) (5/11/95) +===================== + +Another bug fix release distributed only to customers. + +Documentation +------------- + +Fixes bugs: + - Some documentation about parameter lists was incorrect. +(gsparam.h) + - The documentation did not note that one cannot "pipe" PDF files +into the interpreter. (use.doc) + +Adds documentation for the BJC-600 to devices.doc. (devices.doc) + +Procedures +---------- + +Changes the debugging switch for OS calls from -Z0 to -Ze, and adds -Z0 for +high-level GC tracing. (use.doc, gp_unifs.c, ialloc.c, igc.c) + +Utilities +--------- + +Fixes bugs: + - The ps2ascii shell script included an erroneous @d. (ps2ascii) + +Enhances ps2ascii to output color and rectangle fill/stroke information if +COMPLEX is defined. (ps2ascii.ps) + +Drivers +------- + +Fixes bugs: + - the BJC-600 driver didn't handle BitsPerPixel correctly. +(gdevcdj.c) + +Fonts +----- + +Fixes bugs: + - Some buggy Type 1 fonts confused the Type 1 font reader. +(gs_fonts.ps, gs_type1.ps, pdf_font.ps) + +Interpreter (PostScript) +----------- + +Fixes bugs: + - .registerencoding didn't accept mixedarrays, which could cause an +error if an encoding was loaded long after initialization. (zfont2.c) + - If a program did a lot of saves and restores, the garbage +collector could get invoked much too often. (iastate.h, ialloc.c, igc.c, +isave.c) + +Changes the name of the rectappend operator to .rectappend, since it isn't a +standard PostScript operator. (zdps1.c) + +Interpreter (PDF) +----------------- + +Fixes bugs: + - PDF files didn't interact properly with ps2ascii. (gs_pdf.ps) + - setdash wouldn't accept a packed array. (zgstate.c) + - PDF files with incorrect generation numbers in object references +produced an error rather than a warning. (pdf_base.ps) + +Version 3.36(limited) (5/4/95) +===================== + +This is a limited-distribution release for distributing bug fixes to a few +customers. + +Documentation +------------- + +Adds some environment variables to the man page. (gs.1) + +Procedures +---------- + +Adds the psmono device to all 32-bit configurations. (*.mak) + +Moves the psmono and 'bit' devices to DEVICE_DEVS12 to avoid exceeding the +120-character maximum length of the DOS command line. (*.mak) + +Drivers +------- + +Changes the pgm[raw] and ppm[raw] drivers so they do *not* automatically +switch to pbm or pgm/ppm respectively if this is possible for the particular +page being rendered; adds pgnm[raw] and pnm[raw] drivers that *do* do this. +THIS IS A NON-BACKWARD-COMPATIBLE CHANGE. However, existing programs will +still work; they just won't produce the smallest and simplest possible +output. (devs.mak, gdevpbm.c) + +Interpreter +----------- + +Fixes bugs: + - A multi-level restore didn't free gstates allocated by +intermediate saves, causing some global VM to be lost until a garbage +collection. (isave.h, isave.c, zvmem.c) + +Speeds up restore by skipping the scan of the character cache if no new +names have been allocated since the save. (zfont.c) + +Extends the client API to allow for popping return values off the operand +stack. (imain.h, gs.c, gsmain.c) + +Library +------- + +Modifies the character oversampling algorithms to help prevent dropouts. +(gsbitops.c, gschar.c) + +Version 3.35(internal) (5/2/95) +====================== + +This is another internal "snapshot" version. + +Documentation +------------- + +Fixes bugs: + - Some of the file names in the `man' page had gotten out of date. +(gs.1) + - Two references to .PageCount hadn't been changed to PageCount. +(language.doc, devarch.doc) + +Procedures +---------- + +Puts writeppmfile back in the standard Unix and DV/X configurations, since +gsftopk uses it. Also puts the PDF reader in all 32-bit configurations. +(*.mak) + +Moves the BMP devices to DEVICE_DEVS11 to avoid exceeding the 120-character +maximum length of the DOS command line. (bcwin.mak, bcwin32.mak, os2.mak) + +Utilities +--------- + +Fixes bugs: + - unix-lpr.sh didn't handle 32-bit devices. (unix-lpr.sh) + - unix-lpr.sh still used the name .PageCount rather than PageCount. +(unix-lpr.sh) + - font2c gave an error when trying to write general procedures in +font dictionaries. (font2c.ps) + +Adds a pdf2dsc.ps utility for writing out fake DSC-compliant PostScript code +to invoke the PDF reader, for the benefit of viewer programs that aren't +PDF-aware. (unix-end.mak, pdf2dsc.ps) + +Drivers +------- + +Fixes bugs: + - The TIFF drivers put out incorrect PageNumber values. +(gdevtfax.c) + - Printer (and file output) devices got closed and reopened +unnecessarily when changing parameters. (gdevprn.c) + - Printer (and file output) devices didn't check for invalid formats +following a % in OutputFile. (devs.mak, gdevprn.c) + - 1-bit memory devices were not considered page devices, unlike all +other memory devices. (gsdevice.c) + - The black-and-white H-P printers didn't close the printer +properly, causing printing not to happen under MS Windows. (gdevprn.c) + - Some compilers didn't like initializing a const char * to NULL. +(gdevlbp8.c) + +Changes the X Windows driver so that if Ghostview specifies a bounding box, +this also sets ImagingBBox. (gdevxini.c) + +At the request of a customer, adds 1-, 4-, 8-, 24-, and 32-bit-deep memory +devices that store bits in 32-bit units rather than byte units. (gdevmem.h, +gxdevmem.h, gdevmem.c, gdevm1.c, gdevm2.c, gdevm4.c, gdevm8.c, gdevm16.c, +gdevm24.c, gdevm32.c) + +Adds a new MS Windows printer driver, mswinpr2, that uses a DIB rather than +a DDB. (gdevwpr2.c) + +Platforms +--------- + +Fixes bugs: + - A routine wouldn't compile because of a bug in the SGI C compiler. +(zcsindex.c) + - Some declarations were inconsistent when compiling for segmented +environments. (gscie.c) + - A routine wouldn't compile because of a bug in the VAX C compiler. +(gscie.c) + +Turns on compiler optimization for OS/2; adds PDF support and more devices +for Win32 and OS/2. (bcwin.mak, bcwin32.mak, os2.mak) + +Fonts +----- + +Fixes bugs: + - Font loading used 'setglobal' without binding it, which caused +some EPS files to signal errors. (gs_fonts.ps) + - A zero-length string with offset = 0 in a binary object sequence +caused an error. (iscanbin.c) + +Adds a LOCALFONTS switch that causes Ghostscript to load Type 1 fonts into +the current VM, rather than global VM. According to Adobe, this is what +Adobe printers (but not other interpreters, such as DPS and CPSI) do. +(gs_init.ps, gs_fonts.ps) + +Interpreter +----------- + +Fixes bugs: + - The 'note' page size command caused pages to be clipped +improperly. (gs_statd.ps) + +Adds "word" image devices. (gs_init.ps, zdevice.c) + +Starts converting the interpreter to use an explicit instance pointer. This +is very fragmentary so far and not really supported. (main.h, gs.c, +gsmain.c, iccinit.c) + +Library +------- + +Adds "word" image devices. (gsdevice.h, gsdevice.c) + +Removes the requirement that ImagingBBox[0] and [1] be non-negative. (The +Adobe specification requires this, but Ghostscript supports more general +initial CTMs than the Adobe spec.) (gsdparam.c) + +Version 3.34(internal) (4/18/95) +====================== + +This is a "snapshot" version made for internal purposes. It was never +released to anyone. + +Documentation +------------- + +Updates commprod.doc to be fully consistent with the AGFPL. (commprod.doc) + +Procedures +---------- + +Fixes bugs: + - tar_x was out of date. (tar_x) + - tar_gs assumed that if any PC executables were present, gs.exe +would exist. (tar_gs) + - jpeg.mak said the current IJG version was 5b, but the makefiles +actually referred to version 5a. (jpeg.mak) + - The build rule for the LIPS III driver was incorrect. (devs.mak) + - Some definitions in the makefiles occurred out of order. +(ansihead.mak, cc-head.mak, gcc-head.mak, unixhead.mak, unixtail.mak) + - The build rule for dvx-gcc.mak was incorrect. (unix-end.mak) + +Interpreter +----------- + +Restructures the CIE caches to move much more of the computation from color +mapping time to cache loading time. (zcie.c) + +Library +------- + +Fixes bugs: + - Color conversion of 12-bit images was very slightly inaccurate. +(gxfrac.h) + +Changes the transfer function, black generation, and undercolor removal +caches so that they sample at 1024 points and don't interpolate, rather than +sampling at 256 points and interpolating. This significantly improves the +speed of colored image rendering. ****** LIMITED TO 256 POINTS BECAUSE OF +O-STACK SIZE LIMIT. ****** (gxfmap.h, gxcmap.c) + +Restructures the CIE caches to move much more of the computation from color +mapping time to cache loading time. (gscie.h, gscie.c) + +Version 3.33 (4/13/95) +============ + +A few more last-minute bug fixes. This is, finally, the first public +release since 3.12. + +Documentation +------------- + +Fixes bugs: + - There was a reference to "VAX with OSF/1", which doesn't exist, +and an incorrect reference to VAX with Ultrix. (make.doc) + - The Unix makefiles incorrectly stated that gsdatadir was only +relevant to `make install'. (ansihead.mak, cc-head.mak, dgc-head.mak, +gcc-head.mak) + - Notes that DV/X users should use the zip version of the JPEG +library. (jpeg.mak) + +Procedures +---------- + +Fixes bugs: + - A command line had gotten too long for the MS-DOS shell. +(gs.mak) + - The VMS DEC C script didn't explicitly select DEC C. +(vms-decc.mak) + - The VMS MODULES.LIS omitted SPDIFF and ZFPDIFF. (modules.lis) + - The VMS script had an incorrect entry. (vms.mak) + - The `if' fix in 3.31 broke some Unix systems with different +implementations of sh. (unix-end.mak) + - The makefile definition of gscspace_h was out of order. (gs.mak) + - An extra ; got written in gconfig_.h on DV/X platforms. +(dvx-tail.mak) + - '.' was incorrectly prepended to the library search list on DV/X +platforms. (dgc-head.mak) + - The build rules for unix*.mak didn't work on DV/X. (unix-end.mak) + +Adds a description of the -c quit switch to the help message. (gs.c) + +For the DV/X platform, changes /usr/include to /djgpp/include as the place +to look for header files. I'm not sure this is always correct. +(dvx-tail.mak) + +Utilities +--------- + +Fixes bugs: + - ps2ascii would cause an error if given a font that didn't have an +'X' character. (ps2ascii.ps) + - ps2ascii didn't intercept the Level 2 string display operators. +(ps2ascii.ps) + +Drivers +------- + +Fixes bugs: + - The Stylus Color driver had an incorrect type name. (gdevstc.c) + +Platforms +--------- + +Fixes bugs: + - -dBitsPerPixel= didn't work properly for MS Windows or OS/2 PM. +(gdevmswn.c, gdevpm.c) + - The Win32 platform didn't compile properly. (memory_.h) + +Fonts +----- + +Improves the font substitution algorithm to take the face name into account +in more cases. (gs_fonts.ps) + +Library +------- + +Fixes bugs: + - Unrotated black-and-white bitmaps with an inverted device X axis +were displaced in X. (gsimage1.c) + +Version 3.32 (4/7/95) +============ + +More bug fixes. This is still not a public release. + +Documentation +------------- + +Further clarifies the "two-phase commit" algorithm for device put_params +procedures. (drivers.doc, gsparam.h) + +Adds a note about a compiler bug under Ultrix 4.4. (make.doc) + +Procedures +---------- + +Fixes bugs: + - Some installation scripts could fail because some implementations +of sh take the status of an `if' condition as the status of the `if' +command. (unix-end.mak) + +Adds "maintainer-clean" as a synonym for "real-clean". (gs.mak) + +Adds a -dORIENT1 switch that defines orientation = 1 as portrait for +setpage[params]. (use.doc, gs_init.ps, gs_lev2.ps, gs_statd.ps) + +Utilities +--------- + +Fixes bugs: + - ps2ascii didn't redirect %stdout completely. (ps2ascii.ps) + - ps2ascii didn't preserve the local/global VM mode. (ps2ascii.ps) + - ps2ascii didn't handle fonts with an all-zero or missing bounding +box correctly. (ps2ascii.ps) + - viewpbm didn't scale the image properly. (viewpbm.ps) + +Drivers +------- + +Fixes bugs: + - The CGM driver wrote out an incorrect color precision value. +(gdevcgm.c) + - The SGI bitmap driver was named "sgi" rather than "sgirgb". +(gdevsgi.c) + - The PCX driver didn't round up an odd line length for gray-scale +output. (gdevpcx.c) + - The PCX driver produced incorrect output for gray-scale or 4- or +8-bit color. (gdevpcx.c) + +Platforms +--------- + +Fixes bugs: + - The VMS MODULES.LIS file had gotten out of sync with the Unix +makefiles (again). (modules.lis) + +Interpreter +----------- + +Fixes bugs: + - Some compilers won't accept '\l', even in the false arm of a +preprocessor conditional. (scanchar.h) + - A procedure was declared with an incorrect argument type. +(zcsindex.c) + - The scaled font cache didn't copy XUIDs properly. (bfont.h, +zfont.c, zfont2.c) + - status could return true even if the file was closed. (zfile.c) + +Streams +------- + +Fixes bugs: + - The LZW filters were factored improperly. (modules.lis, gs.mak, +vms.mak, slzwx.h, slzwc.c, slzwd.c) + +Changes the DCTDecode filter for compatibility with Adobe implementations: + - Ignore bytes preceding the 0xff that marks the beginning of the +JPEG data. (sdctd.c) + - Set MAX_BLOCKS_IN_MCU to 64. (jpeg.mak, gsjpglib.h) + +Library +------- + +Fixes bugs: + - The "two-phase commit" for device parameters wasn't fully +implemented. (gsiodev.c) + - Asking for a device color map before the device was opened could +cause a crash. (gsdparam.c) + - The scaled font cache didn't copy XUIDs properly. (gxfont.h, +gsfont.c) + - 90 or 270 degree rotated black-and-white bitmaps (including +bitmapped fonts such as downloaded TrueType fonts) with an inverted device Y +axis were displaced in Y. (gsimage1.c) + - On high-resolution devices, parts of regions filled with halftones +could fail to be painted. (gxclist.c) + +Version 3.31 (4/2/95) +============ + +A few final bug fixes for the release. Includes significant speed +improvements for CIE color, and a first draft of a low-level CGM driver. + +Documentation +------------- + +Notes that the BJC600 driver also works for the BJC4000. (devs.mak) + +Procedures +---------- + +At the suggestion of a user, changes the default protections for installed +files on Unix and DV/X systems from 775/664 to 755/644. (*head.mak) + +At the suggestion of a user, adds a -dNOCIE switch to substitute DeviceGray +and DeviceRGB color spaces for CIEBasedA and CIEBasedABC spaces +respectively. (gs_init.ps, gs_lev2.ps) + +Utilities +--------- + +Changes gslp and its relatives to use ISOLatin1Encoding for output, and to +send almost all printout to stderr rather than stdout (for use as a filter +under Unix). (gslp.ps) + +Drivers +------- + +Fixes bugs: + - The fax/TIFF driver no longer exported gdev_fax_print_page, which +the DigiFax driver needs. (gdevtfax.c) + - The color DeskJet drivers gave an error for BitsPerPixel=3. +(gdevcdj.c) + - The "Windows printer" driver was setting its margins in points +rather than inches. (gdevwprn.c) + - The BJ10 and BJ200 drivers calculated vertical skip distances +wrong. (gdevbj10.c) + - The BJ10 and BJ200 drivers output two garbage bytes following the +initialization string. (gdevbj10.c) + +Adds a preliminary driver that produces low-level CGM output. (gdevcgml.h, +gdevcgmx.h, gdevcgm.c, gdevcgml.c) + +Platforms +--------- + +Fixes bugs: + - The VMS files had gotten out of sync with the other makefiles +(again). (modules.lis, vms.mak) + - The MS Windows and OS/2-PM drivers hadn't been updated to handle +BitsPerPixel as a standard parameter. (gdevmswn.c, gdevpm.c) + +Removes the TIFF drivers from the Windows platform, and restores the BMP +drivers. (bcwin.mak) + +Interpreter +----------- + +Fixes bugs: + - The CIE color mapping cache could produce anomalous results +for the default (all zero values) color if some of the mapping +functions were non-linear. (zcie.c) + - MultiMaster font substitution got confused if substituted +fonts had their FontName changed. (gs_fonts.ps) + - A procedure was declared as private inconsistently. (zdevcal.c) + - Some pointer relocation procedures didn't work correctly on +systems with sizeof(T *) > sizeof(int). (istack.c) + - The freelist vector wasn't large enough to handle graphics state +objects on 64-bit systems, leading to severe memory sandbars. (iastate.h) + - The debugging messages from the allocator had gotten inconsistent +and hard to use. (ialloc.c) + - Mixing save/restore with allocation could cause the GC never to +get run. (isave.c) + +Speeds up the mapping of CIE colors. (zcie.c) + +Adds a .namestring operator for getting the string of a name without having +to copy it. (zstring.c) + +Streams +------- + +Fixes bugs: + - The IJG code needed a couple more flags set for IJG v6. +(gsjmorec.h) + - Some pointer relocation procedures didn't work correctly on +systems with sizeof(T *) > sizeof(int). (stream.c) + +Library +------- + +Fixes bugs: + - The end-test for the fast case of monobit images was wrong, +leading to out-of-range memory accesses. (gsimage1.c) + - Monobit images rotated by 270 degrees displayed incorrectly. +(gsimage1.c) + - If a Type 1 font used hint replacement, some parts of the outline +before the hint replacement ignored the old hints. (gstype1.c) + - Some compilers didn't accept a variable name that was the same as +a macro with parameters. (gxht.c) + - A procedure was declared as private inconsistently. (gdevm1.c) + - Some pointer relocation procedures didn't work correctly on +systems with sizeof(T *) > sizeof(int). (gdevmem.c, gsstate.c) + - The test on FORCE_HINTS_TO_BIG_PIXELS was backwards. This bug was +supposed to have been fixed in 3.30, but somehow the fix got lost. +(gstype1.c) + - 90 degree rotated monobit images could drop some scan lines. +(gsimage*.c) + +Speeds up the mapping of CIE colors. (gscie.h, gxcmap.h, gscie.c, gxcmap.c) + +Speeds up color images (non-interpolated, 1-8 bits per component) by adding +a cache for mapped color values. (gximage.h, gsimage.c, gsimage1.c, +gsimage2.c) + +Shrinks the band list file slightly by using only as many bytes as necessary +for writing out colors, rather than always using 4 bytes. (gxclist.c, +gxclread.c) + +Version 3.30(beta) (3/21/95) +================== + +More bug fixes. The garbage collector and PDF interpreter finally appear to +work reliably. + +Documentation +------------- + +Fixes bugs: + - language.doc had gotten out of date. (language.doc) + +Utilities +--------- + +Fixes bugs: + - Changes in the handling of %stdout had broken ps2ascii. +(gs_dps1.ps, ps2ascii.ps) + +Improves ps2ascii to skip empty strings and not output redundant font +changes. (ps2ascii.ps) + +Drivers +------- + +Fixes bugs: + - The fax and TIFF drivers didn't free all their working storage. +(This bug was fixed in 3.27, and the fix somehow got lost.) (gdevtfax.c) + +Adds new drivers: + - sgirgb, to produce SGI RGB raster files. (gdevsgi.c) + - tiffcrle, to produce output in TIFF "CCITT 1-dimensional Huffman +RLE" format (Group 3 fax with no EOLs). (gdevtfax.c) + - tifflzw, to produce output in TIFF LZW format (using the existing +CCITTFaxEncode filter code). (gdevtfax.c) + - tiffpack, to produce output in TIFF PackBits format. (gdevtfax.c) + +Interpreter (PostScript) +------------------------ + +Fixes bugs: + - If the current screen was set with a halftone, setcolorscreen +wouldn't accept what currentcolorscreen returned. (gs_dps1.ps) + - debug_print_full_ref didn't print t_oparray objects correctly. +(idebug.c) + - The internal data for a font could be allocated in a different VM +space from the font dictionary, causing dangling pointers. (zfont2.c) + - definefont became confused if a program failed to delete the FID +from a re-encoded font. (This is questionable PostScript, but dvips does +it.) (zfont2.c) + - If a BuildChar procedure did a save before the setcachedevice and +a restore afterwards, the memory manager would attempt to free the cache +device after it had already been freed by the restore, leading to damaged +freelists. (gschar.c) + - setresolution (in statusdict) was ignored. (gs_lev2.ps, +gs_statd.ps) + - If a string containing a string containing a \ was passed to the +token operator, the \ was not recognized properly in a Level 2 environment. +(iscan.c) + - A couple of default dictionary sizes had become too small. +(iinit.c) + +Makes DOS EOF (control-Z, 0x1a) a self-delimiting token, like left bracket. +THIS IS A NON-BACKWARD-COMPATIBLE CHANGE, but it should not have any adverse +effects. (gs_init.ps, iscan.c, iscantab.c) + +Distinguishes arch_small_memory from arch_ints_are_short, and adds a new +-Z. switch to force small-memory table sizes regardless of actual memory +size. (dstack.h, idict.c, zpcolor.c, zvmem2.c) + +Interpreter (PDF) +----------------- + +Fixes bugs: + - A page with no Contents caused an error. (pdf_main.ps) + - Executing a Form resource caused an error. (pdf_draw.ps) + - Outlines with open entries caused an error. (pdf_main.ps) + - Embedded Type 3 fonts caused an error. (pdf_draw.ps, pdf_font.ps) + - The Widths array of fonts was ignored. (pdf_font.ps) + +Library +------- + +Fixes bugs: + - Freeing an entry in the pattern cache didn't clear the pointers to +the raster data, producing a dangling reference that confused the garbage +collector. (gxpcmap.c) + - The test on FORCE_HINTS_TO_BIG_PIXELS was backwards. (gstype1.c) + - The pattern cache bookkeeping was incorrect. (gxpcmap.c) + - Depending on the order in which pointers were relocated, the +garbage collector could incorrectly relocate pointers from the character +cache. (gxfcache.h, gsfont.c, gxccache.c, gxccman.c) + +Changes the fast case of black-and-white images so it aligns scaled images +with the device coordinate system, to improve performance. (gsimage1.c) + +Extends the coordinate transformation routines to handle absurdly large +translation values in the CTM as long as the final device device coordinates +are within fixed-point range. (gxmatrix.h, gxpath.h, gschar.c, gscoord.c, +gsmatrix.c, gxhint2.c, gxpath2.c) + +Distinguishes arch_small_memory from arch_ints_are_short, and adds a new +-Z. switch to force small-memory table sizes regardless of actual memory +size. (gdevprn.h, gxpcolor.h, gzht.h, std.h, gsfont.c, gsht1.c, gspaint.c, +gsstate.c, gxcht.c, gxht.c, gxpcmap.c) + +Version 3.29(internal) (3/8/95) +====================== + +Another bug-fix release. This release processes all but 7 of the 500+ files +on the Adobe Acrobat Sampler CD-ROM without giving an error. The garbage +collector finally appears to be stable. This version was created for a +customer; it was not released to the general public or even to the beta test +list. + +Documentation +------------- + +Documents the possible need to set LD_RUN_PATH on SVR4 platforms. +(make.doc) + +Expands the description of the device life cycle, and of the constraints on +put_params procedures. (drivers.doc) + +Adds an explicit copyright notice to the Aladdin Ghostscript Free Public +License. (PUBLIC) + +Clarifies that the Win32s documentation also applies to Windows NT. +(make.doc) + +Procedures +---------- + +Removes the obsolete writeppmfile operator from the standard configurations. +(gs.mak) + +Changes the Watcom makefiles to work properly with Watcom C/C++ 10.0. +(make.doc, msc.mak, watc.mak, watcwin.mak, wccommon.mak) + +Utilities +--------- + +Adds a wftopfa utility for converting the Wadalab fonts to usable Type 0 and +Type 1 form. (wftopfa) + +Fonts +----- + +Fixes bugs: + - Entries added automatically by definefont (FontInfo, ExactSize) +could cause a font dictionary to become full. (gs_fonts.ps, gs_type1.ps) + - wrfont.ps couldn't deal with very long CharStrings. (wrfont.ps) + +Makes the name of the Fontmap file an easily editable parameter. +(gs_fonts.ps) + +Adds a utility for converting the Wadalab font to usable Type 0 and Type 1 +form. (wrfont.ps, wftopfa.ps) + +Drivers +------- + +Fixes bugs: + - The top margin for printer (and fax) devices was computed +incorrectly, using the X resolution rather than the Y resolution. +(gdevprn.h) + - Changing the page size or resolution of a printer device closed +and reopened the device unnecessarily. (gdevprn.c) + - Changing the page size of the X11 device didn't change the initial +matrix, so (0,0) didn't wind up in the lower left corner. (gdevx.c) + - The bit devices didn't allow changing the number of bits per +pixel. (gdevbit.c) + +Adds a settable .IsPageDevice boolean device parameter to the X Windows +driver. The default value is true. (gdevx.h, gdevx.c) + +Changes the PPM driver so that it chooses between PBM/PGM/PPM on a +page-by-page basis, rather retaining the most general format ever required +by any page. (gdevpbm.c) + +Interpreter (PostScript) +------------------------ + +Fixes bugs: + - The current page device could be null, rather than an empty +dictionary. (igstate.h, zchar.c, zdevice.c, zdevice2.c, zgstate.c) + - The scanner didn't signal an error for names or strings that were +too long. (iscan.c) + - A missing header file upset the VAX compilers. (ztype.c) + - Some places expecting dictionary operands didn't check the type, +because they incorrectly assumed that the dict_check_read/write macro did +this. (idict.h, zdevice2.c, zht2.c, zmisc2.c) + - The definition of quit in systemdict wasn't disabled within +encapsulated jobs. (gs_lev2.ps) + - resetfile gave an error if the file was closed, rather than doing +nothing. (zfileio.c) + - The scanner attempted to free an uninitialized pointer if it +reached EOF after a / or //. (iscan.c) + - A restore in a different file than the corresponding save caused +an invalidrestore error. (gs_init.ps) + - The default value of EndOfData in RunLengthDecode streams was set +to false. (zfilter.c) + - .registerencoding didn't invoke the save machinery correctly, +leading to GC problems. (zfont2.c) + - The facility for overriding .printerror didn't work correctly. +(gs_init.ps) + - gs_run_file_open wasn't public. (gsmain.c) + - The interpreter returned e_undefined for undefined error names, +rather than the error code. (interp.c) + - Allocation in system memory (specifically, adding a block to a +stack) couldn't trigger automatic garbage collection. (interp.c, igc.c, +zvmem2.c) + - A restore in a different invocation of gs_run_string than the +corresponding save would stop reading the string. (files.h, gsmain.c, +iccinit.c, zfile.c) + - The Type 1 rasterizer state included a pointer into the middle of +an object, confusing the garbage collector. (zchar1.c, zfont1.c) + - When the garbage collector deleted a name, it didn't zero out the +string pointer. (iname.c) + - On platforms where obj_align_mod > 4, the memory manager could +access 1 beyond the end of its freelists. (iastate.h) + - makefont and scalefont didn't check the type of their font operand +soon enough. (zfont.c) + - restore didn't finalize the objects it freed. (isave.c) + - restore didn't free system VM. (isave.c) + - Freeing a ref array that occupied an entire chunk didn't free the +chunk. (ialloc.c) + +Adds a .runexec operator which implements the 'close if error' function of +run. (zfile.c, zfileio.c) + +Moves the obsolete writeppmfile operator into a separate file. (zfileio.c, +zwppm.c) + +Makes the statistics returned by the memory manager more accurate. +(ialloc.c, zvmem.c) + +Adds a (read-only) %Calendar% IODevice. (zdevcal.c) + +Adds a "hook" in the character operators to allow external code to +intervene; this is needed for a customer. (ichar.h, zchar.c, zchar2.c) + +Makes control-D (0x04) a self-delimiting token, like left bracket. THIS IS +A NON-BACKWARD-COMPATIBLE CHANGE, but it should not have any adverse +effects. (scanchar.h, iscan.c, iscantab.c) + +Changes the error stack printout so that it puts line breaks between items +iff the items are being printed with ==. (gs_init.ps) + +Uses finalization to close streams being freed. (igc.c, zfile.c, ziodev.c) + +Interpreter (PDF) +----------------- + +Fixes bugs: + - Embedded Type 1 fonts that invoked save and restore while being +read caused an error. (pdf_font.ps) + - Large files that referenced a non-alphabetic font for the first +time late in the file could cause an error. (pdf_main.ps) + +Streams +------- + +Fixes bugs: + - SubFileDecode streams didn't copy partial matches of the EOD +string into their output. (sfilter1.c) + +Makes switching between read and write modes a stream procedure. (stream.h, +sfile.c, sfileno.c, stream.c, zfileio.c) + +Makes file streams close themselves when finalized. (We can't do this for +other streams, because finalization procedures aren't allowed to free +storage explicitly.) (stream.h, sfile.c, sfileno.c, stream.c) + +Library +------- + +Fixes bugs: + - The obsolete files gcdefs.h and gsfile.c were still included in +the fileset. + - A number of places didn't deal with null patterns properly (p_tile +== 0). (gxdcolor.h, gspcolor.c, gxpcmap.c) + - The pattern tiling algorithm was numerically unstable, especially +if the X/YStep vectors were close to the axes. (gxcolor2.h, gspcolor.c, +gxpcmap.c) + - setdeviceparams checked the values of read-only byte array +parameters incorrectly. (gsdparam.c) + - The statistics macros in gxfill.c didn't use DO_NOTHING when +disabled. (gxfill.c) + - Changing the orientation of a device closed and reopened the +device unnecessarily. (gsdparam.c) + - ioerrors occurring when writing command lists weren't reported +properly. (gxclist.h, gxclist.c) + - Errors from device procedures weren't always propagated up to +clients. (gsimage1.c, gsimage3.c, gxclip2.c, gxclist.c) + - Overflowing the fixed-point translation values in the CTM caused a +floating point exception rather than a limitcheck. (gxmatrix.h, gscoord.c) + - charpath set the current point correctly, but didn't append a +moveto element to the path. (This mostly affected Mathematica output.) +(gzpath.h) + - Image devices mapped colors incorrectly. (gdevmem.c, gdevm16.c) + - On devices with color capability but fewer than 4 bits per pixel, +color halftones didn't work (and could cause an arithmetic exception). +(gxdither.c) + - Black-on-white memory devices didn't map colors properly. +(gdevprn.h, gxdevice.h, gxdevmem.h, gdevmem.c, gdevm1.c, gsdevice.c) + - Memory devices with a non-zero origin in their initial matrix +clipped the image improperly. (gsdevice.c) + - The Type 1 rasterizer state included a pointer into the middle of +an object, confusing the garbage collector. (gstype1.h, gxfont1.h, +gxtype1.h, gstype1.c, gxhint2.c) + - The band rasterizer could produce garbled output for images +(including characters) on 64-bit architectures. (gxclread.c) + - Bounding boxes (for pathbbox and setbbox) could be slightly +inaccurate. (gsmatrix.c) + - On 64-bit architectures, halftone tiles less than 16 bits wide +were handled incorrectly. (gxclist.c) + +Adds an .IsPageDevice boolean device parameter (normally read-only). +(gsdparam.c) + +Removes the library code for implementing the obsolete writeppmfile +operator. (gswppm.c) + +Makes the default matrix (for initmatrix and defaultmatrix) a settable +parameter in the graphics state. (gscoord.h, gzstate.h, gscoord.c, +gsdevice.c, gsdparam.c) + +Makes the statistics returned by the memory manager more accurate. +(gsmemory.h) + +Adds a compile-time flag to choose whether or not to force Type 1 hints to +"big pixel" boundaries when oversampling. (gstype1.c) + +Changes the .PageCount device parameter back to PageCount, because the +change broke some scripts. (gsdparam.c) + +Adds optimization for 90 degree rotated images with pure colors. +(gximage.h, gsimage.c, gsimage1.c) + +Changes the band rasterizer so that replicated halftone tiles are written on +the band list in unreplicated form. (gsbitops.h, gxcldev.h, gsbitops.c, +gxclist.c, gxclread.c, gxht.c) + +Changes the .HWBitsPerPixel device parameter to BitsPerPixel. (drivers.doc, +language.doc, gdevcdj.c, gdevstc.c, gsdparam.c) + +Version 3.28(beta) (2/13/95) +================== + +Another bug-fix beta release. The number of bugs being fixed in each of +these sub-releases does exceed the number of new bugs introduced, but the +latter number is discouragingly high. + +Documentation +------------- + +Adds some information about handling VMS file attributes for files +transferred by FTP. (use.doc) + +Procedures +---------- + +Fixes bugs: + - unix-gcc.mak said the static linkage switch for SunOS was -Bstatic +rather than -static. (unix-gcc.mak) + - Some dependency lists in gs.mak were out of date. (gs.mak) + +Utilities +--------- + +Fixes bugs: + - markhint.ps didn't check for protected fonts. (markhint.ps) + +Drivers +------- + +Fixes bugs: + - The cdj driver had a byte/char agreement problem. (gdevcdj.c) + - The cdj driver attempted to initialize a dynamic array. +(gdevcdj.c) + +Removes the setting of InputAttributes and OutputAttributes from the H-P +drivers, since this causes more problems than it solves. (gdevdjet.c) + +Interpreter +----------- + +Fixes bugs: + - makeoperator assigned incorrect attributes to operators. (bug +introduced in 3.27) (opdef.h, iinit.c, iutil.c, zmisc.c) + +Library +------- + +Fixes bugs: + - gs_makeimagedevice didn't set the caller's pointer to the newly +created device. (bug introduced in 3.27) (gsdevice.c) + - There were still some mismatches between char * and byte * values. +(gsdparam.c) + - The halftone replication algorithm could produce inappropriately +large replicated masks. (gxht.c) + - stroke usually did the wrong thing for degenerate (single-point) +subpaths. (gxstroke.c) + +Version 3.27(beta)(withdrawn) (2/8/95) +============================= + +Yet another bug-fix beta release. This release had so many serious problems +(the most serious being at least one changed file that the release tool +failed to include in the fileset) that it was withdrawn less than a day +after it was issued. + +Documentation +------------- + +Fixes bugs: + - The NEWS for 3.26 didn't mention the fact that the stdxxx stream +interface used by MS Windows, OS/2, and Macintosh implementations had +changed. (NEWS) + - The file public.doc wasn't distributed with the previous fileset. + +Brings the NeXTSTEP documentation up to date for NeXTSTEP releases 3.2 and +subsequent. (make.doc) + +Procedures +---------- + +Fixes bugs: + - Some dependency lists in gs.mak were out of date. (gs.mak) + - A 'fi;' was missing in the Unix install script. (unix-end.mak) + - There was no VMS build script for the PDF options. (vms.mak) + - The VMS script used CC_QUALI instead of CC_QUAL in several places. +(vms.mak) + +Utilities +--------- + +Fixes bugs: + - ps2epsi's usage prompt referred to "pstoepsi". (ps2epsi) + - ps2epsi set PATH and LOCALPATH unilaterally. (ps2epsi) + +Comments out the sample usage line at the end of viewjpeg.ps. (viewjpeg.ps) + +Drivers +------- + +Fixes bugs: + - The fax and tiff drivers didn't free all of their working storage. +(gdevtfax.c) + +Adds user-contributed drivers for the BJC 600 and ESC/P printers. +(devs.mak, gdevcdj.c) + +Platforms +--------- + +Fixes bugs: + - Some necessary casts of string parameters to (const byte *) were +omitted. (gp_mswin.c, gp_os2.c) + +Adds the psmono and bit* drivers, and removes the p*m drivers, in the OS/2, +32-bit MS-DOS, and 32-bit Windows configurations. (bcwin32.mak, os2.mak, +watc.mak) + +Fonts +----- + +Fixes bugs: + - The Fontmap for Ultrix had somehow become slightly incorrect. +(Fontmap.Ult) + +Removes the font file names from the dependency lists in cfonts.mak. This +makes cfonts.mak readily usable with any set of fonts, but it also means +that it will always run font2c, rather than being able to avoid this if the +.c file is up to date. (cfonts.mak) + +Interpreter +----------- + +Fixes bugs: + - Some operators could fail if the stdxxx streams weren't currently +open. (files.h, zfileio.c, ziodev.c) + - setpagedevice didn't handle unrecognized keys properly. +(gs_setpd.ps) + - The value returned for the HWColorMap device parameter was +allocated incorrectly, confusing the garbage collector. (iparam.c) + - Typing ahead at the >>showpage<< prompt no longer caused all +further pages to be processed without stopping. (gs_init.ps) + - Setting DEVICEWIDTHPOINTS or DEVICEHEIGHTPOINTS on the command +line caused a typecheck. (gs_init.ps) + - The garbage collector didn't handle halftone threshold arrays +properly. (zht2.c) + - setdefaulttimeouts caused an error on Level 2 systems. +(gs_lev2.ps) + - cvi and cvr weren't equivalent to token followed by a type check. +(iscan.h, iscannum.h, iscan.c, iscannum.c, ztoken.c, ztype.c) + - In Level 2 systems, image and colorimage didn't allow 12 bits per +sample. (zpaint.c) + - If debugging was enabled, the garbage collector printed spurious +error messages about the allocator objects not being in a chunk. (ialloc.c) + - restore didn't reset the count of operator procedures, so the +operator procedure table could fill up. Fixing this required splitting the +op_array_table into a global table and a local table. (opdef.h, iinit.c, +iutil.c, zmisc.c) + - .forgetsave could leave a dangling pointer in the memory manager, +causing an access error. (ialloc.c, isave.c) + - Freed objects weren't always marked as freed, which could confuse +the memory validator. (ialloc.c) + - .forgetsave didn't mark inner chunk headers as free, leading to +access errors. (isave.c) + +Changes the representation of operator procedures so that they point +directly to their definition in the op_array_table. (iref.h, opdef.h, +idebug.c, igc.c, igcref.c, interp.c, zmisc.c) + +Removes .makeglobaloperator. (zmisc.c) + +Adds patches to discard some common garbage produced by H-P-oriented +applications and drivers. (gs_init.ps) + +Changes the >>showpage<< prompt so that if the input reaches EOF, the +interpreter still stops after the next >>showpage<<, rather than processing +all subsequent pages. This is a consequence of the bug fix that +automatically reopens the stdxxx files. + +Adds an optional dictionary parameter for the RunLengthEncode/Decode +filters, to allow specifying EndOfData. The default is true. (zfilter.c) + +Adds ByteTranslateEncode/Decode filters. (zfilter2.c) + +Streams +------- + +Fixes bugs: + - The K > 0 option of the CCITTFaxDecode filter switched back to 2-D +encoding if an output buffer boundary fell in the middle of a 1-D line, and +signalled an error if an input buffer boundary fell in the middle of an EOL. +(scfd.c) + +Adds an EndOfData flag to the RunLengthEncode/Decode filters. If true, RLE +generates 128 as EOD, and RLD recognizes it; if false, RLE does not mark +EOD, and RLD ignores 128. (srlx.h, gxclist.c, gxclread.c, sfilter1.c) + +Adds ByteTranslateEncode/Decode streams. (sbtx.h, sfilter2.c) + +Library +------- + +Fixes bugs: + - There were some mismatches between char * and byte * values. +(gsdparam.c) + - Failure to round a scaling coordinate caused one-for-one +black-and-white images to render slower than they should. (gsimage.c) + - Setting PageSize without setting HWResolution could cause an +invalid memory access. (gsdparam.c) + - The garbage collector didn't handle halftone threshold arrays +properly. (gxht.h, gsht.c, gsht1.c) + +Version 3.26(beta) (2/1/95) +================== + +Yet another bug-fix beta release, still not ready for public release. + +Documentation +------------- + +Fixes bugs: + - The description of device properties had gotten out of sync with +the code. (language.doc) + +Splits off documentation specific to the Aladdin (non-GNU) release into a +separate file. (readme, public.doc, unix-end.mak) + +Adds a pointer to a collection of other free fonts (including some Cyrillic +ones) available on the net. (public.doc) + +Procedures +---------- + +Fixes bugs: + - On VMS systems with both VAX C and DEC C installed, the build script +used VAX C rather than DEC C. (vms.mak) + - zfdecode.c didn't have a build rule. (gs.mak) + - Several macros in the makefile were used before they were defined. +(gs.mak) + - Several macros in the makefile were used without being defined. +(gs.mak) + +Replaces the gssetdev, gssetmod, and gsaddmod scripts with more variants of +echogs. (echogs.c, gs.mak) + +Utilities +--------- + +Fixes bugs: + - The ps2ascii shell script passed a -f flag to the shell, which not +all shells recognize. (ps2ascii) + +Drivers +------- + +Fixes bugs: + - Due to a typo in an initialization string, the H-P printers didn't +reset the top margin to zero. (gdevdjet.c) + +Adds InputAttributes and OutputAttributes entries to the H-P drivers. (This +should probably be generic to all printers.) (gdevdjet.c) + +Replaces the contributed Epson Stylus Color driver with a newer version. +(devices.doc, gdevstc.c) + +Platforms +--------- + +Fixes bugs: + - DEC C complained about 'abs' and 'exit' not being declared. (x_.h) + - gp_mswin.c and gp_os2.c wouldn't compile. (gp_mswin.c, gp_os2.c, +ziodev.c) + +Interpreter +----------- + +Fixes bugs: + - The default CIE rendering dictionary gave everything a magenta tint. +(gs_lev2.ps) + - Changing HWResolution and PageSize in the same call of +setpagedevice produced an incorrect HWSize. (gsdparam.c) + - .putdeviceparams didn't accept all the keys that .getdeviceparams +returned. (gsdparam.c) + - The default handler for interrupt and timeout errors didn't push a +current object (command) on the stack. (gs_init.ps) + - The garbage collector didn't handle strings larger than 64K +properly. (iastate.h, ialloc.c, igcstr.c) + +Adds media matching and Policy consultation to the implementation of +setpagedevice. (gs_setpd.ps) + +Adds a MaxGlobalVM system parameter. (zmisc2.c) + +Streams +------- + +Fixes bugs: + - The CCITTFaxEncode filter could access a byte beyond the end of +the allocated area. (scfe.c) + - The CCITTFaxDecode filter could get an ioerror if a buffer +boundary fell in exactly the wrong place. (scfd.c) + +Library +------- + +Fixes bugs: + - The garbage collector didn't trace colored halftones properly. +(gzht.h) + - The garbage collector didn't relocate the bitmap pointers in +halftone caches properly. (gzht.h, gxht.c) + +Adds the ability to transmit dictionaries through the param_list mechanism +(specifically, as device parameters). This change is +non-backward-compatible only for implementors of parameter lists, which only +exist within the Ghostscript core. (gsparam.h, iparam.h, iparam.c) + +Removes the InitialMatrix device property. (gsdparam.c) + +Version 3.25(beta) (1/24/95) +================== + +Yet another bug-fix beta release. There are still at least half a dozen +significant known bugs to be fixed before a public release. + +Documentation +------------- + +Notes that on Unix systems, one should not edit 'makefile', but should edit +the individual subfile and run tar_cat. THIS IS A NON-BACKWARD-COMPATIBLE +CHANGE. (make.doc) + +Adds information on the Macintosh implementation. (readme) + +Procedures +---------- + +Fixes bugs: + - make clean failed on Unix systems where rm -f requires at least one +file name. (gs.mak) + - math_.h was omitted from many dependency lists. (gs.mak) + +Drivers +------- + +Fixes bugs: + - The X Windows and MS Windows draw-line routines couldn't possibly +produce sufficiently correct output (since the interface only provides integer +coordinates). (gdevx.c, gdevwddb.c) + +In response to patent-related actions by Unisys and CompuServe, removes the +GIF driver. (*.mak) + +Changes dci_std_color (and std_device_std_color_* and prn_device_std_*) so +that if the number of bits per pixel is 32, the device is defined as CMYK +rather than RGB. (gxdevice.h) + +Removes the tseng8 device, which is no longer useful. (devs.mak, gdevsvga.c) + +Adds pseudo-alpha support to the SVGA drivers, via the TextAlphaBits and +GraphicsAlphaBits device parameters. (gdevsvga.h, gdevsvga.c) + +Adds a user-contributed driver for the Epson Stylus Color printer. (devs.mak, +gdevstc.c, devices.doc) + +Platforms +--------- + +Fixes bugs: + - The VMS build scripts had gotten out of sync (again). (vms*.mak) + +Interpreter +----------- + +Fixes bugs: + - The emulator name array was incorrectly declared const in one place. +(gs.c) + - A closed file could incorrectly appear to be 'eq' to another file +(open or closed). (iutil.c) + - If %stdin/%stdout/%stderr was ever closed, it couldn't be +reopened. (gs_btokn.ps, gs_init.ps, files.h, zfile.c, zfileio.c, zfilter.c, +zfproc.c, ziodev.c) + +Changes (almost) all the operator routines to 'static'. (z*.c) + +Library +------- + +Fixes bugs: + - The raster value for replicated tiles in the halftone cache was +incorrect, causing unaligned memory accesses. (gxht.c) + - stroke and strokepath could produce slightly inaccurate output +(leading to slight visible anomalies) as a result of stroke adjustment. +(gxstroke.c) + - Attempting to draw an arc with zero radius could cause a numeric +exception. (gspath1.c) + - Setting the Orientation of a device to null resulted in actually +setting it to a random value. (gsdparam.c) + - charpath, stringwidth, and cshow attempted to remap the current +color unnecessarily. (gschar.c) + +Adds the ability to trace calls on the sqrt function (and possibly other math +functions in the future.) (math_.h, gsmisc.c) + +Adds additional interrupt checks in the banding code. (gxclist.c, gxclread.c) + +Version 3.24(beta) (1/17/95) +================== + +This was supposed to be a public release, but too many bugs showed up in 3.23, +so this is another bug-fix beta release. This is the first release with a +working PDF reader. + +Documentation +------------- + +Notes that Solaris requires using installbsd instead of install. (make.doc) + +Procedures +---------- + +Changes 'make mostlyclean' so that it doesn't delete the Ghostscript +executable (but deletes everything else that 'make clean' does). (gs.mak) + +Changes the link list generator so it eliminates duplicate library requests. +(genconf.c) + +Factors the interpreter further so as to include less unnecessary PostScript +support in the PDF interpreter. (gs.mak, zpath.c, zpath1.c) + +Adds a printout of the available language interpreters to the -h message. +(genconf.c, gs.c, iinit.c, gs.mak) + +Drivers +------- + +Fixes bugs: + - The alternate X drivers used a cast in an initializer, causing a +compilation error on some platforms. (gdevxalt.c) + +Adds a driver for the LaserJet IIID, including duplex printing if specified by +the Duplex page device parameter. (gdevdjet.c) + +Adds Orientation to the bit device. (gdevbit.c) + +Platforms +--------- + +Fixes bugs: + - There was an extraneous pfen-> in the NT file system module, causing +a compilation error. (gp_ntfs.c) + - The DLL code referred to an obsolete symbol a_foreign. (gsdll.c) + - The VMS build scripts omitted the LaserJet 4 driver. (vms-*.mak) + - The VMS build scripts had several other minor errors. (vms.mak) + +Fonts +----- + +Fixes bugs: + - Defining a font alias in global VM with a name that was a string in +local VM caused an error. (gs_fonts.ps) + - The font compiler referred to an obsolete symbol a_foreign. +(font2c.ps) + +Interpreter +----------- + +Fixes bugs: + - There was an extraneous '#' before an extern declaration. +(gsmain.c) + - The interpreter could (incorrectly) attempt to expand the e-stack. +(istack.h, interp.c, istack.c) + - zfproc.c called memcpy but didn't include memory_.h. (zfproc.c) + - A garbage collection occurring within a 'save' would often smash +memory. (igc.c) + - If the last character returned by the procedure of a procedure-based +filter was \r, readline could get an endless loop. (zfileio.c) + - Saving a change to a ref member of a structure confused the garbage +collector. (isave.h, isave.c, zdict.c) + - The -Zu debugging printout could cause an access error under rare +circumstances. (isave.c) + - Save objects could get allocated in global VM, causing dangling +references. (zvmem.c) + - The vmsave object created by the interpreter for a save didn't get +freed properly if the memory manager created an invisible save level, which +could cause the next garbage collection to crash. (zvmem.c) + - 'run' always printed an error message, rather than letting the +top-level control loop do it. (gs.c, gs_init.ps) + +Adds support for duplex devices. (gxdevice.h, gsdparam.c, gs_statd.ps, +gs_setpd.ps) + +Adds the beginnings of support for CID-keyed fonts. (gs_cidfn.ps) + +Changes the format of the stack dump printed for errors, to make it easier to +read. (gs_init.ps) + +Interpreter (PostScript) +------------------------ + +Fixes bugs: + - The .local/global allocation operators always allocated in system +VM. (zsysvm.c) + - setpage[params] caused an error. (gs_lev2.ps) + - If an error occurred during a cshow or (x|y|xy)show, the interpreter +freed the enumerator twice. (zchar.c, zchar2.c) + +Changes setpageparams so that orientation = 0 means portrait. This is not +compatible with AGFA's convention for roll-feed devices, but it is compatible +with the more common cut-sheet printers. (gs_statd.ps) + +Adds meaningful values for the Emulator resource. (gsmain.c, gs_res.ps) + +Makes -Z? validate the state of memory before and after save and restore. +(ialloc.h, igc.h, ialloc.c, igc.c, ilocate.c, zvmem.c) + +Interpreter (PDF) +----------------- + +Fixes bugs: + - The Unix install script didn't install the PDF files if they were +present. (unix-end.mak) + - PDF to PostScript conversion didn't work at all. (It still doesn't +work very well.) (pdf_2ps.ps, pdf_main.ps) + - Images with an Indexed color space and no Decode entry caused an +error. (pdf_draw.ps) + - The 'Page ' messages were printed even if QUIET was set. +(pdf_main.ps) + +Changes the interpreter so that when it encounters an unknown operator, it +prints an error message and continues, rather than signalling an error. +(pdf_base.ps) + +Makes F a synonym for f if there is nothing on the operand stack, to +compensate for a bug in some Adobe software. (pdf_base.ps) + +Changes pdfgetpage so it uses 1-origin rather than 0-origin indexing. THIS IS +A NON-BACKWARD-COMPATIBLE CHANGE. (pdf_main.ps) + +Streams +------- + +Fixes bugs: + - The Group 3 2-D and Group 4 encoders produced incorrect output if a +scan line beginning with a black pixel was followed by a scan line beginning +with a white pixel. (scfe.c) + - A SubFileDecode filter with a count of 1 and a non-empty EOD string +would smash memory. (sfilter1.c) + +Updates the DCT filters so they will work with the latest version (5a) of the +IJG library. (*.mak, jpeg.mak, sjpegerr.c) + +Library +------- + +Fixes bugs: + - A call with integer parameters to a procedure with floating point +arguments didn't work on non-ANSI compilers. (gsimage.c) + - Arcs could get turned into polygons if the scaling values in the CTM +were very large and the radius was (in user space coordinates) very small. +(gspath.c) + - The current point was defined when a BuildChar procedure was called. +(This bug was documented as fixed in version 2.2!) (gschar.c) + +Adds support for Orientation and Duplex page device parameters, for those +devices that support these. (gdevprn.h, gxdevice.h, gsdevice.c, gsdparam.c) + +Version 3.23(beta) (1/5/95) +================== + +This is almost entirely a bug fix release. It also includes a largely working +PDF reader. This is intended as the beta test release for the next public +release. + +Documentation +------------- + +Fixes bugs: + - COPYLEFT, COPYING, NEWS, PUBLIC, README, and the standard Fontmap +were omitted from the 3.22 fileset. + +Documents the use of the -oldc switch to work around a compiler crash on +the DECstation. + +Expands and clarifies the documentation for building the DesqView/X version +with djgcc. (make.doc) + +Adds documentation on the "600x300" H-P inkjet printers, explaining why +this alleged higher resolution is not available. (devices.doc) + +Adds to the PUBLIC license a warning that it is not a GNU License, and a +requirement to include a copy of or a pointer to the License in any written +material. (PUBLIC) + +Documents the fact that Ghostscript *does* attempt to look up files in the +current directory first. (use.doc) + +Procedures +---------- + +Fixes bugs: + - In VMS.MAK, .JPEG should have been changed to .JPEG-5 in a few +places. (vms.mak) + +Adds the pjxl300 driver to all configurations that include the other color +DeskJet drivers. Replaces pjet and pjetxl with pj and pjxl. (*.mak) + +Makes 'run' recognize PDF files if the PDF reader is included. +(pdf_main.ps) + +Utilities +--------- + +Fixes bugs: + - viewjpeg.ps needed the test for languagelevel = 2 at the +beginning of the file. (viewjpeg.ps) + - prfont.ps used 'min', which isn't a standard PostScript operator. +(prfont.ps) + - prfont.ps created Encoding vectors that weren't 256 elements +long. (prfont.ps) + +Adds the gsdj500 script to the installation list. (unix-end.mak) + +Changes the Unix "line printer" shell scripts to add the date to the page +header. (gsbj, gsdj, gsdj500, gslj) + +Changes ansi2knr so that it will work properly on systems where the ctype +macros don't handle 8-bit characters correctly. (ansi2knr.c) + +Drivers +------- + +Fixes bugs: + - Some compilers don't allow casts in initialization expressions. +(gdevx.c, gdevxalt.c) + - The cdj drivers didn't initialize the color_info structure +properly. (gdevcdj.c) + +Adds another alternate X Windows driver, x11mono, that is a black-and-white +device. (devs.mak, gdevxalt.c) + +Adds a user-contributed driver for the Apple Imagewriter LQ. (devs.mak, +gdevadmp.c) + +Platforms +--------- + +Fixes bugs: + - The VMS MODULES.LIS file had gotten out of sync with the makefile +(again); GDEVABUF and GSBITOPS were missing. (modules.lis) + - The VMS script file had gotten out of sync with the makefile +(again). (vms.mak) + - The MS Windows platform code didn't recognize Windows 95 (Windows +4.0) as equivalent to Windows NT. (gp_mswin.c) + - File name enumeration didn't work on OS/2 or win32. (gp_ntfs.c, +gp_os2.c) + - -sOutputFile= didn't work under MS Windows. (gp_mswin.c) + +Changes the SCO Unix direct frame buffer driver so it generates in-line +instructions to access the frame buffer, for a dramatic speed improvement. +(gdevpcfb.h, gdevsco.c) + +Fonts +----- + +Fixes bugs: + - If a font couldn't be found in the Fontmap, a recursion loop +sometimes occurred. (gs_fonts.ps) + - Aliases for global fonts weren't automatically created as global, +possibly leading to a recursion loop. (gs_dps1.ps, gs_fonts.ps) + - If a font was loaded into global VM within an inner save, the restore +deleted it from FontDirectory but not from SharedFontDirectory, causing a +possible recursion loop. (gs_dps1.ps, gs_fonts.ps, idict.h, idict.c, zdict.c) + +Further improves the algorithm for substituting for unknown fonts. +(gs_fonts.ps) + +Interpreter (PostScript) +------------------------ + +Fixes bugs: + - zcontrol.c had an assignment of const char * to const byte *, +which some compilers don't like. (zcontrol.c) + - Setting an Indexed color space based on a CIE space caused an +attempt to free a random block of memory. (zcsindex.c) + - Some compilers don't like mixing conditionals and casts in +initialization expressions. (iref.h) + - Some calculations of table sizes for string garbage collection +didn't work if sizeof(long) != 4, leading to smashed strings. (iastate.h, +ialloc.c, igcstr.c) + - Strings longer than about 7000 bytes smashed their chunk header +and confused the garbage collector. (ialloc.c) + - Some compilers needed iccfont.c to include strimpl.h. +(iccfont.c) + - The obsolete file zcspace2.c was still included in the fileset. + - If the command line included any @-files that required searching +the library path, a limitcheck would occur. (zfile.c) + - The insideness testing operators caused a memory access error, +because the procedure vector hadn't been updated to provide a default +get_alpha_bits procedure. (zupath.c) + - gcheck didn't check for stack underflow. (zvmem2.c) + - cleardictstack could fail to clear the dictionary stack if the +stack had overflowed into additional blocks. (zdict.c) + - If the '-' switch was selected, resources weren't released +properly on exit. (gs.c) + - Setting a Pattern color space based on a CIE space caused an +invalid memory access. (zcsindex.c) + - The garbage collector didn't treat refs properly on machines with +short ints. (igcref.c) + - Operators with more than 16 arguments could break the +interpreter. (interp.h, iinit.c, interp.c) + - save/restore didn't restore the setting of the current allocator +VM (local/global). (isstate.h, isave.c) + - stdpre.h declared exit as an extern, instead of letting gsmain.c +declare it. (stdpre.h, gsmain.c) + - gs.c used fputs to print help messages rather than fprintf. +(gs.c) + - Interrupts failed to re-execute the operation that was +interrupted. (interp.c) + - Low-resolution CMYK devices didn't use separate screens for each +color plane as the default. (gs_init.ps) + - filterdict wasn't getting undef'ed at the end of initialization. +(gs_init.ps) + - gstate operations were broken (bug introduced in 3.02). +(zdevice2.c) + - resourceforall didn't remove the resource dictionary from the +dictionary stack when calling the client-supplied procedure. (gs_res.ps) + - currentcolor with an Indexed color space returned a real rather +than an integer. (zcolor2.c) + - setshared / setglobal left the stack in an unobvious state if +they were given a non-Boolean argument. (gs_dps1.ps) + - sethalftone followed by currenthalftone returned an invalid value. +(zht2.c) + - Empty strings produced spurious garbage collector error messages. +(gsstruct.h, scommon.h, igc.c, igcstr.c, iname.c) + - The garbage collector didn't trace Separation color spaces properly. +(gscsepr.c) + +Changes defineresource so that it does not, by default, make instances +read-only. (gs_res.ps) + +Adds .{local,global}{array,dict,packedarray,string} operators for creating +objects in a specific VM space. (zsysvm.c, gs_dps1.ps) + +Adds definitions of setpage and setpageparams to statusdict. (gs_setpd.ps, +gs_statd.ps) + +Alleviates some performance problems in the garbage collector. (igc.c) + +Interpreter (PDF) +----------------- + +Fixes bugs: + - PDF files that used filters with parameters caused a typecheck +error because the arguments to 'filter' were reversed. (pdf_base.ps) + - The (undocumented) PDF 1.1 ability to specify link and annotation +destinations indirectly was not supported. (pdf_main.ps) + - The (undocumented) PDF ability to specify a null page in a link +destination was not supported. (pdf_main.ps) + - The PDF encodings weren't loaded properly in a system with both +PS Level 2 and PDF features. (gs_res.ps, gs_init.ps) + - If the next line after a stream keyword was blank, the line +wasn't skipped, which matters for binary data. (pdf_base.ps) + - A Q operator with no matching q operator caused an error. +(pdf_draw.ps) + - The text position wasn't preserved across a fill or stroke +operator. (gs_pdf.ps, pdf_draw.ps) + - Embedded Type 3 fonts didn't work. (pdf_base.ps, pdf_draw.ps, +pdf_main.ps) + - Masked images with no Decode value had their polarity inverted. +(pdf_draw.ps) + - Embedded Type 1 fonts referenced from within a stream didn't +work. (pdf_font.ps) + +Changes the PDF code so that it automatically recognizes PDF files as such. +(pdf_main.ps) + +Splits out the PixelDifference filters as a separate "feature". (gs.mak) + +Streams +------- + +Fixes bugs: + - Closing the primary input stream caused an invalid memory access. +(stream.c) + - Increasing the size of a buffer within a save resulted in a +dangling reference after the restore. (files.h, sfilter.h, zfile.c, +zfilter.c) + - The garbage collector didn't properly trace streams that referenced +strings directly. (stream.h, stream.c, ziodev.c) + +Library +------- + +Fixes bugs: + - An extraneous \ upset some compilers. (gdevabuf.c) + - Uncolored Patterns that completely filled their bounding box +caused an invalid memory access. (gspcolor.c) + - If a color image required clipping, black or white pixels might +be rendered with incorrect (random) colors. (gxcpath.c) + - Reference counts for color spaces were sometimes set too high, so +they would only be freed by restore or garbage collection. (gscolor.c) + - The character cache could get confused if the Encoding for the +character wasn't a name. (gschar.c) + - Character outlines were always rendered with flatness = 0, +causing very bad performance for large characters. (gzstate.h, gschar.c, +gsimage.c, gxfill.c, gxstroke.c) + - If a device (presumably uninitialized) had a +color_info.num_components of zero, an invalid memory access could occur. +(gsdparam.c) + - Intersecting clipping paths that are not both rectangular didn't +properly set the outer box of new clipping path, leading to unnecessary +computation. (gxcpath.h, gxacpath.c, gxcpath.c) + - A call passed false instead of NULL. (gschar.c) + - On machines where sizeof returns a long, genarch.c failed. +(genarch.c) + - xfonts were consulted, incorrectly, even for stroked characters. +(gxccman.c) + - gstate/currentgstate/setgstate didn't work properly. (gsline.c, +gsstate.c) + - On CMYK devices needing halftoning, colors with C = M = Y were +always converted to gray shades. (gxcmap.c) + - Isolated horizontal lines, or the horizontal edges of rectangles, +could get drawn with one or both end pixels missing. (gxfill.c) + +Changes the character cache back so it oversamples characters at small +sizes. (gschar.c) + +Changes all occurrences of (void)x to discard(x), and defines discard in +stdpre.h as a cast to void, to make it possible to pacify compilers that +don't accept this construct for some kinds of x. (gpcheck.h, stdpre.h, +store.h, gdevmswn.c, gp_mswin.c, gscoord.c, gxclread.c, igc.c, sfile.c, +sfileno.c, zcie.c, zht2.c, ziodev.c, zmisc1.c) + +Increases the size of the halftone cache on large-memory machines from 35K +to 100K. This substantially improves halftoning performance at higher +resolutions. (gxht.c) + +Version 3.22(beta) (11/30/94) +================== + +This is primarily a bug fix release. It also includes limited anti-aliased +graphics capability. This release was not distributed to the public. + +Procedures +---------- + +Fixes bugs: + - The definition of ghost_h was misplaced, so changes in it or its +antecedents didn't force recompilation of its dependents. (gs.mak) + +Actually implements the -Z+ switch, for forcing small stack blocks. +(interp.c) + +Makes the -dSAFER switch disable the %pipe syntax for file names, even for +reading. (gs_init.ps) + +Drivers +------- + +Fixes bugs: + - The dfax drivers incorrectly set EncodedByteAlign to false. +(gdevdfax.c) + - softwareValue and dateTimeValue were declared as byte rather than +char. (gdevtfax.c) + +Platforms +--------- + +Fixes bugs: + - The VMS DEC C compilers declare delete in unixio.h, and doesn't +declare unlink anywhere. (stdio_.h) + - The VMS compilers declare malloc and free in stdlib.h, which +wasn't being included in malloc_.h. (malloc_.h) + - The SCO Unix C compiler needs both and . +(time_.h) + - The VMS compilers declare abs in stdlib.h, which wasn't being +included anywhere. (gshtscr.c) + - The definition for A4 paper in VMS-AXP.MAK was incorrect. +(vms-axp.mak) + +Renames VMS-AXP.MAK as VMS-DECC.MAK, with some changes that make it +appropriate for DEC C on both VAX and AXP platforms. (vms-axp.mak => +vms.decc.mak) + +Fonts +----- + +Fixes bugs: + - gs_kanji.ps got an invalidaccess error. (gs_kanji.ps) + +Interpreter +----------- + +Fixes bugs: + - An off-by-1 test in the roll operator caused it to smash the +stack if the operand stack had overflowed into additional blocks. +(zstack.c) + - The default CIE color rendering dictionary didn't assume a +reasonable intermediate (XYZ) space. (gs_lev2.ps) + - CIE color mapping tables weren't traced properly by the garbage +collector. (gscie.h, gscie.c, zcie.c) + - If the very last character of a file was a ^M, the scanner +(incorrectly) signaled a syntaxerror. (iscan.c) + - If an operator could return both a typecheck and a +stackunderflow, it always returned a stackunderflow, which doesn't match +the behavior of Adobe interpreters. (opcheck.h, idparam.c, interp.c, +iutil.c, z*.c) + - astore, dictstack, and execstack could return a spurious +invalidaccess error (or fail to detect an invalid access) if the operand +stack had overflowed into additional blocks. (istack.c) + - The garbage collector didn't relocate pointers to names! (Bug +introduced in 3.20.) (iname.h) + - If the dictionary stack overflowed into additional blocks, the +cached value pointer for a name could get set incorrectly, and also not get +relocated by the garbage collector. (idict.c) + - If the dictionary stack overflowed into additional blocks, the +post-GC fixup of cached value pointers in names could cause an addressing +error. (igc.c) + - With the -Z? switch set, the garbage collector could incorrectly +report that objects or strings weren't in any chunk. (igc.c) + - << /a 1 /a 2 >> /a get gave the value 2 rather than 1. +(gs_init.ps) + - Numbers in binary object sequences and encoded number arrays +didn't work properly on machines where sizeof(short) != 2 or sizeof(long) +!= 4. (ibnum.c) + - The put operator for dictionaries allowed null as a key. +(idict.h, idict.c) + - >> didn't give an error if there were an odd number of values on +the stack above the next mark. (gs_init.ps) + - Operations that explicitly freed ref objects (setting a CIE +colorspace, resizing a dictionary, popping a block off a stack) could +corrupt storage. (ialloc.c) + - The -Z@ switch, which fills freed blocks with a recognizable bit +pattern, could incorrectly overwrite freed blocks in previous save levels, +causing invalid memory accesses. (ialloc.c) + - Since streams freed by a restore weren't marked as free, they +could confuse the garbage collector and lead to invalid memory accesses. +(zfile.c) + - If one of the built-in dictionaries overflowed during +initialization, no error was reported -- entries were simply discarded. +(iinit.c) + - If the level2.dev feature was combined with certain other +features, the current languagelevel was 2 when some gs_*.ps files were +loaded, causing them to load incorrectly. (gs_btokn.ps, gs_setpd.ps) + - If readline read a line that ended with only a CR (no LF) +followed by an end-of-file, it incorrectly closed the stream. (zfileio.c) + +Adds a .cond operator, similar to the Lisp multi-arm conditional. +(zcontrol.c) + +Adds a .makeglobaloperator operator, allowing the definition of operator +procedures in local VM that turn into global operators, provided the save +level is zero. (iref.h, opdef.h, iinit.c, interp.c, zmisc.c) + +Note: the fix for returning typecheck vs. stackunderflow requires that all +operators (or other code) that uses return_error(e_typecheck) to indicate +an incorrect object type on the operand stack must change this to +return_op_typecheck(op), where op points to the operand. THIS IS A +NON-BACKWARD-COMPATIBLE CHANGE. + +Implements string array and name array parameters for parameter lists. +(gsparam.h, iparam.c) + +Brings filterdict inside the INITIAL_DICTIONARIES conditional. (iinit.c) + +Adds a .currentscreenlevels operator that returns the number of +distinguishable halftone levels. (zht.c) + +Streams +------- + +Fixes bugs: + - The 2-D case of CCITTFaxDecode could get confused by an input +data buffer boundary that fell immediately after a horizontal code. +(scfd.c) + - The LZW decoder didn't detect invalid data unless DEBUG was +selected at build time. (slzwd.c) + +Library +------- + +Fixes bugs: + - The clipping region accumulator could refer to a clipping +rectangle even after it had been freed. (No effect on execution unless the +-Z@ switch was selected.) (gxacpath.c) + - setbbox expanded the bounding box, but didn't place a limit on +further path elements, if the current path wasn't empty. (gsdps1.c) + - setbbox didn't make sufficient allowance for rounding. +(gsdps1.c) + +Implements the ProcessColorModel parameter (read-only) for all devices. +(gsdparam.c) + +Adds a gs_currentscreenlevels procedure that returns the number of +distinguishable halftone levels. (gsht.c) + +Version 3.21(beta) (11/17/94) +================== + +This is primarily a bug fix release. It also includes a substantial +improvement in the Type 1 font hinting algorithms. This release was not +distributed to the public. + +Documentation +------------- + +Fixes bugs: + - The `man' page referred to gnu.ghostscript.bug rather than +comp.lang.postscript. (gs.1) + +Documents the special entries in operator definition tables that allow +switching dictionaries. (opdef.h) + +Procedures +---------- + +Moves the definition of JSRCDIR to the individual platform makefiles, to +make it easier to change on platforms that don't have file links. (*.mak) + +Utilities +--------- + +Fixes bugs: + - ansi2knr didn't recognize that a line ending with } couldn't be a +function definition. (ansi2knr.c) + - ps2epsi always returned an empty bounding box. (ps2epsi, +ps2epsi.bat) + +Drivers +------- + +Fixes bugs: + - The bitrgb device had an invalid depth of 3. (gdevbit.c) + +Replaces the color mapping code in the X driver with a much faster +algorithm, courtesy of Tim Theisen. (gdevx.h, gdevx.c, gdevxini.c) + +Platforms +--------- + +Fixes bugs: + - Two variable names were misspelled. (gdevpm.c, gp_mswin.c) + - It wasn't possible to compile a non-DLL configuration under OS/2. +(os2.mak) + - Compilation under Microsoft C/C++ 8.0 gave errors. (gp_mswin.h, +gp_mswin.c, gshtscr.c) + +Adds some more devices to the OS/2 makefile. (os2.mak) + +Fonts +----- + +Fixes bugs: + - wrfont.ps, and hence bdftops, didn't write out the FontType or +PaintType. (Bug introduced since 2.6.1) (wrfont.ps) + - wrfont.ps omitted a 'begin' and 'end', causing -! or -| to be +undefined when the font was loaded. (Bug introduced since 2.6.1) +(wrfont.ps) + +Interpreter +----------- + +Fixes bugs: + - make_tasv_old called make_tasv_new with extra arguments. +(store.h) + - currentcacheparams only returned 2 values instead of 3. +(zfont.c) + - ustroke popped one element too many off the stack if a matrix was +supplied. (zupath.c) + - inu[eo]fill popped one element too many off the stack. +(zupath.c) + - The color rendering dictionary was initialized to null rather +than a valid dictionary. (gs_lev2.ps) + - An invalid IODevice resource named "9" got created. (gs_res.ps) + - bytesavailable often caused an error rather than returning -1. +(zfileio.c, stream.c) + - The insideness testing operators always returned true if the +aperture was defined by a user path rather than a point. (zupath.c) + - If INITIAL_DICTIONARIES was defined in the makefile, the +definition of the initial_dictionaries array was missing a comma. +(iinit.c) + - Even if userdict appeared in INITIAL_DICTIONARIES, gs_init.ps set +its maxlength to 200. (gs_init.ps) + - Setting a CIE color space left a garbage value on the stack. +(zcie.c) + - If a file or filter was opened and then closed, opening a file +subsequently within a 'save' could lead to a memory access error in the +garbage collector. (zfile.c) + - Setting an Indexed or Separation color space could cause a crash +either in the garbage collector or when printing out the e-stack. +(icsmap.h, zcsindex.c, zcssepr.c) + - Invoking a filter with an invalid data source or sink could cause +a memory access error (bug introduced in 3.20). (zfilter.c) + - Invoking stringwidth on a font whose BuildChar procedure did a +save could cause a memory manager error or infinite loop, because +stringwidth attempted to use an inapplicable shortcut. (gschar.c) + - The bounding box for rendering stroked Type 1 characters didn't +take square caps and miter joins into account. (gs_type1.ps) + - Invoking filter with DCTDecode or DCTEncode could cause an +addressing error if no dictionary argument was supplied. (zfdctd.c, +zfdcte.c) + - The Generic resource, the Font resource, and half a dozen +resources with no predefined instances all shared the same Instances +dictionary. (gs_res.ps) + - The temporary null device allocated for stringwidth was never +freed. (gschar.h, gschar.c, zchar.c) + - Internal operators, and structures that might be freed on stack +unwinding, could "escape" from the e-stack. (zcontrol.c, ztype.c) + - makefont and scalefont didn't properly handle a font whose +Encoding had been changed. (bfont.h, zfont.c, zfont2.c) + - Type 1 fonts with PaintType = 2 incorrectly checked for an xfont. +(gxfont.h, gschar.c, gsfont.c, zchar1.c, zfont1.c, zfont2.c) + - Specifying a string argument with -d...=(...) or -d...=<...> +would cause an invalidaccess error. (gs.c) + - The environment for encapsulated jobs didn't rebind quit to stop +in userdict. (gs_lev2.ps) + - restore didn't deal properly with open files on the e-stack. +(zvmem.c) + - Even with the '-' switch, Ghostscript would try to read ahead in +the input stream rather than processing input character-by-character. +(ziodev.c) + - If an error occurred with a unreadable dictionary on any stack, +the standard error printer would get into an error loop and exit the +interpreter. (gs_init.ps) + - The for_roots macro in igc.c used ap rather than mem as its +second formal parameter. (This typo had no effect on the executable +program.) (igc.c) + - If saving the stacks for an error caused a GC request, a value +could get stored into an improper variable on the C stack, causing havoc. +(interp.c) + - setdash checked to make sure that the distance array had read +access; Adobe interpreters don't check this. (zgstate.c) + - The roots for gs_run_string and gs_interpret weren't registered +properly, which could cause a dangling reference in the case of a restore +whose save had been done earlier. (gsmain.c, interp.c) + +Adds an OpenOutputFile Boolean device parameter for printer devices; if +true, the device opens the OutputFile at the time the device is opened, +instead of waiting for the first showpage. This helps with synchronization +when the OutputFile is a pipe. (gdevprn.h, gdevprn.c) + +Changes the BEGIN/END_OP_DEFS macros to require an explicit { and } at each +use. (gsmain.c, interp.c, z*.c) + +Arranges things so that the operators that the interpreter handles +specially are assigned the first N operator indices [internal change only]. +(interp.h, iinit.c, interp.c) + +Changes the operators max and min to .max and .min, to avoid conflicts with +PostScript programs that use these names for variables and also use 'bind'. +THIS IS A NON-BACKWARD-COMPATIBLE CHANGE from programs that depend on +'bind' binding in these operators; however, we have also defined procedures +max and min that just call the operators, which should take care of any +ordinary code. (*.ps, zrelbit.c) + +Streams +------- + +Fixes bugs: + - The pfb_state pointer in the eexecDecode filter state wasn't +marked as traceable for the garbage collector. (sfilter.h) + - The eexec decoding filter could access invalid memory or return +garbage under some conditions. (Bug introduced in 3.12.) (zmisc1.c) + - The eexec decoding filter would incorrectly ask for more input if +the output buffer was full. (seexec.c) + +Library +------- + +Fixes bugs: + - Some compilers reserve the word 'try'. (gshtscr.c) + - Some compilers don't like line continuations (\) within a +preprocessor macro formal parameter list. (gdevprn.h, gxdevice.h) + - Memory devices created with an inverted palette (0=white, +1=black) interchanged white and black in fill operations. (gdevmem1.c) + - The 'bits' variable in mem_mono_copy_mono was unused on +little-endian machines. (gdevmem1.c) + - Some garbage collector procedures were declared 'private' +inconsistently. (gscie.c) + - The new anti-aliased text capability accidentally caused all +characters to be oversampled. (gschar.c) + - Type 1 fonts with PaintType = 2 and StrokeWidth = 0 came out with +many pixels missing because of oversampling. (gschar.c) + - Type 1 font stem hints were not being processed correctly. +(gstype1.h, gxtype1.h, gstype1.c, gxhint2.c, gxhint3.c, gxpath.c) + - The tracing message for 9/7 composite fonts incorrectly +identified them as 1/7 fonts. (gschar0.c) + - If a 1/7 or 9/7 composite font was a child of a non-modal font, +the font number of the child font was computed incorrectly. (gschar0.c) + +Splits up the various memory devices into one file per depth [internal +change only]. (gdevm*.c) + +Version 3.20(beta) (10/31/94) +================== + +This version contains some support for a PDF interpreter; however, the PDF +code itself is not ready for release yet. It also includes anti-aliased text +capability. This release was not distributed to the public. + +Documentation +------------- + +Notes that the FAQ has moved to smallo.ruhr.de:pub/ghost/gs.faq. (readme) + +Documents various implementation limits. (language.doc) + +Procedures +---------- + +Fixes bugs: + - bcp.dev wasn't included in the list of dependencies for +level1.dev. (gs.mak) + +Changes the printout of version numbers so that it is always A.BC, +rather than A.B if C is zero. (gs.c, gs_init.ps) + +Utilities +--------- + +Fixes bugs: + - font2c didn't correctly handle Metrics or Metrics2 dictionaries +whose entries were arrays rather than scalars. (font2c.ps, ccfont.h, +iccfont.c) + - font2c didn't handle CDevProc. (font2c.ps, ccfont.h, iccfont.c) + - genconf could get a stack overflow on small machines. +(genconf.c) + +Changes mergeini.ps so it can take arguments on the command line specifying +the input and output files. (mergeini.ps) + +Adds a gsdj500 shell script to parallel gsdj500.bat. (gsdj500) + +Drivers +------- + +Fixes bugs: + - The X driver didn't mask dynamically assigned colors properly, so +it could request the same color over and over again. (gdevx.c) + +Adds two alternate X Windows drivers, for helping debug drivers with other +color models: + - x11alpha, an RGB device with 4-bit alpha capability (for + copy_alpha only); + - x11cmyk, a 1-bit-per-component CMYK device. +(devs.mak, gdevxalt.c) + +Changes the left margin of the lj4dith driver to 0.26". (gdevcdj.c) + +Platforms +--------- + +Fixes bugs: + - If didn't exist, time_.h didn't always include +. (time_.h) + - The OS/2 platform wouldn't compile. (gdevpm.c) + - The auxiliary VMS command files sometimes got blank lines +inserted when going through EOL conversion. (vms.mak; delete gs_.com) + - The VMS makefiles didn't include the Level 1 operators in +level1.dev. (vms.mak) + - The VMS gcc makefile didn't handle undefined DEVICE_DEVSn +variables properly. (vms*.mak) + - The VMS makefiles didn't recognize DEVICE_DEVS{1,2,5,7}. +(vms.mak) + +At the request of a Unix expert, changes all the Unix shell scripts to use +exec gs ... "$@" rather than gs ... $*. (gsnd, gsbj, gsdj, gslj, gslp) + +Modifies the JPEG library so that it uses 4K less of the automatic data +segment in 16-bit environments. (bcwin.mak, jpeg.mak, sjpeg.c, sjpegerr.c) + +Adds the bmp drivers back into the 16-bit MS Windows executable, since they +will fit now. (bcwin.mak) + +Fonts +----- + +Makes the font substitution algorithm recognize the word Roman as calling +for a serif font. (gs_fonts.ps) + +Interpreters +------------ + +Fixes bugs: + - The fix in 3.13 for the inexact function values at 0 didn't work. +(zcontrol.c) + - Level 1 configurations referenced an undefined procedure +gs_currenthalftone. (gsht.c, gsht1.c) + - Specifying any device properties (including -r and -g) on the +command line caused an error. (gs_init.ps) + - The forward declaration of cfont_name_array_create was +incorrect. (iccfont.c) + - save and restore could get called before the graphics state stack +had been initialized properly. (gs_mex_e.ps) + - Some encodings weren't loaded properly. (gs.mak, gs_mex_e.ps, +gs_mro_e.ps, gs_pdf_e.ps, gs_wan_e.ps) + - Zero-height images were allowed, but zero-width images +weren't. (zpaint.c) + - Neither zero-width nor zero-height images popped their +arguments from the operand stack. (zpaint.c) + - lib_file_fopen overwrote its file name argument, causing havoc +with @-files. (gxiodev.h, gdevpipe.c, gsiodev.c, zfile.c) + - The garbage collector got confused if there were any arrays or +dictionaries with 8K or more elements. (igcref.c) + - >> could leave the stacks in a questionable state if it failed. +(gs_init.ps) + - The Category resource category didn't implement undefineresource. +(gs_res.ps) + - When the token operator read the last token from a string, it +left an unchanged string on the stack instead of an empty string. +(stream.c) + - noaccess didn't give an invalidaccess error when applied to the +permanent dictionaries. (dstack.h, idict.c, ztype.c) + - Overflowing the exec stack wasn't handled properly. (istack.h, +istack.c) + - The garbage collector cleared the cached value pointers in names, +causing interpretation to slow down substantially. (idict.c, igc.c, +iname.c) + - 0 dict created a dictionary with a maxlength of 1. (idict.c) + +Changes the default size of the execution stack from 150 to 250, to match +the Adobe "typical" value. (interp.c) + +Moves the operator definitions out of the automatic data segment. +(opdef.h, iinit.c, z*.c) + +Adds operators that allow creation of objects in system space: +.systemvmstring, .systemvmarray, .systemvmpackedarray, .systemvmdict, +.systemvmcheck. (zsysvm.c) + +Renames gcdefs.h as gscdefs.h. + +Allocates names in system space rather than global space. (gsmain.c) + +Changes the memory manager so that it allows programs to create objects in +system space. (iref.h, iutil.h, ivmspace.h, ...) + +Changes the implementation of filters so they appear in their own +dictionary named filterdict. (gs_init.ps, z*.c) + +Changes the implementation of color spaces so each one has its own +setcolorspace procedure, defined in a new dictionary named +colorspacedict. (gs_lev2.ps, z*.c) + +Adds a new debugging switch, $, that always initializes all fields in a +ref, in order to keep Purify happy. (store.h) + +Library +------- + +Fixes bugs: + - The page size for image devices was always set to (0, 0). +(gsdevice.c) + - The PageSize computation in gx_default_put_params could overflow +on 16-bit machines. (gsdparam.c) + - An omitted 'static' on an initialized array caused a compiler +error. (gxccman.c) + - If interpolated image rendering was requested but not +actually carried out, gs_image_cleanup could attempt to free a random +pointer. (gsimage.c) + - Some compilers only retain 23 characters of procedure names, but +some procedure names weren't unique in the first 23 characters. (gscie.c, +gscolor.c, gscolor1.c, gxcmap.c) + - The garbage collector didn't trace device colors properly. +(gxdcolor.h, gzht.h, gsimage1.c, gspcolor.c, gxcht.c, gxcmap.c, gxdraw.c, +gxht.c) + - For CMYK devices, the transfer functions were being applied to +the CMYK values rather than the complemented RGBW values. (gxcmap.c) + - Memory devices used their own color mapping procedures rather +than those of the target; this could cause incorrect colors for patterns on +devices with more than 1 bit per pixel. (gxdevmem.h, gdevmem1.c, gdevpm.c, +gdevprn.c, gdevwdib.c, gschar.c, gsdevice.c, gxccache.c, gxccman.c, +gxclip2.c, gxclread.c, gxpcmap.c) + - The garbage collector didn't trace image enumerators properly in +the image_render_simple case. (gsimage.c) + - stroke produced different-looking output for thin (zero-width) +lines depending on whether or not clipping was invoked. (gxstroke.c) + - If a clipping list changed from multiple rectangles to a single +rectangle, it could fail to clip properly thereafter. (gxacpath.c) + +Adds two new device procedures: alpha_bits and copy_alpha. This change is +backward-compatible for all existing devices. (gdevmem.h, gxdevice.h, +gsdevice.c, gxclip2.c, gxclist.c, gxcpath.c) + +Changes the implementation of color halftones so that, when appropriate, it +generates a single cell and uses the device tile_rectangle procedure. +(gzht.h, gsht.c, gxcht.c, gxclist.c, gxclread.c) + +Adds partial support for the Orientation page device parameter. +(gsdevice.c) + +Adds support for anti-aliased characters using 2 or 4 bits of alpha. +(gxfcache.h, gschar.c, gxccache.c) + +Version 3.13(private) (10/3/94) +===================== + +This release was created for a customer; it was not distributed to the +public. + +Documentation +------------- + +Notes in make.doc that the file names in the IJG archive distributed with +Ghostscript do not include the gsA.BC/ prefix. (make.doc) + +Adds a cross-reference to make.doc to the Watcom makefiles. (watc.mak, +watcwin.mak, wccommon.mak) + +Procedures +---------- + +Fixes bugs: + - The makefile rule for gconfig.h et al had a couple of blank lines +in the middle of it. (gs.mak) + +Utilities +--------- + +Fixes bugs: + - wrfont.ps didn't add a lenIV entry to the Private dictionary if +it was needed. (wrfont.ps) + +Adds a packfile.ps utility that allows compressing multiple files into a +single file for environments with very little permanent storage. +(gs_pfile.ps, packfile.ps, wrfont.ps) + +Drivers +------- + +Fixes bugs: + - The {tiff,fax}{g32d,g4} devices could produce incorrect output. +See under Streams below. + - The dfax drivers referred to the obsolete structure member +EncodedEOLAlign. (gdevdfax.c) + +Changes the default bit order for TIFF/F output to little-endian, which is +apparently what the majority of TIFF decoders like best. The bit order for +the fax drivers is still big-endian. (gdevdfax.c, gdevtfax.c) + +Platforms +--------- + +Fixes bugs: + - The VMS build script used -a rather than -w for creating +gconfig_.h. (vms.mak) + - The VMS build script didn't create gconfigv.h. (vms.mak) + - The VMS Fontmap had incorrect entries for the Bitstream Charter +fonts. (fontmap.vms) + - The VMS MODULES.LIS file assumed the JPEG library files were in +directory JPEG rather than JPEG-5. (modules.lis) + +Fonts +----- + +Fixes bugs: + - Using DISKFONTS resulted in an invalidaccess error. +(gs_fonts.ps) + +Interpreter +----------- + +Fixes bugs: + - The standard transfer function considered gray values above +roughly 0.994 equivalent to white; 0.999 is a better value. (gs_init.ps) + - The transfer, black generation, and undercolor removal functions +gave slightly inexact results for an input value of 0. (zcolor.c, +zcontrol.c) + - setpagedevice gave an /undefined error if it did not recognize a +key, rather than ignoring the key. (zdevice.c, gs_init.ps, gs_lev2.ps, +gs_setpd.ps) + +Changes .putdeviceparams to take an additional argument, a Boolean that +says whether or not unrecognized keys should be reported as /undefined +errors. THIS IS A NON-BACKWARD-COMPATIBLE CHANGE; however, no user-written +code should be calling .putdeviceparams. (zdevice.c) + +Streams +------- + +Fixes bugs: + - The Group 3 2-D and Group 4 fax encoders could emit incorrect +output. (scfe.c) + - The algorithm for constructing optimal Huffman codes could +produce invalid codes in some rare cases. (shcgen.c) + +Library +------- + +Fixes bugs: + - Rectangles closed with lineto rather than closepath weren't +recognized as rectangles. (This only affected performance, not +functionality.) (gxpath2.c) + - The xfont lookup_font procedure could get called with a matrix +whose translation components had never been initialized. (gxccman.c) + - Some compilers don't allow \ in the formal argument list of a +preprocessor macro. (gdevprn.h, gxdevice.h) + +Version 3.12 (9/29/94) +============ + +This is another bug fix release, the first Level 2 release that we believe +is reasonably reliable. + +Documentation +------------- + +Adds some text warning about making copies of the makefile. (make.doc) + +Procedures +---------- + +Fixes bugs: + - There were a number of unnecessary dependencies on $(MAKEFILE) in +gs.mak, left over from before the existence of gconfigv.h. (gs.mak) + - JPEGSRC was defined in gs.mak rather than in jpeg.mak. (gs.mak, +jpeg.mak) + +Changes the version numbering scheme back to A.BC, since people seem to be +adapting to the change, and this allows using the version number directly +as a MS-DOS directory name. (gconfig.c, gdevtfax.c, gs.c, gs_init.ps) + +Updates the JPEG library to version 5 (official release) of the IJG code. +(jpeg/*, jpeg.mak) + +Drivers +------- + +Fixes bugs: + - The TIFF/F driver put out invalid PageNumber and Software +entries. (gdevtifs.h, gdevtfax.c) + - The TIFF/F and fax Group 3 2-D drivers used K=3 and K=5 instead +of K=2 and K=4. (gdevtfax.c) + - The TIFF/F and fax Group 3 2-D drivers emitted improperly aligned +output. (See under Streams below.) + - The MS Windows driver didn't resize the window properly in +response to changing the device parameters. (gdevmswn.c) + +Because of complementary bugs in various C compilers, changes all the +non-printer devices to use a different set of macros. (gdevmem.h, +gdevpcfb.h, gdevprn.h, gdevsvga.h, gxdevice.h, gdev{3b1, bgi, herc, l256, +pe, pm, sun, vglb, wddb, wdib, wprn, x}.c, gsdevice.c, gxacpath.c, +gxclip2.c, gxcpath.c, gxpcmap.c, zupath.c) + +Changes the X11 driver to ignore the "margins" specified by Ghostview. +This is apparently necessary for Ghostview to handle landscape display +properly. (gdevxini.c) + +Adds a WindowID parameter to the X11 device, to allow setting the window +for the output. (gdevx.h, gdevx.c, gdevxini.c) + +Platforms +--------- + +Fixes bugs: + - The definition of BEGINFILES in os2.mak occurred too late in the +file to have the desired effect. (os2.mak) + +Interpreter +----------- + +Fixes bugs: + - Updating the list of allocated file objects at a restore didn't +clear the prev pointer of the new head, which could cause the garbage +collector to encounter an invalid pointer. (Bug introduced by .forgetsave +in 3.0.3.) (zfile.c) + +Streams +------- + +Fixes bugs: + - The CCITTFaxEncode filter with K > 0 and EncodedByteAlign = true +incorrectly aligned the 1-D/2-D bit as the last bit of a byte, rather than +the first bit. (scfx.h, scfe.c) + - eexec could loop indefinitely under certain conditions. +(seexec.c) + - eexec's algorithm for recognizing text vs. binary encoding didn't +work properly in some cases that don't conform to the Adobe Type 1 Font +Format documentation. (seexec.c) + - Closing a stream didn't clear out the strm and state pointers, +which could cause invalid accesses by the garbage collector. (stream.c) + +Library +------- + +Fixes bugs: + - fill_loop could loop indefinitely under certain conditions. +(Introduced by a bug fix in 3.1.) (gxfill.c) + - fill/eofill sometimes failed to paint parts of a region. +(Introduced by a bug fix in 3.1.1.) (gxfill.c) + - Non-convex clipping paths sometimes omitted thin horizontal +slivers of the region. (Probably introduced by the "thin graphics" fix in +3.1.) (gxacpath.c) + +Version 3.1.1 (9/25/94) +============= + +This is primarily a bug fix release. It was originally intended for some +commercial licensees, but beta testers found too many problems with it. + +Documentation +------------- + +Fixes bugs: + - NEWS didn't indicate that there was a non-backward-compatible +change in the gx_device structure -- specifically, that l_margin, +b_margin, r_margin, and t_margin were replaced by macros named +dev_l_margin(dev), etc. (news) + +Describes the two-phase commit requirement for device put_params +procedures. (drivers.doc, gsparam.h) + +Procedures +---------- + +Fixes bugs: + - The new S macro in genarch.c didn't work on compilers that do +macro substitution within string constants (which is forbidden by the ANSI +standard). (genarch.c) + +Drivers +------- + +Fixes bugs: + - Driver put_params implementations didn't observe a "two-phase +commit" discipline; this could lead to the current device in the graphics +state being closed, and other inconsistencies. (gsparam.h, gxdevice.h, +iparam.h, gdevbit.c, gdevcdj.c, gdevmswn.c, gdevpcfb.c, gdevpm.c, +gdevprn.c, gdevx.c, gsdevice.c, gsdparam.c, zdevice.c, ziodev2.c, zmisc2.c) +THIS IS A NON-BACKWARD-COMPATIBLE CHANGE; however, it only affects +put_params implementations, of which there are few. + +NOTE THE NON-BACKWARD-COMPATIBLE CHANGE IN THE gx_device STRUCTURE UNDER +'Documentation' ABOVE. (gdevescp.c, gdevsj48.c, gdevsppr.c, gdevxini.c) + +Platforms +--------- + +Ensures that the Unix makefiles all include all the variants of TIFF/F and +fax drivers. (ansihead.mak, cc-head.mak, gcc-head.mak) + +Interpreter +----------- + +Fixes bugs: + - Most of the contents of statusdict were missing when +running a Level 2 system in Level 1 mode. (zmisc2.c) + +Version 3.1 (9/20/94) +=========== + +This release finally includes a usable subset implementation of +setpagedevice, including all the machinery needed to address the +long-standing "margins" problems. + +Documentation +------------- + +Fixes bugs: + - t_oparray objects weren't identified as behaving differently +depending on whether they were marked executable. (iref.h) + - drivers.doc had gx_color_value instead of gx_color_index in +the description of color mapping. (drivers.doc) + +Updates drivers.doc to reflect the change from static_procs to +std_procs in the gx_device structure. (drivers.doc) + +Procedures +---------- + +Fixes bugs: + - The commands for building the JPEG library used rm instead +of rm -f. (jpeg.mak) + +Drivers +------- + +Fixes bugs: + - The X Windows driver hadn't been updated to reflect some +name changes in members of the gx_color_info structure. (gdevx.h, +gdevx.c, gdevxini.c) + +Changes all non-printer drivers so that they use the new std_device_body +macros. (gdev*.c) + +Adds a print_page_copies procedure for printer drivers, allowing the +driver to receive num_copies. (gdevprn.h, gdevprn.c) + +Interpreter +----------- + +Fixes bugs: + - ref_memory_enum/reloc_ptrs were declared inconsistently. +(ialloc.c) + - If the operand of restore was invalid, the restore did +nothing, instead of giving a typecheck. (zvmem.c) + - In Level 2, the margins and setmargins compatibility +operators were defined incorrectly in terms of current/setpagedevice. +(gs_lev2.ps) + +Enables .makeoperator to make local operators as well as global ones. +(opdef.h, iinit.c, zmisc.c, zpacked.c) + +Finishes implementing the TransferFunction entry in halftone +dictionaries. (zht1.c, zht2.c) + +Adds .set/currentfilladjust operators for access to the fill +adjustment parameter in the graphics state. (zgstate.h) + +Removes the deviceinitialmatrix operator. (zdevice.c) + +Changes defaultmatrix from a procedure to an operator. (zmatrix.c) + +Sets the fill adjustment to 0.5 for high-resolution devices, effectively +implementing Adobe's any-part-of-pixel filling rule. (gs_init.ps) + +Implements a small but useful subset of setpagedevice. (gs_lev2.ps) + +Streams +------- + +Fixes bugs: + - The eexec decoder incorrectly concluded that its data was +in hex form if the first data character was whitespace. (seexec.c) + +Library +------- + +Fixes bugs: + - Thin graphics (e.g., lines or rectangles) with small angles +relative to the X axis rendered with many points missing. (gxdraw.c, +gxfill.c) + - The character cache rejected oversampled characters if the +scaled-up size was too large, even if the scaled-down size wasn't. +(gxchar.h, gschar.c, gxccache.c, gxccman.c) + - A call on sqrt with an integer argument didn't promote it +explicitly to double, which is required for non-ANSI compilers. +(gshtscr.c) + +Finishes implementing the TransferFunction entry in halftone +dictionaries. (gsht1.c) + +Modifies the character oversampler so it can produce gray scale +output instead of a 1-bit mask. We don't actually make use of this +ability yet. (gxccman.c) + +Adds gs_set/currentfilladjust for access to the fill adjustment +parameter in the graphics state. (gsstate.h, gsstate.c) + +Changes the names of the last few routines beginning with gz_ to +begin with gx_ instead. (gzdraw.h => gxdraw.h, gsimage*.c, gxdraw.c, +gxfill.c, gxstroke.c) + +Properly implements the PageSize, Margins, .HWMargins, and ImagingBBox +device parameters for all devices. (gscoord.c, gsdparam.c, gspath2.c) +Implements the NumCopies device parameter for printer devices. +(gdevprn.c) + +Implements std_device_body macros to help insulate statically initialized +non-printer devices from future changes in the gx_device structure. +(gxdevice.h, ... many .c files ...) + +Version 3.0.3 (9/16/94) +============= + +This is primarily a bug fix release; it also implements most of the +remaining Level 2 loose ends (except for setpagedevice). + +Documentation +------------- + +Changes code that refers to "Ghostscript" to use the correct product +name from gs_product. (gs.mak, gdevpbm.c, gdevsun.c, gswppm.c) + +Documents the new .forgetsave operator. (language.doc) + +Clarifies the distinction between commercial licensing and single-copy +end-user sales. (readme) + +Procedures +---------- + +Fixes bugs: + - The compilation rule for gdevadmp.c was missing from the +makefile. (devs.mak) + +Changes the version numbering scheme back to A.B.C, since too many +people got confused by the change to A.BC. (gconfig.c, gs.c, +gs_init.ps) + +Adds a -dNOGC switch to prevent the garbage collector from being +enabled. (gs_init.ps) + +Utilities +--------- + +Removes the ps2image utility, since the new psmono driver replaces it. + +Drivers +------- + +Fixes bugs: + - The TIFF drivers incorrectly assumed that short and ulong +were the same size as TIFF_short and TIFF_ulong, causing problems on +64-bit systems. (gdevtfax.c) + - The EGA/VGA driver didn't do gray halftones properly if it +was configured as a monochrome or 8-color device. (gdevpcfb.h) + - The comment in gdevevga.c incorrectly identified the file +as gdevpcfb.c. (gdevevga.c) + +Changes the PC display drivers to save and restore more of the BIOS +state. (gdevpcfb.h, gdevevga.c, gdevpcfb.c, gdevsco.c) + +Adds a new psmono driver that does the same thing as ps2image, faster +and more conveniently. (gdevpsim.c) + +Replaces the X11 driver with the one from 3.01, since the color +handling rewrite in 3.02 introduced serious bugs. (gdevx.h, gdevx.c, +gdevxini.c) + +Platforms +--------- + +Changes the definition of gx_no_color_index to work around one of the +bugs in the SGI Irix compiler. (gxdcolor.h) + +Rewrites the installation commands in unix-end.mak so they don't have +very long lines. (unix-end.mak) + +Fonts +----- + +Fixes bugs: + - Fonts that used 2- or 4-element arrays in the Metrics dictionary +interpreted the width and side bearing interchanged with each other. +(gs_type1.ps) + - Setting FONTPATH on the command line didn't work. (gs_fonts.ps) + +Streams +------- + +Fixes bugs: + - The stream position wasn't updated properly if sgets +crossed a buffer boundary. (stream.c) + +Extends the BoundedHuffman filters so they can encode and decode runs of +zeros specially, and so they mark and detect EOD. (sbhc.h, shc.h, sbhc.c, +zfilter2.c) + +Provides an alternate implementation of file streams which doesn't use +stdio buffering and which works around the System V "interrupted system +call" problem. (stream.c, sfile.c, sfileno.c) + +Increases the maximum LZW output code from 3000 to 4095. (slzwe.c) + +Interpreter +----------- + +Fixes bugs: + - Opening a filter on a file of the wrong access type (read +vs. write) didn't cause an error. (stream.h, sbasic.c, zfile.c, zfileio.c) + - save performed an extra, unnecessary gsave. (zvmem.c) + - sethalftone always gave a /undefined error. (zht2.c) + - eexec decryption read too much data from the input -- in +Level 2, it isn't allowed to read 512 characters ahead. (sfilter.h, +strimpl.h, seexec.c, sstring.c, zfileio.c, zmisc1.c) + - The scanner was too aggressive about allocating additional +space for strings on small machines. (iscan.c) + - The AccurateScreens flag in Type 1 and Type 2 halftone +dictionaries was being ignored. (zht2.c) + - The Level 2 definition of margins in statusdict didn't +allow for Margins being undefined in the current page device. +(gs_lev2.ps) + - The Interpolate flag was being ignored in image +dictionaries. [implemented in library] + - The TransferFunction option was being ignored in halftone +dictionaries. (zht2.c) + - Type 5 halftones usually didn't work, because they called +the wrong (or an invalid) spot function. (zht2.c) + +Implements a .forgetsave operator that effectively causes a given save (and +all more recent saves) to disappear. (isave.h, stream.h, isave.c, zfile.c, +zvmem.c) + +Library +------- + +Fixes bugs: + - In the 1-operand form of the image operator, a Decode value of [1 +0] with 8-bit sample values and a single data source was treated the same +as [0 1]. (gsimage1.c) + - Some Monotype fonts put a callsubr between an OtherSubr call and +the following 'pop' opcodes (which the Adobe documentation forbids); The +Type 1 font interpreter gave an invalidfont error rather than allowing +this. (gxtype1.h, gstype1.c) + - Patterns didn't implement XStep and YStep properly. +(gxpcolor.h, gspcolor.c, gxclip2.c) + - Clipping regions were sometimes 1 pixel too small at the edges; +this could cause vertical and horizontal lines produced by certain Windows +drivers to disappear. (gzpath.h, gxacpath.c, gxcpath.c, gxfill.c) + - Oversampling cached rotated characters produced very bad +results (many dropouts). (gschar.c) + - Rendering a DeviceGray color on a DeviceCMYK device applied +the transfer function to all 4 components, not just to the K +component. (gxcmap.c) + - A screen specified with setcolorscreen didn't take effect +properly on CMYK devices. (gsht.c) + +Implements the Interpolate option for images. Currently this is only +implemented for portrait-orientation images (no rotation, skewing, or +X-reflection). (gscspace.h, gximage.h, gscie.c, gscolor.c, gscolor1.c, +gscolor2.c, gspcolor.c, gxcmap.c, gsimage.c, gsimage2.c, gsimage3.c) + +Implements AccurateScreens, but only in the form of a larger limit on +the size of a halftone super-cell. (gxht.h, gsht.c, gsht1.c) + +Starts to implement the TransferFunction option for halftones. +(gzht.h, gzstate.h, gsht.c, ...too many others to list...) + +Version 3.02 (8/30/94) +============ + +This is another bug fix release. It was distributed only to a few people, +since the new X Windows color mapping code is not reliable yet. + +Documentation +------------- + +Fixes bugs: + - make.doc, but not unixtail.mak, called for setting PLATFORM=unix_ +on SVR4 platforms. (unixtail.mak) + - drivers.doc contained some wording that suggested that +Ghostscript always used RGB colors internally. (drivers.doc) + - The definition of gx_device in drivers.doc had gotten out of sync +with gxdevice.h. (drivers.doc) + - README claimed that Ghostscript is not compatible with the +VAX/VMS DEC C compiler, which is no longer true. (readme) + +Adds a new section on printer drivers to drivers.doc. (drivers.doc) + +Adds a large number of new display boards to the 800x600 SVGA section of +use.doc. (use.doc) + +Adds a bug report form to the README file. (readme) + +Notes that OSF/1 AXP systems require changing the definition of INSTALL +from install to installbsd. (make.doc) + +Procedures +---------- + +Removes -Wno-uninitialized from the gcc flags, and fixes all the places (in +Aladdin's code only) that need to be fixed to pacify gcc after doing this. +(gcc-head.mak, gdevgif.c, gdevmem2.c, gdevpcl.c, gs.c, gsht1.c, gsimpath.c, +gsutil.c, gxclread.c, gxpcopy.c, gxstroke.c, idict.c, iscannum.c, stream.c, +zdevice2.c) (NOT FINISHED YET) + +Adds a FAKEFONTS switch that makes fake entries in FontDirectory for +unloaded fonts, for the benefit of programs that think they can find all +the available fonts by scanning FontDirectory. (gs_fonts.ps, gs_init.ps) + +Utilities +--------- + +Fixes bugs: + - ps2epsi didn't work, because setdevice now erases the page. +(ps2epsi.ps) + - ps2epsi didn't work, because -dNODISPLAY installs a null device +with 0 width and height. The fix -- to remove the -dNODISPLAY -- is not +satisfactory, because it opens an unnecessary window. (ps2epsi) + +Drivers +------- + +Fixes bugs: + - gdev_fax_open was incorrectly declared static in gdevtfax.c, +causing the extern reference in the dfax drivers not to be resolved. +(gdevtfax.c) + - devs.mak included a duplicate definition of gdevmswn_h. +(devs.mak) + - The fax drivers didn't link properly in Level 1 systems, because +shc.c was omitted from their dependency list. (gs.mak, devs.mak) + - The TIFF/F drivers didn't set RowsPerStrip properly. +(gdevtfax.c) + - The TIFF/F drivers didn't byte-align the EOL properly. (scfx.h, +gdevdfax.c, gdevtfax.c, scfe.c, zfilter2.c) + - The rule for compiling gdevpccm.c incorrectly specified +dependency on gs.h rather than gx.h. (devs.mak) + - The rule for compiling gdevtfax.c didn't include time_.h as a +dependency. (devs.mak) + - The mode 2 compression routine for the DeskJet/LaserJet printers +was broken. (gdevpcl.c) + +Removes the -O0 from the compilation rule for gdevsco.c, since it was +misplaced to begin with. (devs.mak) + +Adds a maxDynamicColors X resource to control dynamic allocation in the +color map. Replaces the X color lookup algorithms with completely new +ones, for a substantial performance gain. (gdevx.h, gdevx.c, gdevxini.c) + +Adds PageNumber, Software, and DateTime entries to the TIFF/F drivers. +(gdevtifs.h, gdevtfax.c) + +Changes the margins for the LaserJet 4 to 0. (gdevdjet.c) + +Adds a user-contributed LaserJet 4 driver that does Floyd-Steinberg +dithering. (gdevcdj.c) + +Platforms +--------- + +Fixes bugs: + - The exit codes for Ghostscript should be different on VMS. +(iastate.h, gs.c, gsmain.c, igc.c, igcref.c) + - The VMS DEC C compiler declares malloc and free in stdlib.h, and +delete and unlink in stdlib.h. (malloc_.h, stdio_.h) + - st_prn_device wasn't defined, which upset the VMS linker even +though there were no references. (gdevprn.h) + - stdpre.h didn't bring in the right headers when running gcc on +SCO Unix, causing compilation warnings/errors. (stdpre.h) + - The definition of rename in gp_sysv didn't include const for the +arguments. (gp_sysv.c) + - The definition of gettimeofday in gp_sysv didn't return any +value. (gp_sysv.c) + - time_.h didn't work on MS-DOS systems. (time_.h) + - math_.h didn't include when compiling with gcc on VMS +systems. (math_.h) + - DesqView/X doesn't have a 'cat' command, which caused problems in +the linking step. (dvx-tail.mak) + +Changes the definitions of popen in gdevpipe.c and gp_unix.c so they don't +specify the argument list. This is an attempt to get around the fact that +there is no easy way to detect whether the available header files declare +popen correctly (with const arguments), incorrectly (with non-const +arguments), or not at all. (gdevpipe.c, gp_unix.c) + +Replaces VMS.MAK, VMS-CC.MAK, and VMS-AXP.MAK with new versions provided by +a user. (vms.mak, vms-cc.mak, vms-axp.mak) + +Changes the 16-bit Borland makefiles so their standard configuration is +Level 1 plus color.dev (CMYK color and colorimage). (bc.mak, bcwin.mak) + +Fonts +----- + +Fixes bugs: + - cfonts.mak still referred to some .gsf files that have been +replaced by .pfa files. (cfonts.mak) + - Compiled fonts got entered into FontDirectory, but didn't get +registered as resources. (gs_ccfnt.ps) + - The Cyrillic, Kana, Hershey .gsf, and URW fonts didn't include a +necessary systemdict begin/end, which caused them to fail in badly designed +environments. (fonts/f*.gsf, fonts/h*.gsf, fonts/?0*.gsf) + +Changes the default target directory in cfonts.mak from fonts/c to .; +changes the names of the Zapf Chancery compiled font procedures from c* to +zc*. (cfonts.mak) + +Adds more fonts from the Adobe Type Manager package for MS Windows to +Fontmap.ATM. (fontmap.atm) + +Adds the entire set of 35 standard fonts to the ccfonts feature in gs.mak; +removes all the compilation rules for compiled fonts, since these rules are +in cfonts.mak already. (gs.mak) + +Interpreter +----------- + +Fixes bugs: + - kshow executed a null, rather than the correct procedure, between +the characters of the string, and got a typecheck error at the end. +(zchar.c) + - MultiMaster fonts computed their side bearing and width +incorrectly, producing incorrect output. (zchar1.c) + - There was no structure definition for gs_type1_state, so a GC +during the execution of an OtherSubrs procedure could scramble pointers in +the saved state. (zchar1.c, zfont1.c; also affects library, see below) + - kshow didn't work properly if the kerning procedure changed the +depth of the operand or dictionary stack. (zchar.c) + - If the element count for roll was too large by only 1 or 2, the +result was a crash rather than a rangecheck. (zstack.c) + - restore didn't undo currentgstate. (igstate.h, store.h, +gsstate.c, zdevice2.c, zdps1.c, ztype.c) + - The scanner didn't set the local bit properly in a suspended +state. (iscan.c) + - copypage disregarded #copies. (gs_init.ps) + - An incorrectly declared pointer led to addressing faults on +16-bit systems. (zchar1.c) + - The cache for Separation colors was allocated with one element +too few. (zcsindex.c) + +Changes `executive' so that if an error other than EOF occurs in the +reading of the statement, the interpreter prints the error message, but +control remains in the executive loop. (This isn't a very good fix; a +better one will require refactoring executive / execute / run.) +(gs_init.ps) + +Changes dictionary undo saving to use the new ref_must_save macro [internal +change only]. (idict.c) + +Moves configuration definitions from iinit.c to gconfig.c. (gcdefs.h, +interp.h, gconfig.c, gs.c, iinit.c, zmisc2.c, gs.mak) + +Moves =string from systemdict to userdict for Adobe compatibility. +(gs_init.ps) + +Starts to implement the Interpolate flag in image dictionaries. See under +Library below for restrictions. (zpaint.c, zimage2.c) + +Streams +------- + +Fixes bugs: + - stream_compact attempted to compact a read-only string being used +as the data source of a filter. (sbasic.c, stream.c) + +Adds an EncodedEOLAlign flag to the CCITTFaxEncode stream, to allow direct +generation of TIFF/F output. (scfx.h, scfe.c, zfilter2.c) + +Library +------- + +Fixes bugs: + - There was no structure definition for gs_type1_state, so a GC +during the execution of an OtherSubrs procedure could scramble pointers in +the saved state. (gxfont1.h, gxtype1.h, gstype1.c, gxhint2.c) + - A couple of calls had to discard const, but didn't include the +necessary cast. (gxpcmap.c) + - makeimagedevice refused to accept an empty image. (gsdevice.c) + - The extra parentheses around arguments in memory_.h caused some +compilers to fail. (memory_.h) + - Floating point overflows during coordinate conversion terminated +Ghostscript. (gxfarith.h, gxfixed.h, gsmatrix.c, gsmisc.c) + - Accents still weren't getting placed properly on characters +created with seac. (gstype1.c, gxhint2.c) + - The SGI C compiler couldn't handle the (perfectly legal) +definitions of dev_init_[open_]misc. (gxdevice.h) + - string_.h caused some problems with gcc on some versions of +Solaris. (string_.h) + - The halftone levels for color screens were computed incorrectly. +(gzht.h, gxdither.c) + - Color screens sometimes had vertical stripes of solid color +interspersed. (gxcht.c) + - Colors could get mapped incorrectly if a compiler aggressively +(and incorrectly) reordered the computation of procedure arguments +involving the unit_frac macro. (gxcmap.c) + - setcachedevice[2] insisted that the corners of the bounding box +be given in the correct order, i.e., llx < urx and lly < ury. (gschar.c) + - The image operator gave a limitcheck on unrotated 1-bit-per-pixel +images whose width in device coordinates exceeded 65529. (gsimage.c) + - The garbage collector didn't trace the input data of an +in-progress image operator correctly. (gsimage.c) + +Changes the max_rgb and dither_rgb members of gx_device_color_info to +max_color and dither_colors, since Ghostscript now uses these for CMYK +devices as well. Also changes dither_gray to dither_grays. (gdevmem.h, +gdevprn.h, gxdevice.h, gdevbit.c, gdevcdj.c, gdevprn.c, gdevxini.c, +gsdparam.c, gxcht.c, gxcmap.c) + +Starts to implement the Interpolate option for images. Currently this is +only implemented for image, not imagemask, and only for rotations that are +multiples of 90 degrees (possibly with reflection). (gsimage.h, +gsiscale.h, gximage.h, gsimage.c, gsimage1.c, gsiscale.c) + +Starts to implement XStep and YStep in pattern dictionaries. (gxdcolor.h, +gxpcolor.h, gspcolor.c, gxpcmap.c) + +Version 3.01 (8/14/94) +============ + +This is a patch release to fix early problems in release 3.0, and to clean +up a few known loose ends. + +Documentation +------------- + +Fixes bugs: + - language.doc still documented the devicename procedure, which has +been withdrawn. (language.doc) + - drivers.doc didn't specify under what circumstances each +procedure could be called. (drivers.doc) + - current.doc said that setcachedevice and makeimagedevice wouldn't +accept packed arrays, but neither of these operators takes any array +arguments. (current.doc) + - current.doc said that definefont didn't interact properly with +the resource machinery, which apparently is no longer true. (current.doc) + - make.doc incorrectly gave the name of the DVX makefile as +dvx-djg.mak rather than dvx-gcc.mak. (make.doc) + - In one place, devices.doc incorrectly used -sBitsPerPixel= rather +than -dBitsPerPixel=. (devices.doc) + +Notes that a kernel bug in SCO Unix makes Ghostscript not work correctly in +some circumstances. (use.doc) + +Procedures +---------- + +Fixes bugs: + - devs.mak incorrectly referred to gdevjetp.c instead of +gdev3852.c. (devs.mak) + - The obsolete file gsprops.c was accidentally included in the +fileset. + +Changes the version numbering scheme from A.BCC to A.B[C]. E.g., this +release will be 3.01, not 3.001. (gs_init.ps, gs.c, iinit.c) + +Adds the LaserJet 4 driver to all makefiles that already include the +LaserJet 3 driver. (*.mak) + +Adds the BJ-200 driver to all makefiles that already included the BJ-10e +driver. (*.mak) + +Splits the Unix 'install' target into install-exec and install-data. Moves +the executable scripts from gsdatadir to a new directory scriptdir, which +defaults to bindir. (ansihead.mak, cc-head.mak, gcc-head.mak, +unix-end.mak) + +Utilities +--------- + +Fixes bugs: + - genconf had fixed buffer sizes built into it, which it could +overrun its working storage without checking. (genconf.c) + +Removes RCS or SCCS headers from two utility files. (pj-gs.sh, +printafm.ps) + +Drivers +------- + +Fixes bugs: + - The new dfaxhigh and dfaxlow drivers didn't set +state.EncodedByteAlign to false. (gdevdfax.c) + - The sunview driver assumed that the device would be open before +map_rgb_color was called. (gdevsun.c) + - The CP50 driver incremented page_count itself, rather than +letting the core library do it. (gdevcp50.c) + - The GIF driver(s) could loop indefinitely under certain +circumstances. (gdevgif.c) + - The Group 4 fax drivers incorrectly included end-of-line codes in +the output. (gdevtfax.c, gdevdfax.c) + - The Group 4 fax drivers could put out an EOB in the middle of the +data. (scfe.c) + - The DesignJet 650C driver didn't use the correct compression +mode. (gdevcdj.c) + - The Hercules and EGA/VGA/SVGA drivers computed the page height +incorrectly according to the A4 switch. (gdevherc.c, gdevpcfb.h) + +Changes the page_count and showpage_count members of the device structure +from int to long. (gxdevice.h, gdevprn.c, gsdparam.c) + +Changes the faxg3, faxg32d, and faxg4 drivers so that, like the TIFF and +dfax drivers, they adjust the page size to one of the three CCITT standard +sizes if this is reasonable. (gdevtfax.c) + +Splits the bit driver into bit, bitrgb, and bitcmyk. Adds bitrgb and +bitcmyk to all makefiles that included bit. (*.mak, devs.mak, gdevbit.c) + +Replaces the atiw16, tseng16, and tvga16 SuperVGA drivers with a single +svga16 driver that allows specifying the display mode number. (devs.mak, +gdevpcfb.c) + +Platforms +--------- + +Fixes bugs: + - The MS Windows and OS/2 drivers allocated their terminal input +buffers in a way that could cause the GC to crash. (gp_mswin.c, gp_os2.c) + - The handling of gettimeofday on SVR4 platforms was incorrect. +(time_.h, gp_sysv.c, gp_unix.c) + - On some platforms, function prototypes were not enabled even if +__STDC__ was defined. (stdpre.h) + - The VMS build script referred to an obsolete feature lev2only. +(vms.mak) + +Changes the DVX platform so that stdprn is buffered. This should improve +printing performance dramatically. (gp_dvx.c) + +Fonts +----- + +Fixes bugs: + - Setting DISKFONTS resulted in a reference to FontFileDirectory +before it was defined. (gs_type1.ps, gs_fonts.ps) + - /Font findresource gave an error rather than doing font +substitution. (gs_res.ps) + - FontDirectory wasn't rebound to GlobalFontDirectory when global +VM was current. (gs_res.ps, zdict.c) + - Type 1 fonts weren't loaded into global VM. (gs_fonts.ps) + - In the standard Fontmap, the Utopia fonts had extension .gsf +rather than .pfa. (fontmap.gs) + - Fonts whose FontBBox was [0 0 0 0] were not displayed, or were +displayed as tiny dots. (gs_type1.ps) + +Interpreter +----------- + +Fixes bugs: + - dict_put could read from the variable pvslot before it was used. +(This was harmless, since the value was never actually used; it just upset +Purify.) (idict.c) + - Binary object sequences could cause addressing faults. +(iscanbin.c) + - The attributes on names were set incorrectly in binary object +sequences. (iscanbin.c) + - gs.c duplicated (in some cases incorrectly) some definitions in +interp.h. (gs.c) + - gs_lib_paths was declared const in one place and non-const in +another. (zfile.c) + - file_restore and font_restore had inconsistent const declarations +for their argument. (isave.c) + - iodev_os_open_file was missing its last formal parameter. +(ziodev.c) + - gs.c declared gs_devicename with an incorrect extern. (gs.c) + - undefinefont didn't interact properly with the resource +machinery. (gs_lev2.ps) + - The declaration for swap_entry used a typedef name as a formal +parameter, which upset some compilers. (zmisc2.c) + - Including the ccinit feature could cause the garbage collector to +make an invalid access. (stream.c) + - The check for t_[a]struct types in ztype.c was incorrect. +(ztype.c) + - After the collection of halftone samples, temporary data +structures were freed incorrectly. (gzht.h, gsht1.c, zht.c) + - Images with source width between 489 and 492 crashed the +memory manager. (iastate.h) + +Makes it possible to define SEARCH_HERE_FIRST (gsmain.c) in the makefile. +(gsmain.c) + +Splits the Level 2 resource machinery into a separate file. (gs_lev2.ps, +gs_res.ps, gs.mak, unix-end.mak, vms.mak). + +Changes the names of the DiffEncode/Decode filters to +PixelDifferenceEncode/Decode, and splits them off into a separate +"feature". (gs.mak, zfilter2.c, zfpdiff.c, spdiff.c, spdiffx.h) + +Adds experimental code for filtered image scaling. DON'T USE THIS CODE. +(zimage2.c) + +Streams +------- + +Fixes bugs: + - The CCITTFaxEncode filter could put out an EOB in the middle of +the data. (scfe.c) + +Splits off the PixelDifferenceEncode/Decode filters into a separate +"feature". (gs.mak) + +Library +------- + +Fixes bugs: + - gs_setcachedevice could return a garbage error code. (gschar.c) + - joins on stroked lines were incorrect if the device coordinate +system mapped +Y to +Y. (gxstroke.c) + - If gsmisc.c supplied versions of missing library routines, they +could clash with the names of the real ones if those were present +unexpectedly. (memory_.h, gsmisc.c) + - The initialization expression for is_open in the +dev_init_misc_open macro included a cast, which some compilers don't allow. +(gxdevice.h, gsdevice.c, gxclip2.c, gxpcmap.c) + - In Type 1 fonts, character that specified their side bearing and +width with sbw rather than hsbw gave an invalidfont error. (gstype1.c) + - Some procedures were declared inconsistently with regard to const +arguments. (gscie.c, gxpcmap.c, gxacpath.c, gxcmap.c) + - A few places still assumed that pointers occupied 4 bytes. +(gxclist.c) + - Rendering a gray halftone on a CMYK device called the device's +map_rgb_color procedure instead of map_cmyk_color. (gxdither.c) + +Renames gsfile.c as gswppm.c. (gsfile.c, gswppm.c) + +Implements the ability to cache arbitrarily transformed characters. This +is currently enabled by a compile-time flag in gschar.c. (gschar.c) + +Version 3.0 (8/1/94) +=========== + +This is the first full Level 2 version released to the public. +Unfortunately, we were not able to include setpagedevice in this release. + +Documentation +------------- + +Fixes bugs: + - README didn't mention Aladdin's European distributor. + - psfiles.doc didn't describe some of the newer gs_*.ps files. + +Notes that gcc -O2 (version 2.5.8 of gcc) generates incorrect code for some +modules on the H-P RISC architecture. + +Notes that on AXP platforms running VMS, DEC C V4.0 is required. + +Procedures +---------- + +Fixes bugs: + - 'make clean' didn't delete devs.tr or t.tr. + - devs.mak was missing the entry for faxg32d. + - unixansi.mak omitted some drivers that were included in +unix-cc.mak and unix-gcc.mak. + +Updates jpeg.mak to reference version 5beta1 of the IJG JPEG code. + +Changes the version numbering scheme from A.B.C to A.B[CC]. I.e., the +first sub-release after 3.0 will be 3.01 or 3.001, not 3.0.1. + +Utilities +--------- + +Fixes bugs: + - ps2ascii didn't do a setglobal. + +Adds an option to ansi2knr to convert ... to va_alist/va_dcl. + +Drivers +------- + +Fixes bugs: + - The newly added faxg32d driver didn't have an entry in devs.mak. + - The BMP, GIF, and PCX drivers wrote out an incorrect color +palette (the blue values were too small). + - The vgalib driver had some compilation problems. + - The TIFF drivers didn't produce correct multi-page output. + +Adds faxg32d and tiffg32d drivers. + +Reinstates the DigiFax drivers, which were withdrawn when the new fax +drivers were added. + +Platforms +--------- + +Fixes bugs: + - gs_btokn.ps and gs_ccfnt.ps weren't installed on Unix platforms. + - The VMS module list omitted SBHC, included a non-existent GXDASH, +and had incorrect names for some of the IJG JPEG files. + - The VMS build scripts (vms*.mak) had incorrect "boilerplate". + - The VMS script file gssetmod.com had \r characters in it, as well +as \n characters. + - The echogs and genarch utilities didn't return the correct exit +codes under VMS. + - The VMS Fontmap had incorrect entries for the Courier and Charter +fonts. + - When running under Ghostview, Ghostscript didn't drain the input +pipe. (We fixed this with a temporary patch in gs.c; this isn't a good +solution for the longer term.) + +Fonts +----- + +Fixes bugs: + - The free AvantGarde, Bookman, and Palatino font families had +incorrect FontBBox values. + - The 'f' and 'j' in the free AvantGarde-DemiOblique, +Bookman-DemiItalic, Bookman-LightItalic, and Palatino-Italic fonts were +chopped off on the right. (The bitmaps were chopped off in the original +BDF fonts from which these fonts were made.) ****** THIS PROBLEM WAS NOT +ACTUALLY FIXED. ****** + +Interpreter +----------- + +Fixes bugs: + - gs -h and gs -v didn't print the tertiary version number correctly. + - Binary object sequences with no strings or names didn't read in +correctly. + - Binary object sequences that crossed an input buffer boundary +didn't read in correctly. + - Binary object sequences read in as {[e1 .. en] e1 ... en} instead +of {[e1 ... en]}. (New bug in 2.9.x.) + - setpattern didn't set the current color space correctly if the +current color space wasn't a Pattern space. + - If the current color space was an uncolored Pattern space but the +current color was a colored Pattern, currentcolor returned extra values on +the operands stack. + - .buildfont1 in gs_type1.ps didn't force binding of the old +definition, causing ps2ascii to loop endlessly. + +Adds a facility for writing and reading dictionaries in binary object +sequences. This is experimental and subject to change in the future. + +Streams +------- + +Fixes bugs: + - gs_run_string and ccinit didn't have any way to mark the string +as "foreign", which confused the GC. + +Library +------- + +Fixes bugs: + - gxchar.h had an extra comma after the last element of the +show_width_status enum, which upset some compilers. + - stroke and strokepath didn't correctly skip zero-length segments +if the line width was less than one pixel, or if there was a closed subpath +consisting entirely of zero-length segments. + - strokepath sometimes incorrectly added a moveto at the end of the +path. + +Versions before 3.0 +=================== + +See the files history2.txt and history1.txt. diff --git a/gs/humor.txt b/gs/humor.txt new file mode 100644 index 000000000..67daff416 --- /dev/null +++ b/gs/humor.txt @@ -0,0 +1,50 @@ + Copyright (C) 1989 Aladdin Enterprises. All rights reserved. + + This file is part of Aladdin Ghostscript. + + Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author + or distributor accepts any responsibility for the consequences of using it, + or for whether it serves any particular purpose or works at all, unless he + or she says so in writing. Refer to the Aladdin Ghostscript Free Public + License (the "License") for full details. + + Every copy of Aladdin Ghostscript must include a copy of the License, + normally in a plain ASCII text file named PUBLIC. The License grants you + the right to copy, modify and redistribute Aladdin Ghostscript, but only + under certain conditions described in the License. Among other things, the + License requires that the copyright notice and this notice be preserved on + all copies. + +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +This file, humor.txt, contains a humorous message, verbatim except for +minor spelling corrections, received from a friend out in network-land. + +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +Regarding Ghostscript: I hate to say this to you but I've already +implemented a Ghostscript interpreter. I'm happy to see that someone else +has recognized the need dead people have for computers. I have included an +example of the output of my Ghostscript at the end of this letter. + +The interpreter is written in a language called cant-C, developed by Mr. +Turing last year. The compiler is easily ported to any environment you +care to name. I would be more than happy to send you a copy, but you must +first contact my lawyer for this venture, Thomas Jefferson of Phila. Pa.. +(As a side note, Mr. Jefferson is very excited by Ghostscript. Look for +The Declaration of Independance V1.1 RSN). + +The possibilities for Ghostscript go far beyond Deathtop publishing, I'm +sure you'll agree. I have contacted numerous authors who may be interested +in using Ghostscript (Shakespeare, Hemingway, etc) and all have been very +excited by what they've seen. (Shakespeare wants to write a modern Romeo +and Juliette, called Romeo and Julio, the story of 2 gay hispanic men kept +apart by their parents.) + +Anyway, here is the Ghostscript example I promised. Feel free to show this +to your friends and colleagues, I'm sure they'll all be suitably impressed. + + +------Cut Here-------------------------------------- + +------Cut Here-------------------------------------- diff --git a/gs/install.txt b/gs/install.txt new file mode 100644 index 000000000..98716923b --- /dev/null +++ b/gs/install.txt @@ -0,0 +1,256 @@ + Copyright (C) 1995, 1996 Aladdin Enterprises. All rights reserved. + + This file is part of Aladdin Ghostscript. + + Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author + or distributor accepts any responsibility for the consequences of using it, + or for whether it serves any particular purpose or works at all, unless he + or she says so in writing. Refer to the Aladdin Ghostscript Free Public + License (the "License") for full details. + + Every copy of Aladdin Ghostscript must include a copy of the License, + normally in a plain ASCII text file named PUBLIC. The License grants you + the right to copy, modify and redistribute Aladdin Ghostscript, but only + under certain conditions described in the License. Among other things, the + License requires that the copyright notice and this notice be preserved on + all copies. + +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +This file, install.txt, describes how to install the Ghostscript language +interpreter. + +For an overview of Ghostscript and a list of the documentation files, see +README. + +******** +******** How to install Ghostscript ******** +******** + +There are 3 separate items that you must have available in order to be able +to run Ghostscript: + + (1) The Ghostscript executable file(s) -- on some operating + systems, more than one file is required. These are entirely + platform-specific. See below for details. + + (2) Initialization files that Ghostscript reads in when it + starts up. These are the same on all platforms. + + (3) Fonts, for rendering text. These are platform-independent, + but if you already have fonts of the right kind on your platform, + you may be able to use them. See below for details. See the + companion document fonts.txt for more information about fonts. + +The initialization files (2) are the same on all platforms: + + - gs_*.ps (see psfiles.txt for the full list), unless Ghostscript was + compiled using the "compiled initialization files" option. + + - pdf_*.ps, if Ghostscript was compiled with the ability to + interpret PDF files (pdf.dev included in FEATURE_DEVS). + + - Fontmap, unless you plan to always invoke Ghostscript with the + -dNOFONTMAP switch. + +See the search algorithm section of use.txt for a description of the search +algorithm used to find these files. + +The per-platform descriptions that follow tell you where to install these +files. + +MS-DOS +------ + +You need the following files to run Ghostscript: + GS386.EXE + DOS4GW.EXE + +You should install all the files except the fonts in C:\GS, and the +fonts in C:\GS\FONTS. + +If you have Adobe Type Manager fonts installed on your system, and you wish +to use them with Ghostscript, you may wish to replace the FONTMAP file with +FONTMAP.ATM, and to add to the environment variable GS_LIB the name of the +directory where the fonts are located (see below for more information about +GS_LIB). Before you do this, please read carefully the license that +accompanies the ATM fonts; Aladdin Enterprises takes no responsibility for +any possible violations of such licenses. Similarly, if you have Adobe Type +Basics, you may wish to replace FONTMAP with FONTMAP.ATB. Finally, if you +have neither ATM nor ATB but you have Adobe Acrobat installed, you can use +the 14 Acrobat fonts in place of the ones provided with Ghostscript by +removing the following entries from FONTMAP: + Courier, Courier-Bold, Courier-BoldOblique, Courier-Oblique + Helvetica, Helvetica-Bold, Helvetica-BoldOblique, Helvetica-Oblique + Symbol + Times-Bold, Times-BoldItalic, Times-Italic, Times-Roman + ZapfDingbats +and adding the Acrobat fonts directory to GS_FONTPATH. + +MS Windows +---------- + +Win32s or Windows 95 or Windows NT is required. You need the following +files to run Ghostscript: + GSWIN32.EXE + GSWIN32C.EXE + GSDLL32.DLL + GS16SPL.EXE (Win32s only) + +You should install all the files except the fonts in C:\GS, and the fonts in +C:\GS\FONTS. + +The GSview previewer contains an installation program to install and +configure GSview and Ghostscript for Win32. Information on GSview is +available from: + http://www.cs.wisc.edu/~ghost/gsview/ + +See under "MS-DOS" above for information about using Adobe Type Manager, +Adobe Type Basics, or Adobe Acrobat fonts. + +If your system uses TrueType fonts, you can get them converted to a +Ghostscript-compatible format at the time you select your "printer" by +doing the following: + +1) Open control panel and double click on the printers icon. +2) Select your Postscript Printer. +3) Choose Setup. +4) Choose Options. +5) Choose Advanced. +6) At the top of the Dialog Box you will see TrueType Fonts + Send to Printer As: + Choose Adobe Type 1. +7) Uncheck Use Printer Fonts for All TrueType Fonts + and Use Substitution Table. +8) OK. +9) OK etc. + +That's it! Your TrueType fonts will automatically be downloaded in your +PostScript file for Ghostscript to use. + +For printer devices, the default output is: + the default printer (Win95 or WinNT) +OR + prompt for a printer port (Win32s). +This can be modified as follows. + -sOutputFile="LPT1:" + Output to named port. + -sOutputFile="\\spool\printer name" (Win95 or WinNT only) + Output to named printer. + -sOutputFile="\\spool" (Win95 or WinNT only) + Prompt for printer name. Local printers only are supported. +For Win32s, make sure that gs16spl.exe is in the same directory +as gswin32.exe. + + +OS/2 2.x +-------- + +The Ghostscript OS/2 implementation is designed for OS/2 2.1 or later. +A few people have used it successfully under OS/2 2.0, but it has had +very little testing. + +You need the following files to run Ghostscript: + GSOS2.EXE - this is a text application that will run windowed or + full screen. + GSDLL2.DLL - this is a Dynamic Link Library that must be in the same + directory as GSOS2.EXE or on the LIBPATH. + GSPMDRV.EXE - this is an "external driver" used by the "os2pm" + device, which is normally the default device and which + displays output in a Presentation Manager window. + GSPMDRV.EXE must be located in the same directory as + GSOS2.EXE or on the PATH. + +GSOS2.EXE, GSDLL2.DLL and GSPMDRV.EXE are compiled using EMX/GCC 0.9b. +You must have the EMX DLL's on your LIBPATH. These are available from + ftp://hobbes.nmsu.edu/os2/unix/emx09b/emxrt.zip + +The system menu of the Ghostscript Image window includes a "Copy" command +to copy the currently displayed bitmap to the Clipboard. + +OS/2 comes with some Adobe Type Manager fonts. If you wish to use these +with Ghostscript, you should replace the FONTMAP file with FONTMAP.OS2, +and add to the environment variable GS_LIB the name of the directory where +the fonts are located, usually c:\psfonts. (see below for more +information about GS_LIB). Before you do this, please read carefully the +license that accompanies the ATM fonts; Aladdin Enterprises takes no +responsibility for any possible violations of such licenses. + +Since GSOS2.EXE is not a PM application, it cannot determine the depth of +the PM display. You must provide this information using the +-dBitsPerPixel option. The default is 8 bits/pixel. Valid values are 1, +4, 8 & 24. + For monochrome VGA use -dBitsPerPixel=1 + For standard VGA screen use -dBitsPerPixel=4 + For 256 colour SVGA use -dBitsPerPixel=8 +A command file gspm.cmd containing the following line may be useful: + @c:\gs\gsos2.exe -Ic:/gs;c:/gs/fonts;c:/psfonts -sDEVICE=os2pm + -dBitsPerPixel=8 -sPAPERSIZE=a4 %1 %2 %3 %4 %5 %6 %7 %8 + +While drawing, the os2pm driver updates the display every 5 seconds. On +slow computers this is undesirable and a different interval can be +specified in milliseconds with the -dUpdateInterval option. The default +is -dUpdateInterval=5000; to disable update use -dUpdateInterval=0. + +Standard VGA is very slow due to double buffering to avoid bugs and due to +1 plane to 4 plane conversion. Use a 256 color display driver by +preference. Many display drivers have bugs which cause 1 bit/pixel +bitmaps to be displayed incorrectly. + +GSOS2.EXE and GSPMDRV.EXE will stay in memory for the number of minutes +specified in the environment variable GS_LOAD. + +If you run GS386 in the OS/2 2.0 or 2.1 DOS Box, you must select the +"ENABLED" setting for the DPMI_DOS_API option of the DOS Box. GS386 +will not run with the "AUTO" setting. + +For printer devices, output goes to the default queue. +To print to a specified queue, use -sOutputFile=\\spool\NullLPT1 +where NullLPT1 is the queue physical name. + +Unix +---- + +You need the following file to run Ghostscript: + gs + +Installing Ghostscript on a Unix system requires compiling it first: please +read the Unix section(s) in make.txt for more information, especially +regarding how to decide which makefile to use and how you may need to edit +it. After building, execute + make install + +The makefile installs all the files, except the fonts, in /usr/local or +various subdirectories thereof. The fonts should be installed in +/usr/local/share/ghostscript/fonts. Consult the makefile for more details. +If you have Adobe Acrobat installed, you can use the 14 Acrobat fonts in +place of the ones provided with Ghostscript by removing the following +entries from Fontmap: + Courier, Courier-Bold, Courier-BoldOblique, Courier-Oblique + Helvetica, Helvetica-Bold, Helvetica-BoldOblique, Helvetica-Oblique + Symbol + Times-Bold, Times-BoldItalic, Times-Italic, Times-Roman + ZapfDingbats +and adding the Acrobat fonts directory to GS_FONTPATH. + +NOTE: The syntax of the 'install' command varies unpredictably between Unix +systems. If your system has an 'installbsd' program, edit the definition of +INSTALL in the makefile to change 'install' to 'installbsd' before you run +'make install'. + +VMS +--- + +You need the following executable file to run Ghostscript: + GS.EXE + +Installing Ghostscript on a VMS system requires compiling it first. + +You should install all the files, including the fonts, in the same directory +as the executable and initialization files. By default, this is the +directory in which you did the compilation. Consult the makefile +(OPENVMS.MAK) for more details. + +If you have DECWindows/Motif installed, you may wish to replace the FONTMAP +file with the file FONTMAP.VMS. Read the comment at the beginning of the +latter file for more information. diff --git a/gs/jpeg/Makefile b/gs/jpeg/Makefile new file mode 100644 index 000000000..ce0c45f1c --- /dev/null +++ b/gs/jpeg/Makefile @@ -0,0 +1,274 @@ +# Generated automatically from makefile.cfg by configure. +# Makefile for Independent JPEG Group's software + +# makefile.cfg is edited by configure to produce a custom Makefile. + +# Read installation instructions before saying "make" !! + +# For compiling with source and object files in different directories. +srcdir = . + +# Where to install the programs and man pages. +prefix = /usr/local +exec_prefix = ${prefix} +bindir = $(exec_prefix)/bin +libdir = $(exec_prefix)/lib +includedir = $(prefix)/include +binprefix = +manprefix = +manext = 1 +mandir = $(prefix)/man/man$(manext) + +# The name of your C compiler: +CC= gcc + +# You may need to adjust these cc options: +CFLAGS= -O -I$(srcdir) +# Generally, we recommend defining any configuration symbols in jconfig.h, +# NOT via -D switches here. +# However, any special defines for ansi2knr.c may be included here: +ANSI2KNRFLAGS= + +# Link-time cc options: +LDFLAGS= + +# To link any special libraries, add the necessary -l commands here. +LDLIBS= + +# Put here the object file name for the correct system-dependent memory +# manager file. For Unix this is usually jmemnobs.o, but you may want +# to use jmemansi.o or jmemname.o if you have limited swap space. +SYSDEPMEM= jmemnobs.o + +# miscellaneous OS-dependent stuff +SHELL= /bin/sh +# linker +LN= $(CC) +# file deletion command +RM= rm -f +# file rename command +MV= mv +# library (.a) file creation command +AR= ar rc +# second step in .a creation (use "touch" if not needed) +AR2= ranlib +# installation program +INSTALL= /usr/bin/install -c +INSTALL_PROGRAM= ${INSTALL} +INSTALL_DATA= ${INSTALL} -m 644 + +# End of configurable options. + + +# source files: JPEG library proper +LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ + jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ + jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ + jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ + jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ + jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ + jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ + jquant2.c jutils.c jmemmgr.c +# memmgr back ends: compile only one of these into a working library +SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c +# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom +APPSOURCES= cjpeg.c djpeg.c jpegtran.c cdjpeg.c rdcolmap.c rdswitch.c \ + rdjpgcom.c wrjpgcom.c rdppm.c wrppm.c rdgif.c wrgif.c rdtarga.c \ + wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c +SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) +# files included by source files +INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ + jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h +# documentation, test, and support files +DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ + wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ + coderules.doc filelist.doc change.log +MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ + makefile.mc6 makefile.dj makefile.wat makcjpeg.st makdjpeg.st \ + makljpeg.st maktjpeg.st makefile.manx makefile.sas makefile.mms \ + makefile.vms makvms.opt +CONFIGFILES= jconfig.cfg jconfig.manx jconfig.sas jconfig.st jconfig.bcc \ + jconfig.mc6 jconfig.dj jconfig.wat jconfig.vms +OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm +TESTFILES= testorig.jpg testimg.ppm testimg.gif testimg.jpg testprog.jpg \ + testimgp.jpg +DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ + $(OTHERFILES) $(TESTFILES) +# library object files common to compression and decompression +COMOBJECTS= jcomapi.o jutils.o jerror.o jmemmgr.o $(SYSDEPMEM) +# compression library object files +CLIBOBJECTS= jcapimin.o jcapistd.o jctrans.o jcparam.o jdatadst.o jcinit.o \ + jcmaster.o jcmarker.o jcmainct.o jcprepct.o jccoefct.o jccolor.o \ + jcsample.o jchuff.o jcphuff.o jcdctmgr.o jfdctfst.o jfdctflt.o \ + jfdctint.o +# decompression library object files +DLIBOBJECTS= jdapimin.o jdapistd.o jdtrans.o jdatasrc.o jdmaster.o \ + jdinput.o jdmarker.o jdhuff.o jdphuff.o jdmainct.o jdcoefct.o \ + jdpostct.o jddctmgr.o jidctfst.o jidctflt.o jidctint.o jidctred.o \ + jdsample.o jdcolor.o jquant1.o jquant2.o jdmerge.o +# These objectfiles are included in libjpeg.a +LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) +# object files for sample applications (excluding library files) +COBJECTS= cjpeg.o rdppm.o rdgif.o rdtarga.o rdrle.o rdbmp.o rdswitch.o \ + cdjpeg.o +DOBJECTS= djpeg.o wrppm.o wrgif.o wrtarga.o wrrle.o wrbmp.o rdcolmap.o \ + cdjpeg.o +TROBJECTS= jpegtran.o rdswitch.o cdjpeg.o + + +all: libjpeg.a cjpeg djpeg jpegtran rdjpgcom wrjpgcom + +# This rule causes ansi2knr to be invoked. +# .c.o: +# ./ansi2knr $(srcdir)/$*.c T$*.c +# $(CC) $(CFLAGS) -c T$*.c +# $(RM) T$*.c $*.o +# $(MV) T$*.o $*.o + +ansi2knr: ansi2knr.c + $(CC) $(CFLAGS) $(ANSI2KNRFLAGS) -o ansi2knr ansi2knr.c + +libjpeg.a: $(LIBOBJECTS) + $(RM) libjpeg.a + $(AR) libjpeg.a $(LIBOBJECTS) + $(AR2) libjpeg.a + +cjpeg: $(COBJECTS) libjpeg.a + $(LN) $(LDFLAGS) -o cjpeg $(COBJECTS) libjpeg.a $(LDLIBS) + +djpeg: $(DOBJECTS) libjpeg.a + $(LN) $(LDFLAGS) -o djpeg $(DOBJECTS) libjpeg.a $(LDLIBS) + +jpegtran: $(TROBJECTS) libjpeg.a + $(LN) $(LDFLAGS) -o jpegtran $(TROBJECTS) libjpeg.a $(LDLIBS) + +rdjpgcom: rdjpgcom.o + $(LN) $(LDFLAGS) -o rdjpgcom rdjpgcom.o $(LDLIBS) + +wrjpgcom: wrjpgcom.o + $(LN) $(LDFLAGS) -o wrjpgcom wrjpgcom.o $(LDLIBS) + +jconfig.h: jconfig.doc + echo You must prepare a system-dependent jconfig.h file. + echo Please read the installation directions in install.doc. + exit 1 + +install: cjpeg djpeg jpegtran rdjpgcom wrjpgcom + $(INSTALL_PROGRAM) cjpeg $(bindir)/$(binprefix)cjpeg + $(INSTALL_PROGRAM) djpeg $(bindir)/$(binprefix)djpeg + $(INSTALL_PROGRAM) jpegtran $(bindir)/$(binprefix)jpegtran + $(INSTALL_PROGRAM) rdjpgcom $(bindir)/$(binprefix)rdjpgcom + $(INSTALL_PROGRAM) wrjpgcom $(bindir)/$(binprefix)wrjpgcom + $(INSTALL_DATA) $(srcdir)/cjpeg.1 $(mandir)/$(manprefix)cjpeg.$(manext) + $(INSTALL_DATA) $(srcdir)/djpeg.1 $(mandir)/$(manprefix)djpeg.$(manext) + $(INSTALL_DATA) $(srcdir)/jpegtran.1 $(mandir)/$(manprefix)jpegtran.$(manext) + $(INSTALL_DATA) $(srcdir)/rdjpgcom.1 $(mandir)/$(manprefix)rdjpgcom.$(manext) + $(INSTALL_DATA) $(srcdir)/wrjpgcom.1 $(mandir)/$(manprefix)wrjpgcom.$(manext) + +install-lib: libjpeg.a install-headers + $(INSTALL_DATA) libjpeg.a $(libdir)/$(binprefix)libjpeg.a + +install-headers: jconfig.h + $(INSTALL_DATA) jconfig.h $(includedir)/jconfig.h + $(INSTALL_DATA) $(srcdir)/jpeglib.h $(includedir)/jpeglib.h + $(INSTALL_DATA) $(srcdir)/jmorecfg.h $(includedir)/jmorecfg.h + $(INSTALL_DATA) $(srcdir)/jerror.h $(includedir)/jerror.h + +clean: + $(RM) *.o cjpeg djpeg jpegtran libjpeg.a rdjpgcom wrjpgcom + $(RM) ansi2knr core testout* config.log config.status + +distribute: + $(RM) jpegsrc.tar* + tar cvf jpegsrc.tar $(DISTFILES) + compress -v jpegsrc.tar + +test: cjpeg djpeg jpegtran + $(RM) testout* + ./djpeg -dct int -ppm -outfile testout.ppm $(srcdir)/testorig.jpg + ./djpeg -dct int -gif -outfile testout.gif $(srcdir)/testorig.jpg + ./cjpeg -dct int -outfile testout.jpg $(srcdir)/testimg.ppm + ./djpeg -dct int -ppm -outfile testoutp.ppm $(srcdir)/testprog.jpg + ./cjpeg -dct int -progressive -opt -outfile testoutp.jpg $(srcdir)/testimg.ppm + ./jpegtran -outfile testoutt.jpg $(srcdir)/testprog.jpg + cmp $(srcdir)/testimg.ppm testout.ppm + cmp $(srcdir)/testimg.gif testout.gif + cmp $(srcdir)/testimg.jpg testout.jpg + cmp $(srcdir)/testimg.ppm testoutp.ppm + cmp $(srcdir)/testimgp.jpg testoutp.jpg + cmp $(srcdir)/testorig.jpg testoutt.jpg + +check: test + +# GNU Make likes to know which target names are not really files to be made: +.PHONY: all install install-lib install-headers clean distribute test check + + +jcapimin.o: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapistd.o: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccoefct.o: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccolor.o: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcdctmgr.o: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jchuff.o: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcinit.o: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmainct.o: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmarker.o: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmaster.o: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcomapi.o: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcparam.o: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcphuff.o: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcprepct.o: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcsample.o: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jctrans.o: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapimin.o: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapistd.o: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdatadst.o: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdatasrc.o: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdcoefct.o: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdcolor.o: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jddctmgr.o: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jdhuff.o: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdinput.o: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmainct.o: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmarker.o: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmaster.o: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmerge.o: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdphuff.o: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdpostct.o: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdsample.o: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdtrans.o: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jerror.o: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h +jfdctflt.o: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctfst.o: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctint.o: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctflt.o: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctfst.o: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctint.o: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctred.o: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jquant1.o: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jquant2.o: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jutils.o: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jmemmgr.o: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemansi.o: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemname.o: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemnobs.o: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemdos.o: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemmac.o: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +cjpeg.o: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +djpeg.o: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +jpegtran.o: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +cdjpeg.o: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdcolmap.o: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdswitch.o: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdjpgcom.o: rdjpgcom.c jinclude.h jconfig.h +wrjpgcom.o: wrjpgcom.c jinclude.h jconfig.h +rdppm.o: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrppm.o: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdgif.o: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrgif.o: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdtarga.o: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrtarga.o: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdbmp.o: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrbmp.o: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdrle.o: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrrle.o: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/gs/jpeg/README b/gs/jpeg/README new file mode 100644 index 000000000..fa69a18c6 --- /dev/null +++ b/gs/jpeg/README @@ -0,0 +1,383 @@ +The Independent JPEG Group's JPEG software +========================================== + +README for release 6a of 7-Feb-96 +================================= + +This distribution contains the sixth public release of the Independent JPEG +Group's free JPEG software. You are welcome to redistribute this software and +to use it for any purpose, subject to the conditions under LEGAL ISSUES, below. + +Serious users of this software (particularly those incorporating it into +larger programs) should contact IJG at jpeg-info@uunet.uu.net to be added to +our electronic mailing list. Mailing list members are notified of updates +and have a chance to participate in technical discussions, etc. + +This software is the work of Tom Lane, Philip Gladstone, Luis Ortiz, Jim +Boucher, Lee Crocker, Julian Minguillon, George Phillips, Davide Rossi, +Ge' Weijers, and other members of the Independent JPEG Group. + +IJG is not affiliated with the official ISO JPEG standards committee. + + +DOCUMENTATION ROADMAP +===================== + +This file contains the following sections: + +OVERVIEW General description of JPEG and the IJG software. +LEGAL ISSUES Copyright, lack of warranty, terms of distribution. +REFERENCES Where to learn more about JPEG. +ARCHIVE LOCATIONS Where to find newer versions of this software. +RELATED SOFTWARE Other stuff you should get. +FILE FORMAT WARS Software *not* to get. +TO DO Plans for future IJG releases. + +Other documentation files in the distribution are: + +User documentation: + install.doc How to configure and install the IJG software. + usage.doc Usage instructions for cjpeg, djpeg, jpegtran, + rdjpgcom, and wrjpgcom. + *.1 Unix-style man pages for programs (same info as usage.doc). + wizard.doc Advanced usage instructions for JPEG wizards only. + change.log Version-to-version change highlights. +Programmer and internal documentation: + libjpeg.doc How to use the JPEG library in your own programs. + example.c Sample code for calling the JPEG library. + structure.doc Overview of the JPEG library's internal structure. + filelist.doc Road map of IJG files. + coderules.doc Coding style rules --- please read if you contribute code. + +Please read at least the files install.doc and usage.doc. Useful information +can also be found in the JPEG FAQ (Frequently Asked Questions) article. See +ARCHIVE LOCATIONS below to find out where to obtain the FAQ article. + +If you want to understand how the JPEG code works, we suggest reading one or +more of the REFERENCES, then looking at the documentation files (in roughly +the order listed) before diving into the code. + + +OVERVIEW +======== + +This package contains C software to implement JPEG image compression and +decompression. JPEG (pronounced "jay-peg") is a standardized compression +method for full-color and gray-scale images. JPEG is intended for compressing +"real-world" scenes; line drawings, cartoons and other non-realistic images +are not its strong suit. JPEG is lossy, meaning that the output image is not +exactly identical to the input image. Hence you must not use JPEG if you +have to have identical output bits. However, on typical photographic images, +very good compression levels can be obtained with no visible change, and +remarkably high compression levels are possible if you can tolerate a +low-quality image. For more details, see the references, or just experiment +with various compression settings. + +This software implements JPEG baseline, extended-sequential, and progressive +compression processes. Provision is made for supporting all variants of these +processes, although some uncommon parameter settings aren't implemented yet. +For legal reasons, we are not distributing code for the arithmetic-coding +variants of JPEG; see LEGAL ISSUES. We have made no provision for supporting +the hierarchical or lossless processes defined in the standard. + +We provide a set of library routines for reading and writing JPEG image files, +plus two sample applications "cjpeg" and "djpeg", which use the library to +perform conversion between JPEG and some other popular image file formats. +The library is intended to be reused in other applications. + +In order to support file conversion and viewing software, we have included +considerable functionality beyond the bare JPEG coding/decoding capability; +for example, the color quantization modules are not strictly part of JPEG +decoding, but they are essential for output to colormapped file formats or +colormapped displays. These extra functions can be compiled out of the +library if not required for a particular application. We have also included +"jpegtran", a utility for lossless transcoding between different JPEG +processes, and "rdjpgcom" and "wrjpgcom", two simple applications for +inserting and extracting textual comments in JFIF files. + +The emphasis in designing this software has been on achieving portability and +flexibility, while also making it fast enough to be useful. In particular, +the software is not intended to be read as a tutorial on JPEG. (See the +REFERENCES section for introductory material.) Rather, it is intended to +be reliable, portable, industrial-strength code. We do not claim to have +achieved that goal in every aspect of the software, but we strive for it. + +We welcome the use of this software as a component of commercial products. +No royalty is required, but we do ask for an acknowledgement in product +documentation, as described under LEGAL ISSUES. + + +LEGAL ISSUES +============ + +In plain English: + +1. We don't promise that this software works. (But if you find any bugs, + please let us know!) +2. You can use this software for whatever you want. You don't have to pay us. +3. You may not pretend that you wrote this software. If you use it in a + program, you must acknowledge somewhere in your documentation that + you've used the IJG code. + +In legalese: + +The authors make NO WARRANTY or representation, either express or implied, +with respect to this software, its quality, accuracy, merchantability, or +fitness for a particular purpose. This software is provided "AS IS", and you, +its user, assume the entire risk as to its quality and accuracy. + +This software is copyright (C) 1991-1996, Thomas G. Lane. +All Rights Reserved except as specified below. + +Permission is hereby granted to use, copy, modify, and distribute this +software (or portions thereof) for any purpose, without fee, subject to these +conditions: +(1) If any part of the source code for this software is distributed, then this +README file must be included, with this copyright and no-warranty notice +unaltered; and any additions, deletions, or changes to the original files +must be clearly indicated in accompanying documentation. +(2) If only executable code is distributed, then the accompanying +documentation must state that "this software is based in part on the work of +the Independent JPEG Group". +(3) Permission for use of this software is granted only if the user accepts +full responsibility for any undesirable consequences; the authors accept +NO LIABILITY for damages of any kind. + +These conditions apply to any software derived from or based on the IJG code, +not just to the unmodified library. If you use our work, you ought to +acknowledge us. + +Permission is NOT granted for the use of any IJG author's name or company name +in advertising or publicity relating to this software or products derived from +it. This software may be referred to only as "the Independent JPEG Group's +software". + +We specifically permit and encourage the use of this software as the basis of +commercial products, provided that all warranty or liability claims are +assumed by the product vendor. + + +ansi2knr.c is included in this distribution by permission of L. Peter Deutsch, +sole proprietor of its copyright holder, Aladdin Enterprises of Menlo Park, CA. +ansi2knr.c is NOT covered by the above copyright and conditions, but instead +by the usual distribution terms of the Free Software Foundation; principally, +that you must include source code if you redistribute it. (See the file +ansi2knr.c for full details.) However, since ansi2knr.c is not needed as part +of any program generated from the IJG code, this does not limit you more than +the foregoing paragraphs do. + +The configuration script "configure" was produced with GNU Autoconf. It +is copyright by the Free Software Foundation but is freely distributable. + +It appears that the arithmetic coding option of the JPEG spec is covered by +patents owned by IBM, AT&T, and Mitsubishi. Hence arithmetic coding cannot +legally be used without obtaining one or more licenses. For this reason, +support for arithmetic coding has been removed from the free JPEG software. +(Since arithmetic coding provides only a marginal gain over the unpatented +Huffman mode, it is unlikely that very many implementations will support it.) +So far as we are aware, there are no patent restrictions on the remaining +code. + +WARNING: Unisys has begun to enforce their patent on LZW compression against +GIF encoders and decoders. You will need a license from Unisys to use the +included rdgif.c or wrgif.c files in a commercial or shareware application. +At this time, Unisys is not enforcing their patent against freeware, so +distribution of this package remains legal. However, we intend to remove +GIF support from the IJG package as soon as a suitable replacement format +becomes reasonably popular. + +We are required to state that + "The Graphics Interchange Format(c) is the Copyright property of + CompuServe Incorporated. GIF(sm) is a Service Mark property of + CompuServe Incorporated." + + +REFERENCES +========== + +We highly recommend reading one or more of these references before trying to +understand the innards of the JPEG software. + +The best short technical introduction to the JPEG compression algorithm is + Wallace, Gregory K. "The JPEG Still Picture Compression Standard", + Communications of the ACM, April 1991 (vol. 34 no. 4), pp. 30-44. +(Adjacent articles in that issue discuss MPEG motion picture compression, +applications of JPEG, and related topics.) If you don't have the CACM issue +handy, a PostScript file containing a revised version of Wallace's article +is available at ftp.uu.net, graphics/jpeg/wallace.ps.gz. The file (actually +a preprint for an article that appeared in IEEE Trans. Consumer Electronics) +omits the sample images that appeared in CACM, but it includes corrections +and some added material. Note: the Wallace article is copyright ACM and +IEEE, and it may not be used for commercial purposes. + +A somewhat less technical, more leisurely introduction to JPEG can be found in +"The Data Compression Book" by Mark Nelson, published by M&T Books (Redwood +City, CA), 1991, ISBN 1-55851-216-0. This book provides good explanations and +example C code for a multitude of compression methods including JPEG. It is +an excellent source if you are comfortable reading C code but don't know much +about data compression in general. The book's JPEG sample code is far from +industrial-strength, but when you are ready to look at a full implementation, +you've got one here... + +The best full description of JPEG is the textbook "JPEG Still Image Data +Compression Standard" by William B. Pennebaker and Joan L. Mitchell, published +by Van Nostrand Reinhold, 1993, ISBN 0-442-01272-1. Price US$59.95, 638 pp. +The book includes the complete text of the ISO JPEG standards (DIS 10918-1 +and draft DIS 10918-2). This is by far the most complete exposition of JPEG +in existence, and we highly recommend it. + +The JPEG standard itself is not available electronically; you must order a +paper copy through ISO or ITU. (Unless you feel a need to own a certified +official copy, we recommend buying the Pennebaker and Mitchell book instead; +it's much cheaper and includes a great deal of useful explanatory material.) +In the USA, copies of the standard may be ordered from ANSI Sales at (212) +642-4900, or from Global Engineering Documents at (800) 854-7179. (ANSI +doesn't take credit card orders, but Global does.) It's not cheap: as of +1992, ANSI was charging $95 for Part 1 and $47 for Part 2, plus 7% +shipping/handling. The standard is divided into two parts, Part 1 being the +actual specification, while Part 2 covers compliance testing methods. Part 1 +is titled "Digital Compression and Coding of Continuous-tone Still Images, +Part 1: Requirements and guidelines" and has document numbers ISO/IEC IS +10918-1, ITU-T T.81. Part 2 is titled "Digital Compression and Coding of +Continuous-tone Still Images, Part 2: Compliance testing" and has document +numbers ISO/IEC IS 10918-2, ITU-T T.83. + +Extensions to the original JPEG standard are defined in JPEG Part 3, a new ISO +document. Part 3 is undergoing ISO balloting and is expected to be approved +by the end of 1995; it will have document numbers ISO/IEC IS 10918-3, ITU-T +T.84. IJG currently does not support any Part 3 extensions. + +The JPEG standard does not specify all details of an interchangeable file +format. For the omitted details we follow the "JFIF" conventions, revision +1.02. A copy of the JFIF spec is available from: + Literature Department + C-Cube Microsystems, Inc. + 1778 McCarthy Blvd. + Milpitas, CA 95035 + phone (408) 944-6300, fax (408) 944-6314 +A PostScript version of this document is available at ftp.uu.net, file +graphics/jpeg/jfif.ps.gz. It can also be obtained by e-mail from the C-Cube +mail server, netlib@c3.pla.ca.us. Send the message "send jfif_ps from jpeg" +to the server to obtain the JFIF document; send the message "help" if you have +trouble. + +The TIFF 6.0 file format specification can be obtained by FTP from sgi.com +(192.48.153.1), file graphics/tiff/TIFF6.ps.Z; or you can order a printed +copy from Aldus Corp. at (206) 628-6593. The JPEG incorporation scheme +found in the TIFF 6.0 spec of 3-June-92 has a number of serious problems. +IJG does not recommend use of the TIFF 6.0 design (TIFF Compression tag 6). +Instead, we recommend the JPEG design proposed by TIFF Technical Note #2 +(Compression tag 7). Copies of this Note can be obtained from sgi.com or +from ftp.uu.net:/graphics/jpeg/. It is expected that the next revision of +the TIFF spec will replace the 6.0 JPEG design with the Note's design. +Although IJG's own code does not support TIFF/JPEG, the free libtiff library +uses our library to implement TIFF/JPEG per the Note. libtiff is available +from sgi.com:/graphics/tiff/. + + +ARCHIVE LOCATIONS +================= + +The "official" archive site for this software is ftp.uu.net (Internet +address 192.48.96.9). The most recent released version can always be found +there in directory graphics/jpeg. This particular version will be archived +as graphics/jpeg/jpegsrc.v6a.tar.gz. If you are on the Internet, you +can retrieve files from ftp.uu.net by standard anonymous FTP. If you don't +have FTP access, UUNET's archives are also available via UUCP; contact +help@uunet.uu.net for information on retrieving files that way. + +Numerous Internet sites maintain copies of the UUNET files. However, only +ftp.uu.net is guaranteed to have the latest official version. + +You can also obtain this software in DOS-compatible "zip" archive format from +the SimTel archives (ftp.coast.net:/SimTel/msdos/graphics/), or on CompuServe +in the Graphics Support forum (GO CIS:GRAPHSUP), library 12 "JPEG Tools". +Again, these versions may sometimes lag behind the ftp.uu.net release. + +The JPEG FAQ (Frequently Asked Questions) article is a useful source of +general information about JPEG. It is updated constantly and therefore is +not included in this distribution. The FAQ is posted every two weeks to +Usenet newsgroups comp.graphics.misc, news.answers, and other groups. +You can always obtain the latest version from the news.answers archive at +rtfm.mit.edu. By FTP, fetch /pub/usenet/news.answers/jpeg-faq/part1 and +.../part2. If you don't have FTP, send e-mail to mail-server@rtfm.mit.edu +with body + send usenet/news.answers/jpeg-faq/part1 + send usenet/news.answers/jpeg-faq/part2 + + +RELATED SOFTWARE +================ + +Numerous viewing and image manipulation programs now support JPEG. (Quite a +few of them use this library to do so.) The JPEG FAQ described above lists +some of the more popular free and shareware viewers, and tells where to +obtain them on Internet. + +If you are on a Unix machine, we highly recommend Jef Poskanzer's free +PBMPLUS image software, which provides many useful operations on PPM-format +image files. In particular, it can convert PPM images to and from a wide +range of other formats. You can obtain this package by FTP from ftp.x.org +(contrib/pbmplus*.tar.Z) or ftp.ee.lbl.gov (pbmplus*.tar.Z). There is also +a newer update of this package called NETPBM, available from +wuarchive.wustl.edu under directory /graphics/graphics/packages/NetPBM/. +Unfortunately PBMPLUS/NETPBM is not nearly as portable as the IJG software +is; you are likely to have difficulty making it work on any non-Unix machine. + +A different free JPEG implementation, written by the PVRG group at Stanford, +is available from havefun.stanford.edu in directory pub/jpeg. This program +is designed for research and experimentation rather than production use; +it is slower, harder to use, and less portable than the IJG code, but it +is easier to read and modify. Also, the PVRG code supports lossless JPEG, +which we do not. + + +FILE FORMAT WARS +================ + +Some JPEG programs produce files that are not compatible with our library. +The root of the problem is that the ISO JPEG committee failed to specify a +concrete file format. Some vendors "filled in the blanks" on their own, +creating proprietary formats that no one else could read. (For example, none +of the early commercial JPEG implementations for the Macintosh were able to +exchange compressed files.) + +The file format we have adopted is called JFIF (see REFERENCES). This format +has been agreed to by a number of major commercial JPEG vendors, and it has +become the de facto standard. JFIF is a minimal or "low end" representation. +We recommend the use of TIFF/JPEG (TIFF revision 6.0 as modified by TIFF +Technical Note #2) for "high end" applications that need to record a lot of +additional data about an image. TIFF/JPEG is fairly new and not yet widely +supported, unfortunately. + +The upcoming JPEG Part 3 standard defines a file format called SPIFF. +SPIFF is interoperable with JFIF, in the sense that most JFIF decoders should +be able to read the most common variant of SPIFF. SPIFF has some technical +advantages over JFIF, but its major claim to fame is simply that it is an +official standard rather than an informal one. At this point it is unclear +whether SPIFF will supersede JFIF or whether JFIF will remain the de-facto +standard. IJG intends to support SPIFF once the standard is frozen, but we +have not decided whether it should become our default output format or not. +(In any case, our decoder will remain capable of reading JFIF indefinitely.) + +Various proprietary file formats incorporating JPEG compression also exist. +We have little or no sympathy for the existence of these formats. Indeed, +one of the original reasons for developing this free software was to help +force convergence on common, open format standards for JPEG files. Don't +use a proprietary file format! + + +TO DO +===== + +In future versions, we are considering supporting some of the upcoming JPEG +Part 3 extensions --- principally, variable quantization and the SPIFF file +format. + +Tuning the software for better behavior at low quality/high compression +settings is also of interest. The current method for scaling the +quantization tables is known not to be very good at low Q values. + +As always, speeding things up is high on our priority list. + +Please send bug reports, offers of help, etc. to jpeg-info@uunet.uu.net. diff --git a/gs/jpeg/ansi2knr b/gs/jpeg/ansi2knr new file mode 100755 index 000000000..95b717a10 Binary files /dev/null and b/gs/jpeg/ansi2knr differ diff --git a/gs/jpeg/ansi2knr.1 b/gs/jpeg/ansi2knr.1 new file mode 100644 index 000000000..f9ee5a631 --- /dev/null +++ b/gs/jpeg/ansi2knr.1 @@ -0,0 +1,36 @@ +.TH ANSI2KNR 1 "19 Jan 1996" +.SH NAME +ansi2knr \- convert ANSI C to Kernighan & Ritchie C +.SH SYNOPSIS +.I ansi2knr +[--varargs] input_file [output_file] +.SH DESCRIPTION +If no output_file is supplied, output goes to stdout. +.br +There are no error messages. +.sp +.I ansi2knr +recognizes function definitions by seeing a non-keyword identifier at the left +margin, followed by a left parenthesis, with a right parenthesis as the last +character on the line, and with a left brace as the first token on the +following line (ignoring possible intervening comments). It will recognize a +multi-line header provided that no intervening line ends with a left or right +brace or a semicolon. These algorithms ignore whitespace and comments, except +that the function name must be the first thing on the line. +.sp +The following constructs will confuse it: +.br + - Any other construct that starts at the left margin and follows the +above syntax (such as a macro or function call). +.br + - Some macros that tinker with the syntax of the function header. +.sp +The --varargs switch is obsolete, and is recognized only for +backwards compatibility. The present version of +.I ansi2knr +will always attempt to convert a ... argument to va_alist and va_dcl. +.SH AUTHOR +L. Peter Deutsch wrote the original ansi2knr and +continues to maintain the current version; most of the code in the current +version is his work. ansi2knr also includes contributions by Francois +Pinard and Jim Avera . diff --git a/gs/jpeg/ansi2knr.c b/gs/jpeg/ansi2knr.c new file mode 100644 index 000000000..4e05fc2d3 --- /dev/null +++ b/gs/jpeg/ansi2knr.c @@ -0,0 +1,693 @@ +/* ansi2knr.c */ +/* Convert ANSI C function definitions to K&R ("traditional C") syntax */ + +/* +ansi2knr is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY. No author or distributor accepts responsibility to anyone for the +consequences of using it or for whether it serves any particular purpose or +works at all, unless he says so in writing. Refer to the GNU General Public +License (the "GPL") for full details. + +Everyone is granted permission to copy, modify and redistribute ansi2knr, +but only under the conditions described in the GPL. A copy of this license +is supposed to have been given to you along with ansi2knr so you can know +your rights and responsibilities. It should be in a file named COPYLEFT. +[In the IJG distribution, the GPL appears below, not in a separate file.] +Among other things, the copyright notice and this notice must be preserved +on all copies. + +We explicitly state here what we believe is already implied by the GPL: if +the ansi2knr program is distributed as a separate set of sources and a +separate executable file which are aggregated on a storage medium together +with another program, this in itself does not bring the other program under +the GPL, nor does the mere fact that such a program or the procedures for +constructing it invoke the ansi2knr executable bring any other part of the +program under the GPL. +*/ + +/* +---------- Here is the GNU GPL file COPYLEFT, referred to above ---------- +----- These terms do NOT apply to the JPEG software itself; see README ------ + + GHOSTSCRIPT GENERAL PUBLIC LICENSE + (Clarified 11 Feb 1988) + + Copyright (C) 1988 Richard M. Stallman + Everyone is permitted to copy and distribute verbatim copies of this + license, but changing it is not allowed. You can also use this wording + to make the terms for other programs. + + The license agreements of most software companies keep you at the +mercy of those companies. By contrast, our general public license is +intended to give everyone the right to share Ghostscript. To make sure +that you get the rights we want you to have, we need to make +restrictions that forbid anyone to deny you these rights or to ask you +to surrender the rights. Hence this license agreement. + + Specifically, we want to make sure that you have the right to give +away copies of Ghostscript, that you receive source code or else can get +it if you want it, that you can change Ghostscript or use pieces of it +in new free programs, and that you know you can do these things. + + To make sure that everyone has such rights, we have to forbid you to +deprive anyone else of these rights. For example, if you distribute +copies of Ghostscript, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must tell them their rights. + + Also, for our own protection, we must make certain that everyone finds +out that there is no warranty for Ghostscript. If Ghostscript is +modified by someone else and passed on, we want its recipients to know +that what they have is not what we distributed, so that any problems +introduced by others will not reflect on our reputation. + + Therefore we (Richard M. Stallman and the Free Software Foundation, +Inc.) make the following terms which say what you must do to be allowed +to distribute or change Ghostscript. + + + COPYING POLICIES + + 1. You may copy and distribute verbatim copies of Ghostscript source +code as you receive it, in any medium, provided that you conspicuously +and appropriately publish on each copy a valid copyright and license +notice "Copyright (C) 1989 Aladdin Enterprises. All rights reserved. +Distributed by Free Software Foundation, Inc." (or with whatever year is +appropriate); keep intact the notices on all files that refer to this +License Agreement and to the absence of any warranty; and give any other +recipients of the Ghostscript program a copy of this License Agreement +along with the program. You may charge a distribution fee for the +physical act of transferring a copy. + + 2. You may modify your copy or copies of Ghostscript or any portion of +it, and copy and distribute such modifications under the terms of +Paragraph 1 above, provided that you also do the following: + + a) cause the modified files to carry prominent notices stating + that you changed the files and the date of any change; and + + b) cause the whole of any work that you distribute or publish, + that in whole or in part contains or is a derivative of Ghostscript + or any part thereof, to be licensed at no charge to all third + parties on terms identical to those contained in this License + Agreement (except that you may choose to grant more extensive + warranty protection to some or all third parties, at your option). + + c) You may charge a distribution fee for the physical act of + transferring a copy, and you may at your option offer warranty + protection in exchange for a fee. + +Mere aggregation of another unrelated program with this program (or its +derivative) on a volume of a storage or distribution medium does not bring +the other program under the scope of these terms. + + 3. You may copy and distribute Ghostscript (or a portion or derivative +of it, under Paragraph 2) in object code or executable form under the +terms of Paragraphs 1 and 2 above provided that you also do one of the +following: + + a) accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of + Paragraphs 1 and 2 above; or, + + b) accompany it with a written offer, valid for at least three + years, to give any third party free (except for a nominal + shipping charge) a complete machine-readable copy of the + corresponding source code, to be distributed under the terms of + Paragraphs 1 and 2 above; or, + + c) accompany it with the information you received as to where the + corresponding source code may be obtained. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form alone.) + +For an executable file, complete source code means all the source code for +all modules it contains; but, as a special exception, it need not include +source code for modules which are standard libraries that accompany the +operating system on which the executable file runs. + + 4. You may not copy, sublicense, distribute or transfer Ghostscript +except as expressly provided under this License Agreement. Any attempt +otherwise to copy, sublicense, distribute or transfer Ghostscript is +void and your rights to use the program under this License agreement +shall be automatically terminated. However, parties who have received +computer software programs from you with this License Agreement will not +have their licenses terminated so long as such parties remain in full +compliance. + + 5. If you wish to incorporate parts of Ghostscript into other free +programs whose distribution conditions are different, write to the Free +Software Foundation at 675 Mass Ave, Cambridge, MA 02139. We have not +yet worked out a simple rule that can be stated here, but we will often +permit this. We will be guided by the two goals of preserving the free +status of all derivatives of our free software and of promoting the +sharing and reuse of software. + +Your comments and suggestions about our licensing policies and our +software are welcome! Please contact the Free Software Foundation, +Inc., 675 Mass Ave, Cambridge, MA 02139, or call (617) 876-3296. + + NO WARRANTY + + BECAUSE GHOSTSCRIPT IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY +NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT +WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC, RICHARD +M. STALLMAN, ALADDIN ENTERPRISES, L. PETER DEUTSCH, AND/OR OTHER PARTIES +PROVIDE GHOSTSCRIPT "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER +EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE +ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF GHOSTSCRIPT IS WITH +YOU. SHOULD GHOSTSCRIPT PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL +NECESSARY SERVICING, REPAIR OR CORRECTION. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M. +STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., L. PETER DEUTSCH, ALADDIN +ENTERPRISES, AND/OR ANY OTHER PARTY WHO MAY MODIFY AND REDISTRIBUTE +GHOSTSCRIPT AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING +ANY LOST PROFITS, LOST MONIES, OR OTHER SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE +(INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED +INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A FAILURE OF THE +PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) GHOSTSCRIPT, EVEN IF YOU +HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM +BY ANY OTHER PARTY. + +-------------------- End of file COPYLEFT ------------------------------ +*/ + +/* + * Usage: + ansi2knr input_file [output_file] + * If no output_file is supplied, output goes to stdout. + * There are no error messages. + * + * ansi2knr recognizes function definitions by seeing a non-keyword + * identifier at the left margin, followed by a left parenthesis, + * with a right parenthesis as the last character on the line, + * and with a left brace as the first token on the following line + * (ignoring possible intervening comments). + * It will recognize a multi-line header provided that no intervening + * line ends with a left or right brace or a semicolon. + * These algorithms ignore whitespace and comments, except that + * the function name must be the first thing on the line. + * The following constructs will confuse it: + * - Any other construct that starts at the left margin and + * follows the above syntax (such as a macro or function call). + * - Some macros that tinker with the syntax of the function header. + */ + +/* + * The original and principal author of ansi2knr is L. Peter Deutsch + * . Other authors are noted in the change history + * that follows (in reverse chronological order): + lpd 96-01-21 added code to cope with not HAVE_CONFIG_H and with + compilers that don't understand void, as suggested by + Tom Lane + lpd 96-01-15 changed to require that the first non-comment token + on the line following a function header be a left brace, + to reduce sensitivity to macros, as suggested by Tom Lane + + lpd 95-06-22 removed #ifndefs whose sole purpose was to define + undefined preprocessor symbols as 0; changed all #ifdefs + for configuration symbols to #ifs + lpd 95-04-05 changed copyright notice to make it clear that + including ansi2knr in a program does not bring the entire + program under the GPL + lpd 94-12-18 added conditionals for systems where ctype macros + don't handle 8-bit characters properly, suggested by + Francois Pinard ; + removed --varargs switch (this is now the default) + lpd 94-10-10 removed CONFIG_BROKETS conditional + lpd 94-07-16 added some conditionals to help GNU `configure', + suggested by Francois Pinard ; + properly erase prototype args in function parameters, + contributed by Jim Avera ; + correct error in writeblanks (it shouldn't erase EOLs) + lpd 89-xx-xx original version + */ + +/* Most of the conditionals here are to make ansi2knr work with */ +/* or without the GNU configure machinery. */ + +#if HAVE_CONFIG_H +# include +#endif + +#include +#include + +#if HAVE_CONFIG_H + +/* + For properly autoconfiguring ansi2knr, use AC_CONFIG_HEADER(config.h). + This will define HAVE_CONFIG_H and so, activate the following lines. + */ + +# if STDC_HEADERS || HAVE_STRING_H +# include +# else +# include +# endif + +#else /* not HAVE_CONFIG_H */ + +/* Otherwise do it the hard way */ + +# ifdef BSD +# include +# else +# ifdef VMS + extern int strlen(), strncmp(); +# else +# include +# endif +# endif + +#endif /* not HAVE_CONFIG_H */ + +#if STDC_HEADERS +# include +#else +/* + malloc and free should be declared in stdlib.h, + but if you've got a K&R compiler, they probably aren't. + */ +# ifdef MSDOS +# include +# else +# ifdef VMS + extern char *malloc(); + extern void free(); +# else + extern char *malloc(); + extern int free(); +# endif +# endif + +#endif + +/* + * The ctype macros don't always handle 8-bit characters correctly. + * Compensate for this here. + */ +#ifdef isascii +# undef HAVE_ISASCII /* just in case */ +# define HAVE_ISASCII 1 +#else +#endif +#if STDC_HEADERS || !HAVE_ISASCII +# define is_ascii(c) 1 +#else +# define is_ascii(c) isascii(c) +#endif + +#define is_space(c) (is_ascii(c) && isspace(c)) +#define is_alpha(c) (is_ascii(c) && isalpha(c)) +#define is_alnum(c) (is_ascii(c) && isalnum(c)) + +/* Scanning macros */ +#define isidchar(ch) (is_alnum(ch) || (ch) == '_') +#define isidfirstchar(ch) (is_alpha(ch) || (ch) == '_') + +/* Forward references */ +char *skipspace(); +int writeblanks(); +int test1(); +int convert1(); + +/* The main program */ +int +main(argc, argv) + int argc; + char *argv[]; +{ FILE *in, *out; +#define bufsize 5000 /* arbitrary size */ + char *buf; + char *line; + char *more; + /* + * In previous versions, ansi2knr recognized a --varargs switch. + * If this switch was supplied, ansi2knr would attempt to convert + * a ... argument to va_alist and va_dcl; if this switch was not + * supplied, ansi2knr would simply drop any such arguments. + * Now, ansi2knr always does this conversion, and we only + * check for this switch for backward compatibility. + */ + int convert_varargs = 1; + + if ( argc > 1 && argv[1][0] == '-' ) + { if ( !strcmp(argv[1], "--varargs") ) + { convert_varargs = 1; + argc--; + argv++; + } + else + { fprintf(stderr, "Unrecognized switch: %s\n", argv[1]); + exit(1); + } + } + switch ( argc ) + { + default: + printf("Usage: ansi2knr input_file [output_file]\n"); + exit(0); + case 2: + out = stdout; + break; + case 3: + out = fopen(argv[2], "w"); + if ( out == NULL ) + { fprintf(stderr, "Cannot open output file %s\n", argv[2]); + exit(1); + } + } + in = fopen(argv[1], "r"); + if ( in == NULL ) + { fprintf(stderr, "Cannot open input file %s\n", argv[1]); + exit(1); + } + fprintf(out, "#line 1 \"%s\"\n", argv[1]); + buf = malloc(bufsize); + line = buf; + while ( fgets(line, (unsigned)(buf + bufsize - line), in) != NULL ) + { +test: line += strlen(line); + switch ( test1(buf) ) + { + case 2: /* a function header */ + convert1(buf, out, 1, convert_varargs); + break; + case 1: /* a function */ + /* Check for a { at the start of the next line. */ + more = ++line; +f: if ( line >= buf + (bufsize - 1) ) /* overflow check */ + goto wl; + if ( fgets(line, (unsigned)(buf + bufsize - line), in) == NULL ) + goto wl; + switch ( *skipspace(more, 1) ) + { + case '{': + /* Definitely a function header. */ + convert1(buf, out, 0, convert_varargs); + fputs(more, out); + break; + case 0: + /* The next line was blank or a comment: */ + /* keep scanning for a non-comment. */ + line += strlen(line); + goto f; + default: + /* buf isn't a function header, but */ + /* more might be. */ + fputs(buf, out); + strcpy(buf, more); + line = buf; + goto test; + } + break; + case -1: /* maybe the start of a function */ + if ( line != buf + (bufsize - 1) ) /* overflow check */ + continue; + /* falls through */ + default: /* not a function */ +wl: fputs(buf, out); + break; + } + line = buf; + } + if ( line != buf ) + fputs(buf, out); + free(buf); + fclose(out); + fclose(in); + return 0; +} + +/* Skip over space and comments, in either direction. */ +char * +skipspace(p, dir) + register char *p; + register int dir; /* 1 for forward, -1 for backward */ +{ for ( ; ; ) + { while ( is_space(*p) ) + p += dir; + if ( !(*p == '/' && p[dir] == '*') ) + break; + p += dir; p += dir; + while ( !(*p == '*' && p[dir] == '/') ) + { if ( *p == 0 ) + return p; /* multi-line comment?? */ + p += dir; + } + p += dir; p += dir; + } + return p; +} + +/* + * Write blanks over part of a string. + * Don't overwrite end-of-line characters. + */ +int +writeblanks(start, end) + char *start; + char *end; +{ char *p; + for ( p = start; p < end; p++ ) + if ( *p != '\r' && *p != '\n' ) + *p = ' '; + return 0; +} + +/* + * Test whether the string in buf is a function definition. + * The string may contain and/or end with a newline. + * Return as follows: + * 0 - definitely not a function definition; + * 1 - definitely a function definition; + * 2 - definitely a function prototype (NOT USED); + * -1 - may be the beginning of a function definition, + * append another line and look again. + * The reason we don't attempt to convert function prototypes is that + * Ghostscript's declaration-generating macros look too much like + * prototypes, and confuse the algorithms. + */ +int +test1(buf) + char *buf; +{ register char *p = buf; + char *bend; + char *endfn; + int contin; + + if ( !isidfirstchar(*p) ) + return 0; /* no name at left margin */ + bend = skipspace(buf + strlen(buf) - 1, -1); + switch ( *bend ) + { + case ';': contin = 0 /*2*/; break; + case ')': contin = 1; break; + case '{': return 0; /* not a function */ + case '}': return 0; /* not a function */ + default: contin = -1; + } + while ( isidchar(*p) ) + p++; + endfn = p; + p = skipspace(p, 1); + if ( *p++ != '(' ) + return 0; /* not a function */ + p = skipspace(p, 1); + if ( *p == ')' ) + return 0; /* no parameters */ + /* Check that the apparent function name isn't a keyword. */ + /* We only need to check for keywords that could be followed */ + /* by a left parenthesis (which, unfortunately, is most of them). */ + { static char *words[] = + { "asm", "auto", "case", "char", "const", "double", + "extern", "float", "for", "if", "int", "long", + "register", "return", "short", "signed", "sizeof", + "static", "switch", "typedef", "unsigned", + "void", "volatile", "while", 0 + }; + char **key = words; + char *kp; + int len = endfn - buf; + + while ( (kp = *key) != 0 ) + { if ( strlen(kp) == len && !strncmp(kp, buf, len) ) + return 0; /* name is a keyword */ + key++; + } + } + return contin; +} + +/* Convert a recognized function definition or header to K&R syntax. */ +int +convert1(buf, out, header, convert_varargs) + char *buf; + FILE *out; + int header; /* Boolean */ + int convert_varargs; /* Boolean */ +{ char *endfn; + register char *p; + char **breaks; + unsigned num_breaks = 2; /* for testing */ + char **btop; + char **bp; + char **ap; + char *vararg = 0; + + /* Pre-ANSI implementations don't agree on whether strchr */ + /* is called strchr or index, so we open-code it here. */ + for ( endfn = buf; *(endfn++) != '('; ) + ; +top: p = endfn; + breaks = (char **)malloc(sizeof(char *) * num_breaks * 2); + if ( breaks == 0 ) + { /* Couldn't allocate break table, give up */ + fprintf(stderr, "Unable to allocate break table!\n"); + fputs(buf, out); + return -1; + } + btop = breaks + num_breaks * 2 - 2; + bp = breaks; + /* Parse the argument list */ + do + { int level = 0; + char *lp = NULL; + char *rp; + char *end = NULL; + + if ( bp >= btop ) + { /* Filled up break table. */ + /* Allocate a bigger one and start over. */ + free((char *)breaks); + num_breaks <<= 1; + goto top; + } + *bp++ = p; + /* Find the end of the argument */ + for ( ; end == NULL; p++ ) + { switch(*p) + { + case ',': + if ( !level ) end = p; + break; + case '(': + if ( !level ) lp = p; + level++; + break; + case ')': + if ( --level < 0 ) end = p; + else rp = p; + break; + case '/': + p = skipspace(p, 1) - 1; + break; + default: + ; + } + } + /* Erase any embedded prototype parameters. */ + if ( lp ) + writeblanks(lp + 1, rp); + p--; /* back up over terminator */ + /* Find the name being declared. */ + /* This is complicated because of procedure and */ + /* array modifiers. */ + for ( ; ; ) + { p = skipspace(p - 1, -1); + switch ( *p ) + { + case ']': /* skip array dimension(s) */ + case ')': /* skip procedure args OR name */ + { int level = 1; + while ( level ) + switch ( *--p ) + { + case ']': case ')': level++; break; + case '[': case '(': level--; break; + case '/': p = skipspace(p, -1) + 1; break; + default: ; + } + } + if ( *p == '(' && *skipspace(p + 1, 1) == '*' ) + { /* We found the name being declared */ + while ( !isidfirstchar(*p) ) + p = skipspace(p, 1) + 1; + goto found; + } + break; + default: + goto found; + } + } +found: if ( *p == '.' && p[-1] == '.' && p[-2] == '.' ) + { if ( convert_varargs ) + { *bp++ = "va_alist"; + vararg = p-2; + } + else + { p++; + if ( bp == breaks + 1 ) /* sole argument */ + writeblanks(breaks[0], p); + else + writeblanks(bp[-1] - 1, p); + bp--; + } + } + else + { while ( isidchar(*p) ) p--; + *bp++ = p+1; + } + p = end; + } + while ( *p++ == ',' ); + *bp = p; + /* Make a special check for 'void' arglist */ + if ( bp == breaks+2 ) + { p = skipspace(breaks[0], 1); + if ( !strncmp(p, "void", 4) ) + { p = skipspace(p+4, 1); + if ( p == breaks[2] - 1 ) + { bp = breaks; /* yup, pretend arglist is empty */ + writeblanks(breaks[0], p + 1); + } + } + } + /* Put out the function name and left parenthesis. */ + p = buf; + while ( p != endfn ) putc(*p, out), p++; + /* Put out the declaration. */ + if ( header ) + { fputs(");", out); + for ( p = breaks[0]; *p; p++ ) + if ( *p == '\r' || *p == '\n' ) + putc(*p, out); + } + else + { for ( ap = breaks+1; ap < bp; ap += 2 ) + { p = *ap; + while ( isidchar(*p) ) + putc(*p, out), p++; + if ( ap < bp - 1 ) + fputs(", ", out); + } + fputs(") ", out); + /* Put out the argument declarations */ + for ( ap = breaks+2; ap <= bp; ap += 2 ) + (*ap)[-1] = ';'; + if ( vararg != 0 ) + { *vararg = 0; + fputs(breaks[0], out); /* any prior args */ + fputs("va_dcl", out); /* the final arg */ + fputs(bp[0], out); + } + else + fputs(breaks[0], out); + } + free((char *)breaks); + return 0; +} diff --git a/gs/jpeg/cderror.h b/gs/jpeg/cderror.h new file mode 100644 index 000000000..41a29cd12 --- /dev/null +++ b/gs/jpeg/cderror.h @@ -0,0 +1,132 @@ +/* + * cderror.h + * + * Copyright (C) 1994, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file defines the error and message codes for the cjpeg/djpeg + * applications. These strings are not needed as part of the JPEG library + * proper. + * Edit this file to add new codes, or to translate the message strings to + * some other language. + */ + +/* + * To define the enum list of message codes, include this file without + * defining macro JMESSAGE. To create a message string table, include it + * again with a suitable JMESSAGE definition (see jerror.c for an example). + */ +#ifndef JMESSAGE +#ifndef CDERROR_H +#define CDERROR_H +/* First time through, define the enum list */ +#define JMAKE_ENUM_LIST +#else +/* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */ +#define JMESSAGE(code,string) +#endif /* CDERROR_H */ +#endif /* JMESSAGE */ + +#ifdef JMAKE_ENUM_LIST + +typedef enum { + +#define JMESSAGE(code,string) code , + +#endif /* JMAKE_ENUM_LIST */ + +JMESSAGE(JMSG_FIRSTADDONCODE=1000, NULL) /* Must be first entry! */ + +#ifdef BMP_SUPPORTED +JMESSAGE(JERR_BMP_BADCMAP, "Unsupported BMP colormap format") +JMESSAGE(JERR_BMP_BADDEPTH, "Only 8- and 24-bit BMP files are supported") +JMESSAGE(JERR_BMP_BADHEADER, "Invalid BMP file: bad header length") +JMESSAGE(JERR_BMP_BADPLANES, "Invalid BMP file: biPlanes not equal to 1") +JMESSAGE(JERR_BMP_COLORSPACE, "BMP output must be grayscale or RGB") +JMESSAGE(JERR_BMP_COMPRESSED, "Sorry, compressed BMPs not yet supported") +JMESSAGE(JERR_BMP_NOT, "Not a BMP file - does not start with BM") +JMESSAGE(JTRC_BMP, "%ux%u 24-bit BMP image") +JMESSAGE(JTRC_BMP_MAPPED, "%ux%u 8-bit colormapped BMP image") +JMESSAGE(JTRC_BMP_OS2, "%ux%u 24-bit OS2 BMP image") +JMESSAGE(JTRC_BMP_OS2_MAPPED, "%ux%u 8-bit colormapped OS2 BMP image") +#endif /* BMP_SUPPORTED */ + +#ifdef GIF_SUPPORTED +JMESSAGE(JERR_GIF_BUG, "GIF output got confused") +JMESSAGE(JERR_GIF_CODESIZE, "Bogus GIF codesize %d") +JMESSAGE(JERR_GIF_COLORSPACE, "GIF output must be grayscale or RGB") +JMESSAGE(JERR_GIF_IMAGENOTFOUND, "Too few images in GIF file") +JMESSAGE(JERR_GIF_NOT, "Not a GIF file") +JMESSAGE(JTRC_GIF, "%ux%ux%d GIF image") +JMESSAGE(JTRC_GIF_BADVERSION, + "Warning: unexpected GIF version number '%c%c%c'") +JMESSAGE(JTRC_GIF_EXTENSION, "Ignoring GIF extension block of type 0x%02x") +JMESSAGE(JTRC_GIF_NONSQUARE, "Caution: nonsquare pixels in input") +JMESSAGE(JWRN_GIF_BADDATA, "Corrupt data in GIF file") +JMESSAGE(JWRN_GIF_CHAR, "Bogus char 0x%02x in GIF file, ignoring") +JMESSAGE(JWRN_GIF_ENDCODE, "Premature end of GIF image") +JMESSAGE(JWRN_GIF_NOMOREDATA, "Ran out of GIF bits") +#endif /* GIF_SUPPORTED */ + +#ifdef PPM_SUPPORTED +JMESSAGE(JERR_PPM_COLORSPACE, "PPM output must be grayscale or RGB") +JMESSAGE(JERR_PPM_NONNUMERIC, "Nonnumeric data in PPM file") +JMESSAGE(JERR_PPM_NOT, "Not a PPM file") +JMESSAGE(JTRC_PGM, "%ux%u PGM image") +JMESSAGE(JTRC_PGM_TEXT, "%ux%u text PGM image") +JMESSAGE(JTRC_PPM, "%ux%u PPM image") +JMESSAGE(JTRC_PPM_TEXT, "%ux%u text PPM image") +#endif /* PPM_SUPPORTED */ + +#ifdef RLE_SUPPORTED +JMESSAGE(JERR_RLE_BADERROR, "Bogus error code from RLE library") +JMESSAGE(JERR_RLE_COLORSPACE, "RLE output must be grayscale or RGB") +JMESSAGE(JERR_RLE_DIMENSIONS, "Image dimensions (%ux%u) too large for RLE") +JMESSAGE(JERR_RLE_EMPTY, "Empty RLE file") +JMESSAGE(JERR_RLE_EOF, "Premature EOF in RLE header") +JMESSAGE(JERR_RLE_MEM, "Insufficient memory for RLE header") +JMESSAGE(JERR_RLE_NOT, "Not an RLE file") +JMESSAGE(JERR_RLE_TOOMANYCHANNELS, "Cannot handle %d output channels for RLE") +JMESSAGE(JERR_RLE_UNSUPPORTED, "Cannot handle this RLE setup") +JMESSAGE(JTRC_RLE, "%ux%u full-color RLE file") +JMESSAGE(JTRC_RLE_FULLMAP, "%ux%u full-color RLE file with map of length %d") +JMESSAGE(JTRC_RLE_GRAY, "%ux%u grayscale RLE file") +JMESSAGE(JTRC_RLE_MAPGRAY, "%ux%u grayscale RLE file with map of length %d") +JMESSAGE(JTRC_RLE_MAPPED, "%ux%u colormapped RLE file with map of length %d") +#endif /* RLE_SUPPORTED */ + +#ifdef TARGA_SUPPORTED +JMESSAGE(JERR_TGA_BADCMAP, "Unsupported Targa colormap format") +JMESSAGE(JERR_TGA_BADPARMS, "Invalid or unsupported Targa file") +JMESSAGE(JERR_TGA_COLORSPACE, "Targa output must be grayscale or RGB") +JMESSAGE(JTRC_TGA, "%ux%u RGB Targa image") +JMESSAGE(JTRC_TGA_GRAY, "%ux%u grayscale Targa image") +JMESSAGE(JTRC_TGA_MAPPED, "%ux%u colormapped Targa image") +#else +JMESSAGE(JERR_TGA_NOTCOMP, "Targa support was not compiled") +#endif /* TARGA_SUPPORTED */ + +JMESSAGE(JERR_BAD_CMAP_FILE, + "Color map file is invalid or of unsupported format") +JMESSAGE(JERR_TOO_MANY_COLORS, + "Output file format cannot handle %d colormap entries") +JMESSAGE(JERR_UNGETC_FAILED, "ungetc failed") +#ifdef TARGA_SUPPORTED +JMESSAGE(JERR_UNKNOWN_FORMAT, + "Unrecognized input file format --- perhaps you need -targa") +#else +JMESSAGE(JERR_UNKNOWN_FORMAT, "Unrecognized input file format") +#endif +JMESSAGE(JERR_UNSUPPORTED_FORMAT, "Unsupported output file format") + +#ifdef JMAKE_ENUM_LIST + + JMSG_LASTADDONCODE +} ADDON_MESSAGE_CODE; + +#undef JMAKE_ENUM_LIST +#endif /* JMAKE_ENUM_LIST */ + +/* Zap JMESSAGE macro so that future re-inclusions do nothing by default */ +#undef JMESSAGE diff --git a/gs/jpeg/cdjpeg.c b/gs/jpeg/cdjpeg.c new file mode 100644 index 000000000..a3d6e0675 --- /dev/null +++ b/gs/jpeg/cdjpeg.c @@ -0,0 +1,179 @@ +/* + * cdjpeg.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains common support routines used by the IJG application + * programs (cjpeg, djpeg, jpegtran). + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ +#include /* to declare isupper(), tolower() */ +#ifdef NEED_SIGNAL_CATCHER +#include /* to declare signal() */ +#endif +#ifdef USE_SETMODE +#include /* to declare setmode()'s parameter macros */ +/* If you have setmode() but not , just delete this line: */ +#include /* to declare setmode() */ +#endif + + +/* + * Signal catcher to ensure that temporary files are removed before aborting. + * NB: for Amiga Manx C this is actually a global routine named _abort(); + * we put "#define signal_catcher _abort" in jconfig.h. Talk about bogus... + */ + +#ifdef NEED_SIGNAL_CATCHER + +static j_common_ptr sig_cinfo; + +void /* must be global for Manx C */ +signal_catcher (int signum) +{ + if (sig_cinfo != NULL) { + if (sig_cinfo->err != NULL) /* turn off trace output */ + sig_cinfo->err->trace_level = 0; + jpeg_destroy(sig_cinfo); /* clean up memory allocation & temp files */ + } + exit(EXIT_FAILURE); +} + + +GLOBAL(void) +enable_signal_catcher (j_common_ptr cinfo) +{ + sig_cinfo = cinfo; + signal(SIGINT, signal_catcher); +#ifdef SIGTERM /* not all systems have SIGTERM */ + signal(SIGTERM, signal_catcher); +#endif +} + +#endif + + +/* + * Optional progress monitor: display a percent-done figure on stderr. + */ + +#ifdef PROGRESS_REPORT + +METHODDEF(void) +progress_monitor (j_common_ptr cinfo) +{ + cd_progress_ptr prog = (cd_progress_ptr) cinfo->progress; + int total_passes = prog->pub.total_passes + prog->total_extra_passes; + int percent_done = (int) (prog->pub.pass_counter*100L/prog->pub.pass_limit); + + if (percent_done != prog->percent_done) { + prog->percent_done = percent_done; + if (total_passes > 1) { + fprintf(stderr, "\rPass %d/%d: %3d%% ", + prog->pub.completed_passes + prog->completed_extra_passes + 1, + total_passes, percent_done); + } else { + fprintf(stderr, "\r %3d%% ", percent_done); + } + fflush(stderr); + } +} + + +GLOBAL(void) +start_progress_monitor (j_common_ptr cinfo, cd_progress_ptr progress) +{ + /* Enable progress display, unless trace output is on */ + if (cinfo->err->trace_level == 0) { + progress->pub.progress_monitor = progress_monitor; + progress->completed_extra_passes = 0; + progress->total_extra_passes = 0; + progress->percent_done = -1; + cinfo->progress = &progress->pub; + } +} + + +GLOBAL(void) +end_progress_monitor (j_common_ptr cinfo) +{ + /* Clear away progress display */ + if (cinfo->err->trace_level == 0) { + fprintf(stderr, "\r \r"); + fflush(stderr); + } +} + +#endif + + +/* + * Case-insensitive matching of possibly-abbreviated keyword switches. + * keyword is the constant keyword (must be lower case already), + * minchars is length of minimum legal abbreviation. + */ + +GLOBAL(boolean) +keymatch (char * arg, const char * keyword, int minchars) +{ + register int ca, ck; + register int nmatched = 0; + + while ((ca = *arg++) != '\0') { + if ((ck = *keyword++) == '\0') + return FALSE; /* arg longer than keyword, no good */ + if (isupper(ca)) /* force arg to lcase (assume ck is already) */ + ca = tolower(ca); + if (ca != ck) + return FALSE; /* no good */ + nmatched++; /* count matched characters */ + } + /* reached end of argument; fail if it's too short for unique abbrev */ + if (nmatched < minchars) + return FALSE; + return TRUE; /* A-OK */ +} + + +/* + * Routines to establish binary I/O mode for stdin and stdout. + * Non-Unix systems often require some hacking to get out of text mode. + */ + +GLOBAL(FILE *) +read_stdin (void) +{ + FILE * input_file = stdin; + +#ifdef USE_SETMODE /* need to hack file mode? */ + setmode(fileno(stdin), O_BINARY); +#endif +#ifdef USE_FDOPEN /* need to re-open in binary mode? */ + if ((input_file = fdopen(fileno(stdin), READ_BINARY)) == NULL) { + fprintf(stderr, "Cannot reopen stdin\n"); + exit(EXIT_FAILURE); + } +#endif + return input_file; +} + + +GLOBAL(FILE *) +write_stdout (void) +{ + FILE * output_file = stdout; + +#ifdef USE_SETMODE /* need to hack file mode? */ + setmode(fileno(stdout), O_BINARY); +#endif +#ifdef USE_FDOPEN /* need to re-open in binary mode? */ + if ((output_file = fdopen(fileno(stdout), WRITE_BINARY)) == NULL) { + fprintf(stderr, "Cannot reopen stdout\n"); + exit(EXIT_FAILURE); + } +#endif + return output_file; +} diff --git a/gs/jpeg/cdjpeg.h b/gs/jpeg/cdjpeg.h new file mode 100644 index 000000000..cc0d60016 --- /dev/null +++ b/gs/jpeg/cdjpeg.h @@ -0,0 +1,179 @@ +/* + * cdjpeg.h + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains common declarations for the sample applications + * cjpeg and djpeg. It is NOT used by the core JPEG library. + */ + +#define JPEG_CJPEG_DJPEG /* define proper options in jconfig.h */ +#define JPEG_INTERNAL_OPTIONS /* cjpeg.c,djpeg.c need to see xxx_SUPPORTED */ +#include "jinclude.h" +#include "jpeglib.h" +#include "jerror.h" /* get library error codes too */ +#include "cderror.h" /* get application-specific error codes */ + + +/* + * Object interface for cjpeg's source file decoding modules + */ + +typedef struct cjpeg_source_struct * cjpeg_source_ptr; + +struct cjpeg_source_struct { + JMETHOD(void, start_input, (j_compress_ptr cinfo, + cjpeg_source_ptr sinfo)); + JMETHOD(JDIMENSION, get_pixel_rows, (j_compress_ptr cinfo, + cjpeg_source_ptr sinfo)); + JMETHOD(void, finish_input, (j_compress_ptr cinfo, + cjpeg_source_ptr sinfo)); + + FILE *input_file; + + JSAMPARRAY buffer; + JDIMENSION buffer_height; +}; + + +/* + * Object interface for djpeg's output file encoding modules + */ + +typedef struct djpeg_dest_struct * djpeg_dest_ptr; + +struct djpeg_dest_struct { + /* start_output is called after jpeg_start_decompress finishes. + * The color map will be ready at this time, if one is needed. + */ + JMETHOD(void, start_output, (j_decompress_ptr cinfo, + djpeg_dest_ptr dinfo)); + /* Emit the specified number of pixel rows from the buffer. */ + JMETHOD(void, put_pixel_rows, (j_decompress_ptr cinfo, + djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied)); + /* Finish up at the end of the image. */ + JMETHOD(void, finish_output, (j_decompress_ptr cinfo, + djpeg_dest_ptr dinfo)); + + /* Target file spec; filled in by djpeg.c after object is created. */ + FILE * output_file; + + /* Output pixel-row buffer. Created by module init or start_output. + * Width is cinfo->output_width * cinfo->output_components; + * height is buffer_height. + */ + JSAMPARRAY buffer; + JDIMENSION buffer_height; +}; + + +/* + * cjpeg/djpeg may need to perform extra passes to convert to or from + * the source/destination file format. The JPEG library does not know + * about these passes, but we'd like them to be counted by the progress + * monitor. We use an expanded progress monitor object to hold the + * additional pass count. + */ + +struct cdjpeg_progress_mgr { + struct jpeg_progress_mgr pub; /* fields known to JPEG library */ + int completed_extra_passes; /* extra passes completed */ + int total_extra_passes; /* total extra */ + /* last printed percentage stored here to avoid multiple printouts */ + int percent_done; +}; + +typedef struct cdjpeg_progress_mgr * cd_progress_ptr; + + +/* Short forms of external names for systems with brain-damaged linkers. */ + +#ifdef NEED_SHORT_EXTERNAL_NAMES +#define jinit_read_bmp jIRdBMP +#define jinit_write_bmp jIWrBMP +#define jinit_read_gif jIRdGIF +#define jinit_write_gif jIWrGIF +#define jinit_read_ppm jIRdPPM +#define jinit_write_ppm jIWrPPM +#define jinit_read_rle jIRdRLE +#define jinit_write_rle jIWrRLE +#define jinit_read_targa jIRdTarga +#define jinit_write_targa jIWrTarga +#define read_quant_tables RdQTables +#define read_scan_script RdScnScript +#define set_quant_slots SetQSlots +#define set_sample_factors SetSFacts +#define read_color_map RdCMap +#define enable_signal_catcher EnSigCatcher +#define start_progress_monitor StProgMon +#define end_progress_monitor EnProgMon +#define read_stdin RdStdin +#define write_stdout WrStdout +#endif /* NEED_SHORT_EXTERNAL_NAMES */ + +/* Module selection routines for I/O modules. */ + +EXTERN(cjpeg_source_ptr) jinit_read_bmp JPP((j_compress_ptr cinfo)); +EXTERN(djpeg_dest_ptr) jinit_write_bmp JPP((j_decompress_ptr cinfo, + boolean is_os2)); +EXTERN(cjpeg_source_ptr) jinit_read_gif JPP((j_compress_ptr cinfo)); +EXTERN(djpeg_dest_ptr) jinit_write_gif JPP((j_decompress_ptr cinfo)); +EXTERN(cjpeg_source_ptr) jinit_read_ppm JPP((j_compress_ptr cinfo)); +EXTERN(djpeg_dest_ptr) jinit_write_ppm JPP((j_decompress_ptr cinfo)); +EXTERN(cjpeg_source_ptr) jinit_read_rle JPP((j_compress_ptr cinfo)); +EXTERN(djpeg_dest_ptr) jinit_write_rle JPP((j_decompress_ptr cinfo)); +EXTERN(cjpeg_source_ptr) jinit_read_targa JPP((j_compress_ptr cinfo)); +EXTERN(djpeg_dest_ptr) jinit_write_targa JPP((j_decompress_ptr cinfo)); + +/* cjpeg support routines (in rdswitch.c) */ + +EXTERN(boolean) read_quant_tables JPP((j_compress_ptr cinfo, char * filename, + int scale_factor, boolean force_baseline)); +EXTERN(boolean) read_scan_script JPP((j_compress_ptr cinfo, char * filename)); +EXTERN(boolean) set_quant_slots JPP((j_compress_ptr cinfo, char *arg)); +EXTERN(boolean) set_sample_factors JPP((j_compress_ptr cinfo, char *arg)); + +/* djpeg support routines (in rdcolmap.c) */ + +EXTERN(void) read_color_map JPP((j_decompress_ptr cinfo, FILE * infile)); + +/* common support routines (in cdjpeg.c) */ + +EXTERN(void) enable_signal_catcher JPP((j_common_ptr cinfo)); +EXTERN(void) start_progress_monitor JPP((j_common_ptr cinfo, + cd_progress_ptr progress)); +EXTERN(void) end_progress_monitor JPP((j_common_ptr cinfo)); +EXTERN(boolean) keymatch JPP((char * arg, const char * keyword, int minchars)); +EXTERN(FILE *) read_stdin JPP((void)); +EXTERN(FILE *) write_stdout JPP((void)); + +/* miscellaneous useful macros */ + +#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ +#define READ_BINARY "r" +#define WRITE_BINARY "w" +#else +#define READ_BINARY "rb" +#define WRITE_BINARY "wb" +#endif + +#ifndef EXIT_FAILURE /* define exit() codes if not provided */ +#define EXIT_FAILURE 1 +#endif +#ifndef EXIT_SUCCESS +#ifdef VMS +#define EXIT_SUCCESS 1 /* VMS is very nonstandard */ +#else +#define EXIT_SUCCESS 0 +#endif +#endif +#ifndef EXIT_WARNING +#ifdef VMS +#define EXIT_WARNING 1 /* VMS is very nonstandard */ +#else +#define EXIT_WARNING 2 +#endif +#endif diff --git a/gs/jpeg/change.log b/gs/jpeg/change.log new file mode 100644 index 000000000..231650e89 --- /dev/null +++ b/gs/jpeg/change.log @@ -0,0 +1,152 @@ +CHANGE LOG for Independent JPEG Group's JPEG software + + +Version 6a 7-Feb-96 +-------------------- + +Library initialization sequence modified to detect version mismatches +and struct field packing mismatches between library and calling application. +This change requires applications to be recompiled, but does not require +any application source code change. + +All routine declarations changed to the style "GLOBAL(type) name ...", +that is, GLOBAL, LOCAL, METHODDEF, EXTERN are now macros taking the +routine's return type as an argument. This makes it possible to add +Microsoft-style linkage keywords to all the routines by changing just +these macros. Note that any application code that was using these macros +will have to be changed. + +DCT coefficient quantization tables are now stored in normal array order +rather than zigzag order. Application code that calls jpeg_add_quant_table, +or otherwise manipulates quantization tables directly, will need to be +changed. If you need to make such code work with either older or newer +versions of the library, a test like "#if JPEG_LIB_VERSION >= 61" is +recommended. + +djpeg's trace capability now dumps DQT tables in natural order, not zigzag +order. This allows the trace output to be made into a "-qtables" file +more easily. + +New system-dependent memory manager module for use on Apple Macintosh. + +Fix bug in cjpeg's -smooth option: last one or two scanlines would be +duplicates of the prior line unless the image height mod 16 was 1 or 2. + +Repair minor problems in VMS, BCC, MC6 makefiles. + +New configure script based on latest GNU Autoconf. + +Correct the list of include files needed by MetroWerks C for ccommand(). + +Numerous small documentation updates. + + +Version 6 2-Aug-95 +------------------- + +Progressive JPEG support: library can read and write full progressive JPEG +files. A "buffered image" mode supports incremental decoding for on-the-fly +display of progressive images. Simply recompiling an existing IJG-v5-based +decoder with v6 should allow it to read progressive files, though of course +without any special progressive display. + +New "jpegtran" application performs lossless transcoding between different +JPEG formats; primarily, it can be used to convert baseline to progressive +JPEG and vice versa. In support of jpegtran, the library now allows lossless +reading and writing of JPEG files as DCT coefficient arrays. This ability +may be of use in other applications. + +Notes for programmers: +* We changed jpeg_start_decompress() to be able to suspend; this makes all +decoding modes available to suspending-input applications. However, +existing applications that use suspending input will need to be changed +to check the return value from jpeg_start_decompress(). You don't need to +do anything if you don't use a suspending data source. +* We changed the interface to the virtual array routines: access_virt_array +routines now take a count of the number of rows to access this time. The +last parameter to request_virt_array routines is now interpreted as the +maximum number of rows that may be accessed at once, but not necessarily +the height of every access. + + +Version 5b 15-Mar-95 +--------------------- + +Correct bugs with grayscale images having v_samp_factor > 1. + +jpeg_write_raw_data() now supports output suspension. + +Correct bugs in "configure" script for case of compiling in +a directory other than the one containing the source files. + +Repair bug in jquant1.c: sometimes didn't use as many colors as it could. + +Borland C makefile and jconfig file work under either MS-DOS or OS/2. + +Miscellaneous improvements to documentation. + + +Version 5a 7-Dec-94 +-------------------- + +Changed color conversion roundoff behavior so that grayscale values are +represented exactly. (This causes test image files to change.) + +Make ordered dither use 16x16 instead of 4x4 pattern for a small quality +improvement. + +New configure script based on latest GNU Autoconf. +Fix configure script to handle CFLAGS correctly. +Rename *.auto files to *.cfg, so that configure script still works if +file names have been truncated for DOS. + +Fix bug in rdbmp.c: didn't allow for extra data between header and image. + +Modify rdppm.c/wrppm.c to handle 2-byte raw PPM/PGM formats for 12-bit data. + +Fix several bugs in rdrle.c. + +NEED_SHORT_EXTERNAL_NAMES option was broken. + +Revise jerror.h/jerror.c for more flexibility in message table. + +Repair oversight in jmemname.c NO_MKTEMP case: file could be there +but unreadable. + + +Version 5 24-Sep-94 +-------------------- + +Version 5 represents a nearly complete redesign and rewrite of the IJG +software. Major user-visible changes include: + * Automatic configuration simplifies installation for most Unix systems. + * A range of speed vs. image quality tradeoffs are supported. + This includes resizing of an image during decompression: scaling down + by a factor of 1/2, 1/4, or 1/8 is handled very efficiently. + * New programs rdjpgcom and wrjpgcom allow insertion and extraction + of text comments in a JPEG file. + +The application programmer's interface to the library has changed completely. +Notable improvements include: + * We have eliminated the use of callback routines for handling the + uncompressed image data. The application now sees the library as a + set of routines that it calls to read or write image data on a + scanline-by-scanline basis. + * The application image data is represented in a conventional interleaved- + pixel format, rather than as a separate array for each color channel. + This can save a copying step in many programs. + * The handling of compressed data has been cleaned up: the application can + supply routines to source or sink the compressed data. It is possible to + suspend processing on source/sink buffer overrun, although this is not + supported in all operating modes. + * All static state has been eliminated from the library, so that multiple + instances of compression or decompression can be active concurrently. + * JPEG abbreviated datastream formats are supported, ie, quantization and + Huffman tables can be stored separately from the image data. + * And not only that, but the documentation of the library has improved + considerably! + + +The last widely used release before the version 5 rewrite was version 4A of +18-Feb-93. Change logs before that point have been discarded, since they +are not of much interest after the rewrite. diff --git a/gs/jpeg/cjpeg b/gs/jpeg/cjpeg new file mode 100755 index 000000000..ec33ca313 Binary files /dev/null and b/gs/jpeg/cjpeg differ diff --git a/gs/jpeg/cjpeg.1 b/gs/jpeg/cjpeg.1 new file mode 100644 index 000000000..4dfce000c --- /dev/null +++ b/gs/jpeg/cjpeg.1 @@ -0,0 +1,282 @@ +.TH CJPEG 1 "15 June 1995" +.SH NAME +cjpeg \- compress an image file to a JPEG file +.SH SYNOPSIS +.B cjpeg +[ +.I options +] +[ +.I filename +] +.LP +.SH DESCRIPTION +.LP +.B cjpeg +compresses the named image file, or the standard input if no file is +named, and produces a JPEG/JFIF file on the standard output. +The currently supported input file formats are: PPM (PBMPLUS color +format), PGM (PBMPLUS gray-scale format), BMP, GIF, Targa, and RLE (Utah Raster +Toolkit format). (RLE is supported only if the URT library is available.) +.SH OPTIONS +All switch names may be abbreviated; for example, +.B \-grayscale +may be written +.B \-gray +or +.BR \-gr . +Most of the "basic" switches can be abbreviated to as little as one letter. +Upper and lower case are equivalent (thus +.B \-GIF +is the same as +.BR \-gif ). +British spellings are also accepted (e.g., +.BR \-greyscale ), +though for brevity these are not mentioned below. +.PP +The basic switches are: +.TP +.BI \-quality " N" +Scale quantization tables to adjust image quality. Quality is 0 (worst) to +100 (best); default is 75. (See below for more info.) +.TP +.B \-grayscale +Create monochrome JPEG file from color input. Be sure to use this switch when +compressing a grayscale GIF file, because +.B cjpeg +isn't bright enough to notice whether a GIF file uses only shades of gray. +By saying +.BR \-grayscale , +you'll get a smaller JPEG file that takes less time to process. +.TP +.B \-optimize +Perform optimization of entropy encoding parameters. Without this, default +encoding parameters are used. +.B \-optimize +usually makes the JPEG file a little smaller, but +.B cjpeg +runs somewhat slower and needs much more memory. Image quality and speed of +decompression are unaffected by +.BR \-optimize . +.TP +.B \-progressive +Create progressive JPEG file (see below). +.TP +.B \-targa +Input file is Targa format. Targa files that contain an "identification" +field will not be automatically recognized by +.BR cjpeg ; +for such files you must specify +.B \-targa +to make +.B cjpeg +treat the input as Targa format. +For most Targa files, you won't need this switch. +.PP +The +.B \-quality +switch lets you trade off compressed file size against quality of the +reconstructed image: the higher the quality setting, the larger the JPEG file, +and the closer the output image will be to the original input. Normally you +want to use the lowest quality setting (smallest file) that decompresses into +something visually indistinguishable from the original image. For this +purpose the quality setting should be between 50 and 95; the default of 75 is +often about right. If you see defects at +.B \-quality +75, then go up 5 or 10 counts at a time until you are happy with the output +image. (The optimal setting will vary from one image to another.) +.PP +.B \-quality +100 will generate a quantization table of all 1's, minimizing loss in the +quantization step (but there is still information loss in subsampling, as well +as roundoff error). This setting is mainly of interest for experimental +purposes. Quality values above about 95 are +.B not +recommended for normal use; the compressed file size goes up dramatically for +hardly any gain in output image quality. +.PP +In the other direction, quality values below 50 will produce very small files +of low image quality. Settings around 5 to 10 might be useful in preparing an +index of a large image library, for example. Try +.B \-quality +2 (or so) for some amusing Cubist effects. (Note: quality +values below about 25 generate 2-byte quantization tables, which are +considered optional in the JPEG standard. +.B cjpeg +emits a warning message when you give such a quality value, because some +other JPEG programs may be unable to decode the resulting file. Use +.B \-baseline +if you need to ensure compatibility at low quality values.) +.PP +The +.B \-progressive +switch creates a "progressive JPEG" file. In this type of JPEG file, the data +is stored in multiple scans of increasing quality. If the file is being +transmitted over a slow communications link, the decoder can use the first +scan to display a low-quality image very quickly, and can then improve the +display with each subsequent scan. The final image is exactly equivalent to a +standard JPEG file of the same quality setting, and the total file size is +about the same --- often a little smaller. +.B Caution: +progressive JPEG is not yet widely implemented, so many decoders will be +unable to view a progressive JPEG file at all. +.PP +Switches for advanced users: +.TP +.B \-dct int +Use integer DCT method (default). +.TP +.B \-dct fast +Use fast integer DCT (less accurate). +.TP +.B \-dct float +Use floating-point DCT method. +The float method is very slightly more accurate than the int method, but is +much slower unless your machine has very fast floating-point hardware. Also +note that results of the floating-point method may vary slightly across +machines, while the integer methods should give the same results everywhere. +The fast integer method is much less accurate than the other two. +.TP +.BI \-restart " N" +Emit a JPEG restart marker every N MCU rows, or every N MCU blocks if "B" is +attached to the number. +.B \-restart 0 +(the default) means no restart markers. +.TP +.BI \-smooth " N" +Smooth the input image to eliminate dithering noise. N, ranging from 1 to +100, indicates the strength of smoothing. 0 (the default) means no smoothing. +.TP +.BI \-maxmemory " N" +Set limit for amount of memory to use in processing large images. Value is +in thousands of bytes, or millions of bytes if "M" is attached to the +number. For example, +.B \-max 4m +selects 4000000 bytes. If more space is needed, temporary files will be used. +.TP +.BI \-outfile " name" +Send output image to the named file, not to standard output. +.TP +.B \-verbose +Enable debug printout. More +.BR \-v 's +give more output. Also, version information is printed at startup. +.TP +.B \-debug +Same as +.BR \-verbose . +.PP +The +.B \-restart +option inserts extra markers that allow a JPEG decoder to resynchronize after +a transmission error. Without restart markers, any damage to a compressed +file will usually ruin the image from the point of the error to the end of the +image; with restart markers, the damage is usually confined to the portion of +the image up to the next restart marker. Of course, the restart markers +occupy extra space. We recommend +.B \-restart 1 +for images that will be transmitted across unreliable networks such as Usenet. +.PP +The +.B \-smooth +option filters the input to eliminate fine-scale noise. This is often useful +when converting GIF files to JPEG: a moderate smoothing factor of 10 to 50 +gets rid of dithering patterns in the input file, resulting in a smaller JPEG +file and a better-looking image. Too large a smoothing factor will visibly +blur the image, however. +.PP +Switches for wizards: +.TP +.B \-baseline +Force a baseline JPEG file to be generated. This clamps quantization values +to 8 bits even at low quality settings. +.TP +.BI \-qtables " file" +Use the quantization tables given in the specified text file. +.TP +.BI \-qslots " N[,...]" +Select which quantization table to use for each color component. +.TP +.BI \-sample " HxV[,...]" +Set JPEG sampling factors for each color component. +.TP +.BI \-scans " file" +Use the scan script given in the specified text file. +.PP +The "wizard" switches are intended for experimentation with JPEG. If you +don't know what you are doing, \fBdon't use them\fR. These switches are +documented further in the file wizard.doc. +.SH EXAMPLES +.LP +This example compresses the PPM file foo.ppm with a quality factor of +60 and saves the output as foo.jpg: +.IP +.B cjpeg \-quality +.I 60 foo.ppm +.B > +.I foo.jpg +.SH HINTS +Color GIF files are not the ideal input for JPEG; JPEG is really intended for +compressing full-color (24-bit) images. In particular, don't try to convert +cartoons, line drawings, and other images that have only a few distinct +colors. GIF works great on these, JPEG does not. If you want to convert a +GIF to JPEG, you should experiment with +.BR cjpeg 's +.B \-quality +and +.B \-smooth +options to get a satisfactory conversion. +.B \-smooth 10 +or so is often helpful. +.PP +Avoid running an image through a series of JPEG compression/decompression +cycles. Image quality loss will accumulate; after ten or so cycles the image +may be noticeably worse than it was after one cycle. It's best to use a +lossless format while manipulating an image, then convert to JPEG format when +you are ready to file the image away. +.PP +The +.B \-optimize +option to +.B cjpeg +is worth using when you are making a "final" version for posting or archiving. +It's also a win when you are using low quality settings to make very small +JPEG files; the percentage improvement is often a lot more than it is on +larger files. (At present, +.B \-optimize +mode is always selected when generating progressive JPEG files.) +.SH ENVIRONMENT +.TP +.B JPEGMEM +If this environment variable is set, its value is the default memory limit. +The value is specified as described for the +.B \-maxmemory +switch. +.B JPEGMEM +overrides the default value specified when the program was compiled, and +itself is overridden by an explicit +.BR \-maxmemory . +.SH SEE ALSO +.BR djpeg (1), +.BR jpegtran (1), +.BR rdjpgcom (1), +.BR wrjpgcom (1) +.br +.BR ppm (5), +.BR pgm (5) +.br +Wallace, Gregory K. "The JPEG Still Picture Compression Standard", +Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44. +.SH AUTHOR +Independent JPEG Group +.SH BUGS +Arithmetic coding is not supported for legal reasons. +.PP +Not all variants of BMP and Targa file formats are supported. +.PP +The +.B \-targa +switch is not a bug, it's a feature. (It would be a bug if the Targa format +designers had not been clueless.) +.PP +Still not as fast as we'd like. diff --git a/gs/jpeg/cjpeg.c b/gs/jpeg/cjpeg.c new file mode 100644 index 000000000..194d93bdd --- /dev/null +++ b/gs/jpeg/cjpeg.c @@ -0,0 +1,606 @@ +/* + * cjpeg.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a command-line user interface for the JPEG compressor. + * It should work on any system with Unix- or MS-DOS-style command lines. + * + * Two different command line styles are permitted, depending on the + * compile-time switch TWO_FILE_COMMANDLINE: + * cjpeg [options] inputfile outputfile + * cjpeg [options] [inputfile] + * In the second style, output is always to standard output, which you'd + * normally redirect to a file or pipe to some other program. Input is + * either from a named file or from standard input (typically redirected). + * The second style is convenient on Unix but is unhelpful on systems that + * don't support pipes. Also, you MUST use the first style if your system + * doesn't do binary I/O to stdin/stdout. + * To simplify script writing, the "-outfile" switch is provided. The syntax + * cjpeg [options] -outfile outputfile inputfile + * works regardless of which command line style is used. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ +#include "jversion.h" /* for version message */ + +#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ +#ifdef __MWERKS__ +#include /* Metrowerks needs this */ +#include /* ... and this */ +#endif +#ifdef THINK_C +#include /* Think declares it here */ +#endif +#endif + + +/* Create the add-on message string table. */ + +#define JMESSAGE(code,string) string , + +static const char * const cdjpeg_message_table[] = { +#include "cderror.h" + NULL +}; + + +/* + * This routine determines what format the input file is, + * and selects the appropriate input-reading module. + * + * To determine which family of input formats the file belongs to, + * we may look only at the first byte of the file, since C does not + * guarantee that more than one character can be pushed back with ungetc. + * Looking at additional bytes would require one of these approaches: + * 1) assume we can fseek() the input file (fails for piped input); + * 2) assume we can push back more than one character (works in + * some C implementations, but unportable); + * 3) provide our own buffering (breaks input readers that want to use + * stdio directly, such as the RLE library); + * or 4) don't put back the data, and modify the input_init methods to assume + * they start reading after the start of file (also breaks RLE library). + * #1 is attractive for MS-DOS but is untenable on Unix. + * + * The most portable solution for file types that can't be identified by their + * first byte is to make the user tell us what they are. This is also the + * only approach for "raw" file types that contain only arbitrary values. + * We presently apply this method for Targa files. Most of the time Targa + * files start with 0x00, so we recognize that case. Potentially, however, + * a Targa file could start with any byte value (byte 0 is the length of the + * seldom-used ID field), so we provide a switch to force Targa input mode. + */ + +static boolean is_targa; /* records user -targa switch */ + + +LOCAL(cjpeg_source_ptr) +select_file_type (j_compress_ptr cinfo, FILE * infile) +{ + int c; + + if (is_targa) { +#ifdef TARGA_SUPPORTED + return jinit_read_targa(cinfo); +#else + ERREXIT(cinfo, JERR_TGA_NOTCOMP); +#endif + } + + if ((c = getc(infile)) == EOF) + ERREXIT(cinfo, JERR_INPUT_EMPTY); + if (ungetc(c, infile) == EOF) + ERREXIT(cinfo, JERR_UNGETC_FAILED); + + switch (c) { +#ifdef BMP_SUPPORTED + case 'B': + return jinit_read_bmp(cinfo); +#endif +#ifdef GIF_SUPPORTED + case 'G': + return jinit_read_gif(cinfo); +#endif +#ifdef PPM_SUPPORTED + case 'P': + return jinit_read_ppm(cinfo); +#endif +#ifdef RLE_SUPPORTED + case 'R': + return jinit_read_rle(cinfo); +#endif +#ifdef TARGA_SUPPORTED + case 0x00: + return jinit_read_targa(cinfo); +#endif + default: + ERREXIT(cinfo, JERR_UNKNOWN_FORMAT); + break; + } + + return NULL; /* suppress compiler warnings */ +} + + +/* + * Argument-parsing code. + * The switch parser is designed to be useful with DOS-style command line + * syntax, ie, intermixed switches and file names, where only the switches + * to the left of a given file name affect processing of that file. + * The main program in this file doesn't actually use this capability... + */ + + +static const char * progname; /* program name for error messages */ +static char * outfilename; /* for -outfile switch */ + + +LOCAL(void) +usage (void) +/* complain about bad command line */ +{ + fprintf(stderr, "usage: %s [switches] ", progname); +#ifdef TWO_FILE_COMMANDLINE + fprintf(stderr, "inputfile outputfile\n"); +#else + fprintf(stderr, "[inputfile]\n"); +#endif + + fprintf(stderr, "Switches (names may be abbreviated):\n"); + fprintf(stderr, " -quality N Compression quality (0..100; 5-95 is useful range)\n"); + fprintf(stderr, " -grayscale Create monochrome JPEG file\n"); +#ifdef ENTROPY_OPT_SUPPORTED + fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression)\n"); +#endif +#ifdef C_PROGRESSIVE_SUPPORTED + fprintf(stderr, " -progressive Create progressive JPEG file\n"); +#endif +#ifdef TARGA_SUPPORTED + fprintf(stderr, " -targa Input file is Targa format (usually not needed)\n"); +#endif + fprintf(stderr, "Switches for advanced users:\n"); +#ifdef DCT_ISLOW_SUPPORTED + fprintf(stderr, " -dct int Use integer DCT method%s\n", + (JDCT_DEFAULT == JDCT_ISLOW ? " (default)" : "")); +#endif +#ifdef DCT_IFAST_SUPPORTED + fprintf(stderr, " -dct fast Use fast integer DCT (less accurate)%s\n", + (JDCT_DEFAULT == JDCT_IFAST ? " (default)" : "")); +#endif +#ifdef DCT_FLOAT_SUPPORTED + fprintf(stderr, " -dct float Use floating-point DCT method%s\n", + (JDCT_DEFAULT == JDCT_FLOAT ? " (default)" : "")); +#endif + fprintf(stderr, " -restart N Set restart interval in rows, or in blocks with B\n"); +#ifdef INPUT_SMOOTHING_SUPPORTED + fprintf(stderr, " -smooth N Smooth dithered input (N=1..100 is strength)\n"); +#endif + fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n"); + fprintf(stderr, " -outfile name Specify name for output file\n"); + fprintf(stderr, " -verbose or -debug Emit debug output\n"); + fprintf(stderr, "Switches for wizards:\n"); +#ifdef C_ARITH_CODING_SUPPORTED + fprintf(stderr, " -arithmetic Use arithmetic coding\n"); +#endif + fprintf(stderr, " -baseline Force baseline output\n"); + fprintf(stderr, " -qtables file Use quantization tables given in file\n"); + fprintf(stderr, " -qslots N[,...] Set component quantization tables\n"); + fprintf(stderr, " -sample HxV[,...] Set component sampling factors\n"); +#ifdef C_MULTISCAN_FILES_SUPPORTED + fprintf(stderr, " -scans file Create multi-scan JPEG per script file\n"); +#endif + exit(EXIT_FAILURE); +} + + +LOCAL(int) +parse_switches (j_compress_ptr cinfo, int argc, char **argv, + int last_file_arg_seen, boolean for_real) +/* Parse optional switches. + * Returns argv[] index of first file-name argument (== argc if none). + * Any file names with indexes <= last_file_arg_seen are ignored; + * they have presumably been processed in a previous iteration. + * (Pass 0 for last_file_arg_seen on the first or only iteration.) + * for_real is FALSE on the first (dummy) pass; we may skip any expensive + * processing. + */ +{ + int argn; + char * arg; + int quality; /* -quality parameter */ + int q_scale_factor; /* scaling percentage for -qtables */ + boolean force_baseline; + boolean simple_progressive; + char * qtablefile = NULL; /* saves -qtables filename if any */ + char * qslotsarg = NULL; /* saves -qslots parm if any */ + char * samplearg = NULL; /* saves -sample parm if any */ + char * scansarg = NULL; /* saves -scans parm if any */ + + /* Set up default JPEG parameters. */ + /* Note that default -quality level need not, and does not, + * match the default scaling for an explicit -qtables argument. + */ + quality = 75; /* default -quality value */ + q_scale_factor = 100; /* default to no scaling for -qtables */ + force_baseline = FALSE; /* by default, allow 16-bit quantizers */ + simple_progressive = FALSE; + is_targa = FALSE; + outfilename = NULL; + cinfo->err->trace_level = 0; + + /* Scan command line options, adjust parameters */ + + for (argn = 1; argn < argc; argn++) { + arg = argv[argn]; + if (*arg != '-') { + /* Not a switch, must be a file name argument */ + if (argn <= last_file_arg_seen) { + outfilename = NULL; /* -outfile applies to just one input file */ + continue; /* ignore this name if previously processed */ + } + break; /* else done parsing switches */ + } + arg++; /* advance past switch marker character */ + + if (keymatch(arg, "arithmetic", 1)) { + /* Use arithmetic coding. */ +#ifdef C_ARITH_CODING_SUPPORTED + cinfo->arith_code = TRUE; +#else + fprintf(stderr, "%s: sorry, arithmetic coding not supported\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else if (keymatch(arg, "baseline", 1)) { + /* Force baseline output (8-bit quantizer values). */ + force_baseline = TRUE; + + } else if (keymatch(arg, "dct", 2)) { + /* Select DCT algorithm. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + if (keymatch(argv[argn], "int", 1)) { + cinfo->dct_method = JDCT_ISLOW; + } else if (keymatch(argv[argn], "fast", 2)) { + cinfo->dct_method = JDCT_IFAST; + } else if (keymatch(argv[argn], "float", 2)) { + cinfo->dct_method = JDCT_FLOAT; + } else + usage(); + + } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) { + /* Enable debug printouts. */ + /* On first -d, print version identification */ + static boolean printed_version = FALSE; + + if (! printed_version) { + fprintf(stderr, "Independent JPEG Group's CJPEG, version %s\n%s\n", + JVERSION, JCOPYRIGHT); + printed_version = TRUE; + } + cinfo->err->trace_level++; + + } else if (keymatch(arg, "grayscale", 2) || keymatch(arg, "greyscale",2)) { + /* Force a monochrome JPEG file to be generated. */ + jpeg_set_colorspace(cinfo, JCS_GRAYSCALE); + + } else if (keymatch(arg, "maxmemory", 3)) { + /* Maximum memory in Kb (or Mb with 'm'). */ + long lval; + char ch = 'x'; + + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) + usage(); + if (ch == 'm' || ch == 'M') + lval *= 1000L; + cinfo->mem->max_memory_to_use = lval * 1000L; + + } else if (keymatch(arg, "optimize", 1) || keymatch(arg, "optimise", 1)) { + /* Enable entropy parm optimization. */ +#ifdef ENTROPY_OPT_SUPPORTED + cinfo->optimize_coding = TRUE; +#else + fprintf(stderr, "%s: sorry, entropy optimization was not compiled\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else if (keymatch(arg, "outfile", 4)) { + /* Set output file name. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + outfilename = argv[argn]; /* save it away for later use */ + + } else if (keymatch(arg, "progressive", 1)) { + /* Select simple progressive mode. */ +#ifdef C_PROGRESSIVE_SUPPORTED + simple_progressive = TRUE; + /* We must postpone execution until num_components is known. */ +#else + fprintf(stderr, "%s: sorry, progressive output was not compiled\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else if (keymatch(arg, "quality", 1)) { + /* Quality factor (quantization table scaling factor). */ + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%d", &quality) != 1) + usage(); + /* Change scale factor in case -qtables is present. */ + q_scale_factor = jpeg_quality_scaling(quality); + + } else if (keymatch(arg, "qslots", 2)) { + /* Quantization table slot numbers. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + qslotsarg = argv[argn]; + /* Must delay setting qslots until after we have processed any + * colorspace-determining switches, since jpeg_set_colorspace sets + * default quant table numbers. + */ + + } else if (keymatch(arg, "qtables", 2)) { + /* Quantization tables fetched from file. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + qtablefile = argv[argn]; + /* We postpone actually reading the file in case -quality comes later. */ + + } else if (keymatch(arg, "restart", 1)) { + /* Restart interval in MCU rows (or in MCUs with 'b'). */ + long lval; + char ch = 'x'; + + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) + usage(); + if (lval < 0 || lval > 65535L) + usage(); + if (ch == 'b' || ch == 'B') { + cinfo->restart_interval = (unsigned int) lval; + cinfo->restart_in_rows = 0; /* else prior '-restart n' overrides me */ + } else { + cinfo->restart_in_rows = (int) lval; + /* restart_interval will be computed during startup */ + } + + } else if (keymatch(arg, "sample", 2)) { + /* Set sampling factors. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + samplearg = argv[argn]; + /* Must delay setting sample factors until after we have processed any + * colorspace-determining switches, since jpeg_set_colorspace sets + * default sampling factors. + */ + + } else if (keymatch(arg, "scans", 2)) { + /* Set scan script. */ +#ifdef C_MULTISCAN_FILES_SUPPORTED + if (++argn >= argc) /* advance to next argument */ + usage(); + scansarg = argv[argn]; + /* We must postpone reading the file in case -progressive appears. */ +#else + fprintf(stderr, "%s: sorry, multi-scan output was not compiled\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else if (keymatch(arg, "smooth", 2)) { + /* Set input smoothing factor. */ + int val; + + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%d", &val) != 1) + usage(); + if (val < 0 || val > 100) + usage(); + cinfo->smoothing_factor = val; + + } else if (keymatch(arg, "targa", 1)) { + /* Input file is Targa format. */ + is_targa = TRUE; + + } else { + usage(); /* bogus switch */ + } + } + + /* Post-switch-scanning cleanup */ + + if (for_real) { + + /* Set quantization tables for selected quality. */ + /* Some or all may be overridden if -qtables is present. */ + jpeg_set_quality(cinfo, quality, force_baseline); + + if (qtablefile != NULL) /* process -qtables if it was present */ + if (! read_quant_tables(cinfo, qtablefile, + q_scale_factor, force_baseline)) + usage(); + + if (qslotsarg != NULL) /* process -qslots if it was present */ + if (! set_quant_slots(cinfo, qslotsarg)) + usage(); + + if (samplearg != NULL) /* process -sample if it was present */ + if (! set_sample_factors(cinfo, samplearg)) + usage(); + +#ifdef C_PROGRESSIVE_SUPPORTED + if (simple_progressive) /* process -progressive; -scans can override */ + jpeg_simple_progression(cinfo); +#endif + +#ifdef C_MULTISCAN_FILES_SUPPORTED + if (scansarg != NULL) /* process -scans if it was present */ + if (! read_scan_script(cinfo, scansarg)) + usage(); +#endif + } + + return argn; /* return index of next arg (file name) */ +} + + +/* + * The main program. + */ + +int +main (int argc, char **argv) +{ + struct jpeg_compress_struct cinfo; + struct jpeg_error_mgr jerr; +#ifdef PROGRESS_REPORT + struct cdjpeg_progress_mgr progress; +#endif + int file_index; + cjpeg_source_ptr src_mgr; + FILE * input_file; + FILE * output_file; + JDIMENSION num_scanlines; + + /* On Mac, fetch a command line. */ +#ifdef USE_CCOMMAND + argc = ccommand(&argv); +#endif + + progname = argv[0]; + if (progname == NULL || progname[0] == 0) + progname = "cjpeg"; /* in case C library doesn't provide it */ + + /* Initialize the JPEG compression object with default error handling. */ + cinfo.err = jpeg_std_error(&jerr); + jpeg_create_compress(&cinfo); + /* Add some application-specific error messages (from cderror.h) */ + jerr.addon_message_table = cdjpeg_message_table; + jerr.first_addon_message = JMSG_FIRSTADDONCODE; + jerr.last_addon_message = JMSG_LASTADDONCODE; + + /* Now safe to enable signal catcher. */ +#ifdef NEED_SIGNAL_CATCHER + enable_signal_catcher((j_common_ptr) &cinfo); +#endif + + /* Initialize JPEG parameters. + * Much of this may be overridden later. + * In particular, we don't yet know the input file's color space, + * but we need to provide some value for jpeg_set_defaults() to work. + */ + + cinfo.in_color_space = JCS_RGB; /* arbitrary guess */ + jpeg_set_defaults(&cinfo); + + /* Scan command line to find file names. + * It is convenient to use just one switch-parsing routine, but the switch + * values read here are ignored; we will rescan the switches after opening + * the input file. + */ + + file_index = parse_switches(&cinfo, argc, argv, 0, FALSE); + +#ifdef TWO_FILE_COMMANDLINE + /* Must have either -outfile switch or explicit output file name */ + if (outfilename == NULL) { + if (file_index != argc-2) { + fprintf(stderr, "%s: must name one input and one output file\n", + progname); + usage(); + } + outfilename = argv[file_index+1]; + } else { + if (file_index != argc-1) { + fprintf(stderr, "%s: must name one input and one output file\n", + progname); + usage(); + } + } +#else + /* Unix style: expect zero or one file name */ + if (file_index < argc-1) { + fprintf(stderr, "%s: only one input file\n", progname); + usage(); + } +#endif /* TWO_FILE_COMMANDLINE */ + + /* Open the input file. */ + if (file_index < argc) { + if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, argv[file_index]); + exit(EXIT_FAILURE); + } + } else { + /* default input file is stdin */ + input_file = read_stdin(); + } + + /* Open the output file. */ + if (outfilename != NULL) { + if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, outfilename); + exit(EXIT_FAILURE); + } + } else { + /* default output file is stdout */ + output_file = write_stdout(); + } + +#ifdef PROGRESS_REPORT + start_progress_monitor((j_common_ptr) &cinfo, &progress); +#endif + + /* Figure out the input file format, and set up to read it. */ + src_mgr = select_file_type(&cinfo, input_file); + src_mgr->input_file = input_file; + + /* Read the input file header to obtain file size & colorspace. */ + (*src_mgr->start_input) (&cinfo, src_mgr); + + /* Now that we know input colorspace, fix colorspace-dependent defaults */ + jpeg_default_colorspace(&cinfo); + + /* Adjust default compression parameters by re-parsing the options */ + file_index = parse_switches(&cinfo, argc, argv, 0, TRUE); + + /* Specify data destination for compression */ + jpeg_stdio_dest(&cinfo, output_file); + + /* Start compressor */ + jpeg_start_compress(&cinfo, TRUE); + + /* Process data */ + while (cinfo.next_scanline < cinfo.image_height) { + num_scanlines = (*src_mgr->get_pixel_rows) (&cinfo, src_mgr); + (void) jpeg_write_scanlines(&cinfo, src_mgr->buffer, num_scanlines); + } + + /* Finish compression and release memory */ + (*src_mgr->finish_input) (&cinfo, src_mgr); + jpeg_finish_compress(&cinfo); + jpeg_destroy_compress(&cinfo); + + /* Close files, if we opened them */ + if (input_file != stdin) + fclose(input_file); + if (output_file != stdout) + fclose(output_file); + +#ifdef PROGRESS_REPORT + end_progress_monitor((j_common_ptr) &cinfo); +#endif + + /* All done. */ + exit(jerr.num_warnings ? EXIT_WARNING : EXIT_SUCCESS); + return 0; /* suppress no-return-value warnings */ +} diff --git a/gs/jpeg/ckconfig.c b/gs/jpeg/ckconfig.c new file mode 100644 index 000000000..34baf795b --- /dev/null +++ b/gs/jpeg/ckconfig.c @@ -0,0 +1,402 @@ +/* + * ckconfig.c + * + * Copyright (C) 1991-1994, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + */ + +/* + * This program is intended to help you determine how to configure the JPEG + * software for installation on a particular system. The idea is to try to + * compile and execute this program. If your compiler fails to compile the + * program, make changes as indicated in the comments below. Once you can + * compile the program, run it, and it will produce a "jconfig.h" file for + * your system. + * + * As a general rule, each time you try to compile this program, + * pay attention only to the *first* error message you get from the compiler. + * Many C compilers will issue lots of spurious error messages once they + * have gotten confused. Go to the line indicated in the first error message, + * and read the comments preceding that line to see what to change. + * + * Almost all of the edits you may need to make to this program consist of + * changing a line that reads "#define SOME_SYMBOL" to "#undef SOME_SYMBOL", + * or vice versa. This is called defining or undefining that symbol. + */ + + +/* First we must see if your system has the include files we need. + * We start out with the assumption that your system has all the ANSI-standard + * include files. If you get any error trying to include one of these files, + * undefine the corresponding HAVE_xxx symbol. + */ + +#define HAVE_STDDEF_H /* replace 'define' by 'undef' if error here */ +#ifdef HAVE_STDDEF_H /* next line will be skipped if you undef... */ +#include +#endif + +#define HAVE_STDLIB_H /* same thing for stdlib.h */ +#ifdef HAVE_STDLIB_H +#include +#endif + +#include /* If you ain't got this, you ain't got C. */ + +/* We have to see if your string functions are defined by + * strings.h (old BSD convention) or string.h (everybody else). + * We try the non-BSD convention first; define NEED_BSD_STRINGS + * if the compiler says it can't find string.h. + */ + +#undef NEED_BSD_STRINGS + +#ifdef NEED_BSD_STRINGS +#include +#else +#include +#endif + +/* On some systems (especially older Unix machines), type size_t is + * defined only in the include file . If you get a failure + * on the size_t test below, try defining NEED_SYS_TYPES_H. + */ + +#undef NEED_SYS_TYPES_H /* start by assuming we don't need it */ +#ifdef NEED_SYS_TYPES_H +#include +#endif + + +/* Usually type size_t is defined in one of the include files we've included + * above. If not, you'll get an error on the "typedef size_t my_size_t;" line. + * In that case, first try defining NEED_SYS_TYPES_H just above. + * If that doesn't work, you'll have to search through your system library + * to figure out which include file defines "size_t". Look for a line that + * says "typedef something-or-other size_t;". Then, change the line below + * that says "#include " to instead include the file + * you found size_t in, and define NEED_SPECIAL_INCLUDE. If you can't find + * type size_t anywhere, try replacing "#include " with + * "typedef unsigned int size_t;". + */ + +#undef NEED_SPECIAL_INCLUDE /* assume we DON'T need it, for starters */ + +#ifdef NEED_SPECIAL_INCLUDE +#include +#endif + +typedef size_t my_size_t; /* The payoff: do we have size_t now? */ + + +/* The next question is whether your compiler supports ANSI-style function + * prototypes. You need to know this in order to choose between using + * makefile.ansi and using makefile.unix. + * The #define line below is set to assume you have ANSI function prototypes. + * If you get an error in this group of lines, undefine HAVE_PROTOTYPES. + */ + +#define HAVE_PROTOTYPES + +#ifdef HAVE_PROTOTYPES +int testfunction (int arg1, int * arg2); /* check prototypes */ + +struct methods_struct { /* check method-pointer declarations */ + int (*error_exit) (char *msgtext); + int (*trace_message) (char *msgtext); + int (*another_method) (void); +}; + +int testfunction (int arg1, int * arg2) /* check definitions */ +{ + return arg2[arg1]; +} + +int test2function (void) /* check void arg list */ +{ + return 0; +} +#endif + + +/* Now we want to find out if your compiler knows what "unsigned char" means. + * If you get an error on the "unsigned char un_char;" line, + * then undefine HAVE_UNSIGNED_CHAR. + */ + +#define HAVE_UNSIGNED_CHAR + +#ifdef HAVE_UNSIGNED_CHAR +unsigned char un_char; +#endif + + +/* Now we want to find out if your compiler knows what "unsigned short" means. + * If you get an error on the "unsigned short un_short;" line, + * then undefine HAVE_UNSIGNED_SHORT. + */ + +#define HAVE_UNSIGNED_SHORT + +#ifdef HAVE_UNSIGNED_SHORT +unsigned short un_short; +#endif + + +/* Now we want to find out if your compiler understands type "void". + * If you get an error anywhere in here, undefine HAVE_VOID. + */ + +#define HAVE_VOID + +#ifdef HAVE_VOID +/* Caution: a C++ compiler will insist on complete prototypes */ +typedef void * void_ptr; /* check void * */ +#ifdef HAVE_PROTOTYPES /* check ptr to function returning void */ +typedef void (*void_func) (int a, int b); +#else +typedef void (*void_func) (); +#endif + +#ifdef HAVE_PROTOTYPES /* check void function result */ +void test3function (void_ptr arg1, void_func arg2) +#else +void test3function (arg1, arg2) + void_ptr arg1; + void_func arg2; +#endif +{ + char * locptr = (char *) arg1; /* check casting to and from void * */ + arg1 = (void *) locptr; + (*arg2) (1, 2); /* check call of fcn returning void */ +} +#endif + + +/* Now we want to find out if your compiler knows what "const" means. + * If you get an error here, undefine HAVE_CONST. + */ + +#define HAVE_CONST + +#ifdef HAVE_CONST +static const int carray[3] = {1, 2, 3}; + +#ifdef HAVE_PROTOTYPES +int test4function (const int arg1) +#else +int test4function (arg1) + const int arg1; +#endif +{ + return carray[arg1]; +} +#endif + + +/* If you get an error or warning about this structure definition, + * define INCOMPLETE_TYPES_BROKEN. + */ + +#undef INCOMPLETE_TYPES_BROKEN + +#ifndef INCOMPLETE_TYPES_BROKEN +typedef struct undefined_structure * undef_struct_ptr; +#endif + + +/* If you get an error about duplicate names, + * define NEED_SHORT_EXTERNAL_NAMES. + */ + +#undef NEED_SHORT_EXTERNAL_NAMES + +#ifndef NEED_SHORT_EXTERNAL_NAMES + +int possibly_duplicate_function () +{ + return 0; +} + +int possibly_dupli_function () +{ + return 1; +} + +#endif + + + +/************************************************************************ + * OK, that's it. You should not have to change anything beyond this + * point in order to compile and execute this program. (You might get + * some warnings, but you can ignore them.) + * When you run the program, it will make a couple more tests that it + * can do automatically, and then it will create jconfig.h and print out + * any additional suggestions it has. + ************************************************************************ + */ + + +#ifdef HAVE_PROTOTYPES +int is_char_signed (int arg) +#else +int is_char_signed (arg) + int arg; +#endif +{ + if (arg == 189) { /* expected result for unsigned char */ + return 0; /* type char is unsigned */ + } + else if (arg != -67) { /* expected result for signed char */ + printf("Hmm, it seems 'char' is not eight bits wide on your machine.\n"); + printf("I fear the JPEG software will not work at all.\n\n"); + } + return 1; /* assume char is signed otherwise */ +} + + +#ifdef HAVE_PROTOTYPES +int is_shifting_signed (long arg) +#else +int is_shifting_signed (arg) + long arg; +#endif +/* See whether right-shift on a long is signed or not. */ +{ + long res = arg >> 4; + + if (res == -0x7F7E80CL) { /* expected result for signed shift */ + return 1; /* right shift is signed */ + } + /* see if unsigned-shift hack will fix it. */ + /* we can't just test exact value since it depends on width of long... */ + res |= (~0L) << (32-4); + if (res == -0x7F7E80CL) { /* expected result now? */ + return 0; /* right shift is unsigned */ + } + printf("Right shift isn't acting as I expect it to.\n"); + printf("I fear the JPEG software will not work at all.\n\n"); + return 0; /* try it with unsigned anyway */ +} + + +#ifdef HAVE_PROTOTYPES +int main (int argc, char ** argv) +#else +int main (argc, argv) + int argc; + char ** argv; +#endif +{ + char signed_char_check = (char) (-67); + FILE *outfile; + + /* Attempt to write jconfig.h */ + if ((outfile = fopen("jconfig.h", "w")) == NULL) { + printf("Failed to write jconfig.h\n"); + return 1; + } + + /* Write out all the info */ + fprintf(outfile, "/* jconfig.h --- generated by ckconfig.c */\n"); + fprintf(outfile, "/* see jconfig.doc for explanations */\n\n"); +#ifdef HAVE_PROTOTYPES + fprintf(outfile, "#define HAVE_PROTOTYPES\n"); +#else + fprintf(outfile, "#undef HAVE_PROTOTYPES\n"); +#endif +#ifdef HAVE_UNSIGNED_CHAR + fprintf(outfile, "#define HAVE_UNSIGNED_CHAR\n"); +#else + fprintf(outfile, "#undef HAVE_UNSIGNED_CHAR\n"); +#endif +#ifdef HAVE_UNSIGNED_SHORT + fprintf(outfile, "#define HAVE_UNSIGNED_SHORT\n"); +#else + fprintf(outfile, "#undef HAVE_UNSIGNED_SHORT\n"); +#endif +#ifdef HAVE_VOID + fprintf(outfile, "/* #define void char */\n"); +#else + fprintf(outfile, "#define void char\n"); +#endif +#ifdef HAVE_CONST + fprintf(outfile, "/* #define const */\n"); +#else + fprintf(outfile, "#define const\n"); +#endif + if (is_char_signed((int) signed_char_check)) + fprintf(outfile, "#undef CHAR_IS_UNSIGNED\n"); + else + fprintf(outfile, "#define CHAR_IS_UNSIGNED\n"); +#ifdef HAVE_STDDEF_H + fprintf(outfile, "#define HAVE_STDDEF_H\n"); +#else + fprintf(outfile, "#undef HAVE_STDDEF_H\n"); +#endif +#ifdef HAVE_STDLIB_H + fprintf(outfile, "#define HAVE_STDLIB_H\n"); +#else + fprintf(outfile, "#undef HAVE_STDLIB_H\n"); +#endif +#ifdef NEED_BSD_STRINGS + fprintf(outfile, "#define NEED_BSD_STRINGS\n"); +#else + fprintf(outfile, "#undef NEED_BSD_STRINGS\n"); +#endif +#ifdef NEED_SYS_TYPES_H + fprintf(outfile, "#define NEED_SYS_TYPES_H\n"); +#else + fprintf(outfile, "#undef NEED_SYS_TYPES_H\n"); +#endif + fprintf(outfile, "#undef NEED_FAR_POINTERS\n"); +#ifdef NEED_SHORT_EXTERNAL_NAMES + fprintf(outfile, "#define NEED_SHORT_EXTERNAL_NAMES\n"); +#else + fprintf(outfile, "#undef NEED_SHORT_EXTERNAL_NAMES\n"); +#endif +#ifdef INCOMPLETE_TYPES_BROKEN + fprintf(outfile, "#define INCOMPLETE_TYPES_BROKEN\n"); +#else + fprintf(outfile, "#undef INCOMPLETE_TYPES_BROKEN\n"); +#endif + fprintf(outfile, "\n#ifdef JPEG_INTERNALS\n\n"); + if (is_shifting_signed(-0x7F7E80B1L)) + fprintf(outfile, "#undef RIGHT_SHIFT_IS_UNSIGNED\n"); + else + fprintf(outfile, "#define RIGHT_SHIFT_IS_UNSIGNED\n"); + fprintf(outfile, "\n#endif /* JPEG_INTERNALS */\n"); + fprintf(outfile, "\n#ifdef JPEG_CJPEG_DJPEG\n\n"); + fprintf(outfile, "#define BMP_SUPPORTED /* BMP image file format */\n"); + fprintf(outfile, "#define GIF_SUPPORTED /* GIF image file format */\n"); + fprintf(outfile, "#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */\n"); + fprintf(outfile, "#undef RLE_SUPPORTED /* Utah RLE image file format */\n"); + fprintf(outfile, "#define TARGA_SUPPORTED /* Targa image file format */\n\n"); + fprintf(outfile, "#undef TWO_FILE_COMMANDLINE /* You may need this on non-Unix systems */\n"); + fprintf(outfile, "#undef NEED_SIGNAL_CATCHER /* Define this if you use jmemname.c */\n"); + fprintf(outfile, "#undef DONT_USE_B_MODE\n"); + fprintf(outfile, "/* #define PROGRESS_REPORT */ /* optional */\n"); + fprintf(outfile, "\n#endif /* JPEG_CJPEG_DJPEG */\n"); + + /* Close the jconfig.h file */ + fclose(outfile); + + /* User report */ + printf("Configuration check for Independent JPEG Group's software done.\n"); + printf("\nI have written the jconfig.h file for you.\n\n"); +#ifdef HAVE_PROTOTYPES + printf("You should use makefile.ansi as the starting point for your Makefile.\n"); +#else + printf("You should use makefile.unix as the starting point for your Makefile.\n"); +#endif + +#ifdef NEED_SPECIAL_INCLUDE + printf("\nYou'll need to change jconfig.h to include the system include file\n"); + printf("that you found type size_t in, or add a direct definition of type\n"); + printf("size_t if that's what you used. Just add it to the end.\n"); +#endif + + return 0; +} diff --git a/gs/jpeg/coderules.doc b/gs/jpeg/coderules.doc new file mode 100644 index 000000000..0ab5d9bd3 --- /dev/null +++ b/gs/jpeg/coderules.doc @@ -0,0 +1,118 @@ +IJG JPEG LIBRARY: CODING RULES + +Copyright (C) 1991-1996, Thomas G. Lane. +This file is part of the Independent JPEG Group's software. +For conditions of distribution and use, see the accompanying README file. + + +Since numerous people will be contributing code and bug fixes, it's important +to establish a common coding style. The goal of using similar coding styles +is much more important than the details of just what that style is. + +In general we follow the recommendations of "Recommended C Style and Coding +Standards" revision 6.1 (Cannon et al. as modified by Spencer, Keppel and +Brader). This document is available in the IJG FTP archive (see +jpeg/doc/cstyle.ms.tbl.Z, or cstyle.txt.Z for those without nroff/tbl). + +Block comments should be laid out thusly: + +/* + * Block comments in this style. + */ + +We indent statements in K&R style, e.g., + if (test) { + then-part; + } else { + else-part; + } +with two spaces per indentation level. (This indentation convention is +handled automatically by GNU Emacs and many other text editors.) + +Multi-word names should be written in lower case with underscores, e.g., +multi_word_name (not multiWordName). Preprocessor symbols and enum constants +are similar but upper case (MULTI_WORD_NAME). Names should be unique within +the first fifteen characters. (On some older systems, global names must be +unique within six characters. We accommodate this without cluttering the +source code by using macros to substitute shorter names.) + +We use function prototypes everywhere; we rely on automatic source code +transformation to feed prototype-less C compilers. Transformation is done +by the simple and portable tool 'ansi2knr.c' (courtesy of Ghostscript). +ansi2knr is not very bright, so it imposes a format requirement on function +declarations: the function name MUST BEGIN IN COLUMN 1. Thus all functions +should be written in the following style: + +LOCAL(int *) +function_name (int a, char *b) +{ + code... +} + +Note that each function definition must begin with GLOBAL(type), LOCAL(type), +or METHODDEF(type). These macros expand to "static type" or just "type" as +appropriate. They provide a readable indication of the routine's usage and +can readily be changed for special needs. (For instance, special linkage +keywords can be inserted for use in Windows DLLs.) + +ansi2knr does not transform method declarations (function pointers in +structs). We handle these with a macro JMETHOD, defined as + #ifdef HAVE_PROTOTYPES + #define JMETHOD(type,methodname,arglist) type (*methodname) arglist + #else + #define JMETHOD(type,methodname,arglist) type (*methodname) () + #endif +which is used like this: + struct function_pointers { + JMETHOD(void, init_entropy_encoder, (int somearg, jparms *jp)); + JMETHOD(void, term_entropy_encoder, (void)); + }; +Note the set of parentheses surrounding the parameter list. + +A similar solution is used for forward and external function declarations +(see the EXTERN and JPP macros). + +If the code is to work on non-ANSI compilers, we cannot rely on a prototype +declaration to coerce actual parameters into the right types. Therefore, use +explicit casts on actual parameters whenever the actual parameter type is not +identical to the formal parameter. Beware of implicit conversions to "int". + +It seems there are some non-ANSI compilers in which the sizeof() operator +is defined to return int, yet size_t is defined as long. Needless to say, +this is brain-damaged. Always use the SIZEOF() macro in place of sizeof(), +so that the result is guaranteed to be of type size_t. + + +The JPEG library is intended to be used within larger programs. Furthermore, +we want it to be reentrant so that it can be used by applications that process +multiple images concurrently. The following rules support these requirements: + +1. Avoid direct use of file I/O, "malloc", error report printouts, etc; +pass these through the common routines provided. + +2. Minimize global namespace pollution. Functions should be declared static +wherever possible. (Note that our method-based calling conventions help this +a lot: in many modules only the initialization function will ever need to be +called directly, so only that function need be externally visible.) All +global function names should begin with "jpeg_", and should have an +abbreviated name (unique in the first six characters) substituted by macro +when NEED_SHORT_EXTERNAL_NAMES is set. + +3. Don't use global variables; anything that must be used in another module +should be in the common data structures. + +4. Don't use static variables except for read-only constant tables. Variables +that should be private to a module can be placed into private structures (see +the system architecture document, structure.doc). + +5. Source file names should begin with "j" for files that are part of the +library proper; source files that are not part of the library, such as cjpeg.c +and djpeg.c, do not begin with "j". Keep source file names to eight +characters (plus ".c" or ".h", etc) to make life easy for MS-DOSers. Keep +compression and decompression code in separate source files --- some +applications may want only one half of the library. + +Note: these rules (particularly #4) are not followed religiously in the +modules that are used in cjpeg/djpeg but are not part of the JPEG library +proper. Those modules are not really intended to be used in other +applications. diff --git a/gs/jpeg/config.log b/gs/jpeg/config.log new file mode 100644 index 000000000..5c53e215a --- /dev/null +++ b/gs/jpeg/config.log @@ -0,0 +1,20 @@ +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +gcc -E +gcc -o conftest -O conftest.c +gcc -c -O conftest.c +gcc -E +gcc -E +gcc -E +gcc -c -O conftest.c +gcc -c -O conftest.c +gcc -c -O conftest.c +gcc -c -O conftest.c +gcc -c -O conftest.c +gcc -c -O conftest.c +gcc -c -O conftest.c +gcc -o conftest -O conftest.c +gcc -o conftest -O conftest.c +gcc -o conftest -O conftest.c +gcc -o conftest -O conftest.c diff --git a/gs/jpeg/config.status b/gs/jpeg/config.status new file mode 100755 index 000000000..e3cbafc81 --- /dev/null +++ b/gs/jpeg/config.status @@ -0,0 +1,199 @@ +#! /bin/sh +# Generated automatically by configure. +# Run this file to recreate the current configuration. +# This directory was configured as follows, +# on host meerkat.dimensional.com: +# +# ./configure +# +# Compiler output produced by configure, useful for debugging +# configure, is in ./config.log if it exists. + +ac_cs_usage="Usage: ./config.status [--recheck] [--version] [--help]" +for ac_option +do + case "$ac_option" in + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + echo "running ${CONFIG_SHELL-/bin/sh} ./configure --no-create --no-recursion" + exec ${CONFIG_SHELL-/bin/sh} ./configure --no-create --no-recursion ;; + -version | --version | --versio | --versi | --vers | --ver | --ve | --v) + echo "./config.status generated by autoconf version 2.7" + exit 0 ;; + -help | --help | --hel | --he | --h) + echo "$ac_cs_usage"; exit 0 ;; + *) echo "$ac_cs_usage"; exit 1 ;; + esac +done + +ac_given_srcdir=. + +trap 'rm -fr Makefile jconfig.h conftest*; exit 1' 1 2 15 + +# Protect against being on the right side of a sed subst in config.status. +sed 's/%@/@@/; s/@%/@@/; s/%g$/@g/; /@g$/s/[\\&%]/\\&/g; + s/@@/%@/; s/@@/@%/; s/@g$/%g/' > conftest.subs <<\CEOF +/^[ ]*VPATH[ ]*=[^:]*$/d + +s%@CFLAGS@%-O%g +s%@CPPFLAGS@%%g +s%@CXXFLAGS@%%g +s%@DEFS@%-DHAVE_CONFIG_H%g +s%@LDFLAGS@%%g +s%@LIBS@%%g +s%@exec_prefix@%${prefix}%g +s%@prefix@%/usr/local%g +s%@program_transform_name@%s,x,x,%g +s%@bindir@%${exec_prefix}/bin%g +s%@sbindir@%${exec_prefix}/sbin%g +s%@libexecdir@%${exec_prefix}/libexec%g +s%@datadir@%${prefix}/share%g +s%@sysconfdir@%${prefix}/etc%g +s%@sharedstatedir@%${prefix}/com%g +s%@localstatedir@%${prefix}/var%g +s%@libdir@%${exec_prefix}/lib%g +s%@includedir@%${prefix}/include%g +s%@oldincludedir@%/usr/include%g +s%@infodir@%${prefix}/info%g +s%@mandir@%${prefix}/man%g +s%@CC@%gcc%g +s%@CPP@%gcc -E%g +s%@INSTALL@%/usr/bin/install -c%g +s%@INSTALL_PROGRAM@%${INSTALL}%g +s%@INSTALL_DATA@%${INSTALL} -m 644%g +s%@RANLIB@%ranlib%g +s%@MEMORYMGR@%jmemnobs.o%g +s%@ANSI2KNR@%%g +s%@ISANSICOM@%# %g +s%@ANSI2KNRFLAGS@%%g +s%@INCLUDEFLAGS@%-I$(srcdir)%g + +CEOF + +CONFIG_FILES=${CONFIG_FILES-"Makefile:makefile.cfg"} +for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then + # Support "outfile[:infile]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%.*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + # Adjust relative srcdir, etc. for subdirectories. + + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" + # A "../" for each directory in $ac_dir_suffix. + ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` + else + ac_dir_suffix= ac_dots= + fi + + case "$ac_given_srcdir" in + .) srcdir=. + if test -z "$ac_dots"; then top_srcdir=. + else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; + /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; + *) # Relative path. + srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" + top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + + echo creating "$ac_file" + rm -f "$ac_file" + configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." + case "$ac_file" in + *Makefile*) ac_comsub="1i\\ +# $configure_input" ;; + *) ac_comsub= ;; + esac + sed -e "$ac_comsub +s%@configure_input@%$configure_input%g +s%@srcdir@%$srcdir%g +s%@top_srcdir@%$top_srcdir%g +" -f conftest.subs $ac_given_srcdir/$ac_file_in > $ac_file +fi; done +rm -f conftest.subs + +# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where +# NAME is the cpp macro being defined and VALUE is the value it is being given. +# +# ac_d sets the value in "#define NAME VALUE" lines. +ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' +ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' +ac_dC='\3' +ac_dD='%g' +# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". +ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_uB='\([ ]\)%\1#\2define\3' +ac_uC=' ' +ac_uD='\4%g' +# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". +ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_eB='$%\1#\2define\3' +ac_eC=' ' +ac_eD='%g' + +CONFIG_HEADERS=${CONFIG_HEADERS-"jconfig.h:jconfig.cfg"} +for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then + # Support "outfile[:infile]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%.*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + echo creating $ac_file + + rm -f conftest.frag conftest.in conftest.out + cp $ac_given_srcdir/$ac_file_in conftest.in + + cat > conftest.frag < conftest.out + rm -f conftest.in + mv conftest.out conftest.in + + cat > conftest.frag < conftest.out + rm -f conftest.in + mv conftest.out conftest.in + + rm -f conftest.frag conftest.h + echo "/* $ac_file. Generated automatically by configure. */" > conftest.h + cat conftest.in >> conftest.h + rm -f conftest.in + if cmp -s $ac_file conftest.h 2>/dev/null; then + echo "$ac_file is unchanged" + rm -f conftest.h + else + rm -f $ac_file + mv conftest.h $ac_file + fi +fi; done + + + +exit 0 diff --git a/gs/jpeg/configure b/gs/jpeg/configure new file mode 100755 index 000000000..146c43a49 --- /dev/null +++ b/gs/jpeg/configure @@ -0,0 +1,1731 @@ +#! /bin/sh + +# Guess values for system-dependent variables and create Makefiles. +# Generated automatically using autoconf version 2.7 +# Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. + +# Defaults: +ac_help= +ac_default_prefix=/usr/local +# Any additions from configure.in: +ac_help="$ac_help + --enable-maxmem[=N] enable use of temp files, set max mem usage to N MB" +ac_help="$ac_help +" + +# Initialize some variables set by options. +# The variables have the same names as the options, with +# dashes changed to underlines. +build=NONE +cache_file=./config.cache +exec_prefix=NONE +host=NONE +no_create= +nonopt=NONE +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +target=NONE +verbose= +x_includes=NONE +x_libraries=NONE +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +# Initialize some other variables. +subdirs= +MFLAGS= MAKEFLAGS= + +ac_prev= +for ac_option +do + + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + case "$ac_option" in + -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) ac_optarg= ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case "$ac_option" in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir="$ac_optarg" ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build="$ac_optarg" ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file="$ac_optarg" ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir="$ac_optarg" ;; + + -disable-* | --disable-*) + ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + eval "enable_${ac_feature}=no" ;; + + -enable-* | --enable-*) + ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "enable_${ac_feature}='$ac_optarg'" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix="$ac_optarg" ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he) + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat << EOF +Usage: configure [options] [host] +Options: [defaults in brackets after descriptions] +Configuration: + --cache-file=FILE cache test results in FILE + --help print this message + --no-create do not create output files + --quiet, --silent do not print \`checking...' messages + --version print the version of autoconf that created configure +Directory and file names: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [same as prefix] + --bindir=DIR user executables in DIR [EPREFIX/bin] + --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] + --libexecdir=DIR program executables in DIR [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data in DIR + [PREFIX/share] + --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data in DIR + [PREFIX/com] + --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] + --libdir=DIR object code libraries in DIR [EPREFIX/lib] + --includedir=DIR C header files in DIR [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] + --infodir=DIR info documentation in DIR [PREFIX/info] + --mandir=DIR man documentation in DIR [PREFIX/man] + --srcdir=DIR find the sources in DIR [configure dir or ..] + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM + run sed PROGRAM on installed program names +EOF + cat << EOF +Host type: + --build=BUILD configure for building on BUILD [BUILD=HOST] + --host=HOST configure for HOST [guessed] + --target=TARGET configure for TARGET [TARGET=HOST] +Features and packages: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --x-includes=DIR X include files are in DIR + --x-libraries=DIR X library files are in DIR +EOF + if test -n "$ac_help"; then + echo "--enable and --with options recognized:$ac_help" + fi + exit 0 ;; + + -host | --host | --hos | --ho) + ac_prev=host ;; + -host=* | --host=* | --hos=* | --ho=*) + host="$ac_optarg" ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir="$ac_optarg" ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir="$ac_optarg" ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir="$ac_optarg" ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir="$ac_optarg" ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + localstatedir="$ac_optarg" ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir="$ac_optarg" ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir="$ac_optarg" ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix="$ac_optarg" ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix="$ac_optarg" ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix="$ac_optarg" ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name="$ac_optarg" ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir="$ac_optarg" ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir="$ac_optarg" ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site="$ac_optarg" ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir="$ac_optarg" ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir="$ac_optarg" ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target="$ac_optarg" ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers) + echo "configure generated by autoconf version 2.7" + exit 0 ;; + + -with-* | --with-*) + ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "with_${ac_package}='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`echo $ac_option|sed -e 's/-*without-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + eval "with_${ac_package}=no" ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes="$ac_optarg" ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries="$ac_optarg" ;; + + -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } + ;; + + *=*) + varname=`echo "$ac_option"|sed -e 's/=.*//'` + # Reject names that aren't valid shell variable names. + if test -n "`echo $varname| sed 's/[a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $varname: invalid shell variable name" 1>&2; exit 1; } + fi + val="`echo "$ac_option"|sed 's/[^=]*=//'`" + test -n "$verbose" && echo " setting shell variable $varname to $val" + eval "$varname='$val'" + eval "export $varname" ;; + + *) + if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then + echo "configure: warning: $ac_option: invalid host type" 1>&2 + fi + if test "x$nonopt" != xNONE; then + { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } + fi + nonopt="$ac_option" + ;; + + esac +done + +if test -n "$ac_prev"; then + { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } +fi + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +# File descriptor usage: +# 0 standard input +# 1 file creation +# 2 errors and warnings +# 3 some systems may open it to /dev/tty +# 4 used on the Kubota Titan +# 6 checking for... messages and results +# 5 compiler messages saved in config.log +if test "$silent" = yes; then + exec 6>/dev/null +else + exec 6>&1 +fi +exec 5>./config.log + +echo "\ +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. +" 1>&5 + +# Strip out --no-create and --no-recursion so they do not pile up. +# Also quote any args containing shell metacharacters. +ac_configure_args= +for ac_arg +do + case "$ac_arg" in + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) ;; + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) + ac_configure_args="$ac_configure_args '$ac_arg'" ;; + *) ac_configure_args="$ac_configure_args $ac_arg" ;; + esac +done + +# NLS nuisances. +# Only set LANG and LC_ALL to C if already set. +# These must not be set unconditionally because not all systems understand +# e.g. LANG=C (notably SCO). +if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi +if test "${LANG+set}" = set; then LANG=C; export LANG; fi + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo > confdefs.h + +# A filename unique to this package, relative to the directory that +# configure is in, which we can look for to find out if srcdir is correct. +ac_unique_file=jcmaster.c + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then its parent. + ac_prog=$0 + ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` + test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. + srcdir=$ac_confdir + if test ! -r $srcdir/$ac_unique_file; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r $srcdir/$ac_unique_file; then + if test "$ac_srcdir_defaulted" = yes; then + { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } + else + { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } + fi +fi +srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` + +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + echo "loading site script $ac_site_file" + . "$ac_site_file" + fi +done + + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='echo $CPP $CPPFLAGS 1>&5; +$CPP $CPPFLAGS' +ac_compile='echo ${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5; +${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5 2>&5' +ac_link='echo ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5; +${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5 2>&5' + +if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then + # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. + if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then + ac_n= ac_c=' +' ac_t=' ' + else + ac_n=-n ac_c= ac_t= + fi +else + ac_n= ac_c='\c' ac_t= +fi + + + +# Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="gcc" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_CC" && ac_cv_prog_CC="cc" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + +echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.c <&5 | egrep yes >/dev/null 2>&1; then + ac_cv_prog_gcc=yes +else + ac_cv_prog_gcc=no +fi +fi +echo "$ac_t""$ac_cv_prog_gcc" 1>&6 +if test $ac_cv_prog_gcc = yes; then + GCC=yes +else + GCC= +fi +if test "${CFLAGS+set}" != set; then + echo $ac_n "checking whether ${CC-cc} accepts -O""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_prog_cc_o'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + echo 'int f(){ return 0; }' > conftest.c +if test -z "`${CC-cc} -O -c conftest.c 2>&1`"; then + ac_cv_prog_cc_o=yes +else + ac_cv_prog_cc_o=no +fi +rm -f conftest* + +fi + echo "$ac_t""$ac_cv_prog_cc_o" 1>&6 + if test $ac_cv_prog_cc_o = yes; then + CFLAGS="-O" + else + CFLAGS="" + fi +fi + +echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then +if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # This must be in double quotes, not single quotes, because CPP may get + # substituted into the Makefile and "${CC-cc}" will confuse make. + CPP="${CC-cc} -E" + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. + cat > conftest.$ac_ext < +Syntax Error +EOF +eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + rm -rf conftest* + CPP="${CC-cc} -E -traditional-cpp" + cat > conftest.$ac_ext < +Syntax Error +EOF +eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + rm -rf conftest* + CPP=/lib/cpp +fi +rm -f conftest* +fi +rm -f conftest* + ac_cv_prog_CPP="$CPP" +fi + CPP="$ac_cv_prog_CPP" +else + ac_cv_prog_CPP="$CPP" +fi +echo "$ac_t""$CPP" 1>&6 + +# If we cannot run a trivial program, we must be cross compiling. +echo $ac_n "checking whether cross-compiling""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_c_cross'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + ac_cv_c_cross=yes +else +cat > conftest.$ac_ext </dev/null; then + ac_cv_c_cross=no +else + ac_cv_c_cross=yes +fi +fi +rm -fr conftest* +fi + +echo "$ac_t""$ac_cv_c_cross" 1>&6 +cross_compiling=$ac_cv_c_cross + +echo $ac_n "checking for function prototypes""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ijg_cv_have_prototypes'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <&6 +if test $ijg_cv_have_prototypes = yes; then + cat >> confdefs.h <<\EOF +#define HAVE_PROTOTYPES +EOF + +else + echo Your compiler does not seem to know about function prototypes. + echo Perhaps it needs a special switch to enable ANSI C mode. + echo If so, we recommend running configure like this: + echo " ./configure CC='cc -switch'" + echo where -switch is the proper switch. +fi +ac_safe=`echo "stddef.h" | tr './\055' '___'` +echo $ac_n "checking for stddef.h""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<\EOF +#define HAVE_STDDEF_H +EOF + +else + echo "$ac_t""no" 1>&6 +fi + +ac_safe=`echo "stdlib.h" | tr './\055' '___'` +echo $ac_n "checking for stdlib.h""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<\EOF +#define HAVE_STDLIB_H +EOF + +else + echo "$ac_t""no" 1>&6 +fi + +ac_safe=`echo "string.h" | tr './\055' '___'` +echo $ac_n "checking for string.h""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + : +else + echo "$ac_t""no" 1>&6 +cat >> confdefs.h <<\EOF +#define NEED_BSD_STRINGS +EOF + +fi + +echo $ac_n "checking for size_t""... $ac_c" 1>&6 +cat > conftest.$ac_ext < +#endif +#ifdef HAVE_STDLIB_H +#include +#endif +#include +#ifdef NEED_BSD_STRINGS +#include +#else +#include +#endif +typedef size_t my_size_t; + +int main() { return 0; } +int t() { + my_size_t foovar; +; return 0; } +EOF +if eval $ac_compile; then + rm -rf conftest* + ijg_size_t_ok=yes +else + rm -rf conftest* + ijg_size_t_ok="not ANSI, perhaps it is in sys/types.h" +fi +rm -f conftest* + +echo "$ac_t""$ijg_size_t_ok" 1>&6 +if test "$ijg_size_t_ok" != yes; then +ac_safe=`echo "sys/types.h" | tr './\055' '___'` +echo $ac_n "checking for sys/types.h""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<\EOF +#define NEED_SYS_TYPES_H +EOF + +cat > conftest.$ac_ext < +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "size_t" >/dev/null 2>&1; then + rm -rf conftest* + ijg_size_t_ok="size_t is in sys/types.h" +else + rm -rf conftest* + ijg_size_t_ok=no +fi +rm -f conftest* + +else + echo "$ac_t""no" 1>&6 +ijg_size_t_ok=no +fi + +echo "$ac_t""$ijg_size_t_ok" 1>&6 +if test "$ijg_size_t_ok" = no; then + echo Type size_t is not defined in any of the usual places. + echo Try putting '"typedef unsigned int size_t;"' in jconfig.h. +fi +fi +echo $ac_n "checking for type unsigned char""... $ac_c" 1>&6 +cat > conftest.$ac_ext <&6 +cat >> confdefs.h <<\EOF +#define HAVE_UNSIGNED_CHAR +EOF + +else + rm -rf conftest* + echo "$ac_t""no" 1>&6 +fi +rm -f conftest* +echo $ac_n "checking for type unsigned short""... $ac_c" 1>&6 +cat > conftest.$ac_ext <&6 +cat >> confdefs.h <<\EOF +#define HAVE_UNSIGNED_SHORT +EOF + +else + rm -rf conftest* + echo "$ac_t""no" 1>&6 +fi +rm -f conftest* +echo $ac_n "checking for type void""... $ac_c" 1>&6 +cat > conftest.$ac_ext <&6 +else + rm -rf conftest* + echo "$ac_t""no" 1>&6 +cat >> confdefs.h <<\EOF +#define void char +EOF + +fi +rm -f conftest* +echo $ac_n "checking for working const""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <j = 5; +} +{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; +} + +; return 0; } +EOF +if eval $ac_compile; then + rm -rf conftest* + ac_cv_c_const=yes +else + rm -rf conftest* + ac_cv_c_const=no +fi +rm -f conftest* + +fi + +echo "$ac_t""$ac_cv_c_const" 1>&6 +if test $ac_cv_c_const = no; then + cat >> confdefs.h <<\EOF +#define const +EOF + +fi + +echo $ac_n "checking for inline""... $ac_c" 1>&6 +ijg_cv_inline="" +cat > conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext <&6 +cat >> confdefs.h <&6 +cat > conftest.$ac_ext <&6 +else + rm -rf conftest* + echo "$ac_t""broken" 1>&6 +cat >> confdefs.h <<\EOF +#define INCOMPLETE_TYPES_BROKEN +EOF + +fi +rm -f conftest* +echo $ac_n "checking for short external names""... $ac_c" 1>&6 +cat > conftest.$ac_ext <&6 +else + rm -rf conftest* + echo "$ac_t""short" 1>&6 +cat >> confdefs.h <<\EOF +#define NEED_SHORT_EXTERNAL_NAMES +EOF + +fi +rm -f conftest* + +echo $ac_n "checking to see if char is signed""... $ac_c" 1>&6 +if test "$cross_compiling" = yes; then + echo Assuming that char is signed on target machine. +echo If it is unsigned, this will be a little bit inefficient. + +else +cat > conftest.$ac_ext </dev/null; then + echo "$ac_t""no" 1>&6 +cat >> confdefs.h <<\EOF +#define CHAR_IS_UNSIGNED +EOF + +else + echo "$ac_t""yes" 1>&6 +fi +fi +rm -fr conftest* +echo $ac_n "checking to see if right shift is signed""... $ac_c" 1>&6 +if test "$cross_compiling" = yes; then + echo "$ac_t""Assuming that right shift is signed on target machine." 1>&6 +else +cat > conftest.$ac_ext <> 4; + + if (res == -0x7F7E80CL) { /* expected result for signed shift */ + return 1; /* right shift is signed */ + } + /* see if unsigned-shift hack will fix it. */ + /* we can't just test exact value since it depends on width of long... */ + res |= (~0L) << (32-4); + if (res == -0x7F7E80CL) { /* expected result now? */ + return 0; /* right shift is unsigned */ + } + printf("Right shift isn't acting as I expect it to.\n"); + printf("I fear the JPEG software will not work at all.\n\n"); + return 0; /* try it with unsigned anyway */ +} +main() { + exit(is_shifting_signed(-0x7F7E80B1L)); +} +EOF +eval $ac_link +if test -s conftest && (./conftest; exit) 2>/dev/null; then + echo "$ac_t""no" 1>&6 +cat >> confdefs.h <<\EOF +#define RIGHT_SHIFT_IS_UNSIGNED +EOF + +else + echo "$ac_t""yes" 1>&6 +fi +fi +rm -fr conftest* +echo $ac_n "checking to see if fopen accepts b spec""... $ac_c" 1>&6 +if test "$cross_compiling" = yes; then + echo "$ac_t""Assuming that it does." 1>&6 +else +cat > conftest.$ac_ext < +main() { + if (fopen("conftestdata", "wb") != NULL) + exit(0); + exit(1); +} +EOF +eval $ac_link +if test -s conftest && (./conftest; exit) 2>/dev/null; then + echo "$ac_t""yes" 1>&6 +else + echo "$ac_t""no" 1>&6 +cat >> confdefs.h <<\EOF +#define DONT_USE_B_MODE +EOF + +fi +fi +rm -fr conftest* + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# ./install, which can be erroneously created by make from ./install.sh. +echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 +if test -z "$INSTALL"; then +if eval "test \"`echo '$''{'ijg_cv_path_install'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do + # Account for people who put trailing slashes in PATH elements. + case "$ac_dir/" in + /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + for ac_prog in ginstall installbsd scoinst install; do + if test -f $ac_dir/$ac_prog; then + if test $ac_prog = install && + grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + # OSF/1 installbsd also uses dspmsg, but is usable. + : + else + ijg_cv_path_install="$ac_dir/$ac_prog -c" + break 2 + fi + fi + done + ;; + esac + done + IFS="$ac_save_ifs" + # As a last resort, use cp + test -z "$ijg_cv_path_install" && ijg_cv_path_install="cp" +fi + INSTALL="$ijg_cv_path_install" +fi +echo "$ac_t""$INSTALL" 1>&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +if test -z "$INSTALL_DATA"; then + if test "$INSTALL" = cp; then + INSTALL_DATA='${INSTALL}' + else + INSTALL_DATA='${INSTALL} -m 644' + fi +fi + +# Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_RANLIB="ranlib" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":" +fi +fi +RANLIB="$ac_cv_prog_RANLIB" +if test -n "$RANLIB"; then + echo "$ac_t""$RANLIB" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +MEMORYMGR="jmemnobs.o" +MAXMEM="no" +# Check whether --enable-maxmem or --disable-maxmem was given. +if test "${enable_maxmem+set}" = set; then + enableval="$enable_maxmem" + MAXMEM="$enableval" +fi + +# support --with-maxmem for backwards compatibility with IJG V5. +# Check whether --with-maxmem or --without-maxmem was given. +if test "${with_maxmem+set}" = set; then + withval="$with_maxmem" + MAXMEM="$withval" +fi + +if test "x$MAXMEM" = xyes; then + MAXMEM=1 +fi +if test "x$MAXMEM" != xno; then + if test -n "`echo $MAXMEM | sed 's/[0-9]//g'`"; then + { echo "configure: error: non-numeric argument to --enable-maxmem" 1>&2; exit 1; } + fi + DEFAULTMAXMEM=`expr $MAXMEM \* 1048576` +cat >> confdefs.h <&6 +cat > conftest.$ac_ext < +int main() { return 0; } +int t() { + FILE * tfile = tmpfile(); +; return 0; } +EOF +if eval $ac_link; then + rm -rf conftest* + echo "$ac_t""yes" 1>&6 +MEMORYMGR="jmemansi.o" +else + rm -rf conftest* + echo "$ac_t""no" 1>&6 +MEMORYMGR="jmemname.o" +cat >> confdefs.h <<\EOF +#define NEED_SIGNAL_CATCHER +EOF +echo $ac_n "checking for 'mktemp()'""... $ac_c" 1>&6 +cat > conftest.$ac_ext <&6 +else + rm -rf conftest* + echo "$ac_t""no" 1>&6 +cat >> confdefs.h <<\EOF +#define NO_MKTEMP +EOF + +fi +rm -f conftest* + +fi +rm -f conftest* + +fi + +# Prepare to massage makefile.cfg correctly. +if test $ijg_cv_have_prototypes = yes; then + ANSI2KNR="" + ISANSICOM="# " +else + ANSI2KNR="ansi2knr" + ISANSICOM="" +fi +# ansi2knr needs -DBSD if string.h is missing +if test $ac_cv_header_string_h = no; then + ANSI2KNRFLAGS="-DBSD" +else + ANSI2KNRFLAGS="" +fi +# Set up -I directives +if test "x$srcdir" = x.; then + INCLUDEFLAGS='-I$(srcdir)' +else + INCLUDEFLAGS='-I. -I$(srcdir)' +fi +trap '' 1 2 15 + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# Any assignment to VPATH causes Sun make to only execute +# the first set of double-colon rules, so remove it if not needed. +# If there is a colon in the path, we need to keep it. +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' +fi + +trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 + +DEFS=-DHAVE_CONFIG_H + +# Without the "./", some shells look in PATH for config.status. +: ${CONFIG_STATUS=./config.status} + +echo creating $CONFIG_STATUS +rm -f $CONFIG_STATUS +cat > $CONFIG_STATUS </dev/null | sed 1q`: +# +# $0 $ac_configure_args +# +# Compiler output produced by configure, useful for debugging +# configure, is in ./config.log if it exists. + +ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" +for ac_option +do + case "\$ac_option" in + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" + exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; + -version | --version | --versio | --versi | --vers | --ver | --ve | --v) + echo "$CONFIG_STATUS generated by autoconf version 2.7" + exit 0 ;; + -help | --help | --hel | --he | --h) + echo "\$ac_cs_usage"; exit 0 ;; + *) echo "\$ac_cs_usage"; exit 1 ;; + esac +done + +ac_given_srcdir=$srcdir + +trap 'rm -fr `echo "Makefile:makefile.cfg jconfig.h:jconfig.cfg" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +EOF +cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF +$ac_vpsub +$extrasub +s%@CFLAGS@%$CFLAGS%g +s%@CPPFLAGS@%$CPPFLAGS%g +s%@CXXFLAGS@%$CXXFLAGS%g +s%@DEFS@%$DEFS%g +s%@LDFLAGS@%$LDFLAGS%g +s%@LIBS@%$LIBS%g +s%@exec_prefix@%$exec_prefix%g +s%@prefix@%$prefix%g +s%@program_transform_name@%$program_transform_name%g +s%@bindir@%$bindir%g +s%@sbindir@%$sbindir%g +s%@libexecdir@%$libexecdir%g +s%@datadir@%$datadir%g +s%@sysconfdir@%$sysconfdir%g +s%@sharedstatedir@%$sharedstatedir%g +s%@localstatedir@%$localstatedir%g +s%@libdir@%$libdir%g +s%@includedir@%$includedir%g +s%@oldincludedir@%$oldincludedir%g +s%@infodir@%$infodir%g +s%@mandir@%$mandir%g +s%@CC@%$CC%g +s%@CPP@%$CPP%g +s%@INSTALL@%$INSTALL%g +s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g +s%@INSTALL_DATA@%$INSTALL_DATA%g +s%@RANLIB@%$RANLIB%g +s%@MEMORYMGR@%$MEMORYMGR%g +s%@ANSI2KNR@%$ANSI2KNR%g +s%@ISANSICOM@%$ISANSICOM%g +s%@ANSI2KNRFLAGS@%$ANSI2KNRFLAGS%g +s%@INCLUDEFLAGS@%$INCLUDEFLAGS%g + +CEOF +EOF +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF +for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then + # Support "outfile[:infile]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%.*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + # Adjust relative srcdir, etc. for subdirectories. + + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" + # A "../" for each directory in $ac_dir_suffix. + ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` + else + ac_dir_suffix= ac_dots= + fi + + case "$ac_given_srcdir" in + .) srcdir=. + if test -z "$ac_dots"; then top_srcdir=. + else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; + /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; + *) # Relative path. + srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" + top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + + echo creating "$ac_file" + rm -f "$ac_file" + configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." + case "$ac_file" in + *Makefile*) ac_comsub="1i\\ +# $configure_input" ;; + *) ac_comsub= ;; + esac + sed -e "$ac_comsub +s%@configure_input@%$configure_input%g +s%@srcdir@%$srcdir%g +s%@top_srcdir@%$top_srcdir%g +" -f conftest.subs $ac_given_srcdir/$ac_file_in > $ac_file +fi; done +rm -f conftest.subs + +# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where +# NAME is the cpp macro being defined and VALUE is the value it is being given. +# +# ac_d sets the value in "#define NAME VALUE" lines. +ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' +ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' +ac_dC='\3' +ac_dD='%g' +# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". +ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_uB='\([ ]\)%\1#\2define\3' +ac_uC=' ' +ac_uD='\4%g' +# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". +ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_eB='$%\1#\2define\3' +ac_eC=' ' +ac_eD='%g' + +CONFIG_HEADERS=${CONFIG_HEADERS-"jconfig.h:jconfig.cfg"} +for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then + # Support "outfile[:infile]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%.*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + echo creating $ac_file + + rm -f conftest.frag conftest.in conftest.out + cp $ac_given_srcdir/$ac_file_in conftest.in + +EOF + +# Transform confdefs.h into a sed script conftest.vals that substitutes +# the proper values into config.h.in to produce config.h. And first: +# Protect against being on the right side of a sed subst in config.status. +# Protect against being in an unquoted here document in config.status. +rm -f conftest.vals +cat > conftest.hdr <<\EOF +s/[\\&%]/\\&/g +s%[\\$`]%\\&%g +s%#define \([A-Za-z_][A-Za-z0-9_]*\) \(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp +s%ac_d%ac_u%gp +s%ac_u%ac_e%gp +EOF +sed -n -f conftest.hdr confdefs.h > conftest.vals +rm -f conftest.hdr + +# This sed command replaces #undef with comments. This is necessary, for +# example, in the case of _POSIX_SOURCE, which is predefined and required +# on some systems where configure will not decide to define it. +cat >> conftest.vals <<\EOF +EOF + +# Break up conftest.vals because some shells have a limit on +# the size of here documents, and old seds have small limits too. +# Maximum number of lines to put in a single here document. +ac_max_here_lines=12 + +rm -f conftest.tail +while : +do + ac_lines=`grep -c . conftest.vals` + # grep -c gives empty output for an empty file on some AIX systems. + if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi + # Write a limited-size here document to conftest.frag. + echo ' cat > conftest.frag <> $CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS + echo 'CEOF + sed -f conftest.frag conftest.in > conftest.out + rm -f conftest.in + mv conftest.out conftest.in +' >> $CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail + rm -f conftest.vals + mv conftest.tail conftest.vals +done +rm -f conftest.vals + +cat >> $CONFIG_STATUS <<\EOF + rm -f conftest.frag conftest.h + echo "/* $ac_file. Generated automatically by configure. */" > conftest.h + cat conftest.in >> conftest.h + rm -f conftest.in + if cmp -s $ac_file conftest.h 2>/dev/null; then + echo "$ac_file is unchanged" + rm -f conftest.h + else + rm -f $ac_file + mv conftest.h $ac_file + fi +fi; done + + + +exit 0 +EOF +chmod +x $CONFIG_STATUS +rm -fr confdefs* $ac_clean_files +test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 + diff --git a/gs/jpeg/djpeg b/gs/jpeg/djpeg new file mode 100755 index 000000000..9eb99bbb3 Binary files /dev/null and b/gs/jpeg/djpeg differ diff --git a/gs/jpeg/djpeg.1 b/gs/jpeg/djpeg.1 new file mode 100644 index 000000000..8efa5cd86 --- /dev/null +++ b/gs/jpeg/djpeg.1 @@ -0,0 +1,248 @@ +.TH DJPEG 1 "15 June 1995" +.SH NAME +djpeg \- decompress a JPEG file to an image file +.SH SYNOPSIS +.B djpeg +[ +.I options +] +[ +.I filename +] +.LP +.SH DESCRIPTION +.LP +.B djpeg +decompresses the named JPEG file, or the standard input if no file is named, +and produces an image file on the standard output. PBMPLUS (PPM/PGM), BMP, +GIF, Targa, or RLE (Utah Raster Toolkit) output format can be selected. +(RLE is supported only if the URT library is available.) +.SH OPTIONS +All switch names may be abbreviated; for example, +.B \-grayscale +may be written +.B \-gray +or +.BR \-gr . +Most of the "basic" switches can be abbreviated to as little as one letter. +Upper and lower case are equivalent (thus +.B \-GIF +is the same as +.BR \-gif ). +British spellings are also accepted (e.g., +.BR \-greyscale ), +though for brevity these are not mentioned below. +.PP +The basic switches are: +.TP +.BI \-colors " N" +Reduce image to at most N colors. This reduces the number of colors used in +the output image, so that it can be displayed on a colormapped display or +stored in a colormapped file format. For example, if you have an 8-bit +display, you'd need to reduce to 256 or fewer colors. +.TP +.BI \-quantize " N" +Same as +.BR \-colors . +.B \-colors +is the recommended name, +.B \-quantize +is provided only for backwards compatibility. +.TP +.B \-fast +Select recommended processing options for fast, low quality output. (The +default options are chosen for highest quality output.) Currently, this is +equivalent to \fB\-dct fast \-nosmooth \-onepass \-dither ordered\fR. +.TP +.B \-grayscale +Force gray-scale output even if JPEG file is color. Useful for viewing on +monochrome displays; also, +.B djpeg +runs noticeably faster in this mode. +.TP +.BI \-scale " M/N" +Scale the output image by a factor M/N. Currently the scale factor must be +1/1, 1/2, 1/4, or 1/8. Scaling is handy if the image is larger than your +screen; also, +.B djpeg +runs much faster when scaling down the output. +.TP +.B \-bmp +Select BMP output format (Windows flavor). 8-bit colormapped format is +emitted if +.B \-colors +or +.B \-grayscale +is specified, or if the JPEG file is gray-scale; otherwise, 24-bit full-color +format is emitted. +.TP +.B \-gif +Select GIF output format. Since GIF does not support more than 256 colors, +.B \-colors 256 +is assumed (unless you specify a smaller number of colors). +.TP +.B \-os2 +Select BMP output format (OS/2 1.x flavor). 8-bit colormapped format is +emitted if +.B \-colors +or +.B \-grayscale +is specified, or if the JPEG file is gray-scale; otherwise, 24-bit full-color +format is emitted. +.TP +.B \-pnm +Select PBMPLUS (PPM/PGM) output format (this is the default format). +PGM is emitted if the JPEG file is gray-scale or if +.B \-grayscale +is specified; otherwise PPM is emitted. +.TP +.B \-rle +Select RLE output format. (Requires URT library.) +.TP +.B \-targa +Select Targa output format. Gray-scale format is emitted if the JPEG file is +gray-scale or if +.B \-grayscale +is specified; otherwise, colormapped format is emitted if +.B \-colors +is specified; otherwise, 24-bit full-color format is emitted. +.PP +Switches for advanced users: +.TP +.B \-dct int +Use integer DCT method (default). +.TP +.B \-dct fast +Use fast integer DCT (less accurate). +.TP +.B \-dct float +Use floating-point DCT method. +The float method is very slightly more accurate than the int method, but is +much slower unless your machine has very fast floating-point hardware. Also +note that results of the floating-point method may vary slightly across +machines, while the integer methods should give the same results everywhere. +The fast integer method is much less accurate than the other two. +.TP +.B \-dither fs +Use Floyd-Steinberg dithering in color quantization. +.TP +.B \-dither ordered +Use ordered dithering in color quantization. +.TP +.B \-dither none +Do not use dithering in color quantization. +By default, Floyd-Steinberg dithering is applied when quantizing colors; this +is slow but usually produces the best results. Ordered dither is a compromise +between speed and quality; no dithering is fast but usually looks awful. Note +that these switches have no effect unless color quantization is being done. +Ordered dither is only available in +.B \-onepass +mode. +.TP +.BI \-map " file" +Quantize to the colors used in the specified image file. This is useful for +producing multiple files with identical color maps, or for forcing a +predefined set of colors to be used. The +.I file +must be a GIF or PPM file. This option overrides +.B \-colors +and +.BR \-onepass . +.TP +.B \-nosmooth +Use a faster, lower-quality upsampling routine. +.TP +.B \-onepass +Use one-pass instead of two-pass color quantization. The one-pass method is +faster and needs less memory, but it produces a lower-quality image. +.B \-onepass +is ignored unless you also say +.B \-colors +.IR N . +Also, the one-pass method is always used for gray-scale output (the two-pass +method is no improvement then). +.TP +.BI \-maxmemory " N" +Set limit for amount of memory to use in processing large images. Value is +in thousands of bytes, or millions of bytes if "M" is attached to the +number. For example, +.B \-max 4m +selects 4000000 bytes. If more space is needed, temporary files will be used. +.TP +.BI \-outfile " name" +Send output image to the named file, not to standard output. +.TP +.B \-verbose +Enable debug printout. More +.BR \-v 's +give more output. Also, version information is printed at startup. +.TP +.B \-debug +Same as +.BR \-verbose . +.SH EXAMPLES +.LP +This example decompresses the JPEG file foo.jpg, automatically quantizes to +256 colors, and saves the output in GIF format in foo.gif: +.IP +.B djpeg \-gif +.I foo.jpg +.B > +.I foo.gif +.SH HINTS +To get a quick preview of an image, use the +.B \-grayscale +and/or +.B \-scale +switches. +.B \-grayscale \-scale 1/8 +is the fastest case. +.PP +Several options are available that trade off image quality to gain speed. +.B \-fast +turns on the recommended settings. +.PP +.B \-dct fast +and/or +.B \-nosmooth +gain speed at a small sacrifice in quality. +When producing a color-quantized image, +.B \-onepass \-dither ordered +is fast but much lower quality than the default behavior. +.B \-dither none +may give acceptable results in two-pass mode, but is seldom tolerable in +one-pass mode. +.PP +If you are fortunate enough to have very fast floating point hardware, +\fB\-dct float\fR may be even faster than \fB\-dct fast\fR. But on most +machines \fB\-dct float\fR is slower than \fB\-dct int\fR; in this case it is +not worth using, because its theoretical accuracy advantage is too small to be +significant in practice. +.SH ENVIRONMENT +.TP +.B JPEGMEM +If this environment variable is set, its value is the default memory limit. +The value is specified as described for the +.B \-maxmemory +switch. +.B JPEGMEM +overrides the default value specified when the program was compiled, and +itself is overridden by an explicit +.BR \-maxmemory . +.SH SEE ALSO +.BR cjpeg (1), +.BR jpegtran (1), +.BR rdjpgcom (1), +.BR wrjpgcom (1) +.br +.BR ppm (5), +.BR pgm (5) +.br +Wallace, Gregory K. "The JPEG Still Picture Compression Standard", +Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44. +.SH AUTHOR +Independent JPEG Group +.SH BUGS +Arithmetic coding is not supported for legal reasons. +.PP +Still not as fast as we'd like. diff --git a/gs/jpeg/djpeg.c b/gs/jpeg/djpeg.c new file mode 100644 index 000000000..546599404 --- /dev/null +++ b/gs/jpeg/djpeg.c @@ -0,0 +1,604 @@ +/* + * djpeg.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a command-line user interface for the JPEG decompressor. + * It should work on any system with Unix- or MS-DOS-style command lines. + * + * Two different command line styles are permitted, depending on the + * compile-time switch TWO_FILE_COMMANDLINE: + * djpeg [options] inputfile outputfile + * djpeg [options] [inputfile] + * In the second style, output is always to standard output, which you'd + * normally redirect to a file or pipe to some other program. Input is + * either from a named file or from standard input (typically redirected). + * The second style is convenient on Unix but is unhelpful on systems that + * don't support pipes. Also, you MUST use the first style if your system + * doesn't do binary I/O to stdin/stdout. + * To simplify script writing, the "-outfile" switch is provided. The syntax + * djpeg [options] -outfile outputfile inputfile + * works regardless of which command line style is used. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ +#include "jversion.h" /* for version message */ + +#include /* to declare isprint() */ + +#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ +#ifdef __MWERKS__ +#include /* Metrowerks needs this */ +#include /* ... and this */ +#endif +#ifdef THINK_C +#include /* Think declares it here */ +#endif +#endif + + +/* Create the add-on message string table. */ + +#define JMESSAGE(code,string) string , + +static const char * const cdjpeg_message_table[] = { +#include "cderror.h" + NULL +}; + + +/* + * This list defines the known output image formats + * (not all of which need be supported by a given version). + * You can change the default output format by defining DEFAULT_FMT; + * indeed, you had better do so if you undefine PPM_SUPPORTED. + */ + +typedef enum { + FMT_BMP, /* BMP format (Windows flavor) */ + FMT_GIF, /* GIF format */ + FMT_OS2, /* BMP format (OS/2 flavor) */ + FMT_PPM, /* PPM/PGM (PBMPLUS formats) */ + FMT_RLE, /* RLE format */ + FMT_TARGA, /* Targa format */ + FMT_TIFF /* TIFF format */ +} IMAGE_FORMATS; + +#ifndef DEFAULT_FMT /* so can override from CFLAGS in Makefile */ +#define DEFAULT_FMT FMT_PPM +#endif + +static IMAGE_FORMATS requested_fmt; + + +/* + * Argument-parsing code. + * The switch parser is designed to be useful with DOS-style command line + * syntax, ie, intermixed switches and file names, where only the switches + * to the left of a given file name affect processing of that file. + * The main program in this file doesn't actually use this capability... + */ + + +static const char * progname; /* program name for error messages */ +static char * outfilename; /* for -outfile switch */ + + +LOCAL(void) +usage (void) +/* complain about bad command line */ +{ + fprintf(stderr, "usage: %s [switches] ", progname); +#ifdef TWO_FILE_COMMANDLINE + fprintf(stderr, "inputfile outputfile\n"); +#else + fprintf(stderr, "[inputfile]\n"); +#endif + + fprintf(stderr, "Switches (names may be abbreviated):\n"); + fprintf(stderr, " -colors N Reduce image to no more than N colors\n"); + fprintf(stderr, " -fast Fast, low-quality processing\n"); + fprintf(stderr, " -grayscale Force grayscale output\n"); +#ifdef IDCT_SCALING_SUPPORTED + fprintf(stderr, " -scale M/N Scale output image by fraction M/N, eg, 1/8\n"); +#endif +#ifdef BMP_SUPPORTED + fprintf(stderr, " -bmp Select BMP output format (Windows style)%s\n", + (DEFAULT_FMT == FMT_BMP ? " (default)" : "")); +#endif +#ifdef GIF_SUPPORTED + fprintf(stderr, " -gif Select GIF output format%s\n", + (DEFAULT_FMT == FMT_GIF ? " (default)" : "")); +#endif +#ifdef BMP_SUPPORTED + fprintf(stderr, " -os2 Select BMP output format (OS/2 style)%s\n", + (DEFAULT_FMT == FMT_OS2 ? " (default)" : "")); +#endif +#ifdef PPM_SUPPORTED + fprintf(stderr, " -pnm Select PBMPLUS (PPM/PGM) output format%s\n", + (DEFAULT_FMT == FMT_PPM ? " (default)" : "")); +#endif +#ifdef RLE_SUPPORTED + fprintf(stderr, " -rle Select Utah RLE output format%s\n", + (DEFAULT_FMT == FMT_RLE ? " (default)" : "")); +#endif +#ifdef TARGA_SUPPORTED + fprintf(stderr, " -targa Select Targa output format%s\n", + (DEFAULT_FMT == FMT_TARGA ? " (default)" : "")); +#endif + fprintf(stderr, "Switches for advanced users:\n"); +#ifdef DCT_ISLOW_SUPPORTED + fprintf(stderr, " -dct int Use integer DCT method%s\n", + (JDCT_DEFAULT == JDCT_ISLOW ? " (default)" : "")); +#endif +#ifdef DCT_IFAST_SUPPORTED + fprintf(stderr, " -dct fast Use fast integer DCT (less accurate)%s\n", + (JDCT_DEFAULT == JDCT_IFAST ? " (default)" : "")); +#endif +#ifdef DCT_FLOAT_SUPPORTED + fprintf(stderr, " -dct float Use floating-point DCT method%s\n", + (JDCT_DEFAULT == JDCT_FLOAT ? " (default)" : "")); +#endif + fprintf(stderr, " -dither fs Use F-S dithering (default)\n"); + fprintf(stderr, " -dither none Don't use dithering in quantization\n"); + fprintf(stderr, " -dither ordered Use ordered dither (medium speed, quality)\n"); +#ifdef QUANT_2PASS_SUPPORTED + fprintf(stderr, " -map FILE Map to colors used in named image file\n"); +#endif + fprintf(stderr, " -nosmooth Don't use high-quality upsampling\n"); +#ifdef QUANT_1PASS_SUPPORTED + fprintf(stderr, " -onepass Use 1-pass quantization (fast, low quality)\n"); +#endif + fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n"); + fprintf(stderr, " -outfile name Specify name for output file\n"); + fprintf(stderr, " -verbose or -debug Emit debug output\n"); + exit(EXIT_FAILURE); +} + + +LOCAL(int) +parse_switches (j_decompress_ptr cinfo, int argc, char **argv, + int last_file_arg_seen, boolean for_real) +/* Parse optional switches. + * Returns argv[] index of first file-name argument (== argc if none). + * Any file names with indexes <= last_file_arg_seen are ignored; + * they have presumably been processed in a previous iteration. + * (Pass 0 for last_file_arg_seen on the first or only iteration.) + * for_real is FALSE on the first (dummy) pass; we may skip any expensive + * processing. + */ +{ + int argn; + char * arg; + + /* Set up default JPEG parameters. */ + requested_fmt = DEFAULT_FMT; /* set default output file format */ + outfilename = NULL; + cinfo->err->trace_level = 0; + + /* Scan command line options, adjust parameters */ + + for (argn = 1; argn < argc; argn++) { + arg = argv[argn]; + if (*arg != '-') { + /* Not a switch, must be a file name argument */ + if (argn <= last_file_arg_seen) { + outfilename = NULL; /* -outfile applies to just one input file */ + continue; /* ignore this name if previously processed */ + } + break; /* else done parsing switches */ + } + arg++; /* advance past switch marker character */ + + if (keymatch(arg, "bmp", 1)) { + /* BMP output format. */ + requested_fmt = FMT_BMP; + + } else if (keymatch(arg, "colors", 1) || keymatch(arg, "colours", 1) || + keymatch(arg, "quantize", 1) || keymatch(arg, "quantise", 1)) { + /* Do color quantization. */ + int val; + + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%d", &val) != 1) + usage(); + cinfo->desired_number_of_colors = val; + cinfo->quantize_colors = TRUE; + + } else if (keymatch(arg, "dct", 2)) { + /* Select IDCT algorithm. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + if (keymatch(argv[argn], "int", 1)) { + cinfo->dct_method = JDCT_ISLOW; + } else if (keymatch(argv[argn], "fast", 2)) { + cinfo->dct_method = JDCT_IFAST; + } else if (keymatch(argv[argn], "float", 2)) { + cinfo->dct_method = JDCT_FLOAT; + } else + usage(); + + } else if (keymatch(arg, "dither", 2)) { + /* Select dithering algorithm. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + if (keymatch(argv[argn], "fs", 2)) { + cinfo->dither_mode = JDITHER_FS; + } else if (keymatch(argv[argn], "none", 2)) { + cinfo->dither_mode = JDITHER_NONE; + } else if (keymatch(argv[argn], "ordered", 2)) { + cinfo->dither_mode = JDITHER_ORDERED; + } else + usage(); + + } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) { + /* Enable debug printouts. */ + /* On first -d, print version identification */ + static boolean printed_version = FALSE; + + if (! printed_version) { + fprintf(stderr, "Independent JPEG Group's DJPEG, version %s\n%s\n", + JVERSION, JCOPYRIGHT); + printed_version = TRUE; + } + cinfo->err->trace_level++; + + } else if (keymatch(arg, "fast", 1)) { + /* Select recommended processing options for quick-and-dirty output. */ + cinfo->two_pass_quantize = FALSE; + cinfo->dither_mode = JDITHER_ORDERED; + if (! cinfo->quantize_colors) /* don't override an earlier -colors */ + cinfo->desired_number_of_colors = 216; + cinfo->dct_method = JDCT_FASTEST; + cinfo->do_fancy_upsampling = FALSE; + + } else if (keymatch(arg, "gif", 1)) { + /* GIF output format. */ + requested_fmt = FMT_GIF; + + } else if (keymatch(arg, "grayscale", 2) || keymatch(arg, "greyscale",2)) { + /* Force monochrome output. */ + cinfo->out_color_space = JCS_GRAYSCALE; + + } else if (keymatch(arg, "map", 3)) { + /* Quantize to a color map taken from an input file. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + if (for_real) { /* too expensive to do twice! */ +#ifdef QUANT_2PASS_SUPPORTED /* otherwise can't quantize to supplied map */ + FILE * mapfile; + + if ((mapfile = fopen(argv[argn], READ_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]); + exit(EXIT_FAILURE); + } + read_color_map(cinfo, mapfile); + fclose(mapfile); + cinfo->quantize_colors = TRUE; +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } + + } else if (keymatch(arg, "maxmemory", 3)) { + /* Maximum memory in Kb (or Mb with 'm'). */ + long lval; + char ch = 'x'; + + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) + usage(); + if (ch == 'm' || ch == 'M') + lval *= 1000L; + cinfo->mem->max_memory_to_use = lval * 1000L; + + } else if (keymatch(arg, "nosmooth", 3)) { + /* Suppress fancy upsampling */ + cinfo->do_fancy_upsampling = FALSE; + + } else if (keymatch(arg, "onepass", 3)) { + /* Use fast one-pass quantization. */ + cinfo->two_pass_quantize = FALSE; + + } else if (keymatch(arg, "os2", 3)) { + /* BMP output format (OS/2 flavor). */ + requested_fmt = FMT_OS2; + + } else if (keymatch(arg, "outfile", 4)) { + /* Set output file name. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + outfilename = argv[argn]; /* save it away for later use */ + + } else if (keymatch(arg, "pnm", 1) || keymatch(arg, "ppm", 1)) { + /* PPM/PGM output format. */ + requested_fmt = FMT_PPM; + + } else if (keymatch(arg, "rle", 1)) { + /* RLE output format. */ + requested_fmt = FMT_RLE; + + } else if (keymatch(arg, "scale", 1)) { + /* Scale the output image by a fraction M/N. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%d/%d", + &cinfo->scale_num, &cinfo->scale_denom) != 2) + usage(); + + } else if (keymatch(arg, "targa", 1)) { + /* Targa output format. */ + requested_fmt = FMT_TARGA; + + } else { + usage(); /* bogus switch */ + } + } + + return argn; /* return index of next arg (file name) */ +} + + +/* + * Marker processor for COM markers. + * This replaces the library's built-in processor, which just skips the marker. + * We want to print out the marker as text, if possible. + * Note this code relies on a non-suspending data source. + */ + +LOCAL(unsigned int) +jpeg_getc (j_decompress_ptr cinfo) +/* Read next byte */ +{ + struct jpeg_source_mgr * datasrc = cinfo->src; + + if (datasrc->bytes_in_buffer == 0) { + if (! (*datasrc->fill_input_buffer) (cinfo)) + ERREXIT(cinfo, JERR_CANT_SUSPEND); + } + datasrc->bytes_in_buffer--; + return GETJOCTET(*datasrc->next_input_byte++); +} + + +METHODDEF(boolean) +COM_handler (j_decompress_ptr cinfo) +{ + boolean traceit = (cinfo->err->trace_level >= 1); + INT32 length; + unsigned int ch; + unsigned int lastch = 0; + + length = jpeg_getc(cinfo) << 8; + length += jpeg_getc(cinfo); + length -= 2; /* discount the length word itself */ + + if (traceit) + fprintf(stderr, "Comment, length %ld:\n", (long) length); + + while (--length >= 0) { + ch = jpeg_getc(cinfo); + if (traceit) { + /* Emit the character in a readable form. + * Nonprintables are converted to \nnn form, + * while \ is converted to \\. + * Newlines in CR, CR/LF, or LF form will be printed as one newline. + */ + if (ch == '\r') { + fprintf(stderr, "\n"); + } else if (ch == '\n') { + if (lastch != '\r') + fprintf(stderr, "\n"); + } else if (ch == '\\') { + fprintf(stderr, "\\\\"); + } else if (isprint(ch)) { + putc(ch, stderr); + } else { + fprintf(stderr, "\\%03o", ch); + } + lastch = ch; + } + } + + if (traceit) + fprintf(stderr, "\n"); + + return TRUE; +} + + +/* + * The main program. + */ + +int +main (int argc, char **argv) +{ + struct jpeg_decompress_struct cinfo; + struct jpeg_error_mgr jerr; +#ifdef PROGRESS_REPORT + struct cdjpeg_progress_mgr progress; +#endif + int file_index; + djpeg_dest_ptr dest_mgr = NULL; + FILE * input_file; + FILE * output_file; + JDIMENSION num_scanlines; + + /* On Mac, fetch a command line. */ +#ifdef USE_CCOMMAND + argc = ccommand(&argv); +#endif + + progname = argv[0]; + if (progname == NULL || progname[0] == 0) + progname = "djpeg"; /* in case C library doesn't provide it */ + + /* Initialize the JPEG decompression object with default error handling. */ + cinfo.err = jpeg_std_error(&jerr); + jpeg_create_decompress(&cinfo); + /* Add some application-specific error messages (from cderror.h) */ + jerr.addon_message_table = cdjpeg_message_table; + jerr.first_addon_message = JMSG_FIRSTADDONCODE; + jerr.last_addon_message = JMSG_LASTADDONCODE; + /* Insert custom COM marker processor. */ + jpeg_set_marker_processor(&cinfo, JPEG_COM, COM_handler); + + /* Now safe to enable signal catcher. */ +#ifdef NEED_SIGNAL_CATCHER + enable_signal_catcher((j_common_ptr) &cinfo); +#endif + + /* Scan command line to find file names. */ + /* It is convenient to use just one switch-parsing routine, but the switch + * values read here are ignored; we will rescan the switches after opening + * the input file. + * (Exception: tracing level set here controls verbosity for COM markers + * found during jpeg_read_header...) + */ + + file_index = parse_switches(&cinfo, argc, argv, 0, FALSE); + +#ifdef TWO_FILE_COMMANDLINE + /* Must have either -outfile switch or explicit output file name */ + if (outfilename == NULL) { + if (file_index != argc-2) { + fprintf(stderr, "%s: must name one input and one output file\n", + progname); + usage(); + } + outfilename = argv[file_index+1]; + } else { + if (file_index != argc-1) { + fprintf(stderr, "%s: must name one input and one output file\n", + progname); + usage(); + } + } +#else + /* Unix style: expect zero or one file name */ + if (file_index < argc-1) { + fprintf(stderr, "%s: only one input file\n", progname); + usage(); + } +#endif /* TWO_FILE_COMMANDLINE */ + + /* Open the input file. */ + if (file_index < argc) { + if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, argv[file_index]); + exit(EXIT_FAILURE); + } + } else { + /* default input file is stdin */ + input_file = read_stdin(); + } + + /* Open the output file. */ + if (outfilename != NULL) { + if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, outfilename); + exit(EXIT_FAILURE); + } + } else { + /* default output file is stdout */ + output_file = write_stdout(); + } + +#ifdef PROGRESS_REPORT + start_progress_monitor((j_common_ptr) &cinfo, &progress); +#endif + + /* Specify data source for decompression */ + jpeg_stdio_src(&cinfo, input_file); + + /* Read file header, set default decompression parameters */ + (void) jpeg_read_header(&cinfo, TRUE); + + /* Adjust default decompression parameters by re-parsing the options */ + file_index = parse_switches(&cinfo, argc, argv, 0, TRUE); + + /* Initialize the output module now to let it override any crucial + * option settings (for instance, GIF wants to force color quantization). + */ + switch (requested_fmt) { +#ifdef BMP_SUPPORTED + case FMT_BMP: + dest_mgr = jinit_write_bmp(&cinfo, FALSE); + break; + case FMT_OS2: + dest_mgr = jinit_write_bmp(&cinfo, TRUE); + break; +#endif +#ifdef GIF_SUPPORTED + case FMT_GIF: + dest_mgr = jinit_write_gif(&cinfo); + break; +#endif +#ifdef PPM_SUPPORTED + case FMT_PPM: + dest_mgr = jinit_write_ppm(&cinfo); + break; +#endif +#ifdef RLE_SUPPORTED + case FMT_RLE: + dest_mgr = jinit_write_rle(&cinfo); + break; +#endif +#ifdef TARGA_SUPPORTED + case FMT_TARGA: + dest_mgr = jinit_write_targa(&cinfo); + break; +#endif + default: + ERREXIT(&cinfo, JERR_UNSUPPORTED_FORMAT); + break; + } + dest_mgr->output_file = output_file; + + /* Start decompressor */ + (void) jpeg_start_decompress(&cinfo); + + /* Write output file header */ + (*dest_mgr->start_output) (&cinfo, dest_mgr); + + /* Process data */ + while (cinfo.output_scanline < cinfo.output_height) { + num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer, + dest_mgr->buffer_height); + (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines); + } + +#ifdef PROGRESS_REPORT + /* Hack: count final pass as done in case finish_output does an extra pass. + * The library won't have updated completed_passes. + */ + progress.pub.completed_passes = progress.pub.total_passes; +#endif + + /* Finish decompression and release memory. + * I must do it in this order because output module has allocated memory + * of lifespan JPOOL_IMAGE; it needs to finish before releasing memory. + */ + (*dest_mgr->finish_output) (&cinfo, dest_mgr); + (void) jpeg_finish_decompress(&cinfo); + jpeg_destroy_decompress(&cinfo); + + /* Close files, if we opened them */ + if (input_file != stdin) + fclose(input_file); + if (output_file != stdout) + fclose(output_file); + +#ifdef PROGRESS_REPORT + end_progress_monitor((j_common_ptr) &cinfo); +#endif + + /* All done. */ + exit(jerr.num_warnings ? EXIT_WARNING : EXIT_SUCCESS); + return 0; /* suppress no-return-value warnings */ +} diff --git a/gs/jpeg/example.c b/gs/jpeg/example.c new file mode 100644 index 000000000..7fc354f04 --- /dev/null +++ b/gs/jpeg/example.c @@ -0,0 +1,433 @@ +/* + * example.c + * + * This file illustrates how to use the IJG code as a subroutine library + * to read or write JPEG image files. You should look at this code in + * conjunction with the documentation file libjpeg.doc. + * + * This code will not do anything useful as-is, but it may be helpful as a + * skeleton for constructing routines that call the JPEG library. + * + * We present these routines in the same coding style used in the JPEG code + * (ANSI function definitions, etc); but you are of course free to code your + * routines in a different style if you prefer. + */ + +#include + +/* + * Include file for users of JPEG library. + * You will need to have included system headers that define at least + * the typedefs FILE and size_t before you can include jpeglib.h. + * (stdio.h is sufficient on ANSI-conforming systems.) + * You may also wish to include "jerror.h". + */ + +#include "jpeglib.h" + +/* + * is used for the optional error recovery mechanism shown in + * the second part of the example. + */ + +#include + + + +/******************** JPEG COMPRESSION SAMPLE INTERFACE *******************/ + +/* This half of the example shows how to feed data into the JPEG compressor. + * We present a minimal version that does not worry about refinements such + * as error recovery (the JPEG code will just exit() if it gets an error). + */ + + +/* + * IMAGE DATA FORMATS: + * + * The standard input image format is a rectangular array of pixels, with + * each pixel having the same number of "component" values (color channels). + * Each pixel row is an array of JSAMPLEs (which typically are unsigned chars). + * If you are working with color data, then the color values for each pixel + * must be adjacent in the row; for example, R,G,B,R,G,B,R,G,B,... for 24-bit + * RGB color. + * + * For this example, we'll assume that this data structure matches the way + * our application has stored the image in memory, so we can just pass a + * pointer to our image buffer. In particular, let's say that the image is + * RGB color and is described by: + */ + +extern JSAMPLE * image_buffer; /* Points to large array of R,G,B-order data */ +extern int image_height; /* Number of rows in image */ +extern int image_width; /* Number of columns in image */ + + +/* + * Sample routine for JPEG compression. We assume that the target file name + * and a compression quality factor are passed in. + */ + +GLOBAL(void) +write_JPEG_file (char * filename, int quality) +{ + /* This struct contains the JPEG compression parameters and pointers to + * working space (which is allocated as needed by the JPEG library). + * It is possible to have several such structures, representing multiple + * compression/decompression processes, in existence at once. We refer + * to any one struct (and its associated working data) as a "JPEG object". + */ + struct jpeg_compress_struct cinfo; + /* This struct represents a JPEG error handler. It is declared separately + * because applications often want to supply a specialized error handler + * (see the second half of this file for an example). But here we just + * take the easy way out and use the standard error handler, which will + * print a message on stderr and call exit() if compression fails. + * Note that this struct must live as long as the main JPEG parameter + * struct, to avoid dangling-pointer problems. + */ + struct jpeg_error_mgr jerr; + /* More stuff */ + FILE * outfile; /* target file */ + JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */ + int row_stride; /* physical row width in image buffer */ + + /* Step 1: allocate and initialize JPEG compression object */ + + /* We have to set up the error handler first, in case the initialization + * step fails. (Unlikely, but it could happen if you are out of memory.) + * This routine fills in the contents of struct jerr, and returns jerr's + * address which we place into the link field in cinfo. + */ + cinfo.err = jpeg_std_error(&jerr); + /* Now we can initialize the JPEG compression object. */ + jpeg_create_compress(&cinfo); + + /* Step 2: specify data destination (eg, a file) */ + /* Note: steps 2 and 3 can be done in either order. */ + + /* Here we use the library-supplied code to send compressed data to a + * stdio stream. You can also write your own code to do something else. + * VERY IMPORTANT: use "b" option to fopen() if you are on a machine that + * requires it in order to write binary files. + */ + if ((outfile = fopen(filename, "wb")) == NULL) { + fprintf(stderr, "can't open %s\n", filename); + exit(1); + } + jpeg_stdio_dest(&cinfo, outfile); + + /* Step 3: set parameters for compression */ + + /* First we supply a description of the input image. + * Four fields of the cinfo struct must be filled in: + */ + cinfo.image_width = image_width; /* image width and height, in pixels */ + cinfo.image_height = image_height; + cinfo.input_components = 3; /* # of color components per pixel */ + cinfo.in_color_space = JCS_RGB; /* colorspace of input image */ + /* Now use the library's routine to set default compression parameters. + * (You must set at least cinfo.in_color_space before calling this, + * since the defaults depend on the source color space.) + */ + jpeg_set_defaults(&cinfo); + /* Now you can set any non-default parameters you wish to. + * Here we just illustrate the use of quality (quantization table) scaling: + */ + jpeg_set_quality(&cinfo, quality, TRUE /* limit to baseline-JPEG values */); + + /* Step 4: Start compressor */ + + /* TRUE ensures that we will write a complete interchange-JPEG file. + * Pass TRUE unless you are very sure of what you're doing. + */ + jpeg_start_compress(&cinfo, TRUE); + + /* Step 5: while (scan lines remain to be written) */ + /* jpeg_write_scanlines(...); */ + + /* Here we use the library's state variable cinfo.next_scanline as the + * loop counter, so that we don't have to keep track ourselves. + * To keep things simple, we pass one scanline per call; you can pass + * more if you wish, though. + */ + row_stride = image_width * 3; /* JSAMPLEs per row in image_buffer */ + + while (cinfo.next_scanline < cinfo.image_height) { + /* jpeg_write_scanlines expects an array of pointers to scanlines. + * Here the array is only one element long, but you could pass + * more than one scanline at a time if that's more convenient. + */ + row_pointer[0] = & image_buffer[cinfo.next_scanline * row_stride]; + (void) jpeg_write_scanlines(&cinfo, row_pointer, 1); + } + + /* Step 6: Finish compression */ + + jpeg_finish_compress(&cinfo); + /* After finish_compress, we can close the output file. */ + fclose(outfile); + + /* Step 7: release JPEG compression object */ + + /* This is an important step since it will release a good deal of memory. */ + jpeg_destroy_compress(&cinfo); + + /* And we're done! */ +} + + +/* + * SOME FINE POINTS: + * + * In the above loop, we ignored the return value of jpeg_write_scanlines, + * which is the number of scanlines actually written. We could get away + * with this because we were only relying on the value of cinfo.next_scanline, + * which will be incremented correctly. If you maintain additional loop + * variables then you should be careful to increment them properly. + * Actually, for output to a stdio stream you needn't worry, because + * then jpeg_write_scanlines will write all the lines passed (or else exit + * with a fatal error). Partial writes can only occur if you use a data + * destination module that can demand suspension of the compressor. + * (If you don't know what that's for, you don't need it.) + * + * If the compressor requires full-image buffers (for entropy-coding + * optimization or a multi-scan JPEG file), it will create temporary + * files for anything that doesn't fit within the maximum-memory setting. + * (Note that temp files are NOT needed if you use the default parameters.) + * On some systems you may need to set up a signal handler to ensure that + * temporary files are deleted if the program is interrupted. See libjpeg.doc. + * + * Scanlines MUST be supplied in top-to-bottom order if you want your JPEG + * files to be compatible with everyone else's. If you cannot readily read + * your data in that order, you'll need an intermediate array to hold the + * image. See rdtarga.c or rdbmp.c for examples of handling bottom-to-top + * source data using the JPEG code's internal virtual-array mechanisms. + */ + + + +/******************** JPEG DECOMPRESSION SAMPLE INTERFACE *******************/ + +/* This half of the example shows how to read data from the JPEG decompressor. + * It's a bit more refined than the above, in that we show: + * (a) how to modify the JPEG library's standard error-reporting behavior; + * (b) how to allocate workspace using the library's memory manager. + * + * Just to make this example a little different from the first one, we'll + * assume that we do not intend to put the whole image into an in-memory + * buffer, but to send it line-by-line someplace else. We need a one- + * scanline-high JSAMPLE array as a work buffer, and we will let the JPEG + * memory manager allocate it for us. This approach is actually quite useful + * because we don't need to remember to deallocate the buffer separately: it + * will go away automatically when the JPEG object is cleaned up. + */ + + +/* + * ERROR HANDLING: + * + * The JPEG library's standard error handler (jerror.c) is divided into + * several "methods" which you can override individually. This lets you + * adjust the behavior without duplicating a lot of code, which you might + * have to update with each future release. + * + * Our example here shows how to override the "error_exit" method so that + * control is returned to the library's caller when a fatal error occurs, + * rather than calling exit() as the standard error_exit method does. + * + * We use C's setjmp/longjmp facility to return control. This means that the + * routine which calls the JPEG library must first execute a setjmp() call to + * establish the return point. We want the replacement error_exit to do a + * longjmp(). But we need to make the setjmp buffer accessible to the + * error_exit routine. To do this, we make a private extension of the + * standard JPEG error handler object. (If we were using C++, we'd say we + * were making a subclass of the regular error handler.) + * + * Here's the extended error handler struct: + */ + +struct my_error_mgr { + struct jpeg_error_mgr pub; /* "public" fields */ + + jmp_buf setjmp_buffer; /* for return to caller */ +}; + +typedef struct my_error_mgr * my_error_ptr; + +/* + * Here's the routine that will replace the standard error_exit method: + */ + +METHODDEF(void) +my_error_exit (j_common_ptr cinfo) +{ + /* cinfo->err really points to a my_error_mgr struct, so coerce pointer */ + my_error_ptr myerr = (my_error_ptr) cinfo->err; + + /* Always display the message. */ + /* We could postpone this until after returning, if we chose. */ + (*cinfo->err->output_message) (cinfo); + + /* Return control to the setjmp point */ + longjmp(myerr->setjmp_buffer, 1); +} + + +/* + * Sample routine for JPEG decompression. We assume that the source file name + * is passed in. We want to return 1 on success, 0 on error. + */ + + +GLOBAL(int) +read_JPEG_file (char * filename) +{ + /* This struct contains the JPEG decompression parameters and pointers to + * working space (which is allocated as needed by the JPEG library). + */ + struct jpeg_decompress_struct cinfo; + /* We use our private extension JPEG error handler. + * Note that this struct must live as long as the main JPEG parameter + * struct, to avoid dangling-pointer problems. + */ + struct my_error_mgr jerr; + /* More stuff */ + FILE * infile; /* source file */ + JSAMPARRAY buffer; /* Output row buffer */ + int row_stride; /* physical row width in output buffer */ + + /* In this example we want to open the input file before doing anything else, + * so that the setjmp() error recovery below can assume the file is open. + * VERY IMPORTANT: use "b" option to fopen() if you are on a machine that + * requires it in order to read binary files. + */ + + if ((infile = fopen(filename, "rb")) == NULL) { + fprintf(stderr, "can't open %s\n", filename); + return 0; + } + + /* Step 1: allocate and initialize JPEG decompression object */ + + /* We set up the normal JPEG error routines, then override error_exit. */ + cinfo.err = jpeg_std_error(&jerr.pub); + jerr.pub.error_exit = my_error_exit; + /* Establish the setjmp return context for my_error_exit to use. */ + if (setjmp(jerr.setjmp_buffer)) { + /* If we get here, the JPEG code has signaled an error. + * We need to clean up the JPEG object, close the input file, and return. + */ + jpeg_destroy_decompress(&cinfo); + fclose(infile); + return 0; + } + /* Now we can initialize the JPEG decompression object. */ + jpeg_create_decompress(&cinfo); + + /* Step 2: specify data source (eg, a file) */ + + jpeg_stdio_src(&cinfo, infile); + + /* Step 3: read file parameters with jpeg_read_header() */ + + (void) jpeg_read_header(&cinfo, TRUE); + /* We can ignore the return value from jpeg_read_header since + * (a) suspension is not possible with the stdio data source, and + * (b) we passed TRUE to reject a tables-only JPEG file as an error. + * See libjpeg.doc for more info. + */ + + /* Step 4: set parameters for decompression */ + + /* In this example, we don't need to change any of the defaults set by + * jpeg_read_header(), so we do nothing here. + */ + + /* Step 5: Start decompressor */ + + (void) jpeg_start_decompress(&cinfo); + /* We can ignore the return value since suspension is not possible + * with the stdio data source. + */ + + /* We may need to do some setup of our own at this point before reading + * the data. After jpeg_start_decompress() we have the correct scaled + * output image dimensions available, as well as the output colormap + * if we asked for color quantization. + * In this example, we need to make an output work buffer of the right size. + */ + /* JSAMPLEs per row in output buffer */ + row_stride = cinfo.output_width * cinfo.output_components; + /* Make a one-row-high sample array that will go away when done with image */ + buffer = (*cinfo.mem->alloc_sarray) + ((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1); + + /* Step 6: while (scan lines remain to be read) */ + /* jpeg_read_scanlines(...); */ + + /* Here we use the library's state variable cinfo.output_scanline as the + * loop counter, so that we don't have to keep track ourselves. + */ + while (cinfo.output_scanline < cinfo.output_height) { + /* jpeg_read_scanlines expects an array of pointers to scanlines. + * Here the array is only one element long, but you could ask for + * more than one scanline at a time if that's more convenient. + */ + (void) jpeg_read_scanlines(&cinfo, buffer, 1); + /* Assume put_scanline_someplace wants a pointer and sample count. */ + put_scanline_someplace(buffer[0], row_stride); + } + + /* Step 7: Finish decompression */ + + (void) jpeg_finish_decompress(&cinfo); + /* We can ignore the return value since suspension is not possible + * with the stdio data source. + */ + + /* Step 8: Release JPEG decompression object */ + + /* This is an important step since it will release a good deal of memory. */ + jpeg_destroy_decompress(&cinfo); + + /* After finish_decompress, we can close the input file. + * Here we postpone it until after no more JPEG errors are possible, + * so as to simplify the setjmp error logic above. (Actually, I don't + * think that jpeg_destroy can do an error exit, but why assume anything...) + */ + fclose(infile); + + /* At this point you may want to check to see whether any corrupt-data + * warnings occurred (test whether jerr.pub.num_warnings is nonzero). + */ + + /* And we're done! */ + return 1; +} + + +/* + * SOME FINE POINTS: + * + * In the above code, we ignored the return value of jpeg_read_scanlines, + * which is the number of scanlines actually read. We could get away with + * this because we asked for only one line at a time and we weren't using + * a suspending data source. See libjpeg.doc for more info. + * + * We cheated a bit by calling alloc_sarray() after jpeg_start_decompress(); + * we should have done it beforehand to ensure that the space would be + * counted against the JPEG max_memory setting. In some systems the above + * code would risk an out-of-memory error. However, in general we don't + * know the output image dimensions before jpeg_start_decompress(), unless we + * call jpeg_calc_output_dimensions(). See libjpeg.doc for more about this. + * + * Scanlines are returned in the same order as they appear in the JPEG file, + * which is standardly top-to-bottom. If you must emit data bottom-to-top, + * you can use one of the virtual arrays provided by the JPEG memory manager + * to invert the data. See wrbmp.c for an example. + * + * As with compression, some operating modes may require temporary files. + * On some systems you may need to set up a signal handler to ensure that + * temporary files are deleted if the program is interrupted. See libjpeg.doc. + */ diff --git a/gs/jpeg/filelist.doc b/gs/jpeg/filelist.doc new file mode 100644 index 000000000..707dc1c6b --- /dev/null +++ b/gs/jpeg/filelist.doc @@ -0,0 +1,203 @@ +IJG JPEG LIBRARY: FILE LIST + +Copyright (C) 1994-1996, Thomas G. Lane. +This file is part of the Independent JPEG Group's software. +For conditions of distribution and use, see the accompanying README file. + + +Here is a road map to the files in the IJG JPEG distribution. The +distribution includes the JPEG library proper, plus two application +programs ("cjpeg" and "djpeg") which use the library to convert JPEG +files to and from some other popular image formats. A third application +"jpegtran" uses the library to do lossless conversion between different +variants of JPEG. There are also two stand-alone applications, +"rdjpgcom" and "wrjpgcom". + + +THE JPEG LIBRARY +================ + +Include files: + +jpeglib.h JPEG library's exported data and function declarations. +jconfig.h Configuration declarations. Note: this file is not present + in the distribution; it is generated during installation. +jmorecfg.h Additional configuration declarations; need not be changed + for a standard installation. +jerror.h Declares JPEG library's error and trace message codes. +jinclude.h Central include file used by all IJG .c files to reference + system include files. +jpegint.h JPEG library's internal data structures. +jchuff.h Private declarations for Huffman encoder modules. +jdhuff.h Private declarations for Huffman decoder modules. +jdct.h Private declarations for forward & reverse DCT subsystems. +jmemsys.h Private declarations for memory management subsystem. +jversion.h Version information. + +Applications using the library should include jpeglib.h (which in turn +includes jconfig.h and jmorecfg.h). Optionally, jerror.h may be included +if the application needs to reference individual JPEG error codes. The +other include files are intended for internal use and would not normally +be included by an application program. (cjpeg/djpeg/etc do use jinclude.h, +since its function is to improve portability of the whole IJG distribution. +Most other applications will directly include the system include files they +want, and hence won't need jinclude.h.) + + +C source code files: + +These files contain most of the functions intended to be called directly by +an application program: + +jcapimin.c Application program interface: core routines for compression. +jcapistd.c Application program interface: standard compression. +jdapimin.c Application program interface: core routines for decompression. +jdapistd.c Application program interface: standard decompression. +jcomapi.c Application program interface routines common to compression + and decompression. +jcparam.c Compression parameter setting helper routines. +jctrans.c API and library routines for transcoding compression. +jdtrans.c API and library routines for transcoding decompression. + +Compression side of the library: + +jcinit.c Initialization: determines which other modules to use. +jcmaster.c Master control: setup and inter-pass sequencing logic. +jcmainct.c Main buffer controller (preprocessor => JPEG compressor). +jcprepct.c Preprocessor buffer controller. +jccoefct.c Buffer controller for DCT coefficient buffer. +jccolor.c Color space conversion. +jcsample.c Downsampling. +jcdctmgr.c DCT manager (DCT implementation selection & control). +jfdctint.c Forward DCT using slow-but-accurate integer method. +jfdctfst.c Forward DCT using faster, less accurate integer method. +jfdctflt.c Forward DCT using floating-point arithmetic. +jchuff.c Huffman entropy coding for sequential JPEG. +jcphuff.c Huffman entropy coding for progressive JPEG. +jcmarker.c JPEG marker writing. +jdatadst.c Data destination manager for stdio output. + +Decompression side of the library: + +jdmaster.c Master control: determines which other modules to use. +jdinput.c Input controller: controls input processing modules. +jdmainct.c Main buffer controller (JPEG decompressor => postprocessor). +jdcoefct.c Buffer controller for DCT coefficient buffer. +jdpostct.c Postprocessor buffer controller. +jdmarker.c JPEG marker reading. +jdhuff.c Huffman entropy decoding for sequential JPEG. +jdphuff.c Huffman entropy decoding for progressive JPEG. +jddctmgr.c IDCT manager (IDCT implementation selection & control). +jidctint.c Inverse DCT using slow-but-accurate integer method. +jidctfst.c Inverse DCT using faster, less accurate integer method. +jidctflt.c Inverse DCT using floating-point arithmetic. +jidctred.c Inverse DCTs with reduced-size outputs. +jdsample.c Upsampling. +jdcolor.c Color space conversion. +jdmerge.c Merged upsampling/color conversion (faster, lower quality). +jquant1.c One-pass color quantization using a fixed-spacing colormap. +jquant2.c Two-pass color quantization using a custom-generated colormap. + Also handles one-pass quantization to an externally given map. +jdatasrc.c Data source manager for stdio input. + +Support files for both compression and decompression: + +jerror.c Standard error handling routines (application replaceable). +jmemmgr.c System-independent (more or less) memory management code. +jutils.c Miscellaneous utility routines. + +jmemmgr.c relies on a system-dependent memory management module. The IJG +distribution includes the following implementations of the system-dependent +module: + +jmemnobs.c "No backing store": assumes adequate virtual memory exists. +jmemansi.c Makes temporary files with ANSI-standard routine tmpfile(). +jmemname.c Makes temporary files with program-generated file names. +jmemdos.c Custom implementation for MS-DOS: knows about extended and + expanded memory as well as temporary files. +jmemmac.c Custom implementation for Apple Macintosh. + +Exactly one of the system-dependent modules should be configured into an +installed JPEG library (see install.doc for hints about which one to use). +On unusual systems you may find it worthwhile to make a special +system-dependent memory manager. + + +Non-C source code files: + +jmemdosa.asm 80x86 assembly code support for jmemdos.c; used only in + MS-DOS-specific configurations of the JPEG library. + + +CJPEG/DJPEG/JPEGTRAN +==================== + +Include files: + +cdjpeg.h Declarations shared by cjpeg/djpeg modules. +cderror.h Additional error and trace message codes for cjpeg/djpeg. + +C source code files: + +cjpeg.c Main program for cjpeg. +djpeg.c Main program for djpeg. +jpegtran.c Main program for jpegtran. +cdjpeg.c Utility routines used by all three programs. +rdcolmap.c Code to read a colormap file for djpeg's "-map" switch. +rdswitch.c Code to process some of cjpeg's more complex switches. + Also used by jpegtran. + +Image file reader modules for cjpeg: + +rdbmp.c BMP file input. +rdgif.c GIF file input. +rdppm.c PPM/PGM file input. +rdrle.c Utah RLE file input. +rdtarga.c Targa file input. + +Image file writer modules for djpeg: + +wrbmp.c BMP file output. +wrgif.c GIF file output. +wrppm.c PPM/PGM file output. +wrrle.c Utah RLE file output. +wrtarga.c Targa file output. + + +RDJPGCOM/WRJPGCOM +================= + +C source code files: + +rdjpgcom.c Stand-alone rdjpgcom application. +wrjpgcom.c Stand-alone wrjpgcom application. + +These programs do not depend on the IJG library. They do use +jconfig.h and jinclude.h, only to improve portability. + + +ADDITIONAL FILES +================ + +Documentation (see README for a guide to the documentation files): + +README Master documentation file. +*.doc Other documentation files. +*.1 Documentation in Unix man page format. +change.log Version-to-version change highlights. +example.c Sample code for calling JPEG library. + +Configuration/installation files and programs (see install.doc for more info): + +configure Unix shell script to perform automatic configuration. +ckconfig.c Program to generate jconfig.h on non-Unix systems. +jconfig.doc Template for making jconfig.h by hand. +makefile.* Sample makefiles for particular systems. +jconfig.* Sample jconfig.h for particular systems. +ansi2knr.c De-ANSIfier for pre-ANSI C compilers (courtesy of + L. Peter Deutsch and Aladdin Enterprises). + +Test files (see install.doc for test procedure): + +test*.* Source and comparison files for confidence test. + These are binary image files, NOT text files. diff --git a/gs/jpeg/install.doc b/gs/jpeg/install.doc new file mode 100644 index 000000000..585b29b2e --- /dev/null +++ b/gs/jpeg/install.doc @@ -0,0 +1,931 @@ +INSTALLATION INSTRUCTIONS for the Independent JPEG Group's JPEG software + +Copyright (C) 1991-1996, Thomas G. Lane. +This file is part of the Independent JPEG Group's software. +For conditions of distribution and use, see the accompanying README file. + + +This file explains how to configure and install the IJG software. We have +tried to make this software extremely portable and flexible, so that it can be +adapted to almost any environment. The downside of this decision is that the +installation process is complicated. We have provided shortcuts to simplify +the task on common systems. But in any case, you will need at least a little +familiarity with C programming and program build procedures for your system. + +If you are only using this software as part of a larger program, the larger +program's installation procedure may take care of configuring the IJG code. +For example, Ghostscript's installation script will configure the IJG code. +You don't need to read this file if you just want to compile Ghostscript. + +If you are on a Unix machine, you may not need to read this file at all. +Try doing + ./configure + make + make test +If that doesn't complain, do + make install +(better do "make -n install" first to see if the makefile will put the files +where you want them). Read further if you run into snags or want to customize +the code for your system. + + +TABLE OF CONTENTS +----------------- + +Before you start +Configuring the software: + using the automatic "configure" script + using one of the supplied jconfig and makefile files + by hand +Building the software +Testing the software +Installing the software +Optional stuff +Optimization +Hints for specific systems + + +BEFORE YOU START +================ + +Before installing the software you must unpack the distributed source code. +Since you are reading this file, you have probably already succeeded in this +task. However, there is a potential for error if you needed to convert the +files to the local standard text file format (for example, if you are on +MS-DOS you may have converted LF end-of-line to CR/LF). You must apply +such conversion to all the files EXCEPT those whose names begin with "test". +The test files contain binary data; if you change them in any way then the +self-test will give bad results. + +Please check the last section of this file to see if there are hints for the +specific machine or compiler you are using. + + +CONFIGURING THE SOFTWARE +======================== + +To configure the IJG code for your system, you need to create two files: + * jconfig.h: contains values for system-dependent #define symbols. + * Makefile: controls the compilation process. +(On a non-Unix machine, you may create "project files" or some other +substitute for a Makefile. jconfig.h is needed in any environment.) + +We provide three different ways to generate these files: + * On a Unix system, you can just run the "configure" script. + * We provide sample jconfig files and makefiles for popular machines; + if your machine matches one of the samples, just copy the right sample + files to jconfig.h and Makefile. + * If all else fails, read the instructions below and make your own files. + + +Configuring the software using the automatic "configure" script +--------------------------------------------------------------- + +If you are on a Unix machine, you can just type + ./configure +and let the configure script construct appropriate configuration files. +If you're using "csh" on an old version of System V, you might need to type + sh configure +instead to prevent csh from trying to execute configure itself. +Expect configure to run for a few minutes, particularly on slower machines; +it works by compiling a series of test programs. + +Configure was created with GNU Autoconf and it follows the usual conventions +for GNU configure scripts. It makes a few assumptions that you may want to +override. You can do this by providing optional switches to configure: + +* Configure will use gcc (GNU C compiler) if it's available, otherwise cc. +To force a particular compiler to be selected, use the CC option, for example + ./configure CC='cc' +The same method can be used to include any unusual compiler switches. +For example, on HP-UX you probably want to say + ./configure CC='cc -Aa' +to get HP's compiler to run in ANSI mode. + +* The default CFLAGS setting is "-O". You can override this by saying, +for example, ./configure CFLAGS='-O2'. + +* Configure will set up the makefile so that "make install" will install files +into /usr/local/bin, /usr/local/man, etc. You can specify an installation +prefix other than "/usr/local" by giving configure the option "--prefix=PATH". + +* If you don't have a lot of swap space, you may need to enable the IJG +software's internal virtual memory mechanism. To do this, give the option +"--enable-maxmem=N" where N is the default maxmemory limit in megabytes. +This is discussed in more detail under "Selecting a memory manager", below. +You probably don't need to worry about this on reasonably-sized Unix machines, +unless you plan to process very large images. + +Configure has some other features that are useful if you are cross-compiling +or working in a network of multiple machine types; but if you need those +features, you probably already know how to use them. + + +Configuring the software using one of the supplied jconfig and makefile files +----------------------------------------------------------------------------- + +If you have one of these systems, you can just use the provided configuration +files: + +Makefile jconfig file System and/or compiler + +makefile.manx jconfig.manx Amiga, Manx Aztec C +makefile.sas jconfig.sas Amiga, SAS C +mak*jpeg.st jconfig.st Atari ST/STE/TT, Pure C or Turbo C +makefile.bcc jconfig.bcc MS-DOS or OS/2, Borland C +makefile.dj jconfig.dj MS-DOS, DJGPP (Delorie's port of GNU C) +makefile.mc6 jconfig.mc6 MS-DOS, Microsoft C version 6.x and up +makefile.wat jconfig.wat MS-DOS, OS/2, or Windows NT, Watcom C +makefile.mms jconfig.vms Digital VMS, with MMS software +makefile.vms jconfig.vms Digital VMS, without MMS software + +Copy the proper jconfig file to jconfig.h and the makefile to Makefile +(or whatever your system uses as the standard makefile name). For the +Atari, we provide four project files; see the Atari hints below. + + +Configuring the software by hand +-------------------------------- + +First, generate a jconfig.h file. If you are moderately familiar with C, +the comments in jconfig.doc should be enough information to do this; just +copy jconfig.doc to jconfig.h and edit it appropriately. Otherwise, you may +prefer to use the ckconfig.c program. You will need to compile and execute +ckconfig.c by hand --- we hope you know at least enough to do that. +ckconfig.c may not compile the first try (in fact, the whole idea is for it +to fail if anything is going to). If you get compile errors, fix them by +editing ckconfig.c according to the directions given in ckconfig.c. Once +you get it to run, it will write a suitable jconfig.h file, and will also +print out some advice about which makefile to use. + +You may also want to look at the canned jconfig files, if there is one for a +system similar to yours. + +Second, select a makefile and copy it to Makefile (or whatever your system +uses as the standard makefile name). The most generic makefiles we provide +are + makefile.ansi: if your C compiler supports function prototypes + makefile.unix: if not. +(You have function prototypes if ckconfig.c put "#define HAVE_PROTOTYPES" +in jconfig.h.) You may want to start from one of the other makefiles if +there is one for a system similar to yours. + +Look over the selected Makefile and adjust options as needed. In particular +you may want to change the CC and CFLAGS definitions. For instance, if you +are using GCC, set CC=gcc. If you had to use any compiler switches to get +ckconfig.c to work, make sure the same switches are in CFLAGS. + +If you are on a system that doesn't use makefiles, you'll need to set up +project files (or whatever you do use) to compile all the source files and +link them into executable files cjpeg, djpeg, jpegtran, rdjpgcom, and wrjpgcom. +See the file lists in any of the makefiles to find out which files go into +each program. Note that the provided makefiles all make a "library" file +libjpeg first, but you don't have to do that if you don't want to; the file +lists identify which source files are actually needed for compression, +decompression, or both. As a last resort, you can make a batch script that +just compiles everything and links it all together; makefile.vms is an example +of this (it's for VMS systems that have no make-like utility). + +Here are comments about some specific configuration decisions you'll +need to make: + +Command line style +------------------ + +These programs can use a Unix-like command line style which supports +redirection and piping, like this: + cjpeg inputfile >outputfile + cjpeg outputfile + source program | cjpeg >outputfile +The simpler "two file" command line style is just + cjpeg inputfile outputfile +You may prefer the two-file style, particularly if you don't have pipes. + +You MUST use two-file style on any system that doesn't cope well with binary +data fed through stdin/stdout; this is true for some MS-DOS compilers, for +example. If you're not on a Unix system, it's safest to assume you need +two-file style. (But if your compiler provides either the Posix-standard +fdopen() library routine or a Microsoft-compatible setmode() routine, you +can safely use the Unix command line style, by defining USE_FDOPEN or +USE_SETMODE respectively.) + +To use the two-file style, make jconfig.h say "#define TWO_FILE_COMMANDLINE". + +Selecting a memory manager +-------------------------- + +The IJG code is capable of working on images that are too big to fit in main +memory; data is swapped out to temporary files as necessary. However, the +code to do this is rather system-dependent. We provide five different +memory managers: + +* jmemansi.c This version uses the ANSI-standard library routine tmpfile(), + which not all non-ANSI systems have. On some systems + tmpfile() may put the temporary file in a non-optimal + location; if you don't like what it does, use jmemname.c. + +* jmemname.c This version creates named temporary files. For anything + except a Unix machine, you'll need to configure the + select_file_name() routine appropriately; see the comments + near the head of jmemname.c. If you use this version, define + NEED_SIGNAL_CATCHER in jconfig.h to make sure the temp files + are removed if the program is aborted. + +* jmemnobs.c (That stands for No Backing Store :-).) This will compile on + almost any system, but it assumes you have enough main memory + or virtual memory to hold the biggest images you work with. + +* jmemdos.c This should be used with most 16-bit MS-DOS compilers. + See the system-specific notes about MS-DOS for more info. + IMPORTANT: if you use this, define USE_MSDOS_MEMMGR in + jconfig.h, and include the assembly file jmemdosa.asm in the + programs. The supplied makefiles and jconfig files for + 16-bit MS-DOS compilers already do both. + +* jmemmac.c Custom version for Apple Macintosh; see the system-specific + notes for Macintosh for more info. + +To use a particular memory manager, change the SYSDEPMEM variable in your +makefile to equal the corresponding object file name (for example, jmemansi.o +or jmemansi.obj for jmemansi.c). + +If you have plenty of (real or virtual) main memory, just use jmemnobs.c. +"Plenty" means about ten bytes for every pixel in the largest images +you plan to process, so a lot of systems don't meet this criterion. +If yours doesn't, try jmemansi.c first. If that doesn't compile, you'll have +to use jmemname.c; be sure to adjust select_file_name() for local conditions. +You may also need to change unlink() to remove() in close_backing_store(). + +Except with jmemnobs.c or jmemmac.c, you need to adjust the DEFAULT_MAX_MEM +setting to a reasonable value for your system (either by adding a #define for +DEFAULT_MAX_MEM to jconfig.h, or by adding a -D switch to the Makefile). +This value limits the amount of data space the program will attempt to +allocate. Code and static data space isn't counted, so the actual memory +needs for cjpeg or djpeg are typically 100 to 150Kb more than the max-memory +setting. Larger max-memory settings reduce the amount of I/O needed to +process a large image, but too large a value can result in "insufficient +memory" failures. On most Unix machines (and other systems with virtual +memory), just set DEFAULT_MAX_MEM to several million and forget it. At the +other end of the spectrum, for MS-DOS machines you probably can't go much +above 300K to 400K. (On MS-DOS the value refers to conventional memory only. +Extended/expanded memory is handled separately by jmemdos.c.) + + +BUILDING THE SOFTWARE +===================== + +Now you should be able to compile the software. Just say "make" (or +whatever's necessary to start the compilation). Have a cup of coffee. + +Here are some things that could go wrong: + +If your compiler complains about undefined structures, you should be able to +shut it up by putting "#define INCOMPLETE_TYPES_BROKEN" in jconfig.h. + +If you have trouble with missing system include files or inclusion of the +wrong ones, read jinclude.h. This shouldn't happen if you used configure +or ckconfig.c to set up jconfig.h. + +There are a fair number of routines that do not use all of their parameters; +some compilers will issue warnings about this, which you can ignore. There +are also a few configuration checks that may give "unreachable code" warnings. +Any other warning deserves investigation. + +If you don't have a getenv() library routine, define NO_GETENV. + +Also see the system-specific hints, below. + + +TESTING THE SOFTWARE +==================== + +As a quick test of functionality we've included a small sample image in +several forms: + testorig.jpg Starting point for the djpeg tests. + testimg.ppm The output of djpeg testorig.jpg + testimg.gif The output of djpeg -gif testorig.jpg + testimg.jpg The output of cjpeg testimg.ppm + testprog.jpg Progressive-mode equivalent of testorig.jpg. + testimgp.jpg The output of cjpeg -progressive -optimize testimg.ppm +(The first- and second-generation .jpg files aren't identical since JPEG is +lossy.) If you can generate duplicates of the testimg* files then you +probably have working programs. + +With most of the makefiles, "make test" will perform the necessary +comparisons. + +If you're using a makefile that doesn't provide the test option, run djpeg +and cjpeg by hand and compare the output files to testimg* with whatever +binary file comparison tool you have. The files should be bit-for-bit +identical. + +If the programs complain "MAX_ALLOC_CHUNK is wrong, please fix", then you +need to reduce MAX_ALLOC_CHUNK to a value that fits in type size_t. +Try adding "#define MAX_ALLOC_CHUNK 65520L" to jconfig.h. A less likely +configuration error is "ALIGN_TYPE is wrong, please fix": defining ALIGN_TYPE +as long should take care of that one. + +If the cjpeg test run fails with "Missing Huffman code table entry", it's a +good bet that you needed to define RIGHT_SHIFT_IS_UNSIGNED. Go back to the +configuration step and run ckconfig.c. (This is a good plan for any other +test failure, too.) + +If you are using Unix (one-file) command line style on a non-Unix system, +it's a good idea to check that binary I/O through stdin/stdout actually +works. You should get the same results from "djpeg out.ppm" +as from "djpeg -outfile out.ppm testorig.jpg". Note that the makefiles all +use the latter style and therefore do not exercise stdin/stdout! If this +check fails, try recompiling with USE_SETMODE or USE_FDOPEN defined. +If it still doesn't work, better use two-file style. + +If you chose a memory manager other than jmemnobs.c, you should test that +temporary-file usage works. Try "djpeg -gif -max 0 testorig.jpg" and make +sure its output matches testimg.gif. If you have any really large images +handy, try compressing them with -optimize and/or decompressing with -gif to +make sure your DEFAULT_MAX_MEM setting is not too large. + +NOTE: this is far from an exhaustive test of the JPEG software; some modules, +such as 1-pass color quantization, are not exercised at all. It's just a +quick test to give you some confidence that you haven't missed something +major. + + +INSTALLING THE SOFTWARE +======================= + +Once you're done with the above steps, you can install the software by +copying the executable files (cjpeg, djpeg, jpegtran, rdjpgcom, and wrjpgcom) +to wherever you normally install programs. On Unix systems, you'll also want +to put the man pages (cjpeg.1, djpeg.1, jpegtran.1, rdjpgcom.1, wrjpgcom.1) +in the man-page directory. The canned makefiles don't support this step +since there's such a wide variety of installation procedures on different +systems. + +If you generated a Makefile with the "configure" script, you can just say + make install +to install the programs and their man pages into the standard places. +(You'll probably need to be root to do this.) We recommend first saying + make -n install +to see where configure thought the files should go. You may need to edit +the Makefile, particularly if your system's conventions for man page +filenames don't match what configure expects. + +If you want to install the library file libjpeg.a and the include files j*.h +(for use in compiling other programs besides the IJG ones), then say + make install-lib + + +OPTIONAL STUFF +============== + +Progress monitor: + +If you like, you can #define PROGRESS_REPORT (in jconfig.h) to enable display +of percent-done progress reports. The routine provided in cdjpeg.c merely +prints percentages to stderr, but you can customize it to do something +fancier. + +Utah RLE file format support: + +We distribute the software with support for RLE image files (Utah Raster +Toolkit format) disabled, because the RLE support won't compile without the +Utah library. If you have URT version 3.1 or later, you can enable RLE +support as follows: + 1. #define RLE_SUPPORTED in jconfig.h. + 2. Add a -I option to CFLAGS in the Makefile for the directory + containing the URT .h files (typically the "include" + subdirectory of the URT distribution). + 3. Add -L... -lrle to LDLIBS in the Makefile, where ... specifies + the directory containing the URT "librle.a" file (typically the + "lib" subdirectory of the URT distribution). + +Support for 12-bit-deep pixel data: + +The JPEG standard allows either 8-bit or 12-bit data precision. (For color, +this means 8 or 12 bits per channel, of course.) If you need to work with +deeper than 8-bit data, you can compile the IJG code for 12-bit operation. +To do so: + 1. In jmorecfg.h, define BITS_IN_JSAMPLE as 12 rather than 8. + 2. In jconfig.h, undefine BMP_SUPPORTED, RLE_SUPPORTED, and TARGA_SUPPORTED, + because the code for those formats doesn't handle 12-bit data and won't + even compile. (The PPM code does work, as explained below. The GIF + code works too; it scales 8-bit GIF data to and from 12-bit depth + automatically.) + 3. Compile. Don't expect "make test" to pass, since the supplied test + files are for 8-bit data. + +Currently, 12-bit support does not work on 16-bit-int machines. + +Note that a 12-bit version will not read 8-bit JPEG files, nor vice versa; +so you'll want to keep around a regular 8-bit compilation as well. +(Run-time selection of data depth, to allow a single copy that does both, +is possible but would probably slow things down considerably; it's very low +on our to-do list.) + +The PPM reader (rdppm.c) can read 12-bit data from either text-format or +binary-format PPM and PGM files. Binary-format PPM/PGM files which have a +maxval greater than 255 are assumed to use 2 bytes per sample, LSB first +(little-endian order). As of early 1995, 2-byte binary format is not +officially supported by the PBMPLUS library, but it is expected that the +next release of PBMPLUS will support it. Note that the PPM reader will +read files of any maxval regardless of the BITS_IN_JSAMPLE setting; incoming +data is automatically rescaled to either maxval=255 or maxval=4095 as +appropriate for the cjpeg bit depth. + +The PPM writer (wrppm.c) will normally write 2-byte binary PPM or PGM +format, maxval 4095, when compiled with BITS_IN_JSAMPLE=12. Since this +format is not yet widely supported, you can disable it by compiling wrppm.c +with PPM_NORAWWORD defined; then the data is scaled down to 8 bits to make a +standard 1-byte/sample PPM or PGM file. (Yes, this means still another copy +of djpeg to keep around. But hopefully you won't need it for very long. +Poskanzer's supposed to get that new PBMPLUS release out Real Soon Now.) + +Of course, if you are working with 12-bit data, you probably have it stored +in some other, nonstandard format. In that case you'll probably want to +write your own I/O modules to read and write your format. + +Note that a 12-bit version of cjpeg always runs in "-optimize" mode, in +order to generate valid Huffman tables. This is necessary because our +default Huffman tables only cover 8-bit data. + +Removing code: + +If you need to make a smaller version of the JPEG software, some optional +functions can be removed at compile time. See the xxx_SUPPORTED #defines in +jconfig.h and jmorecfg.h. If at all possible, we recommend that you leave in +decoder support for all valid JPEG files, to ensure that you can read anyone's +output. Taking out support for image file formats that you don't use is the +most painless way to make the programs smaller. Another possibility is to +remove some of the DCT methods: in particular, the "IFAST" method may not be +enough faster than the others to be worth keeping on your machine. (If you +do remove ISLOW or IFAST, be sure to redefine JDCT_DEFAULT or JDCT_FASTEST +to a supported method, by adding a #define in jconfig.h.) + + +OPTIMIZATION +============ + +Unless you own a Cray, you'll probably be interested in making the JPEG +software go as fast as possible. This section covers some machine-dependent +optimizations you may want to try. We suggest that before trying any of +this, you first get the basic installation to pass the self-test step. +Repeat the self-test after any optimization to make sure that you haven't +broken anything. + +The integer DCT routines perform a lot of multiplications. These +multiplications must yield 32-bit results, but none of their input values +are more than 16 bits wide. On many machines, notably the 680x0 and 80x86 +CPUs, a 16x16=>32 bit multiply instruction is faster than a full 32x32=>32 +bit multiply. Unfortunately there is no portable way to specify such a +multiplication in C, but some compilers can generate one when you use the +right combination of casts. See the MULTIPLYxxx macro definitions in +jdct.h. If your compiler makes "int" be 32 bits and "short" be 16 bits, +defining SHORTxSHORT_32 is fairly likely to work. When experimenting with +alternate definitions, be sure to test not only whether the code still works +(use the self-test), but also whether it is actually faster --- on some +compilers, alternate definitions may compute the right answer, yet be slower +than the default. Timing cjpeg on a large PGM (grayscale) input file is the +best way to check this, as the DCT will be the largest fraction of the runtime +in that mode. (Note: some of the distributed compiler-specific jconfig files +already contain #define switches to select appropriate MULTIPLYxxx +definitions.) + +If your machine has sufficiently fast floating point hardware, you may find +that the float DCT method is faster than the integer DCT methods, even +after tweaking the integer multiply macros. In that case you may want to +make the float DCT be the default method. (The only objection to this is +that float DCT results may vary slightly across machines.) To do that, add +"#define JDCT_DEFAULT JDCT_FLOAT" to jconfig.h. Even if you don't change +the default, you should redefine JDCT_FASTEST, which is the method selected +by djpeg's -fast switch. Don't forget to update the documentation files +(usage.doc and/or cjpeg.1, djpeg.1) to agree with what you've done. + +If access to "short" arrays is slow on your machine, it may be a win to +define type JCOEF as int rather than short. This will cost a good deal of +memory though, particularly in some multi-pass modes, so don't do it unless +you have memory to burn and short is REALLY slow. + +If your compiler can compile function calls in-line, make sure the INLINE +macro in jmorecfg.h is defined as the keyword that marks a function +inline-able. Some compilers have a switch that tells the compiler to inline +any function it thinks is profitable (e.g., -finline-functions for gcc). +Enabling such a switch is likely to make the compiled code bigger but faster. + +In general, it's worth trying the maximum optimization level of your compiler, +and experimenting with any optional optimizations such as loop unrolling. +(Unfortunately, far too many compilers have optimizer bugs ... be prepared to +back off if the code fails self-test.) If you do any experimentation along +these lines, please report the optimal settings to jpeg-info@uunet.uu.net so +we can mention them in future releases. Be sure to specify your machine and +compiler version. + + +HINTS FOR SPECIFIC SYSTEMS +========================== + +We welcome reports on changes needed for systems not mentioned here. Submit +'em to jpeg-info@uunet.uu.net. Also, if configure or ckconfig.c is wrong +about how to configure the JPEG software for your system, please let us know. + + +Acorn RISC OS: + +(Thanks to Simon Middleton for these hints on compiling with Desktop C.) +After renaming the files according to Acorn conventions, take a copy of +makefile.ansi, change all occurrences of 'libjpeg.a' to 'libjpeg.o' and +change these definitions as indicated: + +CFLAGS= -throwback -IC: -Wn +LDLIBS=C:o.Stubs +SYSDEPMEM=jmemansi.o +LN=Link +AR=LibFile -c -o + +Also add a new line '.c.o:; $(cc) $< $(cflags) -c -o $@'. Remove the +lines '$(RM) libjpeg.o' and '$(AR2) libjpeg.o' and the 'jconfig.h' +dependency section. + +Copy jconfig.doc to jconfig.h. Edit jconfig.h to define TWO_FILE_COMMANDLINE +and CHAR_IS_UNSIGNED. + +Run the makefile using !AMU not !Make. If you want to use the 'clean' and +'test' makefile entries then you will have to fiddle with the syntax a bit +and rename the test files. + + +Amiga: + +SAS C 6.50 reportedly is too buggy to compile the IJG code properly. +A patch to update to 6.51 is available from SAS or AmiNet FTP sites. + +The supplied config files are set up to use jmemname.c as the memory +manager, with temporary files being created on the device named by +"JPEGTMP:". + + +Atari ST/STE/TT: + +Copy the project files makcjpeg.st, makdjpeg.st, maktjpeg.st, and makljpeg.st +to cjpeg.prj, djpeg.prj, jpegtran.prj, and libjpeg.prj respectively. The +project files should work as-is with Pure C. For Turbo C, change library +filenames "PC..." to "TC..." in each project file. Note that libjpeg.prj +selects jmemansi.c as the recommended memory manager. You'll probably want to +adjust the DEFAULT_MAX_MEM setting --- you want it to be a couple hundred K +less than your normal free memory. Put "#define DEFAULT_MAX_MEM nnnn" into +jconfig.h to do this. + +To use the 68881/68882 coprocessor for the floating point DCT, add the +compiler option "-8" to the project files and replace PCFLTLIB.LIB with +PC881LIB.LIB in cjpeg.prj and djpeg.prj. Or if you don't have a +coprocessor, you may prefer to remove the float DCT code by undefining +DCT_FLOAT_SUPPORTED in jmorecfg.h (since without a coprocessor, the float +code will be too slow to be useful). In that case, you can delete +PCFLTLIB.LIB from the project files. + +Note that you must make libjpeg.lib before making cjpeg.ttp, djpeg.ttp, +or jpegtran.ttp. You'll have to perform the self-test by hand. + +We haven't bothered to include project files for rdjpgcom and wrjpgcom. +Those source files should just be compiled by themselves; they don't +depend on the JPEG library. + +There is a bug in some older versions of the Turbo C library which causes the +space used by temporary files created with "tmpfile()" not to be freed after +an abnormal program exit. If you check your disk afterwards, you will find +cluster chains that are allocated but not used by a file. This should not +happen in cjpeg/djpeg/jpegtran, since we enable a signal catcher to explicitly +close temp files before exiting. But if you use the JPEG library with your +own code, be sure to supply a signal catcher, or else use a different +system-dependent memory manager. + + +Cray: + +Should you be so fortunate as to be running JPEG on a Cray YMP, there is a +compiler bug in old versions of Cray's Standard C (prior to 3.1). If you +still have an old compiler, you'll need to insert a line reading +"#pragma novector" just before the loop + for (i = 1; i <= (int) htbl->bits[l]; i++) + huffsize[p++] = (char) l; +in fix_huff_tbl (in V5beta1, line 204 of jchuff.c and line 176 of jdhuff.c). +[This bug may or may not still occur with the current IJG code, but it's +probably a dead issue anyway...] + + +HP-UX: + +If you have HP-UX 7.05 or later with the "software development" C compiler, +you should run the compiler in ANSI mode. If using the configure script, +say + ./configure CC='cc -Aa' +(or -Ae if you prefer). If configuring by hand, use makefile.ansi and add +"-Aa" to the CFLAGS line in the makefile. + +If you have a pre-7.05 system, or if you are using the non-ANSI C compiler +delivered with a minimum HP-UX system, then you must use makefile.unix +(and do NOT add -Aa); or just run configure without the CC option. + +On HP 9000 series 800 machines, the HP C compiler is buggy in revisions prior +to A.08.07. If you get complaints about "not a typedef name", you'll have to +use makefile.unix, or run configure without the CC option. + + +Macintosh, generic comments: + +The supplied user-interface files (cjpeg.c, djpeg.c, etc) are set up to +provide a Unix-style command line interface. You can use this interface on +the Mac by means of the ccommand() library routine provided by Metrowerks +CodeWarrior or Think C. This is only appropriate for testing the library, +however; to make a user-friendly equivalent of cjpeg/djpeg you'd really want +to develop a Mac-style user interface. Such an interface exists for pre-v5 +IJG libraries (see the Think C entry, below) but at this writing it has not +been updated to work with the current release. + +We recommend replacing "malloc" and "free" by "NewPtr" and "DisposePtr" in +whichever memory manager back end you use, because Mac C libraries often +have inferior implementations of malloc/free. jmemmac.c is recommended; +it is a customized version of jmemansi.c with this change and a Mac-specific +implementation of jpeg_mem_available(). You can also use jmemnobs.c if you +don't care about handling images larger than available memory. + + +Macintosh, MPW: + +We don't directly support MPW in the current release, but Larry Rosenstein +ported an earlier version of the IJG code without very much trouble. There's +useful notes and conversion scripts in his kit for porting PBMPLUS to MPW. +You can obtain the kit by FTP to ftp.apple.com, files /pub/lsr/pbmplus-port*. + + +Macintosh, Metrowerks CodeWarrior: + +Metrowerks release DR2 has problems with the IJG code; don't use it. Release +DR3.5 or later should be OK. + +The Unix-command-line-style interface can be used by defining USE_CCOMMAND. +You'll also need to define either TWO_FILE_COMMANDLINE (to avoid stdin/stdout) +or USE_FDOPEN (to make stdin/stdout work in binary mode). See the Think C +entry for more details. + +On 680x0 Macs, Metrowerks defines type "double" as a 10-byte IEEE extended +float. jmemmgr.c won't like this: it wants sizeof(ALIGN_TYPE) to be a power +of 2. Add "#define ALIGN_TYPE long" to jconfig.h to eliminate the complaint. + + +Macintosh, Think C: + +Jim Brunner has prepared a Mac-style user interface for the IJG library. +Unfortunately, the released version of it only works with pre-v5 libraries; +still, it may be a useful starting point. You can obtain Jim's additional +source code from the Info-Mac archives, at sumex-aim.stanford.edu or mirrors +thereof; see file /info-mac/dev/src/jpeg-convert-c.hqx. Jim's documentation +also includes more detailed build instructions for Think C. + +If you want to build the minimal command line version, proceed as follows. +You'll have to prepare project files for the programs; we don't include any +in the distribution since they are not text files. Use the file lists in +any of the supplied makefiles as a guide. Also add the ANSI and Unix C +libraries in a separate segment. You may need to divide the JPEG files into +more than one segment; we recommend dividing compression and decompression +modules. Define USE_CCOMMAND in jconfig.h so that the ccommand() routine is +called. You must also define TWO_FILE_COMMANDLINE because stdin/stdout +don't handle binary data correctly. + +On 680x0 Macs, Think C defines type "double" as a 12-byte IEEE extended float. +jmemmgr.c won't like this: it wants sizeof(ALIGN_TYPE) to be a power of 2. +Add "#define ALIGN_TYPE long" to jconfig.h to eliminate the complaint. + + +MIPS R3000: + +MIPS's cc version 1.31 has a rather nasty optimization bug. Don't use -O +if you have that compiler version. (Use "cc -V" to check the version.) +Note that the R3000 chip is found in workstations from DEC and others. + + +MS-DOS, generic comments for 16-bit compilers: + +The IJG code is designed to be compiled in 80x86 "small" or "medium" memory +models (i.e., data pointers are 16 bits unless explicitly declared "far"; +code pointers can be either size). You may be able to use small model to +compile cjpeg or djpeg by itself, but you will probably have to use medium +model for any larger application. This won't make much difference in +performance. You *will* take a noticeable performance hit if you use a +large-data memory model, and you should avoid "huge" model if at all +possible. Be sure that NEED_FAR_POINTERS is defined in jconfig.h if you use +a small-data memory model; be sure it is NOT defined if you use a large-data +model. (The supplied makefiles and jconfig files for Borland and Microsoft C +compile in medium model and define NEED_FAR_POINTERS.) + +The DOS-specific memory manager, jmemdos.c, should be used if possible. +It needs some assembly-code routines which are in jmemdosa.asm; make sure +your makefile assembles that file and includes it in the library. If you +don't have a suitable assembler, you can get pre-assembled object files for +jmemdosa by FTP from ftp.uu.net: graphics/jpeg/jdosaobj.zip. (DOS-oriented +distributions of the IJG source code often include these object files.) + +When using jmemdos.c, jconfig.h must define USE_MSDOS_MEMMGR and must set +MAX_ALLOC_CHUNK to less than 64K (65520L is a typical value). If your +C library's far-heap malloc() can't allocate blocks that large, reduce +MAX_ALLOC_CHUNK to whatever it can handle. + +If you can't use jmemdos.c for some reason --- for example, because you +don't have an assembler to assemble jmemdosa.asm --- you'll have to fall +back to jmemansi.c or jmemname.c. You'll probably still need to set +MAX_ALLOC_CHUNK in jconfig.h, because most DOS C libraries won't malloc() +more than 64K at a time. IMPORTANT: if you use jmemansi.c or jmemname.c, +you will have to compile in a large-data memory model in order to get the +right stdio library. Too bad. + +wrjpgcom needs to be compiled in large model, because it malloc()s a 64KB +work area to hold the comment text. If your C library's malloc can't +handle that, reduce MAX_COM_LENGTH as necessary in wrjpgcom.c. + +Most MS-DOS compilers treat stdin/stdout as text files, so you must use +two-file command line style. But if your compiler has either fdopen() or +setmode(), you can use one-file style if you like. To do this, define +USE_SETMODE or USE_FDOPEN so that stdin/stdout will be set to binary mode. +(USE_SETMODE seems to work with more DOS compilers than USE_FDOPEN.) You +should test that I/O through stdin/stdout produces the same results as I/O +to explicitly named files... the "make test" procedures in the supplied +makefiles do NOT use stdin/stdout. + + +MS-DOS, generic comments for 32-bit compilers: + +None of the above comments about memory models apply if you are using a +32-bit flat-memory-space environment, such as DJGPP or Watcom C. (And you +should use one if you have it, as performance will be much better than +8086-compatible code!) For flat-memory-space compilers, do NOT define +NEED_FAR_POINTERS, and do NOT use jmemdos.c. Use jmemnobs.c if the +environment supplies adequate virtual memory, otherwise use jmemansi.c or +jmemname.c. + +You'll still need to be careful about binary I/O through stdin/stdout. +See the last paragraph of the previous section. + + +MS-DOS, Borland C: + +Be sure to convert all the source files to DOS text format (CR/LF newlines). +Although Borland C will often work OK with unmodified Unix (LF newlines) +source files, sometimes it will give bogus compile errors. +"Illegal character '#'" is the most common such error. (This is true with +Borland C 3.1, but perhaps is fixed in newer releases.) + +If you want one-file command line style, just undefine TWO_FILE_COMMANDLINE. +jconfig.bcc already includes #define USE_SETMODE to make this work. +(fdopen does not work correctly.) + + +MS-DOS, DJGPP: + +Use a recent version of DJGPP (1.11 or better). If you prefer two-file +command line style, change the supplied jconfig.dj to define +TWO_FILE_COMMANDLINE. makefile.dj is set up to generate only COFF files +(cjpeg, djpeg, etc) when you say make. After testing, say "make exe" to +make executables with stub.exe, or "make standalone" if you want executables +that include go32. You will probably need to tweak the makefile's pointer to +go32.exe to do "make standalone". + + +MS-DOS, Microsoft C: + +makefile.mc6 works with Microsoft C, Visual C++, etc. Note that this +makefile assumes that the working copy of itself is called "makefile". +If you want to call it something else, say "makefile.mak", be sure to adjust +the dependency line that reads "$(RFILE) : makefile". Otherwise the make +will fail because it doesn't know how to create "makefile". Worse, some +releases of Microsoft's make utilities give an incorrect error message in +this situation. + +If you want one-file command line style, just undefine TWO_FILE_COMMANDLINE. +jconfig.mc6 already includes #define USE_SETMODE to make this work. +(fdopen does not work correctly.) + +Old versions of MS C fail with an "out of macro expansion space" error +because they can't cope with the macro TRACEMS8 (defined in jerror.h). +If this happens to you, the easiest solution is to change TRACEMS8 to +expand to nothing. You'll lose the ability to dump out JPEG coefficient +tables with djpeg -debug -debug, but at least you can compile. + +Original MS C 6.0 is very buggy; it compiles incorrect code unless you turn +off optimization entirely (remove -O from CFLAGS). 6.00A is better, but it +still generates bad code if you enable loop optimizations (-Ol or -Ox). + +MS C 8.0 reportedly fails to compile jquant1.c if optimization is turned off +(yes, off). + + +Microsoft Windows (all versions): + +Some Windows system include files define typedef boolean as "unsigned char". +The IJG code also defines typedef boolean, but we make it "int" by default. +This doesn't affect the IJG programs because we don't import those Windows +include files. But if you use the JPEG library in your own program, and some +of your program's files import one definition of boolean while some import the +other, you can get all sorts of mysterious problems. A good preventive step +is to change jmorecfg.h to define boolean as unsigned char. We recommend +making that part of jmorecfg.h read like this: + #ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ + typedef unsigned char boolean; + #endif +In v6a and later, using incompatible definitions of boolean will usually lead +to the failure message "JPEG parameter struct mismatch", rather than the +difficult-to-diagnose bugs it caused with earlier versions. + +When using the library in a Windows application, you will almost certainly +want to modify or replace the error handler module jerror.c, since our +default error handler does a couple of inappropriate things: + 1. it tries to write error and warning messages on stderr; + 2. in event of a fatal error, it exits by calling exit(). +A simple stopgap solution for problem 1 is to replace the line + fprintf(stderr, "%s\n", buffer); +(in output_message in jerror.c) with something like + MessageBox(GetActiveWindow(),buffer,"JPEG Error",MB_OK); +It's highly recommended that you at least do that much, since otherwise +error messages will disappear into nowhere. +The proper solution for problem 2 is to return control to your calling +application after a library error. This can be done with the setjmp/longjmp +technique discussed in libjpeg.doc and illustrated in example.c. + +You may also want to modify jdatasrc.c and jdatadst.c to use Windows file +operations rather than fread/fwrite. This is only necessary if your C +compiler doesn't provide a competent implementation of C stdio functions. + +Many people want to convert the IJG library into a DLL. This is reasonably +straightforward, but watch out for the following: + 1. Don't try to compile as a DLL in small or medium memory model; use +large model, or even better, 32-bit flat model. Many places in the IJG code +assume the address of a local variable is an ordinary (not FAR) pointer; +that isn't true in a medium-model DLL. + 2. Microsoft C cannot pass file pointers between applications and DLLs. +(See Microsoft Knowledge Base, PSS ID Number Q50336.) So jdatasrc.c and +jdatadst.c don't work if you open a file in your application and then pass +the pointer to the DLL. One workaround is to make jdatasrc.c/jdatadst.c +part of your main application rather than part of the DLL. + 3. You'll probably need to modify the macros GLOBAL() and EXTERN() to +attach suitable linkage keywords to the exported routine names. Similarly, +you'll want to modify METHODDEF() and JMETHOD() to ensure function pointers +are declared in a way that lets application routines be called back through +the function pointers. These macros are in jmorecfg.h. Typical definitions +for a 16-bit DLL are: + #define GLOBAL(type) type _far _pascal _loadds _export + #define EXTERN(type) extern type _far _pascal + #define METHODDEF(type) static type _far _pascal + #define JMETHOD(type,methodname,arglist) \ + type (_far _pascal *methodname) arglist +Although not all the GLOBAL routines are actually intended to be called by +the application, the performance cost of making them all DLL entry points is +negligible. + +The unmodified IJG library presents a very C-specific application interface, +so the resulting DLL is only usable from C or C++ applications. There has +been some talk of writing wrapper code that would present a simpler interface +usable from other languages, such as Visual Basic. This is on our to-do list +but hasn't been very high priority --- any volunteers out there? + + +Microsoft Windows, Borland C: + +Borland C++ 4.5 fails with an internal compiler error when trying to compile +jdmerge.c in 32-bit mode. If enough people complain, perhaps Borland will fix +it. In the meantime, the simplest known workaround is to add a redundant +definition of the variable range_limit in h2v1_merged_upsample(), at the head +of the block that handles odd image width (about line 268 in v6 jdmerge.c): + /* If image width is odd, do the last output column separately */ + if (cinfo->output_width & 1) { + register JSAMPLE * range_limit = cinfo->sample_range_limit; /* ADD THIS */ + cb = GETJSAMPLE(*inptr1); +Pretty bizarre, especially since the very similar routine h2v2_merged_upsample +doesn't trigger the bug. +Recent reports suggest that this bug does not occur with "bcc32a" (the +Pentium-optimized version of the compiler). + + +SGI: + +On some SGI systems, you may need to set "AR2= ar -ts" in the Makefile. +If you are using configure, you can do this by saying + ./configure RANLIB='ar -ts' +This change is not needed on all SGIs. Use it only if the make fails at the +stage of linking the completed programs. + +On the MIPS R4000 architecture (Indy, etc.), the compiler option "-mips2" +reportedly speeds up the float DCT method substantially, enough to make it +faster than the default int method (but still slower than the fast int +method). If you use -mips2, you may want to alter the default DCT method to +be float. To do this, put "#define JDCT_DEFAULT JDCT_FLOAT" in jconfig.h. + + +VMS: + +On an Alpha/VMS system with MMS, be sure to use the "/Marco=Alpha=1" +qualifier with MMS when building the JPEG package. + +VAX/VMS v5.5-1 may have problems with the test step of the build procedure +reporting differences when it compares the original and test images. If the +error points to the last block of the files, it is most likely bogus and may +be safely ignored. It seems to be because the files are Stream_LF and +Backup/Compare has difficulty with the (presumably) null padded files. +This problem was not observed on VAX/VMS v6.1 or AXP/VMS v6.1. diff --git a/gs/jpeg/jcapimin.c b/gs/jpeg/jcapimin.c new file mode 100644 index 000000000..6d864574c --- /dev/null +++ b/gs/jpeg/jcapimin.c @@ -0,0 +1,236 @@ +/* + * jcapimin.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains application interface code for the compression half + * of the JPEG library. These are the "minimum" API routines that may be + * needed in either the normal full-compression case or the transcoding-only + * case. + * + * Most of the routines intended to be called directly by an application + * are in this file or in jcapistd.c. But also see jcparam.c for + * parameter-setup helper routines, jcomapi.c for routines shared by + * compression and decompression, and jctrans.c for the transcoding case. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* + * Initialization of a JPEG compression object. + * The error manager must already be set up (in case memory manager fails). + */ + +GLOBAL(void) +jpeg_CreateCompress (j_compress_ptr cinfo, int version, size_t structsize) +{ + int i; + + /* Guard against version mismatches between library and caller. */ + cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */ + if (version != JPEG_LIB_VERSION) + ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version); + if (structsize != SIZEOF(struct jpeg_compress_struct)) + ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, + (int) SIZEOF(struct jpeg_compress_struct), (int) structsize); + + /* For debugging purposes, zero the whole master structure. + * But error manager pointer is already there, so save and restore it. + */ + { + struct jpeg_error_mgr * err = cinfo->err; + MEMZERO(cinfo, SIZEOF(struct jpeg_compress_struct)); + cinfo->err = err; + } + cinfo->is_decompressor = FALSE; + + /* Initialize a memory manager instance for this object */ + jinit_memory_mgr((j_common_ptr) cinfo); + + /* Zero out pointers to permanent structures. */ + cinfo->progress = NULL; + cinfo->dest = NULL; + + cinfo->comp_info = NULL; + + for (i = 0; i < NUM_QUANT_TBLS; i++) + cinfo->quant_tbl_ptrs[i] = NULL; + + for (i = 0; i < NUM_HUFF_TBLS; i++) { + cinfo->dc_huff_tbl_ptrs[i] = NULL; + cinfo->ac_huff_tbl_ptrs[i] = NULL; + } + + cinfo->input_gamma = 1.0; /* in case application forgets */ + + /* OK, I'm ready */ + cinfo->global_state = CSTATE_START; +} + + +/* + * Destruction of a JPEG compression object + */ + +GLOBAL(void) +jpeg_destroy_compress (j_compress_ptr cinfo) +{ + jpeg_destroy((j_common_ptr) cinfo); /* use common routine */ +} + + +/* + * Abort processing of a JPEG compression operation, + * but don't destroy the object itself. + */ + +GLOBAL(void) +jpeg_abort_compress (j_compress_ptr cinfo) +{ + jpeg_abort((j_common_ptr) cinfo); /* use common routine */ +} + + +/* + * Forcibly suppress or un-suppress all quantization and Huffman tables. + * Marks all currently defined tables as already written (if suppress) + * or not written (if !suppress). This will control whether they get emitted + * by a subsequent jpeg_start_compress call. + * + * This routine is exported for use by applications that want to produce + * abbreviated JPEG datastreams. It logically belongs in jcparam.c, but + * since it is called by jpeg_start_compress, we put it here --- otherwise + * jcparam.o would be linked whether the application used it or not. + */ + +GLOBAL(void) +jpeg_suppress_tables (j_compress_ptr cinfo, boolean suppress) +{ + int i; + JQUANT_TBL * qtbl; + JHUFF_TBL * htbl; + + for (i = 0; i < NUM_QUANT_TBLS; i++) { + if ((qtbl = cinfo->quant_tbl_ptrs[i]) != NULL) + qtbl->sent_table = suppress; + } + + for (i = 0; i < NUM_HUFF_TBLS; i++) { + if ((htbl = cinfo->dc_huff_tbl_ptrs[i]) != NULL) + htbl->sent_table = suppress; + if ((htbl = cinfo->ac_huff_tbl_ptrs[i]) != NULL) + htbl->sent_table = suppress; + } +} + + +/* + * Finish JPEG compression. + * + * If a multipass operating mode was selected, this may do a great deal of + * work including most of the actual output. + */ + +GLOBAL(void) +jpeg_finish_compress (j_compress_ptr cinfo) +{ + JDIMENSION iMCU_row; + + if (cinfo->global_state == CSTATE_SCANNING || + cinfo->global_state == CSTATE_RAW_OK) { + /* Terminate first pass */ + if (cinfo->next_scanline < cinfo->image_height) + ERREXIT(cinfo, JERR_TOO_LITTLE_DATA); + (*cinfo->master->finish_pass) (cinfo); + } else if (cinfo->global_state != CSTATE_WRCOEFS) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + /* Perform any remaining passes */ + while (! cinfo->master->is_last_pass) { + (*cinfo->master->prepare_for_pass) (cinfo); + for (iMCU_row = 0; iMCU_row < cinfo->total_iMCU_rows; iMCU_row++) { + if (cinfo->progress != NULL) { + cinfo->progress->pass_counter = (long) iMCU_row; + cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows; + (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); + } + /* We bypass the main controller and invoke coef controller directly; + * all work is being done from the coefficient buffer. + */ + if (! (*cinfo->coef->compress_data) (cinfo, (JSAMPIMAGE) NULL)) + ERREXIT(cinfo, JERR_CANT_SUSPEND); + } + (*cinfo->master->finish_pass) (cinfo); + } + /* Write EOI, do final cleanup */ + (*cinfo->marker->write_file_trailer) (cinfo); + (*cinfo->dest->term_destination) (cinfo); + /* We can use jpeg_abort to release memory and reset global_state */ + jpeg_abort((j_common_ptr) cinfo); +} + + +/* + * Write a special marker. + * This is only recommended for writing COM or APPn markers. + * Must be called after jpeg_start_compress() and before + * first call to jpeg_write_scanlines() or jpeg_write_raw_data(). + */ + +GLOBAL(void) +jpeg_write_marker (j_compress_ptr cinfo, int marker, + const JOCTET *dataptr, unsigned int datalen) +{ + if (cinfo->next_scanline != 0 || + (cinfo->global_state != CSTATE_SCANNING && + cinfo->global_state != CSTATE_RAW_OK && + cinfo->global_state != CSTATE_WRCOEFS)) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + (*cinfo->marker->write_any_marker) (cinfo, marker, dataptr, datalen); +} + + +/* + * Alternate compression function: just write an abbreviated table file. + * Before calling this, all parameters and a data destination must be set up. + * + * To produce a pair of files containing abbreviated tables and abbreviated + * image data, one would proceed as follows: + * + * initialize JPEG object + * set JPEG parameters + * set destination to table file + * jpeg_write_tables(cinfo); + * set destination to image file + * jpeg_start_compress(cinfo, FALSE); + * write data... + * jpeg_finish_compress(cinfo); + * + * jpeg_write_tables has the side effect of marking all tables written + * (same as jpeg_suppress_tables(..., TRUE)). Thus a subsequent start_compress + * will not re-emit the tables unless it is passed write_all_tables=TRUE. + */ + +GLOBAL(void) +jpeg_write_tables (j_compress_ptr cinfo) +{ + if (cinfo->global_state != CSTATE_START) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + /* (Re)initialize error mgr and destination modules */ + (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); + (*cinfo->dest->init_destination) (cinfo); + /* Initialize the marker writer ... bit of a crock to do it here. */ + jinit_marker_writer(cinfo); + /* Write them tables! */ + (*cinfo->marker->write_tables_only) (cinfo); + /* And clean up. */ + (*cinfo->dest->term_destination) (cinfo); + /* We can use jpeg_abort to release memory. */ + jpeg_abort((j_common_ptr) cinfo); +} diff --git a/gs/jpeg/jcapistd.c b/gs/jpeg/jcapistd.c new file mode 100644 index 000000000..c0320b1b1 --- /dev/null +++ b/gs/jpeg/jcapistd.c @@ -0,0 +1,161 @@ +/* + * jcapistd.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains application interface code for the compression half + * of the JPEG library. These are the "standard" API routines that are + * used in the normal full-compression case. They are not used by a + * transcoding-only application. Note that if an application links in + * jpeg_start_compress, it will end up linking in the entire compressor. + * We thus must separate this file from jcapimin.c to avoid linking the + * whole compression library into a transcoder. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* + * Compression initialization. + * Before calling this, all parameters and a data destination must be set up. + * + * We require a write_all_tables parameter as a failsafe check when writing + * multiple datastreams from the same compression object. Since prior runs + * will have left all the tables marked sent_table=TRUE, a subsequent run + * would emit an abbreviated stream (no tables) by default. This may be what + * is wanted, but for safety's sake it should not be the default behavior: + * programmers should have to make a deliberate choice to emit abbreviated + * images. Therefore the documentation and examples should encourage people + * to pass write_all_tables=TRUE; then it will take active thought to do the + * wrong thing. + */ + +GLOBAL(void) +jpeg_start_compress (j_compress_ptr cinfo, boolean write_all_tables) +{ + if (cinfo->global_state != CSTATE_START) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + if (write_all_tables) + jpeg_suppress_tables(cinfo, FALSE); /* mark all tables to be written */ + + /* (Re)initialize error mgr and destination modules */ + (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); + (*cinfo->dest->init_destination) (cinfo); + /* Perform master selection of active modules */ + jinit_compress_master(cinfo); + /* Set up for the first pass */ + (*cinfo->master->prepare_for_pass) (cinfo); + /* Ready for application to drive first pass through jpeg_write_scanlines + * or jpeg_write_raw_data. + */ + cinfo->next_scanline = 0; + cinfo->global_state = (cinfo->raw_data_in ? CSTATE_RAW_OK : CSTATE_SCANNING); +} + + +/* + * Write some scanlines of data to the JPEG compressor. + * + * The return value will be the number of lines actually written. + * This should be less than the supplied num_lines only in case that + * the data destination module has requested suspension of the compressor, + * or if more than image_height scanlines are passed in. + * + * Note: we warn about excess calls to jpeg_write_scanlines() since + * this likely signals an application programmer error. However, + * excess scanlines passed in the last valid call are *silently* ignored, + * so that the application need not adjust num_lines for end-of-image + * when using a multiple-scanline buffer. + */ + +GLOBAL(JDIMENSION) +jpeg_write_scanlines (j_compress_ptr cinfo, JSAMPARRAY scanlines, + JDIMENSION num_lines) +{ + JDIMENSION row_ctr, rows_left; + + if (cinfo->global_state != CSTATE_SCANNING) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + if (cinfo->next_scanline >= cinfo->image_height) + WARNMS(cinfo, JWRN_TOO_MUCH_DATA); + + /* Call progress monitor hook if present */ + if (cinfo->progress != NULL) { + cinfo->progress->pass_counter = (long) cinfo->next_scanline; + cinfo->progress->pass_limit = (long) cinfo->image_height; + (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); + } + + /* Give master control module another chance if this is first call to + * jpeg_write_scanlines. This lets output of the frame/scan headers be + * delayed so that application can write COM, etc, markers between + * jpeg_start_compress and jpeg_write_scanlines. + */ + if (cinfo->master->call_pass_startup) + (*cinfo->master->pass_startup) (cinfo); + + /* Ignore any extra scanlines at bottom of image. */ + rows_left = cinfo->image_height - cinfo->next_scanline; + if (num_lines > rows_left) + num_lines = rows_left; + + row_ctr = 0; + (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, num_lines); + cinfo->next_scanline += row_ctr; + return row_ctr; +} + + +/* + * Alternate entry point to write raw data. + * Processes exactly one iMCU row per call, unless suspended. + */ + +GLOBAL(JDIMENSION) +jpeg_write_raw_data (j_compress_ptr cinfo, JSAMPIMAGE data, + JDIMENSION num_lines) +{ + JDIMENSION lines_per_iMCU_row; + + if (cinfo->global_state != CSTATE_RAW_OK) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + if (cinfo->next_scanline >= cinfo->image_height) { + WARNMS(cinfo, JWRN_TOO_MUCH_DATA); + return 0; + } + + /* Call progress monitor hook if present */ + if (cinfo->progress != NULL) { + cinfo->progress->pass_counter = (long) cinfo->next_scanline; + cinfo->progress->pass_limit = (long) cinfo->image_height; + (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); + } + + /* Give master control module another chance if this is first call to + * jpeg_write_raw_data. This lets output of the frame/scan headers be + * delayed so that application can write COM, etc, markers between + * jpeg_start_compress and jpeg_write_raw_data. + */ + if (cinfo->master->call_pass_startup) + (*cinfo->master->pass_startup) (cinfo); + + /* Verify that at least one iMCU row has been passed. */ + lines_per_iMCU_row = cinfo->max_v_samp_factor * DCTSIZE; + if (num_lines < lines_per_iMCU_row) + ERREXIT(cinfo, JERR_BUFFER_SIZE); + + /* Directly compress the row. */ + if (! (*cinfo->coef->compress_data) (cinfo, data)) { + /* If compressor did not consume the whole row, suspend processing. */ + return 0; + } + + /* OK, we processed one iMCU row. */ + cinfo->next_scanline += lines_per_iMCU_row; + return lines_per_iMCU_row; +} diff --git a/gs/jpeg/jccoefct.c b/gs/jpeg/jccoefct.c new file mode 100644 index 000000000..d971ce5ba --- /dev/null +++ b/gs/jpeg/jccoefct.c @@ -0,0 +1,448 @@ +/* + * jccoefct.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the coefficient buffer controller for compression. + * This controller is the top level of the JPEG compressor proper. + * The coefficient buffer lies between forward-DCT and entropy encoding steps. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* We use a full-image coefficient buffer when doing Huffman optimization, + * and also for writing multiple-scan JPEG files. In all cases, the DCT + * step is run during the first pass, and subsequent passes need only read + * the buffered coefficients. + */ +#ifdef ENTROPY_OPT_SUPPORTED +#define FULL_COEF_BUFFER_SUPPORTED +#else +#ifdef C_MULTISCAN_FILES_SUPPORTED +#define FULL_COEF_BUFFER_SUPPORTED +#endif +#endif + + +/* Private buffer controller object */ + +typedef struct { + struct jpeg_c_coef_controller pub; /* public fields */ + + JDIMENSION iMCU_row_num; /* iMCU row # within image */ + JDIMENSION mcu_ctr; /* counts MCUs processed in current row */ + int MCU_vert_offset; /* counts MCU rows within iMCU row */ + int MCU_rows_per_iMCU_row; /* number of such rows needed */ + + /* For single-pass compression, it's sufficient to buffer just one MCU + * (although this may prove a bit slow in practice). We allocate a + * workspace of C_MAX_BLOCKS_IN_MCU coefficient blocks, and reuse it for each + * MCU constructed and sent. (On 80x86, the workspace is FAR even though + * it's not really very big; this is to keep the module interfaces unchanged + * when a large coefficient buffer is necessary.) + * In multi-pass modes, this array points to the current MCU's blocks + * within the virtual arrays. + */ + JBLOCKROW MCU_buffer[C_MAX_BLOCKS_IN_MCU]; + + /* In multi-pass modes, we need a virtual block array for each component. */ + jvirt_barray_ptr whole_image[MAX_COMPONENTS]; +} my_coef_controller; + +typedef my_coef_controller * my_coef_ptr; + + +/* Forward declarations */ +METHODDEF(boolean) compress_data + JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf)); +#ifdef FULL_COEF_BUFFER_SUPPORTED +METHODDEF(boolean) compress_first_pass + JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf)); +METHODDEF(boolean) compress_output + JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf)); +#endif + + +LOCAL(void) +start_iMCU_row (j_compress_ptr cinfo) +/* Reset within-iMCU-row counters for a new row */ +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + + /* In an interleaved scan, an MCU row is the same as an iMCU row. + * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. + * But at the bottom of the image, process only what's left. + */ + if (cinfo->comps_in_scan > 1) { + coef->MCU_rows_per_iMCU_row = 1; + } else { + if (coef->iMCU_row_num < (cinfo->total_iMCU_rows-1)) + coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; + else + coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; + } + + coef->mcu_ctr = 0; + coef->MCU_vert_offset = 0; +} + + +/* + * Initialize for a processing pass. + */ + +METHODDEF(void) +start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + + coef->iMCU_row_num = 0; + start_iMCU_row(cinfo); + + switch (pass_mode) { + case JBUF_PASS_THRU: + if (coef->whole_image[0] != NULL) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + coef->pub.compress_data = compress_data; + break; +#ifdef FULL_COEF_BUFFER_SUPPORTED + case JBUF_SAVE_AND_PASS: + if (coef->whole_image[0] == NULL) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + coef->pub.compress_data = compress_first_pass; + break; + case JBUF_CRANK_DEST: + if (coef->whole_image[0] == NULL) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + coef->pub.compress_data = compress_output; + break; +#endif + default: + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + break; + } +} + + +/* + * Process some data in the single-pass case. + * We process the equivalent of one fully interleaved MCU row ("iMCU" row) + * per call, ie, v_samp_factor block rows for each component in the image. + * Returns TRUE if the iMCU row is completed, FALSE if suspended. + * + * NB: input_buf contains a plane for each component in image. + * For single pass, this is the same as the components in the scan. + */ + +METHODDEF(boolean) +compress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + JDIMENSION MCU_col_num; /* index of current MCU within row */ + JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; + JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; + int blkn, bi, ci, yindex, yoffset, blockcnt; + JDIMENSION ypos, xpos; + jpeg_component_info *compptr; + + /* Loop to write as much as one whole iMCU row */ + for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; + yoffset++) { + for (MCU_col_num = coef->mcu_ctr; MCU_col_num <= last_MCU_col; + MCU_col_num++) { + /* Determine where data comes from in input_buf and do the DCT thing. + * Each call on forward_DCT processes a horizontal row of DCT blocks + * as wide as an MCU; we rely on having allocated the MCU_buffer[] blocks + * sequentially. Dummy blocks at the right or bottom edge are filled in + * specially. The data in them does not matter for image reconstruction, + * so we fill them with values that will encode to the smallest amount of + * data, viz: all zeroes in the AC entries, DC entries equal to previous + * block's DC value. (Thanks to Thomas Kinsman for this idea.) + */ + blkn = 0; + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width + : compptr->last_col_width; + xpos = MCU_col_num * compptr->MCU_sample_width; + ypos = yoffset * DCTSIZE; /* ypos == (yoffset+yindex) * DCTSIZE */ + for (yindex = 0; yindex < compptr->MCU_height; yindex++) { + if (coef->iMCU_row_num < last_iMCU_row || + yoffset+yindex < compptr->last_row_height) { + (*cinfo->fdct->forward_DCT) (cinfo, compptr, + input_buf[ci], coef->MCU_buffer[blkn], + ypos, xpos, (JDIMENSION) blockcnt); + if (blockcnt < compptr->MCU_width) { + /* Create some dummy blocks at the right edge of the image. */ + jzero_far((void FAR *) coef->MCU_buffer[blkn + blockcnt], + (compptr->MCU_width - blockcnt) * SIZEOF(JBLOCK)); + for (bi = blockcnt; bi < compptr->MCU_width; bi++) { + coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn+bi-1][0][0]; + } + } + } else { + /* Create a row of dummy blocks at the bottom of the image. */ + jzero_far((void FAR *) coef->MCU_buffer[blkn], + compptr->MCU_width * SIZEOF(JBLOCK)); + for (bi = 0; bi < compptr->MCU_width; bi++) { + coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn-1][0][0]; + } + } + blkn += compptr->MCU_width; + ypos += DCTSIZE; + } + } + /* Try to write the MCU. In event of a suspension failure, we will + * re-DCT the MCU on restart (a bit inefficient, could be fixed...) + */ + if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) { + /* Suspension forced; update state counters and exit */ + coef->MCU_vert_offset = yoffset; + coef->mcu_ctr = MCU_col_num; + return FALSE; + } + } + /* Completed an MCU row, but perhaps not an iMCU row */ + coef->mcu_ctr = 0; + } + /* Completed the iMCU row, advance counters for next one */ + coef->iMCU_row_num++; + start_iMCU_row(cinfo); + return TRUE; +} + + +#ifdef FULL_COEF_BUFFER_SUPPORTED + +/* + * Process some data in the first pass of a multi-pass case. + * We process the equivalent of one fully interleaved MCU row ("iMCU" row) + * per call, ie, v_samp_factor block rows for each component in the image. + * This amount of data is read from the source buffer, DCT'd and quantized, + * and saved into the virtual arrays. We also generate suitable dummy blocks + * as needed at the right and lower edges. (The dummy blocks are constructed + * in the virtual arrays, which have been padded appropriately.) This makes + * it possible for subsequent passes not to worry about real vs. dummy blocks. + * + * We must also emit the data to the entropy encoder. This is conveniently + * done by calling compress_output() after we've loaded the current strip + * of the virtual arrays. + * + * NB: input_buf contains a plane for each component in image. All + * components are DCT'd and loaded into the virtual arrays in this pass. + * However, it may be that only a subset of the components are emitted to + * the entropy encoder during this first pass; be careful about looking + * at the scan-dependent variables (MCU dimensions, etc). + */ + +METHODDEF(boolean) +compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; + JDIMENSION blocks_across, MCUs_across, MCUindex; + int bi, ci, h_samp_factor, block_row, block_rows, ndummy; + JCOEF lastDC; + jpeg_component_info *compptr; + JBLOCKARRAY buffer; + JBLOCKROW thisblockrow, lastblockrow; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Align the virtual buffer for this component. */ + buffer = (*cinfo->mem->access_virt_barray) + ((j_common_ptr) cinfo, coef->whole_image[ci], + coef->iMCU_row_num * compptr->v_samp_factor, + (JDIMENSION) compptr->v_samp_factor, TRUE); + /* Count non-dummy DCT block rows in this iMCU row. */ + if (coef->iMCU_row_num < last_iMCU_row) + block_rows = compptr->v_samp_factor; + else { + /* NB: can't use last_row_height here, since may not be set! */ + block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor); + if (block_rows == 0) block_rows = compptr->v_samp_factor; + } + blocks_across = compptr->width_in_blocks; + h_samp_factor = compptr->h_samp_factor; + /* Count number of dummy blocks to be added at the right margin. */ + ndummy = (int) (blocks_across % h_samp_factor); + if (ndummy > 0) + ndummy = h_samp_factor - ndummy; + /* Perform DCT for all non-dummy blocks in this iMCU row. Each call + * on forward_DCT processes a complete horizontal row of DCT blocks. + */ + for (block_row = 0; block_row < block_rows; block_row++) { + thisblockrow = buffer[block_row]; + (*cinfo->fdct->forward_DCT) (cinfo, compptr, + input_buf[ci], thisblockrow, + (JDIMENSION) (block_row * DCTSIZE), + (JDIMENSION) 0, blocks_across); + if (ndummy > 0) { + /* Create dummy blocks at the right edge of the image. */ + thisblockrow += blocks_across; /* => first dummy block */ + jzero_far((void FAR *) thisblockrow, ndummy * SIZEOF(JBLOCK)); + lastDC = thisblockrow[-1][0]; + for (bi = 0; bi < ndummy; bi++) { + thisblockrow[bi][0] = lastDC; + } + } + } + /* If at end of image, create dummy block rows as needed. + * The tricky part here is that within each MCU, we want the DC values + * of the dummy blocks to match the last real block's DC value. + * This squeezes a few more bytes out of the resulting file... + */ + if (coef->iMCU_row_num == last_iMCU_row) { + blocks_across += ndummy; /* include lower right corner */ + MCUs_across = blocks_across / h_samp_factor; + for (block_row = block_rows; block_row < compptr->v_samp_factor; + block_row++) { + thisblockrow = buffer[block_row]; + lastblockrow = buffer[block_row-1]; + jzero_far((void FAR *) thisblockrow, + (size_t) (blocks_across * SIZEOF(JBLOCK))); + for (MCUindex = 0; MCUindex < MCUs_across; MCUindex++) { + lastDC = lastblockrow[h_samp_factor-1][0]; + for (bi = 0; bi < h_samp_factor; bi++) { + thisblockrow[bi][0] = lastDC; + } + thisblockrow += h_samp_factor; /* advance to next MCU in row */ + lastblockrow += h_samp_factor; + } + } + } + } + /* NB: compress_output will increment iMCU_row_num if successful. + * A suspension return will result in redoing all the work above next time. + */ + + /* Emit data to the entropy encoder, sharing code with subsequent passes */ + return compress_output(cinfo, input_buf); +} + + +/* + * Process some data in subsequent passes of a multi-pass case. + * We process the equivalent of one fully interleaved MCU row ("iMCU" row) + * per call, ie, v_samp_factor block rows for each component in the scan. + * The data is obtained from the virtual arrays and fed to the entropy coder. + * Returns TRUE if the iMCU row is completed, FALSE if suspended. + * + * NB: input_buf is ignored; it is likely to be a NULL pointer. + */ + +METHODDEF(boolean) +compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + JDIMENSION MCU_col_num; /* index of current MCU within row */ + int blkn, ci, xindex, yindex, yoffset; + JDIMENSION start_col; + JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; + JBLOCKROW buffer_ptr; + jpeg_component_info *compptr; + + /* Align the virtual buffers for the components used in this scan. + * NB: during first pass, this is safe only because the buffers will + * already be aligned properly, so jmemmgr.c won't need to do any I/O. + */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + buffer[ci] = (*cinfo->mem->access_virt_barray) + ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index], + coef->iMCU_row_num * compptr->v_samp_factor, + (JDIMENSION) compptr->v_samp_factor, FALSE); + } + + /* Loop to process one whole iMCU row */ + for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; + yoffset++) { + for (MCU_col_num = coef->mcu_ctr; MCU_col_num < cinfo->MCUs_per_row; + MCU_col_num++) { + /* Construct list of pointers to DCT blocks belonging to this MCU */ + blkn = 0; /* index of current DCT block within MCU */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + start_col = MCU_col_num * compptr->MCU_width; + for (yindex = 0; yindex < compptr->MCU_height; yindex++) { + buffer_ptr = buffer[ci][yindex+yoffset] + start_col; + for (xindex = 0; xindex < compptr->MCU_width; xindex++) { + coef->MCU_buffer[blkn++] = buffer_ptr++; + } + } + } + /* Try to write the MCU. */ + if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) { + /* Suspension forced; update state counters and exit */ + coef->MCU_vert_offset = yoffset; + coef->mcu_ctr = MCU_col_num; + return FALSE; + } + } + /* Completed an MCU row, but perhaps not an iMCU row */ + coef->mcu_ctr = 0; + } + /* Completed the iMCU row, advance counters for next one */ + coef->iMCU_row_num++; + start_iMCU_row(cinfo); + return TRUE; +} + +#endif /* FULL_COEF_BUFFER_SUPPORTED */ + + +/* + * Initialize coefficient buffer controller. + */ + +GLOBAL(void) +jinit_c_coef_controller (j_compress_ptr cinfo, boolean need_full_buffer) +{ + my_coef_ptr coef; + + coef = (my_coef_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_coef_controller)); + cinfo->coef = (struct jpeg_c_coef_controller *) coef; + coef->pub.start_pass = start_pass_coef; + + /* Create the coefficient buffer. */ + if (need_full_buffer) { +#ifdef FULL_COEF_BUFFER_SUPPORTED + /* Allocate a full-image virtual array for each component, */ + /* padded to a multiple of samp_factor DCT blocks in each direction. */ + int ci; + jpeg_component_info *compptr; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + coef->whole_image[ci] = (*cinfo->mem->request_virt_barray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, + (JDIMENSION) jround_up((long) compptr->width_in_blocks, + (long) compptr->h_samp_factor), + (JDIMENSION) jround_up((long) compptr->height_in_blocks, + (long) compptr->v_samp_factor), + (JDIMENSION) compptr->v_samp_factor); + } +#else + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); +#endif + } else { + /* We only need a single-MCU buffer. */ + JBLOCKROW buffer; + int i; + + buffer = (JBLOCKROW) + (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, + C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); + for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) { + coef->MCU_buffer[i] = buffer + i; + } + coef->whole_image[0] = NULL; /* flag for no virtual arrays */ + } +} diff --git a/gs/jpeg/jccolor.c b/gs/jpeg/jccolor.c new file mode 100644 index 000000000..0a8a4b5d1 --- /dev/null +++ b/gs/jpeg/jccolor.c @@ -0,0 +1,459 @@ +/* + * jccolor.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains input colorspace conversion routines. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Private subobject */ + +typedef struct { + struct jpeg_color_converter pub; /* public fields */ + + /* Private state for RGB->YCC conversion */ + INT32 * rgb_ycc_tab; /* => table for RGB to YCbCr conversion */ +} my_color_converter; + +typedef my_color_converter * my_cconvert_ptr; + + +/**************** RGB -> YCbCr conversion: most common case **************/ + +/* + * YCbCr is defined per CCIR 601-1, except that Cb and Cr are + * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5. + * The conversion equations to be implemented are therefore + * Y = 0.29900 * R + 0.58700 * G + 0.11400 * B + * Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE + * Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE + * (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.) + * Note: older versions of the IJG code used a zero offset of MAXJSAMPLE/2, + * rather than CENTERJSAMPLE, for Cb and Cr. This gave equal positive and + * negative swings for Cb/Cr, but meant that grayscale values (Cb=Cr=0) + * were not represented exactly. Now we sacrifice exact representation of + * maximum red and maximum blue in order to get exact grayscales. + * + * To avoid floating-point arithmetic, we represent the fractional constants + * as integers scaled up by 2^16 (about 4 digits precision); we have to divide + * the products by 2^16, with appropriate rounding, to get the correct answer. + * + * For even more speed, we avoid doing any multiplications in the inner loop + * by precalculating the constants times R,G,B for all possible values. + * For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table); + * for 12-bit samples it is still acceptable. It's not very reasonable for + * 16-bit samples, but if you want lossless storage you shouldn't be changing + * colorspace anyway. + * The CENTERJSAMPLE offsets and the rounding fudge-factor of 0.5 are included + * in the tables to save adding them separately in the inner loop. + */ + +#define SCALEBITS 16 /* speediest right-shift on some machines */ +#define CBCR_OFFSET ((INT32) CENTERJSAMPLE << SCALEBITS) +#define ONE_HALF ((INT32) 1 << (SCALEBITS-1)) +#define FIX(x) ((INT32) ((x) * (1L< Y section */ +#define G_Y_OFF (1*(MAXJSAMPLE+1)) /* offset to G => Y section */ +#define B_Y_OFF (2*(MAXJSAMPLE+1)) /* etc. */ +#define R_CB_OFF (3*(MAXJSAMPLE+1)) +#define G_CB_OFF (4*(MAXJSAMPLE+1)) +#define B_CB_OFF (5*(MAXJSAMPLE+1)) +#define R_CR_OFF B_CB_OFF /* B=>Cb, R=>Cr are the same */ +#define G_CR_OFF (6*(MAXJSAMPLE+1)) +#define B_CR_OFF (7*(MAXJSAMPLE+1)) +#define TABLE_SIZE (8*(MAXJSAMPLE+1)) + + +/* + * Initialize for RGB->YCC colorspace conversion. + */ + +METHODDEF(void) +rgb_ycc_start (j_compress_ptr cinfo) +{ + my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; + INT32 * rgb_ycc_tab; + INT32 i; + + /* Allocate and fill in the conversion tables. */ + cconvert->rgb_ycc_tab = rgb_ycc_tab = (INT32 *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (TABLE_SIZE * SIZEOF(INT32))); + + for (i = 0; i <= MAXJSAMPLE; i++) { + rgb_ycc_tab[i+R_Y_OFF] = FIX(0.29900) * i; + rgb_ycc_tab[i+G_Y_OFF] = FIX(0.58700) * i; + rgb_ycc_tab[i+B_Y_OFF] = FIX(0.11400) * i + ONE_HALF; + rgb_ycc_tab[i+R_CB_OFF] = (-FIX(0.16874)) * i; + rgb_ycc_tab[i+G_CB_OFF] = (-FIX(0.33126)) * i; + /* We use a rounding fudge-factor of 0.5-epsilon for Cb and Cr. + * This ensures that the maximum output will round to MAXJSAMPLE + * not MAXJSAMPLE+1, and thus that we don't have to range-limit. + */ + rgb_ycc_tab[i+B_CB_OFF] = FIX(0.50000) * i + CBCR_OFFSET + ONE_HALF-1; +/* B=>Cb and R=>Cr tables are the same + rgb_ycc_tab[i+R_CR_OFF] = FIX(0.50000) * i + CBCR_OFFSET + ONE_HALF-1; +*/ + rgb_ycc_tab[i+G_CR_OFF] = (-FIX(0.41869)) * i; + rgb_ycc_tab[i+B_CR_OFF] = (-FIX(0.08131)) * i; + } +} + + +/* + * Convert some rows of samples to the JPEG colorspace. + * + * Note that we change from the application's interleaved-pixel format + * to our internal noninterleaved, one-plane-per-component format. + * The input buffer is therefore three times as wide as the output buffer. + * + * A starting row offset is provided only for the output buffer. The caller + * can easily adjust the passed input_buf value to accommodate any row + * offset required on that side. + */ + +METHODDEF(void) +rgb_ycc_convert (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPIMAGE output_buf, + JDIMENSION output_row, int num_rows) +{ + my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; + register int r, g, b; + register INT32 * ctab = cconvert->rgb_ycc_tab; + register JSAMPROW inptr; + register JSAMPROW outptr0, outptr1, outptr2; + register JDIMENSION col; + JDIMENSION num_cols = cinfo->image_width; + + while (--num_rows >= 0) { + inptr = *input_buf++; + outptr0 = output_buf[0][output_row]; + outptr1 = output_buf[1][output_row]; + outptr2 = output_buf[2][output_row]; + output_row++; + for (col = 0; col < num_cols; col++) { + r = GETJSAMPLE(inptr[RGB_RED]); + g = GETJSAMPLE(inptr[RGB_GREEN]); + b = GETJSAMPLE(inptr[RGB_BLUE]); + inptr += RGB_PIXELSIZE; + /* If the inputs are 0..MAXJSAMPLE, the outputs of these equations + * must be too; we do not need an explicit range-limiting operation. + * Hence the value being shifted is never negative, and we don't + * need the general RIGHT_SHIFT macro. + */ + /* Y */ + outptr0[col] = (JSAMPLE) + ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) + >> SCALEBITS); + /* Cb */ + outptr1[col] = (JSAMPLE) + ((ctab[r+R_CB_OFF] + ctab[g+G_CB_OFF] + ctab[b+B_CB_OFF]) + >> SCALEBITS); + /* Cr */ + outptr2[col] = (JSAMPLE) + ((ctab[r+R_CR_OFF] + ctab[g+G_CR_OFF] + ctab[b+B_CR_OFF]) + >> SCALEBITS); + } + } +} + + +/**************** Cases other than RGB -> YCbCr **************/ + + +/* + * Convert some rows of samples to the JPEG colorspace. + * This version handles RGB->grayscale conversion, which is the same + * as the RGB->Y portion of RGB->YCbCr. + * We assume rgb_ycc_start has been called (we only use the Y tables). + */ + +METHODDEF(void) +rgb_gray_convert (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPIMAGE output_buf, + JDIMENSION output_row, int num_rows) +{ + my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; + register int r, g, b; + register INT32 * ctab = cconvert->rgb_ycc_tab; + register JSAMPROW inptr; + register JSAMPROW outptr; + register JDIMENSION col; + JDIMENSION num_cols = cinfo->image_width; + + while (--num_rows >= 0) { + inptr = *input_buf++; + outptr = output_buf[0][output_row]; + output_row++; + for (col = 0; col < num_cols; col++) { + r = GETJSAMPLE(inptr[RGB_RED]); + g = GETJSAMPLE(inptr[RGB_GREEN]); + b = GETJSAMPLE(inptr[RGB_BLUE]); + inptr += RGB_PIXELSIZE; + /* Y */ + outptr[col] = (JSAMPLE) + ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) + >> SCALEBITS); + } + } +} + + +/* + * Convert some rows of samples to the JPEG colorspace. + * This version handles Adobe-style CMYK->YCCK conversion, + * where we convert R=1-C, G=1-M, and B=1-Y to YCbCr using the same + * conversion as above, while passing K (black) unchanged. + * We assume rgb_ycc_start has been called. + */ + +METHODDEF(void) +cmyk_ycck_convert (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPIMAGE output_buf, + JDIMENSION output_row, int num_rows) +{ + my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; + register int r, g, b; + register INT32 * ctab = cconvert->rgb_ycc_tab; + register JSAMPROW inptr; + register JSAMPROW outptr0, outptr1, outptr2, outptr3; + register JDIMENSION col; + JDIMENSION num_cols = cinfo->image_width; + + while (--num_rows >= 0) { + inptr = *input_buf++; + outptr0 = output_buf[0][output_row]; + outptr1 = output_buf[1][output_row]; + outptr2 = output_buf[2][output_row]; + outptr3 = output_buf[3][output_row]; + output_row++; + for (col = 0; col < num_cols; col++) { + r = MAXJSAMPLE - GETJSAMPLE(inptr[0]); + g = MAXJSAMPLE - GETJSAMPLE(inptr[1]); + b = MAXJSAMPLE - GETJSAMPLE(inptr[2]); + /* K passes through as-is */ + outptr3[col] = inptr[3]; /* don't need GETJSAMPLE here */ + inptr += 4; + /* If the inputs are 0..MAXJSAMPLE, the outputs of these equations + * must be too; we do not need an explicit range-limiting operation. + * Hence the value being shifted is never negative, and we don't + * need the general RIGHT_SHIFT macro. + */ + /* Y */ + outptr0[col] = (JSAMPLE) + ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) + >> SCALEBITS); + /* Cb */ + outptr1[col] = (JSAMPLE) + ((ctab[r+R_CB_OFF] + ctab[g+G_CB_OFF] + ctab[b+B_CB_OFF]) + >> SCALEBITS); + /* Cr */ + outptr2[col] = (JSAMPLE) + ((ctab[r+R_CR_OFF] + ctab[g+G_CR_OFF] + ctab[b+B_CR_OFF]) + >> SCALEBITS); + } + } +} + + +/* + * Convert some rows of samples to the JPEG colorspace. + * This version handles grayscale output with no conversion. + * The source can be either plain grayscale or YCbCr (since Y == gray). + */ + +METHODDEF(void) +grayscale_convert (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPIMAGE output_buf, + JDIMENSION output_row, int num_rows) +{ + register JSAMPROW inptr; + register JSAMPROW outptr; + register JDIMENSION col; + JDIMENSION num_cols = cinfo->image_width; + int instride = cinfo->input_components; + + while (--num_rows >= 0) { + inptr = *input_buf++; + outptr = output_buf[0][output_row]; + output_row++; + for (col = 0; col < num_cols; col++) { + outptr[col] = inptr[0]; /* don't need GETJSAMPLE() here */ + inptr += instride; + } + } +} + + +/* + * Convert some rows of samples to the JPEG colorspace. + * This version handles multi-component colorspaces without conversion. + * We assume input_components == num_components. + */ + +METHODDEF(void) +null_convert (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPIMAGE output_buf, + JDIMENSION output_row, int num_rows) +{ + register JSAMPROW inptr; + register JSAMPROW outptr; + register JDIMENSION col; + register int ci; + int nc = cinfo->num_components; + JDIMENSION num_cols = cinfo->image_width; + + while (--num_rows >= 0) { + /* It seems fastest to make a separate pass for each component. */ + for (ci = 0; ci < nc; ci++) { + inptr = *input_buf; + outptr = output_buf[ci][output_row]; + for (col = 0; col < num_cols; col++) { + outptr[col] = inptr[ci]; /* don't need GETJSAMPLE() here */ + inptr += nc; + } + } + input_buf++; + output_row++; + } +} + + +/* + * Empty method for start_pass. + */ + +METHODDEF(void) +null_method (j_compress_ptr cinfo) +{ + /* no work needed */ +} + + +/* + * Module initialization routine for input colorspace conversion. + */ + +GLOBAL(void) +jinit_color_converter (j_compress_ptr cinfo) +{ + my_cconvert_ptr cconvert; + + cconvert = (my_cconvert_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_color_converter)); + cinfo->cconvert = (struct jpeg_color_converter *) cconvert; + /* set start_pass to null method until we find out differently */ + cconvert->pub.start_pass = null_method; + + /* Make sure input_components agrees with in_color_space */ + switch (cinfo->in_color_space) { + case JCS_GRAYSCALE: + if (cinfo->input_components != 1) + ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); + break; + + case JCS_RGB: +#if RGB_PIXELSIZE != 3 + if (cinfo->input_components != RGB_PIXELSIZE) + ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); + break; +#endif /* else share code with YCbCr */ + + case JCS_YCbCr: + if (cinfo->input_components != 3) + ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); + break; + + case JCS_CMYK: + case JCS_YCCK: + if (cinfo->input_components != 4) + ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); + break; + + default: /* JCS_UNKNOWN can be anything */ + if (cinfo->input_components < 1) + ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); + break; + } + + /* Check num_components, set conversion method based on requested space */ + switch (cinfo->jpeg_color_space) { + case JCS_GRAYSCALE: + if (cinfo->num_components != 1) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + if (cinfo->in_color_space == JCS_GRAYSCALE) + cconvert->pub.color_convert = grayscale_convert; + else if (cinfo->in_color_space == JCS_RGB) { + cconvert->pub.start_pass = rgb_ycc_start; + cconvert->pub.color_convert = rgb_gray_convert; + } else if (cinfo->in_color_space == JCS_YCbCr) + cconvert->pub.color_convert = grayscale_convert; + else + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + break; + + case JCS_RGB: + if (cinfo->num_components != 3) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + if (cinfo->in_color_space == JCS_RGB && RGB_PIXELSIZE == 3) + cconvert->pub.color_convert = null_convert; + else + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + break; + + case JCS_YCbCr: + if (cinfo->num_components != 3) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + if (cinfo->in_color_space == JCS_RGB) { + cconvert->pub.start_pass = rgb_ycc_start; + cconvert->pub.color_convert = rgb_ycc_convert; + } else if (cinfo->in_color_space == JCS_YCbCr) + cconvert->pub.color_convert = null_convert; + else + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + break; + + case JCS_CMYK: + if (cinfo->num_components != 4) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + if (cinfo->in_color_space == JCS_CMYK) + cconvert->pub.color_convert = null_convert; + else + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + break; + + case JCS_YCCK: + if (cinfo->num_components != 4) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + if (cinfo->in_color_space == JCS_CMYK) { + cconvert->pub.start_pass = rgb_ycc_start; + cconvert->pub.color_convert = cmyk_ycck_convert; + } else if (cinfo->in_color_space == JCS_YCCK) + cconvert->pub.color_convert = null_convert; + else + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + break; + + default: /* allow null conversion of JCS_UNKNOWN */ + if (cinfo->jpeg_color_space != cinfo->in_color_space || + cinfo->num_components != cinfo->input_components) + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + cconvert->pub.color_convert = null_convert; + break; + } +} diff --git a/gs/jpeg/jcdctmgr.c b/gs/jpeg/jcdctmgr.c new file mode 100644 index 000000000..61fa79b9e --- /dev/null +++ b/gs/jpeg/jcdctmgr.c @@ -0,0 +1,387 @@ +/* + * jcdctmgr.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the forward-DCT management logic. + * This code selects a particular DCT implementation to be used, + * and it performs related housekeeping chores including coefficient + * quantization. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdct.h" /* Private declarations for DCT subsystem */ + + +/* Private subobject for this module */ + +typedef struct { + struct jpeg_forward_dct pub; /* public fields */ + + /* Pointer to the DCT routine actually in use */ + forward_DCT_method_ptr do_dct; + + /* The actual post-DCT divisors --- not identical to the quant table + * entries, because of scaling (especially for an unnormalized DCT). + * Each table is given in normal array order. + */ + DCTELEM * divisors[NUM_QUANT_TBLS]; + +#ifdef DCT_FLOAT_SUPPORTED + /* Same as above for the floating-point case. */ + float_DCT_method_ptr do_float_dct; + FAST_FLOAT * float_divisors[NUM_QUANT_TBLS]; +#endif +} my_fdct_controller; + +typedef my_fdct_controller * my_fdct_ptr; + + +/* + * Initialize for a processing pass. + * Verify that all referenced Q-tables are present, and set up + * the divisor table for each one. + * In the current implementation, DCT of all components is done during + * the first pass, even if only some components will be output in the + * first scan. Hence all components should be examined here. + */ + +METHODDEF(void) +start_pass_fdctmgr (j_compress_ptr cinfo) +{ + my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct; + int ci, qtblno, i; + jpeg_component_info *compptr; + JQUANT_TBL * qtbl; + DCTELEM * dtbl; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + qtblno = compptr->quant_tbl_no; + /* Make sure specified quantization table is present */ + if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS || + cinfo->quant_tbl_ptrs[qtblno] == NULL) + ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno); + qtbl = cinfo->quant_tbl_ptrs[qtblno]; + /* Compute divisors for this quant table */ + /* We may do this more than once for same table, but it's not a big deal */ + switch (cinfo->dct_method) { +#ifdef DCT_ISLOW_SUPPORTED + case JDCT_ISLOW: + /* For LL&M IDCT method, divisors are equal to raw quantization + * coefficients multiplied by 8 (to counteract scaling). + */ + if (fdct->divisors[qtblno] == NULL) { + fdct->divisors[qtblno] = (DCTELEM *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + DCTSIZE2 * SIZEOF(DCTELEM)); + } + dtbl = fdct->divisors[qtblno]; + for (i = 0; i < DCTSIZE2; i++) { + dtbl[i] = ((DCTELEM) qtbl->quantval[i]) << 3; + } + break; +#endif +#ifdef DCT_IFAST_SUPPORTED + case JDCT_IFAST: + { + /* For AA&N IDCT method, divisors are equal to quantization + * coefficients scaled by scalefactor[row]*scalefactor[col], where + * scalefactor[0] = 1 + * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 + * We apply a further scale factor of 8. + */ +#define CONST_BITS 14 + static const INT16 aanscales[DCTSIZE2] = { + /* precomputed values scaled up by 14 bits */ + 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, + 22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270, + 21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906, + 19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315, + 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, + 12873, 17855, 16819, 15137, 12873, 10114, 6967, 3552, + 8867, 12299, 11585, 10426, 8867, 6967, 4799, 2446, + 4520, 6270, 5906, 5315, 4520, 3552, 2446, 1247 + }; + SHIFT_TEMPS + + if (fdct->divisors[qtblno] == NULL) { + fdct->divisors[qtblno] = (DCTELEM *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + DCTSIZE2 * SIZEOF(DCTELEM)); + } + dtbl = fdct->divisors[qtblno]; + for (i = 0; i < DCTSIZE2; i++) { + dtbl[i] = (DCTELEM) + DESCALE(MULTIPLY16V16((INT32) qtbl->quantval[i], + (INT32) aanscales[i]), + CONST_BITS-3); + } + } + break; +#endif +#ifdef DCT_FLOAT_SUPPORTED + case JDCT_FLOAT: + { + /* For float AA&N IDCT method, divisors are equal to quantization + * coefficients scaled by scalefactor[row]*scalefactor[col], where + * scalefactor[0] = 1 + * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 + * We apply a further scale factor of 8. + * What's actually stored is 1/divisor so that the inner loop can + * use a multiplication rather than a division. + */ + FAST_FLOAT * fdtbl; + int row, col; + static const double aanscalefactor[DCTSIZE] = { + 1.0, 1.387039845, 1.306562965, 1.175875602, + 1.0, 0.785694958, 0.541196100, 0.275899379 + }; + + if (fdct->float_divisors[qtblno] == NULL) { + fdct->float_divisors[qtblno] = (FAST_FLOAT *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + DCTSIZE2 * SIZEOF(FAST_FLOAT)); + } + fdtbl = fdct->float_divisors[qtblno]; + i = 0; + for (row = 0; row < DCTSIZE; row++) { + for (col = 0; col < DCTSIZE; col++) { + fdtbl[i] = (FAST_FLOAT) + (1.0 / (((double) qtbl->quantval[i] * + aanscalefactor[row] * aanscalefactor[col] * 8.0))); + i++; + } + } + } + break; +#endif + default: + ERREXIT(cinfo, JERR_NOT_COMPILED); + break; + } + } +} + + +/* + * Perform forward DCT on one or more blocks of a component. + * + * The input samples are taken from the sample_data[] array starting at + * position start_row/start_col, and moving to the right for any additional + * blocks. The quantized coefficients are returned in coef_blocks[]. + */ + +METHODDEF(void) +forward_DCT (j_compress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY sample_data, JBLOCKROW coef_blocks, + JDIMENSION start_row, JDIMENSION start_col, + JDIMENSION num_blocks) +/* This version is used for integer DCT implementations. */ +{ + /* This routine is heavily used, so it's worth coding it tightly. */ + my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct; + forward_DCT_method_ptr do_dct = fdct->do_dct; + DCTELEM * divisors = fdct->divisors[compptr->quant_tbl_no]; + DCTELEM workspace[DCTSIZE2]; /* work area for FDCT subroutine */ + JDIMENSION bi; + + sample_data += start_row; /* fold in the vertical offset once */ + + for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) { + /* Load data into workspace, applying unsigned->signed conversion */ + { register DCTELEM *workspaceptr; + register JSAMPROW elemptr; + register int elemr; + + workspaceptr = workspace; + for (elemr = 0; elemr < DCTSIZE; elemr++) { + elemptr = sample_data[elemr] + start_col; +#if DCTSIZE == 8 /* unroll the inner loop */ + *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; + *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; + *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; + *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; + *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; + *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; + *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; + *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; +#else + { register int elemc; + for (elemc = DCTSIZE; elemc > 0; elemc--) { + *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; + } + } +#endif + } + } + + /* Perform the DCT */ + (*do_dct) (workspace); + + /* Quantize/descale the coefficients, and store into coef_blocks[] */ + { register DCTELEM temp, qval; + register int i; + register JCOEFPTR output_ptr = coef_blocks[bi]; + + for (i = 0; i < DCTSIZE2; i++) { + qval = divisors[i]; + temp = workspace[i]; + /* Divide the coefficient value by qval, ensuring proper rounding. + * Since C does not specify the direction of rounding for negative + * quotients, we have to force the dividend positive for portability. + * + * In most files, at least half of the output values will be zero + * (at default quantization settings, more like three-quarters...) + * so we should ensure that this case is fast. On many machines, + * a comparison is enough cheaper than a divide to make a special test + * a win. Since both inputs will be nonnegative, we need only test + * for a < b to discover whether a/b is 0. + * If your machine's division is fast enough, define FAST_DIVIDE. + */ +#ifdef FAST_DIVIDE +#define DIVIDE_BY(a,b) a /= b +#else +#define DIVIDE_BY(a,b) if (a >= b) a /= b; else a = 0 +#endif + if (temp < 0) { + temp = -temp; + temp += qval>>1; /* for rounding */ + DIVIDE_BY(temp, qval); + temp = -temp; + } else { + temp += qval>>1; /* for rounding */ + DIVIDE_BY(temp, qval); + } + output_ptr[i] = (JCOEF) temp; + } + } + } +} + + +#ifdef DCT_FLOAT_SUPPORTED + +METHODDEF(void) +forward_DCT_float (j_compress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY sample_data, JBLOCKROW coef_blocks, + JDIMENSION start_row, JDIMENSION start_col, + JDIMENSION num_blocks) +/* This version is used for floating-point DCT implementations. */ +{ + /* This routine is heavily used, so it's worth coding it tightly. */ + my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct; + float_DCT_method_ptr do_dct = fdct->do_float_dct; + FAST_FLOAT * divisors = fdct->float_divisors[compptr->quant_tbl_no]; + FAST_FLOAT workspace[DCTSIZE2]; /* work area for FDCT subroutine */ + JDIMENSION bi; + + sample_data += start_row; /* fold in the vertical offset once */ + + for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) { + /* Load data into workspace, applying unsigned->signed conversion */ + { register FAST_FLOAT *workspaceptr; + register JSAMPROW elemptr; + register int elemr; + + workspaceptr = workspace; + for (elemr = 0; elemr < DCTSIZE; elemr++) { + elemptr = sample_data[elemr] + start_col; +#if DCTSIZE == 8 /* unroll the inner loop */ + *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); + *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); + *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); + *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); + *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); + *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); + *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); + *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); +#else + { register int elemc; + for (elemc = DCTSIZE; elemc > 0; elemc--) { + *workspaceptr++ = (FAST_FLOAT) + (GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); + } + } +#endif + } + } + + /* Perform the DCT */ + (*do_dct) (workspace); + + /* Quantize/descale the coefficients, and store into coef_blocks[] */ + { register FAST_FLOAT temp; + register int i; + register JCOEFPTR output_ptr = coef_blocks[bi]; + + for (i = 0; i < DCTSIZE2; i++) { + /* Apply the quantization and scaling factor */ + temp = workspace[i] * divisors[i]; + /* Round to nearest integer. + * Since C does not specify the direction of rounding for negative + * quotients, we have to force the dividend positive for portability. + * The maximum coefficient size is +-16K (for 12-bit data), so this + * code should work for either 16-bit or 32-bit ints. + */ + output_ptr[i] = (JCOEF) ((int) (temp + (FAST_FLOAT) 16384.5) - 16384); + } + } + } +} + +#endif /* DCT_FLOAT_SUPPORTED */ + + +/* + * Initialize FDCT manager. + */ + +GLOBAL(void) +jinit_forward_dct (j_compress_ptr cinfo) +{ + my_fdct_ptr fdct; + int i; + + fdct = (my_fdct_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_fdct_controller)); + cinfo->fdct = (struct jpeg_forward_dct *) fdct; + fdct->pub.start_pass = start_pass_fdctmgr; + + switch (cinfo->dct_method) { +#ifdef DCT_ISLOW_SUPPORTED + case JDCT_ISLOW: + fdct->pub.forward_DCT = forward_DCT; + fdct->do_dct = jpeg_fdct_islow; + break; +#endif +#ifdef DCT_IFAST_SUPPORTED + case JDCT_IFAST: + fdct->pub.forward_DCT = forward_DCT; + fdct->do_dct = jpeg_fdct_ifast; + break; +#endif +#ifdef DCT_FLOAT_SUPPORTED + case JDCT_FLOAT: + fdct->pub.forward_DCT = forward_DCT_float; + fdct->do_float_dct = jpeg_fdct_float; + break; +#endif + default: + ERREXIT(cinfo, JERR_NOT_COMPILED); + break; + } + + /* Mark divisor tables unallocated */ + for (i = 0; i < NUM_QUANT_TBLS; i++) { + fdct->divisors[i] = NULL; +#ifdef DCT_FLOAT_SUPPORTED + fdct->float_divisors[i] = NULL; +#endif + } +} diff --git a/gs/jpeg/jchuff.c b/gs/jpeg/jchuff.c new file mode 100644 index 000000000..b3eec8ada --- /dev/null +++ b/gs/jpeg/jchuff.c @@ -0,0 +1,846 @@ +/* + * jchuff.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains Huffman entropy encoding routines. + * + * Much of the complexity here has to do with supporting output suspension. + * If the data destination module demands suspension, we want to be able to + * back up to the start of the current MCU. To do this, we copy state + * variables into local working storage, and update them back to the + * permanent JPEG objects only upon successful completion of an MCU. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jchuff.h" /* Declarations shared with jcphuff.c */ + + +/* Expanded entropy encoder object for Huffman encoding. + * + * The savable_state subrecord contains fields that change within an MCU, + * but must not be updated permanently until we complete the MCU. + */ + +typedef struct { + INT32 put_buffer; /* current bit-accumulation buffer */ + int put_bits; /* # of bits now in it */ + int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ +} savable_state; + +/* This macro is to work around compilers with missing or broken + * structure assignment. You'll need to fix this code if you have + * such a compiler and you change MAX_COMPS_IN_SCAN. + */ + +#ifndef NO_STRUCT_ASSIGN +#define ASSIGN_STATE(dest,src) ((dest) = (src)) +#else +#if MAX_COMPS_IN_SCAN == 4 +#define ASSIGN_STATE(dest,src) \ + ((dest).put_buffer = (src).put_buffer, \ + (dest).put_bits = (src).put_bits, \ + (dest).last_dc_val[0] = (src).last_dc_val[0], \ + (dest).last_dc_val[1] = (src).last_dc_val[1], \ + (dest).last_dc_val[2] = (src).last_dc_val[2], \ + (dest).last_dc_val[3] = (src).last_dc_val[3]) +#endif +#endif + + +typedef struct { + struct jpeg_entropy_encoder pub; /* public fields */ + + savable_state saved; /* Bit buffer & DC state at start of MCU */ + + /* These fields are NOT loaded into local working state. */ + unsigned int restarts_to_go; /* MCUs left in this restart interval */ + int next_restart_num; /* next restart number to write (0-7) */ + + /* Pointers to derived tables (these workspaces have image lifespan) */ + c_derived_tbl * dc_derived_tbls[NUM_HUFF_TBLS]; + c_derived_tbl * ac_derived_tbls[NUM_HUFF_TBLS]; + +#ifdef ENTROPY_OPT_SUPPORTED /* Statistics tables for optimization */ + long * dc_count_ptrs[NUM_HUFF_TBLS]; + long * ac_count_ptrs[NUM_HUFF_TBLS]; +#endif +} huff_entropy_encoder; + +typedef huff_entropy_encoder * huff_entropy_ptr; + +/* Working state while writing an MCU. + * This struct contains all the fields that are needed by subroutines. + */ + +typedef struct { + JOCTET * next_output_byte; /* => next byte to write in buffer */ + size_t free_in_buffer; /* # of byte spaces remaining in buffer */ + savable_state cur; /* Current bit buffer & DC state */ + j_compress_ptr cinfo; /* dump_buffer needs access to this */ +} working_state; + + +/* Forward declarations */ +METHODDEF(boolean) encode_mcu_huff JPP((j_compress_ptr cinfo, + JBLOCKROW *MCU_data)); +METHODDEF(void) finish_pass_huff JPP((j_compress_ptr cinfo)); +#ifdef ENTROPY_OPT_SUPPORTED +METHODDEF(boolean) encode_mcu_gather JPP((j_compress_ptr cinfo, + JBLOCKROW *MCU_data)); +METHODDEF(void) finish_pass_gather JPP((j_compress_ptr cinfo)); +#endif + + +/* + * Initialize for a Huffman-compressed scan. + * If gather_statistics is TRUE, we do not output anything during the scan, + * just count the Huffman symbols used and generate Huffman code tables. + */ + +METHODDEF(void) +start_pass_huff (j_compress_ptr cinfo, boolean gather_statistics) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + int ci, dctbl, actbl; + jpeg_component_info * compptr; + + if (gather_statistics) { +#ifdef ENTROPY_OPT_SUPPORTED + entropy->pub.encode_mcu = encode_mcu_gather; + entropy->pub.finish_pass = finish_pass_gather; +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } else { + entropy->pub.encode_mcu = encode_mcu_huff; + entropy->pub.finish_pass = finish_pass_huff; + } + + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + dctbl = compptr->dc_tbl_no; + actbl = compptr->ac_tbl_no; + /* Make sure requested tables are present */ + /* (In gather mode, tables need not be allocated yet) */ + if (dctbl < 0 || dctbl >= NUM_HUFF_TBLS || + (cinfo->dc_huff_tbl_ptrs[dctbl] == NULL && !gather_statistics)) + ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, dctbl); + if (actbl < 0 || actbl >= NUM_HUFF_TBLS || + (cinfo->ac_huff_tbl_ptrs[actbl] == NULL && !gather_statistics)) + ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, actbl); + if (gather_statistics) { +#ifdef ENTROPY_OPT_SUPPORTED + /* Allocate and zero the statistics tables */ + /* Note that jpeg_gen_optimal_table expects 257 entries in each table! */ + if (entropy->dc_count_ptrs[dctbl] == NULL) + entropy->dc_count_ptrs[dctbl] = (long *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + 257 * SIZEOF(long)); + MEMZERO(entropy->dc_count_ptrs[dctbl], 257 * SIZEOF(long)); + if (entropy->ac_count_ptrs[actbl] == NULL) + entropy->ac_count_ptrs[actbl] = (long *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + 257 * SIZEOF(long)); + MEMZERO(entropy->ac_count_ptrs[actbl], 257 * SIZEOF(long)); +#endif + } else { + /* Compute derived values for Huffman tables */ + /* We may do this more than once for a table, but it's not expensive */ + jpeg_make_c_derived_tbl(cinfo, cinfo->dc_huff_tbl_ptrs[dctbl], + & entropy->dc_derived_tbls[dctbl]); + jpeg_make_c_derived_tbl(cinfo, cinfo->ac_huff_tbl_ptrs[actbl], + & entropy->ac_derived_tbls[actbl]); + } + /* Initialize DC predictions to 0 */ + entropy->saved.last_dc_val[ci] = 0; + } + + /* Initialize bit buffer to empty */ + entropy->saved.put_buffer = 0; + entropy->saved.put_bits = 0; + + /* Initialize restart stuff */ + entropy->restarts_to_go = cinfo->restart_interval; + entropy->next_restart_num = 0; +} + + +/* + * Compute the derived values for a Huffman table. + * Note this is also used by jcphuff.c. + */ + +GLOBAL(void) +jpeg_make_c_derived_tbl (j_compress_ptr cinfo, JHUFF_TBL * htbl, + c_derived_tbl ** pdtbl) +{ + c_derived_tbl *dtbl; + int p, i, l, lastp, si; + char huffsize[257]; + unsigned int huffcode[257]; + unsigned int code; + + /* Allocate a workspace if we haven't already done so. */ + if (*pdtbl == NULL) + *pdtbl = (c_derived_tbl *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(c_derived_tbl)); + dtbl = *pdtbl; + + /* Figure C.1: make table of Huffman code length for each symbol */ + /* Note that this is in code-length order. */ + + p = 0; + for (l = 1; l <= 16; l++) { + for (i = 1; i <= (int) htbl->bits[l]; i++) + huffsize[p++] = (char) l; + } + huffsize[p] = 0; + lastp = p; + + /* Figure C.2: generate the codes themselves */ + /* Note that this is in code-length order. */ + + code = 0; + si = huffsize[0]; + p = 0; + while (huffsize[p]) { + while (((int) huffsize[p]) == si) { + huffcode[p++] = code; + code++; + } + code <<= 1; + si++; + } + + /* Figure C.3: generate encoding tables */ + /* These are code and size indexed by symbol value */ + + /* Set any codeless symbols to have code length 0; + * this allows emit_bits to detect any attempt to emit such symbols. + */ + MEMZERO(dtbl->ehufsi, SIZEOF(dtbl->ehufsi)); + + for (p = 0; p < lastp; p++) { + dtbl->ehufco[htbl->huffval[p]] = huffcode[p]; + dtbl->ehufsi[htbl->huffval[p]] = huffsize[p]; + } +} + + +/* Outputting bytes to the file */ + +/* Emit a byte, taking 'action' if must suspend. */ +#define emit_byte(state,val,action) \ + { *(state)->next_output_byte++ = (JOCTET) (val); \ + if (--(state)->free_in_buffer == 0) \ + if (! dump_buffer(state)) \ + { action; } } + + +LOCAL(boolean) +dump_buffer (working_state * state) +/* Empty the output buffer; return TRUE if successful, FALSE if must suspend */ +{ + struct jpeg_destination_mgr * dest = state->cinfo->dest; + + if (! (*dest->empty_output_buffer) (state->cinfo)) + return FALSE; + /* After a successful buffer dump, must reset buffer pointers */ + state->next_output_byte = dest->next_output_byte; + state->free_in_buffer = dest->free_in_buffer; + return TRUE; +} + + +/* Outputting bits to the file */ + +/* Only the right 24 bits of put_buffer are used; the valid bits are + * left-justified in this part. At most 16 bits can be passed to emit_bits + * in one call, and we never retain more than 7 bits in put_buffer + * between calls, so 24 bits are sufficient. + */ + +INLINE +LOCAL(boolean) +emit_bits (working_state * state, unsigned int code, int size) +/* Emit some bits; return TRUE if successful, FALSE if must suspend */ +{ + /* This routine is heavily used, so it's worth coding tightly. */ + register INT32 put_buffer = (INT32) code; + register int put_bits = state->cur.put_bits; + + /* if size is 0, caller used an invalid Huffman table entry */ + if (size == 0) + ERREXIT(state->cinfo, JERR_HUFF_MISSING_CODE); + + put_buffer &= (((INT32) 1)<cur.put_buffer; /* and merge with old buffer contents */ + + while (put_bits >= 8) { + int c = (int) ((put_buffer >> 16) & 0xFF); + + emit_byte(state, c, return FALSE); + if (c == 0xFF) { /* need to stuff a zero byte? */ + emit_byte(state, 0, return FALSE); + } + put_buffer <<= 8; + put_bits -= 8; + } + + state->cur.put_buffer = put_buffer; /* update state variables */ + state->cur.put_bits = put_bits; + + return TRUE; +} + + +LOCAL(boolean) +flush_bits (working_state * state) +{ + if (! emit_bits(state, 0x7F, 7)) /* fill any partial byte with ones */ + return FALSE; + state->cur.put_buffer = 0; /* and reset bit-buffer to empty */ + state->cur.put_bits = 0; + return TRUE; +} + + +/* Encode a single block's worth of coefficients */ + +LOCAL(boolean) +encode_one_block (working_state * state, JCOEFPTR block, int last_dc_val, + c_derived_tbl *dctbl, c_derived_tbl *actbl) +{ + register int temp, temp2; + register int nbits; + register int k, r, i; + + /* Encode the DC coefficient difference per section F.1.2.1 */ + + temp = temp2 = block[0] - last_dc_val; + + if (temp < 0) { + temp = -temp; /* temp is abs value of input */ + /* For a negative input, want temp2 = bitwise complement of abs(input) */ + /* This code assumes we are on a two's complement machine */ + temp2--; + } + + /* Find the number of bits needed for the magnitude of the coefficient */ + nbits = 0; + while (temp) { + nbits++; + temp >>= 1; + } + + /* Emit the Huffman-coded symbol for the number of bits */ + if (! emit_bits(state, dctbl->ehufco[nbits], dctbl->ehufsi[nbits])) + return FALSE; + + /* Emit that number of bits of the value, if positive, */ + /* or the complement of its magnitude, if negative. */ + if (nbits) /* emit_bits rejects calls with size 0 */ + if (! emit_bits(state, (unsigned int) temp2, nbits)) + return FALSE; + + /* Encode the AC coefficients per section F.1.2.2 */ + + r = 0; /* r = run length of zeros */ + + for (k = 1; k < DCTSIZE2; k++) { + if ((temp = block[jpeg_natural_order[k]]) == 0) { + r++; + } else { + /* if run length > 15, must emit special run-length-16 codes (0xF0) */ + while (r > 15) { + if (! emit_bits(state, actbl->ehufco[0xF0], actbl->ehufsi[0xF0])) + return FALSE; + r -= 16; + } + + temp2 = temp; + if (temp < 0) { + temp = -temp; /* temp is abs value of input */ + /* This code assumes we are on a two's complement machine */ + temp2--; + } + + /* Find the number of bits needed for the magnitude of the coefficient */ + nbits = 1; /* there must be at least one 1 bit */ + while ((temp >>= 1)) + nbits++; + + /* Emit Huffman symbol for run length / number of bits */ + i = (r << 4) + nbits; + if (! emit_bits(state, actbl->ehufco[i], actbl->ehufsi[i])) + return FALSE; + + /* Emit that number of bits of the value, if positive, */ + /* or the complement of its magnitude, if negative. */ + if (! emit_bits(state, (unsigned int) temp2, nbits)) + return FALSE; + + r = 0; + } + } + + /* If the last coef(s) were zero, emit an end-of-block code */ + if (r > 0) + if (! emit_bits(state, actbl->ehufco[0], actbl->ehufsi[0])) + return FALSE; + + return TRUE; +} + + +/* + * Emit a restart marker & resynchronize predictions. + */ + +LOCAL(boolean) +emit_restart (working_state * state, int restart_num) +{ + int ci; + + if (! flush_bits(state)) + return FALSE; + + emit_byte(state, 0xFF, return FALSE); + emit_byte(state, JPEG_RST0 + restart_num, return FALSE); + + /* Re-initialize DC predictions to 0 */ + for (ci = 0; ci < state->cinfo->comps_in_scan; ci++) + state->cur.last_dc_val[ci] = 0; + + /* The restart counter is not updated until we successfully write the MCU. */ + + return TRUE; +} + + +/* + * Encode and output one MCU's worth of Huffman-compressed coefficients. + */ + +METHODDEF(boolean) +encode_mcu_huff (j_compress_ptr cinfo, JBLOCKROW *MCU_data) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + working_state state; + int blkn, ci; + jpeg_component_info * compptr; + + /* Load up working state */ + state.next_output_byte = cinfo->dest->next_output_byte; + state.free_in_buffer = cinfo->dest->free_in_buffer; + ASSIGN_STATE(state.cur, entropy->saved); + state.cinfo = cinfo; + + /* Emit restart marker if needed */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) + if (! emit_restart(&state, entropy->next_restart_num)) + return FALSE; + } + + /* Encode the MCU data blocks */ + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + ci = cinfo->MCU_membership[blkn]; + compptr = cinfo->cur_comp_info[ci]; + if (! encode_one_block(&state, + MCU_data[blkn][0], state.cur.last_dc_val[ci], + entropy->dc_derived_tbls[compptr->dc_tbl_no], + entropy->ac_derived_tbls[compptr->ac_tbl_no])) + return FALSE; + /* Update last_dc_val */ + state.cur.last_dc_val[ci] = MCU_data[blkn][0][0]; + } + + /* Completed MCU, so update state */ + cinfo->dest->next_output_byte = state.next_output_byte; + cinfo->dest->free_in_buffer = state.free_in_buffer; + ASSIGN_STATE(entropy->saved, state.cur); + + /* Update restart-interval state too */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) { + entropy->restarts_to_go = cinfo->restart_interval; + entropy->next_restart_num++; + entropy->next_restart_num &= 7; + } + entropy->restarts_to_go--; + } + + return TRUE; +} + + +/* + * Finish up at the end of a Huffman-compressed scan. + */ + +METHODDEF(void) +finish_pass_huff (j_compress_ptr cinfo) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + working_state state; + + /* Load up working state ... flush_bits needs it */ + state.next_output_byte = cinfo->dest->next_output_byte; + state.free_in_buffer = cinfo->dest->free_in_buffer; + ASSIGN_STATE(state.cur, entropy->saved); + state.cinfo = cinfo; + + /* Flush out the last data */ + if (! flush_bits(&state)) + ERREXIT(cinfo, JERR_CANT_SUSPEND); + + /* Update state */ + cinfo->dest->next_output_byte = state.next_output_byte; + cinfo->dest->free_in_buffer = state.free_in_buffer; + ASSIGN_STATE(entropy->saved, state.cur); +} + + +/* + * Huffman coding optimization. + * + * This actually is optimization, in the sense that we find the best possible + * Huffman table(s) for the given data. We first scan the supplied data and + * count the number of uses of each symbol that is to be Huffman-coded. + * (This process must agree with the code above.) Then we build an + * optimal Huffman coding tree for the observed counts. + * + * The JPEG standard requires Huffman codes to be no more than 16 bits long. + * If some symbols have a very small but nonzero probability, the Huffman tree + * must be adjusted to meet the code length restriction. We currently use + * the adjustment method suggested in the JPEG spec. This method is *not* + * optimal; it may not choose the best possible limited-length code. But + * since the symbols involved are infrequently used, it's not clear that + * going to extra trouble is worthwhile. + */ + +#ifdef ENTROPY_OPT_SUPPORTED + + +/* Process a single block's worth of coefficients */ + +LOCAL(void) +htest_one_block (JCOEFPTR block, int last_dc_val, + long dc_counts[], long ac_counts[]) +{ + register int temp; + register int nbits; + register int k, r; + + /* Encode the DC coefficient difference per section F.1.2.1 */ + + temp = block[0] - last_dc_val; + if (temp < 0) + temp = -temp; + + /* Find the number of bits needed for the magnitude of the coefficient */ + nbits = 0; + while (temp) { + nbits++; + temp >>= 1; + } + + /* Count the Huffman symbol for the number of bits */ + dc_counts[nbits]++; + + /* Encode the AC coefficients per section F.1.2.2 */ + + r = 0; /* r = run length of zeros */ + + for (k = 1; k < DCTSIZE2; k++) { + if ((temp = block[jpeg_natural_order[k]]) == 0) { + r++; + } else { + /* if run length > 15, must emit special run-length-16 codes (0xF0) */ + while (r > 15) { + ac_counts[0xF0]++; + r -= 16; + } + + /* Find the number of bits needed for the magnitude of the coefficient */ + if (temp < 0) + temp = -temp; + + /* Find the number of bits needed for the magnitude of the coefficient */ + nbits = 1; /* there must be at least one 1 bit */ + while ((temp >>= 1)) + nbits++; + + /* Count Huffman symbol for run length / number of bits */ + ac_counts[(r << 4) + nbits]++; + + r = 0; + } + } + + /* If the last coef(s) were zero, emit an end-of-block code */ + if (r > 0) + ac_counts[0]++; +} + + +/* + * Trial-encode one MCU's worth of Huffman-compressed coefficients. + * No data is actually output, so no suspension return is possible. + */ + +METHODDEF(boolean) +encode_mcu_gather (j_compress_ptr cinfo, JBLOCKROW *MCU_data) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + int blkn, ci; + jpeg_component_info * compptr; + + /* Take care of restart intervals if needed */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) { + /* Re-initialize DC predictions to 0 */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) + entropy->saved.last_dc_val[ci] = 0; + /* Update restart state */ + entropy->restarts_to_go = cinfo->restart_interval; + } + entropy->restarts_to_go--; + } + + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + ci = cinfo->MCU_membership[blkn]; + compptr = cinfo->cur_comp_info[ci]; + htest_one_block(MCU_data[blkn][0], entropy->saved.last_dc_val[ci], + entropy->dc_count_ptrs[compptr->dc_tbl_no], + entropy->ac_count_ptrs[compptr->ac_tbl_no]); + entropy->saved.last_dc_val[ci] = MCU_data[blkn][0][0]; + } + + return TRUE; +} + + +/* + * Generate the optimal coding for the given counts, fill htbl. + * Note this is also used by jcphuff.c. + */ + +GLOBAL(void) +jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[]) +{ +#define MAX_CLEN 32 /* assumed maximum initial code length */ + UINT8 bits[MAX_CLEN+1]; /* bits[k] = # of symbols with code length k */ + int codesize[257]; /* codesize[k] = code length of symbol k */ + int others[257]; /* next symbol in current branch of tree */ + int c1, c2; + int p, i, j; + long v; + + /* This algorithm is explained in section K.2 of the JPEG standard */ + + MEMZERO(bits, SIZEOF(bits)); + MEMZERO(codesize, SIZEOF(codesize)); + for (i = 0; i < 257; i++) + others[i] = -1; /* init links to empty */ + + freq[256] = 1; /* make sure there is a nonzero count */ + /* Including the pseudo-symbol 256 in the Huffman procedure guarantees + * that no real symbol is given code-value of all ones, because 256 + * will be placed in the largest codeword category. + */ + + /* Huffman's basic algorithm to assign optimal code lengths to symbols */ + + for (;;) { + /* Find the smallest nonzero frequency, set c1 = its symbol */ + /* In case of ties, take the larger symbol number */ + c1 = -1; + v = 1000000000L; + for (i = 0; i <= 256; i++) { + if (freq[i] && freq[i] <= v) { + v = freq[i]; + c1 = i; + } + } + + /* Find the next smallest nonzero frequency, set c2 = its symbol */ + /* In case of ties, take the larger symbol number */ + c2 = -1; + v = 1000000000L; + for (i = 0; i <= 256; i++) { + if (freq[i] && freq[i] <= v && i != c1) { + v = freq[i]; + c2 = i; + } + } + + /* Done if we've merged everything into one frequency */ + if (c2 < 0) + break; + + /* Else merge the two counts/trees */ + freq[c1] += freq[c2]; + freq[c2] = 0; + + /* Increment the codesize of everything in c1's tree branch */ + codesize[c1]++; + while (others[c1] >= 0) { + c1 = others[c1]; + codesize[c1]++; + } + + others[c1] = c2; /* chain c2 onto c1's tree branch */ + + /* Increment the codesize of everything in c2's tree branch */ + codesize[c2]++; + while (others[c2] >= 0) { + c2 = others[c2]; + codesize[c2]++; + } + } + + /* Now count the number of symbols of each code length */ + for (i = 0; i <= 256; i++) { + if (codesize[i]) { + /* The JPEG standard seems to think that this can't happen, */ + /* but I'm paranoid... */ + if (codesize[i] > MAX_CLEN) + ERREXIT(cinfo, JERR_HUFF_CLEN_OVERFLOW); + + bits[codesize[i]]++; + } + } + + /* JPEG doesn't allow symbols with code lengths over 16 bits, so if the pure + * Huffman procedure assigned any such lengths, we must adjust the coding. + * Here is what the JPEG spec says about how this next bit works: + * Since symbols are paired for the longest Huffman code, the symbols are + * removed from this length category two at a time. The prefix for the pair + * (which is one bit shorter) is allocated to one of the pair; then, + * skipping the BITS entry for that prefix length, a code word from the next + * shortest nonzero BITS entry is converted into a prefix for two code words + * one bit longer. + */ + + for (i = MAX_CLEN; i > 16; i--) { + while (bits[i] > 0) { + j = i - 2; /* find length of new prefix to be used */ + while (bits[j] == 0) + j--; + + bits[i] -= 2; /* remove two symbols */ + bits[i-1]++; /* one goes in this length */ + bits[j+1] += 2; /* two new symbols in this length */ + bits[j]--; /* symbol of this length is now a prefix */ + } + } + + /* Remove the count for the pseudo-symbol 256 from the largest codelength */ + while (bits[i] == 0) /* find largest codelength still in use */ + i--; + bits[i]--; + + /* Return final symbol counts (only for lengths 0..16) */ + MEMCOPY(htbl->bits, bits, SIZEOF(htbl->bits)); + + /* Return a list of the symbols sorted by code length */ + /* It's not real clear to me why we don't need to consider the codelength + * changes made above, but the JPEG spec seems to think this works. + */ + p = 0; + for (i = 1; i <= MAX_CLEN; i++) { + for (j = 0; j <= 255; j++) { + if (codesize[j] == i) { + htbl->huffval[p] = (UINT8) j; + p++; + } + } + } + + /* Set sent_table FALSE so updated table will be written to JPEG file. */ + htbl->sent_table = FALSE; +} + + +/* + * Finish up a statistics-gathering pass and create the new Huffman tables. + */ + +METHODDEF(void) +finish_pass_gather (j_compress_ptr cinfo) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + int ci, dctbl, actbl; + jpeg_component_info * compptr; + JHUFF_TBL **htblptr; + boolean did_dc[NUM_HUFF_TBLS]; + boolean did_ac[NUM_HUFF_TBLS]; + + /* It's important not to apply jpeg_gen_optimal_table more than once + * per table, because it clobbers the input frequency counts! + */ + MEMZERO(did_dc, SIZEOF(did_dc)); + MEMZERO(did_ac, SIZEOF(did_ac)); + + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + dctbl = compptr->dc_tbl_no; + actbl = compptr->ac_tbl_no; + if (! did_dc[dctbl]) { + htblptr = & cinfo->dc_huff_tbl_ptrs[dctbl]; + if (*htblptr == NULL) + *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); + jpeg_gen_optimal_table(cinfo, *htblptr, entropy->dc_count_ptrs[dctbl]); + did_dc[dctbl] = TRUE; + } + if (! did_ac[actbl]) { + htblptr = & cinfo->ac_huff_tbl_ptrs[actbl]; + if (*htblptr == NULL) + *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); + jpeg_gen_optimal_table(cinfo, *htblptr, entropy->ac_count_ptrs[actbl]); + did_ac[actbl] = TRUE; + } + } +} + + +#endif /* ENTROPY_OPT_SUPPORTED */ + + +/* + * Module initialization routine for Huffman entropy encoding. + */ + +GLOBAL(void) +jinit_huff_encoder (j_compress_ptr cinfo) +{ + huff_entropy_ptr entropy; + int i; + + entropy = (huff_entropy_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(huff_entropy_encoder)); + cinfo->entropy = (struct jpeg_entropy_encoder *) entropy; + entropy->pub.start_pass = start_pass_huff; + + /* Mark tables unallocated */ + for (i = 0; i < NUM_HUFF_TBLS; i++) { + entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL; +#ifdef ENTROPY_OPT_SUPPORTED + entropy->dc_count_ptrs[i] = entropy->ac_count_ptrs[i] = NULL; +#endif + } +} diff --git a/gs/jpeg/jchuff.h b/gs/jpeg/jchuff.h new file mode 100644 index 000000000..fa4643a4e --- /dev/null +++ b/gs/jpeg/jchuff.h @@ -0,0 +1,34 @@ +/* + * jchuff.h + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains declarations for Huffman entropy encoding routines + * that are shared between the sequential encoder (jchuff.c) and the + * progressive encoder (jcphuff.c). No other modules need to see these. + */ + +/* Derived data constructed for each Huffman table */ + +typedef struct { + unsigned int ehufco[256]; /* code for each symbol */ + char ehufsi[256]; /* length of code for each symbol */ + /* If no code has been allocated for a symbol S, ehufsi[S] contains 0 */ +} c_derived_tbl; + +/* Short forms of external names for systems with brain-damaged linkers. */ + +#ifdef NEED_SHORT_EXTERNAL_NAMES +#define jpeg_make_c_derived_tbl jMkCDerived +#define jpeg_gen_optimal_table jGenOptTbl +#endif /* NEED_SHORT_EXTERNAL_NAMES */ + +/* Expand a Huffman table definition into the derived format */ +EXTERN(void) jpeg_make_c_derived_tbl + JPP((j_compress_ptr cinfo, JHUFF_TBL * htbl, c_derived_tbl ** pdtbl)); + +/* Generate an optimal table definition given the specified counts */ +EXTERN(void) jpeg_gen_optimal_table + JPP((j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])); diff --git a/gs/jpeg/jcinit.c b/gs/jpeg/jcinit.c new file mode 100644 index 000000000..d96bb3777 --- /dev/null +++ b/gs/jpeg/jcinit.c @@ -0,0 +1,72 @@ +/* + * jcinit.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains initialization logic for the JPEG compressor. + * This routine is in charge of selecting the modules to be executed and + * making an initialization call to each one. + * + * Logically, this code belongs in jcmaster.c. It's split out because + * linking this routine implies linking the entire compression library. + * For a transcoding-only application, we want to be able to use jcmaster.c + * without linking in the whole library. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* + * Master selection of compression modules. + * This is done once at the start of processing an image. We determine + * which modules will be used and give them appropriate initialization calls. + */ + +GLOBAL(void) +jinit_compress_master (j_compress_ptr cinfo) +{ + /* Initialize master control (includes parameter checking/processing) */ + jinit_c_master_control(cinfo, FALSE /* full compression */); + + /* Preprocessing */ + if (! cinfo->raw_data_in) { + jinit_color_converter(cinfo); + jinit_downsampler(cinfo); + jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */); + } + /* Forward DCT */ + jinit_forward_dct(cinfo); + /* Entropy encoding: either Huffman or arithmetic coding. */ + if (cinfo->arith_code) { + ERREXIT(cinfo, JERR_ARITH_NOTIMPL); + } else { + if (cinfo->progressive_mode) { +#ifdef C_PROGRESSIVE_SUPPORTED + jinit_phuff_encoder(cinfo); +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } else + jinit_huff_encoder(cinfo); + } + + /* Need a full-image coefficient buffer in any multi-pass mode. */ + jinit_c_coef_controller(cinfo, + (cinfo->num_scans > 1 || cinfo->optimize_coding)); + jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */); + + jinit_marker_writer(cinfo); + + /* We can now tell the memory manager to allocate virtual arrays. */ + (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); + + /* Write the datastream header (SOI) immediately. + * Frame and scan headers are postponed till later. + * This lets application insert special markers after the SOI. + */ + (*cinfo->marker->write_file_header) (cinfo); +} diff --git a/gs/jpeg/jcmainct.c b/gs/jpeg/jcmainct.c new file mode 100644 index 000000000..e0279a7e0 --- /dev/null +++ b/gs/jpeg/jcmainct.c @@ -0,0 +1,293 @@ +/* + * jcmainct.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the main buffer controller for compression. + * The main buffer lies between the pre-processor and the JPEG + * compressor proper; it holds downsampled data in the JPEG colorspace. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Note: currently, there is no operating mode in which a full-image buffer + * is needed at this step. If there were, that mode could not be used with + * "raw data" input, since this module is bypassed in that case. However, + * we've left the code here for possible use in special applications. + */ +#undef FULL_MAIN_BUFFER_SUPPORTED + + +/* Private buffer controller object */ + +typedef struct { + struct jpeg_c_main_controller pub; /* public fields */ + + JDIMENSION cur_iMCU_row; /* number of current iMCU row */ + JDIMENSION rowgroup_ctr; /* counts row groups received in iMCU row */ + boolean suspended; /* remember if we suspended output */ + J_BUF_MODE pass_mode; /* current operating mode */ + + /* If using just a strip buffer, this points to the entire set of buffers + * (we allocate one for each component). In the full-image case, this + * points to the currently accessible strips of the virtual arrays. + */ + JSAMPARRAY buffer[MAX_COMPONENTS]; + +#ifdef FULL_MAIN_BUFFER_SUPPORTED + /* If using full-image storage, this array holds pointers to virtual-array + * control blocks for each component. Unused if not full-image storage. + */ + jvirt_sarray_ptr whole_image[MAX_COMPONENTS]; +#endif +} my_main_controller; + +typedef my_main_controller * my_main_ptr; + + +/* Forward declarations */ +METHODDEF(void) process_data_simple_main + JPP((j_compress_ptr cinfo, JSAMPARRAY input_buf, + JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail)); +#ifdef FULL_MAIN_BUFFER_SUPPORTED +METHODDEF(void) process_data_buffer_main + JPP((j_compress_ptr cinfo, JSAMPARRAY input_buf, + JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail)); +#endif + + +/* + * Initialize for a processing pass. + */ + +METHODDEF(void) +start_pass_main (j_compress_ptr cinfo, J_BUF_MODE pass_mode) +{ + my_main_ptr main = (my_main_ptr) cinfo->main; + + /* Do nothing in raw-data mode. */ + if (cinfo->raw_data_in) + return; + + main->cur_iMCU_row = 0; /* initialize counters */ + main->rowgroup_ctr = 0; + main->suspended = FALSE; + main->pass_mode = pass_mode; /* save mode for use by process_data */ + + switch (pass_mode) { + case JBUF_PASS_THRU: +#ifdef FULL_MAIN_BUFFER_SUPPORTED + if (main->whole_image[0] != NULL) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); +#endif + main->pub.process_data = process_data_simple_main; + break; +#ifdef FULL_MAIN_BUFFER_SUPPORTED + case JBUF_SAVE_SOURCE: + case JBUF_CRANK_DEST: + case JBUF_SAVE_AND_PASS: + if (main->whole_image[0] == NULL) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + main->pub.process_data = process_data_buffer_main; + break; +#endif + default: + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + break; + } +} + + +/* + * Process some data. + * This routine handles the simple pass-through mode, + * where we have only a strip buffer. + */ + +METHODDEF(void) +process_data_simple_main (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, + JDIMENSION in_rows_avail) +{ + my_main_ptr main = (my_main_ptr) cinfo->main; + + while (main->cur_iMCU_row < cinfo->total_iMCU_rows) { + /* Read input data if we haven't filled the main buffer yet */ + if (main->rowgroup_ctr < DCTSIZE) + (*cinfo->prep->pre_process_data) (cinfo, + input_buf, in_row_ctr, in_rows_avail, + main->buffer, &main->rowgroup_ctr, + (JDIMENSION) DCTSIZE); + + /* If we don't have a full iMCU row buffered, return to application for + * more data. Note that preprocessor will always pad to fill the iMCU row + * at the bottom of the image. + */ + if (main->rowgroup_ctr != DCTSIZE) + return; + + /* Send the completed row to the compressor */ + if (! (*cinfo->coef->compress_data) (cinfo, main->buffer)) { + /* If compressor did not consume the whole row, then we must need to + * suspend processing and return to the application. In this situation + * we pretend we didn't yet consume the last input row; otherwise, if + * it happened to be the last row of the image, the application would + * think we were done. + */ + if (! main->suspended) { + (*in_row_ctr)--; + main->suspended = TRUE; + } + return; + } + /* We did finish the row. Undo our little suspension hack if a previous + * call suspended; then mark the main buffer empty. + */ + if (main->suspended) { + (*in_row_ctr)++; + main->suspended = FALSE; + } + main->rowgroup_ctr = 0; + main->cur_iMCU_row++; + } +} + + +#ifdef FULL_MAIN_BUFFER_SUPPORTED + +/* + * Process some data. + * This routine handles all of the modes that use a full-size buffer. + */ + +METHODDEF(void) +process_data_buffer_main (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, + JDIMENSION in_rows_avail) +{ + my_main_ptr main = (my_main_ptr) cinfo->main; + int ci; + jpeg_component_info *compptr; + boolean writing = (main->pass_mode != JBUF_CRANK_DEST); + + while (main->cur_iMCU_row < cinfo->total_iMCU_rows) { + /* Realign the virtual buffers if at the start of an iMCU row. */ + if (main->rowgroup_ctr == 0) { + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + main->buffer[ci] = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, main->whole_image[ci], + main->cur_iMCU_row * (compptr->v_samp_factor * DCTSIZE), + (JDIMENSION) (compptr->v_samp_factor * DCTSIZE), writing); + } + /* In a read pass, pretend we just read some source data. */ + if (! writing) { + *in_row_ctr += cinfo->max_v_samp_factor * DCTSIZE; + main->rowgroup_ctr = DCTSIZE; + } + } + + /* If a write pass, read input data until the current iMCU row is full. */ + /* Note: preprocessor will pad if necessary to fill the last iMCU row. */ + if (writing) { + (*cinfo->prep->pre_process_data) (cinfo, + input_buf, in_row_ctr, in_rows_avail, + main->buffer, &main->rowgroup_ctr, + (JDIMENSION) DCTSIZE); + /* Return to application if we need more data to fill the iMCU row. */ + if (main->rowgroup_ctr < DCTSIZE) + return; + } + + /* Emit data, unless this is a sink-only pass. */ + if (main->pass_mode != JBUF_SAVE_SOURCE) { + if (! (*cinfo->coef->compress_data) (cinfo, main->buffer)) { + /* If compressor did not consume the whole row, then we must need to + * suspend processing and return to the application. In this situation + * we pretend we didn't yet consume the last input row; otherwise, if + * it happened to be the last row of the image, the application would + * think we were done. + */ + if (! main->suspended) { + (*in_row_ctr)--; + main->suspended = TRUE; + } + return; + } + /* We did finish the row. Undo our little suspension hack if a previous + * call suspended; then mark the main buffer empty. + */ + if (main->suspended) { + (*in_row_ctr)++; + main->suspended = FALSE; + } + } + + /* If get here, we are done with this iMCU row. Mark buffer empty. */ + main->rowgroup_ctr = 0; + main->cur_iMCU_row++; + } +} + +#endif /* FULL_MAIN_BUFFER_SUPPORTED */ + + +/* + * Initialize main buffer controller. + */ + +GLOBAL(void) +jinit_c_main_controller (j_compress_ptr cinfo, boolean need_full_buffer) +{ + my_main_ptr main; + int ci; + jpeg_component_info *compptr; + + main = (my_main_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_main_controller)); + cinfo->main = (struct jpeg_c_main_controller *) main; + main->pub.start_pass = start_pass_main; + + /* We don't need to create a buffer in raw-data mode. */ + if (cinfo->raw_data_in) + return; + + /* Create the buffer. It holds downsampled data, so each component + * may be of a different size. + */ + if (need_full_buffer) { +#ifdef FULL_MAIN_BUFFER_SUPPORTED + /* Allocate a full-image virtual array for each component */ + /* Note we pad the bottom to a multiple of the iMCU height */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + main->whole_image[ci] = (*cinfo->mem->request_virt_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, + compptr->width_in_blocks * DCTSIZE, + (JDIMENSION) jround_up((long) compptr->height_in_blocks, + (long) compptr->v_samp_factor) * DCTSIZE, + (JDIMENSION) (compptr->v_samp_factor * DCTSIZE)); + } +#else + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); +#endif + } else { +#ifdef FULL_MAIN_BUFFER_SUPPORTED + main->whole_image[0] = NULL; /* flag for no virtual arrays */ +#endif + /* Allocate a strip buffer for each component */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + main->buffer[ci] = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + compptr->width_in_blocks * DCTSIZE, + (JDIMENSION) (compptr->v_samp_factor * DCTSIZE)); + } + } +} diff --git a/gs/jpeg/jcmarker.c b/gs/jpeg/jcmarker.c new file mode 100644 index 000000000..0198954c6 --- /dev/null +++ b/gs/jpeg/jcmarker.c @@ -0,0 +1,641 @@ +/* + * jcmarker.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to write JPEG datastream markers. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +typedef enum { /* JPEG marker codes */ + M_SOF0 = 0xc0, + M_SOF1 = 0xc1, + M_SOF2 = 0xc2, + M_SOF3 = 0xc3, + + M_SOF5 = 0xc5, + M_SOF6 = 0xc6, + M_SOF7 = 0xc7, + + M_JPG = 0xc8, + M_SOF9 = 0xc9, + M_SOF10 = 0xca, + M_SOF11 = 0xcb, + + M_SOF13 = 0xcd, + M_SOF14 = 0xce, + M_SOF15 = 0xcf, + + M_DHT = 0xc4, + + M_DAC = 0xcc, + + M_RST0 = 0xd0, + M_RST1 = 0xd1, + M_RST2 = 0xd2, + M_RST3 = 0xd3, + M_RST4 = 0xd4, + M_RST5 = 0xd5, + M_RST6 = 0xd6, + M_RST7 = 0xd7, + + M_SOI = 0xd8, + M_EOI = 0xd9, + M_SOS = 0xda, + M_DQT = 0xdb, + M_DNL = 0xdc, + M_DRI = 0xdd, + M_DHP = 0xde, + M_EXP = 0xdf, + + M_APP0 = 0xe0, + M_APP1 = 0xe1, + M_APP2 = 0xe2, + M_APP3 = 0xe3, + M_APP4 = 0xe4, + M_APP5 = 0xe5, + M_APP6 = 0xe6, + M_APP7 = 0xe7, + M_APP8 = 0xe8, + M_APP9 = 0xe9, + M_APP10 = 0xea, + M_APP11 = 0xeb, + M_APP12 = 0xec, + M_APP13 = 0xed, + M_APP14 = 0xee, + M_APP15 = 0xef, + + M_JPG0 = 0xf0, + M_JPG13 = 0xfd, + M_COM = 0xfe, + + M_TEM = 0x01, + + M_ERROR = 0x100 +} JPEG_MARKER; + + +/* + * Basic output routines. + * + * Note that we do not support suspension while writing a marker. + * Therefore, an application using suspension must ensure that there is + * enough buffer space for the initial markers (typ. 600-700 bytes) before + * calling jpeg_start_compress, and enough space to write the trailing EOI + * (a few bytes) before calling jpeg_finish_compress. Multipass compression + * modes are not supported at all with suspension, so those two are the only + * points where markers will be written. + */ + +LOCAL(void) +emit_byte (j_compress_ptr cinfo, int val) +/* Emit a byte */ +{ + struct jpeg_destination_mgr * dest = cinfo->dest; + + *(dest->next_output_byte)++ = (JOCTET) val; + if (--dest->free_in_buffer == 0) { + if (! (*dest->empty_output_buffer) (cinfo)) + ERREXIT(cinfo, JERR_CANT_SUSPEND); + } +} + + +LOCAL(void) +emit_marker (j_compress_ptr cinfo, JPEG_MARKER mark) +/* Emit a marker code */ +{ + emit_byte(cinfo, 0xFF); + emit_byte(cinfo, (int) mark); +} + + +LOCAL(void) +emit_2bytes (j_compress_ptr cinfo, int value) +/* Emit a 2-byte integer; these are always MSB first in JPEG files */ +{ + emit_byte(cinfo, (value >> 8) & 0xFF); + emit_byte(cinfo, value & 0xFF); +} + + +/* + * Routines to write specific marker types. + */ + +LOCAL(int) +emit_dqt (j_compress_ptr cinfo, int index) +/* Emit a DQT marker */ +/* Returns the precision used (0 = 8bits, 1 = 16bits) for baseline checking */ +{ + JQUANT_TBL * qtbl = cinfo->quant_tbl_ptrs[index]; + int prec; + int i; + + if (qtbl == NULL) + ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, index); + + prec = 0; + for (i = 0; i < DCTSIZE2; i++) { + if (qtbl->quantval[i] > 255) + prec = 1; + } + + if (! qtbl->sent_table) { + emit_marker(cinfo, M_DQT); + + emit_2bytes(cinfo, prec ? DCTSIZE2*2 + 1 + 2 : DCTSIZE2 + 1 + 2); + + emit_byte(cinfo, index + (prec<<4)); + + for (i = 0; i < DCTSIZE2; i++) { + /* The table entries must be emitted in zigzag order. */ + unsigned int qval = qtbl->quantval[jpeg_natural_order[i]]; + if (prec) + emit_byte(cinfo, qval >> 8); + emit_byte(cinfo, qval & 0xFF); + } + + qtbl->sent_table = TRUE; + } + + return prec; +} + + +LOCAL(void) +emit_dht (j_compress_ptr cinfo, int index, boolean is_ac) +/* Emit a DHT marker */ +{ + JHUFF_TBL * htbl; + int length, i; + + if (is_ac) { + htbl = cinfo->ac_huff_tbl_ptrs[index]; + index += 0x10; /* output index has AC bit set */ + } else { + htbl = cinfo->dc_huff_tbl_ptrs[index]; + } + + if (htbl == NULL) + ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, index); + + if (! htbl->sent_table) { + emit_marker(cinfo, M_DHT); + + length = 0; + for (i = 1; i <= 16; i++) + length += htbl->bits[i]; + + emit_2bytes(cinfo, length + 2 + 1 + 16); + emit_byte(cinfo, index); + + for (i = 1; i <= 16; i++) + emit_byte(cinfo, htbl->bits[i]); + + for (i = 0; i < length; i++) + emit_byte(cinfo, htbl->huffval[i]); + + htbl->sent_table = TRUE; + } +} + + +LOCAL(void) +emit_dac (j_compress_ptr cinfo) +/* Emit a DAC marker */ +/* Since the useful info is so small, we want to emit all the tables in */ +/* one DAC marker. Therefore this routine does its own scan of the table. */ +{ +#ifdef C_ARITH_CODING_SUPPORTED + char dc_in_use[NUM_ARITH_TBLS]; + char ac_in_use[NUM_ARITH_TBLS]; + int length, i; + jpeg_component_info *compptr; + + for (i = 0; i < NUM_ARITH_TBLS; i++) + dc_in_use[i] = ac_in_use[i] = 0; + + for (i = 0; i < cinfo->comps_in_scan; i++) { + compptr = cinfo->cur_comp_info[i]; + dc_in_use[compptr->dc_tbl_no] = 1; + ac_in_use[compptr->ac_tbl_no] = 1; + } + + length = 0; + for (i = 0; i < NUM_ARITH_TBLS; i++) + length += dc_in_use[i] + ac_in_use[i]; + + emit_marker(cinfo, M_DAC); + + emit_2bytes(cinfo, length*2 + 2); + + for (i = 0; i < NUM_ARITH_TBLS; i++) { + if (dc_in_use[i]) { + emit_byte(cinfo, i); + emit_byte(cinfo, cinfo->arith_dc_L[i] + (cinfo->arith_dc_U[i]<<4)); + } + if (ac_in_use[i]) { + emit_byte(cinfo, i + 0x10); + emit_byte(cinfo, cinfo->arith_ac_K[i]); + } + } +#endif /* C_ARITH_CODING_SUPPORTED */ +} + + +LOCAL(void) +emit_dri (j_compress_ptr cinfo) +/* Emit a DRI marker */ +{ + emit_marker(cinfo, M_DRI); + + emit_2bytes(cinfo, 4); /* fixed length */ + + emit_2bytes(cinfo, (int) cinfo->restart_interval); +} + + +LOCAL(void) +emit_sof (j_compress_ptr cinfo, JPEG_MARKER code) +/* Emit a SOF marker */ +{ + int ci; + jpeg_component_info *compptr; + + emit_marker(cinfo, code); + + emit_2bytes(cinfo, 3 * cinfo->num_components + 2 + 5 + 1); /* length */ + + /* Make sure image isn't bigger than SOF field can handle */ + if ((long) cinfo->image_height > 65535L || + (long) cinfo->image_width > 65535L) + ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) 65535); + + emit_byte(cinfo, cinfo->data_precision); + emit_2bytes(cinfo, (int) cinfo->image_height); + emit_2bytes(cinfo, (int) cinfo->image_width); + + emit_byte(cinfo, cinfo->num_components); + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + emit_byte(cinfo, compptr->component_id); + emit_byte(cinfo, (compptr->h_samp_factor << 4) + compptr->v_samp_factor); + emit_byte(cinfo, compptr->quant_tbl_no); + } +} + + +LOCAL(void) +emit_sos (j_compress_ptr cinfo) +/* Emit a SOS marker */ +{ + int i, td, ta; + jpeg_component_info *compptr; + + emit_marker(cinfo, M_SOS); + + emit_2bytes(cinfo, 2 * cinfo->comps_in_scan + 2 + 1 + 3); /* length */ + + emit_byte(cinfo, cinfo->comps_in_scan); + + for (i = 0; i < cinfo->comps_in_scan; i++) { + compptr = cinfo->cur_comp_info[i]; + emit_byte(cinfo, compptr->component_id); + td = compptr->dc_tbl_no; + ta = compptr->ac_tbl_no; + if (cinfo->progressive_mode) { + /* Progressive mode: only DC or only AC tables are used in one scan; + * furthermore, Huffman coding of DC refinement uses no table at all. + * We emit 0 for unused field(s); this is recommended by the P&M text + * but does not seem to be specified in the standard. + */ + if (cinfo->Ss == 0) { + ta = 0; /* DC scan */ + if (cinfo->Ah != 0 && !cinfo->arith_code) + td = 0; /* no DC table either */ + } else { + td = 0; /* AC scan */ + } + } + emit_byte(cinfo, (td << 4) + ta); + } + + emit_byte(cinfo, cinfo->Ss); + emit_byte(cinfo, cinfo->Se); + emit_byte(cinfo, (cinfo->Ah << 4) + cinfo->Al); +} + + +LOCAL(void) +emit_jfif_app0 (j_compress_ptr cinfo) +/* Emit a JFIF-compliant APP0 marker */ +{ + /* + * Length of APP0 block (2 bytes) + * Block ID (4 bytes - ASCII "JFIF") + * Zero byte (1 byte to terminate the ID string) + * Version Major, Minor (2 bytes - 0x01, 0x01) + * Units (1 byte - 0x00 = none, 0x01 = inch, 0x02 = cm) + * Xdpu (2 bytes - dots per unit horizontal) + * Ydpu (2 bytes - dots per unit vertical) + * Thumbnail X size (1 byte) + * Thumbnail Y size (1 byte) + */ + + emit_marker(cinfo, M_APP0); + + emit_2bytes(cinfo, 2 + 4 + 1 + 2 + 1 + 2 + 2 + 1 + 1); /* length */ + + emit_byte(cinfo, 0x4A); /* Identifier: ASCII "JFIF" */ + emit_byte(cinfo, 0x46); + emit_byte(cinfo, 0x49); + emit_byte(cinfo, 0x46); + emit_byte(cinfo, 0); + /* We currently emit version code 1.01 since we use no 1.02 features. + * This may avoid complaints from some older decoders. + */ + emit_byte(cinfo, 1); /* Major version */ + emit_byte(cinfo, 1); /* Minor version */ + emit_byte(cinfo, cinfo->density_unit); /* Pixel size information */ + emit_2bytes(cinfo, (int) cinfo->X_density); + emit_2bytes(cinfo, (int) cinfo->Y_density); + emit_byte(cinfo, 0); /* No thumbnail image */ + emit_byte(cinfo, 0); +} + + +LOCAL(void) +emit_adobe_app14 (j_compress_ptr cinfo) +/* Emit an Adobe APP14 marker */ +{ + /* + * Length of APP14 block (2 bytes) + * Block ID (5 bytes - ASCII "Adobe") + * Version Number (2 bytes - currently 100) + * Flags0 (2 bytes - currently 0) + * Flags1 (2 bytes - currently 0) + * Color transform (1 byte) + * + * Although Adobe TN 5116 mentions Version = 101, all the Adobe files + * now in circulation seem to use Version = 100, so that's what we write. + * + * We write the color transform byte as 1 if the JPEG color space is + * YCbCr, 2 if it's YCCK, 0 otherwise. Adobe's definition has to do with + * whether the encoder performed a transformation, which is pretty useless. + */ + + emit_marker(cinfo, M_APP14); + + emit_2bytes(cinfo, 2 + 5 + 2 + 2 + 2 + 1); /* length */ + + emit_byte(cinfo, 0x41); /* Identifier: ASCII "Adobe" */ + emit_byte(cinfo, 0x64); + emit_byte(cinfo, 0x6F); + emit_byte(cinfo, 0x62); + emit_byte(cinfo, 0x65); + emit_2bytes(cinfo, 100); /* Version */ + emit_2bytes(cinfo, 0); /* Flags0 */ + emit_2bytes(cinfo, 0); /* Flags1 */ + switch (cinfo->jpeg_color_space) { + case JCS_YCbCr: + emit_byte(cinfo, 1); /* Color transform = 1 */ + break; + case JCS_YCCK: + emit_byte(cinfo, 2); /* Color transform = 2 */ + break; + default: + emit_byte(cinfo, 0); /* Color transform = 0 */ + break; + } +} + + +/* + * This routine is exported for possible use by applications. + * The intended use is to emit COM or APPn markers after calling + * jpeg_start_compress() and before the first jpeg_write_scanlines() call + * (hence, after write_file_header but before write_frame_header). + * Other uses are not guaranteed to produce desirable results. + */ + +METHODDEF(void) +write_any_marker (j_compress_ptr cinfo, int marker, + const JOCTET *dataptr, unsigned int datalen) +/* Emit an arbitrary marker with parameters */ +{ + if (datalen <= (unsigned int) 65533) { /* safety check */ + emit_marker(cinfo, (JPEG_MARKER) marker); + + emit_2bytes(cinfo, (int) (datalen + 2)); /* total length */ + + while (datalen--) { + emit_byte(cinfo, *dataptr); + dataptr++; + } + } +} + + +/* + * Write datastream header. + * This consists of an SOI and optional APPn markers. + * We recommend use of the JFIF marker, but not the Adobe marker, + * when using YCbCr or grayscale data. The JFIF marker should NOT + * be used for any other JPEG colorspace. The Adobe marker is helpful + * to distinguish RGB, CMYK, and YCCK colorspaces. + * Note that an application can write additional header markers after + * jpeg_start_compress returns. + */ + +METHODDEF(void) +write_file_header (j_compress_ptr cinfo) +{ + emit_marker(cinfo, M_SOI); /* first the SOI */ + + if (cinfo->write_JFIF_header) /* next an optional JFIF APP0 */ + emit_jfif_app0(cinfo); + if (cinfo->write_Adobe_marker) /* next an optional Adobe APP14 */ + emit_adobe_app14(cinfo); +} + + +/* + * Write frame header. + * This consists of DQT and SOFn markers. + * Note that we do not emit the SOF until we have emitted the DQT(s). + * This avoids compatibility problems with incorrect implementations that + * try to error-check the quant table numbers as soon as they see the SOF. + */ + +METHODDEF(void) +write_frame_header (j_compress_ptr cinfo) +{ + int ci, prec; + boolean is_baseline; + jpeg_component_info *compptr; + + /* Emit DQT for each quantization table. + * Note that emit_dqt() suppresses any duplicate tables. + */ + prec = 0; + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + prec += emit_dqt(cinfo, compptr->quant_tbl_no); + } + /* now prec is nonzero iff there are any 16-bit quant tables. */ + + /* Check for a non-baseline specification. + * Note we assume that Huffman table numbers won't be changed later. + */ + if (cinfo->arith_code || cinfo->progressive_mode || + cinfo->data_precision != 8) { + is_baseline = FALSE; + } else { + is_baseline = TRUE; + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + if (compptr->dc_tbl_no > 1 || compptr->ac_tbl_no > 1) + is_baseline = FALSE; + } + if (prec && is_baseline) { + is_baseline = FALSE; + /* If it's baseline except for quantizer size, warn the user */ + TRACEMS(cinfo, 0, JTRC_16BIT_TABLES); + } + } + + /* Emit the proper SOF marker */ + if (cinfo->arith_code) { + emit_sof(cinfo, M_SOF9); /* SOF code for arithmetic coding */ + } else { + if (cinfo->progressive_mode) + emit_sof(cinfo, M_SOF2); /* SOF code for progressive Huffman */ + else if (is_baseline) + emit_sof(cinfo, M_SOF0); /* SOF code for baseline implementation */ + else + emit_sof(cinfo, M_SOF1); /* SOF code for non-baseline Huffman file */ + } +} + + +/* + * Write scan header. + * This consists of DHT or DAC markers, optional DRI, and SOS. + * Compressed data will be written following the SOS. + */ + +METHODDEF(void) +write_scan_header (j_compress_ptr cinfo) +{ + int i; + jpeg_component_info *compptr; + + if (cinfo->arith_code) { + /* Emit arith conditioning info. We may have some duplication + * if the file has multiple scans, but it's so small it's hardly + * worth worrying about. + */ + emit_dac(cinfo); + } else { + /* Emit Huffman tables. + * Note that emit_dht() suppresses any duplicate tables. + */ + for (i = 0; i < cinfo->comps_in_scan; i++) { + compptr = cinfo->cur_comp_info[i]; + if (cinfo->progressive_mode) { + /* Progressive mode: only DC or only AC tables are used in one scan */ + if (cinfo->Ss == 0) { + if (cinfo->Ah == 0) /* DC needs no table for refinement scan */ + emit_dht(cinfo, compptr->dc_tbl_no, FALSE); + } else { + emit_dht(cinfo, compptr->ac_tbl_no, TRUE); + } + } else { + /* Sequential mode: need both DC and AC tables */ + emit_dht(cinfo, compptr->dc_tbl_no, FALSE); + emit_dht(cinfo, compptr->ac_tbl_no, TRUE); + } + } + } + + /* Emit DRI if required --- note that DRI value could change for each scan. + * If it doesn't, a tiny amount of space is wasted in multiple-scan files. + * We assume DRI will never be nonzero for one scan and zero for a later one. + */ + if (cinfo->restart_interval) + emit_dri(cinfo); + + emit_sos(cinfo); +} + + +/* + * Write datastream trailer. + */ + +METHODDEF(void) +write_file_trailer (j_compress_ptr cinfo) +{ + emit_marker(cinfo, M_EOI); +} + + +/* + * Write an abbreviated table-specification datastream. + * This consists of SOI, DQT and DHT tables, and EOI. + * Any table that is defined and not marked sent_table = TRUE will be + * emitted. Note that all tables will be marked sent_table = TRUE at exit. + */ + +METHODDEF(void) +write_tables_only (j_compress_ptr cinfo) +{ + int i; + + emit_marker(cinfo, M_SOI); + + for (i = 0; i < NUM_QUANT_TBLS; i++) { + if (cinfo->quant_tbl_ptrs[i] != NULL) + (void) emit_dqt(cinfo, i); + } + + if (! cinfo->arith_code) { + for (i = 0; i < NUM_HUFF_TBLS; i++) { + if (cinfo->dc_huff_tbl_ptrs[i] != NULL) + emit_dht(cinfo, i, FALSE); + if (cinfo->ac_huff_tbl_ptrs[i] != NULL) + emit_dht(cinfo, i, TRUE); + } + } + + emit_marker(cinfo, M_EOI); +} + + +/* + * Initialize the marker writer module. + */ + +GLOBAL(void) +jinit_marker_writer (j_compress_ptr cinfo) +{ + /* Create the subobject */ + cinfo->marker = (struct jpeg_marker_writer *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(struct jpeg_marker_writer)); + /* Initialize method pointers */ + cinfo->marker->write_any_marker = write_any_marker; + cinfo->marker->write_file_header = write_file_header; + cinfo->marker->write_frame_header = write_frame_header; + cinfo->marker->write_scan_header = write_scan_header; + cinfo->marker->write_file_trailer = write_file_trailer; + cinfo->marker->write_tables_only = write_tables_only; +} diff --git a/gs/jpeg/jcmaster.c b/gs/jpeg/jcmaster.c new file mode 100644 index 000000000..c3e1ef5f6 --- /dev/null +++ b/gs/jpeg/jcmaster.c @@ -0,0 +1,578 @@ +/* + * jcmaster.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains master control logic for the JPEG compressor. + * These routines are concerned with parameter validation, initial setup, + * and inter-pass control (determining the number of passes and the work + * to be done in each pass). + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Private state */ + +typedef enum { + main_pass, /* input data, also do first output step */ + huff_opt_pass, /* Huffman code optimization pass */ + output_pass /* data output pass */ +} c_pass_type; + +typedef struct { + struct jpeg_comp_master pub; /* public fields */ + + c_pass_type pass_type; /* the type of the current pass */ + + int pass_number; /* # of passes completed */ + int total_passes; /* total # of passes needed */ + + int scan_number; /* current index in scan_info[] */ +} my_comp_master; + +typedef my_comp_master * my_master_ptr; + + +/* + * Support routines that do various essential calculations. + */ + +LOCAL(void) +initial_setup (j_compress_ptr cinfo) +/* Do computations that are needed before master selection phase */ +{ + int ci; + jpeg_component_info *compptr; + long samplesperrow; + JDIMENSION jd_samplesperrow; + + /* Sanity check on image dimensions */ + if (cinfo->image_height <= 0 || cinfo->image_width <= 0 + || cinfo->num_components <= 0 || cinfo->input_components <= 0) + ERREXIT(cinfo, JERR_EMPTY_IMAGE); + + /* Make sure image isn't bigger than I can handle */ + if ((long) cinfo->image_height > (long) JPEG_MAX_DIMENSION || + (long) cinfo->image_width > (long) JPEG_MAX_DIMENSION) + ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION); + + /* Width of an input scanline must be representable as JDIMENSION. */ + samplesperrow = (long) cinfo->image_width * (long) cinfo->input_components; + jd_samplesperrow = (JDIMENSION) samplesperrow; + if ((long) jd_samplesperrow != samplesperrow) + ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); + + /* For now, precision must match compiled-in value... */ + if (cinfo->data_precision != BITS_IN_JSAMPLE) + ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); + + /* Check that number of components won't exceed internal array sizes */ + if (cinfo->num_components > MAX_COMPONENTS) + ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, + MAX_COMPONENTS); + + /* Compute maximum sampling factors; check factor validity */ + cinfo->max_h_samp_factor = 1; + cinfo->max_v_samp_factor = 1; + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + if (compptr->h_samp_factor<=0 || compptr->h_samp_factor>MAX_SAMP_FACTOR || + compptr->v_samp_factor<=0 || compptr->v_samp_factor>MAX_SAMP_FACTOR) + ERREXIT(cinfo, JERR_BAD_SAMPLING); + cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor, + compptr->h_samp_factor); + cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor, + compptr->v_samp_factor); + } + + /* Compute dimensions of components */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Fill in the correct component_index value; don't rely on application */ + compptr->component_index = ci; + /* For compression, we never do DCT scaling. */ + compptr->DCT_scaled_size = DCTSIZE; + /* Size in DCT blocks */ + compptr->width_in_blocks = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, + (long) (cinfo->max_h_samp_factor * DCTSIZE)); + compptr->height_in_blocks = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, + (long) (cinfo->max_v_samp_factor * DCTSIZE)); + /* Size in samples */ + compptr->downsampled_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, + (long) cinfo->max_h_samp_factor); + compptr->downsampled_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, + (long) cinfo->max_v_samp_factor); + /* Mark component needed (this flag isn't actually used for compression) */ + compptr->component_needed = TRUE; + } + + /* Compute number of fully interleaved MCU rows (number of times that + * main controller will call coefficient controller). + */ + cinfo->total_iMCU_rows = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height, + (long) (cinfo->max_v_samp_factor*DCTSIZE)); +} + + +#ifdef C_MULTISCAN_FILES_SUPPORTED + +LOCAL(void) +validate_script (j_compress_ptr cinfo) +/* Verify that the scan script in cinfo->scan_info[] is valid; also + * determine whether it uses progressive JPEG, and set cinfo->progressive_mode. + */ +{ + const jpeg_scan_info * scanptr; + int scanno, ncomps, ci, coefi, thisi; + int Ss, Se, Ah, Al; + boolean component_sent[MAX_COMPONENTS]; +#ifdef C_PROGRESSIVE_SUPPORTED + int * last_bitpos_ptr; + int last_bitpos[MAX_COMPONENTS][DCTSIZE2]; + /* -1 until that coefficient has been seen; then last Al for it */ +#endif + + if (cinfo->num_scans <= 0) + ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, 0); + + /* For sequential JPEG, all scans must have Ss=0, Se=DCTSIZE2-1; + * for progressive JPEG, no scan can have this. + */ + scanptr = cinfo->scan_info; + if (scanptr->Ss != 0 || scanptr->Se != DCTSIZE2-1) { +#ifdef C_PROGRESSIVE_SUPPORTED + cinfo->progressive_mode = TRUE; + last_bitpos_ptr = & last_bitpos[0][0]; + for (ci = 0; ci < cinfo->num_components; ci++) + for (coefi = 0; coefi < DCTSIZE2; coefi++) + *last_bitpos_ptr++ = -1; +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } else { + cinfo->progressive_mode = FALSE; + for (ci = 0; ci < cinfo->num_components; ci++) + component_sent[ci] = FALSE; + } + + for (scanno = 1; scanno <= cinfo->num_scans; scanptr++, scanno++) { + /* Validate component indexes */ + ncomps = scanptr->comps_in_scan; + if (ncomps <= 0 || ncomps > MAX_COMPS_IN_SCAN) + ERREXIT2(cinfo, JERR_COMPONENT_COUNT, ncomps, MAX_COMPS_IN_SCAN); + for (ci = 0; ci < ncomps; ci++) { + thisi = scanptr->component_index[ci]; + if (thisi < 0 || thisi >= cinfo->num_components) + ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno); + /* Components must appear in SOF order within each scan */ + if (ci > 0 && thisi <= scanptr->component_index[ci-1]) + ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno); + } + /* Validate progression parameters */ + Ss = scanptr->Ss; + Se = scanptr->Se; + Ah = scanptr->Ah; + Al = scanptr->Al; + if (cinfo->progressive_mode) { +#ifdef C_PROGRESSIVE_SUPPORTED + if (Ss < 0 || Ss >= DCTSIZE2 || Se < Ss || Se >= DCTSIZE2 || + Ah < 0 || Ah > 13 || Al < 0 || Al > 13) + ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); + if (Ss == 0) { + if (Se != 0) /* DC and AC together not OK */ + ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); + } else { + if (ncomps != 1) /* AC scans must be for only one component */ + ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); + } + for (ci = 0; ci < ncomps; ci++) { + last_bitpos_ptr = & last_bitpos[scanptr->component_index[ci]][0]; + if (Ss != 0 && last_bitpos_ptr[0] < 0) /* AC without prior DC scan */ + ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); + for (coefi = Ss; coefi <= Se; coefi++) { + if (last_bitpos_ptr[coefi] < 0) { + /* first scan of this coefficient */ + if (Ah != 0) + ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); + } else { + /* not first scan */ + if (Ah != last_bitpos_ptr[coefi] || Al != Ah-1) + ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); + } + last_bitpos_ptr[coefi] = Al; + } + } +#endif + } else { + /* For sequential JPEG, all progression parameters must be these: */ + if (Ss != 0 || Se != DCTSIZE2-1 || Ah != 0 || Al != 0) + ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); + /* Make sure components are not sent twice */ + for (ci = 0; ci < ncomps; ci++) { + thisi = scanptr->component_index[ci]; + if (component_sent[thisi]) + ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno); + component_sent[thisi] = TRUE; + } + } + } + + /* Now verify that everything got sent. */ + if (cinfo->progressive_mode) { +#ifdef C_PROGRESSIVE_SUPPORTED + /* For progressive mode, we only check that at least some DC data + * got sent for each component; the spec does not require that all bits + * of all coefficients be transmitted. Would it be wiser to enforce + * transmission of all coefficient bits?? + */ + for (ci = 0; ci < cinfo->num_components; ci++) { + if (last_bitpos[ci][0] < 0) + ERREXIT(cinfo, JERR_MISSING_DATA); + } +#endif + } else { + for (ci = 0; ci < cinfo->num_components; ci++) { + if (! component_sent[ci]) + ERREXIT(cinfo, JERR_MISSING_DATA); + } + } +} + +#endif /* C_MULTISCAN_FILES_SUPPORTED */ + + +LOCAL(void) +select_scan_parameters (j_compress_ptr cinfo) +/* Set up the scan parameters for the current scan */ +{ + int ci; + +#ifdef C_MULTISCAN_FILES_SUPPORTED + if (cinfo->scan_info != NULL) { + /* Prepare for current scan --- the script is already validated */ + my_master_ptr master = (my_master_ptr) cinfo->master; + const jpeg_scan_info * scanptr = cinfo->scan_info + master->scan_number; + + cinfo->comps_in_scan = scanptr->comps_in_scan; + for (ci = 0; ci < scanptr->comps_in_scan; ci++) { + cinfo->cur_comp_info[ci] = + &cinfo->comp_info[scanptr->component_index[ci]]; + } + cinfo->Ss = scanptr->Ss; + cinfo->Se = scanptr->Se; + cinfo->Ah = scanptr->Ah; + cinfo->Al = scanptr->Al; + } + else +#endif + { + /* Prepare for single sequential-JPEG scan containing all components */ + if (cinfo->num_components > MAX_COMPS_IN_SCAN) + ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, + MAX_COMPS_IN_SCAN); + cinfo->comps_in_scan = cinfo->num_components; + for (ci = 0; ci < cinfo->num_components; ci++) { + cinfo->cur_comp_info[ci] = &cinfo->comp_info[ci]; + } + cinfo->Ss = 0; + cinfo->Se = DCTSIZE2-1; + cinfo->Ah = 0; + cinfo->Al = 0; + } +} + + +LOCAL(void) +per_scan_setup (j_compress_ptr cinfo) +/* Do computations that are needed before processing a JPEG scan */ +/* cinfo->comps_in_scan and cinfo->cur_comp_info[] are already set */ +{ + int ci, mcublks, tmp; + jpeg_component_info *compptr; + + if (cinfo->comps_in_scan == 1) { + + /* Noninterleaved (single-component) scan */ + compptr = cinfo->cur_comp_info[0]; + + /* Overall image size in MCUs */ + cinfo->MCUs_per_row = compptr->width_in_blocks; + cinfo->MCU_rows_in_scan = compptr->height_in_blocks; + + /* For noninterleaved scan, always one block per MCU */ + compptr->MCU_width = 1; + compptr->MCU_height = 1; + compptr->MCU_blocks = 1; + compptr->MCU_sample_width = DCTSIZE; + compptr->last_col_width = 1; + /* For noninterleaved scans, it is convenient to define last_row_height + * as the number of block rows present in the last iMCU row. + */ + tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor); + if (tmp == 0) tmp = compptr->v_samp_factor; + compptr->last_row_height = tmp; + + /* Prepare array describing MCU composition */ + cinfo->blocks_in_MCU = 1; + cinfo->MCU_membership[0] = 0; + + } else { + + /* Interleaved (multi-component) scan */ + if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN) + ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan, + MAX_COMPS_IN_SCAN); + + /* Overall image size in MCUs */ + cinfo->MCUs_per_row = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width, + (long) (cinfo->max_h_samp_factor*DCTSIZE)); + cinfo->MCU_rows_in_scan = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height, + (long) (cinfo->max_v_samp_factor*DCTSIZE)); + + cinfo->blocks_in_MCU = 0; + + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + /* Sampling factors give # of blocks of component in each MCU */ + compptr->MCU_width = compptr->h_samp_factor; + compptr->MCU_height = compptr->v_samp_factor; + compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height; + compptr->MCU_sample_width = compptr->MCU_width * DCTSIZE; + /* Figure number of non-dummy blocks in last MCU column & row */ + tmp = (int) (compptr->width_in_blocks % compptr->MCU_width); + if (tmp == 0) tmp = compptr->MCU_width; + compptr->last_col_width = tmp; + tmp = (int) (compptr->height_in_blocks % compptr->MCU_height); + if (tmp == 0) tmp = compptr->MCU_height; + compptr->last_row_height = tmp; + /* Prepare array describing MCU composition */ + mcublks = compptr->MCU_blocks; + if (cinfo->blocks_in_MCU + mcublks > C_MAX_BLOCKS_IN_MCU) + ERREXIT(cinfo, JERR_BAD_MCU_SIZE); + while (mcublks-- > 0) { + cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci; + } + } + + } + + /* Convert restart specified in rows to actual MCU count. */ + /* Note that count must fit in 16 bits, so we provide limiting. */ + if (cinfo->restart_in_rows > 0) { + long nominal = (long) cinfo->restart_in_rows * (long) cinfo->MCUs_per_row; + cinfo->restart_interval = (unsigned int) MIN(nominal, 65535L); + } +} + + +/* + * Per-pass setup. + * This is called at the beginning of each pass. We determine which modules + * will be active during this pass and give them appropriate start_pass calls. + * We also set is_last_pass to indicate whether any more passes will be + * required. + */ + +METHODDEF(void) +prepare_for_pass (j_compress_ptr cinfo) +{ + my_master_ptr master = (my_master_ptr) cinfo->master; + + switch (master->pass_type) { + case main_pass: + /* Initial pass: will collect input data, and do either Huffman + * optimization or data output for the first scan. + */ + select_scan_parameters(cinfo); + per_scan_setup(cinfo); + if (! cinfo->raw_data_in) { + (*cinfo->cconvert->start_pass) (cinfo); + (*cinfo->downsample->start_pass) (cinfo); + (*cinfo->prep->start_pass) (cinfo, JBUF_PASS_THRU); + } + (*cinfo->fdct->start_pass) (cinfo); + (*cinfo->entropy->start_pass) (cinfo, cinfo->optimize_coding); + (*cinfo->coef->start_pass) (cinfo, + (master->total_passes > 1 ? + JBUF_SAVE_AND_PASS : JBUF_PASS_THRU)); + (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU); + if (cinfo->optimize_coding) { + /* No immediate data output; postpone writing frame/scan headers */ + master->pub.call_pass_startup = FALSE; + } else { + /* Will write frame/scan headers at first jpeg_write_scanlines call */ + master->pub.call_pass_startup = TRUE; + } + break; +#ifdef ENTROPY_OPT_SUPPORTED + case huff_opt_pass: + /* Do Huffman optimization for a scan after the first one. */ + select_scan_parameters(cinfo); + per_scan_setup(cinfo); + if (cinfo->Ss != 0 || cinfo->Ah == 0 || cinfo->arith_code) { + (*cinfo->entropy->start_pass) (cinfo, TRUE); + (*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST); + master->pub.call_pass_startup = FALSE; + break; + } + /* Special case: Huffman DC refinement scans need no Huffman table + * and therefore we can skip the optimization pass for them. + */ + master->pass_type = output_pass; + master->pass_number++; + /*FALLTHROUGH*/ +#endif + case output_pass: + /* Do a data-output pass. */ + /* We need not repeat per-scan setup if prior optimization pass did it. */ + if (! cinfo->optimize_coding) { + select_scan_parameters(cinfo); + per_scan_setup(cinfo); + } + (*cinfo->entropy->start_pass) (cinfo, FALSE); + (*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST); + /* We emit frame/scan headers now */ + if (master->scan_number == 0) + (*cinfo->marker->write_frame_header) (cinfo); + (*cinfo->marker->write_scan_header) (cinfo); + master->pub.call_pass_startup = FALSE; + break; + default: + ERREXIT(cinfo, JERR_NOT_COMPILED); + } + + master->pub.is_last_pass = (master->pass_number == master->total_passes-1); + + /* Set up progress monitor's pass info if present */ + if (cinfo->progress != NULL) { + cinfo->progress->completed_passes = master->pass_number; + cinfo->progress->total_passes = master->total_passes; + } +} + + +/* + * Special start-of-pass hook. + * This is called by jpeg_write_scanlines if call_pass_startup is TRUE. + * In single-pass processing, we need this hook because we don't want to + * write frame/scan headers during jpeg_start_compress; we want to let the + * application write COM markers etc. between jpeg_start_compress and the + * jpeg_write_scanlines loop. + * In multi-pass processing, this routine is not used. + */ + +METHODDEF(void) +pass_startup (j_compress_ptr cinfo) +{ + cinfo->master->call_pass_startup = FALSE; /* reset flag so call only once */ + + (*cinfo->marker->write_frame_header) (cinfo); + (*cinfo->marker->write_scan_header) (cinfo); +} + + +/* + * Finish up at end of pass. + */ + +METHODDEF(void) +finish_pass_master (j_compress_ptr cinfo) +{ + my_master_ptr master = (my_master_ptr) cinfo->master; + + /* The entropy coder always needs an end-of-pass call, + * either to analyze statistics or to flush its output buffer. + */ + (*cinfo->entropy->finish_pass) (cinfo); + + /* Update state for next pass */ + switch (master->pass_type) { + case main_pass: + /* next pass is either output of scan 0 (after optimization) + * or output of scan 1 (if no optimization). + */ + master->pass_type = output_pass; + if (! cinfo->optimize_coding) + master->scan_number++; + break; + case huff_opt_pass: + /* next pass is always output of current scan */ + master->pass_type = output_pass; + break; + case output_pass: + /* next pass is either optimization or output of next scan */ + if (cinfo->optimize_coding) + master->pass_type = huff_opt_pass; + master->scan_number++; + break; + } + + master->pass_number++; +} + + +/* + * Initialize master compression control. + */ + +GLOBAL(void) +jinit_c_master_control (j_compress_ptr cinfo, boolean transcode_only) +{ + my_master_ptr master; + + master = (my_master_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_comp_master)); + cinfo->master = (struct jpeg_comp_master *) master; + master->pub.prepare_for_pass = prepare_for_pass; + master->pub.pass_startup = pass_startup; + master->pub.finish_pass = finish_pass_master; + master->pub.is_last_pass = FALSE; + + /* Validate parameters, determine derived values */ + initial_setup(cinfo); + + if (cinfo->scan_info != NULL) { +#ifdef C_MULTISCAN_FILES_SUPPORTED + validate_script(cinfo); +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } else { + cinfo->progressive_mode = FALSE; + cinfo->num_scans = 1; + } + + if (cinfo->progressive_mode) /* TEMPORARY HACK ??? */ + cinfo->optimize_coding = TRUE; /* assume default tables no good for progressive mode */ + + /* Initialize my private state */ + if (transcode_only) { + /* no main pass in transcoding */ + if (cinfo->optimize_coding) + master->pass_type = huff_opt_pass; + else + master->pass_type = output_pass; + } else { + /* for normal compression, first pass is always this type: */ + master->pass_type = main_pass; + } + master->scan_number = 0; + master->pass_number = 0; + if (cinfo->optimize_coding) + master->total_passes = cinfo->num_scans * 2; + else + master->total_passes = cinfo->num_scans; +} diff --git a/gs/jpeg/jcomapi.c b/gs/jpeg/jcomapi.c new file mode 100644 index 000000000..b518ec62c --- /dev/null +++ b/gs/jpeg/jcomapi.c @@ -0,0 +1,94 @@ +/* + * jcomapi.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains application interface routines that are used for both + * compression and decompression. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* + * Abort processing of a JPEG compression or decompression operation, + * but don't destroy the object itself. + * + * For this, we merely clean up all the nonpermanent memory pools. + * Note that temp files (virtual arrays) are not allowed to belong to + * the permanent pool, so we will be able to close all temp files here. + * Closing a data source or destination, if necessary, is the application's + * responsibility. + */ + +GLOBAL(void) +jpeg_abort (j_common_ptr cinfo) +{ + int pool; + + /* Releasing pools in reverse order might help avoid fragmentation + * with some (brain-damaged) malloc libraries. + */ + for (pool = JPOOL_NUMPOOLS-1; pool > JPOOL_PERMANENT; pool--) { + (*cinfo->mem->free_pool) (cinfo, pool); + } + + /* Reset overall state for possible reuse of object */ + cinfo->global_state = (cinfo->is_decompressor ? DSTATE_START : CSTATE_START); +} + + +/* + * Destruction of a JPEG object. + * + * Everything gets deallocated except the master jpeg_compress_struct itself + * and the error manager struct. Both of these are supplied by the application + * and must be freed, if necessary, by the application. (Often they are on + * the stack and so don't need to be freed anyway.) + * Closing a data source or destination, if necessary, is the application's + * responsibility. + */ + +GLOBAL(void) +jpeg_destroy (j_common_ptr cinfo) +{ + /* We need only tell the memory manager to release everything. */ + /* NB: mem pointer is NULL if memory mgr failed to initialize. */ + if (cinfo->mem != NULL) + (*cinfo->mem->self_destruct) (cinfo); + cinfo->mem = NULL; /* be safe if jpeg_destroy is called twice */ + cinfo->global_state = 0; /* mark it destroyed */ +} + + +/* + * Convenience routines for allocating quantization and Huffman tables. + * (Would jutils.c be a more reasonable place to put these?) + */ + +GLOBAL(JQUANT_TBL *) +jpeg_alloc_quant_table (j_common_ptr cinfo) +{ + JQUANT_TBL *tbl; + + tbl = (JQUANT_TBL *) + (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JQUANT_TBL)); + tbl->sent_table = FALSE; /* make sure this is false in any new table */ + return tbl; +} + + +GLOBAL(JHUFF_TBL *) +jpeg_alloc_huff_table (j_common_ptr cinfo) +{ + JHUFF_TBL *tbl; + + tbl = (JHUFF_TBL *) + (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JHUFF_TBL)); + tbl->sent_table = FALSE; /* make sure this is false in any new table */ + return tbl; +} diff --git a/gs/jpeg/jconfig.bcc b/gs/jpeg/jconfig.bcc new file mode 100644 index 000000000..c6c53ff63 --- /dev/null +++ b/gs/jpeg/jconfig.bcc @@ -0,0 +1,48 @@ +/* jconfig.bcc --- jconfig.h for Borland C (Turbo C) on MS-DOS or OS/2. */ +/* see jconfig.doc for explanations */ + +#define HAVE_PROTOTYPES +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT +/* #define void char */ +/* #define const */ +#undef CHAR_IS_UNSIGNED +#define HAVE_STDDEF_H +#define HAVE_STDLIB_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#ifdef __MSDOS__ +#define NEED_FAR_POINTERS /* for small or medium memory model */ +#endif +#undef NEED_SHORT_EXTERNAL_NAMES +#undef INCOMPLETE_TYPES_BROKEN /* this assumes you have -w-stu in CFLAGS */ + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED + +#ifdef __MSDOS__ +#define USE_MSDOS_MEMMGR /* Define this if you use jmemdos.c */ +#define MAX_ALLOC_CHUNK 65520L /* Maximum request to malloc() */ +#define USE_FMEM /* Borland has _fmemcpy() and _fmemset() */ +#endif + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#define TWO_FILE_COMMANDLINE +#define USE_SETMODE /* Borland has setmode() */ +#ifdef __MSDOS__ +#define NEED_SIGNAL_CATCHER /* Define this if you use jmemdos.c */ +#endif +#undef DONT_USE_B_MODE +#undef PROGRESS_REPORT /* optional */ + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/gs/jpeg/jconfig.cfg b/gs/jpeg/jconfig.cfg new file mode 100644 index 000000000..36a04fa84 --- /dev/null +++ b/gs/jpeg/jconfig.cfg @@ -0,0 +1,44 @@ +/* jconfig.cfg --- source file edited by configure script */ +/* see jconfig.doc for explanations */ + +#undef HAVE_PROTOTYPES +#undef HAVE_UNSIGNED_CHAR +#undef HAVE_UNSIGNED_SHORT +#undef void +#undef const +#undef CHAR_IS_UNSIGNED +#undef HAVE_STDDEF_H +#undef HAVE_STDLIB_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#undef NEED_FAR_POINTERS +#undef NEED_SHORT_EXTERNAL_NAMES +/* Define this if you get warnings about undefined structures. */ +#undef INCOMPLETE_TYPES_BROKEN + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED +#undef INLINE +/* These are for configuring the JPEG memory manager. */ +#undef DEFAULT_MAX_MEM +#undef NO_MKTEMP + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#undef TWO_FILE_COMMANDLINE +#undef NEED_SIGNAL_CATCHER +#undef DONT_USE_B_MODE + +/* Define this if you want percent-done progress reports from cjpeg/djpeg. */ +#undef PROGRESS_REPORT + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/gs/jpeg/jconfig.dj b/gs/jpeg/jconfig.dj new file mode 100644 index 000000000..f759a9dbd --- /dev/null +++ b/gs/jpeg/jconfig.dj @@ -0,0 +1,38 @@ +/* jconfig.dj --- jconfig.h for DJGPP (Delorie's GNU C port) on MS-DOS. */ +/* see jconfig.doc for explanations */ + +#define HAVE_PROTOTYPES +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT +/* #define void char */ +/* #define const */ +#undef CHAR_IS_UNSIGNED +#define HAVE_STDDEF_H +#define HAVE_STDLIB_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#undef NEED_FAR_POINTERS /* DJGPP uses flat 32-bit addressing */ +#undef NEED_SHORT_EXTERNAL_NAMES +#undef INCOMPLETE_TYPES_BROKEN + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#undef TWO_FILE_COMMANDLINE /* optional */ +#define USE_SETMODE /* Needed to make one-file style work in DJGPP */ +#undef NEED_SIGNAL_CATCHER /* Define this if you use jmemname.c */ +#undef DONT_USE_B_MODE +#undef PROGRESS_REPORT /* optional */ + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/gs/jpeg/jconfig.doc b/gs/jpeg/jconfig.doc new file mode 100644 index 000000000..c18d1c064 --- /dev/null +++ b/gs/jpeg/jconfig.doc @@ -0,0 +1,155 @@ +/* + * jconfig.doc + * + * Copyright (C) 1991-1994, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file documents the configuration options that are required to + * customize the JPEG software for a particular system. + * + * The actual configuration options for a particular installation are stored + * in jconfig.h. On many machines, jconfig.h can be generated automatically + * or copied from one of the "canned" jconfig files that we supply. But if + * you need to generate a jconfig.h file by hand, this file tells you how. + * + * DO NOT EDIT THIS FILE --- IT WON'T ACCOMPLISH ANYTHING. + * EDIT A COPY NAMED JCONFIG.H. + */ + + +/* + * These symbols indicate the properties of your machine or compiler. + * #define the symbol if yes, #undef it if no. + */ + +/* Does your compiler support function prototypes? + * (If not, you also need to use ansi2knr, see install.doc) + */ +#define HAVE_PROTOTYPES + +/* Does your compiler support the declaration "unsigned char" ? + * How about "unsigned short" ? + */ +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT + +/* Define "void" as "char" if your compiler doesn't know about type void. + * NOTE: be sure to define void such that "void *" represents the most general + * pointer type, e.g., that returned by malloc(). + */ +/* #define void char */ + +/* Define "const" as empty if your compiler doesn't know the "const" keyword. + */ +/* #define const */ + +/* Define this if an ordinary "char" type is unsigned. + * If you're not sure, leaving it undefined will work at some cost in speed. + * If you defined HAVE_UNSIGNED_CHAR then the speed difference is minimal. + */ +#undef CHAR_IS_UNSIGNED + +/* Define this if your system has an ANSI-conforming file. + */ +#define HAVE_STDDEF_H + +/* Define this if your system has an ANSI-conforming file. + */ +#define HAVE_STDLIB_H + +/* Define this if your system does not have an ANSI/SysV , + * but does have a BSD-style . + */ +#undef NEED_BSD_STRINGS + +/* Define this if your system does not provide typedef size_t in any of the + * ANSI-standard places (stddef.h, stdlib.h, or stdio.h), but places it in + * instead. + */ +#undef NEED_SYS_TYPES_H + +/* For 80x86 machines, you need to define NEED_FAR_POINTERS, + * unless you are using a large-data memory model or 80386 flat-memory mode. + * On less brain-damaged CPUs this symbol must not be defined. + * (Defining this symbol causes large data structures to be referenced through + * "far" pointers and to be allocated with a special version of malloc.) + */ +#undef NEED_FAR_POINTERS + +/* Define this if your linker needs global names to be unique in less + * than the first 15 characters. + */ +#undef NEED_SHORT_EXTERNAL_NAMES + +/* Although a real ANSI C compiler can deal perfectly well with pointers to + * unspecified structures (see "incomplete types" in the spec), a few pre-ANSI + * and pseudo-ANSI compilers get confused. To keep one of these bozos happy, + * define INCOMPLETE_TYPES_BROKEN. This is not recommended unless you + * actually get "missing structure definition" warnings or errors while + * compiling the JPEG code. + */ +#undef INCOMPLETE_TYPES_BROKEN + + +/* + * The following options affect code selection within the JPEG library, + * but they don't need to be visible to applications using the library. + * To minimize application namespace pollution, the symbols won't be + * defined unless JPEG_INTERNALS has been defined. + */ + +#ifdef JPEG_INTERNALS + +/* Define this if your compiler implements ">>" on signed values as a logical + * (unsigned) shift; leave it undefined if ">>" is a signed (arithmetic) shift, + * which is the normal and rational definition. + */ +#undef RIGHT_SHIFT_IS_UNSIGNED + + +#endif /* JPEG_INTERNALS */ + + +/* + * The remaining options do not affect the JPEG library proper, + * but only the sample applications cjpeg/djpeg (see cjpeg.c, djpeg.c). + * Other applications can ignore these. + */ + +#ifdef JPEG_CJPEG_DJPEG + +/* These defines indicate which image (non-JPEG) file formats are allowed. */ + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +/* Define this if you want to name both input and output files on the command + * line, rather than using stdout and optionally stdin. You MUST do this if + * your system can't cope with binary I/O to stdin/stdout. See comments at + * head of cjpeg.c or djpeg.c. + */ +#undef TWO_FILE_COMMANDLINE + +/* Define this if your system needs explicit cleanup of temporary files. + * This is crucial under MS-DOS, where the temporary "files" may be areas + * of extended memory; on most other systems it's not as important. + */ +#undef NEED_SIGNAL_CATCHER + +/* By default, we open image files with fopen(...,"rb") or fopen(...,"wb"). + * This is necessary on systems that distinguish text files from binary files, + * and is harmless on most systems that don't. If you have one of the rare + * systems that complains about the "b" spec, define this symbol. + */ +#undef DONT_USE_B_MODE + +/* Define this if you want percent-done progress reports from cjpeg/djpeg. + */ +#undef PROGRESS_REPORT + + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/gs/jpeg/jconfig.h b/gs/jpeg/jconfig.h new file mode 100644 index 000000000..25c413d1b --- /dev/null +++ b/gs/jpeg/jconfig.h @@ -0,0 +1,45 @@ +/* jconfig.h. Generated automatically by configure. */ +/* jconfig.cfg --- source file edited by configure script */ +/* see jconfig.doc for explanations */ + +#define HAVE_PROTOTYPES +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT +#undef void +#undef const +#undef CHAR_IS_UNSIGNED +#define HAVE_STDDEF_H +#define HAVE_STDLIB_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#undef NEED_FAR_POINTERS +#undef NEED_SHORT_EXTERNAL_NAMES +/* Define this if you get warnings about undefined structures. */ +#undef INCOMPLETE_TYPES_BROKEN + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED +#define INLINE inline +/* These are for configuring the JPEG memory manager. */ +#undef DEFAULT_MAX_MEM +#undef NO_MKTEMP + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#undef TWO_FILE_COMMANDLINE +#undef NEED_SIGNAL_CATCHER +#undef DONT_USE_B_MODE + +/* Define this if you want percent-done progress reports from cjpeg/djpeg. */ +#undef PROGRESS_REPORT + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/gs/jpeg/jconfig.manx b/gs/jpeg/jconfig.manx new file mode 100644 index 000000000..6dd0d008e --- /dev/null +++ b/gs/jpeg/jconfig.manx @@ -0,0 +1,43 @@ +/* jconfig.manx --- jconfig.h for Amiga systems using Manx Aztec C ver 5.x. */ +/* see jconfig.doc for explanations */ + +#define HAVE_PROTOTYPES +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT +/* #define void char */ +/* #define const */ +#undef CHAR_IS_UNSIGNED +#define HAVE_STDDEF_H +#define HAVE_STDLIB_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#undef NEED_FAR_POINTERS +#undef NEED_SHORT_EXTERNAL_NAMES +#undef INCOMPLETE_TYPES_BROKEN + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED + +#define TEMP_DIRECTORY "JPEGTMP:" /* recommended setting for Amiga */ + +#define SHORTxSHORT_32 /* produces better DCT code with Aztec C */ + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#define TWO_FILE_COMMANDLINE +#define NEED_SIGNAL_CATCHER +#undef DONT_USE_B_MODE +#undef PROGRESS_REPORT /* optional */ + +#define signal_catcher _abort /* hack for Aztec C naming requirements */ + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/gs/jpeg/jconfig.mc6 b/gs/jpeg/jconfig.mc6 new file mode 100644 index 000000000..c55082df4 --- /dev/null +++ b/gs/jpeg/jconfig.mc6 @@ -0,0 +1,52 @@ +/* jconfig.mc6 --- jconfig.h for Microsoft C on MS-DOS, version 6.00A & up. */ +/* see jconfig.doc for explanations */ + +#define HAVE_PROTOTYPES +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT +/* #define void char */ +/* #define const */ +#undef CHAR_IS_UNSIGNED +#define HAVE_STDDEF_H +#define HAVE_STDLIB_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#define NEED_FAR_POINTERS /* for small or medium memory model */ +#undef NEED_SHORT_EXTERNAL_NAMES +#undef INCOMPLETE_TYPES_BROKEN + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED + +#define USE_MSDOS_MEMMGR /* Define this if you use jmemdos.c */ + +#define MAX_ALLOC_CHUNK 65520L /* Maximum request to malloc() */ + +#define USE_FMEM /* Microsoft has _fmemcpy() and _fmemset() */ + +#define NEED_FHEAPMIN /* far heap management routines are broken */ + +#define SHORTxLCONST_32 /* enable compiler-specific DCT optimization */ +/* Note: the above define is known to improve the code with Microsoft C 6.00A. + * I do not know whether it is good for later compiler versions. + * Please report any info on this point to jpeg-info@uunet.uu.net. + */ + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#define TWO_FILE_COMMANDLINE +#define USE_SETMODE /* Microsoft has setmode() */ +#define NEED_SIGNAL_CATCHER /* Define this if you use jmemdos.c */ +#undef DONT_USE_B_MODE +#undef PROGRESS_REPORT /* optional */ + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/gs/jpeg/jconfig.sas b/gs/jpeg/jconfig.sas new file mode 100644 index 000000000..efdac2229 --- /dev/null +++ b/gs/jpeg/jconfig.sas @@ -0,0 +1,43 @@ +/* jconfig.sas --- jconfig.h for Amiga systems using SAS C 6.0 and up. */ +/* see jconfig.doc for explanations */ + +#define HAVE_PROTOTYPES +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT +/* #define void char */ +/* #define const */ +#undef CHAR_IS_UNSIGNED +#define HAVE_STDDEF_H +#define HAVE_STDLIB_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#undef NEED_FAR_POINTERS +#undef NEED_SHORT_EXTERNAL_NAMES +#undef INCOMPLETE_TYPES_BROKEN + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED + +#define TEMP_DIRECTORY "JPEGTMP:" /* recommended setting for Amiga */ + +#define NO_MKTEMP /* SAS C doesn't have mktemp() */ + +#define SHORTxSHORT_32 /* produces better DCT code with SAS C */ + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#define TWO_FILE_COMMANDLINE +#define NEED_SIGNAL_CATCHER +#undef DONT_USE_B_MODE +#undef PROGRESS_REPORT /* optional */ + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/gs/jpeg/jconfig.st b/gs/jpeg/jconfig.st new file mode 100644 index 000000000..4421b7a1a --- /dev/null +++ b/gs/jpeg/jconfig.st @@ -0,0 +1,42 @@ +/* jconfig.st --- jconfig.h for Atari ST/STE/TT using Pure C or Turbo C. */ +/* see jconfig.doc for explanations */ + +#define HAVE_PROTOTYPES +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT +/* #define void char */ +/* #define const */ +#undef CHAR_IS_UNSIGNED +#define HAVE_STDDEF_H +#define HAVE_STDLIB_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#undef NEED_FAR_POINTERS +#undef NEED_SHORT_EXTERNAL_NAMES +#define INCOMPLETE_TYPES_BROKEN /* suppress undefined-structure warnings */ + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED + +#define ALIGN_TYPE long /* apparently double is a weird size? */ + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#define TWO_FILE_COMMANDLINE /* optional -- undef if you like Unix style */ +/* Note: if you undef TWO_FILE_COMMANDLINE, you may need to define + * USE_SETMODE. Some Atari compilers require it, some do not. + */ +#define NEED_SIGNAL_CATCHER /* needed if you use jmemname.c */ +#undef DONT_USE_B_MODE +#undef PROGRESS_REPORT /* optional */ + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/gs/jpeg/jconfig.vms b/gs/jpeg/jconfig.vms new file mode 100644 index 000000000..55a6ffba5 --- /dev/null +++ b/gs/jpeg/jconfig.vms @@ -0,0 +1,37 @@ +/* jconfig.vms --- jconfig.h for use on Digital VMS. */ +/* see jconfig.doc for explanations */ + +#define HAVE_PROTOTYPES +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT +/* #define void char */ +/* #define const */ +#undef CHAR_IS_UNSIGNED +#define HAVE_STDDEF_H +#define HAVE_STDLIB_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#undef NEED_FAR_POINTERS +#undef NEED_SHORT_EXTERNAL_NAMES +#undef INCOMPLETE_TYPES_BROKEN + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#define TWO_FILE_COMMANDLINE /* Needed on VMS */ +#undef NEED_SIGNAL_CATCHER +#undef DONT_USE_B_MODE +#undef PROGRESS_REPORT /* optional */ + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/gs/jpeg/jconfig.wat b/gs/jpeg/jconfig.wat new file mode 100644 index 000000000..6cc545bae --- /dev/null +++ b/gs/jpeg/jconfig.wat @@ -0,0 +1,38 @@ +/* jconfig.wat --- jconfig.h for Watcom C/C++ on MS-DOS or OS/2. */ +/* see jconfig.doc for explanations */ + +#define HAVE_PROTOTYPES +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT +/* #define void char */ +/* #define const */ +#define CHAR_IS_UNSIGNED +#define HAVE_STDDEF_H +#define HAVE_STDLIB_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#undef NEED_FAR_POINTERS /* Watcom uses flat 32-bit addressing */ +#undef NEED_SHORT_EXTERNAL_NAMES +#undef INCOMPLETE_TYPES_BROKEN + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#undef TWO_FILE_COMMANDLINE /* optional */ +#define USE_SETMODE /* Needed to make one-file style work in Watcom */ +#undef NEED_SIGNAL_CATCHER /* Define this if you use jmemname.c */ +#undef DONT_USE_B_MODE +#undef PROGRESS_REPORT /* optional */ + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/gs/jpeg/jcparam.c b/gs/jpeg/jcparam.c new file mode 100644 index 000000000..54871d5b3 --- /dev/null +++ b/gs/jpeg/jcparam.c @@ -0,0 +1,574 @@ +/* + * jcparam.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains optional default-setting code for the JPEG compressor. + * Applications do not have to use this file, but those that don't use it + * must know a lot more about the innards of the JPEG code. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* + * Quantization table setup routines + */ + +GLOBAL(void) +jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl, + const unsigned int *basic_table, + int scale_factor, boolean force_baseline) +/* Define a quantization table equal to the basic_table times + * a scale factor (given as a percentage). + * If force_baseline is TRUE, the computed quantization table entries + * are limited to 1..255 for JPEG baseline compatibility. + */ +{ + JQUANT_TBL ** qtblptr = & cinfo->quant_tbl_ptrs[which_tbl]; + int i; + long temp; + + /* Safety check to ensure start_compress not called yet. */ + if (cinfo->global_state != CSTATE_START) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + if (*qtblptr == NULL) + *qtblptr = jpeg_alloc_quant_table((j_common_ptr) cinfo); + + for (i = 0; i < DCTSIZE2; i++) { + temp = ((long) basic_table[i] * scale_factor + 50L) / 100L; + /* limit the values to the valid range */ + if (temp <= 0L) temp = 1L; + if (temp > 32767L) temp = 32767L; /* max quantizer needed for 12 bits */ + if (force_baseline && temp > 255L) + temp = 255L; /* limit to baseline range if requested */ + (*qtblptr)->quantval[i] = (UINT16) temp; + } + + /* Initialize sent_table FALSE so table will be written to JPEG file. */ + (*qtblptr)->sent_table = FALSE; +} + + +GLOBAL(void) +jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor, + boolean force_baseline) +/* Set or change the 'quality' (quantization) setting, using default tables + * and a straight percentage-scaling quality scale. In most cases it's better + * to use jpeg_set_quality (below); this entry point is provided for + * applications that insist on a linear percentage scaling. + */ +{ + /* These are the sample quantization tables given in JPEG spec section K.1. + * The spec says that the values given produce "good" quality, and + * when divided by 2, "very good" quality. + */ + static const unsigned int std_luminance_quant_tbl[DCTSIZE2] = { + 16, 11, 10, 16, 24, 40, 51, 61, + 12, 12, 14, 19, 26, 58, 60, 55, + 14, 13, 16, 24, 40, 57, 69, 56, + 14, 17, 22, 29, 51, 87, 80, 62, + 18, 22, 37, 56, 68, 109, 103, 77, + 24, 35, 55, 64, 81, 104, 113, 92, + 49, 64, 78, 87, 103, 121, 120, 101, + 72, 92, 95, 98, 112, 100, 103, 99 + }; + static const unsigned int std_chrominance_quant_tbl[DCTSIZE2] = { + 17, 18, 24, 47, 99, 99, 99, 99, + 18, 21, 26, 66, 99, 99, 99, 99, + 24, 26, 56, 99, 99, 99, 99, 99, + 47, 66, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99 + }; + + /* Set up two quantization tables using the specified scaling */ + jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl, + scale_factor, force_baseline); + jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl, + scale_factor, force_baseline); +} + + +GLOBAL(int) +jpeg_quality_scaling (int quality) +/* Convert a user-specified quality rating to a percentage scaling factor + * for an underlying quantization table, using our recommended scaling curve. + * The input 'quality' factor should be 0 (terrible) to 100 (very good). + */ +{ + /* Safety limit on quality factor. Convert 0 to 1 to avoid zero divide. */ + if (quality <= 0) quality = 1; + if (quality > 100) quality = 100; + + /* The basic table is used as-is (scaling 100) for a quality of 50. + * Qualities 50..100 are converted to scaling percentage 200 - 2*Q; + * note that at Q=100 the scaling is 0, which will cause jpeg_add_quant_table + * to make all the table entries 1 (hence, minimum quantization loss). + * Qualities 1..50 are converted to scaling percentage 5000/Q. + */ + if (quality < 50) + quality = 5000 / quality; + else + quality = 200 - quality*2; + + return quality; +} + + +GLOBAL(void) +jpeg_set_quality (j_compress_ptr cinfo, int quality, boolean force_baseline) +/* Set or change the 'quality' (quantization) setting, using default tables. + * This is the standard quality-adjusting entry point for typical user + * interfaces; only those who want detailed control over quantization tables + * would use the preceding three routines directly. + */ +{ + /* Convert user 0-100 rating to percentage scaling */ + quality = jpeg_quality_scaling(quality); + + /* Set up standard quality tables */ + jpeg_set_linear_quality(cinfo, quality, force_baseline); +} + + +/* + * Huffman table setup routines + */ + +LOCAL(void) +add_huff_table (j_compress_ptr cinfo, + JHUFF_TBL **htblptr, const UINT8 *bits, const UINT8 *val) +/* Define a Huffman table */ +{ + if (*htblptr == NULL) + *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); + + MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits)); + MEMCOPY((*htblptr)->huffval, val, SIZEOF((*htblptr)->huffval)); + + /* Initialize sent_table FALSE so table will be written to JPEG file. */ + (*htblptr)->sent_table = FALSE; +} + + +LOCAL(void) +std_huff_tables (j_compress_ptr cinfo) +/* Set up the standard Huffman tables (cf. JPEG standard section K.3) */ +/* IMPORTANT: these are only valid for 8-bit data precision! */ +{ + static const UINT8 bits_dc_luminance[17] = + { /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 }; + static const UINT8 val_dc_luminance[] = + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; + + static const UINT8 bits_dc_chrominance[17] = + { /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }; + static const UINT8 val_dc_chrominance[] = + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; + + static const UINT8 bits_ac_luminance[17] = + { /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d }; + static const UINT8 val_ac_luminance[] = + { 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, + 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, + 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, + 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, + 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, + 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, + 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, + 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, + 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, + 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, + 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, + 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, + 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, + 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, + 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, + 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, + 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, + 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, + 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, + 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, + 0xf9, 0xfa }; + + static const UINT8 bits_ac_chrominance[17] = + { /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 }; + static const UINT8 val_ac_chrominance[] = + { 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, + 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, + 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, + 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, + 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, + 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, + 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, + 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, + 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, + 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, + 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, + 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, + 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, + 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, + 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, + 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, + 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, + 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, + 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, + 0xf9, 0xfa }; + + add_huff_table(cinfo, &cinfo->dc_huff_tbl_ptrs[0], + bits_dc_luminance, val_dc_luminance); + add_huff_table(cinfo, &cinfo->ac_huff_tbl_ptrs[0], + bits_ac_luminance, val_ac_luminance); + add_huff_table(cinfo, &cinfo->dc_huff_tbl_ptrs[1], + bits_dc_chrominance, val_dc_chrominance); + add_huff_table(cinfo, &cinfo->ac_huff_tbl_ptrs[1], + bits_ac_chrominance, val_ac_chrominance); +} + + +/* + * Default parameter setup for compression. + * + * Applications that don't choose to use this routine must do their + * own setup of all these parameters. Alternately, you can call this + * to establish defaults and then alter parameters selectively. This + * is the recommended approach since, if we add any new parameters, + * your code will still work (they'll be set to reasonable defaults). + */ + +GLOBAL(void) +jpeg_set_defaults (j_compress_ptr cinfo) +{ + int i; + + /* Safety check to ensure start_compress not called yet. */ + if (cinfo->global_state != CSTATE_START) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + /* Allocate comp_info array large enough for maximum component count. + * Array is made permanent in case application wants to compress + * multiple images at same param settings. + */ + if (cinfo->comp_info == NULL) + cinfo->comp_info = (jpeg_component_info *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, + MAX_COMPONENTS * SIZEOF(jpeg_component_info)); + + /* Initialize everything not dependent on the color space */ + + cinfo->data_precision = BITS_IN_JSAMPLE; + /* Set up two quantization tables using default quality of 75 */ + jpeg_set_quality(cinfo, 75, TRUE); + /* Set up two Huffman tables */ + std_huff_tables(cinfo); + + /* Initialize default arithmetic coding conditioning */ + for (i = 0; i < NUM_ARITH_TBLS; i++) { + cinfo->arith_dc_L[i] = 0; + cinfo->arith_dc_U[i] = 1; + cinfo->arith_ac_K[i] = 5; + } + + /* Default is no multiple-scan output */ + cinfo->scan_info = NULL; + cinfo->num_scans = 0; + + /* Expect normal source image, not raw downsampled data */ + cinfo->raw_data_in = FALSE; + + /* Use Huffman coding, not arithmetic coding, by default */ + cinfo->arith_code = FALSE; + + /* By default, don't do extra passes to optimize entropy coding */ + cinfo->optimize_coding = FALSE; + /* The standard Huffman tables are only valid for 8-bit data precision. + * If the precision is higher, force optimization on so that usable + * tables will be computed. This test can be removed if default tables + * are supplied that are valid for the desired precision. + */ + if (cinfo->data_precision > 8) + cinfo->optimize_coding = TRUE; + + /* By default, use the simpler non-cosited sampling alignment */ + cinfo->CCIR601_sampling = FALSE; + + /* No input smoothing */ + cinfo->smoothing_factor = 0; + + /* DCT algorithm preference */ + cinfo->dct_method = JDCT_DEFAULT; + + /* No restart markers */ + cinfo->restart_interval = 0; + cinfo->restart_in_rows = 0; + + /* Fill in default JFIF marker parameters. Note that whether the marker + * will actually be written is determined by jpeg_set_colorspace. + */ + cinfo->density_unit = 0; /* Pixel size is unknown by default */ + cinfo->X_density = 1; /* Pixel aspect ratio is square by default */ + cinfo->Y_density = 1; + + /* Choose JPEG colorspace based on input space, set defaults accordingly */ + + jpeg_default_colorspace(cinfo); +} + + +/* + * Select an appropriate JPEG colorspace for in_color_space. + */ + +GLOBAL(void) +jpeg_default_colorspace (j_compress_ptr cinfo) +{ + switch (cinfo->in_color_space) { + case JCS_GRAYSCALE: + jpeg_set_colorspace(cinfo, JCS_GRAYSCALE); + break; + case JCS_RGB: + jpeg_set_colorspace(cinfo, JCS_YCbCr); + break; + case JCS_YCbCr: + jpeg_set_colorspace(cinfo, JCS_YCbCr); + break; + case JCS_CMYK: + jpeg_set_colorspace(cinfo, JCS_CMYK); /* By default, no translation */ + break; + case JCS_YCCK: + jpeg_set_colorspace(cinfo, JCS_YCCK); + break; + case JCS_UNKNOWN: + jpeg_set_colorspace(cinfo, JCS_UNKNOWN); + break; + default: + ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); + } +} + + +/* + * Set the JPEG colorspace, and choose colorspace-dependent default values. + */ + +GLOBAL(void) +jpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace) +{ + jpeg_component_info * compptr; + int ci; + +#define SET_COMP(index,id,hsamp,vsamp,quant,dctbl,actbl) \ + (compptr = &cinfo->comp_info[index], \ + compptr->component_id = (id), \ + compptr->h_samp_factor = (hsamp), \ + compptr->v_samp_factor = (vsamp), \ + compptr->quant_tbl_no = (quant), \ + compptr->dc_tbl_no = (dctbl), \ + compptr->ac_tbl_no = (actbl) ) + + /* Safety check to ensure start_compress not called yet. */ + if (cinfo->global_state != CSTATE_START) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + /* For all colorspaces, we use Q and Huff tables 0 for luminance components, + * tables 1 for chrominance components. + */ + + cinfo->jpeg_color_space = colorspace; + + cinfo->write_JFIF_header = FALSE; /* No marker for non-JFIF colorspaces */ + cinfo->write_Adobe_marker = FALSE; /* write no Adobe marker by default */ + + switch (colorspace) { + case JCS_GRAYSCALE: + cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */ + cinfo->num_components = 1; + /* JFIF specifies component ID 1 */ + SET_COMP(0, 1, 1,1, 0, 0,0); + break; + case JCS_RGB: + cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag RGB */ + cinfo->num_components = 3; + SET_COMP(0, 0x52 /* 'R' */, 1,1, 0, 0,0); + SET_COMP(1, 0x47 /* 'G' */, 1,1, 0, 0,0); + SET_COMP(2, 0x42 /* 'B' */, 1,1, 0, 0,0); + break; + case JCS_YCbCr: + cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */ + cinfo->num_components = 3; + /* JFIF specifies component IDs 1,2,3 */ + /* We default to 2x2 subsamples of chrominance */ + SET_COMP(0, 1, 2,2, 0, 0,0); + SET_COMP(1, 2, 1,1, 1, 1,1); + SET_COMP(2, 3, 1,1, 1, 1,1); + break; + case JCS_CMYK: + cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag CMYK */ + cinfo->num_components = 4; + SET_COMP(0, 0x43 /* 'C' */, 1,1, 0, 0,0); + SET_COMP(1, 0x4D /* 'M' */, 1,1, 0, 0,0); + SET_COMP(2, 0x59 /* 'Y' */, 1,1, 0, 0,0); + SET_COMP(3, 0x4B /* 'K' */, 1,1, 0, 0,0); + break; + case JCS_YCCK: + cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag YCCK */ + cinfo->num_components = 4; + SET_COMP(0, 1, 2,2, 0, 0,0); + SET_COMP(1, 2, 1,1, 1, 1,1); + SET_COMP(2, 3, 1,1, 1, 1,1); + SET_COMP(3, 4, 2,2, 0, 0,0); + break; + case JCS_UNKNOWN: + cinfo->num_components = cinfo->input_components; + if (cinfo->num_components < 1 || cinfo->num_components > MAX_COMPONENTS) + ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, + MAX_COMPONENTS); + for (ci = 0; ci < cinfo->num_components; ci++) { + SET_COMP(ci, ci, 1,1, 0, 0,0); + } + break; + default: + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + } +} + + +#ifdef C_PROGRESSIVE_SUPPORTED + +LOCAL(jpeg_scan_info *) +fill_a_scan (jpeg_scan_info * scanptr, int ci, + int Ss, int Se, int Ah, int Al) +/* Support routine: generate one scan for specified component */ +{ + scanptr->comps_in_scan = 1; + scanptr->component_index[0] = ci; + scanptr->Ss = Ss; + scanptr->Se = Se; + scanptr->Ah = Ah; + scanptr->Al = Al; + scanptr++; + return scanptr; +} + +LOCAL(jpeg_scan_info *) +fill_scans (jpeg_scan_info * scanptr, int ncomps, + int Ss, int Se, int Ah, int Al) +/* Support routine: generate one scan for each component */ +{ + int ci; + + for (ci = 0; ci < ncomps; ci++) { + scanptr->comps_in_scan = 1; + scanptr->component_index[0] = ci; + scanptr->Ss = Ss; + scanptr->Se = Se; + scanptr->Ah = Ah; + scanptr->Al = Al; + scanptr++; + } + return scanptr; +} + +LOCAL(jpeg_scan_info *) +fill_dc_scans (jpeg_scan_info * scanptr, int ncomps, int Ah, int Al) +/* Support routine: generate interleaved DC scan if possible, else N scans */ +{ + int ci; + + if (ncomps <= MAX_COMPS_IN_SCAN) { + /* Single interleaved DC scan */ + scanptr->comps_in_scan = ncomps; + for (ci = 0; ci < ncomps; ci++) + scanptr->component_index[ci] = ci; + scanptr->Ss = scanptr->Se = 0; + scanptr->Ah = Ah; + scanptr->Al = Al; + scanptr++; + } else { + /* Noninterleaved DC scan for each component */ + scanptr = fill_scans(scanptr, ncomps, 0, 0, Ah, Al); + } + return scanptr; +} + + +/* + * Create a recommended progressive-JPEG script. + * cinfo->num_components and cinfo->jpeg_color_space must be correct. + */ + +GLOBAL(void) +jpeg_simple_progression (j_compress_ptr cinfo) +{ + int ncomps = cinfo->num_components; + int nscans; + jpeg_scan_info * scanptr; + + /* Safety check to ensure start_compress not called yet. */ + if (cinfo->global_state != CSTATE_START) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + /* Figure space needed for script. Calculation must match code below! */ + if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) { + /* Custom script for YCbCr color images. */ + nscans = 10; + } else { + /* All-purpose script for other color spaces. */ + if (ncomps > MAX_COMPS_IN_SCAN) + nscans = 6 * ncomps; /* 2 DC + 4 AC scans per component */ + else + nscans = 2 + 4 * ncomps; /* 2 DC scans; 4 AC scans per component */ + } + + /* Allocate space for script. */ + /* We use permanent pool just in case application re-uses script. */ + scanptr = (jpeg_scan_info *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, + nscans * SIZEOF(jpeg_scan_info)); + cinfo->scan_info = scanptr; + cinfo->num_scans = nscans; + + if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) { + /* Custom script for YCbCr color images. */ + /* Initial DC scan */ + scanptr = fill_dc_scans(scanptr, ncomps, 0, 1); + /* Initial AC scan: get some luma data out in a hurry */ + scanptr = fill_a_scan(scanptr, 0, 1, 5, 0, 2); + /* Chroma data is too small to be worth expending many scans on */ + scanptr = fill_a_scan(scanptr, 2, 1, 63, 0, 1); + scanptr = fill_a_scan(scanptr, 1, 1, 63, 0, 1); + /* Complete spectral selection for luma AC */ + scanptr = fill_a_scan(scanptr, 0, 6, 63, 0, 2); + /* Refine next bit of luma AC */ + scanptr = fill_a_scan(scanptr, 0, 1, 63, 2, 1); + /* Finish DC successive approximation */ + scanptr = fill_dc_scans(scanptr, ncomps, 1, 0); + /* Finish AC successive approximation */ + scanptr = fill_a_scan(scanptr, 2, 1, 63, 1, 0); + scanptr = fill_a_scan(scanptr, 1, 1, 63, 1, 0); + /* Luma bottom bit comes last since it's usually largest scan */ + scanptr = fill_a_scan(scanptr, 0, 1, 63, 1, 0); + } else { + /* All-purpose script for other color spaces. */ + /* Successive approximation first pass */ + scanptr = fill_dc_scans(scanptr, ncomps, 0, 1); + scanptr = fill_scans(scanptr, ncomps, 1, 5, 0, 2); + scanptr = fill_scans(scanptr, ncomps, 6, 63, 0, 2); + /* Successive approximation second pass */ + scanptr = fill_scans(scanptr, ncomps, 1, 63, 2, 1); + /* Successive approximation final pass */ + scanptr = fill_dc_scans(scanptr, ncomps, 1, 0); + scanptr = fill_scans(scanptr, ncomps, 1, 63, 1, 0); + } +} + +#endif /* C_PROGRESSIVE_SUPPORTED */ diff --git a/gs/jpeg/jcphuff.c b/gs/jpeg/jcphuff.c new file mode 100644 index 000000000..9ace161cb --- /dev/null +++ b/gs/jpeg/jcphuff.c @@ -0,0 +1,829 @@ +/* + * jcphuff.c + * + * Copyright (C) 1995-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains Huffman entropy encoding routines for progressive JPEG. + * + * We do not support output suspension in this module, since the library + * currently does not allow multiple-scan files to be written with output + * suspension. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jchuff.h" /* Declarations shared with jchuff.c */ + +#ifdef C_PROGRESSIVE_SUPPORTED + +/* Expanded entropy encoder object for progressive Huffman encoding. */ + +typedef struct { + struct jpeg_entropy_encoder pub; /* public fields */ + + /* Mode flag: TRUE for optimization, FALSE for actual data output */ + boolean gather_statistics; + + /* Bit-level coding status. + * next_output_byte/free_in_buffer are local copies of cinfo->dest fields. + */ + JOCTET * next_output_byte; /* => next byte to write in buffer */ + size_t free_in_buffer; /* # of byte spaces remaining in buffer */ + INT32 put_buffer; /* current bit-accumulation buffer */ + int put_bits; /* # of bits now in it */ + j_compress_ptr cinfo; /* link to cinfo (needed for dump_buffer) */ + + /* Coding status for DC components */ + int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ + + /* Coding status for AC components */ + int ac_tbl_no; /* the table number of the single component */ + unsigned int EOBRUN; /* run length of EOBs */ + unsigned int BE; /* # of buffered correction bits before MCU */ + char * bit_buffer; /* buffer for correction bits (1 per char) */ + /* packing correction bits tightly would save some space but cost time... */ + + unsigned int restarts_to_go; /* MCUs left in this restart interval */ + int next_restart_num; /* next restart number to write (0-7) */ + + /* Pointers to derived tables (these workspaces have image lifespan). + * Since any one scan codes only DC or only AC, we only need one set + * of tables, not one for DC and one for AC. + */ + c_derived_tbl * derived_tbls[NUM_HUFF_TBLS]; + + /* Statistics tables for optimization; again, one set is enough */ + long * count_ptrs[NUM_HUFF_TBLS]; +} phuff_entropy_encoder; + +typedef phuff_entropy_encoder * phuff_entropy_ptr; + +/* MAX_CORR_BITS is the number of bits the AC refinement correction-bit + * buffer can hold. Larger sizes may slightly improve compression, but + * 1000 is already well into the realm of overkill. + * The minimum safe size is 64 bits. + */ + +#define MAX_CORR_BITS 1000 /* Max # of correction bits I can buffer */ + +/* IRIGHT_SHIFT is like RIGHT_SHIFT, but works on int rather than INT32. + * We assume that int right shift is unsigned if INT32 right shift is, + * which should be safe. + */ + +#ifdef RIGHT_SHIFT_IS_UNSIGNED +#define ISHIFT_TEMPS int ishift_temp; +#define IRIGHT_SHIFT(x,shft) \ + ((ishift_temp = (x)) < 0 ? \ + (ishift_temp >> (shft)) | ((~0) << (16-(shft))) : \ + (ishift_temp >> (shft))) +#else +#define ISHIFT_TEMPS +#define IRIGHT_SHIFT(x,shft) ((x) >> (shft)) +#endif + +/* Forward declarations */ +METHODDEF(boolean) encode_mcu_DC_first JPP((j_compress_ptr cinfo, + JBLOCKROW *MCU_data)); +METHODDEF(boolean) encode_mcu_AC_first JPP((j_compress_ptr cinfo, + JBLOCKROW *MCU_data)); +METHODDEF(boolean) encode_mcu_DC_refine JPP((j_compress_ptr cinfo, + JBLOCKROW *MCU_data)); +METHODDEF(boolean) encode_mcu_AC_refine JPP((j_compress_ptr cinfo, + JBLOCKROW *MCU_data)); +METHODDEF(void) finish_pass_phuff JPP((j_compress_ptr cinfo)); +METHODDEF(void) finish_pass_gather_phuff JPP((j_compress_ptr cinfo)); + + +/* + * Initialize for a Huffman-compressed scan using progressive JPEG. + */ + +METHODDEF(void) +start_pass_phuff (j_compress_ptr cinfo, boolean gather_statistics) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + boolean is_DC_band; + int ci, tbl; + jpeg_component_info * compptr; + + entropy->cinfo = cinfo; + entropy->gather_statistics = gather_statistics; + + is_DC_band = (cinfo->Ss == 0); + + /* We assume jcmaster.c already validated the scan parameters. */ + + /* Select execution routines */ + if (cinfo->Ah == 0) { + if (is_DC_band) + entropy->pub.encode_mcu = encode_mcu_DC_first; + else + entropy->pub.encode_mcu = encode_mcu_AC_first; + } else { + if (is_DC_band) + entropy->pub.encode_mcu = encode_mcu_DC_refine; + else { + entropy->pub.encode_mcu = encode_mcu_AC_refine; + /* AC refinement needs a correction bit buffer */ + if (entropy->bit_buffer == NULL) + entropy->bit_buffer = (char *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + MAX_CORR_BITS * SIZEOF(char)); + } + } + if (gather_statistics) + entropy->pub.finish_pass = finish_pass_gather_phuff; + else + entropy->pub.finish_pass = finish_pass_phuff; + + /* Only DC coefficients may be interleaved, so cinfo->comps_in_scan = 1 + * for AC coefficients. + */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + /* Initialize DC predictions to 0 */ + entropy->last_dc_val[ci] = 0; + /* Make sure requested tables are present */ + /* (In gather mode, tables need not be allocated yet) */ + if (is_DC_band) { + if (cinfo->Ah != 0) /* DC refinement needs no table */ + continue; + tbl = compptr->dc_tbl_no; + if (tbl < 0 || tbl >= NUM_HUFF_TBLS || + (cinfo->dc_huff_tbl_ptrs[tbl] == NULL && !gather_statistics)) + ERREXIT1(cinfo,JERR_NO_HUFF_TABLE, tbl); + } else { + entropy->ac_tbl_no = tbl = compptr->ac_tbl_no; + if (tbl < 0 || tbl >= NUM_HUFF_TBLS || + (cinfo->ac_huff_tbl_ptrs[tbl] == NULL && !gather_statistics)) + ERREXIT1(cinfo,JERR_NO_HUFF_TABLE, tbl); + } + if (gather_statistics) { + /* Allocate and zero the statistics tables */ + /* Note that jpeg_gen_optimal_table expects 257 entries in each table! */ + if (entropy->count_ptrs[tbl] == NULL) + entropy->count_ptrs[tbl] = (long *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + 257 * SIZEOF(long)); + MEMZERO(entropy->count_ptrs[tbl], 257 * SIZEOF(long)); + } else { + /* Compute derived values for Huffman tables */ + /* We may do this more than once for a table, but it's not expensive */ + if (is_DC_band) + jpeg_make_c_derived_tbl(cinfo, cinfo->dc_huff_tbl_ptrs[tbl], + & entropy->derived_tbls[tbl]); + else + jpeg_make_c_derived_tbl(cinfo, cinfo->ac_huff_tbl_ptrs[tbl], + & entropy->derived_tbls[tbl]); + } + } + + /* Initialize AC stuff */ + entropy->EOBRUN = 0; + entropy->BE = 0; + + /* Initialize bit buffer to empty */ + entropy->put_buffer = 0; + entropy->put_bits = 0; + + /* Initialize restart stuff */ + entropy->restarts_to_go = cinfo->restart_interval; + entropy->next_restart_num = 0; +} + + +/* Outputting bytes to the file. + * NB: these must be called only when actually outputting, + * that is, entropy->gather_statistics == FALSE. + */ + +/* Emit a byte */ +#define emit_byte(entropy,val) \ + { *(entropy)->next_output_byte++ = (JOCTET) (val); \ + if (--(entropy)->free_in_buffer == 0) \ + dump_buffer(entropy); } + + +LOCAL(void) +dump_buffer (phuff_entropy_ptr entropy) +/* Empty the output buffer; we do not support suspension in this module. */ +{ + struct jpeg_destination_mgr * dest = entropy->cinfo->dest; + + if (! (*dest->empty_output_buffer) (entropy->cinfo)) + ERREXIT(entropy->cinfo, JERR_CANT_SUSPEND); + /* After a successful buffer dump, must reset buffer pointers */ + entropy->next_output_byte = dest->next_output_byte; + entropy->free_in_buffer = dest->free_in_buffer; +} + + +/* Outputting bits to the file */ + +/* Only the right 24 bits of put_buffer are used; the valid bits are + * left-justified in this part. At most 16 bits can be passed to emit_bits + * in one call, and we never retain more than 7 bits in put_buffer + * between calls, so 24 bits are sufficient. + */ + +INLINE +LOCAL(void) +emit_bits (phuff_entropy_ptr entropy, unsigned int code, int size) +/* Emit some bits, unless we are in gather mode */ +{ + /* This routine is heavily used, so it's worth coding tightly. */ + register INT32 put_buffer = (INT32) code; + register int put_bits = entropy->put_bits; + + /* if size is 0, caller used an invalid Huffman table entry */ + if (size == 0) + ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE); + + if (entropy->gather_statistics) + return; /* do nothing if we're only getting stats */ + + put_buffer &= (((INT32) 1)<put_buffer; /* and merge with old buffer contents */ + + while (put_bits >= 8) { + int c = (int) ((put_buffer >> 16) & 0xFF); + + emit_byte(entropy, c); + if (c == 0xFF) { /* need to stuff a zero byte? */ + emit_byte(entropy, 0); + } + put_buffer <<= 8; + put_bits -= 8; + } + + entropy->put_buffer = put_buffer; /* update variables */ + entropy->put_bits = put_bits; +} + + +LOCAL(void) +flush_bits (phuff_entropy_ptr entropy) +{ + emit_bits(entropy, 0x7F, 7); /* fill any partial byte with ones */ + entropy->put_buffer = 0; /* and reset bit-buffer to empty */ + entropy->put_bits = 0; +} + + +/* + * Emit (or just count) a Huffman symbol. + */ + +INLINE +LOCAL(void) +emit_symbol (phuff_entropy_ptr entropy, int tbl_no, int symbol) +{ + if (entropy->gather_statistics) + entropy->count_ptrs[tbl_no][symbol]++; + else { + c_derived_tbl * tbl = entropy->derived_tbls[tbl_no]; + emit_bits(entropy, tbl->ehufco[symbol], tbl->ehufsi[symbol]); + } +} + + +/* + * Emit bits from a correction bit buffer. + */ + +LOCAL(void) +emit_buffered_bits (phuff_entropy_ptr entropy, char * bufstart, + unsigned int nbits) +{ + if (entropy->gather_statistics) + return; /* no real work */ + + while (nbits > 0) { + emit_bits(entropy, (unsigned int) (*bufstart), 1); + bufstart++; + nbits--; + } +} + + +/* + * Emit any pending EOBRUN symbol. + */ + +LOCAL(void) +emit_eobrun (phuff_entropy_ptr entropy) +{ + register int temp, nbits; + + if (entropy->EOBRUN > 0) { /* if there is any pending EOBRUN */ + temp = entropy->EOBRUN; + nbits = 0; + while ((temp >>= 1)) + nbits++; + + emit_symbol(entropy, entropy->ac_tbl_no, nbits << 4); + if (nbits) + emit_bits(entropy, entropy->EOBRUN, nbits); + + entropy->EOBRUN = 0; + + /* Emit any buffered correction bits */ + emit_buffered_bits(entropy, entropy->bit_buffer, entropy->BE); + entropy->BE = 0; + } +} + + +/* + * Emit a restart marker & resynchronize predictions. + */ + +LOCAL(void) +emit_restart (phuff_entropy_ptr entropy, int restart_num) +{ + int ci; + + emit_eobrun(entropy); + + if (! entropy->gather_statistics) { + flush_bits(entropy); + emit_byte(entropy, 0xFF); + emit_byte(entropy, JPEG_RST0 + restart_num); + } + + if (entropy->cinfo->Ss == 0) { + /* Re-initialize DC predictions to 0 */ + for (ci = 0; ci < entropy->cinfo->comps_in_scan; ci++) + entropy->last_dc_val[ci] = 0; + } else { + /* Re-initialize all AC-related fields to 0 */ + entropy->EOBRUN = 0; + entropy->BE = 0; + } +} + + +/* + * MCU encoding for DC initial scan (either spectral selection, + * or first pass of successive approximation). + */ + +METHODDEF(boolean) +encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + register int temp, temp2; + register int nbits; + int blkn, ci; + int Al = cinfo->Al; + JBLOCKROW block; + jpeg_component_info * compptr; + ISHIFT_TEMPS + + entropy->next_output_byte = cinfo->dest->next_output_byte; + entropy->free_in_buffer = cinfo->dest->free_in_buffer; + + /* Emit restart marker if needed */ + if (cinfo->restart_interval) + if (entropy->restarts_to_go == 0) + emit_restart(entropy, entropy->next_restart_num); + + /* Encode the MCU data blocks */ + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + block = MCU_data[blkn]; + ci = cinfo->MCU_membership[blkn]; + compptr = cinfo->cur_comp_info[ci]; + + /* Compute the DC value after the required point transform by Al. + * This is simply an arithmetic right shift. + */ + temp2 = IRIGHT_SHIFT((int) ((*block)[0]), Al); + + /* DC differences are figured on the point-transformed values. */ + temp = temp2 - entropy->last_dc_val[ci]; + entropy->last_dc_val[ci] = temp2; + + /* Encode the DC coefficient difference per section G.1.2.1 */ + temp2 = temp; + if (temp < 0) { + temp = -temp; /* temp is abs value of input */ + /* For a negative input, want temp2 = bitwise complement of abs(input) */ + /* This code assumes we are on a two's complement machine */ + temp2--; + } + + /* Find the number of bits needed for the magnitude of the coefficient */ + nbits = 0; + while (temp) { + nbits++; + temp >>= 1; + } + + /* Count/emit the Huffman-coded symbol for the number of bits */ + emit_symbol(entropy, compptr->dc_tbl_no, nbits); + + /* Emit that number of bits of the value, if positive, */ + /* or the complement of its magnitude, if negative. */ + if (nbits) /* emit_bits rejects calls with size 0 */ + emit_bits(entropy, (unsigned int) temp2, nbits); + } + + cinfo->dest->next_output_byte = entropy->next_output_byte; + cinfo->dest->free_in_buffer = entropy->free_in_buffer; + + /* Update restart-interval state too */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) { + entropy->restarts_to_go = cinfo->restart_interval; + entropy->next_restart_num++; + entropy->next_restart_num &= 7; + } + entropy->restarts_to_go--; + } + + return TRUE; +} + + +/* + * MCU encoding for AC initial scan (either spectral selection, + * or first pass of successive approximation). + */ + +METHODDEF(boolean) +encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + register int temp, temp2; + register int nbits; + register int r, k; + int Se = cinfo->Se; + int Al = cinfo->Al; + JBLOCKROW block; + + entropy->next_output_byte = cinfo->dest->next_output_byte; + entropy->free_in_buffer = cinfo->dest->free_in_buffer; + + /* Emit restart marker if needed */ + if (cinfo->restart_interval) + if (entropy->restarts_to_go == 0) + emit_restart(entropy, entropy->next_restart_num); + + /* Encode the MCU data block */ + block = MCU_data[0]; + + /* Encode the AC coefficients per section G.1.2.2, fig. G.3 */ + + r = 0; /* r = run length of zeros */ + + for (k = cinfo->Ss; k <= Se; k++) { + if ((temp = (*block)[jpeg_natural_order[k]]) == 0) { + r++; + continue; + } + /* We must apply the point transform by Al. For AC coefficients this + * is an integer division with rounding towards 0. To do this portably + * in C, we shift after obtaining the absolute value; so the code is + * interwoven with finding the abs value (temp) and output bits (temp2). + */ + if (temp < 0) { + temp = -temp; /* temp is abs value of input */ + temp >>= Al; /* apply the point transform */ + /* For a negative coef, want temp2 = bitwise complement of abs(coef) */ + temp2 = ~temp; + } else { + temp >>= Al; /* apply the point transform */ + temp2 = temp; + } + /* Watch out for case that nonzero coef is zero after point transform */ + if (temp == 0) { + r++; + continue; + } + + /* Emit any pending EOBRUN */ + if (entropy->EOBRUN > 0) + emit_eobrun(entropy); + /* if run length > 15, must emit special run-length-16 codes (0xF0) */ + while (r > 15) { + emit_symbol(entropy, entropy->ac_tbl_no, 0xF0); + r -= 16; + } + + /* Find the number of bits needed for the magnitude of the coefficient */ + nbits = 1; /* there must be at least one 1 bit */ + while ((temp >>= 1)) + nbits++; + + /* Count/emit Huffman symbol for run length / number of bits */ + emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + nbits); + + /* Emit that number of bits of the value, if positive, */ + /* or the complement of its magnitude, if negative. */ + emit_bits(entropy, (unsigned int) temp2, nbits); + + r = 0; /* reset zero run length */ + } + + if (r > 0) { /* If there are trailing zeroes, */ + entropy->EOBRUN++; /* count an EOB */ + if (entropy->EOBRUN == 0x7FFF) + emit_eobrun(entropy); /* force it out to avoid overflow */ + } + + cinfo->dest->next_output_byte = entropy->next_output_byte; + cinfo->dest->free_in_buffer = entropy->free_in_buffer; + + /* Update restart-interval state too */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) { + entropy->restarts_to_go = cinfo->restart_interval; + entropy->next_restart_num++; + entropy->next_restart_num &= 7; + } + entropy->restarts_to_go--; + } + + return TRUE; +} + + +/* + * MCU encoding for DC successive approximation refinement scan. + * Note: we assume such scans can be multi-component, although the spec + * is not very clear on the point. + */ + +METHODDEF(boolean) +encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + register int temp; + int blkn; + int Al = cinfo->Al; + JBLOCKROW block; + + entropy->next_output_byte = cinfo->dest->next_output_byte; + entropy->free_in_buffer = cinfo->dest->free_in_buffer; + + /* Emit restart marker if needed */ + if (cinfo->restart_interval) + if (entropy->restarts_to_go == 0) + emit_restart(entropy, entropy->next_restart_num); + + /* Encode the MCU data blocks */ + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + block = MCU_data[blkn]; + + /* We simply emit the Al'th bit of the DC coefficient value. */ + temp = (*block)[0]; + emit_bits(entropy, (unsigned int) (temp >> Al), 1); + } + + cinfo->dest->next_output_byte = entropy->next_output_byte; + cinfo->dest->free_in_buffer = entropy->free_in_buffer; + + /* Update restart-interval state too */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) { + entropy->restarts_to_go = cinfo->restart_interval; + entropy->next_restart_num++; + entropy->next_restart_num &= 7; + } + entropy->restarts_to_go--; + } + + return TRUE; +} + + +/* + * MCU encoding for AC successive approximation refinement scan. + */ + +METHODDEF(boolean) +encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + register int temp; + register int r, k; + int EOB; + char *BR_buffer; + unsigned int BR; + int Se = cinfo->Se; + int Al = cinfo->Al; + JBLOCKROW block; + int absvalues[DCTSIZE2]; + + entropy->next_output_byte = cinfo->dest->next_output_byte; + entropy->free_in_buffer = cinfo->dest->free_in_buffer; + + /* Emit restart marker if needed */ + if (cinfo->restart_interval) + if (entropy->restarts_to_go == 0) + emit_restart(entropy, entropy->next_restart_num); + + /* Encode the MCU data block */ + block = MCU_data[0]; + + /* It is convenient to make a pre-pass to determine the transformed + * coefficients' absolute values and the EOB position. + */ + EOB = 0; + for (k = cinfo->Ss; k <= Se; k++) { + temp = (*block)[jpeg_natural_order[k]]; + /* We must apply the point transform by Al. For AC coefficients this + * is an integer division with rounding towards 0. To do this portably + * in C, we shift after obtaining the absolute value. + */ + if (temp < 0) + temp = -temp; /* temp is abs value of input */ + temp >>= Al; /* apply the point transform */ + absvalues[k] = temp; /* save abs value for main pass */ + if (temp == 1) + EOB = k; /* EOB = index of last newly-nonzero coef */ + } + + /* Encode the AC coefficients per section G.1.2.3, fig. G.7 */ + + r = 0; /* r = run length of zeros */ + BR = 0; /* BR = count of buffered bits added now */ + BR_buffer = entropy->bit_buffer + entropy->BE; /* Append bits to buffer */ + + for (k = cinfo->Ss; k <= Se; k++) { + if ((temp = absvalues[k]) == 0) { + r++; + continue; + } + + /* Emit any required ZRLs, but not if they can be folded into EOB */ + while (r > 15 && k <= EOB) { + /* emit any pending EOBRUN and the BE correction bits */ + emit_eobrun(entropy); + /* Emit ZRL */ + emit_symbol(entropy, entropy->ac_tbl_no, 0xF0); + r -= 16; + /* Emit buffered correction bits that must be associated with ZRL */ + emit_buffered_bits(entropy, BR_buffer, BR); + BR_buffer = entropy->bit_buffer; /* BE bits are gone now */ + BR = 0; + } + + /* If the coef was previously nonzero, it only needs a correction bit. + * NOTE: a straight translation of the spec's figure G.7 would suggest + * that we also need to test r > 15. But if r > 15, we can only get here + * if k > EOB, which implies that this coefficient is not 1. + */ + if (temp > 1) { + /* The correction bit is the next bit of the absolute value. */ + BR_buffer[BR++] = (char) (temp & 1); + continue; + } + + /* Emit any pending EOBRUN and the BE correction bits */ + emit_eobrun(entropy); + + /* Count/emit Huffman symbol for run length / number of bits */ + emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + 1); + + /* Emit output bit for newly-nonzero coef */ + temp = ((*block)[jpeg_natural_order[k]] < 0) ? 0 : 1; + emit_bits(entropy, (unsigned int) temp, 1); + + /* Emit buffered correction bits that must be associated with this code */ + emit_buffered_bits(entropy, BR_buffer, BR); + BR_buffer = entropy->bit_buffer; /* BE bits are gone now */ + BR = 0; + r = 0; /* reset zero run length */ + } + + if (r > 0 || BR > 0) { /* If there are trailing zeroes, */ + entropy->EOBRUN++; /* count an EOB */ + entropy->BE += BR; /* concat my correction bits to older ones */ + /* We force out the EOB if we risk either: + * 1. overflow of the EOB counter; + * 2. overflow of the correction bit buffer during the next MCU. + */ + if (entropy->EOBRUN == 0x7FFF || entropy->BE > (MAX_CORR_BITS-DCTSIZE2+1)) + emit_eobrun(entropy); + } + + cinfo->dest->next_output_byte = entropy->next_output_byte; + cinfo->dest->free_in_buffer = entropy->free_in_buffer; + + /* Update restart-interval state too */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) { + entropy->restarts_to_go = cinfo->restart_interval; + entropy->next_restart_num++; + entropy->next_restart_num &= 7; + } + entropy->restarts_to_go--; + } + + return TRUE; +} + + +/* + * Finish up at the end of a Huffman-compressed progressive scan. + */ + +METHODDEF(void) +finish_pass_phuff (j_compress_ptr cinfo) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + + entropy->next_output_byte = cinfo->dest->next_output_byte; + entropy->free_in_buffer = cinfo->dest->free_in_buffer; + + /* Flush out any buffered data */ + emit_eobrun(entropy); + flush_bits(entropy); + + cinfo->dest->next_output_byte = entropy->next_output_byte; + cinfo->dest->free_in_buffer = entropy->free_in_buffer; +} + + +/* + * Finish up a statistics-gathering pass and create the new Huffman tables. + */ + +METHODDEF(void) +finish_pass_gather_phuff (j_compress_ptr cinfo) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + boolean is_DC_band; + int ci, tbl; + jpeg_component_info * compptr; + JHUFF_TBL **htblptr; + boolean did[NUM_HUFF_TBLS]; + + /* Flush out buffered data (all we care about is counting the EOB symbol) */ + emit_eobrun(entropy); + + is_DC_band = (cinfo->Ss == 0); + + /* It's important not to apply jpeg_gen_optimal_table more than once + * per table, because it clobbers the input frequency counts! + */ + MEMZERO(did, SIZEOF(did)); + + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + if (is_DC_band) { + if (cinfo->Ah != 0) /* DC refinement needs no table */ + continue; + tbl = compptr->dc_tbl_no; + } else { + tbl = compptr->ac_tbl_no; + } + if (! did[tbl]) { + if (is_DC_band) + htblptr = & cinfo->dc_huff_tbl_ptrs[tbl]; + else + htblptr = & cinfo->ac_huff_tbl_ptrs[tbl]; + if (*htblptr == NULL) + *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); + jpeg_gen_optimal_table(cinfo, *htblptr, entropy->count_ptrs[tbl]); + did[tbl] = TRUE; + } + } +} + + +/* + * Module initialization routine for progressive Huffman entropy encoding. + */ + +GLOBAL(void) +jinit_phuff_encoder (j_compress_ptr cinfo) +{ + phuff_entropy_ptr entropy; + int i; + + entropy = (phuff_entropy_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(phuff_entropy_encoder)); + cinfo->entropy = (struct jpeg_entropy_encoder *) entropy; + entropy->pub.start_pass = start_pass_phuff; + + /* Mark tables unallocated */ + for (i = 0; i < NUM_HUFF_TBLS; i++) { + entropy->derived_tbls[i] = NULL; + entropy->count_ptrs[i] = NULL; + } + entropy->bit_buffer = NULL; /* needed only in AC refinement scan */ +} + +#endif /* C_PROGRESSIVE_SUPPORTED */ diff --git a/gs/jpeg/jcprepct.c b/gs/jpeg/jcprepct.c new file mode 100644 index 000000000..fa93333db --- /dev/null +++ b/gs/jpeg/jcprepct.c @@ -0,0 +1,354 @@ +/* + * jcprepct.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the compression preprocessing controller. + * This controller manages the color conversion, downsampling, + * and edge expansion steps. + * + * Most of the complexity here is associated with buffering input rows + * as required by the downsampler. See the comments at the head of + * jcsample.c for the downsampler's needs. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* At present, jcsample.c can request context rows only for smoothing. + * In the future, we might also need context rows for CCIR601 sampling + * or other more-complex downsampling procedures. The code to support + * context rows should be compiled only if needed. + */ +#ifdef INPUT_SMOOTHING_SUPPORTED +#define CONTEXT_ROWS_SUPPORTED +#endif + + +/* + * For the simple (no-context-row) case, we just need to buffer one + * row group's worth of pixels for the downsampling step. At the bottom of + * the image, we pad to a full row group by replicating the last pixel row. + * The downsampler's last output row is then replicated if needed to pad + * out to a full iMCU row. + * + * When providing context rows, we must buffer three row groups' worth of + * pixels. Three row groups are physically allocated, but the row pointer + * arrays are made five row groups high, with the extra pointers above and + * below "wrapping around" to point to the last and first real row groups. + * This allows the downsampler to access the proper context rows. + * At the top and bottom of the image, we create dummy context rows by + * copying the first or last real pixel row. This copying could be avoided + * by pointer hacking as is done in jdmainct.c, but it doesn't seem worth the + * trouble on the compression side. + */ + + +/* Private buffer controller object */ + +typedef struct { + struct jpeg_c_prep_controller pub; /* public fields */ + + /* Downsampling input buffer. This buffer holds color-converted data + * until we have enough to do a downsample step. + */ + JSAMPARRAY color_buf[MAX_COMPONENTS]; + + JDIMENSION rows_to_go; /* counts rows remaining in source image */ + int next_buf_row; /* index of next row to store in color_buf */ + +#ifdef CONTEXT_ROWS_SUPPORTED /* only needed for context case */ + int this_row_group; /* starting row index of group to process */ + int next_buf_stop; /* downsample when we reach this index */ +#endif +} my_prep_controller; + +typedef my_prep_controller * my_prep_ptr; + + +/* + * Initialize for a processing pass. + */ + +METHODDEF(void) +start_pass_prep (j_compress_ptr cinfo, J_BUF_MODE pass_mode) +{ + my_prep_ptr prep = (my_prep_ptr) cinfo->prep; + + if (pass_mode != JBUF_PASS_THRU) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + + /* Initialize total-height counter for detecting bottom of image */ + prep->rows_to_go = cinfo->image_height; + /* Mark the conversion buffer empty */ + prep->next_buf_row = 0; +#ifdef CONTEXT_ROWS_SUPPORTED + /* Preset additional state variables for context mode. + * These aren't used in non-context mode, so we needn't test which mode. + */ + prep->this_row_group = 0; + /* Set next_buf_stop to stop after two row groups have been read in. */ + prep->next_buf_stop = 2 * cinfo->max_v_samp_factor; +#endif +} + + +/* + * Expand an image vertically from height input_rows to height output_rows, + * by duplicating the bottom row. + */ + +LOCAL(void) +expand_bottom_edge (JSAMPARRAY image_data, JDIMENSION num_cols, + int input_rows, int output_rows) +{ + register int row; + + for (row = input_rows; row < output_rows; row++) { + jcopy_sample_rows(image_data, input_rows-1, image_data, row, + 1, num_cols); + } +} + + +/* + * Process some data in the simple no-context case. + * + * Preprocessor output data is counted in "row groups". A row group + * is defined to be v_samp_factor sample rows of each component. + * Downsampling will produce this much data from each max_v_samp_factor + * input rows. + */ + +METHODDEF(void) +pre_process_data (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, + JDIMENSION in_rows_avail, + JSAMPIMAGE output_buf, JDIMENSION *out_row_group_ctr, + JDIMENSION out_row_groups_avail) +{ + my_prep_ptr prep = (my_prep_ptr) cinfo->prep; + int numrows, ci; + JDIMENSION inrows; + jpeg_component_info * compptr; + + while (*in_row_ctr < in_rows_avail && + *out_row_group_ctr < out_row_groups_avail) { + /* Do color conversion to fill the conversion buffer. */ + inrows = in_rows_avail - *in_row_ctr; + numrows = cinfo->max_v_samp_factor - prep->next_buf_row; + numrows = (int) MIN((JDIMENSION) numrows, inrows); + (*cinfo->cconvert->color_convert) (cinfo, input_buf + *in_row_ctr, + prep->color_buf, + (JDIMENSION) prep->next_buf_row, + numrows); + *in_row_ctr += numrows; + prep->next_buf_row += numrows; + prep->rows_to_go -= numrows; + /* If at bottom of image, pad to fill the conversion buffer. */ + if (prep->rows_to_go == 0 && + prep->next_buf_row < cinfo->max_v_samp_factor) { + for (ci = 0; ci < cinfo->num_components; ci++) { + expand_bottom_edge(prep->color_buf[ci], cinfo->image_width, + prep->next_buf_row, cinfo->max_v_samp_factor); + } + prep->next_buf_row = cinfo->max_v_samp_factor; + } + /* If we've filled the conversion buffer, empty it. */ + if (prep->next_buf_row == cinfo->max_v_samp_factor) { + (*cinfo->downsample->downsample) (cinfo, + prep->color_buf, (JDIMENSION) 0, + output_buf, *out_row_group_ctr); + prep->next_buf_row = 0; + (*out_row_group_ctr)++; + } + /* If at bottom of image, pad the output to a full iMCU height. + * Note we assume the caller is providing a one-iMCU-height output buffer! + */ + if (prep->rows_to_go == 0 && + *out_row_group_ctr < out_row_groups_avail) { + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + expand_bottom_edge(output_buf[ci], + compptr->width_in_blocks * DCTSIZE, + (int) (*out_row_group_ctr * compptr->v_samp_factor), + (int) (out_row_groups_avail * compptr->v_samp_factor)); + } + *out_row_group_ctr = out_row_groups_avail; + break; /* can exit outer loop without test */ + } + } +} + + +#ifdef CONTEXT_ROWS_SUPPORTED + +/* + * Process some data in the context case. + */ + +METHODDEF(void) +pre_process_context (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, + JDIMENSION in_rows_avail, + JSAMPIMAGE output_buf, JDIMENSION *out_row_group_ctr, + JDIMENSION out_row_groups_avail) +{ + my_prep_ptr prep = (my_prep_ptr) cinfo->prep; + int numrows, ci; + int buf_height = cinfo->max_v_samp_factor * 3; + JDIMENSION inrows; + + while (*out_row_group_ctr < out_row_groups_avail) { + if (*in_row_ctr < in_rows_avail) { + /* Do color conversion to fill the conversion buffer. */ + inrows = in_rows_avail - *in_row_ctr; + numrows = prep->next_buf_stop - prep->next_buf_row; + numrows = (int) MIN((JDIMENSION) numrows, inrows); + (*cinfo->cconvert->color_convert) (cinfo, input_buf + *in_row_ctr, + prep->color_buf, + (JDIMENSION) prep->next_buf_row, + numrows); + /* Pad at top of image, if first time through */ + if (prep->rows_to_go == cinfo->image_height) { + for (ci = 0; ci < cinfo->num_components; ci++) { + int row; + for (row = 1; row <= cinfo->max_v_samp_factor; row++) { + jcopy_sample_rows(prep->color_buf[ci], 0, + prep->color_buf[ci], -row, + 1, cinfo->image_width); + } + } + } + *in_row_ctr += numrows; + prep->next_buf_row += numrows; + prep->rows_to_go -= numrows; + } else { + /* Return for more data, unless we are at the bottom of the image. */ + if (prep->rows_to_go != 0) + break; + /* When at bottom of image, pad to fill the conversion buffer. */ + if (prep->next_buf_row < prep->next_buf_stop) { + for (ci = 0; ci < cinfo->num_components; ci++) { + expand_bottom_edge(prep->color_buf[ci], cinfo->image_width, + prep->next_buf_row, prep->next_buf_stop); + } + prep->next_buf_row = prep->next_buf_stop; + } + } + /* If we've gotten enough data, downsample a row group. */ + if (prep->next_buf_row == prep->next_buf_stop) { + (*cinfo->downsample->downsample) (cinfo, + prep->color_buf, + (JDIMENSION) prep->this_row_group, + output_buf, *out_row_group_ctr); + (*out_row_group_ctr)++; + /* Advance pointers with wraparound as necessary. */ + prep->this_row_group += cinfo->max_v_samp_factor; + if (prep->this_row_group >= buf_height) + prep->this_row_group = 0; + if (prep->next_buf_row >= buf_height) + prep->next_buf_row = 0; + prep->next_buf_stop = prep->next_buf_row + cinfo->max_v_samp_factor; + } + } +} + + +/* + * Create the wrapped-around downsampling input buffer needed for context mode. + */ + +LOCAL(void) +create_context_buffer (j_compress_ptr cinfo) +{ + my_prep_ptr prep = (my_prep_ptr) cinfo->prep; + int rgroup_height = cinfo->max_v_samp_factor; + int ci, i; + jpeg_component_info * compptr; + JSAMPARRAY true_buffer, fake_buffer; + + /* Grab enough space for fake row pointers for all the components; + * we need five row groups' worth of pointers for each component. + */ + fake_buffer = (JSAMPARRAY) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (cinfo->num_components * 5 * rgroup_height) * + SIZEOF(JSAMPROW)); + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Allocate the actual buffer space (3 row groups) for this component. + * We make the buffer wide enough to allow the downsampler to edge-expand + * horizontally within the buffer, if it so chooses. + */ + true_buffer = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) (((long) compptr->width_in_blocks * DCTSIZE * + cinfo->max_h_samp_factor) / compptr->h_samp_factor), + (JDIMENSION) (3 * rgroup_height)); + /* Copy true buffer row pointers into the middle of the fake row array */ + MEMCOPY(fake_buffer + rgroup_height, true_buffer, + 3 * rgroup_height * SIZEOF(JSAMPROW)); + /* Fill in the above and below wraparound pointers */ + for (i = 0; i < rgroup_height; i++) { + fake_buffer[i] = true_buffer[2 * rgroup_height + i]; + fake_buffer[4 * rgroup_height + i] = true_buffer[i]; + } + prep->color_buf[ci] = fake_buffer + rgroup_height; + fake_buffer += 5 * rgroup_height; /* point to space for next component */ + } +} + +#endif /* CONTEXT_ROWS_SUPPORTED */ + + +/* + * Initialize preprocessing controller. + */ + +GLOBAL(void) +jinit_c_prep_controller (j_compress_ptr cinfo, boolean need_full_buffer) +{ + my_prep_ptr prep; + int ci; + jpeg_component_info * compptr; + + if (need_full_buffer) /* safety check */ + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + + prep = (my_prep_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_prep_controller)); + cinfo->prep = (struct jpeg_c_prep_controller *) prep; + prep->pub.start_pass = start_pass_prep; + + /* Allocate the color conversion buffer. + * We make the buffer wide enough to allow the downsampler to edge-expand + * horizontally within the buffer, if it so chooses. + */ + if (cinfo->downsample->need_context_rows) { + /* Set up to provide context rows */ +#ifdef CONTEXT_ROWS_SUPPORTED + prep->pub.pre_process_data = pre_process_context; + create_context_buffer(cinfo); +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } else { + /* No context, just make it tall enough for one row group */ + prep->pub.pre_process_data = pre_process_data; + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + prep->color_buf[ci] = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) (((long) compptr->width_in_blocks * DCTSIZE * + cinfo->max_h_samp_factor) / compptr->h_samp_factor), + (JDIMENSION) cinfo->max_v_samp_factor); + } + } +} diff --git a/gs/jpeg/jcsample.c b/gs/jpeg/jcsample.c new file mode 100644 index 000000000..212ec8757 --- /dev/null +++ b/gs/jpeg/jcsample.c @@ -0,0 +1,519 @@ +/* + * jcsample.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains downsampling routines. + * + * Downsampling input data is counted in "row groups". A row group + * is defined to be max_v_samp_factor pixel rows of each component, + * from which the downsampler produces v_samp_factor sample rows. + * A single row group is processed in each call to the downsampler module. + * + * The downsampler is responsible for edge-expansion of its output data + * to fill an integral number of DCT blocks horizontally. The source buffer + * may be modified if it is helpful for this purpose (the source buffer is + * allocated wide enough to correspond to the desired output width). + * The caller (the prep controller) is responsible for vertical padding. + * + * The downsampler may request "context rows" by setting need_context_rows + * during startup. In this case, the input arrays will contain at least + * one row group's worth of pixels above and below the passed-in data; + * the caller will create dummy rows at image top and bottom by replicating + * the first or last real pixel row. + * + * An excellent reference for image resampling is + * Digital Image Warping, George Wolberg, 1990. + * Pub. by IEEE Computer Society Press, Los Alamitos, CA. ISBN 0-8186-8944-7. + * + * The downsampling algorithm used here is a simple average of the source + * pixels covered by the output pixel. The hi-falutin sampling literature + * refers to this as a "box filter". In general the characteristics of a box + * filter are not very good, but for the specific cases we normally use (1:1 + * and 2:1 ratios) the box is equivalent to a "triangle filter" which is not + * nearly so bad. If you intend to use other sampling ratios, you'd be well + * advised to improve this code. + * + * A simple input-smoothing capability is provided. This is mainly intended + * for cleaning up color-dithered GIF input files (if you find it inadequate, + * we suggest using an external filtering program such as pnmconvol). When + * enabled, each input pixel P is replaced by a weighted sum of itself and its + * eight neighbors. P's weight is 1-8*SF and each neighbor's weight is SF, + * where SF = (smoothing_factor / 1024). + * Currently, smoothing is only supported for 2h2v sampling factors. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Pointer to routine to downsample a single component */ +typedef JMETHOD(void, downsample1_ptr, + (j_compress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY output_data)); + +/* Private subobject */ + +typedef struct { + struct jpeg_downsampler pub; /* public fields */ + + /* Downsampling method pointers, one per component */ + downsample1_ptr methods[MAX_COMPONENTS]; +} my_downsampler; + +typedef my_downsampler * my_downsample_ptr; + + +/* + * Initialize for a downsampling pass. + */ + +METHODDEF(void) +start_pass_downsample (j_compress_ptr cinfo) +{ + /* no work for now */ +} + + +/* + * Expand a component horizontally from width input_cols to width output_cols, + * by duplicating the rightmost samples. + */ + +LOCAL(void) +expand_right_edge (JSAMPARRAY image_data, int num_rows, + JDIMENSION input_cols, JDIMENSION output_cols) +{ + register JSAMPROW ptr; + register JSAMPLE pixval; + register int count; + int row; + int numcols = (int) (output_cols - input_cols); + + if (numcols > 0) { + for (row = 0; row < num_rows; row++) { + ptr = image_data[row] + input_cols; + pixval = ptr[-1]; /* don't need GETJSAMPLE() here */ + for (count = numcols; count > 0; count--) + *ptr++ = pixval; + } + } +} + + +/* + * Do downsampling for a whole row group (all components). + * + * In this version we simply downsample each component independently. + */ + +METHODDEF(void) +sep_downsample (j_compress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION in_row_index, + JSAMPIMAGE output_buf, JDIMENSION out_row_group_index) +{ + my_downsample_ptr downsample = (my_downsample_ptr) cinfo->downsample; + int ci; + jpeg_component_info * compptr; + JSAMPARRAY in_ptr, out_ptr; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + in_ptr = input_buf[ci] + in_row_index; + out_ptr = output_buf[ci] + (out_row_group_index * compptr->v_samp_factor); + (*downsample->methods[ci]) (cinfo, compptr, in_ptr, out_ptr); + } +} + + +/* + * Downsample pixel values of a single component. + * One row group is processed per call. + * This version handles arbitrary integral sampling ratios, without smoothing. + * Note that this version is not actually used for customary sampling ratios. + */ + +METHODDEF(void) +int_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY output_data) +{ + int inrow, outrow, h_expand, v_expand, numpix, numpix2, h, v; + JDIMENSION outcol, outcol_h; /* outcol_h == outcol*h_expand */ + JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; + JSAMPROW inptr, outptr; + INT32 outvalue; + + h_expand = cinfo->max_h_samp_factor / compptr->h_samp_factor; + v_expand = cinfo->max_v_samp_factor / compptr->v_samp_factor; + numpix = h_expand * v_expand; + numpix2 = numpix/2; + + /* Expand input data enough to let all the output samples be generated + * by the standard loop. Special-casing padded output would be more + * efficient. + */ + expand_right_edge(input_data, cinfo->max_v_samp_factor, + cinfo->image_width, output_cols * h_expand); + + inrow = 0; + for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { + outptr = output_data[outrow]; + for (outcol = 0, outcol_h = 0; outcol < output_cols; + outcol++, outcol_h += h_expand) { + outvalue = 0; + for (v = 0; v < v_expand; v++) { + inptr = input_data[inrow+v] + outcol_h; + for (h = 0; h < h_expand; h++) { + outvalue += (INT32) GETJSAMPLE(*inptr++); + } + } + *outptr++ = (JSAMPLE) ((outvalue + numpix2) / numpix); + } + inrow += v_expand; + } +} + + +/* + * Downsample pixel values of a single component. + * This version handles the special case of a full-size component, + * without smoothing. + */ + +METHODDEF(void) +fullsize_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY output_data) +{ + /* Copy the data */ + jcopy_sample_rows(input_data, 0, output_data, 0, + cinfo->max_v_samp_factor, cinfo->image_width); + /* Edge-expand */ + expand_right_edge(output_data, cinfo->max_v_samp_factor, + cinfo->image_width, compptr->width_in_blocks * DCTSIZE); +} + + +/* + * Downsample pixel values of a single component. + * This version handles the common case of 2:1 horizontal and 1:1 vertical, + * without smoothing. + * + * A note about the "bias" calculations: when rounding fractional values to + * integer, we do not want to always round 0.5 up to the next integer. + * If we did that, we'd introduce a noticeable bias towards larger values. + * Instead, this code is arranged so that 0.5 will be rounded up or down at + * alternate pixel locations (a simple ordered dither pattern). + */ + +METHODDEF(void) +h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY output_data) +{ + int outrow; + JDIMENSION outcol; + JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; + register JSAMPROW inptr, outptr; + register int bias; + + /* Expand input data enough to let all the output samples be generated + * by the standard loop. Special-casing padded output would be more + * efficient. + */ + expand_right_edge(input_data, cinfo->max_v_samp_factor, + cinfo->image_width, output_cols * 2); + + for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { + outptr = output_data[outrow]; + inptr = input_data[outrow]; + bias = 0; /* bias = 0,1,0,1,... for successive samples */ + for (outcol = 0; outcol < output_cols; outcol++) { + *outptr++ = (JSAMPLE) ((GETJSAMPLE(*inptr) + GETJSAMPLE(inptr[1]) + + bias) >> 1); + bias ^= 1; /* 0=>1, 1=>0 */ + inptr += 2; + } + } +} + + +/* + * Downsample pixel values of a single component. + * This version handles the standard case of 2:1 horizontal and 2:1 vertical, + * without smoothing. + */ + +METHODDEF(void) +h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY output_data) +{ + int inrow, outrow; + JDIMENSION outcol; + JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; + register JSAMPROW inptr0, inptr1, outptr; + register int bias; + + /* Expand input data enough to let all the output samples be generated + * by the standard loop. Special-casing padded output would be more + * efficient. + */ + expand_right_edge(input_data, cinfo->max_v_samp_factor, + cinfo->image_width, output_cols * 2); + + inrow = 0; + for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { + outptr = output_data[outrow]; + inptr0 = input_data[inrow]; + inptr1 = input_data[inrow+1]; + bias = 1; /* bias = 1,2,1,2,... for successive samples */ + for (outcol = 0; outcol < output_cols; outcol++) { + *outptr++ = (JSAMPLE) ((GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + + GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]) + + bias) >> 2); + bias ^= 3; /* 1=>2, 2=>1 */ + inptr0 += 2; inptr1 += 2; + } + inrow += 2; + } +} + + +#ifdef INPUT_SMOOTHING_SUPPORTED + +/* + * Downsample pixel values of a single component. + * This version handles the standard case of 2:1 horizontal and 2:1 vertical, + * with smoothing. One row of context is required. + */ + +METHODDEF(void) +h2v2_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY output_data) +{ + int inrow, outrow; + JDIMENSION colctr; + JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; + register JSAMPROW inptr0, inptr1, above_ptr, below_ptr, outptr; + INT32 membersum, neighsum, memberscale, neighscale; + + /* Expand input data enough to let all the output samples be generated + * by the standard loop. Special-casing padded output would be more + * efficient. + */ + expand_right_edge(input_data - 1, cinfo->max_v_samp_factor + 2, + cinfo->image_width, output_cols * 2); + + /* We don't bother to form the individual "smoothed" input pixel values; + * we can directly compute the output which is the average of the four + * smoothed values. Each of the four member pixels contributes a fraction + * (1-8*SF) to its own smoothed image and a fraction SF to each of the three + * other smoothed pixels, therefore a total fraction (1-5*SF)/4 to the final + * output. The four corner-adjacent neighbor pixels contribute a fraction + * SF to just one smoothed pixel, or SF/4 to the final output; while the + * eight edge-adjacent neighbors contribute SF to each of two smoothed + * pixels, or SF/2 overall. In order to use integer arithmetic, these + * factors are scaled by 2^16 = 65536. + * Also recall that SF = smoothing_factor / 1024. + */ + + memberscale = 16384 - cinfo->smoothing_factor * 80; /* scaled (1-5*SF)/4 */ + neighscale = cinfo->smoothing_factor * 16; /* scaled SF/4 */ + + inrow = 0; + for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { + outptr = output_data[outrow]; + inptr0 = input_data[inrow]; + inptr1 = input_data[inrow+1]; + above_ptr = input_data[inrow-1]; + below_ptr = input_data[inrow+2]; + + /* Special case for first column: pretend column -1 is same as column 0 */ + membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + + GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]); + neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) + + GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) + + GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[2]) + + GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[2]); + neighsum += neighsum; + neighsum += GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[2]) + + GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[2]); + membersum = membersum * memberscale + neighsum * neighscale; + *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); + inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2; + + for (colctr = output_cols - 2; colctr > 0; colctr--) { + /* sum of pixels directly mapped to this output element */ + membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + + GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]); + /* sum of edge-neighbor pixels */ + neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) + + GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) + + GETJSAMPLE(inptr0[-1]) + GETJSAMPLE(inptr0[2]) + + GETJSAMPLE(inptr1[-1]) + GETJSAMPLE(inptr1[2]); + /* The edge-neighbors count twice as much as corner-neighbors */ + neighsum += neighsum; + /* Add in the corner-neighbors */ + neighsum += GETJSAMPLE(above_ptr[-1]) + GETJSAMPLE(above_ptr[2]) + + GETJSAMPLE(below_ptr[-1]) + GETJSAMPLE(below_ptr[2]); + /* form final output scaled up by 2^16 */ + membersum = membersum * memberscale + neighsum * neighscale; + /* round, descale and output it */ + *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); + inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2; + } + + /* Special case for last column */ + membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + + GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]); + neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) + + GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) + + GETJSAMPLE(inptr0[-1]) + GETJSAMPLE(inptr0[1]) + + GETJSAMPLE(inptr1[-1]) + GETJSAMPLE(inptr1[1]); + neighsum += neighsum; + neighsum += GETJSAMPLE(above_ptr[-1]) + GETJSAMPLE(above_ptr[1]) + + GETJSAMPLE(below_ptr[-1]) + GETJSAMPLE(below_ptr[1]); + membersum = membersum * memberscale + neighsum * neighscale; + *outptr = (JSAMPLE) ((membersum + 32768) >> 16); + + inrow += 2; + } +} + + +/* + * Downsample pixel values of a single component. + * This version handles the special case of a full-size component, + * with smoothing. One row of context is required. + */ + +METHODDEF(void) +fullsize_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr, + JSAMPARRAY input_data, JSAMPARRAY output_data) +{ + int outrow; + JDIMENSION colctr; + JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; + register JSAMPROW inptr, above_ptr, below_ptr, outptr; + INT32 membersum, neighsum, memberscale, neighscale; + int colsum, lastcolsum, nextcolsum; + + /* Expand input data enough to let all the output samples be generated + * by the standard loop. Special-casing padded output would be more + * efficient. + */ + expand_right_edge(input_data - 1, cinfo->max_v_samp_factor + 2, + cinfo->image_width, output_cols); + + /* Each of the eight neighbor pixels contributes a fraction SF to the + * smoothed pixel, while the main pixel contributes (1-8*SF). In order + * to use integer arithmetic, these factors are multiplied by 2^16 = 65536. + * Also recall that SF = smoothing_factor / 1024. + */ + + memberscale = 65536L - cinfo->smoothing_factor * 512L; /* scaled 1-8*SF */ + neighscale = cinfo->smoothing_factor * 64; /* scaled SF */ + + for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { + outptr = output_data[outrow]; + inptr = input_data[outrow]; + above_ptr = input_data[outrow-1]; + below_ptr = input_data[outrow+1]; + + /* Special case for first column */ + colsum = GETJSAMPLE(*above_ptr++) + GETJSAMPLE(*below_ptr++) + + GETJSAMPLE(*inptr); + membersum = GETJSAMPLE(*inptr++); + nextcolsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(*below_ptr) + + GETJSAMPLE(*inptr); + neighsum = colsum + (colsum - membersum) + nextcolsum; + membersum = membersum * memberscale + neighsum * neighscale; + *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); + lastcolsum = colsum; colsum = nextcolsum; + + for (colctr = output_cols - 2; colctr > 0; colctr--) { + membersum = GETJSAMPLE(*inptr++); + above_ptr++; below_ptr++; + nextcolsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(*below_ptr) + + GETJSAMPLE(*inptr); + neighsum = lastcolsum + (colsum - membersum) + nextcolsum; + membersum = membersum * memberscale + neighsum * neighscale; + *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); + lastcolsum = colsum; colsum = nextcolsum; + } + + /* Special case for last column */ + membersum = GETJSAMPLE(*inptr); + neighsum = lastcolsum + (colsum - membersum) + colsum; + membersum = membersum * memberscale + neighsum * neighscale; + *outptr = (JSAMPLE) ((membersum + 32768) >> 16); + + } +} + +#endif /* INPUT_SMOOTHING_SUPPORTED */ + + +/* + * Module initialization routine for downsampling. + * Note that we must select a routine for each component. + */ + +GLOBAL(void) +jinit_downsampler (j_compress_ptr cinfo) +{ + my_downsample_ptr downsample; + int ci; + jpeg_component_info * compptr; + boolean smoothok = TRUE; + + downsample = (my_downsample_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_downsampler)); + cinfo->downsample = (struct jpeg_downsampler *) downsample; + downsample->pub.start_pass = start_pass_downsample; + downsample->pub.downsample = sep_downsample; + downsample->pub.need_context_rows = FALSE; + + if (cinfo->CCIR601_sampling) + ERREXIT(cinfo, JERR_CCIR601_NOTIMPL); + + /* Verify we can handle the sampling factors, and set up method pointers */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + if (compptr->h_samp_factor == cinfo->max_h_samp_factor && + compptr->v_samp_factor == cinfo->max_v_samp_factor) { +#ifdef INPUT_SMOOTHING_SUPPORTED + if (cinfo->smoothing_factor) { + downsample->methods[ci] = fullsize_smooth_downsample; + downsample->pub.need_context_rows = TRUE; + } else +#endif + downsample->methods[ci] = fullsize_downsample; + } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor && + compptr->v_samp_factor == cinfo->max_v_samp_factor) { + smoothok = FALSE; + downsample->methods[ci] = h2v1_downsample; + } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor && + compptr->v_samp_factor * 2 == cinfo->max_v_samp_factor) { +#ifdef INPUT_SMOOTHING_SUPPORTED + if (cinfo->smoothing_factor) { + downsample->methods[ci] = h2v2_smooth_downsample; + downsample->pub.need_context_rows = TRUE; + } else +#endif + downsample->methods[ci] = h2v2_downsample; + } else if ((cinfo->max_h_samp_factor % compptr->h_samp_factor) == 0 && + (cinfo->max_v_samp_factor % compptr->v_samp_factor) == 0) { + smoothok = FALSE; + downsample->methods[ci] = int_downsample; + } else + ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL); + } + +#ifdef INPUT_SMOOTHING_SUPPORTED + if (cinfo->smoothing_factor && !smoothok) + TRACEMS(cinfo, 0, JTRC_SMOOTH_NOTIMPL); +#endif +} diff --git a/gs/jpeg/jctrans.c b/gs/jpeg/jctrans.c new file mode 100644 index 000000000..429604868 --- /dev/null +++ b/gs/jpeg/jctrans.c @@ -0,0 +1,371 @@ +/* + * jctrans.c + * + * Copyright (C) 1995-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains library routines for transcoding compression, + * that is, writing raw DCT coefficient arrays to an output JPEG file. + * The routines in jcapimin.c will also be needed by a transcoder. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Forward declarations */ +LOCAL(void) transencode_master_selection + JPP((j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays)); +LOCAL(void) transencode_coef_controller + JPP((j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays)); + + +/* + * Compression initialization for writing raw-coefficient data. + * Before calling this, all parameters and a data destination must be set up. + * Call jpeg_finish_compress() to actually write the data. + * + * The number of passed virtual arrays must match cinfo->num_components. + * Note that the virtual arrays need not be filled or even realized at + * the time write_coefficients is called; indeed, if the virtual arrays + * were requested from this compression object's memory manager, they + * typically will be realized during this routine and filled afterwards. + */ + +GLOBAL(void) +jpeg_write_coefficients (j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays) +{ + if (cinfo->global_state != CSTATE_START) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + /* Mark all tables to be written */ + jpeg_suppress_tables(cinfo, FALSE); + /* (Re)initialize error mgr and destination modules */ + (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); + (*cinfo->dest->init_destination) (cinfo); + /* Perform master selection of active modules */ + transencode_master_selection(cinfo, coef_arrays); + /* Wait for jpeg_finish_compress() call */ + cinfo->next_scanline = 0; /* so jpeg_write_marker works */ + cinfo->global_state = CSTATE_WRCOEFS; +} + + +/* + * Initialize the compression object with default parameters, + * then copy from the source object all parameters needed for lossless + * transcoding. Parameters that can be varied without loss (such as + * scan script and Huffman optimization) are left in their default states. + */ + +GLOBAL(void) +jpeg_copy_critical_parameters (j_decompress_ptr srcinfo, + j_compress_ptr dstinfo) +{ + JQUANT_TBL ** qtblptr; + jpeg_component_info *incomp, *outcomp; + JQUANT_TBL *c_quant, *slot_quant; + int tblno, ci, coefi; + + /* Safety check to ensure start_compress not called yet. */ + if (dstinfo->global_state != CSTATE_START) + ERREXIT1(dstinfo, JERR_BAD_STATE, dstinfo->global_state); + /* Copy fundamental image dimensions */ + dstinfo->image_width = srcinfo->image_width; + dstinfo->image_height = srcinfo->image_height; + dstinfo->input_components = srcinfo->num_components; + dstinfo->in_color_space = srcinfo->jpeg_color_space; + /* Initialize all parameters to default values */ + jpeg_set_defaults(dstinfo); + /* jpeg_set_defaults may choose wrong colorspace, eg YCbCr if input is RGB. + * Fix it to get the right header markers for the image colorspace. + */ + jpeg_set_colorspace(dstinfo, srcinfo->jpeg_color_space); + dstinfo->data_precision = srcinfo->data_precision; + dstinfo->CCIR601_sampling = srcinfo->CCIR601_sampling; + /* Copy the source's quantization tables. */ + for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) { + if (srcinfo->quant_tbl_ptrs[tblno] != NULL) { + qtblptr = & dstinfo->quant_tbl_ptrs[tblno]; + if (*qtblptr == NULL) + *qtblptr = jpeg_alloc_quant_table((j_common_ptr) dstinfo); + MEMCOPY((*qtblptr)->quantval, + srcinfo->quant_tbl_ptrs[tblno]->quantval, + SIZEOF((*qtblptr)->quantval)); + (*qtblptr)->sent_table = FALSE; + } + } + /* Copy the source's per-component info. + * Note we assume jpeg_set_defaults has allocated the dest comp_info array. + */ + dstinfo->num_components = srcinfo->num_components; + if (dstinfo->num_components < 1 || dstinfo->num_components > MAX_COMPONENTS) + ERREXIT2(dstinfo, JERR_COMPONENT_COUNT, dstinfo->num_components, + MAX_COMPONENTS); + for (ci = 0, incomp = srcinfo->comp_info, outcomp = dstinfo->comp_info; + ci < dstinfo->num_components; ci++, incomp++, outcomp++) { + outcomp->component_id = incomp->component_id; + outcomp->h_samp_factor = incomp->h_samp_factor; + outcomp->v_samp_factor = incomp->v_samp_factor; + outcomp->quant_tbl_no = incomp->quant_tbl_no; + /* Make sure saved quantization table for component matches the qtable + * slot. If not, the input file re-used this qtable slot. + * IJG encoder currently cannot duplicate this. + */ + tblno = outcomp->quant_tbl_no; + if (tblno < 0 || tblno >= NUM_QUANT_TBLS || + srcinfo->quant_tbl_ptrs[tblno] == NULL) + ERREXIT1(dstinfo, JERR_NO_QUANT_TABLE, tblno); + slot_quant = srcinfo->quant_tbl_ptrs[tblno]; + c_quant = incomp->quant_table; + if (c_quant != NULL) { + for (coefi = 0; coefi < DCTSIZE2; coefi++) { + if (c_quant->quantval[coefi] != slot_quant->quantval[coefi]) + ERREXIT1(dstinfo, JERR_MISMATCHED_QUANT_TABLE, tblno); + } + } + /* Note: we do not copy the source's Huffman table assignments; + * instead we rely on jpeg_set_colorspace to have made a suitable choice. + */ + } +} + + +/* + * Master selection of compression modules for transcoding. + * This substitutes for jcinit.c's initialization of the full compressor. + */ + +LOCAL(void) +transencode_master_selection (j_compress_ptr cinfo, + jvirt_barray_ptr * coef_arrays) +{ + /* Although we don't actually use input_components for transcoding, + * jcmaster.c's initial_setup will complain if input_components is 0. + */ + cinfo->input_components = 1; + /* Initialize master control (includes parameter checking/processing) */ + jinit_c_master_control(cinfo, TRUE /* transcode only */); + + /* Entropy encoding: either Huffman or arithmetic coding. */ + if (cinfo->arith_code) { + ERREXIT(cinfo, JERR_ARITH_NOTIMPL); + } else { + if (cinfo->progressive_mode) { +#ifdef C_PROGRESSIVE_SUPPORTED + jinit_phuff_encoder(cinfo); +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } else + jinit_huff_encoder(cinfo); + } + + /* We need a special coefficient buffer controller. */ + transencode_coef_controller(cinfo, coef_arrays); + + jinit_marker_writer(cinfo); + + /* We can now tell the memory manager to allocate virtual arrays. */ + (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); + + /* Write the datastream header (SOI) immediately. + * Frame and scan headers are postponed till later. + * This lets application insert special markers after the SOI. + */ + (*cinfo->marker->write_file_header) (cinfo); +} + + +/* + * The rest of this file is a special implementation of the coefficient + * buffer controller. This is similar to jccoefct.c, but it handles only + * output from presupplied virtual arrays. Furthermore, we generate any + * dummy padding blocks on-the-fly rather than expecting them to be present + * in the arrays. + */ + +/* Private buffer controller object */ + +typedef struct { + struct jpeg_c_coef_controller pub; /* public fields */ + + JDIMENSION iMCU_row_num; /* iMCU row # within image */ + JDIMENSION mcu_ctr; /* counts MCUs processed in current row */ + int MCU_vert_offset; /* counts MCU rows within iMCU row */ + int MCU_rows_per_iMCU_row; /* number of such rows needed */ + + /* Virtual block array for each component. */ + jvirt_barray_ptr * whole_image; + + /* Workspace for constructing dummy blocks at right/bottom edges. */ + JBLOCKROW dummy_buffer[C_MAX_BLOCKS_IN_MCU]; +} my_coef_controller; + +typedef my_coef_controller * my_coef_ptr; + + +LOCAL(void) +start_iMCU_row (j_compress_ptr cinfo) +/* Reset within-iMCU-row counters for a new row */ +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + + /* In an interleaved scan, an MCU row is the same as an iMCU row. + * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. + * But at the bottom of the image, process only what's left. + */ + if (cinfo->comps_in_scan > 1) { + coef->MCU_rows_per_iMCU_row = 1; + } else { + if (coef->iMCU_row_num < (cinfo->total_iMCU_rows-1)) + coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; + else + coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; + } + + coef->mcu_ctr = 0; + coef->MCU_vert_offset = 0; +} + + +/* + * Initialize for a processing pass. + */ + +METHODDEF(void) +start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + + if (pass_mode != JBUF_CRANK_DEST) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + + coef->iMCU_row_num = 0; + start_iMCU_row(cinfo); +} + + +/* + * Process some data. + * We process the equivalent of one fully interleaved MCU row ("iMCU" row) + * per call, ie, v_samp_factor block rows for each component in the scan. + * The data is obtained from the virtual arrays and fed to the entropy coder. + * Returns TRUE if the iMCU row is completed, FALSE if suspended. + * + * NB: input_buf is ignored; it is likely to be a NULL pointer. + */ + +METHODDEF(boolean) +compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + JDIMENSION MCU_col_num; /* index of current MCU within row */ + JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; + JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; + int blkn, ci, xindex, yindex, yoffset, blockcnt; + JDIMENSION start_col; + JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; + JBLOCKROW MCU_buffer[C_MAX_BLOCKS_IN_MCU]; + JBLOCKROW buffer_ptr; + jpeg_component_info *compptr; + + /* Align the virtual buffers for the components used in this scan. */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + buffer[ci] = (*cinfo->mem->access_virt_barray) + ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index], + coef->iMCU_row_num * compptr->v_samp_factor, + (JDIMENSION) compptr->v_samp_factor, FALSE); + } + + /* Loop to process one whole iMCU row */ + for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; + yoffset++) { + for (MCU_col_num = coef->mcu_ctr; MCU_col_num < cinfo->MCUs_per_row; + MCU_col_num++) { + /* Construct list of pointers to DCT blocks belonging to this MCU */ + blkn = 0; /* index of current DCT block within MCU */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + start_col = MCU_col_num * compptr->MCU_width; + blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width + : compptr->last_col_width; + for (yindex = 0; yindex < compptr->MCU_height; yindex++) { + if (coef->iMCU_row_num < last_iMCU_row || + yindex+yoffset < compptr->last_row_height) { + /* Fill in pointers to real blocks in this row */ + buffer_ptr = buffer[ci][yindex+yoffset] + start_col; + for (xindex = 0; xindex < blockcnt; xindex++) + MCU_buffer[blkn++] = buffer_ptr++; + } else { + /* At bottom of image, need a whole row of dummy blocks */ + xindex = 0; + } + /* Fill in any dummy blocks needed in this row. + * Dummy blocks are filled in the same way as in jccoefct.c: + * all zeroes in the AC entries, DC entries equal to previous + * block's DC value. The init routine has already zeroed the + * AC entries, so we need only set the DC entries correctly. + */ + for (; xindex < compptr->MCU_width; xindex++) { + MCU_buffer[blkn] = coef->dummy_buffer[blkn]; + MCU_buffer[blkn][0][0] = MCU_buffer[blkn-1][0][0]; + blkn++; + } + } + } + /* Try to write the MCU. */ + if (! (*cinfo->entropy->encode_mcu) (cinfo, MCU_buffer)) { + /* Suspension forced; update state counters and exit */ + coef->MCU_vert_offset = yoffset; + coef->mcu_ctr = MCU_col_num; + return FALSE; + } + } + /* Completed an MCU row, but perhaps not an iMCU row */ + coef->mcu_ctr = 0; + } + /* Completed the iMCU row, advance counters for next one */ + coef->iMCU_row_num++; + start_iMCU_row(cinfo); + return TRUE; +} + + +/* + * Initialize coefficient buffer controller. + * + * Each passed coefficient array must be the right size for that + * coefficient: width_in_blocks wide and height_in_blocks high, + * with unitheight at least v_samp_factor. + */ + +LOCAL(void) +transencode_coef_controller (j_compress_ptr cinfo, + jvirt_barray_ptr * coef_arrays) +{ + my_coef_ptr coef; + JBLOCKROW buffer; + int i; + + coef = (my_coef_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_coef_controller)); + cinfo->coef = (struct jpeg_c_coef_controller *) coef; + coef->pub.start_pass = start_pass_coef; + coef->pub.compress_data = compress_output; + + /* Save pointer to virtual arrays */ + coef->whole_image = coef_arrays; + + /* Allocate and pre-zero space for dummy DCT blocks. */ + buffer = (JBLOCKROW) + (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, + C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); + jzero_far((void FAR *) buffer, C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); + for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) { + coef->dummy_buffer[i] = buffer + i; + } +} diff --git a/gs/jpeg/jdapimin.c b/gs/jpeg/jdapimin.c new file mode 100644 index 000000000..c70215425 --- /dev/null +++ b/gs/jpeg/jdapimin.c @@ -0,0 +1,406 @@ +/* + * jdapimin.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains application interface code for the decompression half + * of the JPEG library. These are the "minimum" API routines that may be + * needed in either the normal full-decompression case or the + * transcoding-only case. + * + * Most of the routines intended to be called directly by an application + * are in this file or in jdapistd.c. But also see jcomapi.c for routines + * shared by compression and decompression, and jdtrans.c for the transcoding + * case. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* + * Initialization of a JPEG decompression object. + * The error manager must already be set up (in case memory manager fails). + */ + +GLOBAL(void) +jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize) +{ + int i; + + /* Guard against version mismatches between library and caller. */ + cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */ + if (version != JPEG_LIB_VERSION) + ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version); + if (structsize != SIZEOF(struct jpeg_decompress_struct)) + ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, + (int) SIZEOF(struct jpeg_decompress_struct), (int) structsize); + + /* For debugging purposes, zero the whole master structure. + * But error manager pointer is already there, so save and restore it. + */ + { + struct jpeg_error_mgr * err = cinfo->err; + MEMZERO(cinfo, SIZEOF(struct jpeg_decompress_struct)); + cinfo->err = err; + } + cinfo->is_decompressor = TRUE; + + /* Initialize a memory manager instance for this object */ + jinit_memory_mgr((j_common_ptr) cinfo); + + /* Zero out pointers to permanent structures. */ + cinfo->progress = NULL; + cinfo->src = NULL; + + for (i = 0; i < NUM_QUANT_TBLS; i++) + cinfo->quant_tbl_ptrs[i] = NULL; + + for (i = 0; i < NUM_HUFF_TBLS; i++) { + cinfo->dc_huff_tbl_ptrs[i] = NULL; + cinfo->ac_huff_tbl_ptrs[i] = NULL; + } + + /* Initialize marker processor so application can override methods + * for COM, APPn markers before calling jpeg_read_header. + */ + jinit_marker_reader(cinfo); + + /* And initialize the overall input controller. */ + jinit_input_controller(cinfo); + + /* OK, I'm ready */ + cinfo->global_state = DSTATE_START; +} + + +/* + * Destruction of a JPEG decompression object + */ + +GLOBAL(void) +jpeg_destroy_decompress (j_decompress_ptr cinfo) +{ + jpeg_destroy((j_common_ptr) cinfo); /* use common routine */ +} + + +/* + * Abort processing of a JPEG decompression operation, + * but don't destroy the object itself. + */ + +GLOBAL(void) +jpeg_abort_decompress (j_decompress_ptr cinfo) +{ + jpeg_abort((j_common_ptr) cinfo); /* use common routine */ +} + + +/* + * Install a special processing method for COM or APPn markers. + */ + +GLOBAL(void) +jpeg_set_marker_processor (j_decompress_ptr cinfo, int marker_code, + jpeg_marker_parser_method routine) +{ + if (marker_code == JPEG_COM) + cinfo->marker->process_COM = routine; + else if (marker_code >= JPEG_APP0 && marker_code <= JPEG_APP0+15) + cinfo->marker->process_APPn[marker_code-JPEG_APP0] = routine; + else + ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code); +} + + +/* + * Set default decompression parameters. + */ + +LOCAL(void) +default_decompress_parms (j_decompress_ptr cinfo) +{ + /* Guess the input colorspace, and set output colorspace accordingly. */ + /* (Wish JPEG committee had provided a real way to specify this...) */ + /* Note application may override our guesses. */ + switch (cinfo->num_components) { + case 1: + cinfo->jpeg_color_space = JCS_GRAYSCALE; + cinfo->out_color_space = JCS_GRAYSCALE; + break; + + case 3: + if (cinfo->saw_JFIF_marker) { + cinfo->jpeg_color_space = JCS_YCbCr; /* JFIF implies YCbCr */ + } else if (cinfo->saw_Adobe_marker) { + switch (cinfo->Adobe_transform) { + case 0: + cinfo->jpeg_color_space = JCS_RGB; + break; + case 1: + cinfo->jpeg_color_space = JCS_YCbCr; + break; + default: + WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform); + cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */ + break; + } + } else { + /* Saw no special markers, try to guess from the component IDs */ + int cid0 = cinfo->comp_info[0].component_id; + int cid1 = cinfo->comp_info[1].component_id; + int cid2 = cinfo->comp_info[2].component_id; + + if (cid0 == 1 && cid1 == 2 && cid2 == 3) + cinfo->jpeg_color_space = JCS_YCbCr; /* assume JFIF w/out marker */ + else if (cid0 == 82 && cid1 == 71 && cid2 == 66) + cinfo->jpeg_color_space = JCS_RGB; /* ASCII 'R', 'G', 'B' */ + else { + TRACEMS3(cinfo, 1, JTRC_UNKNOWN_IDS, cid0, cid1, cid2); + cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */ + } + } + /* Always guess RGB is proper output colorspace. */ + cinfo->out_color_space = JCS_RGB; + break; + + case 4: + if (cinfo->saw_Adobe_marker) { + switch (cinfo->Adobe_transform) { + case 0: + cinfo->jpeg_color_space = JCS_CMYK; + break; + case 2: + cinfo->jpeg_color_space = JCS_YCCK; + break; + default: + WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform); + cinfo->jpeg_color_space = JCS_YCCK; /* assume it's YCCK */ + break; + } + } else { + /* No special markers, assume straight CMYK. */ + cinfo->jpeg_color_space = JCS_CMYK; + } + cinfo->out_color_space = JCS_CMYK; + break; + + default: + cinfo->jpeg_color_space = JCS_UNKNOWN; + cinfo->out_color_space = JCS_UNKNOWN; + break; + } + + /* Set defaults for other decompression parameters. */ + cinfo->scale_num = 1; /* 1:1 scaling */ + cinfo->scale_denom = 1; + cinfo->output_gamma = 1.0; + cinfo->buffered_image = FALSE; + cinfo->raw_data_out = FALSE; + cinfo->dct_method = JDCT_DEFAULT; + cinfo->do_fancy_upsampling = TRUE; + cinfo->do_block_smoothing = TRUE; + cinfo->quantize_colors = FALSE; + /* We set these in case application only sets quantize_colors. */ + cinfo->dither_mode = JDITHER_FS; +#ifdef QUANT_2PASS_SUPPORTED + cinfo->two_pass_quantize = TRUE; +#else + cinfo->two_pass_quantize = FALSE; +#endif + cinfo->desired_number_of_colors = 256; + cinfo->colormap = NULL; + /* Initialize for no mode change in buffered-image mode. */ + cinfo->enable_1pass_quant = FALSE; + cinfo->enable_external_quant = FALSE; + cinfo->enable_2pass_quant = FALSE; +} + + +/* + * Decompression startup: read start of JPEG datastream to see what's there. + * Need only initialize JPEG object and supply a data source before calling. + * + * This routine will read as far as the first SOS marker (ie, actual start of + * compressed data), and will save all tables and parameters in the JPEG + * object. It will also initialize the decompression parameters to default + * values, and finally return JPEG_HEADER_OK. On return, the application may + * adjust the decompression parameters and then call jpeg_start_decompress. + * (Or, if the application only wanted to determine the image parameters, + * the data need not be decompressed. In that case, call jpeg_abort or + * jpeg_destroy to release any temporary space.) + * If an abbreviated (tables only) datastream is presented, the routine will + * return JPEG_HEADER_TABLES_ONLY upon reaching EOI. The application may then + * re-use the JPEG object to read the abbreviated image datastream(s). + * It is unnecessary (but OK) to call jpeg_abort in this case. + * The JPEG_SUSPENDED return code only occurs if the data source module + * requests suspension of the decompressor. In this case the application + * should load more source data and then re-call jpeg_read_header to resume + * processing. + * If a non-suspending data source is used and require_image is TRUE, then the + * return code need not be inspected since only JPEG_HEADER_OK is possible. + * + * This routine is now just a front end to jpeg_consume_input, with some + * extra error checking. + */ + +GLOBAL(int) +jpeg_read_header (j_decompress_ptr cinfo, boolean require_image) +{ + int retcode; + + if (cinfo->global_state != DSTATE_START && + cinfo->global_state != DSTATE_INHEADER) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + retcode = jpeg_consume_input(cinfo); + + switch (retcode) { + case JPEG_REACHED_SOS: + retcode = JPEG_HEADER_OK; + break; + case JPEG_REACHED_EOI: + if (require_image) /* Complain if application wanted an image */ + ERREXIT(cinfo, JERR_NO_IMAGE); + /* Reset to start state; it would be safer to require the application to + * call jpeg_abort, but we can't change it now for compatibility reasons. + * A side effect is to free any temporary memory (there shouldn't be any). + */ + jpeg_abort((j_common_ptr) cinfo); /* sets state = DSTATE_START */ + retcode = JPEG_HEADER_TABLES_ONLY; + break; + case JPEG_SUSPENDED: + /* no work */ + break; + } + + return retcode; +} + + +/* + * Consume data in advance of what the decompressor requires. + * This can be called at any time once the decompressor object has + * been created and a data source has been set up. + * + * This routine is essentially a state machine that handles a couple + * of critical state-transition actions, namely initial setup and + * transition from header scanning to ready-for-start_decompress. + * All the actual input is done via the input controller's consume_input + * method. + */ + +GLOBAL(int) +jpeg_consume_input (j_decompress_ptr cinfo) +{ + int retcode = JPEG_SUSPENDED; + + /* NB: every possible DSTATE value should be listed in this switch */ + switch (cinfo->global_state) { + case DSTATE_START: + /* Start-of-datastream actions: reset appropriate modules */ + (*cinfo->inputctl->reset_input_controller) (cinfo); + /* Initialize application's data source module */ + (*cinfo->src->init_source) (cinfo); + cinfo->global_state = DSTATE_INHEADER; + /*FALLTHROUGH*/ + case DSTATE_INHEADER: + retcode = (*cinfo->inputctl->consume_input) (cinfo); + if (retcode == JPEG_REACHED_SOS) { /* Found SOS, prepare to decompress */ + /* Set up default parameters based on header data */ + default_decompress_parms(cinfo); + /* Set global state: ready for start_decompress */ + cinfo->global_state = DSTATE_READY; + } + break; + case DSTATE_READY: + /* Can't advance past first SOS until start_decompress is called */ + retcode = JPEG_REACHED_SOS; + break; + case DSTATE_PRELOAD: + case DSTATE_PRESCAN: + case DSTATE_SCANNING: + case DSTATE_RAW_OK: + case DSTATE_BUFIMAGE: + case DSTATE_BUFPOST: + case DSTATE_STOPPING: + retcode = (*cinfo->inputctl->consume_input) (cinfo); + break; + default: + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + } + return retcode; +} + + +/* + * Have we finished reading the input file? + */ + +GLOBAL(boolean) +jpeg_input_complete (j_decompress_ptr cinfo) +{ + /* Check for valid jpeg object */ + if (cinfo->global_state < DSTATE_START || + cinfo->global_state > DSTATE_STOPPING) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + return cinfo->inputctl->eoi_reached; +} + + +/* + * Is there more than one scan? + */ + +GLOBAL(boolean) +jpeg_has_multiple_scans (j_decompress_ptr cinfo) +{ + /* Only valid after jpeg_read_header completes */ + if (cinfo->global_state < DSTATE_READY || + cinfo->global_state > DSTATE_STOPPING) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + return cinfo->inputctl->has_multiple_scans; +} + + +/* + * Finish JPEG decompression. + * + * This will normally just verify the file trailer and release temp storage. + * + * Returns FALSE if suspended. The return value need be inspected only if + * a suspending data source is used. + */ + +GLOBAL(boolean) +jpeg_finish_decompress (j_decompress_ptr cinfo) +{ + if ((cinfo->global_state == DSTATE_SCANNING || + cinfo->global_state == DSTATE_RAW_OK) && ! cinfo->buffered_image) { + /* Terminate final pass of non-buffered mode */ + if (cinfo->output_scanline < cinfo->output_height) + ERREXIT(cinfo, JERR_TOO_LITTLE_DATA); + (*cinfo->master->finish_output_pass) (cinfo); + cinfo->global_state = DSTATE_STOPPING; + } else if (cinfo->global_state == DSTATE_BUFIMAGE) { + /* Finishing after a buffered-image operation */ + cinfo->global_state = DSTATE_STOPPING; + } else if (cinfo->global_state != DSTATE_STOPPING) { + /* STOPPING = repeat call after a suspension, anything else is error */ + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + } + /* Read until EOI */ + while (! cinfo->inputctl->eoi_reached) { + if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED) + return FALSE; /* Suspend, come back later */ + } + /* Do final cleanup */ + (*cinfo->src->term_source) (cinfo); + /* We can use jpeg_abort to release memory and reset global_state */ + jpeg_abort((j_common_ptr) cinfo); + return TRUE; +} diff --git a/gs/jpeg/jdapistd.c b/gs/jpeg/jdapistd.c new file mode 100644 index 000000000..c8e3fa0c3 --- /dev/null +++ b/gs/jpeg/jdapistd.c @@ -0,0 +1,275 @@ +/* + * jdapistd.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains application interface code for the decompression half + * of the JPEG library. These are the "standard" API routines that are + * used in the normal full-decompression case. They are not used by a + * transcoding-only application. Note that if an application links in + * jpeg_start_decompress, it will end up linking in the entire decompressor. + * We thus must separate this file from jdapimin.c to avoid linking the + * whole decompression library into a transcoder. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Forward declarations */ +LOCAL(boolean) output_pass_setup JPP((j_decompress_ptr cinfo)); + + +/* + * Decompression initialization. + * jpeg_read_header must be completed before calling this. + * + * If a multipass operating mode was selected, this will do all but the + * last pass, and thus may take a great deal of time. + * + * Returns FALSE if suspended. The return value need be inspected only if + * a suspending data source is used. + */ + +GLOBAL(boolean) +jpeg_start_decompress (j_decompress_ptr cinfo) +{ + if (cinfo->global_state == DSTATE_READY) { + /* First call: initialize master control, select active modules */ + jinit_master_decompress(cinfo); + if (cinfo->buffered_image) { + /* No more work here; expecting jpeg_start_output next */ + cinfo->global_state = DSTATE_BUFIMAGE; + return TRUE; + } + cinfo->global_state = DSTATE_PRELOAD; + } + if (cinfo->global_state == DSTATE_PRELOAD) { + /* If file has multiple scans, absorb them all into the coef buffer */ + if (cinfo->inputctl->has_multiple_scans) { +#ifdef D_MULTISCAN_FILES_SUPPORTED + for (;;) { + int retcode; + /* Call progress monitor hook if present */ + if (cinfo->progress != NULL) + (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); + /* Absorb some more input */ + retcode = (*cinfo->inputctl->consume_input) (cinfo); + if (retcode == JPEG_SUSPENDED) + return FALSE; + if (retcode == JPEG_REACHED_EOI) + break; + /* Advance progress counter if appropriate */ + if (cinfo->progress != NULL && + (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) { + if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) { + /* jdmaster underestimated number of scans; ratchet up one scan */ + cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows; + } + } + } +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif /* D_MULTISCAN_FILES_SUPPORTED */ + } + cinfo->output_scan_number = cinfo->input_scan_number; + } else if (cinfo->global_state != DSTATE_PRESCAN) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + /* Perform any dummy output passes, and set up for the final pass */ + return output_pass_setup(cinfo); +} + + +/* + * Set up for an output pass, and perform any dummy pass(es) needed. + * Common subroutine for jpeg_start_decompress and jpeg_start_output. + * Entry: global_state = DSTATE_PRESCAN only if previously suspended. + * Exit: If done, returns TRUE and sets global_state for proper output mode. + * If suspended, returns FALSE and sets global_state = DSTATE_PRESCAN. + */ + +LOCAL(boolean) +output_pass_setup (j_decompress_ptr cinfo) +{ + if (cinfo->global_state != DSTATE_PRESCAN) { + /* First call: do pass setup */ + (*cinfo->master->prepare_for_output_pass) (cinfo); + cinfo->output_scanline = 0; + cinfo->global_state = DSTATE_PRESCAN; + } + /* Loop over any required dummy passes */ + while (cinfo->master->is_dummy_pass) { +#ifdef QUANT_2PASS_SUPPORTED + /* Crank through the dummy pass */ + while (cinfo->output_scanline < cinfo->output_height) { + JDIMENSION last_scanline; + /* Call progress monitor hook if present */ + if (cinfo->progress != NULL) { + cinfo->progress->pass_counter = (long) cinfo->output_scanline; + cinfo->progress->pass_limit = (long) cinfo->output_height; + (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); + } + /* Process some data */ + last_scanline = cinfo->output_scanline; + (*cinfo->main->process_data) (cinfo, (JSAMPARRAY) NULL, + &cinfo->output_scanline, (JDIMENSION) 0); + if (cinfo->output_scanline == last_scanline) + return FALSE; /* No progress made, must suspend */ + } + /* Finish up dummy pass, and set up for another one */ + (*cinfo->master->finish_output_pass) (cinfo); + (*cinfo->master->prepare_for_output_pass) (cinfo); + cinfo->output_scanline = 0; +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif /* QUANT_2PASS_SUPPORTED */ + } + /* Ready for application to drive output pass through + * jpeg_read_scanlines or jpeg_read_raw_data. + */ + cinfo->global_state = cinfo->raw_data_out ? DSTATE_RAW_OK : DSTATE_SCANNING; + return TRUE; +} + + +/* + * Read some scanlines of data from the JPEG decompressor. + * + * The return value will be the number of lines actually read. + * This may be less than the number requested in several cases, + * including bottom of image, data source suspension, and operating + * modes that emit multiple scanlines at a time. + * + * Note: we warn about excess calls to jpeg_read_scanlines() since + * this likely signals an application programmer error. However, + * an oversize buffer (max_lines > scanlines remaining) is not an error. + */ + +GLOBAL(JDIMENSION) +jpeg_read_scanlines (j_decompress_ptr cinfo, JSAMPARRAY scanlines, + JDIMENSION max_lines) +{ + JDIMENSION row_ctr; + + if (cinfo->global_state != DSTATE_SCANNING) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + if (cinfo->output_scanline >= cinfo->output_height) { + WARNMS(cinfo, JWRN_TOO_MUCH_DATA); + return 0; + } + + /* Call progress monitor hook if present */ + if (cinfo->progress != NULL) { + cinfo->progress->pass_counter = (long) cinfo->output_scanline; + cinfo->progress->pass_limit = (long) cinfo->output_height; + (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); + } + + /* Process some data */ + row_ctr = 0; + (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, max_lines); + cinfo->output_scanline += row_ctr; + return row_ctr; +} + + +/* + * Alternate entry point to read raw data. + * Processes exactly one iMCU row per call, unless suspended. + */ + +GLOBAL(JDIMENSION) +jpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data, + JDIMENSION max_lines) +{ + JDIMENSION lines_per_iMCU_row; + + if (cinfo->global_state != DSTATE_RAW_OK) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + if (cinfo->output_scanline >= cinfo->output_height) { + WARNMS(cinfo, JWRN_TOO_MUCH_DATA); + return 0; + } + + /* Call progress monitor hook if present */ + if (cinfo->progress != NULL) { + cinfo->progress->pass_counter = (long) cinfo->output_scanline; + cinfo->progress->pass_limit = (long) cinfo->output_height; + (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); + } + + /* Verify that at least one iMCU row can be returned. */ + lines_per_iMCU_row = cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size; + if (max_lines < lines_per_iMCU_row) + ERREXIT(cinfo, JERR_BUFFER_SIZE); + + /* Decompress directly into user's buffer. */ + if (! (*cinfo->coef->decompress_data) (cinfo, data)) + return 0; /* suspension forced, can do nothing more */ + + /* OK, we processed one iMCU row. */ + cinfo->output_scanline += lines_per_iMCU_row; + return lines_per_iMCU_row; +} + + +/* Additional entry points for buffered-image mode. */ + +#ifdef D_MULTISCAN_FILES_SUPPORTED + +/* + * Initialize for an output pass in buffered-image mode. + */ + +GLOBAL(boolean) +jpeg_start_output (j_decompress_ptr cinfo, int scan_number) +{ + if (cinfo->global_state != DSTATE_BUFIMAGE && + cinfo->global_state != DSTATE_PRESCAN) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + /* Limit scan number to valid range */ + if (scan_number <= 0) + scan_number = 1; + if (cinfo->inputctl->eoi_reached && + scan_number > cinfo->input_scan_number) + scan_number = cinfo->input_scan_number; + cinfo->output_scan_number = scan_number; + /* Perform any dummy output passes, and set up for the real pass */ + return output_pass_setup(cinfo); +} + + +/* + * Finish up after an output pass in buffered-image mode. + * + * Returns FALSE if suspended. The return value need be inspected only if + * a suspending data source is used. + */ + +GLOBAL(boolean) +jpeg_finish_output (j_decompress_ptr cinfo) +{ + if ((cinfo->global_state == DSTATE_SCANNING || + cinfo->global_state == DSTATE_RAW_OK) && cinfo->buffered_image) { + /* Terminate this pass. */ + /* We do not require the whole pass to have been completed. */ + (*cinfo->master->finish_output_pass) (cinfo); + cinfo->global_state = DSTATE_BUFPOST; + } else if (cinfo->global_state != DSTATE_BUFPOST) { + /* BUFPOST = repeat call after a suspension, anything else is error */ + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + } + /* Read markers looking for SOS or EOI */ + while (cinfo->input_scan_number <= cinfo->output_scan_number && + ! cinfo->inputctl->eoi_reached) { + if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED) + return FALSE; /* Suspend, come back later */ + } + cinfo->global_state = DSTATE_BUFIMAGE; + return TRUE; +} + +#endif /* D_MULTISCAN_FILES_SUPPORTED */ diff --git a/gs/jpeg/jdatadst.c b/gs/jpeg/jdatadst.c new file mode 100644 index 000000000..a8f6fb0e0 --- /dev/null +++ b/gs/jpeg/jdatadst.c @@ -0,0 +1,151 @@ +/* + * jdatadst.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains compression data destination routines for the case of + * emitting JPEG data to a file (or any stdio stream). While these routines + * are sufficient for most applications, some will want to use a different + * destination manager. + * IMPORTANT: we assume that fwrite() will correctly transcribe an array of + * JOCTETs into 8-bit-wide elements on external storage. If char is wider + * than 8 bits on your machine, you may need to do some tweaking. + */ + +/* this is not a core library module, so it doesn't define JPEG_INTERNALS */ +#include "jinclude.h" +#include "jpeglib.h" +#include "jerror.h" + + +/* Expanded data destination object for stdio output */ + +typedef struct { + struct jpeg_destination_mgr pub; /* public fields */ + + FILE * outfile; /* target stream */ + JOCTET * buffer; /* start of buffer */ +} my_destination_mgr; + +typedef my_destination_mgr * my_dest_ptr; + +#define OUTPUT_BUF_SIZE 4096 /* choose an efficiently fwrite'able size */ + + +/* + * Initialize destination --- called by jpeg_start_compress + * before any data is actually written. + */ + +METHODDEF(void) +init_destination (j_compress_ptr cinfo) +{ + my_dest_ptr dest = (my_dest_ptr) cinfo->dest; + + /* Allocate the output buffer --- it will be released when done with image */ + dest->buffer = (JOCTET *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + OUTPUT_BUF_SIZE * SIZEOF(JOCTET)); + + dest->pub.next_output_byte = dest->buffer; + dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; +} + + +/* + * Empty the output buffer --- called whenever buffer fills up. + * + * In typical applications, this should write the entire output buffer + * (ignoring the current state of next_output_byte & free_in_buffer), + * reset the pointer & count to the start of the buffer, and return TRUE + * indicating that the buffer has been dumped. + * + * In applications that need to be able to suspend compression due to output + * overrun, a FALSE return indicates that the buffer cannot be emptied now. + * In this situation, the compressor will return to its caller (possibly with + * an indication that it has not accepted all the supplied scanlines). The + * application should resume compression after it has made more room in the + * output buffer. Note that there are substantial restrictions on the use of + * suspension --- see the documentation. + * + * When suspending, the compressor will back up to a convenient restart point + * (typically the start of the current MCU). next_output_byte & free_in_buffer + * indicate where the restart point will be if the current call returns FALSE. + * Data beyond this point will be regenerated after resumption, so do not + * write it out when emptying the buffer externally. + */ + +METHODDEF(boolean) +empty_output_buffer (j_compress_ptr cinfo) +{ + my_dest_ptr dest = (my_dest_ptr) cinfo->dest; + + if (JFWRITE(dest->outfile, dest->buffer, OUTPUT_BUF_SIZE) != + (size_t) OUTPUT_BUF_SIZE) + ERREXIT(cinfo, JERR_FILE_WRITE); + + dest->pub.next_output_byte = dest->buffer; + dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; + + return TRUE; +} + + +/* + * Terminate destination --- called by jpeg_finish_compress + * after all data has been written. Usually needs to flush buffer. + * + * NB: *not* called by jpeg_abort or jpeg_destroy; surrounding + * application must deal with any cleanup that should happen even + * for error exit. + */ + +METHODDEF(void) +term_destination (j_compress_ptr cinfo) +{ + my_dest_ptr dest = (my_dest_ptr) cinfo->dest; + size_t datacount = OUTPUT_BUF_SIZE - dest->pub.free_in_buffer; + + /* Write any data remaining in the buffer */ + if (datacount > 0) { + if (JFWRITE(dest->outfile, dest->buffer, datacount) != datacount) + ERREXIT(cinfo, JERR_FILE_WRITE); + } + fflush(dest->outfile); + /* Make sure we wrote the output file OK */ + if (ferror(dest->outfile)) + ERREXIT(cinfo, JERR_FILE_WRITE); +} + + +/* + * Prepare for output to a stdio stream. + * The caller must have already opened the stream, and is responsible + * for closing it after finishing compression. + */ + +GLOBAL(void) +jpeg_stdio_dest (j_compress_ptr cinfo, FILE * outfile) +{ + my_dest_ptr dest; + + /* The destination object is made permanent so that multiple JPEG images + * can be written to the same file without re-executing jpeg_stdio_dest. + * This makes it dangerous to use this manager and a different destination + * manager serially with the same JPEG object, because their private object + * sizes may be different. Caveat programmer. + */ + if (cinfo->dest == NULL) { /* first time for this JPEG object? */ + cinfo->dest = (struct jpeg_destination_mgr *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, + SIZEOF(my_destination_mgr)); + } + + dest = (my_dest_ptr) cinfo->dest; + dest->pub.init_destination = init_destination; + dest->pub.empty_output_buffer = empty_output_buffer; + dest->pub.term_destination = term_destination; + dest->outfile = outfile; +} diff --git a/gs/jpeg/jdatasrc.c b/gs/jpeg/jdatasrc.c new file mode 100644 index 000000000..edc752bf5 --- /dev/null +++ b/gs/jpeg/jdatasrc.c @@ -0,0 +1,212 @@ +/* + * jdatasrc.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains decompression data source routines for the case of + * reading JPEG data from a file (or any stdio stream). While these routines + * are sufficient for most applications, some will want to use a different + * source manager. + * IMPORTANT: we assume that fread() will correctly transcribe an array of + * JOCTETs from 8-bit-wide elements on external storage. If char is wider + * than 8 bits on your machine, you may need to do some tweaking. + */ + +/* this is not a core library module, so it doesn't define JPEG_INTERNALS */ +#include "jinclude.h" +#include "jpeglib.h" +#include "jerror.h" + + +/* Expanded data source object for stdio input */ + +typedef struct { + struct jpeg_source_mgr pub; /* public fields */ + + FILE * infile; /* source stream */ + JOCTET * buffer; /* start of buffer */ + boolean start_of_file; /* have we gotten any data yet? */ +} my_source_mgr; + +typedef my_source_mgr * my_src_ptr; + +#define INPUT_BUF_SIZE 4096 /* choose an efficiently fread'able size */ + + +/* + * Initialize source --- called by jpeg_read_header + * before any data is actually read. + */ + +METHODDEF(void) +init_source (j_decompress_ptr cinfo) +{ + my_src_ptr src = (my_src_ptr) cinfo->src; + + /* We reset the empty-input-file flag for each image, + * but we don't clear the input buffer. + * This is correct behavior for reading a series of images from one source. + */ + src->start_of_file = TRUE; +} + + +/* + * Fill the input buffer --- called whenever buffer is emptied. + * + * In typical applications, this should read fresh data into the buffer + * (ignoring the current state of next_input_byte & bytes_in_buffer), + * reset the pointer & count to the start of the buffer, and return TRUE + * indicating that the buffer has been reloaded. It is not necessary to + * fill the buffer entirely, only to obtain at least one more byte. + * + * There is no such thing as an EOF return. If the end of the file has been + * reached, the routine has a choice of ERREXIT() or inserting fake data into + * the buffer. In most cases, generating a warning message and inserting a + * fake EOI marker is the best course of action --- this will allow the + * decompressor to output however much of the image is there. However, + * the resulting error message is misleading if the real problem is an empty + * input file, so we handle that case specially. + * + * In applications that need to be able to suspend compression due to input + * not being available yet, a FALSE return indicates that no more data can be + * obtained right now, but more may be forthcoming later. In this situation, + * the decompressor will return to its caller (with an indication of the + * number of scanlines it has read, if any). The application should resume + * decompression after it has loaded more data into the input buffer. Note + * that there are substantial restrictions on the use of suspension --- see + * the documentation. + * + * When suspending, the decompressor will back up to a convenient restart point + * (typically the start of the current MCU). next_input_byte & bytes_in_buffer + * indicate where the restart point will be if the current call returns FALSE. + * Data beyond this point must be rescanned after resumption, so move it to + * the front of the buffer rather than discarding it. + */ + +METHODDEF(boolean) +fill_input_buffer (j_decompress_ptr cinfo) +{ + my_src_ptr src = (my_src_ptr) cinfo->src; + size_t nbytes; + + nbytes = JFREAD(src->infile, src->buffer, INPUT_BUF_SIZE); + + if (nbytes <= 0) { + if (src->start_of_file) /* Treat empty input file as fatal error */ + ERREXIT(cinfo, JERR_INPUT_EMPTY); + WARNMS(cinfo, JWRN_JPEG_EOF); + /* Insert a fake EOI marker */ + src->buffer[0] = (JOCTET) 0xFF; + src->buffer[1] = (JOCTET) JPEG_EOI; + nbytes = 2; + } + + src->pub.next_input_byte = src->buffer; + src->pub.bytes_in_buffer = nbytes; + src->start_of_file = FALSE; + + return TRUE; +} + + +/* + * Skip data --- used to skip over a potentially large amount of + * uninteresting data (such as an APPn marker). + * + * Writers of suspendable-input applications must note that skip_input_data + * is not granted the right to give a suspension return. If the skip extends + * beyond the data currently in the buffer, the buffer can be marked empty so + * that the next read will cause a fill_input_buffer call that can suspend. + * Arranging for additional bytes to be discarded before reloading the input + * buffer is the application writer's problem. + */ + +METHODDEF(void) +skip_input_data (j_decompress_ptr cinfo, long num_bytes) +{ + my_src_ptr src = (my_src_ptr) cinfo->src; + + /* Just a dumb implementation for now. Could use fseek() except + * it doesn't work on pipes. Not clear that being smart is worth + * any trouble anyway --- large skips are infrequent. + */ + if (num_bytes > 0) { + while (num_bytes > (long) src->pub.bytes_in_buffer) { + num_bytes -= (long) src->pub.bytes_in_buffer; + (void) fill_input_buffer(cinfo); + /* note we assume that fill_input_buffer will never return FALSE, + * so suspension need not be handled. + */ + } + src->pub.next_input_byte += (size_t) num_bytes; + src->pub.bytes_in_buffer -= (size_t) num_bytes; + } +} + + +/* + * An additional method that can be provided by data source modules is the + * resync_to_restart method for error recovery in the presence of RST markers. + * For the moment, this source module just uses the default resync method + * provided by the JPEG library. That method assumes that no backtracking + * is possible. + */ + + +/* + * Terminate source --- called by jpeg_finish_decompress + * after all data has been read. Often a no-op. + * + * NB: *not* called by jpeg_abort or jpeg_destroy; surrounding + * application must deal with any cleanup that should happen even + * for error exit. + */ + +METHODDEF(void) +term_source (j_decompress_ptr cinfo) +{ + /* no work necessary here */ +} + + +/* + * Prepare for input from a stdio stream. + * The caller must have already opened the stream, and is responsible + * for closing it after finishing decompression. + */ + +GLOBAL(void) +jpeg_stdio_src (j_decompress_ptr cinfo, FILE * infile) +{ + my_src_ptr src; + + /* The source object and input buffer are made permanent so that a series + * of JPEG images can be read from the same file by calling jpeg_stdio_src + * only before the first one. (If we discarded the buffer at the end of + * one image, we'd likely lose the start of the next one.) + * This makes it unsafe to use this manager and a different source + * manager serially with the same JPEG object. Caveat programmer. + */ + if (cinfo->src == NULL) { /* first time for this JPEG object? */ + cinfo->src = (struct jpeg_source_mgr *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, + SIZEOF(my_source_mgr)); + src = (my_src_ptr) cinfo->src; + src->buffer = (JOCTET *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, + INPUT_BUF_SIZE * SIZEOF(JOCTET)); + } + + src = (my_src_ptr) cinfo->src; + src->pub.init_source = init_source; + src->pub.fill_input_buffer = fill_input_buffer; + src->pub.skip_input_data = skip_input_data; + src->pub.resync_to_restart = jpeg_resync_to_restart; /* use default method */ + src->pub.term_source = term_source; + src->infile = infile; + src->pub.bytes_in_buffer = 0; /* forces fill_input_buffer on first read */ + src->pub.next_input_byte = NULL; /* until buffer loaded */ +} diff --git a/gs/jpeg/jdcoefct.c b/gs/jpeg/jdcoefct.c new file mode 100644 index 000000000..c0cd0bd50 --- /dev/null +++ b/gs/jpeg/jdcoefct.c @@ -0,0 +1,735 @@ +/* + * jdcoefct.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the coefficient buffer controller for decompression. + * This controller is the top level of the JPEG decompressor proper. + * The coefficient buffer lies between entropy decoding and inverse-DCT steps. + * + * In buffered-image mode, this controller is the interface between + * input-oriented processing and output-oriented processing. + * Also, the input side (only) is used when reading a file for transcoding. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + +/* Block smoothing is only applicable for progressive JPEG, so: */ +#ifndef D_PROGRESSIVE_SUPPORTED +#undef BLOCK_SMOOTHING_SUPPORTED +#endif + +/* Private buffer controller object */ + +typedef struct { + struct jpeg_d_coef_controller pub; /* public fields */ + + /* These variables keep track of the current location of the input side. */ + /* cinfo->input_iMCU_row is also used for this. */ + JDIMENSION MCU_ctr; /* counts MCUs processed in current row */ + int MCU_vert_offset; /* counts MCU rows within iMCU row */ + int MCU_rows_per_iMCU_row; /* number of such rows needed */ + + /* The output side's location is represented by cinfo->output_iMCU_row. */ + + /* In single-pass modes, it's sufficient to buffer just one MCU. + * We allocate a workspace of D_MAX_BLOCKS_IN_MCU coefficient blocks, + * and let the entropy decoder write into that workspace each time. + * (On 80x86, the workspace is FAR even though it's not really very big; + * this is to keep the module interfaces unchanged when a large coefficient + * buffer is necessary.) + * In multi-pass modes, this array points to the current MCU's blocks + * within the virtual arrays; it is used only by the input side. + */ + JBLOCKROW MCU_buffer[D_MAX_BLOCKS_IN_MCU]; + +#ifdef D_MULTISCAN_FILES_SUPPORTED + /* In multi-pass modes, we need a virtual block array for each component. */ + jvirt_barray_ptr whole_image[MAX_COMPONENTS]; +#endif + +#ifdef BLOCK_SMOOTHING_SUPPORTED + /* When doing block smoothing, we latch coefficient Al values here */ + int * coef_bits_latch; +#define SAVED_COEFS 6 /* we save coef_bits[0..5] */ +#endif +} my_coef_controller; + +typedef my_coef_controller * my_coef_ptr; + +/* Forward declarations */ +METHODDEF(int) decompress_onepass + JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); +#ifdef D_MULTISCAN_FILES_SUPPORTED +METHODDEF(int) decompress_data + JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); +#endif +#ifdef BLOCK_SMOOTHING_SUPPORTED +LOCAL(boolean) smoothing_ok JPP((j_decompress_ptr cinfo)); +METHODDEF(int) decompress_smooth_data + JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); +#endif + + +LOCAL(void) +start_iMCU_row (j_decompress_ptr cinfo) +/* Reset within-iMCU-row counters for a new row (input side) */ +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + + /* In an interleaved scan, an MCU row is the same as an iMCU row. + * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. + * But at the bottom of the image, process only what's left. + */ + if (cinfo->comps_in_scan > 1) { + coef->MCU_rows_per_iMCU_row = 1; + } else { + if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1)) + coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; + else + coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; + } + + coef->MCU_ctr = 0; + coef->MCU_vert_offset = 0; +} + + +/* + * Initialize for an input processing pass. + */ + +METHODDEF(void) +start_input_pass (j_decompress_ptr cinfo) +{ + cinfo->input_iMCU_row = 0; + start_iMCU_row(cinfo); +} + + +/* + * Initialize for an output processing pass. + */ + +METHODDEF(void) +start_output_pass (j_decompress_ptr cinfo) +{ +#ifdef BLOCK_SMOOTHING_SUPPORTED + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + + /* If multipass, check to see whether to use block smoothing on this pass */ + if (coef->pub.coef_arrays != NULL) { + if (cinfo->do_block_smoothing && smoothing_ok(cinfo)) + coef->pub.decompress_data = decompress_smooth_data; + else + coef->pub.decompress_data = decompress_data; + } +#endif + cinfo->output_iMCU_row = 0; +} + + +/* + * Decompress and return some data in the single-pass case. + * Always attempts to emit one fully interleaved MCU row ("iMCU" row). + * Input and output must run in lockstep since we have only a one-MCU buffer. + * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED. + * + * NB: output_buf contains a plane for each component in image. + * For single pass, this is the same as the components in the scan. + */ + +METHODDEF(int) +decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + JDIMENSION MCU_col_num; /* index of current MCU within row */ + JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; + JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; + int blkn, ci, xindex, yindex, yoffset, useful_width; + JSAMPARRAY output_ptr; + JDIMENSION start_col, output_col; + jpeg_component_info *compptr; + inverse_DCT_method_ptr inverse_DCT; + + /* Loop to process as much as one whole iMCU row */ + for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; + yoffset++) { + for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col; + MCU_col_num++) { + /* Try to fetch an MCU. Entropy decoder expects buffer to be zeroed. */ + jzero_far((void FAR *) coef->MCU_buffer[0], + (size_t) (cinfo->blocks_in_MCU * SIZEOF(JBLOCK))); + if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) { + /* Suspension forced; update state counters and exit */ + coef->MCU_vert_offset = yoffset; + coef->MCU_ctr = MCU_col_num; + return JPEG_SUSPENDED; + } + /* Determine where data should go in output_buf and do the IDCT thing. + * We skip dummy blocks at the right and bottom edges (but blkn gets + * incremented past them!). Note the inner loop relies on having + * allocated the MCU_buffer[] blocks sequentially. + */ + blkn = 0; /* index of current DCT block within MCU */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + /* Don't bother to IDCT an uninteresting component. */ + if (! compptr->component_needed) { + blkn += compptr->MCU_blocks; + continue; + } + inverse_DCT = cinfo->idct->inverse_DCT[compptr->component_index]; + useful_width = (MCU_col_num < last_MCU_col) ? compptr->MCU_width + : compptr->last_col_width; + output_ptr = output_buf[ci] + yoffset * compptr->DCT_scaled_size; + start_col = MCU_col_num * compptr->MCU_sample_width; + for (yindex = 0; yindex < compptr->MCU_height; yindex++) { + if (cinfo->input_iMCU_row < last_iMCU_row || + yoffset+yindex < compptr->last_row_height) { + output_col = start_col; + for (xindex = 0; xindex < useful_width; xindex++) { + (*inverse_DCT) (cinfo, compptr, + (JCOEFPTR) coef->MCU_buffer[blkn+xindex], + output_ptr, output_col); + output_col += compptr->DCT_scaled_size; + } + } + blkn += compptr->MCU_width; + output_ptr += compptr->DCT_scaled_size; + } + } + } + /* Completed an MCU row, but perhaps not an iMCU row */ + coef->MCU_ctr = 0; + } + /* Completed the iMCU row, advance counters for next one */ + cinfo->output_iMCU_row++; + if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { + start_iMCU_row(cinfo); + return JPEG_ROW_COMPLETED; + } + /* Completed the scan */ + (*cinfo->inputctl->finish_input_pass) (cinfo); + return JPEG_SCAN_COMPLETED; +} + + +/* + * Dummy consume-input routine for single-pass operation. + */ + +METHODDEF(int) +dummy_consume_data (j_decompress_ptr cinfo) +{ + return JPEG_SUSPENDED; /* Always indicate nothing was done */ +} + + +#ifdef D_MULTISCAN_FILES_SUPPORTED + +/* + * Consume input data and store it in the full-image coefficient buffer. + * We read as much as one fully interleaved MCU row ("iMCU" row) per call, + * ie, v_samp_factor block rows for each component in the scan. + * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED. + */ + +METHODDEF(int) +consume_data (j_decompress_ptr cinfo) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + JDIMENSION MCU_col_num; /* index of current MCU within row */ + int blkn, ci, xindex, yindex, yoffset; + JDIMENSION start_col; + JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; + JBLOCKROW buffer_ptr; + jpeg_component_info *compptr; + + /* Align the virtual buffers for the components used in this scan. */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + buffer[ci] = (*cinfo->mem->access_virt_barray) + ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index], + cinfo->input_iMCU_row * compptr->v_samp_factor, + (JDIMENSION) compptr->v_samp_factor, TRUE); + /* Note: entropy decoder expects buffer to be zeroed, + * but this is handled automatically by the memory manager + * because we requested a pre-zeroed array. + */ + } + + /* Loop to process one whole iMCU row */ + for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; + yoffset++) { + for (MCU_col_num = coef->MCU_ctr; MCU_col_num < cinfo->MCUs_per_row; + MCU_col_num++) { + /* Construct list of pointers to DCT blocks belonging to this MCU */ + blkn = 0; /* index of current DCT block within MCU */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + start_col = MCU_col_num * compptr->MCU_width; + for (yindex = 0; yindex < compptr->MCU_height; yindex++) { + buffer_ptr = buffer[ci][yindex+yoffset] + start_col; + for (xindex = 0; xindex < compptr->MCU_width; xindex++) { + coef->MCU_buffer[blkn++] = buffer_ptr++; + } + } + } + /* Try to fetch the MCU. */ + if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) { + /* Suspension forced; update state counters and exit */ + coef->MCU_vert_offset = yoffset; + coef->MCU_ctr = MCU_col_num; + return JPEG_SUSPENDED; + } + } + /* Completed an MCU row, but perhaps not an iMCU row */ + coef->MCU_ctr = 0; + } + /* Completed the iMCU row, advance counters for next one */ + if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { + start_iMCU_row(cinfo); + return JPEG_ROW_COMPLETED; + } + /* Completed the scan */ + (*cinfo->inputctl->finish_input_pass) (cinfo); + return JPEG_SCAN_COMPLETED; +} + + +/* + * Decompress and return some data in the multi-pass case. + * Always attempts to emit one fully interleaved MCU row ("iMCU" row). + * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED. + * + * NB: output_buf contains a plane for each component in image. + */ + +METHODDEF(int) +decompress_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; + JDIMENSION block_num; + int ci, block_row, block_rows; + JBLOCKARRAY buffer; + JBLOCKROW buffer_ptr; + JSAMPARRAY output_ptr; + JDIMENSION output_col; + jpeg_component_info *compptr; + inverse_DCT_method_ptr inverse_DCT; + + /* Force some input to be done if we are getting ahead of the input. */ + while (cinfo->input_scan_number < cinfo->output_scan_number || + (cinfo->input_scan_number == cinfo->output_scan_number && + cinfo->input_iMCU_row <= cinfo->output_iMCU_row)) { + if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED) + return JPEG_SUSPENDED; + } + + /* OK, output from the virtual arrays. */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Don't bother to IDCT an uninteresting component. */ + if (! compptr->component_needed) + continue; + /* Align the virtual buffer for this component. */ + buffer = (*cinfo->mem->access_virt_barray) + ((j_common_ptr) cinfo, coef->whole_image[ci], + cinfo->output_iMCU_row * compptr->v_samp_factor, + (JDIMENSION) compptr->v_samp_factor, FALSE); + /* Count non-dummy DCT block rows in this iMCU row. */ + if (cinfo->output_iMCU_row < last_iMCU_row) + block_rows = compptr->v_samp_factor; + else { + /* NB: can't use last_row_height here; it is input-side-dependent! */ + block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor); + if (block_rows == 0) block_rows = compptr->v_samp_factor; + } + inverse_DCT = cinfo->idct->inverse_DCT[ci]; + output_ptr = output_buf[ci]; + /* Loop over all DCT blocks to be processed. */ + for (block_row = 0; block_row < block_rows; block_row++) { + buffer_ptr = buffer[block_row]; + output_col = 0; + for (block_num = 0; block_num < compptr->width_in_blocks; block_num++) { + (*inverse_DCT) (cinfo, compptr, (JCOEFPTR) buffer_ptr, + output_ptr, output_col); + buffer_ptr++; + output_col += compptr->DCT_scaled_size; + } + output_ptr += compptr->DCT_scaled_size; + } + } + + if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows) + return JPEG_ROW_COMPLETED; + return JPEG_SCAN_COMPLETED; +} + +#endif /* D_MULTISCAN_FILES_SUPPORTED */ + + +#ifdef BLOCK_SMOOTHING_SUPPORTED + +/* + * This code applies interblock smoothing as described by section K.8 + * of the JPEG standard: the first 5 AC coefficients are estimated from + * the DC values of a DCT block and its 8 neighboring blocks. + * We apply smoothing only for progressive JPEG decoding, and only if + * the coefficients it can estimate are not yet known to full precision. + */ + +/* Natural-order array positions of the first 5 zigzag-order coefficients */ +#define Q01_POS 1 +#define Q10_POS 8 +#define Q20_POS 16 +#define Q11_POS 9 +#define Q02_POS 2 + +/* + * Determine whether block smoothing is applicable and safe. + * We also latch the current states of the coef_bits[] entries for the + * AC coefficients; otherwise, if the input side of the decompressor + * advances into a new scan, we might think the coefficients are known + * more accurately than they really are. + */ + +LOCAL(boolean) +smoothing_ok (j_decompress_ptr cinfo) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + boolean smoothing_useful = FALSE; + int ci, coefi; + jpeg_component_info *compptr; + JQUANT_TBL * qtable; + int * coef_bits; + int * coef_bits_latch; + + if (! cinfo->progressive_mode || cinfo->coef_bits == NULL) + return FALSE; + + /* Allocate latch area if not already done */ + if (coef->coef_bits_latch == NULL) + coef->coef_bits_latch = (int *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + cinfo->num_components * + (SAVED_COEFS * SIZEOF(int))); + coef_bits_latch = coef->coef_bits_latch; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* All components' quantization values must already be latched. */ + if ((qtable = compptr->quant_table) == NULL) + return FALSE; + /* Verify DC & first 5 AC quantizers are nonzero to avoid zero-divide. */ + if (qtable->quantval[0] == 0 || + qtable->quantval[Q01_POS] == 0 || + qtable->quantval[Q10_POS] == 0 || + qtable->quantval[Q20_POS] == 0 || + qtable->quantval[Q11_POS] == 0 || + qtable->quantval[Q02_POS] == 0) + return FALSE; + /* DC values must be at least partly known for all components. */ + coef_bits = cinfo->coef_bits[ci]; + if (coef_bits[0] < 0) + return FALSE; + /* Block smoothing is helpful if some AC coefficients remain inaccurate. */ + for (coefi = 1; coefi <= 5; coefi++) { + coef_bits_latch[coefi] = coef_bits[coefi]; + if (coef_bits[coefi] != 0) + smoothing_useful = TRUE; + } + coef_bits_latch += SAVED_COEFS; + } + + return smoothing_useful; +} + + +/* + * Variant of decompress_data for use when doing block smoothing. + */ + +METHODDEF(int) +decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; + JDIMENSION block_num, last_block_column; + int ci, block_row, block_rows, access_rows; + JBLOCKARRAY buffer; + JBLOCKROW buffer_ptr, prev_block_row, next_block_row; + JSAMPARRAY output_ptr; + JDIMENSION output_col; + jpeg_component_info *compptr; + inverse_DCT_method_ptr inverse_DCT; + boolean first_row, last_row; + JBLOCK workspace; + int *coef_bits; + JQUANT_TBL *quanttbl; + INT32 Q00,Q01,Q02,Q10,Q11,Q20, num; + int DC1,DC2,DC3,DC4,DC5,DC6,DC7,DC8,DC9; + int Al, pred; + + /* Force some input to be done if we are getting ahead of the input. */ + while (cinfo->input_scan_number <= cinfo->output_scan_number && + ! cinfo->inputctl->eoi_reached) { + if (cinfo->input_scan_number == cinfo->output_scan_number) { + /* If input is working on current scan, we ordinarily want it to + * have completed the current row. But if input scan is DC, + * we want it to keep one row ahead so that next block row's DC + * values are up to date. + */ + JDIMENSION delta = (cinfo->Ss == 0) ? 1 : 0; + if (cinfo->input_iMCU_row > cinfo->output_iMCU_row+delta) + break; + } + if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED) + return JPEG_SUSPENDED; + } + + /* OK, output from the virtual arrays. */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Don't bother to IDCT an uninteresting component. */ + if (! compptr->component_needed) + continue; + /* Count non-dummy DCT block rows in this iMCU row. */ + if (cinfo->output_iMCU_row < last_iMCU_row) { + block_rows = compptr->v_samp_factor; + access_rows = block_rows * 2; /* this and next iMCU row */ + last_row = FALSE; + } else { + /* NB: can't use last_row_height here; it is input-side-dependent! */ + block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor); + if (block_rows == 0) block_rows = compptr->v_samp_factor; + access_rows = block_rows; /* this iMCU row only */ + last_row = TRUE; + } + /* Align the virtual buffer for this component. */ + if (cinfo->output_iMCU_row > 0) { + access_rows += compptr->v_samp_factor; /* prior iMCU row too */ + buffer = (*cinfo->mem->access_virt_barray) + ((j_common_ptr) cinfo, coef->whole_image[ci], + (cinfo->output_iMCU_row - 1) * compptr->v_samp_factor, + (JDIMENSION) access_rows, FALSE); + buffer += compptr->v_samp_factor; /* point to current iMCU row */ + first_row = FALSE; + } else { + buffer = (*cinfo->mem->access_virt_barray) + ((j_common_ptr) cinfo, coef->whole_image[ci], + (JDIMENSION) 0, (JDIMENSION) access_rows, FALSE); + first_row = TRUE; + } + /* Fetch component-dependent info */ + coef_bits = coef->coef_bits_latch + (ci * SAVED_COEFS); + quanttbl = compptr->quant_table; + Q00 = quanttbl->quantval[0]; + Q01 = quanttbl->quantval[Q01_POS]; + Q10 = quanttbl->quantval[Q10_POS]; + Q20 = quanttbl->quantval[Q20_POS]; + Q11 = quanttbl->quantval[Q11_POS]; + Q02 = quanttbl->quantval[Q02_POS]; + inverse_DCT = cinfo->idct->inverse_DCT[ci]; + output_ptr = output_buf[ci]; + /* Loop over all DCT blocks to be processed. */ + for (block_row = 0; block_row < block_rows; block_row++) { + buffer_ptr = buffer[block_row]; + if (first_row && block_row == 0) + prev_block_row = buffer_ptr; + else + prev_block_row = buffer[block_row-1]; + if (last_row && block_row == block_rows-1) + next_block_row = buffer_ptr; + else + next_block_row = buffer[block_row+1]; + /* We fetch the surrounding DC values using a sliding-register approach. + * Initialize all nine here so as to do the right thing on narrow pics. + */ + DC1 = DC2 = DC3 = (int) prev_block_row[0][0]; + DC4 = DC5 = DC6 = (int) buffer_ptr[0][0]; + DC7 = DC8 = DC9 = (int) next_block_row[0][0]; + output_col = 0; + last_block_column = compptr->width_in_blocks - 1; + for (block_num = 0; block_num <= last_block_column; block_num++) { + /* Fetch current DCT block into workspace so we can modify it. */ + jcopy_block_row(buffer_ptr, (JBLOCKROW) workspace, (JDIMENSION) 1); + /* Update DC values */ + if (block_num < last_block_column) { + DC3 = (int) prev_block_row[1][0]; + DC6 = (int) buffer_ptr[1][0]; + DC9 = (int) next_block_row[1][0]; + } + /* Compute coefficient estimates per K.8. + * An estimate is applied only if coefficient is still zero, + * and is not known to be fully accurate. + */ + /* AC01 */ + if ((Al=coef_bits[1]) != 0 && workspace[1] == 0) { + num = 36 * Q00 * (DC4 - DC6); + if (num >= 0) { + pred = (int) (((Q01<<7) + num) / (Q01<<8)); + if (Al > 0 && pred >= (1< 0 && pred >= (1<= 0) { + pred = (int) (((Q10<<7) + num) / (Q10<<8)); + if (Al > 0 && pred >= (1< 0 && pred >= (1<= 0) { + pred = (int) (((Q20<<7) + num) / (Q20<<8)); + if (Al > 0 && pred >= (1< 0 && pred >= (1<= 0) { + pred = (int) (((Q11<<7) + num) / (Q11<<8)); + if (Al > 0 && pred >= (1< 0 && pred >= (1<= 0) { + pred = (int) (((Q02<<7) + num) / (Q02<<8)); + if (Al > 0 && pred >= (1< 0 && pred >= (1<DCT_scaled_size; + } + output_ptr += compptr->DCT_scaled_size; + } + } + + if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows) + return JPEG_ROW_COMPLETED; + return JPEG_SCAN_COMPLETED; +} + +#endif /* BLOCK_SMOOTHING_SUPPORTED */ + + +/* + * Initialize coefficient buffer controller. + */ + +GLOBAL(void) +jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer) +{ + my_coef_ptr coef; + + coef = (my_coef_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_coef_controller)); + cinfo->coef = (struct jpeg_d_coef_controller *) coef; + coef->pub.start_input_pass = start_input_pass; + coef->pub.start_output_pass = start_output_pass; +#ifdef BLOCK_SMOOTHING_SUPPORTED + coef->coef_bits_latch = NULL; +#endif + + /* Create the coefficient buffer. */ + if (need_full_buffer) { +#ifdef D_MULTISCAN_FILES_SUPPORTED + /* Allocate a full-image virtual array for each component, */ + /* padded to a multiple of samp_factor DCT blocks in each direction. */ + /* Note we ask for a pre-zeroed array. */ + int ci, access_rows; + jpeg_component_info *compptr; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + access_rows = compptr->v_samp_factor; +#ifdef BLOCK_SMOOTHING_SUPPORTED + /* If block smoothing could be used, need a bigger window */ + if (cinfo->progressive_mode) + access_rows *= 3; +#endif + coef->whole_image[ci] = (*cinfo->mem->request_virt_barray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, TRUE, + (JDIMENSION) jround_up((long) compptr->width_in_blocks, + (long) compptr->h_samp_factor), + (JDIMENSION) jround_up((long) compptr->height_in_blocks, + (long) compptr->v_samp_factor), + (JDIMENSION) access_rows); + } + coef->pub.consume_data = consume_data; + coef->pub.decompress_data = decompress_data; + coef->pub.coef_arrays = coef->whole_image; /* link to virtual arrays */ +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } else { + /* We only need a single-MCU buffer. */ + JBLOCKROW buffer; + int i; + + buffer = (JBLOCKROW) + (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, + D_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); + for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) { + coef->MCU_buffer[i] = buffer + i; + } + coef->pub.consume_data = dummy_consume_data; + coef->pub.decompress_data = decompress_onepass; + coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */ + } +} diff --git a/gs/jpeg/jdcolor.c b/gs/jpeg/jdcolor.c new file mode 100644 index 000000000..026949840 --- /dev/null +++ b/gs/jpeg/jdcolor.c @@ -0,0 +1,367 @@ +/* + * jdcolor.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains output colorspace conversion routines. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Private subobject */ + +typedef struct { + struct jpeg_color_deconverter pub; /* public fields */ + + /* Private state for YCC->RGB conversion */ + int * Cr_r_tab; /* => table for Cr to R conversion */ + int * Cb_b_tab; /* => table for Cb to B conversion */ + INT32 * Cr_g_tab; /* => table for Cr to G conversion */ + INT32 * Cb_g_tab; /* => table for Cb to G conversion */ +} my_color_deconverter; + +typedef my_color_deconverter * my_cconvert_ptr; + + +/**************** YCbCr -> RGB conversion: most common case **************/ + +/* + * YCbCr is defined per CCIR 601-1, except that Cb and Cr are + * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5. + * The conversion equations to be implemented are therefore + * R = Y + 1.40200 * Cr + * G = Y - 0.34414 * Cb - 0.71414 * Cr + * B = Y + 1.77200 * Cb + * where Cb and Cr represent the incoming values less CENTERJSAMPLE. + * (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.) + * + * To avoid floating-point arithmetic, we represent the fractional constants + * as integers scaled up by 2^16 (about 4 digits precision); we have to divide + * the products by 2^16, with appropriate rounding, to get the correct answer. + * Notice that Y, being an integral input, does not contribute any fraction + * so it need not participate in the rounding. + * + * For even more speed, we avoid doing any multiplications in the inner loop + * by precalculating the constants times Cb and Cr for all possible values. + * For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table); + * for 12-bit samples it is still acceptable. It's not very reasonable for + * 16-bit samples, but if you want lossless storage you shouldn't be changing + * colorspace anyway. + * The Cr=>R and Cb=>B values can be rounded to integers in advance; the + * values for the G calculation are left scaled up, since we must add them + * together before rounding. + */ + +#define SCALEBITS 16 /* speediest right-shift on some machines */ +#define ONE_HALF ((INT32) 1 << (SCALEBITS-1)) +#define FIX(x) ((INT32) ((x) * (1L<RGB colorspace conversion. + */ + +LOCAL(void) +build_ycc_rgb_table (j_decompress_ptr cinfo) +{ + my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; + int i; + INT32 x; + SHIFT_TEMPS + + cconvert->Cr_r_tab = (int *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (MAXJSAMPLE+1) * SIZEOF(int)); + cconvert->Cb_b_tab = (int *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (MAXJSAMPLE+1) * SIZEOF(int)); + cconvert->Cr_g_tab = (INT32 *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (MAXJSAMPLE+1) * SIZEOF(INT32)); + cconvert->Cb_g_tab = (INT32 *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (MAXJSAMPLE+1) * SIZEOF(INT32)); + + for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) { + /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */ + /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */ + /* Cr=>R value is nearest int to 1.40200 * x */ + cconvert->Cr_r_tab[i] = (int) + RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS); + /* Cb=>B value is nearest int to 1.77200 * x */ + cconvert->Cb_b_tab[i] = (int) + RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS); + /* Cr=>G value is scaled-up -0.71414 * x */ + cconvert->Cr_g_tab[i] = (- FIX(0.71414)) * x; + /* Cb=>G value is scaled-up -0.34414 * x */ + /* We also add in ONE_HALF so that need not do it in inner loop */ + cconvert->Cb_g_tab[i] = (- FIX(0.34414)) * x + ONE_HALF; + } +} + + +/* + * Convert some rows of samples to the output colorspace. + * + * Note that we change from noninterleaved, one-plane-per-component format + * to interleaved-pixel format. The output buffer is therefore three times + * as wide as the input buffer. + * A starting row offset is provided only for the input buffer. The caller + * can easily adjust the passed output_buf value to accommodate any row + * offset required on that side. + */ + +METHODDEF(void) +ycc_rgb_convert (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION input_row, + JSAMPARRAY output_buf, int num_rows) +{ + my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; + register int y, cb, cr; + register JSAMPROW outptr; + register JSAMPROW inptr0, inptr1, inptr2; + register JDIMENSION col; + JDIMENSION num_cols = cinfo->output_width; + /* copy these pointers into registers if possible */ + register JSAMPLE * range_limit = cinfo->sample_range_limit; + register int * Crrtab = cconvert->Cr_r_tab; + register int * Cbbtab = cconvert->Cb_b_tab; + register INT32 * Crgtab = cconvert->Cr_g_tab; + register INT32 * Cbgtab = cconvert->Cb_g_tab; + SHIFT_TEMPS + + while (--num_rows >= 0) { + inptr0 = input_buf[0][input_row]; + inptr1 = input_buf[1][input_row]; + inptr2 = input_buf[2][input_row]; + input_row++; + outptr = *output_buf++; + for (col = 0; col < num_cols; col++) { + y = GETJSAMPLE(inptr0[col]); + cb = GETJSAMPLE(inptr1[col]); + cr = GETJSAMPLE(inptr2[col]); + /* Range-limiting is essential due to noise introduced by DCT losses. */ + outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; + outptr[RGB_GREEN] = range_limit[y + + ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], + SCALEBITS))]; + outptr[RGB_BLUE] = range_limit[y + Cbbtab[cb]]; + outptr += RGB_PIXELSIZE; + } + } +} + + +/**************** Cases other than YCbCr -> RGB **************/ + + +/* + * Color conversion for no colorspace change: just copy the data, + * converting from separate-planes to interleaved representation. + */ + +METHODDEF(void) +null_convert (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION input_row, + JSAMPARRAY output_buf, int num_rows) +{ + register JSAMPROW inptr, outptr; + register JDIMENSION count; + register int num_components = cinfo->num_components; + JDIMENSION num_cols = cinfo->output_width; + int ci; + + while (--num_rows >= 0) { + for (ci = 0; ci < num_components; ci++) { + inptr = input_buf[ci][input_row]; + outptr = output_buf[0] + ci; + for (count = num_cols; count > 0; count--) { + *outptr = *inptr++; /* needn't bother with GETJSAMPLE() here */ + outptr += num_components; + } + } + input_row++; + output_buf++; + } +} + + +/* + * Color conversion for grayscale: just copy the data. + * This also works for YCbCr -> grayscale conversion, in which + * we just copy the Y (luminance) component and ignore chrominance. + */ + +METHODDEF(void) +grayscale_convert (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION input_row, + JSAMPARRAY output_buf, int num_rows) +{ + jcopy_sample_rows(input_buf[0], (int) input_row, output_buf, 0, + num_rows, cinfo->output_width); +} + + +/* + * Adobe-style YCCK->CMYK conversion. + * We convert YCbCr to R=1-C, G=1-M, and B=1-Y using the same + * conversion as above, while passing K (black) unchanged. + * We assume build_ycc_rgb_table has been called. + */ + +METHODDEF(void) +ycck_cmyk_convert (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION input_row, + JSAMPARRAY output_buf, int num_rows) +{ + my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; + register int y, cb, cr; + register JSAMPROW outptr; + register JSAMPROW inptr0, inptr1, inptr2, inptr3; + register JDIMENSION col; + JDIMENSION num_cols = cinfo->output_width; + /* copy these pointers into registers if possible */ + register JSAMPLE * range_limit = cinfo->sample_range_limit; + register int * Crrtab = cconvert->Cr_r_tab; + register int * Cbbtab = cconvert->Cb_b_tab; + register INT32 * Crgtab = cconvert->Cr_g_tab; + register INT32 * Cbgtab = cconvert->Cb_g_tab; + SHIFT_TEMPS + + while (--num_rows >= 0) { + inptr0 = input_buf[0][input_row]; + inptr1 = input_buf[1][input_row]; + inptr2 = input_buf[2][input_row]; + inptr3 = input_buf[3][input_row]; + input_row++; + outptr = *output_buf++; + for (col = 0; col < num_cols; col++) { + y = GETJSAMPLE(inptr0[col]); + cb = GETJSAMPLE(inptr1[col]); + cr = GETJSAMPLE(inptr2[col]); + /* Range-limiting is essential due to noise introduced by DCT losses. */ + outptr[0] = range_limit[MAXJSAMPLE - (y + Crrtab[cr])]; /* red */ + outptr[1] = range_limit[MAXJSAMPLE - (y + /* green */ + ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], + SCALEBITS)))]; + outptr[2] = range_limit[MAXJSAMPLE - (y + Cbbtab[cb])]; /* blue */ + /* K passes through unchanged */ + outptr[3] = inptr3[col]; /* don't need GETJSAMPLE here */ + outptr += 4; + } + } +} + + +/* + * Empty method for start_pass. + */ + +METHODDEF(void) +start_pass_dcolor (j_decompress_ptr cinfo) +{ + /* no work needed */ +} + + +/* + * Module initialization routine for output colorspace conversion. + */ + +GLOBAL(void) +jinit_color_deconverter (j_decompress_ptr cinfo) +{ + my_cconvert_ptr cconvert; + int ci; + + cconvert = (my_cconvert_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_color_deconverter)); + cinfo->cconvert = (struct jpeg_color_deconverter *) cconvert; + cconvert->pub.start_pass = start_pass_dcolor; + + /* Make sure num_components agrees with jpeg_color_space */ + switch (cinfo->jpeg_color_space) { + case JCS_GRAYSCALE: + if (cinfo->num_components != 1) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + break; + + case JCS_RGB: + case JCS_YCbCr: + if (cinfo->num_components != 3) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + break; + + case JCS_CMYK: + case JCS_YCCK: + if (cinfo->num_components != 4) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + break; + + default: /* JCS_UNKNOWN can be anything */ + if (cinfo->num_components < 1) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + break; + } + + /* Set out_color_components and conversion method based on requested space. + * Also clear the component_needed flags for any unused components, + * so that earlier pipeline stages can avoid useless computation. + */ + + switch (cinfo->out_color_space) { + case JCS_GRAYSCALE: + cinfo->out_color_components = 1; + if (cinfo->jpeg_color_space == JCS_GRAYSCALE || + cinfo->jpeg_color_space == JCS_YCbCr) { + cconvert->pub.color_convert = grayscale_convert; + /* For color->grayscale conversion, only the Y (0) component is needed */ + for (ci = 1; ci < cinfo->num_components; ci++) + cinfo->comp_info[ci].component_needed = FALSE; + } else + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + break; + + case JCS_RGB: + cinfo->out_color_components = RGB_PIXELSIZE; + if (cinfo->jpeg_color_space == JCS_YCbCr) { + cconvert->pub.color_convert = ycc_rgb_convert; + build_ycc_rgb_table(cinfo); + } else if (cinfo->jpeg_color_space == JCS_RGB && RGB_PIXELSIZE == 3) { + cconvert->pub.color_convert = null_convert; + } else + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + break; + + case JCS_CMYK: + cinfo->out_color_components = 4; + if (cinfo->jpeg_color_space == JCS_YCCK) { + cconvert->pub.color_convert = ycck_cmyk_convert; + build_ycc_rgb_table(cinfo); + } else if (cinfo->jpeg_color_space == JCS_CMYK) { + cconvert->pub.color_convert = null_convert; + } else + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + break; + + default: + /* Permit null conversion to same output space */ + if (cinfo->out_color_space == cinfo->jpeg_color_space) { + cinfo->out_color_components = cinfo->num_components; + cconvert->pub.color_convert = null_convert; + } else /* unsupported non-null conversion */ + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + break; + } + + if (cinfo->quantize_colors) + cinfo->output_components = 1; /* single colormapped output component */ + else + cinfo->output_components = cinfo->out_color_components; +} diff --git a/gs/jpeg/jdct.h b/gs/jpeg/jdct.h new file mode 100644 index 000000000..04192a266 --- /dev/null +++ b/gs/jpeg/jdct.h @@ -0,0 +1,176 @@ +/* + * jdct.h + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This include file contains common declarations for the forward and + * inverse DCT modules. These declarations are private to the DCT managers + * (jcdctmgr.c, jddctmgr.c) and the individual DCT algorithms. + * The individual DCT algorithms are kept in separate files to ease + * machine-dependent tuning (e.g., assembly coding). + */ + + +/* + * A forward DCT routine is given a pointer to a work area of type DCTELEM[]; + * the DCT is to be performed in-place in that buffer. Type DCTELEM is int + * for 8-bit samples, INT32 for 12-bit samples. (NOTE: Floating-point DCT + * implementations use an array of type FAST_FLOAT, instead.) + * The DCT inputs are expected to be signed (range +-CENTERJSAMPLE). + * The DCT outputs are returned scaled up by a factor of 8; they therefore + * have a range of +-8K for 8-bit data, +-128K for 12-bit data. This + * convention improves accuracy in integer implementations and saves some + * work in floating-point ones. + * Quantization of the output coefficients is done by jcdctmgr.c. + */ + +#if BITS_IN_JSAMPLE == 8 +typedef int DCTELEM; /* 16 or 32 bits is fine */ +#else +typedef INT32 DCTELEM; /* must have 32 bits */ +#endif + +typedef JMETHOD(void, forward_DCT_method_ptr, (DCTELEM * data)); +typedef JMETHOD(void, float_DCT_method_ptr, (FAST_FLOAT * data)); + + +/* + * An inverse DCT routine is given a pointer to the input JBLOCK and a pointer + * to an output sample array. The routine must dequantize the input data as + * well as perform the IDCT; for dequantization, it uses the multiplier table + * pointed to by compptr->dct_table. The output data is to be placed into the + * sample array starting at a specified column. (Any row offset needed will + * be applied to the array pointer before it is passed to the IDCT code.) + * Note that the number of samples emitted by the IDCT routine is + * DCT_scaled_size * DCT_scaled_size. + */ + +/* typedef inverse_DCT_method_ptr is declared in jpegint.h */ + +/* + * Each IDCT routine has its own ideas about the best dct_table element type. + */ + +typedef MULTIPLIER ISLOW_MULT_TYPE; /* short or int, whichever is faster */ +#if BITS_IN_JSAMPLE == 8 +typedef MULTIPLIER IFAST_MULT_TYPE; /* 16 bits is OK, use short if faster */ +#define IFAST_SCALE_BITS 2 /* fractional bits in scale factors */ +#else +typedef INT32 IFAST_MULT_TYPE; /* need 32 bits for scaled quantizers */ +#define IFAST_SCALE_BITS 13 /* fractional bits in scale factors */ +#endif +typedef FAST_FLOAT FLOAT_MULT_TYPE; /* preferred floating type */ + + +/* + * Each IDCT routine is responsible for range-limiting its results and + * converting them to unsigned form (0..MAXJSAMPLE). The raw outputs could + * be quite far out of range if the input data is corrupt, so a bulletproof + * range-limiting step is required. We use a mask-and-table-lookup method + * to do the combined operations quickly. See the comments with + * prepare_range_limit_table (in jdmaster.c) for more info. + */ + +#define IDCT_range_limit(cinfo) ((cinfo)->sample_range_limit + CENTERJSAMPLE) + +#define RANGE_MASK (MAXJSAMPLE * 4 + 3) /* 2 bits wider than legal samples */ + + +/* Short forms of external names for systems with brain-damaged linkers. */ + +#ifdef NEED_SHORT_EXTERNAL_NAMES +#define jpeg_fdct_islow jFDislow +#define jpeg_fdct_ifast jFDifast +#define jpeg_fdct_float jFDfloat +#define jpeg_idct_islow jRDislow +#define jpeg_idct_ifast jRDifast +#define jpeg_idct_float jRDfloat +#define jpeg_idct_4x4 jRD4x4 +#define jpeg_idct_2x2 jRD2x2 +#define jpeg_idct_1x1 jRD1x1 +#endif /* NEED_SHORT_EXTERNAL_NAMES */ + +/* Extern declarations for the forward and inverse DCT routines. */ + +EXTERN(void) jpeg_fdct_islow JPP((DCTELEM * data)); +EXTERN(void) jpeg_fdct_ifast JPP((DCTELEM * data)); +EXTERN(void) jpeg_fdct_float JPP((FAST_FLOAT * data)); + +EXTERN(void) jpeg_idct_islow + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_ifast + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_float + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_4x4 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_2x2 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_1x1 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); + + +/* + * Macros for handling fixed-point arithmetic; these are used by many + * but not all of the DCT/IDCT modules. + * + * All values are expected to be of type INT32. + * Fractional constants are scaled left by CONST_BITS bits. + * CONST_BITS is defined within each module using these macros, + * and may differ from one module to the next. + */ + +#define ONE ((INT32) 1) +#define CONST_SCALE (ONE << CONST_BITS) + +/* Convert a positive real constant to an integer scaled by CONST_SCALE. + * Caution: some C compilers fail to reduce "FIX(constant)" at compile time, + * thus causing a lot of useless floating-point operations at run time. + */ + +#define FIX(x) ((INT32) ((x) * CONST_SCALE + 0.5)) + +/* Descale and correctly round an INT32 value that's scaled by N bits. + * We assume RIGHT_SHIFT rounds towards minus infinity, so adding + * the fudge factor is correct for either sign of X. + */ + +#define DESCALE(x,n) RIGHT_SHIFT((x) + (ONE << ((n)-1)), n) + +/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. + * This macro is used only when the two inputs will actually be no more than + * 16 bits wide, so that a 16x16->32 bit multiply can be used instead of a + * full 32x32 multiply. This provides a useful speedup on many machines. + * Unfortunately there is no way to specify a 16x16->32 multiply portably + * in C, but some C compilers will do the right thing if you provide the + * correct combination of casts. + */ + +#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */ +#define MULTIPLY16C16(var,const) (((INT16) (var)) * ((INT16) (const))) +#endif +#ifdef SHORTxLCONST_32 /* known to work with Microsoft C 6.0 */ +#define MULTIPLY16C16(var,const) (((INT16) (var)) * ((INT32) (const))) +#endif + +#ifndef MULTIPLY16C16 /* default definition */ +#define MULTIPLY16C16(var,const) ((var) * (const)) +#endif + +/* Same except both inputs are variables. */ + +#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */ +#define MULTIPLY16V16(var1,var2) (((INT16) (var1)) * ((INT16) (var2))) +#endif + +#ifndef MULTIPLY16V16 /* default definition */ +#define MULTIPLY16V16(var1,var2) ((var1) * (var2)) +#endif diff --git a/gs/jpeg/jddctmgr.c b/gs/jpeg/jddctmgr.c new file mode 100644 index 000000000..bbf8d0e92 --- /dev/null +++ b/gs/jpeg/jddctmgr.c @@ -0,0 +1,269 @@ +/* + * jddctmgr.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the inverse-DCT management logic. + * This code selects a particular IDCT implementation to be used, + * and it performs related housekeeping chores. No code in this file + * is executed per IDCT step, only during output pass setup. + * + * Note that the IDCT routines are responsible for performing coefficient + * dequantization as well as the IDCT proper. This module sets up the + * dequantization multiplier table needed by the IDCT routine. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdct.h" /* Private declarations for DCT subsystem */ + + +/* + * The decompressor input side (jdinput.c) saves away the appropriate + * quantization table for each component at the start of the first scan + * involving that component. (This is necessary in order to correctly + * decode files that reuse Q-table slots.) + * When we are ready to make an output pass, the saved Q-table is converted + * to a multiplier table that will actually be used by the IDCT routine. + * The multiplier table contents are IDCT-method-dependent. To support + * application changes in IDCT method between scans, we can remake the + * multiplier tables if necessary. + * In buffered-image mode, the first output pass may occur before any data + * has been seen for some components, and thus before their Q-tables have + * been saved away. To handle this case, multiplier tables are preset + * to zeroes; the result of the IDCT will be a neutral gray level. + */ + + +/* Private subobject for this module */ + +typedef struct { + struct jpeg_inverse_dct pub; /* public fields */ + + /* This array contains the IDCT method code that each multiplier table + * is currently set up for, or -1 if it's not yet set up. + * The actual multiplier tables are pointed to by dct_table in the + * per-component comp_info structures. + */ + int cur_method[MAX_COMPONENTS]; +} my_idct_controller; + +typedef my_idct_controller * my_idct_ptr; + + +/* Allocated multiplier tables: big enough for any supported variant */ + +typedef union { + ISLOW_MULT_TYPE islow_array[DCTSIZE2]; +#ifdef DCT_IFAST_SUPPORTED + IFAST_MULT_TYPE ifast_array[DCTSIZE2]; +#endif +#ifdef DCT_FLOAT_SUPPORTED + FLOAT_MULT_TYPE float_array[DCTSIZE2]; +#endif +} multiplier_table; + + +/* The current scaled-IDCT routines require ISLOW-style multiplier tables, + * so be sure to compile that code if either ISLOW or SCALING is requested. + */ +#ifdef DCT_ISLOW_SUPPORTED +#define PROVIDE_ISLOW_TABLES +#else +#ifdef IDCT_SCALING_SUPPORTED +#define PROVIDE_ISLOW_TABLES +#endif +#endif + + +/* + * Prepare for an output pass. + * Here we select the proper IDCT routine for each component and build + * a matching multiplier table. + */ + +METHODDEF(void) +start_pass (j_decompress_ptr cinfo) +{ + my_idct_ptr idct = (my_idct_ptr) cinfo->idct; + int ci, i; + jpeg_component_info *compptr; + int method = 0; + inverse_DCT_method_ptr method_ptr = NULL; + JQUANT_TBL * qtbl; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Select the proper IDCT routine for this component's scaling */ + switch (compptr->DCT_scaled_size) { +#ifdef IDCT_SCALING_SUPPORTED + case 1: + method_ptr = jpeg_idct_1x1; + method = JDCT_ISLOW; /* jidctred uses islow-style table */ + break; + case 2: + method_ptr = jpeg_idct_2x2; + method = JDCT_ISLOW; /* jidctred uses islow-style table */ + break; + case 4: + method_ptr = jpeg_idct_4x4; + method = JDCT_ISLOW; /* jidctred uses islow-style table */ + break; +#endif + case DCTSIZE: + switch (cinfo->dct_method) { +#ifdef DCT_ISLOW_SUPPORTED + case JDCT_ISLOW: + method_ptr = jpeg_idct_islow; + method = JDCT_ISLOW; + break; +#endif +#ifdef DCT_IFAST_SUPPORTED + case JDCT_IFAST: + method_ptr = jpeg_idct_ifast; + method = JDCT_IFAST; + break; +#endif +#ifdef DCT_FLOAT_SUPPORTED + case JDCT_FLOAT: + method_ptr = jpeg_idct_float; + method = JDCT_FLOAT; + break; +#endif + default: + ERREXIT(cinfo, JERR_NOT_COMPILED); + break; + } + break; + default: + ERREXIT1(cinfo, JERR_BAD_DCTSIZE, compptr->DCT_scaled_size); + break; + } + idct->pub.inverse_DCT[ci] = method_ptr; + /* Create multiplier table from quant table. + * However, we can skip this if the component is uninteresting + * or if we already built the table. Also, if no quant table + * has yet been saved for the component, we leave the + * multiplier table all-zero; we'll be reading zeroes from the + * coefficient controller's buffer anyway. + */ + if (! compptr->component_needed || idct->cur_method[ci] == method) + continue; + qtbl = compptr->quant_table; + if (qtbl == NULL) /* happens if no data yet for component */ + continue; + idct->cur_method[ci] = method; + switch (method) { +#ifdef PROVIDE_ISLOW_TABLES + case JDCT_ISLOW: + { + /* For LL&M IDCT method, multipliers are equal to raw quantization + * coefficients, but are stored as ints to ensure access efficiency. + */ + ISLOW_MULT_TYPE * ismtbl = (ISLOW_MULT_TYPE *) compptr->dct_table; + for (i = 0; i < DCTSIZE2; i++) { + ismtbl[i] = (ISLOW_MULT_TYPE) qtbl->quantval[i]; + } + } + break; +#endif +#ifdef DCT_IFAST_SUPPORTED + case JDCT_IFAST: + { + /* For AA&N IDCT method, multipliers are equal to quantization + * coefficients scaled by scalefactor[row]*scalefactor[col], where + * scalefactor[0] = 1 + * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 + * For integer operation, the multiplier table is to be scaled by + * IFAST_SCALE_BITS. + */ + IFAST_MULT_TYPE * ifmtbl = (IFAST_MULT_TYPE *) compptr->dct_table; +#define CONST_BITS 14 + static const INT16 aanscales[DCTSIZE2] = { + /* precomputed values scaled up by 14 bits */ + 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, + 22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270, + 21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906, + 19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315, + 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, + 12873, 17855, 16819, 15137, 12873, 10114, 6967, 3552, + 8867, 12299, 11585, 10426, 8867, 6967, 4799, 2446, + 4520, 6270, 5906, 5315, 4520, 3552, 2446, 1247 + }; + SHIFT_TEMPS + + for (i = 0; i < DCTSIZE2; i++) { + ifmtbl[i] = (IFAST_MULT_TYPE) + DESCALE(MULTIPLY16V16((INT32) qtbl->quantval[i], + (INT32) aanscales[i]), + CONST_BITS-IFAST_SCALE_BITS); + } + } + break; +#endif +#ifdef DCT_FLOAT_SUPPORTED + case JDCT_FLOAT: + { + /* For float AA&N IDCT method, multipliers are equal to quantization + * coefficients scaled by scalefactor[row]*scalefactor[col], where + * scalefactor[0] = 1 + * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 + */ + FLOAT_MULT_TYPE * fmtbl = (FLOAT_MULT_TYPE *) compptr->dct_table; + int row, col; + static const double aanscalefactor[DCTSIZE] = { + 1.0, 1.387039845, 1.306562965, 1.175875602, + 1.0, 0.785694958, 0.541196100, 0.275899379 + }; + + i = 0; + for (row = 0; row < DCTSIZE; row++) { + for (col = 0; col < DCTSIZE; col++) { + fmtbl[i] = (FLOAT_MULT_TYPE) + ((double) qtbl->quantval[i] * + aanscalefactor[row] * aanscalefactor[col]); + i++; + } + } + } + break; +#endif + default: + ERREXIT(cinfo, JERR_NOT_COMPILED); + break; + } + } +} + + +/* + * Initialize IDCT manager. + */ + +GLOBAL(void) +jinit_inverse_dct (j_decompress_ptr cinfo) +{ + my_idct_ptr idct; + int ci; + jpeg_component_info *compptr; + + idct = (my_idct_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_idct_controller)); + cinfo->idct = (struct jpeg_inverse_dct *) idct; + idct->pub.start_pass = start_pass; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Allocate and pre-zero a multiplier table for each component */ + compptr->dct_table = + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(multiplier_table)); + MEMZERO(compptr->dct_table, SIZEOF(multiplier_table)); + /* Mark multiplier table not yet set up for any method */ + idct->cur_method[ci] = -1; + } +} diff --git a/gs/jpeg/jdhuff.c b/gs/jpeg/jdhuff.c new file mode 100644 index 000000000..5b5544b67 --- /dev/null +++ b/gs/jpeg/jdhuff.c @@ -0,0 +1,574 @@ +/* + * jdhuff.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains Huffman entropy decoding routines. + * + * Much of the complexity here has to do with supporting input suspension. + * If the data source module demands suspension, we want to be able to back + * up to the start of the current MCU. To do this, we copy state variables + * into local working storage, and update them back to the permanent + * storage only upon successful completion of an MCU. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdhuff.h" /* Declarations shared with jdphuff.c */ + + +/* + * Expanded entropy decoder object for Huffman decoding. + * + * The savable_state subrecord contains fields that change within an MCU, + * but must not be updated permanently until we complete the MCU. + */ + +typedef struct { + int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ +} savable_state; + +/* This macro is to work around compilers with missing or broken + * structure assignment. You'll need to fix this code if you have + * such a compiler and you change MAX_COMPS_IN_SCAN. + */ + +#ifndef NO_STRUCT_ASSIGN +#define ASSIGN_STATE(dest,src) ((dest) = (src)) +#else +#if MAX_COMPS_IN_SCAN == 4 +#define ASSIGN_STATE(dest,src) \ + ((dest).last_dc_val[0] = (src).last_dc_val[0], \ + (dest).last_dc_val[1] = (src).last_dc_val[1], \ + (dest).last_dc_val[2] = (src).last_dc_val[2], \ + (dest).last_dc_val[3] = (src).last_dc_val[3]) +#endif +#endif + + +typedef struct { + struct jpeg_entropy_decoder pub; /* public fields */ + + /* These fields are loaded into local variables at start of each MCU. + * In case of suspension, we exit WITHOUT updating them. + */ + bitread_perm_state bitstate; /* Bit buffer at start of MCU */ + savable_state saved; /* Other state at start of MCU */ + + /* These fields are NOT loaded into local working state. */ + unsigned int restarts_to_go; /* MCUs left in this restart interval */ + + /* Pointers to derived tables (these workspaces have image lifespan) */ + d_derived_tbl * dc_derived_tbls[NUM_HUFF_TBLS]; + d_derived_tbl * ac_derived_tbls[NUM_HUFF_TBLS]; +} huff_entropy_decoder; + +typedef huff_entropy_decoder * huff_entropy_ptr; + + +/* + * Initialize for a Huffman-compressed scan. + */ + +METHODDEF(void) +start_pass_huff_decoder (j_decompress_ptr cinfo) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + int ci, dctbl, actbl; + jpeg_component_info * compptr; + + /* Check that the scan parameters Ss, Se, Ah/Al are OK for sequential JPEG. + * This ought to be an error condition, but we make it a warning because + * there are some baseline files out there with all zeroes in these bytes. + */ + if (cinfo->Ss != 0 || cinfo->Se != DCTSIZE2-1 || + cinfo->Ah != 0 || cinfo->Al != 0) + WARNMS(cinfo, JWRN_NOT_SEQUENTIAL); + + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + dctbl = compptr->dc_tbl_no; + actbl = compptr->ac_tbl_no; + /* Make sure requested tables are present */ + if (dctbl < 0 || dctbl >= NUM_HUFF_TBLS || + cinfo->dc_huff_tbl_ptrs[dctbl] == NULL) + ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, dctbl); + if (actbl < 0 || actbl >= NUM_HUFF_TBLS || + cinfo->ac_huff_tbl_ptrs[actbl] == NULL) + ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, actbl); + /* Compute derived values for Huffman tables */ + /* We may do this more than once for a table, but it's not expensive */ + jpeg_make_d_derived_tbl(cinfo, cinfo->dc_huff_tbl_ptrs[dctbl], + & entropy->dc_derived_tbls[dctbl]); + jpeg_make_d_derived_tbl(cinfo, cinfo->ac_huff_tbl_ptrs[actbl], + & entropy->ac_derived_tbls[actbl]); + /* Initialize DC predictions to 0 */ + entropy->saved.last_dc_val[ci] = 0; + } + + /* Initialize bitread state variables */ + entropy->bitstate.bits_left = 0; + entropy->bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */ + entropy->bitstate.printed_eod = FALSE; + + /* Initialize restart counter */ + entropy->restarts_to_go = cinfo->restart_interval; +} + + +/* + * Compute the derived values for a Huffman table. + * Note this is also used by jdphuff.c. + */ + +GLOBAL(void) +jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, JHUFF_TBL * htbl, + d_derived_tbl ** pdtbl) +{ + d_derived_tbl *dtbl; + int p, i, l, si; + int lookbits, ctr; + char huffsize[257]; + unsigned int huffcode[257]; + unsigned int code; + + /* Allocate a workspace if we haven't already done so. */ + if (*pdtbl == NULL) + *pdtbl = (d_derived_tbl *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(d_derived_tbl)); + dtbl = *pdtbl; + dtbl->pub = htbl; /* fill in back link */ + + /* Figure C.1: make table of Huffman code length for each symbol */ + /* Note that this is in code-length order. */ + + p = 0; + for (l = 1; l <= 16; l++) { + for (i = 1; i <= (int) htbl->bits[l]; i++) + huffsize[p++] = (char) l; + } + huffsize[p] = 0; + + /* Figure C.2: generate the codes themselves */ + /* Note that this is in code-length order. */ + + code = 0; + si = huffsize[0]; + p = 0; + while (huffsize[p]) { + while (((int) huffsize[p]) == si) { + huffcode[p++] = code; + code++; + } + code <<= 1; + si++; + } + + /* Figure F.15: generate decoding tables for bit-sequential decoding */ + + p = 0; + for (l = 1; l <= 16; l++) { + if (htbl->bits[l]) { + dtbl->valptr[l] = p; /* huffval[] index of 1st symbol of code length l */ + dtbl->mincode[l] = huffcode[p]; /* minimum code of length l */ + p += htbl->bits[l]; + dtbl->maxcode[l] = huffcode[p-1]; /* maximum code of length l */ + } else { + dtbl->maxcode[l] = -1; /* -1 if no codes of this length */ + } + } + dtbl->maxcode[17] = 0xFFFFFL; /* ensures jpeg_huff_decode terminates */ + + /* Compute lookahead tables to speed up decoding. + * First we set all the table entries to 0, indicating "too long"; + * then we iterate through the Huffman codes that are short enough and + * fill in all the entries that correspond to bit sequences starting + * with that code. + */ + + MEMZERO(dtbl->look_nbits, SIZEOF(dtbl->look_nbits)); + + p = 0; + for (l = 1; l <= HUFF_LOOKAHEAD; l++) { + for (i = 1; i <= (int) htbl->bits[l]; i++, p++) { + /* l = current code's length, p = its index in huffcode[] & huffval[]. */ + /* Generate left-justified code followed by all possible bit sequences */ + lookbits = huffcode[p] << (HUFF_LOOKAHEAD-l); + for (ctr = 1 << (HUFF_LOOKAHEAD-l); ctr > 0; ctr--) { + dtbl->look_nbits[lookbits] = l; + dtbl->look_sym[lookbits] = htbl->huffval[p]; + lookbits++; + } + } + } +} + + +/* + * Out-of-line code for bit fetching (shared with jdphuff.c). + * See jdhuff.h for info about usage. + * Note: current values of get_buffer and bits_left are passed as parameters, + * but are returned in the corresponding fields of the state struct. + * + * On most machines MIN_GET_BITS should be 25 to allow the full 32-bit width + * of get_buffer to be used. (On machines with wider words, an even larger + * buffer could be used.) However, on some machines 32-bit shifts are + * quite slow and take time proportional to the number of places shifted. + * (This is true with most PC compilers, for instance.) In this case it may + * be a win to set MIN_GET_BITS to the minimum value of 15. This reduces the + * average shift distance at the cost of more calls to jpeg_fill_bit_buffer. + */ + +#ifdef SLOW_SHIFT_32 +#define MIN_GET_BITS 15 /* minimum allowable value */ +#else +#define MIN_GET_BITS (BIT_BUF_SIZE-7) +#endif + + +GLOBAL(boolean) +jpeg_fill_bit_buffer (bitread_working_state * state, + register bit_buf_type get_buffer, register int bits_left, + int nbits) +/* Load up the bit buffer to a depth of at least nbits */ +{ + /* Copy heavily used state fields into locals (hopefully registers) */ + register const JOCTET * next_input_byte = state->next_input_byte; + register size_t bytes_in_buffer = state->bytes_in_buffer; + register int c; + + /* Attempt to load at least MIN_GET_BITS bits into get_buffer. */ + /* (It is assumed that no request will be for more than that many bits.) */ + + while (bits_left < MIN_GET_BITS) { + /* Attempt to read a byte */ + if (state->unread_marker != 0) + goto no_more_data; /* can't advance past a marker */ + + if (bytes_in_buffer == 0) { + if (! (*state->cinfo->src->fill_input_buffer) (state->cinfo)) + return FALSE; + next_input_byte = state->cinfo->src->next_input_byte; + bytes_in_buffer = state->cinfo->src->bytes_in_buffer; + } + bytes_in_buffer--; + c = GETJOCTET(*next_input_byte++); + + /* If it's 0xFF, check and discard stuffed zero byte */ + if (c == 0xFF) { + do { + if (bytes_in_buffer == 0) { + if (! (*state->cinfo->src->fill_input_buffer) (state->cinfo)) + return FALSE; + next_input_byte = state->cinfo->src->next_input_byte; + bytes_in_buffer = state->cinfo->src->bytes_in_buffer; + } + bytes_in_buffer--; + c = GETJOCTET(*next_input_byte++); + } while (c == 0xFF); + + if (c == 0) { + /* Found FF/00, which represents an FF data byte */ + c = 0xFF; + } else { + /* Oops, it's actually a marker indicating end of compressed data. */ + /* Better put it back for use later */ + state->unread_marker = c; + + no_more_data: + /* There should be enough bits still left in the data segment; */ + /* if so, just break out of the outer while loop. */ + if (bits_left >= nbits) + break; + /* Uh-oh. Report corrupted data to user and stuff zeroes into + * the data stream, so that we can produce some kind of image. + * Note that this code will be repeated for each byte demanded + * for the rest of the segment. We use a nonvolatile flag to ensure + * that only one warning message appears. + */ + if (! *(state->printed_eod_ptr)) { + WARNMS(state->cinfo, JWRN_HIT_MARKER); + *(state->printed_eod_ptr) = TRUE; + } + c = 0; /* insert a zero byte into bit buffer */ + } + } + + /* OK, load c into get_buffer */ + get_buffer = (get_buffer << 8) | c; + bits_left += 8; + } + + /* Unload the local registers */ + state->next_input_byte = next_input_byte; + state->bytes_in_buffer = bytes_in_buffer; + state->get_buffer = get_buffer; + state->bits_left = bits_left; + + return TRUE; +} + + +/* + * Out-of-line code for Huffman code decoding. + * See jdhuff.h for info about usage. + */ + +GLOBAL(int) +jpeg_huff_decode (bitread_working_state * state, + register bit_buf_type get_buffer, register int bits_left, + d_derived_tbl * htbl, int min_bits) +{ + register int l = min_bits; + register INT32 code; + + /* HUFF_DECODE has determined that the code is at least min_bits */ + /* bits long, so fetch that many bits in one swoop. */ + + CHECK_BIT_BUFFER(*state, l, return -1); + code = GET_BITS(l); + + /* Collect the rest of the Huffman code one bit at a time. */ + /* This is per Figure F.16 in the JPEG spec. */ + + while (code > htbl->maxcode[l]) { + code <<= 1; + CHECK_BIT_BUFFER(*state, 1, return -1); + code |= GET_BITS(1); + l++; + } + + /* Unload the local registers */ + state->get_buffer = get_buffer; + state->bits_left = bits_left; + + /* With garbage input we may reach the sentinel value l = 17. */ + + if (l > 16) { + WARNMS(state->cinfo, JWRN_HUFF_BAD_CODE); + return 0; /* fake a zero as the safest result */ + } + + return htbl->pub->huffval[ htbl->valptr[l] + + ((int) (code - htbl->mincode[l])) ]; +} + + +/* + * Figure F.12: extend sign bit. + * On some machines, a shift and add will be faster than a table lookup. + */ + +#ifdef AVOID_TABLES + +#define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) + (((-1)<<(s)) + 1) : (x)) + +#else + +#define HUFF_EXTEND(x,s) ((x) < extend_test[s] ? (x) + extend_offset[s] : (x)) + +static const int extend_test[16] = /* entry n is 2**(n-1) */ + { 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, + 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 }; + +static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */ + { 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1, + ((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1, + ((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1, + ((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 }; + +#endif /* AVOID_TABLES */ + + +/* + * Check for a restart marker & resynchronize decoder. + * Returns FALSE if must suspend. + */ + +LOCAL(boolean) +process_restart (j_decompress_ptr cinfo) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + int ci; + + /* Throw away any unused bits remaining in bit buffer; */ + /* include any full bytes in next_marker's count of discarded bytes */ + cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8; + entropy->bitstate.bits_left = 0; + + /* Advance past the RSTn marker */ + if (! (*cinfo->marker->read_restart_marker) (cinfo)) + return FALSE; + + /* Re-initialize DC predictions to 0 */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) + entropy->saved.last_dc_val[ci] = 0; + + /* Reset restart counter */ + entropy->restarts_to_go = cinfo->restart_interval; + + /* Next segment can get another out-of-data warning */ + entropy->bitstate.printed_eod = FALSE; + + return TRUE; +} + + +/* + * Decode and return one MCU's worth of Huffman-compressed coefficients. + * The coefficients are reordered from zigzag order into natural array order, + * but are not dequantized. + * + * The i'th block of the MCU is stored into the block pointed to by + * MCU_data[i]. WE ASSUME THIS AREA HAS BEEN ZEROED BY THE CALLER. + * (Wholesale zeroing is usually a little faster than retail...) + * + * Returns FALSE if data source requested suspension. In that case no + * changes have been made to permanent state. (Exception: some output + * coefficients may already have been assigned. This is harmless for + * this module, since we'll just re-assign them on the next call.) + */ + +METHODDEF(boolean) +decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + register int s, k, r; + int blkn, ci; + JBLOCKROW block; + BITREAD_STATE_VARS; + savable_state state; + d_derived_tbl * dctbl; + d_derived_tbl * actbl; + jpeg_component_info * compptr; + + /* Process restart marker if needed; may have to suspend */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) + if (! process_restart(cinfo)) + return FALSE; + } + + /* Load up working state */ + BITREAD_LOAD_STATE(cinfo,entropy->bitstate); + ASSIGN_STATE(state, entropy->saved); + + /* Outer loop handles each block in the MCU */ + + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + block = MCU_data[blkn]; + ci = cinfo->MCU_membership[blkn]; + compptr = cinfo->cur_comp_info[ci]; + dctbl = entropy->dc_derived_tbls[compptr->dc_tbl_no]; + actbl = entropy->ac_derived_tbls[compptr->ac_tbl_no]; + + /* Decode a single block's worth of coefficients */ + + /* Section F.2.2.1: decode the DC coefficient difference */ + HUFF_DECODE(s, br_state, dctbl, return FALSE, label1); + if (s) { + CHECK_BIT_BUFFER(br_state, s, return FALSE); + r = GET_BITS(s); + s = HUFF_EXTEND(r, s); + } + + /* Shortcut if component's values are not interesting */ + if (! compptr->component_needed) + goto skip_ACs; + + /* Convert DC difference to actual value, update last_dc_val */ + s += state.last_dc_val[ci]; + state.last_dc_val[ci] = s; + /* Output the DC coefficient (assumes jpeg_natural_order[0] = 0) */ + (*block)[0] = (JCOEF) s; + + /* Do we need to decode the AC coefficients for this component? */ + if (compptr->DCT_scaled_size > 1) { + + /* Section F.2.2.2: decode the AC coefficients */ + /* Since zeroes are skipped, output area must be cleared beforehand */ + for (k = 1; k < DCTSIZE2; k++) { + HUFF_DECODE(s, br_state, actbl, return FALSE, label2); + + r = s >> 4; + s &= 15; + + if (s) { + k += r; + CHECK_BIT_BUFFER(br_state, s, return FALSE); + r = GET_BITS(s); + s = HUFF_EXTEND(r, s); + /* Output coefficient in natural (dezigzagged) order. + * Note: the extra entries in jpeg_natural_order[] will save us + * if k >= DCTSIZE2, which could happen if the data is corrupted. + */ + (*block)[jpeg_natural_order[k]] = (JCOEF) s; + } else { + if (r != 15) + break; + k += 15; + } + } + + } else { +skip_ACs: + + /* Section F.2.2.2: decode the AC coefficients */ + /* In this path we just discard the values */ + for (k = 1; k < DCTSIZE2; k++) { + HUFF_DECODE(s, br_state, actbl, return FALSE, label3); + + r = s >> 4; + s &= 15; + + if (s) { + k += r; + CHECK_BIT_BUFFER(br_state, s, return FALSE); + DROP_BITS(s); + } else { + if (r != 15) + break; + k += 15; + } + } + + } + } + + /* Completed MCU, so update state */ + BITREAD_SAVE_STATE(cinfo,entropy->bitstate); + ASSIGN_STATE(entropy->saved, state); + + /* Account for restart interval (no-op if not using restarts) */ + entropy->restarts_to_go--; + + return TRUE; +} + + +/* + * Module initialization routine for Huffman entropy decoding. + */ + +GLOBAL(void) +jinit_huff_decoder (j_decompress_ptr cinfo) +{ + huff_entropy_ptr entropy; + int i; + + entropy = (huff_entropy_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(huff_entropy_decoder)); + cinfo->entropy = (struct jpeg_entropy_decoder *) entropy; + entropy->pub.start_pass = start_pass_huff_decoder; + entropy->pub.decode_mcu = decode_mcu; + + /* Mark tables unallocated */ + for (i = 0; i < NUM_HUFF_TBLS; i++) { + entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL; + } +} diff --git a/gs/jpeg/jdhuff.h b/gs/jpeg/jdhuff.h new file mode 100644 index 000000000..bcc3ab127 --- /dev/null +++ b/gs/jpeg/jdhuff.h @@ -0,0 +1,202 @@ +/* + * jdhuff.h + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains declarations for Huffman entropy decoding routines + * that are shared between the sequential decoder (jdhuff.c) and the + * progressive decoder (jdphuff.c). No other modules need to see these. + */ + +/* Short forms of external names for systems with brain-damaged linkers. */ + +#ifdef NEED_SHORT_EXTERNAL_NAMES +#define jpeg_make_d_derived_tbl jMkDDerived +#define jpeg_fill_bit_buffer jFilBitBuf +#define jpeg_huff_decode jHufDecode +#endif /* NEED_SHORT_EXTERNAL_NAMES */ + + +/* Derived data constructed for each Huffman table */ + +#define HUFF_LOOKAHEAD 8 /* # of bits of lookahead */ + +typedef struct { + /* Basic tables: (element [0] of each array is unused) */ + INT32 mincode[17]; /* smallest code of length k */ + INT32 maxcode[18]; /* largest code of length k (-1 if none) */ + /* (maxcode[17] is a sentinel to ensure jpeg_huff_decode terminates) */ + int valptr[17]; /* huffval[] index of 1st symbol of length k */ + + /* Link to public Huffman table (needed only in jpeg_huff_decode) */ + JHUFF_TBL *pub; + + /* Lookahead tables: indexed by the next HUFF_LOOKAHEAD bits of + * the input data stream. If the next Huffman code is no more + * than HUFF_LOOKAHEAD bits long, we can obtain its length and + * the corresponding symbol directly from these tables. + */ + int look_nbits[1< 32 bits on your machine, and shifting/masking longs is + * reasonably fast, making bit_buf_type be long and setting BIT_BUF_SIZE + * appropriately should be a win. Unfortunately we can't do this with + * something like #define BIT_BUF_SIZE (sizeof(bit_buf_type)*8) + * because not all machines measure sizeof in 8-bit bytes. + */ + +typedef struct { /* Bitreading state saved across MCUs */ + bit_buf_type get_buffer; /* current bit-extraction buffer */ + int bits_left; /* # of unused bits in it */ + boolean printed_eod; /* flag to suppress multiple warning msgs */ +} bitread_perm_state; + +typedef struct { /* Bitreading working state within an MCU */ + /* current data source state */ + const JOCTET * next_input_byte; /* => next byte to read from source */ + size_t bytes_in_buffer; /* # of bytes remaining in source buffer */ + int unread_marker; /* nonzero if we have hit a marker */ + /* bit input buffer --- note these values are kept in register variables, + * not in this struct, inside the inner loops. + */ + bit_buf_type get_buffer; /* current bit-extraction buffer */ + int bits_left; /* # of unused bits in it */ + /* pointers needed by jpeg_fill_bit_buffer */ + j_decompress_ptr cinfo; /* back link to decompress master record */ + boolean * printed_eod_ptr; /* => flag in permanent state */ +} bitread_working_state; + +/* Macros to declare and load/save bitread local variables. */ +#define BITREAD_STATE_VARS \ + register bit_buf_type get_buffer; \ + register int bits_left; \ + bitread_working_state br_state + +#define BITREAD_LOAD_STATE(cinfop,permstate) \ + br_state.cinfo = cinfop; \ + br_state.next_input_byte = cinfop->src->next_input_byte; \ + br_state.bytes_in_buffer = cinfop->src->bytes_in_buffer; \ + br_state.unread_marker = cinfop->unread_marker; \ + get_buffer = permstate.get_buffer; \ + bits_left = permstate.bits_left; \ + br_state.printed_eod_ptr = & permstate.printed_eod + +#define BITREAD_SAVE_STATE(cinfop,permstate) \ + cinfop->src->next_input_byte = br_state.next_input_byte; \ + cinfop->src->bytes_in_buffer = br_state.bytes_in_buffer; \ + cinfop->unread_marker = br_state.unread_marker; \ + permstate.get_buffer = get_buffer; \ + permstate.bits_left = bits_left + +/* + * These macros provide the in-line portion of bit fetching. + * Use CHECK_BIT_BUFFER to ensure there are N bits in get_buffer + * before using GET_BITS, PEEK_BITS, or DROP_BITS. + * The variables get_buffer and bits_left are assumed to be locals, + * but the state struct might not be (jpeg_huff_decode needs this). + * CHECK_BIT_BUFFER(state,n,action); + * Ensure there are N bits in get_buffer; if suspend, take action. + * val = GET_BITS(n); + * Fetch next N bits. + * val = PEEK_BITS(n); + * Fetch next N bits without removing them from the buffer. + * DROP_BITS(n); + * Discard next N bits. + * The value N should be a simple variable, not an expression, because it + * is evaluated multiple times. + */ + +#define CHECK_BIT_BUFFER(state,nbits,action) \ + { if (bits_left < (nbits)) { \ + if (! jpeg_fill_bit_buffer(&(state),get_buffer,bits_left,nbits)) \ + { action; } \ + get_buffer = (state).get_buffer; bits_left = (state).bits_left; } } + +#define GET_BITS(nbits) \ + (((int) (get_buffer >> (bits_left -= (nbits)))) & ((1<<(nbits))-1)) + +#define PEEK_BITS(nbits) \ + (((int) (get_buffer >> (bits_left - (nbits)))) & ((1<<(nbits))-1)) + +#define DROP_BITS(nbits) \ + (bits_left -= (nbits)) + +/* Load up the bit buffer to a depth of at least nbits */ +EXTERN(boolean) jpeg_fill_bit_buffer + JPP((bitread_working_state * state, register bit_buf_type get_buffer, + register int bits_left, int nbits)); + + +/* + * Code for extracting next Huffman-coded symbol from input bit stream. + * Again, this is time-critical and we make the main paths be macros. + * + * We use a lookahead table to process codes of up to HUFF_LOOKAHEAD bits + * without looping. Usually, more than 95% of the Huffman codes will be 8 + * or fewer bits long. The few overlength codes are handled with a loop, + * which need not be inline code. + * + * Notes about the HUFF_DECODE macro: + * 1. Near the end of the data segment, we may fail to get enough bits + * for a lookahead. In that case, we do it the hard way. + * 2. If the lookahead table contains no entry, the next code must be + * more than HUFF_LOOKAHEAD bits long. + * 3. jpeg_huff_decode returns -1 if forced to suspend. + */ + +#define HUFF_DECODE(result,state,htbl,failaction,slowlabel) \ +{ register int nb, look; \ + if (bits_left < HUFF_LOOKAHEAD) { \ + if (! jpeg_fill_bit_buffer(&state,get_buffer,bits_left, 0)) {failaction;} \ + get_buffer = state.get_buffer; bits_left = state.bits_left; \ + if (bits_left < HUFF_LOOKAHEAD) { \ + nb = 1; goto slowlabel; \ + } \ + } \ + look = PEEK_BITS(HUFF_LOOKAHEAD); \ + if ((nb = htbl->look_nbits[look]) != 0) { \ + DROP_BITS(nb); \ + result = htbl->look_sym[look]; \ + } else { \ + nb = HUFF_LOOKAHEAD+1; \ +slowlabel: \ + if ((result=jpeg_huff_decode(&state,get_buffer,bits_left,htbl,nb)) < 0) \ + { failaction; } \ + get_buffer = state.get_buffer; bits_left = state.bits_left; \ + } \ +} + +/* Out-of-line case for Huffman code fetching */ +EXTERN(int) jpeg_huff_decode + JPP((bitread_working_state * state, register bit_buf_type get_buffer, + register int bits_left, d_derived_tbl * htbl, int min_bits)); diff --git a/gs/jpeg/jdinput.c b/gs/jpeg/jdinput.c new file mode 100644 index 000000000..a8565c501 --- /dev/null +++ b/gs/jpeg/jdinput.c @@ -0,0 +1,381 @@ +/* + * jdinput.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains input control logic for the JPEG decompressor. + * These routines are concerned with controlling the decompressor's input + * processing (marker reading and coefficient decoding). The actual input + * reading is done in jdmarker.c, jdhuff.c, and jdphuff.c. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Private state */ + +typedef struct { + struct jpeg_input_controller pub; /* public fields */ + + boolean inheaders; /* TRUE until first SOS is reached */ +} my_input_controller; + +typedef my_input_controller * my_inputctl_ptr; + + +/* Forward declarations */ +METHODDEF(int) consume_markers JPP((j_decompress_ptr cinfo)); + + +/* + * Routines to calculate various quantities related to the size of the image. + */ + +LOCAL(void) +initial_setup (j_decompress_ptr cinfo) +/* Called once, when first SOS marker is reached */ +{ + int ci; + jpeg_component_info *compptr; + + /* Make sure image isn't bigger than I can handle */ + if ((long) cinfo->image_height > (long) JPEG_MAX_DIMENSION || + (long) cinfo->image_width > (long) JPEG_MAX_DIMENSION) + ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION); + + /* For now, precision must match compiled-in value... */ + if (cinfo->data_precision != BITS_IN_JSAMPLE) + ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); + + /* Check that number of components won't exceed internal array sizes */ + if (cinfo->num_components > MAX_COMPONENTS) + ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, + MAX_COMPONENTS); + + /* Compute maximum sampling factors; check factor validity */ + cinfo->max_h_samp_factor = 1; + cinfo->max_v_samp_factor = 1; + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + if (compptr->h_samp_factor<=0 || compptr->h_samp_factor>MAX_SAMP_FACTOR || + compptr->v_samp_factor<=0 || compptr->v_samp_factor>MAX_SAMP_FACTOR) + ERREXIT(cinfo, JERR_BAD_SAMPLING); + cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor, + compptr->h_samp_factor); + cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor, + compptr->v_samp_factor); + } + + /* We initialize DCT_scaled_size and min_DCT_scaled_size to DCTSIZE. + * In the full decompressor, this will be overridden by jdmaster.c; + * but in the transcoder, jdmaster.c is not used, so we must do it here. + */ + cinfo->min_DCT_scaled_size = DCTSIZE; + + /* Compute dimensions of components */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + compptr->DCT_scaled_size = DCTSIZE; + /* Size in DCT blocks */ + compptr->width_in_blocks = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, + (long) (cinfo->max_h_samp_factor * DCTSIZE)); + compptr->height_in_blocks = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, + (long) (cinfo->max_v_samp_factor * DCTSIZE)); + /* downsampled_width and downsampled_height will also be overridden by + * jdmaster.c if we are doing full decompression. The transcoder library + * doesn't use these values, but the calling application might. + */ + /* Size in samples */ + compptr->downsampled_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, + (long) cinfo->max_h_samp_factor); + compptr->downsampled_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, + (long) cinfo->max_v_samp_factor); + /* Mark component needed, until color conversion says otherwise */ + compptr->component_needed = TRUE; + /* Mark no quantization table yet saved for component */ + compptr->quant_table = NULL; + } + + /* Compute number of fully interleaved MCU rows. */ + cinfo->total_iMCU_rows = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height, + (long) (cinfo->max_v_samp_factor*DCTSIZE)); + + /* Decide whether file contains multiple scans */ + if (cinfo->comps_in_scan < cinfo->num_components || cinfo->progressive_mode) + cinfo->inputctl->has_multiple_scans = TRUE; + else + cinfo->inputctl->has_multiple_scans = FALSE; +} + + +LOCAL(void) +per_scan_setup (j_decompress_ptr cinfo) +/* Do computations that are needed before processing a JPEG scan */ +/* cinfo->comps_in_scan and cinfo->cur_comp_info[] were set from SOS marker */ +{ + int ci, mcublks, tmp; + jpeg_component_info *compptr; + + if (cinfo->comps_in_scan == 1) { + + /* Noninterleaved (single-component) scan */ + compptr = cinfo->cur_comp_info[0]; + + /* Overall image size in MCUs */ + cinfo->MCUs_per_row = compptr->width_in_blocks; + cinfo->MCU_rows_in_scan = compptr->height_in_blocks; + + /* For noninterleaved scan, always one block per MCU */ + compptr->MCU_width = 1; + compptr->MCU_height = 1; + compptr->MCU_blocks = 1; + compptr->MCU_sample_width = compptr->DCT_scaled_size; + compptr->last_col_width = 1; + /* For noninterleaved scans, it is convenient to define last_row_height + * as the number of block rows present in the last iMCU row. + */ + tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor); + if (tmp == 0) tmp = compptr->v_samp_factor; + compptr->last_row_height = tmp; + + /* Prepare array describing MCU composition */ + cinfo->blocks_in_MCU = 1; + cinfo->MCU_membership[0] = 0; + + } else { + + /* Interleaved (multi-component) scan */ + if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN) + ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan, + MAX_COMPS_IN_SCAN); + + /* Overall image size in MCUs */ + cinfo->MCUs_per_row = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width, + (long) (cinfo->max_h_samp_factor*DCTSIZE)); + cinfo->MCU_rows_in_scan = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height, + (long) (cinfo->max_v_samp_factor*DCTSIZE)); + + cinfo->blocks_in_MCU = 0; + + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + /* Sampling factors give # of blocks of component in each MCU */ + compptr->MCU_width = compptr->h_samp_factor; + compptr->MCU_height = compptr->v_samp_factor; + compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height; + compptr->MCU_sample_width = compptr->MCU_width * compptr->DCT_scaled_size; + /* Figure number of non-dummy blocks in last MCU column & row */ + tmp = (int) (compptr->width_in_blocks % compptr->MCU_width); + if (tmp == 0) tmp = compptr->MCU_width; + compptr->last_col_width = tmp; + tmp = (int) (compptr->height_in_blocks % compptr->MCU_height); + if (tmp == 0) tmp = compptr->MCU_height; + compptr->last_row_height = tmp; + /* Prepare array describing MCU composition */ + mcublks = compptr->MCU_blocks; + if (cinfo->blocks_in_MCU + mcublks > D_MAX_BLOCKS_IN_MCU) + ERREXIT(cinfo, JERR_BAD_MCU_SIZE); + while (mcublks-- > 0) { + cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci; + } + } + + } +} + + +/* + * Save away a copy of the Q-table referenced by each component present + * in the current scan, unless already saved during a prior scan. + * + * In a multiple-scan JPEG file, the encoder could assign different components + * the same Q-table slot number, but change table definitions between scans + * so that each component uses a different Q-table. (The IJG encoder is not + * currently capable of doing this, but other encoders might.) Since we want + * to be able to dequantize all the components at the end of the file, this + * means that we have to save away the table actually used for each component. + * We do this by copying the table at the start of the first scan containing + * the component. + * The JPEG spec prohibits the encoder from changing the contents of a Q-table + * slot between scans of a component using that slot. If the encoder does so + * anyway, this decoder will simply use the Q-table values that were current + * at the start of the first scan for the component. + * + * The decompressor output side looks only at the saved quant tables, + * not at the current Q-table slots. + */ + +LOCAL(void) +latch_quant_tables (j_decompress_ptr cinfo) +{ + int ci, qtblno; + jpeg_component_info *compptr; + JQUANT_TBL * qtbl; + + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + /* No work if we already saved Q-table for this component */ + if (compptr->quant_table != NULL) + continue; + /* Make sure specified quantization table is present */ + qtblno = compptr->quant_tbl_no; + if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS || + cinfo->quant_tbl_ptrs[qtblno] == NULL) + ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno); + /* OK, save away the quantization table */ + qtbl = (JQUANT_TBL *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(JQUANT_TBL)); + MEMCOPY(qtbl, cinfo->quant_tbl_ptrs[qtblno], SIZEOF(JQUANT_TBL)); + compptr->quant_table = qtbl; + } +} + + +/* + * Initialize the input modules to read a scan of compressed data. + * The first call to this is done by jdmaster.c after initializing + * the entire decompressor (during jpeg_start_decompress). + * Subsequent calls come from consume_markers, below. + */ + +METHODDEF(void) +start_input_pass (j_decompress_ptr cinfo) +{ + per_scan_setup(cinfo); + latch_quant_tables(cinfo); + (*cinfo->entropy->start_pass) (cinfo); + (*cinfo->coef->start_input_pass) (cinfo); + cinfo->inputctl->consume_input = cinfo->coef->consume_data; +} + + +/* + * Finish up after inputting a compressed-data scan. + * This is called by the coefficient controller after it's read all + * the expected data of the scan. + */ + +METHODDEF(void) +finish_input_pass (j_decompress_ptr cinfo) +{ + cinfo->inputctl->consume_input = consume_markers; +} + + +/* + * Read JPEG markers before, between, or after compressed-data scans. + * Change state as necessary when a new scan is reached. + * Return value is JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI. + * + * The consume_input method pointer points either here or to the + * coefficient controller's consume_data routine, depending on whether + * we are reading a compressed data segment or inter-segment markers. + */ + +METHODDEF(int) +consume_markers (j_decompress_ptr cinfo) +{ + my_inputctl_ptr inputctl = (my_inputctl_ptr) cinfo->inputctl; + int val; + + if (inputctl->pub.eoi_reached) /* After hitting EOI, read no further */ + return JPEG_REACHED_EOI; + + val = (*cinfo->marker->read_markers) (cinfo); + + switch (val) { + case JPEG_REACHED_SOS: /* Found SOS */ + if (inputctl->inheaders) { /* 1st SOS */ + initial_setup(cinfo); + inputctl->inheaders = FALSE; + /* Note: start_input_pass must be called by jdmaster.c + * before any more input can be consumed. jdapi.c is + * responsible for enforcing this sequencing. + */ + } else { /* 2nd or later SOS marker */ + if (! inputctl->pub.has_multiple_scans) + ERREXIT(cinfo, JERR_EOI_EXPECTED); /* Oops, I wasn't expecting this! */ + start_input_pass(cinfo); + } + break; + case JPEG_REACHED_EOI: /* Found EOI */ + inputctl->pub.eoi_reached = TRUE; + if (inputctl->inheaders) { /* Tables-only datastream, apparently */ + if (cinfo->marker->saw_SOF) + ERREXIT(cinfo, JERR_SOF_NO_SOS); + } else { + /* Prevent infinite loop in coef ctlr's decompress_data routine + * if user set output_scan_number larger than number of scans. + */ + if (cinfo->output_scan_number > cinfo->input_scan_number) + cinfo->output_scan_number = cinfo->input_scan_number; + } + break; + case JPEG_SUSPENDED: + break; + } + + return val; +} + + +/* + * Reset state to begin a fresh datastream. + */ + +METHODDEF(void) +reset_input_controller (j_decompress_ptr cinfo) +{ + my_inputctl_ptr inputctl = (my_inputctl_ptr) cinfo->inputctl; + + inputctl->pub.consume_input = consume_markers; + inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */ + inputctl->pub.eoi_reached = FALSE; + inputctl->inheaders = TRUE; + /* Reset other modules */ + (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); + (*cinfo->marker->reset_marker_reader) (cinfo); + /* Reset progression state -- would be cleaner if entropy decoder did this */ + cinfo->coef_bits = NULL; +} + + +/* + * Initialize the input controller module. + * This is called only once, when the decompression object is created. + */ + +GLOBAL(void) +jinit_input_controller (j_decompress_ptr cinfo) +{ + my_inputctl_ptr inputctl; + + /* Create subobject in permanent pool */ + inputctl = (my_inputctl_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, + SIZEOF(my_input_controller)); + cinfo->inputctl = (struct jpeg_input_controller *) inputctl; + /* Initialize method pointers */ + inputctl->pub.consume_input = consume_markers; + inputctl->pub.reset_input_controller = reset_input_controller; + inputctl->pub.start_input_pass = start_input_pass; + inputctl->pub.finish_input_pass = finish_input_pass; + /* Initialize state: can't use reset_input_controller since we don't + * want to try to reset other modules yet. + */ + inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */ + inputctl->pub.eoi_reached = FALSE; + inputctl->inheaders = TRUE; +} diff --git a/gs/jpeg/jdmainct.c b/gs/jpeg/jdmainct.c new file mode 100644 index 000000000..13c956f5d --- /dev/null +++ b/gs/jpeg/jdmainct.c @@ -0,0 +1,512 @@ +/* + * jdmainct.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the main buffer controller for decompression. + * The main buffer lies between the JPEG decompressor proper and the + * post-processor; it holds downsampled data in the JPEG colorspace. + * + * Note that this code is bypassed in raw-data mode, since the application + * supplies the equivalent of the main buffer in that case. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* + * In the current system design, the main buffer need never be a full-image + * buffer; any full-height buffers will be found inside the coefficient or + * postprocessing controllers. Nonetheless, the main controller is not + * trivial. Its responsibility is to provide context rows for upsampling/ + * rescaling, and doing this in an efficient fashion is a bit tricky. + * + * Postprocessor input data is counted in "row groups". A row group + * is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size) + * sample rows of each component. (We require DCT_scaled_size values to be + * chosen such that these numbers are integers. In practice DCT_scaled_size + * values will likely be powers of two, so we actually have the stronger + * condition that DCT_scaled_size / min_DCT_scaled_size is an integer.) + * Upsampling will typically produce max_v_samp_factor pixel rows from each + * row group (times any additional scale factor that the upsampler is + * applying). + * + * The coefficient controller will deliver data to us one iMCU row at a time; + * each iMCU row contains v_samp_factor * DCT_scaled_size sample rows, or + * exactly min_DCT_scaled_size row groups. (This amount of data corresponds + * to one row of MCUs when the image is fully interleaved.) Note that the + * number of sample rows varies across components, but the number of row + * groups does not. Some garbage sample rows may be included in the last iMCU + * row at the bottom of the image. + * + * Depending on the vertical scaling algorithm used, the upsampler may need + * access to the sample row(s) above and below its current input row group. + * The upsampler is required to set need_context_rows TRUE at global selection + * time if so. When need_context_rows is FALSE, this controller can simply + * obtain one iMCU row at a time from the coefficient controller and dole it + * out as row groups to the postprocessor. + * + * When need_context_rows is TRUE, this controller guarantees that the buffer + * passed to postprocessing contains at least one row group's worth of samples + * above and below the row group(s) being processed. Note that the context + * rows "above" the first passed row group appear at negative row offsets in + * the passed buffer. At the top and bottom of the image, the required + * context rows are manufactured by duplicating the first or last real sample + * row; this avoids having special cases in the upsampling inner loops. + * + * The amount of context is fixed at one row group just because that's a + * convenient number for this controller to work with. The existing + * upsamplers really only need one sample row of context. An upsampler + * supporting arbitrary output rescaling might wish for more than one row + * group of context when shrinking the image; tough, we don't handle that. + * (This is justified by the assumption that downsizing will be handled mostly + * by adjusting the DCT_scaled_size values, so that the actual scale factor at + * the upsample step needn't be much less than one.) + * + * To provide the desired context, we have to retain the last two row groups + * of one iMCU row while reading in the next iMCU row. (The last row group + * can't be processed until we have another row group for its below-context, + * and so we have to save the next-to-last group too for its above-context.) + * We could do this most simply by copying data around in our buffer, but + * that'd be very slow. We can avoid copying any data by creating a rather + * strange pointer structure. Here's how it works. We allocate a workspace + * consisting of M+2 row groups (where M = min_DCT_scaled_size is the number + * of row groups per iMCU row). We create two sets of redundant pointers to + * the workspace. Labeling the physical row groups 0 to M+1, the synthesized + * pointer lists look like this: + * M+1 M-1 + * master pointer --> 0 master pointer --> 0 + * 1 1 + * ... ... + * M-3 M-3 + * M-2 M + * M-1 M+1 + * M M-2 + * M+1 M-1 + * 0 0 + * We read alternate iMCU rows using each master pointer; thus the last two + * row groups of the previous iMCU row remain un-overwritten in the workspace. + * The pointer lists are set up so that the required context rows appear to + * be adjacent to the proper places when we pass the pointer lists to the + * upsampler. + * + * The above pictures describe the normal state of the pointer lists. + * At top and bottom of the image, we diddle the pointer lists to duplicate + * the first or last sample row as necessary (this is cheaper than copying + * sample rows around). + * + * This scheme breaks down if M < 2, ie, min_DCT_scaled_size is 1. In that + * situation each iMCU row provides only one row group so the buffering logic + * must be different (eg, we must read two iMCU rows before we can emit the + * first row group). For now, we simply do not support providing context + * rows when min_DCT_scaled_size is 1. That combination seems unlikely to + * be worth providing --- if someone wants a 1/8th-size preview, they probably + * want it quick and dirty, so a context-free upsampler is sufficient. + */ + + +/* Private buffer controller object */ + +typedef struct { + struct jpeg_d_main_controller pub; /* public fields */ + + /* Pointer to allocated workspace (M or M+2 row groups). */ + JSAMPARRAY buffer[MAX_COMPONENTS]; + + boolean buffer_full; /* Have we gotten an iMCU row from decoder? */ + JDIMENSION rowgroup_ctr; /* counts row groups output to postprocessor */ + + /* Remaining fields are only used in the context case. */ + + /* These are the master pointers to the funny-order pointer lists. */ + JSAMPIMAGE xbuffer[2]; /* pointers to weird pointer lists */ + + int whichptr; /* indicates which pointer set is now in use */ + int context_state; /* process_data state machine status */ + JDIMENSION rowgroups_avail; /* row groups available to postprocessor */ + JDIMENSION iMCU_row_ctr; /* counts iMCU rows to detect image top/bot */ +} my_main_controller; + +typedef my_main_controller * my_main_ptr; + +/* context_state values: */ +#define CTX_PREPARE_FOR_IMCU 0 /* need to prepare for MCU row */ +#define CTX_PROCESS_IMCU 1 /* feeding iMCU to postprocessor */ +#define CTX_POSTPONED_ROW 2 /* feeding postponed row group */ + + +/* Forward declarations */ +METHODDEF(void) process_data_simple_main + JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf, + JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)); +METHODDEF(void) process_data_context_main + JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf, + JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)); +#ifdef QUANT_2PASS_SUPPORTED +METHODDEF(void) process_data_crank_post + JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf, + JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)); +#endif + + +LOCAL(void) +alloc_funny_pointers (j_decompress_ptr cinfo) +/* Allocate space for the funny pointer lists. + * This is done only once, not once per pass. + */ +{ + my_main_ptr main = (my_main_ptr) cinfo->main; + int ci, rgroup; + int M = cinfo->min_DCT_scaled_size; + jpeg_component_info *compptr; + JSAMPARRAY xbuf; + + /* Get top-level space for component array pointers. + * We alloc both arrays with one call to save a few cycles. + */ + main->xbuffer[0] = (JSAMPIMAGE) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + cinfo->num_components * 2 * SIZEOF(JSAMPARRAY)); + main->xbuffer[1] = main->xbuffer[0] + cinfo->num_components; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / + cinfo->min_DCT_scaled_size; /* height of a row group of component */ + /* Get space for pointer lists --- M+4 row groups in each list. + * We alloc both pointer lists with one call to save a few cycles. + */ + xbuf = (JSAMPARRAY) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + 2 * (rgroup * (M + 4)) * SIZEOF(JSAMPROW)); + xbuf += rgroup; /* want one row group at negative offsets */ + main->xbuffer[0][ci] = xbuf; + xbuf += rgroup * (M + 4); + main->xbuffer[1][ci] = xbuf; + } +} + + +LOCAL(void) +make_funny_pointers (j_decompress_ptr cinfo) +/* Create the funny pointer lists discussed in the comments above. + * The actual workspace is already allocated (in main->buffer), + * and the space for the pointer lists is allocated too. + * This routine just fills in the curiously ordered lists. + * This will be repeated at the beginning of each pass. + */ +{ + my_main_ptr main = (my_main_ptr) cinfo->main; + int ci, i, rgroup; + int M = cinfo->min_DCT_scaled_size; + jpeg_component_info *compptr; + JSAMPARRAY buf, xbuf0, xbuf1; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / + cinfo->min_DCT_scaled_size; /* height of a row group of component */ + xbuf0 = main->xbuffer[0][ci]; + xbuf1 = main->xbuffer[1][ci]; + /* First copy the workspace pointers as-is */ + buf = main->buffer[ci]; + for (i = 0; i < rgroup * (M + 2); i++) { + xbuf0[i] = xbuf1[i] = buf[i]; + } + /* In the second list, put the last four row groups in swapped order */ + for (i = 0; i < rgroup * 2; i++) { + xbuf1[rgroup*(M-2) + i] = buf[rgroup*M + i]; + xbuf1[rgroup*M + i] = buf[rgroup*(M-2) + i]; + } + /* The wraparound pointers at top and bottom will be filled later + * (see set_wraparound_pointers, below). Initially we want the "above" + * pointers to duplicate the first actual data line. This only needs + * to happen in xbuffer[0]. + */ + for (i = 0; i < rgroup; i++) { + xbuf0[i - rgroup] = xbuf0[0]; + } + } +} + + +LOCAL(void) +set_wraparound_pointers (j_decompress_ptr cinfo) +/* Set up the "wraparound" pointers at top and bottom of the pointer lists. + * This changes the pointer list state from top-of-image to the normal state. + */ +{ + my_main_ptr main = (my_main_ptr) cinfo->main; + int ci, i, rgroup; + int M = cinfo->min_DCT_scaled_size; + jpeg_component_info *compptr; + JSAMPARRAY xbuf0, xbuf1; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / + cinfo->min_DCT_scaled_size; /* height of a row group of component */ + xbuf0 = main->xbuffer[0][ci]; + xbuf1 = main->xbuffer[1][ci]; + for (i = 0; i < rgroup; i++) { + xbuf0[i - rgroup] = xbuf0[rgroup*(M+1) + i]; + xbuf1[i - rgroup] = xbuf1[rgroup*(M+1) + i]; + xbuf0[rgroup*(M+2) + i] = xbuf0[i]; + xbuf1[rgroup*(M+2) + i] = xbuf1[i]; + } + } +} + + +LOCAL(void) +set_bottom_pointers (j_decompress_ptr cinfo) +/* Change the pointer lists to duplicate the last sample row at the bottom + * of the image. whichptr indicates which xbuffer holds the final iMCU row. + * Also sets rowgroups_avail to indicate number of nondummy row groups in row. + */ +{ + my_main_ptr main = (my_main_ptr) cinfo->main; + int ci, i, rgroup, iMCUheight, rows_left; + jpeg_component_info *compptr; + JSAMPARRAY xbuf; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Count sample rows in one iMCU row and in one row group */ + iMCUheight = compptr->v_samp_factor * compptr->DCT_scaled_size; + rgroup = iMCUheight / cinfo->min_DCT_scaled_size; + /* Count nondummy sample rows remaining for this component */ + rows_left = (int) (compptr->downsampled_height % (JDIMENSION) iMCUheight); + if (rows_left == 0) rows_left = iMCUheight; + /* Count nondummy row groups. Should get same answer for each component, + * so we need only do it once. + */ + if (ci == 0) { + main->rowgroups_avail = (JDIMENSION) ((rows_left-1) / rgroup + 1); + } + /* Duplicate the last real sample row rgroup*2 times; this pads out the + * last partial rowgroup and ensures at least one full rowgroup of context. + */ + xbuf = main->xbuffer[main->whichptr][ci]; + for (i = 0; i < rgroup * 2; i++) { + xbuf[rows_left + i] = xbuf[rows_left-1]; + } + } +} + + +/* + * Initialize for a processing pass. + */ + +METHODDEF(void) +start_pass_main (j_decompress_ptr cinfo, J_BUF_MODE pass_mode) +{ + my_main_ptr main = (my_main_ptr) cinfo->main; + + switch (pass_mode) { + case JBUF_PASS_THRU: + if (cinfo->upsample->need_context_rows) { + main->pub.process_data = process_data_context_main; + make_funny_pointers(cinfo); /* Create the xbuffer[] lists */ + main->whichptr = 0; /* Read first iMCU row into xbuffer[0] */ + main->context_state = CTX_PREPARE_FOR_IMCU; + main->iMCU_row_ctr = 0; + } else { + /* Simple case with no context needed */ + main->pub.process_data = process_data_simple_main; + } + main->buffer_full = FALSE; /* Mark buffer empty */ + main->rowgroup_ctr = 0; + break; +#ifdef QUANT_2PASS_SUPPORTED + case JBUF_CRANK_DEST: + /* For last pass of 2-pass quantization, just crank the postprocessor */ + main->pub.process_data = process_data_crank_post; + break; +#endif + default: + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + break; + } +} + + +/* + * Process some data. + * This handles the simple case where no context is required. + */ + +METHODDEF(void) +process_data_simple_main (j_decompress_ptr cinfo, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail) +{ + my_main_ptr main = (my_main_ptr) cinfo->main; + JDIMENSION rowgroups_avail; + + /* Read input data if we haven't filled the main buffer yet */ + if (! main->buffer_full) { + if (! (*cinfo->coef->decompress_data) (cinfo, main->buffer)) + return; /* suspension forced, can do nothing more */ + main->buffer_full = TRUE; /* OK, we have an iMCU row to work with */ + } + + /* There are always min_DCT_scaled_size row groups in an iMCU row. */ + rowgroups_avail = (JDIMENSION) cinfo->min_DCT_scaled_size; + /* Note: at the bottom of the image, we may pass extra garbage row groups + * to the postprocessor. The postprocessor has to check for bottom + * of image anyway (at row resolution), so no point in us doing it too. + */ + + /* Feed the postprocessor */ + (*cinfo->post->post_process_data) (cinfo, main->buffer, + &main->rowgroup_ctr, rowgroups_avail, + output_buf, out_row_ctr, out_rows_avail); + + /* Has postprocessor consumed all the data yet? If so, mark buffer empty */ + if (main->rowgroup_ctr >= rowgroups_avail) { + main->buffer_full = FALSE; + main->rowgroup_ctr = 0; + } +} + + +/* + * Process some data. + * This handles the case where context rows must be provided. + */ + +METHODDEF(void) +process_data_context_main (j_decompress_ptr cinfo, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail) +{ + my_main_ptr main = (my_main_ptr) cinfo->main; + + /* Read input data if we haven't filled the main buffer yet */ + if (! main->buffer_full) { + if (! (*cinfo->coef->decompress_data) (cinfo, + main->xbuffer[main->whichptr])) + return; /* suspension forced, can do nothing more */ + main->buffer_full = TRUE; /* OK, we have an iMCU row to work with */ + main->iMCU_row_ctr++; /* count rows received */ + } + + /* Postprocessor typically will not swallow all the input data it is handed + * in one call (due to filling the output buffer first). Must be prepared + * to exit and restart. This switch lets us keep track of how far we got. + * Note that each case falls through to the next on successful completion. + */ + switch (main->context_state) { + case CTX_POSTPONED_ROW: + /* Call postprocessor using previously set pointers for postponed row */ + (*cinfo->post->post_process_data) (cinfo, main->xbuffer[main->whichptr], + &main->rowgroup_ctr, main->rowgroups_avail, + output_buf, out_row_ctr, out_rows_avail); + if (main->rowgroup_ctr < main->rowgroups_avail) + return; /* Need to suspend */ + main->context_state = CTX_PREPARE_FOR_IMCU; + if (*out_row_ctr >= out_rows_avail) + return; /* Postprocessor exactly filled output buf */ + /*FALLTHROUGH*/ + case CTX_PREPARE_FOR_IMCU: + /* Prepare to process first M-1 row groups of this iMCU row */ + main->rowgroup_ctr = 0; + main->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size - 1); + /* Check for bottom of image: if so, tweak pointers to "duplicate" + * the last sample row, and adjust rowgroups_avail to ignore padding rows. + */ + if (main->iMCU_row_ctr == cinfo->total_iMCU_rows) + set_bottom_pointers(cinfo); + main->context_state = CTX_PROCESS_IMCU; + /*FALLTHROUGH*/ + case CTX_PROCESS_IMCU: + /* Call postprocessor using previously set pointers */ + (*cinfo->post->post_process_data) (cinfo, main->xbuffer[main->whichptr], + &main->rowgroup_ctr, main->rowgroups_avail, + output_buf, out_row_ctr, out_rows_avail); + if (main->rowgroup_ctr < main->rowgroups_avail) + return; /* Need to suspend */ + /* After the first iMCU, change wraparound pointers to normal state */ + if (main->iMCU_row_ctr == 1) + set_wraparound_pointers(cinfo); + /* Prepare to load new iMCU row using other xbuffer list */ + main->whichptr ^= 1; /* 0=>1 or 1=>0 */ + main->buffer_full = FALSE; + /* Still need to process last row group of this iMCU row, */ + /* which is saved at index M+1 of the other xbuffer */ + main->rowgroup_ctr = (JDIMENSION) (cinfo->min_DCT_scaled_size + 1); + main->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size + 2); + main->context_state = CTX_POSTPONED_ROW; + } +} + + +/* + * Process some data. + * Final pass of two-pass quantization: just call the postprocessor. + * Source data will be the postprocessor controller's internal buffer. + */ + +#ifdef QUANT_2PASS_SUPPORTED + +METHODDEF(void) +process_data_crank_post (j_decompress_ptr cinfo, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail) +{ + (*cinfo->post->post_process_data) (cinfo, (JSAMPIMAGE) NULL, + (JDIMENSION *) NULL, (JDIMENSION) 0, + output_buf, out_row_ctr, out_rows_avail); +} + +#endif /* QUANT_2PASS_SUPPORTED */ + + +/* + * Initialize main buffer controller. + */ + +GLOBAL(void) +jinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer) +{ + my_main_ptr main; + int ci, rgroup, ngroups; + jpeg_component_info *compptr; + + main = (my_main_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_main_controller)); + cinfo->main = (struct jpeg_d_main_controller *) main; + main->pub.start_pass = start_pass_main; + + if (need_full_buffer) /* shouldn't happen */ + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + + /* Allocate the workspace. + * ngroups is the number of row groups we need. + */ + if (cinfo->upsample->need_context_rows) { + if (cinfo->min_DCT_scaled_size < 2) /* unsupported, see comments above */ + ERREXIT(cinfo, JERR_NOTIMPL); + alloc_funny_pointers(cinfo); /* Alloc space for xbuffer[] lists */ + ngroups = cinfo->min_DCT_scaled_size + 2; + } else { + ngroups = cinfo->min_DCT_scaled_size; + } + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / + cinfo->min_DCT_scaled_size; /* height of a row group of component */ + main->buffer[ci] = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + compptr->width_in_blocks * compptr->DCT_scaled_size, + (JDIMENSION) (rgroup * ngroups)); + } +} diff --git a/gs/jpeg/jdmarker.c b/gs/jpeg/jdmarker.c new file mode 100644 index 000000000..b79ec37fb --- /dev/null +++ b/gs/jpeg/jdmarker.c @@ -0,0 +1,1055 @@ +/* + * jdmarker.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to decode JPEG datastream markers. + * Most of the complexity arises from our desire to support input + * suspension: if not all of the data for a marker is available, + * we must exit back to the application. On resumption, we reprocess + * the marker. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +typedef enum { /* JPEG marker codes */ + M_SOF0 = 0xc0, + M_SOF1 = 0xc1, + M_SOF2 = 0xc2, + M_SOF3 = 0xc3, + + M_SOF5 = 0xc5, + M_SOF6 = 0xc6, + M_SOF7 = 0xc7, + + M_JPG = 0xc8, + M_SOF9 = 0xc9, + M_SOF10 = 0xca, + M_SOF11 = 0xcb, + + M_SOF13 = 0xcd, + M_SOF14 = 0xce, + M_SOF15 = 0xcf, + + M_DHT = 0xc4, + + M_DAC = 0xcc, + + M_RST0 = 0xd0, + M_RST1 = 0xd1, + M_RST2 = 0xd2, + M_RST3 = 0xd3, + M_RST4 = 0xd4, + M_RST5 = 0xd5, + M_RST6 = 0xd6, + M_RST7 = 0xd7, + + M_SOI = 0xd8, + M_EOI = 0xd9, + M_SOS = 0xda, + M_DQT = 0xdb, + M_DNL = 0xdc, + M_DRI = 0xdd, + M_DHP = 0xde, + M_EXP = 0xdf, + + M_APP0 = 0xe0, + M_APP1 = 0xe1, + M_APP2 = 0xe2, + M_APP3 = 0xe3, + M_APP4 = 0xe4, + M_APP5 = 0xe5, + M_APP6 = 0xe6, + M_APP7 = 0xe7, + M_APP8 = 0xe8, + M_APP9 = 0xe9, + M_APP10 = 0xea, + M_APP11 = 0xeb, + M_APP12 = 0xec, + M_APP13 = 0xed, + M_APP14 = 0xee, + M_APP15 = 0xef, + + M_JPG0 = 0xf0, + M_JPG13 = 0xfd, + M_COM = 0xfe, + + M_TEM = 0x01, + + M_ERROR = 0x100 +} JPEG_MARKER; + + +/* + * Macros for fetching data from the data source module. + * + * At all times, cinfo->src->next_input_byte and ->bytes_in_buffer reflect + * the current restart point; we update them only when we have reached a + * suitable place to restart if a suspension occurs. + */ + +/* Declare and initialize local copies of input pointer/count */ +#define INPUT_VARS(cinfo) \ + struct jpeg_source_mgr * datasrc = (cinfo)->src; \ + const JOCTET * next_input_byte = datasrc->next_input_byte; \ + size_t bytes_in_buffer = datasrc->bytes_in_buffer + +/* Unload the local copies --- do this only at a restart boundary */ +#define INPUT_SYNC(cinfo) \ + ( datasrc->next_input_byte = next_input_byte, \ + datasrc->bytes_in_buffer = bytes_in_buffer ) + +/* Reload the local copies --- seldom used except in MAKE_BYTE_AVAIL */ +#define INPUT_RELOAD(cinfo) \ + ( next_input_byte = datasrc->next_input_byte, \ + bytes_in_buffer = datasrc->bytes_in_buffer ) + +/* Internal macro for INPUT_BYTE and INPUT_2BYTES: make a byte available. + * Note we do *not* do INPUT_SYNC before calling fill_input_buffer, + * but we must reload the local copies after a successful fill. + */ +#define MAKE_BYTE_AVAIL(cinfo,action) \ + if (bytes_in_buffer == 0) { \ + if (! (*datasrc->fill_input_buffer) (cinfo)) \ + { action; } \ + INPUT_RELOAD(cinfo); \ + } \ + bytes_in_buffer-- + +/* Read a byte into variable V. + * If must suspend, take the specified action (typically "return FALSE"). + */ +#define INPUT_BYTE(cinfo,V,action) \ + MAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \ + V = GETJOCTET(*next_input_byte++); ) + +/* As above, but read two bytes interpreted as an unsigned 16-bit integer. + * V should be declared unsigned int or perhaps INT32. + */ +#define INPUT_2BYTES(cinfo,V,action) \ + MAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \ + V = ((unsigned int) GETJOCTET(*next_input_byte++)) << 8; \ + MAKE_BYTE_AVAIL(cinfo,action); \ + V += GETJOCTET(*next_input_byte++); ) + + +/* + * Routines to process JPEG markers. + * + * Entry condition: JPEG marker itself has been read and its code saved + * in cinfo->unread_marker; input restart point is just after the marker. + * + * Exit: if return TRUE, have read and processed any parameters, and have + * updated the restart point to point after the parameters. + * If return FALSE, was forced to suspend before reaching end of + * marker parameters; restart point has not been moved. Same routine + * will be called again after application supplies more input data. + * + * This approach to suspension assumes that all of a marker's parameters can + * fit into a single input bufferload. This should hold for "normal" + * markers. Some COM/APPn markers might have large parameter segments, + * but we use skip_input_data to get past those, and thereby put the problem + * on the source manager's shoulders. + * + * Note that we don't bother to avoid duplicate trace messages if a + * suspension occurs within marker parameters. Other side effects + * require more care. + */ + + +LOCAL(boolean) +get_soi (j_decompress_ptr cinfo) +/* Process an SOI marker */ +{ + int i; + + TRACEMS(cinfo, 1, JTRC_SOI); + + if (cinfo->marker->saw_SOI) + ERREXIT(cinfo, JERR_SOI_DUPLICATE); + + /* Reset all parameters that are defined to be reset by SOI */ + + for (i = 0; i < NUM_ARITH_TBLS; i++) { + cinfo->arith_dc_L[i] = 0; + cinfo->arith_dc_U[i] = 1; + cinfo->arith_ac_K[i] = 5; + } + cinfo->restart_interval = 0; + + /* Set initial assumptions for colorspace etc */ + + cinfo->jpeg_color_space = JCS_UNKNOWN; + cinfo->CCIR601_sampling = FALSE; /* Assume non-CCIR sampling??? */ + + cinfo->saw_JFIF_marker = FALSE; + cinfo->density_unit = 0; /* set default JFIF APP0 values */ + cinfo->X_density = 1; + cinfo->Y_density = 1; + cinfo->saw_Adobe_marker = FALSE; + cinfo->Adobe_transform = 0; + + cinfo->marker->saw_SOI = TRUE; + + return TRUE; +} + + +LOCAL(boolean) +get_sof (j_decompress_ptr cinfo, boolean is_prog, boolean is_arith) +/* Process a SOFn marker */ +{ + INT32 length; + int c, ci; + jpeg_component_info * compptr; + INPUT_VARS(cinfo); + + cinfo->progressive_mode = is_prog; + cinfo->arith_code = is_arith; + + INPUT_2BYTES(cinfo, length, return FALSE); + + INPUT_BYTE(cinfo, cinfo->data_precision, return FALSE); + INPUT_2BYTES(cinfo, cinfo->image_height, return FALSE); + INPUT_2BYTES(cinfo, cinfo->image_width, return FALSE); + INPUT_BYTE(cinfo, cinfo->num_components, return FALSE); + + length -= 8; + + TRACEMS4(cinfo, 1, JTRC_SOF, cinfo->unread_marker, + (int) cinfo->image_width, (int) cinfo->image_height, + cinfo->num_components); + + if (cinfo->marker->saw_SOF) + ERREXIT(cinfo, JERR_SOF_DUPLICATE); + + /* We don't support files in which the image height is initially specified */ + /* as 0 and is later redefined by DNL. As long as we have to check that, */ + /* might as well have a general sanity check. */ + if (cinfo->image_height <= 0 || cinfo->image_width <= 0 + || cinfo->num_components <= 0) + ERREXIT(cinfo, JERR_EMPTY_IMAGE); + + if (length != (cinfo->num_components * 3)) + ERREXIT(cinfo, JERR_BAD_LENGTH); + + if (cinfo->comp_info == NULL) /* do only once, even if suspend */ + cinfo->comp_info = (jpeg_component_info *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + cinfo->num_components * SIZEOF(jpeg_component_info)); + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + compptr->component_index = ci; + INPUT_BYTE(cinfo, compptr->component_id, return FALSE); + INPUT_BYTE(cinfo, c, return FALSE); + compptr->h_samp_factor = (c >> 4) & 15; + compptr->v_samp_factor = (c ) & 15; + INPUT_BYTE(cinfo, compptr->quant_tbl_no, return FALSE); + + TRACEMS4(cinfo, 1, JTRC_SOF_COMPONENT, + compptr->component_id, compptr->h_samp_factor, + compptr->v_samp_factor, compptr->quant_tbl_no); + } + + cinfo->marker->saw_SOF = TRUE; + + INPUT_SYNC(cinfo); + return TRUE; +} + + +LOCAL(boolean) +get_sos (j_decompress_ptr cinfo) +/* Process a SOS marker */ +{ + INT32 length; + int i, ci, n, c, cc; + jpeg_component_info * compptr; + INPUT_VARS(cinfo); + + if (! cinfo->marker->saw_SOF) + ERREXIT(cinfo, JERR_SOS_NO_SOF); + + INPUT_2BYTES(cinfo, length, return FALSE); + + INPUT_BYTE(cinfo, n, return FALSE); /* Number of components */ + + if (length != (n * 2 + 6) || n < 1 || n > MAX_COMPS_IN_SCAN) + ERREXIT(cinfo, JERR_BAD_LENGTH); + + TRACEMS1(cinfo, 1, JTRC_SOS, n); + + cinfo->comps_in_scan = n; + + /* Collect the component-spec parameters */ + + for (i = 0; i < n; i++) { + INPUT_BYTE(cinfo, cc, return FALSE); + INPUT_BYTE(cinfo, c, return FALSE); + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + if (cc == compptr->component_id) + goto id_found; + } + + ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc); + + id_found: + + cinfo->cur_comp_info[i] = compptr; + compptr->dc_tbl_no = (c >> 4) & 15; + compptr->ac_tbl_no = (c ) & 15; + + TRACEMS3(cinfo, 1, JTRC_SOS_COMPONENT, cc, + compptr->dc_tbl_no, compptr->ac_tbl_no); + } + + /* Collect the additional scan parameters Ss, Se, Ah/Al. */ + INPUT_BYTE(cinfo, c, return FALSE); + cinfo->Ss = c; + INPUT_BYTE(cinfo, c, return FALSE); + cinfo->Se = c; + INPUT_BYTE(cinfo, c, return FALSE); + cinfo->Ah = (c >> 4) & 15; + cinfo->Al = (c ) & 15; + + TRACEMS4(cinfo, 1, JTRC_SOS_PARAMS, cinfo->Ss, cinfo->Se, + cinfo->Ah, cinfo->Al); + + /* Prepare to scan data & restart markers */ + cinfo->marker->next_restart_num = 0; + + /* Count another SOS marker */ + cinfo->input_scan_number++; + + INPUT_SYNC(cinfo); + return TRUE; +} + + +METHODDEF(boolean) +get_app0 (j_decompress_ptr cinfo) +/* Process an APP0 marker */ +{ +#define JFIF_LEN 14 + INT32 length; + UINT8 b[JFIF_LEN]; + int buffp; + INPUT_VARS(cinfo); + + INPUT_2BYTES(cinfo, length, return FALSE); + length -= 2; + + /* See if a JFIF APP0 marker is present */ + + if (length >= JFIF_LEN) { + for (buffp = 0; buffp < JFIF_LEN; buffp++) + INPUT_BYTE(cinfo, b[buffp], return FALSE); + length -= JFIF_LEN; + + if (b[0]==0x4A && b[1]==0x46 && b[2]==0x49 && b[3]==0x46 && b[4]==0) { + /* Found JFIF APP0 marker: check version */ + /* Major version must be 1, anything else signals an incompatible change. + * We used to treat this as an error, but now it's a nonfatal warning, + * because some bozo at Hijaak couldn't read the spec. + * Minor version should be 0..2, but process anyway if newer. + */ + if (b[5] != 1) + WARNMS2(cinfo, JWRN_JFIF_MAJOR, b[5], b[6]); + else if (b[6] > 2) + TRACEMS2(cinfo, 1, JTRC_JFIF_MINOR, b[5], b[6]); + /* Save info */ + cinfo->saw_JFIF_marker = TRUE; + cinfo->density_unit = b[7]; + cinfo->X_density = (b[8] << 8) + b[9]; + cinfo->Y_density = (b[10] << 8) + b[11]; + TRACEMS3(cinfo, 1, JTRC_JFIF, + cinfo->X_density, cinfo->Y_density, cinfo->density_unit); + if (b[12] | b[13]) + TRACEMS2(cinfo, 1, JTRC_JFIF_THUMBNAIL, b[12], b[13]); + if (length != ((INT32) b[12] * (INT32) b[13] * (INT32) 3)) + TRACEMS1(cinfo, 1, JTRC_JFIF_BADTHUMBNAILSIZE, (int) length); + } else { + /* Start of APP0 does not match "JFIF" */ + TRACEMS1(cinfo, 1, JTRC_APP0, (int) length + JFIF_LEN); + } + } else { + /* Too short to be JFIF marker */ + TRACEMS1(cinfo, 1, JTRC_APP0, (int) length); + } + + INPUT_SYNC(cinfo); + if (length > 0) /* skip any remaining data -- could be lots */ + (*cinfo->src->skip_input_data) (cinfo, (long) length); + + return TRUE; +} + + +METHODDEF(boolean) +get_app14 (j_decompress_ptr cinfo) +/* Process an APP14 marker */ +{ +#define ADOBE_LEN 12 + INT32 length; + UINT8 b[ADOBE_LEN]; + int buffp; + unsigned int version, flags0, flags1, transform; + INPUT_VARS(cinfo); + + INPUT_2BYTES(cinfo, length, return FALSE); + length -= 2; + + /* See if an Adobe APP14 marker is present */ + + if (length >= ADOBE_LEN) { + for (buffp = 0; buffp < ADOBE_LEN; buffp++) + INPUT_BYTE(cinfo, b[buffp], return FALSE); + length -= ADOBE_LEN; + + if (b[0]==0x41 && b[1]==0x64 && b[2]==0x6F && b[3]==0x62 && b[4]==0x65) { + /* Found Adobe APP14 marker */ + version = (b[5] << 8) + b[6]; + flags0 = (b[7] << 8) + b[8]; + flags1 = (b[9] << 8) + b[10]; + transform = b[11]; + TRACEMS4(cinfo, 1, JTRC_ADOBE, version, flags0, flags1, transform); + cinfo->saw_Adobe_marker = TRUE; + cinfo->Adobe_transform = (UINT8) transform; + } else { + /* Start of APP14 does not match "Adobe" */ + TRACEMS1(cinfo, 1, JTRC_APP14, (int) length + ADOBE_LEN); + } + } else { + /* Too short to be Adobe marker */ + TRACEMS1(cinfo, 1, JTRC_APP14, (int) length); + } + + INPUT_SYNC(cinfo); + if (length > 0) /* skip any remaining data -- could be lots */ + (*cinfo->src->skip_input_data) (cinfo, (long) length); + + return TRUE; +} + + +LOCAL(boolean) +get_dac (j_decompress_ptr cinfo) +/* Process a DAC marker */ +{ + INT32 length; + int index, val; + INPUT_VARS(cinfo); + + INPUT_2BYTES(cinfo, length, return FALSE); + length -= 2; + + while (length > 0) { + INPUT_BYTE(cinfo, index, return FALSE); + INPUT_BYTE(cinfo, val, return FALSE); + + length -= 2; + + TRACEMS2(cinfo, 1, JTRC_DAC, index, val); + + if (index < 0 || index >= (2*NUM_ARITH_TBLS)) + ERREXIT1(cinfo, JERR_DAC_INDEX, index); + + if (index >= NUM_ARITH_TBLS) { /* define AC table */ + cinfo->arith_ac_K[index-NUM_ARITH_TBLS] = (UINT8) val; + } else { /* define DC table */ + cinfo->arith_dc_L[index] = (UINT8) (val & 0x0F); + cinfo->arith_dc_U[index] = (UINT8) (val >> 4); + if (cinfo->arith_dc_L[index] > cinfo->arith_dc_U[index]) + ERREXIT1(cinfo, JERR_DAC_VALUE, val); + } + } + + INPUT_SYNC(cinfo); + return TRUE; +} + + +LOCAL(boolean) +get_dht (j_decompress_ptr cinfo) +/* Process a DHT marker */ +{ + INT32 length; + UINT8 bits[17]; + UINT8 huffval[256]; + int i, index, count; + JHUFF_TBL **htblptr; + INPUT_VARS(cinfo); + + INPUT_2BYTES(cinfo, length, return FALSE); + length -= 2; + + while (length > 0) { + INPUT_BYTE(cinfo, index, return FALSE); + + TRACEMS1(cinfo, 1, JTRC_DHT, index); + + bits[0] = 0; + count = 0; + for (i = 1; i <= 16; i++) { + INPUT_BYTE(cinfo, bits[i], return FALSE); + count += bits[i]; + } + + length -= 1 + 16; + + TRACEMS8(cinfo, 2, JTRC_HUFFBITS, + bits[1], bits[2], bits[3], bits[4], + bits[5], bits[6], bits[7], bits[8]); + TRACEMS8(cinfo, 2, JTRC_HUFFBITS, + bits[9], bits[10], bits[11], bits[12], + bits[13], bits[14], bits[15], bits[16]); + + if (count > 256 || ((INT32) count) > length) + ERREXIT(cinfo, JERR_DHT_COUNTS); + + for (i = 0; i < count; i++) + INPUT_BYTE(cinfo, huffval[i], return FALSE); + + length -= count; + + if (index & 0x10) { /* AC table definition */ + index -= 0x10; + htblptr = &cinfo->ac_huff_tbl_ptrs[index]; + } else { /* DC table definition */ + htblptr = &cinfo->dc_huff_tbl_ptrs[index]; + } + + if (index < 0 || index >= NUM_HUFF_TBLS) + ERREXIT1(cinfo, JERR_DHT_INDEX, index); + + if (*htblptr == NULL) + *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); + + MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits)); + MEMCOPY((*htblptr)->huffval, huffval, SIZEOF((*htblptr)->huffval)); + } + + INPUT_SYNC(cinfo); + return TRUE; +} + + +LOCAL(boolean) +get_dqt (j_decompress_ptr cinfo) +/* Process a DQT marker */ +{ + INT32 length; + int n, i, prec; + unsigned int tmp; + JQUANT_TBL *quant_ptr; + INPUT_VARS(cinfo); + + INPUT_2BYTES(cinfo, length, return FALSE); + length -= 2; + + while (length > 0) { + INPUT_BYTE(cinfo, n, return FALSE); + prec = n >> 4; + n &= 0x0F; + + TRACEMS2(cinfo, 1, JTRC_DQT, n, prec); + + if (n >= NUM_QUANT_TBLS) + ERREXIT1(cinfo, JERR_DQT_INDEX, n); + + if (cinfo->quant_tbl_ptrs[n] == NULL) + cinfo->quant_tbl_ptrs[n] = jpeg_alloc_quant_table((j_common_ptr) cinfo); + quant_ptr = cinfo->quant_tbl_ptrs[n]; + + for (i = 0; i < DCTSIZE2; i++) { + if (prec) + INPUT_2BYTES(cinfo, tmp, return FALSE); + else + INPUT_BYTE(cinfo, tmp, return FALSE); + /* We convert the zigzag-order table to natural array order. */ + quant_ptr->quantval[jpeg_natural_order[i]] = (UINT16) tmp; + } + + if (cinfo->err->trace_level >= 2) { + for (i = 0; i < DCTSIZE2; i += 8) { + TRACEMS8(cinfo, 2, JTRC_QUANTVALS, + quant_ptr->quantval[i], quant_ptr->quantval[i+1], + quant_ptr->quantval[i+2], quant_ptr->quantval[i+3], + quant_ptr->quantval[i+4], quant_ptr->quantval[i+5], + quant_ptr->quantval[i+6], quant_ptr->quantval[i+7]); + } + } + + length -= DCTSIZE2+1; + if (prec) length -= DCTSIZE2; + } + + INPUT_SYNC(cinfo); + return TRUE; +} + + +LOCAL(boolean) +get_dri (j_decompress_ptr cinfo) +/* Process a DRI marker */ +{ + INT32 length; + unsigned int tmp; + INPUT_VARS(cinfo); + + INPUT_2BYTES(cinfo, length, return FALSE); + + if (length != 4) + ERREXIT(cinfo, JERR_BAD_LENGTH); + + INPUT_2BYTES(cinfo, tmp, return FALSE); + + TRACEMS1(cinfo, 1, JTRC_DRI, tmp); + + cinfo->restart_interval = tmp; + + INPUT_SYNC(cinfo); + return TRUE; +} + + +METHODDEF(boolean) +skip_variable (j_decompress_ptr cinfo) +/* Skip over an unknown or uninteresting variable-length marker */ +{ + INT32 length; + INPUT_VARS(cinfo); + + INPUT_2BYTES(cinfo, length, return FALSE); + + TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, (int) length); + + INPUT_SYNC(cinfo); /* do before skip_input_data */ + (*cinfo->src->skip_input_data) (cinfo, (long) length - 2L); + + return TRUE; +} + + +/* + * Find the next JPEG marker, save it in cinfo->unread_marker. + * Returns FALSE if had to suspend before reaching a marker; + * in that case cinfo->unread_marker is unchanged. + * + * Note that the result might not be a valid marker code, + * but it will never be 0 or FF. + */ + +LOCAL(boolean) +next_marker (j_decompress_ptr cinfo) +{ + int c; + INPUT_VARS(cinfo); + + for (;;) { + INPUT_BYTE(cinfo, c, return FALSE); + /* Skip any non-FF bytes. + * This may look a bit inefficient, but it will not occur in a valid file. + * We sync after each discarded byte so that a suspending data source + * can discard the byte from its buffer. + */ + while (c != 0xFF) { + cinfo->marker->discarded_bytes++; + INPUT_SYNC(cinfo); + INPUT_BYTE(cinfo, c, return FALSE); + } + /* This loop swallows any duplicate FF bytes. Extra FFs are legal as + * pad bytes, so don't count them in discarded_bytes. We assume there + * will not be so many consecutive FF bytes as to overflow a suspending + * data source's input buffer. + */ + do { + INPUT_BYTE(cinfo, c, return FALSE); + } while (c == 0xFF); + if (c != 0) + break; /* found a valid marker, exit loop */ + /* Reach here if we found a stuffed-zero data sequence (FF/00). + * Discard it and loop back to try again. + */ + cinfo->marker->discarded_bytes += 2; + INPUT_SYNC(cinfo); + } + + if (cinfo->marker->discarded_bytes != 0) { + WARNMS2(cinfo, JWRN_EXTRANEOUS_DATA, cinfo->marker->discarded_bytes, c); + cinfo->marker->discarded_bytes = 0; + } + + cinfo->unread_marker = c; + + INPUT_SYNC(cinfo); + return TRUE; +} + + +LOCAL(boolean) +first_marker (j_decompress_ptr cinfo) +/* Like next_marker, but used to obtain the initial SOI marker. */ +/* For this marker, we do not allow preceding garbage or fill; otherwise, + * we might well scan an entire input file before realizing it ain't JPEG. + * If an application wants to process non-JFIF files, it must seek to the + * SOI before calling the JPEG library. + */ +{ + int c, c2; + INPUT_VARS(cinfo); + + INPUT_BYTE(cinfo, c, return FALSE); + INPUT_BYTE(cinfo, c2, return FALSE); + if (c != 0xFF || c2 != (int) M_SOI) + ERREXIT2(cinfo, JERR_NO_SOI, c, c2); + + cinfo->unread_marker = c2; + + INPUT_SYNC(cinfo); + return TRUE; +} + + +/* + * Read markers until SOS or EOI. + * + * Returns same codes as are defined for jpeg_consume_input: + * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI. + */ + +METHODDEF(int) +read_markers (j_decompress_ptr cinfo) +{ + /* Outer loop repeats once for each marker. */ + for (;;) { + /* Collect the marker proper, unless we already did. */ + /* NB: first_marker() enforces the requirement that SOI appear first. */ + if (cinfo->unread_marker == 0) { + if (! cinfo->marker->saw_SOI) { + if (! first_marker(cinfo)) + return JPEG_SUSPENDED; + } else { + if (! next_marker(cinfo)) + return JPEG_SUSPENDED; + } + } + /* At this point cinfo->unread_marker contains the marker code and the + * input point is just past the marker proper, but before any parameters. + * A suspension will cause us to return with this state still true. + */ + switch (cinfo->unread_marker) { + case M_SOI: + if (! get_soi(cinfo)) + return JPEG_SUSPENDED; + break; + + case M_SOF0: /* Baseline */ + case M_SOF1: /* Extended sequential, Huffman */ + if (! get_sof(cinfo, FALSE, FALSE)) + return JPEG_SUSPENDED; + break; + + case M_SOF2: /* Progressive, Huffman */ + if (! get_sof(cinfo, TRUE, FALSE)) + return JPEG_SUSPENDED; + break; + + case M_SOF9: /* Extended sequential, arithmetic */ + if (! get_sof(cinfo, FALSE, TRUE)) + return JPEG_SUSPENDED; + break; + + case M_SOF10: /* Progressive, arithmetic */ + if (! get_sof(cinfo, TRUE, TRUE)) + return JPEG_SUSPENDED; + break; + + /* Currently unsupported SOFn types */ + case M_SOF3: /* Lossless, Huffman */ + case M_SOF5: /* Differential sequential, Huffman */ + case M_SOF6: /* Differential progressive, Huffman */ + case M_SOF7: /* Differential lossless, Huffman */ + case M_JPG: /* Reserved for JPEG extensions */ + case M_SOF11: /* Lossless, arithmetic */ + case M_SOF13: /* Differential sequential, arithmetic */ + case M_SOF14: /* Differential progressive, arithmetic */ + case M_SOF15: /* Differential lossless, arithmetic */ + ERREXIT1(cinfo, JERR_SOF_UNSUPPORTED, cinfo->unread_marker); + break; + + case M_SOS: + if (! get_sos(cinfo)) + return JPEG_SUSPENDED; + cinfo->unread_marker = 0; /* processed the marker */ + return JPEG_REACHED_SOS; + + case M_EOI: + TRACEMS(cinfo, 1, JTRC_EOI); + cinfo->unread_marker = 0; /* processed the marker */ + return JPEG_REACHED_EOI; + + case M_DAC: + if (! get_dac(cinfo)) + return JPEG_SUSPENDED; + break; + + case M_DHT: + if (! get_dht(cinfo)) + return JPEG_SUSPENDED; + break; + + case M_DQT: + if (! get_dqt(cinfo)) + return JPEG_SUSPENDED; + break; + + case M_DRI: + if (! get_dri(cinfo)) + return JPEG_SUSPENDED; + break; + + case M_APP0: + case M_APP1: + case M_APP2: + case M_APP3: + case M_APP4: + case M_APP5: + case M_APP6: + case M_APP7: + case M_APP8: + case M_APP9: + case M_APP10: + case M_APP11: + case M_APP12: + case M_APP13: + case M_APP14: + case M_APP15: + if (! (*cinfo->marker->process_APPn[cinfo->unread_marker - (int) M_APP0]) (cinfo)) + return JPEG_SUSPENDED; + break; + + case M_COM: + if (! (*cinfo->marker->process_COM) (cinfo)) + return JPEG_SUSPENDED; + break; + + case M_RST0: /* these are all parameterless */ + case M_RST1: + case M_RST2: + case M_RST3: + case M_RST4: + case M_RST5: + case M_RST6: + case M_RST7: + case M_TEM: + TRACEMS1(cinfo, 1, JTRC_PARMLESS_MARKER, cinfo->unread_marker); + break; + + case M_DNL: /* Ignore DNL ... perhaps the wrong thing */ + if (! skip_variable(cinfo)) + return JPEG_SUSPENDED; + break; + + default: /* must be DHP, EXP, JPGn, or RESn */ + /* For now, we treat the reserved markers as fatal errors since they are + * likely to be used to signal incompatible JPEG Part 3 extensions. + * Once the JPEG 3 version-number marker is well defined, this code + * ought to change! + */ + ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker); + break; + } + /* Successfully processed marker, so reset state variable */ + cinfo->unread_marker = 0; + } /* end loop */ +} + + +/* + * Read a restart marker, which is expected to appear next in the datastream; + * if the marker is not there, take appropriate recovery action. + * Returns FALSE if suspension is required. + * + * This is called by the entropy decoder after it has read an appropriate + * number of MCUs. cinfo->unread_marker may be nonzero if the entropy decoder + * has already read a marker from the data source. Under normal conditions + * cinfo->unread_marker will be reset to 0 before returning; if not reset, + * it holds a marker which the decoder will be unable to read past. + */ + +METHODDEF(boolean) +read_restart_marker (j_decompress_ptr cinfo) +{ + /* Obtain a marker unless we already did. */ + /* Note that next_marker will complain if it skips any data. */ + if (cinfo->unread_marker == 0) { + if (! next_marker(cinfo)) + return FALSE; + } + + if (cinfo->unread_marker == + ((int) M_RST0 + cinfo->marker->next_restart_num)) { + /* Normal case --- swallow the marker and let entropy decoder continue */ + TRACEMS1(cinfo, 3, JTRC_RST, cinfo->marker->next_restart_num); + cinfo->unread_marker = 0; + } else { + /* Uh-oh, the restart markers have been messed up. */ + /* Let the data source manager determine how to resync. */ + if (! (*cinfo->src->resync_to_restart) (cinfo, + cinfo->marker->next_restart_num)) + return FALSE; + } + + /* Update next-restart state */ + cinfo->marker->next_restart_num = (cinfo->marker->next_restart_num + 1) & 7; + + return TRUE; +} + + +/* + * This is the default resync_to_restart method for data source managers + * to use if they don't have any better approach. Some data source managers + * may be able to back up, or may have additional knowledge about the data + * which permits a more intelligent recovery strategy; such managers would + * presumably supply their own resync method. + * + * read_restart_marker calls resync_to_restart if it finds a marker other than + * the restart marker it was expecting. (This code is *not* used unless + * a nonzero restart interval has been declared.) cinfo->unread_marker is + * the marker code actually found (might be anything, except 0 or FF). + * The desired restart marker number (0..7) is passed as a parameter. + * This routine is supposed to apply whatever error recovery strategy seems + * appropriate in order to position the input stream to the next data segment. + * Note that cinfo->unread_marker is treated as a marker appearing before + * the current data-source input point; usually it should be reset to zero + * before returning. + * Returns FALSE if suspension is required. + * + * This implementation is substantially constrained by wanting to treat the + * input as a data stream; this means we can't back up. Therefore, we have + * only the following actions to work with: + * 1. Simply discard the marker and let the entropy decoder resume at next + * byte of file. + * 2. Read forward until we find another marker, discarding intervening + * data. (In theory we could look ahead within the current bufferload, + * without having to discard data if we don't find the desired marker. + * This idea is not implemented here, in part because it makes behavior + * dependent on buffer size and chance buffer-boundary positions.) + * 3. Leave the marker unread (by failing to zero cinfo->unread_marker). + * This will cause the entropy decoder to process an empty data segment, + * inserting dummy zeroes, and then we will reprocess the marker. + * + * #2 is appropriate if we think the desired marker lies ahead, while #3 is + * appropriate if the found marker is a future restart marker (indicating + * that we have missed the desired restart marker, probably because it got + * corrupted). + * We apply #2 or #3 if the found marker is a restart marker no more than + * two counts behind or ahead of the expected one. We also apply #2 if the + * found marker is not a legal JPEG marker code (it's certainly bogus data). + * If the found marker is a restart marker more than 2 counts away, we do #1 + * (too much risk that the marker is erroneous; with luck we will be able to + * resync at some future point). + * For any valid non-restart JPEG marker, we apply #3. This keeps us from + * overrunning the end of a scan. An implementation limited to single-scan + * files might find it better to apply #2 for markers other than EOI, since + * any other marker would have to be bogus data in that case. + */ + +GLOBAL(boolean) +jpeg_resync_to_restart (j_decompress_ptr cinfo, int desired) +{ + int marker = cinfo->unread_marker; + int action = 1; + + /* Always put up a warning. */ + WARNMS2(cinfo, JWRN_MUST_RESYNC, marker, desired); + + /* Outer loop handles repeated decision after scanning forward. */ + for (;;) { + if (marker < (int) M_SOF0) + action = 2; /* invalid marker */ + else if (marker < (int) M_RST0 || marker > (int) M_RST7) + action = 3; /* valid non-restart marker */ + else { + if (marker == ((int) M_RST0 + ((desired+1) & 7)) || + marker == ((int) M_RST0 + ((desired+2) & 7))) + action = 3; /* one of the next two expected restarts */ + else if (marker == ((int) M_RST0 + ((desired-1) & 7)) || + marker == ((int) M_RST0 + ((desired-2) & 7))) + action = 2; /* a prior restart, so advance */ + else + action = 1; /* desired restart or too far away */ + } + TRACEMS2(cinfo, 4, JTRC_RECOVERY_ACTION, marker, action); + switch (action) { + case 1: + /* Discard marker and let entropy decoder resume processing. */ + cinfo->unread_marker = 0; + return TRUE; + case 2: + /* Scan to the next marker, and repeat the decision loop. */ + if (! next_marker(cinfo)) + return FALSE; + marker = cinfo->unread_marker; + break; + case 3: + /* Return without advancing past this marker. */ + /* Entropy decoder will be forced to process an empty segment. */ + return TRUE; + } + } /* end loop */ +} + + +/* + * Reset marker processing state to begin a fresh datastream. + */ + +METHODDEF(void) +reset_marker_reader (j_decompress_ptr cinfo) +{ + cinfo->comp_info = NULL; /* until allocated by get_sof */ + cinfo->input_scan_number = 0; /* no SOS seen yet */ + cinfo->unread_marker = 0; /* no pending marker */ + cinfo->marker->saw_SOI = FALSE; /* set internal state too */ + cinfo->marker->saw_SOF = FALSE; + cinfo->marker->discarded_bytes = 0; +} + + +/* + * Initialize the marker reader module. + * This is called only once, when the decompression object is created. + */ + +GLOBAL(void) +jinit_marker_reader (j_decompress_ptr cinfo) +{ + int i; + + /* Create subobject in permanent pool */ + cinfo->marker = (struct jpeg_marker_reader *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, + SIZEOF(struct jpeg_marker_reader)); + /* Initialize method pointers */ + cinfo->marker->reset_marker_reader = reset_marker_reader; + cinfo->marker->read_markers = read_markers; + cinfo->marker->read_restart_marker = read_restart_marker; + cinfo->marker->process_COM = skip_variable; + for (i = 0; i < 16; i++) + cinfo->marker->process_APPn[i] = skip_variable; + cinfo->marker->process_APPn[0] = get_app0; + cinfo->marker->process_APPn[14] = get_app14; + /* Reset marker processing state */ + reset_marker_reader(cinfo); +} diff --git a/gs/jpeg/jdmaster.c b/gs/jpeg/jdmaster.c new file mode 100644 index 000000000..6f3351e61 --- /dev/null +++ b/gs/jpeg/jdmaster.c @@ -0,0 +1,555 @@ +/* + * jdmaster.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains master control logic for the JPEG decompressor. + * These routines are concerned with selecting the modules to be executed + * and with determining the number of passes and the work to be done in each + * pass. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Private state */ + +typedef struct { + struct jpeg_decomp_master pub; /* public fields */ + + int pass_number; /* # of passes completed */ + + boolean using_merged_upsample; /* TRUE if using merged upsample/cconvert */ + + /* Saved references to initialized quantizer modules, + * in case we need to switch modes. + */ + struct jpeg_color_quantizer * quantizer_1pass; + struct jpeg_color_quantizer * quantizer_2pass; +} my_decomp_master; + +typedef my_decomp_master * my_master_ptr; + + +/* + * Determine whether merged upsample/color conversion should be used. + * CRUCIAL: this must match the actual capabilities of jdmerge.c! + */ + +LOCAL(boolean) +use_merged_upsample (j_decompress_ptr cinfo) +{ +#ifdef UPSAMPLE_MERGING_SUPPORTED + /* Merging is the equivalent of plain box-filter upsampling */ + if (cinfo->do_fancy_upsampling || cinfo->CCIR601_sampling) + return FALSE; + /* jdmerge.c only supports YCC=>RGB color conversion */ + if (cinfo->jpeg_color_space != JCS_YCbCr || cinfo->num_components != 3 || + cinfo->out_color_space != JCS_RGB || + cinfo->out_color_components != RGB_PIXELSIZE) + return FALSE; + /* and it only handles 2h1v or 2h2v sampling ratios */ + if (cinfo->comp_info[0].h_samp_factor != 2 || + cinfo->comp_info[1].h_samp_factor != 1 || + cinfo->comp_info[2].h_samp_factor != 1 || + cinfo->comp_info[0].v_samp_factor > 2 || + cinfo->comp_info[1].v_samp_factor != 1 || + cinfo->comp_info[2].v_samp_factor != 1) + return FALSE; + /* furthermore, it doesn't work if we've scaled the IDCTs differently */ + if (cinfo->comp_info[0].DCT_scaled_size != cinfo->min_DCT_scaled_size || + cinfo->comp_info[1].DCT_scaled_size != cinfo->min_DCT_scaled_size || + cinfo->comp_info[2].DCT_scaled_size != cinfo->min_DCT_scaled_size) + return FALSE; + /* ??? also need to test for upsample-time rescaling, when & if supported */ + return TRUE; /* by golly, it'll work... */ +#else + return FALSE; +#endif +} + + +/* + * Compute output image dimensions and related values. + * NOTE: this is exported for possible use by application. + * Hence it mustn't do anything that can't be done twice. + * Also note that it may be called before the master module is initialized! + */ + +GLOBAL(void) +jpeg_calc_output_dimensions (j_decompress_ptr cinfo) +/* Do computations that are needed before master selection phase */ +{ + int ci; + jpeg_component_info *compptr; + + /* Prevent application from calling me at wrong times */ + if (cinfo->global_state != DSTATE_READY) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + +#ifdef IDCT_SCALING_SUPPORTED + + /* Compute actual output image dimensions and DCT scaling choices. */ + if (cinfo->scale_num * 8 <= cinfo->scale_denom) { + /* Provide 1/8 scaling */ + cinfo->output_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width, 8L); + cinfo->output_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height, 8L); + cinfo->min_DCT_scaled_size = 1; + } else if (cinfo->scale_num * 4 <= cinfo->scale_denom) { + /* Provide 1/4 scaling */ + cinfo->output_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width, 4L); + cinfo->output_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height, 4L); + cinfo->min_DCT_scaled_size = 2; + } else if (cinfo->scale_num * 2 <= cinfo->scale_denom) { + /* Provide 1/2 scaling */ + cinfo->output_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width, 2L); + cinfo->output_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height, 2L); + cinfo->min_DCT_scaled_size = 4; + } else { + /* Provide 1/1 scaling */ + cinfo->output_width = cinfo->image_width; + cinfo->output_height = cinfo->image_height; + cinfo->min_DCT_scaled_size = DCTSIZE; + } + /* In selecting the actual DCT scaling for each component, we try to + * scale up the chroma components via IDCT scaling rather than upsampling. + * This saves time if the upsampler gets to use 1:1 scaling. + * Note this code assumes that the supported DCT scalings are powers of 2. + */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + int ssize = cinfo->min_DCT_scaled_size; + while (ssize < DCTSIZE && + (compptr->h_samp_factor * ssize * 2 <= + cinfo->max_h_samp_factor * cinfo->min_DCT_scaled_size) && + (compptr->v_samp_factor * ssize * 2 <= + cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size)) { + ssize = ssize * 2; + } + compptr->DCT_scaled_size = ssize; + } + + /* Recompute downsampled dimensions of components; + * application needs to know these if using raw downsampled data. + */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Size in samples, after IDCT scaling */ + compptr->downsampled_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * + (long) (compptr->h_samp_factor * compptr->DCT_scaled_size), + (long) (cinfo->max_h_samp_factor * DCTSIZE)); + compptr->downsampled_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * + (long) (compptr->v_samp_factor * compptr->DCT_scaled_size), + (long) (cinfo->max_v_samp_factor * DCTSIZE)); + } + +#else /* !IDCT_SCALING_SUPPORTED */ + + /* Hardwire it to "no scaling" */ + cinfo->output_width = cinfo->image_width; + cinfo->output_height = cinfo->image_height; + /* jdinput.c has already initialized DCT_scaled_size to DCTSIZE, + * and has computed unscaled downsampled_width and downsampled_height. + */ + +#endif /* IDCT_SCALING_SUPPORTED */ + + /* Report number of components in selected colorspace. */ + /* Probably this should be in the color conversion module... */ + switch (cinfo->out_color_space) { + case JCS_GRAYSCALE: + cinfo->out_color_components = 1; + break; + case JCS_RGB: +#if RGB_PIXELSIZE != 3 + cinfo->out_color_components = RGB_PIXELSIZE; + break; +#endif /* else share code with YCbCr */ + case JCS_YCbCr: + cinfo->out_color_components = 3; + break; + case JCS_CMYK: + case JCS_YCCK: + cinfo->out_color_components = 4; + break; + default: /* else must be same colorspace as in file */ + cinfo->out_color_components = cinfo->num_components; + break; + } + cinfo->output_components = (cinfo->quantize_colors ? 1 : + cinfo->out_color_components); + + /* See if upsampler will want to emit more than one row at a time */ + if (use_merged_upsample(cinfo)) + cinfo->rec_outbuf_height = cinfo->max_v_samp_factor; + else + cinfo->rec_outbuf_height = 1; +} + + +/* + * Several decompression processes need to range-limit values to the range + * 0..MAXJSAMPLE; the input value may fall somewhat outside this range + * due to noise introduced by quantization, roundoff error, etc. These + * processes are inner loops and need to be as fast as possible. On most + * machines, particularly CPUs with pipelines or instruction prefetch, + * a (subscript-check-less) C table lookup + * x = sample_range_limit[x]; + * is faster than explicit tests + * if (x < 0) x = 0; + * else if (x > MAXJSAMPLE) x = MAXJSAMPLE; + * These processes all use a common table prepared by the routine below. + * + * For most steps we can mathematically guarantee that the initial value + * of x is within MAXJSAMPLE+1 of the legal range, so a table running from + * -(MAXJSAMPLE+1) to 2*MAXJSAMPLE+1 is sufficient. But for the initial + * limiting step (just after the IDCT), a wildly out-of-range value is + * possible if the input data is corrupt. To avoid any chance of indexing + * off the end of memory and getting a bad-pointer trap, we perform the + * post-IDCT limiting thus: + * x = range_limit[x & MASK]; + * where MASK is 2 bits wider than legal sample data, ie 10 bits for 8-bit + * samples. Under normal circumstances this is more than enough range and + * a correct output will be generated; with bogus input data the mask will + * cause wraparound, and we will safely generate a bogus-but-in-range output. + * For the post-IDCT step, we want to convert the data from signed to unsigned + * representation by adding CENTERJSAMPLE at the same time that we limit it. + * So the post-IDCT limiting table ends up looking like this: + * CENTERJSAMPLE,CENTERJSAMPLE+1,...,MAXJSAMPLE, + * MAXJSAMPLE (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times), + * 0 (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times), + * 0,1,...,CENTERJSAMPLE-1 + * Negative inputs select values from the upper half of the table after + * masking. + * + * We can save some space by overlapping the start of the post-IDCT table + * with the simpler range limiting table. The post-IDCT table begins at + * sample_range_limit + CENTERJSAMPLE. + * + * Note that the table is allocated in near data space on PCs; it's small + * enough and used often enough to justify this. + */ + +LOCAL(void) +prepare_range_limit_table (j_decompress_ptr cinfo) +/* Allocate and fill in the sample_range_limit table */ +{ + JSAMPLE * table; + int i; + + table = (JSAMPLE *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (5 * (MAXJSAMPLE+1) + CENTERJSAMPLE) * SIZEOF(JSAMPLE)); + table += (MAXJSAMPLE+1); /* allow negative subscripts of simple table */ + cinfo->sample_range_limit = table; + /* First segment of "simple" table: limit[x] = 0 for x < 0 */ + MEMZERO(table - (MAXJSAMPLE+1), (MAXJSAMPLE+1) * SIZEOF(JSAMPLE)); + /* Main part of "simple" table: limit[x] = x */ + for (i = 0; i <= MAXJSAMPLE; i++) + table[i] = (JSAMPLE) i; + table += CENTERJSAMPLE; /* Point to where post-IDCT table starts */ + /* End of simple table, rest of first half of post-IDCT table */ + for (i = CENTERJSAMPLE; i < 2*(MAXJSAMPLE+1); i++) + table[i] = MAXJSAMPLE; + /* Second half of post-IDCT table */ + MEMZERO(table + (2 * (MAXJSAMPLE+1)), + (2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * SIZEOF(JSAMPLE)); + MEMCOPY(table + (4 * (MAXJSAMPLE+1) - CENTERJSAMPLE), + cinfo->sample_range_limit, CENTERJSAMPLE * SIZEOF(JSAMPLE)); +} + + +/* + * Master selection of decompression modules. + * This is done once at jpeg_start_decompress time. We determine + * which modules will be used and give them appropriate initialization calls. + * We also initialize the decompressor input side to begin consuming data. + * + * Since jpeg_read_header has finished, we know what is in the SOF + * and (first) SOS markers. We also have all the application parameter + * settings. + */ + +LOCAL(void) +master_selection (j_decompress_ptr cinfo) +{ + my_master_ptr master = (my_master_ptr) cinfo->master; + boolean use_c_buffer; + long samplesperrow; + JDIMENSION jd_samplesperrow; + + /* Initialize dimensions and other stuff */ + jpeg_calc_output_dimensions(cinfo); + prepare_range_limit_table(cinfo); + + /* Width of an output scanline must be representable as JDIMENSION. */ + samplesperrow = (long) cinfo->output_width * (long) cinfo->out_color_components; + jd_samplesperrow = (JDIMENSION) samplesperrow; + if ((long) jd_samplesperrow != samplesperrow) + ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); + + /* Initialize my private state */ + master->pass_number = 0; + master->using_merged_upsample = use_merged_upsample(cinfo); + + /* Color quantizer selection */ + master->quantizer_1pass = NULL; + master->quantizer_2pass = NULL; + /* No mode changes if not using buffered-image mode. */ + if (! cinfo->quantize_colors || ! cinfo->buffered_image) { + cinfo->enable_1pass_quant = FALSE; + cinfo->enable_external_quant = FALSE; + cinfo->enable_2pass_quant = FALSE; + } + if (cinfo->quantize_colors) { + if (cinfo->raw_data_out) + ERREXIT(cinfo, JERR_NOTIMPL); + /* 2-pass quantizer only works in 3-component color space. */ + if (cinfo->out_color_components != 3) { + cinfo->enable_1pass_quant = TRUE; + cinfo->enable_external_quant = FALSE; + cinfo->enable_2pass_quant = FALSE; + cinfo->colormap = NULL; + } else if (cinfo->colormap != NULL) { + cinfo->enable_external_quant = TRUE; + } else if (cinfo->two_pass_quantize) { + cinfo->enable_2pass_quant = TRUE; + } else { + cinfo->enable_1pass_quant = TRUE; + } + + if (cinfo->enable_1pass_quant) { +#ifdef QUANT_1PASS_SUPPORTED + jinit_1pass_quantizer(cinfo); + master->quantizer_1pass = cinfo->cquantize; +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } + + /* We use the 2-pass code to map to external colormaps. */ + if (cinfo->enable_2pass_quant || cinfo->enable_external_quant) { +#ifdef QUANT_2PASS_SUPPORTED + jinit_2pass_quantizer(cinfo); + master->quantizer_2pass = cinfo->cquantize; +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } + /* If both quantizers are initialized, the 2-pass one is left active; + * this is necessary for starting with quantization to an external map. + */ + } + + /* Post-processing: in particular, color conversion first */ + if (! cinfo->raw_data_out) { + if (master->using_merged_upsample) { +#ifdef UPSAMPLE_MERGING_SUPPORTED + jinit_merged_upsampler(cinfo); /* does color conversion too */ +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } else { + jinit_color_deconverter(cinfo); + jinit_upsampler(cinfo); + } + jinit_d_post_controller(cinfo, cinfo->enable_2pass_quant); + } + /* Inverse DCT */ + jinit_inverse_dct(cinfo); + /* Entropy decoding: either Huffman or arithmetic coding. */ + if (cinfo->arith_code) { + ERREXIT(cinfo, JERR_ARITH_NOTIMPL); + } else { + if (cinfo->progressive_mode) { +#ifdef D_PROGRESSIVE_SUPPORTED + jinit_phuff_decoder(cinfo); +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } else + jinit_huff_decoder(cinfo); + } + + /* Initialize principal buffer controllers. */ + use_c_buffer = cinfo->inputctl->has_multiple_scans || cinfo->buffered_image; + jinit_d_coef_controller(cinfo, use_c_buffer); + + if (! cinfo->raw_data_out) + jinit_d_main_controller(cinfo, FALSE /* never need full buffer here */); + + /* We can now tell the memory manager to allocate virtual arrays. */ + (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); + + /* Initialize input side of decompressor to consume first scan. */ + (*cinfo->inputctl->start_input_pass) (cinfo); + +#ifdef D_MULTISCAN_FILES_SUPPORTED + /* If jpeg_start_decompress will read the whole file, initialize + * progress monitoring appropriately. The input step is counted + * as one pass. + */ + if (cinfo->progress != NULL && ! cinfo->buffered_image && + cinfo->inputctl->has_multiple_scans) { + int nscans; + /* Estimate number of scans to set pass_limit. */ + if (cinfo->progressive_mode) { + /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */ + nscans = 2 + 3 * cinfo->num_components; + } else { + /* For a nonprogressive multiscan file, estimate 1 scan per component. */ + nscans = cinfo->num_components; + } + cinfo->progress->pass_counter = 0L; + cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans; + cinfo->progress->completed_passes = 0; + cinfo->progress->total_passes = (cinfo->enable_2pass_quant ? 3 : 2); + /* Count the input pass as done */ + master->pass_number++; + } +#endif /* D_MULTISCAN_FILES_SUPPORTED */ +} + + +/* + * Per-pass setup. + * This is called at the beginning of each output pass. We determine which + * modules will be active during this pass and give them appropriate + * start_pass calls. We also set is_dummy_pass to indicate whether this + * is a "real" output pass or a dummy pass for color quantization. + * (In the latter case, jdapi.c will crank the pass to completion.) + */ + +METHODDEF(void) +prepare_for_output_pass (j_decompress_ptr cinfo) +{ + my_master_ptr master = (my_master_ptr) cinfo->master; + + if (master->pub.is_dummy_pass) { +#ifdef QUANT_2PASS_SUPPORTED + /* Final pass of 2-pass quantization */ + master->pub.is_dummy_pass = FALSE; + (*cinfo->cquantize->start_pass) (cinfo, FALSE); + (*cinfo->post->start_pass) (cinfo, JBUF_CRANK_DEST); + (*cinfo->main->start_pass) (cinfo, JBUF_CRANK_DEST); +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif /* QUANT_2PASS_SUPPORTED */ + } else { + if (cinfo->quantize_colors && cinfo->colormap == NULL) { + /* Select new quantization method */ + if (cinfo->two_pass_quantize && cinfo->enable_2pass_quant) { + cinfo->cquantize = master->quantizer_2pass; + master->pub.is_dummy_pass = TRUE; + } else if (cinfo->enable_1pass_quant) { + cinfo->cquantize = master->quantizer_1pass; + } else { + ERREXIT(cinfo, JERR_MODE_CHANGE); + } + } + (*cinfo->idct->start_pass) (cinfo); + (*cinfo->coef->start_output_pass) (cinfo); + if (! cinfo->raw_data_out) { + if (! master->using_merged_upsample) + (*cinfo->cconvert->start_pass) (cinfo); + (*cinfo->upsample->start_pass) (cinfo); + if (cinfo->quantize_colors) + (*cinfo->cquantize->start_pass) (cinfo, master->pub.is_dummy_pass); + (*cinfo->post->start_pass) (cinfo, + (master->pub.is_dummy_pass ? JBUF_SAVE_AND_PASS : JBUF_PASS_THRU)); + (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU); + } + } + + /* Set up progress monitor's pass info if present */ + if (cinfo->progress != NULL) { + cinfo->progress->completed_passes = master->pass_number; + cinfo->progress->total_passes = master->pass_number + + (master->pub.is_dummy_pass ? 2 : 1); + /* In buffered-image mode, we assume one more output pass if EOI not + * yet reached, but no more passes if EOI has been reached. + */ + if (cinfo->buffered_image && ! cinfo->inputctl->eoi_reached) { + cinfo->progress->total_passes += (cinfo->enable_2pass_quant ? 2 : 1); + } + } +} + + +/* + * Finish up at end of an output pass. + */ + +METHODDEF(void) +finish_output_pass (j_decompress_ptr cinfo) +{ + my_master_ptr master = (my_master_ptr) cinfo->master; + + if (cinfo->quantize_colors) + (*cinfo->cquantize->finish_pass) (cinfo); + master->pass_number++; +} + + +#ifdef D_MULTISCAN_FILES_SUPPORTED + +/* + * Switch to a new external colormap between output passes. + */ + +GLOBAL(void) +jpeg_new_colormap (j_decompress_ptr cinfo) +{ + my_master_ptr master = (my_master_ptr) cinfo->master; + + /* Prevent application from calling me at wrong times */ + if (cinfo->global_state != DSTATE_BUFIMAGE) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + if (cinfo->quantize_colors && cinfo->enable_external_quant && + cinfo->colormap != NULL) { + /* Select 2-pass quantizer for external colormap use */ + cinfo->cquantize = master->quantizer_2pass; + /* Notify quantizer of colormap change */ + (*cinfo->cquantize->new_color_map) (cinfo); + master->pub.is_dummy_pass = FALSE; /* just in case */ + } else + ERREXIT(cinfo, JERR_MODE_CHANGE); +} + +#endif /* D_MULTISCAN_FILES_SUPPORTED */ + + +/* + * Initialize master decompression control and select active modules. + * This is performed at the start of jpeg_start_decompress. + */ + +GLOBAL(void) +jinit_master_decompress (j_decompress_ptr cinfo) +{ + my_master_ptr master; + + master = (my_master_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_decomp_master)); + cinfo->master = (struct jpeg_decomp_master *) master; + master->pub.prepare_for_output_pass = prepare_for_output_pass; + master->pub.finish_output_pass = finish_output_pass; + + master->pub.is_dummy_pass = FALSE; + + master_selection(cinfo); +} diff --git a/gs/jpeg/jdmerge.c b/gs/jpeg/jdmerge.c new file mode 100644 index 000000000..37444468c --- /dev/null +++ b/gs/jpeg/jdmerge.c @@ -0,0 +1,400 @@ +/* + * jdmerge.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains code for merged upsampling/color conversion. + * + * This file combines functions from jdsample.c and jdcolor.c; + * read those files first to understand what's going on. + * + * When the chroma components are to be upsampled by simple replication + * (ie, box filtering), we can save some work in color conversion by + * calculating all the output pixels corresponding to a pair of chroma + * samples at one time. In the conversion equations + * R = Y + K1 * Cr + * G = Y + K2 * Cb + K3 * Cr + * B = Y + K4 * Cb + * only the Y term varies among the group of pixels corresponding to a pair + * of chroma samples, so the rest of the terms can be calculated just once. + * At typical sampling ratios, this eliminates half or three-quarters of the + * multiplications needed for color conversion. + * + * This file currently provides implementations for the following cases: + * YCbCr => RGB color conversion only. + * Sampling ratios of 2h1v or 2h2v. + * No scaling needed at upsample time. + * Corner-aligned (non-CCIR601) sampling alignment. + * Other special cases could be added, but in most applications these are + * the only common cases. (For uncommon cases we fall back on the more + * general code in jdsample.c and jdcolor.c.) + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + +#ifdef UPSAMPLE_MERGING_SUPPORTED + + +/* Private subobject */ + +typedef struct { + struct jpeg_upsampler pub; /* public fields */ + + /* Pointer to routine to do actual upsampling/conversion of one row group */ + JMETHOD(void, upmethod, (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, + JSAMPARRAY output_buf)); + + /* Private state for YCC->RGB conversion */ + int * Cr_r_tab; /* => table for Cr to R conversion */ + int * Cb_b_tab; /* => table for Cb to B conversion */ + INT32 * Cr_g_tab; /* => table for Cr to G conversion */ + INT32 * Cb_g_tab; /* => table for Cb to G conversion */ + + /* For 2:1 vertical sampling, we produce two output rows at a time. + * We need a "spare" row buffer to hold the second output row if the + * application provides just a one-row buffer; we also use the spare + * to discard the dummy last row if the image height is odd. + */ + JSAMPROW spare_row; + boolean spare_full; /* T if spare buffer is occupied */ + + JDIMENSION out_row_width; /* samples per output row */ + JDIMENSION rows_to_go; /* counts rows remaining in image */ +} my_upsampler; + +typedef my_upsampler * my_upsample_ptr; + +#define SCALEBITS 16 /* speediest right-shift on some machines */ +#define ONE_HALF ((INT32) 1 << (SCALEBITS-1)) +#define FIX(x) ((INT32) ((x) * (1L<RGB colorspace conversion. + * This is taken directly from jdcolor.c; see that file for more info. + */ + +LOCAL(void) +build_ycc_rgb_table (j_decompress_ptr cinfo) +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + int i; + INT32 x; + SHIFT_TEMPS + + upsample->Cr_r_tab = (int *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (MAXJSAMPLE+1) * SIZEOF(int)); + upsample->Cb_b_tab = (int *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (MAXJSAMPLE+1) * SIZEOF(int)); + upsample->Cr_g_tab = (INT32 *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (MAXJSAMPLE+1) * SIZEOF(INT32)); + upsample->Cb_g_tab = (INT32 *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (MAXJSAMPLE+1) * SIZEOF(INT32)); + + for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) { + /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */ + /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */ + /* Cr=>R value is nearest int to 1.40200 * x */ + upsample->Cr_r_tab[i] = (int) + RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS); + /* Cb=>B value is nearest int to 1.77200 * x */ + upsample->Cb_b_tab[i] = (int) + RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS); + /* Cr=>G value is scaled-up -0.71414 * x */ + upsample->Cr_g_tab[i] = (- FIX(0.71414)) * x; + /* Cb=>G value is scaled-up -0.34414 * x */ + /* We also add in ONE_HALF so that need not do it in inner loop */ + upsample->Cb_g_tab[i] = (- FIX(0.34414)) * x + ONE_HALF; + } +} + + +/* + * Initialize for an upsampling pass. + */ + +METHODDEF(void) +start_pass_merged_upsample (j_decompress_ptr cinfo) +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + + /* Mark the spare buffer empty */ + upsample->spare_full = FALSE; + /* Initialize total-height counter for detecting bottom of image */ + upsample->rows_to_go = cinfo->output_height; +} + + +/* + * Control routine to do upsampling (and color conversion). + * + * The control routine just handles the row buffering considerations. + */ + +METHODDEF(void) +merged_2v_upsample (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail) +/* 2:1 vertical sampling case: may need a spare row. */ +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + JSAMPROW work_ptrs[2]; + JDIMENSION num_rows; /* number of rows returned to caller */ + + if (upsample->spare_full) { + /* If we have a spare row saved from a previous cycle, just return it. */ + jcopy_sample_rows(& upsample->spare_row, 0, output_buf + *out_row_ctr, 0, + 1, upsample->out_row_width); + num_rows = 1; + upsample->spare_full = FALSE; + } else { + /* Figure number of rows to return to caller. */ + num_rows = 2; + /* Not more than the distance to the end of the image. */ + if (num_rows > upsample->rows_to_go) + num_rows = upsample->rows_to_go; + /* And not more than what the client can accept: */ + out_rows_avail -= *out_row_ctr; + if (num_rows > out_rows_avail) + num_rows = out_rows_avail; + /* Create output pointer array for upsampler. */ + work_ptrs[0] = output_buf[*out_row_ctr]; + if (num_rows > 1) { + work_ptrs[1] = output_buf[*out_row_ctr + 1]; + } else { + work_ptrs[1] = upsample->spare_row; + upsample->spare_full = TRUE; + } + /* Now do the upsampling. */ + (*upsample->upmethod) (cinfo, input_buf, *in_row_group_ctr, work_ptrs); + } + + /* Adjust counts */ + *out_row_ctr += num_rows; + upsample->rows_to_go -= num_rows; + /* When the buffer is emptied, declare this input row group consumed */ + if (! upsample->spare_full) + (*in_row_group_ctr)++; +} + + +METHODDEF(void) +merged_1v_upsample (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail) +/* 1:1 vertical sampling case: much easier, never need a spare row. */ +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + + /* Just do the upsampling. */ + (*upsample->upmethod) (cinfo, input_buf, *in_row_group_ctr, + output_buf + *out_row_ctr); + /* Adjust counts */ + (*out_row_ctr)++; + (*in_row_group_ctr)++; +} + + +/* + * These are the routines invoked by the control routines to do + * the actual upsampling/conversion. One row group is processed per call. + * + * Note: since we may be writing directly into application-supplied buffers, + * we have to be honest about the output width; we can't assume the buffer + * has been rounded up to an even width. + */ + + +/* + * Upsample and color convert for the case of 2:1 horizontal and 1:1 vertical. + */ + +METHODDEF(void) +h2v1_merged_upsample (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, + JSAMPARRAY output_buf) +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + register int y, cred, cgreen, cblue; + int cb, cr; + register JSAMPROW outptr; + JSAMPROW inptr0, inptr1, inptr2; + JDIMENSION col; + /* copy these pointers into registers if possible */ + register JSAMPLE * range_limit = cinfo->sample_range_limit; + int * Crrtab = upsample->Cr_r_tab; + int * Cbbtab = upsample->Cb_b_tab; + INT32 * Crgtab = upsample->Cr_g_tab; + INT32 * Cbgtab = upsample->Cb_g_tab; + SHIFT_TEMPS + + inptr0 = input_buf[0][in_row_group_ctr]; + inptr1 = input_buf[1][in_row_group_ctr]; + inptr2 = input_buf[2][in_row_group_ctr]; + outptr = output_buf[0]; + /* Loop for each pair of output pixels */ + for (col = cinfo->output_width >> 1; col > 0; col--) { + /* Do the chroma part of the calculation */ + cb = GETJSAMPLE(*inptr1++); + cr = GETJSAMPLE(*inptr2++); + cred = Crrtab[cr]; + cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); + cblue = Cbbtab[cb]; + /* Fetch 2 Y values and emit 2 pixels */ + y = GETJSAMPLE(*inptr0++); + outptr[RGB_RED] = range_limit[y + cred]; + outptr[RGB_GREEN] = range_limit[y + cgreen]; + outptr[RGB_BLUE] = range_limit[y + cblue]; + outptr += RGB_PIXELSIZE; + y = GETJSAMPLE(*inptr0++); + outptr[RGB_RED] = range_limit[y + cred]; + outptr[RGB_GREEN] = range_limit[y + cgreen]; + outptr[RGB_BLUE] = range_limit[y + cblue]; + outptr += RGB_PIXELSIZE; + } + /* If image width is odd, do the last output column separately */ + if (cinfo->output_width & 1) { + cb = GETJSAMPLE(*inptr1); + cr = GETJSAMPLE(*inptr2); + cred = Crrtab[cr]; + cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); + cblue = Cbbtab[cb]; + y = GETJSAMPLE(*inptr0); + outptr[RGB_RED] = range_limit[y + cred]; + outptr[RGB_GREEN] = range_limit[y + cgreen]; + outptr[RGB_BLUE] = range_limit[y + cblue]; + } +} + + +/* + * Upsample and color convert for the case of 2:1 horizontal and 2:1 vertical. + */ + +METHODDEF(void) +h2v2_merged_upsample (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, + JSAMPARRAY output_buf) +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + register int y, cred, cgreen, cblue; + int cb, cr; + register JSAMPROW outptr0, outptr1; + JSAMPROW inptr00, inptr01, inptr1, inptr2; + JDIMENSION col; + /* copy these pointers into registers if possible */ + register JSAMPLE * range_limit = cinfo->sample_range_limit; + int * Crrtab = upsample->Cr_r_tab; + int * Cbbtab = upsample->Cb_b_tab; + INT32 * Crgtab = upsample->Cr_g_tab; + INT32 * Cbgtab = upsample->Cb_g_tab; + SHIFT_TEMPS + + inptr00 = input_buf[0][in_row_group_ctr*2]; + inptr01 = input_buf[0][in_row_group_ctr*2 + 1]; + inptr1 = input_buf[1][in_row_group_ctr]; + inptr2 = input_buf[2][in_row_group_ctr]; + outptr0 = output_buf[0]; + outptr1 = output_buf[1]; + /* Loop for each group of output pixels */ + for (col = cinfo->output_width >> 1; col > 0; col--) { + /* Do the chroma part of the calculation */ + cb = GETJSAMPLE(*inptr1++); + cr = GETJSAMPLE(*inptr2++); + cred = Crrtab[cr]; + cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); + cblue = Cbbtab[cb]; + /* Fetch 4 Y values and emit 4 pixels */ + y = GETJSAMPLE(*inptr00++); + outptr0[RGB_RED] = range_limit[y + cred]; + outptr0[RGB_GREEN] = range_limit[y + cgreen]; + outptr0[RGB_BLUE] = range_limit[y + cblue]; + outptr0 += RGB_PIXELSIZE; + y = GETJSAMPLE(*inptr00++); + outptr0[RGB_RED] = range_limit[y + cred]; + outptr0[RGB_GREEN] = range_limit[y + cgreen]; + outptr0[RGB_BLUE] = range_limit[y + cblue]; + outptr0 += RGB_PIXELSIZE; + y = GETJSAMPLE(*inptr01++); + outptr1[RGB_RED] = range_limit[y + cred]; + outptr1[RGB_GREEN] = range_limit[y + cgreen]; + outptr1[RGB_BLUE] = range_limit[y + cblue]; + outptr1 += RGB_PIXELSIZE; + y = GETJSAMPLE(*inptr01++); + outptr1[RGB_RED] = range_limit[y + cred]; + outptr1[RGB_GREEN] = range_limit[y + cgreen]; + outptr1[RGB_BLUE] = range_limit[y + cblue]; + outptr1 += RGB_PIXELSIZE; + } + /* If image width is odd, do the last output column separately */ + if (cinfo->output_width & 1) { + cb = GETJSAMPLE(*inptr1); + cr = GETJSAMPLE(*inptr2); + cred = Crrtab[cr]; + cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); + cblue = Cbbtab[cb]; + y = GETJSAMPLE(*inptr00); + outptr0[RGB_RED] = range_limit[y + cred]; + outptr0[RGB_GREEN] = range_limit[y + cgreen]; + outptr0[RGB_BLUE] = range_limit[y + cblue]; + y = GETJSAMPLE(*inptr01); + outptr1[RGB_RED] = range_limit[y + cred]; + outptr1[RGB_GREEN] = range_limit[y + cgreen]; + outptr1[RGB_BLUE] = range_limit[y + cblue]; + } +} + + +/* + * Module initialization routine for merged upsampling/color conversion. + * + * NB: this is called under the conditions determined by use_merged_upsample() + * in jdmaster.c. That routine MUST correspond to the actual capabilities + * of this module; no safety checks are made here. + */ + +GLOBAL(void) +jinit_merged_upsampler (j_decompress_ptr cinfo) +{ + my_upsample_ptr upsample; + + upsample = (my_upsample_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_upsampler)); + cinfo->upsample = (struct jpeg_upsampler *) upsample; + upsample->pub.start_pass = start_pass_merged_upsample; + upsample->pub.need_context_rows = FALSE; + + upsample->out_row_width = cinfo->output_width * cinfo->out_color_components; + + if (cinfo->max_v_samp_factor == 2) { + upsample->pub.upsample = merged_2v_upsample; + upsample->upmethod = h2v2_merged_upsample; + /* Allocate a spare row buffer */ + upsample->spare_row = (JSAMPROW) + (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (size_t) (upsample->out_row_width * SIZEOF(JSAMPLE))); + } else { + upsample->pub.upsample = merged_1v_upsample; + upsample->upmethod = h2v1_merged_upsample; + /* No spare row needed */ + upsample->spare_row = NULL; + } + + build_ycc_rgb_table(cinfo); +} + +#endif /* UPSAMPLE_MERGING_SUPPORTED */ diff --git a/gs/jpeg/jdphuff.c b/gs/jpeg/jdphuff.c new file mode 100644 index 000000000..f6a89f346 --- /dev/null +++ b/gs/jpeg/jdphuff.c @@ -0,0 +1,642 @@ +/* + * jdphuff.c + * + * Copyright (C) 1995-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains Huffman entropy decoding routines for progressive JPEG. + * + * Much of the complexity here has to do with supporting input suspension. + * If the data source module demands suspension, we want to be able to back + * up to the start of the current MCU. To do this, we copy state variables + * into local working storage, and update them back to the permanent + * storage only upon successful completion of an MCU. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdhuff.h" /* Declarations shared with jdhuff.c */ + + +#ifdef D_PROGRESSIVE_SUPPORTED + +/* + * Expanded entropy decoder object for progressive Huffman decoding. + * + * The savable_state subrecord contains fields that change within an MCU, + * but must not be updated permanently until we complete the MCU. + */ + +typedef struct { + unsigned int EOBRUN; /* remaining EOBs in EOBRUN */ + int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ +} savable_state; + +/* This macro is to work around compilers with missing or broken + * structure assignment. You'll need to fix this code if you have + * such a compiler and you change MAX_COMPS_IN_SCAN. + */ + +#ifndef NO_STRUCT_ASSIGN +#define ASSIGN_STATE(dest,src) ((dest) = (src)) +#else +#if MAX_COMPS_IN_SCAN == 4 +#define ASSIGN_STATE(dest,src) \ + ((dest).EOBRUN = (src).EOBRUN, \ + (dest).last_dc_val[0] = (src).last_dc_val[0], \ + (dest).last_dc_val[1] = (src).last_dc_val[1], \ + (dest).last_dc_val[2] = (src).last_dc_val[2], \ + (dest).last_dc_val[3] = (src).last_dc_val[3]) +#endif +#endif + + +typedef struct { + struct jpeg_entropy_decoder pub; /* public fields */ + + /* These fields are loaded into local variables at start of each MCU. + * In case of suspension, we exit WITHOUT updating them. + */ + bitread_perm_state bitstate; /* Bit buffer at start of MCU */ + savable_state saved; /* Other state at start of MCU */ + + /* These fields are NOT loaded into local working state. */ + unsigned int restarts_to_go; /* MCUs left in this restart interval */ + + /* Pointers to derived tables (these workspaces have image lifespan) */ + d_derived_tbl * derived_tbls[NUM_HUFF_TBLS]; + + d_derived_tbl * ac_derived_tbl; /* active table during an AC scan */ +} phuff_entropy_decoder; + +typedef phuff_entropy_decoder * phuff_entropy_ptr; + +/* Forward declarations */ +METHODDEF(boolean) decode_mcu_DC_first JPP((j_decompress_ptr cinfo, + JBLOCKROW *MCU_data)); +METHODDEF(boolean) decode_mcu_AC_first JPP((j_decompress_ptr cinfo, + JBLOCKROW *MCU_data)); +METHODDEF(boolean) decode_mcu_DC_refine JPP((j_decompress_ptr cinfo, + JBLOCKROW *MCU_data)); +METHODDEF(boolean) decode_mcu_AC_refine JPP((j_decompress_ptr cinfo, + JBLOCKROW *MCU_data)); + + +/* + * Initialize for a Huffman-compressed scan. + */ + +METHODDEF(void) +start_pass_phuff_decoder (j_decompress_ptr cinfo) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + boolean is_DC_band, bad; + int ci, coefi, tbl; + int *coef_bit_ptr; + jpeg_component_info * compptr; + + is_DC_band = (cinfo->Ss == 0); + + /* Validate scan parameters */ + bad = FALSE; + if (is_DC_band) { + if (cinfo->Se != 0) + bad = TRUE; + } else { + /* need not check Ss/Se < 0 since they came from unsigned bytes */ + if (cinfo->Ss > cinfo->Se || cinfo->Se >= DCTSIZE2) + bad = TRUE; + /* AC scans may have only one component */ + if (cinfo->comps_in_scan != 1) + bad = TRUE; + } + if (cinfo->Ah != 0) { + /* Successive approximation refinement scan: must have Al = Ah-1. */ + if (cinfo->Al != cinfo->Ah-1) + bad = TRUE; + } + if (cinfo->Al > 13) /* need not check for < 0 */ + bad = TRUE; + if (bad) + ERREXIT4(cinfo, JERR_BAD_PROGRESSION, + cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al); + /* Update progression status, and verify that scan order is legal. + * Note that inter-scan inconsistencies are treated as warnings + * not fatal errors ... not clear if this is right way to behave. + */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + int cindex = cinfo->cur_comp_info[ci]->component_index; + coef_bit_ptr = & cinfo->coef_bits[cindex][0]; + if (!is_DC_band && coef_bit_ptr[0] < 0) /* AC without prior DC scan */ + WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, 0); + for (coefi = cinfo->Ss; coefi <= cinfo->Se; coefi++) { + int expected = (coef_bit_ptr[coefi] < 0) ? 0 : coef_bit_ptr[coefi]; + if (cinfo->Ah != expected) + WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, coefi); + coef_bit_ptr[coefi] = cinfo->Al; + } + } + + /* Select MCU decoding routine */ + if (cinfo->Ah == 0) { + if (is_DC_band) + entropy->pub.decode_mcu = decode_mcu_DC_first; + else + entropy->pub.decode_mcu = decode_mcu_AC_first; + } else { + if (is_DC_band) + entropy->pub.decode_mcu = decode_mcu_DC_refine; + else + entropy->pub.decode_mcu = decode_mcu_AC_refine; + } + + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + /* Make sure requested tables are present, and compute derived tables. + * We may build same derived table more than once, but it's not expensive. + */ + if (is_DC_band) { + if (cinfo->Ah == 0) { /* DC refinement needs no table */ + tbl = compptr->dc_tbl_no; + if (tbl < 0 || tbl >= NUM_HUFF_TBLS || + cinfo->dc_huff_tbl_ptrs[tbl] == NULL) + ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tbl); + jpeg_make_d_derived_tbl(cinfo, cinfo->dc_huff_tbl_ptrs[tbl], + & entropy->derived_tbls[tbl]); + } + } else { + tbl = compptr->ac_tbl_no; + if (tbl < 0 || tbl >= NUM_HUFF_TBLS || + cinfo->ac_huff_tbl_ptrs[tbl] == NULL) + ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tbl); + jpeg_make_d_derived_tbl(cinfo, cinfo->ac_huff_tbl_ptrs[tbl], + & entropy->derived_tbls[tbl]); + /* remember the single active table */ + entropy->ac_derived_tbl = entropy->derived_tbls[tbl]; + } + /* Initialize DC predictions to 0 */ + entropy->saved.last_dc_val[ci] = 0; + } + + /* Initialize bitread state variables */ + entropy->bitstate.bits_left = 0; + entropy->bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */ + entropy->bitstate.printed_eod = FALSE; + + /* Initialize private state variables */ + entropy->saved.EOBRUN = 0; + + /* Initialize restart counter */ + entropy->restarts_to_go = cinfo->restart_interval; +} + + +/* + * Figure F.12: extend sign bit. + * On some machines, a shift and add will be faster than a table lookup. + */ + +#ifdef AVOID_TABLES + +#define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) + (((-1)<<(s)) + 1) : (x)) + +#else + +#define HUFF_EXTEND(x,s) ((x) < extend_test[s] ? (x) + extend_offset[s] : (x)) + +static const int extend_test[16] = /* entry n is 2**(n-1) */ + { 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, + 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 }; + +static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */ + { 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1, + ((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1, + ((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1, + ((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 }; + +#endif /* AVOID_TABLES */ + + +/* + * Check for a restart marker & resynchronize decoder. + * Returns FALSE if must suspend. + */ + +LOCAL(boolean) +process_restart (j_decompress_ptr cinfo) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + int ci; + + /* Throw away any unused bits remaining in bit buffer; */ + /* include any full bytes in next_marker's count of discarded bytes */ + cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8; + entropy->bitstate.bits_left = 0; + + /* Advance past the RSTn marker */ + if (! (*cinfo->marker->read_restart_marker) (cinfo)) + return FALSE; + + /* Re-initialize DC predictions to 0 */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) + entropy->saved.last_dc_val[ci] = 0; + /* Re-init EOB run count, too */ + entropy->saved.EOBRUN = 0; + + /* Reset restart counter */ + entropy->restarts_to_go = cinfo->restart_interval; + + /* Next segment can get another out-of-data warning */ + entropy->bitstate.printed_eod = FALSE; + + return TRUE; +} + + +/* + * Huffman MCU decoding. + * Each of these routines decodes and returns one MCU's worth of + * Huffman-compressed coefficients. + * The coefficients are reordered from zigzag order into natural array order, + * but are not dequantized. + * + * The i'th block of the MCU is stored into the block pointed to by + * MCU_data[i]. WE ASSUME THIS AREA IS INITIALLY ZEROED BY THE CALLER. + * + * We return FALSE if data source requested suspension. In that case no + * changes have been made to permanent state. (Exception: some output + * coefficients may already have been assigned. This is harmless for + * spectral selection, since we'll just re-assign them on the next call. + * Successive approximation AC refinement has to be more careful, however.) + */ + +/* + * MCU decoding for DC initial scan (either spectral selection, + * or first pass of successive approximation). + */ + +METHODDEF(boolean) +decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + int Al = cinfo->Al; + register int s, r; + int blkn, ci; + JBLOCKROW block; + BITREAD_STATE_VARS; + savable_state state; + d_derived_tbl * tbl; + jpeg_component_info * compptr; + + /* Process restart marker if needed; may have to suspend */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) + if (! process_restart(cinfo)) + return FALSE; + } + + /* Load up working state */ + BITREAD_LOAD_STATE(cinfo,entropy->bitstate); + ASSIGN_STATE(state, entropy->saved); + + /* Outer loop handles each block in the MCU */ + + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + block = MCU_data[blkn]; + ci = cinfo->MCU_membership[blkn]; + compptr = cinfo->cur_comp_info[ci]; + tbl = entropy->derived_tbls[compptr->dc_tbl_no]; + + /* Decode a single block's worth of coefficients */ + + /* Section F.2.2.1: decode the DC coefficient difference */ + HUFF_DECODE(s, br_state, tbl, return FALSE, label1); + if (s) { + CHECK_BIT_BUFFER(br_state, s, return FALSE); + r = GET_BITS(s); + s = HUFF_EXTEND(r, s); + } + + /* Convert DC difference to actual value, update last_dc_val */ + s += state.last_dc_val[ci]; + state.last_dc_val[ci] = s; + /* Scale and output the DC coefficient (assumes jpeg_natural_order[0]=0) */ + (*block)[0] = (JCOEF) (s << Al); + } + + /* Completed MCU, so update state */ + BITREAD_SAVE_STATE(cinfo,entropy->bitstate); + ASSIGN_STATE(entropy->saved, state); + + /* Account for restart interval (no-op if not using restarts) */ + entropy->restarts_to_go--; + + return TRUE; +} + + +/* + * MCU decoding for AC initial scan (either spectral selection, + * or first pass of successive approximation). + */ + +METHODDEF(boolean) +decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + int Se = cinfo->Se; + int Al = cinfo->Al; + register int s, k, r; + unsigned int EOBRUN; + JBLOCKROW block; + BITREAD_STATE_VARS; + d_derived_tbl * tbl; + + /* Process restart marker if needed; may have to suspend */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) + if (! process_restart(cinfo)) + return FALSE; + } + + /* Load up working state. + * We can avoid loading/saving bitread state if in an EOB run. + */ + EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we care about */ + + /* There is always only one block per MCU */ + + if (EOBRUN > 0) /* if it's a band of zeroes... */ + EOBRUN--; /* ...process it now (we do nothing) */ + else { + BITREAD_LOAD_STATE(cinfo,entropy->bitstate); + block = MCU_data[0]; + tbl = entropy->ac_derived_tbl; + + for (k = cinfo->Ss; k <= Se; k++) { + HUFF_DECODE(s, br_state, tbl, return FALSE, label2); + r = s >> 4; + s &= 15; + if (s) { + k += r; + CHECK_BIT_BUFFER(br_state, s, return FALSE); + r = GET_BITS(s); + s = HUFF_EXTEND(r, s); + /* Scale and output coefficient in natural (dezigzagged) order */ + (*block)[jpeg_natural_order[k]] = (JCOEF) (s << Al); + } else { + if (r == 15) { /* ZRL */ + k += 15; /* skip 15 zeroes in band */ + } else { /* EOBr, run length is 2^r + appended bits */ + EOBRUN = 1 << r; + if (r) { /* EOBr, r > 0 */ + CHECK_BIT_BUFFER(br_state, r, return FALSE); + r = GET_BITS(r); + EOBRUN += r; + } + EOBRUN--; /* this band is processed at this moment */ + break; /* force end-of-band */ + } + } + } + + BITREAD_SAVE_STATE(cinfo,entropy->bitstate); + } + + /* Completed MCU, so update state */ + entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we care about */ + + /* Account for restart interval (no-op if not using restarts) */ + entropy->restarts_to_go--; + + return TRUE; +} + + +/* + * MCU decoding for DC successive approximation refinement scan. + * Note: we assume such scans can be multi-component, although the spec + * is not very clear on the point. + */ + +METHODDEF(boolean) +decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + int p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */ + int blkn; + JBLOCKROW block; + BITREAD_STATE_VARS; + + /* Process restart marker if needed; may have to suspend */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) + if (! process_restart(cinfo)) + return FALSE; + } + + /* Load up working state */ + BITREAD_LOAD_STATE(cinfo,entropy->bitstate); + + /* Outer loop handles each block in the MCU */ + + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + block = MCU_data[blkn]; + + /* Encoded data is simply the next bit of the two's-complement DC value */ + CHECK_BIT_BUFFER(br_state, 1, return FALSE); + if (GET_BITS(1)) + (*block)[0] |= p1; + /* Note: since we use |=, repeating the assignment later is safe */ + } + + /* Completed MCU, so update state */ + BITREAD_SAVE_STATE(cinfo,entropy->bitstate); + + /* Account for restart interval (no-op if not using restarts) */ + entropy->restarts_to_go--; + + return TRUE; +} + + +/* + * MCU decoding for AC successive approximation refinement scan. + */ + +METHODDEF(boolean) +decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + int Se = cinfo->Se; + int p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */ + int m1 = (-1) << cinfo->Al; /* -1 in the bit position being coded */ + register int s, k, r; + unsigned int EOBRUN; + JBLOCKROW block; + JCOEFPTR thiscoef; + BITREAD_STATE_VARS; + d_derived_tbl * tbl; + int num_newnz; + int newnz_pos[DCTSIZE2]; + + /* Process restart marker if needed; may have to suspend */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) + if (! process_restart(cinfo)) + return FALSE; + } + + /* Load up working state */ + BITREAD_LOAD_STATE(cinfo,entropy->bitstate); + EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we care about */ + + /* There is always only one block per MCU */ + block = MCU_data[0]; + tbl = entropy->ac_derived_tbl; + + /* If we are forced to suspend, we must undo the assignments to any newly + * nonzero coefficients in the block, because otherwise we'd get confused + * next time about which coefficients were already nonzero. + * But we need not undo addition of bits to already-nonzero coefficients; + * instead, we can test the current bit position to see if we already did it. + */ + num_newnz = 0; + + /* initialize coefficient loop counter to start of band */ + k = cinfo->Ss; + + if (EOBRUN == 0) { + for (; k <= Se; k++) { + HUFF_DECODE(s, br_state, tbl, goto undoit, label3); + r = s >> 4; + s &= 15; + if (s) { + if (s != 1) /* size of new coef should always be 1 */ + WARNMS(cinfo, JWRN_HUFF_BAD_CODE); + CHECK_BIT_BUFFER(br_state, 1, goto undoit); + if (GET_BITS(1)) + s = p1; /* newly nonzero coef is positive */ + else + s = m1; /* newly nonzero coef is negative */ + } else { + if (r != 15) { + EOBRUN = 1 << r; /* EOBr, run length is 2^r + appended bits */ + if (r) { + CHECK_BIT_BUFFER(br_state, r, goto undoit); + r = GET_BITS(r); + EOBRUN += r; + } + break; /* rest of block is handled by EOB logic */ + } + /* note s = 0 for processing ZRL */ + } + /* Advance over already-nonzero coefs and r still-zero coefs, + * appending correction bits to the nonzeroes. A correction bit is 1 + * if the absolute value of the coefficient must be increased. + */ + do { + thiscoef = *block + jpeg_natural_order[k]; + if (*thiscoef != 0) { + CHECK_BIT_BUFFER(br_state, 1, goto undoit); + if (GET_BITS(1)) { + if ((*thiscoef & p1) == 0) { /* do nothing if already changed it */ + if (*thiscoef >= 0) + *thiscoef += p1; + else + *thiscoef += m1; + } + } + } else { + if (--r < 0) + break; /* reached target zero coefficient */ + } + k++; + } while (k <= Se); + if (s) { + int pos = jpeg_natural_order[k]; + /* Output newly nonzero coefficient */ + (*block)[pos] = (JCOEF) s; + /* Remember its position in case we have to suspend */ + newnz_pos[num_newnz++] = pos; + } + } + } + + if (EOBRUN > 0) { + /* Scan any remaining coefficient positions after the end-of-band + * (the last newly nonzero coefficient, if any). Append a correction + * bit to each already-nonzero coefficient. A correction bit is 1 + * if the absolute value of the coefficient must be increased. + */ + for (; k <= Se; k++) { + thiscoef = *block + jpeg_natural_order[k]; + if (*thiscoef != 0) { + CHECK_BIT_BUFFER(br_state, 1, goto undoit); + if (GET_BITS(1)) { + if ((*thiscoef & p1) == 0) { /* do nothing if already changed it */ + if (*thiscoef >= 0) + *thiscoef += p1; + else + *thiscoef += m1; + } + } + } + } + /* Count one block completed in EOB run */ + EOBRUN--; + } + + /* Completed MCU, so update state */ + BITREAD_SAVE_STATE(cinfo,entropy->bitstate); + entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we care about */ + + /* Account for restart interval (no-op if not using restarts) */ + entropy->restarts_to_go--; + + return TRUE; + +undoit: + /* Re-zero any output coefficients that we made newly nonzero */ + while (num_newnz > 0) + (*block)[newnz_pos[--num_newnz]] = 0; + + return FALSE; +} + + +/* + * Module initialization routine for progressive Huffman entropy decoding. + */ + +GLOBAL(void) +jinit_phuff_decoder (j_decompress_ptr cinfo) +{ + phuff_entropy_ptr entropy; + int *coef_bit_ptr; + int ci, i; + + entropy = (phuff_entropy_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(phuff_entropy_decoder)); + cinfo->entropy = (struct jpeg_entropy_decoder *) entropy; + entropy->pub.start_pass = start_pass_phuff_decoder; + + /* Mark derived tables unallocated */ + for (i = 0; i < NUM_HUFF_TBLS; i++) { + entropy->derived_tbls[i] = NULL; + } + + /* Create progression status table */ + cinfo->coef_bits = (int (*)[DCTSIZE2]) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + cinfo->num_components*DCTSIZE2*SIZEOF(int)); + coef_bit_ptr = & cinfo->coef_bits[0][0]; + for (ci = 0; ci < cinfo->num_components; ci++) + for (i = 0; i < DCTSIZE2; i++) + *coef_bit_ptr++ = -1; +} + +#endif /* D_PROGRESSIVE_SUPPORTED */ diff --git a/gs/jpeg/jdpostct.c b/gs/jpeg/jdpostct.c new file mode 100644 index 000000000..571563d72 --- /dev/null +++ b/gs/jpeg/jdpostct.c @@ -0,0 +1,290 @@ +/* + * jdpostct.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the decompression postprocessing controller. + * This controller manages the upsampling, color conversion, and color + * quantization/reduction steps; specifically, it controls the buffering + * between upsample/color conversion and color quantization/reduction. + * + * If no color quantization/reduction is required, then this module has no + * work to do, and it just hands off to the upsample/color conversion code. + * An integrated upsample/convert/quantize process would replace this module + * entirely. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Private buffer controller object */ + +typedef struct { + struct jpeg_d_post_controller pub; /* public fields */ + + /* Color quantization source buffer: this holds output data from + * the upsample/color conversion step to be passed to the quantizer. + * For two-pass color quantization, we need a full-image buffer; + * for one-pass operation, a strip buffer is sufficient. + */ + jvirt_sarray_ptr whole_image; /* virtual array, or NULL if one-pass */ + JSAMPARRAY buffer; /* strip buffer, or current strip of virtual */ + JDIMENSION strip_height; /* buffer size in rows */ + /* for two-pass mode only: */ + JDIMENSION starting_row; /* row # of first row in current strip */ + JDIMENSION next_row; /* index of next row to fill/empty in strip */ +} my_post_controller; + +typedef my_post_controller * my_post_ptr; + + +/* Forward declarations */ +METHODDEF(void) post_process_1pass + JPP((j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail)); +#ifdef QUANT_2PASS_SUPPORTED +METHODDEF(void) post_process_prepass + JPP((j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail)); +METHODDEF(void) post_process_2pass + JPP((j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail)); +#endif + + +/* + * Initialize for a processing pass. + */ + +METHODDEF(void) +start_pass_dpost (j_decompress_ptr cinfo, J_BUF_MODE pass_mode) +{ + my_post_ptr post = (my_post_ptr) cinfo->post; + + switch (pass_mode) { + case JBUF_PASS_THRU: + if (cinfo->quantize_colors) { + /* Single-pass processing with color quantization. */ + post->pub.post_process_data = post_process_1pass; + /* We could be doing buffered-image output before starting a 2-pass + * color quantization; in that case, jinit_d_post_controller did not + * allocate a strip buffer. Use the virtual-array buffer as workspace. + */ + if (post->buffer == NULL) { + post->buffer = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, post->whole_image, + (JDIMENSION) 0, post->strip_height, TRUE); + } + } else { + /* For single-pass processing without color quantization, + * I have no work to do; just call the upsampler directly. + */ + post->pub.post_process_data = cinfo->upsample->upsample; + } + break; +#ifdef QUANT_2PASS_SUPPORTED + case JBUF_SAVE_AND_PASS: + /* First pass of 2-pass quantization */ + if (post->whole_image == NULL) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + post->pub.post_process_data = post_process_prepass; + break; + case JBUF_CRANK_DEST: + /* Second pass of 2-pass quantization */ + if (post->whole_image == NULL) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + post->pub.post_process_data = post_process_2pass; + break; +#endif /* QUANT_2PASS_SUPPORTED */ + default: + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + break; + } + post->starting_row = post->next_row = 0; +} + + +/* + * Process some data in the one-pass (strip buffer) case. + * This is used for color precision reduction as well as one-pass quantization. + */ + +METHODDEF(void) +post_process_1pass (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail) +{ + my_post_ptr post = (my_post_ptr) cinfo->post; + JDIMENSION num_rows, max_rows; + + /* Fill the buffer, but not more than what we can dump out in one go. */ + /* Note we rely on the upsampler to detect bottom of image. */ + max_rows = out_rows_avail - *out_row_ctr; + if (max_rows > post->strip_height) + max_rows = post->strip_height; + num_rows = 0; + (*cinfo->upsample->upsample) (cinfo, + input_buf, in_row_group_ctr, in_row_groups_avail, + post->buffer, &num_rows, max_rows); + /* Quantize and emit data. */ + (*cinfo->cquantize->color_quantize) (cinfo, + post->buffer, output_buf + *out_row_ctr, (int) num_rows); + *out_row_ctr += num_rows; +} + + +#ifdef QUANT_2PASS_SUPPORTED + +/* + * Process some data in the first pass of 2-pass quantization. + */ + +METHODDEF(void) +post_process_prepass (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail) +{ + my_post_ptr post = (my_post_ptr) cinfo->post; + JDIMENSION old_next_row, num_rows; + + /* Reposition virtual buffer if at start of strip. */ + if (post->next_row == 0) { + post->buffer = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, post->whole_image, + post->starting_row, post->strip_height, TRUE); + } + + /* Upsample some data (up to a strip height's worth). */ + old_next_row = post->next_row; + (*cinfo->upsample->upsample) (cinfo, + input_buf, in_row_group_ctr, in_row_groups_avail, + post->buffer, &post->next_row, post->strip_height); + + /* Allow quantizer to scan new data. No data is emitted, */ + /* but we advance out_row_ctr so outer loop can tell when we're done. */ + if (post->next_row > old_next_row) { + num_rows = post->next_row - old_next_row; + (*cinfo->cquantize->color_quantize) (cinfo, post->buffer + old_next_row, + (JSAMPARRAY) NULL, (int) num_rows); + *out_row_ctr += num_rows; + } + + /* Advance if we filled the strip. */ + if (post->next_row >= post->strip_height) { + post->starting_row += post->strip_height; + post->next_row = 0; + } +} + + +/* + * Process some data in the second pass of 2-pass quantization. + */ + +METHODDEF(void) +post_process_2pass (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail) +{ + my_post_ptr post = (my_post_ptr) cinfo->post; + JDIMENSION num_rows, max_rows; + + /* Reposition virtual buffer if at start of strip. */ + if (post->next_row == 0) { + post->buffer = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, post->whole_image, + post->starting_row, post->strip_height, FALSE); + } + + /* Determine number of rows to emit. */ + num_rows = post->strip_height - post->next_row; /* available in strip */ + max_rows = out_rows_avail - *out_row_ctr; /* available in output area */ + if (num_rows > max_rows) + num_rows = max_rows; + /* We have to check bottom of image here, can't depend on upsampler. */ + max_rows = cinfo->output_height - post->starting_row; + if (num_rows > max_rows) + num_rows = max_rows; + + /* Quantize and emit data. */ + (*cinfo->cquantize->color_quantize) (cinfo, + post->buffer + post->next_row, output_buf + *out_row_ctr, + (int) num_rows); + *out_row_ctr += num_rows; + + /* Advance if we filled the strip. */ + post->next_row += num_rows; + if (post->next_row >= post->strip_height) { + post->starting_row += post->strip_height; + post->next_row = 0; + } +} + +#endif /* QUANT_2PASS_SUPPORTED */ + + +/* + * Initialize postprocessing controller. + */ + +GLOBAL(void) +jinit_d_post_controller (j_decompress_ptr cinfo, boolean need_full_buffer) +{ + my_post_ptr post; + + post = (my_post_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_post_controller)); + cinfo->post = (struct jpeg_d_post_controller *) post; + post->pub.start_pass = start_pass_dpost; + post->whole_image = NULL; /* flag for no virtual arrays */ + post->buffer = NULL; /* flag for no strip buffer */ + + /* Create the quantization buffer, if needed */ + if (cinfo->quantize_colors) { + /* The buffer strip height is max_v_samp_factor, which is typically + * an efficient number of rows for upsampling to return. + * (In the presence of output rescaling, we might want to be smarter?) + */ + post->strip_height = (JDIMENSION) cinfo->max_v_samp_factor; + if (need_full_buffer) { + /* Two-pass color quantization: need full-image storage. */ + /* We round up the number of rows to a multiple of the strip height. */ +#ifdef QUANT_2PASS_SUPPORTED + post->whole_image = (*cinfo->mem->request_virt_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, + cinfo->output_width * cinfo->out_color_components, + (JDIMENSION) jround_up((long) cinfo->output_height, + (long) post->strip_height), + post->strip_height); +#else + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); +#endif /* QUANT_2PASS_SUPPORTED */ + } else { + /* One-pass color quantization: just make a strip buffer. */ + post->buffer = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + cinfo->output_width * cinfo->out_color_components, + post->strip_height); + } + } +} diff --git a/gs/jpeg/jdsample.c b/gs/jpeg/jdsample.c new file mode 100644 index 000000000..80ffefb2a --- /dev/null +++ b/gs/jpeg/jdsample.c @@ -0,0 +1,478 @@ +/* + * jdsample.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains upsampling routines. + * + * Upsampling input data is counted in "row groups". A row group + * is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size) + * sample rows of each component. Upsampling will normally produce + * max_v_samp_factor pixel rows from each row group (but this could vary + * if the upsampler is applying a scale factor of its own). + * + * An excellent reference for image resampling is + * Digital Image Warping, George Wolberg, 1990. + * Pub. by IEEE Computer Society Press, Los Alamitos, CA. ISBN 0-8186-8944-7. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Pointer to routine to upsample a single component */ +typedef JMETHOD(void, upsample1_ptr, + (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)); + +/* Private subobject */ + +typedef struct { + struct jpeg_upsampler pub; /* public fields */ + + /* Color conversion buffer. When using separate upsampling and color + * conversion steps, this buffer holds one upsampled row group until it + * has been color converted and output. + * Note: we do not allocate any storage for component(s) which are full-size, + * ie do not need rescaling. The corresponding entry of color_buf[] is + * simply set to point to the input data array, thereby avoiding copying. + */ + JSAMPARRAY color_buf[MAX_COMPONENTS]; + + /* Per-component upsampling method pointers */ + upsample1_ptr methods[MAX_COMPONENTS]; + + int next_row_out; /* counts rows emitted from color_buf */ + JDIMENSION rows_to_go; /* counts rows remaining in image */ + + /* Height of an input row group for each component. */ + int rowgroup_height[MAX_COMPONENTS]; + + /* These arrays save pixel expansion factors so that int_expand need not + * recompute them each time. They are unused for other upsampling methods. + */ + UINT8 h_expand[MAX_COMPONENTS]; + UINT8 v_expand[MAX_COMPONENTS]; +} my_upsampler; + +typedef my_upsampler * my_upsample_ptr; + + +/* + * Initialize for an upsampling pass. + */ + +METHODDEF(void) +start_pass_upsample (j_decompress_ptr cinfo) +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + + /* Mark the conversion buffer empty */ + upsample->next_row_out = cinfo->max_v_samp_factor; + /* Initialize total-height counter for detecting bottom of image */ + upsample->rows_to_go = cinfo->output_height; +} + + +/* + * Control routine to do upsampling (and color conversion). + * + * In this version we upsample each component independently. + * We upsample one row group into the conversion buffer, then apply + * color conversion a row at a time. + */ + +METHODDEF(void) +sep_upsample (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail) +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + int ci; + jpeg_component_info * compptr; + JDIMENSION num_rows; + + /* Fill the conversion buffer, if it's empty */ + if (upsample->next_row_out >= cinfo->max_v_samp_factor) { + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Invoke per-component upsample method. Notice we pass a POINTER + * to color_buf[ci], so that fullsize_upsample can change it. + */ + (*upsample->methods[ci]) (cinfo, compptr, + input_buf[ci] + (*in_row_group_ctr * upsample->rowgroup_height[ci]), + upsample->color_buf + ci); + } + upsample->next_row_out = 0; + } + + /* Color-convert and emit rows */ + + /* How many we have in the buffer: */ + num_rows = (JDIMENSION) (cinfo->max_v_samp_factor - upsample->next_row_out); + /* Not more than the distance to the end of the image. Need this test + * in case the image height is not a multiple of max_v_samp_factor: + */ + if (num_rows > upsample->rows_to_go) + num_rows = upsample->rows_to_go; + /* And not more than what the client can accept: */ + out_rows_avail -= *out_row_ctr; + if (num_rows > out_rows_avail) + num_rows = out_rows_avail; + + (*cinfo->cconvert->color_convert) (cinfo, upsample->color_buf, + (JDIMENSION) upsample->next_row_out, + output_buf + *out_row_ctr, + (int) num_rows); + + /* Adjust counts */ + *out_row_ctr += num_rows; + upsample->rows_to_go -= num_rows; + upsample->next_row_out += num_rows; + /* When the buffer is emptied, declare this input row group consumed */ + if (upsample->next_row_out >= cinfo->max_v_samp_factor) + (*in_row_group_ctr)++; +} + + +/* + * These are the routines invoked by sep_upsample to upsample pixel values + * of a single component. One row group is processed per call. + */ + + +/* + * For full-size components, we just make color_buf[ci] point at the + * input buffer, and thus avoid copying any data. Note that this is + * safe only because sep_upsample doesn't declare the input row group + * "consumed" until we are done color converting and emitting it. + */ + +METHODDEF(void) +fullsize_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) +{ + *output_data_ptr = input_data; +} + + +/* + * This is a no-op version used for "uninteresting" components. + * These components will not be referenced by color conversion. + */ + +METHODDEF(void) +noop_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) +{ + *output_data_ptr = NULL; /* safety check */ +} + + +/* + * This version handles any integral sampling ratios. + * This is not used for typical JPEG files, so it need not be fast. + * Nor, for that matter, is it particularly accurate: the algorithm is + * simple replication of the input pixel onto the corresponding output + * pixels. The hi-falutin sampling literature refers to this as a + * "box filter". A box filter tends to introduce visible artifacts, + * so if you are actually going to use 3:1 or 4:1 sampling ratios + * you would be well advised to improve this code. + */ + +METHODDEF(void) +int_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + JSAMPARRAY output_data = *output_data_ptr; + register JSAMPROW inptr, outptr; + register JSAMPLE invalue; + register int h; + JSAMPROW outend; + int h_expand, v_expand; + int inrow, outrow; + + h_expand = upsample->h_expand[compptr->component_index]; + v_expand = upsample->v_expand[compptr->component_index]; + + inrow = outrow = 0; + while (outrow < cinfo->max_v_samp_factor) { + /* Generate one output row with proper horizontal expansion */ + inptr = input_data[inrow]; + outptr = output_data[outrow]; + outend = outptr + cinfo->output_width; + while (outptr < outend) { + invalue = *inptr++; /* don't need GETJSAMPLE() here */ + for (h = h_expand; h > 0; h--) { + *outptr++ = invalue; + } + } + /* Generate any additional output rows by duplicating the first one */ + if (v_expand > 1) { + jcopy_sample_rows(output_data, outrow, output_data, outrow+1, + v_expand-1, cinfo->output_width); + } + inrow++; + outrow += v_expand; + } +} + + +/* + * Fast processing for the common case of 2:1 horizontal and 1:1 vertical. + * It's still a box filter. + */ + +METHODDEF(void) +h2v1_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) +{ + JSAMPARRAY output_data = *output_data_ptr; + register JSAMPROW inptr, outptr; + register JSAMPLE invalue; + JSAMPROW outend; + int inrow; + + for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) { + inptr = input_data[inrow]; + outptr = output_data[inrow]; + outend = outptr + cinfo->output_width; + while (outptr < outend) { + invalue = *inptr++; /* don't need GETJSAMPLE() here */ + *outptr++ = invalue; + *outptr++ = invalue; + } + } +} + + +/* + * Fast processing for the common case of 2:1 horizontal and 2:1 vertical. + * It's still a box filter. + */ + +METHODDEF(void) +h2v2_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) +{ + JSAMPARRAY output_data = *output_data_ptr; + register JSAMPROW inptr, outptr; + register JSAMPLE invalue; + JSAMPROW outend; + int inrow, outrow; + + inrow = outrow = 0; + while (outrow < cinfo->max_v_samp_factor) { + inptr = input_data[inrow]; + outptr = output_data[outrow]; + outend = outptr + cinfo->output_width; + while (outptr < outend) { + invalue = *inptr++; /* don't need GETJSAMPLE() here */ + *outptr++ = invalue; + *outptr++ = invalue; + } + jcopy_sample_rows(output_data, outrow, output_data, outrow+1, + 1, cinfo->output_width); + inrow++; + outrow += 2; + } +} + + +/* + * Fancy processing for the common case of 2:1 horizontal and 1:1 vertical. + * + * The upsampling algorithm is linear interpolation between pixel centers, + * also known as a "triangle filter". This is a good compromise between + * speed and visual quality. The centers of the output pixels are 1/4 and 3/4 + * of the way between input pixel centers. + * + * A note about the "bias" calculations: when rounding fractional values to + * integer, we do not want to always round 0.5 up to the next integer. + * If we did that, we'd introduce a noticeable bias towards larger values. + * Instead, this code is arranged so that 0.5 will be rounded up or down at + * alternate pixel locations (a simple ordered dither pattern). + */ + +METHODDEF(void) +h2v1_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) +{ + JSAMPARRAY output_data = *output_data_ptr; + register JSAMPROW inptr, outptr; + register int invalue; + register JDIMENSION colctr; + int inrow; + + for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) { + inptr = input_data[inrow]; + outptr = output_data[inrow]; + /* Special case for first column */ + invalue = GETJSAMPLE(*inptr++); + *outptr++ = (JSAMPLE) invalue; + *outptr++ = (JSAMPLE) ((invalue * 3 + GETJSAMPLE(*inptr) + 2) >> 2); + + for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) { + /* General case: 3/4 * nearer pixel + 1/4 * further pixel */ + invalue = GETJSAMPLE(*inptr++) * 3; + *outptr++ = (JSAMPLE) ((invalue + GETJSAMPLE(inptr[-2]) + 1) >> 2); + *outptr++ = (JSAMPLE) ((invalue + GETJSAMPLE(*inptr) + 2) >> 2); + } + + /* Special case for last column */ + invalue = GETJSAMPLE(*inptr); + *outptr++ = (JSAMPLE) ((invalue * 3 + GETJSAMPLE(inptr[-1]) + 1) >> 2); + *outptr++ = (JSAMPLE) invalue; + } +} + + +/* + * Fancy processing for the common case of 2:1 horizontal and 2:1 vertical. + * Again a triangle filter; see comments for h2v1 case, above. + * + * It is OK for us to reference the adjacent input rows because we demanded + * context from the main buffer controller (see initialization code). + */ + +METHODDEF(void) +h2v2_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) +{ + JSAMPARRAY output_data = *output_data_ptr; + register JSAMPROW inptr0, inptr1, outptr; +#if BITS_IN_JSAMPLE == 8 + register int thiscolsum, lastcolsum, nextcolsum; +#else + register INT32 thiscolsum, lastcolsum, nextcolsum; +#endif + register JDIMENSION colctr; + int inrow, outrow, v; + + inrow = outrow = 0; + while (outrow < cinfo->max_v_samp_factor) { + for (v = 0; v < 2; v++) { + /* inptr0 points to nearest input row, inptr1 points to next nearest */ + inptr0 = input_data[inrow]; + if (v == 0) /* next nearest is row above */ + inptr1 = input_data[inrow-1]; + else /* next nearest is row below */ + inptr1 = input_data[inrow+1]; + outptr = output_data[outrow++]; + + /* Special case for first column */ + thiscolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++); + nextcolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++); + *outptr++ = (JSAMPLE) ((thiscolsum * 4 + 8) >> 4); + *outptr++ = (JSAMPLE) ((thiscolsum * 3 + nextcolsum + 7) >> 4); + lastcolsum = thiscolsum; thiscolsum = nextcolsum; + + for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) { + /* General case: 3/4 * nearer pixel + 1/4 * further pixel in each */ + /* dimension, thus 9/16, 3/16, 3/16, 1/16 overall */ + nextcolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++); + *outptr++ = (JSAMPLE) ((thiscolsum * 3 + lastcolsum + 8) >> 4); + *outptr++ = (JSAMPLE) ((thiscolsum * 3 + nextcolsum + 7) >> 4); + lastcolsum = thiscolsum; thiscolsum = nextcolsum; + } + + /* Special case for last column */ + *outptr++ = (JSAMPLE) ((thiscolsum * 3 + lastcolsum + 8) >> 4); + *outptr++ = (JSAMPLE) ((thiscolsum * 4 + 7) >> 4); + } + inrow++; + } +} + + +/* + * Module initialization routine for upsampling. + */ + +GLOBAL(void) +jinit_upsampler (j_decompress_ptr cinfo) +{ + my_upsample_ptr upsample; + int ci; + jpeg_component_info * compptr; + boolean need_buffer, do_fancy; + int h_in_group, v_in_group, h_out_group, v_out_group; + + upsample = (my_upsample_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_upsampler)); + cinfo->upsample = (struct jpeg_upsampler *) upsample; + upsample->pub.start_pass = start_pass_upsample; + upsample->pub.upsample = sep_upsample; + upsample->pub.need_context_rows = FALSE; /* until we find out differently */ + + if (cinfo->CCIR601_sampling) /* this isn't supported */ + ERREXIT(cinfo, JERR_CCIR601_NOTIMPL); + + /* jdmainct.c doesn't support context rows when min_DCT_scaled_size = 1, + * so don't ask for it. + */ + do_fancy = cinfo->do_fancy_upsampling && cinfo->min_DCT_scaled_size > 1; + + /* Verify we can handle the sampling factors, select per-component methods, + * and create storage as needed. + */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Compute size of an "input group" after IDCT scaling. This many samples + * are to be converted to max_h_samp_factor * max_v_samp_factor pixels. + */ + h_in_group = (compptr->h_samp_factor * compptr->DCT_scaled_size) / + cinfo->min_DCT_scaled_size; + v_in_group = (compptr->v_samp_factor * compptr->DCT_scaled_size) / + cinfo->min_DCT_scaled_size; + h_out_group = cinfo->max_h_samp_factor; + v_out_group = cinfo->max_v_samp_factor; + upsample->rowgroup_height[ci] = v_in_group; /* save for use later */ + need_buffer = TRUE; + if (! compptr->component_needed) { + /* Don't bother to upsample an uninteresting component. */ + upsample->methods[ci] = noop_upsample; + need_buffer = FALSE; + } else if (h_in_group == h_out_group && v_in_group == v_out_group) { + /* Fullsize components can be processed without any work. */ + upsample->methods[ci] = fullsize_upsample; + need_buffer = FALSE; + } else if (h_in_group * 2 == h_out_group && + v_in_group == v_out_group) { + /* Special cases for 2h1v upsampling */ + if (do_fancy && compptr->downsampled_width > 2) + upsample->methods[ci] = h2v1_fancy_upsample; + else + upsample->methods[ci] = h2v1_upsample; + } else if (h_in_group * 2 == h_out_group && + v_in_group * 2 == v_out_group) { + /* Special cases for 2h2v upsampling */ + if (do_fancy && compptr->downsampled_width > 2) { + upsample->methods[ci] = h2v2_fancy_upsample; + upsample->pub.need_context_rows = TRUE; + } else + upsample->methods[ci] = h2v2_upsample; + } else if ((h_out_group % h_in_group) == 0 && + (v_out_group % v_in_group) == 0) { + /* Generic integral-factors upsampling method */ + upsample->methods[ci] = int_upsample; + upsample->h_expand[ci] = (UINT8) (h_out_group / h_in_group); + upsample->v_expand[ci] = (UINT8) (v_out_group / v_in_group); + } else + ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL); + if (need_buffer) { + upsample->color_buf[ci] = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) jround_up((long) cinfo->output_width, + (long) cinfo->max_h_samp_factor), + (JDIMENSION) cinfo->max_v_samp_factor); + } + } +} diff --git a/gs/jpeg/jdtrans.c b/gs/jpeg/jdtrans.c new file mode 100644 index 000000000..db620bcdf --- /dev/null +++ b/gs/jpeg/jdtrans.c @@ -0,0 +1,122 @@ +/* + * jdtrans.c + * + * Copyright (C) 1995-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains library routines for transcoding decompression, + * that is, reading raw DCT coefficient arrays from an input JPEG file. + * The routines in jdapimin.c will also be needed by a transcoder. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Forward declarations */ +LOCAL(void) transdecode_master_selection JPP((j_decompress_ptr cinfo)); + + +/* + * Read the coefficient arrays from a JPEG file. + * jpeg_read_header must be completed before calling this. + * + * The entire image is read into a set of virtual coefficient-block arrays, + * one per component. The return value is a pointer to the array of + * virtual-array descriptors. These can be manipulated directly via the + * JPEG memory manager, or handed off to jpeg_write_coefficients(). + * To release the memory occupied by the virtual arrays, call + * jpeg_finish_decompress() when done with the data. + * + * Returns NULL if suspended. This case need be checked only if + * a suspending data source is used. + */ + +GLOBAL(jvirt_barray_ptr *) +jpeg_read_coefficients (j_decompress_ptr cinfo) +{ + if (cinfo->global_state == DSTATE_READY) { + /* First call: initialize active modules */ + transdecode_master_selection(cinfo); + cinfo->global_state = DSTATE_RDCOEFS; + } else if (cinfo->global_state != DSTATE_RDCOEFS) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + /* Absorb whole file into the coef buffer */ + for (;;) { + int retcode; + /* Call progress monitor hook if present */ + if (cinfo->progress != NULL) + (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); + /* Absorb some more input */ + retcode = (*cinfo->inputctl->consume_input) (cinfo); + if (retcode == JPEG_SUSPENDED) + return NULL; + if (retcode == JPEG_REACHED_EOI) + break; + /* Advance progress counter if appropriate */ + if (cinfo->progress != NULL && + (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) { + if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) { + /* startup underestimated number of scans; ratchet up one scan */ + cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows; + } + } + } + /* Set state so that jpeg_finish_decompress does the right thing */ + cinfo->global_state = DSTATE_STOPPING; + return cinfo->coef->coef_arrays; +} + + +/* + * Master selection of decompression modules for transcoding. + * This substitutes for jdmaster.c's initialization of the full decompressor. + */ + +LOCAL(void) +transdecode_master_selection (j_decompress_ptr cinfo) +{ + /* Entropy decoding: either Huffman or arithmetic coding. */ + if (cinfo->arith_code) { + ERREXIT(cinfo, JERR_ARITH_NOTIMPL); + } else { + if (cinfo->progressive_mode) { +#ifdef D_PROGRESSIVE_SUPPORTED + jinit_phuff_decoder(cinfo); +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } else + jinit_huff_decoder(cinfo); + } + + /* Always get a full-image coefficient buffer. */ + jinit_d_coef_controller(cinfo, TRUE); + + /* We can now tell the memory manager to allocate virtual arrays. */ + (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); + + /* Initialize input side of decompressor to consume first scan. */ + (*cinfo->inputctl->start_input_pass) (cinfo); + + /* Initialize progress monitoring. */ + if (cinfo->progress != NULL) { + int nscans; + /* Estimate number of scans to set pass_limit. */ + if (cinfo->progressive_mode) { + /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */ + nscans = 2 + 3 * cinfo->num_components; + } else if (cinfo->inputctl->has_multiple_scans) { + /* For a nonprogressive multiscan file, estimate 1 scan per component. */ + nscans = cinfo->num_components; + } else { + nscans = 1; + } + cinfo->progress->pass_counter = 0L; + cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans; + cinfo->progress->completed_passes = 0; + cinfo->progress->total_passes = 1; + } +} diff --git a/gs/jpeg/jerror.c b/gs/jpeg/jerror.c new file mode 100644 index 000000000..8b89e39c1 --- /dev/null +++ b/gs/jpeg/jerror.c @@ -0,0 +1,228 @@ +/* + * jerror.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains simple error-reporting and trace-message routines. + * These are suitable for Unix-like systems and others where writing to + * stderr is the right thing to do. Many applications will want to replace + * some or all of these routines. + * + * These routines are used by both the compression and decompression code. + */ + +/* this is not a core library module, so it doesn't define JPEG_INTERNALS */ +#include "jinclude.h" +#include "jpeglib.h" +#include "jversion.h" +#include "jerror.h" + +#ifndef EXIT_FAILURE /* define exit() codes if not provided */ +#define EXIT_FAILURE 1 +#endif + + +/* + * Create the message string table. + * We do this from the master message list in jerror.h by re-reading + * jerror.h with a suitable definition for macro JMESSAGE. + * The message table is made an external symbol just in case any applications + * want to refer to it directly. + */ + +#ifdef NEED_SHORT_EXTERNAL_NAMES +#define jpeg_std_message_table jMsgTable +#endif + +#define JMESSAGE(code,string) string , + +const char * const jpeg_std_message_table[] = { +#include "jerror.h" + NULL +}; + + +/* + * Error exit handler: must not return to caller. + * + * Applications may override this if they want to get control back after + * an error. Typically one would longjmp somewhere instead of exiting. + * The setjmp buffer can be made a private field within an expanded error + * handler object. Note that the info needed to generate an error message + * is stored in the error object, so you can generate the message now or + * later, at your convenience. + * You should make sure that the JPEG object is cleaned up (with jpeg_abort + * or jpeg_destroy) at some point. + */ + +METHODDEF(void) +error_exit (j_common_ptr cinfo) +{ + /* Always display the message */ + (*cinfo->err->output_message) (cinfo); + + /* Let the memory manager delete any temp files before we die */ + jpeg_destroy(cinfo); + + exit(EXIT_FAILURE); +} + + +/* + * Actual output of an error or trace message. + * Applications may override this method to send JPEG messages somewhere + * other than stderr. + */ + +METHODDEF(void) +output_message (j_common_ptr cinfo) +{ + char buffer[JMSG_LENGTH_MAX]; + + /* Create the message */ + (*cinfo->err->format_message) (cinfo, buffer); + + /* Send it to stderr, adding a newline */ + fprintf(stderr, "%s\n", buffer); +} + + +/* + * Decide whether to emit a trace or warning message. + * msg_level is one of: + * -1: recoverable corrupt-data warning, may want to abort. + * 0: important advisory messages (always display to user). + * 1: first level of tracing detail. + * 2,3,...: successively more detailed tracing messages. + * An application might override this method if it wanted to abort on warnings + * or change the policy about which messages to display. + */ + +METHODDEF(void) +emit_message (j_common_ptr cinfo, int msg_level) +{ + struct jpeg_error_mgr * err = cinfo->err; + + if (msg_level < 0) { + /* It's a warning message. Since corrupt files may generate many warnings, + * the policy implemented here is to show only the first warning, + * unless trace_level >= 3. + */ + if (err->num_warnings == 0 || err->trace_level >= 3) + (*err->output_message) (cinfo); + /* Always count warnings in num_warnings. */ + err->num_warnings++; + } else { + /* It's a trace message. Show it if trace_level >= msg_level. */ + if (err->trace_level >= msg_level) + (*err->output_message) (cinfo); + } +} + + +/* + * Format a message string for the most recent JPEG error or message. + * The message is stored into buffer, which should be at least JMSG_LENGTH_MAX + * characters. Note that no '\n' character is added to the string. + * Few applications should need to override this method. + */ + +METHODDEF(void) +format_message (j_common_ptr cinfo, char * buffer) +{ + struct jpeg_error_mgr * err = cinfo->err; + int msg_code = err->msg_code; + const char * msgtext = NULL; + const char * msgptr; + char ch; + boolean isstring; + + /* Look up message string in proper table */ + if (msg_code > 0 && msg_code <= err->last_jpeg_message) { + msgtext = err->jpeg_message_table[msg_code]; + } else if (err->addon_message_table != NULL && + msg_code >= err->first_addon_message && + msg_code <= err->last_addon_message) { + msgtext = err->addon_message_table[msg_code - err->first_addon_message]; + } + + /* Defend against bogus message number */ + if (msgtext == NULL) { + err->msg_parm.i[0] = msg_code; + msgtext = err->jpeg_message_table[0]; + } + + /* Check for string parameter, as indicated by %s in the message text */ + isstring = FALSE; + msgptr = msgtext; + while ((ch = *msgptr++) != '\0') { + if (ch == '%') { + if (*msgptr == 's') isstring = TRUE; + break; + } + } + + /* Format the message into the passed buffer */ + if (isstring) + sprintf(buffer, msgtext, err->msg_parm.s); + else + sprintf(buffer, msgtext, + err->msg_parm.i[0], err->msg_parm.i[1], + err->msg_parm.i[2], err->msg_parm.i[3], + err->msg_parm.i[4], err->msg_parm.i[5], + err->msg_parm.i[6], err->msg_parm.i[7]); +} + + +/* + * Reset error state variables at start of a new image. + * This is called during compression startup to reset trace/error + * processing to default state, without losing any application-specific + * method pointers. An application might possibly want to override + * this method if it has additional error processing state. + */ + +METHODDEF(void) +reset_error_mgr (j_common_ptr cinfo) +{ + cinfo->err->num_warnings = 0; + /* trace_level is not reset since it is an application-supplied parameter */ + cinfo->err->msg_code = 0; /* may be useful as a flag for "no error" */ +} + + +/* + * Fill in the standard error-handling methods in a jpeg_error_mgr object. + * Typical call is: + * struct jpeg_compress_struct cinfo; + * struct jpeg_error_mgr err; + * + * cinfo.err = jpeg_std_error(&err); + * after which the application may override some of the methods. + */ + +GLOBAL(struct jpeg_error_mgr *) +jpeg_std_error (struct jpeg_error_mgr * err) +{ + err->error_exit = error_exit; + err->emit_message = emit_message; + err->output_message = output_message; + err->format_message = format_message; + err->reset_error_mgr = reset_error_mgr; + + err->trace_level = 0; /* default = no tracing */ + err->num_warnings = 0; /* no warnings emitted yet */ + err->msg_code = 0; /* may be useful as a flag for "no error" */ + + /* Initialize message table pointers */ + err->jpeg_message_table = jpeg_std_message_table; + err->last_jpeg_message = (int) JMSG_LASTMSGCODE - 1; + + err->addon_message_table = NULL; + err->first_addon_message = 0; /* for safety */ + err->last_addon_message = 0; + + return err; +} diff --git a/gs/jpeg/jerror.h b/gs/jpeg/jerror.h new file mode 100644 index 000000000..de82c8a19 --- /dev/null +++ b/gs/jpeg/jerror.h @@ -0,0 +1,277 @@ +/* + * jerror.h + * + * Copyright (C) 1994-1995, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file defines the error and message codes for the JPEG library. + * Edit this file to add new codes, or to translate the message strings to + * some other language. + * A set of error-reporting macros are defined too. Some applications using + * the JPEG library may wish to include this file to get the error codes + * and/or the macros. + */ + +/* + * To define the enum list of message codes, include this file without + * defining macro JMESSAGE. To create a message string table, include it + * again with a suitable JMESSAGE definition (see jerror.c for an example). + */ +#ifndef JMESSAGE +#ifndef JERROR_H +/* First time through, define the enum list */ +#define JMAKE_ENUM_LIST +#else +/* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */ +#define JMESSAGE(code,string) +#endif /* JERROR_H */ +#endif /* JMESSAGE */ + +#ifdef JMAKE_ENUM_LIST + +typedef enum { + +#define JMESSAGE(code,string) code , + +#endif /* JMAKE_ENUM_LIST */ + +JMESSAGE(JMSG_NOMESSAGE, "Bogus message code %d") /* Must be first entry! */ + +/* For maintenance convenience, list is alphabetical by message code name */ +JMESSAGE(JERR_ARITH_NOTIMPL, + "Sorry, there are legal restrictions on arithmetic coding") +JMESSAGE(JERR_BAD_ALIGN_TYPE, "ALIGN_TYPE is wrong, please fix") +JMESSAGE(JERR_BAD_ALLOC_CHUNK, "MAX_ALLOC_CHUNK is wrong, please fix") +JMESSAGE(JERR_BAD_BUFFER_MODE, "Bogus buffer control mode") +JMESSAGE(JERR_BAD_COMPONENT_ID, "Invalid component ID %d in SOS") +JMESSAGE(JERR_BAD_DCTSIZE, "IDCT output block size %d not supported") +JMESSAGE(JERR_BAD_IN_COLORSPACE, "Bogus input colorspace") +JMESSAGE(JERR_BAD_J_COLORSPACE, "Bogus JPEG colorspace") +JMESSAGE(JERR_BAD_LENGTH, "Bogus marker length") +JMESSAGE(JERR_BAD_LIB_VERSION, + "Wrong JPEG library version: library is %d, caller expects %d") +JMESSAGE(JERR_BAD_MCU_SIZE, "Sampling factors too large for interleaved scan") +JMESSAGE(JERR_BAD_POOL_ID, "Invalid memory pool code %d") +JMESSAGE(JERR_BAD_PRECISION, "Unsupported JPEG data precision %d") +JMESSAGE(JERR_BAD_PROGRESSION, + "Invalid progressive parameters Ss=%d Se=%d Ah=%d Al=%d") +JMESSAGE(JERR_BAD_PROG_SCRIPT, + "Invalid progressive parameters at scan script entry %d") +JMESSAGE(JERR_BAD_SAMPLING, "Bogus sampling factors") +JMESSAGE(JERR_BAD_SCAN_SCRIPT, "Invalid scan script at entry %d") +JMESSAGE(JERR_BAD_STATE, "Improper call to JPEG library in state %d") +JMESSAGE(JERR_BAD_STRUCT_SIZE, + "JPEG parameter struct mismatch: library thinks size is %u, caller expects %u") +JMESSAGE(JERR_BAD_VIRTUAL_ACCESS, "Bogus virtual array access") +JMESSAGE(JERR_BUFFER_SIZE, "Buffer passed to JPEG library is too small") +JMESSAGE(JERR_CANT_SUSPEND, "Suspension not allowed here") +JMESSAGE(JERR_CCIR601_NOTIMPL, "CCIR601 sampling not implemented yet") +JMESSAGE(JERR_COMPONENT_COUNT, "Too many color components: %d, max %d") +JMESSAGE(JERR_CONVERSION_NOTIMPL, "Unsupported color conversion request") +JMESSAGE(JERR_DAC_INDEX, "Bogus DAC index %d") +JMESSAGE(JERR_DAC_VALUE, "Bogus DAC value 0x%x") +JMESSAGE(JERR_DHT_COUNTS, "Bogus DHT counts") +JMESSAGE(JERR_DHT_INDEX, "Bogus DHT index %d") +JMESSAGE(JERR_DQT_INDEX, "Bogus DQT index %d") +JMESSAGE(JERR_EMPTY_IMAGE, "Empty JPEG image (DNL not supported)") +JMESSAGE(JERR_EMS_READ, "Read from EMS failed") +JMESSAGE(JERR_EMS_WRITE, "Write to EMS failed") +JMESSAGE(JERR_EOI_EXPECTED, "Didn't expect more than one scan") +JMESSAGE(JERR_FILE_READ, "Input file read error") +JMESSAGE(JERR_FILE_WRITE, "Output file write error --- out of disk space?") +JMESSAGE(JERR_FRACT_SAMPLE_NOTIMPL, "Fractional sampling not implemented yet") +JMESSAGE(JERR_HUFF_CLEN_OVERFLOW, "Huffman code size table overflow") +JMESSAGE(JERR_HUFF_MISSING_CODE, "Missing Huffman code table entry") +JMESSAGE(JERR_IMAGE_TOO_BIG, "Maximum supported image dimension is %u pixels") +JMESSAGE(JERR_INPUT_EMPTY, "Empty input file") +JMESSAGE(JERR_INPUT_EOF, "Premature end of input file") +JMESSAGE(JERR_MISMATCHED_QUANT_TABLE, + "Cannot transcode due to multiple use of quantization table %d") +JMESSAGE(JERR_MISSING_DATA, "Scan script does not transmit all data") +JMESSAGE(JERR_MODE_CHANGE, "Invalid color quantization mode change") +JMESSAGE(JERR_NOTIMPL, "Not implemented yet") +JMESSAGE(JERR_NOT_COMPILED, "Requested feature was omitted at compile time") +JMESSAGE(JERR_NO_BACKING_STORE, "Backing store not supported") +JMESSAGE(JERR_NO_HUFF_TABLE, "Huffman table 0x%02x was not defined") +JMESSAGE(JERR_NO_IMAGE, "JPEG datastream contains no image") +JMESSAGE(JERR_NO_QUANT_TABLE, "Quantization table 0x%02x was not defined") +JMESSAGE(JERR_NO_SOI, "Not a JPEG file: starts with 0x%02x 0x%02x") +JMESSAGE(JERR_OUT_OF_MEMORY, "Insufficient memory (case %d)") +JMESSAGE(JERR_QUANT_COMPONENTS, + "Cannot quantize more than %d color components") +JMESSAGE(JERR_QUANT_FEW_COLORS, "Cannot quantize to fewer than %d colors") +JMESSAGE(JERR_QUANT_MANY_COLORS, "Cannot quantize to more than %d colors") +JMESSAGE(JERR_SOF_DUPLICATE, "Invalid JPEG file structure: two SOF markers") +JMESSAGE(JERR_SOF_NO_SOS, "Invalid JPEG file structure: missing SOS marker") +JMESSAGE(JERR_SOF_UNSUPPORTED, "Unsupported JPEG process: SOF type 0x%02x") +JMESSAGE(JERR_SOI_DUPLICATE, "Invalid JPEG file structure: two SOI markers") +JMESSAGE(JERR_SOS_NO_SOF, "Invalid JPEG file structure: SOS before SOF") +JMESSAGE(JERR_TFILE_CREATE, "Failed to create temporary file %s") +JMESSAGE(JERR_TFILE_READ, "Read failed on temporary file") +JMESSAGE(JERR_TFILE_SEEK, "Seek failed on temporary file") +JMESSAGE(JERR_TFILE_WRITE, + "Write failed on temporary file --- out of disk space?") +JMESSAGE(JERR_TOO_LITTLE_DATA, "Application transferred too few scanlines") +JMESSAGE(JERR_UNKNOWN_MARKER, "Unsupported marker type 0x%02x") +JMESSAGE(JERR_VIRTUAL_BUG, "Virtual array controller messed up") +JMESSAGE(JERR_WIDTH_OVERFLOW, "Image too wide for this implementation") +JMESSAGE(JERR_XMS_READ, "Read from XMS failed") +JMESSAGE(JERR_XMS_WRITE, "Write to XMS failed") +JMESSAGE(JMSG_COPYRIGHT, JCOPYRIGHT) +JMESSAGE(JMSG_VERSION, JVERSION) +JMESSAGE(JTRC_16BIT_TABLES, + "Caution: quantization tables are too coarse for baseline JPEG") +JMESSAGE(JTRC_ADOBE, + "Adobe APP14 marker: version %d, flags 0x%04x 0x%04x, transform %d") +JMESSAGE(JTRC_APP0, "Unknown APP0 marker (not JFIF), length %u") +JMESSAGE(JTRC_APP14, "Unknown APP14 marker (not Adobe), length %u") +JMESSAGE(JTRC_DAC, "Define Arithmetic Table 0x%02x: 0x%02x") +JMESSAGE(JTRC_DHT, "Define Huffman Table 0x%02x") +JMESSAGE(JTRC_DQT, "Define Quantization Table %d precision %d") +JMESSAGE(JTRC_DRI, "Define Restart Interval %u") +JMESSAGE(JTRC_EMS_CLOSE, "Freed EMS handle %u") +JMESSAGE(JTRC_EMS_OPEN, "Obtained EMS handle %u") +JMESSAGE(JTRC_EOI, "End Of Image") +JMESSAGE(JTRC_HUFFBITS, " %3d %3d %3d %3d %3d %3d %3d %3d") +JMESSAGE(JTRC_JFIF, "JFIF APP0 marker, density %dx%d %d") +JMESSAGE(JTRC_JFIF_BADTHUMBNAILSIZE, + "Warning: thumbnail image size does not match data length %u") +JMESSAGE(JTRC_JFIF_MINOR, "Unknown JFIF minor revision number %d.%02d") +JMESSAGE(JTRC_JFIF_THUMBNAIL, " with %d x %d thumbnail image") +JMESSAGE(JTRC_MISC_MARKER, "Skipping marker 0x%02x, length %u") +JMESSAGE(JTRC_PARMLESS_MARKER, "Unexpected marker 0x%02x") +JMESSAGE(JTRC_QUANTVALS, " %4u %4u %4u %4u %4u %4u %4u %4u") +JMESSAGE(JTRC_QUANT_3_NCOLORS, "Quantizing to %d = %d*%d*%d colors") +JMESSAGE(JTRC_QUANT_NCOLORS, "Quantizing to %d colors") +JMESSAGE(JTRC_QUANT_SELECTED, "Selected %d colors for quantization") +JMESSAGE(JTRC_RECOVERY_ACTION, "At marker 0x%02x, recovery action %d") +JMESSAGE(JTRC_RST, "RST%d") +JMESSAGE(JTRC_SMOOTH_NOTIMPL, + "Smoothing not supported with nonstandard sampling ratios") +JMESSAGE(JTRC_SOF, "Start Of Frame 0x%02x: width=%u, height=%u, components=%d") +JMESSAGE(JTRC_SOF_COMPONENT, " Component %d: %dhx%dv q=%d") +JMESSAGE(JTRC_SOI, "Start of Image") +JMESSAGE(JTRC_SOS, "Start Of Scan: %d components") +JMESSAGE(JTRC_SOS_COMPONENT, " Component %d: dc=%d ac=%d") +JMESSAGE(JTRC_SOS_PARAMS, " Ss=%d, Se=%d, Ah=%d, Al=%d") +JMESSAGE(JTRC_TFILE_CLOSE, "Closed temporary file %s") +JMESSAGE(JTRC_TFILE_OPEN, "Opened temporary file %s") +JMESSAGE(JTRC_UNKNOWN_IDS, + "Unrecognized component IDs %d %d %d, assuming YCbCr") +JMESSAGE(JTRC_XMS_CLOSE, "Freed XMS handle %u") +JMESSAGE(JTRC_XMS_OPEN, "Obtained XMS handle %u") +JMESSAGE(JWRN_ADOBE_XFORM, "Unknown Adobe color transform code %d") +JMESSAGE(JWRN_BOGUS_PROGRESSION, + "Inconsistent progression sequence for component %d coefficient %d") +JMESSAGE(JWRN_EXTRANEOUS_DATA, + "Corrupt JPEG data: %u extraneous bytes before marker 0x%02x") +JMESSAGE(JWRN_HIT_MARKER, "Corrupt JPEG data: premature end of data segment") +JMESSAGE(JWRN_HUFF_BAD_CODE, "Corrupt JPEG data: bad Huffman code") +JMESSAGE(JWRN_JFIF_MAJOR, "Warning: unknown JFIF revision number %d.%02d") +JMESSAGE(JWRN_JPEG_EOF, "Premature end of JPEG file") +JMESSAGE(JWRN_MUST_RESYNC, + "Corrupt JPEG data: found marker 0x%02x instead of RST%d") +JMESSAGE(JWRN_NOT_SEQUENTIAL, "Invalid SOS parameters for sequential JPEG") +JMESSAGE(JWRN_TOO_MUCH_DATA, "Application transferred too many scanlines") + +#ifdef JMAKE_ENUM_LIST + + JMSG_LASTMSGCODE +} J_MESSAGE_CODE; + +#undef JMAKE_ENUM_LIST +#endif /* JMAKE_ENUM_LIST */ + +/* Zap JMESSAGE macro so that future re-inclusions do nothing by default */ +#undef JMESSAGE + + +#ifndef JERROR_H +#define JERROR_H + +/* Macros to simplify using the error and trace message stuff */ +/* The first parameter is either type of cinfo pointer */ + +/* Fatal errors (print message and exit) */ +#define ERREXIT(cinfo,code) \ + ((cinfo)->err->msg_code = (code), \ + (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) +#define ERREXIT1(cinfo,code,p1) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) +#define ERREXIT2(cinfo,code,p1,p2) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (cinfo)->err->msg_parm.i[1] = (p2), \ + (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) +#define ERREXIT3(cinfo,code,p1,p2,p3) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (cinfo)->err->msg_parm.i[1] = (p2), \ + (cinfo)->err->msg_parm.i[2] = (p3), \ + (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) +#define ERREXIT4(cinfo,code,p1,p2,p3,p4) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (cinfo)->err->msg_parm.i[1] = (p2), \ + (cinfo)->err->msg_parm.i[2] = (p3), \ + (cinfo)->err->msg_parm.i[3] = (p4), \ + (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) +#define ERREXITS(cinfo,code,str) \ + ((cinfo)->err->msg_code = (code), \ + strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \ + (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) + +#define MAKESTMT(stuff) do { stuff } while (0) + +/* Nonfatal errors (we can keep going, but the data is probably corrupt) */ +#define WARNMS(cinfo,code) \ + ((cinfo)->err->msg_code = (code), \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) +#define WARNMS1(cinfo,code,p1) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) +#define WARNMS2(cinfo,code,p1,p2) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (cinfo)->err->msg_parm.i[1] = (p2), \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) + +/* Informational/debugging messages */ +#define TRACEMS(cinfo,lvl,code) \ + ((cinfo)->err->msg_code = (code), \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) +#define TRACEMS1(cinfo,lvl,code,p1) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) +#define TRACEMS2(cinfo,lvl,code,p1,p2) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (cinfo)->err->msg_parm.i[1] = (p2), \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) +#define TRACEMS3(cinfo,lvl,code,p1,p2,p3) \ + MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ + _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); \ + (cinfo)->err->msg_code = (code); \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) +#define TRACEMS4(cinfo,lvl,code,p1,p2,p3,p4) \ + MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ + _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ + (cinfo)->err->msg_code = (code); \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) +#define TRACEMS8(cinfo,lvl,code,p1,p2,p3,p4,p5,p6,p7,p8) \ + MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ + _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ + _mp[4] = (p5); _mp[5] = (p6); _mp[6] = (p7); _mp[7] = (p8); \ + (cinfo)->err->msg_code = (code); \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) +#define TRACEMSS(cinfo,lvl,code,str) \ + ((cinfo)->err->msg_code = (code), \ + strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) + +#endif /* JERROR_H */ diff --git a/gs/jpeg/jfdctflt.c b/gs/jpeg/jfdctflt.c new file mode 100644 index 000000000..79d7a0078 --- /dev/null +++ b/gs/jpeg/jfdctflt.c @@ -0,0 +1,168 @@ +/* + * jfdctflt.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a floating-point implementation of the + * forward DCT (Discrete Cosine Transform). + * + * This implementation should be more accurate than either of the integer + * DCT implementations. However, it may not give the same results on all + * machines because of differences in roundoff behavior. Speed will depend + * on the hardware's floating point capacity. + * + * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT + * on each column. Direct algorithms are also available, but they are + * much more complex and seem not to be any faster when reduced to code. + * + * This implementation is based on Arai, Agui, and Nakajima's algorithm for + * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in + * Japanese, but the algorithm is described in the Pennebaker & Mitchell + * JPEG textbook (see REFERENCES section in file README). The following code + * is based directly on figure 4-8 in P&M. + * While an 8-point DCT cannot be done in less than 11 multiplies, it is + * possible to arrange the computation so that many of the multiplies are + * simple scalings of the final outputs. These multiplies can then be + * folded into the multiplications or divisions by the JPEG quantization + * table entries. The AA&N method leaves only 5 multiplies and 29 adds + * to be done in the DCT itself. + * The primary disadvantage of this method is that with a fixed-point + * implementation, accuracy is lost due to imprecise representation of the + * scaled quantization values. However, that problem does not arise if + * we use floating point arithmetic. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdct.h" /* Private declarations for DCT subsystem */ + +#ifdef DCT_FLOAT_SUPPORTED + + +/* + * This module is specialized to the case DCTSIZE = 8. + */ + +#if DCTSIZE != 8 + Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ +#endif + + +/* + * Perform the forward DCT on one block of samples. + */ + +GLOBAL(void) +jpeg_fdct_float (FAST_FLOAT * data) +{ + FAST_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + FAST_FLOAT tmp10, tmp11, tmp12, tmp13; + FAST_FLOAT z1, z2, z3, z4, z5, z11, z13; + FAST_FLOAT *dataptr; + int ctr; + + /* Pass 1: process rows. */ + + dataptr = data; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + tmp0 = dataptr[0] + dataptr[7]; + tmp7 = dataptr[0] - dataptr[7]; + tmp1 = dataptr[1] + dataptr[6]; + tmp6 = dataptr[1] - dataptr[6]; + tmp2 = dataptr[2] + dataptr[5]; + tmp5 = dataptr[2] - dataptr[5]; + tmp3 = dataptr[3] + dataptr[4]; + tmp4 = dataptr[3] - dataptr[4]; + + /* Even part */ + + tmp10 = tmp0 + tmp3; /* phase 2 */ + tmp13 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp12 = tmp1 - tmp2; + + dataptr[0] = tmp10 + tmp11; /* phase 3 */ + dataptr[4] = tmp10 - tmp11; + + z1 = (tmp12 + tmp13) * ((FAST_FLOAT) 0.707106781); /* c4 */ + dataptr[2] = tmp13 + z1; /* phase 5 */ + dataptr[6] = tmp13 - z1; + + /* Odd part */ + + tmp10 = tmp4 + tmp5; /* phase 2 */ + tmp11 = tmp5 + tmp6; + tmp12 = tmp6 + tmp7; + + /* The rotator is modified from fig 4-8 to avoid extra negations. */ + z5 = (tmp10 - tmp12) * ((FAST_FLOAT) 0.382683433); /* c6 */ + z2 = ((FAST_FLOAT) 0.541196100) * tmp10 + z5; /* c2-c6 */ + z4 = ((FAST_FLOAT) 1.306562965) * tmp12 + z5; /* c2+c6 */ + z3 = tmp11 * ((FAST_FLOAT) 0.707106781); /* c4 */ + + z11 = tmp7 + z3; /* phase 5 */ + z13 = tmp7 - z3; + + dataptr[5] = z13 + z2; /* phase 6 */ + dataptr[3] = z13 - z2; + dataptr[1] = z11 + z4; + dataptr[7] = z11 - z4; + + dataptr += DCTSIZE; /* advance pointer to next row */ + } + + /* Pass 2: process columns. */ + + dataptr = data; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7]; + tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7]; + tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6]; + tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6]; + tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5]; + tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5]; + tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4]; + tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4]; + + /* Even part */ + + tmp10 = tmp0 + tmp3; /* phase 2 */ + tmp13 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp12 = tmp1 - tmp2; + + dataptr[DCTSIZE*0] = tmp10 + tmp11; /* phase 3 */ + dataptr[DCTSIZE*4] = tmp10 - tmp11; + + z1 = (tmp12 + tmp13) * ((FAST_FLOAT) 0.707106781); /* c4 */ + dataptr[DCTSIZE*2] = tmp13 + z1; /* phase 5 */ + dataptr[DCTSIZE*6] = tmp13 - z1; + + /* Odd part */ + + tmp10 = tmp4 + tmp5; /* phase 2 */ + tmp11 = tmp5 + tmp6; + tmp12 = tmp6 + tmp7; + + /* The rotator is modified from fig 4-8 to avoid extra negations. */ + z5 = (tmp10 - tmp12) * ((FAST_FLOAT) 0.382683433); /* c6 */ + z2 = ((FAST_FLOAT) 0.541196100) * tmp10 + z5; /* c2-c6 */ + z4 = ((FAST_FLOAT) 1.306562965) * tmp12 + z5; /* c2+c6 */ + z3 = tmp11 * ((FAST_FLOAT) 0.707106781); /* c4 */ + + z11 = tmp7 + z3; /* phase 5 */ + z13 = tmp7 - z3; + + dataptr[DCTSIZE*5] = z13 + z2; /* phase 6 */ + dataptr[DCTSIZE*3] = z13 - z2; + dataptr[DCTSIZE*1] = z11 + z4; + dataptr[DCTSIZE*7] = z11 - z4; + + dataptr++; /* advance pointer to next column */ + } +} + +#endif /* DCT_FLOAT_SUPPORTED */ diff --git a/gs/jpeg/jfdctfst.c b/gs/jpeg/jfdctfst.c new file mode 100644 index 000000000..ccb378a3b --- /dev/null +++ b/gs/jpeg/jfdctfst.c @@ -0,0 +1,224 @@ +/* + * jfdctfst.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a fast, not so accurate integer implementation of the + * forward DCT (Discrete Cosine Transform). + * + * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT + * on each column. Direct algorithms are also available, but they are + * much more complex and seem not to be any faster when reduced to code. + * + * This implementation is based on Arai, Agui, and Nakajima's algorithm for + * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in + * Japanese, but the algorithm is described in the Pennebaker & Mitchell + * JPEG textbook (see REFERENCES section in file README). The following code + * is based directly on figure 4-8 in P&M. + * While an 8-point DCT cannot be done in less than 11 multiplies, it is + * possible to arrange the computation so that many of the multiplies are + * simple scalings of the final outputs. These multiplies can then be + * folded into the multiplications or divisions by the JPEG quantization + * table entries. The AA&N method leaves only 5 multiplies and 29 adds + * to be done in the DCT itself. + * The primary disadvantage of this method is that with fixed-point math, + * accuracy is lost due to imprecise representation of the scaled + * quantization values. The smaller the quantization table entry, the less + * precise the scaled value, so this implementation does worse with high- + * quality-setting files than with low-quality ones. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdct.h" /* Private declarations for DCT subsystem */ + +#ifdef DCT_IFAST_SUPPORTED + + +/* + * This module is specialized to the case DCTSIZE = 8. + */ + +#if DCTSIZE != 8 + Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ +#endif + + +/* Scaling decisions are generally the same as in the LL&M algorithm; + * see jfdctint.c for more details. However, we choose to descale + * (right shift) multiplication products as soon as they are formed, + * rather than carrying additional fractional bits into subsequent additions. + * This compromises accuracy slightly, but it lets us save a few shifts. + * More importantly, 16-bit arithmetic is then adequate (for 8-bit samples) + * everywhere except in the multiplications proper; this saves a good deal + * of work on 16-bit-int machines. + * + * Again to save a few shifts, the intermediate results between pass 1 and + * pass 2 are not upscaled, but are represented only to integral precision. + * + * A final compromise is to represent the multiplicative constants to only + * 8 fractional bits, rather than 13. This saves some shifting work on some + * machines, and may also reduce the cost of multiplication (since there + * are fewer one-bits in the constants). + */ + +#define CONST_BITS 8 + + +/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus + * causing a lot of useless floating-point operations at run time. + * To get around this we use the following pre-calculated constants. + * If you change CONST_BITS you may want to add appropriate values. + * (With a reasonable C compiler, you can just rely on the FIX() macro...) + */ + +#if CONST_BITS == 8 +#define FIX_0_382683433 ((INT32) 98) /* FIX(0.382683433) */ +#define FIX_0_541196100 ((INT32) 139) /* FIX(0.541196100) */ +#define FIX_0_707106781 ((INT32) 181) /* FIX(0.707106781) */ +#define FIX_1_306562965 ((INT32) 334) /* FIX(1.306562965) */ +#else +#define FIX_0_382683433 FIX(0.382683433) +#define FIX_0_541196100 FIX(0.541196100) +#define FIX_0_707106781 FIX(0.707106781) +#define FIX_1_306562965 FIX(1.306562965) +#endif + + +/* We can gain a little more speed, with a further compromise in accuracy, + * by omitting the addition in a descaling shift. This yields an incorrectly + * rounded result half the time... + */ + +#ifndef USE_ACCURATE_ROUNDING +#undef DESCALE +#define DESCALE(x,n) RIGHT_SHIFT(x, n) +#endif + + +/* Multiply a DCTELEM variable by an INT32 constant, and immediately + * descale to yield a DCTELEM result. + */ + +#define MULTIPLY(var,const) ((DCTELEM) DESCALE((var) * (const), CONST_BITS)) + + +/* + * Perform the forward DCT on one block of samples. + */ + +GLOBAL(void) +jpeg_fdct_ifast (DCTELEM * data) +{ + DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + DCTELEM tmp10, tmp11, tmp12, tmp13; + DCTELEM z1, z2, z3, z4, z5, z11, z13; + DCTELEM *dataptr; + int ctr; + SHIFT_TEMPS + + /* Pass 1: process rows. */ + + dataptr = data; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + tmp0 = dataptr[0] + dataptr[7]; + tmp7 = dataptr[0] - dataptr[7]; + tmp1 = dataptr[1] + dataptr[6]; + tmp6 = dataptr[1] - dataptr[6]; + tmp2 = dataptr[2] + dataptr[5]; + tmp5 = dataptr[2] - dataptr[5]; + tmp3 = dataptr[3] + dataptr[4]; + tmp4 = dataptr[3] - dataptr[4]; + + /* Even part */ + + tmp10 = tmp0 + tmp3; /* phase 2 */ + tmp13 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp12 = tmp1 - tmp2; + + dataptr[0] = tmp10 + tmp11; /* phase 3 */ + dataptr[4] = tmp10 - tmp11; + + z1 = MULTIPLY(tmp12 + tmp13, FIX_0_707106781); /* c4 */ + dataptr[2] = tmp13 + z1; /* phase 5 */ + dataptr[6] = tmp13 - z1; + + /* Odd part */ + + tmp10 = tmp4 + tmp5; /* phase 2 */ + tmp11 = tmp5 + tmp6; + tmp12 = tmp6 + tmp7; + + /* The rotator is modified from fig 4-8 to avoid extra negations. */ + z5 = MULTIPLY(tmp10 - tmp12, FIX_0_382683433); /* c6 */ + z2 = MULTIPLY(tmp10, FIX_0_541196100) + z5; /* c2-c6 */ + z4 = MULTIPLY(tmp12, FIX_1_306562965) + z5; /* c2+c6 */ + z3 = MULTIPLY(tmp11, FIX_0_707106781); /* c4 */ + + z11 = tmp7 + z3; /* phase 5 */ + z13 = tmp7 - z3; + + dataptr[5] = z13 + z2; /* phase 6 */ + dataptr[3] = z13 - z2; + dataptr[1] = z11 + z4; + dataptr[7] = z11 - z4; + + dataptr += DCTSIZE; /* advance pointer to next row */ + } + + /* Pass 2: process columns. */ + + dataptr = data; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7]; + tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7]; + tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6]; + tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6]; + tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5]; + tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5]; + tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4]; + tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4]; + + /* Even part */ + + tmp10 = tmp0 + tmp3; /* phase 2 */ + tmp13 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp12 = tmp1 - tmp2; + + dataptr[DCTSIZE*0] = tmp10 + tmp11; /* phase 3 */ + dataptr[DCTSIZE*4] = tmp10 - tmp11; + + z1 = MULTIPLY(tmp12 + tmp13, FIX_0_707106781); /* c4 */ + dataptr[DCTSIZE*2] = tmp13 + z1; /* phase 5 */ + dataptr[DCTSIZE*6] = tmp13 - z1; + + /* Odd part */ + + tmp10 = tmp4 + tmp5; /* phase 2 */ + tmp11 = tmp5 + tmp6; + tmp12 = tmp6 + tmp7; + + /* The rotator is modified from fig 4-8 to avoid extra negations. */ + z5 = MULTIPLY(tmp10 - tmp12, FIX_0_382683433); /* c6 */ + z2 = MULTIPLY(tmp10, FIX_0_541196100) + z5; /* c2-c6 */ + z4 = MULTIPLY(tmp12, FIX_1_306562965) + z5; /* c2+c6 */ + z3 = MULTIPLY(tmp11, FIX_0_707106781); /* c4 */ + + z11 = tmp7 + z3; /* phase 5 */ + z13 = tmp7 - z3; + + dataptr[DCTSIZE*5] = z13 + z2; /* phase 6 */ + dataptr[DCTSIZE*3] = z13 - z2; + dataptr[DCTSIZE*1] = z11 + z4; + dataptr[DCTSIZE*7] = z11 - z4; + + dataptr++; /* advance pointer to next column */ + } +} + +#endif /* DCT_IFAST_SUPPORTED */ diff --git a/gs/jpeg/jfdctint.c b/gs/jpeg/jfdctint.c new file mode 100644 index 000000000..0a78b64ae --- /dev/null +++ b/gs/jpeg/jfdctint.c @@ -0,0 +1,283 @@ +/* + * jfdctint.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a slow-but-accurate integer implementation of the + * forward DCT (Discrete Cosine Transform). + * + * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT + * on each column. Direct algorithms are also available, but they are + * much more complex and seem not to be any faster when reduced to code. + * + * This implementation is based on an algorithm described in + * C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT + * Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics, + * Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991. + * The primary algorithm described there uses 11 multiplies and 29 adds. + * We use their alternate method with 12 multiplies and 32 adds. + * The advantage of this method is that no data path contains more than one + * multiplication; this allows a very simple and accurate implementation in + * scaled fixed-point arithmetic, with a minimal number of shifts. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdct.h" /* Private declarations for DCT subsystem */ + +#ifdef DCT_ISLOW_SUPPORTED + + +/* + * This module is specialized to the case DCTSIZE = 8. + */ + +#if DCTSIZE != 8 + Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ +#endif + + +/* + * The poop on this scaling stuff is as follows: + * + * Each 1-D DCT step produces outputs which are a factor of sqrt(N) + * larger than the true DCT outputs. The final outputs are therefore + * a factor of N larger than desired; since N=8 this can be cured by + * a simple right shift at the end of the algorithm. The advantage of + * this arrangement is that we save two multiplications per 1-D DCT, + * because the y0 and y4 outputs need not be divided by sqrt(N). + * In the IJG code, this factor of 8 is removed by the quantization step + * (in jcdctmgr.c), NOT in this module. + * + * We have to do addition and subtraction of the integer inputs, which + * is no problem, and multiplication by fractional constants, which is + * a problem to do in integer arithmetic. We multiply all the constants + * by CONST_SCALE and convert them to integer constants (thus retaining + * CONST_BITS bits of precision in the constants). After doing a + * multiplication we have to divide the product by CONST_SCALE, with proper + * rounding, to produce the correct output. This division can be done + * cheaply as a right shift of CONST_BITS bits. We postpone shifting + * as long as possible so that partial sums can be added together with + * full fractional precision. + * + * The outputs of the first pass are scaled up by PASS1_BITS bits so that + * they are represented to better-than-integral precision. These outputs + * require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word + * with the recommended scaling. (For 12-bit sample data, the intermediate + * array is INT32 anyway.) + * + * To avoid overflow of the 32-bit intermediate results in pass 2, we must + * have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis + * shows that the values given below are the most effective. + */ + +#if BITS_IN_JSAMPLE == 8 +#define CONST_BITS 13 +#define PASS1_BITS 2 +#else +#define CONST_BITS 13 +#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ +#endif + +/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus + * causing a lot of useless floating-point operations at run time. + * To get around this we use the following pre-calculated constants. + * If you change CONST_BITS you may want to add appropriate values. + * (With a reasonable C compiler, you can just rely on the FIX() macro...) + */ + +#if CONST_BITS == 13 +#define FIX_0_298631336 ((INT32) 2446) /* FIX(0.298631336) */ +#define FIX_0_390180644 ((INT32) 3196) /* FIX(0.390180644) */ +#define FIX_0_541196100 ((INT32) 4433) /* FIX(0.541196100) */ +#define FIX_0_765366865 ((INT32) 6270) /* FIX(0.765366865) */ +#define FIX_0_899976223 ((INT32) 7373) /* FIX(0.899976223) */ +#define FIX_1_175875602 ((INT32) 9633) /* FIX(1.175875602) */ +#define FIX_1_501321110 ((INT32) 12299) /* FIX(1.501321110) */ +#define FIX_1_847759065 ((INT32) 15137) /* FIX(1.847759065) */ +#define FIX_1_961570560 ((INT32) 16069) /* FIX(1.961570560) */ +#define FIX_2_053119869 ((INT32) 16819) /* FIX(2.053119869) */ +#define FIX_2_562915447 ((INT32) 20995) /* FIX(2.562915447) */ +#define FIX_3_072711026 ((INT32) 25172) /* FIX(3.072711026) */ +#else +#define FIX_0_298631336 FIX(0.298631336) +#define FIX_0_390180644 FIX(0.390180644) +#define FIX_0_541196100 FIX(0.541196100) +#define FIX_0_765366865 FIX(0.765366865) +#define FIX_0_899976223 FIX(0.899976223) +#define FIX_1_175875602 FIX(1.175875602) +#define FIX_1_501321110 FIX(1.501321110) +#define FIX_1_847759065 FIX(1.847759065) +#define FIX_1_961570560 FIX(1.961570560) +#define FIX_2_053119869 FIX(2.053119869) +#define FIX_2_562915447 FIX(2.562915447) +#define FIX_3_072711026 FIX(3.072711026) +#endif + + +/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. + * For 8-bit samples with the recommended scaling, all the variable + * and constant values involved are no more than 16 bits wide, so a + * 16x16->32 bit multiply can be used instead of a full 32x32 multiply. + * For 12-bit samples, a full 32-bit multiplication will be needed. + */ + +#if BITS_IN_JSAMPLE == 8 +#define MULTIPLY(var,const) MULTIPLY16C16(var,const) +#else +#define MULTIPLY(var,const) ((var) * (const)) +#endif + + +/* + * Perform the forward DCT on one block of samples. + */ + +GLOBAL(void) +jpeg_fdct_islow (DCTELEM * data) +{ + INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + INT32 tmp10, tmp11, tmp12, tmp13; + INT32 z1, z2, z3, z4, z5; + DCTELEM *dataptr; + int ctr; + SHIFT_TEMPS + + /* Pass 1: process rows. */ + /* Note results are scaled up by sqrt(8) compared to a true DCT; */ + /* furthermore, we scale the results by 2**PASS1_BITS. */ + + dataptr = data; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + tmp0 = dataptr[0] + dataptr[7]; + tmp7 = dataptr[0] - dataptr[7]; + tmp1 = dataptr[1] + dataptr[6]; + tmp6 = dataptr[1] - dataptr[6]; + tmp2 = dataptr[2] + dataptr[5]; + tmp5 = dataptr[2] - dataptr[5]; + tmp3 = dataptr[3] + dataptr[4]; + tmp4 = dataptr[3] - dataptr[4]; + + /* Even part per LL&M figure 1 --- note that published figure is faulty; + * rotator "sqrt(2)*c1" should be "sqrt(2)*c6". + */ + + tmp10 = tmp0 + tmp3; + tmp13 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp12 = tmp1 - tmp2; + + dataptr[0] = (DCTELEM) ((tmp10 + tmp11) << PASS1_BITS); + dataptr[4] = (DCTELEM) ((tmp10 - tmp11) << PASS1_BITS); + + z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); + dataptr[2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865), + CONST_BITS-PASS1_BITS); + dataptr[6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065), + CONST_BITS-PASS1_BITS); + + /* Odd part per figure 8 --- note paper omits factor of sqrt(2). + * cK represents cos(K*pi/16). + * i0..i3 in the paper are tmp4..tmp7 here. + */ + + z1 = tmp4 + tmp7; + z2 = tmp5 + tmp6; + z3 = tmp4 + tmp6; + z4 = tmp5 + tmp7; + z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ + + tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ + tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ + tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ + tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ + z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ + z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ + z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ + z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ + + z3 += z5; + z4 += z5; + + dataptr[7] = (DCTELEM) DESCALE(tmp4 + z1 + z3, CONST_BITS-PASS1_BITS); + dataptr[5] = (DCTELEM) DESCALE(tmp5 + z2 + z4, CONST_BITS-PASS1_BITS); + dataptr[3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, CONST_BITS-PASS1_BITS); + dataptr[1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, CONST_BITS-PASS1_BITS); + + dataptr += DCTSIZE; /* advance pointer to next row */ + } + + /* Pass 2: process columns. + * We remove the PASS1_BITS scaling, but leave the results scaled up + * by an overall factor of 8. + */ + + dataptr = data; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7]; + tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7]; + tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6]; + tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6]; + tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5]; + tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5]; + tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4]; + tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4]; + + /* Even part per LL&M figure 1 --- note that published figure is faulty; + * rotator "sqrt(2)*c1" should be "sqrt(2)*c6". + */ + + tmp10 = tmp0 + tmp3; + tmp13 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp12 = tmp1 - tmp2; + + dataptr[DCTSIZE*0] = (DCTELEM) DESCALE(tmp10 + tmp11, PASS1_BITS); + dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(tmp10 - tmp11, PASS1_BITS); + + z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); + dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865), + CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065), + CONST_BITS+PASS1_BITS); + + /* Odd part per figure 8 --- note paper omits factor of sqrt(2). + * cK represents cos(K*pi/16). + * i0..i3 in the paper are tmp4..tmp7 here. + */ + + z1 = tmp4 + tmp7; + z2 = tmp5 + tmp6; + z3 = tmp4 + tmp6; + z4 = tmp5 + tmp7; + z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ + + tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ + tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ + tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ + tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ + z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ + z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ + z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ + z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ + + z3 += z5; + z4 += z5; + + dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp4 + z1 + z3, + CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp5 + z2 + z4, + CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, + CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, + CONST_BITS+PASS1_BITS); + + dataptr++; /* advance pointer to next column */ + } +} + +#endif /* DCT_ISLOW_SUPPORTED */ diff --git a/gs/jpeg/jidctflt.c b/gs/jpeg/jidctflt.c new file mode 100644 index 000000000..1724a0b82 --- /dev/null +++ b/gs/jpeg/jidctflt.c @@ -0,0 +1,241 @@ +/* + * jidctflt.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a floating-point implementation of the + * inverse DCT (Discrete Cosine Transform). In the IJG code, this routine + * must also perform dequantization of the input coefficients. + * + * This implementation should be more accurate than either of the integer + * IDCT implementations. However, it may not give the same results on all + * machines because of differences in roundoff behavior. Speed will depend + * on the hardware's floating point capacity. + * + * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT + * on each row (or vice versa, but it's more convenient to emit a row at + * a time). Direct algorithms are also available, but they are much more + * complex and seem not to be any faster when reduced to code. + * + * This implementation is based on Arai, Agui, and Nakajima's algorithm for + * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in + * Japanese, but the algorithm is described in the Pennebaker & Mitchell + * JPEG textbook (see REFERENCES section in file README). The following code + * is based directly on figure 4-8 in P&M. + * While an 8-point DCT cannot be done in less than 11 multiplies, it is + * possible to arrange the computation so that many of the multiplies are + * simple scalings of the final outputs. These multiplies can then be + * folded into the multiplications or divisions by the JPEG quantization + * table entries. The AA&N method leaves only 5 multiplies and 29 adds + * to be done in the DCT itself. + * The primary disadvantage of this method is that with a fixed-point + * implementation, accuracy is lost due to imprecise representation of the + * scaled quantization values. However, that problem does not arise if + * we use floating point arithmetic. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdct.h" /* Private declarations for DCT subsystem */ + +#ifdef DCT_FLOAT_SUPPORTED + + +/* + * This module is specialized to the case DCTSIZE = 8. + */ + +#if DCTSIZE != 8 + Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ +#endif + + +/* Dequantize a coefficient by multiplying it by the multiplier-table + * entry; produce a float result. + */ + +#define DEQUANTIZE(coef,quantval) (((FAST_FLOAT) (coef)) * (quantval)) + + +/* + * Perform dequantization and inverse DCT on one block of coefficients. + */ + +GLOBAL(void) +jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + FAST_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + FAST_FLOAT tmp10, tmp11, tmp12, tmp13; + FAST_FLOAT z5, z10, z11, z12, z13; + JCOEFPTR inptr; + FLOAT_MULT_TYPE * quantptr; + FAST_FLOAT * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + FAST_FLOAT workspace[DCTSIZE2]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. */ + + inptr = coef_block; + quantptr = (FLOAT_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = DCTSIZE; ctr > 0; ctr--) { + /* Due to quantization, we will usually find that many of the input + * coefficients are zero, especially the AC terms. We can exploit this + * by short-circuiting the IDCT calculation for any column in which all + * the AC terms are zero. In that case each output is equal to the + * DC coefficient (with scale factor as needed). + * With typical images and quantization tables, half or more of the + * column DCT calculations can be simplified this way. + */ + + if ((inptr[DCTSIZE*1] | inptr[DCTSIZE*2] | inptr[DCTSIZE*3] | + inptr[DCTSIZE*4] | inptr[DCTSIZE*5] | inptr[DCTSIZE*6] | + inptr[DCTSIZE*7]) == 0) { + /* AC terms all zero */ + FAST_FLOAT dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + + wsptr[DCTSIZE*0] = dcval; + wsptr[DCTSIZE*1] = dcval; + wsptr[DCTSIZE*2] = dcval; + wsptr[DCTSIZE*3] = dcval; + wsptr[DCTSIZE*4] = dcval; + wsptr[DCTSIZE*5] = dcval; + wsptr[DCTSIZE*6] = dcval; + wsptr[DCTSIZE*7] = dcval; + + inptr++; /* advance pointers to next column */ + quantptr++; + wsptr++; + continue; + } + + /* Even part */ + + tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + tmp1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); + tmp3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); + + tmp10 = tmp0 + tmp2; /* phase 3 */ + tmp11 = tmp0 - tmp2; + + tmp13 = tmp1 + tmp3; /* phases 5-3 */ + tmp12 = (tmp1 - tmp3) * ((FAST_FLOAT) 1.414213562) - tmp13; /* 2*c4 */ + + tmp0 = tmp10 + tmp13; /* phase 2 */ + tmp3 = tmp10 - tmp13; + tmp1 = tmp11 + tmp12; + tmp2 = tmp11 - tmp12; + + /* Odd part */ + + tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + tmp5 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + tmp6 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + tmp7 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); + + z13 = tmp6 + tmp5; /* phase 6 */ + z10 = tmp6 - tmp5; + z11 = tmp4 + tmp7; + z12 = tmp4 - tmp7; + + tmp7 = z11 + z13; /* phase 5 */ + tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562); /* 2*c4 */ + + z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */ + tmp10 = ((FAST_FLOAT) 1.082392200) * z12 - z5; /* 2*(c2-c6) */ + tmp12 = ((FAST_FLOAT) -2.613125930) * z10 + z5; /* -2*(c2+c6) */ + + tmp6 = tmp12 - tmp7; /* phase 2 */ + tmp5 = tmp11 - tmp6; + tmp4 = tmp10 + tmp5; + + wsptr[DCTSIZE*0] = tmp0 + tmp7; + wsptr[DCTSIZE*7] = tmp0 - tmp7; + wsptr[DCTSIZE*1] = tmp1 + tmp6; + wsptr[DCTSIZE*6] = tmp1 - tmp6; + wsptr[DCTSIZE*2] = tmp2 + tmp5; + wsptr[DCTSIZE*5] = tmp2 - tmp5; + wsptr[DCTSIZE*4] = tmp3 + tmp4; + wsptr[DCTSIZE*3] = tmp3 - tmp4; + + inptr++; /* advance pointers to next column */ + quantptr++; + wsptr++; + } + + /* Pass 2: process rows from work array, store into output array. */ + /* Note that we must descale the results by a factor of 8 == 2**3. */ + + wsptr = workspace; + for (ctr = 0; ctr < DCTSIZE; ctr++) { + outptr = output_buf[ctr] + output_col; + /* Rows of zeroes can be exploited in the same way as we did with columns. + * However, the column calculation has created many nonzero AC terms, so + * the simplification applies less often (typically 5% to 10% of the time). + * And testing floats for zero is relatively expensive, so we don't bother. + */ + + /* Even part */ + + tmp10 = wsptr[0] + wsptr[4]; + tmp11 = wsptr[0] - wsptr[4]; + + tmp13 = wsptr[2] + wsptr[6]; + tmp12 = (wsptr[2] - wsptr[6]) * ((FAST_FLOAT) 1.414213562) - tmp13; + + tmp0 = tmp10 + tmp13; + tmp3 = tmp10 - tmp13; + tmp1 = tmp11 + tmp12; + tmp2 = tmp11 - tmp12; + + /* Odd part */ + + z13 = wsptr[5] + wsptr[3]; + z10 = wsptr[5] - wsptr[3]; + z11 = wsptr[1] + wsptr[7]; + z12 = wsptr[1] - wsptr[7]; + + tmp7 = z11 + z13; + tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562); + + z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */ + tmp10 = ((FAST_FLOAT) 1.082392200) * z12 - z5; /* 2*(c2-c6) */ + tmp12 = ((FAST_FLOAT) -2.613125930) * z10 + z5; /* -2*(c2+c6) */ + + tmp6 = tmp12 - tmp7; + tmp5 = tmp11 - tmp6; + tmp4 = tmp10 + tmp5; + + /* Final output stage: scale down by a factor of 8 and range-limit */ + + outptr[0] = range_limit[(int) DESCALE((INT32) (tmp0 + tmp7), 3) + & RANGE_MASK]; + outptr[7] = range_limit[(int) DESCALE((INT32) (tmp0 - tmp7), 3) + & RANGE_MASK]; + outptr[1] = range_limit[(int) DESCALE((INT32) (tmp1 + tmp6), 3) + & RANGE_MASK]; + outptr[6] = range_limit[(int) DESCALE((INT32) (tmp1 - tmp6), 3) + & RANGE_MASK]; + outptr[2] = range_limit[(int) DESCALE((INT32) (tmp2 + tmp5), 3) + & RANGE_MASK]; + outptr[5] = range_limit[(int) DESCALE((INT32) (tmp2 - tmp5), 3) + & RANGE_MASK]; + outptr[4] = range_limit[(int) DESCALE((INT32) (tmp3 + tmp4), 3) + & RANGE_MASK]; + outptr[3] = range_limit[(int) DESCALE((INT32) (tmp3 - tmp4), 3) + & RANGE_MASK]; + + wsptr += DCTSIZE; /* advance pointer to next row */ + } +} + +#endif /* DCT_FLOAT_SUPPORTED */ diff --git a/gs/jpeg/jidctfst.c b/gs/jpeg/jidctfst.c new file mode 100644 index 000000000..c8661ba21 --- /dev/null +++ b/gs/jpeg/jidctfst.c @@ -0,0 +1,367 @@ +/* + * jidctfst.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a fast, not so accurate integer implementation of the + * inverse DCT (Discrete Cosine Transform). In the IJG code, this routine + * must also perform dequantization of the input coefficients. + * + * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT + * on each row (or vice versa, but it's more convenient to emit a row at + * a time). Direct algorithms are also available, but they are much more + * complex and seem not to be any faster when reduced to code. + * + * This implementation is based on Arai, Agui, and Nakajima's algorithm for + * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in + * Japanese, but the algorithm is described in the Pennebaker & Mitchell + * JPEG textbook (see REFERENCES section in file README). The following code + * is based directly on figure 4-8 in P&M. + * While an 8-point DCT cannot be done in less than 11 multiplies, it is + * possible to arrange the computation so that many of the multiplies are + * simple scalings of the final outputs. These multiplies can then be + * folded into the multiplications or divisions by the JPEG quantization + * table entries. The AA&N method leaves only 5 multiplies and 29 adds + * to be done in the DCT itself. + * The primary disadvantage of this method is that with fixed-point math, + * accuracy is lost due to imprecise representation of the scaled + * quantization values. The smaller the quantization table entry, the less + * precise the scaled value, so this implementation does worse with high- + * quality-setting files than with low-quality ones. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdct.h" /* Private declarations for DCT subsystem */ + +#ifdef DCT_IFAST_SUPPORTED + + +/* + * This module is specialized to the case DCTSIZE = 8. + */ + +#if DCTSIZE != 8 + Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ +#endif + + +/* Scaling decisions are generally the same as in the LL&M algorithm; + * see jidctint.c for more details. However, we choose to descale + * (right shift) multiplication products as soon as they are formed, + * rather than carrying additional fractional bits into subsequent additions. + * This compromises accuracy slightly, but it lets us save a few shifts. + * More importantly, 16-bit arithmetic is then adequate (for 8-bit samples) + * everywhere except in the multiplications proper; this saves a good deal + * of work on 16-bit-int machines. + * + * The dequantized coefficients are not integers because the AA&N scaling + * factors have been incorporated. We represent them scaled up by PASS1_BITS, + * so that the first and second IDCT rounds have the same input scaling. + * For 8-bit JSAMPLEs, we choose IFAST_SCALE_BITS = PASS1_BITS so as to + * avoid a descaling shift; this compromises accuracy rather drastically + * for small quantization table entries, but it saves a lot of shifts. + * For 12-bit JSAMPLEs, there's no hope of using 16x16 multiplies anyway, + * so we use a much larger scaling factor to preserve accuracy. + * + * A final compromise is to represent the multiplicative constants to only + * 8 fractional bits, rather than 13. This saves some shifting work on some + * machines, and may also reduce the cost of multiplication (since there + * are fewer one-bits in the constants). + */ + +#if BITS_IN_JSAMPLE == 8 +#define CONST_BITS 8 +#define PASS1_BITS 2 +#else +#define CONST_BITS 8 +#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ +#endif + +/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus + * causing a lot of useless floating-point operations at run time. + * To get around this we use the following pre-calculated constants. + * If you change CONST_BITS you may want to add appropriate values. + * (With a reasonable C compiler, you can just rely on the FIX() macro...) + */ + +#if CONST_BITS == 8 +#define FIX_1_082392200 ((INT32) 277) /* FIX(1.082392200) */ +#define FIX_1_414213562 ((INT32) 362) /* FIX(1.414213562) */ +#define FIX_1_847759065 ((INT32) 473) /* FIX(1.847759065) */ +#define FIX_2_613125930 ((INT32) 669) /* FIX(2.613125930) */ +#else +#define FIX_1_082392200 FIX(1.082392200) +#define FIX_1_414213562 FIX(1.414213562) +#define FIX_1_847759065 FIX(1.847759065) +#define FIX_2_613125930 FIX(2.613125930) +#endif + + +/* We can gain a little more speed, with a further compromise in accuracy, + * by omitting the addition in a descaling shift. This yields an incorrectly + * rounded result half the time... + */ + +#ifndef USE_ACCURATE_ROUNDING +#undef DESCALE +#define DESCALE(x,n) RIGHT_SHIFT(x, n) +#endif + + +/* Multiply a DCTELEM variable by an INT32 constant, and immediately + * descale to yield a DCTELEM result. + */ + +#define MULTIPLY(var,const) ((DCTELEM) DESCALE((var) * (const), CONST_BITS)) + + +/* Dequantize a coefficient by multiplying it by the multiplier-table + * entry; produce a DCTELEM result. For 8-bit data a 16x16->16 + * multiplication will do. For 12-bit data, the multiplier table is + * declared INT32, so a 32-bit multiply will be used. + */ + +#if BITS_IN_JSAMPLE == 8 +#define DEQUANTIZE(coef,quantval) (((IFAST_MULT_TYPE) (coef)) * (quantval)) +#else +#define DEQUANTIZE(coef,quantval) \ + DESCALE((coef)*(quantval), IFAST_SCALE_BITS-PASS1_BITS) +#endif + + +/* Like DESCALE, but applies to a DCTELEM and produces an int. + * We assume that int right shift is unsigned if INT32 right shift is. + */ + +#ifdef RIGHT_SHIFT_IS_UNSIGNED +#define ISHIFT_TEMPS DCTELEM ishift_temp; +#if BITS_IN_JSAMPLE == 8 +#define DCTELEMBITS 16 /* DCTELEM may be 16 or 32 bits */ +#else +#define DCTELEMBITS 32 /* DCTELEM must be 32 bits */ +#endif +#define IRIGHT_SHIFT(x,shft) \ + ((ishift_temp = (x)) < 0 ? \ + (ishift_temp >> (shft)) | ((~((DCTELEM) 0)) << (DCTELEMBITS-(shft))) : \ + (ishift_temp >> (shft))) +#else +#define ISHIFT_TEMPS +#define IRIGHT_SHIFT(x,shft) ((x) >> (shft)) +#endif + +#ifdef USE_ACCURATE_ROUNDING +#define IDESCALE(x,n) ((int) IRIGHT_SHIFT((x) + (1 << ((n)-1)), n)) +#else +#define IDESCALE(x,n) ((int) IRIGHT_SHIFT(x, n)) +#endif + + +/* + * Perform dequantization and inverse DCT on one block of coefficients. + */ + +GLOBAL(void) +jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + DCTELEM tmp10, tmp11, tmp12, tmp13; + DCTELEM z5, z10, z11, z12, z13; + JCOEFPTR inptr; + IFAST_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[DCTSIZE2]; /* buffers data between passes */ + SHIFT_TEMPS /* for DESCALE */ + ISHIFT_TEMPS /* for IDESCALE */ + + /* Pass 1: process columns from input, store into work array. */ + + inptr = coef_block; + quantptr = (IFAST_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = DCTSIZE; ctr > 0; ctr--) { + /* Due to quantization, we will usually find that many of the input + * coefficients are zero, especially the AC terms. We can exploit this + * by short-circuiting the IDCT calculation for any column in which all + * the AC terms are zero. In that case each output is equal to the + * DC coefficient (with scale factor as needed). + * With typical images and quantization tables, half or more of the + * column DCT calculations can be simplified this way. + */ + + if ((inptr[DCTSIZE*1] | inptr[DCTSIZE*2] | inptr[DCTSIZE*3] | + inptr[DCTSIZE*4] | inptr[DCTSIZE*5] | inptr[DCTSIZE*6] | + inptr[DCTSIZE*7]) == 0) { + /* AC terms all zero */ + int dcval = (int) DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + + wsptr[DCTSIZE*0] = dcval; + wsptr[DCTSIZE*1] = dcval; + wsptr[DCTSIZE*2] = dcval; + wsptr[DCTSIZE*3] = dcval; + wsptr[DCTSIZE*4] = dcval; + wsptr[DCTSIZE*5] = dcval; + wsptr[DCTSIZE*6] = dcval; + wsptr[DCTSIZE*7] = dcval; + + inptr++; /* advance pointers to next column */ + quantptr++; + wsptr++; + continue; + } + + /* Even part */ + + tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + tmp1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); + tmp3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); + + tmp10 = tmp0 + tmp2; /* phase 3 */ + tmp11 = tmp0 - tmp2; + + tmp13 = tmp1 + tmp3; /* phases 5-3 */ + tmp12 = MULTIPLY(tmp1 - tmp3, FIX_1_414213562) - tmp13; /* 2*c4 */ + + tmp0 = tmp10 + tmp13; /* phase 2 */ + tmp3 = tmp10 - tmp13; + tmp1 = tmp11 + tmp12; + tmp2 = tmp11 - tmp12; + + /* Odd part */ + + tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + tmp5 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + tmp6 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + tmp7 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); + + z13 = tmp6 + tmp5; /* phase 6 */ + z10 = tmp6 - tmp5; + z11 = tmp4 + tmp7; + z12 = tmp4 - tmp7; + + tmp7 = z11 + z13; /* phase 5 */ + tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */ + + z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */ + tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */ + tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */ + + tmp6 = tmp12 - tmp7; /* phase 2 */ + tmp5 = tmp11 - tmp6; + tmp4 = tmp10 + tmp5; + + wsptr[DCTSIZE*0] = (int) (tmp0 + tmp7); + wsptr[DCTSIZE*7] = (int) (tmp0 - tmp7); + wsptr[DCTSIZE*1] = (int) (tmp1 + tmp6); + wsptr[DCTSIZE*6] = (int) (tmp1 - tmp6); + wsptr[DCTSIZE*2] = (int) (tmp2 + tmp5); + wsptr[DCTSIZE*5] = (int) (tmp2 - tmp5); + wsptr[DCTSIZE*4] = (int) (tmp3 + tmp4); + wsptr[DCTSIZE*3] = (int) (tmp3 - tmp4); + + inptr++; /* advance pointers to next column */ + quantptr++; + wsptr++; + } + + /* Pass 2: process rows from work array, store into output array. */ + /* Note that we must descale the results by a factor of 8 == 2**3, */ + /* and also undo the PASS1_BITS scaling. */ + + wsptr = workspace; + for (ctr = 0; ctr < DCTSIZE; ctr++) { + outptr = output_buf[ctr] + output_col; + /* Rows of zeroes can be exploited in the same way as we did with columns. + * However, the column calculation has created many nonzero AC terms, so + * the simplification applies less often (typically 5% to 10% of the time). + * On machines with very fast multiplication, it's possible that the + * test takes more time than it's worth. In that case this section + * may be commented out. + */ + +#ifndef NO_ZERO_ROW_TEST + if ((wsptr[1] | wsptr[2] | wsptr[3] | wsptr[4] | wsptr[5] | wsptr[6] | + wsptr[7]) == 0) { + /* AC terms all zero */ + JSAMPLE dcval = range_limit[IDESCALE(wsptr[0], PASS1_BITS+3) + & RANGE_MASK]; + + outptr[0] = dcval; + outptr[1] = dcval; + outptr[2] = dcval; + outptr[3] = dcval; + outptr[4] = dcval; + outptr[5] = dcval; + outptr[6] = dcval; + outptr[7] = dcval; + + wsptr += DCTSIZE; /* advance pointer to next row */ + continue; + } +#endif + + /* Even part */ + + tmp10 = ((DCTELEM) wsptr[0] + (DCTELEM) wsptr[4]); + tmp11 = ((DCTELEM) wsptr[0] - (DCTELEM) wsptr[4]); + + tmp13 = ((DCTELEM) wsptr[2] + (DCTELEM) wsptr[6]); + tmp12 = MULTIPLY((DCTELEM) wsptr[2] - (DCTELEM) wsptr[6], FIX_1_414213562) + - tmp13; + + tmp0 = tmp10 + tmp13; + tmp3 = tmp10 - tmp13; + tmp1 = tmp11 + tmp12; + tmp2 = tmp11 - tmp12; + + /* Odd part */ + + z13 = (DCTELEM) wsptr[5] + (DCTELEM) wsptr[3]; + z10 = (DCTELEM) wsptr[5] - (DCTELEM) wsptr[3]; + z11 = (DCTELEM) wsptr[1] + (DCTELEM) wsptr[7]; + z12 = (DCTELEM) wsptr[1] - (DCTELEM) wsptr[7]; + + tmp7 = z11 + z13; /* phase 5 */ + tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */ + + z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */ + tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */ + tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */ + + tmp6 = tmp12 - tmp7; /* phase 2 */ + tmp5 = tmp11 - tmp6; + tmp4 = tmp10 + tmp5; + + /* Final output stage: scale down by a factor of 8 and range-limit */ + + outptr[0] = range_limit[IDESCALE(tmp0 + tmp7, PASS1_BITS+3) + & RANGE_MASK]; + outptr[7] = range_limit[IDESCALE(tmp0 - tmp7, PASS1_BITS+3) + & RANGE_MASK]; + outptr[1] = range_limit[IDESCALE(tmp1 + tmp6, PASS1_BITS+3) + & RANGE_MASK]; + outptr[6] = range_limit[IDESCALE(tmp1 - tmp6, PASS1_BITS+3) + & RANGE_MASK]; + outptr[2] = range_limit[IDESCALE(tmp2 + tmp5, PASS1_BITS+3) + & RANGE_MASK]; + outptr[5] = range_limit[IDESCALE(tmp2 - tmp5, PASS1_BITS+3) + & RANGE_MASK]; + outptr[4] = range_limit[IDESCALE(tmp3 + tmp4, PASS1_BITS+3) + & RANGE_MASK]; + outptr[3] = range_limit[IDESCALE(tmp3 - tmp4, PASS1_BITS+3) + & RANGE_MASK]; + + wsptr += DCTSIZE; /* advance pointer to next row */ + } +} + +#endif /* DCT_IFAST_SUPPORTED */ diff --git a/gs/jpeg/jidctint.c b/gs/jpeg/jidctint.c new file mode 100644 index 000000000..002dac2b8 --- /dev/null +++ b/gs/jpeg/jidctint.c @@ -0,0 +1,388 @@ +/* + * jidctint.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a slow-but-accurate integer implementation of the + * inverse DCT (Discrete Cosine Transform). In the IJG code, this routine + * must also perform dequantization of the input coefficients. + * + * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT + * on each row (or vice versa, but it's more convenient to emit a row at + * a time). Direct algorithms are also available, but they are much more + * complex and seem not to be any faster when reduced to code. + * + * This implementation is based on an algorithm described in + * C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT + * Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics, + * Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991. + * The primary algorithm described there uses 11 multiplies and 29 adds. + * We use their alternate method with 12 multiplies and 32 adds. + * The advantage of this method is that no data path contains more than one + * multiplication; this allows a very simple and accurate implementation in + * scaled fixed-point arithmetic, with a minimal number of shifts. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdct.h" /* Private declarations for DCT subsystem */ + +#ifdef DCT_ISLOW_SUPPORTED + + +/* + * This module is specialized to the case DCTSIZE = 8. + */ + +#if DCTSIZE != 8 + Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ +#endif + + +/* + * The poop on this scaling stuff is as follows: + * + * Each 1-D IDCT step produces outputs which are a factor of sqrt(N) + * larger than the true IDCT outputs. The final outputs are therefore + * a factor of N larger than desired; since N=8 this can be cured by + * a simple right shift at the end of the algorithm. The advantage of + * this arrangement is that we save two multiplications per 1-D IDCT, + * because the y0 and y4 inputs need not be divided by sqrt(N). + * + * We have to do addition and subtraction of the integer inputs, which + * is no problem, and multiplication by fractional constants, which is + * a problem to do in integer arithmetic. We multiply all the constants + * by CONST_SCALE and convert them to integer constants (thus retaining + * CONST_BITS bits of precision in the constants). After doing a + * multiplication we have to divide the product by CONST_SCALE, with proper + * rounding, to produce the correct output. This division can be done + * cheaply as a right shift of CONST_BITS bits. We postpone shifting + * as long as possible so that partial sums can be added together with + * full fractional precision. + * + * The outputs of the first pass are scaled up by PASS1_BITS bits so that + * they are represented to better-than-integral precision. These outputs + * require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word + * with the recommended scaling. (To scale up 12-bit sample data further, an + * intermediate INT32 array would be needed.) + * + * To avoid overflow of the 32-bit intermediate results in pass 2, we must + * have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis + * shows that the values given below are the most effective. + */ + +#if BITS_IN_JSAMPLE == 8 +#define CONST_BITS 13 +#define PASS1_BITS 2 +#else +#define CONST_BITS 13 +#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ +#endif + +/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus + * causing a lot of useless floating-point operations at run time. + * To get around this we use the following pre-calculated constants. + * If you change CONST_BITS you may want to add appropriate values. + * (With a reasonable C compiler, you can just rely on the FIX() macro...) + */ + +#if CONST_BITS == 13 +#define FIX_0_298631336 ((INT32) 2446) /* FIX(0.298631336) */ +#define FIX_0_390180644 ((INT32) 3196) /* FIX(0.390180644) */ +#define FIX_0_541196100 ((INT32) 4433) /* FIX(0.541196100) */ +#define FIX_0_765366865 ((INT32) 6270) /* FIX(0.765366865) */ +#define FIX_0_899976223 ((INT32) 7373) /* FIX(0.899976223) */ +#define FIX_1_175875602 ((INT32) 9633) /* FIX(1.175875602) */ +#define FIX_1_501321110 ((INT32) 12299) /* FIX(1.501321110) */ +#define FIX_1_847759065 ((INT32) 15137) /* FIX(1.847759065) */ +#define FIX_1_961570560 ((INT32) 16069) /* FIX(1.961570560) */ +#define FIX_2_053119869 ((INT32) 16819) /* FIX(2.053119869) */ +#define FIX_2_562915447 ((INT32) 20995) /* FIX(2.562915447) */ +#define FIX_3_072711026 ((INT32) 25172) /* FIX(3.072711026) */ +#else +#define FIX_0_298631336 FIX(0.298631336) +#define FIX_0_390180644 FIX(0.390180644) +#define FIX_0_541196100 FIX(0.541196100) +#define FIX_0_765366865 FIX(0.765366865) +#define FIX_0_899976223 FIX(0.899976223) +#define FIX_1_175875602 FIX(1.175875602) +#define FIX_1_501321110 FIX(1.501321110) +#define FIX_1_847759065 FIX(1.847759065) +#define FIX_1_961570560 FIX(1.961570560) +#define FIX_2_053119869 FIX(2.053119869) +#define FIX_2_562915447 FIX(2.562915447) +#define FIX_3_072711026 FIX(3.072711026) +#endif + + +/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. + * For 8-bit samples with the recommended scaling, all the variable + * and constant values involved are no more than 16 bits wide, so a + * 16x16->32 bit multiply can be used instead of a full 32x32 multiply. + * For 12-bit samples, a full 32-bit multiplication will be needed. + */ + +#if BITS_IN_JSAMPLE == 8 +#define MULTIPLY(var,const) MULTIPLY16C16(var,const) +#else +#define MULTIPLY(var,const) ((var) * (const)) +#endif + + +/* Dequantize a coefficient by multiplying it by the multiplier-table + * entry; produce an int result. In this module, both inputs and result + * are 16 bits or less, so either int or short multiply will work. + */ + +#define DEQUANTIZE(coef,quantval) (((ISLOW_MULT_TYPE) (coef)) * (quantval)) + + +/* + * Perform dequantization and inverse DCT on one block of coefficients. + */ + +GLOBAL(void) +jpeg_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp0, tmp1, tmp2, tmp3; + INT32 tmp10, tmp11, tmp12, tmp13; + INT32 z1, z2, z3, z4, z5; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[DCTSIZE2]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. */ + /* Note results are scaled up by sqrt(8) compared to a true IDCT; */ + /* furthermore, we scale the results by 2**PASS1_BITS. */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = DCTSIZE; ctr > 0; ctr--) { + /* Due to quantization, we will usually find that many of the input + * coefficients are zero, especially the AC terms. We can exploit this + * by short-circuiting the IDCT calculation for any column in which all + * the AC terms are zero. In that case each output is equal to the + * DC coefficient (with scale factor as needed). + * With typical images and quantization tables, half or more of the + * column DCT calculations can be simplified this way. + */ + + if ((inptr[DCTSIZE*1] | inptr[DCTSIZE*2] | inptr[DCTSIZE*3] | + inptr[DCTSIZE*4] | inptr[DCTSIZE*5] | inptr[DCTSIZE*6] | + inptr[DCTSIZE*7]) == 0) { + /* AC terms all zero */ + int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS; + + wsptr[DCTSIZE*0] = dcval; + wsptr[DCTSIZE*1] = dcval; + wsptr[DCTSIZE*2] = dcval; + wsptr[DCTSIZE*3] = dcval; + wsptr[DCTSIZE*4] = dcval; + wsptr[DCTSIZE*5] = dcval; + wsptr[DCTSIZE*6] = dcval; + wsptr[DCTSIZE*7] = dcval; + + inptr++; /* advance pointers to next column */ + quantptr++; + wsptr++; + continue; + } + + /* Even part: reverse the even part of the forward DCT. */ + /* The rotator is sqrt(2)*c(-6). */ + + z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); + + z1 = MULTIPLY(z2 + z3, FIX_0_541196100); + tmp2 = z1 + MULTIPLY(z3, - FIX_1_847759065); + tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865); + + z2 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + z3 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); + + tmp0 = (z2 + z3) << CONST_BITS; + tmp1 = (z2 - z3) << CONST_BITS; + + tmp10 = tmp0 + tmp3; + tmp13 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp12 = tmp1 - tmp2; + + /* Odd part per figure 8; the matrix is unitary and hence its + * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. + */ + + tmp0 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); + tmp1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + tmp2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + tmp3 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + + z1 = tmp0 + tmp3; + z2 = tmp1 + tmp2; + z3 = tmp0 + tmp2; + z4 = tmp1 + tmp3; + z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ + + tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ + tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ + tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ + tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ + z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ + z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ + z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ + z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ + + z3 += z5; + z4 += z5; + + tmp0 += z1 + z3; + tmp1 += z2 + z4; + tmp2 += z2 + z3; + tmp3 += z1 + z4; + + /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ + + wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp3, CONST_BITS-PASS1_BITS); + wsptr[DCTSIZE*7] = (int) DESCALE(tmp10 - tmp3, CONST_BITS-PASS1_BITS); + wsptr[DCTSIZE*1] = (int) DESCALE(tmp11 + tmp2, CONST_BITS-PASS1_BITS); + wsptr[DCTSIZE*6] = (int) DESCALE(tmp11 - tmp2, CONST_BITS-PASS1_BITS); + wsptr[DCTSIZE*2] = (int) DESCALE(tmp12 + tmp1, CONST_BITS-PASS1_BITS); + wsptr[DCTSIZE*5] = (int) DESCALE(tmp12 - tmp1, CONST_BITS-PASS1_BITS); + wsptr[DCTSIZE*3] = (int) DESCALE(tmp13 + tmp0, CONST_BITS-PASS1_BITS); + wsptr[DCTSIZE*4] = (int) DESCALE(tmp13 - tmp0, CONST_BITS-PASS1_BITS); + + inptr++; /* advance pointers to next column */ + quantptr++; + wsptr++; + } + + /* Pass 2: process rows from work array, store into output array. */ + /* Note that we must descale the results by a factor of 8 == 2**3, */ + /* and also undo the PASS1_BITS scaling. */ + + wsptr = workspace; + for (ctr = 0; ctr < DCTSIZE; ctr++) { + outptr = output_buf[ctr] + output_col; + /* Rows of zeroes can be exploited in the same way as we did with columns. + * However, the column calculation has created many nonzero AC terms, so + * the simplification applies less often (typically 5% to 10% of the time). + * On machines with very fast multiplication, it's possible that the + * test takes more time than it's worth. In that case this section + * may be commented out. + */ + +#ifndef NO_ZERO_ROW_TEST + if ((wsptr[1] | wsptr[2] | wsptr[3] | wsptr[4] | wsptr[5] | wsptr[6] | + wsptr[7]) == 0) { + /* AC terms all zero */ + JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3) + & RANGE_MASK]; + + outptr[0] = dcval; + outptr[1] = dcval; + outptr[2] = dcval; + outptr[3] = dcval; + outptr[4] = dcval; + outptr[5] = dcval; + outptr[6] = dcval; + outptr[7] = dcval; + + wsptr += DCTSIZE; /* advance pointer to next row */ + continue; + } +#endif + + /* Even part: reverse the even part of the forward DCT. */ + /* The rotator is sqrt(2)*c(-6). */ + + z2 = (INT32) wsptr[2]; + z3 = (INT32) wsptr[6]; + + z1 = MULTIPLY(z2 + z3, FIX_0_541196100); + tmp2 = z1 + MULTIPLY(z3, - FIX_1_847759065); + tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865); + + tmp0 = ((INT32) wsptr[0] + (INT32) wsptr[4]) << CONST_BITS; + tmp1 = ((INT32) wsptr[0] - (INT32) wsptr[4]) << CONST_BITS; + + tmp10 = tmp0 + tmp3; + tmp13 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp12 = tmp1 - tmp2; + + /* Odd part per figure 8; the matrix is unitary and hence its + * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. + */ + + tmp0 = (INT32) wsptr[7]; + tmp1 = (INT32) wsptr[5]; + tmp2 = (INT32) wsptr[3]; + tmp3 = (INT32) wsptr[1]; + + z1 = tmp0 + tmp3; + z2 = tmp1 + tmp2; + z3 = tmp0 + tmp2; + z4 = tmp1 + tmp3; + z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ + + tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ + tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ + tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ + tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ + z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ + z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ + z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ + z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ + + z3 += z5; + z4 += z5; + + tmp0 += z1 + z3; + tmp1 += z2 + z4; + tmp2 += z2 + z3; + tmp3 += z1 + z4; + + /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ + + outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp3, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[7] = range_limit[(int) DESCALE(tmp10 - tmp3, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[1] = range_limit[(int) DESCALE(tmp11 + tmp2, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[6] = range_limit[(int) DESCALE(tmp11 - tmp2, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[2] = range_limit[(int) DESCALE(tmp12 + tmp1, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[5] = range_limit[(int) DESCALE(tmp12 - tmp1, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[3] = range_limit[(int) DESCALE(tmp13 + tmp0, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[4] = range_limit[(int) DESCALE(tmp13 - tmp0, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + + wsptr += DCTSIZE; /* advance pointer to next row */ + } +} + +#endif /* DCT_ISLOW_SUPPORTED */ diff --git a/gs/jpeg/jidctred.c b/gs/jpeg/jidctred.c new file mode 100644 index 000000000..3ec649c2b --- /dev/null +++ b/gs/jpeg/jidctred.c @@ -0,0 +1,397 @@ +/* + * jidctred.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains inverse-DCT routines that produce reduced-size output: + * either 4x4, 2x2, or 1x1 pixels from an 8x8 DCT block. + * + * The implementation is based on the Loeffler, Ligtenberg and Moschytz (LL&M) + * algorithm used in jidctint.c. We simply replace each 8-to-8 1-D IDCT step + * with an 8-to-4 step that produces the four averages of two adjacent outputs + * (or an 8-to-2 step producing two averages of four outputs, for 2x2 output). + * These steps were derived by computing the corresponding values at the end + * of the normal LL&M code, then simplifying as much as possible. + * + * 1x1 is trivial: just take the DC coefficient divided by 8. + * + * See jidctint.c for additional comments. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdct.h" /* Private declarations for DCT subsystem */ + +#ifdef IDCT_SCALING_SUPPORTED + + +/* + * This module is specialized to the case DCTSIZE = 8. + */ + +#if DCTSIZE != 8 + Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ +#endif + + +/* Scaling is the same as in jidctint.c. */ + +#if BITS_IN_JSAMPLE == 8 +#define CONST_BITS 13 +#define PASS1_BITS 2 +#else +#define CONST_BITS 13 +#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ +#endif + +/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus + * causing a lot of useless floating-point operations at run time. + * To get around this we use the following pre-calculated constants. + * If you change CONST_BITS you may want to add appropriate values. + * (With a reasonable C compiler, you can just rely on the FIX() macro...) + */ + +#if CONST_BITS == 13 +#define FIX_0_211164243 ((INT32) 1730) /* FIX(0.211164243) */ +#define FIX_0_509795579 ((INT32) 4176) /* FIX(0.509795579) */ +#define FIX_0_601344887 ((INT32) 4926) /* FIX(0.601344887) */ +#define FIX_0_720959822 ((INT32) 5906) /* FIX(0.720959822) */ +#define FIX_0_765366865 ((INT32) 6270) /* FIX(0.765366865) */ +#define FIX_0_850430095 ((INT32) 6967) /* FIX(0.850430095) */ +#define FIX_0_899976223 ((INT32) 7373) /* FIX(0.899976223) */ +#define FIX_1_061594337 ((INT32) 8697) /* FIX(1.061594337) */ +#define FIX_1_272758580 ((INT32) 10426) /* FIX(1.272758580) */ +#define FIX_1_451774981 ((INT32) 11893) /* FIX(1.451774981) */ +#define FIX_1_847759065 ((INT32) 15137) /* FIX(1.847759065) */ +#define FIX_2_172734803 ((INT32) 17799) /* FIX(2.172734803) */ +#define FIX_2_562915447 ((INT32) 20995) /* FIX(2.562915447) */ +#define FIX_3_624509785 ((INT32) 29692) /* FIX(3.624509785) */ +#else +#define FIX_0_211164243 FIX(0.211164243) +#define FIX_0_509795579 FIX(0.509795579) +#define FIX_0_601344887 FIX(0.601344887) +#define FIX_0_720959822 FIX(0.720959822) +#define FIX_0_765366865 FIX(0.765366865) +#define FIX_0_850430095 FIX(0.850430095) +#define FIX_0_899976223 FIX(0.899976223) +#define FIX_1_061594337 FIX(1.061594337) +#define FIX_1_272758580 FIX(1.272758580) +#define FIX_1_451774981 FIX(1.451774981) +#define FIX_1_847759065 FIX(1.847759065) +#define FIX_2_172734803 FIX(2.172734803) +#define FIX_2_562915447 FIX(2.562915447) +#define FIX_3_624509785 FIX(3.624509785) +#endif + + +/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. + * For 8-bit samples with the recommended scaling, all the variable + * and constant values involved are no more than 16 bits wide, so a + * 16x16->32 bit multiply can be used instead of a full 32x32 multiply. + * For 12-bit samples, a full 32-bit multiplication will be needed. + */ + +#if BITS_IN_JSAMPLE == 8 +#define MULTIPLY(var,const) MULTIPLY16C16(var,const) +#else +#define MULTIPLY(var,const) ((var) * (const)) +#endif + + +/* Dequantize a coefficient by multiplying it by the multiplier-table + * entry; produce an int result. In this module, both inputs and result + * are 16 bits or less, so either int or short multiply will work. + */ + +#define DEQUANTIZE(coef,quantval) (((ISLOW_MULT_TYPE) (coef)) * (quantval)) + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a reduced-size 4x4 output block. + */ + +GLOBAL(void) +jpeg_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp0, tmp2, tmp10, tmp12; + INT32 z1, z2, z3, z4; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[DCTSIZE*4]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) { + /* Don't bother to process column 4, because second pass won't use it */ + if (ctr == DCTSIZE-4) + continue; + if ((inptr[DCTSIZE*1] | inptr[DCTSIZE*2] | inptr[DCTSIZE*3] | + inptr[DCTSIZE*5] | inptr[DCTSIZE*6] | inptr[DCTSIZE*7]) == 0) { + /* AC terms all zero; we need not examine term 4 for 4x4 output */ + int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS; + + wsptr[DCTSIZE*0] = dcval; + wsptr[DCTSIZE*1] = dcval; + wsptr[DCTSIZE*2] = dcval; + wsptr[DCTSIZE*3] = dcval; + + continue; + } + + /* Even part */ + + tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + tmp0 <<= (CONST_BITS+1); + + z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); + + tmp2 = MULTIPLY(z2, FIX_1_847759065) + MULTIPLY(z3, - FIX_0_765366865); + + tmp10 = tmp0 + tmp2; + tmp12 = tmp0 - tmp2; + + /* Odd part */ + + z1 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); + z2 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + z3 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + z4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + + tmp0 = MULTIPLY(z1, - FIX_0_211164243) /* sqrt(2) * (c3-c1) */ + + MULTIPLY(z2, FIX_1_451774981) /* sqrt(2) * (c3+c7) */ + + MULTIPLY(z3, - FIX_2_172734803) /* sqrt(2) * (-c1-c5) */ + + MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * (c5+c7) */ + + tmp2 = MULTIPLY(z1, - FIX_0_509795579) /* sqrt(2) * (c7-c5) */ + + MULTIPLY(z2, - FIX_0_601344887) /* sqrt(2) * (c5-c1) */ + + MULTIPLY(z3, FIX_0_899976223) /* sqrt(2) * (c3-c7) */ + + MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */ + + /* Final output stage */ + + wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp2, CONST_BITS-PASS1_BITS+1); + wsptr[DCTSIZE*3] = (int) DESCALE(tmp10 - tmp2, CONST_BITS-PASS1_BITS+1); + wsptr[DCTSIZE*1] = (int) DESCALE(tmp12 + tmp0, CONST_BITS-PASS1_BITS+1); + wsptr[DCTSIZE*2] = (int) DESCALE(tmp12 - tmp0, CONST_BITS-PASS1_BITS+1); + } + + /* Pass 2: process 4 rows from work array, store into output array. */ + + wsptr = workspace; + for (ctr = 0; ctr < 4; ctr++) { + outptr = output_buf[ctr] + output_col; + /* It's not clear whether a zero row test is worthwhile here ... */ + +#ifndef NO_ZERO_ROW_TEST + if ((wsptr[1] | wsptr[2] | wsptr[3] | wsptr[5] | wsptr[6] | + wsptr[7]) == 0) { + /* AC terms all zero */ + JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3) + & RANGE_MASK]; + + outptr[0] = dcval; + outptr[1] = dcval; + outptr[2] = dcval; + outptr[3] = dcval; + + wsptr += DCTSIZE; /* advance pointer to next row */ + continue; + } +#endif + + /* Even part */ + + tmp0 = ((INT32) wsptr[0]) << (CONST_BITS+1); + + tmp2 = MULTIPLY((INT32) wsptr[2], FIX_1_847759065) + + MULTIPLY((INT32) wsptr[6], - FIX_0_765366865); + + tmp10 = tmp0 + tmp2; + tmp12 = tmp0 - tmp2; + + /* Odd part */ + + z1 = (INT32) wsptr[7]; + z2 = (INT32) wsptr[5]; + z3 = (INT32) wsptr[3]; + z4 = (INT32) wsptr[1]; + + tmp0 = MULTIPLY(z1, - FIX_0_211164243) /* sqrt(2) * (c3-c1) */ + + MULTIPLY(z2, FIX_1_451774981) /* sqrt(2) * (c3+c7) */ + + MULTIPLY(z3, - FIX_2_172734803) /* sqrt(2) * (-c1-c5) */ + + MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * (c5+c7) */ + + tmp2 = MULTIPLY(z1, - FIX_0_509795579) /* sqrt(2) * (c7-c5) */ + + MULTIPLY(z2, - FIX_0_601344887) /* sqrt(2) * (c5-c1) */ + + MULTIPLY(z3, FIX_0_899976223) /* sqrt(2) * (c3-c7) */ + + MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */ + + /* Final output stage */ + + outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp2, + CONST_BITS+PASS1_BITS+3+1) + & RANGE_MASK]; + outptr[3] = range_limit[(int) DESCALE(tmp10 - tmp2, + CONST_BITS+PASS1_BITS+3+1) + & RANGE_MASK]; + outptr[1] = range_limit[(int) DESCALE(tmp12 + tmp0, + CONST_BITS+PASS1_BITS+3+1) + & RANGE_MASK]; + outptr[2] = range_limit[(int) DESCALE(tmp12 - tmp0, + CONST_BITS+PASS1_BITS+3+1) + & RANGE_MASK]; + + wsptr += DCTSIZE; /* advance pointer to next row */ + } +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a reduced-size 2x2 output block. + */ + +GLOBAL(void) +jpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp0, tmp10, z1; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[DCTSIZE*2]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) { + /* Don't bother to process columns 2,4,6 */ + if (ctr == DCTSIZE-2 || ctr == DCTSIZE-4 || ctr == DCTSIZE-6) + continue; + if ((inptr[DCTSIZE*1] | inptr[DCTSIZE*3] | + inptr[DCTSIZE*5] | inptr[DCTSIZE*7]) == 0) { + /* AC terms all zero; we need not examine terms 2,4,6 for 2x2 output */ + int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS; + + wsptr[DCTSIZE*0] = dcval; + wsptr[DCTSIZE*1] = dcval; + + continue; + } + + /* Even part */ + + z1 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + tmp10 = z1 << (CONST_BITS+2); + + /* Odd part */ + + z1 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); + tmp0 = MULTIPLY(z1, - FIX_0_720959822); /* sqrt(2) * (c7-c5+c3-c1) */ + z1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + tmp0 += MULTIPLY(z1, FIX_0_850430095); /* sqrt(2) * (-c1+c3+c5+c7) */ + z1 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + tmp0 += MULTIPLY(z1, - FIX_1_272758580); /* sqrt(2) * (-c1+c3-c5-c7) */ + z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + tmp0 += MULTIPLY(z1, FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c7) */ + + /* Final output stage */ + + wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp0, CONST_BITS-PASS1_BITS+2); + wsptr[DCTSIZE*1] = (int) DESCALE(tmp10 - tmp0, CONST_BITS-PASS1_BITS+2); + } + + /* Pass 2: process 2 rows from work array, store into output array. */ + + wsptr = workspace; + for (ctr = 0; ctr < 2; ctr++) { + outptr = output_buf[ctr] + output_col; + /* It's not clear whether a zero row test is worthwhile here ... */ + +#ifndef NO_ZERO_ROW_TEST + if ((wsptr[1] | wsptr[3] | wsptr[5] | wsptr[7]) == 0) { + /* AC terms all zero */ + JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3) + & RANGE_MASK]; + + outptr[0] = dcval; + outptr[1] = dcval; + + wsptr += DCTSIZE; /* advance pointer to next row */ + continue; + } +#endif + + /* Even part */ + + tmp10 = ((INT32) wsptr[0]) << (CONST_BITS+2); + + /* Odd part */ + + tmp0 = MULTIPLY((INT32) wsptr[7], - FIX_0_720959822) /* sqrt(2) * (c7-c5+c3-c1) */ + + MULTIPLY((INT32) wsptr[5], FIX_0_850430095) /* sqrt(2) * (-c1+c3+c5+c7) */ + + MULTIPLY((INT32) wsptr[3], - FIX_1_272758580) /* sqrt(2) * (-c1+c3-c5-c7) */ + + MULTIPLY((INT32) wsptr[1], FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c7) */ + + /* Final output stage */ + + outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp0, + CONST_BITS+PASS1_BITS+3+2) + & RANGE_MASK]; + outptr[1] = range_limit[(int) DESCALE(tmp10 - tmp0, + CONST_BITS+PASS1_BITS+3+2) + & RANGE_MASK]; + + wsptr += DCTSIZE; /* advance pointer to next row */ + } +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a reduced-size 1x1 output block. + */ + +GLOBAL(void) +jpeg_idct_1x1 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + int dcval; + ISLOW_MULT_TYPE * quantptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + SHIFT_TEMPS + + /* We hardly need an inverse DCT routine for this: just take the + * average pixel value, which is one-eighth of the DC coefficient. + */ + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + dcval = DEQUANTIZE(coef_block[0], quantptr[0]); + dcval = (int) DESCALE((INT32) dcval, 3); + + output_buf[0][output_col] = range_limit[dcval & RANGE_MASK]; +} + +#endif /* IDCT_SCALING_SUPPORTED */ diff --git a/gs/jpeg/jinclude.h b/gs/jpeg/jinclude.h new file mode 100644 index 000000000..0a4f15146 --- /dev/null +++ b/gs/jpeg/jinclude.h @@ -0,0 +1,91 @@ +/* + * jinclude.h + * + * Copyright (C) 1991-1994, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file exists to provide a single place to fix any problems with + * including the wrong system include files. (Common problems are taken + * care of by the standard jconfig symbols, but on really weird systems + * you may have to edit this file.) + * + * NOTE: this file is NOT intended to be included by applications using the + * JPEG library. Most applications need only include jpeglib.h. + */ + + +/* Include auto-config file to find out which system include files we need. */ + +#include "jconfig.h" /* auto configuration options */ +#define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */ + +/* + * We need the NULL macro and size_t typedef. + * On an ANSI-conforming system it is sufficient to include . + * Otherwise, we get them from or ; we may have to + * pull in as well. + * Note that the core JPEG library does not require ; + * only the default error handler and data source/destination modules do. + * But we must pull it in because of the references to FILE in jpeglib.h. + * You can remove those references if you want to compile without . + */ + +#ifdef HAVE_STDDEF_H +#include +#endif + +#ifdef HAVE_STDLIB_H +#include +#endif + +#ifdef NEED_SYS_TYPES_H +#include +#endif + +#include + +/* + * We need memory copying and zeroing functions, plus strncpy(). + * ANSI and System V implementations declare these in . + * BSD doesn't have the mem() functions, but it does have bcopy()/bzero(). + * Some systems may declare memset and memcpy in . + * + * NOTE: we assume the size parameters to these functions are of type size_t. + * Change the casts in these macros if not! + */ + +#ifdef NEED_BSD_STRINGS + +#include +#define MEMZERO(target,size) bzero((void *)(target), (size_t)(size)) +#define MEMCOPY(dest,src,size) bcopy((const void *)(src), (void *)(dest), (size_t)(size)) + +#else /* not BSD, assume ANSI/SysV string lib */ + +#include +#define MEMZERO(target,size) memset((void *)(target), 0, (size_t)(size)) +#define MEMCOPY(dest,src,size) memcpy((void *)(dest), (const void *)(src), (size_t)(size)) + +#endif + +/* + * In ANSI C, and indeed any rational implementation, size_t is also the + * type returned by sizeof(). However, it seems there are some irrational + * implementations out there, in which sizeof() returns an int even though + * size_t is defined as long or unsigned long. To ensure consistent results + * we always use this SIZEOF() macro in place of using sizeof() directly. + */ + +#define SIZEOF(object) ((size_t) sizeof(object)) + +/* + * The modules that use fread() and fwrite() always invoke them through + * these macros. On some systems you may need to twiddle the argument casts. + * CAUTION: argument order is different from underlying functions! + */ + +#define JFREAD(file,buf,sizeofbuf) \ + ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) +#define JFWRITE(file,buf,sizeofbuf) \ + ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) diff --git a/gs/jpeg/jmemansi.c b/gs/jpeg/jmemansi.c new file mode 100644 index 000000000..2d93e4962 --- /dev/null +++ b/gs/jpeg/jmemansi.c @@ -0,0 +1,167 @@ +/* + * jmemansi.c + * + * Copyright (C) 1992-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file provides a simple generic implementation of the system- + * dependent portion of the JPEG memory manager. This implementation + * assumes that you have the ANSI-standard library routine tmpfile(). + * Also, the problem of determining the amount of memory available + * is shoved onto the user. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jmemsys.h" /* import the system-dependent declarations */ + +#ifndef HAVE_STDLIB_H /* should declare malloc(),free() */ +extern void * malloc JPP((size_t size)); +extern void free JPP((void *ptr)); +#endif + +#ifndef SEEK_SET /* pre-ANSI systems may not define this; */ +#define SEEK_SET 0 /* if not, assume 0 is correct */ +#endif + + +/* + * Memory allocation and freeing are controlled by the regular library + * routines malloc() and free(). + */ + +GLOBAL(void *) +jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void *) malloc(sizeofobject); +} + +GLOBAL(void) +jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) +{ + free(object); +} + + +/* + * "Large" objects are treated the same as "small" ones. + * NB: although we include FAR keywords in the routine declarations, + * this file won't actually work in 80x86 small/medium model; at least, + * you probably won't be able to process useful-size images in only 64KB. + */ + +GLOBAL(void FAR *) +jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void FAR *) malloc(sizeofobject); +} + +GLOBAL(void) +jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) +{ + free(object); +} + + +/* + * This routine computes the total memory space available for allocation. + * It's impossible to do this in a portable way; our current solution is + * to make the user tell us (with a default value set at compile time). + * If you can actually get the available space, it's a good idea to subtract + * a slop factor of 5% or so. + */ + +#ifndef DEFAULT_MAX_MEM /* so can override from makefile */ +#define DEFAULT_MAX_MEM 1000000L /* default: one megabyte */ +#endif + +GLOBAL(long) +jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, + long max_bytes_needed, long already_allocated) +{ + return cinfo->mem->max_memory_to_use - already_allocated; +} + + +/* + * Backing store (temporary file) management. + * Backing store objects are only used when the value returned by + * jpeg_mem_available is less than the total space needed. You can dispense + * with these routines if you have plenty of virtual memory; see jmemnobs.c. + */ + + +METHODDEF(void) +read_backing_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + if (fseek(info->temp_file, file_offset, SEEK_SET)) + ERREXIT(cinfo, JERR_TFILE_SEEK); + if (JFREAD(info->temp_file, buffer_address, byte_count) + != (size_t) byte_count) + ERREXIT(cinfo, JERR_TFILE_READ); +} + + +METHODDEF(void) +write_backing_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + if (fseek(info->temp_file, file_offset, SEEK_SET)) + ERREXIT(cinfo, JERR_TFILE_SEEK); + if (JFWRITE(info->temp_file, buffer_address, byte_count) + != (size_t) byte_count) + ERREXIT(cinfo, JERR_TFILE_WRITE); +} + + +METHODDEF(void) +close_backing_store (j_common_ptr cinfo, backing_store_ptr info) +{ + fclose(info->temp_file); + /* Since this implementation uses tmpfile() to create the file, + * no explicit file deletion is needed. + */ +} + + +/* + * Initial opening of a backing-store object. + * + * This version uses tmpfile(), which constructs a suitable file name + * behind the scenes. We don't have to use info->temp_name[] at all; + * indeed, we can't even find out the actual name of the temp file. + */ + +GLOBAL(void) +jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, + long total_bytes_needed) +{ + if ((info->temp_file = tmpfile()) == NULL) + ERREXITS(cinfo, JERR_TFILE_CREATE, ""); + info->read_backing_store = read_backing_store; + info->write_backing_store = write_backing_store; + info->close_backing_store = close_backing_store; +} + + +/* + * These routines take care of any system-dependent initialization and + * cleanup required. + */ + +GLOBAL(long) +jpeg_mem_init (j_common_ptr cinfo) +{ + return DEFAULT_MAX_MEM; /* default for max_memory_to_use */ +} + +GLOBAL(void) +jpeg_mem_term (j_common_ptr cinfo) +{ + /* no work */ +} diff --git a/gs/jpeg/jmemdos.c b/gs/jpeg/jmemdos.c new file mode 100644 index 000000000..77fb5ad5b --- /dev/null +++ b/gs/jpeg/jmemdos.c @@ -0,0 +1,634 @@ +/* + * jmemdos.c + * + * Copyright (C) 1992-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file provides an MS-DOS-compatible implementation of the system- + * dependent portion of the JPEG memory manager. Temporary data can be + * stored in extended or expanded memory as well as in regular DOS files. + * + * If you use this file, you must be sure that NEED_FAR_POINTERS is defined + * if you compile in a small-data memory model; it should NOT be defined if + * you use a large-data memory model. This file is not recommended if you + * are using a flat-memory-space 386 environment such as DJGCC or Watcom C. + * Also, this code will NOT work if struct fields are aligned on greater than + * 2-byte boundaries. + * + * Based on code contributed by Ge' Weijers. + */ + +/* + * If you have both extended and expanded memory, you may want to change the + * order in which they are tried in jopen_backing_store. On a 286 machine + * expanded memory is usually faster, since extended memory access involves + * an expensive protected-mode-and-back switch. On 386 and better, extended + * memory is usually faster. As distributed, the code tries extended memory + * first (what? not everyone has a 386? :-). + * + * You can disable use of extended/expanded memory entirely by altering these + * definitions or overriding them from the Makefile (eg, -DEMS_SUPPORTED=0). + */ + +#ifndef XMS_SUPPORTED +#define XMS_SUPPORTED 1 +#endif +#ifndef EMS_SUPPORTED +#define EMS_SUPPORTED 1 +#endif + + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jmemsys.h" /* import the system-dependent declarations */ + +#ifndef HAVE_STDLIB_H /* should declare these */ +extern void * malloc JPP((size_t size)); +extern void free JPP((void *ptr)); +extern char * getenv JPP((const char * name)); +#endif + +#ifdef NEED_FAR_POINTERS + +#ifdef __TURBOC__ +/* These definitions work for Borland C (Turbo C) */ +#include /* need farmalloc(), farfree() */ +#define far_malloc(x) farmalloc(x) +#define far_free(x) farfree(x) +#else +/* These definitions work for Microsoft C and compatible compilers */ +#include /* need _fmalloc(), _ffree() */ +#define far_malloc(x) _fmalloc(x) +#define far_free(x) _ffree(x) +#endif + +#else /* not NEED_FAR_POINTERS */ + +#define far_malloc(x) malloc(x) +#define far_free(x) free(x) + +#endif /* NEED_FAR_POINTERS */ + +#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ +#define READ_BINARY "r" +#else +#define READ_BINARY "rb" +#endif + +#if MAX_ALLOC_CHUNK >= 65535L /* make sure jconfig.h got this right */ + MAX_ALLOC_CHUNK should be less than 64K. /* deliberate syntax error */ +#endif + + +/* + * Declarations for assembly-language support routines (see jmemdosa.asm). + * + * The functions are declared "far" as are all their pointer arguments; + * this ensures the assembly source code will work regardless of the + * compiler memory model. We assume "short" is 16 bits, "long" is 32. + */ + +typedef void far * XMSDRIVER; /* actually a pointer to code */ +typedef struct { /* registers for calling XMS driver */ + unsigned short ax, dx, bx; + void far * ds_si; + } XMScontext; +typedef struct { /* registers for calling EMS driver */ + unsigned short ax, dx, bx; + void far * ds_si; + } EMScontext; + +extern short far jdos_open JPP((short far * handle, char far * filename)); +extern short far jdos_close JPP((short handle)); +extern short far jdos_seek JPP((short handle, long offset)); +extern short far jdos_read JPP((short handle, void far * buffer, + unsigned short count)); +extern short far jdos_write JPP((short handle, void far * buffer, + unsigned short count)); +extern void far jxms_getdriver JPP((XMSDRIVER far *)); +extern void far jxms_calldriver JPP((XMSDRIVER, XMScontext far *)); +extern short far jems_available JPP((void)); +extern void far jems_calldriver JPP((EMScontext far *)); + + +/* + * Selection of a file name for a temporary file. + * This is highly system-dependent, and you may want to customize it. + */ + +static int next_file_num; /* to distinguish among several temp files */ + +LOCAL(void) +select_file_name (char * fname) +{ + const char * env; + char * ptr; + FILE * tfile; + + /* Keep generating file names till we find one that's not in use */ + for (;;) { + /* Get temp directory name from environment TMP or TEMP variable; + * if none, use "." + */ + if ((env = (const char *) getenv("TMP")) == NULL) + if ((env = (const char *) getenv("TEMP")) == NULL) + env = "."; + if (*env == '\0') /* null string means "." */ + env = "."; + ptr = fname; /* copy name to fname */ + while (*env != '\0') + *ptr++ = *env++; + if (ptr[-1] != '\\' && ptr[-1] != '/') + *ptr++ = '\\'; /* append backslash if not in env variable */ + /* Append a suitable file name */ + next_file_num++; /* advance counter */ + sprintf(ptr, "JPG%03d.TMP", next_file_num); + /* Probe to see if file name is already in use */ + if ((tfile = fopen(fname, READ_BINARY)) == NULL) + break; + fclose(tfile); /* oops, it's there; close tfile & try again */ + } +} + + +/* + * Near-memory allocation and freeing are controlled by the regular library + * routines malloc() and free(). + */ + +GLOBAL(void *) +jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void *) malloc(sizeofobject); +} + +GLOBAL(void) +jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) +{ + free(object); +} + + +/* + * "Large" objects are allocated in far memory, if possible + */ + +GLOBAL(void FAR *) +jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void FAR *) far_malloc(sizeofobject); +} + +GLOBAL(void) +jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) +{ + far_free(object); +} + + +/* + * This routine computes the total memory space available for allocation. + * It's impossible to do this in a portable way; our current solution is + * to make the user tell us (with a default value set at compile time). + * If you can actually get the available space, it's a good idea to subtract + * a slop factor of 5% or so. + */ + +#ifndef DEFAULT_MAX_MEM /* so can override from makefile */ +#define DEFAULT_MAX_MEM 300000L /* for total usage about 450K */ +#endif + +GLOBAL(long) +jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, + long max_bytes_needed, long already_allocated) +{ + return cinfo->mem->max_memory_to_use - already_allocated; +} + + +/* + * Backing store (temporary file) management. + * Backing store objects are only used when the value returned by + * jpeg_mem_available is less than the total space needed. You can dispense + * with these routines if you have plenty of virtual memory; see jmemnobs.c. + */ + +/* + * For MS-DOS we support three types of backing storage: + * 1. Conventional DOS files. We access these by direct DOS calls rather + * than via the stdio package. This provides a bit better performance, + * but the real reason is that the buffers to be read or written are FAR. + * The stdio library for small-data memory models can't cope with that. + * 2. Extended memory, accessed per the XMS V2.0 specification. + * 3. Expanded memory, accessed per the LIM/EMS 4.0 specification. + * You'll need copies of those specs to make sense of the related code. + * The specs are available by Internet FTP from the SIMTEL archives + * (oak.oakland.edu and its various mirror sites). See files + * pub/msdos/microsoft/xms20.arc and pub/msdos/info/limems41.zip. + */ + + +/* + * Access methods for a DOS file. + */ + + +METHODDEF(void) +read_file_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + if (jdos_seek(info->handle.file_handle, file_offset)) + ERREXIT(cinfo, JERR_TFILE_SEEK); + /* Since MAX_ALLOC_CHUNK is less than 64K, byte_count will be too. */ + if (byte_count > 65535L) /* safety check */ + ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK); + if (jdos_read(info->handle.file_handle, buffer_address, + (unsigned short) byte_count)) + ERREXIT(cinfo, JERR_TFILE_READ); +} + + +METHODDEF(void) +write_file_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + if (jdos_seek(info->handle.file_handle, file_offset)) + ERREXIT(cinfo, JERR_TFILE_SEEK); + /* Since MAX_ALLOC_CHUNK is less than 64K, byte_count will be too. */ + if (byte_count > 65535L) /* safety check */ + ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK); + if (jdos_write(info->handle.file_handle, buffer_address, + (unsigned short) byte_count)) + ERREXIT(cinfo, JERR_TFILE_WRITE); +} + + +METHODDEF(void) +close_file_store (j_common_ptr cinfo, backing_store_ptr info) +{ + jdos_close(info->handle.file_handle); /* close the file */ + remove(info->temp_name); /* delete the file */ +/* If your system doesn't have remove(), try unlink() instead. + * remove() is the ANSI-standard name for this function, but + * unlink() was more common in pre-ANSI systems. + */ + TRACEMSS(cinfo, 1, JTRC_TFILE_CLOSE, info->temp_name); +} + + +LOCAL(boolean) +open_file_store (j_common_ptr cinfo, backing_store_ptr info, + long total_bytes_needed) +{ + short handle; + + select_file_name(info->temp_name); + if (jdos_open((short far *) & handle, (char far *) info->temp_name)) { + /* might as well exit since jpeg_open_backing_store will fail anyway */ + ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name); + return FALSE; + } + info->handle.file_handle = handle; + info->read_backing_store = read_file_store; + info->write_backing_store = write_file_store; + info->close_backing_store = close_file_store; + TRACEMSS(cinfo, 1, JTRC_TFILE_OPEN, info->temp_name); + return TRUE; /* succeeded */ +} + + +/* + * Access methods for extended memory. + */ + +#if XMS_SUPPORTED + +static XMSDRIVER xms_driver; /* saved address of XMS driver */ + +typedef union { /* either long offset or real-mode pointer */ + long offset; + void far * ptr; + } XMSPTR; + +typedef struct { /* XMS move specification structure */ + long length; + XMSH src_handle; + XMSPTR src; + XMSH dst_handle; + XMSPTR dst; + } XMSspec; + +#define ODD(X) (((X) & 1L) != 0) + + +METHODDEF(void) +read_xms_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + XMScontext ctx; + XMSspec spec; + char endbuffer[2]; + + /* The XMS driver can't cope with an odd length, so handle the last byte + * specially if byte_count is odd. We don't expect this to be common. + */ + + spec.length = byte_count & (~ 1L); + spec.src_handle = info->handle.xms_handle; + spec.src.offset = file_offset; + spec.dst_handle = 0; + spec.dst.ptr = buffer_address; + + ctx.ds_si = (void far *) & spec; + ctx.ax = 0x0b00; /* EMB move */ + jxms_calldriver(xms_driver, (XMScontext far *) & ctx); + if (ctx.ax != 1) + ERREXIT(cinfo, JERR_XMS_READ); + + if (ODD(byte_count)) { + read_xms_store(cinfo, info, (void FAR *) endbuffer, + file_offset + byte_count - 1L, 2L); + ((char FAR *) buffer_address)[byte_count - 1L] = endbuffer[0]; + } +} + + +METHODDEF(void) +write_xms_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + XMScontext ctx; + XMSspec spec; + char endbuffer[2]; + + /* The XMS driver can't cope with an odd length, so handle the last byte + * specially if byte_count is odd. We don't expect this to be common. + */ + + spec.length = byte_count & (~ 1L); + spec.src_handle = 0; + spec.src.ptr = buffer_address; + spec.dst_handle = info->handle.xms_handle; + spec.dst.offset = file_offset; + + ctx.ds_si = (void far *) & spec; + ctx.ax = 0x0b00; /* EMB move */ + jxms_calldriver(xms_driver, (XMScontext far *) & ctx); + if (ctx.ax != 1) + ERREXIT(cinfo, JERR_XMS_WRITE); + + if (ODD(byte_count)) { + read_xms_store(cinfo, info, (void FAR *) endbuffer, + file_offset + byte_count - 1L, 2L); + endbuffer[0] = ((char FAR *) buffer_address)[byte_count - 1L]; + write_xms_store(cinfo, info, (void FAR *) endbuffer, + file_offset + byte_count - 1L, 2L); + } +} + + +METHODDEF(void) +close_xms_store (j_common_ptr cinfo, backing_store_ptr info) +{ + XMScontext ctx; + + ctx.dx = info->handle.xms_handle; + ctx.ax = 0x0a00; + jxms_calldriver(xms_driver, (XMScontext far *) & ctx); + TRACEMS1(cinfo, 1, JTRC_XMS_CLOSE, info->handle.xms_handle); + /* we ignore any error return from the driver */ +} + + +LOCAL(boolean) +open_xms_store (j_common_ptr cinfo, backing_store_ptr info, + long total_bytes_needed) +{ + XMScontext ctx; + + /* Get address of XMS driver */ + jxms_getdriver((XMSDRIVER far *) & xms_driver); + if (xms_driver == NULL) + return FALSE; /* no driver to be had */ + + /* Get version number, must be >= 2.00 */ + ctx.ax = 0x0000; + jxms_calldriver(xms_driver, (XMScontext far *) & ctx); + if (ctx.ax < (unsigned short) 0x0200) + return FALSE; + + /* Try to get space (expressed in kilobytes) */ + ctx.dx = (unsigned short) ((total_bytes_needed + 1023L) >> 10); + ctx.ax = 0x0900; + jxms_calldriver(xms_driver, (XMScontext far *) & ctx); + if (ctx.ax != 1) + return FALSE; + + /* Succeeded, save the handle and away we go */ + info->handle.xms_handle = ctx.dx; + info->read_backing_store = read_xms_store; + info->write_backing_store = write_xms_store; + info->close_backing_store = close_xms_store; + TRACEMS1(cinfo, 1, JTRC_XMS_OPEN, ctx.dx); + return TRUE; /* succeeded */ +} + +#endif /* XMS_SUPPORTED */ + + +/* + * Access methods for expanded memory. + */ + +#if EMS_SUPPORTED + +/* The EMS move specification structure requires word and long fields aligned + * at odd byte boundaries. Some compilers will align struct fields at even + * byte boundaries. While it's usually possible to force byte alignment, + * that causes an overall performance penalty and may pose problems in merging + * JPEG into a larger application. Instead we accept some rather dirty code + * here. Note this code would fail if the hardware did not allow odd-byte + * word & long accesses, but all 80x86 CPUs do. + */ + +typedef void far * EMSPTR; + +typedef union { /* EMS move specification structure */ + long length; /* It's easy to access first 4 bytes */ + char bytes[18]; /* Misaligned fields in here! */ + } EMSspec; + +/* Macros for accessing misaligned fields */ +#define FIELD_AT(spec,offset,type) (*((type *) &(spec.bytes[offset]))) +#define SRC_TYPE(spec) FIELD_AT(spec,4,char) +#define SRC_HANDLE(spec) FIELD_AT(spec,5,EMSH) +#define SRC_OFFSET(spec) FIELD_AT(spec,7,unsigned short) +#define SRC_PAGE(spec) FIELD_AT(spec,9,unsigned short) +#define SRC_PTR(spec) FIELD_AT(spec,7,EMSPTR) +#define DST_TYPE(spec) FIELD_AT(spec,11,char) +#define DST_HANDLE(spec) FIELD_AT(spec,12,EMSH) +#define DST_OFFSET(spec) FIELD_AT(spec,14,unsigned short) +#define DST_PAGE(spec) FIELD_AT(spec,16,unsigned short) +#define DST_PTR(spec) FIELD_AT(spec,14,EMSPTR) + +#define EMSPAGESIZE 16384L /* gospel, see the EMS specs */ + +#define HIBYTE(W) (((W) >> 8) & 0xFF) +#define LOBYTE(W) ((W) & 0xFF) + + +METHODDEF(void) +read_ems_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + EMScontext ctx; + EMSspec spec; + + spec.length = byte_count; + SRC_TYPE(spec) = 1; + SRC_HANDLE(spec) = info->handle.ems_handle; + SRC_PAGE(spec) = (unsigned short) (file_offset / EMSPAGESIZE); + SRC_OFFSET(spec) = (unsigned short) (file_offset % EMSPAGESIZE); + DST_TYPE(spec) = 0; + DST_HANDLE(spec) = 0; + DST_PTR(spec) = buffer_address; + + ctx.ds_si = (void far *) & spec; + ctx.ax = 0x5700; /* move memory region */ + jems_calldriver((EMScontext far *) & ctx); + if (HIBYTE(ctx.ax) != 0) + ERREXIT(cinfo, JERR_EMS_READ); +} + + +METHODDEF(void) +write_ems_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + EMScontext ctx; + EMSspec spec; + + spec.length = byte_count; + SRC_TYPE(spec) = 0; + SRC_HANDLE(spec) = 0; + SRC_PTR(spec) = buffer_address; + DST_TYPE(spec) = 1; + DST_HANDLE(spec) = info->handle.ems_handle; + DST_PAGE(spec) = (unsigned short) (file_offset / EMSPAGESIZE); + DST_OFFSET(spec) = (unsigned short) (file_offset % EMSPAGESIZE); + + ctx.ds_si = (void far *) & spec; + ctx.ax = 0x5700; /* move memory region */ + jems_calldriver((EMScontext far *) & ctx); + if (HIBYTE(ctx.ax) != 0) + ERREXIT(cinfo, JERR_EMS_WRITE); +} + + +METHODDEF(void) +close_ems_store (j_common_ptr cinfo, backing_store_ptr info) +{ + EMScontext ctx; + + ctx.ax = 0x4500; + ctx.dx = info->handle.ems_handle; + jems_calldriver((EMScontext far *) & ctx); + TRACEMS1(cinfo, 1, JTRC_EMS_CLOSE, info->handle.ems_handle); + /* we ignore any error return from the driver */ +} + + +LOCAL(boolean) +open_ems_store (j_common_ptr cinfo, backing_store_ptr info, + long total_bytes_needed) +{ + EMScontext ctx; + + /* Is EMS driver there? */ + if (! jems_available()) + return FALSE; + + /* Get status, make sure EMS is OK */ + ctx.ax = 0x4000; + jems_calldriver((EMScontext far *) & ctx); + if (HIBYTE(ctx.ax) != 0) + return FALSE; + + /* Get version, must be >= 4.0 */ + ctx.ax = 0x4600; + jems_calldriver((EMScontext far *) & ctx); + if (HIBYTE(ctx.ax) != 0 || LOBYTE(ctx.ax) < 0x40) + return FALSE; + + /* Try to allocate requested space */ + ctx.ax = 0x4300; + ctx.bx = (unsigned short) ((total_bytes_needed + EMSPAGESIZE-1L) / EMSPAGESIZE); + jems_calldriver((EMScontext far *) & ctx); + if (HIBYTE(ctx.ax) != 0) + return FALSE; + + /* Succeeded, save the handle and away we go */ + info->handle.ems_handle = ctx.dx; + info->read_backing_store = read_ems_store; + info->write_backing_store = write_ems_store; + info->close_backing_store = close_ems_store; + TRACEMS1(cinfo, 1, JTRC_EMS_OPEN, ctx.dx); + return TRUE; /* succeeded */ +} + +#endif /* EMS_SUPPORTED */ + + +/* + * Initial opening of a backing-store object. + */ + +GLOBAL(void) +jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, + long total_bytes_needed) +{ + /* Try extended memory, then expanded memory, then regular file. */ +#if XMS_SUPPORTED + if (open_xms_store(cinfo, info, total_bytes_needed)) + return; +#endif +#if EMS_SUPPORTED + if (open_ems_store(cinfo, info, total_bytes_needed)) + return; +#endif + if (open_file_store(cinfo, info, total_bytes_needed)) + return; + ERREXITS(cinfo, JERR_TFILE_CREATE, ""); +} + + +/* + * These routines take care of any system-dependent initialization and + * cleanup required. + */ + +GLOBAL(long) +jpeg_mem_init (j_common_ptr cinfo) +{ + next_file_num = 0; /* initialize temp file name generator */ + return DEFAULT_MAX_MEM; /* default for max_memory_to_use */ +} + +GLOBAL(void) +jpeg_mem_term (j_common_ptr cinfo) +{ + /* Microsoft C, at least in v6.00A, will not successfully reclaim freed + * blocks of size > 32Kbytes unless we give it a kick in the rear, like so: + */ +#ifdef NEED_FHEAPMIN + _fheapmin(); +#endif +} diff --git a/gs/jpeg/jmemdosa.asm b/gs/jpeg/jmemdosa.asm new file mode 100644 index 000000000..ecd43729f --- /dev/null +++ b/gs/jpeg/jmemdosa.asm @@ -0,0 +1,379 @@ +; +; jmemdosa.asm +; +; Copyright (C) 1992, Thomas G. Lane. +; This file is part of the Independent JPEG Group's software. +; For conditions of distribution and use, see the accompanying README file. +; +; This file contains low-level interface routines to support the MS-DOS +; backing store manager (jmemdos.c). Routines are provided to access disk +; files through direct DOS calls, and to access XMS and EMS drivers. +; +; This file should assemble with Microsoft's MASM or any compatible +; assembler (including Borland's Turbo Assembler). If you haven't got +; a compatible assembler, better fall back to jmemansi.c or jmemname.c. +; +; To minimize dependence on the C compiler's register usage conventions, +; we save and restore all 8086 registers, even though most compilers only +; require SI,DI,DS to be preserved. Also, we use only 16-bit-wide return +; values, which everybody returns in AX. +; +; Based on code contributed by Ge' Weijers. +; + +JMEMDOSA_TXT segment byte public 'CODE' + + assume cs:JMEMDOSA_TXT + + public _jdos_open + public _jdos_close + public _jdos_seek + public _jdos_read + public _jdos_write + public _jxms_getdriver + public _jxms_calldriver + public _jems_available + public _jems_calldriver + +; +; short far jdos_open (short far * handle, char far * filename) +; +; Create and open a temporary file +; +_jdos_open proc far + push bp ; linkage + mov bp,sp + push si ; save all registers for safety + push di + push bx + push cx + push dx + push es + push ds + mov cx,0 ; normal file attributes + lds dx,dword ptr [bp+10] ; get filename pointer + mov ah,3ch ; create file + int 21h + jc open_err ; if failed, return error code + lds bx,dword ptr [bp+6] ; get handle pointer + mov word ptr [bx],ax ; save the handle + xor ax,ax ; return zero for OK +open_err: pop ds ; restore registers and exit + pop es + pop dx + pop cx + pop bx + pop di + pop si + pop bp + ret +_jdos_open endp + + +; +; short far jdos_close (short handle) +; +; Close the file handle +; +_jdos_close proc far + push bp ; linkage + mov bp,sp + push si ; save all registers for safety + push di + push bx + push cx + push dx + push es + push ds + mov bx,word ptr [bp+6] ; file handle + mov ah,3eh ; close file + int 21h + jc close_err ; if failed, return error code + xor ax,ax ; return zero for OK +close_err: pop ds ; restore registers and exit + pop es + pop dx + pop cx + pop bx + pop di + pop si + pop bp + ret +_jdos_close endp + + +; +; short far jdos_seek (short handle, long offset) +; +; Set file position +; +_jdos_seek proc far + push bp ; linkage + mov bp,sp + push si ; save all registers for safety + push di + push bx + push cx + push dx + push es + push ds + mov bx,word ptr [bp+6] ; file handle + mov dx,word ptr [bp+8] ; LS offset + mov cx,word ptr [bp+10] ; MS offset + mov ax,4200h ; absolute seek + int 21h + jc seek_err ; if failed, return error code + xor ax,ax ; return zero for OK +seek_err: pop ds ; restore registers and exit + pop es + pop dx + pop cx + pop bx + pop di + pop si + pop bp + ret +_jdos_seek endp + + +; +; short far jdos_read (short handle, void far * buffer, unsigned short count) +; +; Read from file +; +_jdos_read proc far + push bp ; linkage + mov bp,sp + push si ; save all registers for safety + push di + push bx + push cx + push dx + push es + push ds + mov bx,word ptr [bp+6] ; file handle + lds dx,dword ptr [bp+8] ; buffer address + mov cx,word ptr [bp+12] ; number of bytes + mov ah,3fh ; read file + int 21h + jc read_err ; if failed, return error code + cmp ax,word ptr [bp+12] ; make sure all bytes were read + je read_ok + mov ax,1 ; else return 1 for not OK + jmp short read_err +read_ok: xor ax,ax ; return zero for OK +read_err: pop ds ; restore registers and exit + pop es + pop dx + pop cx + pop bx + pop di + pop si + pop bp + ret +_jdos_read endp + + +; +; short far jdos_write (short handle, void far * buffer, unsigned short count) +; +; Write to file +; +_jdos_write proc far + push bp ; linkage + mov bp,sp + push si ; save all registers for safety + push di + push bx + push cx + push dx + push es + push ds + mov bx,word ptr [bp+6] ; file handle + lds dx,dword ptr [bp+8] ; buffer address + mov cx,word ptr [bp+12] ; number of bytes + mov ah,40h ; write file + int 21h + jc write_err ; if failed, return error code + cmp ax,word ptr [bp+12] ; make sure all bytes written + je write_ok + mov ax,1 ; else return 1 for not OK + jmp short write_err +write_ok: xor ax,ax ; return zero for OK +write_err: pop ds ; restore registers and exit + pop es + pop dx + pop cx + pop bx + pop di + pop si + pop bp + ret +_jdos_write endp + + +; +; void far jxms_getdriver (XMSDRIVER far *) +; +; Get the address of the XMS driver, or NULL if not available +; +_jxms_getdriver proc far + push bp ; linkage + mov bp,sp + push si ; save all registers for safety + push di + push bx + push cx + push dx + push es + push ds + mov ax,4300h ; call multiplex interrupt with + int 2fh ; a magic cookie, hex 4300 + cmp al,80h ; AL should contain hex 80 + je xmsavail + xor dx,dx ; no XMS driver available + xor ax,ax ; return a nil pointer + jmp short xmsavail_done +xmsavail: mov ax,4310h ; fetch driver address with + int 2fh ; another magic cookie + mov dx,es ; copy address to dx:ax + mov ax,bx +xmsavail_done: les bx,dword ptr [bp+6] ; get pointer to return value + mov word ptr es:[bx],ax + mov word ptr es:[bx+2],dx + pop ds ; restore registers and exit + pop es + pop dx + pop cx + pop bx + pop di + pop si + pop bp + ret +_jxms_getdriver endp + + +; +; void far jxms_calldriver (XMSDRIVER, XMScontext far *) +; +; The XMScontext structure contains values for the AX,DX,BX,SI,DS registers. +; These are loaded, the XMS call is performed, and the new values of the +; AX,DX,BX registers are written back to the context structure. +; +_jxms_calldriver proc far + push bp ; linkage + mov bp,sp + push si ; save all registers for safety + push di + push bx + push cx + push dx + push es + push ds + les bx,dword ptr [bp+10] ; get XMScontext pointer + mov ax,word ptr es:[bx] ; load registers + mov dx,word ptr es:[bx+2] + mov si,word ptr es:[bx+6] + mov ds,word ptr es:[bx+8] + mov bx,word ptr es:[bx+4] + call dword ptr [bp+6] ; call the driver + mov cx,bx ; save returned BX for a sec + les bx,dword ptr [bp+10] ; get XMScontext pointer + mov word ptr es:[bx],ax ; put back ax,dx,bx + mov word ptr es:[bx+2],dx + mov word ptr es:[bx+4],cx + pop ds ; restore registers and exit + pop es + pop dx + pop cx + pop bx + pop di + pop si + pop bp + ret +_jxms_calldriver endp + + +; +; short far jems_available (void) +; +; Have we got an EMS driver? (this comes straight from the EMS 4.0 specs) +; +_jems_available proc far + push si ; save all registers for safety + push di + push bx + push cx + push dx + push es + push ds + mov ax,3567h ; get interrupt vector 67h + int 21h + push cs + pop ds + mov di,000ah ; check offs 10 in returned seg + lea si,ASCII_device_name ; against literal string + mov cx,8 + cld + repe cmpsb + jne no_ems + mov ax,1 ; match, it's there + jmp short avail_done +no_ems: xor ax,ax ; it's not there +avail_done: pop ds ; restore registers and exit + pop es + pop dx + pop cx + pop bx + pop di + pop si + ret + +ASCII_device_name db "EMMXXXX0" + +_jems_available endp + + +; +; void far jems_calldriver (EMScontext far *) +; +; The EMScontext structure contains values for the AX,DX,BX,SI,DS registers. +; These are loaded, the EMS trap is performed, and the new values of the +; AX,DX,BX registers are written back to the context structure. +; +_jems_calldriver proc far + push bp ; linkage + mov bp,sp + push si ; save all registers for safety + push di + push bx + push cx + push dx + push es + push ds + les bx,dword ptr [bp+6] ; get EMScontext pointer + mov ax,word ptr es:[bx] ; load registers + mov dx,word ptr es:[bx+2] + mov si,word ptr es:[bx+6] + mov ds,word ptr es:[bx+8] + mov bx,word ptr es:[bx+4] + int 67h ; call the EMS driver + mov cx,bx ; save returned BX for a sec + les bx,dword ptr [bp+6] ; get EMScontext pointer + mov word ptr es:[bx],ax ; put back ax,dx,bx + mov word ptr es:[bx+2],dx + mov word ptr es:[bx+4],cx + pop ds ; restore registers and exit + pop es + pop dx + pop cx + pop bx + pop di + pop si + pop bp + ret +_jems_calldriver endp + +JMEMDOSA_TXT ends + + end diff --git a/gs/jpeg/jmemmac.c b/gs/jpeg/jmemmac.c new file mode 100644 index 000000000..41756cb03 --- /dev/null +++ b/gs/jpeg/jmemmac.c @@ -0,0 +1,199 @@ +/* + * jmemmac.c + * + * Copyright (C) 1992-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * jmemmac.c provides an Apple Macintosh implementation of the system- + * dependent portion of the JPEG memory manager. + * + * jmemmac.c uses the Macintosh toolbox routines NewPtr and DisposePtr + * instead of malloc and free. It accurately determines the amount of + * memory available by using CompactMem. Notice that if left to its + * own devices, this code can chew up all available space in the + * application's zone, with the exception of the rather small "slop" + * factor computed in jpeg_mem_available(). The application can ensure + * that more space is left over by reducing max_memory_to_use. + * + * Large images are swapped to disk using temporary files created with + * tmpfile(); that part of the module is the same as in jmemansi.c. + * Metrowerks CodeWarrior's implementation of tmpfile() isn't quite what + * we want: it puts the files in the local directory and makes them + * user-visible -- and only deletes them when the application quits, + * which means they stick around in the event of a crash. + * It would be better to create the temp files in the system's temporary + * items folder. Perhaps someday we'll get around to doing that. + * + * Contributed by Sam Bushell (jsam@iagu.on.net). + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jmemsys.h" /* import the system-dependent declarations */ + +#include /* we use the MacOS memory manager */ + +#ifndef SEEK_SET /* pre-ANSI systems may not define this; */ +#define SEEK_SET 0 /* if not, assume 0 is correct */ +#endif + + +/* + * Memory allocation and freeing are controlled by the MacOS library + * routines NewPtr() and DisposePtr(), which allocate fixed-address + * storage. Unfortunately, the IJG library isn't smart enough to cope + * with relocatable storage. + */ + +GLOBAL(void *) +jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void *) NewPtr(sizeofobject); +} + +GLOBAL(void) +jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) +{ + DisposePtr((Ptr) object); +} + + +/* + * "Large" objects are treated the same as "small" ones. + * NB: we include FAR keywords in the routine declarations simply for + * consistency with the rest of the IJG code; FAR should expand to empty + * on rational architectures like the Mac. + */ + +GLOBAL(void FAR *) +jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void FAR *) NewPtr(sizeofobject); +} + +GLOBAL(void) +jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) +{ + DisposePtr((Ptr) object); +} + + +/* + * This routine computes the total memory space available for allocation. + */ + +GLOBAL(long) +jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, + long max_bytes_needed, long already_allocated) +{ + long limit = cinfo->mem->max_memory_to_use - already_allocated; + long slop, mem; + + /* Don't ask for more than what application has told us we may use */ + if (max_bytes_needed > limit && limit > 0) + max_bytes_needed = limit; + /* Find whether there's a big enough free block in the heap. + * CompactMem tries to create a contiguous block of the requested size, + * and then returns the size of the largest free block (which could be + * much more or much less than we asked for). + * We add some slop to ensure we don't use up all available memory. + */ + slop = max_bytes_needed / 16 + 32768L; + mem = CompactMem(max_bytes_needed + slop) - slop; + if (mem < 0) + mem = 0; /* sigh, couldn't even get the slop */ + /* Don't take more than the application says we can have */ + if (mem > limit && limit > 0) + mem = limit; + return mem; +} + + +/* + * Backing store (temporary file) management. + * Backing store objects are only used when the value returned by + * jpeg_mem_available is less than the total space needed. You can dispense + * with these routines if you have plenty of virtual memory; see jmemnobs.c. + */ + + +METHODDEF(void) +read_backing_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + if (fseek(info->temp_file, file_offset, SEEK_SET)) + ERREXIT(cinfo, JERR_TFILE_SEEK); + if (JFREAD(info->temp_file, buffer_address, byte_count) + != (size_t) byte_count) + ERREXIT(cinfo, JERR_TFILE_READ); +} + + +METHODDEF(void) +write_backing_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + if (fseek(info->temp_file, file_offset, SEEK_SET)) + ERREXIT(cinfo, JERR_TFILE_SEEK); + if (JFWRITE(info->temp_file, buffer_address, byte_count) + != (size_t) byte_count) + ERREXIT(cinfo, JERR_TFILE_WRITE); +} + + +METHODDEF(void) +close_backing_store (j_common_ptr cinfo, backing_store_ptr info) +{ + fclose(info->temp_file); + /* Since this implementation uses tmpfile() to create the file, + * no explicit file deletion is needed. + */ +} + + +/* + * Initial opening of a backing-store object. + * + * This version uses tmpfile(), which constructs a suitable file name + * behind the scenes. We don't have to use info->temp_name[] at all; + * indeed, we can't even find out the actual name of the temp file. + */ + +GLOBAL(void) +jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, + long total_bytes_needed) +{ + if ((info->temp_file = tmpfile()) == NULL) + ERREXITS(cinfo, JERR_TFILE_CREATE, ""); + info->read_backing_store = read_backing_store; + info->write_backing_store = write_backing_store; + info->close_backing_store = close_backing_store; +} + + +/* + * These routines take care of any system-dependent initialization and + * cleanup required. + */ + +GLOBAL(long) +jpeg_mem_init (j_common_ptr cinfo) +{ + /* max_memory_to_use will be initialized to FreeMem()'s result; + * the calling application might later reduce it, for example + * to leave room to invoke multiple JPEG objects. + * Note that FreeMem returns the total number of free bytes; + * it may not be possible to allocate a single block of this size. + */ + return FreeMem(); +} + +GLOBAL(void) +jpeg_mem_term (j_common_ptr cinfo) +{ + /* no work */ +} diff --git a/gs/jpeg/jmemmgr.c b/gs/jpeg/jmemmgr.c new file mode 100644 index 000000000..5ea19ce14 --- /dev/null +++ b/gs/jpeg/jmemmgr.c @@ -0,0 +1,1115 @@ +/* + * jmemmgr.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the JPEG system-independent memory management + * routines. This code is usable across a wide variety of machines; most + * of the system dependencies have been isolated in a separate file. + * The major functions provided here are: + * * pool-based allocation and freeing of memory; + * * policy decisions about how to divide available memory among the + * virtual arrays; + * * control logic for swapping virtual arrays between main memory and + * backing storage. + * The separate system-dependent file provides the actual backing-storage + * access code, and it contains the policy decision about how much total + * main memory to use. + * This file is system-dependent in the sense that some of its functions + * are unnecessary in some systems. For example, if there is enough virtual + * memory so that backing storage will never be used, much of the virtual + * array control logic could be removed. (Of course, if you have that much + * memory then you shouldn't care about a little bit of unused code...) + */ + +#define JPEG_INTERNALS +#define AM_MEMORY_MANAGER /* we define jvirt_Xarray_control structs */ +#include "jinclude.h" +#include "jpeglib.h" +#include "jmemsys.h" /* import the system-dependent declarations */ + +#ifndef NO_GETENV +#ifndef HAVE_STDLIB_H /* should declare getenv() */ +extern char * getenv JPP((const char * name)); +#endif +#endif + + +/* + * Some important notes: + * The allocation routines provided here must never return NULL. + * They should exit to error_exit if unsuccessful. + * + * It's not a good idea to try to merge the sarray and barray routines, + * even though they are textually almost the same, because samples are + * usually stored as bytes while coefficients are shorts or ints. Thus, + * in machines where byte pointers have a different representation from + * word pointers, the resulting machine code could not be the same. + */ + + +/* + * Many machines require storage alignment: longs must start on 4-byte + * boundaries, doubles on 8-byte boundaries, etc. On such machines, malloc() + * always returns pointers that are multiples of the worst-case alignment + * requirement, and we had better do so too. + * There isn't any really portable way to determine the worst-case alignment + * requirement. This module assumes that the alignment requirement is + * multiples of sizeof(ALIGN_TYPE). + * By default, we define ALIGN_TYPE as double. This is necessary on some + * workstations (where doubles really do need 8-byte alignment) and will work + * fine on nearly everything. If your machine has lesser alignment needs, + * you can save a few bytes by making ALIGN_TYPE smaller. + * The only place I know of where this will NOT work is certain Macintosh + * 680x0 compilers that define double as a 10-byte IEEE extended float. + * Doing 10-byte alignment is counterproductive because longwords won't be + * aligned well. Put "#define ALIGN_TYPE long" in jconfig.h if you have + * such a compiler. + */ + +#ifndef ALIGN_TYPE /* so can override from jconfig.h */ +#define ALIGN_TYPE double +#endif + + +/* + * We allocate objects from "pools", where each pool is gotten with a single + * request to jpeg_get_small() or jpeg_get_large(). There is no per-object + * overhead within a pool, except for alignment padding. Each pool has a + * header with a link to the next pool of the same class. + * Small and large pool headers are identical except that the latter's + * link pointer must be FAR on 80x86 machines. + * Notice that the "real" header fields are union'ed with a dummy ALIGN_TYPE + * field. This forces the compiler to make SIZEOF(small_pool_hdr) a multiple + * of the alignment requirement of ALIGN_TYPE. + */ + +typedef union small_pool_struct * small_pool_ptr; + +typedef union small_pool_struct { + struct { + small_pool_ptr next; /* next in list of pools */ + size_t bytes_used; /* how many bytes already used within pool */ + size_t bytes_left; /* bytes still available in this pool */ + } hdr; + ALIGN_TYPE dummy; /* included in union to ensure alignment */ +} small_pool_hdr; + +typedef union large_pool_struct FAR * large_pool_ptr; + +typedef union large_pool_struct { + struct { + large_pool_ptr next; /* next in list of pools */ + size_t bytes_used; /* how many bytes already used within pool */ + size_t bytes_left; /* bytes still available in this pool */ + } hdr; + ALIGN_TYPE dummy; /* included in union to ensure alignment */ +} large_pool_hdr; + + +/* + * Here is the full definition of a memory manager object. + */ + +typedef struct { + struct jpeg_memory_mgr pub; /* public fields */ + + /* Each pool identifier (lifetime class) names a linked list of pools. */ + small_pool_ptr small_list[JPOOL_NUMPOOLS]; + large_pool_ptr large_list[JPOOL_NUMPOOLS]; + + /* Since we only have one lifetime class of virtual arrays, only one + * linked list is necessary (for each datatype). Note that the virtual + * array control blocks being linked together are actually stored somewhere + * in the small-pool list. + */ + jvirt_sarray_ptr virt_sarray_list; + jvirt_barray_ptr virt_barray_list; + + /* This counts total space obtained from jpeg_get_small/large */ + long total_space_allocated; + + /* alloc_sarray and alloc_barray set this value for use by virtual + * array routines. + */ + JDIMENSION last_rowsperchunk; /* from most recent alloc_sarray/barray */ +} my_memory_mgr; + +typedef my_memory_mgr * my_mem_ptr; + + +/* + * The control blocks for virtual arrays. + * Note that these blocks are allocated in the "small" pool area. + * System-dependent info for the associated backing store (if any) is hidden + * inside the backing_store_info struct. + */ + +struct jvirt_sarray_control { + JSAMPARRAY mem_buffer; /* => the in-memory buffer */ + JDIMENSION rows_in_array; /* total virtual array height */ + JDIMENSION samplesperrow; /* width of array (and of memory buffer) */ + JDIMENSION maxaccess; /* max rows accessed by access_virt_sarray */ + JDIMENSION rows_in_mem; /* height of memory buffer */ + JDIMENSION rowsperchunk; /* allocation chunk size in mem_buffer */ + JDIMENSION cur_start_row; /* first logical row # in the buffer */ + JDIMENSION first_undef_row; /* row # of first uninitialized row */ + boolean pre_zero; /* pre-zero mode requested? */ + boolean dirty; /* do current buffer contents need written? */ + boolean b_s_open; /* is backing-store data valid? */ + jvirt_sarray_ptr next; /* link to next virtual sarray control block */ + backing_store_info b_s_info; /* System-dependent control info */ +}; + +struct jvirt_barray_control { + JBLOCKARRAY mem_buffer; /* => the in-memory buffer */ + JDIMENSION rows_in_array; /* total virtual array height */ + JDIMENSION blocksperrow; /* width of array (and of memory buffer) */ + JDIMENSION maxaccess; /* max rows accessed by access_virt_barray */ + JDIMENSION rows_in_mem; /* height of memory buffer */ + JDIMENSION rowsperchunk; /* allocation chunk size in mem_buffer */ + JDIMENSION cur_start_row; /* first logical row # in the buffer */ + JDIMENSION first_undef_row; /* row # of first uninitialized row */ + boolean pre_zero; /* pre-zero mode requested? */ + boolean dirty; /* do current buffer contents need written? */ + boolean b_s_open; /* is backing-store data valid? */ + jvirt_barray_ptr next; /* link to next virtual barray control block */ + backing_store_info b_s_info; /* System-dependent control info */ +}; + + +#ifdef MEM_STATS /* optional extra stuff for statistics */ + +LOCAL(void) +print_mem_stats (j_common_ptr cinfo, int pool_id) +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + small_pool_ptr shdr_ptr; + large_pool_ptr lhdr_ptr; + + /* Since this is only a debugging stub, we can cheat a little by using + * fprintf directly rather than going through the trace message code. + * This is helpful because message parm array can't handle longs. + */ + fprintf(stderr, "Freeing pool %d, total space = %ld\n", + pool_id, mem->total_space_allocated); + + for (lhdr_ptr = mem->large_list[pool_id]; lhdr_ptr != NULL; + lhdr_ptr = lhdr_ptr->hdr.next) { + fprintf(stderr, " Large chunk used %ld\n", + (long) lhdr_ptr->hdr.bytes_used); + } + + for (shdr_ptr = mem->small_list[pool_id]; shdr_ptr != NULL; + shdr_ptr = shdr_ptr->hdr.next) { + fprintf(stderr, " Small chunk used %ld free %ld\n", + (long) shdr_ptr->hdr.bytes_used, + (long) shdr_ptr->hdr.bytes_left); + } +} + +#endif /* MEM_STATS */ + + +LOCAL(void) +out_of_memory (j_common_ptr cinfo, int which) +/* Report an out-of-memory error and stop execution */ +/* If we compiled MEM_STATS support, report alloc requests before dying */ +{ +#ifdef MEM_STATS + cinfo->err->trace_level = 2; /* force self_destruct to report stats */ +#endif + ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, which); +} + + +/* + * Allocation of "small" objects. + * + * For these, we use pooled storage. When a new pool must be created, + * we try to get enough space for the current request plus a "slop" factor, + * where the slop will be the amount of leftover space in the new pool. + * The speed vs. space tradeoff is largely determined by the slop values. + * A different slop value is provided for each pool class (lifetime), + * and we also distinguish the first pool of a class from later ones. + * NOTE: the values given work fairly well on both 16- and 32-bit-int + * machines, but may be too small if longs are 64 bits or more. + */ + +static const size_t first_pool_slop[JPOOL_NUMPOOLS] = +{ + 1600, /* first PERMANENT pool */ + 16000 /* first IMAGE pool */ +}; + +static const size_t extra_pool_slop[JPOOL_NUMPOOLS] = +{ + 0, /* additional PERMANENT pools */ + 5000 /* additional IMAGE pools */ +}; + +#define MIN_SLOP 50 /* greater than 0 to avoid futile looping */ + + +METHODDEF(void *) +alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject) +/* Allocate a "small" object */ +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + small_pool_ptr hdr_ptr, prev_hdr_ptr; + char * data_ptr; + size_t odd_bytes, min_request, slop; + + /* Check for unsatisfiable request (do now to ensure no overflow below) */ + if (sizeofobject > (size_t) (MAX_ALLOC_CHUNK-SIZEOF(small_pool_hdr))) + out_of_memory(cinfo, 1); /* request exceeds malloc's ability */ + + /* Round up the requested size to a multiple of SIZEOF(ALIGN_TYPE) */ + odd_bytes = sizeofobject % SIZEOF(ALIGN_TYPE); + if (odd_bytes > 0) + sizeofobject += SIZEOF(ALIGN_TYPE) - odd_bytes; + + /* See if space is available in any existing pool */ + if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS) + ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ + prev_hdr_ptr = NULL; + hdr_ptr = mem->small_list[pool_id]; + while (hdr_ptr != NULL) { + if (hdr_ptr->hdr.bytes_left >= sizeofobject) + break; /* found pool with enough space */ + prev_hdr_ptr = hdr_ptr; + hdr_ptr = hdr_ptr->hdr.next; + } + + /* Time to make a new pool? */ + if (hdr_ptr == NULL) { + /* min_request is what we need now, slop is what will be leftover */ + min_request = sizeofobject + SIZEOF(small_pool_hdr); + if (prev_hdr_ptr == NULL) /* first pool in class? */ + slop = first_pool_slop[pool_id]; + else + slop = extra_pool_slop[pool_id]; + /* Don't ask for more than MAX_ALLOC_CHUNK */ + if (slop > (size_t) (MAX_ALLOC_CHUNK-min_request)) + slop = (size_t) (MAX_ALLOC_CHUNK-min_request); + /* Try to get space, if fail reduce slop and try again */ + for (;;) { + hdr_ptr = (small_pool_ptr) jpeg_get_small(cinfo, min_request + slop); + if (hdr_ptr != NULL) + break; + slop /= 2; + if (slop < MIN_SLOP) /* give up when it gets real small */ + out_of_memory(cinfo, 2); /* jpeg_get_small failed */ + } + mem->total_space_allocated += min_request + slop; + /* Success, initialize the new pool header and add to end of list */ + hdr_ptr->hdr.next = NULL; + hdr_ptr->hdr.bytes_used = 0; + hdr_ptr->hdr.bytes_left = sizeofobject + slop; + if (prev_hdr_ptr == NULL) /* first pool in class? */ + mem->small_list[pool_id] = hdr_ptr; + else + prev_hdr_ptr->hdr.next = hdr_ptr; + } + + /* OK, allocate the object from the current pool */ + data_ptr = (char *) (hdr_ptr + 1); /* point to first data byte in pool */ + data_ptr += hdr_ptr->hdr.bytes_used; /* point to place for object */ + hdr_ptr->hdr.bytes_used += sizeofobject; + hdr_ptr->hdr.bytes_left -= sizeofobject; + + return (void *) data_ptr; +} + + +/* + * Allocation of "large" objects. + * + * The external semantics of these are the same as "small" objects, + * except that FAR pointers are used on 80x86. However the pool + * management heuristics are quite different. We assume that each + * request is large enough that it may as well be passed directly to + * jpeg_get_large; the pool management just links everything together + * so that we can free it all on demand. + * Note: the major use of "large" objects is in JSAMPARRAY and JBLOCKARRAY + * structures. The routines that create these structures (see below) + * deliberately bunch rows together to ensure a large request size. + */ + +METHODDEF(void FAR *) +alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject) +/* Allocate a "large" object */ +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + large_pool_ptr hdr_ptr; + size_t odd_bytes; + + /* Check for unsatisfiable request (do now to ensure no overflow below) */ + if (sizeofobject > (size_t) (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr))) + out_of_memory(cinfo, 3); /* request exceeds malloc's ability */ + + /* Round up the requested size to a multiple of SIZEOF(ALIGN_TYPE) */ + odd_bytes = sizeofobject % SIZEOF(ALIGN_TYPE); + if (odd_bytes > 0) + sizeofobject += SIZEOF(ALIGN_TYPE) - odd_bytes; + + /* Always make a new pool */ + if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS) + ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ + + hdr_ptr = (large_pool_ptr) jpeg_get_large(cinfo, sizeofobject + + SIZEOF(large_pool_hdr)); + if (hdr_ptr == NULL) + out_of_memory(cinfo, 4); /* jpeg_get_large failed */ + mem->total_space_allocated += sizeofobject + SIZEOF(large_pool_hdr); + + /* Success, initialize the new pool header and add to list */ + hdr_ptr->hdr.next = mem->large_list[pool_id]; + /* We maintain space counts in each pool header for statistical purposes, + * even though they are not needed for allocation. + */ + hdr_ptr->hdr.bytes_used = sizeofobject; + hdr_ptr->hdr.bytes_left = 0; + mem->large_list[pool_id] = hdr_ptr; + + return (void FAR *) (hdr_ptr + 1); /* point to first data byte in pool */ +} + + +/* + * Creation of 2-D sample arrays. + * The pointers are in near heap, the samples themselves in FAR heap. + * + * To minimize allocation overhead and to allow I/O of large contiguous + * blocks, we allocate the sample rows in groups of as many rows as possible + * without exceeding MAX_ALLOC_CHUNK total bytes per allocation request. + * NB: the virtual array control routines, later in this file, know about + * this chunking of rows. The rowsperchunk value is left in the mem manager + * object so that it can be saved away if this sarray is the workspace for + * a virtual array. + */ + +METHODDEF(JSAMPARRAY) +alloc_sarray (j_common_ptr cinfo, int pool_id, + JDIMENSION samplesperrow, JDIMENSION numrows) +/* Allocate a 2-D sample array */ +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + JSAMPARRAY result; + JSAMPROW workspace; + JDIMENSION rowsperchunk, currow, i; + long ltemp; + + /* Calculate max # of rows allowed in one allocation chunk */ + ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) / + ((long) samplesperrow * SIZEOF(JSAMPLE)); + if (ltemp <= 0) + ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); + if (ltemp < (long) numrows) + rowsperchunk = (JDIMENSION) ltemp; + else + rowsperchunk = numrows; + mem->last_rowsperchunk = rowsperchunk; + + /* Get space for row pointers (small object) */ + result = (JSAMPARRAY) alloc_small(cinfo, pool_id, + (size_t) (numrows * SIZEOF(JSAMPROW))); + + /* Get the rows themselves (large objects) */ + currow = 0; + while (currow < numrows) { + rowsperchunk = MIN(rowsperchunk, numrows - currow); + workspace = (JSAMPROW) alloc_large(cinfo, pool_id, + (size_t) ((size_t) rowsperchunk * (size_t) samplesperrow + * SIZEOF(JSAMPLE))); + for (i = rowsperchunk; i > 0; i--) { + result[currow++] = workspace; + workspace += samplesperrow; + } + } + + return result; +} + + +/* + * Creation of 2-D coefficient-block arrays. + * This is essentially the same as the code for sample arrays, above. + */ + +METHODDEF(JBLOCKARRAY) +alloc_barray (j_common_ptr cinfo, int pool_id, + JDIMENSION blocksperrow, JDIMENSION numrows) +/* Allocate a 2-D coefficient-block array */ +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + JBLOCKARRAY result; + JBLOCKROW workspace; + JDIMENSION rowsperchunk, currow, i; + long ltemp; + + /* Calculate max # of rows allowed in one allocation chunk */ + ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) / + ((long) blocksperrow * SIZEOF(JBLOCK)); + if (ltemp <= 0) + ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); + if (ltemp < (long) numrows) + rowsperchunk = (JDIMENSION) ltemp; + else + rowsperchunk = numrows; + mem->last_rowsperchunk = rowsperchunk; + + /* Get space for row pointers (small object) */ + result = (JBLOCKARRAY) alloc_small(cinfo, pool_id, + (size_t) (numrows * SIZEOF(JBLOCKROW))); + + /* Get the rows themselves (large objects) */ + currow = 0; + while (currow < numrows) { + rowsperchunk = MIN(rowsperchunk, numrows - currow); + workspace = (JBLOCKROW) alloc_large(cinfo, pool_id, + (size_t) ((size_t) rowsperchunk * (size_t) blocksperrow + * SIZEOF(JBLOCK))); + for (i = rowsperchunk; i > 0; i--) { + result[currow++] = workspace; + workspace += blocksperrow; + } + } + + return result; +} + + +/* + * About virtual array management: + * + * The above "normal" array routines are only used to allocate strip buffers + * (as wide as the image, but just a few rows high). Full-image-sized buffers + * are handled as "virtual" arrays. The array is still accessed a strip at a + * time, but the memory manager must save the whole array for repeated + * accesses. The intended implementation is that there is a strip buffer in + * memory (as high as is possible given the desired memory limit), plus a + * backing file that holds the rest of the array. + * + * The request_virt_array routines are told the total size of the image and + * the maximum number of rows that will be accessed at once. The in-memory + * buffer must be at least as large as the maxaccess value. + * + * The request routines create control blocks but not the in-memory buffers. + * That is postponed until realize_virt_arrays is called. At that time the + * total amount of space needed is known (approximately, anyway), so free + * memory can be divided up fairly. + * + * The access_virt_array routines are responsible for making a specific strip + * area accessible (after reading or writing the backing file, if necessary). + * Note that the access routines are told whether the caller intends to modify + * the accessed strip; during a read-only pass this saves having to rewrite + * data to disk. The access routines are also responsible for pre-zeroing + * any newly accessed rows, if pre-zeroing was requested. + * + * In current usage, the access requests are usually for nonoverlapping + * strips; that is, successive access start_row numbers differ by exactly + * num_rows = maxaccess. This means we can get good performance with simple + * buffer dump/reload logic, by making the in-memory buffer be a multiple + * of the access height; then there will never be accesses across bufferload + * boundaries. The code will still work with overlapping access requests, + * but it doesn't handle bufferload overlaps very efficiently. + */ + + +METHODDEF(jvirt_sarray_ptr) +request_virt_sarray (j_common_ptr cinfo, int pool_id, boolean pre_zero, + JDIMENSION samplesperrow, JDIMENSION numrows, + JDIMENSION maxaccess) +/* Request a virtual 2-D sample array */ +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + jvirt_sarray_ptr result; + + /* Only IMAGE-lifetime virtual arrays are currently supported */ + if (pool_id != JPOOL_IMAGE) + ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ + + /* get control block */ + result = (jvirt_sarray_ptr) alloc_small(cinfo, pool_id, + SIZEOF(struct jvirt_sarray_control)); + + result->mem_buffer = NULL; /* marks array not yet realized */ + result->rows_in_array = numrows; + result->samplesperrow = samplesperrow; + result->maxaccess = maxaccess; + result->pre_zero = pre_zero; + result->b_s_open = FALSE; /* no associated backing-store object */ + result->next = mem->virt_sarray_list; /* add to list of virtual arrays */ + mem->virt_sarray_list = result; + + return result; +} + + +METHODDEF(jvirt_barray_ptr) +request_virt_barray (j_common_ptr cinfo, int pool_id, boolean pre_zero, + JDIMENSION blocksperrow, JDIMENSION numrows, + JDIMENSION maxaccess) +/* Request a virtual 2-D coefficient-block array */ +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + jvirt_barray_ptr result; + + /* Only IMAGE-lifetime virtual arrays are currently supported */ + if (pool_id != JPOOL_IMAGE) + ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ + + /* get control block */ + result = (jvirt_barray_ptr) alloc_small(cinfo, pool_id, + SIZEOF(struct jvirt_barray_control)); + + result->mem_buffer = NULL; /* marks array not yet realized */ + result->rows_in_array = numrows; + result->blocksperrow = blocksperrow; + result->maxaccess = maxaccess; + result->pre_zero = pre_zero; + result->b_s_open = FALSE; /* no associated backing-store object */ + result->next = mem->virt_barray_list; /* add to list of virtual arrays */ + mem->virt_barray_list = result; + + return result; +} + + +METHODDEF(void) +realize_virt_arrays (j_common_ptr cinfo) +/* Allocate the in-memory buffers for any unrealized virtual arrays */ +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + long space_per_minheight, maximum_space, avail_mem; + long minheights, max_minheights; + jvirt_sarray_ptr sptr; + jvirt_barray_ptr bptr; + + /* Compute the minimum space needed (maxaccess rows in each buffer) + * and the maximum space needed (full image height in each buffer). + * These may be of use to the system-dependent jpeg_mem_available routine. + */ + space_per_minheight = 0; + maximum_space = 0; + for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) { + if (sptr->mem_buffer == NULL) { /* if not realized yet */ + space_per_minheight += (long) sptr->maxaccess * + (long) sptr->samplesperrow * SIZEOF(JSAMPLE); + maximum_space += (long) sptr->rows_in_array * + (long) sptr->samplesperrow * SIZEOF(JSAMPLE); + } + } + for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) { + if (bptr->mem_buffer == NULL) { /* if not realized yet */ + space_per_minheight += (long) bptr->maxaccess * + (long) bptr->blocksperrow * SIZEOF(JBLOCK); + maximum_space += (long) bptr->rows_in_array * + (long) bptr->blocksperrow * SIZEOF(JBLOCK); + } + } + + if (space_per_minheight <= 0) + return; /* no unrealized arrays, no work */ + + /* Determine amount of memory to actually use; this is system-dependent. */ + avail_mem = jpeg_mem_available(cinfo, space_per_minheight, maximum_space, + mem->total_space_allocated); + + /* If the maximum space needed is available, make all the buffers full + * height; otherwise parcel it out with the same number of minheights + * in each buffer. + */ + if (avail_mem >= maximum_space) + max_minheights = 1000000000L; + else { + max_minheights = avail_mem / space_per_minheight; + /* If there doesn't seem to be enough space, try to get the minimum + * anyway. This allows a "stub" implementation of jpeg_mem_available(). + */ + if (max_minheights <= 0) + max_minheights = 1; + } + + /* Allocate the in-memory buffers and initialize backing store as needed. */ + + for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) { + if (sptr->mem_buffer == NULL) { /* if not realized yet */ + minheights = ((long) sptr->rows_in_array - 1L) / sptr->maxaccess + 1L; + if (minheights <= max_minheights) { + /* This buffer fits in memory */ + sptr->rows_in_mem = sptr->rows_in_array; + } else { + /* It doesn't fit in memory, create backing store. */ + sptr->rows_in_mem = (JDIMENSION) (max_minheights * sptr->maxaccess); + jpeg_open_backing_store(cinfo, & sptr->b_s_info, + (long) sptr->rows_in_array * + (long) sptr->samplesperrow * + (long) SIZEOF(JSAMPLE)); + sptr->b_s_open = TRUE; + } + sptr->mem_buffer = alloc_sarray(cinfo, JPOOL_IMAGE, + sptr->samplesperrow, sptr->rows_in_mem); + sptr->rowsperchunk = mem->last_rowsperchunk; + sptr->cur_start_row = 0; + sptr->first_undef_row = 0; + sptr->dirty = FALSE; + } + } + + for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) { + if (bptr->mem_buffer == NULL) { /* if not realized yet */ + minheights = ((long) bptr->rows_in_array - 1L) / bptr->maxaccess + 1L; + if (minheights <= max_minheights) { + /* This buffer fits in memory */ + bptr->rows_in_mem = bptr->rows_in_array; + } else { + /* It doesn't fit in memory, create backing store. */ + bptr->rows_in_mem = (JDIMENSION) (max_minheights * bptr->maxaccess); + jpeg_open_backing_store(cinfo, & bptr->b_s_info, + (long) bptr->rows_in_array * + (long) bptr->blocksperrow * + (long) SIZEOF(JBLOCK)); + bptr->b_s_open = TRUE; + } + bptr->mem_buffer = alloc_barray(cinfo, JPOOL_IMAGE, + bptr->blocksperrow, bptr->rows_in_mem); + bptr->rowsperchunk = mem->last_rowsperchunk; + bptr->cur_start_row = 0; + bptr->first_undef_row = 0; + bptr->dirty = FALSE; + } + } +} + + +LOCAL(void) +do_sarray_io (j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing) +/* Do backing store read or write of a virtual sample array */ +{ + long bytesperrow, file_offset, byte_count, rows, thisrow, i; + + bytesperrow = (long) ptr->samplesperrow * SIZEOF(JSAMPLE); + file_offset = ptr->cur_start_row * bytesperrow; + /* Loop to read or write each allocation chunk in mem_buffer */ + for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) { + /* One chunk, but check for short chunk at end of buffer */ + rows = MIN((long) ptr->rowsperchunk, (long) ptr->rows_in_mem - i); + /* Transfer no more than is currently defined */ + thisrow = (long) ptr->cur_start_row + i; + rows = MIN(rows, (long) ptr->first_undef_row - thisrow); + /* Transfer no more than fits in file */ + rows = MIN(rows, (long) ptr->rows_in_array - thisrow); + if (rows <= 0) /* this chunk might be past end of file! */ + break; + byte_count = rows * bytesperrow; + if (writing) + (*ptr->b_s_info.write_backing_store) (cinfo, & ptr->b_s_info, + (void FAR *) ptr->mem_buffer[i], + file_offset, byte_count); + else + (*ptr->b_s_info.read_backing_store) (cinfo, & ptr->b_s_info, + (void FAR *) ptr->mem_buffer[i], + file_offset, byte_count); + file_offset += byte_count; + } +} + + +LOCAL(void) +do_barray_io (j_common_ptr cinfo, jvirt_barray_ptr ptr, boolean writing) +/* Do backing store read or write of a virtual coefficient-block array */ +{ + long bytesperrow, file_offset, byte_count, rows, thisrow, i; + + bytesperrow = (long) ptr->blocksperrow * SIZEOF(JBLOCK); + file_offset = ptr->cur_start_row * bytesperrow; + /* Loop to read or write each allocation chunk in mem_buffer */ + for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) { + /* One chunk, but check for short chunk at end of buffer */ + rows = MIN((long) ptr->rowsperchunk, (long) ptr->rows_in_mem - i); + /* Transfer no more than is currently defined */ + thisrow = (long) ptr->cur_start_row + i; + rows = MIN(rows, (long) ptr->first_undef_row - thisrow); + /* Transfer no more than fits in file */ + rows = MIN(rows, (long) ptr->rows_in_array - thisrow); + if (rows <= 0) /* this chunk might be past end of file! */ + break; + byte_count = rows * bytesperrow; + if (writing) + (*ptr->b_s_info.write_backing_store) (cinfo, & ptr->b_s_info, + (void FAR *) ptr->mem_buffer[i], + file_offset, byte_count); + else + (*ptr->b_s_info.read_backing_store) (cinfo, & ptr->b_s_info, + (void FAR *) ptr->mem_buffer[i], + file_offset, byte_count); + file_offset += byte_count; + } +} + + +METHODDEF(JSAMPARRAY) +access_virt_sarray (j_common_ptr cinfo, jvirt_sarray_ptr ptr, + JDIMENSION start_row, JDIMENSION num_rows, + boolean writable) +/* Access the part of a virtual sample array starting at start_row */ +/* and extending for num_rows rows. writable is true if */ +/* caller intends to modify the accessed area. */ +{ + JDIMENSION end_row = start_row + num_rows; + JDIMENSION undef_row; + + /* debugging check */ + if (end_row > ptr->rows_in_array || num_rows > ptr->maxaccess || + ptr->mem_buffer == NULL) + ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); + + /* Make the desired part of the virtual array accessible */ + if (start_row < ptr->cur_start_row || + end_row > ptr->cur_start_row+ptr->rows_in_mem) { + if (! ptr->b_s_open) + ERREXIT(cinfo, JERR_VIRTUAL_BUG); + /* Flush old buffer contents if necessary */ + if (ptr->dirty) { + do_sarray_io(cinfo, ptr, TRUE); + ptr->dirty = FALSE; + } + /* Decide what part of virtual array to access. + * Algorithm: if target address > current window, assume forward scan, + * load starting at target address. If target address < current window, + * assume backward scan, load so that target area is top of window. + * Note that when switching from forward write to forward read, will have + * start_row = 0, so the limiting case applies and we load from 0 anyway. + */ + if (start_row > ptr->cur_start_row) { + ptr->cur_start_row = start_row; + } else { + /* use long arithmetic here to avoid overflow & unsigned problems */ + long ltemp; + + ltemp = (long) end_row - (long) ptr->rows_in_mem; + if (ltemp < 0) + ltemp = 0; /* don't fall off front end of file */ + ptr->cur_start_row = (JDIMENSION) ltemp; + } + /* Read in the selected part of the array. + * During the initial write pass, we will do no actual read + * because the selected part is all undefined. + */ + do_sarray_io(cinfo, ptr, FALSE); + } + /* Ensure the accessed part of the array is defined; prezero if needed. + * To improve locality of access, we only prezero the part of the array + * that the caller is about to access, not the entire in-memory array. + */ + if (ptr->first_undef_row < end_row) { + if (ptr->first_undef_row < start_row) { + if (writable) /* writer skipped over a section of array */ + ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); + undef_row = start_row; /* but reader is allowed to read ahead */ + } else { + undef_row = ptr->first_undef_row; + } + if (writable) + ptr->first_undef_row = end_row; + if (ptr->pre_zero) { + size_t bytesperrow = (size_t) ptr->samplesperrow * SIZEOF(JSAMPLE); + undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */ + end_row -= ptr->cur_start_row; + while (undef_row < end_row) { + jzero_far((void FAR *) ptr->mem_buffer[undef_row], bytesperrow); + undef_row++; + } + } else { + if (! writable) /* reader looking at undefined data */ + ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); + } + } + /* Flag the buffer dirty if caller will write in it */ + if (writable) + ptr->dirty = TRUE; + /* Return address of proper part of the buffer */ + return ptr->mem_buffer + (start_row - ptr->cur_start_row); +} + + +METHODDEF(JBLOCKARRAY) +access_virt_barray (j_common_ptr cinfo, jvirt_barray_ptr ptr, + JDIMENSION start_row, JDIMENSION num_rows, + boolean writable) +/* Access the part of a virtual block array starting at start_row */ +/* and extending for num_rows rows. writable is true if */ +/* caller intends to modify the accessed area. */ +{ + JDIMENSION end_row = start_row + num_rows; + JDIMENSION undef_row; + + /* debugging check */ + if (end_row > ptr->rows_in_array || num_rows > ptr->maxaccess || + ptr->mem_buffer == NULL) + ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); + + /* Make the desired part of the virtual array accessible */ + if (start_row < ptr->cur_start_row || + end_row > ptr->cur_start_row+ptr->rows_in_mem) { + if (! ptr->b_s_open) + ERREXIT(cinfo, JERR_VIRTUAL_BUG); + /* Flush old buffer contents if necessary */ + if (ptr->dirty) { + do_barray_io(cinfo, ptr, TRUE); + ptr->dirty = FALSE; + } + /* Decide what part of virtual array to access. + * Algorithm: if target address > current window, assume forward scan, + * load starting at target address. If target address < current window, + * assume backward scan, load so that target area is top of window. + * Note that when switching from forward write to forward read, will have + * start_row = 0, so the limiting case applies and we load from 0 anyway. + */ + if (start_row > ptr->cur_start_row) { + ptr->cur_start_row = start_row; + } else { + /* use long arithmetic here to avoid overflow & unsigned problems */ + long ltemp; + + ltemp = (long) end_row - (long) ptr->rows_in_mem; + if (ltemp < 0) + ltemp = 0; /* don't fall off front end of file */ + ptr->cur_start_row = (JDIMENSION) ltemp; + } + /* Read in the selected part of the array. + * During the initial write pass, we will do no actual read + * because the selected part is all undefined. + */ + do_barray_io(cinfo, ptr, FALSE); + } + /* Ensure the accessed part of the array is defined; prezero if needed. + * To improve locality of access, we only prezero the part of the array + * that the caller is about to access, not the entire in-memory array. + */ + if (ptr->first_undef_row < end_row) { + if (ptr->first_undef_row < start_row) { + if (writable) /* writer skipped over a section of array */ + ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); + undef_row = start_row; /* but reader is allowed to read ahead */ + } else { + undef_row = ptr->first_undef_row; + } + if (writable) + ptr->first_undef_row = end_row; + if (ptr->pre_zero) { + size_t bytesperrow = (size_t) ptr->blocksperrow * SIZEOF(JBLOCK); + undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */ + end_row -= ptr->cur_start_row; + while (undef_row < end_row) { + jzero_far((void FAR *) ptr->mem_buffer[undef_row], bytesperrow); + undef_row++; + } + } else { + if (! writable) /* reader looking at undefined data */ + ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); + } + } + /* Flag the buffer dirty if caller will write in it */ + if (writable) + ptr->dirty = TRUE; + /* Return address of proper part of the buffer */ + return ptr->mem_buffer + (start_row - ptr->cur_start_row); +} + + +/* + * Release all objects belonging to a specified pool. + */ + +METHODDEF(void) +free_pool (j_common_ptr cinfo, int pool_id) +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + small_pool_ptr shdr_ptr; + large_pool_ptr lhdr_ptr; + size_t space_freed; + + if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS) + ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ + +#ifdef MEM_STATS + if (cinfo->err->trace_level > 1) + print_mem_stats(cinfo, pool_id); /* print pool's memory usage statistics */ +#endif + + /* If freeing IMAGE pool, close any virtual arrays first */ + if (pool_id == JPOOL_IMAGE) { + jvirt_sarray_ptr sptr; + jvirt_barray_ptr bptr; + + for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) { + if (sptr->b_s_open) { /* there may be no backing store */ + sptr->b_s_open = FALSE; /* prevent recursive close if error */ + (*sptr->b_s_info.close_backing_store) (cinfo, & sptr->b_s_info); + } + } + mem->virt_sarray_list = NULL; + for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) { + if (bptr->b_s_open) { /* there may be no backing store */ + bptr->b_s_open = FALSE; /* prevent recursive close if error */ + (*bptr->b_s_info.close_backing_store) (cinfo, & bptr->b_s_info); + } + } + mem->virt_barray_list = NULL; + } + + /* Release large objects */ + lhdr_ptr = mem->large_list[pool_id]; + mem->large_list[pool_id] = NULL; + + while (lhdr_ptr != NULL) { + large_pool_ptr next_lhdr_ptr = lhdr_ptr->hdr.next; + space_freed = lhdr_ptr->hdr.bytes_used + + lhdr_ptr->hdr.bytes_left + + SIZEOF(large_pool_hdr); + jpeg_free_large(cinfo, (void FAR *) lhdr_ptr, space_freed); + mem->total_space_allocated -= space_freed; + lhdr_ptr = next_lhdr_ptr; + } + + /* Release small objects */ + shdr_ptr = mem->small_list[pool_id]; + mem->small_list[pool_id] = NULL; + + while (shdr_ptr != NULL) { + small_pool_ptr next_shdr_ptr = shdr_ptr->hdr.next; + space_freed = shdr_ptr->hdr.bytes_used + + shdr_ptr->hdr.bytes_left + + SIZEOF(small_pool_hdr); + jpeg_free_small(cinfo, (void *) shdr_ptr, space_freed); + mem->total_space_allocated -= space_freed; + shdr_ptr = next_shdr_ptr; + } +} + + +/* + * Close up shop entirely. + * Note that this cannot be called unless cinfo->mem is non-NULL. + */ + +METHODDEF(void) +self_destruct (j_common_ptr cinfo) +{ + int pool; + + /* Close all backing store, release all memory. + * Releasing pools in reverse order might help avoid fragmentation + * with some (brain-damaged) malloc libraries. + */ + for (pool = JPOOL_NUMPOOLS-1; pool >= JPOOL_PERMANENT; pool--) { + free_pool(cinfo, pool); + } + + /* Release the memory manager control block too. */ + jpeg_free_small(cinfo, (void *) cinfo->mem, SIZEOF(my_memory_mgr)); + cinfo->mem = NULL; /* ensures I will be called only once */ + + jpeg_mem_term(cinfo); /* system-dependent cleanup */ +} + + +/* + * Memory manager initialization. + * When this is called, only the error manager pointer is valid in cinfo! + */ + +GLOBAL(void) +jinit_memory_mgr (j_common_ptr cinfo) +{ + my_mem_ptr mem; + long max_to_use; + int pool; + size_t test_mac; + + cinfo->mem = NULL; /* for safety if init fails */ + + /* Check for configuration errors. + * SIZEOF(ALIGN_TYPE) should be a power of 2; otherwise, it probably + * doesn't reflect any real hardware alignment requirement. + * The test is a little tricky: for X>0, X and X-1 have no one-bits + * in common if and only if X is a power of 2, ie has only one one-bit. + * Some compilers may give an "unreachable code" warning here; ignore it. + */ + if ((SIZEOF(ALIGN_TYPE) & (SIZEOF(ALIGN_TYPE)-1)) != 0) + ERREXIT(cinfo, JERR_BAD_ALIGN_TYPE); + /* MAX_ALLOC_CHUNK must be representable as type size_t, and must be + * a multiple of SIZEOF(ALIGN_TYPE). + * Again, an "unreachable code" warning may be ignored here. + * But a "constant too large" warning means you need to fix MAX_ALLOC_CHUNK. + */ + test_mac = (size_t) MAX_ALLOC_CHUNK; + if ((long) test_mac != MAX_ALLOC_CHUNK || + (MAX_ALLOC_CHUNK % SIZEOF(ALIGN_TYPE)) != 0) + ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK); + + max_to_use = jpeg_mem_init(cinfo); /* system-dependent initialization */ + + /* Attempt to allocate memory manager's control block */ + mem = (my_mem_ptr) jpeg_get_small(cinfo, SIZEOF(my_memory_mgr)); + + if (mem == NULL) { + jpeg_mem_term(cinfo); /* system-dependent cleanup */ + ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 0); + } + + /* OK, fill in the method pointers */ + mem->pub.alloc_small = alloc_small; + mem->pub.alloc_large = alloc_large; + mem->pub.alloc_sarray = alloc_sarray; + mem->pub.alloc_barray = alloc_barray; + mem->pub.request_virt_sarray = request_virt_sarray; + mem->pub.request_virt_barray = request_virt_barray; + mem->pub.realize_virt_arrays = realize_virt_arrays; + mem->pub.access_virt_sarray = access_virt_sarray; + mem->pub.access_virt_barray = access_virt_barray; + mem->pub.free_pool = free_pool; + mem->pub.self_destruct = self_destruct; + + /* Initialize working state */ + mem->pub.max_memory_to_use = max_to_use; + + for (pool = JPOOL_NUMPOOLS-1; pool >= JPOOL_PERMANENT; pool--) { + mem->small_list[pool] = NULL; + mem->large_list[pool] = NULL; + } + mem->virt_sarray_list = NULL; + mem->virt_barray_list = NULL; + + mem->total_space_allocated = SIZEOF(my_memory_mgr); + + /* Declare ourselves open for business */ + cinfo->mem = & mem->pub; + + /* Check for an environment variable JPEGMEM; if found, override the + * default max_memory setting from jpeg_mem_init. Note that the + * surrounding application may again override this value. + * If your system doesn't support getenv(), define NO_GETENV to disable + * this feature. + */ +#ifndef NO_GETENV + { char * memenv; + + if ((memenv = getenv("JPEGMEM")) != NULL) { + char ch = 'x'; + + if (sscanf(memenv, "%ld%c", &max_to_use, &ch) > 0) { + if (ch == 'm' || ch == 'M') + max_to_use *= 1000L; + mem->pub.max_memory_to_use = max_to_use * 1000L; + } + } + } +#endif + +} diff --git a/gs/jpeg/jmemname.c b/gs/jpeg/jmemname.c new file mode 100644 index 000000000..d1b57e9ef --- /dev/null +++ b/gs/jpeg/jmemname.c @@ -0,0 +1,271 @@ +/* + * jmemname.c + * + * Copyright (C) 1992-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file provides a generic implementation of the system-dependent + * portion of the JPEG memory manager. This implementation assumes that + * you must explicitly construct a name for each temp file. + * Also, the problem of determining the amount of memory available + * is shoved onto the user. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jmemsys.h" /* import the system-dependent declarations */ + +#ifndef HAVE_STDLIB_H /* should declare malloc(),free() */ +extern void * malloc JPP((size_t size)); +extern void free JPP((void *ptr)); +#endif + +#ifndef SEEK_SET /* pre-ANSI systems may not define this; */ +#define SEEK_SET 0 /* if not, assume 0 is correct */ +#endif + +#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ +#define READ_BINARY "r" +#define RW_BINARY "w+" +#else +#define READ_BINARY "rb" +#define RW_BINARY "w+b" +#endif + + +/* + * Selection of a file name for a temporary file. + * This is system-dependent! + * + * The code as given is suitable for most Unix systems, and it is easily + * modified for most non-Unix systems. Some notes: + * 1. The temp file is created in the directory named by TEMP_DIRECTORY. + * The default value is /usr/tmp, which is the conventional place for + * creating large temp files on Unix. On other systems you'll probably + * want to change the file location. You can do this by editing the + * #define, or (preferred) by defining TEMP_DIRECTORY in jconfig.h. + * + * 2. If you need to change the file name as well as its location, + * you can override the TEMP_FILE_NAME macro. (Note that this is + * actually a printf format string; it must contain %s and %d.) + * Few people should need to do this. + * + * 3. mktemp() is used to ensure that multiple processes running + * simultaneously won't select the same file names. If your system + * doesn't have mktemp(), define NO_MKTEMP to do it the hard way. + * (If you don't have , also define NO_ERRNO_H.) + * + * 4. You probably want to define NEED_SIGNAL_CATCHER so that cjpeg.c/djpeg.c + * will cause the temp files to be removed if you stop the program early. + */ + +#ifndef TEMP_DIRECTORY /* can override from jconfig.h or Makefile */ +#define TEMP_DIRECTORY "/usr/tmp/" /* recommended setting for Unix */ +#endif + +static int next_file_num; /* to distinguish among several temp files */ + +#ifdef NO_MKTEMP + +#ifndef TEMP_FILE_NAME /* can override from jconfig.h or Makefile */ +#define TEMP_FILE_NAME "%sJPG%03d.TMP" +#endif + +#ifndef NO_ERRNO_H +#include /* to define ENOENT */ +#endif + +/* ANSI C specifies that errno is a macro, but on older systems it's more + * likely to be a plain int variable. And not all versions of errno.h + * bother to declare it, so we have to in order to be most portable. Thus: + */ +#ifndef errno +extern int errno; +#endif + + +LOCAL(void) +select_file_name (char * fname) +{ + FILE * tfile; + + /* Keep generating file names till we find one that's not in use */ + for (;;) { + next_file_num++; /* advance counter */ + sprintf(fname, TEMP_FILE_NAME, TEMP_DIRECTORY, next_file_num); + if ((tfile = fopen(fname, READ_BINARY)) == NULL) { + /* fopen could have failed for a reason other than the file not + * being there; for example, file there but unreadable. + * If isn't available, then we cannot test the cause. + */ +#ifdef ENOENT + if (errno != ENOENT) + continue; +#endif + break; + } + fclose(tfile); /* oops, it's there; close tfile & try again */ + } +} + +#else /* ! NO_MKTEMP */ + +/* Note that mktemp() requires the initial filename to end in six X's */ +#ifndef TEMP_FILE_NAME /* can override from jconfig.h or Makefile */ +#define TEMP_FILE_NAME "%sJPG%dXXXXXX" +#endif + +LOCAL(void) +select_file_name (char * fname) +{ + next_file_num++; /* advance counter */ + sprintf(fname, TEMP_FILE_NAME, TEMP_DIRECTORY, next_file_num); + mktemp(fname); /* make sure file name is unique */ + /* mktemp replaces the trailing XXXXXX with a unique string of characters */ +} + +#endif /* NO_MKTEMP */ + + +/* + * Memory allocation and freeing are controlled by the regular library + * routines malloc() and free(). + */ + +GLOBAL(void *) +jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void *) malloc(sizeofobject); +} + +GLOBAL(void) +jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) +{ + free(object); +} + + +/* + * "Large" objects are treated the same as "small" ones. + * NB: although we include FAR keywords in the routine declarations, + * this file won't actually work in 80x86 small/medium model; at least, + * you probably won't be able to process useful-size images in only 64KB. + */ + +GLOBAL(void FAR *) +jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void FAR *) malloc(sizeofobject); +} + +GLOBAL(void) +jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) +{ + free(object); +} + + +/* + * This routine computes the total memory space available for allocation. + * It's impossible to do this in a portable way; our current solution is + * to make the user tell us (with a default value set at compile time). + * If you can actually get the available space, it's a good idea to subtract + * a slop factor of 5% or so. + */ + +#ifndef DEFAULT_MAX_MEM /* so can override from makefile */ +#define DEFAULT_MAX_MEM 1000000L /* default: one megabyte */ +#endif + +GLOBAL(long) +jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, + long max_bytes_needed, long already_allocated) +{ + return cinfo->mem->max_memory_to_use - already_allocated; +} + + +/* + * Backing store (temporary file) management. + * Backing store objects are only used when the value returned by + * jpeg_mem_available is less than the total space needed. You can dispense + * with these routines if you have plenty of virtual memory; see jmemnobs.c. + */ + + +METHODDEF(void) +read_backing_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + if (fseek(info->temp_file, file_offset, SEEK_SET)) + ERREXIT(cinfo, JERR_TFILE_SEEK); + if (JFREAD(info->temp_file, buffer_address, byte_count) + != (size_t) byte_count) + ERREXIT(cinfo, JERR_TFILE_READ); +} + + +METHODDEF(void) +write_backing_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + if (fseek(info->temp_file, file_offset, SEEK_SET)) + ERREXIT(cinfo, JERR_TFILE_SEEK); + if (JFWRITE(info->temp_file, buffer_address, byte_count) + != (size_t) byte_count) + ERREXIT(cinfo, JERR_TFILE_WRITE); +} + + +METHODDEF(void) +close_backing_store (j_common_ptr cinfo, backing_store_ptr info) +{ + fclose(info->temp_file); /* close the file */ + unlink(info->temp_name); /* delete the file */ +/* If your system doesn't have unlink(), use remove() instead. + * remove() is the ANSI-standard name for this function, but if + * your system was ANSI you'd be using jmemansi.c, right? + */ + TRACEMSS(cinfo, 1, JTRC_TFILE_CLOSE, info->temp_name); +} + + +/* + * Initial opening of a backing-store object. + */ + +GLOBAL(void) +jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, + long total_bytes_needed) +{ + select_file_name(info->temp_name); + if ((info->temp_file = fopen(info->temp_name, RW_BINARY)) == NULL) + ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name); + info->read_backing_store = read_backing_store; + info->write_backing_store = write_backing_store; + info->close_backing_store = close_backing_store; + TRACEMSS(cinfo, 1, JTRC_TFILE_OPEN, info->temp_name); +} + + +/* + * These routines take care of any system-dependent initialization and + * cleanup required. + */ + +GLOBAL(long) +jpeg_mem_init (j_common_ptr cinfo) +{ + next_file_num = 0; /* initialize temp file name generator */ + return DEFAULT_MAX_MEM; /* default for max_memory_to_use */ +} + +GLOBAL(void) +jpeg_mem_term (j_common_ptr cinfo) +{ + /* no work */ +} diff --git a/gs/jpeg/jmemnobs.c b/gs/jpeg/jmemnobs.c new file mode 100644 index 000000000..eb8c33772 --- /dev/null +++ b/gs/jpeg/jmemnobs.c @@ -0,0 +1,109 @@ +/* + * jmemnobs.c + * + * Copyright (C) 1992-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file provides a really simple implementation of the system- + * dependent portion of the JPEG memory manager. This implementation + * assumes that no backing-store files are needed: all required space + * can be obtained from malloc(). + * This is very portable in the sense that it'll compile on almost anything, + * but you'd better have lots of main memory (or virtual memory) if you want + * to process big images. + * Note that the max_memory_to_use option is ignored by this implementation. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jmemsys.h" /* import the system-dependent declarations */ + +#ifndef HAVE_STDLIB_H /* should declare malloc(),free() */ +extern void * malloc JPP((size_t size)); +extern void free JPP((void *ptr)); +#endif + + +/* + * Memory allocation and freeing are controlled by the regular library + * routines malloc() and free(). + */ + +GLOBAL(void *) +jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void *) malloc(sizeofobject); +} + +GLOBAL(void) +jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) +{ + free(object); +} + + +/* + * "Large" objects are treated the same as "small" ones. + * NB: although we include FAR keywords in the routine declarations, + * this file won't actually work in 80x86 small/medium model; at least, + * you probably won't be able to process useful-size images in only 64KB. + */ + +GLOBAL(void FAR *) +jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void FAR *) malloc(sizeofobject); +} + +GLOBAL(void) +jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) +{ + free(object); +} + + +/* + * This routine computes the total memory space available for allocation. + * Here we always say, "we got all you want bud!" + */ + +GLOBAL(long) +jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, + long max_bytes_needed, long already_allocated) +{ + return max_bytes_needed; +} + + +/* + * Backing store (temporary file) management. + * Since jpeg_mem_available always promised the moon, + * this should never be called and we can just error out. + */ + +GLOBAL(void) +jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, + long total_bytes_needed) +{ + ERREXIT(cinfo, JERR_NO_BACKING_STORE); +} + + +/* + * These routines take care of any system-dependent initialization and + * cleanup required. Here, there isn't any. + */ + +GLOBAL(long) +jpeg_mem_init (j_common_ptr cinfo) +{ + return 0; /* just set max_memory_to_use to 0 */ +} + +GLOBAL(void) +jpeg_mem_term (j_common_ptr cinfo) +{ + /* no work */ +} diff --git a/gs/jpeg/jmemsys.h b/gs/jpeg/jmemsys.h new file mode 100644 index 000000000..6d4c7f2ae --- /dev/null +++ b/gs/jpeg/jmemsys.h @@ -0,0 +1,183 @@ +/* + * jmemsys.h + * + * Copyright (C) 1992-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This include file defines the interface between the system-independent + * and system-dependent portions of the JPEG memory manager. No other + * modules need include it. (The system-independent portion is jmemmgr.c; + * there are several different versions of the system-dependent portion.) + * + * This file works as-is for the system-dependent memory managers supplied + * in the IJG distribution. You may need to modify it if you write a + * custom memory manager. If system-dependent changes are needed in + * this file, the best method is to #ifdef them based on a configuration + * symbol supplied in jconfig.h, as we have done with USE_MSDOS_MEMMGR. + */ + + +/* Short forms of external names for systems with brain-damaged linkers. */ + +#ifdef NEED_SHORT_EXTERNAL_NAMES +#define jpeg_get_small jGetSmall +#define jpeg_free_small jFreeSmall +#define jpeg_get_large jGetLarge +#define jpeg_free_large jFreeLarge +#define jpeg_mem_available jMemAvail +#define jpeg_open_backing_store jOpenBackStore +#define jpeg_mem_init jMemInit +#define jpeg_mem_term jMemTerm +#endif /* NEED_SHORT_EXTERNAL_NAMES */ + + +/* + * These two functions are used to allocate and release small chunks of + * memory. (Typically the total amount requested through jpeg_get_small is + * no more than 20K or so; this will be requested in chunks of a few K each.) + * Behavior should be the same as for the standard library functions malloc + * and free; in particular, jpeg_get_small must return NULL on failure. + * On most systems, these ARE malloc and free. jpeg_free_small is passed the + * size of the object being freed, just in case it's needed. + * On an 80x86 machine using small-data memory model, these manage near heap. + */ + +EXTERN(void *) jpeg_get_small JPP((j_common_ptr cinfo, size_t sizeofobject)); +EXTERN(void) jpeg_free_small JPP((j_common_ptr cinfo, void * object, + size_t sizeofobject)); + +/* + * These two functions are used to allocate and release large chunks of + * memory (up to the total free space designated by jpeg_mem_available). + * The interface is the same as above, except that on an 80x86 machine, + * far pointers are used. On most other machines these are identical to + * the jpeg_get/free_small routines; but we keep them separate anyway, + * in case a different allocation strategy is desirable for large chunks. + */ + +EXTERN(void FAR *) jpeg_get_large JPP((j_common_ptr cinfo, + size_t sizeofobject)); +EXTERN(void) jpeg_free_large JPP((j_common_ptr cinfo, void FAR * object, + size_t sizeofobject)); + +/* + * The macro MAX_ALLOC_CHUNK designates the maximum number of bytes that may + * be requested in a single call to jpeg_get_large (and jpeg_get_small for that + * matter, but that case should never come into play). This macro is needed + * to model the 64Kb-segment-size limit of far addressing on 80x86 machines. + * On those machines, we expect that jconfig.h will provide a proper value. + * On machines with 32-bit flat address spaces, any large constant may be used. + * + * NB: jmemmgr.c expects that MAX_ALLOC_CHUNK will be representable as type + * size_t and will be a multiple of sizeof(align_type). + */ + +#ifndef MAX_ALLOC_CHUNK /* may be overridden in jconfig.h */ +#define MAX_ALLOC_CHUNK 1000000000L +#endif + +/* + * This routine computes the total space still available for allocation by + * jpeg_get_large. If more space than this is needed, backing store will be + * used. NOTE: any memory already allocated must not be counted. + * + * There is a minimum space requirement, corresponding to the minimum + * feasible buffer sizes; jmemmgr.c will request that much space even if + * jpeg_mem_available returns zero. The maximum space needed, enough to hold + * all working storage in memory, is also passed in case it is useful. + * Finally, the total space already allocated is passed. If no better + * method is available, cinfo->mem->max_memory_to_use - already_allocated + * is often a suitable calculation. + * + * It is OK for jpeg_mem_available to underestimate the space available + * (that'll just lead to more backing-store access than is really necessary). + * However, an overestimate will lead to failure. Hence it's wise to subtract + * a slop factor from the true available space. 5% should be enough. + * + * On machines with lots of virtual memory, any large constant may be returned. + * Conversely, zero may be returned to always use the minimum amount of memory. + */ + +EXTERN(long) jpeg_mem_available JPP((j_common_ptr cinfo, + long min_bytes_needed, + long max_bytes_needed, + long already_allocated)); + + +/* + * This structure holds whatever state is needed to access a single + * backing-store object. The read/write/close method pointers are called + * by jmemmgr.c to manipulate the backing-store object; all other fields + * are private to the system-dependent backing store routines. + */ + +#define TEMP_NAME_LENGTH 64 /* max length of a temporary file's name */ + +#ifdef USE_MSDOS_MEMMGR /* DOS-specific junk */ + +typedef unsigned short XMSH; /* type of extended-memory handles */ +typedef unsigned short EMSH; /* type of expanded-memory handles */ + +typedef union { + short file_handle; /* DOS file handle if it's a temp file */ + XMSH xms_handle; /* handle if it's a chunk of XMS */ + EMSH ems_handle; /* handle if it's a chunk of EMS */ +} handle_union; + +#endif /* USE_MSDOS_MEMMGR */ + +typedef struct backing_store_struct * backing_store_ptr; + +typedef struct backing_store_struct { + /* Methods for reading/writing/closing this backing-store object */ + JMETHOD(void, read_backing_store, (j_common_ptr cinfo, + backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count)); + JMETHOD(void, write_backing_store, (j_common_ptr cinfo, + backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count)); + JMETHOD(void, close_backing_store, (j_common_ptr cinfo, + backing_store_ptr info)); + + /* Private fields for system-dependent backing-store management */ +#ifdef USE_MSDOS_MEMMGR + /* For the MS-DOS manager (jmemdos.c), we need: */ + handle_union handle; /* reference to backing-store storage object */ + char temp_name[TEMP_NAME_LENGTH]; /* name if it's a file */ +#else + /* For a typical implementation with temp files, we need: */ + FILE * temp_file; /* stdio reference to temp file */ + char temp_name[TEMP_NAME_LENGTH]; /* name of temp file */ +#endif +} backing_store_info; + +/* + * Initial opening of a backing-store object. This must fill in the + * read/write/close pointers in the object. The read/write routines + * may take an error exit if the specified maximum file size is exceeded. + * (If jpeg_mem_available always returns a large value, this routine can + * just take an error exit.) + */ + +EXTERN(void) jpeg_open_backing_store JPP((j_common_ptr cinfo, + backing_store_ptr info, + long total_bytes_needed)); + + +/* + * These routines take care of any system-dependent initialization and + * cleanup required. jpeg_mem_init will be called before anything is + * allocated (and, therefore, nothing in cinfo is of use except the error + * manager pointer). It should return a suitable default value for + * max_memory_to_use; this may subsequently be overridden by the surrounding + * application. (Note that max_memory_to_use is only important if + * jpeg_mem_available chooses to consult it ... no one else will.) + * jpeg_mem_term may assume that all requested memory has been freed and that + * all opened backing-store objects have been closed. + */ + +EXTERN(long) jpeg_mem_init JPP((j_common_ptr cinfo)); +EXTERN(void) jpeg_mem_term JPP((j_common_ptr cinfo)); diff --git a/gs/jpeg/jmorecfg.h b/gs/jpeg/jmorecfg.h new file mode 100644 index 000000000..e43651b14 --- /dev/null +++ b/gs/jpeg/jmorecfg.h @@ -0,0 +1,362 @@ +/* + * jmorecfg.h + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains additional configuration options that customize the + * JPEG software for special applications or support machine-dependent + * optimizations. Most users will not need to touch this file. + */ + + +/* + * Define BITS_IN_JSAMPLE as either + * 8 for 8-bit sample values (the usual setting) + * 12 for 12-bit sample values + * Only 8 and 12 are legal data precisions for lossy JPEG according to the + * JPEG standard, and the IJG code does not support anything else! + * We do not support run-time selection of data precision, sorry. + */ + +#define BITS_IN_JSAMPLE 8 /* use 8 or 12 */ + + +/* + * Maximum number of components (color channels) allowed in JPEG image. + * To meet the letter of the JPEG spec, set this to 255. However, darn + * few applications need more than 4 channels (maybe 5 for CMYK + alpha + * mask). We recommend 10 as a reasonable compromise; use 4 if you are + * really short on memory. (Each allowed component costs a hundred or so + * bytes of storage, whether actually used in an image or not.) + */ + +#define MAX_COMPONENTS 10 /* maximum number of image components */ + + +/* + * Basic data types. + * You may need to change these if you have a machine with unusual data + * type sizes; for example, "char" not 8 bits, "short" not 16 bits, + * or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits, + * but it had better be at least 16. + */ + +/* Representation of a single sample (pixel element value). + * We frequently allocate large arrays of these, so it's important to keep + * them small. But if you have memory to burn and access to char or short + * arrays is very slow on your hardware, you might want to change these. + */ + +#if BITS_IN_JSAMPLE == 8 +/* JSAMPLE should be the smallest type that will hold the values 0..255. + * You can use a signed char by having GETJSAMPLE mask it with 0xFF. + */ + +#ifdef HAVE_UNSIGNED_CHAR + +typedef unsigned char JSAMPLE; +#define GETJSAMPLE(value) ((int) (value)) + +#else /* not HAVE_UNSIGNED_CHAR */ + +typedef char JSAMPLE; +#ifdef CHAR_IS_UNSIGNED +#define GETJSAMPLE(value) ((int) (value)) +#else +#define GETJSAMPLE(value) ((int) (value) & 0xFF) +#endif /* CHAR_IS_UNSIGNED */ + +#endif /* HAVE_UNSIGNED_CHAR */ + +#define MAXJSAMPLE 255 +#define CENTERJSAMPLE 128 + +#endif /* BITS_IN_JSAMPLE == 8 */ + + +#if BITS_IN_JSAMPLE == 12 +/* JSAMPLE should be the smallest type that will hold the values 0..4095. + * On nearly all machines "short" will do nicely. + */ + +typedef short JSAMPLE; +#define GETJSAMPLE(value) ((int) (value)) + +#define MAXJSAMPLE 4095 +#define CENTERJSAMPLE 2048 + +#endif /* BITS_IN_JSAMPLE == 12 */ + + +/* Representation of a DCT frequency coefficient. + * This should be a signed value of at least 16 bits; "short" is usually OK. + * Again, we allocate large arrays of these, but you can change to int + * if you have memory to burn and "short" is really slow. + */ + +typedef short JCOEF; + + +/* Compressed datastreams are represented as arrays of JOCTET. + * These must be EXACTLY 8 bits wide, at least once they are written to + * external storage. Note that when using the stdio data source/destination + * managers, this is also the data type passed to fread/fwrite. + */ + +#ifdef HAVE_UNSIGNED_CHAR + +typedef unsigned char JOCTET; +#define GETJOCTET(value) (value) + +#else /* not HAVE_UNSIGNED_CHAR */ + +typedef char JOCTET; +#ifdef CHAR_IS_UNSIGNED +#define GETJOCTET(value) (value) +#else +#define GETJOCTET(value) ((value) & 0xFF) +#endif /* CHAR_IS_UNSIGNED */ + +#endif /* HAVE_UNSIGNED_CHAR */ + + +/* These typedefs are used for various table entries and so forth. + * They must be at least as wide as specified; but making them too big + * won't cost a huge amount of memory, so we don't provide special + * extraction code like we did for JSAMPLE. (In other words, these + * typedefs live at a different point on the speed/space tradeoff curve.) + */ + +/* UINT8 must hold at least the values 0..255. */ + +#ifdef HAVE_UNSIGNED_CHAR +typedef unsigned char UINT8; +#else /* not HAVE_UNSIGNED_CHAR */ +#ifdef CHAR_IS_UNSIGNED +typedef char UINT8; +#else /* not CHAR_IS_UNSIGNED */ +typedef short UINT8; +#endif /* CHAR_IS_UNSIGNED */ +#endif /* HAVE_UNSIGNED_CHAR */ + +/* UINT16 must hold at least the values 0..65535. */ + +#ifdef HAVE_UNSIGNED_SHORT +typedef unsigned short UINT16; +#else /* not HAVE_UNSIGNED_SHORT */ +typedef unsigned int UINT16; +#endif /* HAVE_UNSIGNED_SHORT */ + +/* INT16 must hold at least the values -32768..32767. */ + +#ifndef XMD_H /* X11/xmd.h correctly defines INT16 */ +typedef short INT16; +#endif + +/* INT32 must hold at least signed 32-bit values. */ + +#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */ +typedef long INT32; +#endif + +/* Datatype used for image dimensions. The JPEG standard only supports + * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore + * "unsigned int" is sufficient on all machines. However, if you need to + * handle larger images and you don't mind deviating from the spec, you + * can change this datatype. + */ + +typedef unsigned int JDIMENSION; + +#define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */ + + +/* These macros are used in all function definitions and extern declarations. + * You could modify them if you need to change function linkage conventions; + * in particular, you'll need to do that to make the library a Windows DLL. + * Another application is to make all functions global for use with debuggers + * or code profilers that require it. + */ + +/* a function called through method pointers: */ +#define METHODDEF(type) static type +/* a function used only in its module: */ +#define LOCAL(type) static type +/* a function referenced thru EXTERNs: */ +#define GLOBAL(type) type +/* a reference to a GLOBAL function: */ +#define EXTERN(type) extern type + + +/* This macro is used to declare a "method", that is, a function pointer. + * We want to supply prototype parameters if the compiler can cope. + * Note that the arglist parameter must be parenthesized! + * Again, you can customize this if you need special linkage keywords. + */ + +#ifdef HAVE_PROTOTYPES +#define JMETHOD(type,methodname,arglist) type (*methodname) arglist +#else +#define JMETHOD(type,methodname,arglist) type (*methodname) () +#endif + + +/* Here is the pseudo-keyword for declaring pointers that must be "far" + * on 80x86 machines. Most of the specialized coding for 80x86 is handled + * by just saying "FAR *" where such a pointer is needed. In a few places + * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol. + */ + +#ifdef NEED_FAR_POINTERS +#define FAR far +#else +#define FAR +#endif + + +/* + * On a few systems, type boolean and/or its values FALSE, TRUE may appear + * in standard header files. Or you may have conflicts with application- + * specific header files that you want to include together with these files. + * Defining HAVE_BOOLEAN before including jpeglib.h should make it work. + */ + +#ifndef HAVE_BOOLEAN +typedef int boolean; +#endif +#ifndef FALSE /* in case these macros already exist */ +#define FALSE 0 /* values of boolean */ +#endif +#ifndef TRUE +#define TRUE 1 +#endif + + +/* + * The remaining options affect code selection within the JPEG library, + * but they don't need to be visible to most applications using the library. + * To minimize application namespace pollution, the symbols won't be + * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined. + */ + +#ifdef JPEG_INTERNALS +#define JPEG_INTERNAL_OPTIONS +#endif + +#ifdef JPEG_INTERNAL_OPTIONS + + +/* + * These defines indicate whether to include various optional functions. + * Undefining some of these symbols will produce a smaller but less capable + * library. Note that you can leave certain source files out of the + * compilation/linking process if you've #undef'd the corresponding symbols. + * (You may HAVE to do that if your compiler doesn't like null source files.) + */ + +/* Arithmetic coding is unsupported for legal reasons. Complaints to IBM. */ + +/* Capability options common to encoder and decoder: */ + +#define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */ +#define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */ +#define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */ + +/* Encoder capability options: */ + +#undef C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ +#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ +#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ +#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */ +/* Note: if you selected 12-bit data precision, it is dangerous to turn off + * ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit + * precision, so jchuff.c normally uses entropy optimization to compute + * usable tables for higher precision. If you don't want to do optimization, + * you'll have to supply different default Huffman tables. + * The exact same statements apply for progressive JPEG: the default tables + * don't work for progressive mode. (This may get fixed, however.) + */ +#define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */ + +/* Decoder capability options: */ + +#undef D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ +#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ +#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ +#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */ +#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */ +#undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */ +#define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */ +#define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */ +#define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */ + +/* more capability options later, no doubt */ + + +/* + * Ordering of RGB data in scanlines passed to or from the application. + * If your application wants to deal with data in the order B,G,R, just + * change these macros. You can also deal with formats such as R,G,B,X + * (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing + * the offsets will also change the order in which colormap data is organized. + * RESTRICTIONS: + * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats. + * 2. These macros only affect RGB<=>YCbCr color conversion, so they are not + * useful if you are using JPEG color spaces other than YCbCr or grayscale. + * 3. The color quantizer modules will not behave desirably if RGB_PIXELSIZE + * is not 3 (they don't understand about dummy color components!). So you + * can't use color quantization if you change that value. + */ + +#define RGB_RED 0 /* Offset of Red in an RGB scanline element */ +#define RGB_GREEN 1 /* Offset of Green */ +#define RGB_BLUE 2 /* Offset of Blue */ +#define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */ + + +/* Definitions for speed-related optimizations. */ + + +/* If your compiler supports inline functions, define INLINE + * as the inline keyword; otherwise define it as empty. + */ + +#ifndef INLINE +#ifdef __GNUC__ /* for instance, GNU C knows about inline */ +#define INLINE __inline__ +#endif +#ifndef INLINE +#define INLINE /* default is to define it as empty */ +#endif +#endif + + +/* On some machines (notably 68000 series) "int" is 32 bits, but multiplying + * two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER + * as short on such a machine. MULTIPLIER must be at least 16 bits wide. + */ + +#ifndef MULTIPLIER +#define MULTIPLIER int /* type for fastest integer multiply */ +#endif + + +/* FAST_FLOAT should be either float or double, whichever is done faster + * by your compiler. (Note that this type is only used in the floating point + * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.) + * Typically, float is faster in ANSI C compilers, while double is faster in + * pre-ANSI compilers (because they insist on converting to double anyway). + * The code below therefore chooses float if we have ANSI-style prototypes. + */ + +#ifndef FAST_FLOAT +#ifdef HAVE_PROTOTYPES +#define FAST_FLOAT float +#else +#define FAST_FLOAT double +#endif +#endif + +#endif /* JPEG_INTERNAL_OPTIONS */ diff --git a/gs/jpeg/jpegint.h b/gs/jpeg/jpegint.h new file mode 100644 index 000000000..7ba30c3fa --- /dev/null +++ b/gs/jpeg/jpegint.h @@ -0,0 +1,388 @@ +/* + * jpegint.h + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file provides common declarations for the various JPEG modules. + * These declarations are considered internal to the JPEG library; most + * applications using the library shouldn't need to include this file. + */ + + +/* Declarations for both compression & decompression */ + +typedef enum { /* Operating modes for buffer controllers */ + JBUF_PASS_THRU, /* Plain stripwise operation */ + /* Remaining modes require a full-image buffer to have been created */ + JBUF_SAVE_SOURCE, /* Run source subobject only, save output */ + JBUF_CRANK_DEST, /* Run dest subobject only, using saved data */ + JBUF_SAVE_AND_PASS /* Run both subobjects, save output */ +} J_BUF_MODE; + +/* Values of global_state field (jdapi.c has some dependencies on ordering!) */ +#define CSTATE_START 100 /* after create_compress */ +#define CSTATE_SCANNING 101 /* start_compress done, write_scanlines OK */ +#define CSTATE_RAW_OK 102 /* start_compress done, write_raw_data OK */ +#define CSTATE_WRCOEFS 103 /* jpeg_write_coefficients done */ +#define DSTATE_START 200 /* after create_decompress */ +#define DSTATE_INHEADER 201 /* reading header markers, no SOS yet */ +#define DSTATE_READY 202 /* found SOS, ready for start_decompress */ +#define DSTATE_PRELOAD 203 /* reading multiscan file in start_decompress*/ +#define DSTATE_PRESCAN 204 /* performing dummy pass for 2-pass quant */ +#define DSTATE_SCANNING 205 /* start_decompress done, read_scanlines OK */ +#define DSTATE_RAW_OK 206 /* start_decompress done, read_raw_data OK */ +#define DSTATE_BUFIMAGE 207 /* expecting jpeg_start_output */ +#define DSTATE_BUFPOST 208 /* looking for SOS/EOI in jpeg_finish_output */ +#define DSTATE_RDCOEFS 209 /* reading file in jpeg_read_coefficients */ +#define DSTATE_STOPPING 210 /* looking for EOI in jpeg_finish_decompress */ + + +/* Declarations for compression modules */ + +/* Master control module */ +struct jpeg_comp_master { + JMETHOD(void, prepare_for_pass, (j_compress_ptr cinfo)); + JMETHOD(void, pass_startup, (j_compress_ptr cinfo)); + JMETHOD(void, finish_pass, (j_compress_ptr cinfo)); + + /* State variables made visible to other modules */ + boolean call_pass_startup; /* True if pass_startup must be called */ + boolean is_last_pass; /* True during last pass */ +}; + +/* Main buffer control (downsampled-data buffer) */ +struct jpeg_c_main_controller { + JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode)); + JMETHOD(void, process_data, (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, + JDIMENSION in_rows_avail)); +}; + +/* Compression preprocessing (downsampling input buffer control) */ +struct jpeg_c_prep_controller { + JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode)); + JMETHOD(void, pre_process_data, (j_compress_ptr cinfo, + JSAMPARRAY input_buf, + JDIMENSION *in_row_ctr, + JDIMENSION in_rows_avail, + JSAMPIMAGE output_buf, + JDIMENSION *out_row_group_ctr, + JDIMENSION out_row_groups_avail)); +}; + +/* Coefficient buffer control */ +struct jpeg_c_coef_controller { + JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode)); + JMETHOD(boolean, compress_data, (j_compress_ptr cinfo, + JSAMPIMAGE input_buf)); +}; + +/* Colorspace conversion */ +struct jpeg_color_converter { + JMETHOD(void, start_pass, (j_compress_ptr cinfo)); + JMETHOD(void, color_convert, (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPIMAGE output_buf, + JDIMENSION output_row, int num_rows)); +}; + +/* Downsampling */ +struct jpeg_downsampler { + JMETHOD(void, start_pass, (j_compress_ptr cinfo)); + JMETHOD(void, downsample, (j_compress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION in_row_index, + JSAMPIMAGE output_buf, + JDIMENSION out_row_group_index)); + + boolean need_context_rows; /* TRUE if need rows above & below */ +}; + +/* Forward DCT (also controls coefficient quantization) */ +struct jpeg_forward_dct { + JMETHOD(void, start_pass, (j_compress_ptr cinfo)); + /* perhaps this should be an array??? */ + JMETHOD(void, forward_DCT, (j_compress_ptr cinfo, + jpeg_component_info * compptr, + JSAMPARRAY sample_data, JBLOCKROW coef_blocks, + JDIMENSION start_row, JDIMENSION start_col, + JDIMENSION num_blocks)); +}; + +/* Entropy encoding */ +struct jpeg_entropy_encoder { + JMETHOD(void, start_pass, (j_compress_ptr cinfo, boolean gather_statistics)); + JMETHOD(boolean, encode_mcu, (j_compress_ptr cinfo, JBLOCKROW *MCU_data)); + JMETHOD(void, finish_pass, (j_compress_ptr cinfo)); +}; + +/* Marker writing */ +struct jpeg_marker_writer { + /* write_any_marker is exported for use by applications */ + /* Probably only COM and APPn markers should be written */ + JMETHOD(void, write_any_marker, (j_compress_ptr cinfo, int marker, + const JOCTET *dataptr, unsigned int datalen)); + JMETHOD(void, write_file_header, (j_compress_ptr cinfo)); + JMETHOD(void, write_frame_header, (j_compress_ptr cinfo)); + JMETHOD(void, write_scan_header, (j_compress_ptr cinfo)); + JMETHOD(void, write_file_trailer, (j_compress_ptr cinfo)); + JMETHOD(void, write_tables_only, (j_compress_ptr cinfo)); +}; + + +/* Declarations for decompression modules */ + +/* Master control module */ +struct jpeg_decomp_master { + JMETHOD(void, prepare_for_output_pass, (j_decompress_ptr cinfo)); + JMETHOD(void, finish_output_pass, (j_decompress_ptr cinfo)); + + /* State variables made visible to other modules */ + boolean is_dummy_pass; /* True during 1st pass for 2-pass quant */ +}; + +/* Input control module */ +struct jpeg_input_controller { + JMETHOD(int, consume_input, (j_decompress_ptr cinfo)); + JMETHOD(void, reset_input_controller, (j_decompress_ptr cinfo)); + JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo)); + JMETHOD(void, finish_input_pass, (j_decompress_ptr cinfo)); + + /* State variables made visible to other modules */ + boolean has_multiple_scans; /* True if file has multiple scans */ + boolean eoi_reached; /* True when EOI has been consumed */ +}; + +/* Main buffer control (downsampled-data buffer) */ +struct jpeg_d_main_controller { + JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)); + JMETHOD(void, process_data, (j_decompress_ptr cinfo, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail)); +}; + +/* Coefficient buffer control */ +struct jpeg_d_coef_controller { + JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo)); + JMETHOD(int, consume_data, (j_decompress_ptr cinfo)); + JMETHOD(void, start_output_pass, (j_decompress_ptr cinfo)); + JMETHOD(int, decompress_data, (j_decompress_ptr cinfo, + JSAMPIMAGE output_buf)); + /* Pointer to array of coefficient virtual arrays, or NULL if none */ + jvirt_barray_ptr *coef_arrays; +}; + +/* Decompression postprocessing (color quantization buffer control) */ +struct jpeg_d_post_controller { + JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)); + JMETHOD(void, post_process_data, (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, + JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, + JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail)); +}; + +/* Marker reading & parsing */ +struct jpeg_marker_reader { + JMETHOD(void, reset_marker_reader, (j_decompress_ptr cinfo)); + /* Read markers until SOS or EOI. + * Returns same codes as are defined for jpeg_consume_input: + * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI. + */ + JMETHOD(int, read_markers, (j_decompress_ptr cinfo)); + /* Read a restart marker --- exported for use by entropy decoder only */ + jpeg_marker_parser_method read_restart_marker; + /* Application-overridable marker processing methods */ + jpeg_marker_parser_method process_COM; + jpeg_marker_parser_method process_APPn[16]; + + /* State of marker reader --- nominally internal, but applications + * supplying COM or APPn handlers might like to know the state. + */ + boolean saw_SOI; /* found SOI? */ + boolean saw_SOF; /* found SOF? */ + int next_restart_num; /* next restart number expected (0-7) */ + unsigned int discarded_bytes; /* # of bytes skipped looking for a marker */ +}; + +/* Entropy decoding */ +struct jpeg_entropy_decoder { + JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); + JMETHOD(boolean, decode_mcu, (j_decompress_ptr cinfo, + JBLOCKROW *MCU_data)); +}; + +/* Inverse DCT (also performs dequantization) */ +typedef JMETHOD(void, inverse_DCT_method_ptr, + (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col)); + +struct jpeg_inverse_dct { + JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); + /* It is useful to allow each component to have a separate IDCT method. */ + inverse_DCT_method_ptr inverse_DCT[MAX_COMPONENTS]; +}; + +/* Upsampling (note that upsampler must also call color converter) */ +struct jpeg_upsampler { + JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); + JMETHOD(void, upsample, (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, + JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, + JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail)); + + boolean need_context_rows; /* TRUE if need rows above & below */ +}; + +/* Colorspace conversion */ +struct jpeg_color_deconverter { + JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); + JMETHOD(void, color_convert, (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION input_row, + JSAMPARRAY output_buf, int num_rows)); +}; + +/* Color quantization or color precision reduction */ +struct jpeg_color_quantizer { + JMETHOD(void, start_pass, (j_decompress_ptr cinfo, boolean is_pre_scan)); + JMETHOD(void, color_quantize, (j_decompress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPARRAY output_buf, + int num_rows)); + JMETHOD(void, finish_pass, (j_decompress_ptr cinfo)); + JMETHOD(void, new_color_map, (j_decompress_ptr cinfo)); +}; + + +/* Miscellaneous useful macros */ + +#undef MAX +#define MAX(a,b) ((a) > (b) ? (a) : (b)) +#undef MIN +#define MIN(a,b) ((a) < (b) ? (a) : (b)) + + +/* We assume that right shift corresponds to signed division by 2 with + * rounding towards minus infinity. This is correct for typical "arithmetic + * shift" instructions that shift in copies of the sign bit. But some + * C compilers implement >> with an unsigned shift. For these machines you + * must define RIGHT_SHIFT_IS_UNSIGNED. + * RIGHT_SHIFT provides a proper signed right shift of an INT32 quantity. + * It is only applied with constant shift counts. SHIFT_TEMPS must be + * included in the variables of any routine using RIGHT_SHIFT. + */ + +#ifdef RIGHT_SHIFT_IS_UNSIGNED +#define SHIFT_TEMPS INT32 shift_temp; +#define RIGHT_SHIFT(x,shft) \ + ((shift_temp = (x)) < 0 ? \ + (shift_temp >> (shft)) | ((~((INT32) 0)) << (32-(shft))) : \ + (shift_temp >> (shft))) +#else +#define SHIFT_TEMPS +#define RIGHT_SHIFT(x,shft) ((x) >> (shft)) +#endif + + +/* Short forms of external names for systems with brain-damaged linkers. */ + +#ifdef NEED_SHORT_EXTERNAL_NAMES +#define jinit_compress_master jICompress +#define jinit_c_master_control jICMaster +#define jinit_c_main_controller jICMainC +#define jinit_c_prep_controller jICPrepC +#define jinit_c_coef_controller jICCoefC +#define jinit_color_converter jICColor +#define jinit_downsampler jIDownsampler +#define jinit_forward_dct jIFDCT +#define jinit_huff_encoder jIHEncoder +#define jinit_phuff_encoder jIPHEncoder +#define jinit_marker_writer jIMWriter +#define jinit_master_decompress jIDMaster +#define jinit_d_main_controller jIDMainC +#define jinit_d_coef_controller jIDCoefC +#define jinit_d_post_controller jIDPostC +#define jinit_input_controller jIInCtlr +#define jinit_marker_reader jIMReader +#define jinit_huff_decoder jIHDecoder +#define jinit_phuff_decoder jIPHDecoder +#define jinit_inverse_dct jIIDCT +#define jinit_upsampler jIUpsampler +#define jinit_color_deconverter jIDColor +#define jinit_1pass_quantizer jI1Quant +#define jinit_2pass_quantizer jI2Quant +#define jinit_merged_upsampler jIMUpsampler +#define jinit_memory_mgr jIMemMgr +#define jdiv_round_up jDivRound +#define jround_up jRound +#define jcopy_sample_rows jCopySamples +#define jcopy_block_row jCopyBlocks +#define jzero_far jZeroFar +#define jpeg_zigzag_order jZIGTable +#define jpeg_natural_order jZAGTable +#endif /* NEED_SHORT_EXTERNAL_NAMES */ + + +/* Compression module initialization routines */ +EXTERN(void) jinit_compress_master JPP((j_compress_ptr cinfo)); +EXTERN(void) jinit_c_master_control JPP((j_compress_ptr cinfo, + boolean transcode_only)); +EXTERN(void) jinit_c_main_controller JPP((j_compress_ptr cinfo, + boolean need_full_buffer)); +EXTERN(void) jinit_c_prep_controller JPP((j_compress_ptr cinfo, + boolean need_full_buffer)); +EXTERN(void) jinit_c_coef_controller JPP((j_compress_ptr cinfo, + boolean need_full_buffer)); +EXTERN(void) jinit_color_converter JPP((j_compress_ptr cinfo)); +EXTERN(void) jinit_downsampler JPP((j_compress_ptr cinfo)); +EXTERN(void) jinit_forward_dct JPP((j_compress_ptr cinfo)); +EXTERN(void) jinit_huff_encoder JPP((j_compress_ptr cinfo)); +EXTERN(void) jinit_phuff_encoder JPP((j_compress_ptr cinfo)); +EXTERN(void) jinit_marker_writer JPP((j_compress_ptr cinfo)); +/* Decompression module initialization routines */ +EXTERN(void) jinit_master_decompress JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_d_main_controller JPP((j_decompress_ptr cinfo, + boolean need_full_buffer)); +EXTERN(void) jinit_d_coef_controller JPP((j_decompress_ptr cinfo, + boolean need_full_buffer)); +EXTERN(void) jinit_d_post_controller JPP((j_decompress_ptr cinfo, + boolean need_full_buffer)); +EXTERN(void) jinit_input_controller JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_marker_reader JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_huff_decoder JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_phuff_decoder JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_inverse_dct JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_upsampler JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_color_deconverter JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_1pass_quantizer JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_2pass_quantizer JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_merged_upsampler JPP((j_decompress_ptr cinfo)); +/* Memory manager initialization */ +EXTERN(void) jinit_memory_mgr JPP((j_common_ptr cinfo)); + +/* Utility routines in jutils.c */ +EXTERN(long) jdiv_round_up JPP((long a, long b)); +EXTERN(long) jround_up JPP((long a, long b)); +EXTERN(void) jcopy_sample_rows JPP((JSAMPARRAY input_array, int source_row, + JSAMPARRAY output_array, int dest_row, + int num_rows, JDIMENSION num_cols)); +EXTERN(void) jcopy_block_row JPP((JBLOCKROW input_row, JBLOCKROW output_row, + JDIMENSION num_blocks)); +EXTERN(void) jzero_far JPP((void FAR * target, size_t bytestozero)); +/* Constant tables in jutils.c */ +extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */ +extern const int jpeg_natural_order[]; /* zigzag coef order to natural order */ + +/* Suppress undefined-structure complaints if necessary. */ + +#ifdef INCOMPLETE_TYPES_BROKEN +#ifndef AM_MEMORY_MANAGER /* only jmemmgr.c defines these */ +struct jvirt_sarray_control { long dummy; }; +struct jvirt_barray_control { long dummy; }; +#endif +#endif /* INCOMPLETE_TYPES_BROKEN */ diff --git a/gs/jpeg/jpeglib.h b/gs/jpeg/jpeglib.h new file mode 100644 index 000000000..b778e2df7 --- /dev/null +++ b/gs/jpeg/jpeglib.h @@ -0,0 +1,1055 @@ +/* + * jpeglib.h + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file defines the application interface for the JPEG library. + * Most applications using the library need only include this file, + * and perhaps jerror.h if they want to know the exact error codes. + */ + +#ifndef JPEGLIB_H +#define JPEGLIB_H + +/* + * First we include the configuration files that record how this + * installation of the JPEG library is set up. jconfig.h can be + * generated automatically for many systems. jmorecfg.h contains + * manual configuration options that most people need not worry about. + */ + +#ifndef JCONFIG_INCLUDED /* in case jinclude.h already did */ +#include "jconfig.h" /* widely used configuration options */ +#endif +#include "jmorecfg.h" /* seldom changed options */ + + +/* Version ID for the JPEG library. + * Might be useful for tests like "#if JPEG_LIB_VERSION >= 60". + */ + +#define JPEG_LIB_VERSION 61 /* Version 6a */ + + +/* Various constants determining the sizes of things. + * All of these are specified by the JPEG standard, so don't change them + * if you want to be compatible. + */ + +#define DCTSIZE 8 /* The basic DCT block is 8x8 samples */ +#define DCTSIZE2 64 /* DCTSIZE squared; # of elements in a block */ +#define NUM_QUANT_TBLS 4 /* Quantization tables are numbered 0..3 */ +#define NUM_HUFF_TBLS 4 /* Huffman tables are numbered 0..3 */ +#define NUM_ARITH_TBLS 16 /* Arith-coding tables are numbered 0..15 */ +#define MAX_COMPS_IN_SCAN 4 /* JPEG limit on # of components in one scan */ +#define MAX_SAMP_FACTOR 4 /* JPEG limit on sampling factors */ +/* Unfortunately, some bozo at Adobe saw no reason to be bound by the standard; + * the PostScript DCT filter can emit files with many more than 10 blocks/MCU. + * If you happen to run across such a file, you can up D_MAX_BLOCKS_IN_MCU + * to handle it. We even let you do this from the jconfig.h file. However, + * we strongly discourage changing C_MAX_BLOCKS_IN_MCU; just because Adobe + * sometimes emits noncompliant files doesn't mean you should too. + */ +#define C_MAX_BLOCKS_IN_MCU 10 /* compressor's limit on blocks per MCU */ +#ifndef D_MAX_BLOCKS_IN_MCU +#define D_MAX_BLOCKS_IN_MCU 10 /* decompressor's limit on blocks per MCU */ +#endif + + +/* Data structures for images (arrays of samples and of DCT coefficients). + * On 80x86 machines, the image arrays are too big for near pointers, + * but the pointer arrays can fit in near memory. + */ + +typedef JSAMPLE FAR *JSAMPROW; /* ptr to one image row of pixel samples. */ +typedef JSAMPROW *JSAMPARRAY; /* ptr to some rows (a 2-D sample array) */ +typedef JSAMPARRAY *JSAMPIMAGE; /* a 3-D sample array: top index is color */ + +typedef JCOEF JBLOCK[DCTSIZE2]; /* one block of coefficients */ +typedef JBLOCK FAR *JBLOCKROW; /* pointer to one row of coefficient blocks */ +typedef JBLOCKROW *JBLOCKARRAY; /* a 2-D array of coefficient blocks */ +typedef JBLOCKARRAY *JBLOCKIMAGE; /* a 3-D array of coefficient blocks */ + +typedef JCOEF FAR *JCOEFPTR; /* useful in a couple of places */ + + +/* Types for JPEG compression parameters and working tables. */ + + +/* DCT coefficient quantization tables. */ + +typedef struct { + /* This array gives the coefficient quantizers in natural array order + * (not the zigzag order in which they are stored in a JPEG DQT marker). + * CAUTION: IJG versions prior to v6a kept this array in zigzag order. + */ + UINT16 quantval[DCTSIZE2]; /* quantization step for each coefficient */ + /* This field is used only during compression. It's initialized FALSE when + * the table is created, and set TRUE when it's been output to the file. + * You could suppress output of a table by setting this to TRUE. + * (See jpeg_suppress_tables for an example.) + */ + boolean sent_table; /* TRUE when table has been output */ +} JQUANT_TBL; + + +/* Huffman coding tables. */ + +typedef struct { + /* These two fields directly represent the contents of a JPEG DHT marker */ + UINT8 bits[17]; /* bits[k] = # of symbols with codes of */ + /* length k bits; bits[0] is unused */ + UINT8 huffval[256]; /* The symbols, in order of incr code length */ + /* This field is used only during compression. It's initialized FALSE when + * the table is created, and set TRUE when it's been output to the file. + * You could suppress output of a table by setting this to TRUE. + * (See jpeg_suppress_tables for an example.) + */ + boolean sent_table; /* TRUE when table has been output */ +} JHUFF_TBL; + + +/* Basic info about one component (color channel). */ + +typedef struct { + /* These values are fixed over the whole image. */ + /* For compression, they must be supplied by parameter setup; */ + /* for decompression, they are read from the SOF marker. */ + int component_id; /* identifier for this component (0..255) */ + int component_index; /* its index in SOF or cinfo->comp_info[] */ + int h_samp_factor; /* horizontal sampling factor (1..4) */ + int v_samp_factor; /* vertical sampling factor (1..4) */ + int quant_tbl_no; /* quantization table selector (0..3) */ + /* These values may vary between scans. */ + /* For compression, they must be supplied by parameter setup; */ + /* for decompression, they are read from the SOS marker. */ + /* The decompressor output side may not use these variables. */ + int dc_tbl_no; /* DC entropy table selector (0..3) */ + int ac_tbl_no; /* AC entropy table selector (0..3) */ + + /* Remaining fields should be treated as private by applications. */ + + /* These values are computed during compression or decompression startup: */ + /* Component's size in DCT blocks. + * Any dummy blocks added to complete an MCU are not counted; therefore + * these values do not depend on whether a scan is interleaved or not. + */ + JDIMENSION width_in_blocks; + JDIMENSION height_in_blocks; + /* Size of a DCT block in samples. Always DCTSIZE for compression. + * For decompression this is the size of the output from one DCT block, + * reflecting any scaling we choose to apply during the IDCT step. + * Values of 1,2,4,8 are likely to be supported. Note that different + * components may receive different IDCT scalings. + */ + int DCT_scaled_size; + /* The downsampled dimensions are the component's actual, unpadded number + * of samples at the main buffer (preprocessing/compression interface), thus + * downsampled_width = ceil(image_width * Hi/Hmax) + * and similarly for height. For decompression, IDCT scaling is included, so + * downsampled_width = ceil(image_width * Hi/Hmax * DCT_scaled_size/DCTSIZE) + */ + JDIMENSION downsampled_width; /* actual width in samples */ + JDIMENSION downsampled_height; /* actual height in samples */ + /* This flag is used only for decompression. In cases where some of the + * components will be ignored (eg grayscale output from YCbCr image), + * we can skip most computations for the unused components. + */ + boolean component_needed; /* do we need the value of this component? */ + + /* These values are computed before starting a scan of the component. */ + /* The decompressor output side may not use these variables. */ + int MCU_width; /* number of blocks per MCU, horizontally */ + int MCU_height; /* number of blocks per MCU, vertically */ + int MCU_blocks; /* MCU_width * MCU_height */ + int MCU_sample_width; /* MCU width in samples, MCU_width*DCT_scaled_size */ + int last_col_width; /* # of non-dummy blocks across in last MCU */ + int last_row_height; /* # of non-dummy blocks down in last MCU */ + + /* Saved quantization table for component; NULL if none yet saved. + * See jdinput.c comments about the need for this information. + * This field is currently used only for decompression. + */ + JQUANT_TBL * quant_table; + + /* Private per-component storage for DCT or IDCT subsystem. */ + void * dct_table; +} jpeg_component_info; + + +/* The script for encoding a multiple-scan file is an array of these: */ + +typedef struct { + int comps_in_scan; /* number of components encoded in this scan */ + int component_index[MAX_COMPS_IN_SCAN]; /* their SOF/comp_info[] indexes */ + int Ss, Se; /* progressive JPEG spectral selection parms */ + int Ah, Al; /* progressive JPEG successive approx. parms */ +} jpeg_scan_info; + + +/* Known color spaces. */ + +typedef enum { + JCS_UNKNOWN, /* error/unspecified */ + JCS_GRAYSCALE, /* monochrome */ + JCS_RGB, /* red/green/blue */ + JCS_YCbCr, /* Y/Cb/Cr (also known as YUV) */ + JCS_CMYK, /* C/M/Y/K */ + JCS_YCCK /* Y/Cb/Cr/K */ +} J_COLOR_SPACE; + +/* DCT/IDCT algorithm options. */ + +typedef enum { + JDCT_ISLOW, /* slow but accurate integer algorithm */ + JDCT_IFAST, /* faster, less accurate integer method */ + JDCT_FLOAT /* floating-point: accurate, fast on fast HW */ +} J_DCT_METHOD; + +#ifndef JDCT_DEFAULT /* may be overridden in jconfig.h */ +#define JDCT_DEFAULT JDCT_ISLOW +#endif +#ifndef JDCT_FASTEST /* may be overridden in jconfig.h */ +#define JDCT_FASTEST JDCT_IFAST +#endif + +/* Dithering options for decompression. */ + +typedef enum { + JDITHER_NONE, /* no dithering */ + JDITHER_ORDERED, /* simple ordered dither */ + JDITHER_FS /* Floyd-Steinberg error diffusion dither */ +} J_DITHER_MODE; + + +/* Common fields between JPEG compression and decompression master structs. */ + +#define jpeg_common_fields \ + struct jpeg_error_mgr * err; /* Error handler module */\ + struct jpeg_memory_mgr * mem; /* Memory manager module */\ + struct jpeg_progress_mgr * progress; /* Progress monitor, or NULL if none */\ + boolean is_decompressor; /* so common code can tell which is which */\ + int global_state /* for checking call sequence validity */ + +/* Routines that are to be used by both halves of the library are declared + * to receive a pointer to this structure. There are no actual instances of + * jpeg_common_struct, only of jpeg_compress_struct and jpeg_decompress_struct. + */ +struct jpeg_common_struct { + jpeg_common_fields; /* Fields common to both master struct types */ + /* Additional fields follow in an actual jpeg_compress_struct or + * jpeg_decompress_struct. All three structs must agree on these + * initial fields! (This would be a lot cleaner in C++.) + */ +}; + +typedef struct jpeg_common_struct * j_common_ptr; +typedef struct jpeg_compress_struct * j_compress_ptr; +typedef struct jpeg_decompress_struct * j_decompress_ptr; + + +/* Master record for a compression instance */ + +struct jpeg_compress_struct { + jpeg_common_fields; /* Fields shared with jpeg_decompress_struct */ + + /* Destination for compressed data */ + struct jpeg_destination_mgr * dest; + + /* Description of source image --- these fields must be filled in by + * outer application before starting compression. in_color_space must + * be correct before you can even call jpeg_set_defaults(). + */ + + JDIMENSION image_width; /* input image width */ + JDIMENSION image_height; /* input image height */ + int input_components; /* # of color components in input image */ + J_COLOR_SPACE in_color_space; /* colorspace of input image */ + + double input_gamma; /* image gamma of input image */ + + /* Compression parameters --- these fields must be set before calling + * jpeg_start_compress(). We recommend calling jpeg_set_defaults() to + * initialize everything to reasonable defaults, then changing anything + * the application specifically wants to change. That way you won't get + * burnt when new parameters are added. Also note that there are several + * helper routines to simplify changing parameters. + */ + + int data_precision; /* bits of precision in image data */ + + int num_components; /* # of color components in JPEG image */ + J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */ + + jpeg_component_info * comp_info; + /* comp_info[i] describes component that appears i'th in SOF */ + + JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]; + /* ptrs to coefficient quantization tables, or NULL if not defined */ + + JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; + JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; + /* ptrs to Huffman coding tables, or NULL if not defined */ + + UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */ + UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */ + UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */ + + int num_scans; /* # of entries in scan_info array */ + const jpeg_scan_info * scan_info; /* script for multi-scan file, or NULL */ + /* The default value of scan_info is NULL, which causes a single-scan + * sequential JPEG file to be emitted. To create a multi-scan file, + * set num_scans and scan_info to point to an array of scan definitions. + */ + + boolean raw_data_in; /* TRUE=caller supplies downsampled data */ + boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ + boolean optimize_coding; /* TRUE=optimize entropy encoding parms */ + boolean CCIR601_sampling; /* TRUE=first samples are cosited */ + int smoothing_factor; /* 1..100, or 0 for no input smoothing */ + J_DCT_METHOD dct_method; /* DCT algorithm selector */ + + /* The restart interval can be specified in absolute MCUs by setting + * restart_interval, or in MCU rows by setting restart_in_rows + * (in which case the correct restart_interval will be figured + * for each scan). + */ + unsigned int restart_interval; /* MCUs per restart, or 0 for no restart */ + int restart_in_rows; /* if > 0, MCU rows per restart interval */ + + /* Parameters controlling emission of special markers. */ + + boolean write_JFIF_header; /* should a JFIF marker be written? */ + /* These three values are not used by the JPEG code, merely copied */ + /* into the JFIF APP0 marker. density_unit can be 0 for unknown, */ + /* 1 for dots/inch, or 2 for dots/cm. Note that the pixel aspect */ + /* ratio is defined by X_density/Y_density even when density_unit=0. */ + UINT8 density_unit; /* JFIF code for pixel size units */ + UINT16 X_density; /* Horizontal pixel density */ + UINT16 Y_density; /* Vertical pixel density */ + boolean write_Adobe_marker; /* should an Adobe marker be written? */ + + /* State variable: index of next scanline to be written to + * jpeg_write_scanlines(). Application may use this to control its + * processing loop, e.g., "while (next_scanline < image_height)". + */ + + JDIMENSION next_scanline; /* 0 .. image_height-1 */ + + /* Remaining fields are known throughout compressor, but generally + * should not be touched by a surrounding application. + */ + + /* + * These fields are computed during compression startup + */ + boolean progressive_mode; /* TRUE if scan script uses progressive mode */ + int max_h_samp_factor; /* largest h_samp_factor */ + int max_v_samp_factor; /* largest v_samp_factor */ + + JDIMENSION total_iMCU_rows; /* # of iMCU rows to be input to coef ctlr */ + /* The coefficient controller receives data in units of MCU rows as defined + * for fully interleaved scans (whether the JPEG file is interleaved or not). + * There are v_samp_factor * DCTSIZE sample rows of each component in an + * "iMCU" (interleaved MCU) row. + */ + + /* + * These fields are valid during any one scan. + * They describe the components and MCUs actually appearing in the scan. + */ + int comps_in_scan; /* # of JPEG components in this scan */ + jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]; + /* *cur_comp_info[i] describes component that appears i'th in SOS */ + + JDIMENSION MCUs_per_row; /* # of MCUs across the image */ + JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */ + + int blocks_in_MCU; /* # of DCT blocks per MCU */ + int MCU_membership[C_MAX_BLOCKS_IN_MCU]; + /* MCU_membership[i] is index in cur_comp_info of component owning */ + /* i'th block in an MCU */ + + int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ + + /* + * Links to compression subobjects (methods and private variables of modules) + */ + struct jpeg_comp_master * master; + struct jpeg_c_main_controller * main; + struct jpeg_c_prep_controller * prep; + struct jpeg_c_coef_controller * coef; + struct jpeg_marker_writer * marker; + struct jpeg_color_converter * cconvert; + struct jpeg_downsampler * downsample; + struct jpeg_forward_dct * fdct; + struct jpeg_entropy_encoder * entropy; +}; + + +/* Master record for a decompression instance */ + +struct jpeg_decompress_struct { + jpeg_common_fields; /* Fields shared with jpeg_compress_struct */ + + /* Source of compressed data */ + struct jpeg_source_mgr * src; + + /* Basic description of image --- filled in by jpeg_read_header(). */ + /* Application may inspect these values to decide how to process image. */ + + JDIMENSION image_width; /* nominal image width (from SOF marker) */ + JDIMENSION image_height; /* nominal image height */ + int num_components; /* # of color components in JPEG image */ + J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */ + + /* Decompression processing parameters --- these fields must be set before + * calling jpeg_start_decompress(). Note that jpeg_read_header() initializes + * them to default values. + */ + + J_COLOR_SPACE out_color_space; /* colorspace for output */ + + unsigned int scale_num, scale_denom; /* fraction by which to scale image */ + + double output_gamma; /* image gamma wanted in output */ + + boolean buffered_image; /* TRUE=multiple output passes */ + boolean raw_data_out; /* TRUE=downsampled data wanted */ + + J_DCT_METHOD dct_method; /* IDCT algorithm selector */ + boolean do_fancy_upsampling; /* TRUE=apply fancy upsampling */ + boolean do_block_smoothing; /* TRUE=apply interblock smoothing */ + + boolean quantize_colors; /* TRUE=colormapped output wanted */ + /* the following are ignored if not quantize_colors: */ + J_DITHER_MODE dither_mode; /* type of color dithering to use */ + boolean two_pass_quantize; /* TRUE=use two-pass color quantization */ + int desired_number_of_colors; /* max # colors to use in created colormap */ + /* these are significant only in buffered-image mode: */ + boolean enable_1pass_quant; /* enable future use of 1-pass quantizer */ + boolean enable_external_quant;/* enable future use of external colormap */ + boolean enable_2pass_quant; /* enable future use of 2-pass quantizer */ + + /* Description of actual output image that will be returned to application. + * These fields are computed by jpeg_start_decompress(). + * You can also use jpeg_calc_output_dimensions() to determine these values + * in advance of calling jpeg_start_decompress(). + */ + + JDIMENSION output_width; /* scaled image width */ + JDIMENSION output_height; /* scaled image height */ + int out_color_components; /* # of color components in out_color_space */ + int output_components; /* # of color components returned */ + /* output_components is 1 (a colormap index) when quantizing colors; + * otherwise it equals out_color_components. + */ + int rec_outbuf_height; /* min recommended height of scanline buffer */ + /* If the buffer passed to jpeg_read_scanlines() is less than this many rows + * high, space and time will be wasted due to unnecessary data copying. + * Usually rec_outbuf_height will be 1 or 2, at most 4. + */ + + /* When quantizing colors, the output colormap is described by these fields. + * The application can supply a colormap by setting colormap non-NULL before + * calling jpeg_start_decompress; otherwise a colormap is created during + * jpeg_start_decompress or jpeg_start_output. + * The map has out_color_components rows and actual_number_of_colors columns. + */ + int actual_number_of_colors; /* number of entries in use */ + JSAMPARRAY colormap; /* The color map as a 2-D pixel array */ + + /* State variables: these variables indicate the progress of decompression. + * The application may examine these but must not modify them. + */ + + /* Row index of next scanline to be read from jpeg_read_scanlines(). + * Application may use this to control its processing loop, e.g., + * "while (output_scanline < output_height)". + */ + JDIMENSION output_scanline; /* 0 .. output_height-1 */ + + /* Current input scan number and number of iMCU rows completed in scan. + * These indicate the progress of the decompressor input side. + */ + int input_scan_number; /* Number of SOS markers seen so far */ + JDIMENSION input_iMCU_row; /* Number of iMCU rows completed */ + + /* The "output scan number" is the notional scan being displayed by the + * output side. The decompressor will not allow output scan/row number + * to get ahead of input scan/row, but it can fall arbitrarily far behind. + */ + int output_scan_number; /* Nominal scan number being displayed */ + JDIMENSION output_iMCU_row; /* Number of iMCU rows read */ + + /* Current progression status. coef_bits[c][i] indicates the precision + * with which component c's DCT coefficient i (in zigzag order) is known. + * It is -1 when no data has yet been received, otherwise it is the point + * transform (shift) value for the most recent scan of the coefficient + * (thus, 0 at completion of the progression). + * This pointer is NULL when reading a non-progressive file. + */ + int (*coef_bits)[DCTSIZE2]; /* -1 or current Al value for each coef */ + + /* Internal JPEG parameters --- the application usually need not look at + * these fields. Note that the decompressor output side may not use + * any parameters that can change between scans. + */ + + /* Quantization and Huffman tables are carried forward across input + * datastreams when processing abbreviated JPEG datastreams. + */ + + JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]; + /* ptrs to coefficient quantization tables, or NULL if not defined */ + + JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; + JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; + /* ptrs to Huffman coding tables, or NULL if not defined */ + + /* These parameters are never carried across datastreams, since they + * are given in SOF/SOS markers or defined to be reset by SOI. + */ + + int data_precision; /* bits of precision in image data */ + + jpeg_component_info * comp_info; + /* comp_info[i] describes component that appears i'th in SOF */ + + boolean progressive_mode; /* TRUE if SOFn specifies progressive mode */ + boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ + + UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */ + UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */ + UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */ + + unsigned int restart_interval; /* MCUs per restart interval, or 0 for no restart */ + + /* These fields record data obtained from optional markers recognized by + * the JPEG library. + */ + boolean saw_JFIF_marker; /* TRUE iff a JFIF APP0 marker was found */ + /* Data copied from JFIF marker: */ + UINT8 density_unit; /* JFIF code for pixel size units */ + UINT16 X_density; /* Horizontal pixel density */ + UINT16 Y_density; /* Vertical pixel density */ + boolean saw_Adobe_marker; /* TRUE iff an Adobe APP14 marker was found */ + UINT8 Adobe_transform; /* Color transform code from Adobe marker */ + + boolean CCIR601_sampling; /* TRUE=first samples are cosited */ + + /* Remaining fields are known throughout decompressor, but generally + * should not be touched by a surrounding application. + */ + + /* + * These fields are computed during decompression startup + */ + int max_h_samp_factor; /* largest h_samp_factor */ + int max_v_samp_factor; /* largest v_samp_factor */ + + int min_DCT_scaled_size; /* smallest DCT_scaled_size of any component */ + + JDIMENSION total_iMCU_rows; /* # of iMCU rows in image */ + /* The coefficient controller's input and output progress is measured in + * units of "iMCU" (interleaved MCU) rows. These are the same as MCU rows + * in fully interleaved JPEG scans, but are used whether the scan is + * interleaved or not. We define an iMCU row as v_samp_factor DCT block + * rows of each component. Therefore, the IDCT output contains + * v_samp_factor*DCT_scaled_size sample rows of a component per iMCU row. + */ + + JSAMPLE * sample_range_limit; /* table for fast range-limiting */ + + /* + * These fields are valid during any one scan. + * They describe the components and MCUs actually appearing in the scan. + * Note that the decompressor output side must not use these fields. + */ + int comps_in_scan; /* # of JPEG components in this scan */ + jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]; + /* *cur_comp_info[i] describes component that appears i'th in SOS */ + + JDIMENSION MCUs_per_row; /* # of MCUs across the image */ + JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */ + + int blocks_in_MCU; /* # of DCT blocks per MCU */ + int MCU_membership[D_MAX_BLOCKS_IN_MCU]; + /* MCU_membership[i] is index in cur_comp_info of component owning */ + /* i'th block in an MCU */ + + int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ + + /* This field is shared between entropy decoder and marker parser. + * It is either zero or the code of a JPEG marker that has been + * read from the data source, but has not yet been processed. + */ + int unread_marker; + + /* + * Links to decompression subobjects (methods, private variables of modules) + */ + struct jpeg_decomp_master * master; + struct jpeg_d_main_controller * main; + struct jpeg_d_coef_controller * coef; + struct jpeg_d_post_controller * post; + struct jpeg_input_controller * inputctl; + struct jpeg_marker_reader * marker; + struct jpeg_entropy_decoder * entropy; + struct jpeg_inverse_dct * idct; + struct jpeg_upsampler * upsample; + struct jpeg_color_deconverter * cconvert; + struct jpeg_color_quantizer * cquantize; +}; + + +/* "Object" declarations for JPEG modules that may be supplied or called + * directly by the surrounding application. + * As with all objects in the JPEG library, these structs only define the + * publicly visible methods and state variables of a module. Additional + * private fields may exist after the public ones. + */ + + +/* Error handler object */ + +struct jpeg_error_mgr { + /* Error exit handler: does not return to caller */ + JMETHOD(void, error_exit, (j_common_ptr cinfo)); + /* Conditionally emit a trace or warning message */ + JMETHOD(void, emit_message, (j_common_ptr cinfo, int msg_level)); + /* Routine that actually outputs a trace or error message */ + JMETHOD(void, output_message, (j_common_ptr cinfo)); + /* Format a message string for the most recent JPEG error or message */ + JMETHOD(void, format_message, (j_common_ptr cinfo, char * buffer)); +#define JMSG_LENGTH_MAX 200 /* recommended size of format_message buffer */ + /* Reset error state variables at start of a new image */ + JMETHOD(void, reset_error_mgr, (j_common_ptr cinfo)); + + /* The message ID code and any parameters are saved here. + * A message can have one string parameter or up to 8 int parameters. + */ + int msg_code; +#define JMSG_STR_PARM_MAX 80 + union { + int i[8]; + char s[JMSG_STR_PARM_MAX]; + } msg_parm; + + /* Standard state variables for error facility */ + + int trace_level; /* max msg_level that will be displayed */ + + /* For recoverable corrupt-data errors, we emit a warning message, + * but keep going unless emit_message chooses to abort. emit_message + * should count warnings in num_warnings. The surrounding application + * can check for bad data by seeing if num_warnings is nonzero at the + * end of processing. + */ + long num_warnings; /* number of corrupt-data warnings */ + + /* These fields point to the table(s) of error message strings. + * An application can change the table pointer to switch to a different + * message list (typically, to change the language in which errors are + * reported). Some applications may wish to add additional error codes + * that will be handled by the JPEG library error mechanism; the second + * table pointer is used for this purpose. + * + * First table includes all errors generated by JPEG library itself. + * Error code 0 is reserved for a "no such error string" message. + */ + const char * const * jpeg_message_table; /* Library errors */ + int last_jpeg_message; /* Table contains strings 0..last_jpeg_message */ + /* Second table can be added by application (see cjpeg/djpeg for example). + * It contains strings numbered first_addon_message..last_addon_message. + */ + const char * const * addon_message_table; /* Non-library errors */ + int first_addon_message; /* code for first string in addon table */ + int last_addon_message; /* code for last string in addon table */ +}; + + +/* Progress monitor object */ + +struct jpeg_progress_mgr { + JMETHOD(void, progress_monitor, (j_common_ptr cinfo)); + + long pass_counter; /* work units completed in this pass */ + long pass_limit; /* total number of work units in this pass */ + int completed_passes; /* passes completed so far */ + int total_passes; /* total number of passes expected */ +}; + + +/* Data destination object for compression */ + +struct jpeg_destination_mgr { + JOCTET * next_output_byte; /* => next byte to write in buffer */ + size_t free_in_buffer; /* # of byte spaces remaining in buffer */ + + JMETHOD(void, init_destination, (j_compress_ptr cinfo)); + JMETHOD(boolean, empty_output_buffer, (j_compress_ptr cinfo)); + JMETHOD(void, term_destination, (j_compress_ptr cinfo)); +}; + + +/* Data source object for decompression */ + +struct jpeg_source_mgr { + const JOCTET * next_input_byte; /* => next byte to read from buffer */ + size_t bytes_in_buffer; /* # of bytes remaining in buffer */ + + JMETHOD(void, init_source, (j_decompress_ptr cinfo)); + JMETHOD(boolean, fill_input_buffer, (j_decompress_ptr cinfo)); + JMETHOD(void, skip_input_data, (j_decompress_ptr cinfo, long num_bytes)); + JMETHOD(boolean, resync_to_restart, (j_decompress_ptr cinfo, int desired)); + JMETHOD(void, term_source, (j_decompress_ptr cinfo)); +}; + + +/* Memory manager object. + * Allocates "small" objects (a few K total), "large" objects (tens of K), + * and "really big" objects (virtual arrays with backing store if needed). + * The memory manager does not allow individual objects to be freed; rather, + * each created object is assigned to a pool, and whole pools can be freed + * at once. This is faster and more convenient than remembering exactly what + * to free, especially where malloc()/free() are not too speedy. + * NB: alloc routines never return NULL. They exit to error_exit if not + * successful. + */ + +#define JPOOL_PERMANENT 0 /* lasts until master record is destroyed */ +#define JPOOL_IMAGE 1 /* lasts until done with image/datastream */ +#define JPOOL_NUMPOOLS 2 + +typedef struct jvirt_sarray_control * jvirt_sarray_ptr; +typedef struct jvirt_barray_control * jvirt_barray_ptr; + + +struct jpeg_memory_mgr { + /* Method pointers */ + JMETHOD(void *, alloc_small, (j_common_ptr cinfo, int pool_id, + size_t sizeofobject)); + JMETHOD(void FAR *, alloc_large, (j_common_ptr cinfo, int pool_id, + size_t sizeofobject)); + JMETHOD(JSAMPARRAY, alloc_sarray, (j_common_ptr cinfo, int pool_id, + JDIMENSION samplesperrow, + JDIMENSION numrows)); + JMETHOD(JBLOCKARRAY, alloc_barray, (j_common_ptr cinfo, int pool_id, + JDIMENSION blocksperrow, + JDIMENSION numrows)); + JMETHOD(jvirt_sarray_ptr, request_virt_sarray, (j_common_ptr cinfo, + int pool_id, + boolean pre_zero, + JDIMENSION samplesperrow, + JDIMENSION numrows, + JDIMENSION maxaccess)); + JMETHOD(jvirt_barray_ptr, request_virt_barray, (j_common_ptr cinfo, + int pool_id, + boolean pre_zero, + JDIMENSION blocksperrow, + JDIMENSION numrows, + JDIMENSION maxaccess)); + JMETHOD(void, realize_virt_arrays, (j_common_ptr cinfo)); + JMETHOD(JSAMPARRAY, access_virt_sarray, (j_common_ptr cinfo, + jvirt_sarray_ptr ptr, + JDIMENSION start_row, + JDIMENSION num_rows, + boolean writable)); + JMETHOD(JBLOCKARRAY, access_virt_barray, (j_common_ptr cinfo, + jvirt_barray_ptr ptr, + JDIMENSION start_row, + JDIMENSION num_rows, + boolean writable)); + JMETHOD(void, free_pool, (j_common_ptr cinfo, int pool_id)); + JMETHOD(void, self_destruct, (j_common_ptr cinfo)); + + /* Limit on memory allocation for this JPEG object. (Note that this is + * merely advisory, not a guaranteed maximum; it only affects the space + * used for virtual-array buffers.) May be changed by outer application + * after creating the JPEG object. + */ + long max_memory_to_use; +}; + + +/* Routine signature for application-supplied marker processing methods. + * Need not pass marker code since it is stored in cinfo->unread_marker. + */ +typedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo)); + + +/* Declarations for routines called by application. + * The JPP macro hides prototype parameters from compilers that can't cope. + * Note JPP requires double parentheses. + */ + +#ifdef HAVE_PROTOTYPES +#define JPP(arglist) arglist +#else +#define JPP(arglist) () +#endif + + +/* Short forms of external names for systems with brain-damaged linkers. + * We shorten external names to be unique in the first six letters, which + * is good enough for all known systems. + * (If your compiler itself needs names to be unique in less than 15 + * characters, you are out of luck. Get a better compiler.) + */ + +#ifdef NEED_SHORT_EXTERNAL_NAMES +#define jpeg_std_error jStdError +#define jpeg_CreateCompress jCreaCompress +#define jpeg_CreateDecompress jCreaDecompress +#define jpeg_destroy_compress jDestCompress +#define jpeg_destroy_decompress jDestDecompress +#define jpeg_stdio_dest jStdDest +#define jpeg_stdio_src jStdSrc +#define jpeg_set_defaults jSetDefaults +#define jpeg_set_colorspace jSetColorspace +#define jpeg_default_colorspace jDefColorspace +#define jpeg_set_quality jSetQuality +#define jpeg_set_linear_quality jSetLQuality +#define jpeg_add_quant_table jAddQuantTable +#define jpeg_quality_scaling jQualityScaling +#define jpeg_simple_progression jSimProgress +#define jpeg_suppress_tables jSuppressTables +#define jpeg_alloc_quant_table jAlcQTable +#define jpeg_alloc_huff_table jAlcHTable +#define jpeg_start_compress jStrtCompress +#define jpeg_write_scanlines jWrtScanlines +#define jpeg_finish_compress jFinCompress +#define jpeg_write_raw_data jWrtRawData +#define jpeg_write_marker jWrtMarker +#define jpeg_write_tables jWrtTables +#define jpeg_read_header jReadHeader +#define jpeg_start_decompress jStrtDecompress +#define jpeg_read_scanlines jReadScanlines +#define jpeg_finish_decompress jFinDecompress +#define jpeg_read_raw_data jReadRawData +#define jpeg_has_multiple_scans jHasMultScn +#define jpeg_start_output jStrtOutput +#define jpeg_finish_output jFinOutput +#define jpeg_input_complete jInComplete +#define jpeg_new_colormap jNewCMap +#define jpeg_consume_input jConsumeInput +#define jpeg_calc_output_dimensions jCalcDimensions +#define jpeg_set_marker_processor jSetMarker +#define jpeg_read_coefficients jReadCoefs +#define jpeg_write_coefficients jWrtCoefs +#define jpeg_copy_critical_parameters jCopyCrit +#define jpeg_abort_compress jAbrtCompress +#define jpeg_abort_decompress jAbrtDecompress +#define jpeg_abort jAbort +#define jpeg_destroy jDestroy +#define jpeg_resync_to_restart jResyncRestart +#endif /* NEED_SHORT_EXTERNAL_NAMES */ + + +/* Default error-management setup */ +EXTERN(struct jpeg_error_mgr *) jpeg_std_error + JPP((struct jpeg_error_mgr * err)); + +/* Initialization of JPEG compression objects. + * jpeg_create_compress() and jpeg_create_decompress() are the exported + * names that applications should call. These expand to calls on + * jpeg_CreateCompress and jpeg_CreateDecompress with additional information + * passed for version mismatch checking. + * NB: you must set up the error-manager BEFORE calling jpeg_create_xxx. + */ +#define jpeg_create_compress(cinfo) \ + jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \ + (size_t) sizeof(struct jpeg_compress_struct)) +#define jpeg_create_decompress(cinfo) \ + jpeg_CreateDecompress((cinfo), JPEG_LIB_VERSION, \ + (size_t) sizeof(struct jpeg_decompress_struct)) +EXTERN(void) jpeg_CreateCompress JPP((j_compress_ptr cinfo, + int version, size_t structsize)); +EXTERN(void) jpeg_CreateDecompress JPP((j_decompress_ptr cinfo, + int version, size_t structsize)); +/* Destruction of JPEG compression objects */ +EXTERN(void) jpeg_destroy_compress JPP((j_compress_ptr cinfo)); +EXTERN(void) jpeg_destroy_decompress JPP((j_decompress_ptr cinfo)); + +/* Standard data source and destination managers: stdio streams. */ +/* Caller is responsible for opening the file before and closing after. */ +EXTERN(void) jpeg_stdio_dest JPP((j_compress_ptr cinfo, FILE * outfile)); +EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FILE * infile)); + +/* Default parameter setup for compression */ +EXTERN(void) jpeg_set_defaults JPP((j_compress_ptr cinfo)); +/* Compression parameter setup aids */ +EXTERN(void) jpeg_set_colorspace JPP((j_compress_ptr cinfo, + J_COLOR_SPACE colorspace)); +EXTERN(void) jpeg_default_colorspace JPP((j_compress_ptr cinfo)); +EXTERN(void) jpeg_set_quality JPP((j_compress_ptr cinfo, int quality, + boolean force_baseline)); +EXTERN(void) jpeg_set_linear_quality JPP((j_compress_ptr cinfo, + int scale_factor, + boolean force_baseline)); +EXTERN(void) jpeg_add_quant_table JPP((j_compress_ptr cinfo, int which_tbl, + const unsigned int *basic_table, + int scale_factor, + boolean force_baseline)); +EXTERN(int) jpeg_quality_scaling JPP((int quality)); +EXTERN(void) jpeg_simple_progression JPP((j_compress_ptr cinfo)); +EXTERN(void) jpeg_suppress_tables JPP((j_compress_ptr cinfo, + boolean suppress)); +EXTERN(JQUANT_TBL *) jpeg_alloc_quant_table JPP((j_common_ptr cinfo)); +EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table JPP((j_common_ptr cinfo)); + +/* Main entry points for compression */ +EXTERN(void) jpeg_start_compress JPP((j_compress_ptr cinfo, + boolean write_all_tables)); +EXTERN(JDIMENSION) jpeg_write_scanlines JPP((j_compress_ptr cinfo, + JSAMPARRAY scanlines, + JDIMENSION num_lines)); +EXTERN(void) jpeg_finish_compress JPP((j_compress_ptr cinfo)); + +/* Replaces jpeg_write_scanlines when writing raw downsampled data. */ +EXTERN(JDIMENSION) jpeg_write_raw_data JPP((j_compress_ptr cinfo, + JSAMPIMAGE data, + JDIMENSION num_lines)); + +/* Write a special marker. See libjpeg.doc concerning safe usage. */ +EXTERN(void) jpeg_write_marker + JPP((j_compress_ptr cinfo, int marker, + const JOCTET * dataptr, unsigned int datalen)); + +/* Alternate compression function: just write an abbreviated table file */ +EXTERN(void) jpeg_write_tables JPP((j_compress_ptr cinfo)); + +/* Decompression startup: read start of JPEG datastream to see what's there */ +EXTERN(int) jpeg_read_header JPP((j_decompress_ptr cinfo, + boolean require_image)); +/* Return value is one of: */ +#define JPEG_SUSPENDED 0 /* Suspended due to lack of input data */ +#define JPEG_HEADER_OK 1 /* Found valid image datastream */ +#define JPEG_HEADER_TABLES_ONLY 2 /* Found valid table-specs-only datastream */ +/* If you pass require_image = TRUE (normal case), you need not check for + * a TABLES_ONLY return code; an abbreviated file will cause an error exit. + * JPEG_SUSPENDED is only possible if you use a data source module that can + * give a suspension return (the stdio source module doesn't). + */ + +/* Main entry points for decompression */ +EXTERN(boolean) jpeg_start_decompress JPP((j_decompress_ptr cinfo)); +EXTERN(JDIMENSION) jpeg_read_scanlines JPP((j_decompress_ptr cinfo, + JSAMPARRAY scanlines, + JDIMENSION max_lines)); +EXTERN(boolean) jpeg_finish_decompress JPP((j_decompress_ptr cinfo)); + +/* Replaces jpeg_read_scanlines when reading raw downsampled data. */ +EXTERN(JDIMENSION) jpeg_read_raw_data JPP((j_decompress_ptr cinfo, + JSAMPIMAGE data, + JDIMENSION max_lines)); + +/* Additional entry points for buffered-image mode. */ +EXTERN(boolean) jpeg_has_multiple_scans JPP((j_decompress_ptr cinfo)); +EXTERN(boolean) jpeg_start_output JPP((j_decompress_ptr cinfo, + int scan_number)); +EXTERN(boolean) jpeg_finish_output JPP((j_decompress_ptr cinfo)); +EXTERN(boolean) jpeg_input_complete JPP((j_decompress_ptr cinfo)); +EXTERN(void) jpeg_new_colormap JPP((j_decompress_ptr cinfo)); +EXTERN(int) jpeg_consume_input JPP((j_decompress_ptr cinfo)); +/* Return value is one of: */ +/* #define JPEG_SUSPENDED 0 Suspended due to lack of input data */ +#define JPEG_REACHED_SOS 1 /* Reached start of new scan */ +#define JPEG_REACHED_EOI 2 /* Reached end of image */ +#define JPEG_ROW_COMPLETED 3 /* Completed one iMCU row */ +#define JPEG_SCAN_COMPLETED 4 /* Completed last iMCU row of a scan */ + +/* Precalculate output dimensions for current decompression parameters. */ +EXTERN(void) jpeg_calc_output_dimensions JPP((j_decompress_ptr cinfo)); + +/* Install a special processing method for COM or APPn markers. */ +EXTERN(void) jpeg_set_marker_processor + JPP((j_decompress_ptr cinfo, int marker_code, + jpeg_marker_parser_method routine)); + +/* Read or write raw DCT coefficients --- useful for lossless transcoding. */ +EXTERN(jvirt_barray_ptr *) jpeg_read_coefficients JPP((j_decompress_ptr cinfo)); +EXTERN(void) jpeg_write_coefficients JPP((j_compress_ptr cinfo, + jvirt_barray_ptr * coef_arrays)); +EXTERN(void) jpeg_copy_critical_parameters JPP((j_decompress_ptr srcinfo, + j_compress_ptr dstinfo)); + +/* If you choose to abort compression or decompression before completing + * jpeg_finish_(de)compress, then you need to clean up to release memory, + * temporary files, etc. You can just call jpeg_destroy_(de)compress + * if you're done with the JPEG object, but if you want to clean it up and + * reuse it, call this: + */ +EXTERN(void) jpeg_abort_compress JPP((j_compress_ptr cinfo)); +EXTERN(void) jpeg_abort_decompress JPP((j_decompress_ptr cinfo)); + +/* Generic versions of jpeg_abort and jpeg_destroy that work on either + * flavor of JPEG object. These may be more convenient in some places. + */ +EXTERN(void) jpeg_abort JPP((j_common_ptr cinfo)); +EXTERN(void) jpeg_destroy JPP((j_common_ptr cinfo)); + +/* Default restart-marker-resync procedure for use by data source modules */ +EXTERN(boolean) jpeg_resync_to_restart JPP((j_decompress_ptr cinfo, + int desired)); + + +/* These marker codes are exported since applications and data source modules + * are likely to want to use them. + */ + +#define JPEG_RST0 0xD0 /* RST0 marker code */ +#define JPEG_EOI 0xD9 /* EOI marker code */ +#define JPEG_APP0 0xE0 /* APP0 marker code */ +#define JPEG_COM 0xFE /* COM marker code */ + + +/* If we have a brain-damaged compiler that emits warnings (or worse, errors) + * for structure definitions that are never filled in, keep it quiet by + * supplying dummy definitions for the various substructures. + */ + +#ifdef INCOMPLETE_TYPES_BROKEN +#ifndef JPEG_INTERNALS /* will be defined in jpegint.h */ +struct jvirt_sarray_control { long dummy; }; +struct jvirt_barray_control { long dummy; }; +struct jpeg_comp_master { long dummy; }; +struct jpeg_c_main_controller { long dummy; }; +struct jpeg_c_prep_controller { long dummy; }; +struct jpeg_c_coef_controller { long dummy; }; +struct jpeg_marker_writer { long dummy; }; +struct jpeg_color_converter { long dummy; }; +struct jpeg_downsampler { long dummy; }; +struct jpeg_forward_dct { long dummy; }; +struct jpeg_entropy_encoder { long dummy; }; +struct jpeg_decomp_master { long dummy; }; +struct jpeg_d_main_controller { long dummy; }; +struct jpeg_d_coef_controller { long dummy; }; +struct jpeg_d_post_controller { long dummy; }; +struct jpeg_input_controller { long dummy; }; +struct jpeg_marker_reader { long dummy; }; +struct jpeg_entropy_decoder { long dummy; }; +struct jpeg_inverse_dct { long dummy; }; +struct jpeg_upsampler { long dummy; }; +struct jpeg_color_deconverter { long dummy; }; +struct jpeg_color_quantizer { long dummy; }; +#endif /* JPEG_INTERNALS */ +#endif /* INCOMPLETE_TYPES_BROKEN */ + + +/* + * The JPEG library modules define JPEG_INTERNALS before including this file. + * The internal structure declarations are read only when that is true. + * Applications using the library should not include jpegint.h, but may wish + * to include jerror.h. + */ + +#ifdef JPEG_INTERNALS +#include "jpegint.h" /* fetch private declarations */ +#include "jerror.h" /* fetch error codes too */ +#endif + +#endif /* JPEGLIB_H */ diff --git a/gs/jpeg/jpegtran b/gs/jpeg/jpegtran new file mode 100755 index 000000000..5a4342ad2 Binary files /dev/null and b/gs/jpeg/jpegtran differ diff --git a/gs/jpeg/jpegtran.1 b/gs/jpeg/jpegtran.1 new file mode 100644 index 000000000..73198845c --- /dev/null +++ b/gs/jpeg/jpegtran.1 @@ -0,0 +1,150 @@ +.TH JPEGTRAN 1 "15 June 1995" +.SH NAME +jpegtran \- lossless transcoding of JPEG files +.SH SYNOPSIS +.B jpegtran +[ +.I options +] +[ +.I filename +] +.LP +.SH DESCRIPTION +.LP +.B jpegtran +translates JPEG files from one variant of JPEG to another, for example +from baseline JPEG to progressive JPEG. The transformation is lossless: +no image degradation occurs, which would not be true if you used +.B djpeg +followed by +.BR cjpeg . +However, you cannot alter the image quality, because that would not be +a lossless operation. +.B jpegtran +reads the named JPEG/JFIF file, or the standard input if no file is +named, and produces a JPEG/JFIF file on the standard output. +.SH OPTIONS +.B jpegtran +accepts a subset of the switches recognized by +.BR cjpeg . +If you specify no switches, you get a plain baseline JPEG output file. +.PP +All switch names may be abbreviated; for example, +.B \-optimize +may be written +.B \-opt +or +.BR \-o . +Upper and lower case are equivalent. +British spellings are also accepted (e.g., +.BR \-optimise ), +though for brevity these are not mentioned below. +.PP +The basic switches are: +.TP +.B \-optimize +Perform optimization of entropy encoding parameters. Without this, default +encoding parameters are used. +.B \-optimize +usually makes the JPEG file a little smaller, but at the price of slower +compression. Note that +.B \-progressive +implies +.BR \-optimize . +.TP +.B \-progressive +Create progressive JPEG file (see below). +.PP +The +.B \-progressive +switch creates a "progressive JPEG" file. In this type of JPEG file, the data +is stored in multiple scans of increasing quality. If the file is being +transmitted over a slow communications link, the decoder can use the first +scan to display a low-quality image very quickly, and can then improve the +display with each subsequent scan. The final image is exactly equivalent to a +standard JPEG file of the same quality setting, and the total file size is +about the same --- often a little smaller. +.B Caution: +progressive JPEG is not yet widely implemented, so many decoders will be +unable to view a progressive JPEG file at all. +.PP +Switches for advanced users: +.TP +.BI \-restart " N" +Emit a JPEG restart marker every N MCU rows, or every N MCU blocks if "B" is +attached to the number. +.B \-restart 0 +(the default) means no restart markers. +.TP +.BI \-maxmemory " N" +Set limit for amount of memory to use in processing large images. Value is +in thousands of bytes, or millions of bytes if "M" is attached to the +number. For example, +.B \-max 4m +selects 4000000 bytes. If more space is needed, temporary files will be used. +.TP +.BI \-outfile " name" +Send output image to the named file, not to standard output. +.TP +.B \-verbose +Enable debug printout. More +.BR \-v 's +give more output. Also, version information is printed at startup. +.TP +.B \-debug +Same as +.BR \-verbose . +.PP +The +.B \-restart +option inserts extra markers that allow a JPEG decoder to resynchronize after +a transmission error. Without restart markers, any damage to a compressed +file will usually ruin the image from the point of the error to the end of the +image; with restart markers, the damage is usually confined to the portion of +the image up to the next restart marker. Of course, the restart markers +occupy extra space. We recommend +.B \-restart 1 +for images that will be transmitted across unreliable networks such as Usenet. +.PP +Switches for wizards: +.TP +.BI \-scans " file" +Use the scan script given in the specified text file. +.PP +The "wizard" switches are intended for experimentation with JPEG. If you +don't know what you are doing, \fBdon't use them\fR. These switches are +documented further in the file wizard.doc. +.SH EXAMPLES +.LP +This example converts a baseline JPEG file to progressive form: +.IP +.B jpegtran \-progressive +.I foo.jpg +.B > +.I fooprog.jpg +.SH ENVIRONMENT +.TP +.B JPEGMEM +If this environment variable is set, its value is the default memory limit. +The value is specified as described for the +.B \-maxmemory +switch. +.B JPEGMEM +overrides the default value specified when the program was compiled, and +itself is overridden by an explicit +.BR \-maxmemory . +.SH SEE ALSO +.BR cjpeg (1), +.BR djpeg (1), +.BR rdjpgcom (1), +.BR wrjpgcom (1) +.br +Wallace, Gregory K. "The JPEG Still Picture Compression Standard", +Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44. +.SH AUTHOR +Independent JPEG Group +.SH BUGS +Arithmetic coding is not supported for legal reasons. +.PP +Still not as fast as we'd like. diff --git a/gs/jpeg/jpegtran.c b/gs/jpeg/jpegtran.c new file mode 100644 index 000000000..51901027c --- /dev/null +++ b/gs/jpeg/jpegtran.c @@ -0,0 +1,372 @@ +/* + * jpegtran.c + * + * Copyright (C) 1995-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a command-line user interface for JPEG transcoding. + * It is very similar to cjpeg.c, but provides lossless transcoding between + * different JPEG file formats. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ +#include "jversion.h" /* for version message */ + +#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ +#ifdef __MWERKS__ +#include /* Metrowerks needs this */ +#include /* ... and this */ +#endif +#ifdef THINK_C +#include /* Think declares it here */ +#endif +#endif + + +/* + * Argument-parsing code. + * The switch parser is designed to be useful with DOS-style command line + * syntax, ie, intermixed switches and file names, where only the switches + * to the left of a given file name affect processing of that file. + * The main program in this file doesn't actually use this capability... + */ + + +static const char * progname; /* program name for error messages */ +static char * outfilename; /* for -outfile switch */ + + +LOCAL(void) +usage (void) +/* complain about bad command line */ +{ + fprintf(stderr, "usage: %s [switches] ", progname); +#ifdef TWO_FILE_COMMANDLINE + fprintf(stderr, "inputfile outputfile\n"); +#else + fprintf(stderr, "[inputfile]\n"); +#endif + + fprintf(stderr, "Switches (names may be abbreviated):\n"); +#ifdef ENTROPY_OPT_SUPPORTED + fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression)\n"); +#endif +#ifdef C_PROGRESSIVE_SUPPORTED + fprintf(stderr, " -progressive Create progressive JPEG file\n"); +#endif + fprintf(stderr, "Switches for advanced users:\n"); + fprintf(stderr, " -restart N Set restart interval in rows, or in blocks with B\n"); + fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n"); + fprintf(stderr, " -outfile name Specify name for output file\n"); + fprintf(stderr, " -verbose or -debug Emit debug output\n"); + fprintf(stderr, "Switches for wizards:\n"); +#ifdef C_ARITH_CODING_SUPPORTED + fprintf(stderr, " -arithmetic Use arithmetic coding\n"); +#endif +#ifdef C_MULTISCAN_FILES_SUPPORTED + fprintf(stderr, " -scans file Create multi-scan JPEG per script file\n"); +#endif + exit(EXIT_FAILURE); +} + + +LOCAL(int) +parse_switches (j_compress_ptr cinfo, int argc, char **argv, + int last_file_arg_seen, boolean for_real) +/* Parse optional switches. + * Returns argv[] index of first file-name argument (== argc if none). + * Any file names with indexes <= last_file_arg_seen are ignored; + * they have presumably been processed in a previous iteration. + * (Pass 0 for last_file_arg_seen on the first or only iteration.) + * for_real is FALSE on the first (dummy) pass; we may skip any expensive + * processing. + */ +{ + int argn; + char * arg; + boolean simple_progressive; + char * scansarg = NULL; /* saves -scans parm if any */ + + /* Set up default JPEG parameters. */ + simple_progressive = FALSE; + outfilename = NULL; + cinfo->err->trace_level = 0; + + /* Scan command line options, adjust parameters */ + + for (argn = 1; argn < argc; argn++) { + arg = argv[argn]; + if (*arg != '-') { + /* Not a switch, must be a file name argument */ + if (argn <= last_file_arg_seen) { + outfilename = NULL; /* -outfile applies to just one input file */ + continue; /* ignore this name if previously processed */ + } + break; /* else done parsing switches */ + } + arg++; /* advance past switch marker character */ + + if (keymatch(arg, "arithmetic", 1)) { + /* Use arithmetic coding. */ +#ifdef C_ARITH_CODING_SUPPORTED + cinfo->arith_code = TRUE; +#else + fprintf(stderr, "%s: sorry, arithmetic coding not supported\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) { + /* Enable debug printouts. */ + /* On first -d, print version identification */ + static boolean printed_version = FALSE; + + if (! printed_version) { + fprintf(stderr, "Independent JPEG Group's JPEGTRAN, version %s\n%s\n", + JVERSION, JCOPYRIGHT); + printed_version = TRUE; + } + cinfo->err->trace_level++; + + } else if (keymatch(arg, "maxmemory", 3)) { + /* Maximum memory in Kb (or Mb with 'm'). */ + long lval; + char ch = 'x'; + + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) + usage(); + if (ch == 'm' || ch == 'M') + lval *= 1000L; + cinfo->mem->max_memory_to_use = lval * 1000L; + + } else if (keymatch(arg, "optimize", 1) || keymatch(arg, "optimise", 1)) { + /* Enable entropy parm optimization. */ +#ifdef ENTROPY_OPT_SUPPORTED + cinfo->optimize_coding = TRUE; +#else + fprintf(stderr, "%s: sorry, entropy optimization was not compiled\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else if (keymatch(arg, "outfile", 4)) { + /* Set output file name. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + outfilename = argv[argn]; /* save it away for later use */ + + } else if (keymatch(arg, "progressive", 1)) { + /* Select simple progressive mode. */ +#ifdef C_PROGRESSIVE_SUPPORTED + simple_progressive = TRUE; + /* We must postpone execution until num_components is known. */ +#else + fprintf(stderr, "%s: sorry, progressive output was not compiled\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else if (keymatch(arg, "restart", 1)) { + /* Restart interval in MCU rows (or in MCUs with 'b'). */ + long lval; + char ch = 'x'; + + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) + usage(); + if (lval < 0 || lval > 65535L) + usage(); + if (ch == 'b' || ch == 'B') { + cinfo->restart_interval = (unsigned int) lval; + cinfo->restart_in_rows = 0; /* else prior '-restart n' overrides me */ + } else { + cinfo->restart_in_rows = (int) lval; + /* restart_interval will be computed during startup */ + } + + } else if (keymatch(arg, "scans", 2)) { + /* Set scan script. */ +#ifdef C_MULTISCAN_FILES_SUPPORTED + if (++argn >= argc) /* advance to next argument */ + usage(); + scansarg = argv[argn]; + /* We must postpone reading the file in case -progressive appears. */ +#else + fprintf(stderr, "%s: sorry, multi-scan output was not compiled\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else { + usage(); /* bogus switch */ + } + } + + /* Post-switch-scanning cleanup */ + + if (for_real) { + +#ifdef C_PROGRESSIVE_SUPPORTED + if (simple_progressive) /* process -progressive; -scans can override */ + jpeg_simple_progression(cinfo); +#endif + +#ifdef C_MULTISCAN_FILES_SUPPORTED + if (scansarg != NULL) /* process -scans if it was present */ + if (! read_scan_script(cinfo, scansarg)) + usage(); +#endif + } + + return argn; /* return index of next arg (file name) */ +} + + +/* + * The main program. + */ + +int +main (int argc, char **argv) +{ + struct jpeg_decompress_struct srcinfo; + struct jpeg_compress_struct dstinfo; + struct jpeg_error_mgr jsrcerr, jdsterr; +#ifdef PROGRESS_REPORT + struct cdjpeg_progress_mgr progress; +#endif + jvirt_barray_ptr * coef_arrays; + int file_index; + FILE * input_file; + FILE * output_file; + + /* On Mac, fetch a command line. */ +#ifdef USE_CCOMMAND + argc = ccommand(&argv); +#endif + + progname = argv[0]; + if (progname == NULL || progname[0] == 0) + progname = "jpegtran"; /* in case C library doesn't provide it */ + + /* Initialize the JPEG decompression object with default error handling. */ + srcinfo.err = jpeg_std_error(&jsrcerr); + jpeg_create_decompress(&srcinfo); + /* Initialize the JPEG compression object with default error handling. */ + dstinfo.err = jpeg_std_error(&jdsterr); + jpeg_create_compress(&dstinfo); + + /* Now safe to enable signal catcher. + * Note: we assume only the decompression object will have virtual arrays. + */ +#ifdef NEED_SIGNAL_CATCHER + enable_signal_catcher((j_common_ptr) &srcinfo); +#endif + + /* Scan command line to find file names. + * It is convenient to use just one switch-parsing routine, but the switch + * values read here are ignored; we will rescan the switches after opening + * the input file. + */ + + file_index = parse_switches(&dstinfo, argc, argv, 0, FALSE); + jsrcerr.trace_level = jdsterr.trace_level; + srcinfo.mem->max_memory_to_use = dstinfo.mem->max_memory_to_use; + +#ifdef TWO_FILE_COMMANDLINE + /* Must have either -outfile switch or explicit output file name */ + if (outfilename == NULL) { + if (file_index != argc-2) { + fprintf(stderr, "%s: must name one input and one output file\n", + progname); + usage(); + } + outfilename = argv[file_index+1]; + } else { + if (file_index != argc-1) { + fprintf(stderr, "%s: must name one input and one output file\n", + progname); + usage(); + } + } +#else + /* Unix style: expect zero or one file name */ + if (file_index < argc-1) { + fprintf(stderr, "%s: only one input file\n", progname); + usage(); + } +#endif /* TWO_FILE_COMMANDLINE */ + + /* Open the input file. */ + if (file_index < argc) { + if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, argv[file_index]); + exit(EXIT_FAILURE); + } + } else { + /* default input file is stdin */ + input_file = read_stdin(); + } + + /* Open the output file. */ + if (outfilename != NULL) { + if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, outfilename); + exit(EXIT_FAILURE); + } + } else { + /* default output file is stdout */ + output_file = write_stdout(); + } + +#ifdef PROGRESS_REPORT + start_progress_monitor((j_common_ptr) &dstinfo, &progress); +#endif + + /* Specify data source for decompression */ + jpeg_stdio_src(&srcinfo, input_file); + + /* Read file header */ + (void) jpeg_read_header(&srcinfo, TRUE); + + /* Read source file as DCT coefficients */ + coef_arrays = jpeg_read_coefficients(&srcinfo); + + /* Initialize destination compression parameters from source values */ + jpeg_copy_critical_parameters(&srcinfo, &dstinfo); + + /* Adjust default compression parameters by re-parsing the options */ + file_index = parse_switches(&dstinfo, argc, argv, 0, TRUE); + + /* Specify data destination for compression */ + jpeg_stdio_dest(&dstinfo, output_file); + + /* Start compressor */ + jpeg_write_coefficients(&dstinfo, coef_arrays); + + /* ought to copy source comments here... */ + + /* Finish compression and release memory */ + jpeg_finish_compress(&dstinfo); + jpeg_destroy_compress(&dstinfo); + (void) jpeg_finish_decompress(&srcinfo); + jpeg_destroy_decompress(&srcinfo); + + /* Close files, if we opened them */ + if (input_file != stdin) + fclose(input_file); + if (output_file != stdout) + fclose(output_file); + +#ifdef PROGRESS_REPORT + end_progress_monitor((j_common_ptr) &dstinfo); +#endif + + /* All done. */ + exit(jsrcerr.num_warnings + jdsterr.num_warnings ?EXIT_WARNING:EXIT_SUCCESS); + return 0; /* suppress no-return-value warnings */ +} diff --git a/gs/jpeg/jquant1.c b/gs/jpeg/jquant1.c new file mode 100644 index 000000000..b2f96aa15 --- /dev/null +++ b/gs/jpeg/jquant1.c @@ -0,0 +1,856 @@ +/* + * jquant1.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains 1-pass color quantization (color mapping) routines. + * These routines provide mapping to a fixed color map using equally spaced + * color values. Optional Floyd-Steinberg or ordered dithering is available. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + +#ifdef QUANT_1PASS_SUPPORTED + + +/* + * The main purpose of 1-pass quantization is to provide a fast, if not very + * high quality, colormapped output capability. A 2-pass quantizer usually + * gives better visual quality; however, for quantized grayscale output this + * quantizer is perfectly adequate. Dithering is highly recommended with this + * quantizer, though you can turn it off if you really want to. + * + * In 1-pass quantization the colormap must be chosen in advance of seeing the + * image. We use a map consisting of all combinations of Ncolors[i] color + * values for the i'th component. The Ncolors[] values are chosen so that + * their product, the total number of colors, is no more than that requested. + * (In most cases, the product will be somewhat less.) + * + * Since the colormap is orthogonal, the representative value for each color + * component can be determined without considering the other components; + * then these indexes can be combined into a colormap index by a standard + * N-dimensional-array-subscript calculation. Most of the arithmetic involved + * can be precalculated and stored in the lookup table colorindex[]. + * colorindex[i][j] maps pixel value j in component i to the nearest + * representative value (grid plane) for that component; this index is + * multiplied by the array stride for component i, so that the + * index of the colormap entry closest to a given pixel value is just + * sum( colorindex[component-number][pixel-component-value] ) + * Aside from being fast, this scheme allows for variable spacing between + * representative values with no additional lookup cost. + * + * If gamma correction has been applied in color conversion, it might be wise + * to adjust the color grid spacing so that the representative colors are + * equidistant in linear space. At this writing, gamma correction is not + * implemented by jdcolor, so nothing is done here. + */ + + +/* Declarations for ordered dithering. + * + * We use a standard 16x16 ordered dither array. The basic concept of ordered + * dithering is described in many references, for instance Dale Schumacher's + * chapter II.2 of Graphics Gems II (James Arvo, ed. Academic Press, 1991). + * In place of Schumacher's comparisons against a "threshold" value, we add a + * "dither" value to the input pixel and then round the result to the nearest + * output value. The dither value is equivalent to (0.5 - threshold) times + * the distance between output values. For ordered dithering, we assume that + * the output colors are equally spaced; if not, results will probably be + * worse, since the dither may be too much or too little at a given point. + * + * The normal calculation would be to form pixel value + dither, range-limit + * this to 0..MAXJSAMPLE, and then index into the colorindex table as usual. + * We can skip the separate range-limiting step by extending the colorindex + * table in both directions. + */ + +#define ODITHER_SIZE 16 /* dimension of dither matrix */ +/* NB: if ODITHER_SIZE is not a power of 2, ODITHER_MASK uses will break */ +#define ODITHER_CELLS (ODITHER_SIZE*ODITHER_SIZE) /* # cells in matrix */ +#define ODITHER_MASK (ODITHER_SIZE-1) /* mask for wrapping around counters */ + +typedef int ODITHER_MATRIX[ODITHER_SIZE][ODITHER_SIZE]; +typedef int (*ODITHER_MATRIX_PTR)[ODITHER_SIZE]; + +static const UINT8 base_dither_matrix[ODITHER_SIZE][ODITHER_SIZE] = { + /* Bayer's order-4 dither array. Generated by the code given in + * Stephen Hawley's article "Ordered Dithering" in Graphics Gems I. + * The values in this array must range from 0 to ODITHER_CELLS-1. + */ + { 0,192, 48,240, 12,204, 60,252, 3,195, 51,243, 15,207, 63,255 }, + { 128, 64,176,112,140, 76,188,124,131, 67,179,115,143, 79,191,127 }, + { 32,224, 16,208, 44,236, 28,220, 35,227, 19,211, 47,239, 31,223 }, + { 160, 96,144, 80,172,108,156, 92,163, 99,147, 83,175,111,159, 95 }, + { 8,200, 56,248, 4,196, 52,244, 11,203, 59,251, 7,199, 55,247 }, + { 136, 72,184,120,132, 68,180,116,139, 75,187,123,135, 71,183,119 }, + { 40,232, 24,216, 36,228, 20,212, 43,235, 27,219, 39,231, 23,215 }, + { 168,104,152, 88,164,100,148, 84,171,107,155, 91,167,103,151, 87 }, + { 2,194, 50,242, 14,206, 62,254, 1,193, 49,241, 13,205, 61,253 }, + { 130, 66,178,114,142, 78,190,126,129, 65,177,113,141, 77,189,125 }, + { 34,226, 18,210, 46,238, 30,222, 33,225, 17,209, 45,237, 29,221 }, + { 162, 98,146, 82,174,110,158, 94,161, 97,145, 81,173,109,157, 93 }, + { 10,202, 58,250, 6,198, 54,246, 9,201, 57,249, 5,197, 53,245 }, + { 138, 74,186,122,134, 70,182,118,137, 73,185,121,133, 69,181,117 }, + { 42,234, 26,218, 38,230, 22,214, 41,233, 25,217, 37,229, 21,213 }, + { 170,106,154, 90,166,102,150, 86,169,105,153, 89,165,101,149, 85 } +}; + + +/* Declarations for Floyd-Steinberg dithering. + * + * Errors are accumulated into the array fserrors[], at a resolution of + * 1/16th of a pixel count. The error at a given pixel is propagated + * to its not-yet-processed neighbors using the standard F-S fractions, + * ... (here) 7/16 + * 3/16 5/16 1/16 + * We work left-to-right on even rows, right-to-left on odd rows. + * + * We can get away with a single array (holding one row's worth of errors) + * by using it to store the current row's errors at pixel columns not yet + * processed, but the next row's errors at columns already processed. We + * need only a few extra variables to hold the errors immediately around the + * current column. (If we are lucky, those variables are in registers, but + * even if not, they're probably cheaper to access than array elements are.) + * + * The fserrors[] array is indexed [component#][position]. + * We provide (#columns + 2) entries per component; the extra entry at each + * end saves us from special-casing the first and last pixels. + * + * Note: on a wide image, we might not have enough room in a PC's near data + * segment to hold the error array; so it is allocated with alloc_large. + */ + +#if BITS_IN_JSAMPLE == 8 +typedef INT16 FSERROR; /* 16 bits should be enough */ +typedef int LOCFSERROR; /* use 'int' for calculation temps */ +#else +typedef INT32 FSERROR; /* may need more than 16 bits */ +typedef INT32 LOCFSERROR; /* be sure calculation temps are big enough */ +#endif + +typedef FSERROR FAR *FSERRPTR; /* pointer to error array (in FAR storage!) */ + + +/* Private subobject */ + +#define MAX_Q_COMPS 4 /* max components I can handle */ + +typedef struct { + struct jpeg_color_quantizer pub; /* public fields */ + + /* Initially allocated colormap is saved here */ + JSAMPARRAY sv_colormap; /* The color map as a 2-D pixel array */ + int sv_actual; /* number of entries in use */ + + JSAMPARRAY colorindex; /* Precomputed mapping for speed */ + /* colorindex[i][j] = index of color closest to pixel value j in component i, + * premultiplied as described above. Since colormap indexes must fit into + * JSAMPLEs, the entries of this array will too. + */ + boolean is_padded; /* is the colorindex padded for odither? */ + + int Ncolors[MAX_Q_COMPS]; /* # of values alloced to each component */ + + /* Variables for ordered dithering */ + int row_index; /* cur row's vertical index in dither matrix */ + ODITHER_MATRIX_PTR odither[MAX_Q_COMPS]; /* one dither array per component */ + + /* Variables for Floyd-Steinberg dithering */ + FSERRPTR fserrors[MAX_Q_COMPS]; /* accumulated errors */ + boolean on_odd_row; /* flag to remember which row we are on */ +} my_cquantizer; + +typedef my_cquantizer * my_cquantize_ptr; + + +/* + * Policy-making subroutines for create_colormap and create_colorindex. + * These routines determine the colormap to be used. The rest of the module + * only assumes that the colormap is orthogonal. + * + * * select_ncolors decides how to divvy up the available colors + * among the components. + * * output_value defines the set of representative values for a component. + * * largest_input_value defines the mapping from input values to + * representative values for a component. + * Note that the latter two routines may impose different policies for + * different components, though this is not currently done. + */ + + +LOCAL(int) +select_ncolors (j_decompress_ptr cinfo, int Ncolors[]) +/* Determine allocation of desired colors to components, */ +/* and fill in Ncolors[] array to indicate choice. */ +/* Return value is total number of colors (product of Ncolors[] values). */ +{ + int nc = cinfo->out_color_components; /* number of color components */ + int max_colors = cinfo->desired_number_of_colors; + int total_colors, iroot, i, j; + boolean changed; + long temp; + static const int RGB_order[3] = { RGB_GREEN, RGB_RED, RGB_BLUE }; + + /* We can allocate at least the nc'th root of max_colors per component. */ + /* Compute floor(nc'th root of max_colors). */ + iroot = 1; + do { + iroot++; + temp = iroot; /* set temp = iroot ** nc */ + for (i = 1; i < nc; i++) + temp *= iroot; + } while (temp <= (long) max_colors); /* repeat till iroot exceeds root */ + iroot--; /* now iroot = floor(root) */ + + /* Must have at least 2 color values per component */ + if (iroot < 2) + ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, (int) temp); + + /* Initialize to iroot color values for each component */ + total_colors = 1; + for (i = 0; i < nc; i++) { + Ncolors[i] = iroot; + total_colors *= iroot; + } + /* We may be able to increment the count for one or more components without + * exceeding max_colors, though we know not all can be incremented. + * Sometimes, the first component can be incremented more than once! + * (Example: for 16 colors, we start at 2*2*2, go to 3*2*2, then 4*2*2.) + * In RGB colorspace, try to increment G first, then R, then B. + */ + do { + changed = FALSE; + for (i = 0; i < nc; i++) { + j = (cinfo->out_color_space == JCS_RGB ? RGB_order[i] : i); + /* calculate new total_colors if Ncolors[j] is incremented */ + temp = total_colors / Ncolors[j]; + temp *= Ncolors[j]+1; /* done in long arith to avoid oflo */ + if (temp > (long) max_colors) + break; /* won't fit, done with this pass */ + Ncolors[j]++; /* OK, apply the increment */ + total_colors = (int) temp; + changed = TRUE; + } + } while (changed); + + return total_colors; +} + + +LOCAL(int) +output_value (j_decompress_ptr cinfo, int ci, int j, int maxj) +/* Return j'th output value, where j will range from 0 to maxj */ +/* The output values must fall in 0..MAXJSAMPLE in increasing order */ +{ + /* We always provide values 0 and MAXJSAMPLE for each component; + * any additional values are equally spaced between these limits. + * (Forcing the upper and lower values to the limits ensures that + * dithering can't produce a color outside the selected gamut.) + */ + return (int) (((INT32) j * MAXJSAMPLE + maxj/2) / maxj); +} + + +LOCAL(int) +largest_input_value (j_decompress_ptr cinfo, int ci, int j, int maxj) +/* Return largest input value that should map to j'th output value */ +/* Must have largest(j=0) >= 0, and largest(j=maxj) >= MAXJSAMPLE */ +{ + /* Breakpoints are halfway between values returned by output_value */ + return (int) (((INT32) (2*j + 1) * MAXJSAMPLE + maxj) / (2*maxj)); +} + + +/* + * Create the colormap. + */ + +LOCAL(void) +create_colormap (j_decompress_ptr cinfo) +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + JSAMPARRAY colormap; /* Created colormap */ + int total_colors; /* Number of distinct output colors */ + int i,j,k, nci, blksize, blkdist, ptr, val; + + /* Select number of colors for each component */ + total_colors = select_ncolors(cinfo, cquantize->Ncolors); + + /* Report selected color counts */ + if (cinfo->out_color_components == 3) + TRACEMS4(cinfo, 1, JTRC_QUANT_3_NCOLORS, + total_colors, cquantize->Ncolors[0], + cquantize->Ncolors[1], cquantize->Ncolors[2]); + else + TRACEMS1(cinfo, 1, JTRC_QUANT_NCOLORS, total_colors); + + /* Allocate and fill in the colormap. */ + /* The colors are ordered in the map in standard row-major order, */ + /* i.e. rightmost (highest-indexed) color changes most rapidly. */ + + colormap = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) total_colors, (JDIMENSION) cinfo->out_color_components); + + /* blksize is number of adjacent repeated entries for a component */ + /* blkdist is distance between groups of identical entries for a component */ + blkdist = total_colors; + + for (i = 0; i < cinfo->out_color_components; i++) { + /* fill in colormap entries for i'th color component */ + nci = cquantize->Ncolors[i]; /* # of distinct values for this color */ + blksize = blkdist / nci; + for (j = 0; j < nci; j++) { + /* Compute j'th output value (out of nci) for component */ + val = output_value(cinfo, i, j, nci-1); + /* Fill in all colormap entries that have this value of this component */ + for (ptr = j * blksize; ptr < total_colors; ptr += blkdist) { + /* fill in blksize entries beginning at ptr */ + for (k = 0; k < blksize; k++) + colormap[i][ptr+k] = (JSAMPLE) val; + } + } + blkdist = blksize; /* blksize of this color is blkdist of next */ + } + + /* Save the colormap in private storage, + * where it will survive color quantization mode changes. + */ + cquantize->sv_colormap = colormap; + cquantize->sv_actual = total_colors; +} + + +/* + * Create the color index table. + */ + +LOCAL(void) +create_colorindex (j_decompress_ptr cinfo) +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + JSAMPROW indexptr; + int i,j,k, nci, blksize, val, pad; + + /* For ordered dither, we pad the color index tables by MAXJSAMPLE in + * each direction (input index values can be -MAXJSAMPLE .. 2*MAXJSAMPLE). + * This is not necessary in the other dithering modes. However, we + * flag whether it was done in case user changes dithering mode. + */ + if (cinfo->dither_mode == JDITHER_ORDERED) { + pad = MAXJSAMPLE*2; + cquantize->is_padded = TRUE; + } else { + pad = 0; + cquantize->is_padded = FALSE; + } + + cquantize->colorindex = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) (MAXJSAMPLE+1 + pad), + (JDIMENSION) cinfo->out_color_components); + + /* blksize is number of adjacent repeated entries for a component */ + blksize = cquantize->sv_actual; + + for (i = 0; i < cinfo->out_color_components; i++) { + /* fill in colorindex entries for i'th color component */ + nci = cquantize->Ncolors[i]; /* # of distinct values for this color */ + blksize = blksize / nci; + + /* adjust colorindex pointers to provide padding at negative indexes. */ + if (pad) + cquantize->colorindex[i] += MAXJSAMPLE; + + /* in loop, val = index of current output value, */ + /* and k = largest j that maps to current val */ + indexptr = cquantize->colorindex[i]; + val = 0; + k = largest_input_value(cinfo, i, 0, nci-1); + for (j = 0; j <= MAXJSAMPLE; j++) { + while (j > k) /* advance val if past boundary */ + k = largest_input_value(cinfo, i, ++val, nci-1); + /* premultiply so that no multiplication needed in main processing */ + indexptr[j] = (JSAMPLE) (val * blksize); + } + /* Pad at both ends if necessary */ + if (pad) + for (j = 1; j <= MAXJSAMPLE; j++) { + indexptr[-j] = indexptr[0]; + indexptr[MAXJSAMPLE+j] = indexptr[MAXJSAMPLE]; + } + } +} + + +/* + * Create an ordered-dither array for a component having ncolors + * distinct output values. + */ + +LOCAL(ODITHER_MATRIX_PTR) +make_odither_array (j_decompress_ptr cinfo, int ncolors) +{ + ODITHER_MATRIX_PTR odither; + int j,k; + INT32 num,den; + + odither = (ODITHER_MATRIX_PTR) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(ODITHER_MATRIX)); + /* The inter-value distance for this color is MAXJSAMPLE/(ncolors-1). + * Hence the dither value for the matrix cell with fill order f + * (f=0..N-1) should be (N-1-2*f)/(2*N) * MAXJSAMPLE/(ncolors-1). + * On 16-bit-int machine, be careful to avoid overflow. + */ + den = 2 * ODITHER_CELLS * ((INT32) (ncolors - 1)); + for (j = 0; j < ODITHER_SIZE; j++) { + for (k = 0; k < ODITHER_SIZE; k++) { + num = ((INT32) (ODITHER_CELLS-1 - 2*((int)base_dither_matrix[j][k]))) + * MAXJSAMPLE; + /* Ensure round towards zero despite C's lack of consistency + * about rounding negative values in integer division... + */ + odither[j][k] = (int) (num<0 ? -((-num)/den) : num/den); + } + } + return odither; +} + + +/* + * Create the ordered-dither tables. + * Components having the same number of representative colors may + * share a dither table. + */ + +LOCAL(void) +create_odither_tables (j_decompress_ptr cinfo) +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + ODITHER_MATRIX_PTR odither; + int i, j, nci; + + for (i = 0; i < cinfo->out_color_components; i++) { + nci = cquantize->Ncolors[i]; /* # of distinct values for this color */ + odither = NULL; /* search for matching prior component */ + for (j = 0; j < i; j++) { + if (nci == cquantize->Ncolors[j]) { + odither = cquantize->odither[j]; + break; + } + } + if (odither == NULL) /* need a new table? */ + odither = make_odither_array(cinfo, nci); + cquantize->odither[i] = odither; + } +} + + +/* + * Map some rows of pixels to the output colormapped representation. + */ + +METHODDEF(void) +color_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf, + JSAMPARRAY output_buf, int num_rows) +/* General case, no dithering */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + JSAMPARRAY colorindex = cquantize->colorindex; + register int pixcode, ci; + register JSAMPROW ptrin, ptrout; + int row; + JDIMENSION col; + JDIMENSION width = cinfo->output_width; + register int nc = cinfo->out_color_components; + + for (row = 0; row < num_rows; row++) { + ptrin = input_buf[row]; + ptrout = output_buf[row]; + for (col = width; col > 0; col--) { + pixcode = 0; + for (ci = 0; ci < nc; ci++) { + pixcode += GETJSAMPLE(colorindex[ci][GETJSAMPLE(*ptrin++)]); + } + *ptrout++ = (JSAMPLE) pixcode; + } + } +} + + +METHODDEF(void) +color_quantize3 (j_decompress_ptr cinfo, JSAMPARRAY input_buf, + JSAMPARRAY output_buf, int num_rows) +/* Fast path for out_color_components==3, no dithering */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + register int pixcode; + register JSAMPROW ptrin, ptrout; + JSAMPROW colorindex0 = cquantize->colorindex[0]; + JSAMPROW colorindex1 = cquantize->colorindex[1]; + JSAMPROW colorindex2 = cquantize->colorindex[2]; + int row; + JDIMENSION col; + JDIMENSION width = cinfo->output_width; + + for (row = 0; row < num_rows; row++) { + ptrin = input_buf[row]; + ptrout = output_buf[row]; + for (col = width; col > 0; col--) { + pixcode = GETJSAMPLE(colorindex0[GETJSAMPLE(*ptrin++)]); + pixcode += GETJSAMPLE(colorindex1[GETJSAMPLE(*ptrin++)]); + pixcode += GETJSAMPLE(colorindex2[GETJSAMPLE(*ptrin++)]); + *ptrout++ = (JSAMPLE) pixcode; + } + } +} + + +METHODDEF(void) +quantize_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf, + JSAMPARRAY output_buf, int num_rows) +/* General case, with ordered dithering */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + register JSAMPROW input_ptr; + register JSAMPROW output_ptr; + JSAMPROW colorindex_ci; + int * dither; /* points to active row of dither matrix */ + int row_index, col_index; /* current indexes into dither matrix */ + int nc = cinfo->out_color_components; + int ci; + int row; + JDIMENSION col; + JDIMENSION width = cinfo->output_width; + + for (row = 0; row < num_rows; row++) { + /* Initialize output values to 0 so can process components separately */ + jzero_far((void FAR *) output_buf[row], + (size_t) (width * SIZEOF(JSAMPLE))); + row_index = cquantize->row_index; + for (ci = 0; ci < nc; ci++) { + input_ptr = input_buf[row] + ci; + output_ptr = output_buf[row]; + colorindex_ci = cquantize->colorindex[ci]; + dither = cquantize->odither[ci][row_index]; + col_index = 0; + + for (col = width; col > 0; col--) { + /* Form pixel value + dither, range-limit to 0..MAXJSAMPLE, + * select output value, accumulate into output code for this pixel. + * Range-limiting need not be done explicitly, as we have extended + * the colorindex table to produce the right answers for out-of-range + * inputs. The maximum dither is +- MAXJSAMPLE; this sets the + * required amount of padding. + */ + *output_ptr += colorindex_ci[GETJSAMPLE(*input_ptr)+dither[col_index]]; + input_ptr += nc; + output_ptr++; + col_index = (col_index + 1) & ODITHER_MASK; + } + } + /* Advance row index for next row */ + row_index = (row_index + 1) & ODITHER_MASK; + cquantize->row_index = row_index; + } +} + + +METHODDEF(void) +quantize3_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf, + JSAMPARRAY output_buf, int num_rows) +/* Fast path for out_color_components==3, with ordered dithering */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + register int pixcode; + register JSAMPROW input_ptr; + register JSAMPROW output_ptr; + JSAMPROW colorindex0 = cquantize->colorindex[0]; + JSAMPROW colorindex1 = cquantize->colorindex[1]; + JSAMPROW colorindex2 = cquantize->colorindex[2]; + int * dither0; /* points to active row of dither matrix */ + int * dither1; + int * dither2; + int row_index, col_index; /* current indexes into dither matrix */ + int row; + JDIMENSION col; + JDIMENSION width = cinfo->output_width; + + for (row = 0; row < num_rows; row++) { + row_index = cquantize->row_index; + input_ptr = input_buf[row]; + output_ptr = output_buf[row]; + dither0 = cquantize->odither[0][row_index]; + dither1 = cquantize->odither[1][row_index]; + dither2 = cquantize->odither[2][row_index]; + col_index = 0; + + for (col = width; col > 0; col--) { + pixcode = GETJSAMPLE(colorindex0[GETJSAMPLE(*input_ptr++) + + dither0[col_index]]); + pixcode += GETJSAMPLE(colorindex1[GETJSAMPLE(*input_ptr++) + + dither1[col_index]]); + pixcode += GETJSAMPLE(colorindex2[GETJSAMPLE(*input_ptr++) + + dither2[col_index]]); + *output_ptr++ = (JSAMPLE) pixcode; + col_index = (col_index + 1) & ODITHER_MASK; + } + row_index = (row_index + 1) & ODITHER_MASK; + cquantize->row_index = row_index; + } +} + + +METHODDEF(void) +quantize_fs_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf, + JSAMPARRAY output_buf, int num_rows) +/* General case, with Floyd-Steinberg dithering */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + register LOCFSERROR cur; /* current error or pixel value */ + LOCFSERROR belowerr; /* error for pixel below cur */ + LOCFSERROR bpreverr; /* error for below/prev col */ + LOCFSERROR bnexterr; /* error for below/next col */ + LOCFSERROR delta; + register FSERRPTR errorptr; /* => fserrors[] at column before current */ + register JSAMPROW input_ptr; + register JSAMPROW output_ptr; + JSAMPROW colorindex_ci; + JSAMPROW colormap_ci; + int pixcode; + int nc = cinfo->out_color_components; + int dir; /* 1 for left-to-right, -1 for right-to-left */ + int dirnc; /* dir * nc */ + int ci; + int row; + JDIMENSION col; + JDIMENSION width = cinfo->output_width; + JSAMPLE *range_limit = cinfo->sample_range_limit; + SHIFT_TEMPS + + for (row = 0; row < num_rows; row++) { + /* Initialize output values to 0 so can process components separately */ + jzero_far((void FAR *) output_buf[row], + (size_t) (width * SIZEOF(JSAMPLE))); + for (ci = 0; ci < nc; ci++) { + input_ptr = input_buf[row] + ci; + output_ptr = output_buf[row]; + if (cquantize->on_odd_row) { + /* work right to left in this row */ + input_ptr += (width-1) * nc; /* so point to rightmost pixel */ + output_ptr += width-1; + dir = -1; + dirnc = -nc; + errorptr = cquantize->fserrors[ci] + (width+1); /* => entry after last column */ + } else { + /* work left to right in this row */ + dir = 1; + dirnc = nc; + errorptr = cquantize->fserrors[ci]; /* => entry before first column */ + } + colorindex_ci = cquantize->colorindex[ci]; + colormap_ci = cquantize->sv_colormap[ci]; + /* Preset error values: no error propagated to first pixel from left */ + cur = 0; + /* and no error propagated to row below yet */ + belowerr = bpreverr = 0; + + for (col = width; col > 0; col--) { + /* cur holds the error propagated from the previous pixel on the + * current line. Add the error propagated from the previous line + * to form the complete error correction term for this pixel, and + * round the error term (which is expressed * 16) to an integer. + * RIGHT_SHIFT rounds towards minus infinity, so adding 8 is correct + * for either sign of the error value. + * Note: errorptr points to *previous* column's array entry. + */ + cur = RIGHT_SHIFT(cur + errorptr[dir] + 8, 4); + /* Form pixel value + error, and range-limit to 0..MAXJSAMPLE. + * The maximum error is +- MAXJSAMPLE; this sets the required size + * of the range_limit array. + */ + cur += GETJSAMPLE(*input_ptr); + cur = GETJSAMPLE(range_limit[cur]); + /* Select output value, accumulate into output code for this pixel */ + pixcode = GETJSAMPLE(colorindex_ci[cur]); + *output_ptr += (JSAMPLE) pixcode; + /* Compute actual representation error at this pixel */ + /* Note: we can do this even though we don't have the final */ + /* pixel code, because the colormap is orthogonal. */ + cur -= GETJSAMPLE(colormap_ci[pixcode]); + /* Compute error fractions to be propagated to adjacent pixels. + * Add these into the running sums, and simultaneously shift the + * next-line error sums left by 1 column. + */ + bnexterr = cur; + delta = cur * 2; + cur += delta; /* form error * 3 */ + errorptr[0] = (FSERROR) (bpreverr + cur); + cur += delta; /* form error * 5 */ + bpreverr = belowerr + cur; + belowerr = bnexterr; + cur += delta; /* form error * 7 */ + /* At this point cur contains the 7/16 error value to be propagated + * to the next pixel on the current line, and all the errors for the + * next line have been shifted over. We are therefore ready to move on. + */ + input_ptr += dirnc; /* advance input ptr to next column */ + output_ptr += dir; /* advance output ptr to next column */ + errorptr += dir; /* advance errorptr to current column */ + } + /* Post-loop cleanup: we must unload the final error value into the + * final fserrors[] entry. Note we need not unload belowerr because + * it is for the dummy column before or after the actual array. + */ + errorptr[0] = (FSERROR) bpreverr; /* unload prev err into array */ + } + cquantize->on_odd_row = (cquantize->on_odd_row ? FALSE : TRUE); + } +} + + +/* + * Allocate workspace for Floyd-Steinberg errors. + */ + +LOCAL(void) +alloc_fs_workspace (j_decompress_ptr cinfo) +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + size_t arraysize; + int i; + + arraysize = (size_t) ((cinfo->output_width + 2) * SIZEOF(FSERROR)); + for (i = 0; i < cinfo->out_color_components; i++) { + cquantize->fserrors[i] = (FSERRPTR) + (*cinfo->mem->alloc_large)((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize); + } +} + + +/* + * Initialize for one-pass color quantization. + */ + +METHODDEF(void) +start_pass_1_quant (j_decompress_ptr cinfo, boolean is_pre_scan) +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + size_t arraysize; + int i; + + /* Install my colormap. */ + cinfo->colormap = cquantize->sv_colormap; + cinfo->actual_number_of_colors = cquantize->sv_actual; + + /* Initialize for desired dithering mode. */ + switch (cinfo->dither_mode) { + case JDITHER_NONE: + if (cinfo->out_color_components == 3) + cquantize->pub.color_quantize = color_quantize3; + else + cquantize->pub.color_quantize = color_quantize; + break; + case JDITHER_ORDERED: + if (cinfo->out_color_components == 3) + cquantize->pub.color_quantize = quantize3_ord_dither; + else + cquantize->pub.color_quantize = quantize_ord_dither; + cquantize->row_index = 0; /* initialize state for ordered dither */ + /* If user changed to ordered dither from another mode, + * we must recreate the color index table with padding. + * This will cost extra space, but probably isn't very likely. + */ + if (! cquantize->is_padded) + create_colorindex(cinfo); + /* Create ordered-dither tables if we didn't already. */ + if (cquantize->odither[0] == NULL) + create_odither_tables(cinfo); + break; + case JDITHER_FS: + cquantize->pub.color_quantize = quantize_fs_dither; + cquantize->on_odd_row = FALSE; /* initialize state for F-S dither */ + /* Allocate Floyd-Steinberg workspace if didn't already. */ + if (cquantize->fserrors[0] == NULL) + alloc_fs_workspace(cinfo); + /* Initialize the propagated errors to zero. */ + arraysize = (size_t) ((cinfo->output_width + 2) * SIZEOF(FSERROR)); + for (i = 0; i < cinfo->out_color_components; i++) + jzero_far((void FAR *) cquantize->fserrors[i], arraysize); + break; + default: + ERREXIT(cinfo, JERR_NOT_COMPILED); + break; + } +} + + +/* + * Finish up at the end of the pass. + */ + +METHODDEF(void) +finish_pass_1_quant (j_decompress_ptr cinfo) +{ + /* no work in 1-pass case */ +} + + +/* + * Switch to a new external colormap between output passes. + * Shouldn't get to this module! + */ + +METHODDEF(void) +new_color_map_1_quant (j_decompress_ptr cinfo) +{ + ERREXIT(cinfo, JERR_MODE_CHANGE); +} + + +/* + * Module initialization routine for 1-pass color quantization. + */ + +GLOBAL(void) +jinit_1pass_quantizer (j_decompress_ptr cinfo) +{ + my_cquantize_ptr cquantize; + + cquantize = (my_cquantize_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_cquantizer)); + cinfo->cquantize = (struct jpeg_color_quantizer *) cquantize; + cquantize->pub.start_pass = start_pass_1_quant; + cquantize->pub.finish_pass = finish_pass_1_quant; + cquantize->pub.new_color_map = new_color_map_1_quant; + cquantize->fserrors[0] = NULL; /* Flag FS workspace not allocated */ + cquantize->odither[0] = NULL; /* Also flag odither arrays not allocated */ + + /* Make sure my internal arrays won't overflow */ + if (cinfo->out_color_components > MAX_Q_COMPS) + ERREXIT1(cinfo, JERR_QUANT_COMPONENTS, MAX_Q_COMPS); + /* Make sure colormap indexes can be represented by JSAMPLEs */ + if (cinfo->desired_number_of_colors > (MAXJSAMPLE+1)) + ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXJSAMPLE+1); + + /* Create the colormap and color index table. */ + create_colormap(cinfo); + create_colorindex(cinfo); + + /* Allocate Floyd-Steinberg workspace now if requested. + * We do this now since it is FAR storage and may affect the memory + * manager's space calculations. If the user changes to FS dither + * mode in a later pass, we will allocate the space then, and will + * possibly overrun the max_memory_to_use setting. + */ + if (cinfo->dither_mode == JDITHER_FS) + alloc_fs_workspace(cinfo); +} + +#endif /* QUANT_1PASS_SUPPORTED */ diff --git a/gs/jpeg/jquant2.c b/gs/jpeg/jquant2.c new file mode 100644 index 000000000..af601e334 --- /dev/null +++ b/gs/jpeg/jquant2.c @@ -0,0 +1,1310 @@ +/* + * jquant2.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains 2-pass color quantization (color mapping) routines. + * These routines provide selection of a custom color map for an image, + * followed by mapping of the image to that color map, with optional + * Floyd-Steinberg dithering. + * It is also possible to use just the second pass to map to an arbitrary + * externally-given color map. + * + * Note: ordered dithering is not supported, since there isn't any fast + * way to compute intercolor distances; it's unclear that ordered dither's + * fundamental assumptions even hold with an irregularly spaced color map. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + +#ifdef QUANT_2PASS_SUPPORTED + + +/* + * This module implements the well-known Heckbert paradigm for color + * quantization. Most of the ideas used here can be traced back to + * Heckbert's seminal paper + * Heckbert, Paul. "Color Image Quantization for Frame Buffer Display", + * Proc. SIGGRAPH '82, Computer Graphics v.16 #3 (July 1982), pp 297-304. + * + * In the first pass over the image, we accumulate a histogram showing the + * usage count of each possible color. To keep the histogram to a reasonable + * size, we reduce the precision of the input; typical practice is to retain + * 5 or 6 bits per color, so that 8 or 4 different input values are counted + * in the same histogram cell. + * + * Next, the color-selection step begins with a box representing the whole + * color space, and repeatedly splits the "largest" remaining box until we + * have as many boxes as desired colors. Then the mean color in each + * remaining box becomes one of the possible output colors. + * + * The second pass over the image maps each input pixel to the closest output + * color (optionally after applying a Floyd-Steinberg dithering correction). + * This mapping is logically trivial, but making it go fast enough requires + * considerable care. + * + * Heckbert-style quantizers vary a good deal in their policies for choosing + * the "largest" box and deciding where to cut it. The particular policies + * used here have proved out well in experimental comparisons, but better ones + * may yet be found. + * + * In earlier versions of the IJG code, this module quantized in YCbCr color + * space, processing the raw upsampled data without a color conversion step. + * This allowed the color conversion math to be done only once per colormap + * entry, not once per pixel. However, that optimization precluded other + * useful optimizations (such as merging color conversion with upsampling) + * and it also interfered with desired capabilities such as quantizing to an + * externally-supplied colormap. We have therefore abandoned that approach. + * The present code works in the post-conversion color space, typically RGB. + * + * To improve the visual quality of the results, we actually work in scaled + * RGB space, giving G distances more weight than R, and R in turn more than + * B. To do everything in integer math, we must use integer scale factors. + * The 2/3/1 scale factors used here correspond loosely to the relative + * weights of the colors in the NTSC grayscale equation. + * If you want to use this code to quantize a non-RGB color space, you'll + * probably need to change these scale factors. + */ + +#define R_SCALE 2 /* scale R distances by this much */ +#define G_SCALE 3 /* scale G distances by this much */ +#define B_SCALE 1 /* and B by this much */ + +/* Relabel R/G/B as components 0/1/2, respecting the RGB ordering defined + * in jmorecfg.h. As the code stands, it will do the right thing for R,G,B + * and B,G,R orders. If you define some other weird order in jmorecfg.h, + * you'll get compile errors until you extend this logic. In that case + * you'll probably want to tweak the histogram sizes too. + */ + +#if RGB_RED == 0 +#define C0_SCALE R_SCALE +#endif +#if RGB_BLUE == 0 +#define C0_SCALE B_SCALE +#endif +#if RGB_GREEN == 1 +#define C1_SCALE G_SCALE +#endif +#if RGB_RED == 2 +#define C2_SCALE R_SCALE +#endif +#if RGB_BLUE == 2 +#define C2_SCALE B_SCALE +#endif + + +/* + * First we have the histogram data structure and routines for creating it. + * + * The number of bits of precision can be adjusted by changing these symbols. + * We recommend keeping 6 bits for G and 5 each for R and B. + * If you have plenty of memory and cycles, 6 bits all around gives marginally + * better results; if you are short of memory, 5 bits all around will save + * some space but degrade the results. + * To maintain a fully accurate histogram, we'd need to allocate a "long" + * (preferably unsigned long) for each cell. In practice this is overkill; + * we can get by with 16 bits per cell. Few of the cell counts will overflow, + * and clamping those that do overflow to the maximum value will give close- + * enough results. This reduces the recommended histogram size from 256Kb + * to 128Kb, which is a useful savings on PC-class machines. + * (In the second pass the histogram space is re-used for pixel mapping data; + * in that capacity, each cell must be able to store zero to the number of + * desired colors. 16 bits/cell is plenty for that too.) + * Since the JPEG code is intended to run in small memory model on 80x86 + * machines, we can't just allocate the histogram in one chunk. Instead + * of a true 3-D array, we use a row of pointers to 2-D arrays. Each + * pointer corresponds to a C0 value (typically 2^5 = 32 pointers) and + * each 2-D array has 2^6*2^5 = 2048 or 2^6*2^6 = 4096 entries. Note that + * on 80x86 machines, the pointer row is in near memory but the actual + * arrays are in far memory (same arrangement as we use for image arrays). + */ + +#define MAXNUMCOLORS (MAXJSAMPLE+1) /* maximum size of colormap */ + +/* These will do the right thing for either R,G,B or B,G,R color order, + * but you may not like the results for other color orders. + */ +#define HIST_C0_BITS 5 /* bits of precision in R/B histogram */ +#define HIST_C1_BITS 6 /* bits of precision in G histogram */ +#define HIST_C2_BITS 5 /* bits of precision in B/R histogram */ + +/* Number of elements along histogram axes. */ +#define HIST_C0_ELEMS (1<cquantize; + register JSAMPROW ptr; + register histptr histp; + register hist3d histogram = cquantize->histogram; + int row; + JDIMENSION col; + JDIMENSION width = cinfo->output_width; + + for (row = 0; row < num_rows; row++) { + ptr = input_buf[row]; + for (col = width; col > 0; col--) { + /* get pixel value and index into the histogram */ + histp = & histogram[GETJSAMPLE(ptr[0]) >> C0_SHIFT] + [GETJSAMPLE(ptr[1]) >> C1_SHIFT] + [GETJSAMPLE(ptr[2]) >> C2_SHIFT]; + /* increment, check for overflow and undo increment if so. */ + if (++(*histp) <= 0) + (*histp)--; + ptr += 3; + } + } +} + + +/* + * Next we have the really interesting routines: selection of a colormap + * given the completed histogram. + * These routines work with a list of "boxes", each representing a rectangular + * subset of the input color space (to histogram precision). + */ + +typedef struct { + /* The bounds of the box (inclusive); expressed as histogram indexes */ + int c0min, c0max; + int c1min, c1max; + int c2min, c2max; + /* The volume (actually 2-norm) of the box */ + INT32 volume; + /* The number of nonzero histogram cells within this box */ + long colorcount; +} box; + +typedef box * boxptr; + + +LOCAL(boxptr) +find_biggest_color_pop (boxptr boxlist, int numboxes) +/* Find the splittable box with the largest color population */ +/* Returns NULL if no splittable boxes remain */ +{ + register boxptr boxp; + register int i; + register long maxc = 0; + boxptr which = NULL; + + for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) { + if (boxp->colorcount > maxc && boxp->volume > 0) { + which = boxp; + maxc = boxp->colorcount; + } + } + return which; +} + + +LOCAL(boxptr) +find_biggest_volume (boxptr boxlist, int numboxes) +/* Find the splittable box with the largest (scaled) volume */ +/* Returns NULL if no splittable boxes remain */ +{ + register boxptr boxp; + register int i; + register INT32 maxv = 0; + boxptr which = NULL; + + for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) { + if (boxp->volume > maxv) { + which = boxp; + maxv = boxp->volume; + } + } + return which; +} + + +LOCAL(void) +update_box (j_decompress_ptr cinfo, boxptr boxp) +/* Shrink the min/max bounds of a box to enclose only nonzero elements, */ +/* and recompute its volume and population */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + hist3d histogram = cquantize->histogram; + histptr histp; + int c0,c1,c2; + int c0min,c0max,c1min,c1max,c2min,c2max; + INT32 dist0,dist1,dist2; + long ccount; + + c0min = boxp->c0min; c0max = boxp->c0max; + c1min = boxp->c1min; c1max = boxp->c1max; + c2min = boxp->c2min; c2max = boxp->c2max; + + if (c0max > c0min) + for (c0 = c0min; c0 <= c0max; c0++) + for (c1 = c1min; c1 <= c1max; c1++) { + histp = & histogram[c0][c1][c2min]; + for (c2 = c2min; c2 <= c2max; c2++) + if (*histp++ != 0) { + boxp->c0min = c0min = c0; + goto have_c0min; + } + } + have_c0min: + if (c0max > c0min) + for (c0 = c0max; c0 >= c0min; c0--) + for (c1 = c1min; c1 <= c1max; c1++) { + histp = & histogram[c0][c1][c2min]; + for (c2 = c2min; c2 <= c2max; c2++) + if (*histp++ != 0) { + boxp->c0max = c0max = c0; + goto have_c0max; + } + } + have_c0max: + if (c1max > c1min) + for (c1 = c1min; c1 <= c1max; c1++) + for (c0 = c0min; c0 <= c0max; c0++) { + histp = & histogram[c0][c1][c2min]; + for (c2 = c2min; c2 <= c2max; c2++) + if (*histp++ != 0) { + boxp->c1min = c1min = c1; + goto have_c1min; + } + } + have_c1min: + if (c1max > c1min) + for (c1 = c1max; c1 >= c1min; c1--) + for (c0 = c0min; c0 <= c0max; c0++) { + histp = & histogram[c0][c1][c2min]; + for (c2 = c2min; c2 <= c2max; c2++) + if (*histp++ != 0) { + boxp->c1max = c1max = c1; + goto have_c1max; + } + } + have_c1max: + if (c2max > c2min) + for (c2 = c2min; c2 <= c2max; c2++) + for (c0 = c0min; c0 <= c0max; c0++) { + histp = & histogram[c0][c1min][c2]; + for (c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS) + if (*histp != 0) { + boxp->c2min = c2min = c2; + goto have_c2min; + } + } + have_c2min: + if (c2max > c2min) + for (c2 = c2max; c2 >= c2min; c2--) + for (c0 = c0min; c0 <= c0max; c0++) { + histp = & histogram[c0][c1min][c2]; + for (c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS) + if (*histp != 0) { + boxp->c2max = c2max = c2; + goto have_c2max; + } + } + have_c2max: + + /* Update box volume. + * We use 2-norm rather than real volume here; this biases the method + * against making long narrow boxes, and it has the side benefit that + * a box is splittable iff norm > 0. + * Since the differences are expressed in histogram-cell units, + * we have to shift back to JSAMPLE units to get consistent distances; + * after which, we scale according to the selected distance scale factors. + */ + dist0 = ((c0max - c0min) << C0_SHIFT) * C0_SCALE; + dist1 = ((c1max - c1min) << C1_SHIFT) * C1_SCALE; + dist2 = ((c2max - c2min) << C2_SHIFT) * C2_SCALE; + boxp->volume = dist0*dist0 + dist1*dist1 + dist2*dist2; + + /* Now scan remaining volume of box and compute population */ + ccount = 0; + for (c0 = c0min; c0 <= c0max; c0++) + for (c1 = c1min; c1 <= c1max; c1++) { + histp = & histogram[c0][c1][c2min]; + for (c2 = c2min; c2 <= c2max; c2++, histp++) + if (*histp != 0) { + ccount++; + } + } + boxp->colorcount = ccount; +} + + +LOCAL(int) +median_cut (j_decompress_ptr cinfo, boxptr boxlist, int numboxes, + int desired_colors) +/* Repeatedly select and split the largest box until we have enough boxes */ +{ + int n,lb; + int c0,c1,c2,cmax; + register boxptr b1,b2; + + while (numboxes < desired_colors) { + /* Select box to split. + * Current algorithm: by population for first half, then by volume. + */ + if (numboxes*2 <= desired_colors) { + b1 = find_biggest_color_pop(boxlist, numboxes); + } else { + b1 = find_biggest_volume(boxlist, numboxes); + } + if (b1 == NULL) /* no splittable boxes left! */ + break; + b2 = &boxlist[numboxes]; /* where new box will go */ + /* Copy the color bounds to the new box. */ + b2->c0max = b1->c0max; b2->c1max = b1->c1max; b2->c2max = b1->c2max; + b2->c0min = b1->c0min; b2->c1min = b1->c1min; b2->c2min = b1->c2min; + /* Choose which axis to split the box on. + * Current algorithm: longest scaled axis. + * See notes in update_box about scaling distances. + */ + c0 = ((b1->c0max - b1->c0min) << C0_SHIFT) * C0_SCALE; + c1 = ((b1->c1max - b1->c1min) << C1_SHIFT) * C1_SCALE; + c2 = ((b1->c2max - b1->c2min) << C2_SHIFT) * C2_SCALE; + /* We want to break any ties in favor of green, then red, blue last. + * This code does the right thing for R,G,B or B,G,R color orders only. + */ +#if RGB_RED == 0 + cmax = c1; n = 1; + if (c0 > cmax) { cmax = c0; n = 0; } + if (c2 > cmax) { n = 2; } +#else + cmax = c1; n = 1; + if (c2 > cmax) { cmax = c2; n = 2; } + if (c0 > cmax) { n = 0; } +#endif + /* Choose split point along selected axis, and update box bounds. + * Current algorithm: split at halfway point. + * (Since the box has been shrunk to minimum volume, + * any split will produce two nonempty subboxes.) + * Note that lb value is max for lower box, so must be < old max. + */ + switch (n) { + case 0: + lb = (b1->c0max + b1->c0min) / 2; + b1->c0max = lb; + b2->c0min = lb+1; + break; + case 1: + lb = (b1->c1max + b1->c1min) / 2; + b1->c1max = lb; + b2->c1min = lb+1; + break; + case 2: + lb = (b1->c2max + b1->c2min) / 2; + b1->c2max = lb; + b2->c2min = lb+1; + break; + } + /* Update stats for boxes */ + update_box(cinfo, b1); + update_box(cinfo, b2); + numboxes++; + } + return numboxes; +} + + +LOCAL(void) +compute_color (j_decompress_ptr cinfo, boxptr boxp, int icolor) +/* Compute representative color for a box, put it in colormap[icolor] */ +{ + /* Current algorithm: mean weighted by pixels (not colors) */ + /* Note it is important to get the rounding correct! */ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + hist3d histogram = cquantize->histogram; + histptr histp; + int c0,c1,c2; + int c0min,c0max,c1min,c1max,c2min,c2max; + long count; + long total = 0; + long c0total = 0; + long c1total = 0; + long c2total = 0; + + c0min = boxp->c0min; c0max = boxp->c0max; + c1min = boxp->c1min; c1max = boxp->c1max; + c2min = boxp->c2min; c2max = boxp->c2max; + + for (c0 = c0min; c0 <= c0max; c0++) + for (c1 = c1min; c1 <= c1max; c1++) { + histp = & histogram[c0][c1][c2min]; + for (c2 = c2min; c2 <= c2max; c2++) { + if ((count = *histp++) != 0) { + total += count; + c0total += ((c0 << C0_SHIFT) + ((1<>1)) * count; + c1total += ((c1 << C1_SHIFT) + ((1<>1)) * count; + c2total += ((c2 << C2_SHIFT) + ((1<>1)) * count; + } + } + } + + cinfo->colormap[0][icolor] = (JSAMPLE) ((c0total + (total>>1)) / total); + cinfo->colormap[1][icolor] = (JSAMPLE) ((c1total + (total>>1)) / total); + cinfo->colormap[2][icolor] = (JSAMPLE) ((c2total + (total>>1)) / total); +} + + +LOCAL(void) +select_colors (j_decompress_ptr cinfo, int desired_colors) +/* Master routine for color selection */ +{ + boxptr boxlist; + int numboxes; + int i; + + /* Allocate workspace for box list */ + boxlist = (boxptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, desired_colors * SIZEOF(box)); + /* Initialize one box containing whole space */ + numboxes = 1; + boxlist[0].c0min = 0; + boxlist[0].c0max = MAXJSAMPLE >> C0_SHIFT; + boxlist[0].c1min = 0; + boxlist[0].c1max = MAXJSAMPLE >> C1_SHIFT; + boxlist[0].c2min = 0; + boxlist[0].c2max = MAXJSAMPLE >> C2_SHIFT; + /* Shrink it to actually-used volume and set its statistics */ + update_box(cinfo, & boxlist[0]); + /* Perform median-cut to produce final box list */ + numboxes = median_cut(cinfo, boxlist, numboxes, desired_colors); + /* Compute the representative color for each box, fill colormap */ + for (i = 0; i < numboxes; i++) + compute_color(cinfo, & boxlist[i], i); + cinfo->actual_number_of_colors = numboxes; + TRACEMS1(cinfo, 1, JTRC_QUANT_SELECTED, numboxes); +} + + +/* + * These routines are concerned with the time-critical task of mapping input + * colors to the nearest color in the selected colormap. + * + * We re-use the histogram space as an "inverse color map", essentially a + * cache for the results of nearest-color searches. All colors within a + * histogram cell will be mapped to the same colormap entry, namely the one + * closest to the cell's center. This may not be quite the closest entry to + * the actual input color, but it's almost as good. A zero in the cache + * indicates we haven't found the nearest color for that cell yet; the array + * is cleared to zeroes before starting the mapping pass. When we find the + * nearest color for a cell, its colormap index plus one is recorded in the + * cache for future use. The pass2 scanning routines call fill_inverse_cmap + * when they need to use an unfilled entry in the cache. + * + * Our method of efficiently finding nearest colors is based on the "locally + * sorted search" idea described by Heckbert and on the incremental distance + * calculation described by Spencer W. Thomas in chapter III.1 of Graphics + * Gems II (James Arvo, ed. Academic Press, 1991). Thomas points out that + * the distances from a given colormap entry to each cell of the histogram can + * be computed quickly using an incremental method: the differences between + * distances to adjacent cells themselves differ by a constant. This allows a + * fairly fast implementation of the "brute force" approach of computing the + * distance from every colormap entry to every histogram cell. Unfortunately, + * it needs a work array to hold the best-distance-so-far for each histogram + * cell (because the inner loop has to be over cells, not colormap entries). + * The work array elements have to be INT32s, so the work array would need + * 256Kb at our recommended precision. This is not feasible in DOS machines. + * + * To get around these problems, we apply Thomas' method to compute the + * nearest colors for only the cells within a small subbox of the histogram. + * The work array need be only as big as the subbox, so the memory usage + * problem is solved. Furthermore, we need not fill subboxes that are never + * referenced in pass2; many images use only part of the color gamut, so a + * fair amount of work is saved. An additional advantage of this + * approach is that we can apply Heckbert's locality criterion to quickly + * eliminate colormap entries that are far away from the subbox; typically + * three-fourths of the colormap entries are rejected by Heckbert's criterion, + * and we need not compute their distances to individual cells in the subbox. + * The speed of this approach is heavily influenced by the subbox size: too + * small means too much overhead, too big loses because Heckbert's criterion + * can't eliminate as many colormap entries. Empirically the best subbox + * size seems to be about 1/512th of the histogram (1/8th in each direction). + * + * Thomas' article also describes a refined method which is asymptotically + * faster than the brute-force method, but it is also far more complex and + * cannot efficiently be applied to small subboxes. It is therefore not + * useful for programs intended to be portable to DOS machines. On machines + * with plenty of memory, filling the whole histogram in one shot with Thomas' + * refined method might be faster than the present code --- but then again, + * it might not be any faster, and it's certainly more complicated. + */ + + +/* log2(histogram cells in update box) for each axis; this can be adjusted */ +#define BOX_C0_LOG (HIST_C0_BITS-3) +#define BOX_C1_LOG (HIST_C1_BITS-3) +#define BOX_C2_LOG (HIST_C2_BITS-3) + +#define BOX_C0_ELEMS (1<actual_number_of_colors; + int maxc0, maxc1, maxc2; + int centerc0, centerc1, centerc2; + int i, x, ncolors; + INT32 minmaxdist, min_dist, max_dist, tdist; + INT32 mindist[MAXNUMCOLORS]; /* min distance to colormap entry i */ + + /* Compute true coordinates of update box's upper corner and center. + * Actually we compute the coordinates of the center of the upper-corner + * histogram cell, which are the upper bounds of the volume we care about. + * Note that since ">>" rounds down, the "center" values may be closer to + * min than to max; hence comparisons to them must be "<=", not "<". + */ + maxc0 = minc0 + ((1 << BOX_C0_SHIFT) - (1 << C0_SHIFT)); + centerc0 = (minc0 + maxc0) >> 1; + maxc1 = minc1 + ((1 << BOX_C1_SHIFT) - (1 << C1_SHIFT)); + centerc1 = (minc1 + maxc1) >> 1; + maxc2 = minc2 + ((1 << BOX_C2_SHIFT) - (1 << C2_SHIFT)); + centerc2 = (minc2 + maxc2) >> 1; + + /* For each color in colormap, find: + * 1. its minimum squared-distance to any point in the update box + * (zero if color is within update box); + * 2. its maximum squared-distance to any point in the update box. + * Both of these can be found by considering only the corners of the box. + * We save the minimum distance for each color in mindist[]; + * only the smallest maximum distance is of interest. + */ + minmaxdist = 0x7FFFFFFFL; + + for (i = 0; i < numcolors; i++) { + /* We compute the squared-c0-distance term, then add in the other two. */ + x = GETJSAMPLE(cinfo->colormap[0][i]); + if (x < minc0) { + tdist = (x - minc0) * C0_SCALE; + min_dist = tdist*tdist; + tdist = (x - maxc0) * C0_SCALE; + max_dist = tdist*tdist; + } else if (x > maxc0) { + tdist = (x - maxc0) * C0_SCALE; + min_dist = tdist*tdist; + tdist = (x - minc0) * C0_SCALE; + max_dist = tdist*tdist; + } else { + /* within cell range so no contribution to min_dist */ + min_dist = 0; + if (x <= centerc0) { + tdist = (x - maxc0) * C0_SCALE; + max_dist = tdist*tdist; + } else { + tdist = (x - minc0) * C0_SCALE; + max_dist = tdist*tdist; + } + } + + x = GETJSAMPLE(cinfo->colormap[1][i]); + if (x < minc1) { + tdist = (x - minc1) * C1_SCALE; + min_dist += tdist*tdist; + tdist = (x - maxc1) * C1_SCALE; + max_dist += tdist*tdist; + } else if (x > maxc1) { + tdist = (x - maxc1) * C1_SCALE; + min_dist += tdist*tdist; + tdist = (x - minc1) * C1_SCALE; + max_dist += tdist*tdist; + } else { + /* within cell range so no contribution to min_dist */ + if (x <= centerc1) { + tdist = (x - maxc1) * C1_SCALE; + max_dist += tdist*tdist; + } else { + tdist = (x - minc1) * C1_SCALE; + max_dist += tdist*tdist; + } + } + + x = GETJSAMPLE(cinfo->colormap[2][i]); + if (x < minc2) { + tdist = (x - minc2) * C2_SCALE; + min_dist += tdist*tdist; + tdist = (x - maxc2) * C2_SCALE; + max_dist += tdist*tdist; + } else if (x > maxc2) { + tdist = (x - maxc2) * C2_SCALE; + min_dist += tdist*tdist; + tdist = (x - minc2) * C2_SCALE; + max_dist += tdist*tdist; + } else { + /* within cell range so no contribution to min_dist */ + if (x <= centerc2) { + tdist = (x - maxc2) * C2_SCALE; + max_dist += tdist*tdist; + } else { + tdist = (x - minc2) * C2_SCALE; + max_dist += tdist*tdist; + } + } + + mindist[i] = min_dist; /* save away the results */ + if (max_dist < minmaxdist) + minmaxdist = max_dist; + } + + /* Now we know that no cell in the update box is more than minmaxdist + * away from some colormap entry. Therefore, only colors that are + * within minmaxdist of some part of the box need be considered. + */ + ncolors = 0; + for (i = 0; i < numcolors; i++) { + if (mindist[i] <= minmaxdist) + colorlist[ncolors++] = (JSAMPLE) i; + } + return ncolors; +} + + +LOCAL(void) +find_best_colors (j_decompress_ptr cinfo, int minc0, int minc1, int minc2, + int numcolors, JSAMPLE colorlist[], JSAMPLE bestcolor[]) +/* Find the closest colormap entry for each cell in the update box, + * given the list of candidate colors prepared by find_nearby_colors. + * Return the indexes of the closest entries in the bestcolor[] array. + * This routine uses Thomas' incremental distance calculation method to + * find the distance from a colormap entry to successive cells in the box. + */ +{ + int ic0, ic1, ic2; + int i, icolor; + register INT32 * bptr; /* pointer into bestdist[] array */ + JSAMPLE * cptr; /* pointer into bestcolor[] array */ + INT32 dist0, dist1; /* initial distance values */ + register INT32 dist2; /* current distance in inner loop */ + INT32 xx0, xx1; /* distance increments */ + register INT32 xx2; + INT32 inc0, inc1, inc2; /* initial values for increments */ + /* This array holds the distance to the nearest-so-far color for each cell */ + INT32 bestdist[BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS]; + + /* Initialize best-distance for each cell of the update box */ + bptr = bestdist; + for (i = BOX_C0_ELEMS*BOX_C1_ELEMS*BOX_C2_ELEMS-1; i >= 0; i--) + *bptr++ = 0x7FFFFFFFL; + + /* For each color selected by find_nearby_colors, + * compute its distance to the center of each cell in the box. + * If that's less than best-so-far, update best distance and color number. + */ + + /* Nominal steps between cell centers ("x" in Thomas article) */ +#define STEP_C0 ((1 << C0_SHIFT) * C0_SCALE) +#define STEP_C1 ((1 << C1_SHIFT) * C1_SCALE) +#define STEP_C2 ((1 << C2_SHIFT) * C2_SCALE) + + for (i = 0; i < numcolors; i++) { + icolor = GETJSAMPLE(colorlist[i]); + /* Compute (square of) distance from minc0/c1/c2 to this color */ + inc0 = (minc0 - GETJSAMPLE(cinfo->colormap[0][icolor])) * C0_SCALE; + dist0 = inc0*inc0; + inc1 = (minc1 - GETJSAMPLE(cinfo->colormap[1][icolor])) * C1_SCALE; + dist0 += inc1*inc1; + inc2 = (minc2 - GETJSAMPLE(cinfo->colormap[2][icolor])) * C2_SCALE; + dist0 += inc2*inc2; + /* Form the initial difference increments */ + inc0 = inc0 * (2 * STEP_C0) + STEP_C0 * STEP_C0; + inc1 = inc1 * (2 * STEP_C1) + STEP_C1 * STEP_C1; + inc2 = inc2 * (2 * STEP_C2) + STEP_C2 * STEP_C2; + /* Now loop over all cells in box, updating distance per Thomas method */ + bptr = bestdist; + cptr = bestcolor; + xx0 = inc0; + for (ic0 = BOX_C0_ELEMS-1; ic0 >= 0; ic0--) { + dist1 = dist0; + xx1 = inc1; + for (ic1 = BOX_C1_ELEMS-1; ic1 >= 0; ic1--) { + dist2 = dist1; + xx2 = inc2; + for (ic2 = BOX_C2_ELEMS-1; ic2 >= 0; ic2--) { + if (dist2 < *bptr) { + *bptr = dist2; + *cptr = (JSAMPLE) icolor; + } + dist2 += xx2; + xx2 += 2 * STEP_C2 * STEP_C2; + bptr++; + cptr++; + } + dist1 += xx1; + xx1 += 2 * STEP_C1 * STEP_C1; + } + dist0 += xx0; + xx0 += 2 * STEP_C0 * STEP_C0; + } + } +} + + +LOCAL(void) +fill_inverse_cmap (j_decompress_ptr cinfo, int c0, int c1, int c2) +/* Fill the inverse-colormap entries in the update box that contains */ +/* histogram cell c0/c1/c2. (Only that one cell MUST be filled, but */ +/* we can fill as many others as we wish.) */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + hist3d histogram = cquantize->histogram; + int minc0, minc1, minc2; /* lower left corner of update box */ + int ic0, ic1, ic2; + register JSAMPLE * cptr; /* pointer into bestcolor[] array */ + register histptr cachep; /* pointer into main cache array */ + /* This array lists the candidate colormap indexes. */ + JSAMPLE colorlist[MAXNUMCOLORS]; + int numcolors; /* number of candidate colors */ + /* This array holds the actually closest colormap index for each cell. */ + JSAMPLE bestcolor[BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS]; + + /* Convert cell coordinates to update box ID */ + c0 >>= BOX_C0_LOG; + c1 >>= BOX_C1_LOG; + c2 >>= BOX_C2_LOG; + + /* Compute true coordinates of update box's origin corner. + * Actually we compute the coordinates of the center of the corner + * histogram cell, which are the lower bounds of the volume we care about. + */ + minc0 = (c0 << BOX_C0_SHIFT) + ((1 << C0_SHIFT) >> 1); + minc1 = (c1 << BOX_C1_SHIFT) + ((1 << C1_SHIFT) >> 1); + minc2 = (c2 << BOX_C2_SHIFT) + ((1 << C2_SHIFT) >> 1); + + /* Determine which colormap entries are close enough to be candidates + * for the nearest entry to some cell in the update box. + */ + numcolors = find_nearby_colors(cinfo, minc0, minc1, minc2, colorlist); + + /* Determine the actually nearest colors. */ + find_best_colors(cinfo, minc0, minc1, minc2, numcolors, colorlist, + bestcolor); + + /* Save the best color numbers (plus 1) in the main cache array */ + c0 <<= BOX_C0_LOG; /* convert ID back to base cell indexes */ + c1 <<= BOX_C1_LOG; + c2 <<= BOX_C2_LOG; + cptr = bestcolor; + for (ic0 = 0; ic0 < BOX_C0_ELEMS; ic0++) { + for (ic1 = 0; ic1 < BOX_C1_ELEMS; ic1++) { + cachep = & histogram[c0+ic0][c1+ic1][c2]; + for (ic2 = 0; ic2 < BOX_C2_ELEMS; ic2++) { + *cachep++ = (histcell) (GETJSAMPLE(*cptr++) + 1); + } + } + } +} + + +/* + * Map some rows of pixels to the output colormapped representation. + */ + +METHODDEF(void) +pass2_no_dither (j_decompress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows) +/* This version performs no dithering */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + hist3d histogram = cquantize->histogram; + register JSAMPROW inptr, outptr; + register histptr cachep; + register int c0, c1, c2; + int row; + JDIMENSION col; + JDIMENSION width = cinfo->output_width; + + for (row = 0; row < num_rows; row++) { + inptr = input_buf[row]; + outptr = output_buf[row]; + for (col = width; col > 0; col--) { + /* get pixel value and index into the cache */ + c0 = GETJSAMPLE(*inptr++) >> C0_SHIFT; + c1 = GETJSAMPLE(*inptr++) >> C1_SHIFT; + c2 = GETJSAMPLE(*inptr++) >> C2_SHIFT; + cachep = & histogram[c0][c1][c2]; + /* If we have not seen this color before, find nearest colormap entry */ + /* and update the cache */ + if (*cachep == 0) + fill_inverse_cmap(cinfo, c0,c1,c2); + /* Now emit the colormap index for this cell */ + *outptr++ = (JSAMPLE) (*cachep - 1); + } + } +} + + +METHODDEF(void) +pass2_fs_dither (j_decompress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows) +/* This version performs Floyd-Steinberg dithering */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + hist3d histogram = cquantize->histogram; + register LOCFSERROR cur0, cur1, cur2; /* current error or pixel value */ + LOCFSERROR belowerr0, belowerr1, belowerr2; /* error for pixel below cur */ + LOCFSERROR bpreverr0, bpreverr1, bpreverr2; /* error for below/prev col */ + register FSERRPTR errorptr; /* => fserrors[] at column before current */ + JSAMPROW inptr; /* => current input pixel */ + JSAMPROW outptr; /* => current output pixel */ + histptr cachep; + int dir; /* +1 or -1 depending on direction */ + int dir3; /* 3*dir, for advancing inptr & errorptr */ + int row; + JDIMENSION col; + JDIMENSION width = cinfo->output_width; + JSAMPLE *range_limit = cinfo->sample_range_limit; + int *error_limit = cquantize->error_limiter; + JSAMPROW colormap0 = cinfo->colormap[0]; + JSAMPROW colormap1 = cinfo->colormap[1]; + JSAMPROW colormap2 = cinfo->colormap[2]; + SHIFT_TEMPS + + for (row = 0; row < num_rows; row++) { + inptr = input_buf[row]; + outptr = output_buf[row]; + if (cquantize->on_odd_row) { + /* work right to left in this row */ + inptr += (width-1) * 3; /* so point to rightmost pixel */ + outptr += width-1; + dir = -1; + dir3 = -3; + errorptr = cquantize->fserrors + (width+1)*3; /* => entry after last column */ + cquantize->on_odd_row = FALSE; /* flip for next time */ + } else { + /* work left to right in this row */ + dir = 1; + dir3 = 3; + errorptr = cquantize->fserrors; /* => entry before first real column */ + cquantize->on_odd_row = TRUE; /* flip for next time */ + } + /* Preset error values: no error propagated to first pixel from left */ + cur0 = cur1 = cur2 = 0; + /* and no error propagated to row below yet */ + belowerr0 = belowerr1 = belowerr2 = 0; + bpreverr0 = bpreverr1 = bpreverr2 = 0; + + for (col = width; col > 0; col--) { + /* curN holds the error propagated from the previous pixel on the + * current line. Add the error propagated from the previous line + * to form the complete error correction term for this pixel, and + * round the error term (which is expressed * 16) to an integer. + * RIGHT_SHIFT rounds towards minus infinity, so adding 8 is correct + * for either sign of the error value. + * Note: errorptr points to *previous* column's array entry. + */ + cur0 = RIGHT_SHIFT(cur0 + errorptr[dir3+0] + 8, 4); + cur1 = RIGHT_SHIFT(cur1 + errorptr[dir3+1] + 8, 4); + cur2 = RIGHT_SHIFT(cur2 + errorptr[dir3+2] + 8, 4); + /* Limit the error using transfer function set by init_error_limit. + * See comments with init_error_limit for rationale. + */ + cur0 = error_limit[cur0]; + cur1 = error_limit[cur1]; + cur2 = error_limit[cur2]; + /* Form pixel value + error, and range-limit to 0..MAXJSAMPLE. + * The maximum error is +- MAXJSAMPLE (or less with error limiting); + * this sets the required size of the range_limit array. + */ + cur0 += GETJSAMPLE(inptr[0]); + cur1 += GETJSAMPLE(inptr[1]); + cur2 += GETJSAMPLE(inptr[2]); + cur0 = GETJSAMPLE(range_limit[cur0]); + cur1 = GETJSAMPLE(range_limit[cur1]); + cur2 = GETJSAMPLE(range_limit[cur2]); + /* Index into the cache with adjusted pixel value */ + cachep = & histogram[cur0>>C0_SHIFT][cur1>>C1_SHIFT][cur2>>C2_SHIFT]; + /* If we have not seen this color before, find nearest colormap */ + /* entry and update the cache */ + if (*cachep == 0) + fill_inverse_cmap(cinfo, cur0>>C0_SHIFT,cur1>>C1_SHIFT,cur2>>C2_SHIFT); + /* Now emit the colormap index for this cell */ + { register int pixcode = *cachep - 1; + *outptr = (JSAMPLE) pixcode; + /* Compute representation error for this pixel */ + cur0 -= GETJSAMPLE(colormap0[pixcode]); + cur1 -= GETJSAMPLE(colormap1[pixcode]); + cur2 -= GETJSAMPLE(colormap2[pixcode]); + } + /* Compute error fractions to be propagated to adjacent pixels. + * Add these into the running sums, and simultaneously shift the + * next-line error sums left by 1 column. + */ + { register LOCFSERROR bnexterr, delta; + + bnexterr = cur0; /* Process component 0 */ + delta = cur0 * 2; + cur0 += delta; /* form error * 3 */ + errorptr[0] = (FSERROR) (bpreverr0 + cur0); + cur0 += delta; /* form error * 5 */ + bpreverr0 = belowerr0 + cur0; + belowerr0 = bnexterr; + cur0 += delta; /* form error * 7 */ + bnexterr = cur1; /* Process component 1 */ + delta = cur1 * 2; + cur1 += delta; /* form error * 3 */ + errorptr[1] = (FSERROR) (bpreverr1 + cur1); + cur1 += delta; /* form error * 5 */ + bpreverr1 = belowerr1 + cur1; + belowerr1 = bnexterr; + cur1 += delta; /* form error * 7 */ + bnexterr = cur2; /* Process component 2 */ + delta = cur2 * 2; + cur2 += delta; /* form error * 3 */ + errorptr[2] = (FSERROR) (bpreverr2 + cur2); + cur2 += delta; /* form error * 5 */ + bpreverr2 = belowerr2 + cur2; + belowerr2 = bnexterr; + cur2 += delta; /* form error * 7 */ + } + /* At this point curN contains the 7/16 error value to be propagated + * to the next pixel on the current line, and all the errors for the + * next line have been shifted over. We are therefore ready to move on. + */ + inptr += dir3; /* Advance pixel pointers to next column */ + outptr += dir; + errorptr += dir3; /* advance errorptr to current column */ + } + /* Post-loop cleanup: we must unload the final error values into the + * final fserrors[] entry. Note we need not unload belowerrN because + * it is for the dummy column before or after the actual array. + */ + errorptr[0] = (FSERROR) bpreverr0; /* unload prev errs into array */ + errorptr[1] = (FSERROR) bpreverr1; + errorptr[2] = (FSERROR) bpreverr2; + } +} + + +/* + * Initialize the error-limiting transfer function (lookup table). + * The raw F-S error computation can potentially compute error values of up to + * +- MAXJSAMPLE. But we want the maximum correction applied to a pixel to be + * much less, otherwise obviously wrong pixels will be created. (Typical + * effects include weird fringes at color-area boundaries, isolated bright + * pixels in a dark area, etc.) The standard advice for avoiding this problem + * is to ensure that the "corners" of the color cube are allocated as output + * colors; then repeated errors in the same direction cannot cause cascading + * error buildup. However, that only prevents the error from getting + * completely out of hand; Aaron Giles reports that error limiting improves + * the results even with corner colors allocated. + * A simple clamping of the error values to about +- MAXJSAMPLE/8 works pretty + * well, but the smoother transfer function used below is even better. Thanks + * to Aaron Giles for this idea. + */ + +LOCAL(void) +init_error_limit (j_decompress_ptr cinfo) +/* Allocate and fill in the error_limiter table */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + int * table; + int in, out; + + table = (int *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE*2+1) * SIZEOF(int)); + table += MAXJSAMPLE; /* so can index -MAXJSAMPLE .. +MAXJSAMPLE */ + cquantize->error_limiter = table; + +#define STEPSIZE ((MAXJSAMPLE+1)/16) + /* Map errors 1:1 up to +- MAXJSAMPLE/16 */ + out = 0; + for (in = 0; in < STEPSIZE; in++, out++) { + table[in] = out; table[-in] = -out; + } + /* Map errors 1:2 up to +- 3*MAXJSAMPLE/16 */ + for (; in < STEPSIZE*3; in++, out += (in&1) ? 0 : 1) { + table[in] = out; table[-in] = -out; + } + /* Clamp the rest to final out value (which is (MAXJSAMPLE+1)/8) */ + for (; in <= MAXJSAMPLE; in++) { + table[in] = out; table[-in] = -out; + } +#undef STEPSIZE +} + + +/* + * Finish up at the end of each pass. + */ + +METHODDEF(void) +finish_pass1 (j_decompress_ptr cinfo) +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + + /* Select the representative colors and fill in cinfo->colormap */ + cinfo->colormap = cquantize->sv_colormap; + select_colors(cinfo, cquantize->desired); + /* Force next pass to zero the color index table */ + cquantize->needs_zeroed = TRUE; +} + + +METHODDEF(void) +finish_pass2 (j_decompress_ptr cinfo) +{ + /* no work */ +} + + +/* + * Initialize for each processing pass. + */ + +METHODDEF(void) +start_pass_2_quant (j_decompress_ptr cinfo, boolean is_pre_scan) +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + hist3d histogram = cquantize->histogram; + int i; + + /* Only F-S dithering or no dithering is supported. */ + /* If user asks for ordered dither, give him F-S. */ + if (cinfo->dither_mode != JDITHER_NONE) + cinfo->dither_mode = JDITHER_FS; + + if (is_pre_scan) { + /* Set up method pointers */ + cquantize->pub.color_quantize = prescan_quantize; + cquantize->pub.finish_pass = finish_pass1; + cquantize->needs_zeroed = TRUE; /* Always zero histogram */ + } else { + /* Set up method pointers */ + if (cinfo->dither_mode == JDITHER_FS) + cquantize->pub.color_quantize = pass2_fs_dither; + else + cquantize->pub.color_quantize = pass2_no_dither; + cquantize->pub.finish_pass = finish_pass2; + + /* Make sure color count is acceptable */ + i = cinfo->actual_number_of_colors; + if (i < 1) + ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, 1); + if (i > MAXNUMCOLORS) + ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS); + + if (cinfo->dither_mode == JDITHER_FS) { + size_t arraysize = (size_t) ((cinfo->output_width + 2) * + (3 * SIZEOF(FSERROR))); + /* Allocate Floyd-Steinberg workspace if we didn't already. */ + if (cquantize->fserrors == NULL) + cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large) + ((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize); + /* Initialize the propagated errors to zero. */ + jzero_far((void FAR *) cquantize->fserrors, arraysize); + /* Make the error-limit table if we didn't already. */ + if (cquantize->error_limiter == NULL) + init_error_limit(cinfo); + cquantize->on_odd_row = FALSE; + } + + } + /* Zero the histogram or inverse color map, if necessary */ + if (cquantize->needs_zeroed) { + for (i = 0; i < HIST_C0_ELEMS; i++) { + jzero_far((void FAR *) histogram[i], + HIST_C1_ELEMS*HIST_C2_ELEMS * SIZEOF(histcell)); + } + cquantize->needs_zeroed = FALSE; + } +} + + +/* + * Switch to a new external colormap between output passes. + */ + +METHODDEF(void) +new_color_map_2_quant (j_decompress_ptr cinfo) +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + + /* Reset the inverse color map */ + cquantize->needs_zeroed = TRUE; +} + + +/* + * Module initialization routine for 2-pass color quantization. + */ + +GLOBAL(void) +jinit_2pass_quantizer (j_decompress_ptr cinfo) +{ + my_cquantize_ptr cquantize; + int i; + + cquantize = (my_cquantize_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_cquantizer)); + cinfo->cquantize = (struct jpeg_color_quantizer *) cquantize; + cquantize->pub.start_pass = start_pass_2_quant; + cquantize->pub.new_color_map = new_color_map_2_quant; + cquantize->fserrors = NULL; /* flag optional arrays not allocated */ + cquantize->error_limiter = NULL; + + /* Make sure jdmaster didn't give me a case I can't handle */ + if (cinfo->out_color_components != 3) + ERREXIT(cinfo, JERR_NOTIMPL); + + /* Allocate the histogram/inverse colormap storage */ + cquantize->histogram = (hist3d) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, HIST_C0_ELEMS * SIZEOF(hist2d)); + for (i = 0; i < HIST_C0_ELEMS; i++) { + cquantize->histogram[i] = (hist2d) (*cinfo->mem->alloc_large) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + HIST_C1_ELEMS*HIST_C2_ELEMS * SIZEOF(histcell)); + } + cquantize->needs_zeroed = TRUE; /* histogram is garbage now */ + + /* Allocate storage for the completed colormap, if required. + * We do this now since it is FAR storage and may affect + * the memory manager's space calculations. + */ + if (cinfo->enable_2pass_quant) { + /* Make sure color count is acceptable */ + int desired = cinfo->desired_number_of_colors; + /* Lower bound on # of colors ... somewhat arbitrary as long as > 0 */ + if (desired < 8) + ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, 8); + /* Make sure colormap indexes can be represented by JSAMPLEs */ + if (desired > MAXNUMCOLORS) + ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS); + cquantize->sv_colormap = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo,JPOOL_IMAGE, (JDIMENSION) desired, (JDIMENSION) 3); + cquantize->desired = desired; + } else + cquantize->sv_colormap = NULL; + + /* Only F-S dithering or no dithering is supported. */ + /* If user asks for ordered dither, give him F-S. */ + if (cinfo->dither_mode != JDITHER_NONE) + cinfo->dither_mode = JDITHER_FS; + + /* Allocate Floyd-Steinberg workspace if necessary. + * This isn't really needed until pass 2, but again it is FAR storage. + * Although we will cope with a later change in dither_mode, + * we do not promise to honor max_memory_to_use if dither_mode changes. + */ + if (cinfo->dither_mode == JDITHER_FS) { + cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (size_t) ((cinfo->output_width + 2) * (3 * SIZEOF(FSERROR)))); + /* Might as well create the error-limiting table too. */ + init_error_limit(cinfo); + } +} + +#endif /* QUANT_2PASS_SUPPORTED */ diff --git a/gs/jpeg/jutils.c b/gs/jpeg/jutils.c new file mode 100644 index 000000000..d18a95556 --- /dev/null +++ b/gs/jpeg/jutils.c @@ -0,0 +1,179 @@ +/* + * jutils.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains tables and miscellaneous utility routines needed + * for both compression and decompression. + * Note we prefix all global names with "j" to minimize conflicts with + * a surrounding application. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* + * jpeg_zigzag_order[i] is the zigzag-order position of the i'th element + * of a DCT block read in natural order (left to right, top to bottom). + */ + +#if 0 /* This table is not actually needed in v6a */ + +const int jpeg_zigzag_order[DCTSIZE2] = { + 0, 1, 5, 6, 14, 15, 27, 28, + 2, 4, 7, 13, 16, 26, 29, 42, + 3, 8, 12, 17, 25, 30, 41, 43, + 9, 11, 18, 24, 31, 40, 44, 53, + 10, 19, 23, 32, 39, 45, 52, 54, + 20, 22, 33, 38, 46, 51, 55, 60, + 21, 34, 37, 47, 50, 56, 59, 61, + 35, 36, 48, 49, 57, 58, 62, 63 +}; + +#endif + +/* + * jpeg_natural_order[i] is the natural-order position of the i'th element + * of zigzag order. + * + * When reading corrupted data, the Huffman decoders could attempt + * to reference an entry beyond the end of this array (if the decoded + * zero run length reaches past the end of the block). To prevent + * wild stores without adding an inner-loop test, we put some extra + * "63"s after the real entries. This will cause the extra coefficient + * to be stored in location 63 of the block, not somewhere random. + * The worst case would be a run-length of 15, which means we need 16 + * fake entries. + */ + +const int jpeg_natural_order[DCTSIZE2+16] = { + 0, 1, 8, 16, 9, 2, 3, 10, + 17, 24, 32, 25, 18, 11, 4, 5, + 12, 19, 26, 33, 40, 48, 41, 34, + 27, 20, 13, 6, 7, 14, 21, 28, + 35, 42, 49, 56, 57, 50, 43, 36, + 29, 22, 15, 23, 30, 37, 44, 51, + 58, 59, 52, 45, 38, 31, 39, 46, + 53, 60, 61, 54, 47, 55, 62, 63, + 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ + 63, 63, 63, 63, 63, 63, 63, 63 +}; + + +/* + * Arithmetic utilities + */ + +GLOBAL(long) +jdiv_round_up (long a, long b) +/* Compute a/b rounded up to next integer, ie, ceil(a/b) */ +/* Assumes a >= 0, b > 0 */ +{ + return (a + b - 1L) / b; +} + + +GLOBAL(long) +jround_up (long a, long b) +/* Compute a rounded up to next multiple of b, ie, ceil(a/b)*b */ +/* Assumes a >= 0, b > 0 */ +{ + a += b - 1L; + return a - (a % b); +} + + +/* On normal machines we can apply MEMCOPY() and MEMZERO() to sample arrays + * and coefficient-block arrays. This won't work on 80x86 because the arrays + * are FAR and we're assuming a small-pointer memory model. However, some + * DOS compilers provide far-pointer versions of memcpy() and memset() even + * in the small-model libraries. These will be used if USE_FMEM is defined. + * Otherwise, the routines below do it the hard way. (The performance cost + * is not all that great, because these routines aren't very heavily used.) + */ + +#ifndef NEED_FAR_POINTERS /* normal case, same as regular macros */ +#define FMEMCOPY(dest,src,size) MEMCOPY(dest,src,size) +#define FMEMZERO(target,size) MEMZERO(target,size) +#else /* 80x86 case, define if we can */ +#ifdef USE_FMEM +#define FMEMCOPY(dest,src,size) _fmemcpy((void FAR *)(dest), (const void FAR *)(src), (size_t)(size)) +#define FMEMZERO(target,size) _fmemset((void FAR *)(target), 0, (size_t)(size)) +#endif +#endif + + +GLOBAL(void) +jcopy_sample_rows (JSAMPARRAY input_array, int source_row, + JSAMPARRAY output_array, int dest_row, + int num_rows, JDIMENSION num_cols) +/* Copy some rows of samples from one place to another. + * num_rows rows are copied from input_array[source_row++] + * to output_array[dest_row++]; these areas may overlap for duplication. + * The source and destination arrays must be at least as wide as num_cols. + */ +{ + register JSAMPROW inptr, outptr; +#ifdef FMEMCOPY + register size_t count = (size_t) (num_cols * SIZEOF(JSAMPLE)); +#else + register JDIMENSION count; +#endif + register int row; + + input_array += source_row; + output_array += dest_row; + + for (row = num_rows; row > 0; row--) { + inptr = *input_array++; + outptr = *output_array++; +#ifdef FMEMCOPY + FMEMCOPY(outptr, inptr, count); +#else + for (count = num_cols; count > 0; count--) + *outptr++ = *inptr++; /* needn't bother with GETJSAMPLE() here */ +#endif + } +} + + +GLOBAL(void) +jcopy_block_row (JBLOCKROW input_row, JBLOCKROW output_row, + JDIMENSION num_blocks) +/* Copy a row of coefficient blocks from one place to another. */ +{ +#ifdef FMEMCOPY + FMEMCOPY(output_row, input_row, num_blocks * (DCTSIZE2 * SIZEOF(JCOEF))); +#else + register JCOEFPTR inptr, outptr; + register long count; + + inptr = (JCOEFPTR) input_row; + outptr = (JCOEFPTR) output_row; + for (count = (long) num_blocks * DCTSIZE2; count > 0; count--) { + *outptr++ = *inptr++; + } +#endif +} + + +GLOBAL(void) +jzero_far (void FAR * target, size_t bytestozero) +/* Zero out a chunk of FAR memory. */ +/* This might be sample-array data, block-array data, or alloc_large data. */ +{ +#ifdef FMEMZERO + FMEMZERO(target, bytestozero); +#else + register char FAR * ptr = (char FAR *) target; + register size_t count; + + for (count = bytestozero; count > 0; count--) { + *ptr++ = 0; + } +#endif +} diff --git a/gs/jpeg/jversion.h b/gs/jpeg/jversion.h new file mode 100644 index 000000000..b903be7d4 --- /dev/null +++ b/gs/jpeg/jversion.h @@ -0,0 +1,14 @@ +/* + * jversion.h + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains software version identification. + */ + + +#define JVERSION "6a 7-Feb-96" + +#define JCOPYRIGHT "Copyright (C) 1996, Thomas G. Lane" diff --git a/gs/jpeg/libjpeg.a b/gs/jpeg/libjpeg.a new file mode 100644 index 000000000..97ba0b1bd Binary files /dev/null and b/gs/jpeg/libjpeg.a differ diff --git a/gs/jpeg/libjpeg.doc b/gs/jpeg/libjpeg.doc new file mode 100644 index 000000000..b3333a8ef --- /dev/null +++ b/gs/jpeg/libjpeg.doc @@ -0,0 +1,2772 @@ +USING THE IJG JPEG LIBRARY + +Copyright (C) 1994-1996, Thomas G. Lane. +This file is part of the Independent JPEG Group's software. +For conditions of distribution and use, see the accompanying README file. + + +This file describes how to use the IJG JPEG library within an application +program. Read it if you want to write a program that uses the library. + +The file example.c provides heavily commented skeleton code for calling the +JPEG library. Also see jpeglib.h (the include file to be used by application +programs) for full details about data structures and function parameter lists. +The library source code, of course, is the ultimate reference. + +Note that there have been *major* changes from the application interface +presented by IJG version 4 and earlier versions. The old design had several +inherent limitations, and it had accumulated a lot of cruft as we added +features while trying to minimize application-interface changes. We have +sacrificed backward compatibility in the version 5 rewrite, but we think the +improvements justify this. + + +TABLE OF CONTENTS +----------------- + +Overview: + Functions provided by the library + Outline of typical usage +Basic library usage: + Data formats + Compression details + Decompression details + Mechanics of usage: include files, linking, etc +Advanced features: + Compression parameter selection + Decompression parameter selection + Special color spaces + Error handling + Compressed data handling (source and destination managers) + I/O suspension + Progressive JPEG support + Buffered-image mode + Abbreviated datastreams and multiple images + Special markers + Raw (downsampled) image data + Really raw data: DCT coefficients + Progress monitoring + Memory management + Library compile-time options + Portability considerations + Notes for MS-DOS implementors + +You should read at least the overview and basic usage sections before trying +to program with the library. The sections on advanced features can be read +if and when you need them. + + +OVERVIEW +======== + +Functions provided by the library +--------------------------------- + +The IJG JPEG library provides C code to read and write JPEG-compressed image +files. The surrounding application program receives or supplies image data a +scanline at a time, using a straightforward uncompressed image format. All +details of color conversion and other preprocessing/postprocessing can be +handled by the library. + +The library includes a substantial amount of code that is not covered by the +JPEG standard but is necessary for typical applications of JPEG. These +functions preprocess the image before JPEG compression or postprocess it after +decompression. They include colorspace conversion, downsampling/upsampling, +and color quantization. The application indirectly selects use of this code +by specifying the format in which it wishes to supply or receive image data. +For example, if colormapped output is requested, then the decompression +library automatically invokes color quantization. + +A wide range of quality vs. speed tradeoffs are possible in JPEG processing, +and even more so in decompression postprocessing. The decompression library +provides multiple implementations that cover most of the useful tradeoffs, +ranging from very-high-quality down to fast-preview operation. On the +compression side we have generally not provided low-quality choices, since +compression is normally less time-critical. It should be understood that the +low-quality modes may not meet the JPEG standard's accuracy requirements; +nonetheless, they are useful for viewers. + +A word about functions *not* provided by the library. We handle a subset of +the ISO JPEG standard; most baseline, extended-sequential, and progressive +JPEG processes are supported. (Our subset includes all features now in common +use.) Unsupported ISO options include: + * Hierarchical storage + * Lossless JPEG + * Arithmetic entropy coding (unsupported for legal reasons) + * DNL marker + * Nonintegral subsampling ratios +We support both 8- and 12-bit data precision, but this is a compile-time +choice rather than a run-time choice; hence it is difficult to use both +precisions in a single application. + +By itself, the library handles only interchange JPEG datastreams --- in +particular the widely used JFIF file format. The library can be used by +surrounding code to process interchange or abbreviated JPEG datastreams that +are embedded in more complex file formats. (For example, this library is +used by the free LIBTIFF library to support JPEG compression in TIFF.) + + +Outline of typical usage +------------------------ + +The rough outline of a JPEG compression operation is: + + Allocate and initialize a JPEG compression object + Specify the destination for the compressed data (eg, a file) + Set parameters for compression, including image size & colorspace + jpeg_start_compress(...); + while (scan lines remain to be written) + jpeg_write_scanlines(...); + jpeg_finish_compress(...); + Release the JPEG compression object + +A JPEG compression object holds parameters and working state for the JPEG +library. We make creation/destruction of the object separate from starting +or finishing compression of an image; the same object can be re-used for a +series of image compression operations. This makes it easy to re-use the +same parameter settings for a sequence of images. Re-use of a JPEG object +also has important implications for processing abbreviated JPEG datastreams, +as discussed later. + +The image data to be compressed is supplied to jpeg_write_scanlines() from +in-memory buffers. If the application is doing file-to-file compression, +reading image data from the source file is the application's responsibility. +The library emits compressed data by calling a "data destination manager", +which typically will write the data into a file; but the application can +provide its own destination manager to do something else. + +Similarly, the rough outline of a JPEG decompression operation is: + + Allocate and initialize a JPEG decompression object + Specify the source of the compressed data (eg, a file) + Call jpeg_read_header() to obtain image info + Set parameters for decompression + jpeg_start_decompress(...); + while (scan lines remain to be read) + jpeg_read_scanlines(...); + jpeg_finish_decompress(...); + Release the JPEG decompression object + +This is comparable to the compression outline except that reading the +datastream header is a separate step. This is helpful because information +about the image's size, colorspace, etc is available when the application +selects decompression parameters. For example, the application can choose an +output scaling ratio that will fit the image into the available screen size. + +The decompression library obtains compressed data by calling a data source +manager, which typically will read the data from a file; but other behaviors +can be obtained with a custom source manager. Decompressed data is delivered +into in-memory buffers passed to jpeg_read_scanlines(). + +It is possible to abort an incomplete compression or decompression operation +by calling jpeg_abort(); or, if you do not need to retain the JPEG object, +simply release it by calling jpeg_destroy(). + +JPEG compression and decompression objects are two separate struct types. +However, they share some common fields, and certain routines such as +jpeg_destroy() can work on either type of object. + +The JPEG library has no static variables: all state is in the compression +or decompression object. Therefore it is possible to process multiple +compression and decompression operations concurrently, using multiple JPEG +objects. + +Both compression and decompression can be done in an incremental memory-to- +memory fashion, if suitable source/destination managers are used. See the +section on "I/O suspension" for more details. + + +BASIC LIBRARY USAGE +=================== + +Data formats +------------ + +Before diving into procedural details, it is helpful to understand the +image data format that the JPEG library expects or returns. + +The standard input image format is a rectangular array of pixels, with each +pixel having the same number of "component" or "sample" values (color +channels). You must specify how many components there are and the colorspace +interpretation of the components. Most applications will use RGB data +(three components per pixel) or grayscale data (one component per pixel). +PLEASE NOTE THAT RGB DATA IS THREE SAMPLES PER PIXEL, GRAYSCALE ONLY ONE. +A remarkable number of people manage to miss this, only to find that their +programs don't work with grayscale JPEG files. + +There is no provision for colormapped input. JPEG files are always full-color +or full grayscale (or sometimes another colorspace such as CMYK). You can +feed in a colormapped image by expanding it to full-color format. However +JPEG often doesn't work very well with source data that has been colormapped, +because of dithering noise. This is discussed in more detail in the JPEG FAQ +and the other references mentioned in the README file. + +Pixels are stored by scanlines, with each scanline running from left to +right. The component values for each pixel are adjacent in the row; for +example, R,G,B,R,G,B,R,G,B,... for 24-bit RGB color. Each scanline is an +array of data type JSAMPLE --- which is typically "unsigned char", unless +you've changed jmorecfg.h. (You can also change the RGB pixel layout, say +to B,G,R order, by modifying jmorecfg.h. But see the restrictions listed in +that file before doing so.) + +A 2-D array of pixels is formed by making a list of pointers to the starts of +scanlines; so the scanlines need not be physically adjacent in memory. Even +if you process just one scanline at a time, you must make a one-element +pointer array to conform to this structure. Pointers to JSAMPLE rows are of +type JSAMPROW, and the pointer to the pointer array is of type JSAMPARRAY. + +The library accepts or supplies one or more complete scanlines per call. +It is not possible to process part of a row at a time. Scanlines are always +processed top-to-bottom. You can process an entire image in one call if you +have it all in memory, but usually it's simplest to process one scanline at +a time. + +For best results, source data values should have the precision specified by +BITS_IN_JSAMPLE (normally 8 bits). For instance, if you choose to compress +data that's only 6 bits/channel, you should left-justify each value in a +byte before passing it to the compressor. If you need to compress data +that has more than 8 bits/channel, compile with BITS_IN_JSAMPLE = 12. +(See "Library compile-time options", later.) + + +The data format returned by the decompressor is the same in all details, +except that colormapped output is supported. (Again, a JPEG file is never +colormapped. But you can ask the decompressor to perform on-the-fly color +quantization to deliver colormapped output.) If you request colormapped +output then the returned data array contains a single JSAMPLE per pixel; +its value is an index into a color map. The color map is represented as +a 2-D JSAMPARRAY in which each row holds the values of one color component, +that is, colormap[i][j] is the value of the i'th color component for pixel +value (map index) j. Note that since the colormap indexes are stored in +JSAMPLEs, the maximum number of colors is limited by the size of JSAMPLE +(ie, at most 256 colors for an 8-bit JPEG library). + + +Compression details +------------------- + +Here we revisit the JPEG compression outline given in the overview. + +1. Allocate and initialize a JPEG compression object. + +A JPEG compression object is a "struct jpeg_compress_struct". (It also has +a bunch of subsidiary structures which are allocated via malloc(), but the +application doesn't control those directly.) This struct can be just a local +variable in the calling routine, if a single routine is going to execute the +whole JPEG compression sequence. Otherwise it can be static or allocated +from malloc(). + +You will also need a structure representing a JPEG error handler. The part +of this that the library cares about is a "struct jpeg_error_mgr". If you +are providing your own error handler, you'll typically want to embed the +jpeg_error_mgr struct in a larger structure; this is discussed later under +"Error handling". For now we'll assume you are just using the default error +handler. The default error handler will print JPEG error/warning messages +on stderr, and it will call exit() if a fatal error occurs. + +You must initialize the error handler structure, store a pointer to it into +the JPEG object's "err" field, and then call jpeg_create_compress() to +initialize the rest of the JPEG object. + +Typical code for this step, if you are using the default error handler, is + + struct jpeg_compress_struct cinfo; + struct jpeg_error_mgr jerr; + ... + cinfo.err = jpeg_std_error(&jerr); + jpeg_create_compress(&cinfo); + +jpeg_create_compress allocates a small amount of memory, so it could fail +if you are out of memory. In that case it will exit via the error handler; +that's why the error handler must be initialized first. + + +2. Specify the destination for the compressed data (eg, a file). + +As previously mentioned, the JPEG library delivers compressed data to a +"data destination" module. The library includes one data destination +module which knows how to write to a stdio stream. You can use your own +destination module if you want to do something else, as discussed later. + +If you use the standard destination module, you must open the target stdio +stream beforehand. Typical code for this step looks like: + + FILE * outfile; + ... + if ((outfile = fopen(filename, "wb")) == NULL) { + fprintf(stderr, "can't open %s\n", filename); + exit(1); + } + jpeg_stdio_dest(&cinfo, outfile); + +where the last line invokes the standard destination module. + +WARNING: it is critical that the binary compressed data be delivered to the +output file unchanged. On non-Unix systems the stdio library may perform +newline translation or otherwise corrupt binary data. To suppress this +behavior, you may need to use a "b" option to fopen (as shown above), or use +setmode() or another routine to put the stdio stream in binary mode. See +cjpeg.c and djpeg.c for code that has been found to work on many systems. + +You can select the data destination after setting other parameters (step 3), +if that's more convenient. You may not change the destination between +calling jpeg_start_compress() and jpeg_finish_compress(). + + +3. Set parameters for compression, including image size & colorspace. + +You must supply information about the source image by setting the following +fields in the JPEG object (cinfo structure): + + image_width Width of image, in pixels + image_height Height of image, in pixels + input_components Number of color channels (samples per pixel) + in_color_space Color space of source image + +The image dimensions are, hopefully, obvious. JPEG supports image dimensions +of 1 to 64K pixels in either direction. The input color space is typically +RGB or grayscale, and input_components is 3 or 1 accordingly. (See "Special +color spaces", later, for more info.) The in_color_space field must be +assigned one of the J_COLOR_SPACE enum constants, typically JCS_RGB or +JCS_GRAYSCALE. + +JPEG has a large number of compression parameters that determine how the +image is encoded. Most applications don't need or want to know about all +these parameters. You can set all the parameters to reasonable defaults by +calling jpeg_set_defaults(); then, if there are particular values you want +to change, you can do so after that. The "Compression parameter selection" +section tells about all the parameters. + +You must set in_color_space correctly before calling jpeg_set_defaults(), +because the defaults depend on the source image colorspace. However the +other three source image parameters need not be valid until you call +jpeg_start_compress(). There's no harm in calling jpeg_set_defaults() more +than once, if that happens to be convenient. + +Typical code for a 24-bit RGB source image is + + cinfo.image_width = Width; /* image width and height, in pixels */ + cinfo.image_height = Height; + cinfo.input_components = 3; /* # of color components per pixel */ + cinfo.in_color_space = JCS_RGB; /* colorspace of input image */ + + jpeg_set_defaults(&cinfo); + /* Make optional parameter settings here */ + + +4. jpeg_start_compress(...); + +After you have established the data destination and set all the necessary +source image info and other parameters, call jpeg_start_compress() to begin +a compression cycle. This will initialize internal state, allocate working +storage, and emit the first few bytes of the JPEG datastream header. + +Typical code: + + jpeg_start_compress(&cinfo, TRUE); + +The "TRUE" parameter ensures that a complete JPEG interchange datastream +will be written. This is appropriate in most cases. If you think you might +want to use an abbreviated datastream, read the section on abbreviated +datastreams, below. + +Once you have called jpeg_start_compress(), you may not alter any JPEG +parameters or other fields of the JPEG object until you have completed +the compression cycle. + + +5. while (scan lines remain to be written) + jpeg_write_scanlines(...); + +Now write all the required image data by calling jpeg_write_scanlines() +one or more times. You can pass one or more scanlines in each call, up +to the total image height. In most applications it is convenient to pass +just one or a few scanlines at a time. The expected format for the passed +data is discussed under "Data formats", above. + +Image data should be written in top-to-bottom scanline order. The JPEG spec +contains some weasel wording about how top and bottom are application-defined +terms (a curious interpretation of the English language...) but if you want +your files to be compatible with everyone else's, you WILL use top-to-bottom +order. If the source data must be read in bottom-to-top order, you can use +the JPEG library's virtual array mechanism to invert the data efficiently. +Examples of this can be found in the sample application cjpeg. + +The library maintains a count of the number of scanlines written so far +in the next_scanline field of the JPEG object. Usually you can just use +this variable as the loop counter, so that the loop test looks like +"while (cinfo.next_scanline < cinfo.image_height)". + +Code for this step depends heavily on the way that you store the source data. +example.c shows the following code for the case of a full-size 2-D source +array containing 3-byte RGB pixels: + + JSAMPROW row_pointer[1]; /* pointer to a single row */ + int row_stride; /* physical row width in buffer */ + + row_stride = image_width * 3; /* JSAMPLEs per row in image_buffer */ + + while (cinfo.next_scanline < cinfo.image_height) { + row_pointer[0] = & image_buffer[cinfo.next_scanline * row_stride]; + jpeg_write_scanlines(&cinfo, row_pointer, 1); + } + +jpeg_write_scanlines() returns the number of scanlines actually written. +This will normally be equal to the number passed in, so you can usually +ignore the return value. It is different in just two cases: + * If you try to write more scanlines than the declared image height, + the additional scanlines are ignored. + * If you use a suspending data destination manager, output buffer overrun + will cause the compressor to return before accepting all the passed lines. + This feature is discussed under "I/O suspension", below. The normal + stdio destination manager will NOT cause this to happen. +In any case, the return value is the same as the change in the value of +next_scanline. + + +6. jpeg_finish_compress(...); + +After all the image data has been written, call jpeg_finish_compress() to +complete the compression cycle. This step is ESSENTIAL to ensure that the +last bufferload of data is written to the data destination. +jpeg_finish_compress() also releases working memory associated with the JPEG +object. + +Typical code: + + jpeg_finish_compress(&cinfo); + +If using the stdio destination manager, don't forget to close the output +stdio stream if necessary. + +If you have requested a multi-pass operating mode, such as Huffman code +optimization, jpeg_finish_compress() will perform the additional passes using +data buffered by the first pass. In this case jpeg_finish_compress() may take +quite a while to complete. With the default compression parameters, this will +not happen. + +It is an error to call jpeg_finish_compress() before writing the necessary +total number of scanlines. If you wish to abort compression, call +jpeg_abort() as discussed below. + +After completing a compression cycle, you may dispose of the JPEG object +as discussed next, or you may use it to compress another image. In that case +return to step 2, 3, or 4 as appropriate. If you do not change the +destination manager, the new datastream will be written to the same target. +If you do not change any JPEG parameters, the new datastream will be written +with the same parameters as before. Note that you can change the input image +dimensions freely between cycles, but if you change the input colorspace, you +should call jpeg_set_defaults() to adjust for the new colorspace; and then +you'll need to repeat all of step 3. + + +7. Release the JPEG compression object. + +When you are done with a JPEG compression object, destroy it by calling +jpeg_destroy_compress(). This will free all subsidiary memory. Or you can +call jpeg_destroy() which works for either compression or decompression +objects --- this may be more convenient if you are sharing code between +compression and decompression cases. (Actually, these routines are equivalent +except for the declared type of the passed pointer. To avoid gripes from +ANSI C compilers, jpeg_destroy() should be passed a j_common_ptr.) + +If you allocated the jpeg_compress_struct structure from malloc(), freeing +it is your responsibility --- jpeg_destroy() won't. Ditto for the error +handler structure. + +Typical code: + + jpeg_destroy_compress(&cinfo); + + +8. Aborting. + +If you decide to abort a compression cycle before finishing, you can clean up +in either of two ways: + +* If you don't need the JPEG object any more, just call + jpeg_destroy_compress() or jpeg_destroy() to release memory. This is + legitimate at any point after calling jpeg_create_compress() --- in fact, + it's safe even if jpeg_create_compress() fails. + +* If you want to re-use the JPEG object, call jpeg_abort_compress(), or + jpeg_abort() which works on both compression and decompression objects. + This will return the object to an idle state, releasing any working memory. + jpeg_abort() is allowed at any time after successful object creation. + +Note that cleaning up the data destination, if required, is your +responsibility. + + +Decompression details +--------------------- + +Here we revisit the JPEG decompression outline given in the overview. + +1. Allocate and initialize a JPEG decompression object. + +This is just like initialization for compression, as discussed above, +except that the object is a "struct jpeg_decompress_struct" and you +call jpeg_create_decompress(). Error handling is exactly the same. + +Typical code: + + struct jpeg_decompress_struct cinfo; + struct jpeg_error_mgr jerr; + ... + cinfo.err = jpeg_std_error(&jerr); + jpeg_create_decompress(&cinfo); + +(Both here and in the IJG code, we usually use variable name "cinfo" for +both compression and decompression objects.) + + +2. Specify the source of the compressed data (eg, a file). + +As previously mentioned, the JPEG library reads compressed data from a "data +source" module. The library includes one data source module which knows how +to read from a stdio stream. You can use your own source module if you want +to do something else, as discussed later. + +If you use the standard source module, you must open the source stdio stream +beforehand. Typical code for this step looks like: + + FILE * infile; + ... + if ((infile = fopen(filename, "rb")) == NULL) { + fprintf(stderr, "can't open %s\n", filename); + exit(1); + } + jpeg_stdio_src(&cinfo, infile); + +where the last line invokes the standard source module. + +WARNING: it is critical that the binary compressed data be read unchanged. +On non-Unix systems the stdio library may perform newline translation or +otherwise corrupt binary data. To suppress this behavior, you may need to use +a "b" option to fopen (as shown above), or use setmode() or another routine to +put the stdio stream in binary mode. See cjpeg.c and djpeg.c for code that +has been found to work on many systems. + +You may not change the data source between calling jpeg_read_header() and +jpeg_finish_decompress(). If you wish to read a series of JPEG images from +a single source file, you should repeat the jpeg_read_header() to +jpeg_finish_decompress() sequence without reinitializing either the JPEG +object or the data source module; this prevents buffered input data from +being discarded. + + +3. Call jpeg_read_header() to obtain image info. + +Typical code for this step is just + + jpeg_read_header(&cinfo, TRUE); + +This will read the source datastream header markers, up to the beginning +of the compressed data proper. On return, the image dimensions and other +info have been stored in the JPEG object. The application may wish to +consult this information before selecting decompression parameters. + +More complex code is necessary if + * A suspending data source is used --- in that case jpeg_read_header() + may return before it has read all the header data. See "I/O suspension", + below. The normal stdio source manager will NOT cause this to happen. + * Abbreviated JPEG files are to be processed --- see the section on + abbreviated datastreams. Standard applications that deal only in + interchange JPEG files need not be concerned with this case either. + +It is permissible to stop at this point if you just wanted to find out the +image dimensions and other header info for a JPEG file. In that case, +call jpeg_destroy() when you are done with the JPEG object, or call +jpeg_abort() to return it to an idle state before selecting a new data +source and reading another header. + + +4. Set parameters for decompression. + +jpeg_read_header() sets appropriate default decompression parameters based on +the properties of the image (in particular, its colorspace). However, you +may well want to alter these defaults before beginning the decompression. +For example, the default is to produce full color output from a color file. +If you want colormapped output you must ask for it. Other options allow the +returned image to be scaled and allow various speed/quality tradeoffs to be +selected. "Decompression parameter selection", below, gives details. + +If the defaults are appropriate, nothing need be done at this step. + +Note that all default values are set by each call to jpeg_read_header(). +If you reuse a decompression object, you cannot expect your parameter +settings to be preserved across cycles, as you can for compression. +You must set desired parameter values each time. + + +5. jpeg_start_decompress(...); + +Once the parameter values are satisfactory, call jpeg_start_decompress() to +begin decompression. This will initialize internal state, allocate working +memory, and prepare for returning data. + +Typical code is just + + jpeg_start_decompress(&cinfo); + +If you have requested a multi-pass operating mode, such as 2-pass color +quantization, jpeg_start_decompress() will do everything needed before data +output can begin. In this case jpeg_start_decompress() may take quite a while +to complete. With a single-scan (non progressive) JPEG file and default +decompression parameters, this will not happen; jpeg_start_decompress() will +return quickly. + +After this call, the final output image dimensions, including any requested +scaling, are available in the JPEG object; so is the selected colormap, if +colormapped output has been requested. Useful fields include + + output_width image width and height, as scaled + output_height + out_color_components # of color components in out_color_space + output_components # of color components returned per pixel + colormap the selected colormap, if any + actual_number_of_colors number of entries in colormap + +output_components is 1 (a colormap index) when quantizing colors; otherwise it +equals out_color_components. It is the number of JSAMPLE values that will be +emitted per pixel in the output arrays. + +Typically you will need to allocate data buffers to hold the incoming image. +You will need output_width * output_components JSAMPLEs per scanline in your +output buffer, and a total of output_height scanlines will be returned. + +Note: if you are using the JPEG library's internal memory manager to allocate +data buffers (as djpeg does), then the manager's protocol requires that you +request large buffers *before* calling jpeg_start_decompress(). This is a +little tricky since the output_XXX fields are not normally valid then. You +can make them valid by calling jpeg_calc_output_dimensions() after setting the +relevant parameters (scaling, output color space, and quantization flag). + + +6. while (scan lines remain to be read) + jpeg_read_scanlines(...); + +Now you can read the decompressed image data by calling jpeg_read_scanlines() +one or more times. At each call, you pass in the maximum number of scanlines +to be read (ie, the height of your working buffer); jpeg_read_scanlines() +will return up to that many lines. The return value is the number of lines +actually read. The format of the returned data is discussed under "Data +formats", above. Don't forget that grayscale and color JPEGs will return +different data formats! + +Image data is returned in top-to-bottom scanline order. If you must write +out the image in bottom-to-top order, you can use the JPEG library's virtual +array mechanism to invert the data efficiently. Examples of this can be +found in the sample application djpeg. + +The library maintains a count of the number of scanlines returned so far +in the output_scanline field of the JPEG object. Usually you can just use +this variable as the loop counter, so that the loop test looks like +"while (cinfo.output_scanline < cinfo.output_height)". (Note that the test +should NOT be against image_height, unless you never use scaling. The +image_height field is the height of the original unscaled image.) +The return value always equals the change in the value of output_scanline. + +If you don't use a suspending data source, it is safe to assume that +jpeg_read_scanlines() reads at least one scanline per call, until the +bottom of the image has been reached. + +If you use a buffer larger than one scanline, it is NOT safe to assume that +jpeg_read_scanlines() fills it. (The current implementation won't return +more than cinfo.rec_outbuf_height scanlines per call, no matter how large +a buffer you pass.) So you must always provide a loop that calls +jpeg_read_scanlines() repeatedly until the whole image has been read. + + +7. jpeg_finish_decompress(...); + +After all the image data has been read, call jpeg_finish_decompress() to +complete the decompression cycle. This causes working memory associated +with the JPEG object to be released. + +Typical code: + + jpeg_finish_decompress(&cinfo); + +If using the stdio source manager, don't forget to close the source stdio +stream if necessary. + +It is an error to call jpeg_finish_decompress() before reading the correct +total number of scanlines. If you wish to abort compression, call +jpeg_abort() as discussed below. + +After completing a decompression cycle, you may dispose of the JPEG object as +discussed next, or you may use it to decompress another image. In that case +return to step 2 or 3 as appropriate. If you do not change the source +manager, the next image will be read from the same source. + + +8. Release the JPEG decompression object. + +When you are done with a JPEG decompression object, destroy it by calling +jpeg_destroy_decompress() or jpeg_destroy(). The previous discussion of +destroying compression objects applies here too. + +Typical code: + + jpeg_destroy_decompress(&cinfo); + + +9. Aborting. + +You can abort a decompression cycle by calling jpeg_destroy_decompress() or +jpeg_destroy() if you don't need the JPEG object any more, or +jpeg_abort_decompress() or jpeg_abort() if you want to reuse the object. +The previous discussion of aborting compression cycles applies here too. + + +Mechanics of usage: include files, linking, etc +----------------------------------------------- + +Applications using the JPEG library should include the header file jpeglib.h +to obtain declarations of data types and routines. Before including +jpeglib.h, include system headers that define at least the typedefs FILE and +size_t. On ANSI-conforming systems, including is sufficient; on +older Unix systems, you may need to define size_t. + +If the application needs to refer to individual JPEG library error codes, also +include jerror.h to define those symbols. + +jpeglib.h indirectly includes the files jconfig.h and jmorecfg.h. If you are +installing the JPEG header files in a system directory, you will want to +install all four files: jpeglib.h, jerror.h, jconfig.h, jmorecfg.h. + +The most convenient way to include the JPEG code into your executable program +is to prepare a library file ("libjpeg.a", or a corresponding name on non-Unix +machines) and reference it at your link step. If you use only half of the +library (only compression or only decompression), only that much code will be +included from the library, unless your linker is hopelessly brain-damaged. +The supplied makefiles build libjpeg.a automatically (see install.doc). + +On some systems your application may need to set up a signal handler to ensure +that temporary files are deleted if the program is interrupted. This is most +critical if you are on MS-DOS and use the jmemdos.c memory manager back end; +it will try to grab extended memory for temp files, and that space will NOT be +freed automatically. See cjpeg.c or djpeg.c for an example signal handler. + +It may be worth pointing out that the core JPEG library does not actually +require the stdio library: only the default source/destination managers and +error handler need it. You can use the library in a stdio-less environment +if you replace those modules and use jmemnobs.c (or another memory manager of +your own devising). More info about the minimum system library requirements +may be found in jinclude.h. + + +ADVANCED FEATURES +================= + +Compression parameter selection +------------------------------- + +This section describes all the optional parameters you can set for JPEG +compression, as well as the "helper" routines provided to assist in this +task. Proper setting of some parameters requires detailed understanding +of the JPEG standard; if you don't know what a parameter is for, it's best +not to mess with it! See REFERENCES in the README file for pointers to +more info about JPEG. + +It's a good idea to call jpeg_set_defaults() first, even if you plan to set +all the parameters; that way your code is more likely to work with future JPEG +libraries that have additional parameters. For the same reason, we recommend +you use a helper routine where one is provided, in preference to twiddling +cinfo fields directly. + +The helper routines are: + +jpeg_set_defaults (j_compress_ptr cinfo) + This routine sets all JPEG parameters to reasonable defaults, using + only the input image's color space (field in_color_space, which must + already be set in cinfo). Many applications will only need to use + this routine and perhaps jpeg_set_quality(). + +jpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace) + Sets the JPEG file's colorspace (field jpeg_color_space) as specified, + and sets other color-space-dependent parameters appropriately. See + "Special color spaces", below, before using this. A large number of + parameters, including all per-component parameters, are set by this + routine; if you want to twiddle individual parameters you should call + jpeg_set_colorspace() before rather than after. + +jpeg_default_colorspace (j_compress_ptr cinfo) + Selects an appropriate JPEG colorspace based on cinfo->in_color_space, + and calls jpeg_set_colorspace(). This is actually a subroutine of + jpeg_set_defaults(). It's broken out in case you want to change + just the colorspace-dependent JPEG parameters. + +jpeg_set_quality (j_compress_ptr cinfo, int quality, boolean force_baseline) + Constructs JPEG quantization tables appropriate for the indicated + quality setting. The quality value is expressed on the 0..100 scale + recommended by IJG (cjpeg's "-quality" switch uses this routine). + Note that the exact mapping from quality values to tables may change + in future IJG releases as more is learned about DCT quantization. + If the force_baseline parameter is TRUE, then the quantization table + entries are constrained to the range 1..255 for full JPEG baseline + compatibility. In the current implementation, this only makes a + difference for quality settings below 25, and it effectively prevents + very small/low quality files from being generated. The IJG decoder + is capable of reading the non-baseline files generated at low quality + settings when force_baseline is FALSE, but other decoders may not be. + +jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor, + boolean force_baseline) + Same as jpeg_set_quality() except that the generated tables are the + sample tables given in the JPEC spec section K.1, multiplied by the + specified scale factor (which is expressed as a percentage; thus + scale_factor = 100 reproduces the spec's tables). Note that larger + scale factors give lower quality. This entry point is useful for + conforming to the Adobe PostScript DCT conventions, but we do not + recommend linear scaling as a user-visible quality scale otherwise. + force_baseline again constrains the computed table entries to 1..255. + +int jpeg_quality_scaling (int quality) + Converts a value on the IJG-recommended quality scale to a linear + scaling percentage. Note that this routine may change or go away + in future releases --- IJG may choose to adopt a scaling method that + can't be expressed as a simple scalar multiplier, in which case the + premise of this routine collapses. Caveat user. + +jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl, + const unsigned int *basic_table, + int scale_factor, boolean force_baseline) + Allows an arbitrary quantization table to be created. which_tbl + indicates which table slot to fill. basic_table points to an array + of 64 unsigned ints given in normal array order. These values are + multiplied by scale_factor/100 and then clamped to the range 1..65535 + (or to 1..255 if force_baseline is TRUE). + CAUTION: prior to library version 6a, jpeg_add_quant_table expected + the basic table to be given in JPEG zigzag order. If you need to + write code that works with either older or newer versions of this + routine, you must check the library version number. Something like + "#if JPEG_LIB_VERSION >= 61" is the right test. + +jpeg_simple_progression (j_compress_ptr cinfo) + Generates a default scan script for writing a progressive-JPEG file. + This is the recommended method of creating a progressive file, + unless you want to make a custom scan sequence. You must ensure that + the JPEG color space is set correctly before calling this routine. + + +Compression parameters (cinfo fields) include: + +J_DCT_METHOD dct_method + Selects the algorithm used for the DCT step. Choices are: + JDCT_ISLOW: slow but accurate integer algorithm + JDCT_IFAST: faster, less accurate integer method + JDCT_FLOAT: floating-point method + JDCT_DEFAULT: default method (normally JDCT_ISLOW) + JDCT_FASTEST: fastest method (normally JDCT_IFAST) + The FLOAT method is very slightly more accurate than the ISLOW method, + but may give different results on different machines due to varying + roundoff behavior. The integer methods should give the same results + on all machines. On machines with sufficiently fast FP hardware, the + floating-point method may also be the fastest. The IFAST method is + considerably less accurate than the other two; its use is not + recommended if high quality is a concern. JDCT_DEFAULT and + JDCT_FASTEST are macros configurable by each installation. + +J_COLOR_SPACE jpeg_color_space +int num_components + The JPEG color space and corresponding number of components; see + "Special color spaces", below, for more info. We recommend using + jpeg_set_color_space() if you want to change these. + +boolean optimize_coding + TRUE causes the compressor to compute optimal Huffman coding tables + for the image. This requires an extra pass over the data and + therefore costs a good deal of space and time. The default is + FALSE, which tells the compressor to use the supplied or default + Huffman tables. In most cases optimal tables save only a few percent + of file size compared to the default tables. Note that when this is + TRUE, you need not supply Huffman tables at all, and any you do + supply will be overwritten. + +unsigned int restart_interval +int restart_in_rows + To emit restart markers in the JPEG file, set one of these nonzero. + Set restart_interval to specify the exact interval in MCU blocks. + Set restart_in_rows to specify the interval in MCU rows. (If + restart_in_rows is not 0, then restart_interval is set after the + image width in MCUs is computed.) Defaults are zero (no restarts). + +const jpeg_scan_info * scan_info +int num_scans + By default, scan_info is NULL; this causes the compressor to write a + single-scan sequential JPEG file. If not NULL, scan_info points to + an array of scan definition records of length num_scans. The + compressor will then write a JPEG file having one scan for each scan + definition record. This is used to generate noninterleaved or + progressive JPEG files. The library checks that the scan array + defines a valid JPEG scan sequence. (jpeg_simple_progression creates + a suitable scan definition array for progressive JPEG.) This is + discussed further under "Progressive JPEG support". + +int smoothing_factor + If non-zero, the input image is smoothed; the value should be 1 for + minimal smoothing to 100 for maximum smoothing. Consult jcsample.c + for details of the smoothing algorithm. The default is zero. + +boolean write_JFIF_header + If TRUE, a JFIF APP0 marker is emitted. jpeg_set_defaults() and + jpeg_set_colorspace() set this TRUE if a JFIF-legal JPEG color space + (ie, YCbCr or grayscale) is selected, otherwise FALSE. + +UINT8 density_unit +UINT16 X_density +UINT16 Y_density + The resolution information to be written into the JFIF marker; + not used otherwise. density_unit may be 0 for unknown, + 1 for dots/inch, or 2 for dots/cm. The default values are 0,1,1 + indicating square pixels of unknown size. + +boolean write_Adobe_marker + If TRUE, an Adobe APP14 marker is emitted. jpeg_set_defaults() and + jpeg_set_colorspace() set this TRUE if JPEG color space RGB, CMYK, + or YCCK is selected, otherwise FALSE. It is generally a bad idea + to set both write_JFIF_header and write_Adobe_marker. In fact, + you probably shouldn't change the default settings at all --- the + default behavior ensures that the JPEG file's color space can be + recognized by the decoder. + +JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS] + Pointers to coefficient quantization tables, one per table slot, + or NULL if no table is defined for a slot. Usually these should + be set via one of the above helper routines; jpeg_add_quant_table() + is general enough to define any quantization table. The other + routines will set up table slot 0 for luminance quality and table + slot 1 for chrominance. + +JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS] +JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS] + Pointers to Huffman coding tables, one per table slot, or NULL if + no table is defined for a slot. Slots 0 and 1 are filled with the + JPEG sample tables by jpeg_set_defaults(). If you need to allocate + more table structures, jpeg_alloc_huff_table() may be used. + Note that optimal Huffman tables can be computed for an image + by setting optimize_coding, as discussed above; there's seldom + any need to mess with providing your own Huffman tables. + +There are some additional cinfo fields which are not documented here +because you currently can't change them; for example, you can't set +arith_code TRUE because arithmetic coding is unsupported. + + +Per-component parameters are stored in the struct cinfo.comp_info[i] for +component number i. Note that components here refer to components of the +JPEG color space, *not* the source image color space. A suitably large +comp_info[] array is allocated by jpeg_set_defaults(); if you choose not +to use that routine, it's up to you to allocate the array. + +int component_id + The one-byte identifier code to be recorded in the JPEG file for + this component. For the standard color spaces, we recommend you + leave the default values alone. + +int h_samp_factor +int v_samp_factor + Horizontal and vertical sampling factors for the component; must + be 1..4 according to the JPEG standard. Note that larger sampling + factors indicate a higher-resolution component; many people find + this behavior quite unintuitive. The default values are 2,2 for + luminance components and 1,1 for chrominance components, except + for grayscale where 1,1 is used. + +int quant_tbl_no + Quantization table number for component. The default value is + 0 for luminance components and 1 for chrominance components. + +int dc_tbl_no +int ac_tbl_no + DC and AC entropy coding table numbers. The default values are + 0 for luminance components and 1 for chrominance components. + +int component_index + Must equal the component's index in comp_info[]. (Beginning in + release v6, the compressor library will fill this in automatically; + you don't have to.) + + +Decompression parameter selection +--------------------------------- + +Decompression parameter selection is somewhat simpler than compression +parameter selection, since all of the JPEG internal parameters are +recorded in the source file and need not be supplied by the application. +(Unless you are working with abbreviated files, in which case see +"Abbreviated datastreams", below.) Decompression parameters control +the postprocessing done on the image to deliver it in a format suitable +for the application's use. Many of the parameters control speed/quality +tradeoffs, in which faster decompression may be obtained at the price of +a poorer-quality image. The defaults select the highest quality (slowest) +processing. + +The following fields in the JPEG object are set by jpeg_read_header() and +may be useful to the application in choosing decompression parameters: + +JDIMENSION image_width Width and height of image +JDIMENSION image_height +int num_components Number of color components +J_COLOR_SPACE jpeg_color_space Colorspace of image +boolean saw_JFIF_marker TRUE if a JFIF APP0 marker was seen + UINT8 density_unit Resolution data from JFIF marker + UINT16 X_density + UINT16 Y_density +boolean saw_Adobe_marker TRUE if an Adobe APP14 marker was seen + UINT8 Adobe_transform Color transform code from Adobe marker + +The JPEG color space, unfortunately, is something of a guess since the JPEG +standard proper does not provide a way to record it. In practice most files +adhere to the JFIF or Adobe conventions, and the decoder will recognize these +correctly. See "Special color spaces", below, for more info. + + +The decompression parameters that determine the basic properties of the +returned image are: + +J_COLOR_SPACE out_color_space + Output color space. jpeg_read_header() sets an appropriate default + based on jpeg_color_space; typically it will be RGB or grayscale. + The application can change this field to request output in a different + colorspace. For example, set it to JCS_GRAYSCALE to get grayscale + output from a color file. (This is useful for previewing: grayscale + output is faster than full color since the color components need not + be processed.) Note that not all possible color space transforms are + currently implemented; you may need to extend jdcolor.c if you want an + unusual conversion. + +unsigned int scale_num, scale_denom + Scale the image by the fraction scale_num/scale_denom. Default is + 1/1, or no scaling. Currently, the only supported scaling ratios + are 1/1, 1/2, 1/4, and 1/8. (The library design allows for arbitrary + scaling ratios but this is not likely to be implemented any time soon.) + Smaller scaling ratios permit significantly faster decoding since + fewer pixels need be processed and a simpler IDCT method can be used. + +boolean quantize_colors + If set TRUE, colormapped output will be delivered. Default is FALSE, + meaning that full-color output will be delivered. + +The next three parameters are relevant only if quantize_colors is TRUE. + +int desired_number_of_colors + Maximum number of colors to use in generating a library-supplied color + map (the actual number of colors is returned in a different field). + Default 256. Ignored when the application supplies its own color map. + +boolean two_pass_quantize + If TRUE, an extra pass over the image is made to select a custom color + map for the image. This usually looks a lot better than the one-size- + fits-all colormap that is used otherwise. Default is TRUE. Ignored + when the application supplies its own color map. + +J_DITHER_MODE dither_mode + Selects color dithering method. Supported values are: + JDITHER_NONE no dithering: fast, very low quality + JDITHER_ORDERED ordered dither: moderate speed and quality + JDITHER_FS Floyd-Steinberg dither: slow, high quality + Default is JDITHER_FS. (At present, ordered dither is implemented + only in the single-pass, standard-colormap case. If you ask for + ordered dither when two_pass_quantize is TRUE or when you supply + an external color map, you'll get F-S dithering.) + +When quantize_colors is TRUE, the target color map is described by the next +two fields. colormap is set to NULL by jpeg_read_header(). The application +can supply a color map by setting colormap non-NULL and setting +actual_number_of_colors to the map size. Otherwise, jpeg_start_decompress() +selects a suitable color map and sets these two fields itself. +[Implementation restriction: at present, an externally supplied colormap is +only accepted for 3-component output color spaces.] + +JSAMPARRAY colormap + The color map, represented as a 2-D pixel array of out_color_components + rows and actual_number_of_colors columns. Ignored if not quantizing. + CAUTION: if the JPEG library creates its own colormap, the storage + pointed to by this field is released by jpeg_finish_decompress(). + Copy the colormap somewhere else first, if you want to save it. + +int actual_number_of_colors + The number of colors in the color map. + +Additional decompression parameters that the application may set include: + +J_DCT_METHOD dct_method + Selects the algorithm used for the DCT step. Choices are the same + as described above for compression. + +boolean do_fancy_upsampling + If TRUE, do careful upsampling of chroma components. If FALSE, + a faster but sloppier method is used. Default is TRUE. The visual + impact of the sloppier method is often very small. + +boolean do_block_smoothing + If TRUE, interblock smoothing is applied in early stages of decoding + progressive JPEG files; if FALSE, not. Default is TRUE. Early + progression stages look "fuzzy" with smoothing, "blocky" without. + In any case, block smoothing ceases to be applied after the first few + AC coefficients are known to full accuracy, so it is relevant only + when using buffered-image mode for progressive images. + +boolean enable_1pass_quant +boolean enable_external_quant +boolean enable_2pass_quant + These are significant only in buffered-image mode, which is + described in its own section below. + + +The output image dimensions are given by the following fields. These are +computed from the source image dimensions and the decompression parameters +by jpeg_start_decompress(). You can also call jpeg_calc_output_dimensions() +to obtain the values that will result from the current parameter settings. +This can be useful if you are trying to pick a scaling ratio that will get +close to a desired target size. It's also important if you are using the +JPEG library's memory manager to allocate output buffer space, because you +are supposed to request such buffers *before* jpeg_start_decompress(). + +JDIMENSION output_width Actual dimensions of output image. +JDIMENSION output_height +int out_color_components Number of color components in out_color_space. +int output_components Number of color components returned. +int rec_outbuf_height Recommended height of scanline buffer. + +When quantizing colors, output_components is 1, indicating a single color map +index per pixel. Otherwise it equals out_color_components. The output arrays +are required to be output_width * output_components JSAMPLEs wide. + +rec_outbuf_height is the recommended minimum height (in scanlines) of the +buffer passed to jpeg_read_scanlines(). If the buffer is smaller, the +library will still work, but time will be wasted due to unnecessary data +copying. In high-quality modes, rec_outbuf_height is always 1, but some +faster, lower-quality modes set it to larger values (typically 2 to 4). +If you are going to ask for a high-speed processing mode, you may as well +go to the trouble of honoring rec_outbuf_height so as to avoid data copying. + + +Special color spaces +-------------------- + +The JPEG standard itself is "color blind" and doesn't specify any particular +color space. It is customary to convert color data to a luminance/chrominance +color space before compressing, since this permits greater compression. The +existing de-facto JPEG file format standards specify YCbCr or grayscale data +(JFIF), or grayscale, RGB, YCbCr, CMYK, or YCCK (Adobe). For special +applications such as multispectral images, other color spaces can be used, +but it must be understood that such files will be unportable. + +The JPEG library can handle the most common colorspace conversions (namely +RGB <=> YCbCr and CMYK <=> YCCK). It can also deal with data of an unknown +color space, passing it through without conversion. If you deal extensively +with an unusual color space, you can easily extend the library to understand +additional color spaces and perform appropriate conversions. + +For compression, the source data's color space is specified by field +in_color_space. This is transformed to the JPEG file's color space given +by jpeg_color_space. jpeg_set_defaults() chooses a reasonable JPEG color +space depending on in_color_space, but you can override this by calling +jpeg_set_colorspace(). Of course you must select a supported transformation. +jccolor.c currently supports the following transformations: + RGB => YCbCr + RGB => GRAYSCALE + YCbCr => GRAYSCALE + CMYK => YCCK +plus the null transforms: GRAYSCALE => GRAYSCALE, RGB => RGB, +YCbCr => YCbCr, CMYK => CMYK, YCCK => YCCK, and UNKNOWN => UNKNOWN. + +The de-facto file format standards (JFIF and Adobe) specify APPn markers that +indicate the color space of the JPEG file. It is important to ensure that +these are written correctly, or omitted if the JPEG file's color space is not +one of the ones supported by the de-facto standards. jpeg_set_colorspace() +will set the compression parameters to include or omit the APPn markers +properly, so long as it is told the truth about the JPEG color space. +For example, if you are writing some random 3-component color space without +conversion, don't try to fake out the library by setting in_color_space and +jpeg_color_space to JCS_YCbCr; use JCS_UNKNOWN. You may want to write an +APPn marker of your own devising to identify the colorspace --- see "Special +markers", below. + +When told that the color space is UNKNOWN, the library will default to using +luminance-quality compression parameters for all color components. You may +well want to change these parameters. See the source code for +jpeg_set_colorspace(), in jcparam.c, for details. + +For decompression, the JPEG file's color space is given in jpeg_color_space, +and this is transformed to the output color space out_color_space. +jpeg_read_header's setting of jpeg_color_space can be relied on if the file +conforms to JFIF or Adobe conventions, but otherwise it is no better than a +guess. If you know the JPEG file's color space for certain, you can override +jpeg_read_header's guess by setting jpeg_color_space. jpeg_read_header also +selects a default output color space based on (its guess of) jpeg_color_space; +set out_color_space to override this. Again, you must select a supported +transformation. jdcolor.c currently supports + YCbCr => GRAYSCALE + YCbCr => RGB + YCCK => CMYK +as well as the null transforms. + +The two-pass color quantizer, jquant2.c, is specialized to handle RGB data +(it weights distances appropriately for RGB colors). You'll need to modify +the code if you want to use it for non-RGB output color spaces. Note that +jquant2.c is used to map to an application-supplied colormap as well as for +the normal two-pass colormap selection process. + +CAUTION: it appears that Adobe Photoshop writes inverted data in CMYK JPEG +files: 0 represents 100% ink coverage, rather than 0% ink as you'd expect. +This is arguably a bug in Photoshop, but if you need to work with Photoshop +CMYK files, you will have to deal with it in your application. We cannot +"fix" this in the library by inverting the data during the CMYK<=>YCCK +transform, because that would break other applications, notably Ghostscript. +Photoshop versions prior to 3.0 write EPS files containing JPEG-encoded CMYK +data in the same inverted-YCCK representation used in bare JPEG files, but +the surrounding PostScript code performs an inversion using the PS image +operator. I am told that Photoshop 3.0 will write uninverted YCCK in +EPS/JPEG files, and will omit the PS-level inversion. (But the data +polarity used in bare JPEG files will not change in 3.0.) In either case, +the JPEG library must not invert the data itself, or else Ghostscript would +read these EPS files incorrectly. + + +Error handling +-------------- + +When the default error handler is used, any error detected inside the JPEG +routines will cause a message to be printed on stderr, followed by exit(). +You can supply your own error handling routines to override this behavior +and to control the treatment of nonfatal warnings and trace/debug messages. +The file example.c illustrates the most common case, which is to have the +application regain control after an error rather than exiting. + +The JPEG library never writes any message directly; it always goes through +the error handling routines. Three classes of messages are recognized: + * Fatal errors: the library cannot continue. + * Warnings: the library can continue, but the data is corrupt, and a + damaged output image is likely to result. + * Trace/informational messages. These come with a trace level indicating + the importance of the message; you can control the verbosity of the + program by adjusting the maximum trace level that will be displayed. + +You may, if you wish, simply replace the entire JPEG error handling module +(jerror.c) with your own code. However, you can avoid code duplication by +only replacing some of the routines depending on the behavior you need. +This is accomplished by calling jpeg_std_error() as usual, but then overriding +some of the method pointers in the jpeg_error_mgr struct, as illustrated by +example.c. + +All of the error handling routines will receive a pointer to the JPEG object +(a j_common_ptr which points to either a jpeg_compress_struct or a +jpeg_decompress_struct; if you need to tell which, test the is_decompressor +field). This struct includes a pointer to the error manager struct in its +"err" field. Frequently, custom error handler routines will need to access +additional data which is not known to the JPEG library or the standard error +handler. The most convenient way to do this is to embed either the JPEG +object or the jpeg_error_mgr struct in a larger structure that contains +additional fields; then casting the passed pointer provides access to the +additional fields. Again, see example.c for one way to do it. + +The individual methods that you might wish to override are: + +error_exit (j_common_ptr cinfo) + Receives control for a fatal error. Information sufficient to + generate the error message has been stored in cinfo->err; call + output_message to display it. Control must NOT return to the caller; + generally this routine will exit() or longjmp() somewhere. + Typically you would override this routine to get rid of the exit() + default behavior. Note that if you continue processing, you should + clean up the JPEG object with jpeg_abort() or jpeg_destroy(). + +output_message (j_common_ptr cinfo) + Actual output of any JPEG message. Override this to send messages + somewhere other than stderr. Note that this method does not know + how to generate a message, only where to send it. + +format_message (j_common_ptr cinfo, char * buffer) + Constructs a readable error message string based on the error info + stored in cinfo->err. This method is called by output_message. Few + applications should need to override this method. One possible + reason for doing so is to implement dynamic switching of error message + language. + +emit_message (j_common_ptr cinfo, int msg_level) + Decide whether or not to emit a warning or trace message; if so, + calls output_message. The main reason for overriding this method + would be to abort on warnings. msg_level is -1 for warnings, + 0 and up for trace messages. + +Only error_exit() and emit_message() are called from the rest of the JPEG +library; the other two are internal to the error handler. + +The actual message texts are stored in an array of strings which is pointed to +by the field err->jpeg_message_table. The messages are numbered from 0 to +err->last_jpeg_message, and it is these code numbers that are used in the +JPEG library code. You could replace the message texts (for instance, with +messages in French or German) by changing the message table pointer. See +jerror.h for the default texts. CAUTION: this table will almost certainly +change or grow from one library version to the next. + +It may be useful for an application to add its own message texts that are +handled by the same mechanism. The error handler supports a second "add-on" +message table for this purpose. To define an addon table, set the pointer +err->addon_message_table and the message numbers err->first_addon_message and +err->last_addon_message. If you number the addon messages beginning at 1000 +or so, you won't have to worry about conflicts with the library's built-in +messages. See the sample applications cjpeg/djpeg for an example of using +addon messages (the addon messages are defined in cderror.h). + +Actual invocation of the error handler is done via macros defined in jerror.h: + ERREXITn(...) for fatal errors + WARNMSn(...) for corrupt-data warnings + TRACEMSn(...) for trace and informational messages. +These macros store the message code and any additional parameters into the +error handler struct, then invoke the error_exit() or emit_message() method. +The variants of each macro are for varying numbers of additional parameters. +The additional parameters are inserted into the generated message using +standard printf() format codes. + +See jerror.h and jerror.c for further details. + + +Compressed data handling (source and destination managers) +---------------------------------------------------------- + +The JPEG compression library sends its compressed data to a "destination +manager" module. The default destination manager just writes the data to a +stdio stream, but you can provide your own manager to do something else. +Similarly, the decompression library calls a "source manager" to obtain the +compressed data; you can provide your own source manager if you want the data +to come from somewhere other than a stdio stream. + +In both cases, compressed data is processed a bufferload at a time: the +destination or source manager provides a work buffer, and the library invokes +the manager only when the buffer is filled or emptied. (You could define a +one-character buffer to force the manager to be invoked for each byte, but +that would be rather inefficient.) The buffer's size and location are +controlled by the manager, not by the library. For example, if you desired to +decompress a JPEG datastream that was all in memory, you could just make the +buffer pointer and length point to the original data in memory. Then the +buffer-reload procedure would be invoked only if the decompressor ran off the +end of the datastream, which would indicate an erroneous datastream. + +The work buffer is defined as an array of datatype JOCTET, which is generally +"char" or "unsigned char". On a machine where char is not exactly 8 bits +wide, you must define JOCTET as a wider data type and then modify the data +source and destination modules to transcribe the work arrays into 8-bit units +on external storage. + +A data destination manager struct contains a pointer and count defining the +next byte to write in the work buffer and the remaining free space: + + JOCTET * next_output_byte; /* => next byte to write in buffer */ + size_t free_in_buffer; /* # of byte spaces remaining in buffer */ + +The library increments the pointer and decrements the count until the buffer +is filled. The manager's empty_output_buffer method must reset the pointer +and count. The manager is expected to remember the buffer's starting address +and total size in private fields not visible to the library. + +A data destination manager provides three methods: + +init_destination (j_compress_ptr cinfo) + Initialize destination. This is called by jpeg_start_compress() + before any data is actually written. It must initialize + next_output_byte and free_in_buffer. free_in_buffer must be + initialized to a positive value. + +empty_output_buffer (j_compress_ptr cinfo) + This is called whenever the buffer has filled (free_in_buffer + reaches zero). In typical applications, it should write out the + *entire* buffer (use the saved start address and buffer length; + ignore the current state of next_output_byte and free_in_buffer). + Then reset the pointer & count to the start of the buffer, and + return TRUE indicating that the buffer has been dumped. + free_in_buffer must be set to a positive value when TRUE is + returned. A FALSE return should only be used when I/O suspension is + desired (this operating mode is discussed in the next section). + +term_destination (j_compress_ptr cinfo) + Terminate destination --- called by jpeg_finish_compress() after all + data has been written. In most applications, this must flush any + data remaining in the buffer. Use either next_output_byte or + free_in_buffer to determine how much data is in the buffer. + +term_destination() is NOT called by jpeg_abort() or jpeg_destroy(). If you +want the destination manager to be cleaned up during an abort, you must do it +yourself. + +You will also need code to create a jpeg_destination_mgr struct, fill in its +method pointers, and insert a pointer to the struct into the "dest" field of +the JPEG compression object. This can be done in-line in your setup code if +you like, but it's probably cleaner to provide a separate routine similar to +the jpeg_stdio_dest() routine of the supplied destination manager. + +Decompression source managers follow a parallel design, but with some +additional frammishes. The source manager struct contains a pointer and count +defining the next byte to read from the work buffer and the number of bytes +remaining: + + const JOCTET * next_input_byte; /* => next byte to read from buffer */ + size_t bytes_in_buffer; /* # of bytes remaining in buffer */ + +The library increments the pointer and decrements the count until the buffer +is emptied. The manager's fill_input_buffer method must reset the pointer and +count. In most applications, the manager must remember the buffer's starting +address and total size in private fields not visible to the library. + +A data source manager provides five methods: + +init_source (j_decompress_ptr cinfo) + Initialize source. This is called by jpeg_read_header() before any + data is actually read. Unlike init_destination(), it may leave + bytes_in_buffer set to 0 (in which case a fill_input_buffer() call + will occur immediately). + +fill_input_buffer (j_decompress_ptr cinfo) + This is called whenever bytes_in_buffer has reached zero and more + data is wanted. In typical applications, it should read fresh data + into the buffer (ignoring the current state of next_input_byte and + bytes_in_buffer), reset the pointer & count to the start of the + buffer, and return TRUE indicating that the buffer has been reloaded. + It is not necessary to fill the buffer entirely, only to obtain at + least one more byte. bytes_in_buffer MUST be set to a positive value + if TRUE is returned. A FALSE return should only be used when I/O + suspension is desired (this mode is discussed in the next section). + +skip_input_data (j_decompress_ptr cinfo, long num_bytes) + Skip num_bytes worth of data. The buffer pointer and count should + be advanced over num_bytes input bytes, refilling the buffer as + needed. This is used to skip over a potentially large amount of + uninteresting data (such as an APPn marker). In some applications + it may be possible to optimize away the reading of the skipped data, + but it's not clear that being smart is worth much trouble; large + skips are uncommon. bytes_in_buffer may be zero on return. + A zero or negative skip count should be treated as a no-op. + +resync_to_restart (j_decompress_ptr cinfo, int desired) + This routine is called only when the decompressor has failed to find + a restart (RSTn) marker where one is expected. Its mission is to + find a suitable point for resuming decompression. For most + applications, we recommend that you just use the default resync + procedure, jpeg_resync_to_restart(). However, if you are able to back + up in the input data stream, or if you have a-priori knowledge about + the likely location of restart markers, you may be able to do better. + Read the read_restart_marker() and jpeg_resync_to_restart() routines + in jdmarker.c if you think you'd like to implement your own resync + procedure. + +term_source (j_decompress_ptr cinfo) + Terminate source --- called by jpeg_finish_decompress() after all + data has been read. Often a no-op. + +For both fill_input_buffer() and skip_input_data(), there is no such thing +as an EOF return. If the end of the file has been reached, the routine has +a choice of exiting via ERREXIT() or inserting fake data into the buffer. +In most cases, generating a warning message and inserting a fake EOI marker +is the best course of action --- this will allow the decompressor to output +however much of the image is there. In pathological cases, the decompressor +may swallow the EOI and again demand data ... just keep feeding it fake EOIs. +jdatasrc.c illustrates the recommended error recovery behavior. + +term_source() is NOT called by jpeg_abort() or jpeg_destroy(). If you want +the source manager to be cleaned up during an abort, you must do it yourself. + +You will also need code to create a jpeg_source_mgr struct, fill in its method +pointers, and insert a pointer to the struct into the "src" field of the JPEG +decompression object. This can be done in-line in your setup code if you +like, but it's probably cleaner to provide a separate routine similar to the +jpeg_stdio_src() routine of the supplied source manager. + +For more information, consult the stdio source and destination managers +in jdatasrc.c and jdatadst.c. + + +I/O suspension +-------------- + +Some applications need to use the JPEG library as an incremental memory-to- +memory filter: when the compressed data buffer is filled or emptied, they want +control to return to the outer loop, rather than expecting that the buffer can +be emptied or reloaded within the data source/destination manager subroutine. +The library supports this need by providing an "I/O suspension" mode, which we +describe in this section. + +The I/O suspension mode is not a panacea: nothing is guaranteed about the +maximum amount of time spent in any one call to the library, so it will not +eliminate response-time problems in single-threaded applications. If you +need guaranteed response time, we suggest you "bite the bullet" and implement +a real multi-tasking capability. + +To use I/O suspension, cooperation is needed between the calling application +and the data source or destination manager; you will always need a custom +source/destination manager. (Please read the previous section if you haven't +already.) The basic idea is that the empty_output_buffer() or +fill_input_buffer() routine is a no-op, merely returning FALSE to indicate +that it has done nothing. Upon seeing this, the JPEG library suspends +operation and returns to its caller. The surrounding application is +responsible for emptying or refilling the work buffer before calling the +JPEG library again. + +Compression suspension: + +For compression suspension, use an empty_output_buffer() routine that returns +FALSE; typically it will not do anything else. This will cause the +compressor to return to the caller of jpeg_write_scanlines(), with the return +value indicating that not all the supplied scanlines have been accepted. +The application must make more room in the output buffer, adjust the output +buffer pointer/count appropriately, and then call jpeg_write_scanlines() +again, pointing to the first unconsumed scanline. + +When forced to suspend, the compressor will backtrack to a convenient stopping +point (usually the start of the current MCU); it will regenerate some output +data when restarted. Therefore, although empty_output_buffer() is only +called when the buffer is filled, you should NOT write out the entire buffer +after a suspension. Write only the data up to the current position of +next_output_byte/free_in_buffer. The data beyond that point will be +regenerated after resumption. + +Because of the backtracking behavior, a good-size output buffer is essential +for efficiency; you don't want the compressor to suspend often. (In fact, an +overly small buffer could lead to infinite looping, if a single MCU required +more data than would fit in the buffer.) We recommend a buffer of at least +several Kbytes. You may want to insert explicit code to ensure that you don't +call jpeg_write_scanlines() unless there is a reasonable amount of space in +the output buffer; in other words, flush the buffer before trying to compress +more data. + +The compressor does not allow suspension while it is trying to write JPEG +markers at the beginning and end of the file. This means that: + * At the beginning of a compression operation, there must be enough free + space in the output buffer to hold the header markers (typically 600 or + so bytes). The recommended buffer size is bigger than this anyway, so + this is not a problem as long as you start with an empty buffer. However, + this restriction might catch you if you insert large special markers, such + as a JFIF thumbnail image, without flushing the buffer afterwards. + * When you call jpeg_finish_compress(), there must be enough space in the + output buffer to emit any buffered data and the final EOI marker. In the + current implementation, half a dozen bytes should suffice for this, but + for safety's sake we recommend ensuring that at least 100 bytes are free + before calling jpeg_finish_compress(). + +A more significant restriction is that jpeg_finish_compress() cannot suspend. +This means you cannot use suspension with multi-pass operating modes, namely +Huffman code optimization and multiple-scan output. Those modes write the +whole file during jpeg_finish_compress(), which will certainly result in +buffer overrun. (Note that this restriction applies only to compression, +not decompression. The decompressor supports input suspension in all of its +operating modes.) + +Decompression suspension: + +For decompression suspension, use a fill_input_buffer() routine that simply +returns FALSE (except perhaps during error recovery, as discussed below). +This will cause the decompressor to return to its caller with an indication +that suspension has occurred. This can happen at four places: + * jpeg_read_header(): will return JPEG_SUSPENDED. + * jpeg_start_decompress(): will return FALSE, rather than its usual TRUE. + * jpeg_read_scanlines(): will return the number of scanlines already + completed (possibly 0). + * jpeg_finish_decompress(): will return FALSE, rather than its usual TRUE. +The surrounding application must recognize these cases, load more data into +the input buffer, and repeat the call. In the case of jpeg_read_scanlines(), +increment the passed pointers past any scanlines successfully read. + +Just as with compression, the decompressor will typically backtrack to a +convenient restart point before suspending. When fill_input_buffer() is +called, next_input_byte/bytes_in_buffer point to the current restart point, +which is where the decompressor will backtrack to if FALSE is returned. +The data beyond that position must NOT be discarded if you suspend; it needs +to be re-read upon resumption. In most implementations, you'll need to shift +this data down to the start of your work buffer and then load more data after +it. Again, this behavior means that a several-Kbyte work buffer is essential +for decent performance; furthermore, you should load a reasonable amount of +new data before resuming decompression. (If you loaded, say, only one new +byte each time around, you could waste a LOT of cycles.) + +The skip_input_data() source manager routine requires special care in a +suspension scenario. This routine is NOT granted the ability to suspend the +decompressor; it can decrement bytes_in_buffer to zero, but no more. If the +requested skip distance exceeds the amount of data currently in the input +buffer, then skip_input_data() must set bytes_in_buffer to zero and record the +additional skip distance somewhere else. The decompressor will immediately +call fill_input_buffer(), which should return FALSE, which will cause a +suspension return. The surrounding application must then arrange to discard +the recorded number of bytes before it resumes loading the input buffer. +(Yes, this design is rather baroque, but it avoids complexity in the far more +common case where a non-suspending source manager is used.) + +If the input data has been exhausted, we recommend that you emit a warning +and insert dummy EOI markers just as a non-suspending data source manager +would do. This can be handled either in the surrounding application logic or +within fill_input_buffer(); the latter is probably more efficient. If +fill_input_buffer() knows that no more data is available, it can set the +pointer/count to point to a dummy EOI marker and then return TRUE just as +though it had read more data in a non-suspending situation. + +The decompressor does not attempt to suspend within any JPEG marker; it will +backtrack to the start of the marker. Hence the input buffer must be large +enough to hold the longest marker in the file. We recommend at least a 2K +buffer. The buffer would need to be 64K to allow for arbitrary COM or APPn +markers, but the decompressor does not actually try to read these; it just +skips them by calling skip_input_data(). If you provide a special marker +handling routine that does look at such markers, coping with buffer overflow +is your problem. Ordinary JPEG markers should normally not exceed a few +hundred bytes each (DHT tables are typically the longest). For robustness +against damaged marker length counts, you may wish to insert a test in your +application for the case that the input buffer is completely full and yet the +decoder has suspended without consuming any data --- otherwise, if this +situation did occur, it would lead to an endless loop. + +Multiple-buffer management: + +In some applications it is desirable to store the compressed data in a linked +list of buffer areas, so as to avoid data copying. This can be handled by +having empty_output_buffer() or fill_input_buffer() set the pointer and count +to reference the next available buffer; FALSE is returned only if no more +buffers are available. Although seemingly straightforward, there is a +pitfall in this approach: the backtrack that occurs when FALSE is returned +could back up into an earlier buffer. For example, when fill_input_buffer() +is called, the current pointer & count indicate the backtrack restart point. +Since fill_input_buffer() will set the pointer and count to refer to a new +buffer, the restart position must be saved somewhere else. Suppose a second +call to fill_input_buffer() occurs in the same library call, and no +additional input data is available, so fill_input_buffer must return FALSE. +If the JPEG library has not moved the pointer/count forward in the current +buffer, then *the correct restart point is the saved position in the prior +buffer*. Prior buffers may be discarded only after the library establishes +a restart point within a later buffer. Similar remarks apply for output into +a chain of buffers. + +The library will never attempt to backtrack over a skip_input_data() call, +so any skipped data can be permanently discarded. You still have to deal +with the case of skipping not-yet-received data, however. + +It's much simpler to use only a single buffer; when fill_input_buffer() is +called, move any unconsumed data (beyond the current pointer/count) down to +the beginning of this buffer and then load new data into the remaining buffer +space. This approach requires a little more data copying but is far easier +to get right. + + +Progressive JPEG support +------------------------ + +Progressive JPEG rearranges the stored data into a series of scans of +increasing quality. In situations where a JPEG file is transmitted across a +slow communications link, a decoder can generate a low-quality image very +quickly from the first scan, then gradually improve the displayed quality as +more scans are received. The final image after all scans are complete is +identical to that of a regular (sequential) JPEG file of the same quality +setting. Progressive JPEG files are often slightly smaller than equivalent +sequential JPEG files, but the possibility of incremental display is the main +reason for using progressive JPEG. + +The IJG encoder library generates progressive JPEG files when given a +suitable "scan script" defining how to divide the data into scans. +Creation of progressive JPEG files is otherwise transparent to the encoder. +Progressive JPEG files can also be read transparently by the decoder library. +If the decoding application simply uses the library as defined above, it +will receive a final decoded image without any indication that the file was +progressive. Of course, this approach does not allow incremental display. +To perform incremental display, an application needs to use the decoder +library's "buffered-image" mode, in which it receives a decoded image +multiple times. + +Each displayed scan requires about as much work to decode as a full JPEG +image of the same size, so the decoder must be fairly fast in relation to the +data transmission rate in order to make incremental display useful. However, +it is possible to skip displaying the image and simply add the incoming bits +to the decoder's coefficient buffer. This is fast because only Huffman +decoding need be done, not IDCT, upsampling, colorspace conversion, etc. +The IJG decoder library allows the application to switch dynamically between +displaying the image and simply absorbing the incoming bits. A properly +coded application can automatically adapt the number of display passes to +suit the time available as the image is received. Also, a final +higher-quality display cycle can be performed from the buffered data after +the end of the file is reached. + +Progressive compression: + +To create a progressive JPEG file (or a multiple-scan sequential JPEG file), +set the scan_info cinfo field to point to an array of scan descriptors, and +perform compression as usual. Instead of constructing your own scan list, +you can call the jpeg_simple_progression() helper routine to create a +recommended progression sequence; this method should be used by all +applications that don't want to get involved in the nitty-gritty of +progressive scan sequence design. (If you want to provide user control of +scan sequences, you may wish to borrow the scan script reading code found +in rdswitch.c, so that you can read scan script files just like cjpeg's.) +When scan_info is not NULL, the compression library will store DCT'd data +into a buffer array as jpeg_write_scanlines() is called, and will emit all +the requested scans during jpeg_finish_compress(). This implies that +multiple-scan output cannot be created with a suspending data destination +manager, since jpeg_finish_compress() does not support suspension. We +should also note that the compressor currently forces Huffman optimization +mode when creating a progressive JPEG file, because the default Huffman +tables are unsuitable for progressive files. + +Progressive decompression: + +When buffered-image mode is not used, the decoder library will read all of +a multi-scan file during jpeg_start_decompress(), so that it can provide a +final decoded image. (Here "multi-scan" means either progressive or +multi-scan sequential.) This makes multi-scan files transparent to the +decoding application. However, existing applications that used suspending +input with version 5 of the IJG library will need to be modified to check +for a suspension return from jpeg_start_decompress(). + +To perform incremental display, an application must use the library's +buffered-image mode. This is described in the next section. + + +Buffered-image mode +------------------- + +In buffered-image mode, the library stores the partially decoded image in a +coefficient buffer, from which it can be read out as many times as desired. +This mode is typically used for incremental display of progressive JPEG files, +but it can be used with any JPEG file. Each scan of a progressive JPEG file +adds more data (more detail) to the buffered image. The application can +display in lockstep with the source file (one display pass per input scan), +or it can allow input processing to outrun display processing. By making +input and display processing run independently, it is possible for the +application to adapt progressive display to a wide range of data transmission +rates. + +The basic control flow for buffered-image decoding is + + jpeg_create_decompress() + set data source + jpeg_read_header() + set overall decompression parameters + cinfo.buffered_image = TRUE; /* select buffered-image mode */ + jpeg_start_decompress() + for (each output pass) { + adjust output decompression parameters if required + jpeg_start_output() /* start a new output pass */ + for (all scanlines in image) { + jpeg_read_scanlines() + display scanlines + } + jpeg_finish_output() /* terminate output pass */ + } + jpeg_finish_decompress() + jpeg_destroy_decompress() + +This differs from ordinary unbuffered decoding in that there is an additional +level of looping. The application can choose how many output passes to make +and how to display each pass. + +The simplest approach to displaying progressive images is to do one display +pass for each scan appearing in the input file. In this case the outer loop +condition is typically + while (! jpeg_input_complete(&cinfo)) +and the start-output call should read + jpeg_start_output(&cinfo, cinfo.input_scan_number); +The second parameter to jpeg_start_output() indicates which scan of the input +file is to be displayed; the scans are numbered starting at 1 for this +purpose. (You can use a loop counter starting at 1 if you like, but using +the library's input scan counter is easier.) The library automatically reads +data as necessary to complete each requested scan, and jpeg_finish_output() +advances to the next scan or end-of-image marker (hence input_scan_number +will be incremented by the time control arrives back at jpeg_start_output()). +With this technique, data is read from the input file only as needed, and +input and output processing run in lockstep. + +After reading the final scan and reaching the end of the input file, the +buffered image remains available; it can be read additional times by +repeating the jpeg_start_output()/jpeg_read_scanlines()/jpeg_finish_output() +sequence. For example, a useful technique is to use fast one-pass color +quantization for display passes made while the image is arriving, followed by +a final display pass using two-pass quantization for highest quality. This +is done by changing the library parameters before the final output pass. +Changing parameters between passes is discussed in detail below. + +In general the last scan of a progressive file cannot be recognized as such +until after it is read, so a post-input display pass is the best approach if +you want special processing in the final pass. + +When done with the image, be sure to call jpeg_finish_decompress() to release +the buffered image (or just use jpeg_destroy_decompress()). + +If input data arrives faster than it can be displayed, the application can +cause the library to decode input data in advance of what's needed to produce +output. This is done by calling the routine jpeg_consume_input(). +The return value is one of the following: + JPEG_REACHED_SOS: reached an SOS marker (the start of a new scan) + JPEG_REACHED_EOI: reached the EOI marker (end of image) + JPEG_ROW_COMPLETED: completed reading one MCU row of compressed data + JPEG_SCAN_COMPLETED: completed reading last MCU row of current scan + JPEG_SUSPENDED: suspended before completing any of the above +(JPEG_SUSPENDED can occur only if a suspending data source is used.) This +routine can be called at any time after initializing the JPEG object. It +reads some additional data and returns when one of the indicated significant +events occurs. (If called after the EOI marker is reached, it will +immediately return JPEG_REACHED_EOI without attempting to read more data.) + +The library's output processing will automatically call jpeg_consume_input() +whenever the output processing overtakes the input; thus, simple lockstep +display requires no direct calls to jpeg_consume_input(). But by adding +calls to jpeg_consume_input(), you can absorb data in advance of what is +being displayed. This has two benefits: + * You can limit buildup of unprocessed data in your input buffer. + * You can eliminate extra display passes by paying attention to the + state of the library's input processing. + +The first of these benefits only requires interspersing calls to +jpeg_consume_input() with your display operations and any other processing +you may be doing. To avoid wasting cycles due to backtracking, it's best to +call jpeg_consume_input() only after a hundred or so new bytes have arrived. +This is discussed further under "I/O suspension", above. (Note: the JPEG +library currently is not thread-safe. You must not call jpeg_consume_input() +from one thread of control if a different library routine is working on the +same JPEG object in another thread.) + +When input arrives fast enough that more than one new scan is available +before you start a new output pass, you may as well skip the output pass +corresponding to the completed scan. This occurs for free if you pass +cinfo.input_scan_number as the target scan number to jpeg_start_output(). +The input_scan_number field is simply the index of the scan currently being +consumed by the input processor. You can ensure that this is up-to-date by +emptying the input buffer just before calling jpeg_start_output(): call +jpeg_consume_input() repeatedly until it returns JPEG_SUSPENDED or +JPEG_REACHED_EOI. + +The target scan number passed to jpeg_start_output() is saved in the +cinfo.output_scan_number field. The library's output processing calls +jpeg_consume_input() whenever the current input scan number and row within +that scan is less than or equal to the current output scan number and row. +Thus, input processing can "get ahead" of the output processing but is not +allowed to "fall behind". You can achieve several different effects by +manipulating this interlock rule. For example, if you pass a target scan +number greater than the current input scan number, the output processor will +wait until that scan starts to arrive before producing any output. (To avoid +an infinite loop, the target scan number is automatically reset to the last +scan number when the end of image is reached. Thus, if you specify a large +target scan number, the library will just absorb the entire input file and +then perform an output pass. This is effectively the same as what +jpeg_start_decompress() does when you don't select buffered-image mode.) +When you pass a target scan number equal to the current input scan number, +the image is displayed no faster than the current input scan arrives. The +final possibility is to pass a target scan number less than the current input +scan number; this disables the input/output interlock and causes the output +processor to simply display whatever it finds in the image buffer, without +waiting for input. (However, the library will not accept a target scan +number less than one, so you can't avoid waiting for the first scan.) + +When data is arriving faster than the output display processing can advance +through the image, jpeg_consume_input() will store data into the buffered +image beyond the point at which the output processing is reading data out +again. If the input arrives fast enough, it may "wrap around" the buffer to +the point where the input is more than one whole scan ahead of the output. +If the output processing simply proceeds through its display pass without +paying attention to the input, the effect seen on-screen is that the lower +part of the image is one or more scans better in quality than the upper part. +Then, when the next output scan is started, you have a choice of what target +scan number to use. The recommended choice is to use the current input scan +number at that time, which implies that you've skipped the output scans +corresponding to the input scans that were completed while you processed the +previous output scan. In this way, the decoder automatically adapts its +speed to the arriving data, by skipping output scans as necessary to keep up +with the arriving data. + +When using this strategy, you'll want to be sure that you perform a final +output pass after receiving all the data; otherwise your last display may not +be full quality across the whole screen. So the right outer loop logic is +something like this: + do { + absorb any waiting input by calling jpeg_consume_input() + final_pass = jpeg_input_complete(&cinfo); + adjust output decompression parameters if required + jpeg_start_output(&cinfo, cinfo.input_scan_number); + ... + jpeg_finish_output() + } while (! final_pass); +rather than quitting as soon as jpeg_input_complete() returns TRUE. This +arrangement makes it simple to use higher-quality decoding parameters +for the final pass. But if you don't want to use special parameters for +the final pass, the right loop logic is like this: + for (;;) { + absorb any waiting input by calling jpeg_consume_input() + jpeg_start_output(&cinfo, cinfo.input_scan_number); + ... + jpeg_finish_output() + if (jpeg_input_complete(&cinfo) && + cinfo.input_scan_number == cinfo.output_scan_number) + break; + } +In this case you don't need to know in advance whether an output pass is to +be the last one, so it's not necessary to have reached EOF before starting +the final output pass; rather, what you want to test is whether the output +pass was performed in sync with the final input scan. This form of the loop +will avoid an extra output pass whenever the decoder is able (or nearly able) +to keep up with the incoming data. + +When the data transmission speed is high, you might begin a display pass, +then find that much or all of the file has arrived before you can complete +the pass. (You can detect this by noting the JPEG_REACHED_EOI return code +from jpeg_consume_input(), or equivalently by testing jpeg_input_complete().) +In this situation you may wish to abort the current display pass and start a +new one using the newly arrived information. To do so, just call +jpeg_finish_output() and then start a new pass with jpeg_start_output(). + +A variant strategy is to abort and restart display if more than one complete +scan arrives during an output pass; this can be detected by noting +JPEG_REACHED_SOS returns and/or examining cinfo.input_scan_number. This +idea should be employed with caution, however, since the display process +might never get to the bottom of the image before being aborted, resulting +in the lower part of the screen being several passes worse than the upper. +In most cases it's probably best to abort an output pass only if the whole +file has arrived and you want to begin the final output pass immediately. + +When receiving data across a communication link, we recommend always using +the current input scan number for the output target scan number; if a +higher-quality final pass is to be done, it should be started (aborting any +incomplete output pass) as soon as the end of file is received. However, +many other strategies are possible. For example, the application can examine +the parameters of the current input scan and decide whether to display it or +not. If the scan contains only chroma data, one might choose not to use it +as the target scan, expecting that the scan will be small and will arrive +quickly. To skip to the next scan, call jpeg_consume_input() until it +returns JPEG_REACHED_SOS or JPEG_REACHED_EOI. Or just use the next higher +number as the target scan for jpeg_start_output(); but that method doesn't +let you inspect the next scan's parameters before deciding to display it. + + +In buffered-image mode, jpeg_start_decompress() never performs input and +thus never suspends. An application that uses input suspension with +buffered-image mode must be prepared for suspension returns from these +routines: +* jpeg_start_output() performs input only if you request 2-pass quantization + and the target scan isn't fully read yet. (This is discussed below.) +* jpeg_read_scanlines(), as always, returns the number of scanlines that it + was able to produce before suspending. +* jpeg_finish_output() will read any markers following the target scan, + up to the end of the file or the SOS marker that begins another scan. + (But it reads no input if jpeg_consume_input() has already reached the + end of the file or a SOS marker beyond the target output scan.) +* jpeg_finish_decompress() will read until the end of file, and thus can + suspend if the end hasn't already been reached (as can be tested by + calling jpeg_input_complete()). +jpeg_start_output(), jpeg_finish_output(), and jpeg_finish_decompress() +all return TRUE if they completed their tasks, FALSE if they had to suspend. +In the event of a FALSE return, the application must load more input data +and repeat the call. Applications that use non-suspending data sources need +not check the return values of these three routines. + + +It is possible to change decoding parameters between output passes in the +buffered-image mode. The decoder library currently supports only very +limited changes of parameters. ONLY THE FOLLOWING parameter changes are +allowed after jpeg_start_decompress() is called: +* dct_method can be changed before each call to jpeg_start_output(). + For example, one could use a fast DCT method for early scans, changing + to a higher quality method for the final scan. +* dither_mode can be changed before each call to jpeg_start_output(); + of course this has no impact if not using color quantization. Typically + one would use ordered dither for initial passes, then switch to + Floyd-Steinberg dither for the final pass. Caution: changing dither mode + can cause more memory to be allocated by the library. Although the amount + of memory involved is not large (a scanline or so), it may cause the + initial max_memory_to_use specification to be exceeded, which in the worst + case would result in an out-of-memory failure. +* do_block_smoothing can be changed before each call to jpeg_start_output(). + This setting is relevant only when decoding a progressive JPEG image. + During the first DC-only scan, block smoothing provides a very "fuzzy" look + instead of the very "blocky" look seen without it; which is better seems a + matter of personal taste. But block smoothing is nearly always a win + during later stages, especially when decoding a successive-approximation + image: smoothing helps to hide the slight blockiness that otherwise shows + up on smooth gradients until the lowest coefficient bits are sent. +* Color quantization mode can be changed under the rules described below. + You *cannot* change between full-color and quantized output (because that + would alter the required I/O buffer sizes), but you can change which + quantization method is used. + +When generating color-quantized output, changing quantization method is a +very useful way of switching between high-speed and high-quality display. +The library allows you to change among its three quantization methods: +1. Single-pass quantization to a fixed color cube. + Selected by cinfo.two_pass_quantize = FALSE and cinfo.colormap = NULL. +2. Single-pass quantization to an application-supplied colormap. + Selected by setting cinfo.colormap to point to the colormap (the value of + two_pass_quantize is ignored); also set cinfo.actual_number_of_colors. +3. Two-pass quantization to a colormap chosen specifically for the image. + Selected by cinfo.two_pass_quantize = TRUE and cinfo.colormap = NULL. + (This is the default setting selected by jpeg_read_header, but it is + probably NOT what you want for the first pass of progressive display!) +These methods offer successively better quality and lesser speed. However, +only the first method is available for quantizing in non-RGB color spaces. + +IMPORTANT: because the different quantizer methods have very different +working-storage requirements, the library requires you to indicate which +one(s) you intend to use before you call jpeg_start_decompress(). (If we did +not require this, the max_memory_to_use setting would be a complete fiction.) +You do this by setting one or more of these three cinfo fields to TRUE: + enable_1pass_quant Fixed color cube colormap + enable_external_quant Externally-supplied colormap + enable_2pass_quant Two-pass custom colormap +All three are initialized FALSE by jpeg_read_header(). But +jpeg_start_decompress() automatically sets TRUE the one selected by the +current two_pass_quantize and colormap settings, so you only need to set the +enable flags for any other quantization methods you plan to change to later. + +After setting the enable flags correctly at jpeg_start_decompress() time, you +can change to any enabled quantization method by setting two_pass_quantize +and colormap properly just before calling jpeg_start_output(). The following +special rules apply: +1. You must explicitly set cinfo.colormap to NULL when switching to 1-pass + or 2-pass mode from a different mode, or when you want the 2-pass + quantizer to be re-run to generate a new colormap. +2. To switch to an external colormap, or to change to a different external + colormap than was used on the prior pass, you must call + jpeg_new_colormap() after setting cinfo.colormap. +NOTE: if you want to use the same colormap as was used in the prior pass, +you should not do either of these things. This will save some nontrivial +switchover costs. +(These requirements exist because cinfo.colormap will always be non-NULL +after completing a prior output pass, since both the 1-pass and 2-pass +quantizers set it to point to their output colormaps. Thus you have to +do one of these two things to notify the library that something has changed. +Yup, it's a bit klugy, but it's necessary to do it this way for backwards +compatibility.) + +Note that in buffered-image mode, the library generates any requested colormap +during jpeg_start_output(), not during jpeg_start_decompress(). + +When using two-pass quantization, jpeg_start_output() makes a pass over the +buffered image to determine the optimum color map; it therefore may take a +significant amount of time, whereas ordinarily it does little work. The +progress monitor hook is called during this pass, if defined. It is also +important to realize that if the specified target scan number is greater than +or equal to the current input scan number, jpeg_start_output() will attempt +to consume input as it makes this pass. If you use a suspending data source, +you need to check for a FALSE return from jpeg_start_output() under these +conditions. The combination of 2-pass quantization and a not-yet-fully-read +target scan is the only case in which jpeg_start_output() will consume input. + + +Application authors who support buffered-image mode may be tempted to use it +for all JPEG images, even single-scan ones. This will work, but it is +inefficient: there is no need to create an image-sized coefficient buffer for +single-scan images. Requesting buffered-image mode for such an image wastes +memory. Worse, it can cost time on large images, since the buffered data has +to be swapped out or written to a temporary file. If you are concerned about +maximum performance on baseline JPEG files, you should use buffered-image +mode only when the incoming file actually has multiple scans. This can be +tested by calling jpeg_has_multiple_scans(), which will return a correct +result at any time after jpeg_read_header() completes. + +It is also worth noting that when you use jpeg_consume_input() to let input +processing get ahead of output processing, the resulting pattern of access to +the coefficient buffer is quite nonsequential. It's best to use the memory +manager jmemnobs.c if you can (ie, if you have enough real or virtual main +memory). If not, at least make sure that max_memory_to_use is set as high as +possible. If the JPEG memory manager has to use a temporary file, you will +probably see a lot of disk traffic and poor performance. (This could be +improved with additional work on the memory manager, but we haven't gotten +around to it yet.) + +In some applications it may be convenient to use jpeg_consume_input() for all +input processing, including reading the initial markers; that is, you may +wish to call jpeg_consume_input() instead of jpeg_read_header() during +startup. This works, but note that you must check for JPEG_REACHED_SOS and +JPEG_REACHED_EOI return codes as the equivalent of jpeg_read_header's codes. +Once the first SOS marker has been reached, you must call +jpeg_start_decompress() before jpeg_consume_input() will consume more input; +it'll just keep returning JPEG_REACHED_SOS until you do. If you read a +tables-only file this way, jpeg_consume_input() will return JPEG_REACHED_EOI +without ever returning JPEG_REACHED_SOS; be sure to check for this case. +If this happens, the decompressor will not read any more input until you call +jpeg_abort() to reset it. It is OK to call jpeg_consume_input() even when not +using buffered-image mode, but in that case it's basically a no-op after the +initial markers have been read: it will just return JPEG_SUSPENDED. + + +Abbreviated datastreams and multiple images +------------------------------------------- + +A JPEG compression or decompression object can be reused to process multiple +images. This saves a small amount of time per image by eliminating the +"create" and "destroy" operations, but that isn't the real purpose of the +feature. Rather, reuse of an object provides support for abbreviated JPEG +datastreams. Object reuse can also simplify processing a series of images in +a single input or output file. This section explains these features. + +A JPEG file normally contains several hundred bytes worth of quantization +and Huffman tables. In a situation where many images will be stored or +transmitted with identical tables, this may represent an annoying overhead. +The JPEG standard therefore permits tables to be omitted. The standard +defines three classes of JPEG datastreams: + * "Interchange" datastreams contain an image and all tables needed to decode + the image. These are the usual kind of JPEG file. + * "Abbreviated image" datastreams contain an image, but are missing some or + all of the tables needed to decode that image. + * "Abbreviated table specification" (henceforth "tables-only") datastreams + contain only table specifications. +To decode an abbreviated image, it is necessary to load the missing table(s) +into the decoder beforehand. This can be accomplished by reading a separate +tables-only file. A variant scheme uses a series of images in which the first +image is an interchange (complete) datastream, while subsequent ones are +abbreviated and rely on the tables loaded by the first image. It is assumed +that once the decoder has read a table, it will remember that table until a +new definition for the same table number is encountered. + +It is the application designer's responsibility to figure out how to associate +the correct tables with an abbreviated image. While abbreviated datastreams +can be useful in a closed environment, their use is strongly discouraged in +any situation where data exchange with other applications might be needed. +Caveat designer. + +The JPEG library provides support for reading and writing any combination of +tables-only datastreams and abbreviated images. In both compression and +decompression objects, a quantization or Huffman table will be retained for +the lifetime of the object, unless it is overwritten by a new table definition. + + +To create abbreviated image datastreams, it is only necessary to tell the +compressor not to emit some or all of the tables it is using. Each +quantization and Huffman table struct contains a boolean field "sent_table", +which normally is initialized to FALSE. For each table used by the image, the +header-writing process emits the table and sets sent_table = TRUE unless it is +already TRUE. (In normal usage, this prevents outputting the same table +definition multiple times, as would otherwise occur because the chroma +components typically share tables.) Thus, setting this field to TRUE before +calling jpeg_start_compress() will prevent the table from being written at +all. + +If you want to create a "pure" abbreviated image file containing no tables, +just call "jpeg_suppress_tables(&cinfo, TRUE)" after constructing all the +tables. If you want to emit some but not all tables, you'll need to set the +individual sent_table fields directly. + +To create an abbreviated image, you must also call jpeg_start_compress() +with a second parameter of FALSE, not TRUE. Otherwise jpeg_start_compress() +will force all the sent_table fields to FALSE. (This is a safety feature to +prevent abbreviated images from being created accidentally.) + +To create a tables-only file, perform the same parameter setup that you +normally would, but instead of calling jpeg_start_compress() and so on, call +jpeg_write_tables(&cinfo). This will write an abbreviated datastream +containing only SOI, DQT and/or DHT markers, and EOI. All the quantization +and Huffman tables that are currently defined in the compression object will +be emitted unless their sent_tables flag is already TRUE, and then all the +sent_tables flags will be set TRUE. + +A sure-fire way to create matching tables-only and abbreviated image files +is to proceed as follows: + + create JPEG compression object + set JPEG parameters + set destination to tables-only file + jpeg_write_tables(&cinfo); + set destination to image file + jpeg_start_compress(&cinfo, FALSE); + write data... + jpeg_finish_compress(&cinfo); + +Since the JPEG parameters are not altered between writing the table file and +the abbreviated image file, the same tables are sure to be used. Of course, +you can repeat the jpeg_start_compress() ... jpeg_finish_compress() sequence +many times to produce many abbreviated image files matching the table file. + +You cannot suppress output of the computed Huffman tables when Huffman +optimization is selected. (If you could, there'd be no way to decode the +image...) Generally, you don't want to set optimize_coding = TRUE when +you are trying to produce abbreviated files. + +In some cases you might want to compress an image using tables which are +not stored in the application, but are defined in an interchange or +tables-only file readable by the application. This can be done by setting up +a JPEG decompression object to read the specification file, then copying the +tables into your compression object. See jpeg_copy_critical_parameters() +for an example of copying quantization tables. + + +To read abbreviated image files, you simply need to load the proper tables +into the decompression object before trying to read the abbreviated image. +If the proper tables are stored in the application program, you can just +allocate the table structs and fill in their contents directly. More commonly +you'd want to read the tables from a tables-only file. The jpeg_read_header() +call is sufficient to read a tables-only file. You must pass a second +parameter of FALSE to indicate that you do not require an image to be present. +Thus, the typical scenario is + + create JPEG decompression object + set source to tables-only file + jpeg_read_header(&cinfo, FALSE); + set source to abbreviated image file + jpeg_read_header(&cinfo, TRUE); + set decompression parameters + jpeg_start_decompress(&cinfo); + read data... + jpeg_finish_decompress(&cinfo); + +In some cases, you may want to read a file without knowing whether it contains +an image or just tables. In that case, pass FALSE and check the return value +from jpeg_read_header(): it will be JPEG_HEADER_OK if an image was found, +JPEG_HEADER_TABLES_ONLY if only tables were found. (A third return value, +JPEG_SUSPENDED, is possible when using a suspending data source manager.) +Note that jpeg_read_header() will not complain if you read an abbreviated +image for which you haven't loaded the missing tables; the missing-table check +occurs later, in jpeg_start_decompress(). + + +It is possible to read a series of images from a single source file by +repeating the jpeg_read_header() ... jpeg_finish_decompress() sequence, +without releasing/recreating the JPEG object or the data source module. +(If you did reinitialize, any partial bufferload left in the data source +buffer at the end of one image would be discarded, causing you to lose the +start of the next image.) When you use this method, stored tables are +automatically carried forward, so some of the images can be abbreviated images +that depend on tables from earlier images. + +If you intend to write a series of images into a single destination file, +you might want to make a specialized data destination module that doesn't +flush the output buffer at term_destination() time. This would speed things +up by some trifling amount. Of course, you'd need to remember to flush the +buffer after the last image. You can make the later images be abbreviated +ones by passing FALSE to jpeg_start_compress(). + + +Special markers +--------------- + +Some applications may need to insert or extract special data in the JPEG +datastream. The JPEG standard provides marker types "COM" (comment) and +"APP0" through "APP15" (application) to hold application-specific data. +Unfortunately, the use of these markers is not specified by the standard. +COM markers are fairly widely used to hold user-supplied text. The JFIF file +format spec uses APP0 markers with specified initial strings to hold certain +data. Adobe applications use APP14 markers beginning with the string "Adobe" +for miscellaneous data. Other APPn markers are rarely seen, but might +contain almost anything. + +If you wish to store user-supplied text, we recommend you use COM markers +and place readable 7-bit ASCII text in them. Newline conventions are not +standardized --- expect to find LF (Unix style), CR/LF (DOS style), or CR +(Mac style). A robust COM reader should be able to cope with random binary +garbage, including nulls, since some applications generate COM markers +containing non-ASCII junk. (But yours should not be one of them.) + +For program-supplied data, use an APPn marker, and be sure to begin it with an +identifying string so that you can tell whether the marker is actually yours. +It's probably best to avoid using APP0 or APP14 for any private markers. +(NOTE: the upcoming SPIFF standard will use APP8 markers; we recommend you +not use APP8 markers for any private purposes, either.) + +Keep in mind that at most 65533 bytes can be put into one marker, but you +can have as many markers as you like. + +By default, the IJG compression library will write a JFIF APP0 marker if the +selected JPEG colorspace is grayscale or YCbCr, or an Adobe APP14 marker if +the selected colorspace is RGB, CMYK, or YCCK. You can disable this, but +we don't recommend it. The decompression library will recognize JFIF and +Adobe markers and will set the JPEG colorspace properly when one is found. + +You can write special markers immediately following the datastream header by +calling jpeg_write_marker() after jpeg_start_compress() and before the first +call to jpeg_write_scanlines(). When you do this, the markers appear after +the SOI and the JFIF APP0 and Adobe APP14 markers (if written), but before +all else. Specify the marker type parameter as "JPEG_COM" for COM or +"JPEG_APP0 + n" for APPn. (Actually, jpeg_write_marker will let you write +any marker type, but we don't recommend writing any other kinds of marker.) +For example, to write a user comment string pointed to by comment_text: + jpeg_write_marker(cinfo, JPEG_COM, comment_text, strlen(comment_text)); +Or if you prefer to synthesize the marker byte sequence yourself, you can +just cram it straight into the data destination module. + +For decompression, you can supply your own routine to process COM or APPn +markers by calling jpeg_set_marker_processor(). Usually you'd call this +after creating a decompression object and before calling jpeg_read_header(), +because the markers of interest will normally be scanned by jpeg_read_header. +Once you've supplied a routine, it will be used for the life of that +decompression object. A separate routine may be registered for COM and for +each APPn marker code. + +A marker processor routine must have the signature + boolean jpeg_marker_parser_method (j_decompress_ptr cinfo) +Although the marker code is not explicitly passed, the routine can find it +in cinfo->unread_marker. At the time of call, the marker proper has been +read from the data source module. The processor routine is responsible for +reading the marker length word and the remaining parameter bytes, if any. +Return TRUE to indicate success. (FALSE should be returned only if you are +using a suspending data source and it tells you to suspend. See the standard +marker processors in jdmarker.c for appropriate coding methods if you need to +use a suspending data source.) + +If you override the default APP0 or APP14 processors, it is up to you to +recognize JFIF and Adobe markers if you want colorspace recognition to occur +properly. We recommend copying and extending the default processors if you +want to do that. + +A simple example of an external COM processor can be found in djpeg.c. + + +Raw (downsampled) image data +---------------------------- + +Some applications need to supply already-downsampled image data to the JPEG +compressor, or to receive raw downsampled data from the decompressor. The +library supports this requirement by allowing the application to write or +read raw data, bypassing the normal preprocessing or postprocessing steps. +The interface is different from the standard one and is somewhat harder to +use. If your interest is merely in bypassing color conversion, we recommend +that you use the standard interface and simply set jpeg_color_space = +in_color_space (or jpeg_color_space = out_color_space for decompression). +The mechanism described in this section is necessary only to supply or +receive downsampled image data, in which not all components have the same +dimensions. + + +To compress raw data, you must supply the data in the colorspace to be used +in the JPEG file (please read the earlier section on Special color spaces) +and downsampled to the sampling factors specified in the JPEG parameters. +You must supply the data in the format used internally by the JPEG library, +namely a JSAMPIMAGE array. This is an array of pointers to two-dimensional +arrays, each of type JSAMPARRAY. Each 2-D array holds the values for one +color component. This structure is necessary since the components are of +different sizes. If the image dimensions are not a multiple of the MCU size, +you must also pad the data correctly (usually, this is done by replicating +the last column and/or row). The data must be padded to a multiple of a DCT +block in each component: that is, each downsampled row must contain a +multiple of 8 valid samples, and there must be a multiple of 8 sample rows +for each component. (For applications such as conversion of digital TV +images, the standard image size is usually a multiple of the DCT block size, +so that no padding need actually be done.) + +The procedure for compression of raw data is basically the same as normal +compression, except that you call jpeg_write_raw_data() in place of +jpeg_write_scanlines(). Before calling jpeg_start_compress(), you must do +the following: + * Set cinfo->raw_data_in to TRUE. (It is set FALSE by jpeg_set_defaults().) + This notifies the library that you will be supplying raw data. + * Ensure jpeg_color_space is correct --- an explicit jpeg_set_colorspace() + call is a good idea. Note that since color conversion is bypassed, + in_color_space is ignored, except that jpeg_set_defaults() uses it to + choose the default jpeg_color_space setting. + * Ensure the sampling factors, cinfo->comp_info[i].h_samp_factor and + cinfo->comp_info[i].v_samp_factor, are correct. Since these indicate the + dimensions of the data you are supplying, it's wise to set them + explicitly, rather than assuming the library's defaults are what you want. + +To pass raw data to the library, call jpeg_write_raw_data() in place of +jpeg_write_scanlines(). The two routines work similarly except that +jpeg_write_raw_data takes a JSAMPIMAGE data array rather than JSAMPARRAY. +The scanlines count passed to and returned from jpeg_write_raw_data is +measured in terms of the component with the largest v_samp_factor. + +jpeg_write_raw_data() processes one MCU row per call, which is to say +v_samp_factor*DCTSIZE sample rows of each component. The passed num_lines +value must be at least max_v_samp_factor*DCTSIZE, and the return value will +be exactly that amount (or possibly some multiple of that amount, in future +library versions). This is true even on the last call at the bottom of the +image; don't forget to pad your data as necessary. + +The required dimensions of the supplied data can be computed for each +component as + cinfo->comp_info[i].width_in_blocks*DCTSIZE samples per row + cinfo->comp_info[i].height_in_blocks*DCTSIZE rows in image +after jpeg_start_compress() has initialized those fields. If the valid data +is smaller than this, it must be padded appropriately. For some sampling +factors and image sizes, additional dummy DCT blocks are inserted to make +the image a multiple of the MCU dimensions. The library creates such dummy +blocks itself; it does not read them from your supplied data. Therefore you +need never pad by more than DCTSIZE samples. An example may help here. +Assume 2h2v downsampling of YCbCr data, that is + cinfo->comp_info[0].h_samp_factor = 2 for Y + cinfo->comp_info[0].v_samp_factor = 2 + cinfo->comp_info[1].h_samp_factor = 1 for Cb + cinfo->comp_info[1].v_samp_factor = 1 + cinfo->comp_info[2].h_samp_factor = 1 for Cr + cinfo->comp_info[2].v_samp_factor = 1 +and suppose that the nominal image dimensions (cinfo->image_width and +cinfo->image_height) are 101x101 pixels. Then jpeg_start_compress() will +compute downsampled_width = 101 and width_in_blocks = 13 for Y, +downsampled_width = 51 and width_in_blocks = 7 for Cb and Cr (and the same +for the height fields). You must pad the Y data to at least 13*8 = 104 +columns and rows, the Cb/Cr data to at least 7*8 = 56 columns and rows. The +MCU height is max_v_samp_factor = 2 DCT rows so you must pass at least 16 +scanlines on each call to jpeg_write_raw_data(), which is to say 16 actual +sample rows of Y and 8 each of Cb and Cr. A total of 7 MCU rows are needed, +so you must pass a total of 7*16 = 112 "scanlines". The last DCT block row +of Y data is dummy, so it doesn't matter what you pass for it in the data +arrays, but the scanlines count must total up to 112 so that all of the Cb +and Cr data gets passed. + +Output suspension is supported with raw-data compression: if the data +destination module suspends, jpeg_write_raw_data() will return 0. +In this case the same data rows must be passed again on the next call. + + +Decompression with raw data output implies bypassing all postprocessing: +you cannot ask for rescaling or color quantization, for instance. More +seriously, you must deal with the color space and sampling factors present in +the incoming file. If your application only handles, say, 2h1v YCbCr data, +you must check for and fail on other color spaces or other sampling factors. +The library will not convert to a different color space for you. + +To obtain raw data output, set cinfo->raw_data_out = TRUE before +jpeg_start_decompress() (it is set FALSE by jpeg_read_header()). Be sure to +verify that the color space and sampling factors are ones you can handle. +Then call jpeg_read_raw_data() in place of jpeg_read_scanlines(). The +decompression process is otherwise the same as usual. + +jpeg_read_raw_data() returns one MCU row per call, and thus you must pass a +buffer of at least max_v_samp_factor*DCTSIZE scanlines (scanline counting is +the same as for raw-data compression). The buffer you pass must be large +enough to hold the actual data plus padding to DCT-block boundaries. As with +compression, any entirely dummy DCT blocks are not processed so you need not +allocate space for them, but the total scanline count includes them. The +above example of computing buffer dimensions for raw-data compression is +equally valid for decompression. + +Input suspension is supported with raw-data decompression: if the data source +module suspends, jpeg_read_raw_data() will return 0. You can also use +buffered-image mode to read raw data in multiple passes. + + +Really raw data: DCT coefficients +--------------------------------- + +It is possible to read or write the contents of a JPEG file as raw DCT +coefficients. This facility is mainly intended for use in lossless +transcoding between different JPEG file formats. Other possible applications +include lossless cropping of a JPEG image, lossless reassembly of a +multi-strip or multi-tile TIFF/JPEG file into a single JPEG datastream, etc. + +To read the contents of a JPEG file as DCT coefficients, open the file and do +jpeg_read_header() as usual. But instead of calling jpeg_start_decompress() +and jpeg_read_scanlines(), call jpeg_read_coefficients(). This will read the +entire image into a set of virtual coefficient-block arrays, one array per +component. The return value is a pointer to an array of virtual-array +descriptors. Each virtual array can be accessed directly using the JPEG +memory manager's access_virt_barray method (see Memory management, below, +and also read structure.doc's discussion of virtual array handling). Or, +for simple transcoding to a different JPEG file format, the array list can +just be handed directly to jpeg_write_coefficients(). + +When you are done using the virtual arrays, call jpeg_finish_decompress() +to release the array storage and return the decompression object to an idle +state; or just call jpeg_destroy() if you don't need to reuse the object. + +If you use a suspending data source, jpeg_read_coefficients() will return +NULL if it is forced to suspend; a non-NULL return value indicates successful +completion. You need not test for a NULL return value when using a +non-suspending data source. + +Each block in the block arrays contains quantized coefficient values in +normal array order (not JPEG zigzag order). The block arrays contain only +DCT blocks containing real data; any entirely-dummy blocks added to fill out +interleaved MCUs at the right or bottom edges of the image are discarded +during reading and are not stored in the block arrays. (The size of each +block array can be determined from the width_in_blocks and height_in_blocks +fields of the component's comp_info entry.) This is also the data format +expected by jpeg_write_coefficients(). + +To write the contents of a JPEG file as DCT coefficients, you must provide +the DCT coefficients stored in virtual block arrays. You can either pass +block arrays read from an input JPEG file by jpeg_read_coefficients(), or +allocate virtual arrays from the JPEG compression object and fill them +yourself. In either case, jpeg_write_coefficients() is substituted for +jpeg_start_compress() and jpeg_write_scanlines(). Thus the sequence is + * Create compression object + * Set all compression parameters as necessary + * Request virtual arrays if needed + * jpeg_write_coefficients() + * jpeg_finish_compress() + * Destroy or re-use compression object +jpeg_write_coefficients() is passed a pointer to an array of virtual block +array descriptors; the number of arrays is equal to cinfo.num_components. + +The virtual arrays need only have been requested, not realized, before +jpeg_write_coefficients() is called. A side-effect of +jpeg_write_coefficients() is to realize any virtual arrays that have been +requested from the compression object's memory manager. Thus, when obtaining +the virtual arrays from the compression object, you should fill the arrays +after calling jpeg_write_coefficients(). The data is actually written out +when you call jpeg_finish_compress(); jpeg_write_coefficients() only writes +the file header. + +When writing raw DCT coefficients, it is crucial that the JPEG quantization +tables and sampling factors match the way the data was encoded, or the +resulting file will be invalid. For transcoding from an existing JPEG file, +we recommend using jpeg_copy_critical_parameters(). This routine initializes +all the compression parameters to default values (like jpeg_set_defaults()), +then copies the critical information from a source decompression object. +The decompression object should have just been used to read the entire +JPEG input file --- that is, it should be awaiting jpeg_finish_decompress(). + +jpeg_write_coefficients() marks all tables stored in the compression object +as needing to be written to the output file (thus, it acts like +jpeg_start_compress(cinfo, TRUE)). This is for safety's sake, to avoid +emitting abbreviated JPEG files by accident. If you really want to emit an +abbreviated JPEG file, call jpeg_suppress_tables(), or set the tables' +individual sent_table flags, between calling jpeg_write_coefficients() and +jpeg_finish_compress(). + + +Progress monitoring +------------------- + +Some applications may need to regain control from the JPEG library every so +often. The typical use of this feature is to produce a percent-done bar or +other progress display. (For a simple example, see cjpeg.c or djpeg.c.) +Although you do get control back frequently during the data-transferring pass +(the jpeg_read_scanlines or jpeg_write_scanlines loop), any additional passes +will occur inside jpeg_finish_compress or jpeg_start_decompress; those +routines may take a long time to execute, and you don't get control back +until they are done. + +You can define a progress-monitor routine which will be called periodically +by the library. No guarantees are made about how often this call will occur, +so we don't recommend you use it for mouse tracking or anything like that. +At present, a call will occur once per MCU row, scanline, or sample row +group, whichever unit is convenient for the current processing mode; so the +wider the image, the longer the time between calls. During the data +transferring pass, only one call occurs per call of jpeg_read_scanlines or +jpeg_write_scanlines, so don't pass a large number of scanlines at once if +you want fine resolution in the progress count. (If you really need to use +the callback mechanism for time-critical tasks like mouse tracking, you could +insert additional calls inside some of the library's inner loops.) + +To establish a progress-monitor callback, create a struct jpeg_progress_mgr, +fill in its progress_monitor field with a pointer to your callback routine, +and set cinfo->progress to point to the struct. The callback will be called +whenever cinfo->progress is non-NULL. (This pointer is set to NULL by +jpeg_create_compress or jpeg_create_decompress; the library will not change +it thereafter. So if you allocate dynamic storage for the progress struct, +make sure it will live as long as the JPEG object does. Allocating from the +JPEG memory manager with lifetime JPOOL_PERMANENT will work nicely.) You +can use the same callback routine for both compression and decompression. + +The jpeg_progress_mgr struct contains four fields which are set by the library: + long pass_counter; /* work units completed in this pass */ + long pass_limit; /* total number of work units in this pass */ + int completed_passes; /* passes completed so far */ + int total_passes; /* total number of passes expected */ +During any one pass, pass_counter increases from 0 up to (not including) +pass_limit; the step size is usually but not necessarily 1. The pass_limit +value may change from one pass to another. The expected total number of +passes is in total_passes, and the number of passes already completed is in +completed_passes. Thus the fraction of work completed may be estimated as + completed_passes + (pass_counter/pass_limit) + -------------------------------------------- + total_passes +ignoring the fact that the passes may not be equal amounts of work. + +When decompressing, pass_limit can even change within a pass, because it +depends on the number of scans in the JPEG file, which isn't always known in +advance. The computed fraction-of-work-done may jump suddenly (if the library +discovers it has overestimated the number of scans) or even decrease (in the +opposite case). It is not wise to put great faith in the work estimate. + +When using the decompressor's buffered-image mode, the progress monitor work +estimate is likely to be completely unhelpful, because the library has no way +to know how many output passes will be demanded of it. Currently, the library +sets total_passes based on the assumption that there will be one more output +pass if the input file end hasn't yet been read (jpeg_input_complete() isn't +TRUE), but no more output passes if the file end has been reached when the +output pass is started. This means that total_passes will rise as additional +output passes are requested. If you have a way of determining the input file +size, estimating progress based on the fraction of the file that's been read +will probably be more useful than using the library's value. + + +Memory management +----------------- + +This section covers some key facts about the JPEG library's built-in memory +manager. For more info, please read structure.doc's section about the memory +manager, and consult the source code if necessary. + +All memory and temporary file allocation within the library is done via the +memory manager. If necessary, you can replace the "back end" of the memory +manager to control allocation yourself (for example, if you don't want the +library to use malloc() and free() for some reason). + +Some data is allocated "permanently" and will not be freed until the JPEG +object is destroyed. Most data is allocated "per image" and is freed by +jpeg_finish_compress, jpeg_finish_decompress, or jpeg_abort. You can call the +memory manager yourself to allocate structures that will automatically be +freed at these times. Typical code for this is + ptr = (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, size); +Use JPOOL_PERMANENT to get storage that lasts as long as the JPEG object. +Use alloc_large instead of alloc_small for anything bigger than a few Kbytes. +There are also alloc_sarray and alloc_barray routines that automatically +build 2-D sample or block arrays. + +The library's minimum space requirements to process an image depend on the +image's width, but not on its height, because the library ordinarily works +with "strip" buffers that are as wide as the image but just a few rows high. +Some operating modes (eg, two-pass color quantization) require full-image +buffers. Such buffers are treated as "virtual arrays": only the current strip +need be in memory, and the rest can be swapped out to a temporary file. + +If you use the simplest memory manager back end (jmemnobs.c), then no +temporary files are used; virtual arrays are simply malloc()'d. Images bigger +than memory can be processed only if your system supports virtual memory. +The other memory manager back ends support temporary files of various flavors +and thus work in machines without virtual memory. They may also be useful on +Unix machines if you need to process images that exceed available swap space. + +When using temporary files, the library will make the in-memory buffers for +its virtual arrays just big enough to stay within a "maximum memory" setting. +Your application can set this limit by setting cinfo->mem->max_memory_to_use +after creating the JPEG object. (Of course, there is still a minimum size for +the buffers, so the max-memory setting is effective only if it is bigger than +the minimum space needed.) If you allocate any large structures yourself, you +must allocate them before jpeg_start_compress() or jpeg_start_decompress() in +order to have them counted against the max memory limit. Also keep in mind +that space allocated with alloc_small() is ignored, on the assumption that +it's too small to be worth worrying about; so a reasonable safety margin +should be left when setting max_memory_to_use. + +If you use the jmemname.c or jmemdos.c memory manager back end, it is +important to clean up the JPEG object properly to ensure that the temporary +files get deleted. (This is especially crucial with jmemdos.c, where the +"temporary files" may be extended-memory segments; if they are not freed, +DOS will require a reboot to recover the memory.) Thus, with these memory +managers, it's a good idea to provide a signal handler that will trap any +early exit from your program. The handler should call either jpeg_abort() +or jpeg_destroy() for any active JPEG objects. A handler is not needed with +jmemnobs.c, and shouldn't be necessary with jmemansi.c or jmemmac.c either, +since the C library is supposed to take care of deleting files made with +tmpfile(). + + +Library compile-time options +---------------------------- + +A number of compile-time options are available by modifying jmorecfg.h. + +The JPEG standard provides for both the baseline 8-bit DCT process and +a 12-bit DCT process. 12-bit lossy JPEG is supported if you define +BITS_IN_JSAMPLE as 12 rather than 8. Note that this causes JSAMPLE to be +larger than a char, so it affects the surrounding application's image data. +The sample applications cjpeg and djpeg can support 12-bit mode only for PPM +and GIF file formats; you must disable the other file formats to compile a +12-bit cjpeg or djpeg. (install.doc has more information about that.) +At present, a 12-bit library can handle *only* 12-bit images, not both +precisions. (If you need to include both 8- and 12-bit libraries in a single +application, you could probably do it by defining NEED_SHORT_EXTERNAL_NAMES +for just one of the copies. You'd have to access the 8-bit and 12-bit copies +from separate application source files. This is untested ... if you try it, +we'd like to hear whether it works!) + +Note that a 12-bit library always compresses in Huffman optimization mode, +in order to generate valid Huffman tables. This is necessary because our +default Huffman tables only cover 8-bit data. If you need to output 12-bit +files in one pass, you'll have to supply suitable default Huffman tables. + +The maximum number of components (color channels) in the image is determined +by MAX_COMPONENTS. The JPEG standard allows up to 255 components, but we +expect that few applications will need more than four or so. + +On machines with unusual data type sizes, you may be able to improve +performance or reduce memory space by tweaking the various typedefs in +jmorecfg.h. In particular, on some RISC CPUs, access to arrays of "short"s +is quite slow; consider trading memory for speed by making JCOEF, INT16, and +UINT16 be "int" or "unsigned int". UINT8 is also a candidate to become int. +You probably don't want to make JSAMPLE be int unless you have lots of memory +to burn. + +You can reduce the size of the library by compiling out various optional +functions. To do this, undefine xxx_SUPPORTED symbols as necessary. + + +Portability considerations +-------------------------- + +The JPEG library has been written to be extremely portable; the sample +applications cjpeg and djpeg are slightly less so. This section summarizes +the design goals in this area. (If you encounter any bugs that cause the +library to be less portable than is claimed here, we'd appreciate hearing +about them.) + +The code works fine on both ANSI and pre-ANSI C compilers, using any of the +popular system include file setups, and some not-so-popular ones too. See +install.doc for configuration procedures. + +The code is not dependent on the exact sizes of the C data types. As +distributed, we make the assumptions that + char is at least 8 bits wide + short is at least 16 bits wide + int is at least 16 bits wide + long is at least 32 bits wide +(These are the minimum requirements of the ANSI C standard.) Wider types will +work fine, although memory may be used inefficiently if char is much larger +than 8 bits or short is much bigger than 16 bits. The code should work +equally well with 16- or 32-bit ints. + +In a system where these assumptions are not met, you may be able to make the +code work by modifying the typedefs in jmorecfg.h. However, you will probably +have difficulty if int is less than 16 bits wide, since references to plain +int abound in the code. + +char can be either signed or unsigned, although the code runs faster if an +unsigned char type is available. If char is wider than 8 bits, you will need +to redefine JOCTET and/or provide custom data source/destination managers so +that JOCTET represents exactly 8 bits of data on external storage. + +The JPEG library proper does not assume ASCII representation of characters. +But some of the image file I/O modules in cjpeg/djpeg do have ASCII +dependencies in file-header manipulation; so does cjpeg's select_file_type() +routine. + +The JPEG library does not rely heavily on the C library. In particular, C +stdio is used only by the data source/destination modules and the error +handler, all of which are application-replaceable. (cjpeg/djpeg are more +heavily dependent on stdio.) malloc and free are called only from the memory +manager "back end" module, so you can use a different memory allocator by +replacing that one file. + +The code generally assumes that C names must be unique in the first 15 +characters. However, global function names can be made unique in the +first 6 characters by defining NEED_SHORT_EXTERNAL_NAMES. + +More info about porting the code may be gleaned by reading jconfig.doc, +jmorecfg.h, and jinclude.h. + + +Notes for MS-DOS implementors +----------------------------- + +The IJG code is designed to work efficiently in 80x86 "small" or "medium" +memory models (i.e., data pointers are 16 bits unless explicitly declared +"far"; code pointers can be either size). You may be able to use small +model to compile cjpeg or djpeg by itself, but you will probably have to use +medium model for any larger application. This won't make much difference in +performance. You *will* take a noticeable performance hit if you use a +large-data memory model (perhaps 10%-25%), and you should avoid "huge" model +if at all possible. + +The JPEG library typically needs 2Kb-3Kb of stack space. It will also +malloc about 20K-30K of near heap space while executing (and lots of far +heap, but that doesn't count in this calculation). This figure will vary +depending on selected operating mode, and to a lesser extent on image size. +There is also about 5Kb-6Kb of constant data which will be allocated in the +near data segment (about 4Kb of this is the error message table). +Thus you have perhaps 20K available for other modules' static data and near +heap space before you need to go to a larger memory model. The C library's +static data will account for several K of this, but that still leaves a good +deal for your needs. (If you are tight on space, you could reduce the sizes +of the I/O buffers allocated by jdatasrc.c and jdatadst.c, say from 4K to +1K. Another possibility is to move the error message table to far memory; +this should be doable with only localized hacking on jerror.c.) + +About 2K of the near heap space is "permanent" memory that will not be +released until you destroy the JPEG object. This is only an issue if you +save a JPEG object between compression or decompression operations. + +Far data space may also be a tight resource when you are dealing with large +images. The most memory-intensive case is decompression with two-pass color +quantization, or single-pass quantization to an externally supplied color +map. This requires a 128Kb color lookup table plus strip buffers amounting +to about 50 bytes per column for typical sampling ratios (eg, about 32000 +bytes for a 640-pixel-wide image). You may not be able to process wide +images if you have large data structures of your own. + +Of course, all of these concerns vanish if you use a 32-bit flat-memory-model +compiler, such as DJGPP or Watcom C. We highly recommend flat model if you +can use it; the JPEG library is significantly faster in flat model. diff --git a/gs/jpeg/makcjpeg.st b/gs/jpeg/makcjpeg.st new file mode 100644 index 000000000..3b523dbd2 --- /dev/null +++ b/gs/jpeg/makcjpeg.st @@ -0,0 +1,37 @@ +; Project file for Independent JPEG Group's software +; +; This project file is for Atari ST/STE/TT systems using Pure C or Turbo C. +; Thanks to Frank Moehle (Frank.Moehle@arbi.informatik.uni-oldenburg.de) +; and to Dr. B. Setzepfandt (bernd@gina.uni-muenster.de). +; +; To use this file, rename it to CJPEG.PRJ. +; If you are using Turbo C, change filenames beginning with "PC..." to "TC..." +; Read installation instructions before trying to make the program! +; +; +; * * * Output file * * * +cjpeg.ttp +; +; * * * COMPILER OPTIONS * * * +.C[-P] ; absolute calls +.C[-M] ; and no string merging, folks +.C[-w-cln] ; no "constant is long" warnings +.C[-w-par] ; no "parameter xxxx unused" +.C[-w-rch] ; no "unreachable code" +.C[-wsig] ; warn if significant digits may be lost += +; * * * * List of modules * * * * +PCSTART.O +cjpeg.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h,jversion.h) +cdjpeg.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +rdswitch.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +rdppm.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +rdgif.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +rdtarga.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +rdbmp.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +rdrle.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +LIBJPEG.LIB ; built by LIBJPEG.PRJ +PCFLTLIB.LIB ; floating point library +; the float library can be omitted if you've turned off DCT_FLOAT_SUPPORTED +PCSTDLIB.LIB ; standard library +PCEXTLIB.LIB ; extended library diff --git a/gs/jpeg/makdjpeg.st b/gs/jpeg/makdjpeg.st new file mode 100644 index 000000000..49d23eacc --- /dev/null +++ b/gs/jpeg/makdjpeg.st @@ -0,0 +1,37 @@ +; Project file for Independent JPEG Group's software +; +; This project file is for Atari ST/STE/TT systems using Pure C or Turbo C. +; Thanks to Frank Moehle (Frank.Moehle@arbi.informatik.uni-oldenburg.de) +; and to Dr. B. Setzepfandt (bernd@gina.uni-muenster.de). +; +; To use this file, rename it to DJPEG.PRJ. +; If you are using Turbo C, change filenames beginning with "PC..." to "TC..." +; Read installation instructions before trying to make the program! +; +; +; * * * Output file * * * +djpeg.ttp +; +; * * * COMPILER OPTIONS * * * +.C[-P] ; absolute calls +.C[-M] ; and no string merging, folks +.C[-w-cln] ; no "constant is long" warnings +.C[-w-par] ; no "parameter xxxx unused" +.C[-w-rch] ; no "unreachable code" +.C[-wsig] ; warn if significant digits may be lost += +; * * * * List of modules * * * * +PCSTART.O +djpeg.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h,jversion.h) +cdjpeg.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +rdcolmap.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +wrppm.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +wrgif.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +wrtarga.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +wrbmp.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +wrrle.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +LIBJPEG.LIB ; built by LIBJPEG.PRJ +PCFLTLIB.LIB ; floating point library +; the float library can be omitted if you've turned off DCT_FLOAT_SUPPORTED +PCSTDLIB.LIB ; standard library +PCEXTLIB.LIB ; extended library diff --git a/gs/jpeg/makefile.ansi b/gs/jpeg/makefile.ansi new file mode 100644 index 000000000..8175ca0e7 --- /dev/null +++ b/gs/jpeg/makefile.ansi @@ -0,0 +1,210 @@ +# Makefile for Independent JPEG Group's software + +# This makefile is suitable for Unix-like systems with ANSI-capable compilers. +# If you have a non-ANSI compiler, makefile.unix is a better starting point. + +# Read installation instructions before saying "make" !! + +# The name of your C compiler: +CC= cc + +# You may need to adjust these cc options: +CFLAGS= -O +# Generally, we recommend defining any configuration symbols in jconfig.h, +# NOT via -D switches here. + +# Link-time cc options: +LDFLAGS= + +# To link any special libraries, add the necessary -l commands here. +LDLIBS= + +# Put here the object file name for the correct system-dependent memory +# manager file. For Unix this is usually jmemnobs.o, but you may want +# to use jmemansi.o or jmemname.o if you have limited swap space. +SYSDEPMEM= jmemnobs.o + +# miscellaneous OS-dependent stuff +# linker +LN= $(CC) +# file deletion command +RM= rm -f +# library (.a) file creation command +AR= ar rc +# second step in .a creation (use "touch" if not needed) +AR2= ranlib + +# End of configurable options. + + +# source files: JPEG library proper +LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ + jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ + jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ + jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ + jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ + jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ + jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ + jquant2.c jutils.c jmemmgr.c +# memmgr back ends: compile only one of these into a working library +SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c +# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom +APPSOURCES= cjpeg.c djpeg.c jpegtran.c cdjpeg.c rdcolmap.c rdswitch.c \ + rdjpgcom.c wrjpgcom.c rdppm.c wrppm.c rdgif.c wrgif.c rdtarga.c \ + wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c +SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) +# files included by source files +INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ + jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h +# documentation, test, and support files +DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ + wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ + coderules.doc filelist.doc change.log +MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ + makefile.mc6 makefile.dj makefile.wat makcjpeg.st makdjpeg.st \ + makljpeg.st maktjpeg.st makefile.manx makefile.sas makefile.mms \ + makefile.vms makvms.opt +CONFIGFILES= jconfig.cfg jconfig.manx jconfig.sas jconfig.st jconfig.bcc \ + jconfig.mc6 jconfig.dj jconfig.wat jconfig.vms +OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm +TESTFILES= testorig.jpg testimg.ppm testimg.gif testimg.jpg testprog.jpg \ + testimgp.jpg +DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ + $(OTHERFILES) $(TESTFILES) +# library object files common to compression and decompression +COMOBJECTS= jcomapi.o jutils.o jerror.o jmemmgr.o $(SYSDEPMEM) +# compression library object files +CLIBOBJECTS= jcapimin.o jcapistd.o jctrans.o jcparam.o jdatadst.o jcinit.o \ + jcmaster.o jcmarker.o jcmainct.o jcprepct.o jccoefct.o jccolor.o \ + jcsample.o jchuff.o jcphuff.o jcdctmgr.o jfdctfst.o jfdctflt.o \ + jfdctint.o +# decompression library object files +DLIBOBJECTS= jdapimin.o jdapistd.o jdtrans.o jdatasrc.o jdmaster.o \ + jdinput.o jdmarker.o jdhuff.o jdphuff.o jdmainct.o jdcoefct.o \ + jdpostct.o jddctmgr.o jidctfst.o jidctflt.o jidctint.o jidctred.o \ + jdsample.o jdcolor.o jquant1.o jquant2.o jdmerge.o +# These objectfiles are included in libjpeg.a +LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) +# object files for sample applications (excluding library files) +COBJECTS= cjpeg.o rdppm.o rdgif.o rdtarga.o rdrle.o rdbmp.o rdswitch.o \ + cdjpeg.o +DOBJECTS= djpeg.o wrppm.o wrgif.o wrtarga.o wrrle.o wrbmp.o rdcolmap.o \ + cdjpeg.o +TROBJECTS= jpegtran.o rdswitch.o cdjpeg.o + + +all: libjpeg.a cjpeg djpeg jpegtran rdjpgcom wrjpgcom + +libjpeg.a: $(LIBOBJECTS) + $(RM) libjpeg.a + $(AR) libjpeg.a $(LIBOBJECTS) + $(AR2) libjpeg.a + +cjpeg: $(COBJECTS) libjpeg.a + $(LN) $(LDFLAGS) -o cjpeg $(COBJECTS) libjpeg.a $(LDLIBS) + +djpeg: $(DOBJECTS) libjpeg.a + $(LN) $(LDFLAGS) -o djpeg $(DOBJECTS) libjpeg.a $(LDLIBS) + +jpegtran: $(TROBJECTS) libjpeg.a + $(LN) $(LDFLAGS) -o jpegtran $(TROBJECTS) libjpeg.a $(LDLIBS) + +rdjpgcom: rdjpgcom.o + $(LN) $(LDFLAGS) -o rdjpgcom rdjpgcom.o $(LDLIBS) + +wrjpgcom: wrjpgcom.o + $(LN) $(LDFLAGS) -o wrjpgcom wrjpgcom.o $(LDLIBS) + +jconfig.h: jconfig.doc + echo You must prepare a system-dependent jconfig.h file. + echo Please read the installation directions in install.doc. + exit 1 + +clean: + $(RM) *.o cjpeg djpeg jpegtran libjpeg.a rdjpgcom wrjpgcom + $(RM) core testout* + +test: cjpeg djpeg jpegtran + $(RM) testout* + ./djpeg -dct int -ppm -outfile testout.ppm testorig.jpg + ./djpeg -dct int -gif -outfile testout.gif testorig.jpg + ./cjpeg -dct int -outfile testout.jpg testimg.ppm + ./djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg + ./cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm + ./jpegtran -outfile testoutt.jpg testprog.jpg + cmp testimg.ppm testout.ppm + cmp testimg.gif testout.gif + cmp testimg.jpg testout.jpg + cmp testimg.ppm testoutp.ppm + cmp testimgp.jpg testoutp.jpg + cmp testorig.jpg testoutt.jpg + + +jcapimin.o: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapistd.o: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccoefct.o: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccolor.o: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcdctmgr.o: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jchuff.o: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcinit.o: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmainct.o: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmarker.o: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmaster.o: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcomapi.o: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcparam.o: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcphuff.o: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcprepct.o: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcsample.o: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jctrans.o: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapimin.o: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapistd.o: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdatadst.o: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdatasrc.o: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdcoefct.o: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdcolor.o: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jddctmgr.o: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jdhuff.o: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdinput.o: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmainct.o: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmarker.o: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmaster.o: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmerge.o: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdphuff.o: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdpostct.o: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdsample.o: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdtrans.o: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jerror.o: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h +jfdctflt.o: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctfst.o: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctint.o: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctflt.o: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctfst.o: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctint.o: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctred.o: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jquant1.o: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jquant2.o: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jutils.o: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jmemmgr.o: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemansi.o: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemname.o: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemnobs.o: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemdos.o: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemmac.o: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +cjpeg.o: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +djpeg.o: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +jpegtran.o: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +cdjpeg.o: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdcolmap.o: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdswitch.o: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdjpgcom.o: rdjpgcom.c jinclude.h jconfig.h +wrjpgcom.o: wrjpgcom.c jinclude.h jconfig.h +rdppm.o: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrppm.o: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdgif.o: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrgif.o: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdtarga.o: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrtarga.o: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdbmp.o: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrbmp.o: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdrle.o: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrrle.o: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/gs/jpeg/makefile.bcc b/gs/jpeg/makefile.bcc new file mode 100644 index 000000000..4f20bea60 --- /dev/null +++ b/gs/jpeg/makefile.bcc @@ -0,0 +1,279 @@ +# Makefile for Independent JPEG Group's software + +# This makefile is suitable for Borland C on MS-DOS or OS/2. +# It works with Borland C++ for DOS, revision 3.0 or later, +# and has been tested with Borland C++ for OS/2, revision 2.0. +# Thanks to Tom Wright and Ge' Weijers (original DOS) and +# Ken Porter (OS/2) for this file. + +# Read installation instructions before saying "make" !! + +# Are we under DOS or OS/2? +!if !$d(DOS) && !$d(OS2) +!if $d(__OS2__) +OS2=1 +!else +DOS=1 +!endif +!endif + +# The name of your C compiler: +CC= bcc + +# You may need to adjust these cc options: +!if $d(DOS) +CFLAGS= -O2 -mm -w-par -w-stu -w-ccc -w-rch +!else +CFLAGS= -O1 -w-par -w-stu -w-ccc -w-rch +!endif +# -O2 enables full code optimization (for pre-3.0 Borland C++, use -O -G -Z). +# -O2 is buggy in Borland OS/2 C++ revision 2.0, so use -O1 for now. +# -mm selects medium memory model (near data, far code pointers; DOS only!) +# -w-par suppresses warnings about unused function parameters +# -w-stu suppresses warnings about incomplete structures +# -w-ccc suppresses warnings about compile-time-constant conditions +# -w-rch suppresses warnings about unreachable code +# Generally, we recommend defining any configuration symbols in jconfig.h, +# NOT via -D switches here. + +# Link-time cc options: +!if $d(DOS) +LDFLAGS= -mm +# memory model option here must match CFLAGS! +!else +LDFLAGS= +# -lai full-screen app +# -lc case-significant link +!endif + +# Put here the object file name for the correct system-dependent memory +# manager file. +# For DOS, we recommend jmemdos.c and jmemdosa.asm. +# For OS/2, we recommend jmemnobs.c (flat memory!) +# SYSDEPMEMLIB must list the same files with "+" signs for the librarian. +!if $d(DOS) +SYSDEPMEM= jmemdos.obj jmemdosa.obj +SYSDEPMEMLIB= +jmemdos.obj +jmemdosa.obj +!else +SYSDEPMEM= jmemnobs.obj +SYSDEPMEMLIB= +jmemnobs.obj +!endif + +# End of configurable options. + + +# source files: JPEG library proper +LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ + jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ + jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ + jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ + jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ + jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ + jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ + jquant2.c jutils.c jmemmgr.c +# memmgr back ends: compile only one of these into a working library +SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c +# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom +APPSOURCES= cjpeg.c djpeg.c jpegtran.c cdjpeg.c rdcolmap.c rdswitch.c \ + rdjpgcom.c wrjpgcom.c rdppm.c wrppm.c rdgif.c wrgif.c rdtarga.c \ + wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c +SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) +# files included by source files +INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ + jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h +# documentation, test, and support files +DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ + wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ + coderules.doc filelist.doc change.log +MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ + makefile.mc6 makefile.dj makefile.wat makcjpeg.st makdjpeg.st \ + makljpeg.st maktjpeg.st makefile.manx makefile.sas makefile.mms \ + makefile.vms makvms.opt +CONFIGFILES= jconfig.cfg jconfig.manx jconfig.sas jconfig.st jconfig.bcc \ + jconfig.mc6 jconfig.dj jconfig.wat jconfig.vms +OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm +TESTFILES= testorig.jpg testimg.ppm testimg.gif testimg.jpg testprog.jpg \ + testimgp.jpg +DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ + $(OTHERFILES) $(TESTFILES) +# library object files common to compression and decompression +COMOBJECTS= jcomapi.obj jutils.obj jerror.obj jmemmgr.obj $(SYSDEPMEM) +# compression library object files +CLIBOBJECTS= jcapimin.obj jcapistd.obj jctrans.obj jcparam.obj jdatadst.obj \ + jcinit.obj jcmaster.obj jcmarker.obj jcmainct.obj jcprepct.obj \ + jccoefct.obj jccolor.obj jcsample.obj jchuff.obj jcphuff.obj \ + jcdctmgr.obj jfdctfst.obj jfdctflt.obj jfdctint.obj +# decompression library object files +DLIBOBJECTS= jdapimin.obj jdapistd.obj jdtrans.obj jdatasrc.obj \ + jdmaster.obj jdinput.obj jdmarker.obj jdhuff.obj jdphuff.obj \ + jdmainct.obj jdcoefct.obj jdpostct.obj jddctmgr.obj jidctfst.obj \ + jidctflt.obj jidctint.obj jidctred.obj jdsample.obj jdcolor.obj \ + jquant1.obj jquant2.obj jdmerge.obj +# These objectfiles are included in libjpeg.lib +LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) +# object files for sample applications (excluding library files) +COBJECTS= cjpeg.obj rdppm.obj rdgif.obj rdtarga.obj rdrle.obj rdbmp.obj \ + rdswitch.obj cdjpeg.obj +DOBJECTS= djpeg.obj wrppm.obj wrgif.obj wrtarga.obj wrrle.obj wrbmp.obj \ + rdcolmap.obj cdjpeg.obj +TROBJECTS= jpegtran.obj rdswitch.obj cdjpeg.obj + + +all: libjpeg.lib cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe + +libjpeg.lib: $(LIBOBJECTS) + - del libjpeg.lib + tlib libjpeg.lib /E /C @&&| ++jcapimin.obj +jcapistd.obj +jctrans.obj +jcparam.obj +jdatadst.obj & ++jcinit.obj +jcmaster.obj +jcmarker.obj +jcmainct.obj +jcprepct.obj & ++jccoefct.obj +jccolor.obj +jcsample.obj +jchuff.obj +jcphuff.obj & ++jcdctmgr.obj +jfdctfst.obj +jfdctflt.obj +jfdctint.obj +jdapimin.obj & ++jdapistd.obj +jdtrans.obj +jdatasrc.obj +jdmaster.obj +jdinput.obj & ++jdmarker.obj +jdhuff.obj +jdphuff.obj +jdmainct.obj +jdcoefct.obj & ++jdpostct.obj +jddctmgr.obj +jidctfst.obj +jidctflt.obj +jidctint.obj & ++jidctred.obj +jdsample.obj +jdcolor.obj +jquant1.obj +jquant2.obj & ++jdmerge.obj +jcomapi.obj +jutils.obj +jerror.obj +jmemmgr.obj & +$(SYSDEPMEMLIB) +| + +cjpeg.exe: $(COBJECTS) libjpeg.lib + $(CC) $(LDFLAGS) -ecjpeg.exe $(COBJECTS) libjpeg.lib + +djpeg.exe: $(DOBJECTS) libjpeg.lib + $(CC) $(LDFLAGS) -edjpeg.exe $(DOBJECTS) libjpeg.lib + +jpegtran.exe: $(TROBJECTS) libjpeg.lib + $(CC) $(LDFLAGS) -ejpegtran.exe $(TROBJECTS) libjpeg.lib + +rdjpgcom.exe: rdjpgcom.c +!if $d(DOS) + $(CC) -ms -O rdjpgcom.c +!else + $(CC) $(CFLAGS) rdjpgcom.c +!endif + +# On DOS, wrjpgcom needs large model so it can malloc a 64K chunk +wrjpgcom.exe: wrjpgcom.c +!if $d(DOS) + $(CC) -ml -O wrjpgcom.c +!else + $(CC) $(CFLAGS) wrjpgcom.c +!endif + +# This "{}" syntax allows Borland Make to "batch" source files. +# In this way, each run of the compiler can build many modules. +.c.obj: + $(CC) $(CFLAGS) -c{ $<} + +jconfig.h: jconfig.doc + echo You must prepare a system-dependent jconfig.h file. + echo Please read the installation directions in install.doc. + exit 1 + +clean: + - del *.obj + - del libjpeg.lib + - del cjpeg.exe + - del djpeg.exe + - del jpegtran.exe + - del rdjpgcom.exe + - del wrjpgcom.exe + - del testout*.* + +test: cjpeg.exe djpeg.exe jpegtran.exe + - del testout*.* + djpeg -dct int -ppm -outfile testout.ppm testorig.jpg + djpeg -dct int -gif -outfile testout.gif testorig.jpg + cjpeg -dct int -outfile testout.jpg testimg.ppm + djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg + cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm + jpegtran -outfile testoutt.jpg testprog.jpg +!if $d(DOS) + fc /b testimg.ppm testout.ppm + fc /b testimg.gif testout.gif + fc /b testimg.jpg testout.jpg + fc /b testimg.ppm testoutp.ppm + fc /b testimgp.jpg testoutp.jpg + fc /b testorig.jpg testoutt.jpg +!else + echo n > n.tmp + comp testimg.ppm testout.ppm < n.tmp + comp testimg.gif testout.gif < n.tmp + comp testimg.jpg testout.jpg < n.tmp + comp testimg.ppm testoutp.ppm < n.tmp + comp testimgp.jpg testoutp.jpg < n.tmp + comp testorig.jpg testoutt.jpg < n.tmp + del n.tmp +!endif + + +jcapimin.obj: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapistd.obj: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccoefct.obj: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccolor.obj: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcdctmgr.obj: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jchuff.obj: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcinit.obj: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmainct.obj: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmarker.obj: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmaster.obj: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcomapi.obj: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcparam.obj: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcphuff.obj: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcprepct.obj: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcsample.obj: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jctrans.obj: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapimin.obj: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapistd.obj: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdatadst.obj: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdatasrc.obj: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdcoefct.obj: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdcolor.obj: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jddctmgr.obj: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jdhuff.obj: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdinput.obj: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmainct.obj: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmarker.obj: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmaster.obj: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmerge.obj: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdphuff.obj: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdpostct.obj: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdsample.obj: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdtrans.obj: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jerror.obj: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h +jfdctflt.obj: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctfst.obj: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctint.obj: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctflt.obj: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctfst.obj: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctint.obj: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctred.obj: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jquant1.obj: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jquant2.obj: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jutils.obj: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jmemmgr.obj: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemansi.obj: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemname.obj: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemnobs.obj: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemdos.obj: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemmac.obj: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +cjpeg.obj: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +djpeg.obj: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +jpegtran.obj: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +cdjpeg.obj: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdcolmap.obj: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdswitch.obj: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdjpgcom.obj: rdjpgcom.c jinclude.h jconfig.h +wrjpgcom.obj: wrjpgcom.c jinclude.h jconfig.h +rdppm.obj: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrppm.obj: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdgif.obj: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrgif.obj: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdtarga.obj: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrtarga.obj: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdbmp.obj: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrbmp.obj: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdrle.obj: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrrle.obj: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +jmemdosa.obj: jmemdosa.asm + tasm /mx jmemdosa.asm diff --git a/gs/jpeg/makefile.cfg b/gs/jpeg/makefile.cfg new file mode 100644 index 000000000..d3241c6e5 --- /dev/null +++ b/gs/jpeg/makefile.cfg @@ -0,0 +1,274 @@ +# Makefile for Independent JPEG Group's software + +# makefile.cfg is edited by configure to produce a custom Makefile. + +# Read installation instructions before saying "make" !! + +# For compiling with source and object files in different directories. +srcdir = @srcdir@ +VPATH = @srcdir@ + +# Where to install the programs and man pages. +prefix = @prefix@ +exec_prefix = @exec_prefix@ +bindir = $(exec_prefix)/bin +libdir = $(exec_prefix)/lib +includedir = $(prefix)/include +binprefix = +manprefix = +manext = 1 +mandir = $(prefix)/man/man$(manext) + +# The name of your C compiler: +CC= @CC@ + +# You may need to adjust these cc options: +CFLAGS= @CFLAGS@ @CPPFLAGS@ @INCLUDEFLAGS@ +# Generally, we recommend defining any configuration symbols in jconfig.h, +# NOT via -D switches here. +# However, any special defines for ansi2knr.c may be included here: +ANSI2KNRFLAGS= @ANSI2KNRFLAGS@ + +# Link-time cc options: +LDFLAGS= @LDFLAGS@ + +# To link any special libraries, add the necessary -l commands here. +LDLIBS= @LIBS@ + +# Put here the object file name for the correct system-dependent memory +# manager file. For Unix this is usually jmemnobs.o, but you may want +# to use jmemansi.o or jmemname.o if you have limited swap space. +SYSDEPMEM= @MEMORYMGR@ + +# miscellaneous OS-dependent stuff +SHELL= /bin/sh +# linker +LN= $(CC) +# file deletion command +RM= rm -f +# file rename command +MV= mv +# library (.a) file creation command +AR= ar rc +# second step in .a creation (use "touch" if not needed) +AR2= @RANLIB@ +# installation program +INSTALL= @INSTALL@ +INSTALL_PROGRAM= @INSTALL_PROGRAM@ +INSTALL_DATA= @INSTALL_DATA@ + +# End of configurable options. + + +# source files: JPEG library proper +LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ + jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ + jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ + jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ + jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ + jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ + jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ + jquant2.c jutils.c jmemmgr.c +# memmgr back ends: compile only one of these into a working library +SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c +# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom +APPSOURCES= cjpeg.c djpeg.c jpegtran.c cdjpeg.c rdcolmap.c rdswitch.c \ + rdjpgcom.c wrjpgcom.c rdppm.c wrppm.c rdgif.c wrgif.c rdtarga.c \ + wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c +SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) +# files included by source files +INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ + jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h +# documentation, test, and support files +DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ + wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ + coderules.doc filelist.doc change.log +MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ + makefile.mc6 makefile.dj makefile.wat makcjpeg.st makdjpeg.st \ + makljpeg.st maktjpeg.st makefile.manx makefile.sas makefile.mms \ + makefile.vms makvms.opt +CONFIGFILES= jconfig.cfg jconfig.manx jconfig.sas jconfig.st jconfig.bcc \ + jconfig.mc6 jconfig.dj jconfig.wat jconfig.vms +OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm +TESTFILES= testorig.jpg testimg.ppm testimg.gif testimg.jpg testprog.jpg \ + testimgp.jpg +DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ + $(OTHERFILES) $(TESTFILES) +# library object files common to compression and decompression +COMOBJECTS= jcomapi.o jutils.o jerror.o jmemmgr.o $(SYSDEPMEM) +# compression library object files +CLIBOBJECTS= jcapimin.o jcapistd.o jctrans.o jcparam.o jdatadst.o jcinit.o \ + jcmaster.o jcmarker.o jcmainct.o jcprepct.o jccoefct.o jccolor.o \ + jcsample.o jchuff.o jcphuff.o jcdctmgr.o jfdctfst.o jfdctflt.o \ + jfdctint.o +# decompression library object files +DLIBOBJECTS= jdapimin.o jdapistd.o jdtrans.o jdatasrc.o jdmaster.o \ + jdinput.o jdmarker.o jdhuff.o jdphuff.o jdmainct.o jdcoefct.o \ + jdpostct.o jddctmgr.o jidctfst.o jidctflt.o jidctint.o jidctred.o \ + jdsample.o jdcolor.o jquant1.o jquant2.o jdmerge.o +# These objectfiles are included in libjpeg.a +LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) +# object files for sample applications (excluding library files) +COBJECTS= cjpeg.o rdppm.o rdgif.o rdtarga.o rdrle.o rdbmp.o rdswitch.o \ + cdjpeg.o +DOBJECTS= djpeg.o wrppm.o wrgif.o wrtarga.o wrrle.o wrbmp.o rdcolmap.o \ + cdjpeg.o +TROBJECTS= jpegtran.o rdswitch.o cdjpeg.o + + +all: @ANSI2KNR@ libjpeg.a cjpeg djpeg jpegtran rdjpgcom wrjpgcom + +# This rule causes ansi2knr to be invoked. +@ISANSICOM@.c.o: +@ISANSICOM@ ./ansi2knr $(srcdir)/$*.c T$*.c +@ISANSICOM@ $(CC) $(CFLAGS) -c T$*.c +@ISANSICOM@ $(RM) T$*.c $*.o +@ISANSICOM@ $(MV) T$*.o $*.o + +ansi2knr: ansi2knr.c + $(CC) $(CFLAGS) $(ANSI2KNRFLAGS) -o ansi2knr ansi2knr.c + +libjpeg.a: @ANSI2KNR@ $(LIBOBJECTS) + $(RM) libjpeg.a + $(AR) libjpeg.a $(LIBOBJECTS) + $(AR2) libjpeg.a + +cjpeg: $(COBJECTS) libjpeg.a + $(LN) $(LDFLAGS) -o cjpeg $(COBJECTS) libjpeg.a $(LDLIBS) + +djpeg: $(DOBJECTS) libjpeg.a + $(LN) $(LDFLAGS) -o djpeg $(DOBJECTS) libjpeg.a $(LDLIBS) + +jpegtran: $(TROBJECTS) libjpeg.a + $(LN) $(LDFLAGS) -o jpegtran $(TROBJECTS) libjpeg.a $(LDLIBS) + +rdjpgcom: rdjpgcom.o + $(LN) $(LDFLAGS) -o rdjpgcom rdjpgcom.o $(LDLIBS) + +wrjpgcom: wrjpgcom.o + $(LN) $(LDFLAGS) -o wrjpgcom wrjpgcom.o $(LDLIBS) + +jconfig.h: jconfig.doc + echo You must prepare a system-dependent jconfig.h file. + echo Please read the installation directions in install.doc. + exit 1 + +install: cjpeg djpeg jpegtran rdjpgcom wrjpgcom + $(INSTALL_PROGRAM) cjpeg $(bindir)/$(binprefix)cjpeg + $(INSTALL_PROGRAM) djpeg $(bindir)/$(binprefix)djpeg + $(INSTALL_PROGRAM) jpegtran $(bindir)/$(binprefix)jpegtran + $(INSTALL_PROGRAM) rdjpgcom $(bindir)/$(binprefix)rdjpgcom + $(INSTALL_PROGRAM) wrjpgcom $(bindir)/$(binprefix)wrjpgcom + $(INSTALL_DATA) $(srcdir)/cjpeg.1 $(mandir)/$(manprefix)cjpeg.$(manext) + $(INSTALL_DATA) $(srcdir)/djpeg.1 $(mandir)/$(manprefix)djpeg.$(manext) + $(INSTALL_DATA) $(srcdir)/jpegtran.1 $(mandir)/$(manprefix)jpegtran.$(manext) + $(INSTALL_DATA) $(srcdir)/rdjpgcom.1 $(mandir)/$(manprefix)rdjpgcom.$(manext) + $(INSTALL_DATA) $(srcdir)/wrjpgcom.1 $(mandir)/$(manprefix)wrjpgcom.$(manext) + +install-lib: libjpeg.a install-headers + $(INSTALL_DATA) libjpeg.a $(libdir)/$(binprefix)libjpeg.a + +install-headers: jconfig.h + $(INSTALL_DATA) jconfig.h $(includedir)/jconfig.h + $(INSTALL_DATA) $(srcdir)/jpeglib.h $(includedir)/jpeglib.h + $(INSTALL_DATA) $(srcdir)/jmorecfg.h $(includedir)/jmorecfg.h + $(INSTALL_DATA) $(srcdir)/jerror.h $(includedir)/jerror.h + +clean: + $(RM) *.o cjpeg djpeg jpegtran libjpeg.a rdjpgcom wrjpgcom + $(RM) ansi2knr core testout* config.log config.status + +distribute: + $(RM) jpegsrc.tar* + tar cvf jpegsrc.tar $(DISTFILES) + compress -v jpegsrc.tar + +test: cjpeg djpeg jpegtran + $(RM) testout* + ./djpeg -dct int -ppm -outfile testout.ppm $(srcdir)/testorig.jpg + ./djpeg -dct int -gif -outfile testout.gif $(srcdir)/testorig.jpg + ./cjpeg -dct int -outfile testout.jpg $(srcdir)/testimg.ppm + ./djpeg -dct int -ppm -outfile testoutp.ppm $(srcdir)/testprog.jpg + ./cjpeg -dct int -progressive -opt -outfile testoutp.jpg $(srcdir)/testimg.ppm + ./jpegtran -outfile testoutt.jpg $(srcdir)/testprog.jpg + cmp $(srcdir)/testimg.ppm testout.ppm + cmp $(srcdir)/testimg.gif testout.gif + cmp $(srcdir)/testimg.jpg testout.jpg + cmp $(srcdir)/testimg.ppm testoutp.ppm + cmp $(srcdir)/testimgp.jpg testoutp.jpg + cmp $(srcdir)/testorig.jpg testoutt.jpg + +check: test + +# GNU Make likes to know which target names are not really files to be made: +.PHONY: all install install-lib install-headers clean distribute test check + + +jcapimin.o: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapistd.o: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccoefct.o: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccolor.o: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcdctmgr.o: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jchuff.o: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcinit.o: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmainct.o: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmarker.o: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmaster.o: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcomapi.o: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcparam.o: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcphuff.o: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcprepct.o: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcsample.o: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jctrans.o: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapimin.o: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapistd.o: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdatadst.o: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdatasrc.o: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdcoefct.o: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdcolor.o: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jddctmgr.o: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jdhuff.o: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdinput.o: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmainct.o: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmarker.o: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmaster.o: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmerge.o: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdphuff.o: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdpostct.o: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdsample.o: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdtrans.o: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jerror.o: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h +jfdctflt.o: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctfst.o: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctint.o: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctflt.o: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctfst.o: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctint.o: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctred.o: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jquant1.o: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jquant2.o: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jutils.o: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jmemmgr.o: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemansi.o: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemname.o: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemnobs.o: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemdos.o: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemmac.o: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +cjpeg.o: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +djpeg.o: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +jpegtran.o: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +cdjpeg.o: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdcolmap.o: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdswitch.o: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdjpgcom.o: rdjpgcom.c jinclude.h jconfig.h +wrjpgcom.o: wrjpgcom.c jinclude.h jconfig.h +rdppm.o: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrppm.o: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdgif.o: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrgif.o: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdtarga.o: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrtarga.o: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdbmp.o: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrbmp.o: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdrle.o: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrrle.o: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/gs/jpeg/makefile.dj b/gs/jpeg/makefile.dj new file mode 100644 index 000000000..811fd7d51 --- /dev/null +++ b/gs/jpeg/makefile.dj @@ -0,0 +1,234 @@ +# Makefile for Independent JPEG Group's software + +# This makefile is for DJGPP (Delorie's GNU C port) on MS-DOS. +# Say "make exe" to get stub-style .exe's, or +# "make standalone" to get standalone .exe's. + +# Read installation instructions before saying "make" !! + +# To do "make standalone", you'll need to be sure this points to go32.exe: +GO32= c:/djgpp/bin/go32.exe + +# The name of your C compiler: +CC= gcc + +# You may need to adjust these cc options: +CFLAGS= -O2 -Wall +# Generally, we recommend defining any configuration symbols in jconfig.h, +# NOT via -D switches here. + +# Link-time cc options: +LDFLAGS= + +# To link any special libraries, add the necessary -l commands here. +LDLIBS= + +# Put here the object file name for the correct system-dependent memory +# manager file. For DJGPP this is usually jmemnobs.o, but you could +# use jmemname.o if you want to use named temp files instead of swap space. +SYSDEPMEM= jmemnobs.o + +# miscellaneous OS-dependent stuff +# linker +LN= $(CC) +# file deletion command +RM= del +# library (.a) file creation command +AR= ar rc +# second step in .a creation (use "touch" if not needed) +AR2= ranlib + +# End of configurable options. + + +# source files: JPEG library proper +LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ + jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ + jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ + jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ + jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ + jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ + jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ + jquant2.c jutils.c jmemmgr.c +# memmgr back ends: compile only one of these into a working library +SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c +# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom +APPSOURCES= cjpeg.c djpeg.c jpegtran.c cdjpeg.c rdcolmap.c rdswitch.c \ + rdjpgcom.c wrjpgcom.c rdppm.c wrppm.c rdgif.c wrgif.c rdtarga.c \ + wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c +SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) +# files included by source files +INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ + jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h +# documentation, test, and support files +DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ + wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ + coderules.doc filelist.doc change.log +MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ + makefile.mc6 makefile.dj makefile.wat makcjpeg.st makdjpeg.st \ + makljpeg.st maktjpeg.st makefile.manx makefile.sas makefile.mms \ + makefile.vms makvms.opt +CONFIGFILES= jconfig.cfg jconfig.manx jconfig.sas jconfig.st jconfig.bcc \ + jconfig.mc6 jconfig.dj jconfig.wat jconfig.vms +OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm +TESTFILES= testorig.jpg testimg.ppm testimg.gif testimg.jpg testprog.jpg \ + testimgp.jpg +DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ + $(OTHERFILES) $(TESTFILES) +# library object files common to compression and decompression +COMOBJECTS= jcomapi.o jutils.o jerror.o jmemmgr.o $(SYSDEPMEM) +# compression library object files +CLIBOBJECTS= jcapimin.o jcapistd.o jctrans.o jcparam.o jdatadst.o jcinit.o \ + jcmaster.o jcmarker.o jcmainct.o jcprepct.o jccoefct.o jccolor.o \ + jcsample.o jchuff.o jcphuff.o jcdctmgr.o jfdctfst.o jfdctflt.o \ + jfdctint.o +# decompression library object files +DLIBOBJECTS= jdapimin.o jdapistd.o jdtrans.o jdatasrc.o jdmaster.o \ + jdinput.o jdmarker.o jdhuff.o jdphuff.o jdmainct.o jdcoefct.o \ + jdpostct.o jddctmgr.o jidctfst.o jidctflt.o jidctint.o jidctred.o \ + jdsample.o jdcolor.o jquant1.o jquant2.o jdmerge.o +# These objectfiles are included in libjpeg.a +LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) +# object files for sample applications (excluding library files) +COBJECTS= cjpeg.o rdppm.o rdgif.o rdtarga.o rdrle.o rdbmp.o rdswitch.o \ + cdjpeg.o +DOBJECTS= djpeg.o wrppm.o wrgif.o wrtarga.o wrrle.o wrbmp.o rdcolmap.o \ + cdjpeg.o +TROBJECTS= jpegtran.o rdswitch.o cdjpeg.o + + +all: libjpeg.a cjpeg djpeg jpegtran rdjpgcom wrjpgcom + +libjpeg.a: $(LIBOBJECTS) + $(RM) libjpeg.a + $(AR) libjpeg.a $(LIBOBJECTS) + $(AR2) libjpeg.a + +cjpeg: $(COBJECTS) libjpeg.a + $(LN) $(LDFLAGS) -o cjpeg $(COBJECTS) libjpeg.a $(LDLIBS) + +djpeg: $(DOBJECTS) libjpeg.a + $(LN) $(LDFLAGS) -o djpeg $(DOBJECTS) libjpeg.a $(LDLIBS) + +jpegtran: $(TROBJECTS) libjpeg.a + $(LN) $(LDFLAGS) -o jpegtran $(TROBJECTS) libjpeg.a $(LDLIBS) + +rdjpgcom: rdjpgcom.o + $(LN) $(LDFLAGS) -o rdjpgcom rdjpgcom.o $(LDLIBS) + +wrjpgcom: wrjpgcom.o + $(LN) $(LDFLAGS) -o wrjpgcom wrjpgcom.o $(LDLIBS) + +exe: cjpeg djpeg jpegtran rdjpgcom wrjpgcom + coff2exe cjpeg + coff2exe djpeg + coff2exe jpegtran + coff2exe rdjpgcom + coff2exe wrjpgcom + +standalone: cjpeg djpeg jpegtran rdjpgcom wrjpgcom + coff2exe -s $(GO32) cjpeg + coff2exe -s $(GO32) djpeg + coff2exe -s $(GO32) jpegtran + coff2exe -s $(GO32) rdjpgcom + coff2exe -s $(GO32) wrjpgcom + +jconfig.h: jconfig.doc + echo You must prepare a system-dependent jconfig.h file. + echo Please read the installation directions in install.doc. + exit 1 + +clean: + $(RM) *.o + $(RM) cjpeg + $(RM) djpeg + $(RM) jpegtran + $(RM) rdjpgcom + $(RM) wrjpgcom + $(RM) libjpeg.a + $(RM) testout*.* + +test: cjpeg djpeg jpegtran + $(RM) testout*.* + go32 djpeg -dct int -ppm -outfile testout.ppm testorig.jpg + go32 djpeg -dct int -gif -outfile testout.gif testorig.jpg + go32 cjpeg -dct int -outfile testout.jpg testimg.ppm + go32 djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg + go32 cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm + go32 jpegtran -outfile testoutt.jpg testprog.jpg + fc /b testimg.ppm testout.ppm + fc /b testimg.gif testout.gif + fc /b testimg.jpg testout.jpg + fc /b testimg.ppm testoutp.ppm + fc /b testimgp.jpg testoutp.jpg + fc /b testorig.jpg testoutt.jpg + + +jcapimin.o: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapistd.o: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccoefct.o: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccolor.o: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcdctmgr.o: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jchuff.o: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcinit.o: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmainct.o: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmarker.o: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmaster.o: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcomapi.o: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcparam.o: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcphuff.o: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcprepct.o: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcsample.o: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jctrans.o: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapimin.o: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapistd.o: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdatadst.o: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdatasrc.o: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdcoefct.o: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdcolor.o: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jddctmgr.o: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jdhuff.o: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdinput.o: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmainct.o: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmarker.o: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmaster.o: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmerge.o: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdphuff.o: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdpostct.o: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdsample.o: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdtrans.o: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jerror.o: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h +jfdctflt.o: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctfst.o: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctint.o: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctflt.o: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctfst.o: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctint.o: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctred.o: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jquant1.o: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jquant2.o: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jutils.o: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jmemmgr.o: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemansi.o: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemname.o: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemnobs.o: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemdos.o: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemmac.o: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +cjpeg.o: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +djpeg.o: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +jpegtran.o: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +cdjpeg.o: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdcolmap.o: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdswitch.o: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdjpgcom.o: rdjpgcom.c jinclude.h jconfig.h +wrjpgcom.o: wrjpgcom.c jinclude.h jconfig.h +rdppm.o: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrppm.o: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdgif.o: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrgif.o: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdtarga.o: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrtarga.o: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdbmp.o: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrbmp.o: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdrle.o: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrrle.o: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/gs/jpeg/makefile.manx b/gs/jpeg/makefile.manx new file mode 100644 index 000000000..fa035fce9 --- /dev/null +++ b/gs/jpeg/makefile.manx @@ -0,0 +1,210 @@ +# Makefile for Independent JPEG Group's software + +# This makefile is for Amiga systems using Manx Aztec C ver 5.x. +# Thanks to D.J. James (djjames@cup.portal.com) for this version. + +# Read installation instructions before saying "make" !! + +# The name of your C compiler: +CC= cc + +# You may need to adjust these cc options: +# Uncomment for generic 68000 code (will work on any Amiga) +ARCHFLAGS= -sn + +# Uncomment for 68020/68030 code (faster, but won't run on 68000 CPU) +#ARCHFLAGS= -c2 + +CFLAGS= -MC -MD $(ARCHFLAGS) -spfam -r4 + +# Link-time cc options: +LDFLAGS= -g + +# To link any special libraries, add the necessary -l commands here. +LDLIBS= -lml -lcl + +# Put here the object file name for the correct system-dependent memory +# manager file. For Amiga we recommend jmemname.o. +SYSDEPMEM= jmemname.o + +# miscellaneous OS-dependent stuff +# linker +LN= ln +# file deletion command +RM= delete quiet +# library (.lib) file creation command +AR= lb + +# End of configurable options. + + +# source files: JPEG library proper +LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ + jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ + jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ + jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ + jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ + jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ + jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ + jquant2.c jutils.c jmemmgr.c +# memmgr back ends: compile only one of these into a working library +SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c +# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom +APPSOURCES= cjpeg.c djpeg.c jpegtran.c cdjpeg.c rdcolmap.c rdswitch.c \ + rdjpgcom.c wrjpgcom.c rdppm.c wrppm.c rdgif.c wrgif.c rdtarga.c \ + wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c +SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) +# files included by source files +INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ + jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h +# documentation, test, and support files +DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ + wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ + coderules.doc filelist.doc change.log +MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ + makefile.mc6 makefile.dj makefile.wat makcjpeg.st makdjpeg.st \ + makljpeg.st maktjpeg.st makefile.manx makefile.sas makefile.mms \ + makefile.vms makvms.opt +CONFIGFILES= jconfig.cfg jconfig.manx jconfig.sas jconfig.st jconfig.bcc \ + jconfig.mc6 jconfig.dj jconfig.wat jconfig.vms +OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm +TESTFILES= testorig.jpg testimg.ppm testimg.gif testimg.jpg testprog.jpg \ + testimgp.jpg +DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ + $(OTHERFILES) $(TESTFILES) +# library object files common to compression and decompression +COMOBJECTS= jcomapi.o jutils.o jerror.o jmemmgr.o $(SYSDEPMEM) +# compression library object files +CLIBOBJECTS= jcapimin.o jcapistd.o jctrans.o jcparam.o jdatadst.o jcinit.o \ + jcmaster.o jcmarker.o jcmainct.o jcprepct.o jccoefct.o jccolor.o \ + jcsample.o jchuff.o jcphuff.o jcdctmgr.o jfdctfst.o jfdctflt.o \ + jfdctint.o +# decompression library object files +DLIBOBJECTS= jdapimin.o jdapistd.o jdtrans.o jdatasrc.o jdmaster.o \ + jdinput.o jdmarker.o jdhuff.o jdphuff.o jdmainct.o jdcoefct.o \ + jdpostct.o jddctmgr.o jidctfst.o jidctflt.o jidctint.o jidctred.o \ + jdsample.o jdcolor.o jquant1.o jquant2.o jdmerge.o +# These objectfiles are included in libjpeg.lib +LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) +# object files for sample applications (excluding library files) +COBJECTS= cjpeg.o rdppm.o rdgif.o rdtarga.o rdrle.o rdbmp.o rdswitch.o \ + cdjpeg.o +DOBJECTS= djpeg.o wrppm.o wrgif.o wrtarga.o wrrle.o wrbmp.o rdcolmap.o \ + cdjpeg.o +TROBJECTS= jpegtran.o rdswitch.o cdjpeg.o + + +all: libjpeg.lib cjpeg djpeg jpegtran rdjpgcom wrjpgcom + +libjpeg.lib: $(LIBOBJECTS) + -$(RM) libjpeg.lib + $(AR) libjpeg.lib $(LIBOBJECTS) + +cjpeg: $(COBJECTS) libjpeg.lib + $(LN) $(LDFLAGS) -o cjpeg $(COBJECTS) libjpeg.lib $(LDLIBS) + +djpeg: $(DOBJECTS) libjpeg.lib + $(LN) $(LDFLAGS) -o djpeg $(DOBJECTS) libjpeg.lib $(LDLIBS) + +jpegtran: $(TROBJECTS) libjpeg.lib + $(LN) $(LDFLAGS) -o jpegtran $(TROBJECTS) libjpeg.lib $(LDLIBS) + +rdjpgcom: rdjpgcom.o + $(LN) $(LDFLAGS) -o rdjpgcom rdjpgcom.o $(LDLIBS) + +wrjpgcom: wrjpgcom.o + $(LN) $(LDFLAGS) -o wrjpgcom wrjpgcom.o $(LDLIBS) + +jconfig.h: jconfig.doc + echo You must prepare a system-dependent jconfig.h file. + echo Please read the installation directions in install.doc. + exit 1 + +clean: + -$(RM) *.o cjpeg djpeg jpegtran libjpeg.lib rdjpgcom wrjpgcom + -$(RM) core testout*.* + +test: cjpeg djpeg jpegtran + -$(RM) testout*.* + djpeg -dct int -ppm -outfile testout.ppm testorig.jpg + djpeg -dct int -gif -outfile testout.gif testorig.jpg + cjpeg -dct int -outfile testout.jpg testimg.ppm + djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg + cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm + jpegtran -outfile testoutt.jpg testprog.jpg + cmp testimg.ppm testout.ppm + cmp testimg.gif testout.gif + cmp testimg.jpg testout.jpg + cmp testimg.ppm testoutp.ppm + cmp testimgp.jpg testoutp.jpg + cmp testorig.jpg testoutt.jpg + + +jcapimin.o: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapistd.o: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccoefct.o: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccolor.o: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcdctmgr.o: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jchuff.o: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcinit.o: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmainct.o: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmarker.o: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmaster.o: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcomapi.o: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcparam.o: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcphuff.o: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcprepct.o: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcsample.o: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jctrans.o: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapimin.o: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapistd.o: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdatadst.o: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdatasrc.o: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdcoefct.o: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdcolor.o: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jddctmgr.o: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jdhuff.o: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdinput.o: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmainct.o: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmarker.o: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmaster.o: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmerge.o: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdphuff.o: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdpostct.o: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdsample.o: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdtrans.o: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jerror.o: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h +jfdctflt.o: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctfst.o: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctint.o: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctflt.o: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctfst.o: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctint.o: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctred.o: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jquant1.o: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jquant2.o: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jutils.o: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jmemmgr.o: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemansi.o: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemname.o: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemnobs.o: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemdos.o: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemmac.o: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +cjpeg.o: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +djpeg.o: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +jpegtran.o: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +cdjpeg.o: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdcolmap.o: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdswitch.o: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdjpgcom.o: rdjpgcom.c jinclude.h jconfig.h +wrjpgcom.o: wrjpgcom.c jinclude.h jconfig.h +rdppm.o: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrppm.o: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdgif.o: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrgif.o: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdtarga.o: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrtarga.o: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdbmp.o: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrbmp.o: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdrle.o: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrrle.o: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/gs/jpeg/makefile.mc6 b/gs/jpeg/makefile.mc6 new file mode 100644 index 000000000..a8ab313a7 --- /dev/null +++ b/gs/jpeg/makefile.mc6 @@ -0,0 +1,233 @@ +# Makefile for Independent JPEG Group's software + +# This makefile is for Microsoft C for MS-DOS, version 6.00A and up. +# Use NMAKE, not Microsoft's brain-damaged MAKE. +# Thanks to Alan Wright and Chris Turner of Olivetti Research Ltd. + +# Read installation instructions before saying "nmake" !! + +# You may need to adjust these compiler options: +CFLAGS = -AM -Oecigt -Gs -W3 +# -AM medium memory model (or use -AS for small model, if you remove features) +# -Oecigt -Gs maximum safe optimisation (-Ol has bugs in MSC 6.00A) +# -W3 warning level 3 +# You might also want to add -G2 if you have an 80286, etc. +# Generally, we recommend defining any configuration symbols in jconfig.h, +# NOT via -D switches here. + +# Put here the object file name for the correct system-dependent memory +# manager file. For DOS, we recommend jmemdos.c and jmemdosa.asm. +# If you change this, you'll need to modify the linker response file +# name list, below, by hand! +SYSDEPMEM= jmemdos.obj jmemdosa.obj + +# End of configurable options. + + +# source files: JPEG library proper +LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ + jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ + jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ + jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ + jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ + jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ + jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ + jquant2.c jutils.c jmemmgr.c +# memmgr back ends: compile only one of these into a working library +SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c +# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom +APPSOURCES= cjpeg.c djpeg.c jpegtran.c cdjpeg.c rdcolmap.c rdswitch.c \ + rdjpgcom.c wrjpgcom.c rdppm.c wrppm.c rdgif.c wrgif.c rdtarga.c \ + wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c +SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) +# files included by source files +INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ + jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h +# documentation, test, and support files +DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ + wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ + coderules.doc filelist.doc change.log +MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ + makefile.mc6 makefile.dj makefile.wat makcjpeg.st makdjpeg.st \ + makljpeg.st maktjpeg.st makefile.manx makefile.sas makefile.mms \ + makefile.vms makvms.opt +CONFIGFILES= jconfig.cfg jconfig.manx jconfig.sas jconfig.st jconfig.bcc \ + jconfig.mc6 jconfig.dj jconfig.wat jconfig.vms +OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm +TESTFILES= testorig.jpg testimg.ppm testimg.gif testimg.jpg testprog.jpg \ + testimgp.jpg +DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ + $(OTHERFILES) $(TESTFILES) +# library object files common to compression and decompression +COMOBJECTS= jcomapi.obj jutils.obj jerror.obj jmemmgr.obj $(SYSDEPMEM) +# compression library object files +CLIBOBJECTS= jcapimin.obj jcapistd.obj jctrans.obj jcparam.obj jdatadst.obj \ + jcinit.obj jcmaster.obj jcmarker.obj jcmainct.obj jcprepct.obj \ + jccoefct.obj jccolor.obj jcsample.obj jchuff.obj jcphuff.obj \ + jcdctmgr.obj jfdctfst.obj jfdctflt.obj jfdctint.obj +# decompression library object files +DLIBOBJECTS= jdapimin.obj jdapistd.obj jdtrans.obj jdatasrc.obj \ + jdmaster.obj jdinput.obj jdmarker.obj jdhuff.obj jdphuff.obj \ + jdmainct.obj jdcoefct.obj jdpostct.obj jddctmgr.obj jidctfst.obj \ + jidctflt.obj jidctint.obj jidctred.obj jdsample.obj jdcolor.obj \ + jquant1.obj jquant2.obj jdmerge.obj +# These objectfiles are included in libjpeg.lib +LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) +# object files for sample applications (excluding library files) +COBJECTS= cjpeg.obj rdppm.obj rdgif.obj rdtarga.obj rdrle.obj rdbmp.obj \ + rdswitch.obj cdjpeg.obj +DOBJECTS= djpeg.obj wrppm.obj wrgif.obj wrtarga.obj wrrle.obj wrbmp.obj \ + rdcolmap.obj cdjpeg.obj +TROBJECTS= jpegtran.obj rdswitch.obj cdjpeg.obj + +# need linker response file because file list > 128 chars +RFILE = libjpeg.ans + + +all: libjpeg.lib cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe + +libjpeg.lib: $(LIBOBJECTS) $(RFILE) + del libjpeg.lib + lib @$(RFILE) + +# linker response file for building libjpeg.lib +$(RFILE) : makefile + del $(RFILE) + echo libjpeg.lib >$(RFILE) +# silly want-to-create-it prompt: + echo y >>$(RFILE) + echo +jcapimin.obj +jcapistd.obj +jctrans.obj +jcparam.obj & >>$(RFILE) + echo +jdatadst.obj +jcinit.obj +jcmaster.obj +jcmarker.obj & >>$(RFILE) + echo +jcmainct.obj +jcprepct.obj +jccoefct.obj & >>$(RFILE) + echo +jccolor.obj +jcsample.obj +jchuff.obj +jcphuff.obj & >>$(RFILE) + echo +jcdctmgr.obj +jfdctfst.obj +jfdctflt.obj & >>$(RFILE) + echo +jfdctint.obj +jdapimin.obj +jdapistd.obj & >>$(RFILE) + echo +jdtrans.obj +jdatasrc.obj +jdmaster.obj +jdinput.obj & >>$(RFILE) + echo +jdmarker.obj +jdhuff.obj +jdphuff.obj +jdmainct.obj & >>$(RFILE) + echo +jdcoefct.obj +jdpostct.obj +jddctmgr.obj & >>$(RFILE) + echo +jidctfst.obj +jidctflt.obj +jidctint.obj & >>$(RFILE) + echo +jidctred.obj +jdsample.obj +jdcolor.obj +jquant1.obj & >>$(RFILE) + echo +jquant2.obj +jdmerge.obj +jcomapi.obj +jutils.obj & >>$(RFILE) + echo +jerror.obj +jmemmgr.obj +jmemdos.obj +jmemdosa.obj ; >>$(RFILE) + +cjpeg.exe: $(COBJECTS) libjpeg.lib + echo $(COBJECTS) >cjpeg.lst + link /STACK:4096 /EXEPACK @cjpeg.lst, cjpeg.exe, , libjpeg.lib, ; + del cjpeg.lst + +djpeg.exe: $(DOBJECTS) libjpeg.lib + echo $(DOBJECTS) >djpeg.lst + link /STACK:4096 /EXEPACK @djpeg.lst, djpeg.exe, , libjpeg.lib, ; + del djpeg.lst + +jpegtran.exe: $(TROBJECTS) libjpeg.lib + link /STACK:4096 /EXEPACK $(TROBJECTS), jpegtran.exe, , libjpeg.lib, ; + +rdjpgcom.exe: rdjpgcom.c + $(CC) -AS -O -W3 rdjpgcom.c + +# wrjpgcom needs large model so it can malloc a 64K chunk +wrjpgcom.exe: wrjpgcom.c + $(CC) -AL -O -W3 wrjpgcom.c + +jconfig.h: jconfig.doc + echo You must prepare a system-dependent jconfig.h file. + echo Please read the installation directions in install.doc. + exit 1 + +clean: + del *.obj + del libjpeg.lib + del cjpeg.exe + del djpeg.exe + del jpegtran.exe + del rdjpgcom.exe + del wrjpgcom.exe + del testout*.* + +test: cjpeg.exe djpeg.exe jpegtran.exe + del testout*.* + djpeg -dct int -ppm -outfile testout.ppm testorig.jpg + djpeg -dct int -gif -outfile testout.gif testorig.jpg + cjpeg -dct int -outfile testout.jpg testimg.ppm + djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg + cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm + jpegtran -outfile testoutt.jpg testprog.jpg + fc /b testimg.ppm testout.ppm + fc /b testimg.gif testout.gif + fc /b testimg.jpg testout.jpg + fc /b testimg.ppm testoutp.ppm + fc /b testimgp.jpg testoutp.jpg + fc /b testorig.jpg testoutt.jpg + + +jcapimin.obj: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapistd.obj: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccoefct.obj: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccolor.obj: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcdctmgr.obj: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jchuff.obj: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcinit.obj: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmainct.obj: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmarker.obj: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmaster.obj: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcomapi.obj: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcparam.obj: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcphuff.obj: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcprepct.obj: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcsample.obj: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jctrans.obj: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapimin.obj: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapistd.obj: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdatadst.obj: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdatasrc.obj: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdcoefct.obj: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdcolor.obj: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jddctmgr.obj: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jdhuff.obj: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdinput.obj: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmainct.obj: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmarker.obj: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmaster.obj: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmerge.obj: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdphuff.obj: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdpostct.obj: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdsample.obj: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdtrans.obj: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jerror.obj: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h +jfdctflt.obj: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctfst.obj: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctint.obj: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctflt.obj: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctfst.obj: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctint.obj: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctred.obj: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jquant1.obj: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jquant2.obj: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jutils.obj: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jmemmgr.obj: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemansi.obj: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemname.obj: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemnobs.obj: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemdos.obj: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemmac.obj: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +cjpeg.obj: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +djpeg.obj: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +jpegtran.obj: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +cdjpeg.obj: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdcolmap.obj: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdswitch.obj: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdjpgcom.obj: rdjpgcom.c jinclude.h jconfig.h +wrjpgcom.obj: wrjpgcom.c jinclude.h jconfig.h +rdppm.obj: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrppm.obj: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdgif.obj: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrgif.obj: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdtarga.obj: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrtarga.obj: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdbmp.obj: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrbmp.obj: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdrle.obj: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrrle.obj: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +jmemdosa.obj : jmemdosa.asm + masm /mx $*; diff --git a/gs/jpeg/makefile.mms b/gs/jpeg/makefile.mms new file mode 100644 index 000000000..401fe200f --- /dev/null +++ b/gs/jpeg/makefile.mms @@ -0,0 +1,214 @@ +# Makefile for Independent JPEG Group's software + +# This makefile is for use with MMS on Digital VMS systems. +# Thanks to Rick Dyson (dyson@iowasp.physics.uiowa.edu) +# and Tim Bell (tbell@netcom.com) for their help. + +# Read installation instructions before saying "MMS" !! + +# You may need to adjust these cc options: +CFLAGS= $(CFLAGS) /NoDebug /Optimize +# Generally, we recommend defining any configuration symbols in jconfig.h, +# NOT via /Define switches here. +.ifdef ALPHA +OPT= +.else +OPT= ,Sys$Disk:[]MAKVMS.OPT/Option +.endif + +# Put here the object file name for the correct system-dependent memory +# manager file. For Unix this is usually jmemnobs.o, but you may want +# to use jmemansi.o or jmemname.o if you have limited swap space. +SYSDEPMEM= jmemnobs.obj + +# End of configurable options. + + +# source files: JPEG library proper +LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ + jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ + jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ + jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ + jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ + jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ + jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ + jquant2.c jutils.c jmemmgr.c +# memmgr back ends: compile only one of these into a working library +SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c +# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom +APPSOURCES= cjpeg.c djpeg.c jpegtran.c cdjpeg.c rdcolmap.c rdswitch.c \ + rdjpgcom.c wrjpgcom.c rdppm.c wrppm.c rdgif.c wrgif.c rdtarga.c \ + wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c +SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) +# files included by source files +INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ + jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h +# documentation, test, and support files +DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ + wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ + coderules.doc filelist.doc change.log +MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ + makefile.mc6 makefile.dj makefile.wat makcjpeg.st makdjpeg.st \ + makljpeg.st maktjpeg.st makefile.manx makefile.sas makefile.mms \ + makefile.vms makvms.opt +CONFIGFILES= jconfig.cfg jconfig.manx jconfig.sas jconfig.st jconfig.bcc \ + jconfig.mc6 jconfig.dj jconfig.wat jconfig.vms +OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm +TESTFILES= testorig.jpg testimg.ppm testimg.gif testimg.jpg testprog.jpg \ + testimgp.jpg +DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ + $(OTHERFILES) $(TESTFILES) +# library object files common to compression and decompression +COMOBJECTS= jcomapi.obj jutils.obj jerror.obj jmemmgr.obj $(SYSDEPMEM) +# compression library object files +CLIBOBJECTS= jcapimin.obj jcapistd.obj jctrans.obj jcparam.obj jdatadst.obj \ + jcinit.obj jcmaster.obj jcmarker.obj jcmainct.obj jcprepct.obj \ + jccoefct.obj jccolor.obj jcsample.obj jchuff.obj jcphuff.obj \ + jcdctmgr.obj jfdctfst.obj jfdctflt.obj jfdctint.obj +# decompression library object files +DLIBOBJECTS= jdapimin.obj jdapistd.obj jdtrans.obj jdatasrc.obj \ + jdmaster.obj jdinput.obj jdmarker.obj jdhuff.obj jdphuff.obj \ + jdmainct.obj jdcoefct.obj jdpostct.obj jddctmgr.obj jidctfst.obj \ + jidctflt.obj jidctint.obj jidctred.obj jdsample.obj jdcolor.obj \ + jquant1.obj jquant2.obj jdmerge.obj +# These objectfiles are included in libjpeg.olb +LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) +# object files for sample applications (excluding library files) +COBJECTS= cjpeg.obj rdppm.obj rdgif.obj rdtarga.obj rdrle.obj rdbmp.obj \ + rdswitch.obj cdjpeg.obj +DOBJECTS= djpeg.obj wrppm.obj wrgif.obj wrtarga.obj wrrle.obj wrbmp.obj \ + rdcolmap.obj cdjpeg.obj +TROBJECTS= jpegtran.obj rdswitch.obj cdjpeg.obj +# objectfile lists with commas --- what a crock +COBJLIST= cjpeg.obj,rdppm.obj,rdgif.obj,rdtarga.obj,rdrle.obj,rdbmp.obj,\ + rdswitch.obj,cdjpeg.obj +DOBJLIST= djpeg.obj,wrppm.obj,wrgif.obj,wrtarga.obj,wrrle.obj,wrbmp.obj,\ + rdcolmap.obj,cdjpeg.obj +TROBJLIST= jpegtran.obj,rdswitch.obj,cdjpeg.obj +LIBOBJLIST= jcapimin.obj,jcapistd.obj,jctrans.obj,jcparam.obj,jdatadst.obj,\ + jcinit.obj,jcmaster.obj,jcmarker.obj,jcmainct.obj,jcprepct.obj,\ + jccoefct.obj,jccolor.obj,jcsample.obj,jchuff.obj,jcphuff.obj,\ + jcdctmgr.obj,jfdctfst.obj,jfdctflt.obj,jfdctint.obj,jdapimin.obj,\ + jdapistd.obj,jdtrans.obj,jdatasrc.obj,jdmaster.obj,jdinput.obj,\ + jdmarker.obj,jdhuff.obj,jdphuff.obj,jdmainct.obj,jdcoefct.obj,\ + jdpostct.obj,jddctmgr.obj,jidctfst.obj,jidctflt.obj,jidctint.obj,\ + jidctred.obj,jdsample.obj,jdcolor.obj,jquant1.obj,jquant2.obj,\ + jdmerge.obj,jcomapi.obj,jutils.obj,jerror.obj,jmemmgr.obj,$(SYSDEPMEM) + + +.first + @- Define /NoLog Sys Sys$Library + +ALL : libjpeg.olb cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe + @ Continue + +libjpeg.olb : $(LIBOBJECTS) + Library /Create libjpeg.olb $(LIBOBJLIST) + +cjpeg.exe : $(COBJECTS) libjpeg.olb + $(LINK) $(LFLAGS) /Executable = cjpeg.exe $(COBJLIST),libjpeg.olb/Library$(OPT) + +djpeg.exe : $(DOBJECTS) libjpeg.olb + $(LINK) $(LFLAGS) /Executable = djpeg.exe $(DOBJLIST),libjpeg.olb/Library$(OPT) + +jpegtran.exe : $(TROBJECTS) libjpeg.olb + $(LINK) $(LFLAGS) /Executable = jpegtran.exe $(TROBJLIST),libjpeg.olb/Library$(OPT) + +rdjpgcom.exe : rdjpgcom.obj + $(LINK) $(LFLAGS) /Executable = rdjpgcom.exe rdjpgcom.obj$(OPT) + +wrjpgcom.exe : wrjpgcom.obj + $(LINK) $(LFLAGS) /Executable = wrjpgcom.exe wrjpgcom.obj$(OPT) + +jconfig.h : jconfig.vms + @- Copy jconfig.vms jconfig.h + +clean : + @- Set Protection = Owner:RWED *.*;-1 + @- Set Protection = Owner:RWED *.OBJ + - Purge /NoLog /NoConfirm *.* + - Delete /NoLog /NoConfirm *.OBJ; + +test : cjpeg.exe djpeg.exe jpegtran.exe + mcr sys$disk:[]djpeg -dct int -ppm -outfile testout.ppm testorig.jpg + mcr sys$disk:[]djpeg -dct int -gif -outfile testout.gif testorig.jpg + mcr sys$disk:[]cjpeg -dct int -outfile testout.jpg testimg.ppm + mcr sys$disk:[]djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg + mcr sys$disk:[]cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm + mcr sys$disk:[]jpegtran -outfile testoutt.jpg testprog.jpg + - Backup /Compare/Log testimg.ppm testout.ppm + - Backup /Compare/Log testimg.gif testout.gif + - Backup /Compare/Log testimg.jpg testout.jpg + - Backup /Compare/Log testimg.ppm testoutp.ppm + - Backup /Compare/Log testimgp.jpg testoutp.jpg + - Backup /Compare/Log testorig.jpg testoutt.jpg + + +jcapimin.obj : jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapistd.obj : jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccoefct.obj : jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccolor.obj : jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcdctmgr.obj : jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jchuff.obj : jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcinit.obj : jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmainct.obj : jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmarker.obj : jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmaster.obj : jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcomapi.obj : jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcparam.obj : jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcphuff.obj : jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcprepct.obj : jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcsample.obj : jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jctrans.obj : jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapimin.obj : jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapistd.obj : jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdatadst.obj : jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdatasrc.obj : jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdcoefct.obj : jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdcolor.obj : jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jddctmgr.obj : jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jdhuff.obj : jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdinput.obj : jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmainct.obj : jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmarker.obj : jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmaster.obj : jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmerge.obj : jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdphuff.obj : jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdpostct.obj : jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdsample.obj : jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdtrans.obj : jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jerror.obj : jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h +jfdctflt.obj : jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctfst.obj : jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctint.obj : jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctflt.obj : jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctfst.obj : jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctint.obj : jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctred.obj : jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jquant1.obj : jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jquant2.obj : jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jutils.obj : jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jmemmgr.obj : jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemansi.obj : jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemname.obj : jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemnobs.obj : jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemdos.obj : jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemmac.obj : jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +cjpeg.obj : cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +djpeg.obj : djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +jpegtran.obj : jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +cdjpeg.obj : cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdcolmap.obj : rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdswitch.obj : rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdjpgcom.obj : rdjpgcom.c jinclude.h jconfig.h +wrjpgcom.obj : wrjpgcom.c jinclude.h jconfig.h +rdppm.obj : rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrppm.obj : wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdgif.obj : rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrgif.obj : wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdtarga.obj : rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrtarga.obj : wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdbmp.obj : rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrbmp.obj : wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdrle.obj : rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrrle.obj : wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/gs/jpeg/makefile.sas b/gs/jpeg/makefile.sas new file mode 100644 index 000000000..14be5a46a --- /dev/null +++ b/gs/jpeg/makefile.sas @@ -0,0 +1,244 @@ +# Makefile for Independent JPEG Group's software + +# This makefile is for Amiga systems using SAS C 6.0 and up. +# Thanks to Ed Hanway, Mark Rinfret, and Jim Zepeda. + +# Read installation instructions before saying "make" !! + +# The name of your C compiler: +CC= sc + +# You may need to adjust these cc options: +# Uncomment the following lines for generic 680x0 version +ARCHFLAGS= cpu=any +SUFFIX= + +# Uncomment the following lines for 68030-only version +#ARCHFLAGS= cpu=68030 +#SUFFIX=.030 + +CFLAGS= nostackcheck data=near parms=register optimize $(ARCHFLAGS) \ + ignore=104 ignore=304 ignore=306 +# ignore=104 disables warnings for mismatched const qualifiers +# ignore=304 disables warnings for variables being optimized out +# ignore=306 disables warnings for the inlining of functions +# Generally, we recommend defining any configuration symbols in jconfig.h, +# NOT via define switches here. + +# Link-time cc options: +LDFLAGS= SC SD ND BATCH + +# To link any special libraries, add the necessary commands here. +LDLIBS= LIB:scm.lib LIB:sc.lib + +# Put here the object file name for the correct system-dependent memory +# manager file. For Amiga we recommend jmemname.o. +SYSDEPMEM= jmemname.o + +# miscellaneous OS-dependent stuff +# linker +LN= slink +# file deletion command +RM= delete quiet +# library (.lib) file creation command +AR= oml + +# End of configurable options. + + +# source files: JPEG library proper +LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ + jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ + jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ + jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ + jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ + jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ + jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ + jquant2.c jutils.c jmemmgr.c +# memmgr back ends: compile only one of these into a working library +SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c +# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom +APPSOURCES= cjpeg.c djpeg.c jpegtran.c cdjpeg.c rdcolmap.c rdswitch.c \ + rdjpgcom.c wrjpgcom.c rdppm.c wrppm.c rdgif.c wrgif.c rdtarga.c \ + wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c +SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) +# files included by source files +INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ + jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h +# documentation, test, and support files +DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ + wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ + coderules.doc filelist.doc change.log +MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ + makefile.mc6 makefile.dj makefile.wat makcjpeg.st makdjpeg.st \ + makljpeg.st maktjpeg.st makefile.manx makefile.sas makefile.mms \ + makefile.vms makvms.opt +CONFIGFILES= jconfig.cfg jconfig.manx jconfig.sas jconfig.st jconfig.bcc \ + jconfig.mc6 jconfig.dj jconfig.wat jconfig.vms +OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm +TESTFILES= testorig.jpg testimg.ppm testimg.gif testimg.jpg testprog.jpg \ + testimgp.jpg +DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ + $(OTHERFILES) $(TESTFILES) +# library object files common to compression and decompression +COMOBJECTS= jcomapi.o jutils.o jerror.o jmemmgr.o $(SYSDEPMEM) +# compression library object files +CLIBOBJECTS= jcapimin.o jcapistd.o jctrans.o jcparam.o jdatadst.o jcinit.o \ + jcmaster.o jcmarker.o jcmainct.o jcprepct.o jccoefct.o jccolor.o \ + jcsample.o jchuff.o jcphuff.o jcdctmgr.o jfdctfst.o jfdctflt.o \ + jfdctint.o +# decompression library object files +DLIBOBJECTS= jdapimin.o jdapistd.o jdtrans.o jdatasrc.o jdmaster.o \ + jdinput.o jdmarker.o jdhuff.o jdphuff.o jdmainct.o jdcoefct.o \ + jdpostct.o jddctmgr.o jidctfst.o jidctflt.o jidctint.o jidctred.o \ + jdsample.o jdcolor.o jquant1.o jquant2.o jdmerge.o +# These objectfiles are included in libjpeg.lib +LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) +# object files for sample applications (excluding library files) +COBJECTS= cjpeg.o rdppm.o rdgif.o rdtarga.o rdrle.o rdbmp.o rdswitch.o \ + cdjpeg.o +DOBJECTS= djpeg.o wrppm.o wrgif.o wrtarga.o wrrle.o wrbmp.o rdcolmap.o \ + cdjpeg.o +TROBJECTS= jpegtran.o rdswitch.o cdjpeg.o + + +all: libjpeg.lib cjpeg$(SUFFIX) djpeg$(SUFFIX) jpegtran$(SUFFIX) rdjpgcom$(SUFFIX) wrjpgcom$(SUFFIX) + +libjpeg.lib: $(LIBOBJECTS) + -$(RM) libjpeg.lib + $(AR) libjpeg.lib r $(LIBOBJECTS) + +cjpeg$(SUFFIX): $(COBJECTS) libjpeg.lib + $(LN) n.tmp + comp testimg.ppm testout.ppm < n.tmp + comp testimg.gif testout.gif < n.tmp + comp testimg.jpg testout.jpg < n.tmp + comp testimg.ppm testoutp.ppm < n.tmp + comp testimgp.jpg testoutp.jpg < n.tmp + comp testorig.jpg testoutt.jpg < n.tmp + del n.tmp +!endif + + +jcapimin.obj: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapistd.obj: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccoefct.obj: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccolor.obj: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcdctmgr.obj: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jchuff.obj: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcinit.obj: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmainct.obj: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmarker.obj: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmaster.obj: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcomapi.obj: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcparam.obj: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcphuff.obj: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcprepct.obj: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcsample.obj: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jctrans.obj: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapimin.obj: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapistd.obj: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdatadst.obj: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdatasrc.obj: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdcoefct.obj: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdcolor.obj: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jddctmgr.obj: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jdhuff.obj: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdinput.obj: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmainct.obj: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmarker.obj: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmaster.obj: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmerge.obj: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdphuff.obj: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdpostct.obj: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdsample.obj: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdtrans.obj: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jerror.obj: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h +jfdctflt.obj: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctfst.obj: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctint.obj: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctflt.obj: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctfst.obj: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctint.obj: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctred.obj: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jquant1.obj: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jquant2.obj: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jutils.obj: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jmemmgr.obj: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemansi.obj: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemname.obj: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemnobs.obj: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemdos.obj: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemmac.obj: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +cjpeg.obj: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +djpeg.obj: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +jpegtran.obj: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h +cdjpeg.obj: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdcolmap.obj: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdswitch.obj: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdjpgcom.obj: rdjpgcom.c jinclude.h jconfig.h +wrjpgcom.obj: wrjpgcom.c jinclude.h jconfig.h +rdppm.obj: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrppm.obj: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdgif.obj: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrgif.obj: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdtarga.obj: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrtarga.obj: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdbmp.obj: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrbmp.obj: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +rdrle.obj: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h +wrrle.obj: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/gs/jpeg/makljpeg.st b/gs/jpeg/makljpeg.st new file mode 100644 index 000000000..435e23411 --- /dev/null +++ b/gs/jpeg/makljpeg.st @@ -0,0 +1,69 @@ +; Project file for Independent JPEG Group's software +; +; This project file is for Atari ST/STE/TT systems using Pure C or Turbo C. +; Thanks to Frank Moehle (Frank.Moehle@arbi.informatik.uni-oldenburg.de) +; and to Dr. B. Setzepfandt (bernd@gina.uni-muenster.de). +; +; To use this file, rename it to LIBJPEG.PRJ. +; Read installation instructions before trying to make the program! +; +; +; * * * Output file * * * +libjpeg.lib +; +; * * * COMPILER OPTIONS * * * +.C[-P] ; absolute calls +.C[-M] ; and no string merging, folks +.C[-w-cln] ; no "constant is long" warnings +.C[-w-par] ; no "parameter xxxx unused" +.C[-w-rch] ; no "unreachable code" +.C[-wsig] ; warn if significant digits may be lost +.L[-J] ; link new Obj-format (so we get a library) += +; * * * * List of modules * * * * +jcapimin.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jcapistd.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jccoefct.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jccolor.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jcdctmgr.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) +jchuff.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jchuff.h) +jcinit.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jcmainct.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jcmarker.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jcmaster.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jcomapi.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jcparam.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jcphuff.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jchuff.h) +jcprepct.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jcsample.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jctrans.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jdapimin.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jdapistd.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jdatadst.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h) +jdatasrc.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h) +jdcoefct.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jdcolor.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jddctmgr.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) +jdhuff.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdhuff.h) +jdinput.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jdmainct.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jdmarker.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jdmaster.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jdmerge.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jdphuff.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdhuff.h) +jdpostct.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jdsample.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jdtrans.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jerror.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jversion.h,jerror.h) +jfdctflt.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) +jfdctfst.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) +jfdctint.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) +jidctflt.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) +jidctfst.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) +jidctint.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) +jidctred.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) +jquant1.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jquant2.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jutils.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) +jmemmgr.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jmemsys.h) +jmemansi.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jmemsys.h) diff --git a/gs/jpeg/maktjpeg.st b/gs/jpeg/maktjpeg.st new file mode 100644 index 000000000..48e57e2c3 --- /dev/null +++ b/gs/jpeg/maktjpeg.st @@ -0,0 +1,30 @@ +; Project file for Independent JPEG Group's software +; +; This project file is for Atari ST/STE/TT systems using Pure C or Turbo C. +; Thanks to Frank Moehle (Frank.Moehle@arbi.informatik.uni-oldenburg.de) +; and to Dr. B. Setzepfandt (bernd@gina.uni-muenster.de). +; +; To use this file, rename it to JPEGTRAN.PRJ. +; If you are using Turbo C, change filenames beginning with "PC..." to "TC..." +; Read installation instructions before trying to make the program! +; +; +; * * * Output file * * * +jpegtran.ttp +; +; * * * COMPILER OPTIONS * * * +.C[-P] ; absolute calls +.C[-M] ; and no string merging, folks +.C[-w-cln] ; no "constant is long" warnings +.C[-w-par] ; no "parameter xxxx unused" +.C[-w-rch] ; no "unreachable code" +.C[-wsig] ; warn if significant digits may be lost += +; * * * * List of modules * * * * +PCSTART.O +jpegtran.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h,jversion.h) +cdjpeg.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +rdswitch.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) +LIBJPEG.LIB ; built by LIBJPEG.PRJ +PCSTDLIB.LIB ; standard library +PCEXTLIB.LIB ; extended library diff --git a/gs/jpeg/makvms.opt b/gs/jpeg/makvms.opt new file mode 100644 index 000000000..675e8fe98 --- /dev/null +++ b/gs/jpeg/makvms.opt @@ -0,0 +1,4 @@ +! A pointer to the VAX/VMS C Run-Time Shareable Library. +! This file is needed by makefile.mms and makefile.vms, +! but only for the older VAX C compiler. DEC C does not need it. +Sys$Library:VAXCRTL.EXE /Share diff --git a/gs/jpeg/rdbmp.c b/gs/jpeg/rdbmp.c new file mode 100644 index 000000000..b05fe2ac4 --- /dev/null +++ b/gs/jpeg/rdbmp.c @@ -0,0 +1,439 @@ +/* + * rdbmp.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to read input images in Microsoft "BMP" + * format (MS Windows 3.x, OS/2 1.x, and OS/2 2.x flavors). + * Currently, only 8-bit and 24-bit images are supported, not 1-bit or + * 4-bit (feeding such low-depth images into JPEG would be silly anyway). + * Also, we don't support RLE-compressed files. + * + * These routines may need modification for non-Unix environments or + * specialized applications. As they stand, they assume input from + * an ordinary stdio stream. They further assume that reading begins + * at the start of the file; start_input may need work if the + * user interface has already read some data (e.g., to determine that + * the file is indeed BMP format). + * + * This code contributed by James Arthur Boucher. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ + +#ifdef BMP_SUPPORTED + + +/* Macros to deal with unsigned chars as efficiently as compiler allows */ + +#ifdef HAVE_UNSIGNED_CHAR +typedef unsigned char U_CHAR; +#define UCH(x) ((int) (x)) +#else /* !HAVE_UNSIGNED_CHAR */ +#ifdef CHAR_IS_UNSIGNED +typedef char U_CHAR; +#define UCH(x) ((int) (x)) +#else +typedef char U_CHAR; +#define UCH(x) ((int) (x) & 0xFF) +#endif +#endif /* HAVE_UNSIGNED_CHAR */ + + +#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len))) + + +/* Private version of data source object */ + +typedef struct _bmp_source_struct * bmp_source_ptr; + +typedef struct _bmp_source_struct { + struct cjpeg_source_struct pub; /* public fields */ + + j_compress_ptr cinfo; /* back link saves passing separate parm */ + + JSAMPARRAY colormap; /* BMP colormap (converted to my format) */ + + jvirt_sarray_ptr whole_image; /* Needed to reverse row order */ + JDIMENSION source_row; /* Current source row number */ + JDIMENSION row_width; /* Physical width of scanlines in file */ + + int bits_per_pixel; /* remembers 8- or 24-bit format */ +} bmp_source_struct; + + +LOCAL(int) +read_byte (bmp_source_ptr sinfo) +/* Read next byte from BMP file */ +{ + register FILE *infile = sinfo->pub.input_file; + register int c; + + if ((c = getc(infile)) == EOF) + ERREXIT(sinfo->cinfo, JERR_INPUT_EOF); + return c; +} + + +LOCAL(void) +read_colormap (bmp_source_ptr sinfo, int cmaplen, int mapentrysize) +/* Read the colormap from a BMP file */ +{ + int i; + + switch (mapentrysize) { + case 3: + /* BGR format (occurs in OS/2 files) */ + for (i = 0; i < cmaplen; i++) { + sinfo->colormap[2][i] = (JSAMPLE) read_byte(sinfo); + sinfo->colormap[1][i] = (JSAMPLE) read_byte(sinfo); + sinfo->colormap[0][i] = (JSAMPLE) read_byte(sinfo); + } + break; + case 4: + /* BGR0 format (occurs in MS Windows files) */ + for (i = 0; i < cmaplen; i++) { + sinfo->colormap[2][i] = (JSAMPLE) read_byte(sinfo); + sinfo->colormap[1][i] = (JSAMPLE) read_byte(sinfo); + sinfo->colormap[0][i] = (JSAMPLE) read_byte(sinfo); + (void) read_byte(sinfo); + } + break; + default: + ERREXIT(sinfo->cinfo, JERR_BMP_BADCMAP); + break; + } +} + + +/* + * Read one row of pixels. + * The image has been read into the whole_image array, but is otherwise + * unprocessed. We must read it out in top-to-bottom row order, and if + * it is an 8-bit image, we must expand colormapped pixels to 24bit format. + */ + +METHODDEF(JDIMENSION) +get_8bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading 8-bit colormap indexes */ +{ + bmp_source_ptr source = (bmp_source_ptr) sinfo; + register JSAMPARRAY colormap = source->colormap; + JSAMPARRAY image_ptr; + register int t; + register JSAMPROW inptr, outptr; + register JDIMENSION col; + + /* Fetch next row from virtual array */ + source->source_row--; + image_ptr = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, source->whole_image, + source->source_row, (JDIMENSION) 1, FALSE); + + /* Expand the colormap indexes to real data */ + inptr = image_ptr[0]; + outptr = source->pub.buffer[0]; + for (col = cinfo->image_width; col > 0; col--) { + t = GETJSAMPLE(*inptr++); + *outptr++ = colormap[0][t]; /* can omit GETJSAMPLE() safely */ + *outptr++ = colormap[1][t]; + *outptr++ = colormap[2][t]; + } + + return 1; +} + + +METHODDEF(JDIMENSION) +get_24bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading 24-bit pixels */ +{ + bmp_source_ptr source = (bmp_source_ptr) sinfo; + JSAMPARRAY image_ptr; + register JSAMPROW inptr, outptr; + register JDIMENSION col; + + /* Fetch next row from virtual array */ + source->source_row--; + image_ptr = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, source->whole_image, + source->source_row, (JDIMENSION) 1, FALSE); + + /* Transfer data. Note source values are in BGR order + * (even though Microsoft's own documents say the opposite). + */ + inptr = image_ptr[0]; + outptr = source->pub.buffer[0]; + for (col = cinfo->image_width; col > 0; col--) { + outptr[2] = *inptr++; /* can omit GETJSAMPLE() safely */ + outptr[1] = *inptr++; + outptr[0] = *inptr++; + outptr += 3; + } + + return 1; +} + + +/* + * This method loads the image into whole_image during the first call on + * get_pixel_rows. The get_pixel_rows pointer is then adjusted to call + * get_8bit_row or get_24bit_row on subsequent calls. + */ + +METHODDEF(JDIMENSION) +preload_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + bmp_source_ptr source = (bmp_source_ptr) sinfo; + register FILE *infile = source->pub.input_file; + register int c; + register JSAMPROW out_ptr; + JSAMPARRAY image_ptr; + JDIMENSION row, col; + cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; + + /* Read the data into a virtual array in input-file row order. */ + for (row = 0; row < cinfo->image_height; row++) { + if (progress != NULL) { + progress->pub.pass_counter = (long) row; + progress->pub.pass_limit = (long) cinfo->image_height; + (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); + } + image_ptr = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, source->whole_image, + row, (JDIMENSION) 1, TRUE); + out_ptr = image_ptr[0]; + for (col = source->row_width; col > 0; col--) { + /* inline copy of read_byte() for speed */ + if ((c = getc(infile)) == EOF) + ERREXIT(cinfo, JERR_INPUT_EOF); + *out_ptr++ = (JSAMPLE) c; + } + } + if (progress != NULL) + progress->completed_extra_passes++; + + /* Set up to read from the virtual array in top-to-bottom order */ + switch (source->bits_per_pixel) { + case 8: + source->pub.get_pixel_rows = get_8bit_row; + break; + case 24: + source->pub.get_pixel_rows = get_24bit_row; + break; + default: + ERREXIT(cinfo, JERR_BMP_BADDEPTH); + } + source->source_row = cinfo->image_height; + + /* And read the first row */ + return (*source->pub.get_pixel_rows) (cinfo, sinfo); +} + + +/* + * Read the file header; return image size and component count. + */ + +METHODDEF(void) +start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + bmp_source_ptr source = (bmp_source_ptr) sinfo; + U_CHAR bmpfileheader[14]; + U_CHAR bmpinfoheader[64]; +#define GET_2B(array,offset) ((unsigned int) UCH(array[offset]) + \ + (((unsigned int) UCH(array[offset+1])) << 8)) +#define GET_4B(array,offset) ((INT32) UCH(array[offset]) + \ + (((INT32) UCH(array[offset+1])) << 8) + \ + (((INT32) UCH(array[offset+2])) << 16) + \ + (((INT32) UCH(array[offset+3])) << 24)) + INT32 bfOffBits; + INT32 headerSize; + INT32 biWidth = 0; /* initialize to avoid compiler warning */ + INT32 biHeight = 0; + unsigned int biPlanes; + INT32 biCompression; + INT32 biXPelsPerMeter,biYPelsPerMeter; + INT32 biClrUsed = 0; + int mapentrysize = 0; /* 0 indicates no colormap */ + INT32 bPad; + JDIMENSION row_width; + + /* Read and verify the bitmap file header */ + if (! ReadOK(source->pub.input_file, bmpfileheader, 14)) + ERREXIT(cinfo, JERR_INPUT_EOF); + if (GET_2B(bmpfileheader,0) != 0x4D42) /* 'BM' */ + ERREXIT(cinfo, JERR_BMP_NOT); + bfOffBits = (INT32) GET_4B(bmpfileheader,10); + /* We ignore the remaining fileheader fields */ + + /* The infoheader might be 12 bytes (OS/2 1.x), 40 bytes (Windows), + * or 64 bytes (OS/2 2.x). Check the first 4 bytes to find out which. + */ + if (! ReadOK(source->pub.input_file, bmpinfoheader, 4)) + ERREXIT(cinfo, JERR_INPUT_EOF); + headerSize = (INT32) GET_4B(bmpinfoheader,0); + if (headerSize < 12 || headerSize > 64) + ERREXIT(cinfo, JERR_BMP_BADHEADER); + if (! ReadOK(source->pub.input_file, bmpinfoheader+4, headerSize-4)) + ERREXIT(cinfo, JERR_INPUT_EOF); + + switch ((int) headerSize) { + case 12: + /* Decode OS/2 1.x header (Microsoft calls this a BITMAPCOREHEADER) */ + biWidth = (INT32) GET_2B(bmpinfoheader,4); + biHeight = (INT32) GET_2B(bmpinfoheader,6); + biPlanes = GET_2B(bmpinfoheader,8); + source->bits_per_pixel = (int) GET_2B(bmpinfoheader,10); + + switch (source->bits_per_pixel) { + case 8: /* colormapped image */ + mapentrysize = 3; /* OS/2 uses RGBTRIPLE colormap */ + TRACEMS2(cinfo, 1, JTRC_BMP_OS2_MAPPED, (int) biWidth, (int) biHeight); + break; + case 24: /* RGB image */ + TRACEMS2(cinfo, 1, JTRC_BMP_OS2, (int) biWidth, (int) biHeight); + break; + default: + ERREXIT(cinfo, JERR_BMP_BADDEPTH); + break; + } + if (biPlanes != 1) + ERREXIT(cinfo, JERR_BMP_BADPLANES); + break; + case 40: + case 64: + /* Decode Windows 3.x header (Microsoft calls this a BITMAPINFOHEADER) */ + /* or OS/2 2.x header, which has additional fields that we ignore */ + biWidth = GET_4B(bmpinfoheader,4); + biHeight = GET_4B(bmpinfoheader,8); + biPlanes = GET_2B(bmpinfoheader,12); + source->bits_per_pixel = (int) GET_2B(bmpinfoheader,14); + biCompression = GET_4B(bmpinfoheader,16); + biXPelsPerMeter = GET_4B(bmpinfoheader,24); + biYPelsPerMeter = GET_4B(bmpinfoheader,28); + biClrUsed = GET_4B(bmpinfoheader,32); + /* biSizeImage, biClrImportant fields are ignored */ + + switch (source->bits_per_pixel) { + case 8: /* colormapped image */ + mapentrysize = 4; /* Windows uses RGBQUAD colormap */ + TRACEMS2(cinfo, 1, JTRC_BMP_MAPPED, (int) biWidth, (int) biHeight); + break; + case 24: /* RGB image */ + TRACEMS2(cinfo, 1, JTRC_BMP, (int) biWidth, (int) biHeight); + break; + default: + ERREXIT(cinfo, JERR_BMP_BADDEPTH); + break; + } + if (biPlanes != 1) + ERREXIT(cinfo, JERR_BMP_BADPLANES); + if (biCompression != 0) + ERREXIT(cinfo, JERR_BMP_COMPRESSED); + + if (biXPelsPerMeter > 0 && biYPelsPerMeter > 0) { + /* Set JFIF density parameters from the BMP data */ + cinfo->X_density = (UINT16) (biXPelsPerMeter/100); /* 100 cm per meter */ + cinfo->Y_density = (UINT16) (biYPelsPerMeter/100); + cinfo->density_unit = 2; /* dots/cm */ + } + break; + default: + ERREXIT(cinfo, JERR_BMP_BADHEADER); + break; + } + + /* Compute distance to bitmap data --- will adjust for colormap below */ + bPad = bfOffBits - (headerSize + 14); + + /* Read the colormap, if any */ + if (mapentrysize > 0) { + if (biClrUsed <= 0) + biClrUsed = 256; /* assume it's 256 */ + else if (biClrUsed > 256) + ERREXIT(cinfo, JERR_BMP_BADCMAP); + /* Allocate space to store the colormap */ + source->colormap = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) biClrUsed, (JDIMENSION) 3); + /* and read it from the file */ + read_colormap(source, (int) biClrUsed, mapentrysize); + /* account for size of colormap */ + bPad -= biClrUsed * mapentrysize; + } + + /* Skip any remaining pad bytes */ + if (bPad < 0) /* incorrect bfOffBits value? */ + ERREXIT(cinfo, JERR_BMP_BADHEADER); + while (--bPad >= 0) { + (void) read_byte(source); + } + + /* Compute row width in file, including padding to 4-byte boundary */ + if (source->bits_per_pixel == 24) + row_width = (JDIMENSION) (biWidth * 3); + else + row_width = (JDIMENSION) biWidth; + while ((row_width & 3) != 0) row_width++; + source->row_width = row_width; + + /* Allocate space for inversion array, prepare for preload pass */ + source->whole_image = (*cinfo->mem->request_virt_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, + row_width, (JDIMENSION) biHeight, (JDIMENSION) 1); + source->pub.get_pixel_rows = preload_image; + if (cinfo->progress != NULL) { + cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; + progress->total_extra_passes++; /* count file input as separate pass */ + } + + /* Allocate one-row buffer for returned data */ + source->pub.buffer = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) (biWidth * 3), (JDIMENSION) 1); + source->pub.buffer_height = 1; + + cinfo->in_color_space = JCS_RGB; + cinfo->input_components = 3; + cinfo->data_precision = 8; + cinfo->image_width = (JDIMENSION) biWidth; + cinfo->image_height = (JDIMENSION) biHeight; +} + + +/* + * Finish up at the end of the file. + */ + +METHODDEF(void) +finish_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + /* no work */ +} + + +/* + * The module selection routine for BMP format input. + */ + +GLOBAL(cjpeg_source_ptr) +jinit_read_bmp (j_compress_ptr cinfo) +{ + bmp_source_ptr source; + + /* Create module interface object */ + source = (bmp_source_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(bmp_source_struct)); + source->cinfo = cinfo; /* make back link for subroutines */ + /* Fill in method ptrs, except get_pixel_rows which start_input sets */ + source->pub.start_input = start_input_bmp; + source->pub.finish_input = finish_input_bmp; + + return (cjpeg_source_ptr) source; +} + +#endif /* BMP_SUPPORTED */ diff --git a/gs/jpeg/rdcolmap.c b/gs/jpeg/rdcolmap.c new file mode 100644 index 000000000..f79458edc --- /dev/null +++ b/gs/jpeg/rdcolmap.c @@ -0,0 +1,253 @@ +/* + * rdcolmap.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file implements djpeg's "-map file" switch. It reads a source image + * and constructs a colormap to be supplied to the JPEG decompressor. + * + * Currently, these file formats are supported for the map file: + * GIF: the contents of the GIF's global colormap are used. + * PPM (either text or raw flavor): the entire file is read and + * each unique pixel value is entered in the map. + * Note that reading a large PPM file will be horrendously slow. + * Typically, a PPM-format map file should contain just one pixel + * of each desired color. Such a file can be extracted from an + * ordinary image PPM file with ppmtomap(1). + * + * Rescaling a PPM that has a maxval unequal to MAXJSAMPLE is not + * currently implemented. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ + +#ifdef QUANT_2PASS_SUPPORTED /* otherwise can't quantize to supplied map */ + +/* Portions of this code are based on the PBMPLUS library, which is: +** +** Copyright (C) 1988 by Jef Poskanzer. +** +** Permission to use, copy, modify, and distribute this software and its +** documentation for any purpose and without fee is hereby granted, provided +** that the above copyright notice appear in all copies and that both that +** copyright notice and this permission notice appear in supporting +** documentation. This software is provided "as is" without express or +** implied warranty. +*/ + + +/* + * Add a (potentially) new color to the color map. + */ + +LOCAL(void) +add_map_entry (j_decompress_ptr cinfo, int R, int G, int B) +{ + JSAMPROW colormap0 = cinfo->colormap[0]; + JSAMPROW colormap1 = cinfo->colormap[1]; + JSAMPROW colormap2 = cinfo->colormap[2]; + int ncolors = cinfo->actual_number_of_colors; + int index; + + /* Check for duplicate color. */ + for (index = 0; index < ncolors; index++) { + if (GETJSAMPLE(colormap0[index]) == R && + GETJSAMPLE(colormap1[index]) == G && + GETJSAMPLE(colormap2[index]) == B) + return; /* color is already in map */ + } + + /* Check for map overflow. */ + if (ncolors >= (MAXJSAMPLE+1)) + ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, (MAXJSAMPLE+1)); + + /* OK, add color to map. */ + colormap0[ncolors] = (JSAMPLE) R; + colormap1[ncolors] = (JSAMPLE) G; + colormap2[ncolors] = (JSAMPLE) B; + cinfo->actual_number_of_colors++; +} + + +/* + * Extract color map from a GIF file. + */ + +LOCAL(void) +read_gif_map (j_decompress_ptr cinfo, FILE * infile) +{ + int header[13]; + int i, colormaplen; + int R, G, B; + + /* Initial 'G' has already been read by read_color_map */ + /* Read the rest of the GIF header and logical screen descriptor */ + for (i = 1; i < 13; i++) { + if ((header[i] = getc(infile)) == EOF) + ERREXIT(cinfo, JERR_BAD_CMAP_FILE); + } + + /* Verify GIF Header */ + if (header[1] != 'I' || header[2] != 'F') + ERREXIT(cinfo, JERR_BAD_CMAP_FILE); + + /* There must be a global color map. */ + if ((header[10] & 0x80) == 0) + ERREXIT(cinfo, JERR_BAD_CMAP_FILE); + + /* OK, fetch it. */ + colormaplen = 2 << (header[10] & 0x07); + + for (i = 0; i < colormaplen; i++) { + R = getc(infile); + G = getc(infile); + B = getc(infile); + if (R == EOF || G == EOF || B == EOF) + ERREXIT(cinfo, JERR_BAD_CMAP_FILE); + add_map_entry(cinfo, + R << (BITS_IN_JSAMPLE-8), + G << (BITS_IN_JSAMPLE-8), + B << (BITS_IN_JSAMPLE-8)); + } +} + + +/* Support routines for reading PPM */ + + +LOCAL(int) +pbm_getc (FILE * infile) +/* Read next char, skipping over any comments */ +/* A comment/newline sequence is returned as a newline */ +{ + register int ch; + + ch = getc(infile); + if (ch == '#') { + do { + ch = getc(infile); + } while (ch != '\n' && ch != EOF); + } + return ch; +} + + +LOCAL(unsigned int) +read_pbm_integer (j_decompress_ptr cinfo, FILE * infile) +/* Read an unsigned decimal integer from the PPM file */ +/* Swallows one trailing character after the integer */ +/* Note that on a 16-bit-int machine, only values up to 64k can be read. */ +/* This should not be a problem in practice. */ +{ + register int ch; + register unsigned int val; + + /* Skip any leading whitespace */ + do { + ch = pbm_getc(infile); + if (ch == EOF) + ERREXIT(cinfo, JERR_BAD_CMAP_FILE); + } while (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'); + + if (ch < '0' || ch > '9') + ERREXIT(cinfo, JERR_BAD_CMAP_FILE); + + val = ch - '0'; + while ((ch = pbm_getc(infile)) >= '0' && ch <= '9') { + val *= 10; + val += ch - '0'; + } + return val; +} + + +/* + * Extract color map from a PPM file. + */ + +LOCAL(void) +read_ppm_map (j_decompress_ptr cinfo, FILE * infile) +{ + int c; + unsigned int w, h, maxval, row, col; + int R, G, B; + + /* Initial 'P' has already been read by read_color_map */ + c = getc(infile); /* save format discriminator for a sec */ + + /* while we fetch the remaining header info */ + w = read_pbm_integer(cinfo, infile); + h = read_pbm_integer(cinfo, infile); + maxval = read_pbm_integer(cinfo, infile); + + if (w <= 0 || h <= 0 || maxval <= 0) /* error check */ + ERREXIT(cinfo, JERR_BAD_CMAP_FILE); + + /* For now, we don't support rescaling from an unusual maxval. */ + if (maxval != (unsigned int) MAXJSAMPLE) + ERREXIT(cinfo, JERR_BAD_CMAP_FILE); + + switch (c) { + case '3': /* it's a text-format PPM file */ + for (row = 0; row < h; row++) { + for (col = 0; col < w; col++) { + R = read_pbm_integer(cinfo, infile); + G = read_pbm_integer(cinfo, infile); + B = read_pbm_integer(cinfo, infile); + add_map_entry(cinfo, R, G, B); + } + } + break; + + case '6': /* it's a raw-format PPM file */ + for (row = 0; row < h; row++) { + for (col = 0; col < w; col++) { + R = pbm_getc(infile); + G = pbm_getc(infile); + B = pbm_getc(infile); + if (R == EOF || G == EOF || B == EOF) + ERREXIT(cinfo, JERR_BAD_CMAP_FILE); + add_map_entry(cinfo, R, G, B); + } + } + break; + + default: + ERREXIT(cinfo, JERR_BAD_CMAP_FILE); + break; + } +} + + +/* + * Main entry point from djpeg.c. + * Input: opened input file (from file name argument on command line). + * Output: colormap and actual_number_of_colors fields are set in cinfo. + */ + +GLOBAL(void) +read_color_map (j_decompress_ptr cinfo, FILE * infile) +{ + /* Allocate space for a color map of maximum supported size. */ + cinfo->colormap = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) (MAXJSAMPLE+1), (JDIMENSION) 3); + cinfo->actual_number_of_colors = 0; /* initialize map to empty */ + + /* Read first byte to determine file format */ + switch (getc(infile)) { + case 'G': + read_gif_map(cinfo, infile); + break; + case 'P': + read_ppm_map(cinfo, infile); + break; + default: + ERREXIT(cinfo, JERR_BAD_CMAP_FILE); + break; + } +} + +#endif /* QUANT_2PASS_SUPPORTED */ diff --git a/gs/jpeg/rdgif.c b/gs/jpeg/rdgif.c new file mode 100644 index 000000000..0da2515cb --- /dev/null +++ b/gs/jpeg/rdgif.c @@ -0,0 +1,683 @@ +/* + * rdgif.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + ************************************************************************** + * WARNING: You will need an LZW patent license from Unisys in order to * + * use this file legally in any commercial or shareware application. * + ************************************************************************** + * + * This file contains routines to read input images in GIF format. + * + * These routines may need modification for non-Unix environments or + * specialized applications. As they stand, they assume input from + * an ordinary stdio stream. They further assume that reading begins + * at the start of the file; input_init may need work if the + * user interface has already read some data (e.g., to determine that + * the file is indeed GIF format). + */ + +/* + * This code is loosely based on giftoppm from the PBMPLUS distribution + * of Feb. 1991. That file contains the following copyright notice: + * +-------------------------------------------------------------------+ + * | Copyright 1990, David Koblas. | + * | Permission to use, copy, modify, and distribute this software | + * | and its documentation for any purpose and without fee is hereby | + * | granted, provided that the above copyright notice appear in all | + * | copies and that both that copyright notice and this permission | + * | notice appear in supporting documentation. This software is | + * | provided "as is" without express or implied warranty. | + * +-------------------------------------------------------------------+ + * + * We are also required to state that + * "The Graphics Interchange Format(c) is the Copyright property of + * CompuServe Incorporated. GIF(sm) is a Service Mark property of + * CompuServe Incorporated." + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ + +#ifdef GIF_SUPPORTED + + +#define MAXCOLORMAPSIZE 256 /* max # of colors in a GIF colormap */ +#define NUMCOLORS 3 /* # of colors */ +#define CM_RED 0 /* color component numbers */ +#define CM_GREEN 1 +#define CM_BLUE 2 + +#define MAX_LZW_BITS 12 /* maximum LZW code size */ +#define LZW_TABLE_SIZE (1< table of prefix symbols */ + UINT8 FAR *symbol_tail; /* => table of suffix bytes */ + UINT8 FAR *symbol_stack; /* => stack for symbol expansions */ + UINT8 FAR *sp; /* stack pointer */ + + /* State for interlaced image processing */ + boolean is_interlaced; /* TRUE if have interlaced image */ + jvirt_sarray_ptr interlaced_image; /* full image in interlaced order */ + JDIMENSION cur_row_number; /* need to know actual row number */ + JDIMENSION pass2_offset; /* # of pixel rows in pass 1 */ + JDIMENSION pass3_offset; /* # of pixel rows in passes 1&2 */ + JDIMENSION pass4_offset; /* # of pixel rows in passes 1,2,3 */ +} gif_source_struct; + +typedef gif_source_struct * gif_source_ptr; + + +/* Forward declarations */ +METHODDEF(JDIMENSION) get_pixel_rows + JPP((j_compress_ptr cinfo, cjpeg_source_ptr sinfo)); +METHODDEF(JDIMENSION) load_interlaced_image + JPP((j_compress_ptr cinfo, cjpeg_source_ptr sinfo)); +METHODDEF(JDIMENSION) get_interlaced_row + JPP((j_compress_ptr cinfo, cjpeg_source_ptr sinfo)); + + +LOCAL(int) +ReadByte (gif_source_ptr sinfo) +/* Read next byte from GIF file */ +{ + register FILE * infile = sinfo->pub.input_file; + int c; + + if ((c = getc(infile)) == EOF) + ERREXIT(sinfo->cinfo, JERR_INPUT_EOF); + return c; +} + + +LOCAL(int) +GetDataBlock (gif_source_ptr sinfo, char *buf) +/* Read a GIF data block, which has a leading count byte */ +/* A zero-length block marks the end of a data block sequence */ +{ + int count; + + count = ReadByte(sinfo); + if (count > 0) { + if (! ReadOK(sinfo->pub.input_file, buf, count)) + ERREXIT(sinfo->cinfo, JERR_INPUT_EOF); + } + return count; +} + + +LOCAL(void) +SkipDataBlocks (gif_source_ptr sinfo) +/* Skip a series of data blocks, until a block terminator is found */ +{ + char buf[256]; + + while (GetDataBlock(sinfo, buf) > 0) + /* skip */; +} + + +LOCAL(void) +ReInitLZW (gif_source_ptr sinfo) +/* (Re)initialize LZW state; shared code for startup and Clear processing */ +{ + sinfo->code_size = sinfo->input_code_size + 1; + sinfo->limit_code = sinfo->clear_code << 1; /* 2^code_size */ + sinfo->max_code = sinfo->clear_code + 2; /* first unused code value */ + sinfo->sp = sinfo->symbol_stack; /* init stack to empty */ +} + + +LOCAL(void) +InitLZWCode (gif_source_ptr sinfo) +/* Initialize for a series of LZWReadByte (and hence GetCode) calls */ +{ + /* GetCode initialization */ + sinfo->last_byte = 2; /* make safe to "recopy last two bytes" */ + sinfo->last_bit = 0; /* nothing in the buffer */ + sinfo->cur_bit = 0; /* force buffer load on first call */ + sinfo->out_of_blocks = FALSE; + + /* LZWReadByte initialization: */ + /* compute special code values (note that these do not change later) */ + sinfo->clear_code = 1 << sinfo->input_code_size; + sinfo->end_code = sinfo->clear_code + 1; + sinfo->first_time = TRUE; + ReInitLZW(sinfo); +} + + +LOCAL(int) +GetCode (gif_source_ptr sinfo) +/* Fetch the next code_size bits from the GIF data */ +/* We assume code_size is less than 16 */ +{ + register INT32 accum; + int offs, ret, count; + + while ( (sinfo->cur_bit + sinfo->code_size) > sinfo->last_bit) { + /* Time to reload the buffer */ + if (sinfo->out_of_blocks) { + WARNMS(sinfo->cinfo, JWRN_GIF_NOMOREDATA); + return sinfo->end_code; /* fake something useful */ + } + /* preserve last two bytes of what we have -- assume code_size <= 16 */ + sinfo->code_buf[0] = sinfo->code_buf[sinfo->last_byte-2]; + sinfo->code_buf[1] = sinfo->code_buf[sinfo->last_byte-1]; + /* Load more bytes; set flag if we reach the terminator block */ + if ((count = GetDataBlock(sinfo, &sinfo->code_buf[2])) == 0) { + sinfo->out_of_blocks = TRUE; + WARNMS(sinfo->cinfo, JWRN_GIF_NOMOREDATA); + return sinfo->end_code; /* fake something useful */ + } + /* Reset counters */ + sinfo->cur_bit = (sinfo->cur_bit - sinfo->last_bit) + 16; + sinfo->last_byte = 2 + count; + sinfo->last_bit = sinfo->last_byte * 8; + } + + /* Form up next 24 bits in accum */ + offs = sinfo->cur_bit >> 3; /* byte containing cur_bit */ +#ifdef CHAR_IS_UNSIGNED + accum = sinfo->code_buf[offs+2]; + accum <<= 8; + accum |= sinfo->code_buf[offs+1]; + accum <<= 8; + accum |= sinfo->code_buf[offs]; +#else + accum = sinfo->code_buf[offs+2] & 0xFF; + accum <<= 8; + accum |= sinfo->code_buf[offs+1] & 0xFF; + accum <<= 8; + accum |= sinfo->code_buf[offs] & 0xFF; +#endif + + /* Right-align cur_bit in accum, then mask off desired number of bits */ + accum >>= (sinfo->cur_bit & 7); + ret = ((int) accum) & ((1 << sinfo->code_size) - 1); + + sinfo->cur_bit += sinfo->code_size; + return ret; +} + + +LOCAL(int) +LZWReadByte (gif_source_ptr sinfo) +/* Read an LZW-compressed byte */ +{ + register int code; /* current working code */ + int incode; /* saves actual input code */ + + /* First time, just eat the expected Clear code(s) and return next code, */ + /* which is expected to be a raw byte. */ + if (sinfo->first_time) { + sinfo->first_time = FALSE; + code = sinfo->clear_code; /* enables sharing code with Clear case */ + } else { + + /* If any codes are stacked from a previously read symbol, return them */ + if (sinfo->sp > sinfo->symbol_stack) + return (int) *(-- sinfo->sp); + + /* Time to read a new symbol */ + code = GetCode(sinfo); + + } + + if (code == sinfo->clear_code) { + /* Reinit state, swallow any extra Clear codes, and */ + /* return next code, which is expected to be a raw byte. */ + ReInitLZW(sinfo); + do { + code = GetCode(sinfo); + } while (code == sinfo->clear_code); + if (code > sinfo->clear_code) { /* make sure it is a raw byte */ + WARNMS(sinfo->cinfo, JWRN_GIF_BADDATA); + code = 0; /* use something valid */ + } + /* make firstcode, oldcode valid! */ + sinfo->firstcode = sinfo->oldcode = code; + return code; + } + + if (code == sinfo->end_code) { + /* Skip the rest of the image, unless GetCode already read terminator */ + if (! sinfo->out_of_blocks) { + SkipDataBlocks(sinfo); + sinfo->out_of_blocks = TRUE; + } + /* Complain that there's not enough data */ + WARNMS(sinfo->cinfo, JWRN_GIF_ENDCODE); + /* Pad data with 0's */ + return 0; /* fake something usable */ + } + + /* Got normal raw byte or LZW symbol */ + incode = code; /* save for a moment */ + + if (code >= sinfo->max_code) { /* special case for not-yet-defined symbol */ + /* code == max_code is OK; anything bigger is bad data */ + if (code > sinfo->max_code) { + WARNMS(sinfo->cinfo, JWRN_GIF_BADDATA); + incode = 0; /* prevent creation of loops in symbol table */ + } + /* this symbol will be defined as oldcode/firstcode */ + *(sinfo->sp++) = (UINT8) sinfo->firstcode; + code = sinfo->oldcode; + } + + /* If it's a symbol, expand it into the stack */ + while (code >= sinfo->clear_code) { + *(sinfo->sp++) = sinfo->symbol_tail[code]; /* tail is a byte value */ + code = sinfo->symbol_head[code]; /* head is another LZW symbol */ + } + /* At this point code just represents a raw byte */ + sinfo->firstcode = code; /* save for possible future use */ + + /* If there's room in table, */ + if ((code = sinfo->max_code) < LZW_TABLE_SIZE) { + /* Define a new symbol = prev sym + head of this sym's expansion */ + sinfo->symbol_head[code] = sinfo->oldcode; + sinfo->symbol_tail[code] = (UINT8) sinfo->firstcode; + sinfo->max_code++; + /* Is it time to increase code_size? */ + if ((sinfo->max_code >= sinfo->limit_code) && + (sinfo->code_size < MAX_LZW_BITS)) { + sinfo->code_size++; + sinfo->limit_code <<= 1; /* keep equal to 2^code_size */ + } + } + + sinfo->oldcode = incode; /* save last input symbol for future use */ + return sinfo->firstcode; /* return first byte of symbol's expansion */ +} + + +LOCAL(void) +ReadColorMap (gif_source_ptr sinfo, int cmaplen, JSAMPARRAY cmap) +/* Read a GIF colormap */ +{ + int i; + + for (i = 0; i < cmaplen; i++) { +#if BITS_IN_JSAMPLE == 8 +#define UPSCALE(x) (x) +#else +#define UPSCALE(x) ((x) << (BITS_IN_JSAMPLE-8)) +#endif + cmap[CM_RED][i] = (JSAMPLE) UPSCALE(ReadByte(sinfo)); + cmap[CM_GREEN][i] = (JSAMPLE) UPSCALE(ReadByte(sinfo)); + cmap[CM_BLUE][i] = (JSAMPLE) UPSCALE(ReadByte(sinfo)); + } +} + + +LOCAL(void) +DoExtension (gif_source_ptr sinfo) +/* Process an extension block */ +/* Currently we ignore 'em all */ +{ + int extlabel; + + /* Read extension label byte */ + extlabel = ReadByte(sinfo); + TRACEMS1(sinfo->cinfo, 1, JTRC_GIF_EXTENSION, extlabel); + /* Skip the data block(s) associated with the extension */ + SkipDataBlocks(sinfo); +} + + +/* + * Read the file header; return image size and component count. + */ + +METHODDEF(void) +start_input_gif (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + gif_source_ptr source = (gif_source_ptr) sinfo; + char hdrbuf[10]; /* workspace for reading control blocks */ + unsigned int width, height; /* image dimensions */ + int colormaplen, aspectRatio; + int c; + + /* Allocate space to store the colormap */ + source->colormap = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) MAXCOLORMAPSIZE, (JDIMENSION) NUMCOLORS); + + /* Read and verify GIF Header */ + if (! ReadOK(source->pub.input_file, hdrbuf, 6)) + ERREXIT(cinfo, JERR_GIF_NOT); + if (hdrbuf[0] != 'G' || hdrbuf[1] != 'I' || hdrbuf[2] != 'F') + ERREXIT(cinfo, JERR_GIF_NOT); + /* Check for expected version numbers. + * If unknown version, give warning and try to process anyway; + * this is per recommendation in GIF89a standard. + */ + if ((hdrbuf[3] != '8' || hdrbuf[4] != '7' || hdrbuf[5] != 'a') && + (hdrbuf[3] != '8' || hdrbuf[4] != '9' || hdrbuf[5] != 'a')) + TRACEMS3(cinfo, 1, JTRC_GIF_BADVERSION, hdrbuf[3], hdrbuf[4], hdrbuf[5]); + + /* Read and decipher Logical Screen Descriptor */ + if (! ReadOK(source->pub.input_file, hdrbuf, 7)) + ERREXIT(cinfo, JERR_INPUT_EOF); + width = LM_to_uint(hdrbuf[0],hdrbuf[1]); + height = LM_to_uint(hdrbuf[2],hdrbuf[3]); + colormaplen = 2 << (hdrbuf[4] & 0x07); + /* we ignore the color resolution, sort flag, and background color index */ + aspectRatio = hdrbuf[6] & 0xFF; + if (aspectRatio != 0 && aspectRatio != 49) + TRACEMS(cinfo, 1, JTRC_GIF_NONSQUARE); + + /* Read global colormap if header indicates it is present */ + if (BitSet(hdrbuf[4], COLORMAPFLAG)) + ReadColorMap(source, colormaplen, source->colormap); + + /* Scan until we reach start of desired image. + * We don't currently support skipping images, but could add it easily. + */ + for (;;) { + c = ReadByte(source); + + if (c == ';') /* GIF terminator?? */ + ERREXIT(cinfo, JERR_GIF_IMAGENOTFOUND); + + if (c == '!') { /* Extension */ + DoExtension(source); + continue; + } + + if (c != ',') { /* Not an image separator? */ + WARNMS1(cinfo, JWRN_GIF_CHAR, c); + continue; + } + + /* Read and decipher Local Image Descriptor */ + if (! ReadOK(source->pub.input_file, hdrbuf, 9)) + ERREXIT(cinfo, JERR_INPUT_EOF); + /* we ignore top/left position info, also sort flag */ + width = LM_to_uint(hdrbuf[4],hdrbuf[5]); + height = LM_to_uint(hdrbuf[6],hdrbuf[7]); + source->is_interlaced = BitSet(hdrbuf[8], INTERLACE); + + /* Read local colormap if header indicates it is present */ + /* Note: if we wanted to support skipping images, */ + /* we'd need to skip rather than read colormap for ignored images */ + if (BitSet(hdrbuf[8], COLORMAPFLAG)) { + colormaplen = 2 << (hdrbuf[8] & 0x07); + ReadColorMap(source, colormaplen, source->colormap); + } + + source->input_code_size = ReadByte(source); /* get min-code-size byte */ + if (source->input_code_size < 2 || source->input_code_size >= MAX_LZW_BITS) + ERREXIT1(cinfo, JERR_GIF_CODESIZE, source->input_code_size); + + /* Reached desired image, so break out of loop */ + /* If we wanted to skip this image, */ + /* we'd call SkipDataBlocks and then continue the loop */ + break; + } + + /* Prepare to read selected image: first initialize LZW decompressor */ + source->symbol_head = (UINT16 FAR *) + (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, + LZW_TABLE_SIZE * SIZEOF(UINT16)); + source->symbol_tail = (UINT8 FAR *) + (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, + LZW_TABLE_SIZE * SIZEOF(UINT8)); + source->symbol_stack = (UINT8 FAR *) + (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, + LZW_TABLE_SIZE * SIZEOF(UINT8)); + InitLZWCode(source); + + /* + * If image is interlaced, we read it into a full-size sample array, + * decompressing as we go; then get_interlaced_row selects rows from the + * sample array in the proper order. + */ + if (source->is_interlaced) { + /* We request the virtual array now, but can't access it until virtual + * arrays have been allocated. Hence, the actual work of reading the + * image is postponed until the first call to get_pixel_rows. + */ + source->interlaced_image = (*cinfo->mem->request_virt_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, + (JDIMENSION) width, (JDIMENSION) height, (JDIMENSION) 1); + if (cinfo->progress != NULL) { + cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; + progress->total_extra_passes++; /* count file input as separate pass */ + } + source->pub.get_pixel_rows = load_interlaced_image; + } else { + source->pub.get_pixel_rows = get_pixel_rows; + } + + /* Create compressor input buffer. */ + source->pub.buffer = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) width * NUMCOLORS, (JDIMENSION) 1); + source->pub.buffer_height = 1; + + /* Return info about the image. */ + cinfo->in_color_space = JCS_RGB; + cinfo->input_components = NUMCOLORS; + cinfo->data_precision = BITS_IN_JSAMPLE; /* we always rescale data to this */ + cinfo->image_width = width; + cinfo->image_height = height; + + TRACEMS3(cinfo, 1, JTRC_GIF, width, height, colormaplen); +} + + +/* + * Read one row of pixels. + * This version is used for noninterlaced GIF images: + * we read directly from the GIF file. + */ + +METHODDEF(JDIMENSION) +get_pixel_rows (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + gif_source_ptr source = (gif_source_ptr) sinfo; + register int c; + register JSAMPROW ptr; + register JDIMENSION col; + register JSAMPARRAY colormap = source->colormap; + + ptr = source->pub.buffer[0]; + for (col = cinfo->image_width; col > 0; col--) { + c = LZWReadByte(source); + *ptr++ = colormap[CM_RED][c]; + *ptr++ = colormap[CM_GREEN][c]; + *ptr++ = colormap[CM_BLUE][c]; + } + return 1; +} + + +/* + * Read one row of pixels. + * This version is used for the first call on get_pixel_rows when + * reading an interlaced GIF file: we read the whole image into memory. + */ + +METHODDEF(JDIMENSION) +load_interlaced_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + gif_source_ptr source = (gif_source_ptr) sinfo; + JSAMPARRAY image_ptr; + register JSAMPROW sptr; + register JDIMENSION col; + JDIMENSION row; + cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; + + /* Read the interlaced image into the virtual array we've created. */ + for (row = 0; row < cinfo->image_height; row++) { + if (progress != NULL) { + progress->pub.pass_counter = (long) row; + progress->pub.pass_limit = (long) cinfo->image_height; + (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); + } + image_ptr = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, source->interlaced_image, + row, (JDIMENSION) 1, TRUE); + sptr = image_ptr[0]; + for (col = cinfo->image_width; col > 0; col--) { + *sptr++ = (JSAMPLE) LZWReadByte(source); + } + } + if (progress != NULL) + progress->completed_extra_passes++; + + /* Replace method pointer so subsequent calls don't come here. */ + source->pub.get_pixel_rows = get_interlaced_row; + /* Initialize for get_interlaced_row, and perform first call on it. */ + source->cur_row_number = 0; + source->pass2_offset = (cinfo->image_height + 7) / 8; + source->pass3_offset = source->pass2_offset + (cinfo->image_height + 3) / 8; + source->pass4_offset = source->pass3_offset + (cinfo->image_height + 1) / 4; + + return get_interlaced_row(cinfo, sinfo); +} + + +/* + * Read one row of pixels. + * This version is used for interlaced GIF images: + * we read from the virtual array. + */ + +METHODDEF(JDIMENSION) +get_interlaced_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + gif_source_ptr source = (gif_source_ptr) sinfo; + JSAMPARRAY image_ptr; + register int c; + register JSAMPROW sptr, ptr; + register JDIMENSION col; + register JSAMPARRAY colormap = source->colormap; + JDIMENSION irow; + + /* Figure out which row of interlaced image is needed, and access it. */ + switch ((int) (source->cur_row_number & 7)) { + case 0: /* first-pass row */ + irow = source->cur_row_number >> 3; + break; + case 4: /* second-pass row */ + irow = (source->cur_row_number >> 3) + source->pass2_offset; + break; + case 2: /* third-pass row */ + case 6: + irow = (source->cur_row_number >> 2) + source->pass3_offset; + break; + default: /* fourth-pass row */ + irow = (source->cur_row_number >> 1) + source->pass4_offset; + break; + } + image_ptr = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, source->interlaced_image, + irow, (JDIMENSION) 1, FALSE); + /* Scan the row, expand colormap, and output */ + sptr = image_ptr[0]; + ptr = source->pub.buffer[0]; + for (col = cinfo->image_width; col > 0; col--) { + c = GETJSAMPLE(*sptr++); + *ptr++ = colormap[CM_RED][c]; + *ptr++ = colormap[CM_GREEN][c]; + *ptr++ = colormap[CM_BLUE][c]; + } + source->cur_row_number++; /* for next time */ + return 1; +} + + +/* + * Finish up at the end of the file. + */ + +METHODDEF(void) +finish_input_gif (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + /* no work */ +} + + +/* + * The module selection routine for GIF format input. + */ + +GLOBAL(cjpeg_source_ptr) +jinit_read_gif (j_compress_ptr cinfo) +{ + gif_source_ptr source; + + /* Create module interface object */ + source = (gif_source_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(gif_source_struct)); + source->cinfo = cinfo; /* make back link for subroutines */ + /* Fill in method ptrs, except get_pixel_rows which start_input sets */ + source->pub.start_input = start_input_gif; + source->pub.finish_input = finish_input_gif; + + return (cjpeg_source_ptr) source; +} + +#endif /* GIF_SUPPORTED */ diff --git a/gs/jpeg/rdjpgcom b/gs/jpeg/rdjpgcom new file mode 100755 index 000000000..7b5c2ed8e Binary files /dev/null and b/gs/jpeg/rdjpgcom differ diff --git a/gs/jpeg/rdjpgcom.1 b/gs/jpeg/rdjpgcom.1 new file mode 100644 index 000000000..0de92bff8 --- /dev/null +++ b/gs/jpeg/rdjpgcom.1 @@ -0,0 +1,45 @@ +.TH RDJPGCOM 1 "15 June 1995" +.SH NAME +rdjpgcom \- display text comments from a JPEG file +.SH SYNOPSIS +.B rdjpgcom +[ +.B \-verbose +] +[ +.I filename +] +.LP +.SH DESCRIPTION +.LP +.B rdjpgcom +reads the named JPEG/JFIF file, or the standard input if no file is named, +and prints any text comments found in the file on the standard output. +.PP +The JPEG standard allows "comment" (COM) blocks to occur within a JPEG file. +Although the standard doesn't actually define what COM blocks are for, they +are widely used to hold user-supplied text strings. This lets you add +annotations, titles, index terms, etc to your JPEG files, and later retrieve +them as text. COM blocks do not interfere with the image stored in the JPEG +file. The maximum size of a COM block is 64K, but you can have as many of +them as you like in one JPEG file. +.SH OPTIONS +.TP +.B \-verbose +Causes +.B rdjpgcom +to also display the JPEG image dimensions. +.PP +Switch names may be abbreviated, and are not case sensitive. +.SH HINTS +.B rdjpgcom +does not depend on the IJG JPEG library. Its source code is intended as an +illustration of the minimum amount of code required to parse a JPEG file +header correctly. +.SH SEE ALSO +.BR cjpeg (1), +.BR djpeg (1), +.BR jpegtran (1), +.BR wrjpgcom (1) +.SH AUTHOR +Independent JPEG Group diff --git a/gs/jpeg/rdjpgcom.c b/gs/jpeg/rdjpgcom.c new file mode 100644 index 000000000..95770ec74 --- /dev/null +++ b/gs/jpeg/rdjpgcom.c @@ -0,0 +1,476 @@ +/* + * rdjpgcom.c + * + * Copyright (C) 1994-1995, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a very simple stand-alone application that displays + * the text in COM (comment) markers in a JFIF file. + * This may be useful as an example of the minimum logic needed to parse + * JPEG markers. + */ + +#define JPEG_CJPEG_DJPEG /* to get the command-line config symbols */ +#include "jinclude.h" /* get auto-config symbols, */ + +#include /* to declare isupper(), tolower() */ +#ifdef USE_SETMODE +#include /* to declare setmode()'s parameter macros */ +/* If you have setmode() but not , just delete this line: */ +#include /* to declare setmode() */ +#endif + +#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ +#ifdef __MWERKS__ +#include /* Metrowerks needs this */ +#include /* ... and this */ +#endif +#ifdef THINK_C +#include /* Think declares it here */ +#endif +#endif + +#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ +#define READ_BINARY "r" +#else +#define READ_BINARY "rb" +#endif + +#ifndef EXIT_FAILURE /* define exit() codes if not provided */ +#define EXIT_FAILURE 1 +#endif +#ifndef EXIT_SUCCESS +#ifdef VMS +#define EXIT_SUCCESS 1 /* VMS is very nonstandard */ +#else +#define EXIT_SUCCESS 0 +#endif +#endif + + +/* + * These macros are used to read the input file. + * To reuse this code in another application, you might need to change these. + */ + +static FILE * infile; /* input JPEG file */ + +/* Return next input byte, or EOF if no more */ +#define NEXTBYTE() getc(infile) + + +/* Error exit handler */ +#define ERREXIT(msg) (fprintf(stderr, "%s\n", msg), exit(EXIT_FAILURE)) + + +/* Read one byte, testing for EOF */ +static int +read_1_byte (void) +{ + int c; + + c = NEXTBYTE(); + if (c == EOF) + ERREXIT("Premature EOF in JPEG file"); + return c; +} + +/* Read 2 bytes, convert to unsigned int */ +/* All 2-byte quantities in JPEG markers are MSB first */ +static unsigned int +read_2_bytes (void) +{ + int c1, c2; + + c1 = NEXTBYTE(); + if (c1 == EOF) + ERREXIT("Premature EOF in JPEG file"); + c2 = NEXTBYTE(); + if (c2 == EOF) + ERREXIT("Premature EOF in JPEG file"); + return (((unsigned int) c1) << 8) + ((unsigned int) c2); +} + + +/* + * JPEG markers consist of one or more 0xFF bytes, followed by a marker + * code byte (which is not an FF). Here are the marker codes of interest + * in this program. (See jdmarker.c for a more complete list.) + */ + +#define M_SOF0 0xC0 /* Start Of Frame N */ +#define M_SOF1 0xC1 /* N indicates which compression process */ +#define M_SOF2 0xC2 /* Only SOF0-SOF2 are now in common use */ +#define M_SOF3 0xC3 +#define M_SOF5 0xC5 /* NB: codes C4 and CC are NOT SOF markers */ +#define M_SOF6 0xC6 +#define M_SOF7 0xC7 +#define M_SOF9 0xC9 +#define M_SOF10 0xCA +#define M_SOF11 0xCB +#define M_SOF13 0xCD +#define M_SOF14 0xCE +#define M_SOF15 0xCF +#define M_SOI 0xD8 /* Start Of Image (beginning of datastream) */ +#define M_EOI 0xD9 /* End Of Image (end of datastream) */ +#define M_SOS 0xDA /* Start Of Scan (begins compressed data) */ +#define M_COM 0xFE /* COMment */ + + +/* + * Find the next JPEG marker and return its marker code. + * We expect at least one FF byte, possibly more if the compressor used FFs + * to pad the file. + * There could also be non-FF garbage between markers. The treatment of such + * garbage is unspecified; we choose to skip over it but emit a warning msg. + * NB: this routine must not be used after seeing SOS marker, since it will + * not deal correctly with FF/00 sequences in the compressed image data... + */ + +static int +next_marker (void) +{ + int c; + int discarded_bytes = 0; + + /* Find 0xFF byte; count and skip any non-FFs. */ + c = read_1_byte(); + while (c != 0xFF) { + discarded_bytes++; + c = read_1_byte(); + } + /* Get marker code byte, swallowing any duplicate FF bytes. Extra FFs + * are legal as pad bytes, so don't count them in discarded_bytes. + */ + do { + c = read_1_byte(); + } while (c == 0xFF); + + if (discarded_bytes != 0) { + fprintf(stderr, "Warning: garbage data found in JPEG file\n"); + } + + return c; +} + + +/* + * Read the initial marker, which should be SOI. + * For a JFIF file, the first two bytes of the file should be literally + * 0xFF M_SOI. To be more general, we could use next_marker, but if the + * input file weren't actually JPEG at all, next_marker might read the whole + * file and then return a misleading error message... + */ + +static int +first_marker (void) +{ + int c1, c2; + + c1 = NEXTBYTE(); + c2 = NEXTBYTE(); + if (c1 != 0xFF || c2 != M_SOI) + ERREXIT("Not a JPEG file"); + return c2; +} + + +/* + * Most types of marker are followed by a variable-length parameter segment. + * This routine skips over the parameters for any marker we don't otherwise + * want to process. + * Note that we MUST skip the parameter segment explicitly in order not to + * be fooled by 0xFF bytes that might appear within the parameter segment; + * such bytes do NOT introduce new markers. + */ + +static void +skip_variable (void) +/* Skip over an unknown or uninteresting variable-length marker */ +{ + unsigned int length; + + /* Get the marker parameter length count */ + length = read_2_bytes(); + /* Length includes itself, so must be at least 2 */ + if (length < 2) + ERREXIT("Erroneous JPEG marker length"); + length -= 2; + /* Skip over the remaining bytes */ + while (length > 0) { + (void) read_1_byte(); + length--; + } +} + + +/* + * Process a COM marker. + * We want to print out the marker contents as legible text; + * we must guard against random junk and varying newline representations. + */ + +static void +process_COM (void) +{ + unsigned int length; + int ch; + int lastch = 0; + + /* Get the marker parameter length count */ + length = read_2_bytes(); + /* Length includes itself, so must be at least 2 */ + if (length < 2) + ERREXIT("Erroneous JPEG marker length"); + length -= 2; + + while (length > 0) { + ch = read_1_byte(); + /* Emit the character in a readable form. + * Nonprintables are converted to \nnn form, + * while \ is converted to \\. + * Newlines in CR, CR/LF, or LF form will be printed as one newline. + */ + if (ch == '\r') { + printf("\n"); + } else if (ch == '\n') { + if (lastch != '\r') + printf("\n"); + } else if (ch == '\\') { + printf("\\\\"); + } else if (isprint(ch)) { + putc(ch, stdout); + } else { + printf("\\%03o", ch); + } + lastch = ch; + length--; + } + printf("\n"); +} + + +/* + * Process a SOFn marker. + * This code is only needed if you want to know the image dimensions... + */ + +static void +process_SOFn (int marker) +{ + unsigned int length; + unsigned int image_height, image_width; + int data_precision, num_components; + const char * process; + int ci; + + length = read_2_bytes(); /* usual parameter length count */ + + data_precision = read_1_byte(); + image_height = read_2_bytes(); + image_width = read_2_bytes(); + num_components = read_1_byte(); + + switch (marker) { + case M_SOF0: process = "Baseline"; break; + case M_SOF1: process = "Extended sequential"; break; + case M_SOF2: process = "Progressive"; break; + case M_SOF3: process = "Lossless"; break; + case M_SOF5: process = "Differential sequential"; break; + case M_SOF6: process = "Differential progressive"; break; + case M_SOF7: process = "Differential lossless"; break; + case M_SOF9: process = "Extended sequential, arithmetic coding"; break; + case M_SOF10: process = "Progressive, arithmetic coding"; break; + case M_SOF11: process = "Lossless, arithmetic coding"; break; + case M_SOF13: process = "Differential sequential, arithmetic coding"; break; + case M_SOF14: process = "Differential progressive, arithmetic coding"; break; + case M_SOF15: process = "Differential lossless, arithmetic coding"; break; + default: process = "Unknown"; break; + } + + printf("JPEG image is %uw * %uh, %d color components, %d bits per sample\n", + image_width, image_height, num_components, data_precision); + printf("JPEG process: %s\n", process); + + if (length != (unsigned int) (8 + num_components * 3)) + ERREXIT("Bogus SOF marker length"); + + for (ci = 0; ci < num_components; ci++) { + (void) read_1_byte(); /* Component ID code */ + (void) read_1_byte(); /* H, V sampling factors */ + (void) read_1_byte(); /* Quantization table number */ + } +} + + +/* + * Parse the marker stream until SOS or EOI is seen; + * display any COM markers. + * While the companion program wrjpgcom will always insert COM markers before + * SOFn, other implementations might not, so we scan to SOS before stopping. + * If we were only interested in the image dimensions, we would stop at SOFn. + * (Conversely, if we only cared about COM markers, there would be no need + * for special code to handle SOFn; we could treat it like other markers.) + */ + +static int +scan_JPEG_header (int verbose) +{ + int marker; + + /* Expect SOI at start of file */ + if (first_marker() != M_SOI) + ERREXIT("Expected SOI marker first"); + + /* Scan miscellaneous markers until we reach SOS. */ + for (;;) { + marker = next_marker(); + switch (marker) { + case M_SOF0: /* Baseline */ + case M_SOF1: /* Extended sequential, Huffman */ + case M_SOF2: /* Progressive, Huffman */ + case M_SOF3: /* Lossless, Huffman */ + case M_SOF5: /* Differential sequential, Huffman */ + case M_SOF6: /* Differential progressive, Huffman */ + case M_SOF7: /* Differential lossless, Huffman */ + case M_SOF9: /* Extended sequential, arithmetic */ + case M_SOF10: /* Progressive, arithmetic */ + case M_SOF11: /* Lossless, arithmetic */ + case M_SOF13: /* Differential sequential, arithmetic */ + case M_SOF14: /* Differential progressive, arithmetic */ + case M_SOF15: /* Differential lossless, arithmetic */ + if (verbose) + process_SOFn(marker); + else + skip_variable(); + break; + + case M_SOS: /* stop before hitting compressed data */ + return marker; + + case M_EOI: /* in case it's a tables-only JPEG stream */ + return marker; + + case M_COM: + process_COM(); + break; + + default: /* Anything else just gets skipped */ + skip_variable(); /* we assume it has a parameter count... */ + break; + } + } /* end loop */ +} + + +/* Command line parsing code */ + +static const char * progname; /* program name for error messages */ + + +static void +usage (void) +/* complain about bad command line */ +{ + fprintf(stderr, "rdjpgcom displays any textual comments in a JPEG file.\n"); + + fprintf(stderr, "Usage: %s [switches] [inputfile]\n", progname); + + fprintf(stderr, "Switches (names may be abbreviated):\n"); + fprintf(stderr, " -verbose Also display dimensions of JPEG image\n"); + + exit(EXIT_FAILURE); +} + + +static int +keymatch (char * arg, const char * keyword, int minchars) +/* Case-insensitive matching of (possibly abbreviated) keyword switches. */ +/* keyword is the constant keyword (must be lower case already), */ +/* minchars is length of minimum legal abbreviation. */ +{ + register int ca, ck; + register int nmatched = 0; + + while ((ca = *arg++) != '\0') { + if ((ck = *keyword++) == '\0') + return 0; /* arg longer than keyword, no good */ + if (isupper(ca)) /* force arg to lcase (assume ck is already) */ + ca = tolower(ca); + if (ca != ck) + return 0; /* no good */ + nmatched++; /* count matched characters */ + } + /* reached end of argument; fail if it's too short for unique abbrev */ + if (nmatched < minchars) + return 0; + return 1; /* A-OK */ +} + + +/* + * The main program. + */ + +int +main (int argc, char **argv) +{ + int argn; + char * arg; + int verbose = 0; + + /* On Mac, fetch a command line. */ +#ifdef USE_CCOMMAND + argc = ccommand(&argv); +#endif + + progname = argv[0]; + if (progname == NULL || progname[0] == 0) + progname = "rdjpgcom"; /* in case C library doesn't provide it */ + + /* Parse switches, if any */ + for (argn = 1; argn < argc; argn++) { + arg = argv[argn]; + if (arg[0] != '-') + break; /* not switch, must be file name */ + arg++; /* advance over '-' */ + if (keymatch(arg, "verbose", 1)) { + verbose++; + } else + usage(); + } + + /* Open the input file. */ + /* Unix style: expect zero or one file name */ + if (argn < argc-1) { + fprintf(stderr, "%s: only one input file\n", progname); + usage(); + } + if (argn < argc) { + if ((infile = fopen(argv[argn], READ_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]); + exit(EXIT_FAILURE); + } + } else { + /* default input file is stdin */ +#ifdef USE_SETMODE /* need to hack file mode? */ + setmode(fileno(stdin), O_BINARY); +#endif +#ifdef USE_FDOPEN /* need to re-open in binary mode? */ + if ((infile = fdopen(fileno(stdin), READ_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open stdin\n", progname); + exit(EXIT_FAILURE); + } +#else + infile = stdin; +#endif + } + + /* Scan the JPEG headers. */ + (void) scan_JPEG_header(verbose); + + /* All done. */ + exit(EXIT_SUCCESS); + return 0; /* suppress no-return-value warnings */ +} diff --git a/gs/jpeg/rdppm.c b/gs/jpeg/rdppm.c new file mode 100644 index 000000000..e1c2a9285 --- /dev/null +++ b/gs/jpeg/rdppm.c @@ -0,0 +1,450 @@ +/* + * rdppm.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to read input images in PPM/PGM format. + * The extended 2-byte-per-sample raw PPM/PGM formats are supported. + * The PBMPLUS library is NOT required to compile this software + * (but it is highly useful as a set of PPM image manipulation programs). + * + * These routines may need modification for non-Unix environments or + * specialized applications. As they stand, they assume input from + * an ordinary stdio stream. They further assume that reading begins + * at the start of the file; start_input may need work if the + * user interface has already read some data (e.g., to determine that + * the file is indeed PPM format). + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ + +#ifdef PPM_SUPPORTED + + +/* Portions of this code are based on the PBMPLUS library, which is: +** +** Copyright (C) 1988 by Jef Poskanzer. +** +** Permission to use, copy, modify, and distribute this software and its +** documentation for any purpose and without fee is hereby granted, provided +** that the above copyright notice appear in all copies and that both that +** copyright notice and this permission notice appear in supporting +** documentation. This software is provided "as is" without express or +** implied warranty. +*/ + + +/* Macros to deal with unsigned chars as efficiently as compiler allows */ + +#ifdef HAVE_UNSIGNED_CHAR +typedef unsigned char U_CHAR; +#define UCH(x) ((int) (x)) +#else /* !HAVE_UNSIGNED_CHAR */ +#ifdef CHAR_IS_UNSIGNED +typedef char U_CHAR; +#define UCH(x) ((int) (x)) +#else +typedef char U_CHAR; +#define UCH(x) ((int) (x) & 0xFF) +#endif +#endif /* HAVE_UNSIGNED_CHAR */ + + +#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len))) + + +/* + * On most systems, reading individual bytes with getc() is drastically less + * efficient than buffering a row at a time with fread(). On PCs, we must + * allocate the buffer in near data space, because we are assuming small-data + * memory model, wherein fread() can't reach far memory. If you need to + * process very wide images on a PC, you might have to compile in large-memory + * model, or else replace fread() with a getc() loop --- which will be much + * slower. + */ + + +/* Private version of data source object */ + +typedef struct { + struct cjpeg_source_struct pub; /* public fields */ + + U_CHAR *iobuffer; /* non-FAR pointer to I/O buffer */ + JSAMPROW pixrow; /* FAR pointer to same */ + size_t buffer_width; /* width of I/O buffer */ + JSAMPLE *rescale; /* => maxval-remapping array, or NULL */ +} ppm_source_struct; + +typedef ppm_source_struct * ppm_source_ptr; + + +LOCAL(int) +pbm_getc (FILE * infile) +/* Read next char, skipping over any comments */ +/* A comment/newline sequence is returned as a newline */ +{ + register int ch; + + ch = getc(infile); + if (ch == '#') { + do { + ch = getc(infile); + } while (ch != '\n' && ch != EOF); + } + return ch; +} + + +LOCAL(unsigned int) +read_pbm_integer (j_compress_ptr cinfo, FILE * infile) +/* Read an unsigned decimal integer from the PPM file */ +/* Swallows one trailing character after the integer */ +/* Note that on a 16-bit-int machine, only values up to 64k can be read. */ +/* This should not be a problem in practice. */ +{ + register int ch; + register unsigned int val; + + /* Skip any leading whitespace */ + do { + ch = pbm_getc(infile); + if (ch == EOF) + ERREXIT(cinfo, JERR_INPUT_EOF); + } while (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'); + + if (ch < '0' || ch > '9') + ERREXIT(cinfo, JERR_PPM_NONNUMERIC); + + val = ch - '0'; + while ((ch = pbm_getc(infile)) >= '0' && ch <= '9') { + val *= 10; + val += ch - '0'; + } + return val; +} + + +/* + * Read one row of pixels. + * + * We provide several different versions depending on input file format. + * In all cases, input is scaled to the size of JSAMPLE. + * + * A really fast path is provided for reading byte/sample raw files with + * maxval = MAXJSAMPLE, which is the normal case for 8-bit data. + */ + + +METHODDEF(JDIMENSION) +get_text_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading text-format PGM files with any maxval */ +{ + ppm_source_ptr source = (ppm_source_ptr) sinfo; + FILE * infile = source->pub.input_file; + register JSAMPROW ptr; + register JSAMPLE *rescale = source->rescale; + JDIMENSION col; + + ptr = source->pub.buffer[0]; + for (col = cinfo->image_width; col > 0; col--) { + *ptr++ = rescale[read_pbm_integer(cinfo, infile)]; + } + return 1; +} + + +METHODDEF(JDIMENSION) +get_text_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading text-format PPM files with any maxval */ +{ + ppm_source_ptr source = (ppm_source_ptr) sinfo; + FILE * infile = source->pub.input_file; + register JSAMPROW ptr; + register JSAMPLE *rescale = source->rescale; + JDIMENSION col; + + ptr = source->pub.buffer[0]; + for (col = cinfo->image_width; col > 0; col--) { + *ptr++ = rescale[read_pbm_integer(cinfo, infile)]; + *ptr++ = rescale[read_pbm_integer(cinfo, infile)]; + *ptr++ = rescale[read_pbm_integer(cinfo, infile)]; + } + return 1; +} + + +METHODDEF(JDIMENSION) +get_scaled_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading raw-byte-format PGM files with any maxval */ +{ + ppm_source_ptr source = (ppm_source_ptr) sinfo; + register JSAMPROW ptr; + register U_CHAR * bufferptr; + register JSAMPLE *rescale = source->rescale; + JDIMENSION col; + + if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) + ERREXIT(cinfo, JERR_INPUT_EOF); + ptr = source->pub.buffer[0]; + bufferptr = source->iobuffer; + for (col = cinfo->image_width; col > 0; col--) { + *ptr++ = rescale[UCH(*bufferptr++)]; + } + return 1; +} + + +METHODDEF(JDIMENSION) +get_scaled_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading raw-byte-format PPM files with any maxval */ +{ + ppm_source_ptr source = (ppm_source_ptr) sinfo; + register JSAMPROW ptr; + register U_CHAR * bufferptr; + register JSAMPLE *rescale = source->rescale; + JDIMENSION col; + + if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) + ERREXIT(cinfo, JERR_INPUT_EOF); + ptr = source->pub.buffer[0]; + bufferptr = source->iobuffer; + for (col = cinfo->image_width; col > 0; col--) { + *ptr++ = rescale[UCH(*bufferptr++)]; + *ptr++ = rescale[UCH(*bufferptr++)]; + *ptr++ = rescale[UCH(*bufferptr++)]; + } + return 1; +} + + +METHODDEF(JDIMENSION) +get_raw_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading raw-byte-format files with maxval = MAXJSAMPLE. + * In this case we just read right into the JSAMPLE buffer! + * Note that same code works for PPM and PGM files. + */ +{ + ppm_source_ptr source = (ppm_source_ptr) sinfo; + + if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) + ERREXIT(cinfo, JERR_INPUT_EOF); + return 1; +} + + +METHODDEF(JDIMENSION) +get_word_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading raw-word-format PGM files with any maxval */ +{ + ppm_source_ptr source = (ppm_source_ptr) sinfo; + register JSAMPROW ptr; + register U_CHAR * bufferptr; + register JSAMPLE *rescale = source->rescale; + JDIMENSION col; + + if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) + ERREXIT(cinfo, JERR_INPUT_EOF); + ptr = source->pub.buffer[0]; + bufferptr = source->iobuffer; + for (col = cinfo->image_width; col > 0; col--) { + register int temp; + temp = UCH(*bufferptr++); + temp |= UCH(*bufferptr++) << 8; + *ptr++ = rescale[temp]; + } + return 1; +} + + +METHODDEF(JDIMENSION) +get_word_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading raw-word-format PPM files with any maxval */ +{ + ppm_source_ptr source = (ppm_source_ptr) sinfo; + register JSAMPROW ptr; + register U_CHAR * bufferptr; + register JSAMPLE *rescale = source->rescale; + JDIMENSION col; + + if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) + ERREXIT(cinfo, JERR_INPUT_EOF); + ptr = source->pub.buffer[0]; + bufferptr = source->iobuffer; + for (col = cinfo->image_width; col > 0; col--) { + register int temp; + temp = UCH(*bufferptr++); + temp |= UCH(*bufferptr++) << 8; + *ptr++ = rescale[temp]; + temp = UCH(*bufferptr++); + temp |= UCH(*bufferptr++) << 8; + *ptr++ = rescale[temp]; + temp = UCH(*bufferptr++); + temp |= UCH(*bufferptr++) << 8; + *ptr++ = rescale[temp]; + } + return 1; +} + + +/* + * Read the file header; return image size and component count. + */ + +METHODDEF(void) +start_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + ppm_source_ptr source = (ppm_source_ptr) sinfo; + int c; + unsigned int w, h, maxval; + boolean need_iobuffer, use_raw_buffer, need_rescale; + + if (getc(source->pub.input_file) != 'P') + ERREXIT(cinfo, JERR_PPM_NOT); + + c = getc(source->pub.input_file); /* save format discriminator for a sec */ + + /* fetch the remaining header info */ + w = read_pbm_integer(cinfo, source->pub.input_file); + h = read_pbm_integer(cinfo, source->pub.input_file); + maxval = read_pbm_integer(cinfo, source->pub.input_file); + + if (w <= 0 || h <= 0 || maxval <= 0) /* error check */ + ERREXIT(cinfo, JERR_PPM_NOT); + + cinfo->data_precision = BITS_IN_JSAMPLE; /* we always rescale data to this */ + cinfo->image_width = (JDIMENSION) w; + cinfo->image_height = (JDIMENSION) h; + + /* initialize flags to most common settings */ + need_iobuffer = TRUE; /* do we need an I/O buffer? */ + use_raw_buffer = FALSE; /* do we map input buffer onto I/O buffer? */ + need_rescale = TRUE; /* do we need a rescale array? */ + + switch (c) { + case '2': /* it's a text-format PGM file */ + cinfo->input_components = 1; + cinfo->in_color_space = JCS_GRAYSCALE; + TRACEMS2(cinfo, 1, JTRC_PGM_TEXT, w, h); + source->pub.get_pixel_rows = get_text_gray_row; + need_iobuffer = FALSE; + break; + + case '3': /* it's a text-format PPM file */ + cinfo->input_components = 3; + cinfo->in_color_space = JCS_RGB; + TRACEMS2(cinfo, 1, JTRC_PPM_TEXT, w, h); + source->pub.get_pixel_rows = get_text_rgb_row; + need_iobuffer = FALSE; + break; + + case '5': /* it's a raw-format PGM file */ + cinfo->input_components = 1; + cinfo->in_color_space = JCS_GRAYSCALE; + TRACEMS2(cinfo, 1, JTRC_PGM, w, h); + if (maxval > 255) { + source->pub.get_pixel_rows = get_word_gray_row; + } else if (maxval == MAXJSAMPLE && SIZEOF(JSAMPLE) == SIZEOF(U_CHAR)) { + source->pub.get_pixel_rows = get_raw_row; + use_raw_buffer = TRUE; + need_rescale = FALSE; + } else { + source->pub.get_pixel_rows = get_scaled_gray_row; + } + break; + + case '6': /* it's a raw-format PPM file */ + cinfo->input_components = 3; + cinfo->in_color_space = JCS_RGB; + TRACEMS2(cinfo, 1, JTRC_PPM, w, h); + if (maxval > 255) { + source->pub.get_pixel_rows = get_word_rgb_row; + } else if (maxval == MAXJSAMPLE && SIZEOF(JSAMPLE) == SIZEOF(U_CHAR)) { + source->pub.get_pixel_rows = get_raw_row; + use_raw_buffer = TRUE; + need_rescale = FALSE; + } else { + source->pub.get_pixel_rows = get_scaled_rgb_row; + } + break; + + default: + ERREXIT(cinfo, JERR_PPM_NOT); + break; + } + + /* Allocate space for I/O buffer: 1 or 3 bytes or words/pixel. */ + if (need_iobuffer) { + source->buffer_width = (size_t) w * cinfo->input_components * + ((maxval<=255) ? SIZEOF(U_CHAR) : (2*SIZEOF(U_CHAR))); + source->iobuffer = (U_CHAR *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + source->buffer_width); + } + + /* Create compressor input buffer. */ + if (use_raw_buffer) { + /* For unscaled raw-input case, we can just map it onto the I/O buffer. */ + /* Synthesize a JSAMPARRAY pointer structure */ + /* Cast here implies near->far pointer conversion on PCs */ + source->pixrow = (JSAMPROW) source->iobuffer; + source->pub.buffer = & source->pixrow; + source->pub.buffer_height = 1; + } else { + /* Need to translate anyway, so make a separate sample buffer. */ + source->pub.buffer = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) w * cinfo->input_components, (JDIMENSION) 1); + source->pub.buffer_height = 1; + } + + /* Compute the rescaling array if required. */ + if (need_rescale) { + INT32 val, half_maxval; + + /* On 16-bit-int machines we have to be careful of maxval = 65535 */ + source->rescale = (JSAMPLE *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (size_t) (((long) maxval + 1L) * SIZEOF(JSAMPLE))); + half_maxval = maxval / 2; + for (val = 0; val <= (INT32) maxval; val++) { + /* The multiplication here must be done in 32 bits to avoid overflow */ + source->rescale[val] = (JSAMPLE) ((val*MAXJSAMPLE + half_maxval)/maxval); + } + } +} + + +/* + * Finish up at the end of the file. + */ + +METHODDEF(void) +finish_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + /* no work */ +} + + +/* + * The module selection routine for PPM format input. + */ + +GLOBAL(cjpeg_source_ptr) +jinit_read_ppm (j_compress_ptr cinfo) +{ + ppm_source_ptr source; + + /* Create module interface object */ + source = (ppm_source_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(ppm_source_struct)); + /* Fill in method ptrs, except get_pixel_rows which start_input sets */ + source->pub.start_input = start_input_ppm; + source->pub.finish_input = finish_input_ppm; + + return (cjpeg_source_ptr) source; +} + +#endif /* PPM_SUPPORTED */ diff --git a/gs/jpeg/rdrle.c b/gs/jpeg/rdrle.c new file mode 100644 index 000000000..542bc3749 --- /dev/null +++ b/gs/jpeg/rdrle.c @@ -0,0 +1,387 @@ +/* + * rdrle.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to read input images in Utah RLE format. + * The Utah Raster Toolkit library is required (version 3.1 or later). + * + * These routines may need modification for non-Unix environments or + * specialized applications. As they stand, they assume input from + * an ordinary stdio stream. They further assume that reading begins + * at the start of the file; start_input may need work if the + * user interface has already read some data (e.g., to determine that + * the file is indeed RLE format). + * + * Based on code contributed by Mike Lijewski, + * with updates from Robert Hutchinson. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ + +#ifdef RLE_SUPPORTED + +/* rle.h is provided by the Utah Raster Toolkit. */ + +#include + +/* + * We assume that JSAMPLE has the same representation as rle_pixel, + * to wit, "unsigned char". Hence we can't cope with 12- or 16-bit samples. + */ + +#if BITS_IN_JSAMPLE != 8 + Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */ +#endif + +/* + * We support the following types of RLE files: + * + * GRAYSCALE - 8 bits, no colormap + * MAPPEDGRAY - 8 bits, 1 channel colomap + * PSEUDOCOLOR - 8 bits, 3 channel colormap + * TRUECOLOR - 24 bits, 3 channel colormap + * DIRECTCOLOR - 24 bits, no colormap + * + * For now, we ignore any alpha channel in the image. + */ + +typedef enum + { GRAYSCALE, MAPPEDGRAY, PSEUDOCOLOR, TRUECOLOR, DIRECTCOLOR } rle_kind; + + +/* + * Since RLE stores scanlines bottom-to-top, we have to invert the image + * to conform to JPEG's top-to-bottom order. To do this, we read the + * incoming image into a virtual array on the first get_pixel_rows call, + * then fetch the required row from the virtual array on subsequent calls. + */ + +typedef struct _rle_source_struct * rle_source_ptr; + +typedef struct _rle_source_struct { + struct cjpeg_source_struct pub; /* public fields */ + + rle_kind visual; /* actual type of input file */ + jvirt_sarray_ptr image; /* virtual array to hold the image */ + JDIMENSION row; /* current row # in the virtual array */ + rle_hdr header; /* Input file information */ + rle_pixel** rle_row; /* holds a row returned by rle_getrow() */ + +} rle_source_struct; + + +/* + * Read the file header; return image size and component count. + */ + +METHODDEF(void) +start_input_rle (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + rle_source_ptr source = (rle_source_ptr) sinfo; + JDIMENSION width, height; +#ifdef PROGRESS_REPORT + cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; +#endif + + /* Use RLE library routine to get the header info */ + source->header = *rle_hdr_init(NULL); + source->header.rle_file = source->pub.input_file; + switch (rle_get_setup(&(source->header))) { + case RLE_SUCCESS: + /* A-OK */ + break; + case RLE_NOT_RLE: + ERREXIT(cinfo, JERR_RLE_NOT); + break; + case RLE_NO_SPACE: + ERREXIT(cinfo, JERR_RLE_MEM); + break; + case RLE_EMPTY: + ERREXIT(cinfo, JERR_RLE_EMPTY); + break; + case RLE_EOF: + ERREXIT(cinfo, JERR_RLE_EOF); + break; + default: + ERREXIT(cinfo, JERR_RLE_BADERROR); + break; + } + + /* Figure out what we have, set private vars and return values accordingly */ + + width = source->header.xmax - source->header.xmin + 1; + height = source->header.ymax - source->header.ymin + 1; + source->header.xmin = 0; /* realign horizontally */ + source->header.xmax = width-1; + + cinfo->image_width = width; + cinfo->image_height = height; + cinfo->data_precision = 8; /* we can only handle 8 bit data */ + + if (source->header.ncolors == 1 && source->header.ncmap == 0) { + source->visual = GRAYSCALE; + TRACEMS2(cinfo, 1, JTRC_RLE_GRAY, width, height); + } else if (source->header.ncolors == 1 && source->header.ncmap == 1) { + source->visual = MAPPEDGRAY; + TRACEMS3(cinfo, 1, JTRC_RLE_MAPGRAY, width, height, + 1 << source->header.cmaplen); + } else if (source->header.ncolors == 1 && source->header.ncmap == 3) { + source->visual = PSEUDOCOLOR; + TRACEMS3(cinfo, 1, JTRC_RLE_MAPPED, width, height, + 1 << source->header.cmaplen); + } else if (source->header.ncolors == 3 && source->header.ncmap == 3) { + source->visual = TRUECOLOR; + TRACEMS3(cinfo, 1, JTRC_RLE_FULLMAP, width, height, + 1 << source->header.cmaplen); + } else if (source->header.ncolors == 3 && source->header.ncmap == 0) { + source->visual = DIRECTCOLOR; + TRACEMS2(cinfo, 1, JTRC_RLE, width, height); + } else + ERREXIT(cinfo, JERR_RLE_UNSUPPORTED); + + if (source->visual == GRAYSCALE || source->visual == MAPPEDGRAY) { + cinfo->in_color_space = JCS_GRAYSCALE; + cinfo->input_components = 1; + } else { + cinfo->in_color_space = JCS_RGB; + cinfo->input_components = 3; + } + + /* + * A place to hold each scanline while it's converted. + * (GRAYSCALE scanlines don't need converting) + */ + if (source->visual != GRAYSCALE) { + source->rle_row = (rle_pixel**) (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) width, (JDIMENSION) cinfo->input_components); + } + + /* request a virtual array to hold the image */ + source->image = (*cinfo->mem->request_virt_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, + (JDIMENSION) (width * source->header.ncolors), + (JDIMENSION) height, (JDIMENSION) 1); + +#ifdef PROGRESS_REPORT + if (progress != NULL) { + /* count file input as separate pass */ + progress->total_extra_passes++; + } +#endif + + source->pub.buffer_height = 1; +} + + +/* + * Read one row of pixels. + * Called only after load_image has read the image into the virtual array. + * Used for GRAYSCALE, MAPPEDGRAY, TRUECOLOR, and DIRECTCOLOR images. + */ + +METHODDEF(JDIMENSION) +get_rle_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + rle_source_ptr source = (rle_source_ptr) sinfo; + + source->row--; + source->pub.buffer = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, source->image, source->row, (JDIMENSION) 1, FALSE); + + return 1; +} + +/* + * Read one row of pixels. + * Called only after load_image has read the image into the virtual array. + * Used for PSEUDOCOLOR images. + */ + +METHODDEF(JDIMENSION) +get_pseudocolor_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + rle_source_ptr source = (rle_source_ptr) sinfo; + JSAMPROW src_row, dest_row; + JDIMENSION col; + rle_map *colormap; + int val; + + colormap = source->header.cmap; + dest_row = source->pub.buffer[0]; + source->row--; + src_row = * (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, source->image, source->row, (JDIMENSION) 1, FALSE); + + for (col = cinfo->image_width; col > 0; col--) { + val = GETJSAMPLE(*src_row++); + *dest_row++ = (JSAMPLE) (colormap[val ] >> 8); + *dest_row++ = (JSAMPLE) (colormap[val + 256] >> 8); + *dest_row++ = (JSAMPLE) (colormap[val + 512] >> 8); + } + + return 1; +} + + +/* + * Load the image into a virtual array. We have to do this because RLE + * files start at the lower left while the JPEG standard has them starting + * in the upper left. This is called the first time we want to get a row + * of input. What we do is load the RLE data into the array and then call + * the appropriate routine to read one row from the array. Before returning, + * we set source->pub.get_pixel_rows so that subsequent calls go straight to + * the appropriate row-reading routine. + */ + +METHODDEF(JDIMENSION) +load_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + rle_source_ptr source = (rle_source_ptr) sinfo; + JDIMENSION row, col; + JSAMPROW scanline, red_ptr, green_ptr, blue_ptr; + rle_pixel **rle_row; + rle_map *colormap; + char channel; +#ifdef PROGRESS_REPORT + cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; +#endif + + colormap = source->header.cmap; + rle_row = source->rle_row; + + /* Read the RLE data into our virtual array. + * We assume here that (a) rle_pixel is represented the same as JSAMPLE, + * and (b) we are not on a machine where FAR pointers differ from regular. + */ + RLE_CLR_BIT(source->header, RLE_ALPHA); /* don't read the alpha channel */ + +#ifdef PROGRESS_REPORT + if (progress != NULL) { + progress->pub.pass_limit = cinfo->image_height; + progress->pub.pass_counter = 0; + (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); + } +#endif + + switch (source->visual) { + + case GRAYSCALE: + case PSEUDOCOLOR: + for (row = 0; row < cinfo->image_height; row++) { + rle_row = (rle_pixel **) (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, source->image, row, (JDIMENSION) 1, TRUE); + rle_getrow(&source->header, rle_row); +#ifdef PROGRESS_REPORT + if (progress != NULL) { + progress->pub.pass_counter++; + (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); + } +#endif + } + break; + + case MAPPEDGRAY: + case TRUECOLOR: + for (row = 0; row < cinfo->image_height; row++) { + scanline = * (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, source->image, row, (JDIMENSION) 1, TRUE); + rle_row = source->rle_row; + rle_getrow(&source->header, rle_row); + + for (col = 0; col < cinfo->image_width; col++) { + for (channel = 0; channel < source->header.ncolors; channel++) { + *scanline++ = (JSAMPLE) + (colormap[GETJSAMPLE(rle_row[channel][col]) + 256 * channel] >> 8); + } + } + +#ifdef PROGRESS_REPORT + if (progress != NULL) { + progress->pub.pass_counter++; + (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); + } +#endif + } + break; + + case DIRECTCOLOR: + for (row = 0; row < cinfo->image_height; row++) { + scanline = * (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, source->image, row, (JDIMENSION) 1, TRUE); + rle_getrow(&source->header, rle_row); + + red_ptr = rle_row[0]; + green_ptr = rle_row[1]; + blue_ptr = rle_row[2]; + + for (col = cinfo->image_width; col > 0; col--) { + *scanline++ = *red_ptr++; + *scanline++ = *green_ptr++; + *scanline++ = *blue_ptr++; + } + +#ifdef PROGRESS_REPORT + if (progress != NULL) { + progress->pub.pass_counter++; + (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); + } +#endif + } + } + +#ifdef PROGRESS_REPORT + if (progress != NULL) + progress->completed_extra_passes++; +#endif + + /* Set up to call proper row-extraction routine in future */ + if (source->visual == PSEUDOCOLOR) { + source->pub.buffer = source->rle_row; + source->pub.get_pixel_rows = get_pseudocolor_row; + } else { + source->pub.get_pixel_rows = get_rle_row; + } + source->row = cinfo->image_height; + + /* And fetch the topmost (bottommost) row */ + return (*source->pub.get_pixel_rows) (cinfo, sinfo); +} + + +/* + * Finish up at the end of the file. + */ + +METHODDEF(void) +finish_input_rle (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + /* no work */ +} + + +/* + * The module selection routine for RLE format input. + */ + +GLOBAL(cjpeg_source_ptr) +jinit_read_rle (j_compress_ptr cinfo) +{ + rle_source_ptr source; + + /* Create module interface object */ + source = (rle_source_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(rle_source_struct)); + /* Fill in method ptrs */ + source->pub.start_input = start_input_rle; + source->pub.finish_input = finish_input_rle; + source->pub.get_pixel_rows = load_image; + + return (cjpeg_source_ptr) source; +} + +#endif /* RLE_SUPPORTED */ diff --git a/gs/jpeg/rdswitch.c b/gs/jpeg/rdswitch.c new file mode 100644 index 000000000..4f4bb4f58 --- /dev/null +++ b/gs/jpeg/rdswitch.c @@ -0,0 +1,332 @@ +/* + * rdswitch.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to process some of cjpeg's more complicated + * command-line switches. Switches processed here are: + * -qtables file Read quantization tables from text file + * -scans file Read scan script from text file + * -qslots N[,N,...] Set component quantization table selectors + * -sample HxV[,HxV,...] Set component sampling factors + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ +#include /* to declare isdigit(), isspace() */ + + +LOCAL(int) +text_getc (FILE * file) +/* Read next char, skipping over any comments (# to end of line) */ +/* A comment/newline sequence is returned as a newline */ +{ + register int ch; + + ch = getc(file); + if (ch == '#') { + do { + ch = getc(file); + } while (ch != '\n' && ch != EOF); + } + return ch; +} + + +LOCAL(boolean) +read_text_integer (FILE * file, long * result, int * termchar) +/* Read an unsigned decimal integer from a file, store it in result */ +/* Reads one trailing character after the integer; returns it in termchar */ +{ + register int ch; + register long val; + + /* Skip any leading whitespace, detect EOF */ + do { + ch = text_getc(file); + if (ch == EOF) { + *termchar = ch; + return FALSE; + } + } while (isspace(ch)); + + if (! isdigit(ch)) { + *termchar = ch; + return FALSE; + } + + val = ch - '0'; + while ((ch = text_getc(file)) != EOF) { + if (! isdigit(ch)) + break; + val *= 10; + val += ch - '0'; + } + *result = val; + *termchar = ch; + return TRUE; +} + + +GLOBAL(boolean) +read_quant_tables (j_compress_ptr cinfo, char * filename, + int scale_factor, boolean force_baseline) +/* Read a set of quantization tables from the specified file. + * The file is plain ASCII text: decimal numbers with whitespace between. + * Comments preceded by '#' may be included in the file. + * There may be one to NUM_QUANT_TBLS tables in the file, each of 64 values. + * The tables are implicitly numbered 0,1,etc. + * NOTE: does not affect the qslots mapping, which will default to selecting + * table 0 for luminance (or primary) components, 1 for chrominance components. + * You must use -qslots if you want a different component->table mapping. + */ +{ + FILE * fp; + int tblno, i, termchar; + long val; + unsigned int table[DCTSIZE2]; + + if ((fp = fopen(filename, "r")) == NULL) { + fprintf(stderr, "Can't open table file %s\n", filename); + return FALSE; + } + tblno = 0; + + while (read_text_integer(fp, &val, &termchar)) { /* read 1st element of table */ + if (tblno >= NUM_QUANT_TBLS) { + fprintf(stderr, "Too many tables in file %s\n", filename); + fclose(fp); + return FALSE; + } + table[0] = (unsigned int) val; + for (i = 1; i < DCTSIZE2; i++) { + if (! read_text_integer(fp, &val, &termchar)) { + fprintf(stderr, "Invalid table data in file %s\n", filename); + fclose(fp); + return FALSE; + } + table[i] = (unsigned int) val; + } + jpeg_add_quant_table(cinfo, tblno, table, scale_factor, force_baseline); + tblno++; + } + + if (termchar != EOF) { + fprintf(stderr, "Non-numeric data in file %s\n", filename); + fclose(fp); + return FALSE; + } + + fclose(fp); + return TRUE; +} + + +#ifdef C_MULTISCAN_FILES_SUPPORTED + +LOCAL(boolean) +read_scan_integer (FILE * file, long * result, int * termchar) +/* Variant of read_text_integer that always looks for a non-space termchar; + * this simplifies parsing of punctuation in scan scripts. + */ +{ + register int ch; + + if (! read_text_integer(file, result, termchar)) + return FALSE; + ch = *termchar; + while (ch != EOF && isspace(ch)) + ch = text_getc(file); + if (isdigit(ch)) { /* oops, put it back */ + if (ungetc(ch, file) == EOF) + return FALSE; + ch = ' '; + } else { + /* Any separators other than ';' and ':' are ignored; + * this allows user to insert commas, etc, if desired. + */ + if (ch != EOF && ch != ';' && ch != ':') + ch = ' '; + } + *termchar = ch; + return TRUE; +} + + +GLOBAL(boolean) +read_scan_script (j_compress_ptr cinfo, char * filename) +/* Read a scan script from the specified text file. + * Each entry in the file defines one scan to be emitted. + * Entries are separated by semicolons ';'. + * An entry contains one to four component indexes, + * optionally followed by a colon ':' and four progressive-JPEG parameters. + * The component indexes denote which component(s) are to be transmitted + * in the current scan. The first component has index 0. + * Sequential JPEG is used if the progressive-JPEG parameters are omitted. + * The file is free format text: any whitespace may appear between numbers + * and the ':' and ';' punctuation marks. Also, other punctuation (such + * as commas or dashes) can be placed between numbers if desired. + * Comments preceded by '#' may be included in the file. + * Note: we do very little validity checking here; + * jcmaster.c will validate the script parameters. + */ +{ + FILE * fp; + int scanno, ncomps, termchar; + long val; + jpeg_scan_info * scanptr; +#define MAX_SCANS 100 /* quite arbitrary limit */ + jpeg_scan_info scans[MAX_SCANS]; + + if ((fp = fopen(filename, "r")) == NULL) { + fprintf(stderr, "Can't open scan definition file %s\n", filename); + return FALSE; + } + scanptr = scans; + scanno = 0; + + while (read_scan_integer(fp, &val, &termchar)) { + if (scanno >= MAX_SCANS) { + fprintf(stderr, "Too many scans defined in file %s\n", filename); + fclose(fp); + return FALSE; + } + scanptr->component_index[0] = (int) val; + ncomps = 1; + while (termchar == ' ') { + if (ncomps >= MAX_COMPS_IN_SCAN) { + fprintf(stderr, "Too many components in one scan in file %s\n", + filename); + fclose(fp); + return FALSE; + } + if (! read_scan_integer(fp, &val, &termchar)) + goto bogus; + scanptr->component_index[ncomps] = (int) val; + ncomps++; + } + scanptr->comps_in_scan = ncomps; + if (termchar == ':') { + if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ') + goto bogus; + scanptr->Ss = (int) val; + if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ') + goto bogus; + scanptr->Se = (int) val; + if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ') + goto bogus; + scanptr->Ah = (int) val; + if (! read_scan_integer(fp, &val, &termchar)) + goto bogus; + scanptr->Al = (int) val; + } else { + /* set non-progressive parameters */ + scanptr->Ss = 0; + scanptr->Se = DCTSIZE2-1; + scanptr->Ah = 0; + scanptr->Al = 0; + } + if (termchar != ';' && termchar != EOF) { +bogus: + fprintf(stderr, "Invalid scan entry format in file %s\n", filename); + fclose(fp); + return FALSE; + } + scanptr++, scanno++; + } + + if (termchar != EOF) { + fprintf(stderr, "Non-numeric data in file %s\n", filename); + fclose(fp); + return FALSE; + } + + if (scanno > 0) { + /* Stash completed scan list in cinfo structure. + * NOTE: for cjpeg's use, JPOOL_IMAGE is the right lifetime for this data, + * but if you want to compress multiple images you'd want JPOOL_PERMANENT. + */ + scanptr = (jpeg_scan_info *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + scanno * SIZEOF(jpeg_scan_info)); + MEMCOPY(scanptr, scans, scanno * SIZEOF(jpeg_scan_info)); + cinfo->scan_info = scanptr; + cinfo->num_scans = scanno; + } + + fclose(fp); + return TRUE; +} + +#endif /* C_MULTISCAN_FILES_SUPPORTED */ + + +GLOBAL(boolean) +set_quant_slots (j_compress_ptr cinfo, char *arg) +/* Process a quantization-table-selectors parameter string, of the form + * N[,N,...] + * If there are more components than parameters, the last value is replicated. + */ +{ + int val = 0; /* default table # */ + int ci; + char ch; + + for (ci = 0; ci < MAX_COMPONENTS; ci++) { + if (*arg) { + ch = ','; /* if not set by sscanf, will be ',' */ + if (sscanf(arg, "%d%c", &val, &ch) < 1) + return FALSE; + if (ch != ',') /* syntax check */ + return FALSE; + if (val < 0 || val >= NUM_QUANT_TBLS) { + fprintf(stderr, "JPEG quantization tables are numbered 0..%d\n", + NUM_QUANT_TBLS-1); + return FALSE; + } + cinfo->comp_info[ci].quant_tbl_no = val; + while (*arg && *arg++ != ',') /* advance to next segment of arg string */ + ; + } else { + /* reached end of parameter, set remaining components to last table */ + cinfo->comp_info[ci].quant_tbl_no = val; + } + } + return TRUE; +} + + +GLOBAL(boolean) +set_sample_factors (j_compress_ptr cinfo, char *arg) +/* Process a sample-factors parameter string, of the form + * HxV[,HxV,...] + * If there are more components than parameters, "1x1" is assumed for the rest. + */ +{ + int ci, val1, val2; + char ch1, ch2; + + for (ci = 0; ci < MAX_COMPONENTS; ci++) { + if (*arg) { + ch2 = ','; /* if not set by sscanf, will be ',' */ + if (sscanf(arg, "%d%c%d%c", &val1, &ch1, &val2, &ch2) < 3) + return FALSE; + if ((ch1 != 'x' && ch1 != 'X') || ch2 != ',') /* syntax check */ + return FALSE; + if (val1 <= 0 || val1 > 4 || val2 <= 0 || val2 > 4) { + fprintf(stderr, "JPEG sampling factors must be 1..4\n"); + return FALSE; + } + cinfo->comp_info[ci].h_samp_factor = val1; + cinfo->comp_info[ci].v_samp_factor = val2; + while (*arg && *arg++ != ',') /* advance to next segment of arg string */ + ; + } else { + /* reached end of parameter, set remaining components to 1x1 sampling */ + cinfo->comp_info[ci].h_samp_factor = 1; + cinfo->comp_info[ci].v_samp_factor = 1; + } + } + return TRUE; +} diff --git a/gs/jpeg/rdtarga.c b/gs/jpeg/rdtarga.c new file mode 100644 index 000000000..4c2cd2673 --- /dev/null +++ b/gs/jpeg/rdtarga.c @@ -0,0 +1,500 @@ +/* + * rdtarga.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to read input images in Targa format. + * + * These routines may need modification for non-Unix environments or + * specialized applications. As they stand, they assume input from + * an ordinary stdio stream. They further assume that reading begins + * at the start of the file; start_input may need work if the + * user interface has already read some data (e.g., to determine that + * the file is indeed Targa format). + * + * Based on code contributed by Lee Daniel Crocker. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ + +#ifdef TARGA_SUPPORTED + + +/* Macros to deal with unsigned chars as efficiently as compiler allows */ + +#ifdef HAVE_UNSIGNED_CHAR +typedef unsigned char U_CHAR; +#define UCH(x) ((int) (x)) +#else /* !HAVE_UNSIGNED_CHAR */ +#ifdef CHAR_IS_UNSIGNED +typedef char U_CHAR; +#define UCH(x) ((int) (x)) +#else +typedef char U_CHAR; +#define UCH(x) ((int) (x) & 0xFF) +#endif +#endif /* HAVE_UNSIGNED_CHAR */ + + +#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len))) + + +/* Private version of data source object */ + +typedef struct _tga_source_struct * tga_source_ptr; + +typedef struct _tga_source_struct { + struct cjpeg_source_struct pub; /* public fields */ + + j_compress_ptr cinfo; /* back link saves passing separate parm */ + + JSAMPARRAY colormap; /* Targa colormap (converted to my format) */ + + jvirt_sarray_ptr whole_image; /* Needed if funny input row order */ + JDIMENSION current_row; /* Current logical row number to read */ + + /* Pointer to routine to extract next Targa pixel from input file */ + JMETHOD(void, read_pixel, (tga_source_ptr sinfo)); + + /* Result of read_pixel is delivered here: */ + U_CHAR tga_pixel[4]; + + int pixel_size; /* Bytes per Targa pixel (1 to 4) */ + + /* State info for reading RLE-coded pixels; both counts must be init to 0 */ + int block_count; /* # of pixels remaining in RLE block */ + int dup_pixel_count; /* # of times to duplicate previous pixel */ + + /* This saves the correct pixel-row-expansion method for preload_image */ + JMETHOD(JDIMENSION, get_pixel_rows, (j_compress_ptr cinfo, + cjpeg_source_ptr sinfo)); +} tga_source_struct; + + +/* For expanding 5-bit pixel values to 8-bit with best rounding */ + +static const UINT8 c5to8bits[32] = { + 0, 8, 16, 25, 33, 41, 49, 58, + 66, 74, 82, 90, 99, 107, 115, 123, + 132, 140, 148, 156, 165, 173, 181, 189, + 197, 206, 214, 222, 230, 239, 247, 255 +}; + + + +LOCAL(int) +read_byte (tga_source_ptr sinfo) +/* Read next byte from Targa file */ +{ + register FILE *infile = sinfo->pub.input_file; + register int c; + + if ((c = getc(infile)) == EOF) + ERREXIT(sinfo->cinfo, JERR_INPUT_EOF); + return c; +} + + +LOCAL(void) +read_colormap (tga_source_ptr sinfo, int cmaplen, int mapentrysize) +/* Read the colormap from a Targa file */ +{ + int i; + + /* Presently only handles 24-bit BGR format */ + if (mapentrysize != 24) + ERREXIT(sinfo->cinfo, JERR_TGA_BADCMAP); + + for (i = 0; i < cmaplen; i++) { + sinfo->colormap[2][i] = (JSAMPLE) read_byte(sinfo); + sinfo->colormap[1][i] = (JSAMPLE) read_byte(sinfo); + sinfo->colormap[0][i] = (JSAMPLE) read_byte(sinfo); + } +} + + +/* + * read_pixel methods: get a single pixel from Targa file into tga_pixel[] + */ + +METHODDEF(void) +read_non_rle_pixel (tga_source_ptr sinfo) +/* Read one Targa pixel from the input file; no RLE expansion */ +{ + register FILE *infile = sinfo->pub.input_file; + register int i; + + for (i = 0; i < sinfo->pixel_size; i++) { + sinfo->tga_pixel[i] = (U_CHAR) getc(infile); + } +} + + +METHODDEF(void) +read_rle_pixel (tga_source_ptr sinfo) +/* Read one Targa pixel from the input file, expanding RLE data as needed */ +{ + register FILE *infile = sinfo->pub.input_file; + register int i; + + /* Duplicate previously read pixel? */ + if (sinfo->dup_pixel_count > 0) { + sinfo->dup_pixel_count--; + return; + } + + /* Time to read RLE block header? */ + if (--sinfo->block_count < 0) { /* decrement pixels remaining in block */ + i = read_byte(sinfo); + if (i & 0x80) { /* Start of duplicate-pixel block? */ + sinfo->dup_pixel_count = i & 0x7F; /* number of dups after this one */ + sinfo->block_count = 0; /* then read new block header */ + } else { + sinfo->block_count = i & 0x7F; /* number of pixels after this one */ + } + } + + /* Read next pixel */ + for (i = 0; i < sinfo->pixel_size; i++) { + sinfo->tga_pixel[i] = (U_CHAR) getc(infile); + } +} + + +/* + * Read one row of pixels. + * + * We provide several different versions depending on input file format. + */ + + +METHODDEF(JDIMENSION) +get_8bit_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading 8-bit grayscale pixels */ +{ + tga_source_ptr source = (tga_source_ptr) sinfo; + register JSAMPROW ptr; + register JDIMENSION col; + + ptr = source->pub.buffer[0]; + for (col = cinfo->image_width; col > 0; col--) { + (*source->read_pixel) (source); /* Load next pixel into tga_pixel */ + *ptr++ = (JSAMPLE) UCH(source->tga_pixel[0]); + } + return 1; +} + +METHODDEF(JDIMENSION) +get_8bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading 8-bit colormap indexes */ +{ + tga_source_ptr source = (tga_source_ptr) sinfo; + register int t; + register JSAMPROW ptr; + register JDIMENSION col; + register JSAMPARRAY colormap = source->colormap; + + ptr = source->pub.buffer[0]; + for (col = cinfo->image_width; col > 0; col--) { + (*source->read_pixel) (source); /* Load next pixel into tga_pixel */ + t = UCH(source->tga_pixel[0]); + *ptr++ = colormap[0][t]; + *ptr++ = colormap[1][t]; + *ptr++ = colormap[2][t]; + } + return 1; +} + +METHODDEF(JDIMENSION) +get_16bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading 16-bit pixels */ +{ + tga_source_ptr source = (tga_source_ptr) sinfo; + register int t; + register JSAMPROW ptr; + register JDIMENSION col; + + ptr = source->pub.buffer[0]; + for (col = cinfo->image_width; col > 0; col--) { + (*source->read_pixel) (source); /* Load next pixel into tga_pixel */ + t = UCH(source->tga_pixel[0]); + t += UCH(source->tga_pixel[1]) << 8; + /* We expand 5 bit data to 8 bit sample width. + * The format of the 16-bit (LSB first) input word is + * xRRRRRGGGGGBBBBB + */ + ptr[2] = (JSAMPLE) c5to8bits[t & 0x1F]; + t >>= 5; + ptr[1] = (JSAMPLE) c5to8bits[t & 0x1F]; + t >>= 5; + ptr[0] = (JSAMPLE) c5to8bits[t & 0x1F]; + ptr += 3; + } + return 1; +} + +METHODDEF(JDIMENSION) +get_24bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +/* This version is for reading 24-bit pixels */ +{ + tga_source_ptr source = (tga_source_ptr) sinfo; + register JSAMPROW ptr; + register JDIMENSION col; + + ptr = source->pub.buffer[0]; + for (col = cinfo->image_width; col > 0; col--) { + (*source->read_pixel) (source); /* Load next pixel into tga_pixel */ + *ptr++ = (JSAMPLE) UCH(source->tga_pixel[2]); /* change BGR to RGB order */ + *ptr++ = (JSAMPLE) UCH(source->tga_pixel[1]); + *ptr++ = (JSAMPLE) UCH(source->tga_pixel[0]); + } + return 1; +} + +/* + * Targa also defines a 32-bit pixel format with order B,G,R,A. + * We presently ignore the attribute byte, so the code for reading + * these pixels is identical to the 24-bit routine above. + * This works because the actual pixel length is only known to read_pixel. + */ + +#define get_32bit_row get_24bit_row + + +/* + * This method is for re-reading the input data in standard top-down + * row order. The entire image has already been read into whole_image + * with proper conversion of pixel format, but it's in a funny row order. + */ + +METHODDEF(JDIMENSION) +get_memory_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + tga_source_ptr source = (tga_source_ptr) sinfo; + JDIMENSION source_row; + + /* Compute row of source that maps to current_row of normal order */ + /* For now, assume image is bottom-up and not interlaced. */ + /* NEEDS WORK to support interlaced images! */ + source_row = cinfo->image_height - source->current_row - 1; + + /* Fetch that row from virtual array */ + source->pub.buffer = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, source->whole_image, + source_row, (JDIMENSION) 1, FALSE); + + source->current_row++; + return 1; +} + + +/* + * This method loads the image into whole_image during the first call on + * get_pixel_rows. The get_pixel_rows pointer is then adjusted to call + * get_memory_row on subsequent calls. + */ + +METHODDEF(JDIMENSION) +preload_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + tga_source_ptr source = (tga_source_ptr) sinfo; + JDIMENSION row; + cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; + + /* Read the data into a virtual array in input-file row order. */ + for (row = 0; row < cinfo->image_height; row++) { + if (progress != NULL) { + progress->pub.pass_counter = (long) row; + progress->pub.pass_limit = (long) cinfo->image_height; + (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); + } + source->pub.buffer = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, source->whole_image, row, (JDIMENSION) 1, TRUE); + (*source->get_pixel_rows) (cinfo, sinfo); + } + if (progress != NULL) + progress->completed_extra_passes++; + + /* Set up to read from the virtual array in unscrambled order */ + source->pub.get_pixel_rows = get_memory_row; + source->current_row = 0; + /* And read the first row */ + return get_memory_row(cinfo, sinfo); +} + + +/* + * Read the file header; return image size and component count. + */ + +METHODDEF(void) +start_input_tga (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + tga_source_ptr source = (tga_source_ptr) sinfo; + U_CHAR targaheader[18]; + int idlen, cmaptype, subtype, flags, interlace_type, components; + unsigned int width, height, maplen; + boolean is_bottom_up; + +#define GET_2B(offset) ((unsigned int) UCH(targaheader[offset]) + \ + (((unsigned int) UCH(targaheader[offset+1])) << 8)) + + if (! ReadOK(source->pub.input_file, targaheader, 18)) + ERREXIT(cinfo, JERR_INPUT_EOF); + + /* Pretend "15-bit" pixels are 16-bit --- we ignore attribute bit anyway */ + if (targaheader[16] == 15) + targaheader[16] = 16; + + idlen = UCH(targaheader[0]); + cmaptype = UCH(targaheader[1]); + subtype = UCH(targaheader[2]); + maplen = GET_2B(5); + width = GET_2B(12); + height = GET_2B(14); + source->pixel_size = UCH(targaheader[16]) >> 3; + flags = UCH(targaheader[17]); /* Image Descriptor byte */ + + is_bottom_up = ((flags & 0x20) == 0); /* bit 5 set => top-down */ + interlace_type = flags >> 6; /* bits 6/7 are interlace code */ + + if (cmaptype > 1 || /* cmaptype must be 0 or 1 */ + source->pixel_size < 1 || source->pixel_size > 4 || + (UCH(targaheader[16]) & 7) != 0 || /* bits/pixel must be multiple of 8 */ + interlace_type != 0) /* currently don't allow interlaced image */ + ERREXIT(cinfo, JERR_TGA_BADPARMS); + + if (subtype > 8) { + /* It's an RLE-coded file */ + source->read_pixel = read_rle_pixel; + source->block_count = source->dup_pixel_count = 0; + subtype -= 8; + } else { + /* Non-RLE file */ + source->read_pixel = read_non_rle_pixel; + } + + /* Now should have subtype 1, 2, or 3 */ + components = 3; /* until proven different */ + cinfo->in_color_space = JCS_RGB; + + switch (subtype) { + case 1: /* Colormapped image */ + if (source->pixel_size == 1 && cmaptype == 1) + source->get_pixel_rows = get_8bit_row; + else + ERREXIT(cinfo, JERR_TGA_BADPARMS); + TRACEMS2(cinfo, 1, JTRC_TGA_MAPPED, width, height); + break; + case 2: /* RGB image */ + switch (source->pixel_size) { + case 2: + source->get_pixel_rows = get_16bit_row; + break; + case 3: + source->get_pixel_rows = get_24bit_row; + break; + case 4: + source->get_pixel_rows = get_32bit_row; + break; + default: + ERREXIT(cinfo, JERR_TGA_BADPARMS); + break; + } + TRACEMS2(cinfo, 1, JTRC_TGA, width, height); + break; + case 3: /* Grayscale image */ + components = 1; + cinfo->in_color_space = JCS_GRAYSCALE; + if (source->pixel_size == 1) + source->get_pixel_rows = get_8bit_gray_row; + else + ERREXIT(cinfo, JERR_TGA_BADPARMS); + TRACEMS2(cinfo, 1, JTRC_TGA_GRAY, width, height); + break; + default: + ERREXIT(cinfo, JERR_TGA_BADPARMS); + break; + } + + if (is_bottom_up) { + /* Create a virtual array to buffer the upside-down image. */ + source->whole_image = (*cinfo->mem->request_virt_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, + (JDIMENSION) width * components, (JDIMENSION) height, (JDIMENSION) 1); + if (cinfo->progress != NULL) { + cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; + progress->total_extra_passes++; /* count file input as separate pass */ + } + /* source->pub.buffer will point to the virtual array. */ + source->pub.buffer_height = 1; /* in case anyone looks at it */ + source->pub.get_pixel_rows = preload_image; + } else { + /* Don't need a virtual array, but do need a one-row input buffer. */ + source->whole_image = NULL; + source->pub.buffer = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) width * components, (JDIMENSION) 1); + source->pub.buffer_height = 1; + source->pub.get_pixel_rows = source->get_pixel_rows; + } + + while (idlen--) /* Throw away ID field */ + (void) read_byte(source); + + if (maplen > 0) { + if (maplen > 256 || GET_2B(3) != 0) + ERREXIT(cinfo, JERR_TGA_BADCMAP); + /* Allocate space to store the colormap */ + source->colormap = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, (JDIMENSION) maplen, (JDIMENSION) 3); + /* and read it from the file */ + read_colormap(source, (int) maplen, UCH(targaheader[7])); + } else { + if (cmaptype) /* but you promised a cmap! */ + ERREXIT(cinfo, JERR_TGA_BADPARMS); + source->colormap = NULL; + } + + cinfo->input_components = components; + cinfo->data_precision = 8; + cinfo->image_width = width; + cinfo->image_height = height; +} + + +/* + * Finish up at the end of the file. + */ + +METHODDEF(void) +finish_input_tga (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) +{ + /* no work */ +} + + +/* + * The module selection routine for Targa format input. + */ + +GLOBAL(cjpeg_source_ptr) +jinit_read_targa (j_compress_ptr cinfo) +{ + tga_source_ptr source; + + /* Create module interface object */ + source = (tga_source_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(tga_source_struct)); + source->cinfo = cinfo; /* make back link for subroutines */ + /* Fill in method ptrs, except get_pixel_rows which start_input sets */ + source->pub.start_input = start_input_tga; + source->pub.finish_input = finish_input_tga; + + return (cjpeg_source_ptr) source; +} + +#endif /* TARGA_SUPPORTED */ diff --git a/gs/jpeg/structure.doc b/gs/jpeg/structure.doc new file mode 100644 index 000000000..51c9def7e --- /dev/null +++ b/gs/jpeg/structure.doc @@ -0,0 +1,948 @@ +IJG JPEG LIBRARY: SYSTEM ARCHITECTURE + +Copyright (C) 1991-1995, Thomas G. Lane. +This file is part of the Independent JPEG Group's software. +For conditions of distribution and use, see the accompanying README file. + + +This file provides an overview of the architecture of the IJG JPEG software; +that is, the functions of the various modules in the system and the interfaces +between modules. For more precise details about any data structure or calling +convention, see the include files and comments in the source code. + +We assume that the reader is already somewhat familiar with the JPEG standard. +The README file includes references for learning about JPEG. The file +libjpeg.doc describes the library from the viewpoint of an application +programmer using the library; it's best to read that file before this one. +Also, the file coderules.doc describes the coding style conventions we use. + +In this document, JPEG-specific terminology follows the JPEG standard: + A "component" means a color channel, e.g., Red or Luminance. + A "sample" is a single component value (i.e., one number in the image data). + A "coefficient" is a frequency coefficient (a DCT transform output number). + A "block" is an 8x8 group of samples or coefficients. + An "MCU" (minimum coded unit) is an interleaved set of blocks of size + determined by the sampling factors, or a single block in a + noninterleaved scan. +We do not use the terms "pixel" and "sample" interchangeably. When we say +pixel, we mean an element of the full-size image, while a sample is an element +of the downsampled image. Thus the number of samples may vary across +components while the number of pixels does not. (This terminology is not used +rigorously throughout the code, but it is used in places where confusion would +otherwise result.) + + +*** System features *** + +The IJG distribution contains two parts: + * A subroutine library for JPEG compression and decompression. + * cjpeg/djpeg, two sample applications that use the library to transform + JFIF JPEG files to and from several other image formats. +cjpeg/djpeg are of no great intellectual complexity: they merely add a simple +command-line user interface and I/O routines for several uncompressed image +formats. This document concentrates on the library itself. + +We desire the library to be capable of supporting all JPEG baseline, extended +sequential, and progressive DCT processes. Hierarchical processes are not +supported. + +The library does not support the lossless (spatial) JPEG process. Lossless +JPEG shares little or no code with lossy JPEG, and would normally be used +without the extensive pre- and post-processing provided by this library. +We feel that lossless JPEG is better handled by a separate library. + +Within these limits, any set of compression parameters allowed by the JPEG +spec should be readable for decompression. (We can be more restrictive about +what formats we can generate.) Although the system design allows for all +parameter values, some uncommon settings are not yet implemented and may +never be; nonintegral sampling ratios are the prime example. Furthermore, +we treat 8-bit vs. 12-bit data precision as a compile-time switch, not a +run-time option, because most machines can store 8-bit pixels much more +compactly than 12-bit. + +For legal reasons, JPEG arithmetic coding is not currently supported, but +extending the library to include it would be straightforward. + +By itself, the library handles only interchange JPEG datastreams --- in +particular the widely used JFIF file format. The library can be used by +surrounding code to process interchange or abbreviated JPEG datastreams that +are embedded in more complex file formats. (For example, libtiff uses this +library to implement JPEG compression within the TIFF file format.) + +The library includes a substantial amount of code that is not covered by the +JPEG standard but is necessary for typical applications of JPEG. These +functions preprocess the image before JPEG compression or postprocess it after +decompression. They include colorspace conversion, downsampling/upsampling, +and color quantization. This code can be omitted if not needed. + +A wide range of quality vs. speed tradeoffs are possible in JPEG processing, +and even more so in decompression postprocessing. The decompression library +provides multiple implementations that cover most of the useful tradeoffs, +ranging from very-high-quality down to fast-preview operation. On the +compression side we have generally not provided low-quality choices, since +compression is normally less time-critical. It should be understood that the +low-quality modes may not meet the JPEG standard's accuracy requirements; +nonetheless, they are useful for viewers. + + +*** Portability issues *** + +Portability is an essential requirement for the library. The key portability +issues that show up at the level of system architecture are: + +1. Memory usage. We want the code to be able to run on PC-class machines +with limited memory. Images should therefore be processed sequentially (in +strips), to avoid holding the whole image in memory at once. Where a +full-image buffer is necessary, we should be able to use either virtual memory +or temporary files. + +2. Near/far pointer distinction. To run efficiently on 80x86 machines, the +code should distinguish "small" objects (kept in near data space) from +"large" ones (kept in far data space). This is an annoying restriction, but +fortunately it does not impact code quality for less brain-damaged machines, +and the source code clutter turns out to be minimal with sufficient use of +pointer typedefs. + +3. Data precision. We assume that "char" is at least 8 bits, "short" and +"int" at least 16, "long" at least 32. The code will work fine with larger +data sizes, although memory may be used inefficiently in some cases. However, +the JPEG compressed datastream must ultimately appear on external storage as a +sequence of 8-bit bytes if it is to conform to the standard. This may pose a +problem on machines where char is wider than 8 bits. The library represents +compressed data as an array of values of typedef JOCTET. If no data type +exactly 8 bits wide is available, custom data source and data destination +modules must be written to unpack and pack the chosen JOCTET datatype into +8-bit external representation. + + +*** System overview *** + +The compressor and decompressor are each divided into two main sections: +the JPEG compressor or decompressor proper, and the preprocessing or +postprocessing functions. The interface between these two sections is the +image data that the official JPEG spec regards as its input or output: this +data is in the colorspace to be used for compression, and it is downsampled +to the sampling factors to be used. The preprocessing and postprocessing +steps are responsible for converting a normal image representation to or from +this form. (Those few applications that want to deal with YCbCr downsampled +data can skip the preprocessing or postprocessing step.) + +Looking more closely, the compressor library contains the following main +elements: + + Preprocessing: + * Color space conversion (e.g., RGB to YCbCr). + * Edge expansion and downsampling. Optionally, this step can do simple + smoothing --- this is often helpful for low-quality source data. + JPEG proper: + * MCU assembly, DCT, quantization. + * Entropy coding (sequential or progressive, Huffman or arithmetic). + +In addition to these modules we need overall control, marker generation, +and support code (memory management & error handling). There is also a +module responsible for physically writing the output data --- typically +this is just an interface to fwrite(), but some applications may need to +do something else with the data. + +The decompressor library contains the following main elements: + + JPEG proper: + * Entropy decoding (sequential or progressive, Huffman or arithmetic). + * Dequantization, inverse DCT, MCU disassembly. + Postprocessing: + * Upsampling. Optionally, this step may be able to do more general + rescaling of the image. + * Color space conversion (e.g., YCbCr to RGB). This step may also + provide gamma adjustment [ currently it does not ]. + * Optional color quantization (e.g., reduction to 256 colors). + * Optional color precision reduction (e.g., 24-bit to 15-bit color). + [This feature is not currently implemented.] + +We also need overall control, marker parsing, and a data source module. +The support code (memory management & error handling) can be shared with +the compression half of the library. + +There may be several implementations of each of these elements, particularly +in the decompressor, where a wide range of speed/quality tradeoffs is very +useful. It must be understood that some of the best speedups involve +merging adjacent steps in the pipeline. For example, upsampling, color space +conversion, and color quantization might all be done at once when using a +low-quality ordered-dither technique. The system architecture is designed to +allow such merging where appropriate. + + +Note: it is convenient to regard edge expansion (padding to block boundaries) +as a preprocessing/postprocessing function, even though the JPEG spec includes +it in compression/decompression. We do this because downsampling/upsampling +can be simplified a little if they work on padded data: it's not necessary to +have special cases at the right and bottom edges. Therefore the interface +buffer is always an integral number of blocks wide and high, and we expect +compression preprocessing to pad the source data properly. Padding will occur +only to the next block (8-sample) boundary. In an interleaved-scan situation, +additional dummy blocks may be used to fill out MCUs, but the MCU assembly and +disassembly logic will create or discard these blocks internally. (This is +advantageous for speed reasons, since we avoid DCTing the dummy blocks. +It also permits a small reduction in file size, because the compressor can +choose dummy block contents so as to minimize their size in compressed form. +Finally, it makes the interface buffer specification independent of whether +the file is actually interleaved or not.) Applications that wish to deal +directly with the downsampled data must provide similar buffering and padding +for odd-sized images. + + +*** Poor man's object-oriented programming *** + +It should be clear by now that we have a lot of quasi-independent processing +steps, many of which have several possible behaviors. To avoid cluttering the +code with lots of switch statements, we use a simple form of object-style +programming to separate out the different possibilities. + +For example, two different color quantization algorithms could be implemented +as two separate modules that present the same external interface; at runtime, +the calling code will access the proper module indirectly through an "object". + +We can get the limited features we need while staying within portable C. +The basic tool is a function pointer. An "object" is just a struct +containing one or more function pointer fields, each of which corresponds to +a method name in real object-oriented languages. During initialization we +fill in the function pointers with references to whichever module we have +determined we need to use in this run. Then invocation of the module is done +by indirecting through a function pointer; on most machines this is no more +expensive than a switch statement, which would be the only other way of +making the required run-time choice. The really significant benefit, of +course, is keeping the source code clean and well structured. + +We can also arrange to have private storage that varies between different +implementations of the same kind of object. We do this by making all the +module-specific object structs be separately allocated entities, which will +be accessed via pointers in the master compression or decompression struct. +The "public" fields or methods for a given kind of object are specified by +a commonly known struct. But a module's initialization code can allocate +a larger struct that contains the common struct as its first member, plus +additional private fields. With appropriate pointer casting, the module's +internal functions can access these private fields. (For a simple example, +see jdatadst.c, which implements the external interface specified by struct +jpeg_destination_mgr, but adds extra fields.) + +(Of course this would all be a lot easier if we were using C++, but we are +not yet prepared to assume that everyone has a C++ compiler.) + +An important benefit of this scheme is that it is easy to provide multiple +versions of any method, each tuned to a particular case. While a lot of +precalculation might be done to select an optimal implementation of a method, +the cost per invocation is constant. For example, the upsampling step might +have a "generic" method, plus one or more "hardwired" methods for the most +popular sampling factors; the hardwired methods would be faster because they'd +use straight-line code instead of for-loops. The cost to determine which +method to use is paid only once, at startup, and the selection criteria are +hidden from the callers of the method. + +This plan differs a little bit from usual object-oriented structures, in that +only one instance of each object class will exist during execution. The +reason for having the class structure is that on different runs we may create +different instances (choose to execute different modules). You can think of +the term "method" as denoting the common interface presented by a particular +set of interchangeable functions, and "object" as denoting a group of related +methods, or the total shared interface behavior of a group of modules. + + +*** Overall control structure *** + +We previously mentioned the need for overall control logic in the compression +and decompression libraries. In IJG implementations prior to v5, overall +control was mostly provided by "pipeline control" modules, which proved to be +large, unwieldy, and hard to understand. To improve the situation, the +control logic has been subdivided into multiple modules. The control modules +consist of: + +1. Master control for module selection and initialization. This has two +responsibilities: + + 1A. Startup initialization at the beginning of image processing. + The individual processing modules to be used in this run are selected + and given initialization calls. + + 1B. Per-pass control. This determines how many passes will be performed + and calls each active processing module to configure itself + appropriately at the beginning of each pass. End-of-pass processing, + where necessary, is also invoked from the master control module. + + Method selection is partially distributed, in that a particular processing + module may contain several possible implementations of a particular method, + which it will select among when given its initialization call. The master + control code need only be concerned with decisions that affect more than + one module. + +2. Data buffering control. A separate control module exists for each + inter-processing-step data buffer. This module is responsible for + invoking the processing steps that write or read that data buffer. + +Each buffer controller sees the world as follows: + +input data => processing step A => buffer => processing step B => output data + | | | + ------------------ controller ------------------ + +The controller knows the dataflow requirements of steps A and B: how much data +they want to accept in one chunk and how much they output in one chunk. Its +function is to manage its buffer and call A and B at the proper times. + +A data buffer control module may itself be viewed as a processing step by a +higher-level control module; thus the control modules form a binary tree with +elementary processing steps at the leaves of the tree. + +The control modules are objects. A considerable amount of flexibility can +be had by replacing implementations of a control module. For example: +* Merging of adjacent steps in the pipeline is done by replacing a control + module and its pair of processing-step modules with a single processing- + step module. (Hence the possible merges are determined by the tree of + control modules.) +* In some processing modes, a given interstep buffer need only be a "strip" + buffer large enough to accommodate the desired data chunk sizes. In other + modes, a full-image buffer is needed and several passes are required. + The control module determines which kind of buffer is used and manipulates + virtual array buffers as needed. One or both processing steps may be + unaware of the multi-pass behavior. + +In theory, we might be able to make all of the data buffer controllers +interchangeable and provide just one set of implementations for all. In +practice, each one contains considerable special-case processing for its +particular job. The buffer controller concept should be regarded as an +overall system structuring principle, not as a complete description of the +task performed by any one controller. + + +*** Compression object structure *** + +Here is a sketch of the logical structure of the JPEG compression library: + + |-- Colorspace conversion + |-- Preprocessing controller --| + | |-- Downsampling +Main controller --| + | |-- Forward DCT, quantize + |-- Coefficient controller --| + |-- Entropy encoding + +This sketch also describes the flow of control (subroutine calls) during +typical image data processing. Each of the components shown in the diagram is +an "object" which may have several different implementations available. One +or more source code files contain the actual implementation(s) of each object. + +The objects shown above are: + +* Main controller: buffer controller for the subsampled-data buffer, which + holds the preprocessed input data. This controller invokes preprocessing to + fill the subsampled-data buffer, and JPEG compression to empty it. There is + usually no need for a full-image buffer here; a strip buffer is adequate. + +* Preprocessing controller: buffer controller for the downsampling input data + buffer, which lies between colorspace conversion and downsampling. Note + that a unified conversion/downsampling module would probably replace this + controller entirely. + +* Colorspace conversion: converts application image data into the desired + JPEG color space; also changes the data from pixel-interleaved layout to + separate component planes. Processes one pixel row at a time. + +* Downsampling: performs reduction of chroma components as required. + Optionally may perform pixel-level smoothing as well. Processes a "row + group" at a time, where a row group is defined as Vmax pixel rows of each + component before downsampling, and Vk sample rows afterwards (remember Vk + differs across components). Some downsampling or smoothing algorithms may + require context rows above and below the current row group; the + preprocessing controller is responsible for supplying these rows via proper + buffering. The downsampler is responsible for edge expansion at the right + edge (i.e., extending each sample row to a multiple of 8 samples); but the + preprocessing controller is responsible for vertical edge expansion (i.e., + duplicating the bottom sample row as needed to make a multiple of 8 rows). + +* Coefficient controller: buffer controller for the DCT-coefficient data. + This controller handles MCU assembly, including insertion of dummy DCT + blocks when needed at the right or bottom edge. When performing + Huffman-code optimization or emitting a multiscan JPEG file, this + controller is responsible for buffering the full image. The equivalent of + one fully interleaved MCU row of subsampled data is processed per call, + even when the JPEG file is noninterleaved. + +* Forward DCT and quantization: Perform DCT, quantize, and emit coefficients. + Works on one or more DCT blocks at a time. (Note: the coefficients are now + emitted in normal array order, which the entropy encoder is expected to + convert to zigzag order as necessary. Prior versions of the IJG code did + the conversion to zigzag order within the quantization step.) + +* Entropy encoding: Perform Huffman or arithmetic entropy coding and emit the + coded data to the data destination module. Works on one MCU per call. + For progressive JPEG, the same DCT blocks are fed to the entropy coder + during each pass, and the coder must emit the appropriate subset of + coefficients. + +In addition to the above objects, the compression library includes these +objects: + +* Master control: determines the number of passes required, controls overall + and per-pass initialization of the other modules. + +* Marker writing: generates JPEG markers (except for RSTn, which is emitted + by the entropy encoder when needed). + +* Data destination manager: writes the output JPEG datastream to its final + destination (e.g., a file). The destination manager supplied with the + library knows how to write to a stdio stream; for other behaviors, the + surrounding application may provide its own destination manager. + +* Memory manager: allocates and releases memory, controls virtual arrays + (with backing store management, where required). + +* Error handler: performs formatting and output of error and trace messages; + determines handling of nonfatal errors. The surrounding application may + override some or all of this object's methods to change error handling. + +* Progress monitor: supports output of "percent-done" progress reports. + This object represents an optional callback to the surrounding application: + if wanted, it must be supplied by the application. + +The error handler, destination manager, and progress monitor objects are +defined as separate objects in order to simplify application-specific +customization of the JPEG library. A surrounding application may override +individual methods or supply its own all-new implementation of one of these +objects. The object interfaces for these objects are therefore treated as +part of the application interface of the library, whereas the other objects +are internal to the library. + +The error handler and memory manager are shared by JPEG compression and +decompression; the progress monitor, if used, may be shared as well. + + +*** Decompression object structure *** + +Here is a sketch of the logical structure of the JPEG decompression library: + + |-- Entropy decoding + |-- Coefficient controller --| + | |-- Dequantize, Inverse DCT +Main controller --| + | |-- Upsampling + |-- Postprocessing controller --| |-- Colorspace conversion + |-- Color quantization + |-- Color precision reduction + +As before, this diagram also represents typical control flow. The objects +shown are: + +* Main controller: buffer controller for the subsampled-data buffer, which + holds the output of JPEG decompression proper. This controller's primary + task is to feed the postprocessing procedure. Some upsampling algorithms + may require context rows above and below the current row group; when this + is true, the main controller is responsible for managing its buffer so as + to make context rows available. In the current design, the main buffer is + always a strip buffer; a full-image buffer is never required. + +* Coefficient controller: buffer controller for the DCT-coefficient data. + This controller handles MCU disassembly, including deletion of any dummy + DCT blocks at the right or bottom edge. When reading a multiscan JPEG + file, this controller is responsible for buffering the full image. + (Buffering DCT coefficients, rather than samples, is necessary to support + progressive JPEG.) The equivalent of one fully interleaved MCU row of + subsampled data is processed per call, even when the source JPEG file is + noninterleaved. + +* Entropy decoding: Read coded data from the data source module and perform + Huffman or arithmetic entropy decoding. Works on one MCU per call. + For progressive JPEG decoding, the coefficient controller supplies the prior + coefficients of each MCU (initially all zeroes), which the entropy decoder + modifies in each scan. + +* Dequantization and inverse DCT: like it says. Note that the coefficients + buffered by the coefficient controller have NOT been dequantized; we + merge dequantization and inverse DCT into a single step for speed reasons. + When scaled-down output is asked for, simplified DCT algorithms may be used + that emit only 1x1, 2x2, or 4x4 samples per DCT block, not the full 8x8. + Works on one DCT block at a time. + +* Postprocessing controller: buffer controller for the color quantization + input buffer, when quantization is in use. (Without quantization, this + controller just calls the upsampler.) For two-pass quantization, this + controller is responsible for buffering the full-image data. + +* Upsampling: restores chroma components to full size. (May support more + general output rescaling, too. Note that if undersized DCT outputs have + been emitted by the DCT module, this module must adjust so that properly + sized outputs are created.) Works on one row group at a time. This module + also calls the color conversion module, so its top level is effectively a + buffer controller for the upsampling->color conversion buffer. However, in + all but the highest-quality operating modes, upsampling and color + conversion are likely to be merged into a single step. + +* Colorspace conversion: convert from JPEG color space to output color space, + and change data layout from separate component planes to pixel-interleaved. + Works on one pixel row at a time. + +* Color quantization: reduce the data to colormapped form, using either an + externally specified colormap or an internally generated one. This module + is not used for full-color output. Works on one pixel row at a time; may + require two passes to generate a color map. Note that the output will + always be a single component representing colormap indexes. In the current + design, the output values are JSAMPLEs, so an 8-bit compilation cannot + quantize to more than 256 colors. This is unlikely to be a problem in + practice. + +* Color reduction: this module handles color precision reduction, e.g., + generating 15-bit color (5 bits/primary) from JPEG's 24-bit output. + Not quite clear yet how this should be handled... should we merge it with + colorspace conversion??? + +Note that some high-speed operating modes might condense the entire +postprocessing sequence to a single module (upsample, color convert, and +quantize in one step). + +In addition to the above objects, the decompression library includes these +objects: + +* Master control: determines the number of passes required, controls overall + and per-pass initialization of the other modules. This is subdivided into + input and output control: jdinput.c controls only input-side processing, + while jdmaster.c handles overall initialization and output-side control. + +* Marker reading: decodes JPEG markers (except for RSTn). + +* Data source manager: supplies the input JPEG datastream. The source + manager supplied with the library knows how to read from a stdio stream; + for other behaviors, the surrounding application may provide its own source + manager. + +* Memory manager: same as for compression library. + +* Error handler: same as for compression library. + +* Progress monitor: same as for compression library. + +As with compression, the data source manager, error handler, and progress +monitor are candidates for replacement by a surrounding application. + + +*** Decompression input and output separation *** + +To support efficient incremental display of progressive JPEG files, the +decompressor is divided into two sections that can run independently: + +1. Data input includes marker parsing, entropy decoding, and input into the + coefficient controller's DCT coefficient buffer. Note that this + processing is relatively cheap and fast. + +2. Data output reads from the DCT coefficient buffer and performs the IDCT + and all postprocessing steps. + +For a progressive JPEG file, the data input processing is allowed to get +arbitrarily far ahead of the data output processing. (This occurs only +if the application calls jpeg_consume_input(); otherwise input and output +run in lockstep, since the input section is called only when the output +section needs more data.) In this way the application can avoid making +extra display passes when data is arriving faster than the display pass +can run. Furthermore, it is possible to abort an output pass without +losing anything, since the coefficient buffer is read-only as far as the +output section is concerned. See libjpeg.doc for more detail. + +A full-image coefficient array is only created if the JPEG file has multiple +scans (or if the application specifies buffered-image mode anyway). When +reading a single-scan file, the coefficient controller normally creates only +a one-MCU buffer, so input and output processing must run in lockstep in this +case. jpeg_consume_input() is effectively a no-op in this situation. + +The main impact of dividing the decompressor in this fashion is that we must +be very careful with shared variables in the cinfo data structure. Each +variable that can change during the course of decompression must be +classified as belonging to data input or data output, and each section must +look only at its own variables. For example, the data output section may not +depend on any of the variables that describe the current scan in the JPEG +file, because these may change as the data input section advances into a new +scan. + +The progress monitor is (somewhat arbitrarily) defined to treat input of the +file as one pass when buffered-image mode is not used, and to ignore data +input work completely when buffered-image mode is used. Note that the +library has no reliable way to predict the number of passes when dealing +with a progressive JPEG file, nor can it predict the number of output passes +in buffered-image mode. So the work estimate is inherently bogus anyway. + +No comparable division is currently made in the compression library, because +there isn't any real need for it. + + +*** Data formats *** + +Arrays of pixel sample values use the following data structure: + + typedef something JSAMPLE; a pixel component value, 0..MAXJSAMPLE + typedef JSAMPLE *JSAMPROW; ptr to a row of samples + typedef JSAMPROW *JSAMPARRAY; ptr to a list of rows + typedef JSAMPARRAY *JSAMPIMAGE; ptr to a list of color-component arrays + +The basic element type JSAMPLE will typically be one of unsigned char, +(signed) char, or short. Short will be used if samples wider than 8 bits are +to be supported (this is a compile-time option). Otherwise, unsigned char is +used if possible. If the compiler only supports signed chars, then it is +necessary to mask off the value when reading. Thus, all reads of JSAMPLE +values must be coded as "GETJSAMPLE(value)", where the macro will be defined +as "((value) & 0xFF)" on signed-char machines and "((int) (value))" elsewhere. + +With these conventions, JSAMPLE values can be assumed to be >= 0. This helps +simplify correct rounding during downsampling, etc. The JPEG standard's +specification that sample values run from -128..127 is accommodated by +subtracting 128 just as the sample value is copied into the source array for +the DCT step (this will be an array of signed ints). Similarly, during +decompression the output of the IDCT step will be immediately shifted back to +0..255. (NB: different values are required when 12-bit samples are in use. +The code is written in terms of MAXJSAMPLE and CENTERJSAMPLE, which will be +defined as 255 and 128 respectively in an 8-bit implementation, and as 4095 +and 2048 in a 12-bit implementation.) + +We use a pointer per row, rather than a two-dimensional JSAMPLE array. This +choice costs only a small amount of memory and has several benefits: +* Code using the data structure doesn't need to know the allocated width of + the rows. This simplifies edge expansion/compression, since we can work + in an array that's wider than the logical picture width. +* Indexing doesn't require multiplication; this is a performance win on many + machines. +* Arrays with more than 64K total elements can be supported even on machines + where malloc() cannot allocate chunks larger than 64K. +* The rows forming a component array may be allocated at different times + without extra copying. This trick allows some speedups in smoothing steps + that need access to the previous and next rows. + +Note that each color component is stored in a separate array; we don't use the +traditional layout in which the components of a pixel are stored together. +This simplifies coding of modules that work on each component independently, +because they don't need to know how many components there are. Furthermore, +we can read or write each component to a temporary file independently, which +is helpful when dealing with noninterleaved JPEG files. + +In general, a specific sample value is accessed by code such as + GETJSAMPLE(image[colorcomponent][row][col]) +where col is measured from the image left edge, but row is measured from the +first sample row currently in memory. Either of the first two indexings can +be precomputed by copying the relevant pointer. + + +Since most image-processing applications prefer to work on images in which +the components of a pixel are stored together, the data passed to or from the +surrounding application uses the traditional convention: a single pixel is +represented by N consecutive JSAMPLE values, and an image row is an array of +(# of color components)*(image width) JSAMPLEs. One or more rows of data can +be represented by a pointer of type JSAMPARRAY in this scheme. This scheme is +converted to component-wise storage inside the JPEG library. (Applications +that want to skip JPEG preprocessing or postprocessing will have to contend +with component-wise storage.) + + +Arrays of DCT-coefficient values use the following data structure: + + typedef short JCOEF; a 16-bit signed integer + typedef JCOEF JBLOCK[DCTSIZE2]; an 8x8 block of coefficients + typedef JBLOCK *JBLOCKROW; ptr to one horizontal row of 8x8 blocks + typedef JBLOCKROW *JBLOCKARRAY; ptr to a list of such rows + typedef JBLOCKARRAY *JBLOCKIMAGE; ptr to a list of color component arrays + +The underlying type is at least a 16-bit signed integer; while "short" is big +enough on all machines of interest, on some machines it is preferable to use +"int" for speed reasons, despite the storage cost. Coefficients are grouped +into 8x8 blocks (but we always use #defines DCTSIZE and DCTSIZE2 rather than +"8" and "64"). + +The contents of a coefficient block may be in either "natural" or zigzagged +order, and may be true values or divided by the quantization coefficients, +depending on where the block is in the processing pipeline. In the current +library, coefficient blocks are kept in natural order everywhere; the entropy +codecs zigzag or dezigzag the data as it is written or read. The blocks +contain quantized coefficients everywhere outside the DCT/IDCT subsystems. +(This latter decision may need to be revisited to support variable +quantization a la JPEG Part 3.) + +Notice that the allocation unit is now a row of 8x8 blocks, corresponding to +eight rows of samples. Otherwise the structure is much the same as for +samples, and for the same reasons. + +On machines where malloc() can't handle a request bigger than 64Kb, this data +structure limits us to rows of less than 512 JBLOCKs, or a picture width of +4000+ pixels. This seems an acceptable restriction. + + +On 80x86 machines, the bottom-level pointer types (JSAMPROW and JBLOCKROW) +must be declared as "far" pointers, but the upper levels can be "near" +(implying that the pointer lists are allocated in the DS segment). +We use a #define symbol FAR, which expands to the "far" keyword when +compiling on 80x86 machines and to nothing elsewhere. + + +*** Suspendable processing *** + +In some applications it is desirable to use the JPEG library as an +incremental, memory-to-memory filter. In this situation the data source or +destination may be a limited-size buffer, and we can't rely on being able to +empty or refill the buffer at arbitrary times. Instead the application would +like to have control return from the library at buffer overflow/underrun, and +then resume compression or decompression at a later time. + +This scenario is supported for simple cases. (For anything more complex, we +recommend that the application "bite the bullet" and develop real multitasking +capability.) The libjpeg.doc file goes into more detail about the usage and +limitations of this capability; here we address the implications for library +structure. + +The essence of the problem is that the entropy codec (coder or decoder) must +be prepared to stop at arbitrary times. In turn, the controllers that call +the entropy codec must be able to stop before having produced or consumed all +the data that they normally would handle in one call. That part is reasonably +straightforward: we make the controller call interfaces include "progress +counters" which indicate the number of data chunks successfully processed, and +we require callers to test the counter rather than just assume all of the data +was processed. + +Rather than trying to restart at an arbitrary point, the current Huffman +codecs are designed to restart at the beginning of the current MCU after a +suspension due to buffer overflow/underrun. At the start of each call, the +codec's internal state is loaded from permanent storage (in the JPEG object +structures) into local variables. On successful completion of the MCU, the +permanent state is updated. (This copying is not very expensive, and may even +lead to *improved* performance if the local variables can be registerized.) +If a suspension occurs, the codec simply returns without updating the state, +thus effectively reverting to the start of the MCU. Note that this implies +leaving some data unprocessed in the source/destination buffer (ie, the +compressed partial MCU). The data source/destination module interfaces are +specified so as to make this possible. This also implies that the data buffer +must be large enough to hold a worst-case compressed MCU; a couple thousand +bytes should be enough. + +In a successive-approximation AC refinement scan, the progressive Huffman +decoder has to be able to undo assignments of newly nonzero coefficients if it +suspends before the MCU is complete, since decoding requires distinguishing +previously-zero and previously-nonzero coefficients. This is a bit tedious +but probably won't have much effect on performance. Other variants of Huffman +decoding need not worry about this, since they will just store the same values +again if forced to repeat the MCU. + +This approach would probably not work for an arithmetic codec, since its +modifiable state is quite large and couldn't be copied cheaply. Instead it +would have to suspend and resume exactly at the point of the buffer end. + +The JPEG marker reader is designed to cope with suspension at an arbitrary +point. It does so by backing up to the start of the marker parameter segment, +so the data buffer must be big enough to hold the largest marker of interest. +Again, a couple KB should be adequate. (A special "skip" convention is used +to bypass COM and APPn markers, so these can be larger than the buffer size +without causing problems; otherwise a 64K buffer would be needed in the worst +case.) + +The JPEG marker writer currently does *not* cope with suspension. I feel that +this is not necessary; it is much easier simply to require the application to +ensure there is enough buffer space before starting. (An empty 2K buffer is +more than sufficient for the header markers; and ensuring there are a dozen or +two bytes available before calling jpeg_finish_compress() will suffice for the +trailer.) This would not work for writing multi-scan JPEG files, but +we simply do not intend to support that capability with suspension. + + +*** Memory manager services *** + +The JPEG library's memory manager controls allocation and deallocation of +memory, and it manages large "virtual" data arrays on machines where the +operating system does not provide virtual memory. Note that the same +memory manager serves both compression and decompression operations. + +In all cases, allocated objects are tied to a particular compression or +decompression master record, and they will be released when that master +record is destroyed. + +The memory manager does not provide explicit deallocation of objects. +Instead, objects are created in "pools" of free storage, and a whole pool +can be freed at once. This approach helps prevent storage-leak bugs, and +it speeds up operations whenever malloc/free are slow (as they often are). +The pools can be regarded as lifetime identifiers for objects. Two +pools/lifetimes are defined: + * JPOOL_PERMANENT lasts until master record is destroyed + * JPOOL_IMAGE lasts until done with image (JPEG datastream) +Permanent lifetime is used for parameters and tables that should be carried +across from one datastream to another; this includes all application-visible +parameters. Image lifetime is used for everything else. (A third lifetime, +JPOOL_PASS = one processing pass, was originally planned. However it was +dropped as not being worthwhile. The actual usage patterns are such that the +peak memory usage would be about the same anyway; and having per-pass storage +substantially complicates the virtual memory allocation rules --- see below.) + +The memory manager deals with three kinds of object: +1. "Small" objects. Typically these require no more than 10K-20K total. +2. "Large" objects. These may require tens to hundreds of K depending on + image size. Semantically they behave the same as small objects, but we + distinguish them for two reasons: + * On MS-DOS machines, large objects are referenced by FAR pointers, + small objects by NEAR pointers. + * Pool allocation heuristics may differ for large and small objects. + Note that individual "large" objects cannot exceed the size allowed by + type size_t, which may be 64K or less on some machines. +3. "Virtual" objects. These are large 2-D arrays of JSAMPLEs or JBLOCKs + (typically large enough for the entire image being processed). The + memory manager provides stripwise access to these arrays. On machines + without virtual memory, the rest of the array may be swapped out to a + temporary file. + +(Note: JSAMPARRAY and JBLOCKARRAY data structures are a combination of large +objects for the data proper and small objects for the row pointers. For +convenience and speed, the memory manager provides single routines to create +these structures. Similarly, virtual arrays include a small control block +and a JSAMPARRAY or JBLOCKARRAY working buffer, all created with one call.) + +In the present implementation, virtual arrays are only permitted to have image +lifespan. (Permanent lifespan would not be reasonable, and pass lifespan is +not very useful since a virtual array's raison d'etre is to store data for +multiple passes through the image.) We also expect that only "small" objects +will be given permanent lifespan, though this restriction is not required by +the memory manager. + +In a non-virtual-memory machine, some performance benefit can be gained by +making the in-memory buffers for virtual arrays be as large as possible. +(For small images, the buffers might fit entirely in memory, so blind +swapping would be very wasteful.) The memory manager will adjust the height +of the buffers to fit within a prespecified maximum memory usage. In order +to do this in a reasonably optimal fashion, the manager needs to allocate all +of the virtual arrays at once. Therefore, there isn't a one-step allocation +routine for virtual arrays; instead, there is a "request" routine that simply +allocates the control block, and a "realize" routine (called just once) that +determines space allocation and creates all of the actual buffers. The +realize routine must allow for space occupied by non-virtual large objects. +(We don't bother to factor in the space needed for small objects, on the +grounds that it isn't worth the trouble.) + +To support all this, we establish the following protocol for doing business +with the memory manager: + 1. Modules must request virtual arrays (which may have only image lifespan) + during the initial setup phase, i.e., in their jinit_xxx routines. + 2. All "large" objects (including JSAMPARRAYs and JBLOCKARRAYs) must also be + allocated during initial setup. + 3. realize_virt_arrays will be called at the completion of initial setup. + The above conventions ensure that sufficient information is available + for it to choose a good size for virtual array buffers. +Small objects of any lifespan may be allocated at any time. We expect that +the total space used for small objects will be small enough to be negligible +in the realize_virt_arrays computation. + +In a virtual-memory machine, we simply pretend that the available space is +infinite, thus causing realize_virt_arrays to decide that it can allocate all +the virtual arrays as full-size in-memory buffers. The overhead of the +virtual-array access protocol is very small when no swapping occurs. + +A virtual array can be specified to be "pre-zeroed"; when this flag is set, +never-yet-written sections of the array are set to zero before being made +available to the caller. If this flag is not set, never-written sections +of the array contain garbage. (This feature exists primarily because the +equivalent logic would otherwise be needed in jdcoefct.c for progressive +JPEG mode; we may as well make it available for possible other uses.) + +The first write pass on a virtual array is required to occur in top-to-bottom +order; read passes, as well as any write passes after the first one, may +access the array in any order. This restriction exists partly to simplify +the virtual array control logic, and partly because some file systems may not +support seeking beyond the current end-of-file in a temporary file. The main +implication of this restriction is that rearrangement of rows (such as +converting top-to-bottom data order to bottom-to-top) must be handled while +reading data out of the virtual array, not while putting it in. + + +*** Memory manager internal structure *** + +To isolate system dependencies as much as possible, we have broken the +memory manager into two parts. There is a reasonably system-independent +"front end" (jmemmgr.c) and a "back end" that contains only the code +likely to change across systems. All of the memory management methods +outlined above are implemented by the front end. The back end provides +the following routines for use by the front end (none of these routines +are known to the rest of the JPEG code): + +jpeg_mem_init, jpeg_mem_term system-dependent initialization/shutdown + +jpeg_get_small, jpeg_free_small interface to malloc and free library routines + (or their equivalents) + +jpeg_get_large, jpeg_free_large interface to FAR malloc/free in MSDOS machines; + else usually the same as + jpeg_get_small/jpeg_free_small + +jpeg_mem_available estimate available memory + +jpeg_open_backing_store create a backing-store object + +read_backing_store, manipulate a backing-store object +write_backing_store, +close_backing_store + +On some systems there will be more than one type of backing-store object +(specifically, in MS-DOS a backing store file might be an area of extended +memory as well as a disk file). jpeg_open_backing_store is responsible for +choosing how to implement a given object. The read/write/close routines +are method pointers in the structure that describes a given object; this +lets them be different for different object types. + +It may be necessary to ensure that backing store objects are explicitly +released upon abnormal program termination. For example, MS-DOS won't free +extended memory by itself. To support this, we will expect the main program +or surrounding application to arrange to call self_destruct (typically via +jpeg_destroy) upon abnormal termination. This may require a SIGINT signal +handler or equivalent. We don't want to have the back end module install its +own signal handler, because that would pre-empt the surrounding application's +ability to control signal handling. + +The IJG distribution includes several memory manager back end implementations. +Usually the same back end should be suitable for all applications on a given +system, but it is possible for an application to supply its own back end at +need. + + +*** Implications of DNL marker *** + +Some JPEG files may use a DNL marker to postpone definition of the image +height (this would be useful for a fax-like scanner's output, for instance). +In these files the SOF marker claims the image height is 0, and you only +find out the true image height at the end of the first scan. + +We could read these files as follows: +1. Upon seeing zero image height, replace it by 65535 (the maximum allowed). +2. When the DNL is found, update the image height in the global image + descriptor. +This implies that control modules must avoid making copies of the image +height, and must re-test for termination after each MCU row. This would +be easy enough to do. + +In cases where image-size data structures are allocated, this approach will +result in very inefficient use of virtual memory or much-larger-than-necessary +temporary files. This seems acceptable for something that probably won't be a +mainstream usage. People might have to forgo use of memory-hogging options +(such as two-pass color quantization or noninterleaved JPEG files) if they +want efficient conversion of such files. (One could improve efficiency by +demanding a user-supplied upper bound for the height, less than 65536; in most +cases it could be much less.) + +The standard also permits the SOF marker to overestimate the image height, +with a DNL to give the true, smaller height at the end of the first scan. +This would solve the space problems if the overestimate wasn't too great. +However, it implies that you don't even know whether DNL will be used. + +This leads to a couple of very serious objections: +1. Testing for a DNL marker must occur in the inner loop of the decompressor's + Huffman decoder; this implies a speed penalty whether the feature is used + or not. +2. There is no way to hide the last-minute change in image height from an + application using the decoder. Thus *every* application using the IJG + library would suffer a complexity penalty whether it cared about DNL or + not. +We currently do not support DNL because of these problems. + +A different approach is to insist that DNL-using files be preprocessed by a +separate program that reads ahead to the DNL, then goes back and fixes the SOF +marker. This is a much simpler solution and is probably far more efficient. +Even if one wants piped input, buffering the first scan of the JPEG file needs +a lot smaller temp file than is implied by the maximum-height method. For +this approach we'd simply treat DNL as a no-op in the decompressor (at most, +check that it matches the SOF image height). + +We will not worry about making the compressor capable of outputting DNL. +Something similar to the first scheme above could be applied if anyone ever +wants to make that work. diff --git a/gs/jpeg/testimg.gif b/gs/jpeg/testimg.gif new file mode 100644 index 000000000..ca4036187 Binary files /dev/null and b/gs/jpeg/testimg.gif differ diff --git a/gs/jpeg/testimg.jpg b/gs/jpeg/testimg.jpg new file mode 100644 index 000000000..b34ca5d31 Binary files /dev/null and b/gs/jpeg/testimg.jpg differ diff --git a/gs/jpeg/testimg.ppm b/gs/jpeg/testimg.ppm new file mode 100644 index 000000000..9d81ce24a --- /dev/null +++ b/gs/jpeg/testimg.ppm @@ -0,0 +1,4 @@ +P6 +227 149 +255 +0/-0/-10.21/51.51.62/62/83/83/:3-:3-:3-:3-:3-:3-:2/91.91.80-80-91.91.:2/80-80-80-80-80-80-80-80-6.+6.+6.+5-*5-*4,)4,)4,)4,)4,)4,)4,)4,)4,)4,)2-)/*$/,%/,%0-&1.'2/(30)30)63,63,74-85.85.96/:70:7.A:0B<0D>2F@4IA4JB5KC6KC6MD5MD5OC3NB2OC3OC3PD4RE5R?1Y?2b@4nB5}E6‹H8™G9£F7¯G:¸G9¾E:ÅG;ÇG>ÊG?ËH@ÐE@çFLíCLëDKëEIîCIïBDñ>Bô=Aø;A÷:@ô:?ð×?<ËA7»=/µ@.µ@.´?-´?-³@-²?-¯@-­@,ªA,¦A-¢B,Ÿ@*›A)˜@*–A,”>-’?/’?/‘>.‘>,=+’<+’<+”?+”?+”=*”=*”=*•>+–?,–@/–?6•>5—=2Ÿ?1©B3³D3¼D4¿D4¹?0µA2¬F8žH;‡H9oA2T8*C3&=5295495473271160050-50-72/72/72/61.61-50,50,41,//-.0-//-//-0/-0/-2.-2.-5,-4+,4*+3)*7(+=.1E69P:0U?1^A3jC4xD6„E4’E5œC3§C4¯A4µA4¼B7ÀD:ÄE<ÅF=ÍC@áEIçBIèCIêDHíDGïBDó@Cö?Cø;A÷:@ô:?ðÕ@<Ê@6¹>/µ@.´?-´?-´?-²?,°?-¯@-­@,©@+¦A-¡A+Ÿ@*›A)˜@*–A,”>-’?/‘>.‘>.‘>,=+’<+’<+”?+“>*”=*”=*”=*•>+–?,–@/”@5•>5˜>3 >1«A3µD4½C4¿D5»A2·C6¬F8œI;…G:l@3S9*B4)>63:6595484382271161.61.72/72/72/61.61-50,50,41,//-.0-//-//-0/-0/-2.-2.-3--5,-4*+3)*5)+<-0C47N8:d>=vEA†JINLšTV¤aj¥l}rŽ‘{¢†€®…¹{„»ou©[[QHuOCiOFeOG_PH_RN_[Yfnotƒ‡ˆ”™•™ž—š ”™‘ƒ~ojkY][LVSJXSZVRaXQa/.,/.,0/-10.40-40-51.51.72.72.72.72.92,92,92,92,91.80.7/-7/-7/-7/-80.91/80.80.80.80.80.80.80.80.6.,5-+5-+5-+4,*4,*4,*4,*5-+5-+5-+5-+5-+5-+5-+3.*2-'1.'2/(30)30)41*41*52+63,63,63,74-85.96/96/:7.?8.@:.B<0D>2G?4H@5H@3H@3I@1I@1K?1K?1K?/L@0MA1NB2MA1QA1YB2dC2qC3|C2‡B2’A0˜<- :+§;.¯=2µ@6ºD:¿F=ÅD>ÙCEá@FãBGçBFêDFðCEôADø?Dú;@ù:?õ;@ð=@è@@ÜA=Ñ@;Æ@5·=.³@-³@-²?,²?-°?-¯>,­@,ª?-§@-¥@,¡A+A,š?*˜@*•@+”>-‘>.‘>.‘>.=+=+=+=+‘>,‘>,’<+’<+“=,“=,”?+•?.•A6–?5š>3£>2¯A4¹C5¿D5ÁC5ÀD8¸F;®I=™J=G;h@4Q:,B5,?74=77<66:4494183072/72/62/62/62/51.52-41,41,21,.0-,1-.0-.0-//-//-0/-2.-5//4..5,-4*+4*+9-/>24I56[97l?9|E@†IDOM˜[`›fv”mˆŒwžƒ}­}‚¹u~·fm¤TV‰MEvLAkMAeOFcQHcMH^NK\[[eqty…‰ˆ‡Œ†Šˆ…†Š|xzlfiXZ[MVSLZU[ZT`[S`.-+/.,/.,0/-3/,40-40-40-61-61-61-61-81+81+81+81+7/-7/-6.,6.,6.,6.,7/-7/-80.80.80.80.80.80.80.80.5-+5-+5-+4,*4,*4,*3+)3+)6.,6.,6.,6.,6.,6.,6.,4/,30+30)30)41*41*52+52+52+52+52+63,74-85.85.96/96->7-?9-@:.B<0E=2E=2F>1F>1G=1G>/H<.I=/I=/J>.L@0JA0KD2NE4UD4^D3iD2sB1~A/†?-Œ9)”9'9*£<-¬@3³E8¸H<ÁF>ÒDCÚACÞBCâDCçCDìBCó@C÷?Aú;@ù:?õ;@î>@åA@ÚB=Í@9Â@3µ=-°@,°@,°@,¯>,®?,®?,¬?+©@-¦?,£@+ @*œ@+˜@*–@)”?*‘>,‘>.‘>.=-=+=+<*<*=+=+<*<*’<+‘>,”>-’?-•A6–?5œ>2¦@4²B6¼C8ÁC7ÂB7ÂF<ºJ?¬L@—K>|F:b@4L:.A7-@85>96=77<74:5294183083062/62/62/32.52-21,21,12--2.-2./1./1.00.00.10.10.5106005//5,-4+,6,-:01D22T71c;3qA7{E;‚HD‰RU_l‹i‚ƒs˜}y«x}µowµ`f¢QR‹LEyL@pL@hPEgQFfLC^GBVMLZ^^fjnquyxx}wz€vwzokoa`bTWYLTTL]WY]V]]V^------.-+/.,0/-10.3/,40-3/,3/,4/+4/+4/+4/+6/)6/)4/,4/,3.+3.+3.+3.+4/,4/,50-50-50-50-50-50-50-50-3.+3.+2-*2-*2-*1,)1,)1,)4/,4/,4/,4/,4/,4/,4/,4/,41,41,41,41,41,52-52-52-52-52-63.63.74/85096196/<5-=6,?8.@9/B:/C;0C;0C;.D:.D:.F:.G;-H<.I=/J>0I@1JG6MH5RG5YF5bE3jD1uB/}>,‚;)‹:)“:*š=,£B2¬F8²J=»I?ÌGBÔDCØDBÝEBâBBéAAð=@ô<>ù:?ø:<ô<>í?>áB>ÓC:ÅA5¹?0²?-®?,®?,®?,­>-¬>-¬>-ª?-¨>.¤?- ?,ž?+š?,—?+•>*“>*‘>,?.>->->-Ž=,Ž=,Ž=,Ž=,Ž=,Ž=,Ž=,<,>-‘>.?.”B4—A4@1¨@3¶A7¿C9ÅB8ÄA7¾C;·H?¦LCJ@tE;Z>2E9-<5+@93@85?75>63=52<4194083/62/43/43/23.32.12-12-02--2.,2.-2.-2./1./1.00.10.3205105104..2,,4+,7./=/.N5.Y9.e=1n@3sB;yKK€Zeƒg€p—zxªu{·ks´_d¦TT”OGƒLBwNAmNBhMAeJA`GBYGFXKKWMPU]cc`fbbia`f\Z`TW[MUXMXXP^YV`WX`WZ,,,,,,.-+.-+/.,0/-3/,3/,2.+2.+3.*3.*3.*3.*5.(5-*3.+3.+2-*1,)1,)2-*3.+3.+3.+3.+3.+3.+3.+3.+3.+3.+2-*2-*2-*2-*1,)1,)1,)0+(3.+3.+3.+3.+3.+3.+3.+3.+41,41,41,41,41,41,41,41,41,52-52-63.74/85085085.;4,<5+=6,>7-@7.A9.A9.A9.C9/C9-E9-F:.G;/H<.J>0HA1JG6IH6NG5VF6\E3dC2n@0v>-{<+‚;)Œ;*”=,œ@1£F5ªJ:´J=ÄH@ÌEAÑFAÖE@ÞCAä@>ì>?ñ:<÷;<ô:;ð<=é@=ÜC=ÍC8¾@2±>,®?,«@,ª?+ª?+ª?-©>,©>,¨?,¥>-¢?, ?,›>,—?+•>*“>)‘?*>+>->->-Ž=,Ž=,Ž=,<+Ž=,‹<+<+‹<+‹<-Œ=,>/Ž?.”B4—A2 @2¬B5¹C9ÂC:ÅB:ÂA;ºA9±I@£NGNEoG=S?4A;/96-@93A75?74>63<4194083/74/43/43/34/23.23.02-02-.3--3/-3/.3/.3/02/02/11/11/21/32032040/2.-1-,4..8.,G4-O4)X8+`<0e?6mGFyYd‚k…€uŸ||²w|¼nu»dh¯[[¡RMLB~OArL@hI=cH>`HB^ECX@BO;@FBGJDMJJQJJQIIQFKQEOUIVWO^YS`YS`XU++++++,,,---/.,/.,0/-0/-1-*1-*1-*1-*2-)2-)2-)2-)2-*2,,1++1++1++1++2,,2,,1++1++1++1++1++1++1++1++2,,2,,2,,1++1++1++0**0**3--3--3--3--3--3--3--3.+41,41,41,30+30+30+30+30+41,41,52-63.74/74/85085.:3+;4,<5-=6.?6/?6-?6-?7,B8.B8.E8/E9-G;/H<0J>2H@3HE6GF4KE5QD4XC2_B2f?.n=,v=,|:*…9)Œ;*“=.›B2¢F7¬F8»F<ÂF>ÉF>ÐE>ÙD@âC?ê@@ð>>ò::ñ;:ì<<äA<ÖC;ÆD6µ@/ª=)ª?-©@-©@-¨?,¨>.¨>.§=-¥>-£=. ?.ž?-š?-–?,“>*‘?*>)>+>->-Œ=,Œ=.Œ=.‹<-‹<-‹<-Š=-Š;,‰<,Š.‹=0Œ?/’C2˜B1¡A1®B6¼C:ÂC<ÄC=ÀC=¹FA²QJ¥XRXQsRIWI>CC793@72>71=60:5/94.83/63.43.43.34/13.13..3-.3-.3--3/-3/-3/-3/.3/.3/02/02/00.11/22021/0/-/.,2.-4/,?0+D0)K3)T8-Z<4dFFu]jƒs‰€«…„¾~ƒÇtzÆmp½ce¯VSšLC‚K?qI_FB]DBW?AN;?H:BE>HGDMHGQIGQHJRGNVKUXM^ZOaYNaXO++++++,,,,,,.,-/.,0/-0/-1-*1-*1-*1-*2-)2-)2-)2-*2,,1++1++0**0**1++1++2,,0**0**0**0**0**0**0**0**2,,2,,2,,1++1++0**0**0**2,,2,,2,,2,,2,,2,,2,,2,,3/,30+30+30+30+30+30+30+41,41,52-63.63.74/85085092,:3+;4,<5->5.>5.>5.>5,B8/B8.E8/E8/G:1I=1J>2I?3FC4FC4JB5OA4TA2\@2b>0j<-q<.w9*}8)…8(Œ:,•=/›B4¤B5²F:ºE;ÁF>ÊG?ÔG@ÞFAçCAîB@í;;ë;;ç>;ßB;ÑD:¿D4¯@-¤>(¦A-¦A-¥@,¥@.¥@.¤?-¤?-¤>/¢>.Ÿ@.œ?.˜?-•>+‘?*>)>+>->->-Œ=,Œ=.‹<-‹<-Š=-Š=-ˆ<.ˆ<.ˆ<.ˆ/ˆ>1‹?1‘D2–C1¢B4­C6ºC;ÁD>ÁD>»EA¹PL²[T¥e\‘f]u_T[UIGMACI?<92?82>71;6094.74-63.43.43.34.24/13./4..3-.3-.3--3/-3/-3/-3/.3/.3/02/02///-00.22022010.0/-0/-3/,8,,;,)C0*K70S<6^IHtbn‡z”Š¶ŒÆ„ˆÏz€ÌrxÆik¶WWŸID„E=nG^CAY@CV@DP>EKGQRKWUQ^WU`XS_UR^TT^SY_S^[LaZJaZJ,-/,-/,-/,.-------.-+.-+/.,/.,1-*0,)0,)0,)/+(/+(/+*/+*/+*/+*/+*/+*/+*0,+/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*0,+0,+1-,1-,2.-1-,1-,1-,1-,1-,1-,1-,1-,0,)1-*2.+3/,3/,3/,3/,3/,3/,3/,3/,3/,40-51.62/74/80-92,:3-;4.=4/>5.>5.>5.?4.?5,B5-C6.D7/F90G:1F<2G?4H@5J@6P?5T>3X<1^90b6+m9.t8-|8+ƒ9,;/“=0˜?1ž>0§A3­A4µC8¾E:ÊG=ÔG>ÞE?åC@è@?êBAæDAÚE>ÈD8·B1ªA.¢B,¢A.¡@-¢?,¢>.¡=-¡=-¢>. ?/œ<,š=,˜<-•>-“=,=+Ž=*Œ>*‹<+‹<+Š=-‰<,‰<,‰<,ˆ:-‡;-‰=/†3ˆ@2‰A5‹A4‘E5—D4£E9±I>ºG@»D>»EA¸MG´ZR¯f_£qf‘sh~rdjj^V^SIQFLLBJF=B>5<8/95,74+63,33+43.34.14-14-02-/1,,1+,1+-2.-2.-2.-2./1./1./1./1.02/02/11/11/11/11/11/40/4+0;/3A32C4/J;6]OOymy‹…Ÿ“»”–Ï•Ùƒ‰ÓtzÆjn·_b§Z[”LItHBdA>]>>X?BUAIVLU\U`bbqnn}xv†|rulyoguh_k_W_P]\Hb\Fc]G,-/,-/,-/,-/------.,-.-+/.,.-+0,)0,)/+(/+(/+(/+(.*).*).*).*)/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*0,+0,+0,+1-,1-,1-,1-,1-,1-,1-,1-,1-,1-,0,+0,)1-*2.+3/,3/,2.+2.+2.+2.+2.+2.+3/,40-51.62/80.91.:2/;4.=4/>50>50=4-?4.?4.A4.B5-C6.E80G:2H;3H>5H>5L=6O>6Q=4V;2Z90_7/h70p7.w7-9-‰9.<1–<1›=1¢@3§A3¬B5´D8¾E:ÉF<ÔE=ÛD=ßD@àE@ÞFAÔG>ÄF8²C2¥B-žB-ŸC.žB-Ÿ@.ž?-ž?-ž?-ž>.ž>.š=,™>,–=-”=,=+>+Œ>*Œ=,‹<+Š=+‰<,‰<,‰<,‡;+‡;-…<-†2†@6‡A7ˆB6“G9—E7£G<¯J@¸IB¸GA·LF³TN±d\ªqfŸ~oo|mmseZfZNXMLNAKI=EC7@=4=:188.44,11)23-23-03,/2+/1,.0+.0+.0+/1.-2./1./1./1./1./1./1.02/02/11/11/11/11/11/2015+49-7<23?53H?:^VTxr|Šˆž““¹”—Ê–Ô„‹ÏyÂqy¸kt­hnž\_€XZqSUjRWjT^hZgmfvvr‚tˆ~’‡ƒ•‰~Žv†yr€qfteZeT[ZE`Z@b\D,-/,-/,-/,-/,-/,.-------.-+.-+.-+-,*/+(.*'.*'.*',+),*+,*+,*++)*+)*+)*+)*-+,-+,-+,-+,-+,-+,-+,-+,,*+,*+-+,-+,-+,.,-.,-.,-.,-.,-.,-/-./-./-./-./.,0,+0,+1-,2.-2.-2.-2.-1-,1-,1-,1-,1-,2.-3/.40/51.80.91.:2/;30=31=4/=4/=4/?40?4.A4.A4.C60D71F93G:4H;5J;6K<7N=6P;6S:5V72[6.c60k6.t5,}7/‡9/;0”<0–<1?3 @4¢@3¨@3±C6ºD8ÅE:ÍD:ÕF@×H@ÔIBÌI?¾E:®C3¡B.œA.B/œA.œ?.›>-›>-›>-›>/›?0˜<-–=-”<.“=.>-Œ=,‹<+Š=+‰<*‰<*‰<,‡;+‡;-…<-„:-ƒ;-„<0‚<0‚<2‚>3ƒ?4…A8‡C:ˆD9”J=—H; H>¬KD²KF³LG²SM®`V­sg¦qŒz‘Ž{‚‰ws€ocqbXcUNRDMN@HI;DD8@@49;.46+/1&01)01)/0*/0*./*./*//-//-//-.0-//-//-//-//-//-//-00.00.00.00.00.00.00.1/26+97+98/4;63HE>_^Yzz|‹š”±’—¿•Ç„ŽÃ}‰»{‰¶|‹²}Œ«}ˆšwƒq~‡n}‚n~~o‚~yŽ…ƒ™‹¡”‘¨˜¥”ˆŠƒ–ƒ|{j{i\hTXX@]Y<_[@-.0-.0-.0-.0-.0-.0.......-+.-+-,*-,*.*'.*'.*'.*),*++)*+)*+)*+)**()*()*(),*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*+-+,-+,-+,-+,.,-.,-.,-.,-/-./-./-./+*0,+1-,1-,1-,1-,0,+0,+0,+0,+0,+0,+1-,2.-3/.40/91/:20;31<41=31=31=31=4/>3/>3/@2/@3-A4.C60D71E82F93H94I:5J;6L:6N94Q83T50^72e60o6/x8/‚90Š:/<1”>1™?4›?4›?2Ÿ?1¥A2®B5¸D7¿E:ÇG>ËH@ÊJAÃI>¶F:ªB5žA0™@.™A-™A-˜?-—>,—>,™>,™=.—>.•<,”=,“=.=-Ž=,Š=+Š=-‰<,ˆ;)ˆ;)‡;+‡;+„;,„;,ƒ;-€;,;/€<1€<1>5ƒ@7ƒC:‡D<ˆE<”L@–H<žG>§JC®LI®QL­]Vªj^§€o¡yšš‚›ƒ†•€z‹xm{jbm]SZJQUFKO@EI:@D6;=057,13(01)/0(./).-(.-).-)/.,0/-/.,/.,/.,/.,/.,..,/.,..,0/-//-0/-//-//-//-//-2-17,:6*83-1961HJ?bfX{€z‹““£–°Œ•¶ƒ²¯…™²¤¶’¨³“¨«¤£Œ ž‡ž˜‚™}˜‰œ‹ˆ£”°š˜±›”­—‹£…›„’|k|iXfOSV;ZV9^Z=+/2+/2+/2+/2-.0-.0......------.-+-,*-,*,+),+),+),*+,*+,*++)*+)**()*()*(),*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*++)*+)*+)*,*+-+,-+,.,-.,-/-./-./-./+*0,+0,+0,+0,+0,+/+*.*)/+*/+*/+*/+*0,+1-,3/.40/901:20;31<42=32=31<20<20=20=2.?1.?1.@2/A30B5/C60D63C84D95E:6G96H94K84N50X72_60i70r7/}:1†<1Œ>2>2—@6—?5—?5—?3œ@3£C5«C6³E8ºE;½G=¾H>¹G=°D8¦A5›?0—@/—@-—@-–?.•>-”=,•<,–=/–=/•<.“;-’0->0-?1.@2/A4.?4.@51@72@93A:4B94C84F74H5/Q51X5/a6/l8-u9.€0‹=1“?5•>5“?5“?4•B4šB4 C4¥D4¬B5°D8´E:±E;ªB7¡?4š>1–>0•?.”?+“=,“=,“<+“<+”<.”<.“;-’<-<.;-Š;,‰<,‡;+‡;+†:*†:*…9)ƒ:)ƒ:+9*9-9-€<1<3?6€A8‚C<…F?ˆIBŠICŽJAG>—HCŸNJ§VR§`Z©pe¤ƒrœ”}–¡ƒ¨Šˆ§ˆƒ „~–~yˆup{jdp\]iSR^JJS@BK:>E5:@29<134,22*1.)/,'/))0**1++2,,1++1++1++1++1++0,+0,+0,+1-,1-,1-,1-,/.,/.,/.,2,.8*75(13+(56&EK1\gGu‚d†“yŽ›Š‘ž”Ÿš‹ž˜¥——´ž¢Å¥©Î­¥É­¦Ê°§Ë±¤È¬—¾Ÿ‹³‘ˆ°²Ž²Ž²¬Š„¡‚€™{wŽrdx]Q_ENR7QQ5SR6,03,03,03,03./1./1./1./1/////////////.,/.,.-+.-+/-..,-.,--+,,*++)*+)**()+)*+)*+)*+)*+)*+)*+)*+)*+)*+)*+)**()*()*())'()'(+)*+)*,*+-+,.,-.,-/-./-./+*/+*/+*/+*/+*.*)-)(,('0,+0,+0,+0,+1-,2.-40/40/:12;23;23<34=32<21<21;10<1/<1/>0/=/.>0->0-?1.>3/=60;60;83<94=:5>93@72C60G4.O4+Y4+d5+n8,x:-;.…;.<4‘<5>3@3A2“B1—A2™@0 >1¦@4ªB7ªB9¥@6Ÿ>5—=2•?2’?-’?-‘>,=+‘;*‘;*’<-’<-‘;.‘;.Ž;-;-Š;.ˆ:-†:,„;,…9)…9)ƒ:)‚9(‚9*9*~8,~8,€<1€=4€@7B9„E>…IAˆKFŒMFŒIAŽH@˜JF¡SO¨]X©hb©{n¤Žy™œ’§†‰¬‹‚ªˆ€¡„™€~‹wxnjxadr[ZhQQ]IITCCL;>D60-?1.=2.=4-=6.;819919:29:2;81?6/C2+J1,T2)^3*g7+o9-u=.z2¢B6¡C7žB7™?4–>2”>1”>/“=.=-<,Ž=,Œ=,Œ=.>/Ž<.Ž<.‹2>5€@6‚C:ƒG=…JB‡NE‹OGŒICŽID“PJ˜\Tžg`uiž‡už˜€”¡…ª‰‰¬‹ƒ¨‡€¡„~›zytˆoi}bby]\pUUgOO\HGRAAH8=A388.85.7/,3+)2()2()3)*4*+0*,/+*0*,0**0*,0*,2),2),3*-1+-1+-1+-0,-0,-0,-1+/4)/4*+4-%46!?F%T`8m|Qg‰™tžz¡~ˆ¡zŠ§{‘¶‚›ÄˆŸËŸÉ™žÇÆš˜Á•Œ·Š‚­€…®‚Œµ‰„«‰®…‰©‚~œxvolƒfZnSJZ?GM3FJ1DF./0+.0+/0+01,01,01,12-21-32.43/43/62/51.41,3/,4/,50-50-4/,3.+2,,1-,0,+0,+.,-.,---/--/,,.++-*).))+.)/.)-/(/.)-/)-.)-.*+.*+/+*/+*-,*.-)--+-.)./*./*------.,-/-./.,0/-2.+2.+2-*4,)5-*6.+8/*:1,:1*;2+=4-=4->50>50>50=4/<3.;2-=2.<1-<1/;0.=/.>0/>0/@1.A0)@2);4*77-39-28.56.:3-?-)F*'L)'S*&Z/(`5,d<0k@0yA0@/†A1‹B3@3“=0“;/’8-“;/“=.”A1•B2”C2’A0‘>.‘;,—;0—:2’;1Œ=0ˆ?0„?/‚?.ƒ>.ˆ@1ˆ?0Š>1Š<0‰;/ˆ:.†:-ƒ;-{9+~@3w<.q7)w>-w>-v;-}?2{;/‚@4‡E9‰I?ˆLA†MB„PC‡NE‘KI—SP”bY‘paŒ}j‰‰q‰–|Šž‚¤‡¦‰Ž§Š§Œ‡¤ˆ~Ÿ‚uš{o—uiib„_[zXZsUZnSWeNPWEJK=C?6@93;0.6**3')3'+3'+1&*,*-)+***,*(),'+.(,1(-2'-3(.3(.3(02(00)10)1/*1/*0/)-1++0-(//#5,>5,>5.>5.>5.=4-<3.<3.=2.<1-;0.;0.=/.=/.>0/@1.C0*C0)A2+>4+:6-95,:3-<1-?-+D*)I*(N+'T/)Z5-_:1e>/pA/xA-€A0ˆ@2?4‘=3“:2“;19.‹.Œ@0A1A1ŽA/‘?1•;2•;2<2‹=0†>0ƒ@/?/‚?.…@1†>/‰=0ˆ<.‡;.„;,‚:,€;,x8,x<1s9-n9+s>.s>.r8*u:,}=1ƒA5‰E:‹I=‰K@†NA„PC‡NE‘JH—SR’f]Œwf„†p€“wž„¥†ˆ§ˆ§Š§§Š¤‰Ÿƒwœ}o˜ve’i`‹`Y‚ZY{X\wXZnSSaJNUCFH;C@7<737/-3*+2)*1(+.(*,*+**,+),+),-(,/)-2(02(02(02(02(10)1/*1-*3-*3-*12-12.-0,)--%8:,SXBox]€‹i‡–o†™l†žnˆ£p†¤p„¥pŠ­w“¶€™¹‡–¶„“³Œ®{†«x‚¨w‚¨yƒ¨|ƒ¦|‚¤{x’uqˆnh{eYjWMZHEL<@D5;=/12,12,12,12,23-23-43.43.54/54/85085085074/72.61-80-80-7/,6.+4/,3.+2,,1-,1-./-.0.1/-0--/,,.+*/+)./(/1'//)-/)-/)-/)-.*+.*+0,+0,+/.*/.*/.)0/*0/*0/+//-///0./0./0/-/.,1-*2-*6.+70*90+:1*<1+=3*>4+?5,?6-?6-@7.@7.?6/>5.=4-=4-=2.<1-;0.;0.;0.;0.<1/?1.C2+E0+H/+K--L,/K+.I*/E+.A-,@.*A.(E.(M.)X1*b3-g5,j:,o;-w;0=4‡<6Œ<5:4:4Š<2‡=2†>2…?3†A2‰A3ŒB5C5Ž?2=/Œ>1Š>.‡>/…>,†=.ˆ<,‰;.‰<,ˆ:-†:*ƒ;,<)~=+{<+}=1z<1v:/u;/x@1x@1v<.v;-?5‚B8‰F=‹H?‰JA‡KA‡NCŠNF‘JH˜TQ–f\ve‡…n‚‘t{¤ƒ…¨‡ˆª‰ªŒ©ŒŽ¥‰ˆŸƒš}y˜xi–ma’e\‹a\†`]‚`[|]UrVPhPFYEBP?:D93:2.3,*/)*,)**(0'(1&*1&*1&*0'*1(+0*.0+//*.-+.,+0+,0)-0(-1(-1)-01/23/..*'**"57*PUAmv[|Ši€k~“j™jƒŸn€ n~ m€¥q‡¬x¯|‹­zˆªx„©v§v§u¦w¦y¤y€¢}}›yw‘tp‡mh|cYkUMZHDH9=?299-23-23-34.34.34.45/54/54/650761961:72:72961940940:2/91.91.80-50-4/,4..4..3/03/01/01/20.1..0--/-+.0)02).0*.0*.0*.0*,/+,/+*1-,1-,0/+0/+10+10+10+10,11/1111/010.10.2.+3.+3.*92,92,;2+<3,>4+@6-@6-A7.B8/A8/B90A8/A81@70>5.>5.=2.=2.<1/;0.;0.<1/=20=2.B3.E2.L..R+0V'/U&.P'/I).C/.<1+;2)?2)G0(R/)_.*d/)i9/k;/u<3}<6…;8‰;9Š;7ˆ:6‰>8†@8†B9…B9…C7†B7‡A7‰A5ˆ@1ˆA/‡@.‡@.‡>-ˆ<,ˆ;+‰:+Š8*ˆ9*‡:*ƒ:)<){=(x>(x>*‚>1{7.z7.z<1v;-w=/|A3{@2€B7ƒE:†H=ˆJ?†J@‡MBˆODŠQHŒSJŽ\QŽh[‹tb…g€‹m~–vž|ƒ§ƒ„©‡‡ª‰‹ªŠ‹¦‡‡ ‚ƒš~}˜yq•oi”ifgfŒeg‹gd†e_~_Zw[PhPK^JBP?8D62:/.4*,/(+*%2&&5%(4%(2&(1'(/)+/+,.,-+++*+-*+-(,-(,/',/',/*+-.*+1++0+'.+"88,PUAiqYv„c{Œhyh|–iœl}Ÿmyžkz m¥r‚§t€¥q}£p}£p}¥s~¥v~¥x}¤x|¡x}Ÿzz™wuqn‡je|bWkRN[GDF9?=1:8,45/45/45/560560560761761872872;83<94<94<94<73<73<41<41;30;3083072/61.61.5106216213122011/00./1-.2,04+.4+.4+.2,.2,,2,,2,,3/.3/,3/,3/,21,21,32-32.32032032032051051.61.61-;4.<5/=4-?6-A7.B8/E8/C9/D:1D:1E;2D:1C90B8/@5/@5/>3/>3/=2.=2.=20=20>31>31@51E31M02T,4X)3W(2R)1K,1B30:6-77+:6*B4)M2)X/)^/)f:1j;3s<7z=:‚<:†<;‡;;†::‚;7>8A8B9ƒC:ƒC:…@9„@7‚C2‚C1ƒB0„?/†=.ˆ<.‰:-‹9-‰7+‡8+…9+‚:+~=+x>*v?*x>*9-|/'‚8/„>4w4+s5*}A6}C7E:€G<‚I>ƒJ?„KB†MD‡QG…WJ|aNzjQ€pYu]‚|bƒ†i†“uˆ|ƒ£~§‚‚ª…‚¬†©„¥€{ž}z™wz’pzlxlwŒkumr‰lm„gkd`rX[iRR[HHL=@@4;7,70&5*$6('5''3''1'&.)&+*(++)+-*',('+*)+*)+***,+),+),-)*,#$2*'50*86*BC5UZFfpWn}^tˆeqŠbuex˜iw›ks™htšiwŸkz¢nx lwŸmx ny£s{¥u{¥w|£wyžuzœww–tsŽom†hd{_WkPN[GCC7>:195,560560671671782782872872983:94=:5>;6>;6>;6>95>95?74?74>63=52;63:5294194184184395484373243151240/6-06-.6-06-.4..4..4..4/,40-40-40-51.32-32-43.43.43/431542540841850940:5/=60>7/@7.A8/C90D:0G:1H;2F<3F<3F<3F<3E;2C90B71A60@51@51?40>3/>31?42@53?53@72C52I35P16T/6S.5P05J22C52=90<:-=:+C7)I6(Q3)W2)]2+d3,l50v64}77‚87ƒ77‚66~75}:4}<6}>5€?9ƒ@8†?9…A8€B3€C1B1ƒ@0…=/‡;.ˆ:.‡9-…9,ƒ9,‚:,<,|=,y>,x?,|=,‡5*‹2,¡LE§XQ‹A8|90‚F;€K=yH:zJ<{M>|N?}OBQE‡UJ‚_LrkOosR|uX‡w]yb˜iŸ‹s ”z––z|‹£ˆ¨…§‚€¤~{Ÿy~™vƒ‘p…ŽoƒŽp€pp{ŽpwŒms‡kj~bfv\_hSV[GOM>GA3@6*=0';,'9+(6+'3+(/,',-'+.').().(+-(-,*/+*3)*4(*7'*7'(3($<3,E>4IG8QR@]bKgqVjyZn‚]k„\l‰]p‘bq•eo•do—eršfuŸmrœjq›itžnx¢rz¤vy¢vyŸvvštw™vu”rokj…fc|^UlON\ECC7@91;4,671782782782893893983:94:94;:5>;6?<7?<7?<7@;7@;7B:7B:7A96@85=84=84<73<73<73<74<74<74;639529338308/09/.8/080.80.80.61.61-61-61-52-52-63.63.74/74/540540841952:63<94=84@93@70A8/C90D:0G:1H<0I=1I=1J=4J=4J=4I<3F<3D:1B8/A7.A81@70@72?61?61@72@72A83?74@85B86D97G96H96H96H94E80E8/E9-E9+G9,I9*K9+Q7*Z/&d/'n3-z63ƒ98‰;9‹;:‹=;‹A>‡@:‚=6<3:3‚<4ˆ=7‰@7ƒA5B3‚@2ƒ?2ƒ=1„<0;/€/|>/}>/=/†9/1+¢<8ÍlfÙ~y­ZTŒC<ˆLAN@tJ(+C&+E$+C&(F5-LC4VQ>[YD`bJgmQiwVj{Wl‚[g‚Wf†WlŽ\o”an”an–bršfsko›jo™irœnw ty¢xxžwu›vs—su—vs’rn‹li„cb{[TmMM]CGH:E<5@707827828938938939:4:94:94;:5<;6?<7@=8@=8@=8A<8A<8C;8C;8C;8B:7?:6>95>95=84>95>95>95>95=85<73:51;30:0.:0.91.91.91/91.91.72.61-61-63.63.63.74/74/74/540651952;83<94?:4B;5B;3A8/B:/C9/E;/H<0I=1J>2J>2K>5K>5J=4J=4F<3E;2C90B8/B92B92A83@72@72A83B94A:4?82@93B;5D=7F=6G<6K<5N;4M6.N6,Q6+Q6+Q7*P9+P9)V6'f6*r6,~;3‰@9•D@›HDŸJGŸLF QJ™LDŽD;…;0„7-…7-Œ91=4ˆ>5‡>7†=6…<5…<5=4}=3z>3x@3vA3x@3z>3<3ƒ:3ˆ73‘31˜(&³=;ì|zý•’Åhc–G@‰K@xH:nMhV>lX@t[E`L€hPysQ„wUžt\´l^É__ÓV\ÙQ[×T\äouÙzx̆|À~µ•€«•}£’xŸvœŠrœŠt™u•u‘‘u‹’s†‘s‚‘r|‹ny†ju{amoWgbN_TBUE5R/(9/&7.'6/'81):/)=.+A,+F)+H(+K'+H)'TB4YQ9B?:D?;D?;E@8E>8D=7B;5B;5B;5B;5B:7B;5A:4A:4A83A83A83@72@64>71>71>71<71<71;60:5/85.85.74/74/961961961:70<71=82A:2B;1C:1D<1F<2J>2K?3L@2N@3N@5N@7N@7L?6K>5I<3H;2E;2E;2B90A8/@91?80?80?80@93@93<5/MD=M@:K:3T@9R62O0+a<6\3-`5.`4+^/'^/%f6,m=1q=0‰I=G;—I?ŸKAŸF>›>7š=6žD;¦ND¤PE¨VJ«YK¥OB™A5—;0›>6“98‘98Œ65†52†84„?8|@6r>1rB4oA2q=0v:0‚72Œ43’-1š',ÈHIèbaÅEDÍWUáyv«VO†F<„VFmR=i[AibFjeHj`En^D|dLjT’bL²m]ÑnhÛX]à;Lç-Eò+Hõ0Lö@YìI\ä[eånrâ{|Û€}Ûƒ؉‚Ãv½wº„x¶†x²ˆx­Šw¨‹y¥Œxš€o™~m˜xi“oabY„UM{IBxA>u:9:49:49:49:4:;5;<6>=8?>9>=8>=8A>9A>9B?:C@;D?;D?;FA=E@8E>8E>8E>8E>8D=5C<6C<4D;4C:1B92B92B92B92A83A83@93@93>71<71;60;6096/85.74/74/96196/96/:70<71>:1A:0B<0C;0E;/I=1J>0L@2L@2N@3N@3N@5N@7M?6J=4I<3H;2E;2E;2C:1B90@91@91@91@91A:4B92D93I81L/+V.,j76u99{;;…ECƒD?„H@…IA†G>ŽIB™NH¡PL¢OG“D7”B4šB6ŸC8 >3œ7-œ7-Ÿ=0£C5›?0™@0 E3¤G6§F6®H:¶NE´LM¯HL¥@D™9;‘98>:ƒ@8x>3o>0zI;…LA„?8„,+’).³9DÒLWÜKNßMMÊ>=À@?Ð`\³YQ„@5‚TDyaIe[@^]?ihIslOvgJ~dK–cN¼dXÖ_[æUZëANò,Eþ%Dÿ&Hÿ'Iÿ.Nù3Nò6UE8[O5cZ9gaAifEnrOz‚]z‰bt†^r‰_p‰_p‹`qŽ`u’dw”dw”dw”fs’ix–rz—xy–x~˜}ƒ„…‡ƒ›…™ƒz’zr‰om„hhd`y[TmMNaERSAVPBUOC8938938939:4;<6<=7?>9@?:@?:@?:C@;C@;C@;C@;D?;D?;FA;FA;FA;E@:E@:E@:G@8F?7JA:I@9H?8G>5F=6E<3F<3E;1D:1D:1D:1D:1D;4D;4D;4C<4?80?80<71;60:5/:5/94.94.96/96/:5/;7.>7/@9/B90C;0E;1F<0I=1K?1M?2M@0NA1M@0P?5M?4L>3K=2I<3H;2E;1D:0C:1C:1A:0A:0?;2@<3@<3D;4UD—I?–LAœNB¬RJ¾URÌOSÄLK¥@4B0 @0¥?1¥;.£7+¤8+§=/«E6¡>+˜7$:'¥>-¬A/²C2¶D:§02¯:B¹DL½LRºMR­KL–A>‚71{8/v6,x2*„1-œ37¹=GÕGWèM[âFIÏ53Ð:9½31ÈNKÆc]”J?Œ[J}cLj_CgdEtoOpQhJhN°hYäbbõQZôDQö7Iý1Jÿ2Nÿ/Mÿ*Hÿ2Oü0K÷1Jõ5Lò4Mð2Kó3Ló7Pò@XïC[îF]íIaëNcêQeèUhèVkåSjäRiãOiäNiçNlëPoòSsóVuþh…ña|å[tÕUlÍYlÉdr¨R]r-2^&'Y0,W:4Q?5B:-:8)>B1LN9VO3aV6e_?heDquT†e~ŒiwˆdxŒiu‹er‹dr‹cvŒeyhzizj€•v„›~Šž… Š’£—¨–˜©™–¦™‘¢’‡˜†zypƒmg~b^wYTmMPcGSXDXUDYVG7827828939:4;<6=>8@?:A@;BA5G=3F<2E;1D:0D:0E;1E;2D;2E<3E<5E<5@91?80=82<71;60:5/:5/:5/96/96-;7.;7,?8.@:.C;0D0K?/M@0M@0M@/M@0O?2O>4L>3K=2J<3G:1E;1D:0D;2D;2B;1@<1@<3A=4B>5F<3S81[*&‰:?¾T`ÙTeæUfãUcËJOŸ30–:/‘>0™A3®F=ÅIGÕBHÍ>@±B7§F5©B3¬@3¯?3°>3³B4´D6²G5©B/£<)¤;(©<(«:(®6&­3(¶97º9=½7>¼7<¿^õ@aøCfö@fõ?eõ?gø?hüCmÿErÿIsÿOuÿQuþUvòSqçTnåaxÖfv·Wb}15j0/X1*P8,G>/>A.;D/?G/PK._T8g`CokN||`ˆŽr‡‘v}‹qzq|s|szozŠm}Œoƒ’uˆ—z•£Šœ©•£®¦±¡¬´§±¹®°·°«µ­¡«¢” ”ƒ‘‚s„qh|c]tXSlNPdHRZCWYDYZH671671782893:;5<=7?>9@?:BA/K?1M@0M@0NA0O?/O?0O?2N=3N=3J<1I;0G;/D:0D:0D<1D<1B;1@<1A=2A?3B?6K=4\5.w32­LSÛ]iæM_å@Q×6E·&+¨1)7(’:&—<)¬@3ÃD=Ô>?Í;;±?5¨B4ª@2­?2²@5¸C9¼H;»J<¬>/ª?/¨=+¦;)ª9)°:,·;/¼<1ÊFAÎDAÐ>?Ð79Ö7<ÞBEâLNÝROÄC>ÆKCÍTLÔSMÙKJÛ?Bà5>á27Û4.Ú7.Ð1+Ï:4¿84³@9µ[P–UC{N9‚bI†kP„`F’[F­fTËrdçmhêEKò:Dê9Cç=8@?:@?:C@;DAGB>GD=GD=HC=ID>IE2I=1G=1G=1F<0F<0E;1E;1D;2C:1A:0A:0@91@91=82<71;60;60;7.;7.;7,<8-?9-A;/D0L?/M@0NA0NA0O?/O?/O?2N=3M<2L;1I;0G;/F90C9/C;0B<0B;1@<1@>2A?3B?6N;4m84—FEÄY_ÛWbßCQÞ8FÔ3;½++­1'¡8%˜:!—9 ¤;&¶>.Ã:2¾71§7,¢:-¥9-§7,¯:1¸B8ºE;·E:®>2­?0§<,¤6'ª6)¶>0ÃD;ÊG=¾8-Î@6áD?ìBBô=Aó9>ë27Þ.0Û75âGBèSLåNGÜ=9Ù10ã/2ê67Ù1(ÞÒA>ÒGBÝOMëWWíNRïDMð:Gö5F÷2Fø.Dû1Gþ7Nþ8Sý8Tý8Vþ9Wÿ;\ÿ>aÿAeÿCkþ;eýjý?mú>nø>oô=mö:jÿHrÿ;aÿ?dÿKnÿKn÷NmïUoãZnèr‚Âaj˜ILt:8\6-P9+PC2UM:^QAreUˆ|n•‚Ÿ‘¦§Ÿ¡¦Ÿ–œ˜•ž›ž§¤¦¯¬¦¬¨¢§£¦¨£µ´°ÂÁ¼ÌÉÀÑÎÅÕÐÌÕÐÍÔÎÎÕÏÑÑËÏËÆÊ¿½À°²¯˜Ÿ˜€Œ~m~k`t[WnRVjNS`FV`EX`H560560560560671893:94;:5=<7>=8A>9C@;DAHC?HC?GD=HE>ID>ID>JF=JF=MF2@@4P91r1/¨JKÁSV»>D½06Â03Á//º1)©1!£9#œ=!™;›< ¡=#¥;%¤6%ž6) 8-¢6,¥4,­81·@:¸C<²@6±B7­A4¨-Ï>-Ù5+á*&í"%ú%+ÿ*1ÿ.4í)*ç.+á3,ß4,à3,ã2,é0-ç2+Ú2%Ö6&Ð2&Ï7,Å6.½>7È`UÒq¦eSVBŠM:£WIÈf[ßd_çRTèCIõFMí@Dß??Ô@<É@8Æ@7ÑFAãMLïJNô@Kù9Hý7Hü5Hø3E÷6Gú;Mú8Pü7Rû6Rý6Uÿ6Xÿ9]ÿ;aÿkÿ?mÿ@qÿBtÿBuþBuüBtùBpÿFmúAaþEeÿKjþKkÿVtÿ_zõ]tòj~æp~Óow®^aƒCAg6/hB7sUJye\Œ}v£–­£¡²®«¶¶¶²¶¹ª¯³°·½¶½Å½ÁÊÀÃÊÃÂÊÉÆÍÕÎÖÝ×ÛâÚØçÝÛéÝÝæÚÜåØßä×ààÔÞÙÏØÊÅ˺ºº¢§£ˆ’‡t‚qexb\sW[oS[jM\iK]gL561561561560561671872983<;6=<7@=8B?:DAHE>HE>HE2G=1E=2D;2C:1C:3A:2A:4@93?74<73<71>7/>7/<8/=90>:1A:2C<2D=3H@5I?3L@2MA1NA0P@0O@-O@-L?/L>1M=0L;1J91I81E80C90@9/>:/;;/<<0=>0>?1A?0S8-‡<7Ä\[ÊZY®86«.*²1+®.%­2#¬9&¬B*ªF,¦D'£A&£A&¢<#Ÿ9# 9*£;0¦:0¦7.­<4¶C<·E;°@5«=0¨Dá;=Ö<<Í@9Á>4¶8,¹6.Ä94âHHé@Eð;Dö:Hú:Iø8G÷;Iû?NþAUÿ?Vþiÿ>lÿ>oÿ>pý>qú@rø@t÷Aq÷CjÿMmÿSs÷Jhë@`ýTsÿg…ÿe‚÷]wï_xçh{Üp}Æqx§gg^X{ZQ—~wª™’¾°­Ä¼ºÆÂÃÈÇÌÇÇÏÃÃÏËÊØÌÊØÑÊÚ×ÎßßÔäæÛéêàëíãëïåæòèæôèèðäæîáèíàéêÝçäØâÑÊÑÁ¿Â««©‘–z†xl{hbu_`rXbpVboScmT21/320431651875984984984;:5<;6==5??7AA9CC9EE;EE;HH@HH>HHLC4J@4KA5MC9LB8F=4B90E<5C:5@93?74@85?75<74<42C:5B94A96>95?:7>:7?;8@<9B?:D@7G@6J@4L@0O@-O@+L?,G@.F?/I;0K81M53K65J88F;9B?:6904,«=,­<,³=/½C4ÄF8À>1º2&Ç9+Ì8*Ð8+Ö8-Û7-â5.é3/î1-ñ.,ô.-ó0,ñ1,ê5*ã7)Ý:)Û:(Ü9&Ô3Ð3 Ï8'Æ7'¾6(ÂB5ÏSIÈNCÏSKá\Wî]ZðPRí>Cò9?÷?GêAFßCDÕAAÈ?9»<3±;/°HH>HH9H?:F=8B;5D:8A96?74?74@85@85=85;62=4/=4/=52<74=96>:9=<:>=9B?:D?9G@6J@4M@0O@-P?+L@*B?,B?.F<0H:1J65I56F35@65@<9:=6;>5@@4E<-J9)^B4€L>®QB«;- 2#¡6&£:'ž7$ž9%£>*¡;%§<(®?+³@-¶=,·9*¸6(µ7)ª9)¥:*¤9)¥;+¨>.«A1«B/«@.®?,«:(±<+¿E6ÆH9Á?1¼8+À6)Ë7+Ï7,Ð9.Ñ;-Ô8·;1®:-ª<-«=.¶E5ÆL?ÔNEÜGCã?>ï?Bú?Fþ@JøCJ÷CLúDPÿFTýBSù>Sü>XÿBaÿFhÿCiü?iù@jùBpüFvþJzÿK{ÿJzÿHtõKpñQsõ\zù_{ûXwüNqýEkúDlïEiÚKgÈ_p±nukLI~t°–‰Ì²¥äÓÉìãÜëçæêéîêçòíâóöãùûáúÿâýÿçÿÿìÿÿòþÿöþÿùûþú÷ýúõü÷ôúõòøïðôëîñèíïæëæÝàÜÖØÊÆų²®ž¡šŽ“Œ‰…ˆƒ•‡‰€†Œ~/.,0/-10.21/43/540762761:94::2<<4>>6@@6BB8CC9DD:IF=IG;JH;LI8MJ7NL7NL7OL9KI:NKBTRS_^fihxmm…lkŠkhƒ`YiYQ\OGRH@KH>GG=EE93>:1=9083-94.;60<92=:3>;4?<5@<3E>4G?4I?3L@0O?0P?/P?-L?,<;&:=(?<+A;-B71A62>42;30=84B;5H94N2.Y,)l/.‡;= FE£;0¢2$Ÿ1 ¤9'¥<)ž7$ž8"¢<&¤;&ª=)±A-¶A/¹>.»<-¾:-¾-­>-­<,²?-°8(¹>.ËL=ËG:¼6*º2&É9.Ð6,Ô6+Ô8,Ö:.Ø:/Ü8.ã6/è3,ð0-ô.+ô.+ð1)ç2'Ý6&Ô8"Ò7!Ý8$Ü5#Ú9'Ú>/Ó=.È6)Å9,ËA7É<5Í>8ÙEAåKIêJJéCCì?AëCCÞCAÕD?ÍB=Â=4¶:.®8*«:*¬;+¬8)ÀD8ÔNEÝIEà@@è>A÷BIÿHPôAGô@IùCOýGTþEUú@Uû?XþA_ÿDfÿCiÿCkÿFpÿIwÿK{ÿL|ÿJzÿFxÿHwÿKtúNtÿZ|ÿa€ýUvñCdûIkÿTvÜ?\ÍI`Ø{…¸||aC;|n®ŽÕ³§óÛÑûìåúòðù÷ú÷ôýôìûúëÿÿêÿÿìÿÿîÿÿóÿÿ÷ÿÿûÿÿýüÿþûÿýùÿúøÿøöÿõöýóôûðôùðóðçêåßáÓÏξ½¹­®¨¢¥ž£™£—£«žž¦—›£–/.,/.,0/-10,21-32.54/650880991;;3==5??5AA7BB8CC9HEQPL^]bmlzzz’‚¡€‚¨€€¦{u—rkŠe_{YSmTLdMEZG@PB;2?=1@<1?;/A;-F?/H?.K?/M@/O?0O?/P>0L?/@=*?>,@=.?;/?;2>93=:5:94<94D95M51V-+j)-„28ž8C«>C¦7.¥7(¥:(ª?-¨?, 9&¡8#¤;&¥:&«<)³>,¹@/½>/Á=0Å=1Ä>2½?3¶=2²9.®8*¯9+°:,²:,³9*¶;,¹;-ÄB4ËE9È>3¾1'À2(Í9/Ö5+Ø4*Ú6-Û7-Þ7.á6,æ3,ì1*ó0,ô.+ô/)ï0(ä2&Û4$Ò6 Ð5×2Ú0Ú4$Ü<.Ö=/Ð9.Í=2ÒD:Ä5-Å60Ê;5ØD@âMIåKIÞC?Ö=8Ó@9ÎA8Ç>4¾VádtþŸ§ÓŽd92lJ>¥ynÐ¥œõÔËÿéãÿôòÿýÿÿüÿùóÿüïÿÿïÿÿðÿÿòÿÿôÿÿ÷ÿÿûýÿüûÿýúÿüøÿúøÿù÷ÿö÷ÿõöÿôøþó÷öëïìãäÚÕÒÉÆÁº¹´³´¬±´©°¶ª¶¾³°¸­¬´©10,10,0/+0/+10,21,43.54/77/880991;;3==3??5AA7DA8IE:LF:NH:PJ:RK9RM:SL:QK=OJDVTUfdqwx††¨¹“ÃÆŽ‹À‡ƒ¶{w©pmšid_[~UPnNJaKGXEBM?=B;7895296/85,85,671783891;;1>5L?6K>5F<3B92=82:946;47<59<5>:1H4-Y2-w78”?D¦>E§9<ª;0ª<+«@.¬A/©@-¥<)¦;'«>*§8$­:'µ<+¼=.Á<-Å;.Ê<0Ê=3Å?6¾>3º:/·7,·7,¸8+º8+º8+»7+ÇA5ÍC8Å8.Á1&Æ3)Ë7-Ï5+Û4+ß3)á4-â6,ã5,ç5+ì1*ð/*õ/,ö/*ò/)ì0'â2#Ù4!Ð5Ï4Ö1Ù/Ø2"Ø6)×9-Ô:0Ö?6ØE=ÖF>Í@7É<5Ë@9ÖKDÙNGÒE>Å;1Å=1Â<0ÀCòBLûIUÿJYýFXúCYûC]û@_ûBdÿElÿJsÿNzÿO|ÿLyþIvÿJwÿTÿT}ýJqùImÿStÿVtøNiëD^äF]êXkÿ–¢ÿµ¼óžŽHFk.)¦kcÍ–óÈÁÿãÞÿñðÿüýÿýÿü÷þþöÿÿöÿÿ÷ÿÿøÿÿúÿÿüÿÿýýÿýúÿüøÿûøÿùøÿø÷ÿöøÿõ÷ÿôøÿôøýñóóéêäÜÚÖÑÍÍÊÃÉÉ¿ÊÊÀÊÍÂÉÐȾȿ·Á¸65143.32.10+10+21,32-43.66.77/880::2<<2>>4@@6B@4JD8ME8OH8RK;TK:TM;SL*F@*G?*H@+IA,IB0IA4HB6HA9G@:K=?ž51§;/ª<+ª?-ª?-©>,©>*¬?+°?-«8%²9(¹:+¿9-Ã9,È:.Í:0Ï<4Ë>5Æ;4Â91Á8.Á8.Â9/Â8.Ã6,Å7-ÑC9Ð@7Ã0&Ã,#Ð7/Ö<4Ó2*à3,ä2(ç2+è3*ê3+í2+ð/*ó-*ö/*õ.)ñ0)ì1(á4$Ú5"Ñ6 Ð5Ø7#Ù3#Ö3$Õ3&Õ5)Ô8,Ô<1Ö?6ìYQáRJÓHAÌC;ÊE<ÌI?ÈE;À>1¼:*¼;(¼:*¹:)·:(¸:+¼>0¿A3ÁA6Á<3Å<6ÏA=×EEÝGHäIMëLPèBFê@CðCIùKTþNYüJZüF\üF_øA_ùBaýEiÿJpÿNwÿOzÿNxÿLvÿQ{ÿRyþOvýOtÿVyÿ]{ÿSoîD^úTlîQd÷dtÿ’žÿ‹•ôƒ‰Ç`d§MMµjgΊXÿÞÙÿïîÿúùÿüþýûÿýúÿþûÿÿûÿÿûÿÿüÿÿûýÿûûÿûøÿûøÿüùÿûúÿûúÿøúÿöøÿó÷ýñóùíïòææçÝÛßØÒÛ×ÎÝÛÏàÞÒßáÖÜãÛÏØÓÅÎÉ<94;8185052+41*41*52+63,74-85.96/;81=:1?<3A>5C?4JB7MC7PG8SJ;WK;UL=UK?SJCSJK]Wcnl‚‚‚¦‘•Åš ÚŸ¦ê¢©ñ¡¥ïž ë™›å•˜Ý”•Ö‘ʉ‰½‚ƒ±zy¡rq‘fc~XVkPN\IGRFCLCBJ??K==G;:@;9:<94?;/C=-E@,F@*FA+EB/EC4CC7BC;AC>@ACBLCANEEOCHNAIL>HI>GDCHAA=2L:.gF7ƒOAI<Ž?2”8)¥>/©>,«>*¬?+­@,¯@-°?-±<*±8'¶8)½9*Ã9,È8-Ì8.Ò91Ô;5Ï:4Í:3Ë81Ë81Ì92Í:2Ì70Ë6/Ó<5Õ>5Ò91Ì2(Î4*Ø;2Ú<3×3*ä1*é1'ì1*î2)ð1)ò/)ô-(ö,(÷-)ô/)ð1)é3(â5'Ù6%Ò7!Ï7 Ô9%Õ8%Ó6%Ñ4%Ò4(Ó7+Ò8.Ð7/ãNGèXPçZSÚQIÌG>ÄD9¿@7¹>/¹<*¹<&¹<(¹:'¸9(º;*À>0ÃA4ÉD;Æ@7É@:ÑFCÕIHÖHGØGJßIKæFHèBDíDIõLSüQZûO]ûL]ûK`öD^÷DaùFfýIlÿNuÿOxÿOxÿPw÷VxóUvôTvüYxÿ]{ÿZwûQkòI`ýWköUgêM^ö^mâKZæTaåTa×XaÁefȃ~嫧ÿÔÑÿëèÿóòÿøùÿþÿûüÿûüÿûüÿüüþüúýýùúý÷÷ü÷ôÿú÷ÿûøÿüûÿûúÿøøÿóóýîñúëîðáäéÝÝäÙÕâÙÒæßÕëçÛñíáññåìóìÛæâÎÙÕ@=6=:3:7074-52+52+52+63,74-74-96/;81=:1?<3@=4B>3JB7MC7RF8VJ:WK;XL?:6@<1A>/C@/CB0BC3BD7?D=>D@CVCIaLRhU\o\br`dobbjd`afXWaJDlG>ƒSE•XF“J7‘@+™>+¨A.®@/®A-¯@-°A.´A/²=+°7&µ7(¼8+Â8+È8-Í6-Ñ7/Õ81Ø;4Ò72Ð72Ð72Ñ82Ô94Ô94Ó83Ó6/ÞA:Õ8/Ñ3*Ö8/Þ=5Þ=5Ú91Ü5,ç2)ë0'ï0(ñ0)ô/)÷-)÷,(÷,(÷-)ô/)î2)é4)á5'Ú7&Ô7$Ï8#Î7"Ï8%Î7$Ï6&Ð7)Ò9+Ñ7+Î4*Ë4+ãNGód\ë`YÕOFÄA7º;2µ9-¸>)¸>'¹<&¹;%º9&½9*À2ÊD9ÊA9ÎE?ÕKHÓLIÎGDÍEEÖHGãIIæCDèEHòMSøSZùR\÷O^úOaôH^õG`øGdûIiÿNrÿQxÿRyÿTzðUuïZwù^}ý^|ùUpõMgùOiÿYnÿ[mÿctðM^÷TeôO`üUgõL_äR_À^_»vqל˜úÉÅÿåãÿíëÿôôÿÿýüÿÿûÿÿûÿÿûÿþýýýýüúþùöýøõÿøõÿùöÿúùÿúùÿööüððøéìôææëÝÝèÚÙäÙÓèÞÕðèÝùóåÿúìþþòôúöáëêÓÝÜB>5A=4@<3>:1<8/:6-84+73*62)62)73*84+;60>93A<6E>6I@7MC7RF8UI9WJ:XK;ZLA[NHTIMXR`gd|~§’Ê— ãžªö¥°ÿª³ÿ«²ÿ¬´ÿ¬²üª±ùª¯ó¨¬ì©«èŸ¡Ú™šÒÁ±tr¡he’]Z‡XR~XQzYQvVOnMH_C?M?:@?;:B?8>>4@B5BE:?D=:CB>FH?LUDVnQfƒarŽisŽtvx„o€€^lŠ[c’WYžWU¦VM¦M?Ÿ@.œ9$ :$§<(¬=*®?,±@.³@-´?-¶=,¹;,º6'¾6(Ä6*Ë7-Ñ7-Ö8/Ú91Ú83×84Ø95Ù:6Ø93Ø61Ø61Ú83Ý:3æC<à=6Ú70ã@7þ[Rÿlcÿ]Tç?6å3)í2)ñ2*ô/)ô*&õ(%ø(&ø+(÷-+ó0,í2+ã1'Ú0#Ô1"Ô4$Ó:(Ì;&Ê<(Í<)Ï<*Ò:,Ò9+Ò8,Ñ7-Ú@8Ï81ÜGAôc^åXQËB<Å@;·4*·:&¶<$¹<&º<&½:(¿:+Ä<0Æ>2Ç>4ÌC;ÙPJßXRÔOJÃ?:À?:ÏHDÞHGâGEæJKïPTñRWïNVíKXñL\ùRføOf÷Ke÷JfüMlÿQsÿRvýRvôWvîXuõXuû[wÿ\xÿZsÿWnÿVkÿbuýVgÿ\mÿ[lñFXôDXÿQeîVeÆfgªieʋ網øÒÏÿëçýïîüø÷ùýüùÿÿùÿÿúÿþüþýÿþüÿûøþöôþùõÿû÷ÿùöÿöôÿööÿõõöèèæØØãÕÔÞÐÍáÖÐñçÞüôçþøèÿüéÿÿóúÿùèñðØáàC?6B>3A=4?;2=90;7.:6-95,73*73*73*84+:5/=82@;5D=5H?6LB6QE7TH8VI8WJ9YK>ZMEUJNWQ_eby{¤ŠÉ”⛦õ£®þ«´ÿ¬µÿ®¶ÿ¯·ÿ°·ÿ¯¶ü¯´ø¯²õ©ªë¢£ã˜˜ØŒŠÉ€»uq®ie c^˜`WŽ`Vˆ]TVPtMIbFCTBAIAAC<<:AB=FEACD?A?@DBEOMRWVdch†quš}¢‡}Ÿ’}œ {š¥pŠ¤`u¬Yi¶VaºQU¸HF°@4¬;)¬<&­='¨8$¨7%«8&®9(°8'²9(µ7(¸6(»3%Â4(Ê7-Ó:2Ù<3Þ=5ß<5ß<5á>9ß<7ß<7á>9åB=èC=çB<æA;å@:æB9ä@7Ü8/Õ1(Ø6+ëI>ÿ[Oñ@6î6,ê+#î)#ø-)ÿ/-þ,+ö((ú0.õ4/ï61ç6.Þ3)Ö2&Ô2%Ï6&Ë:'È;'Ê<(Í:(Ï9*Ð7)Ñ5)Ð4(Ó9/Ï5-Ô=6åPJåTQÛLHÍB?·1(¼;(»=&½<'¾;'¾9(À8(Â:,Ä:/È>4ËB8ÕOFÜWPÒRIÃD=¿C;ÌHCÛLHßJFåMLëSRíTWëPVéNVìOZ÷VføUhùSiúRküRmÿSqÿStÿRuòMmøUtÿ\zÿ_{ÿ\vÿUoûRiûReüUf÷RbÿZhÿZhóN^øScþYißS^¶`_—^W¶}Ù©¥îÈÅýáÞùééýøõúüùùÿÿøÿÿ÷ÿýúþýÿÿýÿûûÿ÷õýøôþùõþùõþöóÿ÷öÿõõöêêêÜÛäÖÓÝÐÊßÕÌïåÛüõåÿùçÿýéÿÿïúÿøèñîÛáßEA6EA5C?4A=2?;0=9.<8-;7,84+84+73*84+:5/=82?:4C<4G>5JB7ND8RF6TG6WG7YIBZEJpW]‚cs˜r—¥z§®«²{£¸vœÀp“ÂcƒÀTnÂG\ÐK\ÑHPÄ<<º5.¸9*µ<'°<%°;'°;)²:)´;*·<,»<-À<-Ä<.Ä6*Ë8.Ó<1Ù?5ßA8á>7à<3ß:4Ü71Ù4.Ø3-Þ93æA;ìE?éB<ä=5ã<4Û4,Ø4+Û7-Ô2'Ì, Ö6*éG:õK>ò@6ï4-ð-)ö,*ú,,ü,,ø*,ð*)ì/+è2.ã5.Ü4+Ø1(Õ1'Ñ3'Í7(Ë:)Í:(Ð:)Ò;*Ó:*Ô8+Ô8,Ñ4+Ö<4Õ:5Õ<7åONíYWÙEEÂ3/À;,¿<(À;*¿:)Á9)À8(À8*À8,Æ=3ÇA6ÏJAØUKÒRGÆG>ÀD:ÇG>ÖKDØICÝLIäSPåSTâPSâMSåNWòXdöZhý[pþZrüVnúRlûQlÿQpýGmÿPvÿZ}ÿ[{ÿVrýTkþWkÿ\mûYhøZhûamö`kí]gïfnìfmÉ\_ ]W{OF˜mfÁ˜”ݺ¶ðÔÑôàßÿõôùù÷ùÿýùÿÿ÷ÿýúþýÿÿÿÿýÿÿøùüùôüùòüùôýøôÿùöÿøöùîìïäâåÚÖÛÐÊÜÒÈîäØýöäÿûèÿýçÿÿíúýôêðìÞãßIE9HD8FB6D@4B>3@<1?;0>:/:6-95,95,95,:5/<71>93@;5E>6I@7LD7OF5RE4UE5WG8WI>XMKXNW^Zqpp–€†ºŒ–Ô•¡é©õ¨°ù©±ù­³ý°·ÿ±·ÿ²¹ÿ´¸ÿ´¸ÿ¯±ü«­ø¥§òŸžê—–⌋ׂÍ}yÅum¶pgªf`ž_ZYX„QQuGGcA>Q=5DH8BT=C`@EnCJ€OU–]d«fx¿kÉnšËo˜ÉiÈ`ƒÉWxÆIgÄ;UÆ2HÙAPàEMÑ;<Æ71Ä?0½@,±:$­6"­5$®5$³5&¶7(¼8+Ã;-È/Û?0Ü@3Ü@3Ò6*æLBåJEÎ50ßGFóZ\ßIKÕA?È2ÈF9ÏOBÎPDÆH<¿C7ÁC7ÎH?ÑF?ÕJEÛPKÝROÙMLÚKMÜKPëX`ó[güaqÿauúXmõOgõMgÿNkÿOuÿRyÿUwÿTqüTmý[pÿcuÿjxÿguúboõamídlãflÙhjÎghµfa^TeG<^U©ˆÍ«©åÇÅïÚÙÿóóùøöùýüøÿÿ÷ÿÿûÿÿÿþÿÿüÿÿùúþûöûûóûúõþûöÿýùÿûøþôòøíéêßÙÞÔËÝÓÉíæÖÿøåÿþèÿÿæÿÿëøúïêïèãæßNH:MG9LF8JD6HB6F@4D=3C<2?80>7/=6.=6.=60>71@93?:4C>8EA8KC8NE6QD3RE2VF6VH;ZMGVMR[Whlk‹~‚±Š“Î’Ÿãš¦î¦®÷©¯ù­°ý¯³ý°³ÿ°´þ°³ÿ¯³ý«®û¨«ø¤§ô ¢ïšœé“•âŠŒÙ†…уÉ{u»mk¬dež_a’Y[„RQsNHbWFY_CQmBLEM˜MT¬U]¼[bÊZhÙRpâRußTuÙPlÒJbÍBWÇ8JÅ.?Ô8EãCKæGKØ>>Í>6ÌF:ÃH6¶?+·>-¸=-º<-½>/Ã?0ÊB4ÐD7ÕE:ÙE9ÚB7Û>5Ù;2Ù6-Ù5,Ú3+×3*Ô1*×4-Ú7.Ý90ß80Þ7/Ý6.Ü5,Ö/&Ù5+×7+Ï2#Í1"Ò9)Õ>-Ô;)Ø<-æD7øJAýD?ù64õ*-ö*-÷/2÷67í55â30Ú1,×0*×/,Ù0-Ù0+ã81ä91â:1â;2à<0ß=0Ü?0Ú>1Ñ7+ïWLøaZÓ;6Ñ;:æPQÜFHæPQÏ<4Ê:/Æ8,Å9,Ä:-Ä<.Ã;-À;,¾:-¾<.ÃA3ÇH9ÇI;ÂD6¾@2¼>0ÉF<ÊE<ÎIBÕPI×RMÕNKÓKK×LOéZ`ð^hüfrÿhxü]qòPeóMeýNkÿVzÿTxÿRrøTmö]qûhxûjw÷erüetó_mì`kêkrßruÃjfªd\žla}fVXH9kXJ”|r½ œÞÂÁîÖÖþîïûõõûûûûÿÿùÿÿýþÿÿþÿÿûÿÿúýÿþùûþõûüöÿþùÿÿúÿþúÿûõÿ÷òñèáäÜÑáÙÌðé×ÿúäÿÿæÿþåÿÿê÷ùëíðçèéáQK=PJ1ÃE6ÃE6ÅF7ÉE8ÎF8ÑG:×G<ÚG=Ö>3Õ;1Ö8/Õ4,Ö3*Ø4+Û4,Ú6-Û81Ý<4à=4ß<3Ý90Ü5-Ü5,Û7-Ò.$Ý;0Ú=.Í1"Æ-Î7&Ò=)Í:&Ì9'Ô8)â:/ó=9ÿ@@ÿ<>þ37ó,/ê,.á+*Ø*)Ô+(×/,Þ44ä88é99ï75ð74î73è71ã7-Ü6*×5(Ñ5&Í5(çPEÿmcÛHAÈ42×CCÓ>BêVVÙA<Ò>4Ë8.Æ6+Æ:-Æ/Á=.»9+»<-¾?0ÀA2¿A2½@.¼=.»<-ÃC6ÄD9ÈH?ÐPGÓRLÐOIÒNLÕONé^cîagûitÿnzÿduõVjõQiÿUoÿWvÿVtúXpñ^pônyöw€íksÞXañ`mñ`mìboïs}숊Ì|ªth™yjskXON:_VGƒqg¯–’ÜÀ¿ïÕØüéëþôõýûüýþÿúþÿþýÿÿýÿÿûÿÿùþÿÿûùÿõúýöÿÿúÿÿúÿÿøÿý÷ÿþöùðçíåÚéáÔôïÜÿûåÿþåÿÿãÿÿèùúêòôçîðåSM=RL4D=3B;3A:2@93A:4A96@;7A@;CC;IE9MG7OG2RF0UF1UH5WK?RHFXR^jg‚}§‰“Ä’žÚ˜¢ç¤§ö¦§ú«©ü«¬þ¬­ÿ­®þ¬®û¬®û¨¬ö¦ªô¤¨ñ£§ð¡¨î §í¤è›¢æ™žâ’šÛ‹“҆ʃ„ˆ·ƒ¨ˆyšmˆšcz©Xi»Q_ÏMYàIRèAIê=Aé=;ã>8ÝC9ÖH:ÎI8ÅF3ÂC0Å@1äTIàG?Ú;7Ø64Ø88Ø:;Ñ98È74À:/¾<.¿;.À:.Â8+Ã7*Æ4'Æ2&Î4*Ð3*Ñ3(Ô3)Ö3*Ù5,Ý6.Ü8/Þ=3Û=2Ü;1Û8/Û7-Ú6,Ø4*×3)Õ3&Ó3%Ð4%Ï6&Ò=)Ñ>*Ê9$À2È:&Ê4%Õ1'ç51ú<<ÿ=@ÿ7=÷37ê-1á-.Ù--×/.Ü43ã9:é;=ð9=ö26ø03ô01í1/ä1*Þ2(Õ1%Ï3$É1$Ñ=1új_äTLÈ95Ð@?Ë:=äRSäJHÜC=Ñ:3É6.Æ8.Å;0Â<0¿=/º;*¼?-½@.¼?-º;*º;(½;+¾<,¼>0¼>2ÀD8ÈLBÌPHÊNFÌLIÐNLèaeìaføhrÿo{ÿhx÷Zk÷UjþZrÿYsû]tîaræjtë}€ñ‡‰èwyÚ_dñgtþm|óeuëlwö‘•ì¢ŸÄ”Š¢|hjUHQSK>PJ>êDFå@DÙ8=Î65ÍB;ÈD8ÉC8ÇA5Æ>2Ã9,Â6)Â2'Æ2(Ë3(Î4*Ó5,Ø5.Ù4.Û4.Û4,äB7Ý=1Ù7,Ú6,ß9-ß9-Û5)Õ1%Ø8(Í2 Ê1!Ï9(Î8'Ç4"Ê7%ÔC0È7&Î8*×6,Þ5.æ3/î53ö:9û?>ÿLKúHFòBBì>=ê<=ç7:å26æ,1ô+1ø)/ô,.ï/.è1+à4*Ù5)Ó7(Æ0!À.ôdYë]SÏ@:ÔDCË;;ßMMêRQàHEÓ;6É6/Æ8.Æ9/Ã;-¾:+¾<,Á@-ÀA.»<)·8%¸9&½<)¾?.µ7)³7+¸>1ÁG:ÅK@ÅIAÈIBËJEåa_æ^`ñdjþnwþkuó]iðXeø]mú^sõbtèdoãlrì~ù‹ö†…éqsøryÿy†õaqàXföˆ‘ÿ´´Ð®¢ ›‡]jPDR9QT?jbU›ˆÚÀ¿òØÙöàãÿô÷ÿúýÿþÿýüÿþüÿÿýÿÿûÿþùýûÿúôÿòòþòùÿôüÿöûýòÿýôÿÿôÿÿóûõç÷ñáþùåÿýçþüãþýáÿÿêÿÿñýýóüüòXO@WP@WN?UN>TK2G?2H>2F@4GC:GE9JG8NI6RJ5UJ4UJ4VK9XNDULMZTbkhƒ{~§‰Ã‘™×˜Ÿç£¤ö¥¢ù¢¢ü¡¢ü ¤ÿ¢¨ÿ£«ÿ¤­ü¡ªõ¡©ñ¡¨ì¥¨íª©ï­©ó±©ö¬©ø ©ø—§ò’¡â–ŸÖ¦£Î¶ž¾¹…œ¸gz¿L]ÑERß>Mç;Gç?ß<=ÝEBÉ:4ÊD9ÊF:º1)ÛJEèJIéCEë>Bè;?æÚ<=Ô<;ÏB;È?7ÊD;ÑMAÍK>¿=0¸6)½9,¿7+Ã6,È5-Ë2*Ñ/*Ô/+Û2/Þ5.çA5ß9+Ù1$Ý3&å9+ç;-ß8&Õ2Ï2Ì4Ê5!Ç4"Ç4"Ê4%Í5'Ï5)Ê0&Ï2)Ñ5)Ò6*Ò4(Õ3&×3'Ü4)à2)æ3.ë52ë33é/2ç-2è-4í.5ö-3ö+/ï+,ì/-ê5.ã9,Ù7(Ð4%Ã-Ä3"çXHéYNË;3ßNIÅ41ÚHHáOPÜJJÔC@Ì;6È80Æ8,Ç9+È<+Å<*Â;(¾9&¼;(»<)º=)º=+·<,´8,µ;0¹=1»?3»?3¾@4À@5ÄA7ïjaõpiêc_ômjûqqìadôgmÿpyÿlzûhxðdoébiëdjîlnîqoîqoûy{ÿ}…ùZlücwßbpû¬¯¶ªš}‘u]rQJY:LR8snZ¥•ˆË·°íÕÓÿîðÿö÷ÿ÷ûýøüüüþþÿÿþÿÿÿþÿûÿþðÿôåþéæûêïÿîøÿöüÿôþÿóÿþñÿýñÿûîÿúêÿùæÿùãÿùáÿùáüúåÿÿõÿÿûÿÿûYPAXO@XO@VM>UL=TKÌLAÁC5¸:,·9+¹7*¿7+Æ6-Ë4-Ñ2.Ø3/á53ä84ä>2á;-Þ6)ß5&á5'á5'Ú5"Ó4Ñ9$Ë9"Ç9%Ç:&É<+Ë<,Ì8,Î4*Õ3.Ö5-Ó7+Ï7)É6&Ç4"Ë4!Ï4"Ø2$Þ2&ã0+æ.,æ,-æ,/æ-2è.3ì+.í,-ì0.è2.à4*Û5'Õ8'Ò9'Õ?.»*ÖD5Ð>1ÙF>ëVPÚB?ØBAçUVâRRÜKHÔC>Í=5É9.È9+Ç8(È;*Ä;(¿:'½<)½>+º?-¹@/¶>.²:,´;0·=0¸>1º?0½?1ÁB3ÅC5ëi\òmdçb[ðkfõolèbañklütxÿq~ÿo|öirí]fêY`ñbf÷qpþzxûvwÿx~ùRdþ[pä]nö¦©©¦“jŒkZtON_;SZ;us\©ÖĸöáÜÿõñÿúúÿúûÿûüüüüúþýûÿþúþÿõÿúíÿóáÿéáýæéÿëóÿñøÿòýÿòÿÿñÿýïÿýíÿúéÿöåûóàúòÝüôßü÷äýúóüüúÿÿý\PB[OA[OAYM?XL>WK=VJDã=?å==åAá>CàBè;?ã9<Ü68Ö66Ñ96Ì;6ÕHAÄ;1¾5+ÅA5ÍK>ÆH:»=/·8)º6)¿7)Ç7,Ï6.×50Þ71æ95é=9×3*×5*Ú6*Ü6*Ý5*Ý7)Ú:*×>,Å4!¿4¹4!¹6"¼8)½8)½3(À-%ã@;å>8Þ=3Õ<.Ì9)È7$È7"Ì7#Ò7%Õ3$×/&Ù.'Û.*Ü.-Û//Ü./Û,)ß0+à5-Ü5,Õ3&Ð4%Ð9&Ñ>*ÔA/Â1 çSEÒ;0ÚA;ÞC?èJIðTUíUTçSQãOMÝJCÖC;Ï<2Ê8+Å6&Ä7&À7%¼7&¹:'¹<*·>-µ=,²=,°:,±;/´<.µ=/·=.¹?0¾C4ÃE7Ü\Qêg]äaYðlgöpmça`ìfgójqàR^ï^kõhqòemñ`gôeiùqqþxwútuÿnuóJ]øRhä[mñœ¡£œŠa€`UoHOd=W`Aww]­¥’áÑÂÿîæÿøñÿüøÿþúþÿúûÿüûÿýûÿýùÿûóÿöèÿîÜþãÚøÞáùáèûåïüèöýëýþìýúéÿúêÿ÷æúñàôèØòçÕöëÙøñáþúñýüøÿþû\PB\PB[OAZN@YM?YM?XL>XL>UI;TH:SG9RF8RF8RF8RF8PF:LE;KGEç=Fã?FÖ:>Ñ?@ÑEDÆA<º61Å>:êZYÝABã@Cæ=@ã:=Û89Ó97Ð<8ÎA8ÏE;Â:.»2(À/¸9(½8)Â9)Ë8.Ò:/Ù80à91è;7ë>8Ø1+Ù2*Ü3,Ý5,à5-ß7.Û9.Ö=/É7(Æ:)Á<+¾<,¿;.Á;0Å<6Î95ëC@í@<ä@7Ù=1Ï9*Ç9%È:&É;%Ï<(Ð7'Ï1%Ñ1%Ô1(Ö3,Ô1,Ñ/*Ó2*Ó5,Ó7+Ð7)Í5'Ê7%Ì;(Ì>*Ì;(Ï<,ô^PàF<Ò3/Ò.,æ@@ûWXÿusÿroÿjgö^YçPGÕA7Ç5(½. Ä8'À8(»8&¸;)·<,µ=-²=,°<-¯;.­<.°.¼B3ÀF7ËMAß`Wâa[ôpløtræ`aä]aæ]dÖHTçYeógrôgoöelükpþsvþvvûpsûenñDXôKbåXkë’– •ƒ_zYQlCSh?\gEy|_°ª”çÜÊÿõèÿùðÿûñþþôýÿ÷ûÿúùÿúöÿøòüóêûëÚøÞÎóÒÊëÌÏìÎ×îÒàðÖéóÛò÷áöõáûöãüõãõìÛíáÑéÝÍíáÑñèÙüõíü÷ñþùó\PB\PB[OA[OAZN@YM?YM?YM?WK=VJ@Ð@?ÐIE¿>8³2,ÈC<àUPÜDCáACã?@á>?Ú?=Ô@<ÑD;ÏF<Ç=2À8*½5)½9*¿=-¿=-½;+½<)Â:*Ç;*Ï;/Õ;/Û8/à8/ç83é:5æ95ä52ä20æ21ç32æ40Ý2+Ô0'Ë1'Ë7-È:0Ä7.Á4-Ã40Ì:;Ý?@ë8;í76ä71Ø5,Ì4&Æ5"Ä7#Å:%Ë=)Ë8&Ì4&Î5'Ô8,Ô:0Ó9/Ð8-Ð>1Ê;-Å8'Ä7%Æ9'Ç<)Ç<)Ç:(Í>-Í:*Ø>2áC:Ô/-ä::à24ß56×53Ö;6ÞC>åKCêQIêSHèTHäUGË?0Ä?.¾<,¸=-·>-´?.°?/®>0¬<.¬<.¬<.¬=,­<,±=.·A3ºD6ÆLAÞbXâc]ðnlôrrå`cå`eç`g÷kvûoz÷kví`hð_fýlqÿx{ÿy|úmsø^jóAWôC]èUh懣“ƒg]YtI^uIhwPˆf³²–èâÌÿúéÿýíÿþïýÿòûÿôøÿôôÿñíûêäòáØî×Åèǻ伺޺¿Þ¼ÇàÀÍâÃØæÌãëÓìîØôñÞ÷òßóêÙìàÒèÚÍêÜÏïáÖòèßñèáòéâ[OA[OA[OAZN@ZN@YM?YM?YM?XL>XL>WK=VJQI>QI>SK>UL;XM9XM7YL9XM;WK?ULGYSWe^nnjƒut–~}¥„…±†‰´‡‰¹Š‹Á‹ÈŽÏŽŽÔÕӔӋʃˆÀ|¸u|²ov­io«ljœ€lˆ“cy®YvËPoãBdð7Vö4L÷8Hï@EåFBÝJCÛJEáGGèCJò=Nð>LäCI×CCÌA>ÎIDº;4°4,ÉI@ÕLFØBAÚ?=Û;;Ú<;Ø@=ÔE?ÍG<ËG:À8*Á8(À8*¾9(¼9'»8&½:(À;(Ä;)Ê=,Ò<.×;.Ü8.á6.ä6/è50é32è./é,0î02õ47õ77î45æ21Ú.*×4/Õ62Ñ32Ï/1Ò/4Û6=ê:Dí06î02æ3/Ü3,Ñ5)Ê7'È9(É<(Æ8$É6$Î6(Ó:,Ú>2ÝA5ÝA5ØA6ÓG8ÉA1Â;(À9&Ã<)Æ=*Å<*Å8&Ì:+Í7)Í0'æC<Û2/ï?Aã/2Ú*,Õ1/Ò5.Õ81Ö90Ò8.Ì5*Æ2&À1#ÎE5ÆA2¼=.µ:*±9)¯9+«:,ª:,«;/«=0¬>/¬<.«<+­<,²>/µA2ÉSGàg^àc_êjiînoæchðjqõoxúq{ýt~ömuîbködnÿrzÿx~ÿquúipøWfùAYô@[êQfá~ƒ¬—†ykmˆ]o‰ZyŠ`—r¶·˜ßÞÂùôÞüúåÿÿïûÿïõÿïïÿëçúäÜïÙÐãÍÅÞÁ°Ö­¨Ó¦ªÐ§°Ó«¶Ô®¼Ö±ÇÚºÒßÁàæÌèêÔòíÚòéØîâÔìÛÑêÙÏìÛÓéÚÓæÙÑåØÐ[N>[N>[N>[N>ZM=ZM=ZM=ZM=YLUL=XLNÝAEÔFDÈA=ÉHB´:/±7,ÎOFÉB<Î=8Ð64Ï10Ð51Ó>8ÏE;ÈF9ÃD5¾9(Ã:(Â:*¿:'½8%¾9&¿:'Á:&Ä9&Ë:)Ó:,Ù9+Ý7+á5+ä3+ê3-ë*+ñ*-ø-3ü/4ÿ17ÿ37ÿ38ý58ù8;õ8<ò9>ò9Aô9D÷7Fû6Hþ5Eô+5ô-2í12ã4/Ù6-Ð8*Î;+Î=,Ë5&Ñ8*Ù;/ß=2â>4ä=4å>5ßA6ÙJ<ÏG7ÉA1Ä<,Â9)Â9'Æ8*È9)É2'Ó9/á@8ëD>Þ0/à..ë46è66Ø3-Õ7.×90×:1Õ;1Ò;0Í:0É;/ÖL?ÌF:¿@1´9*°6)¬6(«7*©8*¬;-­=/®>0­=/«<+«<+­<.±=0ÀKAÚdZÞc^èkiðosêinõrzüvîfp÷oyùryöjsþlvÿwÿv}ùhoùcn÷RbþB[÷ZM=ZM=ZM=ZM=ZM=YLVJ>XL>YN5É83Ç/,Å*&È/*Í:3ÌC9ÃC6¼>/À;*Ä;)Ã<)Á:'Â;(Ã<)Â;'Ã8%Ä5$Ê7%Ô8)Ù7*Ý5*á3*å3)ê2*õ33ÿ58ÿ8<ÿ4:ÿ-2ÿ(-ÿ(-þ+1ü-3ö)0ò&1÷)6ÿ,?ÿ*Aü 9ó/ö"0ó(.í,1æ0/Ú1,Ô3+Ñ5)Ð6*Ô6+Ý90æ=6ë>7ë:4è71è50â92ßH=×K<ÓE7Ë=/Ä6(Â3%È6)Ï8-Î4*Ô6-æC<ß82à21Ò ì89å63Õ1(Ò4)Ò4)Ï5)Î6+Ê6*È5+Å7+ãYNØRFÊH;¾@2·;/µ;.µ<1µ<1¯9-±;/±=0±=.¯;,­9*­9,®:-±<2ÐYQÜb]ìppôvyîmrõq|ör}ÿzƒÿ‰ÿy€ôhq÷epÿq|ÿuÿktø^jöOaÿA^÷8WéG^Ûntº‹™©„‚žn~šg—hœq¡©‚´º–ÈÍ­ÕܽÌÙ»ÁÔ´²Ì©§ÂŸž¼˜š¶–²Œ±†‰³†µ~¹„•À‹œÂŸÄ‘¨Å™²È¡¾ÎªÉÒµÚÙÄæßÍêÞÒéÖÏáÌÉÛÆÃÔÁ»Î½µÈ·°ZM=ZM=ZM=ZM=ZM=ZM=ZM=ZM=XK;XK;XK;YLYM=WMCWLHXNOZPX]Ub`Yia\rjfokŽsp›vq§{u³ƒ~ÁŠƒÉŠƒÇˆÀŠ~¼ˆy²ƒr¨†r§t«‡l£†\„HL¤B9¶A:ÍC@Þ@?è:;ô<>ÿDE÷><ó=<ì>=ê@AëBIêCMëANãALÐ>>Å@9¾?6·>3°,º7%Á:'Ã<)Â;(À9%Â9&Å:'Ç:(Ë:'Ð9(Ö6(Ø2$Ú."à/%ì7.õ=5õ82÷40÷0-ø**û&(û%'û%'û%'û&*÷!)ø".ÿ'7ÿ(>ÿ!;ÿ6ý1ÿ'8ï#,æ#+ã+-Ý--Ô+(Ò-)Ü41â62è64î66ò65ò12ï./î,,å/,Ü92Ñ:1Ò91ìSK»"Ä+#ßF>È.&Í.(Þ<7èE@â:7Ø/*Ú.*â51å<7ß>4Õ<.Ï5)Ë3&Ì5*Í;.Ë;0Å8.ìbXàZOÈC:¹6,º:/¸8-±3'´6*°0%°2&®2&¯4%°6'²:*´<.³=1°:0ºC;Ö\Wìppñsvöx|ûyƒõq|ÿ|„ýw€út}üs{ÿr~ÿr}ÿmxÿgsü`nôI\ÿ>\ÿ>[äAVÔek´•€’¡zƒm}™f~”c‡—j”Ÿwž¦ ¨ƒœ¨„’£Š£|€Ÿvzšqyšo|r vƒ¤u‚­wƒ³y‹¸‘¼„“¾†—¾‡œ¾Œ¢½§¼“¯½š¾Â§Ï̹ßÓÇãÒÊÜÇÄÔ¿¼Ìº¶Á²«¹ª¥ZM=ZM=ZM=ZM=ZM=ZM=ZM=ZM=XK;XK;XK;YL]P@[OC[NFYNJZPQ\SX_U^_Wfd\tibƒng‘qjxp¬€y¼‡€ÄŠÄ€Á~ºt«Œn¢—q¤¡u¨šjž™W{=Aª5+±5+Â<3Ó@8Ý>8è?:óA=õ=;õ;<ô;@ñ>Bî@IèAIâ@KÚAFÇ<9½=4¶<1±;/«:,®:+½A5ÐJAÚG@ÜA=Ô63Ð51Õ@9ÍC8»9+²5#½8'Â;(Ä=*Ä=*Ä;(Æ;(Ç:(Ê9(Ï9(Ï6&Ô2%Ú2%ã5*ê8.ï80ð91ç1&ç/%ê.%ï,&ö+'û+)þ,+ÿ-.ü*-ú%+ú$.ÿ'7ÿ$;ÿ7ÿ3ü0õ0ö.9õ3<å*1Û(,Ü.0Þ02Û+.ñ:>ô7=÷4:ö26ö/4ø03ù25ô87Û2-Ú;5×82äE?äE?Î/+Ñ2.Á"Ô51á?:èE@à=8Ø3-Ù2,Ý60Ý:1Ô:.Ï9*É5'Ç5(È9+Ê<0Ê<2Æ9/ícYáXNÉ@8º4+Â91Ã:0¿6,Â9/¿5+¾4*½4*»5)¸6)µ5(´6(°6)´;0»B9ÓYTèljïqtöx|þ|„øv€þ|„üyùv~þuÿsÿp}ÿkwüdqý_nöI]ÿ>\ÿ>\éCYÓeh®Žw‰˜oz•bu’\xŽ]cŠ•k˜p‹•p…”mp‡]l‰]h‰\g^k_q•ey›izŸk¬t„±vŠ·|»}¼“¼‚–½†›»‰›µ†¡³‹­¶—¾½¨ÏÆ·ØÇ¿ÖÁ¼Ï¼¸Æ·´º¬©²¤£\L<\L<\L<\L<\L<\L<\L<\Lù:Aö=Eï@GæAHÙ@EÏ@BÀ;6¸90±9+­9*©8(­9*»?3ÏF<ÙD>×96Ù74Ú;7ÜC=ÝOEÎH<µ3#¾9(Á:'Ä;)Æ=+É=,È<+É:)Ì9)Ï7)Ï2#Ó/#ß4*î=3ô?6ñ91é4+à4&ß5&â2%å/$ë,$î+%ñ+(ò+(ó+-ð(+ò&/ø(6þ%:ý7ü3ø3ô%7ò0;ó5Aò8Cð;Dðä,6ð2<ó/;ö.9ö-7õ.3õ.1ó/1í42Ü0,â=9Ú64ß;9ÿmjåCAÑ/-Î/,Ù:7ß@<àA;Û<6Õ7.Ö5-Ö5+Ò6*È6'Ã6%Â6'Ä8)Å;.Æ<1Æ<1Å;1ë`YáTMÉ<3¿0(Ë;3Ñ>6Î;3Ò=6Ø=8×<7Ô=6Ï<2É;1Ã9.¼6*¶6)¹;/¼@6ÏTMãgeíorøz~ÿˆû|ƒû|ƒûyûx€ÿwÿsÿn}ÿgvû`pü[mõG^ÿ\ìFZÎ`až~ev…Zi„Qh…OmƒRt…X{ˆ]}ˆ^x„\q‚X`zM_Pa…UeYn•`uœg} j~£mƒ¬r„²tˆ¶x‹¹y‹¹y¹z‘º~”º“±•¬€›©†©­’ºµ¢Ç¹®Ë¸²È¶´¸¬¬ª¡¢ —š[K;[K;[K;[K;[K;[K;[K;[K;ZJ:ZJ:ZJ:[K;[K;\L<\L<\L<]K=]K=]L<^M=^M;^O<^O<^O<^Q@^Q@]OB[OC\NE[NF\OI]OO^P_bTmdY{i^‰pgœ|t­…{·ˆ{³™…º¥…´¯€ª¸z¡ÆxŸÑuœÌcŒÈMlÜFRßA@ÕA=ÏE;ÌH;ÍG;ÓE9ÞA:î@Aõ0ÎD:Õ<7Õ31à;9åA?áD?èSLßUJ¿:+Á9)¾7$À7%Ä;)É=,Ê=,Ë9*Î8)Í4&Ò2&Ù2)å9/ñ>7õ>6ð5.ä/&à6)Þ6)à4*ã1'ç.)ê-)ì*(ì**ê),è',ë'1ò)9ö&<÷!;û=û%Aû6Hä(6ç.<ÿP\ÿ`lÿP\ò;åGDÛ=:Ú<9Õ:5Ò80Ñ7-Ð6*Í4&Æ3#¾5#¹6$»8&¿;,À9é=9æ?9á@8Ù?5Ð<2È:.Á9-»9,»=1ËNHàc_ìnoú|ÿ„ˆý~…øy€øy€üyÿx‚ÿt‚ÿn}ýetù^n÷VhóE\ý8Vÿ^N>\O?^NA]OB^PE^OJbNYbQdcTqdZ}le‘xr¢w¨ƒv¤”}§¬†«Â‰©Î‚žÚw”ál‰ÛXwÚD_óBTúDPïJPáIHÐE>ËE<ÐF<ÙD>èBBð@Cõ@GõBHíDGßCDÏA=Â?7¿@7µ=/®:+«:*ª9)®8*»;.Ì?6áFAâ=;îBBëAAÞ;6ãJBæXLÕK>È@2À8(¼3#Á8(È<-É:*Ë7)Ð8+Î0%×3)à8/é;4í:5í60ë0+å,'ã0,ã1-ç10ì31ó25ö37÷48÷6;ì-5ê,6í.=ñ0Có-Fö)Gý+Nÿ3Rô9Lå3?ð@Mÿ_lÿlzÿWfõCSõ>Pî3Dí3Aí3>é6<ã99Û83Î4*Ç/$Ë2*Ç.(Ð72òYTö\ZòXVÛA?âHFÜB@Ô<7Î70Í6-Ï8-Ï9+Ê7'Â5#¹8#³9$µ:(¸=-¹;,¶6)¼7.Æ=5ÛNGÙEAÎ50Ð1-á>9ç@:ã81ç51ë20î21ë52ç83á:2Ø:/Ð9.È:.¾6*º8+ÈIBÜ_Yënlû}€ÿ…‰ýƒõv}öw~üyÿx‚ÿsƒÿk}ýdvù^pôSeôF]ý8Vþ=ZïL]ÀTRz_BWhÑC?ÖEBãEFèBDîAEíCFçDEÚEAËB:¿?4»?3±;-©8(¨9(ª9)°8*¼:-Ê;3èIEé??ë=>å78Ú2/ÞA:îZPôh[ÚPCÉA3¾5%Â6'Ç9+È9+Ë7+Ò8,Ñ0&Ú6-æ;4é;4ê40è/,ê-+ë--ó49õ3;ø3=ü3=ÿ1>þ0=ý1=ù1>õ0Aò1Bô4Kõ5Nõ0Nö-Oÿ1Xÿ>_æ3HùO\ÿanÿ_nÿWfûP`ôDXé8JóAQê:GÝ2:Ò/2Ê2-Â8-½;+¼:*Ä:/À2(ÙJBúkcÝLGáPKÏ;9Ï;9àLJÔ@<Ê70Ê7-Î-±9)¯3'º:/ÊD;ÖGAØC=Ô72×2.ç;7ì:6è2.í2-ò,-ô,,ò./ï31è71â:1Ú<1Ò>2Â6)º4)ÅB:×XRçjhú|}ÿ†‰þ€„õv}÷xýz‚ÿx‚ÿqÿi{ûbtø]oòQc÷I`ÿ:Xý?[ðO_ºQNqX:Sf8]uEa|InSv†Y{ˆ]~‹`g‚—l€œl}Ÿm|¤o}¨p€©o‚ªnƒ©l…©lˆ«qˆ®qˆ°r†³r„³oƒµp…·r‰¸t‹µv‰¬tŽ¥wš¨„°´™ÈïØ̾ÚÑÌÂÂÌ«±Á›¡±ZK8ZK8ZK8ZK8ZK8ZK8ZK8ZK8ZK8ZK8ZK8[L9[L9\M:\M:]L:^K<`J<^K<_L=^M;_N<^O<^O<^O:_P;`O;aP>aP>aP>aPÉ@8¾>3¸>1¯9+¨7'©:)­<*´<,Á=1Ï?7ß=:å99ã03â/2à42Û94æMEülaòh[ÙQCÆÍD>Á63É;7äUQÕF@É91È8-É:,È9(È9(Ä=)±?'¦<&¨;&¬=*«7(¬3(¼=4ÓLFÖGAÝE@Û96Ü30é73ì51ë0+ô1-ý,/ÿ+-ú./ô1/í4/æ81ß;1Ø>2É9.½3(À;2ÏNHáa^÷yzÿˆŠÿƒ‡ùzû|ƒÿ{†ÿx„ÿn~þew÷^põZlëL`õIaü9Wû=YîM]²JGhQ1Qd6\tDf~Nuˆ[Žc„h†’jˆ—n‰žsˆ¤t„¦t§r}¨p¨n©mƒ©l…©l…¨n‡«n…­o…¯o°l€²k‚¶n…·r‡³t‡­t§wœ¬…²¹šÈƯ×νÙÒÌ»¿Ê¤¬¿’š­[J8ZK8[J8ZK8[J8ZK8[J8ZK8[J8ZK8[J8[L9\K9\M:]L:]L:^K<^K<^K<^M=^M=^O<^O<\O<`Q>aR=aR?bQ?bQ?aP>aO;bL>hOKgNRbP\cWkjfuv”}|œx—‘z–«•Æ„’Ú}…ðuzþlmÿY[ýDLþ/Iÿ5Rÿ4½=0µ?1¬;+©8(­<,´?.»@1ÊA7ØC=Ù74á85Þ..â30æ:6Ó0'Ï5)ëUGÿwjë[PÑC7Ê<0Ë;0É7*Í6+Ô:0Ú70ß82å63ç32ê01í12ô36ý4<þ%6ÿ#9ÿ"9ÿ"9ÿ!8ÿ6ý5ø6ï2î9ð%Bï(Gî&Jñ'Mÿ3\ÿEhÿbuÿ`l÷WcñQ]òP]ïMZâ@MÔ2=Ú=FÌ7;»/.®/(¦5'¢;(›?&œ>%ª9'²8+ÒVJ»;2Ä?8¾41½2/ÎC@åWSÕHAÈ91Ä6*Å6(Ä5%Æ5$Ã:(±<(§:&¨7%­9*¬4&¯1%Â?5ÛRJÙIAáHBÞ;6Þ2.ê41í1/ï-+ü22þ,/ý+.ù+-ó++í-*æ1*ß4,Ö8,Ñ=1¿2(¼7.ÈIBÙ\Xówwÿ‰‹ÿ‡Šû€…þ†ÿ}ˆÿv„ÿj|þ_s÷XlöTiêD\õD^õ6Uñ:VàLZ¥HC^K-Mc5Uo?b}JtŒ\€–g‡˜lˆ›nŠ r‹¥vŒ¬z†«wªr~§m|¥i}¥g¥g‚¦i‚¥k‚¨mƒ«m‚¬l®h~°i³j„¶o‰¶s‰¯rŽ¬x™°„­»˜¿Å©ËʵËͶ½Åžªº‹—§]K7\K7]K7\K7]K7\K7]K7\K7^L8]L8^L8]L8^L8]L8^L8]L:]J<]K=^L>\L<\L<[N=]P?^SA`SB_R?`P@bQAcRBdQBdNAdLBjMIhKMdPYf[lnk†w{ž€…­‰ˆ²ƒ©¥‡©¾ˆ Ð‚’ây~ðsqújbÿa^ùJWñ>Që:Lî?NïCQê@Kæ9Ê=4Á;0¸:,§6&¯A0­<,¬6(¿A5ÌF=Ì=5Ð72Ú85Ü71Þ5.Þ6-Þ8*Ý<*×:'Ó6%Ù;0ðSLòZOÙE9Ç8*Í>.ÔB3Ò:-Ô3+ðGBá//î5:ó6=î,7ÿBMñ'3ú&2ÿ)2ÿ(2ù'ý"*ÿ'/þ'/ð&ð)ù+7ê .ì&7ñ-Aç#;ÿXrç-Dÿ]lÿ_iþZcùU\õPWëHMÝ?@Í84Ë>7ÄA7·?1¦7&™2!™6#š;'Ÿ<)§8-®7/ÂE?¿;7½31Ä64Å54ÔDCÛLHÚKEÑD;È:0Ä4)Ç5(Ë4)Å5*¼1¹=3Ö_Yésqÿû„†û‡Šÿ„Œÿxˆÿh}ÿ_wÿ[uÿUoøLføEcñ:Yô;[æ?YÛ]i‹@;VF-L^6YuBg†Mw–]}œcg€¡jƒ¦n‚¨o€§n¦m~¥l}¥i|¤h}£f£e£f¥l¦m«l¬k~­g®f±gƒ³i‡µm‹´r°vŽ®|™´‰§½™±Á¤²Á®¦²°˜žz…‹]K7]K7]K7]K7]K7]K7]K7]K7^L8^L8^L8^L8^L8^L8^L8^K:\K;^L>_M?^N>[N=[N=\Q?^RB_SC]QA]OB_OB`NDbPFcOHeNHiMJgNQeS_g_tnny~¨€‡»‡ŠÁž•Ê£‹»«£¹xÓyƒê|{ôvjöi`ø]aóOZìFRòHSøIVõEPï?Jë;Eä9?à:<Ú::Õ=8Î?7Ç>4À/Ç8(Ê8)Ó;.Þ;4öJFä01ð6;ö6Añ.<ÿ@Nï'4ó$,÷%(û),ý+,ü*+ø((ö((÷+,ï$'í%(ê%,ý;DÙ'ð4CüARØ&6ÿjuÿbjþZaüW]ôOSåBC×<8Ñ>6¾8,¿D5¹H6©>,™/)(’(ž-%°:6ÑTPÎHGÃ54Æ45Ñ==ëWUØGBÖG?ÐA9Ç9/Æ3)Ê6,Ð7/Î70Ç=3Â91Â5.Ã2-É4.Ñ83Ø?9ÞE=äJ@ÞA8Ú6-Ý0*ç0,ò21û03û03ô02ó12ô01ó/0ó0.î1-ç4-ß9-×=1¿3$¾aP@`P@]P?\O>[O?[RC[QE[QG\OG\OI_PMcQOfTTgUUgUUgV\h]nli†sv£|ƒº‚ŠËŠÔ˜‘× ŠÊª‚´¹}ŸÏ€“䄆îvósjûeg÷S\íGQðFOöHR÷EQòAKî=Eä7=à7:Ù99Ô<7Í@7ÅA4¾?0¶>-­>-ª<+«:,¸B6ÇH?À;2»0)Ê:2Í6/Ð6.Õ7,Ø8,Ù7(Ù8&Ü9&à:*Ý4-Û4.âA9éOCÞH:È5%È2#Ù@2â>5õHDè13ò5;ù7@ø4@ÿESø2?ð)0ë#&ì$'ù13õ-/ï''ì&%õ12ë)*ö8:è+1â)1ë3=ÿR^ï=Kÿ[gþ^fñV\îOTðMRêEIÝ:;Õ74Ô?9À6,Á?2¼B5³=1¬7-¥3)¡,#œ' š%©/*ÇECÂ::¼,,È35×ABô^]Ð?:ÒC;ÐA9Ë=3Ì9/Ô=4Ú@8Û@;Û@<Ø=;Ý>;ãA?ä>>à::ã?=ëIDàB9Ý<4Ù5,Ý2+ç1-ð31õ12ø02ô02ô02ô01ó/0ó0.î1-ç4-ß9-Ø>2À4%º8+µ;0Ð[Tízwÿ“’û‡Šúƒ‰ý~‰ÿr‚ÿdyÿ[tÿTqÿNmÿFgû=_ô=\îEbßTg¢AHp;3SH2Qa<]xEf‡Nr“Zu˜^tš_xžc{£g{£gy¢fy¢fy¡cx byŸby a| bz cz¢f{¤h{§h{¨e{©a{©`}«`®`‡²jŠµn‹²s‰¬t†¦w‚žuy“no†lSeYAPM2A>^M9^M9^M9^M9^M9^M9^M9^M9^M9^M9^M9^M9^M9^M9^M9^M9^L8`N:aP<`Q>]P?ZN>YOCXPEXOH[QO_UTbXYeX_iYcl\fk^glaildqok‚rtšy~µ†Ê…ŒÚŒŽáŽ‡×Ÿ‹Ó­ŠÄ³€©½yŽÌ{Þzò‚wÿsrÿcgùU\ôMTõGPôCMò>Gï-±=0¼F:ÌRGÇH?º5.º1)È91Í81Ó;0Ù=1Û;-Ù6'Ü6&à8+à5-Û2+à=4ìNBãK=Ò:,Ñ8*àB6ß7.ð>:é/0ð16÷4<ü8BÿNZÿLUý>Eò38â$&í/1ê,,ð22è**ë/.ò::Ñæ37Ý,2è9@ðEMÿXcóMWØ=CÚADáBFá>AÞ9=Ü89Ø88Ó97É83Â91½:2ÀA:ÍNHÖVSÐNNÃC@²72¶95ÏKIÙMLãQRïYZêRQñYVÉ51Î>6ÒB9Ð@7Ó?5ÙB9àC<â@;é?@ç8=ì9=ò?Cï:?è58ì>=öMJÞ93Û60Ú3+Þ3,å4.ì30ò21ô01ô02ö/2ö01õ/0õ/.ð0-é4-à8-Ù?3Â6'·5(³9.ËVOï|yÿ“’üˆ‹ý‰þz‡ýoücwÿXqÿOlÿFhÿ@cû9\ô?^éKdØZh…35g;0WO8WgCa{Kj‰Ps’Yt•\u˜^wby¡ez¢fw dv awŸavž`xŸ`xŸ`{Ÿaz cz¢fz£gz§fz§bz¨`z¨]|«]~­_†²g‹´nŒ³tŠ­s†¦u€qtŽii€dQcUDSL8G@^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M9]K5_M5`P9_P;\O>ZN@XOFXQKYPQ`W\g`hnfsshysg{sg}qh}ol}pq†rw—v}«z‚Á‡Ò„ŠàŠ‹å“ãŒÚ „¿žuŸ l‚¬nq¼vlÒviòsmÿllÿgiþ^`ûRWõFMï3Û=1Ú6*Ü4'â6*à3,â70ä=5åE9âF9ÞB3ÞA2â>2Û0&ê72ì0/ï.1ñ.4ú7?ÿPXÿ]dÿZ_ÿOSá.1ã03à,-÷EEè66Ü,,Û-.ë>@Ü25Ù37ÿbhà=BË*2Ê-4Á&*Õ;=á@EÛ6:Ù37ß9=Ü7;Í/0Ì43Í;;ÕGFÞRSì`cõilôekê^aÄ@>ÆE@å^[øhgÿopÿjjåKK×=;É40Ñ>7×D<ÖC;Õ>5Õ<4Ø:1Ü41î5;ñ-7ð,6ò.8ï,4ë,3ó9<þJKß3/Ü3.Ú3+Ü3,ã5.ê40ï4/ò21ô02ö/2÷/1ö.0õ/.ð0-ê3-â7-Ù?3Æ8*´2%²8-ÃNGï|yÿ’‘ÿˆŒÿ‰ÿw…úl|øatûTnýHgÿ>bÿ:_ú6\óAaàNeÂWap/+_?0[W>^lIe}Mk‰St’\u–_v™_xžcy¡cx buŸ`uŸ`u_vž_wž_xŸ`{Ÿaz¡bz¢d{¥e|¦d|§`y§^y¨Z{ª\}¬^€¬a…¯g‡®m‡ªp…¥sƒ r{•nrŠjexe[k^RbU_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N:^L4_N4`N8^O:[N>YOEZSMZTT_ZahbprmzuŒ{u‘{q“zp“vp’qt“rxšt}¨w¶zƒÄ~†Ï„‰Ú‹ŒÞ–Ü™ŠÍ›…¶¢ƒ£ª„‘«~yŸl[šQ>¼MBÔQIâWRëWUñSRñKMí>Cå4:é9<æ9;à;9Ø=8Ó@8ÊB6ÀA0º?/³9,ºA6«5+£.$¾I?Ùg\ÙdZËUI¸<2¸6)À3)Î:0Ù;0Ú6,Þ3)ä6-ß1*ä71ã;2Ý9/Þ>0ãF5äB3ß9+ß1(é4-ð31ï-.í*.ô17ÿEJÿV[ÿ]bÿ\aâ9<ã9<Õ+,ôJKâ89×//Û57Ì()Ì'+øXZÝ>BÕ9=Ñ6:º#Ä(+Ü<>æAEÝ49Ù,2Þ17Ù05Í(.Ò37äKNöaeûhnùcl÷`iú`løbkÖLLÕNJê\ZêVTçMMãHFÏ42Î3/ÙA<àKDäOHßJCÙ@8×:3×6.Ü.-õ2:û-:ø*7õ'4õ)4ø0:ÿ>CÿJJà1.Þ3,Ü3,Ý5,á4-ç4/í4/ð3/ô02÷/2ù.1ø-0ö..ñ/-ë2-â7-Ù=1É;-³1$±7,ºC=ìyvÿÿˆÿ|ˆÿqöhxö_rùRlûDcÿ9^ÿ6]ú6\ðFcÑN`¢IMe5+VD0[Y@^lIe|NkˆRt‘[w•_x™`{ždz cvž`s›]rœ\s›\tœ]v^wž_{Ÿaz¡by¡bz¤b|§b{¦_x¦[x§Yz©Y{ªZ~ª_ƒ­e…¬k‡©m‰§s‰¥u„s|”ru‰pnlfwe_P=_P=_P=_P=_P=_P=_P=_P=^O<^O<^O<^O<^O<^O<^O<_N:aP6aP6aO9^O<[OA[RK\VV_Zakgvso†}z—‚~¡|¥}w£{u¥xv§sy©s}°x¸{„¿~†Ä„‰ÉŽÎ”“Íš“Ç •½«›µ¼¦²É­©Å¦”ªˆmœfJœE2¯A4¶@4ÂB9ÖHDèNNîJKì?Cë=?é;=ä<;ß=:Ù@8Ð@5È>1Á=0½:0¾?6¯4,§1'»I?ÑcVÖh[ÕeWÃOBº>2º4)Ç7,Ö90Ù5,ß2+ç60â0,ã4/â7/Þ7.à>1åC4ä>0Þ4%æ4*é0+ð3/ð..ï-.ò14ó78öBEöMRüY^éFKöQWØ37ëFJÝ8<æAEÚ7:Î.0Ñ05äHKÒ7;Ð7:¹#%Õ;=Û8;å;>ëÿ0=ú*7ü.:ÿ;EÿCHûABã1/ß4-Ý4-Ý5,â4-æ3,í4/ñ40ô02÷/2ù.1ø-0ö..ñ/-ë2-ã7-Ø:/Í>0µ1%±7,²;5ésqÿŠŠÿ‡ÿv†þi}óató[p÷PjúCbÿ7`ÿ7aù;_ìLf¿O[~86]=0NF1VX@ZeEcxMj…RrŽ[v”^yša{ždxžas›]p˜Yp™WqšXqšXt›\uœ]y_xŸ`x¡_y¢^z¥^y¤\x¤Yx¤Wy¥V{§X©_‚¬d„«h†¨l‡¥o†¢q€šmx‘jq…ij~cbv]_P=_P=_P=_P=_P=_P=_P=_P=^O<^O<^O<^O<^O<^O<^O<_N:cQ9cQ9aP<]P@ZPG\TR_Zaa_mtrŠyx˜€¨ƒ°~~°yy¯yu°wwµw|¾x€Á}…Ä‚ˆÄ…ŠÁ¿—–¾ ¼¬§»¶¬µ¾³±È¸«Ð¾¦ÖÁ¢Ñ»–Ьˆ¯oT®\G¤G5¨>0ÂG?àWQïWVñNOé@Cê=?æ<=â=;ß=:×=5Ñ:1É90Á80Á<5¹:3¸=5ÁOEÇXMÇ]OÑeXÓcUÂL>¼:-Å8.Ò91×4-ß2,ç60æ40á2-à5.ã<3çC7æC4â:-ß3%ê5,æ.&ð0-ï/,ð31ñ54ç-.â24çBF÷X]öW\ÿouåDJëHMà@Æ02Ö:=òHKî9>ð7?ø=Fò7Bè-8ô>Jÿ]gÿmwÿjrÿcn÷]gú^kÿaoÿ]nùYeò\]ãPIâJGÕ74Ò/0Ù54Ò0.Ø95ßD?ãJDâIAÙ@8Ó6/Ö4/Ü71è66ê'/ü0<þ2=÷+6ù0:ÿ>Eý?Aì44â3.à5.Þ6-ß4,á3*è3,ï4/ô41ö01÷/2ù.1ø-0ø..ò/-ë2-ã7-×9.Ñ?2¶0%²6,°61èpoÿ‡ˆÿ†Žÿp‚ücxñ\pôXn÷OiûBbÿ9aÿ`P@`P@_O?_O?_O?aQAbRB_O?]M=]M=aQAcSCbRB`Q>dS?aP>]P@^QI[QPZSZeapsq‰yxšz|¥~€±€¹}ºxz·rs´lo¶twÈv{Ì€ƒÊ‹Æ–—䤾²°»¼¹´ËƳÓÌ°ÙϬÛϧÜÏ£ÝУÙ˜٘Ѩˆ¸€g ^FËzgÖue½H?×QN÷ccéKLå?Aâ89ä::â:9Ü75Ù61Ö;6Ë81À5.ÇB;»<3¿I?ÆXK¹OAÎdVÑcTÌXIÅG9Ä:/Í6-Ø7/á6/ã4/ß0-ß2,à70ä=4à<0Ý7)ß5(å7,ä/$ê/&ì/)î1-î20ë40è51â64×79æJNõY]íNS×8=×6<ùX`ÿ~„ÿ~†ÿouÿgoÿipÿflõ\añX[ûZ_ÿUZÿDKü8Bû7Aö2>î+9ì0>ñ=HÿS_ÿ`iÿgrÿepþbmÿcnÿ`oý]gíSSßF@Ö85Ö41×11×/.Ø31Û94áD=ÜB:Ù?7Ö<4×90Û81à93æ66ð7<ó4;ó4;ö4<õ6;ò59ë33ã1/Þ3,Þ5.ß7.à5+ä3+é2,ï2,õ20÷12ø03ú/2ù.1ù//ó0.ì3.å7.à?5Ì8,¿6,¯/&¸;7ÒXWÿ˜šþ{ƒÿm€ÿe|ø\rðPhôGeüCeÿ;dù9`õNlÓRd‰=?P, C;&CG.KM5Y_CZjEcxMqˆZx’bx–`t•\r–Yq˜Yl•Sm–Rn—So˜Tr™Xt›Zuœ]uœ[t›XtWv Xw¡Wv¢Wv¢Uu¡Tt S{¥[{£]zž^u—[m‹Ub~MXrCSj>AW0?U/`P@`P@`P@_O?`P@aQAbRB`P@_O?`P@bRBcSCbRB`P@fVG_QF\OG^TSaZad`omkƒvw–wy¢{}®}¸x|¹quµkp´lo¶nq¾uvÐ|~Õ‰‰Ó˜˜Î¨§Ç¸¶ÁÉźÓαÛתâÛ¥çÞ¥æÝ¢äÛ¤âØ£ÛÑ ÔǛӼš»œ€©}dÅ‹wÊ}m´VJÒa[örpìZ[çKLã?@ç=>ë>@ç;;â66Û64Ö=8É83Ê?8¹6.¸>3½K@¶H;È]MÝo`Ô`QÆH:½5)Ä0&Ô6-Ü5-Û0)â51å95ä=7à<3Ü8.Û5)ß4*ã5*ì7.í5+í2+ë0+ç0,ã2,á4.Ý52Ö87Ø>@äJLóW[ú^bü\dþ]eÿaiôS[ïNVñQYÿ_gÿjqÿflõZ`óNTí4:ñ,5ô*6÷-9ñ'5å!-æ'6í7CþPZÿZdÿblÿdmÿenÿcmý[hõQZåEEÞ<7Û64Þ63ß55Ü30Ú2/Û62à>9Û>7Ø;4×:3Û81ß82å95ç:6é9;ê7:ë7:î79î79ì65å31ß2,Ü3,Ý6-ß7,â6,å2+ê1,ò1,õ20÷12÷03ú/2ù.1÷//ó0.ì3.å7.ß<3Ô=2Â8.¶1*·74ØZ[ÿ“ûs}ÿfzÿ^vùWo÷OiùFfû?bü^QA^QA^QA^QA_RB`SCaTD`SC_RB`SCaTDaTD`SC^PCbUM\QM[QRcYbkdtqm„vu•y{¤y{¬y~¶x|»nsµei°`g¯jn¸ruÆ}}ׇ„Ý—”Û©§Ø»¹ÏËÊÈÜØ¿åá´éäªíè¦ðé¥íå¤çá§âÛ§×Ï¡ËÃœ¸¯©››ƒk¨ƒp§o`œRGº]UÝmi÷uuï__äJLå@DëADì>@è8:â66ß=:Ô;6ÔA:Â70·7,·>3®=/¶F8Ûj\ßi[Ù[MÊB6Å2(Ñ4+Ù6-Ù2,Þ52éA>ìGCà=6Õ2)Õ1'Ú2'Þ0%æ4*è1)ç.)æ/)ã2,â7/á=4àB9Æ-(Ê43ÜDCðVXú^b÷ZaóS[ñQ[èFQêHSïOYü\fÿmvÿntôY_ã>Dé.5ô-4û2<ü2>õ+9í'4ö6EÿKW÷ISõPWøW_þ^fÿckÿ`i÷RYéBIÞ97Þ71ã75é<8ë;;æ95á51Ý60Ý:3Ù;2×90×90Ü71á83ç:6é<8ã99ã99å97ç98è88æ74á40Û2+Ú6-Û7-Þ8,â6,ç2)ë0)ó0,÷10õ12õ13ø02÷/1÷//ò0.î3.ç6.Ý90ÜD9Ç80»4.µ/.ä_bÿƒˆølwþbxþWsúPmþLlÿCfö:]ó;_ìIfÔSgDJl;4O>,=<':?(ED/FH0Q\U'B\/E_2Ic6WJ:ZM=\O?^QA]P@^QA_RBaTD`SC`SC`SCaTDaTD`SC_RB\PDZOMZQVbXcjcsqm†vu•xz£z|­w|´sy·mr´bi¯]d¬ag±lr¾x{ʉ‰ß•‘夡䶵áÇÄÙÕÑÎáÝÄçä¹ëæ¯îê­îè¬éâ«ãÛªÚÓ©Ë¡»¶™¥¥›™„“ˆv˜q™rc›bW³i`Ïrmû‹‰õutê[]æLNèCGí@Dìô@?ï=;æ95à72Ý82Ú91Ù80Ù80Ü71ã73è96é:7â:7à;9ã:7æ:8ç:6å84à5.Ú3+Ú6,Û7-Þ8,â6,ç2)ë0)ò/+ö0/ô22ô23÷12ö01ö0/ò0.î3.ç6.Ü8/àF<É91¾3.¶,,îfjÿy€øgtÿbyýTqþKkÿGjÿ>cò6Yë=^ãQhÄXeˆBBgC7[N;GF1AC-JH3EE-LU6Sc>btLlƒUp‹XnRkPiŽKgIhJh‘Kj“Mk”Pm–To–Wp—Vt›Xs›Uq™So—Pj“MgJeŽHdG`‡D]AWy=Rq8Mi6Lf6Ne7Of8Lf7Oi9Sm>UH8WJ:[N>\O?]P@]P@_RBaTD_RB`SCaTDaTD`SC_RB_RB^QIVMR_Xhnf{tp‰xt—xw¡xz«y{´sy·jr³`g­[c«_g°jr»v|Æ€„Γ•àžžä­®ç»½æËÉßÔÓØÝÛÎáßÆåá¾æâ¼äß¹à׶ÚеÎƱ¾µ¦­§›˜šŒŒŽ€‰…yŠ|q‘vk›si¨meºoi扄î~ósrñedñWYðMNîDEì@@ã:7à;7äB=ÞE?Ì<3Æ=3ÄB5¯1#®0"ÇI;ÜXKÖN@Ì=/Î8*Ð6*Ñ3*Ö42õUUÿkhú]XãD>Ü;3ß;2ã80â4-ã2,â1+Ý0)Ô0'Í/$Æ/$Â0#Å9,À4'Á3)Ë:5×CAÛEGÛBGÚ@HàDOëOZòVaòVaú^iÿgoóYaáBGê:<í57í38ï28ñ3=÷9CÿHSÿV_ä6?Ý4;ß6;ëADùJOüIMô;Aé13è51ë95ï<8ò<9ó;9ð:7é73â70ß;2Ü;1Û:0Ü90ß82ä73è64é75æ:8ä;8æ:8è:9è;7æ95á6/Ü3,Û7-Ü8.ß9-á7*å3)é1)ñ0)ô1-ó32ñ33ô22ô01ô1/ò0.î3.ç6.Þ7/àC:Ê70À1-À13÷jpÿqzúftû]túPmÿCfÿ=dÿ9cõ8^æEdÙZm«V[wE>dJ=aYFTO;KI4PI6GE.GP3L\8ZlFf|Nm…SmŠRlŒMhJfŽHgHg‘Ii’Lj“Ol•Sn•Vo–Ut™Vs˜Un•Rj’LfKcŒHaŠF_ˆFZBX|?St;Pn8Ok:Rl=Wn@ZqCUo?Vq>WqARE5UH8XK;ZM=[N>\O?^QA`SC`SCaTDaTDaTD`SC`SCbUEaVP^Vcje|yu}yšzy¡xy©vy°sw´jr³cj°[c«]e®hp¹v~LJшŒÓ™Ý£¥à¯³ã»¿åÆÇãÏÎÞÔÓØ×ÖÑÙ×ËÙÖÇ×ÑÅÒÉÀÌþŹ¹´¨¬£šŠ‹†x{tyvquleleogŽa[`[ÀsmØyuð{ü|yÿrpýccöSTðHGïC?ê>:á<6àA;Ñ:1ÓC:ÝTJÂ>2¸6)½9,Â=.È?/ÏB1×C5Ö@1Ñ7-Ð2/êLMú_]òWSßD?Ù:4Û81à70æ93ç92ç92â:1Ú9/Ñ9,Ê8+Ä8)°(¸3"È@2ÓI>ÒD@Ë;:Ì7;Ï:@Ñ7AâHRíV_ðYbõ^g÷`iêU[ÜAEå@>ì?;ñACúGJÿLTÿQYÿT]ÿV^á4:Ú/5Ü/3ç7:ô=Aø;?÷48ó12í42ï95ð86í42ë20ê20ç40á4.ã<4à=4ß<3Þ;2á83ä73è43è43è88ç98è88ë99ë97é75â5/Þ3,Û7-Ü8,Ý:+ß7*ã2(ç0(ï0(ò1,ñ42ð43ó32ó11ó1/ñ1.ì3.ç6.à91Ù<3Ì71Á0-Ñ@CÿnuýkuùbqðRiõHfÿ;aÿ4^ÿ6bû>däNiÊ\i‹GFjF:]L<]VCXQ>RJ7OG4ID.DJ.GU2Sc>^sHgMj‡OjŠKgŒGgŒFfŽGfHgJi’Nk”Rm”Um”Uq•Uo”Qj‘NgŽKcŒH`‰E_ˆF^†G\‚E[~DWxAVr?Uo@YpB]rG^uG[sCYtAXs@NB2QE5UI9WK;XL\P@^RBaUEbVFbVFaUE_SCaUEfZJh]YngwupŽ|x™{y wx¦vw­pu¯jo¯ah¬^f®_g°em¶pxÀ}…ؙ͉ؗ Ö¡¨Öª±Û´¹ßº¿ßÀÁÝÃÃÛÇÆØÆÃÔÅÁÐÁ»É¼³Ä»°Áµ¨¼¦˜¯–‹œˆ…Œqqqtpopfewhe†nj„_Y•d_›ZT¹f`Ùsnðzvÿ{wÿwsÿhfüZWþRNõHBæ=6çD=Ø;4ÛG=ê\RÅ;0Ä<0½7+¾6(Ç>.ÑD3ÔB3ÔA1×A3Ò86Ø>>ÝCCÜB@Ö=7Õ81Ø7/Þ7/å:3æ93å:3â;3Û>5ÕA5ÑE8ÌG6®-¼;%ÍJ8ÑL=Æ=5»0+À00Ê9>×AJáKTëU`ðZeð]eìYaßLRÔ>@Ï4/Ø7/à;9ê@@òCHõDJñBIî?Fâ5;ß26ã36ï8<õ79ø14û/2ü14ï20ð95ð74ì0.è,*ç0,æ3.à3,ä=5à=4à=4à<3ã:5æ95ê65ì65ì57ì57í57î68î66ë54ä2.Þ1+Þ7.Ý9-Ý:+ß7*á4&æ1&í1(ñ1,ð42î53ñ42ò21ó1/ñ1.ì3.ç6.â;3Ò4+Ò:5Æ20çUXÿpxùcnòZiçI`óEfÿ8bÿ/]ÿ5bÿBhÜLe±PYj5/^G7XK:UN;[P>VI8M@0JC0@F,AO.K[6Xj@bxGfJhˆIf‹FeŠDc‹BcEeŽHgLh‘Oi‘Rk’Sn’RlPhNd‹JaŠH_ˆF_‡H_‡H_…H_‚H]~G]yF]wH`wKcxOczN]uC[vAZu@JC3MF6QH9TK.ÑE6Ë>-Á2"Ê7'ÛE7ÞE?Ó97Ì3.Í50Ô;5×=5Ý<4á=4ä;4ä92Þ5.×4+Ï5)Ê8+Å<,Â?-ÔS>ÈG2½<)¾:-Ã=2Ä;5Â74Â43ÜKNÞMRáPUåTYèY]åVXÜMOÓD@É5+Ñ7+Ø7/Ý52â24å26æ18æ.6ì4>ì3;ó5?û9Bý4>ú+5ÿ(3ÿ/9ø-3ù57ù59ð./ë*+é0.è51â5/ã<4à=4à=4á=4ä;6ç:6ë76î66ì46ë35ì25í34í55ê41ã1-Û0(Þ8,Ý:+Ý:+Þ8(à4&ã3$é3&ì4*î50î52ð42ð3/ò2/ï2,ì4,ç6.ä=4Í/&×>9Ì35ùbgÿoy÷[iðNcêC]ùEhÿ:eÿ0]ÿ6aöGhÉJ]“CFR,#VI8SL:OH6[O?UI9F?-HF1>B'@J(IU1Sd:_rEe}Ig„JeˆHcˆCa‰BbŠCcEeŽHfMhPiQlPkMfJcŠIaˆG`‡F`‡H`†I^G^F_}G`|Ia{Kd{Mf|Nf~N]xC]z@^{CDB6FD8JF;PG>RH>WI>]M>_O?`Q>aR?`SB_VGbYRgb_ojnso~wq“zt |y¨yw©pp¦gg£`a¢\_¤`b­fhµopÀyzÌ„‚Ö‹ß–’眙栞ݡ¡×££Ù¤¤Ú¦£Ø¥¢×¥¡Ô¤ Ó¥žÑ£Í¢šÉ¢™ÈŸ–Ù»Ž‚°ƒ|žrn}igld^`fZZkYUrWP}WNŒWO•RI¨ZPµXPÁZSØkdìyrù‚|ÿ‹†ùuqÿusí_]ßPLÙEAïZTÌ71Å2*Ä6*Ã7(À7'Ã7&Æ9(Ê;+Ð<.Õ?1Ò8.Ö<2×?4Ó;0Í5(Í3'Ø:/â@5à90á90Þ7.×7+Ï7)É:*Æ?,ÄA/Â=.Æ@4ËE:ÍG<ÌC;Å<4»2,¶+&Ç<7ÐEBÙOLàVSãYVáXRØOIÐC:Ì;*Ó:(Ü8,â5.è./ì*2ð(3ô'6ú->ú+?û*?ý)?ÿ(?ÿ&?ÿ$<ÿ$<ÿ$8ÿ'9ÿ+<þ,9ó+5í.5è45ç;9Ý84Ý:3Þ;4à;5ã:5æ95é73ë54ë35ì46ë54é54ç53â5/Ý5,Û5)Ü8,Û9*Ü9(Þ9&ß8&â7%ã6%æ4&ì5-í4/ð50ñ4.ñ5,í5+ê5*å7,à90Ø7/Õ:6Û?BÿmwÿbsûSjõIcÿKjö6[ÿ6_ÿcçNj¯IV^$"D, ?:'HE4PMC/?G/BH&EK%KS.S]8[kDavKd~NdƒJb†F`ˆBa‰@c‹BeFhJlPm‘Ql‘LiŽHgŒGf‹HfŠJe‰Ic…HaƒGdƒJdIbGc~GdJdHe~Ga}C[{<\=_‚B=?4?A6FC[K>]M=`O;`Q<^SA^VIc[Xhcinlyso†tp•vpžtp¢pm¢gfŸaaŸ]^¡\\¤ed°kjºtrÅ}{φ‚Ù‰à”Žæ˜“å›–Ùœ˜Õ™Öžš×ž˜Ö—Õœ–Ô›•Ñž–Ñœ”Íœ“Ê›’ǚē‰»ˆ®‚xtk|mdif]^f[YiZSoWM{UJŠVKšVK°\RºYRÁXRÓfaàqjãvoí~wý‡…ÿ‡…÷usîgdãUSëZUÇ2,Â/%Å7)Ã7&À7%Á8&Ä8'È;*Ï;-Ó=/Õ9,Õ9,Ó:,Ò:,Ñ9+Ñ9+Ô8+Ø8,ß;1à90Ü8.Ö8,Ï9*È9(Á:&¾9&¾6*Á80Æ=5É@8ÊA9È?7Å<4Â91¿4-Ç>6ÑH@ØOGÚQI×NFÌC;Ã7*Ê7%Ó8$Ý7)å4,í//ô+3ù)7ý(:ÿ+@ÿ*Aÿ)Aÿ&Aÿ#@ÿ!<ÿ=ÿ:ÿ:ÿ 9ÿ%;ÿ);÷-9ð19ê7:å;;Ü94Ü:5Þ;4à;5ã:5æ95é73ë52ë35ì46ë54è64ä71ß6/Ü5,Ù5)Û9*Û9*Ü9(Ü9&Þ9&ß8%á8%ã6%ç5+ê3+ë4,ë5*ë5*ê6(ä7)á7*ß;1Õ4,Ó54óTYÿesÿ[põGbÿIhÿAdÿ;`ý3[ù;aòMmÍLb‰8?S*$A5'69(;<,B@1DA0@?-=B.>G,=CKP'\b_„?b‡B69.:<1??7DA:KB;OE/Ô>/Î6(Ë/"Ú:.Ú8-Ù7,Ö8,Ð:+É:)Â9&¾7$½5)À6,Â8.Ä:0Ç=3Ê@6ËA7ÌB8Ç:1Ê@6ÏE;ÐF<ÒH>ÑG=Ê@6Å7+Ì6%Ö6&ß7,ç4/ñ03ö-5û+9ÿ*<ü';ü'=û%=ù#;û!:ú7ü7þ6ÿ8ÿ6ÿ$8ý*;÷2<ñ6=ë8;ä::Ü94Ü:5Þ;4à;5å95ç85é73ë52í36î47í55ê65å61á6/Ü5,Ø4(Ú8)Ù9)Ú9'Û8%Ý8%Þ7$à7$á6%á5'â4)ã5*ã6(ã6(á7(Þ6)Û7+Ý<2Ð1+Ø88ÿkrÿ]nþPiñ<[ÿHlÿ7]ÿ>eù5[î>bæVqª?Qa#(L/);7+07'37&9<)@=*A<(@>)BB&?FXa4s~T€Œdw‡`hSa}La€G`ƒC`…?a‰@cŒ@hŽEjJkMl‘Nn“Mk‘HhHgŒGh‹Kh‹KfˆLd†Je„KdƒJc€FdGf‚Hf‚GeFb€Bc†DeŠEhH25*58-;<4A>7G@:KB;RE.Ñ>.Ë8(Ç/!Ò6)Ó5)Ò4(Ò6)Ñ9+Í<+È=*Ä;)Ä:-Ä:/Æ90Æ9/Ç:1È;1É<3Ë=3ÓD<ÓE;ÐA9Ë=3Ë<4ÏA7Ï@8Î;1Î5'Ù5)â5.ë31ò/5÷+6ù)7ü):ù&9÷&;÷&;ø'<û&<ý%:ÿ$:ÿ#:ÿ"7þ#7ú%7ù,;÷5>ò9?è8:à87Ü94Ü:5Þ;4à;5å95ç85é73ë54î47î47î66ê65æ72á6/Ü5,×5*Ø8*Ø8(Ø8(Ù8&Ú7&Ü7$Ý6$Ý6$Û5%Ü6(Ý7'Ü9(Ü9(Û:(Ù9)×:+×:1Ð3.ëHKÿoyÿVjøD_ø<_ÿAgÿ3\ÿ8bø>cèMlÅOe€0=J C1-11'.6'4=,=B.B@+B<$E>$HE$U\0p~MŸr—¨|ƒ˜mj„W_{J]~E_ƒCa†@bŠAfCkJl‘Lm’Om’Oo”Nl’IiŽIhHiŒLiŒLhŠNg‰Mf…LdƒJdGe‚HgƒHh„If‚Gd‚DgŠHiŽIl‘L-3'36+891<;6B=9G@:MD=QG=SI=SK>UNDZUQa^eigumklkŠjhb`XVˆPP†QQXYš`cªfj´orÁuxÉ|Ђ…Ö†‡Ù‡ˆØŠ‰Ù‹ŠÖ‹ŒÏ‹ŠÌŠ‰Í‰‡Ð‰…ш„ÑŠƒÑ‰‚ÐŒ„Ï‹„È…Á†º†°‡¥~w–m…„Yj€SZnVTc\RZaOZ_HeZDxUB’LD¸TRÐSWÛRYå^dèejãklæuqäunâoh÷~vÿ‚{ÿ‡~ôl`É?2Á8(À;(¿='¿='À<'Â;'Å:'Ç8(Í7)Ø:/Ù8.Ò8,Ï9+Ì:+É:*È9)É7(Ï9+Ñ7+Ò8,Ñ7+Ï7*Ì8*Ë<,Ë>-Ê<0É=0Ê<2É;/È:0Æ8,Å7-Å5*Ð@7Ð@5Í=4É9.Ë80Î;1Í:2Ì5,Ð/%Ù0)ä20ì25ô/8ù-9û+;ü,<ü-?û.?ü/@ü/@þ/Aÿ/?ÿ-?ÿ.@ÿ)9ü)8÷+7õ0:ñ6=í8=ã77Ü43Ü94Ü:5Þ;6â:7å95ç85ê65ì44ñ48ñ48ï56í76æ72á6/Ú6,×5*Ø8*Ö9(Ö9(Ø9&Ø9&Ù8&Ú7&Ù8&Õ8%Õ:&Ö;'Õ=(Ô=(Ô=*Ô=,Ô<.Ñ7/Ú;8ÿ^eÿaqÿPi÷<[ÿAiÿ4_ÿ4`û1YôKlÛYq•>NZ%-C),:2/-0)08+7@/:B+<<"A<UH(`[5{…S£lª¾‹¨¾Ž¥wo‹[aK^F`„DcˆBeDj“Go”Np•Po“So“So”Nl’IiŽIgŒGiŒLiŒLi‹OhŠNf…Je„IdƒHe„Ig…Ih†Hg…Ge…DiŽIi‘Kl”N+1%.4*470893>:7B=:HA;KD1Î8*È4&Ê8)Ë<,É:,È:,É;/É;-Ê:/È9+È5+Ç5(Ê6,Ï;/Ò>4Ó?3Ö?6Õ>3Î7.É,#Ò+%Ü-*ç02ð39ö1;ú0<ý0?ý0?ù0@÷1@÷1@ö0=÷/<÷-9ú,9ú*7ý/<ù/;õ0:ð3:í6;æ69ß55Ù42Ü94Ý:5ß:6â:7å95ç85ê65ì44ò59ò59ð67í76æ74ß6/Ú6-Ö6*Õ7+Ô8)Ô8)Ô9'Õ8'Õ8%×7'Ô9%Ð9$Î<%Ï=&Ï?'Î@(Î@*Ð?.Ò;0Ñ61ëHIÿfrÿOdÿHfû7[ÿAmý/]ÿ7aò4XãPj¼Ufm19E(*E697325406906=-3;#38CCja:…TŸ®w©Á‡µÎ—¯Ç“’®}v”be†Q`‚F`…BcˆBgFm–Jr˜Or—Rq•Up”To”Nl‘KhHf‹Fh‹KiŒLi‹Ni‹Og†Kf…Je„If…IhˆIi‰Hi‡Gf†CjJk“Mn–P(0#+1'/4-350764<85@=8C>8IEù4>ù1>ú0@ø/?ò.<ï/<í/9í07ï-5ï,2ò+2ñ*1õ2:õ3;ò5;ì59å57á55Þ65Ü75Ü86Ý97ß:6ã:7æ87é77ê67ì46ô5:ô5:ñ7:î87æ74à70Ú6-Ô6*Ó7*Ñ8*Ð8*Ð9(Ð9(Ð9&Ñ8(Ð9&Ë9"È:"È>$Ç?%È@(È@*Ì=-Ï;1×96üU\ÿ^qÿGcÿ?aÿ:aÿ7gþ3bû8`íFdÅNa‰@IS12A64@:<:46?56<7179+4="9CSZ.‚‚P¢§q±ÅŠ¯ËŽ°Ì’¦Ã’®}{™egˆQ_E^ƒ@c‰@iDo•Js™Ps˜Sq•Uo“Sn“NkJgŒGeŠEgŠJh‹Ki‹Ni‹NfˆKd†Id†IeˆHgŠJh‹Ii‰Hf‰Ej’Ll–No™Q&.!(0%-2+13.331764:95<;6GD=DD*¾;'¼7$À4#ÑB2ãOAäN@ØB4Ë7)Ë7)Ð>/Ê;+É:*Ç8(Æ7'È6'Ê6(Î8*Ð8+Ó;.Õ;/Õ9-Ò6*Õ7,Ú<1Ý<2Ü71è88ñ8=÷:Aû9Bú4Aõ/<ò,;ï,:í/;ê19ê38ë48í57ñ56ô36ó57ð37ï6;í9<é69â45Ý33ß76à;9Ý86Þ97á96ã:7æ87é77ê67ì46ô5:ô5:ñ7:ì89æ95ß82Ø7/Ó7+Ð8+Í:*Í9+Ì;*Í:*Í:(Í:*Ì;(Å9"Â:"Ã=$Â>%Ã?(Æ?+Ê<.Ï81ß<89?48E26C41=:)>E&FU*bs?›a­½±ËŒ«É‹¦Ã‹º„Ž¬z{™ef‡PZ|@^?a‡>hŽCo•Jr˜Or—Rp”Tn’Rn“NjIf‹Fd‰Df‰Ih‹Ki‹Ni‹NfˆKe‡Jd‡GeˆFgŠHh‹Gh‹GeŠDk“Lm—OpšR(0!'/"(-&).(.0-3317839:4==5?@8DE@JLKORYVXeZ\s]^}YX‚[Y‹^]–ee£nn¶wxÈØ„…⌌ðŠŠì†‡ä‚‚Ü€€Ö‚€Óƒ‚΀ƒÈ„ǃƒË„„ΆƒÐˆƒÓ‹„ÒŒ„ÏŠ€ÅŠ€¼‰€¯‡}Ÿ€xwozkegf]Xm[Qm[Mi\Lf^Kd_IeaHhaGo_FoP;…UA¥]O¿aYÑYXÝQTîS[ø\`ùheæYPÔD<Î70Ñ7/×:1Ö=/Ô;+Ï9(Í:&Ï9(Ñ:)Ô8)Ø8*Ü5,Ü5,Ð/%Í3)Ì8,Ê>/Å@/Á@-¾=*¼9'Â9)¾0"éWJßK?Ã/#Ñ=1Î2Ü<0Ù7,Ú8-â>4ìC<õBEò9?ð2<ö4?ö2@ñ-;í-:í2=ì7>æ5;ä68å78ë99ð:9ñ78ï77ò;=î<<ê::æ87á85ß74Ü75Ü75Þ97á98ã99æ::é9;ì9<í9<ï8<ô7;ó6:ð8:í9:ç;9à;5×90Ï7,Ê8+È9)Ç9+Æ:)Ç:)Ç:(È;*Ç<)Á9#Ä='¾:#¶4¼9%ÉD3Ï?6Ê1,ÿ^eÿVgÿIbÿ<\ø1X÷0Yû6cõBiçYo¬FQo33N3,B?6>C<@78@-1L/3K2.A9&DJ(Zn=~š_ž¸w¨Å‚¬ÊŒŸ¾‚˜¶€”²~‚ nf„RXvBY{?]€>c‡AiDn”Im•Ll”Nk’Ol‘NiŽIfŠDc†Bc†Bf‰Ih‹KfŠLdˆJg‹MhŒNg‹Kf‹HeŠEf‹EjIk“Jq›QržSt U*0")/#).').(-/,130561782;<4>?7AD=HJGOPTSUaXYkZ\u\Z^]‰db”kj¤utº~·‡ß‹Œéð‰‰ë…„ ؀~Ҁς‚Ì…†É†‡È‡ˆË‰ˆÎ‹ˆÏŒ†Î†ÌŽ…ÈŠ€¼‰±†|¡‚x‘{s€tknlb`e]Re`Me^Kf^Kh]Ki\Ij^Hk_Gn^Ew_G[C’YF­ZLÇVPÞRSõQXÿX_ðUSãLEÙ>9Õ60Ù6/Ü90Û9,Ö9(Ó8&Ñ8&Ñ8(Ô8)×7)Ü6*ß4,Ý5,Î0'É5)È9+Æ=-ÄA/Á@-¿<*¾9(Ä8)Ë<.äREÜH<È4(Ì:-È:,Â4&Ê=,Ë<+Ê;*Ê;*Ë:)Ì9)Î8)Ï6(Ó7*Ö8,Ù7,×3)Õ1'Ø1(Þ7.ç<5øDGñ8>í/9ï/:ð0=î.;ë1<ë6?ä5:Ü36Ø22ß:8îEBøIFøDCó?>é:7ç98å97â96á85à85á98á98à87â88å99ç9:é9;ì9<í9<î7;ó6:ò59î68ê88ä;8Ü:5Ó9/Ë7+Æ8*Ã:*Â:*À;*À;*Á<)Á<+Á<)½9$Á?)»:%³5¹:'Á;/Ê:2Ø<=ÿ^gÿPdÿA[ù8Wö6[õ;`ô>dãIe«?Lƒ?>_:2G;/:>08>2F<:R>=N0.S8/VK5ciEx[°pÂ}¡Æš¹}š¹€š¶ƒ©xrŽ^YuETp=\{B_@b†@iCm“Hl”Kk“LiMiMgŒGe‰Cc†Bc†DgŠJiŒLhŒNg‹MiOiMiŽKgŒGgŒFfŽEl’Im•LpœQoRt U-1"-1#,/&,.)//-11/34/45-9;0<>1@B7EHAKMLQRWUUaVWi\Yt^]fdŒpn zx·…ƒÎ‹ßêŽïŽŒíŠ‰ç‡„ßÓ|Ë}ȀƅLjˆÆŠŠÊŒŠÉŒŠÉŒˆÅŒ„¿‹‚·‰€­†|¡€v{p€ujpndbi_Vc]M_aL_aKc^Jg\Jl[In\Ho]Gq]EwaIxX?‡S=£VDÇXOãUSøOTþMSâ><Þ<7Ý84Þ71á6/á6.Ý7+Ú7(Ô7&Ó8$Ó8&Õ8'Ø6)Ý5*à3,Ý5,Ë3(Ä6(Â9)Á<+Â?-Â?-Á<+À8(Ã5'ÜJ=ÚF:ÕA5Îå84â62à72à72à72á85â96ä;8ä;8á77ä88æ8:è8;ë8<ë8<ë8<ì8;ï58î47ì57ç77â:7Ù:4Ï8/Ç7,Â8+¿:+½;+»<+»<+»<)»<+»<)¸9&½@*³9$±6$¶;+µ0'Ã40ìPTÿ[iÿJ`õ:Uð7Vñ@]ïHfçHdÍNa‚89e?6R@2DA09=,57)>6+K9/E-#R=,g]Bˆ_’«t—»{–Áz–¿{”³xœ¸…š´…€šm\uKHb5Nh8[xB_}?cƒ@hŒDl’Gj’Ih’JgLfKd‰Dd‡Cc†DeˆFh‹KkŽNkOjŽNiOiOiMhJgHh’Hl”Ko™Ms¡Vs£Wv¤Y24&04&01)01+12-23.34.46+9;-;>-?A3DF9IJDMONRQWSS]XVd\Zoda~nl”zw¬„‚ÃŒ‰Ö‘㔑ê“뎋≅قÌ|Ã|¿€~½„‚Á†…Á‰ˆÂŠÃ‹ˆ¿‰…¸‡®…}¤…{€vŽyn~rgmmaak^Vi[Pc\J]`K]aJc^Jh[JmZKqZJtZIv[FsWAxR;ŠQ=ªYFÍ[PãTPðFIñ>AÛ2/Ü5/á51ã60ã5.á5+à6)Û8)Ö7$Ó8$Ñ8&Ô9'Ø6)Ü6*à3,Ú6-È6)½8'¼7&½:(¿>+Â?-Ã;+Ä8)Æ4'éUIÓ<1Ì8,ÑB4¾5%À=+À=+À8(Ä8'Å9(Ç:)È9)Ë7)Ì6(Í3'Ò6*Ô3)Õ2)Û4,ã:3é>7ì?9ì=:è45ì59ï6;î5;ê2:æ39ä7=â<@óUVübbÿmjÿidóVQäA<ß63Ý4/ß61Þ71Þ71ß82á85â96å97æ:8å78æ89è8;é9<ë8<ë8<ë8<ì7<î5:î68ê67å97ß<7Ö<4Ì9/Å9,¾9*º;*¶;)µ<)µ<+´=)³;*³<(³:'·@,­8&­8'³;-«+"Ã54ý`gÿTdúG\ð-=@-@C.DG4IK>MNFQPNRRRVUSYX]a_lkius›€}²ˆ†ÇŒŠÓ•’ᔑâÜ‹‡Ó„Ä}º|µ|³~·„º‡„¹‰…·Š„²†¨z›€xs‡znzrfjm_^j[Ti[PjZKfZJb_Lb_Le^Li\Kn[Lr[Kw\K{ZG~UA†R=›RA¶VFÎRHÚG@â88å33Ý1-ß3/â5/ã5.á3,ß3)Ý5(Ü9(Ó8$Ð9$Ï:&Ñ:'Ô8)Ù7*Ý5,Ø7-Ä;+¹:)µ6%·8'½;+Â=.Ç;.Ç7,Ð90õ\TÖ=5É5+ÏA5¸3$·:(¼?+¿:)Ã:*Æ:+È:,Ê;-Ì:-Ï8-Ñ7-Ð3*Ò1)Ö1+Þ71å<7ê>:è;7æ74é75ï;<ðë8>è7=ê7;î7;î79ê7:ä::ß=:Ö=7Ë;2Ã;/º8*µ:*³;*¯<)¯<*¬<(¬;)¬;)ª;(¬=*¦8'§9*ª8-¬/)Ë@CÿhrôM^óH[íDYåH[ÙO^ÉT]·TWœXUdM?OL9LG4JE1FD-?B'=D#>H#KV.\g.==1==3==5;<4;=2;=/?B/@D-CG.FJ3KL:NOAQQIRRHYWJZZN_^\gerqn‰{y¡ƒ€·‡…Čьӊϊ…ǃº~y¯zw¦yv¥{v¬|y®€|®ƒ}©ƒ}£x—|t‹zrvksrffm_\j\Sk[NlZLl[Kk[Ki]Mg^Mi]Mj]Mn]Ms^Mz]MZI“`O›VG§N@¸J=Å@7Ï6.Ø1+Þ1+á51á6/â5.â4-à2)Þ4'Ü6&Ú;(Ñ9$Í;$Ì;&Î;'Ñ:)Õ9*Ù7,Ó9-Á>,´;(°5#²5#»9)Ä<.É;/Ë7-Ù?7ø[TãIAÎ:0Ì@3¸6&¬3 µ<)¼9'¿7'À7'Ã7(Å7)É7*Î7,Ñ7-Ù<3Û:2Þ93å<7ê>:ê=9ç85ã41è96ë<9ì::è8:ì>@øPPÿbcÿppùheâTPÊ=6À1+É40Ö;7ß=:à;7â;5á:2â94á83ã73ä73å55æ66é69é69ê7;ë8<ë8>ê7=è7=é6:ï8<ì89è8:ã;:Ý>:Ó>7É<2À8ÛTXûepîK\ïI]éJ\ÛM[ÉQZ´VV ZRŠ`RPI7HM9NI5H@+;567>O%Lf6lŠTw”\„›e‰šd›f£k”­t˜°|ƒ•mn}\Q`Cg{HiƒFl‹Gm‘Gj“Gf’GbGcŽGhJlMo’Pn“PlMiŽKjJj’Ls›TsUsSržQržOs¢Rw¦Uz«Zv¦Zu¥[s£YRK;RK;RJ=RJ=RJ=RJ=RJ=RK;UNXQ?YR@[TD\UE\UEb[HaZHaYLbYRe][kaiqftuj{zn„|pˆs‹s‰|p„uj{mbre]jc`k`_g_\c_Z^^ZY^YUaZRbZOe[Og[Ki\Kk\Ik\Gm]Fm]Fj^HicMqfTqZJuOB‹WJœ\P£YL¬ZL¥N=¦E4§<,±7(Â8-Ñ80Ü41Ý1-ß6/Þ7.Þ7.Þ7.Þ7.Û7+Ø6)×7)Õ8)Ô8)Ò9)Ò9)Ò9+Ò9+Ô8+Í;,½;+¶>-®9(©1 «2!·9*ÀÔH9Â=,·2#ÝPFØJ@ÔF<ÔD;ÚG?ÞG@àC>à<:à74æ87ì::ì::ç77â64à93Ü=7ÙF>ÏB9Ä:/¼4(·1&¹5)¿;/Ã?3Ã:0É<3Ò?7Ú?:â=;ç;9ì89í9:ç7:å8:å8:å99å97å97å95å95à40á51ä65å76æ89ç9:ç9:ç9;ë;>æ9;ß99Ü=:ÖA=ÍB;ÁA6·?1©:)£<+ =*›<(™:&–:%—8&‘8&A0‹<-‡/#‘/&¼LJämoçloÍVZ½LNµNOªQM¢UO›XO—]R•aTŠjSWZ/:M7FTa)~ŽP›°oŸ¼yœ½x’µs~ah€L\mCYdBT]BHP9?D0:=,@C2<@1:>0]sBgƒHpKo“Kl’Gj’Ii“KgJlPm‘So“Sl“Pm’Mk“Jm–Jm˜IqœLqžMrŸNr¡Pt£Rv§UyªYzª^y¦cm™ZbŽOWN?WN?WN?WN?WN?WN?WN?WN?XO@YPAYPA[RC\SD]TE^UF_VGd[JcZIcYMcYOf[Uj_]nbdpdhreltgpvirvirsfmm`gg[_bXY^[VZZRYVOWTKXTIXTH\VH^WGcZKcZIf[Ig\Hi]Gj^Fk_Gh`IcbMngTv\MSFšVM«VO°RJ·QE¯H9¬C0¬=,±9)¾8,Ë80Õ62Ù40Ý6.Ü8.Ü8.Ü8.Û7-Ú8-Ù7,×7+×7+Õ7+Õ7+Õ7+Ô8+Ô8+Ô8+Î:,¾<.¶>.®9(¦1 §2 ²:)¹>.¾<.Æ:-Ç4*Ë4)Ò;0ÜE:áOBßQCÝOCÛF?Ø@;Ó<5Ò;4Ö=7Ú=8Ü86Ý33ç77ë78î79ë78ç77å97â=9ÛB:ÊA7¿?4¸:,±6'¯5&²8)¸=-¿@1ÅA4Í@6×@7ß=8ã:7é77ï56ñ7:é6:ç6<ç7:æ89æ87å95å95ã:5â92ã:3ã:5ä;6ä;8ä;8å99å99ä:;ã;;ß<=Ù?=ÐA;Ä?6·=2¬;-¥;+ =*œ=+—<)–;(’:&“8%Œ:%€9'€8)‰5*<5¿QP×eeÑ^a·MM¬NL¤TMYP˜\Q—^S—^S˜_VŒfQ`_/Sg*^r3zO™¯n¥¾|™²pˆ bj‚HauBTe;JX7FP7?H59?158-:^tEgƒHqMp”Ln’Hk”Hk“Lh‘Km‘Qn’Tm”Sm”Qk“Lk”Hl—Hm˜HpJpJp Ls¢Qu¦Tx©Xx©Xx¨^m—Xb‹QY‚H]TE]TE]TE]TE]TE]TE]TE]TE[RC\SD]TE^UF_VG`WHaXIaXGe]Je]Hd[Jd[Le[Qf[Uh]Yh][i]]j^^k__k__i^\f[YbWS_VQZVMWTKUQHRNCQMBSOCWQCXRB^WG^WEaYFc[Fg\Hi^Hk`JhbLbaMngUy_PˆXN¢[U±VQ²IE¸E@¹@7¸>1·;/¸8+¼8+Ã9,É;/Ñ:/Ù8.Û7-Û7-Û9.Ú8-Ù7,Ù7,×7+×7+Õ7+Õ7+Ô8+Ô8+Ô8+Ò9+Í;,À>0¶>.­:(£2 £3ª:&³>,¹>.Ä?0Ä8+Å2(È4*Ð<0ØF9ÜM?âNDÙ:6Ø43Ô20Ö42Û97á=<æ<<é;<í9<î5:ë27é26è58å99á<:Ù@:¾8-µ:+±6'®4%­5%°8(µ<+»=.ÈD5ÏC6ÖB8Ü=7â94è64í55ï79ê69é69é69ç77ç77æ95å95å:3ã:3ä;4ä;6ã<6ã;8â:9á99Þ88Ý9:Ü<<Ú@>ÓB=È?9¹:1­7+¥7(¡;,<+™<+”;)“:(9&7%Š9&z6#y6%ˆ9, F=¹SOÀWT¸PO«IF¢MHœSL™YP—^S—aW—aW˜_V‹ePsrFzV“¦n¤¹€«À‡ž³{|[[oaXIaXIaXIaXIaXIaXIaXIaXI_VG`WH`WHaXIbYJcZKd[Ld[Je]Hf^Gf^Ig_Lg^Of\Pf\Rf\Sh]Wh]Wh]Wh^Ug]Te[QdZPc[N]YMZVJVRFRNBPL@PM>TN@UO?WQAYTA[VC]XDaZGd]Jf_LfaMdcQleUv\OŠ[Q©b\¸ZX¶FD¹<:Ã<8Æ;6Ä:0Â8-½8)¼:*¾?.Ç?/Ó9-Ù7,Ú8-Ù9-Ú8-Ø8,Ø8,Õ7+Õ7+Ô8+Ô8+Ô8+Ô8+Ô8+Ò9+Í;,Á?1¶>.¬9'¢3 3¢8"¬=)µ@.¼?-¿:+Ã7*Å5*Ë7+Î:.Îî7<ì38é06æ25å58á77Ú65Î61·5(¯7'®6&¬7&¬7&®9(²:)µ:*ÃA1ÊB4ÔA7Ü?8â;5æ95ë76î87í68ë78ë78ê86ê86è94ç:4æ;4â92á:2ß:4à;7Þ:8Ü:8Û97Ù99Ö<:Õ@<ÒC=ÊA;»;2¯6+¤6'ž7(œ;*˜;)”;)’;(:&8$Œ7#‡9%€=*v5#5'™E:ªPH¬MG©LG¦QLPJ˜UL”ZO”^R•aV•aV—aWgT‰…_™©x­½Ž¦¸ˆ¡ts†YN`8/A->3B%:F.=F3;A3:=2:=4<=599-?@2<>39<1<@29B/?L2PbNK:NK:NK:PMTQ@VS@XWC[ZF]\H^]Kb`Qf^QmWJ†[R¬ic¾c`ÁMMÈBCÐ;=Ô89Ó84Ì70Á9+º=)µC+¼B+Î;+×7)Ø8*×:+Ù9+Ö9*Ö9*Ô8)Ô8)Ô8)Ô8)Ò9)Ò9)Ò9)Ò9)Í;,Á?1¶>0«:(¡6"š4›7 £=&¯B-³;*º;,Â:,Ç9-Ë8.Î:0Ð<0Ù:4é9<ì4<æ39ã28â38á48â38â25é6<é49ç4:ç7:ã9<Û76Ð21À0(´6(­:(­:(«:(«:(«:(¬9&¯7&¸:+Á;/Î>3Ø?7à=8ä;8è96ì87î66î66î66í74ê84è:3ç:3ä<3á:2ß;2ß<5Ü=7Û=:Ù><×=;Ô>=Ï@<ËB<ÅB:¹=5­7-£5(ž7(š:*–;)“<)‘;*:(Š9&‰8%ˆ7$ƒ8%ƒ@-u4"{3%“G:¤QI¡NFžNG¡WN˜UL’XLZN\N]R”`U—aWhW‰f˜¥z©€Žj]kHDS42@&$2-:&0;*5=.9?3?1;=28;0;?18A.>K1PbÜ87Ô70Ç;.¼?+±C*µA(Ê;*Ô7(Õ8)Õ9*Ö9*Õ9*Õ9*Ô8)Ô8)Ò9)Ò9)Ò9)Ò9)Ò9)Ò9)Í;,Á?1µ=/«<)¢9$™6•5›;"§A*²B.¹@/¿;,Ã7*Å2(Ë4+Ò;0ß=8ê5:î3<ë6=é8>ç:>ä;>ã:=â9<ß58á7:â9>á=>Û=>Ñ96Ã2/¶0'¯9+«>*«>*©>*ª=)©<(©:'«8%¯6%¹7)Å;0Ð=3Ù<5ß<7ä;8è;7î87ï75ï75î85ë:4é;4ç<4ä=4â>5à?7ÞA:ÚA;ÙA>ÕA?Ñ@=ÍB?Ã?:»@8³=3ª8-¡5(›5'˜8(•<*‘<(<)Š<(ˆ:&†9'„7%ƒ6$6%}:)t3!~9*—OA£YNœRG•OE˜VJ•YN[MŽZMŒ[MŽ\Q“_T™`W‘gW~xXyƒ^r|ZU`B;E,/;%0;*0<.3=24<16<2?1:<17:/:>07@-=J0Oa;bxIk‡Lu”Qu™Qt˜NqšNršSpšRršQsœPr›Op™Kn™Jp›LsžOv¡Ry¥X{§Zz¨]x¦]qŸWg”O]ŠEX‚B`‡NY€ISzCg^Og^Og^Og^Og^Og^Og^Og^Og^Og^Og^Oh_Ph_Ph_Ph_Pi`OjaPjbOjbOjbOi`Oi`OiaNiaNiaNh`Kh`Kh`Ih`IhaGhaGhaGf_Le^Kb[I\WDWR?PM:LI8IH6IH6GH6GJ9GK:HL;IMì;Aê@CæAEàBCÜ@AÙ??Í12Ð66Ó:<Ñ=;É;9¾71µ4.­4)ª<-¥>+¥>+¥@,¥>+¤>(¦;'©:'ª7%²7'¼8+Å8.Ì70Ô94Ü=9æ>;é:7ì95ì95ë:4é;4è;4å=4â>4àB7ÝC9ÚC<ÕB;ÏA=Ê?<Ç=;¿>9±<3©:/¢8+œ6(˜7'”8)‘:):(‹=)‰<*‡<)ƒ:'‚9(€7&6%}6$x3#x5%…B2˜UEWK”PCPD•ZL“YMZN\Q\Q’[T•\U˜[VŽbUkbEV`=JS4=G,6?*2=,4>35?66=68?8=B;CF=EG/;9*78*=>0:<17:/:>06?,=J0N`:awHk‡Lu”Qu™Qt˜Nr›OršSpšPq›OrNqœMp›LošKrNu¡Ty¥X«`~©az¥]qœUf‘L_‰G]‡E^ˆIb‰PY€ISzCh_Ph_Ph_Ph_Ph_Ph_Ph_Ph_Pg^Oh_Ph_Ph_Ph_Ph_Pi`Qi`QmdUlcTjaRi`Qh_Pg^Og^Mh`MiaNiaLiaLiaLh`Ih`IhaGh`IgaKf_Le^Kb[H\WDUR?PMSQDSPAXLÂYSÙROàDEà::Ü75Õ;3Ê>/º=)µ8"É:)Ï8'Ð9(Ò;*Ò;*Ò;*Ò;*Ò;*Ñ:)Ñ:)Ñ:)Ñ:)Ñ:)Ñ:)Ñ:)Í;,Á;0¶:.­<,§>+™9#3“7Ÿ?'£9#°;)À>0Æ<1Ì8.Ð7/Ù<5ã?=ì=Bî?DéCEâDCØ@?Ê;7À50»1.¹/,¼51¾:6»<6³:2ª8.¤8,¡:+¡=-Ÿ>+ ?,¡@-¡@-¡A+£>*¦=*©;*­:(²7(¹5)¿5+É90Ô?9àC>ä=7è;5è;5ç<4å<5ä=4á>5Þ@5ÜD9ØD:ÒC;ÊA9Ä?:¼;6¸85°93¢7-™8(•5'“6'‘:)<*‹:)…8&ˆ=*…<+ƒ<*€<)~:'|8%{6&{6&y1#€8*ŒG8–SC’PB‹L=RE™_S‘WL’YN”[R–]T–]V—\V–YTŒ^QaX;EM(6@8A&>G26BE*;:&78(=>09;069.:>06?,F7GK=IK=AE4KJ6\Q;aE/ƒJ9Àj]Üg`ãUSäFEåA@àA=Õ>5É=0Æ=-Æ4%Ë5&Ì6'Í7(Í7(Î8)Ñ;,Ó=.Ò<-Ò<-Ò<-Ò<-Ñ;,Ñ;,Ñ;,Î<-»2(¶7.±;/¨:)š7"”5•7œ9"®A-³;+º6)Á4*Í6/×<7âC?êHEèDEèEHÝCCÉ:6»61´80®8.©4+«9/©9.¤8. 8-›9,–:+“<+’<+–=+˜=*™>+š?,›@-A, A-£@-¢;*¥:(«7(°6)¶6+¾8-Ä;3Ì<4Ú=6à=6â?8âA7âA9ÞB6Ú@6×@5ØH=ÒE;ÇA8»;2²5/ª3-¦1*Ÿ2+™9-’;*‘9+:*‹:)ˆ;)‡;+…<+€9'}8(|9(|9(|9({8'y6&x3$w- ‹A4—OC“MAŽL@‘QE“UJŽRG˜\R˜\R‘UMTL—ZU•XS”WT“gZ]T5IQ*AK(BK,>H/7@+2=-4?14<1HPCZ^PW[JMO:DF.AA'==%:;)>?1;=2:=2;?14=*;H.PbF7>F7=E6@F8>E5>F1HL5MI0U?'Q:¼sbËcXà_ZëUTçGGâ@>àA=Ø?9Î:0Í9+Î=,Ï=.Ï>-Ï;-Î;+Í9+Í:*Î:,Ð:+Ð:,Ð:+Ð:,Ð:+Ð:,Í;.É?5ÅB:¼B7®=/Ÿ6#–1–1›2¨5#´6(Ã;/ÑA8ÞE?æIDéJFêKHÞCAÛEDÐB>¼<3¯9/©=0¥?1Ÿ=0Ÿ?1œ>2—>0”>/=/Š>.‡@.ˆ?,Ž=*‘;*’<+“=,”?+•>+—>,™>,Ÿ@.¡=-¤:,¨8,¬8+±8-¶:0¼9/Ê<2Ð<2Ó?5ÕA7×C9ÖC9ÔD9ÑE8ÊB6ÃA4¹=3°:0©6/¤5.Ÿ4,™7,’:.Œ=,Š;,ˆ;+†:*„;*ƒ<*<,~;*|;){9)y:)x9(w8'u6'w4$€4'D7˜NC‘K?ŒJ>QD’TIRG“SJ˜XO˜UO—VPœ]X”WRŽSOŠcT]W5Xc9_jBZfBIT66C)4@*0:<19<1<@25>+;H.PbMKD63Å?3ÅA4ÃA3ÁA4¶;,²:,ª8-£7+ž6+›6,˜7.”:/;/ˆ<,‡;-„;,‚:+€;+€;+<,};+z;*z;,w9*v8)u7(t6)v4&ˆ;1”F<–NBŽJ=ˆHEI0?C(=@#:<$89';<.8:/9<1=A36?,MK4Ñ>4Ò>4Ò>4Ó?5Ó?5Ó?5Ó>7Ó?;ÑB>ËD>ÆF=ÂF<ÃI>ÇM@ÎPDÙSHÝPGâMGäIEäGBâC?àA=ÛB=ÕFBÉD?º?7«=0Ÿ>.šC0•G3”I6F4ŒE3ˆC3…B1€A0}@.zA.|?-‚:,†8,…9+†:,†:,‡;-‡;+ˆ;+‰:+‹:)Ž8)8*•9,™;/=/¢<0ª:/­8.¯9/°:.°:.°:,¯9+®8*¨7)¥7(ž6)›6*•7+’8-‘9/Ž<0ˆ<.…<-ƒ;,9*:*~9*}:*};+|:,z;,y;,w9*s8*q6(r7)u5)ŒD8’H=‘K?ŠH:‡I<‹OD“TK—TL–QL›TP˜QO”SO–\X_Xh^—~j””p…’fu‚WYh?CR+?O*P`B)=A(;='78(:;-79.9<1=A37@-NKB1=I1?G/LG1S>+g=-•ZL­_Sœ>4ž3+¶?9ØXUóigödeëRUæJNèNPÙIAÓF<Í@6Ë>4Î@6ÒD:ÕG=×G>ÚJAÚJAÝJBÝJBÞKCÞKCàKDàKEëSRèTTãSRÜROØSLØSLÛULàUNàLHáIFãEBâC@äB@âC@äEBàFDÙJFÊE@¹>7¬=2¡?2˜B1’E3G4ŒE3ˆC3‡B3ƒ@0?1~?0z?/|>/€:.ƒ9.ƒ9.ƒ9.ƒ;-ƒ;-ƒ;-ƒ;-9*‚9*…9+‡:*‰:+;-<.“;/›;/ž9-Ÿ9- :,¡9,¢8+¢8*¢8*Ÿ8)œ8)˜8(”8)9*Œ:,‰:-‡;-„:-‚:,9+€8*}8)}7+|8+{9+z8,y9-x:-v8+q5*o5)q7+t9+ŒH;I<‰I=„I;…K?ŒRF“WM˜XO˜QMœUQ˜RP“VQ’`YˆbWƒg[†zdnrQZi@JY0AR(IZ0Wi?dvNj|VXiEL[:?L.:D)C-B47@-;H.L^8_uFi…Jt“Pt˜Pt˜Nr›Os›TpœQnMmžLp¡Pw¨Y|ªaz¨`rXi“QZƒA\„EaˆIeŒMgŽMgŽKhJfŠLc†PY{IRtBi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`QkbSkbSkbSkbSkbSkbSkbSkaUlbYlbYlbYlbVlbVlcRlcRldQldQldQlcRlcTlbVlbXlbXlbXocUnbRkbQlcRlcRkbQg`Pd]M^WGYSCSM?MJ;KH9GE6EB3?B/;H.?H-OC-a=-ƒE:«XR´NJž,+²:9¹=;ÓSRòpnþvvñehëX^ð^_ãUQÚPFÔG@ÐC:ÑD=ÔG>ÖGAÖG?ÙHCÚJBÜHDÝJCÞJFÞKDàKGàKGâHHáGIÜHHÙGGÖHD×HDØGBÛFBàBAäABæBAèBBçCBäB@ßA>ÛA?ÛJGÊC?¹<6®>3¢@3˜A0A0C3ŠA2ˆ@1‡?1…=1‚<0€<1=1=1;1;1ƒ:3;1;1€.™9)–9(“:*:+Š;,‡;+„;,‚:+‚:,9+7)~6({5){5){5)z6)x6*x8,w9,s8*p4)o5)r:-v<0‹M@‰K<„J<‚M=…QC‹VH’XM—WN“NI™TO—VR•\Ue\{^PfVF`^GEO->N)?O(J\2_rEk~QexKXj@M_7@Q-6E&7D*=F1=D4:>07;-8:,:;-68-8;0>B47@-9F,I[5[qBeFr‘Ns—Os—Mr›Os›TpœQmœLo Os¤Ux¨\z¨`s [i“Q`ŠHYB^†GeŒMgŽMfJeGgŒGhŒLa„NXzHQsAi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`QkbSkbSkbSkbSkbSkbSkbSkbSlbXlbVlbVlcRlcRldOldOldMldMldMldOldQlcRlcTlbVlbVocUmaSkbSlcTmdUlcTi`Qf_Ob[K^WGXQARLÐB>Í@9ÒC?ÒC=ÔC@ÕD?×CAØD@ÙECÚDCÝADÝADÞDFÝGHßIHàJIãIIåGHçACêADìBEìBEçAAâ@>Û=:Õ=:ÚFFÉ=<¹83°;2¦@4˜?1‘>0@1ŠG]/AV-7H$1@!6B*=F5PK8MH5ID1DC.@F*DD([B,ˆTG¯\X«>A¬/3ÎINÆ?EÀ;>»;<ÄFGØZ[ãefÛY[ÌGHÑJGÐEBÍB?ÐB>ÔFBÔFBÐB>É>7ÏD=ÏD=ÒD@ÔEAÖEBÙECÚDEÝDFÞ?Cß@DÞBEßEEáGGàFFàBCá>?èBDé@Cè>Aç=>ä>>ãA?áC@ßECÖBBÅ98¶50°;4¦?6š>3=/?2ˆ)=C5ã?>â@=â@=ÞC?ÓB?Å>:¶93ª70Ÿ:0—=2Ž>3†>2ƒ?2?3=2;3„93†93ˆ81ˆ92…;0„<.„<.ƒ;-;/€:.€:.€:.~:-~:-~:-~:-};/};/};/};/}90}90~80~8.€7.€7.€7.~8,€8,~8,}9,|8-{9-z8,x8,x8,x8.x8.w7-v8-v6,t6+s5*q5+m1'r6,n4)m3(o6+m4)q8-I=…SH…SJ†RGˆRH‹PHQJ”QK•RL“TMTK‰[N‚cQo_HYU:MV7O_;j~YbxQYoHUjCRg@Mb;IY5CR17D&4>#2:#6;'<>0@B5@@6<>358-39-4:.7:/9=/;?.=B,%Q?)kP=XG„NBˆE=“D?±WV¸TT»QQÀPOÀNMÁMMÂLJÃKJÐTTÈHGÂ=>Ä=:ÐB@ÓEAÏB;Ç>4ÊD9ÉE9ËF=ÍG>ÔFBØDDÜAEÝAEáBFáCDáCDâDEâDCáFDáFDáFDàEAßD@àB?ßA>àA=àA=àA=ÞC?ÔE?ÈC<º>6¬:0 90”:/Š<0‚<0€A2~@3~>4<3ƒ:3†91ˆ81‰90‡;.…<-„;,„;,ƒ;-‚:,‚:,‚:,9-9-9-9-~:/~:/~:/~:/}90}90}90}90}90}90|90|90|90z:0z:0y9/y9/y9/w9.w9.w8/w8/t8.s7-r6,r6,p6+p6+k1&q7,m4)l3(o6+l3(p7,~H>„RI…SLˆQJ‹PJQL”PM•QN”SOŠOG…SH€[K{ePsiPhkLfqQgxT^tMXnGPf?La:K_:K\:GV7CP4>2;=04:03;05;16<0:A,>D*Q[9^mDkRpŒRp“Sq™RsSsžVxŸ^|¢exžak‘T`†I]ƒF]ƒF\‚E`†Ia‡Jc‰Le‹NdŠMbˆK`†I^„I]LRtBIk9i`Qi`Qi`QjaRjaRkbSkbSkbSjaRjaRjaRjaRjaRjaRjaRjaRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTnbTqdTo_Pm]Pm_RqeYog\ldYhbVfbWpl`{xi~{jyizubpiVe`JTT(MB.S@/U8(]7*l=3n70u91~;5‡@:’IB›PJ¥XP­ZR»^YºSN·GE¼B?ÈDBÑFCÓD@Ï@:ÐA;ÐC<ÒE>ÔG@ÖGCÚFFÛEFÞDFßCDßCDßCDßCDàDEßEEßECßECÞDBÞDBÜD?ÛC>ÜC=ÜC=ÜC=ÛC>ÖE@ÎE?ÃB<³>5¢:1”8-ˆ9,ƒ;-‚@2@1~>2=1ƒ:1†91‡81ˆ:0‡;.„;,„;,„;,‚:,‚:,€:.€:.9-9-~:/~:/~:/~:/~:/~:/}90}90}90}90|90{8/{8/{8/{;1{;1z:0y;0x:/x:/x:/x:/t8.t8.s7-s7-r6,q5+o5*o5*j1&o6+m4)k2'l6*i3'm7+}G=‡PI‡PI‹PJŽQL‘RM’SN”UP‘VPŒWO‡[P~^OtbNoiQorUlwYfwUQeBK_:EY6DU3EV6GV9GT8ER8?I0*7;*:<.<>0;=/9;.6<25=26<26<0:0=@-=C)MW5Zi@f|MlˆNn‘Qq™RuŸUtŸWz¡`w`n”Wc‰L\‚E\‚E\‚EZ€C_…Ha‡JbˆKdŠMc‰La‡J_…H]ƒH[}JPr@Gi7i`Qi`Qi`QjaRjaRkbSkbSkbSjaRjaRjaRjaRjaRjaRjaRjaRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTnbTrdWoaTm_Rk_SkaWlcZle[jf]jf]xtiˆ„x‘•’Œ~‰‚r}zg`cNOT>DG2FE1HC0F=,L<,VC4P9+R6*V4*Y5)\6+a9/e=1m=1ŠKBSJ®UO¶NK¼FDÆABÒDCØFFÔ@>ÕA?ÖB>ÖE@ÙECÚFDÛEDÝEDÞDDßCDßCDÞDDÞDDÝEDÝEBÞFCÛFBÚEAÙD>ØE>×D<×D<ÙD=ØE>ÔD<ÓF?ÉF>ºA8§;1˜8,Œ9+…<-ƒ@0@1~?0=/ƒ:1„:/‡9/ˆ:.„:-„;,„;,ƒ:+‚:,‚:,9-9-9-9-~:/~:/~:/~:/~:/~:/}90|90}90{8/{8/{8/{8/x8.{;1y;0y;0y;0x:/x:/x:/v:/s7-s7-s7-r6,q5+o5*o5*m4)j1&o6+l3(h2&k5)h2&l6*|F<ŠOGŒOJPKRMSN‘VPWPŒZQ‰]R…aUy_PiZGd_IdhO\fKN]@EU8AQ4=M0G2:A/9=,9=.9=.8<-7;-7=36=56;46<2:<1;=/bxIj†Ln‘Qs›Tw¡Wx¢Z{¢ar˜[e‹N\‚EZ€C\‚E\‚EZ€C_…H`†Ia‡JbˆKa‡J`†I^„G]ƒHY{HNp>Eg5haQhaQhaQibRibRjcSjcSjcSibRibRibRibRibRibRibRibRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTlcTrfXth\sg[mcYjaXle]snhzwp~w† ”¨¥œ«§œ¨¤™£‘™–‡z{kcfSOR?GJ7EH5BE2BE2EH5KL0A9,A7+@6*F4(S5*qB8ŒPHŸPK¯IG¿GIÌEIÓBEÖ@BÙ@BÚBAÛCBÚEAÚEAÜDAÜDAÞDDÞDFÞDFÞDFÞDDÝEDÝEDÚDCÚFB×FAÖF>ÔE=ÔE=ÓF=ÔE=ÕF>ÔA:ÓC;ÎE=ÁB9®>3ž9-‘;.Š.€=-;/„:-†:-‡;.„:-ƒ;-‚:,‚:,‚:,9+9-9-~:/~:/~:/~:/}:1}:1}:1}:1|91z:1|91y90y90x8/x8/v7.y:1y:1x90v:0v:0u9/u9/t:/r7/q6.q6.p5-o4,n3+n3+m4+j1(m7-j4*h2(j4*f2'j6+}D;NGNHQJTLUOŽWPŠYRƒ[Q{YMv\OkZJ]UBYXDY^HOYA?K3:H/7E.4B+5A+8D.=I3CL7EN9BK6?H5.5<,4:,5<45<56;56;49;0:-;@)GP1Ra:`vGi…Ko’RuVy£Yy£[xŸ`n‘W`ƒIZ}C[~D^G^G]€F`ƒIa„Jb…Kb…Ka„J`ƒI_‚H^IW|ILp@Bf6haQhaQhaQibRibRjcSjcSjcSibRibRibRibRibRibRibRibRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTlcTkaUndZpf\lcZkd\rmg„|‘Œ§£ µ±®ÄÁ¼ÉÆÁÉľÅÀºÀ¹±¹²¨¤œˆ‚rfcTPQ?FI8>E3;D1:F28E38E38C2:B34(P:/e?6€EA¡PO¿X[ÊQVÊCIÕFJ×EFÚFFÛEDÝEBÞDBÝD?ÞCAÞDDÞDFÞDFÞDFÜDCÜDCÜDCÚDCÙEA×FAÕF@ÓF=ÒE<ÐF<ÑG=ÔE=Ô?8Õ@9ÐC:ÆC9¶A7¥=0–=/Œ=.†>/‚?/>.€=-<-ƒ;-„:-…;.‚:,‚:,‚:,‚:,9+:+9-~8,~:/~:/~:/~:/}:1}:1}:1}:1z:1z:1y90y90x8/v7.v7.t8.w8/u9/u9/s9.t8.s9.r8-r8-q6.q6.p5-o4,n3+m4+l3*j4*h2(l6,i3)f2'h4)e1&i5*{B9ŽMG’MH‘PJTLVO‡XNYO|\Qs\Nk[L`WFVSBPSBJQ?@I64@,3<+2;*09(09(2;*5>-9B1G4:F2:C25@/3>-1<,3:33954954928919;.;>-;@*CL/O^7]sDi„Mp“SwŸYy£Yw¡Yq˜Yf‰OZ}CX{A\E]€F]€F^G`ƒI`ƒI`ƒI`ƒI`ƒI_‚H^G]€JV{HJn@Ae7haQhaQhaQibRibRjcSjcSjcSibRibRibRibRibRibRibRibRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTlbVj`VjaXkdZkg^upjˆ…€Ÿžš°°®ÃÂÀÓÒÐâáßçæäçãàãÞÚÞÖÓÙÎÈμ²¸¥——‡zym]_YIKL:@E1;D/>J6=H7=F5;C4;>5:;3983880==3C<2N71a84ˆHH¯]_Å`dÊWZÍQSÓNO×MKÛKJÞHGáFDãDAâBBßCDÞDFÞDFÝCEÝCEÜBDÜBBÛCBÚDCØD@ÕD?ÓF?ÒE<ÐF<ÐG=ÔE=Ù@:Ù@:ÑB:ÈC:¼C:¬@4™;/Œ9+‰=/ƒ>.>-€=,<,ƒ;,ƒ;,„<-‚:,‚:,‚:,9+9-9-~8.}9.~:/~:/}:1}:1}:1}:1}:1}:1z:1y:1x90x90w8/t8.s7-r8-t8.s9.r8-q8-r8-p7,p7,p7,o6-o6-n5,n5,m4+l3*k2)i3)g1'k7,h4)e1&h4)b0%f4)zA8MG’MH‘PJŽULˆXNYOxZOr\Nk^N^WGRPAKN=CJ:9B12:+08)17+17-06,/5+/5)08+2:+4<-9D4;F5=H7-.800621622717829;0:<.:?)?H+KY5[qChƒLq“Vwž[w¡YsœVgP^IUx@WzB[~F[~F[~F]€H_‚J_‚J_‚J_‚J^I^I]€H]€JUvIJk@@a6haQhaQhaQibRibRjcSjcSjcSibRibRibRibRibRibRibRibRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTlbVpg^ng_lgatqj‡„¡ œ¼¼ºÎÐÏÏÏÏàààòòòúøùû÷ö÷óðñìéðâßèÐÆÝÁµÁ«¢‘}ub^\GKM7CH2AI2AI4@G5BD7AA7B=9C97?:69<5>?7B71J.+d66QR³giÆnmÀ\\ÇZWÐVS×QNÜLKâHHæCDåBCßCFÝDFÝDFÝCEÝCEÜBDÜBBÜBBÜDCÙCB×C?ÓD>ÒE>ÐF<ÐF<ÔE=ÜC=ÛA9ÒB:ÊD;¿E:°A6œ:-‹5&ŠD69A208+/7*6<247058157247025.06,08-19,6A3:E5=J9>K9-,6..400511606718:/:<.:?+WzB[~FY|DY|D\G_‚J_‚J^I^I^I]€H]€H]LStIHhA?]7icSicSicSicSicSicSicSicSicSicSicSicSicSicSicSjcSkbSkbSkbSlcTlcTmdUmdUmdUmdUmdUmdUmdUmdUmdUmdUldWibZgd]vsn“’Ž¯¯­ÄÆÅÚÜÛêîïóôöö÷ùüüþÿÿÿÿÿýÿûúü÷ôýòì÷áÔòØÇàʵƶŸª ‡ˆ„ibbFEH-DH/CG0FE1GD5F<3C60F42H:9>=9>?:B:7I75cGF’jjÅ“’è­©Ò‹‡ÇtnÀ]XÆSPÕONßJLçFKéFKßEGßIKÚDFÔ;>Ø>@áGIàDGÖ:=Ú@@Ú@@ÙA@ÖB>ÔC>ÑB<ÐA;ÑA9ÞC>ÛA9Ó@9ÊA9¾B8°@5Ÿ:.8*Œ=0‡>/ƒ>.>-€=,<+=*<,:+9-9-~8,~8.|8-|8-|8-|90|90|90|90z:1z:1z:1z:1y=5w<4w;3u:2t91q8/p7.p7.o6-m7-m7-l8-m7-l8-m7-m7-i2+m6/p92o81k4-g2*g2*h3+e0(i7.d2)]-#`0&_/%b2(s>6ŒOJPKˆQJRJ}YMv_QfYITN>DE5>E5:C25@04&DR1WlCh‚Rs”]wž_r›Wk”R[~DXyDTu@Tu@WxCZ{F[|GZ{F^JbƒNbƒN^J\}H_€K`L^~MTsJFd@2I:3L95K<9?:7BA?MHE]RPyjg£Ž‹Î²®èÅ¿ÿ×Ñ쳪͂|Àc^ÊVVØRSßHMÚADÖDEÕEEØHHÜJKÛEFÕ<>Ö<>ÛACÙ??Ù??ÙA@×A@ÖB>ÓB=ÒA<Ó@9ÜA<Û@;Ó@9ËB:¿C;±A6 ;1’8-Œ=0‡>/ƒ>.>-€=,<+<,<,:+9-9-~8,}9.|8-|8-|8-|90|90|90|90z:1{;2{;2z;2w<4u<3u:2s:1r90n8.o6-m7-m7-l8-l8-l8-l8-j8-l8-l8-k6.n70o81n91l7/i4,g2*e3*c1(d4*_/%^.$b2(^.$`0&p>5JE‡RL‡XR~XOrVKdRDQJ:>?/:A16A05@03>04<14<15;17:379477577557246116//6./7,.9+1<.4A08E49H58G44E24B1.8/.5..3--2+23+46+8:-9=,7?(DQ3WlEh‚Ut•`wbp˜YgPY|DWxCTu@Tu@VwBYzEYzEYzE[|G_€K_€K\}H[|G^J^J^{MSnKF_A9R4icSicSicSicSicSicSicSicSicSicSicSicSicSicSicSicSkbSkbSkbSlcTlcTmdUmdUmdUmdUmdUmdUmdUmdUneVneVlfZed_y{x—™˜²¶·ÍÑÒäéìôùüúÿÿûÿÿüÿÿýþÿþþþÿþüÿÿûÿÿúÿÿôþüçúùÝïðÑáåÄÒØ´¼ÄŸ ¨ƒ‡‘l`gEQX7DG,DC.JD4LD7KA8I>:C;9SJKia_wvœ’¾³¯ÙÎÈêÜÓþèÝÿóéÿäÛð©£ÃecµBEÇDIÚRVÛUTÑMKÊDAÍCAÔFE×EFØDDÙCDÖ=?×>@Ø@?Ö@?ÖB@ÓB?ÓB=ÔA:Ù@:Ù@:ÒB:ËE<ÀD<²B7¡<2“9.Ž<0‰=0ƒ>/>.=-~<,€=-€=-9-9-~:/}9.}9.|8-{8/{8/}:1}:1{;2{;2{;2{;2z;4x<4t;2q;1r90o9/n8.l8-l6,k7,l8-j8-j8-j8-j8-i9-j8-j8-n91m80m80m80m80i7.f4+c1(d2)a1']-#_0&c4*\-#_0&sD<}PJVP~YQpTI^J?OC7?<-46(2;*0;+1<.2=/4<14<15;17:379479668357257227007/08-.9+0;-2?.6C27E48G48G49F54>33:2/4-,2(/0(13(57*6:)6>'DQ5YmJk„Zw—fwœfl“Z_‡KWxCWuCTr@Tr@VtBXvDYwEYwEZxF]{I_}K]{I]{I_}K^|JZwKPgJAW@3I2icSicSicSicSicSicSicSicSicSicSicSicSicSicSicSicSjcSkbSkbSlcTlcTmdUmdUmdUmdUmdUmdUneVneVneVneVmg[jkfƒ‡ˆ£§¨¹¾ÁÐÕØåíïóûýõýÿûÿÿûÿÿüÿÿüþûýþùþýøÿþ÷ÿÿóøýæôýÞî÷ØæòÎÝéÃÎÚ´¶Á™¡«†€‡efmLMQ6FH0HJ5KI:HD9D@7OGDj`_‹€¤š™·¯¬ËÆÂÞÛÔêæÝúñèÿûñÿ÷íÿÝÕû¶±åŽÊcd°@?ÃPKÉTMÉPHÃF@ÈGBÔMJÖKHÐ@?Ò>>Ó??Õ?>ÕA?ÕA?ÓB?ÓB=ÓB=Ö>9Õ@:ÒC=ÌE?ÀE>²A9¢=5•;2Ž<1‰=0ƒ>/>.=/~<,€=-€=-9-9-~:/}9.}9.|8-{8/{8/~;2~;2|<3{;2{;2{;2z;4x<4r90o9/o9/m9.l8-k7,j6+h6+i7,i7,i7,h8,h8,h8,h8,h8,m;2l7/j5-i7.j8/j8/f4+a1'e5+a2(].$a2(b3)Y* a2(yNE\VvWRiNGWC:I<3@:.:;-8<.08)/:*3;.4Ð@?ÑA@ÒC?ÑC?ÑC?ÒC=Ó?;ÒA<ÐE@ÉE@½C>¯@9 >5•=3Ž<1‰<2ƒ=1=0=1~<.=/=/~:/~:/~:/}9.|90{8/{8/{8/|<3|<3|<3{;2z;4y:3y:3w;3n70m80l7/l7/k6.h6-h6-h6-i7.h8.h8.g8.g8.g8.g8.h8.k92h6/f4-g5.i70h70e4-b1*c2+b3+_0(]1(]1(V*!b6-{ULtYRaNHN?8A7.=6,;9-9;.9<139-3;.5;/6<06<07:/58-47.69049238139/39/2:/19.19,.9+.9+/:,0;-3>.6C2:E5Qn>Qn>Qn>Qn>Qn>Sp@Sp@WtD[xH]zJ]zJ_|L_|LZwGRlECU?6D7(6)gdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSicSjcSkbSkbSlcTlcTmdUmdUmdUmdUmdUneVneVofWpgXpgXng]lnmz‚…“š «µ·ÄÎÐÜæèí÷ùôþÿõþýöÿüúÿúûÿùûþóøúíõöèñôãôýêôýèôüåóùßòöÛéìÍØ×¹ÅÄ¥±°’ŽregOMP;GK:FM=GOBKQG{{sŸš”ž¸ØÎÌßÓÓçÛÛóëéü÷ôðïêüüôÿÿöÿýóÿùïÿóêÿçÞÿ×ËØ“ƒ¸eS£J:´TF½WIµF;·@8ÈKEÇC>ÊC?ÌB?ÎC@ÎC>ÎC>ÍD>ÍB=ÑB<ÒC?ÎDAÅD?¸A=ª=8ž;5•<4Ž;3‰<2ƒ=3=2=1~<0=1=/~:/~:/~:/}9.|90{8/{8/{8/|<3{;2{;2z:1y:3x92w81u91n70l7/l7/j8/i7.i7.h6-g7-g7-g7-f7-f7-f7-f7-f7-f7-h70h6/g5.g5.g6/h70g6/f5.a2*e6.^2)\0'`4+a5,i=4uSJXG@E>6<5/95,;8/8:/57,36+69.5;/7:/69.69.58-57,36+28,19,28.19,19.19,19,19,.9+.9+.9+/:,0;+3>.6A17B2ex\umt’lf‰_RwKBh9KkVsCZwG]zJ^{K_|L_|LVsCNg@ÉD=ÈC<ÉB<ÑC?ÐE@ÌEAÂC=³=9¦;5œ;5•<6Œ<3‡=4…<5=4<3~<0=1=1~:/~:/~:/}9.|90{8/{8/{8/{;2{;2y:3x92w81v70v70s7/n70j8/j8/j8/j8/h8.h8.h8.g7-f7-f7-f7-d8-d8-d8-f7-g6/h70i81i81h70i81j;3l=5g80k<4b6-a5,oC:xLCtI@nMDC9056.45/8918;247.14+25,58-58-57,46+46+46+46)37)/7(.9)08+.9).9+.9)08)08)19*08)08+/7*08+19,3;.4<-9B1:C0;B0:A1:<.68*24&/3$29'IU?cu[m„gf„bWyTInE?d8Hg;Li;Nk=Nk=Li;Li;Mj
    UrDYvH[xJ]zL^{M\yKQn@G_;6B4+4/#)%gdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSicSjcSjcSjbUlbVlbVmcWmdUmdUmdUleUmfVngWogZnh\oh^mjekormtzƒŠ¥®³ÃÌÑÕßáæîñôüþôýú÷ýùùþ÷úÿôüÿòüÿñüÿîýþðûøïþúñÿùïÿúíÿùéÿòßïàËÝηÁ²›¢—|ubb_NXZL]cWmwn|†}¦¬¢¾ÀµÚÕÏîäâüîîÿôôÿô÷þôõÿùùûúøûýøüÿúøÿõôüñ÷ýñÿÿñÿùèÿôãÿÌ»½p›QD©SFµSH²C:ÀJ@ÄH@ÇG>ÉF>ÈE=ÇD<ÆC;ÆC;ÍG>ÌG>ÇG>¼C;­>5Ÿ:2—:3‘>6Š=5†=4ƒ=5=4€<3;0;1;1~:/~:/~:1}90|90{8/{8/{8/z:1z:1x92w81v70u6/u6/q6.m80k90j8/j8/i9/i9/i9/h8.g7-f7-g7-f7-f7-f7-f7-f7-f5.j81m;4k:3j92j:0m>4oC8l@5oD;d<2c=2zVJ†dZyWMbLA>:13814927<54:0/5+25,9<336+25*24)03(13(25*46+47,.6),7)/7*-8*/7*/7*/7*/7*19,08+08-/7,/7,/7,08-08+7?09B14*00!''heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVjdVjdVjdXldYlcZmeZmeXmfVg`NjeRnkXol]he\feasqr‚†Š“–ž¡«³¶ÃÈËØÝàêîïö÷ùùûúüþýþþüÿÿúýþöúýòùüñúýòûþóùúòúúòùùíüúëþüçù÷ÞéåÊÕÔ¶º¹›˜˜|qtY_dMbkXr}l„‚‘›´¹²ËÌÇãâÞòîë÷óòû÷öýùøüø÷ÿþüþþüþþüýÿúýÿúýÿúýÿúýÿúúü÷ÿÿúÿûöÿêåا £`X›D=µNE¿MCÂF<ÄD9ÊE<ÎI@ÎKAËH@ÇG<ÆG8ÃH8½J8³H8¦E5šB4‘B5‹C5†B5„B6‚@4‚>3‚<2„:1†91†9191~:1|91{80z7/z7/w7.v6-w7.w7.w8/w8/v7.u6-q5+n3+l7/i81i81h70h70g6/g6/g6/f5.g6/i70i81h70g6/e4-e3,h3-j5/m80k90j:0i;.i=0kA3gB2jI:dH:v_O~k\ŠxjŒoRJ=79.4:04:039/39/39/28.28.17-17-36-06,25,/5+14+/5+/4-.5-/4-.5-/4-/4-/4-/4-05./4-/4-.3,.3,/4-/4-/6.1;23=26@58B79D67B45@03>-4?.DQ=WeN[kQPbHEX<@T8BW6Ic>Ke>Kf=Kf=JeOj?UpGYtK\vO]wP]wRWqNHb?;O6&1+&+.$),heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVjcYkdZlc\md[meZmfVidQjhSmjWjk[gg_lll~„“š¨¯µ¸ÂÄÑÖÙâçêòóõûüþÿþÿÿþÿþýûÿþúÿÿúþÿùûüôøûòöüò÷ýó÷úñøúïøúí÷úéùûåòõÚßâÃÌЯ´¸—‘–vkqUYaI_kUtoŒ˜Š§œ¿Á¼ÓÓÑççåóóñ÷÷õûûùüüúûûùþþüþþüþþüþþüþþüþþüþþüûÿþõÿÿõÿÿþÿÿÿûúÿíêð¿ºÂ~uŸKA¯M@¹K>ÂL@ÅK>ÃE9¼=4¾?6ÃE9ÄF7ÃJ7½L:³J7¦F6™C2‘C6E7…C7‚B8A7>5‚<4ƒ:3†91„93~92}:2z:1z:1y90x8/v7.v7.u6-v7.t8.t8.t8.r6,o5*m4+l7/i81j81h70i70h70g6/g6/e3,e3,g5.h6/j81j81j81k92k60l71k90k;1k;/j>1j@0iD2gH6kP=gRAufSueŒ…s†ƒrKL<69.39/39/39/28.28.28.17-17-17-17-06,06,/5+/5+/5+/4./4./4./4./4./4./4./4.05//4..3-.3-.3-.3-/4./6/.80/:21=34@66B66B66B45B16C1CP>P]IR`IIW@AO6BP7EU:Jb@Jd?Ke@Ke>Ic6I5&1-',0$)-heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVjcYkdZlc\md[meZmfVmhUkiTmjWjk[kkcwww‘’—§¬²¿ÆÌÒÜÞìñô÷üÿþÿÿþÿÿÿþÿÿþÿþýûÿþúÿÿúýþøúûóõøïñ÷ëñ÷ëô÷ìõùëöøêõøåõ÷áîîÔÛÛ¿ÉÊ«°±’“–yuy`kpZt{iˆŸ§œ®µ­ÍÏÊÞÞÜïïíøøöûûùþþüþþüýýûþþüþþüþþüþþüþþüþþüþþüýÿþûÿÿûÿÿÿÿÿÿûùÿúôÿ÷íýÑÆØž”L=¥RB©L;§@1·G;ÏYMÏUJ¼@4ÄD7ÆH:ÃK=¹I;ªB7?3—@7“E;‰@9„A9A8?6~>5}=4<4}=4z;4x<4w;3w;3u:2t91t91t91r90r90r90r90o9/n8.l6,k5+l7/j81l71j81k60i70i70h6/g5.g5.f5.g6/h70i81k:3k:3l;4j;3i:0h<1k?2jC4iD2fE2fI7lVAjYGujV†m‘Ž{€mEF658-28.28.28.17-17-17-06,17-17-17-06,06,/5+/5+/5+/4./4./4./4./4./4./4./4./4./4..3--2,-2,.3-/4..5.+5-+6.-9//;12>24@46B47D38E3?L:ER>CQ:;I28F->L3DT9J_@Jb@LdBKc?Ia=G`9F_8G`9RkDXpL]uS^vVZqTPgK=T8.A.&1-',0%*.heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVjcYkdZlc\md[meZmfVniVljUlkWlm]pqi€‚ž¡¦¹¾ÄÄËÑÛåçõúýûÿÿüýÿüýÿþüýüûùÿþüÿÿûÿþùûüôõöîîñæéïãçíßíñâðôåñôãñôßòñÜêêÐØؼÇÇ«²±•¡¡‰‘“}“€œž‘ª­¢¶»´ÀÅ¿ÜÜÚééçööôûûùýýûÿÿýÿÿýýýûþþüþþüþþüþþüþþüþþüþþüþþþûûýÿþÿÿþÿ÷òïüóìÿüóÿûíÿôäìñ¹p•P@¢O?¸XJ·M?µE9ÀG<ÁA6ÈE;ÅI?½G=¯@9¡<4š=6–A4e=1f>2hC3iE5fG3cG2cJ6hV@i\IskV…‚oŽzpq_9=,47,28.17-17-17-06,06,06,17-17-17-06,06,/5+/5+/5+.3-.3-.3-.3-.3-.3-.3-.3-.3-.3--2,-2,-2,-2,.3--4-*4,)4,*6,+7-.:.1=14@25A36C2:G5N4DX¿@7ÆC;ÅF?¿D=±>;¦:7ž:8™>;‘=;Š?<„@=}@=xA6s>6r=5r=5r=5p>5o=4n>4m=3l<2k;1j;1i:0i:0j:0n72p62p62m61m61l71i70i70l;4k:3h91e90e90e90e:1d<2fB6cA5cC4dD5dG5dI6bI3_I2^L6eV?jbMrmW„ƒo„‡r[`L3:(28,28.17-17-17-06,06,06,17-17-17-06,06,/5+/5+/5+.3-.3-.3-.3-.3-.3-.3-.3--2,-2,,1+,1+,1+,1+-2,,3,,6.+5-*4+*4++5,.8-0;-2=/2=-5@/6A05A-1=)1=)5A-8F/=O5@T8FY=H\@J]?I^=K^>K`?TgG[pQcvZauZYkSJ]G6G4&4%$-*$),"'*heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVjcYkdZlc\md[meZlfVjgTkjUlnYorasvm…„Ÿ¤¨¸¿ÇÖßäí÷ùûÿÿûÿÿûüÿþÿÿÿþÿþýûÿÿûÿÿúüüôóõêëíâãçÙÝãÕÜãÑäéÓçìÕéíÖêìÔëëÓèæÏßÚÄÓθÓκÌƶËøÐÉÁ×ÒÎàÛØêæåðïíóòðùù÷ýýûýýûýýûÿÿýþþüüüúþþüþþüþþüþþüþþüþþüþþüÿýüÿûüÿøùÿþýþÿýùÿýôÿøïÿõ÷ÿöð÷çÿÿíÿîÛͧ”¤kX¢[GªWE­L;¹D:ÀD<ÀE>¼E?´A>ª=:¢:9š;9•=5o?5o?5o@6n?5m>4k<2h<1h<1h<1l<2o83q62p62p62m61l71j81i81h70g80e90e:1d<2e?4f@5dB6^B4aG8cL:dM;cM8`K6]K3]M4]Q9bX?mhRss[€ƒnv{eFO:4=*39-28.28.28.17-17-17-06,17-17-17-06,06,/5+/5+/5+-2,-2,-2,-2,-2,-2,-2,-2,-2,,1++0*+0*+0*+0*,1+,3,.5.,6.*4+*4+*4++5,-7,.9+-8*0;+4?/5@/4?.3?+3>-3@,7F/9K3@O8BT:GW¸J=¹I>¸I@´G@¯D>¥=:œ:7–=9>:ˆ?9€A:xA:tD:pF:pE5j>5n=6o83r73p62p62n72l71j81i81d8/d90c;1d>3d@4cA5cA5_C5ZE4_NnlUtv^|kcmU2>(6B.3;.39/39/39/28.28.28.17-17-17-17-06,06,/5+/5+/5+-2,-2,-2,-2,-2,-2,-2,-2,,1+,1++0**/)*/)+0*,1++2+-4-+5-*4,*4,+5,+5,,6+-7,,6+/:,2=/6A17B27B15@04?.2?-4C.:G3=L5AO8DT:JX?L\BTbI\kTcqZ^mXUbPDRA2>0#/%&/,&,,$**heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVjdVjdVjcYkdZlc\md[lfZlfVolYmlWjlWgkZflbr{xŽ˜š¨±¸ÊÓØãìñøýÿ÷üÿúûÿþÿÿÿþÿúùõÿÿúýýõøøîðòåéëÝåéØãêØåíÖæìÒéíÒêíÒèèÎèæÏèãÏáÚÈØÐÃØÎÄÝÒÌêßÛøíëÿôöÿõùÿõûÿùüþüýÿÿýÿÿýþþüþþüÿÿýÿÿýýýûþþüþþüþþüþþüþþüþþüþþüÿþúÿýûÿýûýüúùýüøÿÿõÿÿóÿÿíýúóÿûûÿúÿÿôÿöæÿóßÿãÍ×­•©oY¨WD®Q@¬O>¯OA±OB­K@¤C<™<5•>7?6ˆ?8A7{B7uD6qE8qE8p?8q?8s>8q?8q?8q?8q?8p?8sB;qB:o@8m>6l=5j>5m>6o>7o83q73o83m82m82i81h91f:1f;2d>3d@4bB5`C5]A3\@2WB1TG4[S>f^Gi^HbX?ZS9ZS7\W:ZV;XW;kmUsw^u}fUaI&28D03;.4:04:039/39/39/28.28.17-17-17-06,06,/5+/5+/5+-2,-2,-2,-2,-2,-2,-2,-2,,1++0*+0**/)*/)+0*+0*,1++2+)3+*4,+5-+5,,6--7.-7,,6+.8-2<16A39D69D47B46A10;+2?-5B09F22=/x=/t?/sB3tD6r=5r=7t=8s>8u@:u@:t?9q?8sA:q@9q@9q@9p?8n?7o>7o>7k92m82l:3l;4l;4h<3g<3c=2c?3^>1dG9cG9T=-N9(M8'@1WQ;PN7KI0OK2]Y>ieJeaDVU7XX<]`CosZz€fdlU=I1-9#2>*4-1=)2>*9E/BN8IU?O[GVbN]hWYdTLWI/u@8s>8u>9u@:t?9o=6p>7sA:q?8p?8p?8n?7o>7m>6n=6m>6k<4l=5m>6k?6j?6gA6eA5bB5dG9[A2^G7^I8N=+F7$G8%>6!LL4GK2DG,DD*MM1\[?baC`aBYY=dgJsw^sy_X`I:D,/;%7C/6>16<26<26<25;15;15;15;15;15;15;14:04:039/39/39/27127127116016016005/05/.3-.3--2,-2,,1+,1++0*+0**1**1*)0))0))0)*1*+2*,3+.5--4,.5-07/4;39A6?F>BJ?;F8:E57B14?.3?+6B.)r>)s@+tD0vE4q?4n<3q<4tB9sA8o?5qA7xH>n>4m>4m>4k?4l=3j>3l=3j>3g?5gA6gA6gC7eC7cC6`C5^D5bK;UB1ZI7`S@RG3C;&E=(FA+AE,BH.AE*<@%?B%NN2_`AijKaaEnqTvzagmSJO94<%4=(=F38>28>48>48>47=37=37=36<28>48>47=37=37=36<26<26<25:449349349338238238227105/05//4..3--2,,1++0*+0*).().().().().(*/)+0*,1+160/4.,1+,1+/4.6;4=BK:4.8/-4--4-,3,gdUgdUheVheVheVheVifWifWifWifWifWifWifWifWifWifWkeWkeWlcZmd[md]mf\mg[jiWkmXimVjoYjs`hthm|wˆ˜˜¦³¹¿ÊÐÓÜãëðööûÿüýÿýÿþÿÿýÿþùþþöýýñúûí÷úçô÷âîóÜåíÕâèÎÛàÀ×Ú»ÖÖ¼Ù×ÂÝ×ÇÞ×ÍåÛÙìààøìðûðöÿõûÿùþÿúýÿûûÿûûÿýüÿþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüýÿüøÿþøÿþûÿþþþþÿüþÿúÿÿùÿÿøþÿúýÿùüÿùùÿýúÿÿøÿÿøûÿõüþðÿÿíÿüéÿñßÿðÝÿïÚñÒ½´z{R>tJ4uH3vI4zM8}P;yL7nA.e7'{M@sD:qB8sD:oC8g;0d8-g=1i?3i?3i?3g?3f>2f>2f>2e?2b@4bB5`C5_C5_C5[D4ZE4WD3XI6OB/\T?oiSc^HMK4IG0IK3>D*?H-@F*48>47=37=37=39?58>48>48>48>48>48>48>47<67<67<66;56;56;55:45:438238216005//4.-2,,1+,1++0*+0**/)*/)+0*,1+-2,-2,05/.3-+0*+0*-2.2718=9;B:@K=@M;@M;=J68E13@,1?(0>'4.:0,6..5.-4-gdUgdUgdUheVheVifWifWifWifWifWifWifWifWifWifWifWkeWldWlcZmd[md]mf\mg[jiWkmXinWiqZgs_drejyt…••£²·½ÈÎÒÛâêïõôùýûüÿýÿþÿÿýÿÿúÿÿøÿÿóþÿñûþë÷úåðõÞæîÖâèÌÙÜ¿ÕÕ¹ÒйÔѾÚÔÈàÙÑêàßôéíþóùÿ÷üÿûÿÿýÿÿþÿÿþüÿþúÿþúþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüýÿþúÿÿúÿÿûÿÿþþþÿýþÿüüÿûüÿûúÿúøÿù÷ÿú÷ÿýøÿÿûÿÿûýÿúýþùùôîÿþöÿýôÿüóÿûîÿ÷çûæÕéÒÀÏ´¡¶š…”uawVCjI6lI6rM;uP>mF7iB3gB2jE5nI9nJ:oK;oK;eA1cB1cB1cB1cB1cB1bC1`C3]F6\G6\G6ZG6ZG6WH5TG4RG3PH3NH2fdM~~frrZVX@JL4GM3A.:>-;>39?59?58>48>47=37=37=38>48>48>48>48>48>48>48>49>89>89>88=78=78=77<67<66;55:449338227105//4./4.-2.-2.,1-+0,+0,,1--2.-2.,1-,1-,1-,1-.210513764;4;G9=L9@O<@O:8F71?2-9-,6--4,,3+fcTfcTgdUheVheVifWjgXjgXifWifWifWifWifWifWifWifWldWldWlcZmd[md]mf\mg[jiWkmXinWiqZgs_bpcgxr‚””£²·ÀËÑÔÝäëðöõúþûüÿýÿþÿÿýÿÿúÿÿøÿÿôÿÿóÿÿïúýèò÷àçðÕâèÌ×Ú½ÑѵÍË´Î˺ÖÏÅÞ×Ñìâã÷îóÿöþÿúÿÿýÿÿþÿÿÿýþÿúþÿùþÿúþÿúþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþüþþþýþÿýþÿýþÿýÿþýÿüþÿúþÿùÿÿ÷ýýóýýõþýøþýùÿþüþþþÿýÿÿþÿþùÿÿüÿÿûüûöóÿøòÿýôÿþñÿýíÿúéÿòà÷äÓçÒ¿Ò»©¹ŸŽŸ„srb|]K}^LtUCaD2W:(Y<*[>,X=*`E2`E2`E2_F2`G3`G3`G3]H3\K7\M:\M:YL9XM9UM8RL6QL6NL5QQ9ikS|€gmqXSY?FL2>G,48>48>48>47=37=38>48>48>48>49?59?5:?9:?9:?9:?99>89>89>88=78=78=77<66;55:4493382382/40.3/-2.,1-+0,+0,+0,+0,+0,,1--10.21/32/32/32-4-3?17F3=L7@O:?N7M:MJ9BC3=@5;A7;A7;A7:@6:@6:@69?58>48>48>49?59?5:@6:@6:@6;@:;@:;@::?9:?99>89>89>8:?9:?99>89>88=78=77<67<6495273162/40-2.,1-+/.+/.,0/,0/-10.21.23.23-12+1-+9*/@-6H2;M7=O7A6>A6>A6=@7=@79?59?59?5:@6:@6:B7:B7:B7;@9;@9;@::?8:?99>79>89>7;@:;@9;@:;@9:?9:?8:?9:?98?87=94;4382160/4..3/.3/.21.21,2.,2.+2++2*,4))6%$6)=!2F+8L1;O6;M5;M5;M58J29K3;M5H&DK*FM+EL*PV4PT3KN/HK,TT8bbFccIZZ@[Y@\ZA][B][B[Y@XV=US:SQ8HF1GD1DA0A?0@>1>>2??5>@5;>59?59?59A69A48C58C58C5:B79A69@88@58?79A69@8:B7:A9:B79@8:B7;B:E=8B:8B:7A88@56>14O<>P::L6@R8EW=FY=DX=@T;5H2+<),6+,3++2*ZgM[hN\hP]iQbjSckTglXhkXghVghVifWifWkeWlfXmeZmgYmgYkhYkg[kg\jf]jf[hfZefVhiWglVfo\erajwnzŠ‰œ«²ºÈÑÐÙàáéìò÷ûøþþùþúúÿøûþóùýïøùë÷øæõôâíìØéæÓåâÏÜ×ÄÒ˹ʿ­Á´¤¹­¡¼¯¦Á¶²ËÁÀÛÐÖæßæûóþý÷ÿþûÿÿþÿþýÿüýÿüýÿüýÿþþþþþþþþþþþþþþþþþþÿþüÿþüÿþüÿþüÿýúÿüùÿüùÿýúÿýùÿþúÿþýÿýüÿüýÿýþÿþÿÿþÿÿýþýûüÿþýÿþûÿüúÿøóøíçòåÝöèßûðêÿúýÿüÿÿýþÿÿýÿÿûýÿüýÿþüýÿýþÿýþÿÿýÿÿþüÿþõÿÿîÿþèÿÿäúöÝýûâäàÇ‹‡lRM0SN0QK+QK+UO/UO/TO1TO1SO2SO2QP4QP4QM2PO3PN5NQ6MO7JP6HM6EM5HQ6EN1BK.?I'BI(FM+JP,KQ-NR/PT1VZ7^bA_bCY\?TWWU>XV=YW>XV=XW;WV:XT9QK3OI3LG4ID1DA2B@3A?3>@5<=59?59?59A67B48C57D37D3:B79A69A68@58@59A69A6:B7:B7:B7:B7:B7;C874>63=40>-3C)9M*BY/Ga1Op;Ln;Li=Fa>BY?F;J@?I>>I9?G8>F7>D8=B;>E>9C;6@74B19I/BV3Pg=XrB^J[}JXuIMhECZ@9O:6G54E2XR6:@6:@69A67B47B46C26C2;C8:B79A69A69A69A6:B7;C8;C8:B7:B7;C8;C8=E:>F;=G<=G?>H=>I9?G8>F7>D8=B;=D=9C;6@74B19I/DX5Ri?[uEZ{FWyFTqEIdA=T:2H3/@.->+6H2@R8L_CReGSgKOcG@W=6I30:/07/-4,YgMZhN\hP^jRblTemVinZjo[mn\lm[mk\mj[nhZnhZoi]oi[liZkhYjfZieZie\ieZig[ghXghVchRajWerao|s{‹ŠŸ¦¢°¹ÁËÔÔÝäéñôòúüôúøñöðíðçèìÞâãÕÚÛÉÒÑ¿ÌɶÉıþ«¿¸¦¼³¢Ê¾®ÓŸÜÐÄæÙÑíâàöìíÿôúÿùÿÿ÷ÿÿúÿÿüÿþýÿýüÿûüþüþýþÿÿþþþþþþþþþþþþþþþþþþÿþüÿþüþýûþýûÿýúÿýúÿýúÿûøÿúöþùõÿýüÿûúýùúþúûþüýÿýþÿþÿÿýþÿüûÿýúÿüúÿøó÷ìæòåÝøêáÿôîÿúýÿüÿÿýþÿÿýÿÿûýÿúýÿþüýÿüýÿýþÿÿþÿÿÿýÿþõÿýìÿûãþúßÿüæÿÿéçâÌŒˆoRL2TO2TM0UN1TN.UO/VQ3VQ3UQ4SO2ON2NM1PL1NM1NL3KN3LN6KQ7KP9JR:LU:IR5JS6OY7SZ9T[9]c?fnG‚’c’¦sŸ±›ª’¡zˆ”pr{\\bFLP7KM5LK6KI4LJ5PK5TN8VP:WQ;VP:SN;QL9LI:IG:GE9CE:=>6:@6:@69A67B47B46C26C2;C8;C8:B79A69A6:B7;C8;C8;C8;C8;C8;C8F;=G<=G?=G<=H8>F7=E6=C7=B;:A:7A95?64B19I/BV3Ne;Uo?Tu@RtAPmAE`=9P6-C.+<*+<)1C-jpegfile +or + djpeg [switches] [jpegfile] >imagefile +The programs read the specified input file, or standard input if none is +named. They always write to standard output (with trace/error messages to +standard error). These conventions are handy for piping images between +programs. + +On most non-Unix systems, you say: + cjpeg [switches] imagefile jpegfile +or + djpeg [switches] jpegfile imagefile +i.e., both the input and output files are named on the command line. This +style is a little more foolproof, and it loses no functionality if you don't +have pipes. (You can get this style on Unix too, if you prefer, by defining +TWO_FILE_COMMANDLINE when you compile the programs; see install.doc.) + +You can also say: + cjpeg [switches] -outfile jpegfile imagefile +or + djpeg [switches] -outfile imagefile jpegfile +This syntax works on all systems, so it is useful for scripts. + +The currently supported image file formats are: PPM (PBMPLUS color format), +PGM (PBMPLUS gray-scale format), BMP, GIF, Targa, and RLE (Utah Raster Toolkit +format). (RLE is supported only if the URT library is available.) +cjpeg recognizes the input image format automatically, with the exception +of some Targa-format files. You have to tell djpeg which format to generate. + +JPEG files are in the defacto standard JFIF file format. There are other, +less widely used JPEG-based file formats, but we don't support them. + +All switch names may be abbreviated; for example, -grayscale may be written +-gray or -gr. Most of the "basic" switches can be abbreviated to as little as +one letter. Upper and lower case are equivalent (-GIF is the same as -gif). +British spellings are also accepted (e.g., -greyscale), though for brevity +these are not mentioned below. + + +CJPEG DETAILS + +The basic command line switches for cjpeg are: + + -quality N Scale quantization tables to adjust image quality. + Quality is 0 (worst) to 100 (best); default is 75. + (See below for more info.) + + -grayscale Create monochrome JPEG file from color input. + Be sure to use this switch when compressing a grayscale + GIF file, because cjpeg isn't bright enough to notice + whether a GIF file uses only shades of gray. By + saying -grayscale, you'll get a smaller JPEG file that + takes less time to process. + + -optimize Perform optimization of entropy encoding parameters. + Without this, default encoding parameters are used. + -optimize usually makes the JPEG file a little smaller, + but cjpeg runs somewhat slower and needs much more + memory. Image quality and speed of decompression are + unaffected by -optimize. + + -progressive Create progressive JPEG file (see below). + + -targa Input file is Targa format. Targa files that contain + an "identification" field will not be automatically + recognized by cjpeg; for such files you must specify + -targa to make cjpeg treat the input as Targa format. + For most Targa files, you won't need this switch. + +The -quality switch lets you trade off compressed file size against quality of +the reconstructed image: the higher the quality setting, the larger the JPEG +file, and the closer the output image will be to the original input. Normally +you want to use the lowest quality setting (smallest file) that decompresses +into something visually indistinguishable from the original image. For this +purpose the quality setting should be between 50 and 95; the default of 75 is +often about right. If you see defects at -quality 75, then go up 5 or 10 +counts at a time until you are happy with the output image. (The optimal +setting will vary from one image to another.) + +-quality 100 will generate a quantization table of all 1's, minimizing loss +in the quantization step (but there is still information loss in subsampling, +as well as roundoff error). This setting is mainly of interest for +experimental purposes. Quality values above about 95 are NOT recommended for +normal use; the compressed file size goes up dramatically for hardly any gain +in output image quality. + +In the other direction, quality values below 50 will produce very small files +of low image quality. Settings around 5 to 10 might be useful in preparing an +index of a large image library, for example. Try -quality 2 (or so) for some +amusing Cubist effects. (Note: quality values below about 25 generate 2-byte +quantization tables, which are considered optional in the JPEG standard. +cjpeg emits a warning message when you give such a quality value, because some +other JPEG programs may be unable to decode the resulting file. Use -baseline +if you need to ensure compatibility at low quality values.) + +The -progressive switch creates a "progressive JPEG" file. In this type of +JPEG file, the data is stored in multiple scans of increasing quality. If the +file is being transmitted over a slow communications link, the decoder can use +the first scan to display a low-quality image very quickly, and can then +improve the display with each subsequent scan. The final image is exactly +equivalent to a standard JPEG file of the same quality setting, and the total +file size is about the same --- often a little smaller. CAUTION: progressive +JPEG is not yet widely implemented, so many decoders will be unable to view a +progressive JPEG file at all. + +Switches for advanced users: + + -dct int Use integer DCT method (default). + -dct fast Use fast integer DCT (less accurate). + -dct float Use floating-point DCT method. + The float method is very slightly more accurate than + the int method, but is much slower unless your machine + has very fast floating-point hardware. Also note that + results of the floating-point method may vary slightly + across machines, while the integer methods should give + the same results everywhere. The fast integer method + is much less accurate than the other two. + + -restart N Emit a JPEG restart marker every N MCU rows, or every + N MCU blocks if "B" is attached to the number. + -restart 0 (the default) means no restart markers. + + -smooth N Smooth the input image to eliminate dithering noise. + N, ranging from 1 to 100, indicates the strength of + smoothing. 0 (the default) means no smoothing. + + -maxmemory N Set limit for amount of memory to use in processing + large images. Value is in thousands of bytes, or + millions of bytes if "M" is attached to the number. + For example, -max 4m selects 4000000 bytes. If more + space is needed, temporary files will be used. + + -verbose Enable debug printout. More -v's give more printout. + or -debug Also, version information is printed at startup. + +The -restart option inserts extra markers that allow a JPEG decoder to +resynchronize after a transmission error. Without restart markers, any damage +to a compressed file will usually ruin the image from the point of the error +to the end of the image; with restart markers, the damage is usually confined +to the portion of the image up to the next restart marker. Of course, the +restart markers occupy extra space. We recommend -restart 1 for images that +will be transmitted across unreliable networks such as Usenet. + +The -smooth option filters the input to eliminate fine-scale noise. This is +often useful when converting GIF files to JPEG: a moderate smoothing factor of +10 to 50 gets rid of dithering patterns in the input file, resulting in a +smaller JPEG file and a better-looking image. Too large a smoothing factor +will visibly blur the image, however. + +Switches for wizards: + + -baseline Force a baseline JPEG file to be generated. This + clamps quantization values to 8 bits even at low + quality settings. + + -qtables file Use the quantization tables given in the specified + text file. + + -qslots N[,...] Select which quantization table to use for each color + component. + + -sample HxV[,...] Set JPEG sampling factors for each color component. + + -scans file Use the scan script given in the specified text file. + +The "wizard" switches are intended for experimentation with JPEG. If you +don't know what you are doing, DON'T USE THEM. These switches are documented +further in the file wizard.doc. + + +DJPEG DETAILS + +The basic command line switches for djpeg are: + + -colors N Reduce image to at most N colors. This reduces the + or -quantize N number of colors used in the output image, so that it + can be displayed on a colormapped display or stored in + a colormapped file format. For example, if you have + an 8-bit display, you'd need to reduce to 256 or fewer + colors. (-colors is the recommended name, -quantize + is provided only for backwards compatibility.) + + -fast Select recommended processing options for fast, low + quality output. (The default options are chosen for + highest quality output.) Currently, this is equivalent + to "-dct fast -nosmooth -onepass -dither ordered". + + -grayscale Force gray-scale output even if JPEG file is color. + Useful for viewing on monochrome displays; also, + djpeg runs noticeably faster in this mode. + + -scale M/N Scale the output image by a factor M/N. Currently + the scale factor must be 1/1, 1/2, 1/4, or 1/8. + Scaling is handy if the image is larger than your + screen; also, djpeg runs much faster when scaling + down the output. + + -bmp Select BMP output format (Windows flavor). 8-bit + colormapped format is emitted if -colors or -grayscale + is specified, or if the JPEG file is gray-scale; + otherwise, 24-bit full-color format is emitted. + + -gif Select GIF output format. Since GIF does not support + more than 256 colors, -colors 256 is assumed (unless + you specify a smaller number of colors). If you + specify -fast, the default number of colors is 216. + + -os2 Select BMP output format (OS/2 1.x flavor). 8-bit + colormapped format is emitted if -colors or -grayscale + is specified, or if the JPEG file is gray-scale; + otherwise, 24-bit full-color format is emitted. + + -pnm Select PBMPLUS (PPM/PGM) output format (this is the + default format). PGM is emitted if the JPEG file is + gray-scale or if -grayscale is specified; otherwise + PPM is emitted. + + -rle Select RLE output format. (Requires URT library.) + + -targa Select Targa output format. Gray-scale format is + emitted if the JPEG file is gray-scale or if + -grayscale is specified; otherwise, colormapped format + is emitted if -colors is specified; otherwise, 24-bit + full-color format is emitted. + +Switches for advanced users: + + -dct int Use integer DCT method (default). + -dct fast Use fast integer DCT (less accurate). + -dct float Use floating-point DCT method. + The float method is very slightly more accurate than + the int method, but is much slower unless your machine + has very fast floating-point hardware. Also note that + results of the floating-point method may vary slightly + across machines, while the integer methods should give + the same results everywhere. The fast integer method + is much less accurate than the other two. + + -dither fs Use Floyd-Steinberg dithering in color quantization. + -dither ordered Use ordered dithering in color quantization. + -dither none Do not use dithering in color quantization. + By default, Floyd-Steinberg dithering is applied when + quantizing colors; this is slow but usually produces + the best results. Ordered dither is a compromise + between speed and quality; no dithering is fast but + usually looks awful. Note that these switches have + no effect unless color quantization is being done. + Ordered dither is only available in -onepass mode. + + -map FILE Quantize to the colors used in the specified image + file. This is useful for producing multiple files + with identical color maps, or for forcing a predefined + set of colors to be used. The FILE must be a GIF + or PPM file. This option overrides -colors and + -onepass. + + -nosmooth Use a faster, lower-quality upsampling routine. + + -onepass Use one-pass instead of two-pass color quantization. + The one-pass method is faster and needs less memory, + but it produces a lower-quality image. -onepass is + ignored unless you also say -colors N. Also, + the one-pass method is always used for gray-scale + output (the two-pass method is no improvement then). + + -maxmemory N Set limit for amount of memory to use in processing + large images. Value is in thousands of bytes, or + millions of bytes if "M" is attached to the number. + For example, -max 4m selects 4000000 bytes. If more + space is needed, temporary files will be used. + + -verbose Enable debug printout. More -v's give more printout. + or -debug Also, version information is printed at startup. + + +HINTS FOR CJPEG + +Color GIF files are not the ideal input for JPEG; JPEG is really intended for +compressing full-color (24-bit) images. In particular, don't try to convert +cartoons, line drawings, and other images that have only a few distinct +colors. GIF works great on these, JPEG does not. If you want to convert a +GIF to JPEG, you should experiment with cjpeg's -quality and -smooth options +to get a satisfactory conversion. -smooth 10 or so is often helpful. + +Avoid running an image through a series of JPEG compression/decompression +cycles. Image quality loss will accumulate; after ten or so cycles the image +may be noticeably worse than it was after one cycle. It's best to use a +lossless format while manipulating an image, then convert to JPEG format when +you are ready to file the image away. + +The -optimize option to cjpeg is worth using when you are making a "final" +version for posting or archiving. It's also a win when you are using low +quality settings to make very small JPEG files; the percentage improvement +is often a lot more than it is on larger files. (At present, -optimize +mode is always selected when generating progressive JPEG files.) + + +HINTS FOR DJPEG + +To get a quick preview of an image, use the -grayscale and/or -scale switches. +"-grayscale -scale 1/8" is the fastest case. + +Several options are available that trade off image quality to gain speed. +"-fast" turns on the recommended settings. + +"-dct fast" and/or "-nosmooth" gain speed at a small sacrifice in quality. +When producing a color-quantized image, "-onepass -dither ordered" is fast but +much lower quality than the default behavior. "-dither none" may give +acceptable results in two-pass mode, but is seldom tolerable in one-pass mode. + +If you are fortunate enough to have very fast floating point hardware, +"-dct float" may be even faster than "-dct fast". But on most machines +"-dct float" is slower than "-dct int"; in this case it is not worth using, +because its theoretical accuracy advantage is too small to be significant +in practice. + +Two-pass color quantization requires a good deal of memory; on MS-DOS machines +it may run out of memory even with -maxmemory 0. In that case you can still +decompress, with some loss of image quality, by specifying -onepass for +one-pass quantization. + + +HINTS FOR BOTH PROGRAMS + +If more space is needed than will fit in the available main memory (as +determined by -maxmemory), temporary files will be used. (MS-DOS versions +will try to get extended or expanded memory first.) The temporary files are +often rather large: in typical cases they occupy three bytes per pixel, for +example 3*800*600 = 1.44Mb for an 800x600 image. If you don't have enough +free disk space, leave out -progressive and -optimize (for cjpeg) or specify +-onepass (for djpeg). + +On MS-DOS, the temporary files are created in the directory named by the TMP +or TEMP environment variable, or in the current directory if neither of those +exist. Amiga implementations put the temp files in the directory named by +JPEGTMP:, so be sure to assign JPEGTMP: to a disk partition with adequate free +space. + +The default memory usage limit (-maxmemory) is set when the software is +compiled. If you get an "insufficient memory" error, try specifying a smaller +-maxmemory value, even -maxmemory 0 to use the absolute minimum space. You +may want to recompile with a smaller default value if this happens often. + +On machines that have "environment" variables, you can define the environment +variable JPEGMEM to set the default memory limit. The value is specified as +described for the -maxmemory switch. JPEGMEM overrides the default value +specified when the program was compiled, and itself is overridden by an +explicit -maxmemory switch. + +On MS-DOS machines, -maxmemory is the amount of main (conventional) memory to +use. (Extended or expanded memory is also used if available.) Most +DOS-specific versions of this software do their own memory space estimation +and do not need you to specify -maxmemory. + + +JPEGTRAN + +jpegtran translates JPEG files from one variant of JPEG to another, for +example from baseline JPEG to progressive JPEG or vice versa. The +transformation is lossless: no image degradation occurs, which would not +be true if you used djpeg followed by cjpeg. However, you cannot alter +the image quality, because that would not be a lossless operation. + +jpegtran operates similarly to cjpeg, except that it reads a JPEG file +and writes another JPEG file. + +jpegtran accepts a subset of the switches recognized by cjpeg: + -outfile filename + -optimize + -progressive + -restart N + -scans file + -maxmemory N + -verbose + -debug +See the previous discussion of cjpeg for details about these switches. + +If you specify no switches, you get a plain baseline-JPEG output file. + + +THE COMMENT UTILITIES + +The JPEG standard allows "comment" (COM) blocks to occur within a JPEG file. +Although the standard doesn't actually define what COM blocks are for, they +are widely used to hold user-supplied text strings. This lets you add +annotations, titles, index terms, etc to your JPEG files, and later retrieve +them as text. COM blocks do not interfere with the image stored in the JPEG +file. The maximum size of a COM block is 64K, but you can have as many of +them as you like in one JPEG file. + +We provide two utility programs to display COM block contents and add COM +blocks to a JPEG file. + +rdjpgcom searches a JPEG file and prints the contents of any COM blocks on +standard output. The command line syntax is + rdjpgcom [-verbose] [inputfilename] +The switch "-verbose" (or just "-v") causes rdjpgcom to also display the JPEG +image dimensions. If you omit the input file name from the command line, +the JPEG file is read from standard input. (This may not work on some +operating systems, if binary data can't be read from stdin.) + +wrjpgcom adds a COM block, containing text you provide, to a JPEG file. +Ordinarily, the COM block is added after any existing COM blocks, but you +can delete the old COM blocks if you wish. wrjpgcom produces a new JPEG +file; it does not modify the input file. DO NOT try to overwrite the input +file by directing wrjpgcom's output back into it; on most systems this will +just destroy your file. + +The command line syntax for wrjpgcom is similar to cjpeg's. On Unix-like +systems, it is + wrjpgcom [switches] [inputfilename] +The output file is written to standard output. The input file comes from +the named file, or from standard input if no input file is named. + +On most non-Unix systems, the syntax is + wrjpgcom [switches] inputfilename outputfilename +where both input and output file names must be given explicitly. + +wrjpgcom understands three switches: + -replace Delete any existing COM blocks from the file. + -comment "Comment text" Supply new COM text on command line. + -cfile name Read text for new COM block from named file. +(Switch names can be abbreviated.) If you have only one line of comment text +to add, you can provide it on the command line with -comment. The comment +text must be surrounded with quotes so that it is treated as a single +argument. Longer comments can be read from a text file. + +If you give neither -comment nor -cfile, then wrjpgcom will read the comment +text from standard input. (In this case an input image file name MUST be +supplied, so that the source JPEG file comes from somewhere else.) You can +enter multiple lines, up to 64KB worth. Type an end-of-file indicator +(usually control-D or control-Z) to terminate the comment text entry. + +wrjpgcom will not add a COM block if the provided comment string is empty. +Therefore -replace -comment "" can be used to delete all COM blocks from a +file. + +These utility programs do not depend on the IJG JPEG library. In +particular, the source code for rdjpgcom is intended as an illustration of +the minimum amount of code required to parse a JPEG file header correctly. diff --git a/gs/jpeg/wizard.doc b/gs/jpeg/wizard.doc new file mode 100644 index 000000000..54170b227 --- /dev/null +++ b/gs/jpeg/wizard.doc @@ -0,0 +1,211 @@ +Advanced usage instructions for the Independent JPEG Group's JPEG software +========================================================================== + +This file describes cjpeg's "switches for wizards". + +The "wizard" switches are intended for experimentation with JPEG by persons +who are reasonably knowledgeable about the JPEG standard. If you don't know +what you are doing, DON'T USE THESE SWITCHES. You'll likely produce files +with worse image quality and/or poorer compression than you'd get from the +default settings. Furthermore, these switches must be used with caution +when making files intended for general use, because not all JPEG decoders +will support unusual JPEG parameter settings. + + +Quantization Table Adjustment +----------------------------- + +Ordinarily, cjpeg starts with a default set of tables (the same ones given +as examples in the JPEG standard) and scales them up or down according to +the -quality setting. The details of the scaling algorithm can be found in +jcparam.c. At very low quality settings, some quantization table entries +can get scaled up to values exceeding 255. Although 2-byte quantization +values are supported by the IJG software, this feature is not in baseline +JPEG and is not supported by all implementations. If you need to ensure +wide compatibility of low-quality files, you can constrain the scaled +quantization values to no more than 255 by giving the -baseline switch. +Note that use of -baseline will result in poorer quality for the same file +size, since more bits than necessary are expended on higher AC coefficients. + +You can substitute a different set of quantization values by using the +-qtables switch: + + -qtables file Use the quantization tables given in the named file. + +The specified file should be a text file containing decimal quantization +values. The file should contain one to four tables, each of 64 elements. +The tables are implicitly numbered 0,1,etc. in order of appearance. Table +entries appear in normal array order (NOT in the zigzag order in which they +will be stored in the JPEG file). + +Quantization table files are free format, in that arbitrary whitespace can +appear between numbers. Also, comments can be included: a comment starts +with '#' and extends to the end of the line. Here is an example file that +duplicates the default quantization tables: + + # Quantization tables given in JPEG spec, section K.1 + + # This is table 0 (the luminance table): + 16 11 10 16 24 40 51 61 + 12 12 14 19 26 58 60 55 + 14 13 16 24 40 57 69 56 + 14 17 22 29 51 87 80 62 + 18 22 37 56 68 109 103 77 + 24 35 55 64 81 104 113 92 + 49 64 78 87 103 121 120 101 + 72 92 95 98 112 100 103 99 + + # This is table 1 (the chrominance table): + 17 18 24 47 99 99 99 99 + 18 21 26 66 99 99 99 99 + 24 26 56 99 99 99 99 99 + 47 66 99 99 99 99 99 99 + 99 99 99 99 99 99 99 99 + 99 99 99 99 99 99 99 99 + 99 99 99 99 99 99 99 99 + 99 99 99 99 99 99 99 99 + +If the -qtables switch is used without -quality, then the specified tables +are used exactly as-is. If both -qtables and -quality are used, then the +tables taken from the file are scaled in the same fashion that the default +tables would be scaled for that quality setting. If -baseline appears, then +the quantization values are constrained to the range 1-255. + +By default, cjpeg will use quantization table 0 for luminance components and +table 1 for chrominance components. To override this choice, use the -qslots +switch: + + -qslots N[,...] Select which quantization table to use for + each color component. + +The -qslots switch specifies a quantization table number for each color +component, in the order in which the components appear in the JPEG SOF marker. +For example, to create a separate table for each of Y,Cb,Cr, you could +provide a -qtables file that defines three quantization tables and say +"-qslots 0,1,2". If -qslots gives fewer table numbers than there are color +components, then the last table number is repeated as necessary. + + +Sampling Factor Adjustment +-------------------------- + +By default, cjpeg uses 2:1 horizontal and vertical downsampling when +compressing YCbCr data, and no downsampling for all other color spaces. +You can override this default with the -sample switch: + + -sample HxV[,...] Set JPEG sampling factors for each color + component. + +The -sample switch specifies the JPEG sampling factors for each color +component, in the order in which they appear in the JPEG SOF marker. +If you specify fewer HxV pairs than there are components, the remaining +components are set to 1x1 sampling. For example, the default YCbCr setting +is equivalent to "-sample 2x2,1x1,1x1", which can be abbreviated to +"-sample 2x2". + +There are still some JPEG decoders in existence that support only 2x1 +sampling (also called 4:2:2 sampling). Compatibility with such decoders can +be achieved by specifying "-sample 2x1". This is not recommended unless +really necessary, since it increases file size and encoding/decoding time +with very little quality gain. + + +Multiple Scan / Progression Control +----------------------------------- + +By default, cjpeg emits a single-scan sequential JPEG file. The +-progressive switch generates a progressive JPEG file using a default series +of progression parameters. You can create multiple-scan sequential JPEG +files or progressive JPEG files with custom progression parameters by using +the -scans switch: + + -scans file Use the scan sequence given in the named file. + +The specified file should be a text file containing a "scan script". +The script specifies the contents and ordering of the scans to be emitted. +Each entry in the script defines one scan. A scan definition specifies +the components to be included in the scan, and for progressive JPEG it also +specifies the progression parameters Ss,Se,Ah,Al for the scan. Scan +definitions are separated by semicolons (';'). A semicolon after the last +scan definition is optional. + +Each scan definition contains one to four component indexes, optionally +followed by a colon (':') and the four progressive-JPEG parameters. The +component indexes denote which color component(s) are to be transmitted in +the scan. Components are numbered in the order in which they appear in the +JPEG SOF marker, with the first component being numbered 0. (Note that these +indexes are not the "component ID" codes assigned to the components, just +positional indexes.) + +The progression parameters for each scan are: + Ss Zigzag index of first coefficient included in scan + Se Zigzag index of last coefficient included in scan + Ah Zero for first scan of a coefficient, else Al of prior scan + Al Successive approximation low bit position for scan +If the progression parameters are omitted, the values 0,63,0,0 are used, +producing a sequential JPEG file. cjpeg automatically determines whether +the script represents a progressive or sequential file, by observing whether +Ss and Se values other than 0 and 63 appear. (The -progressive switch is +not needed to specify this; in fact, it is ignored when -scans appears.) +The scan script must meet the JPEG restrictions on progression sequences. +(cjpeg checks that the spec's requirements are obeyed.) + +Scan script files are free format, in that arbitrary whitespace can appear +between numbers and around punctuation. Also, comments can be included: a +comment starts with '#' and extends to the end of the line. For additional +legibility, commas or dashes can be placed between values. (Actually, any +single punctuation character other than ':' or ';' can be inserted.) For +example, the following two scan definitions are equivalent: + 0 1 2: 0 63 0 0; + 0,1,2 : 0-63, 0,0 ; + +Here is an example of a scan script that generates a partially interleaved +sequential JPEG file: + + 0; # Y only in first scan + 1 2; # Cb and Cr in second scan + +Here is an example of a progressive scan script using only spectral selection +(no successive approximation): + + # Interleaved DC scan for Y,Cb,Cr: + 0,1,2: 0-0, 0, 0 ; + # AC scans: + 0: 1-2, 0, 0 ; # First two Y AC coefficients + 0: 3-5, 0, 0 ; # Three more + 1: 1-63, 0, 0 ; # All AC coefficients for Cb + 2: 1-63, 0, 0 ; # All AC coefficients for Cr + 0: 6-9, 0, 0 ; # More Y coefficients + 0: 10-63, 0, 0 ; # Remaining Y coefficients + +Here is an example of a successive-approximation script. This is equivalent +to the default script used by "cjpeg -progressive" for YCbCr images: + + # Initial DC scan for Y,Cb,Cr (lowest bit not sent) + 0,1,2: 0-0, 0, 1 ; + # First AC scan: send first 5 Y AC coefficients, minus 2 lowest bits: + 0: 1-5, 0, 2 ; + # Send all Cr,Cb AC coefficients, minus lowest bit: + # (chroma data is usually too small to be worth subdividing further; + # but note we send Cr first since eye is least sensitive to Cb) + 2: 1-63, 0, 1 ; + 1: 1-63, 0, 1 ; + # Send remaining Y AC coefficients, minus 2 lowest bits: + 0: 6-63, 0, 2 ; + # Send next-to-lowest bit of all Y AC coefficients: + 0: 1-63, 2, 1 ; + # At this point we've sent all but the lowest bit of all coefficients. + # Send lowest bit of DC coefficients + 0,1,2: 0-0, 1, 0 ; + # Send lowest bit of AC coefficients + 2: 1-63, 1, 0 ; + 1: 1-63, 1, 0 ; + # Y AC lowest bit scan is last; it's usually the largest scan + 0: 1-63, 1, 0 ; + +It may be worth pointing out that this script is tuned for quality settings +of around 50 to 75. For lower quality settings, you'd probably want to use +a script with fewer stages of successive approximation (otherwise the +initial scans will be really bad). For higher quality settings, you might +want to use more stages of successive approximation (so that the initial +scans are not too large). diff --git a/gs/jpeg/wrbmp.c b/gs/jpeg/wrbmp.c new file mode 100644 index 000000000..3283b0f15 --- /dev/null +++ b/gs/jpeg/wrbmp.c @@ -0,0 +1,442 @@ +/* + * wrbmp.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to write output images in Microsoft "BMP" + * format (MS Windows 3.x and OS/2 1.x flavors). + * Either 8-bit colormapped or 24-bit full-color format can be written. + * No compression is supported. + * + * These routines may need modification for non-Unix environments or + * specialized applications. As they stand, they assume output to + * an ordinary stdio stream. + * + * This code contributed by James Arthur Boucher. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ + +#ifdef BMP_SUPPORTED + + +/* + * To support 12-bit JPEG data, we'd have to scale output down to 8 bits. + * This is not yet implemented. + */ + +#if BITS_IN_JSAMPLE != 8 + Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */ +#endif + +/* + * Since BMP stores scanlines bottom-to-top, we have to invert the image + * from JPEG's top-to-bottom order. To do this, we save the outgoing data + * in a virtual array during put_pixel_row calls, then actually emit the + * BMP file during finish_output. The virtual array contains one JSAMPLE per + * pixel if the output is grayscale or colormapped, three if it is full color. + */ + +/* Private version of data destination object */ + +typedef struct { + struct djpeg_dest_struct pub; /* public fields */ + + boolean is_os2; /* saves the OS2 format request flag */ + + jvirt_sarray_ptr whole_image; /* needed to reverse row order */ + JDIMENSION data_width; /* JSAMPLEs per row */ + JDIMENSION row_width; /* physical width of one row in the BMP file */ + int pad_bytes; /* number of padding bytes needed per row */ + JDIMENSION cur_output_row; /* next row# to write to virtual array */ +} bmp_dest_struct; + +typedef bmp_dest_struct * bmp_dest_ptr; + + +/* Forward declarations */ +LOCAL(void) write_colormap + JPP((j_decompress_ptr cinfo, bmp_dest_ptr dest, + int map_colors, int map_entry_size)); + + +/* + * Write some pixel data. + * In this module rows_supplied will always be 1. + */ + +METHODDEF(void) +put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied) +/* This version is for writing 24-bit pixels */ +{ + bmp_dest_ptr dest = (bmp_dest_ptr) dinfo; + JSAMPARRAY image_ptr; + register JSAMPROW inptr, outptr; + register JDIMENSION col; + int pad; + + /* Access next row in virtual array */ + image_ptr = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, dest->whole_image, + dest->cur_output_row, (JDIMENSION) 1, TRUE); + dest->cur_output_row++; + + /* Transfer data. Note destination values must be in BGR order + * (even though Microsoft's own documents say the opposite). + */ + inptr = dest->pub.buffer[0]; + outptr = image_ptr[0]; + for (col = cinfo->output_width; col > 0; col--) { + outptr[2] = *inptr++; /* can omit GETJSAMPLE() safely */ + outptr[1] = *inptr++; + outptr[0] = *inptr++; + outptr += 3; + } + + /* Zero out the pad bytes. */ + pad = dest->pad_bytes; + while (--pad >= 0) + *outptr++ = 0; +} + +METHODDEF(void) +put_gray_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied) +/* This version is for grayscale OR quantized color output */ +{ + bmp_dest_ptr dest = (bmp_dest_ptr) dinfo; + JSAMPARRAY image_ptr; + register JSAMPROW inptr, outptr; + register JDIMENSION col; + int pad; + + /* Access next row in virtual array */ + image_ptr = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, dest->whole_image, + dest->cur_output_row, (JDIMENSION) 1, TRUE); + dest->cur_output_row++; + + /* Transfer data. */ + inptr = dest->pub.buffer[0]; + outptr = image_ptr[0]; + for (col = cinfo->output_width; col > 0; col--) { + *outptr++ = *inptr++; /* can omit GETJSAMPLE() safely */ + } + + /* Zero out the pad bytes. */ + pad = dest->pad_bytes; + while (--pad >= 0) + *outptr++ = 0; +} + + +/* + * Startup: normally writes the file header. + * In this module we may as well postpone everything until finish_output. + */ + +METHODDEF(void) +start_output_bmp (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) +{ + /* no work here */ +} + + +/* + * Finish up at the end of the file. + * + * Here is where we really output the BMP file. + * + * First, routines to write the Windows and OS/2 variants of the file header. + */ + +LOCAL(void) +write_bmp_header (j_decompress_ptr cinfo, bmp_dest_ptr dest) +/* Write a Windows-style BMP file header, including colormap if needed */ +{ + char bmpfileheader[14]; + char bmpinfoheader[40]; +#define PUT_2B(array,offset,value) \ + (array[offset] = (char) ((value) & 0xFF), \ + array[offset+1] = (char) (((value) >> 8) & 0xFF)) +#define PUT_4B(array,offset,value) \ + (array[offset] = (char) ((value) & 0xFF), \ + array[offset+1] = (char) (((value) >> 8) & 0xFF), \ + array[offset+2] = (char) (((value) >> 16) & 0xFF), \ + array[offset+3] = (char) (((value) >> 24) & 0xFF)) + INT32 headersize, bfSize; + int bits_per_pixel, cmap_entries; + + /* Compute colormap size and total file size */ + if (cinfo->out_color_space == JCS_RGB) { + if (cinfo->quantize_colors) { + /* Colormapped RGB */ + bits_per_pixel = 8; + cmap_entries = 256; + } else { + /* Unquantized, full color RGB */ + bits_per_pixel = 24; + cmap_entries = 0; + } + } else { + /* Grayscale output. We need to fake a 256-entry colormap. */ + bits_per_pixel = 8; + cmap_entries = 256; + } + /* File size */ + headersize = 14 + 40 + cmap_entries * 4; /* Header and colormap */ + bfSize = headersize + (INT32) dest->row_width * (INT32) cinfo->output_height; + + /* Set unused fields of header to 0 */ + MEMZERO(bmpfileheader, SIZEOF(bmpfileheader)); + MEMZERO(bmpinfoheader, SIZEOF(bmpinfoheader)); + + /* Fill the file header */ + bmpfileheader[0] = 0x42; /* first 2 bytes are ASCII 'B', 'M' */ + bmpfileheader[1] = 0x4D; + PUT_4B(bmpfileheader, 2, bfSize); /* bfSize */ + /* we leave bfReserved1 & bfReserved2 = 0 */ + PUT_4B(bmpfileheader, 10, headersize); /* bfOffBits */ + + /* Fill the info header (Microsoft calls this a BITMAPINFOHEADER) */ + PUT_2B(bmpinfoheader, 0, 40); /* biSize */ + PUT_4B(bmpinfoheader, 4, cinfo->output_width); /* biWidth */ + PUT_4B(bmpinfoheader, 8, cinfo->output_height); /* biHeight */ + PUT_2B(bmpinfoheader, 12, 1); /* biPlanes - must be 1 */ + PUT_2B(bmpinfoheader, 14, bits_per_pixel); /* biBitCount */ + /* we leave biCompression = 0, for none */ + /* we leave biSizeImage = 0; this is correct for uncompressed data */ + if (cinfo->density_unit == 2) { /* if have density in dots/cm, then */ + PUT_4B(bmpinfoheader, 24, (INT32) (cinfo->X_density*100)); /* XPels/M */ + PUT_4B(bmpinfoheader, 28, (INT32) (cinfo->Y_density*100)); /* XPels/M */ + } + PUT_2B(bmpinfoheader, 32, cmap_entries); /* biClrUsed */ + /* we leave biClrImportant = 0 */ + + if (JFWRITE(dest->pub.output_file, bmpfileheader, 14) != (size_t) 14) + ERREXIT(cinfo, JERR_FILE_WRITE); + if (JFWRITE(dest->pub.output_file, bmpinfoheader, 40) != (size_t) 40) + ERREXIT(cinfo, JERR_FILE_WRITE); + + if (cmap_entries > 0) + write_colormap(cinfo, dest, cmap_entries, 4); +} + + +LOCAL(void) +write_os2_header (j_decompress_ptr cinfo, bmp_dest_ptr dest) +/* Write an OS2-style BMP file header, including colormap if needed */ +{ + char bmpfileheader[14]; + char bmpcoreheader[12]; + INT32 headersize, bfSize; + int bits_per_pixel, cmap_entries; + + /* Compute colormap size and total file size */ + if (cinfo->out_color_space == JCS_RGB) { + if (cinfo->quantize_colors) { + /* Colormapped RGB */ + bits_per_pixel = 8; + cmap_entries = 256; + } else { + /* Unquantized, full color RGB */ + bits_per_pixel = 24; + cmap_entries = 0; + } + } else { + /* Grayscale output. We need to fake a 256-entry colormap. */ + bits_per_pixel = 8; + cmap_entries = 256; + } + /* File size */ + headersize = 14 + 12 + cmap_entries * 3; /* Header and colormap */ + bfSize = headersize + (INT32) dest->row_width * (INT32) cinfo->output_height; + + /* Set unused fields of header to 0 */ + MEMZERO(bmpfileheader, SIZEOF(bmpfileheader)); + MEMZERO(bmpcoreheader, SIZEOF(bmpcoreheader)); + + /* Fill the file header */ + bmpfileheader[0] = 0x42; /* first 2 bytes are ASCII 'B', 'M' */ + bmpfileheader[1] = 0x4D; + PUT_4B(bmpfileheader, 2, bfSize); /* bfSize */ + /* we leave bfReserved1 & bfReserved2 = 0 */ + PUT_4B(bmpfileheader, 10, headersize); /* bfOffBits */ + + /* Fill the info header (Microsoft calls this a BITMAPCOREHEADER) */ + PUT_2B(bmpcoreheader, 0, 12); /* bcSize */ + PUT_2B(bmpcoreheader, 4, cinfo->output_width); /* bcWidth */ + PUT_2B(bmpcoreheader, 6, cinfo->output_height); /* bcHeight */ + PUT_2B(bmpcoreheader, 8, 1); /* bcPlanes - must be 1 */ + PUT_2B(bmpcoreheader, 10, bits_per_pixel); /* bcBitCount */ + + if (JFWRITE(dest->pub.output_file, bmpfileheader, 14) != (size_t) 14) + ERREXIT(cinfo, JERR_FILE_WRITE); + if (JFWRITE(dest->pub.output_file, bmpcoreheader, 12) != (size_t) 12) + ERREXIT(cinfo, JERR_FILE_WRITE); + + if (cmap_entries > 0) + write_colormap(cinfo, dest, cmap_entries, 3); +} + + +/* + * Write the colormap. + * Windows uses BGR0 map entries; OS/2 uses BGR entries. + */ + +LOCAL(void) +write_colormap (j_decompress_ptr cinfo, bmp_dest_ptr dest, + int map_colors, int map_entry_size) +{ + JSAMPARRAY colormap = cinfo->colormap; + int num_colors = cinfo->actual_number_of_colors; + FILE * outfile = dest->pub.output_file; + int i; + + if (colormap != NULL) { + if (cinfo->out_color_components == 3) { + /* Normal case with RGB colormap */ + for (i = 0; i < num_colors; i++) { + putc(GETJSAMPLE(colormap[2][i]), outfile); + putc(GETJSAMPLE(colormap[1][i]), outfile); + putc(GETJSAMPLE(colormap[0][i]), outfile); + if (map_entry_size == 4) + putc(0, outfile); + } + } else { + /* Grayscale colormap (only happens with grayscale quantization) */ + for (i = 0; i < num_colors; i++) { + putc(GETJSAMPLE(colormap[0][i]), outfile); + putc(GETJSAMPLE(colormap[0][i]), outfile); + putc(GETJSAMPLE(colormap[0][i]), outfile); + if (map_entry_size == 4) + putc(0, outfile); + } + } + } else { + /* If no colormap, must be grayscale data. Generate a linear "map". */ + for (i = 0; i < 256; i++) { + putc(i, outfile); + putc(i, outfile); + putc(i, outfile); + if (map_entry_size == 4) + putc(0, outfile); + } + } + /* Pad colormap with zeros to ensure specified number of colormap entries */ + if (i > map_colors) + ERREXIT1(cinfo, JERR_TOO_MANY_COLORS, i); + for (; i < map_colors; i++) { + putc(0, outfile); + putc(0, outfile); + putc(0, outfile); + if (map_entry_size == 4) + putc(0, outfile); + } +} + + +METHODDEF(void) +finish_output_bmp (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) +{ + bmp_dest_ptr dest = (bmp_dest_ptr) dinfo; + register FILE * outfile = dest->pub.output_file; + JSAMPARRAY image_ptr; + register JSAMPROW data_ptr; + JDIMENSION row; + register JDIMENSION col; + cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; + + /* Write the header and colormap */ + if (dest->is_os2) + write_os2_header(cinfo, dest); + else + write_bmp_header(cinfo, dest); + + /* Write the file body from our virtual array */ + for (row = cinfo->output_height; row > 0; row--) { + if (progress != NULL) { + progress->pub.pass_counter = (long) (cinfo->output_height - row); + progress->pub.pass_limit = (long) cinfo->output_height; + (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); + } + image_ptr = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, dest->whole_image, row-1, (JDIMENSION) 1, FALSE); + data_ptr = image_ptr[0]; + for (col = dest->row_width; col > 0; col--) { + putc(GETJSAMPLE(*data_ptr), outfile); + data_ptr++; + } + } + if (progress != NULL) + progress->completed_extra_passes++; + + /* Make sure we wrote the output file OK */ + fflush(outfile); + if (ferror(outfile)) + ERREXIT(cinfo, JERR_FILE_WRITE); +} + + +/* + * The module selection routine for BMP format output. + */ + +GLOBAL(djpeg_dest_ptr) +jinit_write_bmp (j_decompress_ptr cinfo, boolean is_os2) +{ + bmp_dest_ptr dest; + JDIMENSION row_width; + + /* Create module interface object, fill in method pointers */ + dest = (bmp_dest_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(bmp_dest_struct)); + dest->pub.start_output = start_output_bmp; + dest->pub.finish_output = finish_output_bmp; + dest->is_os2 = is_os2; + + if (cinfo->out_color_space == JCS_GRAYSCALE) { + dest->pub.put_pixel_rows = put_gray_rows; + } else if (cinfo->out_color_space == JCS_RGB) { + if (cinfo->quantize_colors) + dest->pub.put_pixel_rows = put_gray_rows; + else + dest->pub.put_pixel_rows = put_pixel_rows; + } else { + ERREXIT(cinfo, JERR_BMP_COLORSPACE); + } + + /* Calculate output image dimensions so we can allocate space */ + jpeg_calc_output_dimensions(cinfo); + + /* Determine width of rows in the BMP file (padded to 4-byte boundary). */ + row_width = cinfo->output_width * cinfo->output_components; + dest->data_width = row_width; + while ((row_width & 3) != 0) row_width++; + dest->row_width = row_width; + dest->pad_bytes = (int) (row_width - dest->data_width); + + /* Allocate space for inversion array, prepare for write pass */ + dest->whole_image = (*cinfo->mem->request_virt_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, + row_width, cinfo->output_height, (JDIMENSION) 1); + dest->cur_output_row = 0; + if (cinfo->progress != NULL) { + cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; + progress->total_extra_passes++; /* count file input as separate pass */ + } + + /* Create decompressor output buffer. */ + dest->pub.buffer = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, row_width, (JDIMENSION) 1); + dest->pub.buffer_height = 1; + + return (djpeg_dest_ptr) dest; +} + +#endif /* BMP_SUPPORTED */ diff --git a/gs/jpeg/wrgif.c b/gs/jpeg/wrgif.c new file mode 100644 index 000000000..85cfaa8bd --- /dev/null +++ b/gs/jpeg/wrgif.c @@ -0,0 +1,505 @@ +/* + * wrgif.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + ************************************************************************** + * WARNING: You will need an LZW patent license from Unisys in order to * + * use this file legally in any commercial or shareware application. * + ************************************************************************** + * + * This file contains routines to write output images in GIF format. + * + * These routines may need modification for non-Unix environments or + * specialized applications. As they stand, they assume output to + * an ordinary stdio stream. + */ + +/* + * This code is loosely based on ppmtogif from the PBMPLUS distribution + * of Feb. 1991. That file contains the following copyright notice: + * Based on GIFENCODE by David Rowley . + * Lempel-Ziv compression based on "compress" by Spencer W. Thomas et al. + * Copyright (C) 1989 by Jef Poskanzer. + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, provided + * that the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation. This software is provided "as is" without express or + * implied warranty. + * + * We are also required to state that + * "The Graphics Interchange Format(c) is the Copyright property of + * CompuServe Incorporated. GIF(sm) is a Service Mark property of + * CompuServe Incorporated." + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ + +#ifdef GIF_SUPPORTED + + +#define MAX_LZW_BITS 12 /* maximum LZW code size (4096 symbols) */ + +typedef INT16 code_int; /* must hold -1 .. 2**MAX_LZW_BITS */ + +#define LZW_TABLE_SIZE ((code_int) 1 << MAX_LZW_BITS) + +#define HSIZE 5003 /* hash table size for 80% occupancy */ + +typedef int hash_int; /* must hold -2*HSIZE..2*HSIZE */ + +#define MAXCODE(n_bits) (((code_int) 1 << (n_bits)) - 1) + + +/* + * The LZW hash table consists of two parallel arrays: + * hash_code[i] code of symbol in slot i, or 0 if empty slot + * hash_value[i] symbol's value; undefined if empty slot + * where slot values (i) range from 0 to HSIZE-1. The symbol value is + * its prefix symbol's code concatenated with its suffix character. + * + * Algorithm: use open addressing double hashing (no chaining) on the + * prefix code / suffix character combination. We do a variant of Knuth's + * algorithm D (vol. 3, sec. 6.4) along with G. Knott's relatively-prime + * secondary probe. + * + * The hash_value[] table is allocated from FAR heap space since it would + * use up rather a lot of the near data space in a PC. + */ + +typedef INT32 hash_entry; /* must hold (code_int<<8) | byte */ + +#define HASH_ENTRY(prefix,suffix) ((((hash_entry) (prefix)) << 8) | (suffix)) + + +/* Private version of data destination object */ + +typedef struct { + struct djpeg_dest_struct pub; /* public fields */ + + j_decompress_ptr cinfo; /* back link saves passing separate parm */ + + /* State for packing variable-width codes into a bitstream */ + int n_bits; /* current number of bits/code */ + code_int maxcode; /* maximum code, given n_bits */ + int init_bits; /* initial n_bits ... restored after clear */ + INT32 cur_accum; /* holds bits not yet output */ + int cur_bits; /* # of bits in cur_accum */ + + /* LZW string construction */ + code_int waiting_code; /* symbol not yet output; may be extendable */ + boolean first_byte; /* if TRUE, waiting_code is not valid */ + + /* State for LZW code assignment */ + code_int ClearCode; /* clear code (doesn't change) */ + code_int EOFCode; /* EOF code (ditto) */ + code_int free_code; /* first not-yet-used symbol code */ + + /* LZW hash table */ + code_int *hash_code; /* => hash table of symbol codes */ + hash_entry FAR *hash_value; /* => hash table of symbol values */ + + /* GIF data packet construction buffer */ + int bytesinpkt; /* # of bytes in current packet */ + char packetbuf[256]; /* workspace for accumulating packet */ + +} gif_dest_struct; + +typedef gif_dest_struct * gif_dest_ptr; + + +/* + * Routines to package compressed data bytes into GIF data blocks. + * A data block consists of a count byte (1..255) and that many data bytes. + */ + +LOCAL(void) +flush_packet (gif_dest_ptr dinfo) +/* flush any accumulated data */ +{ + if (dinfo->bytesinpkt > 0) { /* never write zero-length packet */ + dinfo->packetbuf[0] = (char) dinfo->bytesinpkt++; + if (JFWRITE(dinfo->pub.output_file, dinfo->packetbuf, dinfo->bytesinpkt) + != (size_t) dinfo->bytesinpkt) + ERREXIT(dinfo->cinfo, JERR_FILE_WRITE); + dinfo->bytesinpkt = 0; + } +} + + +/* Add a character to current packet; flush to disk if necessary */ +#define CHAR_OUT(dinfo,c) \ + { (dinfo)->packetbuf[++(dinfo)->bytesinpkt] = (char) (c); \ + if ((dinfo)->bytesinpkt >= 255) \ + flush_packet(dinfo); \ + } + + +/* Routine to convert variable-width codes into a byte stream */ + +LOCAL(void) +output (gif_dest_ptr dinfo, code_int code) +/* Emit a code of n_bits bits */ +/* Uses cur_accum and cur_bits to reblock into 8-bit bytes */ +{ + dinfo->cur_accum |= ((INT32) code) << dinfo->cur_bits; + dinfo->cur_bits += dinfo->n_bits; + + while (dinfo->cur_bits >= 8) { + CHAR_OUT(dinfo, dinfo->cur_accum & 0xFF); + dinfo->cur_accum >>= 8; + dinfo->cur_bits -= 8; + } + + /* + * If the next entry is going to be too big for the code size, + * then increase it, if possible. We do this here to ensure + * that it's done in sync with the decoder's codesize increases. + */ + if (dinfo->free_code > dinfo->maxcode) { + dinfo->n_bits++; + if (dinfo->n_bits == MAX_LZW_BITS) + dinfo->maxcode = LZW_TABLE_SIZE; /* free_code will never exceed this */ + else + dinfo->maxcode = MAXCODE(dinfo->n_bits); + } +} + + +/* The LZW algorithm proper */ + + +LOCAL(void) +clear_hash (gif_dest_ptr dinfo) +/* Fill the hash table with empty entries */ +{ + /* It's sufficient to zero hash_code[] */ + MEMZERO(dinfo->hash_code, HSIZE * SIZEOF(code_int)); +} + + +LOCAL(void) +clear_block (gif_dest_ptr dinfo) +/* Reset compressor and issue a Clear code */ +{ + clear_hash(dinfo); /* delete all the symbols */ + dinfo->free_code = dinfo->ClearCode + 2; + output(dinfo, dinfo->ClearCode); /* inform decoder */ + dinfo->n_bits = dinfo->init_bits; /* reset code size */ + dinfo->maxcode = MAXCODE(dinfo->n_bits); +} + + +LOCAL(void) +compress_init (gif_dest_ptr dinfo, int i_bits) +/* Initialize LZW compressor */ +{ + /* init all the state variables */ + dinfo->n_bits = dinfo->init_bits = i_bits; + dinfo->maxcode = MAXCODE(dinfo->n_bits); + dinfo->ClearCode = ((code_int) 1 << (i_bits - 1)); + dinfo->EOFCode = dinfo->ClearCode + 1; + dinfo->free_code = dinfo->ClearCode + 2; + dinfo->first_byte = TRUE; /* no waiting symbol yet */ + /* init output buffering vars */ + dinfo->bytesinpkt = 0; + dinfo->cur_accum = 0; + dinfo->cur_bits = 0; + /* clear hash table */ + clear_hash(dinfo); + /* GIF specifies an initial Clear code */ + output(dinfo, dinfo->ClearCode); +} + + +LOCAL(void) +compress_byte (gif_dest_ptr dinfo, int c) +/* Accept and compress one 8-bit byte */ +{ + register hash_int i; + register hash_int disp; + register hash_entry probe_value; + + if (dinfo->first_byte) { /* need to initialize waiting_code */ + dinfo->waiting_code = c; + dinfo->first_byte = FALSE; + return; + } + + /* Probe hash table to see if a symbol exists for + * waiting_code followed by c. + * If so, replace waiting_code by that symbol and return. + */ + i = ((hash_int) c << (MAX_LZW_BITS-8)) + dinfo->waiting_code; + /* i is less than twice 2**MAX_LZW_BITS, therefore less than twice HSIZE */ + if (i >= HSIZE) + i -= HSIZE; + + probe_value = HASH_ENTRY(dinfo->waiting_code, c); + + if (dinfo->hash_code[i] != 0) { /* is first probed slot empty? */ + if (dinfo->hash_value[i] == probe_value) { + dinfo->waiting_code = dinfo->hash_code[i]; + return; + } + if (i == 0) /* secondary hash (after G. Knott) */ + disp = 1; + else + disp = HSIZE - i; + for (;;) { + i -= disp; + if (i < 0) + i += HSIZE; + if (dinfo->hash_code[i] == 0) + break; /* hit empty slot */ + if (dinfo->hash_value[i] == probe_value) { + dinfo->waiting_code = dinfo->hash_code[i]; + return; + } + } + } + + /* here when hashtable[i] is an empty slot; desired symbol not in table */ + output(dinfo, dinfo->waiting_code); + if (dinfo->free_code < LZW_TABLE_SIZE) { + dinfo->hash_code[i] = dinfo->free_code++; /* add symbol to hashtable */ + dinfo->hash_value[i] = probe_value; + } else + clear_block(dinfo); + dinfo->waiting_code = c; +} + + +LOCAL(void) +compress_term (gif_dest_ptr dinfo) +/* Clean up at end */ +{ + /* Flush out the buffered code */ + if (! dinfo->first_byte) + output(dinfo, dinfo->waiting_code); + /* Send an EOF code */ + output(dinfo, dinfo->EOFCode); + /* Flush the bit-packing buffer */ + if (dinfo->cur_bits > 0) { + CHAR_OUT(dinfo, dinfo->cur_accum & 0xFF); + } + /* Flush the packet buffer */ + flush_packet(dinfo); +} + + +/* GIF header construction */ + + +LOCAL(void) +put_word (gif_dest_ptr dinfo, unsigned int w) +/* Emit a 16-bit word, LSB first */ +{ + putc(w & 0xFF, dinfo->pub.output_file); + putc((w >> 8) & 0xFF, dinfo->pub.output_file); +} + + +LOCAL(void) +put_3bytes (gif_dest_ptr dinfo, int val) +/* Emit 3 copies of same byte value --- handy subr for colormap construction */ +{ + putc(val, dinfo->pub.output_file); + putc(val, dinfo->pub.output_file); + putc(val, dinfo->pub.output_file); +} + + +LOCAL(void) +emit_header (gif_dest_ptr dinfo, int num_colors, JSAMPARRAY colormap) +/* Output the GIF file header, including color map */ +/* If colormap==NULL, synthesize a gray-scale colormap */ +{ + int BitsPerPixel, ColorMapSize, InitCodeSize, FlagByte; + int cshift = dinfo->cinfo->data_precision - 8; + int i; + + if (num_colors > 256) + ERREXIT1(dinfo->cinfo, JERR_TOO_MANY_COLORS, num_colors); + /* Compute bits/pixel and related values */ + BitsPerPixel = 1; + while (num_colors > (1 << BitsPerPixel)) + BitsPerPixel++; + ColorMapSize = 1 << BitsPerPixel; + if (BitsPerPixel <= 1) + InitCodeSize = 2; + else + InitCodeSize = BitsPerPixel; + /* + * Write the GIF header. + * Note that we generate a plain GIF87 header for maximum compatibility. + */ + putc('G', dinfo->pub.output_file); + putc('I', dinfo->pub.output_file); + putc('F', dinfo->pub.output_file); + putc('8', dinfo->pub.output_file); + putc('7', dinfo->pub.output_file); + putc('a', dinfo->pub.output_file); + /* Write the Logical Screen Descriptor */ + put_word(dinfo, (unsigned int) dinfo->cinfo->output_width); + put_word(dinfo, (unsigned int) dinfo->cinfo->output_height); + FlagByte = 0x80; /* Yes, there is a global color table */ + FlagByte |= (BitsPerPixel-1) << 4; /* color resolution */ + FlagByte |= (BitsPerPixel-1); /* size of global color table */ + putc(FlagByte, dinfo->pub.output_file); + putc(0, dinfo->pub.output_file); /* Background color index */ + putc(0, dinfo->pub.output_file); /* Reserved (aspect ratio in GIF89) */ + /* Write the Global Color Map */ + /* If the color map is more than 8 bits precision, */ + /* we reduce it to 8 bits by shifting */ + for (i=0; i < ColorMapSize; i++) { + if (i < num_colors) { + if (colormap != NULL) { + if (dinfo->cinfo->out_color_space == JCS_RGB) { + /* Normal case: RGB color map */ + putc(GETJSAMPLE(colormap[0][i]) >> cshift, dinfo->pub.output_file); + putc(GETJSAMPLE(colormap[1][i]) >> cshift, dinfo->pub.output_file); + putc(GETJSAMPLE(colormap[2][i]) >> cshift, dinfo->pub.output_file); + } else { + /* Grayscale "color map": possible if quantizing grayscale image */ + put_3bytes(dinfo, GETJSAMPLE(colormap[0][i]) >> cshift); + } + } else { + /* Create a gray-scale map of num_colors values, range 0..255 */ + put_3bytes(dinfo, (i * 255 + (num_colors-1)/2) / (num_colors-1)); + } + } else { + /* fill out the map to a power of 2 */ + put_3bytes(dinfo, 0); + } + } + /* Write image separator and Image Descriptor */ + putc(',', dinfo->pub.output_file); /* separator */ + put_word(dinfo, 0); /* left/top offset */ + put_word(dinfo, 0); + put_word(dinfo, (unsigned int) dinfo->cinfo->output_width); /* image size */ + put_word(dinfo, (unsigned int) dinfo->cinfo->output_height); + /* flag byte: not interlaced, no local color map */ + putc(0x00, dinfo->pub.output_file); + /* Write Initial Code Size byte */ + putc(InitCodeSize, dinfo->pub.output_file); + + /* Initialize for LZW compression of image data */ + compress_init(dinfo, InitCodeSize+1); +} + + +/* + * Startup: write the file header. + */ + +METHODDEF(void) +start_output_gif (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) +{ + gif_dest_ptr dest = (gif_dest_ptr) dinfo; + + if (cinfo->quantize_colors) + emit_header(dest, cinfo->actual_number_of_colors, cinfo->colormap); + else + emit_header(dest, 256, (JSAMPARRAY) NULL); +} + + +/* + * Write some pixel data. + * In this module rows_supplied will always be 1. + */ + +METHODDEF(void) +put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied) +{ + gif_dest_ptr dest = (gif_dest_ptr) dinfo; + register JSAMPROW ptr; + register JDIMENSION col; + + ptr = dest->pub.buffer[0]; + for (col = cinfo->output_width; col > 0; col--) { + compress_byte(dest, GETJSAMPLE(*ptr++)); + } +} + + +/* + * Finish up at the end of the file. + */ + +METHODDEF(void) +finish_output_gif (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) +{ + gif_dest_ptr dest = (gif_dest_ptr) dinfo; + + /* Flush LZW mechanism */ + compress_term(dest); + /* Write a zero-length data block to end the series */ + putc(0, dest->pub.output_file); + /* Write the GIF terminator mark */ + putc(';', dest->pub.output_file); + /* Make sure we wrote the output file OK */ + fflush(dest->pub.output_file); + if (ferror(dest->pub.output_file)) + ERREXIT(cinfo, JERR_FILE_WRITE); +} + + +/* + * The module selection routine for GIF format output. + */ + +GLOBAL(djpeg_dest_ptr) +jinit_write_gif (j_decompress_ptr cinfo) +{ + gif_dest_ptr dest; + + /* Create module interface object, fill in method pointers */ + dest = (gif_dest_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(gif_dest_struct)); + dest->cinfo = cinfo; /* make back link for subroutines */ + dest->pub.start_output = start_output_gif; + dest->pub.put_pixel_rows = put_pixel_rows; + dest->pub.finish_output = finish_output_gif; + + if (cinfo->out_color_space != JCS_GRAYSCALE && + cinfo->out_color_space != JCS_RGB) + ERREXIT(cinfo, JERR_GIF_COLORSPACE); + + /* Force quantization if color or if > 8 bits input */ + if (cinfo->out_color_space != JCS_GRAYSCALE || cinfo->data_precision > 8) { + /* Force quantization to at most 256 colors */ + cinfo->quantize_colors = TRUE; + if (cinfo->desired_number_of_colors > 256) + cinfo->desired_number_of_colors = 256; + } + + /* Calculate output image dimensions so we can allocate space */ + jpeg_calc_output_dimensions(cinfo); + + if (cinfo->output_components != 1) /* safety check: just one component? */ + ERREXIT(cinfo, JERR_GIF_BUG); + + /* Create decompressor output buffer. */ + dest->pub.buffer = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, cinfo->output_width, (JDIMENSION) 1); + dest->pub.buffer_height = 1; + + /* Allocate space for hash table */ + dest->hash_code = (code_int *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + HSIZE * SIZEOF(code_int)); + dest->hash_value = (hash_entry FAR *) + (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, + HSIZE * SIZEOF(hash_entry)); + + return (djpeg_dest_ptr) dest; +} + +#endif /* GIF_SUPPORTED */ diff --git a/gs/jpeg/wrjpgcom b/gs/jpeg/wrjpgcom new file mode 100755 index 000000000..e0aeb79b0 Binary files /dev/null and b/gs/jpeg/wrjpgcom differ diff --git a/gs/jpeg/wrjpgcom.1 b/gs/jpeg/wrjpgcom.1 new file mode 100644 index 000000000..d419a9999 --- /dev/null +++ b/gs/jpeg/wrjpgcom.1 @@ -0,0 +1,103 @@ +.TH WRJPGCOM 1 "15 June 1995" +.SH NAME +wrjpgcom \- insert text comments into a JPEG file +.SH SYNOPSIS +.B wrjpgcom +[ +.B \-replace +] +[ +.BI \-comment " text" +] +[ +.BI \-cfile " name" +] +[ +.I filename +] +.LP +.SH DESCRIPTION +.LP +.B wrjpgcom +reads the named JPEG/JFIF file, or the standard input if no file is named, +and generates a new JPEG/JFIF file on standard output. A comment block is +added to the file. +.PP +The JPEG standard allows "comment" (COM) blocks to occur within a JPEG file. +Although the standard doesn't actually define what COM blocks are for, they +are widely used to hold user-supplied text strings. This lets you add +annotations, titles, index terms, etc to your JPEG files, and later retrieve +them as text. COM blocks do not interfere with the image stored in the JPEG +file. The maximum size of a COM block is 64K, but you can have as many of +them as you like in one JPEG file. +.PP +.B wrjpgcom +adds a COM block, containing text you provide, to a JPEG file. +Ordinarily, the COM block is added after any existing COM blocks; but you +can delete the old COM blocks if you wish. +.SH OPTIONS +Switch names may be abbreviated, and are not case sensitive. +.TP +.B \-replace +Delete any existing COM blocks from the file. +.TP +.BI \-comment " text" +Supply text for new COM block on command line. +.TP +.BI \-cfile " name" +Read text for new COM block from named file. +.PP +If you have only one line of comment text to add, you can provide it on the +command line with +.BR \-comment . +The comment text must be surrounded with quotes so that it is treated as a +single argument. Longer comments can be read from a text file. +.PP +If you give neither +.B \-comment +nor +.BR \-cfile , +then +.B wrjpgcom +will read the comment text from standard input. (In this case an input image +file name MUST be supplied, so that the source JPEG file comes from somewhere +else.) You can enter multiple lines, up to 64KB worth. Type an end-of-file +indicator (usually control-D) to terminate the comment text entry. +.PP +.B wrjpgcom +will not add a COM block if the provided comment string is empty. Therefore +\fB\-replace \-comment ""\fR can be used to delete all COM blocks from a file. +.SH EXAMPLES +.LP +Add a short comment to in.jpg, producing out.jpg: +.IP +.B wrjpgcom \-c +\fI"View of my back yard" in.jpg +.B > +.I out.jpg +.PP +Attach a long comment previously stored in comment.txt: +.IP +.B wrjpgcom +.I in.jpg +.B < +.I comment.txt +.B > +.I out.jpg +.PP +or equivalently +.IP +.B wrjpgcom +.B -cfile +.I comment.txt +.B < +.I in.jpg +.B > +.I out.jpg +.SH SEE ALSO +.BR cjpeg (1), +.BR djpeg (1), +.BR jpegtran (1), +.BR rdjpgcom (1) +.SH AUTHOR +Independent JPEG Group diff --git a/gs/jpeg/wrjpgcom.c b/gs/jpeg/wrjpgcom.c new file mode 100644 index 000000000..3b6411ce5 --- /dev/null +++ b/gs/jpeg/wrjpgcom.c @@ -0,0 +1,575 @@ +/* + * wrjpgcom.c + * + * Copyright (C) 1994-1995, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a very simple stand-alone application that inserts + * user-supplied text as a COM (comment) marker in a JFIF file. + * This may be useful as an example of the minimum logic needed to parse + * JPEG markers. + */ + +#define JPEG_CJPEG_DJPEG /* to get the command-line config symbols */ +#include "jinclude.h" /* get auto-config symbols, */ + +#ifndef HAVE_STDLIB_H /* should declare malloc() */ +extern void * malloc (); +#endif +#include /* to declare isupper(), tolower() */ +#ifdef USE_SETMODE +#include /* to declare setmode()'s parameter macros */ +/* If you have setmode() but not , just delete this line: */ +#include /* to declare setmode() */ +#endif + +#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ +#ifdef __MWERKS__ +#include /* Metrowerks needs this */ +#include /* ... and this */ +#endif +#ifdef THINK_C +#include /* Think declares it here */ +#endif +#endif + +#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ +#define READ_BINARY "r" +#define WRITE_BINARY "w" +#else +#define READ_BINARY "rb" +#define WRITE_BINARY "wb" +#endif + +#ifndef EXIT_FAILURE /* define exit() codes if not provided */ +#define EXIT_FAILURE 1 +#endif +#ifndef EXIT_SUCCESS +#ifdef VMS +#define EXIT_SUCCESS 1 /* VMS is very nonstandard */ +#else +#define EXIT_SUCCESS 0 +#endif +#endif + +/* Reduce this value if your malloc() can't allocate blocks up to 64K. + * On DOS, compiling in large model is usually a better solution. + */ + +#ifndef MAX_COM_LENGTH +#define MAX_COM_LENGTH 65000 /* must be < 65534 in any case */ +#endif + + +/* + * These macros are used to read the input file and write the output file. + * To reuse this code in another application, you might need to change these. + */ + +static FILE * infile; /* input JPEG file */ + +/* Return next input byte, or EOF if no more */ +#define NEXTBYTE() getc(infile) + +static FILE * outfile; /* output JPEG file */ + +/* Emit an output byte */ +#define PUTBYTE(x) putc((x), outfile) + + +/* Error exit handler */ +#define ERREXIT(msg) (fprintf(stderr, "%s\n", msg), exit(EXIT_FAILURE)) + + +/* Read one byte, testing for EOF */ +static int +read_1_byte (void) +{ + int c; + + c = NEXTBYTE(); + if (c == EOF) + ERREXIT("Premature EOF in JPEG file"); + return c; +} + +/* Read 2 bytes, convert to unsigned int */ +/* All 2-byte quantities in JPEG markers are MSB first */ +static unsigned int +read_2_bytes (void) +{ + int c1, c2; + + c1 = NEXTBYTE(); + if (c1 == EOF) + ERREXIT("Premature EOF in JPEG file"); + c2 = NEXTBYTE(); + if (c2 == EOF) + ERREXIT("Premature EOF in JPEG file"); + return (((unsigned int) c1) << 8) + ((unsigned int) c2); +} + + +/* Routines to write data to output file */ + +static void +write_1_byte (int c) +{ + PUTBYTE(c); +} + +static void +write_2_bytes (unsigned int val) +{ + PUTBYTE((val >> 8) & 0xFF); + PUTBYTE(val & 0xFF); +} + +static void +write_marker (int marker) +{ + PUTBYTE(0xFF); + PUTBYTE(marker); +} + +static void +copy_rest_of_file (void) +{ + int c; + + while ((c = NEXTBYTE()) != EOF) + PUTBYTE(c); +} + + +/* + * JPEG markers consist of one or more 0xFF bytes, followed by a marker + * code byte (which is not an FF). Here are the marker codes of interest + * in this program. (See jdmarker.c for a more complete list.) + */ + +#define M_SOF0 0xC0 /* Start Of Frame N */ +#define M_SOF1 0xC1 /* N indicates which compression process */ +#define M_SOF2 0xC2 /* Only SOF0-SOF2 are now in common use */ +#define M_SOF3 0xC3 +#define M_SOF5 0xC5 /* NB: codes C4 and CC are NOT SOF markers */ +#define M_SOF6 0xC6 +#define M_SOF7 0xC7 +#define M_SOF9 0xC9 +#define M_SOF10 0xCA +#define M_SOF11 0xCB +#define M_SOF13 0xCD +#define M_SOF14 0xCE +#define M_SOF15 0xCF +#define M_SOI 0xD8 /* Start Of Image (beginning of datastream) */ +#define M_EOI 0xD9 /* End Of Image (end of datastream) */ +#define M_SOS 0xDA /* Start Of Scan (begins compressed data) */ +#define M_COM 0xFE /* COMment */ + + +/* + * Find the next JPEG marker and return its marker code. + * We expect at least one FF byte, possibly more if the compressor used FFs + * to pad the file. (Padding FFs will NOT be replicated in the output file.) + * There could also be non-FF garbage between markers. The treatment of such + * garbage is unspecified; we choose to skip over it but emit a warning msg. + * NB: this routine must not be used after seeing SOS marker, since it will + * not deal correctly with FF/00 sequences in the compressed image data... + */ + +static int +next_marker (void) +{ + int c; + int discarded_bytes = 0; + + /* Find 0xFF byte; count and skip any non-FFs. */ + c = read_1_byte(); + while (c != 0xFF) { + discarded_bytes++; + c = read_1_byte(); + } + /* Get marker code byte, swallowing any duplicate FF bytes. Extra FFs + * are legal as pad bytes, so don't count them in discarded_bytes. + */ + do { + c = read_1_byte(); + } while (c == 0xFF); + + if (discarded_bytes != 0) { + fprintf(stderr, "Warning: garbage data found in JPEG file\n"); + } + + return c; +} + + +/* + * Read the initial marker, which should be SOI. + * For a JFIF file, the first two bytes of the file should be literally + * 0xFF M_SOI. To be more general, we could use next_marker, but if the + * input file weren't actually JPEG at all, next_marker might read the whole + * file and then return a misleading error message... + */ + +static int +first_marker (void) +{ + int c1, c2; + + c1 = NEXTBYTE(); + c2 = NEXTBYTE(); + if (c1 != 0xFF || c2 != M_SOI) + ERREXIT("Not a JPEG file"); + return c2; +} + + +/* + * Most types of marker are followed by a variable-length parameter segment. + * This routine skips over the parameters for any marker we don't otherwise + * want to process. + * Note that we MUST skip the parameter segment explicitly in order not to + * be fooled by 0xFF bytes that might appear within the parameter segment; + * such bytes do NOT introduce new markers. + */ + +static void +copy_variable (void) +/* Copy an unknown or uninteresting variable-length marker */ +{ + unsigned int length; + + /* Get the marker parameter length count */ + length = read_2_bytes(); + write_2_bytes(length); + /* Length includes itself, so must be at least 2 */ + if (length < 2) + ERREXIT("Erroneous JPEG marker length"); + length -= 2; + /* Skip over the remaining bytes */ + while (length > 0) { + write_1_byte(read_1_byte()); + length--; + } +} + +static void +skip_variable (void) +/* Skip over an unknown or uninteresting variable-length marker */ +{ + unsigned int length; + + /* Get the marker parameter length count */ + length = read_2_bytes(); + /* Length includes itself, so must be at least 2 */ + if (length < 2) + ERREXIT("Erroneous JPEG marker length"); + length -= 2; + /* Skip over the remaining bytes */ + while (length > 0) { + (void) read_1_byte(); + length--; + } +} + + +/* + * Parse the marker stream until SOFn or EOI is seen; + * copy data to output, but discard COM markers unless keep_COM is true. + */ + +static int +scan_JPEG_header (int keep_COM) +{ + int marker; + + /* Expect SOI at start of file */ + if (first_marker() != M_SOI) + ERREXIT("Expected SOI marker first"); + write_marker(M_SOI); + + /* Scan miscellaneous markers until we reach SOFn. */ + for (;;) { + marker = next_marker(); + switch (marker) { + case M_SOF0: /* Baseline */ + case M_SOF1: /* Extended sequential, Huffman */ + case M_SOF2: /* Progressive, Huffman */ + case M_SOF3: /* Lossless, Huffman */ + case M_SOF5: /* Differential sequential, Huffman */ + case M_SOF6: /* Differential progressive, Huffman */ + case M_SOF7: /* Differential lossless, Huffman */ + case M_SOF9: /* Extended sequential, arithmetic */ + case M_SOF10: /* Progressive, arithmetic */ + case M_SOF11: /* Lossless, arithmetic */ + case M_SOF13: /* Differential sequential, arithmetic */ + case M_SOF14: /* Differential progressive, arithmetic */ + case M_SOF15: /* Differential lossless, arithmetic */ + return marker; + + case M_SOS: /* should not see compressed data before SOF */ + ERREXIT("SOS without prior SOFn"); + break; + + case M_EOI: /* in case it's a tables-only JPEG stream */ + return marker; + + case M_COM: /* Existing COM: conditionally discard */ + if (keep_COM) { + write_marker(marker); + copy_variable(); + } else { + skip_variable(); + } + break; + + default: /* Anything else just gets copied */ + write_marker(marker); + copy_variable(); /* we assume it has a parameter count... */ + break; + } + } /* end loop */ +} + + +/* Command line parsing code */ + +static const char * progname; /* program name for error messages */ + + +static void +usage (void) +/* complain about bad command line */ +{ + fprintf(stderr, "wrjpgcom inserts a textual comment in a JPEG file.\n"); + fprintf(stderr, "You can add to or replace any existing comment(s).\n"); + + fprintf(stderr, "Usage: %s [switches] ", progname); +#ifdef TWO_FILE_COMMANDLINE + fprintf(stderr, "inputfile outputfile\n"); +#else + fprintf(stderr, "[inputfile]\n"); +#endif + + fprintf(stderr, "Switches (names may be abbreviated):\n"); + fprintf(stderr, " -replace Delete any existing comments\n"); + fprintf(stderr, " -comment \"text\" Insert comment with given text\n"); + fprintf(stderr, " -cfile name Read comment from named file\n"); + fprintf(stderr, "Notice that you must put quotes around the comment text\n"); + fprintf(stderr, "when you use -comment.\n"); + fprintf(stderr, "If you do not give either -comment or -cfile on the command line,\n"); + fprintf(stderr, "then the comment text is read from standard input.\n"); + fprintf(stderr, "It can be multiple lines, up to %u characters total.\n", + (unsigned int) MAX_COM_LENGTH); +#ifndef TWO_FILE_COMMANDLINE + fprintf(stderr, "You must specify an input JPEG file name when supplying\n"); + fprintf(stderr, "comment text from standard input.\n"); +#endif + + exit(EXIT_FAILURE); +} + + +static int +keymatch (char * arg, const char * keyword, int minchars) +/* Case-insensitive matching of (possibly abbreviated) keyword switches. */ +/* keyword is the constant keyword (must be lower case already), */ +/* minchars is length of minimum legal abbreviation. */ +{ + register int ca, ck; + register int nmatched = 0; + + while ((ca = *arg++) != '\0') { + if ((ck = *keyword++) == '\0') + return 0; /* arg longer than keyword, no good */ + if (isupper(ca)) /* force arg to lcase (assume ck is already) */ + ca = tolower(ca); + if (ca != ck) + return 0; /* no good */ + nmatched++; /* count matched characters */ + } + /* reached end of argument; fail if it's too short for unique abbrev */ + if (nmatched < minchars) + return 0; + return 1; /* A-OK */ +} + + +/* + * The main program. + */ + +int +main (int argc, char **argv) +{ + int argn; + char * arg; + int keep_COM = 1; + char * comment_arg = NULL; + FILE * comment_file = NULL; + unsigned int comment_length = 0; + int marker; + + /* On Mac, fetch a command line. */ +#ifdef USE_CCOMMAND + argc = ccommand(&argv); +#endif + + progname = argv[0]; + if (progname == NULL || progname[0] == 0) + progname = "wrjpgcom"; /* in case C library doesn't provide it */ + + /* Parse switches, if any */ + for (argn = 1; argn < argc; argn++) { + arg = argv[argn]; + if (arg[0] != '-') + break; /* not switch, must be file name */ + arg++; /* advance over '-' */ + if (keymatch(arg, "replace", 1)) { + keep_COM = 0; + } else if (keymatch(arg, "cfile", 2)) { + if (++argn >= argc) usage(); + if ((comment_file = fopen(argv[argn], "r")) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]); + exit(EXIT_FAILURE); + } + } else if (keymatch(arg, "comment", 1)) { + if (++argn >= argc) usage(); + comment_arg = argv[argn]; + /* If the comment text starts with '"', then we are probably running + * under MS-DOG and must parse out the quoted string ourselves. Sigh. + */ + if (comment_arg[0] == '"') { + comment_arg = (char *) malloc((size_t) MAX_COM_LENGTH); + if (comment_arg == NULL) + ERREXIT("Insufficient memory"); + strcpy(comment_arg, argv[argn]+1); + for (;;) { + comment_length = strlen(comment_arg); + if (comment_length > 0 && comment_arg[comment_length-1] == '"') { + comment_arg[comment_length-1] = '\0'; /* zap terminating quote */ + break; + } + if (++argn >= argc) + ERREXIT("Missing ending quote mark"); + strcat(comment_arg, " "); + strcat(comment_arg, argv[argn]); + } + } + comment_length = strlen(comment_arg); + } else + usage(); + } + + /* Cannot use both -comment and -cfile. */ + if (comment_arg != NULL && comment_file != NULL) + usage(); + /* If there is neither -comment nor -cfile, we will read the comment text + * from stdin; in this case there MUST be an input JPEG file name. + */ + if (comment_arg == NULL && comment_file == NULL && argn >= argc) + usage(); + + /* Open the input file. */ + if (argn < argc) { + if ((infile = fopen(argv[argn], READ_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]); + exit(EXIT_FAILURE); + } + } else { + /* default input file is stdin */ +#ifdef USE_SETMODE /* need to hack file mode? */ + setmode(fileno(stdin), O_BINARY); +#endif +#ifdef USE_FDOPEN /* need to re-open in binary mode? */ + if ((infile = fdopen(fileno(stdin), READ_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open stdin\n", progname); + exit(EXIT_FAILURE); + } +#else + infile = stdin; +#endif + } + + /* Open the output file. */ +#ifdef TWO_FILE_COMMANDLINE + /* Must have explicit output file name */ + if (argn != argc-2) { + fprintf(stderr, "%s: must name one input and one output file\n", + progname); + usage(); + } + if ((outfile = fopen(argv[argn+1], WRITE_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, argv[argn+1]); + exit(EXIT_FAILURE); + } +#else + /* Unix style: expect zero or one file name */ + if (argn < argc-1) { + fprintf(stderr, "%s: only one input file\n", progname); + usage(); + } + /* default output file is stdout */ +#ifdef USE_SETMODE /* need to hack file mode? */ + setmode(fileno(stdout), O_BINARY); +#endif +#ifdef USE_FDOPEN /* need to re-open in binary mode? */ + if ((outfile = fdopen(fileno(stdout), WRITE_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open stdout\n", progname); + exit(EXIT_FAILURE); + } +#else + outfile = stdout; +#endif +#endif /* TWO_FILE_COMMANDLINE */ + + /* Collect comment text from comment_file or stdin, if necessary */ + if (comment_arg == NULL) { + FILE * src_file; + int c; + + comment_arg = (char *) malloc((size_t) MAX_COM_LENGTH); + if (comment_arg == NULL) + ERREXIT("Insufficient memory"); + comment_length = 0; + src_file = (comment_file != NULL ? comment_file : stdin); + while ((c = getc(src_file)) != EOF) { + if (comment_length >= (unsigned int) MAX_COM_LENGTH) { + fprintf(stderr, "Comment text may not exceed %u bytes\n", + (unsigned int) MAX_COM_LENGTH); + exit(EXIT_FAILURE); + } + comment_arg[comment_length++] = (char) c; + } + if (comment_file != NULL) + fclose(comment_file); + } + + /* Copy JPEG headers until SOFn marker; + * we will insert the new comment marker just before SOFn. + * This (a) causes the new comment to appear after, rather than before, + * existing comments; and (b) ensures that comments come after any JFIF + * or JFXX markers, as required by the JFIF specification. + */ + marker = scan_JPEG_header(keep_COM); + /* Insert the new COM marker, but only if nonempty text has been supplied */ + if (comment_length > 0) { + write_marker(M_COM); + write_2_bytes(comment_length + 2); + while (comment_length > 0) { + write_1_byte(*comment_arg++); + comment_length--; + } + } + /* Duplicate the remainder of the source file. + * Note that any COM markers occuring after SOF will not be touched. + */ + write_marker(marker); + copy_rest_of_file(); + + /* All done. */ + exit(EXIT_SUCCESS); + return 0; /* suppress no-return-value warnings */ +} diff --git a/gs/jpeg/wrppm.c b/gs/jpeg/wrppm.c new file mode 100644 index 000000000..6c6d90881 --- /dev/null +++ b/gs/jpeg/wrppm.c @@ -0,0 +1,268 @@ +/* + * wrppm.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to write output images in PPM/PGM format. + * The extended 2-byte-per-sample raw PPM/PGM formats are supported. + * The PBMPLUS library is NOT required to compile this software + * (but it is highly useful as a set of PPM image manipulation programs). + * + * These routines may need modification for non-Unix environments or + * specialized applications. As they stand, they assume output to + * an ordinary stdio stream. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ + +#ifdef PPM_SUPPORTED + + +/* + * For 12-bit JPEG data, we either downscale the values to 8 bits + * (to write standard byte-per-sample PPM/PGM files), or output + * nonstandard word-per-sample PPM/PGM files. Downscaling is done + * if PPM_NORAWWORD is defined (this can be done in the Makefile + * or in jconfig.h). + * (When the core library supports data precision reduction, a cleaner + * implementation will be to ask for that instead.) + */ + +#if BITS_IN_JSAMPLE == 8 +#define PUTPPMSAMPLE(ptr,v) *ptr++ = (char) (v) +#define BYTESPERSAMPLE 1 +#define PPM_MAXVAL 255 +#else +#ifdef PPM_NORAWWORD +#define PUTPPMSAMPLE(ptr,v) *ptr++ = (char) ((v) >> (BITS_IN_JSAMPLE-8)) +#define BYTESPERSAMPLE 1 +#define PPM_MAXVAL 255 +#else +/* The word-per-sample format always puts the LSB first. */ +#define PUTPPMSAMPLE(ptr,v) \ + { register int val_ = v; \ + *ptr++ = (char) (val_ & 0xFF); \ + *ptr++ = (char) ((val_ >> 8) & 0xFF); \ + } +#define BYTESPERSAMPLE 2 +#define PPM_MAXVAL ((1<pub.output_file, dest->iobuffer, dest->buffer_width); +} + + +/* + * This code is used when we have to copy the data and apply a pixel + * format translation. Typically this only happens in 12-bit mode. + */ + +METHODDEF(void) +copy_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied) +{ + ppm_dest_ptr dest = (ppm_dest_ptr) dinfo; + register char * bufferptr; + register JSAMPROW ptr; + register JDIMENSION col; + + ptr = dest->pub.buffer[0]; + bufferptr = dest->iobuffer; + for (col = dest->samples_per_row; col > 0; col--) { + PUTPPMSAMPLE(bufferptr, GETJSAMPLE(*ptr++)); + } + (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); +} + + +/* + * Write some pixel data when color quantization is in effect. + * We have to demap the color index values to straight data. + */ + +METHODDEF(void) +put_demapped_rgb (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied) +{ + ppm_dest_ptr dest = (ppm_dest_ptr) dinfo; + register char * bufferptr; + register int pixval; + register JSAMPROW ptr; + register JSAMPROW color_map0 = cinfo->colormap[0]; + register JSAMPROW color_map1 = cinfo->colormap[1]; + register JSAMPROW color_map2 = cinfo->colormap[2]; + register JDIMENSION col; + + ptr = dest->pub.buffer[0]; + bufferptr = dest->iobuffer; + for (col = cinfo->output_width; col > 0; col--) { + pixval = GETJSAMPLE(*ptr++); + PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map0[pixval])); + PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map1[pixval])); + PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map2[pixval])); + } + (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); +} + + +METHODDEF(void) +put_demapped_gray (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied) +{ + ppm_dest_ptr dest = (ppm_dest_ptr) dinfo; + register char * bufferptr; + register JSAMPROW ptr; + register JSAMPROW color_map = cinfo->colormap[0]; + register JDIMENSION col; + + ptr = dest->pub.buffer[0]; + bufferptr = dest->iobuffer; + for (col = cinfo->output_width; col > 0; col--) { + PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map[GETJSAMPLE(*ptr++)])); + } + (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); +} + + +/* + * Startup: write the file header. + */ + +METHODDEF(void) +start_output_ppm (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) +{ + ppm_dest_ptr dest = (ppm_dest_ptr) dinfo; + + /* Emit file header */ + switch (cinfo->out_color_space) { + case JCS_GRAYSCALE: + /* emit header for raw PGM format */ + fprintf(dest->pub.output_file, "P5\n%ld %ld\n%d\n", + (long) cinfo->output_width, (long) cinfo->output_height, + PPM_MAXVAL); + break; + case JCS_RGB: + /* emit header for raw PPM format */ + fprintf(dest->pub.output_file, "P6\n%ld %ld\n%d\n", + (long) cinfo->output_width, (long) cinfo->output_height, + PPM_MAXVAL); + break; + default: + ERREXIT(cinfo, JERR_PPM_COLORSPACE); + } +} + + +/* + * Finish up at the end of the file. + */ + +METHODDEF(void) +finish_output_ppm (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) +{ + /* Make sure we wrote the output file OK */ + fflush(dinfo->output_file); + if (ferror(dinfo->output_file)) + ERREXIT(cinfo, JERR_FILE_WRITE); +} + + +/* + * The module selection routine for PPM format output. + */ + +GLOBAL(djpeg_dest_ptr) +jinit_write_ppm (j_decompress_ptr cinfo) +{ + ppm_dest_ptr dest; + + /* Create module interface object, fill in method pointers */ + dest = (ppm_dest_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(ppm_dest_struct)); + dest->pub.start_output = start_output_ppm; + dest->pub.finish_output = finish_output_ppm; + + /* Calculate output image dimensions so we can allocate space */ + jpeg_calc_output_dimensions(cinfo); + + /* Create physical I/O buffer. Note we make this near on a PC. */ + dest->samples_per_row = cinfo->output_width * cinfo->out_color_components; + dest->buffer_width = dest->samples_per_row * (BYTESPERSAMPLE * SIZEOF(char)); + dest->iobuffer = (char *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, dest->buffer_width); + + if (cinfo->quantize_colors || BITS_IN_JSAMPLE != 8 || + SIZEOF(JSAMPLE) != SIZEOF(char)) { + /* When quantizing, we need an output buffer for colormap indexes + * that's separate from the physical I/O buffer. We also need a + * separate buffer if pixel format translation must take place. + */ + dest->pub.buffer = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + cinfo->output_width * cinfo->output_components, (JDIMENSION) 1); + dest->pub.buffer_height = 1; + if (! cinfo->quantize_colors) + dest->pub.put_pixel_rows = copy_pixel_rows; + else if (cinfo->out_color_space == JCS_GRAYSCALE) + dest->pub.put_pixel_rows = put_demapped_gray; + else + dest->pub.put_pixel_rows = put_demapped_rgb; + } else { + /* We will fwrite() directly from decompressor output buffer. */ + /* Synthesize a JSAMPARRAY pointer structure */ + /* Cast here implies near->far pointer conversion on PCs */ + dest->pixrow = (JSAMPROW) dest->iobuffer; + dest->pub.buffer = & dest->pixrow; + dest->pub.buffer_height = 1; + dest->pub.put_pixel_rows = put_pixel_rows; + } + + return (djpeg_dest_ptr) dest; +} + +#endif /* PPM_SUPPORTED */ diff --git a/gs/jpeg/wrrle.c b/gs/jpeg/wrrle.c new file mode 100644 index 000000000..a4e73372d --- /dev/null +++ b/gs/jpeg/wrrle.c @@ -0,0 +1,305 @@ +/* + * wrrle.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to write output images in RLE format. + * The Utah Raster Toolkit library is required (version 3.1 or later). + * + * These routines may need modification for non-Unix environments or + * specialized applications. As they stand, they assume output to + * an ordinary stdio stream. + * + * Based on code contributed by Mike Lijewski, + * with updates from Robert Hutchinson. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ + +#ifdef RLE_SUPPORTED + +/* rle.h is provided by the Utah Raster Toolkit. */ + +#include + +/* + * We assume that JSAMPLE has the same representation as rle_pixel, + * to wit, "unsigned char". Hence we can't cope with 12- or 16-bit samples. + */ + +#if BITS_IN_JSAMPLE != 8 + Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */ +#endif + + +/* + * Since RLE stores scanlines bottom-to-top, we have to invert the image + * from JPEG's top-to-bottom order. To do this, we save the outgoing data + * in a virtual array during put_pixel_row calls, then actually emit the + * RLE file during finish_output. + */ + + +/* + * For now, if we emit an RLE color map then it is always 256 entries long, + * though not all of the entries need be used. + */ + +#define CMAPBITS 8 +#define CMAPLENGTH (1<<(CMAPBITS)) + +typedef struct { + struct djpeg_dest_struct pub; /* public fields */ + + jvirt_sarray_ptr image; /* virtual array to store the output image */ + rle_map *colormap; /* RLE-style color map, or NULL if none */ + rle_pixel **rle_row; /* To pass rows to rle_putrow() */ + +} rle_dest_struct; + +typedef rle_dest_struct * rle_dest_ptr; + +/* Forward declarations */ +METHODDEF(void) rle_put_pixel_rows + JPP((j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied)); + + +/* + * Write the file header. + * + * In this module it's easier to wait till finish_output to write anything. + */ + +METHODDEF(void) +start_output_rle (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) +{ + rle_dest_ptr dest = (rle_dest_ptr) dinfo; + size_t cmapsize; + int i, ci; +#ifdef PROGRESS_REPORT + cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; +#endif + + /* + * Make sure the image can be stored in RLE format. + * + * - RLE stores image dimensions as *signed* 16 bit integers. JPEG + * uses unsigned, so we have to check the width. + * + * - Colorspace is expected to be grayscale or RGB. + * + * - The number of channels (components) is expected to be 1 (grayscale/ + * pseudocolor) or 3 (truecolor/directcolor). + * (could be 2 or 4 if using an alpha channel, but we aren't) + */ + + if (cinfo->output_width > 32767 || cinfo->output_height > 32767) + ERREXIT2(cinfo, JERR_RLE_DIMENSIONS, cinfo->output_width, + cinfo->output_height); + + if (cinfo->out_color_space != JCS_GRAYSCALE && + cinfo->out_color_space != JCS_RGB) + ERREXIT(cinfo, JERR_RLE_COLORSPACE); + + if (cinfo->output_components != 1 && cinfo->output_components != 3) + ERREXIT1(cinfo, JERR_RLE_TOOMANYCHANNELS, cinfo->num_components); + + /* Convert colormap, if any, to RLE format. */ + + dest->colormap = NULL; + + if (cinfo->quantize_colors) { + /* Allocate storage for RLE-style cmap, zero any extra entries */ + cmapsize = cinfo->out_color_components * CMAPLENGTH * SIZEOF(rle_map); + dest->colormap = (rle_map *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, cmapsize); + MEMZERO(dest->colormap, cmapsize); + + /* Save away data in RLE format --- note 8-bit left shift! */ + /* Shifting would need adjustment for JSAMPLEs wider than 8 bits. */ + for (ci = 0; ci < cinfo->out_color_components; ci++) { + for (i = 0; i < cinfo->actual_number_of_colors; i++) { + dest->colormap[ci * CMAPLENGTH + i] = + GETJSAMPLE(cinfo->colormap[ci][i]) << 8; + } + } + } + + /* Set the output buffer to the first row */ + dest->pub.buffer = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, dest->image, (JDIMENSION) 0, (JDIMENSION) 1, TRUE); + dest->pub.buffer_height = 1; + + dest->pub.put_pixel_rows = rle_put_pixel_rows; + +#ifdef PROGRESS_REPORT + if (progress != NULL) { + progress->total_extra_passes++; /* count file writing as separate pass */ + } +#endif +} + + +/* + * Write some pixel data. + * + * This routine just saves the data away in a virtual array. + */ + +METHODDEF(void) +rle_put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied) +{ + rle_dest_ptr dest = (rle_dest_ptr) dinfo; + + if (cinfo->output_scanline < cinfo->output_height) { + dest->pub.buffer = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, dest->image, + cinfo->output_scanline, (JDIMENSION) 1, TRUE); + } +} + +/* + * Finish up at the end of the file. + * + * Here is where we really output the RLE file. + */ + +METHODDEF(void) +finish_output_rle (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) +{ + rle_dest_ptr dest = (rle_dest_ptr) dinfo; + rle_hdr header; /* Output file information */ + rle_pixel **rle_row, *red, *green, *blue; + JSAMPROW output_row; + char cmapcomment[80]; + int row, col; + int ci; +#ifdef PROGRESS_REPORT + cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; +#endif + + /* Initialize the header info */ + header = *rle_hdr_init(NULL); + header.rle_file = dest->pub.output_file; + header.xmin = 0; + header.xmax = cinfo->output_width - 1; + header.ymin = 0; + header.ymax = cinfo->output_height - 1; + header.alpha = 0; + header.ncolors = cinfo->output_components; + for (ci = 0; ci < cinfo->output_components; ci++) { + RLE_SET_BIT(header, ci); + } + if (cinfo->quantize_colors) { + header.ncmap = cinfo->out_color_components; + header.cmaplen = CMAPBITS; + header.cmap = dest->colormap; + /* Add a comment to the output image with the true colormap length. */ + sprintf(cmapcomment, "color_map_length=%d", cinfo->actual_number_of_colors); + rle_putcom(cmapcomment, &header); + } + + /* Emit the RLE header and color map (if any) */ + rle_put_setup(&header); + + /* Now output the RLE data from our virtual array. + * We assume here that (a) rle_pixel is represented the same as JSAMPLE, + * and (b) we are not on a machine where FAR pointers differ from regular. + */ + +#ifdef PROGRESS_REPORT + if (progress != NULL) { + progress->pub.pass_limit = cinfo->output_height; + progress->pub.pass_counter = 0; + (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); + } +#endif + + if (cinfo->output_components == 1) { + for (row = cinfo->output_height-1; row >= 0; row--) { + rle_row = (rle_pixel **) (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, dest->image, + (JDIMENSION) row, (JDIMENSION) 1, FALSE); + rle_putrow(rle_row, (int) cinfo->output_width, &header); +#ifdef PROGRESS_REPORT + if (progress != NULL) { + progress->pub.pass_counter++; + (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); + } +#endif + } + } else { + for (row = cinfo->output_height-1; row >= 0; row--) { + rle_row = (rle_pixel **) dest->rle_row; + output_row = * (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, dest->image, + (JDIMENSION) row, (JDIMENSION) 1, FALSE); + red = rle_row[0]; + green = rle_row[1]; + blue = rle_row[2]; + for (col = cinfo->output_width; col > 0; col--) { + *red++ = GETJSAMPLE(*output_row++); + *green++ = GETJSAMPLE(*output_row++); + *blue++ = GETJSAMPLE(*output_row++); + } + rle_putrow(rle_row, (int) cinfo->output_width, &header); +#ifdef PROGRESS_REPORT + if (progress != NULL) { + progress->pub.pass_counter++; + (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); + } +#endif + } + } + +#ifdef PROGRESS_REPORT + if (progress != NULL) + progress->completed_extra_passes++; +#endif + + /* Emit file trailer */ + rle_puteof(&header); + fflush(dest->pub.output_file); + if (ferror(dest->pub.output_file)) + ERREXIT(cinfo, JERR_FILE_WRITE); +} + + +/* + * The module selection routine for RLE format output. + */ + +GLOBAL(djpeg_dest_ptr) +jinit_write_rle (j_decompress_ptr cinfo) +{ + rle_dest_ptr dest; + + /* Create module interface object, fill in method pointers */ + dest = (rle_dest_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(rle_dest_struct)); + dest->pub.start_output = start_output_rle; + dest->pub.finish_output = finish_output_rle; + + /* Calculate output image dimensions so we can allocate space */ + jpeg_calc_output_dimensions(cinfo); + + /* Allocate a work array for output to the RLE library. */ + dest->rle_row = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + cinfo->output_width, (JDIMENSION) cinfo->output_components); + + /* Allocate a virtual array to hold the image. */ + dest->image = (*cinfo->mem->request_virt_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, + (JDIMENSION) (cinfo->output_width * cinfo->output_components), + cinfo->output_height, (JDIMENSION) 1); + + return (djpeg_dest_ptr) dest; +} + +#endif /* RLE_SUPPORTED */ diff --git a/gs/jpeg/wrtarga.c b/gs/jpeg/wrtarga.c new file mode 100644 index 000000000..cf104d2de --- /dev/null +++ b/gs/jpeg/wrtarga.c @@ -0,0 +1,253 @@ +/* + * wrtarga.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to write output images in Targa format. + * + * These routines may need modification for non-Unix environments or + * specialized applications. As they stand, they assume output to + * an ordinary stdio stream. + * + * Based on code contributed by Lee Daniel Crocker. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ + +#ifdef TARGA_SUPPORTED + + +/* + * To support 12-bit JPEG data, we'd have to scale output down to 8 bits. + * This is not yet implemented. + */ + +#if BITS_IN_JSAMPLE != 8 + Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */ +#endif + +/* + * The output buffer needs to be writable by fwrite(). On PCs, we must + * allocate the buffer in near data space, because we are assuming small-data + * memory model, wherein fwrite() can't reach far memory. If you need to + * process very wide images on a PC, you might have to compile in large-memory + * model, or else replace fwrite() with a putc() loop --- which will be much + * slower. + */ + + +/* Private version of data destination object */ + +typedef struct { + struct djpeg_dest_struct pub; /* public fields */ + + char *iobuffer; /* physical I/O buffer */ + JDIMENSION buffer_width; /* width of one row */ +} tga_dest_struct; + +typedef tga_dest_struct * tga_dest_ptr; + + +LOCAL(void) +write_header (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, int num_colors) +/* Create and write a Targa header */ +{ + char targaheader[18]; + + /* Set unused fields of header to 0 */ + MEMZERO(targaheader, SIZEOF(targaheader)); + + if (num_colors > 0) { + targaheader[1] = 1; /* color map type 1 */ + targaheader[5] = (char) (num_colors & 0xFF); + targaheader[6] = (char) (num_colors >> 8); + targaheader[7] = 24; /* 24 bits per cmap entry */ + } + + targaheader[12] = (char) (cinfo->output_width & 0xFF); + targaheader[13] = (char) (cinfo->output_width >> 8); + targaheader[14] = (char) (cinfo->output_height & 0xFF); + targaheader[15] = (char) (cinfo->output_height >> 8); + targaheader[17] = 0x20; /* Top-down, non-interlaced */ + + if (cinfo->out_color_space == JCS_GRAYSCALE) { + targaheader[2] = 3; /* image type = uncompressed gray-scale */ + targaheader[16] = 8; /* bits per pixel */ + } else { /* must be RGB */ + if (num_colors > 0) { + targaheader[2] = 1; /* image type = colormapped RGB */ + targaheader[16] = 8; + } else { + targaheader[2] = 2; /* image type = uncompressed RGB */ + targaheader[16] = 24; + } + } + + if (JFWRITE(dinfo->output_file, targaheader, 18) != (size_t) 18) + ERREXIT(cinfo, JERR_FILE_WRITE); +} + + +/* + * Write some pixel data. + * In this module rows_supplied will always be 1. + */ + +METHODDEF(void) +put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied) +/* used for unquantized full-color output */ +{ + tga_dest_ptr dest = (tga_dest_ptr) dinfo; + register JSAMPROW inptr; + register char * outptr; + register JDIMENSION col; + + inptr = dest->pub.buffer[0]; + outptr = dest->iobuffer; + for (col = cinfo->output_width; col > 0; col--) { + outptr[0] = (char) GETJSAMPLE(inptr[2]); /* RGB to BGR order */ + outptr[1] = (char) GETJSAMPLE(inptr[1]); + outptr[2] = (char) GETJSAMPLE(inptr[0]); + inptr += 3, outptr += 3; + } + (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); +} + +METHODDEF(void) +put_gray_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied) +/* used for grayscale OR quantized color output */ +{ + tga_dest_ptr dest = (tga_dest_ptr) dinfo; + register JSAMPROW inptr; + register char * outptr; + register JDIMENSION col; + + inptr = dest->pub.buffer[0]; + outptr = dest->iobuffer; + for (col = cinfo->output_width; col > 0; col--) { + *outptr++ = (char) GETJSAMPLE(*inptr++); + } + (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); +} + + +/* + * Write some demapped pixel data when color quantization is in effect. + * For Targa, this is only applied to grayscale data. + */ + +METHODDEF(void) +put_demapped_gray (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, + JDIMENSION rows_supplied) +{ + tga_dest_ptr dest = (tga_dest_ptr) dinfo; + register JSAMPROW inptr; + register char * outptr; + register JSAMPROW color_map0 = cinfo->colormap[0]; + register JDIMENSION col; + + inptr = dest->pub.buffer[0]; + outptr = dest->iobuffer; + for (col = cinfo->output_width; col > 0; col--) { + *outptr++ = (char) GETJSAMPLE(color_map0[GETJSAMPLE(*inptr++)]); + } + (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); +} + + +/* + * Startup: write the file header. + */ + +METHODDEF(void) +start_output_tga (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) +{ + tga_dest_ptr dest = (tga_dest_ptr) dinfo; + int num_colors, i; + FILE *outfile; + + if (cinfo->out_color_space == JCS_GRAYSCALE) { + /* Targa doesn't have a mapped grayscale format, so we will */ + /* demap quantized gray output. Never emit a colormap. */ + write_header(cinfo, dinfo, 0); + if (cinfo->quantize_colors) + dest->pub.put_pixel_rows = put_demapped_gray; + else + dest->pub.put_pixel_rows = put_gray_rows; + } else if (cinfo->out_color_space == JCS_RGB) { + if (cinfo->quantize_colors) { + /* We only support 8-bit colormap indexes, so only 256 colors */ + num_colors = cinfo->actual_number_of_colors; + if (num_colors > 256) + ERREXIT1(cinfo, JERR_TOO_MANY_COLORS, num_colors); + write_header(cinfo, dinfo, num_colors); + /* Write the colormap. Note Targa uses BGR byte order */ + outfile = dest->pub.output_file; + for (i = 0; i < num_colors; i++) { + putc(GETJSAMPLE(cinfo->colormap[2][i]), outfile); + putc(GETJSAMPLE(cinfo->colormap[1][i]), outfile); + putc(GETJSAMPLE(cinfo->colormap[0][i]), outfile); + } + dest->pub.put_pixel_rows = put_gray_rows; + } else { + write_header(cinfo, dinfo, 0); + dest->pub.put_pixel_rows = put_pixel_rows; + } + } else { + ERREXIT(cinfo, JERR_TGA_COLORSPACE); + } +} + + +/* + * Finish up at the end of the file. + */ + +METHODDEF(void) +finish_output_tga (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) +{ + /* Make sure we wrote the output file OK */ + fflush(dinfo->output_file); + if (ferror(dinfo->output_file)) + ERREXIT(cinfo, JERR_FILE_WRITE); +} + + +/* + * The module selection routine for Targa format output. + */ + +GLOBAL(djpeg_dest_ptr) +jinit_write_targa (j_decompress_ptr cinfo) +{ + tga_dest_ptr dest; + + /* Create module interface object, fill in method pointers */ + dest = (tga_dest_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(tga_dest_struct)); + dest->pub.start_output = start_output_tga; + dest->pub.finish_output = finish_output_tga; + + /* Calculate output image dimensions so we can allocate space */ + jpeg_calc_output_dimensions(cinfo); + + /* Create I/O buffer. Note we make this near on a PC. */ + dest->buffer_width = cinfo->output_width * cinfo->output_components; + dest->iobuffer = (char *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (size_t) (dest->buffer_width * SIZEOF(char))); + + /* Create decompressor output buffer. */ + dest->pub.buffer = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, dest->buffer_width, (JDIMENSION) 1); + dest->pub.buffer_height = 1; + + return (djpeg_dest_ptr) dest; +} + +#endif /* TARGA_SUPPORTED */ diff --git a/gs/language.txt b/gs/language.txt new file mode 100644 index 000000000..00dd65fda --- /dev/null +++ b/gs/language.txt @@ -0,0 +1,768 @@ + Copyright (C) 1989, 1995, 1996, 1997 Aladdin Enterprises. All rights reserved. + + This file is part of Aladdin Ghostscript. + + Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author + or distributor accepts any responsibility for the consequences of using it, + or for whether it serves any particular purpose or works at all, unless he + or she says so in writing. Refer to the Aladdin Ghostscript Free Public + License (the "License") for full details. + + Every copy of Aladdin Ghostscript must include a copy of the License, + normally in a plain ASCII text file named PUBLIC. The License grants you + the right to copy, modify and redistribute Aladdin Ghostscript, but only + under certain conditions described in the License. Among other things, the + License requires that the copyright notice and this notice be preserved on + all copies. + +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +This file, language.txt, describes the relationship between the Ghostscript +interpreter and the PostScript language. + +For an overview of Ghostscript and a list of the documentation files, see +README. + +The Ghostscript interpreter, except as noted below, is intended to execute +properly any source program written in the (Level 2) PostScript language as +defined in the December 1990 printing of the PostScript Language Reference +Manual (Second Edition) published by Addison-Wesley (ISBN 0-201-18127-4). +However, the interpreter is configurable in ways that can restrict it to +various subsets of this language. Specifically, the base interpreter +accepts the Level 1 subset of the PostScript language, as defined in the +first edition of the PostScript Language Reference Manual, ISBN +0-201-10174-2, Addison-Wesley, 1985, plus the file system, version 25.0 +language, and miscellaneous additions listed in sections A.1.6, A.1.7, and +A.1.8 of the Second Edition respectively, including allowing a string +operand for the 'status' operator. The base interpreter may be configured +by adding any combination of the following: + + - The ability to process PostScript Type 1 fonts. This facility is +normally included in the interpreter. + + - The CMYK color extensions listed in section A.1.4 of the Second +Edition (including colorimage). These facilities are only available if the +color, dps, or level2 feature was selected at the time that Ghostscript was +compiled and linked. + + - The Display PostScript extensions listed in section A.1.3 +of the Second Edition, but excluding the operators listed in section +A.1.2. These facilities are only available if the dps feature or the +level2 feature was selected at the time that Ghostscript was compiled +and linked. + + - The composite font extensions listed in section A.1.5 of the +Second Edition, and the ability to handle Type 0 fonts. These facilities +are only available if the compfont feature or the level2 feature was +selected at the time that Ghostscript was compiled and linked. + + - The ability to load TrueType fonts and to handle PostScript Type +42 (encapsulated TrueType) fonts. These facilities are only available if +the ttfont feature was selected at the time that Ghostscript was compiled +and linked. + + - The PostScript Level 2 "filter" facilities aside from DCTEncode +and DCTDecode filters. These facilities are only available if the filter, +dps, or level2 feature was selected at the time that Ghostscript was +compiled and linked. + + - The PostScript Level 2 DCTEncode and DCTDecode filters. These +facilities are only available if the dct or level2 feature was selected at +the time that Ghostscript was compiled and linked. + + - All the other PostScript Level 2 operators and facilities listed +in section A.1.1 of the Second Edition and not listed in any of the other +A.1.n sections. These facilities are only available if the level2 feature +was selected at the time that Ghostscript was compiled and linked. + + - The ability to recognize MS-DOS EPSF files and process only the +PostScript part, ignoring bitmap previews or other information. This +facility is only available if the epsf feature was selected at the time that +Ghostscript was compiled and linked. + +Adding all of these produces a full Level 2 PostScript language +interpreter. + +Ghostscript also includes the optional ability to interpret files in the PDF +1.2 format defined in the Portable Document Format Reference Manual, Version +1.2 (November 12, 1996) distributed by Adobe Systems Incorporated. This +facility is only available if the 'pdf' feature was selected at the time +that Ghostscript was compiled and linked. + +Ghostscript also includes a number of operators defined below that are not +in the PostScript language. + +Implementation limits +===================== + +The following implementation limits correspond to those in Table B.1 and +B.2 of the Second Edition. Those marked with * are different from the ones +in the Second Edition. + +Architectural limits +-------------------- + +integer 32-bit two's complement integer +real single-precision IEEE float +*array + On 16-bit systems: 8191 elements + On 32-bit systems: 65535 elements +*dictionary + On 16-bit systems: 8190 elements + On 32-bit systems: 65534 elements +*string 65535 characters +*name 16383 characters +filename 100 characters +*save level none (capacity of memory) +*gsave level none (capacity of memory) + +Typical memory limits in Level 1 +-------------------------------- + +userdict 200 +FontDirectory 100 +*operand stack 800 +dictionary stack 20 +execution stack 250 +*interpreter level none (capacity of memory) +*path none (capacity of memory) +dash 11 +*VM capacity of memory +*file determined by operating system +*image 65535 values (samples x components) for 1, 2, 4, + or 8-bit samples; 32767 values for 12-bit samples + +Other differences in VM consumption +----------------------------------- + +Packed array elements occupy either 2 bytes or 8 bytes. The average +element size is probably about 5 bytes. + +Names occupy 12 bytes plus the space for the string. + +Graphics/text operator additions +================================ + +Graphics state operators +------------------------ + + .setaccuratecurves - + Sets a graphics state flag that determines whether curves + and arcs, when flattened, always start and end with a + line that a segment of the tangent; this also causes + butt and square caps to be properly perpendicular to + the tangent. initgraphics sets this flag to false, + to match other PostScript implementations. + + - .currentaccuratecurves + Returns the current value of the accurate curves flag. + + .setclipoutside - + Sets a graphics state flag that determines whether the + effective clipping region is the inside (false) or the + outside (true) of the region defined by the clipping + operators (clip, rectclip, etc.) initclip sets this + flag to false. + + - .currentclipoutside + Returns the current value of the outside clipping flag. + + .setdashadapt - + Sets a graphics state flag that determines whether dash + patterns do (true) or do not (false) automatically scale + themselves so that each line segment consists of an + integral number of pattern repetitions. initgraphics sets + this flag to false. + + - .currentdashadapt + Returns the current value of the dash adaptation flag. + + .setdefaultmatrix - + Sets the default matrix that is returned by defaultmatrix + and installed by initmatrix. Ordinary programs should + not use this operator. + + .setdotlength - + Sets a graphics state parameter that determines the handling + of zero-length lines (dots). If the dot length is zero, + dots are painted as circles if round line caps are in + effect, otherwise they are not painted at all. If the dot + length is non-zero, dots are treated exactly like lines of + the given length: the length is specified in user + coordinates (like line width) if bool is false, or in + default user coordinates (1/72" units) if bool is true. + Dots occurring as part of dash patterns will be oriented + correctly; isolated dots will be oriented as though they + were part of a vertical line. initgraphics sets the dot + length to zero. + + - .currentdotlength + Returns the current dot length and dot length mode. + + .setfilladjust2 - + Sets graphics state parameters that cause all filled and + stroked regions to be "fattened" by the given amount + relative to an algorithm that only paints pixels whose + centers fall within the region to be painted. + dx and dy are numbers between 0 and 0.5, measured in + device space. The only two values that are likely to + be useful are 0, which gives a pure center-of-pixel + rule, and 0.5, which gives Adobe's any-part-of-pixel + rule. (0.5 is treated slightly specially in order to + create half-open pixels per Adobe's specification.) + + - .currentfilladjust2 + Returns the current fill adjustment values. + +Path operators +-------------- + + - .dashpath - + If there is no current dash pattern, does nothing. + Otherwise, does the equivalent of flattenpath and then + chops up the path as determined by the dash pattern. + + .rectappend - + .rectappend - + .rectappend - + Appends a rectangle or rectangles to the current path, in + the same manner as rectfill, rectclip, etc. Only + defined if the dps and/or level2 option is selected. + +Painting operators +------------------ + +Ghostscript supports an experimental extension of the PostScript imaging +model to include RasterOp and some related facilities. This extension is +only available if the rasterop option was selected when building +Ghostscript. + +With the RasterOp extension, imaging operations compute a function D = +f(D,S,T) in RGB space, where f is an arbitrary 3-input Boolean function, D +is the destination (frame buffer or print buffer), S is the source +(described below), and T is the texture (the current PostScript color, which +may be a pattern). The source and texture depend on the PostScript imaging +operation: + + - For fill and stroke, the source is solid black, covering the + region to be painted; the texture is the current PostScript color. + + - For show and imagemask, the source is solid black, covering the + pixels to be painted; the texture is the current PostScript color. + + - For image and colorimage, the source is the image data; the + texture depends on an optional Boolean parameter, CombineWithColor, + in the image dictionary. If CombineWithColor is false (the + default), the texture is solid black. If CombineWithColor is true, + the texture is the current color. For the non-dictionary form of + the image operator, CombineWithColor is considered to be false. + +The rasterop option adds the following operators: + + .setrasterop - + Sets the RasterOp function in the graphics state. + The default function is 252, Source | Texture. + + - .currentrasterop + Returns the current RasterOp function. + + .setsourcetransparent - + Sets source transparency in the graphics state. When source + transparency is true, white source pixels prevent storing + into the destination, regardless of what the RasterOp + function returns. The default source transparency is + false. + + - .currentsourcetransparent - + Returns the current source transparency. + + .settexturetransparent - + Sets texture transparency in the graphics state. When texture + transparency is true, white texture pixels prevent storing + into the destination, regardless of what the RasterOp + function returns. The default texture transparency is + false. + + - .currenttexturetransparent - + Returns the current texture transparency. + +For more information on RasterOp and transparency, please consult chapter 5 +of the "PCL 5 Color Technical Reference Manual", Hewlett-Packard Manual Part +No. 5961-0635. + +Character operators +------------------- + + .charboxpath - + For each character C in the rendering of , let the + bounding box of C *in device space* be the four + *user-space* points p1x/y, p2x/y, p3x/y, and p4x/y. For + each character in order, .charboxpath appends the + following to the current path: + - If is true, the equivalent of: + p1x p1y moveto + p2x p2y lineto + p3x p3y lineto + p4x p4y lineto + closepath + This creates a path whose pathbbox is the bbox of the + string. + - If is false, the equivalent of: + p1x p1y moveto + p3x p3y lineto + If the CTM is well-behaved (consists only of reflection, + scaling, and rotation by multiples of 90 degrees), this + too creates a (simpler) path whose pathbbox is the bbox of + the string. + + .type1execchar - + Does all the work for rendering a Type 1 outline. This + operator, like setcharwidth and setcachedevice, is + only valid in the context of a show operator -- i.e., + it must only be called from within a BuildChar or + BuildGlyph procedure. + + %Type1BuildChar - + This is not a new operator: rather, it is a name known + specially to the interpreter. Whenever the interpreter + needs to render a character (during a ...show, + stringwidth, or charpath), it looks up the name + BuildChar in the font dictionary to find a procedure to + run. If it does not find this name, and if the FontType + is 1, the interpreter instead uses the value (looked up + on the dictionary stack in the usual way) of the name + %Type1BuildChar. + The standard definition of %Type1BuildChar is in gs_type1.ps. + Users should not need to redefine %Type1BuildChar, except + perhaps for tracing or debugging. + + %Type1BuildGlyph - + Provides the Type 1 implementation of BuildGlyph. + +Other operator additions +======================== + +Mathematical operators +---------------------- + + arccos + Computes the arc cosine of a number between -1 and 1. + + arcsin + Computes the arc sine of a number between -1 and 1. + +String operators +---------------- + + .type1encrypt + Encrypts fromString according to the algorithm for Adobe + Type 1 fonts, writing the result into toString. + toString must be at least as long as fromString or a + rangecheck error occurs. state is the initial state of + the encryption algorithm (a 16-bit non-negative + integer); newState is the new state of the algorithm. + + .type1decrypt + Decrypts fromString according to the algorithm for Adobe + Type 1 fonts, writing the result into toString. Other + specifications are as for type1encrypt. + +Relational operators +-------------------- + + max + Returns the larger of two numbers or strings. + + min + Returns the smaller of two numbers or strings. + +File operators +-------------- + + findlibfile true + findlibfile false + Opens the file of the given name for reading, searching + through directories as described in use.txt. If the + search fails, findlibfile simply pushes false on the + stack and returns, rather than causing an error. + + unread - + Pushes back the last-read character onto the front of the + file. If the file is only open for writing, or if the + integer argument is not the same as the last character + read from the file, causes an ioerror error. May also + cause an ioerror if the last operation on the file was not + a reading operation. + + writeppmfile - + Writes the contents of the device, which must be an image + device, onto the file, in Portable PixMap (ppm) format. + Does not close the file. + +Ghostscript also supports the following IODevice in addition to a subset of +those defined in the Adobe documentation: %pipe%command, which opens a pipe +on the given command. This is only supported on operating systems that +provide popen (primarily Unix systems, and not all of those). + +Filters +------- + +Ghostscript supports all the standard PostScript Level 2 filters, except +that it does not currently support the EarlyChange key in the LZWEncode +filter. Ghostscript also supports the as yet undocumented FlateEncode and +FlateDecode filters from PDF 1.2 and (presumably) PostScript Level 3, except +for the Effort key in FlateEncode. In addition, Ghostscript supports the +following non-standard filters: + + /BCPEncode filter + /BCPDecode filter + Create filters that implement the Adobe Binary + Communications Protocol. See Adobe documentation for + details. + + /eexecEncode filter + Creates a filter for encrypting data into the + eexec encrypted format described in the + Adobe Type 1 Font Format documentation. The + seed_integer must be 55665 for proper operation. + This filter produces binary output and does not + include the initial 4 (or lenIV) garbage bytes. + + /eexecDecode filter + /eexecDecode filter + Creates a filter for decrypting data that has been + encrypted using eexec encryption as described in the + Adobe Type 1 Font Format documentation. The + seed_integer must be 55665 for proper operation. + Recognized dictionary keys are: + seed <16-bit integer> (required) + lenIV (default=4) + + /PCXDecode filter + Creates a filter that decodes data in the run-length + encoding used in the PCX graphics file format. + + /PFBDecode filter + Creates a filter that decodes data in .PFB format, the + usual semi-binary representation for Type 1 font files + on IBM PC and compatible systems. If hex_boolean is true, + binary packets are converted to hex; if false, binary + packets are not converted. + + /PixelDifferenceEncode filter + /PixelDifferenceDecode filter + Implements the Predictor=2 pixel-differencing option of the + LZW filters. Recognized keys are: + Colors 1..4 (default=1) + BitsPerComponent 1,2,4,8 (default=8) + Columns >= 0 (required) + See the Adobe "Portable Document Format Reference Manual" + for details. + + /PNGPredictorEncode filter + /PNGPredictorDecode filter + Implements the "filter" algorithms of the PNG graphics + format. Recognized keys are: + Colors 1..16 (default=1) + BitsPerComponent 1,2,4,8,16 (default=8) + Columns >= 0 (default=1) + Predictor 10..15 (default=15) + The Predictor is the PNG algorithm number + 10 for the + Encoding filter; the Decoding filter ignores Predictor. + 15 means the encoder attempts to optimize the choice of + algorithm. For more details, see libpng.mak, which has + a pointer to the PNG specification. + + /TBCPEncode filter + /TBCPDecode filter + Create filters that implement the Adobe Tagged Binary + Communications Protocol. See Adobe documentation for + details. + + /zlibEncode filter + /zlibDecode filter + Creates filters that use the zlib data compression method + (the same method used by the gzip application). + This filter is only available if the fzlib feature was + selected when Ghostscript was compiled and linked. + +Various versions of Ghostscript may also support other non-standard filters +for experimental purposes. The current version includes the following +non-standard filters, which are not documented further. No guarantee is +made that these filters will exist in compatible form, or at all, in future +versions. + + ByteTranslateEncode/Decode + BigStringEncode + BoundedHuffmanEncode/Decode + FirstBitLowOrder false + MaxCodeLength 16 + EndOfData true + EncodeZeroRuns 256 + Tables + BWBlockSortEncode/Decode + BlockSize 16384 + MoveToFrontEncode/Decode + +Ghostscript also supports additional keys in the optional dictionary +operands for some filters. For the LZWDecode filter: + + InitialCodeLength + An integer between 2 and 11 specifying the initial number +of data bits per code. Note that the actual initial code length is 1 +greater than this, to allow for the reset and end-of-data code values. +Default value: 8. + + FirstBitLowOrder + If true, codes appear with their low-order bit first. +Default value: false. + + BlockData + If true, the data is broken into blocks in the manner +specified for the GIF file format. Default value: false. + +For the CCITTFaxEncode and CCITTFaxDecode filters: + + DecodedByteAlign + An integer N with the value 1, 2, 4, 8, or 16, specifying +that decoded data scan lines are always a multiple of N bytes. The encoding +filter skips data in each scan line from Columns to the next multiple of N +bytes; the decoding filter pads each scan line to a multiple of N bytes. +Default value: 1. + +Virtual memory operators +------------------------ + + .forgetsave - + Cancels the effect of a save -- makes it as though the + save never happened. + +Miscellaneous operators +----------------------- + + getenv true + getenv false + Looks up a name in the shell environment. If the name is + found, returns the corresponding value and true; if the + name is not found, returns false. + + .makeoperator + Constructs and returns a new operator that is actually the + given procedure in disguise. The name is only used for + printing. The operator has the executable attribute. + Operators defined in this way do one other thing besides + running the procedure: if an error occurs during the + execution of the procedure, and there has been no net + reduction in operand or dictionary stack depth, the + operand or dictionary stack pointer respectively is reset + to its position at the beginning of the procedure. + + .setdebug - + If the Ghostscript interpreter was built with the DEBUG + flag set, sets or resets any subset of the debugging + flags normally controlled by -Z in the command line. + Has no effect otherwise. + + - .oserrno + Returns the error code for the most recent OS error. + + - .oserror + Returns the error string for the most recent OS error. + +Device operators +---------------- + + copydevice + Copies a device. The copy is writable and installable. + + .getdevice + Returns a device from the set of devices known to the + system. The first device, which is default, is numbered + 0. If the index is out of range, causes a rangecheck + error. This device is actually a prototype, not a + directly usable device, and is marked read-only; + it cannot have its parameters changed or be installed as + the current device. + + makeimagedevice + Makes a new device that accumulates an image in memory. + matrix is the initial transformation matrix: it must be + orthogonal (i.e., [a 0 0 b x y] or [0 a b 0 x y]). + palette is a string of 2^N or 3*2^N elements, specifying + how the 2^N possible pixel values will be interpreted. + Each element is interpreted as a gray value, or as RGB + values, multiplied by 255. For example, if you want + a monochrome image for which 0=white and 1=black, the + palette should be ; if you want a 3-bit deep + image with just the primary colors and their complements + (ignoring the fact that 3-bit images are not supported), + the palette might be <000000 0000ff 00ff00 00ffff + ff0000 ff00ff ffff00 ffffff>. At present, the palette + must contain exactly 2, 4, 16, or 256 entries, + and must contain an entry for black and an entry + for white; if it contains any entries that aren't black, + white, or gray, it must contain at least the six primary + colors (red, green, blue, and their complements cyan, + magenta, and yellow); aside from this, its contents are + arbitrary. + Alternatively, palette can be 16, 24, 32, or null + (equivalent to 24). These are interpreted as: + 16 = 5R, 6G, 5B bits; + 24 = 8R, 8G, 8B bits; + 32 = 8C, 8M, 8Y, 8K bits. + Note that one can also make an image device (with the same + palette as an existing image device) by copying a device + using the copydevice operator. + + makewordimagedevice + + Makes an image device as described above. word? is a + Boolean value indicating whether the data should be stored + in a word-oriented format internally. No ordinary + PostScript programs should use this operator. + + copyscanlines + Copies one or more scan lines from an image device into a + string, starting at a given scan line in the image. + The data is in the same format as for the image + operator. Error if the device is not an image device or + if the string is too small to hold at least one complete + scan line. Always copies an integral number of scan + lines. + + setdevice - + Sets the current device to the specified device. Also + resets the transformation and clipping path to the + initial values for the device. Signals an invalidaccess + error if the device is a prototype. + + - currentdevice + Gets the current device from the graphics state. + + getdeviceprops ... + Gets the properties of a device. See the "device + parameters" section below for details. + + ... + putdeviceprops + Sets properties of a device. May cause undefined, + typecheck, rangecheck, or limitcheck errors. + + - flushpage - + On displays, flushes any buffered output, so that it + is guaranteed to show up on the screen; on printers, + has no effect. + +Device parameters +================= + +Ghostscript supports the concept of device parameters for all devices, not +just page devices. (For non-page devices, these are accessible through +get/putdeviceprops, as indicated above.) + +Here are the currently defined parameters for all devices: + + BitsPerPixel (usually read-only) + Number of bits per pixel. + + .HWMargins [<4 floats>] + Size of non-imageable regions around the edges + of the page, in 1/72" units. + + HWSize [ ] + X and Y size in pixels. + + Name (read-only) + The device name. Currently, same as OutputDevice. + + Colors, GrayValues, RedValues, GreenValues, + BlueValues, ColorValues (usually read-only) + As for the 'deviceinfo' operator of Display PostScript. + Red/Green/Blue/ColorValues are only defined if Colors > 1. + + TextAlphaBits, GraphicsAlphaBits (usually read-only) + The number of bits of anti-aliasing + information for text or graphics + respectively. Legal values are 1 (no + anti-aliasing), 2, or 4; the default value + for most devices is 1. + +In addition, the following are defined per Adobe's documentation for the +setpagedevice operator: + Duplex (if supported) + HWResolution + ImagingBBox + Margins + NumCopies (for printers only) + Orientation (if supported) + OutputDevice + PageOffset (write-only) + PageSize + ProcessColorModel +Some devices may only allow certain values for HWResolution and PageSize. +The null device ignores attempts to set PageSize; its size is always [0 0]. + +For printers, the following are also defined: + + BufferSpace + Buffer space for band lists, if the bitmap + is too big to fit in RAM. + + MaxBitmap + Maximum space for a full bitmap in RAM. + + OutputFile + () means send to printer directly, + otherwise specifies the file name for + output; a %d is replaced by the page #; + on Unix systems, (|command) writes to a pipe + + OpenOutputFile + If true, open the device's output file + when the device is opened, rather than + waiting until the first page is ready to + print. + + PageCount (read-only) + Counts the number of pages printed on the device. + +The following parameters are for use only by very specialized applications +that separate band construction from band rasterization. Improper use may +cause unpredictable errors. In particular, if you only want to allocate +more memory for banding, to increase band size and improve performance, use +the BufferSpace parameter, not BandBufferSpace. + + BandHeight + The height of bands when banding. 0 means use the largest + band height that will fit within the BandBufferSpace + (or BufferSpace, if BandBufferSpace is not specified). + + BandWidth + The width of bands in the rasterizing pass, in pixels. 0 + means use the actual page width. + + BandBufferSpace + The size of the band buffer in the rasterizing pass, in + bytes. 0 means use the same buffer size as for the + interpretation pass. + +In addition, Ghostscript supports the following parameter for +setpagedevice/currentpagedevice that is *not* a device parameter per se: + + ViewerPreProcess procedure + Specifies a procedure to be applied to the page device + dictionary before any other processing is done. The + procedure may not alter the dictionary, but it may return + a modified copy. This "hook" is provided for use by + viewing programs such as GSview. + +Miscellaneous additions +======================= + +run can take either a string or a file as its argument. In the latter +case, it just runs the file, closing it at the end, and trapping errors +just as for the string case. + +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +PostScript is a trademark of Adobe Systems, Incorporated. diff --git a/gs/lib.txt b/gs/lib.txt new file mode 100644 index 000000000..e279b053e --- /dev/null +++ b/gs/lib.txt @@ -0,0 +1,363 @@ + Copyright (C) 1989, 1996 Aladdin Enterprises. All rights reserved. + + This file is part of Aladdin Ghostscript. + + Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author + or distributor accepts any responsibility for the consequences of using it, + or for whether it serves any particular purpose or works at all, unless he + or she says so in writing. Refer to the Aladdin Ghostscript Free Public + License (the "License") for full details. + + Every copy of Aladdin Ghostscript must include a copy of the License, + normally in a plain ASCII text file named PUBLIC. The License grants you + the right to copy, modify and redistribute Aladdin Ghostscript, but only + under certain conditions described in the License. Among other things, the + License requires that the copyright notice and this notice be preserved on + all copies. + +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +This file, lib.txt, describes the Ghostscript library, a collection of C +procedures that implement the primitive graphic operations of the +Ghostscript language. + +For an overview of Ghostscript and a list of the documentation files, see +README. + +******** +******** The Ghostscript library ******** +******** + +Ghostscript is actually two programs: a language interpreter, and a graphics +library. The library provides, in the form of C procedures, all the +graphics functions of the language, i.e., approximately those facilities +listed in section 8.1 of the PostScript Language Reference Manual, Second +Edition, starting with the graphics state operators. In addition, the +library provides some lower-level graphics facilities that offer higher +performance in exchange for less generality. + +PostScript operator API +----------------------- + +The highest level of the library, which is the one that most clients will +use, directly implements the PostScript graphics operators with procedures +named gs_XXX, e.g., gs_moveto, gs_fill. Nearly all of these procedures take +a graphics state object as their first argument, e.g., + int gs_moveto(gs_state *, double, double); + +Nearly all procedures return an integer code which is >= 0 for a successful +return or <0 for a failure. The failure codes correspond directly to +PostScript errors, and are defined in gserrors.h. + +The library implements all the operators in the following sections of the +PostScript Language Reference Manual, Second Edition, with the indicated +omissions and with the APIs defined in the indicated .h files. A header of +the form A.h(B.h) indicates that A.h is included in B.h, so A.h need not be +included explicitly if B.h is included. Operators marked with * in the +Omissions column are not implemented directly; the library provides +lower-level procedures that can be used to implement the operator. + +There are slight differences in the operators that return multiple values, +since C's provisions for this are awkward. Also, the control structure for +the operators involving (a) callback procedure(s) (pathforall, image, +colorimage, imagemask) is partly inverted: the client calls a procedure to +set up an enumerator object, and then calls another procedure for each +iteration. The ...show operators, charpath, and stringwidth also use an +inverted control structure. + +Section Headers Omissions +------- ------- --------- + +Graphics State Operators -- +Device Independent + gscolor.h(gsstate.h) + gscolor1.h + gscolor2.h + gscspace.h + gshsb.h + gsline.h(gsstate.h) + gsstate.h + +Graphics State Operators -- +Device Dependent + gscolor.h(gsstate.h) + gscolor1.h + gscolor2.h + gsht.h(gsht1.h,gsstate.h) + gsht1.h + gsline.h(gsstate.h) + +Coordinate System and +Matrix Operators + gscoord.h *matrix, *identmatrix, + gsmatrix.h *concatmatrix, *invertmatrix + +Path Construction Operators + gspath.h *arct, *pathforall, + gspath2.h ustrokepath, uappend, upath, ucache + +Painting Operators + gsimage.h *image, *colorimage, *imagemask, + gspaint.h ufill, ueofill, ustroke + gspath2.h + +Form and Pattern Operators + gscolor2.h execform + +Device Setup and Output +Operators + gsdevice.h *showpage, *set/currentpagedevice + +Character and Font Operators + gschar.h *(all the show operators), + gsfont.h definefont, undefinefont, + findfont, *scalefont, *makefont, + selectfont, [Global]FontDirectory, + Standard/ISOLatin1Encoding, + findencoding + +<< -------------------------------- end -------------------------------- >> + +The following procedures in the above list operate differently from their +PostScript operator counterparts: + +Procedure(header) Difference(s) +----------------- ------------- + +gs_makepattern(gscolor2.h) + Takes an explicit current color, rather than using + the current color in the graphics state. + Takes an explicit allocator for allocating the + pattern implementation. See below for more details + on gs_makepattern. + +gs_setpattern(gscolor2.h) +gs_setcolor(gscolor2.h) +gs_currentcolor(gscolor2.h) + Use gs_client_color rather than a set of color + parameter values. See below for more details on + gs_setpattern. + +gs_currentdash_length/pattern/offset(gsline.h) + Splits up currentdash into 3 separate procedures. + +gs_screen_init/currentpoint/next/install(gsht.h) + Provide an "enumeration style" interface to + setscreen. (gs_setscreen is also implemented.) + +gs_rotate/scale/translate(gscoord.h) +gs_[i][d]transform(gscoord.h) + These always operate on the graphics state CTM. + The corresponding operations on free-standing + matrices are in gsmatrix.h and have different names. + +gs_path_enum_alloc/init/next/cleanup(gspath.h) + Provide an "enumeration style" implementation of + pathforall. + +gs_image_enum_alloc(gsimage.h) +gs_image_init/next/cleanup(gsimage.h) + Provide an "enumeration style" interface to the + equivalent of image, imagemask, and colorimage. + In the gs_image_t, ColorSpace provides an explicit + color space, rather than using the current color + space in the graphics state; ImageMask distinguishes + imagemask from [color]image. + +gs_get/putdeviceparams(gsdevice.h) + Take a gs_param_list for specifying or receiving + the parameter values. See gsparam.h for more + details. + +gs_show_enum_alloc/release(gschar.h) +gs_xxxshow_[n_]init(gschar.h) +gs_show_next(gschar.h) + Provide an "enumeration style" interface to writing + text. Note that control returns to the caller if + the character must be rasterized. + +<< -------------------------------- end -------------------------------- >> + +This level of the library also implements the following operators from other +sections of the Manual: + +Section Headers Operators +------- ------- --------- + +Interpreter Parameter +Operators + gsfont.h cachestatus, setcachelimit, + *set/currentcacheparams + +Display PostScript Operators + gsstate.h set/currenthalftonephase + +<< -------------------------------- end -------------------------------- >> + +In order to obtain the full PostScript Level 2 functionality listed above, +FEATURE_DEVS must be set in the makefile to include at least the following: + + FEATURE_DEVS=patcore.dev cmykcore.dev psl2core.dev dps2core.dev ciecore.dev\ + path1core.dev hsbcore.dev + +The *lib.mak makefiles mentioned below do not always include all of these +features. + +Files named gs*.c implement the higher level of the graphics library. As +might be expected, all procedures, variables, and structures available at +this level begin with gs_. Structures that appear in these interfaces, but +whose definitions may be hidden from clients, also have names beginning with +gs_, i.e., the prefix reflects at what level the abstraction is made +available, not the implementation. + +Patterns +-------- + +Patterns are the most complicated PostScript language objects that the +library API deals with. As in PostScript, defining a pattern color and +using the color are two separate operations. + +gs_makepattern defines a pattern color. Its arguments are as follows: + + gs_client_color * -- the resulting Pattern color is stored here. + This is different from PostScript, which has no color objects per + se and hence returns a modified copy of the dictionary. + + const gs_client_pattern * -- the analogue of the original Pattern + dictionary, described in detail just below. + + const gs_matrix * -- corresponds to the matrix argument of the + makepattern operator. + + gs_state * -- the current graphics state. + + gs_memory_t * -- the allocator to use for allocating the saved data + for the Pattern color. If this is NULL, gs_makepattern uses the + same allocator that allocated the graphics state. Library clients + should probably always use NULL. + +The gs_client_pattern structure defined in gscolor2.h corresponds to the +Pattern dictionary that is the argument to the PostScript language +makepattern operator. This structure has one extra member, void +*client_data, which is a place for clients to store a pointer to additional +data for the PaintProc; this provides the same functionality as putting +additional keys in the Pattern dictionary at the PostScript language level. +The PaintProc is an ordinary C procedure that takes as parameters a +gs_client_color *, which is the Pattern color that is being used for +painting, and a gs_state *, which is the same graphics state that would be +presented to the PaintProc in PostScript. Currently the gs_client_color * +is always the current color in the graphics state, but the PaintProc should +not rely on this. The PaintProc can retrieve the gs_client_pattern * from +the gs_client_color * with the gs_getpattern procedure, also defined in +gscolor2.h, and from there, it can retrieve the client_data pointer. + +The normal way to set a Pattern color is to call gs_setpattern with the +graphics state and with the gs_client_color returned by gs_makepattern. +After that, one can use gs_setcolor to set further Pattern colors (colored, +or uncolored with the same underlying color space); the rules are the same +as those in PostScript. Note that for gs_setpattern, the paint.values in +the gs_client_color must be filled in for uncolored patterns; this +corresponds to the additional arguments for the PostScript setpattern +operator in the uncolored case. + +There is a special procedure gs_makebitmappattern for creating bitmap-based +patterns. Its API is documented in gscolor2.h; its implementation, in +gspcolor.c, may be useful as an example of a pattern using a particularly +simple PaintProc. + +Lower-level API +--------------- + +Files named gx*.c implement the lower level of the graphics library. The +interfaces at the gx level are less stable, and expose more of the +implementation detail, than those at the gs level: in particular, the gx +interfaces generally use device coordinates in an internal fixed-point +representation, as opposed to the gs interfaces that use floating point user +coordinates. Named entities at this level begin with gx_. + +Files named gz*.c and gz*.h are internal to the Ghostscript implementation, +and are not designed to be called by clients. + +A full example +-------------- + +The file gslib.c in the Ghostscript fileset is a complete example program +that initializes the library and produces output using it; files named +*lib.mak (e.g., ugcclib.mak, bclib.mak) are makefiles using gslib.c as the +main program. The following annotated excerpts from this file are intended +to provide a roadmap for applications that call the library. + + /* Capture stdin/out/err before gs.h redefines them. */ + #include + static FILE *real_stdin, *real_stdout, *real_stderr; + static void + get_real(void) + { real_stdin = stdin, real_stdout = stdout, real_stderr = stderr; + } + +Any application using Ghostscript should include the above fragment at the +very beginning of the main program. + + #include "gx.h" + +The gx.h header includes a wealth of declarations related to the Ghostscript +memory manager, portability machinery, debugging framework, and other +substrate facilities. Any application file that calls any Ghostscript API +functions should probably include gx.h. + + /* Configuration information imported from gconfig.c. */ + extern gx_device *gx_device_list[]; + + /* Other imported procedures */ + /* from gsinit.c */ + extern void gs_lib_init(P1(FILE *)); + extern void gs_lib_finit(P2(int, int)); + /* from gsalloc.c */ + extern gs_ref_memory_t *ialloc_alloc_state(P2(gs_memory_t *, uint)); + +The above externs are needed for initializing the library. + + gs_ref_memory_t *imem; + #define mem ((gs_memory_t *)imem) + gs_state *pgs; + gx_device *dev = gx_device_list[0]; + + gp_init(); + get_real(); + gs_stdin = real_stdin; + gs_stdout = real_stdout; + gs_stderr = real_stderr; + gs_lib_init(stdout); + .... + imem = ialloc_alloc_state(&gs_memory_default, 20000); + imem->space = 0; + .... + pgs = gs_state_alloc(mem); + +The above code initializes the library and its memory manager. pgs now +points to the graphics state that will be passed to the drawing routines in +the library. + + gs_setdevice_no_erase(pgs, dev); /* can't erase yet */ + { gs_point dpi; + gs_screen_halftone ht; + gs_dtransform(pgs, 72.0, 72.0, &dpi); + ht.frequency = min(fabs(dpi.x), fabs(dpi.y)) / 16.001; + ht.angle = 0; + ht.spot_function = odsf; + gs_setscreen(pgs, &ht); + } + +The above initializes the default device and sets a default halftone screen. +(For brevity, we have omitted the definition of odsf, the spot function.) + + /* gsave and grestore (among other places) assume that */ + /* there are at least 2 gstates on the graphics stack. */ + /* Ensure that now. */ + gs_gsave(pgs); + +The above call completes initializing the graphics state. + +When the program is finished, it should execute: + + gs_lib_finit(0, 0); diff --git a/gs/lib/Fontmap b/gs/lib/Fontmap new file mode 100644 index 000000000..70e42feea --- /dev/null +++ b/gs/lib/Fontmap @@ -0,0 +1,399 @@ +% Copyright (C) 1996 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% Fontmap - standard font catalog for Ghostscript. + +% ---------------------------------------------------------------- + +% This file is a catalog of fonts known to Ghostscript. Any font +% that is to be loaded automatically when named must be in this catalog, +% except for fonts that Ghostscript finds automatically in directories +% named in the GS_FONTPATH environment variable. + +% Each font has an entry consisting of three items: +% +% - The name by which the font is known inside Ghostscript +% (a Ghostscript name preceded by a `/', or a string enclosed +% in parentheses). This is used to find the file from which +% a font of a given name should be loaded. +% +% - Information depending on whether this is a real font or a +% font alias: +% +% - For real fonts, the name of the Ghostscript font +% file (a Ghostscript string, enclosed in parentheses). +% The filename should include the extension, which (by +% convention) is `.gsf'. `.pfa' and `.pfb' files are +% also usable as fonts for Ghostscript. +% +% - For font aliases, the name of the font which should +% be used when this one is requested, preceded by a +% `/'. See the entry for Charter below for an example. +% Note that an alias name cannot be enclosed in parentheses. +% +% - At least one space or tab, and a terminating semicolon. + +% Because of limitations in the MS-DOS environment, Ghostscript font +% file names must be no more than 8 characters long, must consist only +% of LOWER CASE letters, digits, and underscores, and must start with a +% letter. Font names, on the other hand, need only obey the syntax of +% names in the Ghostscript language, which is much more liberal. + +% The following table is actually a Ghostscript data structure. +% If you add new entries, be sure to copy the punctuation accurately; +% in particular, you must leave at least one space or tab between each +% field in the entry. Also, please read fonts.doc for important information +% about font names. + +% Note that .pfa and .pfb fonts are compatible with Adobe Type Manager +% and other programs that don't include full PostScript interpreters, +% as well as with PostScript interpreters; .gsf fonts are compatible with +% PostScript interpreters, but not with ATM or similar programs. + +% +% +% Fonts contributed by: +% URW++ Design and Development Incorporated +% Poppenbuetteler Bogen 29A +% D-22399 Hamburg +% Germany +% tel. +49 (40) 60 60 50 +% fax +49 (40) 60 60 51 11 +% http://www.urwpp.de +% for distribution under the GNU License and Aladdin Free Public License. +% See the notice at the head of this Fontmap file for licensing terms. +% Each of these fonts is individually covered by the license: +% for licensing purposes, they are not "part of" any larger entity. +% The following notice applies to these fonts: +% +% Copyright URW Software, Copyright 1994 by URW. +% + +% Actual fonts + +/URWBookmanL-DemiBold (b018015l.pfb) ; +/URWBookmanL-DemiBoldItal (b018035l.pfb) ; +/URWBookmanL-Ligh (b018012l.pfb) ; +/URWBookmanL-LighItal (b018032l.pfb) ; + +/NimbusMonL-Regu (n022003l.pfb) ; +/NimbusMonL-ReguObli (n022023l.pfb) ; +/NimbusMonL-Bold (n022004l.pfb) ; +/NimbusMonL-BoldObli (n022024l.pfb) ; + +/URWGothicL-Book (a010013l.pfb) ; +/URWGothicL-BookObli (a010033l.pfb) ; +/URWGothicL-Demi (a010015l.pfb) ; +/URWGothicL-DemiObli (a010035l.pfb) ; + +/NimbusSanL-Regu (n019003l.pfb) ; +/NimbusSanL-ReguItal (n019023l.pfb) ; +/NimbusSanL-Bold (n019004l.pfb) ; +/NimbusSanL-BoldItal (n019024l.pfb) ; + +/NimbusSanL-ReguCond (n019043l.pfb) ; +/NimbusSanL-ReguCondItal (n019063l.pfb) ; +/NimbusSanL-BoldCond (n019044l.pfb) ; +/NimbusSanL-BoldCondItal (n019064l.pfb) ; + +/URWPalladioL-Roma (p052003l.pfb) ; +/URWPalladioL-Ital (p052023l.pfb) ; +/URWPalladioL-Bold (p052004l.pfb) ; +/URWPalladioL-BoldItal (p052024l.pfb) ; + +/CenturySchL-Roma (c059013l.pfb) ; +/CenturySchL-Ital (c059033l.pfb) ; +/CenturySchL-Bold (c059016l.pfb) ; +/CenturySchL-BoldItal (c059036l.pfb) ; + +/NimbusRomNo9L-Regu (n021003l.pfb) ; +/NimbusRomNo9L-ReguItal (n021023l.pfb) ; +/NimbusRomNo9L-Medi (n021004l.pfb) ; +/NimbusRomNo9L-MediItal (n021024l.pfb) ; + +/StandardSymL (s050000l.pfb) ; + +/URWChanceryL-MediItal (z003034l.pfb) ; + +/Dingbats (d050000l.pfb) ; + +% Aliases + +/Bookman-Demi /URWBookmanL-DemiBold ; +/Bookman-DemiItalic /URWBookmanL-DemiBoldItal ; +/Bookman-Light /URWBookmanL-Ligh ; +/Bookman-LightItalic /URWBookmanL-LighItal ; + +/Courier /NimbusMonL-Regu ; +/Courier-Oblique /NimbusMonL-ReguObli ; +/Courier-Bold /NimbusMonL-Bold ; +/Courier-BoldOblique /NimbusMonL-BoldObli ; + +/AvantGarde-Book /URWGothicL-Book ; +/AvantGarde-BookOblique /URWGothicL-BookObli ; +/AvantGarde-Demi /URWGothicL-Demi ; +/AvantGarde-DemiOblique /URWGothicL-DemiObli ; + +/Helvetica /NimbusSanL-Regu ; +/Helvetica-Oblique /NimbusSanL-ReguItal ; +/Helvetica-Bold /NimbusSanL-Bold ; +/Helvetica-BoldOblique /NimbusSanL-BoldItal ; + +/Helvetica-Narrow /NimbusSanL-ReguCond ; +/Helvetica-Narrow-Oblique /NimbusSanL-ReguCondItal ; +/Helvetica-Narrow-Bold /NimbusSanL-BoldCond ; +/Helvetica-Narrow-BoldOblique /NimbusSanL-BoldCondItal ; + +/Palatino-Roman /URWPalladioL-Roma ; +/Palatino-Italic /URWPalladioL-Ital ; +/Palatino-Bold /URWPalladioL-Bold ; +/Palatino-BoldItalic /URWPalladioL-BoldItal ; + +/NewCenturySchlbk-Roman /CenturySchL-Roma ; +/NewCenturySchlbk-Italic /CenturySchL-Ital ; +/NewCenturySchlbk-Bold /CenturySchL-Bold ; +/NewCenturySchlbk-BoldItalic /CenturySchL-BoldItal ; + +/Times-Roman /NimbusRomNo9L-Regu ; +/Times-Italic /NimbusRomNo9L-ReguItal ; +/Times-Bold /NimbusRomNo9L-Medi ; +/Times-BoldItalic /NimbusRomNo9L-MediItal ; + +/Symbol /StandardSymL ; + +/ZapfChancery-MediumItalic /URWChanceryL-MediItal ; + +/ZapfDingbats /Dingbats ; + +% +% +% Type 1 fonts contributed to the X11R5 distribution. +% + +% The following notice accompanied the Charter fonts. +% +% (c) Copyright 1989-1992, Bitstream Inc., Cambridge, MA. +% +% You are hereby granted permission under all Bitstream propriety rights +% to use, copy, modify, sublicense, sell, and redistribute the 4 Bitstream +% Charter (r) Type 1 outline fonts and the 4 Courier Type 1 outline fonts +% for any purpose and without restriction; provided, that this notice is +% left intact on all copies of such fonts and that Bitstream's trademark +% is acknowledged as shown below on all unmodified copies of the 4 Charter +% Type 1 fonts. +% +% BITSTREAM CHARTER is a registered trademark of Bitstream Inc. + +% The Bitstream Charter fonts have different names (CharterBT- +% instead of Charter-), but Ghostscript doesn't care. +/Charter-Roman (bchr.pfa) ; +/Charter-Italic (bchri.pfa) ; +/Charter-Bold (bchb.pfa) ; +/Charter-BoldItalic (bchbi.pfa) ; + +% The following notice accompanied the Utopia font: +% +% Permission to use, reproduce, display and distribute the listed +% typefaces is hereby granted, provided that the Adobe Copyright notice +% appears in all whole and partial copies of the software and that the +% following trademark symbol and attribution appear in all unmodified +% copies of the software: +% +% Copyright (c) 1989 Adobe Systems Incorporated +% Utopia (R) +% Utopia is a registered trademark of Adobe Systems Incorporated +% +% The Adobe typefaces (Type 1 font program, bitmaps and Adobe Font +% Metric files) donated are: +% +% Utopia Regular +% Utopia Italic +% Utopia Bold +% Utopia Bold Italic + +/Utopia-Regular (putr.pfa) ; +/Utopia-Italic (putri.pfa) ; +/Utopia-Bold (putb.pfa) ; +/Utopia-BoldItalic (putbi.pfa) ; + +% +% +% Fonts contributed by URW GmbH for distribution under the GNU License. +% The following notice accompanied these fonts: +% +% U004006T URW Grotesk 2031 Bold PostScript Type 1 Font Program +% U003043T URW Antiqua 2051 Regular Condensed PostScript Type 1 Font Program +% +% Copyright (c) 1992 URW GmbH, Hamburg, Germany +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; wihtout even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +% See the GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +% +% Address: +% URW GmbH +% PC Support +% Harksheider Strasse 102 +% 2000 Hamburg 65 +% Germany +% Phone: +49 40 60 60 50 (Reception) +% Phone: +49 40 60 60 52 30 (PC Support) +% Fax : +49 40 60 60 52 52 +% + +/URWAntiquaT-RegularCondensed (u003043t.gsf) ; +/URWGroteskT-Bold (u004006t.gsf) ; + +% +% +% Shareware Kana fonts. These are subject to the following notice: +% +% These copyrighted fonts were developed by Kevin Hartig. Permission is +% granted to freely distribute them in entirety along with this statement. +% This is shareware. If you decide to use these fonts please contribute +% $10 US to help support further freeware and shareware software development. +% Questions and comments may be sent to: +% +% hartig@fsl.noaa.gov +% khartig@nyx.cs.du.edu +% +% Kevin Hartig +% 1126 Collyer Street +% Longmont, CO 80501 USA +% +% copyright 1993. + +% Hiragana and Katakana fonts. The character names are inappropriate, +% and the encoding is probably not related to any known standard. + +/Calligraphic-Hiragana (fhirw.gsf) ; +/Calligraphic-Katakana (fkarw.gsf) ; + +% +% +% Public-domain fonts. These have no copyright, and are of unknown quality. + +% Cyrillic fonts. The character names are inappropriate, +% and the encoding is probably not related to any known standard. + +/Shareware-Cyrillic-Regular (fcyr.gsf) ; +/Shareware-Cyrillic-Italic (fcyri.gsf) ; + +% Aliases +/Cyrillic /Cyrillic-Regular ; +/Cyrillic-Regular /Shareware-Cyrillic-Regular ; +/Cyrillic-Italic /Shareware-Cyrillic-Italic ; + +% +% +% Fonts converted from Hershey outlines. These are constructed and +% maintained manually. These are also in the public domain. +% +% The suggested UniqueID's and filenames are constructed differently for +% these than for the ones above, because of the strange way that the Hershey +% fonts were constructed. The scheme for these looks like: +% +% 42TTXY0 +% +% TT = typeface, X = ``class'', Y = variation +% +% The typeface names and numbers are listed in fonts.mak. +% +% class: +% 0 = normal = r +% 1 = simplex = s +% 2 = complex = c +% 3 = triplex = t +% 4 = duplex = d +% +% variation: +% 0 = normal (omitted) +% 1 = oblique = o +% 2 = italic = i +% 3 = bold = b +% 4 = bold oblique = bo +% 5 = bold italic = bi +% + +% Fonts created by Thomas Wolff , by adding +% accents, accented characters, and various other non-alphabetics +% to the original Hershey fonts. These are "freeware", not to be sold. + +/Hershey-Gothic-English (hrger.pfa) ; % 5066533 +/Hershey-Gothic-German (hrgrr.pfa) ; +/Hershey-Gothic-Italian (hritr.pfa) ; + +/Hershey-Plain-Duplex (hrpld.pfa) ; +/Hershey-Plain-Duplex-Italic (hrpldi.pfa) ; +/Hershey-Plain-Triplex (hrplt.pfa) ; +/Hershey-Plain-Triplex-Italic (hrplti.pfa) ; + +/Hershey-Script-Complex (hrscc.pfa) ; +/Hershey-Script-Simplex (hrscs.pfa) ; % 5066541 + +% Fonts created algorithmically from the above. + +/Hershey-Gothic-English-Bold (hrgerb.gsf) ; % 5066542 +/Hershey-Gothic-English-Oblique (hrgero.gsf) ; +/Hershey-Gothic-English-SemiBold (hrgerd.gsf) ; +/Hershey-Gothic-German-Bold (hrgrrb.gsf) ; +/Hershey-Gothic-German-Oblique (hrgrro.gsf) ; +/Hershey-Gothic-Italian-Bold (hritrb.gsf) ; +/Hershey-Gothic-Italian-Oblique (hritro.gsf) ; + +/Hershey-Plain-Duplex-Bold (hrpldb.gsf) ; +/Hershey-Plain-Duplex-Bold-Italic (hrpldbi.gsf) ; +/Hershey-Plain-Triplex-Bold (hrpltb.gsf) ; +/Hershey-Plain-Triplex-Bold-Italic (hrpltbi.gsf) ; + +/Hershey-Script-Complex-Bold (hrsccb.gsf) ; +/Hershey-Script-Complex-Oblique (hrscco.gsf) ; +/Hershey-Script-Simplex-Bold (hrscsb.gsf) ; +/Hershey-Script-Simplex-Oblique (hrscso.gsf) ; % 5066556 + +% Fonts consisting only of characters from the original Hershey +% distribution. These are Type 3 fonts. + +/Hershey-Greek-Complex (hrgkc.gsf) ; % 5066557 +/Hershey-Greek-Simplex (hrgks.gsf) ; + +/Hershey-Plain (hrplr.gsf) ; +/Hershey-Plain-Simplex (hrpls.gsf) ; % 5066560 + +% Fonts created algorithmically from the above. + +/Hershey-Plain-Bold (hrplrb.gsf) ; % 5066561 +/Hershey-Plain-Bold-Oblique (hrplrbo.gsf) ; +/Hershey-Plain-Oblique (hrplro.gsf) ; +/Hershey-Plain-Simplex-Bold (hrplsb.gsf) ; +/Hershey-Plain-Simplex-Bold-Oblique (hrplsbo.gsf) ; +/Hershey-Plain-Simplex-Oblique (hrplso.gsf) ; % 5066566 + +% This font, and only this font among the Hershey fonts, uses +% the SymbolEncoding. + +/Hershey-Symbol (hrsyr.gsf) ; % 5066567 diff --git a/gs/lib/Fontmap.ATB b/gs/lib/Fontmap.ATB new file mode 100644 index 000000000..a622c9e6b --- /dev/null +++ b/gs/lib/Fontmap.ATB @@ -0,0 +1,169 @@ +% Copyright (C) 1994 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% Fontmap.ATB - an alternative Fontmap for Ghostscript, +% suitable for use with the 65 Adobe Type Manager fonts +% supplied with Adobe Type Basics. + +% Before you use ATM fonts with Ghostscript, please read carefully +% the license that accompanies the ATM fonts; neither Aladdin Enterprises +% nor any other distributor of Ghostscript takes any responsibility for +% any possible violations of such licenses. + +% The 65 Adobe Type Basics ATM fonts + +%disk 1 +/Bookman-Light (bkl_____.pfb) ; +/Bookman-Demi (bkd_____.pfb) ; +/Bookman-DemiItalic (bkdi____.pfb) ; +/Bookman-LightItalic (bkli____.pfb) ; +/Courier (com_____.pfb) ; +/Courier-Bold (cob_____.pfb) ; +/Courier-BoldOblique (cobo____.pfb) ; +/Courier-Oblique (coo_____.pfb) ; +/Helvetica (hv______.pfb) ; +/Helvetica-Bold (hvb_____.pfb) ; +/Helvetica-BoldOblique (hvbo____.pfb) ; +/Helvetica-Oblique (hvo_____.pfb) ; +/Helvetica-Narrow (hvn_____.pfb) ; +/Helvetica-Narrow-Bold (hvnb____.pfb) ; +/Helvetica-Narrow-BoldOblique (hvnbo___.pfb) ; +/Helvetica-Narrow-Oblique (hvno____.pfb) ; +/Palatino-Roman (por_____.pfb) ; +/Palatino-Bold (pob_____.pfb) ; +/Palatino-BoldItalic (pobi____.pfb) ; +/Palatino-Italic (poi_____.pfb) ; +/Symbol (sy______.pfb) ; +/Times-Roman (tir_____.pfb) ; +/Times-Bold (tib_____.pfb) ; +/Times-BoldItalic (tibi____.pfb) ; +/Times-Italic (tii_____.pfb) ; + +% disk2 +/AGaramond-Regular (gdrg____.pfb) ; +/AGaramond-Italic (gdi_____.pfb) ; +/AGaramond-Bold (gdb_____.pfb) ; +/AGaramond-BoldItalic (gdbi____.pfb) ; +/Americana (am______.pfb) ; +/Americana-ExtraBold (ameb____.pfb) ; +/AvantGarde-Book (agw_____.pfb) ; +/AvantGarde-Demi (agd_____.pfb) ; +/AvantGarde-DemiOblique (agdo____.pfb) ; +/AvantGarde-BookOblique (agwo____.pfb) ; +/Carta (cr______.pfb) ; +/Kaufmann (kf______.pfb) ; +/Lithos-Regular (lorg____.pfb) ; +/Lithos-Black (lobl____.pfb) ; +/NewCenturySchlbk-Roman (ncr_____.pfb) ; +/NewCenturySchlbk-Bold (ncb_____.pfb) ; +/NewCenturySchlbk-BoldItalic (ncbi____.pfb) ; +/NewCenturySchlbk-Italic (nci_____.pfb) ; +/Parisian (pn______.pfb) ; +/ParkAvenue (pa______.pfb) ; +/Tekton (tkrg____.pfb) ; +/Tekton-Bold (tkb_____.pfb) ; +/Trajan-Bold (tjb_____.pfb) ; +/ZapfChancery-MediumItalic (zcmi____.pfb) ; +/ZapfDingbats (zd______.pfb) ; + +%disk 3 +/ACaslon-Regular (awrg____.pfb) ; +/ACaslon-Semibold (awsb____.pfb) ; +/ACaslon-SemiboldItalic (awsbi___.pfb) ; +/ACaslon-Italic (awi_____.pfb) ; +/Barmeno-Regular (bfrg____.pfb) ; +/Barmeno-Medium (bfm_____.pfb) ; +/Barmeno-Bold (bfb_____.pfb) ; +/Barmeno-ExtraBold (bfeb____.pfb) ; +/Blackoak (bo______.pfb) ; +/Formata-Regular (fmrg____.pfb) ; +/Formata-Medium (fmm_____.pfb) ; +/Formata-MediumItalic (fmmi____.pfb) ; +/Formata-Italic (fmi_____.pfb) ; +/Poetica-SuppOrnaments (pvor____.pfb) ; +/WoodtypeOrnaments-Two (woor2___.pfb) ; + + +% Fonts converted from bitmaps. + +/Charter-Roman (bchr.gsf) ; +/Charter-Italic (bchri.gsf) ; +/Charter-Bold (bchb.gsf) ; +/Charter-BoldItalic (bchbi.gsf) ; + +/ZapfChancery (zcr.gsf) ; +/ZapfChancery-Oblique (zcro.gsf) ; +/ZapfChancery-Bold (zcb.gsf) ; + +% Fonts from the X11R5 distribution. + +/Utopia-Regular (putr.gsf) ; +/Utopia-Italic (putri.gsf) ; +/Utopia-Bold (putb.gsf) ; +/Utopia-BoldItalic (putbi.gsf) ; + +% Shareware fonts. See FONTMAP.GS for the copyright statements. + +/Shareware-Cyrillic-Regular (fcyr.gsf) ; +/Shareware-Cyrillic-Italic (fcyri.gsf) ; +% Aliases +/Cyrillic /Cyrillic-Regular ; +/Cyrillic-Regular /Shareware-Cyrillic-Regular ; +/Cyrillic-Italic /Shareware-Cyrillic-Italic ; + +/Calligraphic-Hiragana (fhirw.gsf) ; +/Calligraphic-Katakana (fkarw.gsf) ; + +% Fonts converted from Hershey outlines. + +/Hershey-Gothic-English (hrge_r.gsf) 4290000 ; +/Hershey-Gothic-English-Bold (hrge_rb.gsf) 4290030 ; +/Hershey-Gothic-English-Oblique (hrge_ro.gsf) 4290010 ; + +/Hershey-Gothic-German (hrgr_r.gsf) 4291000 ; +/Hershey-Gothic-German-Bold (hrgr_rb.gsf) 4291030 ; +/Hershey-Gothic-German-Oblique (hrgr_ro.gsf) 4291010 ; + +/Hershey-Gothic-Italian (hrit_r.gsf) 4292000 ; +/Hershey-Gothic-Italian-Bold (hrit_rb.gsf) 4292030 ; +/Hershey-Gothic-Italian-Oblique (hrit_ro.gsf) 4292010 ; + +/Hershey-Greek-Complex (hrgk_c.gsf) 4293200 ; +/Hershey-Greek-Simplex (hrgk_s.gsf) 4293100 ; + +/Hershey-Plain (hrpl_r.gsf) 4294000 ; +/Hershey-Plain-Bold (hrpl_rb.gsf) 4294030 ; +/Hershey-Plain-Oblique (hrpl_ro.gsf) 4294010 ; +/Hershey-Plain-Simplex (hrpl_s.gsf) 4294100 ; +/Hershey-Plain-Simplex-Bold (hrpl_sb.gsf) 4294130 ; +/Hershey-Plain-Simplex-Bold-Oblique (hrpl_sbo.gsf) 4294140 ; +/Hershey-Plain-Simplex-Oblique (hrpl_so.gsf) 4294110 ; +/Hershey-Plain-Triplex (hrpl_t.gsf) 4294300 ; +/Hershey-Plain-Triplex-Italic (hrpl_ti.gsf) 4294320 ; +/Hershey-Plain-Triplex-Bold (hrpl_tb.gsf) 4294330 ; +/Hershey-Plain-Triplex-Bold-Italic (hrpl_tbi.gsf) 4294350 ; + +/Hershey-Script-Complex (hrsc_c.gsf) 4295200 ; +/Hershey-Script-Complex-Bold (hrsc_cb.gsf) 4295230 ; +/Hershey-Script-Complex-Oblique (hrsc_co.gsf) 4295210 ; +/Hershey-Script-Simplex (hrsc_s.gsf) 4295100 ; +/Hershey-Script-Simplex-Bold (hrsc_sb.gsf) 4295130 ; +/Hershey-Script-Simplex-Oblique (hrsc_so.gsf) 4295110 ; + +% This font, and only this font among the Hershey fonts, uses +% the SymbolEncoding. +/Hershey-Symbol (hrsy_r.gsf) 4296000 ; diff --git a/gs/lib/Fontmap.ATM b/gs/lib/Fontmap.ATM new file mode 100644 index 000000000..6500a7a5d --- /dev/null +++ b/gs/lib/Fontmap.ATM @@ -0,0 +1,186 @@ +% Copyright (C) 1990, 1992, 1994, 1996 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% Fontmap.ATM - an alternative Fontmap for Ghostscript, +% suitable for use with Adobe Type Manager fonts. + +% Before you use ATM fonts with Ghostscript, please read carefully +% the license that accompanies the ATM fonts; neither Aladdin Enterprises +% nor any other distributor of Ghostscript takes any responsibility for +% any possible violations of such licenses. + +% +% +% Fonts contributed by: +% URW++ Design and Development Incorporated +% Poppenbuetteler Bogen 29A +% D-22399 Hamburg +% Germany +% tel. +49 (40) 60 60 50 +% fax +49 (40) 60 60 51 11 +% http://www.urwpp.de +% for distribution under the GNU License and Aladdin Free Public License. +% See the notice at the head of this Fontmap file for licensing terms. +% Each of these fonts is individually covered by the license: +% for licensing purposes, they are not "part of" any larger entity. +% The following notice applies to these fonts: +% +% Copyright URW Software, Copyright 1994 by URW. +% + +% Actual fonts + +/URWBookmanL-DemiBold (b018015l.pfb) ; +/URWBookmanL-DemiBoldItal (b018035l.pfb) ; +/URWBookmanL-Ligh (b018012l.pfb) ; +/URWBookmanL-LighItal (b018032l.pfb) ; + +/NimbusMonL-Regu (n022003l.pfb) ; +/NimbusMonL-ReguObli (n022023l.pfb) ; +/NimbusMonL-Bold (n022004l.pfb) ; +/NimbusMonL-BoldObli (n022024l.pfb) ; + +/URWGothicL-Book (a010013l.pfb) ; +/URWGothicL-BookObli (a010033l.pfb) ; +/URWGothicL-Demi (a010015l.pfb) ; +/URWGothicL-DemiObli (a010035l.pfb) ; + +/NimbusSanL-Regu (n019003l.pfb) ; +/NimbusSanL-ReguItal (n019023l.pfb) ; +/NimbusSanL-Bold (n019004l.pfb) ; +/NimbusSanL-BoldItal (n019024l.pfb) ; + +/NimbusSanL-ReguCond (n019043l.pfb) ; +/NimbusSanL-ReguCondItal (n019063l.pfb) ; +/NimbusSanL-BoldCond (n019044l.pfb) ; +/NimbusSanL-BoldCondItal (n019064l.pfb) ; + +/URWPalladioL-Roma (p052003l.pfb) ; +/URWPalladioL-Ital (p052023l.pfb) ; +/URWPalladioL-Bold (p052004l.pfb) ; +/URWPalladioL-BoldItal (p052024l.pfb) ; + +/CenturySchL-Roma (c059013l.pfb) ; +/CenturySchL-Ital (c059033l.pfb) ; +/CenturySchL-Bold (c059016l.pfb) ; +/CenturySchL-BoldItal (c059036l.pfb) ; + +/NimbusRomNo9L-Regu (n021003l.pfb) ; +/NimbusRomNo9L-ReguItal (n021023l.pfb) ; +/NimbusRomNo9L-Medi (n021004l.pfb) ; +/NimbusRomNo9L-MediItal (n021024l.pfb) ; + +/StandardSymL (s050000l.pfb) ; + +/URWChanceryL-MediItal (z003034l.pfb) ; + +/Dingbats (d050000l.pfb) ; + +% Aliases + +/Bookman-Demi /URWBookmanL-DemiBold ; +/Bookman-DemiItalic /URWBookmanL-DemiBoldItal ; +/Bookman-Light /URWBookmanL-Ligh ; +/Bookman-LightItalic /URWBookmanL-LighItal ; + +/Courier /NimbusMonL-Regu ; +/Courier-Oblique /NimbusMonL-ReguObli ; +/Courier-Bold /NimbusMonL-Bold ; +/Courier-BoldOblique /NimbusMonL-BoldObli ; + +/AvantGarde-Book /URWGothicL-Book ; +/AvantGarde-BookOblique /URWGothicL-BookObli ; +/AvantGarde-Demi /URWGothicL-Demi ; +/AvantGarde-DemiOblique /URWGothicL-DemiObli ; + +/Helvetica /NimbusSanL-Regu ; +/Helvetica-Oblique /NimbusSanL-ReguItal ; +/Helvetica-Bold /NimbusSanL-Bold ; +/Helvetica-BoldOblique /NimbusSanL-BoldItal ; + +/Helvetica-Narrow /NimbusSanL-ReguCond ; +/Helvetica-Narrow-Oblique /NimbusSanL-ReguCondItal ; +/Helvetica-Narrow-Bold /NimbusSanL-BoldCond ; +/Helvetica-Narrow-BoldOblique /NimbusSanL-BoldCondItal ; + +/Palatino-Roman /URWPalladioL-Roma ; +/Palatino-Italic /URWPalladioL-Ital ; +/Palatino-Bold /URWPalladioL-Bold ; +/Palatino-BoldItalic /URWPalladioL-BoldItal ; + +/NewCenturySchlbk-Roman /CenturySchL-Roma ; +/NewCenturySchlbk-Italic /CenturySchL-Ital ; +/NewCenturySchlbk-Bold /CenturySchL-Bold ; +/NewCenturySchlbk-BoldItalic /CenturySchL-BoldItal ; + +/Times-Roman /NimbusRomNo9L-Regu ; +/Times-Italic /NimbusRomNo9L-ReguItal ; +/Times-Bold /NimbusRomNo9L-Medi ; +/Times-BoldItalic /NimbusRomNo9L-MediItal ; + +/Symbol /StandardSymL ; + +/ZapfChancery-MediumItalic /URWChanceryL-MediItal ; + +/ZapfDingbats /Dingbats ; + + +% ATM fonts. + +/Courier (com_____.pfb) ; +/Courier-Oblique (coo_____.pfb) ; +/Courier-Bold (cob_____.pfb) ; +/Courier-BoldOblique (cobo____.pfb) ; + +/Helvetica (hv______.pfb) ; +/Helvetica-Oblique (hvo_____.pfb) ; +/Helvetica-Bold (hvb_____.pfb) ; +/Helvetica-BoldOblique (hvbo____.pfb) ; + +/Symbol (sy______.pfb) ; + +/Times-Roman (tir_____.pfb) ; +/Times-Italic (tii_____.pfb) ; +/Times-Bold (tib_____.pfb) ; +/Times-BoldItalic (tibi____.pfb) ; + + +% More fonts from Adobe Type Manager for MS Windows. + +/TektonMM (zjrg____.pfb) ; + +/Boulevard (qtrg____.pfb) ; +/Anna (iarg____.pfb) ; + +/PopplLaudatio-Regular (pyrg____.pfb) ; +/PopplLaudatio-Medium (pym_____.pfb) ; +/PopplLaudatio-Italic (pyi_____.pfb) ; +/PopplLaudatio-MediumItalic (pymi____.pfb) ; + +/Boton-Regular (tnr_____.pfb) ; +/Boton-Medium (tnm_____.pfb) ; +/Boton-Italic (tni_____.pfb) ; +/Boton-MediumItalic (tnmi____.pfb) ; + +/BaskervilleBE-Regular (virg____.pfb) ; +/BaskervilleBE-Medium (vim_____.pfb) ; +/BaskervilleBE-Italic (vii_____.pfb) ; +/BaskervilleBE-MediumItalic (vimi____.pfb) ; + +/Giddyup (wg______.pfb) ; +/Giddyup-Thangs (wgtha___.pfb) ; + diff --git a/gs/lib/Fontmap.GS b/gs/lib/Fontmap.GS new file mode 100644 index 000000000..70e42feea --- /dev/null +++ b/gs/lib/Fontmap.GS @@ -0,0 +1,399 @@ +% Copyright (C) 1996 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% Fontmap - standard font catalog for Ghostscript. + +% ---------------------------------------------------------------- + +% This file is a catalog of fonts known to Ghostscript. Any font +% that is to be loaded automatically when named must be in this catalog, +% except for fonts that Ghostscript finds automatically in directories +% named in the GS_FONTPATH environment variable. + +% Each font has an entry consisting of three items: +% +% - The name by which the font is known inside Ghostscript +% (a Ghostscript name preceded by a `/', or a string enclosed +% in parentheses). This is used to find the file from which +% a font of a given name should be loaded. +% +% - Information depending on whether this is a real font or a +% font alias: +% +% - For real fonts, the name of the Ghostscript font +% file (a Ghostscript string, enclosed in parentheses). +% The filename should include the extension, which (by +% convention) is `.gsf'. `.pfa' and `.pfb' files are +% also usable as fonts for Ghostscript. +% +% - For font aliases, the name of the font which should +% be used when this one is requested, preceded by a +% `/'. See the entry for Charter below for an example. +% Note that an alias name cannot be enclosed in parentheses. +% +% - At least one space or tab, and a terminating semicolon. + +% Because of limitations in the MS-DOS environment, Ghostscript font +% file names must be no more than 8 characters long, must consist only +% of LOWER CASE letters, digits, and underscores, and must start with a +% letter. Font names, on the other hand, need only obey the syntax of +% names in the Ghostscript language, which is much more liberal. + +% The following table is actually a Ghostscript data structure. +% If you add new entries, be sure to copy the punctuation accurately; +% in particular, you must leave at least one space or tab between each +% field in the entry. Also, please read fonts.doc for important information +% about font names. + +% Note that .pfa and .pfb fonts are compatible with Adobe Type Manager +% and other programs that don't include full PostScript interpreters, +% as well as with PostScript interpreters; .gsf fonts are compatible with +% PostScript interpreters, but not with ATM or similar programs. + +% +% +% Fonts contributed by: +% URW++ Design and Development Incorporated +% Poppenbuetteler Bogen 29A +% D-22399 Hamburg +% Germany +% tel. +49 (40) 60 60 50 +% fax +49 (40) 60 60 51 11 +% http://www.urwpp.de +% for distribution under the GNU License and Aladdin Free Public License. +% See the notice at the head of this Fontmap file for licensing terms. +% Each of these fonts is individually covered by the license: +% for licensing purposes, they are not "part of" any larger entity. +% The following notice applies to these fonts: +% +% Copyright URW Software, Copyright 1994 by URW. +% + +% Actual fonts + +/URWBookmanL-DemiBold (b018015l.pfb) ; +/URWBookmanL-DemiBoldItal (b018035l.pfb) ; +/URWBookmanL-Ligh (b018012l.pfb) ; +/URWBookmanL-LighItal (b018032l.pfb) ; + +/NimbusMonL-Regu (n022003l.pfb) ; +/NimbusMonL-ReguObli (n022023l.pfb) ; +/NimbusMonL-Bold (n022004l.pfb) ; +/NimbusMonL-BoldObli (n022024l.pfb) ; + +/URWGothicL-Book (a010013l.pfb) ; +/URWGothicL-BookObli (a010033l.pfb) ; +/URWGothicL-Demi (a010015l.pfb) ; +/URWGothicL-DemiObli (a010035l.pfb) ; + +/NimbusSanL-Regu (n019003l.pfb) ; +/NimbusSanL-ReguItal (n019023l.pfb) ; +/NimbusSanL-Bold (n019004l.pfb) ; +/NimbusSanL-BoldItal (n019024l.pfb) ; + +/NimbusSanL-ReguCond (n019043l.pfb) ; +/NimbusSanL-ReguCondItal (n019063l.pfb) ; +/NimbusSanL-BoldCond (n019044l.pfb) ; +/NimbusSanL-BoldCondItal (n019064l.pfb) ; + +/URWPalladioL-Roma (p052003l.pfb) ; +/URWPalladioL-Ital (p052023l.pfb) ; +/URWPalladioL-Bold (p052004l.pfb) ; +/URWPalladioL-BoldItal (p052024l.pfb) ; + +/CenturySchL-Roma (c059013l.pfb) ; +/CenturySchL-Ital (c059033l.pfb) ; +/CenturySchL-Bold (c059016l.pfb) ; +/CenturySchL-BoldItal (c059036l.pfb) ; + +/NimbusRomNo9L-Regu (n021003l.pfb) ; +/NimbusRomNo9L-ReguItal (n021023l.pfb) ; +/NimbusRomNo9L-Medi (n021004l.pfb) ; +/NimbusRomNo9L-MediItal (n021024l.pfb) ; + +/StandardSymL (s050000l.pfb) ; + +/URWChanceryL-MediItal (z003034l.pfb) ; + +/Dingbats (d050000l.pfb) ; + +% Aliases + +/Bookman-Demi /URWBookmanL-DemiBold ; +/Bookman-DemiItalic /URWBookmanL-DemiBoldItal ; +/Bookman-Light /URWBookmanL-Ligh ; +/Bookman-LightItalic /URWBookmanL-LighItal ; + +/Courier /NimbusMonL-Regu ; +/Courier-Oblique /NimbusMonL-ReguObli ; +/Courier-Bold /NimbusMonL-Bold ; +/Courier-BoldOblique /NimbusMonL-BoldObli ; + +/AvantGarde-Book /URWGothicL-Book ; +/AvantGarde-BookOblique /URWGothicL-BookObli ; +/AvantGarde-Demi /URWGothicL-Demi ; +/AvantGarde-DemiOblique /URWGothicL-DemiObli ; + +/Helvetica /NimbusSanL-Regu ; +/Helvetica-Oblique /NimbusSanL-ReguItal ; +/Helvetica-Bold /NimbusSanL-Bold ; +/Helvetica-BoldOblique /NimbusSanL-BoldItal ; + +/Helvetica-Narrow /NimbusSanL-ReguCond ; +/Helvetica-Narrow-Oblique /NimbusSanL-ReguCondItal ; +/Helvetica-Narrow-Bold /NimbusSanL-BoldCond ; +/Helvetica-Narrow-BoldOblique /NimbusSanL-BoldCondItal ; + +/Palatino-Roman /URWPalladioL-Roma ; +/Palatino-Italic /URWPalladioL-Ital ; +/Palatino-Bold /URWPalladioL-Bold ; +/Palatino-BoldItalic /URWPalladioL-BoldItal ; + +/NewCenturySchlbk-Roman /CenturySchL-Roma ; +/NewCenturySchlbk-Italic /CenturySchL-Ital ; +/NewCenturySchlbk-Bold /CenturySchL-Bold ; +/NewCenturySchlbk-BoldItalic /CenturySchL-BoldItal ; + +/Times-Roman /NimbusRomNo9L-Regu ; +/Times-Italic /NimbusRomNo9L-ReguItal ; +/Times-Bold /NimbusRomNo9L-Medi ; +/Times-BoldItalic /NimbusRomNo9L-MediItal ; + +/Symbol /StandardSymL ; + +/ZapfChancery-MediumItalic /URWChanceryL-MediItal ; + +/ZapfDingbats /Dingbats ; + +% +% +% Type 1 fonts contributed to the X11R5 distribution. +% + +% The following notice accompanied the Charter fonts. +% +% (c) Copyright 1989-1992, Bitstream Inc., Cambridge, MA. +% +% You are hereby granted permission under all Bitstream propriety rights +% to use, copy, modify, sublicense, sell, and redistribute the 4 Bitstream +% Charter (r) Type 1 outline fonts and the 4 Courier Type 1 outline fonts +% for any purpose and without restriction; provided, that this notice is +% left intact on all copies of such fonts and that Bitstream's trademark +% is acknowledged as shown below on all unmodified copies of the 4 Charter +% Type 1 fonts. +% +% BITSTREAM CHARTER is a registered trademark of Bitstream Inc. + +% The Bitstream Charter fonts have different names (CharterBT- +% instead of Charter-), but Ghostscript doesn't care. +/Charter-Roman (bchr.pfa) ; +/Charter-Italic (bchri.pfa) ; +/Charter-Bold (bchb.pfa) ; +/Charter-BoldItalic (bchbi.pfa) ; + +% The following notice accompanied the Utopia font: +% +% Permission to use, reproduce, display and distribute the listed +% typefaces is hereby granted, provided that the Adobe Copyright notice +% appears in all whole and partial copies of the software and that the +% following trademark symbol and attribution appear in all unmodified +% copies of the software: +% +% Copyright (c) 1989 Adobe Systems Incorporated +% Utopia (R) +% Utopia is a registered trademark of Adobe Systems Incorporated +% +% The Adobe typefaces (Type 1 font program, bitmaps and Adobe Font +% Metric files) donated are: +% +% Utopia Regular +% Utopia Italic +% Utopia Bold +% Utopia Bold Italic + +/Utopia-Regular (putr.pfa) ; +/Utopia-Italic (putri.pfa) ; +/Utopia-Bold (putb.pfa) ; +/Utopia-BoldItalic (putbi.pfa) ; + +% +% +% Fonts contributed by URW GmbH for distribution under the GNU License. +% The following notice accompanied these fonts: +% +% U004006T URW Grotesk 2031 Bold PostScript Type 1 Font Program +% U003043T URW Antiqua 2051 Regular Condensed PostScript Type 1 Font Program +% +% Copyright (c) 1992 URW GmbH, Hamburg, Germany +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; wihtout even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +% See the GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +% +% Address: +% URW GmbH +% PC Support +% Harksheider Strasse 102 +% 2000 Hamburg 65 +% Germany +% Phone: +49 40 60 60 50 (Reception) +% Phone: +49 40 60 60 52 30 (PC Support) +% Fax : +49 40 60 60 52 52 +% + +/URWAntiquaT-RegularCondensed (u003043t.gsf) ; +/URWGroteskT-Bold (u004006t.gsf) ; + +% +% +% Shareware Kana fonts. These are subject to the following notice: +% +% These copyrighted fonts were developed by Kevin Hartig. Permission is +% granted to freely distribute them in entirety along with this statement. +% This is shareware. If you decide to use these fonts please contribute +% $10 US to help support further freeware and shareware software development. +% Questions and comments may be sent to: +% +% hartig@fsl.noaa.gov +% khartig@nyx.cs.du.edu +% +% Kevin Hartig +% 1126 Collyer Street +% Longmont, CO 80501 USA +% +% copyright 1993. + +% Hiragana and Katakana fonts. The character names are inappropriate, +% and the encoding is probably not related to any known standard. + +/Calligraphic-Hiragana (fhirw.gsf) ; +/Calligraphic-Katakana (fkarw.gsf) ; + +% +% +% Public-domain fonts. These have no copyright, and are of unknown quality. + +% Cyrillic fonts. The character names are inappropriate, +% and the encoding is probably not related to any known standard. + +/Shareware-Cyrillic-Regular (fcyr.gsf) ; +/Shareware-Cyrillic-Italic (fcyri.gsf) ; + +% Aliases +/Cyrillic /Cyrillic-Regular ; +/Cyrillic-Regular /Shareware-Cyrillic-Regular ; +/Cyrillic-Italic /Shareware-Cyrillic-Italic ; + +% +% +% Fonts converted from Hershey outlines. These are constructed and +% maintained manually. These are also in the public domain. +% +% The suggested UniqueID's and filenames are constructed differently for +% these than for the ones above, because of the strange way that the Hershey +% fonts were constructed. The scheme for these looks like: +% +% 42TTXY0 +% +% TT = typeface, X = ``class'', Y = variation +% +% The typeface names and numbers are listed in fonts.mak. +% +% class: +% 0 = normal = r +% 1 = simplex = s +% 2 = complex = c +% 3 = triplex = t +% 4 = duplex = d +% +% variation: +% 0 = normal (omitted) +% 1 = oblique = o +% 2 = italic = i +% 3 = bold = b +% 4 = bold oblique = bo +% 5 = bold italic = bi +% + +% Fonts created by Thomas Wolff , by adding +% accents, accented characters, and various other non-alphabetics +% to the original Hershey fonts. These are "freeware", not to be sold. + +/Hershey-Gothic-English (hrger.pfa) ; % 5066533 +/Hershey-Gothic-German (hrgrr.pfa) ; +/Hershey-Gothic-Italian (hritr.pfa) ; + +/Hershey-Plain-Duplex (hrpld.pfa) ; +/Hershey-Plain-Duplex-Italic (hrpldi.pfa) ; +/Hershey-Plain-Triplex (hrplt.pfa) ; +/Hershey-Plain-Triplex-Italic (hrplti.pfa) ; + +/Hershey-Script-Complex (hrscc.pfa) ; +/Hershey-Script-Simplex (hrscs.pfa) ; % 5066541 + +% Fonts created algorithmically from the above. + +/Hershey-Gothic-English-Bold (hrgerb.gsf) ; % 5066542 +/Hershey-Gothic-English-Oblique (hrgero.gsf) ; +/Hershey-Gothic-English-SemiBold (hrgerd.gsf) ; +/Hershey-Gothic-German-Bold (hrgrrb.gsf) ; +/Hershey-Gothic-German-Oblique (hrgrro.gsf) ; +/Hershey-Gothic-Italian-Bold (hritrb.gsf) ; +/Hershey-Gothic-Italian-Oblique (hritro.gsf) ; + +/Hershey-Plain-Duplex-Bold (hrpldb.gsf) ; +/Hershey-Plain-Duplex-Bold-Italic (hrpldbi.gsf) ; +/Hershey-Plain-Triplex-Bold (hrpltb.gsf) ; +/Hershey-Plain-Triplex-Bold-Italic (hrpltbi.gsf) ; + +/Hershey-Script-Complex-Bold (hrsccb.gsf) ; +/Hershey-Script-Complex-Oblique (hrscco.gsf) ; +/Hershey-Script-Simplex-Bold (hrscsb.gsf) ; +/Hershey-Script-Simplex-Oblique (hrscso.gsf) ; % 5066556 + +% Fonts consisting only of characters from the original Hershey +% distribution. These are Type 3 fonts. + +/Hershey-Greek-Complex (hrgkc.gsf) ; % 5066557 +/Hershey-Greek-Simplex (hrgks.gsf) ; + +/Hershey-Plain (hrplr.gsf) ; +/Hershey-Plain-Simplex (hrpls.gsf) ; % 5066560 + +% Fonts created algorithmically from the above. + +/Hershey-Plain-Bold (hrplrb.gsf) ; % 5066561 +/Hershey-Plain-Bold-Oblique (hrplrbo.gsf) ; +/Hershey-Plain-Oblique (hrplro.gsf) ; +/Hershey-Plain-Simplex-Bold (hrplsb.gsf) ; +/Hershey-Plain-Simplex-Bold-Oblique (hrplsbo.gsf) ; +/Hershey-Plain-Simplex-Oblique (hrplso.gsf) ; % 5066566 + +% This font, and only this font among the Hershey fonts, uses +% the SymbolEncoding. + +/Hershey-Symbol (hrsyr.gsf) ; % 5066567 diff --git a/gs/lib/Fontmap.OS2 b/gs/lib/Fontmap.OS2 new file mode 100644 index 000000000..4ec6074bf --- /dev/null +++ b/gs/lib/Fontmap.OS2 @@ -0,0 +1,215 @@ +% Copyright (C) 1990, 1992, 1993, 1996 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% fontmap.os2 aka Fontmap.OS2 - OS/2 font catalog for Ghostscript. + +% ---------------------------------------------------------------- + +% This file is a catalog of fonts known to Ghostscript. Any font +% that is to be loaded automatically when named must be in this catalog, +% except for fonts that Ghostscript finds automatically in directories +% named in the GS_FONTPATH environment variable. + +% Each font has an entry consisting of three items: +% +% - The name by which the font is known inside Ghostscript +% (a Ghostscript name preceded by a `/', or a string enclosed +% in parentheses). This is used to find the file from which +% a font of a given name should be loaded. +% +% - Information depending on whether this is a real font or a +% font alias: +% +% - For real fonts, the name of the Ghostscript font +% file (a Ghostscript string, enclosed in parentheses). +% The filename should include the extension, which (by +% convention) is `.gsf'. `.pfa' and `.pfb' files are +% also usable as fonts for Ghostscript. +% +% - For font aliases, the name of the font which should +% be used when this one is requested, preceded by a +% `/'. See the entry for Charter below for an example. +% +% - A terminating semicolon. + +% Because of limitations in the MS-DOS environment, Ghostscript font +% file names must be no more than 8 characters long, must consist only +% of LOWER CASE letters, digits, and underscores, and must start with a +% letter. Font names, on the other hand, need only obey the syntax of +% names in the Ghostscript language, which is much more liberal. + +% Most of the Ghostscript fonts were created automatically from freely +% available bitmaps. There is a makefile (fonts.mak) that specifies +% how this conversion was done. fonts.mak also specifies, for each such +% converted font, its uniqueID (an integer used to identify distinct fonts +% within the Ghostscript font machinery), and its encoding (the mapping +% from character codes in a string to character names). For more detailed +% information, read fonts.mak. + +% The following table is actually a Ghostscript data structure. +% If you add new entries, be sure to copy the punctuation accurately; +% in particular, you must leave at least one space or tab between each +% field in the entry. Also, please read fonts.doc for important information +% about font names. + + +% +% +% Fonts contributed by: +% URW++ Design and Development Incorporated +% Poppenbuetteler Bogen 29A +% D-22399 Hamburg +% Germany +% tel. +49 (40) 60 60 50 +% fax +49 (40) 60 60 51 11 +% http://www.urwpp.de +% for distribution under the GNU License and Aladdin Free Public License. +% See the notice at the head of this Fontmap file for licensing terms. +% Each of these fonts is individually covered by the license: +% for licensing purposes, they are not "part of" any larger entity. +% The following notice applies to these fonts: +% +% Copyright URW Software, Copyright 1994 by URW. +% + +% Actual fonts + +/URWBookmanL-DemiBold (b018015l.pfb) ; +/URWBookmanL-DemiBoldItal (b018035l.pfb) ; +/URWBookmanL-Ligh (b018012l.pfb) ; +/URWBookmanL-LighItal (b018032l.pfb) ; + +/NimbusMonL-Regu (n022003l.pfb) ; +/NimbusMonL-ReguObli (n022023l.pfb) ; +/NimbusMonL-Bold (n022004l.pfb) ; +/NimbusMonL-BoldObli (n022024l.pfb) ; + +/URWGothicL-Book (a010013l.pfb) ; +/URWGothicL-BookObli (a010033l.pfb) ; +/URWGothicL-Demi (a010015l.pfb) ; +/URWGothicL-DemiObli (a010035l.pfb) ; + +/NimbusSanL-Regu (n019003l.pfb) ; +/NimbusSanL-ReguItal (n019023l.pfb) ; +/NimbusSanL-Bold (n019004l.pfb) ; +/NimbusSanL-BoldItal (n019024l.pfb) ; + +/NimbusSanL-ReguCond (n019043l.pfb) ; +/NimbusSanL-ReguCondItal (n019063l.pfb) ; +/NimbusSanL-BoldCond (n019044l.pfb) ; +/NimbusSanL-BoldCondItal (n019064l.pfb) ; + +/URWPalladioL-Roma (p052003l.pfb) ; +/URWPalladioL-Ital (p052023l.pfb) ; +/URWPalladioL-Bold (p052004l.pfb) ; +/URWPalladioL-BoldItal (p052024l.pfb) ; + +/CenturySchL-Roma (c059013l.pfb) ; +/CenturySchL-Ital (c059033l.pfb) ; +/CenturySchL-Bold (c059016l.pfb) ; +/CenturySchL-BoldItal (c059036l.pfb) ; + +/NimbusRomNo9L-Regu (n021003l.pfb) ; +/NimbusRomNo9L-ReguItal (n021023l.pfb) ; +/NimbusRomNo9L-Medi (n021004l.pfb) ; +/NimbusRomNo9L-MediItal (n021024l.pfb) ; + +/StandardSymL (s050000l.pfb) ; + +/URWChanceryL-MediItal (z003034l.pfb) ; + +/Dingbats (d050000l.pfb) ; + +% Aliases + +/Bookman-Demi /URWBookmanL-DemiBold ; +/Bookman-DemiItalic /URWBookmanL-DemiBoldItal ; +/Bookman-Light /URWBookmanL-Ligh ; +/Bookman-LightItalic /URWBookmanL-LighItal ; + +/Courier /NimbusMonL-Regu ; +/Courier-Oblique /NimbusMonL-ReguObli ; +/Courier-Bold /NimbusMonL-Bold ; +/Courier-BoldOblique /NimbusMonL-BoldObli ; + +/AvantGarde-Book /URWGothicL-Book ; +/AvantGarde-BookOblique /URWGothicL-BookObli ; +/AvantGarde-Demi /URWGothicL-Demi ; +/AvantGarde-DemiOblique /URWGothicL-DemiObli ; + +/Helvetica /NimbusSanL-Regu ; +/Helvetica-Oblique /NimbusSanL-ReguItal ; +/Helvetica-Bold /NimbusSanL-Bold ; +/Helvetica-BoldOblique /NimbusSanL-BoldItal ; + +/Helvetica-Narrow /NimbusSanL-ReguCond ; +/Helvetica-Narrow-Oblique /NimbusSanL-ReguCondItal ; +/Helvetica-Narrow-Bold /NimbusSanL-BoldCond ; +/Helvetica-Narrow-BoldOblique /NimbusSanL-BoldCondItal ; + +/Palatino-Roman /URWPalladioL-Roma ; +/Palatino-Italic /URWPalladioL-Ital ; +/Palatino-Bold /URWPalladioL-Bold ; +/Palatino-BoldItalic /URWPalladioL-BoldItal ; + +/NewCenturySchlbk-Roman /CenturySchL-Roma ; +/NewCenturySchlbk-Italic /CenturySchL-Ital ; +/NewCenturySchlbk-Bold /CenturySchL-Bold ; +/NewCenturySchlbk-BoldItalic /CenturySchL-BoldItal ; + +/Times-Roman /NimbusRomNo9L-Regu ; +/Times-Italic /NimbusRomNo9L-ReguItal ; +/Times-Bold /NimbusRomNo9L-Medi ; +/Times-BoldItalic /NimbusRomNo9L-MediItal ; + +/Symbol /StandardSymL ; + +/ZapfChancery-MediumItalic /URWChanceryL-MediItal ; + +/ZapfDingbats /Dingbats ; + + +% +% ATM fonts that come with OS/2. + +/Courier (cour.pfb) ; +/Courier-Oblique /Courier-Italic ; +/Courier-Italic (couri.pfb) ; +/Courier-Bold (courb.pfb) ; +/Courier-BoldOblique /Courier-BoldItalic ; +/Courier-BoldItalic (courbi.pfb) ; + +/Helvetica (helv.pfb) ; +/Helvetica-Oblique /Helvetica-Italic ; +/Helvetica-Italic (helvi.pfb) ; +/Helvetica-Bold (helvb.pfb) ; +/Helvetica-BoldOblique /Helvetica-BoldItalic ; +/Helvetica-BoldItalic (helvbi.pfb) ; + +/Symbol /SymbolSet ; +/SymbolSet (symb.pfb) ; + +/Times-Roman /TimesNewRoman ; +/TimesNewRoman (tnr.pfb) ; +/Times-Italic /TimesNewRoman-Italic ; +/TimesNewRoman-Italic (tnri.pfb) ; +/Times-Bold /TimesNewRoman-Bold ; +/TimesNewRoman-Bold (tnrb.pfb) ; +/Times-BoldItalic /TimesNewRoman-BoldItalic ; +/TimesNewRoman-BoldItalic (tnrbi.pfb) ; + + diff --git a/gs/lib/Fontmap.OSF b/gs/lib/Fontmap.OSF new file mode 100644 index 000000000..563f14a99 --- /dev/null +++ b/gs/lib/Fontmap.OSF @@ -0,0 +1,163 @@ +% fontmap.osf aka Fontmap.OSF1 - Ghostscript fontmap for DEC OSF/1 systems. +% +% UNIX systems from Digital Equipment Corporation are bundled with a license +% for Display PostScript, including certain fonts. Using their font outlines +% (which on OSF/1 systems are found in /usr/lib/X11/fonts/Type1Adobe) +% improves the visual quality of documents displayed on screen. To do that, +% use this file as your Fontmap file and add /usr/lib/X11/fonts/Type1Adobe +% as the second argument to GS_LIB_DEFAULT in your makefile +% in your makefile. +% +% This file is Pete Kaiser's original Ultrix file as modified by +% Bjorn S. Nilsson (nilsson@nbi.dk) first for Ultrix 4.3 and then +% for OSF/1 version 1.3. +% + +%/AvantGarde-Book (AvantGarde-Book) ; +%/AvantGarde-BookOblique (AvantGarde-BookOblique); +%/AvantGarde-Demi (AvantGarde-Demi) ; +%/AvantGarde-DemiOblique (AvantGarde-DemiOblique); + +%/Courier-BoldItalic /Courier-BoldOblique ; +%/Courier-Italic /Courier-Oblique ; + +%/Courier (Courier) ; +%/Courier-Bold (Courier-Bold) ; +%/Courier-BoldOblique (Courier-BoldOblique) ; +%/Courier-Oblique (Courier-Oblique) ; + +%/Helvetica (Helvetica) ; +%/Helvetica-Bold (Helvetica-Bold) ; +%/Helvetica-BoldOblique (Helvetica-BoldOblique) ; +%/Helvetica-Oblique (Helvetica-Oblique) ; + +%/LubalinGraph-Book (LubalinGraph-Book) ; +%/LubalinGraph-BookOblique (LubalinGraph-BookOblique); +%/LubalinGraph-Demi (LubalinGraph-Demi) ; +%/LubalinGraph-DemiOblique (LubalinGraph-DemiOblique); + +%/NewCenturySchlbk-Bold (NewCenturySchlbk-Bold) ; +%/NewCenturySchlbk-BoldItalic (NewCenturySchlbk-BoldItalic); +%/NewCenturySchlbk-Italic (NewCenturySchlbk-Italic); +%/NewCenturySchlbk-Roman (NewCenturySchlbk-Roman); + +%/Souvenir-Demi (Souvenir-Demi) ; +%/Souvenir-DemiItalic (Souvenir-DemiItalic) ; +%/Souvenir-Light (Souvenir-Light) ; +%/Souvenir-LightItalic (Souvenir-LightItalic) ; + +%/Symbol (Symbol) ; + +%/Times-Bold (Times-Bold) ; +%/Times-BoldItalic (Times-BoldItalic) ; +%/Times-Italic (Times-Italic) ; +%/Times-Roman (Times-Roman) ; + +%/ZapfDingbats (ZapfDingbats) ; + +/AvantGarde-Book (AvantGarde-Book.pfa) ; +/AvantGarde-BookOblique (AvantGarde-BookOblique.pfa) ; +/AvantGarde-Demi (AvantGarde-Demi.pfa) ; +/AvantGarde-DemiOblique (AvantGarde-DemiOblique.pfa) ; +/Bookman-Demi (pbkd.gsf) ; +/Bookman-DemiItalic (pbkdi.gsf) ; +/Bookman-Light (pbkl.gsf) ; +/Bookman-LightItalic (pbkli.gsf) ; +/Calligraphic-Hiragana (fhirw.gsf) ; +/Calligraphic-Katakana (fkarw.gsf) ; +/CharterBT-Bold (bchb.gsf) ; +/CharterBT-BoldItalic (bchbi.gsf) ; +/CharterBT-Italic (bchri.gsf) ; +/CharterBT-Roman (bchr.gsf) ; +/Courier (Courier.pfa) ; +/Courier-Bold (Courier-Bold.pfa) ; +/Courier-BoldOblique (Courier-BoldOblique.pfa) ; +/Courier-Oblique (Courier-Oblique.pfa) ; +/Helvetica (Helvetica.pfa) ; +/Helvetica-Bold (Helvetica-Bold.pfa) ; +/Helvetica-BoldOblique (Helvetica-BoldOblique.pfa) ; +/Helvetica-Oblique (Helvetica-Oblique.pfa) ; +/Hershey-Gothic-English (hrger.gsf) ; +/Hershey-Gothic-German (hrgrr.gsf) ; +/Hershey-Gothic-Italian (hritr.gsf) ; +/Hershey-Plain-Duplex (hrpld.gsf) ; +/Hershey-Plain-Duplex-Italic (hrpldi.gsf) ; +/Hershey-Plain-Triplex (hrplt.gsf) ; +/Hershey-Plain-Triplex-Italic (hrplti.gsf) ; +/Hershey-Script-Complex (hrscc.gsf) ; +/Hershey-Script-Simplex (hrscs.gsf) ; +/Hershey-Gothic-English-Bold (hrgerb.gsf) ; +/Hershey-Gothic-English-Oblique (hrgero.gsf) ; +/Hershey-Gothic-English-Semibold (hrgerd.gsf) ; +/Hershey-Gothic-German-Bold (hrgrrb.gsf) ; +/Hershey-Gothic-German-Oblique (hrgrro.gsf) ; +/Hershey-Gothic-Italian-Bold (hritrb.gsf) ; +/Hershey-Gothic-Italian-Oblique (hritro.gsf) ; +/Hershey-Plain-Duplex-Bold (hrpldb.gsf) ; +/Hershey-Plain-Duplex-Bold-Italic (hrpldbi.gsf) ; +/Hershey-Plain-Triplex-Bold (hrpltb.gsf) ; +/Hershey-Plain-Triplex-Bold-Italic (hrpltbi.gsf) ; +/Hershey-Script-Complex-Bold (hrsccb.gsf) ; +/Hershey-Script-Complex-Oblique (hrscco.gsf) ; +/Hershey-Script-Simplex-Bold (hrscsb.gsf) ; +/Hershey-Script-Simplex-Oblique (hrscso.gsf) ; +/Hershey-Greek-Complex (hrgkc.gsf) ; +/Hershey-Greek-Simplex (hrgks.gsf) ; +/Hershey-Plain (hrplr.gsf) ; +/Hershey-Plain-Simplex (hrpls.gsf) ; +/Hershey-Plain-Bold (hrplrb.gsf) ; +/Hershey-Plain-Bold-Oblique (hrplrbo.gsf) ; +/Hershey-Plain-Oblique (hrplro.gsf) ; +/Hershey-Plain-Simplex-Bold (hrplsb.gsf) ; +/Hershey-Plain-Simplex-Bold-Oblique (hrplsbo.gsf) ; +/Hershey-Plain-Simplex-Oblique (hrplso.gsf) ; +/Hershey-Symbol (hrsy_r.gsf) ; +/LubalinGraph-Book (LubalinGraph-Book.pfa) ; +/LubalinGraph-BookOblique (LubalinGraph-BookOblique.pfa) ; +/LubalinGraph-Demi (LubalinGraph-Demi.pfa) ; +/LubalinGraph-DemiOblique (LubalinGraph-DemiOblique.pfa) ; +/NewCenturySchlbk-Bold (NewCenturySchlbk-Bold.pfa) ; +/NewCenturySchlbk-BoldItalic (NewCenturySchlbk-BoldItalic.pfa) ; +/NewCenturySchlbk-Italic (NewCenturySchlbk-Italic.pfa) ; +/NewCenturySchlbk-Roman (NewCenturySchlbk-Roman.pfa) ; +/NimbusRomanNo9L-Regular (n021003l.gsf) ; +/NimbusSansL-Regular (n019003l.gsf) ; +/Palatino-Bold (pplb.gsf) ; +/Palatino-BoldItalic (pplbi.gsf) ; +/Palatino-Italic (pplri.gsf) ; +/Palatino-Roman (pplr.gsf) ; +/Shareware-Cyrillic-Regular (fcyr.gsf) ; +/Shareware-Cyrillic-Italic (fcyri.gsf) ; +/Souvenir-Demi (Souvenir-Demi.pfa) ; +/Souvenir-DemiItalic (Souvenir-DemiItalic.pfa) ; +/Souvenir-Light (Souvenir-Light.pfa) ; +/Souvenir-LightItalic (Souvenir-LightItalic.pfa) ; +/Symbol (Symbol.pfa) ; +/Times-Bold (Times-Bold.pfa) ; +/Times-BoldItalic (Times-BoldItalic.pfa) ; +/Times-Italic (Times-Italic.pfa) ; +/Times-Roman (Times-Roman.pfa) ; +/URWAntiquaT-RegularCondensed (u003043t.gsf) ; +/URWGroteskT-Bold (u004006t.gsf) ; +/Utopia-Bold (putb.gsf) ; +/Utopia-BoldItalic (putbi.gsf) ; +/Utopia-Italic (putri.gsf) ; +/Utopia-Regular (putr.gsf) ; +/ZapfChancery (zcr.gsf) ; +/ZapfChancery-Bold (zcb.gsf) ; +/ZapfChancery-Oblique (zcro.gsf) ; +/ZapfDingbats (ZapfDingbats.pfa) ; +/Cyrillic /Cyrillic-Regular ; +/Cyrillic-Regular /Shareware-Cyrillic-Regular ; +/Cyrillic-Italic /Shareware-Cyrillic-Italic ; + +% BSN additions from original Fontmap file and some more aliases + +/Helvetica-Narrow-Bold /Helvetica-Narrow ; +/ZapfChancery-MediumItalic /ZapfChancery-Oblique ; +/Charter-Roman /CharterBT-Roman ; +/Charter-Italic /CharterBT-Italic ; +/Charter-Bold /CharterBT-Bold ; +/Charter-BoldItalic /CharterBT-BoldItalic ; +/Courier-Italic /Courier-Oblique ; +/Courier-BoldItalic /Courier-BoldOblique ; diff --git a/gs/lib/Fontmap.Sol b/gs/lib/Fontmap.Sol new file mode 100644 index 000000000..9f34460a0 --- /dev/null +++ b/gs/lib/Fontmap.Sol @@ -0,0 +1,482 @@ +% Copyright (C) 1996 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% Fontmap.Solaris - Ghostscript Fontmap for Solaris 2.3 and above +% =============================================================== +% +% The Solaris 2.3 (and above) operating system from Sun Microsystems comes with +% Display Postscript (DPS), including certain Type1 and Type3 PostScript fonts. +% Using these fonts instead of the default Ghostscript fonts greatly improves +% the visual quality of Ghostscript rendered documents, especially at larger +% font sizes. You should definately use these fonts if you have Solaris 2.3 or +% above. +% +% To use the Solaris 2 DPS fonts, simply copy this file (Fontmap.Solaris) to +% +% /usr/local/lib/Ghostscript/VERSION/Fontmap +% (where VERSION is the version number of Ghostscript, eg: 3.33) +% +% and set the environment variable GS_LIB as follows: +% +% GS_LIB=/usr/openwin/lib/X11/fonts/Type1:/usr/openwin/lib/X11/fonts/Type3 +% export GS_LIB +% +% You can use /usr/openwin/lib/fonts/Type1/outline instead if you like, it +% makes no difference (the files in /usr/openwin/lib/fonts/Type1 are symlinks +% into /usr/openwin/lib/fonts/Type1/outline). +% +% Instead of setting GS_LIB, you could add the above directories to +% GS_LIB_DEFAULT in your makefile before building Ghostscript. +% +% +% IMPORTANT NOTE +% ============== +% +% Note that simply setting GS_FONTPATH may not work, because for some reason +% some versions of gs can't seem to find any fonts in +% /usr/openwin/lib/X11/fonts/Type1/outline. +% It says: "15 files, 15 scanned, 0 new fonts". +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% ---------------------------------------------------------------- + +% This file is a catalog of fonts known to Ghostscript. Any font +% that is to be loaded automatically when named must be in this catalog, +% except for fonts that Ghostscript finds automatically in directories +% named in the GS_FONTPATH environment variable. + +% Each font has an entry consisting of three items: +% +% - The name by which the font is known inside Ghostscript +% (a Ghostscript name preceded by a `/', or a string enclosed +% in parentheses). This is used to find the file from which +% a font of a given name should be loaded. +% +% - Information depending on whether this is a real font or a +% font alias: +% +% - For real fonts, the name of the Ghostscript font +% file (a Ghostscript string, enclosed in parentheses). +% The filename should include the extension, which (by +% convention) is `.gsf'. `.pfa' and `.pfb' files are +% also usable as fonts for Ghostscript. +% +% - For font aliases, the name of the font which should +% be used when this one is requested, preceded by a +% `/'. See the entry for Charter below for an example. +% Note that an alias name cannot be enclosed in parentheses. +% +% - At least one space or tab, and a terminating semicolon. + +% Because of limitations in the MS-DOS environment, Ghostscript font +% file names must be no more than 8 characters long, must consist only +% of LOWER CASE letters, digits, and underscores, and must start with a +% letter. Font names, on the other hand, need only obey the syntax of +% names in the Ghostscript language, which is much more liberal. + +% The following table is actually a Ghostscript data structure. +% If you add new entries, be sure to copy the punctuation accurately; +% in particular, you must leave at least one space or tab between each +% field in the entry. Also, please read fonts.doc for important information +% about font names. + +% Note that .pfa and .pfb fonts are compatible with Adobe Type Manager +% and other programs that don't include full PostScript interpreters, +% as well as with PostScript interpreters; .gsf fonts are compatible with +% PostScript interpreters, but not with ATM or similar programs. + +% +% +% Fonts contributed by: +% URW++ Design and Development Incorporated +% Poppenbuetteler Bogen 29A +% D-22399 Hamburg +% Germany +% tel. +49 (40) 60 60 50 +% fax +49 (40) 60 60 51 11 +% http://www.urwpp.de +% for distribution under the GNU License and Aladdin Free Public License. +% See the notice at the head of this Fontmap file for licensing terms. +% Each of these fonts is individually covered by the license: +% for licensing purposes, they are not "part of" any larger entity. +% The following notice applies to these fonts: +% +% Copyright URW Software, Copyright 1994 by URW. +% + +% Actual fonts + +/URWBookmanL-DemiBold (b018015l.pfb) ; +/URWBookmanL-DemiBoldItal (b018035l.pfb) ; +/URWBookmanL-Ligh (b018012l.pfb) ; +/URWBookmanL-LighItal (b018032l.pfb) ; + +/NimbusMonL-Regu (n022003l.pfb) ; +/NimbusMonL-ReguObli (n022023l.pfb) ; +/NimbusMonL-Bold (n022004l.pfb) ; +/NimbusMonL-BoldObli (n022024l.pfb) ; + +/URWGothicL-Book (a010013l.pfb) ; +/URWGothicL-BookObli (a010033l.pfb) ; +/URWGothicL-Demi (a010015l.pfb) ; +/URWGothicL-DemiObli (a010035l.pfb) ; + +/NimbusSanL-Regu (n019003l.pfb) ; +/NimbusSanL-ReguItal (n019023l.pfb) ; +/NimbusSanL-Bold (n019004l.pfb) ; +/NimbusSanL-BoldItal (n019024l.pfb) ; + +/NimbusSanL-ReguCond (n019043l.pfb) ; +/NimbusSanL-ReguCondItal (n019063l.pfb) ; +/NimbusSanL-BoldCond (n019044l.pfb) ; +/NimbusSanL-BoldCondItal (n019064l.pfb) ; + +/URWPalladioL-Roma (p052003l.pfb) ; +/URWPalladioL-Ital (p052023l.pfb) ; +/URWPalladioL-Bold (p052004l.pfb) ; +/URWPalladioL-BoldItal (p052024l.pfb) ; + +/CenturySchL-Roma (c059013l.pfb) ; +/CenturySchL-Ital (c059033l.pfb) ; +/CenturySchL-Bold (c059016l.pfb) ; +/CenturySchL-BoldItal (c059036l.pfb) ; + +/NimbusRomNo9L-Regu (n021003l.pfb) ; +/NimbusRomNo9L-ReguItal (n021023l.pfb) ; +/NimbusRomNo9L-Medi (n021004l.pfb) ; +/NimbusRomNo9L-MediItal (n021024l.pfb) ; + +/StandardSymL (s050000l.pfb) ; + +/URWChanceryL-MediItal (z003034l.pfb) ; + +/Dingbats (d050000l.pfb) ; + +% Aliases + +/Bookman-Demi /URWBookmanL-DemiBold ; +/Bookman-DemiItalic /URWBookmanL-DemiBoldItal ; +/Bookman-Light /URWBookmanL-Ligh ; +/Bookman-LightItalic /URWBookmanL-LighItal ; + +/Courier /NimbusMonL-Regu ; +/Courier-Oblique /NimbusMonL-ReguObli ; +/Courier-Bold /NimbusMonL-Bold ; +/Courier-BoldOblique /NimbusMonL-BoldObli ; + +/AvantGarde-Book /URWGothicL-Book ; +/AvantGarde-BookOblique /URWGothicL-BookObli ; +/AvantGarde-Demi /URWGothicL-Demi ; +/AvantGarde-DemiOblique /URWGothicL-DemiObli ; + +% Solaris 2 DPS has Helvetica as a Type1 font. +%/Helvetica /NimbusSanL-Regu ; +%/Helvetica-Oblique /NimbusSanL-ReguItal ; +%/Helvetica-Bold /NimbusSanL-Bold ; +%/Helvetica-BoldOblique /NimbusSanL-BoldItal ; + +/Helvetica-Narrow /NimbusSanL-ReguCond ; +/Helvetica-Narrow-Oblique /NimbusSanL-ReguCondItal ; +/Helvetica-Narrow-Bold /NimbusSanL-BoldCond ; +/Helvetica-Narrow-BoldOblique /NimbusSanL-BoldCondItal ; + +/Palatino-Roman /URWPalladioL-Roma ; +/Palatino-Italic /URWPalladioL-Ital ; +/Palatino-Bold /URWPalladioL-Bold ; +/Palatino-BoldItalic /URWPalladioL-BoldItal ; + +/NewCenturySchlbk-Roman /CenturySchL-Roma ; +/NewCenturySchlbk-Italic /CenturySchL-Ital ; +/NewCenturySchlbk-Bold /CenturySchL-Bold ; +/NewCenturySchlbk-BoldItalic /CenturySchL-BoldItal ; + +% Solaris 2 DPS has Times as a Type1 font. +%/Times-Roman /NimbusRomNo9L-Regu ; +%/Times-Italic /NimbusRomNo9L-ReguItal ; +%/Times-Bold /NimbusRomNo9L-Medi ; +%/Times-BoldItalic /NimbusRomNo9L-MediItal ; + +% Solaris 2 DPS has Symbol as a Type1 font. +%/Symbol /StandardSymL ; + +/ZapfChancery-MediumItalic /URWChanceryL-MediItal ; + +/ZapfDingbats /Dingbats ; + +% +% +% Type 1 fonts contributed to the X11R5 distribution. +% + +% The following notice accompanied the Charter fonts. +% +% (c) Copyright 1989-1992, Bitstream Inc., Cambridge, MA. +% +% You are hereby granted permission under all Bitstream propriety rights +% to use, copy, modify, sublicense, sell, and redistribute the 4 Bitstream +% Charter (r) Type 1 outline fonts and the 4 Courier Type 1 outline fonts +% for any purpose and without restriction; provided, that this notice is +% left intact on all copies of such fonts and that Bitstream's trademark +% is acknowledged as shown below on all unmodified copies of the 4 Charter +% Type 1 fonts. +% +% BITSTREAM CHARTER is a registered trademark of Bitstream Inc. + +% The Bitstream Charter fonts have different names (CharterBT- +% instead of Charter-), but Ghostscript doesn't care. +/Charter-Roman (bchr.pfa) ; +/Charter-Italic (bchri.pfa) ; +/Charter-Bold (bchb.pfa) ; +/Charter-BoldItalic (bchbi.pfa) ; + +% The following notice accompanied the Utopia font: +% +% Permission to use, reproduce, display and distribute the listed +% typefaces is hereby granted, provided that the Adobe Copyright notice +% appears in all whole and partial copies of the software and that the +% following trademark symbol and attribution appear in all unmodified +% copies of the software: +% +% Copyright (c) 1989 Adobe Systems Incorporated +% Utopia (R) +% Utopia is a registered trademark of Adobe Systems Incorporated +% +% The Adobe typefaces (Type 1 font program, bitmaps and Adobe Font +% Metric files) donated are: +% +% Utopia Regular +% Utopia Italic +% Utopia Bold +% Utopia Bold Italic + +/Utopia-Regular (putr.pfa) ; +/Utopia-Italic (putri.pfa) ; +/Utopia-Bold (putb.pfa) ; +/Utopia-BoldItalic (putbi.pfa) ; + +% +% +% Fonts contributed by URW GmbH for distribution under the GNU License. +% The following notice accompanied these fonts: +% +% U004006T URW Grotesk 2031 Bold PostScript Type 1 Font Program +% U003043T URW Antiqua 2051 Regular Condensed PostScript Type 1 Font Program +% +% Copyright (c) 1992 URW GmbH, Hamburg, Germany +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; wihtout even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +% See the GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +% +% Address: +% URW GmbH +% PC Support +% Harksheider Strasse 102 +% 2000 Hamburg 65 +% Germany +% Phone: +49 40 60 60 50 (Reception) +% Phone: +49 40 60 60 52 30 (PC Support) +% Fax : +49 40 60 60 52 52 +% + +/URWAntiquaT-RegularCondensed (u003043t.gsf) ; +/URWGroteskT-Bold (u004006t.gsf) ; + +% +% +% Shareware Kana fonts. These are subject to the following notice: +% +% These copyrighted fonts were developed by Kevin Hartig. Permission is +% granted to freely distribute them in entirety along with this statement. +% This is shareware. If you decide to use these fonts please contribute +% $10 US to help support further freeware and shareware software development. +% Questions and comments may be sent to: +% +% hartig@fsl.noaa.gov +% khartig@nyx.cs.du.edu +% +% Kevin Hartig +% 1126 Collyer Street +% Longmont, CO 80501 USA +% +% copyright 1993. + +% Hiragana and Katakana fonts. The character names are inappropriate, +% and the encoding is probably not related to any known standard. + +/Calligraphic-Hiragana (fhirw.gsf) ; +/Calligraphic-Katakana (fkarw.gsf) ; + +% +% +% Public-domain fonts. These have no copyright, and are of unknown quality. + +% Cyrillic fonts. The character names are inappropriate, +% and the encoding is probably not related to any known standard. + +/Shareware-Cyrillic-Regular (fcyr.gsf) ; +/Shareware-Cyrillic-Italic (fcyri.gsf) ; + +% Aliases +/Cyrillic /Cyrillic-Regular ; +/Cyrillic-Regular /Shareware-Cyrillic-Regular ; +/Cyrillic-Italic /Shareware-Cyrillic-Italic ; + +% +% +% Fonts converted from Hershey outlines. These are constructed and +% maintained manually. These are also in the public domain. +% +% The suggested UniqueID's and filenames are constructed differently for +% these than for the ones above, because of the strange way that the Hershey +% fonts were constructed. The scheme for these looks like: +% +% 42TTXY0 +% +% TT = typeface, X = ``class'', Y = variation +% +% The typeface names and numbers are listed in fonts.mak. +% +% class: +% 0 = normal = r +% 1 = simplex = s +% 2 = complex = c +% 3 = triplex = t +% 4 = duplex = d +% +% variation: +% 0 = normal (omitted) +% 1 = oblique = o +% 2 = italic = i +% 3 = bold = b +% 4 = bold oblique = bo +% 5 = bold italic = bi +% + +% Fonts created by Thomas Wolff , by adding +% accents, accented characters, and various other non-alphabetics +% to the original Hershey fonts. These are "freeware", not to be sold. + +/Hershey-Gothic-English (hrger.pfa) ; % 5066533 +/Hershey-Gothic-German (hrgrr.pfa) ; +/Hershey-Gothic-Italian (hritr.pfa) ; + +/Hershey-Plain-Duplex (hrpld.pfa) ; +/Hershey-Plain-Duplex-Italic (hrpldi.pfa) ; +/Hershey-Plain-Triplex (hrplt.pfa) ; +/Hershey-Plain-Triplex-Italic (hrplti.pfa) ; + +/Hershey-Script-Complex (hrscc.pfa) ; +/Hershey-Script-Simplex (hrscs.pfa) ; % 5066541 + +% Fonts created algorithmically from the above. + +/Hershey-Gothic-English-Bold (hrgerb.gsf) ; % 5066542 +/Hershey-Gothic-English-Oblique (hrgero.gsf) ; +/Hershey-Gothic-English-SemiBold (hrgerd.gsf) ; +/Hershey-Gothic-German-Bold (hrgrrb.gsf) ; +/Hershey-Gothic-German-Oblique (hrgrro.gsf) ; +/Hershey-Gothic-Italian-Bold (hritrb.gsf) ; +/Hershey-Gothic-Italian-Oblique (hritro.gsf) ; + +/Hershey-Plain-Duplex-Bold (hrpldb.gsf) ; +/Hershey-Plain-Duplex-Bold-Italic (hrpldbi.gsf) ; +/Hershey-Plain-Triplex-Bold (hrpltb.gsf) ; +/Hershey-Plain-Triplex-Bold-Italic (hrpltbi.gsf) ; + +/Hershey-Script-Complex-Bold (hrsccb.gsf) ; +/Hershey-Script-Complex-Oblique (hrscco.gsf) ; +/Hershey-Script-Simplex-Bold (hrscsb.gsf) ; +/Hershey-Script-Simplex-Oblique (hrscso.gsf) ; % 5066556 + +% Fonts consisting only of characters from the original Hershey +% distribution. These are Type 3 fonts. + +/Hershey-Greek-Complex (hrgkc.gsf) ; % 5066557 +/Hershey-Greek-Simplex (hrgks.gsf) ; + +/Hershey-Plain (hrplr.gsf) ; +/Hershey-Plain-Simplex (hrpls.gsf) ; % 5066560 + +% Fonts created algorithmically from the above. + +/Hershey-Plain-Bold (hrplrb.gsf) ; % 5066561 +/Hershey-Plain-Bold-Oblique (hrplrbo.gsf) ; +/Hershey-Plain-Oblique (hrplro.gsf) ; +/Hershey-Plain-Simplex-Bold (hrplsb.gsf) ; +/Hershey-Plain-Simplex-Bold-Oblique (hrplsbo.gsf) ; +/Hershey-Plain-Simplex-Oblique (hrplso.gsf) ; % 5066566 + +% This font, and only this font among the Hershey fonts, uses +% the SymbolEncoding. + +/Hershey-Symbol (hrsyr.gsf) ; % 5066567 +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Solaris 2 Display PostScript Type1 and Type3 fonts... +% + +/Helvetica (Helvetica.pfa) ; +/Helvetica-Bold (Helvetica-Bold.pfa) ; +/Helvetica-BoldOblique (Helvetica-BoldOblique.pfa) ; +/Helvetica-Oblique (Helvetica-Oblique.pfa) ; + +/Symbol (Symbol.pfa) ; +/SymbolSet /Symbol ; + +/Times-Bold (Times-Bold.pfa) ; +/Times-BoldItalic (Times-BoldItalic.pfa) ; +/Times-Italic (Times-Italic.pfa) ; +/Times-Roman (Times-Roman.pfa) ; +/TimesNewRoman /Times-Roman ; +/TimesNewRoman-Bold /Times-Bold ; +/TimesNewRoman-BoldItalic /Times-BoldItalic ; +/TimesNewRoman-Italic /Times-Italic ; + +/Dijkstra (Dijkstra.ps) ; + +/Hershey-Cyrillic (HrshCyr.ps) ; + +/Hershey-Gothic (HrshGoth.ps) ; + +/Hershey-Greek (HrshGrk.ps) ; +/Hershey-Greek-Narrow (HrshGrkN.ps) ; +/Hershey-Greekp (HrshGrkp.ps) ; + +/Hershey-Italic (HrshI.ps) ; +/Hershey-Italic-Narrow (HrshIN.ps) ; +/Hershey-Italic-Wide (HrshIW.ps) ; +/Hershey-Roman (HrshRom.ps) ; +/Hershey-Roman-Narrow (HrshRomN.ps) ; +/Hershey-Roman-Wide (HrshRomW.ps) ; +/Hershey-Romand (HrshRomd.ps) ; +/Hershey-Romanp (HrshRomp.ps) ; + +/Hershey-Script (HrshScr.ps) ; +/Hershey-Script-Narrow (HrshScrN.ps) ; diff --git a/gs/lib/Fontmap.Ult b/gs/lib/Fontmap.Ult new file mode 100644 index 000000000..00aa778e9 --- /dev/null +++ b/gs/lib/Fontmap.Ult @@ -0,0 +1,143 @@ +% Copyright (C) 1990, 1995 Aladdin Enterprises. All rights reserved. +% +% Fontmap.Ult +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. +% +% Fontmap.Ult is derived from the standard Fontmap file distributed with +% ghostscript; for credits and sources see that file. The modifications here +% are valid for ULTRIX 4.3, and consist of defining some fonts and font +% aliases as the licensed fontfiles included in ULTRIX for use on ULTRIX +% workstations, which give better quality than the free fontfiles available +% for ghostscript. Under ULTRIX 4.3 the licensed fontfiles are found in +% +% /usr/lib/DPS/outline/decwin +% +% so that directory must either be built into ghostscript by redefining +% GS_LIB_DEFAULT when ghostscript is compiled, or else by defining an +% environmental variable GS_LIB_DEFAULT, which contains it as an element of +% the path, when running ghostscript. For instance, under the KornShell +% +% GS_LIB_DEFAULT=/usr/gs:/usr/lib/DPS/outline/decwin:/usr/gs/fonts +% export GS_LIB_DEFAULT +% +% Peter Kaiser (kaiser@acm.org) 27 January 1995 + +/AvantGarde-Book (AvantGarde-Book) ; +/AvantGarde-BookOblique (AvantGarde-BookOblique) ; +/AvantGarde-Demi (AvantGarde-Demi) ; +/AvantGarde-DemiOblique (AvantGarde-DemiOblique) ; +/Courier (Courier) ; +/Courier-Bold (Courier-Bold) ; +/Courier-BoldOblique (Courier-BoldOblique) ; +/Courier-Oblique (Courier-Oblique) ; +/Helvetica (Helvetica) ; +/Helvetica-Bold (Helvetica-Bold) ; +/Helvetica-BoldOblique (Helvetica-BoldOblique) ; +/Helvetica-Oblique (Helvetica-Oblique) ; +/LubalinGraph-Book (LubalinGraph-Book) ; +/LubalinGraph-BookOblique (LubalinGraph-BookOblique) ; +/LubalinGraph-Demi (LubalinGraph-Demi) ; +/LubalinGraph-DemiOblique (LubalinGraph-DemiOblique) ; +/NewCenturySchlbk-Bold (NewCenturySchlbk-Bold) ; +/NewCenturySchlbk-BoldItalic (NewCenturySchlbk-BoldItalic) ; +/NewCenturySchlbk-Italic (NewCenturySchlbk-Italic) ; +/NewCenturySchlbk-Roman (NewCenturySchlbk-Roman) ; +/Souvenir-Demi (Souvenir-Demi) ; +/Souvenir-DemiItalic (Souvenir-DemiItalic) ; +/Souvenir-Light (Souvenir-Light) ; +/Souvenir-LightItalic (Souvenir-LightItalic) ; +/Symbol (Symbol) ; +/Times-Bold (Times-Bold) ; +/Times-BoldItalic (Times-BoldItalic) ; +/Times-Italic (Times-Italic) ; +/Times-Roman (Times-Roman) ; + +% Fonts distributed as part of ghostscript + +/Bookman-Demi (pbkd.gsf) ; +/Bookman-DemiItalic (pbkdi.gsf) ; +/Bookman-Light (pbkl.gsf) ; +/Bookman-LightItalic (pbkli.gsf) ; +/Calligraphic-Hiragana (fhirw.gsf) ; +/Calligraphic-Katakana (fkarw.gsf) ; +/Charter-Bold (bchb.pfa) ; +/Charter-BoldItalic (bchbi.pfa) ; +/Charter-Italic (bchri.pfa) ; +/Charter-Roman (bchr.pfa) ; +/Hershey-Gothic-English (hrger.pfa) ; +/Hershey-Gothic-English-Bold (hrgerb.gsf) ; +/Hershey-Gothic-English-Oblique (hrgero.gsf) ; +/Hershey-Gothic-English-SemiBold (hrgerd.gsf) ; +/Hershey-Gothic-German (hrgrr.pfa) ; +/Hershey-Gothic-German-Bold (hrgrrb.gsf) ; +/Hershey-Gothic-German-Oblique (hrgrro.gsf) ; +/Hershey-Gothic-Italian (hritr.pfa) ; +/Hershey-Gothic-Italian-Bold (hritrb.gsf) ; +/Hershey-Gothic-Italian-Oblique (hritro.gsf) ; +/Hershey-Greek-Complex (hrgkc.gsf) ; +/Hershey-Greek-Simplex (hrgks.gsf) ; +/Hershey-Plain (hrplr.gsf) ; +/Hershey-Plain-Bold (hrplrb.gsf) ; +/Hershey-Plain-Bold-Oblique (hrplrbo.gsf) ; +/Hershey-Plain-Duplex (hrpld.pfa) ; +/Hershey-Plain-Duplex-Bold (hrpldb.gsf) ; +/Hershey-Plain-Duplex-Bold-Italic (hrpldbi.gsf) ; +/Hershey-Plain-Duplex-Italic (hrpldi.pfa) ; +/Hershey-Plain-Oblique (hrplro.gsf) ; +/Hershey-Plain-Simplex (hrpls.gsf) ; +/Hershey-Plain-Simplex-Bold (hrplsb.gsf) ; +/Hershey-Plain-Simplex-Bold-Oblique (hrplsbo.gsf) ; +/Hershey-Plain-Simplex-Oblique (hrplso.gsf) ; +/Hershey-Plain-Triplex (hrplt.pfa) ; +/Hershey-Plain-Triplex-Bold (hrpltb.gsf) ; +/Hershey-Plain-Triplex-Bold-Italic (hrpltbi.gsf) ; +/Hershey-Plain-Triplex-Italic (hrplti.pfa) ; +/Hershey-Script-Complex (hrscc.pfa) ; +/Hershey-Script-Complex-Bold (hrsccb.gsf) ; +/Hershey-Script-Complex-Oblique (hrscco.gsf) ; +/Hershey-Script-Simplex (hrscs.pfa) ; +/Hershey-Script-Simplex-Bold (hrscsb.gsf) ; +/Hershey-Script-Simplex-Oblique (hrscso.gsf) ; +/Hershey-Symbol (hrsyr.gsf) ; +/NimbusRomanNo9L-Regular (n021003l.gsf) ; +/NimbusSansL-Regular (n019003l.gsf) ; +/Palatino-Bold (pplb.gsf) ; +/Palatino-BoldItalic (pplbi.gsf) ; +/Palatino-Italic (pplri.gsf) ; +/Palatino-Roman (pplr.gsf) ; +/Shareware-Cyrillic-Italic (fcyri.gsf) ; +/Shareware-Cyrillic-Regular (fcyr.gsf) ; +/URWAntiquaT-RegularCondensed (u003043t.gsf) ; +/URWGroteskT-Bold (u004006t.gsf) ; +/Utopia-Bold (putb.pfa) ; +/Utopia-BoldItalic (putbi.pfa) ; +/Utopia-Italic (putri.pfa) ; +/Utopia-Regular (putr.pfa) ; +/ZapfChancery (zcr.gsf) ; +/ZapfChancery-Bold (zcb.gsf) ; +/ZapfChancery-Oblique (zcro.gsf) ; +/ZapfDingbats (pzdr.gsf) ; + +% Font aliases + +/Courier-BoldItalic /Courier-BoldOblique ; +/Courier-Italic /Courier-Oblique ; +/Cyrillic /Shareware-Cyrillic-Regular ; +/Cyrillic-Italic /Shareware-Cyrillic-Italic ; +/Cyrillic-Regular /Shareware-Cyrillic-Regular ; +/Helvetica-Narrow-Bold /Helvetica-Narrow ; +/ZapfChancery-MediumItalic /ZapfChancery-Oblique ; diff --git a/gs/lib/Fontmap.VMS b/gs/lib/Fontmap.VMS new file mode 100644 index 000000000..4348b104b --- /dev/null +++ b/gs/lib/Fontmap.VMS @@ -0,0 +1,120 @@ +% fontmap.vms - Ghostscript fontmap for VAX/VMS systems with DECwindows/Motif. +% +%Uses all the XDPS Outline fonts (Type 1 fonts) provided with Motif (with the +%exception of Courier which already comes with GhostScript in Type 1 form). +% +%XDPS on VAX/VMS does not have Bookman, Palatino and ZapfChancery fonts, so +%we still have to use the dreaded bitmaps for those. Helvetica-Narrow is also +%missing. But then you get the LubalinGraph and Souvenir fonts which are just +%beautiful! +% +%Note: this file omits the Hershey fonts (Hershey ?? YOU MUST BE JOKING) +% but retains the Cyrillic and Kana fonts. + +/AvantGarde-Book + (SYS$COMMON:[SYSFONT.XDPS.OUTLINE]AVANTGARDE-BOOK.XDPS$OUTLINE) ; +/AvantGarde-BookOblique + (SYS$COMMON:[SYSFONT.XDPS.OUTLINE]AVANTGARDE-BOOKOBLIQUE.XDPS$OUTLINE) ; +/AvantGarde-Demi + (SYS$COMMON:[SYSFONT.XDPS.OUTLINE]AVANTGARDE-DEMI.XDPS$OUTLINE) ; +/AvantGarde-DemiOblique + (SYS$COMMON:[SYSFONT.XDPS.OUTLINE]AVANTGARDE-DEMIOBLIQUE.XDPS$OUTLINE) ; +/Helvetica-Bold + (SYS$COMMON:[SYSFONT.XDPS.OUTLINE]HELVETICA-BOLD.XDPS$OUTLINE) ; +/Helvetica-BoldOblique + (SYS$COMMON:[SYSFONT.XDPS.OUTLINE]HELVETICA-BOLDOBLIQUE.XDPS$OUTLINE) ; +/Helvetica-Oblique + (SYS$COMMON:[SYSFONT.XDPS.OUTLINE]HELVETICA-OBLIQUE.XDPS$OUTLINE) ; +/Helvetica + (SYS$COMMON:[SYSFONT.XDPS.OUTLINE]HELVETICA.XDPS$OUTLINE) ; +/LubalinGraph-Book + (SYS$COMMON:[SYSFONT.XDPS.OUTLINE]LUBALINGRAPH-BOOK.XDPS$OUTLINE) ; +/LubalinGraph-BookOblique + (SYS$COMMON:[SYSFONT.XDPS.OUTLINE]LUBALINGRAPH-BOOKOBLIQUE.XDPS$OUTLINE) ; +/LubalinGraph-Demi + (SYS$COMMON:[SYSFONT.XDPS.OUTLINE]LUBALINGRAPH-DEMI.XDPS$OUTLINE) ; +/LubalinGraph-DemiOblique + (SYS$COMMON:[SYSFONT.XDPS.OUTLINE]LUBALINGRAPH-DEMIOBLIQUE.XDPS$OUTLINE) ; +/NewCenturySchlbk-Roman + (SYS$COMMON:[SYSFONT.XDPS.OUTLINE]NEWCENTURYSCHLBK-ROMAN.XDPS$OUTLINE) ; +/NewCenturySchlbk-Italic + (SYS$COMMON:[SYSFONT.XDPS.OUTLINE]NEWCENTURYSCHLBK-ITALIC.XDPS$OUTLINE) ; +/NewCenturySchlbk-Bold + (SYS$COMMON:[SYSFONT.XDPS.OUTLINE]NEWCENTURYSCHLBK-BOLD.XDPS$OUTLINE) ; +/NewCenturySchlbk-BoldItalic + (SYS$COMMON:[SYSFONT.XDPS.OUTLINE]NEWCENTURYSCHLBK-BOLDITALIC.XDPS$OUTLINE) ; +/Souvenir-Light + (SYS$COMMON:[SYSFONT.XDPS.OUTLINE]SOUVENIR-LIGHT.XDPS$OUTLINE) ; +/Souvenir-LightItalic + (SYS$COMMON:[SYSFONT.XDPS.OUTLINE]SOUVENIR-LIGHTITALIC.XDPS$OUTLINE) ; +/Souvenir-Demi + (SYS$COMMON:[SYSFONT.XDPS.OUTLINE]SOUVENIR-DEMI.XDPS$OUTLINE) ; +/Souvenir-DemiItalic + (SYS$COMMON:[SYSFONT.XDPS.OUTLINE]SOUVENIR-DEMIITALIC.XDPS$OUTLINE) ; +%If you want the Apple symbol (SIC!) then remove the comment (%) +%in front of character 240 in the following file (he he he) +/Symbol + (SYS$COMMON:[SYSFONT.XDPS.OUTLINE]SYMBOL.XDPS$OUTLINE) ; +/Times-Roman + (SYS$COMMON:[SYSFONT.XDPS.OUTLINE]TIMES-ROMAN.XDPS$OUTLINE) ; +/Times-Italic + (SYS$COMMON:[SYSFONT.XDPS.OUTLINE]TIMES-ITALIC.XDPS$OUTLINE) ; +/Times-Bold + (SYS$COMMON:[SYSFONT.XDPS.OUTLINE]TIMES-BOLD.XDPS$OUTLINE) ; +/Times-BoldItalic + (SYS$COMMON:[SYSFONT.XDPS.OUTLINE]TIMES-BOLDITALIC.XDPS$OUTLINE) ; + +% Fonts converted from bitmaps (Not in the XDPS set) +/Bookman-Light (pbkl.gsf) ; +/Bookman-LightItalic (pbkli.gsf) ; +/Bookman-Demi (pbkd.gsf) ; +/Bookman-DemiItalic (pbkdi.gsf) ; +/Palatino-Roman (pplr.gsf) ; +/Palatino-Italic (pplri.gsf) ; +/Palatino-Bold (pplb.gsf) ; +/Palatino-BoldItalic (pplbi.gsf) ; +/ZapfChancery (zcr.gsf) ; +/ZapfChancery-Oblique (zcro.gsf) ; +/ZapfChancery-Bold (zcb.gsf) ; +%MediumItalic font to Oblique aliasing +/ZapfChancery-MediumItalic /ZapfChancery-Oblique ; +/ZapfDingbats (pzdr.gsf) ; + +% BITSTREAM CHARTER is a registered trademark of Bitstream Inc. +/CharterBT-Roman (bchr.pfa) ; +/CharterBT-Italic (bchri.pfa) ; +/CharterBT-Bold (bchb.pfa) ; +/CharterBT-BoldItalic (bchbi.pfa) ; +%Charter to CharterBT aliasing +/Charter-Roman /CharterBT-Roman ; +/Charter-Italic /CharterBT-Italic ; +/Charter-Bold /CharterBT-Bold ; +/Charter-BoldItalic /CharterBT-BoldItalic ; + +% IBM Courier - Copyright (c) IBM Corporation 1990, 1991 +/Courier (ncrr.pfa) ; +/Courier-Italic (ncrri.pfa) ; +/Courier-Bold (ncrb.pfa) ; +/Courier-BoldItalic (ncrbi.pfa) ; +%Oblique to Italic aliasing +/Courier-Oblique /Courier-Italic ; +/Courier-BoldOblique /Courier-BoldItalic ; + +% Utopia is a registered trademark of Adobe Systems Incorporated +/Utopia-Regular (putr.gsf) ; +/Utopia-Italic (putri.gsf) ; +/Utopia-Bold (putb.gsf) ; +/Utopia-BoldItalic (putbi.gsf) ; + +% Shareware fonts. These have no copyright, and are of unknown quality. +/Shareware-Cyrillic-Regular (fcyr.gsf) ; +/Shareware-Cyrillic-Italic (fcyri.gsf) ; +% Aliases +/Cyrillic /Cyrillic-Regular ; +/Cyrillic-Regular /Shareware-Cyrillic-Regular ; +/Cyrillic-Italic /Shareware-Cyrillic-Italic ; + +% Copyrighted shareware fonts. +% See FONTMAP.GS for the full copyright statement. +/Calligraphic-Hiragana (fhirw.gsf) ; +/Calligraphic-Katakana (fkarw.gsf) ; diff --git a/gs/lib/_vc_make.bat b/gs/lib/_vc_make.bat new file mode 100755 index 000000000..e80bd028f --- /dev/null +++ b/gs/lib/_vc_make.bat @@ -0,0 +1,5 @@ +cd ..\gs +c:\progra~1\devstudio\VC\bin\nmake /F _vc_temp.mak CONFIG=5 gsargs.obj gsnogc.obj echogs.exe +c:\progra~1\devstudio\VC\bin\nmake /F _vc_temp.mak CONFIG=5 ld5.tr gconfig5.obj gscdefs5.obj +..\gs\echogs.exe -w _wm_cdir.bat cd -s -r _vc_dir.bat +_wm_cdir.bat diff --git a/gs/lib/_wm_cdir.bat b/gs/lib/_wm_cdir.bat new file mode 100755 index 000000000..6cc2625dd --- /dev/null +++ b/gs/lib/_wm_cdir.bat @@ -0,0 +1 @@ +cd \ No newline at end of file diff --git a/gs/lib/acctest.ps b/gs/lib/acctest.ps new file mode 100644 index 000000000..b1c5e9dca --- /dev/null +++ b/gs/lib/acctest.ps @@ -0,0 +1,99 @@ +%! +% Check that operators do their access tests correctly. + +% proc dotest => . +/dotest + { + dup + mark + exch + stopped not % False if error, true if no error. + { (Allowed access: ) print cleartomark == } + if + clear + } +def + +0 0 moveto % So the show commands don't bomb because of nocurrentpoint. + +{ [1 2] executeonly aload } dotest +{ (string) executeonly (seek) anchorsearch } dotest +{ (string) (seek) executeonly anchorsearch } dotest +{ 100 101 (string) noaccess ashow} dotest +{ 100 1 array readonly astore } dotest +{ 100 101 102 103 104 (string) noaccess awidthshow } dotest +{ 1 dict noacess begin } dotest +{ 1 array executeonly 1 array copy } dotest +{ 1 array 1 array readonly copy } dotest +{ 1 dict noaccess 1 dict copy } dotest +{ 1 dict 1 dict readonly copy } dotest +{ 1 string executeonly 1 string copy } dotest +{ 1 string 1 string readonly copy } dotest +{ (100) executeonly cvi } dotest +{ (string) executeonly cvn } dotest +{ (100.001) executeonly cvr } dotest +{ 1 10 1 string readonly cvrs } dotest +{ true 5 string readonly cvs } dotest +{ 1 dict readonly begin /foo true def } dotest +{ 10 array readonly dictstack } dotest +{ 1 string executeonly 1 string eq } dotest +{ 1 string 1 string executeonly eq } dotest +{ 10 array readonly execstack } dotest +{ 1 string noaccess executeonly } dotest +{ 1 array noaccess executeonly } dotest +{ 1 array executeonly { pop } forall } dotest +{ 1 dict noaccess { pop pop } forall } dotest +{ 1 string executeonly { pop } forall } dotest +{ (string1) executeonly (string2) ge } dotest +{ (string1) (string2) executeonly ge } dotest +{ 1 array executeonly 0 get } dotest +{ 1 dict noaccess /key get } dotest +{ 1 string executeonly 0 get } dotest +{ 1 array executeonly 0 1 getinterval } dotest +{ 1 string executeonly 0 1 getinterval } dotest +{ (string1) executeonly (string2) gt } dotest +{ (string1) (string2) executeonly gt } dotest +{ 1 dict noaccess /key known } dotest +{ {} (string) executeonly kshow } dotest +{ (string1) executeonly (string2) le } dotest +{ (string1) (string2) executeonly le } dotest +{ 1 array executeonly length } dotest +{ 1 dict noaccess length } dotest +{ 1 string executeonly length } dotest +%%{ /foo 1 dict def foo begin /bar foo def bar noaccess pop /key load } dotest +{ (string1) executeonly (string2) lt } dotest +{ (string1) (string2) executeonly lt } dotest +{ 1 dict noaccess maxlength } dotest +{ 1 string executeonly 1 string ne } dotest +{ 1 string 1 string executeonly ne } dotest +%{ newpath 0 0 moveto (a) false charpath +% {} {} {} {} pathforall closepath } dotest +{ 1 array executeonly 0 put } dotest +{ 1 dict noaccess /key put } dotest +{ 1 string executeonly 0 put } dotest +{ 1 array executeonly 0 1 putinterval } dotest +{ 1 string executeonly 0 1 putinterval } dotest +{ (access.ps) (r) file executeonly read } dotest +{ (access.ps) (r) file executeonly 10 string readhexstring } dotest +{ (access.ps) (r) file 10 string readonly readhexstring } dotest +{ (access.ps) (r) file executeonly 100 string readline } dotest +{ (access.ps) (r) file 100 string readonly readline } dotest +{ (access.ps) (r) file executeonly 10 string readstring } dotest +{ (access.ps) (r) file 10 string readonly readstring } dotest +% run does not check for no read access? +{ (string) executeonly (seek) search } dotest +{ (string) (seek) executeonly search } dotest +{ (string) executeonly show } +%% some test for store. +{ (string) executeonly stringwidth } dotest +{ (access.ps) (r) file executeonly token } dotest +{ (10) executeonly token } dotest +{ /foo 1 dict def foo begin /bar foo def bar noaccess pop /key where } dotest +{ 100 101 102 (string) noaccess widthshow } dotest +{ (/tmp/_.ps) noaccess (w) file closefile } dotest +{ (/tmp/_.ps) (w) noaccess file closefile } dotest +{ (/tmp/_.ps) (w) file executeonly 100 write } dotest +{ (/tmp/_.ps) (w) file executeonly 10 string writehexstring } dotest +{ (/tmp/_.ps) (w) file 10 string executeonly writehexstring } dotest +{ (/tmp/_.ps) (w) file executeonly 10 string writestring } dotest +{ (/tmp/_.ps) (w) file 10 string executeonly writestring } dotest diff --git a/gs/lib/align.ps b/gs/lib/align.ps new file mode 100644 index 000000000..75d2b66c7 --- /dev/null +++ b/gs/lib/align.ps @@ -0,0 +1,71 @@ +% Copyright (C) 1989, 1996 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% Print a page that indicates the proper settings of Margins and HWMargins +% for a given device. Requires a Level 2 system. + +% Reset the offset and margins. + +<< + /PageOffset [0 0] + /Margins [0 0] + /.HWMargins [0 0 0 0] +>> +setpagedevice +<< + /ImagingBBox null +>> +setpagedevice + +% Determine the actual page size. + +clippath pathbbox newpath +/y1 exch def /x1 exch def pop pop + +% Draw lines that should be exactly 1" in from each edge, +% and should extend precisely to the edge of the paper. + +1 setlinewidth +0 setgray +72 0 moveto 0 y1 rlineto stroke +0 72 moveto x1 0 rlineto stroke + +% Print the text in the middle of the page. + +/S 80 string def +108 360 moveto +/Helvetica 12 selectfont + { currentfile S readline pop dup (%END) eq { pop exit } if + gsave show grestore 0 -15 rmoveto + } loop +Let the distance in inches from the left edge of the page to +the vertical line be H, and from the bottom edge to the +horizontal line be V; let the lengths of the gaps at the top +and bottom of the vertical line be T and B respectively, and +the gaps at the left and right of the horizontal line be L +and R. For measurements in inches, the proper page device +parameters for this printer are set by + << /.HWMargins [ml mb mr mt] /Margins [x y] + >> setpagedevice +where + ml = L * 72, mb = B * 72, mr = R * 72, mt = T * 72 +%END +/res currentpagedevice /.MarginsHWResolution get def +( x = (1 - H) * ) show res 0 get =string cvs show +(, y = (V - 1) * ) show res 1 get =string cvs show + +showpage diff --git a/gs/lib/alphabet.ps b/gs/lib/alphabet.ps new file mode 100644 index 000000000..80dc25e8a --- /dev/null +++ b/gs/lib/alphabet.ps @@ -0,0 +1,56 @@ +% Check for command line parameters: +% Name, FirstSize, Ratio, NumSizes, UseOutline. + +/FontName where { pop } { /FontName (Palatino-Italic) def } ifelse +/FirstSize where { pop } { /FirstSize 15 def } ifelse +/Ratio where { pop } { /Ratio 1.6 def } ifelse +/NumSizes where { pop } { /NumSizes 3 def } ifelse +/UseOutline where { pop } { /UseOutline false def } ifelse + +/Strings FirstSize 20 gt + { [ + (ABCDEFGHIJ) (KLMNOPQR) (STUVWXYZ) + (abcdefghijklm) (nopqrstuvwxyz) + (0123456789<=>) (:;?@ !"#$%&') + (\(\)*+,-./[\\]^_) (`{|}~) + ] } + { [ + (ABCDEFGHIJKLMNOPQRSTUVWXYZ) + (abcdefghijklmnopqrstuvwxyz) + (0123456789<=>:;?@ !"#$%&') + (\(\)*+,-./ [\\]^_ `{|}~) + ] } +ifelse def + +/sshow + { gsave UseOutline + { { gsave ( ) dup 0 4 -1 roll put + false charpath pathbbox 0 setlinewidth stroke grestore + pop 8 add currentpoint exch pop moveto pop + } forall + } + { 2 0 3 -1 roll ashow } + ifelse grestore + } def + +FontName findfont FirstSize scalefont setfont + +clippath pathbbox /top exch def pop pop pop newpath +10 10 moveto +NumSizes + { gsave nulldevice (Q) false charpath pathbbox grestore + exch pop exch sub exch pop 1.25 mul /height exch def + Strings + { currentpoint exch pop top height 3 mul sub gt + { showpage 10 10 height sub moveto + } + if + dup sshow + UseOutline not + { 0 height rmoveto gsave 0.01 rotate sshow grestore } + if + 0 height rmoveto + } forall + Ratio dup scale + } repeat +showpage diff --git a/gs/lib/bdftops b/gs/lib/bdftops new file mode 100755 index 000000000..c2d86bd77 --- /dev/null +++ b/gs/lib/bdftops @@ -0,0 +1,2 @@ +#!/bin/sh +exec gs -q -dNODISPLAY -- bdftops.ps "$@" diff --git a/gs/lib/bdftops.bat b/gs/lib/bdftops.bat new file mode 100755 index 000000000..bd3d6fa8d --- /dev/null +++ b/gs/lib/bdftops.bat @@ -0,0 +1 @@ +@gs -q -dNODISPLAY -- bdftops.ps %1 %2 %3 %4 %5 %6 %7 %8 %9 diff --git a/gs/lib/bdftops.ps b/gs/lib/bdftops.ps new file mode 100644 index 000000000..4bfc12aaa --- /dev/null +++ b/gs/lib/bdftops.ps @@ -0,0 +1,793 @@ +% Copyright (C) 1990, 1995, 1996 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% bdftops.ps +% Convert a BDF file (possibly with (an) associated AFM file(s)) +% to a PostScript Type 1 font (without eexec encryption). +% The resulting font will work with any PostScript language interpreter, +% but not with ATM or other font rasterizers lacking a complete interpreter. + +/envBDF 120 dict def +envBDF begin + +% "Import" the image-to-path package. +% This also brings in the Type 1 opcodes (type1ops.ps). + (impath.ps) runlibfile + +% "Import" the font-writing package. + (wrfont.ps) runlibfile + wrfont_dict begin + /binary_CharStrings false def + /binary_tokens false def + /encrypt_CharStrings true def + /standard_only true def + end + /lenIV 0 def + +% Invert the StandardEncoding vector. + 256 dict dup begin + 0 1 255 { dup StandardEncoding exch get exch def } for + end /StandardDecoding exch def + +% Define the properties copied to FontInfo. + mark + (COPYRIGHT) /Notice + (FAMILY_NAME) /FamilyName + (FULL_NAME) /FullName + (WEIGHT_NAME) /Weight + .dicttomark /properties exch def + +% Define the character sequences for synthesizing missing composite +% characters in the standard encoding. + mark + /AE [/A /E] + /OE [/O /E] + /ae [/a /e] + /ellipsis [/period /period /period] + /emdash [/hyphen /hyphen /hyphen] + /endash [/hyphen /hyphen] + /fi [/f /i] + /fl [/f /l] + /germandbls [/s /s] + /guillemotleft [/less /less] + /guillemotright [/greater /greater] + /oe [/o /e] + /quotedblbase [/comma /comma] + .dicttomark /composites exch def + +% Define the procedure for synthesizing composites. +% This must not be bound. + /compose + { exch pop + FontMatrix Private /composematrix get invertmatrix concat + 0 0 moveto + dup gsave false charpath pathbbox currentpoint grestore + 6 2 roll setcachedevice show + } def +% Define the CharString procedure that calls compose, with the string +% on the stack. This too must remain unbound. + /compose_proc + { Private /compose get exec + } def + +% Define aliases for missing characters similarly. + mark + /acute /quoteright + /bullet /asterisk + /cedilla /comma + /circumflex /asciicircum + /dieresis /quotedbl + /dotlessi /i + /exclamdown /exclam + /florin /f + /fraction /slash + /grave /quoteleft + /guilsinglleft /less + /guilsinglright /greater + /hungarumlaut /quotedbl + /periodcentered /asterisk + /questiondown /question + /quotedblleft /quotedbl + /quotedblright /quotedbl + /quotesinglbase /comma + /quotesingle /quoteright + /tilde /asciitilde + .dicttomark /aliases exch def + +% Define overstruck characters that can be synthesized with seac. + mark + [ /Aacute /Acircumflex /Adieresis /Agrave /Aring /Atilde + /Ccedilla + /Eacute /Ecircumflex /Edieresis /Egrave + /Iacute /Icircumflex /Idieresis /Igrave + /Lslash + /Ntilde + /Oacute /Ocircumflex /Odieresis /Ograve /Otilde + /Scaron + /Uacute /Ucircumflex /Udieresis /Ugrave + /Yacute /Ydieresis + /Zcaron + /aacute /acircumflex /adieresis /agrave /aring /atilde + /ccedilla + /eacute /ecircumflex /edieresis /egrave + /iacute /icircumflex /idieresis /igrave + /lslash + /ntilde + /oacute /ocircumflex /odieresis /ograve /otilde + /scaron + /uacute /ucircumflex /udieresis /ugrave + /yacute /ydieresis + /zcaron + ] + { dup =string cvs + [ exch dup 0 1 getinterval cvn + exch dup length 1 sub 1 exch getinterval cvn + ] + } forall + /cent [/c /slash] + /daggerdbl [/bar /equal] + /divide [/colon /hyphen] + /sterling [/L /hyphen] + /yen [/Y /equal] + .dicttomark /accentedchars exch def + +% ------ Output utilities ------ % + + /ws {psfile exch writestring} bind def + /wl {ws (\n) ws} bind def + /wt {=string cvs ws ( ) ws} bind def + +% ------ BDF file parsing utilities ------ % + +% Define a buffer for reading the BDF file. + /buffer 400 string def + +% Read a line from the BDF file into the buffer. +% Ignore empty (zero-length) lines. +% Define /keyword as the first word on the line. +% Define /args as the remainder of the line. +% If the keyword is equal to commentword, skip the line. +% (If commentword is equal to a space, never skip.) + /nextline + { { bdfile buffer readline not + { (Premature EOF\n) print stop } if + dup length 0 ne { exit } if pop + } + loop + ( ) search + { /keyword exch def pop } + { /keyword exch def () } + ifelse + /args exch def + keyword commentword eq { nextline } if + } bind def + +% Get a word argument from args. We do *not* copy the string. + /warg % warg -> string + { args ( ) search + { exch pop exch } + { () } + ifelse /args exch def + } bind def + +% Get an integer argument from args. + /iarg % iarg -> int + { warg cvi + } bind def + +% Get a numeric argument from args. + /narg % narg -> int|real + { warg cvr + dup dup cvi eq { cvi } if + } bind def + +% Convert the remainder of args into a string. + /remarg % remarg -> string + { args copystring + } bind def + +% Get a string argument that occupies the remainder of args. + /sarg % sarg -> string + { args (") anchorsearch + { pop /args exch def } { pop } ifelse + args args length 1 sub get (") 0 get eq + { args 0 args length 1 sub getinterval /args exch def } if + args copystring + } bind def + +% Check that the keyword is the expected one. + /checkline % (EXPECTED-KEYWORD) checkline -> + { dup keyword ne + { (Expected ) print = + (Line=) print keyword print ( ) print args print (\n) print stop + } if + pop + } bind def + +% Read a line and check its keyword. + /getline % (EXPECTED-KEYWORD) getline -> + { nextline checkline + } bind def + +% Find the first/last non-zero bit of a non-zero byte. + /fnzb + { 0 { exch dup 128 ge { pop exit } { dup add exch 1 add } ifelse } + loop + } bind def + /lnzb + { 7 { exch dup 1 and 0 ne { pop exit } { -1 bitshift exch 1 sub } ifelse } + loop + } bind def + +% ------ Type 1 encoding utilities ------ % + +% Parse the side bearing and width information that begins a CharString. +% Arguments: charstring. Result: sbx sby wx wy substring. + /parsesbw + { mark exch lenIV + { % stack: mark ... string dropcount + dup 2 index length exch sub getinterval + dup 0 get dup 32 lt { pop exit } if + dup 246 le + { 139 sub exch 1 } + { dup 250 le + { 247 sub 8 bitshift 108 add 1 index 1 get add exch 2 } + { dup 254 le + { 251 sub 8 bitshift 108 add 1 index 1 get add neg exch 2 } + { pop dup 1 get 128 xor 128 sub + 8 bitshift 1 index 2 get add + 8 bitshift 1 index 3 get add + 8 bitshift 1 index 4 get add exch 5 + } ifelse + } ifelse + } ifelse + } loop + counttomark 3 eq { 0 3 1 roll 0 exch } if + 6 -1 roll pop + } bind def + +% Find the side bearing and width information that begins a CharString. +% Arguments: charstring. Result: charstring sizethroughsbw. + /findsbw + { dup parsesbw 4 { exch pop } repeat skipsbw + } bind def + /skipsbw % charstring sbwprefix -> sizethroughsbw + { length 1 index length exch sub + 2 copy get 12 eq { 2 } { 1 } ifelse add + } bind def + +% Encode a number, and append it to a string. +% Arguments: str num. Result: newstr. + /concatnum + { dup dup -107 ge exch 107 le and + { 139 add 1 string dup 0 3 index put } + { dup dup -1131 ge exch 1131 le and + { dup 0 ge { 16#f694 } { neg 16#fa94 } ifelse add + 2 string dup 0 3 index -8 bitshift put + dup 1 3 index 255 and put + } + { 5 string dup 0 255 put exch + 2 copy 1 exch -24 bitshift 255 and put + 2 copy 2 exch -16 bitshift 255 and put + 2 copy 3 exch -8 bitshift 255 and put + 2 copy 4 exch 255 and put + exch + } + ifelse + } + ifelse exch pop concatstrings + } bind def + +% ------ Point arithmetic utilities ------ % + + /ptadd { exch 4 -1 roll add 3 1 roll add } bind def + /ptexch { 4 2 roll } bind def + /ptneg { neg exch neg exch } bind def + /ptpop { pop pop } bind def + /ptsub { ptneg ptadd } bind def + +% ------ The main program ------ % + + /readBDF % + % readBDF -> + { /xuid exch def % may be null + /uniqueID exch def % may be -1 + /encodingname exch def + /encoding encodingname cvx exec def + /fontname exch def + /psname exch def + /bdfname exch def + gsave % so we can set the CTM to the font matrix + +% Open the input files. We don't open the output file until +% we've done a minimal validity check on the input. + bdfname (r) file /bdfile exch def + /commentword ( ) def + +% Check for the STARTFONT. + (STARTFONT) getline + args (2.1) ne { (Not version 2.1\n) print stop } if + +% Initialize the font. + /Font 20 dict def + Font begin + /FontName fontname def + /PaintType 0 def + /FontType 1 def + uniqueID 0 gt { /UniqueID uniqueID def } if + xuid null ne { /XUID xuid def } if + /Encoding encoding def + /FontInfo 20 dict def + /Private 20 dict def + currentdict end currentdict end + exch begin begin % insert font above environment + +% Initialize the Private dictionary in the font. + Private begin + /-! {string currentfile exch readhexstring pop} readonly def + /-| {string currentfile exch readstring pop} readonly def + /|- {readonly def} readonly def + /| {readonly put} readonly def + /BlueValues [] def + /lenIV lenIV def + /MinFeature {16 16} def + /password 5839 def + /UniqueID uniqueID def + end % Private + +% Invert the Encoding, for synthesizing composite characters. + /decoding encoding length dict def + 0 1 encoding length 1 sub + { dup encoding exch get exch decoding 3 1 roll put } + for + +% Now open the output file. + psname (w) file /psfile exch def + +% Put out a header compatible with the Adobe "standard". + (%!FontType1-1.0: ) ws fontname wt (000.000) wl + (% This is a font description converted from ) ws + bdfname wl + (% by bdftops running on ) ws + statusdict /product get ws ( revision ) ws + revision =string cvs ws (.) wl + +% Copy the initial comments, up to FONT. + true + { nextline + keyword (COMMENT) ne {exit} if + { (% Here are the initial comments from the BDF file:\n%) wl + } if false + (%) ws remarg wl + } loop pop + () wl + /commentword (COMMENT) def % do skip comments from now on + +% Read and process the FONT, SIZE, and FONTBOUNDINGBOX. + % If we cared about FONT, we'd use it here. If the BDF files + % from MIT had PostScript names rather than X names, we would + % care; but what's there is unusable, so we discard FONT. + % The FONTBOUNDINGBOX may not be reliable, so we discard it too. + (FONT) checkline + (SIZE) getline + /pointsize iarg def /xres iarg def /yres iarg def + (FONTBOUNDINGBOX) getline + nextline + +% Initialize the font bounding box bookeeping. + /fbbxo 1000 def + /fbbyo 1000 def + /fbbxe -1000 def + /fbbye -1000 def + +% Read and process the properties. We only care about a few of them. + keyword (STARTPROPERTIES) eq + { iarg + { nextline + properties keyword known + { FontInfo properties keyword get sarg readonly put + } if + } repeat + (ENDPROPERTIES) getline + nextline + } if + +% Compute and set the FontMatrix. + Font /FontMatrix + [ 0.001 0 0 0.001 xres mul yres div 0 0 ] readonly + dup setmatrix put + +% Read and process the header for the bitmaps. + (CHARS) checkline + /ccount iarg def + +% Initialize the CharStrings dictionary. + /charstrings ccount + composites length add + aliases length add + accentedchars length add + 1 add dict def % 1 add for .notdef + /isfixedwidth true def + /fixedwidth null def + /subrcount 0 def + /subrs [] def + +% Read the bitmap data. This reads the remainder of the file. +% We do this before processing the bitmaps so that we can compute +% the correct FontBBox first. + /chardata ccount dict def + ccount -1 1 + { (STARTCHAR) getline + /charname remarg def + (ENCODING) getline + /eindex iarg def + eindex 0 ge + { charname /charname StandardEncoding eindex get def + charname /.notdef eq eindex 0 gt and + { /charname (A) eindex =string cvs concatstrings cvn def + } + if + (/) print charname =string cvs print (,) print print + } + { (/) print charname print + } + ifelse + 10 mod 1 eq { (\n) print flush } if + (SWIDTH) getline + /swx iarg pointsize mul 1000 div xres mul 72 div def + /swy iarg pointsize mul 1000 div xres mul 72 div def + (DWIDTH) getline % Ignore, use SWIDTH instead + (BBX) getline + /bbw iarg def /bbh iarg def /bbox iarg def /bboy iarg def + nextline + keyword (ATTRIBUTES) eq + { nextline + } if + (BITMAP) checkline + +% Update the font bounding box. + /fbbxo fbbxo bbox min def + /fbbyo fbbyo bboy min def + /fbbxe fbbxe bbox bbw add max def + /fbbye fbbye bboy bbh add max def + +% Read the bits for this character. + /raster bbw 7 add 8 idiv def + /cbits raster bbh mul string def + 0 raster cbits length raster sub + { cbits exch raster getinterval + bdfile buffer readline not + { (EOF in bitmap\n) print stop } if + % stack has + 0 () /SubFileDecode filter + exch 2 copy readhexstring pop pop pop closefile + } for + (ENDCHAR) getline + +% Save the character data. + chardata charname [swx swy bbw bbh bbox bboy cbits] put + } for + + (ENDFONT) getline + +% Allocate the buffers for the bitmap and the outline, +% according to the font bounding box. + /fbbw fbbxe fbbxo sub def + /fbbh fbbye fbbyo sub def + /fraster fbbw 7 add 8 idiv def + /bits fraster fbbh mul 200 max 65535 min string def + /outline bits length 6 mul 65535 min string def + +% Process the characters. + chardata + { exch /charname exch def aload pop + /cbits exch def + /bboy exch def /bbox exch def + /bbh exch def /bbw exch def + /swy exch def /swx exch def + +% The bitmap handed to type1imagepath must have the correct height, +% because type1imagepath uses this to compute the scale factor, +% so we have to clear the unused parts of it. + /raster bbw 7 add 8 idiv def + bits dup 0 1 raster fbbh mul 1 sub + { 0 put dup } for + pop pop + bits raster fbbh bbh sub mul cbits putinterval + +% Compute the font entry, converting the bitmap to an outline. + bits 0 raster fbbh mul getinterval % the bitmap image + bbw fbbh % bitmap width & height + swx swy % width x & y + bbox neg bboy neg % origin x & y + % Account for lenIV when converting the outline. + outline lenIV outline length lenIV sub getinterval + type1imagepath + length lenIV add + outline exch 0 exch getinterval + +% Check for a fixed width font. + isfixedwidth + { fixedwidth null eq + { /fixedwidth swx def } + { fixedwidth swx ne { /isfixedwidth false def } if } + ifelse + } if + +% Finish up the character. + copystring + charname exch charstrings 3 1 roll put + } forall + +% Add CharStrings entries for aliases. + aliases + { charstrings 2 index known not charstrings 2 index known and + { charstrings exch get charstrings 3 1 roll put + } + { pop pop + } + ifelse + } + forall + +% If this is not a fixed-width font, synthesize missing characters +% out of available ones. + isfixedwidth not + { false composites + { 1 index charstrings exch known not + 1 index { decoding exch known and } forall + { ( /) print 1 index bits cvs print + /combine exch def + 0 1 combine length 1 sub + { dup combine exch get decoding exch get + bits 3 1 roll put + } for + bits 0 combine length getinterval copystring + [ exch /compose_proc load aload pop ] cvx + charstrings 3 1 roll put + pop true + } + { pop pop } + ifelse + } + forall flush + { Private /composematrix matrix put + Private /compose /compose load put + } + if + } + if + +% Synthesize accented characters with seac if needed and possible. + accentedchars + { aload pop /accent exch def /base exch def + buffer cvs /accented exch def + charstrings accented known not + charstrings base known and + charstrings accent known and + StandardDecoding base known and + StandardDecoding accent known and + encoding StandardDecoding base get get base eq and + encoding StandardDecoding accent get get accent eq and + { ( /) print accented print + charstrings base get findsbw 0 exch getinterval + /acstring exch def % start with sbw of base + charstrings accent get parsesbw + 4 { pop } repeat % just leave sbx + acstring exch concatnum + 0 concatnum 0 concatnum % adx ady + decoding base get concatnum % bchar + decoding accent get concatnum % achar + s_seac concatstrings + charstrings exch accented copystring exch put + } if + } forall + +% Make a CharStrings entry for .notdef. + outline lenIV <8b8b0d0e> putinterval % 0 0 hsbw endchar + charstrings /.notdef outline 0 lenIV 4 add getinterval copystring put + +% Encrypt the CharStrings and Subrs (in place). + charstrings + { % Be careful not to encrypt aliased characters twice, + % since they share their CharString. + aliases 2 index known + { charstrings aliases 3 index get .knownget + { 1 index ne } + { true } + ifelse + } + { true + } + ifelse + 1 index type /stringtype eq and + { 4330 exch dup .type1encrypt exch pop + readonly charstrings 3 1 roll put + } + { pop pop + } + ifelse + } + forall + 0 1 subrcount 1 sub + { dup subrs exch get + 4330 exch dup .type1encrypt exch pop + subrs 3 1 roll put + } + for + +% Make most of the remaining entries in the font dictionaries. + +% The Type 1 font machinery really only works with a 1000 unit +% character coordinate system. Set this up here, by computing the factor +% to make the X entry in the FontMatrix come out at exactly 0.001. + /fontscale 1000 fbbh div yres mul xres div def + Font /FontBBox + [ fbbxo fontscale mul + fbbyo fontscale mul + fbbxe fontscale mul + fbbye fontscale mul + ] cvx readonly put + Font /CharStrings charstrings readonly put + FontInfo /FullName known not + { % Some programs insist on FullName being present. + FontInfo /FullName FontName dup length string cvs put + } + if + FontInfo /isFixedPitch isfixedwidth put + subrcount 0 gt + { Private /Subrs subrs 0 subrcount getinterval readonly put + } if + +% Determine the italic angle and underline position +% by actually installing the font. + save + /_temp_ Font definefont setfont + [1000 0 0 1000 0 0] setmatrix % mitigate rounding problems +% The italic angle is the multiple of -5 degrees +% that minimizes the width of the 'I'. + 0 9999 0 5 85 + { dup rotate + newpath 0 0 moveto (I) false charpath + dup neg rotate + pathbbox pop exch pop exch sub + dup 3 index lt { 4 -2 roll } if + pop pop + } + for pop +% The underline position is halfway between the bottom of the 'A' +% and the bottom of the FontBBox. + newpath 0 0 moveto (A) false charpath + FontMatrix concat + pathbbox pop pop exch pop +% Put the values in FontInfo. + 3 -1 roll + restore + Font /FontBBox get 1 get add 2 div cvi + dup FontInfo /UnderlinePosition 3 -1 roll put + 2 div abs FontInfo /UnderlineThickness 3 -1 roll put + FontInfo /ItalicAngle 3 -1 roll put + +% Clean up and finish. + grestore + bdfile closefile + Font currentdict end end begin % remove font from dict stack + (\n) print flush + + } bind def + +% ------ Reader for AFM files ------ % + +% Dictionary for looking up character keywords + /cmdict 6 dict dup begin + /C { /c iarg def } def + /N { /n warg copystring def } def + /WX { /w narg def } def + /W0X /WX load def + /W /WX load def + /W0 /WX load def + end def + + /readAFM % fontdict afmfilename readAFM -> fontdict + { (r) file /bdfile exch def + /Font exch def + /commentword (Comment) def + +% Check for the StartFontMetrics. + (StartFontMetrics) getline + args cvr 2.0 lt { (Not version 2.0 or greater\n) print stop } if + +% Look for StartCharMetrics, then parse the character metrics. +% The only information we care about is the X width. + /metrics 0 dict def + { nextline + keyword (EndFontMetrics) eq { exit } if + keyword (StartCharMetrics) eq + { iarg dup dict /metrics exch def + { /c -1 def /n null def /w null def + nextline buffer + { token not { exit } if + dup cmdict exch known + { exch /args exch def cmdict exch get exec args } + { pop } + ifelse + } loop + c 0 ge n null ne or w null ne and + { n null eq { /n Font /Encoding get c get def } if + metrics n w put + } + if + } + repeat + (EndCharMetrics) getline + } if + } loop + +% Insert the metrics in the font. + metrics length 0 ne + { Font /Metrics metrics readonly put + } if + Font + } bind def + +end % envBDF + +% Enter the main program in the current dictionary. +/bdfafmtops % infilename afmfilename* outfilename fontname + % encodingname uniqueID xuid + { envBDF begin + 7 -2 roll exch 7 2 roll % afm* in out fontname encodingname uniqueID xuid + readBDF % afm* font + exch { readAFM } forall + save exch + dup /FontName get exch definefont + setfont + psfile writefont + restore + psfile closefile + end + } bind def + +% If the program was invoked from the command line, run it now. +[ shellarguments + { counttomark 4 ge + { dup 0 get + dup 48 ge exch 57 le and % last arg starts with a digit? + { /StandardEncoding } % no encodingname + { cvn } % have encodingname + ifelse + exch (.) search % next-to-last arg has . in it? + { mark 4 1 roll % have xuid + { cvi exch pop exch (.) search not { exit } if } + loop cvi ] + 3 -1 roll cvi exch + } + { cvi null % no xuid + } + ifelse + counttomark 5 roll + counttomark 6 sub array astore + 7 -2 roll cvn 7 -3 roll % make sure fontname is a name + bdfafmtops + } + { cleartomark + (Usage:\n bdftops xx.bdf [yy1.afm ...] zz.gsf fontname uniqueID [xuid] [encodingname]\n) print flush + mark + } + ifelse + } +if pop diff --git a/gs/lib/bjc610a0.upp b/gs/lib/bjc610a0.upp new file mode 100644 index 000000000..99d676f96 --- /dev/null +++ b/gs/lib/bjc610a0.upp @@ -0,0 +1,44 @@ +-supModel="Canon BJC 610, 360x360DpI, plain paper high speed, color, rendered" +-sDEVICE=uniprint +-dNOPAUSE +-dSAFER +-dupColorModel=/DeviceCMYKgenerate +-dupRendering=/FSCMYK32 +-dupOutputFormat=/Canon +-r360x360 +-dupMargins="{ 8.23 20.44 11.05 7.9 }" +-dupOutputComponentOrder="{ 3 2 1 0 }" +-dupBlackTransfer="{ +0.0000 0.0058 0.0164 0.0301 0.0463 0.0648 0.0851 0.1073 +0.1311 0.1564 0.1832 0.2114 0.2408 0.2716 0.3035 0.3366 +0.3708 0.4061 0.4425 0.4798 0.5182 0.5576 0.5978 0.6391 +0.6812 0.7242 0.7681 0.8128 0.8584 0.9048 0.9520 1.0000 +}" +-dupCyanTransfer="{ +0.0000 0.0008 0.0033 0.0075 0.0133 0.0208 0.0300 0.0408 +0.0533 0.0674 0.0832 0.1007 0.1199 0.1407 0.1632 0.1873 +0.2131 0.2406 0.2697 0.3005 0.3330 0.3671 0.4029 0.4404 +0.4795 0.5203 0.5627 0.6069 0.6527 0.7001 0.7492 0.8000 +}" +-dupMagentaTransfer="{ +0.0000 0.0008 0.0033 0.0075 0.0133 0.0208 0.0300 0.0408 +0.0533 0.0674 0.0832 0.1007 0.1199 0.1407 0.1632 0.1873 +0.2131 0.2406 0.2697 0.3005 0.3330 0.3671 0.4029 0.4404 +0.4795 0.5203 0.5627 0.6069 0.6527 0.7001 0.7492 0.8000 +}" +-dupYellowTransfer="{ +0.0000 0.0008 0.0033 0.0075 0.0133 0.0208 0.0300 0.0408 +0.0533 0.0674 0.0832 0.1007 0.1199 0.1407 0.1632 0.1873 +0.2131 0.2406 0.2697 0.3005 0.3330 0.3671 0.4029 0.4404 +0.4795 0.5203 0.5627 0.6069 0.6527 0.7001 0.7492 0.8000 +}" +-dupBeginPageCommand="< + 1b5b4b 0200 000f + 1b28 62 0100 01 + 1b28 63 0300 100200 + 1b28 64 0200 0168 + 1b28 6c 0200 1400 + 1b28 67 0100 E5 +>" +-dupEndJobCommand="(\033\050b\001\000\000\033@)" +-dupEndPageCommand="(\014)" diff --git a/gs/lib/bjc610a1.upp b/gs/lib/bjc610a1.upp new file mode 100644 index 000000000..febbdd954 --- /dev/null +++ b/gs/lib/bjc610a1.upp @@ -0,0 +1,44 @@ +-supModel="Canon BJC 610, 360x360DpI, plain paper, color, rendered" +-sDEVICE=uniprint +-dNOPAUSE +-dSAFER +-dupColorModel=/DeviceCMYKgenerate +-dupRendering=/FSCMYK32 +-dupOutputFormat=/Canon +-r360x360 +-dupMargins="{ 8.23 20.44 11.05 7.9 }" +-dupOutputComponentOrder="{ 3 2 1 0 }" +-dupBlackTransfer="{ +0.0000 0.0058 0.0164 0.0301 0.0463 0.0648 0.0851 0.1073 +0.1311 0.1564 0.1832 0.2114 0.2408 0.2716 0.3035 0.3366 +0.3708 0.4061 0.4425 0.4798 0.5182 0.5576 0.5978 0.6391 +0.6812 0.7242 0.7681 0.8128 0.8584 0.9048 0.9520 1.0000 +}" +-dupCyanTransfer="{ +0.0000 0.0008 0.0033 0.0075 0.0133 0.0208 0.0300 0.0408 +0.0533 0.0674 0.0832 0.1007 0.1199 0.1407 0.1632 0.1873 +0.2131 0.2406 0.2697 0.3005 0.3330 0.3671 0.4029 0.4404 +0.4795 0.5203 0.5627 0.6069 0.6527 0.7001 0.7492 0.8000 +}" +-dupMagentaTransfer="{ +0.0000 0.0008 0.0033 0.0075 0.0133 0.0208 0.0300 0.0408 +0.0533 0.0674 0.0832 0.1007 0.1199 0.1407 0.1632 0.1873 +0.2131 0.2406 0.2697 0.3005 0.3330 0.3671 0.4029 0.4404 +0.4795 0.5203 0.5627 0.6069 0.6527 0.7001 0.7492 0.8000 +}" +-dupYellowTransfer="{ +0.0000 0.0008 0.0033 0.0075 0.0133 0.0208 0.0300 0.0408 +0.0533 0.0674 0.0832 0.1007 0.1199 0.1407 0.1632 0.1873 +0.2131 0.2406 0.2697 0.3005 0.3330 0.3671 0.4029 0.4404 +0.4795 0.5203 0.5627 0.6069 0.6527 0.7001 0.7492 0.8000 +}" +-dupBeginPageCommand="< + 1b5b4b 0200 000f + 1b28 62 0100 01 + 1b28 63 0300 100110 + 1b28 64 0200 0168 + 1b28 6c 0200 1400 + 1b28 67 0100 E5 +>" +-dupEndJobCommand="(\033\050b\001\000\000\033@)" +-dupEndPageCommand="(\014)" diff --git a/gs/lib/bjc610a2.upp b/gs/lib/bjc610a2.upp new file mode 100644 index 000000000..bf039508c --- /dev/null +++ b/gs/lib/bjc610a2.upp @@ -0,0 +1,44 @@ +-supModel="Canon BJC 610, 360x360DpI, coated paper, color, rendered" +-sDEVICE=uniprint +-dNOPAUSE +-dSAFER +-dupColorModel=/DeviceCMYKgenerate +-dupRendering=/FSCMYK32 +-dupOutputFormat=/Canon +-r360x360 +-dupMargins="{ 8.23 20.44 11.05 7.9 }" +-dupOutputComponentOrder="{ 3 2 1 0 }" +-dupBlackTransfer="{ +0.0000 0.0058 0.0164 0.0301 0.0463 0.0648 0.0851 0.1073 +0.1311 0.1564 0.1832 0.2114 0.2408 0.2716 0.3035 0.3366 +0.3708 0.4061 0.4425 0.4798 0.5182 0.5576 0.5978 0.6391 +0.6812 0.7242 0.7681 0.8128 0.8584 0.9048 0.9520 1.0000 +}" +-dupCyanTransfer="{ +0.0000 0.0008 0.0033 0.0075 0.0133 0.0208 0.0300 0.0408 +0.0533 0.0674 0.0832 0.1007 0.1199 0.1407 0.1632 0.1873 +0.2131 0.2406 0.2697 0.3005 0.3330 0.3671 0.4029 0.4404 +0.4795 0.5203 0.5627 0.6069 0.6527 0.7001 0.7492 0.8000 +}" +-dupMagentaTransfer="{ +0.0000 0.0008 0.0033 0.0075 0.0133 0.0208 0.0300 0.0408 +0.0533 0.0674 0.0832 0.1007 0.1199 0.1407 0.1632 0.1873 +0.2131 0.2406 0.2697 0.3005 0.3330 0.3671 0.4029 0.4404 +0.4795 0.5203 0.5627 0.6069 0.6527 0.7001 0.7492 0.8000 +}" +-dupYellowTransfer="{ +0.0000 0.0008 0.0033 0.0075 0.0133 0.0208 0.0300 0.0408 +0.0533 0.0674 0.0832 0.1007 0.1199 0.1407 0.1632 0.1873 +0.2131 0.2406 0.2697 0.3005 0.3330 0.3671 0.4029 0.4404 +0.4795 0.5203 0.5627 0.6069 0.6527 0.7001 0.7492 0.8000 +}" +-dupBeginPageCommand="< + 1b5b4b 0200 000f + 1b28 62 0100 01 + 1b28 63 0300 101110 + 1b28 64 0200 0168 + 1b28 6c 0200 1410 + 1b28 67 0100 E5 +>" +-dupEndJobCommand="(\033\050b\001\000\000\033@)" +-dupEndPageCommand="(\014)" diff --git a/gs/lib/bjc610a3.upp b/gs/lib/bjc610a3.upp new file mode 100644 index 000000000..031f47c83 --- /dev/null +++ b/gs/lib/bjc610a3.upp @@ -0,0 +1,44 @@ +-supModel="Canon BJC 610, 360x360DpI, transparency film, color, rendered" +-sDEVICE=uniprint +-dNOPAUSE +-dSAFER +-dupColorModel=/DeviceCMYKgenerate +-dupRendering=/FSCMYK32 +-dupOutputFormat=/Canon +-r360x360 +-dupMargins="{ 8.23 20.44 11.05 7.9 }" +-dupOutputComponentOrder="{ 3 2 1 0 }" +-dupBlackTransfer="{ +0.0000 0.0008 0.0033 0.0075 0.0133 0.0208 0.0300 0.0408 +0.0533 0.0674 0.0832 0.1007 0.1199 0.1407 0.1632 0.1873 +0.2131 0.2406 0.2697 0.3005 0.3330 0.3671 0.4029 0.4404 +0.4795 0.5203 0.5627 0.6069 0.6527 0.7001 0.7492 0.8000 +}" +-dupCyanTransfer="{ +0.0000 0.0008 0.0033 0.0075 0.0133 0.0208 0.0300 0.0408 +0.0533 0.0674 0.0832 0.1007 0.1199 0.1407 0.1632 0.1873 +0.2131 0.2406 0.2697 0.3005 0.3330 0.3671 0.4029 0.4404 +0.4795 0.5203 0.5627 0.6069 0.6527 0.7001 0.7492 0.8000 +}" +-dupMagentaTransfer="{ +0.0000 0.0008 0.0033 0.0075 0.0133 0.0208 0.0300 0.0408 +0.0533 0.0674 0.0832 0.1007 0.1199 0.1407 0.1632 0.1873 +0.2131 0.2406 0.2697 0.3005 0.3330 0.3671 0.4029 0.4404 +0.4795 0.5203 0.5627 0.6069 0.6527 0.7001 0.7492 0.8000 +}" +-dupYellowTransfer="{ +0.0000 0.0008 0.0033 0.0075 0.0133 0.0208 0.0300 0.0408 +0.0533 0.0674 0.0832 0.1007 0.1199 0.1407 0.1632 0.1873 +0.2131 0.2406 0.2697 0.3005 0.3330 0.3671 0.4029 0.4404 +0.4795 0.5203 0.5627 0.6069 0.6527 0.7001 0.7492 0.8000 +}" +-dupBeginPageCommand="< + 1b5b4b 0200 000f + 1b28 62 0100 01 + 1b28 63 0300 102110 + 1b28 64 0200 0168 + 1b28 6c 0200 1420 + 1b28 67 0100 E5 +>" +-dupEndJobCommand="(\033\050b\001\000\000\033@)" +-dupEndPageCommand="(\014)" diff --git a/gs/lib/bjc610a4.upp b/gs/lib/bjc610a4.upp new file mode 100644 index 000000000..eb47e685c --- /dev/null +++ b/gs/lib/bjc610a4.upp @@ -0,0 +1,45 @@ +-supModel="Canon BJC 610, 360x360DpI, back print film, color, rendered" +-sDEVICE=uniprint +-dNOPAUSE +-dSAFER +-dupColorModel=/DeviceCMYKgenerate +-dupRendering=/FSCMYK32 +-dupOutputFormat=/Canon +-r360x360 +-dupYFlip +-dupMargins="{ 8.23 20.44 11.05 7.9 }" +-dupOutputComponentOrder="{ 3 2 1 0 }" +-dupBlackTransfer="{ +0.0000 0.0058 0.0164 0.0301 0.0463 0.0648 0.0851 0.1073 +0.1311 0.1564 0.1832 0.2114 0.2408 0.2716 0.3035 0.3366 +0.3708 0.4061 0.4425 0.4798 0.5182 0.5576 0.5978 0.6391 +0.6812 0.7242 0.7681 0.8128 0.8584 0.9048 0.9520 1.0000 +}" +-dupCyanTransfer="{ +0.0000 0.0008 0.0033 0.0075 0.0133 0.0208 0.0300 0.0408 +0.0533 0.0674 0.0832 0.1007 0.1199 0.1407 0.1632 0.1873 +0.2131 0.2406 0.2697 0.3005 0.3330 0.3671 0.4029 0.4404 +0.4795 0.5203 0.5627 0.6069 0.6527 0.7001 0.7492 0.8000 +}" +-dupMagentaTransfer="{ +0.0000 0.0008 0.0033 0.0075 0.0133 0.0208 0.0300 0.0408 +0.0533 0.0674 0.0832 0.1007 0.1199 0.1407 0.1632 0.1873 +0.2131 0.2406 0.2697 0.3005 0.3330 0.3671 0.4029 0.4404 +0.4795 0.5203 0.5627 0.6069 0.6527 0.7001 0.7492 0.8000 +}" +-dupYellowTransfer="{ +0.0000 0.0008 0.0033 0.0075 0.0133 0.0208 0.0300 0.0408 +0.0533 0.0674 0.0832 0.1007 0.1199 0.1407 0.1632 0.1873 +0.2131 0.2406 0.2697 0.3005 0.3330 0.3671 0.4029 0.4404 +0.4795 0.5203 0.5627 0.6069 0.6527 0.7001 0.7492 0.8000 +}" +-dupBeginPageCommand="< + 1b5b4b 0200 000f + 1b28 62 0100 01 + 1b28 63 0300 103110 + 1b28 64 0200 0168 + 1b28 6c 0200 1430 + 1b28 67 0100 E5 +>" +-dupEndJobCommand="(\033\050b\001\000\000\033@)" +-dupEndPageCommand="(\014)" diff --git a/gs/lib/bjc610a5.upp b/gs/lib/bjc610a5.upp new file mode 100644 index 000000000..42dbd20ef --- /dev/null +++ b/gs/lib/bjc610a5.upp @@ -0,0 +1,44 @@ +-supModel="Canon BJC 610, 360x360DpI, fabric sheet, color, rendered" +-sDEVICE=uniprint +-dNOPAUSE +-dSAFER +-dupColorModel=/DeviceCMYKgenerate +-dupRendering=/FSCMYK32 +-dupOutputFormat=/Canon +-r360x360 +-dupMargins="{ 8.23 20.44 11.05 7.9 }" +-dupOutputComponentOrder="{ 3 2 1 0 }" +-dupBlackTransfer="{ +0.0000 0.0058 0.0164 0.0301 0.0463 0.0648 0.0851 0.1073 +0.1311 0.1564 0.1832 0.2114 0.2408 0.2716 0.3035 0.3366 +0.3708 0.4061 0.4425 0.4798 0.5182 0.5576 0.5978 0.6391 +0.6812 0.7242 0.7681 0.8128 0.8584 0.9048 0.9520 1.0000 +}" +-dupCyanTransfer="{ +0.0000 0.0008 0.0033 0.0075 0.0133 0.0208 0.0300 0.0408 +0.0533 0.0674 0.0832 0.1007 0.1199 0.1407 0.1632 0.1873 +0.2131 0.2406 0.2697 0.3005 0.3330 0.3671 0.4029 0.4404 +0.4795 0.5203 0.5627 0.6069 0.6527 0.7001 0.7492 0.8000 +}" +-dupMagentaTransfer="{ +0.0000 0.0008 0.0033 0.0075 0.0133 0.0208 0.0300 0.0408 +0.0533 0.0674 0.0832 0.1007 0.1199 0.1407 0.1632 0.1873 +0.2131 0.2406 0.2697 0.3005 0.3330 0.3671 0.4029 0.4404 +0.4795 0.5203 0.5627 0.6069 0.6527 0.7001 0.7492 0.8000 +}" +-dupYellowTransfer="{ +0.0000 0.0008 0.0033 0.0075 0.0133 0.0208 0.0300 0.0408 +0.0533 0.0674 0.0832 0.1007 0.1199 0.1407 0.1632 0.1873 +0.2131 0.2406 0.2697 0.3005 0.3330 0.3671 0.4029 0.4404 +0.4795 0.5203 0.5627 0.6069 0.6527 0.7001 0.7492 0.8000 +}" +-dupBeginPageCommand="< + 1b5b4b 0200 000f + 1b28 62 0100 01 + 1b28 63 0300 104110 + 1b28 64 0200 0168 + 1b28 6c 0200 1850 + 1b28 67 0100 E5 +>" +-dupEndJobCommand="(\033\050b\001\000\000\033@)" +-dupEndPageCommand="(\014)" diff --git a/gs/lib/bjc610a6.upp b/gs/lib/bjc610a6.upp new file mode 100644 index 000000000..19ad1f656 --- /dev/null +++ b/gs/lib/bjc610a6.upp @@ -0,0 +1,44 @@ +-supModel="Canon BJC 610, 360x360DpI, glossy paper, color, rendered" +-sDEVICE=uniprint +-dNOPAUSE +-dSAFER +-dupColorModel=/DeviceCMYKgenerate +-dupRendering=/FSCMYK32 +-dupOutputFormat=/Canon +-r360x360 +-dupMargins="{ 8.23 20.44 11.05 7.9 }" +-dupOutputComponentOrder="{ 3 2 1 0 }" +-dupBlackTransfer="{ +0.0000 0.0058 0.0164 0.0301 0.0463 0.0648 0.0851 0.1073 +0.1311 0.1564 0.1832 0.2114 0.2408 0.2716 0.3035 0.3366 +0.3708 0.4061 0.4425 0.4798 0.5182 0.5576 0.5978 0.6391 +0.6812 0.7242 0.7681 0.8128 0.8584 0.9048 0.9520 1.0000 +}" +-dupCyanTransfer="{ +0.0000 0.0008 0.0033 0.0075 0.0133 0.0208 0.0300 0.0408 +0.0533 0.0674 0.0832 0.1007 0.1199 0.1407 0.1632 0.1873 +0.2131 0.2406 0.2697 0.3005 0.3330 0.3671 0.4029 0.4404 +0.4795 0.5203 0.5627 0.6069 0.6527 0.7001 0.7492 0.8000 +}" +-dupMagentaTransfer="{ +0.0000 0.0008 0.0033 0.0075 0.0133 0.0208 0.0300 0.0408 +0.0533 0.0674 0.0832 0.1007 0.1199 0.1407 0.1632 0.1873 +0.2131 0.2406 0.2697 0.3005 0.3330 0.3671 0.4029 0.4404 +0.4795 0.5203 0.5627 0.6069 0.6527 0.7001 0.7492 0.8000 +}" +-dupYellowTransfer="{ +0.0000 0.0008 0.0033 0.0075 0.0133 0.0208 0.0300 0.0408 +0.0533 0.0674 0.0832 0.1007 0.1199 0.1407 0.1632 0.1873 +0.2131 0.2406 0.2697 0.3005 0.3330 0.3671 0.4029 0.4404 +0.4795 0.5203 0.5627 0.6069 0.6527 0.7001 0.7492 0.8000 +}" +-dupBeginPageCommand="< + 1b5b4b 0200 000f + 1b28 62 0100 01 + 1b28 63 0300 105110 + 1b28 64 0200 0168 + 1b28 6c 0200 1460 + 1b28 67 0100 E5 +>" +-dupEndJobCommand="(\033\050b\001\000\000\033@)" +-dupEndPageCommand="(\014)" diff --git a/gs/lib/bjc610a7.upp b/gs/lib/bjc610a7.upp new file mode 100644 index 000000000..727d366f8 --- /dev/null +++ b/gs/lib/bjc610a7.upp @@ -0,0 +1,44 @@ +-supModel="Canon BJC 610, 360x360DpI, high gloss film, color, rendered" +-sDEVICE=uniprint +-dNOPAUSE +-dSAFER +-dupColorModel=/DeviceCMYKgenerate +-dupRendering=/FSCMYK32 +-dupOutputFormat=/Canon +-r360x360 +-dupMargins="{ 8.23 20.44 11.05 7.9 }" +-dupOutputComponentOrder="{ 3 2 1 0 }" +-dupBlackTransfer="{ +0.0000 0.0008 0.0033 0.0075 0.0133 0.0208 0.0300 0.0408 +0.0533 0.0674 0.0832 0.1007 0.1199 0.1407 0.1632 0.1873 +0.2131 0.2406 0.2697 0.3005 0.3330 0.3671 0.4029 0.4404 +0.4795 0.5203 0.5627 0.6069 0.6527 0.7001 0.7492 0.8000 +}" +-dupCyanTransfer="{ +0.0000 0.0008 0.0033 0.0075 0.0133 0.0208 0.0300 0.0408 +0.0533 0.0674 0.0832 0.1007 0.1199 0.1407 0.1632 0.1873 +0.2131 0.2406 0.2697 0.3005 0.3330 0.3671 0.4029 0.4404 +0.4795 0.5203 0.5627 0.6069 0.6527 0.7001 0.7492 0.8000 +}" +-dupMagentaTransfer="{ +0.0000 0.0008 0.0033 0.0075 0.0133 0.0208 0.0300 0.0408 +0.0533 0.0674 0.0832 0.1007 0.1199 0.1407 0.1632 0.1873 +0.2131 0.2406 0.2697 0.3005 0.3330 0.3671 0.4029 0.4404 +0.4795 0.5203 0.5627 0.6069 0.6527 0.7001 0.7492 0.8000 +}" +-dupYellowTransfer="{ +0.0000 0.0008 0.0033 0.0075 0.0133 0.0208 0.0300 0.0408 +0.0533 0.0674 0.0832 0.1007 0.1199 0.1407 0.1632 0.1873 +0.2131 0.2406 0.2697 0.3005 0.3330 0.3671 0.4029 0.4404 +0.4795 0.5203 0.5627 0.6069 0.6527 0.7001 0.7492 0.8000 +}" +-dupBeginPageCommand="< + 1b5b4b 0200 000f + 1b28 62 0100 01 + 1b28 63 0300 106110 + 1b28 64 0200 0168 + 1b28 6c 0200 1470 + 1b28 67 0100 E5 +>" +-dupEndJobCommand="(\033\050b\001\000\000\033@)" +-dupEndPageCommand="(\014)" diff --git a/gs/lib/bjc610a8.upp b/gs/lib/bjc610a8.upp new file mode 100644 index 000000000..b5407b576 --- /dev/null +++ b/gs/lib/bjc610a8.upp @@ -0,0 +1,44 @@ +-supModel="Canon BJC 610, 360x360DpI, high resolution paper, color, rendered" +-sDEVICE=uniprint +-dNOPAUSE +-dSAFER +-dupColorModel=/DeviceCMYKgenerate +-dupRendering=/FSCMYK32 +-dupOutputFormat=/Canon +-r360x360 +-dupMargins="{ 8.23 20.44 11.05 7.9 }" +-dupOutputComponentOrder="{ 3 2 1 0 }" +-dupBlackTransfer="{ +0.0000 0.0058 0.0164 0.0301 0.0463 0.0648 0.0851 0.1073 +0.1311 0.1564 0.1832 0.2114 0.2408 0.2716 0.3035 0.3366 +0.3708 0.4061 0.4425 0.4798 0.5182 0.5576 0.5978 0.6391 +0.6812 0.7242 0.7681 0.8128 0.8584 0.9048 0.9520 1.0000 +}" +-dupCyanTransfer="{ +0.0000 0.0008 0.0033 0.0075 0.0133 0.0208 0.0300 0.0408 +0.0533 0.0674 0.0832 0.1007 0.1199 0.1407 0.1632 0.1873 +0.2131 0.2406 0.2697 0.3005 0.3330 0.3671 0.4029 0.4404 +0.4795 0.5203 0.5627 0.6069 0.6527 0.7001 0.7492 0.8000 +}" +-dupMagentaTransfer="{ +0.0000 0.0008 0.0033 0.0075 0.0133 0.0208 0.0300 0.0408 +0.0533 0.0674 0.0832 0.1007 0.1199 0.1407 0.1632 0.1873 +0.2131 0.2406 0.2697 0.3005 0.3330 0.3671 0.4029 0.4404 +0.4795 0.5203 0.5627 0.6069 0.6527 0.7001 0.7492 0.8000 +}" +-dupYellowTransfer="{ +0.0000 0.0008 0.0033 0.0075 0.0133 0.0208 0.0300 0.0408 +0.0533 0.0674 0.0832 0.1007 0.1199 0.1407 0.1632 0.1873 +0.2131 0.2406 0.2697 0.3005 0.3330 0.3671 0.4029 0.4404 +0.4795 0.5203 0.5627 0.6069 0.6527 0.7001 0.7492 0.8000 +}" +-dupBeginPageCommand="< + 1b5b4b 0200 000f + 1b28 62 0100 01 + 1b28 63 0300 107110 + 1b28 64 0200 0168 + 1b28 6c 0200 14a0 + 1b28 67 0100 E5 +>" +-dupEndJobCommand="(\033\050b\001\000\000\033@)" +-dupEndPageCommand="(\014)" diff --git a/gs/lib/bjc610b1.upp b/gs/lib/bjc610b1.upp new file mode 100644 index 000000000..0d6e48137 --- /dev/null +++ b/gs/lib/bjc610b1.upp @@ -0,0 +1,44 @@ +-supModel="Canon BJC 610, 720x720DpI, plain paper, color, rendered" +-sDEVICE=uniprint +-dNOPAUSE +-dSAFER +-dupColorModel=/DeviceCMYKgenerate +-dupRendering=/FSCMYK32 +-dupOutputFormat=/Canon +-r720x720 +-dupMargins="{ 8.23 20.44 11.05 7.9 }" +-dupOutputComponentOrder="{ 3 2 1 0 }" +-dupBlackTransfer="{ +0.0000 0.0029 0.0082 0.0151 0.0232 0.0324 0.0426 0.0537 +0.0655 0.0782 0.0916 0.1057 0.1204 0.1358 0.1517 0.1683 +0.1854 0.2030 0.2212 0.2399 0.2591 0.2788 0.2989 0.3195 +0.3406 0.3621 0.3840 0.4064 0.4292 0.4524 0.4760 0.5000 +}" +-dupCyanTransfer="{ +0.0000 0.0004 0.0017 0.0037 0.0067 0.0104 0.0150 0.0204 +0.0266 0.0337 0.0416 0.0504 0.0599 0.0703 0.0816 0.0937 +0.1066 0.1203 0.1349 0.1503 0.1665 0.1836 0.2015 0.2202 +0.2398 0.2601 0.2814 0.3034 0.3263 0.3501 0.3746 0.4000 +}" +-dupMagentaTransfer="{ +0.0000 0.0004 0.0017 0.0037 0.0067 0.0104 0.0150 0.0204 +0.0266 0.0337 0.0416 0.0504 0.0599 0.0703 0.0816 0.0937 +0.1066 0.1203 0.1349 0.1503 0.1665 0.1836 0.2015 0.2202 +0.2398 0.2601 0.2814 0.3034 0.3263 0.3501 0.3746 0.4000 +}" +-dupYellowTransfer="{ +0.0000 0.0004 0.0017 0.0037 0.0067 0.0104 0.0150 0.0204 +0.0266 0.0337 0.0416 0.0504 0.0599 0.0703 0.0816 0.0937 +0.1066 0.1203 0.1349 0.1503 0.1665 0.1836 0.2015 0.2202 +0.2398 0.2601 0.2814 0.3034 0.3263 0.3501 0.3746 0.4000 +}" +-dupBeginPageCommand="< + 1b5b4b 0200 000f + 1b28 62 0100 01 + 1b28 63 0300 101110 + 1b28 64 0200 02d0 + 1b28 6c 0200 1410 + 1b28 67 0100 E5 +>" +-dupEndJobCommand="(\033\050b\001\000\000\033@)" +-dupEndPageCommand="(\014)" diff --git a/gs/lib/bjc610b2.upp b/gs/lib/bjc610b2.upp new file mode 100644 index 000000000..f17947af8 --- /dev/null +++ b/gs/lib/bjc610b2.upp @@ -0,0 +1,44 @@ +-supModel="Canon BJC 610, 720x720DpI, coated paper, color, rendered" +-sDEVICE=uniprint +-dNOPAUSE +-dSAFER +-dupColorModel=/DeviceCMYKgenerate +-dupRendering=/FSCMYK32 +-dupOutputFormat=/Canon +-r720x720 +-dupMargins="{ 8.23 20.44 11.05 7.9 }" +-dupOutputComponentOrder="{ 3 2 1 0 }" +-dupBlackTransfer="{ +0.0000 0.0029 0.0082 0.0151 0.0232 0.0324 0.0426 0.0537 +0.0655 0.0782 0.0916 0.1057 0.1204 0.1358 0.1517 0.1683 +0.1854 0.2030 0.2212 0.2399 0.2591 0.2788 0.2989 0.3195 +0.3406 0.3621 0.3840 0.4064 0.4292 0.4524 0.4760 0.5000 +}" +-dupCyanTransfer="{ +0.0000 0.0005 0.0021 0.0047 0.0083 0.0130 0.0187 0.0255 +0.0333 0.0421 0.0520 0.0630 0.0749 0.0879 0.1020 0.1171 +0.1332 0.1504 0.1686 0.1878 0.2081 0.2294 0.2518 0.2752 +0.2997 0.3252 0.3517 0.3793 0.4079 0.4376 0.4683 0.5000 +}" +-dupMagentaTransfer="{ +0.0000 0.0005 0.0021 0.0047 0.0083 0.0130 0.0187 0.0255 +0.0333 0.0421 0.0520 0.0630 0.0749 0.0879 0.1020 0.1171 +0.1332 0.1504 0.1686 0.1878 0.2081 0.2294 0.2518 0.2752 +0.2997 0.3252 0.3517 0.3793 0.4079 0.4376 0.4683 0.5000 +}" +-dupYellowTransfer="{ +0.0000 0.0005 0.0021 0.0047 0.0083 0.0130 0.0187 0.0255 +0.0333 0.0421 0.0520 0.0630 0.0749 0.0879 0.1020 0.1171 +0.1332 0.1504 0.1686 0.1878 0.2081 0.2294 0.2518 0.2752 +0.2997 0.3252 0.3517 0.3793 0.4079 0.4376 0.4683 0.5000 +}" +-dupBeginPageCommand="< + 1b5b4b 0200 000f + 1b28 62 0100 01 + 1b28 63 0300 101110 + 1b28 64 0200 02d0 + 1b28 6c 0200 1410 + 1b28 67 0100 E5 +>" +-dupEndJobCommand="(\033\050b\001\000\000\033@)" +-dupEndPageCommand="(\014)" diff --git a/gs/lib/bjc610b3.upp b/gs/lib/bjc610b3.upp new file mode 100644 index 000000000..0ed5ca27b --- /dev/null +++ b/gs/lib/bjc610b3.upp @@ -0,0 +1,44 @@ +-supModel="Canon BJC 610, 720x720DpI, transparency film, color, rendered" +-sDEVICE=uniprint +-dNOPAUSE +-dSAFER +-dupColorModel=/DeviceCMYKgenerate +-dupRendering=/FSCMYK32 +-dupOutputFormat=/Canon +-r720x720 +-dupMargins="{ 8.23 20.44 11.05 7.9 }" +-dupOutputComponentOrder="{ 3 2 1 0 }" +-dupBlackTransfer="{ +0.0000 0.0008 0.0033 0.0075 0.0133 0.0208 0.0300 0.0408 +0.0533 0.0674 0.0832 0.1007 0.1199 0.1407 0.1632 0.1873 +0.2131 0.2406 0.2697 0.3005 0.3330 0.3671 0.4029 0.4404 +0.4795 0.5203 0.5627 0.6069 0.6527 0.7001 0.7492 0.8000 +}" +-dupCyanTransfer="{ +0.0000 0.0005 0.0021 0.0047 0.0083 0.0130 0.0187 0.0255 +0.0333 0.0421 0.0520 0.0630 0.0749 0.0879 0.1020 0.1171 +0.1332 0.1504 0.1686 0.1878 0.2081 0.2294 0.2518 0.2752 +0.2997 0.3252 0.3517 0.3793 0.4079 0.4376 0.4683 0.5000 +}" +-dupMagentaTransfer="{ +0.0000 0.0005 0.0021 0.0047 0.0083 0.0130 0.0187 0.0255 +0.0333 0.0421 0.0520 0.0630 0.0749 0.0879 0.1020 0.1171 +0.1332 0.1504 0.1686 0.1878 0.2081 0.2294 0.2518 0.2752 +0.2997 0.3252 0.3517 0.3793 0.4079 0.4376 0.4683 0.5000 +}" +-dupYellowTransfer="{ +0.0000 0.0005 0.0021 0.0047 0.0083 0.0130 0.0187 0.0255 +0.0333 0.0421 0.0520 0.0630 0.0749 0.0879 0.1020 0.1171 +0.1332 0.1504 0.1686 0.1878 0.2081 0.2294 0.2518 0.2752 +0.2997 0.3252 0.3517 0.3793 0.4079 0.4376 0.4683 0.5000 +}" +-dupBeginPageCommand="< + 1b5b4b 0200 000f + 1b28 62 0100 01 + 1b28 63 0300 102110 + 1b28 64 0200 02d0 + 1b28 6c 0200 1420 + 1b28 67 0100 E5 +>" +-dupEndJobCommand="(\033\050b\001\000\000\033@)" +-dupEndPageCommand="(\014)" diff --git a/gs/lib/bjc610b4.upp b/gs/lib/bjc610b4.upp new file mode 100644 index 000000000..a4d665688 --- /dev/null +++ b/gs/lib/bjc610b4.upp @@ -0,0 +1,45 @@ +-supModel="Canon BJC 610, 720x720DpI, back print film, color, rendered" +-sDEVICE=uniprint +-dNOPAUSE +-dSAFER +-dupColorModel=/DeviceCMYKgenerate +-dupRendering=/FSCMYK32 +-dupOutputFormat=/Canon +-r720x720 +-dupYFlip +-dupMargins="{ 8.23 20.44 11.05 7.9 }" +-dupOutputComponentOrder="{ 3 2 1 0 }" +-dupBlackTransfer="{ +0.0000 0.0008 0.0033 0.0075 0.0133 0.0208 0.0300 0.0408 +0.0533 0.0674 0.0832 0.1007 0.1199 0.1407 0.1632 0.1873 +0.2131 0.2406 0.2697 0.3005 0.3330 0.3671 0.4029 0.4404 +0.4795 0.5203 0.5627 0.6069 0.6527 0.7001 0.7492 0.8000 +}" +-dupCyanTransfer="{ +0.0000 0.0005 0.0019 0.0042 0.0075 0.0117 0.0169 0.0229 +0.0300 0.0379 0.0468 0.0567 0.0674 0.0791 0.0918 0.1054 +0.1199 0.1353 0.1517 0.1690 0.1873 0.2065 0.2266 0.2477 +0.2697 0.2927 0.3165 0.3414 0.3671 0.3938 0.4214 0.4500 +}" +-dupMagentaTransfer="{ +0.0000 0.0005 0.0019 0.0042 0.0075 0.0117 0.0169 0.0229 +0.0300 0.0379 0.0468 0.0567 0.0674 0.0791 0.0918 0.1054 +0.1199 0.1353 0.1517 0.1690 0.1873 0.2065 0.2266 0.2477 +0.2697 0.2927 0.3165 0.3414 0.3671 0.3938 0.4214 0.4500 +}" +-dupYellowTransfer="{ +0.0000 0.0005 0.0019 0.0042 0.0075 0.0117 0.0169 0.0229 +0.0300 0.0379 0.0468 0.0567 0.0674 0.0791 0.0918 0.1054 +0.1199 0.1353 0.1517 0.1690 0.1873 0.2065 0.2266 0.2477 +0.2697 0.2927 0.3165 0.3414 0.3671 0.3938 0.4214 0.4500 +}" +-dupBeginPageCommand="< + 1b5b4b 0200 000f + 1b28 62 0100 01 + 1b28 63 0300 103110 + 1b28 64 0200 02d0 + 1b28 6c 0200 1430 + 1b28 67 0100 E5 +>" +-dupEndJobCommand="(\033\050b\001\000\000\033@)" +-dupEndPageCommand="(\014)" diff --git a/gs/lib/bjc610b6.upp b/gs/lib/bjc610b6.upp new file mode 100644 index 000000000..ae27bdb32 --- /dev/null +++ b/gs/lib/bjc610b6.upp @@ -0,0 +1,44 @@ +-supModel="Canon BJC 610, 720x720DpI, glossy paper, color, rendered" +-sDEVICE=uniprint +-dNOPAUSE +-dSAFER +-dupColorModel=/DeviceCMYKgenerate +-dupRendering=/FSCMYK32 +-dupOutputFormat=/Canon +-r720x720 +-dupMargins="{ 8.23 20.44 11.05 7.9 }" +-dupOutputComponentOrder="{ 3 2 1 0 }" +-dupBlackTransfer="{ +0.0000 0.0029 0.0082 0.0151 0.0232 0.0324 0.0426 0.0537 +0.0655 0.0782 0.0916 0.1057 0.1204 0.1358 0.1517 0.1683 +0.1854 0.2030 0.2212 0.2399 0.2591 0.2788 0.2989 0.3195 +0.3406 0.3621 0.3840 0.4064 0.4292 0.4524 0.4760 0.5000 +}" +-dupCyanTransfer="{ +0.0000 0.0005 0.0021 0.0047 0.0083 0.0130 0.0187 0.0255 +0.0333 0.0421 0.0520 0.0630 0.0749 0.0879 0.1020 0.1171 +0.1332 0.1504 0.1686 0.1878 0.2081 0.2294 0.2518 0.2752 +0.2997 0.3252 0.3517 0.3793 0.4079 0.4376 0.4683 0.5000 +}" +-dupMagentaTransfer="{ +0.0000 0.0005 0.0021 0.0047 0.0083 0.0130 0.0187 0.0255 +0.0333 0.0421 0.0520 0.0630 0.0749 0.0879 0.1020 0.1171 +0.1332 0.1504 0.1686 0.1878 0.2081 0.2294 0.2518 0.2752 +0.2997 0.3252 0.3517 0.3793 0.4079 0.4376 0.4683 0.5000 +}" +-dupYellowTransfer="{ +0.0000 0.0005 0.0021 0.0047 0.0083 0.0130 0.0187 0.0255 +0.0333 0.0421 0.0520 0.0630 0.0749 0.0879 0.1020 0.1171 +0.1332 0.1504 0.1686 0.1878 0.2081 0.2294 0.2518 0.2752 +0.2997 0.3252 0.3517 0.3793 0.4079 0.4376 0.4683 0.5000 +}" +-dupBeginPageCommand="< + 1b5b4b 0200 000f + 1b28 62 0100 01 + 1b28 63 0300 105110 + 1b28 64 0200 02d0 + 1b28 6c 0200 1460 + 1b28 67 0100 E5 +>" +-dupEndJobCommand="(\033\050b\001\000\000\033@)" +-dupEndPageCommand="(\014)" diff --git a/gs/lib/bjc610b7.upp b/gs/lib/bjc610b7.upp new file mode 100644 index 000000000..f7c68c4b2 --- /dev/null +++ b/gs/lib/bjc610b7.upp @@ -0,0 +1,44 @@ +-supModel="Canon BJC 610, 720x720DpI, high gloss paper, color, rendered" +-sDEVICE=uniprint +-dNOPAUSE +-dSAFER +-dupColorModel=/DeviceCMYKgenerate +-dupRendering=/FSCMYK32 +-dupOutputFormat=/Canon +-r720x720 +-dupMargins="{ 8.23 20.44 11.05 7.9 }" +-dupOutputComponentOrder="{ 3 2 1 0 }" +-dupBlackTransfer="{ +0.0000 0.0008 0.0033 0.0075 0.0133 0.0208 0.0300 0.0408 +0.0533 0.0674 0.0832 0.1007 0.1199 0.1407 0.1632 0.1873 +0.2131 0.2406 0.2697 0.3005 0.3330 0.3671 0.4029 0.4404 +0.4795 0.5203 0.5627 0.6069 0.6527 0.7001 0.7492 0.8000 +}" +-dupCyanTransfer="{ +0.0000 0.0005 0.0021 0.0047 0.0083 0.0130 0.0187 0.0255 +0.0333 0.0421 0.0520 0.0630 0.0749 0.0879 0.1020 0.1171 +0.1332 0.1504 0.1686 0.1878 0.2081 0.2294 0.2518 0.2752 +0.2997 0.3252 0.3517 0.3793 0.4079 0.4376 0.4683 0.5000 +}" +-dupMagentaTransfer="{ +0.0000 0.0005 0.0021 0.0047 0.0083 0.0130 0.0187 0.0255 +0.0333 0.0421 0.0520 0.0630 0.0749 0.0879 0.1020 0.1171 +0.1332 0.1504 0.1686 0.1878 0.2081 0.2294 0.2518 0.2752 +0.2997 0.3252 0.3517 0.3793 0.4079 0.4376 0.4683 0.5000 +}" +-dupYellowTransfer="{ +0.0000 0.0005 0.0021 0.0047 0.0083 0.0130 0.0187 0.0255 +0.0333 0.0421 0.0520 0.0630 0.0749 0.0879 0.1020 0.1171 +0.1332 0.1504 0.1686 0.1878 0.2081 0.2294 0.2518 0.2752 +0.2997 0.3252 0.3517 0.3793 0.4079 0.4376 0.4683 0.5000 +}" +-dupBeginPageCommand="< + 1b5b4b 0200 000f + 1b28 62 0100 01 + 1b28 63 0300 106110 + 1b28 64 0200 02d0 + 1b28 6c 0200 1470 + 1b28 67 0100 E5 +>" +-dupEndJobCommand="(\033\050b\001\000\000\033@)" +-dupEndPageCommand="(\014)" diff --git a/gs/lib/bjc610b8.upp b/gs/lib/bjc610b8.upp new file mode 100644 index 000000000..56c2feec2 --- /dev/null +++ b/gs/lib/bjc610b8.upp @@ -0,0 +1,44 @@ +-supModel="Canon BJC 610, 720x720DpI, high resolution paper, color, rendered" +-sDEVICE=uniprint +-dNOPAUSE +-dSAFER +-dupColorModel=/DeviceCMYKgenerate +-dupRendering=/FSCMYK32 +-dupOutputFormat=/Canon +-r720x720 +-dupMargins="{ 8.23 20.44 11.05 7.9 }" +-dupOutputComponentOrder="{ 3 2 1 0 }" +-dupBlackTransfer="{ +0.0000 0.0008 0.0033 0.0075 0.0133 0.0208 0.0300 0.0408 +0.0533 0.0674 0.0832 0.1007 0.1199 0.1407 0.1632 0.1873 +0.2131 0.2406 0.2697 0.3005 0.3330 0.3671 0.4029 0.4404 +0.4795 0.5203 0.5627 0.6069 0.6527 0.7001 0.7492 0.8000 +}" +-dupCyanTransfer="{ +0.0000 0.0005 0.0021 0.0047 0.0083 0.0130 0.0187 0.0255 +0.0333 0.0421 0.0520 0.0630 0.0749 0.0879 0.1020 0.1171 +0.1332 0.1504 0.1686 0.1878 0.2081 0.2294 0.2518 0.2752 +0.2997 0.3252 0.3517 0.3793 0.4079 0.4376 0.4683 0.5000 +}" +-dupMagentaTransfer="{ +0.0000 0.0005 0.0021 0.0047 0.0083 0.0130 0.0187 0.0255 +0.0333 0.0421 0.0520 0.0630 0.0749 0.0879 0.1020 0.1171 +0.1332 0.1504 0.1686 0.1878 0.2081 0.2294 0.2518 0.2752 +0.2997 0.3252 0.3517 0.3793 0.4079 0.4376 0.4683 0.5000 +}" +-dupYellowTransfer="{ +0.0000 0.0005 0.0021 0.0047 0.0083 0.0130 0.0187 0.0255 +0.0333 0.0421 0.0520 0.0630 0.0749 0.0879 0.1020 0.1171 +0.1332 0.1504 0.1686 0.1878 0.2081 0.2294 0.2518 0.2752 +0.2997 0.3252 0.3517 0.3793 0.4079 0.4376 0.4683 0.5000 +}" +-dupBeginPageCommand="< + 1b5b4b 0200 000f + 1b28 62 0100 01 + 1b28 63 0300 107110 + 1b28 64 0200 02d0 + 1b28 6c 0200 14a0 + 1b28 67 0100 E5 +>" +-dupEndJobCommand="(\033\050b\001\000\000\033@)" +-dupEndPageCommand="(\014)" diff --git a/gs/lib/bughunt.sh b/gs/lib/bughunt.sh new file mode 100755 index 000000000..f3292aac0 --- /dev/null +++ b/gs/lib/bughunt.sh @@ -0,0 +1,119 @@ +#! /bin/sh +# NB: If your sh does not support functions, then try +# /usr/local/bin/bash or /bin/ksh, if you have them. +# +# Hunt down compiler bugs that break gs. +# +# Usage: +# ./BUGHUNT "optimization level" +# e.g. +# ./BUGHUNT "-O2" +# +# Start with the code compiled at the lowest optimization level where +# it works, then run this script with suitable compiler options. The +# script will delete one object file at a time and rebuild gs at +# a higher optimization level. This should uncover the routine(s) +# that the compiler is generating bad code for. +# +# In order to make this test possible in unattended batch mode, +# ghostscript is run with command-line options that force creation of +# a bitmap file, rather than a window. +# +# The okay subdirectory should contain correct output for each +# of the tests. +# +# [06-Dec-1995] + +OBJECTS=" adler32.o deflate.o gconfig.o gdevabuf.o gdevbit.o \ + gdevbj10.o gdevcdj.o gdevdflt.o gdevdjet.o \ + gdevemap.o gdevm1.o gdevm16.o gdevm2.o gdevm24.o \ + gdevm32.o gdevm4.o gdevm8.o gdevmem.o gdevmpla.o \ + gdevmrop.o gdevpbm.o gdevpccm.o gdevpcl.o gdevpcx.o \ + gdevpipe.o gdevpng.o gdevprn.o gdevpsim.o gdevtfax.o \ + gdevtfnx.o gdevtifs.o gdevx.o gdevxalt.o gdevxini.o \ + gdevxxf.o gp_nofb.o gp_unifn.o gp_unifs.o gp_unix.o \ + gs.o gsalloc.o gsbitops.o gsbittab.o gschar.o \ + gschar0.o gscie.o gscolor.o gscolor1.o gscolor2.o \ + gscoord.o gscsepr.o gsdevice.o gsdevmem.o gsdparam.o \ + gsdps1.o gsfont.o gsfont0.o gshsb.o gsht.o gsht1.o \ + gshtscr.o gsimage.o gsimage0.o gsimage1.o gsimage2.o \ + gsimage3.o gsimpath.o gsinit.o gsiodev.o gsline.o \ + gsmain.o gsmatrix.o gsmemory.o gsmisc.o gspaint.o \ + gsparam.o gspath.o gspath1.o gspcolor.o gsrop.o \ + gsroptab.o gsstate.o gstype1.o gsutil.o gxacpath.o \ + gxbcache.o gxccache.o gxccman.o gxcht.o gxclbits.o \ + gxclfile.o gxclip2.o gxclist.o gxclpath.o gxclread.o \ + gxcmap.o gxcpath.o gxctable.o gxdcconv.o gxdither.o \ + gxdraw.o gxfill.o gxhint1.o gxhint2.o gxhint3.o \ + gxht.o gxpaint.o gxpath.o gxpath2.o gxpcmap.o \ + gxpcopy.o gxstroke.o ialloc.o ibnum.o iccinit0.o \ + iconfig.o idebug.o idict.o idparam.o igc.o igcref.o \ + igcstr.o iinit.o ilocate.o iname.o interp.o iparam.o \ + ireclaim.o isave.o iscan.o iscanbin.o iscannum.o \ + iscantab.o istack.o iutil.o iutil2.o jcapimin.o \ + jcapistd.o jccoefct.o jccolor.o jcdctmgr.o jchuff.o \ + jcinit.o jcmainct.o jcmarker.o jcmaster.o jcomapi.o \ + jcparam.o jcprepct.o jcsample.o jdapimin.o \ + jdapistd.o jdcoefct.o jdcolor.o jddctmgr.o jdhuff.o \ + jdinput.o jdmainct.o jdmarker.o jdmaster.o jdphuff.o \ + jdpostct.o jdsample.o jfdctint.o jidctint.o \ + jmemmgr.o jutils.o png.o pngerror.o pngio.o pngmem.o \ + pngtrans.o pngwrite.o pngwtran.o pngwutil.o sbcp.o \ + sbhc.o sbwbs.o scfd.o scfdtab.o scfe.o scfetab.o \ + sdctc.o sdctd.o sdcte.o seexec.o sfile.o sfilter1.o \ + sfilter2.o shc.o shcgen.o siscale.o sjpegc.o \ + sjpegd.o sjpege.o sjpegerr.o slzwc.o slzwd.o slzwe.o \ + smtf.o spdiff.o srld.o srle.o sstring.o stream.o \ + trees.o zarith.o zarray.o zbseq.o zchar.o zchar1.o \ + zchar2.o zcie.o zcolor.o zcolor1.o zcolor2.o \ + zcontrol.o zcrd.o zcsindex.o zcssepr.o zdevcal.o \ + zdevice.o zdevice2.o zdict.o zdps1.o zfbcp.o \ + zfdctc.o zfdctd.o zfdcte.o zfdecode.o zfile.o \ + zfileio.o zfilter.o zfilter2.o zfilterx.o zfname.o \ + zfont.o zfont0.o zfont1.o zfont2.o zfproc.o \ + zgeneric.o zgstate.o zhsb.o zht.o zht1.o zht2.o \ + zimage2.o ziodev.o ziodev2.o zmath.o zmatrix.o \ + zmedia2.o zmisc.o zmisc1.o zmisc2.o zpacked.o \ + zpaint.o zpath.o zpath1.o zpcolor.o zrelbit.o \ + zstack.o zstring.o zsysvm.o ztoken.o ztype.o \ + zupath.o zutil.o zvmem.o zvmem2.o zwppm.o" + +TESTS="exepsf tiger" + +dotest() +{ + # Create empty output file, so even if gs core dumps, + # we will have something to compare against. + touch $1.ljp + ./gs -sDEVICE=ljetplus -r75x75 -sOutputFile=$1.ljp \ + $1.ps quit.ps < /dev/null + if cmp $1.ljp okay/$1.ljp + then + /bin/true + else + echo COMPARISON FAILURE: $1.ljp okay/$1.ljp + echo "Remaking $f and gs with lower optimization" + /bin/rm -f $f ./gs + make $f gs + fi +} + +for f in $OBJECTS +do + echo ==================== $f ==================== + + date + + # Remove the old (good) object file and ghostscript + /bin/rm -f $f gs + + # Rebuild gs with optimization; only one object file should be + # recreated. + make gs CC="cc $1" + + # Now check this new version of gs with each test file. + for t in $TESTS + do + dotest $t + done +done diff --git a/gs/lib/caption.ps b/gs/lib/caption.ps new file mode 100644 index 000000000..c119f022c --- /dev/null +++ b/gs/lib/caption.ps @@ -0,0 +1,57 @@ +%! +% Copyright (C) 1995 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% Add a "caption" to the bottom of each page. +/captionsize 20 def +/caption + { /Helvetica //captionsize selectfont + (Printed by Aladdin's XXYYZZ) show + /Symbol //captionsize selectfont + (\324) show % trademarkserif + /Helvetica //captionsize selectfont + ( product) show + } bind def + +10 dict begin +gsave + initgraphics + clippath pathbbox + pop exch 36 add /by exch def + % We can't use stringwidth, so we have to show and measure. + gsave + 0 0 0 0 rectclip + 0 0 moveto caption currentpoint pop /bw exch def + grestore + add bw sub 2 div /bx exch def + % We don't have the font bbox available, so we guess. + /bh captionsize 1.05 mul def +grestore +/showcaption + { gsave + initgraphics + //bx 9 sub //by 9 sub //bw 18 add //bh 18 add + 1 setgray 4 copy rectfill 0 setgray 1.5 setlinewidth rectstroke + //bx //by moveto //caption exec + grestore + } bind def +<< /EndPage [ + /showcaption load /exec load + currentpagedevice /EndPage get /exec load + ] cvx +>> setpagedevice +end diff --git a/gs/lib/cbjc600.ppd b/gs/lib/cbjc600.ppd new file mode 100644 index 000000000..4b992d48a --- /dev/null +++ b/gs/lib/cbjc600.ppd @@ -0,0 +1,404 @@ +*PPD-Adobe: "4.1" +*% Adobe Systems PostScript(R) Printer Description File +*% Copyright 1995 Yves Arrouye for Aladdin Ghostscript with Level 2 PS. +*% All Rights Reserved. +*% This file may be distributed as part of GNU Ghostscript and/or Aladdin +*% Ghostscript, under the same terms and conditions as Ghostscript. +*% End of Copyright statement +*FormatVersion: "4.1" +*FileVersion: "1.0" +*LanguageVersion: English +*PCFileName: "CBJC600.PPD" +*Product: "(Canon Bubble Jet Color 600)" +*PSVersion: "(2010.351) 0" +*ModelName: "Canon Bubble Jet Color 600" +*NickName: "BJC-600" + +*% This file is not complete, and may lack some useful information... + +*% Note: the default transfer function should be set to Null if Ghostscript +*% exhibit a bug making magenta appear while printing in gray levels... +*% Note: if you print on A4 paper by default, change *Default values (the +*% default is Letter here). + +*% ==============Constraints ================= + +*UIConstraints: *BitsPerPixel None *ColorModel DeviceCMYK +*UIConstraints: *BitsPerPixel None *ColorModel DeviceRGB +*UIConstraints: *BitsPerPixel 16 *ColorModel DeviceRGB +*UIConstraints: *BitsPerPixel 16 *ColorModel DeviceGray +*UIConstraints: *BitsPerPixel 24 *ColorModel DeviceGray +*UIConstraints: *BitsPerPixel 32 *ColorModel DeviceRGB +*UIConstraints: *BitsPerPixel 32 *ColorModel DeviceGray + +*UIConstraints: *ColorModel DeviceCMYK *BitsPerPixel None +*UIConstraints: *ColorModel DeviceRGB *BitsPerPixel None +*UIConstraints: *ColorModel DeviceRGB *BitsPerPixel 16 +*UIConstraints: *ColorModel DeviceRGB *BitsPerPixel 32 +*UIConstraints: *ColorModel DeviceGray *BitsPerPixel 16 +*UIConstraints: *ColorModel DeviceGray *BitsPerPixel 24 +*UIConstraints: *ColorModel DeviceGray *BitsPerPixel 32 + +*% =========== Device Capabilities =============== + +*LanguageLevel: "2" +*Protocols: TBCP +*FreeVM: "2124600" +*ColorDevice: True +*DefaultColorSpace: CMYK +*FileSystem: True +*Throughput: "1" + +*Password: "()" + +*% ============Paper Size Information ============== + +*OpenUI *PageSize: PickOne +*OrderDependency: 30 AnySetup *PageSize +*DefaultPageSize: Letter +*PageSize A4: "1 dict dup /PageSize [595 842] put setpagedevice" +*PageSize A5: "1 dict dup /PageSize [421 595] put setpagedevice" +*PageSize A6: "1 dict dup /PageSize [297 421] put setpagedevice" +*PageSize A7: "1 dict dup /PageSize [210 297] put setpagedevice" +*PageSize A8: "1 dict dup /PageSize [148 210] put setpagedevice" +*PageSize A9: "1 dict dup /PageSize [105 148] put setpagedevice" +*PageSize A10: "1 dict dup /PageSize [74 105] put setpagedevice" +*PageSize B5: "1 dict dup /PageSize [501 709] put setpagedevice" +*PageSize Letter/US Letter: "1 dict dup /PageSize [612 792] put setpagedevice" +*CloseUI: *PageSize + +*OpenUI *PageRegion: PickOne +*OrderDependency: 40 AnySetup *PageRegion +*DefaultPageRegion: Letter +*PageRegion A4: "1 dict dup /PageSize [595 842] put setpagedevice" +*PageRegion A5: "1 dict dup /PageSize [421 595] put setpagedevice" +*PageRegion A6: "1 dict dup /PageSize [297 421] put setpagedevice" +*PageRegion A7: "1 dict dup /PageSize [210 297] put setpagedevice" +*PageRegion A8: "1 dict dup /PageSize [148 210] put setpagedevice" +*PageRegion A9: "1 dict dup /PageSize [105 148] put setpagedevice" +*PageRegion A10: "1 dict dup /PageSize [74 105] put setpagedevice" +*PageRegion B5: "1 dict dup /PageSize [501 709] put setpagedevice" +*PageRegion Letter/US Letter: "1 dict dup /PageSize [612 792] put setpagedevice" +*CloseUI: *PageRegion + +*DefaultImageableArea: Letter +*ImageableArea A4: "18.425196 27.096094 576.625183 833.496094" +*ImageableArea A5: "18.425196 27.096045 402.625183 586.496033" +*ImageableArea A6: "18.425196 27.096045 278.625183 412.496033" +*ImageableArea A7: "18.425196 27.096045 191.625198 288.496033" +*ImageableArea A8: "18.425196 27.096045 129.625198 201.496048" +*ImageableArea A9: "18.425196 27.096045 86.625198 139.496048" +*ImageableArea A10: "18.425196 27.096045 55.625195 96.496048" +*ImageableArea B5: "18.425196 27.096045 482.625183 700.496033" +*ImageableArea Letter/US Letter: "18.425196 27.096045 593.625183 783.496033" + +*?ImageableArea: " +save + /cvp {( ) cvs print ( ) print } bind def + /upperright {10000 mul floor 10000 div} bind def + /lowerleft {10000 mul ceiling 10000 div} bind def + newpath clippath pathbbox + 4 -2 roll exch 2 {lowerleft cvp} repeat + exch 2 {upperright cvp} repeat flush + restore +" +*End + +*PaperDimension A4: "595 842" +*PaperDimension A5: "421 595" +*PaperDimension A6: "297 421" +*PaperDimension A7: "210 297" +*PaperDimension A8: "148 210" +*PaperDimension A9: "105 148" +*PaperDimension A10: "74 105" +*PaperDimension B5: "501 709" +*PaperDimension Letter/US Letter: "612 792" + +*HWMargins: "9.637794495 27.042521 9.637794495 8.503937" + +*% =============Halftone Information =============== + +*ScreenFreq: "60.0" +*ScreenAngle: "45.0" + +*DefaultScreenProc: Dot +*ScreenProc Dot: " +{dup mul exch dup mul add 1.0 exch sub } +" +*End +*ScreenProc Line: "{ pop }" +*ScreenProc Ellipse: "{ dup 5 mul 8 div mul exch dup mul exch add sqrt 1 exch sub }" + +*DefaultTransfer: Normalized +*Transfer Normalized: "{mark +1.0 1.000 0.955 0.915 0.847 0.765 0.683 0.602 0.500 0.311 0.030 0.0 +counttomark dup 3 add -1 roll exch +2 sub mul dup floor cvi dup 3 1 roll sub exch dup +3 add index exch 2 add index dup 4 1 roll sub mul add +counttomark 1 add 1 roll cleartomark +} bind" +*End +*Transfer Null: "{ }" +*Transfer Null.Inverse: "{ 1 exch sub }" +*End + +*%==================Input Slot==================== + +*OpenUI *InputSlot/Media Source: PickOne +*OrderDependency: 20 AnySetup *InputSlot +*DefaultInputSlot: Feeder +*InputSlot Feeder/Paper Tray: "" +*CloseUI: *InputSlot + +*%=================Manual Feed==================== + +*OpenUI *ManualFeed/Manual Feed: Boolean +*OrderDependency: 20 AnySetup *ManualFeed +*DefaultManualFeed: False +*ManualFeed True/True: "1 dict dup /ManualFeed true put setpagedevice" +*ManualFeed False/False: "1 dict dup /ManualFeed false put setpagedevice" +*?ManualFeed: " + save + currentpagedevice /ManualFeed get + {(True)}{(False)}ifelse = flush + restore" +*End + +*CloseUI: *ManualFeed + +*%===================Resolution==================== + +*OpenUI *Resolution/Resolution: PickOne +*OrderDependency: 10 AnySetup *Resolution +*DefaultResolution: 360x360dpi +*Resolution 90x90dpi/90dpi: " + 1 dict dup /HWResolution [ 90 90 ] + put setpagedevice" +*End + +*Resolution 180x180dpi/180dpi: " + 1 dict dup /HWResolution [ 180 180 ] + put setpagedevice" +*End + +*Resolution 360x360dpi/360dpi: " + 1 dict dup /HWResolution [ 360 360 ] + put setpagedevice" +*End + +*?Resolution: " + save + currentpagedevice /HWResolution get dup + 0 get cvi 10 string cvs print + (x) print + 0 get cvi 10 string print + (dpi) = flush + restore" +*End + +*CloseUI: *Resolution + +*%===================Output Depth==================== + +*OpenUI *BitsPerPixel/Print Depth: PickOne +*OrderDependency: 30 AnySetup *BitsPerPixel +*DefaultBitsPerPixel: 24 +*BitsPerPixel None/1bpp: " + 1 dict dup /BitsPerPixel 1 put + setpagedevice" +*End + +*BitsPerPixel 8/8bpp: " + 1 dict dup /BitsPerPixel 8 put + setpagedevice" +*End + +*BitsPerPixel 16/16bpp: " + 1 dict dup /BitsPerPixel 16 put + setpagedevice" +*End + +*BitsPerPixel 24/24bpp: " + 1 dict dup /BitsPerPixel 24 put + setpagedevice" +*End + +*BitsPerPixel 32/32bpp: " + 1 dict dup /BitsPerPixel 32 put + setpagedevice" +*End + +*?BitsPerPixel: " + save + currentpagedevice /BitsPerPixel get dup 1 eq { pop (None) } if = flush + restore" +*End + +*CloseUI: *BitsPerPixel + +*%=================Media Type============================ + +*OpenUI *MediaType/Media Type: PickOne +*OrderDependency: 50 AnySetup *MediaType +*DefaultMediaType: PlainPaper +*MediaType PlainPaper/Plain Paper: " + 1 dict dup /MediaType (PlainPaper) put setpagedevice" +*End + +*MediaType CoatedPaper/Coated Paper: " + 1 dict dup /MediaType (CoatedPaper) put setpagedevice" +*End + +*MediaType TransparencyFilm/Transparency Film: " + 1 dict dup /MediaType (TransparencyFilm) put setpagedevice" +*End + +*MediaType Envelope/Envelope: " + 1 dict dup /MediaType (Envelope) put setpagedevice" +*End + +*MediaType Card/Card: " + 1 dict dup /MediaType (Card) put setpagedevice" +*End + +*MediaType Other/Other: " + 1 dict dup /MediaType (Other) put setpagedevice" +*End + +*?MediaType: " + save + currentpagedevice /MediaType get + dup null eq {pop (Unknown)} if = flush + restore " +*End + +*CloseUI: *MediaType + +*%===================Printing Quality==================== + +*OpenUI *OutputMode/Print Quality: PickOne +*OrderDependency: 50 AnySetup *OuputMode +*DefaultOutputMode: Normal +*OutputMode Draft/Draft: " + 1 dict dup /PrintQuality (Draft) put setpagedevice" +*End + +*OutputMode Normal/Normal: " + 1 dict dup /PrintQuality (Normal) put setpagedevice" +*End + +*OutputMode High/High: " + 1 dict dup /PrintQuality (High) put setpagedevice" +*End + +*?OutputMode: " + save + currentpagedevice /PrintQuality get + dup null eq {pop (Unknown)} if = flush + restore " +*End + +*CloseUI: *OutputMode + +*%===================Color/Gray Printing==================== + +*OpenUI *ColorModel/Color Processing: PickOne +*OrderDependency: 20 AnySetup *ColorModel +*DefaultColorModel: DeviceCMYK +*ColorModel DeviceGray/Gray: " + 1 dict dup /ProcessColorModel /DeviceGray + put setpagedevice" +*End + +*ColorModel DeviceRGB/RGB: " + 1 dict dup /ProcessColorModel /DeviceRGB + put setpagedevice" +*End + +*ColorModel DeviceCMYK/CMYK: " + 1 dict dup /ProcessColorModel /DeviceCMYK + put setpagedevice" +*End + +*?ColorModel: " + save + currentpagedevice /ProcessColorModel get = flush + restore " +*End + +*CloseUI: *ColorModel + +*%===================Media Weight/Thick Media==================== + +*OpenUI *ThickMedia/Thick Media: PickOne +*OrderDependency: 30 AnySetup *ThickMedia +*Default ThickMedia: Thin +*ThickMedia Thin/No: " + 1 dict dup /MediaWeight 80 + put setpagedevice" +*End + +*ThickMedia Thick/Yes: " + 1 dict dup /ThickMedia 120 + put setpagedevice" +*End + +*?ThickMedia: " + save + currentpagedevice /MediaWeight get 105 gt { (Thick) } { (Thin) } ifelse + = flush + restore " +*End + +*CloseUI: *ThickMedia + +*%===================PrintColors==================== + +*OpenUI *PrintColors/Print Colors: PickOne +*OrderDependency: 20 AnySetup *PrintColors +*DefaultPrintColors: "15" +*PrintColors 0/None: "1 dict dup /PrintColors 0 put setpagedevice" +*End + +*PrintColors 1/Cyan: "1 dict dup /PrintColors 1 put setpagedevice" +*End + +*PrintColors 2/Magenta: "1 dict dup /PrintColors 2 put setpagedevice" +*End + +*PrintColors 4/Yellow: "1 dict dup /PrintColors 4 put setpagedevice" +*End + +*PrintColors 8/Black: "1 dict dup /PrintColors 8 put setpagedevice" +*End + +*PrintColors 15/All: "1 dict dup /PrintColors 15 put setpagedevice" +*End + + +*CloseUI *PrintColors + +*%===================Monochrome Printing==================== + +*OpenUI *MonochromePrint/Monochrome Print: Boolean +*OrderDependency: 50 AnySetup *MonochromePrint +*DefaultMonochromePrint: False +*MonochromePrint True/Yes: " + 1 dict dup /MonochromePrint true + put setpagedevice" +*End + +*MonochromePrint False/No: " + 1 dict dup /MonochromePrint false + put setpagedevice" +*End + +*?MonochromePrint: " + save + currentpagedevice /MonochromePrint get + {(True)}{(False)}ifelse = flush + restore" +*End + +*CloseUI: *MonochromePrint + diff --git a/gs/lib/cbjc800.ppd b/gs/lib/cbjc800.ppd new file mode 100644 index 000000000..a36d5e62d --- /dev/null +++ b/gs/lib/cbjc800.ppd @@ -0,0 +1,389 @@ +*PPD-Adobe: "4.1" +*% Adobe Systems PostScript(R) Printer Description File +*% Copyright 1995 Yves Arrouye for Aladdin Ghostscript with Level 2 PS. +*% All Rights Reserved. +*% This file may be distributed as part of GNU Ghostscript and/or Aladdin +*% Ghostscript, under the same terms and conditions as Ghostscript. +*% End of Copyright statement +*FormatVersion: "4.1" +*FileVersion: "1.0" +*LanguageVersion: English +*PCFileName: "CBJC800.PPD" +*Product: "(Canon Bubble Jet Color 800)" +*PSVersion: "(2010.351) 0" +*ModelName: "Canon Bubble Jet Color 800" +*NickName: "BJC-800" + +*% This file is not complete, and may lack some useful information... + +*% Note: the default transfer function should be set to Null if Ghostscript +*% exhibit a bug making magenta appear while printing in gray levels... +*% Note: if you print on A4 paper by default, change *Default values (the +*% default is Letter here). + +*% ==============Constraints ================= + +*UIConstraints: *BitsPerPixel None *ColorModel DeviceCMYK +*UIConstraints: *BitsPerPixel None *ColorModel DeviceRGB +*UIConstraints: *BitsPerPixel 16 *ColorModel DeviceRGB +*UIConstraints: *BitsPerPixel 16 *ColorModel DeviceGray +*UIConstraints: *BitsPerPixel 24 *ColorModel DeviceGray +*UIConstraints: *BitsPerPixel 32 *ColorModel DeviceRGB +*UIConstraints: *BitsPerPixel 32 *ColorModel DeviceGray + +*UIConstraints: *ColorModel DeviceCMYK *BitsPerPixel None +*UIConstraints: *ColorModel DeviceRGB *BitsPerPixel None +*UIConstraints: *ColorModel DeviceRGB *BitsPerPixel 16 +*UIConstraints: *ColorModel DeviceRGB *BitsPerPixel 32 +*UIConstraints: *ColorModel DeviceGray *BitsPerPixel 16 +*UIConstraints: *ColorModel DeviceGray *BitsPerPixel 24 +*UIConstraints: *ColorModel DeviceGray *BitsPerPixel 32 + +*% =========== Device Capabilities =============== + +*LanguageLevel: "2" +*Protocols: TBCP +*FreeVM: "2124600" +*ColorDevice: True +*DefaultColorSpace: CMYK +*FileSystem: True +*Throughput: "1" + +*Password: "()" + +*% ============Paper Size Information ============== + +*OpenUI *PageSize: PickOne +*OrderDependency: 30 AnySetup *PageSize +*DefaultPageSize: Letter +*PageSize A4: "1 dict dup /PageSize [595 842] put setpagedevice" +*PageSize A5: "1 dict dup /PageSize [421 595] put setpagedevice" +*PageSize A6: "1 dict dup /PageSize [297 421] put setpagedevice" +*PageSize A7: "1 dict dup /PageSize [210 297] put setpagedevice" +*PageSize A8: "1 dict dup /PageSize [148 210] put setpagedevice" +*PageSize A9: "1 dict dup /PageSize [105 148] put setpagedevice" +*PageSize A10: "1 dict dup /PageSize [74 105] put setpagedevice" +*PageSize B5: "1 dict dup /PageSize [501 709] put setpagedevice" +*PageSize Letter/US Letter: "1 dict dup /PageSize [612 792] put setpagedevice" +*PageSize 11x17/US 11x17: "1 dict dup /PageSize [792 1224] put setpagedevice" +*PageSize Ledger/US Ledger: "1 dict dup /PageSize [1224 792] put setpagedevice" +*PageSize Legal/US Legal: "1 dict dup /PageSize [612 1008] put setpagedevice" +*CloseUI: *PageSize + +*OpenUI *PageRegion: PickOne +*OrderDependency: 40 AnySetup *PageRegion +*DefaultPageRegion: Letter +*PageRegion A4: "1 dict dup /PageSize [595 842] put setpagedevice" +*PageRegion A5: "1 dict dup /PageSize [421 595] put setpagedevice" +*PageRegion A6: "1 dict dup /PageSize [297 421] put setpagedevice" +*PageRegion A7: "1 dict dup /PageSize [210 297] put setpagedevice" +*PageRegion A8: "1 dict dup /PageSize [148 210] put setpagedevice" +*PageRegion A9: "1 dict dup /PageSize [105 148] put setpagedevice" +*PageRegion A10: "1 dict dup /PageSize [74 105] put setpagedevice" +*PageRegion B5: "1 dict dup /PageSize [501 709] put setpagedevice" +*PageRegion Letter/US Letter: "1 dict dup /PageSize [612 792] put setpagedevice" +*PageRegion 11x17/US 11x17: "1 dict dup /PageSize [792 1224] put setpagedevice" +*PageRegion Ledger/US Ledger: "1 dict dup /PageSize [1224 792] put setpagedevice" +*PageRegion Legal/US Legal: "1 dict dup /PageSize [612 1008] put setpagedevice" +*CloseUI: *PageRegion + +*DefaultImageableArea: Letter +*ImageableArea A3: "9.637793 27.096094 832.437805 1181.496094" +*ImageableArea A4: "18.425196 27.096094 576.625183 833.496094" +*ImageableArea A5: "18.425196 27.096045 402.625183 586.496033" +*ImageableArea A6: "18.425196 27.096045 278.625183 412.496033" +*ImageableArea A7: "18.425196 27.096045 191.625198 288.496033" +*ImageableArea A8: "18.425196 27.096045 129.625198 201.496048" +*ImageableArea A9: "18.425196 27.096045 86.625198 139.496048" +*ImageableArea A10: "18.425196 27.096045 55.625195 96.496048" +*ImageableArea B5: "18.425196 27.096045 482.625183 700.496033" +*ImageableArea Letter/US Letter: "18.425196 27.096045 593.625183 783.496033" +*ImageableArea 11x17/US 11x17: "9.637793 27.096094 782.437805 1215.496094" +*ImageableArea Ledger/US Ledger: "9.637793 27.096045 1214.437744 783.496033" +*ImageableArea Legal/US Legal: "9.637793 27.096094 602.437805 999.496094" + +*?ImageableArea: " +save + /cvp {( ) cvs print ( ) print } bind def + /upperright {10000 mul floor 10000 div} bind def + /lowerleft {10000 mul ceiling 10000 div} bind def + newpath clippath pathbbox + 4 -2 roll exch 2 {lowerleft cvp} repeat + exch 2 {upperright cvp} repeat flush + restore +" +*End + +*PaperDimension A4: "595 842" +*PaperDimension A5: "421 595" +*PaperDimension A6: "297 421" +*PaperDimension A7: "210 297" +*PaperDimension A8: "148 210" +*PaperDimension A9: "105 148" +*PaperDimension A10: "74 105" +*PaperDimension B5: "501 709" +*PaperDimension Letter/US Letter: "612 792" +*PaperDimension 11x17/US 11x17: "792 1224" +*PaperDimension Ledger/US Ledger: "1224 792" +*PaperDimension Legal/US Legal: "612 1008" + +*HWMargins: "9.637794495 19.842518 9.637794495 8.503937" + +*% =============Halftone Information =============== + +*ScreenFreq: "60.0" +*ScreenAngle: "45.0" + +*DefaultScreenProc: Dot +*ScreenProc Dot: " +{dup mul exch dup mul add 1.0 exch sub } +" +*End +*ScreenProc Line: "{ pop }" +*ScreenProc Ellipse: "{ dup 5 mul 8 div mul exch dup mul exch add sqrt 1 exch sub }" + +*DefaultTransfer: Normalized +*Transfer Normalized: "{mark +1.0 1.000 0.955 0.915 0.847 0.765 0.683 0.602 0.500 0.311 0.030 0.0 +counttomark dup 3 add -1 roll exch +2 sub mul dup floor cvi dup 3 1 roll sub exch dup +3 add index exch 2 add index dup 4 1 roll sub mul add +counttomark 1 add 1 roll cleartomark +} bind" +*End +*Transfer Null: "{ }" +*Transfer Null.Inverse: "{ 1 exch sub }" +*End + +*%==================Input Slot==================== + +*OpenUI *InputSlot/Media Source: PickOne +*OrderDependency: 20 AnySetup *InputSlot +*DefaultInputSlot: Feeder +*InputSlot Feeder/Paper Tray: "" +*CloseUI: *InputSlot + +*%=================Manual Feed==================== + +*OpenUI *ManualFeed/Manual Feed: Boolean +*OrderDependency: 20 AnySetup *ManualFeed +*DefaultManualFeed: False +*ManualFeed True/True: "1 dict dup /ManualFeed true put setpagedevice" +*ManualFeed False/False: "1 dict dup /ManualFeed false put setpagedevice" +*?ManualFeed: " + save + currentpagedevice /ManualFeed get + {(True)}{(False)}ifelse = flush + restore" +*End + +*CloseUI: *ManualFeed + +*%===================Resolution==================== + +*OpenUI *Resolution/Resolution: PickOne +*OrderDependency: 10 AnySetup *Resolution +*DefaultResolution: 360x360dpi +*Resolution 90x90dpi/90dpi: " + 1 dict dup /HWResolution [ 90 90 ] + put setpagedevice" +*End + +*Resolution 180x180dpi/180dpi: " + 1 dict dup /HWResolution [ 180 180 ] + put setpagedevice" +*End + +*Resolution 360x360dpi/360dpi: " + 1 dict dup /HWResolution [ 360 360 ] + put setpagedevice" +*End + +*?Resolution: " + save + currentpagedevice /HWResolution get dup + 0 get cvi 10 string cvs print + (x) print + 0 get cvi 10 string print + (dpi) = flush + restore" +*End + +*CloseUI: *Resolution + +*%===================Output Depth==================== + +*OpenUI *BitsPerPixel/Print Depth: PickOne +*OrderDependency: 30 AnySetup *BitsPerPixel +*DefaultBitsPerPixel: 24 +*BitsPerPixel None/1bpp: " + 1 dict dup /BitsPerPixel 1 put + setpagedevice" +*End + +*BitsPerPixel 8/8bpp: " + 1 dict dup /BitsPerPixel 8 put + setpagedevice" +*End + +*BitsPerPixel 16/16bpp: " + 1 dict dup /BitsPerPixel 16 put + setpagedevice" +*End + +*BitsPerPixel 24/24bpp: " + 1 dict dup /BitsPerPixel 24 put + setpagedevice" +*End + +*BitsPerPixel 32/32bpp: " + 1 dict dup /BitsPerPixel 32 put + setpagedevice" +*End + +*?BitsPerPixel: " + save + currentpagedevice /BitsPerPixel get dup 1 eq { pop (None) } if = flush + restore" +*End + +*CloseUI: *BitsPerPixel + +*%=================Media Type============================ + +*OpenUI *MediaType/Media Type: PickOne +*OrderDependency: 50 AnySetup *MediaType +*DefaultMediaType: PlainPaper +*MediaType PlainPaper/Plain Paper: " + 1 dict dup /MediaType (PlainPaper) put setpagedevice" +*End + +*MediaType CoatedPaper/Coated Paper: " + 1 dict dup /MediaType (CoatedPaper) put setpagedevice" +*End + +*MediaType TransparencyFilm/Transparency Film: " + 1 dict dup /MediaType (TransparencyFilm) put setpagedevice" +*End + +*MediaType Envelope/Envelope: " + 1 dict dup /MediaType (Envelope) put setpagedevice" +*End + +*MediaType Card/Card: " + 1 dict dup /MediaType (Card) put setpagedevice" +*End + +*MediaType Other/Other: " + 1 dict dup /MediaType (Other) put setpagedevice" +*End + +*?MediaType: " + save + currentpagedevice /MediaType get + dup null eq {pop (Unknown)} if = flush + restore " +*End + +*CloseUI: *MediaType + +*%===================Printing Quality==================== + +*OpenUI *OutputMode/Print Quality: PickOne +*OrderDependency: 10 AnySetup *OuputMode +*DefaultOutputMode: Normal +*OutputMode Draft/Draft: " + 1 dict dup /PrintQuality (Draft) put setpagedevice" +*End + +*OutputMode Low/Low: " + 1 dict dup /PrintQuality (Low) put setpagedevice" +*End + +*OutputMode Normal/Normal: " + 1 dict dup /PrintQuality (Normal) put setpagedevice" +*End + +*OutputMode High/High: " + 1 dict dup /PrintQuality (High) put setpagedevice" +*End + +*CloseUI: *OutputMode + +*%===================Color/Gray Printing==================== + +*OpenUI *ColorModel/Color Processing: PickOne +*OrderDependency: 20 AnySetup *ColorModel +*DefaultColorModel: DeviceCMYK +*ColorModel DeviceGray/Gray: " + 1 dict dup /ProcessColorModel /DeviceGray + put setpagedevice" +*End + +*ColorModel DeviceRGB/RGB: " + 1 dict dup /ProcessColorModel /DeviceRGB + put setpagedevice" +*End + +*ColorModel DeviceCMYK/CMYK: " + 1 dict dup /ProcessColorModel /DeviceCMYK + put setpagedevice" +*End + +*?ColorModel: " + save + currentpagedevice /ProcessColorModel get = flush + restore " +*End + +*CloseUI: *ColorModel + +*%===================Media Weight/Thick Media==================== + +*OpenUI *ThickMedia/Thick Media: PickOne +*OrderDependency: 30 AnySetup *ThickMedia +*Default ThickMedia: Thin +*ThickMedia Thin/No: " + 1 dict dup /MediaWeight 80 + put setpagedevice" +*End + +*ThickMedia Thick/Yes: " + 1 dict dup /ThickMedia 120 + put setpagedevice" +*End + +*?ThickMedia: " + save + currentpagedevice /MediaWeight get 105 gt { (Thick) } { (Thin) } ifelse + = flush + restore " +*End + +*CloseUI: *ThickMedia + +*%===================PrintColors==================== + +*OpenUI *PrintColors/Print Colors: PickOne +*OrderDependency: 20 AnySetup *PrintColors +*DefaultPrintColors: "15" +*PrintColors 0/None: "1 dict dup /PrintColors 0 put setpagedevice" +*End + +*PrintColors 1/Cyan: "1 dict dup /PrintColors 1 put setpagedevice" +*End + +*PrintColors 2/Magenta: "1 dict dup /PrintColors 2 put setpagedevice" +*End + +*PrintColors 4/Yellow: "1 dict dup /PrintColors 4 put setpagedevice" +*End + +*PrintColors 8/Black: "1 dict dup /PrintColors 8 put setpagedevice" +*End + +*PrintColors 15/All: "1 dict dup /PrintColors 15 put setpagedevice" +*End + + +*CloseUI *PrintColors diff --git a/gs/lib/cdj550.upp b/gs/lib/cdj550.upp new file mode 100644 index 000000000..9e2a5422d --- /dev/null +++ b/gs/lib/cdj550.upp @@ -0,0 +1,48 @@ +-supModel="HP Deskjet 550c, 300x300DpI, Gamma=2" +-sDEVICE=uniprint +-dNOPAUSE +-dSAFER +-dupColorModel=/DeviceCMYKgenerate +-dupRendering=/FSCMYK32 +-dupOutputFormat=/Pcl +-r300x300 +-dupMargins="{ 12.0 36.0 12.0 12.0}" +-dupBlackTransfer="{ + 0.0000 0.0010 0.0042 0.0094 0.0166 0.0260 0.0375 0.0510 + 0.0666 0.0843 0.1041 0.1259 0.1498 0.1758 0.2039 0.2341 + 0.2663 0.3007 0.3371 0.3756 0.4162 0.4589 0.5036 0.5505 + 0.5994 0.6504 0.7034 0.7586 0.8158 0.8751 0.9365 1.0000 +}" +-dupCyanTransfer="{ + 0.0000 0.0010 0.0042 0.0094 0.0166 0.0260 0.0375 0.0510 + 0.0666 0.0843 0.1041 0.1259 0.1498 0.1758 0.2039 0.2341 + 0.2663 0.3007 0.3371 0.3756 0.4162 0.4589 0.5036 0.5505 + 0.5994 0.6504 0.7034 0.7586 0.8158 0.8751 0.9365 1.0000 +}" +-dupMagentaTransfer="{ + 0.0000 0.0010 0.0042 0.0094 0.0166 0.0260 0.0375 0.0510 + 0.0666 0.0843 0.1041 0.1259 0.1498 0.1758 0.2039 0.2341 + 0.2663 0.3007 0.3371 0.3756 0.4162 0.4589 0.5036 0.5505 + 0.5994 0.6504 0.7034 0.7586 0.8158 0.8751 0.9365 1.0000 +}" +-dupYellowTransfer="{ + 0.0000 0.0010 0.0042 0.0094 0.0166 0.0260 0.0375 0.0510 + 0.0666 0.0843 0.1041 0.1259 0.1498 0.1758 0.2039 0.2341 + 0.2663 0.3007 0.3371 0.3756 0.4162 0.4589 0.5036 0.5505 + 0.5994 0.6504 0.7034 0.7586 0.8158 0.8751 0.9365 1.0000 +}" +-dupBeginPageCommand="< + 1b2a726243 + 1b2a7433303052 + 1b266c33616f6c45 + 1b2a6f31643251 + 1b2a703059 + 1b2a72732d34753041 + 1b2a62326d +>" +-dupAdjustPageWidthCommand +-dupEndPageCommand="(0M\033*rbC\033E\033&l0H)" +-dupAbortCommand="(0M\033*rbC\033E\15\12\12\12\12 Printout-Aborted\15\033&l0H)" +-dupYMoveCommand="(%dy\0)" +-dupWriteComponentCommands="{ (%dv\0) (%dv\0) (%dv\0) (%dw\0) }" + diff --git a/gs/lib/cheq.ps b/gs/lib/cheq.ps new file mode 100644 index 000000000..2e98d0edd --- /dev/null +++ b/gs/lib/cheq.ps @@ -0,0 +1,945 @@ +%!PS-AdobeFont-1.0: Cheq 001.000 +%%CreationDate: Wed May 24 10:41:05 1989 +%%VMusage: 23317 29750 +%% Adobe is licensing this font software "Cheq" to you royalty-free for your +%% use and not for sale to others. This font software is provided as is and +%% Adobe disclaims all warranties, including merchantability and fitness for +%% a particular purpose. Any and all copies of this software must contain +%% this notice intact. Design (D) 1989 John S. Renner, Adobe Systems, +%% Inc. +11 dict begin +/FontInfo 10 dict dup begin +/version (001.000) readonly def +/Notice (Copyright (c) 1989 Adobe Systems Incorporated. All rights reserved.) readonly def +/Copyright ( Adobe is licensing this font software "Cheq" to you + royalty-free for your use and not for sale to others. This + font software is provided as is and Adobe disclaims all + warranties, including merchantability and fitness for a + particular purpose. + Any and all copies of this software must contain this notice + intact. + + Design (D) 1989 John S. Renner, Adobe Systems, Inc. + ) readonly def +/FullName (Cheq) readonly def +/FamilyName (Cheq) readonly def +/Weight (Medium) readonly def +/ItalicAngle 0 def +/isFixedPitch true def +/UnderlinePosition -100 def +/UnderlineThickness 50 def +end readonly def +/FontName /Cheq def +/Encoding 256 array +0 1 255 {1 index exch /.notdef put} for + %% Encoding below refers to Macintosh keyboard. + %% You may want to re-encode for your needs. + %% some entries are an attempt to accommodate + %% the German/Russian spelling mnemonics, + %% except for "B" which remains for Bishop, + %% and not for Bauer (the pawn). +dup 120 /BSquare put % x +dup 32 /space put % space +dup 66 /BBishop put % shift-b +dup 68 /BQueen put % shift-d +dup 75 /BKing put % shift-k +dup 76 /BBishop put % shift-l +dup 78 /BKnight put % shift-n +dup 80 /BPawn put % shift-p +dup 81 /BQueen put % shift-q +dup 82 /BRook put % shift-r +dup 83 /BKnight put % shift-s +dup 84 /BRook put % shift-t +dup 98 /WBishop put % b +dup 100 /WQueen put % d +dup 107 /WKing put % k +dup 108 /WBishop put % l +dup 110 /WKnight put % n +dup 112 /WPawn put % p +dup 113 /WQueen put % q +dup 114 /WRook put % r +dup 115 /WKnight put % s +dup 116 /WRook put % t +dup 245 /BBishopOnBlack put % shift-option-b +dup 235 /BQueenOnBlack put % shift-option-d +dup 240 /BKingOnBlack put % shift-option-k +dup 241 /BBishopOnBlack put % shift-option-l +dup 246 /BKnightOnBlack put % shift-option-n +dup 184 /BPawnOnBlack put % shift-option-p +dup 206 /BQueenOnBlack put % shift-option-q +dup 229 /BRookOnBlack put % shift-option-r +dup 234 /BKnightOnBlack put % shift-option-s +dup 230 /BRookOnBlack put % shift-option-t +dup 186 /WBishopOnBlack put % option-b +dup 182 /WQueenOnBlack put % option-d +dup 251 /WKingOnBlack put % option-k +dup 194 /WBishopOnBlack put % option-l +dup 181 /WKnightOnBlack put % option-m +dup 185 /WPawnOnBlack put % option-p +dup 207 /WQueenOnBlack put % option-q +dup 168 /WRookOnBlack put % option-r +dup 167 /WKnightOnBlack put % option-s +dup 160 /WRookOnBlack put % option-t +dup 47 /left put % slash +dup 92 /right put % backslash +dup 95 /top put % underscore +dup 45 /bottom put % hyphen/minus +def +/PaintType 0 def +/FontType 1 def +/FontMatrix [0.001 0 0 0.001 0 0] readonly def +/UniqueID 23368 def +/FontBBox{-50 -150 1050 950}readonly def +currentdict end +currentfile eexec +06ba7b33fcf5ae0f0b258ced9b9688e8a87f93db8efdacd17ec2401f2e7dac03 +bf5515b9e42d78a8037b743d280529fc7630d62bd4c75492c78fd28b2c2aba67 +9cc93d471b097ea30e29f7c89735dd88b4c3e9cb32e14ef50432a6ab37870a14 +af81e471af496fa0e292e1e8168461acf6191017048deb62dd5fd7c784ba88aa +a921563b3143218981a38441910687a3202a5135e58ce2ecdf9c2d521c6df45b +aab245f99427574c148904e2a60104e97e6b05bfd9be9a086246a797a03dab25 +948bf8e7996f70ffd6471eef9faeada641e245d63c4964a38500b4754836131f +86fc61b1de2e0b53ad441b1446fedcd2c533d44c69631a545c98d4c552e5f0b2 +27b40aa0443f7f88e1d6e5bd206ed737fffbe94e8bf001e3481cca5a45735979 +e41ea918a7c0ca5e26ab946df29d27b5ec2671d8e0d7d31b114c29e48ccd3e8d +7bc69903aeb804fc25aa2dda700de6ede9fc025f0db1aa478b53fa21ed455ec1 +98c7a20020a077a67b743f563cc4c4e59c2d8253bc8c3ea62d4a870f53b2515c +8b63b857664ab5f0ad71eb89d34decf825e81c10c3a7e676ddddd182cd6ff6da +631d2051ccb078bea7b2ffab7dc23ca08b337ecc454a8f743a71512149244b00 +72670c8978396cefa735113500de6cec50ab91084340db0ba24a01672dc3a3a5 +e860df42ef02350778cb8e77b5533227aa2f79cbed414f760d92cd071fb5db1b +669ef0196c6e95a530c8112a8a3ac716fb913a8a1332a590b46d2e267b97b1be +0e0ba7e4e8c90f1d37b8c1836fbdc93121c5758a31d3ef4650adc41f253ba07a +ab0dc45d90e8936672b1a47307903dbcbf8e15b70c862d25c57c6e2727f6674b +c47ff5eae01e0fe7d182742ac456f986d0eb460f4f7fc2693e37899a04b3684e +fd57e9b235b339017c36b1ef22f9659a0c7743e663e831be7faa602cff221701 +85b13653ad5269a88da74ed803beb08bc40f0bfcfd7cbc49531756b41171c22d +aae8ff9a454f9d68df7f4b23409634346d8e26ac2109391398ed37705e2e063a +065a871b78b2b0d4c74b6e4e42877a4450b1974474dc19437e9e1d8a6ff2a374 +0e399857e4f67056577a19f7e26542fae9a75f1e07ed1869c504625d701fdbea +392b4b2e83ea3c179991f5dded833a74df4d277fdd119f69e8209be9394473f3 +6d6383a762a518d04812f29ec4bb71f451882e9f89a52114215b31b225db3da5 +eb453e7f4f40861963d6412855582128dcd1677d94df95442aba41d3cdf32f0c +f1a6eace61e491f64152a57410902642145aca0104350bd8b19441072da5e142 +758ef9a1f6c6e0fe47335113843443a07c68606510af206677e764dc0e319ff0 +93d0fef01274205b370422182765a40ac3d23f4c326a732282c455a0eb737ac4 +11673164b7b35e42cb4be5dd4be49958b2c61a5bcc5a332b917d5525c0680a14 +b7c700339112eb47015e80cadfd5a6484af9201f57f6e15b70c0964ea5365173 +ba78aec0d5a7414a4636090b9eef9d71fa424c47fb191bfaeea8d1d29beebbe2 +fc78ea4a1edb5c325bba25851e72146eab86a69e57b6a4a31bc7a4cad9f8910d +3394c3a92e5189b3447df2fc1a5add98fb8e4ad616685beb6778fe7d444b5ef3 +f4847419c0013e6689e40860aaf46d77f172b86be22630674ac7d37354098a7b +08add07f1c48dc3dfd56716c3e126f674690d504fc771beaf5e12e9a32f2a17b +1f753b50c16bb45e2db812bb8e179f1641147da41ac30d08238141315c211f57 +fe8f9c86a087208ebd350f3d1381187a19850d4c2dc0428889c7776047f69574 +4ac1f676453ea360e0d5b18fdf2b2ac8f9e72369e221f447f0eb55bc80460149 +9e5e501c359e1656ab1bc4699569566ba8bee1463746ca84c51ce83cc98adcde +48f109d71339d0293ed3104a84287b15c3fc4ae425754f5fd66bec0c9f6e27b6 +ea6dbfdbdbdb3c3aaf935969d635a71a61fb4bd8a8384571c4671c98da20d1fd +accbcdcdd1cca1f44bdd6ea4827ebcf41ea97147921d6894eff290d1bda74208 +38e9c0453e9f9e6d522dcc5667c1b44f57d60be5239c5e58f4b1e16672608a3f +68f1b7c3d11f609ed4fe10ab359a5b5a7a9da15b44273fd38c303dad6832ace0 +81e7e85a836e4bd7e9f9149276be282442ae3ce0fa74d29a9b4e56a99aa06f2a +be39c7f4755745f07d29f9a4522a1a43f11f60c31538ea1a37ca793376ecdb2f +9dee32abb3fb035ad68e1b24d97ac3004508b514f33b86b6e19ab578c1a891ec +6a2e2f9cb6f784f2c1372978706102bd273bb721cddb3fa2659ff4485119cc94 +2e140051600bb66d0ae6db27205fc9c9e1c6f07a4eb6cda7adec4d86bfbf0748 +45dd09d9178745f790ef5f5679840deff1cc38810e49066d41743db0b6a087bc +93307d009dd566c4cc13ed3b634b7f60fd6a7e9fb2774eda2b106d2960dfe979 +c76d0fe4689ce8f4490c76c1064861624d909d678379f9602c2b9df3b0f9abcf +dab614aec38e22bf064950094d9201c6afa52cc5fc7779b279ef41231546f13d +f1ef498eae5c445f7691f96ebabef21e7f2d1ee2eedd9846c20b067a73aa2159 +a116bd056e733b00a847a9dcc82ce288f3037b76be87412ab5c0f86dc3959ab5 +85223a2465a11d0bc9b5d93805c5e4466081109f175fae62f82c5012ef4a2c7c +23ff8004c8704103f0dc1589270f8282f9d5a0f51408379ace784d0af862b548 +1c11650e865e17af7e04df20a4049295e93d32f22c1cc3c39a8626fa343d1f18 +a3495bc7dcab911cff66d60d29e1b45a7f16a477b83cf18c523c288c91adc74f +e6b3a91445a68313118abd7bd8a0a1ce9290f868f583a3ff80db71381eeb2de8 +e80b4d8d2cf70bcdafc08788ba8cd6cb2b6fd739ef809c3cb2ad1ded30e14240 +a7db077e83d18c867e22ba60a57ee2d825c2f7c8b9054d09d6049255a30c67d7 +3d01bca101e4e93d2e82e14a86f331b501736cdcac5f562d16f190aeecb5fe39 +7b434555d2b8a2bd4d363cdd4a19e69c6bf2e7856e3c9214b0931d392ae644b9 +bec489e739e7e091e0dea23212e398e9ae3194d52f42afb75079a63f9c39f205 +73acb5dc43426f3657575930d5c2a053f7fd5b43f2d011ad74070c1ebdd52aa9 +70961253b0715079e17a8339f7d48c9821bad9b4ea2ea0e03e19fefca01f36c8 +bb91586e2ded2b2fd7512bc9e6787340d78d6d308e8fcafc751707f243fb30f2 +5479cf7e89801c62ba25ff7548892e1e224878aeb4cb1f05287cb7febe450986 +5d8f2f6469bba902a8f7f0892a954d7ab83e600ceb2dc127239d570428fe9008 +ba45c4f6b1734a4019122ccea228571be3dee9302bbb7aff9f4ff06290422f91 +97f61416b4b19c2cf8225cb54dd3e8090c74abbe1080301cf19d61faebaee2db +9e5c3931c102eab99c20676b1920913273aaf753ba60d87773ca7215562fb612 +5f246db99d0b1381f716a7690efe7ab2b54c072853bb28705d12dc35b3722ff6 +11675754ee99e7323b2389024b7112be202194e142285227bf08270b560fcf34 +2d16392b6dd428e30a10e0d87977a5e6b035063b3f43f4fcaa21b30c90a194cc +5569a0c060b081a054de4bee53914c2bba4e3376b4a44ca48b58e18be2f84a62 +5039ec6f2ef3a6cd1d31d5eb6692420d89306f2e6a712d3f3220e2937f9c4e41 +33cdae5b6d2a09e0a141fb41d58d5ae2111e74501fe591bd3697d6592db2b425 +0ca00f66be5069fc5800e04fd4c4dc1c86f723c02684b7c353f90c4cffa5fd92 +8ee3d10b9b259048c67c3bbfe026185e8a5e8b097390dac73faeedd924ea3d24 +cf82c27494b4f0d7abb77821408175187ce0e81ee5d672000d1dfdb089864ead +599f8392cb7a14624c0624d8b1116645ecede619b1d864332d521b0124de044f +e576158176364601a6192366bfe9c3ca0491c91e53d21845b63b54ed4d1f37c1 +8214248152c57a2bfdf8499abb15e1b9dc565456e5765edab49357464a2597c0 +e4c987620bb512fa33b6c3f643f94e89d83b5778cf56e0cdf6c1721f58c4d3b2 +dc13d5372a854d1b4f0415d37e96f6ba8cc5685413ba4481f2fc489484461d6f +5e081b04a478b0a09139a26ab2944deb0ea32a61f1e787d90cb55ca1c88bbfcd +37233d2cc2f7deea0112a9ea83ede40232d5d97e4447e02dc450d0c944bd746c +8d33b0bf6a190614c016bc96dc7b58835bb0daeeeed1b306326a4c516ef39a43 +4e59f1d5e469678ddfb649bfb3ae3726c2a50e680701812e57f5f11056d3b6a4 +df4be50aa1edab57e5df5f5fa7af30f9fe9627b01871e88637ab68e7d7d9aef6 +7920bdfa66b77bcccbaa2f09cb59496e96a4f7cdd7986e6a1fac884a9c729771 +a3c7ce311151e93138e3e02bab11bdd4b1fc2e7073b5a35bb8601ad01da624d8 +2f578fefdd7f81db5ccf4e4eeabba67aac9b5e38a63ce7c1e591dccc86ccd17c +f978e4fa9ba685854464de478f113a9be8d6575cbed7d32723a879628b9f977c +42d4771fe17fa0a4cb918b6565dda1c28f7219851e917806cf7105efe42a9a94 +a76536077b3a9732c01dea56b938803a43f521faa3ab493383ddafd8b159f00e +87dcd4dd42de5bd113ea2ff055a2153bbb1fcf3b51a85fa18191ff143948de0b +cf606706cba9afc5db85c4911fd1fe2377f68514a3485b40b91c1aa46f526485 +ca9720dd285b3abad88fe5d9ff2afc628caddd01b044161f6c18ec243028b727 +b2aa343385c848560c52d6fb81791f3a2ff66fcadd3ea41691a2073ef984229f +07355f8a6a37a9489494fe02c233c4506f440043b4062755f0cf7ff4b32bc154 +dd96fc84a35f0f989a1c668a945a8032980f073469b84002a85bebf6ef17fa30 +d332c88ef5235cddf6a66addac6d66d1f8944d9fdf9e33740c319979ca36a0d2 +02e72221f5fa890d1b88734bf6504ff40a4777b27fab35ae19a46338f9542851 +ab50034d1a515fd8aa550bd7074b283b2206acf1c13da6d3a9430b1dc5463b95 +b631f28aa62edf5d9b273ba803e72145bf0dfae33223132539b0346c9de97ed2 +7e553e095c97f9b3a14da699c383840456823419906b5f4be20337e537e0e8ad +557795a68d1fd3e6f770b2cceadcf493d19d688e2e80f83d8dbaa95ece47f6a3 +5c028455cff81071c06eeb830496722a588204cbf52d18544b9ad755e21afb16 +7e27bd39aba20041bad3a99c66d6c16e67fee8ed79712f2a0a788c51e8f26d73 +54585dee498403b734f56cc3015e2a88a23dc6890f942690ee717ac457a1592a +ba7b038bf3f0e6f1e056879cf8d23660d8eb5db01951f0ef32ad2e6e8af7e06f +b81e7e945f45dfe64a264ffa6e8d9f0b03d2ff2ebe450e8b6d4969e49d0f5e1b +080eec0d7f9ec42dd64d2f2629db0769590fe62871df28a350379426cea16b52 +db14a5e5c23d13da4084723b9346011ac33caa39886424c31899460a5f35f405 +363e69085db6e55b069ded255dd172fe3df0b0d31a0053e234b3e2ec44f433a6 +7a638f9a55a445412fcf8c6ff4d01fdcf6e012ed305beb3fa0b1752441c56e51 +c30b82300e0b98ff032e3bc4e27d6485741e27a07ea8a131bd7e697e28854ef8 +c58801a100ba86d94ebc1213cb54a81083367f385d028644f213bc18eb70734e +8de376d680e8b71b530a5f235fb14d7f3d3059862cbb7ea9b6bc2d827bf71744 +87226be663ce0a9feb4f248e28b71649355bde7febf2b8cce5f674f6afea22cf +f42e98405fd872dc2afadb1d8b1630265913cd5452c7b6bfe516624c16e6133c +3b0152abf170701b5600882b3a4c2fabe4c9794a4bb48c3e2d9a4c03744662b8 +0ffa2ac877f5a0db47d26d97bece9f04220d7a19f7abae2346016a359f183271 +1a022c704e4bb9bf7215089e7979cefb7fd438fce318f3a900385d6162aaf8d6 +23f50ebd7b7de89e426631b59b1fdc688f36fc81ff8621e7adbc3b1aad6c2d19 +b9995b873acdce08661a25f30f551144e88bf163db7739c67fe4f26ed01fb8fa +9e0a8628ac2338778249c101bcb667f8e7d37f97fa68a680ebe80421ff943a33 +ddb2dd16c13f82c7100d6d4ca8fea5283518cc9004a9cf1e6b590bd8b9795599 +eb091c682528dcc8890bc45517ee013e146f6e2d37e4b20f007c47fbba8d600a +63288701ae7e57cb2905f5b71557f2d1599f1d5eda80f59896199e2aa744dd56 +74af44b9b87886ff41240188c6753248d30b7f1aec5520c18589120615e458f0 +65e158f2015098676e62329cbfb76bd5bacbe510ab5cd1df00c4b750eab9bc05 +b2a6d05a17ff8f198ddc48abe338e5aa4280080f5256bca57289511d5206dc65 +d77507048626e2483fd6239bd14d81b4e6ee321c957332629f004710adda7007 +04307317a3daa98a28ae9a788c025aba2e667f28e567678f7dd8e1ab1732e74c +886e342da3330094619b2a0fb6adb7189c0be350c4052e24ac09c307b4de27de +88b13f8c3690f42ffc6f9b3a16ea9fd3aad6d2529d507de80a66fb2974f96f5a +6ec51c306f3253a03720e45cdeff9d70d1383ef21e36f9d9a8236fb90504eecc +5cf90d24debe60c8c45e12ed3f6a61c29788d1c5cd7cada5a2f09dd01bfd1a4e +f57202691b773a337533dcaf80ed4dadcbbbaccd19765eff4d7316860502a30c +b422ebaf5d9b9bb9634abd56a40c0e5d05b1e8b76710abf46d8ae3be97ac19b0 +31f01237a0bf80b474cbfec8b863141298ddcc4bbe702d5cc574d64d21921615 +755553007b7a3e031ece5e2797d72e381c49f4c3976594f863660c1529b461fb +bbd4da0d101d5f1b7e3f00a0e0611758619f0624fffef8c234c224de122ba669 +2621eee9b5edc20b8071453f3773c076ff8025824aaf89ad9d17024b7bbd3db3 +477635edfff2293a9d9e5d7553bf5fdf6eed19a04bca31837facd884f5fa0735 +b2f244ecc17773995d753c3ec1f81fcf46b9c7fc35b6d8c073fe3700a2924c4a +673fafc2fc4bb02ec5d7e864176d5c87c5348c3b2a8d5c583196fdf8cf6108a0 +0b0381d126076f5ff5283d05b97b0a21091be3f73860f72b69b3a4dbd19372ae +b661219c6fc715f06d226bf54805fe97a1b03a69f6818a561a3c789ee6db3af6 +8fe31b152e9c8813a880c08295cb6e6167a145b4ab25e97855f7e058d02fa8ef +0f828432b6e9436ab01c7c6a320a33d542ca5e5446d08ebd597d8dd49ed5f83a +b9803bb48daaf7bdf9a0457e4247eb2fc41a96c19e562a5513494350acec5ed4 +75d010b13951fd6c1ff7ffdacc977e1f22da9d11636bd77d80c7742bec079523 +fb7036b4c65f16330cbb06bb4441ba6d9695d57f376a7faef1c5c051b0485d08 +25cf232eb12683489e97e46c1addae9f5147ae117c5744fc975eb90821791157 +110fd856d1bd00c7f9bc1040ae0d83b1ddf572d7d958c1af16549c7c9a498007 +002bc771b5286ba7af2ae748c03e5885407d7a5b56aa55e1d86e583fbbd9b88f +3fce64f8aeb894babf7521ad50dc5608d04765ca71b0a97ea4d4f67fda9efb5f +1d67b0fba08ddb711f63e52304e098f871ec1c7e9d58b2b2e58c887122e1fab6 +d3d4b391f3253170ace505c35c4877d32c9c36506cde3ae243d1de6aa33f5e18 +fd129165278045b075c43bcf0ced8580a81d702ba464102bdd123a6c2b2310cb +c2236427fb40b0f16dbcf46c31019d5beed1e6034949377fd5f7cd57bc04479a +8b53083904c373a63a4a09c60eca4229aff9209449eb78d245ad1cbf3d831867 +7d60c285af422f15d6cab2efe202a00c5f21635ba36b4bfb92bc54557de1c092 +7a3645afb9dc24dc97030dfffb5606c8db3dc60e35bc6a0086aae19ace912bfb +c12f209036c0d43f1aa6500f94ba24a0c4db2309a26f0960fe1426f4239d4551 +fc9a87d4add8c89cf7c5e40a181396b68043e0b9321caad83cc8a2a71b51c2ca +3efe240e26ddcb4d64eb6fdcb0b59ec196361f7897a2a16b25bfc5513129bb27 +24023176e04983e273b0780533fea226cedeff949967b1b9aa9815ba9e1cccda +bdf873229770b6d02b5bc81a2cdca77d93ebc04b79595d1eff2afd3d6ced3489 +b9d273766dfae70b459d5b94b1182cd11bd4beb370c4ef4d5c551063fec1ddb9 +8761995d160323356be08008e366649a771b54b5bf40f822ba6dfe66dcaa7caa +4ea1ee4ff8fca8aed14a2966baa5d3db25d0d2cb4062a06061adbb7b2a35b2df +5dc202bafbfeccae75c27aea6c7230320412c30a993e056d6288935160ef1ed2 +c9f6cfa3119948d4b63e5708cc6923dcd520d8a45a1fbbb34567f322d7a8676b +8fc31fca3c42b5a5528b5151127a445f34f897175f317579593251a920f0b4f6 +a0d85e4aabf120ed28263706965ae8564bf9fdca5fbff9721299b212d7562335 +f12569804a23475ae1f5ca757b91ea476efb0da9baadfa85b1c33f6e4ff91e1d +1863aca97bb5b63a07e76a2e0d9d88718871f4e9ff325aa7c5fcfcf40dbeeb1b +82536677ec6ed3e57fc50270ef1067354719a1b2026927e52d0e3e69521d8e8a +a0186da08d4cbf91f7cb7701ffe8f63ad558fe50e1a19550d6f769068b96f7a4 +7bf99f865c8b6d0de4c4b3a24c9deaf648c462cdd4892a544430ac0ff0932695 +8a9df434c065161b1adfb008cc3cd949c055fb8a99c7712789321628f72a498c +646096ad2f24620366f20fa7516c2535df0d3745143b62424254dd79e2f14d07 +ac4e4f623b95dfc1e3dc8a980451f248d55cf6b0257c95f72915c53e710cc7e4 +c770c7176434d40d1e2f6ac378dee3d56599be2e75dbb80b68aa0cb1a9b05640 +2eb87374757ebcd800ee8166a7c14344d534ec43c679f19a3faf0831f6ac06c5 +418d0cc5bd0202c8fb9ea4a4bbeec84746782b34f0cdf595537108c04fb2c4f0 +f734dfc1ab7b6e448c5466e596f550709be51ea4ad3d2e1809406081f24bedc2 +afe6b2f0dc106177f0f23e50a68087b935681700a73687311c047b7a3b959e94 +f1d66a5b9d363b07946af750f7c23c88ac57abe52753eee2ca1738ced53e343c +d7147f4e518e410268717ea1d47f935e68e37f1393f4643295cf9fe6bb6a8e4f +24eb7d36e5a73e95668dd0484b43dc7fa7a2e1a4771439af53b8292d4dd9ba0f +87090fa3fc1412e99fbbd9293d622389feab98221d1d17783f4e98f438807085 +f1c5248b0d6cc84306cdd2d6b4b49859030ecca03a3bc135fd0e2e0c4dbce468 +b2fb4d3149b24460809e7a40e7733fc69ff9e1f5034bdbbcf54b02de9ba72d97 +3e02f2391c4ffaad4155684839c9a1ad84259f7e0e0870b443f6065a9e6ba2f2 +5d2b7ed4ff02b658fd881882183a92a619e23b78e368deeac7731942c86e792f +575e124aba8bc9eb8f1ff27baa023b354cb58a1b4b7bca7ace708aa264079a54 +8a7291a7aa9ce597599c436314f0ce6bd9a91f7d7d6f5fc74311e3a43bca381f +84343da850a3b97a8b8647428fb3d7675a8c747a364af6733b624c37e119408e +2b8dbcd0ebf1128d3d622fb12811f6fa86734714fdacd66f22fbbed86e0eef19 +8165412707a465ab93c043d6ace1453d51a027eea5aee64dc20e6b1677bf0c51 +6d988d4c2dea53fd3220ae68b7ba8ec9b4a9e12740610db32c86ff6f9dbbc4be +c895877b4a50136972e64c5cec736350fcc746b9a35d227e861a84ea1b7a991d +df9923afa67b38558210e59584be3bc822be7b00f0b676d52860aff3fca1c731 +29ba85e325b7c525bedf73fd53f8cca733dc99afb00c7d35203ec104ab6ef99a +303c5320a7ae6961e7ad96e49801de1aadfb9a49a4e4938ec5c9866a2a073255 +3a0ca67cd73514e1925cc131a6201522d44caacaed554b6dce99a30ca2fcfbb8 +00b9b263fa2680d678a94aa745d1628c8722384af1a6ffa490b18e3d34d21ddd +6fb6a7d01123c8071d7325e30c1d0d29c069f00c2b3e6c2c337e4c19c151c5c9 +780d3e2b9fb69473e31406af3d3894edf3d56b15719b27bfbd18bf14e245b809 +f29ecae8d0d23194e99d15e3b3cfe3c6dadfffbf9f33c139f814ba96aaafab3d +7de097d6ec31f1bae09529750e5a124b1df043b0fcb630631fdcee4fc7238b1e +08a3a34498bf112ef7a8c543720cbaa77200a40b1cf72b5a6a05d66a0ed37d68 +22533e12b1393da9c1edaad4f2299558c82506af548eaf465c76ed43926797c0 +8c127e349a26c21006cde478eaffe17c59d981f045ae488880e427626ef9c073 +d5c9145af6f127bc9f127f0a859836c56b9f40b6ecc446e137e9d9fff367226e +73ca9add9ea28abad05f87cac5643bc07e91b82e0b35b36626444dfc50a6dafc +c37d6306d441ade0b998c7c98dc259e40d974a22d8900263f9421d506386ac95 +c1c00fef532fe5641f4cacd814ceb9cffceb23a219841e9e1b6c465ac9fcf270 +5408cd925a37ee97c64894e02c73d0df87b382622c074734a1e2370aa4a2642c +1fd382156fd054f3a5e2f66a623e396cf56f44273eccb27b5d11170338d4cf27 +3f61f8effe3e52b90bd1c49dc15e8416f3f1f839b2a5d900ec8a33b3bd8c3ead +6f51f1d68dd4e4202021adb52ce62191f848273c485a5f88dc1c09952bd38ad9 +4d0d9c08cac17187e36c4bef849ea1b5eae2c15ba8a299e9fb3e8d7353fbafa3 +0d7af0f616bd16a11d8e98b7c5f39155b2c8bc3a360c89961ab212a8520db33f +763c7caead9ed5815351fcc2026a35646336a498ff3bfc6a074e90f0395ff802 +48c1a6b403c1e57eca7068453f149eb8c5a6c1bd980a0215d90b9825372d8d3b +3fe32871eb3b517ed6e20e30477c0433de4d2cec73f7d7773210a10c4932e909 +eff2f2f83896892eb69f7d27014b55aca65dcc5e8bc62046fcb80a2a24a52165 +77e8ae37ef099a4dab23cd5979017ad30872aa6e94b2bf4e4d7f495f2eceb4f0 +b6d258f94077d191f62dd3f96f94ab43f4ec19a0c1182c13a8ba469601ff148a +57e007c07b6d305e3bacb2bc0a6708a1b17bef4ea41982a321240ef969390985 +d83828feea903855db4ed66f678dc7c5d6ab49070c4079106163e37cd1144057 +c781dfd270ee40e3c13b5d74f52324f85c84e55f750298ad9f145759c26b4528 +8e707897bbb2aed1037f30d37109a784174cfd5b0aa698c1e79f25d09c603628 +e23a3abc8d6ee13777f7f5f9e27cf34b97598d3d5bfa96d2499e91e2fa7c505e +3227f8217212bec21eb2f31622a28d292429ab899aaa92ea40a4ca1033217f4a +ef6666c16305389f149449a44a0adec2899fe892fba9d88b635668becd219657 +02d4b8792bdf922e4342dd5d6d27dd7392a427f153ff35552140a01d7dbb14b7 +57da81569ced971af93e59ec7a6927843ece2a555a58532c4a5c0c5aa2d27405 +72cab4d7f7b59b45fba1c9f61115ee87574e374554d2ea0c7bc7ef0a07843e37 +cfc76c2baf0bbc7d58a95b70f7ad9d2c2c1cbacc6f5190e4392fc5598792e623 +4f89f3b28442b8d37e3cc2c612b29f960005e68198ccdc8805d2887d9e9fab27 +70299a4eae741dca4c983967bb2275ab152a58299a35457759619c6dc3b25eab +68fa0ed545b09833bc269e15456c018ed4494d2c8529f176a03b340fb3d39c45 +726f023eaf1cbb5a0c776e2a65b77db5a17e47f75c0debec46166e3ad2804efc +2e41259900f9cbf3dde0d6b1ee4f16964e1f3df0c332021504140bb87e68694d +f8046216bc50fb9d7c68a5870ca8ef17d8d543dcc872a32d6421c5b30d561efb +e55607c7e21669fb949aee071954491d5ed28c97304eedb5941fc51aec6b7d4c +fb4efd4d49610ca7779e0c384e3435e4e9ad4346616667794b925d638355d76e +a0130cc84045ef68a6f45a9839d642faec80a9b817474fa8ecf3176570bcb441 +e9b7450ea2d3f2d5586db80b4218d41c3f256ab8d7bed7e59458b91872f91ceb +fcfad2965a08a73861fa7388dd75cac1924c202b26387b6129e5ba5830b9e88a +497c7e94c61c286ae8f4d596fee7c17ba5635b829029ff837c7d4c084df29bd1 +b318d69d487a679988ebc1751d7c944b83b6b44824cf91246fc75de3d8a2b092 +d1946b845f3f5ebb0b9b043215188cfe3a4f34fb4fd0d6dd89af38c49d8309f1 +b95e43c6e5a48a4684dd826e526d8bfd8318447b57aa8c210753b55039c057a4 +4a35faf9efa90f25e9c5336ac001e71374dd7e45588759e4c0a2689d82870948 +68f456a56dac56b2f0f60a1b7bd307ef18d7d86a3d0fb8e4599524341d8c57cc +3f20e4840cf87c11929718d250faeb37a28a5c230e9aac9abd7f0339d4128c54 +eb3cc09e4ec9eda06a4687cdf21d1f117e63aba8fe5079e879eb3d1309d24761 +32dd8f3ed3ec6a3ecefbbd5eddeab99521bd87f39f20b19ed0cbee4fbadb108a +8a25aef0f277ec0c2d49f30afed6975967c513a0772d8a1176d3a4e0a7768321 +2c85b1cd14ac7825d029b02cdecca22e891f3579ff5ef8304e74cf3dccdcb3a7 +254134118665dfbdff5427c0471b7d7c2b64118d995734a9cb4495bd347cac39 +8805fe76a5973959645a471df1bf99cd333f8a68815706fc4e365de7b496160a +4aba0c061e8509a1b39fd0f2582f813d21daa11c35a5350036dd993e83ef6c41 +dd17d079fcdc56e9bc4b1c0afd6eb855c7d347612938431ae72bceb78aab6efa +5ccb731cc337171d3e591140e9ec3436bb12ff9b39ee8631de4a6934bce1a4db +b61aae9a226e38b0db3afd189165d90812e6a8e74490e080d2d79eb010b96bc1 +548062cf654b1b627b7a8faec8f496cb6898635e123651996d2cb52afd58c014 +ab44719499d2eccbb5378666d6a0b14f8c336226b55f8e4fe55c975c84eda8b3 +cb66b0e4372f23966d4a1ec8e7e2333acd6f7a18423ab867dd5572e30ee1028c +8a172ab879715601ccc59e4431f3a1923fa3c5f79e1ef8ba28b54ff006bc380c +db98623bbf0604a247e87888a62fb03473a98e06c9879f158484d243b72b4d3e +04573192531beffc3202c5740209da69deeefa077d9497e9c5d2309b941d8397 +2d9f88eab63fe121bd4658a3bc09677772f7f63d27ee5374adf60c1cb4f37a43 +355567a8649aa36d60bb14b0ed70932de29a7ec4910b836fcf8662adf5d80f49 +362ed0e804b459be1c5315d4070b61bb6d1296a5a8b2516b11dcb8dfd0bbb426 +c5897ae6a20b531f8f251cc12bb52ae6406ddf28d77784229ce474b8b72b4329 +97073759a48cc211b122ac6e29e089d75b81a983c4c9aee019e5cf78a4c77bca +b335eebd138ba85807b57bbd7321283d1cc1793721189de7062dcae2c3533402 +06426a9edf0844911997187917ba23fe1d0718acd5c4d4ad8c2819de24db6ef2 +b2cb9701789ded9938eb436641d998078216ebdb97c418428e99b6abdef04853 +bc270a8bd461065d26efea3434e7d3b52eccd21e07f526881b3ea123e3c2329a +056ed88fb4089b69abb3746877771817f2fe9bb6728a7eb3fd2e64761463ac3d +669ad3d8928451303c7d645910521533282982bca604677f2bb2988b10f7b848 +2114cf7557798ce13952dea8adc2c68397f100a0ce55f5b790c6b8ead46fe7e3 +6e958c634bf76423a7a87c9448e0824f142d0a64ba8215e8cbc0da34e79d8589 +cc9baa0f29410ca4162c027383eb8260a8705f7f1c2c7676aeec54c4e0c42b08 +5b66dda1c9f7984877dc5219fa062d884266438b49c4a9aa6a1c469440c75a4b +ae1f5362b78a3c9f74181f0f28b0354af3c84affd618a156a3aad277065fc6cb +ffcae5406758d4add98169fe89d3e21f9d39e00d018da20350599a441b786cfe +74a43b7bc4659b5904b02ea88638622bb0096ac3b47af0476594fd3ca6753f65 +357d504941120a2aa326d006e5a69c6b806d3a0e928b926e253dc81ae13b1dfe +f4ddc4709ff15ecd4bd41b88d8ac189096ed4c56465d3dc7b76ad19f222f7397 +52426640589f5c13136131d42b814a8c40d6597572e6766dced40ecc45059318 +5cce8f0121abe54423c3b28e103a8660df4fbb1b95aa2ef9a9cb0a1253c49a94 +f32be151957c11ab2c0d522f57b245edb047eafed062c59ed0a6b82687caa7c9 +9b203a1c30ec063b4905ae31f0118f800c6c3f7759cdb6b3f043af3243b8ba8c +cc383e27aaba6334a74868e3f85d9a4fed0550257ef85cdbe8ecb69e7a5d7dc9 +3bfc2ccfc997e74ca7714fd25ddffb54650d15417471c95360ce43693abeeb42 +5804a13f77d03cc1b53084ffdab17f068e4f0c506cf6343b928251165853f6c7 +d337f6c3bd8aa64c57156ccc69050130f1206cbaff5f2202b8a17630d41b7b62 +0c4c276f8c6e76a9228b1756aaa31b87598b29d2bc5a268b45ee3720261cab35 +e5997e262ccbd3c464aa67d0074f1c4b04c786ee08c05d643e01acf498be936c +d83bf1800d6f30a4b5d7a08c15fb036d4e053e436c9260891534cbc3c8eda536 +2cdeccbc03a423e0f2e508ab719f6bf7c274d8ee7740b79b13a505102acdd25c +50637a1c6b75840b12e6dc77e1befb1b6e4f3877cf2e1c2ddc399e0098093d39 +c8951f6e32c75fd6ca02d74451fdf614a55007b0bd7b920aab1cbf2de7eb072a +4d57fd5734e35cbbf8b5693fa3a09e5842d938b609110d33b63dfa6c31bfb1d0 +7696ee850223891791a68294433e6b9d733eef2683785694539e5c9d34d5963e +22672ae0f47061e450c62df0596aa5742d7d720906e6d8b6002ba1b01a8f0732 +5aa66cb81ec1a2009f72790ffbbf58a0d6838a934c41aa1e9d34edb183e4715d +e1025b0a03a2b4d3083d5dc24bf1656751ff0d50ed96d3d03ba155a1de7ba075 +cb09c98ac1f7d7565fa3b826d89c02b966b978fd33ca5a42cb96345f356ee8dd +d392b5a04cc3333002d469e6e1efde17df13d5d2037545694b428a6a3706e769 +6d31cd8cf72cf7245865818fb45979507b876a83aa961312a92bfd0fea3f0037 +a3025364dba8603907e6f3641a4823a1bbc556638b27133a0071790fb8fcbd0e +abcb83a258007bd8e2fa723b72fc36ede7e4745e67f5ecd38db6278901e4559a +efb6761215e98f2dec27a53eb6a5090030c74c57d1d1b1a29f0a578ce26e4682 +bdd7854c35cf5690514eac890d2dddabf2b6aa6b66304abc6b9f012d4c70bfb3 +a3ba42cb4bdd4f3550172055a44dda0cec627935ad8d96aa1048ca98256417a8 +c56462c7ac76f1f7977d51a5a65c2ad9bc3115a0728235fcb438f18cf370e880 +684c90971014482b2ca100d46d3a3de6a16b75c1d8e9c4949985b753c4256ef2 +49aaa058a2d4795774325e21f92fd0350dd2ff1a3ea9f8f0e9142a4757b7e926 +8c8ada143c295cb86a21afdb5260b4afb8e3bb4a0902b9d4fe09e3b0a187f7d4 +bd129264d0f121a3e0ca622bee85bfef35a039f29ff88131ebd4ac4ee473773d +b5c0a258efc4a51dc8582089314ded2ae3d39c42f5a733585c5b32343e23681a +2c5207e7b8c1477e09a3f131ae893172b7d2ff21d7bd5e67e1fdce06450b5406 +0b163a8c31674c8d6749d270a15117df4a221fe98463eaddadb4c8c8c8638439 +bc34c47fae4ca32e13579ce1fd6d5448bf23fa791905adab3e42aeed0b5bb6c1 +1f541b58bc1355288c4557b690ab27616f462fea63bd490e1c481338e9d7d68f +daf78b3fed65606463aea70d124b4757f47db307487a0360d2a422dd6aeee042 +27a9f57f734e233a4153fb652c06ee776a4c64991cf2d3e69c90ec4e797273a3 +d1339ddbed5e2810f5b54aa0b611ca5f1565c3cea89bfdd721151f01d625f07d +0c551db5db902aa5fb2027c8e5513f2000bb5d5e33bd99132536d3e65fb52c4c +424688691e4801e9d00f29a61dd7493228a9a3c137bb298257714ef0ee4f9f16 +87f0fafa42a93bf619817a73f292ff65941ac480bb3f9e4a5612a98e24a5373c +30b5e0a5b5d4b55221199eb4f5a6f70b7330a182c3c195229155f9d3ed4d7fd2 +f08cef3911f7ab70cf3d7d4b7dc302623b383a236f3f7c985ab4828709ba1d4c +c2a0e4daca3ece4c41e53a853c98e7e840c59614a88fe1227be49c38154f024d +83c4f0339c7f1afdee7b6d58c003359d1bc4f460468448222c26258d81b1844d +40283e5db7bb6baa955d9effbbe88f9981bd204a79da80206033a5d3c0c1b8f5 +00ec8a79f2472396493eae9ebeafd1662b941db3c23e3e820c7e8f85988a2a53 +7d955f18d7869632f498be0d6f5a81fe7e6727d8e6d0fc88cafa99839629c1cf +b7ac3cf2b21c43da3f07a3cc1798909400e840f4f48bcd3e76be4f94d9f38ee7 +f480e76021b36b9306c16a51ec9bba0c6f9b98248f17d49dddfde34226e33622 +c94655b5afa1c372d4463bc68155803096a36b6cffb7cf261100a46c0ce8bae0 +9fd42e392888bc3431bc9212de09437d3b7ff15fff9320fe11b2a16adf4f8350 +564725a52e4183b11b06166e8ca561d4913fa14603baff5169b44ab1f9085d2f +0111e4c3b9f6f72f92b61a915f4b6aff97b5163c5e131f1e0083a00f45e5eb57 +3b5de28f5e51e6484af6eece850985170fae9a91040fd860faf7b6be1fa851f8 +2740f3f32906c221796fef28187ada916dfebc65e327533b83a9a63d164d8b2e +6a6d834bb6390399d564c91c1b998ec5f992d280ba2538098b91cbfb09379f9d +c35deb26723693e7ce021f80792262a4d2f6e0f9a4df9f5286705c04f982ec57 +f10d2ac027d949cc4b62304d987640a6bda12acc60644983811ae225a0869ee5 +d5d92ec5ca8571b372033c63c402b0c671c63c3677d129837e6e75528351562e +bc2f6fba03df82eb600e57094c370d1dc844143b30b7d5dd0f7e20b4dabf379c +6a2e401a6023773c8b85ee50e1949476341338f3477113e8deea7096b8255aa4 +1fc4bb718842713425c6385227e6fb1ccf1f3fe89cd7f7f153a8132be0fcf7ff +5e30259022e09ab8a3932cc33d1cb4f6d3e299adf4c15ed0be59df30c1d5ed5b +471ac14fc7b10192ce7d55a412628142ba12ff9b39dff0cc18176e9693ecfcf4 +452838dd87cc9059f1aff608182b12d37ad5c13ad77ada2114f1cae0951a4d58 +725b18973e4c5c3ce7d4454aab91090409fee42d3ccf5d09cd768712e2a73b6a +4c134b390e0209773af69e875de4f7903b65f8ac253eefa28de825e83ff35b5e +7357ae7de5445bc6e2022b3d4c161f3697b2ee9650552271020b06f802f5a418 +d20dd1def4368956c713a197321b545625093fab4cb41413f88b6ed006c8fd54 +296ec46e4834ced1987ce6739f21631e0b79de38542248c7afb9e08a9e8f68fd +243f7cfb11767e9e4647972dbead5ec136764ad4120e1431b38e2566c0c0bb81 +6117d1d5b188935ba2924653feb532cc4f900f7e81e2e6278a753fcd50fd04c7 +3b0edd77747e070c2bd18ceeea2eae31dbaa343678b28b05b037c7b6e604d048 +394b1e694d23096040a5e709eca5a8755a2f15df09c607843d8abdca62b82e42 +5d0dcfe5bec63ffabe011e9aae3322228a26b0358d7c6a740cf91c526d847b84 +87c084b7f813f6870a27535b9f727253a9c41f502ddefdc210d7367371a8a1ca +6dd58d8a7234bd5457772728fccb21f82b1b5d1d8c538661c92fdab651e02e56 +766e16d58fb6ec299dd0fab458a79ec777eefe57ef9919b5f966c7de075c87b0 +f624e4900d476b49ff754e3029607cac879c150f12b548cd78aa6a6fcf0dabee +40412bc17072ea2e951b2268eb3777a619a250fa18c1f25a0db6f5b8895565d1 +5ca1a6f296c7a95aea09063c817468ad8c76694f2025db959a3f476c0235f3cd +2dc07f725c862e3cc9ecad251596061eeb04156fe89cf21589f6e11082bf3c5b +8d61dfbdbe592a120402983939b99c7d38b4cd32429237421594e21a21841a6a +e3756576fc0b063ea6a439f193e4f1dd48edb446da9ae6dbc55f0983f0a5445b +1223abb431e6bb1683c0d07d33e42ff9c37b2d16a0fbc52ea27f53937ebb52f5 +bc7493f84915b1e4b8f5c05441cd09f43e0e5418cc9d82f31ad35a5a69f32289 +df6f52bca5f1fc74b2625a42185cbf40350779c94b75a4b9f551f30439acd9d8 +3f9b79c46694b87fa60ea3af78ab05a65df0fbd2491d8a33710137a2e7fa7559 +39941651fe072f868f92b80792a40673a91776b083156f36bec4a3120d0ddb82 +9296dcb0f5d70028c9838788b84b6d9a84a12dd167eb1afafede886c6e9e9d21 +4ef74aef4a070cc6ca07a88629d15241be5d62e4975b55c734cdbdf872471c4c +9bc047036203d37cff7a98848b58e6ebc04412dabba494d4bf25ad9e4b4ef4b4 +ee155539af0c4b9aa1b8b8195375f6d5444a7ba34c0586405946b2492652ddd3 +d3e034add236bfa5a8612e8d453736ecef2fca9d8cada78698cbe62f7a7d9611 +f4bf3e04813a874d0e5bab4de5e3c72a98f38457dfbc0852557f6fb9e376e7c7 +1d3a0c9492e439cfecfdac766b7b5c3b59c29b3239726e2d6f672352a15d2aa4 +14d150814d18468a2558a8b86d2642c2b83db6b296b5a943ef70eaf987be7ee7 +de41f5cd1b1280aaf49289de4f4865f6c1a3a303e77b80a9263b142cf080ab87 +8fb6ebcb18a9701ea271a21b287bb8436d780dbcb0f20cb1bf949f080680a92b +ea81f980230b41311c8f30e9e25f325c92c2fd4006211444a31f80c86919f8f0 +890e6c1ca1ff51741d0634ce4818c9c2f0c553e5e8a17ffa5b834fa7672fe319 +75c0731a3f73a51585f5815419d05a7b10a7e24abdfae5078f7f8f5b34581bac +224f8d63b4283dbc34a2a1573b5f69eeb158c93e844403f3bd4e7a3b3a4e1e8a +ac0878ec2eb7c1b7e1c9e6780233608d46b7c801c6c0c83eb67b5d080f4af67a +7b0ce2d1a392ece3e3a0b71f7f37ee8c333ac76bf8ccadbbe158caa15c6a2429 +9b350ae180c2ce885d870be5d8378fbc05643de7c8da7171ec14c923c59fa500 +4d4fca2d8f85e7ba1aa642c8a214ff8bce3b9f62ef6a4a88c8129bebdcbfe426 +808e6d59b712b2aa3d7edee5e45bfa7aec02429796717995785614d69721ed40 +c9c5a56c5b10e5fb4d5e30d02371ee0b7c7b67d8c7a9fe60b2b9cc7ff4efac5f +523fd88267950ec3d0640347966f43bd326def79b20ddf0421551168a43c8791 +627a6ee25d3d8a1200c504226211219c690f3e708465da2317bc25baa1e9efd7 +78c9daef857ecbec0449bc16dad92f9f054d68cb91de65caac086e95605ef628 +702bcb7e8dfe538d683263bef330c0d900bbf6f62fdaf663d6d1346274006ba0 +e321644c01e752faa7793efbeede43a7b83173f7f167f3d6fe970acb6646917f +d36bb285e6d96ff1fcfc668ae4d185d868c898f3964fda9f0463eb6f83d2cec9 +ed861f5027330eefe13163560908a7129990799e21a1e83e814c7df4dfe15365 +ff29765bd346019d69809f425c453ce0a3948fdf3565b83332e47cd65c73467f +efb2bf3791994d3172dcff4f82a8d7ae4f9fd53664d180d930dd20aa1001a935 +e61e9410667536058ec3fd7b97aabd163f8de60a45794196df0cee18e8c56276 +25217e4002862b3241a017e7b497ba015662ed624d48749b783f69b204792a35 +1212fcf465faa1d4d5905a68f5f17e25ea35b3bb33498162e88f3b0e44d0b2e5 +756156eaf47340a82db8a28fce1e0b26e104295e94ac9aa330a5292167d153dd +cdc91e47e273eeff554fd652213148655557763b3aef2797df0ab81b202d53ec +76f5f57865cd1835f7f94515efd2335b966b9e81c76335a29414e4372bc6f186 +7140b735589bac9c6a9203b83919f44ee6c51e805a5bed6d7ffb66c44ccfe988 +59c87bc52021a819b52b850573c5fff13bf7cb9c11f23387d486eee0afca0052 +334f4858f1643f6163936a27c472b8dafcd6e14d3bf3f91eecd70bb7856ef444 +9cc49c7b9788c6c095e968b2c59923dde8ed1628c62eebcd5f32681ced0dccd0 +8e1e61a074c1a78d340c3d873c1eddc97df7051e3d3feb313e054934d4f8696e +8d617c28f03d817a40572e3630f050091c8738fd3e40c231abe958a9f5868b3a +3c9120fcfd2dbc319a91289cba50898b43a409cbb612c040d2f33d43ad9d759a +4cce86ef8dd46945e33caf837a0a7ecfb6b5900204662c56c9cc1b943427074e +a3a81765d85dbe3ad77bf5c1162900b5f1ef594285ce655ca2a15ca431afcbc4 +6007c144597fbe8ca9638756b3ce61ffa44d524266d2d4c6d6b7a7273625c55d +56c00242b0ff2a150297e504b9fef2b0b478531e1cc7e1c14ab647dac9feb0c5 +b7b3b20dbfc4285db7745ebb9a3039b230282cdf2a19c1afc822775f3a8026d7 +d793498b915d792bbda081d45f89d9af12967de9e4f4e3779650d7c2dc3cf1dc +d91b8debee82d3d4fbcca89dd4e129a73968660b457da664d1cec437e17680bb +7094ab35e4f77fdcf34b40b84b76f8b7750346b1e2f133686110e9f1de217d4f +8eb81f8d1be2e871ce57632c635189116b9a0a7deaf78d9d6d85178a4f1edef5 +e30c05971c0d6746dd2e1104281b6148217916a8fcb3944217a35b1a98390849 +68cebde7f17a14ccb58bfc1b5440b5d8c75ada3f1a581db2cf6bba553cc32e52 +0b3c5f0a9f7cc12e549f3c65798f74123c5556c9e0173254c1eeb1e094e0d8ef +35ea280b388b3d393dc9b84e6400abf8493017c5de85bc0c23ac61919a053262 +9a05cf198df82d4f2fb5d6b837fa75bab14bc34c1b46b9ddc4deb67ef4444152 +c280be46a9f0aeb0fdd5e90e8bfa5449bae9315ab5184a01d4753af4286ceb79 +09dbef7f742f7a488c93ed0024ee725686ba71296a18e04aa758742844d37648 +5541087952778948eff1a7521fe37a8ab311c7a7e818841c1d39751430a7b656 +0453c931b40d6d15915b79a73bd0d06893c0cfa0517e76cd9bd87673f7e7fdc0 +317e639f78ba7baaa5f1b43bb52788807b2461e95cd8193414724d954ea066e4 +63f578d9ac9a67822057b4e61241b8b5c8f3ce019c767ea2b84fec80ee642ab5 +9af04e1490b930da33cee816e91a7ec3756343129efc90f36468b8286566fdd7 +3f94d19bbe2076959797ddd83a7b901741578486b79d8102942f71f70c72b2f7 +359de20293952d3fd821f6a164487ac420dbf4374463889ca97198ade2827ad7 +d08bcc071bf2e455b4703891e0ddd950b5f2a11ab246cd2e4bd5401721b8e9b1 +702b439fdc8f1ba1a4ed9ef30a18eb514ec61d3fee9e20822a84c3ea225e5652 +65eeb21129e3e950d1143cfb759f8ac5e097a42fbd4807034c2b375598b6c439 +a2e90d007a1995738c61217224cbb54be3ad5aab1fc60d9f9414146b0cacc853 +4a57c5aa095ac953a6c4f5c16f001cf51c9586a3e67e2abbbd304e5abd9fe25f +ad3d2ad2c8b193113bdca6d5cbe2ce54fbc7f7f8feccff8eb98fb09dd1e2b7ae +b2db85d4a4aa399585edfcd485ca6bbde307e546e39856f24d3ce215a5ca1bc1 +b6aba3df0bce9bfb7ada72b6a9e1d73ffeb9dcdbbbb0861651ff71373d040f9a +43bb1797bd93db1948fb3a28cb446a04f52c3c8ff33ab4a9d87708e0bb86efc2 +db4e9459f7213ad59a61d9d7790d346d7036d36a8aa2599241d59b8130b8a37b +0242a2b59220eae2c2b7a1b169b1729da75fb682f0d612c007372135fab5afb2 +a6c05076f0f08c198a8178e84b9943ec3c8321e0d5ffdb4e07004e2d17a8fe28 +632cb2949c1fe77b543318c7b107212b363f9ac881c7b868255952cf50cb9504 +9dfdb8d429d7a0f3337db9da3e48be60d69999be3df1093303c88f2bfc2982e5 +5e8b7004b75d5658f681fe30bfb471863a318d7d0fb496ceec4429bf71d9f07f +32c5af99df3e6fa0095b096a3ac03c9b8009471cae3cdbf81cb21baaca707ba3 +f0bd970b52a4844cfc81cd66da5930686163303bb503cf72f7bbbb6f47b14785 +f6c40dc6518227a76bdfc5f7788fbb79978b6de3cf37e0e4f8b284bf249fd602 +d5ef47d169eb36137bddb00ba693ab9974d37347e9f8f0eb9f06f87d515cbf4d +003396ecfcf3305e83ea35edd75e05b2b363111f45fbc056cd13d1cee1e96797 +adab632023d85dbbc2fa22e057c031a84f69448fac91d804e40e3d8861b30469 +2fd221c7d77e7742ff66aa06be2e20150f6ba142e6c2ce640291d2374b849eac +f6b4b970ec408a84c72aa94de175618cb50e0f0813b179066d3e41e644fcc92f +97558fd8523d73986daa8e1a598b5a151fa10ba8b0795d9dd932948ceb56fa1a +3b6a96166bdfb663301bdb0a3d559a7e398c117e425e9c9b809995e757c4423e +ee52c0271a7ed1fdeba6ff0c18fc199b3d73b8441d7d64b4bcd2231375412415 +85e7c8ce647a5b45e0f1378d7948ec1b69d676ead40dd592947249b4fbf8b75c +36631914cb78d3bc5cf506520d6f9c1cb2e9aaf47a213b804496242a77e7b160 +1be264e885bb92abbd28ca502653a98b811c244cd92de8d9b95a46457f7e0390 +0ac1f0f5f458f5052d069d7320cd09e76aebfae3b0a6676e4de1742acf1e2fa2 +d5369d5670e30c7bb46abc78f1bb601f1b652ddd740261811cda6d6215be2a58 +cf2c798f9a47abf9b59fc32046e927c413de487117ab003c4da86f1ef4a2a92c +5d1ba48d463b11fc9a455a56010bac81b71212e818f15b498882338b83053bfc +f2126947a623eec40ec7348718f95aca261e8de0f35b8cbd5f9412659725a2c4 +9f29bc32e865636e1ef039b0efc8443db058159aaf304477fe7c2dabfc81b3d4 +35499d35a59eb97061292996fa65c5a1c1b4762d31046dfe2dd4a33e3f8e390c +922447ce8ff34f911e68000e98d0a94e9c84ea366eca151a3b9ba00d021367f2 +03bc330c1ce0f955231ba61a54c655d8dd7b271a0eedd56a844bc77181f724d2 +42e49d31778f9fdeaf240c096ee364c1e9945fec04d9b2b3cd256c70390f8f00 +aa80d6608d747053bfb92005c8b204abfd262dc7f7d015f4b966d7831e4a506e +87cdc738974049daee1e1c945fa916b7d8a04885c7be53d7191ed6839fb61409 +9a9798c718a6e2d96c362b5ae30d79c432279ef0b7c8e1a53e7e7e7be0074459 +f4941bc1b6f3efb8a8a3df0f0c2fbbfadfc1f48fed0a1c9aad6a08a50bd7582b +cee2ddb5be2a5ce078cc8e8beb8119bd78e320d6890bc7dcb10aeb7b5562b9ee +7e3c2d1a6b38fbf551cc5a3b60054d4718fbb6c396753ec4c76f99b5ac70d9e8 +29d607bebc0fbfeb7d33e6c876f0f1ae24e25393d501aa2a5b18a393975da2f1 +0e048f2043c45126643b6827d80f45c649f44580845f0e8e8e1a04e743364248 +cbc3891cb409f801a153bb47c4672976c62caf5d87c2bf547d3ba11abdbda794 +6ac66599f6819bfcc0f6ee2bd9d94562322edb6b87a3767f30d82bad0e023b88 +602eed6dcd0b9e387e586aeefdc3a2ccdb482604f556ef16193355c437e382b5 +0b87aa275f70bafdd7d5fdab98635e4110030e18f7ddf58c3978c7967df99427 +592988661029f55423765dcea061f1ae72f3aeaae59400cf30f6104614e62825 +9ba0d0151dcb3f28aa6ff41f16ac640b01ba51627f923386c33013bdae4aea54 +eaeeeeef8da3109e8866aa8aab18217a1a1f890d10df396a74bd0e1057a2dedd +7986109646d103f44f1581821446c1f8cf0b3bb5ef8bf04b27938a6ebfcd5001 +c67de72985041253e4df6d5ab6048002bf1d16753cee57e3fd8414e43c2ff7f2 +b46e54c389c058073f7affacc5140294666f06e2ad2eae8a41add24dff1a32d7 +3c94032b739009b75cf1b8771764f48d1c57033e9ee582144e4af8255ee0d7b3 +ea36a8208a72147db694e21b144c29f0d07e4af8c01fda6c109ca8612a1a6fad +3d2308b8b6b064f2dab4203724b76c0ad3df3f6e03eb5ec4f42739173e2bd19f +8cd09a5b79a6b1d6851af6e5c47545e4273d0be5f0147d68c3af68f59bbbd05a +b913d069a61831cfaf101c2f2174aa0f1c3daa7a73074611624db7ebf1f5643e +2c5bb1da08b0e1418733d28d0da8f543e438076eea37da310b2f4e049d7d3a64 +2db23c12150dddd516ad182b31e7549fb791e28cb54b37655d95b3c23c879ed0 +c6956040b8c5bc89cbb2a8473df767ca889a2e1240b735313254e9294dc91e31 +b3ed5faa6f7b4267f70524bf8e81c0aebdd63dc94ffa5742b20acc20ec097eec +40f28ea5744a3ee3910dcaae093b74e694dce05ac03ed910eccb4133fba37d0e +99953a6a3e290725d5ee4c10d03bd7f254ba2a4d1bf25e6b98de5c940f6f5303 +2cb0d0f029f0985b418b1f07af698bbc601329f9fe9978e5038e749f5872f2eb +5572d9225f688d3e9c228f8c793e227bd5a9a28d0d5ce6cae9bb7a8372ff7519 +e40e2bab027992d8ba49458b42abc954fbfce21141a270468b9fdee484a7ebff +64cf291404eca8486b14d0a5614604d5b80f8eef6eca462f6e672d72908cc3f8 +57550b516fab7e03c4d74245f2fe2c35df1535196170e9653be1b5cdb555cb60 +2d46549c63987b12a4cb569223c13d255ecb9300ba7a38686eab1c0b4484671c +3523cab620c1d5670d4bc9e59d23bf85e9bb2f57764031e1840437832ed96e79 +4ecb47cb9b8c8f45a922179f111895947ebcd3fe38d2e54eed036ec309f28af4 +1d9964639cab6eeadd23691b8da7affa00b364817cbb5a2f1100bf653ae568e4 +6cee6fd265e715618c4270e482e5162d85cc1125c7f7218aaf555f518373057b +75e49bd4a6f0903e0c3345337e00a2c6e1ec2d30162aa033016253af30b9ddd8 +c16dbb6e053ff3ce4c5b052f3f00daccf580a0ab2244670597e8dbfd66f3f088 +a51db45be935a2f8042e2dff5424e3804cd135f96cc59da82cfcb7216e7f719b +a361f655f268616942e7b79bba5d73683ad747440c75e9d07569d8aa38824a46 +b20d8b3bb3e86297d45632d310abb735d92e2ecd158cefcb4a98c93bb3f13c0a +36af62f165ea7f5eede9cc125600127618e35d12f3bf700e58cae49b05e22c79 +e591171df2f348d5455eb23b1513521bdbb0eb06d5bcb69b982190e63e28eb39 +7da07c06e388ea6229223ee4f14a9c384dfdc2ba0d8f9ff3c5fe852d0d662628 +d103f681fa2b56421d40944ad0d0e750c84b8e6ff963f5f37b2e3116082662bc +59e3614531463a63ca3caa4af5fa82add2ba8ec478c04cec24104b3e608d0fb4 +611bc75b97c00d1729e8650a636a36861e8f7e6429c8ca0d2f566e73611a114a +8b8e9f96300bcafde0cf2324243e77fff438811aa9882989a8bd09c385609a4d +dcb6209312d4529ad9bc0969a05b91e42492cba53b5249a102662e6edac95704 +271d5502666bc5255d35aa2f20e77729e8ab3987b82521bebd459fee449f240c +6b1d52790b5ea81f4a4cdadb65d89bff4399fce28a200917fffef754fe24b734 +13186717c09a7579cc44b7946d1838026896e2ccc45f41f5b1354f3de87292be +7e6a7e66626b69c59cb697684023f79f832fee404e3a83bed6aa7376239c326d +4c30ce5b557e8670fe2ca161d3d28515a89e9d378c6f2b479a93be0584a26d3e +c35e7a54c2f25589da8f4c0577e177da9564d0a704e1559046299345d7c9f68c +3ecd1a372bace2ac0321805c103ac438985078a4766b0daf8590e683db158636 +ce4b7c3ea542584d1df38d2d8f0cdb679bd0b5c82423d902ef6f1fcfd746324b +50128d13ee0f5ac9957188c08b0eb413328ca4f8080d7beaab16cc3aacd51a8f +03839492b671138f3960de304ffb63286fe91486319e92ad8493045516b4636a +8e178794903a2252eef2e90806740071b9817742f87e074af21c498fa3f21dbb +e1b8e3c8146d7973d10dbb2708d5024eba4f333669bccc0a29312420c0dc7138 +463b986f41d8c25950d7ef64a99ffe90f6a3520939de3d0e516a4dc7be23bea4 +74f3fd1c2f2ad8d7ce4c327ffa20710e2bf6c5f815693a5b4025605314f715a3 +9ef8f5a86b7f260c8a6c345840443bc02d700d46bff7ce8667032a952d4063e7 +0dda03de1244830f0ccaadc7062abc6ff41ddc4ed9ca12488904ebed85608c97 +5d0e302df6ebd6c22a5e213d21019ca37446a679eac1bbe0de6317005f955de8 +6b2a301f0c903915981e74f2ef18c4671bec9f12c2595d7f51788d54009c46ea +e3e1af39badc71cef60d590ca95e47a8f1c53274a7e02c50e21c8bea2001dbf8 +5d787235e5f31bac2d4d489136d9491c83001256948fdcd34eb2da295a775fae +9e9fccbd0830a99cdc497bdb8cf2adc6bdbb7ff8c150f306e5875378457e79c0 +1a01ff998cc41965862136b37e22ef4d3aa1234bb3419bdc71a43d45f10f879b +925fe4aa3b48c736f989898c68d3fefcee68ce151a55590d4b1a5312a2558be5 +6066657d53fc820e84fcb162f67de282b513f80d182931c323959377f16c483b +fb0b65b28215a0dc15dacc09b82551f9a04cba42cdad1dd1aa8871c534e0413b +5e1dbdd772e4b0eafb21e01a245bfc273b2f8ad00d518dbc35d0ed6ff463c68d +00165563ec93b156cc00e7f945a8705726c752907283e71ae5bc8e1dd61ca3d6 +dea7fec8928d460243534d16dba851dd77e3176eed0d7b8284718a891a0e8091 +e8525ca038e4a358ba3fbd2089ad33bc7821bf753dbaa23c1708cd6c80fd8e04 +919a230b790ba7e65e2e6c99c6254ce61b1f23466843a12a87d0bb46993d114f +2cfa18545e813e0f0bcd42fb41ca0bb3843f5324d9f68825c520beb38e34c1aa +da4aa7c3e03c55fa023b2f4b4d3ae618a14b2b3555de7f2a55a644f2035fa18b +787abdf31401eef648529e4bd15d9b8e3e3ff5eed76afa2112a32716ca12e39b +08f6053b68c42944648bbfc34d02af7e6bd35d21127f9fa0a79406f7c2b6d278 +62103da11c6e1cb34512af560b3af2300882fa769716e84a435a9c6cefdcb0be +e0ce3c9fd5531cd4d66ea9f663889660385423c905663cbbe9bb46838799f9b2 +1d0485547700339b458c605f15f65030e4ab270ae1500e30a133ce0ddefa2190 +23d55a16daf62c8c788432c3b9813865a25edaaa731831ff905bd900434f2d69 +2f8880b60a14c12e99c74bb7550da6b5ce8d2228ac4b44cc7432b1dc58c96e4d +1f4390a3b6dcba3569110f0d5f98f77289d27feb69b656257aa14edc8bb3c00d +2da9a4cbbab69bf6ce190c1270be5fc5efc49df45c0b376f081dcfecd80b12e6 +cced2edb8423294bf8886bdba31002f5c673c0ec8772585640feea2a6e17f385 +1cfb1639e697548a5bd849e688ba187bc1b261c60e67cc84a4e5920fb753d5ca +5db41f5bca801c9cf1daf7b88c866d8c18c117ec29aa7087fc08ac4518eb94f6 +c761bdfae10843c4e6f279d7ffdc2eb36fe38f777745dd255415a9b2bd9c5b7c +efc7fbebefb52686382f76cfa9b6af9241d1573bcb8e1e7d2243f621380ea522 +a30c94f1b19e21e9f2e4ce61d1597e45aad5e4180b1d7069b7f9f2e9490722f0 +73f8c7dfb9c8f7514d97d18a2f4ad6a49985f7f4d6447bd439a6ed01e198440d +4b30845005396d3c346450902f88e470141d2cd45b253f8a7fb94342be3f8dfa +0fb042e016ce042d04f903e36519b2750136b94c1978a66b660e3c79a698abb2 +d7340e9097fc4bd724050ad42cec80696352c3c6e82558361b6421084a509a0c +40eaddcee7050ca7c43726daacab25ed87ad4c04bfd64047f24d7c8230cba804 +948d06cd0c1aa4fdba32b51f268dc4730b8d65c8b50a4bf0b2a9b43ece574336 +bd1cd5af9a1994f3709aa64583a2cd451e3a787307a84a7a159d34c2dd276b9d +a351f2751918509502ae9bc0590450916a99ed8b3778d1afed341f0584589c94 +f0dcca7db60869ff3f91493e636c35194d1dc1a396a48bd1f7e724c6ec46db60 +0a4a38ab1535ff3da2c64000dbbe240236143c66cf63742f621896406fcfcd43 +c4822c4d1c80e2f7722fea857c98180318338e1009afcbd10d5b65ecc2796a8c +14457624bad811cfe85533418fd87f901ae8b760df86e190e0682da9156b7476 +d6b0f81ba0c303e4dcf6607893de4f15b6ff0de435efcf8398dd55f416502d46 +99baaf44e39a29dc7d7c01332922934bb5fc9e5dadf4688f7a997ef9d8deaad3 +035640e40af15329b528ef163ecd867d31d008aae735f7a9498eaf20c4804f27 +a1ced03d39d4ca49791493e0e570e6fa9796e1f9fc79f3f74db5c1ccfa3c53b0 +182c636df0377c95d1d560da832244fdd446df61ed5cb36a2c5336cd59f63d0e +df7efd374fee9b2d35dc757ad2922bcf7441bb44167fa4c1e47ce46bb63a787a +90b9377fd9e42548091bae3db4a20bba6c4471dcb335b9b043c318577c96af23 +d046572134d38c2b38fdff6e5eda47689ef58ac2bcc0159d31355d7d063c4bb9 +5cf7a615ba26328a3173163f081c01aef825343386df17f0226890e536fe35c4 +1792b5115f3c92561da144315039f3f03d7eb6f450bb94931ea74ac6455dfe65 +b7c4b4993417f69ee10db426fc86681a697e7dc9abd96b7eac6b9a243cb6bc41 +f38340628ccf7bb442c089beffaa2ef864a31a736bff274ef95ce0cc2a77f695 +edadda05bc61825f4657bc14e579dcf1d05791a1b079cdccf6def41f026d4aeb +44604cd93e788fde233afd4d26aa71b111e2024e3b271d0e703022f52f635e5a +371c892ac55cb627caa3f36c14745b5fdf230211e076965f29ce80b102bd0b57 +a0322849da6cf05aa33b10384e32aee2ee65674e554eeac8cc9074b5d71c7988 +929b350b98950f6704c9448f2fdc0e4cd8c2f650be4a1ab53fced3c25a7bee82 +f35fae1c3bfe26407db5e7aceab1cc4b6dc4da552f5cd79ee8d5f068b1fff665 +e6fa41e77db2a0629507bfc547493051d4942405b0f01eb5deaf18dd9ade3631 +184ef75891ce7a1fafda1380d47e55767dd7d3c88baab501cbe0a87352716873 +8137bfb1a91b6c98b52dbadbee01a113655dcb67359a2314099b2866b3261773 +392aebd266a8fb6a11c04f40b345b4382ed8d2a25eabcf4ece87af1900c891aa +bd5a30cde2f1a0d3be3e5ce534299632521430f12084948a6ae70b75517ff665 +62e9268f2a454f3a10d7e5710f87ab29b96801b4fa815ce8a8acce2ea4404cba +5ff8b3a56c64ef081a75d664a6206fa341c605683b17d01abbcda227ef3c55a2 +3c56c79194138ea19d3cf3be55ddb73f45d00c4c681b667b8eda54a174968018 +5a5d990820dc716000a49c13d583bc06cff6a8f0f95ba7bb84e8d8673aef8817 +793f4981e1a4f4378958d7388db7ea6c9d1863d153a536a70a229a240aff8194 +e8ac2dcd2ea751a22d00784c7045c2c9d23e5fb214bc817b60425fc3e8a48f31 +e6e8a9342cc134e95c4e59026d9abdfc49900411c4a5d972027ffb7e1662a19c +56eeb69c9e67040399fd3913ade537cce040b8180c8c9e323a7d6b1e0c7d12f1 +52b135e2e4b589ce34338eff6bd405f1bb1d7ff5c2d7c221bcf320d672fcb97c +0bcf0649e70bc0f85b0c7462816a69f038e97fd614d97f82cb01d144c0743126 +e8b4b7a34995fbd9d870a22e9ef270926e0fb1f345e3f70f258a45f3c3af6036 +af94b49a7695dfffaba8d00d7c92687ef96b5f268b5ca004d10e38ee997df62a +cc19ee6387baeff268359df4880fe6a31bd113b4e10464365f31f7a1dd16bf3b +5fa72f13f53b1a0d61f7ae2e001b475ac61066bed04fcfbaa0dc7aac8dd693f4 +15eed8a4c33b7ae5d845a61c63d382a0b952b0672cccae58110544e7a7329441 +0bb1b2f7283a052228b7da6f5094202c0ed8eb09dbdf2ce10fa5c55cd44a35e7 +085258438bd77317fd7f990c408f4ad2ac594bf9d3f335e505cb3c024381c1bb +2fb22bac693761ca67bb1b8942103892402f006015466d5cb35492e507018581 +4ff9733b61051f2a0c71269d06af3c2a58bd5449a65a42d008a139c7beaa45ed +220a233174b00e35c77ee5a5e2995511f17a2eacd575007e666c2e57761e8385 +dba2ef66791e676bdfdc06efac4fbb27ab2ac285295b5ae013026e1bb7938a13 +e1fb9d071ae6f9fe3eb0f3b382695382783fa00c461d622a50ffe6b4651cd059 +c5cf8a359a5a2222b2ae48acea4f258460c8f69283f7e4554d37b18b691815ad +faab55eabbc37c18ea30eaaf5991d7e06574d94e9b87e631806c1d94ff0b7d78 +701743409efb366d7c405a11819f5472ffcb3f595ec7bf6146d8570caa949cab +15327fb424c04827148f1793c7041740ce61b521bdb5144e26bfa74be5adb8ca +b319e3ddd345b30662422673bbbbd23d30e71f6375c29bcd1ec632652f181c68 +efbc2026dae64875e32d6c7d8412c9724b72011f8a6615f972e5d4bd4f92d308 +ef8bb44cd603d22639fcdea9601ac016efd1284e4f899c1f977272926ff61d89 +89fea615693c7ad528befdc4277c2a50f335299cd065418407a0d3698ec60244 +dc7266dbda3270547e90eff22c65e2676a9fae32c088da780b75ea2ddd2bb617 +2eb6b68c19b0435652f8d5d2690a15747d6ee5180654fbee72f84a3051dcd4a4 +eb767370a85995016bac53ab3c0ee44a2e405903e8f6f33c36bf8feb48410d83 +cf3a04681cb878490415f09229bee9ca1d73da791c2c71313cb951713c5e450c +8482216a71f86f8a541122bea18446797554323764998165bac81b3096796faf +8538bf83af476e0bbabfa0813feed0dc578814b387a0473badf2da98a5f1a129 +b1385b2e4c9ab79424548e922b91cf56cb3f7a0dca6f4f04ac1ce5d4681d4062 +dc238c93ece3cb0f6c3523d07115a0c7c018a73490d5cdbb1985165ac41b14fe +de1352571c132e47e16915b04c85e16e57a07fd5aea653ad9491019970546d19 +3caf494886d2c197c8a39bb5ca92348b18ed84814a6fca4b9e07271c13598990 +08c821cf8044a71b89ee6b7c7581e5be5f0167f7f6c39f1e4eae183ac9a5b9da +9f71945962b981055d138d93acdafe0ff2162eb6e320a55fb6783e4755624762 +0326c12ae49da52f315f90646fa82072fc772a557b777ffbf2cc54c2c2f76b7f +09531e2890dce9f26157181c69e8fb98d1de277ea3ef5a9653198ca06524ff00 +248413ef8662efd204a4163e39b86c3d7a27f1e81052713179c5a39fea89b5e5 +5f7ddf87911339a827bdef19ab239624e7c0617ec03e0a6fb4fa29fe6e0b05fa +c50a614158995dfed1235c3b39fa966d848633c5a740632d285edce385929d15 +0d389b43f47da2171ca336cded4a0851470cc086c04a466e4cf03fddb92f9c20 +1f7c732e4a8077527ba27743f9dd4e207b97a1f7cd53778a99f64b092d66f4f9 +1b6a3455a72666386fbc9dd06631a041ae1c63452b5a0480fa75e9a5eeedb8d2 +7bd88740e3d38d5e954d622aacf4342f536ca534cab1e34d352f706b06e04630 +169bc810621d52699cedb96d4796ae1cc28fee4ba7e2223e77faafb9160e3571 +c013b910f1c61fe188625f318ffcc0a10f614d5716e806f14326aad495ea90a4 +4f7bcf589dba538895d4d3da8b5871eeea731f956594bf088a9c4a67794cf661 +ffb389ca93696eb5fb9589aa2c19f43cfeb41cac18b736775017ad51339e5ccf +de061c17b697242189fe127db52d26407b204a664a4d4ef5428ca588f07d5b3e +8d19ad7d2437cdafa87353498a304838433dd2b372b15ed83e7969a11f793b58 +40c2d5161aa2f7398f754e2ab2721cfa51915c1795bfdc775012050ac793768b +960744ec1b1e34a02bd28a03660e0da853be50177e0a22fe9e8355cebf20ee28 +332ac812ab318ab5a391fe54f18fb88d9effdbabffc20ca9a16d9ef29ea37b8d +5a10f7d36fb1e102528c65f9535683cbe3e31a5d5d1274ec5c7e57042b9b5126 +38015154d7080dc6068f4a5cad76cd02ccce389db91c27d9eeaaeb619569a4da +f8c6375fd2e2876111e6d481192007eb92f84674583ff8d706e922d31e97178d +1a0e968e64ceb0a703df1e3de767135b655e569c6fa83e1713b15532205a736f +cc3899b0df69a87d53a2f065f69988b35cbd395427bc6e6b688cc3d4a11bf0f4 +311b75cfab9955f347a91c8f3245c8fb5555075e8a3d529f33aedba49aaec0c6 +04a19a7bc5ed45f2f09c7548f6f59b933e96350221fb10d2e654e52f508060ac +b0082531fc830e5f4b059731a81ac8e36a2ad89735ecec3d1c30aea57af5d4da +a8769c1801f817e4f29c2214ec66d58c3918a9f233133120541f4938c0c8ab6a +e2dbf3b0deeb140cb17070d75a64e4b41a169534dd99ad8ee635779da4b131be +e1165e25aa26a2127fdcab0738d769117d8c4b7ee4dcf2caff4e126fa83dd96d +0373bfcda5e1a920756329ff21cd4445ebda128a491860b193a4d97d5605acb9 +9610029edc11f240a776c45f55997f7d94e5346e1a94d9d8c9ce272d16331f42 +e6158bd248136122b06bf617d6e51977f2ef2ca94fbfbec1ed369ed566da0a3f +0011484eea81b59772c52834f41208c87b06bcd4dda705404082ccd6280fe7c5 +72e8e5f7279d16bdb543488fdcdbc01e3781c3f2f1343c805c2f5d3b3b5ef19f +ebc207585693f4ad3b5333260b10a3fd73ae4c496d62bd0abf05f089a89ab658 +aadceec15421d25fbe0c5df76884133b05214e327cf0f6b872bd93160f69435c +fb012578b281d2d38ba93de5d992574e0ee2f0dad835146f4cec5373b1213fa3 +c8198b7dfbf455d73a7cc6fd50c37b7adcfb6d5c6b5be7c66bbcfe1f58245626 +96a7369a9d01fd31b358cdd12738bc129f571396931b3d14e65866e5881e92c0 +c57ce463d9af9663b21a4c47fe605cd91d220a72d57c5f5217031634e59a7fdc +784d90821ad69adf1bff61844e9f87bb12576a97d6a658daff1c8dfc6815df7e +8dc35d4dde5b42c440259bda1f8112756a956aeb85e59da6b13030837403d79b +726b4cea02e999a2bfdfe58428731cfaddba5504de48dbfc609d7989ebe36b0e +b4eaa7e5c3f285d51f3898d1b2e8d3e653374014629b506b8b3fc0bcdab045e0 +8a43aa4513e2355dcc5ac7a703c31dcaa61f24213832aca3bbc7e342d7ad27f3 +4152ae1fe6f4e28eba9245faf38fc3266cd5ae400635942efd22f0ff9dca428f +ce3a8d7d19b8eaa5b36f4e0057b37f83f1b10a83b5d1aab002d6d63bec695e6c +2b46ffa670650aa4f2dc3578114987faa786de2d6db7e6e6872282d0a86e1b82 +1cfb6be029aebf854dac8c88f35dab7cdd4a9ed0077dc7ba7c39a34df81662c3 +3a5f558328bd31934517e79a53563d330b41105a5329d1fa7053820da39a811d +74c4a92a9ee3f923a26d86c59a8908b9a042e1981da48642ff2298a9b05a5878 +5566e7be4c0aa5e34759faaefc41dfbbfc3af607411349681b5030e287d0b577 +a3eafa4753e746f1d71fd7a6915f7708cd60d15ecc6ce797ba3798a93265a03a +874a07745af0df81363002f3aadd88cb95d5fbb6c45fb044e4ce9e09502003d8 +7c4bef2b82b63f91910a0d4ead2f1ea8c8ba01dffbfade76731a8690dd289a7b +71ed0c03819641772101c6bf4c433ccc585d18f93f26fa41fdffe0ef8294296a +b9172a28f500fe5b75eef97ee0165ba4a878084ae651784d5de65f5b65cc479b +04116a57611681eba68c09f82efec26ae0c60ac40424bb0fdc8b987b75875464 +f59dd2e0b62dba0b3fd820cb03f00c2f7babbdf5e24267b9038b45966cb2ff3b +115ca8b0af271afd2b574a0153eebd04a87ab4b418c6a554682b3d2b5420d0e2 +e23e16ceb4953105df0355be7f31c233af2c0153858030f9fb16e7e9b4795718 +7b436b9788c463c7e8d8ab67a6cad843d27dce5caefedc3a76ec535ec979093e +723ca8bd8d0234e1f39973064946c79b93fc892e7b24cefce88d099b821a69c7 +7324c9ccf28db4b97f844fdcca54012b142a6f560426674c19839f5d776b29c4 +424979e3a16e398e7a792a5e92a7eee5727b6d033e3f305e204ce370dfe40997 +b7a84f7eb97795b9e243c8fd58ea4cc7371d9ad3949f1c8e9c174cb9af2b0c28 +633cfbce09b4a380aa29e9199e055d891e3d89d5589c5e83e8aa7770220551d1 +b10a88550cf10372add5884010c25359e45c821611a71adeeff841d5d8068918 +68f204fcb9f4c9493c8d91cc039baeb898efc4b5eec85623bfc6fdbf5bce605f +5c7c618e19ac01c68961d702b17d16d31368a0b7c3bc46c5b6da34a546e31b5b +c9ed437ae5209c91433d0e8df0021e606294a22edc3a02ece80bbd267bc3a1e4 +1ce2f5272f1db7002aac2a8d7dc2a649c8316662a941f6baf7fb8ee7e86922c2 +75588ff6af85f540bbcc5a380d86e81a37bf88a3c57a8deaed33d274e87720be +2d99585c5029538b2fee86082598a139ec39ca4e061c137f1ff59cfc69120c28 +3e654ecb7cc48649900801bb329736c7bf21b07ffba69534036cb85dc5f29396 +9ab322e19804863da9c5f0860ebadc5228badb80cfd4e9f31bc0052430e0f3cc +0b63b1cff9fa9f4467d43262d4f63eeae49ff8d1560ec55a06a3a92fdcf158bd +5089f8b188d3095666d4aa9679ffebc6786940132d259d42e7153760de7b6adc +d3e6056db55f124726cb20d0ac763b67c727e9789979882578ef2ae32c8d0a9e +2e2947f7ba52cf89944a36cd2f2e5dc4a02656202cb49ba081569584a335be14 +9cb5bd5b785123b7cd202158ba98a831edc01d6a461ba2641c07150d3f55b292 +bcf9c69d619746c9fc9d444a6132c5fc9ed2228bef99ca5c7e6dc772f194a1e7 +7a54a8d99c5e665422be3f13bd4e104e69ad02a479ac3c9ff61bb2e74dfa9735 +e80a744cc4d4674c5b33e674eec87362da4012b98ed0e7f05d75073897a40bc8 +d66140db1a850483fdd4606b3110ab5d7a6bb6229a6df028e8c8c62538a85884 +0abd25dcc84bfe9d13fe4ef567165eb72e0e246826cc67d0f35bcec135c2d4f7 +433f278e9948eb91b30f0c11de38e1c9b7484c5e3970b09d37334df686c704b7 +77fe267a0ce2ad7a5887e5dff00640e3f619dfcab32fbc28192876018f4fa492 +b2ed5983a9a1325acc22366a8c5c94412d26b75eee6a2bd08d3d2d9247d0673b +59e680ad1d3432849a695c8910b686533f3bd7d64c3fa3e9ccd76475b4e2d079 +0b9e58f792d619b0cc48defcf09cd6855293975b75e38847041662a1899686b7 +74d2bbeaeab5431d53aa8c380a57703a21c1306472c4420d33076c25a2bd2710 +cd7cbe3616afe747a410e03387ff9c5951a89c8818af2879d95d74c5c0734c5a +c84218c219a639ad2e8329e55f6d339c03c64452aaab6608a0829f6979a745ac +d351cdc8b67f351549aa6df608197e0eb65718f47b5513bbfbad13a5e32adcd4 +e7869dcfd53b918282c5916f756f6e8eac46cf58f5e9de2d073a4bdd54a54d0b +f2f4a61432c62430c1f9eb783018d1c7be62df2514f562f3a285e9584819c8da +91e15749bd71197cd549ef0f89638f560f42a3e02a9dc69a93da820d3748b983 +b1409f29e499401bd76037e195f9c50895b1034089d2bf6fa736591ef5cad597 +836512b623f94e85907d7706b8e3c0686b93432e3d3bf7f42c98de62ad150fdf +ee1569f3d3b8aad8fe31f00fed1c767736e9dc189d1ef18979d1725538b060bb +2dac78c707f717a0ecf9bb9f222ef8aff9fda74c4f07ea07b6f52d8b3bc3f02d +763abd9b9bb4305f4707fcd03750e033d502e9e69bbc3db91f4fc1ab9356f1e8 +b66649370d6e1099250e0638d0b5688bfff1bb8dc7ea038a7163502eee800e53 +a1bda9971e2ac70b7489492bafa8ef42dfe4851f9f1cc7c2c95a40ab25db455c +12b42cb94aebc3b1b3d7cabdbef637205ec1dec48bf04fe2c86c3f41ff127108 +9d8e5c37f7d406d743962f7fe013149b4c1291d9573a544f2bc8e2fea78fb276 +c5ea8cd6583182ee34fcd8ccdc4dbb7273f848b2c2005dae6e43f99086dd21b1 +0756bb1258696753248513daeaff92bfeaae1eabe8c063491a5fd6c00e1f445c +cc1ec75c816d6d27e62bc657ed551328c3b85afcd1ca9b09d00373f0053ff68c +97605c183bf8c30a2bfed48a3245ef6b584398f62024642832c88f24a24d3a01 +be6f512b9c3623843d388c792bc4add0805343713d7535f6a1d03d4a2fce724a +b91c4977150914ad0a34fef0addb71980c0a764375d91b86e9f379c438562dcf +11686d0794d26b07d4c59febaff8a93c43946d987e6c4b6ad650c932cd595fa5 +a2b46b2802463c70449af8e61fa30c6e83c748a33be7d81476376064716e3197 +f8703d525f95c6a2ddae5b66a9561d8b1440915286c30c345f599ac82fdd1a12 +a5be554ec240b610383f34d85a1ed94466ee7c0cd5cc1676570a73ac9c6d80df +f71c2b487882da466f9a08a2cd963653dc67957514976be58d40a12e9ff9962e +3407c304c750f81a7bfb458a44dcd8a04f8742c8d7ad67b9bc8e4fb9bd425abe +af4a2714d56d23dd7fe79d99c5d935b2b97d82415e55f326135fcf51db7e4a81 +8e6177e53ce48a628514e93ad45782277eeb78f5dbb51908db22e74825d31478 +f4a9f5ecd373d6f4fda7b89dcc1d124c3d09265a8835ef1b36c31cb078b4de28 +3435ae9df3477504a90b52a788093f0ee924d382b380295faba3c35f56b8f46b +0bfbe880af354d949dc30f0869b9ccb3f194782f4f784c37b79f575ed5dbb38a +d3819a668e204d528f6d6e05ba0a45371f7656c6d1be0aff866f9fa6a8ce5654 +fa485ab31cf114a531b1b674371119eb36ccba3350c58ec35af3c410c393f0a5 +d6c2149856ddaf28ed279ef64a66a77297f131a9981ca618b5941f28af7ee370 +30a59da5e4175b5806a786d4981081b31d306b96f4c7a54e024ea32b8892b12b +6161f3c880242602476dff9070e24a364d40e9a5fde87b26535e9f892c778c50 +98e10efa0b5b661971a3a018028789a71b363c7a62ed0944b0c2cbba0c79e4bb +9f7a05b1dc1fcc278e2546201c9d23ba42d67d68d1f4614b3735cbd6f50dc46f +8172cb5d3b6d099e43499c2c0b14c58aecacf63b00a58204f99026dc45994d28 +6de59019e2275322d4ce46ebe5ed630489886160a2bf9a7099abb49a864a6e0b +a9446b97ed62b61926520d26201f31a803e4bbd8c9bf89d154f3005950dd5721 +e7d1ccd7982ca0beca6a8cd2dcae488fd9edea9f09ecacc6b430ad9e644bfd94 +f43177ef3eaca6f2b22ed5c1f61657102792f438a6a8bcc721cf54d445ae5973 +ed53eef181537f66fe15498f408fce30eb7348a97857391ab7532865f48f7240 +5040adf2af45da7b6f5b03d8a37a94a2647936865b470ecd43dc0d4d72269950 +f0a668b72e6001519f6934380b80a2758686d4f99a618fc4bb61abbb58eddd87 +7bc4f0aabd28d596fb613ccffb0f26a75e53a7c7fd432754422538424fdbd636 +be60414dbede5fa639eeca055c7d0d0f80a121c24f3b2402f98ac91dea0d06de +0e1faab1c2e4ce5172a48a417c210c2ee4619edcadc89c4b69aec28c8b2efb81 +e37a006366876e99eaa815b69837baa67778e5e359fd316570fb52880a9ca629 +97dd0dbf406138783d84792cf7616dbf2c7a31825aa33670c6bdec650ca2698c +5c8546a3966159d66473b07c4c99f2d48c95238ad5352a1cb2f06afdd953475a +4e5dda657bb5f5f834b29b30fc9d9aee7f4d8797dcee9a35cfeb066d8317fb4a +41924f4a2e65cea7cb1fa8114e9e31c4be6847b0547b9712df4cdcf490709df9 +e76cb3fd933b03b8b7c786790c6ed880458500a3c66ae48306a3dacce3fc1663 +b0d7e2850a7d9d22c4e2b183ec58bfbf818b4fb7717ae53cf58d9b52020c02af +1686682b215aae195d6c82abf3d27a82a28b2a580a79c88ea264b478196848b3 +f8789685914564daec64c7798d8ceca706aecdbdf57ad457eb1b5058dd8d081b +b125ecd5b6c8cd541f4fe62c9c48a708df183f53b8ee3d1226bb909492ba6878 +e837627727fa290c2e9296f29991a366a2977ef4ee9c1b9a4635b424b78b0a92 +eea383038fd13201bf9724313c7bef7f3f86a6b854375077625cfd5c90de6f49 +c8f7a0da7c5f31b611ecabb893e90a470ca1bfced8b4b34c757869d0778a4934 +2a73cf77653d660d6815e3fe282d9d172522f351c58ee095b7dcdf3196b59c39 +20309447c3dc2e1679ca39c9efc65b587f0e4c879c8542869bee1ef90f562fb8 +02323011b77fd8e079009aabd0011f382de66d9cd74a581b8810251482c985ec +af0ca59367f51819c4532af37a5bd5926744b46a03f43da0560bd0eead27310e +3a3e522593a807ad4b8f800960f78894cb757e82f3476a2724d0ae623f5460f1 +67bf93d0b305322dca45e038a56b299c7ed6dff66fd747bfa55947b9ecb485db +681af9d82546e9096ae4d6172dcf0aff907642ef8d57ea3f84921041b8a29c94 +d5a8e867bb5d85576e08324ed1c18b9384fb2c0f5fa5aa87f48d4f2f6f2ed3ac +0cdadc949455fce9165d5e5f5bc4bf4d6314ae8ab1708d2774f95a808ac809fe +565d77765add2900affc +0000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000 +cleartomark diff --git a/gs/lib/chess.ps b/gs/lib/chess.ps new file mode 100644 index 000000000..3200f1eab --- /dev/null +++ b/gs/lib/chess.ps @@ -0,0 +1,101 @@ +%!PS-Adobe-2.1 +%%% HOW TO USE: from Unix, "cat Cheq Example | lpr -Pprintername " +%%Title: Cheq.cheqtxtx +%%Creator: Glenn Reid and still.ps (V 1.0d release 10 edit 08) +%%BoundingBox: (atend) +%%Pages: (atend) +%%DocumentProcSets: Adobe_distill 0.95 +%%EndComments +%%BeginProcSet: Adobe_distill 0.95 +/PROLOGUE 30 40 add dict def + % 30 procedure entries + room for 40 cached font dictionaries + PROLOGUE begin + /clip { } def % causes problems. remove if "clip" is needed + /bdef { bind def } bind def /ldef { load def } bdef + /T { moveto show } bdef /A { moveto ashow } bdef + /W { moveto widthshow } bdef /AW { moveto awidthshow } bdef + /f /fill ldef /R { { rlineto } repeat } bdef + /r /rlineto ldef /L { { lineto } repeat } bdef + /m /moveto ldef /l { moveto lineto stroke } bdef + /x { 0 rlineto } bdef /y { 0 exch rlineto } bdef + /c /curveto ldef /cp /closepath ldef + /s /stroke ldef /w /setlinewidth ldef + /g /setgray ldef /j /setlinejoin ldef + /d /setdash ldef /F /setfont ldef + /C /setcmykcolor where { /setcmykcolor get }{ %ifelse + { %def + 1 sub 3 { 3 index add neg dup 0 lt { pop 0 } if 3 1 roll } repeat + setrgbcolor + } bind + } ifelse def + /MF { findfont exch makefont setfont } bdef + /DF { findfont exch scalefont setfont currentfont def } bdef + /BEGINPAGE { pop /pagesave save def } bdef + /ENDPAGE { pop pagesave restore showpage } def + /REMAP { %def + FontDirectory 2 index known { pop pop pop } { %ifelse + findfont dup length dict begin + { 1 index /FID ne {def}{pop pop} ifelse } forall + exch dup length 0 gt { /Encoding exch def }{ pop } ifelse + currentdict end definefont pop + } ifelse + } bdef + /RECODE { %def + 3 -1 roll 1 index findfont /Encoding get 256 array copy exch + 0 exch { %forall + dup type/nametype eq + { 3 {2 index} repeat put pop 1 add }{ exch pop }ifelse + } forall pop 3 1 roll REMAP + } bdef + end %PROLOGUE +%%EndProcSet: Adobe_distill 0.95 +%%EndProlog +%%BeginSetup +PROLOGUE begin + +%%EndSetup +%%Page: 1 1 +%%PageFonts: (atend) +%%PageBoundingBox: (atend) + + +%%%%%% Following line added by Aladdin Enterprises: +%%%%%% load the font explicitly so it doesn't have to be in Fontmap. +(cheq.ps) run + + +1 BEGINPAGE +1 1 1 0 C +/F1 12 /Times-Roman DF +(Cheq \(gift of Adobe Systems\) "Chequed Board") +72 756 T +(p. 1) +558 756 T +/F2 30 /Cheq DF + + +%%%%%% Following line added by Aladdin Enterprises: +%%%%%% scale up and relocate the image. +-140 -800 translate 2 2 scale + + +( ________) 72 714 T +(/R\366B\316K\365N\345\\) 72 684 T +(/\270P\270P\270P\270P\\) 72 654 T +(/ x x x x\\) 72 624 T +(/x xQ\360 x \\) 72 594 T +(/ x x x x\\) 72 564 T +(/x x \317kx \\) 72 534 T +(/p\271p\271p\271p\271\\) 72 504 T +(/\250n\272q\373b\265r\\) 72 474 T %%%%%% 277?? +( --------) 72 444 T +2 ENDPAGE +%%PageTrailer +%%PageFonts: Times-Roman Cheq +%%PageBoundingBox: 20 20 576 756 +%%Trailer +end %PROLOGUE +%%Pages: 1 +%%BoundingBox: 20 20 576 756 +%%DocumentFonts: Times-Roman Cheq +%%EOF diff --git a/gs/lib/colorcir.ps b/gs/lib/colorcir.ps new file mode 100644 index 000000000..d8360d4ff --- /dev/null +++ b/gs/lib/colorcir.ps @@ -0,0 +1,120 @@ +%! + +gsave +/Times-Roman findfont 24 scalefont setfont +72 72 translate 0 0 moveto 1 0 0 setrgbcolor (Red) show +72 0 translate 0 0 moveto 0 1 0 setrgbcolor (Green) show +72 0 translate 0 0 moveto 0 0 1 setrgbcolor (Blue) show +72 0 translate 0 0 moveto 1 1 0 setrgbcolor (Yellow) show +72 0 translate 0 0 moveto 1 0 1 setrgbcolor (Pink) show +72 0 translate 0 0 moveto 0 1 1 setrgbcolor (Cyan) show +72 0 translate 0 0 moveto 0.9 0.9 0.9 setrgbcolor ('White') show +grestore + +0.0 setlinewidth + +/hsvcircle { +gsave + /h 0.0 def + 0 4 360 { + pop + gsave + 0.5 0.0 translate + + newpath + 0.0 0.0 moveto + 0.1 0.0 lineto + 0.1 0.02 lineto + 0.0 0.02 lineto + closepath + h 1.0 1.0 sethsbcolor + fill + + %newpath + %0.0 0.0 moveto + %0.1 0.0 lineto + %0.1 0.02 lineto + %0.0 0.02 lineto + %closepath + %0.0 setgray + %stroke + + grestore + /h h 4 360 div add def + 4 rotate + } for +grestore +} def + +/graycircle { +gsave + /h -1.0 def + 0 4 360 { + pop + gsave + 0.5 0.0 translate + + newpath + 0.0 0.0 moveto + 0.1 0.0 lineto + 0.1 0.02 lineto + 0.0 0.02 lineto + closepath + + h abs setgray + fill + + %newpath + %0.0 0.0 moveto + %0.1 0.0 lineto + %0.1 0.02 lineto + %0.0 0.02 lineto + %closepath + %0.0 setgray + %stroke + grestore + + /h h 8 360 div add def + 4 rotate + } for +grestore +} def + +0.0 setlinewidth +0.0 setgray +300 400 translate +500 500 scale + +30 rotate +1.0 0.7 scale +-30 rotate + +hsvcircle +0.8 0.8 scale +graycircle +0.8 0.8 scale +hsvcircle +0.8 0.8 scale +graycircle +0.8 0.8 scale +hsvcircle +0.8 0.8 scale +graycircle +0.8 0.8 scale +hsvcircle +0.8 0.8 scale +graycircle +0.8 0.8 scale +hsvcircle +0.8 0.8 scale +graycircle +0.8 0.8 scale +hsvcircle +0.8 0.8 scale +graycircle +0.8 0.8 scale +hsvcircle +0.8 0.8 scale +graycircle + +showpage diff --git a/gs/lib/cp.bat b/gs/lib/cp.bat new file mode 100755 index 000000000..a40a63ff8 --- /dev/null +++ b/gs/lib/cp.bat @@ -0,0 +1,10 @@ +@echo off +if "%2"=="." goto ne +erase _.tmp +rem >_.tmp +copy /B %1+_.tmp %2 +erase _.tmp +goto x +:ne +copy /B %1 %2 +:x diff --git a/gs/lib/decrypt.ps b/gs/lib/decrypt.ps new file mode 100644 index 000000000..9cc8b2f17 --- /dev/null +++ b/gs/lib/decrypt.ps @@ -0,0 +1,13 @@ +% Decrypt an eexec-encoded file. + +(t.in) (r) file /in exch def +(t.out) (w) file /out exch def +256 string /buf exch def +55665 % eexec encryption seed + { in buf readhexstring /more exch def + dup .type1decrypt out exch writestring + more not { exit } if + } loop +in closefile +out closefile +quit diff --git a/gs/lib/docie.ps b/gs/lib/docie.ps new file mode 100644 index 000000000..9e7419047 --- /dev/null +++ b/gs/lib/docie.ps @@ -0,0 +1,219 @@ +% Copyright (C) 1995 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% docie.ps +% Emulate CIE algorithms in PostScript. + +% ---------------- Auxiliary procedures ---------------- % + +/r1default [0 1] def +/r3default [0 1 0 1 0 1] def + +/apply3 % [ ] apply3 + { { 4 -1 roll exch exec } forall + } bind def + +/restrict % restrict + { 3 1 roll .max .min + } bind def + +/restrict3 % [ ... ] restrict3 + { aload pop + 7 -1 roll 3 1 roll restrict 7 1 roll + 5 -1 roll 3 1 roll restrict 5 1 roll + restrict 3 1 roll + } bind def + +/rescale % rescale + { 1 index sub 3 1 roll sub exch div 0 .max 1 .min + } bind def + +/rescale3 % [ ... ] rescale3 + { aload pop + 7 -1 roll 3 1 roll rescale 7 1 roll + 5 -1 roll 3 1 roll rescale 5 1 roll + rescale 3 1 roll + } bind def + +/mmult3 % [ ... ] mmult3 + % + { 4 -1 roll dup dup 6 -1 roll dup dup 8 -1 roll dup dup + 10 -1 roll { 10 -1 roll mul } forall + % Stack: u1 v1 w1 u2 v2 w2 u3 v3 w3 + 4 -1 roll add 6 -1 roll add + % Stack: u1 v1 u2 v2 u3 v3 w' + 7 1 roll 3 -1 roll add 4 -1 roll add + % Stack: w' u1 u2 u3 v' + 5 1 roll add add 3 1 roll + } bind def + +/minvert3 % [ ... ] minvert3 + % [ ... ] + { 16 dict begin + aload pop { I H G F E D C B A } { exch def } forall + /coa E I mul F H mul sub def + /cob F G mul D I mul sub def + /coc D H mul E G mul sub def + /det A coa mul B cob mul add C coc mul add def + [ coa det div + C H mul B I mul sub det div + B F mul C E mul sub det div + cob det div + A I mul C G mul sub det div + C D mul A F mul sub det div + coc det div + B G mul A H mul sub det div + A E mul B D mul sub det div + ] + end + } bind def + +/print1 + { print dup == + } bind def + +/print3 + { print 3 array astore dup == aload pop + } bind def + +% ---------------- Mapping to XYZ ---------------- % + +/csmap % csmap + { 3 index /RangeLMN .knownget not { r3default } if restrict3 +DEBUG { (After RangeLMN Decode: ) print3 } if + 3 index /DecodeLMN .knownget { apply3 } if +DEBUG { (After DecodeLMN Decode: ) print3 } if + 3 index /MatrixLMN .knownget { mmult3 } if +DEBUG { (After MatrixLMN Decode: ) print3 } if + } bind def + +/csciea % csciea + { 1 index /RangeA .knownget not { r1default } if restrict +DEBUG { (After RangeA Decode: ) print1 } if + 1 index /DecodeA .knownget { exec } if +DEBUG { (After DecodeA Decode: ) print1 } if + 1 index /MatrixA .knownget + { { 1 index mul exch } forall pop } + { dup dup } + ifelse +DEBUG { (After MatrixA Decode: ) print3 } if + csmap + } bind def + +/cscieabc % cscieabc + { 3 index /RangeABC .knownget not { r3default } if restrict3 +DEBUG { (After RangeABC Decode: ) print3 } if + 3 index /DecodeABC .knownget { apply3 } if +DEBUG { (After DecodeABC Decode: ) print3 } if + 3 index /MatrixABC .knownget { mmult3 } if +DEBUG { (After MatrixABC Decode: ) print3 } if + csmap + } bind def + +% ---------------- Rendering from XYZ ---------------- % + +/lookup3 % lookup3 + % + { 3 -1 roll 3 index 0 get 1 sub mul + 3 -1 roll 3 index 1 get 1 sub mul + 3 -1 roll 3 index 2 get 1 sub mul + % Stack: rtable ia ib ic +DEBUG { (RenderTable indices: ) print3 mark 5 1 roll } if + 3 -1 roll round cvi 3 index 3 get exch get + % Stack: rtable ib ic string + 3 -1 roll round cvi 3 index 2 get mul + % Stack: rtable ic string ib*nc + 3 -1 roll round cvi add 2 index 4 get mul + % Stack: rtable string index + 2 index 4 get getinterval + % Stack: rtable bytes +DEBUG { (RenderTable values: ) print (<) print (%stdout) (w) file 1 index writehexstring (>) = } if + } bind def + +/bpdefault [0 0 0] def + +/crmap % crmap ... + { +DEBUG { (CIE XYZ = ) print3 } if + 3 index /MatrixPQR .knownget { mmult3 } if +DEBUG { (After MatrixPQR: ) print3 } if + 4 index /WhitePoint get + 5 index /BlackPoint .knownget not { bpdefault } if + 5 index /WhitePoint get + 6 index /BlackPoint .knownget not { bpdefault } if + 4 + { 4 -1 roll aload pop + % Stack: csdict crdict x y z pt pt pt px py pz + 3 copy 12 index /MatrixPQR .knownget { mmult3 } if 6 array astore + } + repeat + % Stack: csdict crdict x y z wps+ bps+ wpd+ bpd+ + 9 -1 roll pop % get rid of csdict + 7 4 roll + 7 index /TransformPQR get + { % Stack: crdict wps+ bps+ wpd+ bpd+ u v w proc + 8 copy exch pop exch pop + exec exch pop 4 -1 roll pop + } + forall + 7 3 roll pop pop pop pop % get rid of White/BlackPoints +DEBUG { (After TransformPQR: ) print3 } if + 3 index /MatrixPQR .knownget { minvert3 mmult3 } if +DEBUG { (After MatrixPQR': ) print3 } if + 3 index /MatrixLMN .knownget { mmult3 } if +DEBUG { (After MatrixLMN Encode: ) print3 } if + 3 index /EncodeLMN .knownget { apply3 } if +DEBUG { (After EncodeLMN Encode: ) print3 } if + 3 index /RangeLMN .knownget not { r3default } if restrict3 +DEBUG { (After RangeLMN Encode: ) print3 } if + 3 index /MatrixABC .knownget { mmult3 } if +DEBUG { (After MatrixABC Encode: ) print3 } if + 3 index /EncodeABC .knownget { apply3 } if +DEBUG { (After EncodeABC Encode: ) print3 } if + 3 index /RangeABC .knownget not { r3default } if + 5 -1 roll /RenderTable .knownget + { % Stack: u v w ranges rtable + 5 1 roll rescale3 +DEBUG { (Rescaled ABC: ) print3 } if + % Stack: rtable a b c + lookup3 + % Stack: rtable bytes + 0 1 3 index 4 get 1 sub + { % Stack: values rtable bytes c + 2 copy get 255 div + % Stack: values rtable bytes c v + 3 index 3 -1 roll 5 add get exec 3 1 roll + } + for pop pop +DEBUG { (After RenderTableT: ) print ] dup == aload pop } if + } + { restrict3 +DEBUG { (After RangeABC Encode: ) print3 } if + } + ifelse + } bind def + +% ---------------- Top level control ---------------- % + +/mapdict mark + /CIEBasedA { 1 get exch csciea currentcolorrendering 4 1 roll crmap } bind + /CIEBasedABC { 1 get 4 1 roll cscieabc currentcolorrendering 4 1 roll crmap } bind +.dicttomark def +/mapcie % mapcie ... + % mapcie ... + { currentcolorspace dup 0 get //mapdict exch get exec + } bind def diff --git a/gs/lib/escher.ps b/gs/lib/escher.ps new file mode 100644 index 000000000..c17bf0f4b --- /dev/null +++ b/gs/lib/escher.ps @@ -0,0 +1,379 @@ +%! +% If you're concerned that the cpu in your PostScript printer will atrophy +% from disuse, here is another Escher-like contribution to to keep it busy +% for a while. It uses PostScript color commands, but will still work on +% a monochrome printer (but isn't very pretty in black & white). +% +% The butterflies are arranged in a hexagonal grid (wallpaper group p6), +% and the moveto, lineto, curveto commands used to render the tesselation +% are redefined so as to impose a nonlinear transform that shrinks the +% infinite plane to an ellipse. This is a sleazy way to mimic Escher's +% "circle limit" sorts of things. +% +% The butterfly permimeter was made by imposing all the symmetry constraints +% on a path, and then that path was filled in using Adobe Illustrator +% +% The routines Xform and next_color are easy to change if you want to hack +% with them. The code was written to sacrifice efficiency for readability. +% +% Bob Wallis +% +% UUCP {sun,pyramid,cae780,apple}!weitek!wallis + +%statusdict begin waittimeout 6000 lt % if you have a slow printer, you +% {0 60 6000 setdefaulttimeouts} % might need to uncomment this +%if end + +/nlayers 1 def % 1 takes about 10 minutes on a LW+; 2 takes 4x longer +/warp 1 def % 1 -> ellipsoidal distortion; 0 -> flat Euclidean +/inch {72 mul} def + +/x4 152 def /y4 205.6 def % 6 fold rotation center of bfly +/x12 387.20 def /y12 403.84 def % 3 fold center of bfly + +/dx x4 x12 sub def % [dx,dy] = distance between the +/dy y4 y12 sub def % two fixed points above + +/Dm dx dup mul dy dup mul % magnitude of basis vectors of + add sqrt 3 sqrt mul % parallelogram lattice +def % = |dx,dy| * sqrt(3) + +/Da dy dx atan 30 add def +/D1x Dm Da cos mul def % [D1x, D1y] = basis vector vector #1 +/D1y Dm Da sin mul def % = [Dm,0] exp(j30) + +/Da dy dx atan 30 sub def +/D2x Dm Da cos mul def % [D2x, D2y] = basis vector vector #2 +/D2y Dm Da sin mul def % = [Dm,0] exp(-j30) + +/m { moveto} def +/L {lineto} def +/S {stroke} def +/c {curveto} def +/f {closepath fill} def +/F {closepath fill} def +/g { setgray} def + +/FillStroke { % fill interior & stroke black border + closepath gsave fill grestore 0 setgray stroke +} def + +% +% Description of 1 butterfly +% +/body { + 314.96 280.19 m + 383.4 261.71 445.11 243.23 513.52 224.68 c + 463.68 256.59 490.26 328.83 446.99 360.76 c + 423.71 347.32 397.08 339.7 367.07 337.9 c + 388.93 358.28 414.14 372.84 442.73 381.58 c + 426.68 398.18 394.07 389.7 387.2 403.84 c + 371.52 404.96 362.56 372.48 340.16 366.88 c + 346.88 396.01 346.88 425.12 340.16 454.24 c + 326.72 427.35 320 400.48 320 373.6 c + 270.71 352.1 221.44 411.23 168.88 384.02 c + 189.04 388.03 202.48 380.4 212.57 366.95 c + 216.72 350.85 209.23 341.46 190.1 338.79 c + 177.34 343.57 167.94 354.17 161.9 370.59 c + 176.06 305.52 132.02 274.05 152 205.6 c + 201.29 257.12 250.56 234.72 299.84 279.52 c + 288.64 266.08 284.16 252.64 286.4 239.2 c + 298.27 223.97 310.15 222.18 322.02 233.82 c + 328.62 249.28 328.51 264.74 314.96 280.19 c + FillStroke +} def + +/eyes { + 294.8125 238.3246 m + 296.9115 238.3246 298.6132 242.7964 298.6132 248.3125 c + 298.6132 253.8286 296.9115 258.3004 294.8125 258.3004 c + 292.7135 258.3004 291.0118 253.8286 291.0118 248.3125 c + 291.0118 242.7964 292.7135 238.3246 294.8125 238.3246 c + closepath gsave 1 g fill grestore 0 g S + + 319.5 241.1782 m + 321.7455 241.1782 323.5659 245.4917 323.5659 250.8125 c + 323.5659 256.1333 321.7455 260.4468 319.5 260.4468 c + 317.2545 260.4468 315.4341 256.1333 315.4341 250.8125 c + 315.4341 245.4917 317.2545 241.1782 319.5 241.1782 c + closepath gsave 1 g fill grestore 0 g S + 0 g + 296.875 242.0939 m + 297.4608 242.0939 297.9356 243.479 297.9356 245.1875 c + 297.9356 246.896 297.4608 248.2811 296.875 248.2811 c + 296.2892 248.2811 295.8143 246.896 295.8143 245.1875 c + 295.8143 243.479 296.2892 242.0939 296.875 242.0939 c + f + 0 g + 318.5 243.7707 m + 319.281 243.7707 319.9142 245.0766 319.9142 246.6875 c + 319.9142 248.2984 319.281 249.6043 318.5 249.6043 c + 317.719 249.6043 317.0858 248.2984 317.0858 246.6875 c + 317.0858 245.0766 317.719 243.7707 318.5 243.7707 c + f +} def + +/stripes { + 292 289 m + 252 294 241 295 213 279 c + 185 263 175 252 159 222 c + S + 285 313 m + 239 326 226 325 206 315 c + 186 305 164 278 161 267 c + S + 298 353 m + 262 342 251 339 237 355 c + 223 371 213 380 201 383 c + S + 330 288 m + 384 293 385 292 418 280 c + 451 268 452 264 473 247 c + S + 342 306 m + 381 311 386 317 410 311 c + 434 305 460 287 474 262 c + S + 345 321 m + 352 357 359 367 379 377 c + 399 387 409 385 426 382 c + S + 327.75 367.75 m + 336.5 392.25 333.682 403.348 335.25 415.5 c + S + 320 364.75 m + 322 361.75 323.5 360.5 326.25 360 c + 329 359.5 332 360.5 334 362.75 c + S + 316.25 356.5 m + 318.75 353.25 320 353 323.25 352.25 c + 326.5 351.5 329 352 331.5 353.25 c + S + 312.5 349 m + 316.75 345.5 318.25 344.5 321.25 343.75 c + 324.25 343 327 344 329.75 346 c + S + 310.75 340.75 m + 314.25 336.5 316.25 335.25 320 335.25 c + 323.75 335.25 327 336.5 329.25 338 c + S + 308.5 332 m + 311.75 328.5 312.5 327.25 317 327 c + 321.5 326.75 325.75 328.25 327.75 329.75 c + S + 305 322 m + 309.5 317.75 310.75 317 315 316.5 c + 319.25 316 322.25 318 324.75 320 c + S + 302.25 311 m + 307 307.5 307.75 306.25 312.75 306 c + 317.75 305.75 320 307.25 323.75 309.5 c + S + 301.25 298.25 m + 304.5 292.75 305.25 292 308.25 292 c + 311.25 292 313.75 293.75 315.75 295.75 c + S +} def +/nostrils { + 0 g + 304.062 227.775 m + 304.599 227.775 305.034 228.883 305.034 230.25 c + 305.034 231.616 304.599 232.724 304.062 232.724 c + 303.525 232.724 303.09 231.616 303.09 230.25 c + 303.09 228.883 303.525 227.775 304.062 227.775 c + f + 304.062 230.25 m + F + 309.562 228.275 m + 310.099 228.275 310.534 229.383 310.534 230.75 c + 310.534 232.116 310.099 233.224 309.562 233.224 c + 309.025 233.224 308.59 232.116 308.59 230.75 c + 308.59 229.383 309.025 228.275 309.562 228.275 c + f +} def +/thorax +{ + 327.5 300 m + 316.5 283 315.5 275.5 308 277.5 c + 294 311.5 299 313.5 304 334 c + 309 354.5 315.5 362 322.5 372 c + 329.5 382 327.5 376.5 331 376 c + 334.5 375.5 339.1367 379.1109 339 369 c + 338.5 332 333.4999 324.5 330.5 311.5 c + 0 g S +} def +/spots { + next_color + 192 242.201 m + 202.1535 242.201 210.3848 251.0655 210.3848 262 c + 210.3848 272.9345 202.1535 281.799 192 281.799 c + 181.8465 281.799 173.6152 272.9345 173.6152 262 c + 173.6152 251.0655 181.8465 242.201 192 242.201 c + FillStroke + next_color + 447.5 250.2365 m + 459.6061 250.2365 469.4203 257.5181 469.4203 266.5 c + 469.4203 275.4819 459.6061 282.7635 447.5 282.7635 c + 435.3939 282.7635 425.5797 275.4819 425.5797 266.5 c + 425.5797 257.5181 435.3939 250.2365 447.5 250.2365 c + FillStroke + next_color + 401 369.1005 m + 409.5914 369.1005 416.5563 373.5327 416.5563 379 c + 416.5563 384.4673 409.5914 388.8995 401 388.8995 c + 392.4086 388.8995 385.4436 384.4673 385.4436 379 c + 385.4436 373.5327 392.4086 369.1005 401 369.1005 c + FillStroke + next_color + 249 348.2721 m + 261.4966 348.2721 271.6274 353.9707 271.6274 361 c + 271.6274 368.0293 261.4966 373.7279 249 373.7279 c + 236.5034 373.7279 226.3726 368.0293 226.3726 361 c + 226.3726 353.9707 236.5034 348.2721 249 348.2721 c + FillStroke +} def + +/ncolor 6 def +/cidx 0 def + +/next_color { + cidx ncolor div % hue + .75 % saturation (change these if you like) + .8 % lightness + sethsbcolor + /cidx cidx 1 add ncolor mod def +} def + +/cidx 0 def + +/max_r2 % radius^2 for center of outermost ring of butterflies + Dm nlayers mul 1.05 mul dup mul +def + +/max_radius max_r2 sqrt def +/max_radius_inv 1 max_radius div def +/Dm_inv 1 Dm div def + +% +% Ellipsoidal distortion, maps "nlayers" concentric rings of cells into +% an ellipse centered on page + +% D length of 1 basis vector separating hexagonal cells +% z0 center of 6-fold rotation = origin of shrink xform +% z' = (z - z0)/D new coord system +% |z'| = sqrt(x^2 + [(8.5/11)*y]^2) aspect ratio of paper +% z" = z' * a/M(|z'|) shrink by "a/M(|z|)" as fcn of radius + +% At the max radius, we want the shrunk ellipse to be "W" units wide so it +% just fits our output format - solve for scale factor "a" + +% zmax = n+0.5 for n layers of cells +% zmax * [a/M(zmax)] = W 1/2 width of output on paper +% a = M(zmax)*W/zmax solve for "a" + +%/M{dup mul 1 add sqrt}bind def % M(u) = sqrt(1+|u|^2) = one possible shrink +/M { 1.5 add } bind def % M(u) = (1.5+|u|) = another possible one +/W 3.8 inch def % 1/2 width of ellipse +/zmax 0.5 nlayers add def % radius at last layer of hexagons +/a zmax M W mul zmax div def % a = M(zmax)*W/zmax + +/Xform { % [x0,y0] = ctr ellipse + Matrix transform + /y exch def + /x exch def + /z x dup mul y .773 mul dup mul add sqrt def % ellipse radius + /Scale a z M div def % z=a/M(|z|) + x Scale mul x0 add % magnify back up + y Scale mul y0 add % [x0+x*s, y0+y*s] +} def + + +/Helvetica findfont 8 scalefont setfont +4.25 inch 0.5 inch moveto +(RHW) stringwidth pop -0.5 mul 0 rmoveto +(RHW) show % autograph + +warp 1 eq { % redefine commands to use Xform + /moveto { Xform //moveto} def + /lineto { Xform //lineto} def + /curveto { + Xform 6 -2 roll + Xform 6 -2 roll + Xform 6 -2 roll + //curveto + } def +}if + + +/bfly { % paint 1 butterfly + next_color body + 1 setgray eyes + stripes + 0 setgray nostrils + 0.5 setgray thorax next_color + spots +} def + +/x0 x4 def % center +/y0 y4 def + +/T1matrix % xlate to center of image + x0 neg y0 neg matrix translate +def + +/Smatrix % scale so that 1 basis vector = 1.0 + Dm_inv dup matrix scale +def + +/HexCell { % 6 butterflys rotated about center of + /cidx 0 def % 6 fold symmetry + /color 0 def + /T2matrix dx dy matrix translate def + 0 60 300 { + /angle exch def + /Rmatrix angle matrix rotate def + /Matrix % translate, rotate, scale - used by Xform + T1matrix Rmatrix matrix concatmatrix + T2matrix matrix concatmatrix + Smatrix matrix concatmatrix + def + gsave + warp 0 eq % then may use usual PostScript machinery + { % else using Xform + x0 y0 translate angle rotate + .5 dup scale + dx x0 sub dy y0 sub translate + } if + bfly + next_color + grestore + } for +} def + + +%320 x4 sub 240 y4 sub translate +4.25 inch x4 sub 5.5 inch y4 sub translate + + +0 setlinewidth +/N 2 def +N neg 1 N { + /i exch def % translate to + N neg 1 N { % i*D1 + j*D2 + /j exch def % and draw HexCell + gsave + /dx i D1x mul j D2x mul add def % translate HexCell by + /dy i D1y mul j D2y mul add def % [dx,dy] + /r2 dx dup mul dy dup mul add def % r^2 = |dx,dy|^2 + r2 max_r2 lt % inside radius? + { % yes + 1 r2 max_r2 div sub sqrt 2 div + setlinewidth % make skinnier lines + HexCell % 6 butterflies + } + if + grestore + } for +} for + +showpage diff --git a/gs/lib/font2c b/gs/lib/font2c new file mode 100755 index 000000000..0d0fcbd2a --- /dev/null +++ b/gs/lib/font2c @@ -0,0 +1,2 @@ +#!/bin/sh +exec gs -q -dNODISPLAY -dWRITESYSTEMDICT -- font2c.ps "$@" diff --git a/gs/lib/font2c.bat b/gs/lib/font2c.bat new file mode 100755 index 000000000..b9daf4095 --- /dev/null +++ b/gs/lib/font2c.bat @@ -0,0 +1 @@ +@gs -q -dNODISPLAY -dWRITESYSTEMDICT -- font2c.ps %1 %2 %3 %4 %5 %6 %7 %8 %9 diff --git a/gs/lib/font2c.ps b/gs/lib/font2c.ps new file mode 100644 index 000000000..50a34a1c1 --- /dev/null +++ b/gs/lib/font2c.ps @@ -0,0 +1,686 @@ +% Copyright (C) 1992, 1993, 1994, 1995 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% font2c.ps +% Write out a PostScript Type 0 or Type 1 font as C code +% that can be linked with the interpreter. +% This even works on protected fonts, if you use the -dWRITESYSTEMDICT +% switch in the command line. The code is reentrant and location- +% independent and has no external references, so it can be put into +% a sharable library even on VMS. + +% Define the maximum string length that all compilers will accept. +% This must be approximately +% min(max line length, max string literal length) / 4 - 5. + +/font2cdict 100 dict dup begin + +/max_wcs 50 def + +% Define a temporary file for writing out procedures. +/wtempname (_.tmp) def + +% ------ Protection utilities ------ % + +% Protection values are represented by a mask: +/a_noaccess 0 def +/a_executeonly 1 def +/a_readonly 3 def +/a_all 7 def +/prot_names + [ (0) (a_execute) null (a_readonly) null null null (a_all) + ] def +/prot_opers + [ {noaccess} {executeonly} {} {readonly} {} {} {} {} + ] def + +% Get the protection of an object. + /getpa + { dup wcheck + { pop a_all } + { % Check for executeonly or noaccess objects in protected. + dup protected exch known + { protected exch get } + { pop a_readonly } + ifelse + } + ifelse + } bind def + +% Get the protection appropriate for (all the) values in a dictionary. + /getva + { a_noaccess exch + { exch pop + dup type dup /stringtype eq 1 index /arraytype eq or + exch /packedarraytype eq or + { getpa a_readonly and or } + { pop pop a_all exit } + ifelse + } + forall + } bind def + +% Keep track of executeonly and noaccess objects, +% but don't let the protection actually take effect. +.currentglobal +false .setglobal % so protected can reference local objs +/protected % do first so // will work + systemdict wcheck { 1500 dict } { 1 dict } ifelse +def +systemdict wcheck not + { (Warning: you will not be able to convert protected fonts.\n) print + (If you need to convert a protected font, please\n) print + (restart the program and specify the -dWRITESYSTEMDICT switch.\n) print + flush + (%end) .skipeof + } +if +userdict begin + /executeonly + { dup //protected exch //a_executeonly put readonly + } bind def + /noaccess + { dup //protected exch //a_noaccess put readonly + } bind def +end +true .setglobal +systemdict begin + /executeonly + { userdict /executeonly get exec + } bind odef + /noaccess + { userdict /noaccess get exec + } bind odef +end +%end +.setglobal + +% ------ Output utilities ------ % + +% By convention, the output file is named cfile. + +% Define some utilities for writing the output file. + /wtstring 100 string def + /wb {cfile exch write} bind def + /ws {cfile exch writestring} bind def + /wl {ws (\n) ws} bind def + /wt {wtstring cvs ws} bind def + +% Write a C string. Some compilers have unreasonably small limits on +% the length of a string literal or the length of a line, so every place +% that uses wcs must either know that the string is short, +% or be prepared to use wcca instead. + /wbx + { 8#1000 add 8 (0000) cvrs dup 0 (\\) 0 get put ws + } bind def + /wcst + [ + 32 { /wbx load } repeat + 95 { /wb load } repeat + 129 { /wbx load } repeat + ] def + ("\\) { wcst exch { (\\) ws wb } put } forall + /wcs + { (") ws { dup wcst exch get exec } forall (") ws + } bind def + /can_wcs % Test if can use wcs + { length max_wcs le + } bind def + /wncs % name -> C string + { wtstring cvs wcs + } bind def +% Write a C string as an array of character values. +% We only need this because of line and literal length limitations. + /wca % wca - + { 0 4 -2 roll exch + { % Stack: suffix n prefix char + exch ws + exch dup 19 ge { () wl pop 0 } if 1 add + exch dup 32 ge 1 index 126 le and + { 39 wb dup 39 eq 1 index 92 eq or { 92 wb } if wb 39 wb } + { wt } + ifelse (,) + } forall + pop pop ws + } bind def + /wcca % wcca - + { ({\n) (}) wca + } bind def + +% Write object protection attributes. Note that dictionaries and arrays are +% the only objects that can be writable. + /wpa + { dup xcheck { (a_executable|) ws } if + dup type dup /dicttype eq exch /arraytype eq or + { getpa } + { getpa a_readonly and } + ifelse prot_names exch get ws + } bind def + /wva + { getva prot_names exch get ws + } bind def + +% ------ Object writing ------ % + + /wnstring 128 string def + +% Convert an object to a string to be scanned at a later time. + /cvos % cvos + { % We'd like to use == and write directly to a string, + % but we can't do the former because of operators, + % and we can't do the latter because we can't predict + % how long the string would have to be.... + wtempname (w) file dup 3 -1 roll wproc closefile + wtempname status pop pop pop exch pop string + wtempname (r) file dup 3 -1 roll readstring pop exch closefile + } bind def + +% Write a string/name or null as an element of a string/name/null array. +% Convert any other kind of value to a token to be read back in. + /wsn + { dup null eq + { pop (\t255,255,) wl + } + { dup type /nametype eq { wnstring cvs } if + dup type /stringtype ne { cvos (255,) ws } if + dup length 256 idiv wt (,) ws + dup length 256 mod wt + (,) (,\n) wca + } + ifelse + } bind def +% Write a packed string/name/null array. + /wsna % <(string|name|null)*> wsna - + { (\tstatic const char ) ws exch wt ([] = {) wl + { wsn } forall + (\t0\n};) wl + } bind def + +% Write a number or an array of numbers, as refs. +/isnumber + { type dup /integertype eq exch /realtype eq or + } bind def +/wnums + { dup isnumber + { (real_v\() ws wt (\),) ws } + { { wnums } forall } + ifelse + } bind def + +% Test whether a procedure or unusual array can be written (printed). +/iswx 4 dict dup begin + /arraytype { { iswproc } isall } def + /nametype { pop true } def + /operatortype { pop true } def % assume it has been bound in + /packedarraytype /arraytype load def +end def +/iswnx 6 dict dup begin + /arraytype { { iswproc } isall } def + /integertype { pop true } def + /nametype { pop true } def + /realtype { pop true } def + /stringtype { pop true } def + /packedarraytype /arraytype load def +end def +/iswproc % iswproc + { dup xcheck { iswx } { iswnx } ifelse + 1 index type .knownget { exec } { pop false } ifelse + } bind def + +% Write a printable procedure (one for which iswproc returns true). +/wproca 3 dict dup begin + /arraytype + { 1 index ({) writestring + { 1 index ( ) writestring 1 index exch wproc } forall + (}) writestring + } bind def + /packedarraytype /arraytype load def + /operatortype { .writecvs } bind def % assume binding would work +end def +/wproc % wproc - + { dup type wproca exch .knownget { exec } { write==only } ifelse + } bind def + +% Write a named object. Return true if this was possible. +% Legal types are: boolean, integer, name, real, string, +% array of (integer, integer+real, name, null+string), +% and certain procedures and other arrays (see iswproc above). +% All other objects are either handled specially or ignored. + /isall % isall + { true 3 -1 roll + { 2 index exec not { pop false exit } if } + forall exch pop + } bind def + /wott 8 dict dup begin + /arraytype + { woatt + { aload pop 2 index 2 index exec + { exch pop exec exit } + { pop pop } + ifelse + } + forall + } bind def + /booleantype + { { (\tmake_true\(&) } { (\tmake_false\(&) } ifelse ws + wt (\);) wl true + } bind def + /integertype + { (\tmake_int\(&) ws exch wt (, ) ws + wt (\);) wl true + } bind def + /nametype + { (\tcode = (*pprocs->name_create)\(&) ws exch wt + (, ) ws wnstring cvs wcs % OK, names are short + (\);) wl + (\tif ( code < 0 ) return code;) wl + true + } bind def + /packedarraytype + /arraytype load def + /realtype + { (\tmake_real\(&) ws exch wt (, ) ws + wt (\);) wl true + } bind def + /stringtype + { ({\tstatic const char s_[] = ) ws + dup dup can_wcs { wcs } { wcca } ifelse + (;) wl + (\tmake_const_string\(&) ws exch wt + (, a_readonly, ) ws length wt (, (const byte *)s_\);) wl + (}) wl true + } bind def + end def +% Write some other kind of object, if known. + /wother + { dup otherobjs exch known + { otherobjs exch get (\t) ws exch wt ( = ) ws wt (;) wl true } + { pop pop false } + ifelse + } bind def +% Top-level procedure. + /wo % name obj -> OK + { dup type wott exch .knownget { exec } { wother } ifelse + } bind def + +% Write an array (called by wo). + /wap % wap - + { dup xcheck not 1 index wcheck not and 1 index rcheck and + { pop pop } + { (\tr_set_attrs\(&) ws exch wt (, ) ws wpa (\);) wl } + ifelse + } bind def + /wnuma % <_v> wnuma - + { 2 index wcheck + { % Allocate an array and copy the values into it. + % We can't define new callback procedures, so we must + % do this the hard way. + pop pop + ({\tstatic const byte z_[) ws dup length 1 .max 2 mul wt + (] = {0}; ref r_;) wl + (\tcode = (*pprocs->string_array_create)\(&r_, z_, ) ws + dup length wt (, 0\);) wl + (\tif ( code < 0 ) return code;) wl + (\tr_set_attrs\(&r_, ) ws dup wpa (\);) wl + (\t) ws exch wt ( = r_;) wl + 0 1 2 index length 1 sub + { 2 copy get + % Stack: array index value + dup type /integertype eq { (\tmake_int) } { (\tmake_real) } ifelse + ws (_new\(&r_.value.refs[) ws exch wt + (], ) ws wt (\);) wl + } + for pop + } + { ({\tstatic const ref_\() ws exch ws + (\) a_[] = {) wl exch + dup length 0 eq + { (\t) ws 1 index ws (\(0\)) wl + } + { dup + { (\t) ws 2 index ws (\() ws wt (\),) wl + } forall + } + ifelse exch pop + (\t};) wl + (\tmake_const_array\(&) ws exch wt + (, avm_foreign|) ws dup wpa (, ) ws length wt + (, (const ref *)a_\);) wl + } + ifelse + (}) wl + } bind def + /woatt [ + % Integers + { { { type /integertype eq } isall } + { (long) (integer_v) wnuma true } + } + % Integers + reals + { { { type dup /integertype eq exch /realtype eq or } isall } + { (float) (real_v) wnuma true } + } + % Strings + nulls + { { { type dup /nulltype eq exch /stringtype eq or } isall } + { ({) ws dup (sa_) exch wsna + (\tcode = (*pprocs->string_array_create)\(&) ws exch wt + (, sa_, ) ws dup length wt (, ) ws wpa (\);) wl + (\tif ( code < 0 ) return code;) wl + (}) wl true + } + } + % Names + { { { type /nametype eq } isall } + { ({) ws dup (na_) exch wsna + (\tcode = (*pprocs->name_array_create)\(&) ws 1 index wt + (, na_, ) ws dup length wt (\);) wl + (\tif ( code < 0 ) return code;) wl + wap (}) wl true + } + } + % Procedure + { { iswproc } + { dup cvos + % Stack: name proc string + ({\tstatic const char s_[] = ) ws + dup dup can_wcs { wcs } { wcca } ifelse + (;) wl + (\tcode = (*pprocs->ref_from_string)\(&) ws 2 index wt + (, s_, ) ws length wt (\);) wl + (\tif ( code < 0 ) return code;) wl + wap (}) wl true + wtempname deletefile + } + } + % Default + { { pop true } + { wother } + } + ] def + +% Write a named dictionary. We assume the ref is already declared. + /wd % wd - + { 3 1 roll + ({) ws + (\tref v_[) ws dup length wt (];) wl + dup [ exch + { counttomark 2 sub wtstring cvs + (v_[) exch concatstrings (]) concatstrings exch wo not + { (Skipping ) print ==only (....\n) print } + if + } forall + ] + % Stack: array of keys (names) + ({) ws dup (str_keys_) exch wsna + (\tstatic const cfont_dict_keys keys_ =) wl + (\t { 0, 0, ) ws length wt (, ) ws 3 -1 roll wt (, ) ws + dup wpa (, ) ws dup wva ( };) wl pop + (\tcode = \(*pprocs->ref_dict_create\)\(&) ws wt + (, &keys_, str_keys_, v_\);) wl + (\tif ( code < 0 ) return code;) wl + (}) wl + (}) wl + } bind def + +% Write character dictionary keys. +% We save a lot of space by abbreviating keys which appear in +% StandardEncoding or ISOLatin1Encoding. +% Writes code to declare and initialize enc_keys_, str_keys, and keys_. +/wcdkeys % wcdkeys - + { % Write keys present in StandardEncoding or ISOLatin1Encoding, + % pushing other keys on the o-stack. + (static const charindex enc_keys_[] = {) wl + dup [ exch 0 exch + { pop decoding 1 index known + { decoding exch get ({) ws dup -8 bitshift wt + (,) ws 255 and wt (}, ) ws + 1 add dup 5 mod 0 eq { (\n) ws } if + } + { exch } + ifelse + } + forall pop + ] + ({0,0}\n};) wl + % Write other keys. + (str_keys_) exch wsna + % Write the declaration for keys_. + (static const cfont_dict_keys keys_ = {) wl + (\tenc_keys_, countof\(enc_keys_\) - 1,) wl + (\t) ws dup length wt ( - \(countof\(enc_keys_\) - 1\), 0, ) ws + dup wpa (, ) ws wva () wl + (};) wl + } bind def + +% Enumerate character dictionary values in the same order that +% the keys appear in enc_keys_ and str_keys_. +% is called with each value in turn. +/cdforall % cdforall - + { 2 copy + { decoding 3 index known + { 3 -1 roll pop exec } + { pop pop pop } + ifelse + } + /exec cvx 3 packedarray cvx + /forall cvx + 5 -2 roll + { decoding 3 index known + { pop pop pop } + { 3 -1 roll pop exec } + ifelse + } + /exec cvx 3 packedarray cvx + /forall cvx + 6 packedarray cvx exec + } bind def + +% ------ Writers for special objects ------ % + +/writespecial 10 dict dup begin + + /FontInfo { 0 wd } def + + /Private { 0 wd } def + + /CharStrings + { ({) wl + dup wcdkeys + (static const char values_[] = {) wl + { wsn } cdforall + (\t0\n};) wl + (\tcode = \(*pprocs->string_dict_create\)\(&) ws wt + (, &keys_, str_keys_, values_\);) wl + (\tif ( code < 0 ) return code;) wl + (}) wl + } bind def + + /Metrics + { ({) wl + dup wcdkeys + (static const ref_(float) values_[] = {) wl + dup { (\t) ws wnums () wl } cdforall + (\t0\n};) wl + (static const char lengths_[] = {) wl + { (\t) ws dup isnumber + { pop 0 } + { length 1 add } + ifelse wt (,) wl + } cdforall + (\t0\n};) wl + (\tcode = \(*pprocs->num_dict_create\)\(&) ws wt + (, &keys_, str_keys_, (const ref *)values_, lengths_\);) wl + (\tif ( code < 0 ) return code;) wl + (}) wl + } bind def + + /Metrics2 /Metrics load def + + /FDepVector pop % (converted to a list of font names) + +end def + +% ------ The main program ------ % + +% Construct an inverse dictionary of encodings. +[ /StandardEncoding /ISOLatin1Encoding + /SymbolEncoding /DingbatsEncoding + /KanjiSubEncoding +] +dup length dict begin + { mark exch dup { .findencoding exch def } stopped cleartomark + } forall +currentdict end /encodingnames exch def + +% Invert the StandardEncoding and ISOLatin1Encoding vectors. +512 dict begin + 0 1 255 { dup ISOLatin1Encoding exch get exch 256 add def } for + 0 1 255 { dup StandardEncoding exch get exch def } for +currentdict end /decoding exch def + +/writefont % cfilename procname -> [writes the current font] + { (gsf_) exch concatstrings + /fontprocname exch def + /cfname exch def + /cfile cfname (w) file def + +% Remove unwanted keys from the font. + currentfont dup length dict begin { def } forall + { /FID /MIDVector /CurMID } { currentdict exch undef } forall + /Font currentdict end def + +% Replace the FDepVector with a list of font names. + Font /FDepVector .knownget + { [ exch { /FontName get } forall ] + Font /FDepVector 3 -1 roll put + } + if + +% Find all the special objects we know about. +% wo uses this to write out references to otherwise intractable objects. + /otherobjs writespecial length dict dup begin + writespecial + { pop Font 1 index .knownget { exch def } { pop } ifelse + } + forall + end def + +% Define a dummy FontInfo, in case the font doesn't have one. + /FontInfo 0 dict def + +% Write out the boilerplate. + Font begin + (/****************************************************************) wl + ( Portions of this file are subject to the following notice(s):) wl + systemdict /copyright get wl + FontInfo /Notice .knownget + { (----------------------------------------------------------------) wl wl + } if + (****************************************************************/) wl + () wl + (/* ) ws cfname ws ( */) wl + (/* This file was created by the ) ws product ws ( font2c utility. */) wl + () wl + (#undef DEBUG) wl + (#include "ccfont.h") wl + () wl + +% Write the procedure prologue. + (#ifdef __PROTOTYPES__) wl + (int huge) wl + fontprocname ws ((const cfont_procs *pprocs, ref *pfont)) wl + (#else) wl + (int huge) wl + fontprocname ws ((pprocs, pfont) const cfont_procs *pprocs; ref *pfont;) wl + (#endif) wl + ({\tint code;) wl + (\tref Font;) wl + otherobjs + { exch pop (\tref ) ws wt (;) wl } + forall + +% Write out the special objects. + otherobjs + { exch writespecial 2 index get exec + } + forall + +% Write out the main font dictionary. +% If possible, substitute the encoding name for the encoding; +% PostScript code will fix this up. + { /Encoding /PrefEnc } + { Font 1 index .knownget + { encodingnames exch .knownget { def } { pop } ifelse } + { pop } + ifelse + } + forall + (Font) Font FontType 0 eq { 5 } { 1 } ifelse wd + +% Finish the procedural initialization code. + (\t*pfont = Font;) wl + (\treturn 0;) wl + (}) wl + end % Font + + cfile closefile + + } bind def + +end def % font2cdict + +% Compute the procedure name from the font name. +% Replace all non-alphanumeric characters with '_'. +/makefontprocnamemap 256 string + 0 1 255 { 2 copy 95 put pop } for + (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz) + { 2 copy dup put pop } forall +readonly def +/makefontprocname % makefontprocname + { dup length string cvs + dup length 1 sub -1 0 + { % Stack: string index + 2 copy 2 copy get //makefontprocnamemap exch get put pop + } + for + } def + +/writefont { font2cdict begin writefont end } def + +% If the program was invoked from the command line, run it now. +[ shellarguments + { counttomark dup 2 eq exch 3 eq or + { counttomark -1 roll cvn + (Converting ) print dup =only ( font.\n) print flush + dup FontDirectory exch known { dup FontDirectory exch undef } if + findfont setfont + (FontName is ) print currentfont /FontName get ==only (.\n) print flush + counttomark 1 eq + { % Construct the procedure name from the file name. + currentfont /FontName get makefontprocname + } + if + writefont + (Done.\n) print flush + } + { cleartomark + (Usage: font2c fontname cfilename.c [shortname]\n) print + ( e.g.: font2c Courier cour.c\n) print flush + mark + } + ifelse + } +if pop diff --git a/gs/lib/golfer.ps b/gs/lib/golfer.ps new file mode 100644 index 000000000..930f777de --- /dev/null +++ b/gs/lib/golfer.ps @@ -0,0 +1,1398 @@ +%!PS-Adobe-2.0 EPSF-1.2 +%%Creator:Adobe Illustrator(TM) 1.0b2- +%%Title:golfer art+ +%%CreationDate:1/6/87 9:32 AM +%%DocumentFonts:Helvetica-Bold +%%BoundingBox:7 31 577 726 +%%TemplateBox:0 -48 576 672 +%%EndComments +100 dict begin +/q{bind def}bind def +/Q{load def}q +/x{exch def}q +/X/def Q +/g{/_g x/p{_g setgray}X}q +/G{/_G x/P{_G setgray}X}q +/k{/_b x/_g x/_r x/p{_r _g _b setrgbcolor}X}q +/K{/_B x/_G x/_R x/P{_R _G _B setrgbcolor}X}q +/d/setdash Q +/i/setflat Q +/j/setlinejoin Q +/J/setlinecap Q +/M/setmiterlimit Q +/w/setlinewidth Q +/_C{.25 sub round .25 add}q +/_c{transform _C exch _C exch itransform}q +/c{_c curveto}q +/C/c Q +/v{currentpoint 6 2 roll _c curveto}q +/V/v Q +/y{_c 2 copy curveto}q +/Y/y Q +/l{_c lineto}q +/L/l Q +/m{_c moveto}q +/_e[]X +/_E{_e length 0 ne{gsave 1 g 0 G 1 i 0 J 0 j .5 w 10 M[]0 d +/Helvetica-Bold 24 0 0 1 z +[0.966 0.259 -0.259 0.966 +_e 0 get _e 2 get add 2 div _e 1 get _e 3 get add 2 div]a +(ERROR: can't fill a path)t T grestore}if}q +/n/newpath Q +/N/newpath Q +/F{p{fill}stopped{/_e[pathbbox]X n _E}if}q +/f{closepath F}q +/S{P stroke}q +/s{closepath S}q +/B{gsave F grestore S}q +/b{closepath B}q +/u{}q +/U{}q +/_s/ashow Q +/_S{(?)exch{2 copy 0 exch put pop dup true charpath currentpoint _m setmatrix +stroke _M setmatrix moveto 3 copy pop rmoveto}forall pop pop pop n}q +/_A{_a moveto _t exch 0 exch}q +/_L{0 _l neg translate _M currentmatrix pop}q +/_w{dup stringwidth exch 3 -1 roll length 1 sub _t mul add exch}q +/_z[{0 0}bind{dup _w exch neg 2 div exch neg 2 div}bind +{dup _w exch neg exch neg}bind]X +/z{_z exch get/_a x/_t x/_l x exch findfont exch scalefont setfont}q +/_d{matrix currentmatrix X}q +/_D{/_m _d gsave concat/_M _d}q +/e{_D p/t{_A _s _L}X}q +/r{_D P/t{_A _S _L}X}q +/a{_D/t{dup p _A _s P _A _S _L}X}q +/o{_D/t{pop _L}X}q +/T{grestore}q +/Z{findfont begin currentdict dup length dict begin +{1 index/FID ne{X}{pop pop}ifelse}forall/FontName exch X dup length 0 ne +{/Encoding Encoding 256 array copy X 0 exch{dup type/nametype eq +{Encoding 2 index 2 index put pop 1 add}{exch pop}ifelse}forall}if pop +currentdict dup end end/FontName get exch definefont pop}q +n +%%EndProlog +u +0.9 g +0 G +1 i +0 J +0 j +1 w +10 M +[]0 d +%%Note: +15.815 40.248 m +567.815 40.002 L +567.748 716.565 L +15.998 716.81 L +15.815 40.248 L +b +U +1 g +285.313 40 m +567.688 40.125 L +567.812 78.375 L +285.312 78.25 L +285.313 40 L +b +0 g +175.5 163 m +180.007 163 173.738 169.081 171.75 168.75 c +174.75 169.25 176.25 169.5 174.5 171.25 C +178 171.25 176.349 173.783 175 176.75 c +173.75 179.5 170.75 182.25 168.25 182 C +165.5 181.25 167.622 182.838 165.25 186 c +164.5 187 164.75 187.5 161.75 186.75 c +158.75 186 163.25 190 156.75 190 c +150.25 190 148.5 189 145.5 186 c +142.5 183 139.75 183.75 139.5 182.5 c +139.25 181.25 139.5 176.75 138.75 175.5 c +138 174.25 136.75 174.25 136.25 178 c +135.75 181.75 140.25 182.25 134 187 C +135.75 190.75 134.5 191.75 131 193.5 C +131 200 129.202 203.364 119.5 208.5 c +115.25 210.75 107 212.75 104.75 208.75 c +102.5 204.75 103 206.5 96.5 205.75 c +90 205 87.25 202.5 86.5 197.75 c +85.75 193 82.75 195 79 194.75 c +75.25 194.5 77 192.75 77.25 191.75 c +77.5 190.75 75.25 192.5 71.5 192 c +67.75 191.5 64.25 185.5 69.5 180.75 c +74.75 176 66.5 180.75 64.25 182.25 c +62 183.75 60.5 181.75 61 180.25 c +61.5 178.75 58.75 180.75 57.5 180.75 c +56.25 180.75 51.008 180.188 52 172.25 c +52.25 170.25 51.5 170.5 49.75 169.25 c +48 168 45.75 164.25 48.5 158.75 c +51.25 153.25 49 150 48 145.5 c +47 141 48 138.25 51.25 137.25 c +54.5 136.25 54 133.791 54 130.75 C +57 130.5 59 129.25 58.75 124.5 C +62.25 124.5 61.75 126.75 62.5 130 c +63.25 133.25 65.75 129 66.25 127 c +66.75 125 67.5 125 72 125 C +74.75 116.25 74.75 120.5 75.25 117.25 C +80 117.5 79.5 116.75 83.25 113.75 c +87 110.75 88.25 115.5 92 118.5 c +95.75 121.5 94.25 122.75 96.25 118.75 c +98.25 114.75 98.5 119 101.5 119.25 c +104.5 119.5 101 115.75 105.25 114.5 c +109.5 113.25 105 113.75 103.5 111.25 c +102 108.75 95 103.5 101.75 101.5 c +108.5 99.5 103.5 99.75 94.75 99.5 c +86 99.25 73.75 87.5 97.25 73.25 C +117.25 53.25 117.25 53.5 v +117.25 53.75 175.25 163 175.5 163 c +f +1 J +0.2 w +389.709 210.076 m +511.826 210.076 l +S +394.709 212.461 m +516.826 212.461 l +S +415.459 215.112 m +537.576 215.112 l +S +399.709 217.762 m +521.826 217.762 l +S +402.459 222.799 m +524.576 222.799 l +S +402.709 225.45 m +524.826 225.45 l +S +392.959 227.851 m +515.076 227.851 l +S +400.691 232.856 m +522.809 232.856 l +S +388.191 235.241 m +510.309 235.241 l +S +393.941 237.892 m +516.059 237.892 l +S +393.441 240.292 m +515.559 240.292 l +S +396.191 242.928 m +518.309 242.928 l +S +386.441 245.579 m +508.559 245.579 l +S +393.191 248.23 m +515.309 248.23 l +S +414.191 250.631 m +536.309 250.631 l +S +397.95 252.973 m +520.067 252.973 l +S +398.7 255.358 m +520.817 255.358 l +S +400.7 258.009 m +522.817 258.009 l +S +384.45 260.659 m +506.567 260.659 l +S +380.7 265.696 m +502.817 265.696 l +S +379.95 268.347 m +502.067 268.347 l +S +386.7 270.748 m +508.817 270.748 l +S +394.433 275.752 m +516.55 275.752 l +S +381.933 278.138 m +504.05 278.138 l +S +379.433 280.789 m +501.55 280.789 l +S +383.183 283.189 m +505.3 283.189 l +S +370.433 285.825 m +492.55 285.825 l +S +382.433 288.476 m +504.55 288.476 l +S +356.183 291.127 m +478.3 291.127 l +S +372.433 293.277 m +494.55 293.277 l +S +361.866 296.006 m +483.984 296.006 l +S +365.616 298.406 m +487.734 298.406 l +S +366.866 301.042 m +488.984 301.042 l +S +346.866 303.693 m +468.984 303.693 l +S +338.616 306.344 m +460.734 306.344 l +S +330.866 308.494 m +452.984 308.494 l +S +301.575 344.342 m +423.692 344.342 l +S +314.075 346.728 m +436.192 346.728 l +S +318.325 349.378 m +440.442 349.378 l +S +312.075 352.029 m +434.192 352.029 l +S +327.325 357.065 m +449.442 357.065 l +S +327.575 359.716 m +449.692 359.716 l +S +317.825 362.117 m +439.942 362.117 l +S +335.558 367.122 m +457.675 367.122 l +S +313.058 369.507 m +435.175 369.507 l +S +318.808 372.158 m +440.925 372.158 l +S +317.579 404.674 m +439.696 404.674 l +S +322.312 409.179 m +444.429 409.179 l +S +323.812 412.065 m +445.929 412.065 l +S +329.562 414.715 m +451.679 414.715 l +S +329.062 417.116 m +451.179 417.116 l +S +331.812 419.752 m +453.929 419.752 l +S +322.062 422.402 m +444.179 422.402 l +S +328.812 425.053 m +450.929 425.053 l +S +349.812 427.454 m +471.929 427.454 l +S +333.571 429.796 m +455.688 429.796 l +S +334.321 432.182 m +456.438 432.182 l +S +336.321 434.832 m +458.438 434.832 l +S +320.071 437.483 m +442.188 437.483 l +S +316.321 442.519 m +438.438 442.519 l +S +315.571 445.17 m +437.688 445.17 l +S +322.321 447.571 m +444.438 447.571 l +S +330.054 452.576 m +452.171 452.576 l +S +317.554 454.961 m +439.671 454.961 l +S +315.054 457.612 m +437.171 457.612 l +S +318.804 460.012 m +440.921 460.012 l +S +306.054 462.648 m +428.171 462.648 l +S +300.054 465.299 m +422.171 465.299 l +S +291.804 467.95 m +413.921 467.95 l +S +308.054 470.101 m +430.171 470.101 l +S +260.834 543.511 m +382.951 543.511 l +S +246.066 548.016 m +368.184 548.016 l +S +256.066 550.901 m +378.184 550.901 l +S +253.566 553.552 m +375.684 553.552 l +S +230.316 555.952 m +352.434 555.952 l +S +244.566 558.588 m +366.684 558.588 l +S +238.566 561.239 m +360.684 561.239 l +S +230.316 563.89 m +352.434 563.89 l +S +216.566 565.541 m +338.684 565.541 l +S +104.443 572.01 m +226.575 572.209 l +S +98.682 567.48 m +220.814 567.68 l +S +91.688 565.11 m +213.82 565.31 l +S +97.192 561.955 m +219.324 562.155 l +S +73.943 559.517 m +196.075 559.717 l +S +88.199 556.904 m +210.331 557.103 l +S +82.203 554.243 m +204.335 554.443 l +S +73.956 551.578 m +196.088 551.778 l +S +73.707 549.405 m +195.839 549.605 l +S +85.302 539.953 m +207.434 540.152 l +S +79.541 535.423 m +201.673 535.623 l +S +72.547 533.053 m +194.679 533.253 l +S +78.051 529.898 m +200.183 530.098 l +S +54.802 527.46 m +176.934 527.66 l +S +69.058 524.847 m +191.19 525.046 l +S +63.061 522.186 m +185.194 522.385 l +S +54.815 519.521 m +176.947 519.721 l +S +54.566 517.348 m +176.698 517.547 l +S +u +189.475 196.879 m +311.592 196.879 l +S +176.975 199.265 m +299.092 199.265 l +S +174.475 201.916 m +296.592 201.916 l +S +178.225 204.316 m +300.342 204.316 l +S +165.475 206.952 m +287.592 206.952 l +S +177.475 209.603 m +299.592 209.603 l +S +155.725 212.254 m +277.842 212.254 l +S +167.475 214.404 m +289.592 214.404 l +S +156.908 217.133 m +279.026 217.133 l +S +144.658 219.533 m +266.776 219.533 l +S +161.908 222.169 m +284.026 222.169 l +S +153.908 224.82 m +276.026 224.82 l +S +163.658 226.971 m +285.776 226.971 l +S +152.408 229.121 m +274.526 229.121 l +S +145.925 233.316 m +268.042 233.316 l +S +157.675 235.466 m +279.792 235.466 l +S +147.108 238.195 m +269.226 238.195 l +S +134.858 240.595 m +256.976 240.595 l +S +137.608 243.231 m +259.726 243.231 l +S +144.108 245.882 m +266.226 245.882 l +S +153.858 248.033 m +275.976 248.033 l +S +155.108 231.183 m +277.226 231.183 l +S +103.425 247.816 m +225.542 247.816 l +S +100.175 249.966 m +222.292 249.966 l +S +89.608 252.695 m +211.726 252.695 l +S +77.358 255.095 m +199.476 255.095 l +S +U +u +1 g +0 J +1 w +120.001 389.999 m +170.811 344.713 248.714 349.191 294.001 400.001 c +339.287 450.811 334.809 528.714 283.999 574.001 c +233.189 619.287 155.286 614.809 109.999 563.999 c +64.713 513.189 69.191 435.286 120.001 389.999 c +f +202 482 m +F +U +u +258 302 m +306.6 267.759 373.759 279.4 408 328 c +442.241 376.6 430.6 443.759 382 478 c +333.4 512.241 266.241 500.6 232 452 c +197.759 403.4 209.4 336.241 258 302 c +f +320 390 m +F +U +u +196 376 m +252.332 345.072 323.072 365.668 354 422 c +384.928 478.332 364.332 549.072 308 580 c +251.668 610.928 180.928 590.332 150 534 c +119.072 477.668 139.668 406.928 196 376 c +f +252 478 m +F +U +u +106 257 m +170.064 231.595 242.595 262.936 268 327 c +293.405 391.064 262.064 463.595 198 489 c +133.936 514.405 61.405 483.064 36 419 c +10.595 354.936 41.936 282.405 106 257 c +f +152 373 m +F +U +u +366.001 122 m +415.706 97.7 475.7 118.296 500 168.001 c +524.3 217.706 503.704 277.7 453.999 302 c +404.294 326.3 344.3 305.704 320 255.999 c +295.7 206.294 316.296 146.3 366.001 122 c +f +410 212 m +F +U +u +227.999 198 m +267.763 185.85 309.849 208.236 322 247.999 c +334.15 287.763 311.764 329.849 272.001 342 c +232.237 354.15 190.151 331.764 178 292.001 c +165.85 252.237 188.236 210.151 227.999 198 c +f +250 270 m +F +U +0 g +15.75 71.25 m +24.25 82.75 24.75 84.75 27.75 82.25 c +30.75 79.75 31.75 81.25 32.75 82.75 c +33.75 84.25 30.75 86.75 35.75 88.75 c +40.75 90.75 41.25 91.75 43.25 89.75 c +45.25 87.75 39.25 89.25 50.25 88.75 c +61.25 88.25 70.25 81.75 74.25 75.25 c +78.25 68.75 77.75 67.25 75.25 63.25 c +72.75 59.25 68.25 56.75 72.25 57.25 c +76.25 57.75 75.75 60.75 77.75 56.75 c +79.75 52.75 80.25 51.25 79.25 49.25 c +78.25 47.25 74.25 46.75 81.25 46.25 c +88.25 45.75 91.75 37.557 91.75 40.25 c +15.752 40.248 l +15.75 71.25 l +f +340.75 55.5 m +F +u +u +3 w +280.774 44.223 m +567.893 44.223 l +S +280.774 48.728 m +567.893 48.728 l +S +280.774 53.734 m +567.893 53.734 l +S +U +u +280.774 58.739 m +567.893 58.739 l +S +280.774 63.245 m +567.893 63.245 l +S +280.774 68.251 m +567.893 68.251 l +S +U +u +280.774 73.257 m +567.893 73.257 l +S +280.774 78.263 m +567.893 78.263 l +S +U +U +0.8 g +0.2 w +243 252 m +323 235 l +346 273 l +368 248 l +376 247 376 248 V +377 174 380.5 121 330.5 40 C +90.5 40 91.5 40 V +138.5 129 163 162 214 200 C +236 229 234.527 240.11 238 254 c +240 262 243 252 y +b +0.5 g +359.5 485 m +389.267 485 402.5 486.25 415.75 489 c +429 491.75 435 493.25 439 493.5 c +443 493.75 490.398 537.797 502.5 562 c +507 571 514.5 577 517.5 579.5 c +520.5 582 501.5 591 y +428 512 428 512.5 v +428 513 356.5 510 356 509.5 c +355.5 509 351 488 y +359 485 359.5 485 v +b +0.7 g +370 496.5 m +368 480.5 365.5 472.5 364.5 471.5 C +329.5 476.5 l +323.5 489.5 l +370 496.5 l +b +0.5 g +352.75 494 m +380 493.25 399.626 496.75 407.5 499 c +418 502 424.586 497.135 432.75 505.5 c +453 526.25 473.5 544.5 496.5 586.5 C +473.5 590 473.5 590.5 V +456 571.5 443 563.5 434 558 c +425 552.5 416 544 408.5 534.5 C +399 533 379.5 537.5 364 537.5 c +348.5 537.5 352.75 494 y +b +1 g +500 583 m +500.5 577.098 517 573.5 520.5 572 c +524 570.5 526.353 568.989 526.5 579 c +526.675 590.992 541 586 539 624 C +538.5 624 506 628 y +499.958 583.498 500 583 v +b +0 g +1 J +3 w +562 629 m +343 645 217 644 77 601 C +52 576 L +59.5 562 80.132 560.877 87 589 c +89.513 599.292 87 597 101 601 c +108.323 603.092 265 654 561 617 C +562 629 l +f +1 G +0 J +0.7 w +305 634 m +391.5 636.5 415 635 473 632 c +S +0.5 w +213 626.5 m +153.5 619 125.925 611.699 90.75 602.5 c +78.654 599.337 82.567 597.884 82.5 592 c +82.395 582.717 73.75 571 59 572.5 c +S +1 g +0 G +1 w +73 595.25 m +79.25 592.5 76.25 574.75 57.25 580 C +73 595.25 l +f +0.5 g +0.2 w +312 574.25 m +311.25 570.5 310.687 571.687 306.187 569.187 C +307.687 564.187 311.106 565.66 304.5 561.5 c +302.594 560.299 305.598 556.561 305.75 555.5 c +306.038 553.485 304.629 548.098 297 548.5 c +292.25 548.75 255.5 536 y +229.5 608.5 l +224 650 224.5 650 v +248.101 650 273.345 678.918 298 655.5 c +324.857 629.99 316.981 613.501 316.75 612.875 c +313.346 603.644 313.238 604.937 314.75 597.375 c +316.88 586.725 317.016 588.834 318.625 584.75 C +320.25 581.875 318.625 580.375 y +316.689 578.236 313.081 579.809 310.375 579 c +307.013 577.994 312 574.25 y +B +0 g +0.5 w +288.5 456 m +S +0.2 w +211 511 m +194.5 518.5 187 520.5 170.5 500 C +154.5 498.5 149.5 501 131.5 479.5 C +151 477.5 140 475 161 460 c +182 445 190.5 436.5 212 461 C +224.5 458 229 454.5 238.5 447 C +238 446.5 237 500.5 y +211 511 l +f +1 g +207.5 526.5 m +206 514.5 204 506 236 490.5 C +242.5 509.5 l +207.5 526.5 l +b +0 g +1 w +294.464 627.589 m +288.571 618.522 284.821 617.313 280 615.5 c +275.179 613.686 271.429 605.224 277.857 587.089 C +274.107 586.485 275.179 585.88 275.714 582.858 C +271.429 599.179 270.357 606.433 259.643 609.455 c +248.929 612.477 245.714 589.507 247.321 566.537 C +228.572 554.448 L +224.639 578.851 235.956 576.38 212.5 600.992 c +194.17 620.226 195.893 654.791 225.357 658.418 C +223.214 667.485 233.929 678.97 259.107 677.761 c +284.286 676.552 281.071 667.485 Y +302.5 667.485 334.964 665.942 301.429 614.895 C +306.25 639.679 303.571 643.306 296.607 646.933 C +299.286 634.239 294.464 627.589 y +f +0.7 g +0.2 w +207.5 524.5 m +214.75 519.25 241.5 509 y +239 504.5 l +232 503 214.5 508.75 206.75 519 C +207 522.5 207.5 524.5 y +b +1 g +298 546.5 m +272.625 574.625 248.5 596 195.5 568.5 C +196.26 524.417 214.492 504.333 239.5 510.5 C +298 546.5 l +b +0.8 g +351.5 542 m +367 540 L +358.5 509.5 357 489.5 357 482 C +323.5 482.5 295.5 485.5 284.5 477.5 c +298.5 468.5 l +299 457 l +270.5 451 l +238.5 483.5 l +241 513.5 l +250.5 538 252.5 547.5 282.5 550 C +306.251 550 334.454 541.702 343.687 542.187 C +342.576 538.175 346.737 538.055 351.5 542 c +b +0 g +1 w +333.25 484.75 m +343.25 458.25 371.5 466 349 418.5 C +359 348.5 378 357 363 336 C +358.5 333 359 333 v +359.5 333 353 328 359 327.5 c +365 327 371 316.5 373.5 253.5 C +381 245.5 l +371 221 371 220.5 V +360.5 247 358 253 351 261.5 C +340 238 331.5 220.5 328.5 211.5 C +301 229.5 265 250 232.5 244.5 C +247.5 287 246 299.5 275 320.5 C +270 331.5 268.689 334.634 265.75 336.25 c +255.75 341.75 261.891 340.771 251 375 c +247.5 386 249.5 384 255.5 399 C +252.5 397 253.5 401 253.5 402.5 c +253.5 404 252.057 400.023 251 402.5 c +235 440 219.5 489.5 249.5 534 C +238.5 503.5 242.102 477.13 260 463 c +269.5 455.5 278.75 453.25 291 457.25 C +297.5 461 299.549 465.787 282 476.75 C +292.5 487.5 333.25 484.75 y +f +457.25 576.25 m +454.936 574.233 453.51 595.217 479.25 583 C +495.651 573.321 495.931 560.263 482.5 560.5 C +486.25 566 491.682 565.465 478.5 575 c +463.444 585.891 460.318 578.924 457.25 576.25 c +f +1 g +460.75 581.5 m +463.387 583.699 467.528 583.937 470.5 583.375 c +473.752 582.76 473.75 581.75 Y +461.735 583.841 458.891 579.95 460.75 581.5 c +f +0 g +310.393 647.785 m +329.089 651.66 328.75 623.692 320.178 607.976 C +319.107 621.274 316.428 636.386 310.536 635.782 c +304.643 635.177 310.393 647.785 y +f +284.286 663.858 m +286.964 677.157 280.536 689.246 281.071 689.246 C +289.107 677.761 288.036 665.672 y +284.286 663.858 l +f +0.2 w +274.643 683.201 m +278.929 678.97 280 668.694 279.464 665.672 c +S +276.25 686.224 m +284.393 677.036 283.75 662.045 y +S +1 w +297.679 661.44 m +312.602 661.44 312.143 677.157 310.536 680.784 C +308.929 672.321 305.179 666.276 292.857 664.463 C +297.679 661.44 l +f +0.2 w +295 661.44 m +298.75 666.276 302.5 675.343 294.464 683.201 c +S +300.357 681.992 m +304.265 669.255 303.814 670.807 292.321 656.604 c +S +311.821 649.078 m +321.464 649.078 330.571 646.66 329.5 627.921 c +S +307.536 650.892 m +316.268 651.33 319.057 653.025 326.821 646.056 c +330.446 642.802 331.1 637.618 331.107 637.593 c +S +304.643 665.067 m +305.629 663.874 321.031 667.072 321.304 651.569 c +S +0.5 w +311.071 639.679 m +317.893 638.968 312.696 617.332 v +S +1 w +313.375 612.875 m +315.455 614.262 313.5 617.375 297.125 615.375 C +310.375 616.625 311.875 611.875 313.375 612.875 c +f +1 g +308.5 604.875 m +309.833 600.875 309.125 601.25 307.375 599 C +302.25 600.625 303.25 599.875 299 602.5 C +304.25 604.75 308.375 605.25 308.5 604.875 c +f +0 g +307.5 604.437 m +305.463 602.811 305.481 601.49 307.375 598.937 C +309.261 601.307 309.489 602.172 308.562 605.062 C +308.562 604.937 308.191 604.989 307.5 604.437 c +f +0.2 w +305.625 583.75 m +304.687 582.562 306.5 579.375 308.875 579.75 c +S +1 w +311.125 574.5 m +310.25 573.898 310 573.437 304.937 569.312 C +306.229 564.611 308.063 564.014 308.312 564.562 C +309.775 566.476 307.663 569.565 306.687 569.75 C +311.812 571.75 311.625 572.5 312 574.25 C +311.687 574.75 311.176 574.535 311.125 574.5 c +f +298.625 603 m +302 600.437 304.294 599.524 307.812 598.937 c +308.187 598.875 308.562 598.5 308.687 597.875 c +S +297.5 602.25 m +299.939 602.851 307.687 603.062 311.75 607.812 C +307.812 606 297.011 602.129 297.5 602.25 c +f +213.5 576.125 m +218.674 549.92 230.862 532.355 245.5 526.5 C +243.75 514.5 209.75 494.25 195.5 568.5 C +203.75 572.25 213.347 576.901 213.5 576.125 c +f +0.2 w +343.375 541.75 m +333.375 534.75 318.25 525.5 312 521.25 c +S +351.562 541.937 m +337.936 530.579 327.2 525.581 313.25 517.75 c +S +0.3 w +312.75 495 m +291.75 483.5 276.25 476 274.25 466 c +S +0.5 w +229 580.75 m +235.5 571 241.25 554.75 245.75 528 c +S +1 w +235 581 m +246 555.75 246.75 537.75 245.75 526 C +252.125 560.5 243.75 567.75 239.75 581.5 C +240 581.5 237 581.75 235 581 C +f +0.7 g +0.2 w +248.625 580.5 m +253.169 564.605 256.75 553.75 250.25 535.75 C +257.5 552.75 259.125 558.937 252.875 579.687 C +251.029 580.149 248.517 580.879 248.625 580.5 c +b +0 g +1 w +258.25 577.75 m +262.047 567.879 262.5 552.5 259.25 544.25 C +267.75 548.25 275 549.75 278.25 549.75 C +281.75 555.25 282.75 556.75 279.5 565.25 C +270.06 573.13 257.909 578.635 258.25 577.75 c +f +207.5 524.5 m +F +207.25 514.75 m +207.185 514.86 228.75 497.5 238 500.75 C +236 494.5 l +225 498 213.924 503.454 207.25 514.75 c +f +1 g +0.2 w +191 516 m +175.472 497.418 168.5 492 171.5 453 C +185 443.5 189 443.5 200 450.5 C +186.5 469.5 182 491 198.5 515.5 C +194.5 516 191.339 516.406 191 516 c +b +201 515 m +194 499 187 484 203.5 453 C +206.5 455 211.5 460.5 212 461 C +203.5 480.5 193.5 501.5 206 510.5 C +205 499.5 210.5 490.5 232.5 473.5 C +232.5 483 231.5 482.5 233 492 C +221 498 210 505 208 512.5 C +201 515 l +b +0 g +1 G +0.5 w +268 442.5 m +253.5 402.5 l +S +269.5 435.5 m +258.5 407 258.5 407.5 v +S +0.5 G +0.4 w +293.5 480.5 m +297.5 463.5 298.5 460.5 289 445.5 c +S +1 G +1 J +0.3 w +349.125 418.125 m +338.393 403.978 348.387 416.158 341.625 408.875 c +S +u +1 g +0 G +0 J +0.2 w +336.038 340.015 m +338.267 329.694 L +342.937 338.843 L +340.707 349.164 L +336.038 340.015 L +b +339.487 339.429 m +B +U +u +328.791 340.569 m +331.562 330.38 L +335.743 339.762 L +332.972 349.952 L +328.791 340.569 L +b +332.267 340.166 m +B +U +u +321.758 340.67 m +325.133 330.664 L +328.746 340.28 L +325.37 350.286 L +321.758 340.67 L +b +325.252 340.475 m +B +U +u +314.504 340.97 m +317.88 330.964 L +321.492 340.58 L +318.117 350.586 L +314.504 340.97 L +b +317.998 340.775 m +B +U +u +u +307.24 340.468 m +311.982 331.033 L +314.214 341.059 L +309.473 350.494 L +307.24 340.468 L +b +310.727 340.764 m +B +U +u +300.016 339.751 m +304.757 330.316 L +306.99 340.342 L +302.249 349.777 L +300.016 339.751 L +b +303.503 340.047 m +B +U +U +u +u +292.985 339.2 m +298.349 330.104 L +299.903 340.258 L +294.54 349.353 L +292.985 339.2 L +b +296.444 339.729 m +B +U +u +285.826 338 m +291.189 328.904 L +292.744 339.057 L +287.38 348.153 L +285.826 338 L +b +289.285 338.529 m +B +U +U +u +278.742 336.229 m +285.413 328.042 L +285.423 338.314 L +278.753 346.501 L +278.742 336.229 L +b +282.083 337.272 m +B +U +u +272.228 332.392 m +279.743 324.974 L +278.644 335.186 L +271.13 342.604 L +272.228 332.392 L +b +275.437 333.789 m +B +U +0 g +1 G +1 w +266.25 335.5 m +276.25 351.5 284.659 350 343 350 c +364 350 363 336 y +S +271 321 m +294 332 309 335 362 324 c +S +u +1 g +0 G +0.2 w +350.823 325.912 m +364.33 322.302 L +361.658 347.078 L +348.151 350.689 L +350.823 325.912 L +b +356.24 336.495 m +B +U +0 g +1 w +274 347.5 m +281.5 351.5 280.229 357.581 311 338 c +316.5 334.5 322.5 338 351 357.5 C +282 360 l +274 347.5 l +f +1 G +0.5 w +269.25 355.75 m +277.75 353.25 284.25 352.5 288.75 349.75 c +S +353.25 358.25 m +347.25 354 345.5 353.5 339.75 349.5 c +S +0.3 w +355.25 272.75 m +359.75 281.5 361.25 285 363.25 290.75 c +S +0.5 G +0.5 w +354 219 m +339 195 327 176 317 166 c +S +323 197 m +310 150 308 135 235 48 c +S +1 w +241 241.5 m +232 227.5 215.231 198.443 215 198 c +192.581 155 178 110 164 71 c +S +0 G +0.2 w +265.394 600.822 m +263.576 606.114 262.122 612.994 253.035 607.173 C +250.126 603.468 249.763 601.704 249.763 596.589 c +249.763 591.473 254.307 592.179 257.76 587.24 c +261.213 582.301 266.484 579.302 267.029 588.475 c +S +0.3 g +260.668 605.409 m +262.486 601.352 261.94 599.941 257.578 597.824 c +253.216 595.707 257.76 591.473 260.305 592.355 c +262.849 593.237 263.394 592.532 264.303 591.65 c +265.212 590.768 266.666 591.826 264.667 594.119 c +262.667 596.413 259.759 593.943 261.032 597.471 c +262.304 600.999 260.668 605.409 y +b +0 g +257.578 606.644 m +254.125 605.056 251.58 604.174 251.58 598.177 c +251.58 592.179 258.487 590.415 259.214 588.651 c +S +u +1 g +257.397 584.594 m +258.601 581.671 262.019 580.25 265.03 581.419 c +268.041 582.588 269.506 585.905 268.302 588.827 c +267.097 591.75 263.679 593.172 260.668 592.003 c +257.657 590.833 256.192 587.516 257.397 584.594 c +b +262.849 586.711 m +B +U +u +0.2 g +1 w +258.487 586.358 m +263.213 582.477 L +267.211 587.063 L +262.486 590.944 L +258.487 586.358 L +f +262.849 586.711 m +F +U +0 g +309.25 579.875 m +310.75 580.5 313.25 583.125 314.625 581 c +F +1 g +307.964 565.926 m +307.88 566.015 306.794 566.513 307.22 566.682 c +307.647 566.851 307.68 566.599 307.935 566.639 C +307.924 566.13 307.971 566.31 307.964 565.926 c +f +510 104 m +509.564 104.895 511.5 89 495.5 74.5 C +495.5 68 l +506 79 518.582 86.358 510 104 c +f +0 g +0.2 w +403.75 534.25 m +413.25 533.75 415.75 534.25 417.75 534.75 c +S +1 G +0.3 w +538.5 629 m +542 625 547.5 620 y +S +548.75 629.25 m +552.25 625.25 557.75 620.25 y +S +0 G +0.2 w +518.5 587.5 m +522.5 586 526 587.5 527 587.5 c +S +514 617.5 m +518 614 518.5 611.5 520 607.5 c +S +528.25 613.75 m +533.25 615.25 532.5 615.5 538.25 614.25 c +S +1 g +538 637.5 m +537.25 618 533 617.5 531.25 617.5 c +529.5 617.5 528.235 615.255 528.5 622.5 c +529.25 643 528.775 643.326 534.25 642.75 c +539 642.25 539 642.25 540.5 630.75 C +538 631 l +538 629 538 631.25 v +538 633.5 538 637.5 Y +b +0.7 g +507.5 650.75 m +510 648.5 510.25 645.75 511.75 643.25 c +513.25 640.75 508.5 638.25 508.5 638 c +508.5 637.75 507.5 650.75 y +b +1 g +529.25 639.25 m +528.5 643 527 642.75 524 642.75 c +521 642.75 519.75 644 519.5 632.25 C +519.75 638 519.75 641 v +519.75 644 518.75 644.25 515.25 644.25 c +511.75 644.25 511.75 646 509.25 641.25 c +506.75 636.5 505.75 633.25 506 633.25 c +506.25 633.25 509.75 628.25 Y +511.5 620.25 512.75 619.75 515.5 619.5 c +518.25 619.25 520.25 618.25 519.5 623.5 C +521 618.25 521 617.75 524.75 617 c +528.5 616.25 528.5 618.25 528.5 622.5 c +528.5 626.75 529.25 639.25 y +b +507.75 636.75 m +512.687 638.231 515.604 641 515.25 641 C +517.839 637.469 517.494 629.281 508.75 625.5 C +508.75 625.25 502 635 502.25 634.75 c +502.5 634.5 507.75 636.75 y +b +493.5 571.5 m +495.171 563.425 503.634 565.498 503.5 576.25 c +503.25 596.25 515.75 586.25 509 636.75 c +508.301 641.977 510 650.75 506.5 651.5 c +501.514 652.568 500.436 652.26 499.25 644.75 c +498.5 640 496.5 646.25 496 648.5 c +495.5 650.75 493.75 651 490.75 650.25 c +487.75 649.5 488.253 648.665 487.5 645.5 c +486.194 640.013 486.75 641.75 484.5 645.5 c +482.39 649.016 481.306 648.011 477.5 647.25 c +475 646.75 474.784 644.479 475.25 640.75 c +475.5 638.75 474 642.25 472.5 644.5 c +471 646.75 469.25 645.5 466.5 645.5 c +463.75 645.5 463.25 641.003 463.5 635.5 c +463.511 635.25 463 626.25 y +449.75 627.25 l +459.25 618.5 465.606 612.863 468.25 597 c +468.75 594 468 592.25 470 592.75 C +459.719 593.497 459.195 585.398 461 586 c +466.25 587.75 471.75 589.25 476.75 587 c +481.75 584.75 486.25 584.25 489.5 586.25 C +490.25 582.75 492 578.75 493.5 571.5 c +b +0 g +486.25 592.5 m +489 595.25 492.117 593.078 492.25 592.75 c +494.972 586.028 477 591.75 467.25 593 c +S +0.4 w +470 592.75 m +474.25 595.75 475 596 481.5 595.75 c +S +1 J +2.5 w +477.75 630 m +478.5 620.75 l +S +479.25 617.5 m +480 610.5 l +S +480.25 607.75 m +481 600.25 481 600.5 v +S +487.5 631.75 m +487.75 623.5 l +S +487.75 620.75 m +487.75 612.5 l +S +488 609.25 m +488.25 609.25 487.75 602.5 y +S +498 630.75 m +497.25 623.75 l +S +496.75 620.75 m +495.5 612.5 l +S +495.25 609.5 m +493.75 602 l +S +0 J +0.2 w +465.5 637.25 m +464.5 629.75 461.25 628.75 464.75 617 c +S +0.5 w +502 589.25 m +503.25 585 503.5 583.25 503.5 577 c +S +1 g +1 w +521.949 86.694 m +521.637 87.353 523.021 75.657 511.583 64.988 C +511.583 60.205 l +519.089 68.299 528.083 73.713 521.949 86.694 c +f +553.457 99.673 m +553.091 100.449 554.713 86.67 541.309 74.1 C +541.309 68.465 l +550.105 78.001 560.646 84.379 553.457 99.673 c +f +482.74 95.04 m +482.429 95.699 483.812 84.003 472.375 73.334 C +472.375 68.551 l +479.881 76.645 488.875 82.059 482.74 95.04 c +f +450.924 87.63 m +450.69 88.028 451.731 80.968 443.129 74.528 C +443.129 71.641 l +448.774 76.527 455.538 79.795 450.924 87.63 c +f +0 g +308 61.5 m +N +3 w +16.002 40.373 m +568.002 40.127 L +567.748 716.565 L +S +u +15.815 40.248 m +567.815 40.002 L +567.748 716.565 L +15.998 716.81 L +15.815 40.248 L +s +U +%%Trailer +_E end +showpage diff --git a/gs/lib/grayalph.ps b/gs/lib/grayalph.ps new file mode 100644 index 000000000..d7ed52d61 --- /dev/null +++ b/gs/lib/grayalph.ps @@ -0,0 +1,61 @@ +%! +% grayscaled text test, including a trivial user bitmap font + +/inch {72 mul} def + +/BuildCharDict 10 dict def +/$ExampleFont 7 dict def +$ExampleFont begin + /FontType 3 def % user defined font. + /FontMatrix [1 0 0 1 0 0] def + /FontBBox [0 0 1 1] def + /Encoding 256 array def + 0 1 255 {Encoding exch /.notdef put} for + Encoding (a) 0 get /plus put + /CharStrings 2 dict def + CharStrings /.notdef {} put + CharStrings /plus + { gsave + 0 0 moveto + 32 32 true [32 0 0 -32 0 32] + {<0007E000 0007E000 0007E000 0007E000 0007E000 0007E000 0007E000 0007E000 + 0007E000 0007E000 0007E000 0007E000 0007E000 FFFFFFFF FFFFFFFF FFFFFFFF + FFFFFFFF FFFFFFFF FFFFFFFF 0007E000 0007E000 0007E000 0007E000 0007E000 + 0007E000 0007E000 0007E000 0007E000 0007E000 0007E000 0007E000 0007E000> + } imagemask + grestore + } put + /BuildChar + { BuildCharDict begin + /char exch def + /fontdict exch def + /charproc + fontdict /Encoding get char get + fontdict /CharStrings get + exch get def + 1 0 0 0 1 1 setcachedevice + charproc + end + } def +end + +/MyFont $ExampleFont definefont pop + + newpath + .5 inch 7.5 inch moveto + 7.5 inch 0 rlineto + 0 1.5 inch rlineto + -7.5 inch 0 rlineto + closepath + 0 setgray + fill + + /MyFont findfont 72 scalefont setfont + .75 inch 7.75 inch moveto + 0 1 6 + { /n exch def + 1 n 6 div sub setgray + (a) show + } for + +showpage diff --git a/gs/lib/gs_btokn.ps b/gs/lib/gs_btokn.ps new file mode 100644 index 000000000..afba44651 --- /dev/null +++ b/gs/lib/gs_btokn.ps @@ -0,0 +1,283 @@ +% Copyright (C) 1994, 1996, 1997 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% Initialization file for binary tokens. +% When this is run, systemdict is still writable, +% but everything defined here goes into level2dict. + +% Define whether or not to allow writing dictionaries. +/WRITEDICTS true def + +languagelevel 1 .setlanguagelevel +level2dict begin + +% Initialization for the system name table. + +mark +% 0 + /abs /add /aload /anchorsearch /and + /arc /arcn /arct /arcto /array + /ashow /astore /awidthshow /begin /bind + /bitshift /ceiling /charpath /clear /cleartomark +% 20 + /clip /clippath /closepath /concat /concatmatrix + /copy /count /counttomark /currentcmykcolor /currentdash + /currentdict /currentfile /currentfont /currentgray /currentgstate + /currenthsbcolor /currentlinecap /currentlinejoin /currentlinewidth /currentmatrix +% 40 + /currentpoint /currentrgbcolor /currentshared /curveto /cvi + /cvlit /cvn /cvr /cvrs /cvs + /cvx /def /defineusername /dict /div + /dtransform /dup /end /eoclip /eofill +% 60 + /eoviewclip /eq /exch /exec /exit + /file /fill /findfont /flattenpath /floor + /flush /flushfile /for /forall /ge + /get /getinterval /grestore /gsave /gstate +% 80 + /gt /identmatrix /idiv /idtransform /if + /ifelse /image /imagemask /index /ineofill + /infill /initviewclip /inueofill /inufill /invertmatrix + /itransform /known /le /length /lineto +% 100 + /load /loop /lt /makefont /matrix + /maxlength /mod /moveto /mul /ne + /neg /newpath /not /null /or + /pathbbox /pathforall /pop /print /printobject +% 120 + /put /putinterval /rcurveto /read /readhexstring + /readline /readstring /rectclip /rectfill /rectstroke + /rectviewclip /repeat /restore /rlineto /rmoveto + /roll /rotate /round /save /scale +% 140 + /scalefont /search /selectfont /setbbox /setcachedevice + /setcachedevice2 /setcharwidth /setcmykcolor /setdash /setfont + /setgray /setgstate /sethsbcolor /setlinecap /setlinejoin + /setlinewidth /setmatrix /setrgbcolor /setshared /shareddict +% 160 + /show /showpage /stop /stopped /store + /string /stringwidth /stroke /strokepath /sub + /systemdict /token /transform /translate /truncate + /type /uappend /ucache /ueofill /ufill +% 180 + /undef /upath /userdict /ustroke /viewclip + /viewclippath /where /widthshow /write /writehexstring + /writeobject /writestring /wtranslation /xor /xshow + /xyshow /yshow /FontDirectory /SharedFontDirectory /Courier +% 200 + /Courier-Bold /Courier-BoldOblique /Courier-Oblique /Helvetica /Helvetica-Bold + /Helvetica-BoldOblique /Helvetica-Oblique /Symbol /Times-Bold /Times-BoldItalic + /Times-Italic /Times-Roman /execuserobject /currentcolor /currentcolorspace + /currentglobal /execform /filter /findresource /globaldict +% 220 + /makepattern /setcolor /setcolorspace /setglobal /setpagedevice + /setpattern +% pad to 256 + counttomark 256 exch sub { 0 } repeat +% 256 + /= /== /ISOLatin1Encoding /StandardEncoding +% 260 + ([) cvn (]) cvn /atan /banddevice /bytesavailable + /cachestatus /closefile /colorimage /condition /copypage + /cos /countdictstack /countexecstack /cshow /currentblackgeneration + /currentcacheparams /currentcolorscreen /currentcolortransfer /currentcontext /currentflat +% 280 + /currenthalftone /currenthalftonephase /currentmiterlimit /currentobjectformat /currentpacking + /currentscreen /currentstrokeadjust /currenttransfer /currentundercolorremoval /defaultmatrix + /definefont /deletefile /detach /deviceinfo /dictstack + /echo /erasepage /errordict /execstack /executeonly +% 300 + /exp /false /filenameforall /fileposition /fork + /framedevice /grestoreall /handleerror /initclip /initgraphics + /initmatrix /instroke /inustroke /join /kshow + /ln /lock /log /mark /monitor +% 320 + /noaccess /notify /nulldevice /packedarray /quit + /rand /rcheck /readonly /realtime /renamefile + /renderbands /resetfile /reversepath /rootfont /rrand + /run /scheck /setblackgeneration /setcachelimit /setcacheparams +% 340 + /setcolorscreen /setcolortransfer /setfileposition /setflat /sethalftone + /sethalftonephase /setmiterlimit /setobjectformat /setpacking /setscreen + /setstrokeadjust /settransfer /setucacheparams /setundercolorremoval /sin + /sqrt /srand /stack /status /statusdict +% 360 + /true /ucachestatus /undefinefont /usertime /ustrokepath + /version /vmreclaim /vmstatus /wait /wcheck + /xcheck /yield /defineuserobject /undefineuserobject /UserObjects + /cleardictstack +% 376 + /A /B /C /D /E /F /G /H /I /J /K /L /M + /N /O /P /Q /R /S /T /U /V /W /X /Y /Z + /a /b /c /d /e /f /g /h /i /j /k /l /m + /n /o /p /q /r /s /t /u /v /w /x /y /z +% 428 + /setvmthreshold (<<) cvn + (>>) cvn /currentcolorrendering /currentdevparams /currentoverprint /currentpagedevice + /currentsystemparams /currentuserparams /defineresource /findencoding /gcheck +% 440 + /glyphshow /languagelevel /product /pstack /resourceforall + /resourcestatus /revision /serialnumber /setcolorrendering /setdevparams + /setoverprint /setsystemparams /setuserparams /startjob /undefineresource + /GlobalFontDirectory /ASCII85Decode /ASCII85Encode /ASCIIHexDecode /ASCIIHexEncode +% 460 + /CCITTFaxDecode /CCITTFaxEncode /DCTDecode /DCTEncode /LZWDecode + /LZWEncode /NullEncode /RunLengthDecode /RunLengthEncode /SubFileDecode + /CIEBasedA /CIEBasedABC /DeviceCMYK /DeviceGray /DeviceRGB + /Indexed /Pattern /Separation +% 478 -- end +.packtomark +dup /SystemNames exch def .installsystemnames + +% Define printobject and writeobject. +% These are mostly implemented in PostScript, so that we don't have to +% worry about interrupts or callbacks when writing to the output file. + +% Define procedures for accumulating the space required to represent +% an object in binary form. +/cntdict mark % <#refs> <#chars> -proc- <#refs> <#chars> + /integertype /pop load + /realtype 1 index + /marktype 1 index + /nulltype 1 index + /booleantype 1 index + /nametype { length add } bind + /stringtype 1 index + /arraytype null + WRITEDICTS { /dicttype null } if +.dicttomark def +cntdict /arraytype + { dup dup length 5 -1 roll add 4 2 roll + { dup type //cntdict exch get exec } forall + } bind put +WRITEDICTS + { cntdict /dicttype + { dup dup length 2 mul 5 -1 roll add 4 2 roll + { 4 1 roll dup type //cntdict exch get exec + 3 -1 roll dup type //cntdict exch get exec + } forall + } bind put + } if + +/w2dict mark + /nametype { 2 copy .writecvs pop } bind + /stringtype 1 index +.dicttomark def + +/.writeobjects % .writeobjects - + { + mark exch + + % Count the space required for refs and strings. + dup length 0 3 -1 roll + % Stack: -mark- <#refs> <#chars> + + dup 4 1 roll + { dup type //cntdict exch get exec + } forall + + % Write the header. + % Stack: -mark- ... <#refs> <#chars> + counttomark 3 add -2 roll 4 1 roll + % Stack: -mark- ... <#refs> <#chars> + dup counttomark 1 sub index length + 4 index 3 bitshift 4 index add + (xxxxxxxx) .bosheader writestring + + % Write the objects per se. + 3 1 roll pop + counttomark 1 sub index length 3 bitshift exch + 3 bitshift + % Stack: -mark- ... + + counttomark 4 sub + { counttomark -1 roll dup 6 1 roll + dup type /dicttype eq % can't be first object + { { 5 1 roll (xxxxxxxx) .bosobject + 3 index exch writestring + 4 -1 roll (xxxxxxxx) .bosobject + 3 index exch writestring + } forall + } + { { (xxxxxxxx) .bosobject + dup 1 6 index put + 3 index exch writestring + 4 -1 roll pop 0 4 1 roll % clear tag + } forall + } + ifelse + } + repeat + + % Write the strings and names. + pop pop exch pop + % Stack: -mark- ... + + counttomark 1 sub + { counttomark -1 roll + { % The counting pass ensured that the keys and values + % of any dictionary must be writable objects. + % Hence, we are processing a dictionary iff + % the next-to-top stack element is not a file. + 1 index type /filetype ne + { exch 2 index exch dup type //w2dict exch .knownget + { exec } { pop } ifelse pop + } + if + dup type //w2dict exch .knownget { exec } { pop } ifelse + } forall + } + repeat + + % Clean up. + % Stack: -mark- + + pop pop + + } odef +currentdict /cntdict .undef +currentdict /w2dict .undef + +/printobject { % printobject - + (%stdout) (w) file 2 index 2 index writeobject pop pop +} odef +/writeobject { % writeobject - + 3 copy exch + % We must allocate the array in local VM + % to avoid a possible invalidaccess. + .currentglobal false .setglobal exch 1 array astore exch .setglobal + .writeobjects pop pop pop +} odef + +% Implement binary error message output. + /.printerror + { $error /binary get .languagelevel 2 eq and + { currentobjectformat 0 ne + { [ /Error $error /errorname get $error /command get false + ] 250 printobject + } + //.printerror + ifelse + } + //.printerror + ifelse + } bind def + +% End of level2dict + +end +.setlanguagelevel diff --git a/gs/lib/gs_ccfnt.ps b/gs/lib/gs_ccfnt.ps new file mode 100644 index 000000000..0c37d7e4f --- /dev/null +++ b/gs/lib/gs_ccfnt.ps @@ -0,0 +1,93 @@ +% Copyright (C) 1994, 1996 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% Find and register all the precompiled font operators in systemdict. + +/registerfont % registerfont + { DEBUG { (Registering ) print 1 index = } if + dup begin + Encoding type /nametype eq + { Encoding .findencoding /Encoding exch def + } + if + dup /PrefEnc known + { PrefEnc type /nametype eq + { PrefEnc .findencoding /PrefEnc exch def + } + if + } + if + dup /FDepVector known + { /FDepVector [ FDepVector + { .FontDirectory 1 index .knownget + { exch pop } + { ccfonts 1 index .knownget + { registerfont + } + { Fontmap 1 index known + { findfont } + { pop NullFont } + ifelse + } + ifelse + } + ifelse + } + forall ] readonly def + } + if + end + % Use the value of definefont appropriate at run-time, not bind-time + /definefont load exec + } bind odef +% Bind recursive call (bind descends into oparrays: feature!) +/registerfont dup load bind def + +/.loadinitialfonts { + //.loadinitialfonts exec + /ccfonts mark + 0 1 null .getccfont 1 sub { .getccfont dup /FontName get exch } for + .dicttomark def + ccfonts + { .FontDirectory 2 index known { pop pop } { registerfont pop } ifelse } + forall + currentdict /ccfonts .undef +} bind def + +currentdict /registerfont .undef + + +% If we're in a Level 2 system but running in Level 1 mode, +% register the fonts explicitly as resources. +% This is a bit of a hack, but doing better is too much work. + +/level2dict where + { pop /findresource where + { % Level 2 system, Level 2 mode + pop + } + { % Level 2 system, Level 1 mode + /Font /Category level2dict /findresource get exec begin + .FontDirectory + { dup .gcheck { Instances } { LocalInstances } ifelse + 3 1 roll [exch 0 -1] .growput + } + forall end + } + ifelse + } +if diff --git a/gs/lib/gs_cff.ps b/gs/lib/gs_cff.ps new file mode 100644 index 000000000..7510443a5 --- /dev/null +++ b/gs/lib/gs_cff.ps @@ -0,0 +1,605 @@ +% Copyright (C) 1997 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% Loader for CFF (compressed) fonts. +% The following are not implemented yet: +% Deleted entries in the Name Index +% Embedded PostScript +% Multiple Master fonts +% CIDFonts +% Chameleon fonts +% Synthetic fonts +% Also, Type 2 charstrings are converted into Type 1 fonts with +% CharstringType = 2, which may or may not be supported. + +30 dict begin + +% ---------------- Standard strings (actually names) ---------------- % + +/StandardStrings mark +% 0 + /.notdef /space /exclam /quotedbl /numbersign + /dollar /percent /ampersand /quoteright /parenleft + /parenright /asterisk /plus /comma /hyphen + /period /slash /zero /one /two + /three /four /five /six /seven + /eight /nine /colon /semicolon /less + /equal /greater /question /at /A + /B /C /D /E /F + /G /H /I /J /K + /L /M /N /O /P +% 50 + /Q /R /S /T /U + /V /W /X /Y /Z + /bracketleft /backslash /bracketright /asciicircum /underscore + /quoteleft /a /b /c /d + /e /f /g /h /i + /j /k /l /m /n + /o /p /q /r /s + /t /u /v /w /x + /y /z /braceleft /bar /braceright + /asciitilde /exclamdown /cent /sterling /fraction +% 100 + /yen /florin /section /currency /quotesingle + /quotedblleft /guillemotleft /guilsinglleft /guilsinglright /fi + /fl /endash /dagger /daggerdbl /periodcentered + /paragraph /bullet /quotesinglbase /quotedblbase /quotedblright + /guillemotright /ellipsis /perthousand /questiondown /grave + /acute /circumflex /tilde /macron /breve + /dotaccent /dieresis /ring /cedilla /hungarumlaut + /ogonek /caron /emdash /AE /ordfeminine + /Lslash /Oslash /OE /ordmasculine /ae + /dotlessi /lslash /oslash /oe /germandbls +% 150 + /onesuperior /logicalnot /mu /trademark /Eth + /onehalf /plusminus /Thorn /onequarter /divide + /brokenbar /degree /thorn /threequarters /twosuperior + /registered /minus /eth /multiply /threesuperior + /copyright /Aacute /Acircumflex /Adieresis /Agrave + /Aring /Atilde /Ccedilla /Eacute /Ecircumflex + /Edieresis /Egrave /Iacute /Icircumflex /Idieresis + /Igrave /Ntilde /Oacute /Ocircumflex /Odieresis + /Ograve /Otilde /Scaron /Uacute /Ucircumflex + /Udieresis /Ugrave /Yacute /Ydieresis /Zcaron +% 200 + /aacute /acircumflex /adieresis /agrave /aring + /atilde /ccedilla /eacute /ecircumflex /edieresis + /egrave /iacute /icircumflex /idieresis /igrave + /ntilde /oacute /ocircumflex /odieresis /ograve + /otilde /scaron /uacute /ucircumflex /udieresis + /ugrave /yacute /ydieresis /zcaron /exclamsmall + /Hungarumlautsmall /dollaroldstyle /dollarsuperior /ampersandsmall /Acutesmall + /parenleftsuperior /parenrightsuperior /twodotenleader /onedotenleader /zerooldstyle + /oneoldstyle /twooldstyle /threeoldstyle /fouroldstyle /fiveoldstyle + /sixoldstyle /sevenoldstyle /eightoldstyle /nineoldstyle /commasuperior +% 250 + /threequartersemdash /periodsuperior /questionsmall /asuperior /bsuperior + /centsuperior /dsuperior /esuperior /isuperior /lsuperior + /msuperior /nsuperior /osuperior /rsuperior /ssuperior + /tsuperior /ff /ffi /ffl /parenleftinferior + /parenrightinferior /Circumflexsmall /hyphensuperior /Gravesmall /Asmall + /Bsmall /Csmall /Dsmall /Esmall /Fsmall + /Gsmall /Hsmall /Ismall /Jsmall /Ksmall + /Lsmall /Msmall /Nsmall /Osmall /Psmall + /Qsmall /Rsmall /Ssmall /Tsmall /Usmall + /Vsmall /Wsmall /Xsmall /Ysmall /Zsmall +% 300 + /colonmonetary /onefitted /rupiah /Tildesmall /exclamdownsmall + /centoldstyle /Lslashsmall /Scaronsmall /Zcaronsmall /Dieresissmall + /Brevesmall /Caronsmall /Dotaccentsmall /Macronsmall /figuredash + /hypheninferior /Ogoneksmall /Ringsmall /Cedillasmall /questiondownsmall + /oneeighth /threeeighths /fiveeighths /seveneighths /onethird + /twothirds /zerosuperior /foursuperior /fivesuperior /sixsuperior + /sevensuperior /eightsuperior /ninesuperior /zeroinferior /oneinferior + /twoinferior /threeinferior /fourinferior /fiveinferior /sixinferior + /seveninferior /eightinferior /nineinferior /centinferior /dollarinferior + /periodinferior /commainferior /Agravesmall /Aacutesmall /Acircumflexsmall +% 350 + /Atildesmall /Adieresissmall /Aringsmall /AEsmall /Ccedillasmall + /Egravesmall /Eacutesmall /Ecircumflexsmall /Edieresissmall /Igravesmall + /Iacutesmall /Icircumflexsmall /Idieresissmall /Ethsmall /Ntildesmall + /Ogravesmall /Oacutesmall /Ocircumflexsmall /Otildesmall /Odieresissmall + /OEsmall /Oslashsmall /Ugravesmall /Uacutesmall /Ucircumflexsmall + /Udieresissmall /Yacutesmall /Thornsmall /Ydieresissmall (001.000) + (001.001) (001.002) (001.003) /Black /Bold + /Book /Light /Medium /Regular /Roman + /Semibold +.packtomark def + +% ---------------- Standard encodings ---------------- % + +/StandardEncodings [ + +% StandardEncoding +mark + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 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 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 + 0 111 112 113 114 0 115 116 117 118 119 120 121 122 0 123 + 0 124 125 126 127 128 129 130 131 0 132 133 0 134 135 136 + 137 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 138 0 139 0 0 0 0 140 141 142 143 0 0 0 0 + 0 144 0 0 0 145 0 0 146 147 148 149 0 0 0 0 +.packtomark + +% ExpertEncoding +mark + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 1 229 230 0 231 232 233 234 235 236 237 238 13 14 15 99 + 239 240 241 242 243 244 245 246 247 248 27 28 249 250 251 252 + 0 253 254 255 256 257 0 0 0 258 0 0 259 260 261 262 + 0 0 263 264 265 0 266 109 110 267 268 269 0 270 271 272 + 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 + 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 304 305 306 0 0 307 308 309 310 311 0 312 0 0 313 + 0 0 314 315 0 0 316 317 318 0 0 0 158 155 163 319 + 320 321 322 323 324 325 0 0 326 150 164 169 327 328 329 330 + 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 + 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 + 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 +.packtomark + +] readonly def + +% ---------------- Standard Charsets ---------------- % + +% We include an explicit 0 at the beginning of each charset. + +/StandardCharsets [ + +% ISOAdobe +mark + 0 + 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 149 150 151 152 153 154 155 156 157 158 159 160 + 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 + 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 + 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 + 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 + 225 226 227 228 +.packtomark + +% Expert +mark + 0 + 1 229 230 231 232 233 234 235 236 237 238 13 14 15 99 239 + 240 241 242 243 244 245 246 247 248 27 28 249 250 251 252 253 + 254 255 256 257 258 259 260 261 262 263 264 265 266 109 110 267 + 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 + 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 + 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 + 316 317 318 158 155 163 319 320 321 322 323 324 325 326 150 164 + 169 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 + 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 + 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 + 374 375 376 377 378 +.packtomark + +% ExpertSubset +mark + 0 + 1 231 232 235 236 237 238 13 14 15 99 239 240 241 242 243 + 244 245 246 247 248 27 28 249 250 251 253 254 255 256 257 258 + 259 260 261 262 263 264 265 266 109 110 267 268 269 270 272 300 + 301 302 305 314 315 158 155 163 320 321 322 323 324 325 326 150 + 164 169 327 328 329 330 331 332 333 334 335 336 337 338 339 340 + 341 342 343 344 345 346 +.packtomark + +] readonly def + +% ---------------- Font loading ---------------- % + +% ------ Utilities ------ % + +/advance { % advance - + f cff eq { /pos pos 3 -1 roll add store } { pop } ifelse +} def +/next { % - next + f read { 1 advance } if +} def +/nextstring { % nextstring + dup 0 eq { + pop () + } { + string f exch readstring pop dup length advance + } ifelse +} def +/card8 % - card8 + /next load +def +/card16 { % - card16 + card8 8 bitshift card8 add +} def +/offset { % offset + 0 exch { 8 bitshift next add } repeat +} def +/sid % - sid + /card16 load +def +/Index { % - Index + mark card16 dup 0 ne { + 1 exch next dup offset pop exch { + dup offset dup 4 -1 roll sub 3 1 roll exch + } repeat pop + } if pop .packtomark + [ exch { nextstring } forall ] readonly +} def +/tokens { % - tokens ... (op# = 12 means EOF) + { + f read not { 12 exit } if + 1 advance + dup 12 eq { pop next 32 add exit } if + dup 28 lt { exit } if + dup 32 lt { + 28 sub { + { card16 32768 xor 32768 sub } + { 4 offset dup 16#7fffffff gt { -1 32 bitshift add } if } + { tokenreal } + { 31 exit } + } exch get exec + } { + dup 247 lt { + 139 sub + } { + 247 sub { + { next 108 add } + { next 364 add } + { next 620 add } + { next 876 add } + { next 108 add neg } + { next 364 add neg } + { next 620 add neg } + { next 876 add neg } + % 255 is deliberately omitted and will cause a rangecheck + } exch get exec + } ifelse + } ifelse + } loop +} def +/tokenbuf 100 string def +/tokenput { % tokenput + tokenbuf 2 index 3 -1 roll put 1 add +} def +/tokenrealarray [ + (0123456789.E) { } forall + [(E) 0 get /tokenput cvx (-) 0 get] cvx + null % will give an error + (-) 0 get + { exit } +] readonly def +/tokenreal { % - tokenreal + 0 { + next exch 1 index -4 bitshift tokenrealarray exch get exec tokenput + % We must leave the byte on the stack temporarily so that + % the exit will see a consistent stack state. + 1 index 15 and tokenrealarray exch get exec tokenput exch pop + } loop + tokenbuf 0 3 -1 roll getinterval cvr exch pop +} def +/Dict { % Dict - + /opdict exch store { + mark tokens opdict exch .knownget { exec } if cleartomark + } loop cleartomark +} def +/idstring { % idstring + dup 391 lt { StandardStrings } { 391 sub strings } ifelse exch get +} def +/idname { % idname + idstring dup type /nametype ne { cvn } if +} def + +% ------ Top dictionary ------ % + +/offput { % offput - + currentdict exch aload length 1 add packedarray cvx + offsets 3 1 roll put +} def +/queueput { % queueput - + 16#7fffffff offsets { pop .min } forall + pos sub nextstring + 3 1 roll aload length 2 add packedarray cvx + [ queued aload pop counttomark 2 add -1 roll ] + /queued exch store +} def +/xxput { % xxput - + 3 1 roll exch put +} def +/putfi { % putfi - + FontInfo xxput +} def +/xdef { % xdef - + exch def +} def +/topdictops mark + 12 { exit } + 0 { idstring /version putfi } + 1 { idstring /Notice putfi } + 32 { idstring /Copyright putfi } + 2 { idstring /FullName putfi } + 3 { idstring /FamilyName putfi } + 4 { idstring /Weight putfi } + 33 { 0 ne /isFixedPitch putfi } + 34 { /ItalicAngle putfi } + 35 { /UnderlinePosition putfi } + 36 { /UnderlineThickness putfi } + 37 { /PaintType xdef } + 38 { /CharstringType xdef } + 39 { counttomark array astore /FontMatrix xdef } + 13 { /UniqueID xdef } + 5 { counttomark array astore /FontBBox xdef } + 40 { /StrokeWidth xdef } + 14 { counttomark array astore /XUID xdef } + 15 { + dup StandardCharsets length lt { + StandardCharsets exch get /charset xdef + } { + { queuecharset } offput + } ifelse + } + 16 { + dup StandardEncodings length lt { + /Encoding xdef + } { + { queueEncoding } offput + } ifelse + } + 17 { { readCharStrings } offput } + 18 { exch /readPrivate cvx 2 packedarray offput } +.dicttomark readonly def + +/readCharStrings { % readCharStrings - + /CharStringArray Index put +} def + +% ------ Charsets and encodings ------ % + +% Note: formats 1 and 2 can overflow the operand stack. +% We'll fix this if it ever becomes necessary. +/charsetformats [ +{ [ 0 CharStringArray length 1 sub { sid } repeat ] +} +{ [ 0 CharStringArray length 1 sub { + dup 0 eq { pop exit } if + sid card8 1 add 2 index .min { exch 1 sub 1 index 1 add } repeat pop + } loop ] +} +{ [ 0 CharStringArray length 1 sub { + dup 0 eq { pop exit } if + sid card16 1 add 2 index .min { exch 1 sub 1 index 1 add } repeat pop + } loop ] +} +] readonly def +/queuecharset { % queuecharset - + { readcharset } queueput +} def +/readcharset { % readcharset - + begin 0 () /SubFileDecode filter /f exch store + charsetformats next get exec /charset exch def end +} def + +/encodingformats [ +{ 1 1 next { next exch Encoding 3 1 roll put } for +} +{ 1 next { + next next 1 add { + % Stack: gid code + Encoding 1 index 3 index put + exch 1 add exch 1 add + } repeat pop + } repeat pop +} +] readonly def +/queueEncoding { % queueEncoding - + { readEncoding } queueput +} def +/readEncoding { % readEncoding - + begin 0 () /SubFileDecode filter /f exch store + /Encoding [ 256 { /.notdef } repeat ] def + next encodingformats 1 index 127 and get exec + 128 ge { + % Read supplementary encodings. + next { + Encoding next sid idname put + } repeat + } if end +} def + +% ------ Private dictionary ------ % + +/deltarray { % -mark- ... deltarray ... + 0 counttomark 1 sub { counttomark -1 roll add dup } repeat pop + counttomark array astore +} def + +/privatedictops mark + 12 { exit } + 6 { deltarray /BlueValues xdef } + 7 { deltarray /OtherBlues xdef } + 8 { deltarray /FamilyBlues xdef } + 9 { deltarray /FamilyOtherBlues xdef } + 41 { /BlueScale xdef } + 42 { /BlueShift xdef } + 43 { /BlueFuzz xdef } + 10 { 1 array astore /StdHW xdef } + 11 { 1 array astore /StdVW xdef } + 44 { deltarray /StemSnapH xdef } + 45 { deltarray /StemSnapV xdef } + 46 { 0 ne /ForceBold xdef } + 47 { /ForceBoldThreshold xdef } + 48 { /lenIV xdef } + 49 { /LanguageGroup xdef } + 50 { /ExpansionFactor xdef } + 51 { /initialRandomSeed xdef } + 19 { { readSubrs } offput } + 20 { /defaultWidthX xdef } + 21 { /nominalWidthX xdef } + % Multiple Master fonts only + 59 { /NDV xdef } + 60 { /CDV xdef } + 61 { /lenBuildCharArray xdef } +.dicttomark readonly def + +/readPrivate { % readPrivate - + exch 1 index f exch () /SubFileDecode filter /f exch def + /Private get begin //privatedictops Dict end + /f cff def advance +} def + +% ------ Main program ------ % + +% We need to pass the file as a parameter for the sake of the PDF +% interpreter. +/StartData { % StartData - + currentfile exch () /SubFileDecode filter ReadData +} def +/ReadData { % ReadData - + + % Initialize. + + 30 dict begin + /cff exch def + /pos 0 def + /resname exch cvlit def + + % Read the header. + + /f cff def + /vmajor next def + /vminor next def + /hdrsize next def + /aoffsize next def + + % Read the Indexes. + + /names Index def + /topdicts Index def + /strings Index def + /gsubrs Index def + + % Read the top Dicts. + + /offsets 50 dict def + /queued [] def + /opdict null def % reserve a slot + /fonts [ topdicts { + 0 () /SubFileDecode filter /f exch def + 40 dict begin + % Preload defaults that differ from PostScript defaults. + /FontType 1 def + /CharstringType 2 def + /FontMatrix [0.001 0 0 0.001 0 0] def + /charset StandardCharsets 0 get def + /Encoding 0 def + /FontInfo 10 dict + dup /UnderlinePosition -100 put + dup /UnderlineThickness 50 put + def + /Private 20 dict + gsubrs length 0 ne { dup /GlobalSubrs gsubrs put } if + def + //topdictops Dict + currentdict end + } forall ] def + + % Read other tables with queued offsets. + + { /f cff def + offsets pos 2 copy .knownget not { pop pop exit } if + 3 1 roll undef exec + } loop + offsets length 0 ne { + (Error: missing tables at ) print [ offsets { pop } forall ] == + (Current position is ) print pos == + flush stop + } if + + % Process out-of-order tables. + + queued { exec } forall + + % Update Encoding and CharStrings. + + fonts { + begin + % Construct the real Encoding. + % The value of Encoding is either a number, for predefined + % encodings, or an array of mixed GIDs and names. + /Encoding mark Encoding dup type /integertype eq { + StandardEncodings exch get { idname } forall + } { + { + dup type /integertype eq { charset exch get idname } if + } forall + } ifelse .packtomark def + % Construct the CharStrings. + /CharStrings charset length dict def + 0 1 charset length 1 sub { + dup CharStringArray exch get + exch charset exch get idstring + CharStrings xxput + } for + % Remove unwanted entries. + currentdict /charset undef + currentdict /CharSetArray undef + end + } forall + + % Wrap up. + + resname mark 0 1 fonts length 1 sub { + dup names exch get exch fonts exch get + dup /FontName 3 index put + 1 index exch definefont + } for .dicttomark + end % temporary dict + end % FontSetInit ProcSet + /FontSet defineresource pop + +} bind def + +% ---------------- Resource category definition ---------------- % + +currentdict end readonly + +languagelevel exch 2 .setlanguagelevel + +/FontSet /Generic /Category findresource dup length dict .copydict +/Category defineresource pop + +/FontSetInit exch /ProcSet defineresource pop + +.setlanguagelevel diff --git a/gs/lib/gs_cidfn.ps b/gs/lib/gs_cidfn.ps new file mode 100644 index 000000000..557065b7c --- /dev/null +++ b/gs/lib/gs_cidfn.ps @@ -0,0 +1,428 @@ +% Copyright (C) 1995, 1996, 1997 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% ProcSet for implementing CIDFont and CIDMap resources. +% When this is run, systemdict is still writable. + +% ---------------- Defining CIDFont resources ---------------- % + +% Define a CIDFont resource. This is the defineresource implementation for +% the CIDFont resource category. + +/.definecidfont [ + +% CIDFontType 0 +{ dup /FontMatrix known not + { dup /FontMatrix [0.001 0 0 0.001 0 0] put + dup /FDArray get + { /FontMatrix get [1000 0 0 1000 0 0] 1 index concatmatrix pop } + forall + } + if + dup /FDArray get mark exch + { % Add pro forma entries + dup /FontType 1 put + dup /CharStrings 10 dict put + dup /Encoding [] put + % Create a dummy Subrs array now. + dup /Private get dup /SubrCount .knownget + { array 1 index /Subrs 3 -1 roll put } + if pop + dup /FontName .knownget not { () } if exch .buildfont1 exch pop + } + forall ] 1 index /FDepVector 3 -1 roll put + 1 index exch .buildfont9 exch pop +} bind + +% CIDFontType 1 +{ 1 index exch .buildfont10 exch pop +} bind + +% CIDFontType 2 +{ 1 index exch .buildfont11 exch pop +} bind + +] def + +% ---------------- Reading CIDFontType 0 files ---------------- % + +30 dict begin + +% We add the following entries to the CIDFont dictionary, in addition to +% the ones documented by Adobe: +% ReadString - procedure for reading a string from the binary data +% SubrCache - dictionary for caching Subr arrays +% For CIDFonts where we read the data from disk incrementally: +% DataOffset - starting position of data in file +% (if data are in hex) OffsetMap - map from logical data positions to +% physical positions in file + +/StartData % <(Binary)|(Hex)> StartData - + % (currentdict is CID font dict) +{ % If we're loading a resource file, we can just save a + % pointer to the binary data and load it incrementally. + % Check for this by opening the resource file, + % positioning it to currentfile's position plus the + % data length, and checking for %%EndData. + mark + { currentfile fileposition + CIDFontName 100 string ResourceFileName (r) file + mark + { % Stack: (Binary)|(Hex) length -mark- pos resfile + % -mark- + 5 index (Hex) eq + { 1 index 3 index setfileposition + 1 index 5 index .skiphex + %**************** SKIP > AND WHITESPACE SOMEHOW + } + { 1 index 3 index 6 index add setfileposition + } + ifelse + 1 index 9 string readstring pop (%%EndData) ne { stop } if + } + .internalstopped { cleartomark closefile stop } if + pop % pop the mark + } + .internalstopped + { % File is not positionable, load the data now. + cleartomark exch (Hex) eq + { { currentfile exch readhexstring pop } } + { { currentfile exch readstring pop } } + ifelse /ReadString exch def + dup 65535 le + { string ReadString + } + { mark exch + { dup 0 eq { pop exit } if + dup 65535 min dup string ReadString + 3 1 roll sub + } + loop ] + } + ifelse + /GlyphData exch def + /.vmreadstring cvx + } + { % File is positionable, just save a pointer. + % Stack: (Binary)|(Hex) length -mark- pos file + 4 1 roll + /DataOffset exch def + pop /GlyphData exch def + exch (Hex) eq + { % Hex data, build the offset map. + .buildoffsetmap + /.hexreadstring + } + { % Binary data, just skip over it. + currentfile DataOffset GlyphData add setfileposition + /.binaryreadstring + } + ifelse cvx + 2 packedarray cvx + } + ifelse /ReadString exch def + /SubrCache 10 dict def + CIDFontName currentdict /CIDFont defineresource pop + end % CID font dict + end % resource category dict +} bind def + +% Skip a given distance in an ASCIIHex encoded file. We use this at +% rendering time as well. +/.skiphex % .skiphex - +{ exch /ASCIIHexDecode filter dup 3 -1 roll () /SubFileDecode filter + dup flushfile closefile closefile +} bind def + +% Build the map from logical offsets to physical offsets in ASCIIHex +% encoded data. +/.buildoffsetmap +{ /OffsetMap GlyphData 256 idiv 8000 min array def + 2 dict begin + /block GlyphData OffsetMap length idiv def + 0 1 OffsetMap length 1 sub + { OffsetMap exch currentfile fileposition put + currentfile block .skiphex + } + for + GlyphData block mod dup 0 eq + { pop } + { currentfile exch .skiphex } + ifelse + end % scratch dict +} bind def + +currentdict end + +% ---------------- Rendering ---------------- % + +% ------ Generic ------ % + +% Read a string at a given offset in a "file" (binary file, ASCII hex file, +% or GlyphData in RAM). +/.binaryreadstring % .binaryreadstring + { dup 4 -1 roll DataOffset add setfileposition exch readstring pop + } bind def +/.hexreadstring % .hexreadstring +{ % Use the OffsetMap to get to the block of hex data, + % then skip to the correct position by reading. + GlyphData OffsetMap length idiv + % Stack: pos string file blocklen + 3 index 1 index idiv OffsetMap exch get + 2 index exch setfileposition + % Skip the next (pos % blocklen) hex bytes. + 4 -1 roll exch mod 1 index exch .skiphex + % Stack: string file + exch readhexstring pop +} bind def +/.vmreadstring % .vmreadstring +{ GlyphData .stringsreadstring +} bind def +/.stringsreadstring % .stringsreadstring + % +{ dup type /stringtype eq + { 3 1 roll length getinterval + } + { { % Stack: pos string glyphdata + dup 0 get length dup 4 index gt { exit } if + 4 -1 roll exch sub 3 1 roll + dup length 1 sub 1 exch getinterval + } + loop + % Stack: pos string glyphdata glyphdata[0]length + % We know no request can span more than 2 strings. + 3 index 3 index length add 1 index le + { % Request fits in a single string: just return a substring. + pop 0 get 3 1 roll length getinterval + } + { % Request spans 2 strings. Copy the first part. + 1 index 0 get 4 index 3 -1 roll 1 index sub getinterval + 2 index copy + % Copy the second part. + % Stack: pos str glyphdata str1 + length exch 1 get 0 3 index length + 3 index sub getinterval 2 index 3 1 roll putinterval + exch pop + } + ifelse + } + ifelse +} bind def + +% Interpret a byte string as a (big-endian) integer. +/.cvbsi % .cvbsi +{ 0 exch { exch 8 bitshift add } forall +} bind def + +% Read an integer from binary data. +/.readint % .readint +{ string ReadString .cvbsi +} bind def + +% Read the glyph data for a given CID. +% The CIDFont is currentdict. +/.readglyphdata % .readglyphdata +{ currentdict /GlyphDirectory .knownget + { dup type /arraytype eq + { 1 index exch get } + { 1 index exch .knownget not { null } if } + ifelse + dup null eq + { FDepVector 0 get exch } + { FDBytes 0 eq + { FDepVector 0 get exch } + { % Note: FDBytes > 1 is not supported. + dup 0 get FDepVector exch get + exch dup length 1 sub 1 exch getinterval + } + ifelse + } + ifelse + } + { FDBytes GDBytes add mul CIDMapOffset add + dup FDBytes .readint exch + FDBytes add dup GDBytes .readint + exch GDBytes add FDBytes add GDBytes .readint + % Stack: fd pos nextpos + 1 index sub dup 0 eq + { pop pop pop FDepVector 0 get null } + { string ReadString exch FDepVector exch get exch } + ifelse + } + ifelse +} bind def + +% ------ CIDFontType 0 ------ % + +% Read some Subrs for the current Type 1 subfont. +% The subfont's Private dict is currentdict; the CIDFont itself is the +% next dictionary on the stack. +/.readsubrs % .readsubrs +{ 1 SubrCount 1 sub + { dup SDBytes mul SubrMapOffset add + dup SDBytes .readint exch SDBytes add SDBytes .readint + 1 index sub string ReadString 2 index 3 1 roll put + } + for +} bind def + +% Ensure that all the Subrs for the current Type 1 subfont are loaded. +% The subfont's Private dict is currentdict; the CIDFont itself is the +% next dictionary on the stack. +/.loadsubrs +{ currentdict /SubrMapOffset .knownget + { Subrs 0 get null ne + { pop % We've already loaded the Subrs. + } + { SubrCache 1 index .knownget + { % We've already loaded some Subrs at this offset. + % Make sure we've got as many as we need. + dup length SubrCount lt + { % We need to load more. + SubrCount array exch 1 index copy length .readsubrs + SubrCache 3 -1 roll 2 index put + } + if + } + { % We haven't loaded any Subrs at this offset yet. + SubrCount array 0 .readsubrs + SubrCache 3 -1 roll 2 index put + } + ifelse + Subrs copy pop + } + ifelse + } + if +} bind def + +% BuildGlyph procedure for CIDFontType 0. +% ****** WHY NOT USE .type1execchar FOR THIS? ****** +% The name %Type9BuildGlyph is known to the interpreter. +/.cid0buildstring 10 string def +(%Type9BuildGlyph) cvn % %Type9BuildGlyph - +{ .currentglobal 3 1 roll 1 index gcheck .setglobal + 1 index begin + dup .readglyphdata dup null eq + { %**** HANDLE NOTDEF **** + } + if + % Stack: cidfont cid subfont charstring +dup null eq { pop pop pop pop } { %**** WRONG **** + 4 -1 roll pop + exch dup /Private get begin .loadsubrs end + 3 -1 roll //.cid0buildstring cvs cvn 3 1 roll + dup /CharStrings get 3 index 4 -1 roll put + setfont + 1000 0 setcharwidth %**** WRONG **** + 0 0 moveto glyphshow +} ifelse %**** WRONG **** + end + .setglobal +} bind def + +% ------ CIDFontType 2 ------ % + +% BuildGlyph procedure for CIDFontType 2. +% ****** ADD THE OUTLINE STRING AS AN ARGUMENT TO .type42execchar. ****** +% The name %Type11BuildGlyph is known to the interpreter. +(%Type11BuildGlyph) cvn % %Type11BuildGlyph - +{ .currentglobal 3 1 roll 1 index gcheck .setglobal + 1 index begin + dup GDBytes mul GDBytes string CIDMap .stringsreadstring .cvbsi + % Stack: cidfont cid glyphindex +%**************** GlyphDirectory is not supported yet. +( + currentdict /GlyphDirectory .knownget +) pop false + { dup type /arraytype eq + { 1 index exch get } + { 1 index exch .knownget not { null } if } + ifelse + dup null eq + { %**** HANDLE NOTDEF + } + if + 1 index exch .type42execchar + } + { 1 index exch .type42execchar + } + ifelse + end + .setglobal +} bind def + +% ---------------- Define resources ---------------- % + +languagelevel exch 2 .setlanguagelevel + +% Define the CIDInit ProcSet resource. +% The ProcSet dictionary is still on the stack. + +/CMap /Generic /Category findresource dup length dict .copydict +/Category defineresource pop + % We might have loaded CMap support already. +/CIDInit /ProcSet 2 copy resourcestatus { + pop pop findresource dup length 4 index length add dict .copydict + 4 -1 roll exch .copydict +} { + 3 -1 roll +} ifelse exch defineresource pop + +% Define the CIDFont resource category. + +/CIDFont /Generic /Category findresource dup length dict .copydict +dup /InstanceType /dicttype put +dup /DefineResource { + dup /CIDFontType get dup 9 add /FontType exch 3 index 3 1 roll put + //.definecidfont exch get exec + /Generic /Category findresource /DefineResource get exec +} put +/Category defineresource pop + +currentdict /.definecidfont undef + +% Add the new FontType resources. + +9 1 11 { dup /FontType defineresource pop } for + +% Add the new FMapType resource. + +9 dup /FMapType defineresource pop + +% Define the CIDMap resource category. +% These aren't documented, but it's clear what they are for: +% to give names to CIDMaps for CIDFontType 2 fonts. + +/CIDMap /Generic /Category findresource dup length dict .copydict +dup /.CheckResource { + % Allow either a string or an array of strings. + dup type dup /stringtype eq + { pop true + } + { dup /arraytype eq exch /packedarraytype eq or + { true exch { type /stringtype ne { pop false exit } if } forall + } + { false + } + ifelse + } + ifelse +} bind put +/Category defineresource pop + +.setlanguagelevel diff --git a/gs/lib/gs_cmap.ps b/gs/lib/gs_cmap.ps new file mode 100644 index 000000000..7905d3639 --- /dev/null +++ b/gs/lib/gs_cmap.ps @@ -0,0 +1,242 @@ +% Copyright (C) 1995, 1996, 1997 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% ProcSet for implementing CMap resources. +% When this is run, systemdict is still writable. + +% NOTE: Rearranged fonts are not implemented yet. + +% ---------------- Public operators ---------------- % + +% composefont doesn't appear in CMap files -- it's documented in +% the "PostScript Language Reference Manual Supplement". +/composefont % composefont + { 10 dict begin + 1 index dup type /dicttype ne { /CMap findresource } if + /CMap exch def + /Encoding [ 0 1 4 index length 1 sub { } for ] def + /FDepVector 1 index def + /FMapType 9 def + /FontMatrix matrix def + /FontName 3 index def + /CMap load /WMode .knownget { /WMode exch def } if + /FontType 0 def + pop pop currentdict end /Font defineresource + } bind odef + +% ---------------- CMap operators ---------------- % + +30 dict begin + +% Our internal .CodeMaps structure is an array of two arrays: array 0 +% is the map for defined characters, array 1 is the map for notdefs. +% Both are multi-level arrays indexed by the successive bytes of the +% character code. Each value is either a sub-array, null, a character name, +% a CID (an integer), or a character code (expressed as a byte string). +% All of the arrays are read-only after they have been built. +% +% Note that the code in zfcmap.c that constructs the C structures from +% the PostScript structures has intimate knowledge of the above format. + +/.getmap { .CodeMaps exch get } bind def +/.putmap { .CodeMaps exch 3 -1 roll put } bind def + +% ------ Font-level operators ------ % + +/begincmap % - begincmap - + { /.CodeMaps [256 array 256 array] def + } bind def +/endcmap % - endcmap - + { /.CodeMaps .CodeMaps .endmap def + /CodeMap null def % for .buildcmap + currentdict end .buildcmap begin + } bind def + +/begincodespacerange % begincodespacerange - + { pop mark + } bind def +/endcodespacerange % ... endcodespacerange - + { counttomark 2 idiv + { .CodeMaps { 3 copy .addcodespacerange pop } forall pop pop + } repeat pop + } bind def + +/.addcodespacerange % .addcodespacerange - + { 2 index length 1 eq + { 2 { 3 -1 roll 0 get } repeat 1 exch + { 2 copy 0 put pop } for pop + } + { 2 index 0 get 1 3 index 0 get + 6 -2 roll + 2 { 1 1 index length 1 sub getinterval 6 1 roll } repeat + % Stack: lo hi map lo0 1 hi0 + { 2 copy get null eq { 2 copy 256 array put } if + 4 copy get .addcodespacerange pop + } + for pop pop pop + } + ifelse + } bind def +/.endmap % .endmap + { dup type /arraytype eq { dup { .endmap exch } forall astore readonly } if + } bind def + +/usecmap % usecmap - + { /CMap findresource + dup length dict .copydict + currentdict end exch .copydict begin + } bind def + +% ------ Rearranged font operators ------ % + +/beginrearrangedfont % beginrearrangedfont - + { (NOT IMPLEMENTED YET.\n) print flush + } bind def +/endrearrangedfont % - endrearrangedfont - + { (NOT IMPLEMENTED YET.\n) print flush + } bind def + +/usefont % usefont - + { (NOT IMPLEMENTED YET.\n) print flush + } bind def + +/beginusematrix % beginusematrix - + { (NOT IMPLEMENTED YET.\n) print flush + } bind def +/endusematrix % endusematrix - + { (NOT IMPLEMENTED YET.\n) print flush + } bind def + +% ------ Character name/code selector operators ------ % + +/beginbfchar % beginbfchar - + { pop mark + } bind def +/endbfchar % ... endbfchar + { 0 .getmap .endmapchar 0 .putmap + } bind def + +/beginbfrange % beginbfrange - + { pop mark + } bind def +/endbfrange % ... + % endbfrange - + { 0 .getmap counttomark 3 idiv { .addbfrange } repeat 0 .putmap pop + } bind def + +/.addbfrange % + % .addbfrange + { 1 index type /stringtype eq + { { dup length string copy dup dup length 1 sub 2 copy get 1 add put } + exch .addmaprange + } + { 2 dict begin exch /codes 1 index def 0 get exch + { codes dup length 1 sub 1 exch getinterval /codes 1 index def + dup length 0 gt { 0 get } if + } + exch .addmaprange end + } + ifelse exch pop + } bind def + +% ------ CID selector operators ------ % + +/begincidchar % begincidchar - + { pop mark + } bind def +/endcidchar % ... endcidchar - + { 0 .getmap .endmapchar 0 .putmap + } bind def + +/begincidrange % begincidrange - + { pop mark + } bind def +/endcidrange % ... endcidrange - + { 0 .getmap counttomark 3 idiv { { 1 add } exch .addmaprange exch pop } repeat + 0 .putmap pop + } bind def + +/.endmapchar % -mark- ... .endmapchar - + { counttomark 2 idiv + { 2 index 3 1 roll { } exch .addmaprange exch pop + } repeat exch pop + } bind def + +/.addmaprange % + % .addcidrange + { % We may be updating a (partly) read-only map from another CMap. + % If so, implement copy-on-write. + dup wcheck not { dup length array copy } if + 4 index length 1 eq + { 2 { 5 -1 roll 0 get } repeat 1 exch + { % Stack: value proc map code + 2 copy 5 index put pop + 3 -1 roll 2 index exec 3 1 roll + } for + } + { 4 index 0 get 1 5 index 0 get + 8 -2 roll + 2 { 1 1 index length 1 sub getinterval 8 1 roll } repeat + % Stack: lo hi next proc map lo0 1 hi0 + { 6 copy get .addmaprange + % Stack: lo hi oldnext proc map i next submap + exch 6 1 roll 5 -1 roll pop + % Stack: lo hi next proc map i submap + 3 copy put pop pop + } + for 5 -2 roll pop pop + } + ifelse exch pop + } bind def + +% ------ notdef operators ------ % + +/beginnotdefchar % beginnotdefchar - + { pop mark + } bind def +/endnotdefchar % ... endnotdefchar - + { counttomark 2 idiv { 1 index exch .addnotdefrange } repeat pop + } bind def + +/beginnotdefrange % beginnotdefrange - + { pop mark + } bind def +/endnotdefrange % ... endnotdefrange - + { counttomark 3 idiv { .addnotdefrange } repeat pop + } bind def + +/.addnotdefrange % .addnotdefrange - + { { } 1 .getmap .addmaprange 1 .putmap pop + } bind def + +% ---------------- Resource category definition ---------------- % + +currentdict end + +languagelevel exch 2 .setlanguagelevel + +/CMap /Generic /Category findresource dup length dict .copydict +/Category defineresource pop + % We might have loaded CID font support already. +/CIDInit /ProcSet 2 copy { findresource } .internalstopped + % An interior `stopped' might have reset VM allocation to local. +true .setglobal + { pop pop 3 -1 roll } + { dup length 4 index length add dict .copydict 4 -1 roll exch .copydict } +ifelse exch defineresource pop + +.setlanguagelevel diff --git a/gs/lib/gs_cmdl.ps b/gs/lib/gs_cmdl.ps new file mode 100644 index 000000000..a245ebbdb --- /dev/null +++ b/gs/lib/gs_cmdl.ps @@ -0,0 +1,181 @@ +% Copyright (C) 1994, 1996 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% Parse and execute the command line. +% C code handles the following switches: -h/-? -I -M -v + +/cmddict 50 dict def +cmddict begin + +% ---------------- Utility procedures ---------------- % + +% Get the next argument from the parsed argument list. +/nextarg % - nextarg true + % - nextarg false + { argv length 0 eq + { false } + { argv dup 0 get exch dup length 1 sub 1 exch getinterval /argv exch def } + ifelse + } bind def + +% Run a file, under job control if implemented. +/runjob % runjob - + { end % cmddict + /startjob where { pop false () startjob pop } + run + //cmddict begin + } bind def +/runfilejob % runfilejob - + { findlibfile { exch pop } { (r) file } runjob + } bind def + +% Expand arguments. Free variables: expand@. +/expandarg % expandarg + { dup () eq + { pop + } + { dup dup (--) eq exch (-+) eq or + { pop /expand@ false def + } + { expand@ { (@) anchorsearch } { false } ifelse + { pop findlibfile + { exch pop } + { (r) file } % let the error happen + expandargfile + } + if + } + ifelse + } + } bind def +/expandargfile % expandargfile + { [ exch cvlit + { token not { exit } if + dup type /stringtype ne { =string cvs dup length string copy } if + expandarg + } + /exec cvx + ] cvx loop + } bind def + +% ---------------- Recognized switches ---------------- % + +% Switches with arguments are defined as ; +% switches without arguments are defined as -. + +% Switches without arguments +/-- + { nextarg not + { (-- and -+ require a file name.\n) print flush } + { //systemdict /ARGUMENTS argv put /argv [] def runjob } + ifelse + } bind def +/-+ /-- load def +/-@ /-- load def +/-A { (@) Z } bind def +/-c + { { argv length 0 eq { exit } if + argv 0 get (-) anchorsearch { pop pop exit } if + pop nextarg token + { exch pop % Probably should check for empty. + end exec //cmddict begin + } + if + } + loop + } bind def +/-e { (#) Z } bind def +/-E /-e load def +/-f { } def +/-q { //systemdict /QUIET true put } bind def + +% Switches with arguments +/d + { (=) search not { (#) search not { () exch dup } if } if + exch pop cvn dup where + { pop (Redefining ) print print ( is not allowed.\n) print flush pop } + { exch token + { exch pop } % Probably should check for empty. + { true } + ifelse + //systemdict 3 1 roll put + } + ifelse + } bind def +/D /d load def +/f { dup length 0 ne { runfilejob } if } bind def +/g + { (x) search { cvi pop exch cvi } { cvi dup } ifelse + //systemdict begin /DEVICEHEIGHT exch def /DEVICEWIDTH exch def end + } bind def +/r + { (x) search { cvr pop exch cvr } { cvr dup } ifelse + //systemdict begin /DEVICEYRESOLUTION exch def /DEVICEXRESOLUTION exch def end + } bind def +/s + { (=) search not { (#) search not { () exch dup } if } if + exch pop cvn dup where { pop dup load } { () } ifelse + type /stringtype ne + { (Redefining ) print print ( is not allowed.\n) print flush pop } + { exch //systemdict 3 1 roll put } + ifelse + } bind def +/S /s load def +/Z { true .setdebug } bind def + +% ---------------- Main program ---------------- % + +% We process the command line in two passes. In the first pass, +% we read and expand any @-files as necessary. The second pass +% does the real work. + +/cmdstart + { //cmddict begin + /expand@ true def + [ + % Process the GS_OPTIONS environment variable. + (GS_OPTIONS) getenv { 0 () /SubFileDecode filter expandargfile } if + % Process the actual command line. + .getargv { expandarg } forall + ] readonly /argv exch def + % Now interpret the commands. + { nextarg not { exit } if + dup 0 get (-) 0 get eq + { dup length 1 eq + { pop (%stdin) (r) file runjob + } + { dup length 2 gt + { dup dup length 2 sub 2 exch getinterval exch 1 1 getinterval } + if currentdict .knownget + { exec + } + { (Ignoring unknown switch ) print + dup length 1 eq { (-) print print } if print + (\n) print flush + } + ifelse + } + ifelse + } + { runfilejob + } + ifelse + } + loop end + } bind def + +end % cmddict diff --git a/gs/lib/gs_dbt_e.ps b/gs/lib/gs_dbt_e.ps new file mode 100644 index 000000000..53698ec47 --- /dev/null +++ b/gs/lib/gs_dbt_e.ps @@ -0,0 +1,60 @@ +% Copyright (C) 1993, 1994 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% Define the Dingbats encoding vector. +/currentglobal where + { pop currentglobal { setglobal } true setglobal } + { { } } +ifelse +/DingbatsEncoding +% \000 + StandardEncoding 0 32 getinterval aload pop % /.notdef +% \040 + /space /a1 /a2 /a202 /a3 /a4 /a5 /a119 + /a118 /a117 /a11 /a12 /a13 /a14 /a15 /a16 + /a105 /a17 /a18 /a19 /a20 /a21 /a22 /a23 + /a24 /a25 /a26 /a27 /a28 /a6 /a7 /a8 +% \100 + /a9 /a10 /a29 /a30 /a31 /a32 /a33 /a34 + /a35 /a36 /a37 /a38 /a39 /a40 /a41 /a42 + /a43 /a44 /a45 /a46 /a47 /a48 /a49 /a50 + /a51 /a52 /a53 /a54 /a55 /a56 /a57 /a58 +% \140 + /a59 /a60 /a61 /a62 /a63 /a64 /a65 /a66 + /a67 /a68 /a69 /a70 /a71 /a72 /a73 /a74 + /a203 /a75 /a204 /a76 /a77 /a78 /a79 /a81 + /a82 /a83 /a84 /a97 /a98 /a99 /a100 /.notdef +% \200 + StandardEncoding 0 32 getinterval aload pop % /.notdef +% \240 + /.notdef /a101 /a102 /a103 /a104 /a106 /a107 /a108 + /a112 /a111 /a110 /a109 /a120 /a121 /a122 /a123 + /a124 /a125 /a126 /a127 /a128 /a129 /a130 /a131 + /a132 /a133 /a134 /a135 /a136 /a137 /a138 /a139 +% \300 + /a140 /a141 /a142 /a143 /a144 /a145 /a146 /a147 + /a148 /a149 /a150 /a151 /a152 /a153 /a154 /a155 + /a156 /a157 /a158 /a159 /a160 /a161 /a163 /a164 + /a196 /a165 /a192 /a166 /a167 /a168 /a169 /a170 +% \340 + /a171 /a172 /a173 /a162 /a174 /a175 /a176 /a177 + /a178 /a179 /a193 /a180 /a199 /a181 /a200 /a182 + /.notdef /a201 /a183 /a184 /a197 /a185 /a194 /a198 + /a186 /a195 /a187 /a188 /a189 /a190 /a191 /.notdef +256 packedarray .defineencoding +3 DingbatsEncoding .registerencoding +exec diff --git a/gs/lib/gs_diskf.ps b/gs/lib/gs_diskf.ps new file mode 100644 index 000000000..3a9e65100 --- /dev/null +++ b/gs/lib/gs_diskf.ps @@ -0,0 +1,225 @@ +% Copyright (C) 1996 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% Support for converting Type 1 fonts without eexec encryption to +% Type 4 fonts that load individual character outlines on demand. + +% If DISKFONTS is true, we load individual CharStrings as they are needed. +% (This is intended primarily for machines with very small memories.) +% Initially, the character definition is the file position of the definition; +% this gets replaced with the actual CharString. +% Note that if we are loading characters lazily, CharStrings is writable. + +% _Cstring must be long enough to hold the longest CharString for +% a character defined using seac. This is lenIV + 4 * 5 (for the operands +% of sbw, assuming div is not used) + 2 (for sbw) + 3 * 5 (for the operands +% of seac other than the character codes) + 2 * 2 (for the character codes) +% + 2 (for seac), i.e., lenIV + 43. + +/_Cstring 60 string def + +% When we initially load the font, we call +% cskip_C +% to skip over each character definition and return the file position instead. +% This substitutes for the procedure +% string currentfile exch read[hex]string pop +% [encrypt] +% What we actually store in the CharString is fileposition * 1000 + length, +% negated if the string is stored in binary form. + +/cskip_C + { exch dup 1000 ge 3 index type /nametype ne or + { % This is a Subrs string, or the string is so long we can't represent + % its length. Load it now. + exch exec + } + { % Record the position and length, and skip the string. + dup currentfile fileposition 1000 mul add + 2 index 3 get /readstring cvx eq { neg } if + 3 1 roll + dup _Cstring length idiv + { currentfile _Cstring 3 index 3 get exec pop pop + } repeat + _Cstring length mod _Cstring exch 0 exch getinterval + currentfile exch 3 -1 roll 3 get exec pop pop + } + ifelse + } bind def + +% Load a CharString from the file. The font is the top entry +% on the dictionary stack. +/load_C % load_C - + { dup abs 1000 idiv FontFile exch setfileposition + CharStrings 3 1 roll + .currentglobal CharStrings .gcheck .setglobal exch + dup 0 lt + { neg 1000 mod string FontFile exch readstring } + { 1000 mod string FontFile exch readhexstring } + ifelse pop + exch .setglobal +% If the CharStrings aren't encrypted on the file, encrypt now. + Private /-| get 0 get + dup type /nametype ne + { dup length 5 sub 5 exch getinterval exec } + { pop } + ifelse dup 4 1 roll put +% If the character is defined with seac, load its components now. + mark exch seac_C + counttomark + { StandardEncoding exch get dup CharStrings exch get + dup type /integertype eq { load_C } { pop pop } ifelse + } repeat + pop % the mark + } bind def + +/seac_C % seac_C ..or nothing.. + { dup length _Cstring length le + { 4330 exch _Cstring .type1decrypt exch pop + dup dup length 2 sub 2 getinterval <0c06> eq % seac + { dup length + Private /lenIV known { Private /lenIV get } { 4 } ifelse + exch 1 index sub getinterval +% Parse the string just enough to extract the seac information. +% We assume that the only possible operators are hsbw, sbw, and seac, +% and that there are no 5-byte numbers. + mark 0 3 -1 roll + { exch + { { dup 32 lt + { pop 0 } + { dup 247 lt + { 139 sub 0 } + { dup 251 lt + { 247 sub 256 mul 108 add 1 1 } + { 251 sub -256 mul -108 add -1 1 } + ifelse + } + ifelse + } + ifelse + } % 0 + { mul add 0 } % 1 + } + exch get exec + } + forall pop + counttomark 1 add 2 roll cleartomark % pop all but achar bchar + } + { pop % not seac + } + ifelse + } + { pop % punt + } + ifelse + } bind def + +% Define replacement procedures for loading fonts. +% If DISKFONTS is true and the body of the font is not encrypted with eexec: +% - Prevent the CharStrings from being made read-only. +% - Substitute a different CharString-reading procedure. +% (eexec disables this because the implicit 'systemdict begin' hides +% the redefinitions that make the scheme work.) +% We assume that: +% - The magic procedures (-|, -!, |-, and |) are defined with +% executeonly or readonly; +% - The contents of the reading procedures are as defined in bdftops.ps; +% - The font includes the code +% /CharStrings readonly put +/.loadfontdict 6 dict def mark + /begin % push this dict after systemdict + { dup begin + //systemdict eq { //.loadfontdict begin } if + } bind + /end % match begin + { currentdict end + //.loadfontdict eq currentdict //systemdict eq and { end } if + } bind + /dict % leave room for FontFile, BuildChar, BuildGlyph + { 3 add dict + } bind + /executeonly % for reading procedures + { readonly + } + /noaccess % for Subrs strings and Private dictionary + { readonly + } + /readonly % for procedures and CharStrings dictionary + { % We want to take the following non-standard actions here: + % - If the operand is the CharStrings dictionary, do nothing; + % - If the operand is a number (a file position replacing the + % actual CharString), do nothing; + % - If the operand is either of the reading procedures (-| or -!), + % substitute a different one. + dup type /dicttype eq % CharStrings or Private + count 2 gt and + { 1 index /CharStrings ne { readonly } if } + { dup type /arraytype eq % procedure or data array + { dup length 5 ge 1 index xcheck and + { dup 0 get /string eq + 1 index 1 get /currentfile eq and + 1 index 2 get /exch eq and + 1 index 3 get dup /readstring eq exch /readhexstring eq or and + 1 index 4 get /pop eq and + { /cskip_C cvx 2 packedarray cvx + } + { readonly + } + ifelse + } + { readonly + } + ifelse + } + { dup type /stringtype eq % must be a Subr string + { readonly } + if + } + ifelse + } + ifelse + } bind + /definefont % to insert BuildChar/Glyph and change FontType + { dup /FontType get 1 eq + { dup /FontType 4 put + dup /BuildChar /build_C load put + dup /BuildGlyph /build_C load put + } + if definefont + } bind +counttomark 2 idiv { .loadfontdict 3 1 roll put } repeat pop +.loadfontdict readonly pop + +% Define the BuildChar and BuildGlyph procedures for modified fonts. +% A single procedure serves for both. +/build_C % build_C - + { 1 index begin + dup dup type /integertype eq { Encoding exch get } if + % Stack: font code|name name + dup CharStrings exch .knownget not + { 2 copy eq { exch pop /.notdef exch } if + QUIET not + { (Substituting .notdef for ) print = flush } + { pop } + ifelse + /.notdef CharStrings /.notdef get + } if + % Stack: font code|name name charstring + dup type /integertype eq + { load_C end build_C } + { end .type1execchar } + ifelse + } bind def diff --git a/gs/lib/gs_dpnxt.ps b/gs/lib/gs_dpnxt.ps new file mode 100644 index 000000000..515e16d3f --- /dev/null +++ b/gs/lib/gs_dpnxt.ps @@ -0,0 +1,30 @@ +% Copyright (C) 1997 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% gs_dpnxt.ps +% NeXT Display PostScript extensions + +/sizeimage { % sizeimage + % + % + /sizeimage cvx /undefined signalerror % ****** NYI ****** +} odef + +/readimage { % [... ] + % readimage - + /readimage cvx /undefined signalerror % ****** NYI ****** +} odef diff --git a/gs/lib/gs_dps.ps b/gs/lib/gs_dps.ps new file mode 100644 index 000000000..6978d4189 --- /dev/null +++ b/gs/lib/gs_dps.ps @@ -0,0 +1,54 @@ +% Copyright (C) 1997 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% Initialization file for Display PostScript functions. + +% ------ Halftone phase ------ % + +/sethalftonephase { % sethalftonephase - + -1 2 index 2 index .setscreenphase pop pop +} odef +/currenthalftonephase { % - currenthalftonephase + 0 .currentscreenphase +} odef + +% ------ Device information ------ % + +/.deviceinfodict mark + /Colors null /GrayValues null /RedValues null /GreenValues null + /BlueValues null /ColorValues null +.dicttomark readonly def +/deviceinfo { % - deviceinfo + currentdevice //.deviceinfodict .getdeviceparams .dicttomark readonly +} odef + +% The current implementation allocates a 2-element array each time. +% Perhaps we should change this to 2 separate parameters for X and Y? +/.wtdict mark + /wtranslation null +.dicttomark readonly def +/wtranslation { % - wtranslation + currentdevice //.wtdict .getdeviceparams exch pop exch pop aload pop +} odef +currentdict /.wtdict .undef + +% ------ View clipping ------ % + +/rectviewclip { % rectviewclip - + % rectviewclip - + newpath .rectappend viewclip +} odef diff --git a/gs/lib/gs_dps1.ps b/gs/lib/gs_dps1.ps new file mode 100644 index 000000000..45b79cee3 --- /dev/null +++ b/gs/lib/gs_dps1.ps @@ -0,0 +1,136 @@ +% Copyright (C) 1997 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% Initialization file for most of the Display PostScript functions +% that are also included in Level 2. + +level2dict begin + +% ------ Virtual memory ------ % + +/currentshared /.currentglobal load def +/scheck /.gcheck load def +%****** FOLLOWING IS WRONG ****** +/shareddict currentdict /globaldict .knownget not { 20 dict } if def + +% Global and LocalFontDirectory must remain in systemdict +% even if we temporarily exit Level 2 mode. + +end % level2dict +systemdict begin + +/SharedFontDirectory .FontDirectory .gcheck + { .currentglobal false .setglobal + /LocalFontDirectory .FontDirectory dup maxlength dict copy def + .setglobal .FontDirectory + } + { /LocalFontDirectory .FontDirectory def + 50 dict + } +ifelse def + +end % systemdict +level2dict begin + +% setshared must rebind FontDirectory to the appropriate one of +% Local or SharedFontDirectory. + +/.setglobal % .setglobal - + { dup .setglobal + //systemdict /FontDirectory .currentglobal + { //SharedFontDirectory } + { //systemdict /LocalFontDirectory get } % can't embed ref to local VM + ifelse .forceput pop + } .bind odef % must bind .forceput and .setglobal + % even if NOBIND in effect +/setshared /.setglobal load def +.currentglobal setshared + +% ------ Fonts ------ % + +/selectfont % selectfont - + { 1 index findfont + 1 index dup type /arraytype eq { makefont } { scalefont } ifelse + setfont pop pop + } odef +% undefinefont has to take local/global VM into account. +/undefinefont % undefinefont - + { .FontDirectory 1 index .undef + .currentglobal + { % Current mode is global; delete from local directory too. + //systemdict /LocalFontDirectory .knownget + { 1 index .undef } + if + } + { % Current mode is local; if there was a shadowed global + % definition, copy it into the local directory. + //systemdict /SharedFontDirectory .knownget + { 1 index .knownget + { .FontDirectory 2 index 3 -1 roll put } + if + } + if + } + ifelse pop + } odef + +% If we load a font into global VM within an inner save, the restore +% will delete it from FontDirectory but not from SharedFontDirectory. +% We have to handle this by making restore copy missing entries from +% SharedFontDirectory to FontDirectory. Since this could slow down restore +% considerably, we define a new operator .dictcopynew for this purpose. +% Furthermore, if FAKEFONTS is in effect, we want global real fonts to +% override fake local ones. We handle this by brute force. +/restore % restore - + { dup //restore % bind even if NOBIND + //systemdict /LocalFontDirectory get + FAKEFONTS + { mark + % We want to delete a fake font from the local directory + % iff the global directory now has no definition for it, + % or a non-fake definition. + 1 index dup + { % Stack: lfd mark lfd key ... lfd key value + length 1 gt + { % This is a real local definition; don't do anything. + pop + } + { % This is a fake local definition, check for global. + //SharedFontDirectory 1 index .knownget + { % A global definition exists, check for fake. + length 1 eq { pop } { 1 index } ifelse + } + { % No global definition, delete the local one. + 1 index + } + ifelse + } + ifelse + } forall + pop counttomark 2 idiv { .undef } repeat pop + } + if + //SharedFontDirectory exch .dictcopynew pop + .currentglobal .setglobal % Rebind FontDirectory according to current VM. + pop + } bind odef + +% ------ Miscellaneous ------ % + +/undef /.undef load def + +end % level2dict diff --git a/gs/lib/gs_dps2.ps b/gs/lib/gs_dps2.ps new file mode 100644 index 000000000..9a6d715fb --- /dev/null +++ b/gs/lib/gs_dps2.ps @@ -0,0 +1,203 @@ +% Copyright (C) 1990, 1996, 1997 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% Initialization file for basic Display PostScript functions +% that are also included in Level 2. + +level2dict begin + +% ------ Halftones ------ % + +/.makestackdict + { { counttomark -1 roll } forall .dicttomark + } bind def +/currenthalftone % - currenthalftone + { mark .currenthalftone + { { exch pop } % halftone + { /HalftoneType 1 % screen + { /Frequency /Angle /SpotFunction } + .makestackdict + } + { /HalftoneType 2 % colorscreen + { /RedFrequency /RedAngle /RedSpotFunction + /GreenFrequency /GreenAngle /GreenSpotFunction + /BlueFrequency /BlueAngle /BlueSpotFunction + /GrayFrequency /GrayAngle /GraySpotFunction + } + .makestackdict + } + } + exch get exec + } odef +% Define sethalftone so it converts all other types to type 5. +/.sethalftoneRGBV % + { 4 -1 roll exch { 1 index exch get exch } forall 15 1 roll + 14 -2 roll mark 15 1 roll { /Gray /Blue /Green /Red } + { % stack: v0 v1 v2 type keys comp + mark + 2 index 0 get 8 -1 roll + 4 index 1 get 9 -1 roll + 6 index 2 get 10 -1 roll + % stack: type keys comp mark k0 v0 k1 v1 k2 v2 + /HalftoneType 10 index .dicttomark + counttomark 2 roll + } + forall pop pop + /Default 1 index .dicttomark .sethalftone5 + } bind def +/sethalftone { % sethalftone - + % We must create the new dictionary in the same VM as the + % operand; otherwise, invalidaccess errors may occur. + .currentglobal 1 index dup gcheck .setglobal + dup /HalftoneType get 1 sub { + { mark /Default 2 index .dicttomark .sethalftone5 + } + { 1 { /Frequency /Angle /SpotFunction } + { /RedFrequency /RedAngle /RedSpotFunction + /GreenFrequency /GreenAngle /GreenSpotFunction + /BlueFrequency /BlueAngle /BlueSpotFunction + /GrayFrequency /GrayAngle /GraySpotFunction + } .sethalftoneRGBV + } + { mark /Default 2 index .dicttomark .sethalftone5 + } + { 3 { /Width /Height /Thresholds } + { /RedWidth /RedHeight /RedThresholds + /GreenWidth /GreenHeight /GreenThresholds + /BlueWidth /BlueHeight /BlueThresholds + /GrayWidth /GrayHeight /GrayThresholds + } .sethalftoneRGBV + } + { dup .sethalftone5 + } + } exch get exec .setglobal pop +} odef +% Redefine setscreen and setcolorscreen to recognize halftone dictionaries, +% and to insert the Frequency and Angle into Type 1 halftones, per +% Adobe TN 5085. +/.fixsethalftonescreen % .fix...screen + % + { dup dup /HalftoneType get 1 eq + { dup wcheck not { dup length .copydict } if + dup /Frequency 5 index put + dup /Angle 4 index put + } + if + } bind def +/setscreen % setscreen - + { dup type /dicttype eq + { .fixsethalftonescreen sethalftone pop pop pop } + { //setscreen } + ifelse + } odef +/setcolorscreen % setcolorscreen - + { dup type /dicttype eq + { .fixsethalftonescreen sethalftone 12 { pop } repeat } + { //setcolorscreen } + ifelse + } odef +% Redefine currentscreen and currentcolorscreen to extract the Frequency +% and Angle from Type 1 halftones, per Adobe TN 5085. +/.fixcurrenthalftonescreen % .fix... + { dup /HalftoneType get 1 eq + { dup /Frequency get 1 index /Angle get } + { 60 0 } + ifelse 3 2 roll + } bind def +/currentscreen % - currentscreen 60 0 + { .currenthalftone + { { .fixcurrenthalftonescreen } % halftone + { } % screen + { 12 3 roll 9 { pop } repeat % colorscreen + dup type /dicttype eq { .fixcurrenthalftonescreen } if + } + } + exch get exec + } odef +/currentcolorscreen % - currentcolorscreen (60 0 )*4 + { .currenthalftone + { { .fixcurrenthalftonescreen 3 copy 6 copy } % halftone + { 3 copy 6 copy } % screen + { } % colorscreen + } + exch get exec + } odef + +% ------ User objects ------ % + +/.localarray where { + pop +} { + /.localarray { + currentglobal false setglobal + exch array exch setglobal + } bind def +} ifelse +% The name UserObjects may be rebound, but we need to make sure these +% operators always refer to the binding in userdict (which may also be +% rebound!). +/.UserObjects { + //systemdict /userdict get /UserObjects +} odef +% In order to get proper error recovery behavior, we need to be careful +% not to pop any operands from the stack until we're done. +% The code below faithfully duplicates the apparent array-growing +% behavior of Adobe interpreters. +/defineuserobject { % defineuserobject - + .UserObjects .knownget { + length dup 3 index le { + % Stack: index value len + 2 index eq { 1 index 2 mul } { 1 index 1 add } ifelse + .localarray userdict /UserObjects get + 1 index copy pop + .UserObjects 3 -1 roll put + } { + pop + } ifelse + } { + .UserObjects 3 index 1 add 10 .max .localarray put + } ifelse + .UserObjects get 2 index 2 index put pop pop +} odef +/execuserobject { % execuserobject - + .UserObjects get 1 index get exch pop exec +} odef +/undefineuserobject { % undefineuserobject - + .UserObjects get 1 index null put pop +} odef + +% ------ User paths ------ % + +/upath { % upath + [ 1 index {/ucache cvx} if + true .pathbbox /setbbox cvx + {/moveto cvx} {/lineto cvx} {/curveto cvx} {/closepath cvx} + pathforall ] cvx exch pop +} odef + +% Dummy definitions for cache control operators + +/ucachestatus { % - ucachestatus -mark- ? ? ? ? + mark 0 0 0 0 userdict /.ucachesize .knownget not { 0 } if +} odef +/setucacheparams { % -mark- ... setucacheparams - + % Provoke an appropriate error if needed. + counttomark 1 lt { () 0 get } if + 0 or userdict /.ucachesize 2 index 0 .max put cleartomark +} odef + +end % level2dict diff --git a/gs/lib/gs_epsf.ps b/gs/lib/gs_epsf.ps new file mode 100644 index 000000000..e45b5e652 --- /dev/null +++ b/gs/lib/gs_epsf.ps @@ -0,0 +1,60 @@ +% Copyright (C) 1989, 1996 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% Allow the interpreter to recognize MS-DOS EPSF file headers, and skip to +% the PostScript section of the file. + +/.runnoepsf /run load def +/.epsfheader def +/run + { dup type /filetype ne { (r) file } if + % Check for MS-DOS EPSF file (see Red Book p. 729). + true exch 0 1 3 + { % Stack: true file index + 1 index read dup { pop dup .epsfheader 3 index get eq } if + { pop pop } % if matched, don't need the character + { % unread characters (wasn't EPSF) + 2 index exch unread % unread mismatch character + dup { % loop unreading backwards in .epsfheader + 1 sub dup .epsfheader exch get 2 index exch unread + } repeat pop + exch not exch exit % change true to false + } + ifelse + } + for exch % Stack: file true/false + { % This block is executed if the file is MS-DOS EPSF. + % Build up the little-endian byte offset and length. + 2 + { 1 0 4 + { 2 index read not { pop exit } if % if EOF, let error happen + 2 index mul add exch 256 mul exch + } + repeat exch pop exch + } + repeat + % Stack: offset length file + % Use flushfile to skip quickly to the start of the + % PostScript section. + dup 4 -1 roll 12 sub () /SubFileDecode filter flushfile + % Now interpret the PostScript. + exch () /SubFileDecode filter cvx .runexec + } + { .runnoepsf + } + ifelse + } odef diff --git a/gs/lib/gs_fform.ps b/gs/lib/gs_fform.ps new file mode 100644 index 000000000..38ea6be2b --- /dev/null +++ b/gs/lib/gs_fform.ps @@ -0,0 +1,110 @@ +% Copyright (C) 1995, 1996 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% gs_fform.ps +% Monochrome Form caching implemented in PostScript. + +% This implementation is pretty unreasonable: +% - It doesn't remember transparent pixels. +% - It reduces everything to black and white. +% - It doesn't handle halftone or Pattern phasing. +% However, it's good enough to produce some useful output. + +% In order to prevent restore from clearing the cache, we explicitly +% push the cache entries on the stack before a restore and reinstall them. +/formcachedict 20 dict def +currentglobal true setglobal +/restore + { mark formcachedict { } forall + counttomark 1 add index { restore } .internalstopped + { cleartomark restore } + { counttomark 2 idiv { formcachedict 3 1 roll put } repeat pop pop } + ifelse + } bind odef + +/.form.buffer 65000 string def +/execform + { dup /Implementation known not + { dup /FormType get 1 ne { /rangecheck signalerror } if + formcachedict 1 index .knownget not + { currentglobal true setglobal + % Stack: form global + 10 dict + dup /ImageType 1 put + dup /ImageMatrix [0 0 0 0 0 0] put + dup /DataSource + { % Stack: y (impl is on dict stack) + Height 1 index sub + //.form.buffer length Width 7 add 8 idiv idiv .min + 1 index add exch + Device exch //.form.buffer copyscanlines + } + put + dup /BitsPerComponent 1 put + dup /Decode [0 1] put + dup /Device null put + % Stack: form global impl + formcachedict 3 index 2 index put + exch setglobal + } + if 1 index /Implementation 3 -1 roll put + } + if + gsave dup /Matrix get concat + dup /Implementation get + % Check whether we can use the cached value. + % Stack: form implementation + dup /ImageMatrix get matrix currentmatrix + true 0 1 3 + { % Stack: form impl cachemat curmat true index + 3 index 1 index get exch 3 index exch get ne { pop false exit } if + } + for % Stack: form impl cachemat curmat valid + exch pop exch pop not + { % Cache is invalid. Execute the Form and save the bits. + gsave begin + currentglobal exch true setglobal + ImageMatrix currentmatrix pop + dup /BBox get aload pop + exch 3 index sub exch 2 index sub rectclip + % Make the cache device. + clippath gsave matrix setmatrix pathbbox grestore + % We now have the bounding box in device space. + 2 { 4 -1 roll floor cvi } repeat + 2 { 4 -1 roll ceiling cvi } repeat + 2 index sub /Height exch def + 2 index sub /Width exch def + ImageMatrix aload pop + exch 7 index sub exch 6 index sub + 6 array astore + 3 1 roll pop pop + dup ImageMatrix copy pop + Width Height <00 ff> makeimagedevice + /Device 1 index def + nulldevice setdevice initgraphics + exch setglobal + dup dup /PaintProc get exec + nulldevice grestore currentdict end + } + if + % Now paint the bits. + % Stack: form implementation + /DeviceGray setcolorspace dup begin 0 exch image end pop + pop grestore + } odef + +setglobal diff --git a/gs/lib/gs_fonts.ps b/gs/lib/gs_fonts.ps new file mode 100644 index 000000000..e36214b25 --- /dev/null +++ b/gs/lib/gs_fonts.ps @@ -0,0 +1,912 @@ +% Copyright (C) 1990, 1995, 1996, 1997 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% Font initialization and management code. + +% Define the default font. +/defaultfontname /Courier def + +% Define the name of the font map file. +/defaultfontmap (Fontmap) def + +% ------ End of editable parameters ------ % + +% If SUBSTFONT is defined, make it the default font. +/SUBSTFONT where { pop /defaultfontname /SUBSTFONT load def } if + +% Define a reliable way of accessing FontDirectory in systemdict. +/.FontDirectory +{ //systemdict /FontDirectory get +} bind odef + +% If DISKFONTS is true, we load individual CharStrings as they are needed. +% (This is intended primarily for machines with very small memories.) +% In this case, we define another dictionary, parallel to FontDirectory, +% that retains an open file for every font loaded. +/FontFileDirectory 10 dict def + +% Define a temporary string for local use, since using =string +% interferes with some PostScript programs. +/.fonttempstring 128 string def + +% Split up a search path into individual directories or files. +/.pathlist % .pathlist ... + { { dup length 0 eq { pop exit } if + .filenamelistseparator search not { exit } if + exch pop exch + } + loop + } bind def + +% Load a font name -> font file name map. +userdict /Fontmap .FontDirectory maxlength dict put +/.loadFontmap % .loadFontmap - + { % We would like to simply execute .definefontmap as we read, + % but we have to maintain backward compatibility with an older + % specification that makes later entries override earlier. + 50 dict exch + { dup token not { closefile exit } if + % stack: fontname + % This is a hack to get around the absurd habit of MS-DOS editors + % of adding an EOF character at the end of the file. + dup (\032) eq { pop closefile exit } if + 1 index token not + { (Fontmap entry for ) print dup =only + ( has no associated file or alias name! Giving up.\n) print flush + {.loadFontmap} 0 get 1 .quit + } if + dup type dup /stringtype eq exch /nametype eq or not + { (Fontmap entry for ) print 1 index =only + ( has an invalid file or alias name! Giving up.\n) print flush + {.loadFontmap} 0 get 1 .quit + } if + % stack: dict file fontname filename|aliasname + % Read and pop tokens until a semicolon. + { 2 index token not + { (Fontmap entry for ) print 1 index =only + ( ends prematurely! Giving up.\n) print flush + {.loadFontmap} 0 get 1 .quit + } if + dup /; eq { pop 3 index 3 1 roll .growput exit } if + pop + } loop + } loop + { .definefontmap } forall + } bind def +% Add an entry in Fontmap. We redefine this if the Level 2 +% resource machinery is loaded. +/.definefontmap % .definefontmap - + { % Since Fontmap is global, make sure the values are storable. + .currentglobal 3 1 roll true .setglobal + dup type /stringtype eq + { dup .gcheck not { dup length string copy } if + } + if + Fontmap 3 -1 roll 2 copy .knownget + { % Add an element to the end of the existing value, + % unless it's the same as the current last element. + mark exch aload pop counttomark 4 add -1 roll + 2 copy eq { cleartomark pop pop } { ] readonly .growput } ifelse + } + { % Make a new entry. + mark 4 -1 roll ] readonly .growput + } + ifelse .setglobal + } bind def + +% Parse a font file just enough to find the FontName or FontType. +/.findfontvalue % .findfontvalue true + % .findfontvalue false + % Closes the file in either case. + { exch dup read not { -1 } if + 2 copy unread 16#80 eq + { dup (xxxxxx) readstring pop pop } % skip .PFB header + if + % Stack: key file + { dup token not { false exit } if % end of file + dup /eexec eq { pop false exit } if % reached eexec section + dup /Subrs eq { pop false exit } if % Subrs without eexec + dup /CharStrings eq { pop false exit } if % CharStrings without eexec + dup 3 index eq + { xcheck not { dup token exit } if } % found key + { pop } + ifelse + } loop + % Stack: key file value true (or) + % Stack: key file false + dup { 4 } { 3 } ifelse -2 roll closefile pop + } bind def +/.findfontname + { /FontName .findfontvalue + } bind def + +% If there is no FONTPATH, try to get one from the environment. +NOFONTPATH { /FONTPATH () def } if +/FONTPATH where + { pop } + { /FONTPATH (GS_FONTPATH) getenv not { () } if def } +ifelse +FONTPATH length 0 eq { (%END FONTPATH) .skipeof } if +/FONTPATH [ FONTPATH .pathlist ] def + +% Scan directories looking for plausible fonts. "Plausible" means that +% the file begins with %!PS-AdobeFont or %!FontType1, or with \200\001 +% followed by four arbitrary bytes and then either of these strings. +% To speed up the search, we skip any file whose name appears in +% the Fontmap (with any extension and upper/lower case variation) already, +% and any file whose extension definitely indicates it is not a font. +% +% NOTE: The current implementation of this procedure is somewhat Unix/DOS- +% specific. It assumes that '/' and '\' are directory separators, and that +% the part of a file name following the last '.' is the extension. +% +/.lowerstring % .lowerstring + { 0 1 2 index length 1 sub + { 2 copy get dup 65 ge exch 90 le and + { 2 copy 2 copy get 32 add put } + if pop + } + for + } bind def +/.splitfilename % .basename + { { (/) search { true } { (\\) search } ifelse + { pop pop } + { exit } + ifelse + } + loop + dup { (.) search { pop pop } { exit } ifelse } loop + 2 copy eq + { pop () } + { exch dup length 2 index length 1 add sub 0 exch getinterval exch } + ifelse +% Following is debugging code. +% (*** Split => ) print 2 copy exch ==only ( ) print ==only +% ( ***\n) print flush + } bind def +/.scanfontdict 1 dict def % establish a binding +/.scanfontbegin + { % Construct the table of all file names already in Fontmap. + currentglobal true setglobal + .scanfontdict dup maxlength Fontmap length 2 add .max .setmaxlength + Fontmap + { exch pop + { dup type /stringtype eq + { .splitfilename pop .fonttempstring copy .lowerstring cvn + .scanfontdict exch true put + } + { pop + } + ifelse + } + forall + } + forall + setglobal + } bind def +/.scanfontskip mark + % Strings are converted to names anyway, so.... + /afm true + /bat true + /c true + /cmd true + /com true + /dll true + /doc true + /drv true + /exe true + /fon true + /fot true + /h true + /o true + /obj true + /pfm true + /pss true % Adobe Multiple Master font instances + /txt true +.dicttomark def +/.scan1fontstring 128 string def +/.scanfontheaders [(%!PS-Adobe*) (%!FontType*)] def +0 .scanfontheaders { length max } forall 6 add % extra for PFB header +/.scan1fontfirst exch string def +/.scanfontdir % .scanfontdir - + { currentglobal exch true setglobal + QUIET not { (Scanning ) print dup print ( for fonts...) print flush } if + (*) 2 copy .filenamedirseparator + dup (\\) eq { pop (\\\\) } if % double \ for pattern match + exch concatstrings concatstrings + 0 0 0 4 -1 roll % found scanned files + { % stack: + exch 1 add exch % increment filecount + dup .splitfilename .lowerstring + % stack: + % + .scanfontskip exch known exch .scanfontdict exch known or + { pop + % stack: + } + { 3 -1 roll 1 add 3 1 roll + % stack: + dup (r) { file } .internalstopped + { pop pop null () + % stack: + % null () + } + { + % On some platforms, the file operator will open directories, + % but an error will occur if we try to read from one. + % Handle this possibility here. + dup .scan1fontfirst { readstring } .internalstopped + { pop pop () } + { pop } + ifelse + % stack: + %
    + } + ifelse + % Check for PFB file header. + dup (\200\001????*) .stringmatch + { dup length 6 sub 6 exch getinterval } + if + % Check for font file headers. + false .scanfontheaders + { 2 index exch .stringmatch or + } + forall exch pop + { % stack: + % + dup 0 setfileposition .findfontname + { dup Fontmap exch known + { pop pop + } + { exch copystring exch + DEBUG { ( ) print dup =only } if + 1 index .definefontmap + .splitfilename pop true .scanfontdict 3 1 roll .growput + % Increment fontcount. + 3 -1 roll 1 add 3 1 roll + } + ifelse + } + { pop + } + ifelse + } + % .findfontname will have done a closefile in the above case. + { dup null eq { pop } { closefile } ifelse pop + } + ifelse + } + ifelse + } + .scan1fontstring filenameforall + QUIET + { pop pop pop } + { ( ) print =only ( files, ) print =only ( scanned, ) print + =only ( new fonts.\n) print flush + } + ifelse + setglobal + } bind def + +%END FONTPATH + +% Create the dictionary that registers the .buildfont procedure (called by +% definefont) for each FontType. +/buildfontdict 20 dict def + +% Register Type 3 fonts, which are always supported, for definefont. +buildfontdict 3 /.buildfont3 cvx put + +% Register Type 0 fonts if they are supported. Strictly speaking, +% we should do this in its own file (gs_type0.ps), but since this is +% the only thing that would be in that file, it's simpler to put it here. +/.buildfont0 where { pop buildfontdict 0 /.buildfont0 cvx put } if + +% Define definefont. This is a procedure built on a set of operators +% that do all the error checking and key insertion. +/.growfontdict + { % Grow the font dictionary, if necessary, to ensure room for an + % added entry, making sure there is at least one slot left for FID. + dup maxlength 1 index length sub 2 lt + { dup dup wcheck + { .growdict } + { .growdictlength dict .copydict } + ifelse + } + { dup wcheck not { dup maxlength dict .copydict } if + } + ifelse + } bind def +/.completefont { + { % Check for disabled platform fonts. + NOPLATFONTS + { % Make sure we leave room for FID. + .growfontdict dup /ExactSize 0 put + } + { % Hack: if the Encoding looks like it might be the + % Symbol or Dingbats encoding, load those now (for the + % benefit of platform font matching) just in case + % the font didn't actually reference them. + dup /Encoding get length 65 ge + { dup /Encoding get 64 get + dup /congruent eq { SymbolEncoding pop } if + /a9 eq { DingbatsEncoding pop } if + } + if + } + ifelse + dup /FontType get //buildfontdict exch get exec + DISKFONTS + { FontFileDirectory 2 index known + { dup /FontFile FontFileDirectory 4 index get .growput + } + if + } + if + readonly % stack: name fontdict + } stopped { /invalidfont signalerror } if +} bind odef +/definefont + { .completefont + % If the current allocation mode is global, also enter + % the font in LocalFontDirectory. + .currentglobal + { //systemdict /LocalFontDirectory .knownget + { 2 index 2 index .growput } + if + } + if + dup .FontDirectory 4 -2 roll .growput + } odef + +% Define a procedure for defining aliased fonts. +% We can't just copy the font (or even use the same font unchanged), +% because a significant number of PostScript files assume that +% the FontName of a font is the same as the font resource name or +% the key in [Shared]FontDirectory; on the other hand, some Adobe files +% rely on the FontName of a substituted font *not* being the same as +% the requested resource name. We address this issue heuristically: +% we substitute the new name iff the font name doesn't have MM in it. +/.aliasfont % .aliasfont + { .currentglobal 3 1 roll dup .gcheck .setglobal + dup length 2 add dict + dup 3 -1 roll { 1 index /FID eq { pop pop } { put dup } ifelse } forall + % Stack: global fontname newfont newfont. + % We might be defining a global font whose FontName + % is a local string. This is weird, but legal, + % and doesn't cause problems anywhere else: + % to avoid any possible problems in this case, do a cvn. + % We might also be defining (as an alias) a global font + % whose FontName is a local non-string, if someone passed a + % garbage value to findfont. In this case, just don't + % call definefont at all. + 2 index dup type /stringtype eq exch .gcheck or 1 index .gcheck not or + { 2 index .fonttempstring cvs (MM) search + { pop pop pop pop + } + { /FontName exch dup type /stringtype eq { cvn } if put + } + ifelse + % Don't bind in definefont, since Level 2 redefines it. + //systemdict /definefont get exec + } + { .completefont pop exch pop + } + ifelse exch .setglobal + } odef % so findfont will bind it + +% Define .loadfontfile for loading a font. If we recognize Type 1 and/or +% TrueType fonts, gs_type1.ps and/or gs_ttf.ps will redefine this. +/.loadfontfile { cvx exec } bind def +/.loadfont + { % Some buggy fonts leave extra junk on the stack, + % so we have to make a closure that records the stack depth + % in a fail-safe way. + /.loadfontfile cvx count 1 sub 2 packedarray cvx exec + count exch sub { pop } repeat + } bind def + +% Find an alternate font to substitute for an unknown one. +% We go to some trouble to parse the font name and extract +% properties from it. Later entries take priority over earlier. +/.substitutefaces [ + % Guess at suitable substitutions for random unknown fonts. + [(Grot) /Times] + [(Roman) /Times] + [(Book) /NewCenturySchlbk] + % If the family name appears in the font name, + % use a font from that family. + [(Arial) /Helvetica] + [(Avant) /AvantGarde] + [(Bookman) /Bookman] + [(Century) /NewCenturySchlbk] + [(Cour) /Courier] + [(Geneva) /Helvetica] + [(Helv) /Helvetica] + [(NewYork) /Times] + [(Pala) /Palatino] + [(Sans) /Helvetica] + [(Schlbk) /NewCenturySchlbk] + [(Serif) /Times] + [(Swiss) /Helvetica] + [(Times) /Times] + [(Univers) /Helvetica] + % Substitute for Adobe Multiple Master fonts. + [(Minion) /Times] + [(Myriad) /Helvetica] + [(MyriadPkg) /Helvetica-Narrow] + % Condensed or narrow fonts map to the only narrow family we have. + [(Cond) /Helvetica-Narrow] + [(Narrow) /Helvetica-Narrow] + % If the font wants to be monospace, use Courier. + [(Monospace) /Courier] + [(Typewriter) /Courier] +] readonly def +/.substituteproperties [ + [(It) 1] [(Oblique) 1] + [(Bd) 2] [(Bold) 2] [(bold) 2] [(Demi) 2] [(Heavy) 2] [(Sb) 2] +] readonly def +/.substitutefamilies mark + /AvantGarde + {/AvantGarde-Book /AvantGarde-BookOblique + /AvantGarde-Demi /AvantGarde-DemiOblique} + /Bookman + {/Bookman-Demi /Bookman-DemiItalic /Bookman-Light /Bookman-LightItalic} + /Courier + {/Courier /Courier-Oblique /Courier-Bold /Courier-BoldOblique} + /Helvetica + {/Helvetica /Helvetica-Oblique /Helvetica-Bold /Helvetica-BoldOblique} + /Helvetica-Narrow + {/Helvetica-Narrow /Helvetica-Narrow-Oblique + /Helvetica-Narrow-Bold /Helvetica-Narrow-BoldOblique} + /NewCenturySchlbk + {/NewCenturySchlbk-Roman /NewCenturySchlbk-Italic + /NewCenturySchlbk-Bold /NewCenturySchlbk-BoldItalic} + /Palatino + {/Palatino-Roman /Palatino-Italic /Palatino-Bold /Palatino-BoldItalic} + /Times + {/Times-Roman /Times-Italic /Times-Bold /Times-BoldItalic} +.dicttomark readonly def +/.substitutefont % .substitutefont + { % Look for properties and/or a face name in the font name. + % If we find any, use Helvetica as the base font; + % otherwise, use the default font. + % Note that the "substituted" font name may be the same as + % the requested one; the caller must check this. + dup type dup /stringtype eq exch /nametype eq or + { dup length string cvs } { () } ifelse + {defaultfontname /Helvetica-Oblique /Helvetica-Bold /Helvetica-BoldOblique} + exch 0 exch % stack: fontname facelist properties fontname + % Look for a face name. + .substitutefaces + { 2 copy 0 get search + { pop pop pop 1 get .substitutefamilies exch get + 4 -1 roll pop 3 1 roll + } + { pop pop + } + ifelse + } + forall + .substituteproperties + { 2 copy 0 get search + { pop pop pop 1 get 3 -1 roll or exch } + { pop pop } + ifelse + } + forall pop get exec + % Only accept fonts known in the Fontmap. + Fontmap 1 index known not { pop defaultfontname } if + } bind def + +% If requested, make (and recognize) fake entries in FontDirectory for fonts +% present in Fontmap but not actually loaded. Thanks to Ray Johnston for +% the idea behind this code. +FAKEFONTS not { (%END FAKEFONTS) .skipeof } if + +% We use the presence or absence of the FontMatrix key to indicate whether +% a font is real or fake. We must pop the arguments at the very end, +% so that stack protection will be effective. + +/definefont { % definefont + dup /FontMatrix known { + //definefont + } { + 2 copy /FontName get findfont //definefont exch pop exch pop + } ifelse +} bind odef + +/scalefont { % scalefont + 1 index /FontMatrix known { + //scalefont + } { + 1 index /FontName get findfont 1 index //scalefont + exch pop exch pop + } ifelse +} bind odef + +/makefont { % makefont + 1 index /FontMatrix known { + //makefont + } { + 1 index /FontName get findfont 1 index //makefont + exch pop exch pop + } ifelse +} bind odef + +/setfont { % setfont - + dup /FontMatrix known { + //setfont + } { + dup /FontName get findfont //setfont pop + } ifelse +} bind odef + +%END FAKEFONTS + +% Define findfont so it tries to load a font if it's not found. +% The Red Book requires that findfont be a procedure, not an operator, +% but it still needs to restore the stacks reliably if it fails, +% so we do all the work in an operator. +/.findfont { + mark 1 index + //systemdict begin .dofindfont + % Define any needed aliases. + counttomark 1 sub { .aliasfont } repeat end + exch pop exch pop +} odef +/findfont { + .findfont +} bind def +% Check whether the font name we are about to look for is already on the list +% of aliases we're accumulating; if so, cause an error. +/.checkalias % -mark- ... .checkalias <> + { counttomark 1 sub -1 1 + { index 1 index eq + { pop QUIET not + { (Unable to substitute for font.\n) print flush + } if + /findfont cvx /invalidfont signalerror + } + if + } + for + } bind def +% Get a (non-fake) font if present in a FontDirectory. +/.fontknownget % .fontknownget true + % .fontknownget false + { .knownget + { FAKEFONTS + { dup /FontMatrix known { true } { pop false } ifelse } + { true } + ifelse + } + { false + } + ifelse + } bind def +% Do the work of findfont, including substitution, defaulting, and +% scanning of FONTPATH. +/.dofindfont % .dofindfont + { { .tryfindfont { exit } if + % We didn't find the font. If we haven't scanned + % all the directories in FONTPATH, scan the next one now, + % and look for the font again. + null 0 1 FONTPATH length 1 sub + { FONTPATH 1 index get null ne { exch pop exit } if pop + } + for dup null ne + { dup 0 eq { .scanfontbegin } if + FONTPATH 1 index get .scanfontdir + FONTPATH exch null put + % Start over with an empty alias list. + counttomark 1 sub { pop } repeat + .dofindfont exit + } + if pop + % No luck. Make sure we're not already + % looking for the default font. + dup defaultfontname eq + { QUIET not + { (Unable to load default font ) print + dup =only (! Giving up.\n) print flush + } + if /findfont cvx /invalidfont signalerror + } + if + % Substitute for the font. + % If SUBSTFONT is defined, don't alias. + /SUBSTFONT where { + pop QUIET not { + (Substituting for font ) print dup =only + (.\n) print flush + } if + cleartomark mark defaultfontname + } { + dup .substitutefont + 2 copy eq { pop defaultfontname } if + .checkalias + QUIET not { + (Substituting font ) print dup =only ( for ) print + 1 index =only (.\n) print flush + } if + } ifelse + } + loop + } bind def +% Try to find a font using only the present contents of Fontmap. +/.tryfindfont % .tryfindfont true + % .tryfindfont false + { .FontDirectory 1 index .fontknownget + { % Already loaded + exch pop true + } + { dup Fontmap exch .knownget not + { % Unknown font name. Look for a file with the + % same name as the requested font. + dup dup type /nametype eq { .namestring } if .loadfontloop + } + { % Try each element of the Fontmap in turn. + false exch % (in case we exhaust the list) + % Stack: fontname false fontmaplist + { exch pop + dup type /nametype eq + { % Font alias + .checkalias .tryfindfont exit + } + { dup dup type dup /arraytype eq exch /packedarraytype eq or exch xcheck and + { % Font with a procedural definition + exec % The procedure will load the font. + % Check to make sure this really happened. + .FontDirectory 1 index .knownget + { exch pop true exit } + if + } + { % Font file name + .loadfontloop { true exit } if + } + ifelse + } + ifelse false + } + forall + % Stack: font true -or- fontname false + { true + } + { % None of the Fontmap entries worked. + % Try loading a file with the same name + % as the requested font. + dup dup type /nametype eq { .namestring } if .loadfontloop + } + ifelse + } + ifelse + } + ifelse + } bind def +% Attempt to load a font from a file. +/.loadfontloop % .loadfontloop true + % .loadfontloop false + { % See above regarding the use of 'loop'. + + { + % Is the font name a string? + dup type /stringtype ne + { QUIET not + { (Can't find font with non-string name: ) print dup =only (.\n) print flush + } + if pop false exit + } + if + % Can we open the file? + findlibfile not + { QUIET not + { (Can't find \(or can't open\) font file ) print dup print + (.\n) print flush + } + if pop false exit + } + if + + % Stack: fontname fontfilename fontfile + DISKFONTS + { .currentglobal true .setglobal + 2 index (r) file + FontFileDirectory exch 5 index exch .growput + .setglobal + } + if + QUIET not + { (Loading ) print 2 index =only + ( font from ) print 1 index print (... ) print flush + } + if + % If LOCALFONTS isn't set, load the font into local or global + % VM according to FontType; if LOCALFONTS is set, load the font + % into the current VM, which is what Adobe printers (but not + % DPS or CPSI) do. + LOCALFONTS { false } { /setglobal where } ifelse + { pop /FontType .findfontvalue { 1 eq } { false } ifelse + % .setglobal, like setglobal, aliases FontDirectory to + % GlobalFontDirectory if appropriate. However, we mustn't + % allow the current version of .setglobal to be bound in, + % because it's different depending on language level. + .currentglobal exch /.setglobal load exec + % Remove the fake definition, if any. + .FontDirectory 3 index .undef + 1 index (r) file .loadfont .FontDirectory exch + /.setglobal load exec + } + { .loadfont .FontDirectory + } + ifelse + % Stack: fontname fontfilename fontdirectory + QUIET not + { //systemdict /level2dict known + { .currentglobal false .setglobal vmstatus + true .setglobal vmstatus 3 -1 roll pop + 6 -1 roll .setglobal 5 + } + { vmstatus 3 + } + ifelse { =only ( ) print } repeat + (done.\n) print flush + } if + + % Check to make sure the font was actually loaded. + dup 3 index .fontknownget + { 4 1 roll pop pop pop true exit } if + + % Maybe the file had a different FontName. + % See if we can get a FontName from the file, and if so, + % whether a font by that name exists now. + exch (r) file .findfontname + { 2 copy .fontknownget + { % Yes. Stack: origfontname fontdirectory filefontname fontdict + 3 -1 roll pop exch + QUIET + { pop + } + { (Using ) print =only + ( font for ) print 1 index =only + (.\n) print flush + } + ifelse true exit + } + if pop + } + if pop + + % The font definitely did not load correctly. + QUIET not + { (Loading ) print dup =only + ( font failed.\n) print flush + } if + false exit + + } loop % end of loop + + } bind def + +% Define a procedure to load all known fonts. +% This isn't likely to be very useful. +/loadallfonts + { Fontmap { pop findfont pop } forall + } bind def + +% If requested, load all the fonts defined in the Fontmap into FontDirectory +% as "fake" fonts i.e., font dicts with only FontName and FontType defined. +% (We define FontType only to for the sake of some questionable code in the +% Apple Printer Utility 2.0 font inquiry code.) We must ensure that this +% happens in both global and local directories. +/.definefakefonts + { + } + { (gs_fonts FAKEFONTS) VMDEBUG + 2 + { .currentglobal not .setglobal + Fontmap + { pop dup type /stringtype eq { cvn } if + .FontDirectory 1 index known not + { 2 dict dup /FontName 3 index put + dup /FontType 1 put + .FontDirectory 3 1 roll put + } + { pop + } + ifelse + } + forall + } + repeat + } +FAKEFONTS { exch } if pop def % don't bind, .current/setglobal get redefined + +% Install initial fonts from Fontmap. +/.loadinitialfonts + { NOFONTMAP not + { /FONTMAP where + { pop [ FONTMAP .pathlist ] + { dup VMDEBUG findlibfile + { exch pop .loadFontmap } + { /undefinedfilename signalerror } + ifelse + } + } + { LIBPATH + { defaultfontmap 2 copy .filenamedirseparator + exch concatstrings concatstrings dup VMDEBUG + (r) { file } .internalstopped + { pop pop } { .loadFontmap } ifelse + } + } + ifelse forall + } + if + .definefakefonts + } def % don't bind, .current/setglobal get redefined + +% ---------------- Synthetic font support ---------------- % + +% Create a new font by modifying an existing one. paramdict contains +% entries with the same keys as the ones found in a Type 1 font; +% it should also contain enough empty entries to allow adding the +% corresponding non-overridden entries from the original font dictionary, +% including FID. If paramdict includes a FontInfo entry, this will +% also override the original font's FontInfo, entry by entry; +% again, it must contain enough empty entries. + +% Note that this procedure does not perform a definefont. + +/.makemodifiedfont % .makemodifiedfont + { exch + { % Stack: destdict key value + 1 index /FID ne + { 2 index 2 index known + { % Skip fontdict entry supplied in paramdict, but + % handle FontInfo specially. + 1 index /FontInfo eq + { 2 index 2 index get % new FontInfo + 1 index % old FontInfo + { % Stack: destdict key value destinfo key value + 2 index 2 index known + { pop pop } + { 2 index 3 1 roll put } + ifelse + } + forall pop + } + if + } + { % No override, copy the fontdict entry. + 2 index 3 1 roll put + dup dup % to match pop pop below + } + ifelse + } + if + pop pop + } forall + } bind def + +% Make a modified font and define it. Note that unlike definefont, +% this does not leave the font on the operand stack. + +/.definemodifiedfont % .definemodifiedfont - + { .makemodifiedfont + dup /FontName get exch definefont pop + } bind def diff --git a/gs/lib/gs_init.ps b/gs/lib/gs_init.ps new file mode 100644 index 000000000..791a36afa --- /dev/null +++ b/gs/lib/gs_init.ps @@ -0,0 +1,1458 @@ +% Copyright (C) 1989, 1996, 1997, 1998 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% Initialization file for the interpreter. +% When this is run, systemdict is still writable. + +% Comment lines of the form +% %% Replace +% indicate places where the next lines should be replaced by +% the contents of , when creating a single merged init file. + +% The interpreter can call out to PostScript code. All procedures +% called in this way, and no other procedures defined in these +% initialization files, have names that begin with %, e.g., +% (%Type1BuildChar) cvn. + +% Check the interpreter revision. NOTE: the interpreter code requires +% that the first non-comment token in this file be an integer. +513 +dup revision ne + { (gs: Interpreter revision \() print revision 10 string cvs print + (\) does not match gs_init.ps revision \() print 10 string cvs print + (\).\n) print flush null 1 .quit + } +if pop + +% Acquire userdict, and set its length if necessary. +/userdict where + { pop userdict maxlength 0 eq } + { true } +ifelse + { % userdict wasn't already set up by iinit.c. + /userdict + currentdict dup 200 .setmaxlength % userdict + systemdict begin def % can't use 'put', userdict is local + } + { systemdict begin + } +ifelse + +% Define dummy local/global operators if needed. +systemdict /.setglobal known + { true .setglobal + } + { /.setglobal { pop } bind def + /.currentglobal { false } bind def + /.gcheck { pop false } bind def + } +ifelse + +% Define .languagelevel if needed. +systemdict /.languagelevel known not { /.languagelevel 1 def } if + +% Optionally choose a default paper size other than U.S. letter. +% (a4) /PAPERSIZE where { pop pop } { /PAPERSIZE exch def } ifelse + +% Turn on array packing for the rest of initialization. +true setpacking + +% Define the old MS-DOS EOF character as a no-op. +% This is a hack to get around the absurd habit of MS-DOS editors +% of adding an EOF character at the end of the file. +<1a> cvn { } def + +% Acquire the debugging flags. +currentdict /DEBUG known /DEBUG exch def + /VMDEBUG + DEBUG {{print mark + systemdict /level2dict known + { .currentglobal dup false .setglobal vmstatus + true .setglobal vmstatus 3 -1 roll pop + 6 -2 roll pop .setglobal + } + { vmstatus 3 -1 roll pop + } + ifelse usertime 16#fffff and counttomark + { ( ) print ( ) cvs print } + repeat pop + ( ) print systemdict length ( ) cvs print + ( ) print countdictstack ( ) cvs print + ( <) print count ( ) cvs print (>\n) print flush + }} + {{pop + }} + ifelse + def + +currentdict /BATCH known /BATCH exch def +currentdict /DELAYBIND known /DELAYBIND exch def +currentdict /DISKFONTS known /DISKFONTS exch def +currentdict /ESTACKPRINT known /ESTACKPRINT exch def +currentdict /FAKEFONTS known /FAKEFONTS exch def +currentdict /FIXEDMEDIA known /FIXEDMEDIA exch def +currentdict /FIXEDRESOLUTION known /FIXEDRESOLUTION exch def +currentdict /LOCALFONTS known /LOCALFONTS exch def +currentdict /NOBIND known /NOBIND exch def +/.bind /bind load def +NOBIND { /bind { } def } if +currentdict /NOCACHE known /NOCACHE exch def +currentdict /NOCIE known /NOCIE exch def +currentdict /NODISPLAY known not /DISPLAYING exch def +currentdict /NOFONTMAP known /NOFONTMAP exch def +currentdict /NOFONTPATH known /NOFONTPATH exch def +currentdict /NOGC known /NOGC exch def +currentdict /NOPAUSE known /NOPAUSE exch def +currentdict /NOPLATFONTS known /NOPLATFONTS exch def +currentdict /NOPROMPT known /NOPROMPT exch def +% The default value of ORIENT1 is true, not false. +currentdict /ORIENT1 known not { /ORIENT1 true def } if +currentdict /OSTACKPRINT known /OSTACKPRINT exch def +currentdict /OUTPUTFILE known % obsolete + { /OutputFile /OUTPUTFILE load def + currentdict /OUTPUTFILE .undef + } if +currentdict /QUIET known /QUIET exch def +currentdict /SAFER known /SAFER exch def +currentdict /SHORTERRORS known /SHORTERRORS exch def +currentdict /WRITESYSTEMDICT known /WRITESYSTEMDICT exch def + +% Acquire environment variables. +currentdict /DEVICE known not + { (GS_DEVICE) getenv { /DEVICE exch def } if } if + +(START) VMDEBUG + +% Open the standard files, so they will be open at the outermost save level. +(%stdin) (r) file pop +(%stdout) (w) file pop +(%stderr) (w) file pop + +% Define a procedure for skipping over an unneeded section of code. +% This avoids allocating space for the skipped procedures. +% We can't use readline, because that imposes a line length limit. +/.skipeof % .skipeof - + { currentfile exch 1 exch .subfiledecode flushfile + } bind def + +% If we're delaying binding, remember everything that needs to be bound later. +DELAYBIND NOBIND not and + { .currentglobal false .setglobal + userdict /.delaybind 1500 array put + .setglobal + userdict /.delaycount 0 put + % When we've done the delayed bind, we want to stop saving. + % Detect this by the disappearance of .delaybind. + /bind + { userdict /.delaybind .knownget + { .delaycount 2 index put + userdict /.delaycount .delaycount 1 add put + } + { .bind + } + ifelse + } bind def + } if + +% Define procedures to assist users who don't read the documentation. +userdict begin +/help + { (Enter PostScript commands. '(filename) run' runs a file, 'quit' exits.\n) + print flush + } bind def +/? /help load def +end + +% Define =string, which is used by some PostScript programs even though +% it isn't documented anywhere. +% Put it in userdict so that each context can have its own copy. +userdict /=string 256 string put + +% Print the greeting. + +/printgreeting + { mark + product (Ghostscript) search + { pop pop pop + (This software comes with NO WARRANTY: see the file PUBLIC for details.\n) + } + { pop + } + ifelse + (\n) copyright + (\)\n) revisiondate 100 mod (-) + revisiondate 100 idiv 100 mod (-) + revisiondate 10000 idiv ( \() + revision 10 mod + revision 100 mod dup 0 ne { 10 idiv } { pop } ifelse (.) + revision 100 idiv ( ) + product + counttomark + { (%stdout) (w) file exch false .writecvp + } repeat pop + } bind def + +QUIET not { printgreeting flush } if + +% Define a special version of def for making operator procedures. +/odef % odef - + { 1 index exch .makeoperator def + } .bind def + +%**************** BACKWARD COMPATIBILITY +/getdeviceprops + { null .getdeviceparams + } bind odef +/.putdeviceprops + { null true counttomark 1 add 3 roll .putdeviceparams + dup type /booleantype ne + { dup mark eq { /unknown /rangecheck } if + counttomark 4 add 1 roll cleartomark pop pop pop + /.putdeviceprops load exch signalerror + } + if + } bind odef +/max { .max } bind def +/min { .min } bind def +/.currentfilladjust { .currentfilladjust2 pop } bind odef +/.setfilladjust { dup .setfilladjust2 } bind odef +/.writecvs { false .writecvp } bind odef + +% Define predefined procedures substituting for operators, +% in alphabetical order. + +userdict /#copies 1 put +% Adobe implementations don't accept /[ or /], so we don't either. +([) cvn + /mark load def +(]) cvn + {counttomark array astore exch pop} odef +/abs {dup 0 lt {neg} if} odef +% .beginpage is redefined if setpagedevice is present. +/.beginpage { } odef +/copypage + { 1 .endpage + { .currentnumcopies false .outputpage + (>>copypage, press to continue<<\n) .confirm + } + if .beginpage + } odef +/countexecstack { false .countexecstack } odef +% .currentnumcopies is redefined in Level 2. +/.currentnumcopies { #copies } odef +/setcolorscreen where { pop % not in all Level 1 configurations + /currentcolorscreen + { .currenthalftone + { { 60 exch 0 exch 3 copy 6 copy } % halftone - not possible + { 3 copy 6 copy } % screen + { } % colorscreen + } + exch get exec + } odef +} if +/currentscreen + { .currenthalftone + { { 60 exch 0 exch } % halftone - not possible + { } % screen + { 12 3 roll 9 { pop } repeat } % colorscreen + } + exch get exec + } odef +/.echo /echo load def +userdict /.echo.mode true put +/echo {dup /.echo.mode exch store .echo} odef +/eexec + { 55665 //filterdict /eexecDecode get exec + cvx //systemdict begin exec + % Only pop systemdict if it is still the top element, + % because this is apparently what Adobe interpreters do. + currentdict //systemdict eq { end } if + } odef +% .endpage is redefined if setpagedevice is present. +/.endpage { 2 ne } odef +% erasepage mustn't use gsave/grestore, because we call it before +% the graphics state stack has been fully initialized. +/erasepage + { /currentcolor where + { pop currentcolor currentcolorspace { setcolorspace setcolor } } + { /currentcmykcolor where + { pop currentcmykcolor { setcmykcolor } } + { currentrgbcolor { setrgbcolor } } + ifelse + } + ifelse 1 setgray .fillpage exec + } odef +/execstack { false .execstack } odef +/executive + { { prompt + { (%statementedit) (r) file } stopped + { pop pop $error /errorname get /undefinedfilename eq + { .clearerror exit } if % EOF + handleerror null % ioerror?? + } + if + cvx { .runexec } execute + } loop + } odef +/filter + { //filterdict 1 index .knownget + { exch pop exec } + { /filter load /undefined signalerror } + ifelse + } odef +/handleerror + { //systemdict /errordict get /handleerror get exec } bind def +/identmatrix [1.0 0.0 0.0 1.0 0.0 0.0] readonly def +/identmatrix + { dup 0 //identmatrix putinterval } odef +/languagelevel 1 def % gs_lev2.ps may change this +/makeimagedevice { false makewordimagedevice } odef +/matrix { 6 array identmatrix } odef +/pathbbox + { false .pathbbox + } odef +/prompt { flush flushpage + (GS) print + count 0 ne { (<) print count =only } if + (>) print flush + } bind def +/pstack { 0 1 count 3 sub { index == } for } bind def +/putdeviceprops + { .putdeviceprops { erasepage } if } odef +/quit { /quit load 0 .quit } odef +/run { dup type /filetype ne { (r) file } if + % We must close the file when execution terminates, + % regardless of the state of the stack, + % and then propagate an error, if any. + cvx .runexec + } odef +% Execute a file. +% Level 2 uses 2 .stop to clear the e-stack for a successful startjob: +% we detect that here, since we need to handle this even if we start out +% without job control in effect. +% +% What we push on the e-stack is the following to be executed in this order: +% .runexec1 .runexec2 +/.runexec1 { % .runexec1 - + dup type /filetype ne { cvx exec } if + cvx null 2 .stopped + % If we got back here from a startjob, just keep going. + % startjob replaces the null on the o-stack with a procedure + % to be executed when we get back here. + dup null ne { exec true } { pop false } ifelse +} bind def +/.runexec2 { % .runexec2 - + exch { + .runexec + } { + dup type /filetype ne { cvx exec } if + closefile + } ifelse +} bind def +/.runexec { % .runexec - + cvlit /.runexec1 cvx 1 index /.runexec2 cvx 4 .execn +} bind def +% The following is only for compatibility with Adobe interpreters. +/setdash { + 1 index length 11 gt { /setdash load /limitcheck signalerror } if + //setdash +} odef +/setdevice + { .setdevice { erasepage } if } odef +/setlinecap { + dup 2 gt { /setlinecap load /rangecheck signalerror } if + .setlinecap +} odef +/setlinejoin { + dup 2 gt { /setlinejoin load /rangecheck signalerror } if + .setlinejoin +} odef +/showpage + { 0 .endpage .doneshowpage + { .currentnumcopies true .outputpage + (>>showpage, press to continue<<\n) .confirm + erasepage + } + if initgraphics .beginpage + } odef +% Code output by Adobe Illustrator relies on the fact that +% `stack' is a procedure, not an operator!!! +/stack { 0 1 count 3 sub { index = } for } bind def +/start { BATCH { null 0 .quit } { executive } ifelse } def +% Internal uses of stopped that aren't going to do a stop if an error occurs +% should use .internalstopped to avoid setting newerror et al. +/.internalstopped { null 1 .stopped null ne } bind def +/store { % Don't alter operands before completing. + 1 index where { 2 index 2 index put pop pop } { def } ifelse + } odef +% When running in Level 1 mode, this interpreter is supposed to be +% compatible with PostScript "version" 54.0 (I think). +/version (54.0) def + +% internaldict is defined in systemdict, but is allocated in local VM. +systemdict /internaldict .knownget not { 0 } if type /operatortype ne + { .currentglobal false .setglobal + //systemdict /internaldict known not { /internaldict 5 dict def } if + /internaldict + [ /dup load 1183615869 /eq load + [ /pop load internaldict ] cvx + [ /internaldict /cvx load /invalidaccess /signalerror cvx ] cvx + /ifelse load + ] cvx bind odef + .setglobal + } if + +% Define some additional built-in procedures (beyond the ones defined by +% the PostScript Language Reference Manual). +% Warning: these are not guaranteed to stay the same from one release +% to the next! +/concatstrings + { exch dup length 2 index length add string % str2 str1 new + dup dup 4 2 roll copy % str2 new new new1 + length 4 -1 roll putinterval + } bind def +/copyarray + { dup length array copy } bind def +% Copy a dictionary per the Level 2 spec even in Level 1. +/.copydict % .copydict + { dup 3 -1 roll { put dup } forall pop } bind def +/copystring + { dup length string copy } bind def +/finddevice + { //systemdict /devicedict get exch get + dup 1 get null eq + { % This is the first request for this type of device. + % Create a default instance now. + % Stack: [proto null] + .currentglobal true .setglobal exch + dup dup 0 get copydevice 1 exch put + exch .setglobal + } + if 1 get + } bind def +/.growdictlength % get size for growing a dictionary + { length 3 mul 2 idiv 1 add + } bind def +/.growdict % grow a dictionary + { dup .growdictlength .setmaxlength + } bind def +/.growput % put, grow the dictionary if needed + { 2 index length 3 index maxlength eq + { 3 copy pop known not { 2 index .growdict } if + } if + put + } bind def +/.packtomark + { counttomark packedarray exch pop } bind def +/ppstack + { 0 1 count 3 sub { index === } for } bind def +/runlibfile + { % We don't want to bind 'run' into this procedure, + % since run may get redefined. + findlibfile + { exch pop //systemdict /run get exec } + { /undefinedfilename signalerror } + ifelse + } bind def +/selectdevice + { finddevice setdevice .setdefaultscreen } bind def +/signalerror % signalerror - + { //systemdict /errordict get exch get exec } bind def + +% Define the =[only] procedures. Also define =print, +% which is used by some PostScript programs even though +% it isn't documented anywhere. +/write=only { + .writecvs +} bind def +/write= { + 1 index exch write=only (\n) writestring +} bind def +/=only { (%stdout) (w) file exch write=only } bind def +/= { =only (\n) print } bind def +/=print /=only load def +% Temporarily define == as = for the sake of runlibfile0. +/== /= load def + +% Define procedures for getting and setting the current device resolution. + +/gsgetdeviceprop % gsgetdeviceprop + { 2 copy mark exch null .dicttomark .getdeviceparams + dup mark eq % if true, not found + { pop dup /undefined signalerror } + { 5 1 roll pop pop pop pop } + ifelse + } bind def +/gscurrentresolution % - gscurrentresolution <[xres yres]> + { currentdevice /HWResolution gsgetdeviceprop + } bind def +/gssetresolution % <[xres yres]> gssetresolution - + { 2 array astore mark exch /HWResolution exch + currentdevice copydevice putdeviceprops setdevice + } bind def + +% Define auxiliary procedures needed for the above. +/shellarguments % -> shell_arguments true (or) false + { /ARGUMENTS where + { /ARGUMENTS get dup type /arraytype eq + { aload pop /ARGUMENTS null store true } + { pop false } + ifelse } + { false } ifelse + } bind def +/.confirm + { DISPLAYING NOPAUSE not and + { % Print a message (unless NOPROMPT is true) + % and wait for the user to type something. + % If the user just types a newline, flush it. + NOPROMPT { pop } { print flush } ifelse + .echo.mode false echo + (%stdin) (r) file dup read + { dup (\n) 0 get eq { pop pop } { unread } ifelse } + { pop } + ifelse echo + } + { pop + } + ifelse + } bind def + +% Define the procedure used by .runfile, .runstdin and .runstring +% for executing user input. +% This is called with a procedure or executable file on the operand stack. +/.execute { % .execute + stopped $error /newerror get and + { handleerror flush true } { false } ifelse +} bind def +/execute { % execute - + .execute pop +} odef +% Define an execute analogue of runlibfile0. +/execute0 { % execute0 - + .execute { /execute0 cvx 1 .quit } if +} bind def +% Define the procedure that the C code uses for running files +% named on the command line. +/.runfile { + { runlibfile } execute +} def +% Define the procedure that the C code uses for running piped input. +% We don't use the obvious { (%stdin) run }, because we want the file to be +% reopened if a startjob does a restore. +/.runstdin { + { { (%stdin) (r) file cvx } .runexec } execute0 +} bind def +% Define the procedure that the C code uses for running commands +% given on the command line with -c. We turn the string into a file so that +% .runexec can do the right thing with a startjob. +/.runstring { + .currentglobal exch true .setglobal + 0 () .subfiledecode + exch .setglobal cvx { .runexec } execute +} bind def +% Define the procedure that the C code uses to set up for executing +% a string that may be received in pieces. +/.runstringbegin { + .currentglobal true .setglobal + { .needinput } bind 0 () .subfiledecode + exch .setglobal cvx .runexec +} bind def + +% Define a special version of runlibfile that aborts on errors. +/runlibfile0 + { cvlit dup /.currentfilename exch def + { findlibfile not { stop } if } + stopped + { (Can't find \(or open\) initialization file ) print + .currentfilename == flush /runlibfile0 cvx 1 .quit + } if + exch pop cvx stopped + { (While reading ) print .currentfilename print (:\n) print flush + handleerror /runlibfile0 1 .quit + } if + } bind def +% Temporarily substitute it for the real runlibfile. +/.runlibfile /runlibfile load def +/runlibfile /runlibfile0 load def + +% Create the error handling machinery. +% Define the standard error handlers. +% The interpreter has created the ErrorNames array. +/.unstoppederrorhandler % .unstoppederrorhandler - + { % This is the handler that gets used for recursive errors, + % or errors outside the scope of a 'stopped'. + 2 copy SHORTERRORS + { (%%[ Error: ) print =only flush + (; OffendingCommand: ) print =only ( ]%%\n) print + } + { (Unrecoverable error: ) print =only flush + ( in ) print = flush + count 2 gt + { (Operand stack:\n ) print + 2 1 count 3 sub { ( ) print index =only flush } for + (\n) print flush + } if + } + ifelse + -1 0 1 //ErrorNames length 1 sub + { dup //ErrorNames exch get 3 index eq + { not exch pop exit } { pop } ifelse + } + for exch pop .quit + } bind def +/.errorhandler % .errorhandler - + { % Detect an internal 'stopped'. + 1 .instopped { null eq { pop pop stop } if } if + $error /.inerror get 1 .instopped { pop } { pop true } ifelse + { .unstoppederrorhandler + } if % detect error recursion + $error /globalmode .currentglobal false .setglobal put + $error /.inerror true put + $error /newerror true put + $error exch /errorname exch put + $error exch /command exch put + $error /recordstacks get $error /errorname get /VMerror ne and + { % Attempt to store the stack contents atomically. + count array astore dup $error /ostack 4 -1 roll + countexecstack array execstack $error /estack 3 -1 roll + countdictstack array dictstack $error /dstack 3 -1 roll + put put put aload pop + } + { $error /dstack .undef + $error /estack .undef + $error /ostack .undef + } + ifelse + $error /position currentfile status + { currentfile { fileposition } .internalstopped { pop null } if + } + { % If this was a scanner error, the file is no longer current, + % but the command holds the file, which may still be open. + $error /command get dup type /filetype eq + { { fileposition } .internalstopped { pop null } if } + { pop null } + ifelse + } + ifelse put + % During initialization, we don't reset the allocation + % mode on errors. + $error /globalmode get $error /.nosetlocal get and .setglobal + $error /.inerror false put + stop + } bind def +% Define the standard handleerror. We break out the printing procedure +% (.printerror) so that it can be extended for binary output +% if the Level 2 facilities are present. + /.printerror + { $error begin + /command load errorname SHORTERRORS + { (%%[ Error: ) print =only flush + (; OffendingCommand: ) print =only + currentdict /errorinfo .knownget + { (;\nErrorInfo:) print + dup type /arraytype eq + { { ( ) print =only } forall } + { ( ) print =only } + ifelse + } if + ( ]%%\n) print flush + } + { (Error: ) print ==only flush + ( in ) print ==only flush + currentdict /errorinfo .knownget + { (\nAdditional information: ) print ==only flush + } if + .printerror_long + } + ifelse + .clearerror + end + flush + } bind def + /.printerror_long % long error printout, + % $error is on the dict stack + { % Push the (anonymous) stack printing procedure. + % <==flag> proc + { + currentdict exch .knownget % stackname defined in $error? + { + 4 1 roll % stack: <==flag> + errordict exch .knownget % overridename defined? + { + exch pop exch pop exec % call override with + } + { + exch print exch % print heading. stack <==flag> + 1 index not { (\n) print } if + { 1 index { (\n ) } { ( ) } ifelse print + dup type /dicttype eq + { + (--dict:) print + dup rcheck + { dup length =only (/) print maxlength =only } + { pop } + ifelse + (--) print + } + { + dup type /stringtype eq 2 index or + { ===only } { =only } ifelse + } ifelse + } forall + pop + } + ifelse % overridden + } + { pop pop pop + } + ifelse % stack known + } + + (\nOperand stack:) OSTACKPRINT /.printostack /ostack 4 index exec + (\nExecution stack:) ESTACKPRINT /.printestack /estack 4 index exec + (\nBacktrace:) true /.printbacktrace /backtrace 4 index exec + (\nDictionary stack:) false /.printdstack /dstack 4 index exec + (\n) print + pop % printing procedure + + errorname /VMerror eq + { (VM status:) print mark vmstatus + counttomark { ( ) print counttomark -1 roll dup =only } repeat + cleartomark (\n) print + } if + + .languagelevel 2 ge + { (Current allocation mode is ) print + globalmode { (global\n) } { (local\n) } ifelse print + } if + + .oserrno dup 0 ne + { (Last OS error: ) print + errorname /VMerror ne + { dup .oserrorstring { = pop } { = } ifelse } + { = } + ifelse + } + { pop + } + ifelse + + position null ne + { (Current file position is ) print position = } + if + + } bind def +% Define a procedure for clearing the error indication. +/.clearerror + { $error /newerror false put + $error /errorname null put + $error /errorinfo .undef + 0 .setoserrno + } bind def + +% Define $error. This must be in local VM. +.currentglobal false .setglobal +/$error 40 dict def % newerror, errorname, command, errorinfo, + % ostack, estack, dstack, recordstacks, + % binary, globalmode, + % .inerror, .nosetlocal, position, + % plus extra space for badly designed error handers. +$error begin + /newerror false def + /recordstacks true def + /binary false def + /globalmode .currentglobal def + /.inerror false def + /.nosetlocal true def + /position null def +end +% Define errordict similarly. It has one entry per error name, +% plus handleerror. +/errordict ErrorNames length 1 add dict def +.setglobal % contents of errordict are global +errordict begin + ErrorNames + { mark 1 index systemdict /.errorhandler get /exec load .packtomark cvx def + } forall +% The handlers for interrupt and timeout are special; there is no +% 'current object', so they push their own name. + { /interrupt /timeout } + { mark 1 index dup systemdict /.errorhandler get /exec load .packtomark cvx def + } forall +/handleerror + { //systemdict /.printerror get exec + } bind def +end + +% Define the [write]==[only] procedures. +/.dict 26 dict dup +begin def + /.cvp {1 index exch .writecvs} bind def + /.nop {exch pop .p} bind def + /.p {1 index exch writestring} bind def + /.p1 {2 index exch writestring} bind def + /.p2 {3 index exch writestring} bind def + /.print + { dup type .dict exch .knownget + { dup type /stringtype eq { .nop } { exec } ifelse } + { (-) .p1 type .cvp (-) .p } + ifelse + } bind def + /.pstring + { { dup dup 32 lt exch 127 ge or + { (\\) .p1 2 copy -6 bitshift 48 add write + 2 copy -3 bitshift 7 and 48 add write + 7 and 48 add + } + { dup dup -2 and 40 eq exch 92 eq or {(\\) .p1} if + } + ifelse 1 index exch write + } + forall + } bind def + /booleantype /.cvp load def + /conditiontype (-condition-) def + /devicetype (-device-) def + /dicttype (-dict-) def + /filetype (-file-) def + /fonttype (-fontID-) def + /gstatetype (-gstate-) def + /integertype /.cvp load def + /locktype (-lock-) def + /marktype (-mark-) def + /nulltype (null) def + /realtype {1 index exch true .writecvp} bind def + /savetype (-save-) def + /nametype + {dup xcheck not {(/) .p1} if + 1 index exch .writecvs} bind def + /arraytype + {dup rcheck + {() exch dup xcheck + {({) .p2 + {exch .p1 + 1 index exch .print pop ( )} forall + (})} + {([) .p2 + {exch .p1 + 1 index exch .print pop ( )} forall + (])} + ifelse exch pop .p} + {(-array-) .nop} + ifelse} bind def + /operatortype + {(--) .p1 .cvp (--) .p} bind def + /packedarraytype + { dup rcheck + { arraytype } + { (-packedarray-) .nop } + ifelse + } bind def + /stringtype + { dup rcheck + { (\() .p1 dup length 200 le + { .pstring } + { 0 200 getinterval .pstring (...) .p } + ifelse (\)) .p + } + { (-string-) .nop + } + ifelse + } bind def +{//.dict begin .print pop end} + bind +end + +/write==only exch def +/write== {1 index exch write==only (\n) writestring} bind def +/==only { (%stdout) (w) file exch write==only } bind def +/== {==only (\n) print} bind def + +% Define [write]===[only], an extension that prints dictionaries +% in readable form and doesn't truncate strings. +/.dict /write==only load 0 get dup length dict .copydict dup +begin def + /dicttype + { dup rcheck + { (<< ) .p1 + { 2 index 3 -1 roll .print pop ( ) .p1 + 1 index exch .print pop ( ) .p + } + forall (>>) .p + } + { (-dict-) .nop + } + ifelse + } bind def + /stringtype + { dup rcheck + { (\() .p1 .pstring (\)) .p } + { (-string-) .nop } + ifelse + } bind def + +{//.dict begin .print pop end} + bind +end + +/write===only exch def +/write=== {1 index exch write===only (\n) writestring} bind def +/===only { (%stdout) (w) file exch write===only } bind def +/=== { ===only (\n) print } bind def + +(END PROCS) VMDEBUG + +% Define the font directory. +/FontDirectory false .setglobal 100 dict true .setglobal def + +% Define the encoding dictionary. +/EncodingDirectory 10 dict def % enough for Level 2 + PDF standard encodings + +% Define .findencoding. (This is redefined in Level 2.) +/.findencoding + { //EncodingDirectory exch get exec + } bind def +/.defineencoding + { //EncodingDirectory 3 1 roll put + } bind def +% If we've got the composite font extensions, define findencoding. +/rootfont where { pop /findencoding { .findencoding } odef } if + +% Load StandardEncoding. +%% Replace 1 (gs_std_e.ps) +(gs_std_e.ps) dup runlibfile VMDEBUG + +% Load ISOLatin1Encoding. +%% Replace 1 (gs_iso_e.ps) +(gs_iso_e.ps) dup runlibfile VMDEBUG + +% Define stubs for the Symbol and Dingbats encodings. +% Note that the first element of the procedure must be the file name, +% since gs_lev2.ps extracts it to set up the Encoding resource category. + + /SymbolEncoding { /SymbolEncoding .findencoding } bind def +%% Replace 3 (gs_sym_e.ps) + EncodingDirectory /SymbolEncoding + { (gs_sym_e.ps) //systemdict begin runlibfile SymbolEncoding end } + bind put + + /DingbatsEncoding { /DingbatsEncoding .findencoding } bind def +%% Replace 3 (gs_dbt_e.ps) + EncodingDirectory /DingbatsEncoding + { (gs_dbt_e.ps) //systemdict begin runlibfile DingbatsEncoding end } + bind put + +(END FONTDIR/ENCS) VMDEBUG + +% Construct a dictionary of all available devices. +% These are (read-only) device prototypes that can't be +% installed or have their parameters changed. For this reason, +% the value in the dictionary is actually a 2-element writable array, +% to allow us to create a default instance of the prototype on demand. + + % Loop until the .getdevice gets a rangecheck. +errordict /rangecheck 2 copy get +errordict /rangecheck { pop stop } put % pop the command + 0 { {dup .getdevice exch 1 add} loop} .internalstopped pop + 1 add dict /devicedict 1 index def + begin % 2nd copy of count is on stack + { dup .devicename exch + dup wcheck { dup } { null } ifelse 2 array astore def + } repeat + end +put % errordict /rangecheck +.clearerror +/devicenames devicedict { pop } forall devicedict length packedarray def + +% Determine the default device. +/defaultdevice DISPLAYING + { systemdict /DEVICE .knownget + { devicedict 1 index known not + { (Unknown device: ) print = + flush /defaultdevice cvx 1 .quit + } + if + } + { 0 .getdevice .devicename + } + ifelse + } + { /nullpage + } +ifelse +/.defaultdevicename 1 index def +finddevice % make a copy +def +devicedict /Default devicedict .defaultdevicename get put + +(END DEVS) VMDEBUG + +% Define statusdict, for the benefit of programs +% that think they are running on a LaserWriter or similar printer. +%% Replace 1 (gs_statd.ps) +(gs_statd.ps) runlibfile + +(END STATD) VMDEBUG + +% Load the standard font environment. +%% Replace 1 (gs_fonts.ps) +(gs_fonts.ps) runlibfile + +(END GS_FONTS) VMDEBUG + +% Load the initialization files for optional features. +%% Replace 4 INITFILES +systemdict /INITFILES known + { INITFILES { dup runlibfile VMDEBUG } forall + } +if + +% If Level 2 functionality is implemented, enable it now. +/.setlanguagelevel where + { pop 2 .setlanguagelevel + % If the resource machinery is loaded, fix up some things now. + /.fixresources where { pop .fixresources } if + } if + +(END INITFILES) VMDEBUG + +% Create a null font. This is the initial font. +8 dict dup begin + /FontMatrix [ 1 0 0 1 0 0 ] readonly def + /FontType 3 def + /FontName () def + /Encoding StandardEncoding def + /FontBBox { 0 0 0 0 } readonly def % executable is bogus, but customary ... + /BuildChar { pop pop 0 0 setcharwidth } bind def + /PaintType 0 def % shouldn't be needed! +end +/NullFont exch definefont setfont + +% Define NullFont as the font. +/NullFont currentfont def + +% Load initial fonts from FONTPATH directories, Fontmap file, +% and/or .getccfont as appropriate. +.loadinitialfonts + +% Remove NullFont from FontDirectory, so it can't be accessed by mistake. +FontDirectory /NullFont .undef + +(END FONTS) VMDEBUG + +% Restore the real definition of runlibfile. +/runlibfile /.runlibfile load def +currentdict /.runlibfile .undef + +% Bind all the operators defined as procedures. +/.bindoperators % binds operators in currentdict + { % Temporarily disable the typecheck error. + errordict /typecheck 2 copy get + errordict /typecheck { pop } put % pop the command + currentdict + { dup type /operatortype eq + { % This might be a real operator, so bind might cause a typecheck, + % but we've made the error a no-op temporarily. + .bind % do a real bind even if NOBIND is set + } + if pop pop + } forall + put + } def +NOBIND DELAYBIND or not { .bindoperators } if + +% Establish a default environment. + +defaultdevice +DISPLAYING not { setdevice (%END DISPLAYING) .skipeof } if +systemdict /DEVICEWIDTH known +systemdict /DEVICEHEIGHT known or +systemdict /DEVICEWIDTHPOINTS known or +systemdict /DEVICEHEIGHTPOINTS known or +systemdict /DEVICEXRESOLUTION known or +systemdict /DEVICEYRESOLUTION known or +systemdict /PAPERSIZE known or +not { (%END DEVICE) .skipeof } if +% Let DEVICE{WIDTH,HEIGHT}[POINTS] override PAPERSIZE. +systemdict /PAPERSIZE known +systemdict /DEVICEWIDTH known not and +systemdict /DEVICEHEIGHT known not and +systemdict /DEVICEWIDTHPOINTS known not and +systemdict /DEVICEHEIGHTPOINTS known not and + { % Convert the paper size to device dimensions. + true statusdict /.pagetypenames get + { PAPERSIZE eq + { PAPERSIZE load + dup 0 get /DEVICEWIDTHPOINTS exch def + 1 get /DEVICEHEIGHTPOINTS exch def + pop false exit + } + if + } + forall + { (Unknown paper size: ) print PAPERSIZE ==only (.\n) print + } + if + } +if +% Adjust the device parameters per the command line. +% It is possible to specify resolution, pixel size, and page size; +% since any two of these determine the third, conflicts are possible. +% We simply pass them to .setdeviceparams and let it sort things out. + mark /HWResolution null /HWSize null /PageSize null .dicttomark + .getdeviceparams .dicttomark begin + mark + % Check for resolution. + /DEVICEXRESOLUTION where dup + { exch pop HWResolution 0 DEVICEXRESOLUTION put } + if + /DEVICEYRESOLUTION where dup + { exch pop HWResolution 1 DEVICEYRESOLUTION put } + if + or { /HWResolution HWResolution } if + % Check for device sizes specified in pixels. + /DEVICEWIDTH where dup + { exch pop HWSize 0 DEVICEWIDTH put } + if + /DEVICEHEIGHT where dup + { exch pop HWSize 1 DEVICEHEIGHT put } + if + or { /HWSize HWSize } if + % Check for device sizes specified in points. + /DEVICEWIDTHPOINTS where dup + { exch pop PageSize 0 DEVICEWIDTHPOINTS put } + if + /DEVICEHEIGHTPOINTS where dup + { exch pop PageSize 1 DEVICEHEIGHTPOINTS put } + if + or { /PageSize PageSize } if + % Check whether any parameters were set. + dup mark eq { pop } { defaultdevice putdeviceprops } ifelse + end +%END DEVICE +% Set any device properties defined on the command line. +% If BufferSpace is defined but not MaxBitmap, set MaxBitmap to BufferSpace. +systemdict /BufferSpace known +systemdict /MaxBitmap known not and + { systemdict /MaxBitmap BufferSpace put + } if +dup getdeviceprops +counttomark 2 idiv + { systemdict 2 index known + { pop dup load counttomark 2 roll } + { pop pop } + ifelse + } repeat +counttomark dup 0 ne + { 2 add -1 roll putdeviceprops } + { pop pop } +ifelse +setdevice % does an erasepage +% If the media size is fixed, update the current page device dictionary. +FIXEDMEDIA +dup { pop systemdict /.currentpagedevice known } if +dup { pop .currentpagedevice exch pop } if +not { (%END MEDIA) .skipeof } if +currentpagedevice dup length dict .copydict +dup /Policies + % Stack: /Policies +1 index /InputAttributes +2 copy get dup length dict .copydict + % Stack: /Policies + % /InputAttributes +dup 0 2 copy get dup length dict .copydict + % Stack: /Policies + % /InputAttributes 0 +dup /PageSize 7 index /PageSize get +put % PageSize in 0 +put % 0 in InputAttributes +put % InputAttributes in pagedevice +% Also change the page size policy so we don't get an error. + % Stack: /Policies +2 copy get dup length dict .copydict + % Stack: /Policies +dup /PageSize 7 put % PageSize in Policies +put % Policies in pagedevice +.setpagedevice +%END MEDIA +%END DISPLAYING + +(END DEVICE) VMDEBUG + +% Establish a default upper limit in the character cache, +% namely, enough room for a 18-point character at the resolution +% of the default device, or for a character consuming 1% of the +% maximum cache size, whichever is larger. +mark + % Compute limit based on character size. + 18 dup dtransform + exch abs cvi 31 add 32 idiv 4 mul % X raster + exch abs cvi mul % Y + % Compute limit based on allocated space. + cachestatus pop pop pop pop pop exch pop 0.01 mul cvi + .max dup 10 idiv exch +setcacheparams +% Conditionally disable the character cache. +NOCACHE { 0 setcachelimit } if + +(END CONFIG) VMDEBUG + +% Establish an appropriate halftone screen and BG/UCR functions. +% We make this a procedure so we can call it again when switching devices. + +% Use an ordered dither for low-resolution devices. +/.setloresscreen % .setloresscreen - + { % The following 'ordered dither' spot function was contributed by + % Gregg Townsend. Thanks, Gregg! + 16.001 div 0 % not 16: avoids rounding problems + { 1 add 7.9999 mul cvi exch 1 add 7.9999 mul cvi 16 mul add < + 0E 8E 2E AE 06 86 26 A6 0C 8C 2C AC 04 84 24 A4 + CE 4E EE 6E C6 46 E6 66 CC 4C EC 6C C4 44 E4 64 + 3E BE 1E 9E 36 B6 16 96 3C BC 1C 9C 34 B4 14 94 + FE 7E DE 5E F6 76 D6 56 FC 7C DC 5C F4 74 D4 54 + 01 81 21 A1 09 89 29 A9 03 83 23 A3 0B 8B 2B AB + C1 41 E1 61 C9 49 E9 69 C3 43 E3 63 CB 4B EB 6B + 31 B1 11 91 39 B9 19 99 33 B3 13 93 3B BB 1B 9B + F1 71 D1 51 F9 79 D9 59 F3 73 D3 53 FB 7B DB 5B + 0D 8D 2D AD 05 85 25 A5 0F 8F 2F AF 07 87 27 A7 + CD 4D ED 6D C5 45 E5 65 CF 4F EF 6F C7 47 E7 67 + 3D BD 1D 9D 35 B5 15 95 3F BF 1F 9F 37 B7 17 97 + FD 7D DD 5D F5 75 D5 55 FF 7F DF 5F F7 77 D7 57 + 02 82 22 A2 0A 8A 2A AA 00 80 20 A0 08 88 28 A8 + C2 42 E2 62 CA 4A EA 6A C0 40 E0 60 C8 48 E8 68 + 32 B2 12 92 3A BA 1A 9A 30 B0 10 90 38 B8 18 98 + F2 72 D2 52 FA 7A DA 5A F0 70 D0 50 F8 78 D8 58 + > exch get 256 div + } + bind + % Use correct, per-plane screens for CMYK devices only. + //systemdict /setcolorscreen known processcolors 4 eq and + { 3 copy 6 copy setcolorscreen } + { setscreen } + ifelse + 0 array cvx settransfer % Genoa CET won't accept a packed array! + /setstrokeadjust where { pop true setstrokeadjust } if + } bind def +% Use a 45-degree spot screen for high-resolution devices. +/.sethiresscreen % .sethiresscreen - + { % According to information published by Hewlett-Packard, + % they use a 60 line screen on 300 DPI printers and + % an 85 line screen on 600 DPI printers. + % However, we use a 106 line screen, which produces smoother- + % looking shades but fewer of them (32 vs. 50). + % 46 was suggested as a good frequency value for printers + % between 200 and 400 DPI, so we use it for lower resolutions. + % Imagesetters need even higher frequency screens. + //systemdict /DITHERPPI known + { DITHERPPI + } + { dup cvi 100 idiv 15 .min + {null 46 46 60 60 60 106 106 106 106 133 133 133 133 133 150} + exch get + } + ifelse + 1 index 4.01 div .min % at least a 4x4 cell + 45 + % The following screen algorithm is used by permission of the author. + { 1 add 180 mul cos 1 0.08 add mul exch 2 add 180 mul cos + 1 0.08 sub mul add 2 div % (C) 1989 Berthold K.P. Horn + } + bind + % Determine whether we have lots of process colors. + % If so, don't bother with color screening or gamma correction. + % Also don't do gamma correction on very high-resolution devices. + % (This should depend on dot gain, not resolution, but we don't + % currently have a way to determine this.) + currentdevice mark + /RedValues 0 /GreenValues 0 /BlueValues 0 /GrayValues 0 + .dicttomark .getdeviceparams + counttomark 2 idiv 1 sub { exch pop min } repeat + exch pop exch pop 32 lt 4 index 800 lt and 5 1 roll + % Stack: doscreen dpi freq angle proc + % Ghostscript currently doesn't use correct, per-plane halftones + % unless setcolorscreen has been executed. Since these are + % computationally much more expensive than binary halftones, + % we check to make sure they are really warranted, i.e., we have + % a high-resolution CMYK device (i.e., not a display) with + % fewer than 5 bits per plane (i.e., not a true-color device). + 4 -1 roll 150 ge + { /setcolorscreen where + { pop //systemdict /COLORSCREEN known + { COLORSCREEN } + { 3 index } + ifelse + dup false ne + { 4 1 roll 3 copy 6 copy 13 -1 roll + % For really high-quality screening on printers, we need to + % give each plane its own screen angle. Unfortunately, + % this currently has very large space and time costs. + true eq % true => different angles, + % 0 => same angles + { { 45 90 15 75 } { 3 1 roll exch pop 12 3 roll } forall + } + if setcolorscreen + } + { pop setscreen % false => single binary screen + } + ifelse + } + { setscreen % setcolorscreen not known + } + ifelse + } + { setscreen % not high resolution + } + ifelse + % Stack: doscreen + { % Set the transfer function to lighten up the grays. + % We correct at the high end so that very light grays + % don't disappear completely if they darken <1 screen pixel. + % Parameter values closer to 1 are better for devices with + % less dot spreading; lower values are better with more spreading. + % The value 0.8 is a compromise that will probably please no one! + % + % Because of a bug in FrameMaker, we have to accept operands + % outside the valid range of [0..1]. + { dup dup 0.0 gt exch 1.0 lt and + { 0.8 exp dup dup 0.9375 gt exch 0.999 lt and % > 15/16 + { .currentscreenlevels 1 sub % tweak to avoid boundary + 1 exch div 1 exch sub .min + } + if + } + if + } + } + { % Set the transfer function to the identity. + 0 array cvx % Genoa CET won't accept a packed array! + } + ifelse settransfer + /setstrokeadjust where { pop false setstrokeadjust } if + % Increase fill adjustment so that we effectively use Adobe's + % any-part-of-pixel rule. + 0.5 .setfilladjust + } bind def +% Set the default screen and BG/UCR based on the device resolution and +% process color capability. +/.setdefaultbgucr systemdict /setblackgeneration known { { + processcolors 1 eq { { } } { { pop 0.0 } } ifelse + dup setblackgeneration setundercolorremoval +} } { { +} } ifelse bind def +/.setdefaultscreen + { % Compute min(|dpi x|,|dpi y|) as the definition of the resolution. + 72 72 matrix defaultmatrix dtransform abs exch abs .min + dup 150 lt //systemdict /DITHERPPI known not and + { .setloresscreen } { .sethiresscreen } + ifelse .setdefaultbgucr + } bind def +.setdefaultscreen +initgraphics + +% The interpreter relies on there being at least 2 entries +% on the graphics stack. Establish the second one now. +gsave + +% Define some control sequences as no-ops. +% This is a hack to get around problems +% in some common PostScript-generating applications. +<04> cvn { } def % Apple job separator +<0404> cvn { } def % two of the same +<1b> cvn { } def % MS Windows LaserJet 4 prologue + % (UEL = ESC %-12345X) +<1b45> cvn { } def % PJL reset prologue (ESC E) +<1b451b> cvn { } def % PJL reset epilogue (ESC E + UEL) +<041b> cvn { } def % MS Windows LaserJet 4 epilogue (^D + UEL) +(\001M) cvn % TBCP initiator + { currentfile /TBCPDecode filter cvx exec + } bind def +/@PJL % H-P job control + { currentfile //=string readline { pop } if + } bind def + +% If we want a "safer" system, disable some obvious ways to cause havoc. +SAFER not { (%END SAFER) .skipeof } if +/file + { dup (r) eq 2 index (%pipe*) .stringmatch not and + 2 index (%std*) .stringmatch or + { file } + { /invalidfileaccess signalerror } + ifelse + } .bind odef +/renamefile { /invalidfileaccess signalerror } odef +/deletefile { /invalidfileaccess signalerror } odef +/putdeviceprops + { counttomark + dup 2 mod 0 eq { pop /rangecheck signalerror } if + 3 2 3 2 roll + { dup index /OutputFile eq + { -2 roll + dup () ne { /putdeviceprops load /invalidfileaccess signalerror } if + 3 -1 roll + } + { pop + } + ifelse + } for + putdeviceprops + } .bind odef + +%END SAFER + +% If we delayed binding, make it possible to do it later. +/.bindnow + { //systemdict begin .bindoperators end + % Temporarily disable the typecheck error. + errordict /typecheck 2 copy get + errordict /typecheck { pop } put % pop the command + 0 1 .delaycount 1 sub { .delaybind exch get .bind pop } for + userdict /.delaybind .undef % reclaim the space + userdict /.delaycount .undef + put + } .bind def + +% Turn off array packing, since some PostScript code assumes that +% procedures are writable. +false setpacking + +% Close up systemdict. +currentdict /.forceput .undef % remove temptation +currentdict /filterdict .undef % bound in where needed +end +WRITESYSTEMDICT not { systemdict readonly pop } if + +(END INIT) VMDEBUG + +% Since some badly-behaved files include extremely long procedures, +% or construct huge arrays on the operand stack, increase the operand +% stack size here. +/setuserparams where + { pop mark /MaxOpStack 20000 .dicttomark setuserparams + } if + +% Establish local VM as the default. +false /setglobal where { pop setglobal } { .setglobal } ifelse +$error /.nosetlocal false put + +% Clean up VM, and enable GC. +/vmreclaim where + { pop NOGC not { 2 vmreclaim 0 vmreclaim } if + } if + +(END GC) VMDEBUG + +% The interpreter will run the initial procedure (start). diff --git a/gs/lib/gs_iso_e.ps b/gs/lib/gs_iso_e.ps new file mode 100644 index 000000000..2f4245b14 --- /dev/null +++ b/gs/lib/gs_iso_e.ps @@ -0,0 +1,67 @@ +% Copyright (C) 1993, 1994 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% Define the ISO Latin-1 encoding vector. +% The first half is the same as the standard encoding, +% except for minus instead of hyphen at code 055. +/ISOLatin1Encoding +StandardEncoding 0 45 getinterval aload pop + /minus +StandardEncoding 46 82 getinterval aload pop +% NOTE: the following are missing in the Adobe documentation, +% but appear in the displayed table: +% macron at 0225, dieresis at 0230, cedilla at 0233, space at 0240. +% This is an error in the Red Book, corrected in Adobe TN 5085. +% \20x + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + /dotlessi /grave /acute /circumflex /tilde /macron /breve /dotaccent + /dieresis /.notdef /ring /cedilla /.notdef /hungarumlaut /ogonek /caron +% \24x + /space /exclamdown /cent /sterling + /currency /yen /brokenbar /section + /dieresis /copyright /ordfeminine /guillemotleft + /logicalnot /hyphen /registered /macron + /degree /plusminus /twosuperior /threesuperior + /acute /mu /paragraph /periodcentered + /cedilla /onesuperior /ordmasculine /guillemotright + /onequarter /onehalf /threequarters /questiondown +% \30x + /Agrave /Aacute /Acircumflex /Atilde + /Adieresis /Aring /AE /Ccedilla + /Egrave /Eacute /Ecircumflex /Edieresis + /Igrave /Iacute /Icircumflex /Idieresis + /Eth /Ntilde /Ograve /Oacute + /Ocircumflex /Otilde /Odieresis /multiply + /Oslash /Ugrave /Uacute /Ucircumflex + /Udieresis /Yacute /Thorn /germandbls +% \34x + /agrave /aacute /acircumflex /atilde + /adieresis /aring /ae /ccedilla + /egrave /eacute /ecircumflex /edieresis + /igrave /iacute /icircumflex /idieresis + /eth /ntilde /ograve /oacute + /ocircumflex /otilde /odieresis /divide + /oslash /ugrave /uacute /ucircumflex + /udieresis /yacute /thorn /ydieresis +% Make an array on large systems, a packed array on small ones. +256 +vmstatus exch pop exch pop +100000 ge { array astore readonly } { packedarray } ifelse +def +1 ISOLatin1Encoding .registerencoding +/ISOLatin1Encoding ISOLatin1Encoding .defineencoding diff --git a/gs/lib/gs_kanji.ps b/gs/lib/gs_kanji.ps new file mode 100644 index 000000000..09bb529a4 --- /dev/null +++ b/gs/lib/gs_kanji.ps @@ -0,0 +1,159 @@ +% Copyright (C) 1994, 1995, 1996 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% Scaffolding for Kanji fonts. This is based on the Wadalab free font +% from the University of Tokyo; it may not be appropriate for other +% Kanji fonts. + +/currentglobal where + { pop currentglobal { setglobal } true setglobal } + { { } } +ifelse + +% Define the encoding for the root font. + +/KanjiEncoding +% \x00 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 +% \x20 + 0 1 2 3 4 5 6 7 + 8 0 0 0 0 0 0 0 + 9 10 11 12 13 14 15 16 + 17 18 19 20 21 22 23 24 +% \x40 + 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 +% \x60 + 57 58 59 60 61 62 63 64 + 65 66 67 68 69 70 71 72 + 73 74 75 76 77 0 0 0 + 0 0 0 0 0 0 0 0 +% \x80 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 +% \xA0 + 0 1 2 3 4 5 6 7 + 8 0 0 0 0 0 0 0 + 9 10 11 12 13 14 15 16 + 17 18 19 20 21 22 23 24 +% \xC0 + 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 +% \xE0 + 57 58 59 60 61 62 63 64 + 65 66 67 68 69 70 71 72 + 73 74 75 76 77 0 0 0 + 0 0 0 0 0 0 0 0 +256 packedarray def + +% Define a stub for the base font encoding. + + /KanjiSubEncoding { /KanjiSubEncoding .findencoding } bind def +%% Replace 3 (gs_ksb_e.ps) + EncodingDirectory /KanjiSubEncoding + { (gs_ksb_e.ps) //systemdict begin runlibfile KanjiSubEncoding end } + bind put + +% Support procedures and data. + +/T1FontInfo 8 dict begin + /version (001.001) readonly def + /FullName (KanjiBase) readonly def + /FamilyName (KanjiBase) readonly def + /Weight (Medium) readonly def + /ItalicAngle 0 def + /isFixedPitch false def + /UnderlinePosition 0 def + /UnderlineThickness 0 def +currentdict end readonly def + +/T1NF % T1NF +{ +20 dict begin + /FontName exch def + /FontType 1 def + /FontInfo T1FontInfo def + /FontMatrix [.001 0 0 .001 0 0] def + /FontBBox [0 0 1000 1000] def + /Encoding KanjiSubEncoding def + /CharStrings 150 dict def + /PaintType 0 def + /Private 2 dict def + Private begin + /BlueValues [] def + /password 5839 def + end +FontName currentdict end definefont +} def + +/T0NF % T0NF +{ +20 dict begin + /FontName exch def + /FDepVector exch def + /FontType 0 def + /FontMatrix [1 0 0 1 0 0] def + /FMapType 2 def + /Encoding KanjiEncoding def +FontName currentdict end definefont +} def + +% Define the composite font and all the base fonts. + +/CompNF % CompNF +{ +/newname1 exch def +newname1 dup length string cvs /str exch def +str length /len exch def +/fdepvector 78 array def +/j 1 def +16#21 1 16#74 { +/i exch def +KanjiEncoding i get 0 gt { +len 4 add string /newstr exch def +newstr 0 str putinterval +newstr len (.r) putinterval +newstr len 2 add i 16 2 string cvrs putinterval +newstr cvn /newlit exch def +newlit T1NF /newfont exch def +fdepvector j newfont put +/j j 1 add def +} if +} for +fdepvector 0 fdepvector 1 get put +/j 0 def +fdepvector newname1 T0NF +} def + +% Define an individual character in a composite font. +/CompD % <(HL)> CompD - + { currentfont /Encoding get 1 index 0 get get % FDepVector index + currentfont /FDepVector get exch get % base font + dup /Encoding get 3 -1 roll 1 get get % base font character name + exch /CharStrings get exch 3 -1 roll put + } bind def + +exec diff --git a/gs/lib/gs_ksb_e.ps b/gs/lib/gs_ksb_e.ps new file mode 100644 index 000000000..b6e478914 --- /dev/null +++ b/gs/lib/gs_ksb_e.ps @@ -0,0 +1,65 @@ +% Copyright (C) 1994 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% Define the KanjiSub encoding vector. +/currentglobal where + { pop currentglobal { setglobal } true setglobal } + { { } } +ifelse +/KanjiSubEncoding +%\x00 + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +%\x20 + /.notdef /c21 /c22 /c23 /c24 /c25 /c26 /c27 + /c28 /c29 /c2A /c2B /c2C /c2D /c2E /c2F + /c30 /c31 /c32 /c33 /c34 /c35 /c36 /c37 + /c38 /c39 /c3A /c3B /c3C /c3D /c3E /c3F +%\x40 + /c40 /c41 /c42 /c43 /c44 /c45 /c46 /c47 + /c48 /c49 /c4A /c4B /c4C /c4D /c4E /c4F + /c50 /c51 /c52 /c53 /c54 /c55 /c56 /c57 + /c58 /c59 /c5A /c5B /c5C /c5D /c5E /c5F +%\x60 + /c60 /c61 /c62 /c63 /c64 /c65 /c66 /c67 + /c68 /c69 /c6A /c6B /c6C /c6D /c6E /c6F + /c70 /c71 /c72 /c73 /c74 /c75 /c76 /c77 + /c78 /c79 /c7A /c7B /c7C /c7D /c7E /.notdef +%\x80 + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +%\xA0 + /.notdef /c21 /c22 /c23 /c24 /c25 /c26 /c27 + /c28 /c29 /c2A /c2B /c2C /c2D /c2E /c2F + /c30 /c31 /c32 /c33 /c34 /c35 /c36 /c37 + /c38 /c39 /c3A /c3B /c3C /c3D /c3E /c3F +%\xC0 + /c40 /c41 /c42 /c43 /c44 /c45 /c46 /c47 + /c48 /c49 /c4A /c4B /c4C /c4D /c4E /c4F + /c50 /c51 /c52 /c53 /c54 /c55 /c56 /c57 + /c58 /c59 /c5A /c5B /c5C /c5D /c5E /c5F +%\xE0 + /c60 /c61 /c62 /c63 /c64 /c65 /c66 /c67 + /c68 /c69 /c6A /c6B /c6C /c6D /c6E /c6F + /c70 /c71 /c72 /c73 /c74 /c75 /c76 /c77 + /c78 /c79 /c7A /c7B /c7C /c7D /c7E /.notdef +256 packedarray .defineencoding +exec diff --git a/gs/lib/gs_l2img.ps b/gs/lib/gs_l2img.ps new file mode 100644 index 000000000..9ac5726ee --- /dev/null +++ b/gs/lib/gs_l2img.ps @@ -0,0 +1,186 @@ +% Copyright (C) 1995, 1996 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% Emulate the Level 2 dictionary-based image operator in Level 1, +% except for Interpolate (ignored) and MultipleDataSources = true; +% also, we require that the data source be either a procedure of a +% particular form or a stream, not a string or a general procedure. + +% pdf2ps copies the portion of this file from %BEGIN to %END if Level 1 +% compatible output is requested. + +/currentglobal where + { pop currentglobal { setglobal } true setglobal } + { { } } +ifelse + +/packedarray where + { pop } + { /packedarray { array astore readonly } bind def } +ifelse + +%BEGIN + +11 dict /.csncompdict 1 index def begin + /DeviceGray { 1 /setgray load } bind def + /DeviceRGB { 3 /setrgbcolor load } bind def + /DeviceCMYK { 4 /setcmykcolor load } bind def + /Indexed + { dup 1 index 1 get //.csncompdict exch get exec + % Stack: [/Indexed base hival map] ncomp basesetcolor + 3 -1 roll 3 get mark 3 1 roll + % Stack: ncomp -mark- basesetcolor map + dup type /stringtype eq + { { - + { exch round cvi get 255 div + } + - + { exch round cvi 3 mul 2 copy 2 copy get 255 div + 3 1 roll 1 add get 255 div + 4 2 roll 2 add get 255 div + } + { exch round cvi 4 mul 2 copy 2 copy 2 copy get 255 div + 3 1 roll 1 add get 255 div + 4 2 roll 2 add get 255 div + 5 3 roll 3 add get 255 div + } + } + 4 index get aload pop counttomark -1 roll + } + { /exec load 3 -1 roll + % Stack: -mark- mapproc --exec-- basesetcolor + } + ifelse .packtomark cvx + exch pop 1 exch + } bind def + /Separation + { dup 2 index //.csncompdict exch get exec + % Stack: [/Separation name alt xform] ncomp altsetcolor + 3 -1 roll 3 get /exec load 3 -1 roll 3 array astore readonly cvx + exch pop 1 exch + } bind def + % Substitute device spaces for CIE spaces. + /CIEBasedA /DeviceGray load def + /CIEBasedABC /DeviceRGB load def + /CIEBasedDEF /DeviceRGB load def + /CIEBasedDEFG /DeviceCMYK load def +end + +/.packtomark { counttomark packedarray exch pop } bind def + +/.csinextbits % - .csinextbits + % Uses b, nnb, i, row, mask, BitsPerComponent; + % sets b, nnb, i. + { /nnb nnb BitsPerComponent add + { dup 0 le { exit } if + /b b 8 bitshift row i get add def + /i i 1 add def 8 sub + } + loop def + b nnb bitshift mask and + } bind def + +% Note that the ColorSpace key must be present in the image dictionary. +/.colorspaceimage % .colorspaceimage - + { save exch + dup length 15 add dict begin { cvlit def } forall + ColorSpace dup dup type /nametype ne { 0 get } if + .csncompdict exch get exec + /setpixelcolor exch def /ncomp exch def pop + /row ncomp BitsPerComponent mul Width mul 7 add 8 idiv string def + /mask 1 BitsPerComponent bitshift 1 sub def + /nextbits BitsPerComponent 8 eq + { { row i get /i i 1 add def } } + { /.csinextbits load } + ifelse def + /nextpixel mark 0 2 ncomp 1 sub 2 mul + { /nextbits cvx exch + Decode exch 2 getinterval + dup aload pop exch sub + dup mask eq { pop } { mask div /mul load 3 -1 roll } ifelse + 0 get dup 0 eq { pop } { /sub load 3 -1 roll } ifelse + } + for + /setpixelcolor load dup type /operatortype ne { /exec load } if + .packtomark cvx def + /readrow + /DataSource load dup type + dup /arraytype eq exch /packedarraytype eq or + { % Must be { ... } + aload length 1 add array /pop load exch astore + dup 1 row put cvx + } + { pop + % Adobe requires readstring to signal an error if given + % an empty string. Work around this nonsense here. + row length 0 eq + { { } } + { { DataSource row readstring pop pop } } + ifelse + } + ifelse def + ImageMatrix matrix invertmatrix concat + /imat matrix def + 0 1 Height 1 sub + { imat 5 3 -1 roll neg put +%(.) print flush + readrow + /b 0 def /nnb 0 def /i 0 def + 0 1 Width 1 sub + { imat 4 3 -1 roll neg put nextpixel + 1 1 true imat {<80>} imagemask + } + for + } + for + end restore + } bind def + +%END +exec +currentfile closefile + +% Patch for testing. +/.cincompdict 3 dict begin + 1 { {0 1} {/DeviceGray} } def + 3 { {0 1 0 1 0 1} {/DeviceRGB} } def + 4 { {0 1 0 1 0 1 0 1} {/DeviceCMYK} } def +currentdict end def +/.imagekeys [ + /Decode /DataSource /ImageMatrix /BitsPerComponent /Height /Width +] def +/colorimage % + % false colorimage - + { 1 index { /colorimage load /rangecheck signalerror } if exch pop + //.cincompdict exch get exec + 7 dict begin /ColorSpace exch cvlit def + .imagekeys { exch cvlit def } forall + currentdict end .colorspaceimage + } bind odef +/image + { dup type /dicttype ne + { 7 dict begin /ColorSpace /DeviceGray def [0 1] + .imagekeys { exch cvlit def } forall + currentdict end + } + { dup length 1 add dict .copydict dup /ColorSpace currentcolorspace put + } + ifelse + .colorspaceimage + } bind odef + +exec diff --git a/gs/lib/gs_lev2.ps b/gs/lib/gs_lev2.ps new file mode 100644 index 000000000..f07bf81b9 --- /dev/null +++ b/gs/lib/gs_lev2.ps @@ -0,0 +1,459 @@ +% Copyright (C) 1990, 1996, 1997 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% Initialization file for Level 2 functions. +% When this is run, systemdict is still writable, +% but (almost) everything defined here goes into level2dict. + +level2dict begin + +% ------ System and user parameters ------ % + +% User parameters are managed entirely in C code. +/currentuserparams { % - currentuserparams + mark .currentuserparams .dicttomark + } odef +systemdict begin +/getuserparam { % getuserparam + .getuserparam +} odef +end + +% Some system parameters are managed entirely at the PostScript level. +% We take care of that here. +systemdict begin +currentdict /systemparams known not { + /systemparams 10 dict readonly def +} if +/getsystemparam { % getsystemparam + //systemparams 1 index .knownget { exch pop } { .getsystemparam } ifelse +} odef +end +/currentsystemparams { % - currentsystemparams + mark .currentsystemparams //systemparams { } forall .dicttomark +} odef +/.setsystemparams /setsystemparams load def +/setsystemparams { % setsystemparams - + % Check that we will be able to set the PostScript-level + % system parameters. + dup + { //systemparams 3 -1 roll .knownget + { type 1 index type ne + { pop /setsystemparams load /typecheck signalerror } + if + dup type /stringtype eq + { dup dup gcheck exch rcheck or not + { /setsystemparams load /invalidaccess signalerror } + if + } + if pop + } + { pop + } + ifelse + } + forall + % Set the C-level system params. If this succeeds, we know that + % the password check succeeded. + dup .setsystemparams + % Now set the PostScript-level params. We must copy local strings + % into global VM. + dup + { //systemparams 2 index known + { % Stack: key newvalue + dup gcheck not + { % The only composite objects that can have passed + % the type check are strings. + .currentglobal true .setglobal + 1 index length string exch .setglobal + copy readonly + } + if //systemparams 3 1 roll .forceput + } + { pop pop + } + ifelse + } + forall pop +} odef + +% ------ Miscellaneous ------ % + +(<<) cvn % - << -mark- + /mark load def +(>>) cvn % -mark- ... >> + /.dicttomark load def +/languagelevel 2 def +% When running in Level 2 mode, this interpreter is supposed to be +% compatible with PostScript version 2010 (I think). +/version (2010) def + +% If binary tokens are supported by this interpreter, +% set an appropriate default binary object format. +/setobjectformat where + { pop + /RealFormat getsystemparam (IEEE) eq { 1 } { 3 } ifelse + /ByteOrder getsystemparam { 1 add } if + setobjectformat + } if + +% ------ Virtual memory ------ % + +/currentglobal % - currentglobal + /currentshared load def +/gcheck % gcheck + /scheck load def +/setglobal % setglobal - + /setshared load def +% We can make the global dictionaries very small, because they auto-expand. +/globaldict currentdict /shareddict .knownget not { 4 dict } if def +/GlobalFontDirectory SharedFontDirectory def + +% ------ IODevices ------ % + +/.getdevparams where { + pop /currentdevparams { % currentdevparams + .getdevparams .dicttomark + } odef +} if +/.putdevparams where { + pop /setdevparams { % setdevparams - + mark 1 index { } forall counttomark 2 add index + .putdevparams pop pop + } odef +} if + +% ------ Job control ------ % + +serverdict begin + +% We could protect the job information better, but we aren't attempting +% (currently) to protect ourselves against maliciousness. + +/.jobsave null def % top-level save object +/.jobsavelevel 0 def % save depth of job (0 if .jobsave is null, + % 1 otherwise) +/.adminjob true def % status of current unencapsulated job + +/exitserver { % exitserver - + true exch startjob not { /exitserver /invalidaccess signalerror } if +} bind def + +end % serverdict + +% Because there may be objects on the e-stack created since the job save, +% we have to clear the e-stack before doing the end-of-job restore. +% We do this by executing a 2 .stop, which is caught by the 2 .stopped +% in .runexec; we leave on the o-stack a procedure to execute aftewards. +% +%**************** The definition of startjob is not complete yet, since +% it doesn't reset stdin/stdout or other aspects of the interpreter. +/.finishstartjob { % + % .finishstartjob -true- + serverdict /.jobsave get dup null eq { pop } { restore } ifelse + exch { + % Unencapsulated job + serverdict /.jobsave null put + serverdict /.jobsavelevel 0 put + serverdict /.adminjob 3 -1 roll 1 gt put + } { + % Encapsulated job + pop + serverdict /.jobsave save put + serverdict /.jobsavelevel 1 put + userdict /quit /stop load put + } ifelse true +} bind def +/startjob { % startjob + vmstatus pop pop serverdict /.jobsavelevel get eq + 1 index .checkpassword 0 gt and { + .checkpassword count 2 roll count 2 sub { pop } repeat + cleardictstack + % Reset the e-stack back to the 2 .stopped in .runexec. + { .finishstartjob } 2 .stop + } { % Password check failed + pop pop false + } ifelse +} odef + +systemdict begin +/quit { % - quit - + //systemdict begin serverdict /.jobsave get null eq + { end //quit } + { /quit load /invalidaccess /signalerror load end exec } + ifelse +} bind odef +end + +% ------ Compatibility ------ % + +% In Level 2 mode, the following replace the definitions that gs_statd.ps +% installs in statusdict and serverdict. +% Note that statusdict must be allocated in local VM. +% We don't bother with many of these yet. + +/.dict1 { exch mark 3 1 roll .dicttomark } bind def + +currentglobal false setglobal 25 dict exch setglobal begin +currentsystemparams + +/buildtime 1 index /BuildTime get def +/byteorder 1 index /ByteOrder get def +/checkpassword { .checkpassword 0 gt } bind def +/defaulttimeouts + { currentsystemparams dup + /JobTimeout .knownget not { 0 } if + exch /WaitTimeout .knownget not { 0 } if + currentpagedevice /ManualFeedTimeout .knownget not { 0 } if + } bind def +dup /DoStartPage known + { /dostartpage { /DoStartPage getsystemparam } bind def + /setdostartpage { /DoStartPage .dict1 setsystemparams } bind def + } if +dup /StartupMode known + { /dosysstart { /StartupMode getsystemparam 0 ne } bind def + /setdosysstart { { 1 } { 0 } ifelse /StartupMode .dict1 setsystemparams } bind def + } if +%****** Setting jobname is supposed to set userparams.JobName, too. +/jobname { /JobName getuserparam } bind def +/jobtimeout { /JobTimeout getuserparam } bind def +%manualfeed +%manualfeedtimeout +/margins + { currentpagedevice /Margins .knownget { exch } { [0 0] } ifelse + } bind def +%pagecount +%pagestackorder +/printername + { currentsystemparams /PrinterName .knownget not { () } if exch copy + } bind def +%/ramsize { /RamSize getsystemparam } bind def +/realformat 1 index /RealFormat get def + +/.setpagedevice where + { pop + /setdefaulttimeouts + { exch mark /ManualFeedTimeout 3 -1 roll + /Policies mark /ManualFeedTimeout 1 .dicttomark + .dicttomark setpagedevice + /WaitTimeout exch mark /JobTimeout 5 2 roll .dicttomark setsystemparams + } bind def + /setmargins + { exch 2 array astore /Margins .dict1 setpagedevice + } bind def + } +if +%setpagestackorder +dup /PrinterName known + { /setprintername { /PrinterName .dict1 setsystemparams } bind def + } if +currentuserparams /WaitTimeout known + { /waittimeout { /WaitTimeout getuserparam } bind def + } if + +/.setpagedevice where + { pop + /pagemargin + { currentpagedevice /PageOffset .knownget { 0 get } { 0 } ifelse + } bind def + /pageparams + { currentpagedevice + dup /Orientation .knownget { 1 and ORIENT1 { 1 xor } if } { 0 } ifelse exch + dup /PageSize get aload pop 3 index 0 ne { exch } if 3 2 roll + /PageOffset .knownget { 0 get } { 0 } ifelse 4 -1 roll + } bind def + /.setpagesize { 2 array astore /PageSize .dict1 setpagedevice } bind def + /setduplexmode { /Duplex .dict1 setpagedevice } bind def + /setpagemargin { 0 2 array astore /PageOffset .dict1 setpagedevice } bind def + /setpageparams + { mark /PageSize 6 -2 roll + 4 index 1 and ORIENT1 { 1 } { 0 } ifelse ne { exch } if 2 array astore + /Orientation 5 -1 roll ORIENT1 { 1 xor } if + /PageOffset counttomark 2 add -1 roll 0 2 array astore + .dicttomark setpagedevice + } bind def + /setresolution + { dup 2 array astore /HWResolution .dict1 setpagedevice + } bind def + } +if + +pop % currentsystemparams + +% Flag the current dictionary so it will be swapped when we +% change language levels. (See zmisc2.c for more information.) +/statusdict currentdict def + +currentdict end +/statusdict exch def + +% ------ Color spaces ------ % + +% Define the setcolorspace procedures: +% proc +/colorspacedict mark + /DeviceGray { pop 0 setgray null } bind + /DeviceRGB { pop 0 0 0 setrgbcolor null } bind + /setcmykcolor where + { pop /DeviceCMYK { pop 0 0 0 1 setcmykcolor null } bind + } if + /.setcieaspace where + { pop /CIEBasedA { NOCIE { pop 0 setgray null } { dup 1 get .setcieaspace } ifelse } bind + } if + /.setcieabcspace where + { pop /CIEBasedABC { NOCIE { pop 0 0 0 setrgbcolor null } { dup 1 get .setcieabcspace } ifelse } bind + } if + /.setciedefspace where + { pop /CIEBasedDEF { NOCIE { pop 0 0 0 setrgbcolor null } { dup 1 get .setciedefspace } ifelse } bind + } if + /.setciedefgspace where + { pop /CIEBasedDEFG { NOCIE { pop 0 0 0 1 setcmykcolor null } { dup 1 get .setciedefgspace } ifelse } bind + } if + /.setseparationspace where + { pop /Separation { dup 2 get setcolorspace dup .setseparationspace } bind + } if + /.setindexedspace where + { pop /Indexed { dup 1 get setcolorspace dup .setindexedspace } bind + } if + /.nullpatternspace [/Pattern] readonly def + /.setpatternspace where + { pop /Pattern + { dup type /nametype eq { pop //.nullpatternspace } if + dup length 1 gt { dup 1 get setcolorspace } if + dup .setpatternspace + } bind + } if + currentdict /.nullpatternspace .undef +.dicttomark def + +/.devcs [/DeviceGray /DeviceRGB /DeviceCMYK] readonly def +/currentcolorspace { % - currentcolorspace + .currentcolorspace dup type /integertype eq { + //.devcs exch 1 getinterval + } if +} odef +currentdict /.devcs .undef + +/setcolorspace { % setcolorspace - + dup dup dup type /nametype ne { 0 get } if + //colorspacedict exch get exec + dup null eq { pop } { .setcolorspace } ifelse pop +} odef + +% ------ CIE color rendering ------ % + +/setcolorrendering where { pop } { (%END CRD) .skipeof } ifelse + +% Initialize the CIE rendering dictionary if necessary. +% The most common CIE files seem to assume the "calibrated RGB color space" +% described on p. 189 of the PostScript Language Reference Manual, +% 2nd Edition; we simply invert this transformation back to RGB. +mark + /ColorRenderingType 1 +% We must make RangePQR and RangeLMN large enough so that values computed by +% the assumed encoding MatrixLMN don't get clamped. + /RangePQR [0 0.9505 0 1 0 1.0890] + /TransformPQR [ { 4 { exch pop } repeat } dup dup ] + /RangeLMN [0 0.9505 0 1 0 1.0890] + /MatrixABC + [ 3.24063 -0.96893 0.05571 + -1.53721 1.87576 -0.20402 + -0.49863 0.04152 1.05700 + ] + /EncodeABC [{0 max 0.45 exp} bind dup dup] + /WhitePoint [0.9505 1 1.0890] + % Some Genoa tests seem to require the presence of BlackPoint. + /BlackPoint [0 0 0] +.dicttomark setcolorrendering + +% Define findcolorrendering and a default ColorRendering ProcSet. + +/findcolorrendering { % findcolorrendering + % + /ColorRendering /ProcSet findresource + 1 index .namestring (.) concatstrings + 1 index /GetPageDeviceName get exec .namestring (.) concatstrings + 2 index /GetHalftoneName get exec .namestring + concatstrings concatstrings + dup /ColorRendering resourcestatus { + pop pop exch pop exch pop true + } { + pop /GetSubstituteCRD get exec false + } ifelse +} odef + +5 dict dup begin + +/GetPageDeviceName { % - GetPageDeviceName + currentpagedevice dup /PageDeviceName .knownget { + exch pop + } { + pop /none + } ifelse +} bind def + +/GetHalftoneName { % - GetHalftoneName + currenthalftone /HalftoneName .knownget not { /none } if +} bind def + +/GetSubstituteCRD { % GetSubstituteCRD + pop /DefaultColorRendering +} bind def + +end +% The resource machinery hasn't been activated, so just save the ProcSet +% and let .fixresources finish the installation process. +/ColorRendering exch def + +%END CRD + +% ------ Painting ------ % + +% A straightforward definition of execform that doesn't actually +% do any caching. +/.execform1 + { % This is a separate operator so that the stacks will be restored + % properly if an error occurs. + dup /Implementation known not + { dup /FormType get 1 ne { /rangecheck signalerror } if + dup /Implementation null put readonly + } if + dup /Matrix get concat + dup /BBox get aload pop + exch 3 index sub exch 2 index sub rectclip + dup /PaintProc get exec + } odef +/execform %
    execform - + { gsave { .execform1 } stopped grestore { stop } if + } odef + +/makepattern { % makepattern + 1 index dup length 1 add currentglobal + { false setglobal dict .copydict 1 index .buildpattern true setglobal } + { dict .copydict 1 index .buildpattern } + ifelse + 1 index /Implementation 3 -1 roll put + readonly exch pop exch pop +} odef + +/setpattern { % [ ...] setpattern - + currentcolorspace 0 get /Pattern ne { + [ /Pattern currentcolorspace ] setcolorspace + } if setcolor +} odef + +end % level2dict diff --git a/gs/lib/gs_mex_e.ps b/gs/lib/gs_mex_e.ps new file mode 100644 index 000000000..45baf92f7 --- /dev/null +++ b/gs/lib/gs_mex_e.ps @@ -0,0 +1,65 @@ +% Copyright (C) 1994 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% Define the MacExpert encoding vector. +/currentglobal where + { pop currentglobal { setglobal } true setglobal } + { { } } +ifelse +/MacExpertEncoding +% \00x + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% \04x + /space /exclamsmall /Hungarumlautsmall /centoldstyle /dollaroldstyle /dollarsuperior /ampersandsmall /Acutesmall + /parenleftsuperior /parenrightsuperior /twodotenleader /onedotenleader /comma /hyphen /period /fraction + /zerooldstyle /oneoldstyle /twooldstyle /threeoldstyle /fouroldstyle /fiveoldstyle /sixoldstyle /sevenoldstyle + /eightoldstyle /nineoldstyle /colon /semicolon /.notdef /threequartersemdash /.notdef /questionsmall +% \10x + /.notdef /.notdef /.notdef /.notdef /Ethsmall /.notdef /.notdef /onequarter + /onehalf /threequarters /oneeighth /threeeighths /fiveeighths /seveneighths /onethird /twothirds + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /ff /fi + /fl /ffi /ffl /parenleftinferior /.notdef /parenrightinferior /Circumflexsmall /hypheninferior +% \14x + /Gravesmall /Asmall /Bsmall /Csmall /Dsmall /Esmall /Fsmall /Gsmall + /Hsmall /Ismall /Jsmall /Ksmall /Lsmall /Msmall /Nsmall /Osmall + /Psmall /Qsmall /Rsmall /Ssmall /Tsmall /Usmall /Vsmall /Wsmall + /Xsmall /Ysmall /Zsmall /colonmonetary /onefitted /rupiah /Tildesmall /.notdef +% \20x + /.notdef /asuperior /centsuperior /.notdef /.notdef /.notdef /.notdef /Aacutesmall + /Agravesmall /Acircumflexsmall /Adieresissmall /Atildesmall /Aringsmall /Ccedillasmall /Eacutesmall /Egravesmall + /Ecircumflexsmall /Edieresissmall /Iacutesmall /Igravesmall /Icircumflexsmall /Idieresissmall /Ntildesmall /Oacutesmall + /Ogravesmall /Ocircumflexsmall /Odieresissmall /Otildesmall /Uacutesmall /Ugravesmall /Ucircumflexsmall /Udieresissmall +% \24x + /.notdef /eightsuperior /fourinferior /threeinferior /sixinferior /eightinferior /seveninferior /Scaronsmall + /.notdef /centinferior /twoinferior /.notdef /Dieresissmall /.notdef /Caronsmall /osuperior + /fiveinferior /.notdef /commainferior /periodinferior /Yacutesmall /.notdef /dollarinferior /.notdef + /.notdef /Thornsmall /.notdef /nineinferior /zeroinferior /Zcaronsmall /AEsmall /Oslashsmall +% \30x + /questiondownsmall /oneinferior /Lslashsmall /.notdef /.notdef /.notdef /.notdef /.notdef + /.notdef /Cedillasmall /.notdef /.notdef /.notdef /.notdef /.notdef /OEsmall + /figuredash /hyphensuperior /.notdef /.notdef /.notdef /.notdef /exclamdownsmall /.notdef + /Ydieresissmall /.notdef /onesuperior /twosuperior /threesuperior /foursuperior /fivesuperior /sixsuperior +% \34x + /sevensuperior /ninesuperior /zerosuperior /.notdef /esuperior /rsuperior /tsuperior /.notdef + /.notdef /isuperior /ssuperior /dsuperior /.notdef /.notdef /.notdef /.notdef + /.notdef /lsuperior /Ogoneksmall /Brevesmall /Macronsmall /bsuperior /nsuperior /msuperior + /commasuperior /periodsuperior /Dotaccentsmall /Ringsmall /.notdef /.notdef /.notdef /.notdef +256 packedarray .defineencoding +exec diff --git a/gs/lib/gs_mro_e.ps b/gs/lib/gs_mro_e.ps new file mode 100644 index 000000000..6cd59cbc2 --- /dev/null +++ b/gs/lib/gs_mro_e.ps @@ -0,0 +1,58 @@ +% Copyright (C) 1994 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% Define the MacRoman encoding vector. +/currentglobal where + { pop currentglobal { setglobal } true setglobal } + { { } } +ifelse +/MacRomanEncoding +StandardEncoding 0 39 getinterval aload pop + /quotesingle +StandardEncoding 40 56 getinterval aload pop + /grave +StandardEncoding 97 31 getinterval aload pop +% \20x + /Adieresis /Aring /Ccedilla /Eacute /Ntilde /Odieresis /Udieresis /aacute + /agrave /acircumflex /adieresis /atilde /aring /ccedilla /eacute /egrave + /ecircumflex /edieresis /iacute /igrave + /icircumflex /idieresis /ntilde /oacute + /ograve /ocircumflex /odieresis /otilde + /uacute /ugrave /ucircumflex /udieresis +% \24x + /dagger /degree /cent /sterling /section /bullet /paragraph /germandbls + /registered /copyright /trademark /acute /dieresis /.notdef /AE /Oslash + /.notdef /plusminus /.notdef /.notdef /yen /mu /.notdef /.notdef + /.notdef /.notdef /.notdef /ordfeminine /ordmasculine /.notdef /ae /oslash +% \30x + /questiondown /exclamdown /logicalnot /.notdef + /florin /.notdef /.notdef /guillemotleft + /guillemotright /ellipsis /space /Agrave /Atilde /Otilde /OE /oe + /endash /emdash /quotedblleft /quotedblright + /quoteleft /quoteright /divide /.notdef + /ydieresis /Ydieresis /fraction /currency + /guilsingleft /guilsingright /fi /fl +% \34x + /daggerdbl /periodcentered /quotesinglbase /quotedblbase + /perthousand /Acircumflex /Ecircumflex /Aacute + /Edieresis /Egrave /Iacute /Icircumflex + /Idieresis /Igrave /Oacute /Ocircumflex + /.notdef /Ograve /Uacute /Ucircumflex + /Ugrave /dotlessi /circumflex /tilde + /macron /breve /dotaccent /ring /cedilla /hungarumlaut /ogonek /caron +256 packedarray .defineencoding +exec diff --git a/gs/lib/gs_pdf.ps b/gs/lib/gs_pdf.ps new file mode 100644 index 000000000..3798278ac --- /dev/null +++ b/gs/lib/gs_pdf.ps @@ -0,0 +1,646 @@ +% Copyright (C) 1994, 1996, 1997 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% gs_pdf.ps +% ProcSet for PostScript files created by the PDF to PostScript converter. +% This ProcSet requires only a Level 1 interpreter, unless fonts other +% than ordinary Type 1 or Type 3 fonts are involved. + +% pdf2ps copies this file from %BEGIN to the end. + +%BEGIN +% Patches for Level 1 printers and non-Ghostscript interpreters. +mark +/currentglobal { false } +/setglobal { pop } +/packedarray { array astore readonly } +/setcmykcolor { + 1 exch sub + 4 -1 roll 1 exch sub 1 index mul + 4 -1 roll 1 exch sub 2 index mul + 4 -2 roll exch 1 exch sub mul + setrgbcolor +} +/sethalftonephase { pop pop } +/setpagedevice { + statusdict /pageparams get exec + 4 index /PageSize .knownget { aload pop 6 -2 roll pop pop 4 2 roll } if + 4 index /Orientation .knownget { 3 -1 roll pop exch } if + statusdict /setpageparams get exec + /PageOffset .knownget { aload pop translate } if +} +/setoverprint { pop } +/setstrokeadjust { pop } +/.copydict { dup 3 -1 roll { put dup } forall pop } +/.dicttomark { + counttomark 2 idiv dup dict begin { def } repeat pop currentdict end +} +/.knownget { 2 copy known { get true } { pop pop false } ifelse } +/.setdefaultscreen { } +counttomark 2 idiv { + 1 index where { pop pop pop } { bind executeonly def } ifelse +} repeat pop + +currentglobal true setglobal + +% Define pdfmark. Don't allow it to be bound in. +% Also don't define it in systemdict, because this leads some Adobe code +% to think this interpreter is a distiller. +% (If this interpreter really is a distiller, don't do this.) +systemdict /pdfmark known not + { userdict /pdfmark { cleartomark } bind put } if + +% This ProcSet is designed so that it can be used either to execute PDF +% (the default) or to convert PDF to PostScript. See ! and ~ below. + +userdict /GS_PDF_ProcSet 127 dict dup begin + +% ---------------- Abbreviations ---------------- % + +/bdef { bind def } bind def + +% ---------------- Operator execution ---------------- % + +% We record "operator" names in a dictionary with their argument counts, +% so that they can easily be redefined later to write PostScript in +% addition to (or instead of) being executed. + +/numargsdict 100 dict def +/! % ! - + { //numargsdict 3 index 3 -1 roll put def + } bdef +/~ % ~ - + { exch cvx 1 packedarray cvx exch ! + } bdef + +% ---------------- Graphics state stack ---------------- % + +% PDF adds a number of parameters to the graphics state. +% We implement this by pushing and popping a dictionary +% each time we do a PDF gsave or grestore. +% The keys in this dictionary are as follows: +% self % identifies the dictionary as one of ours +% Show +% TextOrigin % origin of current line, in text space +% TextSaveMatrix % matrix at time of BT +% (The following correspond directly to PDF state parameters.) +% FillColor +% FillColorSpace +% StrokeColor +% StrokeColorSpace +% TextSpacing +% TextHScaling +% Leading +% TextFont +% TextMatrix +% TextRise +% TextRenderingMode +% WordSpacing + +/nodict 1 dict def +nodict /self { //nodict } executeonly put +nodict readonly pop + +/beginpage + { //nodict 20 dict .copydict begin graphicsbeginpage textbeginpage + } bdef +/endpage + { showpage end + } bdef + +/graphicsbeginpage { initgraphics 0 g 0 G } bdef + +/gput % gput - + { exch currentdict //nodict eq { /self dup load end 5 dict begin def } if + % If we're in a Level 1 system, we need to grow the + % dictionary explicitly. + currentdict length currentdict maxlength ge %eq + { currentdict dup length 3 mul 2 idiv 1 add dict .copydict end begin + } + if def + } bdef + +/q_ + { gsave //nodict begin + } bdef +/q /q_ load 0 ! +% Some PDF files have excess Q operators! +/Q_ + { currentdict /self .knownget { exec //nodict eq { end grestore } if } if + } bdef +/Q /Q_ load 0 ! + +% ---------------- Graphics state parameters ---------------- % + +/d /setdash 2 ~ +/i /setflat 1 ~ +/j /setlinejoin 1 ~ +/J /setlinecap 1 ~ +/M /setmiterlimit 1 ~ +/w /setlinewidth 1 ~ + +% ---------------- Color setting ---------------- % + +/fcput % fcput - + { /FillColorSpace gput /FillColor gput + } bdef +/scput % scput - + { /StrokeColorSpace gput /StrokeColor gput + } bdef + +/csdevgray [/DeviceGray] readonly def +/csdevrgb [/DeviceRGB] readonly def +/csdevcmyk [/DeviceCMYK] readonly def +% Perhaps some of the values in the following need to be modified +% depending on the WhitePoint value.... +/cslabinit mark + /DecodeABC [{16 add 116 div} bind {500 div} bind {200 div} bind] + /MatrixABC [1 1 1 1 0 0 0 0 -1] + /DecodeLMN [ + {dup 6 29 div ge {dup dup mul mul} {4 29 div sub 108 841 div mul} ifelse + 0.9505 mul} bind + {dup 6 29 div ge {dup dup mul mul} {4 29 div sub 108 841 div mul} ifelse + } bind + {dup 6 29 div ge {dup dup mul mul} {4 29 div sub 108 841 div mul} ifelse + 1.0890 mul} bind + ] +.dicttomark readonly def +/nullpattern1 mark + /PatternType 1 /PaintType 1 /TilingType 3 /BBox [0 0 0 0] + /XStep 1 /YStep 1 /PaintProc { } +.dicttomark readonly def +/nullpattern2 nullpattern1 dup length dict copy readonly def + +% Each entry in the color space dictionary is a procedure of the form +% -proc- +/CSdict 11 dict dup begin + /DeviceGray { 0 exch } bdef + /DeviceRGB { [0 0 0] cvx exch } bdef + /DeviceCMYK { [0 0 0 1] cvx exch } bdef + /Indexed + { dup 1 get csset exch pop + dup 2 index 1 get eq + { pop } + { exch 4 array copy dup 1 4 -1 roll put } + ifelse 0 exch + } bdef + /CalGray + { systemdict /setcolorrendering known + { 1 get dup /Gamma .knownget + { dup length 1 add dict .copydict + dup /DecodeA 4 -1 roll /exp load 2 packedarray cvx put + } + if /CIEBasedA exch 2 array astore 0 exch + } + { pop //csdevgray csset + } + ifelse + } bdef + /CalRGB + { systemdict /setcolorrendering known + { 1 get dup /Gamma known 1 index /Matrix known or + { dup length 2 add dict .copydict + dup /Matrix .knownget { 1 index /MatrixABC 3 -1 roll put } if + dup /Gamma .knownget + { [ exch { /exp load 2 packedarray cvx } forall + ] 1 index /DecodeABC 3 -1 roll put + } + if + } + if /CIEBasedABC exch 2 array astore [0 0 0] cvx exch + } + { pop //csdevrgb csset + } + ifelse + } bdef + /CalCMYK { pop //csdevcmyk csset } bdef % not supported yet + /Lab + { systemdict /setcolorrendering known + { 1 get dup length 3 add dict .copydict + dup /Range .knownget not { [-100 100 -100 100] } if + [-100 0 null null null null] dup 2 4 -1 roll putinterval + 1 index /RangeABC 3 -1 roll put + //cslabinit exch copy + /CIEBasedABC exch 2 array astore [0 0 0] cvx exch + } + { (****** Lab color space not supported. ******\n) print flush + /setcolorspace cvx /undefined signalerror + } + ifelse + } bdef + /Pattern + { //nullpattern1 1 index type /nametype ne + { 1 index length 0 ne { pop //nullpattern2 } if + } if + matrix makepattern exch + } bdef + /Separation { 1 exch } bdef +end def +/csset % csset + { dup dup type /nametype ne { 0 get } if //CSdict exch get exec + } bdef + +/g { //csdevgray fcput } 1 ! +/G { //csdevgray scput } 1 ! +/rg { 3 array astore cvx //csdevrgb fcput } 3 ! +/RG { 3 array astore cvx //csdevrgb scput } 3 ! +/k { 4 array astore cvx //csdevcmyk fcput } 4 ! +/K { 4 array astore cvx //csdevcmyk scput } 4 ! +/cs { csset fcput } 1 ! +/CS { csset scput } 1 ! +% We have to break up sc according to the number of operands. +/sc1 { /FillColor gput } 1 ! +/SC1 { /StrokeColor gput } 1 ! +/sc2 { /FillColor gput } 2 ! +/SC2 { /StrokeColor gput } 2 ! +/sc3 { /FillColor load astore pop } 3 ! +/SC3 { /StrokeColor load astore pop } 3 ! +/sc4 { /FillColor load astore pop } 4 ! +/SC4 { /StrokeColor load astore pop } 4 ! +/sc5 { /FillColor gput } 5 ! +/SC5 { /StrokeColor gput } 5 ! + +% ---------------- Color installation ---------------- % + +% Establish a given color (and color space) as current. +/setfillcolor { FillColor FillColorSpace setgcolor } def +/setstrokecolor { StrokeColor StrokeColorSpace setgcolor } def +/CIdict mark % only used for Level 1 + /DeviceGray 1 /DeviceRGB 3 /DeviceCMYK 4 + /CIEBaseA 1 /CIEBaseABC 3 /CIEBasedDEF 3 /CIEBaseDEFG 4 +.dicttomark def +/Cdict 11 dict dup begin % -proc- - + /DeviceGray { pop setgray } bdef + /DeviceRGB { pop setrgbcolor } bdef + /DeviceCMYK { pop setcmykcolor } bdef + /CIEBasedA + { dup currentcolorspace eq { pop } { setcolorspace } ifelse setcolor } bdef + /CIEBasedABC /CIEBasedA load def + /CIEBasedDEF /CIEBasedA load def + /CIEBasedDEFG /CIEBasedA load def + /Indexed /setcolorspace where + { pop /CIEBasedA load } + { /setindexedcolor cvx } + ifelse def + /Pattern + { dup currentcolorspace eq { pop } { setcolorspace } ifelse + dup /Matrix get makepattern setcolor + } bdef + /Separation /CIEBasedA load def +end def +/setindexedcolor % [/Indexed base hival proc|str] + % setindexedcolor - (only used for Level 1) + { mark 3 -1 roll + 2 index 3 get % Stack: cspace -mark- index proc|str + dup type /stringtype eq + { //CIdict 4 index 1 get 0 get get % # of components + dup 4 -1 roll mul exch getinterval { 255 div } forall + } + { exec + } + ifelse + counttomark 2 add -2 roll pop + 1 get setgcolor + } bdef +/setgcolor % (null | ) setgcolor - + { 1 index null eq + { pop pop } + { dup 0 get //Cdict exch get exec } + ifelse + } bdef +/fsexec % fsexec - + { % Preserve the current point, if any. + { currentpoint } stopped + { $error /newerror false put cvx exec } + { 3 -1 roll cvx exec moveto } + ifelse + } bdef + +% ---------------- Transformations ---------------- % + +/cmmatrix matrix def +/cm { //cmmatrix astore concat } 6 ! + +% ---------------- Path creation ---------------- % + +/m /moveto 2 ~ +/l /lineto 2 ~ +/c /curveto 6 ~ +/h /closepath 0 ~ +/v { currentpoint 6 2 roll curveto } 4 ! +/y { 2 copy curveto } 4 ! +/re + { 4 2 roll moveto exch dup 0 rlineto 0 3 -1 roll rlineto neg 0 rlineto + closepath + } 4 ! + +% ---------------- Path painting and clipping ---------------- % + +/S_ { setstrokecolor /stroke fsexec } bdef +/S { S_ } 0 ! +/f { setfillcolor /fill fsexec } 0 ! +/f* { setfillcolor /eofill fsexec } 0 ! +/n_ { newpath } bdef % don't allow n_ to get bound in +/n { n_ } 0 ! +/s { closepath S_ } 0 ! +/B_ { gsave setfillcolor fill grestore S_ } bdef +/B /B_ load 0 ! +/b { closepath B_ } 0 ! +/B*_ { gsave setfillcolor eofill grestore S_ } bdef +/B* /B*_ load 0 ! +/b* { closepath B*_ } 0 ! + +% Clipping: + +/Wdict 4 dict dup begin +/S_ { gsave setstrokecolor stroke grestore n_ } bdef +/f { gsave setfillcolor fill grestore n_ } 0 ! +/f* { gsave setfillcolor eofill grestore n_ } 0 ! +/n_ { end clip newpath } bdef +end readonly def +/W { //Wdict begin } 0 ! +/W*dict 4 dict dup begin +/S_ { gsave setstrokecolor stroke grestore n_ } bdef +/f { gsave setfillcolor fill grestore n_ } 0 ! +/f* { gsave setfillcolor eofill grestore n_ } 0 ! +/n_ { end eoclip newpath } bdef +end readonly def +/W* { //W*dict begin } 0 ! + +% ---------------- Images ---------------- % + +% We mustn't bind these now, since they reference Level 2 operators. +/Is % Is + { dup /DataSource get string /readstring cvx /currentfile cvx + % Stack: imagedict string -readstring- -currentfile- + 3 index /FilterProc .knownget + { dup dup 0 get /ASCIIHexDecode eq exch length 2 eq and + { pop exch pop /readhexstring cvx exch } + { exch exec exch exec } + ifelse + } + if 3 1 roll /pop cvx 4 packedarray cvx + } bdef +/EI { } def % placeholder, only needed when writing PostScript +% Note that ID* take a dictionary, not separate values; +% ColorSpace must be a name if it has no parameters; +% DataSource is the size of the row buffer in bytes; +% FilterProc is an optional procedure for constructing the decoding filter; +% and ImageMask is required, not optional. +/csimage + { /setcolorspace where + { pop dup /ColorSpace get csset setcolorspace pop image } + { .colorspaceimage } + ifelse + } def % don't bind, because of Level 2 +/ID % ID - + { Is dup 3 -1 roll dup /ImageMask get + { setfillcolor dup /Interpolate .knownget not { false } if + { dup /DataSource 4 -1 roll put /imagemask cvx exec + } + { { /Width /Height /Decode /ImageMatrix } + { 1 index exch get exch } + forall pop exch 0 get 0 ne exch + 5 -1 roll imagemask + } + ifelse + } + { dup /ColorSpace get /DeviceGray eq + 1 index /BitsPerComponent get 8 le and + 1 index /Decode get dup 1 get 1 eq exch 0 get 0 eq and and + 1 index /Interpolate .knownget not { false } if not and + { { /Width /Height /BitsPerComponent /ImageMatrix } + { 1 index exch get exch } + forall pop 5 -1 roll image + } + { dup /DataSource 4 -1 roll put csimage + } + ifelse + } + ifelse + % If we were reading with readhexstring, + % skip the terminating > now. + % Stack: datasource + dup type /filetype ne % array or packedarray + { dup 2 get /readhexstring eq + { { dup 0 get exec read pop (>) 0 get eq { exit } if } loop + } + if pop + } + { pop + } + ifelse EI + } 1 ! +% IDx handles general images. +/IDx % IDx - + { Is 1 index /DataSource 3 -1 roll put + csimage EI + } 1 ! + +% ---------------- Text control ---------------- % + +/textbeginpage + { /TextSpacing 0 def % 0 Tc + /TextLeading 0 def % 0 TL + /TextRenderingMode 0 def % 0 Tr + /TextRise 0 def % 0 Ts + /WordSpacing 0 def % 0 Tw + /TextHScaling 1.0 def % 100 Tz + /TextFont null def + /Show { showfirst } def + } bdef + +% Contrary to the statement in the PDF manual, BT and ET *can* be nested, +% if the CharProc for a Type 3 font does a BT/ET itself. +% Since we always call the CharProc inside a q_/Q_, we simply ensure that +% the text state is saved and restored like the rest of the extended +% graphics state. + +/settextmatrix + { TextMatrix concat + TextHScaling 1 ne { TextHScaling 1 scale } if + TextRise 0 ne { 0 TextRise translate } if + } bdef +/settextstate { TextSaveMatrix setmatrix settextmatrix } bdef + +/BT + { currentdict /TextMatrix .knownget + { identmatrix pop } + { matrix /TextMatrix gput } + ifelse + currentdict /TextOrigin .knownget + { dup 0 0 put 1 0 put } + { [0 0] cvx /TextOrigin gput } + ifelse + { showfirst } /Show gput + currentdict /TextSaveMatrix .knownget not + { matrix dup /TextSaveMatrix gput } + if currentmatrix pop settextmatrix 0 0 moveto + TextFont dup null eq { pop } { setfont } ifelse + } bind 0 ! +/ET + { TextSaveMatrix setmatrix + } bind 0 ! +/Tc_ { /TextSpacing gput { showfirst } /Show gput } bdef +/Tc { Tc_ } 1 ! +/TL { /TextLeading gput } bind 1 ! +/Tr { /TextRenderingMode gput { showfirst } /Show gput } bind 1 ! +/Ts { /TextRise gput settextstate } bind 1 ! +/Tw_ { /WordSpacing gput { showfirst } /Show gput } bdef +/Tw { Tw_ } 1 ! +/Tz { 100 div /TextHScaling gput settextstate } bind 1 ! + +% ---------------- Font control ---------------- % + +/Tf % Tf - + { dup 1 eq { pop } { scalefont } ifelse + dup setfont /TextFont gput + } 2 ! + +% Read a CFF font. +/FRD % FRD - + { /FontSetInit /ProcSet findresource begin ReadData + } 2 ! + +% Copy a font, removing its FID. If changed is true, also remove +% the UniqueID and XUID, if any. If the original dictionary doesn't have +% the keys being removed, don't copy it. +/.copyfontdict % .copyfontdict + { 1 index /FID known + 1 index { 2 index /UniqueID known or 2 index /XUID known or } if + { % We add 1 to the length just in case the original + % didn't have a FID. + exch dup length 1 add dict exch + { % Stack: changed newfont key value + 1 index /FID eq 4 index + { 2 index /UniqueID eq or 2 index /XUID eq or } + if not { 3 copy put } if pop pop + } + forall exch + } + if pop + } bdef + +% Insert a new Encoding or Metrics into a font if necessary. +% Return a possibly updated font, and a flag to indicate whether +% the font was actually copied. +/.updatefont % .updatefont + % + { 2 index 4 1 roll + dup null ne + { 3 -1 roll true .copyfontdict dup /Metrics 4 -1 roll put exch } + { pop } + ifelse + dup null ne 1 index 3 index /Encoding get ne and + { exch false .copyfontdict dup /Encoding 4 -1 roll put } + { pop } + ifelse exch 1 index ne + } bdef + +% ---------------- Text positioning ---------------- % + +/Td_ + { TextOrigin exch 4 -1 roll add 3 1 roll add + 2 copy /TextOrigin load astore pop moveto + } bdef +/Td { Td_ } 2 ! +/TD { dup neg /TextLeading gput Td_ } 2 ! +/T*_ { 0 TextLeading neg Td_ } bdef +/T* { T*_ } 0 ! +/Tm + { TextMatrix astore pop settextstate + 0 0 /TextOrigin load astore pop + 0 0 moveto + } 6 ! + +% ---------------- Text painting ---------------- % + +/textrenderingprocs [ % (0 is handled specially) + { tf } { tS } { tB } { tn } + % We don't know what the clipping modes mean.... + 4 copy +] readonly def +/setshowstate + { WordSpacing 0 eq TextSpacing 0 eq and + { TextRenderingMode 0 eq + { { setfillcolor show } } + { { false charpath textrenderingprocs TextRenderingMode get exec } } + ifelse + } + { TextRenderingMode 0 eq + { WordSpacing 0 eq + { { setfillcolor TextSpacing exch 0 exch ashow } } + { TextSpacing 0 eq + { { setfillcolor WordSpacing exch 0 exch 32 exch widthshow } } + { { setfillcolor WordSpacing exch TextSpacing exch 0 32 4 2 roll 0 exch awidthshow } } + ifelse + } + ifelse + } + { { WordSpacing TextSpacing 2 index + % Implement the combination of t3 and false charpath. + % Stack: xword xchar string + 0 1 2 index length 1 sub + { 2 copy 1 getinterval false charpath + % Stack: xword xchar string i + 4 copy get 32 eq { add } { exch pop } ifelse 0 rmoveto + pop + } + for pop pop pop pop + textrenderingprocs TextRenderingMode get exec + } + } + ifelse + } + ifelse /Show gput + } bdef +/showfirst { setshowstate Show } def + +/Tj { Show } 1 ! +/' { T*_ Show } 1 ! +/" { exch Tc_ exch Tw_ T*_ Show } 3 ! +% TJ expects a mark followed by arguments, not an array. +/TJ + { counttomark -1 1 + { -1 roll dup type /stringtype eq + { Show + } + { -1000 div + currentfont /ScaleMatrix .knownget { 0 get mul } if + 0 rmoveto + } + ifelse + } + for pop +% Adobe implementations don't accept /[, so we don't either. + } ([) cvn ! + +/tf { setfillcolor currentpoint fill moveto } bdef +/tn { currentpoint newpath moveto } bdef +% For stroking characters, temporarily restore the graphics CTM so that +% the line width will be transformed properly. +/Tmatrix matrix def +/tS + { setstrokecolor + currentpoint //Tmatrix currentmatrix TextSaveMatrix setmatrix stroke + setmatrix moveto + } bdef +/tB { gsave tf grestore tS } bdef + +end readonly put % GS_PDF_ProcSet + +setglobal diff --git a/gs/lib/gs_pdf_e.ps b/gs/lib/gs_pdf_e.ps new file mode 100644 index 000000000..c0c935653 --- /dev/null +++ b/gs/lib/gs_pdf_e.ps @@ -0,0 +1,45 @@ +% Copyright (C) 1994, 1997 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% Define the PDFDoc encoding vector. +/currentglobal where + { pop currentglobal { setglobal } true setglobal } + { { } } +ifelse +/PDFDocEncoding +ISOLatin1Encoding 0 24 getinterval aload pop + /breve /caron /circumflex /dotaccent /hungarumlaut /ogonek /ring /tilde +ISOLatin1Encoding 32 7 getinterval aload pop + /quotesingle +ISOLatin1Encoding 40 5 getinterval aload pop + /hyphen +ISOLatin1Encoding 46 50 getinterval aload pop + /grave +ISOLatin1Encoding 97 31 getinterval aload pop +% \20x + /bullet /dagger /daggerdbl /ellipsis /emdash /endash /florin /fraction + /guilsinglleft /guilsinglright /minus /perthousand + /quotedblbase /quotedblleft /quotedblright /quoteleft + /quoteright /quotesinglbase /trademark /fi /fl /Lslash /OE /Scaron + /Ydieresis /Zcaron /dotlessi /lslash /oe /scaron /zcaron /.notdef +% \24x + /.notdef +ISOLatin1Encoding 161 12 getinterval aload pop + /.notdef +ISOLatin1Encoding 174 82 getinterval aload pop +256 packedarray .defineencoding +exec diff --git a/gs/lib/gs_pdfwr.ps b/gs/lib/gs_pdfwr.ps new file mode 100644 index 000000000..e4b079aac --- /dev/null +++ b/gs/lib/gs_pdfwr.ps @@ -0,0 +1,377 @@ +% Copyright (C) 1996, 1997 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% gs_pdfwr.ps +% PDF writer additions to systemdict. + +% This file should be included iff the pdfwrite "device" is included +% in the executable. + +% Redefine pdfmark to pass the data to the driver. +% We use a pseudo-parameter named /pdfmark whose value is an array: +% key1 value1 ... CTM /type +/.pdf===dict mark + /arraytype + { dup xcheck { ({) (}) } { ([) (]) } ifelse + % Stack: file obj left right + 4 1 roll 2 index exch writestring () exch + { exch 2 index exch writestring + 1 index exch pdfmark===only ( ) + } + forall pop exch writestring + } bind + /packedarraytype 1 index + /dicttype + { 1 index (<<\n) writestring + { 2 index 3 -1 roll pdfmark===only 1 index ( ) writestring + 1 index exch pdfmark===only dup (\n) writestring + } + forall (>>) writestring + } bind +.dicttomark readonly def +/pdfmark===only % pdfmark===only - + { .pdf===dict 1 index type .knownget { exec } { write==only } ifelse + } bind def +/.pdfcvs % .pdfcvs + { % We can't handle long values yet. + =string /NullEncode filter dup 2 index pdfmark===only + dup (\n\000) writestring closefile pop + =string (\n\000) search + { dup length string copy exch pop exch pop } + { % The converted representation didn't fit. Punt. + pop (???) + } + ifelse + } bind def +/.pdfputparams % .pdfputparams + { currentdevice null false mark 6 -2 roll exch + % Don't allow the page device to get cleared.... + {.putdeviceparams} 0 get .currentpagedevice pop {.setpagedevice} 0 get + 3 array astore cvx exec + } bind def +/pdfmark % -mark- ... pdfmark - + { counttomark 1 add copy + matrix currentmatrix .pdfcvs exch ] + 1 2 2 index length 3 sub { 2 copy 2 copy get .pdfcvs put pop } for + /pdfmark .pdfputparams + type /booleantype ne { cleartomark } if cleartomark + } odef +userdict /pdfmark .undef + +% Define setdistillerparams / currentdistillerparams. +% Distiller parameters are currently treated as device parameters. +/.distillerparamkeys mark + % General parameters + /ASCII85EncodePages { } + /AutoRotatePages { } + /CompatibilityLevel { } + /CompressPages { } + /CoreDistVersion { } + /DoThumbnails { } + /ImageMemory { } + /LZWEncodePages { } + /PreserveHalftoneInfo { } + /PreserveOPIComments { } + /PreserveOverprintSettings { } + /TransferFunctionInfo { } + /UCRandBGInfo { } + /UseFlateCompression { } + % Color sampled image parameters + /ColorACSDict { } + /AntiAliasColorImages { } + /AutoFilterColorImages { } + /ColorImageDepth { } + /ColorImageDict { } + /DownsampleColorImages { } + /ColorImageDownsampleType { } + /EncodeColorImages { } + /ColorImageFilter { } + /ColorImageResolution { } + /ColorConversionStrategy { } + /ConvertCMYKImagesToRGB { } + /ConvertImagesToIndexed { } + % Grayscale sampled image parameters + /GrayACSDict { } + /AntiAliasGrayImages { } + /AutoFilterGrayImages { } + /GrayImageDepth { } + /GrayImageDict { } + /DownsampleGrayImages { } + /GrayImageDownsampleType { } + /EncodeGrayImages { } + /GrayImageFilter { } + /GrayImageResolution { } + % Monochrome sampled image parameters + /AntiAliasMonoImages { } + /MonoImageDepth { } + /MonoImageDict { } + /DownsampleMonoImages { } + /MonoImageDownsampleType { } + /EncodeMonoImages { } + /MonoImageFilter { } + /MonoImageResolution { } + % Font embedding parameters + /AlwaysEmbed + { dup length 0 gt + { dup 0 get false eq + { dup length 1 sub 1 exch getinterval exch pop /~AlwaysEmbed exch + } if + } if + } + /NeverEmbed + { dup length 0 gt + { dup 0 get false eq + { dup length 1 sub 1 exch getinterval exch pop /~NeverEmbed exch + } if + } if + } + /EmbedAllFonts { } + /SubsetFonts { } + /MaxSubsetPct { } +.dicttomark readonly def +/.distillerdevice + { currentdevice .devicename /pdfwrite eq + { currentdevice } + { /pdfwrite finddevice } + ifelse + } bind def +/setdistillerparams % setdistillerparams - + { .distillerdevice null false mark 4 index + { //.distillerparamkeys 2 index .knownget { exec } { pop pop } ifelse } + forall .putdeviceparams + type /booleantype eq { pop } { cleartomark pop pop pop } ifelse pop + } odef +/currentdistillerparams % - currentdistillerparams + { .distillerdevice //.distillerparamkeys .getdeviceparams .dicttomark + } odef + +% Patch the 'show' operators to pass the data to the device. +% We use a pseudo-parameter named /show whose value is a dictionary: +% /String (str) +% /Values [cx cy char ax ay px py] +% /FontName /fontname +% /Matrix [xx xy yx yy tx ty] +% /Encoding [e0 .. e255] +% (optional, omitted if Encoding = BaseEncoding = StandardEncoding) +% /BaseEncoding [e0 ... e255] (optional, ditto) +% /CharStrings << charnames => anything >> (optional) +% Note that the cx/y and ax/y values are in text space, not user space. +% We also fill an empty path in order to get the clipping region and +% current color set properly. THIS IS A BIG HACK. +/.pdfknownfonts mark + /Courier {StandardEncoding} + /Courier-Bold 1 index + /Courier-Oblique 1 index + /Courier-BoldOblique 1 index + /Helvetica 1 index + /Helvetica-Bold 1 index + /Helvetica-Oblique 1 index + /Helvetica-BoldOblique 1 index + /Times-Roman 1 index + /Times-Bold 1 index + /Times-Italic 1 index + /Times-BoldItalic 1 index + /Symbol {SymbolEncoding} + /ZapfDingbats {DingbatsEncoding} +.dicttomark readonly def +.currentglobal false .setglobal +/.pdfknownids 50 dict def +.setglobal +/.findorigfont { % .findorigfont + % Check for a known font with the same name, + % or one of the 14 known names, + % and the same UniqueID. + dup /UniqueID .knownget { + .pdfknownids 1 index .knownget { + exch pop dup null ne { true } { pop false } ifelse + } { % We haven't looked up the UniqueID yet. + % Register the UniqueIDs of all fonts. + .FontDirectory { + exch pop dup /UniqueID .knownget { + % Stack: font uniqueid somefont somefontid + exch .pdfknownids 3 1 roll put + } { + pop + } ifelse + } forall + % Register the UniqueIDs of the 14 built-in fonts, + % to make sure they override any other fonts + % with the same UniqueIDs. + .pdfknownfonts { + pop + //systemdict /GlobalFontDirectory .knownget not { .FontDirectory } if + 1 index .knownget { + % Stack: font uniqueid knownname knownfont + dup /UniqueID get exch .pdfknownids 3 1 roll put + } if pop + } forall + % Now see if the UniqueID is known. + .pdfknownids 1 index .knownget { + exch pop true + } { % Record the UniqueID as not registered. + .pdfknownids exch null put false + } ifelse + } ifelse + } { % This font has no UniqueID. + false + } ifelse + % Stack: font knownfont -true- | font -false- + { + exch pop + } { + { dup /OrigFont .knownget not { exit } if exch pop } loop + } ifelse +} .bind def +/setvmthreshold where { pop 1000000 setvmthreshold } if +/.pdfdoshow % .pdfdoshow + % + { mark /String 8 2 roll +%vmstatus pop =only pop (, ) print + currentpoint transform 7 array astore /Values exch + currentfont .findorigfont + % Pass the original font name. + dup /FontName get + /FontName exch 3 -1 roll + % Concatenate the "quotient" of the current FontMatrix + % and the FontMatrix of the original font. + % Be sure to include any translation. + /Matrix + exch /FontMatrix get matrix invertmatrix + currentfont /FontMatrix get 1 index concatmatrix + % The matrix on the stack is now the font scaling matrix. + % Use it to inverse-transform cx/y and ax/y, so they will be in + % text space. + % Stack: mark /String /Values /FontName + % /Matrix + 4 index aload + % ... cx cy char ax ay px py values + 8 -2 roll 8 index idtransform 8 2 roll + 5 -2 roll 8 index idtransform 5 2 roll + astore pop + % Now construct the combined matrix. + matrix currentmatrix dup 4 0 put dup 5 0 put dup concatmatrix + % Omit either encoding that is StandardEncoding. + /Encoding currentfont /Encoding .knownget not { [] } if + dup StandardEncoding eq { pop pop } if + % Make a reasonable guess at the base encoding. + /BaseEncoding .pdfknownfonts 6 index % FontName + .knownget { exec } { StandardEncoding } ifelse + dup StandardEncoding eq { + pop pop + } { + currentfont /CharStrings .knownget { /CharStrings exch } if + } ifelse +%vmstatus pop =only pop (, ) print + .dicttomark + % Set the clipping region and color in the output. + % This is another hack! + gsave newpath fill grestore +%vmstatus pop =only pop (, ) print + /show .pdfputparams +%vmstatus pop =only pop () = flush + dup type /booleantype eq + { pop pop true } + { dup /undefined eq + { cleartomark pop pop pop false } + { dup mark eq { /unknown /rangecheck } if + counttomark 4 add 1 roll cleartomark pop pop pop + /.pdfshow cvx exch signalerror + } + ifelse + } + ifelse + } .bind def +/.pdfexecshow % .pdfexecshow - + { % Prevent output, but don't switch devices, since this + % confuses the Pattern caching mechanism. + gsave currentpoint newpath clip moveto exec currentpoint + grestore moveto + } .bind def +/.pdfwrite? % - .pdfwrite? + { currentdevice .devicename /pdfwrite eq + currentfont /FontType get 1 eq and + } .bind def +% .pdfshow isn't an operator per se, but it still needs to be careful with +% the stack so that the operators will have stack protection. +/.pdfshow % + % .pdfshow - + { 7 1 roll .pdfwrite? + { .pdfdoshow } + { 6 { pop } repeat false } + ifelse + { .pdfexecshow } + { exec } + ifelse + } .bind def +/show + { dup 0 0 32 0 0 { show } .pdfshow + } .bind odef +/ashow + { dup 0 0 32 6 index 6 index { ashow } .pdfshow + } .bind odef +/widthshow + { 4 copy 4 1 roll 0 0 { widthshow } .pdfshow + } .bind odef +/awidthshow + { 6 copy 6 1 roll { awidthshow } .pdfshow + } .bind odef +/glyphshow where { pop } { (%END) .skipeof } ifelse +/glyphshow + { .pdfwrite? + { currentfont /Encoding .knownget not { {} } if + 0 1 2 index length 1 sub + { % Stack: glyph encoding index + 2 copy get 3 index eq { exch pop exch pop null exit } if pop + } + for null eq + { (X) dup 0 3 index put show pop } + { glyphshow } + ifelse + } + { glyphshow + } + ifelse + } .bind odef +%END +/.kshow1 { % .kshow1 + (X) dup 0 3 index 6 index get put show + 2 index 1 index length 1 sub lt { + dup 3 index get exch 4 -1 roll 1 add get + 3 -1 roll exec + } { + pop pop pop + } ifelse +} .bind def +/kshow { + .pdfwrite? { + % Construct a closure, and work character by character. + 0 1 2 index length 1 sub 5 -2 roll + //.kshow1 /exec cvx 4 packedarray cvx for + } { + kshow + } ifelse +} .bind odef +% The remaining operators aren't implemented correctly. +/xshow where { + pop /xshow { .pdfwrite? { 1 index show pop pop } { xshow } ifelse } .bind odef +} if +/yshow where { + pop /yshow { .pdfwrite? { 1 index show pop pop } { yshow } ifelse } .bind odef +} if +/xyshow where { + pop /xyshow { .pdfwrite? { 1 index show pop pop } { xyshow } ifelse } .bind odef +} if diff --git a/gs/lib/gs_pfile.ps b/gs/lib/gs_pfile.ps new file mode 100644 index 000000000..00190bf4c --- /dev/null +++ b/gs/lib/gs_pfile.ps @@ -0,0 +1,128 @@ +% Copyright (C) 1994, 1995 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% Runtime support for minimum-space fonts and packed files. + +% ****** NOTE: This file must be kept consistent with +% ****** packfile.ps and wrfont.ps. + +% ---------------- Packed file support ---------------- % + +% A packed file is the concatenation of several file groups, each of which +% is the result of compressing several files concatenated together. +% The packed file begins with a procedure that creates an appropriate +% decoding filter for each file group, as follows: +% -proc- +% Thus, accessing an individual file requires 4 parameters: +% the starting address and length of the outer compressed file, +% and the starting address and length of the inner file. +/.packedfilefilter % + % .packedfilefilter + { 4 index systemdict begin token pop end 6 1 roll + % Stack: fproc file ostart olength istart ilength + 4 index 5 -1 roll setfileposition + % Stack: fproc file olength istart ilength + 4 -2 roll () /SubFileDecode filter + % Stack: fproc istart ilength ofilter + 4 -1 roll exec + % Filters don't support setfileposition, so we must skip data + % by reading it into a buffer. We rely on the fact that + % save/restore don't affect file positions. + % Stack: istart ilength dfilter + save exch 1000 string + % Stack: istart ilength save dfilter scratch + 4 index 1 index length idiv { 2 copy readstring pop pop } repeat + 2 copy 0 8 -1 roll 2 index length mod getinterval readstring pop pop pop + % Stack: ilength save dfilter + exch restore exch () /SubFileDecode filter + } bind def + +% Run a packed library file. +/.runpackedlibfile % + % .runpackedlibfile + { 5 -1 roll findlibfile + { exch pop dup 6 2 roll .packedfilefilter + currentobjectformat exch 1 setobjectformat run + setobjectformat closefile + } + { 5 1 roll /findlibfile load /undefinedfilename signalerror + } + ifelse + } bind def + +% ---------------- Compacted font support ---------------- % + +% Compacted fonts written by wrfont.ps depend on the existence and +% specifications of the procedures and data in this section. + +/.compactfontdefault mark + /PaintType 0 + /FontMatrix [0.001 0 0 0.001 0 0] readonly + /FontType 1 + /Encoding StandardEncoding +.dicttomark readonly def + +/.checkexistingfont % + % .checkexistingfont + % {} ( on d-stack) + % + % .checkexistingfont + % -save- --restore-- ( on d-stack) + { FontDirectory 4 index .knownget + { dup /UniqueID .knownget + { 4 index eq exch /FontType get 1 eq and } + { pop false } + ifelse + } + { false + } + ifelse + { save /restore load 6 2 roll } + { {} 5 1 roll } + ifelse + dict //.compactfontdefault exch .copydict begin + dict /Private exch def + Private begin + /MinFeature {16 16} def + /Password 5839 def + /UniqueID 1 index def + end + /UniqueID exch def + /FontName exch def + } bind def + +/.knownEncodings [ + ISOLatin1Encoding + StandardEncoding + SymbolEncoding +] readonly def + +/.readCharStrings % .readCharStrings + { exch dup dict dup 3 -1 roll + { currentfile token pop dup type /integertype eq + { dup -8 bitshift //.knownEncodings exch get exch 255 and get } if + currentfile token pop dup type /nametype eq + { 2 index exch get + } + { % Stack: encrypt dict dict key value + 4 index { 4330 exch dup .type1encrypt exch pop } if + readonly + } + ifelse put dup + } + repeat pop exch pop + } bind def diff --git a/gs/lib/gs_res.ps b/gs/lib/gs_res.ps new file mode 100644 index 000000000..8ce478525 --- /dev/null +++ b/gs/lib/gs_res.ps @@ -0,0 +1,665 @@ +% Copyright (C) 1994, 1996, 1997 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% Initialization file for Level 2 resource machinery. +% When this is run, systemdict is still writable, +% but (almost) everything defined here goes into level2dict. + +level2dict begin + +(BEGIN RESOURCES) VMDEBUG + +% We keep track of (global) instances with another entry in the resource +% dictionary, an Instances dictionary. For categories with implicit +% instances, the values in Instances are the same as the keys; +% for other categories, the values are [instance status size]. + +% Note that the dictionary that defines a resource category is stored +% in global memory. The PostScript manual says that each category must +% manage global and local instances separately. However, objects in +% global memory other than systemdict can't reference objects in local memory. +% This means that the resource category dictionary, which would otherwise be +% the obvious place to keep track of the instances, can't be used to keep +% track of local instances. Instead, we define a dictionary in local VM +% called localinstancedict, in which the key is the category name and +% the value is the analogue of Instances for local instances. + +% We don't currently implement automatic resource unloading. +% When and if we do, it should be hooked to the garbage collector. +% However, Ed Taft of Adobe says their interpreters don't implement this +% either, so we aren't going to worry about it for a while. + +currentglobal false setglobal systemdict begin + /localinstancedict 5 dict def +end true setglobal +/.emptydict 0 dict readonly def +setglobal + +% Resource category dictionaries have the following keys (those marked with +% * are optional): +% Standard, defined in the Red Book: +% Category (name) +% *InstanceType (name) +% DefineResource +% DefineResource +% UndefineResource +% UndefineResource - +% FindResource +% FindResource +% ResourceStatus +% ResourceStatus true +% ResourceStatus false +% ResourceForAll +%